index.js 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  1. var template = ''
  2. $.ajax('../../../component/statistics/GxbManageSum/index.html', {
  3. data: {},
  4. dataType: 'html',
  5. cache: false,
  6. timeout: 60000,
  7. async: false,
  8. error: function (res) {},
  9. success: function (res) {
  10. template = res
  11. }
  12. })
  13. Vue.component('gxb-manage-sum', {
  14. template: template,
  15. props: [],
  16. data: function () {
  17. return {
  18. years: [],
  19. yearType: '1',
  20. chooseYear: null,
  21. chooseTime: null,
  22. rangeOptions: [
  23. { label: '区', value: 'town' },
  24. { label: '社区', value: 'hospital' },
  25. { label: '团队', value: 'team' }
  26. ],
  27. areaOptions: [
  28. { label: '思明区', value: '350203' },
  29. { label: '海沧区', value: '350205' },
  30. { label: '湖里区', value: '350206' },
  31. { label: '集美区', value: '350211' },
  32. { label: '同安区', value: '350212' },
  33. { label: '翔安区', value: '350213' }
  34. ],
  35. hospitalOptions: [],
  36. teamOptions: [],
  37. form: {
  38. range: 'town'
  39. },
  40. loading: false,
  41. exportLoading: false,
  42. tableData: [],
  43. tableHeader: [],
  44. constantHeader: [
  45. { label: '筛评人数', prop: 'totalNum', width: '90' },
  46. { label: '上转人数', prop: 'turnUpNum', width: '90' },
  47. { label: '下转人数', prop: 'turnDownNum', width: '90' },
  48. { label: '康复管理人数', prop: 'rehabilitationNum', width: '90' }
  49. ],
  50. level: 0
  51. }
  52. },
  53. methods: {
  54. init() {
  55. var selectedRole = JSON.parse(sessionStorage.getItem('selectedRole'))
  56. if (selectedRole.code.indexOf('350200') > -1) {
  57. this.level = 1 // 市卫健委
  58. this.areaOptions = [
  59. { label: '思明区', value: '350203' },
  60. { label: '海沧区', value: '350205' },
  61. { label: '湖里区', value: '350206' },
  62. { label: '集美区', value: '350211' },
  63. { label: '同安区', value: '350212' },
  64. { label: '翔安区', value: '350213' }
  65. ]
  66. } else if (selectedRole.code.length == 6) {
  67. this.level = 2 // 区管理
  68. this.areaOptions = [{ label: selectedRole.name.substring(0, 3), value: selectedRole.code }]
  69. this.form = {
  70. range: 'town',
  71. area: selectedRole.code
  72. }
  73. this.getHospital(selectedRole.code)
  74. } else {
  75. this.level = 3 // 社区管理
  76. this.rangeOptions = [
  77. { label: '社区', value: 'hospital' },
  78. { label: '团队', value: 'team' }
  79. ]
  80. this.areaOptions = [{ label: selectedRole.name.substring(0, 3), value: selectedRole.code.substring(0, 6) }]
  81. this.hospitalOptions = [{ name: selectedRole.name, code: selectedRole.code }]
  82. this.form = {
  83. range: 'hospital',
  84. area: selectedRole.code.substring(0, 6),
  85. hospital: selectedRole.code
  86. }
  87. this.getTeam(selectedRole.code)
  88. }
  89. this.initTime()
  90. this.searchFn()
  91. },
  92. initTime() {
  93. var vm = this
  94. var now = new Date()
  95. vm.nowyear = vm.chooseYear = now.getFullYear()
  96. vm.years = []
  97. for (i = vm.nowyear; i >= 2013; i--) {
  98. vm.years.push(i)
  99. }
  100. },
  101. resetArea() {
  102. if (this.level == 1) {
  103. delete this.form.area
  104. delete this.form.hospital
  105. delete this.form.team
  106. } else if (this.level == 2) {
  107. delete this.form.hospital
  108. delete this.form.team
  109. } else {
  110. delete this.form.team
  111. }
  112. },
  113. searchFn() {
  114. var vm = this
  115. this.loading = true
  116. var params = {
  117. ...this.form,
  118. isTotal: 1
  119. }
  120. if (this.yearType == '1') {
  121. params.startDate = this.chooseYear + '-01-01'
  122. params.endDate = this.chooseYear + '-12-31'
  123. } else {
  124. if (this.chooseTime) {
  125. params.startDate = this.chooseTime[0]
  126. params.endDate = this.chooseTime[1]
  127. }
  128. }
  129. if (this.form.range == 'town') {
  130. this.tableHeader = getTownHeader().concat(this.constantHeader)
  131. } else if (this.form.range == 'hospital') {
  132. this.tableHeader = getHospitalHeader().concat(this.constantHeader)
  133. } else {
  134. this.tableHeader = getTeamHeader().concat(this.constantHeader)
  135. }
  136. httpRequest.get('statistics/collaborate/gxbScreenInfoTotal', { data: params }).then(function (res) {
  137. if (res.status == 200) {
  138. vm.tableData = res.detailModelList.map(function (item) {
  139. var data = JSON.parse(JSON.stringify(item))
  140. if (vm.form.range == 'town') {
  141. data.town = item.name
  142. data.hasChildren = item.code && true
  143. } else if (vm.form.range == 'hospital') {
  144. data.hospital = item.name
  145. data.hasChildren = item.code && true
  146. } else if (vm.form.range == 'team') {
  147. data.team = item.name
  148. }
  149. return data
  150. })
  151. }
  152. vm.loading = false
  153. })
  154. },
  155. exportTable() {
  156. var vm = this
  157. var params = {
  158. ...this.form
  159. }
  160. if (this.yearType == '1') {
  161. params.startDate = this.chooseYear + '-01-01'
  162. params.endDate = this.chooseYear + '-12-31'
  163. } else {
  164. if (this.chooseTime) {
  165. params.startDate = this.chooseTime[0]
  166. params.endDate = this.chooseTime[1]
  167. }
  168. }
  169. this.exportLoading = true
  170. var fileName = `冠心病筛评管理情况汇总表${new Date().getTime()}.xls`
  171. httpRequest.downLoadFileForAjax('statistics/collaborate/exportGxbScreenInfoTotal', fileName, params).then(function () {
  172. vm.exportLoading = false
  173. })
  174. },
  175. eliminateClick() {
  176. var selectedRole = JSON.parse(sessionStorage.getItem('selectedRole'))
  177. if (this.level == 1) {
  178. this.form = {
  179. range: 'town'
  180. }
  181. } else if (this.level == 2) {
  182. this.form = {
  183. range: 'town',
  184. area: selectedRole.code
  185. }
  186. this.getHospital(selectedRole.code)
  187. } else {
  188. this.form = {
  189. range: 'hospital',
  190. area: selectedRole.code.substring(0, 6),
  191. hospital: selectedRole.code
  192. }
  193. this.getTeam(selectedRole.code)
  194. }
  195. this.yearType = '1'
  196. this.chooseYear = new Date().getFullYear()
  197. this.chooseTime = null
  198. this.$forceUpdate()
  199. },
  200. getHospital(code) {
  201. var vm = this
  202. delete this.form.hospital
  203. delete this.form.team
  204. var params = {
  205. type: 5,
  206. code: code
  207. }
  208. httpRequest.post('common/district', { data: params }).then(function (res) {
  209. vm.hospitalOptions = [{ code: '', name: '全部' }]
  210. vm.hospitalOptions = vm.hospitalOptions.concat(res.list)
  211. })
  212. },
  213. getTeam(code) {
  214. var vm = this
  215. delete this.form.team
  216. var params = {
  217. hospital: code,
  218. area: this.form.area
  219. }
  220. httpRequest.get('statisticsExport/teamList', { data: params }).then(function (res) {
  221. vm.teamOptions = [{ id: '', name: '全部' }]
  222. vm.teamOptions = vm.teamOptions.concat(res.data)
  223. })
  224. },
  225. load(row, treeNode, resolve) {
  226. var params = {}
  227. var len = row.code.length
  228. if (len == 6) {
  229. params.range = 'hospital'
  230. params.area = row.code
  231. } else if (len == 10) {
  232. params.range = 'team'
  233. params.hospital = row.code
  234. }
  235. if (this.yearType == '1') {
  236. params.startDate = this.chooseYear + '-01-01'
  237. params.endDate = this.chooseYear + '-12-31'
  238. } else {
  239. if (this.chooseTime) {
  240. params.startDate = this.chooseTime[0]
  241. params.endDate = this.chooseTime[1]
  242. }
  243. }
  244. httpRequest.get('statistics/collaborate/gxbScreenInfoTotal', { data: params }).then(function (res) {
  245. if (res.status == 200) {
  246. var children = res.detailModelList.map(function (item) {
  247. var data = {
  248. ...item
  249. }
  250. if (len == 6) {
  251. data.hospital = item.name
  252. data.hasChildren = true
  253. data.town1 = row.code
  254. } else if (len == 10) {
  255. data.team = item.name
  256. data.hospital1 = row.code
  257. data.town1 = row.town1
  258. }
  259. return data
  260. })
  261. resolve(children)
  262. }
  263. })
  264. },
  265. toPage(row, prop) {
  266. var len = row.code.length
  267. var range, area, hospital, team
  268. if (len == 6 && row.code.indexOf('3502') > -1) {
  269. range = 'town'
  270. area = row.code
  271. } else if (len == 10) {
  272. range = 'hospital'
  273. area = row.town1
  274. hospital = row.code
  275. } else {
  276. range = 'team'
  277. area = row.town1
  278. hospital = row.hospital1
  279. team = row.code
  280. }
  281. if (prop == 'totalNum') {
  282. EventBus.$emit('toPage', {
  283. id: '77',
  284. range: range,
  285. area: area,
  286. hospital: hospital,
  287. team: team,
  288. yearType: this.yearType,
  289. time: this.yearType == '1' ? this.chooseYear : this.chooseTime
  290. })
  291. } else if (prop == 'turnUpNum') {
  292. EventBus.$emit('toPage', {
  293. id: '78',
  294. range: range,
  295. area: area,
  296. hospital: hospital,
  297. team: team,
  298. yearType: this.yearType,
  299. time: this.yearType == '1' ? this.chooseYear : this.chooseTime
  300. })
  301. } else if (prop == 'turnDownNum') {
  302. EventBus.$emit('toPage', {
  303. id: '79',
  304. range: range,
  305. area: area,
  306. hospital: hospital,
  307. team: team,
  308. yearType: this.yearType,
  309. time: this.yearType == '1' ? this.chooseYear : this.chooseTime
  310. })
  311. } else if (prop == 'rehabilitationNum') {
  312. EventBus.$emit('toPage', {
  313. id: '80',
  314. range: range,
  315. area: area,
  316. hospital: hospital,
  317. team: team,
  318. yearType: this.yearType,
  319. time: this.yearType == '1' ? this.chooseYear : this.chooseTime
  320. })
  321. }
  322. }
  323. },
  324. mounted() {
  325. this.init()
  326. }
  327. })