123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164 |
- <template>
- <!-- 添加运单 -->
- <view>
- <u-navbar title="添加运单" 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_waybill">物品信息:</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="添加运单"></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: {
- temperatureInterval: '',
- deliveryCondition: '',
- cargoType: '',
- remark: '',
- customerName: '',
- },
- rules: {
- name: {
- required: true,
- message: '请输入姓名',
- trigger: ['blur', 'change']
- },
- phone: {
- required: true,
- message: '请输入电话',
- trigger: ['blur', 'change']
- },
- address: {
- required: true,
- message: '请输入地址',
- trigger: ['blur', 'change']
- },
- },
- goodsRules: {
- temperatureInterval: {
- required: true,
- message: '请选择温度需求',
- trigger: ['blur', 'change']
- },
- deliveryCondition: {
- required: true,
- message: '请选择配送要求',
- trigger: ['blur', 'change']
- },
- cargoType: {
- required: true,
- message: '请选择货物类型',
- trigger: ['blur', 'change']
- },
- },
- list: pickupRulesil(),
- goodsList: formRules(),
- userInfo: {},
- }
- },
- mounted() {
- var userInfo = this.$cache.getCache('userInfo')
- this.userInfo = userInfo
- },
- methods: {
- // 打印运单
- 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.userInfo.userType == 'sys') {
- this.$api.post('/api/waybill/applet', 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.post('/api/waybill/customer', params).then(res => {
- if (res.code == 200) {
- 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_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>
|