田源
2024-08-23 9e20b9fb77a41cb5b4a6eb6213fc51cab1f0bb91
Source/plt-web/plt-web-ui/src/views/modelingMenu/queryTemplate/linkTypeQuery/index.vue
@@ -3,24 +3,9 @@
    <el-aside>
      <basic-container>
        <div ref="TreeBox" style="height: calc(100vh - 144px);!important;">
          <div class="headerCon">
            <el-button icon="el-icon-plus" plain size="small" type="primary" @click="addClickHandler">创建
            </el-button>
            <el-button icon="el-icon-edit" plain size="small" type="primary" @click="editClickHandler">修改
            </el-button>
            <el-button icon="el-icon-delete" plain size="small" type="danger" @click="delClickHandler">删除
            </el-button>
            <el-button icon="el-icon-download" plain size="small" type="primary" @click="exportClickHandler">导出
            </el-button>
            <el-button icon="el-icon-upload2" plain size="small" type="primary" @click="uploadClickHandler">导入
            </el-button>
            <el-button class="smallBtn" plain size="small" type="primary"
                       @click="checkViewClickHandler">查看使用范围
            </el-button>
          </div>
        <div ref="TreeBox" style="height: calc(100vh - 154px);!important;">
          <!-- 左侧树         -->
          <div style="height:  calc(100vh - 280px);">
          <div style="height:  calc(100vh - 190px);">
            <avue-tree :data="treeData" :option="treeOption" @node-click="nodeClick">
          <span slot-scope="{ node, data }" class="el-tree-node__label">
           <span style="font-size: 15px">
@@ -36,6 +21,16 @@
    <el-main>
      <basic-container>
        <avue-crud  ref="crud"
                    :data="crudData" :option="crudOption" :table-loading="tableLoading" style="margin-top: 10px">
          <template slot="menuLeft" slot-scope="scope">
            <el-button icon="el-icon-plus" size="small" type="primary" @click="addHandler">创建</el-button>
            <el-button icon="el-icon-edit" plain size="small" type="primary" @click="editHandler">修改</el-button>
            <el-button icon="el-icon-delete" plain size="small" type="danger" @click="delHandler">删除</el-button>
            <el-button icon="el-icon-download" plain size="small" type="primary" @click="exportClickHandler">导出</el-button>
            <el-button icon="el-icon-upload2" plain size="small" type="primary" @click="upLoadClickHandler">导入</el-button>
          </template>
        </avue-crud>
      </basic-container>
    </el-main>
@@ -43,8 +38,189 @@
</template>
<script>
import {gridLink} from "@/api/modeling/linkType/api";
import { gridTemplate, saveTemplate, updateTemplate} from "@/api/queryTemplate/queryDefine";
import {deleteLinkTemplate} from "@/api/queryTemplate/linkTypeQuery";
import func from "@/util/func";
import {dateFormat} from "@/util/date";
import basicOption from "@/util/basic-option";
export default {
  name: "index"
  name: "index",
  data() {
    return {
      treeOption: {
        height: 'auto',
        defaultExpandedKeys: ['topNode'],
        menu: false,
        addBtn: false,
        props: {
          label: 'label',
          value: 'oid',
          children: 'children'
        }
      },
      nodeRow: {},
      treeData: [{
        label: '链接类型',
        oid: 'topNode',
        children: []
      }],
      templateForm: '',
      templateData: [],
      form: {
        name: ''
      },
      rules: {
        name: [
          {required: true, message: '请输入查询模板名称', trigger: 'blur'}
        ]
      },
      title: '',
      visible: false,
      tableLoading: false,
      crudData: [],
      crudOption: {
        ...basicOption,
        addBtn: false,
        editBtn: false,
        delBtn: false,
        selection: true,
        menu: false,
        height: "auto",
        calcHeight: -40,
        tip: false,
        column: [{
          label: '查询模板名称',
          prop: 'name'
        }, {
          label: '创建人',
          prop: 'creator'
        }, {
          label: '创建时间',
          prop: 'createTime',
          formatter:function (row, value) {
            return dateFormat(new Date(value))
          }
        }]
      },
      selectionRow: [],
    }
  },
  created() {
    this.getTreeList();
  },
  methods: {
    //树表查询
    getTreeList() {
      const loading = this.$loading({});
      gridLink().then(res => {
        const data = res.data.data.map(item => {
          item.label=item.name;
          return item;
        });
        this.treeData[0].children = data;
        loading.close();
      })
    },
    // 树点击
    nodeClick(row) {
      this.nodeRow = row;
      this.tableLoading = true;
      this.getTemp();
    },
    getTemp() {
      gridTemplate({btmName: this.nodeRow.label, linkFlag: true}).then(res => {
        this.crudData = res.data.data;
        this.tableLoading = false;
      })
    },
    selectHandler(selection, row) {
    },
    changeTemp(data) {
      this.$refs.queryCrud.clearSelection();
      if (data.value != '') {
        let abNames = data.item.abNames.join(',').toLowerCase().split(',')
      }
    },
    //创建
    addHandler() {
      if (func.isEmptyObject(this.nodeRow)) {
        this.$message.error('请选择要添加的节点');
        return;
      }
      this.title = 'add';
      this.visible = true;
      this.$nextTick(() => {
      });
    },
    //修改
    editHandler() {
      if (func.isEmptyObject(this.nodeRow)) {
        this.$message.error('请至少选择一条数据');
        return;
      }
      this.form.name = this.templateForm;
      this.title = 'edit';
      this.visible = true;
      this.$nextTick(() => {
      });
    },
    // 新增编辑保存
    addDialogSavaHandler() {
      this.$refs.form.validate((valid) => {
        const saveFunction = this.title === 'add' ? saveTemplate : updateTemplate;
        if (valid) {
          saveFunction(this.form).then(res => {
            if (res.data.code === 200) {
              this.$message.success(res.data.obj);
              this.addDialogClose();
            }
          })
        } else {
          return false;
        }
      });
    },
    // 新增编辑对话框取消
    addDialogClose() {
      this.form = {
        name: ''
      };
      this.$refs.form.clearValidate();
      this.visible = false;
    },
    //删除
    delHandler() {
      if (func.isEmptyObject(this.nodeRow)) {
        this.$message.error('请选择数据');
        return;
      }
      this.$confirm('您确定要删除所选择的数据吗?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        deleteLinkTemplate({
          name: this.templateForm,
          btmName: this.nodeRow.label,
          linkFlag: false
        }).then(res => {
          if (res.data.code === 200) {
            this.$message.success(res.data.obj);
          }
        })
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消删除'
        });
      });
    }
  }
}
</script>