146 lines
4.7 KiB
Vue
Raw Normal View History

<template>
<div class="table-box">
<ProTable
ref="proTable"
title="我发布的"
:columns="columns"
:requestApi="getTableList"
:dataCallback="dataCallback"
:tool-button="false"
:pagination="true"
background
:isShowSearch="false"
@row-click="rowClick"
>
<template #operation="{ row }">
<el-button type="primary" link @click="ondownLoad(row)">
<img src="@/assets/images/tableIcon/下载附件.png" alt="" class="configureIcon" />
<span>下载附件</span>
</el-button>
<el-button type="primary" link @click="handleEditItem(row)">
<img src="@/assets/images/tableIcon/updateIcon.png" alt="" class="configureIcon" />
<span>编辑</span>
</el-button>
<el-button type="danger" link :icon="Delete" @click="handleDeleteItem(row)">删除</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" v-html="rowList.content"></div>
<template #footer>
<el-button type="primary" @click="visible = false">关闭</el-button>
</template>
</el-dialog>
</div>
</template>
<script setup lang="tsx" name="governmentMyposted">
import { ref, reactive, onMounted } from "vue";
import { ElMessage, ElMessageBox } from "element-plus";
import { ColumnProps } from "@/components/ProTable/interface";
import { Delete } from "@element-plus/icons-vue";
import { jxj_User } from "@/api/types";
import { useHandleData } from "@/hooks/useHandleData";
import ProTable from "@/components/ProTable/index.vue";
import { myPostPage, delMyPost, getDetailPolicy } from "@/api/modules/common";
import { GlobalStore } from "@/stores";
import router from "@/routers";
const store = GlobalStore();
// 获取 ProTable 元素,调用其获取刷新数据方法(还能获取到当前查询参数,方便导出携带参数)
const proTable = ref();
const baseUrl = import.meta.env.VITE_API_URL;
const visible = ref(false);
const rowList = ref({
title: "",
createByName: "",
createTime: "",
content: ""
});
// 表格配置项
const columns: ColumnProps[] = [
{ type: "index", label: "序号", width: 80 },
// 多级 prop
{
prop: "title",
label: "文件标题",
search: { el: "input" }
},
2023-05-29 18:19:12 +08:00
{ prop: "content", label: "文件内容", search: { el: "input" }, type: "html" },
{ prop: "createTime", label: "发布时间" },
{ prop: "operation", label: "操作", fixed: "right", width: 240 }
];
// 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 myPostPage(newParams);
};
const rowClick = (row: any, column: ColumnProps) => {
// console.log("row", row, "1", column);
if (column.property == "operation") return;
visible.value = true;
rowList.value = row;
};
// 修改数据按钮
const handleEditItem = async (row: any) => {
2023-05-29 18:19:12 +08:00
console.log(row);
const { result } = await getDetailPolicy({ policyId: row.policyId });
store.Message = result;
router.push({ path: "/goverment/policyLows/releaseLows/index" });
};
// 删除用户信息
const handleDeleteItem = async (params: jxj_User.ResUserList) => {
await useHandleData(delMyPost, { policyId: params.policyId }, `删除【${params.title}`);
proTable.value.getTableList();
};
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 scoped lang="scss">
@import "./index.scss";
:deep(.el-table tr) {
cursor: pointer;
}
:deep(.el-dialog .el-dialog__header) {
border-bottom: 1px solid #eff0f3;
}
:deep(.el-dialog__body) {
max-height: 600px;
overflow: auto;
}
</style>