zhangwei
2025-08-06 60f24769048e3c36f8bdde0ac4649ee6f15df334
'项目管理多选操作'
5个文件已修改
230 ■■■■■ 已修改文件
src/router/modules/item.ts 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/system/dept/form.vue 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/system/dept/index.vue 65 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/system/dept/utils/hook.tsx 161 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/system/dept/utils/types.ts 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/router/modules/item.ts
@@ -13,7 +13,7 @@
      name: "item",
      meta: {
        title: "项目管理",
        roles: ["GYS"]
        roles: ["DLJG", "CGR"]
        // showLink:false
      }
    }
src/views/system/dept/form.vue
@@ -11,6 +11,7 @@
const { state } = useDept();
const props = withDefaults(defineProps<FormProps>(), {
  formInline: () => ({
    id: "",
    projectCode: "", // 项目编号(必填)
    projectName: "", // 项目名称(必填)
    hangyepinmu: null, // 行业品目(可选)
src/views/system/dept/index.vue
@@ -1,5 +1,5 @@
<script setup lang="ts">
import { ref, reactive, onMounted } from "vue";
import { ref, reactive, onMounted, computed } from "vue";
import { useDept } from "./utils/hook";
import { PureTableBar } from "@/components/RePureTableBar";
import { useRenderIcon } from "@/components/ReIcon/src/hooks";
@@ -8,6 +8,7 @@
import EditPen from "~icons/ep/edit-pen";
import Refresh from "~icons/ep/refresh";
import AddFill from "~icons/ri/add-circle-line";
import { useUserStoreHook } from "@/store/modules/user";
defineOptions({
  name: "SystemDept"
@@ -15,11 +16,14 @@
const formRef = ref();
const tableRef = ref();
const {
  form,
  state,
  loading,
  columns,
  CGRcolumns,
  selectedNum,
  dataList,
  onSearch,
  resetForm,
@@ -29,13 +33,18 @@
  handleSizeChange,
  handleCurrentChange,
  pagination,
  checkboxAsRadio
} = useDept();
  checkboxAsRadio,
  onSelectionCancel,
  onbatchDel
} = useDept(tableRef);
function onFullscreen() {
  // 重置表格高度
  tableRef.value.setAdaptive();
}
const nowRole = computed(() => {
  return useUserStoreHook().nowRole;
});
onMounted(() => {});
</script>
@@ -147,11 +156,35 @@
              />
            </el-form-item>
          </el-col>
          <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="4">
          <el-col
            v-if="nowRole.code == 'CGR'"
            :xs="24"
            :sm="12"
            :md="8"
            :lg="6"
            :xl="4"
          >
            <el-form-item label="代理机构:">
              <el-input
                v-model="form.dailijigoumingcheng"
                placeholder="请输入代理机构"
                clearable
                class="w-[100%]!"
              />
            </el-form-item>
          </el-col>
          <el-col
            v-if="nowRole.code == 'DLJG'"
            :xs="24"
            :sm="12"
            :md="8"
            :lg="6"
            :xl="4"
          >
            <el-form-item label="采购人:">
              <el-input
                v-model="form.caigourenmingcheng"
                placeholder="请输入采购人"
                clearable
                class="w-[100%]!"
              />
@@ -196,7 +229,7 @@
    </el-card>
    <PureTableBar
      title=""
      :columns="columns"
      :columns="nowRole.code == 'CGR' ? CGRcolumns : columns"
      :tableRef="tableRef?.getTableRef()"
      @refresh="onSearch"
      @fullscreen="onFullscreen"
@@ -211,6 +244,28 @@
        </el-button>
      </template> -->
      <template v-slot="{ size, dynamicColumns }">
        <div
          v-if="selectedNum > 0"
          v-motion-fade
          class="bg-[var(--el-fill-color-light)] w-full h-[46px] mb-2 pl-4 flex items-center"
        >
          <div class="flex-auto">
            <span
              style="font-size: var(--el-font-size-base)"
              class="text-[rgba(42,46,54,0.5)] dark:text-[rgba(220,220,242,0.5)]"
            >
              已选 {{ selectedNum }} 项
            </span>
            <el-button type="primary" text @click="onSelectionCancel">
              取消选择
            </el-button>
          </div>
          <el-popconfirm title="是否确认删除?" @confirm="onbatchDel">
            <template #reference>
              <el-button type="danger" text class="mr-1!"> 批量删除 </el-button>
            </template>
          </el-popconfirm>
        </div>
        <pure-table
          ref="tableRef"
          adaptive
src/views/system/dept/utils/hook.tsx
@@ -12,15 +12,28 @@
  getDaimaleixingList,
  caigourenAdd,
  caigourenUpdate,
  caigourenDelete
  caigourenDelete,
  caigourenBatchDelete
} from "@/api/item/index";
import { usePublicHooks } from "../../hooks";
import { addDialog } from "@/components/ReDialog";
import { reactive, ref, onMounted, h } from "vue";
import { type Ref, reactive, ref, onMounted, h, computed } from "vue";
import type { FormItemProps } from "../utils/types";
import { cloneDeep, isAllEmpty, deviceDetection } from "@pureadmin/utils";
import {
  cloneDeep,
  isAllEmpty,
  deviceDetection,
  getKeyList
} from "@pureadmin/utils";
import { useUserStoreHook } from "@/store/modules/user";
import type { PaginationProps } from "@pureadmin/table";
export function useDept() {
const nowRole = computed(() => {
  return useUserStoreHook().nowRole;
});
const selectedNum = ref(0);
export function useDept(tableRef: Ref) {
  const form = reactive({
    // 新增日期范围,可为 null,类型为数组
    createDateRange: null,
@@ -38,6 +51,7 @@
    projectName: null,
    // 代理机构名称,可为 null,类型为字符串
    dailijigoumingcheng: null,
    caigourenmingcheng: null,
    // 中标供应商姓名,可为 null,类型为字符串
    zhongbiaoName: null,
    // 专家姓名,可为 null,类型为字符串
@@ -97,15 +111,21 @@
  };
  const columns: TableColumnList = [
    {
      label: "勾选列", // 如果需要表格多选,此处label必须设置
      type: "selection",
      fixed: "left",
      reserveSelection: true // 数据刷新后保留选项
    },
    {
      label: "采购人",
      prop: "caigourenmingcheng",
      minWidth: 70
    },
    {
      label: "项目名称",
      prop: "projectName",
      width: 180,
      align: "left"
    },
    {
      label: "代理机构",
      prop: "dailijigoumingcheng",
      minWidth: 70
    },
    {
      label: "项目进度",
@@ -126,7 +146,7 @@
    {
      label: "中标供应商",
      prop: "zhongbiaoName",
      minWidth: 70
      minWidth: 180
    },
    {
      label: "评审专家",
@@ -154,13 +174,117 @@
    {
      label: "操作",
      fixed: "right",
      width: 210,
      width: 80,
      slot: "operation"
    }
  ];
  const CGRcolumns: TableColumnList = [
    {
      label: "勾选列", // 如果需要表格多选,此处label必须设置
      type: "selection",
      fixed: "left",
      reserveSelection: true // 数据刷新后保留选项
    },
    {
      label: "代理机构",
      prop: "dailijigoumingcheng",
      minWidth: 70
    },
    {
      label: "项目名称",
      prop: "projectName",
      width: 180,
      align: "left"
    },
    {
      label: "项目进度",
      prop: "orderStatus",
      minWidth: 70,
      cellRenderer: ({ row, props }) => getOrderStatus(row)
    },
    {
      label: "报名费",
      prop: "baomingfei",
      minWidth: 70
    },
    {
      label: "投标保证金",
      prop: "toubiaobaozhengjin",
      minWidth: 70
    },
    {
      label: "中标供应商",
      prop: "zhongbiaoName",
      minWidth: 180
    },
    {
      label: "评审专家",
      prop: "zhuanjiaName",
      minWidth: 70
    },
    {
      label: "质疑",
      prop: "zhiyi",
      minWidth: 100,
      cellRenderer: ({ row, props }) => (
        <span>{row.status === 1 ? "有" : "无"}</span>
      )
    },
    {
      label: "投诉",
      prop: "tousu",
      minWidth: 100,
      cellRenderer: ({ row, props }) => (
        // <el-tag size={props.size} style={tagStyle.value(row.status)}>
        <span>{row.status === 1 ? "有" : "无"}</span>
        // </el-tag>
      )
    },
    {
      label: "操作",
      fixed: "right",
      width: 80,
      slot: "operation"
    }
  ];
  /** 当CheckBox选择项发生变化时会触发该事件 */
  function handleSelectionChange(val) {
    console.log("handleSelectionChange", val);
    selectedNum.value = val.length;
    // 重置表格高度
    tableRef.value.setAdaptive();
  }
  /** 取消选择 */
  function onSelectionCancel() {
    selectedNum.value = 0;
    // 用于多选表格,清空用户的选择
    tableRef.value.getTableRef().clearSelection();
  }
  /** 批量删除 */
  async function onbatchDel() {
    // 返回当前选中的行
    const curSelected = tableRef.value.getTableRef().getSelectionRows();
    const data = [];
    curSelected.forEach(item => {
      data.push({ id: item.id });
    });
    const res = await caigourenBatchDelete(data);
    if (res.code == "200") {
      // 接下来根据实际业务,通过选中行的某项数据,比如下面的id,调用接口进行批量删除
      message(
        `已删除项目名称为 ${getKeyList(curSelected, "projectName")} 的数据`,
        {
          type: "success"
        }
      );
      onSearch();
    } else {
      message(res.message, {
        type: "error"
      });
    }
    tableRef.value.getTableRef().clearSelection();
    onSearch();
  }
  function handleSizeChange(val: number) {
    console.log(`${val} items per page`);
@@ -216,13 +340,14 @@
  }
  function openDialog(title = "新增", row?: FormItemProps) {
    console.log(row,'-');
    console.log(row, "-");
    addDialog({
      title: `${title}项目`,
      props: {
        formInline: {
          higherDeptOptions: formatHigherDeptOptions(cloneDeep(dataList.value)),
          id: row?.id ?? "",
          projectCode: row?.projectCode ?? "", // 项目编号(必填)
          projectName: row?.projectName ?? "", // 项目名称(必填)
          hangyepinmu: row?.hangyepinmu ?? null, // 行业品目(可选)
@@ -301,8 +426,6 @@
          } else {
            closeLoading();
            const fail = [];
            console.log(obj);
            for (const key in obj) {
              fail.push(obj[key][0].message);
            }
@@ -344,7 +467,9 @@
    state,
    loading,
    columns,
    CGRcolumns,
    dataList,
    selectedNum,
    /** 搜索 */
    onSearch,
    /** 重置 */
@@ -357,6 +482,8 @@
    handleSizeChange,
    handleCurrentChange,
    pagination,
    checkboxAsRadio
    checkboxAsRadio,
    onSelectionCancel,
    onbatchDel
  };
}
src/views/system/dept/utils/types.ts
@@ -1,4 +1,5 @@
interface FormItemProps {
  id: string;
  projectCode: string; // 项目编号(必填)
  projectName: string; // 项目名称(必填)
  hangyepinmu: any | null; // 行业品目(可选)