123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427 |
- <template>
- <div class="page-header-index-wide">
- <a-card title="采购报表" :loading="loading" v-show="visible" :bordered="false" :body-style="{padding: '0'}">
- <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"
- :default-value="moment(defaultStartMonth, monthFormat)"
- :format="monthFormat"
- showTime
- v-model="queryParam.createdTimeStart"
- placeholder="开始月份"
- @change="onStartChange" />
- <a-date-picker
- style="margin-left: 8px"
- :default-value="moment(defaultEndMonth, monthFormat)"
- :format="monthFormat"
- showTime
- v-model="queryParam.createdTimeEnd"
- placeholder="结束月份"
- @change="onEndChange" />
- <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 :xl="12" :lg="12" :md="12" :sm="24" :xs="24">
- <chart-view :chartOption="chartOption1" width="100%" height="600px" />
- </a-col>
- <a-col :xl="12" :lg="12" :md="12" :sm="24" :xs="24">
- <chart-view :chartOption="chartOption2" width="100%" height="600px" />
- </a-col>
- <a-col :xl="12" :lg="12" :md="12" :sm="24" :xs="24">
- <chart-view :chartOption="chartOption3" width="100%" height="600px" />
- </a-col>
- <a-col :xl="12" :lg="12" :md="12" :sm="24" :xs="24">
- <chart-view :chartOption="chartOption4" width="100%" height="600px" />
- </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="chartsData"
- :columns="columns"
- tableLayout="auto"
- :scroll="{x: 1, y: BaseTool.Constant.scrollY }"
- rowKey="month">
- <span slot="action" slot-scope="record">
- <template>
- <a @click="handleView(record)">查看明细</a>
- <a-divider type="vertical" />
- <a @click="doExportDetail(record)">导出</a>
- </template>
- </span>
- </a-table>
- </div>
- </a-col>
- </a-row>
- </a-tab-pane> -->
- </a-tabs>
- </div>
- </a-card>
- <print-in-repair-report ref="basePrintModal" @ok="handleOk"/>
- <detail ref="detailModal" @ok="handleOk"/>
- </div>
- </template>
- <script>
- import { Chart } from '@antv/g2'
- import PrintInRepairReport from '@/views/dashboard/modules/PrintInRepairReport'
- import Detail from './modules/Detail'
- import moment from 'moment'
- import { getPieByCondition, exportOrder, exportOrderDetail } from '@/api/purchase/purchase-order'
- export default {
- name: 'Analysis',
- components: {
- PrintInRepairReport,
- Chart,
- Detail
- },
- props: {
- /**
- * 检查类型: 1->24小时非计划性维修 2-全部维修(不包括其他临时完善维修)
- */
- searchType: {
- type: Number,
- default: 1
- },
- title: {
- type: String,
- default: '大于24小时非计划性维修'
- }
- },
- data () {
- return {
- loading: false,
- serverData: [],
- monthFormat: 'YYYY-MM-DD',
- defaultStartMonth: this.BaseTool.Moment().format(this.BaseTool.Date.PICKER_NORM_YEAR_MONTH) + '-01 00:00:00',
- defaultEndMonth: this.BaseTool.Moment().format(this.BaseTool.Date.PICKER_NORM_DATETIME_PATTERN),
- queryParam: {
- // year: 2021,
- createdTimeStart: this.BaseTool.Moment().format(this.BaseTool.Date.PICKER_NORM_YEAR_MONTH) + '-01 00:00:00',
- createdTimeEnd: this.BaseTool.Moment().format(this.BaseTool.Date.PICKER_NORM_DATETIME_PATTERN)
- },
- visible: true,
- chart: null, // 创建一个chart变量
- chartsData: [[], [], [], []],
- // 表头
- columns: [
- {
- title: '采购单状态',
- width: 180,
- dataIndex: 'purchaseType',
- customRender: (text, record, index) => {
- return this.BaseTool.Table.getMapText(this.typeMap, text)
- }
- },
- {
- title: '采购单总数',
- width: 120,
- dataIndex: 'orderTotalNum'
- },
- {
- title: '备件总数',
- width: 120,
- dataIndex: 'spareTotalNum'
- },
- {
- title: '操作',
- key: 'action',
- width: '200px',
- align: 'center',
- scopedSlots: { customRender: 'action' }
- }
- ],
- typeMap: {},
- cptcodeMap: {}
- }
- },
- computed: {
- chartOption1 () {
- console.log(this.chartsData)
- const data = this.chartsData[1].map(item => {
- return {
- value: item.num,
- name: this.cptcodeMap[item.type]
- }
- })
- return {
- title: {
- left: 'center',
- text: '采购类型统计'
- },
- legend: {
- top: '10%'
- },
- grid: {
- left: '3%',
- right: '4%',
- bottom: '3%',
- containLabel: true
- },
- series: [
- {
- type: 'pie',
- center: ['50%', '50%'],
- radius: [0, 100],
- label: {
- formatter: `{b}:{c}`,
- textBorderColor: '#000',
- textBorderWidth: 0,
- fontSize: 16,
- overflow: 'breakAll',
- labelLine: {
- length: 3
- }
- },
- data: data
- }
- ]
- }
- },
- chartOption2 () {
- console.log(this.chartsData)
- const data = this.chartsData[2].map(item => {
- return {
- value: item.num,
- name: item.type
- }
- })
- return {
- title: {
- left: 'center',
- text: '业务类型统计'
- },
- legend: {
- top: '10%'
- },
- grid: {
- left: '3%',
- right: '4%',
- bottom: '3%',
- containLabel: true
- },
- series: [
- {
- type: 'pie',
- center: ['50%', '50%'],
- radius: [0, 100],
- label: {
- formatter: `{b}:{c}`,
- textBorderColor: '#000',
- textBorderWidth: 0,
- fontSize: 16,
- overflow: 'breakAll',
- labelLine: {
- length: 3
- }
- },
- data: data
- }
- ]
- }
- },
- chartOption3 () {
- console.log(this.chartsData)
- const data = this.chartsData[3].map(item => {
- return {
- value: item.num,
- name: this.flagMap[item.type]
- }
- })
- return {
- title: {
- left: 'center',
- text: '采购厂区统计'
- },
- legend: {
- top: '10%'
- },
- grid: {
- left: '3%',
- right: '4%',
- bottom: '3%',
- containLabel: true
- },
- series: [
- {
- type: 'pie',
- center: ['50%', '50%'],
- radius: [0, 100],
- label: {
- formatter: `{b}:{c}`,
- textBorderColor: '#000',
- textBorderWidth: 0,
- fontSize: 16,
- overflow: 'breakAll',
- labelLine: {
- length: 3
- }
- },
- data: data
- }
- ]
- }
- },
- chartOption4 () {
- console.log(this.chartsData)
- const data = this.chartsData[4].map(item => {
- return {
- value: item.num,
- name: this.deptMap[item.type]
- }
- })
- return {
- title: {
- left: 'center',
- text: '申请部门统计'
- },
- legend: {
- top: '10%'
- },
- grid: {
- left: '3%',
- right: '4%',
- bottom: '3%',
- containLabel: true
- },
- series: [
- {
- type: 'pie',
- center: ['50%', '50%'],
- radius: [0, 100],
- label: {
- formatter: `{b}:{c}`,
- textBorderColor: '#000',
- textBorderWidth: 0,
- fontSize: 16,
- overflow: 'breakAll',
- labelLine: {
- length: 3
- }
- },
- data: data
- }
- ]
- }
- }
- },
- created () {
- this.typeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.LONG_YAN_PURCHASE_TYPE)
- this.cptcodeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.LONG_YAN_PURCHASE_ORDER_PLAN_TYPE)
- this.flagMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.PROJECT_NEW_AND_OLD)
- this.deptMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.YONG_YOU_DEPT)
- },
- mounted () {
- this.$nextTick(function () {
- this.getData()
- })
- },
- methods: {
- moment,
- onStartChange (date, dateString) {
- this.queryParam.createdTimeStart = this.BaseTool.Date.formatter(date, this.BaseTool.Date.PICKER_NORM_DATETIME_PATTERN)
- },
- onEndChange (date, dateString) {
- console.log(date)
- this.queryParam.createdTimeEnd = this.BaseTool.Date.formatter(date, this.BaseTool.Date.PICKER_NORM_DATETIME_PATTERN)
- },
- getData () {
- getPieByCondition()
- .then(res => {
- this.chartsData = res.data
- })
- },
- doExport () {
- const parameter = {
- ...this.queryParam
- }
- exportOrder(parameter).then(file => {
- this.BaseTool.UPLOAD.downLoadExportExcel(file)
- })
- },
- doExportDetail (record) {
- const parameter = {
- ...this.queryParam,
- type: record.purchaseType
- }
- exportOrderDetail(parameter).then(file => {
- this.BaseTool.UPLOAD.downLoadExportExcel(file)
- })
- },
- handlePrint (record) {
- const modal = this.$refs.basePrintModal
- this.visible = false
- modal.base({ createdTimeStart: this.queryParam.createdTimeStart, createdTimeEnd: this.queryParam.createdTimeEnd, title: this.title, data: this.chartsData })
- },
- handleView (record) {
- console.log(111)
- console.log(record)
- const modal = this.$refs.detailModal
- modal.base(record)
- },
- handleOk () {
- this.visible = true
- }
- }
- }
- </script>
- <style lang="less" scoped>
- .extra-wrapper {
- line-height: 55px;
- padding-right: 24px;
- .extra-item {
- display: inline-block;
- margin-right: 24px;
- a {
- margin-left: 24px;
- }
- }
- }
- .antd-pro-pages-dashboard-analysis-twoColLayout {
- position: relative;
- display: flex;
- display: block;
- flex-flow: row wrap;
- }
- .antd-pro-pages-dashboard-analysis-salesCard {
- height: calc(100% - 24px);
- /deep/ .ant-card-head {
- position: relative;
- }
- }
- .dashboard-analysis-iconGroup {
- i {
- margin-left: 16px;
- color: rgba(0,0,0,.45);
- cursor: pointer;
- transition: color .32s;
- color: black;
- }
- }
- .analysis-salesTypeRadio {
- position: absolute;
- right: 54px;
- bottom: 12px;
- }
- </style>
|