sign_handle.js 18 KB

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