attended.vue 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <template>
  2. <view style="padding: 30rpx;">
  3. <uni-forms ref="formRef" :modelValue="formData" :rules="formRules" validateTrigger="bind" label-width="80px" label-align="right" label-position="left">
  4. <uni-forms-item name="reason" label="爽约原因" required>
  5. <uni-easyinput v-model="formData.reason" type="textarea" placeholder="请输入爽约原因"></uni-easyinput>
  6. </uni-forms-item>
  7. </uni-forms>
  8. <button class="send-button" @tap="handleSubmit">提 交</button>
  9. </view>
  10. </template>
  11. <script setup>
  12. import { ref, unref } from 'vue'
  13. import { onLoad } from '@dcloudio/uni-app'
  14. import { noAttendInterviewInvite } from '@/api/interview'
  15. const formRef = ref(null)
  16. const formData = ref({
  17. id: null,
  18. reason: null
  19. })
  20. const formRules = {
  21. reason: {
  22. rules: [{ required: true, errorMessage: '请输入爽约原因' }]
  23. }
  24. }
  25. onLoad(async (options) => {
  26. const { id } = options
  27. if (!id) {
  28. uni.showToast({
  29. title: 'ID缺失',
  30. icon: 'none'
  31. })
  32. setTimeout(() => {
  33. uni.navigateBack({ delta: 1 })
  34. }, 1000)
  35. return
  36. }
  37. formData.value.id = id
  38. })
  39. // 提交
  40. const handleSubmit = async () => {
  41. const valid = await unref(formRef).validate()
  42. if (!valid) return
  43. uni.showLoading({ title: '提交中' })
  44. try {
  45. await noAttendInterviewInvite(formData.value)
  46. uni.hideLoading()
  47. uni.showToast({
  48. title: '提交成功',
  49. icon: 'success'
  50. })
  51. setTimeout(() => {
  52. uni.navigateBack({ delta: 1 })
  53. }, 1000)
  54. } catch {
  55. uni.hideLoading()
  56. }
  57. }
  58. </script>
  59. <style scoped lang="scss">
  60. </style>