田源
2024-08-30 fec7ad22eeee559ab290c30bb8a81ebca2008954
Source/plt-web/plt-web-ui/src/views/modelingMenu/ui/formDefine/index.vue
@@ -5,12 +5,12 @@
      <basic-container>
        <div ref="TreeBox" style="height: calc(100vh - 144px);!important;">
          <!-- 左侧树         -->
          <div style="height:  calc(100vh - 280px);">
          <div style="height:  calc(100vh - 220px);">
            <div style="margin-bottom: 10px;display: flex;justify-content: center">
              <el-radio v-model="treeRadio" label="0">业务类型树</el-radio>
              <el-radio v-model="treeRadio" label="1">链接类型树</el-radio>
              <el-radio v-model="treeRadio" label="0" @input="TreeRadioChange">业务类型树</el-radio>
              <el-radio v-model="treeRadio" label="1" @input="TreeRadioChange">链接类型树</el-radio>
            </div>
            <avue-tree :data="treeData" :option="treeOption" @node-click="nodeClick">
            <avue-tree v-loading="treeLoading" :data="treeData" :option="treeOption" @node-click="nodeClick">
          <span slot-scope="{ node, data }" class="el-tree-node__label">
           <span style="font-size: 15px">
              <i class="el-icon-s-promotion"></i>
@@ -26,13 +26,17 @@
    <el-main>
      <basic-container>
        <avue-crud
          v-if="!tableStatus"
          :data="data"
          :option="option">
          :option="option"
          :page.sync="page"
          @size-change="sizeChange"
          @current-change="currentChange">
          <template slot="menuLeft">
            <div style="display: flex; align-items: center;">
               <span style="display: inline-block; margin-right: 10px;">
                <el-radio v-model="tableRadio" label="0">表单</el-radio>
                <el-radio v-model="tableRadio" label="1">表格<span style="color: red;">(先导入表单,再导入表格!)</span></el-radio>
                <el-radio v-model="tableRadio" label="0" @input="tableRadioChange">表单</el-radio>
                <el-radio v-model="tableRadio" label="1" @input="tableRadioChange">表格<span style="color: red;">(先导入表单,再导入表格!)</span></el-radio>
               </span>
              <span style="display: flex;align-items: center; margin-right: 10px;">
                <p style="display: flex; flex-shrink: 0;font-size: 14px">名称:</p>
@@ -53,7 +57,7 @@
            </el-button>
          </template>
        </avue-crud>
        <div style="display: flex;justify-content: center;margin-top: 15px">
        <div v-if="!tableStatus" style="display: flex;justify-content: center;margin-top: 15px">
          <el-button icon="el-icon-plus" plain size="small" type="primary" @click="addClickHandler">增加</el-button>
          <el-button icon="el-icon-delete" plain size="small" type="danger">删除</el-button>
          <el-button icon="el-icon-document-add" plain size="small" type="primary">克隆</el-button>
@@ -71,17 +75,44 @@
import basicOption from "@/util/basic-option";
import FormDialog from "@/views/modelingMenu/ui/formDefine/components/formDialog";
import TableDialog from "@/views/modelingMenu/ui/formDefine/components/tableDialog"
import {gridPortalVIDatas} from "@/api/UI/formDefine/api"
import {getBizTypes} from "@/api/modeling/businessType/api";
import {gridLink} from "@/api/modeling/linkType/api";
import func from "@/util/func";
export default {
  name: "index",
  components: {FormDialog, TableDialog},
  data() {
    return {
      page: {
        currentPage: 1,
        pageSize: 10,
        total: 0,
        pageSizes: [10, 30, 50, 100],
      },
      nodeRow: {},
      treeLoading: false,
      option: {
        ...basicOption,
        addBtn: false,
        editBtn: false,
        delBtn: false
        delBtn: false,
        column: [
          {
            label: '业务名称',
            prop: 'typeName',
          },
          {
            label: '名称',
            prop: 'viName',
            sortable: true,
          },
          {
            label: '类型',
            prop: 'viTypeText',
          },
        ]
      },
      data: [],
      tableRadio: "",
@@ -92,7 +123,16 @@
      }
    }
  },
  created() {
    this.getTreeList();
  },
  computed: {
    tableStatus() {
      return func.isEmptyObject(this.nodeRow)
    }
  },
  methods: {
    // 右侧新增
    addClickHandler() {
      if (!this.tableRadio) {
        this.$message.error('请在表格上方选择新增类型');
@@ -100,7 +140,93 @@
      }
      this.tableRadio === "0" ? this.$refs.formDialog.visible = true : this.$refs.tableDialog.visible = true;
    },
    // 初始化树请求
    getTreeList() {
      this.treeLoading = true;
      getBizTypes().then(res => {
        const data = res.data.data.map(item => {
          item.label = item.attributes.id;
          return item;
        });
        this.treeData = data;
        this.treeLoading = false;
      })
    },
    // 左侧业务类型切换
    TreeRadioChange(val) {
      this.treeLoading = true;
      this.resetTable();
      if (val === "0") {
        getBizTypes().then(res => {
          const data = res.data.data.map(item => {
            item.label = item.attributes.id;
            return item;
          });
          this.treeData = data;
          this.treeLoading = false;
        })
      } else {
        gridLink().then(res => {
          const data = res.data.data.map(item => {
            item.label = item.name;
            return item;
          });
          this.treeData = data;
          this.treeLoading = false;
        })
    }
    },
    // 左侧树点击
    nodeClick(row) {
      console.log(row);
      this.tableRadio = null;
      this.nodeRow = row;
      this.getRightPortalVIDatas(row);
    },
    // 重置表格展示信息 和 表格表单选项
    resetTable() {
      this.data = [];
      this.tableRadio = null;
    },
    // 右侧 表格 表单 信息查询
    getRightPortalVIDatas() {
      const params = {
        'conditionMap[typeName]': this.treeRadio === '0' ? this.nodeRow.attributes.id : this.nodeRow.name,
        'conditionMap[viType]': this.tableRadio === '0' ? 'Form' : this.tableRadio === '1' ? 'Table' : '',
        'conditionMap[viTypeFlag]': this.treeRadio === '0' ? 'BtmType' : this.treeRadio === '1' ? 'LinkType' : '',
      }
      gridPortalVIDatas(this.page.currentPage, this.page.pageSize, params).then(res => {
        console.log(res);
        if (res.data.code === 200) {
          const data = res.data.data;
          this.data = data;
          this.page.total = res.data.total;
        }
      })
    },
    sizeChange(val) {
      this.page.pageSize = val;
      this.getRightPortalVIDatas();
    },
    // 页码
    currentChange(val) {
      this.page.currentPage = val;
      this.getRightPortalVIDatas();
    },
    // 表格 表单切换
    tableRadioChange() {
      this.getRightPortalVIDatas();
    },
  }
}
</script>