toll_administration.js 77 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062
  1. //@ sourceURL=toll_administration.js
  2. var LODOP; //声明为全局变量
  3. //默认打印机下标
  4. var printIndex = -1;
  5. //选中的要退的费用收费编码
  6. var chargeItemCodes = null;
  7. $(function () {
  8. //默认光标在卡号输入框
  9. $("#cardNo").focus();
  10. init_daterangepicker();
  11. initSelect();
  12. initFeeTable();
  13. //卡号输入改变事件
  14. cardNoChange();
  15. //重置查询参数
  16. $('#btn_clean').click(function () {
  17. cleanParams();
  18. });
  19. //初始化页面上面的按钮事件
  20. //查询
  21. $('#btn_query').click(function () {
  22. initFeeTable();
  23. });
  24. /**
  25. * 增加收款方式按钮事件
  26. */
  27. $("#addPayType").on("click", function (t) {
  28. // var arr = $("#payForm").find("div.pay-item");
  29. // if (arr.length > 0) {
  30. // for (var i = 0; i < arr.length; i++) {
  31. // var temp = parseFloat($(arr[i]).find("input").val());
  32. // if (temp == 0) {
  33. // new PNotify({
  34. // title: '错误提示',
  35. // text: "存在未使用的收款方式,请不要重复添加!",
  36. // type: 'error',
  37. // hide: true,
  38. // styling: 'bootstrap3'
  39. // });
  40. // return;
  41. // }
  42. // }
  43. // }
  44. var payTypeIndex = $("#payTypeIndex").val();
  45. var payTypeId = "payType_" + payTypeIndex;
  46. var html = '<div class="item form-group pay-item"><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 + '" onchange="checkFee(false)"></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" onchange="checkFee()"></div><div class="col-md-1 col-sm-1 col-xs-12" style="line-height: 34px;">元&nbsp;&nbsp;<a style="line-height: 34px;cursor: pointer;" onclick="closeThisParent(this)"><i class="fa fa-close"></i></a></div></div></div>';
  47. $("#changeAmountParent").before(html);
  48. initChequeType(payTypeId)
  49. payTypeIndex = payTypeIndex + 1;
  50. $("#payTypeIndex").val(payTypeIndex);
  51. $("#addPayType").parent().removeClass("in").addClass("hide");
  52. });
  53. //初始门诊收银方式下拉选
  54. initChequeType("payType");
  55. setTimeout(function () {
  56. getLodop();
  57. }, 800);
  58. // $("#editPrint").on("click", function (t) {
  59. // CreatePrinterList();
  60. // $("#editPrintModal").modal();
  61. // });
  62. // /**
  63. // * 设置窗口号
  64. // */
  65. // $("#editWindows").on("click", function (t) {
  66. // $.ajax({
  67. // type: "GET",
  68. // url: '/thmz/getLastWindowsByCurrentUser',
  69. // contentType: "application/json;charset=UTF-8",
  70. // dataType: "json",
  71. // headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
  72. // success: function (res) {
  73. // if (res == '401' || res == 401) {
  74. // window.location.href = '/thmz/login/view'
  75. // return;
  76. // }
  77. // if (res.code == 0) {
  78. // $("#windowsNum").val(res.data.windowsNo)
  79. // } else {
  80. // new PNotify({
  81. // title: '错误提示',
  82. // text: res.message,
  83. // type: 'error',
  84. // hide: true,
  85. // styling: 'bootstrap3'
  86. // });
  87. // }
  88. // }
  89. // });
  90. // $("#editWindowsModal").modal();
  91. // });
  92. });
  93. /**
  94. * 列表类型按钮切换事件
  95. * @param object
  96. */
  97. function payMarkButtonChange(object) {
  98. $("#pay_mark_group").find("button").each(function (index, element) {
  99. if ($(element).hasClass("btn-primary")) {
  100. $(element).removeClass("btn-primary").addClass("btn-default");
  101. }
  102. });
  103. $(object).removeClass("btn-default").addClass("btn-primary");
  104. initFeeTable();
  105. }
  106. /**
  107. * 收费明细类型按钮切换事件
  108. * @param object
  109. */
  110. function billItemButtonChange(object) {
  111. $("#bill_item_group").find("button").each(function (index, element) {
  112. if ($(element).hasClass("btn-primary")) {
  113. $(element).removeClass("btn-primary").addClass("btn-default");
  114. }
  115. });
  116. $(object).removeClass("btn-default").addClass("btn-primary");
  117. initChargeDetailTable();
  118. //默认光标在卡号输入框
  119. $("#cardNo").focus();
  120. }
  121. /**
  122. * 收费明细类型按钮切换事件
  123. * @param object
  124. */
  125. function refundBillItemButtonChange(object) {
  126. $("#refund_bill_item_group").find("button").each(function (index, element) {
  127. if ($(element).hasClass("btn-primary")) {
  128. $(element).removeClass("btn-primary").addClass("btn-default");
  129. }
  130. });
  131. $(object).removeClass("btn-default").addClass("btn-primary");
  132. initMzChargeDetailByBillItem(false);
  133. }
  134. /**
  135. * 初始化下拉选
  136. */
  137. function initSelect() {
  138. $(".selectpicker").selectpicker({
  139. dropuAuto: false
  140. });
  141. initDeptSelect();
  142. initDoctorSelect();
  143. }
  144. /**
  145. * 挂号列表中的科室列表
  146. */
  147. function initDeptSelect() {
  148. //科室列表
  149. $.ajax({
  150. type: "GET",
  151. url: '/thmz/allMzUnitCode',
  152. dataType: "json",
  153. headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
  154. success: function (data) {
  155. if (data == '401' || data == 401) {
  156. window.location.href = '/thmz/login/view'
  157. return;
  158. }
  159. var html = '';
  160. $.each(data.data, function (commentIndex, comment) {
  161. html += '<option value="' + comment.code + '">' + comment.name + '(' + comment.pyCode + ')</option>';
  162. });
  163. $('#deptNoParam').empty();
  164. $('#deptNoParam').html(html);
  165. $('#deptNoParam').selectpicker('refresh');
  166. }
  167. });
  168. }
  169. /**
  170. * 挂号列表中的医生列表初始化
  171. */
  172. function initDoctorSelect() {
  173. //医生列表
  174. $.ajax({
  175. type: "GET",
  176. url: '/thmz/listEmployeeByDepts?depts=' + $('#deptNoParam').val(),
  177. dataType: "json",
  178. headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
  179. success: function (res) {
  180. if (res == '401' || res == 401) {
  181. window.location.href = '/thmz/login/view'
  182. return;
  183. }
  184. var html = '';
  185. $.each(res.data, function (commentIndex, comment) {
  186. html += '<option value="' + comment.employeeCode + '">' + comment.employeeName + '</option>';
  187. });
  188. $('#doctorParam').empty();
  189. $('#doctorParam').html(html);
  190. $('#doctorParam').selectpicker('destroy').selectpicker('refresh');
  191. }
  192. });
  193. }
  194. var $table_1;
  195. /**
  196. * 初始化收费表格
  197. */
  198. function initFeeTable() {
  199. var payMarkGroup = getIndex("pay_mark_group");
  200. var timeColumusName = "处方时间";
  201. var timeColumus = "priceTime";
  202. $("#refundFeeTip").removeClass("in").addClass("hide");
  203. $("#chargeFeeTip").removeClass("hide").addClass("in");
  204. if (payMarkGroup == 1) {
  205. timeColumusName = "缴费时间";
  206. timeColumus = "chargeDate";
  207. $("#refundFeeTip").removeClass("hide").addClass("in");
  208. $("#chargeFeeTip").removeClass("in").addClass("hide");
  209. } else if (payMarkGroup == 2) {
  210. timeColumusName = "退费时间";
  211. timeColumus = "inputDate";
  212. }
  213. var patientId = $("#patientId").val();
  214. if (payMarkGroup == 0 && patientId != null && patientId != '') {
  215. $("#patientIdHaveTally").val(patientId);
  216. $.ajax({
  217. type: "GET",
  218. url: '/thmz/getTallyTotalCharge?patientId=' + patientId,
  219. contentType: "application/json;charset=UTF-8",
  220. dataType: "json",
  221. headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
  222. success: function (res) {
  223. if (res == '401' || res == 401) {
  224. window.location.href = '/thmz/login/view'
  225. return;
  226. }
  227. if (res.code == 0) {
  228. if (res.data != null && res.data > 0) {
  229. $("#haveTallyModal").modal();
  230. $("#totalTallyAmount").text(res.data.toFixed(2));
  231. } else {
  232. $("#haveTallyModal").modal('hide');
  233. }
  234. } else {
  235. new PNotify({
  236. title: '错误提示',
  237. text: res.message,
  238. type: 'error',
  239. hide: true,
  240. styling: 'bootstrap3'
  241. });
  242. }
  243. }
  244. });
  245. }
  246. $('#tb_table').bootstrapTable("destroy");
  247. $table_1 = $('#tb_table').bootstrapTable({
  248. url: '/thmz/listMzChargeDetail', //请求后台的URL(*)
  249. method: 'post', //请求方式(*)
  250. toolbar: '#toolbar', //工具按钮用哪个容器
  251. striped: true, //是否显示行间隔色
  252. cache: false, //是否使用缓存,默认为true,所以一般情况下需要设置一下这个属性(*)
  253. pagination: true, //是否显示分页(*)
  254. sortable: true, //是否启用排序
  255. sortOrder: "asc", //排序方式
  256. queryParams: queryParams, //传递参数(*)
  257. sidePagination: "server", //分页方式:client客户端分页,server服务端分页(*)
  258. pageNumber: 1, //初始化加载第一页,默认第一页
  259. pageSize: 5, //每页的记录行数(*)
  260. pageList: [5, 10, 25, 50, 100], //可供选择的每页的行数(*)
  261. search: false, //是否显示表格搜索,此搜索是客户端搜索,不会进服务端,所以,个人感觉意义不大
  262. strictSearch: true,
  263. showColumns: false, //是否显示所有的列
  264. showRefresh: false, //是否显示刷新按钮
  265. minimumCountColumns: 2, //最少允许的列数
  266. clickToSelect: true, //是否启用点击选中行
  267. uniqueId: "ID", //每一行的唯一标识,一般为主键列
  268. showToggle: false, //是否显示详细视图和列表视图的切换按钮
  269. cardView: false, //是否显示详细视图
  270. detailView: false,
  271. //rowStyle:rowStyle,//通过自定义函数设置行样式
  272. ajaxOptions: {
  273. headers: {
  274. 'Accept': 'application/json',
  275. 'Authorization': 'Bearer ' + localStorage.getItem("token")
  276. }
  277. },
  278. columns: [
  279. // {
  280. // checkbox: true
  281. // },
  282. {
  283. field: 'realNo',
  284. title: '缴费流水号',
  285. align: "center",
  286. valign: 'middle',
  287. formatter: function (value, row, index) {
  288. return Math.abs(value);
  289. }
  290. }, {
  291. field: 'patientId',
  292. title: '患者编号',
  293. align: "center",
  294. valign: 'middle',
  295. }, {
  296. field: 'name',
  297. title: '患者姓名',
  298. align: "center",
  299. valign: 'middle',
  300. }, {
  301. field: 'times',
  302. title: '就诊次数',
  303. align: "center",
  304. valign: 'middle',
  305. }, {
  306. field: 'receiptNo',
  307. title: '结算次数',
  308. align: "center",
  309. valign: 'middle',
  310. formatter: function (value, row, index) {
  311. return Math.abs(value);
  312. }
  313. }, {
  314. field: 'amount',
  315. title: '金额(元)',
  316. align: "center",
  317. valign: 'middle',
  318. formatter: function (value, row, index) {
  319. return Math.abs(value);
  320. }
  321. }, {
  322. field: 'warnDept',
  323. title: '科室',
  324. align: "center",
  325. valign: 'middle',
  326. }, {
  327. field: 'doctorCode',
  328. title: '医生',
  329. align: "center",
  330. valign: 'middle',
  331. }, {
  332. field: timeColumus,
  333. title: timeColumusName,
  334. align: "center",
  335. valign: 'middle',
  336. formatter: function (value, row, index) {
  337. if (value == null || value == "") {
  338. return "";
  339. }
  340. return format(value, "yyyy-MM-dd HH:mm:ss");
  341. }
  342. }, {
  343. title: '操作',
  344. align: "center",
  345. valign: 'middle',
  346. // sortable: true,
  347. formatter: function (value, row, index) {
  348. var str = '<button type="button" class="registration-no-color-foot-button" title="费用明细" onclick="chargeDetailModal(\'' + row.patientId + '\',' + row.times + ',' + row.receiptNo + ')"><i class="fa fa-plus"></i></button>';
  349. str += '<button type="button" class="registration-no-color-foot-button" title="诊断查询" onclick="diagnoseQuery(\'' + row.patientId + '\',' + row.times + ')"><i class="fa fa-search-minus"></i></button>';
  350. var payMarkGroup = getIndex("pay_mark_group");
  351. if (payMarkGroup == 0) {
  352. str += '<button type="button" class="registration-no-color-foot-button"title="确认收费" onclick="tipHaveTally(' + row.amount + ',\'' + row.patientId + '\',' + row.times + ',\'' + row.name + '\',' + row.receiptNo + ')"><i class="fa fa-rmb"></i></button>';
  353. }
  354. if (payMarkGroup == 1) {
  355. str += '<button type="button" class="registration-no-color-foot-button" title="退费" onclick="refundFee(\'' + row.patientId + '\',' + row.times + ',' + row.receiptNo + ',' + row.printFlag + ');"><i class="fa fa-reply"></i></button>';
  356. if (row.printFlag == 0) {
  357. str += '<button type="button" class="registration-no-color-foot-button" title="发票打印" onclick="prn1Print(\'' + row.patientId + '\',' + row.times + ',true);" style="color: #35D082;"><i class="fa fa-print"></i></button>';
  358. } else if (row.printFlag == 1) {
  359. str += '<button type="button" class="registration-no-color-foot-button" title="发票重打" onclick="repPrint(\'' + row.patientId + '\',' + row.times + ');" style="color: #F4BD00;"><i class="fa fa-print"></i></button>';
  360. str += '<button type="button" class="registration-no-color-foot-button" title="发票作废重打" onclick="obsoleteAndRepPrint(\'' + row.patientId + '\',' + row.times + ',' + row.receiptNo + ');" style="color: #E73E48;"><i class="fa fa-print"></i></button>';
  361. }
  362. }
  363. return str;
  364. }
  365. }
  366. ],
  367. responseHandler: function (res) {
  368. if (res == '401' || res == 401) {
  369. window.location.href = '/thmz/login/view'
  370. return;
  371. }
  372. var ress = eval(res);
  373. if (ress.code == -1) {
  374. if (ress.message != null && ress.message != '') {
  375. new PNotify({
  376. title: '错误提示',
  377. text: ress.message,
  378. type: 'error',
  379. hide: true,
  380. styling: 'bootstrap3'
  381. });
  382. }
  383. return {
  384. "total": 0,//总页数
  385. "rows": {} //数据
  386. };
  387. }
  388. // if(ress.pageViewVo.total==0){
  389. // $("#cardNo").val(null);
  390. // $("#name").val(null);
  391. // }
  392. return {
  393. "total": ress.pageViewVo.total,//总页数
  394. "rows": ress.pageViewVo.data //数据
  395. };
  396. },
  397. /**
  398. * @param {点击列的 field 名称} field
  399. * @param {点击列的 value 值} value
  400. * @param {点击列的整行数据} row
  401. * @param {td 元素} $element
  402. */
  403. onClickCell: function (field, value, row, $element) {
  404. var cardNo = $("#cardNo").val();
  405. if (cardNo == '120' && field == 'name' && (payMarkGroup == 0 || payMarkGroup == 1)) {
  406. $element.attr('contenteditable', true);
  407. $element.html(null);
  408. $element.focus();
  409. $element.blur(function () {
  410. var index = $element.parent().data('index');
  411. var tdValue = $element.html();
  412. saveData(index, field, tdValue, row, $table_1);
  413. })
  414. }
  415. },
  416. });
  417. }
  418. /**
  419. * 更新病人缴费记录病人姓名
  420. * @param index
  421. * @param field
  422. * @param value
  423. * @param row
  424. */
  425. function saveData(index, field, value, row, table) {
  426. $.ajax({
  427. type: "POST",
  428. url: '/thmz/changePatientIdName',
  429. contentType: "application/json;charset=UTF-8",
  430. dataType: "json",
  431. data: JSON.stringify({"patientId": row.patientId, "times": row.times, "name": value}),
  432. headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
  433. async: false,
  434. success: function (res) {
  435. if (res == '401' || res == 401) {
  436. window.location.href = '/thmz/login/view'
  437. return;
  438. }
  439. if (res.code == 0) {
  440. table.bootstrapTable('updateCell', {
  441. index: index, //行索引
  442. field: field, //列名
  443. value: value //cell值
  444. })
  445. } else {
  446. table.bootstrapTable('updateCell', {
  447. index: index, //行索引
  448. field: field, //列名
  449. value: row.name //cell值
  450. })
  451. errorMesage(res);
  452. }
  453. }
  454. });
  455. }
  456. /**
  457. * 构建列表查询参数
  458. * @param params
  459. * @returns {{mzChargeDetail: {patientId: string | number | string[] | undefined | jQuery, warnDept: string | number | string[] | undefined | jQuery, doctorCode: string | number | string[] | undefined | jQuery, name: string | number | string[] | undefined | jQuery, payMark: number}, beginTime: Date, endTime: Date, pageSize: *, pageIndex: number}}
  460. */
  461. function queryParams(params) {
  462. var rePortRangeArr = getRePortRangeArr();
  463. var payMarkGroup = getIndex("pay_mark_group");
  464. var temp = {
  465. mzChargeDetail: {
  466. patientId: $("#patientId").val(),
  467. warnDept: $("#deptNoParam").val(),
  468. doctorCode: $("#doctorParam").val(),
  469. name: $("#name").val(),
  470. payMark: 5
  471. },
  472. beginTime: new Date(rePortRangeArr[0]),
  473. endTime: new Date(rePortRangeArr[1]),
  474. pageSize: params.limit, //页面大小
  475. pageIndex: params.offset / params.limit, //页码
  476. serialNo: $("#serialNo").val(),
  477. ownData: $('#ownData').is(':checked') ? 0 : 1,
  478. };
  479. if (payMarkGroup == 1) {
  480. temp.mzChargeDetail.payMark = 0;
  481. } else if (payMarkGroup == 2) {
  482. temp.mzChargeDetail.payMark = 1;
  483. }
  484. return temp;
  485. };
  486. function initChargeDetailTable() {
  487. initChargeDetailTablePublic('/thmz/getMzChargeDetailByBillItem', $('#charge_detail_table'), queryParamsForDetail);
  488. }
  489. function initMzChargeDetailByBillItem(flag) {
  490. if (flag) {
  491. $("#refund_bill_item_group").removeClass("hide").addClass("in");
  492. if ($("#plusOrMinus").hasClass("fa-plus")) {
  493. $("#plusOrMinus").removeClass("fa-plus").addClass("fa-minus");
  494. initChargeDetailTablePublic('/thmz/getNewListForRefundFeeByBillItem', $('#refund_fee_bill_table'), queryParamsForRefundByBillItem);
  495. } else if ($("#plusOrMinus").hasClass("fa-minus")) {
  496. $("#plusOrMinus").removeClass("fa-minus").addClass("fa-plus");
  497. $("#refund_bill_item_group").removeClass("in").addClass("hide");
  498. $('#refund_fee_bill_table').bootstrapTable("destroy");
  499. }
  500. } else {
  501. initChargeDetailTablePublic('/thmz/getNewListForRefundFeeByBillItem', $('#refund_fee_bill_table'), queryParamsForRefundByBillItem);
  502. }
  503. }
  504. /**
  505. * 初始化收费明细表格
  506. */
  507. function initChargeDetailTablePublic(url, obj, params) {
  508. $(obj).bootstrapTable("destroy");
  509. $(obj).bootstrapTable({
  510. url: url, //请求后台的URL(*)
  511. method: 'post', //请求方式(*)
  512. toolbar: '#toolbar', //工具按钮用哪个容器
  513. striped: true, //是否显示行间隔色
  514. cache: false, //是否使用缓存,默认为true,所以一般情况下需要设置一下这个属性(*)
  515. pagination: false, //是否显示分页(*)
  516. sortable: true, //是否启用排序
  517. sortOrder: "asc", //排序方式
  518. // sortName: 'orderNo', //排序字段
  519. queryParams: params, //传递参数(*)
  520. sidePagination: "server", //分页方式:client客户端分页,server服务端分页(*)
  521. pageNumber: 1, //初始化加载第一页,默认第一页
  522. pageSize: 10, //每页的记录行数(*)
  523. pageList: [10, 25, 50, 100], //可供选择的每页的行数(*)
  524. search: false, //是否显示表格搜索,此搜索是客户端搜索,不会进服务端,所以,个人感觉意义不大
  525. strictSearch: true,
  526. showColumns: false, //是否显示所有的列
  527. showRefresh: false, //是否显示刷新按钮
  528. minimumCountColumns: 2, //最少允许的列数
  529. clickToSelect: true, //是否启用点击选中行
  530. uniqueId: "ID", //每一行的唯一标识,一般为主键列
  531. showToggle: false, //是否显示详细视图和列表视图的切换按钮
  532. cardView: false, //是否显示详细视图
  533. detailView: false,
  534. //rowStyle:rowStyle,//通过自定义函数设置行样式
  535. ajaxOptions: {
  536. headers: {
  537. 'Accept': 'application/json',
  538. 'Authorization': 'Bearer ' + localStorage.getItem("token")
  539. }
  540. },
  541. columns: [
  542. // {
  543. // checkbox: true
  544. // },
  545. {
  546. field: 'orderNo',
  547. title: '处方号',
  548. align: "center",
  549. valign: 'middle',
  550. formatter: function (value, row, index) {
  551. return Math.abs(value);
  552. }
  553. }, {
  554. field: 'chargeItemCode',
  555. title: '编码',
  556. align: "center",
  557. valign: 'middle',
  558. }, {
  559. field: 'tcName',
  560. title: '项目',
  561. align: "center",
  562. valign: 'middle',
  563. },
  564. // {
  565. // field: 'times',
  566. // title: '规格',
  567. // align: "center",
  568. // valign: 'middle',
  569. // },
  570. {
  571. field: 'quantity',
  572. title: '数量',
  573. align: "center",
  574. valign: 'middle'
  575. }, {
  576. field: 'drugWin',
  577. title: '副数',
  578. align: "center",
  579. valign: 'middle',
  580. }, {
  581. field: 'unitPrice',
  582. title: '单价(元)',
  583. align: "center",
  584. valign: 'middle',
  585. formatter: function (value, row, index) {
  586. return value.toFixed(2);
  587. }
  588. }, {
  589. field: 'amount',
  590. title: '总金额(元)',
  591. align: "center",
  592. valign: 'middle',
  593. formatter: function (value, row, index) {
  594. return value.toFixed(2);
  595. }
  596. }
  597. ],
  598. responseHandler: function (res) {
  599. if (res == '401' || res == 401) {
  600. window.location.href = '/thmz/login/view'
  601. return;
  602. }
  603. var ress = eval(res);
  604. if (ress.code == -1) {
  605. new PNotify({
  606. title: '错误提示',
  607. text: ress.message,
  608. type: 'error',
  609. hide: true,
  610. styling: 'bootstrap3'
  611. });
  612. return {
  613. "total": 0,//总页数
  614. "rows": {} //数据
  615. };
  616. }
  617. return {
  618. //"total": ress.pageViewVo.total,//总页数
  619. "rows": ress.data //数据
  620. };
  621. },
  622. });
  623. }
  624. /**
  625. * 构建列表查询参数
  626. * @param params
  627. * @returns {{patientId: string | number | string[] | undefined | jQuery, times: string | number | string[] | undefined | jQuery, billItemCode: number}}
  628. */
  629. function queryParamsForDetail(params) {
  630. var billItemGroup = getIndex("bill_item_group");
  631. var payMarkGroup = getIndex("pay_mark_group");
  632. var temp = {
  633. patientId: $("#patientIdChargeItem").val(),
  634. times: $("#timesChargeItem").val(),
  635. receiptNo: $("#receiptNoChargeItem").val(),
  636. billItemCode: billItemGroup,
  637. payMark: 5
  638. };
  639. if (payMarkGroup == 1) {
  640. temp.payMark = 0;
  641. } else if (payMarkGroup == 2) {
  642. temp.payMark = 1;
  643. }
  644. return temp;
  645. };
  646. /**
  647. * 构建列表查询参数
  648. * @param params
  649. * @returns {{patientId: string | number | string[] | undefined | jQuery, times: string | number | string[] | undefined | jQuery, billItemCode: number}}
  650. */
  651. function queryParamsForRefundByBillItem(params) {
  652. var billItemGroup = getIndex("refund_bill_item_group");
  653. return {
  654. patientId: $("#patientIdRefund").val(),
  655. times: $("#timesRefund").val(),
  656. receiptNo: $("#receiptNoRefund").val(),
  657. chargeItemCodes: chargeItemCodes,
  658. billItemCode: billItemGroup
  659. };
  660. };
  661. /**
  662. * 卡号输入改变事件
  663. */
  664. function cardNoChange() {
  665. if (window.ActiveXObject || "ActiveXObject" in window) {
  666. $("#cardNo").on('input propertychange', function () {
  667. queryUserInfoByCardNo();
  668. });
  669. } else {
  670. $("#cardNo").on('input οninput', function () {
  671. queryUserInfoByCardNo();
  672. });
  673. }
  674. }
  675. /**
  676. * 卡号有变化后查询病人信息
  677. */
  678. function queryUserInfoByCardNo() {
  679. var cardNo = $("#cardNo").val();
  680. var index = cardNo.indexOf("-");
  681. if (index > 0 && index == cardNo.length - 2) {
  682. $("#patientId").val(cardNo);
  683. initFeeTable();
  684. } else if (cardNo == '120' || cardNo.length == 8) {
  685. $("#cardNo").attr("title", cardNo);
  686. $.ajax({
  687. type: "GET",
  688. url: '/thmz/getByIcCardNo?icCardNo=' + cardNo,
  689. contentType: "application/json;charset=UTF-8",
  690. dataType: "json",
  691. headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
  692. success: function (res) {
  693. if (res == '401' || res == 401) {
  694. window.location.href = '/thmz/login/view'
  695. return;
  696. }
  697. if (res.code == 0) {
  698. if (res.data != null) {
  699. $("#patientId").val(res.data.patientId);
  700. initFeeTable();
  701. }
  702. } else {
  703. new PNotify({
  704. title: '错误提示',
  705. text: res.message,
  706. type: 'error',
  707. hide: true,
  708. styling: 'bootstrap3'
  709. });
  710. }
  711. }
  712. });
  713. } else if (cardNo == null || cardNo == "") {
  714. cleanParams();
  715. }
  716. }
  717. /**
  718. * 获取按钮组选择的下标
  719. * @param id
  720. * @returns {number}
  721. */
  722. function getIndex(id) {
  723. var index = 0;
  724. var item = $("#" + id).find("button");
  725. for (var i = 0; i <= item.length; i++) {
  726. if ($(item[i]).hasClass("btn-primary")) {
  727. index = i;
  728. break;
  729. }
  730. }
  731. return index;
  732. }
  733. /**
  734. * 获取时间选择器的时间数组
  735. * @returns {string[]}
  736. */
  737. function getRePortRangeArr() {
  738. var rePortRange = $('#reportrange span').html();
  739. var rePortRangeArr = rePortRange.split(" - ");
  740. rePortRangeArr[0] = rePortRangeArr[0] + " 00:00:00"
  741. rePortRangeArr[1] = rePortRangeArr[1] + " 23:59:59"
  742. return rePortRangeArr;
  743. }
  744. /**
  745. * 打开收费窗口
  746. */
  747. function confirmFeeModal(times, totalCharge, receiptNo) {
  748. $('#payType').selectpicker('val', 1);
  749. $('#payType').selectpicker('refresh');
  750. var data = parseFloat($("#dataIdHaveTally").val());
  751. if (totalCharge != null && totalCharge > 0) {
  752. data = totalCharge;
  753. $("#timesHaveTally").val(times);
  754. $("#receiptNoHaveTally").val(receiptNo);
  755. }
  756. var prevAll = $("#changeAmountParent").prevAll();
  757. while (prevAll.length > 2) {
  758. $("#changeAmountParent").prev().remove();
  759. prevAll = $("#changeAmountParent").prevAll();
  760. }
  761. $("#realMoney").val($("#amountMoneyConfirm").text());
  762. $("#cash").val($("#amountMoneyConfirm").text());
  763. $("#tallyDetailModal").modal('hide');
  764. $("#haveTallyModal").modal('hide');
  765. $("#confirmFeeModal").modal();
  766. $("#amountMoneyConfirm").text(data);
  767. $("#realMoney").val(data);
  768. $("#cash").val(data);
  769. // $("#cash").val(null);
  770. setTimeout(function () {
  771. //默认光标在卡号输入框
  772. $("#cash").focus();
  773. }, 800);
  774. $("#payType").selectpicker('val', 1);
  775. $("#payType").selectpicker('refresh');
  776. $("#changeAmount").val(0.0);
  777. $("#surplusAmount").val(0.0);
  778. }
  779. /**
  780. * 打开收费明细窗口
  781. * @param data
  782. */
  783. function chargeDetailModal(patientId, times, receiptNo) {
  784. $("#patientIdChargeItem").val(patientId);
  785. $("#timesChargeItem").val(times);
  786. $("#receiptNoChargeItem").val(receiptNo);
  787. $("#chargeDetailModal").modal();
  788. initChargeDetailTable();
  789. }
  790. /**
  791. * 病人当前就诊次数的诊断查询
  792. * @param data
  793. */
  794. function diagnoseQuery(patientId, times) {
  795. $.ajax({
  796. type: "POST",
  797. url: '/thmz/getVisitTableByPatientIdAndTimes',
  798. contentType: "application/json;charset=UTF-8",
  799. dataType: "json",
  800. data: JSON.stringify({"patientId": patientId, "times": times}),
  801. headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
  802. async: false,
  803. success: function (res) {
  804. if (res == '401' || res == 401) {
  805. window.location.href = '/thmz/login/view'
  806. return;
  807. }
  808. if (res.code == 0) {
  809. if (res.data.icdText != null || res.data.icdText != '') {
  810. $("#diagnoseModal").modal();
  811. $("#diagnose").html(res.data.icdText);
  812. } else {
  813. new PNotify({
  814. title: '操作提示',
  815. text: '当前病人诊断未知',
  816. type: 'warn',
  817. styling: 'bootstrap3'
  818. });
  819. }
  820. } else {
  821. errorMesage(res);
  822. }
  823. }
  824. });
  825. }
  826. // /**
  827. // * 打开退费重收明细窗口
  828. // * @param data
  829. // */
  830. // function chargeRefundDetailModal(patientId, times) {
  831. // // $("#patientIdChargeItem").val(patientId);
  832. // // $("#timesChargeItem").val(times);
  833. // initMzChargeDetailByBillItem();
  834. // }
  835. /**
  836. * 初始门诊收银方式下拉选
  837. */
  838. function initChequeType(payType) {
  839. $.ajax({
  840. type: "GET",
  841. url: '/thmz/getAllZdChequeTypeForMz',
  842. dataType: "json",
  843. headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
  844. success: function (res) {
  845. if (res == '401' || res == 401) {
  846. window.location.href = '/thmz/login/view'
  847. return;
  848. }
  849. var html = '';
  850. $.each(res.data, function (commentIndex, comment) {
  851. html += '<option value="' + comment.code + '">' + comment.name + '</option>';
  852. });
  853. $('#' + payType).empty();
  854. $('#' + payType).html(html);
  855. $('#' + payType).selectpicker('refresh');
  856. $('#' + payType).selectpicker('val', 1);
  857. $('#' + payType).selectpicker('refresh');
  858. }
  859. });
  860. }
  861. /**
  862. * 关闭当前这个付款方式
  863. */
  864. function closeThisParent(obj) {
  865. $(obj).parent().parent().parent().remove();
  866. checkFee(false);
  867. }
  868. /**
  869. * 校验收款金额
  870. * @param flag 是否时提交时候的校验,是的话,如果缴费金额不够,需要返回 false
  871. */
  872. function checkFee(flag) {
  873. var realMoney = parseFloat($("#realMoney").val());
  874. realMoney = realMoney.toFixed(2);
  875. $("#realMoney").val(realMoney)
  876. var arr = $("#payForm").find("div.pay-item");
  877. if (arr.length > 0) {
  878. //非现金收款总金额
  879. var notCashAmount = 0;
  880. //现金收款总额
  881. var cashAmount = 0;
  882. for (var i = 0; i < arr.length; i++) {
  883. var temp = parseFloat($(arr[i]).find("input").val());
  884. if (isNaN(temp)) {
  885. temp = 0;
  886. }
  887. if ($(arr[i]).find("select").val() != 1) {
  888. notCashAmount += temp;
  889. } else {
  890. cashAmount += temp;
  891. }
  892. for (var j = 0; j < arr.length; j++) {
  893. if ($(arr[i]).find("select").val() == $(arr[j]).find("select").val() && i != j) {
  894. new PNotify({
  895. title: '错误提示',
  896. text: "已经存在相同的收款方式,请不要重复添加!",
  897. type: 'error',
  898. hide: true,
  899. styling: 'bootstrap3'
  900. });
  901. return;
  902. }
  903. }
  904. }
  905. if (notCashAmount > realMoney) {
  906. new PNotify({
  907. title: '错误提示',
  908. text: "非现金收款金额不能大于实收金额!",
  909. type: 'error',
  910. hide: true,
  911. styling: 'bootstrap3'
  912. });
  913. $("#addPayType").parent().removeClass("in").addClass("hide");
  914. return;
  915. }
  916. var totalAmount = cashAmount + notCashAmount;
  917. $("#surplusAmount").val(0.0);
  918. if (totalAmount < realMoney) {
  919. if (flag) {
  920. new PNotify({
  921. title: '错误提示',
  922. text: "收款金额不能少于实收金额,请调整收款金额或者增加收款方式!",
  923. type: 'error',
  924. hide: true,
  925. styling: 'bootstrap3'
  926. });
  927. return false;
  928. }
  929. if (totalAmount == 0) {
  930. $("#addPayType").parent().removeClass("in").addClass("hide");
  931. } else {
  932. $("#addPayType").parent().removeClass("hide").addClass("in");
  933. }
  934. $("#changeAmount").val(0.00);
  935. var surplusAmount = realMoney - totalAmount;
  936. $("#surplusAmount").val(surplusAmount.toFixed(2));
  937. return;
  938. }
  939. var changeAmount = 0.00;
  940. if (totalAmount >= realMoney) {
  941. changeAmount = totalAmount - realMoney;
  942. changeAmount = changeAmount.toFixed(2);
  943. $("#changeAmount").val(changeAmount);
  944. $("#addPayType").parent().removeClass("in").addClass("hide");
  945. }
  946. //设置收费首页找零与应收和实收金额
  947. $("#payableAmount").text(realMoney);
  948. $("#paidAmount").text(totalAmount);
  949. $("#changedAmount").text(changeAmount);
  950. }
  951. //计算和设置折扣比例
  952. var amountMoneyConfirm = parseFloat($("#amountMoneyConfirm").text());
  953. var discount = 100;
  954. if (realMoney < amountMoneyConfirm) {
  955. discount = realMoney / amountMoneyConfirm * 100;
  956. }
  957. $("#discount").text(discount.toFixed(2))
  958. return true;
  959. }
  960. /**
  961. * 提示有记账记录
  962. */
  963. function tipHaveTally(data, patientId, times, name, receiptNo) {
  964. if (patientId == null || patientId == "") {
  965. return;
  966. }
  967. $("#patientIdHaveTally").val(patientId);
  968. $("#nameHaveTally").val(name);
  969. $("#dataIdHaveTally").val(data);
  970. $("#timesHaveTally").val(times);
  971. $("#receiptNoHaveTally").val(receiptNo);
  972. // $.ajax({
  973. // type: "GET",
  974. // url: '/thmz/getTallyTotalCharge?patientId=' + patientId,
  975. // contentType: "application/json;charset=UTF-8",
  976. // dataType: "json",
  977. // headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
  978. // success: function (res) {
  979. // if (res == '401' || res == 401) {
  980. // window.location.href = '/thmz/login/view'
  981. // return;
  982. // }
  983. // if (res.code == 0) {
  984. // if (res.data != null && res.data > 0) {
  985. // $("#haveTallyModal").modal();
  986. // $("#totalTallyAmount").text(res.data.toFixed(2));
  987. // } else {
  988. // $("#haveTallyModal").modal('hide');
  989. // confirmFeeModal(null,null,null);
  990. // }
  991. // } else {
  992. // new PNotify({
  993. // title: '错误提示',
  994. // text: res.message,
  995. // type: 'error',
  996. // hide: true,
  997. // styling: 'bootstrap3'
  998. // });
  999. // }
  1000. // }
  1001. // });
  1002. confirmFeeModal(null, null, null);
  1003. }
  1004. var $tally_detail_table;
  1005. /**
  1006. * 初始化本院记账明细表格
  1007. */
  1008. function initTallyDetailTable() {
  1009. $("#haveTallyModal").modal('hide');
  1010. var patientId = $("#patientIdHaveTally").val();
  1011. // var name = $("#nameHaveTally").val();
  1012. if (patientId == null || patientId == '') {
  1013. return;
  1014. }
  1015. $("#tallyDetailModal").modal();
  1016. $('#tally_detail_table').bootstrapTable("destroy");
  1017. $tally_detail_table = $('#tally_detail_table').bootstrapTable({
  1018. url: '/thmz/getTallyReceiptSerial?patientId=' + patientId, //请求后台的URL(*)
  1019. method: 'get', //请求方式(*)
  1020. toolbar: '#toolbar', //工具按钮用哪个容器
  1021. striped: true, //是否显示行间隔色
  1022. cache: false, //是否使用缓存,默认为true,所以一般情况下需要设置一下这个属性(*)
  1023. pagination: false, //是否显示分页(*)
  1024. sortable: true, //是否启用排序
  1025. sortOrder: "asc", //排序方式
  1026. sidePagination: "server", //分页方式:client客户端分页,server服务端分页(*)
  1027. pageNumber: 1, //初始化加载第一页,默认第一页
  1028. pageSize: 10, //每页的记录行数(*)
  1029. pageList: [10, 25, 50, 100], //可供选择的每页的行数(*)
  1030. search: false, //是否显示表格搜索,此搜索是客户端搜索,不会进服务端,所以,个人感觉意义不大
  1031. strictSearch: true,
  1032. showColumns: false, //是否显示所有的列
  1033. showRefresh: false, //是否显示刷新按钮
  1034. minimumCountColumns: 2, //最少允许的列数
  1035. clickToSelect: true, //是否启用点击选中行
  1036. uniqueId: "ID", //每一行的唯一标识,一般为主键列
  1037. showToggle: false, //是否显示详细视图和列表视图的切换按钮
  1038. cardView: false, //是否显示详细视图
  1039. detailView: false,
  1040. //rowStyle:rowStyle,//通过自定义函数设置行样式
  1041. ajaxOptions: {
  1042. headers: {
  1043. 'Accept': 'application/json',
  1044. 'Authorization': 'Bearer ' + localStorage.getItem("token")
  1045. }
  1046. },
  1047. columns: [
  1048. // {
  1049. // checkbox: true,
  1050. // },
  1051. {
  1052. field: 'patientId',
  1053. title: '病人编号',
  1054. align: "center",
  1055. valign: 'middle'
  1056. }, {
  1057. field: 'name',
  1058. title: '病人姓名',
  1059. align: "center",
  1060. valign: 'middle',
  1061. // formatter: function (value, row, index) {
  1062. // return name;
  1063. // }
  1064. }, {
  1065. field: 'times',
  1066. title: '就诊次数',
  1067. align: "center",
  1068. valign: 'middle',
  1069. },
  1070. {
  1071. field: 'totalCharge',
  1072. title: '总费用(元)',
  1073. align: "center",
  1074. valign: 'middle',
  1075. formatter: function (value, row, index) {
  1076. return value.toFixed(2);
  1077. }
  1078. }
  1079. ],
  1080. /**
  1081. * @param {点击列的 field 名称} field
  1082. * @param {点击列的 value 值} value
  1083. * @param {点击列的整行数据} row
  1084. * @param {td 元素} $element
  1085. */
  1086. onClickCell: function (field, value, row, $element) {
  1087. var cardNo = $("#cardNo").val();
  1088. if (cardNo == '120' && field == 'name') {
  1089. $element.attr('contenteditable', true);
  1090. $element.html(null);
  1091. $element.focus();
  1092. $element.blur(function () {
  1093. var index = $element.parent().data('index');
  1094. var tdValue = $element.html();
  1095. saveData(index, field, tdValue, row, $tally_detail_table);
  1096. })
  1097. }
  1098. },
  1099. onDblClickRow: function (row) {
  1100. confirmFeeModal(row.times, row.totalCharge, row.receiptNo);
  1101. },
  1102. responseHandler: function (res) {
  1103. if (res == '401' || res == 401) {
  1104. window.location.href = '/thmz/login/view'
  1105. return;
  1106. }
  1107. var ress = eval(res);
  1108. if (ress.code == -1) {
  1109. new PNotify({
  1110. title: '错误提示',
  1111. text: ress.message,
  1112. type: 'error',
  1113. hide: true,
  1114. styling: 'bootstrap3'
  1115. });
  1116. return {
  1117. "total": 0,//总页数
  1118. "rows": {} //数据
  1119. };
  1120. }
  1121. if (ress.data == null || ress.data.length == 0) {
  1122. $("#tallyDetailModal").modal("hide");
  1123. }
  1124. return {
  1125. "rows": ress.data //数据
  1126. };
  1127. },
  1128. });
  1129. }
  1130. /**
  1131. * 提交缴费申请
  1132. */
  1133. function saveConfirmFee() {
  1134. if (!checkFee(true)) {
  1135. return;
  1136. }
  1137. var jsonData = JSON.parse('{"patientId":"","times":"","receiptNo":"","mzDepositFiles":[]}');
  1138. var patientId = $("#patientIdHaveTally").val();
  1139. var times = $("#timesHaveTally").val();
  1140. var receiptNo = $("#receiptNoHaveTally").val();
  1141. jsonData.patientId = patientId;
  1142. jsonData.times = times;
  1143. jsonData.receiptNo = receiptNo;
  1144. var arr = $("#payForm").find("div.pay-item");
  1145. if (arr.length > 0) {
  1146. for (var i = 0; i < arr.length; i++) {
  1147. var temp = parseFloat($(arr[i]).find("input").val());
  1148. var tempJson = JSON.parse('{"chequeType":"","amount":""}');
  1149. tempJson.chequeType = $(arr[i]).find("select").val();
  1150. if (tempJson.chequeType == "1") {
  1151. temp = temp - $("#changeAmount").val();
  1152. temp = temp.toFixed(2);
  1153. }
  1154. tempJson.amount = temp;
  1155. jsonData.mzDepositFiles[i] = tempJson;
  1156. }
  1157. }
  1158. $.ajax({
  1159. type: "POST",
  1160. url: '/thmz/chargeFee',
  1161. contentType: "application/json;charset=UTF-8",
  1162. dataType: "json",
  1163. data: JSON.stringify(jsonData),
  1164. headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
  1165. success: function (res) {
  1166. if (res == '401' || res == 401) {
  1167. window.location.href = '/thmz/login/view'
  1168. return;
  1169. }
  1170. if (res.code == 0) {
  1171. prn1Print(patientId, times, true);
  1172. new PNotify({
  1173. title: '操作提示',
  1174. text: res.message,
  1175. type: 'success',
  1176. hide: true,
  1177. styling: 'bootstrap3'
  1178. });
  1179. $("#confirmFeeModal").modal("hide");
  1180. initFeeTable();
  1181. $("#patientId").val(null);
  1182. $("#cardNo").val(null);
  1183. $("#name").val(null);
  1184. //默认光标在卡号输入框
  1185. $("#cardNo").focus();
  1186. } else {
  1187. new PNotify({
  1188. title: '错误提示',
  1189. text: res.message,
  1190. type: 'error',
  1191. hide: true,
  1192. styling: 'bootstrap3'
  1193. });
  1194. }
  1195. }
  1196. });
  1197. }
  1198. /**
  1199. * 直接打印发票
  1200. * @param patientId
  1201. * @param times
  1202. * @param chargeFeeFlag 收费 退费标记 true 收费和重打发票来源 false 退费来源
  1203. */
  1204. function prn1Print(patientId, times, chargeFeeFlag) {
  1205. var url = '/thmz/getAllSerialForThisTime?patientId=' + patientId + "&times=" + times;
  1206. printCommon(url, patientId, times, chargeFeeFlag);
  1207. }
  1208. /**
  1209. * 重打发票
  1210. * @param patientId
  1211. * @param times
  1212. */
  1213. function repPrint(patientId, times) {
  1214. $.ajax({
  1215. type: "GET",
  1216. url: '/thmz/getReceiptForThisTime?patientId=' + patientId + "&times=" + times,
  1217. contentType: "application/json;charset=UTF-8",
  1218. dataType: "json",
  1219. headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
  1220. success: function (res) {
  1221. if (res == '401' || res == 401) {
  1222. window.location.href = '/thmz/login/view'
  1223. return;
  1224. }
  1225. if (res.code == 0) {
  1226. if (res.data.length == 1) {
  1227. var message = "确定要重新打印发票号码为【" + res.data[0].receiptBill + "】的发票吗?请确认发票打印机即将要打印的发票编号";
  1228. var url = '/thmz/repPrintForThisTime?patientId=' + patientId + "&times=" + times + "&obsolete=0" + "&receiptBill=" + res.data[0].receiptBill;
  1229. confirmMessage(patientId, times, message, url);
  1230. } else {
  1231. $("#tip_message").text("请选择需要重新打印的发票号");
  1232. $("#repPrintModal").modal();
  1233. $("#repPrintTable").html(null);
  1234. for (var i = 0; i < res.data.length; i++) {
  1235. $("<tr><td>" + res.data[i].receiptBill + "</td></tr>").appendTo("#repPrintTable").bind('click', function () {
  1236. $("#repPrintModal").modal("hide");
  1237. var message = "确定要重新打印发票号码为【" + $(this).text() + "】的发票吗?请确认发票打印机即将要打印的发票编号";
  1238. var url = '/thmz/repPrintForThisTime?patientId=' + patientId + "&times=" + times + "&obsolete=0" + "&receiptBill=" + $(this).text();
  1239. confirmMessage(patientId, times, message, url);
  1240. });
  1241. }
  1242. }
  1243. }
  1244. }
  1245. });
  1246. }
  1247. /**
  1248. * 发票重打提示
  1249. * @param patientId
  1250. * @param times
  1251. * @param name
  1252. */
  1253. function confirmMessage(patientId, times, message, url) {
  1254. if (!confirm(message)) {
  1255. return;
  1256. }
  1257. //var url='/thmz/repPrintForThisTime?patientId=' + patientId + "&times=" + times + "&obsolete=0" + "&receiptBill="+receiptBill;
  1258. printCommon(url, patientId, times, true);
  1259. }
  1260. /**
  1261. * 作废重打发票
  1262. * @param patientId
  1263. * @param times
  1264. */
  1265. function obsoleteAndRepPrint(patientId, times, receiptNo) {
  1266. $.ajax({
  1267. type: "GET",
  1268. url: '/thmz/getReceiptForThisTime?patientId=' + patientId + "&times=" + times + "&receiptNo=" + receiptNo,
  1269. contentType: "application/json;charset=UTF-8",
  1270. dataType: "json",
  1271. headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
  1272. success: function (res) {
  1273. if (res == '401' || res == 401) {
  1274. window.location.href = '/thmz/login/view'
  1275. return;
  1276. }
  1277. if (res.code == 0) {
  1278. if (res.data.length == 1) {
  1279. var message = "确定要作废发票号码为【" + res.data[0].receiptBill + "】的发票吗?请确认需要作废发票编号";
  1280. var url = '/thmz/repPrintForThisTime?patientId=' + patientId + "&times=" + times + "&obsolete=1" + "&receiptBill=" + res.data[0].receiptBill;
  1281. confirmMessage(patientId, times, message, url);
  1282. } else {
  1283. $("#tip_message").text("请选择需要作废的发票号");
  1284. $("#repPrintModal").modal();
  1285. $("#repPrintTable").html(null);
  1286. for (var i = 0; i < res.data.length; i++) {
  1287. $("<tr><td>" + res.data[i].receiptBill + "</td></tr>").appendTo("#repPrintTable").bind('click', function () {
  1288. $("#repPrintModal").modal("hide");
  1289. var message = "确定要作废发票号码为【" + $(this).text() + "】的发票吗?请确认需要作废发票编号";
  1290. var url = '/thmz/repPrintForThisTime?patientId=' + patientId + "&times=" + times + "&obsolete=1" + "&receiptBill=" + $(this).text();
  1291. confirmMessage(patientId, times, message, url);
  1292. });
  1293. }
  1294. }
  1295. }
  1296. }
  1297. });
  1298. }
  1299. /**
  1300. * 打印发票通用方法
  1301. * @param patientId
  1302. * @param times
  1303. * @param chargeFeeFlag 收费 退费标记 true 收费和重打发票来源 false 退费来源
  1304. */
  1305. function printCommon(url, patientId, times, chargeFeeFlag) {
  1306. setPrint();
  1307. var height = "93.02mm";
  1308. // if (countReceiot % 2 == 0) {
  1309. // height = "93.2mm";
  1310. // }
  1311. $.ajax({
  1312. type: "GET",
  1313. url: url,
  1314. contentType: "application/json;charset=UTF-8",
  1315. dataType: "json",
  1316. headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
  1317. success: function (res) {
  1318. if (res == '401' || res == 401) {
  1319. window.location.href = '/thmz/login/view'
  1320. return;
  1321. }
  1322. if (res.code == 0) {
  1323. if (res.data == null || res.data.length == 0) {
  1324. return;
  1325. }
  1326. // countReceiot++;
  1327. for (var i = 0; i < res.data.length; i++) {
  1328. LODOP = getLodop();
  1329. var temp = res.data[i].mzReceiptSerial;
  1330. LODOP.PRINT_INITA(6, 0, "120mm", height, "泰和门诊发票打印");
  1331. //设置默认打印机
  1332. LODOP.SET_PRINTER_INDEX(printIndex);
  1333. LODOP.SET_SHOW_MODE("BKIMG_WIDTH", "120mm");
  1334. LODOP.SET_SHOW_MODE("BKIMG_HEIGHT", height);
  1335. LODOP.SET_PRINT_PAGESIZE(1, "120mm", height, "CreateCustomPage");
  1336. LODOP.SET_PRINT_MODE("CREATE_CUSTOM_PAGE_NAME", "门诊发票");//对新建的纸张重命名
  1337. LODOP.SET_PRINT_STYLE("FontSize", 11); //字体大小
  1338. LODOP.ADD_PRINT_TEXT("6mm", "0mm", "45mm", "3mm", "湖南泰和医院管理有限公司");
  1339. LODOP.ADD_PRINT_TEXT("6mm", "59mm", "30mm", "3mm", "机制号:");
  1340. LODOP.ADD_PRINT_TEXT("6mm", "72mm", "20mm", "3mm", temp.serialNo);
  1341. LODOP.ADD_PRINT_TEXT("19mm", "0mm", "35mm", "3mm", temp.receiptBill);
  1342. LODOP.ADD_PRINT_TEXT("25mm", "7mm", "40mm", "3mm", res.mzPatientMi.name);
  1343. LODOP.ADD_PRINT_TEXT("25mm", "61mm", "27mm", "3mm", patientId);
  1344. var feeList = res.data[i].feeList;
  1345. if (feeList != null && feeList.length > 0) {
  1346. var top = 32;
  1347. var left = 6;
  1348. for (var j = 0; j < feeList.length; j++) {
  1349. var row = parseInt(j / 3);
  1350. var tempTop = top + row * 5;
  1351. var tempLeft = left;
  1352. if (j % 3 == 1) {
  1353. tempLeft = left + 30;
  1354. } else if (j % 3 == 2) {
  1355. tempLeft = left + 60;
  1356. }
  1357. LODOP.ADD_PRINT_TEXT(tempTop + "mm", tempLeft + "mm", "30mm", "3mm", feeList[j]);
  1358. }
  1359. }
  1360. // LODOP.ADD_PRINT_TEXT("32mm","25mm","25mm","3mm","诊查费 10.00");
  1361. // LODOP.ADD_PRINT_TEXT("32mm","50mm","25mm","3mm","中成药费30.10");
  1362. // LODOP.ADD_PRINT_TEXT("37mm","25mm","25mm","3mm","治疗费 22.00");
  1363. // LODOP.ADD_PRINT_TEXT("37mm","50mm","25mm","3mm","材料费 14.20");
  1364. // LODOP.ADD_PRINT_TEXT("42mm","25mm","25mm","3mm","西药费 161.20");
  1365. var qyxxs = res.data[i].qyxxs;
  1366. if (qyxxs != null && qyxxs.length > 0) {
  1367. var top = 54;
  1368. for (var j = 0; j < qyxxs.length; j++) {
  1369. var row = j / 3;
  1370. var tempTop = top + row * 10;
  1371. var qyxx = qyxxs[j];
  1372. var arr = qyxx.split(",");
  1373. LODOP.ADD_PRINT_TEXT(tempTop + "mm", "6mm", "50mm", "3mm", "取药窗口:" + arr[0]);
  1374. LODOP.ADD_PRINT_TEXT(tempTop + "mm", "61mm", "50mm", "3mm", "取药号码:" + arr[1]);
  1375. }
  1376. }
  1377. // LODOP.ADD_PRINT_TEXT("54mm","25mm","50mm","3mm","取药窗口:西药房4号窗口");
  1378. // LODOP.ADD_PRINT_TEXT("54mm","80mm","35mm","3mm","取药号码:408392");
  1379. LODOP.ADD_PRINT_TEXT("65mm", "21mm", "60mm", "3mm", temp.totalCharge + " 元");
  1380. LODOP.ADD_PRINT_TEXT("72mm", "19mm", "60mm", "3mm", res.data[i].totalChargeStr);
  1381. LODOP.ADD_PRINT_TEXT("79mm", "0mm", "15mm", "3mm", res.data[i].year);//年
  1382. LODOP.ADD_PRINT_TEXT("79mm", "13mm", "10mm", "3mm", res.data[i].month);//月
  1383. LODOP.ADD_PRINT_TEXT("79mm", "25mm", "10mm", "3mm", res.data[i].day);//日
  1384. LODOP.ADD_PRINT_TEXT("79mm", "53mm", "50mm", "3mm", temp.operatorId);//收费员
  1385. LODOP.PRINT();
  1386. //LODOP.PREVIEW();
  1387. initFeeTable();
  1388. }
  1389. } else if (res.code == -1) {
  1390. if (!chargeFeeFlag) {
  1391. return;
  1392. }
  1393. new PNotify({
  1394. title: '错误提示',
  1395. text: res.message,
  1396. type: 'error',
  1397. hide: true,
  1398. styling: 'bootstrap3'
  1399. });
  1400. }
  1401. }
  1402. });
  1403. }
  1404. //
  1405. // /**
  1406. // * 加载打印机列表
  1407. // * @constructor
  1408. // */
  1409. // function CreatePrinterList() {
  1410. // LODOP = getLodop();
  1411. // LODOP.PRINT_INITA(6, 0, "92mm", "120mm", "泰和门诊发票打印");
  1412. // //获取打印机设备数,用于进行遍历
  1413. // var count = LODOP.GET_PRINTER_COUNT();
  1414. // var html = "";
  1415. // for (var i = 0; i < count; i++) {
  1416. // //根据设备序号获取设备名
  1417. // var msg = LODOP.GET_PRINTER_NAME(i);
  1418. // html += "<option value='" + i + "'>" + msg + "</option>";
  1419. // }
  1420. // $('#printSelect').html(html);
  1421. // $('#printSelect').selectpicker('refresh');
  1422. // $.ajax({
  1423. // type: "GET",
  1424. // url: '/thmz/getLastWindowsByCurrentUser',
  1425. // contentType: "application/json;charset=UTF-8",
  1426. // dataType: "json",
  1427. // headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
  1428. // success: function (res) {
  1429. // if (res == '401' || res == 401) {
  1430. // window.location.href = '/thmz/login/view'
  1431. // return;
  1432. // }
  1433. // if (res.code == 0) {
  1434. // $('#printSelect').selectpicker('val', res.data.printIndex);
  1435. // $('#printSelect').selectpicker('refresh');
  1436. // printIndex=res.data.printIndex;
  1437. // }
  1438. // }
  1439. // });
  1440. // }
  1441. //
  1442. //
  1443. // /**
  1444. // * 保存窗口号
  1445. // */
  1446. // function saveWindows() {
  1447. // $.ajax({
  1448. // type: "POST",
  1449. // url: '/thmz/saveWindows',
  1450. // contentType: "application/json;charset=UTF-8",
  1451. // dataType: "json",
  1452. // data: JSON.stringify({"windowsNo": $("#windowsNum").val()}),
  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. // $('#editWindowsModal').modal('hide');
  1460. // if (res.code == 0) {
  1461. // new PNotify({
  1462. // title: '操作提示',
  1463. // text: res.message,
  1464. // type: 'success',
  1465. // hide: true,
  1466. // styling: 'bootstrap3'
  1467. // });
  1468. // } else {
  1469. // new PNotify({
  1470. // title: '错误提示',
  1471. // text: res.message,
  1472. // type: 'error',
  1473. // hide: true,
  1474. // styling: 'bootstrap3'
  1475. // });
  1476. // }
  1477. // }
  1478. // });
  1479. // }
  1480. //
  1481. //
  1482. //
  1483. // /**
  1484. // * 保存打印机
  1485. // */
  1486. // function savePrint() {
  1487. // $.ajax({
  1488. // type: "POST",
  1489. // url: '/thmz/savePrintIndex',
  1490. // contentType: "application/json;charset=UTF-8",
  1491. // dataType: "json",
  1492. // data: JSON.stringify({"printIndex": $("#printSelect").val()}),
  1493. // headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
  1494. // success: function (res) {
  1495. // if (res == '401' || res == 401) {
  1496. // window.location.href = '/thmz/login/view'
  1497. // return;
  1498. // }
  1499. // LODOP = getLodop();
  1500. // LODOP.PRINT_INITA(6, 0, "92mm", "120mm", "泰和门诊发票打印");
  1501. // LODOP.SET_PRINTER_INDEX($("#printSelect").val());
  1502. // printIndex=$("#printSelect").val();
  1503. // $('#editPrintModal').modal('hide');
  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. // } else {
  1513. // new PNotify({
  1514. // title: '错误提示',
  1515. // text: res.message,
  1516. // type: 'error',
  1517. // hide: true,
  1518. // styling: 'bootstrap3'
  1519. // });
  1520. // }
  1521. // }
  1522. // });
  1523. // }
  1524. /**
  1525. * 查询默认打印机
  1526. */
  1527. function setPrint() {
  1528. if (printIndex >= 0) {
  1529. return;
  1530. }
  1531. $.ajax({
  1532. type: "GET",
  1533. url: '/thmz/getLastWindowsByCurrentUser',
  1534. contentType: "application/json;charset=UTF-8",
  1535. dataType: "json",
  1536. headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
  1537. async: false,
  1538. success: function (res) {
  1539. if (res == '401' || res == 401) {
  1540. window.location.href = '/thmz/login/view'
  1541. return;
  1542. }
  1543. if (res.code == 0) {
  1544. printIndex = res.data.printIndex;
  1545. } else {
  1546. printIndex = -1;
  1547. }
  1548. }
  1549. });
  1550. }
  1551. /**
  1552. * 退费操作
  1553. */
  1554. function refundFee(patientId, times, receiptNo, printFlag) {
  1555. if (printFlag == 0) {
  1556. new PNotify({
  1557. title: '错误提示',
  1558. text: '当前病人缴费记录发票还未打印,无法进行退费,请先打印该发票!',
  1559. type: 'error',
  1560. hide: true,
  1561. styling: 'bootstrap3'
  1562. });
  1563. return;
  1564. }
  1565. $("#refundFeeDetailModal").modal();
  1566. $("#refund_bill_item_group").removeClass("in").addClass("hide");
  1567. $('#refund_fee_bill_table').bootstrapTable("destroy");
  1568. initRefundFeeDetailTable(patientId, times, receiptNo);
  1569. }
  1570. /**
  1571. * 初始化退费明细表格
  1572. * @param patientId
  1573. * @param times
  1574. * @param receiptNo
  1575. */
  1576. function initRefundFeeDetailTable(patientId, times, receiptNo) {
  1577. $("#patientIdRefund").val(patientId);
  1578. $("#timesRefund").val(times);
  1579. $("#receiptNoRefund").val(receiptNo);
  1580. $('#refund_fee_detail_table').bootstrapTable("destroy");
  1581. $('#refund_fee_detail_table').bootstrapTable({
  1582. url: '/thmz/getRefundFeeDetail', //请求后台的URL(*)
  1583. method: 'post', //请求方式(*)
  1584. toolbar: '#toolbar', //工具按钮用哪个容器
  1585. striped: true, //是否显示行间隔色
  1586. cache: false, //是否使用缓存,默认为true,所以一般情况下需要设置一下这个属性(*)
  1587. pagination: false, //是否显示分页(*)
  1588. sortable: true, //是否启用排序
  1589. sortOrder: "asc", //排序方式
  1590. // sortName: 'orderNo', //排序字段
  1591. queryParams: queryParamsForRefundFee(patientId, times), //传递参数(*)
  1592. sidePagination: "server", //分页方式:client客户端分页,server服务端分页(*)
  1593. pageNumber: 1, //初始化加载第一页,默认第一页
  1594. pageSize: 10, //每页的记录行数(*)
  1595. pageList: [10, 25, 50, 100], //可供选择的每页的行数(*)
  1596. search: false, //是否显示表格搜索,此搜索是客户端搜索,不会进服务端,所以,个人感觉意义不大
  1597. strictSearch: true,
  1598. showColumns: false, //是否显示所有的列
  1599. showRefresh: false, //是否显示刷新按钮
  1600. minimumCountColumns: 2, //最少允许的列数
  1601. clickToSelect: true, //是否启用点击选中行
  1602. uniqueId: "ID", //每一行的唯一标识,一般为主键列
  1603. showToggle: false, //是否显示详细视图和列表视图的切换按钮
  1604. cardView: false, //是否显示详细视图
  1605. detailView: false,
  1606. //rowStyle:rowStyle,//通过自定义函数设置行样式
  1607. ajaxOptions: {
  1608. headers: {
  1609. 'Accept': 'application/json',
  1610. 'Authorization': 'Bearer ' + localStorage.getItem("token")
  1611. }
  1612. },
  1613. columns: [
  1614. {
  1615. checkbox: true,
  1616. formatter: function (value, row, index) {
  1617. if (row.confirmFlag == 1) {
  1618. return {
  1619. disabled: true, //设置是否可用
  1620. checked: false//设置选中
  1621. }
  1622. }
  1623. if (row.confirmFlag == 3) {
  1624. return {
  1625. disabled: true, //设置是否可用
  1626. checked: true//设置选中
  1627. }
  1628. }
  1629. }
  1630. },
  1631. {
  1632. field: 'orderNo',
  1633. title: '处方号',
  1634. align: "center",
  1635. valign: 'middle',
  1636. formatter: function (value, row, index) {
  1637. return Math.abs(value);
  1638. }
  1639. }, {
  1640. field: '',
  1641. title: '项目号',
  1642. align: "center",
  1643. valign: 'middle',
  1644. formatter: function (value, row, index) {
  1645. return index + 1;
  1646. }
  1647. }, {
  1648. field: 'billItemCode',
  1649. title: '分类名称',
  1650. align: "center",
  1651. valign: 'middle',
  1652. }, {
  1653. field: 'chargeItemCode',
  1654. title: '收费编码',
  1655. align: "center",
  1656. valign: 'middle',
  1657. }, {
  1658. field: 'tcName',
  1659. title: '项目',
  1660. align: "center",
  1661. valign: 'middle',
  1662. },
  1663. {
  1664. field: 'quantity',
  1665. title: '数量',
  1666. align: "center",
  1667. valign: 'middle'
  1668. }, {
  1669. field: 'unitPrice',
  1670. title: '单价(元)',
  1671. align: "center",
  1672. valign: 'middle',
  1673. formatter: function (value, row, index) {
  1674. return value.toFixed(2);
  1675. }
  1676. }, {
  1677. field: 'amount',
  1678. title: '总金额(元)',
  1679. align: "center",
  1680. valign: 'middle',
  1681. formatter: function (value, row, index) {
  1682. return value.toFixed(2);
  1683. }
  1684. }, {
  1685. field: 'confirmFlag',
  1686. title: '确认标志',
  1687. align: "center",
  1688. valign: 'middle',
  1689. formatter: function (value, row, index) {
  1690. if (value == 0) {
  1691. return "待确认";
  1692. }
  1693. if (value == 1) {
  1694. return "已确认";
  1695. }
  1696. if (value == 3) {
  1697. return "已取消";
  1698. }
  1699. if (value == 4) {
  1700. return "已退费";
  1701. }
  1702. }
  1703. }, {
  1704. field: 'decAmount',
  1705. title: '退药量',
  1706. align: "center",
  1707. valign: 'middle',
  1708. // formatter: function (value, row, index) {
  1709. // return value.toFixed(2);
  1710. // }
  1711. }, {
  1712. field: 'execDept',
  1713. title: '确认科室',
  1714. align: "center",
  1715. valign: 'middle'
  1716. }, {
  1717. field: 'confirmTime',
  1718. title: '确认时间',
  1719. align: "center",
  1720. valign: 'middle',
  1721. formatter: function (value, row, index) {
  1722. if (value != null && value != "") {
  1723. return format(value, "yyyy-MM-dd HH:mm:ss");
  1724. }
  1725. return "";
  1726. }
  1727. }
  1728. ],
  1729. responseHandler: function (res) {
  1730. if (res == '401' || res == 401) {
  1731. window.location.href = '/thmz/login/view'
  1732. return;
  1733. }
  1734. var ress = eval(res);
  1735. if (ress.code == -1) {
  1736. new PNotify({
  1737. title: '错误提示',
  1738. text: ress.message,
  1739. type: 'error',
  1740. hide: true,
  1741. styling: 'bootstrap3'
  1742. });
  1743. return {
  1744. "total": 0,//总页数
  1745. "rows": {} //数据
  1746. };
  1747. }
  1748. return {
  1749. //"total": ress.pageViewVo.total,//总页数
  1750. "rows": ress.data //数据
  1751. };
  1752. },
  1753. });
  1754. }
  1755. /**
  1756. * 退费列表参数
  1757. * @param patientId
  1758. * @param times
  1759. * @returns {{patientId: *, times: *}}
  1760. */
  1761. function queryParamsForRefundFee(patientId, times) {
  1762. var temp = {
  1763. patientId: patientId,
  1764. times: times,
  1765. };
  1766. return temp;
  1767. };
  1768. /**
  1769. * 发起预退费
  1770. */
  1771. function readyRefundFee() {
  1772. var allSelecteds = $('#refund_fee_detail_table').bootstrapTable('getAllSelections');
  1773. chargeItemCodes = null;
  1774. if (allSelecteds != null && allSelecteds.length > 0) {
  1775. for (var i = 0; i < allSelecteds.length; i++) {
  1776. var temp = allSelecteds[i].orderNo + "_" + allSelecteds[i].itemNo +"_"+allSelecteds[i].chargeItemCode;
  1777. if (chargeItemCodes == null) {
  1778. chargeItemCodes = temp;
  1779. } else {
  1780. chargeItemCodes += "," + temp;
  1781. }
  1782. }
  1783. }
  1784. $("#refundFeeModal").modal();
  1785. initRefundChargeDetailTable(chargeItemCodes);
  1786. $("#refundFeeDetailModal").modal("hide");
  1787. }
  1788. /**
  1789. * 初始化退费重收费明细表格
  1790. */
  1791. function initRefundChargeDetailTable(chargeItemCodes) {
  1792. $('#refund_fee_table').bootstrapTable("destroy");
  1793. $('#refund_fee_table').bootstrapTable({
  1794. url: '/thmz/getNewListForRefundFee', //请求后台的URL(*)
  1795. method: 'post', //请求方式(*)
  1796. toolbar: '#toolbar', //工具按钮用哪个容器
  1797. striped: true, //是否显示行间隔色
  1798. cache: false, //是否使用缓存,默认为true,所以一般情况下需要设置一下这个属性(*)
  1799. pagination: false, //是否显示分页(*)
  1800. sortable: true, //是否启用排序
  1801. sortOrder: "asc", //排序方式
  1802. // sortName: 'orderNo', //排序字段
  1803. queryParams: queryParamsForRefundDetail(chargeItemCodes), //传递参数(*)
  1804. sidePagination: "server", //分页方式:client客户端分页,server服务端分页(*)
  1805. pageNumber: 1, //初始化加载第一页,默认第一页
  1806. pageSize: 10, //每页的记录行数(*)
  1807. pageList: [10, 25, 50, 100], //可供选择的每页的行数(*)
  1808. search: false, //是否显示表格搜索,此搜索是客户端搜索,不会进服务端,所以,个人感觉意义不大
  1809. strictSearch: true,
  1810. showColumns: false, //是否显示所有的列
  1811. showRefresh: false, //是否显示刷新按钮
  1812. minimumCountColumns: 2, //最少允许的列数
  1813. clickToSelect: true, //是否启用点击选中行
  1814. uniqueId: "ID", //每一行的唯一标识,一般为主键列
  1815. showToggle: false, //是否显示详细视图和列表视图的切换按钮
  1816. cardView: false, //是否显示详细视图
  1817. detailView: false,
  1818. //rowStyle:rowStyle,//通过自定义函数设置行样式
  1819. ajaxOptions: {
  1820. headers: {
  1821. 'Accept': 'application/json',
  1822. 'Authorization': 'Bearer ' + localStorage.getItem("token")
  1823. }
  1824. },
  1825. columns: [
  1826. // {
  1827. // checkbox: true
  1828. // },
  1829. {
  1830. field: 'patientId',
  1831. title: '患者编号',
  1832. align: "center",
  1833. valign: 'middle',
  1834. }, {
  1835. field: 'name',
  1836. title: '患者姓名',
  1837. align: "center",
  1838. valign: 'middle',
  1839. }, {
  1840. field: 'oriAmount',
  1841. title: '已收金额(元)',
  1842. align: "center",
  1843. valign: 'middle',
  1844. }, {
  1845. field: 'refundFee',
  1846. title: '应退金额(元)',
  1847. align: "center",
  1848. valign: 'middle'
  1849. }, {
  1850. field: 'amount',
  1851. title: '应收金额(元)',
  1852. align: "center",
  1853. valign: 'middle',
  1854. formatter: function (value, row, index) {
  1855. return Math.abs(value);
  1856. }
  1857. }, {
  1858. title: '操作',
  1859. align: "center",
  1860. valign: 'middle',
  1861. // sortable: true,
  1862. formatter: function (value, row, index) {
  1863. var str = "";
  1864. if (row.amount == 0 || row.amount == null || row.amount == undefined) {
  1865. str = '<button type="button" class="can-not-used" title="费用明细" ><i id="plusOrMinus" class="fa fa-plus"></i></button>';
  1866. } else {
  1867. str = '<button type="button" class="registration-no-color-foot-button" title="费用明细" onclick="initMzChargeDetailByBillItem(true)"><i id="plusOrMinus" class="fa fa-plus"></i></button>';
  1868. }
  1869. str += '<button type="button" class="registration-no-color-foot-button"title="确认退费" onclick="saveRefundFee()"><i class="fa fa-check"></i></button>';
  1870. return str;
  1871. }
  1872. }
  1873. ],
  1874. responseHandler: function (res) {
  1875. if (res == '401' || res == 401) {
  1876. window.location.href = '/thmz/login/view'
  1877. return;
  1878. }
  1879. var ress = eval(res);
  1880. if (ress.code == -1) {
  1881. new PNotify({
  1882. title: '错误提示',
  1883. text: ress.message,
  1884. type: 'error',
  1885. hide: true,
  1886. styling: 'bootstrap3'
  1887. });
  1888. return {
  1889. "total": 0,//总页数
  1890. "rows": {} //数据
  1891. };
  1892. }
  1893. $("#oriAmount").text(ress.pageViewVo.data[0].oriAmount);
  1894. $("#newAmount").text(ress.pageViewVo.data[0].amount);
  1895. $("#refundAmount").text(ress.pageViewVo.data[0].refundFee);
  1896. return {
  1897. "total": ress.pageViewVo.total,//总页数
  1898. "rows": ress.pageViewVo.data //数据
  1899. };
  1900. },
  1901. });
  1902. }
  1903. /**
  1904. * 构建列表查询参数
  1905. * @param chargeItemCodes
  1906. * @returns {{patientId: string | number | string[] | undefined | jQuery, times: string | number | string[] | undefined | jQuery, billItemCode: number}}
  1907. */
  1908. function queryParamsForRefundDetail(chargeItemCodes) {
  1909. return {
  1910. patientId: $("#patientIdRefund").val(),
  1911. times: $("#timesRefund").val(),
  1912. chargeItemCodes: chargeItemCodes
  1913. };
  1914. };
  1915. /**
  1916. * 关闭预退费窗口
  1917. */
  1918. function closeRefundFeeDetailModal() {
  1919. $("#refundFeeDetailModal").modal("hide");
  1920. }
  1921. /**
  1922. * 提交退费操作
  1923. */
  1924. function saveRefundFee() {
  1925. var params = queryParamsForRefundByBillItem(null);
  1926. $.ajax({
  1927. type: "POST",
  1928. url: '/thmz/saveRefundFee',
  1929. contentType: "application/json;charset=UTF-8",
  1930. dataType: "json",
  1931. data: JSON.stringify(params),
  1932. headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
  1933. success: function (res) {
  1934. if (res == '401' || res == 401) {
  1935. window.location.href = '/thmz/login/view'
  1936. return;
  1937. }
  1938. if (res.code == 0) {
  1939. new PNotify({
  1940. title: '操作提示',
  1941. text: res.message,
  1942. type: 'success',
  1943. hide: true,
  1944. styling: 'bootstrap3'
  1945. });
  1946. $("#refundFeeModal").modal("hide");
  1947. if (res.times > 0) {
  1948. prn1Print(res.patientId, res.times, false);
  1949. } else {
  1950. initFeeTable();
  1951. }
  1952. } else {
  1953. new PNotify({
  1954. title: '错误提示',
  1955. text: res.message,
  1956. type: 'error',
  1957. hide: true,
  1958. styling: 'bootstrap3'
  1959. });
  1960. }
  1961. }
  1962. });
  1963. }
  1964. /**
  1965. * 清空查询条件
  1966. */
  1967. function cleanParams() {
  1968. $("#deptNoParam").selectpicker('val', null);//默认选中
  1969. $("#deptNoParam").selectpicker('refresh');
  1970. $("#doctorParam").selectpicker('val', null);//默认选中
  1971. $("#doctorParam").selectpicker('refresh');
  1972. $("#cardNo").val(null);
  1973. $("#name").val(null);
  1974. $('#reportrange span').html(moment().format('YYYY-MM-DD') + ' - ' + moment().format('YYYY-MM-DD'));
  1975. $("#patientId").val(null);
  1976. //默认光标在卡号输入框
  1977. $("#cardNo").focus();
  1978. $("#serialNo").val(null);
  1979. $("#ownData").removeAttr("checked");
  1980. }