付延余
2022-07-26 7c3218e12105b87cab21e9ced57c99c339ffac10
pages/new-application-form-data/new-application-form-data.vue
@@ -83,7 +83,7 @@
                                 width: 43px;
                                 font-size: 10px;
                                 padding: 0;"
                                 @click="selectCustomerOkClick(item.id)"
                                 @click="selectCustomerOkClick(item)"
                              >
                                 选择
                              </button>
@@ -91,7 +91,9 @@
                        </u-cell>
                     </u-cell-group>
                  </view>
                  <view class="loadmoreClass">
                     <u-loadmore loadmoreText="点击加载更多" nomoreText="无更多数据!!!" :status="status" @loadmore="loadingCustomer" fontSize="20" height="30px" />
                  </view>
                  <!-- 选择用户菜单项 -->
                  <view class="selectCustomerCompSheet">
                     <u-action-sheet
@@ -347,9 +349,11 @@
                        <u-form-item label="单价" labelWidth="20%" ref="item1">
                           <u--input v-model="addContractFormdata.price" disabled disabledColor="#ffffff" border="none"></u--input>
                        </u-form-item>
                        <u-form-item label="订单金额" labelWidth="20%" ref="item1"><u--input v-show="currentRowComputed" v-model="addContractFormdata.amount"></u--input></u-form-item>
                        <u-form-item label="订单金额" labelWidth="20%" ref="item1">
                           <u--input :disabled="addContractFormdata.trainType == 2" v-show="currentRowComputed" v-model="addContractFormdata.amount"></u--input>
                        </u-form-item>
                        <u-form-item label="订单数量" labelWidth="20%" ref="item1">
                           <u--input v-model="addContractFormdata.quant" disabled disabledColor="#ffffff" border="none"></u--input>
                           <u--input :disabled="addContractFormdata.trainType == 1" @input="jisuanAmount" v-model="addContractFormdata.quant"></u--input>
                        </u-form-item>
                     </view>
@@ -461,6 +465,9 @@
                                 </u-cell>
                              </u-cell-group>
                           </view>
                           <view class="loadmoreClass">
                              <u-loadmore loadmoreText="点击加载更多" nomoreText="无更多数据!!!" :status="status" @loadmore="loadingCustomer" fontSize="20" height="30px" />
                           </view>
                           <!-- 选择用户菜单项 -->
                           <view class="selectCustomerCompSheet">
                              <u-action-sheet
@@ -536,8 +543,9 @@
            <text style="color: #FFA500;;">客户账户现汇余额:{{ accountDetails.balanceTotal }},承兑余额:{{ accountDetails.balance2 == null ? 0 : customerChengdui }}</text>
         </view>
         <u-swipe-action>
            <u-swipe-action-item @click="deleteContractCardClick" :options="options1" v-for="(item, index) in this.newFormData.contractOrders" :key="index">
            <u-swipe-action-item @click="deleteContractCardClick" :options="options1" v-for="(item, index) in newFormData.contractOrders" :key="index">
               <view class="cardList">
                  <view class="" class="cardListIcon"><u-icon name="edit-pen" color="#2979ff" size="35"></u-icon></view>
                  <view class="cardList-container">
                     <view class="cardList_item">
                        收货人:
@@ -678,7 +686,7 @@
         // 时间
         timeShow: false,
         mode: 'range',
         maxDate: `${year}-${month}-${date + 80}`,
         maxDate: `${year}-${month}-${date + 70}`,
         // 选择客户
         selectCustomerData: {
            compIds: '',
@@ -687,6 +695,8 @@
            current: 1,
            size: 10
         },
         status: 'loadmore',
         customerDataAllNum: 0, //客户列表总条数
         account: null, //客户账户信息
         // 搜索字段
         selectCompsData: [],
@@ -715,6 +725,7 @@
            customerName: ''
         },
         contractData: [],
         contractNumList: [],
         // 类型
         selectContractTypeShow: false,
         selectContractTypeData: [[]],
@@ -884,36 +895,34 @@
         return true;
      },
      async currentRowComputed() {
         console.log('currentRowComputed');
         //变价格用的
         this.changePriceMode(this.addContractFormdata.priceMode);
         //变订单量
         if (this.addContractFormdata.amount > 0 && this.addContractFormdata.price > 0) {
         if (this.addContractFormdata.price > 0 && (this.addContractFormdata.amount > 0 || this.addContractFormdata.quant > 0)) {
            let price = this.addContractFormdata.price;
            if (this.addContractFormdata.trainType == 2) {
            if (this.addContractFormdata.trainType == 1) {
               let q = this.addContractFormdata.amount / price;
               this.addContractFormdata.quant = q.toFixed(2);
               this.addContractFormdata.cost1 = null; //运费
               this.addContractFormdata.cost2 = null; //抑尘费
            } else if (this.addContractFormdata.trainType == 2) {
               //如果路运价格增加抑尘费和运费
               let cost1Price = await this.getFreight(this.addContractFormdata.fromStation, this.addContractFormdata.toStation, this.addContractFormdata.customerAddressId); //路运运费
               price += cost1Price;
               price += this.dust;
            }
            let q = this.addContractFormdata.amount / price;
            this.addContractFormdata.quant = q.toFixed(2);
            if (this.addContractFormdata.trainType == 2) {
               let cost1Price = await this.getFreight(this.addContractFormdata.fromStation, this.addContractFormdata.toStation, this.addContractFormdata.customerAddressId); //路运运费
               this.addContractFormdata.cost1 = (this.addContractFormdata.quant * cost1Price).toFixed(2); //运费
               this.addContractFormdata.cost2 = (this.addContractFormdata.quant * this.dust).toFixed(2); //抑尘费
               console.log('运费,抑尘费:', this.addContractFormdata.cost1, this.addContractFormdata.cost2);
            } else {
               this.addContractFormdata.cost1 = null; //运费
               this.addContractFormdata.cost2 = null; //抑尘费
               let amount = Number(price * this.addContractFormdata.quant) + Number(this.addContractFormdata.cost1) + Number(this.addContractFormdata.cost2);
               console.log(amount);
               this.addContractFormdata.amount = amount.toFixed(2);
               // console.log('运费,抑尘费:', this.addContractFormdata.cost1, this.addContractFormdata.cost2);
            }
         } else {
            this.addContractFormdata.quant = null;
         }
         // if (this.currentRow.quant > 0 && this.currentRow.price > 0) {
         //   this.currentRow.amount = this.currentRow.quant * this.currentRow.price;
         //   return true;
         // }
         return true;
      }
      // accountMsg() {
@@ -962,6 +971,20 @@
      combinationTitle
   },
   methods: {
      async jisuanAmount() {
         if (this.addContractFormdata.trainType == 2) {
            let price = this.addContractFormdata.price;
            //如果路运价格增加抑尘费和运费
            let cost1Price = await this.getFreight(this.addContractFormdata.fromStation, this.addContractFormdata.toStation, this.addContractFormdata.customerAddressId); //路运运费
            price += cost1Price;
            price += this.dust;
            this.addContractFormdata.cost1 = (this.addContractFormdata.quant * cost1Price).toFixed(2); //运费
            this.addContractFormdata.cost2 = (this.addContractFormdata.quant * this.dust).toFixed(2); //抑尘费
            let amount = Number(price * this.addContractFormdata.quant) + Number(this.addContractFormdata.cost1) + Number(this.addContractFormdata.cost2);
          console.log(amount);
            this.addContractFormdata.amount = amount.toFixed(2);
         }
      },
      init() {
         this.jcfavouredpolicyitem();
         this.coalfiled();
@@ -980,10 +1003,13 @@
            title: '加载中...'
         });
         this.selectCustomerShow = true;
         this.selectCustomerData.current = 1;
         this.$reqGet('customer', this.selectCustomerData).then(res => {
            console.log('客户呵呵哈哈哈或', res);
            uni.hideLoading();
            if (res.code == 0) {
               this.customerData = res.data.records;
               this.customerDataAllNum = res.data.total;
            }
         });
      },
@@ -1042,15 +1068,47 @@
         this.selectCustomer();
      },
      selectCustomerOkClick(v) {
         console.log('id', v);
         this.$reqGet('getAccount', { customerId: v }).then(res => {
         console.log('外层客户选择', v);
         this.newFormData.customerName = v.customerName;
         this.newFormData.customerId = v.id;
         this.$reqGet('getAccount', { customerId: v.id }).then(res => {
            console.log('客户选择账户', res);
            this.accountDetails = res.data;
            this.newFormData.customerName = res.data.customerName;
            this.newFormData.customerId = res.data.id;
            this.searchContractForm.customerName = res.data.customerName;
            this.reqContract();
            this.$nextTick(() => {
               this.contractData.forEach(item => {
                  this.contractNumList.push(item.num);
               });
               console.log('合同号码列表', this.contractNumList);
               // 检查换客户后对应的合同
               if (this.contractNumList.indexOf(this.newFormData.contractNum) > -1) {
                  this.newFormData.contractNum = '';
                  this.newFormData.contractName = '';
               }
            });
         });
         this.$nextTick(() => {
            this.selectCustomerShow = false;
         });
      },
      loadingCustomer() {
         console.log('加载更多事件');
         if (this.selectCustomerData.current >= this.customerDataAllNum / 10) return;
         this.status = 'loading';
         this.selectCustomerData.current = ++this.selectCustomerData.current;
         this.$reqGet('customer', this.selectCustomerData).then(res => {
            if (this.selectCustomerData.current >= this.customerDataAllNum / 10) {
               this.status = 'nomore';
               this.$u.toast('没有更多数据了!');
            }
            uni.hideLoading();
            if (res.code == 0) {
               this.customerDataAllNum = res.data.total;
               this.customerData = this.customerData.concat(res.data.records);
               this.status = 'loadmore';
               console.log(this.selectCustomerData);
            }
         });
      },
      // 时间
@@ -1107,6 +1165,10 @@
         this.$reqGet('contract_status').then(res => {
            console.log('状态', res);
         });
         this.reqContract();
      },
      // 合同请求
      reqContract() {
         this.$reqGet('contract', this.searchContractForm).then(res => {
            uni.hideLoading();
            if (res.code == 0) {
@@ -1275,15 +1337,16 @@
         this.addContractConsigneeShow = true;
      },
      addContractConsigneeConfirm(v) {
         console.log('收货人', v);
         this.addContractFormdata.toStation = v.toStation;
         this.addContractFormdata.customerName = v.customerName;
         this.addContractFormdata.customerId = v.id;
         this.$reqGet('getAccount', { customerId: v.id }).then(res => {
            console.log('获取收货人账号', res);
            // this.accountDetails = res.data;
            // this.newFormData.customerName = res.data.customerName;
            // this.newFormData.customerId = res.data.id;
            // this.searchContractForm.customerName = res.data.customerName;
            this.addContractFormdata.customerId = res.data.id;
         });
         this.$nextTick(() => {
            this.addContractConsigneeShow = false;
@@ -1415,6 +1478,7 @@
      addContractSanConfirm() {
         if (this.addContractFormdata.compId && this.addContractFormdata.customerId && this.addContractFormdata.filedId) {
            this.newFormData.contractOrders.push(this.addContractFormdata);
            console.log('添加子订单',this.addContractFormdata);
            this.$nextTick(() => {
               this.addContractShow = false;
            });
@@ -1469,6 +1533,7 @@
      // 获取所有的优惠政策
      getFavouredPolicyItem() {
         this.$reqGet('getFavouredPolicyItem', { current: 1, size: 1000, status: 0 }).then(res => {
            console.log('所有优惠政策', res.data.records);
            this.favouredpolicyListAll = res.data.records;
         });
      },
@@ -1502,7 +1567,10 @@
                  amount += Number(e.amount);
               });
               if (this.newFormData.payType == '0') {
                  if (this.accountDetails.balance < amount) {
                  if (this.newFormData.contractOrders.length <= 0) {
                     this.$u.toast('请添加订单子项!');
                     return false;
                  } else if (this.accountDetails.balance < amount) {
                     let msg = this.accountDetails.balance == null ? 0 : this.accountDetails.balance;
                     uni.showToast({
                        title: '客户账户现汇余额不足,现汇余额:' + msg,
@@ -1510,10 +1578,14 @@
                        duration: 2000
                     });
                  } else {
                     console.log('提交整体',this.newFormData);
                     this.xswaybill();
                  }
               } else {
                  if (this.accountDetails.balance2 < amount) {
                  if (this.newFormData.contractOrders.length <= 0) {
                     this.$u.toast('请添加订单子项!');
                     return false;
                  } else if (this.accountDetails.balance2 < amount) {
                     let msg = this.accountDetails.balance2 == null ? 0 : this.accountDetails.balance2;
                     uni.showToast({
                        title: '客户账户承兑余额不足,承兑余额:' + msg,
@@ -1521,6 +1593,7 @@
                        duration: 2000
                     });
                  } else {
                     console.log('提交整体',this.newFormData);
                     this.xswaybill();
                  }
               }
@@ -1535,7 +1608,7 @@
         this.newFormData.contractOrders.splice(e, 1);
      },
      xswaybill() {
         console.log('新建发运申请');
         console.log('新建发运申请', this.newFormData);
         uni.showLoading({
            title: '加载中...'
         });
@@ -1611,6 +1684,14 @@
               }
               .selectCustomerContainer {
                  padding: 0 4%;
                  // .loadmoreClass{
                  //    .u-loadmore{
                  //       .u-loadmore__content{
                  //          .u-loadmore__content__text{
                  //          }
                  //       }
                  //    }
                  // }
                  .searchContainer {
                  }
                  .searchCustomerBtn {
@@ -1904,6 +1985,12 @@
         height: vww(130);
         border-radius: vww(4);
         padding: vww(10);
         position: relative;
         .cardListIcon {
            position: absolute;
            right: vww(20);
            top: vww(20);
         }
         .cardList-container {
            .cardList_item {
               margin-top: vww(12);