shish 3 лет назад
Родитель
Сommit
e99fe6c64d
3 измененных файлов с 130 добавлено и 108 удалено
  1. 11 74
      ghsApp/src/admin/changePrice/setSon.vue
  2. 111 34
      ghsApp/src/admin/item/sendStock.vue
  3. 8 0
      ghsApp/src/api/item/index.js

+ 11 - 74
ghsApp/src/admin/changePrice/setSon.vue

@@ -56,42 +56,9 @@
 		</view>
 
       <div class="app-footer">
-		<button class="admin-button-com big blue" @click="modifyClass()">提交所选花材</button>
+		<button class="admin-button-com big blue" @click="addSetItem()">添加所选花材</button>
       </div>
 
-		<uni-popup ref="selectFlowerNumRef" background-color="#fff" type="center" :animation="false" class="class-popup-style">
-			<view style="display:flex;padding:20upx;height:auto;justify-content: space-between;align-items:center;flex-wrap:wrap;max-height:100vh;overflow:auto;">
-
-				<view v-for="(item, index) in globalClassItemList" :key="index" @tap.stop="changeClass(index)" style="margin-bottom:20upx;margin-left:3upx;">
-				<image :src="item.classCover" style="width:120upx;height:120upx;border-radius:10upx;"></image>
-				<view style="margin-top:5upx;overflow: hidden;white-space: nowrap;width:120upx;text-align:center;">{{item.className}}</view>
-				</view>
-
-			</view>
-		</uni-popup>
-
-		<image v-if="showClassRemind" @click="hideClassRemind" style="position:absolute;width:610upx;height:699upx;top:225upx;left:80upx;z-index:9999;" :src="`${constant.imgUrl}/class_remind.png`"></image>
-
-		<modal-module :show="showClassModel" @cancel="cancelModifyClass" @click="confirmModifyClass" title=" " color="#333" :size="32" padding="30rpx 30rpx" >
-			<template slot="customContent">
-				<view style="padding:30upx 0">
-
-<view class="module-com input-line-wrap">
-	<tui-list-cell class="line-cell" :arrow="true">
-		<view class="tui-title">分类</view>
-		<picker mode="selector" :value="classId" :range="itemClassData" range-key="name" @change="changeItemClassFn" class="tui-input" >
-		<view v-if="Number(classId)>0" style="height:45upx;" >{{ itemClassSelectedData.name }}</view>
-		<view class="tui-placeholder" style="height:45upx;" v-else>请选择</view>
-		</picker>
-	</tui-list-cell>
-</view>
-
-
-				</view>
-			</template>
-		</modal-module>
-
-
 	</view>
 </view>
 </template>
@@ -105,8 +72,9 @@ import { mapGetters } from "vuex";
 import ModalModule from "@/components/plugin/modal";
 import TuiListCell from "@/components/plugin/list-cell";
 import { getAllItemClass } from "@/api/item-class";
+import { batchAddItem } from "@/api/item";
 export default {
-	name: "outlist",
+	name: "setSon",
 	components: {
 		AppSearchModule,
 		AppWrapperEmpty,
@@ -118,12 +86,11 @@ export default {
 	data() {
 		return {
 			autoLoad: false,
-			selectJobType: "stock",
+			selectJobType: "add-ms-item",
 			tabIndex: 0,
 			priceArr:[],
 			showClassRemind:false,
 			currentList:[],
-			itemClassData:[],
 			itemClassSelectedData:{},
 			classId:0,
 			showClassModel:false
@@ -134,20 +101,8 @@ export default {
 	},
 	onLoad() {
 		this.initProduct()
-
-		getAllItemClass().then(res => {
-			if (this.$util.isEmpty(res.data)){
-				return false;
-			}
-			this.itemClassData = res.data;
-		})
-
 	},
 	methods: {
-		changeItemClassFn(e) {
-			this.itemClassSelectedData = this.itemClassData[e.detail.value];
-			this.classId = this.itemClassSelectedData.id;
-		},
 		getCurrentAll(index){
 			let that = this
 			let child = this.globalClassItemList[index] && this.globalClassItemList[index].child ? this.globalClassItemList[index].child : []
@@ -159,38 +114,24 @@ export default {
 				})
 			}
 		},
-		modifyClass(){
-			this.showClassModel = true
-		},
-		confirmModifyClass(val){
-			if (val.index === 0) {
-				this.cancelModifyClass();
-				return false
-			}
+		addSetItem(){
 			let that = this
 			if(this.$util.isEmpty(this.currentList)){
 				this.$msg('请选择花材')
 				return false
 			}
-			if(Number(this.classId)==0){
-				this.$msg('请选择分类')
-				return false
-			}
-			this.$util.confirmModal({content:'确认移动?'},() => {
-				batchModifyClass({ids:JSON.stringify(that.currentList),classId:that.classId}).then(res=>{
+			let motherId = this.option.id ? this.option.id : 0
+			this.$util.confirmModal({content:'确认添加?'},() => {
+				batchAddItem({ids:JSON.stringify(that.currentList),motherId:motherId}).then(res=>{
 					if(res.code == 1){
-						that.cancelModifyClass()
 						that.$msg(res.msg)
-						that.initProduct()
+						setTimeout(function(){
+							uni.navigateBack({})
+						},1200)
 					}
 				})
 			})
 		},
-		cancelModifyClass() {
-			this.showClassModel = false;
-			this.classId = 0
-			this.itemClassSelectedData = {}
-		},
 		checkItemEvent(item,check) {
 			let id = item.id
 			if(check == true){
@@ -205,10 +146,6 @@ export default {
 				}
 			}
 		},
-		changeClass(index){
-			this.$refs.selectFlowerNumRef.close()
-			this.swichClass(index)
-		},
 		selectFlowerNumFn(){
 			this.$refs.selectFlowerNumRef.open('top')
 		},

+ 111 - 34
ghsApp/src/admin/item/sendStock.vue

@@ -2,8 +2,8 @@
 	<view class="app-content">
 		<view class="billing_box_bg">
 			<view class="input-wrap">
-				<text style="margin-right:15upx;font-size:42upx;">库存:{{stock}}扎</text>
-				<text style="margin-right:20upx;font-size:42upx;">批发价:¥{{ price }}</text>
+				<text style="margin-right:15upx;font-size:40upx;">库存:{{stock}}扎</text>
+				<text style="margin-right:20upx;font-size:40upx;">批发价:¥{{ price }}</text>
 				<button class="admin-button-com middle blue" @click="setSon()">新增子花材</button>
 			</view>
 			<view class="scroll-middle_bx">
@@ -20,11 +20,11 @@
 										<view class="kc">剩 {{sonItem.stock ? parseFloat(sonItem.stock) : 0}}</view>
 										<view class="num-open_bx">
 											<view class="open-bx">
-	<button class="admin-button-com mini-btn blue del-button" @click="delItem(sonItem)">删除</button>
-	<input class="hy-ok-price" placeholder-style="color:#CCCCCC" v-model="sonItem.sendHyPrice" type="number" placeholder="会员价" />
-	<input class="add-ok-stock" placeholder-style="color:#CCCCCC" v-model="sonItem.sendSonStock" type="digit" placeholder="库存数量" />
-	<input class="ls-ok-price" placeholder-style="color:#CCCCCC" v-model="sonItem.sendLsPrice" type="digit" placeholder="零售价" />
-	<input class="pf-ok-price" placeholder-style="color:#CCCCCC" @input="linkChange(sonItem)" v-model="sonItem.sendPfPrice" type="digit" placeholder="批发价" />
+<button class="admin-button-com mini-btn blue del-button" @click="delItem(sonItem)">删除</button>
+<input class="hy-ok-price" placeholder-style="color:#CCCCCC" v-model="sonItem.sendHyPrice" type="number" placeholder="会员价" />
+<input class="add-ok-stock" placeholder-style="color:#CCCCCC" @input="stockToggle(sonItem)" v-model="sonItem.sendSonStock" type="digit" placeholder="库存数量" />
+<input class="ls-ok-price" placeholder-style="color:#CCCCCC" v-model="sonItem.sendLsPrice" type="digit" placeholder="零售价" />
+<input class="pf-ok-price" placeholder-style="color:#CCCCCC" @input="linkChange(sonItem)" v-model="sonItem.sendPfPrice" type="digit" placeholder="批发价" />
 											</view>
 										</view>
 									</view>
@@ -38,17 +38,19 @@
 			<div class="app-footer footer-button">
 				<button class="admin-button-com big default" @click="goBack()" 
 				style="margin-left:58upx;padding:30upx 55upx 30upx 55upx;">返回</button>
-				<button class="admin-button-com big blue" @click="confirmSend()" 
-				style="margin-left:58upx;padding:30upx 65upx; 30upx 65upx;" >确认</button>
+				<button class="admin-button-com big blue" @click="toSend()" 
+				style="margin-left:58upx;padding:30upx 65upx; 30upx 65upx;" >确认分配</button>
 			</div>
-	
+			<view v-if="remain>=0" style="width:200upx;position:fixed;bottom:40upx;left:10upx;z-index:99999;font-size:32upx;">
+				还剩{{ remain }}
+			</view>
 		</view>
 	</view>
 	</template>
 	<script>
 	import AppWrapperEmpty from "@/components/app-wrapper-empty";
 	import { mapGetters } from "vuex";
-	import { getSonList,delMsItem } from "@/api/item"
+	import { getSonList,delMsItem,sendStockFn } from "@/api/item"
 	export default {
 		name: "sendStock",
 		components: {
@@ -59,7 +61,8 @@
 			return {
 				sonItemList:[],
 				stock:0,
-				price:0
+				price:0,
+				remain:0
 			};
 		},
 		onShow(){
@@ -68,11 +71,39 @@
 		onLoad(){
 			this.price = this.option.price ? parseFloat(this.option.price) : 0
 			this.stock = this.option.stock ? parseFloat(this.option.stock) : 0
+			this.remain = this.stock
 		},
 		methods: {
+			stockToggle(item){
+				let totalNum = 0
+				if (!this.$util.isEmpty(this.sonItemList)){
+					this.sonItemList.forEach((item,idx,arr) => {
+						if(Number(item.sendSonStock)>0){
+							totalNum = totalNum + Number(item.sendSonStock)
+						}
+					})
+				}
+				let remain = Number(this.stock) - Number(totalNum)
+				remain = parseFloat(remain.toFixed(2))
+				this.remain = remain
+			},
 			linkChange(item){
-				let skMore = item.skMore
-				let hj
+				let skMore = item.skMore ? parseFloat(item.skMore) : 0
+				let hjAddPrice = item.hjAddPrice ? parseFloat(item.hjAddPrice) : 0
+				let addPrice = item.addPrice ? parseFloat(item.addPrice) : 0
+				if(Number(item.sendPfPrice)>0){
+					let lsDiff = Number(skMore) - Number(addPrice)
+					let lsPrice = Number(item.sendPfPrice) + Number(lsDiff)
+					lsPrice = parseFloat(lsPrice.toFixed(2))
+					item.sendLsPrice = lsPrice
+					let hyDiff = Number(addPrice) - Number(hjAddPrice)
+					let hyPrice = Number(item.sendPfPrice) - Number(hyDiff)
+					hyPrice = parseFloat(hyPrice.toFixed(2))
+					item.sendHyPrice = hyPrice
+				}else{
+					item.sendLsPrice = ''
+					item.sendHyPrice = ''
+				}
 			},
 			delItem(item){
 				let that = this
@@ -80,7 +111,6 @@
 				this.$util.confirmModal({content:'确认删除?'},() => {
 					delMsItem({motherId:motherId,id:item.id}).then(res=>{
 						if(res.code == 1){
-							that.$msg(res.msg)
 							that.init()
 						}
 					})
@@ -93,17 +123,64 @@
 			goBack(){
 				uni.navigateBack({});
 			},
-			confirmSend(){
-				if (!this.$util.isEmpty(this.sonItemList)){
-					this.sonItemList.forEach((item,idx,arr) => {
-						if(Number(item.sendSonStock)>0){
-							
-						}else{
-
+			toSend(){
+				let that = this
+				if (this.$util.isEmpty(this.sonItemList)){
+					this.$msg('没有花材')
+					return false
+				}
+				let hasErr = false
+				let errText = ''
+				let productList = []
+				for (const item of this.sonItemList) {
+					if(Number(item.sendSonStock)>0){
+						if(Number(item.sendHyPrice)<=0){
+							hasErr = true
+							errText = '请填写 '+item.name+' 会员价'
+							break
 						}
-					})
+						if(Number(item.sendLsPrice)<=0){
+							hasErr = true
+							errText = '请填写 '+item.name+' 零售价'
+							break
+						}
+						if(Number(item.sendPfPrice)<=0){
+							hasErr = true
+							errText = '请填写 '+item.name+' 批发价'
+							break
+						}
+						let groupItem = {id:item.id,stock:item.sendSonStock,lsPrice:item.sendLsPrice,pfPrice:item.sendPfPrice,hyPrice:item.sendHyPrice}
+						productList.push(groupItem)
+					}else{
+						if(Number(item.sendPfPrice)>0){
+							hasErr = true
+							errText = '请填写 '+item.name+' 数量'
+							break
+						}
+					}
 				}
-
+				if(hasErr == true){
+					that.$msg(errText)
+					return false
+				}
+				if (this.$util.isEmpty(productList)){
+					this.$msg('请填写数量和价格')
+					return false
+				}
+				console.log(productList)
+				console.log('---------')
+				let jsonProduct = JSON.stringify(productList)
+				let params = {product:jsonProduct}
+				this.$util.confirmModal({content:'确认分配?'},() => {
+					sendStockFn(params).then(res=>{
+						if(res.code == 1){
+							that.$msg('分配成功')
+							setTimeout(function(){
+								//that.goBack()
+							},1200)
+						}
+					})
+      			})
 			},
 			init(){
 				let productId = this.option.id ? this.option.id : 0
@@ -297,10 +374,10 @@
 						line-height: 60upx;
 						text-align: center;
 						background: #ffffff;
-						border: 1upx solid #b4b4b4;
+						border: 1upx solid #568014;
 						border-radius: 4upx;
-						font-size: 25upx;
-						color:#5e5d5d;
+						font-size: 30upx;
+						color:#568014;
 						position: absolute;
 						left:180upx;
 						top:15upx;
@@ -313,7 +390,7 @@
 						background: #ffffff;
 						border: 1upx solid #3385FF;
 						border-radius: 4upx;
-						font-size: 25upx;
+						font-size: 30upx;
 						color:#3385FF;
 						position: absolute;
 						left:180upx;
@@ -325,10 +402,10 @@
 						line-height: 60upx;
 						text-align: center;
 						background: #ffffff;
-						border: 1upx solid #b4b4b4;
+						border: 1upx solid #568014;
 						border-radius: 4upx;
-						font-size: 25upx;
-						color:#5e5d5d;
+						font-size: 30upx;
+						color:#568014;
 						position: absolute;
 						left:350upx;
 						top:15upx;
@@ -339,10 +416,10 @@
 						line-height: 60upx;
 						text-align: center;
 						background: #ffffff;
-						border: 1upx solid #3385FF;
+						border: 1upx solid #568014;
 						border-radius: 4upx;
-						font-size: 25upx;
-						color:#3385FF;
+						font-size: 30upx;
+						color:#568014;
 						position: absolute;
 						left:350upx;
 						top:-58upx;

+ 8 - 0
ghsApp/src/api/item/index.js

@@ -1,5 +1,13 @@
 import https from '@/plugins/luch-request_0.0.7/request'
 
+export const batchAddItem = data => {
+	return https.post('/item-ms/batch-add-item', data)
+}
+
+export const sendStockFn = data => {
+	return https.post('/item-ms/send-stock', data)
+}
+
 export const delMsItem = data => {
 	return https.get('/item-ms/del-item', data)
 }