|
@@ -9,12 +9,16 @@
|
|
|
:before-open="beforeOpen"
|
|
:before-open="beforeOpen"
|
|
|
@current-change="currentChange"
|
|
@current-change="currentChange"
|
|
|
@size-change="sizeChange"
|
|
@size-change="sizeChange"
|
|
|
|
|
+ @refresh-change="refreshChange"
|
|
|
@on-load="onLoad"
|
|
@on-load="onLoad"
|
|
|
>
|
|
>
|
|
|
<template #menu="{ row }">
|
|
<template #menu="{ row }">
|
|
|
<el-button icon="Open" type="primary" text @click="Enable(row)">
|
|
<el-button icon="Open" type="primary" text @click="Enable(row)">
|
|
|
{{ row.clientId.indexOf('project_web') === -1 ? '启用' : '停用' }}
|
|
{{ row.clientId.indexOf('project_web') === -1 ? '启用' : '停用' }}
|
|
|
</el-button>
|
|
</el-button>
|
|
|
|
|
+ <el-button icon="Refresh" type="primary" text @click="restPwd(row)">
|
|
|
|
|
+ 重置密码
|
|
|
|
|
+ </el-button>
|
|
|
</template>
|
|
</template>
|
|
|
<template #status="{ row }">
|
|
<template #status="{ row }">
|
|
|
<el-tag
|
|
<el-tag
|
|
@@ -62,7 +66,7 @@
|
|
|
</el-form-item>
|
|
</el-form-item>
|
|
|
</div>
|
|
</div>
|
|
|
<div class="flex flex-center">
|
|
<div class="flex flex-center">
|
|
|
- <el-form-item class="full-width" label="手机号码" prop="phone">
|
|
|
|
|
|
|
+ <el-form-item label="手机号码" class="full-width" prop="phone">
|
|
|
<el-input
|
|
<el-input
|
|
|
v-model="userInfoForm.phone"
|
|
v-model="userInfoForm.phone"
|
|
|
clearable
|
|
clearable
|
|
@@ -77,8 +81,9 @@
|
|
|
>
|
|
>
|
|
|
<el-input
|
|
<el-input
|
|
|
v-model="userInfoForm.password"
|
|
v-model="userInfoForm.password"
|
|
|
|
|
+ :disabled="form.type !== 'add'"
|
|
|
clearable
|
|
clearable
|
|
|
- placeholder="输入登陆密码"
|
|
|
|
|
|
|
+ :placeholder="form.type !== 'add' ? '******' : '输入登陆密码'"
|
|
|
>
|
|
>
|
|
|
</el-input>
|
|
</el-input>
|
|
|
</el-form-item>
|
|
</el-form-item>
|
|
@@ -162,7 +167,7 @@
|
|
|
<route>
|
|
<route>
|
|
|
{
|
|
{
|
|
|
name: '用户管理',
|
|
name: '用户管理',
|
|
|
-meta: { 'back':true}
|
|
|
|
|
|
|
+meta: { 'back':true,'showMsg' : "添加用户时,手机号码为必填,用户使用手机号码进行登录;如果手机号为用户微信绑定的手机号时,微信小程序将自动登录,并同步信息!"}
|
|
|
}
|
|
}
|
|
|
</route>
|
|
</route>
|
|
|
|
|
|
|
@@ -170,6 +175,7 @@ meta: { 'back':true}
|
|
|
import BasicContainer from '@/components/basic-container/main.vue'
|
|
import BasicContainer from '@/components/basic-container/main.vue'
|
|
|
import { useStore } from '@/store/user.js'
|
|
import { useStore } from '@/store/user.js'
|
|
|
import baseButton from '@/components/base-button.vue'
|
|
import baseButton from '@/components/base-button.vue'
|
|
|
|
|
+import { ElMessageBox } from 'element-plus'
|
|
|
|
|
|
|
|
export default {
|
|
export default {
|
|
|
name: 'manage',
|
|
name: 'manage',
|
|
@@ -200,7 +206,7 @@ export default {
|
|
|
addBtnText: '添加用户',
|
|
addBtnText: '添加用户',
|
|
|
viewBtn: false,
|
|
viewBtn: false,
|
|
|
delBtn: false,
|
|
delBtn: false,
|
|
|
- refreshBtn: false,
|
|
|
|
|
|
|
+ refreshBtn: true,
|
|
|
columnBtn: false,
|
|
columnBtn: false,
|
|
|
labelWidth: 140,
|
|
labelWidth: 140,
|
|
|
border: true,
|
|
border: true,
|
|
@@ -267,7 +273,7 @@ export default {
|
|
|
],
|
|
],
|
|
|
password: [
|
|
password: [
|
|
|
{ required: true, message: '请输入密码', trigger: 'blur' },
|
|
{ required: true, message: '请输入密码', trigger: 'blur' },
|
|
|
- { min: 3, max: 16, message: '长度在 3 到 16 个字符', trigger: 'blur' }
|
|
|
|
|
|
|
+ { min: 6, max: 16, message: '长度在 6 到 16 个字符', trigger: 'blur' }
|
|
|
]
|
|
]
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -279,7 +285,10 @@ export default {
|
|
|
methods: {
|
|
methods: {
|
|
|
onLoad() {
|
|
onLoad() {
|
|
|
this.loading = true
|
|
this.loading = true
|
|
|
|
|
+ this.page.current = this.page.currentPage
|
|
|
|
|
+ this.page.size = this.page.pageSize
|
|
|
const data = { deptId: this.user.info.deptId }
|
|
const data = { deptId: this.user.info.deptId }
|
|
|
|
|
+ console.log(this.page)
|
|
|
this.$api.role
|
|
this.$api.role
|
|
|
.roleList(Object.assign(this.page, data))
|
|
.roleList(Object.assign(this.page, data))
|
|
|
.then(res => {
|
|
.then(res => {
|
|
@@ -317,47 +326,71 @@ export default {
|
|
|
})
|
|
})
|
|
|
},
|
|
},
|
|
|
beforeOpen(done, type) {
|
|
beforeOpen(done, type) {
|
|
|
- if (this.form.clientId.indexOf('project_web') === -1) {
|
|
|
|
|
- this.$message.error('该账号已经停用,无需进行编辑!')
|
|
|
|
|
- return
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ this.form.type = type
|
|
|
if (type === 'edit') {
|
|
if (type === 'edit') {
|
|
|
- this.userInfoForm.name = this.form.name
|
|
|
|
|
- this.userInfoForm.realName = this.form.realName
|
|
|
|
|
- this.userInfoForm.phone = this.form.phone
|
|
|
|
|
- this.userInfoForm.password = this.form.password
|
|
|
|
|
- this.userInfoForm.deptId = this.form.deptId
|
|
|
|
|
- this.jobs.find(e => {
|
|
|
|
|
- const temp = this.form.roleId.split(',').find(sub => sub === e.id)
|
|
|
|
|
- if (temp) {
|
|
|
|
|
- this.userInfoForm.roleIds = temp
|
|
|
|
|
- }
|
|
|
|
|
- return temp
|
|
|
|
|
- })
|
|
|
|
|
- this.$api.role.managerList({ userId: this.form.id }).then(res => {
|
|
|
|
|
- if (res.code === 200) {
|
|
|
|
|
- res.data.forEach(ele => {
|
|
|
|
|
- const tmp = this.deptList.findIndex(sub => sub.id === ele.deptId)
|
|
|
|
|
- if (tmp > -1) {
|
|
|
|
|
- this.deptList[tmp].checked = true
|
|
|
|
|
- }
|
|
|
|
|
- this.userInfoForm.deptIds = this.deptList.map(e => e.id)
|
|
|
|
|
- })
|
|
|
|
|
- this.showEdit = true
|
|
|
|
|
- }
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ this.rowEdit()
|
|
|
} else if (type === 'add') {
|
|
} else if (type === 'add') {
|
|
|
|
|
+ this.userInfoForm = {
|
|
|
|
|
+ name: '',
|
|
|
|
|
+ realName: '',
|
|
|
|
|
+ phone: '',
|
|
|
|
|
+ password: '',
|
|
|
|
|
+ roleIds: '',
|
|
|
|
|
+ deptIds: [],
|
|
|
|
|
+ deptId: ''
|
|
|
|
|
+ }
|
|
|
|
|
+ this.deptList.map(e => (e.checked = false))
|
|
|
this.showEdit = true
|
|
this.showEdit = true
|
|
|
} else {
|
|
} else {
|
|
|
done()
|
|
done()
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
|
|
+ rowEdit() {
|
|
|
|
|
+ if (this.form.clientId.indexOf('project_web') === -1) {
|
|
|
|
|
+ this.$message.error('该账号已经停用,无需进行编辑!')
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ this.userInfoForm.name = this.form.name
|
|
|
|
|
+ this.userInfoForm.realName = this.form.realName
|
|
|
|
|
+ this.userInfoForm.phone = this.form.phone
|
|
|
|
|
+ this.userInfoForm.password = this.form.password
|
|
|
|
|
+ this.userInfoForm.deptId = this.form.deptId
|
|
|
|
|
+ this.jobs.find(e => {
|
|
|
|
|
+ const temp = this.form.roleId.split(',').find(sub => sub === e.id)
|
|
|
|
|
+ if (temp) {
|
|
|
|
|
+ this.userInfoForm.roleIds = temp
|
|
|
|
|
+ }
|
|
|
|
|
+ return temp
|
|
|
|
|
+ })
|
|
|
|
|
+ this.$api.role.managerList({ userId: this.form.id }).then(res => {
|
|
|
|
|
+ if (res.code === 200) {
|
|
|
|
|
+ res.data.forEach(ele => {
|
|
|
|
|
+ const tmp = this.deptList.findIndex(sub => sub.id === ele.deptId)
|
|
|
|
|
+ if (tmp > -1) {
|
|
|
|
|
+ this.deptList[tmp].checked = true
|
|
|
|
|
+ }
|
|
|
|
|
+ this.userInfoForm.deptIds = this.deptList.map(e => e.id)
|
|
|
|
|
+ })
|
|
|
|
|
+ if (
|
|
|
|
|
+ this.deptList.filter(e => e.checked).length === this.deptList.length
|
|
|
|
|
+ ) {
|
|
|
|
|
+ this.checkAll = true
|
|
|
|
|
+ } else {
|
|
|
|
|
+ this.checkAll = false
|
|
|
|
|
+ }
|
|
|
|
|
+ this.showEdit = true
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ },
|
|
|
currentChange(currentPage) {
|
|
currentChange(currentPage) {
|
|
|
this.page.current = currentPage
|
|
this.page.current = currentPage
|
|
|
},
|
|
},
|
|
|
sizeChange(pageSize) {
|
|
sizeChange(pageSize) {
|
|
|
this.page.size = pageSize
|
|
this.page.size = pageSize
|
|
|
},
|
|
},
|
|
|
|
|
+ refreshChange() {
|
|
|
|
|
+ this.onLoad()
|
|
|
|
|
+ },
|
|
|
getJobList() {
|
|
getJobList() {
|
|
|
this.$api.role.jobList({ roleAlias: 'post' }).then(res => {
|
|
this.$api.role.jobList({ roleAlias: 'post' }).then(res => {
|
|
|
if (res.code === 200) {
|
|
if (res.code === 200) {
|
|
@@ -413,14 +446,46 @@ export default {
|
|
|
} else {
|
|
} else {
|
|
|
data.deptIds = this.form.deptId
|
|
data.deptIds = this.form.deptId
|
|
|
}
|
|
}
|
|
|
- this.$api.role.roleSave(data).then(res => {
|
|
|
|
|
- if (res.code === 200) {
|
|
|
|
|
- this.showEdit = false
|
|
|
|
|
- this.$message.success(res.msg)
|
|
|
|
|
- this.onLoad()
|
|
|
|
|
- } else {
|
|
|
|
|
- this.$message.error(res.msg)
|
|
|
|
|
|
|
+ data.isUpdate = false
|
|
|
|
|
+ if (this.form.id) {
|
|
|
|
|
+ data.userId = this.form.id
|
|
|
|
|
+ this.$api.role.roleUpdate(data).then(res => {
|
|
|
|
|
+ if (res.code === 200) {
|
|
|
|
|
+ this.showEdit = false
|
|
|
|
|
+ this.$message.success(res.msg)
|
|
|
|
|
+ this.onLoad()
|
|
|
|
|
+ } else {
|
|
|
|
|
+ this.$message.error(res.msg)
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ } else {
|
|
|
|
|
+ this.$api.role.roleSave(data).then(res => {
|
|
|
|
|
+ if (res.code === 200) {
|
|
|
|
|
+ this.showEdit = false
|
|
|
|
|
+ this.$message.success(res.msg)
|
|
|
|
|
+ this.onLoad()
|
|
|
|
|
+ } else {
|
|
|
|
|
+ this.$message.error(res.msg)
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ restPwd(row) {
|
|
|
|
|
+ console.log(row)
|
|
|
|
|
+ ElMessageBox.prompt('', '更改 (' + row.name + ') 的密码', {
|
|
|
|
|
+ inputPattern: /\w{6,16}/,
|
|
|
|
|
+ inputErrorMessage: '密码长度在 6 到 16 个字符'
|
|
|
|
|
+ }).then(({ value }) => {
|
|
|
|
|
+ if (value.length === 0) {
|
|
|
|
|
+ return
|
|
|
}
|
|
}
|
|
|
|
|
+ this.$api.role
|
|
|
|
|
+ .restPwde({ userId: row.id, password: value })
|
|
|
|
|
+ .then(res => {
|
|
|
|
|
+ if (res.code === 200) {
|
|
|
|
|
+ console.log(res)
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|