-
zhangwei
2025-03-24 2d43a1df3f5ba42710e6d21c27d1e13bdb8dfd56
src/pages/delivergoods/arrange.vue
@@ -17,21 +17,32 @@
   </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" @click='goDetail(item)'>
         <view class="listrecord c-p-t-20" v-for="(item,index) in orderList" :key="item.keyid">
            <view class="coreshop-ff chuany-bradius20">
               <view class="chuany-font26">
                  <view class="chuany-flex chuany-justify-between">
                     <text class="chuany-width7">{{index+1}}</text>
                     <text class="chuany-width6">{{index+1}}</text>
                     <view class="chuany-width15">
                        {{$util.formatDate(item.createTime,'riqi')}}
                        {{$util.formatDate(item.deliverTime,'riqi')}}
                     </view>
                     <view class="chuany-width73">
                        <u-text size='14' :text="item.remark" lines="1">
                     <view :class="item.deliveredstatus !== 'Delivered'?'chuany-width67':'chuany-width79'"
                        @click='goDetail(item)'>
                        <u-text size='14' :text="item.companyName" lines="1">
                        <!-- <u-text size='14' :text="item.remark||item.companyName" lines="1"> -->
                        </u-text>
                     </view>
                     <view class="chuany-width5" @tap.stop='editOrder(item)'>
                        <up-icon name="edit-pen" ></up-icon>
                     </view>
                     <template v-if="item.deliveredstatus !== 'Delivered'">
                        <view class="chuany-width6 chuany-paddingright-10" @tap.stop='editOrder(item)'>
                           <up-icon name="edit-pen" size='18'></up-icon>
                        </view>
                        <view class="chuany-width6" @tap.stop='UndoDeliverPlans(item)'>
                           <up-icon name="reload" size='19'></up-icon>
                        </view>
                     </template>
                     <!-- <view class="chuany-width6" v-else>
                        <u-text size='14' type="" text="" lines="1">
                        </u-text>
                     </view> -->
                  </view>
               </view>
            </view>
@@ -42,28 +53,41 @@
         <up-empty text='暂无' icon="/static/order.png">
         </up-empty>
      </view>
      <up-modal title="送货安排" :show="show7" showCancelButton @confirm="confirmSave" @cancel='cancelModal'
         :asyncClose="true">
      <up-modal title="送货安排" :show="show7" showCancelButton @confirm="confirmSave" @cancel='cancelModal'
         ref='modalArrange' :asyncClose="true">
         <up-form labelPosition="left" :model="arrangeInfo" ref="formRef" labelWidth='140rpx'>
            <up-form-item label="送货日期" prop="deliverTime" required :borderBottom='false' ref="item1"
               @click="clickShouTime">
               <!-- <up-input v-model="arrangeInfo.deliverTime" readonly border="none"
                  placeholder="点击选择工作日期"></up-input> -->
               <up-datetime-picker hasInput @confirm='confirmDate' :show="shougHuoshow" v-model="deliverTime"
                  mode="date" placeholder="点击选择工作日期" :minDate='Number(new Date(minDate))'
                  @cancel='() => shougHuoshow = false'></up-datetime-picker>
                  disabled disabledColor='#FFF' mode="date" placeholder="点击选择工作日期"
                  :minDate='Number(new Date(minDate))' @cancel='() => shougHuoshow = false'></up-datetime-picker>
            </up-form-item>
            <up-form-item label="司机" prop="driverId" required :borderBottom='false' @click="clickAction('driver')"
            <up-form-item label="排序" prop="sort" required :borderBottom='false' ref="item1">
               <up-input v-model="arrangeInfo.sort" placeholder="请输入排序" border="none" type="number">
               </up-input>
            </up-form-item>
            <up-form-item label="司机" prop="driverName" required :borderBottom='false' @click="clickAction('driver')"
               ref="item1">
               <up-input v-model="driverName" disabled border="none" disabledColor="#ffffff"
               <up-input v-model="arrangeInfo.driverName" disabled border="none" disabledColor="#ffffff"
                  placeholder="请选择司机"></up-input>
            </up-form-item>
            <up-form-item label="收货单位" prop="buyerId" required :borderBottom='false' ref="item1">
               <up-input v-model="arrangeInfo.companyName" placeholder="请选择收货单位" border="none">
            <up-form-item label="收货单位" prop="companyName" labelPosition='top' required :borderBottom='false'
               ref="item1" v-if='show7'>
               <!-- <tem-selects-fan placeholder="请选择收货单位" :data="customerList" :clearable='true'
                  :value="arrangeInfo.companyName" :value-type="valueType" :filterable='true' :searchType='1'
                  @input='selectChange'></tem-selects-fan> -->
               <!-- <form-select class="form_select" ref="formSelect1" :search="true" :icon="true"
                  :placeholder="optionPlaceholder" :selectedId="optionId" :localdata="optionModel"
                  @change="changeOption" @clear="clearOption"></form-select> -->
               <tem-select ref="formSelect" placeholder="请选择收货单位" :selectedId="arrangeInfo.buyerId" :value='arrangeInfo.companyName' :search='true'
                  :localdata="customerList" @change="selectChange"></tem-select>
               <!-- <up-input v-model="arrangeInfo.companyName" placeholder="请选择收货单位" border="none">
                  <template #suffix>
                     <up-button @tap="clickAction" text="点击选择" type="primary" size="mini"></up-button>
                  </template>
               </up-input>
               </up-input> -->
            </up-form-item>
            <up-form-item label="联系人" prop="lianxiren" :borderBottom='false' ref="item1">
               <up-input v-model="arrangeInfo.lianxiren" border="none" placeholder="请输入联系人"></up-input>
@@ -71,18 +95,18 @@
            <up-form-item label="联系电话" prop="dianhua" required :borderBottom='false' ref="item1">
               <up-input v-model="arrangeInfo.dianhua" border="none" placeholder="请输入联系电话"></up-input>
            </up-form-item>
            <up-form-item label="送货地址" prop="dizhi" required :borderBottom='false' ref="item1">
            <up-form-item label="送货地址" prop="dizhi" labelPosition='top' required :borderBottom='false' ref="item1">
               <up-input v-model="arrangeInfo.dizhi" border="none" placeholder="请输入送货地址"></up-input>
            </up-form-item>
            <up-form-item label="送货事由" prop="remark" required :borderBottom='false' ref="item1">
               <up-textarea v-model="arrangeInfo.remark" border="none" placeholder="请输入送货事由"></up-textarea>
            <up-form-item label="送货事由" prop="remark" labelPosition='top' required :borderBottom='false' ref="item1">
               <up-input v-model="arrangeInfo.remark" border="none" placeholder="请输入送货事由"></up-input>
            </up-form-item>
         </up-form>
      </up-modal>
      <fui-date-picker range :show="datePickerShow" :value="getFirstDayOfMonth()" type="3" zIndex="10000"
      <fui-date-picker :show="datePickerShow" :value="getFirstDayOfMonth()" type="3" zIndex="10000"
         @change="changePicker" :minDate='minDate' :maxDate='maxDate' @cancel="clickTime"></fui-date-picker>
      <up-action-sheet :show="showActions" :actions="actions" title="请选择" @close="showActions = false" wrapMaxHeight='500px'
         @select="selectItem">
      <up-action-sheet :show="showActions" :actions="actions" title="请选择" @close="showActions = false"
         wrapMaxHeight='500px' @select="selectItem">
      </up-action-sheet>
   </view>
</template>
@@ -96,14 +120,17 @@
   export default {
      data() {
         return {
            valueType: {
               label: 'companyName',
               value: 'keyid'
            },
            datePickerShow: false,
            shougHuoshow: false,
            workTime: '',
            workTime: this.$util.formatDate(new Date()),
            orderList: [],
            loadStatus: 'loadmore',
            pageIndex: 1,
            pageSize: 20,
            contentVal: '',
            pageSize: 30,
            customerList: [],
            isEdit: false,
            editItem: {},
@@ -119,12 +146,14 @@
            arrangeInfo: {
               deliverTime: this.$util.formatDate(new Date(), null, 1),
               driverId: '',
               buyerId: '',
               buyerId: null,
               dianhua: '',
               remark: '',
               lianxiren: '',
               dizhi: '',
               companyName:''
               companyName: '',
               driverName: '',
               sort: '1'
            },
            rules: {
               'deliverTime': {
@@ -133,32 +162,40 @@
                  message: '请选择日期',
                  trigger: ['blur', 'change']
               },
               'arrangeInfo.driverId': {
               'driverName': {
                  type: 'string',
                  max: 1,
                  required: true,
                  message: '请选择司机',
                  trigger: ['blur', 'change']
               },
               'arrangeInfo.dianhua': {
               'companyName': {
                  type: 'string',
                  max: 1,
                  required: true,
                  message: '请选择或填写送货单位',
                  trigger: ['blur', 'change']
               },
               'dianhua': {
                  type: 'string',
                  required: true,
                  message: '请输入联系电话',
                  trigger: ['blur', 'change']
               },
               'arrangeInfo.dizhi': {
               'dizhi': {
                  type: 'string',
                  max: 1,
                  required: true,
                  message: '请输入送货地址',
                  trigger: ['blur', 'change']
               },
               'arrangeInfo.remark': {
               'remark': {
                  type: 'string',
                  max: 1,
                  required: true,
                  message: '请输入送货事由',
                  trigger: ['blur', 'change']
               },
               'sort': {
                  type: 'number',
                  required: true,
                  message: '请输入排序',
                  trigger: ['blur', 'change']
               },
            },
@@ -166,8 +203,8 @@
            switchVal: false,
            driverList: [],
            buyerName: '',
            timeStart: '',
            timeEnd: '',
            timeStart: new Date(),
            timeEnd: new Date(),
            sevenDaysDriver: [],
            deliverKeyID: '',
            deliverKeyName: ''
@@ -184,21 +221,24 @@
         this.getCustomer()
         this.GetDriversOfWithin7days()
      },
      onMounted() {
         this.$refs.formRef.setRules(this.rules);
      },
      onReachBottom() {
         if (this.loadStatus != 'nomore') {
            this.getList()
         }
      },
      onPullDownRefresh() {
         this.startDate = ''
         this.endDate = ''
         this.workTime = ''
         this.timeStart = new Date()
         this.timeEnd = new Date()
         this.workTime = this.$util.formatDate(new Date())
         this.deliverKeyName = ''
         this.init()
         uni.stopPullDownRefresh();
      },
      methods: {
         goDetail(item){
         goDetail(item) {
            uni.navigateTo({
               url: `/pages/delivergoods/arrangedetail?KeyId=${item.keyid}`
            });
@@ -211,16 +251,16 @@
            })
         },
         changePicker(val) {
            console.log(val);
            this.workTime = val.startDate.result + '至' + val.endDate.result
            this.timeStart = new Date(val.startDate.result) //工作开始时间
            this.timeEnd = new Date(val.endDate.result)
            console.log(val, '-=-=’');
            this.workTime = val.result
            this.timeStart = new Date(val.result) //工作开始时间
            this.timeEnd = new Date(val.result)
            this.datePickerShow = !this.datePickerShow
            this.getList()
            this.init()
         },
         confirmDate(val) {
            console.log(val);
            this.arrangeInfo.deliverTime = val
            this.arrangeInfo.deliverTime = this.$util.formatDate(val.value)
            this.shougHuoshow = false
         },
         getCustomer() {
@@ -229,13 +269,15 @@
                  this.customerList = res.data
                  this.customerList.forEach(item => {
                     item.name = item.companyName
                     item.title = item.companyName
                     item.id = item.keyid
                  })
               }
            })
         },
         selectItem(item) {
            if (this.selectAc == 'driver') {
               this.driverName = item.name
               this.arrangeInfo.driverName = item.name
               this.arrangeInfo.driverId = item.keyid
            } else if (this.selectAc == 'driver7') {
               this.deliverKeyID = item.keyid
@@ -250,6 +292,19 @@
               this.arrangeInfo.companyName = item.companyName
            }
            this.selectAc = ''
         },
         selectChange(item) {
            console.log(item,'hhhhh');
            if (typeof item == 'object') {
               this.buyerName = item.name
               this.arrangeInfo.buyerId = item.keyid
               this.arrangeInfo.dizhi = item.adder
               this.arrangeInfo.dianhua = item.companyPhone
               this.arrangeInfo.lianxiren = item.businessManagers
               this.arrangeInfo.companyName = item.companyName
            } else {
               this.arrangeInfo.companyName = item
            }
         },
         getFirstDayOfMonth() {
            var currentDate = new Date();
@@ -281,7 +336,7 @@
         editOrder(item) {
            this.isEdit = true
            this.arrangeInfo = {
               deliverTime: this.$util.formatDate(new Date(), null, 1),
               deliverTime: this.$util.formatDate(item.deliverTime),
               driverId: item.driverId,
               buyerId: item.buyerId,
               dianhua: item.dianhua,
@@ -289,14 +344,43 @@
               lianxiren: item.lianxiren,
               dizhi: item.dizhi,
               keyid: item.keyid,
               companyName:item.companyName
               companyName: item.companyName,
               sort: item.sort,
               driverName: item.driver.name || ''
            }
            this.show7 = true
            this.driverName = item.driver.name
            this.driverName = item.driver && item.driver.name
            // let obj = this.customerList.find(ite => {
            //    return ite.keyid == item.buyerId
            // })
            // this.buyerName = obj.companyName
         },
         UndoDeliverPlans(item) {
            let that = this
            uni.showModal({
               title: '提示',
               content: '确认撤销该订单吗?',
               success: function(res) {
                  if (res.confirm) {
                     // 执行确认后的操作
                     that.$api.UndoDeliverPlans(item.keyid).then(res => {
                        if (res.code == 1) {
                           that.$util.showToast({
                              title: '撤销成功!'
                           })
                           that.init()
                        } else {
                           that.$util.showToast({
                              title: res.error
                           })
                        }
                     })
                  } else {
                     // 执行取消后的操作
                  }
               }
            })
         },
         delOrder(item) {
            let that = this
@@ -328,13 +412,20 @@
         },
         init() {
            this.pageIndex = 1
            this.pageSize = 20
            this.pageSize = 30
            this.loadStatus = 'loadmore'
            this.orderList = []
            this.contentVal = ''
            console.log(this.orderList);
            this.getList()
         },
         confirmSave() {
            // if (!this.arrangeInfo.driverId) {
            //    this.$refs.modalArrange.loading = false
            //    return this.$util.showToast({
            //       title: '请选择司机!'
            //    })
            // }
            console.log();
            this.$refs.formRef.validate().then(res => {
               if (this.isEdit) {
                  this.$api.UpDataDeliverPlans(this.arrangeInfo).then(res => {
@@ -343,11 +434,14 @@
                        this.arrangeInfo = {
                           deliverTime: this.$util.formatDate(new Date(), null, 1),
                           driverId: '',
                           buyerId: '',
                           buyerId: null,
                           dianhua: '',
                           remark: '',
                           lianxiren: '',
                           dizhi: '',
                           companyName: '',
                           driverName: '',
                           sort: '1'
                        }
                        this.show7 = false
                        this.driverName = ''
@@ -367,11 +461,14 @@
                     this.arrangeInfo = {
                        deliverTime: this.$util.formatDate(new Date(), null, 1),
                        driverId: '',
                        buyerId: '',
                        buyerId: null,
                        dianhua: '',
                        remark: '',
                        lianxiren: '',
                        dizhi: '',
                        companyName: '',
                        driverName: '',
                        sort: '1'
                     }
                     this.show7 = false
                     this.driverName = ''
@@ -384,6 +481,8 @@
                  }
                  this.isLoading = false
               })
            }).catch(errors => {
               this.$refs.modalArrange.loading = false
            })
         },
@@ -391,11 +490,14 @@
            this.arrangeInfo = {
               deliverTime: this.$util.formatDate(new Date(), null, 1),
               driverId: '',
               buyerId: '',
               buyerId: null,
               dianhua: '',
               remark: '',
               lianxiren: '',
               dizhi: '',
               companyName: '',
               driverName: '',
               sort: '1'
            }
            this.show7 = false
            this.driverName = ''
@@ -472,12 +574,6 @@
                  }
               }
            })
         },
         actionClick(item, e) {
            console.log(e);
            if (e.index == 0) {
               this.contentVal = item.remark
            }
         }
      }
   }