| | |
| | | </div> |
| | | <!--表单组件--> |
| | | <el-dialog append-to-body :close-on-click-modal="false" :before-close="crud.cancelCU" :visible.sync="crud.status.cu > 0" :title="crud.status.title" width="570px"> |
| | | <el-form ref="form" :inline="true" :model="form" :rules="rules" size="small" label-width="66px"> |
| | | <el-form ref="form" :inline="true" :model="form" :rules="rules" size="small" label-width="70px"> |
| | | <el-form-item label="用户名" prop="username"> |
| | | <el-input v-model="form.username" @keydown.native="keydown($event)" /> |
| | | </el-form-item> |
| | |
| | | <el-option v-for="item in companyList" :key="item.id" :label="item.label" :value="item.id" /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item style="margin-bottom: 0;" label="角色" prop="roles"> |
| | | <el-form-item label="角色" prop="roles"> |
| | | <el-select |
| | | v-model="roleDatas" |
| | | style="width: 437px" |
| | |
| | | :label="item.name" |
| | | :value="item.id" |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="操作公司" prop="companys"> |
| | | <el-select v-model="companyDatas" clearable multiple collapse-tags style="width: 437px" @remove-tag="deleteCompanyTag" @change="changeCompany"> |
| | | <el-option v-for="item in companyList" :key="item.id" :label="item.label" :value="item.id" /> |
| | | </el-select> |
| | | </el-form-item> |
| | | </el-form> |
| | |
| | | import crudSysCompany from '@/api/system/sysCompany' |
| | | let userRoles = [] |
| | | let userJobs = [] |
| | | const defaultForm = { id: null, username: null, company: { id: null }, internshipTime: null, nickName: null, gender: '男', email: null, enabled: 'false', roles: [], jobs: [], dept: { id: null }, phone: null, birthday: null, address: null, dingding: null, sysRostering: { id: null }, levelId: null } |
| | | let userCompanys = [] |
| | | const defaultForm = { id: null, username: null, company: { id: null }, internshipTime: null, nickName: null, gender: '男', email: null, enabled: 'false', roles: [], jobs: [], dept: { id: null }, phone: null, birthday: null, address: null, dingding: null, sysRostering: { id: null }, levelId: null, companys: [] } |
| | | export default { |
| | | name: 'User', |
| | | components: { Treeselect, crudOperation, rrOperation, udOperation, pagination, DateRangePicker }, |
| | |
| | | return { |
| | | height: document.documentElement.clientHeight - 180 + 'px;', |
| | | deptName: '', depts: [], deptDatas: [], jobs: [], level: 3, roles: [], |
| | | jobDatas: [], roleDatas: [], // 多选时使用 |
| | | jobDatas: [], roleDatas: [], companyDatas: [], // 多选时使用 |
| | | defaultProps: { children: 'children', label: 'name', isLeaf: 'leaf' }, |
| | | permission: { |
| | | add: ['admin', 'user:add'], |
| | |
| | | this.form.levelId = null |
| | | } |
| | | }, |
| | | changeCompany(value) { |
| | | userCompanys = [] |
| | | value.forEach(function(data, index) { |
| | | const com = { id: data } |
| | | userCompanys.push(com) |
| | | }) |
| | | }, |
| | | deleteTag(value) { |
| | | userRoles.forEach(function(data, index) { |
| | | if (data.id === value) { |
| | | userRoles.splice(index, value) |
| | | } |
| | | }) |
| | | }, |
| | | deleteCompanyTag(value) { |
| | | userCompanys.forEach(function(data, index) { |
| | | if (data.id === value) { |
| | | userCompanys.splice(index, value) |
| | | } |
| | | }) |
| | | }, |
| | |
| | | [CRUD.HOOK.beforeToAdd]() { |
| | | this.jobDatas = [] |
| | | this.roleDatas = [] |
| | | this.companyDatas = [] |
| | | this.isEditing = false |
| | | }, |
| | | // 初始化编辑时候的角色与岗位 |
| | | // 初始化编辑时候的角色与岗位与操作公司 |
| | | [CRUD.HOOK.beforeToEdit](crud, form) { |
| | | this.getJobs(this.form.dept.id) |
| | | this.jobDatas = [] |
| | | this.roleDatas = [] |
| | | this.companyDatas = [] |
| | | userRoles = [] |
| | | userJobs = [] |
| | | userCompanys = [] |
| | | const _this = this |
| | | this.isEditing = true |
| | | form.roles.forEach(function(role, index) { |
| | |
| | | // 获取级别 |
| | | _this.getLevel() |
| | | } |
| | | }) |
| | | form.companys.forEach(function(company, index) { |
| | | _this.companyDatas.push(company.id) |
| | | const com = { id: company.id } |
| | | userCompanys.push(com) |
| | | }) |
| | | }, |
| | | // 提交前做的操作 |
| | |
| | | } |
| | | crud.form.roles = userRoles |
| | | crud.form.jobs = userJobs |
| | | crud.form.companys = userCompanys |
| | | return true |
| | | }, |
| | | // 获取左侧部门数据 |