Commit 10cf77141435edd844b9dfa963c5cb4b232012d9

Authored by 刘汉宸
1 parent 07b39253

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

packages/schema-select/index.vue
... ... @@ -12,7 +12,7 @@
12 12 </style>
13 13  
14 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 16 <template #reference>
17 17 <el-input
18 18 v-model="model"
... ... @@ -93,10 +93,6 @@ export default {
93 93 type: Array,
94 94 default: () => [],
95 95 },
96   - auto: {
97   - type: Boolean,
98   - default: true,
99   - },
100 96 clearable: {
101 97 type: Boolean,
102 98 default: true,
... ... @@ -124,6 +120,8 @@ export default {
124 120 },
125 121 },
126 122 apiSearch: Function,
  123 + lazy: Boolean,
  124 + update: Boolean,
127 125 },
128 126 inject: {
129 127 elForm: {
... ... @@ -141,6 +139,7 @@ export default {
141 139 visible: false,
142 140 inputHovering: false,
143 141 tableData: [],
  142 + loaded: false,
144 143 };
145 144 },
146 145 created() {
... ... @@ -213,6 +212,15 @@ export default {
213 212 }
214 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 225 watch: {
218 226 value(val) {
... ... @@ -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 262 onInputFocus() {
242 263 if (!this.allowCreate) {
243 264 this.model = '';
... ...
packages/select/index.vue
... ... @@ -95,7 +95,7 @@ export default {
95 95 };
96 96 },
97 97 created() {
98   - if (this.remote && !this.lazy) {
  98 + if (this.remote && !(this.lazy || this.update)) {
99 99 this.initing = true;
100 100 this.remoteMethod();
101 101 }
... ... @@ -191,6 +191,8 @@ export default {
191 191 if (this.lazy) {
192 192 if (!this.loaded) {
193 193 this.remoteMethod();
  194 + } else if (this.update) {
  195 + this.remoteMethod();
194 196 }
195 197 } else if (this.update) {
196 198 this.remoteMethod();
... ...