lilei 2 years ago
parent
commit
aaa970bcc7

+ 9 - 0
api/shelfReplenish.js

@@ -92,4 +92,13 @@ export const shelfReplenishOutStock = (params) => {
     data: params,
     method: 'post'
   })
+}
+
+// 快速补货 
+export const createShelfReplenishBill = (params) => {
+  return axios.request({
+    url: 'shelfReplenish/createShelfReplenishBill',
+    data: params,
+    method: 'post'
+  })
 }

+ 8 - 1
components/kk-printer/index.vue

@@ -1,7 +1,8 @@
 <template>
 	<view class="kk-printer">
 		<view class="kk-printer-btn">
-			<u-button @tap="handlePrintTap" :loading="isPrinting" shape="circle" :custom-style="{background:$config('primaryColor')}" type="primary">{{isPrinting?printingText:defaultText}}</u-button>
+			<u-button v-if="printBtnStyle=='blue-large'" @tap="handlePrintTap" :loading="isPrinting" shape="circle" :custom-style="{background:$config('primaryColor')}" type="primary">{{isPrinting?printingText:defaultText}}</u-button>
+			<u-button v-if="printBtnStyle=='default-mid'" shape="circle" size="medium" hover-class="none" @tap="handlePrintTap" :loading="isPrinting">{{isPrinting?printingText:defaultText}}</u-button>
 		</view>
 		<view class="kk-shadow" :class="isShowSearch?'show':''" @tap="handleSearchClose">
 			<view class="kk-modal" @tap.stop="doNothing">
@@ -110,6 +111,11 @@
 				type:String,
 				default:'打印中...'
 			},
+			// 按钮样式
+			printBtnStyle:{
+				type: String,
+				default: 'blue-large'
+			},
 			roomcode:{
 				type:String, 
 				require:true
@@ -167,6 +173,7 @@
 			},
 			//点击打印按钮
 			handlePrintTap(){
+				this.$emit("hasProduct")
 				//打开蓝牙适配器
 				blesdk.openBlue().then((res)=>{
 					//获取已连接设备

+ 9 - 0
pages.json

@@ -424,6 +424,15 @@
             }
             
         }
+        ,{
+            "path" : "pages/shelfSetting/quickReplenish",
+            "style" :                                                                                    
+            {
+                "navigationBarTitleText": "快速补货",
+                "enablePullDownRefresh": false
+            }
+            
+        }
     ],
 	"globalStyle": {
 		"navigationBarTextStyle": "black",

+ 1 - 1
pages/shelfSetting/batchPrint.vue

@@ -3,7 +3,7 @@
 		<view class="batchPrint-manualPrint-body">
 			<u-alert-tips :show="show" @close="show = false" type="warning" description="正在打印中,请勿息屏或退出应用!"></u-alert-tips>
 			<view class="part-list">
-				<!-- 补货产品 -->
+				<!-- 产品 -->
 				<productList :list="partList" title="产品列表" ref="productList" noDataText="暂无产品" @allChecked="allCheckedCallback"></productList>
 			</view>
 		</view>

+ 179 - 0
pages/shelfSetting/quickProductList.vue

@@ -0,0 +1,179 @@
+<template>
+	<view class="partList-box flex flex_column">
+		<view class="partList-list">
+			<view class="partList-list-box" v-for="item in partList" :key="item.productSn">
+				<view class="product flex align_center">
+					<view class="checkbox">
+						<u-checkbox v-model="item.checked" :name="item.productSn" @change="checkChange" size="40" shape="circle"></u-checkbox>
+					</view>
+					<view class="flex align_center flex_1" @click="checkChange({name:item.productSn})">
+						<view class="pimgs">
+							<u-image :src="item.productImageUrl?item.productImageUrl:`../../static/${$config('themePath')}/def_img@2x.png`" width="128" height="128" border-radius="10"></u-image>
+						</view>
+						<view class="pinfo">
+							<view class="pname">
+								{{item.productCode}}
+							</view>
+							<view class="pname pname1">
+								{{item.productName}}
+							</view>
+						</view>
+					</view>
+				</view>
+				<view class="ptxt flex align_center justify_end">
+					<view>
+					最大库容:<text class="pnums">{{item.maxQty}}</text>
+					/ 当前库存:<text class="pnums">{{item.qty}}</text>
+					/ 补货在途:<text class="pnums">{{item.afloatQty||0}}</text>
+					</view>
+				</view>
+				<view class="ptools flex align_center justify_between">
+					<view></view>
+					<view class="pcurnums flex align_center">
+						<text>补货数量</text>
+						<view class="u-ninput">
+							<u-number-box color="#000" bg-color="#fff" v-model="item.printQty" :min="0" :max="item.maxQty"></u-number-box>
+						</view>
+					</view>
+				</view>
+			</view>
+			<view class="nodata" v-if="partList.length==0">
+				<u-empty :src="`/static/${$config('themePath')}/def_no_data@3x.png`" icon-size="120" :text="noDataText" img-width="120" mode="list"></u-empty>
+			</view>
+		</view>
+	</view>
+</template>
+
+<script>
+	export default {
+		props: {
+			list: {
+				type: Array,
+				default: function(){
+					return []
+				}
+			},
+			noDataText: {
+				type: String,
+				default: '暂无产品'
+			},
+			title: {
+				type: String,
+				default: '列表'
+			},
+			// model: checkbox 可选择模式,view 只显示
+			model: {
+				type: String,
+				default: 'checkbox'
+			},
+		},
+		data() {
+			return {
+				partList: [],
+			}
+		},
+		methods: {
+			setData(list){
+				const _this = this
+				list.map(item => {
+					item.printQty = item.replenishBillQty
+					item.checked = false
+				})
+				this.partList = JSON.parse(JSON.stringify(list))
+			},
+			// 全选
+			allSelect(val){
+				this.partList.map(item => {
+					item.checked = val
+				})
+				this.partList.splice()
+			},
+			checkChange(e){
+				const row = this.partList.find(item => item.productSn == e.name)
+				if(row){
+					row.checked = !row.checked
+					this.partList.splice()
+				}
+				// 判断是否全选
+				const isAllNoChecked = this.partList.filter(item => !item.checked)
+				this.$emit('allChecked',isAllNoChecked.length == 0)
+			},
+			// 获取所有选择的
+			getAllChecked(){
+				return this.partList.filter(item => item.checked && item.printQty)
+			},
+			// 获取所有数据
+			getAllData(){
+				return this.partList
+			},
+			// 数量 change
+			numberChange(value, index){
+				this.$emit('numberChange', value, index)
+			}
+		}
+	}
+</script>
+
+<style lang="less" scoped>
+.partList-box{
+	height: 100%;
+	position: relative;
+	.nodata{
+		padding: 10vh 0;
+	}
+	.partList-list{
+		flex-grow: 1;
+	}
+	.partList-list-box{
+		padding: 10px 0;
+		border-bottom: 2rpx solid #f5f5f5;
+		.product{
+			flex-grow: 1;
+			.checkbox{
+				width: 60rpx;
+			}
+			.pinfo{
+				flex-grow: 1;
+				padding-left: 20rpx;
+				.pname{
+					color: #191919;
+					margin-bottom: 5rpx;
+				}
+			}
+		}
+		.ptxt{
+			font-size: 28rpx;
+			color: #999;
+			.pnums{
+				color: #222;
+				padding: 0 4upx;
+			}
+		}
+		.ptools{
+			margin-top: 20rpx;
+			.pcurnums{
+				> text{
+					margin-right: 20rpx;
+				}
+			}
+			.u-ninput{
+				border: 2rpx solid #eee;
+				border-radius: 50rpx;
+				padding: 0 6rpx;
+			}
+			/deep/ .u-icon-disabled{
+				background: #fff!important;
+			}
+			/deep/ .u-number-input{
+				margin: 0 0;
+				border: 2rpx solid #eee;
+				border-top: 0;
+				border-bottom: 0;
+			}
+			/deep/ .u-icon-plus, /deep/ .u-icon-minus{
+				border-radius: 50rpx;
+			}
+		}
+	}
+}
+</style>

+ 214 - 0
pages/shelfSetting/quickReplenish.vue

@@ -0,0 +1,214 @@
+<template>
+	<view class="content flex flex_column">
+		<view class="head-info">
+			<view class="p-title flex align_center">
+				<view class="shelfName flex align_center"><text></text>{{basicInfoData.shelfName}}</view>
+			</view>
+			<view>系统检测到以下产品缺货,请选择需要补货的产品</view>
+		</view>
+		<view class="partlist">
+			<quickProductList :list="partList" ref="productList" noDataText="暂无产品" @allChecked="allCheckedCallback"></quickProductList>
+		</view>
+		<view class="part-footer flex align_item justify_between">
+			<view>
+				<u-checkbox size="40" @change="allCheckeChange" v-model="allChecked" shape="circle">{{allChecked?'取消全选':'全选'}}</u-checkbox>
+			</view>
+			<view class="btns flex align_item justify_end">
+				<kk-printer ref="kkprinter" @hasProduct="hasProduct" printBtnStyle="default-mid" defaultText="打印贴签" @startPrint="startPrint"></kk-printer>
+				<view style="padding: 0 10rpx;"></view>
+				<view>
+					<u-button class="handle-btn" shape="circle" size="medium" hover-class="none" :custom-style="customBtnStyle" @click="replenish()">快速补货</u-button>
+				</view>
+			</view>
+		</view>
+	</view>
+</template>
+
+<script>
+	import quickProductList from './quickProductList.vue'
+	import kkPrinter from '@/components/kk-printer/index.vue';
+	import {printTempl} from '@/libs/printTools.js'
+	export default {
+		components: { quickProductList, kkPrinter },
+		data() {
+			return {
+				show: false,
+				basicInfoData:null,
+				partList: [],
+				allChecked: false,
+				printIndex: 0,
+				isParinting: false,
+				customBtnStyle: {  //  自定义按钮样式
+					borderColor: this.$config('primaryColor'),
+					backgroundColor: this.$config('primaryColor'),
+					color: '#fff'
+				},
+			}
+		},
+		onReady() {
+			uni.setNavigationBarColor({
+				frontColor: '#ffffff',
+				backgroundColor: this.$config('primaryColor')
+			})
+			this.$refs.productList.setData(this.partList)
+		},
+		onLoad(option) {
+			this.basicInfoData = JSON.parse(decodeURIComponent(option.data));
+			this.partList = this.basicInfoData.list
+			// 保持屏幕常亮
+			uni.setKeepScreenOn({
+				keepScreenOn: true
+			});
+		},
+		onUnload() {
+			this.partList = []
+			// 保持屏幕常亮
+			uni.setKeepScreenOn({
+				keepScreenOn: false
+			});
+		},
+		onBackPress(event){
+			if(event.from == 'backbutton'){
+				if(this.isParinting){
+					uni.showToast({
+						icon:'none',
+						title: '正在打印中...'
+					})
+				}else{
+					uni.navigateBack({delta: 1})
+				}
+				return true  // 阻止默认返回行为(会导致无限循环)
+			}
+		},
+		methods: {
+			// 全选
+			allCheckeChange(e){
+				this.$refs.productList.allSelect(e.value)
+			},
+			allCheckedCallback(val){
+				this.allChecked = val
+			},
+			hasProduct(){
+				const result =this.$refs.productList.getAllChecked()
+				if(!result.length){
+					this.toashMsg("请选择产品!")
+				}
+			},
+			// 补货
+			replenish(){
+				const result =this.$refs.productList.getAllChecked()
+				if(result.length){
+				}else{
+					this.toashMsg("请选择产品!")
+				}
+			},
+			printOnce(opt,tsc,blesdk,data){
+				const _this = this
+				const dealer = this.$store.state.vuex_userData
+				// 60*40 打印模板
+				const command = printTempl(tsc,{
+					dealerName: dealer.orgName,
+					shelfName: data.shelfName || '',
+					productCode: data.productCode || '',
+					productName: data.productName || '',
+					shelfPlaceCode: data.shelfPlaceCode || '',
+					currentInven: data.printQty,
+					printDate: this.$u.timeFormat(this.timestamp, 'yyyy-mm-dd hh:MM'),
+					printUser: dealer.userNameCN,
+					barCode: `${data.shelfSn}&${data.productCode}&${data.productSn}&${data.shelfPlaceSn}`
+				})
+				// 开始批量打印 
+				blesdk.senBlData(
+				opt.deviceId, 
+				opt.serviceId, 
+				opt.writeId, 
+				command.getData(), 
+				function(){
+					const result =_this.$refs.productList.getAllChecked()
+					_this.printIndex = _this.printIndex + 1
+					if(_this.printIndex < result.length){
+						_this.printOnce(opt,tsc,blesdk,result[_this.printIndex])
+					}else{
+						_this.printIndex = 0
+						_this.$refs.kkprinter.onPrintSuccess()
+						_this.isParinting = false
+						_this.show = false
+					}
+				});
+			},
+			// 批量打印 
+			startPrint(opt,tsc,blesdk){
+				const result =this.$refs.productList.getAllChecked()
+				console.log(result,result.length)
+				if(result.length){
+					 if(this.isParinting){
+					 	return
+					 }
+					 this.isParinting = true
+					 this.show = true
+					 this.printOnce(opt,tsc,blesdk,result[this.printIndex])
+				}else{
+					this.toashMsg("请选择产品!")
+					this.$refs.kkprinter.onPrintFail()
+				}
+			},
+		}
+	}
+</script>
+
+<style lang="less">
+	.content{
+		width: 100%;
+		height: 100vh;
+		background: #fff;
+		.head-info{
+			padding: 10rpx;
+			border-bottom: 2rpx solid #eee;
+			> view{
+				padding: 5rpx 10rpx;
+			}
+			.p-title{
+				padding: 0 20rpx;
+				display: flex;
+				align-items: center;
+				color: #222;
+				font-size: 32rpx;
+				.shelfName{
+					flex-grow: 1;
+					font-weight: bold;
+					text{
+						display: block;
+						height: 30rpx;
+						width: 6rpx;
+						background: #0485F6;
+						margin-right: 10rpx;
+						border-radius: 10rpx;
+					}
+				}
+			}
+		}
+		.partlist{
+			flex-grow: 1;
+			padding: 0 30rpx;
+			overflow: auto;
+		}
+		.part-footer{
+			padding: 15rpx 30rpx;
+			border-top: 2rpx solid #eee;
+			> view{
+				&:first-child{
+					width: 30%;
+					text-align: left;
+					padding-top: 10rpx;
+				}
+				text-align: right;
+			}
+			.btns{
+				flex-grow: 1;
+				button{
+					width: 200rpx;
+				}
+			}
+		}
+	}
+</style>

+ 35 - 4
pages/shelfSetting/shelfSet.vue

@@ -16,12 +16,12 @@
 				</view>
 			</view>
 			<view class="card-row align_center flex justify_between">
-				<view class="label" style="width: 50%;" @click="showTip">是否设置完成 <u-icon color="#2979ff" name="question-circle"></u-icon></view>
+				<view class="label" style="width: 50%;" @click="showTip">是否设置完成 <u-icon color="#ffaa00" name="question-circle"></u-icon></view>
 				<view class="text" style="width: 50%;text-align: right;"><u-switch v-model="switchVal" @change="switchChange"></u-switch></view>
 			</view>
 		</view>
 		<!-- 货位信息 -->
-		<view class="shelfPlace">
+		<view class="shelfPlace" v-if="shelfPlaceList">
 			<view class="flex align_center shelfPlaceHead">
 				<view class="lt"><text>□</text>表示没有绑定产品</view>
 				<view class="search-btn flex align_center" @click="toSearchHw">
@@ -29,7 +29,7 @@
 					<u-icon name="scan"></u-icon>
 				</view>
 			</view>
-			<view class="flex shelfTabs" v-if="shelfPlaceList">
+			<view class="flex shelfTabs">
 				<view class="leftTabs">
 					<view v-for="item in placeTab" :key="item" :class="curTab==item?'active':''" @click="tabChange(item)">{{item}}层</view>
 				</view>
@@ -47,6 +47,9 @@
 				</view>
 			</view>
 		</view>
+		<view v-else>
+			<view class="nodata">暂无货位信息,请点击 <text @click="addHw('add',0)">新增货位</text></view>
+		</view>
 		<chunLeiPopups v-model="showMenus" theme="dark" :popData="popData" @tapPopup="tapPopup" :x="pleft" :y="ptop" placement="bottom-start"></chunLeiPopups>
 	</view>
 </template>
@@ -54,6 +57,7 @@
 <script>
 	import chunLeiPopups from "@/components/chunLei-popups/chunLei-popups.vue";
     import { shelfDetail, shelfSave, modifFinishFlag, getProductPlace } from '@/api/shelf'
+	import { createShelfReplenishBill } from '@/api/shelfReplenish'
 	export default {
 		components:{chunLeiPopups},
 		data() {
@@ -109,7 +113,22 @@
 				}
 				// 快速补货
 				if(e.val == 0){
-					
+					createShelfReplenishBill({shelfSn: this.shelfSn}).then(res => {
+						console.log(res.data)
+						if(res.data&&res.data.length){
+							const params = Object.assign(this.detailData,{list:res.data})
+							uni.navigateTo({
+								url: "/pages/shelfSetting/quickReplenish?data="+encodeURIComponent(JSON.stringify(params))
+							})
+						}else{
+							uni.showModal({
+								showCancel:false,
+								confirmText:"好的",
+								title: "提示",
+								content: "没有需要补货的产品"
+							})
+						}
+					})
 				}
 			},
 			showTip(){
@@ -212,12 +231,16 @@
 				getProductPlace({ shelfSn: this.shelfSn }).then(res => {
 				  if (res.status == 200) {
 				    this.shelfPlaceList = res.data
+					console.log(res.data)
 					for(let a in res.data){
 						this.placeTab.push(a)
 					}
 					if(!flag){
 					  this.curTab = this.placeTab[0]
 					}
+					if(this.placeTab.length == 0){
+						this.shelfPlaceList = null
+					}
 				  } else {
 				    this.shelfPlaceList = null
 				  }
@@ -233,6 +256,14 @@
 <style lang="less">
 .content{
 	width:100%;
+	.nodata{
+		padding: 100rpx 50rpx;
+		text-align: center;
+		> text{
+			color: #00aaff;
+			margin-left: 10rpx;
+		}
+	}
 }
 .card-box{
 	background-color: #fff;