StudentInspection.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. <template>
  2. <window-size :showBackNav="false">
  3. <div style="display: flex">
  4. <div>
  5. <van-image width="120" height="60" :src="logo"></van-image>
  6. </div>
  7. <div class="logo">学生体检信息录入</div>
  8. </div>
  9. <van-field v-model="student.name" required type="text" label="姓名" placeholder="请输入您的姓名" />
  10. <van-field v-model="student.idcard" required type="tel" label="身份证号" placeholder="请输入您的身份证号" />
  11. <van-field v-model="student.phone" required type="tel" label="电话" placeholder="请输入您的联系电话" />
  12. <van-field v-model="student.school" required type="text" label="学校" placeholder="请输入您在读的学校" />
  13. <van-field v-model="student.tclass" required type="text" label="班级" placeholder="请输入您所在的班级" />
  14. <van-field
  15. v-model="student.orderName"
  16. required
  17. label="套餐类型"
  18. readonly
  19. @click="showPickOrder = true"
  20. placeholder="请选择套餐类型"
  21. ></van-field>
  22. <van-popup v-model:show="showPickOrder" position="bottom" :style="{ height: '50%' }">
  23. <van-picker
  24. title="套餐类型"
  25. :columns="orderTypes"
  26. :columns-field-names="customFieldName"
  27. @cancel="showPickOrder = false"
  28. @confirm="confirmPickOrder"
  29. >
  30. <template #option="item"> {{ item.name }}(单价:¥{{ item.price }}) </template>
  31. </van-picker>
  32. </van-popup>
  33. <van-cell title="查看收款码" label="付款完成后点击下方保存按钮" center is-link @click="beforeShowQrcode"></van-cell>
  34. <div style="height: 8px"></div>
  35. <van-button type="primary" icon="certificate" block @click="saveTjInfo">保存</van-button>
  36. <van-dialog
  37. v-model:show="showQrcode"
  38. :show-cancel-button="false"
  39. :show-confirm-button="false"
  40. :close-on-click-overlay="true"
  41. >
  42. <van-image fit="contain" :src="wxPay" />
  43. </van-dialog>
  44. </window-size>
  45. </template>
  46. <script>
  47. import logo from '../../assets/thyylogo.png'
  48. import { reactive, ref } from 'vue'
  49. import wxPay from '../../assets/isolations/wxpay-xh.png'
  50. import { isValidIdcard, isValidPhone } from '../../utils/validate'
  51. import { saveStudentInspection } from '../../api/isolations'
  52. import { showToast } from 'vant'
  53. export default {
  54. setup() {
  55. const student = reactive({})
  56. const showPickOrder = ref(false)
  57. const orderTypes = [
  58. { code: 'XSTJ', name: '学生体检', price: 55, value: 'XSTJ' },
  59. { code: 'PDD', name: 'PDD', price: 25, value: 'PDD' },
  60. ]
  61. const customFieldName = {
  62. code: 'code',
  63. text: 'name',
  64. }
  65. const confirmPickOrder = (val) => {
  66. student.orderCode = val.selectedOptions[0].code
  67. student.orderName = val.selectedOptions[0].name
  68. student.orderPrice = val.selectedOptions[0].price
  69. showPickOrder.value = false
  70. }
  71. const showQrcode = ref(false)
  72. const validate = () => {
  73. if (!student.name) {
  74. return '请输入您的姓名'
  75. }
  76. if (!isValidIdcard(student.idcard)) {
  77. return '请输入正确的身份证号码'
  78. }
  79. if (!isValidPhone(student.phone)) {
  80. return '请输入正确的电话号码'
  81. }
  82. if (!student.school) {
  83. return '请输入您在读学校的名称'
  84. }
  85. if (!student.tclass) {
  86. return '请输入您所在的班级'
  87. }
  88. if (!student.orderCode) {
  89. return '请选择套餐类型'
  90. }
  91. return null
  92. }
  93. const beforeShowQrcode = () => {
  94. const message = validate()
  95. if (message) {
  96. showToast({
  97. message,
  98. position: 'top',
  99. })
  100. } else {
  101. showQrcode.value = true
  102. }
  103. }
  104. const saveTjInfo = () => {
  105. const message = validate()
  106. if (message) {
  107. showToast({
  108. message,
  109. position: 'top',
  110. })
  111. } else {
  112. saveStudentInspection(student).then((res) => {
  113. showToast({
  114. message: res,
  115. position: 'top'
  116. })
  117. })
  118. }
  119. }
  120. return {
  121. logo,
  122. student,
  123. showPickOrder,
  124. orderTypes,
  125. customFieldName,
  126. confirmPickOrder,
  127. wxPay,
  128. showQrcode,
  129. beforeShowQrcode,
  130. saveTjInfo,
  131. }
  132. },
  133. }
  134. </script>
  135. <style scoped>
  136. .logo {
  137. color: #00525e;
  138. height: 60px;
  139. line-height: 60px;
  140. font-weight: bold;
  141. font-size: 18px;
  142. }
  143. </style>