sign_handle.js 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634
  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(v.code == vm.signInfo.doctor && vm.doctorType == 3) {
  388. judge = true
  389. }
  390. if(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 && !vm.signInfo.doctorName) {
  400. vm.signInfo.doctorName = vm.signInfo.healthDoctorName
  401. vm.signInfo.doctor = vm.signInfo.healthDoctor
  402. return false
  403. }
  404. if(!vm.justDoc) {
  405. vm.justDoc = vm.signInfo.doctorName
  406. }
  407. vm.warnMsg = "去年签约的全科医生" + vm.justDoc + "已不在您的团队,请重新选择一位全科医生"
  408. vm.justDoc = null
  409. vm.signInfo.doctor = null
  410. vm.signInfo.doctorName = null
  411. }
  412. if(vm.doctorType == 2) {
  413. if(!vm.justHDoc && !vm.signInfo.healthDoctorName) {
  414. vm.signInfo.healthDoctorName = vm.signInfo.doctorName
  415. vm.signInfo.healthDoctor = vm.signInfo.doctor
  416. return false
  417. }
  418. if(!vm.justHDoc) {
  419. vm.justHDoc = vm.signInfo.healthDoctorName
  420. }
  421. vm.warnMsg = "去年签约的健管师" + vm.justHDoc + "已不在您的团队,请重新选择一位健管师"
  422. vm.justHDoc = null
  423. vm.signInfo.healthDoctor = null
  424. vm.signInfo.healthDoctorName = null
  425. }
  426. top.changeTypeIndex=null
  427. }
  428. } else {
  429. showErrorMessage(res.msg);
  430. }
  431. })
  432. },
  433. selectStatus: function(num) {
  434. if(num == 1) {
  435. this.isShowList2 = false;
  436. this.isShowList3 = false;
  437. this.isShowList4 = false;
  438. this.isShowList1 = !this.isShowList1;
  439. } else if (num == 2) {
  440. if(!this.signInfo.adminTeamCode) {
  441. showWarningMessage("请先选择签约团队")
  442. return false;
  443. }
  444. this.isShowList1 = false;
  445. this.isShowList3 = false;
  446. this.isShowList4 = false;
  447. this.isShowList2 = !this.isShowList2;
  448. } else if (num == 3) {
  449. this.isShowList1 = false;
  450. this.isShowList2 = false;
  451. this.isShowList4 = false;
  452. this.isShowList3 = !this.isShowList3;
  453. } else {
  454. if(!this.signInfo.adminTeamCode) {
  455. showWarningMessage("请先选择签约团队")
  456. return false;
  457. }
  458. this.isShowList1 = false;
  459. this.isShowList2 = false;
  460. this.isShowList3 = false;
  461. this.isShowList4 = !this.isShowList4;
  462. }
  463. },
  464. selectLi: function(num, data) {
  465. if(num == 1) { // 选择签约团队
  466. this.isShowList1 = false;
  467. this.signInfo.adminTeamCode = data.id;
  468. this.signInfo.teamCode = data.id;
  469. if(this.doctorType == 2) {
  470. this.signInfo.healthDoctor = null
  471. this.signInfo.healthDoctorName = null
  472. }
  473. if(this.doctorType == 3) {
  474. this.signInfo.doctor = null
  475. this.signInfo.doctorName = null
  476. }
  477. if(!this.memberList || !this.doctorList) {
  478. this.teamMember()
  479. }
  480. }
  481. if(num == 2) { // 选择健管师
  482. this.isShowList2 = false;
  483. this.signInfo.healthDoctorName = data.name
  484. this.signInfo.healthDoctor = data.code
  485. }
  486. if(num == 3) {
  487. this.isShowList3 = false;
  488. this.signInfo.expenses = data.code;
  489. }
  490. if(num == 4) { // 选择全科医生
  491. this.isShowList4 = false;
  492. this.signInfo.doctorName = data.name
  493. this.signInfo.doctor = data.code
  494. }
  495. },
  496. showTeamName: function(teamCode) {
  497. var teamName;
  498. if(!this.teamList) {
  499. return "请选择签约团队";
  500. }
  501. for(var i = 0, len = this.teamList.length; i < len; i++) {
  502. if(teamCode == this.teamList[i].id) {
  503. teamName = this.teamList[i].name;
  504. }
  505. }
  506. return teamName
  507. },
  508. showExpensesName: function(code) {
  509. var expensesName;
  510. if(!this.dictList) {
  511. return "请选择补贴类型";
  512. }
  513. for(var i = 0, len = this.dictList.length; i < len; i++) {
  514. if(code == this.dictList[i].code) {
  515. expensesName = this.dictList[i].value;
  516. }
  517. }
  518. return expensesName
  519. },
  520. setPatImg: function(str) {
  521. var imgStr = httpRequest.getImgUrl(str);
  522. if (imgStr == "") {
  523. return '../../../images/p-female.png';
  524. } else {
  525. return imgStr;
  526. }
  527. },
  528. lookPhoto: function(data) {
  529. parent.photoLayerIndex = parent.layer.open({
  530. type: 2,
  531. area: ['70%', '600px'],
  532. title: false,
  533. shade: 0.5,
  534. shadeClose: true,
  535. shift: 2,
  536. content: '../html/photo_show.html?serverType=' + data.serverType + '&patientCode=' + httpData.patientCode
  537. })
  538. },
  539. refuse: function() {
  540. var vm = this;
  541. layer.open({
  542. type: 1,
  543. area: ['400px', '300px'],
  544. shade: 0.5,
  545. title: '拒绝签约原因',
  546. shift: 2,
  547. shadeClose: false, //点击遮罩关闭层
  548. 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>',
  549. btn: ['提 交', '取 消'],
  550. yes:function(index, layero) {
  551. if(!refuseReason) {
  552. if(!$("#reason").val()) {
  553. showWarningMessage("请选择或输入拒绝理由!");
  554. layer.close(index);
  555. return false
  556. }
  557. vm.signInfo.refuseReason = $("#reason").val()
  558. } else {
  559. if($("#reason").val()) {
  560. vm.signInfo.refuseReason = refuseReason + "。" + $("#reason").val()
  561. } else {
  562. vm.signInfo.refuseReason = refuseReason
  563. }
  564. }
  565. vm.signInfo.adminTeamCode = 0;
  566. vm.signInfo.teamCode = 0;
  567. vm.signInfo.type = 2;
  568. vm.signInfo.state = 0;
  569. vm.sign();
  570. layer.close(index);
  571. },
  572. success: function(layero){
  573. layero.find('.layui-layer-btn').css('text-align', 'center')
  574. }
  575. });
  576. },
  577. sign: function() {// type:1签约 2拒签
  578. 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))) {
  579. showWarningMessage("请将填写完整签约信息!");
  580. return false;
  581. }
  582. var vm = this,
  583. loadding = layer.load(0, {shade: false});
  584. if (httpData.status == 0) {
  585. var param = vm.signInfo
  586. if(vm.doctorType == 2) {
  587. param.doctor = null
  588. param.doctorName = null
  589. }
  590. if(vm.doctorType == 3) {
  591. param.doctorHealth = null
  592. param.doctorHealthName = null
  593. }
  594. signAPI.sign(vm.signInfo).then(function(res) {
  595. layer.close(loadding)
  596. if(res.status == 200) {
  597. showSuccessMessage(res.msg || "操作成功")
  598. setTimeout(function() {
  599. parent.gobalVue.signCount();
  600. layer.closeAll();
  601. parent.layer.closeAll();
  602. }, 1000)
  603. } else {
  604. showErrorMessage(res.msg);
  605. }
  606. })
  607. } else {
  608. signAPI.signRenew(vm.signInfo).then(function(res) {
  609. layer.close(loadding)
  610. if(res.status == 200) {
  611. showSuccessMessage(res.msg || "操作成功")
  612. setTimeout(function() {
  613. parent.gobalVue.signCount();
  614. layer.closeAll();
  615. parent.layer.closeAll();
  616. }, 1000)
  617. } else {
  618. showErrorMessage(res.msg);
  619. }
  620. })
  621. }
  622. }
  623. }
  624. })