index.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463
  1. // 慢阻肺患者档案-服务档案
  2. var template = ''
  3. $.ajax('../../../component/statistics/CopdServeNum/index.html', {
  4. data: {},
  5. dataType: 'html',
  6. cache: false,
  7. timeout: 60000,
  8. async: false,
  9. error: function (res) {},
  10. success: function (res) {
  11. template = res
  12. }
  13. })
  14. Vue.component('copd-serve-num', {
  15. template: template,
  16. props: [],
  17. data() {
  18. return {
  19. // 当前显示的字段
  20. communityArr: [],
  21. tableFieldList: [],
  22. quotaStrArr: [],
  23. value1: [],
  24. rangeList: [
  25. { name: '按区', code: 'town' },
  26. { name: '按社区', code: 'hospital' }
  27. ],
  28. startTime: '',
  29. endTime: '',
  30. rangeCode: 'town',
  31. quotaStr: '',
  32. range: '',
  33. area: '',
  34. hospital: '',
  35. page: 1,
  36. size: 20,
  37. chooseYear: '',
  38. years: '',
  39. userRole: '',
  40. levelList: [
  41. { level: '4', areaLevel: '2' },
  42. { level: '3', areaLevel: '3' },
  43. { level: '2', areaLevel: '4' }
  44. ], //两种搜索,地区等级对比
  45. areaLevel: '', // 2、市,3、区,4、社区,5、团队
  46. initareaLevel: '',
  47. initlevel: '',
  48. initarea: '',
  49. level: '',
  50. areaTitle: '',
  51. areaCode: null,
  52. communityList: [{ code: '', name: '全部' }],
  53. communityCode: null,
  54. teamList: [{ code: '', name: '全部' }],
  55. teamCode: '',
  56. form: {
  57. range: 'town'
  58. },
  59. userRoleCode: '',
  60. docInfo: JSON.parse(window.localStorage.getItem('docInfo')),
  61. isShowBtn: 0,
  62. isGuGan: false,
  63. areaList: [],
  64. rangeList: [
  65. { name: '按区', code: 'town' },
  66. { name: '按社区', code: 'hospital' }
  67. ],
  68. areaList: [],
  69. tabledata: [],
  70. hospitalOptions: [],
  71. tableHeader: [
  72. { label: '地区', prop: 'name', width: '90' },
  73. { label: '总患者人数', prop: 'patientNum', width: '90' },
  74. { label: '计划服务人数', prop: 'planNum', width: '90' },
  75. { label: '已服务人数', prop: 'serviceNum', width: '90' },
  76. { label: '服务完成度', prop: 'serviceProgress', width: '90' }
  77. ],
  78. radio: '1',
  79. fileList: [],
  80. file: undefined,
  81. isProgressShow: false,
  82. percentage: 0,
  83. success: false,
  84. loading: false,
  85. isOver: false,
  86. status: '',
  87. errList: [],
  88. daLoading: false,
  89. isShow: false,
  90. datatotal: 0,
  91. exportLoading: false
  92. }
  93. },
  94. methods: {
  95. gotoDownLoad() {
  96. const a = document.createElement('a')
  97. a.style.display = 'none'
  98. a.download = '模板.xlsx'
  99. a.href = './template.xls'
  100. a.target = '_blank'
  101. a.click()
  102. },
  103. hospitalList() {
  104. var vm = this
  105. statisticAPI.hospitalList({ queryArea: vm.userRoleCode }).then(function (res) {
  106. if (res.status == 200) {
  107. vm.communityArr = res.detailModelList
  108. }
  109. })
  110. },
  111. //获取省市区 type:区3
  112. getDistrict: function (type, code, name) {
  113. var vm = this,
  114. list = [],
  115. param = ''
  116. if (type == 3) {
  117. list = [{ code: code, name: name }]
  118. param = 'area'
  119. } else if (type == 5) {
  120. list = [{ code: '', name: '全部' }]
  121. param = 'community'
  122. }
  123. var params = {
  124. type: type,
  125. code: code
  126. }
  127. homeAPI.getDistrict(params).then(function (res) {
  128. if (res.status == 200) {
  129. vm[param + 'List'] = list.concat(res.list)
  130. if (type == 3) {
  131. vm[param + 'Code'] = vm[param + 'List'][0].code
  132. vm.selChange(3)
  133. vm.search()
  134. }
  135. } else {
  136. vm.$message.error(res.msg)
  137. }
  138. })
  139. },
  140. // 初始化时间
  141. initTime(vm) {
  142. var now = new Date()
  143. vm.endTime = now.format('yyyy-MM-dd')
  144. var start = now.getFullYear() + '-' + '01-01'
  145. vm.startTime = new Date(start).format('yyyy-MM-dd')
  146. vm.nowyear = vm.chooseYear = now.getFullYear()
  147. // vm.chooseYear = '2022'
  148. vm.nowmonth = now.getMonth() + 1
  149. vm.years = [2025]
  150. // for (i = vm.nowyear; i >= 2013; i--) {
  151. // vm.years.push(i)
  152. // }
  153. },
  154. resetArea() {
  155. if (this.level == 1) {
  156. delete this.areaCode
  157. delete this.hospital
  158. delete this.form.team
  159. } else if (this.level == 2) {
  160. delete this.form.hospital
  161. delete this.form.team
  162. } else {
  163. delete this.form.team
  164. }
  165. },
  166. // 数据范围初始化
  167. initScope(type) {
  168. var vm = this
  169. //获得缓存中缓存的角色权限
  170. var userRole = window.sessionStorage.getItem('selectedRole')
  171. if (!userRole) {
  172. return false
  173. }
  174. vm.userRole = JSON.parse(userRole)
  175. vm.areaTitle = vm.userRole.name
  176. if (vm.isGuGan) {
  177. return
  178. }
  179. if (type == 3) {
  180. this.areaCode = null
  181. this.communityCode = null
  182. if (vm.userRole.code == '350200' || vm.userRole.code == 'jk_350200') {
  183. vm.getDistrict(type, 350200, '厦门市')
  184. } else if (vm.userRole.code.indexOf('jk_') > -1) {
  185. vm.getDistrict(type, vm.userRole.code.substring(3), vm.areaTitle.substring(0, 3))
  186. } else if (vm.userRole.code.length == 6) {
  187. vm.getDistrict(type, vm.userRole.code, vm.areaTitle.substring(0, 3))
  188. } else if (vm.userRole.code.length == 10) {
  189. this.rangeList = [{ name: '按社区', code: 'hospital' }]
  190. this.rangeCode = 'hospital'
  191. this.areaList = [{ name: this.userRole.name.substring(0, 3), code: this.userRole.code.substring(0, 6) }]
  192. this.areaCode = this.userRole.code.substring(0, 6)
  193. this.communityList = [{ name: this.userRole.name, code: this.userRole.code }]
  194. this.communityCode = this.userRole.code
  195. }
  196. } else {
  197. this.communityCode = null
  198. if (this.rangeCode == 'hospital') vm.getDistrict(type, vm.areaCode)
  199. }
  200. return
  201. },
  202. toggleField(fieldName) {
  203. return this.tableFieldList.indexOf(fieldName) !== -1
  204. },
  205. selChange: function (type) {
  206. var vm = this,
  207. name = ''
  208. if (type == 3) {
  209. vm.initSelOption('community')
  210. vm.initSelOption('team')
  211. vm.getCommunityHospital()
  212. } else if (type == 5) {
  213. vm.initSelOption('team')
  214. // vm.teamListByArea();
  215. }
  216. },
  217. initSelOption: function (param) {
  218. var vm = this
  219. vm[param + 'List'] = [{ code: '', name: '全部' }]
  220. if (param == 'team') {
  221. vm[param + 'List'] = [{ id: '', name: '全部' }]
  222. }
  223. vm[param + 'Code'] = vm[param + 'List'][0].code || vm[param + 'List'][0].id
  224. },
  225. getCommunityHospital: function () {
  226. var vm = this,
  227. list = [{ code: '', name: '全部' }],
  228. param = 'community'
  229. homeAPI.getCommunityHospital({ area: vm.areaCode == '350200' ? '' : vm.areaCode }).then(function (res) {
  230. if (res.status == 200) {
  231. vm[param + 'List'] = list.concat(res.data)
  232. vm[param + 'Code'] = vm[param + 'List'][0].code
  233. } else {
  234. vm.$message.error(res.msg)
  235. }
  236. })
  237. },
  238. exportTable() {
  239. var vm = this
  240. vm.exportLoading = true
  241. var params = {
  242. year: this.chooseYear,
  243. range: this.rangeCode,
  244. area: this.areaCode == '350200' ? '' : this.areaCode === null ? '' : this.areaCode
  245. }
  246. if (this.rangeCode == 'hospital') {
  247. params.hospital = this.communityCode
  248. }
  249. statisticAPI.exportServiceProgress(params, '服务人数配置及进度查询.xls').then(function (res) {
  250. vm.exportLoading = false
  251. vm.$message({
  252. message: '导出成功!',
  253. type: 'success'
  254. })
  255. })
  256. },
  257. getHospital(code) {
  258. var vm = this
  259. homeAPI.getCommunityHospital({ area: vm.areaCode == '350200' ? '' : vm.areaCode }).then(function (res) {
  260. vm.communityList = [{ code: '', name: '全部' }]
  261. vm.communityList = vm.communityList.concat(res.data)
  262. })
  263. },
  264. getTeam(code) {
  265. var vm = this
  266. delete this.form.team
  267. var params = {
  268. hospital: code,
  269. area: this.form.area
  270. }
  271. httpRequest.get('statisticsExport/teamList', { data: params }).then(function (res) {
  272. vm.teamOptions = [{ id: '', name: '全部' }]
  273. vm.teamOptions = vm.teamOptions.concat(res.data)
  274. })
  275. },
  276. resetDate() {
  277. if (this.isGuGan) {
  278. this.rangeCode = 'hospital'
  279. this.areaCode = this.docInfo.town
  280. this.communityCode = this.docInfo.hospital
  281. } else {
  282. this.rangeCode = 'town'
  283. this.areaCode = ''
  284. this.communityCode = ''
  285. }
  286. },
  287. eliminateClick() {
  288. var selectedRole = JSON.parse(sessionStorage.getItem('selectedRole'))
  289. if (this.level == 1) {
  290. this.form = {
  291. range: 'town'
  292. }
  293. this.rangeCode = 'town'
  294. } else if (this.level == 2) {
  295. this.form = {
  296. range: 'town',
  297. area: selectedRole.code
  298. }
  299. this.getHospital(selectedRole.code)
  300. } else {
  301. this.form = {
  302. range: 'hospital',
  303. area: selectedRole.code.substring(0, 6),
  304. hospital: selectedRole.code
  305. }
  306. this.getTeam(selectedRole.code)
  307. }
  308. this.yearType = '1'
  309. this.chooseYear = new Date().getFullYear()
  310. this.chooseTime = null
  311. this.$forceUpdate()
  312. },
  313. handleCurrentChange(val) {
  314. this.page = val
  315. this.search()
  316. },
  317. handleSizeChange(val) {
  318. this.size = val
  319. this.search()
  320. },
  321. //上传
  322. toggle(isShow) {
  323. this.isShow = isShow
  324. if (!isShow) {
  325. this.reset()
  326. }
  327. },
  328. reset(type) {
  329. this.percentage = 0
  330. this.success = false
  331. this.isOver = false
  332. this.errList = []
  333. if (type != 1) {
  334. this.loading = false
  335. this.file = undefined
  336. this.month = ''
  337. }
  338. },
  339. search() {
  340. var vm = this
  341. vm.daLoading = true
  342. var params = {
  343. year: this.chooseYear,
  344. range: this.rangeCode,
  345. area: this.areaCode == '350200' ? '' : this.areaCode === null ? '' : this.areaCode
  346. }
  347. if (this.rangeCode == 'hospital') {
  348. params.hospital = this.communityCode
  349. }
  350. statisticAPI.getServiceProgress(params).then(function (res) {
  351. vm.daLoading = false
  352. if (res.status == 200) {
  353. vm.tabledata = res.detailModelList
  354. vm.totalCount = res.totalCount
  355. vm.totalPage = res.totalPage
  356. } else {
  357. vm.$message.error(res.msg)
  358. }
  359. })
  360. },
  361. close(type) {
  362. this.reset(type)
  363. this.isProgressShow = false
  364. if (type != 1) {
  365. this.isShow = false
  366. }
  367. },
  368. beforeUploadPic(file) {
  369. this.file = file
  370. },
  371. check() {
  372. var vm = this
  373. vm.loading = true
  374. if (!vm.file) {
  375. vm.loading = false
  376. vm.$message('请选择文件')
  377. return
  378. }
  379. vm.save()
  380. },
  381. save() {
  382. var vm = this
  383. vm.daLoading = true
  384. var formData = new FormData()
  385. formData.append('file', vm.file)
  386. // vm.initProgress()
  387. httpRequest
  388. .post('doctor/jkCopd/importPlanExcel', {
  389. data: formData,
  390. cache: false, //上传文件无需缓存
  391. processData: false, //用于对data参数进行序列化处理 这里必须false
  392. contentType: false //必须
  393. })
  394. .then(function (res) {
  395. if (res.status == 200) {
  396. vm.search()
  397. vm.daLoading = false
  398. vm.isShow = false
  399. vm.$message({
  400. message: '导入成功!',
  401. type: 'success'
  402. })
  403. } else {
  404. vm.$message.error('导入失败!')
  405. vm.daLoading = false
  406. }
  407. })
  408. .catch(function (e) {
  409. console.error(e)
  410. vm.daLoading = false
  411. })
  412. },
  413. initProgress() {
  414. var vm = this
  415. this.isProgressShow = true
  416. setTimeout(() => {
  417. if (!vm.isOver && vm.percentage != 90) {
  418. vm.percentage += 10
  419. vm.initProgress()
  420. }
  421. }, 1000)
  422. }
  423. },
  424. mounted() {
  425. var vm = this
  426. var userRole = JSON.parse(window.sessionStorage.getItem('selectedRole'))
  427. vm.userRoleCode = userRole.code
  428. this.initTime(this)
  429. if (this.docInfo.expandLevelName) {
  430. this.isGuGan = this.docInfo.expandLevelName.indexOf('慢病骨干') > -1
  431. }
  432. this.initScope(3)
  433. if (this.isGuGan) {
  434. // 如何是慢病骨干 则只能选社区,并且限定死社区
  435. this.rangeList = [{ name: '按社区', code: 'hospital' }]
  436. this.rangeCode = 'hospital'
  437. this.areaList = [{ name: this.docInfo.hospitalName.substring(0, 3), code: this.docInfo.town }]
  438. this.areaCode = this.docInfo.town
  439. this.communityList = [{ name: this.docInfo.hospitalName, code: this.docInfo.hospital }]
  440. this.communityCode = this.docInfo.hospital
  441. // vm.receivingHospitalList = [{code:this.docInfo.hospital,name:this.docInfo.hospitalName}]
  442. // this.hospital = this.docInfo.hospital
  443. }
  444. this.search()
  445. EventBus.$on('copd-record-filter-change', function (event) {
  446. vm.quotaStrArr = event
  447. })
  448. },
  449. destroyed() {
  450. EventBus.$off('copd-record-filter-change')
  451. }
  452. })