sign_handle.js 19 KB

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