From c56cb87cd2aeba4d63938910b6a78117729573a1 Mon Sep 17 00:00:00 2001 From: yangyin <1850366751@qq.com> Date: 星期五, 30 八月 2024 14:25:17 +0800 Subject: [PATCH] Merge branch 'master' of http://47.103.154.90:83/r/WI/Web.Admin.V1.0 --- src/views/project/yw/lowCode/sqlAmis/edit/SqlAmisEdit.vue | 95 ++++++++++++++++++++++++++++++++--------------- 1 files changed, 65 insertions(+), 30 deletions(-) diff --git a/src/views/project/yw/lowCode/sqlAmis/edit/SqlAmisEdit.vue b/src/views/project/yw/lowCode/sqlAmis/edit/SqlAmisEdit.vue index d4a697b..dbc68a5 100644 --- a/src/views/project/yw/lowCode/sqlAmis/edit/SqlAmisEdit.vue +++ b/src/views/project/yw/lowCode/sqlAmis/edit/SqlAmisEdit.vue @@ -1,6 +1,19 @@ <template> <div class="h-full flex flex-col"> - <div class="grid grid-cols-2 gap-2 h-full flex-0"> + <titleBox class="flex-0" style="background-color: #fff" :title="supervisor?.title"> + <template v-slot:left> + <el-button + icon="ele-ArrowLeft" + text + style="margin-right: 10px; margin-left: 10px; width: 40px" + size="small" + @click="backLastPage" + > + </el-button> + </template> + </titleBox> + + <div class="grid grid-cols-2 gap-2 h-full flex-auto"> <div class="h-full overflow-auto"> <el-table :data="configList" @@ -41,21 +54,6 @@ /> </div> </div> - <!-- <div class="flex-auto overflow-auto mt-3"> - <codemirror - disabled - class="h-full overflow-auto" - v-model="jsonCode" - :style="{ height: '100%' }" - :autofocus="true" - :indent-with-tab="true" - :tab-size="2" - :extensions="jsonEditorExtensions" - @change="log('change', $event)" - @focus="log('focus', $event)" - @blur="log('blur', $event)" - /> - </div> --> </div> </template> @@ -64,11 +62,20 @@ import { sql } from '@codemirror/lang-sql'; import { xml } from '@codemirror/lang-xml'; import { vscodeDark } from '@uiw/codemirror-theme-vscode'; -import { ref } from 'vue'; +import _ from 'lodash'; +import { onMounted, ref } from 'vue'; import { Codemirror } from 'vue-codemirror'; import * as codeExample from './testData'; -import _, { uniqueId } from 'lodash'; -import {v4 as uuid} from 'uuid' +import titleBox from '/@/components/titleBox.vue'; + +import { v4 as uuid } from 'uuid'; +import { getAmisXml } from '/@/api/supervisorAdmin'; +import { useCompRef } from '/@/utils/types'; +import { XMLParser, XMLBuilder, XMLValidator } from 'fast-xml-parser'; +import { ElMessage } from 'element-plus'; + +const props = defineProps(['supervisor']); +const emit = defineEmits(['backLastPage']); const log = console.log; const jsonCode = ref(codeExample.jsonCode); const dockCode = ref(codeExample.dockCode); @@ -77,7 +84,17 @@ const jsonEditorExtensions = [json(), vscodeDark]; const sqlEditorExtensions = [sql(), vscodeDark]; const dockEditorExtensions = [xml(), vscodeDark]; - +const sqlCodeEditorRef = useCompRef(Codemirror); +const resetStatus = () => { + configList.value = []; + sqlCode.value = ''; +}; +const backLastPage = () => { + // setTimeout(() => { + // resetStatus(); + // }, 300); + emit('backLastPage'); +}; const dockRowChange = (row) => {}; /** @description 璺緞鍒嗛殧绗� */ const PATH_SEPARATOR = '/'; @@ -128,10 +145,10 @@ value: AmisDockValue; }; -type AmisDockSQLConfig = AmisDockConfig&{ - queryId:string; - recordId:string; -} +type AmisDockSQLConfig = AmisDockConfig & { + queryId: string; + recordId: string; +}; const configList = ref<AmisDockConfig[]>([]); const parseJSONData = (json: string) => { @@ -141,20 +158,38 @@ if (key === 'api') { const url = value.url; const urlPath = path + PATH_SEPARATOR + 'url'; - const queryId ='query_'+uuid().slice(0,12); - + const queryId = 'query_' + uuid().slice(0, 12); + // const recordId = uniqueId() configList.value.push({ - queryId:queryId, - recordId:queryId, + queryId: queryId, + recordId: queryId, type: AmisDockType.Api, path: urlPath, value: url, - url:url, + url: url, } as any); } }); }; -parseJSONData(codeExample.jsonCode); + +const xmlParserInstance = new XMLParser(); +const xmlBuilderInstance = new XMLBuilder(); +let xmlConfig = null; +onMounted(async () => { + xmlConfig = await getAmisXml({ + agent_id: props.supervisor.id, + }); + if (!xmlConfig?.amis_xml) { + // ElMessage.warning('鏆傛棤鏁版嵁'); + return; + } + const jObj = xmlParserInstance.parse(xmlConfig.amis_xml); + if (!jObj?.AMIS_JSON) { + return; + } + const amisJSON = jObj.AMIS_JSON; + parseJSONData(amisJSON); +}); </script> -- Gitblit v1.9.3