shish před 2 roky
rodič
revize
481583e5f5
2 změnil soubory, kde provedl 32 přidání a 50 odebrání
  1. 8 1
      ghs/src/mixins/product2.js
  2. 24 49
      ghs/src/views/order/add.vue

+ 8 - 1
ghs/src/mixins/product2.js

@@ -86,6 +86,7 @@ export default {
 			let bigLength = 0;
 			let smallLength = 0;
 			let weight = 0
+			let kind = 0
 			if (this.selectList) {
 				for (const item of this.selectList) {
 					bigLength += Number(item.bigCount)
@@ -93,11 +94,12 @@ export default {
 					let thisWeight = item.weight ? item.weight : 0
 					let currentWeight = Number(thisWeight)*Number(item.bigCount)
 					weight = Number(weight) + Number(currentWeight)
+					kind++
 				}
 				weight = weight.toFixed(2)
 				weight = parseFloat(weight)
 			}
-			return {bigLength:bigLength,smallLength:smallLength,weight:weight};
+			return {bigLength:bigLength,smallLength:smallLength,weight:weight,kind:kind};
 		},
 		hasNoStock() {
 			let has = false;
@@ -161,6 +163,11 @@ export default {
 			this.setSelectInfo({ selectJobType: this.selectJobType, info: selectData,selectJobId:this.selectJobId })
 			localStorage.setItem('selectList_'+this.selectJobType+'_target_'+this.selectJobId, JSON.stringify(selectData));
 		},
+		getFromStorage(){
+			let res = localStorage.getItem('selectList_'+this.selectJobType+'_target_'+this.selectJobId)
+			let obj = JSON.parse(res)
+			this.setSelectInfo({ selectJobType: this.selectJobType, info: obj,selectJobId:this.selectJobId })
+		},
 		globalChangeClass(index,item){
 			this.$refs.globalClassImgRef.close()
 			this.globalSwitchClass(index,item)

+ 24 - 49
ghs/src/views/order/add.vue

@@ -17,7 +17,7 @@
         <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-column prop="index" label="编号" width="120" align="center"></el-table-column>
+        <el-table-column prop="id" label="编号" width="120" align="center"></el-table-column>
 
         <el-table-column prop="cover" label="图片" align="center" width="130">
           <template slot-scope="scope">
@@ -26,8 +26,8 @@
         </el-table-column>
 
         <el-table-column prop="name" label="名称" align="center"></el-table-column>
-        <el-table-column prop="price" label="单价" width="150" align="center"></el-table-column>
-        <el-table-column prop="big" label="数量" width="150" align="center"></el-table-column>
+        <el-table-column prop="userPrice" label="单价" width="150" align="center"></el-table-column>
+        <el-table-column prop="bigCount" label="数量" width="150" align="center"></el-table-column>
         <el-table-column prop="totalAmount" label="金额" width="150" align="center"></el-table-column>
 
         <el-table-column prop="ratioType" label="单位比" align="center" width="150">
@@ -55,16 +55,16 @@
     <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>
-        <div style="display: inline-block;" class="allPrice">{{selectList.length}}种</div>
-        <div style="display: inline-block;" class="allPrice">¥{{ totalMoney }}</div>
-        <div style="display: inline-block;" class="allPrice active"></div>
+        <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>
     </div>
 
     <el-dialog :title="getItemList[getIndex].name" v-if="showConfirmNum" :visible.sync="showConfirmNum" width="30%" center>
       <div class="el-dialog-center">
-        <el-input ref="bigInput" style="width: 130px;margin-left: 15px" placeholder="数量" @keyup.key-backspace.native="backspaceFun('big')" @keyup.enter.native="confirmNumPrice()" type="number" v-model="big"></el-input>
+        <el-input ref="bigInput" style="width: 130px;margin-left: 15px" placeholder="数量" @keyup.key-backspace.native="backspaceFun('big')" @keyup.enter.native="confirmNumPrice()" type="number" v-model="customData.bigCount"></el-input>
         <span>{{getItemList[getIndex].bigUnit}}</span>
-        <el-input style="width: 130px;margin-left: 15px" placeholder="价格" @keyup.key-backspace.native="backspaceFun('price')" @keyup.enter.native="confirmNumPrice()" type="number" v-model="price"></el-input>
+        <el-input style="width: 130px;margin-left: 15px" placeholder="价格" @keyup.key-backspace.native="backspaceFun('price')" @keyup.enter.native="confirmNumPrice()" type="number" v-model="customData.userPrice"></el-input>
         <span>元</span>
       </div>
       <div class="remark">Enter 确定,Backspace 清0,Esc 取消</div>
@@ -212,9 +212,6 @@ export default {
       isAccounts:false,//结账弹窗
       priceAmend:0,//修改单价弹窗
       isSeek:false,
-      big:null,//大单位(扎)
-      small:null,//小单位(支
-      price:null,
       totalMoney:0,//总价
       modifyPrice:0,//实际收款
       searchVal:'',//搜索值
@@ -222,7 +219,6 @@ export default {
       getIndex:0,
       getItemList:[],//搜索展示的列表
       selectIndex:0,
-      selectList: [],// {index:'001',name:'测试1',lv:'2',unit:'支',count:'100',price:'50',money:'100'},
       allShopList:[],
       selectShopListVal:'',
       freight:'',//运费
@@ -324,6 +320,7 @@ export default {
     searchSelectCustom(e){
       this.customId = e
       this.selectJobId = e
+      this.getFromStorage()
 		  this.$nextTick(()=>{
 			  this.$refs['itemSearchRef'].focus()
       })
@@ -396,14 +393,16 @@ export default {
       this.getItemList = []
     },
     selectCurrentItem(){
-      this.big = 1
-      this.price = this.getItemList[this.getIndex].price
-      this.isSeek = false;
-      this.showConfirmNum = true;
-      this.$nextTick(()=>{
-        this.$refs['bigInput'].focus()
-        this.$refs['bigInput'].select()
-      })
+      if(this.getItemList[this.getIndex]){
+        this.customData.bigCount = 1
+        this.customData.userPrice = parseFloat(this.getItemList[this.getIndex].price)
+        this.isSeek = false;
+        this.showConfirmNum = true;
+        this.$nextTick(()=>{
+          this.$refs['bigInput'].focus()
+          this.$refs['bigInput'].select()
+        })
+      }
     },
     beginSearchItem(){
       let that = this
@@ -438,20 +437,17 @@ export default {
     },
     confirmNumPrice(){
       let currentItem = this.getItemList[this.getIndex];
-      let big = this.big == null ? 0 : Number(this.big)
-      if(big<=0){
+      if(Number(this.customData.bigCount)<=0){
         this.$message({message: '请先输入数量',type: 'warning'});
         return;
       }
-      let money = Number(currentItem.price) * Number(big)
       for (let i=0;i<this.selectList.length;i++){
         if(this.selectList[i].id == currentItem.id){
           this.selectList.splice(i,1)
         }
       }
-      currentItem = {...currentItem,bigCount:parseFloat(Number(big)),totalAmount:money.toFixed(2),smallCount:0}
+      currentItem = {...currentItem,bigCount:this.customData.bigCount,userPrice:this.customData.userPrice,smallCount:this.customData.smallCount}
       this.replaceItemFn(currentItem,1,'add')
-      //this.selectList.push(newItem)
       this.selectIndex = this.selectList.length-1;
       this.$refs.singleTable.setCurrentRow(this.selectList[this.selectList.length-1]);
       this.$nextTick(()=>{
@@ -460,18 +456,7 @@ export default {
       })
       this.escFun();
     },
-    getAllTableDataMoney(){
-      let totalMoney = 0;
-      this.selectList.forEach(ele => {
-        totalMoney= totalMoney + ele.totalAmount
-      })
-      totalMoney = Number(totalMoney)
-      this.totalMoney = parseFloat(totalMoney.toFixed(2))
-      this.number = this.totalMoney
-      this.modifyPrice = this.totalMoney;
-    },
     escFun(){
-      this.getAllTableDataMoney();
       this.isAmendPrice = false;
       this.searchVal = '';
       this.getItemList = [];
@@ -505,16 +490,11 @@ export default {
     },
     addBigNum(){
       let currentItem = this.selectList[this.selectIndex];
-      // if(Number(currentItem.stock)<Number(currentItem.big+1) + Number(currentItem.small) / Number(currentItem.ratio)){
-      //   this.$message({message: '库存不足',type: 'warning'});
-      //   return;
-      // }
       this.selectList[this.selectIndex].big++
       let money = Number(currentItem.price) * (Number(currentItem.big) + Number(currentItem.small) / Number(currentItem.ratio));
       this.selectList[this.selectIndex].count = this.selectList[this.selectIndex].big+'/'+Number(this.selectList[this.selectIndex].small);
       this.selectList[this.selectIndex].money = money;
-      this.selectList[this.selectIndex].totalMoney = money.toFixed(2),
-          this.getAllTableDataMoney();
+      this.selectList[this.selectIndex].totalMoney = money.toFixed(2)
       setTimeout(()=>{
         this.searchVal = '';
       },100)
@@ -527,16 +507,11 @@ export default {
         },100)
         return;
       }
-      // if(Number(currentItem.stock)<Number(currentItem.big-1) + Number(currentItem.small) / Number(currentItem.ratio)){
-      //   this.$message({message: '库存不足',type: 'warning'});
-      //   return;
-      // }
       this.selectList[this.selectIndex].big--
       let money = Number(currentItem.price) * (Number(currentItem.big) + Number(currentItem.small) / Number(currentItem.ratio));
       this.selectList[this.selectIndex].count = this.selectList[this.selectIndex].big+'/'+Number(this.selectList[this.selectIndex].small);
       this.selectList[this.selectIndex].money = money;
-      this.selectList[this.selectIndex].totalMoney = money.toFixed(2),
-      this.getAllTableDataMoney();
+      this.selectList[this.selectIndex].totalMoney = money.toFixed(2)
       setTimeout(()=>{
         this.searchVal = '';
       },100)
@@ -645,7 +620,7 @@ export default {
     width:100%;
     text-align: center;
     .allPrice {
-      margin-left:50px;
+      margin-left:30px;
       font-size: 16px;
       font-weight: 700;
       &.active{