调整数据源配置、机构管理、服务指令同步机构获取相关逻辑
This commit is contained in:
parent
d3bed9c000
commit
d61a805aad
|
@ -1,13 +1,6 @@
|
|||
<template>
|
||||
<BasicDrawer
|
||||
v-bind="$attrs"
|
||||
@register="registerDrawer"
|
||||
:title="getTitle"
|
||||
:width="adaptiveWidth"
|
||||
@ok="handleSubmit"
|
||||
:showFooter="showFooter"
|
||||
destroyOnClose
|
||||
>
|
||||
<BasicDrawer v-bind="$attrs" @register="registerDrawer" :title="getTitle" :width="adaptiveWidth" @ok="handleSubmit"
|
||||
:showFooter="showFooter" destroyOnClose>
|
||||
<BasicForm @register="registerForm">
|
||||
<template #pwd="{ model, field }">
|
||||
<a-row :gutter="8">
|
||||
|
@ -19,11 +12,12 @@
|
|||
</a-col>
|
||||
</a-row>
|
||||
</template>
|
||||
<template #departSelect ="{model,field}">
|
||||
<a-select v-model:value="model[field]" :disabled="model['id']!=null" @change="(value,option) => handleChange(value,model)">
|
||||
<template #departSelect="{ model, field }">
|
||||
<a-select v-model:value="model[field]" :disabled="model['id'] != null"
|
||||
@change="(value, option) => handleChange(value, model)" :allowClear="true">
|
||||
<template v-for="item in departOptions" :key="`${item.code}`">
|
||||
<a-select-option :value="item.code" :label="item.departName">
|
||||
{{item.departName}}
|
||||
{{ item.departName }}
|
||||
</a-select-option>
|
||||
</template>
|
||||
</a-select>
|
||||
|
@ -33,112 +27,110 @@
|
|||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { defineComponent, ref, computed, unref, useAttrs } from 'vue';
|
||||
import { BasicForm, useForm } from '/@/components/Form/index';
|
||||
import { BasicDrawer, useDrawerInner } from '/@/components/Drawer';
|
||||
import { useDrawerAdaptiveWidth } from '/@/hooks/jeecg/useAdaptiveWidth';
|
||||
import { formSchema } from './datasource.data';
|
||||
import { saveOrUpdateDataSource, getDataSourceById, testConnection, queryDeparts } from './datasource.api';
|
||||
import {useMessage} from "@/hooks/web/useMessage";
|
||||
const { createMessage } = useMessage();
|
||||
// 声明Emits
|
||||
const emit = defineEmits(['success', 'register']);
|
||||
const attrs = useAttrs();
|
||||
const isUpdate = ref(true);
|
||||
const rowId = ref('');
|
||||
let isFormDepartUser = false;
|
||||
//表单配置
|
||||
const [registerForm, { setProps, resetFields, validateFields, getFieldsValue, setFieldsValue, validate, updateSchema }] = useForm({
|
||||
labelWidth: 90,
|
||||
schemas: formSchema,
|
||||
showActionButtonGroup: false,
|
||||
});
|
||||
const showFooter = ref(true);
|
||||
const departOptions = ref<any[]>([]);
|
||||
//表单赋值
|
||||
const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async (data) => {
|
||||
await resetFields();
|
||||
showFooter.value = data?.showFooter ?? true;
|
||||
setDrawerProps({ confirmLoading: false, showFooter: showFooter.value });
|
||||
isUpdate.value = !!data?.isUpdate;
|
||||
if (unref(isUpdate)){
|
||||
await getDepartOptions('');
|
||||
}else{
|
||||
await getDepartOptions('1');
|
||||
}
|
||||
|
||||
if (unref(isUpdate)) {
|
||||
|
||||
//获取详情
|
||||
data.record = await getDataSourceById({ id: data.record.id });
|
||||
//表单赋值
|
||||
await setFieldsValue({
|
||||
...data.record,
|
||||
});
|
||||
}
|
||||
// 隐藏底部时禁用整个表单
|
||||
setProps({ disabled: !showFooter.value });
|
||||
});
|
||||
//获取标题
|
||||
const getTitle = computed(() => {
|
||||
if (!unref(isUpdate)) {
|
||||
return '新增数据源';
|
||||
} else {
|
||||
return unref(showFooter) ? '编辑数据源' : '数据源详情';
|
||||
}
|
||||
});
|
||||
const { adaptiveWidth } = useDrawerAdaptiveWidth();
|
||||
|
||||
async function getDepartOptions(addFLag){
|
||||
departOptions.value = [];
|
||||
const data = await queryDeparts({ addFLag : addFLag });
|
||||
Object.assign(departOptions.value, data);
|
||||
import { defineComponent, ref, computed, unref, useAttrs } from 'vue';
|
||||
import { BasicForm, useForm } from '/@/components/Form/index';
|
||||
import { BasicDrawer, useDrawerInner } from '/@/components/Drawer';
|
||||
import { useDrawerAdaptiveWidth } from '/@/hooks/jeecg/useAdaptiveWidth';
|
||||
import { formSchema } from './datasource.data';
|
||||
import { saveOrUpdateDataSource, getDataSourceById, testConnection, queryDeparts } from './datasource.api';
|
||||
import { useMessage } from "@/hooks/web/useMessage";
|
||||
const { createMessage } = useMessage();
|
||||
// 声明Emits
|
||||
const emit = defineEmits(['success', 'register']);
|
||||
const attrs = useAttrs();
|
||||
const isUpdate = ref(true);
|
||||
const rowId = ref('');
|
||||
let isFormDepartUser = false;
|
||||
//表单配置
|
||||
const [registerForm, { setProps, resetFields, validateFields, getFieldsValue, setFieldsValue, validate, updateSchema }] = useForm({
|
||||
labelWidth: 90,
|
||||
schemas: formSchema,
|
||||
showActionButtonGroup: false,
|
||||
});
|
||||
const showFooter = ref(true);
|
||||
const departOptions = ref<any[]>([]);
|
||||
//表单赋值
|
||||
const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async (data) => {
|
||||
await resetFields();
|
||||
showFooter.value = data?.showFooter ?? true;
|
||||
setDrawerProps({ confirmLoading: false, showFooter: showFooter.value });
|
||||
isUpdate.value = !!data?.isUpdate;
|
||||
if (unref(isUpdate)) {
|
||||
await getDepartOptions('');
|
||||
} else {
|
||||
await getDepartOptions('1');
|
||||
}
|
||||
|
||||
async function handleChange(value,formData){
|
||||
if(value == null){
|
||||
formData["code"] = "";
|
||||
}else{
|
||||
formData["code"] = value;
|
||||
}
|
||||
}
|
||||
if (unref(isUpdate)) {
|
||||
|
||||
async function handleTest() {
|
||||
let keys = ['dbType', 'dbDriver', 'dbUrl', 'dbName', 'dbUsername', 'dbPassword'];
|
||||
// 获取以上字段的值,并清除校验状态
|
||||
let fieldsValues = getFieldsValue(keys);
|
||||
let setFields = {};
|
||||
keys.forEach((key) => (setFields[key] = { value: fieldsValues[key], errors: null }));
|
||||
await validateFields(keys).then((values) => {
|
||||
let loading = createMessage.loading('连接中....', 0);
|
||||
testConnection(values)
|
||||
.then((data) => {
|
||||
if (data.success) {
|
||||
createMessage.success('连接成功');
|
||||
}
|
||||
})
|
||||
.catch((error) => {})
|
||||
.finally(() => loading());
|
||||
//获取详情
|
||||
data.record = await getDataSourceById({ id: data.record.id });
|
||||
//表单赋值
|
||||
await setFieldsValue({
|
||||
...data.record,
|
||||
});
|
||||
}
|
||||
|
||||
//提交事件
|
||||
async function handleSubmit() {
|
||||
try {
|
||||
let values = await validate();
|
||||
setDrawerProps({ confirmLoading: true });
|
||||
await saveOrUpdateDataSource(values, isUpdate.value);
|
||||
//关闭弹窗
|
||||
closeDrawer();
|
||||
//刷新列表
|
||||
emit('success');
|
||||
} finally {
|
||||
setDrawerProps({ confirmLoading: false });
|
||||
}
|
||||
// 隐藏底部时禁用整个表单
|
||||
setProps({ disabled: !showFooter.value });
|
||||
});
|
||||
//获取标题
|
||||
const getTitle = computed(() => {
|
||||
if (!unref(isUpdate)) {
|
||||
return '新增数据源';
|
||||
} else {
|
||||
return unref(showFooter) ? '编辑数据源' : '数据源详情';
|
||||
}
|
||||
});
|
||||
const { adaptiveWidth } = useDrawerAdaptiveWidth();
|
||||
|
||||
async function getDepartOptions(addFLag) {
|
||||
departOptions.value = [];
|
||||
const data = await queryDeparts({ addFLag: addFLag });
|
||||
Object.assign(departOptions.value, data);
|
||||
}
|
||||
|
||||
async function handleChange(value, formData) {
|
||||
if (value == null) {
|
||||
formData["code"] = "";
|
||||
} else {
|
||||
formData["code"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
async function handleTest() {
|
||||
let keys = ['dbType', 'dbDriver', 'dbUrl', 'dbName', 'dbUsername', 'dbPassword'];
|
||||
// 获取以上字段的值,并清除校验状态
|
||||
let fieldsValues = getFieldsValue(keys);
|
||||
let setFields = {};
|
||||
keys.forEach((key) => (setFields[key] = { value: fieldsValues[key], errors: null }));
|
||||
await validateFields(keys).then((values) => {
|
||||
let loading = createMessage.loading('连接中....', 0);
|
||||
testConnection(values)
|
||||
.then((data) => {
|
||||
if (data.success) {
|
||||
createMessage.success('连接成功');
|
||||
}
|
||||
})
|
||||
.catch((error) => { })
|
||||
.finally(() => loading());
|
||||
});
|
||||
}
|
||||
|
||||
//提交事件
|
||||
async function handleSubmit() {
|
||||
try {
|
||||
let values = await validate();
|
||||
setDrawerProps({ confirmLoading: true });
|
||||
await saveOrUpdateDataSource(values, isUpdate.value);
|
||||
//关闭弹窗
|
||||
closeDrawer();
|
||||
//刷新列表
|
||||
emit('success');
|
||||
} finally {
|
||||
setDrawerProps({ confirmLoading: false });
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
<style scoped></style>
|
||||
|
|
|
@ -11,11 +11,12 @@
|
|||
</a-col>
|
||||
</a-row>
|
||||
</template>
|
||||
<template #departSelect ="{model,field}">
|
||||
<a-select v-model:value="model[field]" :disabled="model['id']!=null" @change="(value,option) => handleChange(value,model)">
|
||||
<template #departSelect="{ model, field }">
|
||||
<a-select v-model:value="model[field]" :disabled="model['id'] != null"
|
||||
@change="(value, option) => handleChange(value, model)" :allowClear="true">
|
||||
<template v-for="item in departOptions" :key="`${item.code}`">
|
||||
<a-select-option :value="item.code" :label="item.departName">
|
||||
{{item.departName}}
|
||||
{{ item.departName }}
|
||||
</a-select-option>
|
||||
</template>
|
||||
</a-select>
|
||||
|
@ -24,95 +25,95 @@
|
|||
</BasicModal>
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
import { ref, computed, unref } from 'vue';
|
||||
import { BasicModal, useModalInner } from '/@/components/Modal';
|
||||
import { BasicForm, useForm } from '/@/components/Form/index';
|
||||
import { formSchema } from './datasource.data';
|
||||
import { saveOrUpdateDataSource, getDataSourceById, testConnection, queryDeparts } from './datasource.api';
|
||||
import { useMessage } from '/@/hooks/web/useMessage';
|
||||
import { ref, computed, unref } from 'vue';
|
||||
import { BasicModal, useModalInner } from '/@/components/Modal';
|
||||
import { BasicForm, useForm } from '/@/components/Form/index';
|
||||
import { formSchema } from './datasource.data';
|
||||
import { saveOrUpdateDataSource, getDataSourceById, testConnection, queryDeparts } from './datasource.api';
|
||||
import { useMessage } from '/@/hooks/web/useMessage';
|
||||
|
||||
const { createMessage } = useMessage();
|
||||
// Emits声明
|
||||
const emit = defineEmits(['register', 'success']);
|
||||
const isUpdate = ref(true);
|
||||
const departOptions = ref<any[]>([]);
|
||||
//表单配置
|
||||
const [registerForm, { getFieldsValue, resetFields, validateFields, setFieldsValue, validate }] = useForm({
|
||||
// labelWidth: 150,
|
||||
schemas: formSchema,
|
||||
showActionButtonGroup: false,
|
||||
});
|
||||
//表单赋值
|
||||
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
|
||||
//重置表单
|
||||
await resetFields();
|
||||
const { createMessage } = useMessage();
|
||||
// Emits声明
|
||||
const emit = defineEmits(['register', 'success']);
|
||||
const isUpdate = ref(true);
|
||||
const departOptions = ref<any[]>([]);
|
||||
//表单配置
|
||||
const [registerForm, { getFieldsValue, resetFields, validateFields, setFieldsValue, validate }] = useForm({
|
||||
// labelWidth: 150,
|
||||
schemas: formSchema,
|
||||
showActionButtonGroup: false,
|
||||
});
|
||||
//表单赋值
|
||||
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
|
||||
//重置表单
|
||||
await resetFields();
|
||||
|
||||
setModalProps({ confirmLoading: false });
|
||||
isUpdate.value = !!data?.isUpdate;
|
||||
if (unref(isUpdate)){
|
||||
await getDepartOptions('');
|
||||
}else{
|
||||
await getDepartOptions('1');
|
||||
}
|
||||
if (unref(isUpdate)) {
|
||||
//获取详情
|
||||
data.record = await getDataSourceById({ id: data.record.id });
|
||||
//表单赋值
|
||||
await setFieldsValue({
|
||||
...data.record,
|
||||
});
|
||||
}
|
||||
});
|
||||
//设置标题
|
||||
const title = computed(() => (!unref(isUpdate) ? '新增数据源' : '编辑数据源'));
|
||||
|
||||
async function getDepartOptions(addFLag){
|
||||
departOptions.value = [];
|
||||
const data = await queryDeparts({ addFLag : addFLag });
|
||||
console.log(data);
|
||||
Object.assign(departOptions.value, data);
|
||||
setModalProps({ confirmLoading: false });
|
||||
isUpdate.value = !!data?.isUpdate;
|
||||
if (unref(isUpdate)) {
|
||||
await getDepartOptions('');
|
||||
} else {
|
||||
await getDepartOptions('1');
|
||||
}
|
||||
|
||||
async function handleChange(value,formData){
|
||||
if(value == null){
|
||||
formData["code"] = "";
|
||||
}else{
|
||||
formData["code"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
async function handleTest() {
|
||||
let keys = ['dbType', 'dbDriver', 'dbUrl', 'dbName', 'dbUsername', 'dbPassword'];
|
||||
// 获取以上字段的值,并清除校验状态
|
||||
let fieldsValues = getFieldsValue(keys);
|
||||
let setFields = {};
|
||||
keys.forEach((key) => (setFields[key] = { value: fieldsValues[key], errors: null }));
|
||||
await validateFields(keys).then((values) => {
|
||||
let loading = createMessage.loading('连接中....', 0);
|
||||
testConnection(values)
|
||||
.then((data) => {
|
||||
if (data.success) {
|
||||
createMessage.success('连接成功');
|
||||
}
|
||||
})
|
||||
.catch((error) => {})
|
||||
.finally(() => loading());
|
||||
if (unref(isUpdate)) {
|
||||
//获取详情
|
||||
data.record = await getDataSourceById({ id: data.record.id });
|
||||
//表单赋值
|
||||
await setFieldsValue({
|
||||
...data.record,
|
||||
});
|
||||
}
|
||||
});
|
||||
//设置标题
|
||||
const title = computed(() => (!unref(isUpdate) ? '新增数据源' : '编辑数据源'));
|
||||
|
||||
//表单提交事件
|
||||
async function handleSubmit(v) {
|
||||
try {
|
||||
let values = await validate();
|
||||
setModalProps({ confirmLoading: true });
|
||||
//提交表单
|
||||
await saveOrUpdateDataSource(values, isUpdate.value);
|
||||
//关闭弹窗
|
||||
closeModal();
|
||||
//刷新列表
|
||||
emit('success');
|
||||
} finally {
|
||||
setModalProps({ confirmLoading: false });
|
||||
}
|
||||
async function getDepartOptions(addFLag) {
|
||||
departOptions.value = [];
|
||||
const data = await queryDeparts({ addFLag: addFLag });
|
||||
console.log(data);
|
||||
Object.assign(departOptions.value, data);
|
||||
}
|
||||
|
||||
async function handleChange(value, formData) {
|
||||
if (value == null) {
|
||||
formData["code"] = "";
|
||||
} else {
|
||||
formData["code"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
async function handleTest() {
|
||||
let keys = ['dbType', 'dbDriver', 'dbUrl', 'dbName', 'dbUsername', 'dbPassword'];
|
||||
// 获取以上字段的值,并清除校验状态
|
||||
let fieldsValues = getFieldsValue(keys);
|
||||
let setFields = {};
|
||||
keys.forEach((key) => (setFields[key] = { value: fieldsValues[key], errors: null }));
|
||||
await validateFields(keys).then((values) => {
|
||||
let loading = createMessage.loading('连接中....', 0);
|
||||
testConnection(values)
|
||||
.then((data) => {
|
||||
if (data.success) {
|
||||
createMessage.success('连接成功');
|
||||
}
|
||||
})
|
||||
.catch((error) => { })
|
||||
.finally(() => loading());
|
||||
});
|
||||
}
|
||||
|
||||
//表单提交事件
|
||||
async function handleSubmit(v) {
|
||||
try {
|
||||
let values = await validate();
|
||||
setModalProps({ confirmLoading: true });
|
||||
//提交表单
|
||||
await saveOrUpdateDataSource(values, isUpdate.value);
|
||||
//关闭弹窗
|
||||
closeModal();
|
||||
//刷新列表
|
||||
emit('success');
|
||||
} finally {
|
||||
setModalProps({ confirmLoading: false });
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -13,6 +13,7 @@ enum Api {
|
|||
getByCode = '/sys/dataSource/queryBySysOrgCode',
|
||||
// exportXlsUrl = 'sys/dataSource/exportXls',
|
||||
// importExcelUrl = 'sys/dataSource/importExcel',
|
||||
validCode = '/sys/dataSource/validCode',
|
||||
}
|
||||
// /**
|
||||
// * 导出api
|
||||
|
@ -99,3 +100,8 @@ export const queryDeparts = (params) => {
|
|||
export const getDataSourceByCode = (params) => {
|
||||
return defHttp.get({ url: Api.getByCode, params });
|
||||
};
|
||||
|
||||
|
||||
export const validCode = (params) => {
|
||||
return defHttp.get({ url: Api.validCode, params });
|
||||
};
|
|
@ -1,4 +1,5 @@
|
|||
import { BasicColumn, FormSchema } from '/@/components/Table';
|
||||
import { validCode } from './datasource.api'
|
||||
|
||||
const dbDriverMap = {
|
||||
// MySQL 数据库
|
||||
|
@ -69,6 +70,12 @@ const dbUrlMap = {
|
|||
};
|
||||
|
||||
export const columns: BasicColumn[] = [
|
||||
{
|
||||
title: '数据源名称',
|
||||
dataIndex: 'name',
|
||||
width: 150,
|
||||
align: 'left',
|
||||
},
|
||||
{
|
||||
title: '所属机构',
|
||||
dataIndex: 'sysOrgCode_dictText',
|
||||
|
@ -81,12 +88,6 @@ export const columns: BasicColumn[] = [
|
|||
width: 150,
|
||||
align: 'left',
|
||||
},
|
||||
{
|
||||
title: '数据源名称',
|
||||
dataIndex: 'name',
|
||||
width: 150,
|
||||
align: 'left',
|
||||
},
|
||||
{
|
||||
title: '数据库类型',
|
||||
dataIndex: 'dbType_dictText',
|
||||
|
@ -143,11 +144,17 @@ export const formSchema: FormSchema[] = [
|
|||
component: 'Input',
|
||||
show: false,
|
||||
},
|
||||
{
|
||||
field: 'name',
|
||||
label: '数据源名称',
|
||||
component: 'Input',
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
field: 'sysOrgCode',
|
||||
label: '所属机构',
|
||||
component: 'Input',
|
||||
required: true,
|
||||
required: false,
|
||||
slot: 'departSelect',
|
||||
},
|
||||
{
|
||||
|
@ -155,13 +162,24 @@ export const formSchema: FormSchema[] = [
|
|||
label: '数据源编码',
|
||||
component: 'Input',
|
||||
required: true,
|
||||
dynamicDisabled: true
|
||||
},
|
||||
{
|
||||
field: 'name',
|
||||
label: '数据源名称',
|
||||
component: 'Input',
|
||||
required: true,
|
||||
dynamicDisabled: (val) => {
|
||||
return !!val.model.sysOrgCode;
|
||||
},
|
||||
// dynamicDisabled:true,
|
||||
// rules: [
|
||||
// {
|
||||
// validator: async (_, value) => {
|
||||
// if (!value) return Promise.resolve();
|
||||
// const res = await validCode({code:value});
|
||||
|
||||
// if (res == 'exist') {
|
||||
// return Promise.reject('编码已存在!');
|
||||
// }
|
||||
// return Promise.resolve();
|
||||
// },
|
||||
// trigger: 'blur',
|
||||
// }
|
||||
// ]
|
||||
},
|
||||
{
|
||||
field: 'dbType',
|
||||
|
@ -230,7 +248,7 @@ export function useDataSourceFormSchema() {
|
|||
label: '数据源编码',
|
||||
component: 'Input',
|
||||
// required: true,
|
||||
dynamicDisabled: true
|
||||
dynamicDisabled: true,
|
||||
},
|
||||
{
|
||||
field: 'name',
|
||||
|
|
|
@ -424,7 +424,7 @@ const handleResetOrg = () => {
|
|||
}
|
||||
|
||||
onMounted(() => {
|
||||
queryDepartTreeSync().then(res => {
|
||||
queryDepartTreeSync({platType:'ywjg'}).then(res => {
|
||||
orgTable.value = res;
|
||||
});
|
||||
});
|
||||
|
|
|
@ -48,6 +48,10 @@
|
|||
treeData: props.rootTreeData,
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'platType',
|
||||
show: !isChild
|
||||
},
|
||||
{
|
||||
field: 'orgCode',
|
||||
show: false,
|
||||
|
|
|
@ -37,10 +37,10 @@ export function useBasicFormSchema() {
|
|||
componentProps: { options: [] },
|
||||
},
|
||||
{
|
||||
field: 'platType_dictText',
|
||||
field: 'platType',
|
||||
label: '业务平台类型',
|
||||
defaultValue:'ywjg',
|
||||
component: 'JDictSelectTag',
|
||||
defaultValue:"ywjg",
|
||||
componentProps: {
|
||||
dictCode: 'iz_test_site'
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue