Browse Source

✨ feat: 引入乐跑星期设置功能

Pchen. 4 months ago
parent
commit
976e5122ab
2 changed files with 36 additions and 4 deletions
  1. 16 1
      src/pages/admin/lepaoAccount/accountList.vue
  2. 20 3
      src/pages/lepao/accountList/index.vue

+ 16 - 1
src/pages/admin/lepaoAccount/accountList.vue

@@ -177,6 +177,9 @@
                     <div>当有效次数达到目标次数时自动乐跑将关闭,0为不限次</div>
                 </template>
             </a-form-item>
+            <a-form-item field="auto_day" label="自动乐跑星期" v-if="form.auto_run">
+                <a-checkbox-group v-model="form.auto_day" placeholder="请选择每天自动乐跑的星期" :options="auto_day" />
+            </a-form-item>
             <a-form-item field="auto_time" label="自动乐跑时段" v-if="form.auto_run">
                 <a-select v-model="form.auto_time" placeholder="请选择每天自动乐跑的时段" :options="auto_time" />
             </a-form-item>
@@ -218,17 +221,27 @@ const form = reactive({
     student_num: '',
     password: '',
     email: '',
-    distance: [2.00, 4.00],
     area: '',
     auto_run: 1,
     auto_time: -1,
     target_count: 30,
+    auto_day: [0, 1, 2, 3, 4, 5, 6],
     notes: ''
 })
 
 const loading = ref(false)
 const data = ref([])
 
+const auto_day = [
+    { label: '周一', value: 1 },
+    { label: '周二', value: 2 },
+    { label: '周三', value: 3 },
+    { label: '周四', value: 4 },
+    { label: '周五', value: 5 },
+    { label: '周六', value: 6 },
+    { label: '周日', value: 0 }
+]
+
 const state = [
     { label: '全部', value: -1 }, { label: '需登录', value: 0 }, { label: '正常', value: 1 }, { label: '状态异常', value: 2 }
 ]
@@ -352,6 +365,7 @@ const editAccount = (item) => {
         form.area = item.area
         form.auto_run = item.auto_run
         form.auto_time = item.auto_time
+        form.auto_day = item.auto_day
         form.target_count = item.target_count
         form.notes = item.notes
     } else {
@@ -361,6 +375,7 @@ const editAccount = (item) => {
         form.auto_run = 1
         form.auto_time = 7
         form.target_count = 45
+        form.auto_day = [0, 1, 2, 3, 4, 5, 6]
         form.email = email.value
         form.notes = ''
     }

+ 20 - 3
src/pages/lepao/accountList/index.vue

@@ -239,6 +239,9 @@
           <div>当有效次数达到目标次数时自动乐跑将关闭,0为不限次</div>
         </template>
       </a-form-item>
+      <a-form-item field="auto_day" label="自动乐跑星期" v-if="form.auto_run">
+        <a-checkbox-group v-model="form.auto_day" placeholder="请选择每天自动乐跑的星期" :options="auto_day" />
+      </a-form-item>
       <a-form-item field="auto_time" label="自动乐跑时段" v-if="form.auto_run">
         <a-select v-model="form.auto_time" placeholder="请选择每天自动乐跑的时段" :options="auto_time" />
       </a-form-item>
@@ -364,6 +367,16 @@ const handlePageSizeChange = (size) => {
   getAccountsAsync()
 }
 
+const auto_day = [
+  { label: '周一', value: 1 },
+  { label: '周二', value: 2 },
+  { label: '周三', value: 3 },
+  { label: '周四', value: 4 },
+  { label: '周五', value: 5 },
+  { label: '周六', value: 6 },
+  { label: '周日', value: 0 }
+]
+
 const auto_time = [
   { label: '随机分配', value: -1 },
   ...Array.from({ length: 15 }, (_, i) => {
@@ -373,8 +386,10 @@ const auto_time = [
 ]
 
 const autoTimeLabel = (record) => {
-  if (record.auto_time === -1 && record.today_auto_time) {
-    return `随机-今日${record.today_auto_time}时`
+  if (record.auto_time === -1) {
+    if (record.today_auto_time)
+      return `随机-今日${record.today_auto_time}时`
+    return '随机-待分配'
   }
   const match = auto_time.find(item => item.value === record.auto_time)
   return match ? match.label : '-'
@@ -390,11 +405,11 @@ const form = reactive({
   student_num: '',
   password: '',
   email: '',
-  distance: [2.00, 4.00],
   area: '',
   auto_time: -1,
   auto_run: 1,
   target_count: 0,
+  auto_day: [0, 1, 2, 3, 4, 5, 6],
   notes: ''
 })
 
@@ -408,6 +423,7 @@ const editAccount = (item) => {
     form.auto_time = item.auto_time
     form.auto_run = item.auto_run
     form.target_count = item.target_count
+    form.auto_day = item.auto_day
     form.notes = item.notes
   } else {
     form.id = null
@@ -418,6 +434,7 @@ const editAccount = (item) => {
     form.auto_time = -1
     form.target_count = 0
     form.area = '重庆工程学院南泉校区'
+    form.auto_day = [0, 1, 2, 3, 4, 5, 6]
     form.notes = ''
   }
   visible.value = true