refund_medicine.js 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403
  1. //@ sourceURL=refund_medicine.js
  2. $(function () {
  3. init_daterangepicker();
  4. initChargeListByPatient();
  5. // initFeeTable();
  6. //重置查询参数
  7. $('#btn_clean').click(function () {
  8. cleanParams();
  9. });
  10. $("#btn_query").click(function (t) {
  11. initChargeListByPatient();
  12. });
  13. $("#btn_save").click(function (t) {
  14. saveRefundMedicine();
  15. });
  16. $(".selectpicker").selectpicker({
  17. dropuAuto: false
  18. });
  19. });
  20. /**
  21. * 查询病人缴费记录
  22. */
  23. function initChargeListByPatient() {
  24. $('#tb_table').bootstrapTable("destroy");
  25. $('#tb_table').bootstrapTable({
  26. url: '/thmz/getYfyjl', //请求后台的URL(*)
  27. method: 'post', //请求方式(*)
  28. toolbar: '#toolbar', //工具按钮用哪个容器
  29. striped: true, //是否显示行间隔色
  30. cache: false, //是否使用缓存,默认为true,所以一般情况下需要设置一下这个属性(*)
  31. pagination: true, //是否显示分页(*)
  32. sortable: true, //是否启用排序
  33. sortOrder: "asc", //排序方式
  34. queryParams: queryParams, //传递参数(*)
  35. sidePagination: "client", //分页方式:client客户端分页,server服务端分页(*)
  36. pageNumber: 1, //初始化加载第一页,默认第一页
  37. pageSize: 10, //每页的记录行数(*)
  38. pageList: [10, 25, 50, 100], //可供选择的每页的行数(*)
  39. search: false, //是否显示表格搜索,此搜索是客户端搜索,不会进服务端,所以,个人感觉意义不大
  40. strictSearch: true,
  41. showColumns: false, //是否显示所有的列
  42. showRefresh: false, //是否显示刷新按钮
  43. minimumCountColumns: 2, //最少允许的列数
  44. clickToSelect: true, //是否启用点击选中行
  45. uniqueId: "ID", //每一行的唯一标识,一般为主键列
  46. showToggle: false, //是否显示详细视图和列表视图的切换按钮
  47. cardView: false, //是否显示详细视图
  48. detailView: false,
  49. //rowStyle:rowStyle,//通过自定义函数设置行样式
  50. ajaxOptions: {
  51. headers: {
  52. 'Accept': 'application/json',
  53. 'Authorization': 'Bearer ' + localStorage.getItem("token")
  54. }
  55. },
  56. columns: [
  57. {
  58. field: 'patientId',
  59. title: '门诊号',
  60. align: "center",
  61. valign: 'middle',
  62. }, {
  63. field: 'name',
  64. title: '姓名',
  65. align: "center",
  66. valign: 'middle',
  67. }, {
  68. field: 'orderNo',
  69. title: '处方号',
  70. align: "center",
  71. valign: 'middle',
  72. }, {
  73. field: 'groupNoOut',
  74. title: '药房',
  75. align: "center",
  76. valign: 'middle',
  77. }, {
  78. field: 'chargeDate',
  79. title: '缴费日期',
  80. align: "center",
  81. valign: 'middle',
  82. formatter: function (value, row, index) {
  83. if (value != null && value != "") {
  84. return format(value, "yyyy-MM-dd HH:mm:ss");
  85. }
  86. return "";
  87. }
  88. }, {
  89. field: 'doctorName',
  90. title: '医生',
  91. align: "center",
  92. valign: 'middle',
  93. }, {
  94. field: 'confirmTime',
  95. title: '确认日期',
  96. align: "center",
  97. valign: 'middle',
  98. formatter: function (value, row, index) {
  99. if (value != null && value != "") {
  100. return format(value, "yyyy-MM-dd HH:mm:ss");
  101. }
  102. return "";
  103. }
  104. }, {
  105. field: 'realNo',
  106. title: '流水号',
  107. align: "center",
  108. valign: 'middle',
  109. }
  110. ],
  111. onClickRow: function (row) {
  112. fitfymx(row.patientId, row.times, row.receiptNo,row.orderNo,row.groupNo);
  113. },
  114. responseHandler: function (res) {
  115. if (res == '401' || res == 401) {
  116. window.location.href = '/thmz/login/view'
  117. return;
  118. }
  119. var ress = eval(res);
  120. if (ress.code == -1) {
  121. if (ress.message != null && ress.message != '') {
  122. new PNotify({
  123. title: '错误提示',
  124. text: ress.message,
  125. type: 'error',
  126. hide: true,
  127. styling: 'bootstrap3'
  128. });
  129. }
  130. return {
  131. "total": 0,//总页数
  132. "rows": {} //数据
  133. };
  134. }
  135. return {
  136. "total": ress.data.length,//总页数
  137. "rows": ress.data //数据
  138. };
  139. },
  140. });
  141. }
  142. /**
  143. * 构建列表查询参数
  144. * @param params
  145. * @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}}
  146. */
  147. function queryParams(params) {
  148. var rePortRangeArr = getRePortRangeArr();
  149. var temp = {
  150. beginDate: rePortRangeArr[0],
  151. endDate: rePortRangeArr[1],
  152. name: $("#name").val(),
  153. patientId: $("#patientId").val(),
  154. serialNo: $("#serialNo").val()
  155. };
  156. return temp;
  157. };
  158. /**
  159. * 设置病人id
  160. */
  161. function setPatientId() {
  162. var patientId_or_cardNo = $("#patientId_or_cardNo").val();
  163. $.ajax({
  164. type: "GET",
  165. url: '/thmz/getByIcCardNo?icCardNo=' + patientId_or_cardNo,
  166. contentType: "application/json;charset=UTF-8",
  167. dataType: "json",
  168. headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
  169. success: function (res) {
  170. if (res == '401' || res == 401) {
  171. window.location.href = '/thmz/login/view'
  172. return;
  173. }
  174. if (res.code == 0) {
  175. if (res.data != null) {
  176. $("#patientId").val(res.data.patientId);
  177. } else {
  178. $("#patientId").val(patientId_or_cardNo);
  179. }
  180. }
  181. }
  182. });
  183. }
  184. /**
  185. * 获取时间选择器的时间数组
  186. * @returns {string[]}
  187. */
  188. function getRePortRangeArr() {
  189. var rePortRange = $('#reportrange span').html();
  190. var rePortRangeArr = rePortRange.split(" - ");
  191. rePortRangeArr[0] = rePortRangeArr[0] + " 00:00:00"
  192. rePortRangeArr[1] = rePortRangeArr[1] + " 23:59:59"
  193. return rePortRangeArr;
  194. }
  195. /**
  196. * 清空查询条件
  197. */
  198. function cleanParams() {
  199. $('#reportrange span').html(moment().format('YYYY-MM-DD') + ' - ' + moment().format('YYYY-MM-DD'));
  200. $("#name").val(null),
  201. $("#patientId").val(null),
  202. $("#serialNo").val(null),
  203. $("#patientId_or_cardNo").val(null)
  204. }
  205. /**
  206. * 设置病人药品明细
  207. */
  208. var $table;
  209. function fitfymx(patientId,times,receiptNo,orderNo,groupNoOut) {
  210. var temp = {
  211. patientId: patientId,
  212. times: times,
  213. receiptNo:receiptNo,
  214. orderNo:orderNo,
  215. groupNoOut:groupNoOut
  216. };
  217. $('#tb_table_right').bootstrapTable("destroy");
  218. $table= $('#tb_table_right').bootstrapTable({
  219. url: '/thmz/getYpMx', //请求后台的URL(*)
  220. method: 'post', //请求方式(*)
  221. toolbar: '#toolbar', //工具按钮用哪个容器
  222. striped: true, //是否显示行间隔色
  223. cache: false, //是否使用缓存,默认为true,所以一般情况下需要设置一下这个属性(*)
  224. pagination: true, //是否显示分页(*)
  225. sortable: true, //是否启用排序
  226. sortOrder: "asc", //排序方式
  227. queryParams: temp, //传递参数(*)
  228. sidePagination: "client", //分页方式:client客户端分页,server服务端分页(*)
  229. pageNumber: 1, //初始化加载第一页,默认第一页
  230. pageSize: 10, //每页的记录行数(*)
  231. pageList: [10, 25, 50, 100], //可供选择的每页的行数(*)
  232. search: false, //是否显示表格搜索,此搜索是客户端搜索,不会进服务端,所以,个人感觉意义不大
  233. strictSearch: true,
  234. showColumns: false, //是否显示所有的列
  235. showRefresh: false, //是否显示刷新按钮
  236. minimumCountColumns: 2, //最少允许的列数
  237. clickToSelect: true, //是否启用点击选中行
  238. uniqueId: "ID", //每一行的唯一标识,一般为主键列
  239. showToggle: false, //是否显示详细视图和列表视图的切换按钮
  240. cardView: false, //是否显示详细视图
  241. detailView: false,
  242. //rowStyle:rowStyle,//通过自定义函数设置行样式
  243. ajaxOptions: {
  244. headers: {
  245. 'Accept': 'application/json',
  246. 'Authorization': 'Bearer ' + localStorage.getItem("token")
  247. }
  248. },
  249. columns: [
  250. {
  251. field: 'drugname',
  252. title: '品名',
  253. align: "center",
  254. valign: 'middle',
  255. formatter: function (value, row, index) {
  256. if (value != null && value != "") {
  257. return value.replace("()","");
  258. }
  259. return "";
  260. }
  261. }, {
  262. field: 'specification',
  263. title: '规格',
  264. align: "center",
  265. valign: 'middle',
  266. }, {
  267. field: 'quantity',
  268. title: '数量',
  269. align: "center",
  270. valign: 'middle',
  271. }, {
  272. field: 'unit_price',
  273. title: '单价',
  274. align: "center",
  275. valign: 'middle',
  276. }, {
  277. field: 'dec_amount',
  278. title: '退药量',
  279. align: "center",
  280. valign: 'middle',
  281. }
  282. ],
  283. /**
  284. * @param {点击列的 field 名称} field
  285. * @param {点击列的 value 值} value
  286. * @param {点击列的整行数据} row
  287. * @param {td 元素} $element
  288. */
  289. onClickCell: function(field, value, row, $element) {
  290. var bill_item_code=row.bill_item_code.trim();
  291. if(field == 'dec_amount' && (bill_item_code =='010' || bill_item_code =='011')){
  292. $element.attr('contenteditable', true);
  293. $element.html(null);
  294. $element.focus();
  295. $element.blur(function() {
  296. var index = $element.parent().data('index');
  297. var tdValue = $element.html();
  298. saveData(index, field, tdValue);
  299. })
  300. }
  301. },
  302. responseHandler: function (res) {
  303. if (res == '401' || res == 401) {
  304. window.location.href = '/thmz/login/view'
  305. return;
  306. }
  307. var ress = eval(res);
  308. if (ress.code == -1) {
  309. if (ress.message != null && ress.message != '') {
  310. new PNotify({
  311. title: '错误提示',
  312. text: ress.message,
  313. type: 'error',
  314. hide: true,
  315. styling: 'bootstrap3'
  316. });
  317. }
  318. return {
  319. "total": 0,//总页数
  320. "rows": {} //数据
  321. };
  322. }
  323. return {
  324. "total": ress.data.length,//总页数
  325. "rows": ress.data //数据
  326. };
  327. },
  328. });
  329. function saveData(index, field, value) {
  330. $table.bootstrapTable('updateCell', {
  331. index: index, //行索引
  332. field: field, //列名
  333. value: value //cell值
  334. })
  335. }
  336. }
  337. /**
  338. * 保存退药信息
  339. */
  340. function saveRefundMedicine() {
  341. var data= $table.bootstrapTable('getData');
  342. var jsonData = JSON.parse('{"serialNo":"","groupNoOut":"","orderNo":"","chargeItemCodeAndDecAmounts":[]}');
  343. if(data!=null){
  344. jsonData.serialNo = data[0].serial_no;
  345. jsonData.groupNoOut = data[0].group_no;
  346. jsonData.orderNo = data[0].order_no;
  347. for (var i=0;i<data.length;i++){
  348. var dec_amount=data[i].dec_amount;
  349. if(dec_amount==null || dec_amount==""){
  350. new PNotify({
  351. title: '警告提示',
  352. text: "【"+data[i].drugname+"】"+'的退药量不能为空',
  353. hide: false,
  354. styling: 'bootstrap3'
  355. });
  356. return;
  357. }
  358. jsonData.chargeItemCodeAndDecAmounts[i] = data[i].charge_item_code+","+dec_amount;
  359. }
  360. }
  361. $.ajax({
  362. type: "POST",
  363. url: '/thmz/refundMedicine',
  364. contentType: "application/json;charset=UTF-8",
  365. dataType: "json",
  366. headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
  367. data: JSON.stringify(jsonData),
  368. success: function (res) {
  369. if (res == '401' || res == 401) {
  370. window.location.href = '/thmz/login/view'
  371. return;
  372. }
  373. if (res.code == 0) {
  374. successMesage(res);
  375. } else {
  376. errorMesage(res);
  377. }
  378. }
  379. });
  380. }