index.js 11 KB

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