ExcuteAppointment.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. <template>
  2. <window-size>
  3. <van-notice-bar left-icon="volume-o" text="可接种年龄为【18岁-59岁】之间。" />
  4. <van-field v-model="vaccinate.vaccinateName" required label="疫苗名称" readonly />
  5. <van-field
  6. v-model="vaccinate.vaccinateFactory"
  7. required
  8. type="text"
  9. label="疫苗厂家"
  10. readonly
  11. @click="showPickFactory = true"
  12. placeholder="选择疫苗厂家"
  13. ></van-field>
  14. <van-field v-model="vaccinate.name" required type="text" label="姓名" placeholder="请输入姓名" />
  15. <van-field v-model="vaccinate.phone" required type="tel" label="电话" placeholder="请输入手机号" />
  16. <van-field v-model="vaccinate.socialNo" required type="tel" label="身份证" placeholder="请输入身份证号" />
  17. <van-field v-model="vaccinate.corpName" required type="text" label="工作单位" placeholder="请输入工作单位" />
  18. <van-field
  19. v-model="jobCategoryName"
  20. required
  21. type="textarea"
  22. label="工作性质"
  23. readonly
  24. @click="showPickJobCategory = true"
  25. placeholder="选择工作性质"
  26. ></van-field>
  27. <van-field
  28. v-model="vaccinate.executeDate"
  29. required
  30. label="接种日期"
  31. readonly
  32. @click="showPickDatetime = true"
  33. placeholder="选择接种日期"
  34. ></van-field>
  35. <van-popup v-model:show="showPickFactory" position="bottom" :style="{ height: '50%' }">
  36. <van-picker
  37. title="疫苗厂家"
  38. :columns="vaccinateFactories"
  39. :columns-field-names="customFieldName"
  40. @confirm="confirmPickFactory"
  41. />
  42. </van-popup>
  43. <van-popup v-model:show="showPickJobCategory" position="bottom" :style="{ height: '50%' }">
  44. <van-picker
  45. title="工作性质"
  46. :columns="jobCategories"
  47. :columns-field-names="customFieldName"
  48. @confirm="confirmPickJobCategory"
  49. />
  50. </van-popup>
  51. <van-popup v-model:show="showPickDatetime" position="bottom" :style="{ height: '50%' }">
  52. <van-datetime-picker
  53. v-model="currentDate"
  54. type="date"
  55. title="选择接种日期"
  56. :min-date="minDate"
  57. :max-date="maxDate"
  58. :formatter="formatter"
  59. @confirm="confirmPickDatetime"
  60. />
  61. </van-popup>
  62. <div style="height: 10px"></div>
  63. <van-button block type="primary" @click="submit">提交预约</van-button>
  64. </window-size>
  65. </template>
  66. <script>
  67. import { onMounted, reactive, ref } from 'vue'
  68. import router from '../../../router'
  69. import { formatDate, getAWeekFromNow, getTomorrow } from '../../../utils/date'
  70. import {
  71. getPatientInfoAndJobCategories,
  72. getVaccinateFactories,
  73. submitVaccinateAppointment,
  74. } from '../../../api/covid-vaccinate'
  75. import { Dialog, Toast } from 'vant'
  76. import { isValidIdcard, isValidPhone } from '../../../utils/validate'
  77. export default {
  78. setup() {
  79. let patientId = router.currentRoute.value.params.patientId
  80. const vaccinateId = router.currentRoute.value.params.vaccinateId
  81. const vaccinateFactories = ref([])
  82. const showPickFactory = ref(false)
  83. const showPickDatetime = ref(false)
  84. const showPickJobCategory = ref(false)
  85. const currentDate = ref(new Date())
  86. const formatter = (type, val) => {
  87. if (type === 'year') {
  88. return val + '年'
  89. }
  90. if (type === 'month') {
  91. return val + '月'
  92. }
  93. if (type === 'day') {
  94. return val + '日'
  95. }
  96. return val
  97. }
  98. const confirmPickDatetime = (val) => {
  99. vaccinate.executeDate = formatDate(val)
  100. showPickDatetime.value = false
  101. }
  102. const jobCategoryName = ref('')
  103. const jobCategories = ref([])
  104. const customFieldName = {
  105. code: 'code',
  106. text: 'name',
  107. }
  108. const confirmPickFactory = (val) => {
  109. vaccinate.vaccinateCode = val.code
  110. vaccinate.vaccinateFactory = val.name
  111. showPickFactory.value = false
  112. }
  113. const confirmPickJobCategory = (val) => {
  114. vaccinate.jobCategory = val.code
  115. jobCategoryName.value = val.name
  116. showPickJobCategory.value = false
  117. }
  118. const vaccinate = reactive({
  119. vaccinateId,
  120. vaccinateCode: '',
  121. vaccinateName: '',
  122. vaccinateFactory: '',
  123. patientId: '',
  124. name: '',
  125. phone: '',
  126. socialNo: '',
  127. corpName: '',
  128. jobCategory: '',
  129. executeDate: '',
  130. })
  131. const submit = () => {
  132. if (!vaccinate.vaccinateCode || !vaccinate.vaccinateFactory) {
  133. Toast({
  134. message: '请选择疫苗厂家!',
  135. position: 'top',
  136. })
  137. return
  138. }
  139. if (!vaccinate.name) {
  140. Toast({
  141. message: '请输入姓名!',
  142. position: 'top',
  143. })
  144. return
  145. }
  146. if (!isValidPhone(vaccinate.phone)) {
  147. Toast({
  148. message: '请输入正确的手机号码',
  149. position: 'top',
  150. })
  151. return
  152. }
  153. if (!isValidIdcard(vaccinate.socialNo)) {
  154. Toast({
  155. message: '请输入正确的身份证号码',
  156. position: 'top',
  157. })
  158. return
  159. }
  160. if (!vaccinate.corpName) {
  161. Toast({
  162. message: '请输入工作单位,没有工作单位请填‘无’',
  163. position: 'top',
  164. duration: 3000,
  165. })
  166. return
  167. }
  168. if (!vaccinate.jobCategory) {
  169. Toast({
  170. message: '请选择工作性质,如不确定请选‘其他人员’,如无工作请选择‘家务及待业人员’',
  171. position: 'top',
  172. duration: 3000,
  173. })
  174. return
  175. }
  176. if (!vaccinate.executeDate) {
  177. Toast({
  178. message: '请选择接种日期',
  179. position: 'top',
  180. })
  181. return
  182. }
  183. submitVaccinateAppointment(vaccinate).then((res) => {
  184. Dialog.alert({
  185. title: '提示',
  186. message: res,
  187. }).then(() => {
  188. router.push('/hospitalService')
  189. })
  190. })
  191. }
  192. onMounted(() => {
  193. if (!patientId) {
  194. patientId = ''
  195. }
  196. getVaccinateFactories(vaccinateId).then((res) => {
  197. vaccinateFactories.value = res.factories
  198. vaccinate.vaccinateId = res.id
  199. vaccinate.vaccinateName = res.name
  200. if (res.factory) {
  201. vaccinate.vaccinateCode = res.factory.code
  202. vaccinate.vaccinateFactory = res.factory.name
  203. }
  204. })
  205. getPatientInfoAndJobCategories(patientId).then((res) => {
  206. vaccinate.patientId = res.patientId
  207. vaccinate.name = res.name
  208. vaccinate.phone = res.phone
  209. vaccinate.socialNo = res.socialNo
  210. jobCategories.value = res.jobCategories
  211. })
  212. })
  213. return {
  214. vaccinate,
  215. vaccinateFactories,
  216. showPickFactory,
  217. showPickDatetime,
  218. minDate: getTomorrow(),
  219. maxDate: getAWeekFromNow(),
  220. currentDate,
  221. formatter,
  222. confirmPickDatetime,
  223. showPickJobCategory,
  224. jobCategories,
  225. confirmPickFactory,
  226. confirmPickJobCategory,
  227. customFieldName,
  228. jobCategoryName,
  229. submit,
  230. }
  231. },
  232. }
  233. </script>