增加主机信息功能

This commit is contained in:
2026-04-19 21:44:59 +08:00
parent bc5ab27986
commit f6637a255d
26 changed files with 95 additions and 2308 deletions

View File

@@ -1,55 +0,0 @@
/**
* Copyright (c) 2013-Now https://jeesite.com All rights reserved.
* No deletion without permission, or be held responsible to law.
* @author gaoxq
*/
import { defHttp } from '@jeesite/core/utils/http/axios';
import { useGlobSetting } from '@jeesite/core/hooks/setting';
import { BasicModel, Page } from '@jeesite/core/api/model/baseModel';
import { UploadApiResult } from '@jeesite/core/api/sys/upload';
import { UploadFileParams } from '@jeesite/types/axios';
import { AxiosProgressEvent } from 'axios';
const { ctxPath, adminPath } = useGlobSetting();
export interface MyDataColumn extends BasicModel<MyDataColumn> {
createTime?: string; // 创建时间
columnId?: string; // 字段ID
tableId: string; // 所属表ID
columnName: string; // 字段名
columnComment?: string; // 字段注释
columnType: string; // 字段类型
dataType?: string; // 数据类型
maxLength?: number; // 长度
isNullable?: string; // 0非空 1可为空
isPrimaryKey?: string; // 0否 1是主键
sort?: number; // 排序
updateTime?: string; // update_time
}
export const myDataColumnList = (params?: MyDataColumn | any) =>
defHttp.get<MyDataColumn>({ url: adminPath + '/biz/myDataColumn/list', params });
export const myDataColumnListData = (params?: MyDataColumn | any) =>
defHttp.post<Page<MyDataColumn>>({ url: adminPath + '/biz/myDataColumn/listData', params });
export const myDataColumnForm = (params?: MyDataColumn | any) =>
defHttp.get<MyDataColumn>({ url: adminPath + '/biz/myDataColumn/form', params });
export const myDataColumnSave = (params?: any, data?: MyDataColumn | any) =>
defHttp.postJson<MyDataColumn>({ url: adminPath + '/biz/myDataColumn/save', params, data });
export const myDataColumnImportData = (
params: UploadFileParams,
onUploadProgress: (progressEvent: AxiosProgressEvent) => void,
) =>
defHttp.uploadFile<UploadApiResult>(
{
url: ctxPath + adminPath + '/biz/myDataColumn/importData',
onUploadProgress,
},
params,
);
export const myDataColumnDelete = (params?: MyDataColumn | any) =>
defHttp.get<MyDataColumn>({ url: adminPath + '/biz/myDataColumn/delete', params });

View File

@@ -1,50 +0,0 @@
/**
* Copyright (c) 2013-Now https://jeesite.com All rights reserved.
* No deletion without permission, or be held responsible to law.
* @author gaoxq
*/
import { defHttp } from '@jeesite/core/utils/http/axios';
import { useGlobSetting } from '@jeesite/core/hooks/setting';
import { BasicModel, Page } from '@jeesite/core/api/model/baseModel';
import { UploadApiResult } from '@jeesite/core/api/sys/upload';
import { UploadFileParams } from '@jeesite/types/axios';
import { AxiosProgressEvent } from 'axios';
const { ctxPath, adminPath } = useGlobSetting();
export interface MyDataTable extends BasicModel<MyDataTable> {
createTime?: string; // 创建时间
tableId?: string; // 表ID
sourceId: string; // 数据源ID
tableName: string; // 数据表名
tableComment?: string; // 表注释
tableRows?: number; // 数据行数
updateTime?: string; // update_time
}
export const myDataTableList = (params?: MyDataTable | any) =>
defHttp.get<MyDataTable>({ url: adminPath + '/biz/myDataTable/list', params });
export const myDataTableListData = (params?: MyDataTable | any) =>
defHttp.post<Page<MyDataTable>>({ url: adminPath + '/biz/myDataTable/listData', params });
export const myDataTableForm = (params?: MyDataTable | any) =>
defHttp.get<MyDataTable>({ url: adminPath + '/biz/myDataTable/form', params });
export const myDataTableSave = (params?: any, data?: MyDataTable | any) =>
defHttp.postJson<MyDataTable>({ url: adminPath + '/biz/myDataTable/save', params, data });
export const myDataTableImportData = (
params: UploadFileParams,
onUploadProgress: (progressEvent: AxiosProgressEvent) => void,
) =>
defHttp.uploadFile<UploadApiResult>(
{
url: ctxPath + adminPath + '/biz/myDataTable/importData',
onUploadProgress,
},
params,
);
export const myDataTableDelete = (params?: MyDataTable | any) =>
defHttp.get<MyDataTable>({ url: adminPath + '/biz/myDataTable/delete', params });

View File

@@ -1,175 +0,0 @@
<!--
* Copyright (c) 2013-Now https://jeesite.com All rights reserved.
* No deletion without permission, or be held responsible to law.
* @author gaoxq
-->
<template>
<BasicDrawer
v-bind="$attrs"
:showFooter="true"
:okAuth="'biz:myDataColumn: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" />
</BasicDrawer>
</template>
<script lang="ts" setup name="ViewsBizMyDataColumnForm">
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, FormSchema, useForm } from '@jeesite/core/components/Form';
import { BasicDrawer, useDrawerInner } from '@jeesite/core/components/Drawer';
import { MyDataColumn, myDataColumnSave, myDataColumnForm } from '@jeesite/biz/api/biz/myDataColumn';
const emit = defineEmits(['success', 'register']);
const { t } = useI18n('biz.myDataColumn');
const { showMessage } = useMessage();
const { meta } = unref(router.currentRoute);
const record = ref<MyDataColumn>({} as MyDataColumn);
const getTitle = computed(() => ({
icon: meta.icon || 'i-ant-design:book-outlined',
value: record.value.isNewRecord ? t('新增字段信息表') : t('编辑字段信息表'),
}));
const inputFormSchemas: FormSchema<MyDataColumn>[] = [
{
label: t('基本信息'),
field: 'basicInfo',
component: 'FormGroup',
colProps: { md: 24, lg: 24 },
},
{
label: t('所属表ID'),
field: 'tableId',
component: 'Input',
componentProps: {
maxlength: 52,
},
required: true,
},
{
label: t('字段名'),
field: 'columnName',
component: 'Input',
componentProps: {
maxlength: 200,
},
required: true,
},
{
label: t('字段注释'),
field: 'columnComment',
component: 'Input',
componentProps: {
maxlength: 500,
},
},
{
label: t('字段类型'),
field: 'columnType',
component: 'Input',
componentProps: {
maxlength: 100,
},
required: true,
},
{
label: t('数据类型'),
field: 'dataType',
component: 'Input',
componentProps: {
maxlength: 50,
},
},
{
label: t('长度'),
field: 'maxLength',
component: 'Input',
componentProps: {
maxlength: 9,
},
},
{
label: t('0非空 1可为空'),
field: 'isNullable',
component: 'Input',
componentProps: {
maxlength: 12,
},
},
{
label: t('0否 1是主键'),
field: 'isPrimaryKey',
component: 'Input',
componentProps: {
maxlength: 12,
},
},
{
label: t('排序'),
field: 'sort',
component: 'Input',
componentProps: {
maxlength: 9,
},
},
{
label: t('update_time'),
field: 'updateTime',
component: 'DatePicker',
componentProps: {
format: 'YYYY-MM-DD HH:mm',
showTime: { format: 'HH:mm' },
},
},
];
const [registerForm, { resetFields, setFieldsValue, validate }] = useForm<MyDataColumn>({
labelWidth: 120,
schemas: inputFormSchemas,
baseColProps: { md: 24, lg: 12 },
});
const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async (data) => {
setDrawerProps({ loading: true });
await resetFields();
const res = await myDataColumnForm(data);
record.value = (res.myDataColumn || {}) as MyDataColumn;
record.value.__t = new Date().getTime();
await setFieldsValue(record.value);
setDrawerProps({ loading: false });
});
async function handleSubmit() {
try {
const data = await validate();
setDrawerProps({ confirmLoading: true });
const params: any = {
isNewRecord: record.value.isNewRecord,
columnId: record.value.columnId || data.columnId,
};
// console.log('submit', params, data, record);
const res = await myDataColumnSave(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

@@ -1,103 +0,0 @@
<!--
* Copyright (c) 2013-Now https://jeesite.com All rights reserved.
* No deletion without permission, or be held responsible to law.
* @author gaoxq
-->
<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="ant-design:upload-outlined" /> {{ t('选择文件') }} </a-button>
<span class="ml-4">{{ uploadInfo }}</span>
</Upload>
<div class="ml-4 mt-4">
{{ t('提示仅允许导入“xls”或“xlsx”格式文件') }}
</div>
<div class="mt-4">
<a-button @click="handleDownloadTemplate()" type="text">
<Icon icon="i-fa:file-excel-o" />
{{ t('下载模板') }}
</a-button>
</div>
</BasicModal>
</template>
<script lang="ts" setup>
import { ref } from 'vue';
import { Upload } 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 { myDataColumnImportData } from '@jeesite/biz/api/biz/myDataColumn';
import { FileType } from 'ant-design-vue/es/upload/interface';
import { AxiosProgressEvent } from 'axios';
const emit = defineEmits(['success', 'register']);
const { t } = useI18n('biz.myDataColumn');
const { showMessage, showMessageModal } = useMessage();
const fileList = ref<FileType[]>([]);
const uploadInfo = ref('');
const beforeUpload = (file: FileType) => {
fileList.value = [file];
return false;
};
const handleRemove = () => {
fileList.value = [];
};
const [registerModal, { setModalProps, closeModal }] = useModalInner(() => {
fileList.value = [];
uploadInfo.value = '';
});
async function handleDownloadTemplate() {
const { ctxAdminPath } = useGlobSetting();
downloadByUrl({ url: ctxAdminPath + '/biz/myDataColumn/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],
};
const { data } = await myDataColumnImportData(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

@@ -1,297 +0,0 @@
<!--
* Copyright (c) 2013-Now https://jeesite.com All rights reserved.
* No deletion without permission, or be held responsible to law.
* @author gaoxq
-->
<template>
<div>
<BasicTable @register="registerTable">
<template #tableTitle>
<Icon :icon="getTitle.icon" class="m-1 pr-1" />
<span> {{ getTitle.value }} </span>
</template>
<template #toolbar>
<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="'biz:myDataColumn:edit'">
<Icon icon="i-fluent:add-12-filled" /> {{ t('新增') }}
</a-button>
</template>
<template #firstColumn="{ record, text, value }">
<a @click="handleForm({ columnId: record.columnId })" :title="value">
{{ text }}
</a>
</template>
</BasicTable>
<InputForm @register="registerDrawer" @success="handleSuccess" />
<FormImport @register="registerImportModal" @success="handleSuccess" />
</div>
</template>
<script lang="ts" setup name="ViewsBizMyDataColumnList">
import { onMounted, ref, unref } 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 { MyDataColumn, myDataColumnList } from '@jeesite/biz/api/biz/myDataColumn';
import { myDataColumnDelete, myDataColumnListData } from '@jeesite/biz/api/biz/myDataColumn';
import { useDrawer } from '@jeesite/core/components/Drawer';
import { useModal } from '@jeesite/core/components/Modal';
import { FormProps } from '@jeesite/core/components/Form';
import InputForm from './form.vue';
import FormImport from './formImport.vue';
const { t } = useI18n('biz.myDataColumn');
const { showMessage } = useMessage();
const { meta } = unref(router.currentRoute);
const record = ref<MyDataColumn>({} as MyDataColumn);
const getTitle = {
icon: meta.icon || 'i-ant-design:book-outlined',
value: meta.title || t('字段信息表管理'),
};
const loading = ref(false);
const searchForm: FormProps<MyDataColumn> = {
baseColProps: { md: 8, lg: 6 },
labelWidth: 90,
schemas: [
{
label: t('创建时间'),
field: 'createTime',
component: 'DatePicker',
componentProps: {
format: 'YYYY-MM-DD HH:mm',
showTime: { format: 'HH:mm' },
},
},
{
label: t('所属表ID'),
field: 'tableId',
component: 'Input',
},
{
label: t('字段名'),
field: 'columnName',
component: 'Input',
},
{
label: t('字段注释'),
field: 'columnComment',
component: 'Input',
},
{
label: t('字段类型'),
field: 'columnType',
component: 'Input',
},
{
label: t('数据类型'),
field: 'dataType',
component: 'Input',
},
{
label: t('长度'),
field: 'maxLength',
component: 'Input',
},
{
label: t('0非空 1可为空'),
field: 'isNullable',
component: 'Input',
},
{
label: t('0否 1是主键'),
field: 'isPrimaryKey',
component: 'Input',
},
{
label: t('排序'),
field: 'sort',
component: 'Input',
},
{
label: t('update_time'),
field: 'updateTime',
component: 'DatePicker',
componentProps: {
format: 'YYYY-MM-DD HH:mm',
showTime: { format: 'HH:mm' },
},
},
],
};
const tableColumns: BasicColumn<MyDataColumn>[] = [
{
title: t('创建时间'),
dataIndex: 'createTime',
key: 'a.create_time',
sorter: true,
width: 230,
align: 'left',
slot: 'firstColumn',
},
{
title: t('所属表ID'),
dataIndex: 'tableId',
key: 'a.table_id',
sorter: true,
width: 130,
align: 'left',
},
{
title: t('字段名'),
dataIndex: 'columnName',
key: 'a.column_name',
sorter: true,
width: 130,
align: 'left',
},
{
title: t('字段注释'),
dataIndex: 'columnComment',
key: 'a.column_comment',
sorter: true,
width: 130,
align: 'left',
},
{
title: t('字段类型'),
dataIndex: 'columnType',
key: 'a.column_type',
sorter: true,
width: 130,
align: 'left',
},
{
title: t('数据类型'),
dataIndex: 'dataType',
key: 'a.data_type',
sorter: true,
width: 130,
align: 'left',
},
{
title: t('长度'),
dataIndex: 'maxLength',
key: 'a.max_length',
sorter: true,
width: 130,
align: 'center',
},
{
title: t('0非空 1可为空'),
dataIndex: 'isNullable',
key: 'a.is_nullable',
sorter: true,
width: 130,
align: 'left',
},
{
title: t('0否 1是主键'),
dataIndex: 'isPrimaryKey',
key: 'a.is_primary_key',
sorter: true,
width: 130,
align: 'left',
},
{
title: t('排序'),
dataIndex: 'sort',
key: 'a.sort',
sorter: true,
width: 130,
align: 'center',
},
{
title: t('update_time'),
dataIndex: 'updateTime',
key: 'a.update_time',
sorter: true,
width: 130,
align: 'center',
},
];
const actionColumn: BasicColumn<MyDataColumn> = {
width: 160,
actions: (record: MyDataColumn) => [
{
icon: 'i-clarity:note-edit-line',
title: t('编辑字段信息表'),
onClick: handleForm.bind(this, { columnId: record.columnId }),
auth: 'biz:myDataColumn:edit',
},
{
icon: 'i-ant-design:delete-outlined',
color: 'error',
title: t('删除字段信息表'),
popConfirm: {
title: t('是否确认删除字段信息表'),
confirm: handleDelete.bind(this, record),
},
auth: 'biz:myDataColumn:edit',
},
],
};
const [registerTable, { reload, getForm }] = useTable<MyDataColumn>({
api: myDataColumnListData,
beforeFetch: (params) => {
return params;
},
columns: tableColumns,
actionColumn: actionColumn,
formConfig: searchForm,
showTableSetting: true,
useSearchForm: true,
canResize: true,
});
onMounted(async () => {
const res = await myDataColumnList();
record.value = (res.myDataColumn || {}) as MyDataColumn;
await getForm().setFieldsValue(record.value);
});
const [registerDrawer, { openDrawer }] = useDrawer();
function handleForm(record: Recordable) {
openDrawer(true, record);
}
async function handleExport() {
loading.value = true;
const { ctxAdminPath } = useGlobSetting();
await downloadByUrl({
url: ctxAdminPath + '/biz/myDataColumn/exportData',
params: getForm().getFieldsValue(),
});
loading.value = false;
}
const [registerImportModal, { openModal: importModal }] = useModal();
function handleImport() {
importModal(true, {});
}
async function handleDelete(record: Recordable) {
const params = { columnId: record.columnId };
const res = await myDataColumnDelete(params);
showMessage(res.message);
await handleSuccess(record);
}
async function handleSuccess(record: Recordable) {
await reload({ record });
}
</script>

View File

@@ -1,190 +0,0 @@
import { useI18n } from '@jeesite/core/hooks/web/useI18n';
import { BasicColumn, BasicTableProps, FormProps } from '@jeesite/core/components/Table';
import { myDataColumnListData } from '@jeesite/biz/api/biz/myDataColumn';
const { t } = useI18n('biz.myDataColumn');
const modalProps = {
title: t('字段信息表选择'),
};
const searchForm: FormProps<MyDataColumn> = {
baseColProps: { md: 8, lg: 6 },
labelWidth: 90,
schemas: [
{
label: t('创建时间'),
field: 'createTime',
component: 'DatePicker',
componentProps: {
format: 'YYYY-MM-DD HH:mm',
showTime: { format: 'HH:mm' },
},
},
{
label: t('所属表ID'),
field: 'tableId',
component: 'Input',
},
{
label: t('字段名'),
field: 'columnName',
component: 'Input',
},
{
label: t('字段注释'),
field: 'columnComment',
component: 'Input',
},
{
label: t('字段类型'),
field: 'columnType',
component: 'Input',
},
{
label: t('数据类型'),
field: 'dataType',
component: 'Input',
},
{
label: t('长度'),
field: 'maxLength',
component: 'Input',
},
{
label: t('0非空 1可为空'),
field: 'isNullable',
component: 'Input',
},
{
label: t('0否 1是主键'),
field: 'isPrimaryKey',
component: 'Input',
},
{
label: t('排序'),
field: 'sort',
component: 'Input',
},
{
label: t('update_time'),
field: 'updateTime',
component: 'DatePicker',
componentProps: {
format: 'YYYY-MM-DD HH:mm',
showTime: { format: 'HH:mm' },
},
},
],
};
const tableColumns: BasicColumn<MyDataColumn>[] = [
{
title: t('创建时间'),
dataIndex: 'createTime',
key: 'a.create_time',
sorter: true,
width: 230,
align: 'left',
slot: 'firstColumn',
},
{
title: t('所属表ID'),
dataIndex: 'tableId',
key: 'a.table_id',
sorter: true,
width: 130,
align: 'left',
},
{
title: t('字段名'),
dataIndex: 'columnName',
key: 'a.column_name',
sorter: true,
width: 130,
align: 'left',
},
{
title: t('字段注释'),
dataIndex: 'columnComment',
key: 'a.column_comment',
sorter: true,
width: 130,
align: 'left',
},
{
title: t('字段类型'),
dataIndex: 'columnType',
key: 'a.column_type',
sorter: true,
width: 130,
align: 'left',
},
{
title: t('数据类型'),
dataIndex: 'dataType',
key: 'a.data_type',
sorter: true,
width: 130,
align: 'left',
},
{
title: t('长度'),
dataIndex: 'maxLength',
key: 'a.max_length',
sorter: true,
width: 130,
align: 'center',
},
{
title: t('0非空 1可为空'),
dataIndex: 'isNullable',
key: 'a.is_nullable',
sorter: true,
width: 130,
align: 'left',
},
{
title: t('0否 1是主键'),
dataIndex: 'isPrimaryKey',
key: 'a.is_primary_key',
sorter: true,
width: 130,
align: 'left',
},
{
title: t('排序'),
dataIndex: 'sort',
key: 'a.sort',
sorter: true,
width: 130,
align: 'center',
},
{
title: t('update_time'),
dataIndex: 'updateTime',
key: 'a.update_time',
sorter: true,
width: 130,
align: 'center',
},
];
const tableProps: BasicTableProps = {
api: myDataColumnListData,
beforeFetch: (params) => {
params['isAll'] = true;
return params;
},
columns: tableColumns,
formConfig: searchForm,
rowKey: 'columnId',
};
export default {
modalProps,
tableProps,
itemCode: 'columnId',
itemName: 'columnId',
isShowCode: false,
};

View File

@@ -1,134 +0,0 @@
<!--
* Copyright (c) 2013-Now https://jeesite.com All rights reserved.
* No deletion without permission, or be held responsible to law.
* @author gaoxq
-->
<template>
<BasicDrawer
v-bind="$attrs"
:showFooter="true"
:okAuth="'biz:myDataTable: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" />
</BasicDrawer>
</template>
<script lang="ts" setup name="ViewsBizMyDataTableForm">
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, FormSchema, useForm } from '@jeesite/core/components/Form';
import { BasicDrawer, useDrawerInner } from '@jeesite/core/components/Drawer';
import { MyDataTable, myDataTableSave, myDataTableForm } from '@jeesite/biz/api/biz/myDataTable';
const emit = defineEmits(['success', 'register']);
const { t } = useI18n('biz.myDataTable');
const { showMessage } = useMessage();
const { meta } = unref(router.currentRoute);
const record = ref<MyDataTable>({} as MyDataTable);
const getTitle = computed(() => ({
icon: meta.icon || 'i-ant-design:book-outlined',
value: record.value.isNewRecord ? t('新增数据表信息') : t('编辑数据表信息'),
}));
const inputFormSchemas: FormSchema<MyDataTable>[] = [
{
label: t('基本信息'),
field: 'basicInfo',
component: 'FormGroup',
colProps: { md: 24, lg: 24 },
},
{
label: t('数据源ID'),
field: 'sourceId',
component: 'Input',
componentProps: {
maxlength: 52,
},
required: true,
},
{
label: t('数据表名'),
field: 'tableName',
component: 'Input',
componentProps: {
maxlength: 200,
},
required: true,
},
{
label: t('表注释'),
field: 'tableComment',
component: 'Input',
componentProps: {
maxlength: 500,
},
},
{
label: t('数据行数'),
field: 'tableRows',
component: 'Input',
componentProps: {
maxlength: 18,
},
},
{
label: t('update_time'),
field: 'updateTime',
component: 'DatePicker',
componentProps: {
format: 'YYYY-MM-DD HH:mm',
showTime: { format: 'HH:mm' },
},
},
];
const [registerForm, { resetFields, setFieldsValue, validate }] = useForm<MyDataTable>({
labelWidth: 120,
schemas: inputFormSchemas,
baseColProps: { md: 24, lg: 12 },
});
const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async (data) => {
setDrawerProps({ loading: true });
await resetFields();
const res = await myDataTableForm(data);
record.value = (res.myDataTable || {}) as MyDataTable;
record.value.__t = new Date().getTime();
await setFieldsValue(record.value);
setDrawerProps({ loading: false });
});
async function handleSubmit() {
try {
const data = await validate();
setDrawerProps({ confirmLoading: true });
const params: any = {
isNewRecord: record.value.isNewRecord,
tableId: record.value.tableId || data.tableId,
};
// console.log('submit', params, data, record);
const res = await myDataTableSave(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

@@ -1,103 +0,0 @@
<!--
* Copyright (c) 2013-Now https://jeesite.com All rights reserved.
* No deletion without permission, or be held responsible to law.
* @author gaoxq
-->
<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="ant-design:upload-outlined" /> {{ t('选择文件') }} </a-button>
<span class="ml-4">{{ uploadInfo }}</span>
</Upload>
<div class="ml-4 mt-4">
{{ t('提示仅允许导入“xls”或“xlsx”格式文件') }}
</div>
<div class="mt-4">
<a-button @click="handleDownloadTemplate()" type="text">
<Icon icon="i-fa:file-excel-o" />
{{ t('下载模板') }}
</a-button>
</div>
</BasicModal>
</template>
<script lang="ts" setup>
import { ref } from 'vue';
import { Upload } 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 { myDataTableImportData } from '@jeesite/biz/api/biz/myDataTable';
import { FileType } from 'ant-design-vue/es/upload/interface';
import { AxiosProgressEvent } from 'axios';
const emit = defineEmits(['success', 'register']);
const { t } = useI18n('biz.myDataTable');
const { showMessage, showMessageModal } = useMessage();
const fileList = ref<FileType[]>([]);
const uploadInfo = ref('');
const beforeUpload = (file: FileType) => {
fileList.value = [file];
return false;
};
const handleRemove = () => {
fileList.value = [];
};
const [registerModal, { setModalProps, closeModal }] = useModalInner(() => {
fileList.value = [];
uploadInfo.value = '';
});
async function handleDownloadTemplate() {
const { ctxAdminPath } = useGlobSetting();
downloadByUrl({ url: ctxAdminPath + '/biz/myDataTable/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],
};
const { data } = await myDataTableImportData(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

@@ -1,232 +0,0 @@
<!--
* Copyright (c) 2013-Now https://jeesite.com All rights reserved.
* No deletion without permission, or be held responsible to law.
* @author gaoxq
-->
<template>
<div>
<BasicTable @register="registerTable">
<template #tableTitle>
<Icon :icon="getTitle.icon" class="m-1 pr-1" />
<span> {{ getTitle.value }} </span>
</template>
<template #toolbar>
<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="'biz:myDataTable:edit'">
<Icon icon="i-fluent:add-12-filled" /> {{ t('新增') }}
</a-button>
</template>
<template #firstColumn="{ record, text, value }">
<a @click="handleForm({ tableId: record.tableId })" :title="value">
{{ text }}
</a>
</template>
</BasicTable>
<InputForm @register="registerDrawer" @success="handleSuccess" />
<FormImport @register="registerImportModal" @success="handleSuccess" />
</div>
</template>
<script lang="ts" setup name="ViewsBizMyDataTableList">
import { onMounted, ref, unref } 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 { MyDataTable, myDataTableList } from '@jeesite/biz/api/biz/myDataTable';
import { myDataTableDelete, myDataTableListData } from '@jeesite/biz/api/biz/myDataTable';
import { useDrawer } from '@jeesite/core/components/Drawer';
import { useModal } from '@jeesite/core/components/Modal';
import { FormProps } from '@jeesite/core/components/Form';
import InputForm from './form.vue';
import FormImport from './formImport.vue';
const { t } = useI18n('biz.myDataTable');
const { showMessage } = useMessage();
const { meta } = unref(router.currentRoute);
const record = ref<MyDataTable>({} as MyDataTable);
const getTitle = {
icon: meta.icon || 'i-ant-design:book-outlined',
value: meta.title || t('数据表信息管理'),
};
const loading = ref(false);
const searchForm: FormProps<MyDataTable> = {
baseColProps: { md: 8, lg: 6 },
labelWidth: 90,
schemas: [
{
label: t('创建时间'),
field: 'createTime',
component: 'DatePicker',
componentProps: {
format: 'YYYY-MM-DD HH:mm',
showTime: { format: 'HH:mm' },
},
},
{
label: t('数据源ID'),
field: 'sourceId',
component: 'Input',
},
{
label: t('数据表名'),
field: 'tableName',
component: 'Input',
},
{
label: t('表注释'),
field: 'tableComment',
component: 'Input',
},
{
label: t('数据行数'),
field: 'tableRows',
component: 'Input',
},
{
label: t('update_time'),
field: 'updateTime',
component: 'DatePicker',
componentProps: {
format: 'YYYY-MM-DD HH:mm',
showTime: { format: 'HH:mm' },
},
},
],
};
const tableColumns: BasicColumn<MyDataTable>[] = [
{
title: t('创建时间'),
dataIndex: 'createTime',
key: 'a.create_time',
sorter: true,
width: 230,
align: 'left',
slot: 'firstColumn',
},
{
title: t('数据源ID'),
dataIndex: 'sourceId',
key: 'a.source_id',
sorter: true,
width: 130,
align: 'left',
},
{
title: t('数据表名'),
dataIndex: 'tableName',
key: 'a.table_name',
sorter: true,
width: 130,
align: 'left',
},
{
title: t('表注释'),
dataIndex: 'tableComment',
key: 'a.table_comment',
sorter: true,
width: 130,
align: 'left',
},
{
title: t('数据行数'),
dataIndex: 'tableRows',
key: 'a.table_rows',
sorter: true,
width: 130,
align: 'center',
},
{
title: t('update_time'),
dataIndex: 'updateTime',
key: 'a.update_time',
sorter: true,
width: 130,
align: 'center',
},
];
const actionColumn: BasicColumn<MyDataTable> = {
width: 160,
actions: (record: MyDataTable) => [
{
icon: 'i-clarity:note-edit-line',
title: t('编辑数据表信息'),
onClick: handleForm.bind(this, { tableId: record.tableId }),
auth: 'biz:myDataTable:edit',
},
{
icon: 'i-ant-design:delete-outlined',
color: 'error',
title: t('删除数据表信息'),
popConfirm: {
title: t('是否确认删除数据表信息'),
confirm: handleDelete.bind(this, record),
},
auth: 'biz:myDataTable:edit',
},
],
};
const [registerTable, { reload, getForm }] = useTable<MyDataTable>({
api: myDataTableListData,
beforeFetch: (params) => {
return params;
},
columns: tableColumns,
actionColumn: actionColumn,
formConfig: searchForm,
showTableSetting: true,
useSearchForm: true,
canResize: true,
});
onMounted(async () => {
const res = await myDataTableList();
record.value = (res.myDataTable || {}) as MyDataTable;
await getForm().setFieldsValue(record.value);
});
const [registerDrawer, { openDrawer }] = useDrawer();
function handleForm(record: Recordable) {
openDrawer(true, record);
}
async function handleExport() {
loading.value = true;
const { ctxAdminPath } = useGlobSetting();
await downloadByUrl({
url: ctxAdminPath + '/biz/myDataTable/exportData',
params: getForm().getFieldsValue(),
});
loading.value = false;
}
const [registerImportModal, { openModal: importModal }] = useModal();
function handleImport() {
importModal(true, {});
}
async function handleDelete(record: Recordable) {
const params = { tableId: record.tableId };
const res = await myDataTableDelete(params);
showMessage(res.message);
await handleSuccess(record);
}
async function handleSuccess(record: Recordable) {
await reload({ record });
}
</script>

View File

@@ -1,125 +0,0 @@
import { useI18n } from '@jeesite/core/hooks/web/useI18n';
import { BasicColumn, BasicTableProps, FormProps } from '@jeesite/core/components/Table';
import { myDataTableListData } from '@jeesite/biz/api/biz/myDataTable';
const { t } = useI18n('biz.myDataTable');
const modalProps = {
title: t('数据表信息选择'),
};
const searchForm: FormProps<MyDataTable> = {
baseColProps: { md: 8, lg: 6 },
labelWidth: 90,
schemas: [
{
label: t('创建时间'),
field: 'createTime',
component: 'DatePicker',
componentProps: {
format: 'YYYY-MM-DD HH:mm',
showTime: { format: 'HH:mm' },
},
},
{
label: t('数据源ID'),
field: 'sourceId',
component: 'Input',
},
{
label: t('数据表名'),
field: 'tableName',
component: 'Input',
},
{
label: t('表注释'),
field: 'tableComment',
component: 'Input',
},
{
label: t('数据行数'),
field: 'tableRows',
component: 'Input',
},
{
label: t('update_time'),
field: 'updateTime',
component: 'DatePicker',
componentProps: {
format: 'YYYY-MM-DD HH:mm',
showTime: { format: 'HH:mm' },
},
},
],
};
const tableColumns: BasicColumn<MyDataTable>[] = [
{
title: t('创建时间'),
dataIndex: 'createTime',
key: 'a.create_time',
sorter: true,
width: 230,
align: 'left',
slot: 'firstColumn',
},
{
title: t('数据源ID'),
dataIndex: 'sourceId',
key: 'a.source_id',
sorter: true,
width: 130,
align: 'left',
},
{
title: t('数据表名'),
dataIndex: 'tableName',
key: 'a.table_name',
sorter: true,
width: 130,
align: 'left',
},
{
title: t('表注释'),
dataIndex: 'tableComment',
key: 'a.table_comment',
sorter: true,
width: 130,
align: 'left',
},
{
title: t('数据行数'),
dataIndex: 'tableRows',
key: 'a.table_rows',
sorter: true,
width: 130,
align: 'center',
},
{
title: t('update_time'),
dataIndex: 'updateTime',
key: 'a.update_time',
sorter: true,
width: 130,
align: 'center',
},
];
const tableProps: BasicTableProps = {
api: myDataTableListData,
beforeFetch: (params) => {
params['isAll'] = true;
return params;
},
columns: tableColumns,
formConfig: searchForm,
rowKey: 'tableId',
};
export default {
modalProps,
tableProps,
itemCode: 'tableId',
itemName: 'tableId',
isShowCode: false,
};