diff --git a/src/api/DesignForm/type.ts b/src/api/DesignForm/type.ts index 46bc2f0..c3b865a 100644 --- a/src/api/DesignForm/type.ts +++ b/src/api/DesignForm/type.ts @@ -117,7 +117,7 @@ export interface formTabelStruct{ type:string; attribute:string; collation:string; - null:string; + nullVal:string; key:string; default:string; extra:string; diff --git a/src/api/date/apidate.ts b/src/api/date/apidate.ts index 7acd115..1cf922a 100644 --- a/src/api/date/apidate.ts +++ b/src/api/date/apidate.ts @@ -1,5 +1,9 @@ import request from '@/utils/request'; - +import { AxiosPromise } from 'axios'; +import { + gainDatabaseInfo, + havesDatabaseInfo, + } from "@/api/date/type"; export function getOrPostDate(methodStr:string,data?: any) { return request({ url: "/systemapi/dataCenter/gaindataCenter", @@ -14,3 +18,11 @@ export function postSaveData(data?: any) { data: data }); } +//获取数据表 +export function gainDataTable(data?: gainDatabaseInfo): AxiosPromise { + return request({ + url: "/systemapi/dataCenter/gainDataTable", + method: "POST", + data: data + }); +} diff --git a/src/api/date/type.ts b/src/api/date/type.ts index 2ac503e..34b3425 100644 --- a/src/api/date/type.ts +++ b/src/api/date/type.ts @@ -288,3 +288,36 @@ export interface appMatrix{ outcomeName: string; outcomeid: number; } +//获取数据源参数 +export interface gainDatabaseInfo{ + id: string; + type: string; + dataBaseName: string; + ip: string; + port: number; + userName: string; + password: string; +} + +//接收数据库列表 +export interface havesDatabaseInfo{ + tableName: string; + tableKey: string; + fields?: fieldList[]; +} +//数据表结构 +export interface fieldList{ + fieldes:string; + types:string; + attribute:string; + collation:string; + nullVal:string; + key:string; + defaultVal:string; + extra:string; + privileges:string; + comment:string; + pattern:string; + classify: string; + auxiliary: string; +} diff --git a/src/components/DesignForm/formControlPropertiNew.vue b/src/components/DesignForm/formControlPropertiNew.vue index 1e3e04c..2ee1f77 100644 --- a/src/components/DesignForm/formControlPropertiNew.vue +++ b/src/components/DesignForm/formControlPropertiNew.vue @@ -31,6 +31,7 @@ import LayoutPage from "@/components/DesignForm/layoutPage/index.vue"; import { Plus } from "@element-plus/icons-vue"; import Draggable from "vuedraggable-es"; +import { dataBaseStruct } from "@/api/date/type"; const props = withDefaults( //接收父级参数 @@ -83,6 +84,8 @@ const controlDataStyls = computed(() => { return store.controlAttr.styles; }); +const openDataSourceBox = ref(false); + const dataSourceOption = ref([]); const designType = inject("formDesignType"); const state = reactive({ @@ -157,12 +160,31 @@ const numberUinrVerfy = reactive([...validateInt]); const formAttr = computed(() => { const isSearch = state.isSearch; return [ + { + label: "数据源", + placeholder: "请选择引用的数据源", + value: 1, + key: "dataSourceSetup", + type: "dataSourceSetup", + hide: isSearch, + options: [ + { + label: "无", + value: "no", + }, + { + label: "引用数据源", + value: "yes", + }, + ], + }, { label: "表单名称", placeholder: "用于保存的表单名称", value: props.formOtherData.formName, key: "formName", hide: isSearch, + disabled: false, }, { label: "数据源", @@ -180,6 +202,7 @@ const formAttr = computed(() => { placeholder: "表单唯一标识,可为空", key: "name", hide: isSearch, + disabled: false, }, // { // label: '表单标签宽度', @@ -324,7 +347,7 @@ const attrList = computed(() => { { label: "字段标识", value: name, - type: Object.keys(state.dataSourceList).length > 0 ? "select" : "text", + type: Object.keys(state.dataSourceList).length > 0 ? "selectDataSoure" : "text", placeholder: "字段唯一标识,对应数据库", dict: state.dataSourceList, path: "name", @@ -1693,8 +1716,12 @@ defineExpose({ getFormFieldBySource, saveRefreshFormControlAttr }); //判断输入框是否可写 const isNotWrite = (val: any) => { // console.log("判断输入框是否可写--->",val,props.customerformid) - if (val.key === "name" && props.customerformid != "") { + if (val.disabled) { return true; + } else { + if (val.key === "name" && props.customerformid != "") { + return true; + } } return false; }; @@ -3568,15 +3595,102 @@ const radioChangeSet = (val: any) => { }); } }; + +watch( + () => formData.value.dataSource, + (val: string) => { + if (val == "yes") { + formAttr.value.forEach((item) => { + console.log(item.label, "item.", item.type); + if (!item.hide) { + if (!item.type) { + // console.log(item.label, "item.", item.type); + item.disabled = true; + } + } + }); + } else { + + formData.value.dataSourceConfig.id = ""; + formData.value.dataSourceConfig.dataBaseName = ""; + formData.value.dataSourceConfig.tableName = ""; + formData.value.dataSourceConfig.tableKey = ""; + formData.value.dataSourceConfig.dsn = { + dataBaseName: "", + ip: "", + port: 0, + userName: "", + password: "", + }; + + + formAttr.value.forEach((item) => { + console.log(item.label, "item.", item.type); + if (!item.hide) { + if (!item.type) { + // console.log(item.label, "item.", item.type); + item.disabled = false; + } + } + }); + } + }, + { + deep: true, + } +); + +/** +@ 作者: 秦东 +@ 时间: 2024-12-23 10:39:48 +@ 功能: 打开数据源设定 +*/ +const openSetDataSource = () => { + openDataSourceBox.value = true; +}; +/** +@ 作者: 秦东 +@ 时间: 2024-12-23 16:36:16 +@ 功能: 关闭数据源 +*/ +const closeDataSource = () => { + openDataSourceBox.value = false; +}; +/** +@ 作者: 秦东 +@ 时间: 2024-12-26 16:26:06 +@ 功能: 设定关联数据 +*/ +// const dataList = ref([]); +const updataBase = (val: any) => { + console.log("设定关联数据", val); + formData.value.dataSourceConfig.id = val.id; + formData.value.dataSourceConfig.dataBaseName = val.dataBaseName; + formData.value.dataSourceConfig.tableName = val.tableName; + formData.value.dataSourceConfig.tableKey = val.tableKey; + formData.value.dataSourceConfig.dsn = val.dsn; + // dataList.value = val.fields; + state.dataSourceList = val.fields; + + console.log("设定关联数据------1-------》", state.dataSourceList); + console.log("设定关联数据------2-------》", val.fields); + console.log("设定关联数据------3-------》", state.dataSourceList); +};