sign_handle.js 17 KB

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