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