| | |
| | | // 然后将数组转为对象数组
|
| | | fileList.value = list.map((item) => {
|
| | | if (typeof item === "string") {
|
| | | if (item.indexOf(baseUrl) === -1 && !isExternal(item)) {
|
| | | item = { name: baseUrl + item, url: baseUrl + item };
|
| | | const url =
|
| | | item.indexOf(baseUrl) === -1 && !isExternal(item)
|
| | | ? baseUrl + item
|
| | | : item;
|
| | | item = { name: getFileName(url), url };
|
| | | } else {
|
| | | item = { name: item, url: item };
|
| | | item = { ...item };
|
| | | if (!item.name) {
|
| | | item.name = getFileName(item.url || item.name || "");
|
| | | }
|
| | | }
|
| | | return item;
|
| | |
| | | const findex = fileList.value.map((f) => f.name).indexOf(file.name);
|
| | | if (findex > -1 && uploadList.value.length === number.value) {
|
| | | fileList.value.splice(findex, 1);
|
| | | emit("update:modelValue", listToString(fileList.value));
|
| | | emit("update:modelValue", fileList.value);
|
| | | return false;
|
| | | }
|
| | | }
|
| | |
| | | .concat(uploadList.value);
|
| | | uploadList.value = [];
|
| | | number.value = 0;
|
| | | emit("update:modelValue", listToString(fileList.value));
|
| | | emit("update:modelValue", fileList.value);
|
| | | proxy.$modal.closeLoading();
|
| | | }
|
| | | }
|
| | |
| | | dialogVisible.value = true;
|
| | | }
|
| | |
|
| | | // 对象转成指定字符串分隔
|
| | | function listToString(list, separator) {
|
| | | let strs = "";
|
| | | separator = separator || ",";
|
| | | for (let i in list) {
|
| | | if (undefined !== list[i].url && list[i].url.indexOf("blob:") !== 0) {
|
| | | strs += list[i].url.replace(baseUrl, "") + separator;
|
| | | // 获取文件名
|
| | | function getFileName(name) {
|
| | | if (!name) return "";
|
| | | if (name.lastIndexOf("/") > -1) {
|
| | | return name.slice(name.lastIndexOf("/") + 1);
|
| | | }
|
| | | }
|
| | | return strs != "" ? strs.substr(0, strs.length - 1) : "";
|
| | | return name;
|
| | | }
|
| | |
|
| | | // 初始化拖拽排序
|