date-source.js 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411
  1. (function(){
  2. Vue.component('date-scource', {
  3. template: '<section class="mt30" name="date-section">\
  4. <p class="c-f18">就诊日期</p>\
  5. <div class="div-table">\
  6. <div class="table-row">\
  7. <div class="table-cell arrow-cell" :class="{\'active\': curPage!=1}" @click="prePage"><i class="fa fa-caret-left c-f20 c-909090"></i></div>\
  8. <div v-for="(d, index) in planDate" v-show="showCol(index)" class="table-cell">{{d.dStr}} {{d.day}}</div>\
  9. <div class="table-cell arrow-cell" :class="{\'active\': curPage != totalPage}" @click="nextPage"><i class="fa fa-caret-right c-f20 c-909090"></i></div>\
  10. </div>\
  11. <div class="table-row">\
  12. <div class="table-cell arrow-cell c-f16 bgc-ebf4f3">上午</div>\
  13. <div class="table-cell" v-for="(item, index) in amData" v-show="showCol(index)" :class="{\'active\': item.arrangeID == arrangeid && arrangeid!=undefined}" @click="getNumbers(item.arrangeID)">\
  14. <span :class="getColor(item.arrangeStatus, item.numberStatus)">{{getStatusName(item.arrangeStatus, item.numberStatus)}}</span><br/>\
  15. <span class="yy-tag" :class="{\'active\': item.arrangeStatus==1 && item.numberStatus==1}">预约</span>\
  16. </div>\
  17. <div class="table-cell arrow-cell"></div>\
  18. </div>\
  19. <div class="table-row">\
  20. <div class="table-cell arrow-cell c-f16 bgc-ebf4f3">下午</div>\
  21. <div class="table-cell" v-for="(item, index) in pmData" v-show="showCol(index)" :class="{\'active\': item.arrangeID == arrangeid && arrangeid!=undefined}" @click="getNumbers(item.arrangeID)">\
  22. <span :class="getColor(item.arrangeStatus, item.numberStatus)">{{getStatusName(item.arrangeStatus, item.numberStatus)}}</span><br/>\
  23. <span class="yy-tag" :class="{\'active\': item.arrangeStatus==1 && item.numberStatus==1}">预约</span>\
  24. </div>\
  25. <div class="table-cell arrow-cell"></div>\
  26. </div>\
  27. </div>\
  28. <p class="c-f18 mt30">就诊时间</p>\
  29. <div class="clearfix">\
  30. <div v-for="it in numberSource" class="c-20 fl mb20">\
  31. <div class="source-tag c-t-center" :class="{\'active\': registerNumber==it.numberSN}" @click="chooseNumber(it.numberSN, it.modeId)">\
  32. {{it.commendTime || it.commendScope}}\
  33. </div>\
  34. </div>\
  35. </div>\
  36. <div class="mt30 c-t-center mb50">\
  37. <button class="btn btn-primary" @click="submitForm">确认预约</button>\
  38. </div>\
  39. </section>',
  40. props: ['doctorsn', 'arrangeid', 'registerdate'],
  41. data: function(){
  42. return {
  43. planDate: [],
  44. selectedDate: 0,
  45. amData: [],
  46. pmData: [],
  47. numberSource: [],
  48. registerNumber: '',
  49. modeId: '', //号源池模式:1:实时号源池, 0:非实时号源池
  50. baseInfo: {}, //记录医生医院等基础信息
  51. specialPrice: 0, //挂号费(单位:分),
  52. curPage: 1, //当前页
  53. page: 1 , //日期分页,当有号源的日期数超过了7天,则需要分页展示
  54. totalPage: 5,
  55. pageSize: 31
  56. }
  57. },
  58. mounted: function(){
  59. getDoctorInfo(this);
  60. getNumbers(this.arrangeid, this);
  61. },
  62. methods: {
  63. getStatusName: function(arrangeStatus, numberStatus){
  64. return getStatusName(arrangeStatus, numberStatus);
  65. },
  66. getColor: function(arrangeStatus, numberStatus){
  67. return getStatusColor(arrangeStatus, numberStatus);
  68. },
  69. getNumbers: function(code, specialPrice){
  70. if(code && this.arrangeid != code){
  71. getNumbers(code, this);
  72. this.arrangeid = code;
  73. }
  74. },
  75. showCol: function(index){
  76. //默认分页一页展示7条数据,然后显示一个月的数据31天
  77. switch(this.curPage){
  78. case 1:
  79. return index < 7 ? true: false;
  80. break;
  81. case 2:
  82. return index >=7 && index<14 ? true: false;
  83. break;
  84. case 3:
  85. return index >=14 && index<21 ? true: false;
  86. break;
  87. case 4:
  88. return index >=21 && index<28? true: false;
  89. break;
  90. case 5:
  91. return index>=28 ? true : false;
  92. break;
  93. default:
  94. return true;
  95. break;
  96. }
  97. },
  98. chooseNumber: function(id, modeId){
  99. this.registerNumber = id;
  100. this.modeId = modeId;
  101. },
  102. prePage: function(){
  103. if(this.curPage > 1){
  104. this.curPage --;
  105. }
  106. },
  107. nextPage: function(){
  108. if(this.curPage < this.totalPage){
  109. this.curPage ++;
  110. }
  111. },
  112. submitForm: function(){
  113. if(!this.arrangeid){
  114. dialog({
  115. content: "请选择就诊日期",
  116. contentType:'tipsbox',
  117. skin:'bk-popup',
  118. quickClose: true
  119. }).showModal();
  120. return false;
  121. }
  122. if(!this.registerNumber){
  123. dialog({
  124. content: "请选择就诊时间",
  125. contentType:'tipsbox',
  126. skin:'bk-popup',
  127. quickClose: true
  128. }).showModal();
  129. return false;
  130. }
  131. var oauthInfo = JSON.parse(sessionStorage.getItem("oauthInfo"));
  132. if(!oauthInfo){
  133. //要求登录
  134. dialog({
  135. title: "登录提醒",
  136. skin: "my-dialog",
  137. content: "需要登录才可以预约",
  138. okValue: "跳转去登录",
  139. ok: function(){
  140. window.location.href = "../../login/html/login.html";
  141. },
  142. cancelValue: "我知道了",
  143. cancel: function(){}
  144. }).showModal();
  145. return false;
  146. }
  147. submitForm(this);
  148. }
  149. }
  150. });
  151. //获取医生基本信息
  152. function getDoctorInfo(vm){
  153. var params = {
  154. doctorSn: vm.doctorsn
  155. }
  156. appointmentAPI.querySimpleDoctorBySn(params).then(function(res){
  157. if(res.successFlg){
  158. if(res.obj.Code == "10000"){
  159. //触发父类获取医生信息
  160. EventBus.$emit("get-doctor-info", {docInfo: res.obj});
  161. getArrangeDate(vm, res.obj)
  162. vm.baseInfo = res.obj;
  163. }else{
  164. showErrorMessage(res.obj.Message);
  165. }
  166. }else{
  167. showErrorMessage(res.errorMsg);
  168. }
  169. })
  170. }
  171. //获取医生排班信息
  172. function getArrangeDate(vm, docInfo){
  173. var params = {
  174. hospitalId: docInfo.hospitalId, //'2h+klDvGn+Q=',
  175. hosDeptId: docInfo.hosDeptId, //'vp0N0lqGZgA=',
  176. doctorSn: vm.doctorsn, //'1jGMsR3q3nZawh/iQIuzYg==', //科室和医生必选一
  177. registerDate: '', //就诊日期 yyyy-MM-dd
  178. pageIndex: vm.page,
  179. pageSize: vm.pageSize
  180. };
  181. appointmentAPI.queryGhtArrangeWater(params).then(function(res){
  182. if(res.successFlg){
  183. if(res.obj.Code == "10000"){
  184. var list = res.obj.Result;
  185. //先groupby结果,判断有几天号源
  186. var dateGroup = _.groupBy(list, 'registerDate');
  187. //展示整个月的数据
  188. var now = new Date();
  189. var planDate = [],
  190. selectedIndex;
  191. for(i=0; i<31; i++){
  192. var d = new Date();
  193. d.setDate(now.getDate()+i);
  194. var dStr = d.format("yyyy-MM-dd");
  195. planDate.push({
  196. date: dStr,
  197. dStr: d.format("MM/dd"),
  198. day: getWeekDay(d.getDay())
  199. }); //日期记录
  200. //记录选中的日期
  201. if(vm.registerdate == dStr){
  202. selectedIndex = i;
  203. }
  204. var objArr = dateGroup[dStr];
  205. if(objArr && objArr.length > 0){
  206. if(objArr.length == 1){
  207. var obj = objArr[0];
  208. if(obj.timeId == 1){ //1 上午 2下午 3 晚上
  209. vm.amData.push(obj);
  210. vm.pmData.push({
  211. arrangeID: '', //没有排号
  212. arrangeStatus: 0,
  213. });
  214. }else{
  215. vm.pmData.push(obj);
  216. vm.amData.push({
  217. arrangeID: '', //没有排号
  218. arrangeStatus: 0,
  219. });
  220. }
  221. }else if(objArr.length == 2){
  222. for(j=0; j<objArr.length; j++){
  223. var obj = objArr[j];
  224. if(obj.timeId == 1){ //1 上午 2下午 3 晚上
  225. vm.amData.push(obj);
  226. }
  227. if(obj.timeId == 2 || obj.timeId == 3){
  228. vm.pmData.push(obj);
  229. }
  230. }
  231. }
  232. }else{
  233. vm.amData.push({
  234. arrangeID: '', //没有排号
  235. arrangeStatus: 0,
  236. });
  237. vm.pmData.push({
  238. arrangeID: '', //没有排号
  239. arrangeStatus: 0,
  240. });
  241. }
  242. }
  243. vm.planDate = planDate;
  244. if(selectedIndex || selectedIndex == 0){
  245. vm.curPage = parseInt(selectedIndex / 7) + 1;
  246. }
  247. }else{
  248. showErrorMessage(res.obj.Message);
  249. }
  250. }else{
  251. showErrorMessage(res.errorMsg);
  252. }
  253. });
  254. }
  255. //获取号源信息
  256. function getNumbers(code, vm){
  257. var params = {
  258. arrangeID: code
  259. };
  260. appointmentAPI.queryNumbers(params).then(function(res){
  261. if(res.successFlg){
  262. if(res.obj.Code == "10000"){
  263. vm.numberSource = res.obj.Result;
  264. }else{
  265. showErrorMessage(res.Message);
  266. }
  267. }else{
  268. showErrorMessage(res.errorMsg);
  269. }
  270. });
  271. }
  272. //将挂号信息提交给下一个页面去确认
  273. function submitForm(vm){
  274. var dateInfo = {};
  275. var arr = _.where(vm.amData, {arrangeID: parseInt(vm.arrangeid)});
  276. if(arr.length == 0){
  277. arr = _.where(vm.pmData, {arrangeID: parseInt(vm.arrangeid)});
  278. }
  279. dateInfo = arr[0];
  280. var numberInfo = _.findWhere(vm.numberSource, {numberSN: vm.registerNumber});
  281. var patientInfo = JSON.parse(window.sessionStorage.getItem("oauthInfo"));
  282. //请求接口提交挂号单(我们自己系统)
  283. var params = {
  284. patientName: patientInfo.realName,
  285. userId: patientInfo.id,
  286. cardType: 1, //默认身份证
  287. cardNo: patientInfo.idCardNo,
  288. phoneNo: patientInfo.telephone,
  289. hospitalName: vm.baseInfo.hosName,
  290. hospitalId: vm.baseInfo.hospitalId,
  291. deptName: vm.baseInfo.deptName,
  292. deptId: vm.baseInfo.hosDeptId,
  293. doctorName: vm.baseInfo.doctorName,
  294. doctorId: vm.baseInfo.doctorSn,
  295. lczcName: vm.baseInfo.lczcName,
  296. photoUri: vm.baseInfo.photoUri,
  297. registerDate: dateInfo.registerDate,
  298. timeId: dateInfo.timeId,
  299. commendTime: numberInfo.commendTime || numberInfo.commendScope,
  300. serialNo: numberInfo.serialNo,
  301. invalidDate: dateInfo.invalidDate,
  302. originType: 1, //来源类型,1:PC,2:APP,
  303. registerType: 1 //挂号方式,1:预约挂号,2:现场挂号
  304. };
  305. appointmentAPI.createRegistration({entityJson: JSON.stringify(params)}).then(function(res){
  306. if(res.successFlg){
  307. var id = res.obj.id;
  308. //存储这些数据传递去确认页面
  309. window.localStorage.setItem("dateInfo", JSON.stringify(dateInfo));
  310. window.localStorage.setItem("numberInfo", JSON.stringify(numberInfo));
  311. window.localStorage.setItem("baseInfo", JSON.stringify(vm.baseInfo));
  312. //跳转去确认信息页面
  313. window.location.href = "confirm-info.html?id="+id;
  314. }else{
  315. showErrorMessage(res.errorMsg);
  316. }
  317. })
  318. }
  319. function getWeekDay(val){
  320. switch(val){
  321. case 0:
  322. return "周日";
  323. break;
  324. case 1:
  325. return "周一";
  326. break;
  327. case 2:
  328. return "周二";
  329. break;
  330. case 3:
  331. return "周三";
  332. break;
  333. case 4:
  334. return "周四";
  335. break;
  336. case 5:
  337. return "周五";
  338. break;
  339. case 6:
  340. return "周六";
  341. break;
  342. }
  343. }
  344. function getStatusName(arrangeStatus, numberStatus){
  345. //arrangeStatus: 1正常 2停诊 3已取消 4暂停预约,自定义: 5无安排
  346. //numberStatus: 1可约 2已约满或无号源
  347. switch(arrangeStatus){
  348. case 1:
  349. if(numberStatus==1){
  350. return "可预约";
  351. }else{
  352. return "已满"
  353. }
  354. break;
  355. case 2:
  356. return "停诊";
  357. break;
  358. case 3:
  359. return "已取消";
  360. break;
  361. case 4:
  362. return "暂停预约";
  363. break;
  364. default:
  365. return "无安排";
  366. break;
  367. }
  368. }
  369. function getStatusColor(arrangeStatus, numberStatus){
  370. switch(arrangeStatus){
  371. case 1:
  372. if(numberStatus==1){
  373. return "";
  374. }else{
  375. return "c-909090"
  376. }
  377. break;
  378. case 2:
  379. return "c-ffb5b6";
  380. break;
  381. case 3:
  382. case 4:
  383. return "c-909090";
  384. break;
  385. default:
  386. return "c-f3be88";
  387. break;
  388. }
  389. }
  390. function showErrorMessage(content){
  391. layer.msg(content, {
  392. icon: 2,
  393. time: 3000
  394. });
  395. }
  396. })()