fuwei 4 лет назад
Родитель
Сommit
4def2c7975

+ 68 - 28
ghsPad/src/admin/home/components/select-settle.vue

@@ -21,7 +21,7 @@
                             :key="item.id"
                             @tap="changeType('payId',item.id)"
                             v-for="item in payWay" 
-                            :class="[settleId===item.id?'active':'']">
+                            :class="[payId===item.id?'active':'']">
                             {{item.name}}
                         </view>  
                     </view>
@@ -33,7 +33,7 @@
                             :key="item.id"
                             @tap="changeType('payUserId',item.id)"
                             v-for="item in payUser" 
-                            :class="[settleId===item.id?'active':'']">
+                            :class="[payUserId===item.id?'active':'']">
                             {{item.name}}
                         </view>      
                     </view>
@@ -42,18 +42,22 @@
             <view class="select-item_box">
                 <view class="title">打印小票</view>
                 <view class="item-list_box">
-                    <view class="active">
-                        打印
-                    </view>   
+                    <view 
+                        :key="item.id"
+                        @tap="changeType('isPrint',item.id)"
+                        v-for="item in printOptions" 
+                        :class="[isPrint===item.id?'active':'']">
+                        {{item.name}}
+                    </view>     
                 </view>
             </view>
         </view>
         <view class="line"></view>
         <view class="select-right">
             <AppInputAll v-model="totalShop.totalPrice" title="商品合计" disabled></AppInputAll>
-            <AppInputAll v-model="shopVal" title="运费" placeholder="没有运费留空"></AppInputAll>
-            <AppInputAll v-model="shopVal" title="总金额" placeholder="总金额"></AppInputAll>
-            <AppInputAll v-model="shopVal" title="实收金额" placeholder="实收金额"></AppInputAll>
+            <AppInputAll v-model="freight" title="运费" @tap.native="changeEnterType('freight')" disabled placeholder="没有运费留空"></AppInputAll>
+            <AppInputAll v-model="totalMoney" title="总金额" disabled placeholder="总金额"></AppInputAll>
+            <AppInputAll v-model="proceeds" title="实收金额" @tap.native="changeEnterType('proceeds')" disabled placeholder="实收金额"></AppInputAll>
             <view class="shop-distoracn">优惠5</view>
             <view class="keyboard-body_box">
                 <VKeyboard
@@ -85,71 +89,95 @@
             VKeyboard,
             AppInputAll
         },
+        computed:{
+        },
         data() {
 			return {
-				input: '',//键盘输入
-                shopVal: '¥100',
+                // shopVal: '100',
+                freight: '',
                 settleId: 1,
                 payId:1,
                 payUserId:1,
+                isPrint:1,
+                proceeds: '0',
                 returnWay:[
                     {
-                        name:'款',
-                        id:1,
+                        name:'扫码付款',
+                        id:0,
                     },
                     {
                         name:'已付款',
-                        id:2,
+                        id:1,
                     },
                     {
                         name:'待付款',
-                        id:3,
+                        id:2,
                     }
                 ],
                 payWay:[
                     {
                         name:'微信',
-                        id:1
+                        id:0
                     },
                     {
                         name:'支付宝',
-                        id:2
+                        id:1
                     },
                     {
                         name:'现金',
-                        id:3
+                        id:4
                     },
                      {
                         name:'银行卡',
-                        id:4
+                        id:5
                     }
                 ],
                 payUser:[
                     {
                         name:'收款码',
-                        id:1    
+                        id:0   
                     },
                     {
                         name:'微信客服1',
-                        id:2   
+                        id:1 
                     },
                     {
                         name:'微信客服2',
-                        id:3   
+                        id:2   
                     },{
                         name:'微信客服3',
-                        id:4  
+                        id:3  
                     },{
                         name:'微信客服4',
-                        id:5   
+                        id:4   
+                    }
+                ],
+                currentInputType:'proceeds',
+                totalMoney: 0,
+                printOptions:[
+                    {
+                        name:'打印',
+                        id:1
+                    },
+                    {
+                        name:'不大',
+                        id:2
                     }
                 ]
 			};
 		},
         mounted() {
             this.activeKeyboard();
+            this.updateTotal()
         },
         methods: {
+            updateTotal(){
+                this.proceeds = this.totalShop.totalPrice
+                this.totalMoney = (+this.totalShop.totalPrice) +  (this.$util.isEmpty(this.freight)?0: +this.freight)
+            },
+            changeEnterType(type){
+                this.currentInputType = type
+            },
             changeType(key, id){
                 this[key] = id
             },
@@ -159,19 +187,31 @@
 			},
 			typing(e) {
 				if (e.backspace) {
-					if (this.input.length > 0) {
-						this.input = this.input.substring(0, this.input.length - 1);
+					if (this[this.currentInputType].length > 0) {
+						this[this.currentInputType] = this[this.currentInputType].substring(0, this[this.currentInputType].length - 1);
 					}
 				}
 				else {
-					this.input += e.char;
+                    if(this[this.currentInputType]== 0 || this.$util.isEmpty(this[this.currentInputType])) {
+                        this[this.currentInputType] = e.char
+                    }else {
+                        this[this.currentInputType] += e.char;
+                    }
 				}
+                if(this[this.currentInputType] === 'freight') {
+                     this.updateTotal()
+                }  
 			},
 			enter() {
-				this.$refs.keyboard.deactivate();
+               this.$emit('settleReturn') 
 			},
 			//键盘方法end
-		}
+		},
+        watch:{
+            totalShop(){
+                this.updateTotal()
+            }
+        }
     }
 </script>
 

+ 2 - 2
ghsPad/src/admin/home/components/select-user.vue

@@ -71,8 +71,8 @@ export default {
 	 async init() {
 		 try {
 		let { data:{list} } = await customList({
-															name: this.searchUser
-														})
+                            name: this.searchUser
+                          })
 			this.list = list
 		 }catch(err) {
 

+ 76 - 28
ghsPad/src/admin/home/workbench.vue

@@ -106,7 +106,7 @@
 			type="top"
 			maxHeight="90vh"
 			>
-			<selectSettle :totalShop="totalShop"></selectSettle>
+			<selectSettle @settleReturn="settleReturn" ref="selectSettle" :totalShop="totalShop"></selectSettle>
 		</uniPopup>
 		<NotLogin></NotLogin>
 	</view>
@@ -121,7 +121,7 @@ import keyboardSetFlower from '@/components/app-boardSet-flower.vue'
 import selectSettle from './components/select-settle.vue'
 import selectUser from './components/select-user.vue'
 import shopTypeSelect from './components/shopTypeSelect.vue'
-import { createOrder } from '@/api/home/index'
+import { createCreateOrder, wastageCreateOrder } from '@/api/home/index'
 export default {
 	name: "workbench",
 	components: { NotLogin,uniPopup,selectUser,shopTypeSelect,keyboardSetFlower,selectSettle },
@@ -139,7 +139,8 @@ export default {
 					bigUnit: 0,
 					smallUnit:0,
 					totalPrice: 0
-			}
+			},
+			selectItemUser:{}
 		};
 	},
 	computed: {
@@ -156,41 +157,71 @@ export default {
 	},
 	watch:{
 			shopList(){
-							if(this.$util.isEmpty(this.shopList)) {
-									this.totalShop = {
-											bigUnit: 0,
-											smallUnit:0,
-											totalPrice: 0
-										}
+			if(this.$util.isEmpty(this.shopList)) {
+					this.totalShop = {
+							bigUnit: 0,
+							smallUnit:0,
+							totalPrice: 0
+						}
+					}
+				this.totalShop =	this.shopList.reduce((total,val)=>{
+							// 0 大单位 1小单位
+							if(val.unitType === 0) {
+								total.bigUnit = total.bigUnit + (val.currentNum *1)
+							}else {
+								total.smallUnit = total.smallUnit +(1*val.currentNum)
 							}
-						this.totalShop =	this.shopList.reduce((total,val)=>{
-									// 0 大单位 1小单位
-									if(val.unitType === 0) {
-										total.bigUnit = total.bigUnit + (val.currentNum *1)
-									}else {
-										total.smallUnit = total.smallUnit +(1*val.currentNum)
-									}
-										total.totalPrice = total.totalPrice +  (1*val.currentNum) * (val.currentUnitPrice*1)
-									return total
-							},{
-								bigUnit: 0,
-								smallUnit:0,
-								totalPrice: 0
-							})
+								total.totalPrice = total.totalPrice +  (1*val.currentNum) * (val.currentUnitPrice*1)
+							return total
+					},{
+						bigUnit: 0,
+						smallUnit:0,
+						totalPrice: 0
+					})
 			}
 	},
 	methods: {
+		// 结算创建订单
+		async setCreateOrder(){
+			try {
+				let arr = this.shopList.map(i=>({
+						productId:i.id,
+						unitType: i.unitType,
+						num: i.currentNum,
+						property: i.property,
+						unitPrice: i.currentUnitPrice
+					}))
+				const {settleId,payId,payUserId,isPrint,proceeds,freight} = this.$refs.selectSettle
+				await createCreateOrder({
+					customId: this.selectItemUser.id,
+					product: JSON.stringify(arr),
+					modifyPrice: proceeds,
+					sendType: 1,
+					hasPay: settleId,
+					payWay: payId,
+					getUserId: payUserId,
+					needPrint: isPrint,
+					sendCost: freight,
+					remark:''
+				})
+				this.isShowSettle = false
+				this.$msg('订单创建成功')
+			}catch(err) {
+				console.log(err)
+			}
+		},
+		async settleReturn(){
+			this.setCreateOrder()
+		},
 		selectCurrentActive(item){
 				this.selectCurrentActiveItem = item
 		},
 		selectUserReturn(val){
-					this.isShowUser = false
+			this.selectItemUser = val
+			this.isShowUser = false
 		},
 		init() {
 		},
-		// selectItem(){
-		// 	this.isShowFllowNum = true
-		// },
 		selectUser(){
 			this.isShowUser = true
 		},
@@ -201,7 +232,20 @@ export default {
 			}
 			this.$util.confirmModal({content:'确定报损吗?'}, 
 			async() => {
-				// that.paySuccess(parameter)
+				try {
+					let arr = this.shopList.map(i=>({
+						productId:i.id,
+						unitType: i.unitType,
+						num: i.currentNum
+					}))
+					await wastageCreateOrder({
+						product: JSON.stringify(arr)
+					})
+					this.$msg("报损成功!");
+				}catch(err) {
+					console.log(err)
+				}
+				
 			})
 		},
 		settle(){
@@ -209,6 +253,10 @@ export default {
 				this.$msg('请选择结算商品')
 				return false
 			}
+			if(this.$util.isEmpty(this.selectItemUser)) {
+				this.$msg('请选择客户')
+				return false
+			}
 			this.isShowSettle = true
 			
 		},

+ 6 - 1
ghsPad/src/api/home/index.js

@@ -25,8 +25,13 @@ export const showList = async (data) => {
 export const customList = async (data) => {
 	return https.get("/custom/list", data);
 };
-export const createOrder = data => {
+// 报损
+export const wastageCreateOrder = data => {
 	return https.post('/wastage/create-order', data)
 }
+//创建订单
+export const createCreateOrder = data => {
+	return https.post('/order/create-order', data)
+}