index.js 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334
  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. vm.tableData = []
  121. if (this.yearType == '1') {
  122. params.startDate = this.chooseYear + '-01-01'
  123. params.endDate = this.chooseYear + '-12-31'
  124. } else {
  125. if (this.chooseTime) {
  126. params.startDate = this.chooseTime[0]
  127. params.endDate = this.chooseTime[1]
  128. }
  129. }
  130. if (this.form.range == 'town') {
  131. this.tableHeader = getTownHeader().concat(this.constantHeader)
  132. } else if (this.form.range == 'hospital') {
  133. this.tableHeader = getHospitalHeader().concat(this.constantHeader)
  134. } else {
  135. this.tableHeader = getTeamHeader().concat(this.constantHeader)
  136. }
  137. httpRequest.get('statistics/collaborate/gxbScreenInfoTotal', { data: params }).then(function (res) {
  138. if (res.status == 200) {
  139. vm.tableData = res.detailModelList.map(function (item) {
  140. var data = JSON.parse(JSON.stringify(item))
  141. if (vm.form.range == 'town') {
  142. data.town = item.name
  143. data.hasChildren = item.code && true
  144. } else if (vm.form.range == 'hospital') {
  145. data.hospital = item.name
  146. data.hasChildren = item.code && true
  147. } else if (vm.form.range == 'team') {
  148. data.team = item.name
  149. }
  150. return data
  151. })
  152. }
  153. vm.loading = false
  154. })
  155. },
  156. exportTable() {
  157. var vm = this
  158. var params = {
  159. ...this.form
  160. }
  161. if (this.yearType == '1') {
  162. params.startDate = this.chooseYear + '-01-01'
  163. params.endDate = this.chooseYear + '-12-31'
  164. } else {
  165. if (this.chooseTime) {
  166. params.startDate = this.chooseTime[0]
  167. params.endDate = this.chooseTime[1]
  168. }
  169. }
  170. this.exportLoading = true
  171. var fileName = `冠心病筛评管理情况汇总表${new Date().getTime()}.xls`
  172. httpRequest.downLoadFileForAjax('statistics/collaborate/exportGxbScreenInfoTotal', fileName, params).then(function () {
  173. vm.exportLoading = false
  174. })
  175. },
  176. eliminateClick() {
  177. var selectedRole = JSON.parse(sessionStorage.getItem('selectedRole'))
  178. if (this.level == 1) {
  179. this.form = {
  180. range: 'town'
  181. }
  182. } else if (this.level == 2) {
  183. this.form = {
  184. range: 'town',
  185. area: selectedRole.code
  186. }
  187. this.getHospital(selectedRole.code)
  188. } else {
  189. this.form = {
  190. range: 'hospital',
  191. area: selectedRole.code.substring(0, 6),
  192. hospital: selectedRole.code
  193. }
  194. this.getTeam(selectedRole.code)
  195. }
  196. this.yearType = '1'
  197. this.chooseYear = new Date().getFullYear()
  198. this.chooseTime = null
  199. this.$forceUpdate()
  200. },
  201. getHospital(code) {
  202. var vm = this
  203. delete this.form.hospital
  204. delete this.form.team
  205. var params = {
  206. type: 5,
  207. code: code
  208. }
  209. httpRequest.post('common/district', { data: params }).then(function (res) {
  210. vm.hospitalOptions = [{ code: '', name: '全部' }]
  211. vm.hospitalOptions = vm.hospitalOptions.concat(res.list)
  212. })
  213. },
  214. getTeam(code) {
  215. var vm = this
  216. delete this.form.team
  217. var params = {
  218. hospital: code,
  219. area: this.form.area
  220. }
  221. httpRequest.get('statisticsExport/teamList', { data: params }).then(function (res) {
  222. vm.teamOptions = [{ id: '', name: '全部' }]
  223. vm.teamOptions = vm.teamOptions.concat(res.data)
  224. })
  225. },
  226. load(row, treeNode, resolve) {
  227. var params = {}
  228. var len = row.code.length
  229. if (len == 6) {
  230. params.range = 'hospital'
  231. params.area = row.code
  232. } else if (len == 10) {
  233. params.range = 'team'
  234. params.hospital = row.code
  235. }
  236. if (this.yearType == '1') {
  237. params.startDate = this.chooseYear + '-01-01'
  238. params.endDate = this.chooseYear + '-12-31'
  239. } else {
  240. if (this.chooseTime) {
  241. params.startDate = this.chooseTime[0]
  242. params.endDate = this.chooseTime[1]
  243. }
  244. }
  245. httpRequest.get('statistics/collaborate/gxbScreenInfoTotal', { data: params }).then(function (res) {
  246. if (res.status == 200) {
  247. var children = res.detailModelList.map(function (item) {
  248. var data = {
  249. ...item
  250. }
  251. if (len == 6) {
  252. data.hospital = item.name
  253. data.hasChildren = true
  254. data.town1 = row.code
  255. } else if (len == 10) {
  256. data.team = item.name
  257. data.hospital1 = row.code
  258. data.town1 = row.town1
  259. }
  260. return data
  261. })
  262. resolve(children)
  263. }
  264. })
  265. },
  266. toPage(row, prop) {
  267. if (!row.code) return
  268. var len = row.code.length
  269. var range, area, hospital, team
  270. if (len == 6 && row.code.indexOf('3502') > -1) {
  271. range = 'town'
  272. area = row.code
  273. } else if (len == 10) {
  274. range = 'hospital'
  275. area = row.town1
  276. hospital = row.code
  277. } else {
  278. range = 'team'
  279. area = row.town1
  280. hospital = row.hospital1
  281. team = row.code
  282. }
  283. if (prop == 'totalNum') {
  284. EventBus.$emit('toPage', {
  285. id: '77',
  286. range: range,
  287. area: area,
  288. hospital: hospital,
  289. team: team,
  290. yearType: this.yearType,
  291. time: this.yearType == '1' ? this.chooseYear : this.chooseTime
  292. })
  293. } else if (prop == 'turnUpNum') {
  294. EventBus.$emit('toPage', {
  295. id: '78',
  296. range: range,
  297. area: area,
  298. hospital: hospital,
  299. team: team,
  300. yearType: this.yearType,
  301. time: this.yearType == '1' ? this.chooseYear : this.chooseTime
  302. })
  303. } else if (prop == 'turnDownNum') {
  304. EventBus.$emit('toPage', {
  305. id: '79',
  306. range: range,
  307. area: area,
  308. hospital: hospital,
  309. team: team,
  310. yearType: this.yearType,
  311. time: this.yearType == '1' ? this.chooseYear : this.chooseTime
  312. })
  313. } else if (prop == 'rehabilitationNum') {
  314. EventBus.$emit('toPage', {
  315. id: '80',
  316. range: range,
  317. area: area,
  318. hospital: hospital,
  319. team: team,
  320. yearType: this.yearType,
  321. time: this.yearType == '1' ? this.chooseYear : this.chooseTime
  322. })
  323. }
  324. }
  325. },
  326. mounted() {
  327. this.init()
  328. }
  329. })