Merge branch 'main' of http://27.223.88.102:33000/chenx/qhmes
This commit is contained in:
19
jeecgboot-vue3/src/views/system/appconfig/McsDbConfig.api.ts
Normal file
19
jeecgboot-vue3/src/views/system/appconfig/McsDbConfig.api.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import { defHttp } from '/@/utils/http/axios';
|
||||
|
||||
enum Api {
|
||||
getConfig = '/xslmes/mcs/dbConfig/get',
|
||||
saveConfig = '/xslmes/mcs/dbConfig/save',
|
||||
testConnect = '/xslmes/mcs/dbConfig/testConnect',
|
||||
deleteConfig = '/xslmes/mcs/dbConfig/delete',
|
||||
status = '/xslmes/mcs/dbConfig/status',
|
||||
}
|
||||
|
||||
export const getMcsDbConfig = (params?) => defHttp.get({ url: Api.getConfig, params });
|
||||
|
||||
export const saveMcsDbConfig = (params) => defHttp.post({ url: Api.saveConfig, params });
|
||||
|
||||
export const testMcsDbConnect = (params?) => defHttp.get({ url: Api.testConnect, params }, { isTransformResponse: false });
|
||||
|
||||
export const deleteMcsDbConfig = (params) => defHttp.delete({ url: Api.deleteConfig, params }, { joinParamsToUrl: true });
|
||||
|
||||
export const getMcsDbStatus = () => defHttp.get({ url: Api.status });
|
||||
100
jeecgboot-vue3/src/views/system/appconfig/McsDbConfig.data.ts
Normal file
100
jeecgboot-vue3/src/views/system/appconfig/McsDbConfig.data.ts
Normal file
@@ -0,0 +1,100 @@
|
||||
import { FormSchema } from '/@/components/Form';
|
||||
|
||||
export const mcsDbConfigFormSchema: FormSchema[] = [
|
||||
{ label: 'id', field: 'id', component: 'Input', show: false },
|
||||
{ label: 'tenantId', field: 'tenantId', component: 'InputNumber', show: false },
|
||||
{
|
||||
label: '服务器地址',
|
||||
field: 'serverHost',
|
||||
component: 'Input',
|
||||
required: true,
|
||||
componentProps: { placeholder: 'IP 或域名,例如 192.168.1.10 或 xxx.vicp.fun' },
|
||||
},
|
||||
{
|
||||
label: '端口',
|
||||
field: 'serverPort',
|
||||
component: 'InputNumber',
|
||||
defaultValue: 1433,
|
||||
required: true,
|
||||
componentProps: { min: 1, max: 65535, style: { width: '100%' } },
|
||||
},
|
||||
{
|
||||
label: '数据库名',
|
||||
field: 'dbName',
|
||||
component: 'Input',
|
||||
defaultValue: 'MES_ShareDB',
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
label: '用户名',
|
||||
field: 'dbUsername',
|
||||
component: 'Input',
|
||||
required: true,
|
||||
componentProps: { placeholder: '例如 sa' },
|
||||
},
|
||||
{
|
||||
label: '密码',
|
||||
field: 'dbPassword',
|
||||
component: 'InputPassword',
|
||||
componentProps: { placeholder: '编辑时留空表示不修改密码' },
|
||||
},
|
||||
{
|
||||
label: '读取开关',
|
||||
field: 'readEnabled',
|
||||
component: 'Switch',
|
||||
helpMessage: '关闭后所有中间表列表/详情查询将被拦截(含 MCS→MES 与 MES→MCS 方向)',
|
||||
componentProps: {
|
||||
checkedChildren: '开启',
|
||||
checkedValue: 1,
|
||||
unCheckedChildren: '关闭',
|
||||
unCheckedValue: 0,
|
||||
},
|
||||
defaultValue: 1,
|
||||
},
|
||||
{
|
||||
label: '写入开关',
|
||||
field: 'writeEnabled',
|
||||
component: 'Switch',
|
||||
helpMessage: '关闭后 MES→MCS 方向的增删改将被拦截(不影响列表查询,查询由读取开关控制)',
|
||||
componentProps: {
|
||||
checkedChildren: '开启',
|
||||
checkedValue: 1,
|
||||
unCheckedChildren: '关闭',
|
||||
unCheckedValue: 0,
|
||||
},
|
||||
defaultValue: 1,
|
||||
},
|
||||
{
|
||||
label: '启用连接',
|
||||
field: 'status',
|
||||
component: 'Switch',
|
||||
helpMessage: '开启后立即连接中间库并热刷新数据源,无需重启后端',
|
||||
componentProps: {
|
||||
checkedChildren: '启用',
|
||||
checkedValue: 1,
|
||||
unCheckedChildren: '停用',
|
||||
unCheckedValue: 0,
|
||||
},
|
||||
defaultValue: 0,
|
||||
},
|
||||
{
|
||||
label: '登录超时(秒)',
|
||||
field: 'loginTimeout',
|
||||
component: 'InputNumber',
|
||||
defaultValue: 120,
|
||||
componentProps: { min: 10, max: 600, style: { width: '100%' } },
|
||||
},
|
||||
{
|
||||
label: '连接超时(毫秒)',
|
||||
field: 'connectTimeout',
|
||||
component: 'InputNumber',
|
||||
defaultValue: 120000,
|
||||
componentProps: { min: 5000, max: 600000, style: { width: '100%' } },
|
||||
},
|
||||
{
|
||||
label: '备注',
|
||||
field: 'remark',
|
||||
component: 'InputTextArea',
|
||||
componentProps: { rows: 2 },
|
||||
},
|
||||
];
|
||||
@@ -0,0 +1,62 @@
|
||||
<template>
|
||||
<BasicModal @register="registerModal" :width="720" title="上辅机中间库配置" @ok="handleSubmit">
|
||||
<BasicForm @register="registerForm" />
|
||||
</BasicModal>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import { BasicModal, useModalInner } from '/@/components/Modal';
|
||||
import { useForm, BasicForm } from '/@/components/Form';
|
||||
import { mcsDbConfigFormSchema } from './McsDbConfig.data';
|
||||
import { getMcsDbConfig, saveMcsDbConfig } from './McsDbConfig.api';
|
||||
import { getTenantId } from '/@/utils/auth';
|
||||
import { useMessage } from '/@/hooks/web/useMessage';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'McsDbConfigModal',
|
||||
components: { BasicModal, BasicForm },
|
||||
emits: ['success'],
|
||||
setup(_props, { emit }) {
|
||||
const { createMessage } = useMessage();
|
||||
const [registerForm, { resetFields, setFieldsValue, validate }] = useForm({
|
||||
schemas: mcsDbConfigFormSchema,
|
||||
showActionButtonGroup: false,
|
||||
labelCol: { span: 24 },
|
||||
wrapperCol: { span: 24 },
|
||||
});
|
||||
|
||||
const [registerModal, { setModalProps, closeModal }] = useModalInner(async () => {
|
||||
setModalProps({ confirmLoading: true });
|
||||
await resetFields();
|
||||
const tenantId = getTenantId();
|
||||
const values = await getMcsDbConfig({ tenantId });
|
||||
setModalProps({ confirmLoading: false });
|
||||
if (values) {
|
||||
await setFieldsValue({ ...values, dbPassword: '' });
|
||||
} else {
|
||||
await setFieldsValue({ tenantId, readEnabled: 1, writeEnabled: 1, status: 0, serverPort: 1433, dbName: 'MES_ShareDB' });
|
||||
}
|
||||
});
|
||||
|
||||
async function handleSubmit() {
|
||||
const values = await validate();
|
||||
if (!values.id && !values.dbPassword) {
|
||||
createMessage.warning('请输入数据库密码');
|
||||
return;
|
||||
}
|
||||
setModalProps({ confirmLoading: true });
|
||||
try {
|
||||
await saveMcsDbConfig(values);
|
||||
createMessage.success('保存成功,已热刷新连接,无需重启后端');
|
||||
emit('success');
|
||||
closeModal();
|
||||
} finally {
|
||||
setModalProps({ confirmLoading: false });
|
||||
}
|
||||
}
|
||||
|
||||
return { registerForm, registerModal, handleSubmit };
|
||||
},
|
||||
});
|
||||
</script>
|
||||
@@ -5,6 +5,7 @@
|
||||
<li :class="activeKey === 'ding' ? 'active' : ''" @click="dingLiClick('ding')"><a>钉钉集成</a></li>
|
||||
<li :class="activeKey === 'wechat' ? 'active' : ''" @click="dingLiClick('wechat')"><a>企业微信集成</a></li>
|
||||
<li :class="activeKey === 'kingdee' ? 'active' : ''" @click="dingLiClick('kingdee')"><a>金蝶集成</a></li>
|
||||
<li :class="activeKey === 'mcs' ? 'active' : ''" @click="dingLiClick('mcs')"><a>上辅机中间库</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div v-show="activeKey === 'ding'" class="base-collapse">
|
||||
@@ -16,14 +17,19 @@
|
||||
<div v-show="activeKey === 'kingdee'" class="base-collapse">
|
||||
<ThirdAppKingdeeConfigForm />
|
||||
</div>
|
||||
<div v-show="activeKey === 'mcs'" class="base-collapse">
|
||||
<ThirdAppMcsDbConfigForm />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent, ref } from 'vue';
|
||||
import { defineComponent, onMounted, ref } from 'vue';
|
||||
import { useRoute } from 'vue-router';
|
||||
import ThirdAppDingTalkConfigForm from './ThirdAppDingTalkConfigForm.vue';
|
||||
import ThirdAppWeEnterpriseConfigForm from './ThirdAppWeEnterpriseConfigForm.vue';
|
||||
import ThirdAppKingdeeConfigForm from './ThirdAppKingdeeConfigForm.vue';
|
||||
import ThirdAppMcsDbConfigForm from './ThirdAppMcsDbConfigForm.vue';
|
||||
import { useDesign } from '/@/hooks/web/useDesign';
|
||||
|
||||
export default defineComponent({
|
||||
@@ -32,13 +38,22 @@
|
||||
ThirdAppDingTalkConfigForm,
|
||||
ThirdAppWeEnterpriseConfigForm,
|
||||
ThirdAppKingdeeConfigForm,
|
||||
ThirdAppMcsDbConfigForm,
|
||||
},
|
||||
setup() {
|
||||
const { prefixCls } = useDesign('j-dd-container');
|
||||
const route = useRoute();
|
||||
|
||||
//选中的key
|
||||
const activeKey = ref<string>('ding');
|
||||
|
||||
onMounted(() => {
|
||||
const tab = route.query.tab as string;
|
||||
if (tab === 'mcs') {
|
||||
activeKey.value = 'mcs';
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* tab点击事件
|
||||
* @param key
|
||||
|
||||
@@ -0,0 +1,208 @@
|
||||
<template>
|
||||
<div class="base-collapse">
|
||||
<div class="header"> 上辅机中间库 </div>
|
||||
<a-collapse expand-icon-position="right" :bordered="false">
|
||||
<a-collapse-panel key="1">
|
||||
<template #header>
|
||||
<div style="font-size: 16px"> 1.配置说明</div>
|
||||
</template>
|
||||
<div class="base-desc">
|
||||
在此配置 SQL Server 中间库(MES_ShareDB)连接信息。<strong>保存后立即生效,无需重启后端</strong>,也无需修改 application.yml。
|
||||
读取开关控制 MCS→MES 方向数据查询;写入开关控制 MES→MCS 方向数据写入。
|
||||
</div>
|
||||
</a-collapse-panel>
|
||||
</a-collapse>
|
||||
<div class="sync-padding">
|
||||
<a-collapse expand-icon-position="right" :bordered="false">
|
||||
<a-collapse-panel key="2">
|
||||
<template #header>
|
||||
<div style="width: 100%; justify-content: space-between; display: flex">
|
||||
<div style="font-size: 16px"> 2.连接信息及开关</div>
|
||||
</div>
|
||||
</template>
|
||||
<a-alert v-if="connStatus" type="info" show-icon style="margin-bottom: 12px" message="当前运行状态" :description="connStatus" />
|
||||
<div class="flex-flow">
|
||||
<div class="base-title">服务器</div>
|
||||
<div class="base-message">
|
||||
<a-input :value="displayHost" readonly />
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex-flow">
|
||||
<div class="base-title">数据库</div>
|
||||
<div class="base-message">
|
||||
<a-input :value="configData.dbName || '-'" readonly />
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex-flow">
|
||||
<div class="base-title">用户名</div>
|
||||
<div class="base-message">
|
||||
<a-input :value="configData.dbUsername || '-'" readonly />
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex-flow">
|
||||
<div class="base-title">读取开关</div>
|
||||
<div class="base-message" style="display: flex; align-items: center; height: 50px">
|
||||
<a-tag :color="runtimeStatus.readEnabled ? 'green' : 'default'">{{ runtimeStatus.readEnabled ? '已开启' : '已关闭' }}</a-tag>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex-flow">
|
||||
<div class="base-title">写入开关</div>
|
||||
<div class="base-message" style="display: flex; align-items: center; height: 50px">
|
||||
<a-tag :color="runtimeStatus.writeEnabled ? 'green' : 'default'">{{ runtimeStatus.writeEnabled ? '已开启' : '已关闭' }}</a-tag>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex-flow">
|
||||
<div class="base-title">连接状态</div>
|
||||
<div class="base-message" style="display: flex; align-items: center; height: 50px">
|
||||
<a-tag :color="runtimeStatus.dbConfigActive ? 'green' : 'orange'">{{ runtimeStatus.dbConfigActive ? '已启用数据库配置' : '使用 yml 默认配置' }}</a-tag>
|
||||
</div>
|
||||
</div>
|
||||
<div style="margin-top: 20px; width: 100%; text-align: right">
|
||||
<a-button type="primary" @click="editClick">编辑配置</a-button>
|
||||
<a-button @click="testClick" style="margin-left: 10px">连接测试</a-button>
|
||||
<a-button v-if="configData.id" @click="deleteClick" danger style="margin-left: 10px">删除配置</a-button>
|
||||
</div>
|
||||
</a-collapse-panel>
|
||||
</a-collapse>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<McsDbConfigModal @register="registerModal" @success="reload" />
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { computed, defineComponent, onMounted, ref } from 'vue';
|
||||
import { Modal } from 'ant-design-vue';
|
||||
import { useModal } from '/@/components/Modal';
|
||||
import { useMessage } from '/@/hooks/web/useMessage';
|
||||
import { getTenantId } from '/@/utils/auth';
|
||||
import McsDbConfigModal from './McsDbConfigModal.vue';
|
||||
import { deleteMcsDbConfig, getMcsDbConfig, getMcsDbStatus, testMcsDbConnect } from './McsDbConfig.api';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'ThirdAppMcsDbConfigForm',
|
||||
components: { McsDbConfigModal },
|
||||
setup() {
|
||||
const { createMessage } = useMessage();
|
||||
const configData = ref<any>({});
|
||||
const runtimeStatus = ref<any>({ dbConfigActive: false, readEnabled: true, writeEnabled: true });
|
||||
const [registerModal, { openModal }] = useModal();
|
||||
|
||||
const displayHost = computed(() => {
|
||||
if (!configData.value.serverHost) return '-';
|
||||
const port = configData.value.serverPort || 1433;
|
||||
return `${configData.value.serverHost}:${port}`;
|
||||
});
|
||||
|
||||
const connStatus = computed(() => {
|
||||
const s = runtimeStatus.value;
|
||||
if (!configData.value.id) {
|
||||
return '尚未保存数据库配置,当前使用 application.yml 中的 sqlserver_mcs 默认连接。';
|
||||
}
|
||||
return `读取:${s.readEnabled ? '开' : '关'} | 写入:${s.writeEnabled ? '开' : '关'} | 连接:${s.dbConfigActive ? '已启用数据库配置' : '使用 yml 默认配置'}`;
|
||||
});
|
||||
|
||||
async function reload() {
|
||||
const tenantId = getTenantId();
|
||||
configData.value = (await getMcsDbConfig({ tenantId })) || {};
|
||||
runtimeStatus.value = (await getMcsDbStatus()) || {};
|
||||
}
|
||||
|
||||
function editClick() {
|
||||
openModal(true, {});
|
||||
}
|
||||
|
||||
async function testClick() {
|
||||
const tenantId = getTenantId();
|
||||
const res = await testMcsDbConnect({ tenantId });
|
||||
if (res.success) {
|
||||
createMessage.success(res.message || '连接成功');
|
||||
} else {
|
||||
createMessage.warning(res.message || '连接失败');
|
||||
}
|
||||
}
|
||||
|
||||
function deleteClick() {
|
||||
Modal.confirm({
|
||||
title: '删除配置',
|
||||
content: '删除后将断开数据库中的中间库配置,系统回退使用 application.yml 默认连接。确认删除?',
|
||||
okText: '确认',
|
||||
cancelText: '取消',
|
||||
onOk: async () => {
|
||||
await deleteMcsDbConfig({ id: configData.value.id });
|
||||
createMessage.success('已删除');
|
||||
await reload();
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
onMounted(reload);
|
||||
|
||||
return {
|
||||
configData,
|
||||
runtimeStatus,
|
||||
displayHost,
|
||||
connStatus,
|
||||
registerModal,
|
||||
editClick,
|
||||
testClick,
|
||||
deleteClick,
|
||||
reload,
|
||||
};
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
.header {
|
||||
align-items: center;
|
||||
box-sizing: border-box;
|
||||
display: flex;
|
||||
height: 50px;
|
||||
justify-content: space-between;
|
||||
font-weight: 700;
|
||||
font-size: 18px;
|
||||
color: @text-color;
|
||||
}
|
||||
|
||||
.flex-flow {
|
||||
display: flex;
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
.sync-padding {
|
||||
padding: 12px 0 16px;
|
||||
color: @text-color;
|
||||
}
|
||||
|
||||
.base-collapse {
|
||||
margin-top: 20px;
|
||||
padding: 0 24px;
|
||||
font-size: 20px;
|
||||
|
||||
.base-desc {
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.base-title {
|
||||
width: 100px;
|
||||
text-align: left;
|
||||
height: 50px;
|
||||
line-height: 50px;
|
||||
}
|
||||
|
||||
.base-message {
|
||||
width: 100%;
|
||||
height: 50px;
|
||||
line-height: 50px;
|
||||
}
|
||||
|
||||
:deep(.ant-collapse-header) {
|
||||
padding: 12px 0 16px;
|
||||
}
|
||||
|
||||
:deep(.ant-collapse-content-box) {
|
||||
padding-left: 0;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user