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

Loading…
Cancel
Save