| | |
| | | v-model="val" |
| | | v-if="item.type === 'cascader'" |
| | | :options="item.options" |
| | | :props="item.optionsConfig.props||{ checkStrictly: true,value: 'id' }" |
| | | :clearable="true" |
| | | :props="item.optionsConfig.props||{ checkStrictly: true,emitPath: false,value: 'id' }" |
| | | :show-all-levels="false" |
| | | filterable |
| | | style="width: 150px" |
| | | @change="(v) => this.$emit('change', v)" |
| | | > |
| | |
| | | v-if="item.type === 'select'" |
| | | :placeholder="item.placeholder || ''" |
| | | v-model="val" |
| | | show-search |
| | | filterable |
| | | :multiple="item.multiple || false" |
| | | :collapse-tags="item.collapseTags || false" |
| | | :clearable="true" |
| | |
| | | item: Object, |
| | | }, |
| | | created() { |
| | | if (this.item.type === 'select' && this.item.optionsConfig) { |
| | | if (this.$axios === undefined) { |
| | | console.error('请先配置this.$axios'); |
| | | return; |
| | | } |
| | | request({ |
| | | url: this.item.optionsConfig.url, |
| | | method: 'get', |
| | | }).then((res) => { |
| | | const data = res || []; |
| | | this.item.options = []; |
| | | data.forEach((v) => { |
| | | this.item.options.push({ |
| | | label: v[this.item.optionsConfig.label || 'label'], |
| | | value: v[this.item.optionsConfig.value || 'value'], |
| | | }); |
| | | }); |
| | | }); |
| | | } |
| | | if (this.item.type === 'cascader' && this.item.optionsConfig) { |
| | | if (this.$axios === undefined) { |
| | | console.error('请先配置this.$axios'); |
| | | return; |
| | | } |
| | | request({ |
| | | url: this.item.optionsConfig.url, |
| | | method: 'get', |
| | | }).then((res) => { |
| | | const data = res || []; |
| | | this.item.options = []; |
| | | this.item.options = data; |
| | | }); |
| | | } |
| | | if (this.item.type === 'tree-select' && this.item.optionsConfig) { |
| | | if (this.$axios === undefined) { |
| | | console.error('请先配置this.$axios'); |
| | | return; |
| | | } |
| | | if (this.item.asyncLoad) { |
| | | this.asyncLoad({value: 0}).then((res) => { |
| | | this.treeData = res; |
| | | }); |
| | | } else { |
| | | this.asyncLoad({}).then((res) => { |
| | | this.treeData = res; |
| | | }); |
| | | } |
| | | } |
| | | this.initData({}) |
| | | }, |
| | | watch: { |
| | | value(v) { |
| | |
| | | }; |
| | | }, |
| | | methods: { |
| | | clearData() { |
| | | this.item.options = [] |
| | | this.treeData = [] |
| | | }, |
| | | initData(params) { |
| | | this.val = this.item.defaultValue |
| | | if (this.item.type === 'select' && this.item.optionsConfig) { |
| | | if (this.$axios === undefined) { |
| | | console.error('请先配置this.$axios'); |
| | | return; |
| | | } |
| | | request({ |
| | | url: this.item.optionsConfig.url, |
| | | method: 'get', |
| | | params |
| | | }).then((res) => { |
| | | const data = res || []; |
| | | this.item.options = []; |
| | | data.forEach((v) => { |
| | | this.item.options.push({ |
| | | label: v[this.item.optionsConfig.label || 'label'], |
| | | value: v[this.item.optionsConfig.value || 'value'], |
| | | }); |
| | | }); |
| | | }); |
| | | } |
| | | if (this.item.type === 'cascader' && this.item.optionsConfig) { |
| | | if (this.$axios === undefined) { |
| | | console.error('请先配置this.$axios'); |
| | | return; |
| | | } |
| | | request({ |
| | | url: this.item.optionsConfig.url, |
| | | method: 'get', |
| | | params |
| | | }).then((res) => { |
| | | const data = res || []; |
| | | this.item.options = []; |
| | | this.item.options = data; |
| | | }); |
| | | } |
| | | if (this.item.type === 'tree-select' && this.item.optionsConfig) { |
| | | if (this.$axios === undefined) { |
| | | console.error('请先配置this.$axios'); |
| | | return; |
| | | } |
| | | if (this.item.asyncLoad) { |
| | | params.value = 0 |
| | | this.asyncLoad(params).then((res) => { |
| | | this.treeData = res; |
| | | }); |
| | | } else { |
| | | this.asyncLoad(params).then((res) => { |
| | | this.treeData = res; |
| | | }); |
| | | } |
| | | } |
| | | }, |
| | | panelChange(v, type) { |
| | | var info = null |
| | | if (v && this.item.type !== 'date-time-picker') { |