@vipl520/dk-ui 1.0.22 → 1.0.24

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/dist/index.js CHANGED
@@ -11813,7 +11813,7 @@
11813
11813
  const _hoisted_8$9 = { class: "attachment-group" };
11814
11814
  const _hoisted_9$7 = { class: "group_list" };
11815
11815
  const _hoisted_10$6 = ["onClick"];
11816
- const _hoisted_11$5 = { class: "ml-10px" };
11816
+ const _hoisted_11$6 = { class: "ml-10px" };
11817
11817
  const _hoisted_12$5 = { class: "op" };
11818
11818
  const _hoisted_13$4 = { class: "attachment-container" };
11819
11819
  const _hoisted_14$4 = {
@@ -12190,7 +12190,7 @@
12190
12190
  })),
12191
12191
  require$$0.createElementVNode(
12192
12192
  "span",
12193
- _hoisted_11$5,
12193
+ _hoisted_11$6,
12194
12194
  require$$0.toDisplayString(item.name),
12195
12195
  1
12196
12196
  /* TEXT */
@@ -14397,7 +14397,7 @@
14397
14397
  const _hoisted_8$8 = ["title", "onDblclick"];
14398
14398
  const _hoisted_9$6 = ["onUpdate:modelValue", "onBlur"];
14399
14399
  const _hoisted_10$5 = ["width", "height", "viewBox", "data-link-anchor", "innerHTML"];
14400
- const _hoisted_11$4 = /* @__PURE__ */ require$$0.createElementVNode(
14400
+ const _hoisted_11$5 = /* @__PURE__ */ require$$0.createElementVNode(
14401
14401
  "div",
14402
14402
  { style: { "position": "absolute", "display": "none", "width": "100%", "height": "100%" } },
14403
14403
  null,
@@ -14820,7 +14820,7 @@
14820
14820
  /* KEYED_FRAGMENT */
14821
14821
  ))
14822
14822
  ]),
14823
- _hoisted_11$4,
14823
+ _hoisted_11$5,
14824
14824
  require$$0.createElementVNode("div", _hoisted_12$4, [
14825
14825
  (require$$0.openBlock(), require$$0.createElementBlock(
14826
14826
  require$$0.Fragment,
@@ -17854,7 +17854,7 @@
17854
17854
  );
17855
17855
  const _hoisted_9$5 = { class: "phone-title" };
17856
17856
  const _hoisted_10$4 = { class: "phone-title-icon" };
17857
- const _hoisted_11$3 = /* @__PURE__ */ require$$0.createElementVNode(
17857
+ const _hoisted_11$4 = /* @__PURE__ */ require$$0.createElementVNode(
17858
17858
  "div",
17859
17859
  null,
17860
17860
  "\u9875\u9762\u6807\u9898",
@@ -18023,7 +18023,7 @@
18023
18023
  /* STABLE */
18024
18024
  })
18025
18025
  ]),
18026
- _hoisted_11$3,
18026
+ _hoisted_11$4,
18027
18027
  require$$0.createElementVNode("div", _hoisted_12$3, [
18028
18028
  require$$0.createVNode(_component_el_popover, {
18029
18029
  placement: "bottom",
@@ -22933,7 +22933,7 @@
22933
22933
  key: 0,
22934
22934
  class: "tag"
22935
22935
  };
22936
- const _hoisted_11$2 = {
22936
+ const _hoisted_11$3 = {
22937
22937
  key: 1,
22938
22938
  class: "tag"
22939
22939
  };
@@ -23137,7 +23137,7 @@
23137
23137
  ]))
23138
23138
  : require$$0.createCommentVNode("v-if", true),
23139
23139
  (item.down_count > 100)
23140
- ? (require$$0.openBlock(), require$$0.createElementBlock("span", _hoisted_11$2, [
23140
+ ? (require$$0.openBlock(), require$$0.createElementBlock("span", _hoisted_11$3, [
23141
23141
  require$$0.createVNode(_component_van_icon, { name: "fire" }),
23142
23142
  require$$0.createTextVNode("热门")
23143
23143
  ]))
@@ -24749,6 +24749,24 @@
24749
24749
  cacheTable: {
24750
24750
  default: true,
24751
24751
  type: Boolean
24752
+ },
24753
+ tableBefore: {
24754
+ default: () => {
24755
+ return {};
24756
+ },
24757
+ type: Object
24758
+ },
24759
+ tableAfter: {
24760
+ default: () => {
24761
+ return {};
24762
+ },
24763
+ type: Object
24764
+ },
24765
+ buttons: {
24766
+ default: () => {
24767
+ return ["refresh", "add", "export_csv", "edit", "delete", "comSearch", "quickSearch", "columnDisplay"];
24768
+ },
24769
+ type: Array
24752
24770
  }
24753
24771
  // ...ElTableNext.props,
24754
24772
  };
@@ -28127,6 +28145,8 @@
28127
28145
  * 显示回收站
28128
28146
  */
28129
28147
  async showRecycle() {
28148
+ if (!this.runBefore("getRecycleTable"))
28149
+ return;
28130
28150
  this.recycleTable.showDialogLoading = true;
28131
28151
  if (this.recycleTable.column.length <= 0) {
28132
28152
  await this.getRecycleTable();
@@ -28139,6 +28159,8 @@
28139
28159
  * 获取回收站列表
28140
28160
  */
28141
28161
  getRecycleIndex = () => {
28162
+ if (!this.runBefore("getRecycleIndex"))
28163
+ return;
28142
28164
  this.recycleTable.loading = true;
28143
28165
  return this.api.recycle(this.recycleTable.filter).then((res) => {
28144
28166
  this.recycleTable.data = res.data.list;
@@ -28317,6 +28339,36 @@
28317
28339
  this.runAfter("onTableDblclick", { row, column });
28318
28340
  }
28319
28341
  };
28342
+ exportCsv = () => {
28343
+ const header = this.table.column;
28344
+ const headerMap = new Map(
28345
+ header.filter((item) => item !== void 0 && item.label !== void 0 && item.export).map((item) => [item.label, item.prop])
28346
+ );
28347
+ const headerLabels = Array.from(headerMap.keys());
28348
+ function jsonToCsv(data) {
28349
+ let csvContent = headerLabels.join(",") + "\n";
28350
+ data.forEach((row) => {
28351
+ const line = [];
28352
+ headerLabels.forEach((label) => {
28353
+ const prop = headerMap.get(label);
28354
+ const value = String(row[prop]);
28355
+ line.push(`"${value.replace(/"/g, '""').replace(/[\n\r]/g, " ")}"`);
28356
+ });
28357
+ csvContent += line.join(",") + "\n";
28358
+ });
28359
+ return csvContent;
28360
+ }
28361
+ function downloadCsv(csvContent, fileName) {
28362
+ const link = document.createElement("a");
28363
+ link.setAttribute("href", "data:text/csv;charset=utf-8," + encodeURIComponent(csvContent));
28364
+ link.setAttribute("download", fileName + ".csv");
28365
+ document.body.appendChild(link);
28366
+ link.click();
28367
+ document.body.removeChild(link);
28368
+ }
28369
+ const csvStr = jsonToCsv(this.table.selection);
28370
+ downloadCsv(csvStr, "export_data");
28371
+ };
28320
28372
  /**
28321
28373
  * 打开表单
28322
28374
  * @param operate 操作:Add=添加,Edit=编辑
@@ -28408,6 +28460,12 @@
28408
28460
  this.toggleForm("Add");
28409
28461
  }
28410
28462
  ],
28463
+ [
28464
+ "export_csv",
28465
+ () => {
28466
+ this.exportCsv();
28467
+ }
28468
+ ],
28411
28469
  [
28412
28470
  "edit",
28413
28471
  () => {
@@ -29405,7 +29463,7 @@
29405
29463
  };
29406
29464
  const _hoisted_9$3 = { class: "com-search-col-input-range" };
29407
29465
  const _hoisted_10$2 = { class: "com-search-col" };
29408
- const _hoisted_11$1 = {
29466
+ const _hoisted_11$2 = {
29409
29467
  key: 0,
29410
29468
  class: "com-search-col-label"
29411
29469
  };
@@ -29668,7 +29726,7 @@
29668
29726
  require$$0.createElementVNode("div", _hoisted_10$2, [
29669
29727
  item.comSearchShowLabel !== false ? (require$$0.openBlock(), require$$0.createElementBlock(
29670
29728
  "div",
29671
- _hoisted_11$1,
29729
+ _hoisted_11$2,
29672
29730
  require$$0.toDisplayString(item.label),
29673
29731
  1
29674
29732
  /* TEXT */
@@ -29916,31 +29974,38 @@
29916
29974
  /* HOISTED */
29917
29975
  );
29918
29976
  const _hoisted_3$6 = /* @__PURE__ */ require$$0.createElementVNode(
29977
+ "span",
29978
+ { class: "m-l-5px" },
29979
+ "\u5BFC\u51FA",
29980
+ -1
29981
+ /* HOISTED */
29982
+ );
29983
+ const _hoisted_4$6 = /* @__PURE__ */ require$$0.createElementVNode(
29919
29984
  "span",
29920
29985
  { class: "m-l-5px" },
29921
29986
  "\u7F16\u8F91",
29922
29987
  -1
29923
29988
  /* HOISTED */
29924
29989
  );
29925
- const _hoisted_4$6 = { class: "m-l-5px" };
29926
- const _hoisted_5$4 = /* @__PURE__ */ require$$0.createElementVNode(
29990
+ const _hoisted_5$4 = { class: "m-l-5px" };
29991
+ const _hoisted_6$4 = /* @__PURE__ */ require$$0.createElementVNode(
29927
29992
  "span",
29928
29993
  { class: "m-l-5px" },
29929
29994
  "\u5220\u9664",
29930
29995
  -1
29931
29996
  /* HOISTED */
29932
29997
  );
29933
- const _hoisted_6$4 = { class: "table-header-operate-text" };
29934
- const _hoisted_7$4 = /* @__PURE__ */ require$$0.createElementVNode(
29998
+ const _hoisted_7$4 = { class: "table-header-operate-text" };
29999
+ const _hoisted_8$3 = /* @__PURE__ */ require$$0.createElementVNode(
29935
30000
  "span",
29936
30001
  { class: "table-header-operate-text" },
29937
30002
  " \u56DE\u6536\u7AD9 ",
29938
30003
  -1
29939
30004
  /* HOISTED */
29940
30005
  );
29941
- const _hoisted_8$3 = { class: "table-search" };
29942
- const _hoisted_9$2 = { class: "mr-1" };
29943
- const _hoisted_10$1 = { class: "table-search-button-group" };
30006
+ const _hoisted_9$2 = { class: "table-search" };
30007
+ const _hoisted_10$1 = { class: "mr-1" };
30008
+ const _hoisted_11$1 = { class: "table-search-button-group" };
29944
30009
  const __default__$d = require$$0.defineComponent({
29945
30010
  name: "DkTableHeader"
29946
30011
  });
@@ -29953,7 +30018,7 @@
29953
30018
  },
29954
30019
  buttons: {
29955
30020
  default: () => {
29956
- return ["refresh", "add", "edit", "delete", "comSearch", "quickSearch", "columnDisplay"];
30021
+ return ["refresh", "add", "export_csv", "edit", "delete", "comSearch", "quickSearch", "columnDisplay"];
29957
30022
  },
29958
30023
  type: Array
29959
30024
  },
@@ -30087,8 +30152,33 @@
30087
30152
  _: 1
30088
30153
  /* STABLE */
30089
30154
  })) : require$$0.createCommentVNode("v-if", true),
30090
- props.buttons.includes("edit") && require$$0.unref(DkTable).auth("edit") ? (require$$0.openBlock(), require$$0.createBlock(_component_el_tooltip, {
30155
+ props.buttons.includes("export_csv") && require$$0.unref(DkTable).auth("export_csv") ? (require$$0.openBlock(), require$$0.createBlock(_component_el_tooltip, {
30091
30156
  key: 2,
30157
+ content: "\u5BFC\u51FA\u9009\u4E2D\u884C",
30158
+ placement: "top"
30159
+ }, {
30160
+ default: require$$0.withCtx(() => [
30161
+ require$$0.withDirectives((require$$0.openBlock(), require$$0.createBlock(_component_el_button, {
30162
+ disabled: !enableBatchOpt.value,
30163
+ class: "table-header-operate",
30164
+ type: "primary",
30165
+ onClick: _cache[2] || (_cache[2] = ($event) => onAction("export_csv"))
30166
+ }, {
30167
+ default: require$$0.withCtx(() => [
30168
+ require$$0.createVNode(_component_dk_icon, { icon: "typcn:download" }),
30169
+ _hoisted_3$6
30170
+ ]),
30171
+ _: 1
30172
+ /* STABLE */
30173
+ }, 8, ["disabled"])), [
30174
+ [_directive_blur]
30175
+ ])
30176
+ ]),
30177
+ _: 1
30178
+ /* STABLE */
30179
+ })) : require$$0.createCommentVNode("v-if", true),
30180
+ props.buttons.includes("edit") && require$$0.unref(DkTable).auth("edit") ? (require$$0.openBlock(), require$$0.createBlock(_component_el_tooltip, {
30181
+ key: 3,
30092
30182
  content: "\u7F16\u8F91\u9009\u4E2D\u884C",
30093
30183
  placement: "top"
30094
30184
  }, {
@@ -30097,11 +30187,11 @@
30097
30187
  disabled: !enableBatchOpt.value,
30098
30188
  class: "table-header-operate",
30099
30189
  type: "primary",
30100
- onClick: _cache[2] || (_cache[2] = ($event) => onAction("edit"))
30190
+ onClick: _cache[3] || (_cache[3] = ($event) => onAction("edit"))
30101
30191
  }, {
30102
30192
  default: require$$0.withCtx(() => [
30103
30193
  require$$0.createVNode(_component_dk_icon, { icon: "typcn:edit" }),
30104
- _hoisted_3$6
30194
+ _hoisted_4$6
30105
30195
  ]),
30106
30196
  _: 1
30107
30197
  /* STABLE */
@@ -30113,16 +30203,16 @@
30113
30203
  /* STABLE */
30114
30204
  })) : require$$0.createCommentVNode("v-if", true),
30115
30205
  props.buttons.includes("delete") && require$$0.unref(DkTable).auth("del") ? (require$$0.openBlock(), require$$0.createBlock(_component_el_popconfirm, {
30116
- key: 3,
30206
+ key: 4,
30117
30207
  "confirm-button-text": "\u5220\u9664",
30118
30208
  "cancel-button-text": "\u53D6\u6D88",
30119
30209
  "confirm-button-type": "danger",
30120
30210
  title: "\u60A8\u786E\u5B9A\u8981\u5220\u9664\u6240\u9009\u8BB0\u5F55\u5417\uFF1F",
30121
30211
  disabled: !enableBatchOpt.value,
30122
- onConfirm: _cache[3] || (_cache[3] = ($event) => onAction("delete"))
30212
+ onConfirm: _cache[4] || (_cache[4] = ($event) => onAction("delete"))
30123
30213
  }, {
30124
30214
  reference: require$$0.withCtx(() => [
30125
- require$$0.createElementVNode("div", _hoisted_4$6, [
30215
+ require$$0.createElementVNode("div", _hoisted_5$4, [
30126
30216
  require$$0.createVNode(_component_el_tooltip, {
30127
30217
  content: "\u5220\u9664\u6240\u9009\u884C",
30128
30218
  placement: "top"
@@ -30136,7 +30226,7 @@
30136
30226
  default: require$$0.withCtx(() => [
30137
30227
  require$$0.createCommentVNode(' <Icon name="fa fa-trash" />'),
30138
30228
  require$$0.createVNode(_component_dk_icon, { icon: "typcn:trash" }),
30139
- _hoisted_5$4
30229
+ _hoisted_6$4
30140
30230
  ]),
30141
30231
  _: 1
30142
30232
  /* STABLE */
@@ -30153,7 +30243,7 @@
30153
30243
  /* STABLE */
30154
30244
  }, 8, ["disabled"])) : require$$0.createCommentVNode("v-if", true),
30155
30245
  props.buttons.includes("unfold") ? (require$$0.openBlock(), require$$0.createBlock(_component_el_tooltip, {
30156
- key: 4,
30246
+ key: 5,
30157
30247
  content: (require$$0.unref(DkTable).table.expandAll ? "\u6536\u7F29" : "\u5C55\u5F00") + "\u6240\u6709\u5B50\u83DC\u5355",
30158
30248
  placement: "top"
30159
30249
  }, {
@@ -30161,14 +30251,14 @@
30161
30251
  require$$0.withDirectives((require$$0.openBlock(), require$$0.createBlock(_component_el_button, {
30162
30252
  class: "table-header-operate",
30163
30253
  type: require$$0.unref(DkTable).table.expandAll ? "danger" : "warning",
30164
- onClick: _cache[4] || (_cache[4] = ($event) => require$$0.unref(DkTable).onTableHeaderAction("unfold", {
30254
+ onClick: _cache[5] || (_cache[5] = ($event) => require$$0.unref(DkTable).onTableHeaderAction("unfold", {
30165
30255
  unfold: !require$$0.unref(DkTable).table.expandAll
30166
30256
  }))
30167
30257
  }, {
30168
30258
  default: require$$0.withCtx(() => [
30169
30259
  require$$0.createElementVNode(
30170
30260
  "span",
30171
- _hoisted_6$4,
30261
+ _hoisted_7$4,
30172
30262
  require$$0.toDisplayString(require$$0.unref(DkTable).table.expandAll ? "\u6536\u7F29\u6240\u6709" : "\u5C55\u5F00\u6240\u6709"),
30173
30263
  1
30174
30264
  /* TEXT */
@@ -30192,10 +30282,10 @@
30192
30282
  class: "table-header-operate m-l-5px",
30193
30283
  type: "warning",
30194
30284
  loading: require$$0.unref(DkTable).recycleTable.showDialogLoading,
30195
- onClick: _cache[5] || (_cache[5] = ($event) => onAction("recycle"))
30285
+ onClick: _cache[6] || (_cache[6] = ($event) => onAction("recycle"))
30196
30286
  }, {
30197
30287
  default: require$$0.withCtx(() => [
30198
- _hoisted_7$4
30288
+ _hoisted_8$3
30199
30289
  ]),
30200
30290
  _: 1
30201
30291
  /* STABLE */
@@ -30206,18 +30296,18 @@
30206
30296
  _: 1
30207
30297
  /* STABLE */
30208
30298
  }),
30209
- require$$0.createElementVNode("div", _hoisted_8$3, [
30210
- require$$0.createElementVNode("div", _hoisted_9$2, [
30299
+ require$$0.createElementVNode("div", _hoisted_9$2, [
30300
+ require$$0.createElementVNode("div", _hoisted_10$1, [
30211
30301
  require$$0.createVNode(_component_el_input, {
30212
30302
  modelValue: require$$0.unref(DkTable).table.filter.quickSearch,
30213
- "onUpdate:modelValue": _cache[6] || (_cache[6] = ($event) => require$$0.unref(DkTable).table.filter.quickSearch = $event),
30303
+ "onUpdate:modelValue": _cache[7] || (_cache[7] = ($event) => require$$0.unref(DkTable).table.filter.quickSearch = $event),
30214
30304
  placeholder: "\u8BF7\u8F93\u5165",
30215
30305
  "prefix-icon": "Search",
30216
30306
  size: __props.size,
30217
- onInput: _cache[7] || (_cache[7] = ($event) => require$$0.unref(debounce)(onSearchInput, 500)())
30307
+ onInput: _cache[8] || (_cache[8] = ($event) => require$$0.unref(debounce)(onSearchInput, 500)())
30218
30308
  }, null, 8, ["modelValue", "size"])
30219
30309
  ]),
30220
- require$$0.createElementVNode("div", _hoisted_10$1, [
30310
+ require$$0.createElementVNode("div", _hoisted_11$1, [
30221
30311
  props.buttons.includes("columnDisplay") ? (require$$0.openBlock(), require$$0.createBlock(_component_el_dropdown, {
30222
30312
  key: 0,
30223
30313
  "max-height": 380,
@@ -30287,7 +30377,7 @@
30287
30377
  require$$0.withDirectives((require$$0.openBlock(), require$$0.createBlock(_component_el_button, {
30288
30378
  size: __props.size,
30289
30379
  class: "table-search-button-item",
30290
- onClick: _cache[8] || (_cache[8] = ($event) => require$$0.unref(DkTable).table.showComSearch = !require$$0.unref(DkTable).table.showComSearch)
30380
+ onClick: _cache[9] || (_cache[9] = ($event) => require$$0.unref(DkTable).table.showComSearch = !require$$0.unref(DkTable).table.showComSearch)
30291
30381
  }, {
30292
30382
  default: require$$0.withCtx(() => [
30293
30383
  require$$0.createVNode(_component_dk_icon, { icon: "Search" })
@@ -31052,7 +31142,7 @@
31052
31142
  const props = __props;
31053
31143
  const FormRef = require$$0.ref();
31054
31144
  const TableRef = require$$0.ref();
31055
- const DkTable = new dkTable(props.tableApi);
31145
+ const DkTable = new dkTable(props.tableApi, props.tableBefore, props.tableAfter);
31056
31146
  require$$0.provide("DkTable", DkTable);
31057
31147
  require$$0.onMounted(() => {
31058
31148
  DkTable.getTable(props.cacheTable)?.then(() => {
@@ -31169,25 +31259,22 @@
31169
31259
  [
31170
31260
  require$$0.createElementVNode("div", _hoisted_1$8, [
31171
31261
  require$$0.createCommentVNode("\u9876\u90E8\u83DC\u5355"),
31172
- require$$0.createVNode(
31173
- DkTableHeader,
31174
- { size: "default" },
31175
- require$$0.createSlots({
31176
- _: 2
31177
- /* DYNAMIC */
31178
- }, [
31179
- require$$0.renderList(_ctx.$slots, (slot, idx) => {
31180
- return {
31181
- name: idx,
31182
- fn: require$$0.withCtx(() => [
31183
- require$$0.renderSlot(_ctx.$slots, idx)
31184
- ])
31185
- };
31186
- })
31187
- ]),
31188
- 1024
31189
- /* DYNAMIC_SLOTS */
31190
- ),
31262
+ require$$0.createVNode(DkTableHeader, {
31263
+ size: "default",
31264
+ buttons: _ctx.buttons
31265
+ }, require$$0.createSlots({
31266
+ _: 2
31267
+ /* DYNAMIC */
31268
+ }, [
31269
+ require$$0.renderList(_ctx.$slots, (slot, idx) => {
31270
+ return {
31271
+ name: idx,
31272
+ fn: require$$0.withCtx(() => [
31273
+ require$$0.renderSlot(_ctx.$slots, idx)
31274
+ ])
31275
+ };
31276
+ })
31277
+ ]), 1032, ["buttons"]),
31191
31278
  require$$0.createCommentVNode("\u8868\u683C"),
31192
31279
  require$$0.withDirectives((require$$0.openBlock(), require$$0.createBlock(_component_el_table, require$$0.mergeProps({
31193
31280
  ref_key: "TableRef",