Browse Source

修复科室添加后报错,以及添加上级科室字段

master
李磊 3 years ago
parent
commit
8aa50a7724
  1. 39
      src/views/user/department.vue

39
src/views/user/department.vue

@ -84,6 +84,11 @@
<el-form-item label="部门代码(选填)"> <el-form-item label="部门代码(选填)">
<el-input v-model="tempDepartment.code" type="text" size="small" style="width: 200px" /> <el-input v-model="tempDepartment.code" type="text" size="small" style="width: 200px" />
</el-form-item> </el-form-item>
<el-form-item label="上级科室">
<el-select v-model="tempDepartment.parentId" filterable clearable>
<el-option v-for="dept in departments" :key="dept.id" :value="dept.id" :label="dept.name" />
</el-select>
</el-form-item>
<el-form-item label="成员"> <el-form-item label="成员">
<template> <template>
<el-transfer v-model="departmentUserList" :props="{key: 'id', label: 'nickname'}" :button-texts="['移除', '添加']" :titles="['未分配员工', '部门成员']" :data="unAllotUserList" /> <el-transfer v-model="departmentUserList" :props="{key: 'id', label: 'nickname'}" :button-texts="['移除', '添加']" :titles="['未分配员工', '部门成员']" :data="unAllotUserList" />
@ -134,15 +139,31 @@ export default {
multipleSelection: [], multipleSelection: [],
isIndeterminate: true, isIndeterminate: true,
sbzlList: [], sbzlList: [],
areas: [] areas: [],
departmentAll: []
}
},
computed: {
departments: function() {
return this.departmentAll.filter(row => row.id !== this.tempDepartment.id)
} }
}, },
created() { created() {
this.getList() this.getList()
this.getSbzlList() this.getSbzlList()
this.getArea() this.getArea()
this.getAllDepartment()
}, },
methods: { methods: {
getAllDepartment() {
this.api({
url: '/department/all',
method: 'get'
}).then(data => {
this.departmentAll = [{ id: 0, name: '顶级科室' }]
this.departmentAll = this.departmentAll.concat(data)
})
},
getSbzlList() { getSbzlList() {
this.api({ this.api({
url: '/sedirectory/getList', url: '/sedirectory/getList',
@ -181,7 +202,9 @@ export default {
}, },
showCreate() { showCreate() {
this.leaders = this.$store.getters.allUser this.leaders = this.$store.getters.allUser
this.tempDepartment = {} this.tempDepartment = {
parentId: 0
}
this.getUserListByDepartmentIdOrNull(0) this.getUserListByDepartmentIdOrNull(0)
this.dialogStatus = 'create' this.dialogStatus = 'create'
this.dialogFormVisible = true this.dialogFormVisible = true
@ -189,9 +212,9 @@ export default {
showUpdate(item) { showUpdate(item) {
this.leaders = this.$store.getters.allUser this.leaders = this.$store.getters.allUser
this.tempDepartment = item this.tempDepartment = item
this.tempDepartment.quhuadaima = item.quhuadaima.split(',') this.tempDepartment.quhuadaima = item.quhuadaima && item.quhuadaima.split(',')
this.tempDepartment.shebeizhongleidaima = item.shebeizhongleidaima.split(',') this.tempDepartment.shebeizhongleidaima = item.shebeizhongleidaima && item.shebeizhongleidaima.split(',')
this.tempDepartment.jianyanleibie = item.jianyanleibie.split(',') this.tempDepartment.jianyanleibie = item.jianyanleibie && item.jianyanleibie.split(',')
this.getUserListByDepartmentIdOrNull(item.id) this.getUserListByDepartmentIdOrNull(item.id)
this.getUserListByDepartmentId(item.id) this.getUserListByDepartmentId(item.id)
this.dialogStatus = 'update' this.dialogStatus = 'update'
@ -227,9 +250,9 @@ export default {
const form = {} const form = {}
form.department = this.tempDepartment form.department = this.tempDepartment
form.userIds = this.departmentUserList form.userIds = this.departmentUserList
form.department.quhuadaima = form.department.quhuadaima.toString() form.department.quhuadaima = form.department.quhuadaima && form.department.quhuadaima.toString()
form.department.shebeizhongleidaima = form.department.shebeizhongleidaima.toString() form.department.shebeizhongleidaima = form.department.shebeizhongleidaima && form.department.shebeizhongleidaima.toString()
form.department.jianyanleibie = form.department.jianyanleibie.toString() form.department.jianyanleibie = form.department.jianyanleibie && form.department.jianyanleibie.toString()
this.$refs['tempDepartment'].validate(valid => { this.$refs['tempDepartment'].validate(valid => {
if (valid) { if (valid) {
addDepartmentFn(form).then(() => { addDepartmentFn(form).then(() => {

Loading…
Cancel
Save