index.js 12 KB

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