kz-ui-base 1.0.163 → 1.0.165

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.
@@ -177,6 +177,10 @@ import * as Utils from "@utils/utils";
177
177
  },
178
178
  })
179
179
  export default class dropDownList extends Vue {
180
+ // 静态缓存对象,所有实例共享
181
+ private static globalCache: any = {};
182
+ private static globalRequesting: any = {};
183
+
180
184
  @Prop()
181
185
  property;
182
186
  @Prop()
@@ -807,24 +811,84 @@ export default class dropDownList extends Vue {
807
811
  self.firstLoaded = true;
808
812
  });
809
813
  } else if (this.setting.url && !this.setting.remote) {
810
- ajaxUrl({
811
- url: this.setting.url,
812
- method: "get",
813
- params: this.getSearchParams(this.setting.searchRules, undefined),
814
- }).then((response) => {
814
+ // 生成缓存键
815
+ const cacheKey = this.setting.url + JSON.stringify(this.getSearchParams(this.setting.searchRules, undefined));
816
+
817
+ // 使用静态缓存
818
+ const globalCache = (dropDownList as any).globalCache;
819
+ const globalRequesting = (dropDownList as any).globalRequesting;
820
+
821
+ // 检查缓存中是否已有数据
822
+ if (globalCache[cacheKey]) {
823
+ // 使用缓存数据
824
+ const cachedData = globalCache[cacheKey];
815
825
  if (this.setting.treeSelect) {
816
- self.data = response["data" || "rows"];
826
+ self.data = cachedData;
817
827
  }
818
-
819
828
  self.items = (self as any).convertSourceToOptions(
820
- response[self.setting.dataField || "data" || "rows"]
829
+ cachedData
821
830
  );
822
- this.objList = response["data" || "rows"];
831
+ this.objList = cachedData;
823
832
  if (this.entity[this.column.property]) {
824
833
  this.onChangeEvent(this.entity[this.column.property], true);
825
834
  }
826
835
  self.firstLoaded = true;
827
- });
836
+ } else if (globalRequesting[cacheKey]) {
837
+ // 正在请求中,等待请求完成
838
+ // 使用定时器轮询检查缓存
839
+ const checkCache = setInterval(() => {
840
+ if (globalCache[cacheKey]) {
841
+ clearInterval(checkCache);
842
+ const cachedData = globalCache[cacheKey];
843
+ if (this.setting.treeSelect) {
844
+ self.data = cachedData;
845
+ }
846
+ self.items = (self as any).convertSourceToOptions(
847
+ cachedData
848
+ );
849
+ this.objList = cachedData;
850
+ if (this.entity[this.column.property]) {
851
+ this.onChangeEvent(this.entity[this.column.property], true);
852
+ }
853
+ self.firstLoaded = true;
854
+ }
855
+ }, 100);
856
+ // 5秒后清除定时器,避免无限等待
857
+ setTimeout(() => clearInterval(checkCache), 5000);
858
+ } else {
859
+ // 没有缓存且没有在请求中,发送请求
860
+ globalRequesting[cacheKey] = true;
861
+
862
+ ajaxUrl({
863
+ url: this.setting.url,
864
+ method: "get",
865
+ params: this.getSearchParams(this.setting.searchRules, undefined),
866
+ }).then((response) => {
867
+ const responseData = response[this.setting.dataField || "data" || "rows"];
868
+
869
+ // 存入静态缓存
870
+ globalCache[cacheKey] = responseData;
871
+
872
+ if (this.setting.treeSelect) {
873
+ self.data = response["data" || "rows"];
874
+ }
875
+
876
+ self.items = (self as any).convertSourceToOptions(
877
+ responseData
878
+ );
879
+ this.objList = response["data" || "rows"];
880
+ if (this.entity[this.column.property]) {
881
+ this.onChangeEvent(this.entity[this.column.property], true);
882
+ }
883
+ self.firstLoaded = true;
884
+
885
+ // 清除请求标记
886
+ delete globalRequesting[cacheKey];
887
+ }).catch(() => {
888
+ // 请求失败也要清除标记
889
+ delete globalRequesting[cacheKey];
890
+ });
891
+ }
828
892
  }
829
893
  }
830
894
  }
@@ -56,11 +56,14 @@
56
56
  <i class="el-icon-delete"></i>
57
57
  </span>
58
58
  </span>
59
- <el-link style="line-height: 88px" :href="file.url">
60
- <span v-if="setting.showName" class="linkClass">
61
- {{ file.name }}
62
- </span>
63
- </el-link>
59
+ <span
60
+ v-if="setting.showName"
61
+ class="linkClass"
62
+ style="line-height: 88px; cursor: pointer;"
63
+ @click="handlePictureCardPreview(file)"
64
+ >
65
+ {{ file.name }}
66
+ </span>
64
67
  </div>
65
68
 
66
69
  <!-- <el-button size="mini" type="primary">选取文件</el-button> -->
@@ -1724,6 +1724,10 @@ export default class listBasePage extends Vue {
1724
1724
  cachedData = {};
1725
1725
  // 正在请求的URL标记
1726
1726
  requestingUrls = {};
1727
+ // DropDownList 组件缓存数据
1728
+ dropDownListCache = {};
1729
+ // DropDownList 正在请求的URL标记
1730
+ dropDownListRequesting = {};
1727
1731
  exportButton = false;
1728
1732
  // @Watch("searchRules", { deep: true })
1729
1733
  // watchSearchRules(newVal, oldVal) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kz-ui-base",
3
- "version": "1.0.163",
3
+ "version": "1.0.165",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {