Kaynağa Gözat

赛事核销默认勾选

学习?学个屁 1 gün önce
ebeveyn
işleme
8eb0ca1140
2 değiştirilmiş dosya ile 81 ekleme ve 129 silme
  1. 18 46
      src/components/classItem/index.vue
  2. 63 83
      src/subPack/writeOff/index.vue

+ 18 - 46
src/components/classItem/index.vue

@@ -12,55 +12,27 @@
       <view class="max-w-500rpx">
         <wd-text :text="item.name" size="28rpx" :lines="1"></wd-text>
       </view>
-      <commonbtn
-        bg-color="#0074FF"
-        @click="handlePic(String(item.id))"
-        v-if="type == 0 && showBtn"
-        >拍照核销</commonbtn
-      >
-      <commonbtn
-        bg-color="#0074FF"
-        @click="handleGoPath(`/subPack/ReservationClass/index?id=${item.id}`)"
-        v-if="type == 1 && showBtn"
-        >预约这节</commonbtn
-      ><commonbtn
-        bg-color="#0074FF"
-        @click="handlePost"
-        v-if="type == 2 && showBtn"
-        >延期这节</commonbtn
-      >
+      <commonbtn bg-color="#0074FF" @click="handlePic(String(item.id))" v-if="type == 0 && showBtn">拍照核销</commonbtn>
+      <commonbtn bg-color="#0074FF" @click="handleGoPath(`/subPack/ReservationClass/index?id=${item.id}`)"
+        v-if="type == 1 && showBtn">预约这节</commonbtn>
+      <commonbtn bg-color="#0074FF" @click="handlePost" v-if="type == 2 && showBtn">延期这节</commonbtn>
       <view v-if="!showBtn">
-        <view class="text-gray font-semibold text-28rpx" v-if="item.orDone"
-          >已完成</view
-        >
-        <view v-else class="text-[#0074FF] font-semibold text-28rpx"
-          >未开始</view
-        >
+        <view class="text-gray font-semibold text-28rpx" v-if="item.orDone">已完成</view>
+        <view v-else class="text-[#0074FF] font-semibold text-28rpx">未开始</view>
       </view>
     </view>
-    <view
-      class="mt20rpx pl20rpx flex items-center text-24rpx"
-      @click="
-        handleGoPath(
-          `/subPack/PersonnelView/index?id=${item.id}&postponeNum=${item.postponeNum}&writtenOffNum=${item.writtenOffNum}&unwrittenOffNum=${item.unwrittenOffNum}`,
-        )
-      "
-    >
-      <view class="text-[rgb(0,0,0,0.3)] mr20rpx"
-        >共{{ item?.totalNum }}人</view
-      >
-      <view class="text-[rgb(0,0,0,0.3)] mr20rpx"
-        >延课
-        <text class="text-#0074FF"> {{ item.postponeNum }} </text> 人</view
-      >
-      <view class="text-[rgb(0,0,0,0.3)] mr20rpx"
-        >已核销<text class="text-#0074FF"> {{ item.writtenOffNum }} </text
-        >人</view
-      >
-      <view class="text-[rgb(0,0,0,0.3)]"
-        >未核销<text class="text-#0074FF"> {{ item.unwrittenOffNum }} </text
-        >人</view
-      >
+    <view class="mt20rpx pl20rpx flex items-center text-24rpx" @click="
+      handleGoPath(
+        `/subPack/PersonnelView/index?id=${item.id}&postponeNum=${item.postponeNum}&writtenOffNum=${item.writtenOffNum}&unwrittenOffNum=${item.unwrittenOffNum}`,
+      )
+      ">
+      <view class="text-[rgb(0,0,0,0.3)] mr20rpx">共{{ item?.totalNum }}人</view>
+      <view class="text-[rgb(0,0,0,0.3)] mr20rpx">延课
+        <text class="text-#0074FF"> {{ item.postponeNum }} </text> 人
+      </view>
+      <view class="text-[rgb(0,0,0,0.3)] mr20rpx">已核销<text class="text-#0074FF"> {{ item.writtenOffNum }} </text>人
+      </view>
+      <view class="text-[rgb(0,0,0,0.3)]">未核销<text class="text-#0074FF"> {{ item.unwrittenOffNum }} </text>人</view>
     </view>
   </view>
 </template>

+ 63 - 83
src/subPack/writeOff/index.vue

@@ -5,18 +5,12 @@
       </image>
       <view class="font-semibold text-32rpx">{{ data.siteName }}</view>
     </view>
-    <view
-      class="mt20rpx bg-white px-24rpx py-28rpx rounded-32rpx"
-      v-if="data.appOrderProInfoVerifyVOS"
-    >
+    <view class="mt20rpx bg-white px-24rpx py-28rpx rounded-32rpx" v-if="data.appOrderProInfoVerifyVOS">
       <wd-checkbox-group v-model="checkedAll">
         <!-- 无固定场 -->
         <template v-if="type >= GoodsType.noFixed">
           <view class="flex items-center">
-            <image
-              :src="data.productImage"
-              class="w200rpx h-200rpx rounded-32rpx min-w-200rpx"
-            />
+            <image :src="data.productImage" class="w200rpx h-200rpx rounded-32rpx min-w-200rpx" />
             <view class="ml20rpx flex-1">
               <view class="text-32rpx">{{ data.productName }}</view>
 
@@ -28,47 +22,24 @@
               </view>
             </view>
           </view>
-          <view
-            class="flex items-center justify-between mb20rpx mt24rpx"
-            v-for="item in data.appOrderProInfoVerifyVOS"
-            :key="item.appOrderProInfo.id"
-          >
-            <view v-if="item.appOrderProInfo.type != 6"
-              >券号:{{ item.appOrderProInfo.ticketNo }}</view
-            >
-            <wd-checkbox
-              :model-value="item.isinId"
-              checked-color="#fdd143"
-              v-if="item.isinStatus == 0"
-            >
+          <view class="flex items-center justify-between mb20rpx mt24rpx" v-for="item in data.appOrderProInfoVerifyVOS"
+            :key="item.appOrderProInfo.id">
+            <view v-if="item.appOrderProInfo.type != 6">券号:{{ item.appOrderProInfo.ticketNo }}</view>
+            <wd-checkbox :model-value="item.isinId" checked-color="#fdd143" v-if="item.isinStatus == 0"
+              :disabled="isType4DefaultChecked">
             </wd-checkbox>
-            <wd-tag
-              v-if="item.appOrderProInfo.orderStatus == 6"
-              bg-color="rgba(0,0,0,0.1)"
-              color="rgba(0,0,0,0.3)"
-              >已退款</wd-tag
-            >
-            <wd-tag
-              v-if="item.appOrderProInfo.orderStatus == 2"
-              bg-color="rgba(0,0,0,0.1)"
-              color="rgba(0,0,0,0.3)"
-              >已使用</wd-tag
-            >
-            <wd-tag
-              v-if="item.appOrderProInfo.orderStatus == 3"
-              bg-color="rgba(0,0,0,0.1)"
-              color="rgba(0,0,0,0.3)"
-              >已到期</wd-tag
-            >
+            <wd-tag v-if="item.appOrderProInfo.orderStatus == 6" bg-color="rgba(0,0,0,0.1)"
+              color="rgba(0,0,0,0.3)">已退款</wd-tag>
+            <wd-tag v-if="item.appOrderProInfo.orderStatus == 2" bg-color="rgba(0,0,0,0.1)"
+              color="rgba(0,0,0,0.3)">已使用</wd-tag>
+            <wd-tag v-if="item.appOrderProInfo.orderStatus == 3" bg-color="rgba(0,0,0,0.1)"
+              color="rgba(0,0,0,0.3)">已到期</wd-tag>
           </view>
         </template>
         <!-- 包场 -->
         <template v-else>
-          <view
-            class="flex justify-between items-center w-full mb20rpx"
-            v-for="item in data.appOrderProInfoVerifyVOS"
-            :key="item.id"
-          >
+          <view class="flex justify-between items-center w-full mb20rpx" v-for="item in data.appOrderProInfoVerifyVOS"
+            :key="item.id">
             <view>场次</view>
             <view class="flex-1">
               <view class="flex items-center justify-between ml20rpx">
@@ -77,29 +48,14 @@
                     item.appOrderProInfo.price
                   }}
                 </view>
-                <wd-tag
-                  v-if="item.appOrderProInfo.orderStatus == 6"
-                  bg-color="rgba(0,0,0,0.1)"
-                  color="rgba(0,0,0,0.3)"
-                  >已退款</wd-tag
-                >
-                <wd-tag
-                  v-if="item.appOrderProInfo.orderStatus == 2"
-                  bg-color="rgba(0,0,0,0.1)"
-                  color="rgba(0,0,0,0.3)"
-                  >已使用</wd-tag
-                >
-                <wd-tag
-                  v-if="item.appOrderProInfo.orderStatus == 3"
-                  bg-color="rgba(0,0,0,0.1)"
-                  color="rgba(0,0,0,0.3)"
-                  >已到期</wd-tag
-                >
-                <wd-checkbox
-                  :model-value="item.isinId"
-                  checked-color="#fdd143"
-                  v-if="item.isinStatus == 0"
-                ></wd-checkbox>
+                <wd-tag v-if="item.appOrderProInfo.orderStatus == 6" bg-color="rgba(0,0,0,0.1)"
+                  color="rgba(0,0,0,0.3)">已退款</wd-tag>
+                <wd-tag v-if="item.appOrderProInfo.orderStatus == 2" bg-color="rgba(0,0,0,0.1)"
+                  color="rgba(0,0,0,0.3)">已使用</wd-tag>
+                <wd-tag v-if="item.appOrderProInfo.orderStatus == 3" bg-color="rgba(0,0,0,0.1)"
+                  color="rgba(0,0,0,0.3)">已到期</wd-tag>
+                <wd-checkbox :model-value="item.isinId" checked-color="#fdd143"
+                  v-if="item.isinStatus == 0"></wd-checkbox>
               </view>
             </view>
           </view>
@@ -109,9 +65,7 @@
       <wd-divider color="#F0F0F0"></wd-divider>
       <view class="flex items-center justify-between">
         <view class="text-28rpx">消费张数</view>
-        <view class="font-semibold text-#FB5B5B"
-          >本次核销{{ checkedAll.length }}张</view
-        >
+        <view class="font-semibold text-#FB5B5B">本次核销{{ checkedAll.length }}张</view>
       </view>
       <view class="mt12rpx text-#FB5B5B"> 共{{ AvailableNumber }}张可用</view>
     </view>
@@ -120,14 +74,8 @@
       <view>核销前请与顾客确认核销券数</view>
     </view>
   </view>
-  <fixdbtn
-    block
-    size="large"
-    :disabled="!checkedAll.length"
-    v-if="data"
-    @click="handleSubmit"
-    >确认核销({{ checkedAll.length }})</fixdbtn
-  >
+  <fixdbtn block size="large" :disabled="!checkedAll.length" v-if="data" @click="handleSubmit">确认核销({{ checkedAll.length
+  }})</fixdbtn>
 </template>
 
 <script setup lang="ts">
@@ -135,7 +83,7 @@ import { GoodsType } from "@/config";
 import { createGlobalLoadingMiddleware } from "@/api/core/middleware";
 import router from "@/router";
 const { isShowLoging } = storeToRefs(useUserStore());
-const checkedAll = ref([]);
+const checkedAll = ref<string[]>([]);
 
 const { data, send: getOrder } = useRequest(
   (id: string) =>
@@ -151,6 +99,40 @@ const { data, send: getOrder } = useRequest(
   console.log(err, "asdasdsad");
   router.replace({ name: "error" });
 });
+
+// 查找所有 type=4 且可选的项目,默认选中
+const isType4DefaultChecked = ref(false);
+watch(
+  () => data.value,
+  (newData) => {
+    if (newData && newData.appOrderProInfoVerifyVOS) {
+      const isType4 = newData.appOrderProInfoVerifyVOS.some(
+        item => item.appOrderProInfo.type === 4
+      );
+      if (isType4) {
+        // type=4时默认全选并禁用
+        const defaultSelected = newData.appOrderProInfoVerifyVOS
+          .filter(item => item.appOrderProInfo.type === 4 && item.isinStatus === 0)
+          .map(item => item.isinId)
+          .filter((id): id is string => id !== undefined);
+
+        checkedAll.value = [...defaultSelected];
+        isType4DefaultChecked.value = true;
+      } else {
+        // 非type=4时按原逻辑处理
+        const defaultSelected = newData.appOrderProInfoVerifyVOS
+          .filter(item => item.appOrderProInfo.type === 4 && item.isinStatus === 0)
+          .map(item => item.isinId)
+          .filter((id): id is string => id !== undefined);
+
+        checkedAll.value = [...defaultSelected];
+        isType4DefaultChecked.value = false;
+      }
+    }
+  },
+  { immediate: true }
+);
+
 const { send: submit } = useRequest(
   (orderProInfoIds: string[]) =>
     Apis.app.scanCodeVerification({
@@ -199,11 +181,9 @@ async function handleSubmit() {
   margin-bottom: 0px !important;
 }
 </style>
-<route lang="json">
-{
+<route lang="json">{
   "name": "writeOff",
   "style": {
     "navigationBarTitleText": "扫码核销"
   }
-}
-</route>
+}</route>