index.js 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489
  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. }
  207. } else {
  208. this.communityCode = null
  209. if (this.rangeCode == 'hospital') vm.getDistrict(type, vm.areaCode)
  210. }
  211. return
  212. //获得缓存中缓存的角色权限
  213. var userRole = window.sessionStorage.getItem('selectedRole')
  214. if (!userRole) {
  215. return false
  216. }
  217. vm.userRole = JSON.parse(userRole)
  218. //level:2、市,3、区,4、社区,5、团队
  219. vm.initareaLevel = vm.areaLevel = vm.userRole.code == 'jk_350200' ? 2 : vm.userRole.code.length == 9 ? 3 : 4
  220. vm.initlevel = vm.level = vm.userRole.code == 'jk_350200' ? 4 : vm.userRole.code.length == 9 ? 3 : 2
  221. // vm.lowLevel = vm.initlowLevel = vm.userRole.code == '350200' ? 3 : vm.userRole.code.length == 6 ? 2 : 1;
  222. vm.initarea = vm.area = vm.userRole.code
  223. vm.areaTitle = vm.userRole.name
  224. if (vm.initlevel == 4) {
  225. //市获取区
  226. vm.getDistrict(3, vm.initarea.substring(3), vm.areaTitle.substr(0, 3))
  227. vm.rangeCode = vm.rangeList[0].code
  228. } else if (vm.initlevel == 3) {
  229. //区获取社区
  230. vm.areaList = [{ code: vm.initarea, name: vm.areaTitle }]
  231. vm.areaCode = vm.initarea
  232. vm.rangeCode = vm.rangeList[0].code
  233. } else if (vm.initlevel == 2) {
  234. //社区获取团队
  235. vm.communityList = [{ code: vm.initarea, name: vm.areaTitle }]
  236. vm.communityCode = vm.initarea
  237. vm.rangeList.shift()
  238. vm.rangeCode = vm.rangeList[0].code
  239. }
  240. vm.range = vm.rangeCode
  241. },
  242. toggleField(fieldName) {
  243. return this.tableFieldList.indexOf(fieldName) !== -1
  244. },
  245. manageInfo() {
  246. var vm = this
  247. this.daLoading = true
  248. var params = {
  249. startTime: this.radio == 1 ? this.chooseYear + '-01-01' : this.startTime,
  250. endTime: this.radio == 1 ? this.chooseYear + '-12-31' : this.endTime,
  251. quotaStr: this.quotaStrArr.join(','),
  252. range: this.rangeCode,
  253. area: this.areaCode == '350200' ? '' : this.areaCode,
  254. page: 1,
  255. size: 50,
  256. sex: this.sex,
  257. firstVisitType: this.firstVisitType,
  258. hasLung: this.hasLung,
  259. hasCt: this.hasCt,
  260. hasx: this.hasx,
  261. hasBloodGas: this.hasBloodGas,
  262. hasSmoke: this.hasSmoke,
  263. hasDrink: this.hasDrink,
  264. diseaseConversion: this.diseaseConversion,
  265. age: this.age
  266. }
  267. if (this.rangeCode == 'hospital') {
  268. params.hospital = this.communityCode
  269. }
  270. console.log('tableheader')
  271. statisticAPI
  272. .manageInfo(params)
  273. .then(function (res) {
  274. if (res.status == 200) {
  275. vm.tabledata = res.data.data
  276. vm.datatotal = res.data.total
  277. if (vm.tabledata.length) {
  278. vm.tableHeader = []
  279. if (vm.rangeCode == 'town') {
  280. vm.tableHeader.push({ prop: 'townName', label: '地区', width: '100', align: 'center' })
  281. } else {
  282. vm.tableHeader.push({ prop: 'hospitalName', label: '社区', width: '180', align: 'center' })
  283. }
  284. _.each(vm.tabledata[0], function (item, index) {
  285. if (
  286. index != 'town' &&
  287. index != 'townName' &&
  288. index != 'hospital' &&
  289. index != 'hospitalName' &&
  290. index != 'area' &&
  291. index != 'areaName' &&
  292. index != 'code' &&
  293. index != 'name'
  294. )
  295. vm.tableHeader.push({ prop: index, label: index, align: 'right', headerAlign: 'center' })
  296. })
  297. }
  298. } else {
  299. vm.$message.error(res.msg)
  300. }
  301. vm.daLoading = false
  302. })
  303. .catch(function (err) {
  304. vm.daLoading = false
  305. })
  306. },
  307. bubbleSort(array) {
  308. for (var i = 0; i < array.length - 1; i++) {
  309. for (var j = 0; j < array.length - i - 1; j++) {
  310. // 1.对每一个值和它的下一个值进行比较
  311. if (array[j] > array[j + 1]) {
  312. // 如果第一个值更多,则将其赋予自定义计数值 count
  313. var count = array[j]
  314. // 反复交换
  315. array[j] = array[j + 1]
  316. array[j + 1] = count
  317. }
  318. }
  319. }
  320. return array
  321. },
  322. search() {
  323. if (this.rangeCode == 'town' && this.areaCode == null) {
  324. this.$message.warning('请选择地区')
  325. return
  326. }
  327. if (this.rangeCode == 'hospital' && this.communityCode == null) {
  328. this.$message.warning('请选择社区')
  329. return
  330. }
  331. if (this.quotaStrArr.length) {
  332. this.manageInfo()
  333. } else {
  334. this.$message({
  335. message: '请选择查询指标!',
  336. type: 'warning'
  337. })
  338. return false
  339. }
  340. },
  341. selChange: function (type) {
  342. var vm = this,
  343. name = ''
  344. if (type == 3) {
  345. vm.initSelOption('community')
  346. vm.initSelOption('team')
  347. vm.getCommunityHospital()
  348. } else if (type == 5) {
  349. vm.initSelOption('team')
  350. // vm.teamListByArea();
  351. }
  352. },
  353. initSelOption: function (param) {
  354. var vm = this
  355. vm[param + 'List'] = [{ code: '', name: '全部' }]
  356. if (param == 'team') {
  357. vm[param + 'List'] = [{ id: '', name: '全部' }]
  358. }
  359. vm[param + 'Code'] = vm[param + 'List'][0].code || vm[param + 'List'][0].id
  360. },
  361. getCommunityHospital: function () {
  362. var vm = this,
  363. list = [{ code: '', name: '全部' }],
  364. param = 'community'
  365. homeAPI.getCommunityHospital({ area: vm.areaCode == '350200' ? '' : vm.areaCode }).then(function (res) {
  366. if (res.status == 200) {
  367. vm[param + 'List'] = list.concat(res.data)
  368. vm[param + 'Code'] = vm[param + 'List'][0].code
  369. } else {
  370. vm.$message.error(res.msg)
  371. }
  372. })
  373. },
  374. exportTable() {
  375. var vm = this
  376. vm.daLoading = true
  377. // var quotaStrs= this.bubbleSort(this.quotaStrArr)
  378. this.quotaStrArr.sort(function (a, b) {
  379. return a - b
  380. })
  381. var params = {
  382. startTime: this.radio == 1 ? this.chooseYear + '-01-01' : this.startTime,
  383. endTime: this.radio == 1 ? this.chooseYear + '-12-31' : this.endTime,
  384. quotaStr: this.quotaStrArr.join(','),
  385. range: this.rangeCode,
  386. area: this.areaCode == '350200' ? '' : this.areaCode,
  387. hospital: this.communityCode,
  388. page: 1,
  389. size: 50,
  390. sex: this.sex,
  391. firstVisitType: this.firstVisitType,
  392. hasLung: this.hasLung,
  393. hasCt: this.hasCt,
  394. hasx: this.hasx,
  395. hasBloodGas: this.hasBloodGas,
  396. hasSmoke: this.hasSmoke,
  397. hasDrink: this.hasDrink,
  398. diseaseConversion: this.diseaseConversion,
  399. age: this.age
  400. }
  401. statisticAPI.exportManageInfo(params, '管理情况.xls').then(function (res) {
  402. vm.daLoading = false
  403. vm.$message({
  404. message: '导出成功!',
  405. type: 'success'
  406. })
  407. })
  408. },
  409. resetDate() {
  410. if(this.isGuGan){
  411. this.rangeCode = 'hospital'
  412. this.areaCode = this.docInfo.town
  413. this.communityCode = this.docInfo.hospital
  414. }else{
  415. this.rangeCode = 'town'
  416. this.areaCode = ''
  417. this.communityCode = ''
  418. }
  419. this.startTime = ''
  420. this.endTime = ''
  421. this.quotaStr = ''
  422. this.range = ''
  423. this.area = ''
  424. this.hospital = ''
  425. this.sex = ''
  426. this.firstVisitType = ''
  427. this.firstVisitArea = ''
  428. this.firstVisitOrgLevel = ''
  429. this.hasLung = ''
  430. this.hasCt = ''
  431. this.hasx = ''
  432. this.hasBloodGas = ''
  433. this.hasSmoke = ''
  434. this.hasDrink = ''
  435. this.diseaseConversion = ''
  436. this.age = ''
  437. },
  438. handleCurrentChange(val) {
  439. this.page = val
  440. this.search()
  441. },
  442. handleSizeChange(val) {
  443. this.size = val
  444. this.search()
  445. }
  446. },
  447. mounted() {
  448. var vm = this
  449. var userRole = JSON.parse(window.sessionStorage.getItem('selectedRole'))
  450. vm.userRoleCode = userRole.code
  451. this.initTime(this)
  452. if (this.docInfo.expandLevelName) {
  453. this.isGuGan = this.docInfo.expandLevelName.indexOf('慢病骨干') > -1
  454. }
  455. this.initScope(3)
  456. if (this.isGuGan) {
  457. // 如何是慢病骨干 则只能选社区,并且限定死社区
  458. this.rangeList = [{ name: '按社区', code: 'hospital' }]
  459. this.rangeCode = 'hospital'
  460. this.areaList = [{ name: this.docInfo.hospitalName.substring(0, 3), code: this.docInfo.town }]
  461. this.areaCode = this.docInfo.town
  462. this.communityList = [{ name: this.docInfo.hospitalName, code: this.docInfo.hospital }]
  463. this.communityCode = this.docInfo.hospital
  464. // vm.receivingHospitalList = [{code:this.docInfo.hospital,name:this.docInfo.hospitalName}]
  465. // this.hospital = this.docInfo.hospital
  466. }
  467. EventBus.$on('copd-record-filter-change', function (event) {
  468. vm.quotaStrArr = event
  469. console.log(vm.quotaStrArr, '999sd8s9a8d9s8ad9sa89')
  470. })
  471. this.dicName.forEach(function (item) {
  472. vm.getDictByDictName(item)
  473. })
  474. // this.manageInfo()
  475. },
  476. destroyed() {
  477. EventBus.$off('copd-record-filter-change')
  478. }
  479. })