From 1f6893d24ba87313d4114c68813073ead53b2e12 Mon Sep 17 00:00:00 2001 From: zhouwx <1175765986@qq.com> Date: 星期五, 30 八月 2024 09:26:22 +0800 Subject: [PATCH] 群发新通讯录懒加载 --- src/views/Admin/list.vue | 118 +++++++++++++++++++++++++++++++++++++++++++---------------- 1 files changed, 86 insertions(+), 32 deletions(-) diff --git a/src/views/Admin/list.vue b/src/views/Admin/list.vue index 8a45500..0c5efea 100644 --- a/src/views/Admin/list.vue +++ b/src/views/Admin/list.vue @@ -29,8 +29,8 @@ style="width: 100%" /> </a-col> - <a-col :span="4"> - <a-button type="primary" @click="getData">查询</a-button> + <a-col :span="6"> + <a-button type="primary" @click="searchData" v-preventReClick="1000">查询</a-button> <a-button style="margin-left: 12px" @click="resetSearch">重置</a-button> </a-col> </a-row> @@ -38,7 +38,7 @@ </a-row> <!-- 表格实体部分--> <div class="table-cont"> - <a-table :columns="columns" :data-source="data" bordered :pagination="pagination"> + <a-table :columns="columns" :data-source="data" bordered :pagination="pagination" :rowKey="record=>record.id"> <template #index="text,record,index"> {{index + 1}} </template> @@ -53,8 +53,11 @@ {{ getLevelName(text) }} </a-tag> </template> - <template #attachment="text"> - <a><b><a-icon type="paper-clip" /> {{text}}</b></a> + <template #attachment="attachment"> + <span v-if="attachment===null|| attachment===[]">无</span> + <div v-else> + <a-button @click="viewFile(item)" type="link" v-for="(item,index) in attachment" :key="index"><a-icon type="paper-clip"/>{{item.attachmentName}}</a-button> + </div> </template > <template #responseStatus="text"> <a-tag :color="text === 3 ? 'red' :text === 2? 'green':text === 1?'orange':'blue'"> @@ -73,13 +76,14 @@ <!-- </div>--> <!-- </template>--> <template #operation="text, record, index"> - <a-button type="primary" v-if="record.responseStatus == 1" style="margin-right: 12px" @click="confirmResponce(record.id)">确认已收到</a-button> - <a-button type="primary" @click="openMod('repost',record)">转发</a-button> - <a-button type="link" @click="openMod('view',record)">查看详情</a-button> + <a-button type="primary" v-if="record.responseStatus == 1 && userInfo.unittype !== 4" style="margin-right: 12px" @click="confirmResponce(record.id)">确认已收到</a-button> + <a-button type="primary" @click="openMod('repost',record)" v-if="userInfo.unittype !== 4">转发</a-button> + <a-button type="link" @click="openDetails(record,record.warnInfoId)">查看详情</a-button> </template> </a-table> </div> - <msg-edit-mod ref="msgEdit" @refresh="getData"></msg-edit-mod> + <msg-edit-mod ref="msgEdit" @refresh="getData()"></msg-edit-mod> + <msg-detail-mod ref="msgDetail"></msg-detail-mod> <!-- 对话框 --> <!-- <a-modal title="回执" --> <!-- okText="确认已安排部署"--> @@ -94,14 +98,20 @@ <script> import {getMsgRecord, readById, responseMsg} from "@/api/list"; import msgEditMod from "@/views/Admin/components/msgEditMod"; +import msgDetailMod from "@/views/Admin/components/msgDetailMod"; import {publishMsg} from "@/api/send"; import {getReviewDetail, getReviewDetailByWorker} from "@/api/review"; +import axios from "axios"; +import Cookies from "js-cookie"; +import {getUserInfo} from "@/util/storage"; +import {debounce} from "@/util/debounce"; export default { name: 'list', - components: { msgEditMod }, + components: { msgEditMod, msgDetailMod }, data() { return { + userInfo: getUserInfo(), search:{ pageIndex: 1, pageSize: 10, @@ -116,7 +126,6 @@ { title: '序号', dataIndex: 'index', - width: '5%', scopedSlots: { customRender: 'index' }, @@ -124,7 +133,6 @@ { title: '发布时间', dataIndex: 'publishingTime', - width: '15%', scopedSlots: { customRender: 'publishingTime' }, //设置定制化表格数据 @@ -132,12 +140,10 @@ { title: '发布单位', dataIndex: 'publishingUnit', - width: '12%', }, { title: '灾种', dataIndex: 'disasterType', - width: '8%', scopedSlots: { customRender: 'disasterType' } @@ -148,17 +154,15 @@ scopedSlots: { customRender: 'warningLevel' }, //设置定制化表格数据 - width: '8%', }, { title: '信息标题', dataIndex: 'title', - width: '16%', }, { title: '附件', dataIndex: 'attachment', - width: '6%', + width: '15%', scopedSlots: { customRender: 'attachment' }, @@ -166,7 +170,6 @@ { title: '叫应状态', dataIndex: 'responseStatus', - width: '10%', scopedSlots: { customRender: 'responseStatus' }, //设置定制化表格数据 @@ -174,6 +177,7 @@ { title: '操作', dataIndex: 'operation', + width: '18%', scopedSlots: { customRender: 'operation' }, @@ -197,9 +201,8 @@ confirmLoading: false, riskOptions: [ {name: '地震',value: 1}, - {name: '洪涝',value: 2}, {name: '气象',value: 3}, - {name: '泥石流',value: 4}, + {name: '地质灾害',value: 4}, {name: '水旱',value: 5}, {name: '森林草原火灾',value: 6} ], @@ -211,12 +214,20 @@ ] }; }, + mounted() { + if(this.userInfo.role.id == 1){ + this.columns = this.columns.filter(i=>i.dataIndex !== 'operation') + } + }, created() { const t = this + if(t.$route.query){ + t.search.searchParams.responseStatus = t.$route.query.type + } t.getData() }, methods: { - async getData(){ + getData: debounce(async function(){ const t = this const res = await getMsgRecord(this.search) if(res.data.code == 100){ @@ -225,7 +236,7 @@ }else{ this.$message.error(res.data.msg) } - }, + },1000), onPageChange(page, pageSize) { const t= this @@ -240,6 +251,31 @@ t.search.searchParams.startTime = value[0].format('YYYY-MM-DD 00:00:00') t.search.searchParams.endTime = value[1].format('YYYY-MM-DD 23:59:59') } + }, + + viewFile(item){ + const t = this + const { baseUrl } = require('../../../config/env.' + process.env.NODE_ENV) + axios.get(baseUrl + item.attachment,{headers:{'Content-Type': 'application/json','tk': `${Cookies.get('resTk')}`,'uid':`${Cookies.get('resUid')}`},responseType: 'blob'}).then(res=>{ + if (res) { + const link = document.createElement('a') + let blob = new Blob([res.data],{type: res.data.type}) + link.style.display = "none"; + link.href = URL.createObjectURL(blob); // 创建URL + window.open(link.href) + // link.setAttribute("download", item.attachmentName); + // document.body.appendChild(link); + // link.click(); + // document.body.removeChild(link); + } else { + this.$message.error('获取文件失败') + } + }) + }, + + searchData(){ + this.search.pageIndex = 1 + this.getData() }, resetSearch(){ @@ -265,14 +301,24 @@ cancelText: '取消', okText: '确认', centered: true, - async onOk() { - let res = await responseMsg(id) - if(res.data.code == 100){ - t.$message.success('信息叫应成功'); - t.getData() - }else{ - t.$message.warning(res.data.msg); - } + onOk() { + responseMsg(id).then(res=>{ + if(res.data.code == 100){ + t.$message.success('信息叫应成功'); + t.search = { + pageIndex: 1, + pageSize: 10, + searchParams:{ + responseStatus: null, + startTime: '', + endTime: '' + } + }, + t.getData() + }else{ + t.$message.warning(res.data.msg); + } + }) }, onCancel() { console.log('Cancel'); @@ -285,8 +331,7 @@ getReviewDetailByWorker(data.warnInfoId).then(res=>{ if(res.data.code == 100){ if(res.data.data){ - t.read(data.id) - t.$refs.msgEdit.openMod(type,res.data.data) + t.$refs.msgEdit.openMod(type,res.data.data,data.id) }else{ t.$message.error('查询信息详情失败') } @@ -296,11 +341,20 @@ }) }, + openDetails(data,id){ + const t = this + t.read(data.id) + t.$refs.msgDetail.getDetails(id) + t.$refs.msgDetail.getMeasures(data.id) + t.$refs.msgDetail.visible = true + }, + async read(id){ const t = this const res = await readById(id) if(res.data.code == 100){ console.log('已读') + t.getData() }else{ t.$message.error('设置已读出错') } -- Gitblit v1.9.2