<template>
|
<GlobalWindow
|
:title="title"
|
:visible.sync="visible"
|
:confirm-working="isWorking"
|
@confirm="changeTissue"
|
>
|
<el-form :model="form" ref="form" :rules="rules">
|
<el-form-item label="所在部门" prop="departmentId">
|
<el-cascader
|
placeholder="请选择所属部门"
|
v-model="form.departmentId"
|
:options="departmentList"
|
:props="{ value: 'id', label: 'name', checkStrictly: true }"
|
:show-all-levels="false"
|
|
></el-cascader>
|
</el-form-item>
|
</el-form>
|
</GlobalWindow>
|
</template>
|
|
<script>
|
import BaseOpera from '@/components/base/BaseOpera'
|
import GlobalWindow from '@/components/common/GlobalWindow'
|
// import ZuzhiSelect from './zuzhiSelect.vue'
|
import { treeComList, updateById } from '@/api/ext/companyUserExt'
|
|
export default {
|
name: 'OperaCategoryExtWindow',
|
extends: BaseOpera,
|
components: { GlobalWindow },
|
props: {
|
id: {
|
type: String,
|
required: false,
|
default: () => ''
|
}
|
},
|
data () {
|
return {
|
// 表单数据
|
form: {
|
departmentId: null
|
},
|
// 验证规则
|
rules: {
|
name: [
|
{ required: true, message: '请选择所在部门', trigger: 'blur' }
|
]
|
},
|
departmentList: []
|
}
|
},
|
methods: {
|
open (title, target) {
|
this.title = title
|
this.visible = true
|
console.log('target', target)
|
// 新建
|
if (target == null) {
|
this.$nextTick(() => {
|
this.$refs.form.resetFields()
|
this.form[this.configData['field.id']] = null
|
})
|
return
|
}
|
// 编辑
|
this.$nextTick(() => {
|
for (const key in this.form) {
|
this.form[key] = target[key]
|
}
|
})
|
},
|
changeTissue () {
|
|
let departmentIds = JSON.parse(JSON.stringify(this.form.departmentId))
|
// console.log(departmentIds)
|
|
this.$refs.form.validate((valid) => {
|
if (valid) {
|
updateById({
|
id: this.id,
|
departmentId: departmentIds[departmentIds.length - 1]
|
}).then(res => {
|
this.$tip.success('更换组织成功')
|
this.visible = false
|
this.isWorking = false
|
this.$emit('success')
|
})
|
} else {
|
return false
|
}
|
})
|
},
|
handleChange (e) {
|
// console.log(e)
|
this.form.departmentId = e[e.length - 1]
|
},
|
// 获取企业部门数据
|
treeComList () {
|
treeComList({})
|
.then(res => {
|
this.departmentList = [res]
|
})
|
}
|
/**
|
* 确认更改部门
|
*/
|
// confirm () {
|
// this.api.create({
|
// id: this.targetUser.id,
|
// departmentId: this.form.departmentId
|
// })
|
// .then((res) => {
|
// this.$tip.apiSuccess(res)
|
// this.visible = false
|
// this.$emit('success')
|
// }).catch((err) => {
|
// this.$tip.apiFailed(err)
|
// })
|
// },
|
// 打开部门窗口
|
// open (title, target) {
|
// console.log(target, 'this.isShow')
|
// this.title = title
|
// this.targetUser = target
|
// this.visible = true
|
// this.form.departmentId = target.departmentId
|
// console.log(this.form, 'this.isShow')
|
// },
|
// changeModel (item) {
|
// if (item === '1') {
|
// console.log('vvvvisShow', this.isShow)
|
// this.isShow = false
|
// } else if (item === '2' || item === '3') {
|
// console.log('isShow', this.isShow)
|
// this.isShow = true
|
// console.log('isShowssss', this.isShow)
|
// }
|
// }
|
|
},
|
mounted () {
|
// this.changeModel()
|
},
|
created () {
|
this.config({
|
api: '/system/user',
|
'field.id': 'id'
|
})
|
this.treeComList()
|
}
|
}
|
</script>
|