sign_handle.js 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599
  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. if()
  252. vm.signInfo.adminTeamCode = vm.patientInfo.jtSign.adminTeamId
  253. vm.signInfo.teamCode = vm.patientInfo.jtSign.adminTeamId
  254. if(vm.doctorType == 2) {
  255. vm.signInfo.doctorName = doctorInfo.name
  256. vm.signInfo.doctor = doctorInfo.uid
  257. }
  258. if(vm.doctorType == 3) {
  259. vm.signInfo.healthDoctorName = doctorInfo.name
  260. vm.signInfo.healthDoctor = doctorInfo.uid
  261. }
  262. vm.signInfo.expenses = vm.patientInfo.jtSign.expensesType
  263. vm.judgeTeamToDoc(vm.signInfo.adminTeamCode)
  264. } else {
  265. showErrorMessage(res.msg);
  266. }
  267. })
  268. },
  269. judgeTeamToDoc: function(teamCode) {
  270. var judge = false
  271. for(var i = 0, len = this.teamList.length; i < len; i++) {
  272. if(this.teamList[i].id == teamCode) {
  273. judge = true
  274. this.teamMember()
  275. }
  276. }
  277. if(!judge) {
  278. this.signInfo.adminTeamCode = null
  279. this.signInfo.teamCode = null
  280. this.warnMsg = "您已不在原签约团队,请选择新的签约团队"
  281. if(this.doctorType == 2) {
  282. this.justHDoc = this.signInfo.healthDoctorName
  283. this.signInfo.healthDoctorName = null
  284. this.signInfo.healthDoctor = null
  285. } else {
  286. this.justDoc = this.signInfo.doctorName
  287. this.signInfo.doctor = null
  288. this.signInfo.doctorName = null
  289. }
  290. }
  291. },
  292. getDictByDictName: function() {
  293. var vm =this,
  294. loadding = layer.load(0, {shade: false}),
  295. params = {
  296. name: "SIGN_EXPENSES"
  297. }
  298. signAPI.getDictByDictName(params).then(function(res) {
  299. layer.close(loadding)
  300. if(res.status == 200) {
  301. vm.dictList = res.list
  302. } else {
  303. showErrorMessage(res.msg);
  304. }
  305. })
  306. },
  307. teamLimit: function() {
  308. var vm = this,
  309. loadding = layer.load(0, {shade: false}),
  310. params = {
  311. doctorId: doctorInfo.uid
  312. }
  313. signAPI.teamLimit(params).then(function(res) {
  314. layer.close(loadding)
  315. if(res.status == 200) {
  316. vm.teamList = res.data
  317. if (httpData.status == 0) {
  318. vm.signing()
  319. } else {
  320. vm.signOuttime();
  321. }
  322. } else {
  323. showErrorMessage(res.msg);
  324. }
  325. })
  326. },
  327. findPatientSignServerBySignCode: function() {
  328. var vm =this,
  329. loadding = layer.load(0, {shade: false}),
  330. params = {
  331. signCode: httpData.signCode
  332. };
  333. signAPI.findPatientSignServerBySignCode(params).then(function(res) {
  334. layer.close(loadding)
  335. if(res.status == 200) {
  336. vm.fileList = [];
  337. var len = res.data.length;
  338. if(res.data.length > 0) {
  339. vm.serverName = "";
  340. vm.signInfo.sevId = "";
  341. for(var i = 0; i < len; i++) {
  342. if(i == 0) {
  343. vm.serverName += res.data[i].serverTypeName
  344. vm.signInfo.sevId += res.data[i].servetType
  345. } else {
  346. vm.serverName += + ', ' + res.data[i].serverTypeName
  347. vm.signInfo.sevId += +',' + res.data[i].servetType
  348. }
  349. }
  350. }
  351. $.each(res.data, function(i, v) {
  352. if(v.serverType == 8 || v.serverType == 9 || v.serverType == 11) {
  353. vm.fileList.push(v);
  354. }
  355. });
  356. } else {
  357. showErrorMessage(res.msg);
  358. }
  359. })
  360. },
  361. teamMember: function() {
  362. var vm = this,
  363. loadding = layer.load(0, {shade: false}),
  364. params = {
  365. teamId: vm.signInfo.adminTeamCode
  366. }
  367. signAPI.teamMember(params).then(function(res) {
  368. layer.close(loadding)
  369. vm.memberList = [];
  370. vm.doctorList = [];
  371. if(res.status == 200) {
  372. var judge = false
  373. $.each(res.data, function(i, v) {
  374. if(v.available) {
  375. if(v.code == vm.signInfo.doctor && vm.doctorType == 3) {
  376. judge = true
  377. }
  378. if(v.code == vm.signInfo.healthDoctor && vm.doctorType == 2) {
  379. judge = true
  380. }
  381. }
  382. if(v.available && (v.level == 3 || v.level == 2)) {vm.memberList.push(v);}
  383. if(v.available && v.level == 2) {vm.doctorList.push(v);}
  384. });
  385. if(!judge && httpData.status == 1) {
  386. if(vm.doctorType == 3) {
  387. if(!vm.justDoc) {
  388. vm.justDoc = vm.signInfo.doctorName
  389. }
  390. vm.warnMsg = "去年居民续签的全科医生" + vm.justDoc + "已不在您的团队,请重新选择一位全科医生"
  391. vm.justDoc = null
  392. vm.signInfo.doctor = null
  393. vm.signInfo.doctorName = null
  394. }
  395. if(vm.doctorType == 2) {
  396. if(!vm.justHDoc) {
  397. vm.justHDoc = vm.signInfo.healthDoctorName
  398. }
  399. vm.warnMsg = "去年居民续签的健管师" + vm.justHDoc + "已不在您的团队,请重新选择一位健管师"
  400. vm.justHDoc = null
  401. vm.signInfo.healthDoctor = null
  402. vm.signInfo.healthDoctorName = null
  403. }
  404. top.changeTypeIndex=null
  405. }
  406. } else {
  407. showErrorMessage(res.msg);
  408. }
  409. })
  410. },
  411. selectStatus: function(num) {
  412. if(num == 1) {
  413. this.isShowList2 = false;
  414. this.isShowList3 = false;
  415. this.isShowList4 = false;
  416. this.isShowList1 = !this.isShowList1;
  417. } else if (num == 2) {
  418. if(!this.signInfo.adminTeamCode) {
  419. showWarningMessage("请先选择签约团队")
  420. return false;
  421. }
  422. this.isShowList1 = false;
  423. this.isShowList3 = false;
  424. this.isShowList4 = false;
  425. this.isShowList2 = !this.isShowList2;
  426. } else if (num == 3) {
  427. this.isShowList1 = false;
  428. this.isShowList2 = false;
  429. this.isShowList4 = false;
  430. this.isShowList3 = !this.isShowList3;
  431. } else {
  432. this.isShowList1 = false;
  433. this.isShowList2 = false;
  434. this.isShowList3 = false;
  435. this.isShowList4 = !this.isShowList4;
  436. }
  437. },
  438. selectLi: function(num, data) {
  439. if(num == 1) { // 选择签约团队
  440. this.isShowList1 = false;
  441. this.signInfo.adminTeamCode = data.id;
  442. this.signInfo.teamCode = data.id;
  443. if(this.doctorType == 2) {
  444. this.signInfo.healthDoctor = null
  445. this.signInfo.healthDoctorName = null
  446. }
  447. if(this.doctorType == 3) {
  448. this.signInfo.doctor = null
  449. this.signInfo.doctorName = null
  450. }
  451. if(!this.memberList || !this.doctorList) {
  452. this.teamMember()
  453. }
  454. }
  455. if(num == 2) { // 选择健管师
  456. this.isShowList2 = false;
  457. this.signInfo.healthDoctorName = data.name
  458. this.signInfo.healthDoctor = data.code
  459. }
  460. if(num == 3) {
  461. this.isShowList3 = false;
  462. this.signInfo.expenses = data.code;
  463. }
  464. if(num == 4) { // 选择全科医生
  465. this.isShowList4 = false;
  466. this.signInfo.doctorName = data.name
  467. this.signInfo.doctor = data.code
  468. }
  469. },
  470. showTeamName: function(teamCode) {
  471. var teamName;
  472. if(!this.teamList) {
  473. return "请选择签约团队";
  474. }
  475. for(var i = 0, len = this.teamList.length; i < len; i++) {
  476. if(teamCode == this.teamList[i].id) {
  477. teamName = this.teamList[i].name;
  478. }
  479. }
  480. return teamName
  481. },
  482. showExpensesName: function(code) {
  483. var expensesName;
  484. if(!this.dictList) {
  485. return "请选择补贴类型";
  486. }
  487. for(var i = 0, len = this.dictList.length; i < len; i++) {
  488. if(code == this.dictList[i].code) {
  489. expensesName = this.dictList[i].value;
  490. }
  491. }
  492. return expensesName
  493. },
  494. setPatImg: function(str) {
  495. var imgStr = httpRequest.getImgUrl(str);
  496. if (imgStr == "") {
  497. return '../../../images/p-female.png';
  498. } else {
  499. return imgStr;
  500. }
  501. },
  502. lookPhoto: function(data) {
  503. parent.photoLayerIndex = parent.layer.open({
  504. type: 2,
  505. area: ['70%', '600px'],
  506. title: false,
  507. shade: 0.5,
  508. shadeClose: true,
  509. shift: 2,
  510. content: '../html/photo_show.html?serverType=' + data.serverType + '&patientCode=' + httpData.patientCode
  511. })
  512. },
  513. refuse: function() {
  514. var vm = this;
  515. layer.open({
  516. type: 1,
  517. area: ['400px', '300px'],
  518. shade: 0.5,
  519. title: '拒绝签约原因',
  520. shift: 2,
  521. shadeClose: false, //点击遮罩关闭层
  522. 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>',
  523. btn: ['提 交', '取 消'],
  524. yes:function(index, layero) {
  525. if(!refuseReason) {
  526. if(!$("#reason").val()) {
  527. showWarningMessage("请选择或输入拒绝理由!");
  528. layer.close(index);
  529. return false
  530. }
  531. vm.signInfo.refuseReason = $("#reason").val()
  532. } else {
  533. if($("#reason").val()) {
  534. vm.signInfo.refuseReason = refuseReason + "。" + $("#reason").val()
  535. } else {
  536. vm.signInfo.refuseReason = refuseReason
  537. }
  538. }
  539. vm.signInfo.adminTeamCode = 0;
  540. vm.signInfo.teamCode = 0;
  541. vm.signInfo.type = 2;
  542. vm.signInfo.state = 0;
  543. vm.sign();
  544. layer.close(index);
  545. },
  546. success: function(layero){
  547. layero.find('.layui-layer-btn').css('text-align', 'center')
  548. }
  549. });
  550. },
  551. sign: function() {// type:1签约 2拒签
  552. 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))) {
  553. showWarningMessage("请将填写完整签约信息!");
  554. return false;
  555. }
  556. var vm = this,
  557. loadding = layer.load(0, {shade: false});
  558. if (httpData.status == 0) {
  559. signAPI.sign(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. } else {
  573. signAPI.signRenew(vm.signInfo).then(function(res) {
  574. layer.close(loadding)
  575. if(res.status == 200) {
  576. showSuccessMessage(res.msg || "操作成功")
  577. setTimeout(function() {
  578. parent.gobalVue.signCount();
  579. layer.closeAll();
  580. parent.layer.closeAll();
  581. }, 1000)
  582. } else {
  583. showErrorMessage(res.msg);
  584. }
  585. })
  586. }
  587. }
  588. }
  589. })