wk
2024-09-09 71ba67906896248aa2df5e70756b997fad9a9033
pages/driver-page/delivery-my/delivery-my/delivery-my.vue
@@ -35,14 +35,100 @@
               label="车牌号"
               labelWidth="20%"
               borderBottom
               required>
               >
               <u--input v-model="registerFormModel.carNo"
                  placeholder="请输入内容"
                  clearable></u--input>
            </u-form-item>
            <u-form-item prop="skin"
               label="皮重"
               labelWidth="20%"
               borderBottom
               required v-if="daydata.isWeighing==1">
               <u--input v-model="skin"
               border="surround"
                  placeholder="请输入皮重"
                  clearable></u--input>
            </u-form-item>
            <u-form-item prop="hair"
               label="毛重"
               labelWidth="20%"
               borderBottom
               required v-if="daydata.isWeighing==1">
               <u--input v-model="hair"
               border="surround"
                  placeholder="请输入毛重"
                  clearable></u--input>
            </u-form-item>
            <u-form-item prop="clean"
               label="净重"
               labelWidth="20%"
               borderBottom
               required v-if="daydata.isWeighing==1">
               <u--input v-model="clean"
               border="surround"
               disabled
                  placeholder="请输入净重"
                  clearable></u--input>
            </u-form-item>
            <uni-table
             border
            id="table-box"
            emptyText="暂无更多数据" v-if="daydata.isWeighing==0">
                  <uni-tr>
                     <uni-th align="center" >产品</uni-th>
                     <uni-th align="center">数量</uni-th>
                  </uni-tr>
                  <uni-tr v-for="(subItem, index) in tmTaskCoalList" :key="index">
                     <uni-td align="center">
                        <view class="name">{{ subItem.productName }}</view></uni-td>
                   <uni-td align="right">
                  <view>
                  <u--input
                  placeholder="请输入产品数量"
                  type='number'
                  v-model="subItem.productQuantity"
                  ></u--input>
                  </view></uni-td>
               </uni-tr>
               </uni-table>
               <u-form-item prop='contactPicture'>
                  <view class="label-text">
                     <text style="color: #f56c6c;">*</text>原发单据
                  </view>
                  <u-upload :fileList="fileList1"
                     @afterRead="afterRead"
                     @delete="deletePic"
                     name="1"
                     multiple
                     :maxCount="2"
                     width="250"
                     height="150"
                     :previewFullImage="true"
                     ></u-upload>
               </u-form-item>
            <!-- <u-form-item labelWidth="20%"
               label="空车出厂"
               borderBottom
               ref="roleRef"
               required>
               <u-radio-group v-model="registerFormModel.isEmptyCar"
                  placement="row"
                  size="30"
                  shape="circle"
                  iconSize="20">
                  <u-radio labelSize="14px"
                     size="20px"
                     v-for="(item, index) in radiolist1"
                     :key="index"
                     :label="item.name"
                     :name="item.value"
                     ></u-radio>
               </u-radio-group>
            </u-form-item> -->
         </u--form>
      </view>
      <view class="history-numbers">
      <!-- <view class="history-numbers">
         <scroll-view :scroll-top="scrollTop"
            scroll-y="true"
            class="scroll-Y"
@@ -73,7 +159,7 @@
               <view class="fourth">
                  <view class="fourth-icon">
                     <view
                        style="width: 24rpx;height: 24rpx;line-height: 24rpx;background: url('https://mx.jzeg.cn:9096/appimg/image/banner/clock.png') no-repeat;background-size: cover">
                        style="width: 24rpx;height: 24rpx;line-height: 24rpx;background: url('https://wrzs.czjlchem.com:9090/appimg/image/banner/clock.png') no-repeat;background-size: cover">
                     </view>
                  </view>
                  <view class="senddate">{{ daydata.sendDate }}</view>
@@ -81,14 +167,14 @@
               <view class="fourth">
                  <view class="fourth-icon">
                     <view
                        style="width: 26rpx;height: 26rpx;line-height: 26rpx;background: url('https://mx.jzeg.cn:9096/appimg/image/banner/carnNUm.png') no-repeat;background-size: cover;">
                        style="width: 26rpx;height: 26rpx;line-height: 26rpx;background: url('https://wrzs.czjlchem.com:9090/appimg/image/banner/carnNUm.png') no-repeat;background-size: cover;">
                     </view>
                  </view>
                  <view class="senddate">{{ daydata.orderCode }}</view>
               </view>
            </view>
               </scroll-view>
            </view>
         </scroll-view>
      </view> -->
      <combined-title
         :title="yuYueData.length != 0 ? yuYueData[0].filedName + '——' + yuYueData[0].sendDate : '暂无预约列表'"></combined-title>
      <view class="appointment-table">
@@ -119,6 +205,8 @@
<script>
   import { apiRegister } from '@/api/publicInterface.js';
   import { mapMutations } from 'vuex';
   import { BaseUrl } from '@/api/publicInterface.js';
   import BigNumber from "bignumber.js"
   export default {
      // 监听页面初次渲染完成。注意如果渲染速度快,会在页面进入动画完成前触发
      onReady() {
@@ -129,6 +217,7 @@
         if (params.id) {
           this.id = params.id
         }
         this.fileList1 = []
         this.GetMyDelivery()
         uni.getStorage({
             key: 'myDelivery',
@@ -143,16 +232,30 @@
            id:"",
            value: 0,
            daydata:{},
            tmTaskCoalList:[],
            range: [{"value": 0,"label": "否"   },{"value": 1,"label": "是"}],
            carNumShow: false,
            yuYueData: [],
            fileList1: [], //图片列表
            contactPicture:"",
            registerFormModel: {
               phone: '',
               driver: '',
               idNumber: '',
               carNo: '',
            },
            skin:"",
            hair:"",
            TableData:[],
            radiolist1: [{
                  name: '否',
                  value:"0"
               },
               {
                  name: '是',
                  value:"1"
               }
            ],
            rules: {
               driver: [{
                  type: 'string',
@@ -196,56 +299,222 @@
                     trigger: ['change', 'blur']
                  }
               ],
               carNo: [{
                     type: 'string',
                     required: true,
                     message: '请输入车牌号',
                     trigger: ['blur', 'change']
                  },
                  {
                     transform(value) {
                        return String(value);
                     },
                     validator: (rule, value, callback) => {
                        return uni.$u.test.carNo(value);
                     },
                     message: '请输入正确的车牌号',
                     trigger: ['change', 'blur']
                  }
               ],
               // carNo: [{
               //       type: 'string',
               //       required: true,
               //       message: '请输入车牌号',
               //       trigger: ['blur', 'change']
               //    },
               //    {
               //       transform(value) {
               //          return String(value);
               //       },
               //       validator: (rule, value, callback) => {
               //          return uni.$u.test.carNo(value);
               //       },
               //       message: '请输入正确的车牌号',
               //       trigger: ['change', 'blur']
               //    }
               // ],
            },
         };
      },
      computed:{
         clean() {
            if(this.daydata.isWeighing==1){
            let xx = BigNumber(this.hair ? this.hair : 0)
            let yy = BigNumber(this.skin ? this.skin : 0)
            return xx.minus(yy).toNumber() > 0 ? xx.minus(yy).toNumber().toFixed(2) : 0
            }else{
               //数量
               if(!this.tmTaskCoalList.length){
                  return false
               }else{
                  const reslut = this.tmTaskCoalList.find(item=>!item.productQuantity);
                  if(reslut){
                     return false
                  }else{
                     return true
                  }
               }
            }
         }
      },
      methods: {
         ...mapMutations(['changeisUploadimg']),
         // input聚焦
         inputFocus(v) {
            if (v == 1) {
               this.isfocus1 = true;
            } else {
               this.isfocus2 = true;
            }
         },
         // input失焦
         inputBlur() {
            this.isfocus1 = false;
            this.isfocus2 = false;
         },
         inputChange() {
            if (Number(this.originInfoForm.coalContactHair) > 0 && Number(this.originInfoForm.coalContactSkin >
                  0)) {
               this.isInputOrigin = true;
            }
         },
         deletePic(event) {
            this.changeisUploadimg(true);
            this[`fileList${event.name}`].splice(event.index, 1);
         },
         async afterRead(event) {
            // 当设置 mutiple 为 true 时, file 为数组格式,否则为对象格式
            let lists = [].concat(event.file);
            let fileListLen = this[`fileList${event.name}`].length;
            lists.map(item => {
               this[`fileList${event.name}`].push({
                  ...item,
                  status: 'uploading',
                  message: '上传中'
               });
            });
            for (let i = 0; i < lists.length; i++) {
               const result = await this.uploadFilePromise(lists[i].url, event.name);
               let item = this[`fileList${event.name}`][fileListLen];
               this[`fileList${event.name}`].splice(
                  fileListLen,
                  1,
                  Object.assign(item, {
                     status: 'success',
                     message: '上传成功',
                     url: result
                  })
               );
               fileListLen++;
            }
         },
         uploadFilePromise(url, num) {
            return new Promise((resolve, reject) => {
               let a = uni.uploadFile({
                  url: BaseUrl + '/admin/sys-file/uploadUnToken',
                  filePath: url,
                  name: 'file',
                  success: res => {
                     if (num == 1) {
                        this.contactPicture = JSON.parse(res.data)
                           .data.url;
                        resolve(`${BaseUrl}${JSON.parse(res.data).data.url}`);
                     }
                  }
               });
            });
         },
         yuYueBtnClick(item){
            this.$refs.regesterFormRef.validate().then(res => {
            this.$reqPost('saveMyDelivery',{
               productName:this.daydata.productName,
               customerId:this.daydata.customerId,
               deptId:this.daydata.deptId,
               filedId:this.daydata.filedId,
               orderPlanId:this.daydata.id,
               orderTye:this.daydata.orderType,
               sendDate:this.daydata.sendDate,
               carNumSurplus:this.daydata.carNumSurplus,
               yyId:item.id,
               ...this.registerFormModel
            }, 'json').then(res => {
               uni.setStorage({
                   key: 'myDelivery',
                   data: this.registerFormModel,
               });
               if (res.code === 0) {
                  uni.$u.toast('预约成功')
                  this.GetMyDelivery()
               } else {
                  uni.$u.toast(res.msg ? res.msg : '预约失败')
            if(this.daydata.orderType=='外购'){
               if(this.daydata.isWeighing==1){
                  this.$reqPost('saveMyDelivery',{
                     productName:this.daydata.productName,
                     customerId:this.daydata.customerId,
                     deptId:this.daydata.deptId,
                     filedId:this.daydata.filedId,
                     orderPlanId:this.daydata.id,
                     orderTye:this.daydata.orderType,
                     sendDate:this.daydata.sendDate,
                     carNumSurplus:this.daydata.carNumSurplus,
                     yyId:item.id,
                     ...this.registerFormModel,
                     tmTaskCoalContact:{
                        coalName:this.daydata.productName,
                        contactPicture:this.contactPicture,
                        skin:this.skin,
                        hair:this.hair,
                        clean:this.clean
                     }
                  }, 'json').then(res => {
                     uni.setStorage({
                         key: 'myDelivery',
                         data: this.registerFormModel,
                     });
                     if (res.code === 0) {
                        uni.$u.toast('预约成功')
                        this.GetMyDeliverys()
                     } else {
                        uni.$u.toast(res.msg ? res.msg : '预约失败')
                     }
                  })
               }else{
                  let numDtoList=this.tmTaskCoalList.map(item=>{
                     return {tmId:item.productId,num:item.productQuantity,coalName:item.coalName}
                  })
                  this.$reqPost('saveMyDelivery',{
                     productName:this.daydata.productName,
                     customerId:this.daydata.customerId,
                     deptId:this.daydata.deptId,
                     filedId:this.daydata.filedId,
                     orderPlanId:this.daydata.id,
                     orderTye:this.daydata.orderType,
                     sendDate:this.daydata.sendDate,
                     carNumSurplus:this.daydata.carNumSurplus,
                     yyId:item.id,
                     ...this.registerFormModel,
                     tmTaskCoalContact:{
                        contactPicture:this.contactPicture,
                        numDtoList:numDtoList
                     }
                  }, 'json').then(res => {
                     uni.setStorage({
                         key: 'myDelivery',
                         data: this.registerFormModel,
                     });
                     if (res.code === 0) {
                        uni.$u.toast('预约成功')
                        this.GetMyDeliverys()
                     } else {
                        uni.$u.toast(res.msg ? res.msg : '预约失败')
                     }
                  })
               }
            }else{
               this.$reqPost('saveMyDelivery',{
                  productName:this.daydata.productName,
                  customerId:this.daydata.customerId,
                  deptId:this.daydata.deptId,
                  filedId:this.daydata.filedId,
                  orderPlanId:this.daydata.id,
                  orderTye:this.daydata.orderType,
                  sendDate:this.daydata.sendDate,
                  carNumSurplus:this.daydata.carNumSurplus,
                  yyId:item.id,
                  ...this.registerFormModel
               }, 'json').then(res => {
                  uni.setStorage({
                      key: 'myDelivery',
                      data: this.registerFormModel,
                  });
                  if (res.code === 0) {
                     uni.$u.toast('预约成功')
                     this.GetMyDeliverys()
                  } else {
                     uni.$u.toast(res.msg ? res.msg : '预约失败')
                  }
               })
            }
            })
            })
         },
         GetMyDeliverys() {
            this.$reqGet('driverYuYueList', {orderPlanId:this.id}).then(res => {
               if (res.code == 0) {
                  this.yuYueData = res.data;
               } else {
                  this.$u.toast('加载失败');
               }
            });
            this.$reqGetId('myDelivery',this.id).then(res => {
               if (res.data) {
                  this.daydata=res.data
                  this.tmTaskCoalList=res.data.jhOrderPlanList
               }
            });
         },
         GetMyDelivery() {
            uni.showLoading({
@@ -262,6 +531,7 @@
            this.$reqGetId('myDelivery',this.id).then(res => {
               if (res.data) {
                  this.daydata=res.data
                  this.tmTaskCoalList=res.data.jhOrderPlanList
               }
            });
         }