Commit 10cf77141435edd844b9dfa963c5cb4b232012d9

Authored by 刘汉宸
1 parent 07b39253

fix: 修复Select组件的lazy和update判断逻辑

packages/schema-select/index.vue
@@ -12,7 +12,7 @@ @@ -12,7 +12,7 @@
12 </style> 12 </style>
13 13
14 <template> 14 <template>
15 - <el-popover class="z-schema-select" popper-class="z-schema-select__popper" v-model="visible" trigger="click" placement="bottom-start" transition="el-zoom-in-top"> 15 + <el-popover class="z-schema-select" popper-class="z-schema-select__popper" v-model="visible" trigger="click" placement="bottom-start" transition="el-zoom-in-top" @show="onTriggerShow">
16 <template #reference> 16 <template #reference>
17 <el-input 17 <el-input
18 v-model="model" 18 v-model="model"
@@ -93,10 +93,6 @@ export default { @@ -93,10 +93,6 @@ export default {
93 type: Array, 93 type: Array,
94 default: () => [], 94 default: () => [],
95 }, 95 },
96 - auto: {  
97 - type: Boolean,  
98 - default: true,  
99 - },  
100 clearable: { 96 clearable: {
101 type: Boolean, 97 type: Boolean,
102 default: true, 98 default: true,
@@ -124,6 +120,8 @@ export default { @@ -124,6 +120,8 @@ export default {
124 }, 120 },
125 }, 121 },
126 apiSearch: Function, 122 apiSearch: Function,
  123 + lazy: Boolean,
  124 + update: Boolean,
127 }, 125 },
128 inject: { 126 inject: {
129 elForm: { 127 elForm: {
@@ -141,6 +139,7 @@ export default { @@ -141,6 +139,7 @@ export default {
141 visible: false, 139 visible: false,
142 inputHovering: false, 140 inputHovering: false,
143 tableData: [], 141 tableData: [],
  142 + loaded: false,
144 }; 143 };
145 }, 144 },
146 created() { 145 created() {
@@ -213,6 +212,15 @@ export default { @@ -213,6 +212,15 @@ export default {
213 } 212 }
214 return []; 213 return [];
215 }, 214 },
  215 + auto() {
  216 + if (this.lazy) {
  217 + return false;
  218 + }
  219 + if (this.update) {
  220 + return false;
  221 + }
  222 + return true;
  223 + },
216 }, 224 },
217 watch: { 225 watch: {
218 value(val) { 226 value(val) {
@@ -238,6 +246,19 @@ export default { @@ -238,6 +246,19 @@ export default {
238 } 246 }
239 } 247 }
240 }, 248 },
  249 + // 显示弹框
  250 + onTriggerShow() {
  251 + if (this.lazy) {
  252 + if (!this.loaded) {
  253 + this.onInput();
  254 + this.loaded = true;
  255 + } else if (this.update) {
  256 + this.onInput();
  257 + }
  258 + } else if (this.update) {
  259 + this.onInput();
  260 + }
  261 + },
241 onInputFocus() { 262 onInputFocus() {
242 if (!this.allowCreate) { 263 if (!this.allowCreate) {
243 this.model = ''; 264 this.model = '';
packages/select/index.vue
@@ -95,7 +95,7 @@ export default { @@ -95,7 +95,7 @@ export default {
95 }; 95 };
96 }, 96 },
97 created() { 97 created() {
98 - if (this.remote && !this.lazy) { 98 + if (this.remote && !(this.lazy || this.update)) {
99 this.initing = true; 99 this.initing = true;
100 this.remoteMethod(); 100 this.remoteMethod();
101 } 101 }
@@ -191,6 +191,8 @@ export default { @@ -191,6 +191,8 @@ export default {
191 if (this.lazy) { 191 if (this.lazy) {
192 if (!this.loaded) { 192 if (!this.loaded) {
193 this.remoteMethod(); 193 this.remoteMethod();
  194 + } else if (this.update) {
  195 + this.remoteMethod();
194 } 196 }
195 } else if (this.update) { 197 } else if (this.update) {
196 this.remoteMethod(); 198 this.remoteMethod();