123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251 |
- <template>
- <a-card :loading="loading" title="筹建类型报表">
- <div class="salesCard">
- <a-tabs default-active-key="1" size="large" :tab-bar-style="{marginBottom: '24px', paddingLeft: '16px'}">
- <div class="extra-wrapper" slot="tabBarExtraContent">
- <a-date-picker
- style="margin-left: 8px"
- :format="BaseTool.Date.PICKER_NORM_DATE_PATTERN"
- v-model="queryParam.startMonth"
- placeholder="开始时间"
- />
- <a-date-picker
- style="margin-left: 8px"
- :format="BaseTool.Date.PICKER_NORM_DATE_PATTERN"
- v-model="queryParam.endMonth"
- placeholder="结束时间"
- />
- <a-button style="margin-left: 8px" type="default" @click="getData()">查询</a-button>
- <!-- <a-button style="margin-left: 8px" type="primary" icon="printer" @click="handlePrint()">打印</a-button>-->
- <a-button style="margin-left: 8px" type="primary" @click="doExport()">导出</a-button>
- </div>
- <a-tab-pane loading="true" tab="图形统计" key="1">
- <a-row>
- <a-col :span="24">
- <div style="padding: 10px">
- <chart-view :chartOption="chartOption2" width="100%" height="600px" />
- </div>
- </a-col>
- </a-row>
- </a-tab-pane>
- <a-tab-pane loading="true" tab="表格统计" key="2">
- <a-row>
- <a-col :xl="24" :lg="24" :md="24" :sm="24" :xs="24">
- <div style="padding: 10px">
- <a-table
- bordered
- :data-source="chartsData2"
- :columns="columns2"
- tableLayout="auto"
- :scroll="{x: 1000, y: BaseTool.Constant.scrollY }"
- rowKey="month">
- <span slot="action" slot-scope="record">
- <a @click="handleView(record)">查看明细</a>
- <a-divider type="vertical" />
- <a @click="doExportDetail(record)">导出</a>
- </span>
- </a-table>
- </div>
- </a-col>
- </a-row>
- </a-tab-pane>
- </a-tabs>
- </div>
- <Detail ref="detail" />
- </a-card>
- </template>
- <script>
- import { getPreparationReportGroupByStatus, getAllPreparationReport, exportPreparationReportGroupByStatus, exportPreparationReportGroupByStatusDetail } from '@/api/preparation/preparation'
- import Detail from './modules/Detail.vue'
- export default {
- components: {
- Detail
- },
- data () {
- return {
- loading: false,
- queryParam: {
- startMonth: this.BaseTool.Date.formatter(new Date(), this.BaseTool.Date.PICKER_NORM_YEAR) + '-01-01',
- endMonth: this.BaseTool.Date.formatter(new Date(), this.BaseTool.Date.PICKER_NORM_DATE_PATTERN)
- },
- chartsData1: [],
- chartsData2: [],
- columns1: [
- {
- title: '时间',
- width: 180,
- dataIndex: 'month',
- customRender: (text, record, index) => {
- return record.year + '-' + text
- }
- },
- {
- title: '个数',
- width: 120,
- dataIndex: 'num'
- }
- ],
- columns2: [
- {
- title: '状态',
- width: 180,
- dataIndex: 'statusName'
- },
- {
- title: '个数',
- width: 120,
- dataIndex: 'num'
- },
- {
- title: '操作',
- key: 'action',
- width: '200px',
- align: 'center',
- scopedSlots: { customRender: 'action' }
- }
- ]
- }
- },
- computed: {
- chartOption1 () {
- return {
- // tooltip: {
- // trigger: 'axis',
- // axisPointer: {
- // type: 'shadow'
- // }
- // },
- legend: {},
- grid: {
- left: '3%',
- right: '4%',
- bottom: '3%',
- containLabel: true
- },
- yAxis: {
- type: 'value',
- boundaryGap: [0, 0.01]
- },
- xAxis: {
- type: 'category',
- data: this.chartsData1.map(item => (item.year + '-' + item.month))
- },
- series: [
- {
- type: 'bar',
- data: this.chartsData1.map(item => item.num),
- itemStyle: {
- normal: {
- label: {
- show: true, // 开启显示
- position: 'top', // 在上方显示
- textStyle: { // 数值样式
- color: 'black',
- fontSize: 16
- }
- }
- }
- }
- }
- ]
- }
- },
- chartOption2 () {
- return {
- tooltip: {
- },
- legend: {},
- grid: {
- left: '3%',
- right: '4%',
- bottom: '3%',
- containLabel: true
- },
- series: [
- {
- type: 'pie',
- center: ['50%', '50%'],
- roseType: 'area',
- itemStyle: {
- borderRadius: 8
- },
- label: {
- formatter: '{b}: {c}',
- fontSize: 16
- },
- data: this.chartsData2.map(item => {
- return {
- value: item.num,
- name: item.statusName
- }
- })
- }
- ]
- }
- }
- },
- created () {
- this.getData()
- },
- methods: {
- getData () {
- if (this.queryParam.startMonth) {
- this.queryParam.startMonth = this.BaseTool.Date.formatter(this.queryParam.startMonth, this.BaseTool.Date.PICKER_NORM_DATE_PATTERN)
- }
- if (this.queryParam.endMonth) {
- this.queryParam.endMonth = this.BaseTool.Date.formatter(this.queryParam.endMonth, this.BaseTool.Date.PICKER_NORM_DATE_PATTERN)
- }
- Promise.all([getAllPreparationReport(this.queryParam), getPreparationReportGroupByStatus(this.queryParam)]).then(res => {
- console.log(res)
- this.chartsData1 = res[0].data
- this.chartsData2 = res[1].data
- })
- },
- handleView (record) {
- console.log(record)
- this.$refs.detail.base(record)
- },
- doExport () {
- if (this.queryParam.startMonth) {
- this.queryParam.startMonth = this.BaseTool.Date.formatter(this.queryParam.startMonth, this.BaseTool.Date.PICKER_NORM_DATE_PATTERN)
- }
- if (this.queryParam.endMonth) {
- this.queryParam.endMonth = this.BaseTool.Date.formatter(this.queryParam.endMonth, this.BaseTool.Date.PICKER_NORM_DATE_PATTERN)
- }
- const parameter = {
- ...this.queryParam
- }
- exportPreparationReportGroupByStatus(parameter).then(file => {
- this.BaseTool.UPLOAD.downLoadExportExcel(file)
- })
- },
- doExportDetail (record) {
- if (this.queryParam.startMonth) {
- this.queryParam.startMonth = this.BaseTool.Date.formatter(this.queryParam.startMonth, this.BaseTool.Date.PICKER_NORM_DATE_PATTERN)
- }
- if (this.queryParam.endMonth) {
- this.queryParam.endMonth = this.BaseTool.Date.formatter(this.queryParam.endMonth, this.BaseTool.Date.PICKER_NORM_DATE_PATTERN)
- }
- const parameter = {
- ...this.queryParam,
- status: record.status
- }
- exportPreparationReportGroupByStatusDetail(parameter).then(file => {
- this.BaseTool.UPLOAD.downLoadExportExcel(file)
- })
- }
- }
- }
- </script>
- <style>
- </style>
|