| | |
| | | </el-table></Pane |
| | | > |
| | | <Pane :size="60"> |
| | | <Splitpanes class="default-theme h100" :horizontal="true" > |
| | | <Splitpanes class="default-theme h100" :horizontal="true"> |
| | | <Pane :size="35" class="flex-col flex"> |
| | | <div class="flex-0 flex justify-between items-center mb-1 ml-1 h-[36px]"> |
| | | <span class="font-bold">参数</span> |
| | |
| | | </el-table> |
| | | </Pane> |
| | | <Pane :size="65"> |
| | | <div class=" h-full"> |
| | | <div class="h-full"> |
| | | <template v-if="currentDockConfig"> |
| | | <div class=" flex justify-between items-center my-1 ml-1 h-[36px]"> |
| | | |
| | | <div class="flex justify-between items-center my-1 ml-1 h-[36px]"> |
| | | <el-select class="w-52 font-bold" v-model="currentDockConfig.type"> |
| | | <el-option v-for="item in Object.keys(amisDockTypeMap)" :key="item" :value="(item)" :label="amisDockTypeMap[item]"></el-option> |
| | | <el-option |
| | | v-for="item in Object.keys(amisDockTypeMap)" |
| | | :key="item" |
| | | :value="item" |
| | | :label="amisDockTypeMap[item]" |
| | | ></el-option> |
| | | </el-select> |
| | | |
| | | <el-select class="w-40" v-model="currentDockConfig.database" @change="databaseSelectChange"> |
| | |
| | | </div> |
| | | <codemirror |
| | | class="overflow-auto" |
| | | style="height: calc(100% - 36px);" |
| | | style="height: calc(100% - 36px)" |
| | | v-model="currentDockConfig.sql" |
| | | :autofocus="true" |
| | | :indent-with-tab="true" |
| | |
| | | let defaultSelectDatabase = null; |
| | | const databaseSelectChange = (val) => { |
| | | defaultSelectDatabase = val; |
| | | if(currentDockConfig.value){ |
| | | if (currentDockConfig.value) { |
| | | currentDockConfig.value.database = val; |
| | | } |
| | | updateSqlAndRs(currentDockConfig.value.id,currentDockConfig.value) |
| | | updateSqlAndRs(currentDockConfig.value.id, currentDockConfig.value); |
| | | }; |
| | | const backLastPage = () => { |
| | | // setTimeout(() => { |
| | |
| | | if (key === 'api') { |
| | | // const url = value.url; |
| | | const urlPath = path + PATH_SEPARATOR + 'url'; |
| | | const randomStr = 'query_' + uuid().slice(0, 12); |
| | | const randomStr = 'q_' + value.url + '_' + uuid().slice(0, 12); |
| | | const foundItem = apiDataList.find((item) => item.path === urlPath); |
| | | const asyncId = foundItem?.asyncId ?? randomStr; |
| | | const recordId = foundItem?.recordId ?? randomStr; |
| | |
| | | }; |
| | | |
| | | const checkValid = (showTip: boolean, tip?: string) => { |
| | | if(!dockConfigList.value || dockConfigList.value.length===0) return true; |
| | | const foundWithNoDatabase = dockConfigList.value?.find((item) => !item.database); |
| | | if (foundWithNoDatabase && showTip) { |
| | | ElMessage.warning(tip ?? `【${foundWithNoDatabase.id}】未选择数据库`); |
| | |
| | | |
| | | const updateSqlAndRs = (id?, sqlValue?: { database?: string; sql?: string; type?: AmisDockType }) => { |
| | | const apiConfig = configList.value.filter((item) => item.type === AmisDockType.Sql); |
| | | if (apiConfig.length === 0) return; |
| | | |
| | | if (!checkValid(true)) { |
| | | return; |
| | | } |
| | | |
| | | const recordIds = apiConfig?.map(item=>item.recordId)??[]; |
| | | // 过滤出 apiConfig 中有的record; |
| | | dockConfigList.value = dockConfigList.value?.filter(item=>recordIds.includes(item.id))??[] |
| | | const asyncRsList = apiConfig.map((item) => ({ |
| | | amis_path: item.path, |
| | | async_id: item.asyncId, |
| | |
| | | |
| | | // 检查是否需要更新 rs |
| | | const checkRsUpdate = (originData: AmisDockConfig[], currentData: AmisDockConfig[]) => { |
| | | |
| | | // 都为空,不需要更新 |
| | | if ((!originData || originData.length === 0) && (!currentData || currentData.length === 0)) { |
| | | return false; |
| | |
| | | id: props.supervisor.id, |
| | | }); |
| | | |
| | | if (!xmlJson?.amis_json) { |
| | | ElMessage.warning('暂无SQL配置'); |
| | | return; |
| | | } |
| | | |
| | | const originConfig = |
| | | xmlJson.async_rs?.map( |
| | | (item) => |
| | |
| | | rsTableRef.value.setCurrentRow(configList.value[0]); |
| | | } |
| | | |
| | | if (checkRsUpdate(originConfig, configList.value)) { |
| | | if(!configList || configList.value.length===0 ){ |
| | | ElMessage.warning('暂无对接配置'); |
| | | } |
| | | |
| | | const isRsUpdate = checkRsUpdate(originConfig, configList.value) |
| | | if (isRsUpdate) { |
| | | // 自动更新Rs |
| | | updateSqlAndRs(); |
| | | } |