12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- import { settleStyleQueryAll } from '@/api/settleStyle'
- const SettleStyle = {
- template: `
- <a-select
- :id="id"
- placeholder="请选择收款方式"
- allowClear
- :value="defaultVal"
- :showSearch="true"
- @change="handleChange"
- :filter-option="filterOption">
- <a-select-option v-for="item in list" :key="item[defValKey]" :value="item[defValKey]">{{ item.name }}</a-select-option>
- </a-select>
- `,
- props: {
- value: {
- type: String,
- defatut: ''
- },
- id: {
- type: String,
- default: ''
- },
- defValKey: {
- type: String,
- default: 'settleStyleSn'
- }
- },
- data() {
- return {
- defaultVal: this.value,
- list: []
- };
- },
- watch: {
- value(newValue, oldValue) {
- console.log(newValue)
- this.defaultVal = newValue
- }
- },
- mounted() {
- this.getList()
- },
- methods: {
- filterOption (input, option) {
- return (
- option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
- )
- },
- handleChange(value) {
- console.log(value)
- this.defaultVal = value;
- this.$emit('change', this.value);
- this.$emit('input', value);
- },
- // 列表数据
- getList () {
- const _this = this
- settleStyleQueryAll().then(res => {
- if (res.status == 200) {
- _this.list = res.data || []
- } else {
- _this.list = []
- }
- })
- },
- },
- };
- export default SettleStyle
|