| | |
| | | <template> |
| | | <win-sm :title="setting.title" @close="close" :width="'800px'"> |
| | | <win-sm :title="setting.title" @close="close" :width="'800px'" :loading="loading"> |
| | | <el-alert |
| | | style="margin-bottom: 10px" |
| | | title="温馨提示:用户初始密码为123456" |
| | |
| | | </el-form-item> |
| | | <el-form-item label="部门" prop="sysDeptId"> |
| | | <el-select v-model="formData.sysDeptId"> |
| | | <el-option v-for="(item,index) in deptmentOptions" :key="index" :label="item.name" :value="item.id"></el-option> |
| | | <el-option v-for="(item,index) in deptmentOptions" :key="index" :label="item.name" |
| | | :value="item.id"></el-option> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="人员姓名" prop="userName"> |
| | | <el-input v-model="formData.userName" clearable maxlength="20" show-word-limit style="width: 250px"/> |
| | | </el-form-item> |
| | | <el-form-item label="员工编号" prop="userCode"> |
| | | <el-form-item label="登录名" prop="userCode"> |
| | | <el-input v-model="formData.userCode" clearable maxlength="20" show-word-limit style="width: 250px"/> |
| | | </el-form-item> |
| | | <el-form-item label="手机号" prop="userPhone"> |
| | |
| | | } |
| | | }, |
| | | data() { |
| | | // 参数1: rule 对象, 是校验规则, 一般不用 |
| | | // 参数2: value 校验项的数据 |
| | | // 参数3: callback 回调函数, 决定是否校验通过 |
| | | const checkedListCheck = (rule, value, callback) => { |
| | | if (this.checkedList.length < 1) { |
| | | callback(new Error('至少选择一个')) |
| | | } else { |
| | | callback() |
| | | } |
| | | } |
| | | return { |
| | | deptmentOptions:[], |
| | | loading: true, |
| | | checkAll: false, |
| | | checkedList: [], |
| | | roleList: [ |
| | |
| | | {required: true, message: '请输入人员姓名', trigger: 'blur'} |
| | | ], |
| | | userCode: [ |
| | | {required: true, message: '请输入员工编号', trigger: 'blur'} |
| | | {required: true, message: '请输入登录名', trigger: 'blur'} |
| | | ], |
| | | userPhone: [ |
| | | {required: true, message: '请输入手机号', trigger: 'blur'} |
| | |
| | | seq: [ |
| | | {required: true, message: '请输入顺序号', trigger: 'blur'} |
| | | ], |
| | | // 角色配置的验证 |
| | | roleSetting: [ |
| | | {validator: checkedListCheck, required: true, trigger: 'blur'}, |
| | | ], |
| | | } |
| | | } |
| | | }, |
| | | created() { |
| | | this.getInfo() |
| | | this.getAllRole() |
| | | this.getDeptmentOptions() |
| | | async created() { |
| | | this.title = this.setting.title |
| | | if (this.setting.id != null) { |
| | | await this.getInfo() |
| | | } |
| | | |
| | | await this.getAllRole() |
| | | await this.getDeptmentOptions() |
| | | this.loading = false |
| | | }, |
| | | methods: { |
| | | // 获取所有角色 |
| | | getAllRole() { |
| | | // const user = this.$store.getters.userInfo |
| | | // this.data_scope = 1 |
| | | // if (user.lv == 1) { |
| | | // this.data_scope = 1 |
| | | // } |
| | | // if (user.lv == 2) { |
| | | // this.data_scope = 2 |
| | | // } |
| | | // if (user.lv == 3) { |
| | | // this.data_scope = 3 |
| | | // } |
| | | this.data_scope = 1 |
| | | role.listRoleByDataScope({dataScope: this.data_scope}).then(response => { |
| | | async getAllRole() { |
| | | this.data_scope = this.$store.getters.userInfo ? this.$store.getters.userInfo.lv : '' |
| | | await role.listRoleByDataScope({dataScope: this.setting.data_scope}).then(response => { |
| | | if (response) { |
| | | this.roleOptions = response; |
| | | } else { |
| | |
| | | } |
| | | ); |
| | | }, |
| | | getDeptmentOptions(){ |
| | | departmentListAll({tenantId:this.setting.tenantId}).then(res=>{ |
| | | async getDeptmentOptions() { |
| | | await departmentListAll({tenantId: this.setting.tenantId}).then(res => { |
| | | this.deptmentOptions = res |
| | | }) |
| | | }, |
| | |
| | | let checkedCount = value.length; |
| | | this.checkAll = checkedCount === this.roleOptions.length; |
| | | }, |
| | | getInfo() { |
| | | async getInfo() { |
| | | this.title = this.setting.title |
| | | if (this.setting.id != null) { |
| | | // 查询数据 |
| | | user.getUser({id: this.setting.id}).then(res => { |
| | | await user.getUser({id: this.setting.id}).then(res => { |
| | | const data = res.data |
| | | this.formData = Object.assign(this.formData, data) |
| | | if (this.formData.projectStart != null && this.formData.projectStart > 0) { |
| | |
| | | this.handleCheckedCitiesChange(res.list) |
| | | } |
| | | }) |
| | | } |
| | | }, |
| | | close() { |
| | | this.formData = { |
| | | projectName: '', |
| | | projectSubName: '', |
| | | projectCode: '', |
| | | projectContact: '', |
| | | projectTel: '', |
| | | projectEmail: '', |
| | | projectStart: null, |
| | | projectEnd: null, |
| | | projectDesc: '', |
| | | status: 1 |
| | | }, |
| | | sysDeptId: '', |
| | | userName: '', |
| | | userCode: '', |
| | | userPhone: '', |
| | | sex: 1, |
| | | status: 1, |
| | | remark: '', |
| | | seq: null, |
| | | } |
| | | this.$emit('close') |
| | | }, |
| | | save() { |
| | |
| | | this.$message.error('服务开始时间和服务结束时间必须成对出现') |
| | | return |
| | | } |
| | | if (this.loading) return; |
| | | this.loading = true |
| | | if (params.id) { |
| | | user.upd(params).then(res => { |
| | | this.loading = false |
| | | if (res) { |
| | | this.$message.success('保存成功!') |
| | | this.close() |
| | |
| | | } else { |
| | | this.$message.error('保存失败') |
| | | } |
| | | }).catch(() => { |
| | | this.loading = false |
| | | }) |
| | | } else { |
| | | user.add(params).then(res => { |
| | | this.loading = false |
| | | if (res) { |
| | | this.$message.success('保存成功!') |
| | | this.close() |
| | |
| | | } else { |
| | | this.$message.error('保存失败') |
| | | } |
| | | }).catch(() => { |
| | | this.loading = false |
| | | }) |
| | | } |
| | | } else { |