libushang 1 рік тому
батько
коміт
5b600daf5c
5 змінених файлів з 81 додано та 27 видалено
  1. 2 2
      .env.development
  2. 3 0
      .env.production
  3. 18 1
      src/api/event.ts
  4. 4 2
      src/router/routes.ts
  5. 54 22
      src/views/signPage/index.vue

+ 2 - 2
.env.development

@@ -6,9 +6,9 @@ VITE_APP_ENV = 'development'
 
 # 开发环境
 # baseUrl
-VITE_BASE_API = 'http://19.155.220.206:80'
+# VITE_BASE_API = 'http://19.155.220.206:80'
 VITE_BASE_DOWNLOAD_API = '/api/file/download/'
-# VITE_BASE_API = 'http://127.0.0.1:9988'
+VITE_BASE_API = 'http://127.0.0.1:9988'
 
 # 开发环境启用 cdn eruda 调试工具。若不启用,将 true 修改为 false 或其他任意值即可
 VITE_ENABLE_ERUDA = "false"

+ 3 - 0
.env.production

@@ -1,3 +1,6 @@
+# 页面标题
+VITE_APP_TITLE = 应急工作台移动端
+
 # baseUrl
 # VITE_BASE_API = "http://19.155.220.206:8088"
 VITE_BASE_API = "/"

+ 18 - 1
src/api/event.ts

@@ -33,4 +33,21 @@ export function closeEvent(data) {
         method: 'post',
         data: data
     });
-}
+}
+
+// 签到/签退
+export function getSignInfo(data) {
+    return request({
+        url: '/api/event_management/checkin/getInfo',
+        method: 'post',
+        data: data
+    });
+}
+
+export function signEvent(data) {
+    return request({
+        url: '/api/event_management/checkin/check',
+        method: 'post',
+        data: data
+    });
+} 

+ 4 - 2
src/router/routes.ts

@@ -1,12 +1,14 @@
 import Layout from "@/layout/index.vue";
 import type { RouteRecordRaw } from "vue-router";
-import Index from "@/views/index.vue";
 
 const routes: Array<RouteRecordRaw> = [
   {
     path: "/",
     name: "index",
-    component: Index
+    component: () => import("@/views/index.vue"),
+    meta: {
+      title: import.meta.env.VITE_APP_TITLE
+    }
   },
   {
     path: "/yzy/callback",

+ 54 - 22
src/views/signPage/index.vue

@@ -3,7 +3,7 @@
     <van-form @submit="onSubmit">
       <van-cell-group inset>
         <van-field
-            v-model="form.name"
+            v-model="form.user_name"
             name="姓名"
             label="姓名"
             placeholder="姓名"
@@ -19,7 +19,7 @@
             :rules="[{ required: true, message: '请填写职务' }]"
         />
         <van-field
-            v-model="form.unit"
+            v-model="form.dept_name"
             name="单位"
             label="单位"
             placeholder="单位"
@@ -37,13 +37,22 @@
                 { validator: validatePhone, message: '请输入正确的联系方式' }
             ]"
         />
+
+        <van-field
+            v-show="type === '2'"
+            readonly
+            v-model="form.sign_time"
+            name="签到时间"
+            label="签到时间"
+        />
       </van-cell-group>
       <div style="margin: 16px;">
-        <van-button round block type="primary" native-type="submit">
-          {{ type === '1' ? '确定签到' : '确定签退' }}
+        <van-button :loading="loading" :disabled="disabled" loading-text="签到中..." block type="primary" native-type="submit" v-show="type === '1'">
+          确定签到
         </van-button>
-        <van-button round block type="default" style="margin-top: 20px" @click="handleCancel">
-          {{ type === '1' ? '取消签到' : '取消签退' }}
+
+        <van-button :loading="loading" :disabled="disabled" loading-text="签退中..." block type="danger" native-type="submit" v-show="type === '2'">
+          确定签退
         </van-button>
       </div>
     </van-form>
@@ -54,41 +63,64 @@
 import {onMounted, ref} from "vue";
 import {validatePhone} from "@/utils/validate";
 import {showSuccessToast} from "vant";
+import { getSignInfo, signEvent } from '@/api/event';
+import { useRoute } from 'vue-router';
+
+const route = useRoute();
+const loading = ref(false);
+const disabled = ref(false);
+
+const event_id = route.query.event_id as string;
 
 // 1 签到 2 签退
 const type = ref('1');
 const form = ref({
-  name: '',
+  user_id: '',
+  user_name: '',
+  dept_id: '',
+  dept_name: '',
   duties: '',
-  unit: '',
+  sign_time: '',
   phone: ''
 })
 
 // 提交
 const onSubmit = () => {
   const submitMethod = type.value === '1' ? '1' : '2';
-  showSuccessToast(type.value === '1' ? '签到成功' : '签退成功');
-}
-// 取消
-const handleCancel = () => {
-  const cancelMethod = type.value === '1' ? '1' : '2';
-  showSuccessToast(type.value === '1' ? '取消签到成功' : '取消签退成功');
+  const data = {
+    ...form.value,
+    event_id: event_id,
+    type: submitMethod
+  };
+  loading.value = true;
+  signEvent(data).then((res)=>{
+    showSuccessToast(res.msg);
+    loading.value = false;
+    disabled.value = true;
+  })
 }
+
 onMounted(() => {
-  type.value = '1';
-  if (type.value === '2') {
+  getSignInfo({event_id: event_id}).then((res)=> {
+    const user = res.data;
+    console.log('user', user);
+    type.value = user.sign_time == '' ? '1' : '2';
+
     form.value = {
-      name: '张胜',
-      duties: 'xxx',
-      unit: 'xxx',
-      phone: '18782728732'
+      user_id: user.user_id,
+      user_name: user.nick_name,
+      dept_id: user.dept_id,
+      dept_name: user.dept_name,
+      duties: user.duties,
+      sign_time: user.sign_time,
+      phone: user.phone
     }
-  }
+  })
 })
 </script>
 
 <style lang="scss" scoped>
 .container {
-  //padding-top: 25px;
+  padding-top: 10px;
 }
 </style>