sign_handle.js 17 KB

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