shish 2 лет назад
Родитель
Сommit
2b6c3213f3
1 измененных файлов с 36 добавлено и 17 удалено
  1. 36 17
      ghs/src/views/order/add.vue

+ 36 - 17
ghs/src/views/order/add.vue

@@ -40,8 +40,9 @@
 
       </el-table>
     </div>
-    <div class="seek-list-box" v-if="getItemList!=''">
-      <el-table ref="showItemRef" :data="getItemList" highlight-current-row style="width:65%" border :header-cell-style="{background:'#fdfdfd', color: '#666'}" class="tableBox active" height="740">
+    <div class="seek-list-box" v-if="!$util.isEmpty(getItemList) && showGetItemList == true">
+      <el-table ref="showItemRef" :data="getItemList" highlight-current-row style="width:65%" border :header-cell-style="{background:'#fdfdfd', color: '#666'}" 
+      class="tableBox active" height="740" @row-click="pickItem">
         <el-table-column prop="cover" label="图片" align="center" width="120">
           <template slot-scope="scope">
             <img :src="scope.row.cover" style="width:26px;margin:0 auto;" />
@@ -55,7 +56,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="selectCurrentItem" @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="pickCurrentItem" @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>
@@ -256,7 +257,9 @@ export default {
       selectCustomName:'',
       t:null,
       currentShop:{default:0,pfLevel:0},
-      diffList:[]
+      diffList:[],
+      showGetItemList:false,
+      currentItem:{}
     };
   },
 	mixins: [productMins],
@@ -306,8 +309,6 @@ export default {
       if(e && e.key == 'Enter' && e.ctrlKey){
           that.createOrder()        
       }
-      if(e && e.key == 'Enter'){
-      }
       if(e && e.key && e.key.toLowerCase() =='c' && e.ctrlKey){
         that.$refs['customref'].focus();
       }
@@ -405,13 +406,15 @@ export default {
       })
     },
     searchSelectCustom(e){
-      this.form.customId = e.id
-      this.form.customName = e.name
-      this.selectJobId = e.id
-      this.getFromStorage()
-		  this.$nextTick(()=>{
-			  this.$refs['itemSearchRef'].focus()
-      })
+      if(e.id && e.name){
+        this.form.customId = e.id
+        this.form.customName = e.name
+        this.selectJobId = e.id
+        this.getFromStorage()
+        this.$nextTick(()=>{
+          this.$refs['itemSearchRef'].focus()
+        })
+      }
 		},
 		searchCustomInfo(query) {
 			let that = this
@@ -495,6 +498,7 @@ export default {
             that.$nextTick(()=>{
               that.selectList = [];
               that.diffList = []
+              that.formReset()
               that.removeFromSaveDirect()
               that.showCommitPop = false;
               that.escFun();
@@ -504,21 +508,34 @@ export default {
 
       })
     },
+    formReset(){
+      this.form.customId = 0
+      this.form.customName = ''
+    },
     clearSeachVal(){
       this.searchVal = ''
       this.getItemList = []
     },
-    selectCurrentItem(){
+    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.getItemList[this.getIndex].price)
+        this.customData.userPrice = parseFloat(this.currentItem.price)
         this.isSeek = false;
+        this.showGetItemList = false
         this.showConfirmNum = true;
         this.$nextTick(()=>{
           this.$refs['bigInput'].focus()
           this.$refs['bigInput'].select()
         })
-      }
     },
     beginSearchItem(){
       let that = this
@@ -544,6 +561,7 @@ export default {
       await this.$service.item.getItemList({search:this.searchVal,requestType:'kd',pageSize:20}).then(res=>{
         let list = this.$util.copyObject(res.list)
         if(!that.$util.isEmpty(list)){
+          that.showGetItemList = true
           that.getItemList = list
         }
       })
@@ -552,7 +570,7 @@ export default {
       }
     },
     confirmNumPrice(){
-      let currentItem = this.getItemList[this.getIndex];
+      let currentItem = this.currentItem;
       if(Number(this.customData.bigCount)<=0){
         this.$message({message: '请填写数量',type: 'warning'});
         return;
@@ -582,6 +600,7 @@ export default {
       this.isAmendPrice = false;
       this.searchVal = '';
       this.getItemList = [];
+      this.currentItem = {}
       this.showConfirmNum = false
       this.$nextTick(()=>{
         this.$refs['itemSearchRef'].focus();