zhangwei
2024-09-29 94384dcf5066aa1a7b2e37874fe331e148bc9249
src/pages/order/detail.vue
@@ -3,7 +3,8 @@
      <scroll-view enable-flex="true">
         <view class="list chuany-flex chuany-flex-direction chuany-align-center c-p-b-30">
            <view class="content c-p-b-18">
               <view class="bgblue c-p-l-18 c-p-r-18 c-p-b-10 c-p-t-10 chuany-flex chuany-justify-between chuany-font30">
               <view
                  class="bgblue c-p-l-18 c-p-r-18 c-p-b-10 c-p-t-10 chuany-flex chuany-justify-between chuany-font30">
                  <view class="chuany-flex chuany-flex-direction">
                     <text class=''>
                        {{$util.formatDate(detailItem.startTime)}}
@@ -24,9 +25,12 @@
                  <text class='c-p-l-18 c-p-r-18 text-69'>
                     日期:{{detailItem.wordStartTimeName}} 至 {{detailItem.wordEndTimeName}}
                  </text>
                  <text class='c-p-l-18 c-p-r-18 text-69'>
                  <view class="c-p-l-18 c-p-r-18 text-69" v-if="detailItem.zixinganpai">
                     时间:{{detailItem.zixinganpaiName}}
                  </view>
                  <view class="c-p-l-18 c-p-r-18 text-69" v-else>
                     时间:{{detailItem.startTimeName}} 至 {{detailItem.endTimeName}}
                  </text>
                  </view>
               </view>
               <view class="chuany-flex chuany-flex-direction chuany-font28">
                  <text class='c-p-l-18 c-p-r-18 text-69'>
@@ -36,7 +40,7 @@
                     地址:{{detailItem.worderAddress}}
                  </text>
               </view>
               <view class='chuany-flex chuany-justify-between c-p-l-18 c-p-r-18'>
               <view class='chuany-flex chuany-justify-between c-p-l-18 c-p-r-18 c-p-t-6 chuany-align-center'>
                  <view class="redcla">
                     <text class="chuany-font40">
                        {{detailItem.workPrice}}
@@ -45,8 +49,16 @@
                        {{detailItem.workerType==0?'元/小时':'元/件'}}
                     </text>
                  </view>
                  <!-- <up-tag text="去抢活" type="warning" shape="circle"></up-tag> -->
                  <!-- <up-tag text="去抢活" type="warning" shape="circle"></up-tag> -->
                  <view class="">
                     <!-- <up-tag class='c-m-r-10' text="下架" shape="circle" type="error" size='mini'
                     v-if="detailItem.orderStatus==0" @click.stop="deleteOrder(detailItem)"></up-tag> -->
                     <up-button class='c-m-r-10' :text="detailItem.isEn?'下架':'上架'" shape="circle"
                        :loading='isLoading' :loadingText="detailItem.isEn?'下架中':'上架中'"
                        v-if="detailItem.orderStatus==0" :type="detailItem.isEn?'error':'primary'" size='mini'
                        @click.stop="manageOrder(detailItem)"></up-button>
                     <!-- <up-tag text="去抢活" type="warning" shape="circle"></up-tag> -->
                     <!-- <up-tag text="去抢活" type="warning" shape="circle"></up-tag> -->
                  </view>
               </view>
            </view>
         </view>
@@ -62,9 +74,11 @@
                     <!-- <template #right-icon v-if="item.isSelected">
                        <up-button class="button-layout__item" text="查看" size="mini" type="primary" @click="toView(item)"></up-button>
                     </template> -->
                     <template #right-icon v-if="!item.isSelected">
                        <up-button class="button-layout__item" text="确认" size="mini" type="success"
                           @click="selectBtn(item)"></up-button>
                     <template #right-icon v-if="!item.isSelected" class="chuany-flex">
                        <up-tag class="button-layout__item" text="录用" size="mini" type="success"
                           @click="selectBtn(item,true)"></up-tag>
                        <up-tag class="button-layout__item c-m-l-18" text="拒绝" size="mini" type="error"
                           @click="selectBtn(item,false)"></up-tag>
                     </template>
                  </up-cell>
               </up-list-item>
@@ -106,6 +120,9 @@
            </up-list>
         </view>
      </scroll-view>
      <up-modal :show="modalShow" :asyncClose="true" showCancelButton closeOnClickOverlay :content="content"
         @confirm="modalConfirm" @cancel="modalCancel">
      </up-modal>
   </view>
</template>
@@ -127,7 +144,10 @@
      $db
   } = getCurrentInstance().appContext.config.globalProperties
   const detailItem = ref({})
   const workerItem = ref({})
   let selectVal = ref(false)
   let orderIdVal = ref('')
   let isLoading = ref(false)
   onLoad((option) => {
      let {
         orderid
@@ -137,11 +157,12 @@
      console.log(option, '========orderid', orderid);
      // detailItem.value = JSON.parse($db.get('detailItem'))
   })
   const click = () => {
   }
   let modalShow = ref(false)
   let content = ref('')
   const toView = (item) => {
      uni.navigateTo({
         url: `/pages/company/index?workerid=${item.WorkerUserId}&workname=${item.WorkerName}`
@@ -158,22 +179,59 @@
         url: '/pages/order/worker'
      })
   }
   const selectBtn = (item) => {
      $api.saveQueRen({
         orderBiddingId: item.id
      }).then(res => {
         if (res.code == 1) {
            $util.showToast({
               title: "确认成功!",
               icon: "success"
            })
            getOrder(orderIdVal)
         } else {
            this.$util.showToast({
               title: res.error ? res.error : '失败!'
            })
         }
      })
   const selectBtn = (item, val) => {
      workerItem.value = item
      modalShow.value = true
      selectVal.value = val
      if (val) {
         content.value = `确定录用${item.workerName}吗?`
      } else {
         content.value = `确定拒绝${item.workerName}吗?`
      }
   }
   const modalConfirm = () => {
      if (selectVal.value) {
         console.log('3333333333');
         $api.saveQueRen({
            orderBiddingId: workerItem.value.id
         }).then(res => {
            if (res.code == 1) {
               $util.showToast({
                  title: "录用成功!",
                  icon: "success"
               })
               getOrder(orderIdVal)
            } else {
               $util.showToast({
                  title: res.error ? res.error : '失败!'
               })
            }
            modalShow.value = false
         })
      } else {
         console.log('444444');
         $api.saveBuLuYong({
            orderBiddingId: workerItem.value.id
         }).then(res => {
            if (res.code == 1) {
               $util.showToast({
                  title: "拒绝成功!",
                  icon: "success"
               })
               getOrder(orderIdVal)
            } else {
               $util.showToast({
                  title: res.error ? res.error : '失败!'
               })
            }
            modalShow.value = false
         })
      }
   }
   const modalCancel = () => {
      modalShow.value = false
      workerItem.value = {}
   }
   const getOrder = (orderid) => {
      $api.getOrder(orderid).then(res => {
@@ -182,6 +240,42 @@
         }
      })
   }
   const manageOrder = (item) => {
      let obj = {
         orderId: item.id
      }
      isLoading.value = true
      if (item.isEn) {
         $api.deleteOrder(obj).then(res => {
            if (res.code == 1) {
               $util.showToast({
                  title: '下架成功!'
               })
               getOrder(orderIdVal)
            } else {
               $util.showToast({
                  title: res.error
               })
            }
            isLoading.value = false
         })
      } else {
         $api.saveOrder(item).then(res => {
            if (res.code == 1) {
               $util.showToast({
                  title: "上架成功!",
                  icon: "success"
               })
               getOrder(orderIdVal)
            } else {
               $util.showToast({
                  title: res.msg
               })
            }
            isLoading.value = false
         })
      }
   }
</script>
<style lang='scss'>