const ReturnReason = { template: ` {{item.dispName}} `, props: { value: { type: String, default: undefined }, id: { type: String, default: '' }, placeholder: { type: String, default: '请选择退货原因' }, size: { type: String, default: 'small' }, goodFlag: { type: String, default: '' } }, data() { return { defaultVal: this.value, list: [] }; }, created() { // 不良品 if(this.goodFlag == 'DEFECTIVE_PRODUCT_RETURN'){ this.list = this.$store.state.app.defectiveReturnReason } // 良品 if(this.goodFlag == 'GOOD_PRODUCT_RETURN'){ this.list = this.$store.state.app.goodReturnReason } // 全部 if(!this.goodFlag){ this.list = [...this.$store.state.app.defectiveReturnReason, ...this.$store.state.app.goodReturnReason] } }, watch: { value(newValue, oldValue) { this.defaultVal = newValue || undefined } }, methods: { filterOption(input, option) { return ( option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0 ); }, handleChange(value) { this.defaultVal = value; const row = this.list.find(item => item.code == value) this.$emit('change', value, row); this.$emit('input', value); } }, }; export default ReturnReason