sign_handle.js 17 KB

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