lilei 1 year ago
parent
commit
89ed87e202

+ 5 - 3
config/api.js

@@ -120,12 +120,14 @@ export const receivingStockList = (params, config = {}) => http.post(`/receiving
 //  入库审核 列表  有分页
 export const receivingAuditList = (params, config = {}) => http.post(`/receiving/queryStockInAuditPage/${params.pageNo}/${params.pageSize}`, params, config)
 // 修改入库数量
-export const updateRealPutQty = (params, config = {}) => http.post(`/receivingDetail/updateRealPutQty/${params.productSn}`, params, config)
+export const updateRealPutQty = (params, config = {}) => http.post(`/receivingDetail/updateRealPutQty`, params, config)
 // 采购入库详细列表
 export const receivingDetail = (params, config = {}) => http.post(`/receivingDetail/queryPage/${params.pageNo}/${params.pageSize}`, params, config)
 // 采购入库详情
 export const receivingQuery = (params, config = {}) => http.post(`/receiving/query`, params, config)
 //  采购 入库
-export const purchaseWriteStockIn = (params, config = {}) => http.post(`/receiving/stockIn`, params, config)
+export const purchaseWriteStockIn = (params, config = {}) => http.post(`/receiving/pdaStockIn`, params, config)
 //  采购入库 修改仓库仓位
-export const purchaseUpdateWarehouse = (params, config = {}) => http.post(`/receivingDetail/updateWarehouse`, params, config)
+export const purchaseUpdateWarehouse = (params, config = {}) => http.post(`/receivingDetail/updateWarehouse`, params, config)
+// 采购入库 校验数量
+export const receivingStockInVerify = (data) => http.get(`/receiving/stockInVerify/${data.receivingBillSn}`, data)

+ 121 - 0
pages/purchasing/chooseWarehouse.vue

@@ -0,0 +1,121 @@
+<template>
+	<u-picker
+	:show="showPick" 
+	:closeOnClickOverlay="true" 
+	ref="uPicker" 
+	title="选择仓库仓位" 
+	:columns="pickItem" 
+	:defaultIndex="defaultIndex"
+	keyName="name" 
+	@confirm="confirmWarehouse"
+	@close="showPick=false" 
+	@cancel="showPick=false" 
+	@change="changePick"></u-picker>
+</template>
+
+<script>
+	export default{
+		props:{
+			value: {
+				type: Array,
+				default: function(){
+					return [null,null]
+				}
+			},
+			openPick: {
+				type: Boolean,
+				default: false
+			}
+		},
+		data(){
+			return {
+				showPick: this.openPick,
+				pickItem: [],
+				defaultIndex: [],
+				defaultName: []
+			}
+		},
+		watch: {
+			openPick (a,b){
+				console.log(a)
+				this.showPick = a
+				if(a){
+					// 仓库列表
+					this.getWarehousePick()
+					if(this.value&&this.value[0]&&this.value[1]){
+						const list = this.$store.state.vuex_warehouseList
+						const w = list.findIndex(item => item.warehouseSn == this.value[0])
+						const sc = list[w].warehouseLocationList
+						if(w>=0 && sc){
+							const s = sc.findIndex(item => item.warehouseLocationSn == this.value[1])
+							this.defaultIndex = [w||0,s||0]
+							this.defaultName = [list[w||0].name,sc[s||0].name]
+						}
+					}else{
+						this.defaultIndex = [0,0]
+					}
+				}
+			},
+			showPick(a,b){
+				if(!a){
+					this.$emit('close')
+				}
+			}
+		},
+		methods:{
+			 getDefName(){
+				return this.defaultName
+			 },
+			 getWarehousePick(){
+			 	const col1 = []
+			 	const col2 = []
+				const list = this.$store.state.vuex_warehouseList
+				const s = this.value && this.value[0] ? list.findIndex(item => item.warehouseSn == this.value[0]) : 0
+			 	list.map((item,index) => {
+			 		col1.push(item)
+			 		if(index == s && item.warehouseLocationList){
+			 			item.warehouseLocationList.map(k => {
+			 				col2.push(k)
+			 			})
+			 		}
+			 	})
+			 	this.pickItem = [col1,col2]
+			 },
+			 // 选择仓库
+			 changePick(e){
+			 	const {
+			 		columnIndex,
+			 		index,
+			 		// 微信小程序无法将picker实例传出来,只能通过ref操作
+			 		picker = this.$refs.uPicker
+			 	} = e
+			 	console.log(columnIndex,index)
+			 	if (columnIndex === 0) {
+			 		const currow = this.pickItem[0][index]
+			 		const col2 = []
+			 		currow&&currow.warehouseLocationList.map(item => {
+			 			col2.push(item)
+			 		})
+			 		picker.setColumnValues(1, col2)
+			 	}
+			 },
+			 // 确定选择仓库
+			 confirmWarehouse(e){
+			 	console.log(e.indexs)
+			 	const indexs = e.indexs
+			 	const currow = this.pickItem[0][indexs[0]]
+			 	if(currow){
+			 		const warehouseSn = currow.warehouseSn
+			 		const curcol = currow.warehouseLocationList[indexs[1]]
+			 		if(curcol){
+			 			const warehouseLocationSn = curcol.warehouseLocationSn
+						this.$emit("change", [warehouseSn,warehouseLocationSn])
+			 		}
+			 	}
+			 },
+		}
+	}
+</script>
+
+<style>
+</style>

+ 146 - 71
pages/purchasing/index.vue

@@ -11,19 +11,23 @@
 				</view>
 			</view>
 			<view>
-				<text>发货单号:</text>
-				<text style="color: crimson;">{{baseData[0].sendBillNo}}</text>
+				<view>
+					<text>发货单号:</text>
+					<text style="color: crimson;">{{baseData[0].sendBillNo}}</text>
+				</view>
 			</view>
 			<view>
-				<text>条码:</text>
 				<view>
-					<input
-					@blur="addQty(true)"
-					style="width: 100%;text-align: left;" 
-					class="uni-input" 
-					placeholder="扫描或输入条码" 
-					border="surround" 
-					v-model="code">
+					<text>条码:</text>
+					<view>
+						<input
+						@blur="addQty(true)"
+						style="width: 100%;text-align: left;" 
+						class="uni-input" 
+						placeholder="扫描或输入条码" 
+						border="surround" 
+						v-model="code">
+					</view>
 				</view>
 			</view>
 			<view style="justify-content: flex-start;flex-wrap: wrap;"  v-for="(item,bindex) in baseData" :key="item.id">
@@ -39,16 +43,27 @@
 				<!-- 表头行 -->
 				<uni-tr>
 					<uni-td align="center">产品编码</uni-td>
-					<uni-td align="center">产品分类</uni-td>
+					<uni-td align="center">仓库仓位</uni-td>
 					<uni-td align="center">入库/发货数量</uni-td>
 					<uni-td align="center">入库金额</uni-td>
 				</uni-tr>
 				<!-- 表格数据行 -->
-				<uni-tr v-for="item in detailList" :key="item.id" :checkedRow="curProduct&&curProduct.dealerProductEntity.qrCode == item.dealerProductEntity.qrCode">
-					<uni-td width="30%" align="center">{{item.dealerProductEntity.code}}</uni-td>
-					<uni-td width="30%" align="center">{{item.dealerProductEntity.productTypeName3}}</uni-td>
-					<uni-td width="25%" align="center"><text style="color: red;">{{item.realPutQty}}</text>/{{item.putQty}}</uni-td>
-					<uni-td width="15%" align="center">
+				<uni-tr 
+				v-for="item in detailList" 
+				:key="item.id" 
+				:checkedRow="curProduct&&curProduct.dealerProductEntity.qrCode == item.dealerProductEntity.qrCode"
+				>
+					<uni-td width="30%" align="center">
+						<view @click="copyText(item.dealerProductEntity.code)">{{item.dealerProductEntity.code}}</view>
+					</uni-td>
+					<uni-td width="30%" align="center">
+						<view @click="editRow(item)">
+							<view>{{item.warehouseEntity&&item.warehouseEntity.name||defWarehouseName[0]}}/</view>
+							<view>{{item.warehouseLocationEntity&&item.warehouseLocationEntity.name||defWarehouseName[1]}}</view>
+						</view>
+					</uni-td>
+					<uni-td width="20%" align="center"><text style="color: red;">{{item.realPutQty}}</text>/{{item.putQty}}</uni-td>
+					<uni-td width="20%" align="center">
 						 {{item.realPutAmount}}
 					</uni-td>
 				</uni-tr>
@@ -59,28 +74,52 @@
 			<button size="mini" type="primary" @click="addQty(true)"> <text class="iconfont icon-add-btn"> 加 </text></button>
 		</view>
 		<scanCode @onKeyDown="keyDown"></scanCode>
-		<u-picker 
-		:show="showPick" 
-		:closeOnClickOverlay="true" 
-		ref="uPicker" 
-		title="选择仓库仓位" 
-		:columns="pickItem" 
-		keyName="name" 
-		@close="showPick=false" 
-		@cancel="showPick=false" 
-		@change="changePick"></u-picker>
+		 <!-- 选择仓库 -->
+		<chooseWarehouse ref="chooseWarehouse" :openPick="showPick" :value="defWarehouse" @close="showPick=false" @change="confirmWarehouse"></chooseWarehouse>
+		<!-- 左键扫描,修改包装数 -->
+		<uni-popup ref="popup" :mask-click="false" type="dialog">
+			<view style="background-color: #fff;padding: 30rpx 50rpx;border-radius: 30rpx;width: 75%;margin: 0 auto;">
+				<view v-if="curProduct">
+					<view style="padding: 30rpx 0;">
+						产品编码:{{curProduct.dealerProductEntity.code}}
+					</view>
+					<view style="display: flex;align-items: center;">
+						数量:
+						<u--input
+						    placeholder="请输入数量"
+						    border="surround"
+						    v-model="curProduct.packQty"
+							:min="0"
+							type="digit"
+						  ></u--input>
+						  {{curProduct.dealerProductEntity.unit}}
+						  {{curProduct.dealerProductEntity.packQtyUnit?("/"+curProduct.dealerProductEntity.packQtyUnit):''}}
+					</view>
+				</view>
+				<view style="display: flex;padding: 60rpx 15rpx 10rpx;justify-content: space-between;">
+					<button size="mini" @click="closePop">取消</button>
+					<button size="mini" type="primary" @click="okPop">确定</button>
+				</view>
+			</view>
+		</uni-popup>
+		
+		<u-modal :show="showModal" :title="msg.title" :confirmText="msg.confirmText" showCancelButton :content='msg.content' @cancel="showModal=false" @confirm="confirmModal"></u-modal>
 	</view>
 </template>
 
 <script>
 	import scanCode from '@/libs/scan-code.vue';
-	import { purchaseWriteStockIn, receivingQuery, receivingDetail, purchaseUpdateWarehouse, updateRealPutQty } from '@/config/api.js'
+	import { purchaseWriteStockIn, receivingQuery, receivingDetail, purchaseUpdateWarehouse, updateRealPutQty, receivingStockInVerify } from '@/config/api.js'
 	import { playAudio, toThousands } from '@/libs/tools.js'
+	import clipboard from "@/js_sdk/dc-clipboard/clipboard.js"
+	import chooseWarehouse from './chooseWarehouse.vue'
 	export default {
-		components: { scanCode },
+		components: { scanCode, chooseWarehouse },
 		data() {
 			return {
 				loading: false,
+				showModal: false,
+				msg:{title:'提示',content:''},
 				showPick: false,
 				baseData: null,
 				detailList:[],
@@ -89,36 +128,40 @@
 				salesId: null,
 				curProduct: null,
 				toThousands,
-				warehouseList: [],
-				pickItem: [],
+				defWarehouse: [],
+				defWarehouseName:[],
 				keyName: ''
 			};
 		},
 		onLoad(opts) {
 		  var _this = this
-		  this.warehouseList = this.$store.state.vuex_warehouseList
 		  this.receivingBillSn = opts.receivingBillSn
 		  this.salesId = opts.id
+		  // 默认仓库仓位
+		  this.defWarehouse = this.$store.state.vuex_tempData
 		  
-		  // 仓库列表
-		  this.getWarehousePick()
-		  
+		  // 调用数据
 		  this.getDetail()
 		  this.getDetailList()
 		  
 		  uni.$on('scancodedate', function(content) {
-			  console.log("扫描到的内容为:", content, this.keyName)
-			  if(this.keyName == 'rightKey'){
-				  _this.code = content||''
+			  console.log("扫描到的内容为:", content, _this.keyName)
+			  _this.code = content||''
+			  if(_this.keyName == 'rightKey'){
 				  _this.addQty(true)
 			  }
-			  if(this.keyName == 'leftKey'){
-			  				  
+			  if(_this.keyName == 'leftKey'){
+				_this.openPack()
 			  }
 		  })
 		},
 		onShow() {
 			this.hideKeyborder()
+			const list = this.$store.state.vuex_warehouseList
+			const an =list.find(item => item.warehouseSn==this.defWarehouse[0])
+			const cn = an&&an.warehouseLocationList&&an.warehouseLocationList.find(item => item.warehouseLocationSn == this.defWarehouse[1])
+			this.defWarehouseName = [an&&an.name,cn&&cn.name]
+			console.log(this.defWarehouseName)
 		},
 		onUnload() {
 			uni.$off('scancodedate')
@@ -127,48 +170,48 @@
 			hideKeyborder(){
 				uni.hideKeyboard()
 			},
+			// 复制
+			copyText(text){
+				clipboard.setText(text);
+				uni.showToast({
+					icon: 'none',
+					title: '编码已复制成功'
+				})
+			},
+			closePop(){
+				this.$refs.popup.close()
+			},
+			okPop(){
+				if(this.curProduct.packQty){
+					this.changePutQty(this.curProduct,Number(this.curProduct.realPutQty) + Number(this.curProduct.packQty))
+					this.closePop()
+				}else{
+					uni.$u.toast("请输入数量!")
+				}
+			},
 			keyDown(e){
 				this.keyName = e
 			},
-			getWarehousePick(){
-				const col1 = []
-				const col2 = []
-				this.warehouseList.map((item,index) => {
-					col1.push(item)
-					if(index == 0 && item.warehouseLocationList){
-						item.warehouseLocationList.map(k => {
-							col2.push(k)
-						})
-					}
-				})
-				this.pickItem = [col1,col2]
-				// this.showPick = true
+			// 确定选择仓库
+			confirmWarehouse(data){
+				console.log(data)
+				this.updateWarehouse({id:this.curProduct.id,warehouseSn:data[0],warehouseLocationSn:data[1]})
 			},
-			// 选择仓库
-			changePick(e){
-				const {
-					columnIndex,
-					index,
-					// 微信小程序无法将picker实例传出来,只能通过ref操作
-					picker = this.$refs.uPicker
-				} = e
-				console.log(columnIndex,index)
-				if (columnIndex === 0) {
-					const currow = this.pickItem[0][index]
-					const col2 = []
-					currow&&currow.warehouseLocationList.map(item => {
-						col2.push(item)
-					})
-					picker.setColumnValues(1, col2)
-				}
+			// 修改仓库
+			editRow(item){
+				this.showPick = true
+				this.curProduct = item
 			},
+			// 获取当前操作行
 			getCurRow(){
 				const curProduct = this.detailList.find(item => item.dealerProductEntity.qrCode == this.code)
 				this.curProduct = curProduct || null
+				this.curProduct.packQty = this.curProduct.dealerProductEntity.packQty || 0
 				return curProduct
 			},
 			// 修改仓库
 			updateWarehouse (row) {
+			  console.log(row)
 			  this.loading = true
 			  purchaseUpdateWarehouse({
 				id: row.id,
@@ -176,6 +219,7 @@
 				warehouseLocationSn: row.warehouseLocationSn
 			  }).then(res => {
 				if (res.status == 200) {
+				  this.showPick = false
 				  this.getDetailList()
 				}
 				this.loading = false
@@ -205,7 +249,11 @@
 				}
 				const row = this.getCurRow()
 				if(row){
-					this.changePutQty(row,row.realPutQty + (flag?1:-1))
+					if(row.warehouseLocationSn){
+						this.changePutQty(row,row.realPutQty + (flag?1:-1))
+					}else{
+						uni.$u.toast("此商品没有仓库仓位")
+					}
 				}else{
 					uni.$u.toast("此商品不存在")
 				}
@@ -229,13 +277,40 @@
 					}
 				})
 			},
+			// 打开包装数弹框
+			openPack(){
+				const curProduct = this.getCurRow()
+				if(curProduct){
+					this.$refs.popup.open()
+				}else{
+					uni.$u.toast("此商品不存在")
+				}
+			},
 			// 入库
 			async toOut(){
-				const ret = await salesWriteStockOut({receivingBillSn: this.receivingBillSn})
+				const isOk = await receivingStockInVerify({receivingBillSn:this.receivingBillSn})
+				if(!isOk.data){
+					this.submitForm()
+				}else{
+					this.showModal = true
+					this.msg = {
+						title: '提示',
+						content: '有产品入库数量与发货数量不一致',
+						confirmText: '确定入库'
+					}
+				}
+			},
+			confirmModal(e){
+				this.submitForm()
+			},
+			async submitForm(){
+				const a = this.defWarehouse
+				const ret = await purchaseWriteStockIn({id: this.baseData[0].id,warehouseSn:a[0], warehouseLocationSn:a[1]})
 				if(ret.status == 200){
 					this.$store.state.vuex_isRefash = true
 					uni.navigateBack()
 				}
+				this.showModal = false
 			}
 		},
 	}

+ 52 - 40
pages/purchasing/list.vue

@@ -1,40 +1,45 @@
 <template>
-	<u-cell-group>
-	    <u-cell
-	        center
-			isLink
-			v-for="item in list"
-			:key="item.id"
-			@click="toEdit(item)"
-	    >
-		<view slot="label">
-			<view class="u-kh">
-				<view>
-					{{item.purchaseBillNo}}
+	<view>
+		<u-cell-group>
+		    <u-cell
+		        center
+				isLink
+				v-for="item in list"
+				:key="item.id"
+				@click="toEdit(item)"
+		    >
+			<view slot="label">
+				<view class="u-kh">
+					<view>
+						{{item.purchaseBillNo}}
+					</view>
 				</view>
+				<view class="u-time">
+					发货单号: {{item.sendBillNo}}
+				</view>
+				<view class="u-time">创建时间:{{item.createDate}}</view>
+				<view class="u-time" v-if="item.stockPutTime">入库时间:{{item.stockPutTime}}</view>
+			</view>
+			<view slot="value">
+				<text class="u-text" :style="{color: (item.auditState == 'PUT_WAREHOUSE_AUDIT_REJECT'|| item.auditState == 'WAIT_PUT_WAREHOUSE') ? '#00aaff' : '#999'}">{{item.auditStateDictValue}}</text>
+			</view>
+			</u-cell>
+			<view v-if="list.length==0&&status != 'loading'">
+				<u-empty :iconSize="60" text="暂无数据" :marginTop="100"></u-empty>
 			</view>
-			<view class="u-time">
-				发货单号: {{item.sendBillNo}}
+			<view style="padding: 30rpx 0;">
+				<u-loadmore :status="status" />
 			</view>
-			<view class="u-time">创建时间:{{item.createDate}}</view>
-			<view class="u-time" v-if="item.stockPutTime">入库时间:{{item.stockPutTime}}</view>
-		</view>
-		<view slot="value">
-			<text class="u-text" :style="{color: (item.auditState == 'PUT_WAREHOUSE_AUDIT_REJECT'|| item.auditState == 'WAIT_PUT_WAREHOUSE') ? '#00aaff' : '#999'}">{{item.auditStateDictValue}}</text>
-		</view>
-		</u-cell>
-		<view v-if="list.length==0&&status != 'loading'">
-			<u-empty :iconSize="60" text="暂无数据" :marginTop="100"></u-empty>
-		</view>
-		<view style="padding: 30rpx 0;">
-			<u-loadmore :status="status" />
-		</view>
-	</u-cell-group>
+		</u-cell-group>
+		<chooseWarehouse :openPick="openPick" @close="openPick=false" @change="changeWarehouse"></chooseWarehouse>
+	</view>
 </template>
 
 <script>
 	import { receivingStockList } from '@/config/api.js'
+	import chooseWarehouse from './chooseWarehouse.vue'
 	export default{
+		components: { chooseWarehouse },
 		data(){
 			return {
 				list: [],
@@ -42,22 +47,22 @@
 				pageNo: 1,
 				total: 0,
 				status: 'loadmore',
-				warehouseList: []
+				warehouseList: [],
+				openPick: false,
+				editRow: null
 			}
 		},
 		onLoad() {
 			var _this = this
 			this.status = 'loading'
 			this.getList()
-			
-			// 刷新
-			uni.$on('refashList', function(content) {
-				_this.status = 'loading'
-				_this.getList()
-			})
 		},
-		onUnload() {
-			uni.$off("refashList")
+		onShow() {
+			if(this.$store.state.vuex_isRefash){
+				this.pageNo = 1
+				this.getList()
+				this.$store.state.vuex_isRefash = false
+			}
 		},
 		methods:{
 			getList(){
@@ -81,11 +86,18 @@
 			toEdit(item){
 				// 入库
 				if(item.auditState == 'PUT_WAREHOUSE_AUDIT_REJECT' || item.auditState == 'WAIT_PUT_WAREHOUSE'){
-					uni.navigateTo({
-						url:"/pages/purchasing/index?receivingBillSn="+item.receivingBillSn+"&id="+item.id
-					})
+					this.editRow = item
+					this.openPick = true
 				}
 			},
+			changeWarehouse(e){
+				console.log(e)
+				this.$store.state.vuex_tempData = e
+				this.openPick = false
+				uni.navigateTo({
+					url:"/pages/purchasing/index?receivingBillSn="+this.editRow.receivingBillSn+"&id="+this.editRow.id
+				})
+			},
 			onReachBottom(){
 				const pageNums = Math.ceil(this.total / this.pageSize)
 				if(this.pageNo < pageNums){

File diff suppressed because it is too large
+ 0 - 0
unpackage/dist/dev/app-plus/app-service.js


File diff suppressed because it is too large
+ 109 - 81
unpackage/dist/dev/app-plus/app-view.js


Some files were not shown because too many files changed in this diff