From 0056dec32f8abde1987d8db32d4920eabdcc4012 Mon Sep 17 00:00:00 2001 From: haoyahui <2032914783@qq.com> Date: 星期一, 27 十一月 2023 10:00:30 +0800 Subject: [PATCH] 列表样式 --- admin-web/src/components/mySearch/SearchItem.vue | 114 +++++++++++++++++++++++++++++++------------------------- 1 files changed, 63 insertions(+), 51 deletions(-) diff --git a/admin-web/src/components/mySearch/SearchItem.vue b/admin-web/src/components/mySearch/SearchItem.vue index 4da675b..7e2bdf4 100644 --- a/admin-web/src/components/mySearch/SearchItem.vue +++ b/admin-web/src/components/mySearch/SearchItem.vue @@ -16,8 +16,9 @@ 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)" > @@ -27,7 +28,7 @@ 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" @@ -132,54 +133,7 @@ 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) { @@ -230,6 +184,64 @@ }; }, 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') { -- Gitblit v1.9.1