Selaa lähdekoodia

清表列表>>新增清表节点,未自动关闭弹窗和刷新节点

duy 3 päivää sitten
vanhempi
commit
c4b21636f6
1 muutettua tiedostoa jossa 77 lisäystä ja 73 poistoa
  1. 77 73
      src/views/exctab/excelmodel/excelmodel.vue

+ 77 - 73
src/views/exctab/excelmodel/excelmodel.vue

@@ -3,7 +3,7 @@
     <div class="boxswai" style="width:26%;padding-left:0px;">
       <div class="boxnei" style="display: flex;flex-direction: column;">
         <div class="flex">
-          <el-input size="small" placeholder="输入关键字搜索" clearable @clear="allTreeShow = false" v-model="filterText">
+          <el-input size="small" placeholder="输入关键字搜索" clearable @clear="allTreeShow = false" v-model.trim="filterText">
           </el-input>
           <el-button size="small" class="mg-l-10" @click="treeFilter">搜索</el-button>
         </div>
@@ -46,8 +46,8 @@
             </span>
           </el-tree>
           <el-tree style="display: inline-block;min-width: 100%;" ref="treeall" v-loading="treeloading"
-            :data="allTreeData" :props="defaultProps" @node-click="nodeClick" node-key="id" :expand-on-click-node="false"
-            :filter-node-method="filterNode" v-show="allTreeShow">
+            :data="allTreeData" :props="defaultProps" @node-click="nodeClick" node-key="id"
+            :expand-on-click-node="false" :filter-node-method="filterNode" v-show="allTreeShow">
             <span class="custom-tree-node" slot-scope="{ data ,node }" @mouseover.stop="mouseOver(data)"
               @mouseleave.stop="mouseLeave(data)" style="box-sizing: border-box;padding-right:70px!important;;">
               <div style="width:100%;">
@@ -119,7 +119,8 @@
                 :on-change="uploadcoverfileExcel" ref="file3">
                 <el-button type="primary" size="mini">{{ from.templateExtension ? '重新上传导入模板' : '上传导入模板' }}</el-button>
               </el-upload> -->
-              <el-link v-if="from.templateExtension" class="marleft10 colorblue" @click="delectExcelMSModel">删除</el-link>
+              <el-link v-if="from.templateExtension" class="marleft10 colorblue"
+                @click="delectExcelMSModel">删除</el-link>
               <el-link v-if="from.templateExtension" underline class="marleft10 colorblue"
                 style="text-decoration:underline;" @click="downloadExcelModel()">下载模板</el-link>
             </div>
@@ -132,7 +133,8 @@
               :src="excelSrc"
               style="width:100%;height:100%;"
             ></iframe> -->
-            <div v-if='excelshow' class='qualityManual-container-office' style="width:100%;height:100%;" id="fullscreen_content">
+            <div v-if='excelshow' class='qualityManual-container-office' style="width:100%;height:100%;"
+              id="fullscreen_content">
               <vab-only-office :option='exceloption' />
             </div>
           </div>
@@ -146,7 +148,7 @@
         <el-form ref="excelForm" :model="excelForm" label-width="80px" :rules="rules">
           <div style="display: flex;justify-content: space-between;">
             <el-form-item label="清表名称" style="width: 370px;" size="small" prop="nodeName">
-              <el-input v-model="excelForm.nodeName"></el-input>
+              <el-input v-model.trim="excelForm.nodeName"></el-input>
             </el-form-item>
             <el-form-item label="清表类型" style="width: 370px;" size="small" prop="tabType">
               <el-select v-model="excelForm.tabType" style="width:100%;" placeholder="请选择清表类型">
@@ -161,7 +163,8 @@
             <div class="select">
               <el-select placeholder="请选择WBS模板" style="width: 96%;" size="small" @change="wbsmodelchange"
                 v-model="excelForm.wbsId">
-                <el-option v-for="(val, index) in wbsmodel" :key="index" :label="val.wbsName" :value="val.id"></el-option>
+                <el-option v-for="(val, index) in wbsmodel" :key="index" :label="val.wbsName"
+                  :value="val.id"></el-option>
               </el-select>
             </div>
             <div class="treecontent" v-loading="loading">
@@ -193,7 +196,7 @@
       </div>
       <div class="btbox">
         <el-button size="mini" @click="handleClose()">取消</el-button>
-        <el-button type="info" style="margin-left: 50px;" size="mini" :loading="saveExcelLoad"
+        <el-button type="primary" style="margin-left: 50px;" size="mini" :loading="saveExcelLoad"
           @click="saveExcel()">确定</el-button>
       </div>
     </el-dialog>
@@ -209,17 +212,17 @@
     <el-dialog title="上传Excel表格" :visible.sync="exceldialogVisible" width="40%" append-to-body
       :before-close="cancleexceldialog">
       <span>
-        <el-upload accept=".xls, .xlsx" class="upload-demo" action="#" :auto-upload="false" :on-change="excelhandleChange"
-          :show-file-list="false" multiple :on-exceed="excelhandleExceed" :file-list="excelfileList"
-          ref="excelmoudelupload">
+        <el-upload accept=".xls, .xlsx" class="upload-demo" action="#" :auto-upload="false"
+          :on-change="excelhandleChange" :show-file-list="false" multiple :on-exceed="excelhandleExceed"
+          :file-list="excelfileList" ref="excelmoudelupload">
           <el-button size="small" type="primary">选择文件</el-button>
           <!-- <div slot="tip" class="el-upload__tip">只能上传jpg/png文件,且不超过500kb</div> -->
         </el-upload>
         <el-table class="down" :data="dataList" border stripe style="width: 100%;margin-top: 20px;">
           <el-table-column label="序号" width="150">
             <template slot-scope="scope">
-              <i class="el-icon-sort-up marleft10 text-hover" @click="upSortFile(scope.row,scope.$index)"></i>
-              <i class="el-icon-sort-down marleft10 text-hover" @click="downSortFile(scope.row,scope.$index)"></i>
+              <i class="el-icon-sort-up marleft10 text-hover" @click="upSortFile(scope.row, scope.$index)"></i>
+              <i class="el-icon-sort-down marleft10 text-hover" @click="downSortFile(scope.row, scope.$index)"></i>
               {{ scope.$index + 1 }}
             </template>
           </el-table-column>
@@ -248,11 +251,11 @@
 import { mapGetters } from "vuex";
 import {
   detailExcel, excelType, tabLazytree, getWbsTypeList, wbstree, selectByNodeTable, Excelmodify, uploadExcel, deleteExcelshu, deleteExcel, deleteExcelmodel, tabLazytreeAll,
-  uploadcoverfileExcel, downExcelFile, downExcelFileModel, exctabSort,batchUploadExcelTab
+  uploadcoverfileExcel, downExcelFile, downExcelFileModel, exctabSort, batchUploadExcelTab
 } from '@/api/exctab/excelmodel';
 import ManualSorting from '@/components/WbsTree/ManualSorting'
 import VabOnlyOffice from '@/components/online-office/index'
-import { log } from '@antv/g2plot/lib/utils';
+// import { log } from '@antv/g2plot/lib/utils';
 import screenfull from "screenfull";
 
 export default {
@@ -367,8 +370,8 @@ export default {
       curTreeData: {},
       defaultExpandKey: [],
       exceldialogVisible: false,
-      isShowTree:true,
-      uploadId:'',
+      isShowTree: true,
+      uploadId: '',
       excelfileList: [],
       dataList: [],
       fileobj: []
@@ -378,10 +381,10 @@ export default {
     ...mapGetters(["userInfo"]),
   },
   methods: {
-    fullPage(){
+    fullPage() {
       console.log('全屏显示');
-        // 判断是否支持
-        if (!screenfull.isEnabled) {
+      // 判断是否支持
+      if (!screenfull.isEnabled) {
         this.$message({
           message: "浏览器不支持全屏",
           type: "warning"
@@ -392,16 +395,16 @@ export default {
       screenfull.request(element);
       // screenfull.toggle();
 
-s
+      s
     },
-    getBaseUrl () {
+    getBaseUrl() {
       const host = window.location.hostname;
       if (host === '192.168.0.109') {
         return 'http://192.168.0.109:8090';
       } else if (host === 'testmanger.hcxxy.com') {
         return 'http://219.151.181.73:8090';
-      }else if(host === '183.247.216.148'){
-         return 'http://183.247.216.148:8090';
+      } else if (host === '183.247.216.148') {
+        return 'http://183.247.216.148:8090';
       }
       return 'http://192.168.0.109:8090'; // 默认值
     },
@@ -416,9 +419,9 @@ s
       this.exceloption.user = { id: this.userInfo.id, name: this.userInfo.user_name }
       // this.exceloption.editUrl = "http://172.31.222.127:8090/blade-manager/exceltab/callbackSave";
       // this.exceloption.editUrl = "http://47.110.251.215:8090/blade-manager/exceltab/callbackSave";
-     // this.exceloption.editUrl = "http://219.151.181.73:8090/blade-manager/exceltab/callbackSave";
-          // this.exceloption.editUrl =  "http://192.168.0.109:8090/blade-manager/exceltab/callbackSave";
-          this.exceloption.editUrl = `${this.getBaseUrl()}/blade-manager/exceltab/callbackSave`;
+      // this.exceloption.editUrl = "http://219.151.181.73:8090/blade-manager/exceltab/callbackSave";
+      // this.exceloption.editUrl =  "http://192.168.0.109:8090/blade-manager/exceltab/callbackSave";
+      this.exceloption.editUrl = `${this.getBaseUrl()}/blade-manager/exceltab/callbackSave`;
       this.exceloption.key = this.from.id + "_" + Math.random() + "";
     },
     //刷新左边树形数据
@@ -623,9 +626,14 @@ s
         } else {
           this.$refs.trees.updateKeyChildren(this.treeNode.id, das)
         }
-        let node = this.$refs.trees.getNode(ids);
-        node.isLeaf = false;
-        node.isLeafByUser = false;
+        const node = this.$refs.trees.getNode(ids);
+        if (node) {
+          node.isLeaf = false;
+          node.isLeafByUser = false;
+        }
+        if (this.filterText) {
+          this.treeFilter(true)
+        }
         this.dialogTap = false
       }
     },
@@ -870,6 +878,7 @@ s
       this.tableData = []//弹框table数据
       this.tableList = []//关联取消关联的数据
       this.dialogTap = false
+      this.$refs.excelForm.resetFields()
     },
     wbsmodelchange(val) {//wbs模板change事件
       if (val) {
@@ -887,8 +896,6 @@ s
       this.tableList = [];
     },
     nodeClickExcel(data) {//wbs树点击事件
-      console.log(this.excelId, "xxxxxxxxx");
-      console.log(this.excelForm.id, "yyyyyyyy");
       this.wbsform.id = data.id
       this.wbsform.wbsType = data.type
       this.wbsform.wbsName = data.nodeName
@@ -938,6 +945,7 @@ s
     },
     saveExcel() {//保存按钮
       this.$refs.excelForm.validate(async (valid) => {
+        console.log("保存按钮", this.tableList);
         if (valid) {
           let linkDataInfo = []
           if (this.tableList.length > 0) {
@@ -980,18 +988,17 @@ s
           } catch (error) {
             console.log(error)
           }
-
           this.saveExcelLoad = false;
         }
       });
     },
     //#endregion
 
-    //搜索树
-    treeFilter() {
+    //搜索树 (isReset) 是否刷新树
+    treeFilter(isReset = false) {
       if (this.filterText) {
         this.allTreeShow = true;
-        if (!this.allTreeData.length) {
+        if (!this.allTreeData.length || isReset) {
           this.treeloading = true;
           tabLazytreeAll({
             modeId: this.$route.params.id,
@@ -1045,15 +1052,11 @@ s
 
       this.$refs.file3.clearFiles();
       this.$forceUpdate()
-
-
-
-
     },
     //上传
     uploadMoudle(data) {
       console.log('上传');
-      this.uploadId=data.id
+      this.uploadId = data.id
       this.curTreeData = data;
       this.exceldialogVisible = true
     },
@@ -1073,56 +1076,56 @@ s
     aumbitexcelmoudel() {
       let formData = new FormData()
       this.dataList.forEach((item) => {
-        formData.append('file', item.raw,item.name)
+        formData.append('file', item.raw, item.name)
       })
-      formData.append('id',this.uploadId)
+      formData.append('id', this.uploadId)
       const loading = this.$loading({
-          lock: true,
-          text: 'Loading',
-          spinner: 'el-icon-loading',
-          background: 'rgba(0, 0, 0, 0.7)'
-        });
-        batchUploadExcelTab(formData).then(() => {
-          this.$message({
-            message: '上传文件成功',
-            type: 'success'
-          })
-          this.exceldialogVisible=false
-          this.refreshTree()
+        lock: true,
+        text: 'Loading',
+        spinner: 'el-icon-loading',
+        background: 'rgba(0, 0, 0, 0.7)'
+      });
+      batchUploadExcelTab(formData).then(() => {
+        this.$message({
+          message: '上传文件成功',
+          type: 'success'
+        })
+        this.exceldialogVisible = false
+        this.refreshTree()
 
-          loading.close();
-        }).catch(() => {
-          loading.close();
-        });
-        this.$refs.excelmoudelupload.clearFiles();
-        this.cancleexceldialog()
+        loading.close();
+      }).catch(() => {
+        loading.close();
+      });
+      this.$refs.excelmoudelupload.clearFiles();
+      this.cancleexceldialog()
 
     },
     //更改上传文件顺序
-    upSortFile(row,index){
-      const data= this.dataList
-      if(index!==0){
+    upSortFile(row, index) {
+      const data = this.dataList
+      if (index !== 0) {
         const tmp = data.splice(index - 1, 1);
         this.dataList.splice(index, 0, tmp[0]);
-      }else{
+      } else {
         this.$message.warning('已经处于置顶,无法上移')
       }
 
     },
-    downSortFile(row,index){
+    downSortFile(row, index) {
       const indexs = index + 1
       const data = this.dataList
       if (indexs !== data.length) {
-          const tmp = data.splice(indexs, 1);
-          this.dataList.splice(index, 0, tmp[0]);
+        const tmp = data.splice(indexs, 1);
+        this.dataList.splice(index, 0, tmp[0]);
       } else {
         this.$message.warning('已经处于置底,无法下移')
       }
     },
-    cancleexceldialog(){
-      this.exceldialogVisible=false
-      this.dataList=[]
-      this.excelfileList=[]
+    cancleexceldialog() {
+      this.exceldialogVisible = false
+      this.dataList = []
+      this.excelfileList = []
     }
   },
   created() {
@@ -1234,7 +1237,8 @@ s
   box-sizing: border-box;
   padding-bottom: 10px;
 }
-.text-hover{
+
+.text-hover {
   cursor: pointer;
   color: #409EFF;
 }