zhangwei
2025-08-28 06e4c8c1bad514992186d94a65c0dc6250e34716
src/views/system/dept/utils/detail.tsx
@@ -16,8 +16,44 @@
} 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) {
@@ -65,9 +101,10 @@
                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();
@@ -96,9 +133,10 @@
            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();
@@ -245,14 +283,14 @@
    );
    // 拼接时间戳和随机数
    return (
      `${dirPath}${filename}${timestamp}_${randomNumber}` +
      filename.match(/\.[^.]+$/)
      `${dirPath}${timestamp}_${randomNumber}` + filename.match(/\.[^.]+$/)
    );
  }
  return {
    openUploadDialog,
    state,
    generateTimestampWithRandom,
    changeDialog
    changeDialog,
    getDetailList
  };
}