|
@@ -0,0 +1,180 @@
|
|
|
+<template>
|
|
|
+ <m-dialog :title="isEdit ? '编辑配置' : '新增配置'" ref="dialog" @sure="onSure">
|
|
|
+ <m-form ref="form" :items="formItems" v-model="formValues" v-loading="loading"></m-form>
|
|
|
+
|
|
|
+ </m-dialog>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+import { mapGetters } from 'vuex'
|
|
|
+import {
|
|
|
+ getRosterList
|
|
|
+} from '@/api/system'
|
|
|
+import {
|
|
|
+ saveAllocationConfig
|
|
|
+} from '@/api/bonus'
|
|
|
+export default {
|
|
|
+ name: 'AllocationConfigEdit',
|
|
|
+ data () {
|
|
|
+ return {
|
|
|
+ formValues: {
|
|
|
+ employeeCode: null,
|
|
|
+ employeeName: null,
|
|
|
+ organizationNo: null,
|
|
|
+ organizationName: null
|
|
|
+ },
|
|
|
+ itemData: {},
|
|
|
+ filterLoading: false,
|
|
|
+ loading: false,
|
|
|
+ items: []
|
|
|
+ }
|
|
|
+ },
|
|
|
+ computed: {
|
|
|
+ isEdit () {
|
|
|
+ return Object.keys(this.itemData).length > 0
|
|
|
+ },
|
|
|
+ ...mapGetters(['organizationTree']),
|
|
|
+ organizationItems () {
|
|
|
+ if (this.organizationTree.length > 0) {
|
|
|
+ return this.organizationTree[0].child
|
|
|
+ }
|
|
|
+ return []
|
|
|
+ },
|
|
|
+ formItems () {
|
|
|
+ return [
|
|
|
+ {
|
|
|
+ label: '管理者',
|
|
|
+ prop: 'employeeCode',
|
|
|
+ type: 'select',
|
|
|
+ options: {
|
|
|
+ placeholder: '请选择管理者',
|
|
|
+ filterable: true,
|
|
|
+ remote: true,
|
|
|
+ labelText: 'employeeName',
|
|
|
+ labelValue: 'personnelCode',
|
|
|
+ remoteMethod: this.remoteMethod,
|
|
|
+ valueKey: 'personnelCode',
|
|
|
+ defaultFirstOption: true,
|
|
|
+ loading: this.filterLoading,
|
|
|
+ items: this.items
|
|
|
+ },
|
|
|
+ handles: {
|
|
|
+ change: (v) => {
|
|
|
+ const item = this.items.find(e => e.personnelCode === v)
|
|
|
+ this.formValues.employeeName = item.employeeName
|
|
|
+ this.formValues.employeeCode = item.personnelCode
|
|
|
+ }
|
|
|
+ },
|
|
|
+ rules: [
|
|
|
+ { required: true, message: '请选择管理者', trigger: 'change' }
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: '管理机构',
|
|
|
+ prop: 'organizationNo',
|
|
|
+ type: 'cascader',
|
|
|
+ rules: [
|
|
|
+ { required: true, message: '请选择机构', trigger: 'change' }
|
|
|
+ ],
|
|
|
+ options: {
|
|
|
+ ref: 'organizationNo',
|
|
|
+ filterable: true,
|
|
|
+ clearable: true,
|
|
|
+ placeholder: '请选择机构',
|
|
|
+ options: this.organizationItems,
|
|
|
+ showAllLevels: false,
|
|
|
+ props: {
|
|
|
+ emitPath: false,
|
|
|
+ checkStrictly: true,
|
|
|
+ value: 'organizationNo',
|
|
|
+ label: 'organizationName',
|
|
|
+ children: 'child'
|
|
|
+ }
|
|
|
+ },
|
|
|
+ handles: {
|
|
|
+ change: (v) => {
|
|
|
+ const nodes = this.$refs.form.$refs.organizationNo.getCheckedNodes()
|
|
|
+ this.formValues.organizationNo = nodes[0].data.organizationNo
|
|
|
+ this.formValues.organizationName = nodes[0].data.organizationName
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ open (item) {
|
|
|
+ this.loading = true
|
|
|
+ // 默认获取一次
|
|
|
+ this.remoteMethod()
|
|
|
+ if (!item) {
|
|
|
+ this.itemData = {}
|
|
|
+ this.formValues = {
|
|
|
+ employeeCode: null,
|
|
|
+ employeeName: null,
|
|
|
+ organizationNo: null,
|
|
|
+ organizationName: null
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ this.itemData = item
|
|
|
+ this.formValues = {
|
|
|
+ employeeCode: item.employeeCode,
|
|
|
+ organizationName: item.organizationName,
|
|
|
+ organizationNo: item.organizationNo,
|
|
|
+ employeeName: item.employeeName
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.$refs.dialog.open()
|
|
|
+ this.$nextTick(() => {
|
|
|
+ this.$refs.form.clearValidate()
|
|
|
+ this.loading = false
|
|
|
+ })
|
|
|
+ },
|
|
|
+ async remoteMethod (str) {
|
|
|
+ this.filterLoading = true
|
|
|
+ try {
|
|
|
+ const { data } = await getRosterList({
|
|
|
+ entity: {
|
|
|
+ employeeName: str
|
|
|
+ },
|
|
|
+ page: {
|
|
|
+ current: 1,
|
|
|
+ size: 99
|
|
|
+ }
|
|
|
+ })
|
|
|
+ this.items = data.records
|
|
|
+ } catch (error) {
|
|
|
+ this.items = []
|
|
|
+ this.$message.error(error)
|
|
|
+ } finally {
|
|
|
+ this.filterLoading = false
|
|
|
+ }
|
|
|
+ },
|
|
|
+ onSure () {
|
|
|
+ this.$refs.form.validate(async valid => {
|
|
|
+ if (!valid) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ this.loading = true
|
|
|
+ try {
|
|
|
+ await saveAllocationConfig({
|
|
|
+ performanceSalaryManageEmployeeId: this.itemData.performanceSalaryManageEmployeeId,
|
|
|
+ ...this.formValues
|
|
|
+ })
|
|
|
+ this.$refs.dialog.close()
|
|
|
+ this.$message.success('操作成功')
|
|
|
+ this.$emit('success')
|
|
|
+ } catch (error) {
|
|
|
+ this.$message.error(error)
|
|
|
+ } finally {
|
|
|
+ this.loading = false
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="scss" scoped>
|
|
|
+
|
|
|
+</style>
|