فهرست منبع

元素识别新需求

gangyj 2 سال پیش
والد
کامیت
3e2f72131d
1فایلهای تغییر یافته به همراه171 افزوده شده و 108 حذف شده
  1. 171 108
      src/views/exctab/ElementIdentification/index.vue

+ 171 - 108
src/views/exctab/ElementIdentification/index.vue

@@ -245,8 +245,8 @@
                     <el-input type="textarea" rows="5" v-model="titleForm.textInfo"></el-input>
                   </div>
                   <el-alert
-                    title="匹配不到右侧元素列表,无法修改到相应名称" v-if="titleIndex < 0"
-                    type="error" :closable="false"
+                    title="该输入框没有匹配到对应元素字段,确定修改将会新增一个元素字段" v-if="titleIndex < 0"
+                    type="warning" :closable="false"
                     effect="dark" style="margin-top:10px;">
                   </el-alert>
                   <span
@@ -257,11 +257,140 @@
                     <el-button
                       type="primary"
                       v-throttle='2000'
-                      :disabled="titleIndex < 0"
                       @click="editTitle()"
                     >确定修改</el-button>
                   </span>
                 </el-dialog>
+
+                <el-dialog
+                  title="添加新元素字段"
+                  :visible.sync="addNewElementDialog"
+                  :before-close="handleClose"
+                  width="80%"
+                  :modal-append-to-body='false'
+                  :append-to-body="false"
+                >
+                  <div>
+                    <!-- <i
+                      @click="addNewElement"
+                      class="el-icon-circle-plus marbottom10"
+                      style="color:red; font-size:24px; float: right;cursor: pointer;"
+                    ></i> -->
+                    <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 class="flex jc-sb mg-b-10">
+                        <div class="flex jc-al-c">
+                          
+                        </div>
+                        <div>
+                          <el-button size="medium" type="primary" @click="setTitleText">合成文本</el-button>
+                        </div>
+                      </div>
+                    </div>
+                    <el-table
+                      :data="newElements"
+                      height="250"
+                      border
+                      style="width: 100%"
+                    >
+                      <el-table-column
+                        label="元素名称"
+                      >
+                        <template slot-scope="scope">
+                          <el-input
+                            v-model="scope.row.textInfo"
+                            placeholder="请输入内容"
+                          ></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"
+                        width="120"
+                        label="操作"
+                      >
+                        <template slot-scope="scope">
+                          <el-button
+                            type="danger"
+                            size="mini"
+                            @click="deleteNewElement(scope.$index)"
+                          >删除</el-button>
+                        </template>
+                      </el-table-column>
+                    </el-table>
+                  </div>
+                  <span
+                    slot="footer"
+                    class="dialog-footer"
+                  >
+                    <el-button @click="handleClose()">取 消</el-button>
+                    <el-button
+                      type="primary"
+                      v-throttle='2000'
+                      :disabled="newElements.length===0"
+                      @click="addNewElementHandle()"
+                    >确 定</el-button>
+                  </span>
+                </el-dialog>
+
               </div>
               </el-col>
             </el-row>
@@ -408,96 +537,6 @@
         </span>
       </el-dialog>
 
-      <el-dialog
-        title="添加新元素字段"
-        :visible="addNewElementDialog"
-        width="60%"
-        :before-close="handleClose"
-        :modal-append-to-body="false"
-        style="z-index: 999999;"
-      >
-        <div>
-          <i
-            @click="addNewElement"
-            class="el-icon-circle-plus marbottom10"
-            style="color:red; font-size:24px; float: right;cursor: pointer;"
-          ></i>
-          <el-table
-            :data="newElements"
-            height="250"
-            border
-            style="width: 100%"
-          >
-            <el-table-column
-              label="元素名称"
-            >
-              <template slot-scope="scope">
-                <el-input
-                  v-model="scope.row.textInfo"
-                  placeholder="请输入内容"
-                ></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"
-              width="120"
-              label="操作"
-            >
-              <template slot-scope="scope">
-                <el-button
-                  type="danger"
-                  size="mini"
-                  @click="deleteNewElement(scope.$index)"
-                >删除</el-button>
-              </template>
-            </el-table-column>
-          </el-table>
-        </div>
-        <span
-          slot="footer"
-          class="dialog-footer"
-        >
-          <el-button @click="handleClose()">取 消</el-button>
-          <el-button
-            type="primary"
-            v-throttle='2000'
-            :disabled="newElements.length===0"
-            @click="addNewElementHandle()"
-          >确 定</el-button>
-        </span>
-      </el-dialog>
-
     </div>
   </div>
 </template>
@@ -659,6 +698,7 @@ export default {
       // }
 
       if (this.from.id) {
+        this.showLeft = false;
         this.addNewElementDialog = true;
       }
     },
@@ -1039,24 +1079,46 @@ export default {
     },
 
     setTitleText(){
-      this.titleForm.textInfo = this.titleList.join('_');
+      if(this.addNewElementDialog){
+        this.newElements.push({
+          exctabId:this.from.id,
+          textInfo: this.titleList.join('_')
+        })
+        this.titleList = [];
+      }else{
+        this.titleForm.textInfo = this.titleList.join('_');
+      }
     },
 
     editTitle(){
-      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;
+      if(this.titleIndex < 0){
+        //新增
+        exctabcellSave([this.titleForm]).then(()=>{
+            this.editTitleDialog = false;
+            //触发自动识别按钮
+            this.automaticRecognition();
+            this.$message({
+              type: "success",
+              message: "新增成功!"
+            });
+        })
+      }else{
+        //修改
+        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;
-        this.$message({
-          type: "success",
-          message: "保存成功!"
-        });
-      })
+          //console.log(this.$refs.tablescroll)
+          this.$refs.tablescroll.$el.scrollTop = 120+this.titleIndex*65;
+          this.editTitleDialog = false;
+          this.$message({
+            type: "success",
+            message: "保存成功!"
+          });
+        })
+      }
     },
 
     dblBtnClick(e){
@@ -1068,6 +1130,7 @@ export default {
         this.titleList = [];
         this.$refs.tablescroll.$el.scrollTop = 0;
         this.editTitleDialog = true;
+        this.showLeft = false;
         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){
@@ -1099,7 +1162,7 @@ export default {
         //     }
         //   }
         // }
-      }else if(target.innerHTML){
+      }else if(target.innerHTML && target.nodeName === "TD"){
         this.titleList.push(target.innerHTML)
       }
     },