registration.js 63 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820
  1. //@ sourceURL=registration.js
  2. var $dataTableHot;
  3. //病人下拉选当前页记录
  4. var pageIndex = 0;
  5. //判断病人列表是否在加载中,防止重复加载
  6. var msg_list_loading = false;
  7. //挂号卡片列表页面下标
  8. var pageIndex = 0;
  9. var LODOP; //声明为全局变量
  10. //默认打印机下标
  11. var printIndex = -1;
  12. var TableInit = function () {
  13. var oTableInit = new Object();
  14. //初始化Table
  15. oTableInit.Init = function () {
  16. $dataTableHot = $('#tb_fee_info').bootstrapTable({
  17. url: '', //请求后台的URL(*)
  18. method: 'post', //请求方式(*)
  19. toolbar: '#toolbar', //工具按钮用哪个容器
  20. striped: true, //是否显示行间隔色
  21. cache: false, //是否使用缓存,默认为true,所以一般情况下需要设置一下这个属性(*)
  22. pagination: false, //是否显示分页(*)
  23. sortable: true, //是否启用排序
  24. sortOrder: "asc", //排序方式
  25. //queryParams: oTableInit.queryParams,//传递参数(*)
  26. sidePagination: "server", //分页方式:client客户端分页,server服务端分页(*)
  27. pageNumber: 1, //初始化加载第一页,默认第一页
  28. pageSize: 10, //每页的记录行数(*)
  29. pageList: [10, 25, 50, 100], //可供选择的每页的行数(*)
  30. search: false, //是否显示表格搜索,此搜索是客户端搜索,不会进服务端,所以,个人感觉意义不大
  31. strictSearch: true,
  32. showColumns: false, //是否显示所有的列
  33. showRefresh: false, //是否显示刷新按钮
  34. minimumCountColumns: 2, //最少允许的列数
  35. clickToSelect: true, //是否启用点击选中行
  36. uniqueId: "ID", //每一行的唯一标识,一般为主键列
  37. showToggle: false, //是否显示详细视图和列表视图的切换按钮
  38. cardView: false, //是否显示详细视图
  39. detailView: false,
  40. ajaxOptions: {
  41. headers: {
  42. 'Accept': 'application/json',
  43. 'Authorization': 'Bearer ' + localStorage.getItem("token")
  44. }
  45. },
  46. columns: [
  47. // {
  48. // checkbox: true
  49. // },
  50. {
  51. field: 'name',
  52. title: '名称',
  53. align: "center",
  54. valign: 'middle',
  55. //sortable: true
  56. }, {
  57. field: 'money',
  58. title: '金额(元)',
  59. align: "center",
  60. valign: 'middle',
  61. //sortable: true
  62. }, {
  63. field: 'moneyReceived',
  64. title: '实收金额(元)',
  65. align: "center",
  66. valign: 'middle',
  67. // sortable: true
  68. }],
  69. responseHandler: function (res) {
  70. if (res == '401' || res == 401) {
  71. window.location.href = '/thmz/login/view'
  72. return;
  73. }
  74. var ress = eval(res);
  75. if (ress.code == -1) {
  76. new PNotify({
  77. title: '错误提示',
  78. text: ress.message,
  79. type: 'error',
  80. hide: true,
  81. styling: 'bootstrap3'
  82. });
  83. return {
  84. "total": 0,//总页数
  85. "rows": {} //数据
  86. };
  87. }
  88. return {
  89. "total": ress.pageViewVO.total,//总页数
  90. "rows": ress.pageViewVO.data //数据
  91. };
  92. },
  93. });
  94. };
  95. return oTableInit;
  96. };
  97. $(function () {
  98. initGenderSelect();
  99. initResponceTypeSelect();
  100. // var birthDay = $('#birthDayGroup').datetimepicker({
  101. // format: 'yyyy-mm-dd',
  102. // language: 'zh-CN',
  103. // minView: "month",
  104. // }).on('changeDate', changeDate);
  105. // var editUserBirthDay = $('#editUserBirthDayGroup').datetimepicker({
  106. // format: 'yyyy-mm-dd',
  107. // language: 'zh-CN',
  108. // minView: "month",
  109. // });
  110. //设置挂号窗口的高度
  111. var width = $('#confirmFee').css("width");
  112. var widthNum = parseInt(width);
  113. widthNum -= 24;
  114. $("#confirmFee").css("width", widthNum + "px");
  115. init_daterangepicker();
  116. //1.初始化Table
  117. var oTable = new TableInit();
  118. oTable.Init();
  119. formatCheck();
  120. //默认光标在卡号输入框
  121. $("#cardNo").focus();
  122. //根据病人姓名输入框内容动态加载病人列表
  123. //initUserList();
  124. //卡号输入改变事件
  125. cardNoChange();
  126. //病人姓名输入改变事件
  127. // userNameChange();
  128. //数据校验
  129. init_validator();
  130. //时间区间
  131. initMzWorkTime();
  132. //初始门诊收银方式下拉选
  133. initChequeType("payType");
  134. /**
  135. * 清空
  136. */
  137. $("#clearRegistration").on("click", function (t) {
  138. clearRegistration();
  139. });
  140. /**
  141. * 增加收款方式按钮事件
  142. */
  143. $("#addPayType").on("click", function (t) {
  144. var payTypeIndex = $("#payTypeIndex").val();
  145. var payTypeId = "payType_" + payTypeIndex;
  146. var html = '<div class="item form-group"><div class="col-md-12 col-sm-12 col-xs-12"><div class="col-md-2 col-sm-2 col-xs-12"></div><label class="col-md-3 col-sm-3 col-xs-12"><select class="form-control selectpicker show-tick" required="true" id="' + payTypeId + '"></select></label><div class="col-md-3 col-sm-3 col-xs-12"><input class="form-control col-md-5 col-xs-12" type="number" data-placement="bottom-right" min="0"></div><a style="line-height: 34px;cursor: pointer;" onclick="closeThisParent(this)"><i class="fa fa-close"></i></a></div></div>';
  147. $("#changeAmountParent").before(html);
  148. initChequeType(payTypeId)
  149. payTypeIndex = payTypeIndex + 1;
  150. $("#payTypeIndex").val(payTypeIndex);
  151. });
  152. // //当ic卡号输入框失去光标后,重置光标到卡号输入框
  153. // $("#cardNo").blur(function () {
  154. // var focus = !($("#userName").is(":focus") || $("#age").is(":focus") || $("#birthDay").is(":focus") || $("#phoneNum").is(":focus") || $("#idCard").is(":focus") || $("#address").is(":focus"));
  155. // if (focus && $("#cardNo").val() == null || $("#cardNo").val() == "") {
  156. // //默认光标在卡号输入框
  157. // $("#cardNo").focus();
  158. // }
  159. // });
  160. /**
  161. * 保存挂号信息
  162. */
  163. $("#saveConfirmFee").on("click", function (t) {
  164. var cash=$("#cash").val();
  165. if(cash==null || cash ==""){
  166. new PNotify({
  167. title: '错误提示',
  168. text: "金额不能为空!",
  169. type: 'error',
  170. hide: false,
  171. styling: 'bootstrap3'
  172. });
  173. return;
  174. }
  175. var realMoney = parseFloat($("#realMoney").val());
  176. realMoney = realMoney.toFixed(2);
  177. if (parseFloat(cash) < realMoney) {
  178. return;
  179. }
  180. var patientId = $("#patientId").val();
  181. if (patientId == null || patientId == "") {
  182. savePatient(true);
  183. } else {
  184. saveMzyReqrec();
  185. }
  186. });
  187. // /**
  188. // * 设置窗口号
  189. // */
  190. // $("#editWindows").on("click", function (t) {
  191. // $.ajax({
  192. // type: "GET",
  193. // url: '/thmz/getLastWindowsByCurrentUser',
  194. // contentType: "application/json;charset=UTF-8",
  195. // dataType: "json",
  196. // headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
  197. // success: function (res) {
  198. // if (res == '401' || res == 401) {
  199. // window.location.href = '/thmz/login/view'
  200. // return;
  201. // }
  202. // if (res.code == 0) {
  203. // $("#windowsNum").val(res.data.windowsNo)
  204. // } else {
  205. // new PNotify({
  206. // title: '错误提示',
  207. // text: res.message,
  208. // type: 'error',
  209. // hide: true,
  210. // styling: 'bootstrap3'
  211. // });
  212. // }
  213. // }
  214. // });
  215. // $("#editWindowsModal").modal();
  216. // });
  217. /**
  218. * 患者信息修改
  219. */
  220. $("#saveEditUser").on("click", function (t) {
  221. modifyPatient();
  222. });
  223. /**
  224. * 挂号列表中的科室和医生列表初始化
  225. */
  226. initListSelect();
  227. // $("#editPrint").on("click", function (t) {
  228. // CreatePrinterList();
  229. // $("#editPrintModal").modal();
  230. // });
  231. //每隔三秒读一次身份证
  232. setInterval(function () {
  233. new Device().startFun();
  234. }, 3000);
  235. // $("#birthDay").keypress(function () { // keypress:输入框每获取一个字符,就触发一次该事件。
  236. // var birthDay= $("#birthDay").val();
  237. // birthDay='19880613';
  238. //
  239. // });
  240. $("#birthDay").change(function (e) {
  241. var birthDay = $("#birthDay").val();
  242. if (birthDay.length == 8 && birthDay.indexOf("-") <= 0) {
  243. birthDay = birthDay.substring(0, 4) + "-" + birthDay.substring(4, 6) + "-" + birthDay.substring(6);
  244. $("#birthDay").val(birthDay);
  245. }
  246. var dateFormat = /^(\d{4})-(\d{2})-(\d{2})$/;
  247. if (!dateFormat.test(birthDay)) {
  248. new PNotify({
  249. title: '错误提示',
  250. text: '生日日期错误',
  251. type: 'error',
  252. hide: true,
  253. styling: 'bootstrap3'
  254. });
  255. }
  256. var arr = birthDay.split("-");
  257. if (!checkDate(arr[0], arr[1], arr[2])) {
  258. new PNotify({
  259. title: '错误提示',
  260. text: '生日日期错误',
  261. type: 'error',
  262. hide: true,
  263. styling: 'bootstrap3'
  264. });
  265. }
  266. var returnAge = jsGetAge(birthDay);
  267. $("#age").val(returnAge);
  268. $("#age").blur();
  269. });
  270. $("#editUserBirthDay").change(function (e) {
  271. var editUserBirthDay = $("#editUserBirthDay").val();
  272. if (editUserBirthDay.length == 8 && editUserBirthDay.indexOf("-") <= 0) {
  273. editUserBirthDay = editUserBirthDay.substring(0, 4) + "-" + editUserBirthDay.substring(4, 6) + "-" + editUserBirthDay.substring(6);
  274. $("#editUserBirthDay").val(editUserBirthDay);
  275. }
  276. var dateFormat = /^(\d{4})-(\d{2})-(\d{2})$/;
  277. if (!dateFormat.test(editUserBirthDay)) {
  278. new PNotify({
  279. title: '错误提示',
  280. text: '生日日期错误',
  281. type: 'error',
  282. hide: true,
  283. styling: 'bootstrap3'
  284. });
  285. }
  286. var arr = editUserBirthDay.split("-");
  287. if (!checkDate(arr[0], arr[1], arr[2])) {
  288. new PNotify({
  289. title: '错误提示',
  290. text: '生日日期错误',
  291. type: 'error',
  292. hide: true,
  293. styling: 'bootstrap3'
  294. });
  295. }
  296. var returnAge = jsGetAge(editUserBirthDay);
  297. $("#editUserAge").val(returnAge);
  298. });
  299. $("#idCard").change(function (e) {
  300. queryUserInfoBySocialNo();
  301. });
  302. $("#editUserIdCard").change(function (e) {
  303. var editUserIdCard = $("#editUserIdCard").val();
  304. var birthday = editUserIdCard.substring(6, 14);
  305. birthday = birthday.substring(0, 4) + "-" + birthday.substring(4, 6) + "-" + birthday.substring(6);
  306. $("#editUserBirthDay").val(birthday);
  307. var returnAge = jsGetAge(birthday);
  308. $("#editUserAge").val(returnAge);
  309. var gender = editUserIdCard.substring(16, 17);
  310. if (gender % 2 == 0) {
  311. $("#editUserGender").val(2);
  312. } else {
  313. $("#editUserGender").val(1);
  314. }
  315. $('#editUserGender').selectpicker('refresh');
  316. });
  317. $("#phoneNum").change(function (e) {
  318. queryUserInfoByphoneNo();
  319. });
  320. $("#userName").change(function (e) {
  321. queryUserInfoByName();
  322. });
  323. });
  324. //判断给定日期是否合法
  325. function checkDate(year, month, date) {
  326. var now = new Date(year, month - 1, date);
  327. if (now.getDate() == date && now.getFullYear() == year && now.getMonth() == (month - 1)) {
  328. return true;
  329. }
  330. return false;
  331. }
  332. // function CreatePageList() {
  333. // LODOP = getLodop();
  334. // LODOP.PRINT_INITA(6, 0, "92mm", "120mm", "泰和门诊发票打印");
  335. // //获取纸张大小数,用于进行遍历
  336. // var strPageSizeList = LODOP.GET_PAGESIZES_LIST($('#printSelect').val(), "\n");
  337. // var html = "";
  338. // var arr = strPageSizeList.split("\n");
  339. // for (var i = 0; i < arr.length; i++) {
  340. // html += "<option value='" + arr[i] + "'>" + arr[i] + "</option>";
  341. // }
  342. // $('#pageSelect').html(html);
  343. // $('#pageSelect').selectpicker('refresh');
  344. // }
  345. /**
  346. * 初始化性别下拉选
  347. */
  348. function initGenderSelect() {
  349. $(".selectpicker").selectpicker({
  350. dropuAuto: false
  351. });
  352. var gender = '<option value="1">男</option><option value="2">女</option><option value="0">未知</option>';
  353. $('#gender').html(gender);
  354. $('#gender').selectpicker('refresh');
  355. $('#editUserGender').html(gender);
  356. $('#editUserGender').selectpicker('refresh');
  357. }
  358. /**
  359. * 初始化病人身份类别下拉选
  360. */
  361. function initResponceTypeSelect() {
  362. $(".selectpicker").selectpicker({
  363. dropuAuto: false
  364. });
  365. $.ajax({
  366. type: "GET",
  367. url: '/thmz/getMzResponceType',
  368. contentType: "application/json;charset=UTF-8",
  369. dataType: "json",
  370. headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
  371. success: function (res) {
  372. if (res == '401' || res == 401) {
  373. window.location.href = '/thmz/login/view'
  374. return;
  375. }
  376. if (res.code == 0) {
  377. res.data.forEach(function (item, index) {
  378. var html = '<option value="' + item.code + '">' + item.name + '</option>';
  379. $('#patientsNature').append(html);
  380. $('#editUserPatientsNature').append(html);
  381. });
  382. $('#patientsNature').selectpicker('refresh');
  383. $('#editUserPatientsNature').selectpicker('refresh');
  384. } else {
  385. new PNotify({
  386. title: '错误提示',
  387. text: res.message,
  388. type: 'error',
  389. hide: true,
  390. styling: 'bootstrap3'
  391. });
  392. }
  393. }
  394. });
  395. }
  396. /**
  397. * 初始科室下拉选
  398. * @param ampm 时间段区间
  399. */
  400. function initDeptPlus() {
  401. //科室列表
  402. $.ajax({
  403. type: "GET",
  404. url: '/thmz/getUnitCodeByRequestDay?ampm=' + $("#ampm").val(),
  405. dataType: "json",
  406. headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
  407. success: function (data) {
  408. if (data == '401' || data == 401) {
  409. window.location.href = '/thmz/login/view'
  410. return;
  411. }
  412. var html = '';
  413. $.each(data.data, function (commentIndex, comment) {
  414. html += '<option value="' + comment.code + '">' + comment.name + '(' + comment.pyCode + ')</option>';
  415. });
  416. $('#deptNo').empty();
  417. $('#deptNo').html(html);
  418. $('#deptNo').selectpicker('refresh');
  419. $('#chargeType').empty();
  420. $('#chargeType').selectpicker('refresh');
  421. emptyInput();
  422. }
  423. });
  424. }
  425. /**
  426. * 初始医生下拉选
  427. * @param ampm 时间段区间
  428. */
  429. function initEmployee() {
  430. //医生列表
  431. $.ajax({
  432. type: "GET",
  433. url: '/thmz/getDoctorCodeByRequestDay?unitCode=' + $('#deptNo').val() + "&ampm=" + $("#ampm").val() + "&chargeType=" + $("#chargeType").val(),
  434. dataType: "json",
  435. headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
  436. success: function (res) {
  437. if (res == '401' || res == 401) {
  438. window.location.href = '/thmz/login/view'
  439. return;
  440. }
  441. var html = '';
  442. var defaultCode = null;
  443. $.each(res.data, function (commentIndex, comment) {
  444. var employeeName =comment.employee.employeeName;
  445. if(comment.leftNum!=null){
  446. employeeName=employeeName+" 余号("+comment.leftNum+")"
  447. }
  448. html += '<option value="' + comment.employee.employeeCode + '" data-chargeType="' + comment.chargeType + '" data-checkFee="' + comment.checkFee + '" data-mzyRequestId="' + comment.mzyRequestId + '">' + employeeName + '</option>';
  449. if (res.data.length == 1) {
  450. //如果只有一个号别,默认选中
  451. defaultCode = comment.employee.employeeCode;
  452. }
  453. });
  454. $('#doctor').empty();
  455. $('#doctor').html(html);
  456. $('#doctor').selectpicker('refresh');
  457. //validator.checkAll($("#regi_form"));
  458. if (defaultCode != null) {
  459. //如果有无需选择医生的选项,默认选择
  460. $('#doctor').selectpicker('val', defaultCode);
  461. $('#doctor').selectpicker('refresh');
  462. fitFee();
  463. }
  464. }
  465. });
  466. }
  467. /**
  468. * 初始门诊时间区间下拉选
  469. */
  470. function initMzWorkTime() {
  471. $.ajax({
  472. type: "GET",
  473. url: '/thmz/getMzWorkTime',
  474. dataType: "json",
  475. headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
  476. success: function (res) {
  477. if (res == '401' || res == 401) {
  478. window.location.href = '/thmz/login/view'
  479. return;
  480. }
  481. var html = '';
  482. var ampm = null;
  483. $.each(res.data, function (commentIndex, comment) {
  484. html += '<option value="' + comment.code + '">' + comment.name + '</option>';
  485. if (ampm == null || (ampm != "a" && ampm != "p")) {
  486. var startTime = paseToFullTime(comment.startTime);
  487. var endTime = paseToFullTime(comment.endTime);
  488. if (range(startTime, endTime)) {
  489. ampm = comment.code;
  490. }
  491. }
  492. });
  493. $('#ampm').empty(); //清空resText里面的所有内容
  494. $('#ampm').html(html);
  495. $('#ampm').selectpicker('refresh');
  496. $("#ampm").selectpicker('val', ampm);
  497. $('#ampm').selectpicker('refresh');
  498. initDeptPlus();
  499. }
  500. });
  501. }
  502. /**
  503. * 初始门诊号别下拉选
  504. */
  505. function initChargeType() {
  506. $.ajax({
  507. type: "GET",
  508. url: '/thmz/getChargeTypeByRequestDay?unitCode=' + $('#deptNo').val() + "&ampm=" + $("#ampm").val(),
  509. dataType: "json",
  510. headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
  511. success: function (res) {
  512. if (res == '401' || res == 401) {
  513. window.location.href = '/thmz/login/view'
  514. return;
  515. }
  516. var html = '';
  517. var defaultCode = null;
  518. $.each(res.data, function (commentIndex, comment) {
  519. if (res.data.length == 1) {
  520. //如果只有一个号别,默认选中
  521. defaultCode = comment.code;
  522. }
  523. html += '<option value="' + comment.code + '">' + comment.name + '</option>';
  524. });
  525. $('#chargeType').empty(); //清空resText里面的所有内容
  526. $('#chargeType').html(html);
  527. $('#chargeType').selectpicker('refresh');
  528. if (defaultCode != null) {
  529. //如果有默认选项,默认选择
  530. $('#chargeType').selectpicker('val', defaultCode);
  531. $('#chargeType').selectpicker('refresh');
  532. initEmployee();
  533. }
  534. validator.checkAll($("#regi_form"));
  535. emptyInput();
  536. }
  537. });
  538. }
  539. /**
  540. * 设置挂号费等费用
  541. */
  542. function fitFee() {
  543. var chargeType = $('#doctor').find("option:selected").attr('data-chargeType');
  544. var checkFee = $('#doctor').find("option:selected").attr('data-checkFee');
  545. $("#checkFee").val(checkFee);
  546. $("#amountMoney").text(checkFee);
  547. $("#amountMoneyConfirm").text(checkFee);
  548. $("#realMoney").val(checkFee);
  549. $("#cash").val(checkFee);
  550. $("#changeAmount").val(0);
  551. $.ajax({
  552. type: "GET",
  553. url: '/thmz/getMzChargeTypeByCode?code=' + chargeType,
  554. dataType: "json",
  555. headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
  556. success: function (res) {
  557. if (res == '401' || res == 401) {
  558. window.location.href = '/thmz/login/view'
  559. return;
  560. }
  561. $("#registrationFee").val(res.data.reqFee);
  562. $("#hospitalFee").val(res.data.clinicFee);
  563. checkFee = parseFloat(checkFee) + parseFloat(res.data.reqFee) + parseFloat(res.data.clinicFee);
  564. $("#amountMoney").text(checkFee);
  565. $("#amountMoneyConfirm").text(checkFee);
  566. $("#realMoney").val(checkFee);
  567. $("#cash").val(checkFee);
  568. validator.checkAll($("#regi_form"));
  569. }
  570. });
  571. }
  572. /**
  573. * 初始门诊收银方式下拉选
  574. */
  575. function initChequeType(payType) {
  576. $.ajax({
  577. type: "GET",
  578. url: '/thmz/getAllZdChequeTypeForMz',
  579. dataType: "json",
  580. headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
  581. success: function (res) {
  582. if (res == '401' || res == 401) {
  583. window.location.href = '/thmz/login/view'
  584. return;
  585. }
  586. var html = '';
  587. $.each(res.data, function (commentIndex, comment) {
  588. html += '<option value="' + comment.code + '">' + comment.name + '</option>';
  589. });
  590. $('#' + payType).empty();
  591. $('#' + payType).html(html);
  592. $('#' + payType).selectpicker('refresh');
  593. $('#' + payType).selectpicker('val', 1);
  594. $('#' + payType).selectpicker('refresh');
  595. }
  596. });
  597. }
  598. /**
  599. * 日期值改变修改年龄字段
  600. * @param ev
  601. */
  602. function changeDate(ev) {
  603. }
  604. /**
  605. * 列表类型按钮切换事件
  606. * @param object
  607. */
  608. function titleButtonChange(object) {
  609. $("#regi_List_btn_group").find("button").each(function (index, element) {
  610. if ($(element).hasClass("btn-primary")) {
  611. $(element).removeClass("btn-primary").addClass("btn-default");
  612. }
  613. });
  614. $(object).removeClass("btn-default").addClass("btn-primary");
  615. loadRegistrationList(true);
  616. }
  617. /**
  618. * 表格类型切换事件 卡片展示或者列表形式
  619. */
  620. function listTypeChange(object) {
  621. //var indexNum = 0;
  622. $("#regi_List_type").find("button").each(function (index, element) {
  623. if ($(element).hasClass("btn-primary")) {
  624. $(element).removeClass("btn-primary").addClass("btn-default");
  625. }
  626. // if (object == element) {
  627. // indexNum = index;
  628. // }
  629. });
  630. $(object).removeClass("btn-default").addClass("btn-primary");
  631. loadRegistrationList(true);
  632. }
  633. /**
  634. * 打开编辑用户信息窗口
  635. * @param data
  636. */
  637. function editUserModal(data) {
  638. $("#editUserModal").modal();
  639. if (data == null) {
  640. data = $("#patientId").val();
  641. }
  642. $.ajax({
  643. type: "GET",
  644. url: '/thmz/getByPatientId?patientId=' + data,
  645. contentType: "application/json;charset=UTF-8",
  646. dataType: "json",
  647. headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
  648. success: function (res) {
  649. if (res == '401' || res == 401) {
  650. window.location.href = '/thmz/login/view'
  651. return;
  652. }
  653. if (res.code == 0) {
  654. if (res.data != null) {
  655. //延时调用,因为当前弹框还没有加载出来,校验规则无法获取光标与模拟光标丢失事件,延时可以等弹框加载出来后模拟事件
  656. setTimeout(function () {
  657. fillPlusPatinet(res.data);
  658. }, 400);
  659. }
  660. } else {
  661. new PNotify({
  662. title: '错误提示',
  663. text: res.message,
  664. type: 'error',
  665. hide: true,
  666. styling: 'bootstrap3'
  667. });
  668. }
  669. }
  670. });
  671. }
  672. /**
  673. * 打开打印内容窗口
  674. * @param data
  675. */
  676. function printModal(data) {
  677. $("#printOrPreviewModal").modal("hide");
  678. $("#printModal").modal();
  679. }
  680. /**
  681. * 打开收费窗口
  682. * @param data
  683. */
  684. function confirmFeeModal() {
  685. var validatorResult = validator.checkAll($("#regi_form"));
  686. if (!validatorResult) {
  687. return;
  688. }
  689. $('#payType').selectpicker('val', 1);
  690. $('#payType').selectpicker('refresh');
  691. var prevAll = $("#changeAmountParent").prevAll();
  692. while (prevAll.length > 2) {
  693. $("#changeAmountParent").prev().remove();
  694. prevAll = $("#changeAmountParent").prevAll();
  695. }
  696. $("#realMoney").val($("#amountMoneyConfirm").text());
  697. $("#cash").val($("#amountMoneyConfirm").text());
  698. //$("#cash").val(null);
  699. $("#confirmFeeModal").modal();
  700. }
  701. /**
  702. * checkBox样式
  703. */
  704. function formatCheck() {
  705. if ($("input.flat")[0]) {
  706. $(document).ready(function () {
  707. $('input.flat').iCheck({
  708. checkboxClass: 'icheckbox_flat-blue',
  709. radioClass: 'iradio_flat-blue'
  710. });
  711. });
  712. }
  713. }
  714. /**
  715. * 卡号有变化后查询病人信息
  716. */
  717. function queryUserInfoByCardNo() {
  718. var cardNo = $("#cardNo").val();
  719. var index =cardNo.indexOf("-");
  720. if ((index > 0 && index==cardNo.length-2) || cardNo.length == 8) {
  721. $("#cardNo").attr("title", cardNo);
  722. $.ajax({
  723. type: "GET",
  724. url: '/thmz/getByIcCardNo?icCardNo=' + cardNo,
  725. contentType: "application/json;charset=UTF-8",
  726. dataType: "json",
  727. headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
  728. success: function (res) {
  729. if (res == '401' || res == 401) {
  730. window.location.href = '/thmz/login/view'
  731. return;
  732. }
  733. if (res.code == 0) {
  734. if (res.data != null) {
  735. $("#cardNo").blur();
  736. $("#userName").val(res.data.name);
  737. $("#userName").blur();
  738. $("#userNameReadOnly").val(res.data.name);
  739. $("#age").val(res.data.age);
  740. $("#age").blur();
  741. $("#gender").selectpicker('val', res.data.sex);
  742. $("#gender").selectpicker('refresh');
  743. $("#gender").blur();
  744. $("#birthDayReadonly").val(res.data.birthDayStr);
  745. $("#birthDayReadonly").attr("title", res.data.birthDayStr);
  746. $("#birthDay").val(res.data.birthDayStr);
  747. $("#birthDay").blur();
  748. $("#phoneNum").val(res.data.phoneNo);
  749. $("#phoneNum").attr("title", res.data.phoneNo);
  750. $("#phoneNum").blur();
  751. $("#patientsNature").selectpicker('val', res.data.responseType);//默认选中
  752. $('#patientsNature').selectpicker('refresh');
  753. $("#patientsNature").blur();
  754. $("#idCard").val(res.data.socialNo);
  755. $("#idCard").attr("title", res.data.socialNo);
  756. $("#idCard").blur();
  757. $("#address").val(res.data.address);
  758. $("#address").blur();
  759. $("#patientId").val(res.data.patientId);
  760. if (res.data.name != null && res.data.name != "") {
  761. $("#editUser").show();
  762. $("#clearIcCardNo").show();
  763. }
  764. readonlyOrNot(true);
  765. $("#saveUser").hide();
  766. } else {
  767. $("#saveUser").show();
  768. $("#newCardModal").modal();
  769. $(document).keydown(function (event) { //监听键盘按下时的事件
  770. if (event.keyCode == 13) {
  771. //回车键
  772. $('#newCardModal').modal('hide');
  773. }
  774. });
  775. }
  776. } else {
  777. new PNotify({
  778. title: '错误提示',
  779. text: res.message,
  780. type: 'error',
  781. hide: true,
  782. styling: 'bootstrap3'
  783. });
  784. }
  785. }
  786. });
  787. }
  788. }
  789. /**
  790. * 卡号输入改变事件
  791. */
  792. function cardNoChange() {
  793. if (window.ActiveXObject || "ActiveXObject" in window) {
  794. $("#cardNo").on('input propertychange', function () {
  795. queryUserInfoByCardNo();
  796. });
  797. } else {
  798. $("#cardNo").on('input οninput', function () {
  799. queryUserInfoByCardNo();
  800. });
  801. }
  802. }
  803. /**
  804. * 病人姓名输入改变事件
  805. */
  806. function userNameChange() {
  807. if (window.ActiveXObject || "ActiveXObject" in window) {
  808. $("#userName").on('input propertychange', function () {
  809. refeshPatinetList(true);
  810. });
  811. } else {
  812. $("#userName").on('input οninput', function () {
  813. refeshPatinetList(true);
  814. });
  815. }
  816. }
  817. /**
  818. * 校验收款金额
  819. */
  820. function checkFee() {
  821. var cash = parseFloat($("#cash").val());
  822. var realMoney = parseFloat($("#realMoney").val());
  823. realMoney = realMoney.toFixed(2);
  824. $("#realMoney").val(realMoney)
  825. if (cash < realMoney) {
  826. new PNotify({
  827. title: '错误提示',
  828. text: "收款金额不能少于实收金额!",
  829. type: 'error',
  830. hide: true,
  831. styling: 'bootstrap3'
  832. });
  833. return;
  834. } else if (cash > realMoney) {
  835. if ($("#payType").val() == 1) {
  836. var changeAmount = cash - realMoney;
  837. $("#changeAmount").val(changeAmount.toFixed(2));
  838. } else {
  839. new PNotify({
  840. title: '错误提示',
  841. text: "非现金收款金额不能大于实收金额!",
  842. type: 'error',
  843. hide: true,
  844. styling: 'bootstrap3'
  845. });
  846. return;
  847. }
  848. }
  849. //计算和设置折扣比例
  850. var amountMoneyConfirm = parseFloat($("#amountMoneyConfirm").text());
  851. var discount = 100;
  852. if (realMoney < amountMoneyConfirm) {
  853. discount = realMoney / amountMoneyConfirm * 100;
  854. }
  855. $("#discount").text(discount.toFixed(2))
  856. }
  857. /**
  858. * 根据病人姓名输入框内容动态加载病人列表
  859. */
  860. function initUserList() {
  861. //var width=$("#userName").css("width");
  862. var settings = {
  863. trigger: 'click',
  864. content: '',
  865. width: 170,
  866. multi: true,
  867. closeable: false,
  868. style: '',
  869. delay: 300,
  870. padding: true,
  871. height: 300
  872. };
  873. var webuiPopover = $('#userName').webuiPopover('destroy').webuiPopover(settings);
  874. //用户姓名选中事件
  875. $("#userName").on("click", function (t) {
  876. if ($(webuiPopover).css("display") == "block") {
  877. refeshPatinetList(true);
  878. }
  879. });
  880. }
  881. /**
  882. * 刷新病人列表
  883. */
  884. function refeshPatinetList(flag) {
  885. //如果是重新加载病人列表,需要重置下标
  886. if (flag) {
  887. //重置下标
  888. pageIndex = 0;
  889. msg_list_loading = true;
  890. }
  891. var userName = $('#userName').val();
  892. if (!(userName == null || userName == "" || isChinese(userName))) {
  893. return;
  894. }
  895. $.ajax({
  896. type: "GET",
  897. url: '/thmz/getPatientMiByName?name=' + userName + "&pageIndex=" + pageIndex,
  898. contentType: "application/json;charset=UTF-8",
  899. dataType: "json",
  900. headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
  901. success: function (res) {
  902. if (res == '401' || res == 401) {
  903. window.location.href = '/thmz/login/view'
  904. return;
  905. }
  906. if (res.code == 0) {
  907. if (res.data != null && res.data.length > 0) {
  908. $("#webuiPopover0").css("display", "block");
  909. var html = '<div class="list-group">';
  910. for (var i = 0; i < res.data.length; i++) {
  911. var mzPatientMi = res.data[i];
  912. html += '<a href="#" class="list-group-item list-group-item-action" onclick="fillPatinet(\'' + mzPatientMi.patientId + '\')">';
  913. var sex = "未知";
  914. if (mzPatientMi.sex == 1) {
  915. html += '<img src="/thmz/images/boy.png"/>'
  916. sex = "男";
  917. } else if (mzPatientMi.sex == 2) {
  918. html += '<img src="/thmz/images/girl.png"/>'
  919. sex = "女";
  920. } else if (mzPatientMi.sex == 0 || mzPatientMi.sex == null) {
  921. html += '<img src="/thmz/images/girl_or_boy.png"/>'
  922. sex = "未知";
  923. }
  924. html += '<div>' + mzPatientMi.name + '&nbsp;' + sex + '&nbsp;';
  925. if (mzPatientMi.age != null && mzPatientMi.age != "") {
  926. html += mzPatientMi.age + '岁';
  927. } else {
  928. html += '**岁';
  929. }
  930. if (mzPatientMi.phoneNo != null && mzPatientMi.phoneNo != "") {
  931. html += '<span>' + mzPatientMi.phoneNo + '</span>';
  932. }
  933. html += '</div></a>';
  934. }
  935. html += '</div>';
  936. if (flag) {
  937. $("div.webui-popover-content").html("");
  938. }
  939. $("div.webui-popover-content").append(html);
  940. $("div.arrow").css("left", "23px");
  941. refeshPatinetListScrollEvent();
  942. } else {
  943. $("#webuiPopover0").css("display", "none");
  944. }
  945. }
  946. //查询完成,设置加载完成
  947. msg_list_loading = false;
  948. }
  949. });
  950. }
  951. /**
  952. * 病人下拉列表滚动条滚动到底部时继续加载新纪录
  953. */
  954. function refeshPatinetListScrollEvent() {
  955. $('.webui-popover-content').scroll(function (event) {
  956. var top = $(this).scrollTop();
  957. var height = $(this).height();
  958. var scrollHeight = $(this).get(0).scrollHeight;
  959. if (scrollHeight <= top + height) {
  960. if (!msg_list_loading) {
  961. msg_list_loading = true;
  962. pageIndex = pageIndex + 1;
  963. refeshPatinetList(false);
  964. }
  965. }
  966. });
  967. }
  968. /**
  969. * 按照病人id查询病人信息
  970. * @param patientId
  971. */
  972. function fillPatinet(patientId) {
  973. if (patientId == null || patientId == "") {
  974. return;
  975. }
  976. $.ajax({
  977. type: "GET",
  978. url: '/thmz/getByPatientId?patientId=' + patientId,
  979. contentType: "application/json;charset=UTF-8",
  980. dataType: "json",
  981. headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
  982. success: function (res) {
  983. if (res == '401' || res == 401) {
  984. window.location.href = '/thmz/login/view'
  985. return;
  986. }
  987. if (res.code == 0) {
  988. if (res.data != null) {
  989. $("#cardNo").val(res.data.icCardNo);
  990. $("#cardNo").attr("title", res.data.icCardNo);
  991. $("#cardNo").blur();
  992. $("#userName").val(res.data.name);
  993. $("#userName").blur();
  994. $("#userNameReadOnly").val(res.data.name);
  995. $("#age").val(res.data.age);
  996. $("#age").blur();
  997. $("#gender").selectpicker('val', res.data.sex);
  998. $("#gender").selectpicker('refresh');
  999. $("#gender").blur();
  1000. $("#birthDayReadonly").val(res.data.birthDayStr);
  1001. $("#birthDayReadonly").attr("title", res.data.birthDayStr);
  1002. $("#birthDayReadonly").blur();
  1003. $("#birthDay").val(res.data.birthDayStr);
  1004. $("#birthDay").blur();
  1005. $("#phoneNum").val(res.data.phoneNo);
  1006. $("#phoneNum").attr("title", res.data.phoneNo);
  1007. $("#phoneNum").blur();
  1008. $("#patientsNature").selectpicker('val', res.data.responseType);//默认选中
  1009. $('#patientsNature').selectpicker('refresh');
  1010. $("#patientsNature").blur();
  1011. $("#idCard").val(res.data.socialNo);
  1012. $("#idCard").attr("title", res.data.socialNo);
  1013. $("#idCard").blur();
  1014. $("#address").val(res.data.address);
  1015. $("#address").blur();
  1016. $("#patientId").val(res.data.patientId);
  1017. if (res.data.name != null && res.data.name != "") {
  1018. $("#editUser").show();
  1019. }
  1020. readonlyOrNot(true);
  1021. }
  1022. } else {
  1023. new PNotify({
  1024. title: '错误提示',
  1025. text: res.message,
  1026. type: 'error',
  1027. hide: true,
  1028. styling: 'bootstrap3'
  1029. });
  1030. }
  1031. }
  1032. });
  1033. }
  1034. /**
  1035. * 将病人信息填入患者信息修改form
  1036. * @param patinet
  1037. */
  1038. function fillPlusPatinet(patinet) {
  1039. if (patinet != null) {
  1040. $("#editUserCode").val(patinet.patientId);
  1041. $("#editUserName").val(patinet.name);
  1042. $("#editUserName").blur();
  1043. $("#editUserAge").val(patinet.age);
  1044. $("#editUserAge").blur();
  1045. $("#editUserGender").selectpicker('val', patinet.sex);
  1046. $("#editUserGender").selectpicker('refresh');
  1047. $("#editUserGender").blur();
  1048. $("#editUserBirthDay").val(patinet.birthDayStr);
  1049. $("#editUserBirthDay").blur();
  1050. $("#editUserCardNo").val(patinet.icCardNo);
  1051. $("#editUserCardNo").attr("title", patinet.icCardNo);
  1052. $("#editUserCardNo").blur();
  1053. $("#editUserPhoneNum").val(patinet.phoneNo);
  1054. $("#editUserPhoneNum").attr("title", patinet.phoneNo);
  1055. $("#editUserPhoneNum").blur();
  1056. $("#editUserPatientsNature").selectpicker('val', patinet.responseType);//默认选中
  1057. $('#editUserPatientsNature').selectpicker('refresh');
  1058. $("#editUserPatientsNature").blur();
  1059. $("#editUserIdCard").val(patinet.socialNo);
  1060. $("#editUserIdCard").attr("title", patinet.socialNo);
  1061. $("#editUserIdCard").blur();
  1062. $("#editUserAddress").val(patinet.address);
  1063. $("#editUserAddress").blur();
  1064. $("#editUserContact").val(patinet.relName);
  1065. $("#editUserContactPhone").val(patinet.contractName);
  1066. }
  1067. }
  1068. /**
  1069. * 关闭当前这个付款方式
  1070. */
  1071. function closeThisParent(obj) {
  1072. $(obj).parent().parent().remove();
  1073. }
  1074. /**
  1075. * 科室与时间区间下拉选改变时清空输入框内容
  1076. */
  1077. function emptyInput() {
  1078. $('#doctor').empty();
  1079. $('#doctor').selectpicker('refresh');
  1080. $("#registrationFee").val(0.00);
  1081. $("#hospitalFee").val(0.00);
  1082. $("#checkFee").val(0.00);
  1083. $("#amountMoney").text(0.00);
  1084. $("#amountMoneyConfirm").text(0.00);
  1085. $("#realMoney").val(0.00);
  1086. }
  1087. /**
  1088. * 给某些域增加title或者清除title
  1089. * @param obj
  1090. */
  1091. function clearTextOrTitle(obj) {
  1092. if ($(obj).val() == null || $(obj).val().length == 0) {
  1093. $(obj).attr("title", null);
  1094. } else {
  1095. $(obj).attr("title", $(obj).val());
  1096. if ($(obj).attr("id") == "birthDay") {
  1097. $(obj).blur()
  1098. }
  1099. }
  1100. }
  1101. /**
  1102. * 当按照卡号查询时,病人信息输入框不可编辑,当清空输入框时可编辑
  1103. * @param flag
  1104. */
  1105. function readonlyOrNot(flag) {
  1106. if (flag) {
  1107. $("#cardNo").attr("readonly", "readonly");
  1108. $("#userName").attr("readonly", "readonly");
  1109. $("#age").attr("readonly", "readonly");
  1110. $("#gender").attr("disabled", "disabled");
  1111. $("#phoneNum").attr("readonly", "readonly");
  1112. $("#patientsNature").attr("disabled", "disabled");
  1113. $("#idCard").attr("readonly", "readonly");
  1114. $("#address").attr("readonly", "readonly");
  1115. $("#birthDayReadonly").removeClass("hide").addClass("in");
  1116. $("#birthDayGroup").removeClass("in").addClass("hide");
  1117. $("#userName").removeClass("in").addClass("hide");
  1118. $("#userNameReadOnly").removeClass("hide").addClass("in");
  1119. $("#webuiPopover0").css("display", "none");
  1120. } else {
  1121. $("#cardNo").removeAttr("readonly");
  1122. $("#userName").removeAttr("readonly");
  1123. $("#age").removeAttr("readonly");
  1124. $("#gender").removeAttr("disabled");
  1125. $("#gender").next().removeClass("disabled");
  1126. $("#phoneNum").removeAttr("readonly");
  1127. $("#patientsNature").removeAttr("disabled");
  1128. $("#patientsNature").next().removeClass("disabled");
  1129. $("#idCard").removeAttr("readonly");
  1130. $("#address").removeAttr("readonly");
  1131. $("#birthDayReadonly").removeClass("in").addClass("hide");
  1132. $("#birthDayGroup").removeClass("hide").addClass("in");
  1133. $("#userName").removeClass("hide").addClass("in");
  1134. $("#userNameReadOnly").removeClass("in").addClass("hide");
  1135. //$("#webuiPopover0").css("display", "block");
  1136. }
  1137. }
  1138. /**
  1139. * 查询默认打印机
  1140. */
  1141. function setPrint() {
  1142. if (printIndex >= 0) {
  1143. return;
  1144. }
  1145. $.ajax({
  1146. type: "GET",
  1147. url: '/thmz/getLastWindowsByCurrentUser',
  1148. contentType: "application/json;charset=UTF-8",
  1149. dataType: "json",
  1150. headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
  1151. async: false,
  1152. success: function (res) {
  1153. if (res == '401' || res == 401) {
  1154. window.location.href = '/thmz/login/view'
  1155. return;
  1156. }
  1157. if (res.code == 0) {
  1158. printIndex = res.data.printIndex;
  1159. } else {
  1160. printIndex = -1;
  1161. }
  1162. }
  1163. });
  1164. }
  1165. //
  1166. // /**
  1167. // * 保存窗口号
  1168. // */
  1169. // function saveWindows() {
  1170. // $.ajax({
  1171. // type: "POST",
  1172. // url: '/thmz/saveWindows',
  1173. // contentType: "application/json;charset=UTF-8",
  1174. // dataType: "json",
  1175. // data: JSON.stringify({"windowsNo": $("#windowsNum").val()}),
  1176. // headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
  1177. // success: function (res) {
  1178. // if (res == '401' || res == 401) {
  1179. // window.location.href = '/thmz/login/view'
  1180. // return;
  1181. // }
  1182. // $('#editWindowsModal').modal('hide');
  1183. // if (res.code == 0) {
  1184. // new PNotify({
  1185. // title: '操作提示',
  1186. // text: res.message,
  1187. // type: 'success',
  1188. // hide: true,
  1189. // styling: 'bootstrap3'
  1190. // });
  1191. // } else {
  1192. // new PNotify({
  1193. // title: '错误提示',
  1194. // text: res.message,
  1195. // type: 'error',
  1196. // hide: true,
  1197. // styling: 'bootstrap3'
  1198. // });
  1199. // }
  1200. // }
  1201. // });
  1202. // }
  1203. //
  1204. // /**
  1205. // * 保存打印机
  1206. // */
  1207. // function savePrint() {
  1208. // $.ajax({
  1209. // type: "POST",
  1210. // url: '/thmz/savePrintIndex',
  1211. // contentType: "application/json;charset=UTF-8",
  1212. // dataType: "json",
  1213. // data: JSON.stringify({"printIndex": $("#printSelect").val()}),
  1214. // headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
  1215. // success: function (res) {
  1216. // if (res == '401' || res == 401) {
  1217. // window.location.href = '/thmz/login/view'
  1218. // return;
  1219. // }
  1220. // LODOP = getLodop();
  1221. // LODOP.PRINT_INITA(6, 0, "92mm", "120mm", "泰和门诊发票打印");
  1222. // LODOP.SET_PRINTER_INDEX($("#printSelect").val());
  1223. // printIndex=$("#printSelect").val();
  1224. // $('#editPrintModal').modal('hide');
  1225. // if (res.code == 0) {
  1226. // new PNotify({
  1227. // title: '操作提示',
  1228. // text: res.message,
  1229. // type: 'success',
  1230. // hide: true,
  1231. // styling: 'bootstrap3'
  1232. // });
  1233. // } else {
  1234. // new PNotify({
  1235. // title: '错误提示',
  1236. // text: res.message,
  1237. // type: 'error',
  1238. // hide: true,
  1239. // styling: 'bootstrap3'
  1240. // });
  1241. // }
  1242. // }
  1243. // });
  1244. // }
  1245. /**
  1246. * 保存病人信息
  1247. * @param flag true 继续调用挂号接口,false,只建档不挂号
  1248. */
  1249. function savePatient(flag) {
  1250. $.ajax({
  1251. type: "POST",
  1252. url: '/thmz/savePatient',
  1253. contentType: "application/json;charset=UTF-8",
  1254. dataType: "json",
  1255. data: JSON.stringify({
  1256. "name": $("#userName").val(),
  1257. "age": $("#age").val(),
  1258. "sex": $("#gender").val(),
  1259. "birthDay": $("#birthDay").val(),
  1260. "icCardNo": $("#cardNo").val(),
  1261. "phoneNo": $("#phoneNum").val(),
  1262. "responseType": $("#patientsNature").val(),
  1263. "socialNo": $("#idCard").val(),
  1264. "address": $("#address").val()
  1265. }),
  1266. headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
  1267. success: function (res) {
  1268. if (res == '401' || res == 401) {
  1269. window.location.href = '/thmz/login/view'
  1270. return;
  1271. }
  1272. if (res.code == 0) {
  1273. if (flag) {
  1274. $("#patientId").val(res.data.patientId);
  1275. saveMzyReqrec();
  1276. } else {
  1277. clearRegistration();
  1278. successMesage(res);
  1279. }
  1280. } else {
  1281. errorMesage(res);
  1282. }
  1283. }
  1284. });
  1285. }
  1286. // /**
  1287. // * 修改病人信息诊疗卡信息
  1288. // */
  1289. // function modifyPatientIcCardNo() {
  1290. // $.ajax({
  1291. // type: "POST",
  1292. // url: '/thmz/modifyPatient',
  1293. // contentType: "application/json;charset=UTF-8",
  1294. // dataType: "json",
  1295. // data: JSON.stringify({
  1296. // //"age": jsGetAge($("#birthDayReadonly").val()),
  1297. // "icCardNo": $("#cardNo").val(),
  1298. // "patientId": $("#patientId").val(),
  1299. // }),
  1300. // headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
  1301. // success: function (res) {
  1302. // if (res == '401' || res == 401) {
  1303. // window.location.href = '/thmz/login/view'
  1304. // return;
  1305. // }
  1306. // if (res.code == 0) {
  1307. // editIcCardNo=false;
  1308. // saveMzyReqrec();
  1309. // successMesage(res)
  1310. // } else {
  1311. // errorMesage(res);
  1312. // }
  1313. // }
  1314. // });
  1315. // }
  1316. /**
  1317. * 修改病人信息
  1318. */
  1319. function modifyPatient() {
  1320. $.ajax({
  1321. type: "POST",
  1322. url: '/thmz/modifyPatient',
  1323. contentType: "application/json;charset=UTF-8",
  1324. dataType: "json",
  1325. data: JSON.stringify({
  1326. "name": $("#editUserName").val(),
  1327. "age": $("#editUserAge").val(),
  1328. "sex": $("#editUserGender").val(),
  1329. "birthDay": $("#editUserBirthDay").val(),
  1330. "icCardNo": $("#editUserCardNo").val(),
  1331. "phoneNo": $("#editUserPhoneNum").val(),
  1332. "responseType": $("#editUserPatientsNature").val(),
  1333. "socialNo": $("#editUserIdCard").val(),
  1334. "address": $("#editUserAddress").val(),
  1335. "patientId": $("#editUserCode").val(),
  1336. "relName": $("#editUserContact").val(),
  1337. "contractName": $("#editUserContactPhone").val()
  1338. }),
  1339. headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
  1340. success: function (res) {
  1341. if (res == '401' || res == 401) {
  1342. window.location.href = '/thmz/login/view'
  1343. return;
  1344. }
  1345. if (res.code == 0) {
  1346. $('#editUserModal').modal('hide');
  1347. fillPatinet($("#patientId").val());
  1348. successMesage(res);
  1349. } else {
  1350. new PNotify({
  1351. title: '错误提示',
  1352. text: res.message,
  1353. type: 'error',
  1354. hide: true,
  1355. styling: 'bootstrap3'
  1356. });
  1357. }
  1358. }
  1359. });
  1360. }
  1361. /**
  1362. * 保存挂号信息
  1363. */
  1364. function saveMzyReqrec() {
  1365. var mzyRequestId = $('#doctor').find("option:selected").attr('data-mzyRequestId');
  1366. var patientId = $("#patientId").val();
  1367. $.ajax({
  1368. type: "POST",
  1369. url: '/thmz/saveMzyReqrec',
  1370. contentType: "application/json;charset=UTF-8",
  1371. dataType: "json",
  1372. data: JSON.stringify({
  1373. "mzyReqrec": {
  1374. "patientId": patientId,
  1375. "ampm": $("#ampm").val(),
  1376. "unitCode": $("#deptNo").val(),
  1377. "chargeType": $("#chargeType").val(),
  1378. "paymode": $("#payType").val()
  1379. }, "responceType": $("#patientsNature").val(), "mzyRequestId": mzyRequestId
  1380. }),
  1381. headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
  1382. success: function (res) {
  1383. if (res == '401' || res == 401) {
  1384. window.location.href = '/thmz/login/view'
  1385. return;
  1386. }
  1387. if (res.code == 0) {
  1388. new PNotify({
  1389. title: '操作提示',
  1390. text: res.message,
  1391. type: 'success',
  1392. hide: true,
  1393. styling: 'bootstrap3'
  1394. });
  1395. $('#confirmFeeModal').modal('hide');
  1396. prn1Print(patientId, -1);
  1397. // loadTableCount();
  1398. // loadRegistrationList(true);
  1399. clearRegistration();
  1400. } else {
  1401. new PNotify({
  1402. title: '错误提示',
  1403. text: res.message,
  1404. type: 'error',
  1405. hide: true,
  1406. styling: 'bootstrap3'
  1407. });
  1408. }
  1409. }
  1410. });
  1411. }
  1412. /**
  1413. * 挂号列表中的科室和医生列表初始化
  1414. */
  1415. function initListSelect() {
  1416. initListDeptSelect();
  1417. initListDoctorSelect();
  1418. }
  1419. /**
  1420. * 挂号列表中的科室列表
  1421. */
  1422. function initListDeptSelect() {
  1423. //科室列表
  1424. $.ajax({
  1425. type: "GET",
  1426. url: '/thmz/allMzUnitCode',
  1427. dataType: "json",
  1428. headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
  1429. success: function (data) {
  1430. if (data == '401' || data == 401) {
  1431. window.location.href = '/thmz/login/view'
  1432. return;
  1433. }
  1434. var html = '';
  1435. $.each(data.data, function (commentIndex, comment) {
  1436. html += '<option value="' + comment.code + '">' + comment.name + '</option>';
  1437. });
  1438. $('#deptNoParam').empty();
  1439. $('#deptNoParam').html(html);
  1440. $('#deptNoParam').selectpicker('refresh');
  1441. }
  1442. });
  1443. }
  1444. /**
  1445. * 挂号列表中的医生列表初始化
  1446. */
  1447. function initListDoctorSelect() {
  1448. //医生列表
  1449. $.ajax({
  1450. type: "GET",
  1451. url: '/thmz/listEmployeeByDepts?depts=' + $('#deptNoParam').val(),
  1452. dataType: "json",
  1453. headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
  1454. success: function (res) {
  1455. if (res == '401' || res == 401) {
  1456. window.location.href = '/thmz/login/view'
  1457. return;
  1458. }
  1459. var html = '';
  1460. $.each(res.data, function (commentIndex, comment) {
  1461. html += '<option value="' + comment.employeeCode + '">' + comment.employeeName + '</option>';
  1462. });
  1463. $('#doctorParam').empty();
  1464. $('#doctorParam').html(html);
  1465. // $("#doctorParam").selectpicker({
  1466. // size: 10
  1467. // });
  1468. $('#doctorParam').selectpicker('destroy').selectpicker('refresh');
  1469. }
  1470. });
  1471. }
  1472. /**
  1473. * 清空搜索参数
  1474. */
  1475. function clearParams() {
  1476. $("#deptNoParam").selectpicker('val', null);
  1477. $("#deptNoParam").selectpicker('refresh');
  1478. $("#doctorParam").selectpicker('val', null);
  1479. $("#deptNoParam").selectpicker('refresh');
  1480. $("#userNameParam").val(null);
  1481. $("#phoneParam").val(null);
  1482. $('#reportrange span').html(moment().format('YYYY-MM-DD') + ' - ' + moment().format('YYYY-MM-DD'));
  1483. }
  1484. /**
  1485. * 保存退号信息
  1486. */
  1487. function saveBackNo() {
  1488. $.ajax({
  1489. type: "POST",
  1490. url: '/thmz/updateReqrec',
  1491. contentType: "application/json;charset=UTF-8",
  1492. dataType: "json",
  1493. data: JSON.stringify({
  1494. "patientId": $("#backNoPatientId").val(),
  1495. "times": $("#backNoTimes").val(),
  1496. "cancelMark": 1
  1497. }),
  1498. headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
  1499. success: function (res) {
  1500. if (res == '401' || res == 401) {
  1501. window.location.href = '/thmz/login/view'
  1502. return;
  1503. }
  1504. if (res.code == 0) {
  1505. new PNotify({
  1506. title: '操作提示',
  1507. text: res.message,
  1508. type: 'success',
  1509. hide: true,
  1510. styling: 'bootstrap3'
  1511. });
  1512. loadTableCount();
  1513. loadRegistrationList(true);
  1514. $("#backNoModal").modal("hide");
  1515. } else {
  1516. new PNotify({
  1517. title: '错误提示',
  1518. text: res.message,
  1519. type: 'error',
  1520. hide: true,
  1521. styling: 'bootstrap3'
  1522. });
  1523. }
  1524. }
  1525. });
  1526. }
  1527. /**
  1528. * 清空挂号信息
  1529. */
  1530. function clearRegistration() {
  1531. $("#cardNo").val(null);
  1532. $("#cardNo").attr("title", null);
  1533. $("#userName").val(null);
  1534. $("#age").val(null);
  1535. $("#gender").selectpicker('val', 1);
  1536. $("#gender").selectpicker('refresh');
  1537. $("#birthDay").val(null);
  1538. $("#birthDay").attr("title", null);
  1539. $("#phoneNum").val(null);
  1540. $("#phoneNum").attr("title", null);
  1541. $("#patientsNature").selectpicker('val', '01');//默认选中
  1542. $('#patientsNature').selectpicker('refresh');
  1543. $("#idCard").val(null);
  1544. $("#idCard").attr("title", null);
  1545. $("#address").val(null);
  1546. $("#patientId").val(null);
  1547. $("#editUser").hide();
  1548. $("#clearIcCardNo").hide();
  1549. //默认光标在卡号输入框
  1550. $("#cardNo").focus();
  1551. initMzWorkTime();
  1552. readonlyOrNot(false);
  1553. $("#saveUser").hide();
  1554. }
  1555. /**
  1556. * 直接打印发票
  1557. * @param patientId
  1558. */
  1559. function prn1Print(patientId, times) {
  1560. setPrint();
  1561. var height ="93.09mm";
  1562. // if(countReceiot%2==0){
  1563. // height ="93.2mm";
  1564. // }
  1565. $.ajax({
  1566. type: "GET",
  1567. url: '/thmz/printMzyReqrecRecept?patientId=' + patientId + "&times=" + times,
  1568. contentType: "application/json;charset=UTF-8",
  1569. dataType: "json",
  1570. headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
  1571. success: function (res) {
  1572. if (res == '401' || res == 401) {
  1573. window.location.href = '/thmz/login/view'
  1574. return;
  1575. }
  1576. if (res.code == 0) {
  1577. if (res.data == null || res.data.length == 0) {
  1578. return;
  1579. }
  1580. // countReceiot++;
  1581. LODOP = getLodop();
  1582. var temp = res.data;
  1583. LODOP.PRINT_INITA(6, 0, "120mm", height, "泰和门诊发票打印");
  1584. //设置默认打印机
  1585. LODOP.SET_PRINTER_INDEX(printIndex);
  1586. LODOP.SET_SHOW_MODE("BKIMG_WIDTH", "120mm");
  1587. LODOP.SET_SHOW_MODE("BKIMG_HEIGHT", height);
  1588. LODOP.SET_PRINT_PAGESIZE(1, "120mm", height, "CreateCustomPage");
  1589. LODOP.SET_PRINT_MODE("CREATE_CUSTOM_PAGE_NAME", "门诊发票");//对新建的纸张重命名
  1590. LODOP.SET_PRINT_STYLE("FontSize", 11); //字体大小
  1591. LODOP.ADD_PRINT_TEXT("6mm", "0mm", "45mm", "3mm", "湖南泰和医院管理有限公司");
  1592. LODOP.ADD_PRINT_TEXT("6mm", "59mm", "30mm", "3mm", "流水号:");
  1593. LODOP.ADD_PRINT_TEXT("6mm", "72mm", "20mm", "3mm", temp.serialNo);
  1594. LODOP.ADD_PRINT_TEXT("19mm", "0mm", "35mm", "3mm", temp.receiptBill);
  1595. LODOP.ADD_PRINT_TEXT("25mm", "7mm", "40mm", "3mm", temp.name);
  1596. LODOP.ADD_PRINT_TEXT("25mm", "61mm", "27mm", "3mm", patientId);
  1597. LODOP.ADD_PRINT_TEXT("32mm", "6mm", "40mm", "3mm", "就诊科室:" + temp.unitCode);
  1598. LODOP.ADD_PRINT_TEXT("32mm", "46mm", "40mm", "3mm", "地点:" + res.officePos==null?"":res.officePos);
  1599. LODOP.ADD_PRINT_TEXT("37mm", "6mm", "40mm", "3mm", "看诊医生:" + temp.doctorCode);
  1600. LODOP.ADD_PRINT_TEXT("37mm", "46mm", "40mm", "3mm", "号段:" + temp.ampm);
  1601. LODOP.ADD_PRINT_TEXT("42mm", "6mm", "40mm", "3mm", "号别:" + temp.chargeType);
  1602. LODOP.ADD_PRINT_TEXT("42mm", "46mm", "40mm", "3mm", "就诊号:" + temp.reqOrder);
  1603. LODOP.ADD_PRINT_TEXT("47mm", "6mm", "40mm", "3mm", "挂号费:" + temp.reqFee);
  1604. LODOP.ADD_PRINT_TEXT("47mm", "46mm", "40mm", "3mm", "诊查费:" + temp.clinicFee);
  1605. LODOP.ADD_PRINT_TEXT("52mm", "6mm", "40mm", "3mm", "其他:" + temp.othFee);
  1606. LODOP.ADD_PRINT_TEXT("52mm", "46mm", "40mm", "3mm", "工本费:" + temp.brochureFee);
  1607. LODOP.ADD_PRINT_TEXT("65mm", "21mm", "60mm", "3mm", res.totalFee + " 元");
  1608. LODOP.ADD_PRINT_TEXT("72mm", "19mm", "60mm", "3mm", res.totalFeeStr);
  1609. LODOP.ADD_PRINT_TEXT("79mm", "0mm", "15mm", "3mm", res.year);//年
  1610. LODOP.ADD_PRINT_TEXT("79mm", "13mm", "10mm", "3mm", res.month);//月
  1611. LODOP.ADD_PRINT_TEXT("79mm", "25mm", "10mm", "3mm", res.day);//日
  1612. LODOP.ADD_PRINT_TEXT("79mm", "53mm", "23mm", "3mm", res.user.userName);//收费员
  1613. //LODOP.PREVIEW();
  1614. LODOP.PRINT();
  1615. if (times > 0) {
  1616. loadRegistrationList(true);
  1617. }
  1618. }else if(res.code == -2){
  1619. new PNotify({
  1620. title: '操作提示',
  1621. text: res.message,
  1622. type: 'success',
  1623. hide: true,
  1624. styling: 'bootstrap3'
  1625. });
  1626. }else if (res.code == -1) {
  1627. new PNotify({
  1628. title: '错误提示',
  1629. text: res.message,
  1630. type: 'error',
  1631. hide: true,
  1632. styling: 'bootstrap3'
  1633. });
  1634. }
  1635. }
  1636. });
  1637. };
  1638. /**
  1639. * 销卡
  1640. * @param data
  1641. */
  1642. function clearIcCardNo() {
  1643. $.ajax({
  1644. type: "GET",
  1645. url: '/thmz/clearIcCardNo?patientId=' + $("#patientId").val(),
  1646. contentType: "application/json;charset=UTF-8",
  1647. dataType: "json",
  1648. headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
  1649. success: function (res) {
  1650. if (res == '401' || res == 401) {
  1651. window.location.href = '/thmz/login/view'
  1652. return;
  1653. }
  1654. if (res.code == 0) {
  1655. clearRegistration();
  1656. successMesage(res);
  1657. } else {
  1658. errorMesage(res);
  1659. }
  1660. }
  1661. });
  1662. }
  1663. /**
  1664. * 根据手机号码查询病人信息
  1665. */
  1666. function queryUserInfoByphoneNo() {
  1667. var phoneNo = $("#phoneNum").val();
  1668. if (phoneNo.length == 11) {
  1669. $.ajax({
  1670. type: "GET",
  1671. url: '/thmz/getByPhoneNo?phoneNo=' + phoneNo,
  1672. contentType: "application/json;charset=UTF-8",
  1673. dataType: "json",
  1674. headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
  1675. success: function (res) {
  1676. if (res == '401' || res == 401) {
  1677. window.location.href = '/thmz/login/view'
  1678. return;
  1679. }
  1680. if (res.code == 0) {
  1681. fitPatient(res);
  1682. }
  1683. }
  1684. });
  1685. }
  1686. }
  1687. /**
  1688. * 根据手机号码查询病人信息
  1689. */
  1690. function queryUserInfoByName() {
  1691. var userName = $('#userName').val();
  1692. // var cardNo=$("#cardNo").val();
  1693. if (userName == null || userName == "") {
  1694. return;
  1695. }
  1696. if (userName.length > 0) {
  1697. $.ajax({
  1698. type: "GET",
  1699. url: '/thmz/getPatientMiByName?name=' + userName,
  1700. contentType: "application/json;charset=UTF-8",
  1701. dataType: "json",
  1702. headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
  1703. success: function (res) {
  1704. if (res == '401' || res == 401) {
  1705. window.location.href = '/thmz/login/view'
  1706. return;
  1707. }
  1708. if (res.code == 0) {
  1709. fitPatient(res);
  1710. }
  1711. }
  1712. });
  1713. }
  1714. }