Selaa lähdekoodia

fix: 交接班——无当班时返回Fail错误码以便前端正确显示接班表单

lq 1 kuukausi sitten
vanhempi
commit
a398dd02cf
2 muutettua tiedostoa jossa 5 lisäystä ja 3 poistoa
  1. 4 2
      frontend/src/view/parking/shiftRecord.vue
  2. 1 1
      internal/modules/shift/api.go

+ 4 - 2
frontend/src/view/parking/shiftRecord.vue

@@ -49,8 +49,10 @@ const startForm = reactive({ starting_cash: 0 })
 const endForm = reactive({ actual_cash: 0 })
 
 async function fetch() {
-  const r = await getCurrentShift()
-  current.value = r.code === 0 ? r.data : null
+  try {
+    const r = await getCurrentShift()
+    current.value = r.code === 0 ? r.data : null
+  } catch (e) { current.value = null }
   const l = await getShiftList({ page: 1, page_size: 20 })
   if (l.code === 0) { list.value = l.data.list || []; list.value.forEach(s => s.collected_cash = s.collected_cash || 0) }
 }

+ 1 - 1
internal/modules/shift/api.go

@@ -50,7 +50,7 @@ func EndShift(c *gin.Context) {
 func GetCurrentShift(c *gin.Context) {
 	rec, err := shiftSvc.GetCurrent(utils.GetUserID(c))
 	if err != nil {
-		response.OkWithData(gin.H{"has_active": false}, c)
+		response.FailWithMessage("无当班", c)
 		return
 	}
 	response.OkWithData(rec, c)