123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298 |
- <template>
- <div class="jg-page-wrap customerReportList-wrap">
- <a-card size="small" :bordered="false" class="table-page-search-wrapper">
- <!-- 搜索条件 -->
- <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-model-item label="客户名称">
- <custList id="chainSalesReportList-salesTargetName" ref="custSatelliteList" @change="custSatelliteChange"></custList>
- </a-form-model-item>
- </a-col>
- <a-col :md="6" :sm="24">
- <a-form-item label="客户类型">
- <custType v-model="queryParam.customerTypeSn" allowClear placeholder="请选择客户类型" style="max-width: 240px;"></custType>
- </a-form-item>
- </a-col>
- <a-col :md="6" :sm="24">
- <a-form-item label="客户所在区">
- <AreaList id="chainSalesReportList-areaList" changeOnSelect ref="areaList" @change="areaChange" defValKey="id"></AreaList>
- </a-form-item>
- </a-col>
- <template v-if="advanced">
- <a-col :md="6" :sm="24">
- <a-form-model-item label="产品分类">
- <a-cascader
- @change="changeProductType"
- change-on-select
- v-model="productType"
- expand-trigger="hover"
- :options="productTypeList"
- :fieldNames="{ label: 'productTypeName', value: 'productTypeSn', children: 'children' }"
- id="customerReportList-productType"
- placeholder="请选择产品分类"
- allowClear />
- </a-form-model-item>
- </a-col>
- </template>
- <a-col :md="24" :sm="24" style="margin-bottom: 10px;text-align:center;">
- <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 @click="advanced=!advanced" style="margin-left: 8px">
- {{ advanced ? '收起' : '展开' }}
- <a-icon :type="advanced ? 'up' : 'down'"/>
- </a>
- </a-col>
- </a-row>
- </a-form-model>
- </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.discountedAmount || totalData.discountedAmount==0)) ? toThousands(totalData.discountedAmount) : '--' }}</strong>;
- <div style="display: inline-block;" v-if="$hasPermissions('M_ShowAllCost')">
- 总毛利:<strong>{{ (totalData && totalData.totalGrossProfit) ? toThousands(totalData.totalGrossProfit) : '--' }}</strong>;
- 总毛利率:<strong>{{ (totalData && totalData.percentage) ? totalData.percentage+'%' : '--' }}</strong>;
- </div>
- </div>
- </div>
- <!-- 列表 -->
- <s-table
- class="sTable"
- ref="table"
- size="small"
- :rowKey="(record) => record.salesTargetSn"
- :columns="columns"
- :data="loadData"
- :defaultLoadData="false"
- bordered>
- </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 custList from '@/views/common/custList.vue'
- import AreaList from '@/views/common/areaList.js'
- import custType from '@/views/common/custType.js'
- // import { getArea } from '@/api/data'
- import { dealerProductTypeList } from '@/api/dealerProductType'
- import { reportBigCustomerList, reportBigCustomerCount } from '@/api/reportData'
- export default {
- mixins: [commonMixin],
- components: { STable, VSelect, rangeDate, custType, custList, AreaList },
- data () {
- return {
- spinning: false,
- labelCol: { span: 8 },
- wrapperCol: { span: 16 },
- advanced: true, // 高级搜索 展开/关闭
- tableHeight: 0,
- queryParam: { // 查询条件
- time: [],
- beginDate: '',
- endDate: '',
- productTypeSn1: '', // 产品一级分类
- productTypeSn2: '', // 产品二级分类
- productTypeSn3: '', // 产品三级分类
- provinceSn: undefined, // 省
- citySn: undefined, // 市
- countySn: undefined, // 区
- customerTypeSn: undefined, // 客户类型,
- customerName: undefined,
- customerSn: 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)
- this.spinning = true
- delete params.time
- if (params.beginDate) {
- return reportBigCustomerList(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
- data.list[i].percentageUnit = data.list[i].percentage ? data.list[i].percentage + '%' : undefined
- }
- 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, // 合计
- addrProvinceList: [], // 省下拉
- addrCityList: [], // 市下拉
- addrDistrictList: [], // 区下拉
- productTypeList: [] // 分类下拉数据
- }
- },
- computed: {
- columns () {
- const _this = this
- const arr = [
- { title: '序号', dataIndex: 'no', width: '5%', align: 'center' },
- { title: '客户名称', dataIndex: 'salesTargetName', width: '35%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true, sorter: true },
- { title: '客户类型', dataIndex: 'customerTypeName', width: '15%', align: 'center', customRender: function (text) { return text || '--' } },
- { title: '交易金额', dataIndex: 'discountedAmount', width: '15%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') }, sorter: true }
- ]
- if (this.$hasPermissions('M_ShowAllCost')) {
- arr.splice(4, 0, { title: '毛利', dataIndex: 'totalGrossProfit', width: '15%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
- arr.splice(5, 0, { title: '毛利率', dataIndex: 'percentageUnit', width: '15%', align: 'right', customRender: function (text) { return text || '--' }, sorter: true })
- }
- return arr
- }
- },
- methods: {
- areaChange (val) {
- this.queryParam.provinceSn = val[0] ? val[0] : ''
- this.queryParam.citySn = val[1] ? val[1] : ''
- this.queryParam.districtSn = val[2] ? val[2] : ''
- },
- // 合计
- getCount (params) {
- reportBigCustomerCount(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] || ''
- },
- custSatelliteChange (v, row) {
- if (row && row.customerSn) {
- this.queryParam.customerSn = row.customerSn
- this.queryParam.customerName = undefined
- } else {
- this.queryParam.customerName = v
- this.queryParam.customerSn = undefined
- }
- },
- // 查询
- 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.productTypeSn1 = ''
- this.queryParam.productTypeSn2 = ''
- this.queryParam.productTypeSn3 = ''
- this.queryParam.provinceSn = undefined
- this.queryParam.citySn = undefined
- this.queryParam.countySn = undefined
- this.queryParam.customerTypeSn = undefined
- this.queryParam.customerSn = undefined
- this.queryParam.customerName = undefined
- this.productType = []
- this.$refs.ruleForm.resetFields()
- this.$refs.custSatelliteList.resetForm()
- this.totalData = null
- this.$refs.table.clearTable()
- },
- filterOption (input, option) {
- return (
- option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
- )
- },
- // 产品分类 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] : ''
- },
- // 产品分类 列表
- getProductType () {
- dealerProductTypeList({}).then(res => {
- if (res.status == 200) {
- this.productTypeList = res.data
- } else {
- this.productTypeList = []
- }
- })
- },
- pageInit () {
- this.getProductType()
- }
- },
- 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>
|