From 11ac1538384c68ffdcd1bb71ed6f2b4b02f77d3c Mon Sep 17 00:00:00 2001 From: huangjiayang <5265313@qq.com> Date: 星期二, 22 四月 2025 13:06:18 +0800 Subject: [PATCH] 【ADD】新增日历管理接口和视图代码 --- src/api/basicData/calendar.js | 44 +++++++ src/views/basicData/calendar/index.vue | 295 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 339 insertions(+), 0 deletions(-) diff --git a/src/api/basicData/calendar.js b/src/api/basicData/calendar.js new file mode 100644 index 0000000..b566159 --- /dev/null +++ b/src/api/basicData/calendar.js @@ -0,0 +1,44 @@ +import request from '@/utils/request' + +// 鏌ヨ鏃ュ巻绠$悊鍒楄〃 +export function listCalendar(query) { + return request({ + url: '/aps/calendar/list', + method: 'get', + params: query + }) +} + +// 鏌ヨ鏃ュ巻绠$悊璇︾粏 +export function getCalendar(id) { + return request({ + url: '/aps/calendar/' + id, + method: 'get' + }) +} + +// 鏂板鏃ュ巻绠$悊 +export function addCalendar(data) { + return request({ + url: '/aps/calendar', + method: 'post', + data: data + }) +} + +// 淇敼鏃ュ巻绠$悊 +export function updateCalendar(data) { + return request({ + url: '/aps/calendar', + method: 'put', + data: data + }) +} + +// 鍒犻櫎鏃ュ巻绠$悊 +export function delCalendar(id) { + return request({ + url: '/aps/calendar/' + id, + method: 'delete' + }) +} diff --git a/src/views/basicData/calendar/index.vue b/src/views/basicData/calendar/index.vue new file mode 100644 index 0000000..bb3b016 --- /dev/null +++ b/src/views/basicData/calendar/index.vue @@ -0,0 +1,295 @@ +<template> + <div class="app-container"> + <el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="68px"> + <el-form-item label="鎻忚堪" prop="description"> + <el-input + v-model="queryParams.description" + placeholder="璇疯緭鍏ユ弿杩�" + clearable + @keyup.enter="handleQuery" + /> + </el-form-item> + <el-form-item label="鏃ュ巻鐢熸晥鏃ユ湡" prop="effectiveDate"> + <el-date-picker clearable + v-model="queryParams.effectiveDate" + type="date" + value-format="YYYY-MM-DD" + placeholder="璇烽�夋嫨鏃ュ巻鐢熸晥鏃ユ湡"> + </el-date-picker> + </el-form-item> + <el-form-item label="澶辨晥鏃ユ湡" prop="expiringDate"> + <el-date-picker clearable + v-model="queryParams.expiringDate" + type="date" + value-format="YYYY-MM-DD" + placeholder="璇烽�夋嫨澶辨晥鏃ユ湡"> + </el-date-picker> + </el-form-item> + <el-form-item> + <el-button type="primary" icon="Search" @click="handleQuery">鎼滅储</el-button> + <el-button icon="Refresh" @click="resetQuery">閲嶇疆</el-button> + </el-form-item> + </el-form> + + <el-row :gutter="10" class="mb8"> + <el-col :span="1.5"> + <el-button + type="primary" + plain + icon="Plus" + @click="handleAdd" + v-hasPermi="['core:calendar:add']" + >鏂板</el-button> + </el-col> + <el-col :span="1.5"> + <el-button + type="success" + plain + icon="Edit" + :disabled="single" + @click="handleUpdate" + v-hasPermi="['core:calendar:edit']" + >淇敼</el-button> + </el-col> + <el-col :span="1.5"> + <el-button + type="danger" + plain + icon="Delete" + :disabled="multiple" + @click="handleDelete" + v-hasPermi="['core:calendar:remove']" + >鍒犻櫎</el-button> + </el-col> + <el-col :span="1.5"> + <el-button + type="warning" + plain + icon="Download" + @click="handleExport" + v-hasPermi="['core:calendar:export']" + >瀵煎嚭</el-button> + </el-col> + <right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar> + </el-row> + + <el-table v-loading="loading" :data="calendarList" @selection-change="handleSelectionChange"> + <el-table-column type="selection" width="55" align="center" /> + <el-table-column label="${comment}" align="center" prop="id" /> + <el-table-column label="鎻忚堪" align="center" prop="description" /> + <el-table-column label="绫诲瀷锛屽懆宸ヤ綔/鑺傚亣鏃�" align="center" prop="type" /> + <el-table-column label="鏃ュ巻鐢熸晥鏃ユ湡" align="center" prop="effectiveDate" width="180"> + <template #default="scope"> + <span>{{ parseTime(scope.row.effectiveDate, '{y}-{m}-{d}') }}</span> + </template> + </el-table-column> + <el-table-column label="澶辨晥鏃ユ湡" align="center" prop="expiringDate" width="180"> + <template #default="scope"> + <span>{{ parseTime(scope.row.expiringDate, '{y}-{m}-{d}') }}</span> + </template> + </el-table-column> + <el-table-column label="鏃ュ巻鍐呭" align="center" prop="content" /> + <el-table-column label="閫傜敤宸ュ巶" align="center" prop="applicableFactory" /> + <el-table-column label="閫傜敤杞﹂棿" align="center" prop="applicableWorkshop" /> + <el-table-column label="閫傜敤宸ュ簭" align="center" prop="applicableProcess" /> + <el-table-column label="鎿嶄綔" align="center" class-name="small-padding fixed-width"> + <template #default="scope"> + <el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['core:calendar:edit']">淇敼</el-button> + <el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['core:calendar:remove']">鍒犻櫎</el-button> + </template> + </el-table-column> + </el-table> + + <pagination + v-show="total>0" + :total="total" + v-model:page="queryParams.pageNum" + v-model:limit="queryParams.pageSize" + @pagination="getList" + /> + + <!-- 娣诲姞鎴栦慨鏀规棩鍘嗙鐞嗗璇濇 --> + <el-dialog :title="title" v-model="open" width="500px" append-to-body> + <el-form ref="calendarRef" :model="form" :rules="rules" label-width="80px"> + <el-form-item label="鎻忚堪" prop="description"> + <el-input v-model="form.description" placeholder="璇疯緭鍏ユ弿杩�" /> + </el-form-item> + <el-form-item label="鏃ュ巻鐢熸晥鏃ユ湡" prop="effectiveDate"> + <el-date-picker clearable + v-model="form.effectiveDate" + type="date" + value-format="YYYY-MM-DD" + placeholder="璇烽�夋嫨鏃ュ巻鐢熸晥鏃ユ湡"> + </el-date-picker> + </el-form-item> + <el-form-item label="澶辨晥鏃ユ湡" prop="expiringDate"> + <el-date-picker clearable + v-model="form.expiringDate" + type="date" + value-format="YYYY-MM-DD" + placeholder="璇烽�夋嫨澶辨晥鏃ユ湡"> + </el-date-picker> + </el-form-item> + <el-form-item label="鏃ュ巻鍐呭" prop="content"> + <el-input v-model="form.content" type="textarea" placeholder="璇疯緭鍏ュ唴瀹�" /> + </el-form-item> + </el-form> + <template #footer> + <div class="dialog-footer"> + <el-button type="primary" @click="submitForm">纭� 瀹�</el-button> + <el-button @click="cancel">鍙� 娑�</el-button> + </div> + </template> + </el-dialog> + </div> +</template> + +<script setup name="Calendar"> +import { listCalendar, getCalendar, delCalendar, addCalendar, updateCalendar } from "@/api/core/calendar"; + +const { proxy } = getCurrentInstance(); + +const calendarList = ref([]); +const open = ref(false); +const loading = ref(true); +const showSearch = ref(true); +const ids = ref([]); +const single = ref(true); +const multiple = ref(true); +const total = ref(0); +const title = ref(""); + +const data = reactive({ + form: {}, + queryParams: { + pageNum: 1, + pageSize: 10, + description: null, + type: null, + effectiveDate: null, + expiringDate: null, + content: null, + applicableFactory: null, + applicableWorkshop: null, + applicableProcess: null, + }, + rules: { + } +}); + +const { queryParams, form, rules } = toRefs(data); + +/** 鏌ヨ鏃ュ巻绠$悊鍒楄〃 */ +function getList() { + loading.value = true; + listCalendar(queryParams.value).then(response => { + calendarList.value = response.rows; + total.value = response.total; + loading.value = false; + }); +} + +// 鍙栨秷鎸夐挳 +function cancel() { + open.value = false; + reset(); +} + +// 琛ㄥ崟閲嶇疆 +function reset() { + form.value = { + id: null, + description: null, + type: null, + effectiveDate: null, + expiringDate: null, + content: null, + applicableFactory: null, + applicableWorkshop: null, + applicableProcess: null, + createBy: null, + createTime: null, + updateBy: null, + updateTime: null + }; + proxy.resetForm("calendarRef"); +} + +/** 鎼滅储鎸夐挳鎿嶄綔 */ +function handleQuery() { + queryParams.value.pageNum = 1; + getList(); +} + +/** 閲嶇疆鎸夐挳鎿嶄綔 */ +function resetQuery() { + proxy.resetForm("queryRef"); + handleQuery(); +} + +// 澶氶�夋閫変腑鏁版嵁 +function handleSelectionChange(selection) { + ids.value = selection.map(item => item.id); + single.value = selection.length != 1; + multiple.value = !selection.length; +} + +/** 鏂板鎸夐挳鎿嶄綔 */ +function handleAdd() { + reset(); + open.value = true; + title.value = "娣诲姞鏃ュ巻绠$悊"; +} + +/** 淇敼鎸夐挳鎿嶄綔 */ +function handleUpdate(row) { + reset(); + const _id = row.id || ids.value + getCalendar(_id).then(response => { + form.value = response.data; + open.value = true; + title.value = "淇敼鏃ュ巻绠$悊"; + }); +} + +/** 鎻愪氦鎸夐挳 */ +function submitForm() { + proxy.$refs["calendarRef"].validate(valid => { + if (valid) { + if (form.value.id != null) { + updateCalendar(form.value).then(response => { + proxy.$modal.msgSuccess("淇敼鎴愬姛"); + open.value = false; + getList(); + }); + } else { + addCalendar(form.value).then(response => { + proxy.$modal.msgSuccess("鏂板鎴愬姛"); + open.value = false; + getList(); + }); + } + } + }); +} + +/** 鍒犻櫎鎸夐挳鎿嶄綔 */ +function handleDelete(row) { + const _ids = row.id || ids.value; + proxy.$modal.confirm('鏄惁纭鍒犻櫎鏃ュ巻绠$悊缂栧彿涓�"' + _ids + '"鐨勬暟鎹」锛�').then(function() { + return delCalendar(_ids); + }).then(() => { + getList(); + proxy.$modal.msgSuccess("鍒犻櫎鎴愬姛"); + }).catch(() => {}); +} + +/** 瀵煎嚭鎸夐挳鎿嶄綔 */ +function handleExport() { + proxy.download('core/calendar/export', { + ...queryParams.value + }, `calendar_${new Date().getTime()}.xlsx`) +} + +getList(); +</script> -- Gitblit v1.9.3