通知公告优化,增加历史通知

This commit is contained in:
曹磊 2024-05-22 21:34:09 +08:00
parent 9d38d55f0e
commit d3c9153e84
9 changed files with 599 additions and 168 deletions

View File

@ -152,12 +152,15 @@ function toIndex(){
let roleList = userStore?.getLoginInfo?.roleList
for(var i=0;i<roleList.length;i++){
var roleCode = roleList[i].roleCode
if(roleCode == 'admin' || roleCode == 'jwms'){
sfxx.value = "1";
if(roleList){
for(var i=0;i<roleList.length;i++){
var roleCode = roleList[i].roleCode
if(roleCode == 'admin' || roleCode == 'jwms'){
sfxx.value = "1";
}
}
}
});
function smoothScroll(topNum){
setTimeout(() => {

View File

@ -11,6 +11,7 @@ enum Api {
deleteBatch = '/zyGonggao/zyGonggao/deleteBatch',
importExcel = '/zyGonggao/zyGonggao/importExcel',
exportXls = '/zyGonggao/zyGonggao/exportXls',
historyList = '/zyGonggao/zyGonggao/historyList',
}
/**
@ -70,3 +71,10 @@ export const saveOrUpdate = (params, isUpdate) => {
let url = isUpdate ? Api.edit : Api.save;
return defHttp.post({ url: url, params }, { isTransformResponse: false });
}
/**
*
* @param params
*/
export const historyList = (params) => defHttp.get({ url: Api.historyList, params });

View File

@ -10,18 +10,23 @@ export const columns: BasicColumn[] = [
dataIndex: 'title'
},
{
title: '状态',
title: '修改时间',
align: "center",
dataIndex: 'ggStatus_dictText'
},
{
title: '发布时间',
align: "center",
dataIndex: 'fbTime',
customRender:({text}) =>{
return !text?"":(text.length>10?text.substr(0,10):text);
},
dataIndex: 'updateTime'
},
// {
// title: '状态',
// align: "center",
// dataIndex: 'ggStatus_dictText'
// },
// {
// title: '发布时间',
// align: "center",
// dataIndex: 'fbTime',
// customRender:({text}) =>{
// return !text?"":(text.length>10?text.substr(0,10):text);
// },
// },
];
//查询数据

View File

@ -1,8 +1,8 @@
<template>
<div style="background: #fff;min-height:97%;margin-top:10px;">
<div style="background: #fff;min-height:97.5%;margin-top:10px;">
<!--查询区域-->
<div class="jeecg-basic-table-form-container">
<a-form @keyup.enter.native="searchQuery" :model="queryParam" :label-col="labelCol" :wrapper-col="wrapperCol">
<div class="jeecg-basic-table-form-container" style="border-bottom: 2px solid #f0f0f0;">
<a-form @keyup.enter.native="searchQuery" :model="queryParam" :label-col="labelCol" :wrapper-col="wrapperCol" style="padding: 20px 10px 0px 10px;">
<a-row :gutter="24">
<a-col :lg="8">
<a-form-item label="标题">
@ -15,91 +15,85 @@
<a-button type="primary" preIcon="ant-design:search-outlined" @click="searchQuery">查询</a-button>
<a-button type="primary" preIcon="ant-design:reload-outlined" @click="searchReset" style="margin-left: 8px">重置</a-button>
<a-button type="primary" @click="handleAdd" preIcon="ant-design:plus-outlined" style="margin-left: 8px"> 新增</a-button>
<!--<a @click="toggleSearchStatus = !toggleSearchStatus" style="margin-left: 8px">
{{ toggleSearchStatus ? '收起' : '展开' }}
<Icon :icon="toggleSearchStatus ? 'ant-design:up-outlined' : 'ant-design:down-outlined'" />
</a>-->
</a-col>
</span>
</a-col>
</a-row>
</a-form>
</div>
<!--引用表格-->
<BasicTable @register="registerTable" style="top: -16px;position: relative;">
<!--插槽:table标题-->
<template #tableTitle>
</template>
<!--操作栏-->
<template #action="{ record }">
<TableAction :actions="getTableAction(record)"/>
</template>
<!--字段回显插槽-->
<template #htmlSlot="{text}">
<div v-html="text"></div>
</template>
<!--省市区字段回显插槽-->
<!--<template #pcaSlot="{text}">
{{ getAreaTextByCode(text) }}
</template>-->
<template #fileSlot="{text}">
<span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
<a-button v-else :ghost="true" type="primary" preIcon="ant-design:download-outlined" size="small" @click="downloadFile(text)">下载</a-button>
</template>
</BasicTable>
<!-- 表单区域 -->
<a-row>
<a-col :span="24" v-for="(item, index) in tableData" :key="index" style="padding:10px;overflow:hidden;border-bottom: 1px solid #f0f0f0;">
<div>
<a-row style="padding:10px;line-height: 30px;">
<a-col :span="14">
<span style="font-size: 16px;color: #515151 ;font-weight: bold;">{{item.title}}</span>
<span v-if="item.ggStatus==0" style="margin-left: 20px;"><a-tag color="blue">草稿</a-tag></span>
</a-col>
<a-col :span="10">
<div v-if="item.ggStatus==0" style="text-align: right;color:#9e9e9e;">尚未发布学生端页面看不到这条通知</div>
</a-col>
</a-row>
<a-row style="padding:10px;">
<a-col :span="24">
<div style="color: #515151" v-html="item.content"></div>
</a-col>
</a-row>
<a-row style="padding:10px;">
<a-col :span="16">
<a-button type="primary" @click="handleEdit(item)" style="margin-left:5px;padding: 0px 8px;background:rgb(28, 132, 198);" v-if="item.ggStatus==0">编辑</a-button>
<a-button type="primary" @click="handleDelete(item)" style="margin-left:5px;padding: 0px 8px;background:rgb(28, 132, 198);" v-if="item.ggStatus==0">删除</a-button>
<a-button type="primary" @click="handleCh(item)" style="margin-left:5px;padding: 0px 8px;background:#a7a6a6;" v-if="item.ggStatus==1">撤回</a-button>
<a-button type="primary" @click="handleDetail(item)" style="margin-left:5px;padding: 0px 8px;background:#18a689;">预览</a-button>
<a-button type="primary" @click="handleHistory(item)" style="margin-left:5px;padding: 0px 8px;background:#18a689;">历史</a-button>
</a-col>
<a-col :span="8">
<div style="text-align: right;color:#9e9e9e;font-weight: bold;">{{item.createTime}}</div>
</a-col>
</a-row>
</div>
</a-col>
<a-col :span="24" style="padding:10px;">
<div v-show="tableData.length>0">
<a-pagination v-model="current" :total="total" @change="handlePageChange" :pageSize="pageSize" style="text-align: right;"/>
</div>
<div v-show="tableData.length==0">
<a-empty/>
</div>
</a-col>
</a-row>
<ZyGonggaoModal ref="registerModal" @success="handleSuccess"></ZyGonggaoModal>
<ZyGonggaoYlModal ref="registerYlModal" @success="handleSuccess"></ZyGonggaoYlModal>
<ZyGonggaoHistoryModal ref="registerHistoryModal" @success="handleSuccess"></ZyGonggaoHistoryModal>
</div>
</template>
<script lang="ts" name="zyGonggao-zyGonggao" setup>
import { ref, reactive, unref } from 'vue';
import { BasicTable, useTable, TableAction } from '/@/components/Table';
import { useListPage } from '/@/hooks/system/useListPage';
import { columns } from './ZyGonggao.data';
import { list, deleteOne, batchDelete, getImportUrl, getExportUrl } from './ZyGonggao.api';
import { downloadFile } from '/@/utils/common/renderUtils';
import {ref, reactive, unref, onMounted} from 'vue';
import { Input, Popover, Pagination, Empty } from 'ant-design-vue';
import { deleteOne } from './ZyGonggao.api';
import ZyGonggaoModal from './components/ZyGonggaoModal.vue';
import ZyGonggaoYlModal from './components/ZyGonggaoYlModal.vue';
import ZyGonggaoHistoryModal from './components/ZyGonggaoHistoryModal.vue';
import { defHttp } from '/@/utils/http/axios';
import { useMessage } from "/@/hooks/web/useMessage";
import { JInput } from '/@/components/Form';
import { useRouter } from 'vue-router';
const APagination = Pagination;
const { createConfirm } = useMessage();
const { currentRoute } = useRouter();
const { query } = unref(currentRoute);
const { rwbh,xqxn } = query;//
const queryParam = ref<any>({rwbh, xqxn});
const toggleSearchStatus = ref<boolean>(false);
const registerModal = ref();
//table
const { prefixCls, tableContext, onExportXls, onImportXls } = useListPage({
tableProps: {
title: '公告',
api: list,
columns,
canResize:false,
useSearchForm: false,
actionColumn: {
width: 220,
fixed: 'right',
},
beforeFetch: (params) => {
params.column = 'createTime',params.order = 'desc';//
return Object.assign(params, queryParam.value);
},
},
exportConfig: {
name: "公告",
url: getExportUrl,
},
importConfig: {
url: getImportUrl,
success: handleSuccess
},
});
const [registerTable, { reload, collapseAll, updateTableDataRecord, findTableDataRecord, getDataSource }, { rowSelection, selectedRowKeys }] = tableContext;
const registerYlModal = ref();
const registerHistoryModal = ref();
const current = ref<number>(0);
const total = ref<number>(0);
const pageNo = ref<number>(0);
const pageSize = ref<number>(5);
const tableData = ref<any>([]);
const labelCol = reactive({
xs: { span: 24 },
sm: { span: 7 },
@ -129,103 +123,84 @@
* 详情
*/
function handleDetail(record: Recordable) {
registerModal.value.disableSubmit = true;
registerModal.value.edit(record);
if(record.ggStatus == 1){
registerYlModal.value.disableSubmit = true;
}else{
registerYlModal.value.disableSubmit = false;
}
registerYlModal.value.edit(record);
}
/**
* 历史通知
*/
function handleHistory(record: Recordable) {
registerHistoryModal.value.disableSubmit = true;
registerHistoryModal.value.edit(record);
}
/**
* 删除事件
*/
async function handleDelete(record) {
await deleteOne({ id: record.id }, handleSuccess);
createConfirm({
iconType: 'warning',
title: '删除',
content: '是否删除此通知?',
okText: '确认',
cancelText: '取消',
onOk: () => {
deleteOne({ id: record.id }, handleSuccess);
}
});
}
function handleFabu(record){
createConfirm({
iconType: 'warning',
title: '确认发布',
content: '是否发布选中数据',
okText: '发布',
cancelText: '取消',
onOk: () => {
var params = {id:record.id,ggStatus:"1",fbTime:new Date()}
defHttp.post({url: '/zyGonggao/zyGonggao/edit', params: params}).then(() => {
handleSuccess();
});
}
});
createConfirm({
iconType: 'warning',
title: '确认发布',
content: '是否发布此通知?',
okText: '发布',
cancelText: '取消',
onOk: () => {
var params = {id:record.id,ggStatus:"1",flag:"1",fbTime:new Date()}
defHttp.post({url: '/zyGonggao/zyGonggao/edit', params: params}).then(() => {
handleSuccess();
});
}
});
}
/**
* 批量删除事件
*/
async function batchHandleDelete() {
await batchDelete({ ids: selectedRowKeys.value }, handleSuccess);
function handleCh(record){
createConfirm({
iconType: 'warning',
title: '撤回',
content: '是否撤回此通知?',
okText: '确认',
cancelText: '取消',
onOk: () => {
var params = {id:record.id,ggStatus:"0",flag:"0",fbTime:new Date()}
defHttp.post({url: '/zyGonggao/zyGonggao/edit', params: params}).then(() => {
handleSuccess();
});
}
});
}
/**
* 成功回调
*/
function handleSuccess() {
(selectedRowKeys.value = []) && reload();
}
/**
* 操作栏
*/
function getTableAction(record) {
var list = [];
if (record.ggStatus == "0") {
list.push({
label: '编辑',
onClick: handleEdit.bind(null, record),
});
list.push({
label: '删除',
popConfirm: {
title: '是否确认删除',
confirm: handleDelete.bind(null, record),
}
});
list.push({
label: '发布',
popConfirm: {
title: '是否确认发布',
confirm: handleFabu.bind(null, record),
}
});
}
list.push({
label: '详情',
onClick: handleDetail.bind(null, record),
});
return list;
}
/**
* 下拉操作栏
*/
function getDropDownAction(record) {
return [
{
label: '详情',
onClick: handleDetail.bind(null, record),
}, {
label: '删除',
popConfirm: {
title: '是否确认删除',
confirm: handleDelete.bind(null, record),
}
}
]
total.value = 1;
pageNo.value = 0;
reload()
}
/**
* 查询
*/
function searchQuery() {
pageNo.value = 0;
reload();
}
@ -234,15 +209,35 @@
*/
function searchReset() {
queryParam.value = {};
selectedRowKeys.value = [];
queryParam.value.rwbh = rwbh;
queryParam.value.xqxn = xqxn;
//
total.value = 1;
handlePageChange(1);
}
function handlePageChange(record){
pageNo.value = record;
reload();
}
function reload(){
queryParam.value.pageNo = pageNo;
queryParam.value.pageSize = pageSize;
queryParam.value.rwbh = rwbh;
queryParam.value.xqxn = xqxn;
queryParam.value.column="createTime";
queryParam.value.order="desc";
defHttp.get({ url: '/zyGonggao/zyGonggao/list', params: queryParam.value }).then(res => {
total.value = res.total;
pageNo.value = res.pages;
current.value = res.current;
tableData.value = res.records;
});
}
onMounted(() => {
searchQuery();
});
</script>

View File

@ -109,7 +109,7 @@
}
}
}
console.log(`🚀 ~ submitForm ~ model:`, model)
// console.log(`🚀 ~ submitForm ~ model:`, model)
await saveOrUpdate(model, isUpdate.value)
.then((res) => {
if (res.success) {

View File

@ -0,0 +1,155 @@
<template>
<div style="background: #fff;min-height:97%;margin-top:10px;">
<!--查询区域-->
<div class="jeecg-basic-table-form-container">
<a-form @keyup.enter.native="searchQuery" :model="queryParam" :label-col="labelCol" :wrapper-col="wrapperCol">
<a-row :gutter="24">
<a-col :lg="8">
<a-form-item label="标题">
<a-input placeholder="请输入标题" v-model:value="queryParam.title"></a-input>
</a-form-item>
</a-col>
<a-col :xl="6" :lg="7" :md="8" :sm="24">
<span style="float: left; overflow: hidden" class="table-page-search-submitButtons">
<a-col :lg="6">
<a-button type="primary" preIcon="ant-design:search-outlined" @click="searchQuery">查询</a-button>
<a-button type="primary" preIcon="ant-design:reload-outlined" @click="searchReset" style="margin-left: 8px">重置</a-button>
</a-col>
</span>
</a-col>
</a-row>
</a-form>
</div>
<!--引用表格-->
<BasicTable @register="registerTable" style="top: -16px;position: relative;">
<!--操作栏-->
<template #action="{ record }">
<TableAction :actions="getTableAction(record)"/>
</template>
<!--字段回显插槽-->
<template #htmlSlot="{text}">
<div v-html="text"></div>
</template>
</BasicTable>
<!-- 表单区域 -->
<ZyGonggaoYlModal ref="registerModal" @success="handleSuccess"></ZyGonggaoYlModal>
</div>
</template>
<script lang="ts" name="zyGonggao-zyGonggao" setup>
import {ref, reactive, unref, defineExpose} from 'vue';
import { BasicTable, useTable, TableAction } from '/@/components/Table';
import { useListPage } from '/@/hooks/system/useListPage';
import { columns } from '../ZyGonggao.data';
import { historyList } from '../ZyGonggao.api';
import ZyGonggaoYlModal from './ZyGonggaoYlModal.vue';
import { useMessage } from "/@/hooks/web/useMessage";
const { createConfirm } = useMessage();
const queryParam = ref<any>({});
const toggleSearchStatus = ref<boolean>(false);
const registerModal = ref();
const gonggaoId = ref<string>();
//table
const { prefixCls, tableContext, onExportXls, onImportXls } = useListPage({
tableProps: {
title: '',
api: historyList,
columns,
canResize:false,
useSearchForm: false,
actionColumn: {
width: 220,
fixed: 'right',
},
beforeFetch: (params) => {
return Object.assign(params, queryParam.value);
},
},
});
const [registerTable, { reload, collapseAll, updateTableDataRecord, findTableDataRecord, getDataSource }, { rowSelection, selectedRowKeys }] = tableContext;
const labelCol = reactive({
xs: { span: 24 },
sm: { span: 7 },
});
const wrapperCol = reactive({
xs: { span: 24 },
sm: { span: 16 },
});
function edit(record){
gonggaoId.value = record.id;
queryParam.value.id = record.id;
reload();
}
/**
* 详情
*/
function handleDetail(record: Recordable) {
registerModal.value.disableSubmit = true;
registerModal.value.edit(record);
}
/**
* 成功回调
*/
function handleSuccess() {
(selectedRowKeys.value = []) && reload();
}
/**
* 操作栏
*/
function getTableAction(record) {
return [
{
label: '详情',
onClick: handleDetail.bind(null, record),
}
]
}
/**
* 查询
*/
function searchQuery() {
reload();
}
/**
* 重置
*/
function searchReset() {
queryParam.value = {};
selectedRowKeys.value = [];
queryParam.value.id = gonggaoId.value;
//
reload();
}
defineExpose({
edit,
});
</script>
<style lang="less" scoped>
.jeecg-basic-table-form-container {
.table-page-search-submitButtons {
display: block;
margin-bottom: 24px;
white-space: nowrap;
}
.query-group-cust{
width: calc(50% - 15px);
min-width: 100px !important;
}
.query-group-split-cust{
width: 30px;
display: inline-block;
text-align: center
}
}
</style>

View File

@ -0,0 +1,61 @@
<template>
<a-modal :title="title" :width="width" :centered="true" :visible="visible" @ok="handleOk" :okButtonProps="{ class: { 'jee-hidden': disableSubmit } }" @cancel="handleCancel" cancelText="关闭">
<ZyGonggaoHistoryList ref="registerModal" @ok="submitCallback" :formDisabled="disableSubmit" :formBpm="false"></ZyGonggaoHistoryList>
</a-modal>
</template>
<script lang="ts" setup>
import { ref, nextTick, defineExpose } from 'vue'
import ZyGonggaoHistoryList from './ZyGonggaoHistoryList.vue'
const title = ref<string>('');
const width = ref<number>(800);
const visible = ref<boolean>(false);
const disableSubmit = ref<boolean>(false);
//model
const registerModal = ref();
const emit = defineEmits(['register', 'success']);
/**
* form保存回调事件
*/
function submitCallback() {
handleCancel();
emit('success');
}
function edit(record){
title.value = '历史通知';
visible.value = true;
nextTick(() => {
registerModal.value.edit(record);
});
}
/**
* 确定按钮点击事件
*/
function handleOk() {
registerModal.value.submitForm();
}
/**
* 取消按钮回调事件
*/
function handleCancel() {
visible.value = false;
emit('success');
}
defineExpose({
edit,
disableSubmit,
});
</script>
<style>
/**隐藏样式-modal确定按钮 */
.jee-hidden {
display: none !important;
}
</style>

View File

@ -0,0 +1,129 @@
<template>
<a-spin :spinning="confirmLoading">
<a-form ref="formRef" class="antd-modal-form" :labelCol="labelCol" :wrapperCol="wrapperCol">
<a-row>
<a-col :span="24" style="font-size: 16px;color: #515151 ;font-weight: bold;padding:10px;line-height: 30px;text-align: center;">
<div v-html="formData.title"></div>
</a-col>
<a-col :span="24" style="color: #515151">
<div v-html="formData.content"></div>
</a-col>
</a-row>
</a-form>
</a-spin>
</template>
<script lang="ts" setup>
import { ref, reactive, defineExpose, nextTick, defineProps, computed, onMounted,unref } from 'vue';
import { defHttp } from '/@/utils/http/axios';
import { useMessage } from '/@/hooks/web/useMessage';
import JEditor from '/@/components/Form/src/jeecg/components/JEditor.vue';
import { getValueType } from '/@/utils';
import { saveOrUpdate } from '../ZyGonggao.api';
import { Form } from 'ant-design-vue';
import { useRouter } from 'vue-router';
const props = defineProps({
formDisabled: { type: Boolean, default: false },
formData: { type: Object, default: ()=>{} },
formBpm: { type: Boolean, default: true }
});
const { currentRoute } = useRouter();
const { query } = unref(currentRoute);
const { rwbh,xqxn } = query;//
const formRef = ref();
const useForm = Form.useForm;
const emit = defineEmits(['register', 'ok']);
const formData = reactive<Record<string, any>>({
id: '',
title: '',
content: '',
});
const { createMessage, createConfirm } = useMessage();
const labelCol = ref<any>({ xs: { span: 24 }, sm: { span: 5 } });
const wrapperCol = ref<any>({ xs: { span: 24 }, sm: { span: 16 } });
const confirmLoading = ref<boolean>(false);
//
const validatorRules = {
title: [{ required: true, message: '请输入标题!'},],
content: [{ required: true, message: '请输入内容!'},],
};
const { resetFields, validate, validateInfos } = useForm(formData, validatorRules, { immediate: true });
//
const disabled = computed(()=>{
if(props.formBpm === true){
if(props.formData.disabled === false){
return false;
}else{
return true;
}
}
return props.formDisabled;
});
/**
* 新增
*/
function add() {
edit({rwbh,xqxn});
}
/**
* 编辑
*/
function edit(record) {
nextTick(() => {
resetFields();
//
Object.assign(formData, record);
});
}
/**
* 提交数据
*/
async function submitForm() {
createConfirm({
iconType: 'warning',
title: '确认发布',
content: '是否发布此通知?',
okText: '发布',
cancelText: '取消',
onOk: () => {
confirmLoading.value = true;
var params = {id:formData.id,ggStatus:"1",flag:"1",fbTime:new Date()}
defHttp.post({url: '/zyGonggao/zyGonggao/edit', params: params},{ isTransformResponse: false })
.then((res) => {
if (res.success) {
createMessage.success(res.message);
console.log("111111111");
emit('ok');
} else {
createMessage.warning(res.message);
console.log("222222");
}
})
.finally(() => {
confirmLoading.value = false;
});
}
});
}
defineExpose({
add,
edit,
submitForm,
});
</script>
<style lang="less" scoped>
.antd-modal-form {
min-height: 500px !important;
overflow-y: auto;
padding: 24px 24px 24px 24px;
}
</style>

View File

@ -0,0 +1,75 @@
<template>
<a-modal :title="title" :width="width" :visible="visible" ok-text="发布" @ok="handleOk" :okButtonProps="{ class: { 'jee-hidden': disableSubmit } }" @cancel="handleCancel" cancelText="关闭">
<ZyGonggaoYlForm ref="registerForm" @ok="submitCallback" :formDisabled="disableSubmit" :formBpm="false"></ZyGonggaoYlForm>
</a-modal>
</template>
<script lang="ts" setup>
import { ref, nextTick, defineExpose } from 'vue';
import ZyGonggaoYlForm from './ZyGonggaoYlForm.vue'
const title = ref<string>('');
const width = ref<number>(800);
const visible = ref<boolean>(false);
const disableSubmit = ref<boolean>(false);
const registerForm = ref();
const emit = defineEmits(['register', 'success']);
/**
* 新增
*/
function add() {
title.value = '新增';
visible.value = true;
nextTick(() => {
registerForm.value.add();
});
}
/**
* 编辑
* @param record
*/
function edit(record) {
title.value = disableSubmit.value ? '详情' : '预览';
visible.value = true;
nextTick(() => {
registerForm.value.edit(record);
});
}
/**
* 确定按钮点击事件
*/
function handleOk() {
registerForm.value.submitForm();
}
/**
* form保存回调事件
*/
function submitCallback() {
handleCancel();
emit('success');
}
/**
* 取消按钮回调事件
*/
function handleCancel() {
visible.value = false;
}
defineExpose({
add,
edit,
disableSubmit,
});
</script>
<style>
/**隐藏样式-modal确定按钮 */
.jee-hidden {
display: none !important;
}
</style>