const app = getApp(); import yygh from "../../../../config/api/yygh/index.js"; import regeneratorRuntime from "../../../../../utils/runtime.js"; import common from "../../../../../utils/common.js"; import icon from "../../../../../utils/icon.js"; import { pagesPatientFn } from '@/utils'; Page({ data: { iconUrl:icon, isFocus: false, //input是否获取焦点 searchValue: '', //搜索值 searchList: [], //搜索结果 deptListFir: [], //一级科室 deptListFirIndex: -1, //当前一级科室 deptListSec: [], //二级科室 deptListSecIndex: -1, //当前二级科室 pageConfig: {}, //页面配置 serviceId:'', queryData: { HosId: '', ParentDeptCode: "", ServiceId:"" }, modalData: {} }, onLoad: function(options) { this.setData({ pageConfig: common.deepCopy(app.globalData.config.pageConfiguration.yyghDeptList_config), serviceId :options.serviceId || '', 'queryData.HosId': app.globalData.districtId || app.globalData.hosId, 'queryData.ServiceId': options.serviceId || '', }) this.main() }, onShow: function() { }, async main() { let pageConfig = this.data.pageConfig //获取一级科室 let deptListFir = []; let deptListSec = []; let queryData = this.data.queryData; let deptListFirResp = await yygh.queryClinicBaseDept(queryData) if (!common.isEmpty(deptListFirResp)) { deptListFir = deptListFirResp; if (pageConfig.showDeptSec) { // 如果有二级科室 默认取第一个一级科室 queryData.ParentDeptCode = deptListFir[0].DeptCode let deptListSecResp = await yygh.queryClinicBaseDept(queryData) if (!common.isEmpty(deptListSecResp)) { deptListSec = deptListSecResp } } } this.setData({ deptListFir: deptListFir, deptListSec: deptListSec, deptListFirIndex: pageConfig.showDeptSec ? 0 : -1, modalData: pageConfig.modalData, }) // }, /** * 科室点击 */ async deptClick(e) { let pageType = ""; let type = e.currentTarget.dataset.type; // 当前触发方式 fir:一级科室 sec:二级科室 否者为搜索 let pageConfig = this.data.pageConfig // 页面配置 let item = e.currentTarget.dataset.item; let index = e.currentTarget.dataset.index; let deptListSec = this.data.deptListSec; let deptListFirIndex = this.data.deptListFirIndex; let deptListSecIndex = this.data.deptListSecIndex; if (type == 'fir') { //如果点击一级科室 deptListFirIndex = index; if (pageConfig.showDeptSec) { //如果医院有二级科室 deptListSec = [] let queryData = this.data.queryData; queryData.ParentDeptCode = item.DeptCode let resp = await yygh.queryClinicBaseDept(queryData) if (!common.isEmpty(resp)) { deptListSec = resp; deptListSecIndex = -1; } }else{ pageType = 'yyghDoctorList' } } else if (type == 'sec') { //如果点击二级科室 deptListSecIndex = index pageType = 'yyghDoctorList' } else { pageType = 'yyghDoctorList' if (item.SearchType == '2') { /**如果点击医生 跳转到挂号页面*/ pageType = "yyghClinicMsg" } } this.setData({ deptListFirIndex: deptListFirIndex, deptListSecIndex: deptListSecIndex, deptListSec: deptListSec }) // 判断如果不为空就是跳转 if(common.isNotEmpty(pageType)){ // 判断等于跳转医生列表页 且有配置特殊科室续弹窗显示内容 if(pageType == 'yyghDoctorList' && pageConfig.deptShowMode[item.DeptCode]){ common.showModal(pageConfig.deptShowMode[item.DeptCode],()=>{ pagesPatientFn.handleRouter(e, pageType, this.data.serviceId) }) }else{ pagesPatientFn.handleRouter(e, pageType, this.data.serviceId) } } }, /** * 点击搜索 */ async searchClick() { let pageConfig = this.data.pageConfig let searchValue = this.data.searchValue; if (common.isEmpty(searchValue)) { common.showModal('请输入搜索科室或医生') return } let result = [] let queryData = { HosId: app.globalData.districtId || app.globalData.hosId, SearchLike: searchValue, ServiceId:this.data.serviceId, QueryLocal:"1", UseBaseInfo:true, ExcludeOneLv:pageConfig.showDeptSec ? 1 : 0 ,// 是否过滤一级科室, } let resp = await yygh.searchClinicDeptAndDoctor(queryData) if (!common.isEmpty(resp)) { result = resp; } this.setData({ searchList: result }) }, // 搜索科室 async queryDeptList(searchValue) { let queryData = { dept:{ hospitalId: app.globalData.districtId || app.globalData.hosId, deptNameOrPingyinLike:searchValue, status:1 }, deptdoctor:{ doctorServiceGh: 1, displaystatus: 1, }, doctor:{}, } let resp = await yygh.queryDeptList_V2(queryData) if (!common.isEmpty(resp)) { if(this.data.pageConfig.showDeptSec){ resp = resp.filter(item=>item.parientId != -1) } resp = common.changeObj(resp) return resp } return [] }, // 搜索医生 async queryDoctorList(searchValue) { let queryData = { isQueryDeptList: "1",//"是否返回医生的科室列表", doctor: { doctorNameOrPingYinLike:searchValue,//"拼音检索-模糊" status:1 }, dept: { hospitalId: app.globalData.districtId || app.globalData.hosId, status:1 }, deptdoctor: { doctorServiceGh: 1, // "是否开通挂号服务" displaystatus: "1"//"是否启用" } } let resp = await yygh.queryDoctorList_V2(queryData) if (!common.isEmpty(resp)) { let doctorList = [] resp.map(item=>{ item.searchType = '2'//医生数据做一个标识 item.deptList.map(ele =>{ // 方向把当前医生所有的坐诊科室排列出来 doctorList.push({...ele,...item}) }) }) doctorList = common.changeObj(doctorList) return doctorList } return [] }, /** * 输入框聚焦 */ focusFn(e) { let type = e.currentTarget.dataset.type; this.setData({ isFocus: type == 'focus' ? true : !this.data.isFocus, searchValue: type == 'focus' ? this.data.searchValue : '', searchList: type == 'focus' ? this.data.searchList : [], }) }, /** * 输入值获取 */ setVal(e) { let key = e.currentTarget.dataset.key; let value = e.detail.value; this.setData({ [key]: value }) }, /** * 空函数 阻止搜索结果点击冒泡 */ doNothing() { }, /** * ai导诊 历史医生点击 */ optionClick(e) { let type = e.currentTarget.dataset.type; if (type == 'ai') { //点击ai导诊 // 跳转密影 根目录加公众号appid wx.navigateToMiniProgram({ appId: this.data.pageConfig.aiMode.appId, // appid=: 需要自行对接配置相应医院的公众号appId path: this.data.pageConfig.aiMode.path }) } else { //点击历史医生 common.goToUrl('/pagesPatient/st1/business/yygh/yyghHistoryDoctor/yyghHistoryDoctor') } }, // 就诊须知弹窗关闭 modalCancel(){ common.navigateBack(1) }, modalConfirm(){ this.setData({ 'modalData.showModal' :false }) }, modalNoData(){ common.navigateBack(1) } })