ludc
2024-08-28 1fa18d4c61c6facb52fe09168dcbf6b46de4aafe
Source/plt-web/plt-web-ui/src/views/modelingMenu/modeling/businessType/index.vue
@@ -451,7 +451,7 @@
        </span>
    </el-dialog>
    <!-- 一致性检查 -->
    <!-- 查看索引 -->
    <el-dialog
      v-dialogDrag
      :visible.sync="indexVisible"
@@ -459,8 +459,61 @@
      class="avue-dialog"
      title="索引信息"
      width="60%"
      @close="indexDialogClose"
    >
      <div v-loading="indexLoading" style="display: flex;height: 500px;width: 100%">
        <basic-container>
          <div style="height: 390px">
            <el-button plain size="mini" style="margin-bottom: 5px" type="danger"
                       @click="deleteIndexLeftTreeClickHandler">删除索引
            </el-button>
            <avue-tree
              :data="indexLeftData"
              :option="indexLeftOption"
              @node-click="indexLeftNodeClick"></avue-tree>
          </div>
        </basic-container>
        <div style="padding: 20px;width: 75%">
          <div>
            <el-form ref="form" :model="indexForm" label-width="90px" size="mini">
              <el-form-item label="索引名称:">
                <el-input v-model="indexForm.name" :readOnly="indexFormRead"></el-input>
              </el-form-item>
              <el-form-item label="描述:">
                <el-input v-model="indexForm.desc"></el-input>
              </el-form-item>
            </el-form>
            <div style="display: flex;justify-content: center">
              <el-button plain size="mini" type="success" @click="rightIndexAddClick">增加</el-button>
              <el-button plain size="mini" type="danger">删除</el-button>
            </div>
          </div>
          <avue-crud
            :data="indexData"
            :option="indexOption"></avue-crud>
        </div>
      </div>
      <el-dialog
        v-dialogDrag
        :visible.sync="indexAttrVisible"
        append-to-body="true"
        class="avue-dialog"
        title="属性信息"
        width="60%"
      >
        <avue-crud
          :data="indexAttrData"
          :option="indexAttrOption"
          @row-click="indexAttrRowClick"></avue-crud>
        <span slot="footer" class="dialog-footer">
         <el-button @click="indexAttrVisible = false">取 消</el-button>
         <el-button type="primary" @click="indexAttrClickAddHandler">确 定</el-button>
        </span>
      </el-dialog>
      <span slot="footer" class="dialog-footer">
         <el-button @click="indexDialogClose">取 消</el-button>
         <el-button type="primary" @click="indexClickAddHandler">保 存</el-button>
        </span>
    </el-dialog>
  </el-container>
@@ -478,7 +531,10 @@
  getUsedBtmLinkList,
  checkBtmConsistency,
  executeRepair,
  getIndexByCondition
  getIndexByCondition,
  delIndex,
  getAllAttributesByBtmId,
  addIndex
} from "@/api/modeling/businessType/api"
import {gridAttribute} from "@/api/modeling/attributePool/api";
import func from "@/util/func";
@@ -489,7 +545,79 @@
  name: "index",
  data() {
    return {
      indexVisible:false,
      indexLoading: false,
      indexFormRead: false,
      indexAttrRow: {},
      indexAttrOption: {
        ...basicOption,
        height: 380,
        highlightCurrentRow: true,
        addBtn: false,
        refreshBtn: false,
        editBtn: false,
        delBtn: false,
        selection: false,
        menu: false,
        column: [
          {
            label: '属性信息',
            prop: 'id',
            sortable: true,
          },
        ]
      },
      indexAttrData: [],
      indexData: [],
      indexAttrVisible: false,
      indexLeftNodeRow: {},
      indexForm: {
        name: '',
        desc: ''
      },
      indexLeftData: [],
      indexLeftOption: {
        height: 'auto',
        menu: false,
        addBtn: false,
        props: {
          label: 'name',
          value: 'id',
          children: 'children',
        },
      },
      indexOption: {
        ...basicOption,
        height: 280,
        addBtn: false,
        refreshBtn: false,
        editBtn: false,
        delBtn: false,
        selection: false,
        menu: false,
        column: [
          {
            label: '业务类型名称',
            prop: 'typeName',
            sortable: true,
          },
          {
            label: '索引名称',
            prop: 'indexName',
            sortable: true,
          },
          {
            label: '属性名称',
            prop: 'attrNames',
            sortable: true,
          },
          {
            label: '描述',
            prop: 'desc',
            sortable: true,
          },
        ]
      },
      indexVisible: false,
      conDefaultCheckData: [], // 保留上个接口返回的数据
      conCheckLoading: false,
      conCheckOption: {
@@ -1305,9 +1433,9 @@
        if (res.data.code === 200) {
          this.checkViewVisible = true;
          const data = res.data.data.map(item => {
            return{
              name:this.nodeRow.id,
              source:item
            return {
              name: this.nodeRow.id,
              source: item
            }
          });
          this.checkViewData = data;
@@ -1340,12 +1468,14 @@
    },
    // 一致性检查按钮点击
    checkClickHandler(){
      checkBtmConsistency().then(res =>{
        if(res && res.data && res.data.data){
    checkClickHandler() {
      this.createViewLoading = true;
      checkBtmConsistency().then(res => {
        this.createViewLoading = false;
        if (res && res.data && res.data.data) {
          this.conCheckVisible = true;
          this.conCheckLoading = true;
          if(res.data.code === 200){
          if (res.data.code === 200) {
            const data = res.data.data[0];
            this.conDefaultCheckData = data; // 保留一份原始数据
            this.conCheckLoading = false;
@@ -1374,7 +1504,7 @@
            })
            this.conCheckData = outputData;
          }
        }else {
        } else {
          this.$message.success(res.data.msg);
        }
      })
@@ -1395,17 +1525,130 @@
    },
    // 创建索引按钮点击
    indexClickHandler(){
      if(func.isEmptyObject(this.nodeRow)){
    indexClickHandler() {
      if (func.isEmptyObject(this.nodeRow)) {
        this.$message.error('请至少选择一条数据');
        return;
      }
      this.getLeftIndex();
      this.indexVisible = true;
    },
    // 左侧树更新
    getLeftIndex() {
      const params = {
        "conditionMap[typename]":this.nodeRow.id
        "conditionMap[typename]": this.nodeRow.id
      }
      getIndexByCondition(params).then(res => {
        console.log(res);
        if (res.data.code === 200) {
          const data = res.data.data.map(item => {
            return {
              indexName: item.indexName,
              name: `${item.indexName} ${item.attrNames}`,
              id: item.oid
            }
          })
          this.indexLeftData = data;
        }
      })
    },
    // 索引左侧树点击
    indexLeftNodeClick(row) {
      this.indexLeftNodeRow = row;
    },
    // 删除左侧树索引
    deleteIndexLeftTreeClickHandler() {
      if (func.isEmptyObject(this.indexLeftNodeRow)) {
        this.$message.error('请选择一条数据进行删除');
        return;
      }
      const params = {
        btmName: this.nodeRow.id,
        indexName: this.indexLeftNodeRow.indexName
      };
      delIndex(params).then(res => {
        if (res.data.code === 200) {
          this.$message.success('删除索引成功');
          this.getLeftIndex();
        }
      })
    },
    //右侧表格添加属性
    indexAttrClickAddHandler() {
      if (func.isEmptyObject(this.indexAttrRow)) {
        this.$message.error('请至少选择一条数据');
        return;
      }
      this.indexData.push(
        {
          typeName: this.nodeRow.id,
          attrNames: this.indexAttrRow.id,
          indexName: this.indexForm.name,
          desc: this.indexForm.desc
        }
      )
      this.indexFormRead = true;
      this.indexAttrVisible = false;
    },
    // 右侧属性表格行点击
    indexAttrRowClick(row) {
      this.indexAttrRow = row;
    },
    // 右侧表格增加
    rightIndexAddClick() {
      if (!this.indexForm.name) {
        this.$message.error('请输入索引名称');
        return;
      }
      // 检查是否为英文字符
      const englishRegex = /^[A-Za-z]+$/;
      if (!englishRegex.test(this.indexForm.name)) {
        this.$message.error('索引名称只能包含英文字符');
        return;
      }
      this.indexLoading = true;
      getAllAttributesByBtmId({btmId: this.nodeRow.id}).then(res => {
        if (res.data.code === 200) {
          const data = res.data.data.map(item => {
            return {
              id: item.id
            }
          })
          this.indexAttrData = data;
        }
        this.indexLoading = false;
        this.indexAttrVisible = true;
      })
    },
    // 创建保存索引
    indexClickAddHandler() {
      const params = {
        typeName: this.nodeRow.id,
        attrNames: this.indexData.map(item => item.attrNames).join(','),
        indexName: this.indexForm.name,
      }
      addIndex([params]).then(res => {
        console.log(res)
        this.$message.success('创建成功');
        this.indexDialogClose();
      }).catch(err => {
        this.indexDialogClose();
      })
    },
    // 索引对话框取消
    indexDialogClose() {
      this.indexFormRead = false;
      this.indexForm = {};
      this.indexData = [];
      this.indexVisible = false;
    }
  }
}