增加系统通知功能

This commit is contained in:
yaoyn
2024-08-29 17:01:30 +08:00
parent 5d15010535
commit 66662d9365
7 changed files with 1582 additions and 0 deletions

View File

@ -0,0 +1,87 @@
import { XjrNoticePageModel, XjrNoticePageParams, XjrNoticePageResult } from './model/SystemNoticeModel';
import { defHttp } from '/@/utils/http/axios';
import { ErrorMessageMode } from '/#/axios';
enum Api {
Page = '/system/systemNotice/page',
List = '/system/systemNotice/list',
Info = '/system/systemNotice/info',
XjrNotice = '/system/systemNotice',
}
/**
* @description: 查询XjrNotice分页列表
*/
export async function getXjrNoticePage(params: XjrNoticePageParams, mode: ErrorMessageMode = 'modal') {
return defHttp.get<XjrNoticePageResult>(
{
url: Api.Page,
params,
},
{
errorMessageMode: mode,
},
);
}
/**
* @description: 获取XjrNotice信息
*/
export async function getXjrNotice(id: String, mode: ErrorMessageMode = 'modal') {
return defHttp.get<XjrNoticePageModel>(
{
url: Api.Info,
params: { id },
},
{
errorMessageMode: mode,
},
);
}
/**
* @description: 新增XjrNotice
*/
export async function addXjrNotice(xjrNotice: Recordable, mode: ErrorMessageMode = 'modal') {
return defHttp.post<boolean>(
{
url: Api.XjrNotice,
params: xjrNotice,
},
{
errorMessageMode: mode,
},
);
}
/**
* @description: 更新XjrNotice
*/
export async function updateXjrNotice(xjrNotice: Recordable, mode: ErrorMessageMode = 'modal') {
return defHttp.put<boolean>(
{
url: Api.XjrNotice,
params: xjrNotice,
},
{
errorMessageMode: mode,
},
);
}
/**
* @description: 删除XjrNotice批量删除
*/
export async function deleteXjrNotice(ids: string[], mode: ErrorMessageMode = 'modal') {
return defHttp.delete<boolean>(
{
url: Api.XjrNotice,
data: ids,
},
{
errorMessageMode: mode,
},
);
}

View File

@ -0,0 +1,114 @@
import { BasicPageParams, BasicFetchResult } from '/@/api/model/baseModel';
/**
* @description: XjrNotice分页参数 模型
*/
export interface XjrNoticePageParams extends BasicPageParams {
title: string;
type: string;
publisherType: string;
publisher: string;
status: string;
}
/**
* @description: XjrNotice分页返回值模型
*/
export interface XjrNoticePageModel {
id: string;
title: string;
type: string;
publisherType: string;
publisher: string;
status: string;
}
/**
* @description: XjrNotice表类型
*/
export interface XjrNoticeModel {
id: number;
title: string;
type: number;
typeName: string;
publisher: number;
publisherType: number;
publisherName: number;
content: string;
attachs: number;
status: number;
createUserId: number;
createDate: string;
modifyUserId: number;
modifyDate: string;
deleteMark: number;
enabledMark: number;
deptId: number;
tenantId: number;
ruleUserId: number;
xjrNoticeUserList?: XjrNoticeUserModel;
}
/**
* @description: XjrNoticeUser表类型
*/
export interface XjrNoticeUserModel {
id: number;
noticeId: number;
userId: number;
isRead: number;
reply: string;
createUserId: number;
createDate: string;
modifyUserId: number;
modifyDate: string;
deleteMark: number;
enabledMark: number;
deptId: number;
tenantId: number;
}
/**
* @description: XjrNotice分页返回值结构
*/
export type XjrNoticePageResult = BasicFetchResult<XjrNoticePageModel>;

View File

@ -0,0 +1,174 @@
<template>
<SimpleForm
ref="systemFormRef"
:formProps="data.formDataProps"
:formModel="{}"
:isWorkFlow="props.fromPage!=FromPageType.MENU"
/>
</template>
<script lang="ts" setup>
import { reactive, ref, onMounted } from 'vue';
import { formProps, formEventConfigs } from './config';
import SimpleForm from '/@/components/SimpleForm/src/SimpleForm.vue';
import { addXjrNotice, getXjrNotice, updateXjrNotice } from '/@/api/system/systemNotice';
import { cloneDeep } from 'lodash-es';
import { FormDataProps } from '/@/components/Designer/src/types';
import { usePermission } from '/@/hooks/web/usePermission';
import { FromPageType } from '/@/enums/workflowEnum';
import { createFormEvent, getFormDataEvent, loadFormEvent, submitFormEvent,} from '/@/hooks/web/useFormEvent';
import { changeWorkFlowForm, changeSchemaDisabled } from '/@/hooks/web/useWorkFlowForm';
import { WorkFlowFormParams } from '/@/model/workflow/bpmnConfig';
const { filterFormSchemaAuth } = usePermission();
const RowKey = 'id';
const emits = defineEmits(['changeUploadComponentIds','loadingCompleted', 'form-mounted']);
const props = defineProps({
fromPage: {
type: Number,
default: FromPageType.MENU,
},
});
const systemFormRef = ref();
const data: { formDataProps: FormDataProps } = reactive({
formDataProps: cloneDeep(formProps),
});
const state = reactive({
formModel: {},
});
onMounted(async () => {
try {
if (props.fromPage == FromPageType.MENU) {
setMenuPermission();
await createFormEvent(formEventConfigs, state.formModel,
systemFormRef.value,
formProps.schemas); //表单事件:初始化表单
await loadFormEvent(formEventConfigs, state.formModel,
systemFormRef.value,
formProps.schemas); //表单事件:加载表单
} else if (props.fromPage == FromPageType.FLOW) {
emits('loadingCompleted'); //告诉系统表单已经加载完毕
// loadingCompleted后 工作流页面直接利用Ref调用setWorkFlowForm方法
} else if (props.fromPage == FromPageType.PREVIEW) {
// 预览 无需权限,表单事件也无需执行
} else if (props.fromPage == FromPageType.DESKTOP) {
// 桌面设计 表单事件需要执行
emits('loadingCompleted'); //告诉系统表单已经加载完毕
await createFormEvent(formEventConfigs, state.formModel,
systemFormRef.value,
formProps.schemas); //表单事件:初始化表单
await loadFormEvent(formEventConfigs, state.formModel,
systemFormRef.value,
formProps.schemas); //表单事件:加载表单
}
emits('form-mounted', formProps);
} catch (error) {
}
});
// 根据菜单页面权限,设置表单属性(必填,禁用,显示)
function setMenuPermission() {
data.formDataProps.schemas = filterFormSchemaAuth(formProps.schemas!);
}
// 校验form 通过返回表单数据
async function validate() {
let values = [];
try {
values = await systemFormRef.value?.validate();
//添加隐藏组件
if (data.formDataProps.hiddenComponent?.length) {
data.formDataProps.hiddenComponent.forEach((component) => {
values[component.bindField] = component.value;
});
}
} finally {
}
return values;
}
// 根据行唯一ID查询行数据并设置表单数据 【编辑】
async function setFormDataFromId(rowId) {
try {
const record = await getXjrNotice(rowId);
setFieldsValue(record);
state.formModel = record;
await getFormDataEvent(formEventConfigs, state.formModel,
systemFormRef.value,
formProps.schemas); //表单事件:获取表单数据
return record;
} catch (error) {
}
}
// 辅助设置表单数据
function setFieldsValue(record) {
systemFormRef.value.setFieldsValue(record);
}
// 重置表单数据
async function resetFields() {
await systemFormRef.value.resetFields();
}
// 设置表单数据全部为Disabled 【查看】
async function setDisabledForm() {
data.formDataProps.schemas = changeSchemaDisabled(cloneDeep(data.formDataProps.schemas));
}
// 获取行键值
function getRowKey() {
return RowKey;
}
// 更新api表单数据
async function update({ values, rowId }) {
try {
values[RowKey] = rowId;
state.formModel = values;
let saveVal = await updateXjrNotice(values);
await submitFormEvent(formEventConfigs, state.formModel,
systemFormRef.value,
formProps.schemas); //表单事件:提交表单
return saveVal;
} catch (error) {}
}
// 新增api表单数据
async function add(values) {
try {
state.formModel = values;
let saveVal = await addXjrNotice(values);
await submitFormEvent(formEventConfigs, state.formModel,
systemFormRef.value,
formProps.schemas); //表单事件:提交表单
return saveVal;
} catch (error) {}
}
// 根据工作流页面权限,设置表单属性(必填,禁用,显示)
async function setWorkFlowForm(obj: WorkFlowFormParams) {
try {
let flowData = changeWorkFlowForm(cloneDeep(formProps), obj);
let { buildOptionJson, uploadComponentIds, formModels, isViewProcess } = flowData;
data.formDataProps = buildOptionJson;
emits('changeUploadComponentIds', uploadComponentIds); //工作流中必须保存上传组件id【附件汇总需要】
if (isViewProcess) {
setDisabledForm(); //查看
}
state.formModel = formModels;
setFieldsValue(formModels);
} catch (error) {}
await createFormEvent(formEventConfigs, state.formModel,
systemFormRef.value,
formProps.schemas); //表单事件:初始化表单
await loadFormEvent(formEventConfigs, state.formModel,
systemFormRef.value,
formProps.schemas); //表单事件:加载表单
}
defineExpose({
setFieldsValue,
resetFields,
validate,
add,
update,
setFormDataFromId,
setDisabledForm,
setMenuPermission,
setWorkFlowForm,
getRowKey,
});
</script>

View File

@ -0,0 +1,110 @@
<template>
<BasicModal v-bind="$attrs" @register="registerModal" :title="getTitle" @ok="handleSubmit" @cancel="handleClose" :paddingRight="15" :bodyStyle="{ minHeight: '400px !important' }">
<ModalForm ref="formRef" :fromPage="FromPageType.MENU" />
</BasicModal>
</template>
<script lang="ts" setup>
import { ref, computed, reactive } from 'vue';
import { BasicModal, useModalInner } from '/@/components/Modal';
import { useMessage } from '/@/hooks/web/useMessage';
import { useI18n } from '/@/hooks/web/useI18n';
import { formProps } from './config';
import ModalForm from './Form.vue';
import { FromPageType } from '/@/enums/workflowEnum';
const emit = defineEmits(['success', 'register']);
const { notification } = useMessage();
const formRef = ref();
const state = reactive({
formModel: {},
isUpdate: true,
isView: false,
isCopy: false,
rowId: '',
});
const { t } = useI18n();
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
state.isUpdate = !!data?.isUpdate;
state.isView = !!data?.isView;
state.isCopy = !!data?.isCopy;
setModalProps({
destroyOnClose: true,
maskClosable: false,
showCancelBtn: !state.isView,
showOkBtn: !state.isView,
canFullscreen: true,
width: 900,
});
if (state.isUpdate || state.isView || state.isCopy) {
state.rowId = data.id;
if (state.isView) {
await formRef.value.setDisabledForm();
}
await formRef.value.setFormDataFromId(state.rowId);
} else {
formRef.value.resetFields();
}
});
const getTitle = computed(() => (state.isView ? '查看' : !state.isUpdate ? '新增' : '编辑'));
async function saveModal() {
let saveSuccess = false;
try {
const values = await formRef.value?.validate();
//添加隐藏组件
if (formProps.hiddenComponent?.length) {
formProps.hiddenComponent.forEach((component) => {
values[component.bindField] = component.value;
});
}
if (values !== false) {
try {
if (!state.isUpdate || state.isCopy) {
saveSuccess = await formRef.value.add(values);
} else {
saveSuccess = await formRef.value.update({ values, rowId: state.rowId });
}
return saveSuccess;
} catch (error) {}
}
} catch (error) {
return saveSuccess;
}
}
async function handleSubmit() {
try {
const saveSuccess = await saveModal();
setModalProps({ confirmLoading: true });
if (saveSuccess) {
if (!state.isUpdate || state.isCopy) {
//false 新增
notification.success({
message: 'Tip',
description: t('新增成功!'),
}); //提示消息
} else {
notification.success({
message: 'Tip',
description: t('修改成功!'),
}); //提示消息
}
closeModal();
formRef.value.resetFields();
emit('success');
}
} finally {
setModalProps({ confirmLoading: false });
}
}
function handleClose() {
formRef.value.resetFields();
}
</script>

View File

@ -0,0 +1,563 @@
import { FormProps, FormSchema } from '/@/components/Form';
import { BasicColumn } from '/@/components/Table';
import { uploadApi } from '/@/api/sys/upload';
export const searchFormSchema: FormSchema[] = [
{
field: 'title',
label: '标题',
component: 'Input',
},
{
field: 'type',
label: '类型',
component: 'XjrSelect',
componentProps: {
datasourceType: 'dic',
params: { itemId: '1718831555510091777' },
labelField: 'name',
valueField: 'value',
getPopupContainer: () => document.body,
},
},
{
field: 'publisherType',
label: '发布主体类型',
component: 'XjrSelect',
componentProps: {
datasourceType: 'staticData',
staticOptions: [
{ key: 1, label: '组织', value: '1' },
{ key: 2, label: '用户', value: '0' },
],
labelField: 'label',
valueField: 'value',
getPopupContainer: () => document.body,
},
},
{
field: 'publisher',
label: '发布主体',
component: 'Dept',
componentProps: {
placeholder: '请选择',
getPopupContainer: () => document.body,
},
},
{
field: 'status',
label: '发布状态',
component: 'XjrSelect',
componentProps: {
datasourceType: 'staticData',
staticOptions: [
{ key: 1, label: '草稿', value: '0' },
{ key: 2, label: '已发布', value: '1' },
{ key: 3, label: '已结束', value: '2' },
],
labelField: 'label',
valueField: 'value',
getPopupContainer: () => document.body,
},
},
];
export const columns: BasicColumn[] = [
{
dataIndex: 'title',
title: '标题',
componentType: 'input',
align: 'left',
sorter: true,
},
{
dataIndex: 'type',
title: '类型',
componentType: 'select',
align: 'left',
sorter: true,
},
{
dataIndex: 'publisherType',
title: '发布主体类型',
componentType: 'radio',
align: 'left',
customRender: ({ record }) => {
const staticOptions = [
{ key: 1, label: '组织', value: '1' },
{ key: 2, label: '用户', value: '0' },
];
return staticOptions.filter((x) => x.value === record.publisherType)[0]?.label;
},
sorter: true,
},
{
dataIndex: 'publisher',
title: '发布主体',
componentType: 'organization',
align: 'left',
sorter: true,
},
{
dataIndex: 'status',
title: '发布状态',
componentType: 'select',
align: 'left',
customRender: ({ record }) => {
const staticOptions = [
{ key: 1, label: '草稿', value: '0' },
{ key: 2, label: '已发布', value: '1' },
{ key: 3, label: '已结束', value: '2' },
];
return staticOptions.filter((x) => x.value === record.status)[0]?.label;
},
sorter: true,
},
];
//表单事件
export const formEventConfigs = {
0: [
{
type: 'circle',
color: '#2774ff',
text: '开始节点',
icon: '#icon-kaishi',
bgcColor: '#D8E5FF',
isUserDefined: false,
},
{
color: '#F6AB01',
icon: '#icon-chushihua',
text: '初始化表单',
bgcColor: '#f9f5ea',
isUserDefined: false,
nodeInfo: { processEvent: [] },
},
],
1: [
{
color: '#B36EDB',
icon: '#icon-shujufenxi',
text: '获取表单数据',
detail: '(新增无此操作)',
bgcColor: '#F8F2FC',
isUserDefined: false,
nodeInfo: { processEvent: [] },
},
],
2: [
{
color: '#F8625C',
icon: '#icon-jiazai',
text: '加载表单',
bgcColor: '#FFF1F1',
isUserDefined: false,
nodeInfo: { processEvent: [] },
},
],
3: [
{
color: '#6C6AE0',
icon: '#icon-jsontijiao',
text: '提交表单',
bgcColor: '#F5F4FF',
isUserDefined: false,
nodeInfo: { processEvent: [] },
},
],
4: [
{
type: 'circle',
color: '#F8625C',
text: '结束节点',
icon: '#icon-jieshuzhiliao',
bgcColor: '#FFD6D6',
isLast: true,
isUserDefined: false,
},
],
};
export const formProps: FormProps = {
labelCol: { span: 3, offset: 0 },
labelAlign: 'right',
layout: 'horizontal',
size: 'default',
schemas: [
{
key: '7b8d7c4f6460482b808e9d6cf62f384c',
field: '',
label: '标题',
type: 'title',
component: 'Title',
colProps: { span: 24 },
defaultValue: '通知',
componentProps: {
defaultValue: '通知',
color: '',
align: 'left',
fontSize: 18,
isShow: true,
style: {},
},
},
{
key: 'b0f1185fbd5e4301b3ce642adee6f714',
field: 'title',
label: '标题',
type: 'input',
component: 'Input',
colProps: { span: 24 },
defaultValue: '',
componentProps: {
width: '100%',
span: '',
defaultValue: '',
labelWidthMode: 'fix',
labelFixWidth: 120,
responsive: true,
respNewRow: false,
placeholder: '请输入标题',
maxlength: null,
prefix: '',
suffix: '',
addonBefore: '',
addonAfter: '',
disabled: false,
allowClear: false,
showLabel: true,
required: true,
rules: [],
events: {},
isSave: false,
isShow: true,
scan: false,
style: { width: '100%' },
},
},
{
key: 'bd89a831bc2a4600aa6cf62ce68f1a83',
field: 'type',
label: '类型',
type: 'select',
component: 'XjrSelect',
colProps: { span: 24 },
componentProps: {
width: '100%',
span: '',
labelWidthMode: 'fix',
labelFixWidth: 120,
responsive: true,
respNewRow: false,
placeholder: '请选择类型',
sepTextField: '',
showLabel: true,
showSearch: false,
clearable: false,
disabled: false,
staticOptions: [
{ key: 1, label: 'Option 1', value: 'Option 1' },
{ key: 2, label: 'Option 2', value: 'Option 2' },
{ key: 3, label: 'Option 3', value: 'Option 3' },
],
defaultSelect: null,
datasourceType: 'dic',
params: { itemId: '1718831555510091777' },
labelField: 'name',
valueField: 'value',
apiConfig: {
path: 'CodeGeneration/selection',
method: 'GET',
apiId: '93d735dcb7364a0f8102188ec4d77ac7',
},
dicOptions: [],
required: true,
rules: [],
events: {},
isShow: true,
itemId: '1718831555510091777',
style: { width: '100%' },
},
},
{
key: 'cda07002c20341b5a3a463ab71f6f6bb',
field: 'publisherType',
label: '发布主体类型',
type: 'radio',
component: 'ApiRadioGroup',
colProps: { span: 24 },
componentProps: {
span: '',
labelWidthMode: 'fix',
labelFixWidth: 120,
responsive: true,
respNewRow: false,
showLabel: true,
disabled: false,
optionType: 'default',
staticOptions: [
{ key: 1, label: '组织', value: '1' },
{ key: 2, label: '用户', value: '0' },
],
datasourceType: 'staticData',
labelField: 'label',
valueField: 'value',
defaultSelect: '1',
apiConfig: {
path: 'CodeGeneration/selection',
method: 'GET',
apiId: '93d735dcb7364a0f8102188ec4d77ac7',
},
dicOptions: [],
required: false,
rules: [],
events: {},
isShow: true,
params: null,
style: {},
},
},
{
key: '491b4e9de46a4d6486e339aacdef8015',
field: 'publisher',
label: '发布主体',
type: 'organization',
component: 'Dept',
colProps: { span: 24 },
componentProps: {
labelWidthMode: 'fix',
labelFixWidth: 120,
parentNode: '',
responsive: true,
sepTextField: '',
span: '',
width: '100%',
orgzType: 0,
placeholder: '请选择发布主体',
showLabel: true,
disabled: false,
required: false,
isShow: true,
events: {},
style: { width: '100%' },
},
},
{
key: '351960d97c424dfc84e198b94b0405a5',
field: 'status',
label: '发布状态',
type: 'select',
component: 'XjrSelect',
colProps: { span: 24 },
componentProps: {
width: '100%',
span: '',
labelWidthMode: 'fix',
labelFixWidth: 120,
responsive: true,
respNewRow: false,
placeholder: '请选择发布状态',
sepTextField: '',
showLabel: true,
showSearch: false,
clearable: false,
disabled: false,
staticOptions: [
{ key: 1, label: '草稿', value: '0' },
{ key: 2, label: '已发布', value: '1' },
{ key: 3, label: '已结束', value: '2' },
],
defaultSelect: '0',
datasourceType: 'staticData',
params: null,
labelField: 'label',
valueField: 'value',
apiConfig: {
path: 'CodeGeneration/selection',
method: 'GET',
apiId: '93d735dcb7364a0f8102188ec4d77ac7',
},
dicOptions: [],
required: false,
rules: [],
events: {},
isShow: true,
style: { width: '100%' },
},
},
{
key: '9628fc13869d420d8ab505dae01127cc',
field: 'content',
label: '内容',
type: 'richtext-editor',
component: 'RichTextEditor',
colProps: { span: 24 },
defaultValue: '',
componentProps: {
labelWidthMode: 'fix',
labelFixWidth: 120,
span: '',
defaultValue: '',
width: '100%',
disabled: false,
showLabel: true,
required: false,
isShow: true,
rules: [],
events: {},
style: { width: '100%' },
},
},
{
key: '4d5977260e2b45a3a75bb9917f6d3cc2',
field: 'attachs',
label: '附件',
type: 'upload',
component: 'Upload',
colProps: { span: 24 },
componentProps: {
api: uploadApi,
labelWidthMode: 'fix',
labelFixWidth: 120,
span: '',
defaultValue: [],
accept: '',
maxNumber: 5,
maxSize: 5,
showLabel: true,
multiple: true,
disabled: false,
required: false,
isShow: true,
events: {},
listType: 'text',
},
},
{
key: '8abfa905aa4243658aaf33f71872f4da',
label: '通知人员',
field: 'xjrNoticeUserList',
type: 'form',
component: 'SubForm',
required: true,
colProps: { span: 24 },
componentProps: {
mainKey: 'xjrNoticeUserList',
columns: [
{
key: '6b00ebe98c3c4c83a82519399de7ec57',
title: '人员',
dataIndex: 'userId',
componentType: 'User',
defaultValue: '',
componentProps: {
labelWidthMode: 'fix',
labelFixWidth: 120,
responsive: false,
sepTextField: '',
span: '',
width: '100%',
defaultValue: '',
placeholder: '请选择人员',
userType: 0,
prefix: '',
suffix: 'ant-design:setting-outlined',
showLabel: true,
disabled: false,
required: true,
isShow: true,
events: {},
},
},
{
key: '33835f3894c54e39baebd3abb0dc447e',
title: '已读',
dataIndex: 'isRead',
componentType: 'Switch',
defaultValue: 0,
componentProps: {
span: '',
labelWidthMode: 'fix',
labelFixWidth: 120,
responsive: false,
respNewRow: false,
defaultValue: 0,
checkedChildren: '',
unCheckedChildren: '',
checkedColor: '#5e95ff',
unCheckedColor: '#bbbdbf',
showLabel: true,
disabled: true,
events: {},
isShow: true,
},
},
{
key: 'bf5c3106785f4d64ab57c7fc76980b85',
title: '回复',
dataIndex: 'reply',
componentType: 'Input',
defaultValue: '',
componentProps: {
width: '100%',
span: '',
defaultValue: '',
labelWidthMode: 'fix',
labelFixWidth: 120,
responsive: false,
respNewRow: false,
placeholder: '暂无回复',
maxlength: null,
prefix: '',
suffix: '',
addonBefore: '',
addonAfter: '',
disabled: true,
allowClear: false,
showLabel: true,
required: false,
rules: [],
events: {},
isSave: false,
isShow: true,
scan: false,
},
},
{ title: '操作', key: 'action', fixed: 'right', width: '50px' },
],
span: '24',
preloadType: 'api',
apiConfig: {},
itemId: '',
dicOptions: [],
useSelectButton: false,
buttonName: '选择数据',
showLabel: true,
showComponentBorder: true,
showFormBorder: true,
showIndex: true,
isShow: true,
multipleHeads: [],
},
},
],
showActionButtonGroup: false,
buttonLocation: 'center',
actionColOptions: { span: 24 },
showResetButton: false,
showSubmitButton: false,
hiddenComponent: [],
};

View File

@ -0,0 +1,179 @@
export const permissionList = [
{
required: false,
view: true,
edit: false,
disabled: true,
isSaveTable: false,
tableName: '',
fieldName: '标题',
fieldId: '',
isSubTable: false,
showChildren: true,
type: 'title',
key: '7b8d7c4f6460482b808e9d6cf62f384c',
children: [],
},
{
required: true,
view: true,
edit: true,
disabled: false,
isSaveTable: false,
tableName: '',
fieldName: '标题',
fieldId: 'title',
isSubTable: false,
showChildren: true,
type: 'input',
key: 'b0f1185fbd5e4301b3ce642adee6f714',
children: [],
},
{
required: true,
view: true,
edit: true,
disabled: false,
isSaveTable: false,
tableName: '',
fieldName: '类型',
fieldId: 'type',
isSubTable: false,
showChildren: true,
type: 'select',
key: 'bd89a831bc2a4600aa6cf62ce68f1a83',
children: [],
},
{
required: true,
view: true,
edit: true,
disabled: false,
isSaveTable: false,
tableName: '',
fieldName: '发布主体类型',
fieldId: 'publisherType',
isSubTable: false,
showChildren: true,
type: 'radio',
key: 'cda07002c20341b5a3a463ab71f6f6bb',
children: [],
},
{
required: true,
view: true,
edit: true,
disabled: false,
isSaveTable: false,
tableName: '',
fieldName: '发布主体',
fieldId: 'publisher',
isSubTable: false,
showChildren: true,
type: 'organization',
key: '491b4e9de46a4d6486e339aacdef8015',
children: [],
},
{
required: true,
view: true,
edit: true,
disabled: false,
isSaveTable: false,
tableName: '',
fieldName: '发布状态',
fieldId: 'status',
isSubTable: false,
showChildren: true,
type: 'select',
key: '351960d97c424dfc84e198b94b0405a5',
children: [],
},
{
required: true,
view: true,
edit: true,
disabled: false,
isSaveTable: false,
tableName: '',
fieldName: '内容',
fieldId: 'content',
isSubTable: false,
showChildren: true,
type: 'richtext-editor',
key: '9628fc13869d420d8ab505dae01127cc',
children: [],
},
{
required: true,
view: true,
edit: true,
disabled: false,
isSaveTable: false,
tableName: '',
fieldName: '附件',
fieldId: 'attachs',
isSubTable: false,
showChildren: true,
type: 'upload',
key: '4d5977260e2b45a3a75bb9917f6d3cc2',
children: [],
},
{
required: true,
view: true,
edit: true,
disabled: false,
isSubTable: true,
showChildren: false,
tableName: 'xjrNoticeUserList',
fieldName: '通知人员',
fieldId: 'xjrNoticeUserList',
type: 'form',
key: '8abfa905aa4243658aaf33f71872f4da',
children: [
{
required: true,
view: true,
edit: true,
disabled: false,
isSubTable: true,
isSaveTable: false,
showChildren: false,
tableName: 'xjrNoticeUserList',
fieldName: '人员',
fieldId: 'userId',
key: '6b00ebe98c3c4c83a82519399de7ec57',
children: [],
},
{
required: true,
view: true,
edit: true,
disabled: false,
isSubTable: true,
isSaveTable: false,
showChildren: false,
tableName: 'xjrNoticeUserList',
fieldName: '已读',
fieldId: 'isRead',
key: '33835f3894c54e39baebd3abb0dc447e',
children: [],
},
{
required: true,
view: true,
edit: true,
disabled: false,
isSubTable: true,
isSaveTable: false,
showChildren: false,
tableName: 'xjrNoticeUserList',
fieldName: '回复',
fieldId: 'reply',
key: 'bf5c3106785f4d64ab57c7fc76980b85',
children: [],
},
],
},
];

View File

@ -0,0 +1,355 @@
<template>
<PageWrapper dense fixedHeight contentFullHeight contentClass="flex">
<BasicTable @register="registerTable" ref="tableRef" @row-dbClick="dbClickRow">
<template #toolbar>
<template v-for="button in tableButtonConfig" :key="button.code">
<a-button v-if="button.isDefault" :type="button.type" @click="buttonClick(button.code)">
<template #icon><Icon :icon="button.icon" /></template>
{{ button.name }}
</a-button>
<a-button v-else :type="button.type">
<template #icon><Icon :icon="button.icon" /></template>
{{ button.name }}
</a-button>
</template>
</template>
<template #bodyCell="{ column, record }">
<template v-if="column.dataIndex === 'action'">
<TableAction :actions="getActions(record)" />
</template>
</template>
</BasicTable>
<SystemNoticeModal @register="registerModal" @success="handleSuccess" />
</PageWrapper>
</template>
<script lang="ts" setup>
import { ref, computed, onMounted, onUnmounted, createVNode,
} from 'vue';
import { Modal } from 'ant-design-vue';
import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
import { BasicTable, useTable, TableAction, ActionItem } from '/@/components/Table';
import { getXjrNoticePage, deleteXjrNotice} from '/@/api/system/systemNotice';
import { PageWrapper } from '/@/components/Page';
import { useMessage } from '/@/hooks/web/useMessage';
import { useI18n } from '/@/hooks/web/useI18n';
import { usePermission } from '/@/hooks/web/usePermission';
import { useRouter } from 'vue-router';
import { getXjrNotice } from '/@/api/system/systemNotice';
import { useModal } from '/@/components/Modal';
import SystemNoticeModal from './components/SystemNoticeModal.vue';
import { searchFormSchema, columns } from './components/config';
import Icon from '/@/components/Icon/index';
import useEventBus from '/@/hooks/event/useEventBus';
const { bus, CREATE_FLOW, FLOW_PROCESSED, FORM_LIST_MODIFIED } = useEventBus();
const { notification } = useMessage();
const { t } = useI18n();
defineEmits(['register']);
const { filterColumnAuth, filterButtonAuth } = usePermission();
const filterColumns = filterColumnAuth(columns);
const tableRef = ref();
//展示在列表内的按钮
const actionButtons = ref<string[]>(['view', 'edit', 'copyData', 'delete', 'startwork','flowRecord']);
const buttonConfigs = computed(()=>{
const list = [{"isUse":true,"name":"新增","code":"add","icon":"ant-design:plus-outlined","isDefault":true,"type":"primary"},{"isUse":true,"name":"编辑","code":"edit","icon":"ant-design:form-outlined","isDefault":true},{"isUse":true,"name":"刷新","code":"refresh","icon":"ant-design:reload-outlined","isDefault":true},{"isUse":true,"name":"查看","code":"view","icon":"ant-design:eye-outlined","isDefault":true},{"isUse":true,"name":"复制数据","code":"copyData","icon":"ant-design:copy-outlined","isDefault":true},{"isUse":true,"name":"删除","code":"delete","icon":"ant-design:delete-outlined","isDefault":true}]
return filterButtonAuth(list);
})
const tableButtonConfig = computed(() => {
return buttonConfigs.value?.filter((x) => !actionButtons.value.includes(x.code));
});
const actionButtonConfig = computed(() => {
return buttonConfigs.value?.filter((x) => actionButtons.value.includes(x.code));
});
const btnEvent = {add : handleAdd,edit : handleEdit,refresh : handleRefresh,view : handleView,copyData : handleCopyData,delete : handleDelete,}
const { currentRoute } = useRouter();
const router = useRouter();
const formIdComputedRef = ref();
formIdComputedRef.value = currentRoute.value.meta.formId
const schemaIdComputedRef = ref();
schemaIdComputedRef.value = currentRoute.value.meta.schemaId
const [registerModal, { openModal }] = useModal();
const formName='系统通知';
const [registerTable, { reload, }] = useTable({
title: '' || (formName + '列表'),
api: getXjrNoticePage,
rowKey: 'id',
columns: filterColumns,
formConfig: {
rowProps: {
gutter: 16,
},
schemas: searchFormSchema,
fieldMapToTime: [],
showResetButton: false,
},
beforeFetch: (params) => {
return { ...params, FormId: formIdComputedRef.value, PK: 'id' };
},
afterFetch: (res) => {
tableRef.value.setToolBarWidth();
},
useSearchForm: true,
showTableSetting: true,
striped: false,
actionColumn: {
width: 160,
title: '操作',
dataIndex: 'action',
slots: { customRender: 'action' },
},
tableSetting: {
size: false,
setting: false,
},
});
function dbClickRow(record) {
const { processId, taskIds, schemaId } = record.workflowData || {};
if (taskIds && taskIds.length) {
router.push({
path: '/flow/' + schemaId + '/' + (processId || '') + '/approveFlow',
query: {
taskId: taskIds[0],
formName: formName
}
});
} else if (schemaId && !taskIds && processId) {
router.push({
path: '/flow/' + schemaId + '/' + processId + '/approveFlow',
query: {
readonly: 1,
taskId: '',
formName: formName
}
});
} else {
router.push({
path: '/form/systemNotice/' + record.id + '/viewForm',
query: {
formPath: 'system/systemNotice',
formName: formName
}
});
}
}
function buttonClick(code) {
btnEvent[code]();
}
function handleAdd() {
if (schemaIdComputedRef.value) {
router.push({
path: '/flow/' + schemaIdComputedRef.value + '/0/createFlow'
});
} else {
router.push({
path: '/form/systemNotice/0/createForm',
query: {
formPath: 'system/systemNotice',
formName: formName
}
});
}
}
function handleEdit(record: Recordable) {
router.push({
path: '/form/systemNotice/' + record.id + '/updateForm',
query: {
formPath: 'system/systemNotice',
formName: formName
}
});
}
async function handleCopyData(record: Recordable) {
/*//弹框添加数据
openModal(true, {
id: record.id,
isCopy: true,
});*/
const result = await getXjrNotice(record['id']);
const form={};
const key="form_copy_"+record['id'];
form[key]=result;
localStorage.setItem('formJsonStr', JSON.stringify(form));
const schemaId=record.workflowData?.schemaId||schemaIdComputedRef.value;
if(schemaId){
router.push({
path: '/flow/' + schemaId + '/0/createFlow',
query: {
fromKey: key
}
});
}else{
router.push({
path: '/form/systemNotice/0/createForm',
query: {
formPath: 'system/systemNotice',
formName: formName,
fromKey: key
}
});
}
}
function handleDelete(record: Recordable) {
deleteList([record.id]);
}
function deleteList(ids) {
Modal.confirm({
title: '提示信息',
icon: createVNode(ExclamationCircleOutlined),
content: '是否确认删除?',
okText: '确认',
cancelText: '取消',
onOk() {
deleteXjrNotice(ids).then((_) => {
handleSuccess();
notification.success({
message: 'Tip',
description: t('删除成功!'),
});
});
},
onCancel() {},
});
}
function handleRefresh() {
reload();
}
function handleSuccess() {
reload();
}
function handleView(record: Recordable) {
dbClickRow(record);
}
onMounted(() => {
if (schemaIdComputedRef.value) {
bus.on(FLOW_PROCESSED, handleRefresh);
bus.on(CREATE_FLOW, handleRefresh);
} else {
bus.on(FORM_LIST_MODIFIED, handleRefresh);
}
});
onUnmounted(() => {
if (schemaIdComputedRef.value) {
bus.off(FLOW_PROCESSED, handleRefresh);
bus.off(CREATE_FLOW, handleRefresh);
} else {
bus.off(FORM_LIST_MODIFIED, handleRefresh);
}
});
function getActions(record: Recordable):ActionItem[] {
const actionsList: ActionItem[] = actionButtonConfig.value?.map((button) => {
if (!record.workflowData?.processId) {
return {
icon: button?.icon,
tooltip: button?.name,
color: button.code === 'delete' ? 'error' : undefined,
onClick: btnEvent[button.code].bind(null, record),
};
} else {
if (button.code === 'view') {
return {
icon: button?.icon,
tooltip: button?.name,
onClick: btnEvent[button.code].bind(null, record),
};
} else {
return {};
}
}
});
return actionsList;
}
</script>
<style lang="less" scoped>
:deep(.ant-table-selection-col) {
width: 50px;
}
.show{
display: flex;
}
.hide{
display: none !important;
}
</style>