|
@@ -42,6 +42,9 @@
|
|
|
</template>
|
|
|
<template #actions="scope">
|
|
|
<template v-if="scope.row.companyInfo?.homeUserId !== scope.row.id">
|
|
|
+ <m-button type="primary" class="pa-0" text @click="onEdit(scope.row)">编辑</m-button>
|
|
|
+ <m-button type="primary" class="pa-0" text @click="onSetRole(scope.row)">角色分配</m-button>
|
|
|
+ <m-button type="warning" class="pa-0" text @click="onReset(scope.row)">重置密码</m-button>
|
|
|
<m-button
|
|
|
:type="scope.row.state ? 'success' : 'danger'"
|
|
|
class="pa-0"
|
|
@@ -50,47 +53,36 @@
|
|
|
>
|
|
|
{{ scope.row.state ? '启用' : '禁用' }}
|
|
|
</m-button>
|
|
|
- <m-button type="primary" class="pa-0" text @click="onEdit(scope.row)">编辑</m-button>
|
|
|
- <m-button type="primary" class="pa-0" text @click="onSetRole(scope.row)">角色分配</m-button>
|
|
|
- <m-button type="warning" class="pa-0" text @click="onReset(scope.row)">重置密码</m-button>
|
|
|
<m-button type="danger" class="pa-0" text @click="onDelete(scope.row)">删除</m-button>
|
|
|
</template>
|
|
|
</template>
|
|
|
</MTable>
|
|
|
- <MDialog ref="dialog" :title="itemData.id ? '编辑用户' : '新增用户'" @sure="handleSave">
|
|
|
- <MForm ref="userForm" :items="userFormItems" v-model="userFormValue"></MForm>
|
|
|
- </MDialog>
|
|
|
- <MDialog ref="role" title="角色分配" @sure="handleSaveRole">
|
|
|
- <MForm ref="roleForm" :items="roleFormItems" v-model="roleFormValue">
|
|
|
- <template #username>
|
|
|
- <el-tag>{{ itemData.username }}</el-tag>
|
|
|
- </template>
|
|
|
- <template #name>
|
|
|
- <el-tag>{{ itemData.name }}</el-tag>
|
|
|
- </template>
|
|
|
- </MForm>
|
|
|
- </MDialog>
|
|
|
- <MDialog ref="password" title="重置密码" @sure="handleSavePassword">
|
|
|
- <MForm ref="passwordForm" :items="passwordFormItems" v-model="passwordFormValue"></MForm>
|
|
|
- </MDialog>
|
|
|
+ <UserEdit ref="dialog" @refresh="init"></UserEdit>
|
|
|
+ <UserRole ref="userRefs" @refresh="init"></UserRole>
|
|
|
+ <UserReset ref="userReset" @refresh="init"></UserReset>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
+import UserEdit from './userEdit.vue'
|
|
|
+import UserRole from './userRole.vue'
|
|
|
+import UserReset from './userReset'
|
|
|
import util from '@/utils/base64ToFile'
|
|
|
import {
|
|
|
getUserList,
|
|
|
- saveUser,
|
|
|
deleteUser,
|
|
|
- resetPassword,
|
|
|
downloadUserTemplate,
|
|
|
userExcelExport,
|
|
|
blockUser
|
|
|
} from '@/api/user'
|
|
|
-import { getRoleList } from '@/api/menu'
|
|
|
import { dateFormat } from '@/utils/date'
|
|
|
export default {
|
|
|
name: 'user-list',
|
|
|
+ components: {
|
|
|
+ UserEdit,
|
|
|
+ UserRole,
|
|
|
+ UserReset
|
|
|
+ },
|
|
|
data () {
|
|
|
return {
|
|
|
searchItems: [
|
|
@@ -106,15 +98,6 @@ export default {
|
|
|
searchValues: {
|
|
|
searchKey: null
|
|
|
},
|
|
|
- roleFormValue: {
|
|
|
- roleId: null
|
|
|
- },
|
|
|
- userFormValue: {
|
|
|
- type: 1
|
|
|
- },
|
|
|
- passwordFormValue: {
|
|
|
- newPwd: null
|
|
|
- },
|
|
|
headers: [
|
|
|
{ label: '用户昵称', prop: 'name', width: 200 },
|
|
|
{ label: '账号', prop: 'username', width: 200 },
|
|
@@ -132,124 +115,12 @@ export default {
|
|
|
size: 10
|
|
|
},
|
|
|
loading: false,
|
|
|
- itemData: {},
|
|
|
showReset: false,
|
|
|
show: false,
|
|
|
- roleList: [],
|
|
|
uploadLoading: false
|
|
|
}
|
|
|
},
|
|
|
- computed: {
|
|
|
- passwordFormItems () {
|
|
|
- return [
|
|
|
- {
|
|
|
- label: '新密码',
|
|
|
- prop: 'newPwd',
|
|
|
- type: 'input',
|
|
|
- options: {
|
|
|
- showPassword: true,
|
|
|
- placeholder: '请输入新密码'
|
|
|
- },
|
|
|
- rules: [
|
|
|
- { required: true, message: '请输入密码', trigger: 'change' }
|
|
|
- ]
|
|
|
- }
|
|
|
- ]
|
|
|
- },
|
|
|
- roleFormItems () {
|
|
|
- return [
|
|
|
- {
|
|
|
- label: '用户名称',
|
|
|
- prop: 'username'
|
|
|
- },
|
|
|
- {
|
|
|
- label: '用户昵称',
|
|
|
- prop: 'name'
|
|
|
- },
|
|
|
- {
|
|
|
- label: '角色',
|
|
|
- prop: 'roleId',
|
|
|
- type: 'select',
|
|
|
- options: {
|
|
|
- multiple: true,
|
|
|
- items: this.roleList.map(e => {
|
|
|
- return {
|
|
|
- label: e.roleName,
|
|
|
- value: e.id
|
|
|
- }
|
|
|
- })
|
|
|
- },
|
|
|
- rules: [
|
|
|
- { required: true, message: '请选择角色', trigger: 'change' }
|
|
|
- ]
|
|
|
- }
|
|
|
- ]
|
|
|
- },
|
|
|
- userFormItems () {
|
|
|
- const hidden = this.userFormValue.type === 2
|
|
|
- return [
|
|
|
- {
|
|
|
- label: '账户类型',
|
|
|
- prop: 'type',
|
|
|
- type: 'radioGroup',
|
|
|
- options: {
|
|
|
- items: [
|
|
|
- { text: '统一认证号用户', label: 1 },
|
|
|
- { text: '系统普通用户', label: 2 }
|
|
|
- ]
|
|
|
- },
|
|
|
- rules: [
|
|
|
- { required: true, message: '请选择账户类型', trigger: 'blur' }
|
|
|
- ]
|
|
|
- },
|
|
|
- {
|
|
|
- label: !hidden ? '统一认证号' : '用户账号',
|
|
|
- prop: 'username',
|
|
|
- type: 'input',
|
|
|
- options: {
|
|
|
- placeholder: '请输入' + (!hidden ? '统一认证号' : '用户账号')
|
|
|
- },
|
|
|
- rules: [
|
|
|
- { required: true, message: `请输入${!hidden ? '统一认证号' : '用户账号'}`, trigger: 'blur' }
|
|
|
- ]
|
|
|
- },
|
|
|
- {
|
|
|
- label: '用户昵称',
|
|
|
- prop: 'name',
|
|
|
- type: 'input',
|
|
|
- options: {
|
|
|
- placeholder: '请输入用户昵称'
|
|
|
- },
|
|
|
- rules: [
|
|
|
- { required: true, message: '请输入用户昵称', trigger: 'blur' }
|
|
|
- ]
|
|
|
- },
|
|
|
- {
|
|
|
- label: '用户密码',
|
|
|
- prop: 'password',
|
|
|
- type: 'input',
|
|
|
- options: {
|
|
|
- showPassword: true,
|
|
|
- placeholder: '请输入用户密码'
|
|
|
- },
|
|
|
- hidden: !hidden || this.itemData.id,
|
|
|
- rules: [
|
|
|
- { required: true, message: '请输入用户密码', trigger: 'blur' }
|
|
|
- ]
|
|
|
- },
|
|
|
- {
|
|
|
- label: '用户邮箱',
|
|
|
- prop: 'email',
|
|
|
- type: 'input',
|
|
|
- options: {
|
|
|
- placeholder: '请输入用户邮箱'
|
|
|
- }
|
|
|
- }
|
|
|
- ]
|
|
|
- }
|
|
|
- },
|
|
|
async created () {
|
|
|
- await this.initDice()
|
|
|
await this.init()
|
|
|
},
|
|
|
methods: {
|
|
@@ -273,28 +144,6 @@ export default {
|
|
|
this.pageInfo.current = 1
|
|
|
this.init()
|
|
|
},
|
|
|
- async initDice () {
|
|
|
- try {
|
|
|
- const { data } = await getRoleList({ size: 999 })
|
|
|
- this.roleList = data.records
|
|
|
- } catch (error) {
|
|
|
- this.$message.error(error)
|
|
|
- }
|
|
|
- },
|
|
|
- async onSave (query) {
|
|
|
- try {
|
|
|
- await saveUser({
|
|
|
- id: this.itemData?.id,
|
|
|
- tenantCode: this.itemData.tenantCode,
|
|
|
- ...query
|
|
|
- })
|
|
|
- this.$message.success('保存成功')
|
|
|
- this.init()
|
|
|
- return true
|
|
|
- } catch (error) {
|
|
|
- this.$message.error(error)
|
|
|
- }
|
|
|
- },
|
|
|
async onStatus (item) {
|
|
|
const state = item.state ? 1 : 0
|
|
|
try {
|
|
@@ -309,34 +158,16 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
onEdit (item) {
|
|
|
- this.itemData = item
|
|
|
- this.userFormValue = {
|
|
|
- type: item.password ? 2 : 1,
|
|
|
- username: item.username,
|
|
|
- name: item.name,
|
|
|
- email: item.email
|
|
|
- }
|
|
|
- this.$refs.dialog.open()
|
|
|
+ this.$refs.dialog.open(item)
|
|
|
},
|
|
|
onAdd () {
|
|
|
- this.itemData = {}
|
|
|
- this.userFormValue = {
|
|
|
- type: 1
|
|
|
- }
|
|
|
this.$refs.dialog.open()
|
|
|
},
|
|
|
onSetRole (item) {
|
|
|
- this.itemData = item
|
|
|
- console.log(item.roleId.length)
|
|
|
- this.roleFormValue = {
|
|
|
- roleId: item.roleId ? item.roleId.split(',').map(e => +e) : []
|
|
|
- }
|
|
|
- this.$refs.role.open()
|
|
|
+ this.$refs.userRefs.open(item)
|
|
|
},
|
|
|
onReset (item) {
|
|
|
- this.itemData = item
|
|
|
- this.passwordFormValue.newPwd = null
|
|
|
- this.$refs.password.open()
|
|
|
+ this.$refs.userReset.open(item)
|
|
|
},
|
|
|
onDelete (item) {
|
|
|
this.$confirm('是否确定删除该选项', '提示', {
|
|
@@ -355,53 +186,7 @@ export default {
|
|
|
})
|
|
|
.catch(_ => {})
|
|
|
},
|
|
|
- async handleSave () {
|
|
|
- this.$refs.userForm.validate(async valid => {
|
|
|
- if (!valid) {
|
|
|
- return
|
|
|
- }
|
|
|
- const { type, ...obj } = this.userFormValue
|
|
|
- const check = await this.onSave({
|
|
|
- ...obj,
|
|
|
- state: 0,
|
|
|
- roleId: ''
|
|
|
- })
|
|
|
- check && this.$refs.dialog.close()
|
|
|
- })
|
|
|
- },
|
|
|
- async handleSaveRole () {
|
|
|
- this.$refs.roleForm.validate(async valid => {
|
|
|
- if (!valid) {
|
|
|
- return
|
|
|
- }
|
|
|
- const check = await this.onSave({
|
|
|
- roleId: this.roleFormValue.roleId.toString()
|
|
|
- })
|
|
|
- check && this.$refs.role.close()
|
|
|
- })
|
|
|
- },
|
|
|
- async handleSavePassword () {
|
|
|
- this.$refs.passwordForm.validate(async valid => {
|
|
|
- if (!valid) {
|
|
|
- return
|
|
|
- }
|
|
|
- const companyCode = this.itemData.companyInfo?.companyCode
|
|
|
- const userId = this.itemData.id
|
|
|
- const param = {
|
|
|
- type: 1,
|
|
|
- userId,
|
|
|
- companyCode,
|
|
|
- ...this.passwordFormValue
|
|
|
- }
|
|
|
- try {
|
|
|
- await resetPassword(param)
|
|
|
- this.$refs.password.close()
|
|
|
- this.$message.success('修改成功')
|
|
|
- } catch (error) {
|
|
|
- this.$message.error(error)
|
|
|
- }
|
|
|
- })
|
|
|
- },
|
|
|
+
|
|
|
handlePageChange (page) {
|
|
|
this.pageInfo.current = page
|
|
|
this.init()
|