Ver código fonte

开单销售单报表

lilei 3 anos atrás
pai
commit
fc13cc55ad

+ 25 - 0
src/api/salesBillReport.js

@@ -0,0 +1,25 @@
+import { axios } from '@/utils/request'
+
+//  开单销售单报表   列表  有分页
+export const salesBillReportList = (params) => {
+  const url = `/report/salesBillReport/queryPage/${params.pageNo}/${params.pageSize}`
+  delete params.pageNo
+  delete params.pageSize
+  return axios({
+    url: url,
+    data: params,
+    method: 'post'
+  })
+}
+
+//  开单销售报表   列表  有分页
+export const salesBillReportGroupByBuyerList = (params) => {
+  const url = `/report/salesBillReport/queryPageGroupByBuyer/${params.pageNo}/${params.pageSize}`
+  delete params.pageNo
+  delete params.pageSize
+  return axios({
+    url: url,
+    data: params,
+    method: 'post'
+  })
+}

+ 191 - 209
src/views/reportData/salesAmountReport/list.vue

@@ -1,115 +1,136 @@
 <template>
   <a-card size="small" :bordered="false" class="salesAmountReportList-wrap">
-    <!-- 搜索条件 -->
-    <div class="table-page-search-wrapper">
-      <a-form layout="inline" @keyup.enter.native="$refs.table.refresh(true)">
-        <a-row :gutter="15">
-          <a-col :md="6" :sm="24">
-            <a-form-item label="销售日期">
-              <rangeDate ref="rangeDate" @change="dateChange" />
-            </a-form-item>
-          </a-col>
-          <a-col :md="6" :sm="24">
-            <a-form-item label="客户名称">
-              <a-input id="salesAmountReportList-allocateTypeSn" v-model.trim="queryParam.allocateTypeSn" allowClear placeholder="请输入客户名称"/>
-            </a-form-item>
-          </a-col>
-          <a-col :md="6" :sm="24">
-            <a-form-item label="客户类型">
-              <a-select id="salesAmountReportList-allocateTypeSn" v-model="queryParam.allocateTypeSn" placeholder="请选择客户类型" allowClear >
-                <a-select-option v-for="item in allocateTypeList" :key="item.allocateTypeSn" :value="item.allocateTypeSn">{{ item.name }}</a-select-option>
-              </a-select>
-            </a-form-item>
-          </a-col>
-          <template v-if="advanced">
+    <a-spin :spinning="spinning" tip="Loading...">
+      <!-- 搜索条件 -->
+      <div class="table-page-search-wrapper">
+        <a-form-model
+          id="salesSlipReportList-form"
+          layout="inline"
+          ref="ruleForm"
+          :model="queryParam"
+          :rules="rules"
+          @keyup.enter.native="$refs.table.refresh(true)">
+          <a-row :gutter="15">
             <a-col :md="6" :sm="24">
-              <a-form-item label="所在区域">
-                <subarea id="salesAmountReportList-allocateTypeSn" v-model="queryParam.subareaSn"></subarea>
-              </a-form-item>
+              <a-form-model-item label="销售日期" prop="time">
+                <rangeDate ref="rangeDate" :value="queryParam.time" @change="dateChange" />
+              </a-form-model-item>
             </a-col>
-            <a-col :md="12" :sm="24">
-              <a-row>
-                <a-form-item label="地区">
-                  <a-col span="7">
-                    <a-form-item prop="dealerProvinceSn" style="margin: 0;">
-                      <a-select v-model="queryParam.dealerProvinceSn" @change="getCityList" placeholder="请选择省">
-                        <a-select-option v-for="item in addrProvinceList" :value="item.id" :key="item.id + 'a'">{{ item.name }}</a-select-option>
-                      </a-select>
-                    </a-form-item>
-                  </a-col>
-                  <a-col span="7" offset="1">
-                    <a-form-item prop="dealerCitySn" style="margin: 0;">
-                      <a-select v-model="queryParam.dealerCitySn" @change="getAreaList" placeholder="请选择市">
-                        <a-select-option v-for="item in addrCityList" :value="item.id" :key="item.id + 'b'">{{ item.name }}</a-select-option>
-                      </a-select>
-                    </a-form-item>
-                  </a-col>
-                  <a-col span="7" offset="1">
-                    <a-form-item prop="dealerCountySn" style="margin: 0;">
-                      <a-select v-model="queryParam.dealerCountySn" placeholder="请选择区/县">
-                        <a-select-option v-for="item in addrDistrictList" :value="item.id" :key="item.id + 'c'">{{ item.name }}</a-select-option>
-                      </a-select>
-                    </a-form-item>
-                  </a-col>
-                </a-form-item>
-              </a-row>
+            <a-col :md="6" :sm="24">
+              <a-form-model-item label="客户名称">
+                <custList id="salesSlipReportList-allocateTypeSn" ref="custList" @change="custChange"></custList>
+              </a-form-model-item>
+            </a-col>
+            <a-col :md="6" :sm="24">
+              <a-form-model-item label="客户类型">
+                <v-select
+                  v-model="queryParam.dealer.dealerLevel"
+                  ref="dealerLevel"
+                  id="salesSlipReportList-allocateTypeSn"
+                  code="DEALER_LEVEL"
+                  placeholder="请选择客户类型"
+                  allowClear></v-select>
+              </a-form-model-item>
+            </a-col>
+            <template v-if="advanced">
+              <a-col :md="6" :sm="24">
+                <a-form-model-item label="所在区域">
+                  <subarea id="salesSlipReportList-allocateTypeSn" v-model="queryParam.dealer.subareaSn"></subarea>
+                </a-form-model-item>
+              </a-col>
+              <a-col :md="12" :sm="24">
+                <a-row>
+                  <a-form-model-item label="地区">
+                    <a-col span="7">
+                      <a-form-model-item prop="dealerProvinceSn" style="margin: 0;">
+                        <a-select v-model="queryParam.dealer.provinceSn" allowClear @change="getCityList" placeholder="请选择省">
+                          <a-select-option v-for="item in addrProvinceList" :value="item.id" :key="item.id + 'a'">{{ item.name }}</a-select-option>
+                        </a-select>
+                      </a-form-model-item>
+                    </a-col>
+                    <a-col span="7" offset="1">
+                      <a-form-model-item prop="dealerCitySn" style="margin: 0;">
+                        <a-select v-model="queryParam.dealer.citySn" allowClear @change="getAreaList" placeholder="请选择市">
+                          <a-select-option v-for="item in addrCityList" :value="item.id" :key="item.id + 'b'">{{ item.name }}</a-select-option>
+                        </a-select>
+                      </a-form-model-item>
+                    </a-col>
+                    <a-col span="7" offset="1">
+                      <a-form-model-item prop="dealerCountySn" style="margin: 0;">
+                        <a-select v-model="queryParam.dealer.districtSn" allowClear placeholder="请选择区/县">
+                          <a-select-option v-for="item in addrDistrictList" :value="item.id" :key="item.id + 'c'">{{ item.name }}</a-select-option>
+                        </a-select>
+                      </a-form-model-item>
+                    </a-col>
+                  </a-form-model-item>
+                </a-row>
+              </a-col>
+            </template>
+            <a-col :md="6" :sm="24">
+              <a-button type="primary" @click="handleSearch" :disabled="disabled" id="salesSlipReportList-refresh">查询</a-button>
+              <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="salesSlipReportList-reset">重置</a-button>
+              <a @click="advanced=!advanced" style="margin-left: 8px">
+                {{ advanced ? '收起' : '展开' }}
+                <a-icon :type="advanced ? 'up' : 'down'"/>
+              </a>
             </a-col>
-          </template>
-          <a-col :md="6" :sm="24">
-            <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="salesAmountReportList-refresh">查询</a-button>
-            <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="salesAmountReportList-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>
-    </div>
-    <!-- 列表 -->
-    <s-table
-      class="sTable"
-      ref="table"
-      size="small"
-      :rowKey="(record) => record.id"
-      :columns="columns"
-      :data="loadData"
-      :scroll="{ x: 3120 }"
-      bordered>
-    </s-table>
+          </a-row>
+        </a-form-model>
+      </div>
+      <!-- 列表 -->
+      <s-table
+        class="sTable"
+        ref="table"
+        size="small"
+        :defaultLoadData="false"
+        :rowKey="(record) => record.id"
+        :columns="columns"
+        :data="loadData"
+        :scroll="{ x: 3120 }"
+        bordered>
+      </s-table>
+    </a-spin>
   </a-card>
 </template>
 
 <script>
 import { STable, VSelect } from '@/components'
-import reportData from '@/libs/reportData'
 import rangeDate from '@/views/common/rangeDate.vue'
+import custList from '@/views/common/custList.vue'
 import subarea from '@/views/common/subarea.js'
 import { getArea } from '@/api/data'
-// import { allocateBillList, allocateBillDel, allocateBillAudit, allocateBillExport } from '@/api/allocateBill'
-// import { allocateTypeAllList } from '@/api/allocateType'
+import { salesBillReportGroupByBuyerList } from '@/api/salesBillReport'
 export default {
-  components: { STable, VSelect, rangeDate, subarea },
+  components: { STable, VSelect, rangeDate, subarea, custList },
   data () {
     return {
+      spinning: false,
       advanced: false, // 高级搜索 展开/关闭
       tableHeight: 0,
       queryParam: { //  查询条件
+        time: [],
         beginDate: '',
         endDate: '',
-        targetName: '', //  调往对象
-        allocateTypeSn: undefined, //  调拨类型
-        state: undefined, //  业务状态
-        allocateNo: '' //  调拨单号
+        dealer: {
+          'dealerSn': undefined,
+          'provinceSn': undefined,
+          'citySn': undefined,
+          'districtSn': undefined,
+          'subareaSn': undefined,
+          'dealerLevel': undefined
+        }
+      },
+      rules: {
+        'time': [{ required: true, message: '请选择销售日期', trigger: 'change' }]
       },
       disabled: false, //  查询、重置按钮是否可操作
       exportLoading: false,
       columns: [
         { title: '序号', dataIndex: 'no', width: 80, align: 'center', fixed: 'left' },
-        { title: '区域', dataIndex: 'area', width: 220, align: 'center', customRender: function (text) { return text || '--' } },
-        { title: '省份', dataIndex: 'provinceName', width: 200, align: 'center', customRender: function (text) { return text || '--' } },
-        { title: '客户名称', dataIndex: 'custName', align: 'center', customRender: function (text) { return text || '--' } },
-        { title: '客户类型', dataIndex: 'custType', width: 200, align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '区域', dataIndex: 'dealer.subareaNameSet', width: 220, align: 'center', customRender: function (text) { return text.join('/') || '--' } },
+        { title: '省份', dataIndex: 'dealer.provinceName', width: 200, align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '客户名称', dataIndex: 'dealer.dealerName', align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '客户类型', dataIndex: 'dealer.dealerLevelDictValue', width: 200, align: 'center', customRender: function (text) { return text || '--' } },
         { title: '品牌',
           align: 'center',
           children: [
@@ -119,38 +140,38 @@ export default {
               children: [
                 {
                   title: '滤清器',
-                  dataIndex: 'pp1',
+                  dataIndex: 'jpLqqAmount',
                   align: 'center',
                   width: 100,
-                  customRender: function (text) { return text ? ('¥' + text) : '--' }
+                  customRender: function (text) { return text ? ('¥' + text) : '0' }
                 },
                 {
                   title: '雨刮片',
-                  dataIndex: 'pp2',
+                  dataIndex: 'jpYgpAmount',
                   align: 'center',
                   width: 100,
-                  customRender: function (text) { return text ? ('¥' + text) : '--' }
+                  customRender: function (text) { return text ? ('¥' + text) : '0' }
                 },
                 {
                   title: '喇叭',
-                  dataIndex: 'pp3',
+                  dataIndex: 'jpLbAmount',
                   align: 'center',
                   width: 100,
-                  customRender: function (text) { return text ? ('¥' + text) : '--' }
+                  customRender: function (text) { return text ? ('¥' + text) : '0' }
                 },
                 {
                   title: '刹车片',
                   dataIndex: 'pp4',
-                  align: 'center',
+                  align: 'jpScpAmount',
                   width: 100,
-                  customRender: function (text) { return text ? ('¥' + text) : '--' }
+                  customRender: function (text) { return text ? ('¥' + text) : '0' }
                 },
                 {
                   title: '感应线',
-                  dataIndex: 'pp5',
+                  dataIndex: 'jpGyxAmount',
                   align: 'center',
                   width: 100,
-                  customRender: function (text) { return text ? ('¥' + text) : '--' }
+                  customRender: function (text) { return text ? ('¥' + text) : '0' }
                 }
               ]
             },
@@ -160,54 +181,54 @@ export default {
               children: [
                 {
                   title: '滤清器',
-                  dataIndex: 'pp6',
+                  dataIndex: 'gpLqqAmount',
                   align: 'center',
                   width: 100,
-                  customRender: function (text) { return text ? ('¥' + text) : '--' }
+                  customRender: function (text) { return text ? ('¥' + text) : '0' }
                 },
                 {
                   title: '雨刮片',
-                  dataIndex: 'pp7',
+                  dataIndex: 'gpYgpAmount',
                   align: 'center',
                   width: 100,
-                  customRender: function (text) { return text ? ('¥' + text) : '--' }
+                  customRender: function (text) { return text ? ('¥' + text) : '0' }
                 },
                 {
                   title: '刹车片',
-                  dataIndex: 'pp8',
+                  dataIndex: 'gpScpAmount',
                   align: 'center',
                   width: 100,
-                  customRender: function (text) { return text ? ('¥' + text) : '--' }
+                  customRender: function (text) { return text ? ('¥' + text) : '0' }
                 }
               ]
             },
             {
               title: '汇箭',
-              dataIndex: 'pp9',
+              dataIndex: 'hjAmount',
               align: 'center',
               width: 100,
-              customRender: function (text) { return text ? ('¥' + text) : '--' }
+              customRender: function (text) { return text ? ('¥' + text) : '0' }
             },
             {
               title: '德路斯',
-              dataIndex: 'pp10',
+              dataIndex: 'dlsAmount',
               align: 'center',
               width: 100,
-              customRender: function (text) { return text ? ('¥' + text) : '--' }
+              customRender: function (text) { return text ? ('¥' + text) : '0' }
             },
             {
               title: '稳升',
-              dataIndex: 'pp11',
+              dataIndex: 'wsAmount',
               align: 'center',
               width: 100,
-              customRender: function (text) { return text ? ('¥' + text) : '--' }
+              customRender: function (text) { return text ? ('¥' + text) : '0' }
             },
             {
               title: 'TBU',
-              dataIndex: 'pp12',
+              dataIndex: 'tbuAmount',
               align: 'center',
               width: 100,
-              customRender: function (text) { return text ? ('¥' + text) : '--' }
+              customRender: function (text) { return text ? ('¥' + text) : '0' }
             }
           ] },
         { title: '代理品牌',
@@ -215,161 +236,122 @@ export default {
           children: [
             {
               title: 'NGK',
-              dataIndex: 'pp13',
+              dataIndex: 'ngkAmount',
               align: 'center',
               width: 100,
-              customRender: function (text) { return text ? ('¥' + text) : '--' }
+              customRender: function (text) { return text ? ('¥' + text) : '0' }
             },
             {
               title: '飞利浦',
-              dataIndex: 'pp14',
+              dataIndex: 'flpAmount',
               align: 'center',
               width: 100,
-              customRender: function (text) { return text ? ('¥' + text) : '--' }
+              customRender: function (text) { return text ? ('¥' + text) : '0' }
             },
             {
               title: '车仆',
-              dataIndex: 'pp15',
+              dataIndex: 'cpAmount',
               align: 'center',
               width: 100,
-              customRender: function (text) { return text ? ('¥' + text) : '--' }
+              customRender: function (text) { return text ? ('¥' + text) : '0' }
             },
             {
               title: '瓦尔塔',
-              dataIndex: 'pp16',
+              dataIndex: 'wetAmount',
               align: 'center',
               width: 100,
-              customRender: function (text) { return text ? ('¥' + text) : '--' }
+              customRender: function (text) { return text ? ('¥' + text) : '0' }
             },
             {
               title: '雷贝斯托',
-              dataIndex: 'pp17',
+              dataIndex: 'lbstAmount',
               align: 'center',
               width: 100,
-              customRender: function (text) { return text ? ('¥' + text) : '--' }
+              customRender: function (text) { return text ? ('¥' + text) : '0' }
             },
             {
               title: '德尔福',
-              dataIndex: 'pp18',
+              dataIndex: 'defAmount',
               align: 'center',
               width: 100,
-              customRender: function (text) { return text ? ('¥' + text) : '--' }
+              customRender: function (text) { return text ? ('¥' + text) : '0' }
             },
             {
               title: '巴诺德',
-              dataIndex: 'pp19',
+              dataIndex: 'bndAmount',
               align: 'center',
               width: 100,
-              customRender: function (text) { return text ? ('¥' + text) : '--' }
+              customRender: function (text) { return text ? ('¥' + text) : '0' }
             }
           ] },
-        { title: '实际销售合计金额', width: 200, dataIndex: 'totalAmount', align: 'center', customRender: function (text) { return text ? ('¥' + text) : '--' } }
+        { title: '实际销售合计金额', width: 200, dataIndex: 'totalAmount', align: 'center', customRender: function (text) { return text ? ('¥' + text) : '0' } }
       ],
       // 加载数据方法 必须为 Promise 对象
       loadData: parameter => {
-        // this.disabled = true
-        // if (this.tableHeight == 0) {
-        //   this.tableHeight = window.innerHeight - 380
-        // }
-        // const paramsPage = Object.assign(this.queryParam, { pageNo: parameter.pageNo, pageSize: parameter.pageSize }) //  有分页
-        // const params = Object.assign(parameter, this.queryParam) //  无分页
-        // return oosBuyerList(params).then(res => {
-        //   const data = res.data
-        //   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
-        //   return data
-        // })
-        const _this = this
-        return new Promise(function (resolve, reject) {
-          const data = {
-            pageNo: 1,
-            pageSize: 10,
-            list: [{
-              area: 'A区',
-              provinceName: '广东省',
-              custName: '箭冠汽配佛山白坭店',
-              custType: '市级经销商',
-              pp1: '0.00',
-              pp2: '0.00',
-              pp3: '0.00',
-              pp4: '0.00',
-              pp5: '0.00',
-              pp6: '0.00',
-              pp7: '0.00',
-              pp8: '0.00',
-              pp9: '0.00',
-              pp10: '0.00',
-              pp11: '0.00',
-              pp12: '0.00',
-              pp13: '92.50',
-              pp14: '0.00',
-              pp15: '0.00',
-              pp16: '0.00',
-              pp17: '0.00',
-              pp18: '0.00',
-              pp19: '0.00',
-              totalAmount: '92.50'
-            },
-            {
-              area: '合计:',
-              provinceName: '',
-              custName: '',
-              custType: '',
-              pp1: '0.00',
-              pp2: '0.00',
-              pp3: '0.00',
-              pp4: '0.00',
-              pp5: '0.00',
-              pp6: '0.00',
-              pp7: '0.00',
-              pp8: '0.00',
-              pp9: '0.00',
-              pp10: '0.00',
-              pp11: '0.00',
-              pp12: '0.00',
-              pp13: '92.50',
-              pp14: '0.00',
-              pp15: '0.00',
-              pp16: '0.00',
-              pp17: '0.00',
-              pp18: '0.00',
-              pp19: '0.00',
-              totalAmount: '92.50'
-            }],
-            count: 1
-          }
+        this.disabled = true
+        this.spinning = true
+        if (this.tableHeight == 0) {
+          this.tableHeight = window.innerHeight - 380
+        }
+        const paramsPage = Object.assign(this.queryParam, { pageNo: parameter.pageNo, pageSize: parameter.pageSize }) //  有分页
+        return salesBillReportGroupByBuyerList(paramsPage).then(res => {
+          const data = res.data
+          const no = (data.pageNo - 1) * data.pageSize
           for (var i = 0; i < data.list.length; i++) {
-            data.list[i].no = i + 1
+            const row = data.list[i]
+            row.no = no + i + 1
+            row.totalAmount = row.jpLqqAmount + row.jpYgpAmount + row.jpLbAmount + row.jpScpAmount
+            row.totalAmount += row.jpGyxAmount + row.gpLqqAmount + row.gpYgpAmount + row.gpScpAmount + row.hjAmount
+            row.totalAmount += row.dlsAmount + row.wsAmount + row.tbuAmount + row.ngkAmount + row.flpAmount + row.cpAmount
+            row.totalAmount += row.wetAmount + row.lbstAmount + row.defAmount + row.bndAmount
           }
-          _this.disabled = false
-          resolve(data)
+          this.disabled = false
+          this.spinning = false
+          return data
         })
       },
       addrProvinceList: [], //  省下拉
       addrCityList: [], //  市下拉
-      addrDistrictList: [], //  区下拉
-      allocateTypeList: [] //  调拨类型
+      addrDistrictList: [] //  区下拉
     }
   },
   methods: {
+    handleSearch () {
+      const _this = this
+      this.$refs.ruleForm.validate(valid => {
+        if (valid) {
+          _this.$refs.table.refresh(true)
+        } else {
+          return false
+        }
+      })
+    },
     //  创建时间  change
     dateChange (date) {
+      this.queryParam.time = date
       this.queryParam.beginDate = date[0]
       this.queryParam.endDate = date[1]
     },
+    custChange (val) {
+      this.queryParam.dealer.dealerSn = val.key
+    },
     //  重置
     resetSearchForm () {
       this.$refs.rangeDate.resetDate()
+      this.queryParam.time = []
       this.queryParam.beginDate = ''
       this.queryParam.endDate = ''
-      this.queryParam.targetName = ''
-      this.queryParam.allocateTypeSn = undefined
-      this.queryParam.state = undefined
-      this.queryParam.allocateNo = ''
-      this.$refs.table.refresh(true)
+      this.queryParam.dealer = {
+        'dealerSn': undefined,
+        'provinceSn': undefined,
+        'citySn': undefined,
+        'districtSn': undefined,
+        'subareaSn': undefined,
+        'dealerLevel': undefined
+      }
+      this.$refs.custList.resetForm()
+      this.$refs.ruleForm.resetFields()
+      this.$refs.table.clearTable()
     },
     // 获取城市列表
     getCityList (val) {

+ 196 - 214
src/views/reportData/salesSlipReport/list.vue

@@ -1,121 +1,143 @@
 <template>
   <a-card size="small" :bordered="false" class="salesSlipReportList-wrap">
-    <!-- 搜索条件 -->
-    <div class="table-page-search-wrapper">
-      <a-form layout="inline" @keyup.enter.native="$refs.table.refresh(true)">
-        <a-row :gutter="15">
-          <a-col :md="6" :sm="24">
-            <a-form-item label="销售日期">
-              <rangeDate ref="rangeDate" @change="dateChange" />
-            </a-form-item>
-          </a-col>
-          <a-col :md="6" :sm="24">
-            <a-form-item label="客户名称">
-              <a-input id="salesSlipReportList-allocateTypeSn" v-model.trim="queryParam.allocateTypeSn" allowClear placeholder="请输入客户名称"/>
-            </a-form-item>
-          </a-col>
-          <a-col :md="6" :sm="24">
-            <a-form-item label="客户类型">
-              <a-select id="salesSlipReportList-allocateTypeSn" v-model="queryParam.allocateTypeSn" placeholder="请选择客户类型" allowClear >
-                <a-select-option v-for="item in allocateTypeList" :key="item.allocateTypeSn" :value="item.allocateTypeSn">{{ item.name }}</a-select-option>
-              </a-select>
-            </a-form-item>
-          </a-col>
-          <template v-if="advanced">
+    <a-spin :spinning="spinning" tip="Loading...">
+      <!-- 搜索条件 -->
+      <div class="table-page-search-wrapper">
+        <a-form-model
+          id="salesSlipReportList-form"
+          layout="inline"
+          ref="ruleForm"
+          :model="queryParam"
+          :rules="rules"
+          @keyup.enter.native="$refs.table.refresh(true)">
+          <a-row :gutter="15">
             <a-col :md="6" :sm="24">
-              <a-form-item label="销售单号">
-                <a-input id="salesSlipReportList-allocateTypeSn" v-model.trim="queryParam.allocateTypeSn" allowClear placeholder="请输入销售单号"/>
-              </a-form-item>
+              <a-form-model-item label="销售日期" prop="time">
+                <rangeDate ref="rangeDate" :value="queryParam.time" @change="dateChange" />
+              </a-form-model-item>
             </a-col>
             <a-col :md="6" :sm="24">
-              <a-form-item label="所在区域">
-                <subarea id="salesSlipReportList-allocateTypeSn" v-model="queryParam.subareaSn"></subarea>
-              </a-form-item>
+              <a-form-model-item label="客户名称">
+                <custList id="salesSlipReportList-allocateTypeSn" ref="custList" @change="custChange"></custList>
+              </a-form-model-item>
             </a-col>
-            <a-col :md="12" :sm="24">
-              <a-row>
-                <a-form-item label="地区">
-                  <a-col span="7">
-                    <a-form-item prop="dealerProvinceSn" style="margin: 0;">
-                      <a-select v-model="queryParam.dealerProvinceSn" @change="getCityList" placeholder="请选择省">
-                        <a-select-option v-for="item in addrProvinceList" :value="item.id" :key="item.id + 'a'">{{ item.name }}</a-select-option>
-                      </a-select>
-                    </a-form-item>
-                  </a-col>
-                  <a-col span="7" offset="1">
-                    <a-form-item prop="dealerCitySn" style="margin: 0;">
-                      <a-select v-model="queryParam.dealerCitySn" @change="getAreaList" placeholder="请选择市">
-                        <a-select-option v-for="item in addrCityList" :value="item.id" :key="item.id + 'b'">{{ item.name }}</a-select-option>
-                      </a-select>
-                    </a-form-item>
-                  </a-col>
-                  <a-col span="7" offset="1">
-                    <a-form-item prop="dealerCountySn" style="margin: 0;">
-                      <a-select v-model="queryParam.dealerCountySn" placeholder="请选择区/县">
-                        <a-select-option v-for="item in addrDistrictList" :value="item.id" :key="item.id + 'c'">{{ item.name }}</a-select-option>
-                      </a-select>
-                    </a-form-item>
-                  </a-col>
-                </a-form-item>
-              </a-row>
+            <a-col :md="6" :sm="24">
+              <a-form-model-item label="客户类型">
+                <v-select
+                  v-model="queryParam.dealer.dealerLevel"
+                  ref="dealerLevel"
+                  id="salesSlipReportList-allocateTypeSn"
+                  code="DEALER_LEVEL"
+                  placeholder="请选择客户类型"
+                  allowClear></v-select>
+              </a-form-model-item>
+            </a-col>
+            <template v-if="advanced">
+              <a-col :md="6" :sm="24">
+                <a-form-model-item label="销售单号">
+                  <a-input id="salesSlipReportList-allocateTypeSn" v-model.trim="queryParam.salesBillNo" allowClear placeholder="请输入销售单号"/>
+                </a-form-model-item>
+              </a-col>
+              <a-col :md="6" :sm="24">
+                <a-form-model-item label="所在区域">
+                  <subarea id="salesSlipReportList-allocateTypeSn" v-model="queryParam.dealer.subareaSn"></subarea>
+                </a-form-model-item>
+              </a-col>
+              <a-col :md="12" :sm="24">
+                <a-row>
+                  <a-form-model-item label="地区">
+                    <a-col span="7">
+                      <a-form-model-item prop="dealerProvinceSn" style="margin: 0;">
+                        <a-select v-model="queryParam.dealer.provinceSn" allowClear @change="getCityList" placeholder="请选择省">
+                          <a-select-option v-for="item in addrProvinceList" :value="item.id" :key="item.id + 'a'">{{ item.name }}</a-select-option>
+                        </a-select>
+                      </a-form-model-item>
+                    </a-col>
+                    <a-col span="7" offset="1">
+                      <a-form-model-item prop="dealerCitySn" style="margin: 0;">
+                        <a-select v-model="queryParam.dealer.citySn" allowClear @change="getAreaList" placeholder="请选择市">
+                          <a-select-option v-for="item in addrCityList" :value="item.id" :key="item.id + 'b'">{{ item.name }}</a-select-option>
+                        </a-select>
+                      </a-form-model-item>
+                    </a-col>
+                    <a-col span="7" offset="1">
+                      <a-form-model-item prop="dealerCountySn" style="margin: 0;">
+                        <a-select v-model="queryParam.dealer.districtSn" allowClear placeholder="请选择区/县">
+                          <a-select-option v-for="item in addrDistrictList" :value="item.id" :key="item.id + 'c'">{{ item.name }}</a-select-option>
+                        </a-select>
+                      </a-form-model-item>
+                    </a-col>
+                  </a-form-model-item>
+                </a-row>
+              </a-col>
+            </template>
+            <a-col :md="6" :sm="24">
+              <a-button type="primary" @click="handleSearch" :disabled="disabled" id="salesSlipReportList-refresh">查询</a-button>
+              <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="salesSlipReportList-reset">重置</a-button>
+              <a @click="advanced=!advanced" style="margin-left: 8px">
+                {{ advanced ? '收起' : '展开' }}
+                <a-icon :type="advanced ? 'up' : 'down'"/>
+              </a>
             </a-col>
-          </template>
-          <a-col :md="6" :sm="24">
-            <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="salesSlipReportList-refresh">查询</a-button>
-            <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="salesSlipReportList-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>
-    </div>
-    <!-- 列表 -->
-    <s-table
-      class="sTable"
-      ref="table"
-      size="small"
-      :rowKey="(record) => record.id"
-      :columns="columns"
-      :data="loadData"
-      :scroll="{ x: 3220 }"
-      bordered>
-    </s-table>
+          </a-row>
+        </a-form-model>
+      </div>
+      <!-- 列表 -->
+      <s-table
+        class="sTable"
+        ref="table"
+        size="small"
+        :defaultLoadData="false"
+        :rowKey="(record) => record.id"
+        :columns="columns"
+        :data="loadData"
+        :scroll="{ x: 3220 }"
+        bordered>
+      </s-table>
+    </a-spin>
   </a-card>
 </template>
 
 <script>
 import { STable, VSelect } from '@/components'
-import reportData from '@/libs/reportData'
 import rangeDate from '@/views/common/rangeDate.vue'
+import custList from '@/views/common/custList.vue'
 import subarea from '@/views/common/subarea.js'
 import { getArea } from '@/api/data'
-// import { allocateBillList, allocateBillDel, allocateBillAudit, allocateBillExport } from '@/api/allocateBill'
-// import { allocateTypeAllList } from '@/api/allocateType'
+import { salesBillReportList } from '@/api/salesBillReport'
 export default {
-  components: { STable, VSelect, rangeDate, subarea },
+  components: { STable, VSelect, rangeDate, subarea, custList },
   data () {
     return {
+      spinning: false,
       advanced: false, // 高级搜索 展开/关闭
       tableHeight: 0,
       queryParam: { //  查询条件
+        time: [],
         beginDate: '',
         endDate: '',
-        targetName: '', //  调往对象
-        allocateTypeSn: undefined, //  调拨类型
-        state: undefined, //  业务状态
-        allocateNo: '' //  调拨单号
+        salesBillNo: '', //  销售单号
+        dealer: {
+          'dealerSn': undefined,
+          'provinceSn': undefined,
+          'citySn': undefined,
+          'districtSn': undefined,
+          'subareaSn': undefined,
+          'dealerLevel': undefined
+        }
+      },
+      rules: {
+        'time': [{ required: true, message: '请选择销售日期', trigger: 'change' }]
       },
       disabled: false, //  查询、重置按钮是否可操作
       exportLoading: false,
       columns: [
         { title: '序号', dataIndex: 'no', width: 80, align: 'center', fixed: 'left' },
-        { title: '区域', dataIndex: 'area', width: 220, align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '区域', dataIndex: 'dealer.subareaNameSet', width: 220, align: 'center', customRender: function (text) { return text.join('/') || '--' } },
         { title: '销售单号', dataIndex: 'salesBillNo', width: 220, align: 'center', customRender: function (text) { return text || '--' } },
-        { title: '省份', dataIndex: 'provinceName', width: 200, align: 'center', customRender: function (text) { return text || '--' } },
-        { title: '客户名称', dataIndex: 'custName', align: 'center', customRender: function (text) { return text || '--' } },
-        { title: '客户类型', dataIndex: 'custType', width: 200, align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '省份', dataIndex: 'dealer.provinceName', width: 200, align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '客户名称', dataIndex: 'dealer.dealerName', align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '客户类型', dataIndex: 'dealer.dealerLevelDictValue', width: 200, align: 'center', customRender: function (text) { return text || '--' } },
         { title: '品牌',
           align: 'center',
           children: [
@@ -125,38 +147,38 @@ export default {
               children: [
                 {
                   title: '滤清器',
-                  dataIndex: 'pp1',
+                  dataIndex: 'jpLqqAmount',
                   align: 'center',
                   width: 100,
-                  customRender: function (text) { return text ? ('¥' + text) : '--' }
+                  customRender: function (text) { return text ? ('¥' + text) : '0' }
                 },
                 {
                   title: '雨刮片',
-                  dataIndex: 'pp2',
+                  dataIndex: 'jpYgpAmount',
                   align: 'center',
                   width: 100,
-                  customRender: function (text) { return text ? ('¥' + text) : '--' }
+                  customRender: function (text) { return text ? ('¥' + text) : '0' }
                 },
                 {
                   title: '喇叭',
-                  dataIndex: 'pp3',
+                  dataIndex: 'jpLbAmount',
                   align: 'center',
                   width: 100,
-                  customRender: function (text) { return text ? ('¥' + text) : '--' }
+                  customRender: function (text) { return text ? ('¥' + text) : '0' }
                 },
                 {
                   title: '刹车片',
                   dataIndex: 'pp4',
-                  align: 'center',
+                  align: 'jpScpAmount',
                   width: 100,
-                  customRender: function (text) { return text ? ('¥' + text) : '--' }
+                  customRender: function (text) { return text ? ('¥' + text) : '0' }
                 },
                 {
                   title: '感应线',
-                  dataIndex: 'pp5',
+                  dataIndex: 'jpGyxAmount',
                   align: 'center',
                   width: 100,
-                  customRender: function (text) { return text ? ('¥' + text) : '--' }
+                  customRender: function (text) { return text ? ('¥' + text) : '0' }
                 }
               ]
             },
@@ -166,54 +188,54 @@ export default {
               children: [
                 {
                   title: '滤清器',
-                  dataIndex: 'pp6',
+                  dataIndex: 'gpLqqAmount',
                   align: 'center',
                   width: 100,
-                  customRender: function (text) { return text ? ('¥' + text) : '--' }
+                  customRender: function (text) { return text ? ('¥' + text) : '0' }
                 },
                 {
                   title: '雨刮片',
-                  dataIndex: 'pp7',
+                  dataIndex: 'gpYgpAmount',
                   align: 'center',
                   width: 100,
-                  customRender: function (text) { return text ? ('¥' + text) : '--' }
+                  customRender: function (text) { return text ? ('¥' + text) : '0' }
                 },
                 {
                   title: '刹车片',
-                  dataIndex: 'pp8',
+                  dataIndex: 'gpScpAmount',
                   align: 'center',
                   width: 100,
-                  customRender: function (text) { return text ? ('¥' + text) : '--' }
+                  customRender: function (text) { return text ? ('¥' + text) : '0' }
                 }
               ]
             },
             {
               title: '汇箭',
-              dataIndex: 'pp9',
+              dataIndex: 'hjAmount',
               align: 'center',
               width: 100,
-              customRender: function (text) { return text ? ('¥' + text) : '--' }
+              customRender: function (text) { return text ? ('¥' + text) : '0' }
             },
             {
               title: '德路斯',
-              dataIndex: 'pp10',
+              dataIndex: 'dlsAmount',
               align: 'center',
               width: 100,
-              customRender: function (text) { return text ? ('¥' + text) : '--' }
+              customRender: function (text) { return text ? ('¥' + text) : '0' }
             },
             {
               title: '稳升',
-              dataIndex: 'pp11',
+              dataIndex: 'wsAmount',
               align: 'center',
               width: 100,
-              customRender: function (text) { return text ? ('¥' + text) : '--' }
+              customRender: function (text) { return text ? ('¥' + text) : '0' }
             },
             {
               title: 'TBU',
-              dataIndex: 'pp12',
+              dataIndex: 'tbuAmount',
               align: 'center',
               width: 100,
-              customRender: function (text) { return text ? ('¥' + text) : '--' }
+              customRender: function (text) { return text ? ('¥' + text) : '0' }
             }
           ] },
         { title: '代理品牌',
@@ -221,163 +243,123 @@ export default {
           children: [
             {
               title: 'NGK',
-              dataIndex: 'pp13',
+              dataIndex: 'ngkAmount',
               align: 'center',
               width: 100,
-              customRender: function (text) { return text ? ('¥' + text) : '--' }
+              customRender: function (text) { return text ? ('¥' + text) : '0' }
             },
             {
               title: '飞利浦',
-              dataIndex: 'pp14',
+              dataIndex: 'flpAmount',
               align: 'center',
               width: 100,
-              customRender: function (text) { return text ? ('¥' + text) : '--' }
+              customRender: function (text) { return text ? ('¥' + text) : '0' }
             },
             {
               title: '车仆',
-              dataIndex: 'pp15',
+              dataIndex: 'cpAmount',
               align: 'center',
               width: 100,
-              customRender: function (text) { return text ? ('¥' + text) : '--' }
+              customRender: function (text) { return text ? ('¥' + text) : '0' }
             },
             {
               title: '瓦尔塔',
-              dataIndex: 'pp16',
+              dataIndex: 'wetAmount',
               align: 'center',
               width: 100,
-              customRender: function (text) { return text ? ('¥' + text) : '--' }
+              customRender: function (text) { return text ? ('¥' + text) : '0' }
             },
             {
               title: '雷贝斯托',
-              dataIndex: 'pp17',
+              dataIndex: 'lbstAmount',
               align: 'center',
               width: 100,
-              customRender: function (text) { return text ? ('¥' + text) : '--' }
+              customRender: function (text) { return text ? ('¥' + text) : '0' }
             },
             {
               title: '德尔福',
-              dataIndex: 'pp18',
+              dataIndex: 'defAmount',
               align: 'center',
               width: 100,
-              customRender: function (text) { return text ? ('¥' + text) : '--' }
+              customRender: function (text) { return text ? ('¥' + text) : '0' }
             },
             {
               title: '巴诺德',
-              dataIndex: 'pp19',
+              dataIndex: 'bndAmount',
               align: 'center',
               width: 100,
-              customRender: function (text) { return text ? ('¥' + text) : '--' }
+              customRender: function (text) { return text ? ('¥' + text) : '0' }
             }
           ] },
-        { title: '实际销售合计金额', width: 200, dataIndex: 'totalAmount', align: 'center', customRender: function (text) { return text ? ('¥' + text) : '--' } }
+        { title: '实际销售合计金额', width: 200, dataIndex: 'totalAmount', align: 'center', customRender: function (text) { return text ? ('¥' + text) : '0' } }
       ],
       // 加载数据方法 必须为 Promise 对象
       loadData: parameter => {
-        // this.disabled = true
-        // if (this.tableHeight == 0) {
-        //   this.tableHeight = window.innerHeight - 380
-        // }
-        // const paramsPage = Object.assign(this.queryParam, { pageNo: parameter.pageNo, pageSize: parameter.pageSize }) //  有分页
-        // const params = Object.assign(parameter, this.queryParam) //  无分页
-        // return oosBuyerList(params).then(res => {
-        //   const data = res.data
-        //   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
-        //   return data
-        // })
-        const _this = this
-        return new Promise(function (resolve, reject) {
-          const data = {
-            pageNo: 1,
-            pageSize: 10,
-            list: [{
-              area: 'A区',
-              salesBillNo: 'XS2106020000001',
-              provinceName: '广东省',
-              custName: '箭冠汽配佛山白坭店',
-              custType: '市级经销商',
-              pp1: '0.00',
-              pp2: '0.00',
-              pp3: '0.00',
-              pp4: '0.00',
-              pp5: '0.00',
-              pp6: '0.00',
-              pp7: '0.00',
-              pp8: '0.00',
-              pp9: '0.00',
-              pp10: '0.00',
-              pp11: '0.00',
-              pp12: '0.00',
-              pp13: '92.50',
-              pp14: '0.00',
-              pp15: '0.00',
-              pp16: '0.00',
-              pp17: '0.00',
-              pp18: '0.00',
-              pp19: '0.00',
-              totalAmount: '92.50'
-            },
-            {
-              area: '合计:',
-              salesBillNo: '',
-              provinceName: '',
-              custName: '',
-              custType: '',
-              pp1: '0.00',
-              pp2: '0.00',
-              pp3: '0.00',
-              pp4: '0.00',
-              pp5: '0.00',
-              pp6: '0.00',
-              pp7: '0.00',
-              pp8: '0.00',
-              pp9: '0.00',
-              pp10: '0.00',
-              pp11: '0.00',
-              pp12: '0.00',
-              pp13: '92.50',
-              pp14: '0.00',
-              pp15: '0.00',
-              pp16: '0.00',
-              pp17: '0.00',
-              pp18: '0.00',
-              pp19: '0.00',
-              totalAmount: '92.50'
-            }],
-            count: 1
-          }
+        this.disabled = true
+        this.spinning = true
+        if (this.tableHeight == 0) {
+          this.tableHeight = window.innerHeight - 380
+        }
+        const paramsPage = Object.assign(this.queryParam, { pageNo: parameter.pageNo, pageSize: parameter.pageSize }) //  有分页
+        return salesBillReportList(paramsPage).then(res => {
+          const data = res.data
+          const no = (data.pageNo - 1) * data.pageSize
           for (var i = 0; i < data.list.length; i++) {
-            data.list[i].no = i + 1
+            const row = data.list[i]
+            row.no = no + i + 1
+            row.totalAmount = row.jpLqqAmount + row.jpYgpAmount + row.jpLbAmount + row.jpScpAmount
+            row.totalAmount += row.jpGyxAmount + row.gpLqqAmount + row.gpYgpAmount + row.gpScpAmount + row.hjAmount
+            row.totalAmount += row.dlsAmount + row.wsAmount + row.tbuAmount + row.ngkAmount + row.flpAmount + row.cpAmount
+            row.totalAmount += row.wetAmount + row.lbstAmount + row.defAmount + row.bndAmount
           }
-          _this.disabled = false
-          resolve(data)
+          this.disabled = false
+          this.spinning = false
+          return data
         })
       },
       addrProvinceList: [], //  省下拉
       addrCityList: [], //  市下拉
-      addrDistrictList: [], //  区下拉
-      allocateTypeList: [] //  调拨类型
+      addrDistrictList: [] //  区下拉
     }
   },
   methods: {
+    handleSearch () {
+      const _this = this
+      this.$refs.ruleForm.validate(valid => {
+        if (valid) {
+          _this.$refs.table.refresh(true)
+        } else {
+          return false
+        }
+      })
+    },
     //  创建时间  change
     dateChange (date) {
+      this.queryParam.time = date
       this.queryParam.beginDate = date[0]
       this.queryParam.endDate = date[1]
     },
+    custChange (val) {
+      this.queryParam.dealer.dealerSn = val.key
+    },
     //  重置
     resetSearchForm () {
       this.$refs.rangeDate.resetDate()
+      this.queryParam.time = []
       this.queryParam.beginDate = ''
       this.queryParam.endDate = ''
-      this.queryParam.targetName = ''
-      this.queryParam.allocateTypeSn = undefined
-      this.queryParam.state = undefined
-      this.queryParam.allocateNo = ''
-      this.$refs.table.refresh(true)
+      this.queryParam.salesBillNo = ''
+      this.queryParam.dealer = {
+        'dealerSn': undefined,
+        'provinceSn': undefined,
+        'citySn': undefined,
+        'districtSn': undefined,
+        'subareaSn': undefined,
+        'dealerLevel': undefined
+      }
+      this.$refs.custList.resetForm()
+      this.$refs.ruleForm.resetFields()
+      this.$refs.table.clearTable()
     },
     // 获取城市列表
     getCityList (val) {