charge_list.js 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439
  1. //@ sourceURL=charge_list.js
  2. var LODOP; //声明为全局变量
  3. //默认打印机下标
  4. var printIndex = -1;
  5. var canPrint = false;
  6. $(function () {
  7. init_daterangepicker();
  8. initChargeListByPatient();
  9. // initFeeTable();
  10. //重置查询参数
  11. $('#btn_clean').click(function () {
  12. cleanParams();
  13. });
  14. //初始化页面上面的按钮事件
  15. $("#btn_daily").click(function (t) {
  16. print();
  17. });
  18. $("#btn_query").click(function (t) {
  19. initChargeListByPatient();
  20. });
  21. setTimeout(function () {
  22. getLodop();
  23. }, 400);
  24. $(".selectpicker").selectpicker({
  25. dropuAuto: false
  26. });
  27. });
  28. /**
  29. * 查询病人缴费记录
  30. */
  31. function initChargeListByPatient() {
  32. $('#tb_table').bootstrapTable("destroy");
  33. $('#tb_table').bootstrapTable({
  34. url: '/thmz/getChargeListByPatient', //请求后台的URL(*)
  35. method: 'post', //请求方式(*)
  36. toolbar: '#toolbar', //工具按钮用哪个容器
  37. striped: true, //是否显示行间隔色
  38. cache: false, //是否使用缓存,默认为true,所以一般情况下需要设置一下这个属性(*)
  39. pagination: true, //是否显示分页(*)
  40. sortable: true, //是否启用排序
  41. sortOrder: "asc", //排序方式
  42. queryParams: queryParams, //传递参数(*)
  43. sidePagination: "client", //分页方式:client客户端分页,server服务端分页(*)
  44. pageNumber: 1, //初始化加载第一页,默认第一页
  45. pageSize: 10, //每页的记录行数(*)
  46. pageList: [10, 25, 50, 100], //可供选择的每页的行数(*)
  47. search: false, //是否显示表格搜索,此搜索是客户端搜索,不会进服务端,所以,个人感觉意义不大
  48. strictSearch: true,
  49. showColumns: false, //是否显示所有的列
  50. showRefresh: false, //是否显示刷新按钮
  51. minimumCountColumns: 2, //最少允许的列数
  52. clickToSelect: true, //是否启用点击选中行
  53. uniqueId: "ID", //每一行的唯一标识,一般为主键列
  54. showToggle: false, //是否显示详细视图和列表视图的切换按钮
  55. cardView: false, //是否显示详细视图
  56. detailView: false,
  57. //rowStyle:rowStyle,//通过自定义函数设置行样式
  58. ajaxOptions: {
  59. headers: {
  60. 'Accept': 'application/json',
  61. 'Authorization': 'Bearer ' + localStorage.getItem("token")
  62. }
  63. },
  64. columns: [
  65. {
  66. field: 'patient_id',
  67. title: '病人ID',
  68. align: "center",
  69. valign: 'middle',
  70. formatter: function (value, row, index) {
  71. var text = value;
  72. if (row.serial_no < 0) {
  73. text = '<span style="color:#ff6b91">' + value + '</span>';
  74. }
  75. return text;
  76. }
  77. }, {
  78. field: 'cheque_type',
  79. title: '收费方式',
  80. align: "center",
  81. valign: 'middle',
  82. formatter: function (value, row, index) {
  83. var text = value;
  84. if (row.serial_no < 0) {
  85. text = '<span style="color:#ff6b91">' + value + '</span>';
  86. }
  87. return text;
  88. }
  89. }, {
  90. field: 'name',
  91. title: '姓名',
  92. align: "center",
  93. valign: 'middle',
  94. formatter: function (value, row, index) {
  95. if(value==null || value==undefined){
  96. value="";
  97. }
  98. var text = value;
  99. if (row.serial_no < 0) {
  100. text = '<span style="color:#ff6b91">' + value + '</span>';
  101. }
  102. return text;
  103. }
  104. }, {
  105. field: 'times',
  106. title: '次数',
  107. align: "center",
  108. valign: 'middle',
  109. formatter: function (value, row, index) {
  110. var text = value;
  111. if (row.serial_no < 0) {
  112. text = '<span style="color:#ff6b91">' + value + '</span>';
  113. }
  114. return text;
  115. }
  116. }, {
  117. field: 'charge_date',
  118. title: '就诊日期',
  119. align: "center",
  120. valign: 'middle',
  121. formatter: function (value, row, index) {
  122. var text = value;
  123. if (row.serial_no < 0) {
  124. text = '<span style="color:#ff6b91">' + value + '</span>';
  125. }
  126. return text;
  127. }
  128. }, {
  129. field: 'serial_no',
  130. title: '机制流水号',
  131. align: "center",
  132. valign: 'middle',
  133. formatter: function (value, row, index) {
  134. var text = value;
  135. if (value < 0) {
  136. text = '<span style="color:#ff6b91">' + value + '</span>';
  137. }
  138. return text;
  139. }
  140. }
  141. ],
  142. onClickRow: function (row) {
  143. fitfymx(row.patient_id, row.real_no);
  144. },
  145. responseHandler: function (res) {
  146. if (res == '401' || res == 401) {
  147. window.location.href = '/thmz/login/view'
  148. return;
  149. }
  150. var ress = eval(res);
  151. if (ress.code == -1) {
  152. if (ress.message != null && ress.message != '') {
  153. new PNotify({
  154. title: '错误提示',
  155. text: ress.message,
  156. type: 'error',
  157. hide: true,
  158. styling: 'bootstrap3'
  159. });
  160. }
  161. return {
  162. "total": 0,//总页数
  163. "rows": {} //数据
  164. };
  165. }
  166. return {
  167. "total": ress.mzChargeDetailList.length,//总页数
  168. "rows": ress.mzChargeDetailList //数据
  169. };
  170. },
  171. });
  172. fitAllfymx();
  173. }
  174. /**
  175. * 构建列表查询参数
  176. * @param params
  177. * @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}}
  178. */
  179. function queryParams(params) {
  180. var rePortRangeArr = getRePortRangeArr();
  181. var temp = {
  182. beginDate: rePortRangeArr[0],
  183. endDate: rePortRangeArr[1],
  184. hisData: $('#hisData').is(':checked') ? 0 : 1,
  185. name: $("#name").val(),
  186. patientId: $("#patientId").val(),
  187. serialNo: $("#serialNo").val()
  188. };
  189. return temp;
  190. };
  191. /**
  192. * 设置病人id
  193. */
  194. function setPatientId() {
  195. var patientId_or_cardNo = $("#patientId_or_cardNo").val();
  196. $.ajax({
  197. type: "GET",
  198. url: '/thmz/getByIcCardNo?icCardNo=' + patientId_or_cardNo,
  199. contentType: "application/json;charset=UTF-8",
  200. dataType: "json",
  201. headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
  202. success: function (res) {
  203. if (res == '401' || res == 401) {
  204. window.location.href = '/thmz/login/view'
  205. return;
  206. }
  207. if (res.code == 0) {
  208. if (res.data != null) {
  209. $("#patientId").val(res.data.patientId);
  210. } else {
  211. $("#patientId").val(patientId_or_cardNo);
  212. }
  213. }
  214. }
  215. });
  216. }
  217. /**
  218. * 获取时间选择器的时间数组
  219. * @returns {string[]}
  220. */
  221. function getRePortRangeArr() {
  222. var rePortRange = $('#reportrange span').html();
  223. var rePortRangeArr = rePortRange.split(" - ");
  224. rePortRangeArr[0] = rePortRangeArr[0] + " 00:00:00"
  225. rePortRangeArr[1] = rePortRangeArr[1] + " 23:59:59"
  226. return rePortRangeArr;
  227. }
  228. /**
  229. * 查询默认打印机
  230. */
  231. function setPrint() {
  232. if (printIndex >= 0) {
  233. return;
  234. }
  235. $.ajax({
  236. type: "GET",
  237. url: '/thmz/getLastWindowsByCurrentUser',
  238. contentType: "application/json;charset=UTF-8",
  239. dataType: "json",
  240. headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
  241. async: false,
  242. success: function (res) {
  243. if (res == '401' || res == 401) {
  244. window.location.href = '/thmz/login/view'
  245. return;
  246. }
  247. if (res.code == 0) {
  248. printIndex = res.data.cgPrintIndex;
  249. } else {
  250. printIndex = -1;
  251. }
  252. }
  253. });
  254. }
  255. /**
  256. * 清空查询条件
  257. */
  258. function cleanParams() {
  259. $('#reportrange span').html(moment().format('YYYY-MM-DD') + ' - ' + moment().format('YYYY-MM-DD'));
  260. $("#hisData").removeAttr("checked");
  261. $("#name").val(null),
  262. $("#patientId").val(null),
  263. $("#serialNo").val(null),
  264. $("#patientId_or_cardNo").val(null)
  265. }
  266. /**
  267. * 打印报表
  268. */
  269. function print() {
  270. if (!canPrint) {
  271. new PNotify({
  272. title: '警告提示',
  273. text: '没有选择合适的报表,无需打印',
  274. hide: false,
  275. styling: 'bootstrap3'
  276. });
  277. return;
  278. }
  279. setPrint();
  280. LODOP = getLodop();
  281. LODOP.PRINT_INITA(6, 0, "210mm", "297mm", "门诊病人费用清单");
  282. //设置默认打印机
  283. LODOP.SET_PRINTER_INDEX(printIndex);
  284. LODOP.SET_SHOW_MODE("BKIMG_WIDTH", "297mm");
  285. LODOP.SET_SHOW_MODE("BKIMG_HEIGHT", "210mm");
  286. LODOP.ADD_PRINT_TABLE(150, "5%", "90%", 800, document.getElementById("fymx_table").innerHTML);
  287. LODOP.SET_PRINT_STYLEA(0, "Vorient", 3);
  288. LODOP.ADD_PRINT_HTM(26, "5%", "90%", 109, document.getElementById("right_title").innerHTML);
  289. LODOP.SET_PRINT_STYLEA(0, "ItemType", 1);
  290. LODOP.SET_PRINT_STYLEA(0, "LinkedItem", 1);
  291. LODOP.ADD_PRINT_HTM(950,"5%","90%",54,document.getElementById("foot").innerHTML);
  292. LODOP.SET_PRINT_STYLEA(0,"ItemType",1);
  293. LODOP.SET_PRINT_STYLEA(0,"LinkedItem",1);
  294. LODOP.PRINT();
  295. //LODOP.PREVIEW();
  296. }
  297. /**
  298. * 查询同一病人所有收费明细
  299. */
  300. function fitAllfymx() {
  301. var patientId=$("#patientId").val();
  302. if(patientId ==undefined || patientId==null || patientId==""){
  303. return;
  304. }
  305. var rePortRangeArr = getRePortRangeArr();
  306. $.ajax({
  307. type: "POST",
  308. url: '/thmz/getAllChargeDetailByPatient',
  309. contentType: "application/json;charset=UTF-8",
  310. dataType: "json",
  311. headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
  312. data: JSON.stringify({
  313. patientId: $("#patientId").val(),
  314. beginDate: rePortRangeArr[0],
  315. endDate: rePortRangeArr[1],
  316. hisData: $('#hisData').is(':checked') ? 0 : 1
  317. }),
  318. success: function (res) {
  319. if (res == '401' || res == 401) {
  320. window.location.href = '/thmz/login/view'
  321. return;
  322. }
  323. if (res.code == 0) {
  324. formatMx(res);
  325. } else {
  326. new PNotify({
  327. title: '错误提示',
  328. text: res.message,
  329. type: 'error',
  330. hide: true,
  331. styling: 'bootstrap3'
  332. });
  333. }
  334. $("#print_date").html(format(new Date(), "yyyy/MM/dd"));
  335. }
  336. });
  337. }
  338. /**
  339. * 设置病人收费明细
  340. */
  341. function fitfymx(patientId, serialNo) {
  342. $.ajax({
  343. type: "POST",
  344. url: '/thmz/getChargeDetailByPatient',
  345. contentType: "application/json;charset=UTF-8",
  346. dataType: "json",
  347. headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
  348. data: JSON.stringify({
  349. patientId: patientId,
  350. serialNo: serialNo,
  351. hisData: $('#hisData').is(':checked') ? 0 : 1
  352. }),
  353. success: function (res) {
  354. if (res == '401' || res == 401) {
  355. window.location.href = '/thmz/login/view'
  356. return;
  357. }
  358. if (res.code == 0) {
  359. formatMx(res);
  360. } else {
  361. new PNotify({
  362. title: '错误提示',
  363. text: res.message,
  364. type: 'error',
  365. hide: true,
  366. styling: 'bootstrap3'
  367. });
  368. }
  369. $("#print_date").html(format(new Date(), "yyyy/MM/dd"));
  370. }
  371. });
  372. }
  373. function formatMx(res) {
  374. if (res.data != null && res.data.length > 0) {
  375. $("#serialNo_t").html("机制号:" + res.data[0].real_no);
  376. $("#doctor").html("医生:" + res.data[0].doctor_code);
  377. $("#cashId").html("收费员:" + res.data[0].op_id);
  378. $("#patientId_t").html("门诊号:" + res.data[0].patient_id);
  379. $("#name_t").html("姓名:" + res.data[0].name);
  380. $("#date_t").html("日期:" + format(res.data[0].charge_date, "yyyy-MM-dd"));
  381. $("#dept_t").html("科室:" + res.data[0].warn_dept);
  382. var html = "";
  383. for (var i = 0; i < res.data.length; i++) {
  384. var temp = res.data[i];
  385. html += "<tr>";
  386. html += ' <td width="17%" style="padding-left: 8px;padding-top: 4px;">' + temp.tybm + '</td>';
  387. html += ' <td width="45%" style="padding-left: 8px;padding-top: 4px;">' + temp.drugname + '</td>';
  388. if (temp.specification == null || temp.specification == undefined) {
  389. html += ' <td width="10%" style="padding-left: 8px;padding-top: 4px;"></td>';
  390. } else {
  391. html += ' <td width="10%" style="padding-left: 8px;padding-top: 4px;">' + temp.specification + '</td>';
  392. }
  393. if (temp.unit == null || temp.unit == undefined) {
  394. html += ' <td width="10%" style="padding-left: 8px;padding-top: 4px;"></td>';
  395. } else {
  396. html += ' <td width="10%" style="padding-left: 8px;padding-top: 4px;">' + temp.unit + '</td>';
  397. }
  398. html += ' <td width="6%" style="padding-left: 8px;padding-top: 4px;">' + temp.unit_price.toFixed(2) + '</td>';
  399. html += ' <td width="6%" style="padding-left: 8px;padding-top: 4px;">' + temp.quantity + '</td>';
  400. html += ' <td width="6%" style="padding-left: 8px;padding-top: 4px;">' + temp.total_price.toFixed(2) + '</td>';
  401. html += "</tr>";
  402. }
  403. html+='<tr><td colspan="8"><div style="border:0;border-top:1px solid #000;overflow:hidden;font-size: 13px;"><div style="float: right;font-weight: 700;padding-top: 4px;padding-bottom: 4px;"><span>金额合计:</span><span id="total_count" style="margin-left: 50px;"></span></div></div></td></tr>';
  404. $("#fymx_table_body").html(html);
  405. if (res.mzReceiptSerial!= undefined && res.mzReceiptSerial != null) {
  406. $("#receipt_no").html(res.mzReceiptSerial.receiptBill);
  407. }else {
  408. $("#receipt_no").html("");
  409. }
  410. $("#opId_print").html(res.user.userName);
  411. $("#total_count").html(res.totalPriceCount.toFixed(2));
  412. canPrint = true;
  413. }
  414. }