yangan
2024-11-04 1db172e1eb09be68008659c9f05bf18144df553a
pages/driver-page/delivery-my/delivery-my/delivery-my.vue
@@ -36,15 +36,14 @@
               labelWidth="20%"
               borderBottom
               >
               <u--input v-model="registerFormModel.carNo"
                  placeholder="请输入内容"
                  clearable></u--input>
               <xm-cell special label="车牌号" :value="registerFormModel.carNo" @show="showKeyboard('xmKeyboard')"></xm-cell>
               <xm-keyboard-v2 ref="xmKeyboard" @confirm="(v) => registerFormModel.carNo = v"></xm-keyboard-v2>
            </u-form-item>
            <u-form-item prop="skin"
               label="皮重"
               labelWidth="20%"
               borderBottom
               required v-if="daydata.isWeighing==1">
               required v-if="(daydata.isWeighing==1&&daydata.productId=='1818237609508347905')||(daydata.isWeighing==1&&daydata.productId=='1818237832536268801')||(daydata.isWeighing==1&&daydata.productId=='1818211942485995521')">
               <u--input v-model="skin"
               border="surround"
                  placeholder="请输入皮重"
@@ -54,7 +53,7 @@
               label="毛重"
               labelWidth="20%"
               borderBottom
               required v-if="daydata.isWeighing==1">
               required v-if="(daydata.isWeighing==1&&daydata.productId=='1818237609508347905')||(daydata.isWeighing==1&&daydata.productId=='1818237832536268801')||(daydata.isWeighing==1&&daydata.productId=='1818211942485995521')">
               <u--input v-model="hair"
               border="surround"
                  placeholder="请输入毛重"
@@ -64,7 +63,7 @@
               label="净重"
               labelWidth="20%"
               borderBottom
               required v-if="daydata.isWeighing==1">
               required v-if="(daydata.isWeighing==1&&daydata.productId=='1818237609508347905')||(daydata.isWeighing==1&&daydata.productId=='1818237832536268801')||(daydata.isWeighing==1&&daydata.productId=='1818211942485995521')">
               <u--input v-model="clean"
               border="surround"
               disabled
@@ -92,7 +91,7 @@
                  </view></uni-td>
               </uni-tr>
               </uni-table>
               <u-form-item prop='contactPicture'>
               <!-- <u-form-item prop='contactPicture'>
                  <view class="label-text">
                     原发单据
                  </view>
@@ -106,7 +105,7 @@
                     height="150"
                     :previewFullImage="true"
                     ></u-upload>
               </u-form-item>
               </u-form-item> -->
            <!-- <u-form-item labelWidth="20%"
               label="空车出厂"
               borderBottom
@@ -225,7 +224,7 @@
         if (params.id) {
           this.id = params.id
         }
         this.fileList1 = []
         // this.fileList1 = []
         this.GetMyDelivery()
         uni.getStorage({
             key: 'myDelivery',
@@ -256,7 +255,7 @@
            range: [{"value": 0,"label": "否"   },{"value": 1,"label": "是"}],
            carNumShow: false,
            yuYueData: [],
            fileList1: [], //图片列表
            // fileList1: [], //图片列表
            contactPicture:"",
            registerFormModel: {
               phone: '',
@@ -369,6 +368,9 @@
      },
      methods: {
         ...mapMutations(['changeisUploadimg']),
         showKeyboard(ref){
            this.$refs[ref].toShow(this.registerFormModel.carNo)
         },
         // input聚焦
         inputFocus(v) {
            if (v == 1) {
@@ -388,96 +390,132 @@
               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}`);
                     }
                  }
               });
            });
         },
         logoutConfirm() {
         // 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}`);
         //             }
         //          }
         //       });
         //    });
         // },
         lohOutLogin(){
            this.$refs.regesterFormRef.validate().then(res => {
            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:this.ids.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,
                     });
                     uni.setStorage({
                         key: 'isshow',
                         data: false,
                     });
                     this.logoutShow=false
                     this.isshow=false
                     if (res.code === 0) {
                        uni.$u.toast('预约成功')
                        this.GetMyDeliverys()
                     } 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:this.ids.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,
                        });
                        uni.setStorage({
                            key: 'isshow',
                            data: false,
                        });
                        this.logoutShow=false
                        this.isshow=false
                        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:this.ids.id,
                        ...this.registerFormModel,
                        tmTaskCoalContact:{
                           // contactPicture:this.contactPicture,
                           numDtoList:numDtoList
                        }
                     }, 'json').then(res => {
                        uni.setStorage({
                            key: 'myDelivery',
                            data: this.registerFormModel,
                        });
                        uni.setStorage({
                            key: 'isshow',
                            data: false,
                        });
                        this.logoutShow=false
                        this.isshow=false
                        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,
@@ -488,11 +526,7 @@
                     sendDate:this.daydata.sendDate,
                     carNumSurplus:this.daydata.carNumSurplus,
                     yyId:this.ids.id,
                     ...this.registerFormModel,
                     tmTaskCoalContact:{
                        contactPicture:this.contactPicture,
                        numDtoList:numDtoList
                     }
                     ...this.registerFormModel
                  }, 'json').then(res => {
                     uni.setStorage({
                         key: 'myDelivery',
@@ -512,39 +546,32 @@
                     }
                  })
               }
            }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:this.ids.id,
                  ...this.registerFormModel
               }, 'json').then(res => {
                  uni.setStorage({
                      key: 'myDelivery',
                      data: this.registerFormModel,
                  });
                  uni.setStorage({
                      key: 'isshow',
                      data: false,
                  });
                  this.logoutShow=false
                  this.isshow=false
                  if (res.code === 0) {
                     uni.$u.toast('预约成功')
                     this.GetMyDeliverys()
                  } else {
                     uni.$u.toast(res.msg ? res.msg : '预约失败')
                  }
               })
            }
            })
         },
         logoutConfirm() {
               if(this.registerFormModel.carNo==""){
                  this.lohOutLogin()
               }else{
                  if(this.registerFormModel.carNo){
                     var xreg=/^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[A-Z]{1}(([0-9]{5}[DF]$)|([DF][A-HJ-NP-Z0-9][0-9]{4}$))/;
                     var creg=/^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[A-Z]{1}[A-HJ-NP-Z0-9]{4}[A-HJ-NP-Z0-9挂学警港澳]{1}$/;
                     if(this.registerFormModel.carNo.length == 7){
                        if(!creg.test(this.registerFormModel.carNo)) {
                           uni.$u.toast('请输入正确的车牌号')
                        }else {
                          this.lohOutLogin()
                        }
                     } else if(this.registerFormModel.carNo.length == 8){
                         if(!xreg.test(this.registerFormModel.carNo)) {
                           uni.$u.toast('请输入正确的车牌号')
                         }else {
                           this.lohOutLogin()
                         }
                     }else {
                         uni.$u.toast('请输入正确的车牌号')
                     }
                  }
               }
         },
         logoutCancel() {
            this.logoutShow = false;
@@ -555,96 +582,8 @@
                  this.logoutShow = true;
                  this.ids=item
               }else{
                  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 : '预约失败')
                        }
                     })
                  }
                  this.ids=item
                  this.logoutConfirm();
               }
            })
         },