yyghDoctorList.js 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323
  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 { pagesPatientFn } from '@/utils';
  6. import apiRootUrl from "../../../../config/api.js";
  7. import icon from "../../../../../utils/icon.js";
  8. Page({
  9. data: {
  10. iconUrl:icon,
  11. dialogIsShow: false, //是否展示医生职称筛选
  12. showNoData: false, //是否展示暂无数据
  13. timeList: [], //预约时段列表
  14. timeActive: '', //当前选择的预约时间index ''为全部
  15. doctorList: [], //预约医生列表
  16. noDataTip: '暂无排班数据', //暂无数据显示字段
  17. showCon: false, //是否展示页面
  18. titleInfoList: [], //医生职称列表
  19. titleSelect: {}, //当前选择的医生职称
  20. titleClick: {}, //当前点击的医生职称
  21. reducibleOnly: false, //是否仅显示可约医生
  22. doctorInfoIsShow: false,
  23. doctorInfo: {}, //医生详情信息
  24. pageConfig: {},
  25. serviceId:'',
  26. },
  27. onLoad: function(options) {
  28. /** 如果有区分院区 会传入院区Id 直接赋值 */
  29. app.globalData.districtId = options.DistrictId || app.globalData.districtId
  30. // 当前页面配置信息
  31. let pageConfig = common.deepCopy(app.globalData.config.pageConfiguration.yyghDoctorList_config)
  32. let queryBean = options.queryBean ? JSON.parse(options.queryBean) : app.globalData.queryBean ? app.globalData.queryBean :{}
  33. console.log(queryBean,'queryBean')
  34. options.deptName && (queryBean.DeptName = options?.deptName)
  35. options.deptCode && (queryBean.DeptCode = options?.deptCode)
  36. this.setData({
  37. queryBean: queryBean,
  38. serviceId:options.serviceId || '',
  39. pageConfig: pageConfig,
  40. timeActive: (pageConfig.hasAllSchedules && options.serviceId != '009') ? '' : 0
  41. })
  42. wx.setNavigationBarTitle({
  43. title: this.data.queryBean.DeptName,
  44. })
  45. this.main()
  46. },
  47. async main() {
  48. let timeList = [];
  49. let titleInfoList = [];
  50. let queryBean = this.data.queryBean;
  51. //获取排班日期列表
  52. let queryData = {
  53. HosId: app.globalData.districtId || app.globalData.hosId,
  54. DeptCode: queryBean.DeptCode
  55. }
  56. let timeListResp = await yygh.queryClinicScheduleDate(queryData)
  57. timeListResp.map(item=>{
  58. if(item.RegDate == common.newDay())item.WeekName = '今天'
  59. })
  60. timeList = !common.isEmpty(timeListResp) ? timeListResp : timeList;
  61. //获取排班医生列表
  62. let doctorListResp = this.setterDoctorList(timeList)
  63. this.setData({
  64. timeList: timeList,
  65. showCon: true,
  66. })
  67. },
  68. /**
  69. * 医生筛选点击
  70. */
  71. async titleClick(e) {
  72. let item = e.currentTarget.dataset.item;
  73. //为空 点击全部
  74. this.setData({
  75. titleClick: common.isEmpty(item) ? "" : item
  76. })
  77. },
  78. /**
  79. * 医生详情点击
  80. */
  81. async doctorInfoClick(e) {
  82. let item = e.currentTarget.dataset.item;
  83. let queryData = {
  84. HosId: app.globalData.districtId || app.globalData.hosId,
  85. DeptCode: item.DeptCode || '',
  86. DoctorCode: item.DoctorCode || '',
  87. DoctorName: ''
  88. }
  89. let resp = await yygh.queryClinicBaseDoctor(queryData);
  90. if (!common.isEmpty(resp)) {
  91. this.setData({
  92. doctorInfoIsShow: true,
  93. doctorInfo: resp[0]
  94. })
  95. }
  96. },
  97. /**
  98. * 点击医生职称重置 确定按钮
  99. */
  100. async titleBtnClick(e) {
  101. let type = e.currentTarget.dataset.type;
  102. if (type == 'reset') {
  103. //点击重置
  104. this.setData({
  105. titleClick: {}
  106. })
  107. } else {
  108. //点击确定
  109. this.setData({
  110. titleSelect: this.data.titleClick
  111. })
  112. await this.setterDoctorList()
  113. this.dialogShowChange()
  114. }
  115. },
  116. /**
  117. * 点击查看全部排班
  118. */
  119. showAll(e) {
  120. let doctorIndex = e.currentTarget.dataset.doctorindex;
  121. let schedulindex = e.currentTarget.dataset.schedulindex;
  122. let doctorList = this.data.doctorList;
  123. doctorList[doctorIndex].Scheduling[schedulindex].showAllSchedu = !doctorList[doctorIndex].Scheduling[schedulindex].showAllSchedu
  124. this.setData({
  125. doctorList: doctorList
  126. })
  127. },
  128. /**
  129. * 是否仅显示可约医生
  130. */
  131. async switchChange(e) {
  132. let value = e.detail.value;
  133. this.setData({
  134. reducibleOnly: value
  135. })
  136. await this.setterDoctorList()
  137. },
  138. /**
  139. * 点击排班时间
  140. */
  141. async timeClick(e) {
  142. let item = e.currentTarget.dataset.item;
  143. let index = e.currentTarget.dataset.index;
  144. let showNoData = true;
  145. let timeActive = this.data.timeActive;
  146. if (!common.isEmpty(item)) {
  147. timeActive = index
  148. } else {
  149. // 点击全部
  150. timeActive = ""
  151. }
  152. this.setData({
  153. timeActive: timeActive
  154. })
  155. await this.setterDoctorList();
  156. },
  157. /**
  158. * 医生dialog显隐
  159. */
  160. dialogShowChange() {
  161. this.setData({
  162. dialogIsShow: !this.data.dialogIsShow,
  163. titleClick: this.data.titleSelect
  164. })
  165. },
  166. /**
  167. * 空函数
  168. */
  169. doNothing() {
  170. },
  171. /**
  172. * 处理医生列表返回值
  173. */
  174. async setterDoctorList(timeList) {
  175. let list = timeList || this.data.timeList;
  176. let time = typeof this.data.timeActive == 'number' ? list[this.data.timeActive].RegDate : ""
  177. let queryData = {
  178. HosId: app.globalData.districtId || app.globalData.hosId,
  179. ServiceId:this.data.serviceId,
  180. DeptCode: this.data.queryBean.DeptCode,
  181. DoctorCode: "",
  182. WorkDateStart: time || "",
  183. WorkDateEnd: time || "",
  184. TitleCode: this.data.titleSelect.DoctorTitleCode || "",
  185. OrderByDoc: '1',
  186. WaitRule : '1'
  187. }
  188. let resp = await yygh.queryClinicDoctorSchedule(queryData)
  189. let reducibleOnly = this.data.reducibleOnly;
  190. if (!common.isEmpty(resp)) {
  191. for (let i of resp) {
  192. if (i.Data_1 && !common.isEmpty(i.Data_1)){
  193. i.Data_1.map(item => {
  194. item.RegDateDiy = item.RegDate.substring(5),
  195. item.WeekName = item.RegDate == common.newDay()?'今天':item.WeekName
  196. })
  197. }
  198. /**如果医生头像没有域名 添加域名 */
  199. if (i.PhotoUrl && i.PhotoUrl.indexOf('http') == '-1') {
  200. i.PhotoUrl = apiRootUrl.ApiRootUrl + i.PhotoUrl
  201. }
  202. i.PhotoUrl = i.PhotoUrl.replace(/\\/g, '/')
  203. if (i.Data_1.length > 6) {
  204. i.Data_1_Diy = i.Data_1.slice(0, 5);
  205. i.showAllSchedu = false
  206. } else {
  207. i.Data_1_Diy = i.Data_1;
  208. i.showAllSchedu = true;
  209. }
  210. }
  211. }
  212. if (reducibleOnly && !common.isEmpty(resp)) {
  213. resp = resp.filter(item => item.Data_1.filter(cell => cell.IsHalt != '7' && cell.IsHalt != '2').length > 0)
  214. }
  215. resp.map(item=>{
  216. let obj = [{
  217. Check:true,
  218. DeptName:item.DeptName,
  219. DeptCode:item.DeptCode,
  220. DoctorName:item.DoctorName,
  221. DoctorCode:item.DoctorCode,
  222. Data_1:item.Data_1,
  223. Data_1_Diy:item.Data_1_Diy,
  224. showAllSchedu:item.showAllSchedu,
  225. }]
  226. item.Scheduling = obj
  227. })
  228. this.setData({
  229. doctorList: resp,
  230. showNoData: common.isEmpty(resp) ? true : false
  231. })
  232. },
  233. /**
  234. * 点击医生具体排班时间
  235. */
  236. async toClinic(e) {
  237. let item = e.currentTarget.dataset.dataitem;
  238. let index = e.currentTarget.dataset.index;
  239. // 判断(约满且无候补)或者停诊
  240. if ((item.IsHalt==7&& item.WaitLeaveCount <= 0) || item.IsHalt == '2') {
  241. return;
  242. }
  243. /**判断有卡无卡 有无就诊人 有无最后操作就诊人的路径跳转处理 */
  244. pagesPatientFn.handleRouter(e, 'yyghClinicMsg',this.data.serviceId, index)
  245. },
  246. /**
  247. * 查询其它科室排班
  248. */
  249. async queryScheduleList(e){
  250. let doctorIndex = e.currentTarget.dataset.index
  251. let doctorItem = e.currentTarget.dataset.doctoritem
  252. let doctorList = common.deepCopy(this.data.doctorList,[])
  253. let time = typeof this.data.timeActive == 'number' ? this.data.timeList[this.data.timeActive].RegDate : ""
  254. let querData = {
  255. workDateEnd: time || "",
  256. workDateStart: time || "",
  257. doctorCode: doctorItem.DoctorCode,
  258. deptCode:doctorItem.DeptCode ,
  259. hosId: app.globalData.districtId || app.globalData.hosId,
  260. WaitRule: '1'
  261. }
  262. let res = await yygh.queryScheduleList(querData)
  263. if(common.isNotEmpty(res)){
  264. let scheduleList = []
  265. res.map(async (item,index)=>{
  266. // 转换返回数据 小写转大写
  267. item.hisQueryClinicSchedules = common.changeObj(item.hisQueryClinicSchedules)
  268. item.hisQueryBaseDoctor = common.changeObj(item.hisQueryBaseDoctor)
  269. if(item.hisQueryClinicSchedules.length > 0){
  270. // 判断是否多数据处理 星期 时间 上下午
  271. if(item.hisQueryClinicSchedules.length > 0){
  272. item.hisQueryClinicSchedules.map(ele=>{
  273. ele.WeekName = ele.RegDate == common.newDay()?'今天':common.weekDay(ele.RegDate,1)
  274. ele.RegDateDiy = ele.RegDate.substring(5)
  275. ele.TimeSliceStr = ele.TimeSlice==1?'上午':ele.TimeSlice==2?'下午':'全天'
  276. })
  277. }
  278. // 判断如果超出6个隐藏
  279. if (item.hisQueryClinicSchedules.length > 6) {
  280. item.Data_1_Diy = item.hisQueryClinicSchedules.slice(0, 5);
  281. item.showAllSchedu = false
  282. } else {
  283. item.Data_1_Diy = item.hisQueryClinicSchedules;
  284. item.showAllSchedu = true;
  285. }
  286. scheduleList.push({
  287. Check:item.hisQueryBaseDoctor.DeptCode==doctorItem.DeptCode?true:false,
  288. DeptName:item.hisQueryBaseDoctor.DeptName,
  289. DeptCode:item.hisQueryBaseDoctor.DeptCode,
  290. DoctorName:doctorItem.DoctorName,
  291. DoctorCode:doctorItem.DoctorCode,
  292. Data_1:item.hisQueryClinicSchedules,
  293. Data_1_Diy:item.Data_1_Diy,
  294. showAllSchedu:item.showAllSchedu,
  295. })
  296. }
  297. })
  298. // 给当前查询的医生新加列表
  299. doctorList[doctorIndex].Scheduling = scheduleList
  300. }
  301. // 查询过的医生 不展示switch
  302. doctorList[doctorIndex].ShowDeptSwitch = true
  303. this.setData({
  304. doctorList:doctorList
  305. })
  306. },
  307. /**
  308. * 折叠列表
  309. */
  310. foldList(e) {
  311. let doctorIndex = e.currentTarget.dataset.doctorindex
  312. let schedulIndex = e.currentTarget.dataset.schedulindex
  313. let doctorList = this.data.doctorList
  314. doctorList[doctorIndex].Scheduling[schedulIndex].Check = !doctorList[doctorIndex].Scheduling[schedulIndex].Check
  315. this.setData({
  316. doctorList
  317. })
  318. },
  319. })