项目初始化

This commit is contained in:
2026-03-19 10:57:24 +08:00
commit ee94d420ad
3822 changed files with 582614 additions and 0 deletions

View File

@@ -0,0 +1,236 @@
<!--
* Copyright (c) 2013-Now https://jeesite.com All rights reserved.
* No deletion without permission, or be held responsible to law.
* @author ThinkGem
-->
<template>
<BasicDrawer
v-bind="$attrs"
:showFooter="true"
:okAuth="'sys:office:edit'"
@register="registerDrawer"
@ok="handleSubmit"
width="70%"
>
<template #title>
<Icon :icon="getTitle.icon" class="m-1 pr-1" />
<span> {{ getTitle.value }} </span>
</template>
<BasicForm @register="registerForm" />
<FormExtend ref="formExtendRef" />
</BasicDrawer>
</template>
<script lang="ts" setup name="ViewsSysOfficeForm">
import { ref, unref, computed } from 'vue';
import { useI18n } from '@jeesite/core/hooks/web/useI18n';
import { useMessage } from '@jeesite/core/hooks/web/useMessage';
import { router } from '@jeesite/core/router';
import { Icon } from '@jeesite/core/components/Icon';
import { BasicForm, FormExtend, FormSchema, useForm } from '@jeesite/core/components/Form';
import { BasicDrawer, useDrawerInner } from '@jeesite/core/components/Drawer';
import { Office, officeSave, officeForm, officeTreeData } from '@jeesite/core/api/sys/office';
const emit = defineEmits(['success', 'register']);
const { t } = useI18n('sys.office');
const { showMessage } = useMessage();
const { meta } = unref(router.currentRoute);
const record = ref<Office>({} as Office);
const getTitle = computed(() => ({
icon: meta.icon || 'ant-design:book-outlined',
value: record.value.isNewRecord ? t('新增机构') : t('编辑机构'),
}));
const formExtendRef = ref<InstanceType<typeof FormExtend>>();
const inputFormSchemas: FormSchema<Office>[] = [
{
label: t('基本信息'),
field: 'basicInfo',
component: 'FormGroup',
colProps: { md: 24, lg: 24 },
},
{
label: t('上级机构'),
field: 'parentCode',
fieldLabel: 'parentName',
component: 'TreeSelect',
componentProps: {
allowClear: true,
// style: 'width: calc(50% - 60px)',
},
// colProps: { md: 24, lg: 24 },
},
{
field: 'none',
component: 'None',
},
{
label: t('机构名称'),
field: 'officeName',
component: 'Input',
componentProps: {
maxlength: 100,
},
required: true,
},
{
label: t('机构代码'),
field: 'viewCode',
component: 'Input',
componentProps: {
maxlength: 100,
},
required: true,
},
{
label: t('机构全称'),
field: 'fullName',
component: 'Input',
componentProps: {
maxlength: 200,
},
required: true,
},
{
label: t('排序号'),
field: 'treeSort',
helpMessage: '升序',
component: 'InputNumber',
defaultValue: '30',
componentProps: {
maxlength: 10,
},
required: true,
},
{
label: t('机构类型'),
field: 'officeType',
component: 'Select',
componentProps: {
dictType: 'sys_office_type',
allowClear: true,
},
required: true,
},
{
label: t('详细信息'),
field: 'officeInfo',
component: 'FormGroup',
colProps: { md: 24, lg: 24 },
},
{
label: t('负责人'),
field: 'leader',
component: 'Input',
componentProps: {
maxlength: 100,
},
},
{
label: t('办公电话'),
field: 'phone',
component: 'Input',
componentProps: {
maxlength: 100,
},
},
{
label: t('联系地址'),
field: 'address',
component: 'Input',
componentProps: {
maxlength: 255,
},
},
{
label: t('邮政编码'),
field: 'zipCode',
component: 'Input',
componentProps: {
maxlength: 100,
},
},
{
label: t('电子邮箱'),
field: 'email',
component: 'Input',
componentProps: {
maxlength: 300,
},
},
{
label: t('备注信息'),
field: 'remarks',
component: 'InputTextArea',
componentProps: {
maxlength: 500,
},
colProps: { md: 24, lg: 24 },
},
];
const [registerForm, { resetFields, setFieldsValue, updateSchema, validate }] = useForm<Office>({
labelWidth: 120,
schemas: inputFormSchemas,
baseColProps: { md: 24, lg: 12 },
});
const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async (data) => {
setDrawerProps({ loading: true });
await resetFields();
await formExtendRef.value?.resetFields();
const res = await officeForm(data);
record.value = (res.office || {}) as Office;
if (data.parentCode && data.parentName) {
record.value.parentCode = data.parentCode;
record.value.parentName = data.parentName;
}
await setFieldsValue(record.value);
await updateSchema([
{
field: 'parentCode',
componentProps: {
api: officeTreeData,
params: {
excludeCode: record.value.id,
isShowRawName: true,
},
},
},
{
field: 'viewCode',
componentProps: {
disabled: !record.value.isNewRecord,
},
},
]);
await formExtendRef.value?.setFieldsValue(record.value.extend);
setDrawerProps({ loading: false });
});
async function handleSubmit() {
try {
const data = await validate();
setDrawerProps({ confirmLoading: true });
const params: any = {
isNewRecord: record.value.isNewRecord,
officeCode: record.value.officeCode,
};
data.oldParentCode = record.value.parentCode;
data.extend = await formExtendRef.value?.validate();
// console.log('submit', params, data, record);
const res = await officeSave(params, data);
showMessage(res.message);
setTimeout(closeDrawer);
emit('success', data);
} catch (error: any) {
if (error && error.errorFields) {
showMessage(error.message || t('common.validateError'));
}
console.log('error', error);
} finally {
setDrawerProps({ confirmLoading: false });
}
}
</script>

View File

@@ -0,0 +1,114 @@
<!--
* Copyright (c) 2013-Now https://jeesite.com All rights reserved.
* No deletion without permission, or be held responsible to law.
* @author ThinkGem
-->
<template>
<BasicModal
v-bind="$attrs"
:title="t('导入机构数据')"
:okText="t('导入')"
@register="registerModal"
@ok="handleSubmit"
:minHeight="120"
:width="400"
>
<Upload accept=".xls,.xlsx" :file-list="fileList" :before-upload="beforeUpload" @remove="handleRemove">
<a-button> <Icon icon="i-ant-design:upload-outlined" /> {{ t('选择文件') }} </a-button>
<span class="ml-4">{{ uploadInfo }}</span>
</Upload>
<div class="mt-4">
<Checkbox v-model:checked="updateSupport">
<Tooltip placement="bottom" :mouse-enter-delay="1" :overlay-style="{ width: '100px' }">
<template #title>
{{ t('如果机构编码已经存在,更新这条数据。') }}
</template>
{{ t('是否更新已经存在的机构数据') }}
</Tooltip>
</Checkbox>
<a-button @click="handleDownloadTemplate()" type="text">
<Icon icon="i-fa:file-excel-o" />
{{ t('下载模板') }}
</a-button>
</div>
<div class="mt-4">
{{ t('提示仅允许导入“xls”或“xlsx”格式文件') }}
</div>
</BasicModal>
</template>
<script lang="ts" setup name="ViewsSysOfficeForm">
import { ref } from 'vue';
import { Upload, Checkbox, Tooltip } from 'ant-design-vue';
import { useI18n } from '@jeesite/core/hooks/web/useI18n';
import { useMessage } from '@jeesite/core/hooks/web/useMessage';
import { useGlobSetting } from '@jeesite/core/hooks/setting';
import { downloadByUrl } from '@jeesite/core/utils/file/download';
import { Icon } from '@jeesite/core/components/Icon';
import { BasicModal, useModalInner } from '@jeesite/core/components/Modal';
import { officeImportData } from '@jeesite/core/api/sys/office';
import { FileType } from 'ant-design-vue/es/upload/interface';
import { AxiosProgressEvent } from 'axios';
const emit = defineEmits(['success', 'register']);
const { t } = useI18n('sys.office');
const { showMessage, showMessageModal } = useMessage();
const fileList = ref<FileType[]>([]);
const updateSupport = ref(false);
const uploadInfo = ref('');
const beforeUpload = (file: FileType) => {
fileList.value = [file];
return false;
};
const handleRemove = () => {
fileList.value = [];
};
const [registerModal, { setModalProps, closeModal }] = useModalInner(() => {
fileList.value = [];
updateSupport.value = false;
uploadInfo.value = '';
});
async function handleDownloadTemplate() {
const { ctxAdminPath } = useGlobSetting();
downloadByUrl({ url: ctxAdminPath + '/sys/office/importTemplate' });
}
function onUploadProgress(progressEvent: AxiosProgressEvent) {
const complete = ((progressEvent.loaded / (progressEvent.total || 1)) * 100) | 0;
if (complete != 100) {
uploadInfo.value = t('正在导入,请稍候') + ' ' + complete + '%...';
} else {
uploadInfo.value = '';
}
}
async function handleSubmit() {
try {
if (fileList.value.length == 0) {
showMessage(t('请选择要导入的数据文件'));
return;
}
setModalProps({ confirmLoading: true });
const params = {
file: fileList.value[0],
updateSupport: updateSupport.value ? '1' : '0',
};
const { data } = await officeImportData(params, onUploadProgress);
showMessageModal({ content: data.message });
setTimeout(closeModal);
emit('success');
} catch (error: any) {
if (error && error.errorFields) {
showMessage(error.message || t('common.validateError'));
}
console.log('error', error);
} finally {
setModalProps({ confirmLoading: false });
}
}
</script>

View File

@@ -0,0 +1,32 @@
<!--
* Copyright (c) 2013-Now https://jeesite.com All rights reserved.
* No deletion without permission, or be held responsible to law.
* @author ThinkGem
-->
<template>
<PageWrapper :sidebarWidth="200">
<template #sidebar>
<BasicTree
:title="t('机构')"
:search="true"
:toolbar="true"
:showIcon="true"
:api="officeTreeData"
:defaultExpandLevel="2"
v-model:selectedKeys="treeCodes"
/>
</template>
<ListView v-model:treeCodes="treeCodes" />
</PageWrapper>
</template>
<script lang="ts" setup name="ViewsSysOfficeIndex">
import { ref } from 'vue';
import { useI18n } from '@jeesite/core/hooks/web/useI18n';
import { PageWrapper } from '@jeesite/core/components/Page';
import { BasicTree } from '@jeesite/core/components/Tree';
import { officeTreeData } from '@jeesite/core/api/sys/office';
import ListView from './list.vue';
const { t } = useI18n('sys.office');
const treeCodes = ref<string[]>([]);
</script>

View File

@@ -0,0 +1,335 @@
<!--
* Copyright (c) 2013-Now https://jeesite.com All rights reserved.
* No deletion without permission, or be held responsible to law.
* @author ThinkGem
-->
<template>
<div>
<BasicTable @register="registerTable" @fetch-success="fetchSuccess">
<template #tableTitle>
<Icon :icon="getTitle.icon" class="m-1 pr-1" />
<span> {{ getTitle.value }} </span>
</template>
<template #toolbar>
<a-button @click="expandAll" :title="t('展开一级')">
<Icon icon="i-bi:chevron-double-down" /> {{ t('展开') }}
</a-button>
<a-button @click="collapseAll" :title="t('折叠全部')">
<Icon icon="i-bi:chevron-double-up" /> {{ t('折叠') }}
</a-button>
<a-button type="default" :loading="loading" @click="handleExport()">
<Icon icon="i-ant-design:download-outlined" /> {{ t('导出') }}
</a-button>
<a-button type="default" @click="handleImport()">
<Icon icon="i-ant-design:import-outlined" /> {{ t('导入') }}
</a-button>
<a-button type="primary" @click="handleForm({})" v-auth="'sys:office:edit'">
<Icon icon="i-fluent:add-12-filled" /> {{ t('新增') }}
</a-button>
</template>
<template #firstColumn="{ record }">
<span class="cursor-pointer" @click="expandCollapse(record)"> ( {{ record.viewCode }} ) </span>
<a @click="handleForm({ officeCode: record.officeCode })">
{{ record.officeName }}
</a>
</template>
</BasicTable>
<InputForm @register="registerDrawer" @success="handleSuccess" />
<FormImport @register="registerImportModal" @success="handleSuccess" />
</div>
</template>
<script lang="ts" setup name="ViewsSysOfficeList">
import { watch, nextTick, unref, ref } from 'vue';
import { useI18n } from '@jeesite/core/hooks/web/useI18n';
import { useMessage } from '@jeesite/core/hooks/web/useMessage';
import { useGlobSetting } from '@jeesite/core/hooks/setting';
import { downloadByUrl } from '@jeesite/core/utils/file/download';
import { router } from '@jeesite/core/router';
import { Icon } from '@jeesite/core/components/Icon';
import { BasicTable, BasicColumn, useTable } from '@jeesite/core/components/Table';
import { Office, officeDelete, officeListData } from '@jeesite/core/api/sys/office';
import { officeDisable, officeEnable } from '@jeesite/core/api/sys/office';
import { useDrawer } from '@jeesite/core/components/Drawer';
import { useModal } from '@jeesite/core/components/Modal';
import { FormProps } from '@jeesite/core/components/Form';
import { isEmpty } from '@jeesite/core/utils/is';
import InputForm from './form.vue';
import FormImport from './formImport.vue';
const props = defineProps({
treeCodes: Array as PropType<String[]>,
});
const emit = defineEmits(['update:treeCodes']);
const { t } = useI18n('sys.office');
const { showMessage } = useMessage();
const { meta } = unref(router.currentRoute);
const getTitle = {
icon: meta.icon || 'ant-design:book-outlined',
value: meta.title || t('机构管理'),
};
const loading = ref(false);
const searchForm: FormProps<Office> = {
baseColProps: { md: 8, lg: 6 },
labelWidth: 90,
schemas: [
{
label: t('机构代码'),
field: 'viewCode_like',
component: 'Input',
},
{
label: t('机构名称'),
field: 'officeName',
component: 'Input',
},
{
label: t('状态'),
field: 'status',
component: 'Select',
componentProps: {
dictType: 'sys_search_status',
allowClear: true,
onChange: handleSuccess,
},
},
{
label: t('负责人'),
field: 'leader',
component: 'Input',
},
{
label: t('机构类型'),
field: 'officeType',
component: 'Select',
componentProps: {
dictType: 'sys_office_type',
allowClear: true,
},
},
{
label: t('机构全称'),
field: 'fullName',
component: 'Input',
},
{
label: t('办公电话'),
field: 'phone',
component: 'Input',
},
],
resetFunc: async () => {
emit('update:treeCodes', []);
},
};
const tableColumns: BasicColumn<Office>[] = [
{
title: t('机构名称'),
dataIndex: 'officeName',
width: 230,
align: 'left',
slot: 'firstColumn',
},
{
title: t('机构全称'),
dataIndex: 'fullName',
width: 130,
align: 'left',
},
{
title: t('排序号'),
dataIndex: 'treeSort',
width: 90,
align: 'center',
},
{
title: t('机构类型'),
dataIndex: 'officeType',
width: 100,
align: 'center',
dictType: 'sys_office_type',
},
{
title: t('状态'),
dataIndex: 'status',
width: 80,
align: 'center',
dictType: 'sys_status',
},
{
title: t('更新时间'),
dataIndex: 'updateDate',
width: 130,
align: 'center',
},
{
title: t('负责人'),
dataIndex: 'leader',
width: 130,
align: 'center',
},
{
title: t('办公电话'),
dataIndex: 'phone',
width: 130,
align: 'center',
},
{
title: t('联系地址'),
dataIndex: 'address',
width: 130,
align: 'center',
},
{
title: t('邮政编码'),
dataIndex: 'zipCode',
width: 130,
align: 'center',
},
{
title: t('电子邮箱'),
dataIndex: 'email',
width: 130,
align: 'center',
},
{
title: t('备注信息'),
dataIndex: 'remarks',
width: 130,
align: 'left',
},
];
const actionColumn: BasicColumn<Office> = {
width: 160,
actions: (record: Office) => [
{
icon: 'i-clarity:note-edit-line',
title: t('编辑机构'),
onClick: handleForm.bind(this, { officeCode: record.officeCode }),
auth: 'sys:office:edit',
},
{
icon: 'i-ant-design:stop-outlined',
color: 'error',
title: t('停用机构'),
popConfirm: {
title: t('是否确认停用机构'),
confirm: handleDisable.bind(this, record),
},
auth: 'sys:office:edit',
ifShow: () => record.status === '0',
},
{
icon: 'i-ant-design:check-circle-outlined',
color: 'success',
title: t('启用机构'),
popConfirm: {
title: t('是否确认启用机构'),
confirm: handleEnable.bind(this, record),
},
auth: 'sys:office:edit',
ifShow: () => record.status === '2',
},
{
icon: 'i-ant-design:delete-outlined',
color: 'error',
title: t('删除机构'),
popConfirm: {
title: t('是否确认删除机构'),
confirm: handleDelete.bind(this, record),
},
auth: 'sys:office:edit',
},
{
icon: 'i-fluent:add-circle-24-regular',
title: t('新增下级机构'),
onClick: handleForm.bind(this, {
parentCode: record.id,
parentName: record.officeName,
}),
auth: 'sys:office:edit',
},
],
};
const [registerDrawer, { openDrawer }] = useDrawer();
const [registerTable, { reload, expandAll, collapseAll, expandCollapse, getForm }] = useTable<Office>({
api: officeListData,
beforeFetch: (params) => {
params.officeCode = !isEmpty(props.treeCodes) ? props.treeCodes[0] : '';
return params;
},
columns: tableColumns,
actionColumn: actionColumn,
formConfig: searchForm,
showTableSetting: true,
useSearchForm: true,
isTreeTable: true,
pagination: false,
canResize: true,
});
watch(
() => props.treeCodes,
() => {
if (!isEmpty(props.treeCodes)) {
reload();
}
},
);
function fetchSuccess() {
if (!isEmpty(props.treeCodes)) {
nextTick(expandAll);
}
}
function handleForm(record: Recordable) {
openDrawer(true, record);
}
async function handleExport() {
loading.value = true;
const { ctxAdminPath } = useGlobSetting();
await downloadByUrl({
url: ctxAdminPath + '/sys/office/exportData',
params: getForm().getFieldsValue(),
});
loading.value = false;
}
const [registerImportModal, { openModal: importModal }] = useModal();
function handleImport() {
importModal(true, {});
}
async function handleDisable(record: Recordable) {
const params = { officeCode: record.officeCode };
const res = await officeDisable(params);
showMessage(res.message);
handleSuccess(record);
}
async function handleEnable(record: Recordable) {
const params = { officeCode: record.officeCode };
const res = await officeEnable(params);
showMessage(res.message);
handleSuccess(record);
}
async function handleDelete(record: Recordable) {
const params = { officeCode: record.officeCode };
const res = await officeDelete(params);
showMessage(res.message);
handleSuccess(record);
}
function handleSuccess(record: Recordable) {
reload({ record });
}
</script>