index.js 10 KB

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