index.js 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  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. hospitalOptions: []
  58. }
  59. },
  60. watch: {
  61. header: {
  62. handler() {
  63. if (this.form.range == 'town') {
  64. this.tableHeader = [
  65. { label: '地区', prop: 'town', width: '120' },
  66. { label: '社区', prop: 'hospital', width: '140' }
  67. ].concat(this.header)
  68. } else if (this.form.range == 'hospital') {
  69. this.tableHeader = [{ label: '社区', prop: 'hospital', width: '140' }].concat(this.header)
  70. }
  71. }
  72. }
  73. },
  74. methods: {
  75. init() {
  76. var selectedRole = JSON.parse(sessionStorage.getItem('selectedRole'))
  77. if (selectedRole.code.indexOf('350200') > -1) {
  78. this.level = 1 // 市卫健委
  79. this.areaOptions = [
  80. { label: '思明区', value: '350203' },
  81. { label: '海沧区', value: '350205' },
  82. { label: '湖里区', value: '350206' },
  83. { label: '集美区', value: '350211' },
  84. { label: '同安区', value: '350212' },
  85. { label: '翔安区', value: '350213' }
  86. ]
  87. } else if (selectedRole.code.length == 6) {
  88. this.level = 2 // 区管理
  89. this.areaOptions = [{ label: selectedRole.name.substring(0, 3), value: selectedRole.code }]
  90. this.form = {
  91. range: 'town',
  92. area: selectedRole.code,
  93. serviceType: ''
  94. }
  95. this.getHospital(selectedRole.code)
  96. } else {
  97. this.rangeOptions = [{ label: '按社区', value: 'hospital' }]
  98. this.form = {
  99. range: 'hospital',
  100. area: selectedRole.code.substring(0, 6),
  101. hospital: selectedRole.code,
  102. serviceType: ''
  103. }
  104. this.level = 3 // 社区管理
  105. this.areaOptions = [{ label: selectedRole.name.substring(0, 3), value: selectedRole.code.substring(0, 6) }]
  106. this.hospitalOptions = [{ name: selectedRole.name, code: selectedRole.code }]
  107. }
  108. this.initTime()
  109. this.searchFn()
  110. },
  111. initTime() {
  112. var vm = this
  113. var now = new Date()
  114. vm.nowyear = vm.chooseYear = now.getFullYear()
  115. vm.years = []
  116. for (i = vm.nowyear; i >= 2013; i--) {
  117. vm.years.push(i)
  118. }
  119. },
  120. searchFn() {
  121. var vm = this
  122. this.loading = true
  123. var params = {
  124. ...this.form,
  125. isTotal: 1,
  126. menu: this.header
  127. .map(function (item) {
  128. return item.prop
  129. })
  130. .join(',')
  131. }
  132. vm.tableData = []
  133. if (this.yearType == '1') {
  134. params.startDate = this.chooseYear + '-01-01'
  135. params.endDate = this.chooseYear + '-12-31'
  136. } else {
  137. if (this.chooseTime) {
  138. params.startDate = this.chooseTime[0]
  139. params.endDate = this.chooseTime[1]
  140. }
  141. }
  142. httpRequest.get('doctor/healthBank/redPackageRewardStatistics', { data: params }).then(function (res) {
  143. if (res.status == 200) {
  144. vm.tableData = res.data.list.map(function (item) {
  145. var data = JSON.parse(JSON.stringify(item))
  146. if (vm.form.range == 'town') {
  147. data.town = item.name
  148. data.hasChildren = item.code && true
  149. } else if (vm.form.range == 'hospital') {
  150. data.hospital = item.name
  151. data.hasChildren = false
  152. }
  153. return data
  154. })
  155. }
  156. vm.loading = false
  157. })
  158. },
  159. exportTable() {
  160. var vm = this
  161. var params = {
  162. ...this.form,
  163. menu: this.header
  164. .map(function (item) {
  165. return item.prop
  166. })
  167. .join(',')
  168. }
  169. if (this.yearType == '1') {
  170. params.startDate = this.chooseYear + '-01-01'
  171. params.endDate = this.chooseYear + '-12-31'
  172. } else {
  173. if (this.chooseTime) {
  174. params.startDate = this.chooseTime[0]
  175. params.endDate = this.chooseTime[1]
  176. }
  177. }
  178. this.exportLoading = true
  179. var fileName = `红包奖励汇总${new Date().getTime()}.xls`
  180. httpRequest.downLoadFileForAjax('/doctor/healthBank/exportRedPackageRewardStatistics', fileName, params).then(function () {
  181. vm.exportLoading = false
  182. })
  183. },
  184. eliminateClick() {
  185. var selectedRole = JSON.parse(sessionStorage.getItem('selectedRole'))
  186. if (this.level == 1) {
  187. this.form = {
  188. range: 'town',
  189. serviceType: ''
  190. }
  191. } else if (this.level == 2) {
  192. this.form = {
  193. range: 'town',
  194. area: selectedRole.code,
  195. serviceType: ''
  196. }
  197. this.getHospital(selectedRole.code)
  198. } else {
  199. this.form = {
  200. range: 'hospital',
  201. area: selectedRole.code.substring(0, 6),
  202. hospital: selectedRole.code,
  203. serviceType: ''
  204. }
  205. this.areaOptions = [{ label: selectedRole.name.substring(0, 3), value: selectedRole.code.substring(0, 6) }]
  206. this.hospitalOptions = [{ name: selectedRole.name, code: selectedRole.code }]
  207. }
  208. this.yearType = '1'
  209. this.chooseYear = new Date().getFullYear()
  210. this.chooseTime = null
  211. this.$forceUpdate()
  212. },
  213. closeDialog() {
  214. this.dialogShow = false
  215. this.dialogShow1 = false
  216. },
  217. getDictData() {
  218. var vm = this
  219. statisticAPI.getDictByDictName({ name: 'health_bank_service_type' }).then(function (res) {
  220. vm.serviceType = [{ label: '全部', value: '' }].concat(res.list)
  221. })
  222. },
  223. getHospital(code) {
  224. var vm = this
  225. delete this.form.hospital
  226. delete this.form.team
  227. var params = {
  228. type: 5,
  229. code: code
  230. }
  231. httpRequest.post('common/district', { data: params }).then(function (res) {
  232. vm.hospitalOptions = [{ code: '', name: '全部' }]
  233. vm.hospitalOptions = vm.hospitalOptions.concat(res.list)
  234. })
  235. },
  236. resetArea() {
  237. if (this.level == 1) {
  238. delete this.form.area
  239. delete this.form.hospital
  240. delete this.form.team
  241. } else if (this.level == 2) {
  242. delete this.form.hospital
  243. delete this.form.team
  244. } else {
  245. delete this.form.team
  246. }
  247. },
  248. load(row, treeNode, resolve) {
  249. var params = {
  250. menu: this.header
  251. .map(function (item) {
  252. return item.prop
  253. })
  254. .join(',')
  255. }
  256. var len = row.code.length
  257. if (len == 6) {
  258. params.range = 'hospital'
  259. params.area = row.code
  260. } else if (len == 10) {
  261. params.range = 'team'
  262. params.hospital = row.code
  263. }
  264. if (this.yearType == '1') {
  265. params.startDate = this.chooseYear + '-01-01'
  266. params.endDate = this.chooseYear + '-12-31'
  267. } else {
  268. if (this.chooseTime) {
  269. params.startDate = this.chooseTime[0]
  270. params.endDate = this.chooseTime[1]
  271. }
  272. }
  273. httpRequest.get('doctor/healthBank/redPackageRewardStatistics', { data: params }).then(function (res) {
  274. if (res.status == 200) {
  275. var children = res.data.list.map(function (item) {
  276. var data = {
  277. ...item
  278. }
  279. if (len == 6) {
  280. data.hospital = item.name
  281. data.hasChildren = false
  282. data.town1 = row.code
  283. }
  284. return data
  285. })
  286. resolve(children)
  287. }
  288. })
  289. }
  290. },
  291. mounted() {
  292. this.init()
  293. this.getDictData()
  294. }
  295. })