|
@@ -1,81 +1,71 @@
|
|
|
<template>
|
|
<template>
|
|
|
<m-card shadow="never">
|
|
<m-card shadow="never">
|
|
|
- <el-form ref="form">
|
|
|
|
|
- <el-form-item label="参数配置" class="mb-3">
|
|
|
|
|
- <m-table
|
|
|
|
|
- ref="tableRefs"
|
|
|
|
|
- shadow="naver"
|
|
|
|
|
- clearHeader
|
|
|
|
|
- :items="items"
|
|
|
|
|
- row-key="index"
|
|
|
|
|
- :headers="[
|
|
|
|
|
- { type: 'expand', prop: 'expandProp' },
|
|
|
|
|
- { label: '参数', prop: 'label' },
|
|
|
|
|
- { label: '参数类型', prop: 'valueCategory' },
|
|
|
|
|
- { label: '操作', prop: 'actions' }
|
|
|
|
|
- ]"
|
|
|
|
|
- >
|
|
|
|
|
- <template #expandProp="{ row }">
|
|
|
|
|
- <el-form label-width="100px">
|
|
|
|
|
- <el-form-item label="参数">
|
|
|
|
|
- <el-input v-model="row.label" size="small"></el-input>
|
|
|
|
|
- </el-form-item>
|
|
|
|
|
- <el-form-item label="参数类型">
|
|
|
|
|
- <el-select v-model="row.valueCategory" size="small">
|
|
|
|
|
- <el-option
|
|
|
|
|
- v-for="item in DICT_CATEGORY"
|
|
|
|
|
- :key="item.value"
|
|
|
|
|
- :label="item.label"
|
|
|
|
|
- :value="item.value"
|
|
|
|
|
- >
|
|
|
|
|
- </el-option>
|
|
|
|
|
- </el-select>
|
|
|
|
|
- </el-form-item>
|
|
|
|
|
- </el-form>
|
|
|
|
|
- </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>
|
|
|
|
|
- </el-form-item>
|
|
|
|
|
- <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>
|
|
|
|
|
- </el-form>
|
|
|
|
|
- <!-- <SalarySolutionRulesEditParam ref="salarySolutionRulesEditParamRefs" @submit="onAddSubmit"></SalarySolutionRulesEditParam> -->
|
|
|
|
|
|
|
+ <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="{ row }">
|
|
|
|
|
+ <SalarySolutionRulesEditParam ref="salarySolutionRulesEditParamRefs" @assign="onAssign(row, $event)"></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"
|
|
|
|
|
+ :mode="mode"
|
|
|
|
|
+ />
|
|
|
|
|
+ <Editor
|
|
|
|
|
+ style="height: 250px; overflow-y: hidden;"
|
|
|
|
|
+ v-model="formulaData"
|
|
|
|
|
+ :defaultConfig="editorConfig"
|
|
|
|
|
+ :mode="mode"
|
|
|
|
|
+ @onCreated="onCreated"
|
|
|
|
|
+ />
|
|
|
|
|
+ </m-card>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </div>
|
|
|
</m-card>
|
|
</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 SalarySolutionRulesEditParam from './salarySolutionRulesEditParam.vue'
|
|
|
import {
|
|
import {
|
|
|
DICT_CATEGORY
|
|
DICT_CATEGORY
|
|
|
} from '../utils/Dict'
|
|
} from '../utils/Dict'
|
|
|
export default {
|
|
export default {
|
|
|
name: 'salarySolutionRulesEdit',
|
|
name: 'salarySolutionRulesEdit',
|
|
|
- components: { Editor, Toolbar },
|
|
|
|
|
|
|
+ components: { Editor, Toolbar, SalarySolutionRulesEditParam },
|
|
|
props: {
|
|
props: {
|
|
|
item: {
|
|
item: {
|
|
|
type: Object,
|
|
type: Object,
|
|
@@ -107,13 +97,16 @@ export default {
|
|
|
editor.destroy() // 组件销毁时,及时销毁编辑器
|
|
editor.destroy() // 组件销毁时,及时销毁编辑器
|
|
|
},
|
|
},
|
|
|
methods: {
|
|
methods: {
|
|
|
|
|
+ onAssign (row, obj) {
|
|
|
|
|
+ Object.assign(row, obj)
|
|
|
|
|
+ },
|
|
|
onCreated (editor) {
|
|
onCreated (editor) {
|
|
|
this.editor = Object.seal(editor) // 一定要用 Object.seal() ,否则会报错
|
|
this.editor = Object.seal(editor) // 一定要用 Object.seal() ,否则会报错
|
|
|
},
|
|
},
|
|
|
onAdd () {
|
|
onAdd () {
|
|
|
const item = {
|
|
const item = {
|
|
|
index: this.items.length,
|
|
index: this.items.length,
|
|
|
- label: '未命名',
|
|
|
|
|
|
|
+ name: '未命名',
|
|
|
valueCategory: 0
|
|
valueCategory: 0
|
|
|
}
|
|
}
|
|
|
this.items.push(item)
|
|
this.items.push(item)
|
|
@@ -126,25 +119,22 @@ export default {
|
|
|
}).catch(_ => {})
|
|
}).catch(_ => {})
|
|
|
},
|
|
},
|
|
|
valid () {
|
|
valid () {
|
|
|
|
|
+ console.log('this.$refs.salarySolutionRulesEditParamRefs', this.$refs)
|
|
|
return new Promise((resolve, reject) => {
|
|
return new Promise((resolve, reject) => {
|
|
|
- resolve(this.getValue())
|
|
|
|
|
- // this.$refs.form.validate(valid => {
|
|
|
|
|
- // if (valid) {
|
|
|
|
|
- // resolve(this.getValue())
|
|
|
|
|
- // } else {
|
|
|
|
|
- // const obj = {
|
|
|
|
|
- // data: this.item,
|
|
|
|
|
- // $refs: this.$refs.form
|
|
|
|
|
- // }
|
|
|
|
|
- // reject(obj)
|
|
|
|
|
- // }
|
|
|
|
|
- // })
|
|
|
|
|
|
|
+ const check = this.$refs.salarySolutionRulesEditParamRefs.some(e => {
|
|
|
|
|
+ return !e.valid()
|
|
|
|
|
+ })
|
|
|
|
|
+ if (check) {
|
|
|
|
|
+ reject(this.item)
|
|
|
|
|
+ } else {
|
|
|
|
|
+ resolve(this.getValue())
|
|
|
|
|
+ }
|
|
|
})
|
|
})
|
|
|
},
|
|
},
|
|
|
setValue (data) {
|
|
setValue (data) {
|
|
|
this.items = data.calculateConfigurations.map(e => {
|
|
this.items = data.calculateConfigurations.map(e => {
|
|
|
return {
|
|
return {
|
|
|
- label: e.name,
|
|
|
|
|
|
|
+ name: e.name,
|
|
|
valueCategory: e.valueCategory
|
|
valueCategory: e.valueCategory
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
@@ -155,12 +145,7 @@ export default {
|
|
|
getValue () {
|
|
getValue () {
|
|
|
return {
|
|
return {
|
|
|
category: this.item.title,
|
|
category: this.item.title,
|
|
|
- calculateConfigurations: this.items.map(e => {
|
|
|
|
|
- return {
|
|
|
|
|
- name: e.label,
|
|
|
|
|
- value: e.value
|
|
|
|
|
- }
|
|
|
|
|
- }),
|
|
|
|
|
|
|
+ calculateConfigurations: this.items,
|
|
|
calculateFormulas: [
|
|
calculateFormulas: [
|
|
|
{
|
|
{
|
|
|
category: this.item.title,
|
|
category: this.item.title,
|
|
@@ -177,4 +162,13 @@ export default {
|
|
|
::v-deep .el-tree-node__content {
|
|
::v-deep .el-tree-node__content {
|
|
|
height: 40px;
|
|
height: 40px;
|
|
|
}
|
|
}
|
|
|
|
|
+.boxLabel {
|
|
|
|
|
+ width: 80px;
|
|
|
|
|
+ text-align: right;
|
|
|
|
|
+ padding-right: 20px;
|
|
|
|
|
+ box-sizing: border-box;
|
|
|
|
|
+}
|
|
|
|
|
+.boxContent {
|
|
|
|
|
+ flex: 1;
|
|
|
|
|
+}
|
|
|
</style>
|
|
</style>
|