2023-09-20 18:11:50 +08:00

208 lines
6.9 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<div class="table-box">
<ProTable
ref="proTable"
title="我接收的"
:columns="columns"
:requestApi="getTableList"
:dataCallback="dataCallback"
:tool-button="false"
:pagination="true"
background
:isShowSearch="false"
>
<template #content="{ row }">
<div v-html="row.content" class="html-div"></div>
</template>
<template #operation="{ row }">
<el-button type="primary" link @click="onLook(row)">
<img src="@/assets/images/tableIcon/look.png" alt="" class="configureIcon" />
<span>查看</span>
</el-button>
</template>
</ProTable>
<el-dialog v-model="visible" :destroy-on-close="true" title="查看通知">
<div>
<span class="flx-center titleText">{{ rowList.title }}</span>
</div>
<div class="text-12 flx-center">
<span>撰稿人{{ rowList.createByName }}</span>
<span class="time">时间:{{ rowList.createTime }}</span>
</div>
<div class="content text-12" v-html="rowList.content"></div>
<div class="littleTitle list">附件列表</div>
<el-table
:data="annexFiles"
border
height="200"
class="el-table"
:header-cell-style="{ backgroundColor: '#e1eeff', textAlign: 'center' }"
:cell-style="{ textAlign: 'center' }"
>
<el-table-column type="index" label="序号" width="200" />
<el-table-column prop="fileName" label="附件名称" />
<el-table-column label="操作" width="200">
<template #default="{ row }">
<el-button type="primary" link size="small" @click="addAnnexFile(row)">查看</el-button>
</template>
</el-table-column>
<template #empty>
<div class="table-empty">
<slot name="empty">
<img src="@/assets/images/notData.png" alt="notData" />
<div>暂无数据</div>
</slot>
</div>
</template>
</el-table>
<div class="littleTitle list">接收人员列表</div>
<el-table
:data="rowList.accetpList"
class="el-table"
max-height="200"
:header-cell-style="{ textAlign: 'center', boxShadow: 'inset 0px -1px 0px 0px #EBEEF5' }"
:cell-style="{ textAlign: 'center' }"
>
<el-table-column prop="acceptName" label="名称" />
<el-table-column prop="isRead" label="阅读状态">
<template #default="{ row }">
{{ row.isRead === 1 ? "已读" : "未读" }}
</template>
</el-table-column>
<el-table-column prop="readTime" label="查看时间" />
</el-table>
<template #footer>
<el-button type="primary" v-if="store.isManager && isReadState === 0" @click="onKnow">我已知晓</el-button>
<el-button type="primary" v-else @click="visible = false">关闭</el-button>
</template>
</el-dialog>
<el-dialog v-model="fileVisible" title="查看附件" width="30%" show-close>
<el-table
:data="current"
border
class="el-table"
:header-cell-style="{ backgroundColor: '#f5f7fa', textAlign: 'center' }"
:cell-style="{ textAlign: 'center' }"
>
<el-table-column prop="fileName" label="文件名称" />
<el-table-column label="操作" width="200">
<template #default="{ row }">
<el-button type="primary" link size="small" @click="ondownLoad(row)">下载</el-button>
</template>
</el-table-column>
</el-table>
<template #footer>
<span class="dialog-footer">
<el-button type="primary" @click="fileVisible = false"> 关闭 </el-button>
</span>
</template>
</el-dialog>
</div>
</template>
<script setup lang="ts" name="governmentmyReceive">
import { ref, reactive, onMounted } from "vue";
import { ElMessage, ElMessageBox } from "element-plus";
import { ColumnProps } from "@/components/ProTable/interface";
import ProTable from "@/components/ProTable/index.vue";
import { myNoticeReceivePage, noticeDetailMyPost, noticeReadMyPost } from "@/api/modules/common";
import { GlobalStore } from "@/stores";
import type { Options } from "@/views/goverment/approve/company/components/unit-table.vue";
import type { UploadFile } from "@/components/FilesUpload/FilesUpload.vue";
const store = GlobalStore();
type AnnexFilesOptions = Options & {
files: UploadFile[];
};
// 获取 ProTable 元素,调用其获取刷新数据方法(还能获取到当前查询参数,方便导出携带参数)
const proTable = ref();
const baseUrl = import.meta.env.VITE_API_URL;
const visible = ref(false);
const fileVisible = ref(false);
const rowList = ref({
title: "",
createByName: "",
createTime: "",
content: "",
accetpList: {}
});
const rowNoticeId = ref("");
const isReadState = ref<number>();
const annexFiles = ref<AnnexFilesOptions[]>([]);
const current = ref<AnnexFilesOptions>({} as AnnexFilesOptions);
// 表格配置项
const columns: ColumnProps[] = [
{ type: "index", label: "序号", width: 80 },
// 多级 prop
{ prop: "title", label: "通知标题", search: { el: "input" } },
{ prop: "content", label: "通知内容", search: { el: "input" } },
{ prop: "createByName", label: "发布人名称" },
{ prop: "createTime", label: "发布时间" },
{
prop: "isRead",
label: "阅读状态",
render: scoped => {
return scoped.row.isRead === 1 ? "已读" : "未读";
}
},
{ prop: "operation", label: "操作", fixed: "right" }
];
// dataCallback 是对于返回的表格数据做处理,如果你后台返回的数据不是 list && total && pageNum && pageSize 这些字段,那么你可以在这里进行处理成这些字段
// 或者直接去 hooks/useTable.ts 文件中把字段改为你后端对应的就行
const dataCallback = (data: any) => {
// console.log(data);
return {
list: data.records,
total: Number(data.total),
pageNo: Number(data.current),
pageSize: Number(data.size)
};
};
// 如果你想在请求之前对当前请求参数做一些操作可以自定义如下函数params 为当前所有的请求参数(包括分页),最后返回请求列表接口
// 默认不做操作就直接在 ProTable 组件上绑定 :requestApi="getUserList"
const getTableList = (params: any) => {
let newParams = JSON.parse(JSON.stringify(params));
return myNoticeReceivePage(newParams);
};
const onLook = async row => {
isReadState.value = row.isRead;
const { result } = await noticeDetailMyPost({ noticeId: row.noticeId });
rowList.value = result || [];
annexFiles.value = result.annexFileList;
rowList.value.accetpList = result.acceptList;
visible.value = true;
rowNoticeId.value = row.noticeId;
};
const onKnow = async () => {
await noticeReadMyPost({ noticeId: rowNoticeId.value });
visible.value = false;
ElMessage.success("已知晓");
proTable.value.getTableList();
};
const addAnnexFile = (row: AnnexFilesOptions) => {
fileVisible.value = true;
current.value = [row];
};
const ondownLoad = row => {
ElMessageBox.confirm("确认下载数据?", "温馨提示", { type: "warning" }).then(() => {
if (!row.fileName) {
ElMessage.error("当前没有文件,请先上传文件");
} else {
window.open(baseUrl + "/xmgl/file/preview?fileUrl=" + row.fileUrl);
}
});
};
</script>
<style lang="scss" scoped>
@import "./index.scss";
</style>