diff --git a/src/views/goods/filter/Index.vue b/src/views/goods/filter/Index.vue index f7d138d..569ef0e 100644 --- a/src/views/goods/filter/Index.vue +++ b/src/views/goods/filter/Index.vue @@ -130,7 +130,8 @@ export default { }, handleAddCondition() { const { form } = this - const keys = form.getFieldValue('fliter_condition') + const key = form.getFieldValue('fliter_condition') + const keys = key ? key : [] const nextKeys = keys.concat([{ category: '', profit: '', profit_rate: '', id: this.generateRandomString(8) }]) form.setFieldsValue({ fliter_condition: nextKeys, @@ -166,7 +167,6 @@ export default { x.id = this.generateRandomString(8) return x }) - record.fliter_condition.forEach((x, i) => { record[`profit${i}`] = x.profit record[`profit_rate${i}`] = x.profit_rate @@ -181,7 +181,7 @@ export default { } if (record.open_channel) { const list = record.open_channel - const channelAry = [] + const channelAry=[] this.checkList.map((item) => { if (list.indexOf(item.id) != -1) { channelAry.push(item.name) @@ -193,7 +193,7 @@ export default { !isEmpty(form.getFieldsValue()) && $nextTick(() => { form.setFieldsValue( - pick(record, ['open_channel', 'fliter_condition', ...profitAry, ...profitRateAry, ...categoryAry]) + pick(record, ['open_channel', 'fliter_condition',...profitAry, ...profitRateAry, ...categoryAry]) ) this.$forceUpdate() }) @@ -209,7 +209,9 @@ export default { Api.info() .then((result) => { // 当前记录 - result.data.storeInfo.open_channel = result.data.storeInfo.open_channel.split(',') + result.data.storeInfo.open_channel = result.data.storeInfo.open_channel + ? result.data.storeInfo.open_channel.split(',') + : undefined this.record = result.data.storeInfo // 设置默认值 this.setFieldsValue() @@ -243,6 +245,7 @@ export default { } }) params.open_channel = values.open_channel ? values.open_channel.join(',') : '' + params.fliter_condition = params.fliter_condition.length > 0 ? params.fliter_condition : [] this.isLoading = true Api.update({ form: params }) .then((result) => {