Browse Source

修复用户信息无法更新的bug

master
李磊 3 years ago
parent
commit
558e3288e9
  1. 144
      src/views/user/user.vue

144
src/views/user/user.vue

@ -29,7 +29,7 @@
v-if="hasPerm('user:add')"
type="primary"
icon="el-icon-edit"
@click="showCreate"
@click="crud.toAdd"
>
添加
</el-button>
@ -61,8 +61,8 @@
<CustomTable ref="customTable" :col-configs="colConfigs" :columns="columns" :crud="crud">
<el-table-column slot="operation" align="center" width="100" label="操作">
<template slot-scope="scope">
<Edit :data="scope.row" :disabled-edit="false" />
<Delete :data="scope.row" style="margin-left: 5px" />
<Edit :permission="permission" :data="scope.row" :disabled-edit="false" />
<Delete :permission="permission" :data="scope.row" style="margin-left: 5px" />
</template>
</el-table-column>
</CustomTable>
@ -70,70 +70,70 @@
</el-col>
</el-row>
<el-dialog :title="textMap[dialogStatus]" :visible="crud.status.editor > 0">
<el-dialog :title="textMap[dialogStatus]" :visible="crud.status.editor > 0" @close="crud.cancelCU">
<el-form
ref="tempUser"
:model="tempUser"
:rules="rules"
:rules="dialogStatus === 'create' ? rules : {}"
class="small-space"
label-position="left"
label-width="120px"
style="width: 300px; margin-left: 50px"
>
<el-form-item
v-if="dialogStatus === 'create'"
label="用户名"
prop="username"
required
>
<el-input v-model="tempUser.username" type="text" />
</el-form-item>
<el-form-item
v-if="dialogStatus === 'create'"
label="身份证号"
prop="identificationNum"
required
>
<el-input v-model="tempUser.identificationNum" type="text" />
</el-form-item>
<el-form-item
v-if="dialogStatus === 'create'"
label="昵称"
prop="nickname"
required
>
<el-input v-model="tempUser.nickname" type="text" />
</el-form-item>
<el-form-item
v-if="dialogStatus === 'create'"
label="密码"
prop="password"
required
>
<el-input v-model="tempUser.password" type="password" />
</el-form-item>
<el-form-item v-else label="新密码">
<el-input
v-model="tempUser.password"
type="password"
placeholder="不填则表示不修改"
/>
</el-form-item>
<el-form-item
v-if="dialogStatus === 'update'"
label="新签名密码"
prop="signPassword"
>
<el-input
v-model="tempUser.signPassword"
type="password"
placeholder="不填则表示不修改"
/>
</el-form-item>
<template v-if="dialogStatus === 'create'">
<el-form-item
label="用户名"
prop="username"
required
>
<el-input v-model="tempUser.username" type="text" />
</el-form-item>
<el-form-item
label="身份证号"
prop="identificationNum"
required
>
<el-input v-model="tempUser.identificationNum" type="text" />
</el-form-item>
<el-form-item
label="昵称"
prop="nickname"
required
>
<el-input v-model="tempUser.nickname" type="text" />
</el-form-item>
<el-form-item
label="密码"
prop="password"
required
>
<el-input v-model="tempUser.password" type="password" />
</el-form-item>
</template>
<template v-else>
<el-form-item label="新密码">
<el-input
v-model="tempUser.password"
type="password"
placeholder="不填则表示不修改"
/>
</el-form-item>
<el-form-item
label="新签名密码"
prop="signPassword"
>
<el-input
v-model="tempUser.signPassword"
type="password"
placeholder="不填则表示不修改"
/>
</el-form-item>
</template>
<el-form-item label="角色" prop="roleIds">
<el-select
v-model="roleIds"
multiple
filterable
placeholder="请选择"
style="width: 180px"
>
@ -295,7 +295,12 @@ export default {
},
fileList: [],
depts: [],
roleIds: []
roleIds: [],
permission: {
add: ['user:add'],
edit: ['user:update'],
del: ['user:delete']
}
}
},
computed: {
@ -316,6 +321,14 @@ export default {
console.log(this.crud, this.query, '啊哈哈哈')
},
methods: {
//
[CRUD.HOOK.beforeToAdd]() {
this.showCreate()
},
//
[CRUD.HOOK.beforeToEdit](crud, form) {
this.showUpdate(form)
},
getAllRoles() {
this.api({
url: '/role/all',
@ -401,23 +414,18 @@ export default {
//
this.tempUser = {}
this.dialogStatus = 'create'
this.dialogFormVisible = true
this.roleIds.length = 0
this.dialogFormVisible = true
},
showUpdate($index) {
const user = this.list[$index]
showUpdate(user) {
this.tempUser = user
this.roleIds.length = 0
if (user.roleIds !== null && user.roleIds !== undefined) {
if (user.roleIds.indexOf(',') !== -1) {
user.roleIds
.split(',')
.forEach((roleId) => this.roleIds.push(Number(roleId)))
}
if (user.roleIds) {
user.roleIds.split(',').forEach((roleId) => this.roleIds.push(Number(roleId)))
}
if (user.signImg !== null && user.signImg !== '') {
if (user.signImg) {
this.tempUser.signImg = user.signImg
this.fileList = JSON.parse(user.signImg)
this.fileList = [{ name: this.tempUser.signImg }]
if (this.fileList.length > 0) {
this.fileList[0].url =
process.env.VUE_APP_IMG_URL + 'signImage/' + this.fileList[0].name
@ -425,6 +433,7 @@ export default {
} else {
this.fileList = []
}
console.log(this.fileList[0])
this.dialogStatus = 'update'
this.dialogFormVisible = true
},
@ -484,6 +493,7 @@ export default {
_vue.getList()
}
})
this.crud.cancelCU()
})
} else {
return false

Loading…
Cancel
Save