tenghui-ui 2.3.2 → 2.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tenghui-ui",
3
- "version": "2.3.2",
3
+ "version": "2.3.4",
4
4
  "description": "vue 2x, tenghui-ui",
5
5
  "files": [
6
6
  "dist",
@@ -37,6 +37,7 @@
37
37
  "vue-tsc": "^0.29.8"
38
38
  },
39
39
  "dependencies": {
40
+ "axios": "^1.6.2",
40
41
  "draggabilly": "^3.0.0",
41
42
  "element-ui": "^2.15.8",
42
43
  "qs": "^6.11.0",
@@ -29,10 +29,10 @@
29
29
  </el-popover>
30
30
  </div>
31
31
  <div>
32
- <div v-if="item.title">
32
+ <div v-if="item.title" class="ui-desc__title">
33
33
  <span>{{ item.title }}</span>
34
34
  </div>
35
- <div v-else>
35
+ <div v-else class="ui-desc__title">
36
36
  <span v-for="(v, index) in item.labels" :key="index">{{v.prependLabel || v.label}}:{{v.valueLabel || v.value}}</span>
37
37
  </div>
38
38
  </div>
@@ -50,7 +50,9 @@
50
50
  :key="index"
51
51
  :title="item.map(v => `${v.prependLabel || v.label}:${v.valueLabel || v.value}`).join(';')"
52
52
  @click="handleShortcut(item, index)">
53
- <span v-for="(v, i) in item" :key="i">{{v.prependLabel || v.label}}:{{v.valueLabel || v.value}}</span>
53
+ <div class="ui-desc__title">
54
+ <span v-for="(v, i) in item" :key="i">{{v.prependLabel || v.label}}:{{v.valueLabel || v.value}}</span>
55
+ </div>
54
56
  <el-tooltip class="item" effect="dark" content="添加到常用筛选" placement="top-start">
55
57
  <i class="el-icon-circle-plus ui-flag--icon" @click.stop="handleOperation(index, 'temps')"></i>
56
58
  </el-tooltip>
@@ -89,21 +91,24 @@ export default {
89
91
  changeLabelTitleItem: {}
90
92
  }
91
93
  },
92
- created() {
93
- let locData = localStorage.getItem(`SaveRecord_${this.configKey}`);
94
- const recordData = locData ? JSON.parse(locData) : {
95
- saves: [],
96
- temps: []
97
- }
94
+ async mounted() {
95
+ // let locData = localStorage.getItem(`SaveRecord_${this.configKey}`);
96
+ setTimeout(async () => {
97
+ let locData = await this.$parent.getConfigCache(`SaveRecord_${this.configKey}`);
98
+ const recordData = !!Object.entries(locData).length ? locData : {
99
+ saves: [],
100
+ temps: []
101
+ }
98
102
 
99
- if (recordData.saves[0] && Array.isArray(recordData.saves[0])) {
100
- recordData.saves = recordData.saves.map(item => ({
101
- labels: item,
102
- title: ''
103
- }));
104
- }
103
+ if (recordData.saves[0] && Array.isArray(recordData.saves[0])) {
104
+ recordData.saves = recordData.saves.map(item => ({
105
+ labels: item,
106
+ title: ''
107
+ }));
108
+ }
105
109
 
106
- this.recordData = recordData;
110
+ this.recordData = recordData;
111
+ }, 500);
107
112
  },
108
113
  methods: {
109
114
  handleOperation(index, type) {
@@ -173,7 +178,8 @@ export default {
173
178
  if (this.recordData.temps.length > 10) {
174
179
  this.recordData.temps.splice(10);
175
180
  }
176
- localStorage.setItem(`SaveRecord_${this.configKey}`, JSON.stringify(this.recordData));
181
+
182
+ this.$parent.setConfigCache(`SaveRecord_${this.configKey}`, this.recordData);
177
183
  },
178
184
 
179
185
  // 修改标签名称
@@ -185,7 +191,7 @@ export default {
185
191
  this.changeLabelTitleItem.title = this.changeLabelTitleVal;
186
192
  this.changeLabelTitleVal = '';
187
193
  this.$refs[`EditLabelTitlePopover_${index}`][0].doClose();
188
- localStorage.setItem(`SaveRecord_${this.configKey}`, JSON.stringify(this.recordData));
194
+ this.$parent.setConfigCache(`SaveRecord_${this.configKey}`, this.recordData);
189
195
  }
190
196
  },
191
197
  watch: {
@@ -251,9 +257,6 @@ export default {
251
257
  font-size: 12px;
252
258
  margin-right: 8px;
253
259
  margin-bottom: 8px;
254
- text-overflow: ellipsis;
255
- white-space: nowrap;
256
- overflow: hidden;
257
260
  border: 1px solid #f1f1f1;
258
261
  padding: 5px;
259
262
  background: #fefefe;
@@ -262,6 +265,13 @@ export default {
262
265
  align-self: flex-end;
263
266
  cursor: pointer;
264
267
  position: relative;
268
+ max-width: 99%;
269
+
270
+ .ui-desc__title {
271
+ text-overflow: ellipsis;
272
+ white-space: nowrap;
273
+ overflow: hidden;
274
+ }
265
275
 
266
276
  span {
267
277
  background-color: #f1f1f1;
@@ -276,7 +286,7 @@ export default {
276
286
 
277
287
  &:hover {
278
288
  border-color: #b2d8ff;
279
- min-width: 100px;
289
+ // min-width: 100px;
280
290
 
281
291
  span {
282
292
  background-color: #b2d8ff;
@@ -290,9 +300,8 @@ export default {
290
300
 
291
301
  .ui-flag--icon {
292
302
  position: absolute;
293
- right: 5px;
294
- top: 50%;
295
- margin-top: -8px;
303
+ left: 2px;
304
+ top: -8px;
296
305
  font-size: 16px;
297
306
  color: #409EFF;
298
307
  display: none;
@@ -306,7 +315,7 @@ export default {
306
315
  }
307
316
 
308
317
  .el-icon-edit {
309
- right: 28px;
318
+ left: 26px;
310
319
  font-size: 12px;
311
320
  }
312
321
  }
@@ -1,6 +1,11 @@
1
1
  <template>
2
2
  <div class="ui-search" ref="Search" v-loading="loadSearch">
3
- <div class="ui-search__main" v-show="collspase">
3
+ <div class="ui-search--mask"
4
+ v-loading="true"
5
+ element-loading-text="加载配置中"
6
+ element-loading-background="rgba(255, 255, 255, 1)"
7
+ v-if="loadingConfig"></div>
8
+ <div class="ui-search__main" :class="{ 'loaddone': loadingConfig == false }" v-show="collspase">
4
9
  <slot v-if="!useConfig"></slot>
5
10
  <div v-else v-show="false"><slot></slot></div>
6
11
  <template v-if="!loadSearch && useConfig">
@@ -146,7 +151,10 @@ export default {
146
151
  searchHeight: '',
147
152
  listenerSearchTimes: '',
148
153
  collspase: true,
149
- showTip: false
154
+ showTip: false,
155
+
156
+ localConfig: null,
157
+ loadingConfig: null
150
158
  }
151
159
  },
152
160
  computed: {
@@ -329,7 +337,8 @@ export default {
329
337
  checkItems: this.checkItems,
330
338
  sortItems: this.sortItems
331
339
  }
332
- localStorage.setItem(`SearchCfg__${this.configKey}`, JSON.stringify(saveConfig));
340
+
341
+ this.setConfigCache(`SearchCfg__${this.configKey}`, saveConfig);
333
342
 
334
343
  const sortItems = this.sortItems.map(item => {
335
344
  const findItem = this.childItems.find(v => v.$options.propsData.label == item);
@@ -354,6 +363,54 @@ export default {
354
363
  findTableRes && findTableRes.handleRefreshHeight();
355
364
  }
356
365
  }, 200);
366
+ },
367
+
368
+
369
+ async setConfigCache(key, value) {
370
+
371
+ if (!this.$UICONFIG.setCacheApi) {
372
+
373
+ localStorage.setItem(key, JSON.stringify(value));
374
+ return;
375
+ }
376
+
377
+ this.localConfig[key] = JSON.stringify(value);
378
+ const { data:res } = await this.$http.post(this.$UICONFIG.setCacheApi, {
379
+ code: this.configKey,
380
+ datas: this.localConfig
381
+ });
382
+ },
383
+
384
+ async getConfigCache(key) {
385
+
386
+ if (!this.$UICONFIG.getCacheApi) {
387
+ this.loadingConfig = false;
388
+ return JSON.parse(localStorage.getItem(key) || "{}");
389
+ }
390
+
391
+ // if (this.loadingConfig) {
392
+ // await (() => {
393
+ // return new Promise(resolve => {
394
+ // let waitLoad = setTimeout(() => {
395
+ // resolve(true);
396
+ // }, 500);
397
+ // })
398
+ // })();
399
+ // }
400
+
401
+ if (!this.localConfig) {
402
+ this.loadingConfig = true;
403
+ const { data:res } = await this.$http.post(this.$UICONFIG.getCacheApi, {
404
+ code: this.configKey
405
+ });
406
+
407
+ setTimeout(() => {
408
+ this.loadingConfig = false;
409
+ }, 200)
410
+ this.localConfig = !Object.entries(res.data).length ? {} : res.data;
411
+ }
412
+
413
+ return JSON.parse(this.localConfig[key] || "{}");
357
414
  }
358
415
  },
359
416
  async mounted() {
@@ -382,11 +439,20 @@ export default {
382
439
 
383
440
 
384
441
  // 读取缓存配置
385
- const locConfig = JSON.parse(localStorage.getItem(`SearchCfg__${this.configKey}`) || "{}");
442
+ const locConfig = await this.getConfigCache(`SearchCfg__${this.configKey}`);
386
443
  if (locConfig.checkItems) {
387
444
  await this.$nextTick();
388
- this.checkItems = locConfig.checkItems;
389
- this.sortItems = locConfig.sortItems;
445
+
446
+ // 处理搜索条件发生变更
447
+ const newItemInx = this.sortItems.findIndex(v => !locConfig.sortItems.includes(v));
448
+ if (newItemInx > -1) {
449
+ const newItem = this.sortItems[newItemInx];
450
+ locConfig.checkItems.push(newItem);
451
+ locConfig.sortItems.splice(newItemInx, 0, newItem);
452
+ }
453
+
454
+ this.checkItems = locConfig.checkItems.filter(v => this.sortItems.includes(v));
455
+ this.sortItems = locConfig.sortItems.filter(v => this.sortItems.includes(v));
390
456
  this.handleRenderConfig();
391
457
  }
392
458
  } else {
@@ -436,6 +502,7 @@ export default {
436
502
  </script>
437
503
  <style lang="less" scoped>
438
504
  .ui-search {
505
+ overflow: hidden;
439
506
  // height: 138px;
440
507
  box-sizing: border-box;
441
508
  margin: 10px 10px 0 10px;
@@ -454,6 +521,12 @@ export default {
454
521
 
455
522
  &__main {
456
523
  display: flex;
524
+ opacity: 0;
525
+ transition: all .2s linear;
526
+
527
+ &.loaddone {
528
+ opacity: 1;
529
+ }
457
530
  }
458
531
 
459
532
  &__footer {
@@ -612,4 +685,13 @@ export default {
612
685
  width: 100%;
613
686
  }
614
687
  }
688
+
689
+ .ui-search--mask {
690
+ position: absolute;
691
+ top: 0;
692
+ left: 0;
693
+ width: 100%;
694
+ height: 100%;
695
+ z-index: 2;
696
+ }
615
697
  </style>