From 3f15d0eef89e52f3fd6d1be13ff3af010b6f0ee9 Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期三, 05 十一月 2025 15:27:44 +0800
Subject: [PATCH] 录入日期改为可选择
---
src/views/collaborativeApproval/noticeManagement/index.vue | 556 +++++++++++++++++++++++++++++--------------------------
1 files changed, 291 insertions(+), 265 deletions(-)
diff --git a/src/views/collaborativeApproval/noticeManagement/index.vue b/src/views/collaborativeApproval/noticeManagement/index.vue
index daa4cd7..77bc697 100644
--- a/src/views/collaborativeApproval/noticeManagement/index.vue
+++ b/src/views/collaborativeApproval/noticeManagement/index.vue
@@ -3,30 +3,6 @@
<!-- 鎼滅储琛ㄥ崟 -->
<div class="search_form">
<div>
- <span class="search_title">鍏憡鏍囬锛�</span>
- <el-input
- v-model="searchForm.noticeTitle"
- style="width: 240px"
- placeholder="璇疯緭鍏ュ叕鍛婃爣棰樻悳绱�"
- @change="handleQuery"
- clearable
- :prefix-icon="Search"
- />
- <span class="search_title ml10">鍏憡绫诲瀷锛�</span>
- <el-select v-model="searchForm.noticeType" 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>
</div>
@@ -35,127 +11,151 @@
<!-- 閫氱煡鍏憡鏉� -->
<div class="notice-board">
<!-- 鏀惧亣閫氱煡鍖哄煙 -->
- <div class="notice-section" v-if="holidayNotices.length > 0">
+ <div class="notice-section" v-if="holidayNoticeCount > 0">
<div class="section-header">
<h3>馃搮 鏀惧亣閫氱煡</h3>
- <span class="section-count">{{ holidayNotices.length }}鏉�</span>
+ <span class="section-count">{{ holidayNoticeCount }}鏉�</span>
</div>
<div class="notice-cards">
- <div
- v-for="notice in holidayNotices"
- :key="notice.id"
- class="notice-card holiday-card"
- :class="{ 'urgent': notice.priority === '3' }"
+ <div
+ v-for="notice in holidayNotices"
+ :key="notice.id"
+ class="notice-card holiday-card"
+ :class="{ 'urgent': notice.priority === '3' }"
>
<div class="card-header">
<div class="card-title">
- <el-icon class="holiday-icon"><Calendar /></el-icon>
- {{ notice.noticeTitle }}
+ <el-icon class="holiday-icon">
+ <Calendar/>
+ </el-icon>
+ {{ 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>
<div class="card-content">
- <p>{{ notice.noticeContent }}</p>
+ <p>{{ notice.content }}</p>
</div>
<div class="card-footer">
<div class="card-meta">
<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.createBy }}</span>
- <span class="time">{{ notice.createTime }}</span>
+ <span class="creator">{{ notice.createUserName }}</span>
+ <span class="expiration" v-if="notice.expirationDate">鎴鏃ユ湡锛歿{ notice.expirationDate }}</span>
</div>
</div>
<div class="card-remark" v-if="notice.remark">
- <el-icon><InfoFilled /></el-icon>
+ <el-icon>
+ <InfoFilled/>
+ </el-icon>
<span>{{ notice.remark }}</span>
</div>
</div>
</div>
</div>
+
+ <pagination
+ v-if="holidayNoticePage.total > 0"
+ :total="holidayNoticePage.total"
+ :page="holidayNoticePage.current"
+ :limit="holidayNoticePage.size"
+ @pagination="handleHolidayNoticeCurrentChange"
+ />
<!-- 璁惧缁翠慨閫氱煡鍖哄煙 -->
- <div class="notice-section" v-if="maintenanceNotices.length > 0">
+ <div class="notice-section" v-if="maintenanceNoticeCount > 0">
<div class="section-header">
<h3>馃敡 璁惧缁翠慨閫氱煡</h3>
- <span class="section-count">{{ maintenanceNotices.length }}鏉�</span>
+ <span class="section-count">{{ maintenanceNoticeCount }}鏉�</span>
</div>
<div class="notice-cards">
- <div
- v-for="notice in maintenanceNotices"
- :key="notice.id"
- class="notice-card maintenance-card"
- :class="{ 'urgent': notice.priority === '3' }"
+ <div
+ v-for="notice in maintenanceNotices"
+ :key="notice.id"
+ class="notice-card maintenance-card"
+ :class="{ 'urgent': notice.priority === '3' }"
>
<div class="card-header">
<div class="card-title">
- <el-icon class="maintenance-icon"><Tools /></el-icon>
- {{ notice.noticeTitle }}
+ <el-icon class="maintenance-icon">
+ <Tools/>
+ </el-icon>
+ {{ 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>
<div class="card-content">
- <p>{{ notice.noticeContent }}</p>
+ <p>{{ notice.content }}</p>
</div>
<div class="card-footer">
<div class="card-meta">
<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.createBy }}</span>
- <span class="time">{{ notice.createTime }}</span>
+ <span class="creator">{{ notice.createUserName }}</span>
+ <span class="expiration" v-if="notice.expirationDate">鎴鏃ユ湡锛歿{ notice.expirationDate }}</span>
</div>
</div>
<div class="card-remark" v-if="notice.remark">
- <el-icon><InfoFilled /></el-icon>
+ <el-icon>
+ <InfoFilled/>
+ </el-icon>
<span>{{ notice.remark }}</span>
</div>
</div>
</div>
</div>
+ <pagination
+ v-if="maintenanceNoticePage.total > 0"
+ :total="maintenanceNoticePage.total"
+ :page="maintenanceNoticePage.current"
+ :limit="maintenanceNoticePage.size"
+ @pagination="handleMaintenanceNoticeCurrentChange"
+ />
+
<!-- 绌虹姸鎬� -->
- <div class="empty-state" v-if="filteredNotices.length === 0">
- <el-empty description="鏆傛棤閫氱煡鍏憡" />
+ <div class="empty-state" v-if="holidayNotices.length === 0 && maintenanceNotices.length === 0">
+ <el-empty description="鏆傛棤閫氱煡鍏憡"/>
</div>
</div>
<!-- 鏂板/缂栬緫瀵硅瘽妗� -->
- <el-dialog
- :title="dialogTitle"
- v-model="dialogVisible"
- width="800px"
- append-to-body
- @close="resetForm"
+ <el-dialog
+ :title="dialogTitle"
+ v-model="dialogVisible"
+ width="800px"
+ append-to-body
+ @close="resetForm"
>
<el-form ref="formRef" :model="form" :rules="rules" label-width="100px">
<el-row>
<el-col :span="12">
- <el-form-item label="鍏憡鏍囬" prop="noticeTitle">
- <el-input v-model="form.noticeTitle" placeholder="璇疯緭鍏ュ叕鍛婃爣棰�" />
+ <el-form-item label="鍏憡鏍囬" prop="title">
+ <el-input v-model="form.title" placeholder="璇疯緭鍏ュ叕鍛婃爣棰�"/>
</el-form-item>
</el-col>
<el-col :span="12">
- <el-form-item label="鍏憡绫诲瀷" prop="noticeType">
- <el-select v-model="form.noticeType" placeholder="璇烽�夋嫨鍏憡绫诲瀷" style="width: 100%">
- <el-option label="鏀惧亣閫氱煡" value="1" />
- <el-option label="璁惧缁翠慨閫氱煡" value="2" />
+ <el-form-item label="鍏憡绫诲瀷" prop="type">
+ <el-select v-model="form.type" placeholder="璇烽�夋嫨鍏憡绫诲瀷" style="width: 100%">
+ <el-option label="鏀惧亣閫氱煡" :value="1"/>
+ <el-option label="璁惧缁翠慨閫氱煡" :value="2"/>
</el-select>
</el-form-item>
</el-col>
@@ -164,32 +164,39 @@
<el-col :span="12">
<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="0">鑽夌</el-radio>
+ <el-radio :value="1">姝e紡鍙戝竷</el-radio>
</el-radio-group>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="浼樺厛绾�">
<el-select v-model="form.priority" placeholder="璇烽�夋嫨浼樺厛绾�" style="width: 100%">
- <el-option label="鏅��" value="1" />
- <el-option label="閲嶈" value="2" />
- <el-option label="绱ф��" value="3" />
+ <el-option label="鏅��" :value="1"/>
+ <el-option label="閲嶈" :value="2"/>
+ <el-option label="绱ф��" :value="3"/>
</el-select>
</el-form-item>
</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.noticeContent"
- type="textarea"
- :rows="6"
- placeholder="璇疯緭鍏ュ叕鍛婂唴瀹�"
- maxlength="500"
- show-word-limit
+ v-model="form.content"
+ type="textarea"
+ :rows="6"
+ placeholder="璇疯緭鍏ュ叕鍛婂唴瀹�"
+ maxlength="500"
+ show-word-limit
/>
</el-form-item>
</el-col>
@@ -198,12 +205,12 @@
<el-col :span="24">
<el-form-item label="澶囨敞">
<el-input
- v-model="form.remark"
- type="textarea"
- :rows="3"
- placeholder="璇疯緭鍏ュ娉ㄤ俊鎭�"
- maxlength="200"
- show-word-limit
+ v-model="form.remark"
+ type="textarea"
+ :rows="3"
+ placeholder="璇疯緭鍏ュ娉ㄤ俊鎭�"
+ maxlength="200"
+ show-word-limit
/>
</el-form-item>
</el-col>
@@ -220,45 +227,55 @@
</template>
<script setup>
-import { Search, Calendar, Tools, InfoFilled } from "@element-plus/icons-vue";
-import { onMounted, ref, reactive, toRefs, computed } from "vue";
-import { ElMessage, ElMessageBox } from "element-plus";
+import {Search, Calendar, Tools, InfoFilled} from "@element-plus/icons-vue";
+import {onMounted, ref, reactive, toRefs, computed} from "vue";
+import {ElMessage, ElMessageBox} from "element-plus";
import useUserStore from "@/store/modules/user";
+import {
+ addNotice,
+ delNotice,
+ getCount,
+ listNotice,
+ updateNotice
+} from "../../../api/collaborativeApproval/noticeManagement.js";
+import pagination from "../../../components/PIMTable/Pagination.vue";
const userStore = useUserStore();
// 鍝嶅簲寮忔暟鎹�
const data = reactive({
searchForm: {
- noticeTitle: "",
- noticeType: "",
- status: "",
+ title: "",
+ type: undefined,
+ status: undefined,
},
form: {
id: undefined,
- noticeTitle: "",
- noticeType: "",
- noticeContent: "",
- status: "0",
- priority: "1",
+ title: "",
+ type: null,
+ content: "",
+ status: 0,
+ priority: 1,
remark: "",
- createBy: "",
- createTime: "",
+ expirationDate: "",
},
rules: {
- noticeTitle: [
- { required: true, message: "鍏憡鏍囬涓嶈兘涓虹┖", trigger: "blur" }
+ title: [
+ {required: true, message: "鍏憡鏍囬涓嶈兘涓虹┖", trigger: "blur"}
],
- noticeType: [
- { required: true, message: "璇烽�夋嫨鍏憡绫诲瀷", trigger: "change" }
+ type: [
+ {required: true, message: "璇烽�夋嫨鍏憡绫诲瀷", trigger: "change"}
],
- noticeContent: [
- { required: true, message: "鍏憡鍐呭涓嶈兘涓虹┖", trigger: "blur" }
+ content: [
+ {required: true, message: "鍏憡鍐呭涓嶈兘涓虹┖", trigger: "blur"}
+ ],
+ expirationDate: [
+ {required: true, message: "璇烽�夋嫨鏃ユ湡", trigger: "change"}
]
}
});
-const { searchForm, form, rules } = toRefs(data);
+const {searchForm, form, rules} = toRefs(data);
// 椤甸潰鐘舵��
const dialogVisible = ref(false);
@@ -266,127 +283,28 @@
const selectedIds = ref([]);
const formRef = ref();
-// 妯℃嫙鏁版嵁 - 鏍规嵁娉曞畾鑺傚亣鏃ヨ璁�
-const mockData = [
- {
- id: 1,
- noticeTitle: "2024骞存槬鑺傛斁鍋囬�氱煡",
- noticeType: "1",
- priority: "2",
- status: "1",
- noticeContent: "鏍规嵁鍥藉姟闄㈠姙鍏巺閫氱煡锛�2024骞存槬鑺傛斁鍋囧畨鎺掑涓嬶細2鏈�10鏃ワ紙鍒濅竴锛夎嚦2鏈�17鏃ワ紙鍒濆叓锛夋斁鍋囪皟浼戯紝鍏�8澶┿��2鏈�4鏃ワ紙鏄熸湡鏃ワ級銆�2鏈�18鏃ワ紙鏄熸湡鏃ワ級涓婄彮銆傝鍚勯儴闂ㄦ彁鍓嶅仛濂藉伐浣滃畨鎺掋��",
- remark: "鏀惧亣鏈熼棿璇蜂繚鎸佹墜鏈虹晠閫氾紝濡傛湁绱ф�ヤ簨鍔″強鏃惰仈绯�",
- createBy: "浜轰簨閮�",
- createTime: "2024-01-15 10:30:00"
- },
- {
- id: 2,
- noticeTitle: "2024骞存竻鏄庤妭鏀惧亣閫氱煡",
- noticeType: "1",
- priority: "1",
- status: "1",
- noticeContent: "鏍规嵁鍥藉姟闄㈠姙鍏巺閫氱煡锛�2024骞存竻鏄庤妭鏀惧亣瀹夋帓濡備笅锛�4鏈�4鏃ワ紙鏄熸湡鍥涳級鑷�4鏈�6鏃ワ紙鏄熸湡鍏級鏀惧亣璋冧紤锛屽叡3澶┿��4鏈�7鏃ワ紙鏄熸湡鏃ワ級涓婄彮銆�",
- remark: "璇峰悇閮ㄩ棬鍋氬ソ鍊肩彮瀹夋帓锛岀‘淇濊妭鏃ユ湡闂村悇椤瑰伐浣滄甯歌繍杞�",
- createBy: "琛屾斂閮�",
- createTime: "2024-01-14 14:20:00"
- },
- {
- id: 3,
- noticeTitle: "2024骞村姵鍔ㄨ妭鏀惧亣閫氱煡",
- noticeType: "1",
- priority: "1",
- status: "1",
- noticeContent: "鏍规嵁鍥藉姟闄㈠姙鍏巺閫氱煡锛�2024骞村姵鍔ㄨ妭鏀惧亣瀹夋帓濡備笅锛�5鏈�1鏃ワ紙鏄熸湡涓夛級鑷�5鏈�5鏃ワ紙鏄熸湡鏃ワ級鏀惧亣璋冧紤锛屽叡5澶┿��4鏈�28鏃ワ紙鏄熸湡鏃ワ級銆�5鏈�11鏃ワ紙鏄熸湡鍏級涓婄彮銆�",
- remark: "鏀惧亣鍓嶈鍏抽棴鐢垫簮锛岄攣濂介棬绐楋紝娉ㄦ剰瀹夊叏",
- createBy: "琛屾斂閮�",
- createTime: "2024-01-13 09:15:00"
- },
- {
- id: 4,
- noticeTitle: "2024骞寸鍗堣妭鏀惧亣閫氱煡",
- noticeType: "1",
- priority: "1",
- status: "1",
- noticeContent: "鏍规嵁鍥藉姟闄㈠姙鍏巺閫氱煡锛�2024骞寸鍗堣妭鏀惧亣瀹夋帓濡備笅锛�6鏈�8鏃ワ紙鏄熸湡鍏級鑷�6鏈�10鏃ワ紙鏄熸湡涓�锛夋斁鍋囪皟浼戯紝鍏�3澶┿��6鏈�11鏃ワ紙鏄熸湡浜岋級涓婄彮銆�",
- remark: "绁濆ぇ瀹剁鍗堣妭蹇箰锛岄槚瀹跺垢绂忥紒",
- createBy: "琛屾斂閮�",
- createTime: "2024-01-12 16:30:00"
- },
- {
- id: 5,
- noticeTitle: "2024骞翠腑绉嬭妭鏀惧亣閫氱煡",
- noticeType: "1",
- priority: "1",
- status: "1",
- noticeContent: "鏍规嵁鍥藉姟闄㈠姙鍏巺閫氱煡锛�2024骞翠腑绉嬭妭鏀惧亣瀹夋帓濡備笅锛�9鏈�15鏃ワ紙鏄熸湡鏃ワ級鑷�9鏈�17鏃ワ紙鏄熸湡浜岋級鏀惧亣璋冧紤锛屽叡3澶┿��9鏈�14鏃ワ紙鏄熸湡鍏級涓婄彮銆�",
- remark: "涓浣宠妭锛岀澶у鍥㈠渾缇庢弧锛屽垢绂忓畨搴凤紒",
- createBy: "琛屾斂閮�",
- createTime: "2024-01-11 11:20:00"
- },
- {
- id: 6,
- noticeTitle: "2024骞村浗搴嗚妭鏀惧亣閫氱煡",
- noticeType: "1",
- priority: "2",
- status: "1",
- noticeContent: "鏍规嵁鍥藉姟闄㈠姙鍏巺閫氱煡锛�2024骞村浗搴嗚妭鏀惧亣瀹夋帓濡備笅锛�10鏈�1鏃ワ紙鏄熸湡浜岋級鑷�10鏈�7鏃ワ紙鏄熸湡涓�锛夋斁鍋囪皟浼戯紝鍏�7澶┿��9鏈�29鏃ワ紙鏄熸湡鏃ワ級銆�10鏈�12鏃ワ紙鏄熸湡鍏級涓婄彮銆�",
- remark: "鍥藉簡鏈熼棿璇峰悇閮ㄩ棬鍋氬ソ鍊肩彮瀹夋帓锛岀‘淇濆畨鍏ㄧǔ瀹�",
- createBy: "琛屾斂閮�",
- createTime: "2024-01-10 15:45:00"
- },
- {
- id: 7,
- noticeTitle: "A杞﹂棿鐢熶骇绾垮勾搴︽淇�氱煡",
- noticeType: "2",
- priority: "2",
- status: "1",
- noticeContent: "A杞﹂棿鐢熶骇绾垮皢浜�2024骞�1鏈�20鏃ワ紙鍛ㄥ叚锛夎繘琛屽勾搴︽淇淮鎶わ紝棰勮鍋滃伐8灏忔椂銆傛淇唴瀹瑰寘鎷細璁惧娓呮磥銆佹鼎婊戜繚鍏汇�佸畨鍏ㄨ缃鏌ョ瓑銆傝鐢熶骇閮ㄩ棬鎻愬墠璋冩暣鐢熶骇璁″垝銆�",
- remark: "缁翠慨鏈熼棿璇风浉鍏充汉鍛橀厤鍚堬紝纭繚妫�淇伐浣滃畨鍏ㄩ『鍒╄繘琛�",
- createBy: "璁惧閮�",
- createTime: "2024-01-14 14:20:00"
- },
- {
- id: 8,
- noticeTitle: "B杞﹂棿璁惧棰勯槻鎬х淮鎶ら�氱煡",
- noticeType: "2",
- priority: "1",
- status: "1",
- noticeContent: "B杞﹂棿鍏抽敭璁惧灏嗕簬2024骞�1鏈�25鏃ヨ繘琛岄闃叉�х淮鎶わ紝棰勮鍋滃伐4灏忔椂銆傜淮鎶ゅ唴瀹瑰寘鎷細璁惧妫�鏌ャ�侀浂浠舵洿鎹€�佹�ц兘娴嬭瘯绛夈�傝鐩稿叧閮ㄩ棬閰嶅悎銆�",
- remark: "缁存姢瀹屾垚鍚庡皢杩涜璇曡繍琛岋紝纭繚璁惧姝e父杩愯",
- createBy: "璁惧閮�",
- createTime: "2024-01-13 09:15:00"
- }
-];
// 璁$畻灞炴��
const filteredNotices = computed(() => {
let filtered = [...mockData];
-
+
if (searchForm.value.noticeTitle) {
- filtered = filtered.filter(item =>
- item.noticeTitle.includes(searchForm.value.noticeTitle)
+ filtered = filtered.filter(item =>
+ item.noticeTitle.includes(searchForm.value.noticeTitle)
);
}
if (searchForm.value.noticeType) {
- filtered = filtered.filter(item =>
- item.noticeType === searchForm.value.noticeType
+ filtered = filtered.filter(item =>
+ item.noticeType === searchForm.value.noticeType
);
}
if (searchForm.value.status !== "") {
- filtered = filtered.filter(item =>
- item.status === searchForm.value.status
+ filtered = filtered.filter(item =>
+ item.status === searchForm.value.status
);
}
-
+
return filtered;
-});
-
-const holidayNotices = computed(() => {
- return filteredNotices.value.filter(notice => notice.noticeType === "1");
-});
-
-const maintenanceNotices = computed(() => {
- return filteredNotices.value.filter(notice => notice.noticeType === "2");
});
// 鏂规硶瀹氫箟
@@ -396,20 +314,44 @@
const resetQuery = () => {
searchForm.value = {
- noticeTitle: "",
- noticeType: "",
+ title: "",
+ type: "",
status: ""
};
};
const getPriorityText = (priority) => {
- const priorityMap = { "1": "鏅��", "2": "閲嶈", "3": "绱ф��" };
+ const priorityMap = {"1": "鏅��", "2": "閲嶈", "3": "绱ф��"};
return priorityMap[priority] || "鏅��";
};
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) => {
@@ -417,44 +359,42 @@
dialogTitle.value = "鏂板鍏憡";
form.value = {
id: undefined,
- noticeTitle: "",
- noticeType: "",
- noticeContent: "",
- status: "0",
- priority: "1",
+ title: "",
+ type: undefined,
+ content: "",
+ status: 0,
+ priority: 1,
remark: "",
- createBy: userStore.name || "褰撳墠鐢ㄦ埛",
- createTime: new Date().toLocaleString()
+ expirationDate: "",
};
}
dialogVisible.value = true;
};
const handleEdit = (row) => {
+ if (isNoticeExpired(row)) {
+ ElMessage.warning("宸茶繃鏈熺殑鍏憡涓嶅彲缂栬緫");
+ return;
+ }
dialogTitle.value = "缂栬緫鍏憡";
- form.value = { ...row };
+ form.value = {...row};
dialogVisible.value = true;
-};
-
-const handleSelectionChange = (selection) => {
- selectedIds.value = selection.map(item => item.id);
};
const handleDelete = (id) => {
ElMessageBox.confirm(
- "纭鍒犻櫎杩欐潯鍏憡鍚楋紵",
- "鎻愮ず",
- {
- confirmButtonText: "纭畾",
- cancelButtonText: "鍙栨秷",
- type: "warning"
- }
+ "纭鍒犻櫎杩欐潯鍏憡鍚楋紵",
+ "鎻愮ず",
+ {
+ confirmButtonText: "纭畾",
+ cancelButtonText: "鍙栨秷",
+ type: "warning"
+ }
).then(() => {
- const index = mockData.findIndex(item => item.id === id);
- if (index > -1) {
- mockData.splice(index, 1);
+ delNotice(id).then(res => {
ElMessage.success("鍒犻櫎鎴愬姛");
- }
+ resetTable()
+ })
});
};
@@ -463,25 +403,83 @@
if (valid) {
if (form.value.id) {
// 缂栬緫妯″紡
- const index = mockData.findIndex(item => item.id === form.value.id);
- if (index > -1) {
- mockData[index] = { ...form.value };
- }
- ElMessage.success("淇敼鎴愬姛");
+ updateNotice(form.value).then(res => {
+ ElMessage.success("淇敼鎴愬姛");
+ resetTable()
+ })
} else {
// 鏂板妯″紡
- const newId = Math.max(...mockData.map(item => item.id)) + 1;
- const newNotice = {
- ...form.value,
- id: newId,
- createTime: new Date().toLocaleString()
- };
- mockData.unshift(newNotice);
- ElMessage.success("鏂板鎴愬姛");
+ addNotice(form.value).then(res => {
+ ElMessage.success("鏂板鎴愬姛");
+ resetTable()
+ })
}
dialogVisible.value = false;
}
});
+};
+
+const holidayNoticeCount = ref()
+const maintenanceNoticeCount = ref()
+const fetchCount = () => {
+ getCount().then(res => {
+ holidayNoticeCount.value = res.data.filter(item => {
+ return item.type === 1
+ })[0].count;
+ maintenanceNoticeCount.value = res.data.filter(item => {
+ return item.type === 2
+ })[0].count;
+ });
+}
+
+const holidayNotices = ref([])
+const maintenanceNotices = ref([])
+const holidayNoticePage = ref({
+ total: 0,
+ current: 1,
+ size: 9
+})
+
+const maintenanceNoticePage = ref({
+ total: 0,
+ current: 1,
+ size: 9
+})
+
+const fetchHolidayNotices = () => {
+ listNotice({...holidayNoticePage.value, type: 1}).then(res => {
+ holidayNotices.value = res.data.records
+ holidayNoticePage.value.total = res.data.total
+ });
+};
+
+const fetchMaintenanceNotices = () => {
+ listNotice({...holidayNoticePage.value, type: 2}).then(res => {
+ maintenanceNotices.value = res.data.records
+ maintenanceNoticePage.value.total = res.data.total
+ });
+};
+
+const handleHolidayNoticeCurrentChange = (val) => {
+ holidayNoticePage.value.size = val.limit
+ holidayNoticePage.value.current = val.page
+ fetchHolidayNotices()
+};
+
+const handleMaintenanceNoticeCurrentChange = (val) => {
+ maintenanceNoticePage.value.size = val.limit
+ maintenanceNoticePage.value.current = val.page
+ fetchMaintenanceNotices()
+};
+
+const resetTable = () => {
+ holidayNoticePage.value.current = 1
+ holidayNoticePage.value.size = 9
+ maintenanceNoticePage.value.current = 1
+ maintenanceNoticePage.value.size = 9
+ fetchHolidayNotices()
+ fetchMaintenanceNotices()
+ fetchCount()
};
const resetForm = () => {
@@ -490,7 +488,9 @@
// 鐢熷懡鍛ㄦ湡
onMounted(() => {
- // 椤甸潰鍔犺浇瀹屾垚
+ fetchCount()
+ fetchHolidayNotices()
+ fetchMaintenanceNotices()
});
</script>
@@ -645,13 +645,35 @@
font-weight: 500;
}
-.priority-1 { background: #f0f9ff; color: #0369a1; }
-.priority-2 { background: #fef3c7; color: #d97706; }
-.priority-3 { background: #fef2f2; color: #dc2626; }
+.priority-1 {
+ background: #f0f9ff;
+ color: #0369a1;
+}
-.status-0 { background: #f3f4f6; color: #6b7280; }
-.status-1 { background: #d1fae5; color: #059669; }
-.status-2 { background: #fef3c7; color: #d97706; }
+.priority-2 {
+ background: #fef3c7;
+ color: #d97706;
+}
+
+.priority-3 {
+ background: #fef2f2;
+ color: #dc2626;
+}
+
+.status-0 {
+ background: #f3f4f6;
+ color: #6b7280;
+}
+
+.status-1 {
+ background: #d1fae5;
+ color: #059669;
+}
+
+.status-2 {
+ background: #fef3c7;
+ color: #d97706;
+}
.card-info {
display: flex;
@@ -664,6 +686,10 @@
.creator {
font-weight: 500;
margin-bottom: 2px;
+}
+
+.expiration {
+ margin-top: 2px;
}
.card-remark {
@@ -692,12 +718,12 @@
.notice-cards {
grid-template-columns: 1fr;
}
-
+
.search_form {
flex-direction: column;
gap: 15px;
}
-
+
.search_form > div {
width: 100%;
}
--
Gitblit v1.9.3