-
zhangwei
2025-03-14 6e961fafc0f921d575772a3c89f2c5cad28c270d
src/pages/delivergoods/clockInRecord.vue
@@ -9,24 +9,40 @@
   </up-sticky>
   <view class="c-p-b-100">
      <view class="c-p-l-20 c-p-r-20" v-if="orderList&&orderList.length>0">
         <view class="listrecord c-p-t-20" v-for="(item,index) in orderList" :key="item.keyid">
         <view class="listrecord c-p-t-20" v-for="(item,index) in orderList" :key="item.keyid" @click='goDetail(item)'>
            <view class="coreshop-ff chuany-bradius20">
               <view class="chuany-font26">
                  <view class="chuany-flex chuany-justify-between">
                     <text class="chuany-width5">{{index+1}}</text>
                     <view class="chuany-width15">
                        {{$util.formatDate(item.deliverTime,'riqi')}}
                     <view class="chuany-width13">
                        {{$util.formatDate(item.creatTime,'riqi')}}
                     </view>
                     <view class="chuany-width67" @click='goDetail(item)'>
                        <u-text size='14' :text="item.remark||item.companyName" lines="1">
                        </u-text>
                     <view class="chuany-width13">
                        {{item.creater}}
                     </view>
                     <view class="chuany-width11 chuany-flex chuany-justify-between">
                     <view class="chuany-width52">
                        {{item.car.carNumber}}
                     </view>
                     <!-- <view class="chuany-width52" @click='goDetail(item)'>
                     </view> -->
                     <!-- <view class="chuany-width11 chuany-flex chuany-justify-between">
                        <up-icon v-if="item.deliveredstatus=='Undeliver'" name="play-right" size='18'
                           @tap.stop='startOrder(item)'></up-icon>
                        <up-icon v-else-if="item.deliveredstatus=='Deliver'" name="checkbox-mark" size='18'
                           @tap.stop="editOrder(item)"></up-icon>
                     </view> -->
                     <view class="chuany-width17 chuany-flex chuany-justify-between">
                        <u-text size='14' :text="item.clockType=='ClockIn'?'出车打卡':'下班打卡'" lines="1">
                        </u-text>
                     </view>
                  </view>
                  <view class="c-p-t-8 chuany-flex">
                     <text class="chuany-width5" style="color: white;">{{index+1}}</text>
                     <u-text size='14' :text="item.carCondition" lines="1">
                     </u-text>
                  </view>
               </view>
            </view>
@@ -56,8 +72,9 @@
            </up-form-item>
         </up-form>
      </up-modal>
      <up-modal title="出车打卡" :show="showClockIn" showCancelButton @confirm="confirmClockSave" @cancel='cancelModal'
         :asyncClose="true" ref='clockInModal'>
      <up-modal :title="clockInfo.clockType=='ClockIn'?'出车打卡':'下班打卡'" :show="showClockIn" showCancelButton
         :closeOnClickOverlay="true" @close="closeModal" @confirm="confirmClockSave" @cancel='cancelModal'
         :asyncClose="true" ref='clockInModal' cancel-text="存为草稿" confirm-text="打卡">
         <up-form labelPosition="left" :model="clockInfo" ref="formClockInRef" labelWidth='140rpx'>
            <up-form-item label="车辆检查" prop="carConditionAttachments" v-if="clockInfo.clockType=='ClockIn'"
               required>
@@ -68,14 +85,14 @@
               </tem-upload-file>
            </up-form-item>
            <template v-else>
               <up-form-item label="装货照片" prop="attachments" required>
               <up-form-item label="装货照片" prop="attachments" required v-if='!clockInfo.emptyCause'>
                  <tem-upload-file immediate btnText="上传照片" :url="`https://appimchat.oss-cn-chengdu.aliyuncs.com`"
                     ref="zhuanghuo" :isSource='true' fileType="all" @success="successClock('zhuanghuo',$event)"
                     @error="errorInvoice" @complete="completeInvoice('zhuanghuo',$event)">
                  </tem-upload-file>
               </up-form-item>
               <up-form-item label="未装货原因" prop="emptyCause" :borderBottom='false' @click="clickAction"
                  labelWidth='160rpx' ref="item1">
               <up-form-item label="未装货原因" required prop="emptyCause" :borderBottom='false' @click="clickAction"
                  v-if="clockInfo.attachments&&clockInfo.attachments.length==0" labelWidth='160rpx' ref="item1">
                  <up-input v-model="clockInfo.emptyCause" disabled border="none" disabledColor="#ffffff"
                     placeholder="请选择未装货原因"></up-input>
               </up-form-item>
@@ -104,14 +121,6 @@
      <up-action-sheet :show="showActions" :actions="actions" title="请选择" @close="showActions = false"
         @select="selectItem">
      </up-action-sheet>
      <view class="tabbtns chuany-flex chuany-justify-between">
         <view class="chuany-width45">
            <up-button type="primary" text="出车打卡" @click="clockIn('ClockIn')"></up-button>
         </view>
         <view class="chuany-width45">
            <up-button type="success" text="下班打卡" @click="clockIn('Clockout')"></up-button>
         </view>
      </view>
   </view>
</template>
@@ -156,7 +165,7 @@
            }],
            // selectAc: '已完成',
            minDate: this.$util.formatDate(new Date(), null, -7),
            maxDate: this.$util.formatDate(new Date(), null, 7),
            maxDate: this.$util.formatDate(new Date(), null),
            deliverTime: Number(new Date(this.$util.formatDate(new Date(), null, 1))),
            arrangeInfo: {
               keyid: '',
@@ -167,7 +176,7 @@
            },
            rules: {
               'mileage': {
                  type: 'string',
                  type: 'number',
                  required: true,
                  message: '请输入里程',
                  trigger: ['blur', 'change']
@@ -198,6 +207,12 @@
                  message: '请上传送货单照片',
                  trigger: ['blur', 'change']
               },
               'emptyCause': {
                  type: 'string',
                  required: true,
                  message: '请选择未装货原因',
                  trigger: ['blur', 'change']
               },
            },
            radio: '',
            switchVal: false,
@@ -214,9 +229,11 @@
               carConditionAttachments: [],
               attachments: [],
               mileageImg: '',
               mileage: '',
               clockType: '', //ClockIn ,Clockout
               carCondition: ''
            },
            nextClockType: ''
         }
      },
      onShow() {
@@ -227,9 +244,9 @@
         this.$refs.formFinishRef.setRules(this.rules1);
      },
      onLoad() {
         this.Getdrivers()
         this.getCustomer()
         this.GetDriversOfWithin7days()
         // this.Getdrivers()
         // this.getCustomer()
         // this.GetDriversOfWithin7days()
      },
      onReachBottom() {
         if (this.loadStatus != 'nomore') {
@@ -246,8 +263,48 @@
      },
      methods: {
         clockIn(text) {
            this.clockInfo.clockType = text
            this.showClockIn = true
            this.$api.GetClockRoughDraft().then(res => {
               if (res.code == 1 && res.data) {
                  this.clockInfo.emptyCause = res.data.emptyCause || ''
                  this.clockInfo.carConditionAttachments = res.data.carConditionAttachments || []
                  this.clockInfo.attachments = res.data.attachments || []
                  this.clockInfo.mileageImg = res.data.mileageImg || ''
                  this.clockInfo.mileage = res.data.mileage || ''
                  this.clockInfo.carCondition = res.data.carCondition || ''
                  this.clockInfo.id = res.data.id
               }
               this.clockInfo.clockType = text
               this.showClockIn = true
               this.$refs.licheng.urls = this.clockInfo.mileageImg ? [this.clockInfo.mileageImg] : []
               this.$refs.licheng.status = this.clockInfo.mileageImg ? ['success'] : []
               this.$nextTick(() => {
                  if (text == 'ClockIn') {
                     this.$refs.carCondition.urls = []
                     this.clockInfo.carConditionAttachments.forEach(item => {
                        this.$refs.carCondition.urls.push(item.planAttachment)
                     })
                     let length = this.$refs.carCondition.urls.length
                     this.$refs.carCondition.status = Array.from({
                        length
                     }, () => 'success')
                     console.log(this.$refs.carCondition.urls, this.$refs.carCondition.status);
                  } else {
                     this.$refs.zhuanghuo.urls = []
                     this.clockInfo.attachments.forEach(item => {
                        console.log(item, '9jh');
                        this.$refs.zhuanghuo.urls.push(item.planAttachment)
                     })
                     console.log(res.data, this.clockInfo.attachments, res.data.attachments);
                     let length = this.$refs.zhuanghuo.urls.length
                     this.$refs.zhuanghuo.status = Array.from({
                        length
                     }, () => 'success')
                  }
               })
            })
         },
         success(text, e) {
            //e.res 为服务器返回数据
@@ -303,6 +360,7 @@
                  this.$refs.zhuanghuo.status.push('success')
                  this.$refs.zhuanghuo.status.length = this.$refs.zhuanghuo.urls.length
                  this.clockInfo.attachments.push(obj)
                  console.log(this.clockInfo.attachments, '------------------------------');
               }
            } else {
               uni.$u.toast(res.error)
@@ -324,7 +382,7 @@
         },
         changePicker(val) {
            console.log(val);
            this.workTime = val.result
            this.workTime = val.result
            this.timeStart = new Date(val.result) //工作开始时间
            this.timeEnd = new Date(val.result)
            this.datePickerShow = !this.datePickerShow
@@ -491,6 +549,9 @@
            //       title: '请上传里程照片!'
            //    })
            // }
            // if(this.clockInfo.emptyCause){
            //    this.clockInfo.attachments = []
            // }
            this.clockInfo = this.$util.removeEmptyValuesRecursive(this.clockInfo)
            this.$refs.formClockInRef.validate().then(res => {
               this.$api.Clock(this.clockInfo).then(res => {
@@ -504,7 +565,7 @@
                        carCondition: ''
                     }
                     this.showClockIn = false
                     // this.init()
                     this.init()
                  } else {
                     this.$util.showToast({
                        title: res.error
@@ -519,27 +580,50 @@
         },
         cancelModal() {
            console.log(this.clockInfo);
            // if (!this.clockInfo.mileageImg) {
            //    this.$refs.clockInModal.loading = false
            //    return this.$util.showToast({
            //       title: '请上传里程照片!'
            //    })
            // }
            // if(this.clockInfo.emptyCause){
            //    this.clockInfo.attachments = []
            // }
            this.clockInfo = this.$util.removeEmptyValuesRecursive(this.clockInfo)
            this.clockInfo.clockType = 'RoughDraft '
            this.$api.Clock(this.clockInfo).then(res => {
               if (res.code == 1) {
                  this.clockInfo = {
                     emptyCause: '',
                     carConditionAttachments: [],
                     mileage: '',
                     mileageImg: '',
                     attachments: [],
                     clockType: '', //ClockIn ,Clockout
                     carCondition: ''
                  }
                  this.showClockIn = false
                  this.init()
               } else {
                  this.$util.showToast({
                     title: res.error
                  })
                  this.$refs.clockInModal.loading = false
               }
            })
         },
         closeModal() {
            this.showClockIn = false
            this.show7 = false
            this.arrangeInfo = {
               deliverTime: this.$util.formatDate(new Date(), null, 1),
               driverId: '',
               buyerId: '',
               dianhua: '',
               wentifankui: '',
               lianxiren: '',
               dizhi: '',
            }
            this.clockInfo = {
               emptyCause: '',
               carConditionAttachments: [],
               mileage: '',
               mileageImg: '',
               attachments: [],
               clockType: '', //ClockIn ,Clockout
               clockType: this.nextClockType, //ClockIn ,Clockout
               carCondition: ''
            }
            this.driverName = ''
            this.buyerName = ''
         },
         Getdrivers() {
            this.$api.Getdrivers().then(res => {
@@ -565,8 +649,9 @@
            if (this.deliverKeyID) {
               data.deliverKeyID = this.deliverKeyID
            }
            this.$api.driverGetDeliverPlans(data).then(res => {
            this.$api.GetDriverRecords(data).then(res => {
               if (res.code == 1) {
                  this.nextClockType = res.data.nextClockType
                  if (this.pageIndex == 1) {
                     this.orderList = res.data.data
                  } else {
@@ -582,6 +667,7 @@
                     // 数据已加载完毕
                     this.loadStatus = 'nomore'
                  }
               } else {
                  // _that.$refs.uToast.show({ message: res.msg, type: 'error' });
               }
@@ -621,7 +707,7 @@
         },
         goDetail(item) {
            uni.navigateTo({
               url: `/pages/delivergoods/feedbackdetail?KeyId=${item.keyid}`
               url: `/pages/delivergoods/clockInDetail?KeyId=${item.id}&isAdmin=true`
            });
         }
      }