Browse Source

报损 修改 功能

shish 4 years ago
parent
commit
35142c4795

+ 1 - 7
hdPad/src/api/home/index.js

@@ -20,10 +20,4 @@ export const customList = async (data) => {
 // 报损
 export const wastageCreateOrder = data => {
 	return https.post('/wastage/create-order', data)
-}
-//创建订单
-export const createCreateOrder = data => {
-	return https.post('/order/create-order', data)
-}
-
-
+}

+ 5 - 0
hdPad/src/api/wastage/index.js

@@ -12,3 +12,8 @@ export const wastageList = data => {
 export const wastageDetail = data => {
 	return https.get('/wastage/detail', data)
 }
+
+//成品报损 ssh 20220424
+export const goodsWastage = data => {
+	return https.post('/wastage/goods-wastage', data)
+}

+ 55 - 23
hdPad/src/pages/home/components/console.vue

@@ -3,11 +3,11 @@
 	<view class="active" @click="changeProperty">{{property==1 ? '花材' : '成品'}}</view>
 	<view @click="gosettleCommit">结算 </view>
 	<view @click="gatheringFn()">收款</view>
-    <view @click="breakage">报损</view>
 	<view @click="resetCustomer">选客</view>
 	<view @click="calcFn">{{calc == 'add' ? '+' : '-'}}</view>
+    <view @click="toWastage">报损</view>
     <view @click="clearItemFn">清空</view>
-	<view @click="logout">退出</view>
+	<view @click="logoutFn">退出</view>
 
     <!-- 清空 -->
     <uni-popup ref="clearItemRef" type="dialog">
@@ -18,6 +18,10 @@
         <uni-popup-dialog type="info" cancelText="取消" confirmText="确认" title="提示" content="确认退出?" @confirm="confirmLogout"></uni-popup-dialog>
     </uni-popup>
 
+    <uni-popup ref="wastageRef" type="dialog">
+        <uni-popup-dialog type="info" cancelText="取消" confirmText="确认" title="提示" content="确认报损?" @confirm="confirmWastage"></uni-popup-dialog>
+    </uni-popup>
+
     <!-- 结算弹框 -->
     <uni-popup ref="settlePopRef" background-color="#fff" type="center" :animation="false">
         <settlePop @settleCommit="settleCommit" @cancelSettle="cancelSettle" ref="settlePop"></settlePop>
@@ -38,7 +42,9 @@
 <script>
 import settlePop from './settlePop.vue'
 import toPayWay from './toPay.vue'
-import { createCreateOrder, wastageCreateOrder } from '@/api/home/index'
+import { wastageCreateOrder } from '@/api/home/index'
+import { createOrder} from '@/api/order'
+import {goodsWastage} from '@/api/wastage'
 import productMins from "@/mixins/product"
 import { allProduct } from '@/api/product'
 import selectPrice from './selectPrice.vue'
@@ -94,7 +100,7 @@ export default {
 		},
 		confirmSelectPrice(params){
 			uni.showLoading({mask:true})
-			createCreateOrder({orderName:params.name,lsGoodsPrice:params.price,modifyPrice:params.price}).then(res=>{
+			createOrder({orderName:params.name,lsGoodsPrice:params.price,modifyPrice:params.price}).then(res=>{
 				uni.hideLoading()
 				if(res.code == 1){
 					this.$refs.gatheringRef.close()
@@ -156,8 +162,8 @@ export default {
 				return false
 			}
 			uni.showLoading({mask:true})
-			let product = this.selectList.map(i=>({ productId:i.id, unitType: i.unitType, num: i.currentNum, property: i.property, unitPrice: i.unitPrice }))
-			createCreateOrder({...params,product:JSON.stringify(product)}).then(res=>{
+			let product = this.selectList.map(i=>({ productId:i.id, unitType: i.unitType||0, num: i.currentNum, property: i.property, unitPrice: i.unitPrice }))
+			createOrder({...params,product:JSON.stringify(product)}).then(res=>{
 				uni.hideLoading()
 				if(res.code == 1){
 					console.log(res.data)
@@ -184,28 +190,51 @@ export default {
 			this.$util.hitRemind()
 			console.log(price)
 		},
-		breakage(){
+		toWastage(){
 			this.$util.hitRemind()
 			if(this.$util.isEmpty(this.selectList)) {
 				this.$msg('请选择报损花材')
 				return false
 			}
-			this.$util.confirmModal({content:'确定报损吗?'},
-			async() => {
-				try {
-					let arr = this.itemList.map(i=>({
-						productId:i.id,
-						unitType: i.unitType,
-						num: i.thatNum
-					}))
-					wastageCreateOrder({
-						product: JSON.stringify(arr)
-					})
-					this.$msg("报损成功!");
-				}catch(err) {
-					console.log(err)
-				}
+			this.$refs.wastageRef.open('center')
+		},
+		confirmWastage(){
+			this.$util.hitRemind()
+			if(this.$util.isEmpty(this.selectList)) {
+				this.$msg('请选择报损花材')
+				return false
+			}
+			let hasGoods = this.selectList.some((item) => {
+			  return item.property  == 0
+			})
+			let hasItem = this.selectList.some((item) => {
+			  return item.property  == 1
 			})
+			if(hasGoods == true && hasItem == true){
+				this.$msg('成品和花材要分别进行报损')
+				return false
+			}
+			if(hasItem == true){
+				let product = this.selectList.map(i=>({ 
+					productId:i.id, unitType: i.unitType||0, num: i.currentNum, property: i.property, unitPrice: i.unitPrice,
+				}))
+				wastageCreateOrder({ product: JSON.stringify(product) }).then(res=>{
+					if(res.code == 1){
+						this.$refs.wastageRef.close()
+						this.$msg("报损成功!")
+					}
+				})
+			}else{
+				let goodsList = this.selectList.map(i=>({ 
+					goodsId:i.id, num: i.currentNum, property: i.property, unitPrice: i.unitPrice,name:i.name,cover:i.shortCover
+				}))
+				goodsWastage({ goodsList: JSON.stringify(goodsList) }).then(res=>{
+					if(res.code == 1){
+						this.$refs.wastageRef.close()
+						this.$msg("报损成功!")
+					}
+				})
+			}
 		},
 		gosettleCommit(){
 			this.$util.hitRemind()
@@ -227,14 +256,17 @@ export default {
 		//确认清空花材
 		confirmClearItem(){
 			this.$util.hitRemind()
+			this.removeFromSaveDirect()
 		},
 		confirmLogout(){
 			this.$util.hitRemind()
 			uni.clearStorage()
 			this.$store.commit("setLoginInfo", {})
+			// #ifdef APP-PLUS
 			plus.runtime.restart()
+			// #endif
 		},
-		logout(){
+		logoutFn(){
 			this.$util.hitRemind()
 			this.$refs.logoutRef.open()
 		},

+ 3 - 2
hdPad/src/pages/home/components/rightGoods.vue

@@ -1,6 +1,6 @@
 <template>
     <view class="shop-listType_box">
-        <view class="shop-type_box">
+        <view class="cat-list-area">
             <view v-for="item in allCategory" :key="item.id" :class="[currentCategory.id===item.id?'active':'']" @click="changeCategory(item)" > {{item.categoryName}} </view>
         </view>
         <view class="num-area" v-if="currentCategory.flower && currentCategory.flower ==1">
@@ -166,12 +166,13 @@ export default {
     display: flex;
     flex-direction: column;
     box-sizing: border-box;
-    & .shop-type_box {
+    & .cat-list-area {
         max-height: 300upx;
         display: flex;
         align-items: center;
         flex-wrap: wrap;
         overflow-y: scroll;
+        border-bottom:1upx solid #EEEEEE;
         & > view {
             border:1px solid #e4e4e4;
             padding: 12upx 0upx;

+ 3 - 2
hdPad/src/pages/home/components/rightItem.vue

@@ -1,6 +1,6 @@
 <template>
     <view class="shop-listType_box">
-        <view class="shop-type_box">
+        <view class="cat-list-area">
             <view v-for="item in classData" :key="item.id" :class="[categoryId===item.id?'active':'']" @click="changeCategory(item)" > {{item.name}} </view>
         </view>
         <view class="shop-show_box">
@@ -153,12 +153,13 @@ export default {
             }
         }
     }
-    & .shop-type_box {
+    & .cat-list-area {
         max-height: 300upx;
         display: flex;
         align-items: center;
         flex-wrap: wrap;
         overflow-y: scroll;
+        border-bottom:1upx solid #EEEEEE;
         & > view {
             border:1px solid #e4e4e4;
             padding: 12upx 0upx;

+ 15 - 0
hdPad/src/pages/home/modify.vue

@@ -20,6 +20,13 @@
 				</view>
 
             </view>
+
+			<!-- 清空 -->
+			<uni-popup ref="clearItemRef" type="dialog">
+				<uni-popup-dialog type="info" cancelText="取消" confirmText="确认" title="提示" content="确认清空?" @confirm="confirmClearItem"></uni-popup-dialog>
+			</uni-popup>
+
+
         </view>
     </view>
 </template>
@@ -46,8 +53,15 @@ export default {
 		...mapGetters(["getLoginInfo"])
 	},
 	methods: {
+		//清空花材弹框
 		clearItemFn(){
 			this.$util.hitRemind()
+			this.$refs.clearItemRef.open()
+		},
+		//确认清空花材
+		confirmClearItem(){
+			this.$util.hitRemind()
+			this.removeFromSaveDirect()
 		},
 		cancel(){
 			this.$util.hitRemind()
@@ -55,6 +69,7 @@ export default {
 		},
 		confirmModify(){
 			this.$util.hitRemind()
+			
 			uni.navigateBack({delta: 1})
 		},
 		getOrderDetail(id){