浏览代码

绑定货架

lilei 2 年之前
父节点
当前提交
fc286f2a47

+ 1 - 1
App.vue

@@ -5,7 +5,7 @@
 			token: '',
 			changeOrg:'',
 			version: '', // 当前版本号
-			buildType: 'uat', // 打包环境对应类型,pro 生产 uat 预发布 dev 本地开发
+			buildType: 'dev', // 打包环境对应类型,pro 生产 uat 预发布 dev 本地开发
 			envTips: '', // 环境文字提示
 			theme: 'default', // 主题,default
 			isIphoneXup: false //是否iphonex以及以上的版本

+ 51 - 0
api/shelf.js

@@ -53,4 +53,55 @@ export const modifFinishFlag = (params) => {
     data: params,
     method: 'post'
   })
+}
+// 新增货位
+export const addPlaceAndProduct = (params) => {
+  return axios.request({
+    url: `shelf/placeAndProduct/save`,
+    data: params,
+    method: 'post'
+  })
+}
+// 删除货位
+export const delShelfPlaceSn = (params) => {
+  return axios.request({
+    url: `shelf/place/deleteBySn/${params.shelfPlaceSn}`,
+    data: params,
+    method: 'post'
+  })
+}
+// 绑定产品
+export const bindProductList = (params) => {
+	let url = `product/queryPageForXPRH/${params.pageNo}/${params.pageSize}`
+	delete params.pageNo
+	delete params.pageSize
+	return axios.request({
+		url: url,
+		data: params,
+		method: 'post'
+	})
+}
+// 查询货位
+export const getProductPlace = (params) => {
+  return axios.request({
+    url: `shelf/app/placeProduct/queryList`,
+    data: params,
+    method: 'post'
+  })
+}
+//  货架  货位产品 详情
+export const shelfProductDetail = (params) => {
+  return axios.request({
+    url: `shelf/placeProduct/queryByPlaceSn/${params.shelfPlaceSn}`,
+    data: params,
+    method: 'get'
+  })
+}
+//  货架  货位产品 保存
+export const shelfProductSave = (params) => {
+  return axios.request({
+    url: `shelf/placeProduct/save`,
+    data: params,
+    method: 'post'
+  })
 }

+ 1 - 1
config/index.js

@@ -6,7 +6,7 @@ const getConfig = (theme) => {
 			themePath: 'default',
 			pro_URL: 'https://iscm.360arrow.com/qpls-md/', // 生产地址
 			uat_URL: 'http://p.iscm.360arrow.com/qpls-md/', // 预发布地址
-			dev_URL: 'http://192.168.0.102/qpls-md/', // 本地地址
+			dev_URL: 'http://192.168.0.215:8076/qpls-md/', // 本地地址
 			appName: 'iSCM智慧供应链', // app 名称
 			company: '陕西山海高科信息技术有限公司',
 			loadText:{

+ 9 - 0
pages.json

@@ -394,6 +394,15 @@
             }
             
         }
+        ,{
+            "path" : "pages/shelfSetting/bindProduct",
+            "style" :                                                                                    
+            {
+                "navigationBarTitleText": "绑定产品",
+                "enablePullDownRefresh": false
+            }
+            
+        }
     ],
 	"globalStyle": {
 		"navigationBarTextStyle": "black",

+ 3 - 3
pages/sales/chooseCustomer.vue

@@ -23,9 +23,9 @@
 				placeholder="请输入客户名称搜索" 
 				v-model="queryWord" 
 				height="90"
-				@input="searchBrand"
-				@blur="searchBrand"
-				@search="searchBrand"
+				@input="$u.debounce(searchBrand, 500)"
+				@blur="$u.debounce(searchBrand, 500)"
+				@search="$u.debounce(searchBrand, 500)"
 				@clear="clearSearch"
 				:showAction="false">
 			</u-search>

+ 122 - 20
pages/shelfSetting/addShelfHw.vue

@@ -1,70 +1,114 @@
 <template>
 	<view class="content flex flex_column">
 		<view class="form-body">
-			<u-form :model="form" label-width="180rpx" :error-type="['toast']" ref="uForm">
+			<u-form :model="form" label-width="155rpx" :error-type="['toast']" ref="uForm">
 				<u-form-item label="货位号" required prop="shelfPlaceCode">
 					<u-input v-model="form.shelfPlaceCode" :maxlength="30" placeholder="请输入货位号(最多30个字符)"/>
 				</u-form-item>
-				<u-form-item label="绑定产品">
-					<view style="flex-grow: 1;color: #c3c9ce;">{{productEntity&&productEntity.productCode||'请输入产品编码搜索'}}</view>
-					<u-icon name="scan" size="45" color="#999"></u-icon>
+				<u-form-item label="绑定产品" v-show="type=='add'">
+					<view style="flex-grow: 1;" v-if="productEntity&&productEntity.code" @click="toBindProduct">
+						{{productEntity&&productEntity.code}}
+					</view>
+					<view style="flex-grow: 1;color: #c3c9ce;" @click="toBindProduct" v-else>
+						请输入产品编码搜索
+					</view>
+					<u-icon name="arrow-right" color="#999" @click="toBindProduct"></u-icon>
 				</u-form-item>
-				<u-form-item label="" v-if="productEntity">
+				<u-form-item label="" v-show="productEntity">
 					<view class="flex align_center">
 						<view class="pimgs">
-							<u-image :src="productEntity&&productEntity.images?productEntity.images:`../../static/${$config('themePath')}/def_img@2x.png`" width="128" height="128" border-radius="10"></u-image>
+							<u-image :src="productEntity&&productEntity.productMsg?productEntity.productMsg:`../../static/${$config('themePath')}/def_img@2x.png`" width="128" height="128" border-radius="10"></u-image>
 						</view>
 						<view class="pinfo flex_1">
 							<view class="pname">
-								{{productEntity&&productEntity.productName}}
+								{{productEntity&&productEntity.name}}
 							</view>
 							<view class="ptxt">
-								<text class="pcode">解除绑定</text>
+								<text class="pcode" @click="clearBind">解除绑定</text>
 							</view>
 						</view>
 					</view>
 				</u-form-item>
 				<u-form-item label="销售价" v-if="productEntity" required prop="price">
-					<u-input :clearable="false" type="digit" :min="0" :maxlength="8" @input="numberToFixed('price',2,999999)" v-model.trim="form.price" placeholder="请输入销售价,最多两位小数"/>
+					<u-input clearable type="number" :min="0" @input="numberToFixed('price',2,999999)" v-model="form.price" placeholder="请输入销售价,最多两位小数"/>
 				</u-form-item>
 				<u-form-item label="结算价" v-if="productEntity" required prop="cost">
-					<u-input :clearable="false" type="digit" :min="0" :maxlength="8" @input="numberToFixed('cost',2,999999)" v-model.trim="form.cost" placeholder="请输入结算价,最多两位小数"/>
+					<u-input clearable type="number" :min="0" @input="numberToFixed('cost',2,999999)" v-model="form.cost" placeholder="请输入结算价,最多两位小数"/>
 				</u-form-item>
 				<u-form-item label="最大库容" v-if="productEntity" required prop="maxQty">
-					<u-input :clearable="false" type="digit" :min="0" :maxlength="8" @input="numberToFixed('maxQty',0,999999)" v-model.trim="form.maxQty" placeholder="请输入最大库容"/>
+					<u-input clearable type="number" :min="1" @input="numberToFixed('maxQty',1,999999)" v-model="form.maxQty" placeholder="请输入最大库容"/>
 				</u-form-item>
 			</u-form>
 		</view>
 		<view class="footer-btn">
-			<u-button class="newbtn" @clik="formSubmit" type='primary' shape="circle" size="medium">保存</u-button>
+			<u-button class="newbtn" :loading='loading' @click="formSubmit" type='primary' shape="circle" size="medium">保存</u-button>
 		</view>
 	</view>
 </template>
 
 <script>
 	import { clzConfirm, numberToFixed } from '@/libs/tools';
+	import { addPlaceAndProduct } from '@/api/shelf'
 	export default {
 		data() {
 			return {
 				form: {
 					shelfPlaceCode: '', // 货位号
+					productSn: undefined,
+					productCode: undefined,
 					price: '', //  销售价
 					cost: '', //结算价
-					maxQty: '', //  最大库容
+					maxQty: 1, //  最大库容
 				},
 				rules: {
-					shelfPlaceCode:[{ required: true, message: '请输入货位号', trigger: 'change' }],
-					price: [{ required: true, message: '请输入销售价', trigger: 'change' }],
-					cost: [{ required: true, message: '请输入结算价', trigger: 'change' }],
-					maxQty: [{ required: true, message: '请输入最大库容', trigger: 'change' }],
+					shelfPlaceCode:[
+						{ required: true, message: '请输入货位号', trigger: 'change' },
+						{
+							pattern: /^[a-zA-Z]{1}(?![a-zA-Z]+$)[a-zA-Z0-9]{1,29}$/g,
+							message: '必需包含字母或数字,且首字符不能是数字'
+						}
+					],
+					price: [{ required: true,type:'number', message: '请输入销售价', trigger: 'change' }],
+					cost: [{ required: true,type:'number', message: '请输入结算价', trigger: 'change' }],
+					maxQty: [{ required: true,type:'number', message: '请输入最大库容', trigger: 'change' }],
 				},
-				productEntity: null
+				productEntity: null,
+				customerSn: null,
+				shelfSn: null,
+				loading: false,
+				type:""
 			}
 		},
 		// 必须要在onReady生命周期,因为onLoad生命周期组件可能尚未创建完毕
 		onReady() {
 			this.$refs.uForm.setRules(this.rules);
 		},
+		onLoad(opts) {
+			const _this = this
+			this.nowData = JSON.parse(decodeURIComponent(opts.detailData));
+			this.customerSn = this.nowData.customerSn
+			this.shelfSn = this.nowData.shelfSn
+			this.type = opts.type
+			this.form.shelfPlaceCode = opts.shelfPlaceCode||''
+			// 选在产品
+			uni.$on('addProductToHw',function(data){
+				console.log(data)
+				_this.productEntity = data
+				_this.form.price = Number(data.price)
+				_this.form.cost = Number(data.cost)
+				_this.form.productCode = data.code
+				_this.form.productSn = data.productSn
+			})
+			
+			if(this.type == 'edit'){
+				uni.setNavigationBarTitle({
+					title: "编辑货位号"
+				})
+			}
+		},
+		onUnload(){
+			uni.$off("addProductToHw")
+		},
 		methods: {
 			// 小数点后两位
 			numberToFixed: function (key, num, max) {
@@ -74,17 +118,58 @@
 					this.form[key] = ret < 0 ? 0 : ret
 				})
 			},
+			// 解除绑定
+			clearBind(){
+				this.productEntity = null
+				this.form.price = ''
+				this.form.cost = ''
+				this.form.productCode = undefined
+				this.form.productSn = undefined
+				this.form.maxQty = 1
+			},
 			//  表单提交
 			formSubmit(){
 				const _this = this
 				this.$refs.uForm.validate(valid => {
 					if (valid) {
+						 const params = {}
+						 const form = JSON.parse(JSON.stringify(_this.form))
+						 params.shelfSn = _this.nowData && _this.nowData.shelfSn
+						 params.shelfPlaceCode = form.shelfPlaceCode
 						 
+						 if (this.type == 'edit') {
+						   params.id = this.nowData.id
+						 }
+						 // 绑定了产品
+						 if (form.productSn) {
+						   params.shelfProductApiEntity = {
+						     productSn: form.productSn,
+						     productCode: form.productCode,
+						     price: form.price,
+						     cost: form.cost,
+						     maxQty: form.maxQty
+						   }
+						 }
+						 // 开始提交数据
+						 _this.loading = true
+						 addPlaceAndProduct(params).then(res => {
+						   if (res.status == 200) {
+							 uni.$emit("updateHw")
+							 uni.$emit("updateHwNo",params.shelfPlaceCode)
+						     uni.navigateBack()
+						   }
+						    _this.loading = false
+						 })
 					} else {
 						console.log('验证失败');
 					}
 				});
 			},
+			toBindProduct(){
+				uni.navigateTo({
+					url: "/pages/shelfSetting/bindProduct?customerSn="+this.customerSn+"&shelfSn="+this.shelfSn
+				})
+			}
 		}
 	}
 </script>
@@ -95,8 +180,25 @@
 	width: 100%;
 	.form-body{
 		flex-grow: 1;
-		background-color: #fff;
-		padding: 0 1.5rem;
+		> view{
+			background-color: #fff;
+			padding: 0 1.5rem;
+		}
+		.pimgs{
+			padding:0.1rem;
+			background:#f8f8f8;
+			border-radius:0.3rem;
+		}
+		.pinfo{
+			line-height:normal;
+			padding-left: 20rpx;
+			.ptxt{
+				padding-top:10rpx;
+			}
+			.pcode{
+				color:red;
+			}
+		}
 	}
 	.footer-btn{
 		padding: 0.5rem 2rem;

+ 222 - 0
pages/shelfSetting/bindProduct.vue

@@ -0,0 +1,222 @@
+<template>
+	<view class="productList flex flex_column">
+		<view class="productList-search">
+			<view class="search flex align_center">
+				<view class="input">
+					<u-search 
+					focus
+					v-model="queryWord" 
+					@input="$u.debounce(getProductList, 500)"
+					@custom="$u.debounce(getProductList, 500)" 
+					@search="$u.debounce(getProductList, 500)" 
+					@clear="clearSearch" 
+					bg-color="#fff" 
+					:action-style="{border:'0.1rpx solid #00aaff',borderRadius:'50rpx',color:'#00aaff'}" 
+					placeholder="请输入产品编码查询并选择产品"></u-search>
+				</view>
+				<view class="icon" @click="toScan">
+					<u-icon name="scan"></u-icon>
+				</view>
+			</view>
+		</view>
+		<view class="productList-body">
+			<view class="nav-right-item" v-for="(item, index) in productList" :key="item.id" @click="choose(item)">
+				<view class="item-info">
+					{{item.code}}
+				</view>
+				<view class="arrow">
+					<u-icon name="arrow-right" color="#969da3" size="28"></u-icon>
+				</view>
+			</view>
+			<view v-if="productList&&productList.length==0">
+				<u-empty v-if="status!='loading'" :src="`/static/${$config('themePath')}/def_no_data@3x.png`" icon-size="180" :text="noDataText" mode="list" :margin-top="50"></u-empty>
+			</view>
+			<view style="padding: 20upx;" v-if="total>pageSize || status=='loading'">
+				<u-loadmore :status="status" />
+			</view> 
+		</view>
+	</view>
+</template>
+
+<script>
+	import { bindProductList } from '@/api/shelf'
+	export default {
+		data() {
+			return {
+				queryWord: '',
+				isGobleSearch: false,
+				productList: [],
+				pageNo:1,
+				pageSize: 20,
+				total: 0, // 列表总数
+				noDataText: '暂无产品',
+				status: 'nomore',
+				customerSn: null,
+				shelfSn: null
+			}
+		},
+		onLoad(opts) {
+			this.customerSn = opts.customerSn
+			this.shelfSn = opts.shelfSn
+			console.log(this.customerSn)
+		},
+		methods: {
+			clearSearch(){
+				this.queryWord = ''
+				this.pageNo = 1
+				this.total = 0
+				this.productList = []
+				this.getProductList()
+			},
+			// 获取数字货架列表
+			getProductList(){
+				if(this.queryWord == ''){
+					this.pageNo = 1
+					this.total = 0
+					this.productList = []
+					return
+				}
+				const _this = this
+				let params = {
+				    pageNo: this.pageNo,
+				    pageSize: this.pageSize,
+					code: this.queryWord,
+					customerSn: this.customerSn
+				}
+				_this.status = 'loading'
+				bindProductList(params).then(res => {
+					uni.hideLoading()
+					if(res.status == 200){
+						let list = res.data.list
+						if (list && list.length){
+							// 分页 拼接数据
+							if (_this.pageNo != 1) {
+								_this.productList = _this.productList ? _this.productList.concat(list) : list
+							} else {
+								_this.productList = list
+							}
+							this.total = res.data.count
+							_this.status = 'nomore'
+						} else {
+							_this.productList = list || []
+							this.total = 0
+							_this.status = 'nomore'
+							_this.noDataText = '没有查询到相关货架'
+						}
+					}else{
+						_this.status = 'nomore'
+						_this.productList = []
+						_this.total = 0
+						_this.noDataText = res.message ? res.message : '网络似乎出错了,请稍后再试'
+					}
+				})
+			},
+			// 选择产品
+			choose(item){
+				 uni.$emit("addProductToHw",item)
+				 uni.navigateBack()
+			},
+			// 扫描
+			toScan(){
+				this.mpaasScanModule = uni.requireNativePlugin("wss-scan")
+				this.mpaasScanModule.scan(
+				{
+					"scanMode":"Customized",
+					"scanStyle":{
+						"scanFrameSizePlus":{"width":250,"height":250},
+						"scanFrameSize":200,
+						"scanLight":"visible",
+						"scanText":"对准条形码/二维码进行识别",
+						"scanTitle":"扫码搜索货位产品",
+					}
+				},
+				(result) => {
+					console.log(result)
+					if(result.scanStatus == 1){
+						this.scanResult(result)
+					}
+				})
+			},
+			// 扫描结果
+			scanResult(data){
+				const params = {
+					pageNo: 1,
+					pageSize:1,
+					customerSn: this.customerSn
+				}
+				// 二维码
+				if(data.scanType == 'QRCODE'){
+					const ret = data.scanValue.split("&")
+					params.code = ret[1] // 产品编码
+				}else{
+					params.qrCode = data.scanValue
+				}
+				
+				bindProductList(params).then(res => {
+					console.log(res)
+					if(res.status == 200){
+						if(res.data&&res.data.list.length){
+							this.choose(res.data.list[0])
+						}else{
+							uni.showToast({
+								icon: "none",
+								title: "没有查找到此产品,请重新扫描",
+								duration: 5000
+							})
+						}
+					}
+				})
+			}
+		}
+	}
+</script>
+
+<style lang="less">
+	.productList{
+		width: 100%;
+		height: 100vh;
+		.productList-search{
+			padding: 20rpx 30rpx;
+			background-color: #FFFFFF;
+			.search{
+				.input{
+					flex-grow: 1;
+					border:0.1rpx solid #eee;
+					padding: 0.1rpx;
+					border-radius: 50rpx;
+					padding-right: 10rpx;
+				}
+				.icon{
+					width: 13%;
+					text-align: center;
+					font-size: 50rpx;
+					color: #999;
+				}
+			}
+		}
+		.productList-body{
+			flex-grow: 1;
+			background-color: #fff;
+			padding: 0 40upx;
+			overflow: auto;
+			.nav-right-item{
+				padding:20upx 0;
+				border-bottom: 2rpx solid #f5f5f5;
+				display: flex;
+				align-items: center;
+				&:active{
+					background: #f8f8f8;
+				}
+				.arrow{
+					text-align: right;
+					padding-left: 20rpx;
+				}
+				.item-info{
+					font-size: 30upx;
+					flex-grow:1;
+				}
+			}
+		}
+		 
+	}
+</style>

+ 262 - 6
pages/shelfSetting/editShelfHw.vue

@@ -1,22 +1,278 @@
 <template>
-	<view>
-		
+	<view class="content flex flex_column">
+		<view class="form-body">
+			<u-form :model="form" label-width="155rpx" :error-type="['toast']" ref="uForm">
+				<u-form-item label="货位号">
+					<view class="flex align_center flex_1 justify_between">
+						<view style="width: 80%;">{{shelfPlaceCode}}</view>
+						<view style="width: 20%;text-align: center;" @click="editShelf"><u-icon name='edit-pen'></u-icon></view>
+					</view>
+				</u-form-item>
+				<view v-if="productEntity">
+					<u-form-item label="" prop="productSn">
+						<view class="flex flex_1">
+							<view class="pimgs">
+								<u-image :src="productEntity.productMsg?productEntity.productMsg:`../../static/${$config('themePath')}/def_img@2x.png`" width="128" height="128" border-radius="10"></u-image>
+							</view>
+							<view class="pinfo flex_1">
+								<view class="ptxt flex align_center justify_between">
+									<text>{{productEntity.code}}</text>
+									<text class="pcode" @click="toBindProduct">
+										<u-icon name='edit-pen'></u-icon>
+										更换产品
+									</text>
+								</view>
+								<view class="pname">
+									{{productEntity.name}}
+								</view>
+							</view>
+						</view>
+					</u-form-item>
+					<u-form-item label="销售价" required prop="price">
+						<u-input clearable type="number" :min="0" @input="numberToFixed('price',2,999999)" v-model="form.price" placeholder="请输入销售价,最多两位小数"/>
+					</u-form-item>
+					<u-form-item label="结算价" required prop="cost">
+						<u-input clearable type="number" :min="0" @input="numberToFixed('cost',2,999999)" v-model="form.cost" placeholder="请输入结算价,最多两位小数"/>
+					</u-form-item>
+					<u-form-item label="最大库容" required prop="maxQty">
+						<u-input clearable type="number" :min="1" @input="numberToFixed('maxQty',1,999999)" v-model="form.maxQty" placeholder="请输入最大库容"/>
+					</u-form-item>
+				</view>
+				<view class="noproduct" v-else  @click="toBindProduct">
+					<view>
+						<u-empty :src="`/static/${$config('themePath')}/def_no_data@3x.png`" icon-size="150" text="此货位还未绑定产品" mode="list"></u-empty>
+					</view>
+					<view>点击去 <text>绑定产品</text></view>
+				</view>
+			</u-form>
+		</view>
+		<view class="flex footer-btn">
+			<u-button v-if="type=='bind'" class="delbtn" :loading='loading' @click="handleDel" type='primary' shape="circle" size="medium">删除货位</u-button>
+			<u-button :style="{width:type=='bind'?'45%':'100%'}" class="newbtn" :loading='loading' @click="formSubmit" type='primary' shape="circle" size="medium">保存</u-button>
+		</view>
 	</view>
 </template>
 
 <script>
+	import { clzConfirm, numberToFixed } from '@/libs/tools';
+	import { shelfProductSave, shelfProductDetail, delShelfPlaceSn } from '@/api/shelf'
 	export default {
 		data() {
 			return {
-				
+				shelfPlaceCode: '',
+				form: {
+					productSn: undefined,
+					productCode: undefined,
+					shelfProductSn: undefined,
+					price: '', //  销售价
+					cost: '', //结算价
+					maxQty: 1, //  最大库容
+				},
+				rules: {
+					productSn: [{ required: true, message: '请选择绑定产品', trigger: 'change' }],
+					price: [{ required: true,type:'number', message: '请输入销售价', trigger: 'change' }],
+					cost: [{ required: true,type:'number', message: '请输入结算价', trigger: 'change' }],
+					maxQty: [{ required: true,type:'number', message: '请输入最大库容', trigger: 'change' }],
+				},
+				productEntity: null,
+				customerSn: null,
+				shelfPlaceSn: null,
+				loading: false,
+				type:"",
+				bakProductSn: null
 			}
 		},
-		methods: {
+		// 必须要在onReady生命周期,因为onLoad生命周期组件可能尚未创建完毕
+		onReady() {
+			this.$refs.uForm.setRules(this.rules);
+		},
+		onLoad(opts) {
+			const _this = this
+			this.nowData = JSON.parse(decodeURIComponent(opts.detailData));
+			this.customerSn = this.nowData.customerSn
+			this.shelfSn = this.nowData.shelfSn
+			this.type = opts.type
+			this.shelfPlaceCode = this.nowData.shelfPlaceCode||''
+			
+			// 选在产品
+			uni.$on('addProductToHw',function(data){
+				console.log(data)
+				_this.productEntity = data
+				_this.form.price = Number(data.price)
+				_this.form.cost = Number(data.cost)
+				_this.form.productCode = data.code
+				_this.form.productSn = data.productSn
+				// 更换产品
+				if(_this.bakProductSn != data.productSn){
+					_this.form.updateProductFlag = 1
+				}
+			})
 			
+			// 修改货位号成功
+			uni.$on('updateHwNo',(data)=>{
+				this.shelfPlaceCode = data
+			})
+			
+			if(this.type != 'bind'){
+				// 获取产品信息
+				this.getProductInfo()
+			}
+		},
+		onUnload(){
+			uni.$off("addProductToHw")
+			uni.$off("updateHwNo")
+		},
+		methods: {
+			// 小数点后两位
+			numberToFixed: function (key, num, max) {
+				let val = this.form[key]
+				let ret = numberToFixed(val, num, max)
+				this.$nextTick(() => {
+					this.form[key] = ret < 0 ? 0 : ret
+				})
+			},
+			// 更换产品
+			toBindProduct(){
+				uni.navigateTo({
+					url: "/pages/shelfSetting/bindProduct?customerSn="+this.customerSn+"&shelfSn="+this.shelfSn
+				})
+			},
+			// 编辑货位号
+			editShelf(){
+				const type ='edit'
+				uni.navigateTo({
+					url: "/pages/shelfSetting/addShelfHw?detailData="+encodeURIComponent(JSON.stringify(this.nowData))+"&type="+type+"&shelfPlaceCode="+this.shelfPlaceCode
+				})
+			},
+			// 获取产品信息
+			getProductInfo () {
+			  shelfProductDetail({ shelfPlaceSn: this.nowData && this.nowData.shelfPlaceSn }).then(res => {
+			    if (res.status == 200 && res.data) {
+			      this.productEntity = {
+					  code: res.data.productCode,
+					  name: res.data.productName,
+					  productMsg: res.data.productImageUrl
+				  }
+			      this.form.productSn = res.data.productSn
+				  this.bakProductSn = res.data.productSn
+			      this.form.productCode = res.data.productCode
+			      this.form.price = res.data.price
+			      this.form.cost = res.data.cost
+			      this.form.maxQty = res.data.maxQty
+			    } else {
+			      this.productEntity = null
+			    }
+			  })
+			},
+			// 删除货位
+			handleDel (row) {
+			  const _this = this
+			  clzConfirm({
+			    title: '提示',
+			    content: '删除后无法恢复,确认删除?',
+			    success (ret) {
+					if (ret.confirm || ret.index == 0) {
+						_this.loading = true
+						delShelfPlaceSn({ shelfPlaceSn: _this.nowData.shelfPlaceSn }).then(res => {
+						  if (res.status == 200) {
+							  uni.showToast({
+							  	icon: "none",
+							  	title: res.message
+							  })
+							  uni.$emit("updateHw")
+							  uni.navigateBack()
+						  }
+						  _this.loading = false
+						})
+					}
+			    }
+			  })
+			},
+			//  表单提交
+			formSubmit(){
+				const _this = this
+				this.$refs.uForm.validate(valid => {
+					if (valid) {
+						 const form = JSON.parse(JSON.stringify(_this.form))
+						 form.shelfPlaceSn = _this.nowData && _this.nowData.shelfPlaceSn
+						 if(this.type != 'bind'){ // 不是绑定产品
+						 	form.shelfProductSn = _this.nowData && _this.nowData.shelfProductApiEntity && _this.nowData.shelfProductApiEntity.shelfProductSn || _this.nowData.shelfProductSn
+						 }
+						 
+						 // 开始提交数据
+						 _this.loading = true
+						 shelfProductSave(form).then(res => {
+						   if (res.status == 200) {
+							 uni.showToast({
+							 	icon: "none",
+							 	title: res.message
+							 })
+							 uni.$emit("updateHw")
+						     uni.navigateBack()
+						   }
+						    _this.loading = false
+						 })
+					} else {
+						console.log('验证失败');
+					}
+				});
+			},
 		}
 	}
 </script>
 
-<style>
-
+<style lang="less">
+.content{
+	height: 100vh;
+	width: 100%;
+	.form-body{
+		flex-grow: 1;
+		> view{
+			background-color: #fff;
+			padding: 0 1.5rem;
+		}
+		.pimgs{
+			padding:0.1rem;
+			background:#f8f8f8;
+			border-radius:0.3rem;
+		}
+		.pinfo{
+			line-height:normal;
+			padding-left: 20rpx;
+			.ptxt{
+				padding-bottom:20rpx;
+			}
+			.pcode{
+				color:rgb(0, 170, 255);
+			}
+		}
+		.noproduct{
+			padding: 40rpx 20rpx;
+			text-align: center;
+			color: #999;
+			>view{
+				padding: 10rpx 0;
+			}
+			text{
+				color: #00aaff;
+				margin-left: 10rpx;
+			}
+		}
+	}
+	.footer-btn{
+		padding: 0.5rem 2rem;
+		justify-content: space-between;
+		button{
+			min-width: 45%;
+		}
+		.newbtn{
+			background-color: rgb(51, 95, 182);
+			color: #fff;
+		}
+		.delbtn{
+			background-color: #fff;
+			color: red;
+		}
+	}
+}
 </style>

+ 34 - 5
pages/shelfSetting/searchShelfHw.vue

@@ -5,7 +5,9 @@
 			<view class="search flex align_center">
 				<view class="input">
 					<u-search 
+					focus
 					v-model="queryWord" 
+					@input="change"
 					@custom="getpartList" 
 					@search="getpartList" 
 					@clear="clearSearch" 
@@ -73,9 +75,11 @@
 		},
 		methods: {
 			//编辑货位
-			toEdit(row){
+			toEdit(item){
+				const type = 'edit'
+				const params = Object.assign({shelfSn: this.shelfSn,shelfName: this.shelfName},item)
 				uni.navigateTo({
-					url: "/pages/shelfSetting/editShelfHw?shelfSn="+this.shelfSn
+					url: "/pages/shelfSetting/editShelfHw?detailData="+encodeURIComponent(JSON.stringify(params))+"&type=" + type
 				})
 			},
 			clearSearch(){
@@ -84,6 +88,11 @@
 				this.partList = []
 				this.getpartList()
 			},
+			change(v){
+				if(v==''){
+					this.clearSearch()
+				}
+			},
 			// 获取数字货架列表
 			getpartList(){
 				const _this = this
@@ -158,13 +167,33 @@
 			},
 			// 扫描结果
 			scanResult(data){
-				// this.toEdit()
+				const params = {
+					pageNo: 1,
+					pageSize:1,
+					shelfSn: this.shelfSn
+				}
 				// 二维码
 				if(data.scanType == 'QRCODE'){
-					
+					const ret = data.scanValue.split("&")
+					params.queryWord = ret[1] // 产品编码
 				}else{
-					
+					params.qrCode = data.scanValue
 				}
+				
+				getShelfProductList(params).then(res => {
+					console.log(res)
+					if(res.status == 200){
+						if(res.data&&res.data.list.length){
+							this.toEdit(res.data.list[0])
+						}else{
+							uni.showToast({
+								icon: "none",
+								title: "产品不属于此货架,请重新扫描",
+								duration: 5000
+							})
+						}
+					}
+				})
 			}
 		}
 	}

+ 9 - 2
pages/shelfSetting/shelfList.vue

@@ -5,6 +5,7 @@
 			placeholder="请输入货架名称搜索" 
 			v-model="shelfName" 
 			:show-action="isGobleSearch" 
+			@input="change"
 			@focus="isGobleSearch=true"
 			@blur="isGobleSearch=false"
 			@custom="getShelfList" 
@@ -62,11 +63,10 @@
 				isGobleSearch: false,
 				shelfList: [],
 				pageNo:1,
-				pageSize: 10,
+				pageSize: 15,
 				total: 0, // 列表总数
 				noDataText: '暂无货架',
 				status: 'loading',
-				vinstatus: 'loading',
 				tempData: null
 			}
 		},
@@ -86,6 +86,11 @@
 				this.shelfList = []
 				this.getShelfList()
 			},
+			change(v){
+				if(v==''){
+					this.clearSearch()
+				}
+			},
 			// 保存数字货架基本信息
 			saveShelf(data){
 				shelfSave({
@@ -118,6 +123,7 @@
 								_this.shelfList = list
 							}
 							this.total = res.data.count
+							console.log(res.data.count)
 							if (_this.shelfList.length == res.data.count) {
 								_this.status = 'nomore'
 							} else {
@@ -129,6 +135,7 @@
 							_this.status = 'nomore'
 							_this.noDataText = '没有查询到相关货架'
 						}
+						_this.noDataText = '暂无货架'
 					}else{
 						_this.status = 'loadmore'
 						_this.shelfList = []

+ 60 - 34
pages/shelfSetting/shelfSet.vue

@@ -29,43 +29,20 @@
 					<u-icon name="scan"></u-icon>
 				</view>
 			</view>
-			<view class="flex shelfTabs">
+			<view class="flex shelfTabs" v-if="shelfPlaceList">
 				<view class="leftTabs">
-					<view class="active">A层</view>
-					<view>B层</view>
-					<view>C层</view>
-					<view>D层</view>
-					<view>E层</view>
-					<view>B层</view>
-					<view>C层</view>
-					<view>D层</view>
-					<view>E层</view>
-					<view>B层</view>
-					<view>C层</view>
-					<view>D层</view>
-					<view>E层</view>
-					<view>B层</view>
-					<view>C层</view>
-					<view>D层</view>
-					<view>E层</view>
-					<view>B层</view>
-					<view>C层</view>
-					<view>D层</view>
-					<view>E层</view>
+					<view v-for="item in placeTab" :key="item" :class="curTab==item?'active':''" @click="tabChange(item)">{{item}}层</view>
 				</view>
 				<view class="rightCons flex flex_column">
 					<view class="hwList flex_1">
-						<text>A01</text>
-						<text>A01</text>
-						<text>A01</text>
-						<text class="red">A01</text>
-						<text>A01</text>
-						<text>A01</text>
-						<text class="add" @click="addHw"><u-icon name="plus"></u-icon></text>
+						<text @click="editHw(item)" v-for="item in shelfPlaceList[curTab]" :key="item.shelfPlaceCode" :class="item.shelfProductApiEntity && item.shelfProductApiEntity.productSn?'':'red'">
+							{{item.shelfPlaceCode}}
+						</text>
+						<text class="add" @click="addHw('add',1)"><u-icon name="plus"></u-icon></text>
 					</view>
 					<view class="hwAction flex justify_between">
 						<u-button shape="circle" @click="showMenus=true" size="medium">更多功能</u-button>
-						<u-button class="newbtn" @click="addHw" type='primary' shape="circle" size="medium">新增货位</u-button>
+						<u-button class="newbtn" @click="addHw('add',0)" type='primary' shape="circle" size="medium">新增货位</u-button>
 					</view>
 				</view>
 			</view>
@@ -76,7 +53,7 @@
 
 <script>
 	import chunLeiPopups from "@/components/chunLei-popups/chunLei-popups.vue";
-    import { shelfDetail, shelfSave, modifFinishFlag } from '@/api/shelf'
+    import { shelfDetail, shelfSave, modifFinishFlag, getProductPlace } from '@/api/shelf'
 	export default {
 		components:{chunLeiPopups},
 		data() {
@@ -87,18 +64,30 @@
 				showMenus:false,
 				popData:[{title:'快速补货',val:'0'},{title:'打印贴签',val:'1'}],
 				pleft:0,
-				ptop:0
+				ptop:0,
+				shelfPlaceList: null,
+				placeTab: [],
+				curTab: ''
 			}
 		},
 		onLoad(option) {
 			this.shelfSn = option.shelfSn
+			// 获取货架详情
 			this.getShelfDetal()
+			// 获取货物
+			this.getShelfPlace()
+			
 			uni.$on("editCustome",(data)=>{
 				this.saveShelf(data,0)
 			})
 			uni.$on("editShelfName",(data)=>{
 				this.saveShelf(data,1)
 			})
+			uni.$on("updateHw",()=>{
+				this.placeTab = []
+				this.getShelfPlace(true)
+			})
+			
 			const win = uni.getWindowInfo()
 			this.pleft = Math.floor(win.windowWidth * 0.3)
 			this.ptop = Math.floor(win.windowHeight - 70)
@@ -106,6 +95,7 @@
 		onUnload() {
 			uni.$off("editCustome")
 			uni.$off("editShelfName")
+			uni.$off("updateHw")
 		},
 		methods: {
 			// 更多操作
@@ -153,10 +143,28 @@
 					url: "/pages/shelfSetting/searchShelfHw?shelfName="+this.detailData.shelfName+"&shelfSn="+this.shelfSn
 				})
 			},
+			// 编辑货位
+			editHw(item){
+				const hasProduct = item.shelfProductApiEntity && item.shelfProductApiEntity.productSn
+				const type = hasProduct ? 'edit':'bind'
+				const params = Object.assign(this.detailData,item)
+				uni.navigateTo({
+					url: "/pages/shelfSetting/editShelfHw?detailData="+encodeURIComponent(JSON.stringify(params))+"&type=" + type
+				})
+			},
 			// 新增货位
-			addHw(){
+			addHw(type,flag){
+				let shelfPlaceCode = ''
+				if(type=='edit'){
+					shelfPlaceCode = flag
+				}
+				if(type=='add'&&flag==1){
+					const row = this.shelfPlaceList[this.curTab]
+					const num = row[row.length-1].shelfPlaceCode.replace(this.curTab,'')
+					shelfPlaceCode = this.curTab + (Number(num) + 1)
+				}
 				uni.navigateTo({
-					url: "/pages/shelfSetting/addShelfHw?shelfName="+this.detailData.shelfName+"&shelfSn="+this.shelfSn
+					url: "/pages/shelfSetting/addShelfHw?detailData="+encodeURIComponent(JSON.stringify(this.detailData))+"&type="+type+"&shelfPlaceCode="+shelfPlaceCode
 				})
 			},
 			// 保存数字货架基本信息
@@ -189,6 +197,24 @@
 				    this.detailData = null
 				  }
 				})
+			},
+			getShelfPlace(flag){
+				getProductPlace({ shelfSn: this.shelfSn }).then(res => {
+				  if (res.status == 200) {
+				    this.shelfPlaceList = res.data
+					for(let a in res.data){
+						this.placeTab.push(a)
+					}
+					if(!flag){
+					  this.curTab = this.placeTab[0]
+					}
+				  } else {
+				    this.shelfPlaceList = null
+				  }
+				})
+			},
+			tabChange(item){
+				this.curTab = item
 			}
 		}
 	}