Pārlūkot izejas kodu

报餐功能-报餐bug修改

yusm 2 nedēļas atpakaļ
vecāks
revīzija
79909ddf6a

+ 7 - 0
fhKeeper/formulahousekeeper/management-workshop/src/main/java/com/management/platform/controller/FactoryController.java

@@ -33,6 +33,13 @@ public class FactoryController {
        msg.setCode("ok");
        return msg;
     }
+    @RequestMapping("/getFactoriesList")
+    public HttpRespMsg getFactoriesList(){
+        HttpRespMsg msg = new HttpRespMsg();
+        msg.setData(factoryService.list());
+        msg.setCode("ok");
+        return msg;
+    }
 
     @RequestMapping("/updateFactory")
     public HttpRespMsg updateMeal(Factory factory){

+ 9 - 2
fhKeeper/formulahousekeeper/management-workshop/src/main/java/com/management/platform/controller/MealApplicationsController.java

@@ -63,6 +63,10 @@ public class MealApplicationsController {
         if (first.isPresent()){
             return msg.fail("已申报过");
         }
+        Optional<MealApplications> second = list.stream().filter(mealApplications -> mealApplications.getStatus()==1).findFirst();
+        if (second.isPresent()){
+            return msg.fail("已核销过");
+        }
         MealTypes mealCategory = mealTypeService.getById(mealType);
 
         try {
@@ -136,10 +140,13 @@ public class MealApplicationsController {
         QueryWrapper<MealApplications> eq = new QueryWrapper<MealApplications>().eq("user_id", request.getHeader("token")).eq("meal_type_id", mealType).eq("factory_id", factory)
                 .eq("application_date", now.toLocalDate()).orderByDesc("applied_at").last("limit 1");
         MealApplications mealApplications = mealApplicationsService.getOne(eq);
-        mealApplications.setDeadlineTime(mealTypes.getDeadlineTime());
         if(mealApplications==null){
-            return msg.fail("二维码不存在");
+            msg.setData(mealTypes.getDeadlineTime());
+            msg.setCode("ok");
+            return msg;
         }
+        mealApplications.setDeadlineTime(mealTypes.getDeadlineTime());
+
         msg.setData(mealApplications);
         return msg;
     }

+ 15 - 2
fhKeeper/formulahousekeeper/management-workshop/src/main/java/com/management/platform/controller/MealTypesController.java

@@ -2,6 +2,7 @@ package com.management.platform.controller;
 
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.management.platform.entity.MealApplications;
 import com.management.platform.entity.MealTypes;
 import com.management.platform.mapper.MealApplicationsMapper;
 import com.management.platform.mapper.MealTypesMapper;
@@ -14,6 +15,7 @@ import org.springframework.web.bind.annotation.RestController;
 
 import javax.annotation.Resource;
 import java.time.LocalDateTime;
+import java.util.List;
 
 /**
  * <p>
@@ -32,8 +34,8 @@ public class MealTypesController {
     @Resource
     private MealTypesMapper mealTypesMapper;
 
-    @Resource
-    private MealApplicationsMapper mealApplicationsMapper;
+   @Resource
+   private MealApplicationsService mealApplicationsService;
 
     @RequestMapping("/getMeals")
     public HttpRespMsg getMeals(){
@@ -42,6 +44,13 @@ public class MealTypesController {
         msg.setCode("ok");
         return msg;
     }
+    @RequestMapping("/getMealsList")
+    public HttpRespMsg getMealsList(){
+        HttpRespMsg msg = new HttpRespMsg();
+        msg.setData(mealTypesService.list());
+        msg.setCode("ok");
+        return msg;
+    }
     @RequestMapping("/updateMeal")
     public HttpRespMsg updateMeal(MealTypes mealTypes){
         HttpRespMsg msg = new HttpRespMsg();
@@ -58,6 +67,10 @@ public class MealTypesController {
     @RequestMapping("/deleteMealType")
     public HttpRespMsg deleteMealType(Integer id){
         HttpRespMsg msg = new HttpRespMsg();
+        List<MealApplications> list = mealApplicationsService.list(new QueryWrapper<MealApplications>().eq("meal_type_id", id).eq("status", 0));
+        if(!list.isEmpty()){
+            return msg.fail("该餐别已有报餐数据,不可删除");
+        }
         boolean delete = mealTypesService.removeById(id);
         if(delete){
             msg.setCode("ok");

+ 18 - 5
fhKeeper/formulahousekeeper/timesheet-workshop-h5/src/views/meal/mealApplication.vue

@@ -111,9 +111,9 @@
   },
   mounted() {
     // 初始化加载二维码
-    this.loadQrCode();
     this.listFactory();
     this.listMeal();
+    this.loadQrCode();
   },
   methods: {
     // 餐别切换
@@ -151,8 +151,10 @@
           if (this.factories.length > 0) {
             this.factory = this.factories[0].id;
           }
+          this.loadQrCode();
         } else {
           this.factory = 1;
+          this.loadQrCode();
         }
       }).catch(err => {
         console.error('获取厂区列表失败:', err);
@@ -173,9 +175,11 @@
           if (this.meals.length > 0) {
             this.mealType = this.meals[0].id;
           }
+          this.loadQrCode();
         } else {
           this.mealType = 1;
         }
+        this.loadQrCode();
       }).catch(err => {
         console.error('获取餐别列表失败:', err);
         this.$toast.fail('获取餐别列表失败');
@@ -189,15 +193,24 @@
         factory: this.factory
       }).then(res => {
         if (res.code === 'ok' && res.data) {
-          this.qrcodeUrl = res.data.qrCode || '';
-          this.qrStatus = res.data.status;
-          this.deadlineTime = res.data.deadlineTime;
+
+          if (typeof res.data === 'string') {
+            //当mealApplications为 null时,直接返回deadlineTime字符串
+            this.deadlineTime = res.data;
+            this.qrcodeUrl = '';
+          } else {
+            this.qrcodeUrl = res.data.qrCode || '';
+            this.qrStatus = res.data.status;
+            this.deadlineTime = res.data.deadlineTime || '';
+          }
         } else {
           this.qrcodeUrl = '';
+          this.deadlineTime = '';
         }
       }).catch(err => {
         console.error('获取二维码失败:', err);
         this.qrcodeUrl = '';
+        this.deadlineTime = '';
         this.$toast.fail('获取二维码失败');
       });
     },
@@ -241,7 +254,7 @@
           this.$toast.success('取消成功');
           this.showCancelDialog = false;
         } else {
-          this.$toast.fail(res.msg || '取消失败');
+          this.$toast.fail(res.msg || '二维码已取消不能重复取消');
         }
         this.loadQrCode();
       }).catch(err => {

+ 6 - 6
fhKeeper/formulahousekeeper/timesheet-workshop/src/views/settings/factorySetting.vue

@@ -8,9 +8,9 @@
     </el-col>
 
     <div style="padding: 20px;">
-      <div style="margin-bottom: 20px;">
-        <el-button type="primary" @click="handleAdd">新增厂区</el-button>
-      </div>
+<!--      <div style="margin-bottom: 20px;">-->
+<!--        <el-button type="primary" @click="handleAdd">新增厂区</el-button>-->
+<!--      </div>-->
 
       <el-table :data="tableData" border style="width: 100%;">
         <el-table-column  type="index" label="序号" width="80" align="center"></el-table-column>
@@ -24,8 +24,8 @@
         </el-table-column>
         <el-table-column label="操作" width="250" align="center">
           <template slot-scope="scope">
-            <el-button size="mini" @click="handleEdit(scope.row)">修改</el-button>
-            <el-button size="mini" type="danger" @click="handleDelete(scope.row)">删除</el-button>
+<!--            <el-button size="mini" @click="handleEdit(scope.row)">修改</el-button>-->
+<!--            <el-button size="mini" type="danger" @click="handleDelete(scope.row)">删除</el-button>-->
             <el-button
                 size="mini"
                 :type="scope.row.isActive === 1 ? 'warning' : 'success'"
@@ -88,7 +88,7 @@
   methods: {
     // 获取数据
     fetchData() {
-      this.http.post('/factory/getFactories', {},
+      this.http.post('/factory/getFactoriesList', {},
           res => {
             if (res.code == "ok") {
               this.tableData = res.data;

+ 1 - 1
fhKeeper/formulahousekeeper/timesheet-workshop/src/views/settings/mealTypeSetting.vue

@@ -101,7 +101,7 @@
   methods: {
     // 获取数据
     fetchData() {
-      this.http.post('/meal-types/getMeals', {},
+      this.http.post('/meal-types/getMealsList', {},
         res => {
           if (res.code == "ok") {
             this.tableData = res.data;