From ba01c8bd58bea9acbb98c2097765b939a81b21cd Mon Sep 17 00:00:00 2001 From: spring <2396852758@qq.com> Date: 星期五, 29 八月 2025 17:52:41 +0800 Subject: [PATCH] Merge branch 'refs/heads/dev_huangjin' into dev --- src/views/collaborativeApproval/noticeManagement/index.vue | 518 +++++++++++++++++++++++++++++---------------------------- 1 files changed, 262 insertions(+), 256 deletions(-) diff --git a/src/views/collaborativeApproval/noticeManagement/index.vue b/src/views/collaborativeApproval/noticeManagement/index.vue index daa4cd7..16cee35 100644 --- a/src/views/collaborativeApproval/noticeManagement/index.vue +++ b/src/views/collaborativeApproval/noticeManagement/index.vue @@ -2,30 +2,30 @@ <div class="app-container"> <!-- 鎼滅储琛ㄥ崟 --> <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>--> + <!-- <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> @@ -35,22 +35,24 @@ <!-- 閫氱煡鍏憡鏉� --> <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> @@ -58,7 +60,7 @@ </div> </div> <div class="card-content"> - <p>{{ notice.noticeContent }}</p> + <p>{{ notice.content }}</p> </div> <div class="card-footer"> <div class="card-meta"> @@ -70,35 +72,47 @@ </span> </div> <div class="card-info"> - <span class="creator">{{ notice.createBy }}</span> + <span class="creator">{{ notice.createUserName }}</span> <span class="time">{{ notice.createTime }}</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> @@ -106,7 +120,7 @@ </div> </div> <div class="card-content"> - <p>{{ notice.noticeContent }}</p> + <p>{{ notice.content }}</p> </div> <div class="card-footer"> <div class="card-meta"> @@ -118,44 +132,54 @@ </span> </div> <div class="card-info"> - <span class="creator">{{ notice.createBy }}</span> + <span class="creator">{{ notice.createUserName }}</span> <span class="time">{{ notice.createTime }}</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,18 +188,18 @@ <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">宸插彂甯�</el-radio> + <el-radio :value="2">宸蹭笅绾�</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> @@ -184,12 +208,12 @@ <el-col :span="24"> <el-form-item label="鍏憡鍐呭" prop="noticeContent"> <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 +222,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 +244,51 @@ </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: "", }, 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"} ] } }); -const { searchForm, form, rules } = toRefs(data); +const {searchForm, form, rules} = toRefs(data); // 椤甸潰鐘舵�� const dialogVisible = ref(false); @@ -266,127 +296,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,19 +327,19 @@ 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] || "鏈煡"; }; @@ -417,14 +348,12 @@ 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() }; } dialogVisible.value = true; @@ -432,29 +361,24 @@ const handleEdit = (row) => { 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 +387,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: 6 +}) + +const maintenanceNoticePage = ref({ + total: 0, + current: 1, + size: 6 +}) + +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 = 6 + maintenanceNoticePage.value.current = 1 + maintenanceNoticePage.value.size = 6 + fetchHolidayNotices() + fetchMaintenanceNotices() + fetchCount() }; const resetForm = () => { @@ -490,7 +472,9 @@ // 鐢熷懡鍛ㄦ湡 onMounted(() => { - // 椤甸潰鍔犺浇瀹屾垚 + fetchCount() + fetchHolidayNotices() + fetchMaintenanceNotices() }); </script> @@ -645,13 +629,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; @@ -692,12 +698,12 @@ .notice-cards { grid-template-columns: 1fr; } - + .search_form { flex-direction: column; gap: 15px; } - + .search_form > div { width: 100%; } -- Gitblit v1.9.3