OutpatientAppointments.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. <script setup name="OutpatientAppointments">
  2. import {huanZheXinXi} from "@/views/hospitalization/zhu-yuan-yi-sheng/public-js/zhu-yuan-yi-sheng";
  3. import {stringIsBlank} from "@/utils/blank-utils";
  4. import {BizException, ExceptionEnum} from "@/utils/BizException";
  5. import {
  6. getAmpmByDateAndDeptCode,
  7. getChargeTypeByRequestDayAndDoctor, getDoctorCodeByRequestDayAndDoctor, getMzChargeTypeByMzyRequestId, saveMzyReqrec
  8. } from "@/api/outpatient-appointments/outpatient-appointments";
  9. const dialog = ref(false)
  10. const openDialog = () => {
  11. if (stringIsBlank(huanZheXinXi.value.zkWard)) {
  12. BizException(ExceptionEnum.MESSAGE_ERROR, "请先选择患者。")
  13. }
  14. if (stringIsBlank(huanZheXinXi.value.mzNo)) {
  15. BizException(ExceptionEnum.MESSAGE_ERROR, "没有查询到患者门诊号,请先建档。");
  16. }
  17. dialog.value = true;
  18. param.unitCode = huanZheXinXi.value.zkWard
  19. param.patientId = huanZheXinXi.value.mzNo
  20. param.birthDay = huanZheXinXi.value.birthDay
  21. }
  22. let param = $ref({
  23. requestDayStr: '',
  24. unitCode: '',
  25. ampm: '',
  26. apTime: '',
  27. chargeType: '',
  28. mzyRequestId: '',
  29. birthDay: '',
  30. patientId: ''
  31. })
  32. let segmentList = $ref([])
  33. const dateChange = () => {
  34. param.ampm = ''
  35. param.apTime = ''
  36. param.chargeType = ''
  37. param.mzyRequestId = ''
  38. segmentList = []
  39. numbercategory = []
  40. doctorList = []
  41. getAmpmByDateAndDeptCode(param.requestDayStr, param.unitCode).then(res => {
  42. segmentList = res
  43. })
  44. }
  45. const aList = [
  46. {code: 'a1', name: '08:00-08:30'},
  47. {code: 'a2', name: '08:30-09:00'},
  48. {code: 'a3', name: '09:00-09:30'},
  49. {code: 'a4', name: '09:30-10:00'},
  50. {code: 'a5', name: '10:00-10:30'},
  51. {code: 'a6', name: '10:30-11:00'},
  52. {code: 'a7', name: '11:00-11:30'},
  53. {code: 'a8', name: '11:30-12:00'},
  54. ]
  55. const pList = [
  56. {code: 'p1', name: '14:00-14:30'},
  57. {code: 'p2', name: '14:30-15:00'},
  58. {code: 'p3', name: '15:00-15:30'},
  59. {code: 'p4', name: '15:30-16:00'},
  60. {code: 'p5', name: '16:00-16:30'},
  61. {code: 'p6', name: '16:30-17:00'},
  62. ]
  63. const segmentCalculation = computed(() => {
  64. if (param.ampm === 'a') {
  65. return aList
  66. } else if (param.ampm === 'p') {
  67. return pList
  68. }
  69. return []
  70. })
  71. let numbercategory = $ref([])
  72. const chargeTypeByRequestDayAndDoctor = () => {
  73. if (param.unitCode && param.ampm && param.requestDayStr) {
  74. getChargeTypeByRequestDayAndDoctor(param.unitCode, param.ampm, param.requestDayStr, param.apTime).then((res) => {
  75. numbercategory = res
  76. console.log(res)
  77. })
  78. }
  79. }
  80. const ampmChange = () => {
  81. param.apTime = ''
  82. param.chargeType = ''
  83. param.mzyRequestId = ''
  84. numbercategory = []
  85. doctorList = []
  86. if (!(param.ampm === 'a' || param.ampm === 'p')) {
  87. chargeTypeByRequestDayAndDoctor()
  88. }
  89. }
  90. let doctorList = $ref([])
  91. const doctorCodeByRequestDayAndDoctor = () => {
  92. param.mzyRequestId = ''
  93. doctorList = []
  94. if (param.unitCode && param.ampm && param.requestDayStr && param.chargeType) {
  95. getDoctorCodeByRequestDayAndDoctor(param.unitCode, param.ampm, param.requestDayStr, param.apTime, param.chargeType).then((res) => {
  96. doctorList = res
  97. console.log(res)
  98. })
  99. }
  100. }
  101. let feeInfo = $ref({})
  102. const doctorsChange = () => {
  103. if (param.mzyRequestId && param.birthDay && param.patientId) {
  104. getMzChargeTypeByMzyRequestId(param.mzyRequestId, param.birthDay, param.patientId).then((res) => {
  105. feeInfo = res
  106. })
  107. }
  108. }
  109. const apTimeValidator = (rule, value, callback) => {
  110. if (param.ampm === 'a' || param.ampm === 'p') {
  111. if (stringIsBlank(param.apTime)) {
  112. callback(new Error('时间不能为空'))
  113. } else {
  114. callback()
  115. }
  116. } else {
  117. param.apTime = ''
  118. callback()
  119. }
  120. }
  121. const rules = {
  122. requestDayStr: [{required: true, message: '预约日期不能为空。', trigger: 'blur'}],
  123. ampm: [{required: true, message: '号段不能为空。', trigger: 'blur'}],
  124. apTime: [{validator: apTimeValidator, message: '时间不能为空。', trigger: 'blur'}],
  125. chargeType: [{required: true, message: '号别不能为空。', trigger: 'blur'}],
  126. mzyRequestId: [{required: true, message: '医生不能为空。', trigger: 'blur'}],
  127. }
  128. const formRef = ref(null)
  129. const confirm = async () => {
  130. if (!formRef.value) return
  131. await formRef.value.validate()
  132. let data = {
  133. mzyRequestId: param.mzyRequestId,
  134. totalFee: feeInfo.clinicFee,
  135. payMark: "5",
  136. mzyReqrec: {
  137. patientId: param.patientId,
  138. ampm: param.ampm,
  139. apTime: param.apTime,
  140. unitCode: param.unitCode,
  141. chargeType: param.chargeType,
  142. requestDayStr: param.requestDayStr,
  143. }
  144. }
  145. saveMzyReqrec(data).then(res => {
  146. cancel()
  147. })
  148. }
  149. const cancel = () => {
  150. segmentList = []
  151. numbercategory = []
  152. doctorList = []
  153. feeInfo = {}
  154. param = {
  155. requestDayStr: '',
  156. unitCode: '',
  157. ampm: '',
  158. apTime: '',
  159. chargeType: '',
  160. mzyRequestId: '',
  161. birthDay: '',
  162. patientId: ''
  163. }
  164. dialog.value = false
  165. }
  166. </script>
  167. <template>
  168. <button @click="openDialog()">门诊预约</button>
  169. <el-dialog v-model="dialog" title="门诊预约" @closed="cancel">
  170. <el-form inline
  171. ref="formRef"
  172. label-position="right"
  173. label-width="120px"
  174. :model="param"
  175. :rules="rules">
  176. <el-row>
  177. <el-col :span="12">
  178. <el-form-item label="日期" prop="requestDayStr">
  179. <el-date-picker v-model="param.requestDayStr"
  180. @change="dateChange"
  181. format="YYYY-MM-DD"
  182. value-format="YYYY-MM-DD"
  183. type="date"/>
  184. </el-form-item>
  185. </el-col>
  186. <el-col :span="12">
  187. <el-form-item label="号段" prop="ampm">
  188. <el-select v-model="param.ampm" @change="ampmChange">
  189. <el-option v-for="item in segmentList" :value="item.code" :label="item.name"/>
  190. </el-select>
  191. </el-form-item>
  192. </el-col>
  193. <el-col :span="12">
  194. <el-form-item label="时间" prop="apTime">
  195. <el-select v-model="param.apTime" @change="chargeTypeByRequestDayAndDoctor">
  196. <el-option
  197. v-for="item in segmentCalculation"
  198. :value="item.code"
  199. :label="item.name"/>
  200. </el-select>
  201. </el-form-item>
  202. </el-col>
  203. <el-col :span="12">
  204. <el-form-item label="号别" prop="chargeType">
  205. <el-select v-model="param.chargeType" @change="doctorCodeByRequestDayAndDoctor">
  206. <el-option
  207. v-for="item in numbercategory"
  208. :value="item.code"
  209. :label="item.name"/>
  210. </el-select>
  211. </el-form-item>
  212. </el-col>
  213. <el-col :span="12">
  214. <el-form-item label="医生" prop="mzyRequestId">
  215. <el-select v-model="param.mzyRequestId" @change="doctorsChange">
  216. <el-option
  217. v-for="item in doctorList"
  218. :value="item.mzyRequestId"
  219. :label="item.employee.employeeName"/>
  220. </el-select>
  221. </el-form-item>
  222. </el-col>
  223. </el-row>
  224. </el-form>
  225. <template #footer>
  226. <el-button type="danger" @click="cancel">取消</el-button>
  227. <el-button type="primary" @click="confirm( )">预约</el-button>
  228. </template>
  229. </el-dialog>
  230. </template>
  231. <style scoped lang="scss">
  232. </style>