index.js 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497
  1. // 慢阻肺患者档案-服务档案
  2. var template = ''
  3. $.ajax('../../../component/statistics/CopdRecordSearch/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-record-search', {
  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. sex: '',
  38. firstVisitType: '',
  39. hasLung: '',
  40. hasCt: '',
  41. hasx: '',
  42. hasBloodGas: '',
  43. hasSmoke: '',
  44. hasDrink: '',
  45. diseaseConversion: '',
  46. age: '',
  47. dataList: [],
  48. daLoading: false,
  49. datatotal: 0,
  50. chooseYear: '',
  51. firstVisitArea: '',
  52. firstVisitOrgLevel: '',
  53. end: '',
  54. start: '',
  55. nowyear: '',
  56. nowmonth: '',
  57. years: [],
  58. radio: '1',
  59. dicName: ['jkcopd_disease_conversion', 'jkcopd_age', 'jkcopd_smoke', 'jkcopd_drink', 'jkcopd_firstVisitType', 'jkcopd_first_area', 'jkcopd_first_org_level'],
  60. conversionArr: [],
  61. ageArr: [],
  62. firstVisitType: [],
  63. areaArr: [],
  64. smokeArr: [],
  65. drinkArr: [],
  66. orGlevelArr: [],
  67. userRole: '',
  68. levelList: [
  69. { level: '4', areaLevel: '2' },
  70. { level: '3', areaLevel: '3' },
  71. { level: '2', areaLevel: '4' }
  72. ], //两种搜索,地区等级对比
  73. areaLevel: '', // 2、市,3、区,4、社区,5、团队
  74. initareaLevel: '',
  75. initlevel: '',
  76. initarea: '',
  77. level: '',
  78. areaTitle: '',
  79. areaCode: null,
  80. communityList: [{ code: '', name: '全部' }],
  81. communityCode: null,
  82. teamList: [{ code: '', name: '全部' }],
  83. teamCode: '',
  84. userRoleCode: '',
  85. docInfo: JSON.parse(window.localStorage.getItem('docInfo')),
  86. isGuGan: false,
  87. areaList: [],
  88. tabledata: [],
  89. tableHeader: []
  90. }
  91. },
  92. watch: {
  93. value1(va) {
  94. if (this.radio == '2') {
  95. this.startTime = va[0]
  96. this.endTime = va[1]
  97. }
  98. },
  99. rangeCode: function (val) {
  100. var vm = this
  101. // if (vm.initlevel != 2) {
  102. // vm.communityCode = ''
  103. // }
  104. // vm.teamCode = ''
  105. }
  106. // areaCode: function (val) {
  107. // var vm = this
  108. // vm.selChange(3)
  109. // },
  110. // communityCode: function (val) {
  111. // var vm = this
  112. // vm.selChange(5)
  113. // }
  114. },
  115. methods: {
  116. hospitalList() {
  117. var vm = this
  118. statisticAPI.hospitalList({ queryArea: vm.userRoleCode }).then(function (res) {
  119. if (res.status == 200) {
  120. vm.communityArr = res.detailModelList
  121. }
  122. })
  123. },
  124. //字典
  125. getDictByDictName(value) {
  126. var vm = this
  127. statisticAPI.getDictByDictName({ name: value }).then(function (res) {
  128. if (value == 'jkcopd_age') {
  129. vm.ageArr = res.list
  130. } else if (value == 'jkcopd_smoke') {
  131. vm.smokeArr = res.list
  132. } else if (value == 'jkcopd_drink') {
  133. vm.drinkArr = res.list
  134. } else if (value == 'jkcopd_first_area') {
  135. vm.areaArr = res.list
  136. } else if (value == 'jkcopd_disease_conversion') {
  137. vm.conversionArr = res.list
  138. } else if (value == 'jkcopd_firstVisitType') {
  139. vm.firstVisitTypeArr = res.list
  140. } else if (value == 'jkcopd_first_org_level') {
  141. vm.orGlevelArr = res.list
  142. }
  143. })
  144. },
  145. //获取省市区 type:区3
  146. getDistrict: function (type, code, name) {
  147. var vm = this,
  148. list = [],
  149. param = ''
  150. if (type == 3) {
  151. list = [{ code: code, name: name }]
  152. param = 'area'
  153. } else if (type == 5) {
  154. list = [{ code: '', name: '全部' }]
  155. param = 'community'
  156. }
  157. var params = {
  158. type: type,
  159. code: code
  160. }
  161. homeAPI.getDistrict(params).then(function (res) {
  162. if (res.status == 200) {
  163. vm[param + 'List'] = list.concat(res.list)
  164. // vm[param + 'Code'] = vm[param + 'List'][0].code
  165. } else {
  166. vm.$message.error(res.msg)
  167. }
  168. })
  169. },
  170. // 初始化时间
  171. initTime(vm) {
  172. var now = new Date()
  173. vm.endTime = now.format('yyyy-MM-dd')
  174. var start = now.getFullYear() + '-' + '01-01'
  175. vm.startTime = new Date(start).format('yyyy-MM-dd')
  176. vm.nowyear = vm.chooseYear = now.getFullYear()
  177. vm.chooseYear = '2022'
  178. vm.nowmonth = now.getMonth() + 1
  179. vm.years = []
  180. for (i = vm.nowyear; i >= 2013; i--) {
  181. vm.years.push(i)
  182. }
  183. },
  184. // 数据范围初始化
  185. initScope(type) {
  186. var vm = this
  187. //获得缓存中缓存的角色权限
  188. var userRole = window.sessionStorage.getItem('selectedRole')
  189. if (!userRole) {
  190. return false
  191. }
  192. vm.userRole = JSON.parse(userRole)
  193. vm.areaTitle = vm.userRole.name
  194. if (vm.isGuGan) {
  195. return
  196. }
  197. if (type == 3) {
  198. this.areaCode = null
  199. this.communityCode = null
  200. if (vm.userRole.code == '350200' || vm.userRole.code == 'jk_350200') {
  201. vm.getDistrict(type, 350200, '厦门市')
  202. } else if (vm.userRole.code.indexOf('jk_') > -1) {
  203. vm.getDistrict(type, vm.userRole.code.substring(3), vm.areaTitle.substring(0, 3))
  204. } else if (vm.userRole.code.length == 6) {
  205. vm.getDistrict(type, vm.userRole.code, vm.areaTitle.substring(0, 3))
  206. } else if (vm.userRole.code.length == 10) {
  207. this.rangeList = [{ name: '按社区', code: 'hospital' }]
  208. this.rangeCode = 'hospital'
  209. this.areaList = [{ name: this.userRole.name.substring(0, 3), code: this.userRole.code.substring(0, 6) }]
  210. this.areaCode = this.userRole.code.substring(0, 6)
  211. this.communityList = [{ name: this.userRole.name, code: this.userRole.code }]
  212. this.communityCode = this.userRole.code
  213. }
  214. } else {
  215. this.communityCode = null
  216. if (this.rangeCode == 'hospital') vm.getDistrict(type, vm.areaCode)
  217. }
  218. return
  219. //获得缓存中缓存的角色权限
  220. var userRole = window.sessionStorage.getItem('selectedRole')
  221. if (!userRole) {
  222. return false
  223. }
  224. vm.userRole = JSON.parse(userRole)
  225. //level:2、市,3、区,4、社区,5、团队
  226. vm.initareaLevel = vm.areaLevel = vm.userRole.code == 'jk_350200' ? 2 : vm.userRole.code.length == 9 ? 3 : 4
  227. vm.initlevel = vm.level = vm.userRole.code == 'jk_350200' ? 4 : vm.userRole.code.length == 9 ? 3 : 2
  228. // vm.lowLevel = vm.initlowLevel = vm.userRole.code == '350200' ? 3 : vm.userRole.code.length == 6 ? 2 : 1;
  229. vm.initarea = vm.area = vm.userRole.code
  230. vm.areaTitle = vm.userRole.name
  231. if (vm.initlevel == 4) {
  232. //市获取区
  233. vm.getDistrict(3, vm.initarea.substring(3), vm.areaTitle.substr(0, 3))
  234. vm.rangeCode = vm.rangeList[0].code
  235. } else if (vm.initlevel == 3) {
  236. //区获取社区
  237. vm.areaList = [{ code: vm.initarea, name: vm.areaTitle }]
  238. vm.areaCode = vm.initarea
  239. vm.rangeCode = vm.rangeList[0].code
  240. } else if (vm.initlevel == 2) {
  241. //社区获取团队
  242. vm.communityList = [{ code: vm.initarea, name: vm.areaTitle }]
  243. vm.communityCode = vm.initarea
  244. vm.rangeList.shift()
  245. vm.rangeCode = vm.rangeList[0].code
  246. }
  247. vm.range = vm.rangeCode
  248. },
  249. toggleField(fieldName) {
  250. return this.tableFieldList.indexOf(fieldName) !== -1
  251. },
  252. manageInfo() {
  253. var vm = this
  254. this.daLoading = true
  255. var params = {
  256. startTime: this.radio == 1 ? this.chooseYear + '-01-01' : this.startTime,
  257. endTime: this.radio == 1 ? this.chooseYear + '-12-31' : this.endTime,
  258. quotaStr: this.quotaStrArr.join(','),
  259. range: this.rangeCode,
  260. area: this.areaCode == '350200' ? '' : this.areaCode,
  261. page: 1,
  262. size: 50,
  263. sex: this.sex,
  264. firstVisitType: this.firstVisitType,
  265. hasLung: this.hasLung,
  266. hasCt: this.hasCt,
  267. hasx: this.hasx,
  268. hasBloodGas: this.hasBloodGas,
  269. hasSmoke: this.hasSmoke,
  270. hasDrink: this.hasDrink,
  271. diseaseConversion: this.diseaseConversion,
  272. age: this.age
  273. }
  274. if (this.rangeCode == 'hospital') {
  275. params.hospital = this.communityCode
  276. }
  277. statisticAPI
  278. .manageInfo(params)
  279. .then(function (res) {
  280. if (res.status == 200) {
  281. vm.tabledata = res.data.data
  282. vm.datatotal = res.data.total
  283. if (vm.tabledata.length) {
  284. vm.tableHeader = []
  285. if (vm.rangeCode == 'town') {
  286. vm.tableHeader.push({ prop: 'townName', label: '地区', width: '100', align: 'center' })
  287. } else {
  288. vm.tableHeader.push({ prop: 'hospitalName', label: '社区', width: '180', align: 'center' })
  289. }
  290. _.each(vm.tabledata[0], function (item, index) {
  291. if (
  292. index != 'town' &&
  293. index != 'townName' &&
  294. index != 'hospital' &&
  295. index != 'hospitalName' &&
  296. index != 'area' &&
  297. index != 'areaName' &&
  298. index != 'code' &&
  299. index != 'name'
  300. )
  301. vm.tableHeader.push({ prop: index, label: index, align: 'right', headerAlign: 'center' })
  302. })
  303. }
  304. } else {
  305. vm.$message.error(res.msg)
  306. }
  307. vm.daLoading = false
  308. })
  309. .catch(function (err) {
  310. vm.daLoading = false
  311. })
  312. },
  313. bubbleSort(array) {
  314. for (var i = 0; i < array.length - 1; i++) {
  315. for (var j = 0; j < array.length - i - 1; j++) {
  316. // 1.对每一个值和它的下一个值进行比较
  317. if (array[j] > array[j + 1]) {
  318. // 如果第一个值更多,则将其赋予自定义计数值 count
  319. var count = array[j]
  320. // 反复交换
  321. array[j] = array[j + 1]
  322. array[j + 1] = count
  323. }
  324. }
  325. }
  326. return array
  327. },
  328. search() {
  329. if (this.rangeCode == 'town' && this.areaCode == null) {
  330. this.$message.warning('请选择地区')
  331. return
  332. }
  333. if (this.rangeCode == 'hospital' && this.communityCode == null) {
  334. this.$message.warning('请选择社区')
  335. return
  336. }
  337. if (this.quotaStrArr.length) {
  338. this.manageInfo()
  339. } else {
  340. this.$message({
  341. message: '请选择查询指标!',
  342. type: 'warning'
  343. })
  344. return false
  345. }
  346. },
  347. selChange: function (type) {
  348. var vm = this,
  349. name = ''
  350. if (type == 3) {
  351. vm.initSelOption('community')
  352. vm.initSelOption('team')
  353. vm.getCommunityHospital()
  354. } else if (type == 5) {
  355. vm.initSelOption('team')
  356. // vm.teamListByArea();
  357. }
  358. },
  359. initSelOption: function (param) {
  360. var vm = this
  361. vm[param + 'List'] = [{ code: '', name: '全部' }]
  362. if (param == 'team') {
  363. vm[param + 'List'] = [{ id: '', name: '全部' }]
  364. }
  365. vm[param + 'Code'] = vm[param + 'List'][0].code || vm[param + 'List'][0].id
  366. },
  367. getCommunityHospital: function () {
  368. var vm = this,
  369. list = [{ code: '', name: '全部' }],
  370. param = 'community'
  371. homeAPI.getCommunityHospital({ area: vm.areaCode == '350200' ? '' : vm.areaCode }).then(function (res) {
  372. if (res.status == 200) {
  373. vm[param + 'List'] = list.concat(res.data)
  374. vm[param + 'Code'] = vm[param + 'List'][0].code
  375. } else {
  376. vm.$message.error(res.msg)
  377. }
  378. })
  379. },
  380. exportTable() {
  381. var vm = this
  382. vm.daLoading = true
  383. // var quotaStrs= this.bubbleSort(this.quotaStrArr)
  384. this.quotaStrArr.sort(function (a, b) {
  385. return a - b
  386. })
  387. var params = {
  388. startTime: this.radio == 1 ? this.chooseYear + '-01-01' : this.startTime,
  389. endTime: this.radio == 1 ? this.chooseYear + '-12-31' : this.endTime,
  390. quotaStr: this.quotaStrArr.join(','),
  391. range: this.rangeCode,
  392. area: this.areaCode == '350200' ? '' : this.areaCode,
  393. hospital: this.communityCode,
  394. page: 1,
  395. size: 50,
  396. sex: this.sex,
  397. firstVisitType: this.firstVisitType,
  398. hasLung: this.hasLung,
  399. hasCt: this.hasCt,
  400. hasx: this.hasx,
  401. hasBloodGas: this.hasBloodGas,
  402. hasSmoke: this.hasSmoke,
  403. hasDrink: this.hasDrink,
  404. diseaseConversion: this.diseaseConversion,
  405. age: this.age
  406. }
  407. statisticAPI.exportManageInfo(params, '管理情况.xls').then(function (res) {
  408. vm.daLoading = false
  409. vm.$message({
  410. message: '导出成功!',
  411. type: 'success'
  412. })
  413. })
  414. },
  415. resetDate() {
  416. if (this.isGuGan) {
  417. this.rangeCode = 'hospital'
  418. this.areaCode = this.docInfo.town
  419. this.communityCode = this.docInfo.hospital
  420. } else {
  421. this.rangeCode = 'town'
  422. this.areaCode = ''
  423. this.communityCode = ''
  424. }
  425. this.startTime = ''
  426. this.endTime = ''
  427. this.quotaStr = ''
  428. this.range = ''
  429. this.area = ''
  430. this.hospital = ''
  431. this.sex = ''
  432. this.firstVisitType = ''
  433. this.firstVisitArea = ''
  434. this.firstVisitOrgLevel = ''
  435. this.hasLung = ''
  436. this.hasCt = ''
  437. this.hasx = ''
  438. this.hasBloodGas = ''
  439. this.hasSmoke = ''
  440. this.hasDrink = ''
  441. this.diseaseConversion = ''
  442. this.age = ''
  443. },
  444. handleCurrentChange(val) {
  445. this.page = val
  446. this.search()
  447. },
  448. handleSizeChange(val) {
  449. this.size = val
  450. this.search()
  451. }
  452. },
  453. mounted() {
  454. var vm = this
  455. var userRole = JSON.parse(window.sessionStorage.getItem('selectedRole'))
  456. vm.userRoleCode = userRole.code
  457. this.initTime(this)
  458. if (this.docInfo.expandLevelName) {
  459. this.isGuGan = this.docInfo.expandLevelName.indexOf('慢病骨干') > -1
  460. }
  461. this.initScope(3)
  462. if (this.isGuGan) {
  463. // 如何是慢病骨干 则只能选社区,并且限定死社区
  464. this.rangeList = [{ name: '按社区', code: 'hospital' }]
  465. this.rangeCode = 'hospital'
  466. this.areaList = [{ name: this.docInfo.hospitalName.substring(0, 3), code: this.docInfo.town }]
  467. this.areaCode = this.docInfo.town
  468. this.communityList = [{ name: this.docInfo.hospitalName, code: this.docInfo.hospital }]
  469. this.communityCode = this.docInfo.hospital
  470. // vm.receivingHospitalList = [{code:this.docInfo.hospital,name:this.docInfo.hospitalName}]
  471. // this.hospital = this.docInfo.hospital
  472. }
  473. EventBus.$on('copd-record-filter-change', function (event) {
  474. vm.quotaStrArr = event
  475. })
  476. this.dicName.forEach(function (item) {
  477. vm.getDictByDictName(item)
  478. })
  479. // this.manageInfo()
  480. },
  481. destroyed() {
  482. EventBus.$off('copd-record-filter-change')
  483. }
  484. })