From 3324a54fa4d0840f8a5dc8adb21753180ecd3f3c Mon Sep 17 00:00:00 2001 From: zhangwei <1504152376@qq.com> Date: 星期二, 02 九月 2025 14:25:06 +0800 Subject: [PATCH] 公告信息页面 --- src/views/home/utils/hook.tsx | 157 ++++++++++++++++++++++++++++++++++++++++++++------- 1 files changed, 134 insertions(+), 23 deletions(-) diff --git a/src/views/home/utils/hook.tsx b/src/views/home/utils/hook.tsx index dd2df48..9cf3975 100644 --- a/src/views/home/utils/hook.tsx +++ b/src/views/home/utils/hook.tsx @@ -1,5 +1,8 @@ -import { onMounted, reactive } from "vue"; +import { reactive, ref, onMounted, h, toRaw, watch } from "vue"; import { useRoute, useRouter } from "vue-router"; +import dayjs from "dayjs"; +import { message } from "@/utils/message"; +import type { PaginationProps } from "@pureadmin/table"; import { pageGonggao, pageGengzgeng, @@ -7,7 +10,8 @@ neirongfabuDetail, shouyeOrder, shouyeChangeOrder, - feizhengfuDetail + feizhengfuDetail, + pageZhongbiaoGonggao } from "@/api/item/shouye"; const convertFujianToObjects = (fujianStr, fujianNameStr) => { // 鍒嗗壊瀛楃涓蹭负鏁扮粍骞惰繃婊ょ┖鍊� @@ -44,20 +48,15 @@ shouyeZhongbiaoOrderList: [], shouyeOrderList: [], active: 0, - gonggaoDetail: {} + activeList: 0, + gonggaoDetail: {}, + gonggaoList: [ + { name: "鎷涢噰鍏憡" }, + { name: "鏇存鍏憡" }, + { name: "缁撴灉鍏憡" } + // { name: "鍏朵粬鍏憡" } + ] }); - async function getPageGonggao() { - const res = await pageGonggao(); - stateHook.pageGonggaoList = res.result; - } - async function getPageGengzgeng() { - const res = await pageGengzgeng(); - stateHook.pageGonggaoList = res.result; - } - async function getShouyeZhongbiaoOrder() { - const res = await shouyeZhongbiaoOrder(); - stateHook.shouyeZhongbiaoOrderList = res.result; - } async function getNeirongfabuDetail(data) { const res = await neirongfabuDetail(data); stateHook.pageGonggaoList = res.result; @@ -88,6 +87,9 @@ break; } } + async function getOrderList(active) { + stateHook.activeList = active; + } async function getShouyeChangeOrder() { const res = await shouyeChangeOrder(); stateHook.shouyeOrderList = res.result; @@ -95,21 +97,130 @@ function goDetail(id) { router.push({ name: "gonggaoDetail", query: { id } }); } - onMounted(() => { - console.log("---"); - // getNeirongfabuDetail(); - // getPageGonggao(); - // getPageGengzgeng(); - // getShouyeZhongbiaoOrder(); + const form = reactive({ + keyword: "", + createDateRange: "" }); + const curRow = ref(); + const dataList = ref([]); + const loading = ref(true); + + const pagination = reactive<PaginationProps>({ + total: 0, + pageSize: 10, + currentPage: 1, + background: true + }); + const columns: TableColumnList = [ + { + label: "鍖哄煙", + prop: "xingzhengquyuName", + minWidth: 80 + }, + { + label: "閲囪喘鏂瑰紡", + prop: "caigoufangshiName", + width: 100 + }, + { + label: "鍚嶇О", + prop: "projectName", + minWidth: 100 + }, + { + label: "鍙戝竷鏃堕棿", + prop: "fabuDate", + width: 160, + formatter: ({ fabuDate }) => dayjs(fabuDate).format("YYYY-MM-DD HH:mm:ss") + } + ]; + + function handleDelete(row) { + message(`鎮ㄥ垹闄や簡瑙掕壊鍚嶇О涓�${row.name}鐨勮繖鏉℃暟鎹甡, { type: "success" }); + onSearch(); + } + + function handleSizeChange(val: number) { + console.log(`${val} items per page`); + } + + function handleCurrentChange(val: number) { + console.log(`current page: ${val}`); + } + + function handleSelectionChange(val) { + console.log("handleSelectionChange", val); + } + + async function onSearch() { + loading.value = true; + let res; + switch (stateHook.activeList) { + case 0: + res = await pageGonggao(form); + break; + case 1: + res = await pageGengzgeng(form); + break; + case 2: + res = await pageZhongbiaoGonggao(form); + break; + } + const { result } = res; + // dataList.value = data.list; + dataList.value = result.items; + loading.value = false; + pagination.total = result.total; + pagination.pageSize = result.pageSize; + pagination.currentPage = result.page; + + // setTimeout(() => { + // loading.value = false; + // }, 500); + } + + const resetForm = formEl => { + if (!formEl) return; + formEl.resetFields(); + onSearch(); + }; + + /** 楂樹寒褰撳墠鏉冮檺閫変腑琛� */ + function rowStyle({ row: { id } }) { + return { + cursor: "pointer", + background: id === curRow.value?.id ? "var(--el-fill-color-light)" : "" + }; + } + + onMounted(async () => { + onSearch(); + // const { data } = await getRoleMenu(); + // treeIds.value = getKeyList(data, "id"); + // treeData.value = handleTree(data); + }); + return { stateHook, - getPageGonggao, getShouyeOrder, getNeirongfabuDetail, goDetail, route, router, - getFeizhengfuDetail + getFeizhengfuDetail, + getOrderList, + form, + curRow, + loading, + columns, + rowStyle, + dataList, + pagination, + onSearch, + resetForm, + handleDelete, + handleSizeChange, + handleCurrentChange, + handleSelectionChange }; } -- Gitblit v1.9.1