Commit 73fdb88c5e5902195c19bec5fb9684ef9fd2f296
1 parent
152f14b3
Exists in
master
and in
2 other branches
fix: 修复SchemaSelect弹出框
Showing
2 changed files
with
31 additions
and
10 deletions
Show diff stats
packages/schema-page/index.vue
| @@ -10,7 +10,7 @@ | @@ -10,7 +10,7 @@ | ||
| 10 | </div> | 10 | </div> |
| 11 | <!-- 筛选组件 --> | 11 | <!-- 筛选组件 --> |
| 12 | <div v-if="schema.filter" class="z-schema-page__filter"> | 12 | <div v-if="schema.filter" class="z-schema-page__filter"> |
| 13 | - <z-schema-filter :size="_size" :schema="schema.filter" :value="valueFilter" @input="e => $emit('update:value-filter', e)" :loading="loading" @search="onSearch"> | 13 | + <z-schema-filter :size="_size" :schema="schema.filter" :value="valueFilter" @input="e => $emit('update:value-filter', e)" :loading="tableLoading" @search="onSearch"> |
| 14 | <template v-for="item in getSlotKeys('filter-')" #[item.name]="slotScope"> | 14 | <template v-for="item in getSlotKeys('filter-')" #[item.name]="slotScope"> |
| 15 | <slot :name="item.slot" v-bind="{ ..._slotScope, ...slotScope }"></slot> | 15 | <slot :name="item.slot" v-bind="{ ..._slotScope, ...slotScope }"></slot> |
| 16 | </template> | 16 | </template> |
| @@ -26,7 +26,13 @@ | @@ -26,7 +26,13 @@ | ||
| 26 | </div> | 26 | </div> |
| 27 | <!-- 表格内容 --> | 27 | <!-- 表格内容 --> |
| 28 | <div v-if="schema.table" class="z-schema-page__table"> | 28 | <div v-if="schema.table" class="z-schema-page__table"> |
| 29 | - <z-schema-table :size="_size" :schema="tableSchemaDefaultProps(schema.table)" v-model="tableData" v-loading="loading" @selection-change="onTableSelectionChange"> | 29 | + <z-schema-table |
| 30 | + :size="_size" | ||
| 31 | + :schema="tableSchemaDefaultProps(schema.table)" | ||
| 32 | + v-model="tableData" | ||
| 33 | + v-loading="schema.loading !== false ? tableLoading : false" | ||
| 34 | + @selection-change="onTableSelectionChange" | ||
| 35 | + > | ||
| 30 | <template #left> | 36 | <template #left> |
| 31 | <el-table-column v-if="schema.selection !== false" type="selection" width="40" align="center"></el-table-column> | 37 | <el-table-column v-if="schema.selection !== false" type="selection" width="40" align="center"></el-table-column> |
| 32 | </template> | 38 | </template> |
| @@ -165,7 +171,7 @@ setKeysDefault(['value-table'], { | @@ -165,7 +171,7 @@ setKeysDefault(['value-table'], { | ||
| 165 | }, | 171 | }, |
| 166 | }); | 172 | }); |
| 167 | setKeysDefault(['size', 'dialogTitle', 'dialogType'], String); | 173 | setKeysDefault(['size', 'dialogTitle', 'dialogType'], String); |
| 168 | -setKeysDefault(['dialogVisible', 'auto'], Boolean); | 174 | +setKeysDefault(['dialogVisible', 'auto', 'loading'], Boolean); |
| 169 | setKeysDefault(['api-search', 'api-submit', 'api-new', 'api-edit', 'api-get', 'api-detail', 'api-delete'], Function); | 175 | setKeysDefault(['api-search', 'api-submit', 'api-new', 'api-edit', 'api-get', 'api-detail', 'api-delete'], Function); |
| 170 | 176 | ||
| 171 | export default { | 177 | export default { |
| @@ -198,7 +204,7 @@ export default { | @@ -198,7 +204,7 @@ export default { | ||
| 198 | detailSchema: filterout(cloneDeep(this.schema.form || {}), ['is', 'rules']), | 204 | detailSchema: filterout(cloneDeep(this.schema.form || {}), ['is', 'rules']), |
| 199 | detail: this.valueDetail || {}, | 205 | detail: this.valueDetail || {}, |
| 200 | tableData: this.valueTable || [], | 206 | tableData: this.valueTable || [], |
| 201 | - loading: false, | 207 | + tableLoading: this.loading || false, |
| 202 | submitting: false, | 208 | submitting: false, |
| 203 | dialogLoading: false, | 209 | dialogLoading: false, |
| 204 | }; | 210 | }; |
| @@ -239,6 +245,9 @@ export default { | @@ -239,6 +245,9 @@ export default { | ||
| 239 | tableData(val) { | 245 | tableData(val) { |
| 240 | this.$emit('update:value-table', val); | 246 | this.$emit('update:value-table', val); |
| 241 | }, | 247 | }, |
| 248 | + tableLoading(val) { | ||
| 249 | + this.$emit('update:loading', val); | ||
| 250 | + }, | ||
| 242 | }, | 251 | }, |
| 243 | computed: { | 252 | computed: { |
| 244 | slotKeys() { | 253 | slotKeys() { |
| @@ -248,10 +257,11 @@ export default { | @@ -248,10 +257,11 @@ export default { | ||
| 248 | return this.size || get(this.schema, 'props.size') || (this.$ELEMENT || {}).size; | 257 | return this.size || get(this.schema, 'props.size') || (this.$ELEMENT || {}).size; |
| 249 | }, | 258 | }, |
| 250 | _slotScope() { | 259 | _slotScope() { |
| 251 | - const properties = ['selection', 'currentPage', 'pageSizes', 'pageSize', 'layout', 'total', 'loading']; | 260 | + const properties = ['selection', 'currentPage', 'pageSizes', 'pageSize', 'layout', 'total']; |
| 252 | const methods = ['search', 'onSearch', 'onDelete', 'onDeleteMultiple', 'openNew', 'openEdit', 'openDetail', 'openDialog', 'closeDialog']; | 261 | const methods = ['search', 'onSearch', 'onDelete', 'onDeleteMultiple', 'openNew', 'openEdit', 'openDetail', 'openDialog', 'closeDialog']; |
| 253 | const defaultScope = { | 262 | const defaultScope = { |
| 254 | size: this._size, | 263 | size: this._size, |
| 264 | + loading: this.tableLoading, | ||
| 255 | }; | 265 | }; |
| 256 | return [...properties, ...methods].reduce((result, current) => { | 266 | return [...properties, ...methods].reduce((result, current) => { |
| 257 | result[current] = this[current]; | 267 | result[current] = this[current]; |
| @@ -327,8 +337,8 @@ export default { | @@ -327,8 +337,8 @@ export default { | ||
| 327 | }, | 337 | }, |
| 328 | // 查询 | 338 | // 查询 |
| 329 | search() { | 339 | search() { |
| 330 | - if (!this.loading) { | ||
| 331 | - this.loading = true; | 340 | + if (!this.tableLoading) { |
| 341 | + this.tableLoading = true; | ||
| 332 | const params = { | 342 | const params = { |
| 333 | ...this.valueFilter, | 343 | ...this.valueFilter, |
| 334 | currentPage: this.currentPage, | 344 | currentPage: this.currentPage, |
| @@ -342,7 +352,7 @@ export default { | @@ -342,7 +352,7 @@ export default { | ||
| 342 | this.total = response[1] || 0; | 352 | this.total = response[1] || 0; |
| 343 | }) | 353 | }) |
| 344 | .finally(() => { | 354 | .finally(() => { |
| 345 | - this.loading = false; | 355 | + this.tableLoading = false; |
| 346 | }); | 356 | }); |
| 347 | } | 357 | } |
| 348 | }, | 358 | }, |
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" @show="onTriggerShow"> | 15 | + <el-popover class="z-schema-select" popper-class="z-schema-select__popper" v-model="visible" trigger="manual" 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" |
| @@ -38,6 +38,7 @@ | @@ -38,6 +38,7 @@ | ||
| 38 | ref="schema" | 38 | ref="schema" |
| 39 | :value-table.sync="tableData" | 39 | :value-table.sync="tableData" |
| 40 | :value-filter="valueFilter" | 40 | :value-filter="valueFilter" |
| 41 | + :loading.sync="loading" | ||
| 41 | @update:value-filter="e => $emit('update:value-filter', e)" | 42 | @update:value-filter="e => $emit('update:value-filter', e)" |
| 42 | :schema="selectSchema" | 43 | :schema="selectSchema" |
| 43 | :size="selectSize" | 44 | :size="selectSize" |
| @@ -80,6 +81,9 @@ export default { | @@ -80,6 +81,9 @@ export default { | ||
| 80 | const props = context.props || {}; | 81 | const props = context.props || {}; |
| 81 | const keyword = props.keyword; | 82 | const keyword = props.keyword; |
| 82 | const value = props.value || ''; | 83 | const value = props.value || ''; |
| 84 | + if (!keyword) { | ||
| 85 | + return h('span', value); | ||
| 86 | + } | ||
| 83 | const reg = new RegExp(`(${keyword})`, 'g'); | 87 | const reg = new RegExp(`(${keyword})`, 'g'); |
| 84 | const result = `${value}`.replace(reg, '<font style="color: red;">$1</font>'); | 88 | const result = `${value}`.replace(reg, '<font style="color: red;">$1</font>'); |
| 85 | return h('span', { domProps: { innerHTML: result } }); | 89 | return h('span', { domProps: { innerHTML: result } }); |
| @@ -149,7 +153,9 @@ export default { | @@ -149,7 +153,9 @@ export default { | ||
| 149 | visible: false, | 153 | visible: false, |
| 150 | inputHovering: false, | 154 | inputHovering: false, |
| 151 | tableData: [], | 155 | tableData: [], |
| 156 | + loading: false, | ||
| 152 | loaded: false, | 157 | loaded: false, |
| 158 | + inFocus: false, | ||
| 153 | }; | 159 | }; |
| 154 | }, | 160 | }, |
| 155 | created() { | 161 | created() { |
| @@ -283,16 +289,22 @@ export default { | @@ -283,16 +289,22 @@ export default { | ||
| 283 | } | 289 | } |
| 284 | }, | 290 | }, |
| 285 | onInputFocus() { | 291 | onInputFocus() { |
| 292 | + this.visible = true; | ||
| 293 | + this.inFocus = true; | ||
| 286 | if (!this.allowCreate) { | 294 | if (!this.allowCreate) { |
| 287 | this.model = ''; | 295 | this.model = ''; |
| 288 | } | 296 | } |
| 289 | }, | 297 | }, |
| 290 | onInputBlur() { | 298 | onInputBlur() { |
| 299 | + this.inFocus = false; | ||
| 291 | if (!this.visible) { | 300 | if (!this.visible) { |
| 292 | this.model = this.selectedLabel; | 301 | this.model = this.selectedLabel; |
| 293 | } | 302 | } |
| 294 | }, | 303 | }, |
| 295 | onClickoutside() { | 304 | onClickoutside() { |
| 305 | + if (!this.inFocus) { | ||
| 306 | + this.visible = false; | ||
| 307 | + } | ||
| 296 | if (this.visible) { | 308 | if (this.visible) { |
| 297 | this.model = this.selectedLabel; | 309 | this.model = this.selectedLabel; |
| 298 | this.query = ''; | 310 | this.query = ''; |
| @@ -311,7 +323,6 @@ export default { | @@ -311,7 +323,6 @@ export default { | ||
| 311 | event.stopPropagation(); | 323 | event.stopPropagation(); |
| 312 | this.query = ''; | 324 | this.query = ''; |
| 313 | this.model = ''; | 325 | this.model = ''; |
| 314 | - this.visible = false; | ||
| 315 | this.$emit('input', ''); | 326 | this.$emit('input', ''); |
| 316 | this.$emit('clear'); | 327 | this.$emit('clear'); |
| 317 | this.$emit('change', ''); | 328 | this.$emit('change', ''); |