123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458 |
- <template>
- <a-spin :spinning="spinning" tip="Loading...">
- <a-alert :show-icon="false" type="error" message="注:销售单报表包含急件销售数量、售价,销售明细报表不包含急件销售数量、成本、售价" banner style="margin-bottom: 10px;" />
- <!-- 搜索条件 -->
- <div class="table-page-search-wrapper">
- <a-form-model
- id="salesDetailReportList-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="创建时间">
- <rangeDate id="salesDetailReportList-creatDate" ref="creatDate" v-model="creatTime" @change="creatDateChange" />
- </a-form-model-item>
- </a-col>
- <template v-if="advanced">
- <a-col :md="6" :sm="24">
- <a-form-model-item label="客户名称">
- <custList id="salesDetailReportList-salesTargetName" ref="custSatelliteList" @change="custSatelliteChange"></custList>
- </a-form-model-item>
- </a-col>
- <a-col :md="6" :sm="24">
- <a-form-item label="客户类型">
- <custType id="salesDetailReportList-salesTarget" v-model="queryParam.salesTargetType" allowClear placeholder="请选择客户类型"></custType>
- </a-form-item>
- </a-col>
- <a-col :md="6" :sm="24">
- <a-form-model-item label="收款方式">
- <v-select
- code="SETTLE_STYLE"
- id="salesDetailReportList-settleStyleSn"
- v-model="queryParam.settleStyleSn"
- allowClear
- placeholder="请选择收款方式"
- ></v-select>
- </a-form-model-item>
- </a-col>
- <a-col :md="6" :sm="24">
- <a-form-model-item label="审核时间">
- <rangeDate id="salesDetailReportList-rangeDate" ref="rangeDate" v-model="time" @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.productEntity.productBrandSn"></ProductBrand>
- </a-form-item>
- </a-col>
- <a-col :md="6" :sm="24">
- <a-form-model-item label="产品分类">
- <ProductType
- id="salesDetailReportList-productType"
- placeholder="请选择产品分类"
- :level="2"
- :isDealer="true"
- @change="changeProductType"
- v-model="productType"></ProductType>
- </a-form-model-item>
- </a-col>
- <a-col :md="6" :sm="24">
- <a-form-model-item label="产品编码">
- <a-input id="salesDetailReportList-code" v-model.trim="queryParam.productEntity.code" allowClear placeholder="请输入产品编码"/>
- </a-form-model-item>
- </a-col>
- <a-col :md="6" :sm="24">
- <a-form-item label="出库时间">
- <rangeDate id="salesDetailReportList-outWareTime" ref="outWareRangeDate" v-model="outWareTime" @change="outWareDateChange" />
- </a-form-item>
- </a-col>
- <a-col :md="6" :sm="24">
- <a-form-model-item label="产品名称">
- <a-input id="salesDetailReportList-name" v-model.trim="queryParam.productEntity.name" allowClear placeholder="请输入产品名称"/>
- </a-form-model-item>
- </a-col>
- <a-col :md="6" :sm="24">
- <a-form-model-item label="仓库仓位">
- <a-cascader
- v-model="queryParam.warehouseCascade"
- expand-trigger="hover"
- :options="warehouseCascadeData"
- :fieldNames="{ label: 'name', value: 'sn', children: 'warehouseLocationList' }"
- id="salesDetailReportList-warehouseCascade"
- placeholder="请选择仓库仓位"
- @change="warehouseCascadeChange"
- allowClear
- style="width: 100%;" />
- </a-form-model-item>
- </a-col>
- <a-col :md="6" :sm="24">
- <a-form-model-item label="单号">
- <a-input id="salesDetailReportList-salesBillNo" v-model.trim="queryParam.salesBillNo" allowClear placeholder="请输入单号"/>
- </a-form-model-item>
- </a-col>
- <a-col :md="6" :sm="24">
- <a-form-model-item label="业务员">
- <a-input id="salesDetailReportList-salesManName" v-model.trim="queryParam.salesManName" allowClear placeholder="请输入业务员"/>
- </a-form-model-item>
- </a-col>
- <a-col :md="6" :sm="24">
- <a-form-item label="客户所在区">
- <AreaList id="salesDetailReportList-area" changeOnSelect ref="areaList" @change="areaChange"></AreaList>
- </a-form-item>
- </a-col>
- </template>
- <a-col :md="6" :sm="24" style="margin-bottom: 10px;">
- <a-button type="primary" @click="handleSearch" :disabled="disabled" id="salesDetailReportList-refresh">查询</a-button>
- <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="salesDetailReportList-reset">重置</a-button>
- <a-button
- type="primary"
- style="margin-left: 5px"
- @click="handleExport"
- :disabled="disabled"
- :loading="exportLoading"
- v-if="$hasPermissions('B_salesDetailExport')"
- class="button-warning"
- id="salesDetailReportList-export-btn">导出</a-button>
- <a @click="advanced=!advanced" style="margin-left: 5px" id="salesDetailReportList-advanced">
- {{ advanced ? '收起' : '展开' }}
- <a-icon :type="advanced ? 'up' : 'down'"/>
- </a>
- </a-col>
- </a-row>
- </a-form-model>
- </div>
- <!-- 合计 -->
- <a-alert type="info" style="margin-bottom:10px">
- <div class="ftext" slot="message">
- 产品总数量:<strong>{{ (totalData && (totalData.productQty || totalData.productQty==0)) ? totalData.productQty : '--' }}</strong>;
- <div style="display: inline-block;" v-if="$hasPermissions('M_ShowAllCost')">
- 总成本:<strong>{{ (totalData && (totalData.totalCost || totalData.totalCost==0)) ? toThousands(totalData.totalCost) : '--' }}</strong>;
- </div>
- 总售价:<strong>{{ (totalData && (totalData.totalAmount || totalData.totalAmount==0)) ? toThousands(totalData.totalAmount) : '--' }}</strong>;
- 折后总售价:<strong>{{ (totalData && (totalData.discountedAmount || totalData.discountedAmount==0)) ? toThousands(totalData.discountedAmount) : '--' }}</strong>;
- <div style="display: inline-block;" v-if="$hasPermissions('M_ShowAllCost')">
- 总毛利:<strong>{{ (totalData && (totalData.grossProfit || totalData.grossProfit==0)) ? toThousands(totalData.grossProfit) : '--' }}</strong>。
- </div>
- </div>
- </a-alert>
- <!-- 列表 -->
- <s-table
- class="sTable"
- ref="table"
- size="small"
- :rowKey="(record) => record.no"
- rowKeyName="no"
- :columns="columns"
- :data="loadData"
- :defaultLoadData="false"
- bordered>
- </s-table>
- </a-spin>
- </template>
- <script>
- import { commonMixin } from '@/utils/mixin'
- import { STable, VSelect } from '@/components'
- import rangeDate from '@/views/common/rangeDate.vue'
- import { downloadExcel } from '@/libs/JGPrint.js'
- import { warehouseCascadeList } from '@/api/warehouse'
- import ProductType from '../../common/productType.js'
- import ProductBrand from '../../common/productBrand.js'
- import custType from '@/views/common/custType.js'
- import AreaList from '@/views/common/areaList.js'
- import custList from '@/views/common/custList.vue'
- import { reportSalesBillDetailList, reportSalesBillDetailCount, reportSalesBillDetailExport } from '@/api/reportData'
- export default {
- components: { STable, VSelect, rangeDate, ProductType, ProductBrand, custList, custType, AreaList },
- mixins: [commonMixin],
- data () {
- return {
- spinning: false,
- labelCol: { span: 8 },
- wrapperCol: { span: 16 },
- advanced: false, // 高级搜索 展开/关闭
- tableHeight: 0,
- outWareTime: [], // 出库时间
- time: [], // 审核时间
- creatTime: [], // 创建时间
- queryParam: { // 查询条件
- createBeginDate: '', // 创建开始时间
- createEndDate: '', // 创建结束时间
- beginDate: '', // 审核时间开始
- endDate: '', // 审核时间结束
- buyerNameCurrent: undefined, // 客户名称
- buyerSnCurrent: undefined, // 客户sn
- salesTargetType: undefined, // 客户类型
- provinceSn: undefined, // 省
- citySn: undefined, // 市
- countySn: undefined, // 区
- settleStyleSn: undefined, // 收款方式
- productEntity: {
- productBrandSn: undefined, // 产品品牌
- productTypeSn1: '', // 产品一级分类
- productTypeSn2: '', // 产品二级分类
- productTypeSn3: '', // 产品三级分类
- code: '', // 产品编码
- name: '' // 产品名称
- },
- warehouseCascade: [], // 仓库仓位列表
- warehouseSn: undefined, // 仓库
- warehouseLocationSn: undefined, // 仓位
- salesBillNo: '', // 销售单号
- salesManName: '' // 销售员
- },
- rules: {
- 'time': [{ required: true, message: '请选择审核时间', trigger: 'change' }]
- },
- disabled: false, // 查询、重置按钮是否可操作
- exportLoading: false,
- // 加载数据方法 必须为 Promise 对象
- loadData: parameter => {
- this.disabled = true
- const params = Object.assign(parameter, this.queryParam)
- this.spinning = true
- delete params.time
- delete params.warehouseCascade
- return reportSalesBillDetailList(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
- if (data.list[i].productEntity) {
- data.list[i].productTypeName = data.list[i].productEntity.productTypeName2
- // data.list[i].productTypeName = data.list[i].productEntity.productTypeName1 + '>' + data.list[i].productEntity.productTypeName2 + '>' + data.list[i].productEntity.productTypeName3
- }
- }
- this.disabled = false
- }
- this.spinning = false
- return data
- })
- },
- totalData: null, // 合计
- addrProvinceList: [], // 省下拉
- addrCityList: [], // 市下拉
- addrDistrictList: [], // 区下拉
- allocateTypeList: [], // 调拨类型
- productType: [], // 产品分类
- warehouseCascadeData: [] // 仓库仓位
- }
- },
- computed: {
- columns () {
- const _this = this
- const arr = [
- { title: '序号', dataIndex: 'no', width: '3%', align: 'center' },
- { title: '销售单号', dataIndex: 'salesBillNo', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
- { title: '客户名称', dataIndex: 'salesTargetName', width: '8%', align: 'left', customRender: function (text) { return text || '--' } },
- { title: '收款方式', dataIndex: 'settleStyleSnDictValue', width: '5%', align: 'center', customRender: function (text) { return text || '--' } },
- { title: '产品编码', dataIndex: 'productEntity.code', width: '5%', align: 'center', customRender: function (text) { return text || '--' } },
- { title: '品牌', dataIndex: 'productEntity.productBrandName', width: '5%', align: 'center', customRender: function (text) { return text || '--' } },
- { title: '二级分类', dataIndex: 'productTypeName', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
- { title: '产品名称', dataIndex: 'productEntity.name', width: '14%', align: 'left', customRender: function (text) { return text || '--' } },
- { title: '原厂编码', dataIndex: 'productEntity.origCode', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
- { title: '单位', dataIndex: 'productEntity.unit', width: '3%', align: 'center', customRender: function (text) { return text || '--' } },
- { title: '数量', dataIndex: 'productQty', width: '3%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
- // { title: '成本', dataIndex: 'productCost', width: '5%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
- { title: '总售价', dataIndex: 'totalAmount', width: '5%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
- { title: '折扣金额', dataIndex: 'discountAmount', width: '5%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
- { title: '折后总售价', dataIndex: 'discountedAmount', width: '5%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
- // { title: '毛利', dataIndex: 'productProfit', width: '5%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
- { title: '审核时间', dataIndex: 'salesAuditDate', width: '5%', align: 'center', customRender: function (text) { return text || '--' } }
- ]
- if (this.$hasPermissions('M_ShowAllCost')) {
- arr.splice(10, 0, { title: '成本', dataIndex: 'totalCost', width: '5%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
- arr.splice(14, 0, { title: '毛利', dataIndex: 'grossProfit', width: '5%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
- }
- return arr
- }
- },
- methods: {
- // 合计
- getCount (params) {
- reportSalesBillDetailCount(params).then(res => {
- if (res.status == 200) {
- this.totalData = res.data
- } else {
- this.totalData = null
- }
- })
- },
- // 创建时间
- creatDateChange (date) {
- this.creatTime = date
- this.queryParam.createBeginDate = date[0] || ''
- this.queryParam.createEndDate = date[1] || ''
- },
- // 审核时间 change
- dateChange (date) {
- this.time = date
- this.queryParam.beginDate = date[0] || ''
- this.queryParam.endDate = date[1] || ''
- },
- // 出库时间
- outWareDateChange (date) {
- this.outWareTime = date
- this.queryParam.outWarehouseBeginDate = date[0]
- this.queryParam.outWarehouseEndDate = date[1]
- },
- // 查询
- handleSearch () {
- const str = JSON.stringify(this.queryParam)
- const ret = str.replace(/\[|\]/g, '"').replace(/"},"/g, '","').replace(/"}/g, '","').match(/"\:".*?","/g)
- const ret1 = ret.filter(item => item != '":"","')
- if (ret1.length) {
- this.$refs.table.refresh(true)
- } else {
- this.$message.info('请至少输入一个查询条件')
- }
- },
- // 客户名称
- custSatelliteChange (v, row) {
- if (row && row.customerSn) {
- this.queryParam.buyerSnCurrent = row.customerSn
- this.queryParam.buyerNameCurrent = undefined
- } else {
- this.queryParam.buyerNameCurrent = v
- this.queryParam.buyerSnCurrent = undefined
- }
- },
- // 所在分区
- areaChange (val) {
- this.queryParam.provinceSn = val[0] ? val[0] : undefined
- this.queryParam.citySn = val[1] ? val[1] : undefined
- this.queryParam.countySn = val[2] ? val[2] : undefined
- },
- // 重置
- resetSearchForm () {
- this.$refs.rangeDate.resetDate()
- this.queryParam.time = []
- this.queryParam.beginDate = ''
- this.queryParam.endDate = ''
- this.$refs.outWareRangeDate.resetDate('')
- this.outWareTime = []
- this.queryParam.outWarehouseBeginDate = ''
- this.queryParam.outWarehouseEndDate = ''
- this.$refs.creatDate.resetDate()
- this.creatTime = []
- this.queryParam.createBeginDate = ''
- this.queryParam.createEndDate = ''
- this.queryParam.buyerNameCurrent = undefined
- this.queryParam.buyerSnCurrent = undefined
- this.queryParam.salesTargetType = undefined
- this.queryParam.provinceSn = undefined
- this.queryParam.citySn = undefined
- this.queryParam.countySn = undefined
- this.queryParam.settleStyleSn = undefined
- this.queryParam.productEntity.productBrandSn = undefined
- this.queryParam.productEntity.productTypeSn1 = ''
- this.queryParam.productEntity.productTypeSn2 = ''
- this.queryParam.productEntity.productTypeSn3 = ''
- this.queryParam.productEntity.code = ''
- this.queryParam.productEntity.name = ''
- this.queryParam.warehouseSn = undefined
- this.queryParam.warehouseLocationSn = undefined
- this.queryParam.showCost = undefined
- this.queryParam.warehouseCascade = []
- this.queryParam.salesBillNo = ''
- this.queryParam.salesManName = ''
- this.productType = []
- this.$refs.ruleForm.resetFields()
- this.totalData = null
- this.$refs.table.clearTable()
- if (this.advanced) {
- this.$refs.custSatelliteList.resetForm()
- this.$refs.areaList.clearData()
- }
- },
- // 导出
- handleExport () {
- const _this = this
- const str = JSON.stringify(this.queryParam)
- const ret = str.replace(/\[|\]/g, '"').replace(/"},"/g, '","').replace(/"}/g, '","').match(/"\:".*?","/g)
- const ret1 = ret.filter(item => item != '":"","')
- console.log(ret1)
- if (ret1.length) {
- const params = _this.queryParam
- params.showCost = this.$hasPermissions('M_ShowAllCost') ? '1' : '0'
- _this.exportLoading = true
- _this.spinning = true
- reportSalesBillDetailExport(params).then(res => {
- downloadExcel(res, '销售明细报表')
- _this.exportLoading = false
- _this.spinning = false
- _this.queryParam.showCost = undefined
- })
- } else {
- this.$message.info('请至少输入一个查询条件')
- }
- },
- // 产品分类 change
- changeProductType (val, opt) {
- this.queryParam.productEntity.productTypeSn1 = val[0] ? val[0] : ''
- this.queryParam.productEntity.productTypeSn2 = val[1] ? val[1] : ''
- this.queryParam.productEntity.productTypeSn3 = val[2] ? val[2] : ''
- },
- // 仓库仓位 级联 列表
- getWarehouseCascade () {
- warehouseCascadeList({}).then(res => {
- if (res.status == 200) {
- res.data.map(item => {
- item.sn = item.warehouseSn
- if (item.warehouseLocationList) {
- item.warehouseLocationList.map(subItem => {
- subItem.sn = subItem.warehouseLocationSn
- })
- }
- })
- this.warehouseCascadeData = res.data
- } else {
- this.warehouseCascadeData = []
- }
- })
- },
- // 仓库仓位change
- warehouseCascadeChange (val) {
- if (val && val.length > 0) {
- this.queryParam.warehouseSn = val[0] || ''
- this.queryParam.warehouseLocationSn = val[1] || ''
- } else {
- this.queryParam.warehouseSn = ''
- this.queryParam.warehouseLocationSn = ''
- }
- },
- // 初始化页面
- pageInit () {
- this.disabled = false
- this.spinning = false
- this.getWarehouseCascade()
- }
- },
- mounted () {
- if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
- this.pageInit()
- this.resetSearchForm()
- }
- },
- activated () {
- // 如果是新页签打开,则重置当前页面
- if (this.$store.state.app.isNewTab) {
- this.pageInit()
- this.resetSearchForm()
- }
- },
- beforeRouteEnter (to, from, next) {
- next(vm => {})
- }
- }
- </script>
|