|
@@ -0,0 +1,279 @@
|
|
|
+<template>
|
|
|
+ <div>
|
|
|
+ <a-card size="small" :bordered="false" class="regionTypeBusinessReportList-wrap searchBoxNormal">
|
|
|
+ <!-- 搜索条件 -->
|
|
|
+ <div class="table-page-search-wrapper" ref="tableSearch">
|
|
|
+ <a-form-model
|
|
|
+ id="regionTypeBusinessReportList-form"
|
|
|
+ ref="ruleForm"
|
|
|
+ class="form-model-con"
|
|
|
+ layout="inline"
|
|
|
+ :rules="rules"
|
|
|
+ :model="queryParam">
|
|
|
+ <a-row :gutter="15">
|
|
|
+ <a-col :md="6" :sm="24">
|
|
|
+ <a-form-model-item label="查询月份" prop="queryDate">
|
|
|
+ <a-month-picker
|
|
|
+ id="regionTypeBusinessReportList-monthBox"
|
|
|
+ class="monthBox"
|
|
|
+ :disabled-date="disabledDate"
|
|
|
+ v-model="monthVal"
|
|
|
+ placeholder="请选择月份"
|
|
|
+ @change="onChangeMonth" />
|
|
|
+ </a-form-model-item>
|
|
|
+ </a-col>
|
|
|
+ <a-col :md="6" :sm="24">
|
|
|
+ <a-form-model-item label="客户名称">
|
|
|
+ <dealerSubareaScopeList ref="dealerSubareaScopeList" id="regionTypeBusinessReportList-dealerName" @change="custChange" />
|
|
|
+ </a-form-model-item>
|
|
|
+ </a-col>
|
|
|
+ <a-col :md="6" :sm="24">
|
|
|
+ <a-form-model-item label="地区">
|
|
|
+ <Area id="regionTypeBusinessReportList-areaList" v-model="queryParam.provinceSn" @change="areaChange" placeholder="请选择省份"></Area>
|
|
|
+ </a-form-model-item>
|
|
|
+ </a-col>
|
|
|
+ <a-col :md="6" :sm="24">
|
|
|
+ <a-button
|
|
|
+ type="primary"
|
|
|
+ @click="handleSearch"
|
|
|
+ :disabled="disabled"
|
|
|
+ id="regionTypeBusinessReportList-refresh">查询</a-button>
|
|
|
+ <a-button
|
|
|
+ style="margin-left: 8px"
|
|
|
+ @click="resetSearchForm"
|
|
|
+ :disabled="disabled"
|
|
|
+ id="regionTypeBusinessReportList-reset">重置</a-button>
|
|
|
+ <a-button
|
|
|
+ style="margin-left: 10px"
|
|
|
+ type="primary"
|
|
|
+ class="button-warning"
|
|
|
+ @click="handleExport"
|
|
|
+ :disabled="disabled"
|
|
|
+ :loading="exportLoading"
|
|
|
+ v-if="$hasPermissions('B_tireFeeExport')"
|
|
|
+ id="regionTypeBusinessReportList-export">导出</a-button>
|
|
|
+ </a-col>
|
|
|
+ </a-row>
|
|
|
+ </a-form-model>
|
|
|
+ </div>
|
|
|
+ </a-card>
|
|
|
+ <a-card size="small" :bordered="false">
|
|
|
+ <a-spin :spinning="spinning" tip="Loading...">
|
|
|
+ <!-- 列表 -->
|
|
|
+ <s-table
|
|
|
+ class="sTable fixPagination"
|
|
|
+ ref="table"
|
|
|
+ size="small"
|
|
|
+ :rowKey="(record) => record.no"
|
|
|
+ rowKeyName="no"
|
|
|
+ :style="{ height: tableHeight+70+'px' }"
|
|
|
+ :columns="columns"
|
|
|
+ :data="loadData"
|
|
|
+ :scroll="{ y: tableHeight-120}"
|
|
|
+ :defaultLoadData="false"
|
|
|
+ :showPagination="false"
|
|
|
+ bordered>
|
|
|
+ </s-table>
|
|
|
+ </a-spin>
|
|
|
+ </a-card>
|
|
|
+ <!-- 导出提示框 -->
|
|
|
+ <reportModal :visible="showExport" @close="showExport=false"></reportModal>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+import { commonMixin } from '@/utils/mixin'
|
|
|
+import { hdExportExcel } from '@/libs/exportExcel'
|
|
|
+import moment from 'moment'
|
|
|
+// 组件
|
|
|
+import { STable, VSelect } from '@/components'
|
|
|
+import Area from '@/views/common/area.js'
|
|
|
+import reportModal from '@/views/common/reportModal.vue'
|
|
|
+import dealerSubareaScopeList from '@/views/common/dealerSubareaScopeList.vue'
|
|
|
+import getDate from '@/libs/getDate'
|
|
|
+// 接口
|
|
|
+import { manageAnalysisReportQuery, manageAnalysisReportExport } from '@/api/reportData'
|
|
|
+export default {
|
|
|
+ name: 'RegionTypeBusinessReportList',
|
|
|
+ mixins: [commonMixin],
|
|
|
+ components: { STable, VSelect, Area, dealerSubareaScopeList, reportModal },
|
|
|
+ data () {
|
|
|
+ return {
|
|
|
+ spinning: false,
|
|
|
+ disabled: false, // 查询、重置按钮是否可操作
|
|
|
+ advanced: true, // 高级搜索 展开/关闭
|
|
|
+ tableHeight: 0, // 表格高度
|
|
|
+ exportLoading: false, // 导出按钮加载状态
|
|
|
+ showExport: false, // 导出弹窗
|
|
|
+ monthVal: moment().format('YYYY-MM'), // 初始化月份值
|
|
|
+ // 查询条件
|
|
|
+ queryParam: {
|
|
|
+ queryDate: moment().format('YYYYMM'), // 选择月份
|
|
|
+ beginDate: getDate.getCurrLastMonthDays().starttime, // 开始日期
|
|
|
+ endDate: getDate.getCurrLastMonthDays().endtime, // 结束日期
|
|
|
+ dealerName: undefined, // 客户名称
|
|
|
+ provinceName: undefined, // 省
|
|
|
+ provinceSn: undefined
|
|
|
+ },
|
|
|
+ rules: {
|
|
|
+ 'queryDate': [{ required: true, message: '请选择查询月份', trigger: 'change' }]
|
|
|
+ },
|
|
|
+ // 加载数据方法 必须为 Promise 对象
|
|
|
+ loadData: parameter => {
|
|
|
+ this.disabled = true
|
|
|
+ this.spinning = true
|
|
|
+ const { beginDate, endDate, dealerName, provinceName } = this.queryParam
|
|
|
+ const params = Object.assign(parameter, { beginDate, endDate, dealerName, provinceName })
|
|
|
+ // 获取列表数据 有分页
|
|
|
+ return manageAnalysisReportQuery(params).then(res => {
|
|
|
+ let data
|
|
|
+ if (res.status == 200) {
|
|
|
+ data = res.data
|
|
|
+ this.disabled = false
|
|
|
+ }
|
|
|
+ this.spinning = false
|
|
|
+ return data
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ watch: {
|
|
|
+ advanced (newValue, oldValue) {
|
|
|
+ const _this = this
|
|
|
+ this.$nextTick(() => { // 页面渲染完成后的回调
|
|
|
+ _this.setTableH()
|
|
|
+ })
|
|
|
+ },
|
|
|
+ '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
|
|
|
+ this.setTableH()
|
|
|
+ }
|
|
|
+ },
|
|
|
+ computed: {
|
|
|
+ columns () {
|
|
|
+ const arr = [
|
|
|
+ { title: '类别', dataIndex: 'category', width: '20%', align: 'center', customRender: function (text) { return (text || text == 0) || '--' } },
|
|
|
+ { title: '成本', dataIndex: 'cost', width: '10%', align: 'center', customRender: function (text) { return (text || text == 0) || '--' } },
|
|
|
+ { title: '销售额', dataIndex: 'amount', width: '10%', align: 'center', customRender: function (text) { return (text || text == 0) || '--' } },
|
|
|
+ { title: '毛利', dataIndex: 'gross', width: '10%', align: 'center', customRender: function (text) { return (text || text == 0) || '--' } },
|
|
|
+ { title: '毛利率', dataIndex: 'grossMargin', width: '10%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
|
|
|
+ { title: '促销费用', dataIndex: 'promo', width: '10%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
|
|
|
+ { title: '减促销费用的毛利', dataIndex: 'removePromoGross', width: '15%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
|
|
|
+ { title: '促销费用占比', dataIndex: 'promoRatio', width: '15%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } }
|
|
|
+ ]
|
|
|
+ return arr
|
|
|
+ }
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ // 选择月份 禁用选择当月以后日期
|
|
|
+ disabledDate (current) {
|
|
|
+ return current && current >= moment().endOf('day')
|
|
|
+ },
|
|
|
+ // 选择月份 change
|
|
|
+ onChangeMonth (date, dateString) {
|
|
|
+ this.monthVal = dateString
|
|
|
+ if (date && dateString != '') {
|
|
|
+ this.queryParam.queryDate = dateString.replace('-', '')
|
|
|
+ const { beginDate, endDate } = getDate.getBeDateByMonth(dateString)
|
|
|
+ this.queryParam.beginDate = beginDate
|
|
|
+ this.queryParam.endDate = endDate
|
|
|
+ } else {
|
|
|
+ this.queryParam.queryDate = void 0
|
|
|
+ this.queryParam.beginDate = undefined
|
|
|
+ this.queryParam.endDate = undefined
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 查询
|
|
|
+ handleSearch () {
|
|
|
+ const _this = this
|
|
|
+ this.$refs.ruleForm.validate(valid => {
|
|
|
+ if (valid) {
|
|
|
+ _this.$refs.table.refresh(true)
|
|
|
+ } else {
|
|
|
+ _this.$message.error('请选择查询月份')
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ // 客户名称 change
|
|
|
+ custChange (val) {
|
|
|
+ this.queryParam.dealerName = val.name
|
|
|
+ },
|
|
|
+ // 地区
|
|
|
+ areaChange (val, item) {
|
|
|
+ this.queryParam.provinceName = item.name
|
|
|
+ },
|
|
|
+ // 重置
|
|
|
+ resetSearchForm () {
|
|
|
+ this.monthVal = moment().format('YYYY-MM')
|
|
|
+ this.queryParam.queryDate = moment().format('YYYYMM')
|
|
|
+ this.queryParam.provinceName = undefined
|
|
|
+ this.queryParam.provinceSn = undefined
|
|
|
+ this.queryParam.dealerName = undefined
|
|
|
+ this.queryParam.beginDate = getDate.getCurrLastMonthDays().starttime
|
|
|
+ this.queryParam.endDate = getDate.getCurrLastMonthDays().endtime
|
|
|
+ if (this.$refs.dealerSubareaScopeList) {
|
|
|
+ this.$refs.dealerSubareaScopeList.resetForm()
|
|
|
+ }
|
|
|
+ this.$refs.ruleForm.resetFields()
|
|
|
+ this.handleSearch()
|
|
|
+ },
|
|
|
+ // 导出 必填判断
|
|
|
+ handleExport () {
|
|
|
+ const _this = this
|
|
|
+ this.$refs.ruleForm.validate(valid => {
|
|
|
+ if (valid) {
|
|
|
+ _this.exportList()
|
|
|
+ } else {
|
|
|
+ _this.$message.error('请选择月份')
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ // 导出
|
|
|
+ exportList () {
|
|
|
+ const _this = this
|
|
|
+ const params = JSON.parse(JSON.stringify(_this.queryParam))
|
|
|
+ _this.exportLoading = true
|
|
|
+ _this.spinning = true
|
|
|
+ _this.showExport = true
|
|
|
+ hdExportExcel(manageAnalysisReportExport, params, '各品类经营分析表-' + this.monthVal, function () {
|
|
|
+ _this.exportLoading = false
|
|
|
+ _this.spinning = false
|
|
|
+ })
|
|
|
+ },
|
|
|
+ // 初始化
|
|
|
+ pageInit () {
|
|
|
+ this.$nextTick(() => { // 页面渲染完成后的回调
|
|
|
+ this.setTableH()
|
|
|
+ })
|
|
|
+ },
|
|
|
+ // 计算表格高度
|
|
|
+ setTableH () {
|
|
|
+ const tableSearchH = this.$refs.tableSearch.offsetHeight
|
|
|
+ this.tableHeight = window.innerHeight - tableSearchH - 280
|
|
|
+ }
|
|
|
+ },
|
|
|
+ mounted () {
|
|
|
+ if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
|
|
|
+ this.pageInit()
|
|
|
+ }
|
|
|
+ },
|
|
|
+ activated () {
|
|
|
+ // 如果是新页签打开,则重置当前页面
|
|
|
+ if (this.$store.state.app.isNewTab) {
|
|
|
+ this.pageInit()
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+</script>
|
|
|
+<style lang="less" scoped>
|
|
|
+ .monthBox{
|
|
|
+ width: 100%;
|
|
|
+ /deep/.ant-calendar-picker-icon{
|
|
|
+ display:none !important;
|
|
|
+ }
|
|
|
+ /deep/.ant-calendar-picker input{
|
|
|
+ text-align:center;
|
|
|
+ }
|
|
|
+ }
|
|
|
+</style>
|