zhangwei
2025-08-15 7339b8a9ccf09e6262cb71ac6c9b724cdfa6fe22
src/views/system/dept/utils/hook.tsx
@@ -1,4 +1,4 @@
import dayjs from "dayjs";
// import dayjs from "dayjs";
import editForm from "../form.vue";
import { handleTree } from "@/utils/tree";
import { message } from "@/utils/message";
@@ -15,22 +15,18 @@
  caigourenDelete,
  caigourenBatchDelete
} from "@/api/item/index";
import { usePublicHooks } from "../../hooks";
// import { usePublicHooks } from "../../hooks";
import { addDialog } from "@/components/ReDialog";
import { type Ref, reactive, ref, onMounted, h, computed } from "vue";
import type { FormItemProps } from "../utils/types";
import {
  cloneDeep,
  isAllEmpty,
  deviceDetection,
  getKeyList
} from "@pureadmin/utils";
import { useUserStoreHook } from "@/store/modules/user";
import { type Ref, reactive, ref, onMounted, h } from "vue";
import type { FormItemProps } from "./types";
import { cloneDeep, deviceDetection, getKeyList } from "@pureadmin/utils";
// import { useUserStoreHook } from "@/store/modules/user";
import type { PaginationProps } from "@pureadmin/table";
const nowRole = computed(() => {
  return useUserStoreHook().nowRole;
});
import pdfPreview from "../../component/pdfPreview.vue";
// const nowRole = computed(() => {
//   return useUserStoreHook().nowRole;
// });
const selectedNum = ref(0);
export function useDept(tableRef: Ref) {
@@ -102,7 +98,7 @@
  const formRef = ref();
  const dataList = ref([]);
  const loading = ref(true);
  const { tagStyle } = usePublicHooks();
  // const { tagStyle } = usePublicHooks();
  const getOrderStatus = row => {
    const res = state.orderStatusList.find(item => {
      return row.orderStatus == item.status;
@@ -131,7 +127,7 @@
      label: "项目进度",
      prop: "orderStatus",
      minWidth: 70,
      cellRenderer: ({ row, props }) => getOrderStatus(row)
      cellRenderer: ({ row }) => getOrderStatus(row)
    },
    {
      label: "报名费",
@@ -157,15 +153,13 @@
      label: "质疑",
      prop: "zhiyi",
      minWidth: 100,
      cellRenderer: ({ row, props }) => (
        <span>{row.status === 1 ? "有" : "无"}</span>
      )
      cellRenderer: ({ row }) => <span>{row.status === 1 ? "有" : "无"}</span>
    },
    {
      label: "投诉",
      prop: "tousu",
      minWidth: 100,
      cellRenderer: ({ row, props }) => (
      cellRenderer: ({ row }) => (
        // <el-tag size={props.size} style={tagStyle.value(row.status)}>
        <span>{row.status === 1 ? "有" : "无"}</span>
        // </el-tag>
@@ -200,7 +194,7 @@
      label: "项目进度",
      prop: "orderStatus",
      minWidth: 70,
      cellRenderer: ({ row, props }) => getOrderStatus(row)
      cellRenderer: ({ row }) => getOrderStatus(row)
    },
    {
      label: "报名费",
@@ -226,15 +220,13 @@
      label: "质疑",
      prop: "zhiyi",
      minWidth: 100,
      cellRenderer: ({ row, props }) => (
        <span>{row.status === 1 ? "有" : "无"}</span>
      )
      cellRenderer: ({ row }) => <span>{row.status === 1 ? "有" : "无"}</span>
    },
    {
      label: "投诉",
      prop: "tousu",
      minWidth: 100,
      cellRenderer: ({ row, props }) => (
      cellRenderer: ({ row }) => (
        // <el-tag size={props.size} style={tagStyle.value(row.status)}>
        <span>{row.status === 1 ? "有" : "无"}</span>
        // </el-tag>
@@ -295,9 +287,22 @@
  }
  function resetForm(formEl) {
    if (!formEl) return;
    formEl.resetFields();
    onSearch();
    // if (!formEl) return;
    // formEl.resetFields();
    // onSearch();
    addDialog({
      title: `预览pdf`,
      props: {},
      width: "60%",
      draggable: true,
      fullscreen: deviceDetection(),
      fullscreenIcon: true,
      sureBtnLoading: true,
      closeOnClickModal: false,
      contentRenderer: () => h(pdfPreview, { ref: formRef, formInline: null })
      // jsx 语法 (注意在.vue文件启用jsx语法,需要在script开启lang="tsx")
    });
  }
  const checkboxAsRadio = data => {
    if (data.length > 1) {
@@ -317,7 +322,7 @@
    pagination.pageSize = result.pageSize;
    pagination.currentPage = result.page;
    // if (!isAllEmpty(form.name)) {
    //   // 前端搜索部门名称
    //   // 前端搜索项目名称
    //   newData = newData.filter(item => item.name.includes(form.name));
    // }
    // if (!isAllEmpty(form.status)) {
@@ -328,7 +333,7 @@
  }
  function formatHigherDeptOptions(treeList) {
    // 根据返回数据的status字段值判断追加是否禁用disabled字段,返回处理后的树结构,用于上级部门级联选择器的展示(实际开发中也是如此,不可能前端需要的每个字段后端都会返回,这时需要前端自行根据后端返回的某些字段做逻辑处理)
    // 根据返回数据的status字段值判断追加是否禁用disabled字段,返回处理后的树结构,用于上级项目级联选择器的展示(实际开发中也是如此,不可能前端需要的每个字段后端都会返回,这时需要前端自行根据后端返回的某些字段做逻辑处理)
    if (!treeList || !treeList.length) return;
    const newTreeList = [];
    for (let i = 0; i < treeList.length; i++) {
@@ -340,8 +345,6 @@
  }
  function openDialog(title = "新增", row?: FormItemProps) {
    console.log(row, "-");
    addDialog({
      title: `${title}项目`,
      props: {
@@ -474,9 +477,9 @@
    onSearch,
    /** 重置 */
    resetForm,
    /** 新增、修改部门 */
    /** 新增、修改项目 */
    openDialog,
    /** 删除部门 */
    /** 删除项目 */
    handleDelete,
    handleSelectionChange,
    handleSizeChange,