|
@@ -1,80 +1,133 @@
|
|
<template>
|
|
<template>
|
|
- <m-card shadow="never">
|
|
|
|
- <div>
|
|
|
|
- <div class="d-flex mb-3">
|
|
|
|
- <div class="boxLabel">参数配置</div>
|
|
|
|
- <div class="boxContent">
|
|
|
|
- <m-table
|
|
|
|
- ref="tableRefs"
|
|
|
|
- shadow="naver"
|
|
|
|
- clearHeader
|
|
|
|
- :items="items"
|
|
|
|
- row-key="index"
|
|
|
|
- :headers="[
|
|
|
|
- { type: 'expand', prop: 'expandProp' },
|
|
|
|
- { label: '参数', prop: 'name' },
|
|
|
|
- { label: '参数类型', prop: 'valueCategory' },
|
|
|
|
- { label: '操作', prop: 'actions' }
|
|
|
|
- ]"
|
|
|
|
- >
|
|
|
|
- <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>
|
|
|
|
- </div>
|
|
|
|
- <template #valueCategory="{ row }">
|
|
|
|
- {{ DICT_CATEGORY.find(item => item.value === row.valueCategory)?.label }}
|
|
|
|
- </template>
|
|
|
|
- <template #actions="scope">
|
|
|
|
- <m-button size="small" text type="danger" @click="onDelete(scope)">移除</m-button>
|
|
|
|
- </template>
|
|
|
|
- </m-table>
|
|
|
|
|
|
+ <!-- <m-card shadow="never"> -->
|
|
|
|
+ <div>
|
|
|
|
+ <el-form-item label="参数配置">
|
|
|
|
+ <m-card shadow="never">
|
|
|
|
+ <el-row>
|
|
|
|
+ <el-col :span="8">参数名称</el-col>
|
|
|
|
+ <el-col :span="4" class="text-center">初始值</el-col>
|
|
|
|
+ <el-col :span="5" class="text-center">最小值 (是否启用)</el-col>
|
|
|
|
+ <el-col :span="5" class="text-center">最大值 (是否启用)</el-col>
|
|
|
|
+ <el-col :span="2">操作</el-col>
|
|
|
|
+ </el-row>
|
|
|
|
+ <el-row
|
|
|
|
+ v-for="(row, index) in items"
|
|
|
|
+ :key="row.key"
|
|
|
|
+ >
|
|
|
|
+ <el-col :span="8">
|
|
|
|
+ <el-input v-model="row.name" placeholder="请输入参数名称" size="small"></el-input>
|
|
|
|
+ </el-col>
|
|
|
|
+ <el-col :span="4" class="text-center">
|
|
|
|
+ <el-input-number v-model="row.value" placeholder="初始值" size="small"></el-input-number>
|
|
|
|
+ </el-col>
|
|
|
|
+ <el-col :span="5" class="text-center">
|
|
|
|
+ <el-input-number :disabled="!row.miniValueActive" v-model="row.miniValue" placeholder="最小值" size="small"></el-input-number>
|
|
|
|
+ <el-switch active-color="#13ce66" class="ml-3" v-model="row.miniValueActive"></el-switch>
|
|
|
|
+ </el-col>
|
|
|
|
+ <el-col :span="5" class="text-center">
|
|
|
|
+ <el-input-number :disabled="!row.maxValueActive" v-model="row.maxValue" placeholder="最大值" size="small"></el-input-number>
|
|
|
|
+ <el-switch active-color="#13ce66" class="ml-3" v-model="row.maxValueActive"></el-switch>
|
|
|
|
+ </el-col>
|
|
|
|
+ <el-col :span="2">
|
|
|
|
+ <m-button :disabled="items.length === 1" size="small" type="danger" @click="onDelete(index)">移除</m-button>
|
|
|
|
+ </el-col>
|
|
|
|
+ </el-row>
|
|
|
|
+ <div class="text-center mt-3">
|
|
|
|
+ <m-button type="orange" size="small" @click="onAdd">添加一个参数</m-button>
|
|
</div>
|
|
</div>
|
|
|
|
+ </m-card>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <!-- <div class="d-flex mb-3">
|
|
|
|
+ <div class="boxLabel">参数配置</div>
|
|
|
|
+ <div class="boxContent">
|
|
|
|
+ <m-table
|
|
|
|
+ ref="tableRefs"
|
|
|
|
+ shadow="naver"
|
|
|
|
+ clearHeader
|
|
|
|
+ :items="items"
|
|
|
|
+ row-key="index"
|
|
|
|
+ :headers="[
|
|
|
|
+ { type: 'expand', prop: 'expandProp' },
|
|
|
|
+ { label: '参数', prop: 'name' },
|
|
|
|
+ { label: '参数类型', prop: 'valueCategory' },
|
|
|
|
+ { label: '操作', prop: 'actions' }
|
|
|
|
+ ]"
|
|
|
|
+ >
|
|
|
|
+ <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>
|
|
|
|
+ </div>
|
|
|
|
+ <template #valueCategory="{ row }">
|
|
|
|
+ {{ DICT_CATEGORY.find(item => item.value === row.valueCategory)?.label }}
|
|
|
|
+ </template>
|
|
|
|
+ <template #actions="scope">
|
|
|
|
+ <m-button size="small" text type="danger" @click="onDelete(scope)">移除</m-button>
|
|
|
|
+ </template>
|
|
|
|
+ </m-table>
|
|
</div>
|
|
</div>
|
|
- <div class="d-flex">
|
|
|
|
- <div class="boxLabel">计算公式</div>
|
|
|
|
- <div class="boxContent">
|
|
|
|
- <m-card shadow="never">
|
|
|
|
- <Toolbar
|
|
|
|
- style="border-bottom: 1px solid #eee"
|
|
|
|
- :editor="editor"
|
|
|
|
- :defaultConfig="toolbarConfig"
|
|
|
|
|
|
+ </div>
|
|
|
|
+ <div class="d-flex">
|
|
|
|
+ <div class="boxLabel">计算公式</div>
|
|
|
|
+ <div class="boxContent">
|
|
|
|
+ <m-card shadow="never">
|
|
|
|
+ <Toolbar
|
|
|
|
+ style="border-bottom: 1px solid #eee"
|
|
|
|
+ :editor="editor"
|
|
|
|
+ :defaultConfig="toolbarConfig"
|
|
|
|
+ :mode="mode"
|
|
|
|
+ />
|
|
|
|
+ <Editor
|
|
|
|
+ style="height: 250px; overflow-y: hidden;"
|
|
|
|
+ v-model="formulaData"
|
|
|
|
+ :defaultConfig="editorConfig"
|
|
:mode="mode"
|
|
:mode="mode"
|
|
- />
|
|
|
|
- <Editor
|
|
|
|
- style="height: 250px; overflow-y: hidden;"
|
|
|
|
- v-model="formulaData"
|
|
|
|
- :defaultConfig="editorConfig"
|
|
|
|
- :mode="mode"
|
|
|
|
- @onCreated="onCreated"
|
|
|
|
- />
|
|
|
|
- </m-card>
|
|
|
|
- </div>
|
|
|
|
|
|
+ @onCreated="onCreated"
|
|
|
|
+ />
|
|
|
|
+ </m-card>
|
|
</div>
|
|
</div>
|
|
- </div>
|
|
|
|
- </m-card>
|
|
|
|
|
|
+ </div> -->
|
|
|
|
+
|
|
|
|
+ <el-form-item label="计算公式">
|
|
|
|
+ <m-card shadow="never">
|
|
|
|
+ <Toolbar
|
|
|
|
+ style="border-bottom: 1px solid #eee"
|
|
|
|
+ :editor="editor"
|
|
|
|
+ :defaultConfig="toolbarConfig"
|
|
|
|
+ :mode="mode"
|
|
|
|
+ />
|
|
|
|
+ <Editor
|
|
|
|
+ style="height: 250px; overflow-y: hidden;"
|
|
|
|
+ v-model="formulaData"
|
|
|
|
+ :defaultConfig="editorConfig"
|
|
|
|
+ :mode="mode"
|
|
|
|
+ @onCreated="onCreated"
|
|
|
|
+ />
|
|
|
|
+ </m-card>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ </div>
|
|
|
|
+ <!-- </m-card> -->
|
|
</template>
|
|
</template>
|
|
|
|
|
|
<script>
|
|
<script>
|
|
import { Editor, Toolbar } from '@wangeditor/editor-for-vue'
|
|
import { Editor, Toolbar } from '@wangeditor/editor-for-vue'
|
|
import '@wangeditor/editor/dist/css/style.css'
|
|
import '@wangeditor/editor/dist/css/style.css'
|
|
-import SalarySolutionRulesEditParam from './salarySolutionRulesEditParam.vue'
|
|
|
|
-import {
|
|
|
|
- DICT_CATEGORY
|
|
|
|
-} from '../utils/Dict'
|
|
|
|
|
|
+// import {
|
|
|
|
+// DICT_CATEGORY
|
|
|
|
+// } from '../utils/Dict'
|
|
export default {
|
|
export default {
|
|
name: 'salarySolutionRulesRulesEdit',
|
|
name: 'salarySolutionRulesRulesEdit',
|
|
- components: { Editor, Toolbar, SalarySolutionRulesEditParam },
|
|
|
|
- props: {
|
|
|
|
- item: {
|
|
|
|
- type: Object,
|
|
|
|
- default: () => ({})
|
|
|
|
- }
|
|
|
|
- },
|
|
|
|
|
|
+ components: { Editor, Toolbar },
|
|
|
|
+ // props: {
|
|
|
|
+ // item: {
|
|
|
|
+ // type: Object,
|
|
|
|
+ // default: () => ({})
|
|
|
|
+ // }
|
|
|
|
+ // },
|
|
data () {
|
|
data () {
|
|
return {
|
|
return {
|
|
- DICT_CATEGORY,
|
|
|
|
|
|
+ // DICT_CATEGORY,
|
|
editor: null,
|
|
editor: null,
|
|
formulaData: '',
|
|
formulaData: '',
|
|
toolbarConfig: {
|
|
toolbarConfig: {
|
|
@@ -88,7 +141,19 @@ export default {
|
|
},
|
|
},
|
|
editorConfig: { placeholder: '请输入内容...' },
|
|
editorConfig: { placeholder: '请输入内容...' },
|
|
mode: 'default', // or 'simple'
|
|
mode: 'default', // or 'simple'
|
|
- items: []
|
|
|
|
|
|
+ id: 0,
|
|
|
|
+ items: [
|
|
|
|
+ {
|
|
|
|
+ key: 0,
|
|
|
|
+ miniValue: 0,
|
|
|
|
+ miniValueActive: true,
|
|
|
|
+ maxValue: 1,
|
|
|
|
+ maxValueActive: true,
|
|
|
|
+ name: null,
|
|
|
|
+ value: 0,
|
|
|
|
+ valueCategory: 0
|
|
|
|
+ }
|
|
|
|
+ ]
|
|
}
|
|
}
|
|
},
|
|
},
|
|
beforeDestroy () {
|
|
beforeDestroy () {
|
|
@@ -101,59 +166,68 @@ export default {
|
|
this.editor = Object.seal(editor) // 一定要用 Object.seal() ,否则会报错
|
|
this.editor = Object.seal(editor) // 一定要用 Object.seal() ,否则会报错
|
|
},
|
|
},
|
|
onAdd () {
|
|
onAdd () {
|
|
- const item = {
|
|
|
|
- index: this.items.length,
|
|
|
|
|
|
+ // const item = {
|
|
|
|
+ // index: this.items.length,
|
|
|
|
+ // name: null,
|
|
|
|
+ // valueCategory: 0
|
|
|
|
+ // }
|
|
|
|
+ this.items.push({
|
|
|
|
+ key: this.id++,
|
|
|
|
+ miniValue: 0,
|
|
|
|
+ miniValueActive: true,
|
|
|
|
+ maxValue: 1,
|
|
|
|
+ maxValueActive: true,
|
|
name: null,
|
|
name: null,
|
|
|
|
+ value: 0,
|
|
valueCategory: 0
|
|
valueCategory: 0
|
|
- }
|
|
|
|
- this.items.push(item)
|
|
|
|
- const ref = this.$refs.tableRefs.getRefs()
|
|
|
|
- ref.toggleRowExpansion(item)
|
|
|
|
|
|
+ })
|
|
|
|
+ // const ref = this.$refs.tableRefs.getRefs()
|
|
|
|
+ // ref.toggleRowExpansion(item)
|
|
},
|
|
},
|
|
- onDelete (scope) {
|
|
|
|
- this.$confirm('确定要移除改组参数吗?', '提示').then(e => {
|
|
|
|
- this.items.splice(scope.$index, 1)
|
|
|
|
- }).catch(_ => {})
|
|
|
|
|
|
+ onDelete (index) {
|
|
|
|
+ this.items.splice(index, 1)
|
|
|
|
+ // this.$confirm('确定要移除改组参数吗?', '提示').then(e => {
|
|
|
|
+ // this.items.splice(scope.$index, 1)
|
|
|
|
+ // }).catch(_ => {})
|
|
},
|
|
},
|
|
valid () {
|
|
valid () {
|
|
return new Promise((resolve, reject) => {
|
|
return new Promise((resolve, reject) => {
|
|
const check = this.items.every(e => {
|
|
const check = this.items.every(e => {
|
|
- 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 true
|
|
|
|
|
|
+ return e.name && e.value !== null && (!e.miniValueActive || e.miniValue !== null) && (!e.maxValueActive || e.maxValue !== null)
|
|
})
|
|
})
|
|
if (!check) {
|
|
if (!check) {
|
|
- reject(this.item)
|
|
|
|
|
|
+ reject(check)
|
|
} else {
|
|
} else {
|
|
resolve(this.getValue())
|
|
resolve(this.getValue())
|
|
}
|
|
}
|
|
})
|
|
})
|
|
},
|
|
},
|
|
setValue (data) {
|
|
setValue (data) {
|
|
- this.items = data.calculateConfigurations.map((e, index) => {
|
|
|
|
- if (e.valueCategory !== 0) {
|
|
|
|
- const { value, ...obj } = e
|
|
|
|
- return {
|
|
|
|
- index,
|
|
|
|
- value: JSON.parse(value),
|
|
|
|
- ...obj
|
|
|
|
|
|
+ this.id = 0
|
|
|
|
+ this.formulaData = data.calculateFormulas.length ? data.calculateFormulas[0].content : ''
|
|
|
|
+ if (!data.calculateConfigurations.length) {
|
|
|
|
+ this.items = [
|
|
|
|
+ {
|
|
|
|
+ key: 0,
|
|
|
|
+ miniValue: 0,
|
|
|
|
+ miniValueActive: true,
|
|
|
|
+ maxValue: 1,
|
|
|
|
+ maxValueActive: true,
|
|
|
|
+ name: null,
|
|
|
|
+ value: 0,
|
|
|
|
+ valueCategory: 0
|
|
}
|
|
}
|
|
- }
|
|
|
|
|
|
+ ]
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ this.items = data.calculateConfigurations.map(e => {
|
|
return {
|
|
return {
|
|
- index,
|
|
|
|
|
|
+ key: this.id++,
|
|
|
|
+ maxValueActive: e.maxValue !== null,
|
|
|
|
+ miniValueActive: e.miniValue !== null,
|
|
...e
|
|
...e
|
|
}
|
|
}
|
|
})
|
|
})
|
|
- this.formulaData = data.calculateFormulas.length ? data.calculateFormulas[0].content : ''
|
|
|
|
- // this.$nextTick(() => {
|
|
|
|
- // this.formulaData = data.calculateFormulas.length ? data.calculateFormulas[0].content : ''
|
|
|
|
- // })
|
|
|
|
},
|
|
},
|
|
getValue () {
|
|
getValue () {
|
|
const calculateConfigurations = this.items.map(e => {
|
|
const calculateConfigurations = this.items.map(e => {
|
|
@@ -161,45 +235,47 @@ export default {
|
|
name,
|
|
name,
|
|
valueCategory,
|
|
valueCategory,
|
|
miniValue,
|
|
miniValue,
|
|
|
|
+ miniValueActive,
|
|
maxValue,
|
|
maxValue,
|
|
|
|
+ maxValueActive,
|
|
value
|
|
value
|
|
} = e
|
|
} = 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
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ // if (valueCategory === 0) {
|
|
return {
|
|
return {
|
|
name,
|
|
name,
|
|
valueCategory,
|
|
valueCategory,
|
|
- miniValue: miniValue ?? null,
|
|
|
|
- maxValue: maxValue ?? null,
|
|
|
|
- value: _value
|
|
|
|
|
|
+ miniValue: miniValueActive ? miniValue : null,
|
|
|
|
+ maxValue: maxValueActive ? maxValue : null,
|
|
|
|
+ value: value.toString()
|
|
}
|
|
}
|
|
|
|
+ // }
|
|
|
|
+ // 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 {
|
|
return {
|
|
- category: this.item.title,
|
|
|
|
|
|
+ category: '类型',
|
|
calculateConfigurations,
|
|
calculateConfigurations,
|
|
calculateFormulas: [
|
|
calculateFormulas: [
|
|
{
|
|
{
|
|
- category: this.item.title,
|
|
|
|
|
|
+ category: '类型',
|
|
content: this.formulaData
|
|
content: this.formulaData
|
|
}
|
|
}
|
|
]
|
|
]
|