gaoshp
2024-06-02 b46e6d2306515f94bf77c06e8d80ac76267e3ddb
src/views/notification/business.vue
@@ -2,7 +2,7 @@
 * @Author: lzhe lzhe@example.com
 * @Date: 2024-03-26 10:28:33
 * @LastEditors: lzhe lzhe@example.com
 * @LastEditTime: 2024-05-09 18:06:28
 * @LastEditTime: 2024-05-10 12:08:41
 * @FilePath: /smart-web/src/views/master/person/main/index.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
@@ -23,11 +23,11 @@
         <div class="right-content">
            <div class="content-title">
               <span class="ct-span">通知方式</span>
               <el-icon><Setting /></el-icon>
               <el-icon @click="gojob"><Setting /></el-icon>
            </div>
            <el-row class="template-content-box">
               <el-col :span="8" v-for="(item,index) in contentData">
                  <el-checkbox v-model="item.checked" label="选择" size="large" />
                  <el-checkbox v-model="item.checked" label="选择" size="large" @change="checkboxChange($event,index,item)"/>
                  <div class="box-top">
                     <div class="box-top-name">{{item.notifyName}}</div>
                     <div class="box-top-title">{{item.notifyTemplateName}}</div>
@@ -80,6 +80,7 @@
      name: "business",
      data(){
         return {
            businessKey: "",
            isSaveing: false,
            employeeLi: [],
            organizationLi: [],
@@ -111,7 +112,6 @@
      },
      mounted(){
         this.getTreeList();
         this.getbusiness();
         this.getgroupType();
         this.getEmployeeList();
      },
@@ -119,15 +119,49 @@
         ...ElementPlusIconsVue,saveDialog
       },
      methods: {
         gojob() {
            window.open('http://116.63.148.72:8080/xxl-job-admin');
         },
         checkboxChange(e,index,item) {
            var obj = {
               businessKey: item.businessKey,
               notifyType: item.notifyType,
               status: e?"1":"0"
            }
            this.$HTTP.put("/api/blade-notify/business-notify/changeStatus",obj).then(res=> {
               if(res.code == 200) {
                  this.getbusiness();  //刷新列表
               }
            })
         },
         saveSubmit() {
            var empIds = [];
            var orgIds = [];
            this.employeeLi.forEach(item=> {
               empIds.push(item.id);
            })
            this.organizationLi.forEach(item=> {
               orgIds.push(item.id);
            })
            var obj = {
               businessKey: this.businessKey,empIds,orgIds
            }
            this.$HTTP.post("/api/blade-notify/business-notify",obj).then(res=> {
               if(res.code == 200) {
                  this.$message.success("保存成功");
               }
            })
         },
         resetData() {
            this.employeeLi = [];
            this.organizationLi = [];
         },
         radio1Change(val) {
            this.getgroupType(val);
            if(val == 1) {
               this.getgroupType();
            }else if(val == 2) {
               this.getEmployeeList();
            }
         },
         addOrganization() {
            this.isaddOrganization = false;
@@ -194,29 +228,54 @@
            })
         },
         getbusiness() {
            this.$HTTP.get("/api/blade-notify/business-notify?businessKey=maintenance").then(res=> {
            this.$HTTP.get(`/api/blade-notify/business-notify?businessKey=${this.businessKey}`).then(res=> {
               if(res.code == 200) {
                  res.data.businessNotifyDTOList.forEach(item=> {
                     item.checked = (item.status == '0'?false: true);
                  })
                  this.contentData = res.data.businessNotifyDTOList;
                  this.employeeLi = res.data.defaultObject.empList || []; //部门反显
                  this.organizationLi = res.data.defaultObject.orgList || []; //员工反显
                  if(this.organizationLi !=  null ) {
                     this.isaddOrganization = false;
                  }
               }
            })
         },
         handleNodeClick(data) {
            if(data.code) {
               this.lastLevelId = data.id;
               // this.$HTTP.post("/api/blade-cps/workstation-wcs-feedback/page?current=1&size=15",obj).then(res=> {
               //    if(res.code == 200) {
               //       this.searchDataList = res.data.records;
               //    }
               // })
            if(data.businessKey) {
               this.businessKey = data.businessKey;
               this.getbusiness();
            }
         },
         getLastLevelIds(tree) {
            if (tree.length === 0) return ""; // 如果没有根节点,返回空
            const lastLevelIds = [];
            const lastLevelCodes = [];
            function traverseTree(node) {
               if(!node.children) {
                  lastLevelCodes.push(node);
               }
               if (node.children) {
                  node.children.forEach(traverseTree); // 递归遍历子节点
               } else {
                  lastLevelIds.push(node.id);
               }
            }
            // 只遍历第一个根节点
            traverseTree(tree[0]);
            return {lastLevelCodes,lastLevelId:lastLevelIds[0]}; // 返回lastLevelCodes:没有code的数组。lastLevelId:有code的第一个id
         },
         getTreeList() {
            this.$HTTP.get("/api/blade-notify/business-notify/tree").then(res=> {
               if(res.code == 200) {
                  this.tableData = res.data;
                  this.lastLevelId = this.getLastLevelIds(this.tableData).lastLevelId;
                  this.$nextTick(()=>{
                     this.$refs.treeRef.setCurrentKey(this.lastLevelId);  //第一个节点的第一个子节点最后一级默认选中
                  })
                  this.businessKey = this.getLastLevelIds(this.tableData).lastLevelCodes[0].businessKey;
                  this.getbusiness();
               }
            })
         },
@@ -284,7 +343,7 @@
   justify-content: space-between;
   margin: 24px 0 0 0;
    padding: 0 20px 0 10px;
    border-left: 6px solid #3b8e8e;
    border-left: 6px solid #409eff;
}
.ct-span {
   color: #101010;
@@ -345,9 +404,9 @@
}
.tagItem {
   margin: 10px 10px 10px 0;
    background-color: #3b8e8e;
    background-color: #409eff;
    color: #fff;
    border-color: #3b8e8e;
    border-color: #409eff;
    display: inline-block;
    font-size: 12px;
    padding: 4px 10px;