@dt-frames/ui 2.0.17 → 2.0.19

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.
Files changed (35) hide show
  1. package/es/components/drawer/index.d.ts +3 -4
  2. package/es/components/drawer/index.js +11 -15
  3. package/es/components/drawer/index.less +6 -0
  4. package/es/components/drawer/src/index.d.ts +5 -7
  5. package/es/components/drawer/src/types/index.type.d.ts +3 -1
  6. package/es/components/form/index.js +62 -65
  7. package/es/components/form/src/components/FormButtons.d.ts +3056 -4
  8. package/es/components/form/src/components/FormItem.d.ts +3 -4
  9. package/es/components/form/src/components/formIcon.d.ts +0 -1209
  10. package/es/components/form/src/components/formInputUseDialog.d.ts +0 -894
  11. package/es/components/form/src/props.d.ts +8 -8
  12. package/es/components/form/src/types/form.type.d.ts +1 -0
  13. package/es/components/form/src/types/items.type.d.ts +8 -0
  14. package/es/components/modal/index.js +19 -7
  15. package/es/components/modal/index.less +1 -9
  16. package/es/components/source/index.js +20 -10
  17. package/es/components/table/index.js +262 -150
  18. package/es/components/table/index.less +5 -1
  19. package/es/components/table/src/types/table.type.d.ts +1 -0
  20. package/es/components/tree/index.js +59 -57
  21. package/es/components/tree/index.less +6 -0
  22. package/es/components/tree/src/type/tree.d.ts +0 -4
  23. package/es/components/tree/src/utils/tree.d.ts +3 -1
  24. package/es/components/upload/index.js +103 -41
  25. package/es/components/upload/src/basicProps.d.ts +5 -1
  26. package/es/components/upload/src/hooks/useFile.d.ts +7 -6
  27. package/es/components/upload/src/index.d.ts +16 -0
  28. package/es/components/upload/src/type/file.d.ts +9 -2
  29. package/es/components/upload/src/utils/fileSize.d.ts +1 -0
  30. package/es/theme/index.js +149 -97
  31. package/es/theme/index.less +14 -0
  32. package/es/theme/src/components/sider/index.d.ts +1 -1
  33. package/es/theme/src/components/sider/mix-sider.d.ts +1 -1
  34. package/es/theme/src/index.d.ts +1 -1
  35. package/package.json +1 -1
@@ -130,8 +130,12 @@
130
130
  }
131
131
  }
132
132
 
133
- .primary-color{
133
+ .primary-color-link{
134
134
  color: @primary-color;
135
+ cursor: pointer;
136
+ &:hover{
137
+ text-decoration: underline;
138
+ }
135
139
  }
136
140
  }
137
141
 
@@ -55,6 +55,7 @@ export interface BasicColumn extends ColumnProps<Recordable> {
55
55
  export declare type ButtonType = {
56
56
  t?: string;
57
57
  label?: string | ((row: Recordable) => string);
58
+ enLabel?: string | ((row: Recordable) => string);
58
59
  icon?: string | ((row: Recordable) => string);
59
60
  auth?: string;
60
61
  color?: string;
@@ -3,8 +3,8 @@ import "ant-design-vue/es/spin/style";
3
3
  import "ant-design-vue/es/empty/style";
4
4
  import "ant-design-vue/es/tree/style";
5
5
  import { unref, defineComponent, useSlots, ref, computed, watch, openBlock, createElementBlock, toDisplayString, createCommentVNode, renderSlot, createVNode, createBlock, withModifiers, withCtx, Fragment, renderList, normalizeProps, guardReactiveProps, createTextVNode, createElementVNode, onMounted, nextTick, onUnmounted, isVNode, getCurrentInstance, render as render$2, useAttrs, reactive, toRaw, watchEffect, normalizeClass, createSlots, withDirectives, mergeProps, vShow } from "vue";
6
- import { useI18n, useSlots as useSlots$1, isEmpty, isBoolean, isArray, isFunction } from "@dt-frames/core";
7
- import { cloneDeep, get, difference, omit } from "lodash-es";
6
+ import { useI18n, useSlots as useSlots$1, isArray, isFunction, isEmpty, isBoolean } from "@dt-frames/core";
7
+ import { cloneDeep, difference, omit, get } from "lodash-es";
8
8
  import "ant-design-vue/es/dropdown/style";
9
9
  import "ant-design-vue/es/menu/style";
10
10
  import "ant-design-vue/es/input/style";
@@ -200,7 +200,7 @@ function eachTree(treeDatas, callBack, parentNode = {}, config = { children: "ch
200
200
  treeDatas.forEach((el) => {
201
201
  const newNode = callBack(el, parentNode) || el;
202
202
  if (el[config.children]) {
203
- eachTree(el[config.children], callBack, newNode);
203
+ eachTree(el[config.children], callBack, newNode, config);
204
204
  }
205
205
  });
206
206
  }
@@ -241,8 +241,8 @@ function useTree(treeDataRef, getFieldNames, emit) {
241
241
  const { key: keyField, children: childrenField } = unref(getFieldNames);
242
242
  if (!childrenField || !keyField)
243
243
  return keys;
244
- for (let index2 = 0; index2 < treeData.length; index2++) {
245
- const node = treeData[index2];
244
+ for (let index = 0; index < treeData.length; index++) {
245
+ const node = treeData[index];
246
246
  keys.push(node[keyField]);
247
247
  const children = node[childrenField];
248
248
  if (children && children.length) {
@@ -257,8 +257,8 @@ function useTree(treeDataRef, getFieldNames, emit) {
257
257
  const { key: keyField, children: childrenField } = unref(getFieldNames);
258
258
  if (!childrenField || !keyField)
259
259
  return keys;
260
- for (let index2 = 0; index2 < treeData.length; index2++) {
261
- const node = treeData[index2];
260
+ for (let index = 0; index < treeData.length; index++) {
261
+ const node = treeData[index];
262
262
  node.disabled !== true && node.selectable !== false && keys.push(node[keyField]);
263
263
  const children = node[childrenField];
264
264
  if (children && children.length) {
@@ -273,8 +273,8 @@ function useTree(treeDataRef, getFieldNames, emit) {
273
273
  const { key: keyField, children: childrenField } = unref(getFieldNames);
274
274
  if (!childrenField || !keyField)
275
275
  return keys;
276
- for (let index2 = 0; index2 < treeData.length; index2++) {
277
- const node = treeData[index2];
276
+ for (let index = 0; index < treeData.length; index++) {
277
+ const node = treeData[index];
278
278
  const children = node[childrenField];
279
279
  if (nodeKey === node[keyField]) {
280
280
  keys.push(node[keyField]);
@@ -296,11 +296,11 @@ function useTree(treeDataRef, getFieldNames, emit) {
296
296
  const { key: keyField, children: childrenField } = unref(getFieldNames);
297
297
  if (!childrenField || !keyField)
298
298
  return;
299
- for (let index2 = 0; index2 < treeData.length; index2++) {
300
- const element = treeData[index2];
299
+ for (let index = 0; index < treeData.length; index++) {
300
+ const element = treeData[index];
301
301
  const children = element[childrenField];
302
302
  if (element[keyField] === key) {
303
- treeData[index2] = { ...treeData[index2], ...node };
303
+ treeData[index] = { ...treeData[index], ...node };
304
304
  break;
305
305
  } else if (children && children.length) {
306
306
  updateNodeByKey(key, node, element[childrenField]);
@@ -312,9 +312,10 @@ function useTree(treeDataRef, getFieldNames, emit) {
312
312
  return [];
313
313
  const res = [];
314
314
  const data = list || unref(treeDataRef) || [];
315
- for (let index2 = 0; index2 < data.length; index2++) {
316
- const item = data[index2];
315
+ for (let index = 0; index < data.length; index++) {
316
+ const item = data[index];
317
317
  const { key: keyField, children: childrenField } = unref(getFieldNames);
318
+ console.log(keyField, childrenField);
318
319
  const key = keyField ? item[keyField] : "";
319
320
  const children = childrenField ? item[childrenField] : [];
320
321
  res.push(key);
@@ -375,11 +376,11 @@ function useTree(treeDataRef, getFieldNames, emit) {
375
376
  const { key: keyField, children: childrenField } = unref(getFieldNames);
376
377
  if (!childrenField || !keyField)
377
378
  return;
378
- for (let index2 = 0; index2 < treeData.length; index2++) {
379
- const element = treeData[index2];
379
+ for (let index = 0; index < treeData.length; index++) {
380
+ const element = treeData[index];
380
381
  const children = element[childrenField];
381
382
  if (element[keyField] === key) {
382
- treeData.splice(index2, 1);
383
+ treeData.splice(index, 1);
383
384
  break;
384
385
  } else if (children && children.length) {
385
386
  deleteNodeByKey(key, element[childrenField]);
@@ -411,17 +412,17 @@ function useTree(treeDataRef, getFieldNames, emit) {
411
412
  const dropPosition = info.dropPosition - Number(dropPos[dropPos.length - 1]);
412
413
  const { children: childrenField } = unref(getFieldNames);
413
414
  const loop = (data2, key, callback) => {
414
- data2.forEach((item, index2) => {
415
+ data2.forEach((item, index) => {
415
416
  if (item.key === key)
416
- return callback(item, index2, data2);
417
+ return callback(item, index, data2);
417
418
  if (item[childrenField])
418
419
  return loop(item[childrenField], key, callback);
419
420
  });
420
421
  };
421
422
  const data = [...treeDataRef.value];
422
423
  let dragObj;
423
- loop(data, dragKey, (item, index2, arr) => {
424
- arr.splice(index2, 1);
424
+ loop(data, dragKey, (item, index, arr) => {
425
+ arr.splice(index, 1);
425
426
  dragObj = item;
426
427
  });
427
428
  if (!info.dropToGap) {
@@ -437,9 +438,9 @@ function useTree(treeDataRef, getFieldNames, emit) {
437
438
  } else {
438
439
  let ar = [];
439
440
  let i = 0;
440
- loop(data, dropKey, (_item, index2, arr) => {
441
+ loop(data, dropKey, (_item, index, arr) => {
441
442
  ar = arr;
442
- i = index2;
443
+ i = index;
443
444
  });
444
445
  dropPosition === -1 ? ar.splice(i, 0, dragObj) : ar.splice(i + 1, 0, dragObj);
445
446
  }
@@ -544,10 +545,10 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
544
545
  const _component_AMenu = Menu;
545
546
  const _component_ADropdown = Dropdown;
546
547
  return openBlock(), createElementBlock("div", _hoisted_1$2, [
547
- _ctx.title ? (openBlock(), createElementBlock("h4", _hoisted_2$2, toDisplayString(_ctx.title), 1)) : createCommentVNode("v-if", true),
548
+ _ctx.title ? (openBlock(), createElementBlock("h4", _hoisted_2$2, toDisplayString(_ctx.title), 1)) : createCommentVNode("", true),
548
549
  _ctx.search || _ctx.toolbar ? (openBlock(), createElementBlock("div", _hoisted_3$2, [
549
550
  _ctx.search ? (openBlock(), createElementBlock("div", _hoisted_4, [
550
- unref(slots).addonBefore ? renderSlot(_ctx.$slots, "addonBefore", { key: 0 }) : createCommentVNode("v-if", true),
551
+ unref(slots).addonBefore ? renderSlot(_ctx.$slots, "addonBefore", { key: 0 }) : createCommentVNode("", true),
551
552
  createVNode(_component_AInput, {
552
553
  size: "small",
553
554
  allowClear: "",
@@ -555,8 +556,8 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
555
556
  "onUpdate:value": _cache[0] || (_cache[0] = ($event) => searchValue.value = $event),
556
557
  placeholder: unref(t)("FILTER")
557
558
  }, null, 8, ["value", "placeholder"]),
558
- unref(slots).addonAfter ? renderSlot(_ctx.$slots, "addonAfter", { key: 1 }) : createCommentVNode("v-if", true)
559
- ])) : createCommentVNode("v-if", true),
559
+ unref(slots).addonAfter ? renderSlot(_ctx.$slots, "addonAfter", { key: 1 }) : createCommentVNode("", true)
560
+ ])) : createCommentVNode("", true),
560
561
  _ctx.toolbar ? (openBlock(), createBlock(_component_ADropdown, {
561
562
  key: 1,
562
563
  onClick: _cache[1] || (_cache[1] = withModifiers(() => {
@@ -575,7 +576,7 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
575
576
  ]),
576
577
  _: 2
577
578
  }, 1040),
578
- item.divider ? (openBlock(), createBlock(_component_AMenuDivider, { key: 0 })) : createCommentVNode("v-if", true)
579
+ item.divider ? (openBlock(), createBlock(_component_AMenuDivider, { key: 0 })) : createCommentVNode("", true)
579
580
  ], 64);
580
581
  }), 128))
581
582
  ]),
@@ -586,20 +587,12 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
586
587
  _hoisted_5
587
588
  ]),
588
589
  _: 1
589
- })) : createCommentVNode("v-if", true)
590
- ])) : createCommentVNode("v-if", true)
590
+ })) : createCommentVNode("", true)
591
+ ])) : createCommentVNode("", true)
591
592
  ]);
592
593
  };
593
594
  }
594
595
  });
595
- const _export_sfc = (sfc, props) => {
596
- const target = sfc.__vccOpts || sfc;
597
- for (const [key, val] of props) {
598
- target[key] = val;
599
- }
600
- return target;
601
- };
602
- const TreeHeader = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__file", "D:/dt/dt-frame-front/dt-frames/frames/packages/ui/src/components/tree/src/components/TreeHeader.vue"]]);
603
596
  function _isSlot(s) {
604
597
  return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
605
598
  }
@@ -722,7 +715,6 @@ const _sfc_main$1 = defineComponent({
722
715
  };
723
716
  }
724
717
  });
725
- const contextMenuVue = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__file", "D:/dt/dt-frame-front/dt-frames/frames/packages/ui/src/components/tree/src/components/ContextMenu.vue"]]);
726
718
  function useContextMenu() {
727
719
  const menuManager = {
728
720
  domList: [],
@@ -746,7 +738,7 @@ function useContextMenu() {
746
738
  propsData.customEvent = event;
747
739
  propsData.axis = { x: event.clientX, y: event.clientY };
748
740
  }
749
- const vm = createVNode(contextMenuVue, propsData);
741
+ const vm = createVNode(_sfc_main$1, propsData);
750
742
  render$2(vm, container);
751
743
  const handleClick = function() {
752
744
  menuManager.resolve("");
@@ -881,16 +873,16 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
881
873
  };
882
874
  const treeData = computed(() => {
883
875
  const data = cloneDeep(getTreeData.value);
876
+ const {
877
+ title: titleField,
878
+ key: keyField,
879
+ children: childrenField
880
+ } = unref(getFieldNames);
884
881
  eachTree(data, (item, _parent) => {
885
882
  const searchText = searchState.searchText;
886
883
  const {
887
884
  highlight
888
885
  } = unref(props);
889
- const {
890
- title: titleField,
891
- key: keyField,
892
- children: childrenField
893
- } = unref(getFieldNames);
894
886
  const icon = getIcon(item, item.icon);
895
887
  const title = get(item, titleField);
896
888
  const searchIdx = searchText ? title.indexOf(searchText) : -1;
@@ -903,13 +895,15 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
903
895
  }, [searchText]), createVNode("span", null, [title.substr(searchIdx + searchText.length)])]) : title;
904
896
  item._title = item[titleField];
905
897
  item[titleField] = createVNode("span", {
906
- "class": `tree-title ${unref(activeKey) === item[keyField] ? "tree-active-node" : ""}`,
898
+ "class": `tree-title ${unref(activeKey) === item[keyField] ? "tree-active-node" : ""}`
899
+ }, [slots?.title ? getSlot(slots, "title", item) : createVNode(Fragment, null, [createVNode("span", {
900
+ "class": "flex items-center flex-1",
907
901
  "onClick": handleClickNode.bind(null, item[keyField], item[childrenField], item)
908
- }, [slots?.title ? getSlot(slots, "title", item) : createVNode(Fragment, null, [unref(getBindValues).showIcon && icon, titleDom, createVNode("span", {
902
+ }, [unref(getBindValues).showIcon && icon, titleDom]), createVNode("span", {
909
903
  "class": "tree-action"
910
904
  }, [renderAction(item)])])]);
911
905
  }, {}, {
912
- children: unref(getFieldNames).children
906
+ children: childrenField
913
907
  });
914
908
  return data;
915
909
  });
@@ -969,9 +963,9 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
969
963
  setExpandedKeys([...state.expandedKeys, key]);
970
964
  } else {
971
965
  const keys = [...state.expandedKeys];
972
- const index2 = keys.findIndex((item) => item === key);
973
- if (index2 !== -1) {
974
- keys.splice(index2, 1);
966
+ const index = keys.findIndex((item) => item === key);
967
+ if (index !== -1) {
968
+ keys.splice(index, 1);
975
969
  }
976
970
  setExpandedKeys(keys);
977
971
  }
@@ -1142,6 +1136,9 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
1142
1136
  emit("update:value", v);
1143
1137
  emit("change", v);
1144
1138
  });
1139
+ watchEffect(() => {
1140
+ activeKey.value = props.activeKey;
1141
+ });
1145
1142
  watchEffect(() => {
1146
1143
  treeDataRef.value = props.treeData;
1147
1144
  });
@@ -1164,7 +1161,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
1164
1161
  const _component_ASpin = Spin;
1165
1162
  return openBlock(), createElementBlock("div", {
1166
1163
  class: normalizeClass(["dt-tree h-full flex flex-col", `dt-tree-${unref(getUiSize)}`])
1167
- }, [unref(showTitle) ? (openBlock(), createBlock(TreeHeader, {
1164
+ }, [unref(showTitle) ? (openBlock(), createBlock(_sfc_main$2, {
1168
1165
  key: 0,
1169
1166
  title: _ctx.title,
1170
1167
  toolbar: _ctx.toolbar,
@@ -1181,7 +1178,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
1181
1178
  name: item,
1182
1179
  fn: withCtx(() => [renderSlot(_ctx.$slots, item)])
1183
1180
  };
1184
- })]), 1032, ["title", "toolbar", "search", "checkable", "searchText"])) : createCommentVNode("v-if", true), createVNode(_component_ASpin, {
1181
+ })]), 1032, ["title", "toolbar", "search", "checkable", "searchText"])) : createCommentVNode("", true), createVNode(_component_ASpin, {
1185
1182
  spinning: _ctx.loading,
1186
1183
  tip: unref(t)("LOADING")
1187
1184
  }, {
@@ -1189,13 +1186,18 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
1189
1186
  showIcon: false,
1190
1187
  treeData: unref(treeData),
1191
1188
  onDrop: unref(onDrop)
1192
- }), null, 16, ["treeData", "onDrop"])], 512), [[vShow, !unref(getNotFound)]]), withDirectives(createVNode(_component_AEmpty, null, null, 512), [[vShow, unref(getNotFound)]])]),
1193
- _: 1
1189
+ }), createSlots({
1190
+ _: 2
1191
+ }, [_ctx.$slots.switcherIcon ? {
1192
+ name: "switcherIcon",
1193
+ fn: withCtx((data) => [renderSlot(_ctx.$slots, "switcherIcon", normalizeProps(guardReactiveProps(data || {})))]),
1194
+ key: "0"
1195
+ } : void 0]), 1040, ["treeData", "onDrop"])], 512), [[vShow, !unref(getNotFound)]]), withDirectives(createVNode(_component_AEmpty, null, null, 512), [[vShow, unref(getNotFound)]])]),
1196
+ _: 3
1194
1197
  }, 8, ["spinning", "tip"])], 2);
1195
1198
  };
1196
1199
  }
1197
1200
  });
1198
- const index = /* @__PURE__ */ _export_sfc(_sfc_main, [["__file", "D:/dt/dt-frame-front/dt-frames/frames/packages/ui/src/components/tree/src/index.vue"]]);
1199
1201
  export {
1200
- index as DtTree
1202
+ _sfc_main as DtTree
1201
1203
  };
@@ -22,6 +22,12 @@
22
22
  overflow-y: auto;
23
23
  padding: 10px 0;
24
24
 
25
+ .ant-tree-switcher{
26
+ display: flex;
27
+ align-items: center;
28
+ justify-content: center;
29
+ }
30
+
25
31
  .ant-tree-treenode{
26
32
  padding: 0;
27
33
  align-items: center;
@@ -1,4 +1,3 @@
1
- import { Recordable } from "@dt-frames/core";
2
1
  import { TreeDataItem } from "ant-design-vue/lib/tree/Tree";
3
2
  export declare type KeyType = string | number;
4
3
  export declare type CheckKeys = KeyType[] | {
@@ -10,9 +9,6 @@ export interface FieldNames {
10
9
  title?: string;
11
10
  key?: string;
12
11
  }
13
- export interface TreeActionItem {
14
- render: (record: Recordable) => any;
15
- }
16
12
  export interface TreeItem extends TreeDataItem {
17
13
  icon?: any;
18
14
  }
@@ -1,5 +1,7 @@
1
1
  import { TreeHelperConfig } from "../type/tree";
2
- export declare function eachTree(treeDatas: any[], callBack: Function, parentNode?: {}): void;
2
+ export declare function eachTree(treeDatas: any[], callBack: Function, parentNode?: {}, config?: {
3
+ children: string;
4
+ }): void;
3
5
  export declare function forEach<T = any>(tree: T[], func: (n: T) => any, config?: Partial<TreeHelperConfig>): void;
4
6
  export declare function filter<T = any>(tree: T[], func: (n: T) => boolean, config?: Partial<TreeHelperConfig>): T[];
5
7
  export declare function treeToList<T = any>(tree: any, config?: Partial<TreeHelperConfig>): T;
@@ -2,9 +2,9 @@ import { Button, Upload, Image } from "ant-design-vue/es";
2
2
  import "ant-design-vue/es/image/style";
3
3
  import "ant-design-vue/es/upload/style";
4
4
  import "ant-design-vue/es/button/style";
5
- import { computed, unref, ref, watch, defineComponent, openBlock, createBlock, withCtx, createVNode, createElementVNode, toRefs, createElementBlock, mergeProps, isRef, createSlots, normalizeClass, toDisplayString, createCommentVNode, normalizeStyle, Fragment, renderList, renderSlot, normalizeProps, guardReactiveProps } from "vue";
5
+ import { computed, unref, ref, watch, defineComponent, openBlock, createBlock, withCtx, createVNode, createElementVNode, toRefs, createElementBlock, mergeProps, isRef, createSlots, normalizeClass, createTextVNode, toDisplayString, createCommentVNode, normalizeStyle, Fragment, renderList, renderSlot, normalizeProps, guardReactiveProps } from "vue";
6
6
  import { takeRight, omit } from "lodash-es";
7
- import { useAppStore, useMessage, isString, dispatchResize, isFunction, http, HttpContentTypeEnum } from "@dt-frames/core";
7
+ import { isString, useAppStore, useMessage, dispatchResize, isFunction, http, HttpContentTypeEnum } from "@dt-frames/core";
8
8
  import { useModal, DtModal, useModalOut } from "../modal";
9
9
  import { DtIframe } from "../iframe";
10
10
  const basicProps = {
@@ -26,6 +26,10 @@ const basicProps = {
26
26
  type: Object,
27
27
  default: {}
28
28
  },
29
+ fieldNames: {
30
+ type: Object,
31
+ default: {}
32
+ },
29
33
  fileName: {
30
34
  type: String,
31
35
  default: "file"
@@ -77,6 +81,10 @@ const basicProps = {
77
81
  type: Object,
78
82
  default: () => ({})
79
83
  },
84
+ emitSnippet: {
85
+ type: Boolean,
86
+ default: false
87
+ },
80
88
  showView: {
81
89
  type: Boolean,
82
90
  default: true
@@ -90,12 +98,28 @@ const basicProps = {
90
98
  default: true
91
99
  }
92
100
  };
101
+ function getFileSize(size) {
102
+ if (!size)
103
+ return "\u672A\u77E5\u5927\u5C0F";
104
+ if (isString(size))
105
+ return size;
106
+ if (size >= 1073741824) {
107
+ return size % 1073741824 === 0 ? size / 1073741824 + "G" : Math.trunc(size / 1073741824) + "G";
108
+ } else if (size >= 1048576) {
109
+ return size % 1048576 === 0 ? size / 1048576 + "MB" : Math.trunc(size / 1048576) + "MB";
110
+ } else if (size >= 1024) {
111
+ return size % 1024 === 0 ? size / 1024 + "KB" : Math.trunc(size / 1024) + "KB";
112
+ } else {
113
+ return size + "B";
114
+ }
115
+ }
93
116
  function useFile({
94
117
  fileListRef = ref([]),
95
118
  acceptRef,
96
119
  helpTextRef,
97
120
  maxCountRef,
98
- maxSizeRef
121
+ maxSizeRef,
122
+ fieldNamesRef
99
123
  }) {
100
124
  const { getAppConf } = useAppStore();
101
125
  const { message } = useMessage();
@@ -134,13 +158,17 @@ function useFile({
134
158
  });
135
159
  const setFile = (file) => {
136
160
  let _downloadUrl = getAppConf.pages?.downloadUrl;
161
+ const { fileName, fileType, fileId, filePath, fileSize } = unref(fieldNamesRef);
162
+ const url = file[filePath] || `${getAppConf.http?.baseUrl}${isString(_downloadUrl) ? _downloadUrl : _downloadUrl.api}?id=${file[fileId]}`;
137
163
  return {
138
164
  ...file,
139
- name: file.fileName ?? file.fileId,
140
- fileType: file.fileName ? takeRight(file.fileName.split("."))[0] : null,
165
+ name: file[fileName],
166
+ fileType: file[fileType] || takeRight(file[fileName].split("."))[0],
141
167
  status: "done",
142
- uid: file.id ?? file.fileId,
143
- url: `${getAppConf.http?.baseUrl}${isString(_downloadUrl) ? _downloadUrl : _downloadUrl.api}?id=${file.fileId}`
168
+ fileSize: getFileSize(file[fileSize]),
169
+ uid: file[fileId],
170
+ url,
171
+ filePath: url
144
172
  };
145
173
  };
146
174
  const fileList = ref(unref(fileListRef).map((it) => setFile(it)));
@@ -312,20 +340,21 @@ const _hoisted_2 = { class: "pl-3" };
312
340
  const _hoisted_3 = { class: "flex items-center flex-1" };
313
341
  const _hoisted_4 = ["src"];
314
342
  const _hoisted_5 = { class: "flex-1 pr-4" };
315
- const _hoisted_6 = {
343
+ const _hoisted_6 = { class: "not-italic text-12 text-gray-400 ml-1" };
344
+ const _hoisted_7 = {
316
345
  key: 0,
317
346
  class: "ant-progress ant-progress-line ant-progress-default ant-progress-status-normal"
318
347
  };
319
- const _hoisted_7 = { class: "ant-progress-outer" };
320
- const _hoisted_8 = { class: "ant-progress-inner" };
321
- const _hoisted_9 = { class: "flex items-center" };
322
- const _hoisted_10 = ["onClick"];
323
- const _hoisted_11 = { key: 0 };
324
- const _hoisted_12 = /* @__PURE__ */ createElementVNode("i", { class: "i ic:baseline-file-upload" }, null, -1);
325
- const _hoisted_13 = /* @__PURE__ */ createElementVNode("div", null, "\u6587\u4EF6\u4E0A\u4F20", -1);
326
- const _hoisted_14 = [
327
- _hoisted_12,
328
- _hoisted_13
348
+ const _hoisted_8 = { class: "ant-progress-outer" };
349
+ const _hoisted_9 = { class: "ant-progress-inner" };
350
+ const _hoisted_10 = { class: "flex items-center" };
351
+ const _hoisted_11 = ["onClick"];
352
+ const _hoisted_12 = { key: 0 };
353
+ const _hoisted_13 = /* @__PURE__ */ createElementVNode("i", { class: "i ic:baseline-file-upload" }, null, -1);
354
+ const _hoisted_14 = /* @__PURE__ */ createElementVNode("div", null, "\u6587\u4EF6\u4E0A\u4F20", -1);
355
+ const _hoisted_15 = [
356
+ _hoisted_13,
357
+ _hoisted_14
329
358
  ];
330
359
  const _sfc_main = /* @__PURE__ */ defineComponent({
331
360
  __name: "index",
@@ -343,6 +372,18 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
343
372
  maxCount: maxCountRef,
344
373
  maxSize: maxSizeRef
345
374
  } = toRefs(props);
375
+ const fieldNamesRef = computed(() => {
376
+ return {
377
+ ...{
378
+ fileId: "id",
379
+ fileName: "fileName",
380
+ filePath: "fileUrl",
381
+ fileSize: "fileSize",
382
+ fileType: "extendName"
383
+ },
384
+ ...unref(props.fieldNames)
385
+ };
386
+ });
346
387
  const {
347
388
  getStringAccept,
348
389
  getHelpText,
@@ -353,7 +394,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
353
394
  acceptRef,
354
395
  helpTextRef,
355
396
  maxCountRef,
356
- maxSizeRef
397
+ maxSizeRef,
398
+ fieldNamesRef
357
399
  });
358
400
  const btns = [
359
401
  {
@@ -400,7 +442,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
400
442
  };
401
443
  });
402
444
  const handlePreview = async (file) => {
403
- imgSrcRef.value = file.url;
445
+ imgSrcRef.value = file.filePath;
404
446
  imgVisable.value = true;
405
447
  };
406
448
  const uploadFile = async ({ file, onSuccess, onError, onProgress }) => {
@@ -429,12 +471,29 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
429
471
  [fileName || "file"]: file
430
472
  }
431
473
  );
432
- Object.assign(file, {
433
- fileId: result?.data?.fileId,
434
- url: `${getAppConf.http?.baseUrl}${_downloadUrl}?id=${result?.data?.fileId}`,
435
- fileName: result?.data?.fileName,
436
- fileType: takeRight(result?.data?.fileName?.split("."))?.[0]
437
- });
474
+ let field = {}, fieldNames = unref(fieldNamesRef);
475
+ for (let key in fieldNames) {
476
+ let val = fieldNames[key];
477
+ if (key === "filePath") {
478
+ field[key] = result?.data?.[val] ?? `${getAppConf.http?.baseUrl}${_downloadUrl}?id=${result?.data?.fileId}`;
479
+ field["url"] = field["thumbUrl"] = field[key];
480
+ continue;
481
+ }
482
+ if (key === "fileType") {
483
+ field[key] = result?.data?.[val] ?? takeRight(file.name?.split("."))?.[0];
484
+ continue;
485
+ }
486
+ if (key === "fileSize") {
487
+ field[key] = getFileSize(file.size);
488
+ continue;
489
+ }
490
+ if (key === "fileName") {
491
+ field[key] = file.name;
492
+ continue;
493
+ }
494
+ field[key] = result?.data?.[val] ?? null;
495
+ }
496
+ Object.assign(file, field);
438
497
  onSuccess(result);
439
498
  } catch (err) {
440
499
  onError(err);
@@ -447,7 +506,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
447
506
  let _downloadUrl = isString(downloadUrl) ? downloadUrl : downloadUrl.api;
448
507
  let _downloadType = isString(downloadUrl) ? "get" : downloadUrl.type;
449
508
  if (["jpg", "jpeg", "png", "bmp", "gif"].includes(file.fileType)) {
450
- imgSrcRef.value = `${getAppConf.http?.baseUrl}${_downloadUrl}?id=${file.fileId}`;
509
+ imgSrcRef.value = file.filePath ?? `${getAppConf.http?.baseUrl}${_downloadUrl}?id=${file.fileId}`;
451
510
  imgVisable.value = true;
452
511
  return;
453
512
  }
@@ -485,13 +544,13 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
485
544
  watch(
486
545
  () => unref(fileList),
487
546
  async (v) => {
488
- let ids = unref(fileList).map((it) => it.fileId);
489
- if (ids.length === v.length)
490
- emits("change", ids.join(","));
491
- },
492
- {
493
- deep: true,
494
- immediate: true
547
+ let ids = [];
548
+ unref(fileList).forEach((it) => {
549
+ ids.push(it.fileId);
550
+ });
551
+ if (props.emitSnippet || !props.emitSnippet && !ids.includes(void 0)) {
552
+ emits("change", ids.join(","), unref(fileList));
553
+ }
495
554
  }
496
555
  );
497
556
  return (_ctx, _cache) => {
@@ -513,11 +572,14 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
513
572
  class: "w-9 h-9 mr-2 p-1"
514
573
  }, null, 8, _hoisted_4),
515
574
  createElementVNode("div", _hoisted_5, [
516
- createElementVNode("span", null, toDisplayString(file.fileName || file.name), 1),
575
+ createElementVNode("span", null, [
576
+ createTextVNode(toDisplayString(file.fileName || file.name) + " ", 1),
577
+ createElementVNode("i", _hoisted_6, "(" + toDisplayString(file.fileSize) + ")", 1)
578
+ ]),
517
579
  createCommentVNode(" \u8BBE\u7F6E\u8FDB\u5EA6 "),
518
- file.percent < 100 && file.percent > 0 ? (openBlock(), createElementBlock("div", _hoisted_6, [
519
- createElementVNode("div", _hoisted_7, [
520
- createElementVNode("div", _hoisted_8, [
580
+ file.percent < 100 && file.percent > 0 ? (openBlock(), createElementBlock("div", _hoisted_7, [
581
+ createElementVNode("div", _hoisted_8, [
582
+ createElementVNode("div", _hoisted_9, [
521
583
  createElementVNode("div", {
522
584
  class: "ant-progress-bg",
523
585
  style: normalizeStyle({
@@ -530,7 +592,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
530
592
  ])) : createCommentVNode("v-if", true)
531
593
  ])
532
594
  ]),
533
- createElementVNode("div", _hoisted_9, [
595
+ createElementVNode("div", _hoisted_10, [
534
596
  (openBlock(), createElementBlock(Fragment, null, renderList(btns, (btn) => {
535
597
  return openBlock(), createElementBlock(Fragment, {
536
598
  key: btn.class
@@ -539,7 +601,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
539
601
  key: 0,
540
602
  class: normalizeClass(["i w-7 h-7 !text-base text-center leading-7 text-gray-600 cursor-pointer hover:bg-gray-200 hover:bg-opacity-50 transition-all duration-300", btn.class]),
541
603
  onClick: ($event) => btn.click(file)
542
- }, null, 10, _hoisted_10)) : createCommentVNode("v-if", true)
604
+ }, null, 10, _hoisted_11)) : createCommentVNode("v-if", true)
543
605
  ], 64);
544
606
  }), 64))
545
607
  ])
@@ -578,7 +640,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
578
640
  onPreview: handlePreview
579
641
  }), {
580
642
  default: withCtx(() => [
581
- !unref(getBind).disabled && (!_ctx.maxCount || !unref(fileList).length || unref(fileList).length < _ctx.maxCount) ? (openBlock(), createElementBlock("div", _hoisted_11, _hoisted_14)) : createCommentVNode("v-if", true)
643
+ !unref(getBind).disabled && (!_ctx.maxCount || !unref(fileList).length || unref(fileList).length < _ctx.maxCount) ? (openBlock(), createElementBlock("div", _hoisted_12, _hoisted_15)) : createCommentVNode("v-if", true)
582
644
  ]),
583
645
  _: 1
584
646
  }, 16, ["fileList"])) : createCommentVNode("v-if", true),
@@ -1,5 +1,5 @@
1
1
  import { PropType, Ref, ComputedRef } from "vue";
2
- import { UploadFile } from "./type/file";
2
+ import { FieldNames, UploadFile } from "./type/file";
3
3
  import { UploadRequestOption } from "ant-design-vue/es/vc-upload/interface";
4
4
  import { ApiType, Recordable } from "@dt-frames/core";
5
5
  export declare const basicProps: {
@@ -21,6 +21,10 @@ export declare const basicProps: {
21
21
  type: PropType<object | ((file: UploadFile) => object)>;
22
22
  default: {};
23
23
  };
24
+ fieldNames: {
25
+ type: PropType<FieldNames>;
26
+ default: {};
27
+ };
24
28
  fileName: {
25
29
  type: StringConstructor;
26
30
  default: string;