Browse Source

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

Pchen. 4 months ago
parent
commit
b5c13f12e2
2 changed files with 38 additions and 10 deletions
  1. 17 4
      src/pages/admin/lepaoAccount/accountList.vue
  2. 21 6
      src/pages/lepao/accountList/index.vue

+ 17 - 4
src/pages/admin/lepaoAccount/accountList.vue

@@ -189,6 +189,9 @@
                     <div>当学期有效次数达到目标次数时自动乐跑将关闭,0为不限次</div>
                     <div>当学期有效次数达到目标次数时自动乐跑将关闭,0为不限次</div>
                 </template>
                 </template>
             </a-form-item>
             </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-form-item field="auto_time" label="自动乐跑时段" v-if="form.auto_run">
                 <a-select v-model="form.auto_time" placeholder="请选择每天自动乐跑的时段" :options="auto_time" />
                 <a-select v-model="form.auto_time" placeholder="请选择每天自动乐跑的时段" :options="auto_time" />
             </a-form-item>
             </a-form-item>
@@ -231,17 +234,27 @@ const form = reactive({
     id: null,
     id: null,
     student_num: '',
     student_num: '',
     email: '',
     email: '',
-    distance: [2.00, 4.00],
     area: '',
     area: '',
     auto_run: 1,
     auto_run: 1,
     auto_time: -1,
     auto_time: -1,
     target_count: 30,
     target_count: 30,
+    auto_day: [0, 1, 2, 3, 4, 5, 6],
     notes: ''
     notes: ''
 })
 })
 
 
 const loading = ref(false)
 const loading = ref(false)
 const data = ref([])
 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 = [
 const state = [
     { label: '全部', value: -1 }, { label: '需登录', value: 0 }, { label: '正常', value: 1 }, { label: '状态异常', value: 2 }
     { label: '全部', value: -1 }, { label: '需登录', value: 0 }, { label: '正常', value: 1 }, { label: '状态异常', value: 2 }
 ]
 ]
@@ -376,6 +389,7 @@ const editAccount = (item) => {
         form.area = item.area
         form.area = item.area
         form.auto_run = item.auto_run
         form.auto_run = item.auto_run
         form.auto_time = item.auto_time
         form.auto_time = item.auto_time
+        form.auto_day = item.auto_day
         form.target_count = item.target_count
         form.target_count = item.target_count
         form.notes = item.notes
         form.notes = item.notes
     } else {
     } else {
@@ -384,6 +398,7 @@ const editAccount = (item) => {
         form.auto_run = 1
         form.auto_run = 1
         form.auto_time = 7
         form.auto_time = 7
         form.target_count = 30
         form.target_count = 30
+        form.auto_day = [0, 1, 2, 3, 4, 5, 6]
         form.email = email.value
         form.email = email.value
         form.notes = ''
         form.notes = ''
     }
     }
@@ -412,9 +427,7 @@ const handleBeforeOk = async (done) => {
         }
         }
 
 
         let data = {
         let data = {
-            ...form,
-            min_distance: form.distance[0],
-            max_distance: form.distance[1]
+            ...form
         }
         }
 
 
         const res = await addAccount(data)
         const res = await addAccount(data)

+ 21 - 6
src/pages/lepao/accountList/index.vue

@@ -274,6 +274,9 @@
           <div>当学期有效次数达到目标次数时自动乐跑将关闭,0为不限次</div>
           <div>当学期有效次数达到目标次数时自动乐跑将关闭,0为不限次</div>
         </template>
         </template>
       </a-form-item>
       </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-form-item field="auto_time" label="自动乐跑时段" v-if="form.auto_run">
         <a-select v-model="form.auto_time" placeholder="请选择每天自动乐跑的时段" :options="auto_time" />
         <a-select v-model="form.auto_time" placeholder="请选择每天自动乐跑的时段" :options="auto_time" />
       </a-form-item>
       </a-form-item>
@@ -404,6 +407,16 @@ const handlePageSizeChange = (size) => {
   getAccountsAsync()
   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 = [
 const auto_time = [
   { label: '随机分配', value: -1 },
   { label: '随机分配', value: -1 },
   ...Array.from({ length: 17 }, (_, i) => {
   ...Array.from({ length: 17 }, (_, i) => {
@@ -413,8 +426,10 @@ const auto_time = [
 ]
 ]
 
 
 const autoTimeLabel = (record) => {
 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)
   const match = auto_time.find(item => item.value === record.auto_time)
   return match ? match.label : '-'
   return match ? match.label : '-'
@@ -429,11 +444,11 @@ const form = reactive({
   id: null,
   id: null,
   student_num: '',
   student_num: '',
   email: '',
   email: '',
-  distance: [2.00, 4.00],
   area: '',
   area: '',
   auto_time: -1,
   auto_time: -1,
   auto_run: 1,
   auto_run: 1,
   target_count: 30,
   target_count: 30,
+  auto_day: [0, 1, 2, 3, 4, 5, 6],
   notes: ''
   notes: ''
 })
 })
 
 
@@ -456,6 +471,7 @@ const editAccount = (item) => {
     form.auto_time = item.auto_time
     form.auto_time = item.auto_time
     form.auto_run = item.auto_run
     form.auto_run = item.auto_run
     form.target_count = item.target_count
     form.target_count = item.target_count
+    form.auto_day = item.auto_day
     form.notes = item.notes
     form.notes = item.notes
   } else {
   } else {
     form.id = null
     form.id = null
@@ -464,6 +480,7 @@ const editAccount = (item) => {
     form.auto_run = 1
     form.auto_run = 1
     form.auto_time = -1
     form.auto_time = -1
     form.target_count = 30
     form.target_count = 30
+    form.auto_day = [0, 1, 2, 3, 4, 5, 6]
     form.area = ''
     form.area = ''
     form.notes = ''
     form.notes = ''
   }
   }
@@ -492,9 +509,7 @@ const handleBeforeOk = async (done) => {
     }
     }
 
 
     let data = {
     let data = {
-      ...form,
-      min_distance: form.distance[0],
-      max_distance: form.distance[1]
+      ...form
     }
     }
 
 
     const res = await addAccount(data)
     const res = await addAccount(data)