---初始化后台管理web页面项目

This commit is contained in:
2025-08-20 14:39:30 +08:00
parent ad49711a7e
commit 87545a8baf
2057 changed files with 282864 additions and 213 deletions

View File

@ -0,0 +1,142 @@
<template>
<BasicModal
v-bind="$attrs"
@register="registerModal"
:title="getTitle"
@ok="handleSubmit"
@cancel="handleClose"
:paddingRight="15"
:bodyStyle="{ minHeight: '400px !important' }"
>
<SimpleForm ref="formRef" :formProps="formProps" :formModel="state.formModel" />
</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 { usePermission } from '/@/hooks/web/usePermission';
import { add, getInfo, edit } from '/@/api/system/oa';
import { formProps } from './newsConfig';
import { cloneDeep } from 'lodash-es';
import SimpleForm from '/@/components/SimpleForm/src/SimpleForm.vue';
import { OaType } from '../../../../enums/oa';
const emit = defineEmits(['success', 'register']);
const { notification } = useMessage();
const { filterFormSchemaAuth } = usePermission();
const formRef = ref();
formProps.schemas = filterFormSchemaAuth(formProps.schemas!);
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: 800,
});
const viewformProps = cloneDeep(formProps);
setDisabled(viewformProps.schemas);
formRef.value.setProps(state.isView ? viewformProps : formProps);
if (state.isUpdate || state.isView || state.isCopy) {
state.rowId = data.id;
const record = await getInfo(data.id);
formRef.value.setFieldsValue(record);
} else {
formRef.value.resetFields();
}
});
const getTitle = computed(() => (state.isView ? '查看' : !state.isUpdate ? '新增' : '编辑'));
function setDisabled(schemas) {
const layoutComponents = ['tab', 'grid', 'card'];
schemas?.map((info) => {
if (layoutComponents.includes(info.type!)) {
info.children?.map((childInfo) => {
childInfo.list.map((com) => {
if (layoutComponents.includes(com.type)) {
setDisabled(childInfo.list);
} else {
com.dynamicDisabled = true;
}
});
});
} else if (info.type == 'table-layout') {
info.children?.map((childInfo) => {
childInfo.list.map((com) => {
com.children.map((el) => {
if (layoutComponents.includes(el.type) || el.type == 'table-layout') {
setDisabled(com.children);
} else {
el.dynamicDisabled = true;
}
});
});
});
} else if (info.type == 'one-for-one') {
setDisabled(info.componentProps.childSchemas);
} else {
info.dynamicDisabled = true;
}
});
}
async function handleSubmit() {
try {
let values = await formRef.value?.validate();
//添加隐藏组件
if (formProps.hiddenComponent?.length) {
formProps.hiddenComponent.forEach((component) => {
values[component.bindField] = component.value;
});
}
setModalProps({ confirmLoading: true });
values = { ...values, typeId: OaType.NEWS };
// TODO custom api
if (!state.isUpdate || state.isCopy) {
//false 新增
await add(values);
notification.success({
message: 'Tip',
description: t('新增成功!'),
}); //提示消息
} else {
values.id = state.rowId;
await edit(values);
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,142 @@
<template>
<BasicModal
v-bind="$attrs"
@register="registerModal"
:title="getTitle"
@ok="handleSubmit"
@cancel="handleClose"
:paddingRight="15"
:bodyStyle="{ minHeight: '400px !important' }"
>
<SimpleForm ref="formRef" :formProps="formProps" :formModel="state.formModel" />
</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 { usePermission } from '/@/hooks/web/usePermission';
import { add, getInfo, edit } from '/@/api/system/oa';
import { formProps } from './noticesConfig';
import { cloneDeep } from 'lodash-es';
import SimpleForm from '/@/components/SimpleForm/src/SimpleForm.vue';
import { OaType } from '/@/enums/oa';
const emit = defineEmits(['success', 'register']);
const { notification } = useMessage();
const { filterFormSchemaAuth } = usePermission();
const formRef = ref();
formProps.schemas = filterFormSchemaAuth(formProps.schemas!);
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: 600,
});
const viewformProps = cloneDeep(formProps);
setDisabled(viewformProps.schemas);
formRef.value.setProps(state.isView ? viewformProps : formProps);
if (state.isUpdate || state.isView || state.isCopy) {
state.rowId = data.id;
const record = await getInfo(data.id);
formRef.value.setFieldsValue(record);
} else {
formRef.value.resetFields();
}
});
const getTitle = computed(() => (state.isView ? '查看' : !state.isUpdate ? '新增' : '编辑'));
function setDisabled(schemas) {
const layoutComponents = ['tab', 'grid', 'card'];
schemas?.map((info) => {
if (layoutComponents.includes(info.type!)) {
info.children?.map((childInfo) => {
childInfo.list.map((com) => {
if (layoutComponents.includes(com.type)) {
setDisabled(childInfo.list);
} else {
com.dynamicDisabled = true;
}
});
});
} else if (info.type == 'table-layout') {
info.children?.map((childInfo) => {
childInfo.list.map((com) => {
com.children.map((el) => {
if (layoutComponents.includes(el.type) || el.type == 'table-layout') {
setDisabled(com.children);
} else {
el.dynamicDisabled = true;
}
});
});
});
} else if (info.type == 'one-for-one') {
setDisabled(info.componentProps.childSchemas);
} else {
info.dynamicDisabled = true;
}
});
}
async function handleSubmit() {
try {
let values = await formRef.value?.validate();
//添加隐藏组件
if (formProps.hiddenComponent?.length) {
formProps.hiddenComponent.forEach((component) => {
values[component.bindField] = component.value;
});
}
setModalProps({ confirmLoading: true });
values = { ...values, typeId: OaType.NOTICE };
// TODO custom api
if (!state.isUpdate || state.isCopy) {
//false 新增
await add(values);
notification.success({
message: 'Tip',
description: t('新增成功!'),
}); //提示消息
} else {
values.id = state.rowId;
await edit(values);
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,69 @@
<template>
<div class="box">
<div class="tag-box">
<div class="tag-item"
><span class="tag-title"> {{ props.viewData?.releaseTime }}</span></div
>
<div class="tag-item"><span class="tag-title hr"> |</span></div>
<div class="tag-item"
><span class="tag-title">{{ props.viewData?.categoryName }}</span></div
>
<div class="tag-item"><span class="tag-title hr"> |</span></div>
<div class="tag-item"
><span class="tag-title">{{
props.viewData?.typeId == OaType.NEWS
? '作者:' + props.viewData?.authorName
: '信息来源:' + props.viewData?.sourceName
}}</span></div
>
<div class="tag-item"><span class="tag-title hr"> |</span></div>
<div class="tag-item"
><span class="tag-title">{{
props.viewData?.typeId == OaType.NEWS
? '编辑:' + props.viewData?.compileName
: '信息地址:' + props.viewData?.sourceAddress
}}</span></div
>
</div>
<div class="content-box">
<div class="content" v-html="props.viewData?.newsContent"> </div>
</div>
</div>
</template>
<script setup lang="ts">
import { OaType } from '../../../../enums/oa';
const props = defineProps({
viewData: {
type: Object as PropType<any>,
},
});
</script>
<style scoped>
.box {
padding: 10px;
}
.tag-box {
margin-bottom: 10px;
display: flex;
}
.tag-item .tag-title {
font-size: 12px;
color: #a8a8a8;
}
.tag-item .hr {
margin: 0 10px;
}
.content-box {
color: #000;
background-color: #f7f7f7;
padding: 20px;
font-size: 14px;
height: 440px;
}
</style>

View File

@ -0,0 +1,307 @@
import { FormProps, FormSchema } from '/@/components/Form';
import { BasicColumn } from '/@/components/Table';
import { NewsCategoryDic } from '/@/enums/oa';
import { useI18n } from '/@/hooks/web/useI18n';
const { t } = useI18n();
export const searchFormSchema: FormSchema[] = [
{
field: 'keyword',
label: '关键字',
component: 'Input',
colProps: { span: 8 },
},
];
export const columns: BasicColumn[] = [
{
dataIndex: 'briefHead',
title: '新闻标题',
componentType: 'input',
sorter: true,
align: 'left',
},
{
dataIndex: 'authorName',
title: '作者',
componentType: 'input',
sorter: true,
align: 'left',
},
{
dataIndex: 'compileName',
title: '编辑',
componentType: 'input',
sorter: true,
align: 'left',
},
{
dataIndex: 'categoryName',
title: '新闻栏目',
componentType: 'input',
sorter: true,
align: 'left',
},
{
dataIndex: 'releaseTime',
title: '发布时间',
componentType: 'date',
sorter: true,
align: 'left',
},
{
dataIndex: 'enabledMark',
title: '发布状态',
componentType: 'input',
customRender: ({ record }) => `${record.enabledMark ? t('已发布') : t('未发布')}`,
sorter: true,
align: 'left',
},
];
export const formProps: FormProps = {
labelCol: { span: 3, offset: 0 },
labelAlign: 'right',
layout: 'horizontal',
size: 'default',
schemas: [
{
key: '54d4d5b63e954ad182b377489ce15ae2',
field: 'briefHead',
label: '新闻标题',
type: 'input',
component: 'Input',
colProps: { span: 24 },
defaultValue: '',
componentProps: {
width: '100%',
span: '',
defaultValue: '',
placeholder: '请输入新闻标题',
maxlength: null,
prefix: '',
suffix: '',
addonBefore: '',
addonAfter: '',
disabled: false,
allowClear: false,
showLabel: true,
required: true,
rules: [],
events: {},
isSave: false,
style: { width: '100%' },
},
},
{
key: '7d9fc13bda494590a4642b75931f4211',
field: '',
label: '',
type: 'grid',
colProps: { span: 24 },
component: 'Grid',
children: [
{
span: 12,
list: [
{
key: '83f75ad3b07242f68b87839dd59d87a2',
field: 'category',
label: '新闻栏目',
type: 'select',
component: 'XjrSelect',
colProps: { span: 24 },
componentProps: {
width: '100%',
span: 7,
placeholder: '请选择新闻栏目',
showLabel: true,
showSearch: false,
clearable: false,
disabled: false,
staticOptions: [],
defaultSelect: 'Facts',
datasourceType: 'dic',
params: { itemId: NewsCategoryDic.ID },
labelField: 'name',
valueField: 'value',
apiConfig: {},
dicOptions: [],
required: true,
rules: [],
events: {},
itemId: NewsCategoryDic.ID,
style: { width: '100%' },
},
},
{
key: 'db6247b0c70f4abaa3774aac0cf229a0',
field: 'authorName',
label: '作者',
type: 'input',
component: 'Input',
colProps: { span: 24 },
defaultValue: '',
componentProps: {
width: '100%',
span: 7,
defaultValue: '',
placeholder: '请输入作者',
maxlength: null,
prefix: '',
suffix: '',
addonBefore: '',
addonAfter: '',
disabled: false,
allowClear: false,
showLabel: true,
required: true,
rules: [],
events: {},
isSave: false,
style: { width: '100%' },
},
},
{
key: '7623d9786dee49b881457291425a7750',
field: 'tagWord',
label: 'Tag标签',
type: 'input',
component: 'Input',
colProps: { span: 24 },
defaultValue: '',
componentProps: {
width: '100%',
span: 7,
defaultValue: '',
placeholder: '请输入Tag标签',
maxlength: null,
prefix: '',
suffix: '',
addonBefore: '',
addonAfter: '',
disabled: false,
allowClear: false,
showLabel: true,
required: false,
rules: [],
events: {},
isSave: false,
style: { width: '100%' },
},
},
],
},
{
span: 12,
list: [
{
key: '1cce31f4c5c64e6ea322d3318b9a2fea',
field: 'releaseTime',
label: '发布时间',
type: 'date',
component: 'DatePicker',
colProps: { span: 24 },
defaultValue: '',
componentProps: {
span: 7,
defaultValue: '',
width: '100%',
placeholder: '请选择发布时间',
format: 'YYYY-MM-DD HH:mm:ss',
showLabel: true,
allowClear: true,
disabled: false,
required: true,
rules: [],
events: {},
style: { width: '100%' },
},
},
{
key: 'e17c4980ab7e4a8cbe59b6ca270653ca',
field: 'compileName',
label: '编辑',
type: 'input',
component: 'Input',
colProps: { span: 24 },
defaultValue: '',
componentProps: {
width: '100%',
span: 7,
defaultValue: '',
placeholder: '请输入编辑',
maxlength: null,
prefix: '',
suffix: '',
addonBefore: '',
addonAfter: '',
disabled: false,
allowClear: false,
showLabel: true,
required: true,
rules: [],
events: {},
isSave: false,
style: { width: '100%' },
},
},
{
key: '370d30c4565a4d25a4dd105d8a074b27',
field: 'keyword',
label: '关键字',
type: 'input',
component: 'Input',
colProps: { span: 24 },
defaultValue: '',
componentProps: {
width: '100%',
span: 7,
defaultValue: '',
placeholder: '请输入关键字',
maxlength: null,
prefix: '',
suffix: '',
addonBefore: '',
addonAfter: '',
disabled: false,
allowClear: false,
showLabel: true,
required: false,
rules: [],
events: {},
isSave: false,
style: { width: '100%' },
},
},
],
},
],
componentProps: { gutter: 16, justify: 'start', align: 'top' },
},
{
key: '3ef88a44265b406a8527fb19ba87948f',
field: 'newsContent',
label: '内容',
type: 'richtext-editor',
component: 'RichTextEditor',
colProps: { span: 24 },
defaultValue: '',
componentProps: {
span: '',
defaultValue: '',
width: '100%',
disabled: false,
showLabel: true,
required: false,
rules: [],
events: {},
style: { width: '100%' },
},
},
],
showActionButtonGroup: false,
buttonLocation: 'center',
actionColOptions: { span: 24 },
showResetButton: false,
showSubmitButton: false,
hiddenComponent: [],
};

View File

@ -0,0 +1,237 @@
import { FormProps, FormSchema } from '/@/components/Form';
import { BasicColumn } from '/@/components/Table';
import { NewsCategoryDic } from '/@/enums/oa';
import { useI18n } from '/@/hooks/web/useI18n';
const { t } = useI18n();
export const searchFormSchema: FormSchema[] = [
{
field: 'keyword',
label: '关键字',
component: 'Input',
colProps: { span: 8 },
},
];
export const columns: BasicColumn[] = [
{
dataIndex: 'briefHead',
title: '公告标题',
componentType: 'input',
sorter: true,
align: 'left',
},
{
dataIndex: 'authorName',
title: '作者',
componentType: 'input',
sorter: true,
align: 'left',
},
{
dataIndex: 'compileName',
title: '编辑',
componentType: 'input',
sorter: true,
align: 'left',
},
{
dataIndex: 'categoryName',
title: '公告类型',
componentType: 'input',
sorter: true,
align: 'left',
},
{
dataIndex: 'sourceName',
title: '信息来源',
componentType: 'input',
sorter: true,
align: 'left',
},
{
dataIndex: 'releaseTime',
title: '发布时间',
componentType: 'date',
sorter: true,
align: 'left',
},
{
dataIndex: 'enabledMark',
title: '发布状态',
componentType: 'input',
customRender: ({ record }) => `${record.enabledMark ? t('已发布') : t('未发布')}`,
sorter: true,
align: 'left',
},
];
export const formProps: FormProps = {
labelCol: { span: 4, offset: 0 },
labelAlign: 'right',
layout: 'horizontal',
size: 'default',
schemas: [
{
key: '54d4d5b63e954ad182b377489ce15ae2',
field: 'briefHead',
label: '公告标题',
type: 'input',
component: 'Input',
colProps: { span: 24 },
defaultValue: '',
componentProps: {
width: '100%',
span: '',
defaultValue: '',
placeholder: '请输入公告标题',
maxlength: null,
prefix: '',
suffix: '',
addonBefore: '',
addonAfter: '',
disabled: false,
allowClear: false,
showLabel: true,
required: true,
rules: [],
events: {},
isSave: false,
style: { width: '100%' },
},
},
{
key: '83f75ad3b07242f68b87839dd59d87a2',
field: 'category',
label: '公告类型',
type: 'select',
component: 'XjrSelect',
colProps: { span: 24 },
componentProps: {
width: '100%',
span: '',
placeholder: '请选择公告类型',
showLabel: true,
showSearch: false,
clearable: false,
disabled: false,
staticOptions: [],
defaultSelect: 'Facts',
datasourceType: 'dic',
params: { itemId: NewsCategoryDic.ID },
labelField: 'name',
valueField: 'value',
apiConfig: {},
dicOptions: [],
required: true,
rules: [],
events: {},
itemId: NewsCategoryDic.ID,
style: { width: '100%' },
},
},
{
key: '1cce31f4c5c64e6ea322d3318b9a2fea',
field: 'releaseTime',
label: '发布时间',
type: 'date',
component: 'DatePicker',
colProps: { span: 24 },
defaultValue: '',
componentProps: {
span: '',
defaultValue: '',
width: '100%',
placeholder: '请选择发布时间',
format: 'YYYY-MM-DD HH:mm:ss',
showLabel: true,
allowClear: true,
disabled: false,
required: true,
rules: [],
events: {},
style: { width: '100%' },
},
},
{
key: 'db6247b0c70f4abaa3774aac0cf229a0',
field: 'sourceName',
label: '信息来源',
type: 'input',
component: 'Input',
colProps: { span: 24 },
defaultValue: '',
componentProps: {
width: '100%',
span: '',
defaultValue: '',
placeholder: '请输入信息来源',
maxlength: null,
prefix: '',
suffix: '',
addonBefore: '',
addonAfter: '',
disabled: false,
allowClear: false,
showLabel: true,
required: false,
rules: [],
events: {},
isSave: false,
style: { width: '100%' },
},
},
{
key: '7623d9786dee49b881457291425a7750',
field: 'sourceAddress',
label: '来源地址',
type: 'input',
component: 'Input',
colProps: { span: 24 },
defaultValue: '',
componentProps: {
width: '100%',
span: '',
defaultValue: '',
placeholder: '请输入来源地址',
maxlength: null,
prefix: '',
suffix: '',
addonBefore: '',
addonAfter: '',
disabled: false,
allowClear: false,
showLabel: true,
required: false,
rules: [],
events: {},
isSave: false,
style: { width: '100%' },
},
},
{
key: '3ef88a44265b406a8527fb19ba87948f',
field: 'newsContent',
label: '内容',
type: 'richtext-editor',
component: 'RichTextEditor',
colProps: { span: 24 },
defaultValue: '',
componentProps: {
span: '',
defaultValue: '',
width: '100%',
disabled: false,
showLabel: true,
required: false,
rules: [],
events: {},
style: { width: '100%' },
},
},
],
showActionButtonGroup: false,
buttonLocation: 'center',
actionColOptions: { span: 24 },
showResetButton: false,
showSubmitButton: false,
hiddenComponent: [],
};