Covid19Assessment.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. <template>
  2. <back-nav></back-nav>
  3. <div style="height: 20px"></div>
  4. <div id="question-body">
  5. <van-field v-model="answer.name" type="text" label="姓名" disabled />
  6. <van-field v-model="answer.idcard" type="text" label="身份证" disabled />
  7. <van-field v-model="answer.phone" type="tel" label="电话" placeholder="请输入手机号" />
  8. <van-field
  9. readonly
  10. clickable
  11. name="calendar"
  12. v-model="answer.date"
  13. label="就诊日期"
  14. placeholder="点击选择日期"
  15. @click="answer.showCalendar = true"
  16. />
  17. <van-calendar v-model:show="answer.showCalendar" :show-confirm="false" @confirm="onConfirmDate" />
  18. <div>
  19. <van-radio-group v-model="answer.temperature" direction="horizontal">
  20. 体温:
  21. <van-radio name="1">正常</van-radio>
  22. <van-radio name="2">发烧</van-radio>
  23. <van-field
  24. ref="mFocus"
  25. style="width: 80px"
  26. v-model="answer.feverNumber"
  27. type="number"
  28. :disabled="answer.temperature != 2"
  29. />&nbsp;℃
  30. </van-radio-group>
  31. </div>
  32. <van-field
  33. readonly
  34. clickable
  35. name="area"
  36. v-model="answer.address"
  37. label="住址地区"
  38. placeholder="点击选择省市区"
  39. @click="answer.showArea = true"
  40. />
  41. <van-popup v-model:show="answer.showArea" position="bottom">
  42. <van-area :area-list="areaList" value="430105" @confirm="onConfirmArea" @cancel="answer.showArea = false" />
  43. </van-popup>
  44. <div v-for="item in assessmentItems" :key="item.key">
  45. {{ item.label }}
  46. <div style="margin-top: 7px; margin-left: 10px">
  47. <van-radio-group v-model="answer['item' + item.key]" direction="vertical">
  48. <van-radio v-for="option in item.options" :key="option.key" :name="option.key" style="margin-top: 10px">
  49. <span :style="{ color: option.color }">{{ option.label }}</span>
  50. <van-checkbox-group v-model="answer.symptoms">
  51. <van-checkbox
  52. shape="square"
  53. v-for="child in option.children"
  54. :key="child.key"
  55. :name="child.key"
  56. style="margin-top: 5px"
  57. >{{ child.label }}</van-checkbox
  58. >
  59. </van-checkbox-group>
  60. </van-radio>
  61. </van-radio-group>
  62. </div>
  63. </div>
  64. <van-button @click="submit" type="primary" icon="passed" block>提交</van-button>
  65. </div>
  66. </template>
  67. <script>
  68. import { onMounted, reactive, ref, watchEffect } from 'vue'
  69. import { assessmentItems } from '../../../data/index'
  70. import { getDate } from '../../../utils/date'
  71. import { getPatientInfo, submitCovidAssessment } from '../../../api/assessments'
  72. import { validateCovid19Answer } from '../../../utils/validate'
  73. import { showDialog } from 'vant'
  74. import allArea from '../../../utils/area'
  75. import { useRouter } from 'vue-router'
  76. export default {
  77. name: 'Covid19Assessment',
  78. setup() {
  79. const areaList = allArea
  80. const answer = reactive({
  81. name: '',
  82. phone: '',
  83. idcard: '',
  84. symptoms: [],
  85. addrProvince: 430000,
  86. addrCity: 430100,
  87. addrDistrict: 430105,
  88. showCalendar: false,
  89. address: '湖南省/长沙市/开福区',
  90. showArea: false,
  91. showIdKeyboard: false,
  92. })
  93. const onConfirmArea = (values) => {
  94. answer.addrProvince = values[0].code
  95. answer.addrCity = values[1].code
  96. answer.addrDistrict = values[2].code
  97. answer.address = values
  98. .filter((item) => !!item)
  99. .map((item) => item.name)
  100. .join('/')
  101. answer.showArea = false
  102. }
  103. const onConfirmDate = (date) => {
  104. answer.date =
  105. date.getFullYear() + '-' + ('0' + (date.getMonth() + 1)).slice(-2) + '-' + ('0' + date.getDate()).slice(-2)
  106. answer.showCalendar = false
  107. }
  108. const onInputIdcard = (val) => {
  109. if (val === '清空') {
  110. setTimeout(() => {
  111. answer.idcard = ''
  112. })
  113. }
  114. }
  115. const from = ref('')
  116. const router = useRouter()
  117. const mFocus = ref(null)
  118. watchEffect(() => {
  119. if (answer.temperature === 2) {
  120. setTimeout(() => {
  121. mFocus.value.focus()
  122. }, 100)
  123. } else {
  124. answer.feverNumber = ''
  125. }
  126. })
  127. watchEffect(() => {
  128. if (answer.symptoms.length > 0) {
  129. answer.item5 = 51
  130. }
  131. })
  132. watchEffect(() => {
  133. if (answer.item5 === 52) {
  134. answer.symptoms = []
  135. }
  136. })
  137. const submit = () => {
  138. const message = validateCovid19Answer(answer)
  139. if (message === '') {
  140. submitCovidAssessment(answer).then((res) => {
  141. showDialog({
  142. title: '提示',
  143. message: '提交成功!',
  144. }).then(() => {
  145. router.go(-1)
  146. })
  147. })
  148. } else {
  149. showDialog({
  150. title: '提示',
  151. message: message,
  152. }).then(() => {
  153. if (message.startsWith('请先绑定')) {
  154. router.push('/myPatientIdCards')
  155. }
  156. })
  157. }
  158. }
  159. onMounted(() => {
  160. const patientId = router.currentRoute.value.params.patientId
  161. if (!patientId || patientId === ':patientId') {
  162. showDialog({
  163. message: '请先绑定就诊卡!',
  164. title: '提示',
  165. }).then(() => {
  166. router.push('/myPatientIdCards')
  167. })
  168. } else {
  169. from.value = router.currentRoute.value.params.from
  170. answer.patientId = patientId
  171. getPatientInfo(patientId).then((res) => {
  172. answer.name = res.name
  173. answer.phone = res.phone
  174. answer.idcard = res.idcard
  175. answer.date = getDate()
  176. })
  177. }
  178. })
  179. return {
  180. mFocus,
  181. areaList,
  182. onInputIdcard,
  183. answer,
  184. onConfirmArea,
  185. onConfirmDate,
  186. assessmentItems,
  187. submit,
  188. }
  189. },
  190. }
  191. </script>
  192. <style scoped>
  193. #question-body {
  194. padding: 0 20px 20px 20px;
  195. }
  196. #question-body > div {
  197. margin-bottom: 15px;
  198. }
  199. </style>