Commit 56b0a7fb by liimin

完善子组件逻辑

1 parent c61c62c1
...@@ -175,7 +175,7 @@ export default { ...@@ -175,7 +175,7 @@ export default {
this.$validator.errors.clear() this.$validator.errors.clear()
}) })
__eventBus.$on('reset', () => { __eventBus.$on('reset', () => {
this.reset() this.__reset()
}) })
} }
}, },
...@@ -187,6 +187,17 @@ export default { ...@@ -187,6 +187,17 @@ export default {
__sAction && (this.action = __sAction) __sAction && (this.action = __sAction)
}, },
immediate: true immediate: true
},
default_value: {
handler(__value) {
if (__value) {
this.__setDefault(__value)
// this.model.merchantId = __value.merchantId
// this.model.manufacturerId = __value.manufacturerId
}
},
immediate: true,
deep: true
} }
}, },
data() { data() {
...@@ -260,7 +271,7 @@ export default { ...@@ -260,7 +271,7 @@ export default {
onRemove_grayscaleuser() { onRemove_grayscaleuser() {
this.model.grayscaleUserList = '' this.model.grayscaleUserList = ''
}, },
reset() { __reset() {
//初始化 //初始化
this.model.manufacturerId = null this.model.manufacturerId = null
this.model.merchantId = null this.model.merchantId = null
...@@ -271,20 +282,28 @@ export default { ...@@ -271,20 +282,28 @@ export default {
influenceScope: '' //用户类型 influenceScope: '' //用户类型
} }
this.$emit('update:value', this.result) this.$emit('update:value', this.result)
},
__setDefault(__default) {
this.model.merchantId = __default.merchantId
this.model.manufacturerId = __default.manufacturerId
this.result.influenceScope = __default.influenceScope
this.model.file_list = __default.file_list
this.result.grayscaleUserList = __default.grayscaleuser
this.default_value = __default
} }
}, },
created() { created() {
if (this.default_value) { // if (this.default_value) {
this.model.merchantId = this.default_value.merchantId // this.model.merchantId = this.default_value.merchantId
this.model.manufacturerId = this.default_value.manufacturerId // this.model.manufacturerId = this.default_value.manufacturerId
this.result.influenceScope = this.default_value.influenceScope // this.result.influenceScope = this.default_value.influenceScope
this.model.file_list = this.default_value.file_list // this.model.file_list = this.default_value.file_list
this.result.grayscaleUserList = this.default_value.grayscaleuser // this.result.grayscaleUserList = this.default_value.grayscaleuser
/** // /**
* file_list // * file_list
* [{name: 'food.jpg', url: 'https://xxx.cdn.com/xxx.jpg'}] // * [{name: 'food.jpg', url: 'https://xxx.cdn.com/xxx.jpg'}]
*/ // */
} // }
Promise.all([this.get_manufacturer_list(), this.get_merchant_list()]) Promise.all([this.get_manufacturer_list(), this.get_merchant_list()])
.then(result => { .then(result => {
this.manufacturer_list = manufacturer_list_back_up.concat(result[0]) this.manufacturer_list = manufacturer_list_back_up.concat(result[0])
......
...@@ -29,7 +29,10 @@ ...@@ -29,7 +29,10 @@
</span> </span>
</gl-form-item> </gl-form-item>
<gl-row> <gl-row>
<gl-col :span="24"> <gl-col
:span="24"
v-if="showManufacturers"
>
<Manufacturers <Manufacturers
width="100%" width="100%"
:eventBus="eventBus" :eventBus="eventBus"
...@@ -306,13 +309,17 @@ export default { ...@@ -306,13 +309,17 @@ export default {
} }
this.editForm.time = [beginTime, endTime] //设置时间 this.editForm.time = [beginTime, endTime] //设置时间
this.editForm.count = this.editForm.count || 1 //触发次数暂时没有 默认 1 触发次数暂时不能选择 this.editForm.count = this.editForm.count || 1 //触发次数暂时没有 默认 1 触发次数暂时不能选择
this.setCouponsData(this.$deep_clone(JSON.parse(activityConfig))) this.setCouponsData(JSON.parse(activityConfig))
} }
setTimeout(() => { setTimeout(() => {
this.eventBus.$emit('clear_error') // this.eventBus.$emit('clear_error') //
}, 100) }, 100)
}) })
this.eventBus.$on('clear_error', () => this.$validator.errors.clear()) //箭头事件 清除页面错误信息 this.eventBus.$on('clear_error', () => this.$validator.errors.clear()) //监听事件 清除页面错误信息
this.eventBus.$on('reset', () => {
this.coupons.data = []
this.default_value = {}
}) //监听事件 清除页面数据
} }
} }
// 'editForm.activityConfig.giftId': { // 'editForm.activityConfig.giftId': {
...@@ -327,6 +334,7 @@ export default { ...@@ -327,6 +334,7 @@ export default {
return { return {
//弹出框标题 //弹出框标题
title: '', title: '',
showManufacturers: true,
//子组件默认值 //子组件默认值
default_value: { default_value: {
// // merchantId: 19180001, // // merchantId: 19180001,
...@@ -394,12 +402,15 @@ export default { ...@@ -394,12 +402,15 @@ export default {
this.giftVisible = true this.giftVisible = true
}, },
setCouponsData(data) { setCouponsData(data) {
console.log(data)
const { giftName, giftId, giftType } = data const { giftName, giftId, giftType } = data
this.editForm.activityConfig = JSON.parse(this.editForm.activityConfig)
this.editForm.activityConfig.giftName = giftName this.editForm.activityConfig.giftName = giftName
this.editForm.activityConfig.giftId = giftId this.editForm.activityConfig.giftId = giftId
this.editForm.activityConfig.giftType = giftType this.editForm.activityConfig.giftType = giftType
this.coupons.data = [this.editForm.activityConfig] this.coupons.data = [this.editForm.activityConfig]
this.editForm.activityConfig = JSON.stringify(
this.editForm.activityConfig
)
} }
} }
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!