sign_handle.js 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585
  1. var httpData=GetRequest(),
  2. doctorInfo = JSON.parse(window.localStorage.getItem('wlyyAgent'));
  3. var refuseReason = null;
  4. function showSuccessMessage(msg) {
  5. layer.msg(msg, {
  6. icon: 1
  7. })
  8. }
  9. function showErrorMessage(msg) {
  10. layer.msg(msg, {
  11. icon: 5
  12. })
  13. }
  14. function showWarningMessage(msg) {
  15. layer.msg(msg, {
  16. icon: 2
  17. })
  18. }
  19. function showInfoMessage(msg) {
  20. layer.msg(msg, {
  21. icon: 6
  22. })
  23. }
  24. function getReason(ele) {
  25. if(ele.hasClass("active")) {
  26. ele.removeClass("active")
  27. refuseReason = null
  28. return false;
  29. }
  30. ele.addClass("active").siblings().removeClass("active");
  31. refuseReason = ele.html();
  32. }
  33. top.changeTypeIndex=null;//修改居民标签的窗体
  34. top.handleVue=new Vue({
  35. el: "#app",
  36. data: {
  37. justDoc: null,
  38. justHDoc: null,
  39. doctorType: doctorInfo.doctorType,
  40. isShowList1: false,
  41. isShowList2: false,
  42. isShowList3: false,
  43. isShowList4: false,
  44. patientInfo: null,
  45. warnMsg: "",
  46. signdictList: null,
  47. teamList: null,
  48. memberList: null, // 团队成员列表
  49. doctorList: null, // 全科医生列表
  50. dictList: null,
  51. fileList: null,
  52. serverName: null,
  53. labelName: null,
  54. signInfo: {
  55. signType: 1,
  56. signCode: httpData.signCode,
  57. majorDoctor: null,
  58. majorDoctorName: null,
  59. healthLabel: null,
  60. customLabel: null,
  61. disease: null,
  62. patientIDcard: null, // 必填
  63. adminTeamCode: null,
  64. msgid: null, // 消息id(必填)
  65. patient: httpData.patientCode,
  66. doctor: null,
  67. doctorName: null,
  68. healthDoctor: null,
  69. healthDoctorName: null,
  70. type: 1,
  71. state: 1,
  72. expenses: null,
  73. group: null,
  74. //添加服务类型数据
  75. sevId: null,
  76. // 拒绝参数
  77. // adminTeamCode:0,
  78. // type: 2,
  79. refuseReason: null
  80. },
  81. },
  82. mounted: function() {
  83. this.getSigndict();
  84. this.getDictByDictName();
  85. if(!httpData.msgid || httpData.msgid == "undefined" || httpData.msgid == "null") {
  86. this.findMsgId()
  87. } else {
  88. this.signInfo.msgid = httpData.msgid
  89. }
  90. this.teamLimit();
  91. this.findPatientSignServerBySignCode();
  92. },
  93. methods: {
  94. allLabels: function(selData) {
  95. var vm =this,
  96. param = {
  97. teamCode: this.signInfo.adminTeamCode
  98. },
  99. loadding = layer.load(0, {shade: false});
  100. signAPI.allLabels(param).then(function(res) {
  101. layer.close(loadding)
  102. if(res.status == 200) {
  103. $.each(res.data, function(i, v) {
  104. if(v.labelType == 2) {
  105. $.each(selData.heath, function(j, u) {
  106. if(u == v.labelCode) {
  107. if(vm.labelName == "") {
  108. vm.labelName += v.labelName
  109. } else {
  110. vm.labelName += ',' + v.labelName
  111. }
  112. }
  113. });
  114. }
  115. if(v.labelType == 3) {
  116. $.each(selData.disease, function(j, u) {
  117. if(u == v.labelCode) {
  118. if(vm.labelName == "") {
  119. vm.labelName += v.labelName
  120. } else {
  121. vm.labelName += ',' + v.labelName
  122. }
  123. }
  124. });
  125. }
  126. if(v.labelType == 4) {
  127. $.each(selData.team, function(j, u) {
  128. if(u == v.labelCode) {
  129. if(vm.labelName == "") {
  130. vm.labelName += v.labelName
  131. } else {
  132. vm.labelName += ',' + v.labelName
  133. }
  134. }
  135. });
  136. }
  137. });
  138. } else {
  139. showErrorMessage(res.msg);
  140. }
  141. })
  142. },
  143. getSigndict: function() {
  144. var vm =this,
  145. loadding = layer.load(0, {shade: false});
  146. signAPI.getSigndict().then(function(res) {
  147. layer.close(loadding)
  148. if(res.status == 200) {
  149. vm.signdictList = res.data
  150. } else {
  151. showErrorMessage(res.msg);
  152. }
  153. })
  154. },
  155. findMsgId: function() {
  156. var vm =this,
  157. params = {
  158. sender: httpData.patientCode,
  159. signStatus: httpData.status == 0 ? 1 : 8
  160. },
  161. loadding = layer.load(0, {shade: false});
  162. signAPI.findMsgId(params).then(function(res) {
  163. layer.close(loadding)
  164. if(res.status == 200) {
  165. vm.signInfo.msgid = res.data.id
  166. } else {
  167. showErrorMessage(res.msg);
  168. }
  169. })
  170. },
  171. signing: function() {
  172. var vm = this,
  173. loadding = layer.load(0, {shade: false}),
  174. params = {
  175. patient: httpData.patientCode
  176. }
  177. signAPI.signing(params).then(function(res) {
  178. layer.close(loadding)
  179. if(res.status == 200) {
  180. vm.patientInfo = res.data
  181. vm.signInfo.patientIDcard = res.data.idCard
  182. } else {
  183. showErrorMessage(res.msg);
  184. }
  185. })
  186. },
  187. selectServer:function(){
  188. var vm=this
  189. if(!this.signInfo.adminTeamCode) {
  190. showWarningMessage("请先选择签约团队");
  191. return false;
  192. }
  193. if(top.changeTypeIndex && top.$('#layui-layer-shade'+top.changeTypeIndex).length){
  194. top.xgLabel.initPage();
  195. (top.$('#layui-layer-shade'+top.changeTypeIndex).show(),top.$('#layui-layer'+top.changeTypeIndex).show());
  196. }else{
  197. top.changeTypeIndex=top.layer.open({
  198. type: 2,
  199. area: ['500px', '405px'],
  200. title: "修改居民标签",
  201. shade: 0.5,
  202. shadeClose: false,
  203. closeBtn: 0,
  204. shift: 2,
  205. content: '../html/modify-the-label.html?patient=' + httpData.patientCode+'&teamCode='+vm.signInfo.adminTeamCode+"&signCode="+httpData.signCode
  206. });
  207. }
  208. },
  209. handleStr: function(str) {
  210. if (!str || str === '') {
  211. return ''
  212. }
  213. return str.substr(0, 19)
  214. },
  215. acceptanceRes:function(res){
  216. var vm = this
  217. this.serverName = "";
  218. this.labelName = "";
  219. if(res.server.length != 0) this.signInfo.sevId = res.server.join(",");
  220. if(res.disease.length != 0) this.signInfo.disease = res.disease.join(",");
  221. if(res.heath.length != 0) this.signInfo.healthLabel = res.heath.join(",");
  222. if(res.team.length != 0) this.signInfo.customLabel = res.team.join(",");
  223. $.each(res.server, function(i, v) {
  224. $.each(vm.signdictList, function(j, u) {
  225. if(v == u.code) {
  226. if(vm.serverName == "") {
  227. vm.serverName += u.name
  228. } else {
  229. vm.serverName += ',' + u.name
  230. }
  231. }
  232. });
  233. });
  234. this.allLabels(res)
  235. },
  236. signOuttime: function() {
  237. var vm = this,
  238. loadding = layer.load(0, {shade: false}),
  239. params = {
  240. patient: httpData.patientCode
  241. }
  242. signAPI.signOuttime(params).then(function(res) {
  243. layer.close(loadding)
  244. if(res.status == 200) {
  245. vm.patientInfo = res.data
  246. vm.signInfo.adminTeamCode = vm.patientInfo.jtSign.adminTeamId
  247. vm.signInfo.healthDoctorName = vm.patientInfo.jtSign.doctorHealthName || ""
  248. vm.signInfo.healthDoctor = vm.patientInfo.jtSign.doctorHealth || ""
  249. vm.signInfo.doctor = vm.patientInfo.jtSign.doctor || ""
  250. vm.signInfo.doctorName = vm.patientInfo.jtSign.doctorName || ""
  251. vm.signInfo.expenses = vm.patientInfo.jtSign.expensesType
  252. vm.judgeTeamToDoc(vm.signInfo.adminTeamCode)
  253. } else {
  254. showErrorMessage(res.msg);
  255. }
  256. })
  257. },
  258. judgeTeamToDoc: function(teamCode) {
  259. var judge = false
  260. for(var i = 0, len = this.teamList.length; i < len; i++) {
  261. if(this.teamList[i].id == teamCode) {
  262. judge = true
  263. this.teamMember()
  264. }
  265. }
  266. if(!judge) {
  267. this.signInfo.adminTeamCode = null
  268. this.warnMsg = "您已不在原签约团队,请选择新的签约团队"
  269. if(this.doctorType == 2) {
  270. this.justHDoc = this.signInfo.healthDoctorName
  271. this.signInfo.healthDoctorName = null
  272. this.signInfo.healthDoctor = null
  273. } else {
  274. this.justDoc = this.signInfo.doctorName
  275. this.signInfo.doctor = null
  276. this.signInfo.doctorName = null
  277. }
  278. }
  279. },
  280. getDictByDictName: function() {
  281. var vm =this,
  282. loadding = layer.load(0, {shade: false}),
  283. params = {
  284. name: "SIGN_EXPENSES"
  285. }
  286. signAPI.getDictByDictName(params).then(function(res) {
  287. layer.close(loadding)
  288. if(res.status == 200) {
  289. vm.dictList = res.list
  290. } else {
  291. showErrorMessage(res.msg);
  292. }
  293. })
  294. },
  295. teamLimit: function() {
  296. var vm = this,
  297. loadding = layer.load(0, {shade: false}),
  298. params = {
  299. doctorId: doctorInfo.uid
  300. }
  301. signAPI.teamLimit(params).then(function(res) {
  302. layer.close(loadding)
  303. if(res.status == 200) {
  304. vm.teamList = res.data
  305. if (httpData.status == 0) {
  306. vm.signing()
  307. } else {
  308. vm.signOuttime();
  309. }
  310. } else {
  311. showErrorMessage(res.msg);
  312. }
  313. })
  314. },
  315. findPatientSignServerBySignCode: function() {
  316. var vm =this,
  317. loadding = layer.load(0, {shade: false}),
  318. params = {
  319. signCode: httpData.signCode
  320. };
  321. signAPI.findPatientSignServerBySignCode(params).then(function(res) {
  322. layer.close(loadding)
  323. if(res.status == 200) {
  324. vm.fileList = [];
  325. var len = res.data.length;
  326. if(res.data.length > 0) {
  327. vm.serverName = "";
  328. vm.signInfo.sevId = "";
  329. for(var i = 0; i < len; i++) {
  330. if(i == 0) {
  331. vm.serverName += res.data[i].serverTypeName
  332. vm.signInfo.sevId += res.data[i].servetType
  333. } else {
  334. vm.serverName += + ', ' + res.data[i].serverTypeName
  335. vm.signInfo.sevId += +',' + res.data[i].servetType
  336. }
  337. }
  338. }
  339. $.each(res.data, function(i, v) {
  340. if(v.serverType == 8 || v.serverType == 9 || v.serverType == 11) {
  341. vm.fileList.push(v);
  342. }
  343. });
  344. } else {
  345. showErrorMessage(res.msg);
  346. }
  347. })
  348. },
  349. teamMember: function() {
  350. var vm = this,
  351. loadding = layer.load(0, {shade: false}),
  352. params = {
  353. teamId: vm.signInfo.adminTeamCode
  354. }
  355. signAPI.teamMember(params).then(function(res) {
  356. layer.close(loadding)
  357. vm.memberList = [];
  358. vm.doctorList = [];
  359. if(res.status == 200) {
  360. var judge = false
  361. $.each(res.data, function(i, v) {
  362. if(v.available) {
  363. if(v.code == vm.signInfo.doctor && vm.doctorType == 3) {
  364. judge = true
  365. }
  366. if(v.code == vm.signInfo.healthDoctor && vm.doctorType == 2) {
  367. judge = true
  368. }
  369. }
  370. if(v.available && (v.level == 3 || v.level == 2)) {vm.memberList.push(v);}
  371. if(v.available && v.level == 2) {vm.doctorList.push(v);}
  372. });
  373. if(!judge && httpData.status == 1) {
  374. if(vm.doctorType == 3) {
  375. if(!vm.justDoc) {
  376. vm.justDoc = vm.signInfo.doctorName
  377. }
  378. vm.warnMsg = "去年居民续签的全科医生" + vm.justDoc + "已不在您的团队,请重新选择一位全科医生"
  379. vm.justDoc = null
  380. vm.signInfo.doctor = null
  381. vm.signInfo.doctorName = null
  382. }
  383. if(vm.doctorType == 2) {
  384. if(!vm.justHDoc) {
  385. vm.justHDoc = vm.signInfo.healthDoctorName
  386. }
  387. vm.warnMsg = "去年居民续签的健管师" + vm.justHDoc + "已不在您的团队,请重新选择一位健管师"
  388. vm.justHDoc = null
  389. vm.signInfo.healthDoctor = null
  390. vm.signInfo.healthDoctorName = null
  391. }
  392. top.changeTypeIndex=null
  393. }
  394. } else {
  395. showErrorMessage(res.msg);
  396. }
  397. })
  398. },
  399. selectStatus: function(num) {
  400. if(num == 1) {
  401. this.isShowList2 = false;
  402. this.isShowList3 = false;
  403. this.isShowList4 = false;
  404. this.isShowList1 = !this.isShowList1;
  405. } else if (num == 2) {
  406. if(!this.signInfo.adminTeamCode) {
  407. showWarningMessage("请先选择签约团队")
  408. return false;
  409. }
  410. this.isShowList1 = false;
  411. this.isShowList3 = false;
  412. this.isShowList4 = false;
  413. this.isShowList2 = !this.isShowList2;
  414. } else if (num == 3) {
  415. this.isShowList1 = false;
  416. this.isShowList2 = false;
  417. this.isShowList4 = false;
  418. this.isShowList3 = !this.isShowList3;
  419. } else {
  420. this.isShowList1 = false;
  421. this.isShowList2 = false;
  422. this.isShowList3 = false;
  423. this.isShowList4 = !this.isShowList4;
  424. }
  425. },
  426. selectLi: function(num, data) {
  427. if(num == 1) { // 选择签约团队
  428. this.isShowList1 = false;
  429. this.signInfo.adminTeamCode = data.id;
  430. if(this.doctorType == 2) {
  431. this.signInfo.healthDoctor = null
  432. this.signInfo.healthDoctorName = null
  433. }
  434. if(this.doctorType == 3) {
  435. this.signInfo.doctor = null
  436. this.signInfo.doctorName = null
  437. }
  438. if(!this.memberList || !this.doctorList) {
  439. this.teamMember()
  440. }
  441. }
  442. if(num == 2) { // 选择健管师
  443. this.isShowList2 = false;
  444. this.signInfo.healthDoctorName = data.name
  445. this.signInfo.healthDoctor = data.code
  446. }
  447. if(num == 3) {
  448. this.isShowList3 = false;
  449. this.signInfo.expenses = data.code;
  450. }
  451. if(num == 4) { // 选择全科医生
  452. this.isShowList4 = false;
  453. this.signInfo.doctorName = data.name
  454. this.signInfo.doctor = data.code
  455. }
  456. },
  457. showTeamName: function(teamCode) {
  458. var teamName;
  459. if(!this.teamList) {
  460. return "请选择签约团队";
  461. }
  462. for(var i = 0, len = this.teamList.length; i < len; i++) {
  463. if(teamCode == this.teamList[i].id) {
  464. teamName = this.teamList[i].name;
  465. }
  466. }
  467. return teamName
  468. },
  469. showExpensesName: function(code) {
  470. var expensesName;
  471. if(!this.dictList) {
  472. return "请选择补贴类型";
  473. }
  474. for(var i = 0, len = this.dictList.length; i < len; i++) {
  475. if(code == this.dictList[i].code) {
  476. expensesName = this.dictList[i].value;
  477. }
  478. }
  479. return expensesName
  480. },
  481. setPatImg: function(str) {
  482. var imgStr = httpRequest.getImgUrl(str);
  483. if (imgStr == "") {
  484. return '../../../images/p-female.png';
  485. } else {
  486. return imgStr;
  487. }
  488. },
  489. lookPhoto: function(data) {
  490. layer.open({
  491. type: 2,
  492. area: ['90%', '100%'],
  493. title: "凭证预览",
  494. shade: 0.5,
  495. shadeClose: true,
  496. shift: 2,
  497. content: '../html/photo_show.html?serverType=' + data.serverType + '&patientCode=' + httpData.patientCode
  498. })
  499. },
  500. refuse: function() {
  501. var vm = this;
  502. layer.open({
  503. type: 1,
  504. area: ['400px', '300px'],
  505. shade: 0.5,
  506. title: '拒绝签约原因',
  507. shift: 2,
  508. shadeClose: false, //点击遮罩关闭层
  509. content: '<div class="p20 pb0"><div class="reason_list clearfix"><span class="fl mr10 mb20" onclick="getReason($(this))">居民信息填写不详</span><span class="fl mr10 mb20" onclick="getReason($(this))">签约人数已满</span><span class="fl mb20" onclick="getReason($(this))">家庭医生变更</span></div><textarea id="reason" maxLength="200" placeholder="可选择填写其他拒签原因(限200字以内)"></textarea></div>',
  510. btn: ['提 交', '取 消'],
  511. yes:function(index, layero) {
  512. if(!refuseReason) {
  513. if(!$("#reason").val()) {
  514. showWarningMessage("请选择或输入拒绝理由!");
  515. layer.close(index);
  516. return false
  517. }
  518. vm.signInfo.refuseReason = $("#reason").val()
  519. } else {
  520. if($("#reason").val()) {
  521. vm.signInfo.refuseReason = refuseReason + "。" + $("#reason").val()
  522. } else {
  523. vm.signInfo.refuseReason = refuseReason
  524. }
  525. }
  526. vm.signInfo.adminTeamCode = 0;
  527. vm.signInfo.type = 2;
  528. vm.signInfo.state = 0;
  529. vm.sign();
  530. layer.close(index);
  531. },
  532. success: function(layero){
  533. layero.find('.layui-layer-btn').css('text-align', 'center')
  534. }
  535. });
  536. },
  537. sign: function() {// type:1签约 2拒签
  538. if(this.signInfo.type == 1 && ((this.doctorType == 2 && !this.signInfo.healthDoctor) || (this.doctorType == 3 && !this.signInfo.doctor) || !this.signInfo.sevId || (!this.signInfo.disease && !this.signInfo.healthLabel && !this.signInfo.customLabel))) {
  539. showWarningMessage("请将填写完整签约信息!");
  540. return false;
  541. }
  542. var vm = this,
  543. loadding = layer.load(0, {shade: false});
  544. if (httpData.status == 0) {
  545. signAPI.sign(vm.signInfo).then(function(res) {
  546. layer.close(loadding)
  547. if(res.status == 200) {
  548. showSuccessMessage(res.msg || "操作成功")
  549. setTimeout(function() {
  550. parent.gobalVue.signCount();
  551. layer.closeAll();
  552. parent.layer.closeAll();
  553. }, 1000)
  554. } else {
  555. showErrorMessage(res.msg);
  556. }
  557. })
  558. } else {
  559. signAPI.signRenew(vm.signInfo).then(function(res) {
  560. layer.close(loadding)
  561. if(res.status == 200) {
  562. showSuccessMessage(res.msg || "操作成功")
  563. setTimeout(function() {
  564. parent.gobalVue.signCount();
  565. layer.closeAll();
  566. parent.layer.closeAll();
  567. }, 1000)
  568. } else {
  569. showErrorMessage(res.msg);
  570. }
  571. })
  572. }
  573. }
  574. }
  575. })