Commit 8704cbbe by 李伟康

refactor(sales): 优化销售合同组件的指标配置处理

- 将metricConfigs通过props传递给ConditionItem组件
- 修复localStorage数据解析的安全性检查
- 优化indicatorOptions计算逻辑并改为方法调用
- 移除不必要的GET_BASE_SCENE_CODE注入
- 使用$nextTick确保表单验证清理的时机正确
1 parent 9a30bf01
......@@ -54,7 +54,7 @@
<template v-for="(item, index) in guaranteeConfigs">
<conditionItem :key="index" :includesList="includesConditionList" :item="item" :num="index"
@delete="deleteCondition(index)" @changeCondition="changeCondition($event, index)"
:listLength="guaranteeConfigs.length" :ref="`conditionItem${index}`" />
:listLength="guaranteeConfigs.length" :ref="`conditionItem${index}`" :metricConfigs="metricConfigs" />
</template>
</div>
</div>
......@@ -126,7 +126,8 @@ export default {
methods: {
async storeApproveQueryMetricConfigs() {
let baseSceneCode = this.GET_BASE_SCENE_CODE(),
metricConfigs = JSON.parse(localStorage.getItem('metricConfigs')) || {}
storageData = localStorage.getItem('metricConfigs'),
metricConfigs = storageData ? JSON.parse(storageData) : {}
if (!metricConfigs[baseSceneCode]) {
const data = await storeApproveQueryMetricConfigs({
baseSceneCode
......
......@@ -18,7 +18,7 @@
<template v-else-if="i.type == 'select'">
<el-select v-model="componentData[i.key]" class="select" :placeholder="`请选择${i.label}`"
:filterable="i.filterable" @change="selectionChange">
<el-option v-for="item in indicatorOptions" :key="item.metricCode" :label="item.metricName"
<el-option v-for="item in indicatorOptions()" :key="item.metricCode" :label="item.metricName"
:value="item.metricCode" :filterable="i.filterable" :disabled="item.disabled" />
</el-select>
</template>
......@@ -87,7 +87,7 @@ const DDBZ = { label: '兜底标准', key: 'guaranteeStandard', type: 'input' },
],
}
export default {
inject: ['size', 'GET_BASE_SCENE_CODE'],
inject: ['size'],
name: 'ConditionItem',
mixins: [componentsMixin],
props: {
......@@ -107,6 +107,7 @@ export default {
type: Array,
default: () => []
},
metricConfigs: Array
},
data() {
return {
......@@ -146,7 +147,9 @@ export default {
this.selectionChange(val.guaranteeIndex, false)
if (val.ladderConditions) this.ladderConditions = JSON.parse(val.ladderConditions)
}
this.formRef && this.formRef.clearValidate()
this.$nextTick(() => {
this.formRef && this.formRef.clearValidate()
})
},
deep: true,
immediate: true
......@@ -170,12 +173,16 @@ export default {
},
computed: {
options() {
let baseSceneCode = this.GET_BASE_SCENE_CODE(),
metricConfigs = localStorage.getItem('metricConfigs') || {},
options = metricConfigs ? deepClone(JSON.parse(metricConfigs)[baseSceneCode]) : []
return options
let {metricConfigs} = this
return metricConfigs
},
indicatorOptions() {
formRef() {
return this.$refs.formRef
},
},
mounted() { },
methods: {
indicatorOptions() {
let { includesList } = this,
options = deepClone(this.options)
if (includesList.length) {
......@@ -186,12 +193,6 @@ export default {
}
return options
},
formRef() {
return this.$refs.formRef
},
},
mounted() { },
methods: {
radioChange(val) {
if (val == 2) {
this.ladderConditions = [{
......@@ -240,7 +241,7 @@ export default {
this.$forceUpdate()
},
indicatorText(val) {
return this.indicatorOptions.find(item => item.metricCode == val)?.metricName || '选中的指标值'
return this.indicatorOptions().find(item => item.metricCode == val)?.metricName || '选中的指标值'
},
clearValue(index, key, errorText) {
this.$set(this.ladderConditions[index], key, '')
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!