From 29527cd31f56f10e4e356c78aa0c2b98f69b1d8d Mon Sep 17 00:00:00 2001 From: 龚焕茏 <2842157468@qq.com> Date: 星期五, 01 三月 2024 16:01:16 +0800 Subject: [PATCH] 交通宣传基础功能 --- src/views/ti/trafficIndex/index.vue | 121 +++--------- src/api/tp/trafficPropaganda/index.ts | 63 +++++++ src/api/tp/trafficPropaganda/types.ts | 71 +++++++ src/views/dg/danger/total.vue | 3 src/views/tp/trafficPropaganda/index.vue | 252 ++++++++++++++++++++++++++++ 5 files changed, 422 insertions(+), 88 deletions(-) diff --git a/src/api/tp/trafficPropaganda/index.ts b/src/api/tp/trafficPropaganda/index.ts new file mode 100644 index 0000000..2369098 --- /dev/null +++ b/src/api/tp/trafficPropaganda/index.ts @@ -0,0 +1,63 @@ +import request from '@/utils/request'; +import { AxiosPromise } from 'axios'; +import { TrafficPropagandaVO, TrafficPropagandaForm, TrafficPropagandaQuery } from '@/api/demo/trafficPropaganda/types'; + +/** + * 鏌ヨ浜ら�氬浼犲垪琛� + * @param query + * @returns {*} + */ + +export const listTrafficPropaganda = (query?: TrafficPropagandaQuery): AxiosPromise<TrafficPropagandaVO[]> => { + return request({ + url: '/demo/trafficPropaganda/list', + method: 'get', + params: query + }); +}; + +/** + * 鏌ヨ浜ら�氬浼犺缁� + * @param id + */ +export const getTrafficPropaganda = (id: string | number): AxiosPromise<TrafficPropagandaVO> => { + return request({ + url: '/demo/trafficPropaganda/' + id, + method: 'get' + }); +}; + +/** + * 鏂板浜ら�氬浼� + * @param data + */ +export const addTrafficPropaganda = (data: TrafficPropagandaForm) => { + return request({ + url: '/demo/trafficPropaganda', + method: 'post', + data: data + }); +}; + +/** + * 淇敼浜ら�氬浼� + * @param data + */ +export const updateTrafficPropaganda = (data: TrafficPropagandaForm) => { + return request({ + url: '/demo/trafficPropaganda', + method: 'put', + data: data + }); +}; + +/** + * 鍒犻櫎浜ら�氬浼� + * @param id + */ +export const delTrafficPropaganda = (id: string | number | Array<string | number>) => { + return request({ + url: '/demo/trafficPropaganda/' + id, + method: 'delete' + }); +}; diff --git a/src/api/tp/trafficPropaganda/types.ts b/src/api/tp/trafficPropaganda/types.ts new file mode 100644 index 0000000..5d5e458 --- /dev/null +++ b/src/api/tp/trafficPropaganda/types.ts @@ -0,0 +1,71 @@ +export interface TrafficPropagandaVO { + /** + * 缂栧彿 + */ + id: string | number; + + /** + * 鏍囬 + */ + title: string; + + /** + * 鎺掑簭 + */ + sequence: number; + + /** + * 鍚敤鐘舵�� 1鍚敤 2鏈惎鐢� + */ + status: number; + +} + +export interface TrafficPropagandaForm extends BaseEntity { + /** + * 缂栧彿 + */ + id?: string | number; + + /** + * 鏍囬 + */ + title?: string; + + /** + * 鎺掑簭 + */ + sequence?: number; + + /** + * 鍚敤鐘舵�� 1鍚敤 2鏈惎鐢� + */ + status?: number; + +} + +export interface TrafficPropagandaQuery extends PageQuery { + + /** + * 鏍囬 + */ + title?: string; + + /** + * 鎺掑簭 + */ + sequence?: number; + + /** + * 鍚敤鐘舵�� 1鍚敤 2鏈惎鐢� + */ + status?: number; + + /** + * 鏃ユ湡鑼冨洿鍙傛暟 + */ + params?: any; +} + + + diff --git a/src/views/dg/danger/total.vue b/src/views/dg/danger/total.vue index 9b260f7..8657463 100644 --- a/src/views/dg/danger/total.vue +++ b/src/views/dg/danger/total.vue @@ -154,7 +154,7 @@ const initFormData: DangerTotalForm = { id: undefined, townStreetName: undefined, - period: 1, + period: 2, periodDate: undefined, findSecurityRisks: undefined, issueNotice: undefined, @@ -282,6 +282,7 @@ /** 鍒犻櫎鎸夐挳鎿嶄綔 */ const handleDelete = async (row?: DangerTotalVO) => { + if(row?.status == 1) { proxy?.$modal.msgWarning("褰撳墠涓哄凡鍚敤鐘舵�侊紝涓嶆敮鎸佸垹闄�"); return; } const _ids = row?.id || ids.value; await proxy?.$modal.confirm('鏄惁纭鍒犻櫎瀹夊叏闅愭偅缁熻缂栧彿涓�"' + _ids + '"鐨勬暟鎹」锛�').finally(() => loading.value = false); await delDangerTotal(_ids); diff --git a/src/views/ti/trafficIndex/index.vue b/src/views/ti/trafficIndex/index.vue index b58e411..9c5c0c8 100644 --- a/src/views/ti/trafficIndex/index.vue +++ b/src/views/ti/trafficIndex/index.vue @@ -5,31 +5,25 @@ <el-tab-pane label="閰嶇疆" name="second"></el-tab-pane> </el-tabs> <div v-show="activeName=='first'"> - <transition :enter-active-class="proxy?.animate.searchAnimate.enter" :leave-active-class="proxy?.animate.searchAnimate.leave"> - <el-form ref="form" :model="form" label-width="80px"> - 缁熻鍛ㄦ湡 - <el-select v-model="form.year" placeholder="璇烽�夋嫨骞翠唤"> - <el-option label="2024骞�" value="2024" /> - <el-option label="2023骞�" value="2023" /> - <el-option label="2022骞�" value="2022" /> + <transition :enter-active-class="proxy?.animate.searchAnimate.enter" :leave-active-class="proxy?.animate.searchAnimate.leave"> + <div class="search" v-show="showSearch"> + <el-form :model="queryParams" ref="queryFormRef" :inline="true" label-width="68px"> + <el-form-item label="缁熻鍛ㄦ湡" prop="periodDate"> + <el-input v-model="queryParams.periodValue" placeholder="璇疯緭鍏ョ粺璁″懆鏈�" clearable style="width: 240px" @keyup.enter="handleQuery" /> + </el-form-item> + <el-form-item label="鐘舵��" prop="status"> + <el-select v-model="queryParams.status" placeholder="璇烽�夋嫨" clearable style="width: 240px" @keyup.enter="handleQuery" > + <el-option key="1" label="宸插惎鐢�" value="1" /> + <el-option key="2" label="宸茬鐢�" value="2" /> </el-select> - <el-select v-model="form.month" placeholder="璇烽�夋嫨鏈堜唤"> - <el-option label="12鏈�" value="12" /> - <el-option label="11鏈�" value="11" /> - <el-option label="10鏈�" value="10" /> - </el-select> - 鐘舵�� - <el-select v-model="form.status" placeholder="璇烽�夋嫨鐘舵��"> - <el-option label="鍏ㄩ儴" value="0" /> - <el-option label="宸插惎鐢�" value="1" /> - <el-option label="宸茬鐢�" value="2" /> - </el-select> - - <el-button type="primary" icon="Search" @click="handleQuery">鎼滅储</el-button> - <el-button icon="Refresh" @click="resetQuery">閲嶇疆</el-button> - - </el-form> - </transition> + </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> + </div> + </transition> <el-card shadow="never"> <template #header> @@ -54,30 +48,21 @@ <el-table-column type="selection" width="55" align="center" /> <el-table-column label="搴忓彿" type="index" width="50"/> <el-table-column label="妯″潡鍚嶇О" align="center" prop="modeName" /> - <el-table-column label="鎸囨爣1鍚嶇О" align="center" prop="targetOneName" /> - <el-table-column label="鎸囨爣1鍊�" align="center" prop="targetOneValue" /> - <el-table-column label="鎸囨爣1鍗曚綅" align="center" prop="targetOneUnit" /> - <el-table-column label="鎸囨爣1鐘舵�� 1 涓婃诞 2涓嬮檷" align="center" prop="targetOneStatus" /> - <el-table-column label="鎸囨爣1涓婃诞鎴栦笅闄嶅��" align="center" prop="targetOneCompareValue" /> - <el-table-column label="鎸囨爣2鍚嶇О" align="center" prop="targetTwoName" /> - <el-table-column label="鎸囨爣2鍊�" align="center" prop="targetTwoValue" /> - <el-table-column label="鎸囨爣2鍗曚綅" align="center" prop="targetTwoUnit" /> - <el-table-column label="鎸囨爣2鐘舵�� 1 涓婃诞 2涓嬮檷" align="center" prop="targetTwoStatus" /> - <el-table-column label="鎸囨爣2涓婃诞鎴栦笅闄嶅��" align="center" prop="targetTwoCompareValue" /> - <el-table-column label="鎸囨爣3鍚嶇О" align="center" prop="targetThreeName" /> - <el-table-column label="鎸囨爣3鍊�" align="center" prop="targetThreeValue" /> - <el-table-column label="鎸囨爣3鍗曚綅" align="center" prop="targetThreeUnit" /> - <el-table-column label="鎸囨爣3鐘舵�� 1 涓婃诞 2涓嬮檷" align="center" prop="targetThreeStatus" /> - <el-table-column label="鎸囨爣3涓婃诞鎴栦笅闄嶅��" align="center" prop="targetThreeCompareValue" /> - <el-table-column label="鎸囨爣4鍚嶇О" align="center" prop="targetFourName" /> - <el-table-column label="鎸囨爣4鍊�" align="center" prop="targetFourValue" /> - <el-table-column label="鎸囨爣4鍗曚綅" align="center" prop="targetFourUnit" /> - <el-table-column label="鎸囨爣4鐘舵�� 1 涓婃诞 2涓嬮檷" align="center" prop="targetFourStatus" /> - <el-table-column label="鎸囨爣4涓婃诞鎴栦笅闄嶅��" align="center" prop="targetFourCompareValue" /> - <el-table-column label="鍚敤鐘舵�� 1鍚敤 2鏈惎鐢�" align="center" prop="status" /> - <el-table-column label="鍛ㄦ湡 1 鏈� 2骞�" align="center" prop="periodName" /> - <el-table-column label="鍛ㄦ湡鍊�" align="center" prop="periodValue" /> - <el-table-column label="0鏈垹闄� 1宸插垹闄�" align="center" prop="del" /> + <el-table-column label="鎸囨爣1" align="center" prop="targetOneName" /> + <el-table-column label="鏁板��" align="center" prop="targetOneValue" /> + <el-table-column label="鎸囨爣2" align="center" prop="targetTwoName" /> + <el-table-column label="鏁板��" align="center" prop="targetTwoValue" /> + <el-table-column label="鎸囨爣3" align="center" prop="targetThreeName" /> + <el-table-column label="鏁板��" align="center" prop="targetThreeValue" /> + <el-table-column label="鎸囨爣4" align="center" prop="targetFourName" /> + <el-table-column label="鏁板��" align="center" prop="targetFourValue" /> + <el-table-column label="鐘舵��" align="center" prop="status"> + <template #default="scope"> + <span v-show="scope.row['status'] == 1">宸插惎鐢�</span> + <span v-show="scope.row['status'] == 2" style="color: rgba(227, 70,101);">宸茬鐢�</span> + </template> + </el-table-column> + <el-table-column label="鍒涘缓鏃堕棿" align="center" prop="createTime"/> <el-table-column label="鎿嶄綔" align="center" class-name="small-padding fixed-width"> <template #default="scope"> <el-tooltip content="淇敼" placement="top"> @@ -101,45 +86,7 @@ </div> <div v-show="activeName=='second'"> <transition :enter-active-class="proxy?.animate.searchAnimate.enter" :leave-active-class="proxy?.animate.searchAnimate.leave"> - <div class="search" v-show="showSearch"> - <el-upload - action="#" - list-type="picture-card" - :auto-upload="false"> - <i slot="default" class="el-icon-plus"></i> - <div slot="file" slot-scope="{file}"> - <img - class="el-upload-list__item-thumbnail" - :src="file.url" alt="" - > - <span class="el-upload-list__item-actions"> - <span - class="el-upload-list__item-preview" - @click="handlePictureCardPreview(file)" - > - <i class="el-icon-zoom-in"></i> - </span> - <span - v-if="!disabled" - class="el-upload-list__item-delete" - @click="handleDownload(file)" - > - <i class="el-icon-download"></i> - </span> - <span - v-if="!disabled" - class="el-upload-list__item-delete" - @click="handleRemove(file)" - > - <i class="el-icon-delete"></i> - </span> - </span> - </div> - </el-upload> - <el-dialog :visible.sync="dialogVisible"> - <img width="100%" :src="dialogImageUrl" alt=""> - </el-dialog> - </div> + </transition> diff --git a/src/views/tp/trafficPropaganda/index.vue b/src/views/tp/trafficPropaganda/index.vue new file mode 100644 index 0000000..e80cbe4 --- /dev/null +++ b/src/views/tp/trafficPropaganda/index.vue @@ -0,0 +1,252 @@ +<template> + <div class="p-2"> + <transition :enter-active-class="proxy?.animate.searchAnimate.enter" :leave-active-class="proxy?.animate.searchAnimate.leave"> + <div class="search" v-show="showSearch"> + <el-form :model="queryParams" ref="queryFormRef" :inline="true" label-width="68px"> + <el-form-item label="鏍囬" prop="title"> + <el-input v-model="queryParams.title" placeholder="璇疯緭鍏ユ爣棰�" clearable style="width: 240px" @keyup.enter="handleQuery" /> + </el-form-item> + <el-form-item label="鐘舵��" prop="status"> + <el-select v-model="queryParams.status" placeholder="璇烽�夋嫨" clearable style="width: 240px" @keyup.enter="handleQuery" > + <el-option key="1" label="宸插惎鐢�" value="1" /> + <el-option key="2" label="宸茬鐢�" value="2" /> + </el-select> + </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> + </div> + </transition> + + <el-card shadow="never"> + <template #header> + <el-row :gutter="10" class="mb8"> + <el-col :span="1.5"> + <el-button type="primary" plain icon="Plus" @click="handleAdd" v-hasPermi="['demo:trafficPropaganda:add']">鏂板</el-button> + </el-col> + <el-col :span="1.5"> + <el-button type="success" plain icon="Edit" :disabled="single" @click="handleUpdate()" v-hasPermi="['demo:trafficPropaganda:edit']">淇敼</el-button> + </el-col> + <el-col :span="1.5"> + <el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete()" v-hasPermi="['demo:trafficPropaganda:remove']">鍒犻櫎</el-button> + </el-col> + <el-col :span="1.5"> + <el-button type="warning" plain icon="Download" @click="handleExport" v-hasPermi="['demo:trafficPropaganda:export']">瀵煎嚭</el-button> + </el-col> + <right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar> + </el-row> + </template> + + <el-table v-loading="loading" :data="trafficPropagandaList" @selection-change="handleSelectionChange"> + <el-table-column type="selection" width="55" align="center" /> + <el-table-column label="搴忓彿" align="center" type="index" v-if="true" width="60" /> + <el-table-column label="鏍囬" align="center" prop="title" /> + <el-table-column label="鎺掑簭" align="center" prop="sequence" /> + <el-table-column label="鐘舵��" align="center" prop="status"> + <template #default="scope"> + <span v-show="scope.row['status'] == 1">宸插惎鐢�</span> + <span v-show="scope.row['status'] == 2" style="color: rgba(227, 70,101);">宸茬鐢�</span> + </template> + </el-table-column> + <el-table-column label="鍒涘缓鏃堕棿" align="center" prop="createTime" /> + <el-table-column label="鎿嶄綔" align="center" class-name="small-padding fixed-width"> + <template #default="scope"> + <el-tooltip content="淇敼" placement="top"> + <el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['demo:trafficPropaganda:edit']"></el-button> + </el-tooltip> + <el-tooltip content="鍒犻櫎" placement="top"> + <el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['demo:trafficPropaganda:remove']"></el-button> + </el-tooltip> + </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-card> + <!-- 娣诲姞鎴栦慨鏀逛氦閫氬浼犲璇濇 --> + <el-dialog :title="dialog.title" v-model="dialog.visible" width="500px" append-to-body> + <el-form ref="trafficPropagandaFormRef" :model="form" :rules="rules" label-width="80px"> + <el-form-item label="鏍囬" prop="title"> + <el-input v-model="form.title" placeholder="璇疯緭鍏ユ爣棰�" /> + </el-form-item> + <el-form-item label="鎺掑簭" prop="title"> + <el-input v-model="form.sequence" placeholder="璇疯緭鍏ユ帓搴�" /> + </el-form-item> + <el-form-item label="鐘舵��" prop="status"> + <el-select v-model="form.status" placeholder="璇烽�夋嫨"> + <el-option key="1" label="宸插惎鐢�" :value="1" /> + <el-option key="2" label="宸茬鐢�" :value="2" /> + </el-select> + </el-form-item> + </el-form> + <template #footer> + <div class="dialog-footer"> + <el-button :loading="buttonLoading" type="primary" @click="submitForm">纭� 瀹�</el-button> + <el-button @click="cancel">鍙� 娑�</el-button> + </div> + </template> + </el-dialog> + </div> +</template> + +<script setup name="TrafficPropaganda" lang="ts"> +import { listTrafficPropaganda, getTrafficPropaganda, delTrafficPropaganda, addTrafficPropaganda, updateTrafficPropaganda } from '@/api/tp/trafficPropaganda'; +import { TrafficPropagandaVO, TrafficPropagandaQuery, TrafficPropagandaForm } from '@/api/tp/trafficPropaganda/types'; + +const { proxy } = getCurrentInstance() as ComponentInternalInstance; + +const trafficPropagandaList = ref<TrafficPropagandaVO[]>([]); +const buttonLoading = ref(false); +const loading = ref(true); +const showSearch = ref(true); +const ids = ref<Array<string | number>>([]); +const single = ref(true); +const multiple = ref(true); +const total = ref(0); + +const queryFormRef = ref<ElFormInstance>(); +const trafficPropagandaFormRef = ref<ElFormInstance>(); + +const dialog = reactive<DialogOption>({ + visible: false, + title: '' +}); + +const initFormData: TrafficPropagandaForm = { + id: undefined, + title: undefined, + sequence: undefined, + status: undefined +} +const data = reactive<PageData<TrafficPropagandaForm, TrafficPropagandaQuery>>({ + form: {...initFormData}, + queryParams: { + pageNum: 1, + pageSize: 10, + title: undefined, + sequence: undefined, + status: undefined, + params: { + } + }, + rules: { + id: [ + { required: true, message: "缂栧彿涓嶈兘涓虹┖", trigger: "blur" } + ], + title: [ + { required: true, message: "鏍囬涓嶈兘涓虹┖", trigger: "blur" } + ], + sequence: [ + { required: true, message: "鎺掑簭涓嶈兘涓虹┖", trigger: "blur" } + ], + status: [ + { required: true, message: "鍚敤鐘舵�� 1鍚敤 2鏈惎鐢ㄤ笉鑳戒负绌�", trigger: "change" } + ] + } +}); + +const { queryParams, form, rules } = toRefs(data); + +/** 鏌ヨ浜ら�氬浼犲垪琛� */ +const getList = async () => { + loading.value = true; + const res = await listTrafficPropaganda(queryParams.value); + trafficPropagandaList.value = res.rows; + total.value = res.total; + loading.value = false; +} + +/** 鍙栨秷鎸夐挳 */ +const cancel = () => { + reset(); + dialog.visible = false; +} + +/** 琛ㄥ崟閲嶇疆 */ +const reset = () => { + form.value = {...initFormData}; + trafficPropagandaFormRef.value?.resetFields(); +} + +/** 鎼滅储鎸夐挳鎿嶄綔 */ +const handleQuery = () => { + queryParams.value.pageNum = 1; + getList(); +} + +/** 閲嶇疆鎸夐挳鎿嶄綔 */ +const resetQuery = () => { + queryFormRef.value?.resetFields(); + handleQuery(); +} + +/** 澶氶�夋閫変腑鏁版嵁 */ +const handleSelectionChange = (selection: TrafficPropagandaVO[]) => { + ids.value = selection.map(item => item.id); + single.value = selection.length != 1; + multiple.value = !selection.length; +} + +/** 鏂板鎸夐挳鎿嶄綔 */ +const handleAdd = () => { + reset(); + dialog.visible = true; + dialog.title = "娣诲姞浜ら�氬浼�"; +} + +/** 淇敼鎸夐挳鎿嶄綔 */ +const handleUpdate = async (row?: TrafficPropagandaVO) => { + reset(); + const _id = row?.id || ids.value[0] + const res = await getTrafficPropaganda(_id); + Object.assign(form.value, res.data); + dialog.visible = true; + dialog.title = "淇敼浜ら�氬浼�"; +} + +/** 鎻愪氦鎸夐挳 */ +const submitForm = () => { + trafficPropagandaFormRef.value?.validate(async (valid: boolean) => { + if (valid) { + buttonLoading.value = true; + if (form.value.id) { + await updateTrafficPropaganda(form.value).finally(() => buttonLoading.value = false); + } else { + await addTrafficPropaganda(form.value).finally(() => buttonLoading.value = false); + } + proxy?.$modal.msgSuccess("淇敼鎴愬姛"); + dialog.visible = false; + await getList(); + } + }); +} + +/** 鍒犻櫎鎸夐挳鎿嶄綔 */ +const handleDelete = async (row?: TrafficPropagandaVO) => { + if(row?.status == 1) { proxy?.$modal.msgWarning("褰撳墠涓哄凡鍚敤鐘舵�侊紝涓嶆敮鎸佸垹闄�"); return; } + const _ids = row?.id || ids.value; + await proxy?.$modal.confirm('鏄惁纭鍒犻櫎浜ら�氬浼犵紪鍙蜂负"' + _ids + '"鐨勬暟鎹」锛�').finally(() => loading.value = false); + await delTrafficPropaganda(_ids); + proxy?.$modal.msgSuccess("鍒犻櫎鎴愬姛"); + await getList(); +} + +/** 瀵煎嚭鎸夐挳鎿嶄綔 */ +const handleExport = () => { + proxy?.download('demo/trafficPropaganda/export', { + ...queryParams.value + }, `trafficPropaganda_${new Date().getTime()}.xlsx`) +} + +onMounted(() => { + getList(); +}); +</script> -- Gitblit v1.8.0