@vipl520/dk-ui 1.0.23 → 1.0.25

Sign up to get free protection for your applications and to get access to all the features.
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
  ]))
@@ -24761,6 +24761,12 @@
24761
24761
  return {};
24762
24762
  },
24763
24763
  type: Object
24764
+ },
24765
+ buttons: {
24766
+ default: () => {
24767
+ return ["refresh", "add", "export_csv", "edit", "delete", "comSearch", "quickSearch", "columnDisplay"];
24768
+ },
24769
+ type: Array
24764
24770
  }
24765
24771
  // ...ElTableNext.props,
24766
24772
  };
@@ -28333,6 +28339,45 @@
28333
28339
  this.runAfter("onTableDblclick", { row, column });
28334
28340
  }
28335
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
+ let value = "";
28355
+ if (prop && prop.indexOf(".") > -1) {
28356
+ const fieldNameArr = prop.split(".");
28357
+ value = row[fieldNameArr[0]] || {};
28358
+ for (let index = 1; index < fieldNameArr.length; index++) {
28359
+ value = value ? value[fieldNameArr[index]] ?? "" : "";
28360
+ }
28361
+ } else {
28362
+ value = String(row[prop]);
28363
+ }
28364
+ line.push(`"${value.replace(/"/g, '""').replace(/[\n\r]/g, " ")}"`);
28365
+ });
28366
+ csvContent += line.join(",") + "\n";
28367
+ });
28368
+ return csvContent;
28369
+ }
28370
+ function downloadCsv(csvContent, fileName) {
28371
+ const link = document.createElement("a");
28372
+ link.setAttribute("href", "data:text/csv;charset=utf-8," + encodeURIComponent(csvContent));
28373
+ link.setAttribute("download", fileName + ".csv");
28374
+ document.body.appendChild(link);
28375
+ link.click();
28376
+ document.body.removeChild(link);
28377
+ }
28378
+ const csvStr = jsonToCsv(this.table.selection);
28379
+ downloadCsv(csvStr, "export_data");
28380
+ };
28336
28381
  /**
28337
28382
  * 打开表单
28338
28383
  * @param operate 操作:Add=添加,Edit=编辑
@@ -28424,6 +28469,12 @@
28424
28469
  this.toggleForm("Add");
28425
28470
  }
28426
28471
  ],
28472
+ [
28473
+ "export_csv",
28474
+ () => {
28475
+ this.exportCsv();
28476
+ }
28477
+ ],
28427
28478
  [
28428
28479
  "edit",
28429
28480
  () => {
@@ -29421,7 +29472,7 @@
29421
29472
  };
29422
29473
  const _hoisted_9$3 = { class: "com-search-col-input-range" };
29423
29474
  const _hoisted_10$2 = { class: "com-search-col" };
29424
- const _hoisted_11$1 = {
29475
+ const _hoisted_11$2 = {
29425
29476
  key: 0,
29426
29477
  class: "com-search-col-label"
29427
29478
  };
@@ -29684,7 +29735,7 @@
29684
29735
  require$$0.createElementVNode("div", _hoisted_10$2, [
29685
29736
  item.comSearchShowLabel !== false ? (require$$0.openBlock(), require$$0.createElementBlock(
29686
29737
  "div",
29687
- _hoisted_11$1,
29738
+ _hoisted_11$2,
29688
29739
  require$$0.toDisplayString(item.label),
29689
29740
  1
29690
29741
  /* TEXT */
@@ -29932,31 +29983,38 @@
29932
29983
  /* HOISTED */
29933
29984
  );
29934
29985
  const _hoisted_3$6 = /* @__PURE__ */ require$$0.createElementVNode(
29986
+ "span",
29987
+ { class: "m-l-5px" },
29988
+ "\u5BFC\u51FA",
29989
+ -1
29990
+ /* HOISTED */
29991
+ );
29992
+ const _hoisted_4$6 = /* @__PURE__ */ require$$0.createElementVNode(
29935
29993
  "span",
29936
29994
  { class: "m-l-5px" },
29937
29995
  "\u7F16\u8F91",
29938
29996
  -1
29939
29997
  /* HOISTED */
29940
29998
  );
29941
- const _hoisted_4$6 = { class: "m-l-5px" };
29942
- const _hoisted_5$4 = /* @__PURE__ */ require$$0.createElementVNode(
29999
+ const _hoisted_5$4 = { class: "m-l-5px" };
30000
+ const _hoisted_6$4 = /* @__PURE__ */ require$$0.createElementVNode(
29943
30001
  "span",
29944
30002
  { class: "m-l-5px" },
29945
30003
  "\u5220\u9664",
29946
30004
  -1
29947
30005
  /* HOISTED */
29948
30006
  );
29949
- const _hoisted_6$4 = { class: "table-header-operate-text" };
29950
- const _hoisted_7$4 = /* @__PURE__ */ require$$0.createElementVNode(
30007
+ const _hoisted_7$4 = { class: "table-header-operate-text" };
30008
+ const _hoisted_8$3 = /* @__PURE__ */ require$$0.createElementVNode(
29951
30009
  "span",
29952
30010
  { class: "table-header-operate-text" },
29953
30011
  " \u56DE\u6536\u7AD9 ",
29954
30012
  -1
29955
30013
  /* HOISTED */
29956
30014
  );
29957
- const _hoisted_8$3 = { class: "table-search" };
29958
- const _hoisted_9$2 = { class: "mr-1" };
29959
- const _hoisted_10$1 = { class: "table-search-button-group" };
30015
+ const _hoisted_9$2 = { class: "table-search" };
30016
+ const _hoisted_10$1 = { class: "mr-1" };
30017
+ const _hoisted_11$1 = { class: "table-search-button-group" };
29960
30018
  const __default__$d = require$$0.defineComponent({
29961
30019
  name: "DkTableHeader"
29962
30020
  });
@@ -29969,7 +30027,7 @@
29969
30027
  },
29970
30028
  buttons: {
29971
30029
  default: () => {
29972
- return ["refresh", "add", "edit", "delete", "comSearch", "quickSearch", "columnDisplay"];
30030
+ return ["refresh", "add", "export_csv", "edit", "delete", "comSearch", "quickSearch", "columnDisplay"];
29973
30031
  },
29974
30032
  type: Array
29975
30033
  },
@@ -30103,8 +30161,33 @@
30103
30161
  _: 1
30104
30162
  /* STABLE */
30105
30163
  })) : require$$0.createCommentVNode("v-if", true),
30106
- props.buttons.includes("edit") && require$$0.unref(DkTable).auth("edit") ? (require$$0.openBlock(), require$$0.createBlock(_component_el_tooltip, {
30164
+ props.buttons.includes("export_csv") && require$$0.unref(DkTable).auth("export_csv") ? (require$$0.openBlock(), require$$0.createBlock(_component_el_tooltip, {
30107
30165
  key: 2,
30166
+ content: "\u5BFC\u51FA\u9009\u4E2D\u884C",
30167
+ placement: "top"
30168
+ }, {
30169
+ default: require$$0.withCtx(() => [
30170
+ require$$0.withDirectives((require$$0.openBlock(), require$$0.createBlock(_component_el_button, {
30171
+ disabled: !enableBatchOpt.value,
30172
+ class: "table-header-operate",
30173
+ type: "primary",
30174
+ onClick: _cache[2] || (_cache[2] = ($event) => onAction("export_csv"))
30175
+ }, {
30176
+ default: require$$0.withCtx(() => [
30177
+ require$$0.createVNode(_component_dk_icon, { icon: "typcn:download" }),
30178
+ _hoisted_3$6
30179
+ ]),
30180
+ _: 1
30181
+ /* STABLE */
30182
+ }, 8, ["disabled"])), [
30183
+ [_directive_blur]
30184
+ ])
30185
+ ]),
30186
+ _: 1
30187
+ /* STABLE */
30188
+ })) : require$$0.createCommentVNode("v-if", true),
30189
+ props.buttons.includes("edit") && require$$0.unref(DkTable).auth("edit") ? (require$$0.openBlock(), require$$0.createBlock(_component_el_tooltip, {
30190
+ key: 3,
30108
30191
  content: "\u7F16\u8F91\u9009\u4E2D\u884C",
30109
30192
  placement: "top"
30110
30193
  }, {
@@ -30113,11 +30196,11 @@
30113
30196
  disabled: !enableBatchOpt.value,
30114
30197
  class: "table-header-operate",
30115
30198
  type: "primary",
30116
- onClick: _cache[2] || (_cache[2] = ($event) => onAction("edit"))
30199
+ onClick: _cache[3] || (_cache[3] = ($event) => onAction("edit"))
30117
30200
  }, {
30118
30201
  default: require$$0.withCtx(() => [
30119
30202
  require$$0.createVNode(_component_dk_icon, { icon: "typcn:edit" }),
30120
- _hoisted_3$6
30203
+ _hoisted_4$6
30121
30204
  ]),
30122
30205
  _: 1
30123
30206
  /* STABLE */
@@ -30129,16 +30212,16 @@
30129
30212
  /* STABLE */
30130
30213
  })) : require$$0.createCommentVNode("v-if", true),
30131
30214
  props.buttons.includes("delete") && require$$0.unref(DkTable).auth("del") ? (require$$0.openBlock(), require$$0.createBlock(_component_el_popconfirm, {
30132
- key: 3,
30215
+ key: 4,
30133
30216
  "confirm-button-text": "\u5220\u9664",
30134
30217
  "cancel-button-text": "\u53D6\u6D88",
30135
30218
  "confirm-button-type": "danger",
30136
30219
  title: "\u60A8\u786E\u5B9A\u8981\u5220\u9664\u6240\u9009\u8BB0\u5F55\u5417\uFF1F",
30137
30220
  disabled: !enableBatchOpt.value,
30138
- onConfirm: _cache[3] || (_cache[3] = ($event) => onAction("delete"))
30221
+ onConfirm: _cache[4] || (_cache[4] = ($event) => onAction("delete"))
30139
30222
  }, {
30140
30223
  reference: require$$0.withCtx(() => [
30141
- require$$0.createElementVNode("div", _hoisted_4$6, [
30224
+ require$$0.createElementVNode("div", _hoisted_5$4, [
30142
30225
  require$$0.createVNode(_component_el_tooltip, {
30143
30226
  content: "\u5220\u9664\u6240\u9009\u884C",
30144
30227
  placement: "top"
@@ -30152,7 +30235,7 @@
30152
30235
  default: require$$0.withCtx(() => [
30153
30236
  require$$0.createCommentVNode(' <Icon name="fa fa-trash" />'),
30154
30237
  require$$0.createVNode(_component_dk_icon, { icon: "typcn:trash" }),
30155
- _hoisted_5$4
30238
+ _hoisted_6$4
30156
30239
  ]),
30157
30240
  _: 1
30158
30241
  /* STABLE */
@@ -30169,7 +30252,7 @@
30169
30252
  /* STABLE */
30170
30253
  }, 8, ["disabled"])) : require$$0.createCommentVNode("v-if", true),
30171
30254
  props.buttons.includes("unfold") ? (require$$0.openBlock(), require$$0.createBlock(_component_el_tooltip, {
30172
- key: 4,
30255
+ key: 5,
30173
30256
  content: (require$$0.unref(DkTable).table.expandAll ? "\u6536\u7F29" : "\u5C55\u5F00") + "\u6240\u6709\u5B50\u83DC\u5355",
30174
30257
  placement: "top"
30175
30258
  }, {
@@ -30177,14 +30260,14 @@
30177
30260
  require$$0.withDirectives((require$$0.openBlock(), require$$0.createBlock(_component_el_button, {
30178
30261
  class: "table-header-operate",
30179
30262
  type: require$$0.unref(DkTable).table.expandAll ? "danger" : "warning",
30180
- onClick: _cache[4] || (_cache[4] = ($event) => require$$0.unref(DkTable).onTableHeaderAction("unfold", {
30263
+ onClick: _cache[5] || (_cache[5] = ($event) => require$$0.unref(DkTable).onTableHeaderAction("unfold", {
30181
30264
  unfold: !require$$0.unref(DkTable).table.expandAll
30182
30265
  }))
30183
30266
  }, {
30184
30267
  default: require$$0.withCtx(() => [
30185
30268
  require$$0.createElementVNode(
30186
30269
  "span",
30187
- _hoisted_6$4,
30270
+ _hoisted_7$4,
30188
30271
  require$$0.toDisplayString(require$$0.unref(DkTable).table.expandAll ? "\u6536\u7F29\u6240\u6709" : "\u5C55\u5F00\u6240\u6709"),
30189
30272
  1
30190
30273
  /* TEXT */
@@ -30208,10 +30291,10 @@
30208
30291
  class: "table-header-operate m-l-5px",
30209
30292
  type: "warning",
30210
30293
  loading: require$$0.unref(DkTable).recycleTable.showDialogLoading,
30211
- onClick: _cache[5] || (_cache[5] = ($event) => onAction("recycle"))
30294
+ onClick: _cache[6] || (_cache[6] = ($event) => onAction("recycle"))
30212
30295
  }, {
30213
30296
  default: require$$0.withCtx(() => [
30214
- _hoisted_7$4
30297
+ _hoisted_8$3
30215
30298
  ]),
30216
30299
  _: 1
30217
30300
  /* STABLE */
@@ -30222,18 +30305,18 @@
30222
30305
  _: 1
30223
30306
  /* STABLE */
30224
30307
  }),
30225
- require$$0.createElementVNode("div", _hoisted_8$3, [
30226
- require$$0.createElementVNode("div", _hoisted_9$2, [
30308
+ require$$0.createElementVNode("div", _hoisted_9$2, [
30309
+ require$$0.createElementVNode("div", _hoisted_10$1, [
30227
30310
  require$$0.createVNode(_component_el_input, {
30228
30311
  modelValue: require$$0.unref(DkTable).table.filter.quickSearch,
30229
- "onUpdate:modelValue": _cache[6] || (_cache[6] = ($event) => require$$0.unref(DkTable).table.filter.quickSearch = $event),
30312
+ "onUpdate:modelValue": _cache[7] || (_cache[7] = ($event) => require$$0.unref(DkTable).table.filter.quickSearch = $event),
30230
30313
  placeholder: "\u8BF7\u8F93\u5165",
30231
30314
  "prefix-icon": "Search",
30232
30315
  size: __props.size,
30233
- onInput: _cache[7] || (_cache[7] = ($event) => require$$0.unref(debounce)(onSearchInput, 500)())
30316
+ onInput: _cache[8] || (_cache[8] = ($event) => require$$0.unref(debounce)(onSearchInput, 500)())
30234
30317
  }, null, 8, ["modelValue", "size"])
30235
30318
  ]),
30236
- require$$0.createElementVNode("div", _hoisted_10$1, [
30319
+ require$$0.createElementVNode("div", _hoisted_11$1, [
30237
30320
  props.buttons.includes("columnDisplay") ? (require$$0.openBlock(), require$$0.createBlock(_component_el_dropdown, {
30238
30321
  key: 0,
30239
30322
  "max-height": 380,
@@ -30303,7 +30386,7 @@
30303
30386
  require$$0.withDirectives((require$$0.openBlock(), require$$0.createBlock(_component_el_button, {
30304
30387
  size: __props.size,
30305
30388
  class: "table-search-button-item",
30306
- onClick: _cache[8] || (_cache[8] = ($event) => require$$0.unref(DkTable).table.showComSearch = !require$$0.unref(DkTable).table.showComSearch)
30389
+ onClick: _cache[9] || (_cache[9] = ($event) => require$$0.unref(DkTable).table.showComSearch = !require$$0.unref(DkTable).table.showComSearch)
30307
30390
  }, {
30308
30391
  default: require$$0.withCtx(() => [
30309
30392
  require$$0.createVNode(_component_dk_icon, { icon: "Search" })
@@ -31185,25 +31268,22 @@
31185
31268
  [
31186
31269
  require$$0.createElementVNode("div", _hoisted_1$8, [
31187
31270
  require$$0.createCommentVNode("\u9876\u90E8\u83DC\u5355"),
31188
- require$$0.createVNode(
31189
- DkTableHeader,
31190
- { size: "default" },
31191
- require$$0.createSlots({
31192
- _: 2
31193
- /* DYNAMIC */
31194
- }, [
31195
- require$$0.renderList(_ctx.$slots, (slot, idx) => {
31196
- return {
31197
- name: idx,
31198
- fn: require$$0.withCtx(() => [
31199
- require$$0.renderSlot(_ctx.$slots, idx)
31200
- ])
31201
- };
31202
- })
31203
- ]),
31204
- 1024
31205
- /* DYNAMIC_SLOTS */
31206
- ),
31271
+ require$$0.createVNode(DkTableHeader, {
31272
+ size: "default",
31273
+ buttons: _ctx.buttons
31274
+ }, require$$0.createSlots({
31275
+ _: 2
31276
+ /* DYNAMIC */
31277
+ }, [
31278
+ require$$0.renderList(_ctx.$slots, (slot, idx) => {
31279
+ return {
31280
+ name: idx,
31281
+ fn: require$$0.withCtx(() => [
31282
+ require$$0.renderSlot(_ctx.$slots, idx)
31283
+ ])
31284
+ };
31285
+ })
31286
+ ]), 1032, ["buttons"]),
31207
31287
  require$$0.createCommentVNode("\u8868\u683C"),
31208
31288
  require$$0.withDirectives((require$$0.openBlock(), require$$0.createBlock(_component_el_table, require$$0.mergeProps({
31209
31289
  ref_key: "TableRef",