var template = '' $.ajax('../../../component/statistics/ResidentScoreDetail/index.html', { data: {}, dataType: 'html', cache: false, timeout: 60000, async: false, error: function (res) {}, success: function (res) { template = res } }) Vue.component('resident-score-detail', { template: template, data() { return { years: [], yearType: '1', chooseYear: null, chooseTime: null, form: { range: 'town' }, tableData: [], info: {}, loading: false, exportLoading: false, rangeOptions: [ { label: '按区', value: 'town' }, { label: '按社区', value: 'hospital' } ], areaOptions: [ { label: '思明区', value: '350203' }, { label: '海沧区', value: '350205' }, { label: '湖里区', value: '350206' }, { label: '集美区', value: '350211' }, { label: '同安区', value: '350212' }, { label: '翔安区', value: '350213' } ], level: 0, tableHeader: [], page: 1, size: 10, total: 0 } }, methods: { init() { var selectedRole = JSON.parse(sessionStorage.getItem('selectedRole')) if (selectedRole.code.indexOf('350200') > -1) { this.level = 1 // 市卫健委 this.areaOptions = [ { label: '思明区', value: '350203' }, { label: '海沧区', value: '350205' }, { label: '湖里区', value: '350206' }, { label: '集美区', value: '350211' }, { label: '同安区', value: '350212' }, { label: '翔安区', value: '350213' } ] } else if (selectedRole.code.length == 6) { this.level = 2 // 区管理 this.areaOptions = [{ label: selectedRole.name.substring(0, 3), value: selectedRole.code }] this.form = { range: 'town', area: selectedRole.code } this.getHospital(selectedRole.code) } this.initTime() this.searchFn() }, initTime() { var vm = this var now = new Date() vm.nowyear = vm.chooseYear = now.getFullYear() vm.years = [] for (i = vm.nowyear; i >= 2013; i--) { vm.years.push(i) } }, searchFn() { var vm = this this.loading = true var params = { ...this.form, page: this.page, pageSize: this.size } vm.tableData = [] if (this.yearType == '1') { params.startDate = this.chooseYear + '-01-01' params.endDate = this.chooseYear + '-12-31' } else { if (this.chooseTime) { params.startDate = this.chooseTime[0] params.endDate = this.chooseTime[1] } } statisticAPI.patinetIntegralAnalysis(params).then(function (res) { if (res.status == 200) { res.data.list.forEach(function (item) { item.ssc = item.ssc.replace(/^(.{4})(?:\d+)(.{1})$/, '$1****$2') // item.idcard = item.idcard.replace(/^(.{6})(?:\d+)(.{4})$/,"$1****$2") }) vm.tableData = res.data.list vm.total = res.data.total } vm.loading = false }) }, exportTable() { var vm = this var params = { ...this.form, page: 1, pageSize: 99999 } if (this.yearType == '1') { params.signYear = this.chooseYear } else { if (this.chooseTime) { params.startDate = this.chooseTime[0] + ' 00:00' params.endDate = this.chooseTime[1] + ' 23:59' } } this.exportLoading = true var fileName = `居民积分明细${new Date().getTime()}.xls` httpRequest.downLoadFileForAjax('statisticsExport/exPatinetIntegralAnalysis', fileName, params).then(function () { vm.exportLoading = false }) }, eliminateClick() { var selectedRole = JSON.parse(sessionStorage.getItem('selectedRole')) if (this.level == 1) { this.form = { range: 'town' } } else if (this.level == 2) { this.form = { range: 'town', area: selectedRole.code } this.getHospital(selectedRole.code) } this.yearType = '1' this.chooseYear = new Date().getFullYear() this.chooseTime = null this.$forceUpdate() }, getHospital(code) { var vm = this delete this.form.hospital delete this.form.team var params = { type: 5, code: code } httpRequest.post('common/district', { data: params }).then(function (res) { vm.hospitalOptions = [{ code: '', name: '全部' }] vm.hospitalOptions = vm.hospitalOptions.concat(res.list) }) }, resetArea() { if (this.level == 1) { delete this.form.area delete this.form.hospital delete this.form.team } else if (this.level == 2) { delete this.form.hospital delete this.form.team } else { delete this.form.team } }, handleCurrentChange(val) { this.page = val this.searchFn() }, handleSizeChange(val) { this.size = val this.searchFn() } }, mounted() { this.init() } })