followup_newplan.js 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430
  1. var httpData=GetRequest();
  2. var docInfo = JSON.parse(window.localStorage.getItem('docInfo'));
  3. var loginDoctor = docInfo
  4. var clientHeight = Math.max(document.body.scrollHeight,document.documentElement.scrollHeight);
  5. new Vue({
  6. el:"#app",
  7. data:{
  8. clientHeight: clientHeight,
  9. planId: httpData['planId'],
  10. planDetaiId: httpData['planDetaiId'],
  11. patient: httpData['patient'],
  12. itemType:"1", //随访计划
  13. followUpItem:{
  14. patientName: '',
  15. planList:[{date:new Date().format("yyyy-MM-dd HH:mm")+":00",type:"22",doctor:loginDoctor.code,followupClass:'',type1:'1'}], //计划列表
  16. },
  17. rules: {
  18. followupPlanDate: [
  19. { required: true, message: '请选择随访时间', trigger: 'change' },
  20. ],
  21. },
  22. item_1:{patientName: '',planList:[{date:"",type:"22",doctor:loginDoctor.code,type1:'1'}]}, //随访计划列表
  23. planItem:{date:"",type:"22",doctor:loginDoctor.code,type1:'1'}, //随访计划列表项
  24. item_2:{
  25. "patientName": '',
  26. "date":"",
  27. "followupType":"22",
  28. "followupClass":"",
  29. "followupManagerStatus":"",
  30. "plandate":"",
  31. "prescriptioncode":""
  32. },
  33. item_3:{
  34. "patientName": '',
  35. "followupDate":"",
  36. "followupPlanDate":"",
  37. "followupType":"22",
  38. "followupClass":"",
  39. },
  40. patientName: '',
  41. patientInfo:{},
  42. loginDoctor: loginDoctor,
  43. doctorList:[],
  44. sfPatientList:{},
  45. followupManagerStatusList:[], //临时随访状态
  46. toSelectsfpatient:false,
  47. },
  48. mounted: function() {
  49. this.doctorList.push(loginDoctor)
  50. this.getDictByDictName("FOLLOWUP_MANAGER_STATUS","followupManagerStatusList")
  51. if(this.patient){
  52. this.getPatientInfo()
  53. this.getDoctorList()
  54. }
  55. $("body").click(function () {
  56. $("#div_items").css('display', 'none');
  57. });
  58. $(".div_item").hover(function () {
  59. $(this).css('background-color', '#f8f8f8')
  60. }, function () {
  61. $(this).css('background-color', 'white')
  62. });
  63. },
  64. methods: {
  65. //计划类型改变
  66. changePlanType: function(){
  67. this.doctorList=[]
  68. if(this.itemType=="1"){
  69. this.doctorList.push(loginDoctor)
  70. }
  71. this.followUpItem=JSON.parse(JSON.stringify(this["item_"+this.itemType]))
  72. if(this.itemType=="1"){
  73. this.followUpItem.planList[0].date=new Date().format("yyyy-MM-dd HH:mm")+":00"
  74. }else if(this.itemType=="2"){
  75. this.followUpItem.date=new Date().format("yyyy-MM-dd HH:mm")+":00"
  76. this.followUpItem.type='2'
  77. }else if(this.itemType=="3"){
  78. this.followUpItem.followupDate=new Date().format("yyyy-MM-dd HH:mm")+":00"
  79. }
  80. // this.patientInfo = {}
  81. setTimeout(()=>{
  82. this.$refs.form.clearValidate()
  83. },100)
  84. },
  85. fsClassChange: function(){
  86. // this.patientInfo = {}
  87. this.followUpItem.patientName=""
  88. setTimeout(()=>{
  89. this.$refs.form.clearValidate()
  90. },100)
  91. },
  92. // 选择随访居民
  93. selectsfPatient: function(){
  94. var vm=this
  95. if(this.followUpItem.patientName.length>=15){
  96. $("#div_items").css('display', 'block');
  97. vm.getsfPatient()
  98. }else{
  99. $("#div_items").css('display', 'none');
  100. }
  101. },
  102. // 获取访视居民列表
  103. getsfPatient: function(){
  104. var vm=this
  105. var params={idcard:this.followUpItem.patientName}
  106. serviceVisitApi.getPatientJWInfo(params).then(res=>{
  107. if(res.status==200){
  108. if(!res.data.data){
  109. vm.sfPatientList={}
  110. }else{
  111. vm.sfPatientList=res.data.data
  112. }
  113. }else{
  114. this.$message.error(res.data.msg)
  115. }
  116. })
  117. },
  118. // 选择访视居民选中单个下拉框
  119. clicksingleItem: function(sitem){
  120. var vm=this
  121. if(!sitem.ssc&&!sitem.patient){
  122. const h = this.$createElement;
  123. this.$msgbox({
  124. title: '系统提示',
  125. message: h('p', { style: 'text-align: center;padding-top:20px;padding-bottom:40px;color:#333;' }, '此居民暂无社保卡号,不支持为其创建入户访视计划。请居民注册厦门i健康账号后,医生方可创建入户访视计划'),
  126. showCancelButton: false,
  127. confirmButtonText: '确定',
  128. confirmButtonClass:"c-btn-plain c-btn-12b7f5-plain c-btn-w68",
  129. cancelButtonClass:"c-btn-plain c-btn-d7dce6-plain c-btn-w68"
  130. }).then(action => {
  131. })
  132. return
  133. }
  134. if(!sitem.patient){
  135. const h = this.$createElement;
  136. this.$msgbox({
  137. title: '系统提示',
  138. message: h('p', { style: 'text-align: center;padding-top:20px;padding-bottom:40px;color:#333;' }, '此居民暂无厦门i健康,若要继续为此居民进行入户访视,系统将为此居民自动创建一个厦门i健康账号,请问您是否确认继续此操作?'),
  139. showCancelButton: true,
  140. confirmButtonText: '确定',
  141. cancelButtonText: '取消',
  142. confirmButtonClass:"c-btn-plain c-btn-12b7f5-plain c-btn-w68",
  143. cancelButtonClass:"c-btn-plain c-btn-d7dce6-plain c-btn-w68"
  144. }).then(action => {
  145. var obj={}
  146. obj.status=1
  147. obj.isCertified=0
  148. obj.address=sitem.homeAddress
  149. obj.name=sitem.sickName
  150. obj.sex=sitem.sickSex
  151. obj.idcard=sitem.idCard
  152. obj.birthday=sitem.birthday
  153. obj.ssc=sitem.ssc
  154. obj.age=sitem.age
  155. var data={
  156. jsonData:JSON.stringify(obj)
  157. }
  158. serviceVisitApi.create(data).then(res=>{
  159. if(res.status==200){
  160. $("#div_items").css('display', 'block');
  161. vm.getsfPatient()
  162. vm.toSelectsfpatient=false
  163. }else{
  164. this.$message.error(res.data.msg)
  165. }
  166. })
  167. }).catch(() => {
  168. });
  169. }else{
  170. vm.patientInfo={}
  171. vm.followUpItem.patientName=sitem.sickName
  172. vm.toSelectsfpatient=true
  173. vm.patientInfo.code=sitem.patient
  174. vm.patientInfo.name=sitem.sickName
  175. vm.patientInfo.idcard=sitem.idCard
  176. vm.patientInfo.age=sitem.age+"岁"
  177. vm.patientInfo.idcardEncrypt=sitem.idcardEncrypt
  178. vm.patientInfo.mobile=sitem.mobile
  179. vm.patientInfo.sex=sitem.sickSex
  180. }
  181. },
  182. // 获取居民对应医生列表--随访
  183. getDoctorList: function() {
  184. var params = {
  185. code: this.patient
  186. }
  187. followUpAPI.sign_doctors(params).then(function(msg){
  188. if (msg.status === 200) {
  189. var hasThisDoctor=_.find(msg.list,{code:loginDoctor.code})
  190. if(hasThisDoctor>-1){ //列表里有当前医生
  191. this.doctorList=msg.list
  192. }else{
  193. this.doctorList.push(loginDoctor)
  194. }
  195. }
  196. })
  197. },
  198. addListItem: function(){
  199. var listItem=JSON.parse(JSON.stringify(this.planItem))
  200. listItem.date=new Date().format("yyyy-MM-dd HH:mm")+":00"
  201. this.followUpItem.planList.push(listItem)
  202. },
  203. removeListItem: function(index){
  204. const h = this.$createElement;
  205. this.$msgbox({
  206. title: '删除提示',
  207. message: h('p', { style: 'text-align: center;padding-top:20px;padding-bottom:40px;color:#333;' }, '请问您是否确认删除本次计划?'),
  208. showCancelButton: true,
  209. confirmButtonText: '确定',
  210. cancelButtonText: '取消',
  211. confirmButtonClass:"c-btn-plain c-btn-12b7f5-plain c-btn-w68",
  212. cancelButtonClass:"c-btn-plain c-btn-d7dce6-plain c-btn-w68"
  213. }).then(action => {
  214. this.followUpItem.planList.splice(index,1)
  215. }).catch(() => {
  216. });
  217. },
  218. //创建随访计划
  219. addFollowupPlan: function(){
  220. var vm = this
  221. this.$refs["form"].validate((valid) => {
  222. if (valid) {
  223. var ispass=_.every(this.followUpItem.planList,(item,index)=>{
  224. var datepass=true
  225. var typepass=item.type!="3"||this.patientInfo.mobile
  226. if(typepass){
  227. datepass=index==0||(index>0 && this.followUpItem.planList[index-1].date<item.date)//前一次随访时间小于后一次随访时间
  228. if(!datepass){
  229. this.$message.warning("第"+index+"次随访时间小于第"+(index+1)+"次随访时间")
  230. }
  231. }else{
  232. this.$message.warning("该居民无联系方式,不可进行电话随访")
  233. }
  234. return typepass && datepass
  235. })
  236. if(!ispass){
  237. return false
  238. }
  239. var params={
  240. patient: this.patientInfo.code,data: JSON.stringify(this.followUpItem.planList)
  241. }
  242. // this.$loading('创建随访计划...')
  243. var loading = layer.load(0, {shade: false})
  244. followUpAPI.addFollowupPlan(params).then(res=>{
  245. // this.$loading.close()
  246. layer.close(loading)
  247. if(res.status == 200){
  248. layer.msg(res.msg, {
  249. icon: 1
  250. })
  251. if(res.data&&res.data.length>0){
  252. var relationCode = res.data[0].id
  253. window.parent.closeFollowUpLayer(vm.planDetaiId, relationCode)
  254. }
  255. }else{
  256. layer.msg(res.msg, {
  257. icon: 5
  258. })
  259. }
  260. })
  261. } else {
  262. console.log('error submit!!');
  263. return false;
  264. }
  265. });
  266. },
  267. //创建临时随访
  268. addFollowup: function(){
  269. var vm = this
  270. this.$refs["form"].validate((valid) => {
  271. if (valid) {
  272. if(this.followUpItem.plandate){
  273. if(this.followUpItem.plandate<=this.followUpItem.date){
  274. this.$message.warning("下次随访时间不可早于随访时间")
  275. return false
  276. }
  277. }
  278. if(this.followUpItem.followupType=="3"&&!this.patientInfo.mobile){
  279. this.$message.warning("该居民无联系方式,不可进行电话随访")
  280. return false
  281. }
  282. var params=JSON.parse(JSON.stringify(this.followUpItem))
  283. params.patient=this.patientInfo.code
  284. // this.$loading('创建临时随访...')
  285. var loading = layer.load(0, {shade: false})
  286. followUpAPI.addFollowup(params).then(res=>{
  287. // this.$loading.close()
  288. layer.close(loading)
  289. if(res.status == 200){
  290. layer.msg(res.msg, {
  291. icon: 1
  292. })
  293. if(res.data&&res.data.length>0){
  294. var relationCode = res.data[0].id
  295. window.parent.closeFollowUpLayer(vm.planDetaiId, relationCode)
  296. }
  297. }else{
  298. layer.msg(res.msg, {
  299. icon: 5
  300. })
  301. }
  302. })
  303. } else {
  304. console.log('error submit!!');
  305. return false;
  306. }
  307. });
  308. },
  309. //创建入户访视
  310. saveFollowup: function(){
  311. var vm = this
  312. if(!this.patientInfo.code){ //未选中居民
  313. this.followUpItem.patientName=""
  314. }
  315. if(this.followUpItem.followupType=="3"&&!this.patientInfo.mobile){
  316. this.$message.warning("该居民无联系方式,不可进行电话访视")
  317. return false
  318. }
  319. this.$refs["form"].validate((valid) => {
  320. if (valid) {
  321. var params={
  322. followupDate: this.followUpItem.followupDate,
  323. followupPlanDate: this.followUpItem.followupDate,
  324. followupType: this.followUpItem.followupType,
  325. followupClass: this.followUpItem.followupClass,
  326. doctorCode: loginDoctor.code,
  327. doctorName: loginDoctor.name,
  328. orgCode: loginDoctor.hospital,
  329. orgName: loginDoctor.hospitalName,
  330. patientCode: this.patientInfo.code,
  331. patientName: this.patientInfo.name,
  332. idcard: this.patientInfo.idcard,
  333. age:this.patientInfo.age,
  334. idcardEncrypt:this.patientInfo.idcardEncrypt,
  335. mobile:this.patientInfo.mobile,
  336. sex:this.patientInfo.sex,
  337. dataFrom: "2",
  338. status: "2",
  339. createTime: new Date().format("yyyy-MM-dd HH:mm:ss"),
  340. creater: loginDoctor.code,
  341. type:'3' //区分随访计划1、新增随访2、临时随访3、入户随访
  342. }
  343. // this.$loading('创建入户访视...')
  344. var loading = layer.load(0, {shade: false})
  345. followUpAPI.saveFollowup({jsonFollowup:JSON.stringify(params)}).then(res=>{
  346. // this.$loading.close()
  347. layer.close(loading)
  348. if(res.status == 200){
  349. layer.msg(res.msg, {
  350. icon: 1
  351. })
  352. if(res.data&&res.data.length>0){
  353. var relationCode = res.data[0].id
  354. window.parent.closeFollowUpLayer(vm.planDetaiId, relationCode)
  355. }
  356. }else{
  357. layer.msg(res.msg, {
  358. icon: 5
  359. })
  360. }
  361. })
  362. } else {
  363. console.log('error submit!!');
  364. return false;
  365. }
  366. });
  367. },
  368. getDictByDictName: function(name,itemName) {
  369. var vm = this
  370. var params = {
  371. name: name
  372. }
  373. signAPI.getDictByDictName(params).then(function(res){
  374. var result = res.list
  375. if (res.status === 200) {
  376. vm[itemName] = result
  377. }
  378. })
  379. },
  380. // 选择居民信息或者获取居民信息
  381. // getPatientInfo(obj) {
  382. // this.patientInfo = obj
  383. // this.$set(this.followUpItem,"patientName",obj.name)
  384. // if(this.itemType=="1"){
  385. // this.getDoctorList()
  386. // }
  387. // },
  388. // 选择居民信息或者获取居民信息
  389. getPatientInfo: function() {
  390. var vm = this
  391. var params = {
  392. patient: vm.patient
  393. }
  394. followUpAPI.getPatientInfo(params).then(function(res){
  395. if(res.status == 200){
  396. vm.patientInfo = res.data?res.data:{}
  397. vm.followUpItem['patientName'] = vm.patientInfo.name
  398. vm.item_1['patientName'] = vm.patientInfo.name
  399. vm.item_2['patientName'] = vm.patientInfo.name
  400. vm.item_3['patientName'] = vm.patientInfo.name
  401. vm.patientName = vm.patientInfo.name
  402. }
  403. })
  404. },
  405. //打开居民列表弹框
  406. showPatientList: function(){
  407. if(this.itemType=="3"){
  408. var ispass=true
  409. this.$refs["form"].validateField(["followupClass","followupDate"],(valid)=>{
  410. if(valid){ //有值说明验证未通过
  411. ispass=false
  412. }
  413. })
  414. if(!ispass){
  415. return false
  416. }
  417. }
  418. this.$root.bus.$emit('selectPatientAddFUPlan',{type:this.itemType,patientInfo:this.patientInfo,followUpItem:this.followUpItem})
  419. },
  420. //关闭弹框
  421. closeMask: function(){
  422. this.$root.bus.$emit('closeMask')
  423. },
  424. back: function(){
  425. this.$emit("removeTab","newPlan")
  426. },
  427. }
  428. })