index.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384
  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. search(){
  260. if(this.quotaStrArr.length){
  261. this.manageInfo()
  262. }else{
  263. this.$message({
  264. message: '请选择查询指标!',
  265. type: 'warning'
  266. });
  267. return false
  268. }
  269. },
  270. selChange: function (type) {
  271. var vm = this,
  272. name = '';
  273. if (type == 3) {
  274. vm.initSelOption('community');
  275. vm.initSelOption('team');
  276. vm.getCommunityHospital();
  277. } else if (type == 5) {
  278. vm.initSelOption('team');
  279. // vm.teamListByArea();
  280. }
  281. },
  282. initSelOption: function (param) {
  283. var vm = this;
  284. vm[param + 'List'] = [{code: '', name: '全部'}];
  285. if (param == 'team') {
  286. vm[param + 'List'] = [{id: '', name: '全部'}];
  287. }
  288. vm[param + 'Code'] = vm[param + 'List'][0].code || vm[param + 'List'][0].id;
  289. },
  290. getCommunityHospital: function () {
  291. var vm = this,
  292. list = [{code: '', name: '全部'}],
  293. param = 'community';
  294. homeAPI.getCommunityHospital({area: vm.areaCode == '350200' ? '' : vm.areaCode}).then(function (res) {
  295. if (res.status == 200) {
  296. vm[param + 'List'] = list.concat(res.data);
  297. vm[param + 'Code'] = vm[param + 'List'][0].code;
  298. } else {
  299. vm.$message.error(res.msg);
  300. }
  301. });
  302. },
  303. exportTable(){
  304. var vm=this
  305. vm.daLoading=true
  306. var params={
  307. startTime: this.radio==1? this.chooseYear+'-01-01' : this.startTime,
  308. endTime:this.radio==1? this.chooseYear+'-12-31': this.endTime,
  309. quotaStr:this.quotaStrArr.join(','),
  310. range:this.rangeCode,
  311. area:this.areaCode=='350200'?'':this.areaCode,
  312. hospital:this.communityCode,
  313. page:1,
  314. size:50,
  315. sex:this.sex,
  316. firstVisitType:this.firstVisitType,
  317. hasLung:this.hasLung,
  318. hasCt:this.hasCt,
  319. hasx:this.hasx,
  320. hasBloodGas:this.hasBloodGas,
  321. hasSmoke:this.hasSmoke,
  322. hasDrink:this.hasDrink,
  323. diseaseConversion:this.diseaseConversion,
  324. age:this.age,
  325. }
  326. statisticAPI.exportManageInfo(params,'管理情况.xls').then(
  327. function(res){
  328. vm.daLoading=false
  329. vm.$message({
  330. message: '导出成功!',
  331. type: 'success'
  332. });
  333. }
  334. )
  335. },
  336. resetDate(){
  337. this.startTime='',
  338. this.endTime='',
  339. this.rangeCode='town',
  340. this.quotaStr='',
  341. this.range='',
  342. this.area='',
  343. this.hospital='',
  344. this.sex='',
  345. this.firstVisitType='',
  346. this.firstVisitArea='',
  347. this.firstVisitOrgLevel='',
  348. this.areaCode='',
  349. this.hasLung='',
  350. this.hasCt='',
  351. this.hasx='',
  352. this.hasBloodGas='',
  353. this.hasSmoke='',
  354. this.hasDrink='',
  355. this.diseaseConversion='',
  356. this.age=''
  357. }
  358. },
  359. mounted() {
  360. var vm = this
  361. this.initTime(this)
  362. this.initScope(this)
  363. EventBus.$on('copd-record-filter-change', function (event) {
  364. vm.quotaStrArr = event
  365. console.log(vm.quotaStrArr,'999sd8s9a8d9s8ad9sa89')
  366. })
  367. this.dicName.forEach(function(item) {
  368. vm.getDictByDictName(item)
  369. });
  370. // this.manageInfo()
  371. },
  372. destroyed() {
  373. EventBus.$off('copd-record-filter-change');
  374. }
  375. });