|
@@ -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>
|