import { settleStyleQueryAll } from '@/api/settleStyle' const CustList = { template: ` {{ item.name }} `, props: { value: { type: String, defatut: '' }, id: { type: String, default: '' }, defValKey: { type: String, default: 'settleStyleSn' }, placeholder: { type: String, default: '请选择结算方式' } }, data() { return { defaultVal: this.value||undefined, list: [] }; }, watch: { value(newValue, oldValue) { console.log(newValue) this.defaultVal = newValue||undefined } }, mounted() { this.getList() }, methods: { filterOption (input, option) { return ( option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0 ) }, handleChange(value) { this.defaultVal = value; const settleStyleName = this.list.find(item => item[this.defValKey] == value).name this.$emit('input', value); this.$emit('change', this.value, settleStyleName); }, // 列表数据 getList () { const _this = this settleStyleQueryAll().then(res => { if (res.status == 200) { _this.list = res.data || [] } else { _this.list = [] } }) }, }, }; export default CustList