request.js 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859
  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. };
  331. return temp;
  332. }
  333. var rePortRangeArr = getSourceRangeArr();
  334. var temp = {
  335. beginDate: rePortRangeArr[0],
  336. endDate: rePortRangeArr[1],
  337. };
  338. return temp;
  339. };
  340. /**
  341. * 生成新号表数据
  342. */
  343. function initNewList() {
  344. if (!showTwoTable) {
  345. return;
  346. }
  347. initNewListCommon('/thmz/getNewRequestByTimes', newListQueryParams);
  348. }
  349. /**
  350. * 生成新号表的通用方法
  351. * @param url
  352. * @param newParams
  353. */
  354. function initNewListCommon(url, newParams) {
  355. $('#tb_table_2').bootstrapTable("destroy");
  356. $('#tb_table_2').bootstrapTable({
  357. url: url, //请求后台的URL(*)
  358. method: 'post', //请求方式(*)
  359. toolbar: '#toolbar', //工具按钮用哪个容器
  360. striped: true, //是否显示行间隔色
  361. cache: false, //是否使用缓存,默认为true,所以一般情况下需要设置一下这个属性(*)
  362. pagination: true, //是否显示分页(*)
  363. sortable: true, //是否启用排序
  364. sortOrder: "asc", //排序方式
  365. queryParams: newParams, //传递参数(*)
  366. sidePagination: "client", //分页方式:client客户端分页,server服务端分页(*)
  367. pageNumber: 1, //初始化加载第一页,默认第一页
  368. pageSize: 15, //每页的记录行数(*)
  369. pageList: [10, 15, 25, 50, 100], //可供选择的每页的行数(*)
  370. search: false, //是否显示表格搜索,此搜索是客户端搜索,不会进服务端,所以,个人感觉意义不大
  371. strictSearch: true,
  372. showColumns: false, //是否显示所有的列
  373. showRefresh: false, //是否显示刷新按钮
  374. minimumCountColumns: 2, //最少允许的列数
  375. clickToSelect: true, //是否启用点击选中行
  376. uniqueId: "ID", //每一行的唯一标识,一般为主键列
  377. showToggle: false, //是否显示详细视图和列表视图的切换按钮
  378. cardView: false, //是否显示详细视图
  379. detailView: false,
  380. //rowStyle:rowStyle,//通过自定义函数设置行样式
  381. ajaxOptions: {
  382. headers: {
  383. 'Accept': 'application/json',
  384. 'Authorization': 'Bearer ' + localStorage.getItem("token")
  385. }
  386. },
  387. columns: [
  388. {
  389. title: '操作',
  390. align: "center",
  391. valign: 'middle',
  392. formatter: function (value, row, index) {
  393. var str = '<button type="button" class="btn btn-primary btn-sm" onclick="updateRequestByIndex(' + index + ')">编辑</button>';
  394. return [str].join('');
  395. }
  396. },
  397. {
  398. field: 'requestDay',
  399. title: '日期',
  400. align: "center",
  401. valign: 'middle',
  402. formatter: function (value, row, index) {
  403. return format(value, "yyyy-MM-dd");
  404. }
  405. }, {
  406. field: 'ampm',
  407. title: '号段',
  408. align: "center",
  409. valign: 'middle',
  410. formatter: function (value, row, index) {
  411. var text = '上午';
  412. if (value == 'p') {
  413. text = '下午';
  414. } else if (value == 'd') {
  415. text = '全天';
  416. }
  417. return text;
  418. }
  419. }, {
  420. field: 'unitName',
  421. title: '科室',
  422. align: "center",
  423. valign: 'middle'
  424. }, {
  425. field: 'doctorName',
  426. title: '医生',
  427. align: "center",
  428. valign: 'middle'
  429. }, {
  430. field: 'chargeTypeName',
  431. title: '号别',
  432. align: "center",
  433. valign: 'middle'
  434. }, {
  435. field: 'checkFee',
  436. title: '检查费',
  437. align: "center",
  438. valign: 'middle',
  439. formatter: function (value, row, index) {
  440. return value.toFixed(2);
  441. }
  442. }, {
  443. field: 'totalNum',
  444. title: '总号数',
  445. align: "center",
  446. valign: 'middle'
  447. }, {
  448. field: 'leftNum',
  449. title: '剩余号数',
  450. align: "center",
  451. valign: 'middle'
  452. }, {
  453. field: 'bespeakNo',
  454. title: '当前号数',
  455. align: "center",
  456. valign: 'middle'
  457. }
  458. ],
  459. responseHandler: function (res) {
  460. if (res == '401' || res == 401) {
  461. window.location.href = '/thmz/login/view'
  462. return;
  463. }
  464. var ress = eval(res);
  465. if (ress.code == -1) {
  466. if (ress.message != null && ress.message != '') {
  467. new PNotify({
  468. title: '错误提示',
  469. text: ress.message,
  470. type: 'error',
  471. hide: true,
  472. styling: 'bootstrap3'
  473. });
  474. }
  475. // return {
  476. // "total": 0,//总页数
  477. // "rows": {} //数据
  478. // };
  479. }
  480. //临时保存新号表数据
  481. tempData = ress.data;
  482. return {
  483. "total": ress.data.length,//总页数
  484. "rows": ress.data //数据
  485. };
  486. },
  487. });
  488. }
  489. /**
  490. * 构建列表查询参数
  491. * @param params
  492. * @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}}
  493. */
  494. function newListQueryParams(params) {
  495. var newRangeArr = getNewRangeArr();
  496. if (baseList) {
  497. var temp = {
  498. beginDate: "2012-02-13 00:00:00",
  499. endDate: "2012-02-19 23:59:59",
  500. newBeginDate: newRangeArr[0],
  501. newEndDate: newRangeArr[1],
  502. };
  503. return temp;
  504. }
  505. var rePortRangeArr = getSourceRangeArr();
  506. var temp = {
  507. beginDate: rePortRangeArr[0],
  508. endDate: rePortRangeArr[1],
  509. newBeginDate: newRangeArr[0],
  510. newEndDate: newRangeArr[1],
  511. };
  512. return temp;
  513. };
  514. /**
  515. * 设置病人id
  516. */
  517. function setPatientId() {
  518. var patientId_or_cardNo = $("#patientId_or_cardNo").val();
  519. $.ajax({
  520. type: "GET",
  521. url: '/thmz/getByIcCardNo?icCardNo=' + patientId_or_cardNo,
  522. contentType: "application/json;charset=UTF-8",
  523. dataType: "json",
  524. headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
  525. success: function (res) {
  526. if (res == '401' || res == 401) {
  527. window.location.href = '/thmz/login/view'
  528. return;
  529. }
  530. if (res.code == 0) {
  531. if (res.data != null) {
  532. $("#patientId").val(res.data.patientId);
  533. } else {
  534. $("#patientId").val(patientId_or_cardNo);
  535. }
  536. }
  537. }
  538. });
  539. }
  540. /**
  541. * 获取源号表时间选择器的时间数组
  542. * @returns {string[]}
  543. */
  544. function getSourceRangeArr() {
  545. var rePortRange = $('#sourceRange span').html();
  546. var rePortRangeArr = rePortRange.split(" - ");
  547. rePortRangeArr[0] = rePortRangeArr[0] + " 00:00:00"
  548. rePortRangeArr[1] = rePortRangeArr[1] + " 23:59:59"
  549. return rePortRangeArr;
  550. }
  551. /**
  552. * 获取新号表时间选择器的时间数组
  553. * @returns {string[]}
  554. */
  555. function getNewRangeArr() {
  556. var rePortRange = $('#newRange span').html();
  557. var rePortRangeArr = rePortRange.split(" - ");
  558. rePortRangeArr[0] = rePortRangeArr[0] + " 00:00:00"
  559. rePortRangeArr[1] = rePortRangeArr[1] + " 23:59:59"
  560. return rePortRangeArr;
  561. }
  562. /**
  563. * 清空查询条件
  564. */
  565. function cleanParams() {
  566. $('#sourceRange span').html(moment().format('YYYY-MM-DD') + ' - ' + moment().format('YYYY-MM-DD'));
  567. $('#newRange span').html(moment().format('YYYY-MM-DD') + ' - ' + moment().format('YYYY-MM-DD'));
  568. }
  569. /**
  570. * 保存临时生成的新号表数据
  571. */
  572. function saveTempRequest() {
  573. var index =$("#requestId").val();
  574. var realParams = JSON.parse('{"mzyRequests":""}');
  575. var tempJson = JSON.parse('{"requestDay":"","ampm":"","unitCode":"","doctorCode":"","chargeType":"","totalNum":"","leftNum":"","bespeakNo":"1","checkFee":""}');
  576. tempJson.requestDay = $("#editDay").val();
  577. tempJson.ampm = $("#ampm").val();
  578. tempJson.unitCode = $("#deptNo").val();
  579. tempJson.doctorCode = $("#doctorParam").val();
  580. tempJson.chargeType = $("#chargeType").val();
  581. tempJson.totalNum = $("#totalNum").val();
  582. tempJson.leftNum = $("#totalNum").val();
  583. tempJson.checkFee = $("#checkFee").val();
  584. if(index==null || index ==""){
  585. tempData[tempData.length] = tempJson;
  586. }else {
  587. tempData[index] = tempJson;
  588. }
  589. realParams.mzyRequests = tempData;
  590. $("#editModal").modal("hide");
  591. initNewListCommon("/thmz/formatRequest", realParams);
  592. }
  593. /**
  594. * 保存号表数据
  595. */
  596. function saveRequest() {
  597. var data = null;
  598. if (showTwoTable) {
  599. var realParams = JSON.parse('{"mzyRequests":[]}');
  600. for (var i = 0; i < tempData.length; i++) {
  601. var thisData = tempData[i];
  602. var tempJson = JSON.parse('{"requestDay":"","ampm":"","unitCode":"","doctorCode":"","chargeType":"","totalNum":"","leftNum":"","bespeakNo":"1","checkFee":""}');
  603. tempJson.requestDay = thisData.requestDay;
  604. tempJson.ampm = thisData.ampm;
  605. tempJson.unitCode = thisData.unitCode;
  606. tempJson.doctorCode = thisData.doctorCode;
  607. tempJson.chargeType = thisData.chargeType;
  608. tempJson.totalNum = thisData.totalNum;
  609. tempJson.leftNum = thisData.leftNum;
  610. tempJson.checkFee = thisData.checkFee;
  611. realParams.mzyRequests[i] = tempJson;
  612. }
  613. data = JSON.stringify(realParams);
  614. } else {
  615. data = JSON.stringify({
  616. mzyRequests: [{
  617. id:$("#requestId").val(),
  618. requestDay: $("#editDay").val(),
  619. ampm: $("#ampm").val(),
  620. unitCode: $("#deptNo").val(),
  621. doctorCode: $("#doctorParam").val(),
  622. chargeType: $("#chargeType").val(),
  623. totalNum: $("#totalNum").val(),
  624. leftNum: $("#totalNum").val(),
  625. bespeakNo: 1,
  626. checkFee: $("#checkFee").val()
  627. }]
  628. });
  629. }
  630. $.ajax({
  631. type: "POST",
  632. url: '/thmz/saveRequest',
  633. contentType: "application/json;charset=UTF-8",
  634. dataType: "json",
  635. headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
  636. data: data,
  637. success: function (res) {
  638. if (res == '401' || res == 401) {
  639. window.location.href = '/thmz/login/view'
  640. return;
  641. }
  642. if (res.code == 0) {
  643. $("#editModal").modal("hide");
  644. clearInput();
  645. initSourceList();
  646. successMesage(res);
  647. if (showTwoTable) {
  648. $('#sourceRange span').html($('#newRange span').html());
  649. $("#btn_cancel").click();
  650. }
  651. } else {
  652. errorMesage(res);
  653. }
  654. }
  655. });
  656. }
  657. /**
  658. * 初始门诊时间区间下拉选
  659. */
  660. function initMzWorkTime() {
  661. $.ajax({
  662. type: "GET",
  663. url: '/thmz/getMzWorkTime',
  664. dataType: "json",
  665. headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
  666. success: function (res) {
  667. if (res == '401' || res == 401) {
  668. window.location.href = '/thmz/login/view'
  669. return;
  670. }
  671. var html = '';
  672. $.each(res.data, function (commentIndex, comment) {
  673. html += '<option value="' + comment.code + '">' + comment.name + '</option>';
  674. });
  675. $('#ampm').empty(); //清空resText里面的所有内容
  676. $('#ampm').html(html);
  677. $('#ampm').selectpicker('refresh');
  678. }
  679. });
  680. }
  681. /**
  682. * 挂号列表中的科室列表
  683. */
  684. function initDeptSelect() {
  685. //科室列表
  686. $.ajax({
  687. type: "GET",
  688. url: '/thmz/allMzUnitCode',
  689. dataType: "json",
  690. headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
  691. success: function (data) {
  692. if (data == '401' || data == 401) {
  693. window.location.href = '/thmz/login/view'
  694. return;
  695. }
  696. var html = '';
  697. $.each(data.data, function (commentIndex, comment) {
  698. html += '<option value="' + comment.code + '">' + comment.name + '(' + comment.pyCode + ')</option>';
  699. });
  700. $('#deptNo').empty();
  701. $('#deptNo').html(html);
  702. $('#deptNo').selectpicker('refresh');
  703. }
  704. });
  705. }
  706. /**
  707. * 挂号列表中的医生列表初始化
  708. */
  709. function initDoctorSelect() {
  710. //医生列表
  711. $.ajax({
  712. type: "GET",
  713. url: '/thmz/listEmployeeByDepts?depts=' + $('#deptNo').val(),
  714. dataType: "json",
  715. headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
  716. success: function (res) {
  717. if (res == '401' || res == 401) {
  718. window.location.href = '/thmz/login/view'
  719. return;
  720. }
  721. var html = '';
  722. $.each(res.data, function (commentIndex, comment) {
  723. html += '<option value="' + comment.employeeCode + '">' + comment.employeeName + '</option>';
  724. });
  725. $('#doctorParam').empty();
  726. $('#doctorParam').html(html);
  727. $('#doctorParam').selectpicker('destroy').selectpicker('refresh');
  728. }
  729. });
  730. }
  731. /**
  732. * 初始门诊号别下拉选
  733. */
  734. function initChargeType() {
  735. $.ajax({
  736. type: "GET",
  737. url: '/thmz/getAllMzChargeType',
  738. dataType: "json",
  739. headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
  740. success: function (res) {
  741. if (res == '401' || res == 401) {
  742. window.location.href = '/thmz/login/view'
  743. return;
  744. }
  745. var html = '<option value=""></option>';
  746. $.each(res.data, function (commentIndex, comment) {
  747. html += '<option value="' + comment.code + '">' + comment.name + '</option>';
  748. });
  749. $('#chargeType').empty(); //清空resText里面的所有内容
  750. $('#chargeType').html(html);
  751. $('#chargeType').selectpicker('refresh');
  752. }
  753. });
  754. }
  755. /**
  756. * 修改号表信息
  757. * @param id
  758. */
  759. function updateRequest(id) {
  760. $("#requestId").val(id);
  761. $.ajax({
  762. type: "GET",
  763. url: '/thmz/getRequestById?id=' + id,
  764. dataType: "json",
  765. headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
  766. success: function (res) {
  767. if (res == '401' || res == 401) {
  768. window.location.href = '/thmz/login/view'
  769. return;
  770. }
  771. if (res.code == 0) {
  772. $("#classTitle").text("修改");
  773. $("#editDay").val(format(res.data.requestDay, "yyyy-MM-dd"));
  774. $('#ampm').selectpicker('val', res.data.ampm);
  775. $('#ampm').selectpicker('refresh');
  776. $('#deptNo').selectpicker('val', res.data.unitCode);
  777. $('#deptNo').selectpicker('refresh');
  778. $('#doctorParam').selectpicker('val', res.data.doctorCode);
  779. $('#doctorParam').selectpicker('refresh');
  780. $('#chargeType').selectpicker('val', res.data.chargeType);
  781. $('#chargeType').selectpicker('refresh');
  782. $("#totalNum").val(res.data.totalNum);
  783. $("#totalNum").val(res.data.leftNum);
  784. $("#checkFee").val(res.data.checkFee);
  785. $("#editModal").modal();
  786. }
  787. }
  788. });
  789. }
  790. /**
  791. * 临时新号表修改
  792. * @param index
  793. */
  794. function updateRequestByIndex(index) {
  795. $("#requestId").val(index);
  796. var data =tempData[index];
  797. $("#classTitle").text("修改");
  798. $("#editDay").val(format(data.requestDay, "yyyy-MM-dd"));
  799. $('#ampm').selectpicker('val', data.ampm);
  800. $('#ampm').selectpicker('refresh');
  801. $('#deptNo').selectpicker('val', data.unitCode);
  802. $('#deptNo').selectpicker('refresh');
  803. $('#doctorParam').selectpicker('val', data.doctorCode);
  804. $('#doctorParam').selectpicker('refresh');
  805. $('#chargeType').selectpicker('val', data.chargeType);
  806. $('#chargeType').selectpicker('refresh');
  807. $("#totalNum").val(data.totalNum);
  808. $("#totalNum").val(data.leftNum);
  809. $("#checkFee").val(data.checkFee);
  810. $("#editModal").modal();
  811. }