Browse Source

元素识别新需求

gangyj 2 years ago
parent
commit
a8b7da5872
2 changed files with 228 additions and 96 deletions
  1. 8 0
      src/api/exctab/excelmodel.js
  2. 220 96
      src/views/exctab/ElementIdentification/index.vue

+ 8 - 0
src/api/exctab/excelmodel.js

@@ -216,3 +216,11 @@ export const exctabcellRemove = (ids) => {
         }
     })
 }
+
+export const exctabcellUpdate = (row) => {
+    return request({
+        url: '/api/blade-manager/exctabcell/update',
+        method: 'post',
+        data: row
+    })
+}

+ 220 - 96
src/views/exctab/ElementIdentification/index.vue

@@ -81,8 +81,10 @@
               </el-col>
               <el-col
                 :span="showLeft?8:12" ref="tablescroll"
-                style="overflow:auto;height:100%;"
-              >
+                style="height:100%;"
+                :style="{'overflow':'auto'}"
+              > 
+              <div class="region">
                 <div class="flexBetween flexItemsC">
                   <div>
                     <el-button
@@ -116,23 +118,23 @@
                   >
                   </el-table-column>
                   <el-table-column
-                    prop="eName"
+                    prop="textInfo"
                     label="元素名称"
                   >
                     <template slot-scope="scope">
                       <el-input
-                        v-model="scope.row.eName"
+                        v-model="scope.row.textInfo"
                         placeholder="请输入内容"
                       ></el-input>
                     </template>
                   </el-table-column>
                   <el-table-column
-                    prop="eType"
+                    prop="textElementType"
                     label="数据类型"
                   >
                     <template slot-scope="scope">
                       <el-select
-                        v-model="scope.row.eType"
+                        v-model="scope.row.textElementType"
                         placeholder="请选择"
                       >
                         <el-option
@@ -146,18 +148,22 @@
                     </template>
                   </el-table-column>
                   <el-table-column
-                    prop="eAllowDeviation"
+                    prop="textDeviation"
                     label="允许偏差值"
                   >
                     <template slot-scope="scope">
                       <el-input
-                        v-model="scope.row.eAllowDeviation"
+                        v-model="scope.row.textDeviation"
                         placeholder="请输入内容"
                       ></el-input>
                     </template>
                   </el-table-column>
-                  <el-table-column label="操作" width="60">
+                  <el-table-column label="操作" width="100">
                     <template slot-scope="scope">
+                      <el-link style="margin-right:16px;"
+                        type="success"
+                        @click="saveELe(scope.row)"
+                      >保存</el-link>
                       <el-link
                         type="danger"
                         @click="deleteTableData(scope.$index)"
@@ -171,6 +177,92 @@
                   @click="establish()"
                   :disabled="from.id==''"
                 >关联WBS并创建元素</el-button> -->
+
+                <el-dialog
+                  title="编辑元素信息"
+                  :visible.sync="editTitleDialog"
+                  width="80%"
+                  :modal-append-to-body='false'
+                  :append-to-body="false"
+                >
+                  <div>
+                    <draggable v-model="titleList">
+                      <div
+                        v-for="(item,key) in titleList"
+                        :key="key"
+                        class="flexBetween flexItemsC title-item"
+                      >
+                        <div>
+                          <span>{{item}}</span>
+                        </div>
+                        <div class="flexItemsC">
+                          <i
+                            @click="listUp(key)"
+                            class="el-icon-top"
+                            :style="{'font-size':'20px','color':key==0 ?'#aaa':'#0A8CD5', 'cursor': key!=0?'pointer':'default'}"
+                          ></i>
+                          <i
+                            @click="listDown(key)"
+                            class="el-icon-bottom marleft5"
+                            :style="{'font-size':'20px','color':key==titleList.length-1?'#aaa':'#0A8CD5', 'cursor':  key!=titleList.length-1?'pointer':'default'}"
+                          ></i>
+                          <i
+                            @click="deleTitle(key)"
+                            class="el-icon-circle-close marleft5"
+                            :style="{'font-size':'20px',
+                            'color':'#ee7049','cursor':'pointer'}"
+                          ></i>
+                        </div>
+                      </div>
+                    </draggable>
+                  </div>
+                  <div style="margin-top:50px;">
+                    <div class="flex jc-sb mg-b-10">
+                      <div class="flex jc-al-c">
+                        <span style="margin-right:10px;">数据类型</span>
+                        <el-select
+                          v-model="titleForm.textElementType"
+                          placeholder="请选择" style="width:130px"
+                        >
+                          <el-option
+                            v-for="item in dataType"
+                            :key="item.dictKey"
+                            :label="item.dictValue"
+                            :value="item.dictKey"
+                          >
+                          </el-option>
+                        </el-select>
+                        <span style="margin:0 10px;">允许偏差值</span>
+                        <el-input
+                          v-model="titleForm.textDeviation"
+                          placeholder="请输入内容" style="width:150px"
+                        ></el-input>
+                      </div>
+                      <div>
+                        <el-button size="medium" type="primary" @click="setTitleText">合成文本</el-button>
+                      </div>
+                    </div>
+                    <el-input type="textarea" rows="5" v-model="titleForm.textInfo"></el-input>
+                  </div>
+                  <el-alert
+                    title="匹配不到右侧元素列表,无法修改到相应名称" v-if="titleIndex < 0"
+                    type="error" :closable="false"
+                    effect="dark" style="margin-top:10px;">
+                  </el-alert>
+                  <span
+                    slot="footer"
+                    class="dialog-footer"
+                  >
+                    <el-button @click="editTitleDialog = false">取 消</el-button>
+                    <el-button
+                      type="primary"
+                      v-throttle='2000'
+                      :disabled="titleIndex < 0"
+                      @click="editTitle()"
+                    >确定修改</el-button>
+                  </span>
+                </el-dialog>
+              </div>
               </el-col>
             </el-row>
           </div>
@@ -346,6 +438,36 @@
                 ></el-input>
               </template>
             </el-table-column>
+            <el-table-column
+              prop="textElementType"
+              label="数据类型"
+            >
+              <template slot-scope="scope">
+                <el-select
+                  v-model="scope.row.textElementType"
+                  placeholder="请选择"
+                >
+                  <el-option
+                    v-for="item in dataType"
+                    :key="item.dictKey"
+                    :label="item.dictValue"
+                    :value="item.dictKey"
+                  >
+                  </el-option>
+                </el-select>
+              </template>
+            </el-table-column>
+            <el-table-column
+              prop="textDeviation"
+              label="允许偏差值"
+            >
+              <template slot-scope="scope">
+                <el-input
+                  v-model="scope.row.textDeviation"
+                  placeholder="请输入内容"
+                ></el-input>
+              </template>
+            </el-table-column>
             <el-table-column
               prop="date"
               align="center"
@@ -376,76 +498,11 @@
         </span>
       </el-dialog>
 
-      <el-dialog
-        title="编辑元素信息"
-        :visible.sync="editTitleDialog"
-        width="60%"
-        append-to-body
-      >
-        <div>
-          <draggable v-model="titleList">
-            <div
-              v-for="(item,key) in titleList"
-              :key="key"
-              class="flexBetween flexItemsC title-item"
-            >
-              <div>
-                <span>{{item}}</span>
-              </div>
-              <div class="flexItemsC">
-                <i
-                  @click="listUp(key)"
-                  class="el-icon-top"
-                  :style="{'font-size':'20px','color':key==0 ?'#aaa':'#0A8CD5', 'cursor': key!=0?'pointer':'default'}"
-                ></i>
-                <i
-                  @click="listDown(key)"
-                  class="el-icon-bottom marleft5"
-                  :style="{'font-size':'20px','color':key==titleList.length-1?'#aaa':'#0A8CD5', 'cursor':  key!=titleList.length-1?'pointer':'default'}"
-                ></i>
-                <i
-                  @click="deleTitle(key)"
-                  class="el-icon-circle-close marleft5"
-                  :style="{'font-size':'20px',
-                  'color':'#ee7049','cursor':'pointer'}"
-                ></i>
-              </div>
-            </div>
-          </draggable>
-        </div>
-        <div style="margin-top:50px;">
-          <div class="flex jc-sb mg-b-10">
-            <div></div>
-            <div>
-              <el-button size="medium" type="primary" @click="setTitleText">合成文本</el-button>
-            </div>
-          </div>
-          <el-input type="textarea" rows="5" v-model="titleText"></el-input>
-        </div>
-        <el-alert
-          title="匹配不到右侧元素列表,无法修改到相应名称" v-if="titleIndex < 0"
-          type="error" :closable="false"
-          effect="dark" style="margin-top:10px;">
-        </el-alert>
-        <span
-          slot="footer"
-          class="dialog-footer"
-        >
-          <el-button @click="editTitleDialog = false">取 消</el-button>
-          <el-button
-            type="primary"
-            v-throttle='2000'
-            :disabled="titleIndex < 0"
-            @click="editTitle()"
-          >确定修改</el-button>
-        </span>
-      </el-dialog>
-
     </div>
   </div>
 </template>
 <script>
-import { tabLazytree, getExcelHtmlCol, excelType, submitExcelRelationWbsTreeAndElement, getWbsTypeList, getLazytree,cancelRelation,saveRelation,searchNodeTables,tabLazytreeAll,exctabcellSave,exctabcellRemove} from "@/api/exctab/excelmodel";
+import { tabLazytree, getExcelHtmlCol, excelType, submitExcelRelationWbsTreeAndElement, getWbsTypeList, getLazytree,cancelRelation,saveRelation,searchNodeTables,tabLazytreeAll,exctabcellSave,exctabcellRemove , exctabcellUpdate} from "@/api/exctab/excelmodel";
 import { dictionarydataType } from "@/api/exctab/editelement";
 import { getColByTabId } from "@/api/manager/AdjustForm";
 import { selectByNodeTable } from "@/api/manager/wbstree";
@@ -521,7 +578,13 @@ export default {
 
       editTitleDialog:false,//编辑标题弹窗
       titleList:[],//标题拆分的列表
-      titleText:'',
+      titleForm:{
+        exctabId:'',
+        id:'',
+        textInfo:'',
+        textElementType:'',
+        textDeviation:'',
+      },
       titleIndex:-1,
     }
   },
@@ -613,8 +676,10 @@ export default {
       console.log(res);
       if (res.code === 200) {
         res.data.forEach((element)=>{
-          element.eName = element.textInfo;
-          element.eType = 1;
+          //element.eName = element.textInfo;
+          if(element.textElementType < 1){
+            element.textElementType = 1;
+          }
         })
         this.tableData = res.data
       }
@@ -969,16 +1034,24 @@ export default {
     },
 
     setTitleText(){
-      this.titleText = this.titleList.join('_');
+      this.titleForm.textInfo = this.titleList.join('_');
     },
 
     editTitle(){
-      this.tableData[this.titleIndex].textInfo = this.titleText;
-      this.tableData[this.titleIndex].eName = this.titleText;
+      exctabcellUpdate(this.titleForm).then(()=>{
+        this.tableData[this.titleIndex].textInfo = this.titleForm.textInfo;
+        //this.tableData[this.titleIndex].eName = this.titleForm.textInfo;
+        this.tableData[this.titleIndex].textElementType = this.titleForm.textElementType;
+        this.tableData[this.titleIndex].textDeviation = this.titleForm.textDeviation;
 
-      //console.log(this.$refs.tablescroll)
-      this.$refs.tablescroll.$el.scrollTop = 120+this.titleIndex*65;
-      this.editTitleDialog = false;
+        //console.log(this.$refs.tablescroll)
+        this.$refs.tablescroll.$el.scrollTop = 120+this.titleIndex*65;
+        this.editTitleDialog = false;
+        this.$message({
+          type: "success",
+          message: "保存成功!"
+        });
+      })
     },
 
     dblBtnClick(e){
@@ -986,20 +1059,43 @@ export default {
       let target = e.target;
       //console.log(target.getAttribute('trindex'))
       if(target.getAttribute('trindex') !== null && target.getAttribute('tdindex')){
-        let tdEle = this.getParentTD(target);
-        if(tdEle){
-          this.editTitleDialog = true;
-          this.titleText = tdEle.getAttribute('title');
-          //console.log(title)
-          this.titleList = this.titleText.split('_');
-          let trtd = target.getAttribute('trindex')+"_"+target.getAttribute('tdindex');
-          for (let i = 0; i < this.tableData.length; i++) {
-            if(this.tableData[i].xys.indexOf(trtd) > -1){
-              this.titleIndex = i;
-              break;
-            }
+        this.titleIndex = -1;
+        this.titleList = [];
+        this.$refs.tablescroll.$el.scrollTop = 0;
+        this.editTitleDialog = true;
+        let trtd = target.getAttribute('trindex')+"_"+target.getAttribute('tdindex');
+        for (let i = 0; i < this.tableData.length; i++) {
+          if(this.tableData[i].xys.indexOf(trtd) > -1){
+            this.titleIndex = i;
+            break;
           }
         }
+        if(this.titleIndex > -1){
+          this.titleForm.textInfo = this.tableData[this.titleIndex].textInfo;
+          this.titleForm.textElementType = this.tableData[this.titleIndex].textElementType;
+          this.titleForm.textDeviation = this.tableData[this.titleIndex].textDeviation;
+          this.titleForm.exctabId = this.tableData[this.titleIndex].exctabId;
+          this.titleForm.id = this.tableData[this.titleIndex].id;
+        }
+        
+
+        // let tdEle = this.getParentTD(target);
+        // if(tdEle){
+        //   this.$refs.tablescroll.$el.scrollTop = 0;
+        //   this.editTitleDialog = true;
+        //   this.titleForm.textInfo = tdEle.getAttribute('title');
+        //   //console.log(title)
+        //   this.titleList = this.titleForm.textInfo.split('_');
+        //   let trtd = target.getAttribute('trindex')+"_"+target.getAttribute('tdindex');
+        //   for (let i = 0; i < this.tableData.length; i++) {
+        //     if(this.tableData[i].xys.indexOf(trtd) > -1){
+        //       this.titleIndex = i;
+        //       break;
+        //     }
+        //   }
+        // }
+      }else if(target.innerHTML){
+        this.titleList.push(target.innerHTML)
       }
     },
 
@@ -1038,6 +1134,23 @@ export default {
         return 'warning-row';
       }
       return '';
+    },
+
+    //保存单条元素
+    saveELe(row){
+      if(row.textInfo){
+        exctabcellUpdate(row).then(()=>{
+          this.$message({
+            type: "success",
+            message: "保存成功!"
+          });
+        })
+      }else{
+        this.$message({
+          type: "warning",
+          message: "请填写元素名称"
+        });
+      }
     }
 
   },
@@ -1084,4 +1197,15 @@ export default {
 /deep/ .el-table .warning-row {
   background: oldlace;
 }
+
+.region{
+  position: relative;
+}
+
+.region /deep/ .el-dialog__wrapper{
+  position: absolute !important;
+}
+.region /deep/ .v-modal{
+  position: absolute !important;
+}
 </style>