knt-shared 1.2.4 → 1.2.6
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/components/Form/BasicForm.vue.d.ts +167 -0
- package/dist/components/Form/BasicForm.vue.d.ts.map +1 -0
- package/dist/components/Form/componentMap.d.ts +7 -8
- package/dist/components/Form/componentMap.d.ts.map +1 -1
- package/dist/components/Form/index.d.ts +5 -7
- package/dist/components/Form/index.d.ts.map +1 -1
- package/dist/components/Form/types.d.ts +7 -4
- package/dist/components/Form/types.d.ts.map +1 -1
- package/dist/components/Table/BasicTable.vue.d.ts +28 -0
- package/dist/components/Table/BasicTable.vue.d.ts.map +1 -1
- package/dist/components/Table/types.d.ts +21 -5
- package/dist/components/Table/types.d.ts.map +1 -1
- package/dist/components/Upload/BasicUpload.vue.d.ts +1 -1
- package/dist/components/Upload/types.d.ts +3 -3
- package/dist/components/Upload/types.d.ts.map +1 -1
- package/dist/index.cjs.js +154 -132
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +154 -132
- package/dist/index.esm.js.map +1 -1
- package/dist/style.css +31 -33
- package/package.json +2 -2
package/dist/index.cjs.js
CHANGED
|
@@ -711,7 +711,7 @@ const _sfc_main$4 = /* @__PURE__ */ vue.defineComponent({
|
|
|
711
711
|
emits: ["register", "update:modelValue", "change", "success", "handleSuccess", "error", "handlError", "progress", "remove", "preview", "exceed"],
|
|
712
712
|
setup(__props, { expose: __expose, emit: __emit }) {
|
|
713
713
|
vue.useCssVars((_ctx) => ({
|
|
714
|
-
"
|
|
714
|
+
"f530bac6": cardSizeValue.value
|
|
715
715
|
}));
|
|
716
716
|
const props = __props;
|
|
717
717
|
const emit = __emit;
|
|
@@ -943,7 +943,7 @@ const _sfc_main$4 = /* @__PURE__ */ vue.defineComponent({
|
|
|
943
943
|
fileListRef.value = fileList;
|
|
944
944
|
emit("change", fileList);
|
|
945
945
|
const isRemove = newLength < oldLength;
|
|
946
|
-
const fileKey = currentFile.uid
|
|
946
|
+
const fileKey = currentFile.uid || `file-${Date.now()}-${Math.random()}`;
|
|
947
947
|
const lastStatus = processedFiles.value.get(fileKey);
|
|
948
948
|
if (currentFile.status === "done" && lastStatus !== "done" && !isRemove) {
|
|
949
949
|
processedFiles.value.set(fileKey, "done");
|
|
@@ -1081,7 +1081,7 @@ const _sfc_main$4 = /* @__PURE__ */ vue.defineComponent({
|
|
|
1081
1081
|
updateFile
|
|
1082
1082
|
});
|
|
1083
1083
|
vue.watch(
|
|
1084
|
-
() =>
|
|
1084
|
+
() => getProps.value.modelValue,
|
|
1085
1085
|
(val) => {
|
|
1086
1086
|
fileListRef.value = parseModelValue(val);
|
|
1087
1087
|
},
|
|
@@ -1183,7 +1183,103 @@ const _export_sfc = (sfc, props) => {
|
|
|
1183
1183
|
}
|
|
1184
1184
|
return target;
|
|
1185
1185
|
};
|
|
1186
|
-
const BasicUpload = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["__scopeId", "data-v-
|
|
1186
|
+
const BasicUpload = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["__scopeId", "data-v-03d56780"]]);
|
|
1187
|
+
function useUpload(props) {
|
|
1188
|
+
const uploadRef = vue.ref(null);
|
|
1189
|
+
const fileListRef = vue.ref((props == null ? void 0 : props.defaultFileList) || []);
|
|
1190
|
+
const register = (uploadInstance) => {
|
|
1191
|
+
uploadRef.value = uploadInstance;
|
|
1192
|
+
if ((props == null ? void 0 : props.defaultFileList) && props.defaultFileList.length > 0) {
|
|
1193
|
+
uploadInstance.setFileList(props.defaultFileList);
|
|
1194
|
+
}
|
|
1195
|
+
if (props && Object.keys(props).length > 0) {
|
|
1196
|
+
const { defaultFileList, ...restProps } = props;
|
|
1197
|
+
if (Object.keys(restProps).length > 0) {
|
|
1198
|
+
setProps(restProps);
|
|
1199
|
+
}
|
|
1200
|
+
}
|
|
1201
|
+
};
|
|
1202
|
+
const getUpload = () => {
|
|
1203
|
+
const upload2 = vue.unref(uploadRef);
|
|
1204
|
+
if (!upload2) {
|
|
1205
|
+
throw new Error('Upload 实例未注册,请确保在组件上使用 @register="register"');
|
|
1206
|
+
}
|
|
1207
|
+
return upload2;
|
|
1208
|
+
};
|
|
1209
|
+
const submit = () => {
|
|
1210
|
+
getUpload().submit();
|
|
1211
|
+
};
|
|
1212
|
+
const abort = (fileItem) => {
|
|
1213
|
+
getUpload().abort(fileItem);
|
|
1214
|
+
};
|
|
1215
|
+
const clearFiles = () => {
|
|
1216
|
+
getUpload().clearFiles();
|
|
1217
|
+
fileListRef.value = [];
|
|
1218
|
+
};
|
|
1219
|
+
const getFileList = () => {
|
|
1220
|
+
return getUpload().getFileList();
|
|
1221
|
+
};
|
|
1222
|
+
const upload = (fileItem) => {
|
|
1223
|
+
getUpload().upload(fileItem);
|
|
1224
|
+
};
|
|
1225
|
+
const setFileList = (files) => {
|
|
1226
|
+
fileListRef.value = files;
|
|
1227
|
+
const upload2 = getUpload();
|
|
1228
|
+
if (upload2.setFileList) {
|
|
1229
|
+
upload2.setFileList(files);
|
|
1230
|
+
}
|
|
1231
|
+
};
|
|
1232
|
+
const addFile = (file) => {
|
|
1233
|
+
fileListRef.value.push(file);
|
|
1234
|
+
const upload2 = getUpload();
|
|
1235
|
+
if (upload2.addFile) {
|
|
1236
|
+
upload2.addFile(file);
|
|
1237
|
+
}
|
|
1238
|
+
};
|
|
1239
|
+
const removeFile = (fileItem) => {
|
|
1240
|
+
const index = fileListRef.value.findIndex(
|
|
1241
|
+
(item) => item.uid === fileItem.uid
|
|
1242
|
+
);
|
|
1243
|
+
if (index !== -1) {
|
|
1244
|
+
fileListRef.value.splice(index, 1);
|
|
1245
|
+
}
|
|
1246
|
+
const upload2 = getUpload();
|
|
1247
|
+
if (upload2.removeFile) {
|
|
1248
|
+
upload2.removeFile(fileItem);
|
|
1249
|
+
}
|
|
1250
|
+
};
|
|
1251
|
+
const updateFile = (fileItem) => {
|
|
1252
|
+
const index = fileListRef.value.findIndex(
|
|
1253
|
+
(item) => item.uid === fileItem.uid
|
|
1254
|
+
);
|
|
1255
|
+
if (index !== -1) {
|
|
1256
|
+
fileListRef.value[index] = { ...fileListRef.value[index], ...fileItem };
|
|
1257
|
+
}
|
|
1258
|
+
const upload2 = getUpload();
|
|
1259
|
+
if (upload2.updateFile) {
|
|
1260
|
+
upload2.updateFile(fileItem);
|
|
1261
|
+
}
|
|
1262
|
+
};
|
|
1263
|
+
const setProps = (uploadProps) => {
|
|
1264
|
+
getUpload().setProps(uploadProps);
|
|
1265
|
+
};
|
|
1266
|
+
const methods = {
|
|
1267
|
+
get fileList() {
|
|
1268
|
+
return fileListRef.value;
|
|
1269
|
+
},
|
|
1270
|
+
submit,
|
|
1271
|
+
abort,
|
|
1272
|
+
upload,
|
|
1273
|
+
clearFiles,
|
|
1274
|
+
getFileList,
|
|
1275
|
+
setFileList,
|
|
1276
|
+
addFile,
|
|
1277
|
+
removeFile,
|
|
1278
|
+
updateFile,
|
|
1279
|
+
setProps
|
|
1280
|
+
};
|
|
1281
|
+
return [register, methods];
|
|
1282
|
+
}
|
|
1187
1283
|
const componentMap = {
|
|
1188
1284
|
Input: webVue.Input,
|
|
1189
1285
|
InputNumber: webVue.InputNumber,
|
|
@@ -1235,6 +1331,10 @@ const componentsNeedSelectPlaceholder = /* @__PURE__ */ new Set([
|
|
|
1235
1331
|
"Cascader",
|
|
1236
1332
|
"TreeSelect"
|
|
1237
1333
|
]);
|
|
1334
|
+
const componentsNeedUploadPlaceholder = /* @__PURE__ */ new Set([
|
|
1335
|
+
"Upload",
|
|
1336
|
+
"BasicUpload"
|
|
1337
|
+
]);
|
|
1238
1338
|
function getPlaceholder(component, label) {
|
|
1239
1339
|
if (componentsNeedPlaceholder.has(component)) {
|
|
1240
1340
|
return `请输入${label}`;
|
|
@@ -1248,10 +1348,10 @@ function getRules(component, label) {
|
|
|
1248
1348
|
if (componentsNeedPlaceholder.has(component)) {
|
|
1249
1349
|
return [{ required: true, message: `请输入${label}` }];
|
|
1250
1350
|
}
|
|
1251
|
-
if (
|
|
1252
|
-
return [{ required: true, message:
|
|
1351
|
+
if (componentsNeedUploadPlaceholder.has(component)) {
|
|
1352
|
+
return [{ required: true, message: `请上传${label}` }];
|
|
1253
1353
|
}
|
|
1254
|
-
return [];
|
|
1354
|
+
return [{ required: true, message: `请选择${label}` }];
|
|
1255
1355
|
}
|
|
1256
1356
|
const _sfc_main$3 = /* @__PURE__ */ vue.defineComponent({
|
|
1257
1357
|
...{
|
|
@@ -1511,7 +1611,7 @@ const _sfc_main$3 = /* @__PURE__ */ vue.defineComponent({
|
|
|
1511
1611
|
scrollToField
|
|
1512
1612
|
});
|
|
1513
1613
|
const stopSchemasWatch = vue.watch(
|
|
1514
|
-
() =>
|
|
1614
|
+
() => getProps.value.schemas,
|
|
1515
1615
|
(newSchemas) => {
|
|
1516
1616
|
if (newSchemas) {
|
|
1517
1617
|
internalSchemas.value = [...newSchemas];
|
|
@@ -1578,8 +1678,12 @@ const _sfc_main$3 = /* @__PURE__ */ vue.defineComponent({
|
|
|
1578
1678
|
ref_for: true
|
|
1579
1679
|
}, getFormItemBindValue(schema)), {
|
|
1580
1680
|
default: vue.withCtx(() => [
|
|
1581
|
-
schema.
|
|
1582
|
-
key:
|
|
1681
|
+
schema.slotName ? vue.renderSlot(_ctx.$slots, schema.slotName, {
|
|
1682
|
+
key: 0,
|
|
1683
|
+
schema,
|
|
1684
|
+
model: formModel
|
|
1685
|
+
}) : schema.renderComponentContent ? (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(schema.renderComponentContent(schema, formModel)), { key: 1 })) : (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(vue.unref(getComponent)(schema.component)), vue.mergeProps({
|
|
1686
|
+
key: 2,
|
|
1583
1687
|
modelValue: formModel[schema.field],
|
|
1584
1688
|
"onUpdate:modelValue": ($event) => formModel[schema.field] = $event,
|
|
1585
1689
|
placeholder: getPlaceholderText(schema)
|
|
@@ -2005,11 +2109,19 @@ const _sfc_main$2 = /* @__PURE__ */ vue.defineComponent({
|
|
|
2005
2109
|
expandable: {},
|
|
2006
2110
|
scroll: {},
|
|
2007
2111
|
draggable: {},
|
|
2008
|
-
pagination: { type: [Boolean, Object]
|
|
2009
|
-
|
|
2010
|
-
|
|
2112
|
+
pagination: { type: [Boolean, Object], default: () => ({
|
|
2113
|
+
current: 1,
|
|
2114
|
+
pageSize: 20,
|
|
2115
|
+
showTotal: true,
|
|
2116
|
+
showJumper: true,
|
|
2117
|
+
showPageSize: true,
|
|
2118
|
+
pageSizeOptions: [5, 10, 20, 50, 100]
|
|
2119
|
+
}) },
|
|
2120
|
+
search: { type: [Boolean, Object], default: () => ({ show: false }) },
|
|
2121
|
+
toolbar: { type: [Boolean, Object], default: () => ({ show: false }) },
|
|
2011
2122
|
immediate: { type: Boolean, default: true },
|
|
2012
2123
|
api: {},
|
|
2124
|
+
fetchSetting: {},
|
|
2013
2125
|
beforeFetch: {},
|
|
2014
2126
|
afterFetch: {},
|
|
2015
2127
|
onFetchError: {},
|
|
@@ -2064,7 +2176,7 @@ const _sfc_main$2 = /* @__PURE__ */ vue.defineComponent({
|
|
|
2064
2176
|
};
|
|
2065
2177
|
const paginationRef = vue.ref({
|
|
2066
2178
|
current: 1,
|
|
2067
|
-
pageSize:
|
|
2179
|
+
pageSize: 20,
|
|
2068
2180
|
total: 0,
|
|
2069
2181
|
showTotal: true,
|
|
2070
2182
|
showJumper: true,
|
|
@@ -2087,7 +2199,7 @@ const _sfc_main$2 = /* @__PURE__ */ vue.defineComponent({
|
|
|
2087
2199
|
}
|
|
2088
2200
|
};
|
|
2089
2201
|
vue.watch(
|
|
2090
|
-
() => [
|
|
2202
|
+
() => [getMergedProps.value.data, getMergedProps.value.loading],
|
|
2091
2203
|
([data, loading]) => {
|
|
2092
2204
|
if (data) {
|
|
2093
2205
|
dataSource.value = data;
|
|
@@ -2295,6 +2407,7 @@ const _sfc_main$2 = /* @__PURE__ */ vue.defineComponent({
|
|
|
2295
2407
|
search,
|
|
2296
2408
|
toolbar,
|
|
2297
2409
|
api,
|
|
2410
|
+
fetchSetting,
|
|
2298
2411
|
beforeFetch,
|
|
2299
2412
|
afterFetch,
|
|
2300
2413
|
onFetchError,
|
|
@@ -2499,15 +2612,22 @@ const _sfc_main$2 = /* @__PURE__ */ vue.defineComponent({
|
|
|
2499
2612
|
const signal = currentAbortController.signal;
|
|
2500
2613
|
try {
|
|
2501
2614
|
loadingRef.value = true;
|
|
2615
|
+
const fetchSetting = {
|
|
2616
|
+
pageField: "page",
|
|
2617
|
+
sizeField: "pageSize",
|
|
2618
|
+
listField: "records",
|
|
2619
|
+
totalField: "total",
|
|
2620
|
+
...mergedProps.fetchSetting
|
|
2621
|
+
};
|
|
2502
2622
|
let params = {
|
|
2503
2623
|
...searchParams.value
|
|
2504
2624
|
};
|
|
2505
2625
|
if (paginationRef.value) {
|
|
2506
|
-
params.
|
|
2507
|
-
params.
|
|
2626
|
+
params[fetchSetting.pageField] = paginationRef.value.current;
|
|
2627
|
+
params[fetchSetting.sizeField] = paginationRef.value.pageSize;
|
|
2508
2628
|
}
|
|
2509
2629
|
if (mergedProps.beforeFetch) {
|
|
2510
|
-
params = mergedProps.beforeFetch(params);
|
|
2630
|
+
params = await Promise.resolve(mergedProps.beforeFetch(params));
|
|
2511
2631
|
}
|
|
2512
2632
|
const result = await mergedProps.api(params, signal);
|
|
2513
2633
|
if (!result || typeof result !== "object") {
|
|
@@ -2517,30 +2637,29 @@ const _sfc_main$2 = /* @__PURE__ */ vue.defineComponent({
|
|
|
2517
2637
|
data: result
|
|
2518
2638
|
};
|
|
2519
2639
|
}
|
|
2520
|
-
|
|
2640
|
+
const listField = fetchSetting.listField;
|
|
2641
|
+
const totalField = fetchSetting.totalField;
|
|
2642
|
+
if (!(listField in result)) {
|
|
2521
2643
|
throw {
|
|
2522
2644
|
code: ERROR_CODES.INVALID_RESPONSE,
|
|
2523
|
-
message:
|
|
2645
|
+
message: `API 响应格式无效:缺少 ${listField} 字段`,
|
|
2524
2646
|
data: result
|
|
2525
2647
|
};
|
|
2526
2648
|
}
|
|
2527
|
-
if (!Array.isArray(result
|
|
2528
|
-
console.warn(
|
|
2529
|
-
}
|
|
2530
|
-
if (!("total" in result) || typeof result.total !== "number") {
|
|
2531
|
-
console.warn("API 响应格式警告:total 字段缺失或类型错误,已设置为 0");
|
|
2649
|
+
if (!Array.isArray(result[listField])) {
|
|
2650
|
+
console.warn(`API 响应格式警告:${listField} 字段不是数组,已转换为空数组`);
|
|
2532
2651
|
}
|
|
2533
|
-
let data = Array.isArray(result
|
|
2534
|
-
let total = typeof result
|
|
2652
|
+
let data = Array.isArray(result[listField]) ? result[listField] : [];
|
|
2653
|
+
let total = typeof result[totalField] === "number" ? result[totalField] : data.length;
|
|
2535
2654
|
if (total < data.length) {
|
|
2536
2655
|
console.warn(
|
|
2537
2656
|
`数据一致性警告:total(${total}) 小于 data.length(${data.length})`
|
|
2538
2657
|
);
|
|
2539
2658
|
}
|
|
2540
2659
|
if (mergedProps.afterFetch) {
|
|
2541
|
-
const processed = mergedProps.afterFetch(result);
|
|
2542
|
-
data = Array.isArray(processed
|
|
2543
|
-
total = typeof processed
|
|
2660
|
+
const processed = await Promise.resolve(mergedProps.afterFetch(result));
|
|
2661
|
+
data = Array.isArray(processed[listField]) ? processed[listField] : data;
|
|
2662
|
+
total = typeof processed[totalField] === "number" ? processed[totalField] : total;
|
|
2544
2663
|
}
|
|
2545
2664
|
dataSource.value = data;
|
|
2546
2665
|
if (paginationRef.value) {
|
|
@@ -2708,7 +2827,6 @@ const _sfc_main$2 = /* @__PURE__ */ vue.defineComponent({
|
|
|
2708
2827
|
initPagination();
|
|
2709
2828
|
initColumnSetting();
|
|
2710
2829
|
document.addEventListener("fullscreenchange", handleFullscreenChange);
|
|
2711
|
-
await vue.nextTick();
|
|
2712
2830
|
const tableInstance = {
|
|
2713
2831
|
getDataSource,
|
|
2714
2832
|
setDataSource,
|
|
@@ -3120,7 +3238,7 @@ const _sfc_main$2 = /* @__PURE__ */ vue.defineComponent({
|
|
|
3120
3238
|
};
|
|
3121
3239
|
}
|
|
3122
3240
|
});
|
|
3123
|
-
const BasicTable = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__scopeId", "data-v-
|
|
3241
|
+
const BasicTable = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__scopeId", "data-v-7a27a6be"]]);
|
|
3124
3242
|
function useTable(options = {}) {
|
|
3125
3243
|
const tableRef = vue.ref(null);
|
|
3126
3244
|
const formRef = vue.ref(null);
|
|
@@ -3600,14 +3718,14 @@ const _sfc_main$1 = /* @__PURE__ */ vue.defineComponent({
|
|
|
3600
3718
|
};
|
|
3601
3719
|
__expose(modalMethods);
|
|
3602
3720
|
vue.watch(
|
|
3603
|
-
() =>
|
|
3721
|
+
() => getProps.value.visible,
|
|
3604
3722
|
(val) => {
|
|
3605
|
-
visibleRef.value = val;
|
|
3723
|
+
visibleRef.value = val ?? false;
|
|
3606
3724
|
},
|
|
3607
3725
|
{ immediate: true }
|
|
3608
3726
|
);
|
|
3609
3727
|
vue.watch(
|
|
3610
|
-
() =>
|
|
3728
|
+
() => getProps.value.defaultFullscreen,
|
|
3611
3729
|
(val) => {
|
|
3612
3730
|
fullscreenRef.value = val || false;
|
|
3613
3731
|
},
|
|
@@ -3761,7 +3879,7 @@ const _sfc_main$1 = /* @__PURE__ */ vue.defineComponent({
|
|
|
3761
3879
|
};
|
|
3762
3880
|
}
|
|
3763
3881
|
});
|
|
3764
|
-
const BasicModal = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-
|
|
3882
|
+
const BasicModal = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-68fed17a"]]);
|
|
3765
3883
|
function useModal(props) {
|
|
3766
3884
|
const modalRef = vue.ref(null);
|
|
3767
3885
|
const loadedRef = vue.ref(false);
|
|
@@ -4143,102 +4261,6 @@ function useDescription(props) {
|
|
|
4143
4261
|
}
|
|
4144
4262
|
];
|
|
4145
4263
|
}
|
|
4146
|
-
function useUpload(props) {
|
|
4147
|
-
const uploadRef = vue.ref(null);
|
|
4148
|
-
const fileListRef = vue.ref((props == null ? void 0 : props.defaultFileList) || []);
|
|
4149
|
-
const register = (uploadInstance) => {
|
|
4150
|
-
uploadRef.value = uploadInstance;
|
|
4151
|
-
if ((props == null ? void 0 : props.defaultFileList) && props.defaultFileList.length > 0) {
|
|
4152
|
-
uploadInstance.setFileList(props.defaultFileList);
|
|
4153
|
-
}
|
|
4154
|
-
if (props && Object.keys(props).length > 0) {
|
|
4155
|
-
const { defaultFileList, ...restProps } = props;
|
|
4156
|
-
if (Object.keys(restProps).length > 0) {
|
|
4157
|
-
setProps(restProps);
|
|
4158
|
-
}
|
|
4159
|
-
}
|
|
4160
|
-
};
|
|
4161
|
-
const getUpload = () => {
|
|
4162
|
-
const upload2 = vue.unref(uploadRef);
|
|
4163
|
-
if (!upload2) {
|
|
4164
|
-
throw new Error('Upload 实例未注册,请确保在组件上使用 @register="register"');
|
|
4165
|
-
}
|
|
4166
|
-
return upload2;
|
|
4167
|
-
};
|
|
4168
|
-
const submit = () => {
|
|
4169
|
-
getUpload().submit();
|
|
4170
|
-
};
|
|
4171
|
-
const abort = (fileItem) => {
|
|
4172
|
-
getUpload().abort(fileItem);
|
|
4173
|
-
};
|
|
4174
|
-
const clearFiles = () => {
|
|
4175
|
-
getUpload().clearFiles();
|
|
4176
|
-
fileListRef.value = [];
|
|
4177
|
-
};
|
|
4178
|
-
const getFileList = () => {
|
|
4179
|
-
return getUpload().getFileList();
|
|
4180
|
-
};
|
|
4181
|
-
const upload = (fileItem) => {
|
|
4182
|
-
getUpload().upload(fileItem);
|
|
4183
|
-
};
|
|
4184
|
-
const setFileList = (files) => {
|
|
4185
|
-
fileListRef.value = files;
|
|
4186
|
-
const upload2 = getUpload();
|
|
4187
|
-
if (upload2.setFileList) {
|
|
4188
|
-
upload2.setFileList(files);
|
|
4189
|
-
}
|
|
4190
|
-
};
|
|
4191
|
-
const addFile = (file) => {
|
|
4192
|
-
fileListRef.value.push(file);
|
|
4193
|
-
const upload2 = getUpload();
|
|
4194
|
-
if (upload2.addFile) {
|
|
4195
|
-
upload2.addFile(file);
|
|
4196
|
-
}
|
|
4197
|
-
};
|
|
4198
|
-
const removeFile = (fileItem) => {
|
|
4199
|
-
const index = fileListRef.value.findIndex(
|
|
4200
|
-
(item) => item.uid === fileItem.uid
|
|
4201
|
-
);
|
|
4202
|
-
if (index !== -1) {
|
|
4203
|
-
fileListRef.value.splice(index, 1);
|
|
4204
|
-
}
|
|
4205
|
-
const upload2 = getUpload();
|
|
4206
|
-
if (upload2.removeFile) {
|
|
4207
|
-
upload2.removeFile(fileItem);
|
|
4208
|
-
}
|
|
4209
|
-
};
|
|
4210
|
-
const updateFile = (fileItem) => {
|
|
4211
|
-
const index = fileListRef.value.findIndex(
|
|
4212
|
-
(item) => item.uid === fileItem.uid
|
|
4213
|
-
);
|
|
4214
|
-
if (index !== -1) {
|
|
4215
|
-
fileListRef.value[index] = { ...fileListRef.value[index], ...fileItem };
|
|
4216
|
-
}
|
|
4217
|
-
const upload2 = getUpload();
|
|
4218
|
-
if (upload2.updateFile) {
|
|
4219
|
-
upload2.updateFile(fileItem);
|
|
4220
|
-
}
|
|
4221
|
-
};
|
|
4222
|
-
const setProps = (uploadProps) => {
|
|
4223
|
-
getUpload().setProps(uploadProps);
|
|
4224
|
-
};
|
|
4225
|
-
const methods = {
|
|
4226
|
-
get fileList() {
|
|
4227
|
-
return fileListRef.value;
|
|
4228
|
-
},
|
|
4229
|
-
submit,
|
|
4230
|
-
abort,
|
|
4231
|
-
upload,
|
|
4232
|
-
clearFiles,
|
|
4233
|
-
getFileList,
|
|
4234
|
-
setFileList,
|
|
4235
|
-
addFile,
|
|
4236
|
-
removeFile,
|
|
4237
|
-
updateFile,
|
|
4238
|
-
setProps
|
|
4239
|
-
};
|
|
4240
|
-
return [register, methods];
|
|
4241
|
-
}
|
|
4242
4264
|
function formatDate(date, format = "YYYY-MM-DD HH:mm:ss") {
|
|
4243
4265
|
const d = typeof date === "number" ? new Date(date) : date;
|
|
4244
4266
|
const year = d.getFullYear();
|