index.js 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319
  1. var template = ''
  2. $.ajax('../../../component/statistics/ResidentScore/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('resident-score', {
  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. },
  27. tableData: [],
  28. dialogShow: false,
  29. info: {},
  30. loading: false,
  31. exportLoading: false,
  32. rangeOptions: [
  33. { label: '区', value: 'town' },
  34. { label: '社区', value: 'hospital' },
  35. { label: '团队', value: 'team' }
  36. ],
  37. areaOptions: [
  38. { label: '思明区', value: '350203' },
  39. { label: '海沧区', value: '350205' },
  40. { label: '湖里区', value: '350206' },
  41. { label: '集美区', value: '350211' },
  42. { label: '同安区', value: '350212' },
  43. { label: '翔安区', value: '350213' }
  44. ],
  45. level: 0,
  46. tableHeader: []
  47. }
  48. },
  49. watch: {
  50. header: {
  51. handler() {
  52. if (this.form.range == 'town') {
  53. this.tableHeader = getTownHeader().concat(this.header)
  54. } else if (this.form.range == 'hospital') {
  55. this.tableHeader = getHospitalHeader().concat(this.header)
  56. } else {
  57. this.tableHeader = getTeamHeader().concat(this.header)
  58. }
  59. }
  60. }
  61. },
  62. methods: {
  63. init() {
  64. var vm = this
  65. var selectedRole = JSON.parse(sessionStorage.getItem('selectedRole'))
  66. if (selectedRole.code.indexOf('350200') > -1) {
  67. this.level = 1 // 市卫健委
  68. this.areaOptions = [
  69. { label: '思明区', value: '350203' },
  70. { label: '海沧区', value: '350205' },
  71. { label: '湖里区', value: '350206' },
  72. { label: '集美区', value: '350211' },
  73. { label: '同安区', value: '350212' },
  74. { label: '翔安区', value: '350213' }
  75. ]
  76. } else if (selectedRole.code.length == 6) {
  77. this.level = 2 // 区管理
  78. this.areaOptions = [{ label: selectedRole.name.substring(0, 3), value: selectedRole.code }]
  79. this.form = {
  80. range: 'town',
  81. area: selectedRole.code
  82. }
  83. this.getHospital(selectedRole.code)
  84. } else {
  85. this.level = 3 // 社区管理
  86. this.rangeOptions = [
  87. { label: '社区', value: 'hospital' },
  88. { label: '团队', value: 'team' }
  89. ]
  90. this.areaOptions = [{ label: selectedRole.name.substring(0, 3), value: selectedRole.code.substring(0, 6) }]
  91. this.hospitalOptions = [{ name: selectedRole.name, code: selectedRole.code }]
  92. this.form = {
  93. range: 'hospital',
  94. area: selectedRole.code.substring(0, 6),
  95. hospital: selectedRole.code
  96. }
  97. this.getTeam(selectedRole.code)
  98. }
  99. this.initTime()
  100. setTimeout(function () {
  101. vm.searchFn()
  102. }, 200)
  103. },
  104. initTime() {
  105. var vm = this
  106. var now = new Date()
  107. vm.nowyear = vm.chooseYear = now.getFullYear()
  108. vm.years = []
  109. for (i = vm.nowyear; i >= 2013; i--) {
  110. vm.years.push(i)
  111. }
  112. },
  113. searchFn() {
  114. var vm = this
  115. this.loading = true
  116. var params = {
  117. ...this.form,
  118. isTotal: 1,
  119. menu: this.header
  120. .map(function (item) {
  121. return item.prop
  122. })
  123. .join(',')
  124. }
  125. vm.tableData = []
  126. if (this.yearType == '1') {
  127. params.startDate = this.chooseYear + '-01-01'
  128. params.endDate = this.chooseYear + '-12-31'
  129. } else {
  130. if (this.chooseTime) {
  131. params.startDate = this.chooseTime[0]
  132. params.endDate = this.chooseTime[1]
  133. }
  134. }
  135. httpRequest.get('doctor/healthBank/integrateStatistics', { data: params }).then(function (res) {
  136. if (res.status == 200) {
  137. vm.tableData = res.data.list.map(function (item) {
  138. var data = JSON.parse(JSON.stringify(item))
  139. if (vm.form.range == 'town') {
  140. data.town = item.name
  141. data.hasChildren = item.code && true
  142. } else if (vm.form.range == 'hospital') {
  143. data.hospital = item.name
  144. data.hasChildren = item.code && true
  145. } else if (vm.form.range == 'team') {
  146. data.team = item.name
  147. }
  148. return data
  149. })
  150. }
  151. vm.loading = false
  152. })
  153. },
  154. exportTable() {
  155. var vm = this
  156. var params = {
  157. ...this.form,
  158. menu: this.header
  159. .map(function (item) {
  160. return item.prop
  161. })
  162. .join(',')
  163. }
  164. if (this.yearType == '1') {
  165. params.startDate = this.chooseYear + '-01-01 00:00'
  166. params.endDate = this.chooseYear + '-12-31 23:59'
  167. } else {
  168. if (this.chooseTime) {
  169. params.startDate = this.chooseTime[0] + ' 00:00'
  170. params.endDate = this.chooseTime[1] + ' 23:59'
  171. }
  172. }
  173. this.exportLoading = true
  174. var fileName = `居民积分汇总${new Date().getTime()}.xls`
  175. httpRequest.downLoadFileForAjax('doctor/healthBank/exportIntegrateStatistics', fileName, params).then(function () {
  176. vm.exportLoading = false
  177. })
  178. },
  179. eliminateClick() {
  180. var selectedRole = JSON.parse(sessionStorage.getItem('selectedRole'))
  181. if (this.level == 1) {
  182. this.form = {
  183. range: 'town'
  184. }
  185. } else if (this.level == 2) {
  186. this.form = {
  187. range: 'town',
  188. area: selectedRole.code
  189. }
  190. this.getHospital(selectedRole.code)
  191. } else {
  192. this.form = {
  193. range: 'hospital',
  194. area: selectedRole.code.substring(0, 6),
  195. hospital: selectedRole.code
  196. }
  197. this.getTeam(selectedRole.code)
  198. }
  199. this.yearType = '1'
  200. this.chooseYear = new Date().getFullYear()
  201. this.chooseTime = null
  202. this.$forceUpdate()
  203. },
  204. closeDialog() {
  205. this.dialogShow = false
  206. this.dialogShow1 = false
  207. },
  208. previewRecord(row) {
  209. var vm = this
  210. this.dialogShow = true
  211. httpRequest.get('doctor/familyBed/findCheckPlanDetail', { data: { id: row.id } }).then(function (res) {
  212. if (res.status == 200) {
  213. vm.info = res.data
  214. if (res.data.planDoctorList) {
  215. vm.info.planDoctor = res.data.planDoctorList
  216. .map(function (item) {
  217. return item.doctorName
  218. })
  219. .join(',')
  220. }
  221. if (res.data.signWay) {
  222. vm.info.signMethod = res.data.signWay == 1 ? '定位签到' : '拍照签到'
  223. }
  224. }
  225. })
  226. },
  227. getHospital(code) {
  228. var vm = this
  229. delete this.form.hospital
  230. delete this.form.team
  231. var params = {
  232. type: 5,
  233. code: code
  234. }
  235. httpRequest.post('common/district', { data: params }).then(function (res) {
  236. vm.hospitalOptions = [{ code: '', name: '全部' }]
  237. vm.hospitalOptions = vm.hospitalOptions.concat(res.list)
  238. })
  239. },
  240. resetArea() {
  241. if (this.level == 1) {
  242. delete this.form.area
  243. delete this.form.hospital
  244. delete this.form.team
  245. } else if (this.level == 2) {
  246. delete this.form.hospital
  247. delete this.form.team
  248. } else {
  249. delete this.form.team
  250. }
  251. },
  252. load(row, treeNode, resolve) {
  253. var params = {
  254. menu: this.header
  255. .map(function (item) {
  256. return item.prop
  257. })
  258. .join(',')
  259. }
  260. var len = row.code.length
  261. if (len == 6) {
  262. params.range = 'hospital'
  263. params.area = row.code
  264. } else if (len == 10) {
  265. params.range = 'team'
  266. params.hospital = row.code
  267. }
  268. if (this.yearType == '1') {
  269. params.startDate = this.chooseYear + '-01-01'
  270. params.endDate = this.chooseYear + '-12-31'
  271. } else {
  272. if (this.chooseTime) {
  273. params.startDate = this.chooseTime[0]
  274. params.endDate = this.chooseTime[1]
  275. }
  276. }
  277. httpRequest.get('doctor/healthBank/integrateStatistics', { data: params }).then(function (res) {
  278. if (res.status == 200) {
  279. var children = res.data.list.map(function (item) {
  280. var data = {
  281. ...item
  282. }
  283. if (len == 6) {
  284. data.hospital = item.name
  285. data.hasChildren = true
  286. data.town1 = row.code
  287. } else if (len == 10) {
  288. data.team = item.name
  289. data.hospital1 = row.code
  290. data.town1 = row.town1
  291. }
  292. return data
  293. })
  294. resolve(children)
  295. }
  296. })
  297. },
  298. getTeam(code) {
  299. var vm = this
  300. delete this.form.team
  301. var params = {
  302. hospital: code,
  303. area: this.form.area
  304. }
  305. httpRequest.get('statisticsExport/teamList', { data: params }).then(function (res) {
  306. vm.teamOptions = [{ id: '', name: '全部' }]
  307. vm.teamOptions = vm.teamOptions.concat(res.data)
  308. })
  309. }
  310. },
  311. mounted() {
  312. this.init()
  313. }
  314. })