toll_administration.js 79 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130
  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,' + row.receiptNo + ');" 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 + ',' + row.receiptNo + ');" 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, res.receiptNo);
  1172. new PNotify({
  1173. title: '操作提示',
  1174. text: res.message,
  1175. type: 'success',
  1176. hide: true,
  1177. styling: 'bootstrap3'
  1178. });
  1179. $("#confirmFeeModal").modal("hide");
  1180. $("#patientId").val(null);
  1181. $("#cardNo").val(null);
  1182. $("#name").val(null);
  1183. initFeeTable();
  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, receiptNo) {
  1205. var url = '/thmz/getAllSerialForThisTime?patientId=' + patientId + "&times=" + times + "&receiptNo=" + receiptNo;
  1206. printCommon(url, patientId, times, chargeFeeFlag);
  1207. }
  1208. /**
  1209. * 重打发票
  1210. * @param patientId
  1211. * @param times
  1212. */
  1213. function repPrint(patientId, times, receiptNo) {
  1214. $.ajax({
  1215. type: "GET",
  1216. url: '/thmz/getReceiptForThisTime?patientId=' + patientId + "&times=" + times + "&receiptNo=" + receiptNo,
  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.14mm";
  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. $("#refundFeePrepare").text(0.00);
  1566. $("#refundFeeDetailModal").modal();
  1567. $("#refund_bill_item_group").removeClass("in").addClass("hide");
  1568. $('#refund_fee_bill_table').bootstrapTable("destroy");
  1569. initRefundFeeDetailTable(patientId, times, receiptNo);
  1570. }
  1571. /**
  1572. * 初始化退费明细表格
  1573. * @param patientId
  1574. * @param times
  1575. * @param receiptNo
  1576. */
  1577. function initRefundFeeDetailTable(patientId, times, receiptNo) {
  1578. $("#patientIdRefund").val(patientId);
  1579. $("#timesRefund").val(times);
  1580. $("#receiptNoRefund").val(receiptNo);
  1581. $('#refund_fee_detail_table').bootstrapTable("destroy");
  1582. $('#refund_fee_detail_table').bootstrapTable({
  1583. url: '/thmz/getRefundFeeDetail', //请求后台的URL(*)
  1584. method: 'post', //请求方式(*)
  1585. toolbar: '#toolbar', //工具按钮用哪个容器
  1586. striped: true, //是否显示行间隔色
  1587. cache: false, //是否使用缓存,默认为true,所以一般情况下需要设置一下这个属性(*)
  1588. pagination: false, //是否显示分页(*)
  1589. sortable: true, //是否启用排序
  1590. sortOrder: "asc", //排序方式
  1591. // sortName: 'orderNo', //排序字段
  1592. queryParams: queryParamsForRefundFee(patientId, times), //传递参数(*)
  1593. sidePagination: "server", //分页方式:client客户端分页,server服务端分页(*)
  1594. pageNumber: 1, //初始化加载第一页,默认第一页
  1595. pageSize: 10, //每页的记录行数(*)
  1596. pageList: [10, 25, 50, 100], //可供选择的每页的行数(*)
  1597. search: false, //是否显示表格搜索,此搜索是客户端搜索,不会进服务端,所以,个人感觉意义不大
  1598. strictSearch: true,
  1599. showColumns: false, //是否显示所有的列
  1600. showRefresh: false, //是否显示刷新按钮
  1601. minimumCountColumns: 2, //最少允许的列数
  1602. clickToSelect: true, //是否启用点击选中行
  1603. uniqueId: "ID", //每一行的唯一标识,一般为主键列
  1604. showToggle: false, //是否显示详细视图和列表视图的切换按钮
  1605. cardView: false, //是否显示详细视图
  1606. detailView: false,
  1607. //rowStyle:rowStyle,//通过自定义函数设置行样式
  1608. ajaxOptions: {
  1609. headers: {
  1610. 'Accept': 'application/json',
  1611. 'Authorization': 'Bearer ' + localStorage.getItem("token")
  1612. }
  1613. },
  1614. columns: [
  1615. {
  1616. checkbox: true,
  1617. formatter: function (value, row, index) {
  1618. if (row.confirmFlag == 1) {
  1619. return {
  1620. disabled: true, //设置是否可用
  1621. checked: false//设置选中
  1622. }
  1623. }
  1624. if (row.confirmFlag == 3) {
  1625. return {
  1626. disabled: true, //设置是否可用
  1627. checked: true//设置选中
  1628. }
  1629. }
  1630. }
  1631. },
  1632. {
  1633. field: 'orderNo',
  1634. title: '处方号',
  1635. align: "center",
  1636. valign: 'middle',
  1637. formatter: function (value, row, index) {
  1638. return Math.abs(value);
  1639. }
  1640. }, {
  1641. field: '',
  1642. title: '项目号',
  1643. align: "center",
  1644. valign: 'middle',
  1645. formatter: function (value, row, index) {
  1646. return index + 1;
  1647. }
  1648. }, {
  1649. field: 'billItemCode',
  1650. title: '分类名称',
  1651. align: "center",
  1652. valign: 'middle',
  1653. }, {
  1654. field: 'chargeItemCode',
  1655. title: '收费编码',
  1656. align: "center",
  1657. valign: 'middle',
  1658. }, {
  1659. field: 'tcName',
  1660. title: '项目',
  1661. align: "center",
  1662. valign: 'middle',
  1663. },
  1664. {
  1665. field: 'quantity',
  1666. title: '数量',
  1667. align: "center",
  1668. valign: 'middle'
  1669. }, {
  1670. field: 'unitPrice',
  1671. title: '单价(元)',
  1672. align: "center",
  1673. valign: 'middle',
  1674. formatter: function (value, row, index) {
  1675. return value.toFixed(2);
  1676. }
  1677. }, {
  1678. field: 'amount',
  1679. title: '总金额(元)',
  1680. align: "center",
  1681. valign: 'middle',
  1682. formatter: function (value, row, index) {
  1683. return value.toFixed(2);
  1684. }
  1685. }, {
  1686. field: 'confirmFlag',
  1687. title: '确认标志',
  1688. align: "center",
  1689. valign: 'middle',
  1690. formatter: function (value, row, index) {
  1691. if (value == 0) {
  1692. return "待确认";
  1693. }
  1694. if (value == 1) {
  1695. return "已确认";
  1696. }
  1697. if (value == 3) {
  1698. return "已取消";
  1699. }
  1700. if (value == 4) {
  1701. return "已退费";
  1702. }
  1703. }
  1704. }, {
  1705. field: 'decAmount',
  1706. title: '退药量',
  1707. align: "center",
  1708. valign: 'middle',
  1709. // formatter: function (value, row, index) {
  1710. // return value.toFixed(2);
  1711. // }
  1712. }, {
  1713. field: 'execDept',
  1714. title: '确认科室',
  1715. align: "center",
  1716. valign: 'middle'
  1717. }, {
  1718. field: 'confirmTime',
  1719. title: '确认时间',
  1720. align: "center",
  1721. valign: 'middle',
  1722. formatter: function (value, row, index) {
  1723. if (value != null && value != "") {
  1724. return format(value, "yyyy-MM-dd HH:mm:ss");
  1725. }
  1726. return "";
  1727. }
  1728. }
  1729. ],
  1730. //点击全选框时触发的操作
  1731. onCheckAll: function (rows) {
  1732. getRefundFee();
  1733. },
  1734. //取消所有
  1735. onUncheckAll: function (row) {
  1736. getRefundFee();
  1737. },
  1738. //点击每一个单选框时触发的操作
  1739. onCheck: function (row) {
  1740. getRefundFee();
  1741. },
  1742. //取消每一个单选框时对应的操作;
  1743. onUncheck: function (row) {
  1744. getRefundFee();
  1745. },
  1746. responseHandler: function (res) {
  1747. if (res == '401' || res == 401) {
  1748. window.location.href = '/thmz/login/view'
  1749. return;
  1750. }
  1751. var ress = eval(res);
  1752. if (ress.code == -1) {
  1753. new PNotify({
  1754. title: '错误提示',
  1755. text: ress.message,
  1756. type: 'error',
  1757. hide: true,
  1758. styling: 'bootstrap3'
  1759. });
  1760. return {
  1761. "total": 0,//总页数
  1762. "rows": {} //数据
  1763. };
  1764. }
  1765. return {
  1766. //"total": ress.pageViewVo.total,//总页数
  1767. "rows": ress.data //数据
  1768. };
  1769. },
  1770. });
  1771. }
  1772. /**
  1773. * 退费列表参数
  1774. * @param patientId
  1775. * @param times
  1776. * @returns {{patientId: *, times: *}}
  1777. */
  1778. function queryParamsForRefundFee(patientId, times) {
  1779. var temp = {
  1780. patientId: patientId,
  1781. times: times,
  1782. };
  1783. return temp;
  1784. };
  1785. /**
  1786. * 每次选择费用清单明细时计算实际应退金额
  1787. */
  1788. function getRefundFee() {
  1789. var chargeItemCodes = extracted();
  1790. if(chargeItemCodes==null){
  1791. $("#refundFeePrepare").text(0.00);
  1792. return;
  1793. }
  1794. $.ajax({
  1795. type: "POST",
  1796. url: '/thmz/getNewListForRefundFee',
  1797. contentType: "application/json;charset=UTF-8",
  1798. dataType: "json",
  1799. data: JSON.stringify({
  1800. patientId: $("#patientIdRefund").val(),
  1801. times: $("#timesRefund").val(),
  1802. chargeItemCodes: chargeItemCodes
  1803. }),
  1804. headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
  1805. success: function (res) {
  1806. if (res == '401' || res == 401) {
  1807. window.location.href = '/thmz/login/view'
  1808. return;
  1809. }
  1810. if (res.code == 0) {
  1811. $("#refundFeePrepare").text(res.pageViewVo.data[0].refundFee.toFixed(2));
  1812. } else {
  1813. new PNotify({
  1814. title: '错误提示',
  1815. text: res.message,
  1816. type: 'error',
  1817. hide: true,
  1818. styling: 'bootstrap3'
  1819. });
  1820. }
  1821. }
  1822. });
  1823. }
  1824. /**
  1825. * 发起预退费
  1826. */
  1827. function readyRefundFee() {
  1828. var chargeItemCodes = extracted();
  1829. $("#refundFeeModal").modal();
  1830. initRefundChargeDetailTable(chargeItemCodes);
  1831. $("#refundFeeDetailModal").modal("hide");
  1832. }
  1833. /**
  1834. * 获取预退费金额
  1835. * @returns {*}
  1836. */
  1837. function extracted() {
  1838. var allSelecteds = $('#refund_fee_detail_table').bootstrapTable('getAllSelections');
  1839. var chargeItemCodes = null;
  1840. if (allSelecteds != null && allSelecteds.length > 0) {
  1841. for (var i = 0; i < allSelecteds.length; i++) {
  1842. var temp = allSelecteds[i].orderNo + "_" + allSelecteds[i].itemNo + "_" + allSelecteds[i].chargeItemCode;
  1843. if (chargeItemCodes == null) {
  1844. chargeItemCodes = temp;
  1845. } else {
  1846. chargeItemCodes += "," + temp;
  1847. }
  1848. }
  1849. }
  1850. return chargeItemCodes;
  1851. }
  1852. /**
  1853. * 初始化退费重收费明细表格
  1854. */
  1855. function initRefundChargeDetailTable(chargeItemCodes) {
  1856. $('#refund_fee_table').bootstrapTable("destroy");
  1857. $('#refund_fee_table').bootstrapTable({
  1858. url: '/thmz/getNewListForRefundFee', //请求后台的URL(*)
  1859. method: 'post', //请求方式(*)
  1860. toolbar: '#toolbar', //工具按钮用哪个容器
  1861. striped: true, //是否显示行间隔色
  1862. cache: false, //是否使用缓存,默认为true,所以一般情况下需要设置一下这个属性(*)
  1863. pagination: false, //是否显示分页(*)
  1864. sortable: true, //是否启用排序
  1865. sortOrder: "asc", //排序方式
  1866. // sortName: 'orderNo', //排序字段
  1867. queryParams: queryParamsForRefundDetail(chargeItemCodes), //传递参数(*)
  1868. sidePagination: "server", //分页方式:client客户端分页,server服务端分页(*)
  1869. pageNumber: 1, //初始化加载第一页,默认第一页
  1870. pageSize: 10, //每页的记录行数(*)
  1871. pageList: [10, 25, 50, 100], //可供选择的每页的行数(*)
  1872. search: false, //是否显示表格搜索,此搜索是客户端搜索,不会进服务端,所以,个人感觉意义不大
  1873. strictSearch: true,
  1874. showColumns: false, //是否显示所有的列
  1875. showRefresh: false, //是否显示刷新按钮
  1876. minimumCountColumns: 2, //最少允许的列数
  1877. clickToSelect: true, //是否启用点击选中行
  1878. uniqueId: "ID", //每一行的唯一标识,一般为主键列
  1879. showToggle: false, //是否显示详细视图和列表视图的切换按钮
  1880. cardView: false, //是否显示详细视图
  1881. detailView: false,
  1882. //rowStyle:rowStyle,//通过自定义函数设置行样式
  1883. ajaxOptions: {
  1884. headers: {
  1885. 'Accept': 'application/json',
  1886. 'Authorization': 'Bearer ' + localStorage.getItem("token")
  1887. }
  1888. },
  1889. columns: [
  1890. // {
  1891. // checkbox: true
  1892. // },
  1893. {
  1894. field: 'patientId',
  1895. title: '患者编号',
  1896. align: "center",
  1897. valign: 'middle',
  1898. }, {
  1899. field: 'name',
  1900. title: '患者姓名',
  1901. align: "center",
  1902. valign: 'middle',
  1903. }, {
  1904. field: 'oriAmount',
  1905. title: '已收金额(元)',
  1906. align: "center",
  1907. valign: 'middle',
  1908. }, {
  1909. field: 'refundFee',
  1910. title: '应退金额(元)',
  1911. align: "center",
  1912. valign: 'middle'
  1913. }, {
  1914. field: 'amount',
  1915. title: '应收金额(元)',
  1916. align: "center",
  1917. valign: 'middle',
  1918. formatter: function (value, row, index) {
  1919. return Math.abs(value);
  1920. }
  1921. }, {
  1922. title: '操作',
  1923. align: "center",
  1924. valign: 'middle',
  1925. // sortable: true,
  1926. formatter: function (value, row, index) {
  1927. var str = "";
  1928. if (row.amount == 0 || row.amount == null || row.amount == undefined) {
  1929. str = '<button type="button" class="can-not-used" title="费用明细" ><i id="plusOrMinus" class="fa fa-plus"></i></button>';
  1930. } else {
  1931. str = '<button type="button" class="registration-no-color-foot-button" title="费用明细" onclick="initMzChargeDetailByBillItem(true)"><i id="plusOrMinus" class="fa fa-plus"></i></button>';
  1932. }
  1933. str += '<button type="button" class="registration-no-color-foot-button"title="确认退费" onclick="saveRefundFee()"><i class="fa fa-check"></i></button>';
  1934. return str;
  1935. }
  1936. }
  1937. ],
  1938. responseHandler: function (res) {
  1939. if (res == '401' || res == 401) {
  1940. window.location.href = '/thmz/login/view'
  1941. return;
  1942. }
  1943. var ress = eval(res);
  1944. if (ress.code == -1) {
  1945. new PNotify({
  1946. title: '错误提示',
  1947. text: ress.message,
  1948. type: 'error',
  1949. hide: true,
  1950. styling: 'bootstrap3'
  1951. });
  1952. return {
  1953. "total": 0,//总页数
  1954. "rows": {} //数据
  1955. };
  1956. }
  1957. $("#oriAmount").text(ress.pageViewVo.data[0].oriAmount);
  1958. $("#newAmount").text(ress.pageViewVo.data[0].amount);
  1959. $("#refundAmount").text(ress.pageViewVo.data[0].refundFee);
  1960. return {
  1961. "total": ress.pageViewVo.total,//总页数
  1962. "rows": ress.pageViewVo.data //数据
  1963. };
  1964. },
  1965. });
  1966. }
  1967. /**
  1968. * 构建列表查询参数
  1969. * @param chargeItemCodes
  1970. * @returns {{patientId: string | number | string[] | undefined | jQuery, times: string | number | string[] | undefined | jQuery, billItemCode: number}}
  1971. */
  1972. function queryParamsForRefundDetail(chargeItemCodes) {
  1973. return {
  1974. patientId: $("#patientIdRefund").val(),
  1975. times: $("#timesRefund").val(),
  1976. chargeItemCodes: chargeItemCodes
  1977. };
  1978. };
  1979. /**
  1980. * 关闭预退费窗口
  1981. */
  1982. function closeRefundFeeDetailModal() {
  1983. $("#refundFeeDetailModal").modal("hide");
  1984. }
  1985. /**
  1986. * 提交退费操作
  1987. */
  1988. function saveRefundFee() {
  1989. var params = queryParamsForRefundByBillItem(null);
  1990. $.ajax({
  1991. type: "POST",
  1992. url: '/thmz/saveRefundFee',
  1993. contentType: "application/json;charset=UTF-8",
  1994. dataType: "json",
  1995. data: JSON.stringify(params),
  1996. headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
  1997. success: function (res) {
  1998. if (res == '401' || res == 401) {
  1999. window.location.href = '/thmz/login/view'
  2000. return;
  2001. }
  2002. if (res.code == 0) {
  2003. new PNotify({
  2004. title: '操作提示',
  2005. text: res.message,
  2006. type: 'success',
  2007. hide: true,
  2008. styling: 'bootstrap3'
  2009. });
  2010. $("#refundFeeModal").modal("hide");
  2011. if (res.times > 0) {
  2012. prn1Print(res.patientId, res.times, false, 1);
  2013. } else {
  2014. initFeeTable();
  2015. }
  2016. } else {
  2017. new PNotify({
  2018. title: '错误提示',
  2019. text: res.message,
  2020. type: 'error',
  2021. hide: true,
  2022. styling: 'bootstrap3'
  2023. });
  2024. }
  2025. }
  2026. });
  2027. }
  2028. /**
  2029. * 清空查询条件
  2030. */
  2031. function cleanParams() {
  2032. $("#deptNoParam").selectpicker('val', null);//默认选中
  2033. $("#deptNoParam").selectpicker('refresh');
  2034. $("#doctorParam").selectpicker('val', null);//默认选中
  2035. $("#doctorParam").selectpicker('refresh');
  2036. $("#cardNo").val(null);
  2037. $("#name").val(null);
  2038. $('#reportrange span').html(moment().format('YYYY-MM-DD') + ' - ' + moment().format('YYYY-MM-DD'));
  2039. $("#patientId").val(null);
  2040. //默认光标在卡号输入框
  2041. $("#cardNo").focus();
  2042. $("#serialNo").val(null);
  2043. $("#ownData").removeAttr("checked");
  2044. }