sign_handle.js 19 KB

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