@dt-frames/ui 2.0.17 → 2.0.18
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/es/components/drawer/index.d.ts +3 -4
- package/es/components/drawer/index.js +11 -15
- package/es/components/drawer/index.less +6 -0
- package/es/components/drawer/src/index.d.ts +5 -7
- package/es/components/drawer/src/types/index.type.d.ts +3 -1
- package/es/components/form/index.js +8 -4
- package/es/components/form/src/components/FormButtons.d.ts +3056 -4
- package/es/components/form/src/components/FormItem.d.ts +2 -2
- package/es/components/form/src/components/formIcon.d.ts +0 -1209
- package/es/components/form/src/components/formInputUseDialog.d.ts +0 -894
- package/es/components/form/src/props.d.ts +3 -3
- package/es/components/form/src/types/items.type.d.ts +8 -0
- package/es/components/modal/index.js +19 -7
- package/es/components/modal/index.less +1 -9
- package/es/components/source/index.js +15 -7
- package/es/components/table/index.js +156 -74
- package/es/components/table/index.less +5 -1
- package/es/components/tree/index.js +47 -55
- package/es/components/tree/src/type/tree.d.ts +0 -4
- package/es/components/tree/src/utils/tree.d.ts +3 -1
- package/es/components/upload/index.js +103 -41
- package/es/components/upload/src/basicProps.d.ts +5 -1
- package/es/components/upload/src/hooks/useFile.d.ts +7 -6
- package/es/components/upload/src/index.d.ts +16 -0
- package/es/components/upload/src/type/file.d.ts +9 -2
- package/es/components/upload/src/utils/fileSize.d.ts +1 -0
- package/es/theme/index.js +149 -97
- package/es/theme/index.less +14 -0
- package/es/theme/src/components/sider/index.d.ts +1 -1
- package/es/theme/src/components/sider/mix-sider.d.ts +1 -1
- package/es/theme/src/index.d.ts +1 -1
- package/package.json +1 -1
|
@@ -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,
|
|
7
|
-
import { cloneDeep,
|
|
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
|
|
245
|
-
const node = treeData[
|
|
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
|
|
261
|
-
const node = treeData[
|
|
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
|
|
277
|
-
const node = treeData[
|
|
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
|
|
300
|
-
const element = treeData[
|
|
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[
|
|
303
|
+
treeData[index] = { ...treeData[index], ...node };
|
|
304
304
|
break;
|
|
305
305
|
} else if (children && children.length) {
|
|
306
306
|
updateNodeByKey(key, node, element[childrenField]);
|
|
@@ -312,8 +312,8 @@ function useTree(treeDataRef, getFieldNames, emit) {
|
|
|
312
312
|
return [];
|
|
313
313
|
const res = [];
|
|
314
314
|
const data = list || unref(treeDataRef) || [];
|
|
315
|
-
for (let
|
|
316
|
-
const item = data[
|
|
315
|
+
for (let index = 0; index < data.length; index++) {
|
|
316
|
+
const item = data[index];
|
|
317
317
|
const { key: keyField, children: childrenField } = unref(getFieldNames);
|
|
318
318
|
const key = keyField ? item[keyField] : "";
|
|
319
319
|
const children = childrenField ? item[childrenField] : [];
|
|
@@ -375,11 +375,11 @@ function useTree(treeDataRef, getFieldNames, emit) {
|
|
|
375
375
|
const { key: keyField, children: childrenField } = unref(getFieldNames);
|
|
376
376
|
if (!childrenField || !keyField)
|
|
377
377
|
return;
|
|
378
|
-
for (let
|
|
379
|
-
const element = treeData[
|
|
378
|
+
for (let index = 0; index < treeData.length; index++) {
|
|
379
|
+
const element = treeData[index];
|
|
380
380
|
const children = element[childrenField];
|
|
381
381
|
if (element[keyField] === key) {
|
|
382
|
-
treeData.splice(
|
|
382
|
+
treeData.splice(index, 1);
|
|
383
383
|
break;
|
|
384
384
|
} else if (children && children.length) {
|
|
385
385
|
deleteNodeByKey(key, element[childrenField]);
|
|
@@ -411,17 +411,17 @@ function useTree(treeDataRef, getFieldNames, emit) {
|
|
|
411
411
|
const dropPosition = info.dropPosition - Number(dropPos[dropPos.length - 1]);
|
|
412
412
|
const { children: childrenField } = unref(getFieldNames);
|
|
413
413
|
const loop = (data2, key, callback) => {
|
|
414
|
-
data2.forEach((item,
|
|
414
|
+
data2.forEach((item, index) => {
|
|
415
415
|
if (item.key === key)
|
|
416
|
-
return callback(item,
|
|
416
|
+
return callback(item, index, data2);
|
|
417
417
|
if (item[childrenField])
|
|
418
418
|
return loop(item[childrenField], key, callback);
|
|
419
419
|
});
|
|
420
420
|
};
|
|
421
421
|
const data = [...treeDataRef.value];
|
|
422
422
|
let dragObj;
|
|
423
|
-
loop(data, dragKey, (item,
|
|
424
|
-
arr.splice(
|
|
423
|
+
loop(data, dragKey, (item, index, arr) => {
|
|
424
|
+
arr.splice(index, 1);
|
|
425
425
|
dragObj = item;
|
|
426
426
|
});
|
|
427
427
|
if (!info.dropToGap) {
|
|
@@ -437,9 +437,9 @@ function useTree(treeDataRef, getFieldNames, emit) {
|
|
|
437
437
|
} else {
|
|
438
438
|
let ar = [];
|
|
439
439
|
let i = 0;
|
|
440
|
-
loop(data, dropKey, (_item,
|
|
440
|
+
loop(data, dropKey, (_item, index, arr) => {
|
|
441
441
|
ar = arr;
|
|
442
|
-
i =
|
|
442
|
+
i = index;
|
|
443
443
|
});
|
|
444
444
|
dropPosition === -1 ? ar.splice(i, 0, dragObj) : ar.splice(i + 1, 0, dragObj);
|
|
445
445
|
}
|
|
@@ -544,10 +544,10 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
544
544
|
const _component_AMenu = Menu;
|
|
545
545
|
const _component_ADropdown = Dropdown;
|
|
546
546
|
return openBlock(), createElementBlock("div", _hoisted_1$2, [
|
|
547
|
-
_ctx.title ? (openBlock(), createElementBlock("h4", _hoisted_2$2, toDisplayString(_ctx.title), 1)) : createCommentVNode("
|
|
547
|
+
_ctx.title ? (openBlock(), createElementBlock("h4", _hoisted_2$2, toDisplayString(_ctx.title), 1)) : createCommentVNode("", true),
|
|
548
548
|
_ctx.search || _ctx.toolbar ? (openBlock(), createElementBlock("div", _hoisted_3$2, [
|
|
549
549
|
_ctx.search ? (openBlock(), createElementBlock("div", _hoisted_4, [
|
|
550
|
-
unref(slots).addonBefore ? renderSlot(_ctx.$slots, "addonBefore", { key: 0 }) : createCommentVNode("
|
|
550
|
+
unref(slots).addonBefore ? renderSlot(_ctx.$slots, "addonBefore", { key: 0 }) : createCommentVNode("", true),
|
|
551
551
|
createVNode(_component_AInput, {
|
|
552
552
|
size: "small",
|
|
553
553
|
allowClear: "",
|
|
@@ -555,8 +555,8 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
555
555
|
"onUpdate:value": _cache[0] || (_cache[0] = ($event) => searchValue.value = $event),
|
|
556
556
|
placeholder: unref(t)("FILTER")
|
|
557
557
|
}, null, 8, ["value", "placeholder"]),
|
|
558
|
-
unref(slots).addonAfter ? renderSlot(_ctx.$slots, "addonAfter", { key: 1 }) : createCommentVNode("
|
|
559
|
-
])) : createCommentVNode("
|
|
558
|
+
unref(slots).addonAfter ? renderSlot(_ctx.$slots, "addonAfter", { key: 1 }) : createCommentVNode("", true)
|
|
559
|
+
])) : createCommentVNode("", true),
|
|
560
560
|
_ctx.toolbar ? (openBlock(), createBlock(_component_ADropdown, {
|
|
561
561
|
key: 1,
|
|
562
562
|
onClick: _cache[1] || (_cache[1] = withModifiers(() => {
|
|
@@ -575,7 +575,7 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
575
575
|
]),
|
|
576
576
|
_: 2
|
|
577
577
|
}, 1040),
|
|
578
|
-
item.divider ? (openBlock(), createBlock(_component_AMenuDivider, { key: 0 })) : createCommentVNode("
|
|
578
|
+
item.divider ? (openBlock(), createBlock(_component_AMenuDivider, { key: 0 })) : createCommentVNode("", true)
|
|
579
579
|
], 64);
|
|
580
580
|
}), 128))
|
|
581
581
|
]),
|
|
@@ -586,20 +586,12 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
586
586
|
_hoisted_5
|
|
587
587
|
]),
|
|
588
588
|
_: 1
|
|
589
|
-
})) : createCommentVNode("
|
|
590
|
-
])) : createCommentVNode("
|
|
589
|
+
})) : createCommentVNode("", true)
|
|
590
|
+
])) : createCommentVNode("", true)
|
|
591
591
|
]);
|
|
592
592
|
};
|
|
593
593
|
}
|
|
594
594
|
});
|
|
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
595
|
function _isSlot(s) {
|
|
604
596
|
return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
|
|
605
597
|
}
|
|
@@ -722,7 +714,6 @@ const _sfc_main$1 = defineComponent({
|
|
|
722
714
|
};
|
|
723
715
|
}
|
|
724
716
|
});
|
|
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
717
|
function useContextMenu() {
|
|
727
718
|
const menuManager = {
|
|
728
719
|
domList: [],
|
|
@@ -746,7 +737,7 @@ function useContextMenu() {
|
|
|
746
737
|
propsData.customEvent = event;
|
|
747
738
|
propsData.axis = { x: event.clientX, y: event.clientY };
|
|
748
739
|
}
|
|
749
|
-
const vm = createVNode(
|
|
740
|
+
const vm = createVNode(_sfc_main$1, propsData);
|
|
750
741
|
render$2(vm, container);
|
|
751
742
|
const handleClick = function() {
|
|
752
743
|
menuManager.resolve("");
|
|
@@ -881,16 +872,16 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
881
872
|
};
|
|
882
873
|
const treeData = computed(() => {
|
|
883
874
|
const data = cloneDeep(getTreeData.value);
|
|
875
|
+
const {
|
|
876
|
+
title: titleField,
|
|
877
|
+
key: keyField,
|
|
878
|
+
children: childrenField
|
|
879
|
+
} = unref(getFieldNames);
|
|
884
880
|
eachTree(data, (item, _parent) => {
|
|
885
881
|
const searchText = searchState.searchText;
|
|
886
882
|
const {
|
|
887
883
|
highlight
|
|
888
884
|
} = unref(props);
|
|
889
|
-
const {
|
|
890
|
-
title: titleField,
|
|
891
|
-
key: keyField,
|
|
892
|
-
children: childrenField
|
|
893
|
-
} = unref(getFieldNames);
|
|
894
885
|
const icon = getIcon(item, item.icon);
|
|
895
886
|
const title = get(item, titleField);
|
|
896
887
|
const searchIdx = searchText ? title.indexOf(searchText) : -1;
|
|
@@ -903,13 +894,15 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
903
894
|
}, [searchText]), createVNode("span", null, [title.substr(searchIdx + searchText.length)])]) : title;
|
|
904
895
|
item._title = item[titleField];
|
|
905
896
|
item[titleField] = createVNode("span", {
|
|
906
|
-
"class": `tree-title ${unref(activeKey) === item[keyField] ? "tree-active-node" : ""}
|
|
897
|
+
"class": `tree-title ${unref(activeKey) === item[keyField] ? "tree-active-node" : ""}`
|
|
898
|
+
}, [slots?.title ? getSlot(slots, "title", item) : createVNode(Fragment, null, [createVNode("span", {
|
|
899
|
+
"class": "flex items-center flex-1",
|
|
907
900
|
"onClick": handleClickNode.bind(null, item[keyField], item[childrenField], item)
|
|
908
|
-
}, [
|
|
901
|
+
}, [unref(getBindValues).showIcon && icon, titleDom]), createVNode("span", {
|
|
909
902
|
"class": "tree-action"
|
|
910
903
|
}, [renderAction(item)])])]);
|
|
911
904
|
}, {}, {
|
|
912
|
-
children:
|
|
905
|
+
children: childrenField
|
|
913
906
|
});
|
|
914
907
|
return data;
|
|
915
908
|
});
|
|
@@ -969,9 +962,9 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
969
962
|
setExpandedKeys([...state.expandedKeys, key]);
|
|
970
963
|
} else {
|
|
971
964
|
const keys = [...state.expandedKeys];
|
|
972
|
-
const
|
|
973
|
-
if (
|
|
974
|
-
keys.splice(
|
|
965
|
+
const index = keys.findIndex((item) => item === key);
|
|
966
|
+
if (index !== -1) {
|
|
967
|
+
keys.splice(index, 1);
|
|
975
968
|
}
|
|
976
969
|
setExpandedKeys(keys);
|
|
977
970
|
}
|
|
@@ -1164,7 +1157,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1164
1157
|
const _component_ASpin = Spin;
|
|
1165
1158
|
return openBlock(), createElementBlock("div", {
|
|
1166
1159
|
class: normalizeClass(["dt-tree h-full flex flex-col", `dt-tree-${unref(getUiSize)}`])
|
|
1167
|
-
}, [unref(showTitle) ? (openBlock(), createBlock(
|
|
1160
|
+
}, [unref(showTitle) ? (openBlock(), createBlock(_sfc_main$2, {
|
|
1168
1161
|
key: 0,
|
|
1169
1162
|
title: _ctx.title,
|
|
1170
1163
|
toolbar: _ctx.toolbar,
|
|
@@ -1181,7 +1174,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1181
1174
|
name: item,
|
|
1182
1175
|
fn: withCtx(() => [renderSlot(_ctx.$slots, item)])
|
|
1183
1176
|
};
|
|
1184
|
-
})]), 1032, ["title", "toolbar", "search", "checkable", "searchText"])) : createCommentVNode("
|
|
1177
|
+
})]), 1032, ["title", "toolbar", "search", "checkable", "searchText"])) : createCommentVNode("", true), createVNode(_component_ASpin, {
|
|
1185
1178
|
spinning: _ctx.loading,
|
|
1186
1179
|
tip: unref(t)("LOADING")
|
|
1187
1180
|
}, {
|
|
@@ -1195,7 +1188,6 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1195
1188
|
};
|
|
1196
1189
|
}
|
|
1197
1190
|
});
|
|
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
1191
|
export {
|
|
1200
|
-
|
|
1192
|
+
_sfc_main as DtTree
|
|
1201
1193
|
};
|
|
@@ -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?: {}
|
|
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,
|
|
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
|
|
140
|
-
fileType: file
|
|
165
|
+
name: file[fileName],
|
|
166
|
+
fileType: file[fileType] || takeRight(file[fileName].split("."))[0],
|
|
141
167
|
status: "done",
|
|
142
|
-
|
|
143
|
-
|
|
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
|
|
320
|
-
const
|
|
321
|
-
const
|
|
322
|
-
const
|
|
323
|
-
const
|
|
324
|
-
const
|
|
325
|
-
const
|
|
326
|
-
const
|
|
327
|
-
|
|
328
|
-
|
|
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.
|
|
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
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
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 =
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
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,
|
|
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",
|
|
519
|
-
createElementVNode("div",
|
|
520
|
-
createElementVNode("div",
|
|
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",
|
|
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,
|
|
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",
|
|
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;
|
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import { Ref } from "vue";
|
|
2
|
-
import { UploadFile } from "../type/file";
|
|
3
|
-
export declare function useFile({ fileListRef, acceptRef, helpTextRef, maxCountRef, maxSizeRef, }: {
|
|
1
|
+
import { Ref, ComputedRef } from "vue";
|
|
2
|
+
import { FieldNames, UploadFile } from "../type/file";
|
|
3
|
+
export declare function useFile({ fileListRef, acceptRef, helpTextRef, maxCountRef, maxSizeRef, fieldNamesRef }: {
|
|
4
4
|
fileListRef: Ref<UploadFile[]>;
|
|
5
5
|
acceptRef: Ref<string[]>;
|
|
6
6
|
helpTextRef: Ref<string>;
|
|
7
7
|
maxCountRef: Ref<number>;
|
|
8
8
|
maxSizeRef: Ref<number>;
|
|
9
|
+
fieldNamesRef: ComputedRef<FieldNames>;
|
|
9
10
|
}): {
|
|
10
|
-
getAccept:
|
|
11
|
-
getStringAccept:
|
|
12
|
-
getHelpText:
|
|
11
|
+
getAccept: ComputedRef<string[]>;
|
|
12
|
+
getStringAccept: ComputedRef<string>;
|
|
13
|
+
getHelpText: ComputedRef<string>;
|
|
13
14
|
fileList: Ref<any[]>;
|
|
14
15
|
setFile: (file: any) => any;
|
|
15
16
|
beforeUpload: (file: File) => void;
|