|
@@ -24,18 +24,18 @@
|
|
|
</el-form-item>
|
|
|
<el-form-item label="用户状态" prop="status">
|
|
|
<el-select
|
|
|
- v-model="queryParams.status"
|
|
|
- placeholder="请选择用户状态"
|
|
|
- clearable
|
|
|
- style="width: 240px"
|
|
|
- >
|
|
|
- <el-option
|
|
|
- v-for="item in statusOptions"
|
|
|
- :key="item.value"
|
|
|
- :label="item.label"
|
|
|
- :value="item.value">
|
|
|
- </el-option>
|
|
|
- </el-select>
|
|
|
+ v-model="queryParams.status"
|
|
|
+ placeholder="请选择用户状态"
|
|
|
+ clearable
|
|
|
+ style="width: 240px"
|
|
|
+ >
|
|
|
+ <el-option
|
|
|
+ v-for="item in statusOptions"
|
|
|
+ :key="item.value"
|
|
|
+ :label="item.label"
|
|
|
+ :value="item.value">
|
|
|
+ </el-option>
|
|
|
+ </el-select>
|
|
|
</el-form-item>
|
|
|
<el-form-item>
|
|
|
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
|
@@ -266,7 +266,8 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import { debounce } from 'lodash'
|
|
|
+import {debounce} from 'lodash'
|
|
|
+
|
|
|
export default {
|
|
|
name: "User",
|
|
|
data() {
|
|
@@ -281,11 +282,11 @@ export default {
|
|
|
remark: undefined,
|
|
|
expDate: undefined,
|
|
|
// 角色表格数据
|
|
|
- jsuserid:'',
|
|
|
+ jsuserid: '',
|
|
|
roleList: [],
|
|
|
- jsusername:'',
|
|
|
- jsnickname:'',
|
|
|
- jsusertype:'',
|
|
|
+ jsusername: '',
|
|
|
+ jsnickname: '',
|
|
|
+ jsusertype: '',
|
|
|
statusOptions: [
|
|
|
{value: '0', label: '正常'},
|
|
|
{value: '1', label: '锁定'},
|
|
@@ -330,7 +331,7 @@ export default {
|
|
|
phonenumber: undefined,
|
|
|
status: undefined
|
|
|
},
|
|
|
- edit:false,
|
|
|
+ edit: false,
|
|
|
// 表单校验
|
|
|
rules: {
|
|
|
username: [
|
|
@@ -388,17 +389,32 @@ export default {
|
|
|
}
|
|
|
return belongTo
|
|
|
},
|
|
|
+ /** 搜索按钮操作 */
|
|
|
+ handleQuery: debounce(function () {
|
|
|
+ this.getList()
|
|
|
+ }, 1000),
|
|
|
/** 查询用户列表 */
|
|
|
- getList(){
|
|
|
+ async getList() {
|
|
|
this.loading = true;
|
|
|
+ let sysTime
|
|
|
+ let lk
|
|
|
+ await this.$axios.get('/sysPolicyController/getLicenseKey').then((res) => {
|
|
|
+ sysTime = res.data.sysTime
|
|
|
+ lk = res.data.lk
|
|
|
+ }).catch((error) => {
|
|
|
+ this.loading = false;
|
|
|
+ })
|
|
|
+
|
|
|
var searchParams = {
|
|
|
currentPage: this.currentPage,
|
|
|
pageSize: this.pageSize,
|
|
|
username: this.queryParams.username,
|
|
|
phonenumber: this.queryParams.phonenumber,
|
|
|
- status: this.queryParams.status
|
|
|
+ status: this.queryParams.status,
|
|
|
+ sysTime: sysTime,
|
|
|
+ lk: lk
|
|
|
}
|
|
|
- this.$axios.get('/sysUserController/getAll',
|
|
|
+ await this.$axios.get('/sysUserController/getAll',
|
|
|
{params: searchParams}).then((res) => {
|
|
|
this.userList = res.data.records
|
|
|
this.total = res.data.total
|
|
@@ -450,10 +466,6 @@ export default {
|
|
|
};
|
|
|
// this.resetForm("form");
|
|
|
},
|
|
|
- /** 搜索按钮操作 */
|
|
|
- handleQuery:debounce(function(){
|
|
|
- this.getList()
|
|
|
- },1000),
|
|
|
/** 重置按钮操作 */
|
|
|
resetQuery() {
|
|
|
this.resetForm("queryForm");
|
|
@@ -461,18 +473,25 @@ export default {
|
|
|
/** 新增按钮操作 */
|
|
|
handleAdd() {
|
|
|
this.reset();
|
|
|
- this.edit=false;
|
|
|
+ this.edit = false;
|
|
|
this.open = true;
|
|
|
this.title = "添加用户";
|
|
|
this.form.password = this.initPassword;
|
|
|
},
|
|
|
/** 提交按钮 */
|
|
|
- submitForm:debounce(function(){
|
|
|
- this.$refs["form"].validate(valid => {
|
|
|
+ submitForm: debounce(function () {
|
|
|
+ this.$refs["form"].validate(async valid => {
|
|
|
if (valid) {
|
|
|
+ let sysTime
|
|
|
+ let lk
|
|
|
+ await this.$axios.get('/sysPolicyController/getLicenseKey').then((res) => {
|
|
|
+ sysTime = res.data.sysTime
|
|
|
+ lk = res.data.lk
|
|
|
+ }).catch((error) => {
|
|
|
+ })
|
|
|
if (this.form.id != undefined) {
|
|
|
// 更新操作
|
|
|
- this.$axios.post('/sysUserController/updateUser', this.form).then((res) => {
|
|
|
+ await this.$axios.post('/sysUserController/updateUser', this.form).then((res) => {
|
|
|
if (res.code == 0) {
|
|
|
this.$message.success('修改成功')
|
|
|
this.open = false;
|
|
@@ -488,13 +507,7 @@ export default {
|
|
|
this.loading = false
|
|
|
})
|
|
|
} else {
|
|
|
- // const param = {
|
|
|
- // username: this.form.username,
|
|
|
- // nickname: this.form.nickname,
|
|
|
- // phonenumber: this.form.phonenumber,
|
|
|
- // mailbox: this.form.mailbox
|
|
|
- // }
|
|
|
- this.$axios.post('/sysUserController/addUser', this.form).then((res) => {
|
|
|
+ await this.$axios.post('/sysUserController/addUser', this.form).then((res) => {
|
|
|
if (res.code == 0) {
|
|
|
this.$message.success('新增成功')
|
|
|
this.open = false;
|
|
@@ -512,42 +525,69 @@ export default {
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
- },1000),
|
|
|
+ }, 1000),
|
|
|
/** 重置密码按钮操作 */
|
|
|
- handleResetPwd:debounce(function(row){
|
|
|
+ handleResetPwd(row) {
|
|
|
this.$confirm('创建密码并发送到邮箱:' + row.mailbox, '提示', {
|
|
|
confirmButtonText: '确定',
|
|
|
cancelButtonText: '取消',
|
|
|
- type: 'warning'
|
|
|
- }).then(() => {
|
|
|
- const param = {
|
|
|
- id: row.id
|
|
|
- }
|
|
|
- this.$axios.post('/sysUserController/resetPassword', param).then((res) => {
|
|
|
- if (res.code == 0) {
|
|
|
- this.$message({
|
|
|
- type: 'success',
|
|
|
- message: '创建并发送成功!'
|
|
|
- });
|
|
|
+ type: 'warning',
|
|
|
+ beforeClose(action, instance, done) {
|
|
|
+ if (action === "confirm") {
|
|
|
+ instance.$refs["confirm"].$el.onclick = (function (e) {
|
|
|
+ e = e || window.event;
|
|
|
+ if (e.detail != 0) {
|
|
|
+ done();
|
|
|
+ }
|
|
|
+ })();
|
|
|
} else {
|
|
|
- this.$message({
|
|
|
- type: 'error',
|
|
|
- message: res.data
|
|
|
- });
|
|
|
+ done();
|
|
|
}
|
|
|
- }).catch((error) => {
|
|
|
+ }
|
|
|
+ }).then(() => {
|
|
|
+ this.doResetPwd(row)
|
|
|
+ }).catch(() => {
|
|
|
+ //取消操作
|
|
|
+ });
|
|
|
+ },
|
|
|
+ doResetPwd: debounce(async function (row) {
|
|
|
+ let sysTime
|
|
|
+ let lk
|
|
|
+ await this.$axios.get('/sysPolicyController/getLicenseKey').then((res) => {
|
|
|
+ sysTime = res.data.sysTime
|
|
|
+ lk = res.data.lk
|
|
|
+ }).catch((error) => {
|
|
|
+ })
|
|
|
+
|
|
|
+ const param = {
|
|
|
+ id: row.id,
|
|
|
+ sysTime: sysTime,
|
|
|
+ lk: lk
|
|
|
+ }
|
|
|
+ await this.$axios.post('/sysUserController/resetPassword', param).then((res) => {
|
|
|
+ if (res.code == 0) {
|
|
|
+ this.$message({
|
|
|
+ type: 'success',
|
|
|
+ message: '创建并发送成功!'
|
|
|
+ });
|
|
|
+ } else {
|
|
|
this.$message({
|
|
|
type: 'error',
|
|
|
- message: '创建密码失败!'
|
|
|
+ message: res.data
|
|
|
});
|
|
|
- console.log(error)
|
|
|
- this.loading = false
|
|
|
- })
|
|
|
- }).catch(() => {
|
|
|
- });
|
|
|
- },500),
|
|
|
+ }
|
|
|
+ }).catch((error) => {
|
|
|
+ this.$message({
|
|
|
+ type: 'error',
|
|
|
+ message: '创建密码失败!'
|
|
|
+ });
|
|
|
+ console.log(error)
|
|
|
+ this.loading = false
|
|
|
+ })
|
|
|
+ }, 1000),
|
|
|
+
|
|
|
/** 删除按钮操作 */
|
|
|
- handleDelete(){
|
|
|
+ handleDelete() {
|
|
|
const _selectData = this.$refs.userTable.getRadioRecord(true)
|
|
|
if (_selectData == null) {
|
|
|
this.$message({
|
|
@@ -556,36 +596,59 @@ export default {
|
|
|
});
|
|
|
return
|
|
|
}
|
|
|
- if (_selectData.id==1) {
|
|
|
+ if (_selectData.id == 1) {
|
|
|
this.$message({
|
|
|
type: 'warning',
|
|
|
message: '内置系统管理员不能删除!'
|
|
|
});
|
|
|
return
|
|
|
}
|
|
|
- this.$prompt('请输入密码','鉴别操作',{
|
|
|
+ this.$prompt('请输入密码', '鉴别操作', {
|
|
|
confirmButtonText: '确定',
|
|
|
cancelButtonText: '取消',
|
|
|
- inputType:'password',
|
|
|
- inputValidator:(val)=>{
|
|
|
- if (val===null || val.length<1 || val.length>20){
|
|
|
+ inputType: 'password',
|
|
|
+ inputValidator: (val) => {
|
|
|
+ if (val === null || val.length < 1 || val.length > 20) {
|
|
|
return false;
|
|
|
}
|
|
|
},
|
|
|
- inputErrorMessage: '不能为空,最多可录入20个字符'
|
|
|
- }).then(async({value})=>{
|
|
|
- this.doDelete(_selectData,value)
|
|
|
- }).catch((e)=>{})
|
|
|
+ inputErrorMessage: '不能为空,最多可录入20个字符',
|
|
|
+ beforeClose(action, instance, done) {
|
|
|
+ if (action === "confirm") {
|
|
|
+ instance.$refs["confirm"].$el.onclick = (function (e) {
|
|
|
+ e = e || window.event;
|
|
|
+ if (e.detail != 0) {
|
|
|
+ done();
|
|
|
+ }
|
|
|
+ })();
|
|
|
+ } else {
|
|
|
+ done();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }).then(async ({value}) => {
|
|
|
+ this.doDelete(_selectData, value)
|
|
|
+ }).catch((e) => {
|
|
|
+ })
|
|
|
},
|
|
|
/**
|
|
|
* 删除提交
|
|
|
*/
|
|
|
- doDelete:debounce(function(_selectData,againPwd){
|
|
|
+ doDelete: debounce(async function (_selectData, againPwd) {
|
|
|
+ let sysTime
|
|
|
+ let lk
|
|
|
+ await this.$axios.get('/sysPolicyController/getLicenseKey').then((res) => {
|
|
|
+ sysTime = res.data.sysTime
|
|
|
+ lk = res.data.lk
|
|
|
+ }).catch((error) => {
|
|
|
+ })
|
|
|
+
|
|
|
const param = {
|
|
|
id: _selectData.id,
|
|
|
- againPwd:againPwd
|
|
|
+ againPwd: againPwd,
|
|
|
+ sysTime: sysTime,
|
|
|
+ lk: lk
|
|
|
}
|
|
|
- this.$axios.post('/sysUserController/delUser', param).then((res) => {
|
|
|
+ await this.$axios.post('/sysUserController/delUser', param).then((res) => {
|
|
|
if (res.code == 0) {
|
|
|
this.$message({
|
|
|
type: 'success',
|
|
@@ -605,12 +668,11 @@ export default {
|
|
|
});
|
|
|
this.loading = false
|
|
|
})
|
|
|
- },500),
|
|
|
+ }, 500),
|
|
|
/** 修改按钮操作 */
|
|
|
handleUpdate() {
|
|
|
this.reset();
|
|
|
let _selectData = this.$refs.userTable.getRadioRecord(true)
|
|
|
- console.log(_selectData)
|
|
|
if (_selectData == null) {
|
|
|
this.$message({
|
|
|
type: 'warning',
|
|
@@ -621,10 +683,10 @@ export default {
|
|
|
this.form = _selectData;
|
|
|
this.open = true;
|
|
|
this.title = "修改用户";
|
|
|
- this.edit=true;
|
|
|
+ this.edit = true;
|
|
|
},
|
|
|
/** 解锁按钮操作 */
|
|
|
- handleRelock(){
|
|
|
+ handleRelock() {
|
|
|
const _selectData = this.$refs.userTable.getRadioRecord(true)
|
|
|
if (_selectData == null) {
|
|
|
this.$message({
|
|
@@ -633,7 +695,7 @@ export default {
|
|
|
});
|
|
|
return
|
|
|
}
|
|
|
- if (_selectData.status!=='1') {
|
|
|
+ if (_selectData.status !== '1') {
|
|
|
this.$message({
|
|
|
type: 'warning',
|
|
|
message: '只能对【锁定】状态的进行解锁!'
|
|
@@ -643,18 +705,40 @@ export default {
|
|
|
this.$confirm('是否解锁用户?', '提示', {
|
|
|
confirmButtonText: '确定',
|
|
|
cancelButtonText: '取消',
|
|
|
- type: 'warning'
|
|
|
+ type: 'warning',
|
|
|
+ beforeClose(action, instance, done) {
|
|
|
+ if (action === "confirm") {
|
|
|
+ instance.$refs["confirm"].$el.onclick = (function (e) {
|
|
|
+ e = e || window.event;
|
|
|
+ if (e.detail != 0) {
|
|
|
+ done();
|
|
|
+ }
|
|
|
+ })();
|
|
|
+ } else {
|
|
|
+ done();
|
|
|
+ }
|
|
|
+ }
|
|
|
}).then(() => {
|
|
|
this.doRelock(_selectData)
|
|
|
}).catch(() => {
|
|
|
+ //取消操作
|
|
|
});
|
|
|
},
|
|
|
/**
|
|
|
- * 删除提交
|
|
|
+ * 解锁提交
|
|
|
*/
|
|
|
- doRelock:debounce(function(_selectData){
|
|
|
+ doRelock: debounce(async function (_selectData) {
|
|
|
+ let sysTime
|
|
|
+ let lk
|
|
|
+ await this.$axios.get('/sysPolicyController/getLicenseKey').then((res) => {
|
|
|
+ sysTime = res.data.sysTime
|
|
|
+ lk = res.data.lk
|
|
|
+ }).catch((error) => {
|
|
|
+ })
|
|
|
const param = {
|
|
|
- id: _selectData.id
|
|
|
+ id: _selectData.id,
|
|
|
+ sysTime: sysTime,
|
|
|
+ lk: lk
|
|
|
}
|
|
|
this.$axios.post('/sysUserController/relockUser', param).then((res) => {
|
|
|
if (res.code == 0) {
|
|
@@ -677,16 +761,26 @@ export default {
|
|
|
console.log(error)
|
|
|
this.loading = false
|
|
|
})
|
|
|
- },1000),
|
|
|
- getUserRole(userid){
|
|
|
+ }, 1000),
|
|
|
+ getUserRole(userid) {
|
|
|
const a = this.$axios
|
|
|
- return new Promise(function(resolve, reject) {
|
|
|
+ return new Promise(async function (resolve, reject) {
|
|
|
+ let sysTime
|
|
|
+ let lk
|
|
|
+ await a.get('/sysPolicyController/getLicenseKey').then((res) => {
|
|
|
+ sysTime = res.data.sysTime
|
|
|
+ lk = res.data.lk
|
|
|
+ }).catch((error) => {
|
|
|
+ })
|
|
|
+
|
|
|
var userRoleParams = {
|
|
|
- userId: userid
|
|
|
+ userId: userid,
|
|
|
+ sysTime: sysTime,
|
|
|
+ lk: lk
|
|
|
}
|
|
|
- a.get('/sysUserController/getUserRole',
|
|
|
+ await a.get('/sysUserController/getUserRole',
|
|
|
{params: userRoleParams}).then(res => {
|
|
|
- // 返回userRole对象
|
|
|
+ // 返回userRole对象
|
|
|
resolve(res.data)
|
|
|
})
|
|
|
}).catch((error) => {
|
|
@@ -694,15 +788,25 @@ export default {
|
|
|
console.error('获取用户角色出错' + error)
|
|
|
})
|
|
|
},
|
|
|
- getRoleByType(usertype){
|
|
|
+ getRoleByType(usertype) {
|
|
|
// 根据用户类型获取角色列表
|
|
|
const a = this.$axios
|
|
|
let _this = this
|
|
|
- return new Promise(function(resolve, reject) {
|
|
|
+ return new Promise(async function (resolve, reject) {
|
|
|
+ let sysTime
|
|
|
+ let lk
|
|
|
+ await a.get('/sysPolicyController/getLicenseKey').then((res) => {
|
|
|
+ sysTime = res.data.sysTime
|
|
|
+ lk = res.data.lk
|
|
|
+ }).catch((error) => {
|
|
|
+ })
|
|
|
+
|
|
|
var searchParams = {
|
|
|
- usertype: usertype
|
|
|
+ usertype: usertype,
|
|
|
+ sysTime: sysTime,
|
|
|
+ lk: lk
|
|
|
}
|
|
|
- a.get('/sysRoleController/getRoleByType',
|
|
|
+ await a.get('/sysRoleController/getRoleByType',
|
|
|
{params: searchParams}).then(res => {
|
|
|
if (res.code == 0) {
|
|
|
// 返回角色列表
|
|
@@ -722,32 +826,32 @@ export default {
|
|
|
})
|
|
|
},
|
|
|
/** 分配角色操作 */
|
|
|
- handleAuthRole:debounce(function(row){
|
|
|
+ handleAuthRole: debounce(function (row) {
|
|
|
this.jsuserid = row.id
|
|
|
this.jsusername = row.username
|
|
|
this.jsnickname = row.nickname
|
|
|
this.jsopen = true;
|
|
|
this.title = "分配角色";
|
|
|
|
|
|
- Promise.all([this.getRoleByType(row.usertype),this.getUserRole(this.jsuserid)]).then((res) => {
|
|
|
- if (res[1]!='' && res[1]!=undefined){
|
|
|
+ Promise.all([this.getRoleByType(row.usertype), this.getUserRole(this.jsuserid)]).then((res) => {
|
|
|
+ if (res[1] != '' && res[1] != undefined) {
|
|
|
const roleTable = this.$refs.xTable.getTableData()
|
|
|
- for (var i=0;i<roleTable.tableData.length;i++){
|
|
|
- if (res[1].roleId==roleTable.tableData[i].roleId){
|
|
|
+ for (var i = 0; i < roleTable.tableData.length; i++) {
|
|
|
+ if (res[1].roleId == roleTable.tableData[i].roleId) {
|
|
|
// 将原有的角色勾选上
|
|
|
this.$refs.xTable.setCheckboxRow(roleTable.tableData[i], true)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- }).catch(e=>{
|
|
|
+ }).catch(e => {
|
|
|
this.loading = false
|
|
|
- this.$message.error("获取分配角色异常:"+e)
|
|
|
+ this.$message.error("获取分配角色异常:" + e)
|
|
|
})
|
|
|
- },1000),
|
|
|
+ }, 1000),
|
|
|
/** 角色分配提交按钮 */
|
|
|
- jssubmitForm:debounce(function(){
|
|
|
+ jssubmitForm: debounce(async function () {
|
|
|
const _selectData = this.$refs.xTable.getCheckboxRecords(true)
|
|
|
- if (_selectData.length>1){
|
|
|
+ if (_selectData.length > 1) {
|
|
|
this.$message({
|
|
|
type: 'warning',
|
|
|
message: '每个用户只能分配一个角色!'
|
|
@@ -755,22 +859,32 @@ export default {
|
|
|
return
|
|
|
}
|
|
|
let roleid = '';
|
|
|
- if (_selectData.length==1){
|
|
|
+ if (_selectData.length == 1) {
|
|
|
roleid = _selectData[0].roleId
|
|
|
- }
|
|
|
- else{
|
|
|
+ } else {
|
|
|
this.$message({
|
|
|
type: 'warning',
|
|
|
message: '请选择角色!'
|
|
|
});
|
|
|
return
|
|
|
}
|
|
|
+
|
|
|
+ let sysTime
|
|
|
+ let lk
|
|
|
+ await this.$axios.get('/sysPolicyController/getLicenseKey').then((res) => {
|
|
|
+ sysTime = res.data.sysTime
|
|
|
+ lk = res.data.lk
|
|
|
+ }).catch((error) => {
|
|
|
+ })
|
|
|
+
|
|
|
// 提交后台角色分配
|
|
|
const param = {
|
|
|
userId: this.jsuserid,
|
|
|
- roleId: roleid
|
|
|
+ roleId: roleid,
|
|
|
+ sysTime: sysTime,
|
|
|
+ lk: lk
|
|
|
}
|
|
|
- this.$axios.post('/sysUserController/authRole', param).then((res) => {
|
|
|
+ await this.$axios.post('/sysUserController/authRole', param).then((res) => {
|
|
|
if (res.code == 0) {
|
|
|
this.$message({
|
|
|
type: 'success',
|
|
@@ -790,7 +904,7 @@ export default {
|
|
|
});
|
|
|
this.loading = false
|
|
|
})
|
|
|
- },1000)
|
|
|
+ }, 1000)
|
|
|
}
|
|
|
};
|
|
|
</script>
|