| | |
| | | } from "@/api/item/index"; |
| | | |
| | | const formRef = ref(); |
| | | const convertFujianToObjects = (fujianStr, fujianNameStr) => { |
| | | // 分割字符串为数组并过滤空值 |
| | | const srcArray = fujianStr.split(",").filter(Boolean); |
| | | const nameArray = fujianNameStr.split(",").filter(Boolean); |
| | | |
| | | // 提取文件后缀作为valu |
| | | const getFileExtension = fileName => { |
| | | const lastDotIndex = fileName.lastIndexOf("."); |
| | | // 如果没有后缀或文件名以点结尾,返回空字符串 |
| | | if (lastDotIndex === -1 || lastDotIndex === fileName.length - 1) { |
| | | return ""; |
| | | } |
| | | return fileName.slice(lastDotIndex + 1).toLowerCase(); |
| | | }; |
| | | |
| | | // 映射为目标对象数组 |
| | | return srcArray.map((src, index) => { |
| | | // 确保名称数组有对应索引的元素 |
| | | const name = nameArray[index]?.trim() || `未知文件${index + 1}`; |
| | | |
| | | return { |
| | | name: name, |
| | | filePath: src.trim(), |
| | | fileType: getFileExtension(name) |
| | | }; |
| | | }); |
| | | }; |
| | | export function useDetail() { |
| | | async function getDetailList(id) { |
| | | const res = await getTenderOrderDetail({ id }); |
| | | state.nowInfo = res.result; |
| | | if (state.nowInfo.fujian) { |
| | | state.nowInfo.fujianList = convertFujianToObjects( |
| | | state.nowInfo.fujian, |
| | | state.nowInfo.fujianName |
| | | ); |
| | | } |
| | | } |
| | | async function openUploadDialog(title = "上传", row?: TenderInfo) { |
| | | const detail = await changeDetail({ id: row.id }); |
| | | if (detail.result) { |
| | |
| | | console.log(options, index, button); |
| | | cHangeDelete({ id: row?.id }).then(res => { |
| | | if (res.code == "200") { |
| | | getTenderOrderDetail({ id: row?.tenderId }).then(res => { |
| | | state.nowInfo = res.result; |
| | | }); |
| | | getDetailList(row?.tenderId); |
| | | // getTenderOrderDetail({ id: row?.tenderId }).then(res => { |
| | | // state.nowInfo = res.result; |
| | | // }); |
| | | closeDialog(options, index); // 关闭弹框 |
| | | } else { |
| | | // closeLoading(); |
| | |
| | | res = await changezhaobiao(curData); |
| | | } |
| | | if (res.code == "200") { |
| | | getTenderOrderDetail({ id: row?.id }).then(res => { |
| | | state.nowInfo = res.result; |
| | | }); |
| | | getDetailList(row?.id); |
| | | // getTenderOrderDetail({ id: row?.id }).then(res => { |
| | | // state.nowInfo = res.result; |
| | | // }); |
| | | done(); // 关闭弹框 |
| | | } else { |
| | | closeLoading(); |
| | |
| | | ); |
| | | // 拼接时间戳和随机数 |
| | | return ( |
| | | `${dirPath}${filename}${timestamp}_${randomNumber}` + |
| | | filename.match(/\.[^.]+$/) |
| | | `${dirPath}${timestamp}_${randomNumber}` + filename.match(/\.[^.]+$/) |
| | | ); |
| | | } |
| | | return { |
| | | openUploadDialog, |
| | | state, |
| | | generateTimestampWithRandom, |
| | | changeDialog |
| | | changeDialog, |
| | | getDetailList |
| | | }; |
| | | } |