wangting
2024-09-06 db252fda6a2d5c806ada7f7a95a11e09d1a9f657
Source/plt-web/plt-web-ui/src/views/modelingMenu/queryTemplate/businessTypeQuery/formDialog.vue
@@ -43,11 +43,11 @@
      <el-container style="margin-top: 10px;">
        <el-aside style="width:350px">
          <fieldset>
            <legend>&nbsp;链接类型候选条件&nbsp;</legend>
            <legend>&nbsp;候选条件&nbsp;</legend>
            <div>
              查询模板定义
              <avue-select @change="linkQueryDefineChange" class="el-input--small" v-model="linkQueryDefineForm" placeholder="请选择内容" type="tree" :dic="linkQueryDefineDic" style="width:240px"></avue-select>
              <avue-tree style="height: 265px" :data="linkTreeData" :option="treeOption"  @node-drag-start="handleDragStart">
              <avue-select @change="businessQueryDefineChange" class="el-input--small" v-model="businessQueryDefineForm" placeholder="请选择内容" type="tree" :dic="businessQueryDefineDic" style="width: 240px;"></avue-select>
              <avue-tree style="height: 265px" :data="businessTreeData" :option="treeOption"  @node-drag-start="handleDragStart" @node-drag-end="handleDragEnd">
              </avue-tree>
            </div>
          </fieldset>
@@ -63,17 +63,6 @@
            ></form-query-dialog>
          </fieldset>
        </el-main>
        <el-aside style="width:350px">
          <fieldset>
            <legend>&nbsp;业务类型候选条件&nbsp;</legend>
            <div>
              查询模板定义
              <avue-select @change="businessQueryDefineChange" class="el-input--small" v-model="businessQueryDefineForm" placeholder="请选择内容" type="tree" :dic="businessQueryDefineDic" style="width: 240px;"></avue-select>
              <avue-tree style="height: 265px" :data="businessTreeData" :option="treeOption"  @node-drag-start="handleDragStart">
              </avue-tree>
            </div>
          </fieldset>
        </el-aside>
      </el-container>
    </div>
    <div class="dialog-footer avue-dialog__footer">
@@ -84,8 +73,7 @@
</template>
<script>
import {getAllOrderbyAttributeByLink} from "@/api/modeling/linkType/api";
import {linkSave} from "@/api/queryTemplate/linkTypeQuery";
import {linkSave,getBizTypeQTDs} from "@/api/queryTemplate/businessTypeQuery";
import basicOption from "@/util/basic-option";
import {queryTemplateListByAttr} from "@/api/queryTemplate/queryDefine";
import formQueryDialog from "./formQueryDialog.vue";
@@ -138,7 +126,14 @@
          prop: 'orderField'
        }, {
          label: '排序方式',
          prop: 'orderMode'
          prop: 'orderMode',
          formatter:function (row, value) {
            if (row.orderMode == 'ASC') {
              return '升序'
            }else{
              return '降序'
            }
          }
        }, {
          label: '优先级',
          prop: 'level'
@@ -210,10 +205,6 @@
          return true;
        },
      },
      linkQueryDefineForm:'',//链接类型查询模板定义选中值
      linkQueryDefineDic:[],//链接类型查询模板定义下拉数据
      //链接类型查询模板定义选中项属性
      linkTreeData: [],
      businessQueryDefineForm:'',//业务类型查询模板定义选中值
      businessQueryDefineDic:[],//业务类型查询模板定义下拉数据
      //业务类型查询模板定义选中项属性
@@ -222,56 +213,9 @@
      queryTree:{},
      //普通查询条件
      queryCondition:[],
    };
  },
  watch: {
    //方向
    'form.direction': {
      handler(val) {
        if(val=='positive'){
          //正向
          const dicData=this.treeData.btmItemsTo.map(item=>{
            return {
              label: item,
              value: item
            }
          })
          dicData.push({
            label: '所有类型',
            value: '*'
          })
          this.$refs.form.updateDic('btmType', dicData);
          this.form.btmType=dicData[0].value
          this.getAllAttr();
        }else if(val=='opposite'){
          //反向
          const dicData=this.treeData.btmItemsFrom.map(item=>{
            return {
              label: item,
              value: item
            }
          })
          dicData.push({
            label: '所有类型',
            value: '*'
          })
          this.$refs.form.updateDic('btmType', dicData);
          this.form.btmType=dicData[0].value
          this.getAllAttr();
        }
      },
      immediate: true,
    },
    //业务类型
    'form.btmType': {
      handler(val) {
        if(val && val!='*'){
          this.getTemp(val,false);
        }
      },
      immediate: true,
    }
  },
  methods: {
    openDialog(btmName, title, mode, data) {
@@ -283,6 +227,7 @@
      if (data.selectData) {
        this.selectData = data.selectData;
        this.form.qtName = this.selectData.qtName;
        this.form.level = this.selectData.queryTemplate.level;
        if (data.selectData.queryTemplate.orderInfoList && data.selectData.queryTemplate.orderInfoList.length > 0) {
          this.orderInfoList = JSON.parse(JSON.stringify(data.selectData.queryTemplate.orderInfoList));//已有排序
        }
@@ -299,7 +244,8 @@
        };
      }
      this.dialog.showDialog = true;
      this.getTemp(data.treeData.label, true)
      this.getTemp(data.treeData.label)
      this.getAllAttr();
    },
    cancelDialog() {
      this.dialog.loading = false;
@@ -327,6 +273,8 @@
              this.$message.success("保存成功");
              this.cancelDialog();
              this.$emit("refresh");
            }else {
              this.$refs.form.clearValidate();
            }
          });
        } else {
@@ -340,10 +288,9 @@
        qtName: this.form.qtName,
        levelFlag: this.form.levelFlag,
        queryTemplate: {
          btmType: this.form.btmType,
          clauseList: ['*'],
          direction: this.form.direction,
          id: this.form.qtName,
          level: this.form.level,
          linkType: this.form.btmName,
          orderInfoList: this.orderInfoList,
          recReturnMode: 1,//递归返回数据模式:1:RECRETURNMODE_FLAT, 2:RECRETURNMODE_FILTER
@@ -394,6 +341,7 @@
    },
    // 行删除
    rowDeleteHandler(data) {
      debugger;
      this.orderInfoList.splice(data.index,1);
      this.orderFieldList.unshift({
        id: data.row.orderField
@@ -402,16 +350,14 @@
    },
    //获取排序设置中所有排序字段
    getAllAttr() {
      getAllOrderbyAttributeByLink({
        name: this.treeData.label,
        btmType: this.form.btmType,
        direction: this.form.direction
      getBizTypeQTDs({
        btmName: this.treeData.label
      }).then(res => {
        const orderInfoStr = JSON.stringify(this.orderInfoList);
        const dicData = [];
        res.data.data.forEach(item => {
          if (orderInfoStr.indexOf('"orderField":"' + item + '"') == -1) {
            dicData.push({id: item});
          if (orderInfoStr.indexOf('"orderField":"' + item.id + '"') == -1) {
            dicData.push(item);
          }
        })
        this.tableFormOption.column[0].dicData=dicData;
@@ -442,38 +388,18 @@
      })
    },
    //获取查询模板定义下拉
    getTemp(btmName,linkFlag) {
    getTemp(btmName) {
      if (btmName) {
        queryTemplateListByAttr({btmName: btmName, linkFlag: linkFlag,direction:this.form.direction}).then(res => {
        queryTemplateListByAttr({btmName: btmName}).then(res => {
          const data = res.data.data.map(item => {
            item.label = item.name + '-' + (item.linkTypeName || item.btmName);
            item.value = item.name;
            return item;
          });
          if(linkFlag){
            this.linkQueryDefineDic=data
            data.length>0 && (this.linkQueryDefineForm=data[0].value);
          }else {
            this.businessQueryDefineDic=data;
            data.length>0 && (this.businessQueryDefineForm= data[0].value);
          }
        })
      }
    },
    linkQueryDefineChange(data) {
      if (data.value) {
        const childData = data.item.attrs.map(item => {
          return {
            label: item.name,
            value: item.name,
            atttributes:item
          };
        });
        this.linkTreeData = [{
          label: data.value,
          value: data.value,
          children: childData
        }]
      }
    },
    businessQueryDefineChange(data) {
@@ -496,7 +422,15 @@
    handleDragStart(node, ev) {
      // 使用 setData 方法设置数据
      ev.dataTransfer.setData('item', JSON.stringify(node.data));
      if(this.form.levelFlag==1){
        this.$refs.formQuery.$refs.tree.$emit('tree-node-drag-start', ev,{node:this.$refs.formQuery.initItem(node)});
      }
    },
    handleDragEnd(draggingNode,endNode,position,ev){
      if(this.form.levelFlag==1) {
        this.$refs.formQuery.$refs.tree.$emit('tree-node-drag-end', ev);
      }
    }
  },
}
</script>