|
@@ -16,10 +16,9 @@
|
|
|
{ label: '参数类型', prop: 'valueCategory' },
|
|
|
{ label: '操作', prop: 'actions' }
|
|
|
]"
|
|
|
- @expand-change="onExpandChange"
|
|
|
>
|
|
|
- <template #expandProp="{ row, $index }">
|
|
|
- <SalarySolutionRulesEditParam :ref="`salarySolutionRulesEditParamRefs${$index}`" @assign="onAssign(row, $event)"></SalarySolutionRulesEditParam>
|
|
|
+ <template #expandProp="{ $index }">
|
|
|
+ <SalarySolutionRulesEditParam :ref="`salarySolutionRulesEditParamRefs${$index}`" v-model="items[$index]"></SalarySolutionRulesEditParam>
|
|
|
</template>
|
|
|
<div class="text-center mt-3">
|
|
|
<m-button icon="el-icon-plus" type="orange" size="small" @click="onAdd">添加参数</m-button>
|
|
@@ -98,9 +97,6 @@ export default {
|
|
|
editor.destroy() // 组件销毁时,及时销毁编辑器
|
|
|
},
|
|
|
methods: {
|
|
|
- onAssign (row, obj) {
|
|
|
- Object.assign(row, obj)
|
|
|
- },
|
|
|
onCreated (editor) {
|
|
|
this.editor = Object.seal(editor) // 一定要用 Object.seal() ,否则会报错
|
|
|
},
|
|
@@ -122,10 +118,15 @@ export default {
|
|
|
valid () {
|
|
|
return new Promise((resolve, reject) => {
|
|
|
const check = this.items.every(e => {
|
|
|
- if (!this.$refs[`salarySolutionRulesEditParamRefs${e.index}`]) {
|
|
|
- return true
|
|
|
+ if (!e.name) {
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ if (e.valueCategory !== 0) {
|
|
|
+ return e.value.every(_e => {
|
|
|
+ return (_e.name === null && _e.value === null) || (_e.name !== null && _e.value !== null)
|
|
|
+ })
|
|
|
}
|
|
|
- return this.$refs[`salarySolutionRulesEditParamRefs${e.index}`].valid()
|
|
|
+ return true
|
|
|
})
|
|
|
if (!check) {
|
|
|
reject(this.item)
|
|
@@ -134,33 +135,64 @@ export default {
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
- onExpandChange (row, expandedRows) {
|
|
|
- const open = expandedRows.find(e => e.index === row.index)
|
|
|
- if (!open) {
|
|
|
- return
|
|
|
- }
|
|
|
- this.$nextTick(() => {
|
|
|
- this.$refs[`salarySolutionRulesEditParamRefs${row.index}`].setValue(row)
|
|
|
- })
|
|
|
- },
|
|
|
setValue (data) {
|
|
|
this.items = data.calculateConfigurations.map((e, index) => {
|
|
|
+ if (e.valueCategory !== 0) {
|
|
|
+ const { value, ...obj } = e
|
|
|
+ return {
|
|
|
+ index,
|
|
|
+ value: JSON.parse(value),
|
|
|
+ ...obj
|
|
|
+ }
|
|
|
+ }
|
|
|
return {
|
|
|
index,
|
|
|
...e
|
|
|
}
|
|
|
})
|
|
|
- this.$nextTick(() => {
|
|
|
- this.formulaData = data.calculateFormulas.length ? data.calculateFormulas[0].content : ''
|
|
|
- })
|
|
|
+ this.formulaData = data.calculateFormulas.length ? data.calculateFormulas[0].content : ''
|
|
|
+ // this.$nextTick(() => {
|
|
|
+ // this.formulaData = data.calculateFormulas.length ? data.calculateFormulas[0].content : ''
|
|
|
+ // })
|
|
|
},
|
|
|
getValue () {
|
|
|
const calculateConfigurations = this.items.map(e => {
|
|
|
- if (!this.$refs[`salarySolutionRulesEditParamRefs${e.index}`]) {
|
|
|
- const { index, ...obj } = e
|
|
|
- return obj
|
|
|
+ const {
|
|
|
+ name,
|
|
|
+ valueCategory,
|
|
|
+ miniValue,
|
|
|
+ maxValue,
|
|
|
+ value
|
|
|
+ } = e
|
|
|
+ if (valueCategory === 0) {
|
|
|
+ return {
|
|
|
+ name,
|
|
|
+ valueCategory,
|
|
|
+ miniValue: miniValue ?? null,
|
|
|
+ maxValue: maxValue ?? null,
|
|
|
+ value
|
|
|
+ }
|
|
|
+ }
|
|
|
+ const _value = JSON.stringify(value.map(_e => {
|
|
|
+ return {
|
|
|
+ name: _e.name,
|
|
|
+ value: _e.value
|
|
|
+ }
|
|
|
+ }))
|
|
|
+ if (valueCategory === 1) {
|
|
|
+ return {
|
|
|
+ name,
|
|
|
+ valueCategory,
|
|
|
+ value: _value
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return {
|
|
|
+ name,
|
|
|
+ valueCategory,
|
|
|
+ miniValue: miniValue ?? null,
|
|
|
+ maxValue: maxValue ?? null,
|
|
|
+ value: _value
|
|
|
}
|
|
|
- return this.$refs[`salarySolutionRulesEditParamRefs${e.index}`].getValue()
|
|
|
})
|
|
|
return {
|
|
|
category: this.item.title,
|