田源
2024-11-01 8c107924ebc49105fa81f13f972f1710b42c1503
Source/plt-web/plt-web-ui/src/views/systemModel/mangeModel/index.vue
@@ -1,9 +1,10 @@
<template>
  <el-container>
  <el-container v-loading="createdLoading">
    <el-aside>
      <basic-container>
        <div style="max-height: calc(100vh - 170px);overflow: auto">
          <avue-tree :key="refresh" ref="tree" :data="treeData" :option="treeOption" @node-click="nodeClick">
        <div style="max-height: calc(100vh - 150px);overflow: auto">
          <avue-tree :key="refresh" ref="tree" :data="treeData" :option="treeOption" node-key="id"
                     @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>
@@ -17,38 +18,96 @@
    <el-main>
      <basic-container>
        <el-form ref="form" :model="form" label-width="85px" style="height: 79vh">
        <div v-if="form.childType && form.childType !== 0 && !addStatus && !editStatus" class="btnBox">
          <el-button :disabled="mangeShowBtn ? false : !childTypeBtn" icon="el-icon-plus" plain
                     size="small"
                     type="primary" @click="addClickHandler">增加
          </el-button>
          <el-button :disabled="mangeShowBtn" icon="el-icon-edit" plain size="small" type="primary"
                     @click="editClickHandler">修改
          </el-button>
          <el-button :disabled="mangeShowBtn" icon="el-icon-close" plain size="small" type="danger"
                     @click="delClickHandler">删除
          </el-button>
          <el-button :disabled="mangeShowBtn ? true : childTypeBtn" icon="el-icon-circle-plus-outline" plain
                     size="small"
                     type="primary" @click="addMethodsClickHandler">增加操作类型
          </el-button>
          <el-button v-if="this.form.childType ? mangeShowBtn :true" icon="el-icon-circle-close" plain size="small"
                     type="danger"
                     @click="addClickHandler">删除非系统模块
          </el-button>
          <el-button v-if="this.form.childType ? mangeShowBtn :true" icon="el-icon-circle-close" plain size="small"
                     type="danger"
                     @click="addClickHandler">删除业务模块
          </el-button>
          <el-button :disabled="!mangeShowBtn" icon="el-icon-upload2" plain size="small" type="primary"
                     @click="upLoadClickHandler">导入
          </el-button>
          <el-button :disabled="!mangeShowBtn" 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="sqlClickExportClick">导出sql
          </el-button>
        </div>
        <div v-else-if="form.childType && form.childType !== 0 &&(addStatus || editStatus)" class="btnBox">
          <el-button v-if="addStatus" icon="el-icon-check" plain size="small"
                     type="success" @click="addSaveClickHandler">保存
          </el-button>
          <el-button v-if="editStatus" icon="el-icon-check" plain size="small"
                     type="success" @click="editSaveClickHandler">保存
          </el-button>
          <el-button icon="el-icon-close" plain size="small"
                     type="danger" @click="addStatus=false;editStatus=false;">取消
          </el-button>
        </div>
        <div v-if="form.childType === 0" class="btnBox">
          <el-button icon="el-icon-edit" plain size="small" type="primary" @click="updataAliasClickHandler">修改别名
          </el-button>
          <el-button icon="el-icon-close" plain size="small" type="danger" @click="deleteOperationClickHandler">删除
          </el-button>
        </div>
        <el-form ref="form" :model="form" label-width="85px" style="max-height: calc(100vh - 200px);overflow: auto;">
          <span v-if="form.childType !== 0">
            <el-form-item label="模块名:">
            <el-input v-model="form.name" placeholder="请输入模块名"></el-input>
            <el-input v-model="form.name" :disabled="!editStatus && !addStatus" placeholder="请输入模块名"></el-input>
          </el-form-item>
          <el-form-item label="模块别名:">
            <el-input v-model="form.alias" placeholder="模块别名用来记录日志使用"></el-input>
            <el-input v-model="form.alias" :disabled="!editStatus && !addStatus" placeholder="模块别名用来记录日志使用"></el-input>
          </el-form-item>
                <el-form-item label="C/S:">
            <el-input v-model="form.pathC" :rows="3" placeholder="请输入C/S路径" type="textarea"></el-input>
            <el-form-item label="C/S:">
            <el-input v-model="form.pathC" :disabled="!editStatus && !addStatus" :rows="2" placeholder="请输入C/S路径"
                      type="textarea"></el-input>
          </el-form-item>
          <el-form-item label="B/S:">
            <el-input v-model="form.path" :rows="3" placeholder="请输入B/S路径" type="textarea"></el-input>
            <el-input v-model="form.path" :disabled="!editStatus && !addStatus" :rows="2" placeholder="请输入B/S路径"
                      type="textarea"></el-input>
          </el-form-item>
          <el-form-item label=".NET:">
            <el-input v-model="form.resourceDotNet" :rows="3" placeholder="请输入.NET" type="textarea"></el-input>
            <el-input v-model="form.resourceDotNet" :disabled="!editStatus && !addStatus" :rows="2"
                      placeholder="请输入.NET" type="textarea"></el-input>
          </el-form-item>
          <el-form-item label="Mobile:">
            <el-input v-model="form.resourceMobile" :rows="3" placeholder="请输入Mobile" type="textarea"></el-input>
            <el-input v-model="form.resourceMobile" :disabled="!editStatus && !addStatus" :rows="2"
                      placeholder="请输入Mobile" type="textarea"></el-input>
          </el-form-item>
          <el-form-item label="序号:">
            <el-input v-model="form.sort" placeholder="数字,描述该模块在其父模块下的显示顺序"></el-input>
            <el-input v-model="form.sort" :disabled="!editStatus && !addStatus"
                      placeholder="数字,描述该模块在其父模块下的显示顺序"></el-input>
          </el-form-item>
          <el-form-item label="简图:">
            <el-input v-model="form.source"></el-input>
          <el-form-item label="图标:">
<!--            <el-input v-model="form.source" :disabled="!editStatus && !addStatus"></el-input>-->
             <avue-input-icon v-model="form.source" :disabled="!editStatus && !addStatus" :icon-list="iconList" placeholder="请选择图标">
             </avue-input-icon>
          </el-form-item>
          <el-form-item label="描述:">
            <el-input v-model="form.remark" :rows="3" placeholder="请输入描述" type="textarea"></el-input>
            <el-input v-model="form.remark" :disabled="!editStatus && !addStatus" :rows="3" placeholder="请输入描述"
                      type="textarea"></el-input>
          </el-form-item>
          <el-form-item label="是否有效:">
            <el-switch
              v-model="form.isValid"
              :disabled="!editStatus && !addStatus"
              active-color="#13ce66"
              inactive-color="#ff4949">
            </el-switch>
@@ -81,50 +140,6 @@
          </el-form-item>
          </span>
        </el-form>
        <div v-if="form.childType && form.childType !== 0" class="btnBox">
          <el-button v-if="!addStatus" :disabled="mangeShowBtn ? false : !childTypeBtn" icon="el-icon-plus" plain
                     size="small"
                     type="primary" @click="addClickHandler">增加
          </el-button>
          <el-button v-if="addStatus" icon="el-icon-check" plain size="small"
                     type="success" @click="addSaveClickHandler">保存
          </el-button>
          <el-button v-if="!editStatus" :disabled="mangeShowBtn" icon="el-icon-edit" plain size="small" type="primary"
                     @click="editClickHandler">修改
          </el-button>
          <el-button v-if="editStatus" icon="el-icon-check" plain size="small"
                     type="success" @click="editSaveClickHandler">保存
          </el-button>
          <el-button :disabled="mangeShowBtn" icon="el-icon-close" plain size="small" type="danger"
                     @click="delClickHandler">删除
          </el-button>
          <el-button :disabled="mangeShowBtn ? true : childTypeBtn" icon="el-icon-circle-plus-outline" plain
                     size="small"
                     type="primary" @click="addMethodsClickHandler">增加操作类型
          </el-button>
          <el-button v-if="this.form.childType ? mangeShowBtn :true" icon="el-icon-circle-close" plain size="small"
                     type="danger"
                     @click="addClickHandler">删除非系统模块
          </el-button>
          <el-button v-if="this.form.childType ? mangeShowBtn :true" icon="el-icon-circle-close" plain size="small"
                     type="danger"
                     @click="addClickHandler">删除业务模块
          </el-button>
          <el-button :disabled="!mangeShowBtn" icon="el-icon-upload2" plain size="small" type="primary"
                     @click="upLoadClickHandler">导入
          </el-button>
          <el-button :disabled="!mangeShowBtn" 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="sqlClickExportClick">导出sql
          </el-button>
        </div>
        <div v-if="form.childType === 0" class="btnBox">
          <el-button icon="el-icon-edit" plain size="small" type="primary">修改别名
          </el-button>
          <el-button icon="el-icon-close" plain size="small" type="danger">删除
          </el-button>
        </div>
      </basic-container>
    </el-main>
    <el-dialog
@@ -133,7 +148,7 @@
      append-to-body="true"
      class="avue-dialog"
      title="操作分类"
      width="60%"
      width="500px"
    >
      <avue-crud
        ref="methodsCrud"
@@ -142,13 +157,15 @@
        :table-loading="methodsLoading"
        @row-click="rowMethodsClickHandler"
        @selection-change="selectMethodsChange">
      </avue-crud>
      <span slot="footer" class="dialog-footer">
         <el-button @click="methodsVisble = false">取 消</el-button>
         <el-button type="primary" @click="methodsSaveClickHandler">保 存</el-button>
         <el-button @click="methodsVisble = false">取 消</el-button>
        </span>
    </el-dialog>
    <!--导入    -->
    <upload-file ref="upload" :fileType="upFileType" :fileUrl="fileUrl" :tipList="tipList" fileName="files" title="导入"
                 @updata="resetFormValue"></upload-file>
  </el-container>
</template>
@@ -160,15 +177,24 @@
  updateModel,
  delModule,
  exportFunctionSql,
  addOperationType
  addOperationType,
  exportModule,
  updateAlias,
  delFuncOperation
} from "@/api/systemModel/mangeModel/api"
import func from "@/util/func";
import basicOption from "@/util/basic-option";
import iconList from "@/config/iconList";
export default {
  name: "index",
  data() {
    return {
      iconList: iconList,
      tipList: [],
      upFileType: ['xls', 'xlsx'],
      fileUrl: 'api/hmSysModConfigController/importModule',
      createdLoading: false,
      lastIndex: null,
      methodsList: [],
      methodsData: [],
@@ -177,6 +203,7 @@
        addBtn: false,
        menu: false,
        height: 500,
        header: false,
        column: [
          {
            label: '操作分类',
@@ -192,6 +219,7 @@
      addStatus: false,
      editStatus: false,
      nodeRow: {},
      currentClickNode: null,
      form: {},
      treeData: [],
      treeOption: {
@@ -245,27 +273,30 @@
  },
  methods: {
    // 树行点击
    nodeClick(row) {
    nodeClick(row, node) {
      console.log(row.childType);
      this.form = {...row};
      this.nodeRow = {...row};
      this.currentClickNode = node;
      this.addStatus = false;
      this.editStatus = false;
    },
    // 新增按钮
    addClickHandler() {
      this.resetFormValue();
      // this.resetFormValue();
      this.defalutName.forEach(key => {
        this.form[key] = null;
      })
      this.form.isValid = false;
      this.addStatus = true;
      this.editStatus = false;
    },
    // 清空表单绑定值
    resetFormValue() {
      this.defalutName.forEach(key => {
        this.form[key] = null;
      })
      this.form.isValid = false;
      this.form = {};
      this.refresh = Math.random(); // 刷新左侧树
    },
    // 新增保存按钮
@@ -275,23 +306,23 @@
        return
      }
      if (this.form.name.length > 128) {
        this.$message.error('模块名长度超过128!');
        this.$message.error('模块名长度不能超过128!');
        return
      }
      if (this.form.remark && this.form.remark.length > 255) {
        this.$message.error('描述长度超过255!');
        this.$message.error('描述长度不能超过255!');
        return
      }
      if (this.form.resourceDotNet && this.form.resourceDotNet.length > 255) {
        this.$message.error('.NET标识长度不能255!');
        this.$message.error('.NET标识长度不能超过255!');
        return
      }
      if (this.form.pathC && this.form.pathC.length > 255) {
        this.$message.error('C/S标识长度不能255!');
        this.$message.error('C/S标识长度不能超过255!');
        return
      }
      if (this.form.resourceMobile && this.form.resourceMobile.length > 255) {
        this.$message.error('Mobile标识长度不能255!');
        this.$message.error('Mobile标识长度不能超过255!');
        return
      }
      this.form.parentId = this.form.id;
@@ -299,14 +330,15 @@
        if (res.data.code === 200) {
          this.$message.success(res.data.msg);
          this.addStatus = false;
          this.refresh = Math.random(); // 刷新左侧树
          // this.resetFormValue();
          this.form.childType = null;
          this.handleRefreshTree('add')
        }
      })
    },
    // 修改按钮
    editClickHandler() {
      console.log(this.form);
      this.editStatus = true;
      this.addStatus = false;
    },
@@ -342,7 +374,9 @@
        if (res.data.code === 200) {
          this.$message.success(res.data.msg);
          this.editStatus = false;
          this.refresh = Math.random(); // 刷新左侧树
          // this.resetFormValue();
          this.form.childType = null;
          this.handleRefreshTree('edit')
        }
      })
    },
@@ -355,13 +389,11 @@
        type: 'warning'
      }).then(() => {
        delModule(this.form).then(res => {
          console.log(res);
          if (res.data.code === 200) {
            this.$message.success(res.data.msg);
            this.resetFormValue();
            this.handleRefreshTree('del')
            this.addStatus = false;
            this.editStatus = false;
            this.refresh = Math.random(); // 刷新左侧树
          }
        })
      }).catch(() => {
@@ -390,12 +422,14 @@
    // 增加操作类型
    addMethodsClickHandler() {
      this.methodsLoading = true;
      getSysModelTreeMenuByPID({parentId: 'sysOptionNode'}).then(res => {
        if (res.data.code === 200) {
      getSysModelTreeMenuByPID({parentId: 'operateNode'}).then(res => {
        if (res.data.code === 200 && res.data.data.length > 0) {
          this.methodsVisble = true;
          const data = res.data.data[0].children;
          const data = res.data.data;
          this.methodsData = data;
          this.methodsLoading = false;
        } else {
          this.$message.error('未找到可增加的操作类型');
        }
      })
    },
@@ -417,9 +451,8 @@
        if (res.data.code === 200) {
          this.methodsVisble = false;
          this.$message.success(res.data.msg);
          this.refresh = Math.random(); // 刷新左侧树
          this.resetFormValue();
          this.form.childType = null;
          this.handleRefreshTree('add')
        }
      })
    },
@@ -438,6 +471,67 @@
        }
      );
    },
    // 修改别名
    updataAliasClickHandler() {
      const params = {
        id: this.form.id,
        isValid: this.form.isValid,
        alias: this.form.alias
      }
      updateAlias(params).then(res => {
        if (res.data.code === 200) {
          this.$message.success(res.data.msg);
          this.handleRefreshTree('edit')
        }
      })
    },
    // 删除模块下关联的操作类型
    deleteOperationClickHandler() {
      const params = {
        funcId: this.form.funcId,
        operId: this.form.operId
      }
      delFuncOperation(params).then(res => {
        if (res.data.code === 200) {
          this.$message.success(res.data.msg);
          this.handleRefreshTree('del');
        }
      })
    },
    // 导出
    exportClickHandler() {
      this.createdLoading = true;
      exportModule().then(res => {
        func.downloadFileByBlobHandler(res);
        this.createdLoading = false
        this.$message.success('导出成功');
      })
    },
    // 导入
    upLoadClickHandler() {
      this.$refs.upload.visible = true;
    },
    handleRefreshTree(type) {
      //type:add\edit\del
      if (type == "del") {
        this.$refs.tree.remove(this.currentClickNode);
        this.currentClickNode = null;
        this.form = {};
      } else {
        if (this.currentClickNode) {
          let node = this.currentClickNode.parent;
          node.loaded = false;
          node.expand();
          this.$refs.tree.setCurrentNode(this.currentClickNode);
        } else {
          this.refresh = Math.random(); // 刷新左侧树
        }
      }
    }
  }
}
</script>
@@ -451,6 +545,8 @@
.btnBox {
  display: flex;
  justify-content: center;
  justify-content: left;
  margin-bottom: 15px;
}
</style>