From 9b522d5a943525698d57f919a93b2af8cda608a8 Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期三, 05 十一月 2025 10:01:00 +0800
Subject: [PATCH] 通知公告-加一个时间限制,过时后状态改为已过期
---
src/views/collaborativeApproval/noticeManagement/index.vue | 100 ++++++++++++++++++++++++++++++--------------------
1 files changed, 60 insertions(+), 40 deletions(-)
diff --git a/src/views/collaborativeApproval/noticeManagement/index.vue b/src/views/collaborativeApproval/noticeManagement/index.vue
index 16cee35..77bc697 100644
--- a/src/views/collaborativeApproval/noticeManagement/index.vue
+++ b/src/views/collaborativeApproval/noticeManagement/index.vue
@@ -2,30 +2,6 @@
<div class="app-container">
<!-- 鎼滅储琛ㄥ崟 -->
<div class="search_form">
- <!-- <div>-->
- <!-- <span class="search_title">鍏憡鏍囬锛�</span>-->
- <!-- <el-input-->
- <!-- v-model="searchForm.title"-->
- <!-- style="width: 240px"-->
- <!-- placeholder="璇疯緭鍏ュ叕鍛婃爣棰樻悳绱�"-->
- <!-- @change="handleQuery"-->
- <!-- clearable-->
- <!-- :prefix-icon="Search"-->
- <!-- />-->
- <!-- <span class="search_title ml10">鍏憡绫诲瀷锛�</span>-->
- <!-- <el-select v-model="searchForm.type" clearable @change="handleQuery" style="width: 240px">-->
- <!-- <el-option label="鏀惧亣閫氱煡" :value="1"/>-->
- <!-- <el-option label="璁惧缁翠慨閫氱煡" :value="2"/>-->
- <!-- </el-select>-->
- <!-- <span class="search_title ml10">鐘舵�侊細</span>-->
- <!-- <el-select v-model="searchForm.status" clearable @change="handleQuery" style="width: 240px">-->
- <!-- <el-option label="鑽夌" :value="0"/>-->
- <!-- <el-option label="宸插彂甯�" :value="1"/>-->
- <!-- <el-option label="宸蹭笅绾�" :value="2"/>-->
- <!-- </el-select>-->
- <!-- <el-button type="primary" @click="handleQuery" style="margin-left: 10px">鎼滅储</el-button>-->
- <!-- <el-button @click="resetQuery" style="margin-left: 10px">閲嶇疆</el-button>-->
- <!-- </div>-->
<div>
<el-button type="primary" @click="openForm('add')">鏂板鍏憡</el-button>
<el-button type="danger" plain @click="handleDelete" :disabled="!selectedIds.length">鍒犻櫎</el-button>
@@ -55,7 +31,7 @@
{{ notice.title }}
</div>
<div class="card-actions">
- <el-button link type="primary" @click="handleEdit(notice)">缂栬緫</el-button>
+ <el-button link type="primary" @click="handleEdit(notice)" :disabled="isNoticeExpired(notice)">缂栬緫</el-button>
<el-button link type="danger" @click="handleDelete(notice.id)">鍒犻櫎</el-button>
</div>
</div>
@@ -67,13 +43,13 @@
<span class="priority" :class="'priority-' + notice.priority">
{{ getPriorityText(notice.priority) }}
</span>
- <span class="status" :class="'status-' + notice.status">
- {{ getStatusText(notice.status) }}
+ <span class="status" :class="'status-' + getNoticeStatus(notice)">
+ {{ getStatusText(getNoticeStatus(notice)) }}
</span>
</div>
<div class="card-info">
<span class="creator">{{ notice.createUserName }}</span>
- <span class="time">{{ notice.createTime }}</span>
+ <span class="expiration" v-if="notice.expirationDate">鎴鏃ユ湡锛歿{ notice.expirationDate }}</span>
</div>
</div>
<div class="card-remark" v-if="notice.remark">
@@ -115,7 +91,7 @@
{{ notice.title }}
</div>
<div class="card-actions">
- <el-button link type="primary" @click="handleEdit(notice)">缂栬緫</el-button>
+ <el-button link type="primary" @click="handleEdit(notice)" :disabled="isNoticeExpired(notice)">缂栬緫</el-button>
<el-button link type="danger" @click="handleDelete(notice.id)">鍒犻櫎</el-button>
</div>
</div>
@@ -127,13 +103,13 @@
<span class="priority" :class="'priority-' + notice.priority">
{{ getPriorityText(notice.priority) }}
</span>
- <span class="status" :class="'status-' + notice.status">
- {{ getStatusText(notice.status) }}
+ <span class="status" :class="'status-' + getNoticeStatus(notice)">
+ {{ getStatusText(getNoticeStatus(notice)) }}
</span>
</div>
<div class="card-info">
<span class="creator">{{ notice.createUserName }}</span>
- <span class="time">{{ notice.createTime }}</span>
+ <span class="expiration" v-if="notice.expirationDate">鎴鏃ユ湡锛歿{ notice.expirationDate }}</span>
</div>
</div>
<div class="card-remark" v-if="notice.remark">
@@ -189,8 +165,7 @@
<el-form-item label="鐘舵��">
<el-radio-group v-model="form.status">
<el-radio :value="0">鑽夌</el-radio>
- <el-radio :value="1">宸插彂甯�</el-radio>
- <el-radio :value="2">宸蹭笅绾�</el-radio>
+ <el-radio :value="1">姝e紡鍙戝竷</el-radio>
</el-radio-group>
</el-form-item>
</el-col>
@@ -205,8 +180,16 @@
</el-col>
</el-row>
<el-row>
+ <el-col :span="12">
+ <el-form-item label="杩囨湡鏃堕棿" prop="expirationDate">
+ <el-date-picker v-model="form.expirationDate" value-format="YYYY-MM-DD" format="YYYY-MM-DD" type="date"
+ placeholder="璇烽�夋嫨" clearable />
+ </el-form-item>
+ </el-col>
+ </el-row>
+ <el-row>
<el-col :span="24">
- <el-form-item label="鍏憡鍐呭" prop="noticeContent">
+ <el-form-item label="鍏憡鍐呭" prop="content">
<el-input
v-model="form.content"
type="textarea"
@@ -274,6 +257,7 @@
status: 0,
priority: 1,
remark: "",
+ expirationDate: "",
},
rules: {
title: [
@@ -284,6 +268,9 @@
],
content: [
{required: true, message: "鍏憡鍐呭涓嶈兘涓虹┖", trigger: "blur"}
+ ],
+ expirationDate: [
+ {required: true, message: "璇烽�夋嫨鏃ユ湡", trigger: "change"}
]
}
});
@@ -339,8 +326,32 @@
};
const getStatusText = (status) => {
- const statusMap = {"0": "鑽夌", "1": "宸插彂甯�", "2": "宸蹭笅绾�"};
+ const statusMap = {"0": "鑽夌", "1": "宸插彂甯�", "2": "宸茶繃鏈�"};
return statusMap[status] || "鏈煡";
+};
+
+const isNoticeExpired = (notice) => {
+ if (!notice || !notice.expirationDate) {
+ return false;
+ }
+
+ const expiration = new Date(notice.expirationDate);
+
+ if (Number.isNaN(expiration.getTime())) {
+ return false;
+ }
+
+ expiration.setHours(23, 59, 59, 999);
+
+ return new Date() > expiration;
+};
+
+const getNoticeStatus = (notice) => {
+ const normalizedStatus = notice && notice.status !== undefined && notice.status !== null
+ ? String(notice.status)
+ : "0";
+
+ return isNoticeExpired(notice) ? "2" : normalizedStatus;
};
const openForm = (type) => {
@@ -354,12 +365,17 @@
status: 0,
priority: 1,
remark: "",
+ expirationDate: "",
};
}
dialogVisible.value = true;
};
const handleEdit = (row) => {
+ if (isNoticeExpired(row)) {
+ ElMessage.warning("宸茶繃鏈熺殑鍏憡涓嶅彲缂栬緫");
+ return;
+ }
dialogTitle.value = "缂栬緫鍏憡";
form.value = {...row};
dialogVisible.value = true;
@@ -421,13 +437,13 @@
const holidayNoticePage = ref({
total: 0,
current: 1,
- size: 6
+ size: 9
})
const maintenanceNoticePage = ref({
total: 0,
current: 1,
- size: 6
+ size: 9
})
const fetchHolidayNotices = () => {
@@ -458,9 +474,9 @@
const resetTable = () => {
holidayNoticePage.value.current = 1
- holidayNoticePage.value.size = 6
+ holidayNoticePage.value.size = 9
maintenanceNoticePage.value.current = 1
- maintenanceNoticePage.value.size = 6
+ maintenanceNoticePage.value.size = 9
fetchHolidayNotices()
fetchMaintenanceNotices()
fetchCount()
@@ -672,6 +688,10 @@
margin-bottom: 2px;
}
+.expiration {
+ margin-top: 2px;
+}
+
.card-remark {
display: flex;
align-items: center;
--
Gitblit v1.9.3