'-'
zhangwei
2025-07-29 2aa2da6ff94c0e88e7ba0638606881a3c04cf579
src/views/system/dept/utils/hook.tsx
@@ -11,6 +11,7 @@
  getRegionList,
  getDaimaleixingList,
  caigourenAdd,
  caigourenUpdate,
  caigourenDelete
} from "@/api/item/index";
import { usePublicHooks } from "../../hooks";
@@ -24,15 +25,15 @@
    // 新增日期范围,可为 null,类型为数组
    createDateRange: null,
    // 行政区域,可为 null,类型为字符串
    xingzhengquyu: "",
    xingzhengquyu: [],
    // 行业品目,可为 null,类型为字符串
    hangyepinmu: "",
    // 订单状态,可为 null,类型为 32 位整数
    orderStatus: "",
    // 质疑有无,可为 null,类型为布尔值
    zhiyi: null,
    zhiyi: [],
    // 投诉有无,可为 null,类型为布尔值
    tousu: null,
    tousu: [],
    // 项目名称,可为 null,类型为字符串
    projectName: null,
    // 代理机构名称,可为 null,类型为字符串
@@ -48,6 +49,12 @@
    orderStatusList: [],
    regionList: [],
    daimaleixingList: []
  });
  const pagination = reactive<PaginationProps>({
    total: 0,
    pageSize: 10,
    currentPage: 1,
    background: true
  });
  //获取采购方式
  const getCaigoufangshiListFun = async () => {
@@ -86,7 +93,7 @@
    const res = state.orderStatusList.find(item => {
      return row.orderStatus == item.status;
    });
    return res.label;
    return res?.label;
  };
  const columns: TableColumnList = [
    {
@@ -155,18 +162,36 @@
  function handleSelectionChange(val) {
    console.log("handleSelectionChange", val);
  }
  function handleSizeChange(val: number) {
    console.log(`${val} items per page`);
  }
  function handleCurrentChange(val: number) {
    console.log(`current page: ${val}`);
  }
  function resetForm(formEl) {
    if (!formEl) return;
    formEl.resetFields();
    onSearch();
  }
  const checkboxAsRadio = data => {
    if (data.length > 1) {
      data.shift();
    }
  };
  async function onSearch() {
    loading.value = true;
    const { result } = await zhaobiaoPageOrder(form); // 这里是返回一维数组结构,前端自行处理成树结构,返回格式要求:唯一id加父节点parentId,parentId取父节点id
    const obj = cloneDeep(form);
    obj.tousu = obj.tousu.join("");
    obj.zhiyi = obj.zhiyi.join("");
    obj.xingzhengquyu = obj.xingzhengquyu.join("");
    const { result } = await zhaobiaoPageOrder(obj); // 这里是返回一维数组结构,前端自行处理成树结构,返回格式要求:唯一id加父节点parentId,parentId取父节点id
    const newData = result.items;
    loading.value = false;
    pagination.total = result.total;
    pagination.pageSize = result.pageSize;
    pagination.currentPage = result.page;
    // if (!isAllEmpty(form.name)) {
    //   // 前端搜索部门名称
    //   newData = newData.filter(item => item.name.includes(form.name));
@@ -209,7 +234,7 @@
          shifoufenbao: row?.shifoufenbao ?? false, // 是否分包(可选)
          shifoutuisongxuanchuan: row?.shifoutuisongxuanchuan ?? true, // 是否推送宣传(可选)
          caigourenmingcheng: row?.caigourenmingcheng ?? null, // 采购人名称(可选)
          xingzhengquyu: row?.xingzhengquyu ?? null, // 行政区域(可选)
          xingzhengquyu: row?.xingzhengquyu.split(",") ?? [], // 行政区域(可选)
          xingzhengquyuName: row?.xingzhengquyuName ?? null, // 行政区域名称(可选)
          jigoudaima: row?.jigoudaima ?? null, // 机构代码(可选)
          daimaleixing: row?.daimaleixing ?? null, // 代码类型(可选)
@@ -237,12 +262,19 @@
      contentRenderer: () => h(editForm, { ref: formRef, formInline: null }),
      beforeSure: (done, { options }) => {
        const FormRef = formRef.value.getRef();
        const curData = options.props.formInline as FormItemProps;
        const curData = cloneDeep(options.props.formInline as FormItemProps);
        async function chores() {
          message(`您${title}了项目名称为${curData.projectName}的这条数据`, {
            type: "success"
          });
          const res = await caigourenAdd(curData);
          // curData.dingbiaoguize = curData.dingbiaoguize.join("");
          curData.xingzhengquyu = curData.xingzhengquyu.join(",");
          let res;
          if (title == "新增") {
            res = await caigourenAdd(curData);
          } else {
            res = await caigourenUpdate(curData);
          }
          if (res.code == "200") {
            done(); // 关闭弹框
            onSearch(); // 刷新表格数据
@@ -306,6 +338,10 @@
    openDialog,
    /** 删除部门 */
    handleDelete,
    handleSelectionChange
    handleSelectionChange,
    handleSizeChange,
    handleCurrentChange,
    pagination,
    checkboxAsRadio
  };
}