| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199 | 
							- <template>
 
- 	<!-- 添加运单 -->
 
- 	<view>
 
- 		<u-navbar :title="headline" autoBack placeholder></u-navbar>
 
- 		<view class="title_waybill">寄件人:</view>
 
- 		<x-form ref="sender" :list="list" :model="senderModel" :rules="rules"></x-form>
 
- 		<view class="title_waybill">收件人:</view>
 
- 		<x-form ref="recipients" :list="list" :model="recipientsModel" :rules="rules"></x-form>
 
- 		<view class="title_waybill1"></view>
 
- 		<x-form ref="goods" :list="goodsList" :model="goodsModel" :rules="goodsRules"></x-form>
 
- 		<view style="width: 100%;height: 150rpx;"></view>
 
- 		<view class="btn_print" @click="printWaybill">
 
- 			<u-button type="primary" :text="headline"></u-button>
 
- 		</view>
 
- 	</view>
 
- </template>
 
- <script>
 
- 	import {
 
- 		formRules,
 
- 		pickupRulesil
 
- 	} from "./waybill.js";
 
- 	export default {
 
- 		name: 'addWaybill',
 
- 		data() {
 
- 			return {
 
- 				senderModel: {
 
- 					name: '',
 
- 					phone: '',
 
- 					address: '',
 
- 				},
 
- 				recipientsModel: {
 
- 					name: '',
 
- 					phone: '',
 
- 					address: '',
 
- 				},
 
- 				goodsModel: {
 
- 					tamperProofLabel: '',
 
- 					tamperProofLabelImg: '',
 
- 					remark: '',
 
- 				},
 
- 				rules: {
 
- 					name: {
 
- 						required: true,
 
- 						message: '请输入姓名',
 
- 						trigger: ['blur', 'change']
 
- 					},
 
- 					phone: {
 
- 						required: true,
 
- 						message: '请输入电话',
 
- 						trigger: ['blur', 'change']
 
- 					},
 
- 					address: {
 
- 						required: true,
 
- 						message: '请输入地址',
 
- 						trigger: ['blur', 'change']
 
- 					},
 
- 				},
 
- 				goodsRules: {
 
- 					tamperProofLabel: {
 
- 						required: true,
 
- 						message: '请输入防拆标签码',
 
- 						trigger: ['blur', 'change']
 
- 					},
 
- 					tamperProofLabelImg: {
 
- 						required: true,
 
- 						message: '请上传防拆标签图片',
 
- 						trigger: ['blur', 'change']
 
- 					},
 
- 				},
 
- 				list: pickupRulesil(),
 
- 				goodsList: formRules(),
 
- 				userInfo: {},
 
- 				headline: '添加运单',
 
- 				type: 1,
 
- 			}
 
- 		},
 
- 		onLoad(value) {
 
- 			this.headline = value.title
 
- 			this.type = Number(value.type)
 
- 			if (this.type == 2) {
 
- 				var orderList = this.$cache.getCache('orderDetails')
 
- 				this.senderModel.name = orderList.senderAddressName
 
- 				this.senderModel.phone = orderList.senderAddressPhone
 
- 				this.senderModel.address = orderList.senderAddressDetails
 
- 				this.recipientsModel.name = orderList.consigneeAddressName
 
- 				this.recipientsModel.phone = orderList.consigneeAddressPhone
 
- 				this.recipientsModel.address = orderList.consigneeAddressDetails
 
- 				this.goodsModel.tamperProofLabel = orderList.tamperProofLabel
 
- 				this.goodsModel.tamperProofLabelImg = orderList.tamperProofLabelImg
 
- 				this.goodsModel.remark = orderList.remark
 
- 				this.goodsModel.id = orderList.id
 
- 				if (orderList.tamperProofLabelImg) {
 
- 					let arrImg = orderList.tamperProofLabelImg.split(',')
 
- 					let arrImgList = []
 
- 					arrImg.forEach((item) => {
 
- 						const arr = {
 
- 							url: item,
 
- 						}
 
- 						arrImgList.push(arr)
 
- 					})
 
- 					this.$nextTick(() => {
 
- 						this.$refs.goods.fileList1 = arrImgList
 
- 					})
 
- 				}
 
- 			}
 
- 		},
 
- 		mounted() {
 
- 			var userInfo = this.$cache.getCache('userInfo')
 
- 			this.userInfo = userInfo
 
- 		},
 
- 		methods: {
 
- 			// tianjia运单
 
- 			async printWaybill() {
 
- 				let flag = await this.$refs['sender'].validateForm();
 
- 				let flag1 = await this.$refs['recipients'].validateForm();
 
- 				let flag2 = await this.$refs['goods'].validateForm();
 
- 				if (flag && flag1 && flag2) {
 
- 					let params = {
 
- 						senderAddressName: this.senderModel.name,
 
- 						senderAddressPhone: this.senderModel.phone,
 
- 						senderAddressDetails: this.senderModel.address,
 
- 						consigneeAddressName: this.recipientsModel.name,
 
- 						consigneeAddressPhone: this.recipientsModel.phone,
 
- 						consigneeAddressDetails: this.recipientsModel.address,
 
- 						...this.goodsModel,
 
- 					}
 
- 					uni.showLoading();
 
- 					if (this.type == 1) {
 
- 						// 添加订单
 
- 						this.$api.post('/api/waybill', params).then(res => {
 
- 							if (res.code == 200) {
 
- 								uni.redirectTo({
 
- 									url: '/pages/order/index'
 
- 								});
 
- 							} else {
 
- 								uni.$u.toast('添加失败')
 
- 							}
 
- 							uni.hideLoading();
 
- 						}).catch(() => {
 
- 							uni.hideLoading();
 
- 						})
 
- 					} else {
 
- 						// 修改订单
 
- 						this.$api.put('/api/waybill', params).then(res => {
 
- 							if (res.code == 200) {
 
- 								// uni.$u.toast(res.msg)
 
- 								uni.redirectTo({
 
- 									url: '/pages/order/index'
 
- 								});
 
- 							} else {
 
- 								uni.$u.toast('修改失败')
 
- 							}
 
- 							uni.hideLoading();
 
- 						}).catch(() => {
 
- 							uni.hideLoading();
 
- 						})
 
- 					}
 
- 				} else {
 
- 					uni.$u.toast('请先完善表单')
 
- 				}
 
- 			}
 
- 		}
 
- 	}
 
- </script>
 
- <style lang="scss">
 
- 	page {
 
- 		background-color: #fff !important;
 
- 	}
 
- 	.title_waybill {
 
- 		position: relative;
 
- 		margin: 20rpx;
 
- 		border-bottom: 1rpx;
 
- 		padding-bottom: 20rpx;
 
- 	}
 
- 	.title_waybill1 {
 
- 		position: relative;
 
- 		margin: 20rpx;
 
- 		border-bottom: 1rpx;
 
- 		padding-bottom: 20rpx;
 
- 	}
 
- 	.title_waybill:before {
 
- 		content: " ";
 
- 		position: absolute;
 
- 		left: 0;
 
- 		bottom: 0;
 
- 		width: 100%;
 
- 		height: 1px;
 
- 		border-top: 1px solid #e7e6e4;
 
- 		-webkit-transform-origin: 0 0;
 
- 		transform-origin: 0 0;
 
- 		-webkit-transform: scaleY(0.5);
 
- 		transform: scaleY(0.5);
 
- 	}
 
- </style>
 
 
  |