田源
2024-10-24 a18dec1e4ae3e241747f73ad409c91a29fd2c42d
Source/plt-web/plt-web-ui/src/views/modelingMenu/ui/formDefine/index.vue
@@ -25,6 +25,15 @@
    <el-main>
      <basic-container>
        <div v-if="!tableStatus" style="display: flex;justify-content: left;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" @click="deleteClickHandler">删除</el-button>
          <el-button icon="el-icon-document-add" plain size="small" type="primary" @click="copyClickHandler">克隆
          </el-button>
          <el-button icon="el-icon-upload2" plain size="small" type="primary" @click="upLoadClickHandler">导入</el-button>
          <el-button icon="el-icon-download" plain size="small" type="primary" @click="exportClickHandler">导出
          </el-button>
        </div>
        <avue-crud
          v-if="!tableStatus"
          ref="crud"
@@ -46,12 +55,6 @@
                <el-input v-model="topName" placeholder="请输入内容" size="mini" style="margin-right: 10px;"></el-input>
                <el-button plain size="mini" type="success" @click="nameSearchHandler">查询</el-button>
              </span>
              <span style="display: flex; align-items: center;">
                <p
                  style="display: flex; align-items: center; margin: 0 10px 0 0;flex-shrink: 0;font-size: 14px">克隆目标:</p>
                <el-input v-model="input" placeholder="请输入内容" size="mini" style="margin-right: 10px;"></el-input>
                <el-button plain size="mini" type="success">克隆目标</el-button>
              </span>
            </div>
          </template>
          <template slot="menu" slot-scope="scope">
@@ -61,22 +64,46 @@
            </el-button>
          </template>
        </avue-crud>
        <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" @click="deleteClickHandler">删除</el-button>
          <el-button icon="el-icon-document-add" plain size="small" type="primary">克隆</el-button>
          <el-button icon="el-icon-upload2" plain size="small" type="primary" @click="upLoadClickHandler">导入</el-button>
          <el-button icon="el-icon-download" plain size="small" type="primary" @click="exportClickHandler">导出
          </el-button>
        </div>
      </basic-container>
    </el-main>
    <form-dialog ref="formDialog" :TreeNodeRow="this.nodeRow" :treeRadio="treeRadio"></form-dialog>
    <form-dialog ref="formDialog" :TreeNodeRow="this.nodeRow" :editRow="editRow" :treeRadio="treeRadio"></form-dialog>
    <table-dialog ref="tableDialog" :TreeNodeRow="this.nodeRow" :treeRadio="treeRadio"
                  @updataTable="getRightPortalVIDatas"></table-dialog>
    <!-- 导入 -->
    <upload-file ref="upload" :fileType="upFileType" :fileUrl="fileUrl" :tipList="tipList" title="导入"
                 @updata="getRightPortalVIDatas"></upload-file>
    <el-dialog
      v-dialogDrag
      :visible.sync="cloneVisible"
      append-to-body="true"
      class="avue-dialog"
      title="克隆"
      width="50%">
      <basic-container>
        <div ref="TreeBox" style="height: calc(100vh - 294px);!important;">
          <!-- 左侧树 -->
          <div style="height:  calc(100vh - 370px);">
            <div style="margin-bottom: 10px;display: flex;justify-content: center">
              <el-radio v-model="cloneTreeRadio" label="0" @input="cloneTreeRadioChange">业务类型树</el-radio>
              <el-radio v-model="cloneTreeRadio" label="1" @input="cloneTreeRadioChange">链接类型树</el-radio>
            </div>
            <avue-tree ref="cloneTree" v-loading="cloneTreeLoading" :data="cloneTreeData" :option="treeOption"
                       @node-click="cloneTreeNodeClick">
          <span slot-scope="{ node, data }" class="el-tree-node__label">
           <span style="font-size: 15px">
              <i class="el-icon-s-promotion"></i>
                {{ (node || {}).label }}
            </span>
          </span>
            </avue-tree>
          </div>
        </div>
      </basic-container>
      <span slot="footer" class="dialog-footer">
         <el-button @click="cloneVisible = false">取 消</el-button>
         <el-button type="primary" @click="cloneSaveHandler">确 定</el-button>
        </span>
    </el-dialog>
  </el-container>
</template>
@@ -84,7 +111,7 @@
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, getPortalVIById, deleteByIds, exportExcel} from "@/api/UI/formDefine/api";
import {gridPortalVIDatas, getPortalVIById, deleteByIds, exportExcel, clone} from "@/api/UI/formDefine/api";
import {getBizTypes} from "@/api/modeling/businessType/api";
import {gridLink} from "@/api/modeling/linkType/api";
import func from "@/util/func";
@@ -94,6 +121,11 @@
  components: {FormDialog, TableDialog},
  data() {
    return {
      cloneTreeNode: {},
      cloneTreeRadio: '0',
      cloneTreeData: [],
      cloneTreeLoading: false,
      cloneVisible: false,
      tipList: [
        "导入业务类型名称不可为空",
        "导入名称不可为空且名称只能为英文字母",
@@ -117,6 +149,7 @@
        addBtn: false,
        editBtn: false,
        delBtn: false,
        calcHeight: -60,
        column: [
          {
            label: '业务名称',
@@ -146,7 +179,8 @@
        }
      },
      dbClickList: [],
      defaultData: [], // 用于查询恢复原始值
      defaultData: [], // 用于查询恢复原始值,
      editRow: {},
    }
  },
  created() {
@@ -165,11 +199,14 @@
        return;
      }
      if (this.tableRadio === "0") {
        this.editRow.id = "";
        this.$refs.formDialog.visible = true;
        this.$refs.formDialog.getTreeList();
      } else {
        this.$refs.tableDialog.visible = true;
        this.$refs.tableDialog.getDbList();
        this.$refs.tableDialog.getDbList(); // 双击操作下拉接口
        this.$refs.tableDialog.getSearchSelectList(); // 选择表单下拉接口
        this.$refs.tableDialog.getFormSelect(); // 查询模板下拉接口
      }
    },
@@ -185,7 +222,7 @@
        this.treeData = data;
        this.treeLoading = false;
      }).catch(error => {
        loading.close();
        this.treeLoading = false;
      });
    },
@@ -201,6 +238,7 @@
            return item.attributes; // 返回处理后的 attributes
          });
          this.treeData = data;
          this.treeLoading = false;
        });
      } else {
        gridLink().then(res => {
@@ -273,6 +311,7 @@
    // 编辑按钮
    editBtnClick(row) {
      console.log('row', row);
      // 表格
      if (row.viType === 0) {
        const params = {
@@ -291,14 +330,18 @@
            // 更新表单
            this.$refs.tableDialog.form = {
              ...prmItem,
              itemFieldWidthList:prmItem.itemFieldWidthList.map(item => {
                return{
                  ...item,
                  $cellEdit: true,
                }
              }),
              viName: res.data.obj.viName,
              editNodeId: row.id,
              itemOutFieldList: (prmItem.itemOutFieldList || []).map(item => ({id: item})),
              itemOutFieldList: (prmItem.itemOutFieldList || []),
              itemSearchFieldList: (prmItem.itemSearchFieldList || []).map(item => ({id: item})),
              itemKeyFieldList: (prmItem.itemKeyFieldList || []).map(item => ({id: item})),
              searchLabel: prmItem.itemSeniorQueryCols || '',
              searchNumber: prmItem.itemSeniorQueryColsCounts || '1',
              searchSql: prmItem.itemQuerySql || '',
              itemKeyFieldList: (prmItem.itemKeyFieldList || []),
              searchNumber: '1',
              itemFileWidthSelect: (prmItem.itemFieldWidthList && prmItem.itemFieldWidthList.length > 0) ? prmItem.itemFieldWidthList[0].key : '',
              itemWidth: (prmItem.itemFieldWidthList && prmItem.itemFieldWidthList.length > 0) ? prmItem.itemFieldWidthList[0].value : '250'
            };
@@ -307,9 +350,6 @@
            const [width = '0', height = '0'] = (prmItem.itemImgWH || '0,0').split(',');
            this.$refs.tableDialog.itemImgWidth = width;
            this.$refs.tableDialog.itemImgHeight = height;
            // 双击操作获取数据方法
            this.$refs.tableDialog.getDbList();
            // 显示对话框
            this.$refs.tableDialog.visible = true;
@@ -320,7 +360,7 @@
          id: row.id,
          viType: row.viType
        };
        this.editRow = row;
        getPortalVIById(params).then(res => {
          if (res.data.code === 200) {
            const data = res.data.obj.prm.prmItemList;
@@ -336,6 +376,7 @@
            this.$refs.formDialog.getTreeList();
            this.$refs.formDialog.topForm.viName = res.data.obj.viName;
            this.$refs.formDialog.topForm.columnNumber = this.getValueBasedOnInput(res.data.obj.prm.showCols);
            this.$refs.formDialog.topForm.showColumn = res.data.obj.prm.showCols;
            this.$refs.formDialog.visible = true;
          }
@@ -372,12 +413,13 @@
    // 名称查询
    nameSearchHandler() {
      if (!this.topName) {
        this.data = this.defaultData;
        this.getRightPortalVIDatas();
        return;
      }
      const list = this.data.filter(item => item.viName.includes(this.topName.trim()));
      const list = this.defaultData.filter(item => item.viName.includes(this.topName.trim()));
      this.data = list;
      this.page.total = this.data.length;
    },
    // 删除按钮
@@ -397,8 +439,8 @@
      })
    },
    rowDeleteHandler(row){
      deleteByIds({ids:row.id}).then(res => {
    rowDeleteHandler(row) {
      deleteByIds({ids: row.id}).then(res => {
        if (res.data.code === 200) {
          this.$message.success('删除成功');
          this.getRightPortalVIDatas();
@@ -446,6 +488,116 @@
    // 导入
    upLoadClickHandler() {
      this.$refs.upload.visible = true;
    },
    // 克隆
    copyClickHandler() {
      if (this.selectList.length <= 0) {
        this.$message.error('请至少选择一条数据');
        return;
      }
      if (this.selectList.length > 1) {
        this.$message.error('只能选择一条数据');
        return;
      }
      this.cloneVisible = true;
      this.cloneTreeLoading = true;
      getBizTypes().then(res => {
        const data = res.data.data.map(item => {
          this.processChildren(item); // 处理每个节点
          item.attributes.id = item.attributes.id;
          return item.attributes; // 返回处理后的 attributes
        });
        this.cloneTreeData = data;
        this.cloneTreeLoading = false;
      }).catch(error => {
        this.cloneTreeLoading = false;
      });
    },
    // 克隆树点击
    cloneTreeNodeClick(row) {
      console.log(row);
      this.cloneTreeNode = row;
    },
    // 克隆树类型切换
    cloneTreeRadioChange(val) {
      this.cloneTreeLoading = true;
      if (val === "0") {
        getBizTypes().then(res => {
          const data = res.data.data.map(item => {
            this.processChildren(item); // 处理每个节点
            item.attributes.id = item.attributes.id;
            return item.attributes; // 返回处理后的 attributes
          });
          this.cloneTreeData = data;
          this.cloneTreeLoading = false;
        });
      } else {
        gridLink().then(res => {
          const data = res.data.data.map(item => {
            item.id = item.name;
            return item;
          });
          this.cloneTreeData = data;
          this.cloneTreeLoading = false;
        })
      }
    },
    // 查询表格数据详情
    searchDetail() {
      return new Promise((resolve, reject) => {
        const params = {
          id: this.selectList[0].id,
          viType: this.selectList[0].viType
        };
        getPortalVIById(params).then(res => {
          const obj = res.data.obj;
          resolve(obj);
        }).catch(error => {
          reject(error);
        });
      });
    },
    // 克隆保存
    async cloneSaveHandler() {
      if (func.isEmptyObject(this.cloneTreeNode)) {
        this.$message.error('请选择一条数据进行克隆');
        return;
      }
      const obj = await this.searchDetail();
      this.$prompt('请输入克隆文件名称', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
      }).then(({value}) => {
        console.log(obj);
        const params = {
          clonePortalVIDTOList: [
            {
              viName: value,
              typeName: this.cloneTreeRadio === '0' ? this.cloneTreeNode.id : this.cloneTreeNode.name,
              typeFlag: this.cloneTreeRadio,
              oldPortalVIDTO: {...obj}
            }
          ],
        }
        clone(params).then(res => {
          if (res.data.code === 200) {
            this.$message.success('克隆成功');
            this.cloneVisible = false;
          }
        })
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '取消输入'
        });
      });
    }
  }
}