var template = '' $.ajax('../../../component/statistics/ResidentScore/index.html', { data: {}, dataType: 'html', cache: false, timeout: 60000, async: false, error: function (res) {}, success: function (res) { template = res } }) Vue.component('resident-score', { template: template, props: { header: {} }, data() { return { years: [], yearType: '1', chooseYear: null, chooseTime: null, form: { range: 'town' }, tableData: [], dialogShow: false, info: {}, loading: false, exportLoading: false, rangeOptions: [ { label: '区', value: 'town' }, { label: '社区', value: 'hospital' }, { label: '团队', value: 'team' } ], areaOptions: [ { label: '思明区', value: '350203' }, { label: '海沧区', value: '350205' }, { label: '湖里区', value: '350206' }, { label: '集美区', value: '350211' }, { label: '同安区', value: '350212' }, { label: '翔安区', value: '350213' } ], level: 0, tableHeader: [] } }, watch: { header: { handler() { if (this.form.range == 'town') { this.tableHeader = getTownHeader().concat(this.header) } else if (this.form.range == 'hospital') { this.tableHeader = getHospitalHeader().concat(this.header) } else { this.tableHeader = getTeamHeader().concat(this.header) } } } }, methods: { init() { var vm = this 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) } else { this.level = 3 // 社区管理 this.rangeOptions = [ { label: '社区', value: 'hospital' }, { label: '团队', value: 'team' } ] this.areaOptions = [{ label: selectedRole.name.substring(0, 3), value: selectedRole.code.substring(0, 6) }] this.hospitalOptions = [{ name: selectedRole.name, code: selectedRole.code }] this.form = { range: 'hospital', area: selectedRole.code.substring(0, 6), hospital: selectedRole.code } this.getTeam(selectedRole.code) } this.initTime() setTimeout(function () { vm.searchFn() }, 200) }, 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, isTotal: 1, menu: this.header .map(function (item) { return item.prop }) .join(',') } 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] } } httpRequest.get('doctor/healthBank/integrateStatistics', { data: params }).then(function (res) { if (res.status == 200) { vm.tableData = res.data.list.map(function (item) { var data = JSON.parse(JSON.stringify(item)) if (vm.form.range == 'town') { data.town = item.name data.hasChildren = item.code && true } else if (vm.form.range == 'hospital') { data.hospital = item.name data.hasChildren = item.code && true } else if (vm.form.range == 'team') { data.team = item.name } return data }) } vm.loading = false }) }, exportTable() { var vm = this var params = { ...this.form, menu: this.header .map(function (item) { return item.prop }) .join(',') } if (this.yearType == '1') { params.startDate = this.chooseYear + '-01-01 00:00' params.endDate = this.chooseYear + '-12-31 23:59' } 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('doctor/healthBank/exportIntegrateStatistics', 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) } else { this.form = { range: 'hospital', area: selectedRole.code.substring(0, 6), hospital: selectedRole.code } this.getTeam(selectedRole.code) } this.yearType = '1' this.chooseYear = new Date().getFullYear() this.chooseTime = null this.$forceUpdate() }, closeDialog() { this.dialogShow = false this.dialogShow1 = false }, previewRecord(row) { var vm = this this.dialogShow = true httpRequest.get('doctor/familyBed/findCheckPlanDetail', { data: { id: row.id } }).then(function (res) { if (res.status == 200) { vm.info = res.data if (res.data.planDoctorList) { vm.info.planDoctor = res.data.planDoctorList .map(function (item) { return item.doctorName }) .join(',') } if (res.data.signWay) { vm.info.signMethod = res.data.signWay == 1 ? '定位签到' : '拍照签到' } } }) }, 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 } }, load(row, treeNode, resolve) { var params = { menu: this.header .map(function (item) { return item.prop }) .join(',') } var len = row.code.length if (len == 6) { params.range = 'hospital' params.area = row.code } else if (len == 10) { params.range = 'team' params.hospital = row.code } 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] } } httpRequest.get('doctor/healthBank/integrateStatistics', { data: params }).then(function (res) { if (res.status == 200) { var children = res.data.list.map(function (item) { var data = { ...item } if (len == 6) { data.hospital = item.name data.hasChildren = true data.town1 = row.code } else if (len == 10) { data.team = item.name data.hospital1 = row.code data.town1 = row.town1 } return data }) resolve(children) } }) }, getTeam(code) { var vm = this delete this.form.team var params = { hospital: code, area: this.form.area } httpRequest.get('statisticsExport/teamList', { data: params }).then(function (res) { vm.teamOptions = [{ id: '', name: '全部' }] vm.teamOptions = vm.teamOptions.concat(res.data) }) } }, mounted() { this.init() } })