|  |  |  | 
|---|
|  |  |  | border | 
|---|
|  |  |  | style="width: 100%" | 
|---|
|  |  |  | :stripe="true" | 
|---|
|  |  |  | > | 
|---|
|  |  |  | ><el-table-column | 
|---|
|  |  |  | prop="unitId" | 
|---|
|  |  |  | label="责任单位" | 
|---|
|  |  |  | :formatter="unitIdFormatter" | 
|---|
|  |  |  | /> | 
|---|
|  |  |  | <el-table-column | 
|---|
|  |  |  | prop="account" | 
|---|
|  |  |  | label="员工账号" | 
|---|
|  |  |  | 
|---|
|  |  |  | <el-form-item label="员工名称" :label-width="formLabelWidth" prop="userName"> | 
|---|
|  |  |  | <el-input v-model="form.userName" autocomplete="off" /> | 
|---|
|  |  |  | </el-form-item> | 
|---|
|  |  |  | <el-form-item label="责任单位" :label-width="formLabelWidth"> | 
|---|
|  |  |  | <el-select v-model="form.unitId" placeholder="请选择" size="small" style="width: 100%;"> | 
|---|
|  |  |  | <el-option | 
|---|
|  |  |  | v-for="item in unitList" | 
|---|
|  |  |  | :key="item.unitId" | 
|---|
|  |  |  | :label="item.unitName" | 
|---|
|  |  |  | :value="item.unitId" | 
|---|
|  |  |  | /> | 
|---|
|  |  |  | </el-select> | 
|---|
|  |  |  | </el-form-item> | 
|---|
|  |  |  | <el-form-item label="手机" :label-width="formLabelWidth" prop="mobile"> | 
|---|
|  |  |  | <el-input v-model="form.mobile" autocomplete="off" /> | 
|---|
|  |  |  | </el-form-item> | 
|---|
|  |  |  | 
|---|
|  |  |  | </el-form-item> | 
|---|
|  |  |  | <el-form-item label="员工名称" :label-width="formLabelWidth" prop="userName"> | 
|---|
|  |  |  | <el-input v-model="formEdit.userName" autocomplete="off" /> | 
|---|
|  |  |  | </el-form-item> | 
|---|
|  |  |  | <el-form-item label="责任单位" :label-width="formLabelWidth"> | 
|---|
|  |  |  | <el-select v-model="formEdit.unitId" placeholder="请选择" size="small" style="width: 100%;"> | 
|---|
|  |  |  | <el-option | 
|---|
|  |  |  | v-for="item in unitList" | 
|---|
|  |  |  | :key="item.unitId" | 
|---|
|  |  |  | :label="item.unitName" | 
|---|
|  |  |  | :value="item.unitId" | 
|---|
|  |  |  | /> | 
|---|
|  |  |  | </el-select> | 
|---|
|  |  |  | </el-form-item> | 
|---|
|  |  |  | <el-form-item label="手机" :label-width="formLabelWidth" prop="mobile"> | 
|---|
|  |  |  | <el-input v-model="formEdit.mobile" autocomplete="off" /> | 
|---|
|  |  |  | 
|---|
|  |  |  | // 这里存放数据 | 
|---|
|  |  |  | return { | 
|---|
|  |  |  | options: [], | 
|---|
|  |  |  | unitList: [], | 
|---|
|  |  |  | radio1: '', | 
|---|
|  |  |  | value: '', | 
|---|
|  |  |  | value1: '', | 
|---|
|  |  |  | 
|---|
|  |  |  | dialogEdit: false, | 
|---|
|  |  |  | dialogRole: false, | 
|---|
|  |  |  | form: { | 
|---|
|  |  |  | unitId: '', | 
|---|
|  |  |  | account: '', | 
|---|
|  |  |  | password: '', | 
|---|
|  |  |  | userName: '', | 
|---|
|  |  |  | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | formEdit: { | 
|---|
|  |  |  | id: 0, | 
|---|
|  |  |  | unitId: '', | 
|---|
|  |  |  | account: '', | 
|---|
|  |  |  | password: '', | 
|---|
|  |  |  | userName: '', | 
|---|
|  |  |  | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | // 生命周期 - 创建完成(可以访问当前 this 实例) | 
|---|
|  |  |  | created() { | 
|---|
|  |  |  | this.getUnitList() | 
|---|
|  |  |  | this.personnelList() | 
|---|
|  |  |  | this.roleList() | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | 
|---|
|  |  |  | this.form.account = '' | 
|---|
|  |  |  | this.form.password = '' | 
|---|
|  |  |  | this.form.userName = '' | 
|---|
|  |  |  | this.form.unitId = '' | 
|---|
|  |  |  | this.form.mobile = '' | 
|---|
|  |  |  | this.form.email = '' | 
|---|
|  |  |  | this.form.wechat = '' | 
|---|
|  |  |  | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | unitIdFormatter(val) { | 
|---|
|  |  |  | const data = this.unitList.find(item => item && item.unitId === val.unitId) | 
|---|
|  |  |  | return data ? data.unitName : '' | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | // 获取责任单位list | 
|---|
|  |  |  | getUnitList() { | 
|---|
|  |  |  | this.$request({ | 
|---|
|  |  |  | url: '/allocation/unit', | 
|---|
|  |  |  | method: 'get' | 
|---|
|  |  |  | }).then((res) => { | 
|---|
|  |  |  | this.unitList = res.data | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | // 新建员工方法 | 
|---|
|  |  |  | personnelAdd() { | 
|---|
|  |  |  | if (this.form.account && this.form.password && this.form.userName) { | 
|---|
|  |  |  | 
|---|
|  |  |  | account: this.form.account, | 
|---|
|  |  |  | password: this.$encrypt(this.form.password), | 
|---|
|  |  |  | userName: this.form.userName, | 
|---|
|  |  |  | unitId: Number(this.form.unitId), | 
|---|
|  |  |  | mobile: this.form.mobile, | 
|---|
|  |  |  | email: this.form.email, | 
|---|
|  |  |  | wechat: this.form.wechat, | 
|---|
|  |  |  | 
|---|
|  |  |  | this.form.id = row.id | 
|---|
|  |  |  | this.form.account = row.account | 
|---|
|  |  |  | this.form.userName = row.userName | 
|---|
|  |  |  | this.form.unitId = row.unitId | 
|---|
|  |  |  | this.form.mobile = row.mobile | 
|---|
|  |  |  | this.form.email = row.email | 
|---|
|  |  |  | this.form.wechat = row.wechat | 
|---|
|  |  |  | 
|---|
|  |  |  | this.formEdit.userName = '' | 
|---|
|  |  |  | this.formEdit.mobile = '' | 
|---|
|  |  |  | this.formEdit.email = '' | 
|---|
|  |  |  | this.formEdit.unitId = '' | 
|---|
|  |  |  | this.formEdit.wechat = '' | 
|---|
|  |  |  | this.formEdit.expireTime = '' | 
|---|
|  |  |  | this.formEdit.password = '' | 
|---|
|  |  |  | 
|---|
|  |  |  | // 编辑员工方法 | 
|---|
|  |  |  | personnelEdit() { | 
|---|
|  |  |  | // return | 
|---|
|  |  |  | if (this.formEdit.userName !== this.form.userName || this.formEdit.password !== this.form.password || this.formEdit.mobile !== this.form.mobile || this.formEdit.wechat !== this.form.wechat || this.formEdit.email !== this.form.email || this.formEdit.expireTime !== this.form.expireTime) { | 
|---|
|  |  |  | if (this.formEdit.unitId !== this.form.unitId || this.formEdit.userName !== this.form.userName || this.formEdit.password !== this.form.password || this.formEdit.mobile !== this.form.mobile || this.formEdit.wechat !== this.form.wechat || this.formEdit.email !== this.form.email || this.formEdit.expireTime !== this.form.expireTime) { | 
|---|
|  |  |  | this.$request({ | 
|---|
|  |  |  | url: '/user/update', | 
|---|
|  |  |  | method: 'post', | 
|---|
|  |  |  | 
|---|
|  |  |  | password: this.formEdit.password ? this.$encrypt(this.formEdit.password) : null, | 
|---|
|  |  |  | userName: this.formEdit.userName ? this.formEdit.userName : null, | 
|---|
|  |  |  | mobile: this.formEdit.mobile ? this.formEdit.mobile : null, | 
|---|
|  |  |  | unitId: Number(this.formEdit.unitId) ? Number(this.formEdit.unitId) : null, | 
|---|
|  |  |  | email: this.formEdit.email ? this.formEdit.email : null, | 
|---|
|  |  |  | wechat: this.formEdit.wechat ? this.formEdit.wechat : null, | 
|---|
|  |  |  | expireTime: this.formEdit.expireTime ? this.formEdit.expireTime : null | 
|---|