shish 2 tahun lalu
induk
melakukan
e9e5263e89

+ 24 - 1
ghsApp/src/mixins/product2.js

@@ -22,7 +22,7 @@ export default {
 			globalCheckStock:true,// 考虑库存,盘点不需要考虑库存
 			isAddModel:false,
 			isAddInputFocus:false,
-			customData: { bigCount: 0, smallCount: 0, userPrice: 0 },
+			customData: { bigCount: 0, smallCount: 0, userPrice: 0,aboutPrice:0,totalPrice:0 },
 			globalItemList:[],
 			globalUnitType:0,
 			globalAllProduct:[],
@@ -212,10 +212,14 @@ export default {
 					that.globalItemData[i].bigCount = selectProduct.bigCount || 0
 					that.globalItemData[i].userPrice = selectProduct.userPrice || 0
 					that.globalItemData[i].smallCount = selectProduct.smallCount || 0
+					that.globalItemData[i].totalPrice = selectProduct.totalPrice || 0
+					that.globalItemData[i].aboutPrice = selectProduct.aboutPrice || 0
 				}else{
 					that.globalItemData[i].bigCount = 0
 					that.globalItemData[i].userPrice = 0
 					that.globalItemData[i].smallCount = 0
+					that.globalItemData[i].totalPrice = 0
+					that.globalItemData[i].aboutPrice = 0
 				}
 				let cName = ''
 				if(hasExists[currentClassId]){
@@ -372,6 +376,8 @@ export default {
 					list[index].bigCount = item.bigCount
 					list[index].smallCount = item.smallCount
 					list[index].userPrice = item.userPrice
+					list[index].aboutPrice = item.aboutPrice||0
+					list[index].totalPrice = item.totalPrice||0
 				}
 			}
 			//点击要响声
@@ -485,6 +491,10 @@ export default {
 				}else{
 					this.customData.userPrice = this.customData.userPrice==0 ? null : parseFloat(this.customData.userPrice)
 				}
+				if(this.selectJobType == 'purchase'){
+					this.customData.totalPrice = this.customData.totalPrice ? Number(this.customData.totalPrice) : null
+					this.customData.aboutPrice = this.customData.aboutPrice||0
+				}
 				this.isAddInputFocus = true;
 			})
 		},
@@ -524,6 +534,19 @@ export default {
 					return;
 				}
 			}
+			if(this.selectJobType == 'purchase'){
+				if(this.customData.aboutPrice == 1){
+					if(Number(this.customData.totalPrice)<=0){
+						uni.showToast({title:"请填写总金额"+this.customData.totalPrice,icon:"none"})
+						return;
+					}
+					if(/(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/.test(this.customData.totalPrice) == false){
+						uni.showToast({title:"请填写总金额哦",icon:"none"})
+						return;
+					}
+				}
+			}
+
 			this.replaceItemFn(this.customData,1)
 			this.addItemModelHidden()			
 		},

+ 87 - 23
ghsApp/src/pagesPurchase/add.vue

@@ -50,27 +50,14 @@
 				<view class="select-view">
 					<view class="select-cmd_bx">
 						<view class="num_bx">
-							
-							<!-- #ifdef APP-PLUS -->
-							<input v-model="customData.bigCount" type="number" v-if="globalUnitType == 0" @focus="customData.bigCount = null" placeholder="扎数" />
-							<input v-model="customData.smallCount" type="number" v-else @focus="customData.smallCount = null" placeholder="支数" />
-							<!-- #endif -->
-							<!-- #ifdef MP-WEIXIN -->							
-							<input v-model="customData.bigCount" type="number" v-if="globalUnitType == 0" @focus="customData.bigCount = null" :focus="isAddInputFocus" placeholder="扎数" />
-							<input v-model="customData.smallCount" type="number" v-else @focus="customData.smallCount = null" :focus="isAddInputFocus" placeholder="支数" />
-							<!-- #endif -->
-
-							<input v-model="customData.userPrice" @focus="customData.userPrice = null" type="digit" placeholder="单价" />
-
-							<text v-if="Number(customData.bigCount)>0">¥{{customData.userPrice && customData.bigCount ? parseFloat((customData.userPrice*customData.bigCount).toFixed(2)):0}}</text>
-							<text v-else>¥{{customData.userPrice && customData.smallCount ? parseFloat((customData.userPrice*customData.smallCount).toFixed(2)):0}}</text>
-
+							<input v-model="customData.bigCount" type="number" v-if="cgUnitType == 0" @focus="customData.bigCount = null" placeholder="扎数" @input="bigCountChange" />
+							<input v-model="customData.smallCount" type="number" v-else @focus="customData.smallCount = null" placeholder="支数" @input="smallCountChange" />
+							<input v-model="customData.userPrice" @focus="customData.userPrice = null" type="digit" placeholder="单价" @input="userPriceChange" />
+							<input v-model="customData.totalPrice" @focus="customData.totalPrice = null" type="digit" placeholder="总价" @input="totalPriceChange" />
 						</view>
+						<view v-if="customData.aboutPrice == 1" style="margin-top:8upx;text-align:center;color:blue;">单价为近似值</view>
+						<view v-else style="margin-top:8upx;text-align:center;">----</view>
 					</view>
-					
-					<image @click="switchGlobalUnitType" :src="`${constant.imgUrl}/icon/switch/switch128.png`" mode="widthFix" 
-					style="width:60upx;height:60upx;position:absolute;top:32upx;left:30upx;" ></image>
-					
 				</view>
 			</template>
 		</modal-module>
@@ -102,6 +89,7 @@ import FooterCart from "@/components/module/app-footer-cart";
 import productMins from "@/mixins/product2";
 import { mapGetters } from "vuex";
 import { delStatusUpdate } from '@/api/product';
+import { getShopInfoApi } from "@/api/common";
 export default {
 	name: "purchase",
 	components: {
@@ -123,7 +111,8 @@ export default {
 			showSubmitModel: false,
 			autoLoad: false,//不自动请求花材数据
 			showButton:[{text: '取消',plain: true}, {text: '确定',plain: false}],
-			globalCheckStock:false
+			globalCheckStock:false,
+			cgUnitType:0
 		};
 	},
 	computed:{
@@ -132,10 +121,18 @@ export default {
 			let price = 0;
 			if (this.selectList) {
 				for (const item of this.selectList) {
-					if(Number(item.bigCount)>0){
-						price += Number(item.userPrice)*Number(item.bigCount)
+					if(this.cgUnitType == 0){
+						if(item.aboutPrice == 1){
+							price += Number(item.totalPrice)
+						}else{
+							price += Number(item.userPrice)*Number(item.bigCount)
+						}
 					}else{
-						price += Number(item.userPrice)*Number(item.smallCount)
+						if(item.aboutPrice == 1){
+							price += Number(item.totalPrice)
+						}else{
+							price += Number(item.userPrice)*Number(item.smallCount)	
+						}
 					}
 				}
 			}
@@ -154,8 +151,75 @@ export default {
 		if(this.option.ghsName){
 			uni.setNavigationBarTitle({ title: this.option.ghsName })
 		}
+		let that = this
+		getShopInfoApi().then(res=>{
+			if(res.code == 1){
+				this.cgUnitType = res.data.shopInfo && res.data.shopInfo.cgUnitType ? res.data.shopInfo.cgUnitType : 0
+			}
+		})
 	},
 	methods: {
+		totalPriceChange(){
+			if(Number(this.customData.totalPrice)>0){
+				if(this.cgUnitType == 0){
+				if(Number(this.customData.bigCount)>0){
+					let a = Number(this.customData.totalPrice)/Number(this.customData.bigCount)
+					this.customData.userPrice = Math.floor(a*100)/100
+
+					let newNum = Number(this.customData.userPrice)*Number(this.customData.bigCount)
+					newNum = parseFloat(newNum.toFixed(2))
+					if(Number(this.customData.totalPrice) > Number(newNum)){
+					this.customData.aboutPrice = 1
+					}else{
+					this.customData.aboutPrice = 0
+					}
+				}
+				}else{
+				if(Number(this.customData.smallCount)>0){
+					let a = Number(this.customData.totalPrice)/Number(this.customData.smallCount)
+					this.customData.userPrice = Math.floor(a*100)/100
+					let newNum = Number(this.customData.userPrice)*Number(this.customData.smallCount)
+					newNum = parseFloat(newNum.toFixed(2))
+					if(Number(this.customData.totalPrice) > Number(newNum)){
+					this.customData.aboutPrice = 1
+					}else{
+					this.customData.aboutPrice = 0
+					}
+				}
+				}
+			}
+		},
+		userPriceChange(){
+			if(Number(this.customData.userPrice)>0){
+				if(this.cgUnitType == 0){
+				if(Number(this.customData.bigCount)>0){
+					this.customData.totalPrice = Number(this.customData.bigCount)*Number(this.customData.userPrice)
+					this.customData.totalPrice = parseFloat(this.customData.totalPrice.toFixed(2))
+				}
+				}else{
+				if(Number(this.customData.smallCount)>0){
+					this.customData.totalPrice = Number(this.customData.smallCount)*Number(this.customData.userPrice)
+					this.customData.totalPrice = parseFloat(this.customData.totalPrice.toFixed(2))
+				}
+				}
+			}
+		},
+		bigCountChange(){
+			if(Number(this.customData.bigCount)>0){
+				if(Number(this.customData.userPrice)>0){
+				this.customData.totalPrice = Number(this.customData.bigCount)*Number(this.customData.userPrice)
+				this.customData.totalPrice = parseFloat(this.customData.totalPrice.toFixed(2))
+				}
+			}
+		},
+		smallCountChange(){
+			if(Number(this.customData.smallCount)>0){
+				if(Number(this.customData.userPrice)>0){
+				this.customData.totalPrice = Number(this.customData.smallCount)*Number(this.customData.userPrice)
+				this.customData.totalPrice = parseFloat(this.customData.totalPrice.toFixed(2))
+				}
+			}
+		},
 		delProduct(info){
 			let that = this
 			that.$util.confirmModal({content:'确认删除?'},() => {

+ 9 - 3
ghsApp/src/pagesPurchase/components/CommodityPurchase.vue

@@ -64,7 +64,7 @@ export default {
       required: true,
       type: Object,
       default () {
-        return {bigCount:0,smallCount:0,userPrice:0};
+        return {bigCount:0,smallCount:0,userPrice:0,totalPrice:0,aboutPrice:0};
       }
     },
     type: {
@@ -76,7 +76,9 @@ export default {
     return {
 			bigCount:0,
 			smallCount:0,
-			userPrice:0
+			userPrice:0,
+      totalPrice:0,
+      aboutPrice:0
     };
   },
 	watch:{
@@ -85,6 +87,8 @@ export default {
         this.bigCount = this.info.bigCount
         this.smallCount = this.info.smallCount
         this.userPrice = this.info.userPrice
+        this.totalPrice = this.info.totalPrice,
+        this.aboutPrice = this.info.aboutPrice
       },
       deep:true
     }
@@ -94,6 +98,8 @@ export default {
 		this.bigCount = this.info.bigCount
 		this.smallCount = this.info.smallCount
 		this.userPrice = this.info.userPrice
+    this.totalPrice = this.info.totalPrice,
+    this.aboutPrice = this.info.aboutPrice
   },
   methods: {
     delProduct(info){
@@ -117,7 +123,7 @@ export default {
       this.$emit("replaceItemFn", this.info,1)
     },
     showAddModelFn () {
-        this.$emit("showAddModelFn", { ...this.info, bigCount: this.bigCount, smallCount: this.smallCount, userPrice: this.userPrice })
+        this.$emit("showAddModelFn", { ...this.info, bigCount: this.bigCount, smallCount: this.smallCount, userPrice: this.userPrice,totalPrice:this.totalPrice,aboutPrice:this.aboutPrice })
     }
   }
 };

+ 25 - 8
ghsApp/src/pagesPurchase/details.vue

@@ -12,8 +12,9 @@
 									<view class="info-line">
 										<text class="item-name">{{ item.name||'' }}</text>
 										<text class="item-price">
-											<text class="price" v-if="Number(item.bigCount)>0">¥{{parseFloat((Number(item.bigCount)*Number(item.userPrice)).toFixed(2))}}</text>
-											<text class="price" v-if="Number(item.smallCount)>0">¥{{parseFloat((Number(item.smallCount)*Number(item.userPrice)).toFixed(2))}}</text>
+											
+											<text class="price">¥{{item.totalPrice ? item.totalPrice : 0}}</text>
+
 										</text>
 									</view>
 									<view class="info-line">
@@ -197,6 +198,7 @@ import { PURCHASE_ORDER_STATUS } from "@/utils/declare";
 import AppDatePicker from "@/components/app-date-picker";
 import { getPrint } from "@/api/shop";
 import { getAllStaff } from "@/api/shop-admin"
+import { getShopInfoApi } from "@/api/common"
 export default {
 	components: {
 		TuiListCell,
@@ -235,7 +237,8 @@ export default {
 			totalFreight:0,
 			perKgFreight:0,
 			location:0,
-			wcPrintList:[]
+			wcPrintList:[],
+			cgUnitType:0
 		};
 	},
 	onLoad() {
@@ -262,6 +265,11 @@ export default {
 			})
 		}
 		this.initData();
+		getShopInfoApi().then(res=>{
+			if(res.code == 1){
+				that.cgUnitType = res.data.shopInfo && res.data.shopInfo.cgUnitType ? res.data.shopInfo.cgUnitType : 0
+			}
+		})
 	},
 	onShow(){
 		if(!this.$util.isEmpty(uni.getStorageSync("newGhs"))){
@@ -303,12 +311,19 @@ export default {
 		selectAllPrice(){
 			let price = 0;
 			if (this.selectList) {
-				console.log(this.selectList,'selectList')
 				for (const item of this.selectList) {
-					if(Number(item.bigCount)>0){
-						price += Number(item.userPrice)*Number(item.bigCount);
+					if(this.cgUnitType == 0){
+						if(item.aboutPrice && item.aboutPrice == 1){
+							price += Number(item.totalPrice)
+						}else{
+							price += Number(item.userPrice)*Number(item.bigCount);
+						}
 					}else{
-						price += Number(item.userPrice)*Number(item.smallCount);
+						if(item.aboutPrice && item.aboutPrice == 1){
+							price += Number(item.totalPrice)
+						}else{
+							price += Number(item.userPrice)*Number(item.smallCount);
+						}
 					}
 				}
 			}
@@ -460,7 +475,9 @@ export default {
 					itemId:ele.itemId,
 					itemPrice: ele.userPrice,
 					ratio:ele.ratio,
-					ratioType:ele.ratioType
+					ratioType:ele.ratioType,
+					aboutPrice:ele.aboutPrice||0,
+					totalPrice:ele.totalPrice||0,
 				}
 			})
 			formData.itemInfo = JSON.stringify(itemInfo)