|
@@ -1,16 +1,30 @@
|
|
|
<template>
|
|
|
- <m-dialog ref="editDialog" v-bind="$attrs" @sure="handleSaveEdit">
|
|
|
- <m-form ref="formRef" :items="items" v-model="query"></m-form>
|
|
|
+ <m-dialog ref="editDialog" :title="title" v-bind="$attrs" @sure="handleSaveEdit">
|
|
|
+ <m-form ref="formRef" :items="items" v-model="query" v-loading="loading"></m-form>
|
|
|
</m-dialog>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
import { saveRoster } from '@/api/system'
|
|
|
+import { mapGetters } from 'vuex'
|
|
|
import {
|
|
|
getSalaryLevelDict
|
|
|
} from '@/api/salary'
|
|
|
+import {
|
|
|
+ getJobLevel,
|
|
|
+ getPositionCategory,
|
|
|
+ getPersonnelCategory,
|
|
|
+ getPositionSequence,
|
|
|
+ getJobName
|
|
|
+} from '@/api/dictionary'
|
|
|
export default {
|
|
|
name: 'roster-edit',
|
|
|
+ props: {
|
|
|
+ title: {
|
|
|
+ type: String,
|
|
|
+ default: '新增'
|
|
|
+ }
|
|
|
+ },
|
|
|
data () {
|
|
|
return {
|
|
|
query: {},
|
|
@@ -20,23 +34,42 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
computed: {
|
|
|
+ ...mapGetters(['organizationTree']),
|
|
|
items () {
|
|
|
return [
|
|
|
- { label: '上级机构', prop: 'parentOrganizationName', type: 'input', options: { placeholder: '请输入上级机构' }, rules: { required: true, message: '请输入上级机构', trigger: 'blur' } },
|
|
|
- { label: '部门名称', prop: 'deptName', type: 'input', options: { placeholder: '请输入部门名称' }, rules: { required: true, message: '请输入部门名称', trigger: 'blur' } },
|
|
|
{
|
|
|
- label: '员工名称',
|
|
|
- prop: 'employeeName',
|
|
|
- type: 'input',
|
|
|
- options: { disabled: this.isEdit, placeholder: '请输入员工名称' },
|
|
|
- rules: { required: true, message: '请输入员工名称', trigger: 'blur' }
|
|
|
+ prop: 'parentOrganizationName',
|
|
|
+ hidden: true
|
|
|
},
|
|
|
{
|
|
|
- label: '人员类别',
|
|
|
- prop: 'personnelCategory',
|
|
|
- type: 'input',
|
|
|
- options: { disabled: this.isEdit, placeholder: '请输入人员类别' },
|
|
|
- rules: { required: true, message: '请输入人员类别', trigger: 'blur' }
|
|
|
+ prop: 'parentOrganizationNo',
|
|
|
+ hidden: true
|
|
|
+ },
|
|
|
+ {
|
|
|
+ prop: 'deptName',
|
|
|
+ hidden: true
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: '部门名称',
|
|
|
+ prop: 'organizationNo',
|
|
|
+ type: 'cascader',
|
|
|
+ options: {
|
|
|
+ ref: 'organizationNo',
|
|
|
+ filterable: true,
|
|
|
+ clearable: true,
|
|
|
+ placeholder: '请选择部门',
|
|
|
+ options: this.organizationTree,
|
|
|
+ showAllLevels: false,
|
|
|
+ props: {
|
|
|
+ emitPath: false,
|
|
|
+ value: 'organizationNo',
|
|
|
+ label: 'organizationName',
|
|
|
+ children: 'child'
|
|
|
+ }
|
|
|
+ },
|
|
|
+ handles: {
|
|
|
+ change: this.onChange
|
|
|
+ }
|
|
|
},
|
|
|
{
|
|
|
label: '通行证号',
|
|
@@ -45,6 +78,13 @@ export default {
|
|
|
options: { disabled: this.isEdit, placeholder: '请输入通行证号' },
|
|
|
rules: [{ required: true, message: '请输入通行证号', trigger: 'blur' }]
|
|
|
},
|
|
|
+ {
|
|
|
+ label: '员工名称',
|
|
|
+ prop: 'employeeName',
|
|
|
+ type: 'input',
|
|
|
+ options: { disabled: this.isEdit, placeholder: '请输入员工名称' },
|
|
|
+ rules: { required: true, message: '请输入员工名称', trigger: 'blur' }
|
|
|
+ },
|
|
|
{
|
|
|
label: '工行时间',
|
|
|
prop: 'tradeUnionsTime',
|
|
@@ -52,10 +92,62 @@ export default {
|
|
|
options: { disabled: this.isEdit, placeholder: '请选择工行时间' },
|
|
|
rules: [{ required: true, message: '请选择工行时间', trigger: 'blur' }]
|
|
|
},
|
|
|
- { label: '岗位名称', prop: 'postName', type: 'input', options: { placeholder: '请输入岗位名称' }, rules: { required: true, message: '请输入岗位名称', trigger: 'blur' } },
|
|
|
- { label: '岗位序列', prop: 'positionSequence', type: 'input', options: { placeholder: '请输入岗位序列' }, rules: [{ required: true, message: '请输入岗位序列', trigger: 'blur' }] },
|
|
|
- { label: '岗位类别', prop: 'positionCategory', type: 'input', options: { placeholder: '请输入岗位类别' }, rules: [{ required: true, message: '请输入岗位类别', trigger: 'blur' }] },
|
|
|
- { label: '职务层级', prop: 'jobLevel', type: 'input', options: { placeholder: '请输入职务层级' }, rules: [{ required: true, message: '请输入职务层级', trigger: 'blur' }] },
|
|
|
+ {
|
|
|
+ label: '人员类别',
|
|
|
+ prop: 'personnelCategory',
|
|
|
+ type: 'select',
|
|
|
+ options: {
|
|
|
+ disabled: this.isEdit,
|
|
|
+ placeholder: '请输入人员类别',
|
|
|
+ filterable: true,
|
|
|
+ items: this.dict.personnelCategory
|
|
|
+ },
|
|
|
+ rules: { required: true, message: '请输入人员类别', trigger: 'change' }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: '岗位名称',
|
|
|
+ prop: 'postName',
|
|
|
+ type: 'select',
|
|
|
+ options: {
|
|
|
+ placeholder: '请输入岗位名称',
|
|
|
+ filterable: true,
|
|
|
+ items: this.dict.jobName
|
|
|
+ },
|
|
|
+ rules: { required: true, message: '请输入岗位名称', trigger: 'change' }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: '岗位序列',
|
|
|
+ prop: 'positionSequence',
|
|
|
+ type: 'select',
|
|
|
+ options: {
|
|
|
+ placeholder: '请输入岗位序列',
|
|
|
+ filterable: true,
|
|
|
+ items: this.dict.positionSequence
|
|
|
+ },
|
|
|
+ rules: [{ required: true, message: '请输入岗位序列', trigger: 'change' }]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: '岗位类别',
|
|
|
+ prop: 'positionCategory',
|
|
|
+ type: 'select',
|
|
|
+ options: {
|
|
|
+ placeholder: '请输入岗位类别',
|
|
|
+ filterable: true,
|
|
|
+ items: this.dict.positionCategory
|
|
|
+ },
|
|
|
+ rules: [{ required: true, message: '请输入岗位类别', trigger: 'change' }]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: '职务层级',
|
|
|
+ prop: 'jobLevel',
|
|
|
+ type: 'select',
|
|
|
+ options: {
|
|
|
+ placeholder: '请输入职务层级',
|
|
|
+ filterable: true,
|
|
|
+ items: this.dict.jobLevel
|
|
|
+ },
|
|
|
+ rules: [{ required: true, message: '请输入职务层级', trigger: 'change' }]
|
|
|
+ },
|
|
|
{
|
|
|
label: '薪酬档次',
|
|
|
prop: 'salaryCategory',
|
|
@@ -87,15 +179,19 @@ export default {
|
|
|
res[item.prop] = null
|
|
|
return res
|
|
|
}, {})
|
|
|
+ this.$nextTick(() => {
|
|
|
+ this.$refs.formRef.clearValidate()
|
|
|
+ })
|
|
|
this.isEdit = Boolean(item)
|
|
|
await this.getDict()
|
|
|
- this.loading = false
|
|
|
+ await this.getOtherDict()
|
|
|
if (item) {
|
|
|
Object.keys(this.query).forEach(key => {
|
|
|
this.query[key] = item[key]
|
|
|
})
|
|
|
this.query.personnelCode = item.personnelCode
|
|
|
}
|
|
|
+ this.loading = false
|
|
|
},
|
|
|
handleSaveEdit () {
|
|
|
this.$refs.formRef.validate(async valid => {
|
|
@@ -121,10 +217,22 @@ export default {
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
+ onChange () {
|
|
|
+ const nodes = this.$refs.formRef.$refs.organizationNo.getCheckedNodes()
|
|
|
+ const node = nodes[0].data
|
|
|
+ const parent = nodes[0].parent.data
|
|
|
+ Object.assign(this.query, {
|
|
|
+ organizationNo: node.organizationNo,
|
|
|
+ deptName: node.organizationName,
|
|
|
+ parentOrganizationName: parent.organizationName,
|
|
|
+ parentOrganizationNo: parent.organizationNo
|
|
|
+ })
|
|
|
+ },
|
|
|
async getDict () {
|
|
|
try {
|
|
|
const { data } = await getSalaryLevelDict()
|
|
|
- this.dict = {
|
|
|
+ const dict = { ...this.dict }
|
|
|
+ Object.assign(dict, {
|
|
|
gradeDict: data.gradeDict.map(e => {
|
|
|
return {
|
|
|
label: e,
|
|
@@ -137,7 +245,28 @@ export default {
|
|
|
value: e
|
|
|
}
|
|
|
})
|
|
|
- }
|
|
|
+ })
|
|
|
+ this.dict = dict
|
|
|
+ } catch (error) {
|
|
|
+ this.$message.error(error)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ async getOtherDict () {
|
|
|
+ const lists = [
|
|
|
+ { key: 'jobLevel', fn: getJobLevel },
|
|
|
+ { key: 'positionCategory', fn: getPositionCategory },
|
|
|
+ { key: 'personnelCategory', fn: getPersonnelCategory },
|
|
|
+ { key: 'positionSequence', fn: getPositionSequence },
|
|
|
+ { key: 'jobName', fn: getJobName }
|
|
|
+ ]
|
|
|
+ try {
|
|
|
+ const result = await Promise.all(lists.map(item => item.fn()))
|
|
|
+ const dict = { ...this.dict }
|
|
|
+ Object.assign(dict, lists.reduce((res, item, index) => {
|
|
|
+ res[item.key] = result[index].data.map(e => ({ label: e, value: e }))
|
|
|
+ return res
|
|
|
+ }, {}))
|
|
|
+ this.dict = dict
|
|
|
} catch (error) {
|
|
|
this.$message.error(error)
|
|
|
}
|