shish 2 tahun lalu
induk
melakukan
ecc63f0136
1 mengubah file dengan 44 tambahan dan 34 penghapusan
  1. 44 34
      ghs/src/views/order/add.vue

+ 44 - 34
ghs/src/views/order/add.vue

@@ -12,11 +12,12 @@
         <span style="font-weight:bold;color:black;">客户:{{form.customName}}</span>
         <span>全屏:F11</span>
         <span>提交:F9</span>
-        <span>修改:回车</span>
+        <span>修改:/</span>
         <span>删除:Delete</span>
         <span>删除所有:Page Down</span>
       </p>
-      <el-table ref="singleTable" :data="selectList" highlight-current-row style="width:80%" border :header-cell-style="{background:'#fdfdfd', color: '#01060a', fontWeight:800}" class="tableBox active">
+      <el-table ref="singleTable" :data="selectList" highlight-current-row style="width:80%" border :header-cell-style="{background:'#fdfdfd', color: '#01060a', fontWeight:800}" 
+      class="tableBox active" @row-click="pickModifyItem">
         <el-table-column prop="id" label="编号" width="120" align="center"></el-table-column>
 
         <el-table-column prop="cover" label="图片" align="center" width="130">
@@ -41,7 +42,7 @@
     </div>
     <div class="seek-list-box" v-if="!$util.isEmpty(getItemList) && showGetItemList == true">
       <el-table ref="showItemRef" :data="getItemList" highlight-current-row style="width:72%" border :header-cell-style="{background:'#fdfdfd', color: '#666'}" 
-      class="tableBox active" height="740" @row-click="pickItem">
+      class="tableBox active" height="740" @row-click="pickAddItem">
         <el-table-column prop="className" label="分类" align="center" width="180"></el-table-column>
         <el-table-column prop="cover" label="图片" align="center" width="120">
           <template slot-scope="scope">
@@ -61,7 +62,7 @@
     </div>
     <div class="bottom_input">
         <span style="margin-right:10px;font-weight: 700;">花材</span>
-        <el-input style="width: 280px;font-size:13px" @input="beginSearchItem" @keyup.enter.native="pickCurrentItem" @focus="clearSeachVal" placeholder="这里搜索,光标插入 Ctrl + Q" type="text" ref="itemSearchRef" v-model="searchVal"></el-input>
+        <el-input style="width: 280px;font-size:13px" @input="beginSearchItem" @keyup.enter.native="pickAddCurrentItem" @focus="clearSeachVal" placeholder="这里搜索,光标插入 Ctrl + Q" type="text" ref="itemSearchRef" v-model="searchVal"></el-input>
         <div style="display: inline-block;" class="allPrice">{{allCount.kind}}种</div>
         <div style="display: inline-block;" class="allPrice">{{ allCount.bigLength }}扎</div>
         <div style="display: inline-block;" class="allPrice">¥{{ allPrice }}</div>
@@ -261,7 +262,8 @@ export default {
       diffList:[],
       showGetItemList:false,
       currentItem:{},
-      classList:[]
+      classList:[],
+      changeType:'add'
     };
   },
 	mixins: [productMins],
@@ -309,7 +311,11 @@ export default {
     document.onkeydown=function(e) {
       console.log(e)
       if(e && e.key == 'Enter' && e.ctrlKey){
-          that.createOrder()        
+        if(that.desk == 'commit'){
+          that.createOrder()
+        }else{
+          that.$message({message: '不在结算页',type: 'warning'})
+        }
       }
       if(e && e.key && e.key.toLowerCase() =='c' && e.ctrlKey){
         that.$refs['customref'].focus();
@@ -508,27 +514,6 @@ export default {
       this.searchVal = ''
       this.getItemList = []
     },
-    pickItem(e){
-      this.selectCurrentItem(e)
-    },
-    pickCurrentItem(){
-      if(this.getItemList[this.getIndex]){
-        let currentItem = this.getItemList[this.getIndex]
-        this.selectCurrentItem(currentItem)
-      }
-    },
-    selectCurrentItem(currentItem){
-        this.currentItem = currentItem
-        this.customData.bigCount = 1
-        this.customData.userPrice = parseFloat(this.currentItem.price)
-        this.desk = 'confirmPriceNum';
-        this.showGetItemList = false
-        this.showConfirmNum = true;
-        this.$nextTick(()=>{
-          this.$refs['bigInput'].focus()
-          this.$refs['bigInput'].select()
-        })
-    },
     beginSearchItem(){
       let that = this
       if(this.t!=null){
@@ -581,19 +566,48 @@ export default {
         that.$refs.showItemRef.setCurrentRow(that.getItemList[0])
       }
     },
+    pickModifyItem(e){
+      this.changeType = 'update'
+      this.selectCurrentItem(e)
+    },
+    pickAddItem(e){
+      this.changeType = 'add'
+      this.selectCurrentItem(e)
+    },
+    pickAddCurrentItem(){
+      this.changeType = 'add'
+      if(this.getItemList[this.getIndex]){
+        let currentItem = this.getItemList[this.getIndex]
+        this.selectCurrentItem(currentItem)
+      }
+    },
+    selectCurrentItem(currentItem){
+        this.currentItem = currentItem
+        this.customData.bigCount = currentItem.bigCount > 0 ? currentItem.bigCount : 1
+        this.customData.userPrice = parseFloat(this.currentItem.price)
+        this.desk = 'confirmPriceNum';
+        this.showGetItemList = false
+        this.showConfirmNum = true;
+        this.$nextTick(()=>{
+          this.$refs['bigInput'].focus()
+          this.$refs['bigInput'].select()
+        })
+    },
     confirmNumPrice(){
       let currentItem = this.currentItem;
       if(Number(this.customData.bigCount)<=0){
         this.$message({message: '请填写数量',type: 'warning'});
         return;
       }
-      let has = false
       for (let i=0;i<this.selectList.length;i++){
         if(this.selectList[i].id == currentItem.id){
-          this.customData.bigCount = Number(this.customData.bigCount)+Number(this.selectList[i].bigCount)
+          if(this.changeType == 'add'){
+            this.customData.bigCount = Number(this.customData.bigCount)+Number(this.selectList[i].bigCount)
+          }else{
+            this.customData.bigCount = Number(this.customData.bigCount)
+          }
           this.customData.bigCount = this.customData.bigCount.toFixed(2)
           this.customData.bigCount = parseFloat(this.customData.bigCount)
-          this.selectList.splice(i,1)
         }
       }
       let sumPrice = Number(this.customData.userPrice)*Number(this.customData.bigCount)
@@ -602,10 +616,6 @@ export default {
       this.replaceItemFn(currentItem,1,'add')
       this.selectIndex = this.selectList.length-1;
       this.$refs.singleTable.setCurrentRow(this.selectList[this.selectList.length-1]);
-      this.$nextTick(()=>{
-        this.big = null;
-        this.small = null;
-      })
       this.backToSearchItem();
     },
     backToSearchItem(){