Browse Source

前端gjy

gjy 3 years ago
parent
commit
3e70a140fc
3 changed files with 180 additions and 206 deletions
  1. 18 4
      pageA/product/Identity_switching.vue
  2. 161 201
      pageA/product/business_buy.vue
  3. 1 1
      pageA/product/detail.vue

+ 18 - 4
pageA/product/Identity_switching.vue

@@ -11,7 +11,13 @@
 						</view>
 						<view class="info">{{item.customerPhone}}</view>
 						<label>
-							<checkbox /><text>设置默认</text>
+							<u-checkbox 
+											@change.stop="checkboxChange" 
+											v-model="item.checked" 
+											:name="item.name"
+										>设置默认</u-checkbox>
+							<checkbox :value='item.id' :checked="item.defaultFlag" @click.stop="checkBox($event,item)" ></checkbox>
+							<text>设置默认</text>
 						</label>
 						
 					</view>
@@ -44,6 +50,7 @@
 				scrollTop: 0,
 				TabCur: 0,
 				current: 1,
+				checked:false,
 				identityAuthenticationInfo: {
 					pageSize: 10,
 					currentPage: 1,
@@ -53,9 +60,11 @@
 				},
 			};
 		},
-		onLoad() {
+		onShow(){
 			this.getList()
 		},
+		onLoad() {
+		},
 		computed: {
 			...mapState(['hasLogin', 'userInfo'])
 		},
@@ -68,8 +77,9 @@
 						currentPage: 1,
 						commonId: this.userInfo.id
 					}, 'application/json;charset=UTF-8').then(res => {
-						console.log("成功连接123")
-						this.lists = res.data.data.records
+						if(res.data.code==200){
+							this.lists = res.data.data.records
+						}
 					})
 					.catch(res => {
 						uni.showToast({
@@ -79,6 +89,10 @@
 						})
 					});
 			},
+			checkBox(e){
+				this.checked=!this.checked
+				console.log(e)
+			},
 			// adddriver(index) {
 			// 	if (index == 1) {
 			// 		uni.navigateTo({

+ 161 - 201
pageA/product/business_buy.vue

@@ -2,9 +2,8 @@
 	<view class="container">
 		<view  class="cu-form-group">
 			<view class="title">卖方</view>
-			
-			<view class="title" @click="liang">{{purchaseOrder.customerName}}></view>
-			
+			<view v-if='goods.customerTypeFlag==1' class="title" @click="liang">{{purchaseOrder.customer?purchaseOrder.customer:goods.customerName}}></view>
+			<view v-if='goods.customerTypeFlag==2' class="title" @click="liang">{{purchaseOrder.compName?purchaseOrder.compName:goods.compName}}></view>
 		</view>
 		<view  class="cu-form-group">
 			<view class="title">买方</view>
@@ -23,30 +22,26 @@
 		<view v-if='companyId!=2' class="cu-form-group">
 			<view class="title">货名</view>
 			<text>{{purchaseOrder.goodsName}}</text>
-			<!-- <input placeholder="请填写" name="input" @input="addressInput"></input> -->
 		</view>
 		<view class="cu-form-group">
 			<view class="title">最小成交量(吨)</view>
 			<text>{{purchaseOrder.minimumVolume}}</text>
 		</view>
-		<view  v-if="invoiceType !=2" class="cu-form-group">
+		<view  v-if="purchaseOrder.procurementPlanType=='期货'" class="cu-form-group">
 			<view  class="title">今日基差(元/吨)</view>
 				<view class="picker">
-					<text>{{purchaseOrder.basisPrice}}</text>
-					<!-- {{invoiceTypeIndex1>-1?invoiceType1[invoiceTypeIndex1]:'请选择'}} -->
+					<text>{{purchaseOrder.basis}}</text>
 				</view>
-			
 		</view>
 		<view v-else class="cu-form-group">
 			<view   class="title">采购单价(元/吨)</view>
 				<view class="picker">
 					<text>{{purchaseOrder.unitPrice}}</text>
-					<!-- {{invoiceTypeIndex>-1?invoiceType[invoiceTypeIndex]:'请选择'}} -->
 				</view>
 		</view>
 		<view class="cu-form-group margin-top">
 			<view class="title">发票类型</view>
-			<picker @change="packingChange" :value="packingIndex" :range="invoiceType">
+			<picker @change="invoiceChange" :value="invoiceIndex" :range="invoiceType">
 				<view class="picker">
 					{{packingIndex>-1?invoiceType[packingIndex]:'请选择'}}
 				</view>
@@ -54,7 +49,7 @@
 		</view>
 		<view  class="cu-form-group">
 			<view class="title">出售数量(吨)</view>
-			<input placeholder="请填写出售数量" name="input" @input='packingInput'></input>
+			<input v-model='purchaseOrder.transactionsNumber' placeholder="请填写出售数量" name="input"></input>
 		</view>
 		<view  class="cu-form-group">
 			<view class="title">包装方式</view>
@@ -64,28 +59,30 @@
 				</view>
 			</picker>
 		</view>
-		<view class="cu-form-group align-start">
+		<view v-if='packingIndex==0' class="cu-form-group align-start">
 			<view class="title">袋装备注</view>
-			<textarea maxlength="-1" :disabled="modalName!=null" @input="textareaInput" placeholder="请填写包装规格、质量、包装物要求。例:50kg袋装、大粒、彩包" ></textarea>
+			<textarea maxlength="-1" v-model='purchaseOrder.baggingNotes' placeholder="请填写包装规格、质量、包装物要求。例:50kg袋装、大粒、彩包" ></textarea>
 		</view>
-		<view class="cu-form-group align-start">
+		<view  v-if="purchaseOrder.procurementPlanType=='期货'" class="cu-form-group align-start">
 			<view class="title">点价(元/吨)</view>
-			<input placeholder="请填写点价" name="input" @input='packingInput' v-model="purchaseOrder.pointPrice"></input>
+			<input placeholder="请填写点价" name="input" @input='someprice' v-model="purchaseOrder.pointPrice"></input>
 		</view>
-		<view class="cu-form-group align-start">
+		<view  v-if="purchaseOrder.procurementPlanType=='期货'" class="cu-form-group align-start">
 			<view class="title">发票费用(元/吨)</view>
-			<input placeholder="请填写发票费用" name="input" @input='packingInput' v-model="purchaseOrder.invoiceFee"></input>
+			<input disabled placeholder="请填写发票费用" name="input" @input='someprice' v-model="purchaseOrder.invoiceFee"></input>
 		</view>
-		<view class="cu-form-group align-start">
+		<view  v-if="purchaseOrder.procurementPlanType=='期货'" class="cu-form-group align-start">
 			<view class="title">包装费(元/吨)</view>
-		<input placeholder="请填写包装费" name="input" @input='packingInput' v-model="purchaseOrder.packingFee"></input>
+		<input placeholder="请填写包装费" name="input" @input='someprice' v-model="purchaseOrder.packingFee"></input>
 		</view>
-		<view class="cu-form-group align-start">
+		<view  v-if="purchaseOrder.procurementPlanType=='期货'" class="cu-form-group align-start">
 			<view class="title">结算价格</view>
-			<text>{{Number(purchaseOrder.pointPrice)  + Number(purchaseOrder.invoiceFee)  + Number(purchaseOrder.packingFee) + Number(purchaseOrder.basisPrice)  }}</text>
-			
+			<text>{{purchaseOrder.settlementPrice}}</text>
 			<!-- <input placeholder="请填写 例:袋装XX斤/散装" name="input" @input='packingInput' v-model="purchaseOrder.settlementPrice"></input> -->
 		</view>
+		<view style='background:#fff;'>
+			结算价格=点价+基差+发票费用+包装费
+		</view>
 		<view class="padding flex flex-direction">
 			<button class="cu-btn bg-red margin-tb-sm lg" @click="commit()">提交</button>
 		</view>
@@ -93,6 +90,9 @@
 </template>
 
 <script>
+	import {
+	    mapState 
+	} from 'vuex';
 	export default {
 			data() {
 				return {
@@ -116,14 +116,21 @@
 						type:0,
 						modalName:"",
 					},
-					purchaseOrder: {},
+					purchaseOrder: {
+						invoiceFee:0,
+						packingFee:0,
+						packingType:"散装",
+						packingTypeKey:1,
+						type:'不开发票',
+						typeKey:1
+					},
 					invoiceTypeIndex:0,
 					invoiceTypeIndex1:0,
 					acceptTypeIndex:0,
 					priceTypeIndex:0,
 					bankNameIndex:0,
 					packingIndex:0,
-					// packingChange:['散袋(默认)','大袋','小袋'],
+					invoiceIndex:0,
 					packingType: ['散袋(默认)','大袋','小袋'],
 					// invoiceType: ['不开发票', '普通发票', '增值税发票'],
 					invoiceType: ['不开发票','增值税发票'],
@@ -138,6 +145,7 @@
 					unitPrice:0,
 					address:'',
 					count:0,
+					id:0,
 					price:'库内价',
 					invoice:'不开发票',
 					accept:'',
@@ -152,6 +160,7 @@
 					isFutures:'',
 					bankNameList:'',
 					Company:[],
+					goods:{},
 					companyId:'',
 					tradeCompanyId:'',
 					basis:0,
@@ -164,70 +173,40 @@
 				};
 			},
 			onLoad(options) {
-				// this.salebuyId = options.id
-				// this.seller = options.seller
-				// this.sellerPhone = options.sellerPhone
-				// this.isFutures = options.isFutures
-				// this.minSale = options.minSale
-				// this.companyId=options.companyId
-				// this.province = options.province
-				// this.city = options.city
-				// this.area = options.area
-				// this.storeName=options.storeName
-				// this.exsitCount = Math.floor(options.exsitCount * 100) / 100
-				// this.basis = options.basis
-				// this.basisBig = options.basisBig
-				// this.basisSmall = options.basisSmall
-				// this.unloadingFee = options.unloadingFee
-				// this.purchaseOrder.seller = options.seller
-				// this.purchaseOrder.goodsName = options.goodsName
-				// this.purchaseOrder.receivePrivate = options.receivePrivate
-				// this.purchaseOrder.receiveCity = options.receiveCity
-				// this.purchaseOrder.receiveArea = options.receiveArea
-				// this.purchaseOrder.minimumVolume = options.minimumVolume
-				// this.purchaseOrder.buyer = options.buyer
-				// this.purchaseOrder.customerName = options.customerName
-				// this.purchaseOrder.basisPrice = options.basisPrice
-				// this.purchaseOrder.unitPrice = options.unitPrice
-				// this.purchaseOrder.receiveWarehouse = options.receiveWarehouse
-				
+				this.id=options.id
+				this.purchaseOrder.seller = options.seller
+				this.purchaseOrder.goodsName = options.goodsName
+				this.purchaseOrder.receivePrivate = options.receivePrivate
+				this.purchaseOrder.receiveCity = options.receiveCity
+				this.purchaseOrder.receiveArea = options.receiveArea
+				this.purchaseOrder.minimumVolume = options.minimumVolume
+				this.purchaseOrder.buyer = options.buyer
+				this.purchaseOrder.customer = options.customerName
+				this.purchaseOrder.basis = options.basisPrice
+				this.purchaseOrder.unitPrice = options.unitPrice
+				this.purchaseOrder.receiveWarehouse = options.receiveWarehouse
+				this.purchaseOrder.settlementPrice = options.basisPrice
+				this.purchaseOrder.procurementPlanType = options.procurementPlanType
+				this.purchaseOrder.procurementPlan=options.procurementPlanNo
+			},
+			computed: {
+				...mapState(['hasLogin','userInfo']),
 			},
 			onShow() {
-				var that=this
-				this.$api.request('company', 'getCompany', failres => {
-					that.$api.msg(failres.errmsg)
-					uni.hideLoading()
-				}).then(res => {
-					if(res.data.code=='SUCCESS'){
-						var data=[]
-						this.Company=res.data.data
-						if(res.data.data){
-							for(let i=0;i<res.data.data.length;i++){
-								data.push(res.data.data[i].companyName+' '+res.data.data[i].companyPhone)
-							}
-						}
-						if(this.Company){
-							this.buyer =this.Company[0].companyName
-							this.buyerPhone=this.Company[0].companyPhone
-							this.tradeCompanyId=this.Company[0].id
+				this.$api.doRequest('get', '/identityAuthenticationInfo/getInfo',{commonId:this.userInfo.id}).then(res => {
+					if(res.data.code==200){
+						this.goods=res.data.data
+						if(this.goods.customerTypeFlag==1){
+							this.purchaseOrder.invoiceFee=-20
+							this.purchaseOrder.settlementPrice = Number(this.purchaseOrder.basis)+Number(this.purchaseOrder.invoiceFee)
+						}else{
+							this.purchaseOrder.invoiceFee=0
+							this.purchaseOrder.settlementPrice = Number(this.purchaseOrder.basis)+Number(this.purchaseOrder.invoiceFee)
 						}
-						that.bankNameList=data
-						uni.hideLoading()
-					}else{
-						that.$api.msg(res.data.code)
-						uni.hideLoading()
 					}
+					uni.hideLoading()
 				})
-				},
-				// uni.getLocation({
-				//     type: 'wgs84',
-				// 	geocode:true,
-				//     success: function (res) {
-				//         console.log('当前位置的经度:' + res.longitude);
-				//         console.log('当前位置的纬度:' + res.latitude);
-				//     }
-				// });
-			// },
+			},
 			methods: {
 				liang(){
 					uni.navigateTo({
@@ -235,29 +214,94 @@
 					})
 				},
 				commit(){
-					this.$api.doRequest('post','/purchaseOrder/api/insertPurchaseOrder', this.purchaseOrder).then(res => {
-					console.log("成功123")
-					}).catch(res => {
-						uni.showToast({
-							title: res.data.message,
-							icon: 'none',
-							duration: 2000
-						})
+					if(!this.purchaseOrder.transactionsNumber){
+						this.$api.msg('出售价格不能为空')
+						return
+					}
+					if(this.purchaseOrder.transactionsNumber>10000||this.purchaseOrder.transactionsNumber<1){
+						this.$api.msg('出售数量输入错误')
+						return
+					}
+					if(!this.purchaseOrder.pointPrice){
+						this.$api.msg('点价不能为空')
+						return
+					}
+					if(this.purchaseOrder.pointPrice>10000){
+						this.$api.msg('点价输入错误')
+						return
+					}
+					if(this.purchaseOrder.pointPrice.indexOf('.')!=-1){
+						if(this.purchaseOrder.pointPrice.split(".")[1].length>2){
+							this.$api.msg('点价输入错误')
+							return
+						}
+					}
+					if(this.purchaseOrder.packingFee>0||this.purchaseOrder.packingFee<-2000){
+						this.$api.msg('包装费输入错误')
+						return
+					}
+					if(!this.purchaseOrder.customer){
+						if(this.goods.customerTypeFlag==1){
+							this.purchaseOrder.customer=this.goods.customerName
+						}else{
+							this.purchaseOrder.customer=this.goods.compName
+						}
+					}
+					if(!this.purchaseOrder.seller){
+						if(this.goods.customerTypeFlag==1){
+							this.purchaseOrder.seller=this.goods.customerName
+							this.purchaseOrder.sellerPhone=this.goods.customerPhone
+						}else{
+							this.purchaseOrder.seller=this.goods.compName
+							this.purchaseOrder.sellerPhone=this.goods.customerPhone
+						}
+					}
+					var that=this
+					uni.showModal({
+						content: '订单提交后将发送给买方,是否确定提交?',
+						success: function (res) {
+							if (res.confirm) {
+								that.$api.doRequest('post','/purchaseOrder/api/insertPurchaseOrder', that.purchaseOrder).then(res => {
+									if(res.data.code==200){
+										uni.showToast({
+											title: '提交成功,等待买方回复',
+											icon: 'none',
+											duration: 2000
+										})
+										// uni.navigateBack();
+									}else{
+										uni.showToast({
+											title: '提交失败:'+res.data.message,
+											icon: 'none',
+											duration: 2000
+										})
+									}
+								}).catch(res => {
+									uni.showToast({
+										title: res.data.message,
+										icon: 'none',
+										duration: 2000
+									})
+								})
+							}
+						}
 					})
 				},
-				InvoiceTypeChange(e) {
-					this.invoiceTypeIndex = e.detail.value
-					this.invoice = this.invoiceType[this.invoiceTypeIndex];
-					
-				},
-				InvoiceTypeChange1(e) {
-					this.invoiceTypeIndex1 = e.detail.value
-					this.invoice = this.invoiceType1[this.invoiceTypeIndex1];
-					if(this.invoiceTypeIndex1 == 0){
-						this.invoiceMoney = 0
-					}
-					else{
-						this.invoiceMoney = 20
+				someprice(e){
+					if(this.purchaseOrder.pointPrice&&this.purchaseOrder.invoiceFee&&this.purchaseOrder.packingFee){
+						this.purchaseOrder.settlementPrice=Number(this.purchaseOrder.basis)+Number(this.purchaseOrder.pointPrice)+Number(this.purchaseOrder.invoiceFee)+Number(-this.purchaseOrder.packingFee)
+					}else if(this.purchaseOrder.pointPrice&&this.purchaseOrder.invoiceFee){
+						this.purchaseOrder.settlementPrice=Number(this.purchaseOrder.basis)+Number(this.purchaseOrder.pointPrice)+Number(this.purchaseOrder.invoiceFee)
+					}else if(this.purchaseOrder.pointPrice&&this.purchaseOrder.packingFee){
+						this.purchaseOrder.settlementPrice=Number(this.purchaseOrder.basis)+Number(this.purchaseOrder.pointPrice)+Number(-this.purchaseOrder.packingFee)
+					}else if(this.purchaseOrder.pointPrice){
+						this.purchaseOrder.settlementPrice=Number(this.purchaseOrder.basis)+Number(this.purchaseOrder.pointPrice)
+					}else if(this.purchaseOrder.packingFee){
+						this.purchaseOrder.settlementPrice=Number(this.purchaseOrder.basis)+Number(-this.purchaseOrder.packingFee)
+					}else if(this.purchaseOrder.invoiceFee){
+						this.purchaseOrder.settlementPrice=Number(this.purchaseOrder.basis)+Number(this.purchaseOrder.invoiceFee)
+					}else{
+						this.purchaseOrder.settlementPrice=this.purchaseOrder.basis
 					}
 				},
 				bankNameChange(e){
@@ -272,15 +316,19 @@
 				},
 				packingChange(e){
 					this.packingIndex = e.detail.value
-					this.packing = this.packingType[this.packingIndex];
-					if(this.packingIndex == 0){
-						this.packingMoney = 0
-					}
-					else if(this.packingIndex == 1){
-						this.packingMoney = this.basisBig - this.basis
-					}
-					else if(this.packingIndex == 2){
-						this.packingMoney = this.basisSmall - this.basis
+					this.purchaseOrder.packingTypeKey=e.detail.value+1
+					this.purchaseOrder.packingType = this.packingType[this.packingIndex];
+				},
+				invoiceChange(e){
+					this.invoiceIndex = e.detail.value
+					this.purchaseOrder.typeKey=e.detail.value+1
+					this.purchaseOrder.type = this.invoiceType[this.invoiceIndex];
+					if(this.invoiceIndex == 0){
+						if(this.goods.customerTypeFlag==1){
+							this.purchaseOrder.invoiceFee=-20
+						}else{
+							this.purchaseOrder.invoiceFee=0
+						}
 					}
 				},
 				changeZhihang(){
@@ -300,9 +348,6 @@
 				textareaInput(e) {
 					this.memo = e.detail.value
 				},
-				packingInput(e){
-					this.packing = e.detail.value
-				},
 				buyerInput(e){
 					this.buyer = e.detail.value
 				},
@@ -318,91 +363,6 @@
 				countInput(e){
 					this.count = e.detail.value
 				},
-				commit(){
-					const that = this
-					// if ( that.companyId !=2&& !that.address) {
-					// 	that.$api.msg('请填写详细交收地址')
-					// 	return
-					// }
-					if (!that.price) {
-						that.$api.msg('请选择出售数量')
-						return
-					}
-					if (!that.invoice) {
-						that.$api.msg('请选择发票类型')
-						return
-					}
-						if (!that.packingType) {
-						that.$api.msg('请选择包装类型')
-						return
-					}
-					if(!that.pointPrice){
-						that.$api.msg('请填写点价');
-						return
-					}
-					if (!that.invoiceFee) {
-						that.$api.msg('请填写发票费用')
-						return
-					}
-					// if(Number(that.count) < Number(that.minSale)){
-					// 	that.$api.msg('购买数量不能小于最小成交量');
-					// 	return
-					// }
-					// if(!that.tradeCompanyId){
-					// 	that.$api.msg('请选择公司名头');
-					// 	return
-					// }
-					// if(that.count > that.exsitCount){
-					// 	that.$api.msg('购买数量大于库存量');
-					// 	return
-					// }
-					//this.$api.prePage()获取上一页实例,可直接调用上页所有数据和方法,在App.vue定义
-					
-					// this.$api.msg(`地址${this.manageType=='edit' ? '修改': '添加'}成功`);
-					that.tradeInfo.salebuyId = that.salebuyId
-					that.tradeInfo.buyer = that.buyer
-					that.tradeInfo.buyerPhone = that.buyerPhone
-					that.tradeInfo.priceType = that.price
-					that.tradeInfo.unitPrice = that.unitPrice
-					that.tradeInfo.province = that.province
-					that.tradeInfo.area = that.area
-					that.tradeInfo.address = that.address
-					that.tradeInfo.count = that.count
-					that.tradeInfo.acceptType = that.accept
-					that.tradeInfo.invoiceType = that.invoice
-					that.tradeInfo.packing = that.packing
-					that.tradeInfo.packingMoney = that.packingMoney
-					that.tradeInfo.memo = that.memo
-					that.tradeInfo.seller = that.seller
-					that.tradeInfo.sellerPhone = that.sellerPhone
-					that.tradeInfo.tradeCompanyId = that.tradeCompanyId
-					that.tradeInfo.invoiceMoney = that.invoiceMoney
-					// that.tradeInfo.unloadingFee = that.unloadingFee
-					uni.showLoading({
-						title: '正在提交',
-						mask:true
-					})
-					that.$api.request('trade', 'addTrade',that.tradeInfo, failres => {
-						uni.hideLoading()
-						that.$api.msg(failres.errmsg);
-						
-					}).then(res => {
-						uni.hideLoading()
-						uni.showModal({
-							title: '提示',
-							content: "交易申请提交成功",
-							showCancel: false,
-							confirmText: '确定',
-							success: () => {
-								uni.navigateBack({
-									delta: 2
-								})
-							}
-						})
-						// that.$api.prePage().refreshList(data, that.manageType);
-					})
-				
-				}
 			}
 		}
 </script>

+ 1 - 1
pageA/product/detail.vue

@@ -407,7 +407,7 @@
 								url: `/pageA/product/business_buy?id=${this.goods.id}&receiveArea=${this.goods.receiveArea}&minimumVolume=${this.goods.minimumVolume}
 										&goodsName=${this.goods.goodsName}&receiveCity=${this.goods.receiveCity}&receivePrivate=${this.goods.receivePrivate}&buyer=${this.goods.buyer}
 										&basisPrice=${this.goods.basisPrice}&unitPrice=${this.goods.unitPrice}&receiveWarehouse=${this.goods.receiveWarehouse}
-										`
+										&procurementPlanType=${this.goods.procurementPlanType}&procurementPlan=${this.goods.procurementPlanNo}`
 							// 	url: `/pageA/product/business_buy?id=${this.goods.id}&packing=${this.goods.packing}}&province=${this.goods.province}
 							// 	&city=${this.goods.city}&area=${this.goods.area}&storeName=${this.goods.storeName}&seller=${this.goods.seller}
 							// 	&companyId=${this.goods.companyId}&sellerPhone=${this.goods.sellerPhone}&minSale=${this.goods.minSale}