shellExecute.vue 7.21 KB
<template>
  <PageWrapper title=" " dense contentFullHeight fixedHeight contentClass="flex">
    <!-- <GroupTree @select="handleSelect" class="w-1/4 xl:w-1/5" /> -->
    <template #headerContent>
      <div style="width: 100%; display: flex; align-items: center; justify-content: space-between">
        <div style="display: flex; align-items: center">
          <Icon
            @click="goBack"
            class="backBtn"
            icon="eva:arrow-ios-back-fill"
            :size="25"
            color="grey"
          />
          <span style="color: grey; margin-left: 10px"> {{ path }}</span>
        </div>
        <div style="display: flex; margin-left: 500px">
          <!--          提交版本-->
          <Tooltip placement="top" title="提交版本">
            <a-button type="primary" style="margin-right: 10px" @click="handleSubmit">
              提交版本
              <!--                <Icon icon="majesticons:cloud-upload-line" :size="20" />-->
            </a-button>
          </Tooltip>
          <!--          版本管理-->
          <Tooltip placement="top" title="版本管理">
            <a-button type="primary" style="margin-right: 10px" @click="handleVersion">
              版本管理
              <!--                <Icon icon="majesticons:file-search-line" :size="20" />-->
            </a-button>
          </Tooltip>
          <!--          参数配置-->
          <Tooltip placement="top" title="参数配置">
            <a-button type="primary" style="margin-right: 10px" @click="handleOptions">
              参数配置
              <!--                <Icon icon="majesticons:link-circle-line" :size="20" />-->
            </a-button>
          </Tooltip>
          <!--          保存-->
          <Tooltip placement="top" title="保存">
            <a-button type="primary" style="margin-right: 10px" @click="handleSave">
              保存
              <!--              <Icon icon="majesticons:save-line" :size="20" />-->
            </a-button>
          </Tooltip>
        </div>
      </div>
    </template>
    <div class="w-full xl:w-full" style="background-color: white">
      <div style="width: 100%; margin-top: 20px">
        <div class="codeEditorH" style="padding: 0 15px" v-if="layout === 'single'">
          <CodeEditor v-model:value="jsonData" :mode="MODE.SHELL" />
        </div>
      </div>
    </div>
    <OptionsModal @register="registerModal" />
    <PreviewModal @register="registerPreviewModal" />
    <SubmitModal @register="registerSubmitModal" @success="handleSuccess" />
    <VersionManagementModal @register="registerVersionManagementModal" />
  </PageWrapper>
</template>
<script lang="ts" setup>
  import { Tooltip } from 'ant-design-vue';
  import { onMounted, ref, nextTick, watch } from 'vue';
  import { PageWrapper } from '@/components/Page';
  import GroupTree from '../GroupTree.vue';
  import { jsonData, DataTreeData } from '../sqlDevelopmentData';
  import { formSchema } from '../data';
  import { useGo } from '@/hooks/web/usePage';
  import { CodeEditor, MODE } from '@/components/CodeEditor';
  import { BasicForm, useForm } from '@/components/Form';
  import OptionsModal from './optionsModal.vue';
  import { useModal } from '@/components/Modal';
  import ResultModal from './resultModal.vue';
  import PreviewModal from './dataPreviewModal.vue';
  import { useMessage } from '@/hooks/web/useMessage';
  import Icon from '@/components/Icon/Icon.vue';
  import RecordModal from './executeRecordModal.vue';
  import SubmitModal from './handleSubmit/submitModal.vue';
  import { schema } from '@/views/dataIntegration/taskOM/taskOM.data';
  import VersionManagementModal from './versionManagementModal.vue';
  import { useRoute } from 'vue-router';
  import { router } from '@/router';

  defineOptions({ name: 'AccountManagement' });

  const { createMessage } = useMessage();
  const go = useGo();
  const route = useRoute();
  const path = ref('');
  const layout = ref('single');
  const editorLeft = ref<HTMLElement | null>(null);
  const editorRight = ref<HTMLElement | null>(null);
  const toggleLayout = () => {
    layout.value = layout.value === 'single' ? 'double' : 'single';
  };
  const [registerModal, { openModal }] = useModal();
  const [registerSubmitModal, { openModal: openSubmitModal }] = useModal();
  const [registerPreviewModal, { openModal: openPreviewModal }] = useModal();
  const [registerVersionManagementModal, { openModal: openVersionManagementModal }] = useModal();

  /** 部门树的select*/
  function handleSelect() {
    openPreviewModal(true, {
      title: '数据预览',
    });
  }
  function handleOptions() {
    openModal(true, {
      title: '参数配置',
    });
  }

  //提交版本按钮
  function handleSubmit() {
    openSubmitModal(true, {
      title: '提交版本',
    });
  }

  //编辑版本
  function handleVersion() {
    openVersionManagementModal(true, {
      title: '版本管理',
      id: route.query.id,
    });
  }
  function handleChange() {
    createMessage.success('格式化成功');
  }
  function handleSuccess() {
    createMessage.success('提交成功');
  }
  //保存按钮
  function handleSave() {
    createMessage.success('保存成功');
  }

  // 根据id获取文件路径
  function getPathById(id) {
    console.log(id);
    const node = DataTreeData.find((item) => '' + item.businessId === id);
    console.log(node);
    if (!node) return ''; // 如果找不到节点,则返回空字符串
    // 如果是根节点,直接返回其名称
    if (node.parentId === 0) {
      return node.workSpaceName;
    }
    // 递归获取父节点路径,并拼接当前节点名称
    const parentPath = getPathById('' + node.parentId);
    console.log('parentPath', parentPath);
    return `${parentPath} / ${node.workSpaceName}`;
  }

  // 页面左侧点击返回链接时的操作
  function goBack() {
    // // 本例的效果时点击返回始终跳转到账号列表页,实际应用时可返回上一页
    // go('/scriptDevelopment/shellDevelopment/index');
    // router.go(-1);
    router.push({
      path: '/scriptDevelopment/shellDevelopment/index',
    });
  }
  //同步滚动
  const handleScroll = () => {
    if (editorLeft.value && editorRight.value) {
      editorLeft.value.scrollTop = editorRight.value.scrollTop;
      editorLeft.value.scrollLeft = editorRight.value.scrollLeft;
    }
  };
  watch([editorLeft, editorRight], ([newEditorLeft, newEditorRight]) => {
    if (newEditorLeft && newEditorRight) {
      newEditorLeft.addEventListener('scroll', handleScroll);
      newEditorRight.addEventListener('scroll', handleScroll);
    } else {
      if (editorLeft.value) {
        editorLeft.value.removeEventListener('scroll', handleScroll);
      }
      if (editorRight.value) {
        editorRight.value.removeEventListener('scroll', handleScroll);
      }
    }
  });
  onMounted(async () => {
    path.value = getPathById(route.query.id);
    await nextTick(() => {
      if (editorLeft.value && editorRight.value) {
        editorLeft.value.addEventListener('scroll', handleScroll);
        editorRight.value.addEventListener('scroll', handleScroll);
      }
    });
  });
</script>
<style lang="less" scoped>
  :deep(.CodeMirror) {
    height: 700px !important;
  }
  :deep(.ant-page-header) {
    padding: 5px !important;
  }
</style>