BindPatientCard.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. <template>
  2. <window-size>
  3. <div id="paddingRightZero">
  4. <van-cell title="关系">
  5. <template #right-icon>
  6. <van-radio-group v-model="card.relation" direction="horizontal">
  7. <van-radio name="1">本人</van-radio>
  8. <van-radio name="2">他人</van-radio>
  9. </van-radio-group>
  10. </template>
  11. </van-cell>
  12. </div>
  13. <div style="height: 5px"></div>
  14. <van-field v-model="card.name" label="姓名" type="text" placeholder="请输入姓名" />
  15. <div style="height: 5px"></div>
  16. <van-cell>
  17. <span style="font-size: 13px; color: gray">门诊号/就诊卡/身份证</span>
  18. <div style="height: 5px"></div>
  19. <van-radio-group v-model="card.cardType" direction="horizontal">
  20. <van-radio name="0">门诊号</van-radio>
  21. <van-radio name="1">就诊卡</van-radio>
  22. <van-radio name="2">身份证</van-radio>
  23. </van-radio-group>
  24. </van-cell>
  25. <van-field v-model="card.cardNo" :placeholder="cardNoHint" />
  26. <div style="height: 5px"></div>
  27. <van-field v-model="card.phone" type="tel" placeholder="请输入手机号" />
  28. <div style="height: 5px"></div>
  29. <van-field
  30. readonly
  31. clickable
  32. name="area"
  33. v-model="card.address"
  34. label="住址地区"
  35. placeholder="点击选择省市区"
  36. @click="showArea = true"
  37. />
  38. <van-popup v-model:show="showArea" position="bottom">
  39. <van-area :area-list="allArea" value="430105" @confirm="onConfirmArea" @cancel="showArea = false" />
  40. </van-popup>
  41. <van-field v-model="card.street" label="街道、小区" type="text" placeholder="请输入住址所在街道、小区" />
  42. <div style="height: 10px"></div>
  43. <van-button type="primary" block icon="checked" @click="bindCard">立即绑定</van-button>
  44. </window-size>
  45. <van-dialog v-model:show="multipleCards.show" title="请选择一张就诊卡" @confirm="bindSelectCard">
  46. <van-radio-group v-model="multipleCards.cardNo">
  47. <div style="height: 30px"></div>
  48. <div id="smallRadio">
  49. <van-row>
  50. <van-col span="6"><div style="width: 100%; text-align: center">姓名</div></van-col>
  51. <van-col span="6"><div style="width: 100%; text-align: center">就诊卡号</div></van-col>
  52. <van-col span="8"><div style="width: 100%; text-align: center">上次就诊</div></van-col>
  53. <van-col span="4">选择</van-col>
  54. </van-row>
  55. <div style="height: 30px"></div>
  56. <div v-for="item in multipleCards.cards" :key="item.patientId">
  57. <van-row @click="multipleCards.cardNo = item.patientId">
  58. <van-col span="6"
  59. ><div style="width: 100%; text-align: center">
  60. {{ item.name }}
  61. </div></van-col
  62. >
  63. <van-col span="6"
  64. ><div style="width: 100%; text-align: center">
  65. {{ item.patientId }}
  66. </div></van-col
  67. >
  68. <van-col span="8"
  69. ><div style="width: 100%; text-align: center">
  70. {{ item.lvDate }}
  71. </div></van-col
  72. >
  73. <van-col span="4">
  74. <van-radio :name="item.patientId" />
  75. </van-col>
  76. </van-row>
  77. <div style="height: 20px"></div>
  78. </div>
  79. </div>
  80. </van-radio-group>
  81. </van-dialog>
  82. </template>
  83. <script>
  84. import store from '../../../store'
  85. import { computed, onMounted, reactive, ref } from 'vue'
  86. import allArea from '../../../utils/area'
  87. import { getLocalOpenId } from '../../../utils/check-patient-id'
  88. import { bindPatientId } from '../../../api/patient-id-cards'
  89. import { validateBindPatientId } from '../../../utils/validate'
  90. import { Dialog, Toast } from 'vant'
  91. import router from '../../../router'
  92. export default {
  93. name: 'BindPatientCard',
  94. setup() {
  95. const card = reactive({
  96. openId: getLocalOpenId(),
  97. relation: '1',
  98. name: '',
  99. cardType: '0',
  100. cardNo: '',
  101. phone: '',
  102. province: '',
  103. city: '',
  104. district: '',
  105. street: '',
  106. })
  107. const cardNoHint = computed(() => {
  108. const type = card.cardType
  109. if (type === '0') {
  110. return '请输入门诊ID号'
  111. } else if (type === '1') {
  112. return '请输入就诊卡号码'
  113. } else {
  114. return '请输入身份证号码'
  115. }
  116. })
  117. const showArea = ref(false)
  118. const onConfirmArea = (values) => {
  119. card.province = values[0].code
  120. card.city = values[1].code
  121. card.district = values[2].code
  122. card.address = values
  123. .filter((item) => !!item)
  124. .map((item) => item.name)
  125. .join('/')
  126. showArea.value = false
  127. }
  128. const multipleCards = reactive({
  129. show: false,
  130. cards: [],
  131. cardNo: '',
  132. })
  133. const bindCard = () => {
  134. const validate = validateBindPatientId(card)
  135. if (validate === 'success') {
  136. bindPatientId(card).then((res) => {
  137. if (res.code === 0) {
  138. Toast.success('绑定成功')
  139. store.commit('SET_PATIENTCARDS', res.cards)
  140. router.go(-1)
  141. } else {
  142. multipleCards.cards = res.cards
  143. multipleCards.show = true
  144. }
  145. })
  146. } else {
  147. Dialog.alert({
  148. title: '提示',
  149. message: validate,
  150. })
  151. }
  152. }
  153. const bindSelectCard = () => {
  154. multipleCards.cards.forEach((item) => {
  155. if (item.patientId === multipleCards.cardNo) {
  156. card.name = item.name
  157. card.cardType = '1'
  158. card.cardNo = item.patientId
  159. bindPatientId(card).then((res) => {
  160. Toast.success('绑定成功')
  161. store.commit('SET_PATIENTCARDS', res.cards)
  162. router.go(-1)
  163. })
  164. }
  165. })
  166. }
  167. onMounted(() => {
  168. if (store.state.patientCards.length > 0) {
  169. card.relation = '2'
  170. }
  171. })
  172. return {
  173. card,
  174. cardNoHint,
  175. showArea,
  176. allArea,
  177. onConfirmArea,
  178. bindCard,
  179. multipleCards,
  180. bindSelectCard,
  181. }
  182. },
  183. }
  184. </script>
  185. <style>
  186. #paddingRightZero .van-cell {
  187. padding-right: 0;
  188. }
  189. #smallRadio {
  190. font-size: 13px;
  191. color: gray;
  192. }
  193. #smallRadio .van-radio__icon {
  194. font-size: 15px;
  195. }
  196. </style>