|
@@ -0,0 +1,133 @@
|
|
|
+<template>
|
|
|
+ <m-dialog ref="dialog" title="规则配置" @sure="onSure">
|
|
|
+ <m-form ref="form" :items="formItems" v-loading="loading">
|
|
|
+ <template #ruleCategory>
|
|
|
+ <el-tag>{{ itemData.ruleCategory }}</el-tag>
|
|
|
+ </template>
|
|
|
+ <template #config>
|
|
|
+ <m-card
|
|
|
+ v-for="(item) in items"
|
|
|
+ :key="item.key"
|
|
|
+ shadow="never"
|
|
|
+ class="mb-3"
|
|
|
+ >
|
|
|
+ <AccumulatePointsRulesConfigItem
|
|
|
+ ref="accumulatePointsRulesConfigItemRefs"
|
|
|
+ :value="item"
|
|
|
+ ></AccumulatePointsRulesConfigItem>
|
|
|
+ </m-card>
|
|
|
+ <div class="text-center">
|
|
|
+ <m-button icon="el-icon-plus" size="small" type="orange" @click="onAddItem">新增一条规则项</m-button>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ </m-form>
|
|
|
+ </m-dialog>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+import {
|
|
|
+ getAccumulatePointRulesDetails,
|
|
|
+ saveAccumulatePointRulesDetails
|
|
|
+} from '@/api/accumulatePoint'
|
|
|
+import AccumulatePointsRulesConfigItem from './accumulatePointsRulesConfigItem.vue'
|
|
|
+export default {
|
|
|
+ name: 'accumulatePointsRulesConfig',
|
|
|
+ components: {
|
|
|
+ AccumulatePointsRulesConfigItem
|
|
|
+ },
|
|
|
+ data () {
|
|
|
+ return {
|
|
|
+ loading: false,
|
|
|
+ itemData: {},
|
|
|
+ formItems: [
|
|
|
+ {
|
|
|
+ label: '模块名称',
|
|
|
+ prop: 'ruleCategory'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: '规则项',
|
|
|
+ prop: 'config'
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ key: 0,
|
|
|
+ items: []
|
|
|
+ }
|
|
|
+ },
|
|
|
+ computed: {
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ async open (item) {
|
|
|
+ this.$refs.dialog.open()
|
|
|
+ this.loading = true
|
|
|
+ this.key = 0
|
|
|
+ try {
|
|
|
+ const { data } = await getAccumulatePointRulesDetails({
|
|
|
+ employeeScoreRuleId: item.employeeScoreRuleId
|
|
|
+ })
|
|
|
+ this.itemData = {
|
|
|
+ ...data.entity,
|
|
|
+ items: data.items
|
|
|
+ }
|
|
|
+ this.items = data.items.map(item => {
|
|
|
+ return {
|
|
|
+ key: this.key++,
|
|
|
+ title: item.title,
|
|
|
+ calculationMethod: item.calculationMethod, // 0.添加 1.减少
|
|
|
+ inputType: item.inputType, // 输入类型0.多次 2.手工 3.单选
|
|
|
+ groupItem: item.groupItem, // { employeeScoreRuleItemId, title, score }
|
|
|
+ score: item.score, // 基础积分
|
|
|
+ maxScore: item.maxScore
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } catch (error) {
|
|
|
+ this.$message.error(error)
|
|
|
+ } finally {
|
|
|
+ this.loading = false
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // onAssign (val, obj) {
|
|
|
+ // Object.assign(obj, val)
|
|
|
+ // },
|
|
|
+ onAddItem () {
|
|
|
+ this.items.push({
|
|
|
+ key: this.key++,
|
|
|
+ title: null,
|
|
|
+ calculationMethod: 0, // 0.添加 1.减少
|
|
|
+ inputType: 0, // 输入类型0.多次 2.手工 3.单选
|
|
|
+ groupItem: [], // { employeeScoreRuleItemId, title, score }
|
|
|
+ score: 0, // 基础积分
|
|
|
+ maxScore: 999
|
|
|
+ })
|
|
|
+ },
|
|
|
+ async onSure () {
|
|
|
+ if (!this.$refs.accumulatePointsRulesConfigItemRefs) {
|
|
|
+ this.$message.error('请先配置规则项')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ const data = await Promise.all(this.$refs.accumulatePointsRulesConfigItemRefs.map(item => item.valid()))
|
|
|
+ this.onSubmit(data)
|
|
|
+ } catch (error) {}
|
|
|
+ },
|
|
|
+ async onSubmit (param) {
|
|
|
+ this.loading = true
|
|
|
+ try {
|
|
|
+ await saveAccumulatePointRulesDetails({
|
|
|
+ employeeScoreRuleId: this.itemData.employeeScoreRuleId,
|
|
|
+ items: param
|
|
|
+ })
|
|
|
+ this.$message.success('保存成功')
|
|
|
+ this.$refs.dialog.close()
|
|
|
+ } catch (error) {
|
|
|
+ this.$message.error(error)
|
|
|
+ } finally {
|
|
|
+ this.loading = false
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="scss" scoped>
|
|
|
+
|
|
|
+</style>
|