| | |
| | | <template> |
| | | <el-dialog :title="titleMap[mode]" v-model="visible" :width="800" destroy-on-close @closed="$emit('closed')"> |
| | | <el-form :model="addPersonForm" :rules="addPersonRules" :disabled="mode=='show'" ref="dialogForm" label-width="120px" label-position="center"> |
| | | <el-form :model="addPersonForm" :rules="addPersonRules" :disabled="mode == 'show'" ref="dialogForm" |
| | | label-width="120px" label-position="center"> |
| | | <el-row> |
| | | <el-col :span="12"> |
| | | <el-form-item label="工号" prop="jobNumber"> |
| | |
| | | <el-col :span="12"> |
| | | <el-form-item label="状态" prop="status"> |
| | | <el-select v-model="addPersonForm.status" placeholder="状态" style="width:100%;"> |
| | | <el-option v-for="item in statusList" :key="item.dictKey" :label="item.dictValue" :value="item.dictKey" size="small"/> |
| | | <el-option v-for="item in statusList" :key="item.dictKey" :label="item.dictValue" |
| | | :value="item.dictKey" size="small" /> |
| | | </el-select> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="岗位"> |
| | | <el-select v-model="addPersonForm.postId" multiple style="width: 100%"> |
| | | <el-option v-for="item in postList" :key="item.id" :label="item.postName" :value="item.id"/> |
| | | <el-option v-for="item in postList" :key="item.id" :label="item.postName" |
| | | :value="item.id" /> |
| | | </el-select> |
| | | </el-form-item> |
| | | </el-col> |
| | |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="部门"> |
| | | <el-select v-model="addPersonForm.organizationId" filterable style="width: 100%" placeholder="部门"> |
| | | <el-option v-for="item in organizationList" :key="item.id" :label="item.name" :value="item.id"/> |
| | | </el-select> |
| | | <el-tree-select @change="parentIdChange" v-model="addPersonForm.organizationId" clearable |
| | | placeholder="上级部门" default-expand-all check-on-click-nod :data="departmentList" |
| | | check-strictly :props="{ label: 'name' }" node-key="id" ref="parentTree" |
| | | style="width: 100%" /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <!-- <el-col :span="12"> |
| | | <el-form-item label="PIN码" prop="pinCode"> |
| | | <el-input v-model="addPersonForm.pinCode" placeholder="PIN码" clearable></el-input> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-col> --> |
| | | <el-col :span="12"> |
| | | <el-form-item label="入职时间"> |
| | | <el-date-picker style="width: 100%;" v-model="addPersonForm.hireDate" type="date" placeholder="入职时间" value-format="YYYY-MM-DD" :size="size"/> |
| | | <el-date-picker style="width: 100%;" v-model="addPersonForm.hireDate" type="date" |
| | | placeholder="入职时间" value-format="YYYY-MM-DD" :size="size" /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="关联账号"> |
| | | <el-select v-model="addPersonForm.userId" filterable style="width: 100%" placeholder="关联账号"> |
| | | <el-option v-for="item in userIdList" :key="item.id" :label="item.account" :value="item.id"/> |
| | | <el-option v-for="item in userIdList" :key="item.id" :label="item.account" |
| | | :value="item.id" /> |
| | | </el-select> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="数据权限配置"> |
| | | <el-select v-model="addPersonForm.deptId" multiple filterable style="width: 100%" placeholder="数据权限配置" @change="deptIdChange"> |
| | | <el-option v-for="item in deptIdList" :key="item.id" :label="item.title" :value="item.id"/> |
| | | </el-select> |
| | | <el-tree-select v-model="addPersonForm.deptId" clearable multiple show-checkbox placeholder="数据权限配置" default-expand-all :data="deptIdList" :props="{ label: 'title' ,id: 'id',children: 'children'}" node-key="id" ref="deptIdTree" style="width: 100%" /> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | </el-form> |
| | | <template #footer> |
| | | <el-button @click="visible=false" >取 消</el-button> |
| | | <el-button v-if="mode!='show'" type="primary" :loading="isSaveing" @click="saveSubmit()">保 存</el-button> |
| | | <el-button @click="visible = false">取 消</el-button> |
| | | <el-button v-if="mode != 'show'" type="primary" :loading="isSaveing" @click="saveSubmit()">保 存</el-button> |
| | | </template> |
| | | </el-dialog> |
| | | </template> |
| | | |
| | | <script> |
| | | export default { |
| | | emits: ['success', 'closed'], |
| | | data() { |
| | | return { |
| | | deptIdList: [], |
| | | userIdList: [], |
| | | organizationList: [], |
| | | postList: [], |
| | | statusList: [], |
| | | mode: "add", |
| | | titleMap: { |
| | | add: '添加员工', |
| | | edit: '修改员工', |
| | | show: '查看' |
| | | }, |
| | | visible: false, |
| | | isSaveing: false, |
| | | //表单数据 |
| | | addPersonForm: { |
| | | jobNumber: "", |
| | | name: "", |
| | | tel: "", |
| | | status: "", |
| | | postId: "", |
| | | email: "", |
| | | organizationId: "", |
| | | pinCode: "", |
| | | hireDate: "", |
| | | jobNumber: "", |
| | | deptId: "", |
| | | userId: "" |
| | | }, |
| | | //验证规则 |
| | | addPersonRules: { |
| | | jobNumber:[{required: true, message: '请输入工号'}], |
| | | name:[{required: true, message: '请输入姓名'}], |
| | | tel:[{required: true, message: '请输入手机号'}], |
| | | status:[{required: true, message: '请选择状态', trigger: 'change'}], |
| | | pinCode:[{required: true, message: '请输入PIN码'}], |
| | | }, |
| | | //所需数据选项 |
| | | groups: [], |
| | | groupsProps: { |
| | | value: "id", |
| | | multiple: true, |
| | | checkStrictly: true |
| | | }, |
| | | depts: [], |
| | | deptsProps: { |
| | | value: "id", |
| | | checkStrictly: true |
| | | } |
| | | } |
| | | }, |
| | | mounted() { |
| | | this.getStatus(); |
| | | this.getpost(); //岗位 |
| | | this.getOrganizationList(); //部门 |
| | | this.getUserId(); //关联账号 |
| | | this.getdeptId(); //数据权限调整 |
| | | }, |
| | | methods: { |
| | | getdeptId() { //数据权限调整 |
| | | this.$HTTP.get(`/api/blade-system/data-scope-manager/tree`).then(res=> { |
| | | if(res.code == 200) { |
| | | this.deptIdList = res.data; |
| | | } |
| | | }) |
| | | export default { |
| | | emits: ['success', 'closed'], |
| | | data() { |
| | | return { |
| | | departmentList: [], |
| | | parentData: {}, |
| | | selectedIds: [], |
| | | deptIdList: [], |
| | | userIdList: [], |
| | | organizationList: [], |
| | | postList: [], |
| | | statusList: [], |
| | | mode: "add", |
| | | titleMap: { |
| | | add: '添加员工', |
| | | edit: '修改员工', |
| | | show: '查看' |
| | | }, |
| | | getUserId() { //关联账号 |
| | | this.$HTTP.get(`/api/blade-user/unbind-account?tel=`).then(res=> { |
| | | if(res.code == 200) { |
| | | this.userIdList = res.data; |
| | | } |
| | | }) |
| | | visible: false, |
| | | isSaveing: false, |
| | | //表单数据 |
| | | addPersonForm: { |
| | | jobNumber: "", |
| | | name: "", |
| | | tel: "", |
| | | status: "", |
| | | postId: "", |
| | | email: "", |
| | | organizationId: [], |
| | | // pinCode: "", |
| | | hireDate: "", |
| | | jobNumber: "", |
| | | deptId: "", |
| | | userId: "" |
| | | }, |
| | | getOrganizationList() { //部门 |
| | | this.$HTTP.get(`/api/blade-cps/organization/tree?groupType=group_organization&groupCategory=1`).then(res=> { |
| | | if(res.code == 200) { |
| | | this.organizationList = res.data; |
| | | } |
| | | }) |
| | | //验证规则 |
| | | addPersonRules: { |
| | | jobNumber: [{ required: true, message: '请输入工号' }], |
| | | name: [{ required: true, message: '请输入姓名' }], |
| | | tel: [{ required: true, message: '请输入手机号' }], |
| | | status: [{ required: true, message: '请选择状态', trigger: 'change' }], |
| | | // pinCode: [{ required: true, message: '请输入PIN码' }], |
| | | }, |
| | | getpost() { //岗位 |
| | | this.$HTTP.get(`/api/blade-system/post/page?current=1&size=-1`).then(res=> { |
| | | if(res.code == 200) { |
| | | this.postList = res.data.records; |
| | | } |
| | | }) |
| | | //所需数据选项 |
| | | groups: [], |
| | | groupsProps: { |
| | | value: "id", |
| | | multiple: true, |
| | | checkStrictly: true |
| | | }, |
| | | getStatus() { //获取全部账号 |
| | | this.$HTTP.get(`/api/blade-system/dict/dictionary?code=employee_status`).then(res=> { |
| | | if(res.code == 200) { |
| | | this.statusList = res.data; |
| | | res.data.forEach(item=> { |
| | | if(item.dictValue == "在职") { |
| | | this.addPersonForm.status = item.dictKey; |
| | | } |
| | | }) |
| | | } |
| | | }) |
| | | }, |
| | | //显示 |
| | | open(mode='add'){ |
| | | this.mode = mode; |
| | | this.visible = true; |
| | | return this |
| | | }, |
| | | //加载树数据 |
| | | async getGroup(){ |
| | | var res = await this.$API.system.role.list.get(); |
| | | this.groups = res.data.rows; |
| | | }, |
| | | async getDept(){ |
| | | var res = await this.$API.system.dept.list.get(); |
| | | this.depts = res.data; |
| | | }, |
| | | //表单提交方法 |
| | | saveSubmit(){ |
| | | var obj = Object.assign({},this.addPersonForm); |
| | | obj.deptId = obj.deptId.join(","); |
| | | obj.postId = obj.postId.join(","); |
| | | this.$refs.dialogForm.validate(async (valid) => { |
| | | if (valid) { |
| | | this.$HTTP.post("/api/blade-cps/employee/submit",obj).then(res=> { |
| | | if(res.code == 200) { |
| | | this.$emit('success', this.addPersonForm, this.mode); |
| | | this.visible = false; |
| | | this.$message.success("操作成功"); |
| | | }else { |
| | | this.$alert(res.message, "提示", {type: 'error'}); |
| | | } |
| | | }) |
| | | }else{ |
| | | return false; |
| | | } |
| | | }) |
| | | }, |
| | | //表单注入数据 |
| | | setData(data){ |
| | | this.$HTTP.get(`/api/blade-cps/employee/detail/${data.id}`).then(res=> { |
| | | if(res.code == 200) { |
| | | res.data.postId = res.data.postId.split(","); |
| | | res.data.deptId = res.data.deptId.split(","); |
| | | //可以和上面一样单个注入,也可以像下面一样直接合并进去 |
| | | Object.assign(this.addPersonForm, res.data) |
| | | } |
| | | }) |
| | | depts: [], |
| | | deptsProps: { |
| | | value: "id", |
| | | checkStrictly: true |
| | | } |
| | | } |
| | | }, |
| | | mounted() { |
| | | this.getStatus(); |
| | | this.getpost(); //岗位 |
| | | this.getOrganizationList(); //部门 |
| | | this.getUserId(); //关联账号 |
| | | this.getdeptId(); //数据权限调整 |
| | | }, |
| | | methods: { |
| | | parentIdChange(val) { |
| | | // var $parentId = this.$refs.parentTree.getCurrentNode().title; |
| | | // this.depatmentForm.$parentId = $parentId; |
| | | }, |
| | | getdeptId() { //数据权限调整 |
| | | this.$HTTP.get(`/api/blade-system/data-scope-manager/tree`).then(res => { |
| | | if (res.code == 200) { |
| | | this.deptIdList = res.data; |
| | | } |
| | | }) |
| | | }, |
| | | getUserId() { //关联账号 |
| | | this.$HTTP.get(`/api/blade-user/unbind-account?tel=`).then(res => { |
| | | if (res.code == 200) { |
| | | this.userIdList = res.data; |
| | | } |
| | | }) |
| | | }, |
| | | getOrganizationList() { |
| | | this.$HTTP.get(`/api/smis/organization/tree?groupType=group_organization&groupCategory=1`).then(res => { |
| | | if (res.code == 200) { |
| | | this.departmentList = res.data; |
| | | this.addPersonForm.organizationId = res.data[0].id; |
| | | } |
| | | }) |
| | | }, |
| | | getpost() { //岗位 |
| | | this.$HTTP.get(`/api/blade-system/post/page?current=1&size=-1`).then(res => { |
| | | if (res.code == 200) { |
| | | this.postList = res.data.records; |
| | | } |
| | | }) |
| | | }, |
| | | getStatus() { //获取全部账号 |
| | | this.$HTTP.get(`/api/blade-system/dict/dictionary?code=employee_status`).then(res => { |
| | | if (res.code == 200) { |
| | | this.statusList = res.data; |
| | | res.data.forEach(item => { |
| | | if (item.dictValue == "在职") { |
| | | this.addPersonForm.status = item.dictKey; |
| | | } |
| | | }) |
| | | } |
| | | }) |
| | | }, |
| | | //显示 |
| | | open(mode = 'add') { |
| | | this.mode = mode; |
| | | this.visible = true; |
| | | return this |
| | | }, |
| | | //加载树数据 |
| | | async getGroup() { |
| | | var res = await this.$API.system.role.list.get(); |
| | | this.groups = res.data.rows; |
| | | }, |
| | | async getDept() { |
| | | var res = await this.$API.system.dept.list.get(); |
| | | this.depts = res.data; |
| | | }, |
| | | //表单提交方法 |
| | | saveSubmit() { |
| | | var obj = Object.assign({}, this.addPersonForm); |
| | | obj.deptId = obj.deptId.join(","); |
| | | obj.postId = obj.postId.join(","); |
| | | this.$refs.dialogForm.validate(async (valid) => { |
| | | if (valid) { |
| | | this.$HTTP.post("/api/smis/employee/submit", obj).then(res => { |
| | | if (res.code == 200) { |
| | | this.$emit('success', this.addPersonForm, this.mode); |
| | | this.visible = false; |
| | | this.$message.success("操作成功"); |
| | | } else { |
| | | this.$alert(res.message, "提示", { type: 'error' }); |
| | | } |
| | | }) |
| | | } else { |
| | | return false; |
| | | } |
| | | }) |
| | | }, |
| | | //表单注入数据 |
| | | setData(data) { |
| | | this.$HTTP.get(`/api/smis/employee/detail/${data.id}`).then(res => { |
| | | if (res.code == 200) { |
| | | if (res.data.postId) { |
| | | res.data.postId = res.data.postId.split(","); |
| | | } else { |
| | | res.data.postId = []; |
| | | } |
| | | if (res.data.deptId) { |
| | | res.data.deptId = res.data.deptId.split(","); |
| | | } else { |
| | | res.data.deptId = []; |
| | | } |
| | | res.data.status = String(res.data.status); |
| | | //可以和上面一样单个注入,也可以像下面一样直接合并进去 |
| | | Object.assign(this.addPersonForm, res.data); |
| | | } |
| | | }) |
| | | } |
| | | } |
| | | } |
| | | </script> |
| | | |
| | | <style> |
| | | </style> |
| | | <style></style> |