From 60f24769048e3c36f8bdde0ac4649ee6f15df334 Mon Sep 17 00:00:00 2001 From: zhangwei <1504152376@qq.com> Date: 星期三, 06 八月 2025 14:59:57 +0800 Subject: [PATCH] '项目管理多选操作' --- src/views/system/dept/utils/hook.tsx | 161 ++++++++++++++++++++++++++++++++++++---- src/views/system/dept/utils/types.ts | 1 src/views/system/dept/index.vue | 65 +++++++++++++++- src/router/modules/item.ts | 2 src/views/system/dept/form.vue | 1 5 files changed, 207 insertions(+), 23 deletions(-) diff --git a/src/router/modules/item.ts b/src/router/modules/item.ts index 7c93c3e..02ecf02 100644 --- a/src/router/modules/item.ts +++ b/src/router/modules/item.ts @@ -13,7 +13,7 @@ name: "item", meta: { title: "椤圭洰绠$悊", - roles: ["GYS"] + roles: ["DLJG", "CGR"] // showLink:false } } diff --git a/src/views/system/dept/form.vue b/src/views/system/dept/form.vue index de51a19..d189790 100644 --- a/src/views/system/dept/form.vue +++ b/src/views/system/dept/form.vue @@ -11,6 +11,7 @@ const { state } = useDept(); const props = withDefaults(defineProps<FormProps>(), { formInline: () => ({ + id: "", projectCode: "", // 椤圭洰缂栧彿锛堝繀濉級 projectName: "", // 椤圭洰鍚嶇О锛堝繀濉級 hangyepinmu: null, // 琛屼笟鍝佺洰锛堝彲閫夛級 diff --git a/src/views/system/dept/index.vue b/src/views/system/dept/index.vue index f156df0..684bc00 100644 --- a/src/views/system/dept/index.vue +++ b/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="浠g悊鏈烘瀯锛�"> <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 diff --git a/src/views/system/dept/utils/hook.tsx b/src/views/system/dept/utils/hook.tsx index 1825877..a0c9b7b 100644 --- a/src/views/system/dept/utils/hook.tsx +++ b/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, // 浠g悊鏈烘瀯鍚嶇О锛屽彲涓� 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: "浠g悊鏈烘瀯", - 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: "浠g悊鏈烘瀯", + 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" } ]; + /** 褰揅heckBox閫夋嫨椤瑰彂鐢熷彉鍖栨椂浼氳Е鍙戣浜嬩欢 */ 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锛岃皟鐢ㄦ帴鍙h繘琛屾壒閲忓垹闄� + 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 }; } diff --git a/src/views/system/dept/utils/types.ts b/src/views/system/dept/utils/types.ts index cbf0301..3e0eca8 100644 --- a/src/views/system/dept/utils/types.ts +++ b/src/views/system/dept/utils/types.ts @@ -1,4 +1,5 @@ interface FormItemProps { + id: string; projectCode: string; // 椤圭洰缂栧彿锛堝繀濉級 projectName: string; // 椤圭洰鍚嶇О锛堝繀濉級 hangyepinmu: any | null; // 琛屼笟鍝佺洰锛堝彲閫夛級 -- Gitblit v1.9.1