request.js 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882
  1. //@ sourceURL=request.js
  2. //默认是查询基础号表字典,当选择源数据的时候改为false
  3. var baseList = false;
  4. //默认是显示一个表格,当点击生产新号表时,改为true
  5. var showTwoTable = false;
  6. //保存临时生成的新号表数据
  7. var tempData = null;
  8. $(function () {
  9. daterangepickerWithIdAndCallBack('sourceRange', initSourceList);
  10. daterangepickerWithIdAndCallBack('newRange', initSourceList);
  11. // initDaterangepickerWithId('sourceRange');
  12. // initDaterangepickerWithId('newRange');
  13. initSourceList();
  14. // initFeeTable();
  15. //重置查询参数
  16. $('#btn_clean').click(function () {
  17. cleanParams();
  18. });
  19. // $("#btn_query").click(function (t) {
  20. // initSourceList();
  21. // });
  22. $(".selectpicker").selectpicker({
  23. dropuAuto: false
  24. });
  25. $("#btn_creat").click(function (t) {
  26. showTwoTable = true;
  27. initSourceList();
  28. $("#btn_creat").removeClass('in').addClass('hide');
  29. $("#btn_cancel").removeClass('hide').addClass('in');
  30. $("#tb_table_1").css("display", "block");
  31. $("#tb_table_2").css("display", "block");
  32. });
  33. $("#btn_cancel").click(function (t) {
  34. showTwoTable = false;
  35. //取消后置空
  36. tempData = null;
  37. initSourceList();
  38. $("#btn_cancel").removeClass('in').addClass('hide');
  39. $("#btn_creat").removeClass('hide').addClass('in');
  40. $("#tb_table_1").css("display", "none");
  41. $("#tb_table_2").css("display", "none");
  42. });
  43. $("#btn_add").click(function (t) {
  44. $("#editModal").modal();
  45. $("#classTitle").text("新增");
  46. clearInput();
  47. });
  48. $("#btn_save").click(function (t) {
  49. if (showTwoTable) {
  50. //保存临时生成的新号表数据
  51. saveRequest();
  52. }
  53. });
  54. $("#saveEdit").click(function (t) {
  55. if (showTwoTable) {
  56. //保存临时生成的新号表数据
  57. saveTempRequest();
  58. } else {
  59. //单独添加一个排班,直接保存
  60. saveRequest();
  61. }
  62. });
  63. initMzWorkTime();
  64. initDeptSelect();
  65. initDoctorSelect();
  66. initChargeType();
  67. $("#editDay").change(function (e) {
  68. var editDay = $("#editDay").val();
  69. if (editDay.length == 8 && editDay.indexOf("-") <= 0) {
  70. if (editDay.substring(4, 6) > 12) {
  71. new PNotify({
  72. title: '错误提示',
  73. text: '号表日期错误,月份不能大于12',
  74. type: 'error',
  75. hide: true,
  76. styling: 'bootstrap3'
  77. });
  78. $("#editDay").val(null);
  79. return;
  80. }
  81. if (editDay.substring(6) > 31) {
  82. new PNotify({
  83. title: '错误提示',
  84. text: '号表日期错误,天数不能大于31',
  85. type: 'error',
  86. hide: true,
  87. styling: 'bootstrap3'
  88. });
  89. $("#editDay").val(null);
  90. return;
  91. }
  92. editDay = editDay.substring(0, 4) + "-" + editDay.substring(4, 6) + "-" + editDay.substring(6);
  93. $("#editDay").val(editDay);
  94. }
  95. var dateFormat = /^(\d{4})-(\d{2})-(\d{2})$/;
  96. if (!dateFormat.test(editDay)) {
  97. new PNotify({
  98. title: '错误提示',
  99. text: '号表日期错误',
  100. type: 'error',
  101. hide: true,
  102. styling: 'bootstrap3'
  103. });
  104. }
  105. var arr = editDay.split("-");
  106. if (!checkDate(arr[0], arr[1], arr[2])) {
  107. new PNotify({
  108. title: '错误提示',
  109. text: '表表日期错误',
  110. type: 'error',
  111. hide: true,
  112. styling: 'bootstrap3'
  113. });
  114. }
  115. });
  116. });
  117. /**
  118. * 清空输入框
  119. */
  120. function clearInput() {
  121. $("#requestId").val(null);
  122. $("#editDay").val(null);
  123. $('#ampm').selectpicker('val', null);
  124. $('#ampm').selectpicker('refresh');
  125. $('#deptNo').selectpicker('val', null);
  126. $('#deptNo').selectpicker('refresh');
  127. $('#doctorParam').selectpicker('val', null);
  128. $('#doctorParam').selectpicker('refresh');
  129. $('#chargeType').selectpicker('val', null);
  130. $('#chargeType').selectpicker('refresh');
  131. $("#checkFee").val(null);
  132. $("#totalNum").val(null);
  133. }
  134. /**
  135. * 号表类型切换事件
  136. * @param object
  137. */
  138. function sourceChange(object) {
  139. $("#source_group").find("button").each(function (index, element) {
  140. if ($(element).hasClass("btn-primary")) {
  141. $(element).removeClass("btn-primary").addClass("btn-default");
  142. }
  143. });
  144. $(object).removeClass("btn-default").addClass("btn-primary");
  145. var sourceGroup = getIndex("source_group");
  146. if (sourceGroup == 0) {
  147. baseList = true;
  148. } else {
  149. baseList = false;
  150. }
  151. initSourceList();
  152. }
  153. /**
  154. * 获取按钮组选择的下标
  155. * @param id
  156. * @returns {number}
  157. */
  158. function getIndex(id) {
  159. var index = 0;
  160. var item = $("#" + id).find("button");
  161. for (var i = 0; i <= item.length; i++) {
  162. if ($(item[i]).hasClass("btn-primary")) {
  163. index = i;
  164. break;
  165. }
  166. }
  167. return index;
  168. }
  169. /**
  170. * 查询源号表信息
  171. */
  172. function initSourceList() {
  173. $('#tb_table_2').bootstrapTable("destroy");
  174. var tableId = 'tb_table';
  175. var destroyTableId = 'tb_table_1';
  176. if (showTwoTable) {
  177. tableId = 'tb_table_1';
  178. destroyTableId = 'tb_table';
  179. }
  180. $('#' + destroyTableId).bootstrapTable("destroy");
  181. $('#' + tableId).bootstrapTable("destroy");
  182. $('#' + tableId).bootstrapTable({
  183. url: '/thmz/getRequestByTimes', //请求后台的URL(*)
  184. method: 'post', //请求方式(*)
  185. toolbar: '#toolbar', //工具按钮用哪个容器
  186. striped: true, //是否显示行间隔色
  187. cache: false, //是否使用缓存,默认为true,所以一般情况下需要设置一下这个属性(*)
  188. pagination: true, //是否显示分页(*)
  189. sortable: true, //是否启用排序
  190. sortOrder: "asc", //排序方式
  191. queryParams: queryParams, //传递参数(*)
  192. sidePagination: "client", //分页方式:client客户端分页,server服务端分页(*)
  193. pageNumber: 1, //初始化加载第一页,默认第一页
  194. pageSize: 15, //每页的记录行数(*)
  195. pageList: [10, 15, 25, 50, 100], //可供选择的每页的行数(*)
  196. search: false, //是否显示表格搜索,此搜索是客户端搜索,不会进服务端,所以,个人感觉意义不大
  197. strictSearch: true,
  198. showColumns: false, //是否显示所有的列
  199. showRefresh: false, //是否显示刷新按钮
  200. minimumCountColumns: 2, //最少允许的列数
  201. clickToSelect: true, //是否启用点击选中行
  202. uniqueId: "ID", //每一行的唯一标识,一般为主键列
  203. showToggle: false, //是否显示详细视图和列表视图的切换按钮
  204. cardView: false, //是否显示详细视图
  205. detailView: false,
  206. //rowStyle:rowStyle,//通过自定义函数设置行样式
  207. ajaxOptions: {
  208. headers: {
  209. 'Accept': 'application/json',
  210. 'Authorization': 'Bearer ' + localStorage.getItem("token")
  211. }
  212. },
  213. columns: [
  214. {
  215. title: '操作',
  216. field: 'op',
  217. align: "center",
  218. valign: 'middle',
  219. formatter: function (value, row, index) {
  220. var str = '<button type="button" class="btn btn-primary btn-sm" onclick="updateRequest(' + row.id + ')">编辑</button>';
  221. return [str].join('');
  222. }
  223. },
  224. {
  225. field: 'requestDay',
  226. title: '日期',
  227. align: "center",
  228. valign: 'middle',
  229. formatter: function (value, row, index) {
  230. return format(value, "yyyy-MM-dd");
  231. }
  232. }, {
  233. field: 'ampm',
  234. title: '号段',
  235. align: "center",
  236. valign: 'middle',
  237. formatter: function (value, row, index) {
  238. var text = '上午';
  239. if (value == 'p') {
  240. text = '下午';
  241. } else if (value == 'd') {
  242. text = '全天';
  243. }
  244. return text;
  245. }
  246. }, {
  247. field: 'unitName',
  248. title: '科室',
  249. align: "center",
  250. valign: 'middle'
  251. }, {
  252. field: 'doctorName',
  253. title: '医生',
  254. align: "center",
  255. valign: 'middle'
  256. }, {
  257. field: 'chargeTypeName',
  258. title: '号别',
  259. align: "center",
  260. valign: 'middle'
  261. }, {
  262. field: 'checkFee',
  263. title: '检查费',
  264. align: "center",
  265. valign: 'middle',
  266. formatter: function (value, row, index) {
  267. return value.toFixed(2);
  268. }
  269. }, {
  270. field: 'totalNum',
  271. title: '总号数',
  272. align: "center",
  273. valign: 'middle'
  274. }, {
  275. field: 'leftNum',
  276. title: '剩余号数',
  277. align: "center",
  278. valign: 'middle'
  279. }, {
  280. field: 'bespeakNo',
  281. title: '当前号数',
  282. align: "center",
  283. valign: 'middle'
  284. }
  285. ],
  286. onLoadSuccess: function () {
  287. if (baseList) {
  288. $('#' + tableId).bootstrapTable('hideColumn', 'op');//隐藏上述操作列
  289. }
  290. },
  291. responseHandler: function (res) {
  292. if (res == '401' || res == 401) {
  293. window.location.href = '/thmz/login/view'
  294. return;
  295. }
  296. var ress = eval(res);
  297. if (ress.code == -1) {
  298. if (ress.message != null && ress.message != '') {
  299. new PNotify({
  300. title: '错误提示',
  301. text: ress.message,
  302. type: 'error',
  303. hide: true,
  304. styling: 'bootstrap3'
  305. });
  306. }
  307. return {
  308. "total": 0,//总页数
  309. "rows": {} //数据
  310. };
  311. }
  312. return {
  313. "total": ress.data.length,//总页数
  314. "rows": ress.data //数据
  315. };
  316. },
  317. });
  318. initNewList();
  319. }
  320. /**
  321. * 构建列表查询参数
  322. * @param params
  323. * @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}}
  324. */
  325. function queryParams(params) {
  326. if (baseList) {
  327. var temp = {
  328. beginDate: "2012-02-13 00:00:00",
  329. endDate: "2012-02-19 23:59:59",
  330. unitCode: $("#unitCode").val(),
  331. ampm: $("#ampmParams").val()
  332. };
  333. return temp;
  334. }
  335. var rePortRangeArr = getSourceRangeArr();
  336. var temp = {
  337. beginDate: rePortRangeArr[0],
  338. endDate: rePortRangeArr[1],
  339. unitCode: $("#unitCode").val(),
  340. ampm: $("#ampmParams").val()
  341. };
  342. return temp;
  343. };
  344. /**
  345. * 生成新号表数据
  346. */
  347. function initNewList() {
  348. if (!showTwoTable) {
  349. return;
  350. }
  351. initNewListCommon('/thmz/getNewRequestByTimes', newListQueryParams);
  352. }
  353. /**
  354. * 生成新号表的通用方法
  355. * @param url
  356. * @param newParams
  357. */
  358. function initNewListCommon(url, newParams) {
  359. $('#tb_table_2').bootstrapTable("destroy");
  360. $('#tb_table_2').bootstrapTable({
  361. url: url, //请求后台的URL(*)
  362. method: 'post', //请求方式(*)
  363. toolbar: '#toolbar', //工具按钮用哪个容器
  364. striped: true, //是否显示行间隔色
  365. cache: false, //是否使用缓存,默认为true,所以一般情况下需要设置一下这个属性(*)
  366. pagination: true, //是否显示分页(*)
  367. sortable: true, //是否启用排序
  368. sortOrder: "asc", //排序方式
  369. queryParams: newParams, //传递参数(*)
  370. sidePagination: "client", //分页方式:client客户端分页,server服务端分页(*)
  371. pageNumber: 1, //初始化加载第一页,默认第一页
  372. pageSize: 15, //每页的记录行数(*)
  373. pageList: [10, 15, 25, 50, 100], //可供选择的每页的行数(*)
  374. search: false, //是否显示表格搜索,此搜索是客户端搜索,不会进服务端,所以,个人感觉意义不大
  375. strictSearch: true,
  376. showColumns: false, //是否显示所有的列
  377. showRefresh: false, //是否显示刷新按钮
  378. minimumCountColumns: 2, //最少允许的列数
  379. clickToSelect: true, //是否启用点击选中行
  380. uniqueId: "ID", //每一行的唯一标识,一般为主键列
  381. showToggle: false, //是否显示详细视图和列表视图的切换按钮
  382. cardView: false, //是否显示详细视图
  383. detailView: false,
  384. //rowStyle:rowStyle,//通过自定义函数设置行样式
  385. ajaxOptions: {
  386. headers: {
  387. 'Accept': 'application/json',
  388. 'Authorization': 'Bearer ' + localStorage.getItem("token")
  389. }
  390. },
  391. columns: [
  392. {
  393. title: '操作',
  394. align: "center",
  395. valign: 'middle',
  396. formatter: function (value, row, index) {
  397. var str = '<button type="button" class="btn btn-primary btn-sm" onclick="updateRequestByIndex(' + index + ')">编辑</button>';
  398. return [str].join('');
  399. }
  400. },
  401. {
  402. field: 'requestDay',
  403. title: '日期',
  404. align: "center",
  405. valign: 'middle',
  406. formatter: function (value, row, index) {
  407. return format(value, "yyyy-MM-dd");
  408. }
  409. }, {
  410. field: 'ampm',
  411. title: '号段',
  412. align: "center",
  413. valign: 'middle',
  414. formatter: function (value, row, index) {
  415. var text = '上午';
  416. if (value == 'p') {
  417. text = '下午';
  418. } else if (value == 'd') {
  419. text = '全天';
  420. }
  421. return text;
  422. }
  423. }, {
  424. field: 'unitName',
  425. title: '科室',
  426. align: "center",
  427. valign: 'middle'
  428. }, {
  429. field: 'doctorName',
  430. title: '医生',
  431. align: "center",
  432. valign: 'middle'
  433. }, {
  434. field: 'chargeTypeName',
  435. title: '号别',
  436. align: "center",
  437. valign: 'middle'
  438. }, {
  439. field: 'checkFee',
  440. title: '检查费',
  441. align: "center",
  442. valign: 'middle',
  443. formatter: function (value, row, index) {
  444. return value.toFixed(2);
  445. }
  446. }, {
  447. field: 'totalNum',
  448. title: '总号数',
  449. align: "center",
  450. valign: 'middle'
  451. }, {
  452. field: 'leftNum',
  453. title: '剩余号数',
  454. align: "center",
  455. valign: 'middle'
  456. }, {
  457. field: 'bespeakNo',
  458. title: '当前号数',
  459. align: "center",
  460. valign: 'middle'
  461. }
  462. ],
  463. responseHandler: function (res) {
  464. if (res == '401' || res == 401) {
  465. window.location.href = '/thmz/login/view'
  466. return;
  467. }
  468. var ress = eval(res);
  469. if (ress.code == -1) {
  470. if (ress.message != null && ress.message != '') {
  471. new PNotify({
  472. title: '错误提示',
  473. text: ress.message,
  474. type: 'error',
  475. hide: true,
  476. styling: 'bootstrap3'
  477. });
  478. }
  479. // return {
  480. // "total": 0,//总页数
  481. // "rows": {} //数据
  482. // };
  483. }
  484. //临时保存新号表数据
  485. tempData = ress.data;
  486. return {
  487. "total": ress.data.length,//总页数
  488. "rows": ress.data //数据
  489. };
  490. },
  491. });
  492. }
  493. /**
  494. * 构建列表查询参数
  495. * @param params
  496. * @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}}
  497. */
  498. function newListQueryParams(params) {
  499. var newRangeArr = getNewRangeArr();
  500. if (baseList) {
  501. var temp = {
  502. beginDate: "2012-02-13 00:00:00",
  503. endDate: "2012-02-19 23:59:59",
  504. newBeginDate: newRangeArr[0],
  505. newEndDate: newRangeArr[1],
  506. };
  507. return temp;
  508. }
  509. var rePortRangeArr = getSourceRangeArr();
  510. var temp = {
  511. beginDate: rePortRangeArr[0],
  512. endDate: rePortRangeArr[1],
  513. newBeginDate: newRangeArr[0],
  514. newEndDate: newRangeArr[1],
  515. };
  516. return temp;
  517. };
  518. /**
  519. * 设置病人id
  520. */
  521. function setPatientId() {
  522. var patientId_or_cardNo = $("#patientId_or_cardNo").val();
  523. $.ajax({
  524. type: "GET",
  525. url: '/thmz/getByIcCardNo?icCardNo=' + patientId_or_cardNo,
  526. contentType: "application/json;charset=UTF-8",
  527. dataType: "json",
  528. headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
  529. success: function (res) {
  530. if (res == '401' || res == 401) {
  531. window.location.href = '/thmz/login/view'
  532. return;
  533. }
  534. if (res.code == 0) {
  535. if (res.data != null) {
  536. $("#patientId").val(res.data.patientId);
  537. } else {
  538. $("#patientId").val(patientId_or_cardNo);
  539. }
  540. }
  541. }
  542. });
  543. }
  544. /**
  545. * 获取源号表时间选择器的时间数组
  546. * @returns {string[]}
  547. */
  548. function getSourceRangeArr() {
  549. var rePortRange = $('#sourceRange span').html();
  550. var rePortRangeArr = rePortRange.split(" - ");
  551. rePortRangeArr[0] = rePortRangeArr[0] + " 00:00:00"
  552. rePortRangeArr[1] = rePortRangeArr[1] + " 23:59:59"
  553. return rePortRangeArr;
  554. }
  555. /**
  556. * 获取新号表时间选择器的时间数组
  557. * @returns {string[]}
  558. */
  559. function getNewRangeArr() {
  560. var rePortRange = $('#newRange span').html();
  561. var rePortRangeArr = rePortRange.split(" - ");
  562. rePortRangeArr[0] = rePortRangeArr[0] + " 00:00:00"
  563. rePortRangeArr[1] = rePortRangeArr[1] + " 23:59:59"
  564. return rePortRangeArr;
  565. }
  566. /**
  567. * 清空查询条件
  568. */
  569. function cleanParams() {
  570. $('#sourceRange span').html(moment().format('YYYY-MM-DD') + ' - ' + moment().format('YYYY-MM-DD'));
  571. $('#newRange span').html(moment().format('YYYY-MM-DD') + ' - ' + moment().format('YYYY-MM-DD'));
  572. $('#ampmParams').selectpicker('val', null);
  573. $('#ampmParams').selectpicker('refresh');
  574. $('#unitCode').selectpicker('val', null);
  575. $('#unitCode').selectpicker('refresh');
  576. initSourceList();
  577. }
  578. /**
  579. * 保存临时生成的新号表数据
  580. */
  581. function saveTempRequest() {
  582. var index = $("#requestId").val();
  583. var realParams = JSON.parse('{"mzyRequests":""}');
  584. var tempJson = JSON.parse('{"requestDay":"","ampm":"","unitCode":"","doctorCode":"","chargeType":"","totalNum":"","leftNum":"","bespeakNo":"1","checkFee":""}');
  585. tempJson.requestDay = $("#editDay").val();
  586. tempJson.ampm = $("#ampm").val();
  587. tempJson.unitCode = $("#deptNo").val();
  588. tempJson.doctorCode = $("#doctorParam").val();
  589. tempJson.chargeType = $("#chargeType").val();
  590. tempJson.totalNum = $("#totalNum").val();
  591. tempJson.leftNum = $("#totalNum").val();
  592. tempJson.checkFee = $("#checkFee").val();
  593. if (index == null || index == "") {
  594. tempData[tempData.length] = tempJson;
  595. } else {
  596. tempData[index] = tempJson;
  597. }
  598. realParams.mzyRequests = tempData;
  599. $("#editModal").modal("hide");
  600. initNewListCommon("/thmz/formatRequest", realParams);
  601. }
  602. /**
  603. * 保存号表数据
  604. */
  605. function saveRequest() {
  606. var data = null;
  607. if (showTwoTable) {
  608. var realParams = JSON.parse('{"mzyRequests":[]}');
  609. for (var i = 0; i < tempData.length; i++) {
  610. var thisData = tempData[i];
  611. var tempJson = JSON.parse('{"requestDay":"","ampm":"","unitCode":"","doctorCode":"","chargeType":"","totalNum":"","leftNum":"","bespeakNo":"1","checkFee":""}');
  612. tempJson.requestDay = thisData.requestDay;
  613. tempJson.ampm = thisData.ampm;
  614. tempJson.unitCode = thisData.unitCode;
  615. tempJson.doctorCode = thisData.doctorCode;
  616. tempJson.chargeType = thisData.chargeType;
  617. tempJson.totalNum = thisData.totalNum;
  618. tempJson.leftNum = thisData.leftNum;
  619. tempJson.checkFee = thisData.checkFee;
  620. realParams.mzyRequests[i] = tempJson;
  621. }
  622. data = JSON.stringify(realParams);
  623. } else {
  624. data = JSON.stringify({
  625. mzyRequests: [{
  626. id: $("#requestId").val(),
  627. requestDay: $("#editDay").val(),
  628. ampm: $("#ampm").val(),
  629. unitCode: $("#deptNo").val(),
  630. doctorCode: $("#doctorParam").val(),
  631. chargeType: $("#chargeType").val(),
  632. totalNum: $("#totalNum").val(),
  633. leftNum: $("#totalNum").val(),
  634. bespeakNo: 1,
  635. checkFee: $("#checkFee").val()
  636. }]
  637. });
  638. }
  639. $.ajax({
  640. type: "POST",
  641. url: '/thmz/saveRequest',
  642. contentType: "application/json;charset=UTF-8",
  643. dataType: "json",
  644. headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
  645. data: data,
  646. success: function (res) {
  647. if (res == '401' || res == 401) {
  648. window.location.href = '/thmz/login/view'
  649. return;
  650. }
  651. if (res.code == 0) {
  652. $("#editModal").modal("hide");
  653. clearInput();
  654. if(showTwoTable){
  655. initSourceList();
  656. }else {
  657. $('#tb_table').bootstrapTable('refresh');
  658. }
  659. successMesage(res);
  660. if (showTwoTable) {
  661. $('#sourceRange span').html($('#newRange span').html());
  662. $("#btn_cancel").click();
  663. }
  664. } else {
  665. errorMesage(res);
  666. }
  667. }
  668. });
  669. }
  670. /**
  671. * 初始门诊时间区间下拉选
  672. */
  673. function initMzWorkTime() {
  674. $.ajax({
  675. type: "GET",
  676. url: '/thmz/getMzWorkTime',
  677. dataType: "json",
  678. headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
  679. success: function (res) {
  680. if (res == '401' || res == 401) {
  681. window.location.href = '/thmz/login/view'
  682. return;
  683. }
  684. var html = '';
  685. $.each(res.data, function (commentIndex, comment) {
  686. html += '<option value="' + comment.code + '">' + comment.name + '</option>';
  687. });
  688. $('#ampm').empty(); //清空resText里面的所有内容
  689. $('#ampm').html(html);
  690. $('#ampm').selectpicker('refresh');
  691. $('#ampmParams').empty(); //清空resText里面的所有内容
  692. $('#ampmParams').html(html);
  693. $('#ampmParams').selectpicker('refresh');
  694. }
  695. });
  696. }
  697. /**
  698. * 挂号列表中的科室列表
  699. */
  700. function initDeptSelect() {
  701. //科室列表
  702. $.ajax({
  703. type: "GET",
  704. url: '/thmz/allMzUnitCode',
  705. dataType: "json",
  706. headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
  707. success: function (data) {
  708. if (data == '401' || data == 401) {
  709. window.location.href = '/thmz/login/view'
  710. return;
  711. }
  712. var html = '';
  713. $.each(data.data, function (commentIndex, comment) {
  714. html += '<option value="' + comment.code + '">' + comment.name + '(' + comment.pyCode + ')</option>';
  715. });
  716. $('#deptNo').empty();
  717. $('#deptNo').html(html);
  718. $('#deptNo').selectpicker('refresh');
  719. $('#unitCode').empty();
  720. $('#unitCode').html(html);
  721. $('#unitCode').selectpicker('refresh');
  722. }
  723. });
  724. }
  725. /**
  726. * 挂号列表中的医生列表初始化
  727. */
  728. function initDoctorSelect() {
  729. //医生列表
  730. $.ajax({
  731. type: "GET",
  732. //url: '/thmz/listEmployeeByDepts?depts=' + $('#deptNo').val(),
  733. url: '/thmz/listEmployeeByDepts?depts=null',
  734. dataType: "json",
  735. headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
  736. success: function (res) {
  737. if (res == '401' || res == 401) {
  738. window.location.href = '/thmz/login/view'
  739. return;
  740. }
  741. var html = '<option value=""></option>';
  742. $.each(res.data, function (commentIndex, comment) {
  743. html += '<option value="' + comment.employeeCode + '">' + comment.employeeName + ' (' + comment.deptName + ') </option>';
  744. });
  745. $('#doctorParam').empty();
  746. $('#doctorParam').html(html);
  747. $('#doctorParam').selectpicker('destroy').selectpicker('refresh');
  748. }
  749. });
  750. }
  751. /**
  752. * 初始门诊号别下拉选
  753. */
  754. function initChargeType() {
  755. $.ajax({
  756. type: "GET",
  757. url: '/thmz/getAllMzChargeType',
  758. dataType: "json",
  759. headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
  760. success: function (res) {
  761. if (res == '401' || res == 401) {
  762. window.location.href = '/thmz/login/view'
  763. return;
  764. }
  765. var html = '<option value=""></option>';
  766. $.each(res.data, function (commentIndex, comment) {
  767. html += '<option value="' + comment.code + '">' + comment.name + '</option>';
  768. });
  769. $('#chargeType').empty(); //清空resText里面的所有内容
  770. $('#chargeType').html(html);
  771. $('#chargeType').selectpicker('refresh');
  772. }
  773. });
  774. }
  775. /**
  776. * 修改号表信息
  777. * @param id
  778. */
  779. function updateRequest(id) {
  780. $("#requestId").val(id);
  781. $.ajax({
  782. type: "GET",
  783. url: '/thmz/getRequestById?id=' + id,
  784. dataType: "json",
  785. headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
  786. success: function (res) {
  787. if (res == '401' || res == 401) {
  788. window.location.href = '/thmz/login/view'
  789. return;
  790. }
  791. if (res.code == 0) {
  792. $("#classTitle").text("修改");
  793. $("#editDay").val(format(res.data.requestDay, "yyyy-MM-dd"));
  794. $('#ampm').selectpicker('val', res.data.ampm);
  795. $('#ampm').selectpicker('refresh');
  796. $('#deptNo').selectpicker('val', res.data.unitCode);
  797. $('#deptNo').selectpicker('refresh');
  798. //initDoctorSelect();
  799. $('#doctorParam').selectpicker('val', res.data.doctorCode);
  800. $('#doctorParam').selectpicker('refresh');
  801. $('#chargeType').selectpicker('val', res.data.chargeType);
  802. $('#chargeType').selectpicker('refresh');
  803. $("#totalNum").val(res.data.totalNum);
  804. $("#totalNum").val(res.data.leftNum);
  805. $("#checkFee").val(res.data.checkFee);
  806. $("#editModal").modal();
  807. }
  808. }
  809. });
  810. }
  811. /**
  812. * 临时新号表修改
  813. * @param index
  814. */
  815. function updateRequestByIndex(index) {
  816. $("#requestId").val(index);
  817. var data = tempData[index];
  818. $("#classTitle").text("修改");
  819. $("#editDay").val(format(data.requestDay, "yyyy-MM-dd"));
  820. $('#ampm').selectpicker('val', data.ampm);
  821. $('#ampm').selectpicker('refresh');
  822. $('#deptNo').selectpicker('val', data.unitCode);
  823. $('#deptNo').selectpicker('refresh');
  824. $('#doctorParam').selectpicker('val', data.doctorCode);
  825. $('#doctorParam').selectpicker('refresh');
  826. $('#chargeType').selectpicker('val', data.chargeType);
  827. $('#chargeType').selectpicker('refresh');
  828. $("#totalNum").val(data.totalNum);
  829. $("#totalNum").val(data.leftNum);
  830. $("#checkFee").val(data.checkFee);
  831. $("#editModal").modal();
  832. }