lilei 2 年之前
父节点
当前提交
e2f4cf6790
共有 4 个文件被更改,包括 87 次插入29 次删除
  1. 8 0
      api/shelfReplenish.js
  2. 65 22
      pages/soldOut/creatOrder.vue
  3. 11 4
      pages/soldOut/productList.vue
  4. 3 3
      pages/soldOut/shelfList.vue

+ 8 - 0
api/shelfReplenish.js

@@ -124,4 +124,12 @@ export const saveReplenishBill = (params) => {
     data: params,
     method: 'post'
   })
+}
+// 保存补货单和明细
+export const saveMainAndDetail = (params) => {
+  return axios.request({
+    url: 'shelfReplenish/saveMainAndDetail',
+    data: params,
+    method: 'post'
+  })
 }

+ 65 - 22
pages/soldOut/creatOrder.vue

@@ -38,8 +38,7 @@
 					已选<text>{{totalCategory}}</text>款/<text>{{totalQty}}</text>件
 				</view>
 				<view>
-					查看明细
-					<u-icon name="arrow-up"></u-icon>
+					查看明细 <u-icon name="arrow-up"></u-icon>
 				</view>
 			</view>
 			<view class="f-btns">
@@ -60,13 +59,12 @@
 				</div>
 				<div class="cpb_cart-list">
 					<view 
-					@click="delDetail"
 					v-for="(item, index) in chooseList" 
-					:key="item.id" 
+					:key="'cpb_'+item.id" 
 					>
 					<view class="nav-right-item flex align_center">
 						<view class="uni-col-1">
-							<u-icon name="close-circle" color="#999" size="35"></u-icon>
+							<u-icon name="close-circle" color="#999" size="35" @click="delDetail(item,index)"></u-icon>
 						</view>
 						<view class="uni-col-11 flex">
 							<view class="uni-col-2">
@@ -106,11 +104,12 @@
 									 <view class="item-detail-text">
 										补货数量:
 										<u-number-box 
-										v-model="item.checkQty" 
+										v-model="item.replenishQty" 
 										@minus="cartChangeNums" 
 										@plus="cartChangeNums" 
 										@blur="cartChangeNums"
 										:index="'cart_'+item.id" 
+										:min="1"
 										:max="999999"></u-number-box>
 									 </view>
 								</view>
@@ -144,6 +143,7 @@
 
 <script>
 	import { queryProductListForReplenish } from '@/api/shelf'
+	import { saveMainAndDetail } from '@/api/shelfReplenish'
 	import productList from './productList.vue'
 	import { clzConfirm } from '@/libs/tools'
 	export default {
@@ -153,7 +153,6 @@
 		data() {
 			return {
 				queryWord: '',
-				qrCode: '',
 				nowData:null,
 				detail:null,
 				pageNo:1,
@@ -164,7 +163,6 @@
 				partList: [],
 				allChecked: false,
 				showTab: false,
-				curType: [],
 				customBtnStyle: {  //  自定义按钮样式
 					borderColor: this.$config('primaryColor'),
 					backgroundColor: this.$config('primaryColor'),
@@ -227,7 +225,7 @@
 		methods: {
 			checkboxGroupChange(e) {
 				console.log(e);
-				this.curType = e
+				this.stockStateList = e
 			},
 			// 全选
 			allCheckeChange(e){
@@ -260,6 +258,7 @@
 			// 打开购物车
 			openCart(){
 				if(this.totalCategory){
+					this.chooseList = this.$refs.productList.getAllChecked()
 					this.showCart = !this.showCart
 				}else{
 					uni.showToast({
@@ -268,7 +267,18 @@
 					})
 				}
 			},
-			// 清空购物车
+			// 删除购物车产品
+			delDetail(item,i){
+				console.log(item.id,i)
+				this.$refs.productList.setChecked(item.id,false)
+				const index = this.chooseList.findIndex(k => k.id == item.id)
+				this.chooseList.splice(index,1)
+				// 全部清空
+				if(this.chooseList.length==0){
+					this.clearChoose()
+				}
+			},
+			// 空列表
 			clearDetail(){
 				const _this = this
 				clzConfirm({
@@ -276,19 +286,24 @@
 				  content: '确认要清空列表吗?',
 				  success (ret) {
 					if (ret.confirm || ret.index == 0) {
-						_this.chooseList = []
-						_this.showCart = false
+						_this.clearChoose()
 					}
 				  }
 				})
 			},
+			// 清空已选数据
+			clearChoose(){
+				this.chooseList = []
+				this.showCart = false
+				this.allChecked = false
+				this.$refs.productList.allSelect(false)
+			},
 			// 修改数量
 			cartChangeNums(v){
-				console.log(v,this.showCart)
-				const data = this.chooseList.find(item => item.id == v.index.split('_')[1])
+				this.$refs.productList.changeNums(v.index.split('_')[1],v.value)
 			},
 			handleClear(){
-				this.curType = []
+				this.stockStateList = []
 				this.queryKeys.map(item => item.checked = false)
 				this.clearSearch()
 			},
@@ -310,6 +325,10 @@
 					stockStateList: this.stockStateList
 				}
 				_this.status = 'loading'
+				uni.showLoading({
+					mask:true,
+					title:"正在加载..."
+				})
 				queryProductListForReplenish(params).then(res => {
 					uni.hideLoading()
 					if(res.status == 200){
@@ -326,12 +345,10 @@
 					this.$refs.productList.setData(_this.partList)
 				})
 			},
-			// 提交盘点单
+			// 提交
 			submitOrder(){
-				if(this.chooseList.length){
-					uni.navigateTo({
-						url: '/pages/stockCheck/submitStockCheck?stockCheckSn='+this.stockCheckSn+'&type=submit'
-					})
+				if(this.totalCategory){
+					this.handleSave()
 				}else{
 					uni.showToast({
 						icon: 'none',
@@ -339,6 +356,32 @@
 					})
 				}
 			},
+			handleSave () {
+			  const data = this.chooseList
+			  const dataList = []
+			  data.map(item => {
+			    dataList.push({
+			      shelfPlaceSn: item.shelfPlaceSn,
+			      shelfPlaceCode: item.shelfPlaceCode,
+			      productSn: item.productSn,
+			      productCode: item.productCode,
+			      qty: item.replenishQty
+			    })
+			  })
+			  this.showLoading("正在提交...")
+			  // 开始提交
+			  saveMainAndDetail({
+			    shelfSn: this.nowData.shelfSn,
+			    dealerSn: this.nowData.dealerSn,
+			    detailList: dataList
+			  }).then(res => {
+			    if (res.status == 200) {
+			      this.toashMsg(res.message)
+				  uni.navigateBack()
+			    }
+				uni.hideLoading()
+			  })
+			},
 			// 扫描
 			toScan(){
 				this.mpaasScanModule = uni.requireNativePlugin("wss-scan")
@@ -366,7 +409,7 @@
 					const ret = data.scanValue.split("&")
 					this.queryWord = ret[1] // 产品编码
 				}else{
-					this.qrCode = data.scanValue
+					this.queryWord = data.scanValue
 				}
 				this.stockStateList = []
 				this.getpartList()
@@ -449,7 +492,7 @@
 			font-size: 0.8rem;
 			color: #666;
 			> view{
-				padding: 0 10upx;
+				padding: 0 5upx;
 				&:first-child{
 					text{
 						color: red;

+ 11 - 4
pages/soldOut/productList.vue

@@ -96,6 +96,11 @@
 				})
 				this.partList.splice()
 			},
+			setChecked(id,val){
+				const row = this.partList.find(item => item.id == id)
+				row.checked = val
+				this.partList.splice()
+			},
 			checkChange(e){
 				const row = this.partList.find(item => item.productSn == e.name)
 				if(row){
@@ -108,15 +113,17 @@
 			},
 			// 获取所有选择的
 			getAllChecked(){
-				return this.partList.filter(item => item.checked)
+				return JSON.parse(JSON.stringify(this.partList.filter(item => item.checked)))
 			},
 			// 获取所有数据
 			getAllData(){
 				return this.partList
 			},
-			// 数量 change
-			numberChange(value, index){
-				this.$emit('numberChange', value, index)
+			// 更新数量
+			changeNums(id,val){
+				const row = this.partList.find(item => item.id == id)
+				row.replenishQty = val
+				this.partList.splice()
 			}
 		}
 	}

+ 3 - 3
pages/soldOut/shelfList.vue

@@ -14,7 +14,7 @@
 			:action-style="{'color': '#fff', 'font-size': '24upx', 'background-color': '#57a3f3', 'border-radius': '6upx', 'padding': '12upx 0'}">
 			</u-search>
 		</view>
-		<view class="flex align_center justify_between" style="padding: 10rpx 20rpx 20rpx;">
+		<view class="flex align_center justify_between" style="padding: 10rpx 20rpx;">
 			<view class="flex align_center" @click="sortList('productCategory',0)">
 				<text>待补货产品款数</text>
 				<view class="flex flex_column" style="margin-left: 5rpx;" >
@@ -216,7 +216,7 @@
 		height: 100vh;
 		background-color: #f8f8f8;
 		.moreShelfPart-search{
-			padding: 20rpx;
+			padding: 0 20rpx 10rpx;
 			background-color: #fff;
 		}
 		.moreShelfPart-body{
@@ -224,7 +224,7 @@
 		}
 		.nav-right{
 			padding: 0 30upx;
-			height: calc(100vh - 170rpx);
+			height: calc(100vh - 160rpx);
 			box-sizing: border-box;
 			 
 			.nav-right-item{