Browse Source

✨ feat: 适配工程学院乐跑

Pchen. 5 months ago
parent
commit
deec47cced
2 changed files with 50 additions and 130 deletions
  1. 23 55
      src/pages/admin/lepaoAccount/accountList.vue
  2. 27 75
      src/pages/lepao/accountList/index.vue

+ 23 - 55
src/pages/admin/lepaoAccount/accountList.vue

@@ -98,18 +98,13 @@
                     </a-avatar>
                     {{ record.name }}
                 </template>
-                <template #sex="{ record }">
-                    <icon-man v-if="record.sex === 1" />
-                    <icon-woman v-else-if="record.sex === 2" />
-                    {{ record.sex === 1 ? '男' : (record.sex === 2 ? '女' : '') }}
-                </template>
+
                 <template #auto_run="{ record }">
-                    <a-tag color="green" v-if="record.auto_run">{{ record.target_count === 0 ? '开启-不限' :
-                        `开启-${record.target_count}次` }}</a-tag>
+                    <a-tag color="green" v-if="record.auto_run">开启</a-tag>
                     <a-tag color="red" v-else>关闭</a-tag>
                 </template>
                 <template #num="{ record }">
-                    {{ record.term_num != record.total_num ? `${record.total_num} / ${record.term_num}` :
+                    {{ record.target_count != record.total_num ? `${record.total_num} / ${record.target_count}` :
                         '已完成' }}
                 </template>
                 <template #state="{ record }">
@@ -123,32 +118,19 @@
                         <div class="circle else"></div>状态异常
                     </div>
                 </template>
-                <template #face_state="{ record }">
-                    <div v-if="record.face_state === 0" class="state">
-                        <div class="circle zero"></div>未采集
-                    </div>
-                    <div v-else-if="record.face_state === 1" class="state">
-                        <div class="circle one"></div>已通过
-                    </div>
-                    <div v-else class="state">
-                        <div class="circle else"></div>不通过
-                    </div>
-                </template>
+
                 <template #auto_time="{ record }">
                     {{ autoTimeLabel(record) }}
                 </template>
                 <template #create_time="{ record }">
                     {{ stramptoTime(record.create_time) }}
                 </template>
-                <template #update_time="{ record }">
-                    {{ record.update_time ? stramptoTime(record.update_time) : '待登录' }}
-                </template>
+
                 <template #optional="{ record }">
                     <a-dropdown :popup-max-height="false" trigger="hover">
                         <a-button>操作 <icon-down /></a-button>
                         <template #content>
                             <a-doption @click="editAccount(record)"><icon-edit /> 编辑账号</a-doption>
-                            <a-doption @click="faceRecoRef.openModal(record)"><icon-video-camera /> 人脸采集</a-doption>
                             <a-doption @click="SingleRun(record)"><icon-play-circle /> 开始单次乐跑</a-doption>
                             <a-doption @click="ChangeAutoRun(record)"><icon-translate /> {{ record.auto_run ? '关闭' :
                                 '开启' }}自动乐跑</a-doption>
@@ -165,14 +147,16 @@
         :ok-loading="ok_loading" esc-to-close closable>
         <a-form :model="form">
             <a-form-item field="student_num" label="学号">
-                <a-input v-model="form.student_num" placeholder="账号所有者学号,填写错误将无法登录" />
+                <a-input v-model="form.student_num" placeholder="账号所有者学号" allow-clear />
+            </a-form-item>
+            <a-form-item field="password" label="密码" v-if="!form.id">
+                <a-input-password v-model="form.password" placeholder="乐跑账号密码,填写错误将无法添加账号" allow-clear />
             </a-form-item>
             <a-form-item field="email" label="通知邮箱">
-                <a-input v-model="form.email" placeholder="用于接收乐跑失败、登录失效的通知" />
+                <a-input v-model="form.email" placeholder="用于接收乐跑失败、登录失效的通知" allow-clear />
             </a-form-item>
             <a-form-item field="area" label="乐跑跑区">
-                <a-select v-model="form.area" placeholder="请选择乐跑跑区" default-value="">
-                    <a-option value="">随机分配</a-option>
+                <a-select v-model="form.area" placeholder="请选择乐跑跑区" default-value="重庆工程学院南泉校区">
                     <a-option v-for="(item, index) in area" :key="index" :value="item">
                         <span class="vipcontent">
                             <span>{{ item }} </span>
@@ -186,7 +170,7 @@
             <a-form-item field="target_count" label="乐跑目标次数" v-if="form.auto_run">
                 <a-input-number v-model="form.target_count" placeholder="请输入乐跑目标次数" mode="button" />
                 <template #extra>
-                    <div>当学期有效次数达到目标次数时自动乐跑将关闭,0为不限次</div>
+                    <div>当有效次数达到目标次数时自动乐跑将关闭,0为不限次</div>
                 </template>
             </a-form-item>
             <a-form-item field="auto_time" label="自动乐跑时段" v-if="form.auto_run">
@@ -206,9 +190,7 @@
 import { ref, reactive, onMounted, h } from 'vue'
 import { addAccount, adminAccountList, deleteAccount, changeAutoRun, singleRun } from '@/api/lepao'
 import { Modal, Notification, Message } from '@arco-design/web-vue'
-import faceModal from '@/components/FaceModal/faceModal.vue'
 
-const faceRecoRef = ref(null)
 const queryData = reactive({
     area: '',
     student_num: '',
@@ -230,6 +212,7 @@ const ok_loading = ref(false)
 const form = reactive({
     id: null,
     student_num: '',
+    password: '',
     email: '',
     distance: [2.00, 4.00],
     area: '',
@@ -256,23 +239,15 @@ const columns = [
     }, {
         title: '创建用户',
         slotName: 'create_user',
-        width: 180
+        width: 170
     }, {
         title: '账号名称',
         slotName: 'name',
-        width: 180
+        width: 150
     }, {
         title: '学号',
         dataIndex: 'student_num',
         width: 115
-    }, {
-        title: '性别',
-        slotName: 'sex',
-        width: 80
-    }, {
-        title: '学院',
-        dataIndex: 'academy_name',
-        width: 200
     }, {
         title: '年级',
         dataIndex: 'grade_id',
@@ -285,7 +260,7 @@ const columns = [
     {
         title: '乐跑跑区',
         dataIndex: 'area',
-        width: 150
+        width: 180
     }, {
         title: '自动乐跑',
         slotName: 'auto_run',
@@ -297,23 +272,15 @@ const columns = [
     }, {
         title: '学期目标',
         slotName: 'num',
-        width: 90
+        width: 110
     }, {
         title: '帐号状态',
         slotName: 'state',
         width: 100
-    }, {
-        title: '人脸状态',
-        slotName: 'face_state',
-        width: 100
     }, {
         title: '添加时间',
         slotName: 'create_time',
         width: 150
-    }, {
-        title: '上次更新时间',
-        slotName: 'update_time',
-        width: 150
     }, {
         title: '备注',
         dataIndex: 'notes',
@@ -372,6 +339,7 @@ const editAccount = (item) => {
     if (item) {
         form.id = item.id
         form.student_num = item.student_num
+        form.password = ''
         form.email = item.email
         form.area = item.area
         form.auto_run = item.auto_run
@@ -381,9 +349,10 @@ const editAccount = (item) => {
     } else {
         form.id = null
         form.student_num = ''
+        form.password = ''
         form.auto_run = 1
         form.auto_time = 7
-        form.target_count = 30
+        form.target_count = 45
         form.email = email.value
         form.notes = ''
     }
@@ -393,13 +362,13 @@ const editAccount = (item) => {
 const handleBeforeOk = async (done) => {
     try {
         ok_loading.value = true
-        const { student_num, email } = form
+        const { student_num, email, password } = form
         if (!student_num || !email) {
             Message.error('请填写完整的账号信息')
             return false
         }
 
-        const studentNumRegex = /^\d{10}$/
+        const studentNumRegex = /^\d{9}$/
         if (!studentNumRegex.test(student_num)) {
             Message.error('请检查学号格式是否正确')
             return false
@@ -413,8 +382,7 @@ const handleBeforeOk = async (done) => {
 
         let data = {
             ...form,
-            min_distance: form.distance[0],
-            max_distance: form.distance[1]
+            password: btoa(password)
         }
 
         const res = await addAccount(data)

+ 27 - 75
src/pages/lepao/accountList/index.vue

@@ -12,20 +12,6 @@
           </template>
           添加账号
         </a-button>
-
-        <a-button size="large" @click="download" style="margin-left: 10px;">
-          <template #icon>
-            <icon-question-circle />
-          </template>
-          操作说明
-        </a-button>
-
-        <a-button size="large" @click="$router.push('/download/down')" style="margin-left: 10px;" v-if="!isElectron()">
-          <template #icon>
-            <icon-download />
-          </template>
-          客户端/登录器下载
-        </a-button>
       </div>
 
       <a-row class="queryForm">
@@ -120,7 +106,7 @@
         </template>
 
         <template #columns>
-          <a-table-column title="" :width="50" data-index="user_avatar" tooltip>
+          <a-table-column title="" :width="45" data-index="user_avatar" tooltip>
             <template #cell="{ record }">
               <a-avatar>
                 <img :alt="record.name ?? ''"
@@ -128,13 +114,13 @@
               </a-avatar>
             </template>
           </a-table-column>
-          <a-table-column title="学号" :width="115" data-index="student_num" ellipsis tooltip></a-table-column>
-          <a-table-column title="姓名" :width="130">
+          <a-table-column title="学号" :width="100" data-index="student_num" ellipsis tooltip></a-table-column>
+          <a-table-column title="姓名" :width="100">
             <template #cell="{ record }">
               {{ record.name ?? '请使用乐跑登录器更新账号信息' }}
             </template>
           </a-table-column>
-          <a-table-column title="性别" :width="80" ellipsis tooltip :filterable="{
+          <!-- <a-table-column title="性别" :width="80" ellipsis tooltip :filterable="{
             filters: [
               { text: '男', value: 1 },
               { text: '女', value: 2 }
@@ -146,10 +132,9 @@
               <icon-woman v-else-if="record.sex === 2" />
               {{ record.sex === 1 ? '男' : (record.sex === 2 ? '女' : '') }}
             </template>
-          </a-table-column>
-          <a-table-column title="年级" :width="70" data-index="grade_id" tooltip></a-table-column>
-          <a-table-column title="学院" :width="220" data-index="academy_name" tooltip></a-table-column>
-          <a-table-column title="跑区" :width="130">
+          </a-table-column> -->
+          <a-table-column title="年级" :width="80" data-index="grade_id" tooltip></a-table-column>
+          <a-table-column title="跑区" :width="170">
             <template #cell="{ record }">
               {{ record.area || '随机分配' }}
             </template>
@@ -168,19 +153,6 @@
               </div>
             </template>
           </a-table-column>
-          <!-- <a-table-column title="人脸状态" :width="100" ellipsis tooltip>
-            <template #cell="{ record }">
-              <div v-if="record.face_state === 0" class="state">
-                <div class="circle zero"></div>未采集
-              </div>
-              <div v-else-if="record.face_state === 1" class="state">
-                <div class="circle one"></div>已通过
-              </div>
-              <div v-else class="state">
-                <div class="circle else"></div>不通过
-              </div>
-            </template>
-          </a-table-column> -->
           <a-table-column title="自动乐跑" :width="105" ellipsis tooltip :filterable="{
             filters: [
               { text: '开启', value: 1 },
@@ -189,8 +161,7 @@
             filter: (value, record) => record.auto_run == value
           }">
             <template #cell="{ record }">
-              <a-tag color="green" v-if="record.auto_run">{{ record.target_count === 0 ? '开启-不限' :
-                `开启-${record.target_count}次` }}</a-tag>
+              <a-tag color="green" v-if="record.auto_run">开启</a-tag>
               <a-tag color="red" v-else>关闭</a-tag>
             </template>
           </a-table-column>
@@ -199,11 +170,10 @@
               {{ autoTimeLabel(record) }}
             </template>
           </a-table-column>
-          <a-table-column title="学期目标" :width="88" ellipsis tooltip>
+          <a-table-column title="乐跑次数" :width="88" ellipsis tooltip>
             <template #cell="{ record }">
-              {{ record.term_num != record.total_num ? `${record.total_num} / ${record.term_num}` :
-                '已完成' }}
-            </template>
+              {{ record.target_count != record.total_num ? `${record.total_num} / ${(record.target_count === 0 ||
+                record.target_count < record.total_num) ? '∞' : record.target_count}` : '已完成' }} </template>
           </a-table-column>
           <a-table-column title="添加时间" :width="145" ellipsis tooltip :sortable="{
             sortDirections: ['ascend', 'descend']
@@ -212,11 +182,6 @@
               {{ stramptoTime(record.create_time) }}
             </template>
           </a-table-column>
-          <a-table-column title="上次登录时间" :width="145" ellipsis tooltip>
-            <template #cell="{ record }">
-              {{ record.update_time ? stramptoTime(record.update_time) : '待登录' }}
-            </template>
-          </a-table-column>
           <a-table-column title="备注" :width="200" ellipsis tooltip>
             <template #cell="{ record }">
               {{ record.notes }}
@@ -229,7 +194,6 @@
                 <a-button>操作 <icon-down /></a-button>
                 <template #content>
                   <a-doption @click="editAccount(record)"><icon-edit /> 编辑账号</a-doption>
-                  <!-- <a-doption @click="faceRecoRef.openModal(record)"><icon-video-camera /> 人脸采集</a-doption> -->
                   <a-doption @click="SingleRun(record)"><icon-play-circle /> 开始单次乐跑</a-doption>
                   <a-doption @click="ChangeAutoRun(record)"><icon-translate /> {{ record.auto_run ? '关闭' :
                     '开启' }}自动乐跑</a-doption>
@@ -248,19 +212,20 @@
     :ok-loading="ok_loading" esc-to-close closable>
     <a-form :model="form">
       <a-form-item field="student_num" label="学号">
-        <a-input v-model="form.student_num" placeholder="账号所有者学号,填写错误将无法登录" allow-clear />
+        <a-input v-model="form.student_num" placeholder="账号所有者学号" allow-clear />
+      </a-form-item>
+      <a-form-item field="password" label="密码" v-if="!form.id">
+        <a-input-password v-model="form.password" placeholder="乐跑账号密码,填写错误将无法添加账号" allow-clear />
       </a-form-item>
       <a-form-item field="email" label="通知邮箱">
         <a-auto-complete :data="email" @search="handleSearch" v-model="form.email" placeholder="用于接收乐跑失败、登录失效的通知"
           allow-clear />
       </a-form-item>
       <a-form-item field="area" label="乐跑跑区">
-        <a-select v-model="form.area" placeholder="请选择乐跑跑区" default-value="">
-          <a-option value="">随机分配</a-option>
+        <a-select v-model="form.area" placeholder="请选择乐跑跑区" default-value="重庆工程学院南泉校区">
           <a-option v-for="(item, index) in area" :key="index" :value="item">
             <span class="vipcontent">
               <span>{{ item }} </span>
-              <!-- <img src="@/assets/vip.svg" alt="vip" height="20"> -->
             </span>
           </a-option>
         </a-select>
@@ -271,7 +236,7 @@
       <a-form-item field="target_count" label="乐跑目标次数" v-if="form.auto_run">
         <a-input-number v-model="form.target_count" placeholder="请输入乐跑目标次数" mode="button" />
         <template #extra>
-          <div>当学期有效次数达到目标次数时自动乐跑将关闭,0为不限次</div>
+          <div>当有效次数达到目标次数时自动乐跑将关闭,0为不限次</div>
         </template>
       </a-form-item>
       <a-form-item field="auto_time" label="自动乐跑时段" v-if="form.auto_run">
@@ -284,7 +249,6 @@
     </a-form>
   </a-modal>
 
-  <faceModal :faceInfo="faceInfo" ref="faceRecoRef" />
 </template>
 
 <script setup>
@@ -293,16 +257,12 @@ import { accountList, deleteAccount, addAccount, changeAutoRun, singleRun } from
 import { Modal, Notification, Message } from '@arco-design/web-vue'
 import { IconSearch } from '@arco-design/web-vue/es/icon'
 import userCard from '@/components/userCard/userCard.vue'
-import { isElectron } from '@/utils/electron'
-import faceModal from '@/components/FaceModal/faceModal.vue'
 import { useRoute } from 'vue-router'
 import { getNotice } from '@/utils/util'
 
 const notice = ref('')
 
 const email = ref([])
-const faceInfo = ref({})
-const faceRecoRef = ref(null)
 
 const queryDataForm = reactive({
   area: '',
@@ -328,7 +288,7 @@ const pagination = reactive({
 })
 
 const handleSearch = (value) => {
-  const emailSuffix = ["qq.com", "ctbu.edu.cn", "163.com"]
+  const emailSuffix = ["qq.com", "163.com"]
   const input = (value || "").trim()
 
   if (!input) {
@@ -428,28 +388,20 @@ const ok_loading = ref(false)
 const form = reactive({
   id: null,
   student_num: '',
+  password: '',
   email: '',
   distance: [2.00, 4.00],
   area: '',
   auto_time: -1,
   auto_run: 1,
-  target_count: 30,
+  target_count: 0,
   notes: ''
 })
 
-const download = () => {
-  const a = document.createElement('a');
-  a.href = 'https:\/\/lepao-cloud.xxoo365.top\/down.php\/682d99f9694c6fe76b64b86c5741a2d8.pdf';
-  a.download = 'RunForge操作说明.pdf'
-  a.target = '_blank'
-  document.body.appendChild(a);
-  a.click();
-  document.body.removeChild(a);
-}
-
 const editAccount = (item) => {
   if (item) {
     form.id = item.id
+    form.password = ''
     form.student_num = item.student_num
     form.email = item.email
     form.area = item.area
@@ -459,12 +411,13 @@ const editAccount = (item) => {
     form.notes = item.notes
   } else {
     form.id = null
+    form.password = ''
     form.student_num = ''
     form.email = ''
     form.auto_run = 1
     form.auto_time = -1
-    form.target_count = 30
-    form.area = ''
+    form.target_count = 0
+    form.area = '重庆工程学院南泉校区'
     form.notes = ''
   }
   visible.value = true
@@ -473,13 +426,13 @@ const editAccount = (item) => {
 const handleBeforeOk = async (done) => {
   try {
     ok_loading.value = true
-    const { student_num, email } = form
+    const { student_num, email, password } = form
     if (!student_num || !email) {
       Message.error('请填写完整的账号信息')
       return false
     }
 
-    const studentNumRegex = /^\d{10}$/
+    const studentNumRegex = /^\d{9}$/
     if (!studentNumRegex.test(student_num)) {
       Message.error('请检查学号格式是否正确')
       return false
@@ -493,8 +446,7 @@ const handleBeforeOk = async (done) => {
 
     let data = {
       ...form,
-      min_distance: form.distance[0],
-      max_distance: form.distance[1]
+      password: btoa(password)
     }
 
     const res = await addAccount(data)