index.js 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  1. var template = ''
  2. $.ajax('../../../component/statistics/MoneyReward/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('money-reward', {
  14. template: template,
  15. props: {
  16. header: {}
  17. },
  18. data() {
  19. return {
  20. years: [],
  21. yearType: '1',
  22. chooseYear: null,
  23. chooseTime: null,
  24. form: {
  25. range: 'town',
  26. serviceType: ''
  27. },
  28. tableData: [],
  29. dialogShow: false,
  30. page: 1,
  31. size: 10,
  32. total: 0,
  33. page1: 1,
  34. size1: 10,
  35. total1: 0,
  36. loading: false,
  37. exportLoading: false,
  38. sexDict: {
  39. 1: '男',
  40. 2: '女'
  41. },
  42. rangeOptions: [
  43. { label: '区', value: 'town' },
  44. { label: '社区', value: 'hospital' }
  45. ],
  46. areaOptions: [
  47. { label: '思明区', value: '350203' },
  48. { label: '海沧区', value: '350205' },
  49. { label: '湖里区', value: '350206' },
  50. { label: '集美区', value: '350211' },
  51. { label: '同安区', value: '350212' },
  52. { label: '翔安区', value: '350213' }
  53. ],
  54. level: 0,
  55. tableHeader: [],
  56. serviceType: []
  57. }
  58. },
  59. watch: {
  60. header: {
  61. handler() {
  62. if (this.form.range == 'town') {
  63. this.tableHeader = [
  64. { label: '地区', prop: 'town', width: '120' },
  65. { label: '社区', prop: 'hospital', width: '140' }
  66. ].concat(this.header)
  67. } else if (this.form.range == 'hospital') {
  68. this.tableHeader = [{ label: '社区', prop: 'hospital', width: '140' }].concat(this.header)
  69. }
  70. }
  71. }
  72. },
  73. methods: {
  74. init() {
  75. var selectedRole = JSON.parse(sessionStorage.getItem('selectedRole'))
  76. if (selectedRole.code.indexOf('350200') > -1) {
  77. this.level = 1 // 市卫健委
  78. this.areaOptions = [
  79. { label: '思明区', value: '350203' },
  80. { label: '海沧区', value: '350205' },
  81. { label: '湖里区', value: '350206' },
  82. { label: '集美区', value: '350211' },
  83. { label: '同安区', value: '350212' },
  84. { label: '翔安区', value: '350213' }
  85. ]
  86. } else if (selectedRole.code.length == 6) {
  87. this.level = 2 // 区管理
  88. this.areaOptions = [{ label: selectedRole.name.substring(0, 3), value: selectedRole.code }]
  89. this.form = {
  90. range: 'town',
  91. area: selectedRole.code,
  92. serviceType: ''
  93. }
  94. this.getHospital(selectedRole.code)
  95. }
  96. this.initTime()
  97. this.searchFn()
  98. },
  99. initTime() {
  100. var vm = this
  101. var now = new Date()
  102. vm.nowyear = vm.chooseYear = now.getFullYear()
  103. vm.years = []
  104. for (i = vm.nowyear; i >= 2013; i--) {
  105. vm.years.push(i)
  106. }
  107. },
  108. searchFn() {
  109. var vm = this
  110. this.loading = true
  111. var params = {
  112. ...this.form,
  113. isTotal: 1,
  114. menu: this.header
  115. .map(function (item) {
  116. return item.prop
  117. })
  118. .join(',')
  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. httpRequest.get('doctor/healthBank/redPackageRewardStatistics', { data: params }).then(function (res) {
  131. if (res.status == 200) {
  132. vm.tableData = res.data.list.map(function (item) {
  133. var data = JSON.parse(JSON.stringify(item))
  134. if (vm.form.range == 'town') {
  135. data.town = item.name
  136. data.hasChildren = item.code && true
  137. } else if (vm.form.range == 'hospital') {
  138. data.hospital = item.name
  139. data.hasChildren = false
  140. }
  141. return data
  142. })
  143. }
  144. vm.loading = false
  145. })
  146. },
  147. exportTable() {
  148. var vm = this
  149. var params = {
  150. ...this.form,
  151. page: this.page,
  152. pageSize: this.size
  153. }
  154. if (this.yearType == '1') {
  155. params.startDate = this.chooseYear + '-01-01'
  156. params.endDate = this.chooseYear + '-12-31'
  157. } else {
  158. if (this.chooseTime) {
  159. params.startDate = this.chooseTime[0]
  160. params.endDate = this.chooseTime[1]
  161. }
  162. }
  163. this.exportLoading = true
  164. var fileName = `红包奖励汇总${new Date().getTime()}.xls`
  165. httpRequest.downLoadFileForAjax('statisticsExport/exPatinetIntegralAnalysis', fileName, params).then(function () {
  166. vm.exportLoading = false
  167. })
  168. },
  169. eliminateClick() {
  170. var selectedRole = JSON.parse(sessionStorage.getItem('selectedRole'))
  171. if (this.level == 1) {
  172. this.form = {
  173. range: 'town',
  174. serviceType: ''
  175. }
  176. } else if (this.level == 2) {
  177. this.form = {
  178. range: 'town',
  179. area: selectedRole.code,
  180. serviceType: ''
  181. }
  182. this.getHospital(selectedRole.code)
  183. }
  184. this.yearType = '1'
  185. this.chooseYear = new Date().getFullYear()
  186. this.chooseTime = null
  187. this.$forceUpdate()
  188. },
  189. closeDialog() {
  190. this.dialogShow = false
  191. this.dialogShow1 = false
  192. },
  193. getDictData() {
  194. var vm = this
  195. statisticAPI.getDictByDictName({ name: 'health_bank_service_type' }).then(function (res) {
  196. vm.serviceType = [{ label: '全部', value: '' }].concat(res.list)
  197. })
  198. },
  199. getHospital(code) {
  200. var vm = this
  201. delete this.form.hospital
  202. delete this.form.team
  203. var params = {
  204. type: 5,
  205. code: code
  206. }
  207. httpRequest.post('common/district', { data: params }).then(function (res) {
  208. vm.hospitalOptions = [{ code: '', name: '全部' }]
  209. vm.hospitalOptions = vm.hospitalOptions.concat(res.list)
  210. })
  211. },
  212. resetArea() {
  213. if (this.level == 1) {
  214. delete this.form.area
  215. delete this.form.hospital
  216. delete this.form.team
  217. } else if (this.level == 2) {
  218. delete this.form.hospital
  219. delete this.form.team
  220. } else {
  221. delete this.form.team
  222. }
  223. },
  224. load(row, treeNode, resolve) {
  225. var params = {
  226. menu: this.header
  227. .map(function (item) {
  228. return item.prop
  229. })
  230. .join(',')
  231. }
  232. var len = row.code.length
  233. if (len == 6) {
  234. params.range = 'hospital'
  235. params.area = row.code
  236. } else if (len == 10) {
  237. params.range = 'team'
  238. params.hospital = row.code
  239. }
  240. if (this.yearType == '1') {
  241. params.startDate = this.chooseYear + '-01-01'
  242. params.endDate = this.chooseYear + '-12-31'
  243. } else {
  244. if (this.chooseTime) {
  245. params.startDate = this.chooseTime[0]
  246. params.endDate = this.chooseTime[1]
  247. }
  248. }
  249. httpRequest.get('doctor/healthBank/redPackageRewardStatistics', { data: params }).then(function (res) {
  250. if (res.status == 200) {
  251. var children = res.data.list.map(function (item) {
  252. var data = {
  253. ...item
  254. }
  255. if (len == 6) {
  256. data.hospital = item.name
  257. data.hasChildren = false
  258. data.town1 = row.code
  259. }
  260. return data
  261. })
  262. resolve(children)
  263. }
  264. })
  265. }
  266. },
  267. mounted() {
  268. this.init()
  269. this.getDictData()
  270. }
  271. })