yyghDeptList.js 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. const app = getApp();
  2. import yygh from "../../../../config/api/yygh/index.js";
  3. import regeneratorRuntime from "../../../../../utils/runtime.js";
  4. import common from "../../../../../utils/common.js";
  5. import icon from "../../../../../utils/icon.js";
  6. import { pagesPatientFn } from '@/utils';
  7. Page({
  8. data: {
  9. iconUrl:icon,
  10. isFocus: false, //input是否获取焦点
  11. searchValue: '', //搜索值
  12. searchList: [], //搜索结果
  13. deptListFir: [], //一级科室
  14. deptListFirIndex: -1, //当前一级科室
  15. deptListSec: [], //二级科室
  16. deptListSecIndex: -1, //当前二级科室
  17. pageConfig: {}, //页面配置
  18. serviceId:'',
  19. queryData: {
  20. HosId: '',
  21. ParentDeptCode: "",
  22. ServiceId:""
  23. },
  24. modalData: {}
  25. },
  26. onLoad: function(options) {
  27. this.setData({
  28. pageConfig: common.deepCopy(app.globalData.config.pageConfiguration.yyghDeptList_config),
  29. serviceId :options.serviceId || '',
  30. 'queryData.HosId': app.globalData.districtId || app.globalData.hosId,
  31. 'queryData.ServiceId': options.serviceId || '',
  32. })
  33. this.main()
  34. },
  35. onShow: function() {
  36. },
  37. async main() {
  38. let pageConfig = this.data.pageConfig
  39. //获取一级科室
  40. let deptListFir = [];
  41. let deptListSec = [];
  42. let queryData = this.data.queryData;
  43. let deptListFirResp = await yygh.queryClinicBaseDept(queryData)
  44. if (!common.isEmpty(deptListFirResp)) {
  45. deptListFir = deptListFirResp;
  46. if (pageConfig.showDeptSec) {
  47. // 如果有二级科室 默认取第一个一级科室
  48. queryData.ParentDeptCode = deptListFir[0].DeptCode
  49. let deptListSecResp = await yygh.queryClinicBaseDept(queryData)
  50. if (!common.isEmpty(deptListSecResp)) {
  51. deptListSec = deptListSecResp
  52. }
  53. }
  54. }
  55. this.setData({
  56. deptListFir: deptListFir,
  57. deptListSec: deptListSec,
  58. deptListFirIndex: pageConfig.showDeptSec ? 0 : -1,
  59. modalData: pageConfig.modalData,
  60. })
  61. //
  62. },
  63. /**
  64. * 科室点击
  65. */
  66. async deptClick(e) {
  67. let pageType = "";
  68. let type = e.currentTarget.dataset.type; // 当前触发方式 fir:一级科室 sec:二级科室 否者为搜索
  69. let pageConfig = this.data.pageConfig // 页面配置
  70. let item = e.currentTarget.dataset.item;
  71. let index = e.currentTarget.dataset.index;
  72. let deptListSec = this.data.deptListSec;
  73. let deptListFirIndex = this.data.deptListFirIndex;
  74. let deptListSecIndex = this.data.deptListSecIndex;
  75. if (type == 'fir') {
  76. //如果点击一级科室
  77. deptListFirIndex = index;
  78. if (pageConfig.showDeptSec) {
  79. //如果医院有二级科室
  80. deptListSec = []
  81. let queryData = this.data.queryData;
  82. queryData.ParentDeptCode = item.DeptCode
  83. let resp = await yygh.queryClinicBaseDept(queryData)
  84. if (!common.isEmpty(resp)) {
  85. deptListSec = resp;
  86. deptListSecIndex = -1;
  87. }
  88. }else{
  89. pageType = 'yyghDoctorList'
  90. }
  91. } else if (type == 'sec') {
  92. //如果点击二级科室
  93. deptListSecIndex = index
  94. pageType = 'yyghDoctorList'
  95. } else {
  96. pageType = 'yyghDoctorList'
  97. if (item.SearchType == '2') {
  98. /**如果点击医生 跳转到挂号页面*/
  99. pageType = "yyghClinicMsg"
  100. }
  101. }
  102. this.setData({
  103. deptListFirIndex: deptListFirIndex,
  104. deptListSecIndex: deptListSecIndex,
  105. deptListSec: deptListSec
  106. })
  107. // 判断如果不为空就是跳转
  108. if(common.isNotEmpty(pageType)){
  109. // 判断等于跳转医生列表页 且有配置特殊科室续弹窗显示内容
  110. if(pageType == 'yyghDoctorList' && pageConfig.deptShowMode[item.DeptCode]){
  111. common.showModal(pageConfig.deptShowMode[item.DeptCode],()=>{
  112. pagesPatientFn.handleRouter(e, pageType, this.data.serviceId)
  113. })
  114. }else{
  115. pagesPatientFn.handleRouter(e, pageType, this.data.serviceId)
  116. }
  117. }
  118. },
  119. /**
  120. * 点击搜索
  121. */
  122. async searchClick() {
  123. let pageConfig = this.data.pageConfig
  124. let searchValue = this.data.searchValue;
  125. if (common.isEmpty(searchValue)) {
  126. common.showModal('请输入搜索科室或医生')
  127. return
  128. }
  129. let result = []
  130. let queryData = {
  131. HosId: app.globalData.districtId || app.globalData.hosId,
  132. SearchLike: searchValue,
  133. ServiceId:this.data.serviceId,
  134. QueryLocal:"1",
  135. UseBaseInfo:true,
  136. ExcludeOneLv:pageConfig.showDeptSec ? 1 : 0 ,// 是否过滤一级科室,
  137. }
  138. let resp = await yygh.searchClinicDeptAndDoctor(queryData)
  139. if (!common.isEmpty(resp)) {
  140. result = resp;
  141. }
  142. this.setData({
  143. searchList: result
  144. })
  145. },
  146. // 搜索科室
  147. async queryDeptList(searchValue) {
  148. let queryData = {
  149. dept:{
  150. hospitalId: app.globalData.districtId || app.globalData.hosId,
  151. deptNameOrPingyinLike:searchValue,
  152. status:1
  153. },
  154. deptdoctor:{
  155. doctorServiceGh: 1,
  156. displaystatus: 1,
  157. },
  158. doctor:{},
  159. }
  160. let resp = await yygh.queryDeptList_V2(queryData)
  161. if (!common.isEmpty(resp)) {
  162. if(this.data.pageConfig.showDeptSec){
  163. resp = resp.filter(item=>item.parientId != -1)
  164. }
  165. resp = common.changeObj(resp)
  166. return resp
  167. }
  168. return []
  169. },
  170. // 搜索医生
  171. async queryDoctorList(searchValue) {
  172. let queryData = {
  173. isQueryDeptList: "1",//"是否返回医生的科室列表",
  174. doctor: {
  175. doctorNameOrPingYinLike:searchValue,//"拼音检索-模糊"
  176. status:1
  177. },
  178. dept: {
  179. hospitalId: app.globalData.districtId || app.globalData.hosId,
  180. status:1
  181. },
  182. deptdoctor: {
  183. doctorServiceGh: 1, // "是否开通挂号服务"
  184. displaystatus: "1"//"是否启用"
  185. }
  186. }
  187. let resp = await yygh.queryDoctorList_V2(queryData)
  188. if (!common.isEmpty(resp)) {
  189. let doctorList = []
  190. resp.map(item=>{
  191. item.searchType = '2'//医生数据做一个标识
  192. item.deptList.map(ele =>{ // 方向把当前医生所有的坐诊科室排列出来
  193. doctorList.push({...ele,...item})
  194. })
  195. })
  196. doctorList = common.changeObj(doctorList)
  197. return doctorList
  198. }
  199. return []
  200. },
  201. /**
  202. * 输入框聚焦
  203. */
  204. focusFn(e) {
  205. let type = e.currentTarget.dataset.type;
  206. this.setData({
  207. isFocus: type == 'focus' ? true : !this.data.isFocus,
  208. searchValue: type == 'focus' ? this.data.searchValue : '',
  209. searchList: type == 'focus' ? this.data.searchList : [],
  210. })
  211. },
  212. /**
  213. * 输入值获取
  214. */
  215. setVal(e) {
  216. let key = e.currentTarget.dataset.key;
  217. let value = e.detail.value;
  218. this.setData({
  219. [key]: value
  220. })
  221. },
  222. /**
  223. * 空函数 阻止搜索结果点击冒泡
  224. */
  225. doNothing() {
  226. },
  227. /**
  228. * ai导诊 历史医生点击
  229. */
  230. optionClick(e) {
  231. let type = e.currentTarget.dataset.type;
  232. if (type == 'ai') {
  233. //点击ai导诊
  234. // 跳转密影 根目录加公众号appid
  235. wx.navigateToMiniProgram({
  236. appId: this.data.pageConfig.aiMode.appId,
  237. // appid=: 需要自行对接配置相应医院的公众号appId
  238. path: this.data.pageConfig.aiMode.path
  239. })
  240. } else {
  241. //点击历史医生
  242. common.goToUrl('/pagesPatient/st1/business/yygh/yyghHistoryDoctor/yyghHistoryDoctor')
  243. }
  244. },
  245. // 就诊须知弹窗关闭
  246. modalCancel(){
  247. common.navigateBack(1)
  248. },
  249. modalConfirm(){
  250. this.setData({
  251. 'modalData.showModal' :false
  252. })
  253. },
  254. modalNoData(){
  255. common.navigateBack(1)
  256. }
  257. })