|
@@ -0,0 +1,410 @@
|
|
|
+<template>
|
|
|
+ <div class="jg-page-wrap customerReportList-wrap">
|
|
|
+ <a-card size="small" :bordered="false" class="table-page-search-wrapper">
|
|
|
+ <div ref="tableSearch">
|
|
|
+ <!-- 搜索条件 -->
|
|
|
+ <a-form-model
|
|
|
+ id="customerReportList-form"
|
|
|
+ ref="ruleForm"
|
|
|
+ class="form-model-con"
|
|
|
+ layout="inline"
|
|
|
+ :model="queryParam"
|
|
|
+ :rules="rules"
|
|
|
+ :labelCol="labelCol"
|
|
|
+ :wrapperCol="wrapperCol"
|
|
|
+ @keyup.enter.native="handleSearch" >
|
|
|
+ <a-row :gutter="15">
|
|
|
+ <a-col :md="6" :sm="24">
|
|
|
+ <a-form-model-item label="查询时间" prop="time">
|
|
|
+ <rangeDate ref="rangeDate" @change="dateChange" />
|
|
|
+ </a-form-model-item>
|
|
|
+ </a-col>
|
|
|
+ <a-col :md="6" :sm="24">
|
|
|
+ <a-form-item label="产品品牌">
|
|
|
+ <ProductBrand id="salesDetailReportList-productBrandSn" placeholder="请选择产品品牌" v-model="queryParam.productBrandSn"></ProductBrand>
|
|
|
+ </a-form-item>
|
|
|
+ </a-col>
|
|
|
+ <a-col :md="6" :sm="24">
|
|
|
+ <a-form-model-item label="产品分类">
|
|
|
+ <ProductType id="chainSalesReportList-productType" placeholder="请选择产品分类" @change="changeProductType" v-model="productType"></ProductType>
|
|
|
+ </a-form-model-item>
|
|
|
+ </a-col>
|
|
|
+ <template v-if="advanced">
|
|
|
+ <a-col :md="6" :sm="24">
|
|
|
+ <a-form-model-item label="产品编码">
|
|
|
+ <a-input id="salesDetailReportList-code" v-model.trim="queryParam.productCode" allowClear placeholder="请输入产品编码"/>
|
|
|
+ </a-form-model-item>
|
|
|
+ </a-col>
|
|
|
+ <a-col :md="6" :sm="24">
|
|
|
+ <a-form-model-item label="产品名称">
|
|
|
+ <a-input id="salesDetailReportList-name" v-model.trim="queryParam.productName" allowClear placeholder="请输入产品名称"/>
|
|
|
+ </a-form-model-item>
|
|
|
+ </a-col>
|
|
|
+ </template>
|
|
|
+ <a-col :md="6" :sm="24" style="margin-bottom: 10px;">
|
|
|
+ <a-button type="primary" @click="handleSearch" :disabled="disabled" id="customerReportList-refresh">查询</a-button>
|
|
|
+ <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="customerReportList-reset">重置</a-button>
|
|
|
+ <a-button
|
|
|
+ type="primary"
|
|
|
+ style="margin-left: 5px"
|
|
|
+ @click="handleExport"
|
|
|
+ :disabled="disabled"
|
|
|
+ :loading="exportLoading"
|
|
|
+ v-if="$hasPermissions('B_salesRankingReportExport')"
|
|
|
+ class="button-warning"
|
|
|
+ id="salesDetailReportList-export-btn">导出</a-button>
|
|
|
+ <a @click="advanced=!advanced" style="margin-left: 8px">
|
|
|
+ {{ advanced ? '收起' : '展开' }}
|
|
|
+ <a-icon :type="advanced ? 'up' : 'down'"/>
|
|
|
+ </a>
|
|
|
+ </a-col>
|
|
|
+ </a-row>
|
|
|
+ </a-form-model>
|
|
|
+ </div>
|
|
|
+ </a-card>
|
|
|
+ <a-card size="small" :bordered="false">
|
|
|
+ <a-spin :spinning="spinning" tip="Loading...">
|
|
|
+ <!-- 合计 -->
|
|
|
+ <div class="table-operator">
|
|
|
+ <div class="alert-message">
|
|
|
+ 销售数量:<strong>{{ (totalData && (totalData.salesTotalQty || totalData.salesTotalQty==0)) ? totalData.salesTotalQty : '--' }}</strong>;
|
|
|
+ 销售金额:<strong>{{ (totalData && (totalData.salesTotalAmount || totalData.salesTotalAmount==0)) ? toThousands(totalData.salesTotalAmount) : '--' }}</strong>;
|
|
|
+ 销售折后金额:<strong>{{ (totalData && (totalData.salesTotalDiscountedAmount || totalData.salesTotalDiscountedAmount==0)) ? toThousands(totalData.salesTotalDiscountedAmount) : '--' }}</strong>;
|
|
|
+ <div style="display: inline-block;" v-show="showCols&&showCols.length>0">
|
|
|
+ 销售退货数量:<strong>{{ (totalData && (totalData.salesReturnTotalQty || totalData.salesReturnTotalQty==0)) ? totalData.salesReturnTotalQty : '--' }}</strong>;
|
|
|
+ 销售退货金额:<strong>{{ (totalData && (totalData.salesReturnTotalAmount || totalData.salesReturnTotalAmount==0)) ?toThousands(totalData.salesReturnTotalAmount) : '--' }}</strong>;
|
|
|
+ 销售退货折后金额:<strong>{{ (totalData && (totalData.salesReturnTotalDiscountedAmount || totalData.salesReturnTotalDiscountedAmount==0)) ? toThousands(totalData.salesReturnTotalDiscountedAmount) : '--' }}</strong>;
|
|
|
+ 销售数量合计:<strong>{{ (totalData && (totalData.totalQty || totalData.totalQty==0)) ? totalData.totalQty : '--' }}</strong>;
|
|
|
+ 销售金额合计:<strong>{{ (totalData && (totalData.totalAmount || totalData.totalAmount==0)) ? toThousands(totalData.totalAmount) : '--' }}</strong>;
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div>
|
|
|
+ <span>显示:</span>
|
|
|
+ <a-tree-select
|
|
|
+ size="small"
|
|
|
+ v-model="showCols"
|
|
|
+ style="min-width: 200px"
|
|
|
+ dropdownMatchSelectWidth
|
|
|
+ :maxTagCount="3"
|
|
|
+ :tree-data="colsArr"
|
|
|
+ tree-checkable
|
|
|
+ @change="handleShowFlag"
|
|
|
+ placeholder="请选择要显示的列(多选)"
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <!-- 列表 -->
|
|
|
+ <s-table
|
|
|
+ class="sTable"
|
|
|
+ ref="table"
|
|
|
+ size="small"
|
|
|
+ :rowKey="(record) => record.no"
|
|
|
+ rowKeyName="no"
|
|
|
+ :columns="columns"
|
|
|
+ :data="loadData"
|
|
|
+ :style="{ height: tableHeight+84+'px' }"
|
|
|
+ :scroll="{ x: 1800,y: tableHeight}"
|
|
|
+ :defaultLoadData="false"
|
|
|
+ bordered>
|
|
|
+ <!-- 产品分类 -->
|
|
|
+ <template slot="productType" slot-scope="text, record">
|
|
|
+ <span v-if="record.productTypeName2 || record.productTypeName3">{{ record.productTypeName2 }} {{ record.productTypeName3 ? '>' : '' }} {{ record.productTypeName3 }}</span>
|
|
|
+ <span v-else>--</span>
|
|
|
+ </template>
|
|
|
+ <!-- 销售数量 标题 -->
|
|
|
+ <template slot="salesNumTit">
|
|
|
+ <a-tooltip placement="top">
|
|
|
+ <template slot="title">
|
|
|
+ <span>销售单创建后开始计算销售数量</span>
|
|
|
+ </template>
|
|
|
+ <div>
|
|
|
+ <span style="margin-right:5px;">销售数量</span>
|
|
|
+ <a-icon type="question-circle" />
|
|
|
+ </div>
|
|
|
+ </a-tooltip>
|
|
|
+ </template>
|
|
|
+ <!-- 销售退货数量 标题 -->
|
|
|
+ <template slot="salesReturnNum">
|
|
|
+ <a-tooltip placement="top">
|
|
|
+ <template slot="title">
|
|
|
+ <span>销售退货单完结后开始计算销售数量</span>
|
|
|
+ </template>
|
|
|
+ <div>
|
|
|
+ <span style="margin-right:5px;">销售退货数量</span>
|
|
|
+ <a-icon type="question-circle" />
|
|
|
+ </div>
|
|
|
+ </a-tooltip>
|
|
|
+ </template>
|
|
|
+ <template slot="action" slot-scope="text, record">
|
|
|
+ <a-button
|
|
|
+ v-if="record.sysFlag==1&&$hasPermissions('B_salesRankingAddCar')"
|
|
|
+ size="small"
|
|
|
+ type="link"
|
|
|
+ class="button-primary"
|
|
|
+ @click="addShopCar(record)"
|
|
|
+ >加入购物车</a-button>
|
|
|
+ <span v-else>--</span>
|
|
|
+ </template>
|
|
|
+ </s-table>
|
|
|
+ </a-spin>
|
|
|
+ </a-card>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+import { commonMixin } from '@/utils/mixin'
|
|
|
+import { STable, VSelect } from '@/components'
|
|
|
+import rangeDate from '@/views/common/rangeDate.vue'
|
|
|
+import ProductBrand from '@/views/common/productBrand.js'
|
|
|
+import ProductType from '@/views/common/productType.js'
|
|
|
+import { downloadExcel } from '@/libs/JGPrint.js'
|
|
|
+import { purchaseCartSave } from '@/api/purchaseCart'
|
|
|
+import { salesBillRankList, salesBillRankCount, salesBillRankExport } from '@/api/reportData'
|
|
|
+export default {
|
|
|
+ mixins: [commonMixin],
|
|
|
+ name: 'SalesRankingReport',
|
|
|
+ components: { STable, VSelect, rangeDate, ProductType, ProductBrand },
|
|
|
+ data () {
|
|
|
+ return {
|
|
|
+ spinning: false,
|
|
|
+ labelCol: { span: 8 },
|
|
|
+ wrapperCol: { span: 16 },
|
|
|
+ advanced: true, // 高级搜索 展开/关闭
|
|
|
+ tableHeight: 0,
|
|
|
+ queryParam: { // 查询条件
|
|
|
+ time: [],
|
|
|
+ beginDate: '',
|
|
|
+ endDate: '',
|
|
|
+ productBrandSn: undefined,
|
|
|
+ productTypeSn1: undefined, // 产品一级分类
|
|
|
+ productTypeSn2: undefined, // 产品二级分类
|
|
|
+ productTypeSn3: undefined, // 产品三级分类
|
|
|
+ productCode: undefined,
|
|
|
+ productName: undefined
|
|
|
+ },
|
|
|
+ productType: [], // 产品分类
|
|
|
+ rules: {
|
|
|
+ 'time': [{ required: true, message: '请选择添加时间', trigger: 'change' }]
|
|
|
+ },
|
|
|
+ disabled: false, // 查询、重置按钮是否可操作
|
|
|
+ exportLoading: false,
|
|
|
+ // 加载数据方法 必须为 Promise 对象
|
|
|
+ loadData: parameter => {
|
|
|
+ this.disabled = true
|
|
|
+ const params = Object.assign(parameter, this.queryParam)
|
|
|
+ params.returnFlag = this.showCols.includes('returnFlag') ? 1 : 0
|
|
|
+ delete params.time
|
|
|
+ this.spinning = true
|
|
|
+ if (params.beginDate && params.endDate) {
|
|
|
+ return salesBillRankList(params).then(res => {
|
|
|
+ let data
|
|
|
+ if (res.status == 200) {
|
|
|
+ data = res.data
|
|
|
+ // 总计
|
|
|
+ this.getCount(params)
|
|
|
+ const no = (data.pageNo - 1) * data.pageSize
|
|
|
+ for (var i = 0; i < data.list.length; i++) {
|
|
|
+ data.list[i].no = no + i + 1
|
|
|
+ }
|
|
|
+ this.disabled = false
|
|
|
+ }
|
|
|
+ this.spinning = false
|
|
|
+ return data
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ const _this = this
|
|
|
+ return new Promise(function (resolve, reject) {
|
|
|
+ const data = {
|
|
|
+ pageNo: 1,
|
|
|
+ pageSize: 10,
|
|
|
+ list: [],
|
|
|
+ count: 0
|
|
|
+ }
|
|
|
+ _this.disabled = false
|
|
|
+ _this.spinning = false
|
|
|
+ _this.$message.info('请选择查询时间')
|
|
|
+ resolve(data)
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
+ totalData: null, // 合计
|
|
|
+ colsArr: [// 显示列表所需要的列
|
|
|
+ {
|
|
|
+ title: '销售退货(明细)',
|
|
|
+ value: 'returnFlag',
|
|
|
+ key: 'returnFlag',
|
|
|
+ disabled: false
|
|
|
+ }],
|
|
|
+ showCols: []// 选中显示的列
|
|
|
+ }
|
|
|
+ },
|
|
|
+ computed: {
|
|
|
+ columns () {
|
|
|
+ const _this = this
|
|
|
+ const arr = [
|
|
|
+ { title: '序号', dataIndex: 'no', width: 60, align: 'center' },
|
|
|
+ { title: '品牌', dataIndex: 'productBrandName', width: 100, align: 'center', customRender: function (text) { return text || '--' } },
|
|
|
+ { title: '分类', scopedSlots: { customRender: 'productType' }, width: 150, align: 'center' },
|
|
|
+ { title: '产品编码', dataIndex: 'productCode', width: 100, align: 'center', customRender: function (text) { return text || '--' } },
|
|
|
+ { title: '产品名称', dataIndex: 'productName', width: 300, align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
|
|
|
+ { title: '原厂编码', dataIndex: 'productOrigCode', width: 180, align: 'center', customRender: function (text) { return text || '--' } },
|
|
|
+ { title: '单位', dataIndex: 'productUnit', width: 80, align: 'center', customRender: function (text) { return text || '--' } },
|
|
|
+ { slots: { title: 'salesNumTit' }, dataIndex: 'salesTotalQty', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
|
|
|
+ { title: '销售金额', dataIndex: 'salesTotalAmount', width: 100, align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
|
|
|
+ { title: '销售折扣金额', dataIndex: 'salesTotalDiscountAmount', width: 110, align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
|
|
|
+ { title: '销售折后金额', dataIndex: 'salesTotalDiscountedAmount', width: 110, align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
|
|
|
+ { title: '当前库存数量', dataIndex: 'stockTotalQty', width: 110, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
|
|
|
+ { title: '当前库存金额', dataIndex: 'stockTotalCost', width: 110, align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
|
|
|
+ { title: '操作', scopedSlots: { customRender: 'action' }, width: 120, align: 'center', fixed: 'right' }
|
|
|
+ ]
|
|
|
+ if (this.$hasPermissions('M_ShowAllCost')) {
|
|
|
+ arr.splice(11, 0, { title: '销售成本金额', dataIndex: 'salesTotalCost', width: 100, align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
|
|
|
+ }
|
|
|
+ if (this.showCols.includes('returnFlag')) {
|
|
|
+ arr.splice(12, 0, { slots: { title: 'salesReturnNum' }, dataIndex: 'salesReturnTotalQty', width: 110, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
|
|
|
+ arr.splice(13, 0, { title: '销售退货金额', dataIndex: 'salesReturnTotalAmount', width: 100, align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
|
|
|
+ arr.splice(14, 0, { title: '销售退货折扣金额', dataIndex: 'salesReturnTotalDiscountAmount', width: 120, align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
|
|
|
+ arr.splice(15, 0, { title: '销售退货折后金额', dataIndex: 'salesReturnTotalDiscountedAmount', width: 120, align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
|
|
|
+ if (this.$hasPermissions('M_ShowAllCost')) {
|
|
|
+ arr.splice(16, 0, { title: '销售退货成本金额', dataIndex: 'salesReturnTotalCost', width: 120, align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
|
|
|
+ }
|
|
|
+ const pos = this.showCols.includes('returnFlag') ? 17 : 16
|
|
|
+ arr.splice(pos, 0, { title: '销售数量合计', dataIndex: 'totalQty', width: 120, align: 'right', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
|
|
|
+ arr.splice(pos * 1 + 1, 0, { title: '销售金额合计', dataIndex: 'totalAmount', width: 120, align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
|
|
|
+ }
|
|
|
+ return arr
|
|
|
+ }
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ // 统计 合计
|
|
|
+ getCount (params) {
|
|
|
+ salesBillRankCount(params).then(res => {
|
|
|
+ if (res.status == 200) {
|
|
|
+ this.totalData = res.data
|
|
|
+ } else {
|
|
|
+ this.totalData = null
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ // 创建时间 change
|
|
|
+ dateChange (date) {
|
|
|
+ this.queryParam.time = date
|
|
|
+ this.queryParam.beginDate = date[0] || ''
|
|
|
+ this.queryParam.endDate = date[1] || ''
|
|
|
+ },
|
|
|
+ // 查询
|
|
|
+ handleSearch () {
|
|
|
+ this.$refs.ruleForm.validate(valid => {
|
|
|
+ if (valid) {
|
|
|
+ this.$refs.table.refresh(true)
|
|
|
+ } else {
|
|
|
+ this.$message.error('查询时间不能为空!')
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ // 重置
|
|
|
+ resetSearchForm () {
|
|
|
+ this.$refs.rangeDate.resetDate()
|
|
|
+ this.queryParam.time = []
|
|
|
+ this.queryParam.beginDate = ''
|
|
|
+ this.queryParam.endDate = ''
|
|
|
+ this.queryParam.productBrandSn = undefined
|
|
|
+ this.queryParam.productTypeSn1 = undefined
|
|
|
+ this.queryParam.productTypeSn2 = undefined
|
|
|
+ this.queryParam.productTypeSn3 = undefined
|
|
|
+ this.queryParam.productCode = undefined
|
|
|
+ this.queryParam.productName = undefined
|
|
|
+ this.productType = []
|
|
|
+ this.$refs.ruleForm.resetFields()
|
|
|
+ this.totalData = null
|
|
|
+ this.$refs.table.clearTable()
|
|
|
+ },
|
|
|
+ // 产品分类 change
|
|
|
+ changeProductType (val, opt) {
|
|
|
+ this.queryParam.productTypeSn1 = val[0] ? val[0] : ''
|
|
|
+ this.queryParam.productTypeSn2 = val[1] ? val[1] : ''
|
|
|
+ this.queryParam.productTypeSn3 = val[2] ? val[2] : ''
|
|
|
+ },
|
|
|
+ handleExport () {
|
|
|
+ const _this = this
|
|
|
+ this.$refs.ruleForm.validate(valid => {
|
|
|
+ if (valid) {
|
|
|
+ const params = JSON.parse(JSON.stringify(_this.queryParam))
|
|
|
+ params.returnFlag = _this.showCols.includes('returnFlag') ? 1 : 0
|
|
|
+ params.showCost = this.$hasPermissions('M_ShowAllCost') ? '1' : '0'
|
|
|
+ delete params.time
|
|
|
+ _this.exportLoading = true
|
|
|
+ _this.spinning = true
|
|
|
+ salesBillRankExport(params).then(res => {
|
|
|
+ downloadExcel(res, '销售排行报表')
|
|
|
+ _this.exportLoading = false
|
|
|
+ _this.spinning = false
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ console.log('error submit!!')
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ // 判断是否显示销售退货(明细)
|
|
|
+ handleShowFlag (e) {
|
|
|
+ this.$refs.table.refresh()
|
|
|
+ },
|
|
|
+ // 加入购物车
|
|
|
+ addShopCar (row) {
|
|
|
+ this.spinning = true
|
|
|
+ purchaseCartSave({
|
|
|
+ productSn: row.productSn,
|
|
|
+ qty: 1,
|
|
|
+ productCode: row.productCode,
|
|
|
+ sysFlag: row.sysFlag
|
|
|
+ }).then(res => {
|
|
|
+ if (res.status == 200) {
|
|
|
+ this.$message.success('添加购物车成功!')
|
|
|
+ }
|
|
|
+ this.spinning = false
|
|
|
+ })
|
|
|
+ },
|
|
|
+ setTableH () {
|
|
|
+ const tableSearchH = this.$refs.tableSearch.offsetHeight
|
|
|
+ this.tableHeight = window.innerHeight - tableSearchH - 255
|
|
|
+ }
|
|
|
+ },
|
|
|
+ watch: {
|
|
|
+ advanced (newValue, oldValue) {
|
|
|
+ const _this = this
|
|
|
+ this.$nextTick(() => { // 页面渲染完成后的回调
|
|
|
+ _this.setTableH()
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
+ mounted () {
|
|
|
+ if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
|
|
|
+ this.resetSearchForm()
|
|
|
+ this.$nextTick(() => { // 页面渲染完成后的回调
|
|
|
+ this.setTableH()
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
+ activated () {
|
|
|
+ // 如果是新页签打开,则重置当前页面
|
|
|
+ if (this.$store.state.app.isNewTab) {
|
|
|
+ this.resetSearchForm()
|
|
|
+ this.$nextTick(() => { // 页面渲染完成后的回调
|
|
|
+ this.setTableH()
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
+ beforeRouteEnter (to, from, next) {
|
|
|
+ next(vm => {})
|
|
|
+ }
|
|
|
+}
|
|
|
+</script>
|
|
|
+<style lang="less" scoped>
|
|
|
+ .table-operator{
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ justify-content: space-between;
|
|
|
+ }
|
|
|
+</style>
|