zhangxiaoxu123
2022-07-29 55dc1d1d1561075a0ccff79d8d6ac1b901e55527
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>
@@ -359,7 +363,7 @@
                     <u-form-item label="抑尘费" labelWidth="18%" borderBottom ref="item1"><u--input v-model="addContractFormdata.cost2" border="none"></u--input></u-form-item> -->
                  </u--form>
                  <view class="addContractConfirm"><u-button text="添加" type="primary" @click="addContractSanConfirm"></u-button></view>
                  <view class="addContractConfirm"><u-button :text="editApplicationIndex != null ? '添加修改':'添加'" type="primary" @click="addContractSanConfirm"></u-button></view>
               </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
@@ -533,11 +540,12 @@
         <view class="balanceNo" v-if="accountDetails.balanceTotal < 0"><text style="color:red;">客户账户当前处于欠款状态</text></view>
         <view class="messageCustomerBalance" v-if="accountDetails.balanceTotal >= 0">
            <text style="color: #FFA500;;">客户账户现汇余额:{{ accountDetails.balanceTotal }},承兑余额:{{ accountDetails.balance2 == null ? 0 : customerChengdui }}</text>
            <text style="color: #FFA500;;">客户账户现汇余额:{{ accountDetails.balanceTotal == null ? 0 :accountDetails.balanceTotal.toFixed(2) }},承兑余额:{{ 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="cardListIcon" @click="editApplicationClick(index)"><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: [[]],
@@ -774,25 +785,25 @@
         loading: false,
         // 价格请求参数
         getNewPriceData: {
            compId: 133,
            compName: '邢台矿',
            customerAddressName: '邢台国泰发电有限责任公司',
            customerAddressId: 236,
            coalId: 45,
            coalName: '',
            trainType: 1,
            fromStation: '小康庄',
            toStation: '小康庄',
            quant: '',
            price: '',
            amount: '',
            priceMode: null,
            filedName: '邢台矿主煤场',
            filedId: 4,
            type: '',
            cost1: '',
            cost2: '',
            edit: true
            // compId: 133,
            // compName: '邢台矿',
            // customerAddressName: '邢台国泰发电有限责任公司',
            // customerAddressId: 236,
            // coalId: 45,
            // coalName: '',
            // trainType: 1,
            // fromStation: '小康庄',
            // toStation: '小康庄',
            // quant: '',
            // price: '',
            // amount: '',
            // priceMode: null,
            // filedName: '邢台矿主煤场',
            // filedId: 4,
            // type: '',
            // cost1: '',
            // cost2: '',
            // edit: true
         },
         dust: null, // 抑尘费
         trainfreight: {}, //路运运费
@@ -814,7 +825,8 @@
            {
               text: '删除'
            }
         ]
         ],
      editApplicationIndex:null
      };
   },
   onShow() {
@@ -884,36 +896,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 +972,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 +1004,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 +1069,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 +1166,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) {
@@ -1242,6 +1305,8 @@
      // 添加合同弹出框
      addContractClose() {
         this.addContractShow = false;
         this.addContractFormdata = {};
         this.editApplicationIndex = null;
      },
      addContractOpen() {
         console.log('添加订单打开');
@@ -1255,6 +1320,7 @@
      },
      // 选择的煤厂
      coalFiledSelectClick(e) {
        console.log('选择的煤厂',e);
         this.addContractFormdata.compName = e.compName;
         this.addContractFormdata.filedName = e.name;
         this.addContractFormdata.compId = e.compId;
@@ -1263,7 +1329,14 @@
         this.selectCoalFiledData = e;
         this.coalFiledSelectShow = false;
         // 获取价格参数
      this.getNewPriceData.compId = e.compId;
      this.getNewPriceData.compName = e.compName;
      this.getNewPriceData.filedId = e.id;
      this.getNewPriceData.filedName = e.name;
      this.coalFiledSelectShow = false;
      },
      // 收货人
      addContractConsigneeClose() {
@@ -1275,15 +1348,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;
@@ -1296,13 +1370,13 @@
         this.addContractFormdata.toStation = v.toStation;
         this.addContractFormdata.customerAddressId = v.id;
         // 添加煤种选项
         this.contractDetails.forEach(item => {
            let a = [{ label: '', id: '' }];
            a[0].label = item.coalName;
            a[0].id = item.coalId;
            if(this.addContractCoalData[0]){
            if (this.addContractCoalData[0]) {
               this.addContractCoalData = [];
            }
            this.addContractCoalData.push(a);
@@ -1342,7 +1416,7 @@
                  //    this.currentCoal.type = 1;
                  // }
                  this.addContractFormdata.modifyId = data.modifyId;
                  this.addContractFormdata.id = data.id;
                  // this.addContractFormdata.id = data.id;
               } else {
                  uni.$u.toast('煤种价格未设置');
               }
@@ -1414,10 +1488,14 @@
      },
      addContractSanConfirm() {
         if (this.addContractFormdata.compId && this.addContractFormdata.customerId && this.addContractFormdata.filedId) {
            this.newFormData.contractOrders.push(this.addContractFormdata);
            this.$nextTick(() => {
               this.addContractShow = false;
            });
           if(this.editApplicationIndex != null){
          this.newFormData.contractOrders[this.editApplicationIndex] = this.addContractFormdata;
        } else {
          this.newFormData.contractOrders.push(this.addContractFormdata);
          console.log('添加子订单',this.addContractFormdata);
        }
        this.addContractShow = false;// 关闭弹出框
        console.log('this.newFormData.contractOrders当前关闭后',this.newFormData.contractOrders)
         } else {
            uni.$u.toast('请规范输入所有信息');
         }
@@ -1469,6 +1547,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 +1581,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 +1592,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 +1607,7 @@
                        duration: 2000
                     });
                  } else {
                     console.log('提交整体',this.newFormData);
                     this.xswaybill();
                  }
               }
@@ -1534,8 +1621,13 @@
         console.log('删除订单卡片', e);
         this.newFormData.contractOrders.splice(e, 1);
      },
    editApplicationClick(index){
        this.editApplicationIndex = index;
      this.addContractFormdata = this.newFormData.contractOrders[index];
      this.addContractShow = true;
    },
      xswaybill() {
         console.log('新建发运申请');
         console.log('新建发运申请', this.newFormData);
         uni.showLoading({
            title: '加载中...'
         });
@@ -1543,17 +1635,19 @@
            uni.hideLoading();
            console.log('新建发运申请', res);
            if (res.code == 0) {
               uni.showToast({
                  title: '添加成功!',
                  icon: 'success',
                  duration: 2000
               });
               this.$nextTick(() => {
                  uni.navigateBack({
                     // url: '/pages/my-application/my-application'
                     delta: 2
                  });
               });
               // uni.showToast({
               //    title: '添加成功!',
               //    icon: 'success',
               //    duration: 1000
               // });
          this.$u.toast('添加成功,即将返回申请页!!!')
               setTimeout(() => {
            uni.navigateBack({
              // url: '/pages/my-application/my-application'
              delta: 2
            });
          },2000)
            }
         });
      },
@@ -1611,6 +1705,14 @@
               }
               .selectCustomerContainer {
                  padding: 0 4%;
                  // .loadmoreClass{
                  //    .u-loadmore{
                  //       .u-loadmore__content{
                  //          .u-loadmore__content__text{
                  //          }
                  //       }
                  //    }
                  // }
                  .searchContainer {
                  }
                  .searchCustomerBtn {
@@ -1904,6 +2006,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);