增加主机信息功能

This commit is contained in:
2026-04-19 21:21:17 +08:00
parent 880bec1745
commit bc5ab27986
53 changed files with 4760 additions and 89 deletions

View File

@@ -0,0 +1,55 @@
/**
* 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

@@ -0,0 +1,56 @@
/**
* 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 MyDataSource extends BasicModel<MyDataSource> {
createTime?: string; // 创建时间
sourceId?: string; // 主键ID
sourceName: string; // 连接名称
dbType: string; // 数据库类型
dbHost: string; // 数据库IP
dbPort: number; // 数据库端口
dbName: string; // 数据库名称
username: string; // 账号
password?: string; // 密码
params?: string; // 连接参数
remark?: string; // 备注说明
ustatus: string; // 状态
updateTime?: string; // 更新时间
}
export const myDataSourceList = (params?: MyDataSource | any) =>
defHttp.get<MyDataSource>({ url: adminPath + '/biz/myDataSource/list', params });
export const myDataSourceListData = (params?: MyDataSource | any) =>
defHttp.post<Page<MyDataSource>>({ url: adminPath + '/biz/myDataSource/listData', params });
export const myDataSourceForm = (params?: MyDataSource | any) =>
defHttp.get<MyDataSource>({ url: adminPath + '/biz/myDataSource/form', params });
export const myDataSourceSave = (params?: any, data?: MyDataSource | any) =>
defHttp.postJson<MyDataSource>({ url: adminPath + '/biz/myDataSource/save', params, data });
export const myDataSourceImportData = (
params: UploadFileParams,
onUploadProgress: (progressEvent: AxiosProgressEvent) => void,
) =>
defHttp.uploadFile<UploadApiResult>(
{
url: ctxPath + adminPath + '/biz/myDataSource/importData',
onUploadProgress,
},
params,
);
export const myDataSourceDelete = (params?: MyDataSource | any) =>
defHttp.get<MyDataSource>({ url: adminPath + '/biz/myDataSource/delete', params });

View File

@@ -0,0 +1,50 @@
/**
* 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

@@ -3,27 +3,26 @@
<div class="analysis-page">
<div class="mySpring-analysis">
<div class="analysis-layout workbench-layout">
<header class="analysis-panel my-screen-panel my-screen-panel--header">
<ChartTop />
</header>
<header class="analysis-panel biz-screen-panel biz-screen-panel--header">
<ChartTop />
</header>
<section class="my-screen-bottom">
<div class="analysis-left my-screen-left">
<section class="my-screen-left-top">
<div class="analysis-panel my-screen-panel">左上左区域</div>
<div class="analysis-panel my-screen-panel">左上右区域</div>
<section class="biz-screen-bottom">
<div class="analysis-left biz-screen-left">
<section class="biz-screen-left-top">
<div class="analysis-panel biz-screen-panel">左上左区域</div>
<div class="analysis-panel biz-screen-panel">左上右区域</div>
</section>
<section class="my-screen-left-middle">
<div class="analysis-panel my-screen-panel">左下区域</div>
<div class="analysis-panel my-screen-panel">左下右区域</div>
<section class="biz-screen-left-middle">
<div class="analysis-panel biz-screen-panel">左下左区域</div>
<div class="analysis-panel biz-screen-panel">左下区域</div>
</section>
</div>
<aside class="analysis-right my-screen-right">
<section class="analysis-panel my-screen-panel my-screen-right-top">右上区域</section>
<section class="analysis-panel my-screen-panel my-screen-right-middle">右中区域</section>
<section class="analysis-panel my-screen-panel my-screen-right-bottom">右下区域</section>
<aside class="analysis-right biz-screen-right">
<section class="analysis-panel biz-screen-panel">右上区域</section>
<section class="analysis-panel biz-screen-panel">右中区域</section>
<section class="analysis-panel biz-screen-panel">右下区域</section>
</aside>
</section>
</div>
@@ -32,9 +31,9 @@
</PageWrapper>
</template>
<script lang="ts" setup name="BizMyScreen">
<script lang="ts" setup name="BizMyBizScreen">
import { PageWrapper } from '@jeesite/core/components/Page';
import ChartTop from './components/ChartTop.vue';
import ChartTop from './components/ChartTop.vue'
</script>
<style lang="less" scoped>
@@ -97,9 +96,6 @@
overflow: hidden;
background: rgb(240, 242, 245);
border-radius: @desktop-card-radius;
}
.mySpring-analysis .workbench-layout {
flex-direction: column;
}
@@ -122,14 +118,12 @@
justify-content: center;
}
.my-screen-panel--header {
.biz-screen-panel--header {
flex: 0 0 10%;
padding: 8px 16px;
font-weight: 500;
color: rgb(51 65 85);
}
.my-screen-bottom {
.biz-screen-bottom {
flex: 1 1 90%;
min-height: 0;
display: grid;
@@ -139,37 +133,29 @@
border-radius: var(--analysis-card-radius);
}
.mySpring-analysis .analysis-left,
.mySpring-analysis .analysis-right {
.biz-screen-left,
.biz-screen-right {
min-width: 0;
min-height: 0;
display: grid;
gap: var(--analysis-gap);
box-sizing: border-box;
}
.my-screen-left {
display: grid;
min-width: 0;
min-height: 0;
.biz-screen-left {
grid-template-rows: repeat(2, minmax(0, 1fr));
gap: var(--analysis-gap);
}
.my-screen-right {
display: grid;
min-width: 0;
min-height: 0;
.biz-screen-right {
grid-template-rows: repeat(3, minmax(0, 1fr));
gap: var(--analysis-gap);
}
.my-screen-left-top,
.my-screen-left-middle {
.biz-screen-left-top,
.biz-screen-left-middle {
display: grid;
min-width: 0;
min-height: 0;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: var(--analysis-gap);
min-width: 0;
min-height: 0;
}
html[data-theme='dark'] .mySpring-analysis .analysis-panel {
@@ -183,41 +169,28 @@
html[data-theme='dark'] .analysis-page,
html[data-theme='dark'] .analysis-page-wrapper,
html[data-theme='dark'] .mySpring-analysis .analysis-layout,
html[data-theme='dark'] .mySpring-analysis .analysis-left,
html[data-theme='dark'] .mySpring-analysis .analysis-right,
html[data-theme='dark'] .my-screen-bottom,
html[data-theme='dark'] .my-screen-left,
html[data-theme='dark'] .my-screen-right,
html[data-theme='dark'] .my-screen-left-top,
html[data-theme='dark'] .my-screen-left-middle {
html[data-theme='dark'] .biz-screen-bottom,
html[data-theme='dark'] .biz-screen-left,
html[data-theme='dark'] .biz-screen-right,
html[data-theme='dark'] .biz-screen-left-top,
html[data-theme='dark'] .biz-screen-left-middle {
background: @dark-bg !important;
}
html[data-theme='dark'] .mySpring-analysis {
border-radius: @desktop-card-radius;
}
html[data-theme='dark'] .my-screen-panel--header {
color: rgb(203 213 225);
}
@media (max-width: 768px) {
.my-screen-panel--header {
flex-basis: 72px;
}
.my-screen-bottom {
@media (max-width: 1280px) {
.biz-screen-bottom {
grid-template-columns: 1fr;
}
.my-screen-left,
.my-screen-right {
.biz-screen-left,
.biz-screen-right {
grid-template-rows: auto;
min-height: 360px;
}
}
.my-screen-left-top,
.my-screen-left-middle {
@media (max-width: 768px) {
.biz-screen-left-top,
.biz-screen-left-middle {
grid-template-columns: 1fr;
}
}

View File

@@ -0,0 +1,194 @@
<template>
<PageWrapper :contentFullHeight="true" :dense="true" title="false" contentClass="analysis-page-wrapper">
<div class="analysis-page">
<div class="mySpring-analysis">
<div class="analysis-layout workbench-layout">
<header class="analysis-panel database-panel database-panel--header"> </header>
<section class="database-bottom">
<div class="analysis-left database-left">
<section class="database-left-top">
<div class="analysis-panel database-panel">左上左区域</div>
<div class="analysis-panel database-panel">左上右区域</div>
</section>
<section class="database-left-middle">
<div class="analysis-panel database-panel">左下左区域</div>
<div class="analysis-panel database-panel">左下右区域</div>
</section>
</div>
<aside class="analysis-right database-right">
<section class="analysis-panel database-panel">右上区域</section>
<section class="analysis-panel database-panel">右中区域</section>
<section class="analysis-panel database-panel">右下区域</section>
</aside>
</section>
</div>
</div>
</div>
</PageWrapper>
</template>
<script lang="ts" setup name="BizMyDataBase">
import { PageWrapper } from '@jeesite/core/components/Page';
</script>
<style lang="less" scoped>
@dark-bg: rgb(0, 0, 0);
@desktop-page-gap: 12px;
@desktop-page-padding: 0;
@desktop-card-radius: 10px;
@desktop-card-border: 1px solid rgb(226 232 240);
@desktop-card-shadow: 0 1px 3px rgb(15 23 42 / 0.06);
@desktop-dark-border: rgb(51 65 85);
.analysis-page-wrapper {
display: flex;
flex-direction: column;
height: 100%;
min-height: 0;
padding: 0 !important;
width: calc(100% + 10px);
margin-left: -5px !important;
margin-right: -5px !important;
margin-bottom: 0 !important;
overflow: hidden !important;
background: transparent !important;
}
.analysis-page {
display: flex;
flex-direction: column;
width: 100%;
height: 100%;
min-height: 0;
padding: 0 !important;
padding-bottom: 2px !important;
overflow: hidden;
background: rgb(240, 242, 245);
}
.mySpring-analysis {
flex: 1;
min-height: 0;
padding: 0 !important;
overflow: hidden;
width: 100%;
height: 100%;
margin: 0;
border-radius: 12px;
}
.mySpring-analysis .analysis-layout {
--analysis-gap: @desktop-page-gap;
--analysis-card-radius: @desktop-card-radius;
display: flex;
width: 100%;
height: 100%;
max-height: 100%;
min-height: 0;
gap: var(--analysis-gap);
padding: @desktop-page-padding;
box-sizing: border-box;
overflow: hidden;
background: rgb(240, 242, 245);
border-radius: @desktop-card-radius;
flex-direction: column;
}
.mySpring-analysis .analysis-panel {
display: flex;
flex-direction: column;
min-height: 0;
height: 100%;
min-width: 0;
padding: 8px 12px 12px;
border-radius: var(--analysis-card-radius);
border: @desktop-card-border;
background: rgb(255, 255, 255);
box-shadow: @desktop-card-shadow;
overflow: hidden;
color: rgb(71 85 105);
font-size: 14px;
line-height: 20px;
align-items: center;
justify-content: center;
}
.database-panel--header {
flex: 0 0 10%;
padding: 8px 16px;
}
.database-bottom {
flex: 1 1 90%;
min-height: 0;
display: grid;
grid-template-columns: 60% calc(40% - 12px);
gap: var(--analysis-gap);
background: rgb(240, 242, 245);
border-radius: var(--analysis-card-radius);
}
.database-left,
.database-right {
min-width: 0;
min-height: 0;
display: grid;
gap: var(--analysis-gap);
}
.database-left {
grid-template-rows: repeat(2, minmax(0, 1fr));
}
.database-right {
grid-template-rows: repeat(3, minmax(0, 1fr));
}
.database-left-top,
.database-left-middle {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: var(--analysis-gap);
min-width: 0;
min-height: 0;
}
html[data-theme='dark'] .mySpring-analysis .analysis-panel {
border-color: @desktop-dark-border;
background: @dark-bg !important;
color: rgb(203 213 225);
box-shadow: none;
}
html[data-theme='dark'] .mySpring-analysis,
html[data-theme='dark'] .analysis-page,
html[data-theme='dark'] .analysis-page-wrapper,
html[data-theme='dark'] .mySpring-analysis .analysis-layout,
html[data-theme='dark'] .database-bottom,
html[data-theme='dark'] .database-left,
html[data-theme='dark'] .database-right,
html[data-theme='dark'] .database-left-top,
html[data-theme='dark'] .database-left-middle {
background: @dark-bg !important;
}
@media (max-width: 1280px) {
.database-bottom {
grid-template-columns: 1fr;
}
.database-left,
.database-right {
grid-template-rows: auto;
}
}
@media (max-width: 768px) {
.database-left-top,
.database-left-middle {
grid-template-columns: 1fr;
}
}
</style>

View File

@@ -0,0 +1,175 @@
<!--
* 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

@@ -0,0 +1,103 @@
<!--
* 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

@@ -0,0 +1,297 @@
<!--
* 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

@@ -0,0 +1,190 @@
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

@@ -0,0 +1,187 @@
<!--
* 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:myDataSource: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="ViewsBizMyDataSourceForm">
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 { MyDataSource, myDataSourceSave, myDataSourceForm } from '@jeesite/biz/api/biz/myDataSource';
const emit = defineEmits(['success', 'register']);
const { t } = useI18n('biz.myDataSource');
const { showMessage } = useMessage();
const { meta } = unref(router.currentRoute);
const record = ref<MyDataSource>({} as MyDataSource);
const getTitle = computed(() => ({
icon: meta.icon || 'i-ant-design:book-outlined',
value: record.value.isNewRecord ? t('新增数据库连接') : t('编辑数据库连接'),
}));
const inputFormSchemas: FormSchema<MyDataSource>[] = [
{
label: t('基本信息'),
field: 'basicInfo',
component: 'FormGroup',
colProps: { md: 24, lg: 24 },
},
{
label: t('连接名称'),
field: 'sourceName',
component: 'Input',
componentProps: {
maxlength: 100,
},
required: true,
},
{
label: t('数据库类型'),
field: 'dbType',
component: 'Input',
componentProps: {
maxlength: 20,
},
required: true,
},
{
label: t('数据库IP'),
field: 'dbHost',
component: 'Input',
componentProps: {
maxlength: 100,
},
required: true,
},
{
label: t('数据库端口'),
field: 'dbPort',
component: 'Input',
componentProps: {
maxlength: 9,
},
required: true,
},
{
label: t('数据库名称'),
field: 'dbName',
component: 'Input',
componentProps: {
maxlength: 100,
},
required: true,
},
{
label: t('账号'),
field: 'username',
component: 'Input',
componentProps: {
maxlength: 100,
},
required: true,
},
{
label: t('密码'),
field: 'password',
component: 'Input',
componentProps: {
maxlength: 500,
},
},
{
label: t('连接参数'),
field: 'params',
component: 'Input',
componentProps: {
maxlength: 500,
},
},
{
label: t('备注说明'),
field: 'remark',
component: 'Input',
componentProps: {
maxlength: 255,
},
},
{
label: t('状态'),
field: 'ustatus',
component: 'Input',
componentProps: {
maxlength: 12,
},
required: true,
},
{
label: t('更新时间'),
field: 'updateTime',
component: 'DatePicker',
componentProps: {
format: 'YYYY-MM-DD HH:mm',
showTime: { format: 'HH:mm' },
},
},
];
const [registerForm, { resetFields, setFieldsValue, validate }] = useForm<MyDataSource>({
labelWidth: 120,
schemas: inputFormSchemas,
baseColProps: { md: 24, lg: 12 },
});
const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async (data) => {
setDrawerProps({ loading: true });
await resetFields();
const res = await myDataSourceForm(data);
record.value = (res.myDataSource || {}) as MyDataSource;
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,
sourceId: record.value.sourceId || data.sourceId,
};
// console.log('submit', params, data, record);
const res = await myDataSourceSave(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,275 @@
<!--
* 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="primary" @click="handleForm({})" v-auth="'biz:myDataSource:edit'">
<Icon icon="i-fluent:add-12-filled" /> {{ t('新增') }}
</a-button>
</template>
<template #firstColumn="{ record, text, value }">
<a @click="handleForm({ sourceId: record.sourceId })" :title="value">
{{ text }}
</a>
</template>
</BasicTable>
<InputForm @register="registerDrawer" @success="handleSuccess" />
</div>
</template>
<script lang="ts" setup name="ViewsBizMyDataSourceList">
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 { MyDataSource, myDataSourceList } from '@jeesite/biz/api/biz/myDataSource';
import { myDataSourceDelete, myDataSourceListData } from '@jeesite/biz/api/biz/myDataSource';
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';
const { t } = useI18n('biz.myDataSource');
const { showMessage } = useMessage();
const { meta } = unref(router.currentRoute);
const record = ref<MyDataSource>({} as MyDataSource);
const getTitle = {
icon: meta.icon || 'i-ant-design:book-outlined',
value: meta.title || t('数据库连接管理'),
};
const loading = ref(false);
const searchForm: FormProps<MyDataSource> = {
baseColProps: { md: 8, lg: 6 },
labelWidth: 90,
schemas: [
{
label: t('记录时间起'),
field: 'createTime_gte',
component: 'DatePicker',
componentProps: {
format: 'YYYY-MM-DD HH:mm',
showTime: { format: 'HH:mm' },
},
},
{
label: t('记录时间止'),
field: 'createTime_lte',
component: 'DatePicker',
componentProps: {
format: 'YYYY-MM-DD HH:mm',
showTime: { format: 'HH:mm' },
},
},
{
label: t('连接名称'),
field: 'sourceName',
component: 'Input',
},
{
label: t('数据库类型'),
field: 'dbType',
component: 'Input',
},
{
label: t('数据库IP'),
field: 'dbHost',
component: 'Input',
},
{
label: t('数据库名称'),
field: 'dbName',
component: 'Input',
},
{
label: t('状态'),
field: 'ustatus',
component: 'Input',
},
],
};
const tableColumns: BasicColumn<MyDataSource>[] = [
{
title: t('记录时间'),
dataIndex: 'createTime',
key: 'a.create_time',
sorter: true,
width: 150,
align: 'center',
fixed: 'left',
},
{
title: t('连接名称'),
dataIndex: 'sourceName',
key: 'a.source_name',
sorter: true,
width: 130,
align: 'left',
},
{
title: t('数据库类型'),
dataIndex: 'dbType',
key: 'a.db_type',
sorter: true,
width: 130,
align: 'left',
},
{
title: t('数据库IP'),
dataIndex: 'dbHost',
key: 'a.db_host',
sorter: true,
width: 130,
align: 'left',
},
{
title: t('数据库端口'),
dataIndex: 'dbPort',
key: 'a.db_port',
sorter: true,
width: 130,
align: 'center',
},
{
title: t('数据库名称'),
dataIndex: 'dbName',
key: 'a.db_name',
sorter: true,
width: 130,
align: 'left',
},
{
title: t('账号'),
dataIndex: 'username',
key: 'a.username',
sorter: true,
width: 130,
align: 'left',
},
{
title: t('密码'),
dataIndex: 'password',
key: 'a.password',
sorter: true,
width: 130,
align: 'left',
},
{
title: t('连接参数'),
dataIndex: 'params',
key: 'a.params',
sorter: true,
width: 130,
align: 'left',
},
{
title: t('备注说明'),
dataIndex: 'remark',
key: 'a.remark',
sorter: true,
width: 130,
align: 'left',
},
{
title: t('状态'),
dataIndex: 'ustatus',
key: 'a.ustatus',
sorter: true,
width: 130,
align: 'left',
},
{
title: t('更新时间'),
dataIndex: 'updateTime',
key: 'a.update_time',
sorter: true,
width: 180,
align: 'center',
},
];
const actionColumn: BasicColumn<MyDataSource> = {
width: 160,
align: 'center',
actions: (record: MyDataSource) => [
{
icon: 'i-clarity:note-edit-line',
title: t('编辑'),
onClick: handleForm.bind(this, { sourceId: record.sourceId }),
auth: 'biz:myDataSource:edit',
},
{
icon: 'i-ant-design:delete-outlined',
color: 'error',
title: t('删除'),
popConfirm: {
title: t('是否确认删除数据库连接?'),
confirm: handleDelete.bind(this, record),
},
auth: 'biz:myDataSource:edit',
},
],
};
const [registerTable, { reload, getForm }] = useTable<MyDataSource>({
api: myDataSourceListData,
beforeFetch: (params) => {
return params;
},
columns: tableColumns,
actionColumn: actionColumn,
formConfig: searchForm,
showTableSetting: true,
useSearchForm: true,
canResize: true,
});
onMounted(async () => {
const res = await myDataSourceList();
record.value = (res.myDataSource || {}) as MyDataSource;
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/myDataSource/exportData',
params: getForm().getFieldsValue(),
});
loading.value = false;
}
async function handleDelete(record: Recordable) {
const params = { sourceId: record.sourceId };
const res = await myDataSourceDelete(params);
showMessage(res.message);
await handleSuccess(record);
}
async function handleSuccess(record: Recordable) {
await reload({ record });
}
</script>

View File

@@ -0,0 +1,178 @@
import { useI18n } from '@jeesite/core/hooks/web/useI18n';
import { BasicColumn, BasicTableProps, FormProps } from '@jeesite/core/components/Table';
import { myDataSourceListData } from '@jeesite/biz/api/biz/myDataSource';
const { t } = useI18n('biz.myDataSource');
const modalProps = {
title: t('数据库连接选择'),
};
const searchForm: FormProps<MyDataSource> = {
baseColProps: { md: 8, lg: 6 },
labelWidth: 90,
schemas: [
{
label: t('创建时间起'),
field: 'createTime_gte',
component: 'DatePicker',
componentProps: {
format: 'YYYY-MM-DD HH:mm',
showTime: { format: 'HH:mm' },
},
},
{
label: t('创建时间止'),
field: 'createTime_lte',
component: 'DatePicker',
componentProps: {
format: 'YYYY-MM-DD HH:mm',
showTime: { format: 'HH:mm' },
},
},
{
label: t('连接名称'),
field: 'sourceName',
component: 'Input',
},
{
label: t('数据库类型'),
field: 'dbType',
component: 'Input',
},
{
label: t('数据库IP'),
field: 'dbHost',
component: 'Input',
},
{
label: t('数据库名称'),
field: 'dbName',
component: 'Input',
},
{
label: t('状态'),
field: 'ustatus',
component: 'Input',
},
],
};
const tableColumns: BasicColumn<MyDataSource>[] = [
{
title: t('创建时间'),
dataIndex: 'createTime',
key: 'a.create_time',
sorter: true,
width: 230,
align: 'left',
slot: 'firstColumn',
},
{
title: t('连接名称'),
dataIndex: 'sourceName',
key: 'a.source_name',
sorter: true,
width: 130,
align: 'left',
},
{
title: t('数据库类型'),
dataIndex: 'dbType',
key: 'a.db_type',
sorter: true,
width: 130,
align: 'left',
},
{
title: t('数据库IP'),
dataIndex: 'dbHost',
key: 'a.db_host',
sorter: true,
width: 130,
align: 'left',
},
{
title: t('数据库端口'),
dataIndex: 'dbPort',
key: 'a.db_port',
sorter: true,
width: 130,
align: 'center',
},
{
title: t('数据库名称'),
dataIndex: 'dbName',
key: 'a.db_name',
sorter: true,
width: 130,
align: 'left',
},
{
title: t('账号'),
dataIndex: 'username',
key: 'a.username',
sorter: true,
width: 130,
align: 'left',
},
{
title: t('密码'),
dataIndex: 'password',
key: 'a.password',
sorter: true,
width: 130,
align: 'left',
},
{
title: t('连接参数'),
dataIndex: 'params',
key: 'a.params',
sorter: true,
width: 130,
align: 'left',
},
{
title: t('备注说明'),
dataIndex: 'remark',
key: 'a.remark',
sorter: true,
width: 130,
align: 'left',
},
{
title: t('状态'),
dataIndex: 'ustatus',
key: 'a.ustatus',
sorter: true,
width: 130,
align: 'left',
},
{
title: t('更新时间'),
dataIndex: 'updateTime',
key: 'a.update_time',
sorter: true,
width: 130,
align: 'center',
},
];
const tableProps: BasicTableProps = {
api: myDataSourceListData,
beforeFetch: (params) => {
params['isAll'] = true;
return params;
},
columns: tableColumns,
formConfig: searchForm,
rowKey: 'sourceId',
};
export default {
modalProps,
tableProps,
itemCode: 'sourceId',
itemName: 'sourceId',
isShowCode: false,
};

View File

@@ -0,0 +1,134 @@
<!--
* 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

@@ -0,0 +1,103 @@
<!--
* 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

@@ -0,0 +1,232 @@
<!--
* 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

@@ -0,0 +1,125 @@
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,
};