소스 검색

新增货位

lilei 2 년 전
부모
커밋
b3d2c5b4c5
6개의 변경된 파일479개의 추가작업 그리고 6개의 파일을 삭제
  1. 36 0
      pages.json
  2. 110 0
      pages/shelfSetting/addShelfHw.vue
  3. 36 0
      pages/shelfSetting/editShelf.vue
  4. 22 0
      pages/shelfSetting/editShelfHw.vue
  5. 247 0
      pages/shelfSetting/searchShelfHw.vue
  6. 28 6
      pages/shelfSetting/shelfSet.vue

+ 36 - 0
pages.json

@@ -358,6 +358,42 @@
             }
             
         }
+        ,{
+            "path" : "pages/shelfSetting/editShelf",
+            "style" :                                                                                    
+            {
+                "navigationBarTitleText": "修改货架名称",
+                "enablePullDownRefresh": false
+            }
+            
+        }
+        ,{
+            "path" : "pages/shelfSetting/searchShelfHw",
+            "style" :                                                                                    
+            {
+                "navigationBarTitleText": "按产品搜索",
+                "enablePullDownRefresh": false
+            }
+            
+        }
+        ,{
+            "path" : "pages/shelfSetting/editShelfHw",
+            "style" :                                                                                    
+            {
+                "navigationBarTitleText": "编辑货位",
+                "enablePullDownRefresh": false
+            }
+            
+        }
+        ,{
+            "path" : "pages/shelfSetting/addShelfHw",
+            "style" :                                                                                    
+            {
+                "navigationBarTitleText": "新增货位",
+                "enablePullDownRefresh": false
+            }
+            
+        }
     ],
 	"globalStyle": {
 		"navigationBarTextStyle": "black",

+ 110 - 0
pages/shelfSetting/addShelfHw.vue

@@ -0,0 +1,110 @@
+<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-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>
+				<u-form-item label="" v-if="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>
+						</view>
+						<view class="pinfo flex_1">
+							<view class="pname">
+								{{productEntity&&productEntity.productName}}
+							</view>
+							<view class="ptxt">
+								<text class="pcode">解除绑定</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-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-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-form-item>
+			</u-form>
+		</view>
+		<view class="footer-btn">
+			<u-button class="newbtn" @clik="formSubmit" type='primary' shape="circle" size="medium">保存</u-button>
+		</view>
+	</view>
+</template>
+
+<script>
+	import { clzConfirm, numberToFixed } from '@/libs/tools';
+	export default {
+		data() {
+			return {
+				form: {
+					shelfPlaceCode: '', // 货位号
+					price: '', //  销售价
+					cost: '', //结算价
+					maxQty: '', //  最大库容
+				},
+				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' }],
+				},
+				productEntity: null
+			}
+		},
+		// 必须要在onReady生命周期,因为onLoad生命周期组件可能尚未创建完毕
+		onReady() {
+			this.$refs.uForm.setRules(this.rules);
+		},
+		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
+				})
+			},
+			//  表单提交
+			formSubmit(){
+				const _this = this
+				this.$refs.uForm.validate(valid => {
+					if (valid) {
+						 
+					} else {
+						console.log('验证失败');
+					}
+				});
+			},
+		}
+	}
+</script>
+
+<style lang="less">
+.content{
+	height: 100vh;
+	width: 100%;
+	.form-body{
+		flex-grow: 1;
+		background-color: #fff;
+		padding: 0 1.5rem;
+	}
+	.footer-btn{
+		padding: 0.5rem 2rem;
+		.newbtn{
+			width: 100%;
+			background-color: rgb(51, 95, 182);
+			color: #fff;
+		}
+	}
+}
+</style>

+ 36 - 0
pages/shelfSetting/editShelf.vue

@@ -0,0 +1,36 @@
+<template>
+	<view style="padding: 1rem;background: #fff;width:100%;height: 100vh;" class="flex flex_column">
+		<view style="flex:1;"><u-input style="border-radius: 50rpx;" height="90" v-model="shelfName" border placeholder="请输入货架名称"></u-input></view>
+		<view><u-button @click="save" shape="circle" type="primary">保存</u-button></view>
+	</view>
+</template>
+
+<script>
+	export default {
+		data() {
+			return {
+				shelfName: ''
+			}
+		},
+		onLoad(opts) {
+			this.shelfName = opts.shelfName
+		},
+		methods: {
+			save(){
+				if(this.shelfName&&this.shelfName.replace(/\s+/g,'') != ''){
+					uni.$emit('editShelfName',{shelfName: this.shelfName})
+					uni.navigateBack()
+				}else{
+					uni.showToast({
+						icon:"none",
+						title: "请输入货架名称"
+					})
+				}
+			}
+		}
+	}
+</script>
+
+<style>
+
+</style>

+ 22 - 0
pages/shelfSetting/editShelfHw.vue

@@ -0,0 +1,22 @@
+<template>
+	<view>
+		
+	</view>
+</template>
+
+<script>
+	export default {
+		data() {
+			return {
+				
+			}
+		},
+		methods: {
+			
+		}
+	}
+</script>
+
+<style>
+
+</style>

+ 247 - 0
pages/shelfSetting/searchShelfHw.vue

@@ -0,0 +1,247 @@
+<template>
+	<view class="content flex flex_column">
+		<view class="searchBar">
+			<view class="shelfName">{{shelfName}}</view>
+			<view class="search flex align_center">
+				<view class="input">
+					<u-search 
+					v-model="queryWord" 
+					@custom="getpartList" 
+					@search="getpartList" 
+					@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="check-list">
+			<scroll-view scroll-y class="scroll-view" @scrolltolower="onreachBottom">
+				<view class="partList-list-box" v-for="item in partList" :key="item.id">
+					<view class="product flex align_center" @click="toEdit(item)">
+						<view class="flex align_center flex_1">
+							<view class="pimgs">
+								<u-image :src="item.productEntity&&item.productEntity.images?item.productEntity.images:`../../static/${$config('themePath')}/def_img@2x.png`" width="128" height="128" border-radius="10"></u-image>
+							</view>
+							<view class="pinfo">
+								<view class="pname">
+									<text>{{item.shelfPlaceCode}}</text>{{item.productEntity&&item.productEntity.code}}
+								</view>
+								<view class="ptxt flex align_center justify_between">
+									<view>
+										<text class="pcode">{{item.productEntity&&item.productEntity.productName}}</text>
+									</view>
+								</view>
+							</view>
+						</view>
+					</view>
+				</view>
+				<view v-if="partList&&partList.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>
+			</scroll-view>
+		</view>
+	</view>
+</template>
+
+<script>
+	import { getShelfProductList } from '@/api/shelf'
+	export default {
+		data() {
+			return {
+				queryWord: '',
+				shelfName:'',
+				shelfSn: '',
+				pageNo:1,
+				pageSize: 10,
+				total: 0, // 列表总数
+				noDataText: '暂无产品',
+				status: 'loading',
+				partList: []
+			}
+		},
+		onLoad(opts) {
+			this.shelfName = opts.shelfName
+			this.shelfSn = opts.shelfSn
+			this.getpartList()
+		},
+		methods: {
+			//编辑货位
+			toEdit(row){
+				uni.navigateTo({
+					url: "/pages/shelfSetting/editShelfHw?shelfSn="+this.shelfSn
+				})
+			},
+			clearSearch(){
+				this.queryWord = ''
+				this.pageNo = 1
+				this.partList = []
+				this.getpartList()
+			},
+			// 获取数字货架列表
+			getpartList(){
+				const _this = this
+				let params = {
+				    pageNo: this.pageNo,
+				    pageSize: this.pageSize,
+					shelfSn: this.shelfSn,
+					queryWord: this.queryWord
+				}
+				_this.status = 'loading'
+				getShelfProductList(params).then(res => {
+					uni.hideLoading()
+					if(res.status == 200){
+						let list = res.data.list
+						console.log(list)
+						if (list && list.length){
+							// 分页 拼接数据
+							if (_this.pageNo != 1) {
+								_this.partList = _this.partList ? _this.partList.concat(list) : list
+							} else {
+								_this.partList = list
+							}
+							this.total = res.data.count
+							if (_this.partList.length == res.data.count) {
+								_this.status = 'nomore'
+							} else {
+								_this.status = 'loadmore'
+							}
+						} else {
+							_this.partList = list || []
+							this.total = 0
+							_this.status = 'nomore'
+						}
+						_this.noDataText = '暂无匹配产品'
+					}else{
+						_this.status = 'loadmore'
+						_this.partList = []
+						_this.total = 0
+						_this.noDataText = res.message ? res.message : '网络似乎出错了,请稍后再试'
+					}
+				})
+			},
+			// 加载更多
+			onreachBottom () {
+				if(this.partList.length < this.total ){
+					this.pageNo++
+					this.getpartList()
+				}else{
+					this.status = "nomore"
+				}
+			},
+			// 扫描
+			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){
+				// this.toEdit()
+				// 二维码
+				if(data.scanType == 'QRCODE'){
+					
+				}else{
+					
+				}
+			}
+		}
+	}
+</script>
+
+<style lang="less">
+.content{
+	height: 100vh;
+	width: 100%;
+	padding: 0 0.5rem;
+	background: #fff;
+	.searchBar{
+		padding: 0.5rem 0;
+		.shelfName{
+			font-weight: bold;
+		}
+		.search{
+			padding: 0.5rem;
+			.input{
+				flex-grow: 1;
+				border:0.1rpx solid #eee;
+				padding: 0.1rpx;
+				border-radius: 50rpx;
+				padding-right: 10rpx;
+			}
+			.icon{
+				width: 10%;
+				text-align: center;
+				font-size: 50rpx;
+				color: #999;
+			}
+		}
+	}
+	.check-list{
+		flex-grow: 1;
+		.scroll-view{
+			height: calc(100vh - 180rpx);
+			box-sizing: border-box;
+		}
+		.partList-list-box{
+			padding: 20rpx 30rpx;
+			border-bottom: 2rpx solid #f5f5f5;
+			&:last-child{
+				border:0;
+			}
+			.product{
+				flex-grow: 1;
+				.checkbox{
+					width: 60rpx;
+				}
+				.pinfo{
+					flex-grow: 1;
+					padding-left: 20rpx;
+					.pname{
+						font-size: 28rpx;
+						color: #191919;
+						margin-bottom: 10rpx;
+						text{
+							font-weight: normal;
+							margin-right: 6rpx;
+							padding: 0 10rpx;
+							background: rgba(3, 54, 146, 0.15);
+							border-radius: 100rpx;
+							color: #033692;
+							font-size: 24rpx;
+						}
+					}
+					.ptxt{
+						font-size: 28rpx;
+						color: #666;
+						.pnums{
+							color: #222;
+						}
+					}
+				}
+			}
+		} 
+	}
+}
+</style>

+ 28 - 6
pages/shelfSetting/shelfSet.vue

@@ -3,7 +3,7 @@
 		<view class="card-box" v-if="detailData">
 			<view class="card-row flex justify_between">
 				<view class="label">货架名称</view>
-				<view class="text flex align_center">
+				<view class="text flex align_center" @click="editShelf">
 					<text style="width: 80%;flex: 1;">{{detailData.shelfName}}</text>
 					<u-icon name="arrow-right" color="#969da3" size="28"></u-icon>
 				</view>
@@ -24,7 +24,7 @@
 		<view class="shelfPlace">
 			<view class="flex align_center shelfPlaceHead">
 				<view class="lt"><text>□</text>表示没有绑定产品</view>
-				<view class="search-btn flex align_center">
+				<view class="search-btn flex align_center" @click="toSearchHw">
 					<view><u-icon name="search"></u-icon><text>按产品搜索</text></view>
 					<u-icon name="scan"></u-icon>
 				</view>
@@ -61,11 +61,11 @@
 						<text class="red">A01</text>
 						<text>A01</text>
 						<text>A01</text>
-						<text class="add"><u-icon name="plus"></u-icon></text>
+						<text class="add" @click="addHw"><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" type='primary' shape="circle" size="medium">新增货位</u-button>
+						<u-button class="newbtn" @click="addHw" type='primary' shape="circle" size="medium">新增货位</u-button>
 					</view>
 				</view>
 			</view>
@@ -96,16 +96,19 @@
 			uni.$on("editCustome",(data)=>{
 				this.saveShelf(data,0)
 			})
-			
+			uni.$on("editShelfName",(data)=>{
+				this.saveShelf(data,1)
+			})
 			const win = uni.getWindowInfo()
-			console.log(win,'win')
 			this.pleft = Math.floor(win.windowWidth * 0.3)
 			this.ptop = Math.floor(win.windowHeight - 70)
 		},
 		onUnload() {
 			uni.$off("editCustome")
+			uni.$off("editShelfName")
 		},
 		methods: {
+			// 更多操作
 			tapPopup(e){
 				console.log(e)
 			},
@@ -138,12 +141,31 @@
 					url: "/pages/sales/chooseCustomer?backPage=shelfEdit&shelfName="+this.detailData.shelfName
 				})
 			},
+			// 修改货架名称
+			editShelf(){
+				uni.navigateTo({
+					url: "/pages/shelfSetting/editShelf?shelfName="+this.detailData.shelfName
+				})
+			},
+			// 按照产品搜索货位
+			toSearchHw(){
+				uni.navigateTo({
+					url: "/pages/shelfSetting/searchShelfHw?shelfName="+this.detailData.shelfName+"&shelfSn="+this.shelfSn
+				})
+			},
+			// 新增货位
+			addHw(){
+				uni.navigateTo({
+					url: "/pages/shelfSetting/addShelfHw?shelfName="+this.detailData.shelfName+"&shelfSn="+this.shelfSn
+				})
+			},
 			// 保存数字货架基本信息
 			saveShelf(data,type){
 				const params = {
 					shelfSn: this.shelfSn
 				}
 				if(type == 1){
+					params.customerSn = this.detailData.customerSn
 					params.shelfName = data.shelfName
 				}else{
 					params.customerSn = data.customerSn