Explorar o código

对接销售退货报表

chenrui %!s(int64=3) %!d(string=hai) anos
pai
achega
67c380113d

+ 9 - 0
src/api/allocateReport.js

@@ -38,3 +38,12 @@ export const allocateReportDetailCount = (params) => {
     method: 'post'
   })
 }
+//  调拨明细报表 导出
+export const allocateReportDetailExport = (params) => {
+  return axios({
+    url: '/report/allocateReport/detail/exportExcel',
+    data: params,
+    method: 'post',
+    responseType: 'blob'
+  })
+}

+ 28 - 0
src/api/reportData.js

@@ -52,3 +52,31 @@ export const reportSalesReturnCount = (params) => {
     method: 'post'
   })
 }
+//  销售退货明细报表
+export const reportSalesReturnDetailList = (params) => {
+  const url = `/report/reportSalesReturn/detail/queryPage/${params.pageNo}/${params.pageSize}`
+  delete params.pageNo
+  delete params.pageSize
+  return axios({
+    url: url,
+    data: params,
+    method: 'post'
+  })
+}
+//  销售退货明细报表  合计
+export const reportSalesReturnDetailCount = (params) => {
+  return axios({
+    url: '/report/reportSalesReturn/detail/queryCount',
+    data: params,
+    method: 'post'
+  })
+}
+//  销售退货明细报表 导出
+export const reportSalesReturnDetailExport = (params) => {
+  return axios({
+    url: '/report/reportSalesReturn/detail/exportExcel',
+    data: params,
+    method: 'post',
+    responseType: 'blob'
+  })
+}

+ 50 - 4
src/views/reportData/allocationDetails/list.vue

@@ -12,7 +12,7 @@
           :wrapperCol="wrapperCol"
           @keyup.enter.native="handleSearch" >
           <a-row :gutter="15">
-            <a-col :md="7" :sm="24">
+            <a-col :md="6" :sm="24">
               <a-form-model-item label="调拨开单日期" prop="time">
                 <rangeDate ref="rangeDate" :value="queryParam.time" @change="dateChange" />
               </a-form-model-item>
@@ -105,7 +105,7 @@
                 </a-form-model-item>
               </a-col>
             </template>
-            <a-col :md="7" :sm="24" style="margin-top: 3px;">
+            <a-col :md="8" :sm="24" style="margin-top: 3px;">
               <a-button
                 style="margin-bottom: 18px;"
                 type="primary"
@@ -115,6 +115,14 @@
                 id="allocationDetailsList-stockDate">盘点区间日期</a-button>
               <a-button style="margin: 0 0 18px 8px" type="primary" @click="handleSearch" :disabled="disabled" id="allocationDetailsList-refresh">查询</a-button>
               <a-button style="margin: 0 0 18px 8px" @click="resetSearchForm" :disabled="disabled" id="allocationDetailsList-reset">重置</a-button>
+              <a-button
+                style="margin-left: 5px"
+                type="primary"
+                class="button-warning"
+                @click="handleExport"
+                :disabled="disabled"
+                :loading="exportLoading"
+                id="allocationDetailsList-export">导出</a-button>
               <a @click="advanced=!advanced" style="margin-left: 8px">
                 {{ advanced ? '收起' : '展开' }}
                 <a-icon :type="advanced ? 'up' : 'down'"/>
@@ -134,7 +142,7 @@
         :defaultLoadData="false"
         :scroll="{ x: 3430 }"
         bordered>
-        <template slot="footer" slot-scope="currentPageData">
+        <template slot="footer">
           <a-row :gutter="15">
             <a-col :md="4" :sm="24">
               总数量:{{ (totalData && (totalData.totalQty || totalData.totalQty==0)) ? totalData.totalQty : '--' }}
@@ -156,6 +164,7 @@
 </template>
 
 <script>
+import moment from 'moment'
 import getDate from '@/libs/getDate.js'
 import { STable, VSelect } from '@/components'
 import rangeDate from '@/views/common/rangeDate.vue'
@@ -165,13 +174,14 @@ import { productTypeQuery } from '@/api/productType'
 import { getArea } from '@/api/data'
 import { allocateTypeAllList } from '@/api/allocateType'
 import { userQueryList } from '@/api/power-user'
-import { allocateReportDetailList, allocateReportDetailCount } from '@/api/allocateReport'
+import { allocateReportDetailList, allocateReportDetailCount, allocateReportDetailExport } from '@/api/allocateReport'
 export default {
   components: { STable, VSelect, rangeDate, subarea },
   data () {
     return {
       spinning: false,
       advanced: false, // 高级搜索 展开/关闭
+      exportLoading: false,
       tableHeight: 0,
       queryParam: { //  查询条件
         time: [
@@ -335,6 +345,42 @@ export default {
       this.totalData = null
       this.$refs.table.clearTable()
     },
+    //  导出
+    handleExport () {
+      const _this = this
+      const params = this.queryParam
+      this.exportLoading = true
+      _this.spinning = true
+      allocateReportDetailExport(params).then(res => {
+        this.exportLoading = false
+        _this.spinning = false
+        if (res.type == 'application/json') {
+          var reader = new FileReader()
+          reader.addEventListener('loadend', function () {
+            const obj = JSON.parse(reader.result)
+            _this.$notification.error({
+              message: '提示',
+              description: obj.message
+            })
+          })
+          reader.readAsText(res)
+        } else {
+          this.download(res)
+        }
+      })
+    },
+    download (data) {
+      if (!data) { return }
+      const url = window.URL.createObjectURL(new Blob([data]))
+      const link = document.createElement('a')
+      link.style.display = 'none'
+      link.href = url
+      const a = moment().format('YYYYMMDDHHmmss')
+      const fname = '调拨明细报表' + a
+      link.setAttribute('download', fname + '.xlsx')
+      document.body.appendChild(link)
+      link.click()
+    },
     filterOption (input, option) {
       return (
         option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0

+ 426 - 204
src/views/reportData/salesReturnDetailReport/list.vue

@@ -1,259 +1,481 @@
 <template>
   <a-card size="small" :bordered="false" class="provinceTypeSalesDetailsList-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="盘点区间日期">
-              <rangeDate ref="rangeDate" @change="dateChange" />
-            </a-form-item>
-          </a-col>
-          <a-col :md="6" :sm="24">
-            <a-form-item label="退货单号" :label-col="{ span:7 }" :wrapper-col="{ span:17}">
-              <a-input id="salesReturn-salesReturnBillNo" v-model.trim="queryParam.salesReturnBillNo" allowClear placeholder="请输入退货单号"/>
-            </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="handleSearch">
+          <a-row :gutter="15">
             <a-col :md="6" :sm="24">
-              <a-form-item label="产品编码" :label-col="{ span:7 }" :wrapper-col="{ span:17}">
-                <a-input id="salesReturn-salesReturnBillNo" v-model.trim="queryParam.salesReturnBillNo" 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="产品名称" :label-col="{ span:7 }" :wrapper-col="{ span:17}">
-                <a-input id="salesReturn-salesReturnBillNo" v-model.trim="queryParam.salesReturnBillNo" allowClear placeholder="请输入产品名称"/>
-              </a-form-item>
+            <a-col :md="5" :sm="24">
+              <a-form-model-item label="退货单号">
+                <a-input id="bulkWarehousingOrderList-salesReturnBillNo" v-model.trim="queryParam.salesReturnBillNo" allowClear placeholder="请输入退货单号"/>
+              </a-form-model-item>
             </a-col>
-            <a-col :md="6" :sm="24">
-              <a-form-item label="客户名称" :label-col="{ span:7 }" :wrapper-col="{ span:17}">
-                <custList id="salesReturn-buyerSn" ref="custList" @change="custChange"></custList>
-              </a-form-item>
+            <a-col :md="5" :sm="24">
+              <a-form-model-item label="产品编码">
+                <a-input id="allocationDetailsList-productCode" v-model.trim="queryParam.productCode" allowClear placeholder="请输入产品编码"/>
+              </a-form-model-item>
             </a-col>
-            <a-col :md="6" :sm="24">
-              <a-form-item label="客户类型">
-                <custList ref="custList" id="shortageStatisticsCList-buyerSn" @change="custChange"></custList>
-              </a-form-item>
+            <template v-if="advanced">
+              <a-col :md="6" :sm="24">
+                <a-form-model-item label="产品名称">
+                  <a-input id="allocationDetailsList-productName" v-model.trim="queryParam.productName" allowClear placeholder="请输入产品名称"/>
+                </a-form-model-item>
+              </a-col>
+              <a-col :md="6" :sm="24">
+                <a-form-model-item label="客户名称">
+                  <a-input id="allocationDetailsList-dealerName" v-model.trim="queryParam.dealerName" allowClear placeholder="请输入客户名称"/>
+                </a-form-model-item>
+              </a-col>
+              <a-col :md="6" :sm="24">
+                <a-form-model-item label="客户类型">
+                  <v-select
+                    v-model="queryParam.dealerLevel"
+                    ref="dealerLevel"
+                    id="salesSlipReportList-dealerLevel"
+                    code="DEALER_LEVEL"
+                    placeholder="请选择客户类型"
+                    allowClear></v-select>
+                </a-form-model-item>
+              </a-col>
+              <a-col :md="6" :sm="24">
+                <a-form-model-item label="品牌分类">
+                  <v-select code="BRAND_TYPE" id="allocationDetailsList-productBrandTypeSn" v-model="queryParam.productBrandTypeSn" allowClear placeholder="请选择品牌分类"></v-select>
+                </a-form-model-item>
+              </a-col>
+              <a-col :md="6" :sm="24">
+                <a-form-model-item label="产品品牌">
+                  <a-select
+                    placeholder="请选择"
+                    id="allocationDetailsList-productBrandSn"
+                    allowClear
+                    v-model="queryParam.productBrandSn"
+                    :showSearch="true"
+                    option-filter-prop="children"
+                    :filter-option="filterOption">
+                    <a-select-option v-for="item in productBrandList" :key="item.brandSn" :value="item.brandSn">{{ item.brandName }}</a-select-option>
+                  </a-select>
+                </a-form-model-item>
+              </a-col>
+              <a-col :md="6" :sm="24">
+                <a-form-model-item label="产品分类">
+                  <a-cascader
+                    @change="changeProductType"
+                    expand-trigger="hover"
+                    change-on-select
+                    :options="productTypeList"
+                    :fieldNames="{ label: 'productTypeName', value: 'productTypeSn', children: 'children' }"
+                    id="allocationDetailsList-productType"
+                    placeholder="请选择产品分类"
+                    allowClear
+                    v-model="productType" />
+                </a-form-model-item>
+              </a-col>
+              <a-col :md="6" :sm="24">
+                <a-form-model-item label="所在区域">
+                  <subarea id="productPricingList-subareaSn" v-model="queryParam.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.dealerProvinceSn" 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.dealerCitySn" 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.dealerCountySn" 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="8" :sm="24">
+              <a-button
+                style="margin-bottom: 18px;"
+                type="primary"
+                class="button-warning"
+                size="small"
+                @click="handleStock"
+                id="allocationDetailsList-stockDate">盘点区间日期</a-button>
+              <a-button style="margin: 0 0 18px 8px" type="primary" @click="handleSearch" :disabled="disabled" id="allocationDetailsList-refresh">查询</a-button>
+              <a-button style="margin: 0 0 18px 8px" @click="resetSearchForm" :disabled="disabled" id="allocationDetailsList-reset">重置</a-button>
+              <a-button
+                style="margin-left: 5px"
+                type="primary"
+                class="button-warning"
+                @click="handleExport"
+                :disabled="disabled"
+                :loading="exportLoading"
+                id="productInfoList-export">导出</a-button>
+              <a @click="advanced=!advanced" style="margin-left: 8px">
+                {{ advanced ? '收起' : '展开' }}
+                <a-icon :type="advanced ? 'up' : 'down'"/>
+              </a>
             </a-col>
-            <a-col :md="6" :sm="24">
-              <a-form-item label="品牌类别">
-                <a-select id="provinceTypeSalesDetailsList-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-row>
+        </a-form-model>
+      </div>
+      <!-- 列表 -->
+      <s-table
+        class="sTable"
+        ref="table"
+        size="small"
+        :rowKey="(record) => record.id"
+        :columns="columns"
+        :data="loadData"
+        :scroll="{ x: 4450 }"
+        bordered>
+        <template slot="footer">
+          <a-row :gutter="15">
+            <a-col :md="4" :sm="24">
+              退货数量:{{ (totalData && (totalData.totalQty || totalData.totalQty==0)) ? totalData.totalQty : '--' }}
             </a-col>
-            <a-col :md="6" :sm="24">
-              <a-form-item label="产品品牌">
-                <a-select id="provinceTypeSalesDetailsList-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 :md="4" :sm="24">
+              开单退货金额:{{ (totalData && (totalData.totalPrice || totalData.totalPrice==0)) ? totalData.totalPrice : '--' }}
             </a-col>
-            <a-col :md="6" :sm="24">
-              <a-form-item label="二级类别">
-                <a-select id="provinceTypeSalesDetailsList-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 :md="4" :sm="24">
+              实售退货金额:{{ (totalData && (totalData.totalRealAmount || totalData.totalRealAmount==0)) ? totalData.totalRealAmount : '--' }}
             </a-col>
-            <a-col :md="6" :sm="24">
-              <a-form-item label="三级类别">
-                <a-select id="provinceTypeSalesDetailsList-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 :md="4" :sm="24">
+              返工数量:{{ (totalData && (totalData.totalBackStockQty || totalData.totalBackStockQty==0)) ? totalData.totalBackStockQty : '--' }}
             </a-col>
-            <a-col :md="6" :sm="24">
-              <a-form-item label="所在区域">
-                <a-select id="provinceTypeSalesDetailsList-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 :md="4" :sm="24">
+              坏件数量:{{ (totalData && (totalData.totalBadQty || totalData.totalBadQty==0)) ? totalData.totalBadQty : '--' }}
             </a-col>
-            <a-col :md="6" :sm="24">
-              <a-form-item label="省份">
-                <a-select id="provinceTypeSalesDetailsList-state" v-model="queryParam.state" 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 :md="4" :sm="24">
+              正常退货数量:{{ (totalData && (totalData.totalNormalQty || totalData.totalNormalQty==0)) ? totalData.totalNormalQty : '--' }}
             </a-col>
-            <a-col :md="6" :sm="24">
-              <a-form-item label="市">
-                <a-select id="provinceTypeSalesDetailsList-state" v-model="queryParam.state" 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 :md="4" :sm="24">
+              正常退货金额:{{ (totalData && (totalData.totalNormalPrice || totalData.totalNormalPrice==0)) ? totalData.totalNormalPrice : '--' }}
             </a-col>
-            <a-col :md="6" :sm="24">
-              <a-form-item label="区">
-                <a-select id="provinceTypeSalesDetailsList-state" v-model="queryParam.state" 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 :md="4" :sm="24">
+              正常再入库金额:{{ (totalData && (totalData.totalNormalCost || totalData.totalNormalCost==0)) ? totalData.totalNormalCost : '--' }}
+            </a-col>
+            <a-col :md="4" :sm="24">
+              正常退货入库差额:{{ (totalData && (totalData.totalNormalBalance || totalData.totalNormalBalance==0)) ? totalData.totalNormalBalance : '--' }}
             </a-col>
-          </template>
-          <a-col :md="6" :sm="24">
-            <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="provinceTypeSalesDetailsList-refresh">查询</a-button>
-            <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="provinceTypeSalesDetailsList-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: 3750 }"
-      bordered>
-      <template slot="footer" slot-scope="currentPageData">
-        <a-table
-          ref="table_footer"
-          size="small"
-          :pagination="false"
-          :bordered="false"
-          :rowKey="(record) => record.id"
-          :columns="columnsTotal"
-          :data-source="totalData"
-        >
-        </a-table>
-      </template>
-    </s-table>
+          </a-row>
+        </template>
+      </s-table>
+    </a-spin>
   </a-card>
 </template>
 
 <script>
+import moment from 'moment'
+import getDate from '@/libs/getDate.js'
 import { STable, VSelect } from '@/components'
-import reportData from '@/libs/reportData'
 import rangeDate from '@/views/common/rangeDate.vue'
+import subarea from '@/views/common/subarea.js'
 import custList from '@/views/common/custList.vue'
-// import { allocateBillList, allocateBillDel, allocateBillAudit, allocateBillExport } from '@/api/allocateBill'
-// import { allocateTypeAllList } from '@/api/allocateType'
+import { getArea } from '@/api/data'
+import { productBrandQuery } from '@/api/productBrand'
+import { productTypeQuery } from '@/api/productType'
+import { reportSalesReturnDetailList, reportSalesReturnDetailCount, reportSalesReturnDetailExport } from '@/api/reportData'
 export default {
-  components: { STable, VSelect, rangeDate, custList },
+  components: { STable, VSelect, rangeDate, custList, subarea },
   data () {
     return {
+      spinning: false,
       advanced: false, // 高级搜索 展开/关闭
       tableHeight: 0,
       queryParam: { //  查询条件
-        beginDate: '',
-        endDate: '',
-        targetName: '', //  调往对象
-        allocateTypeSn: undefined, //  调拨类型
-        state: undefined, //  业务状态
-        allocateNo: '' //  调拨单号
+        time: [
+          getDate.getCurrMonthDays().starttime,
+          getDate.getCurrMonthDays().endtime
+        ],
+        beginDate: getDate.getCurrMonthDays().starttime,
+        endDate: getDate.getCurrMonthDays().endtime,
+        salesReturnBillNo: '',
+        productCode: '',
+        productName: '',
+        dealerName: '',
+        dealerLevel: undefined,
+        productBrandTypeSn: undefined,
+        productBrandSn: undefined, //  产品品牌
+        productTypeSn1: '', //  产品一级分类
+        productTypeSn2: '', //  产品二级分类
+        productTypeSn3: '', //  产品三级分类
+        subareaSn: undefined,
+        dealerProvinceSn: undefined,
+        dealerCitySn: undefined,
+        dealerCountySn: undefined
+      },
+      productType: [],
+      rules: {
+        'time': [{ required: true, message: '请选择退货完成日期', trigger: 'change' }]
       },
       disabled: false, //  查询、重置按钮是否可操作
       exportLoading: false,
-      reportData: reportData.salesReturnDetailReportList,
-      totalData: [
-        { printCsountss: 3, prinftCounts: 27, prisntCogunts: 22.5, prinxtCounts: '0', printCocunts: 3, printCvounts: '0', printCgounts: '0.00', printCouhnts: '0.00', printCournts: '0.00' }
-      ],
       columns: [
         { title: '序号', dataIndex: 'no', width: 80, align: 'center', fixed: 'left' },
-        { title: '区域', dataIndex: 'area', width: 200, align: 'center', customRender: function (text) { return text || '--' } },
-        { title: '退货单号', dataIndex: 'returnNo', width: 220, align: 'center', customRender: function (text) { return text || '--' } },
-        { title: '省份', dataIndex: 'province', width: 100, align: 'center', customRender: function (text) { return text || '--' } },
-        { title: '客户名称', dataIndex: 'customerName', width: 200, align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
-        { title: '客户类型', dataIndex: 'dealerLevelDictValue', width: 120, align: 'center', customRender: function (text) { return text || '--' } },
-        { title: '直接绑定客户名称', dataIndex: 'directCustomName', width: 140, align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
-        { title: '间接绑定客户名称', dataIndex: 'IndirectCustomName', width: 140, align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
-        { title: '退货完成日期', dataIndex: 'returnFinTime', width: 120, align: 'center', customRender: function (text) { return text || '--' } },
-        { title: '品牌', dataIndex: 'type', width: 120, align: 'center', customRender: function (text) { return text || '--' } },
-        { title: '二级类别', dataIndex: 'allocateTypeName', width: 120, align: 'center', customRender: function (text) { return text || '--' } },
-        { title: '产品名称', dataIndex: 'stateDictValue', width: 220, align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
-        { title: '产品编码', dataIndex: 'printStateDictValue', width: 120, align: 'center', customRender: function (text) { return text || '--' } },
-        { title: '单位', dataIndex: 'productUnit', width: 120, align: 'center', customRender: function (text) { return text || '--' } },
-        { title: '退货数量', dataIndex: 'printCounts', width: 120, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
-        { title: '返库数量', dataIndex: 'printCsounts', width: 120, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
-        { title: '坏件数量', dataIndex: 'printdCounts', width: 120, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
-        { title: '退货开单价', dataIndex: 'prfintCounts', width: 120, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
-        { title: '退货开单金额', dataIndex: 'printCogunts', width: 120, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
-        { title: '退货实售价', dataIndex: 'phrintCounts', width: 140, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
-        { title: '退货实售金额', dataIndex: 'printCsountss', width: 120, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
-        { title: '市级价金额', dataIndex: 'prinftCounts', width: 120, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
-        { title: '直接差价', dataIndex: 'prisntCogunts', width: 120, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
-        { title: '间接差价', dataIndex: 'prinxtCounts', width: 120, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
-        { title: '再入库单价', dataIndex: 'printCocunts', width: 120, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
-        { title: '正常退货数量', dataIndex: 'printCvounts', width: 120, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
-        { title: '正常退货金额', dataIndex: 'printCgounts', width: 120, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
-        { title: '正常再入库金额', dataIndex: 'printCouhnts', width: 120, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
-        { title: '正常退货入库差额', dataIndex: 'printCournts', width: 150, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } }
+        { title: '区域', dataIndex: 'subareaNames', width: 200, align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '退货单号', dataIndex: 'salesReturnBillNo', width: 220, align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '省份', dataIndex: 'dealerProvinceName', width: 200, align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
+        { title: '客户名称', dataIndex: 'dealerName', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
+        { title: '客户类型', dataIndex: 'dealerLevelDictValue', width: 200, align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
+        { title: '直接绑定客户名称', dataIndex: 'directDealerName', width: 200, align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
+        { title: '间接绑定客户名称', dataIndex: 'indirectDealerName', width: 200, align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
+        { title: '退货完成日期', dataIndex: 'salesReturnDate', width: 160, align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '品牌', dataIndex: 'productBrandName', width: 200, align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
+        { title: '二级分类', dataIndex: 'productTypeName2', width: 200, align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '产品名称', dataIndex: 'productName', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
+        { title: '产品编码', dataIndex: 'productCode', width: 200, align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '单位', dataIndex: 'productUnit', width: 100, align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '退货数量', dataIndex: 'qty', width: 120, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
+        { title: '返库数量', dataIndex: 'backStockQty', width: 120, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
+        { title: '坏件数量', dataIndex: 'badQty', width: 120, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
+        { title: '退货开单价', dataIndex: 'price', width: 120, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
+        { title: '退货开单金额', dataIndex: 'totalPrice', width: 120, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
+        { title: '退货实售价', dataIndex: 'realPrice', width: 140, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
+        { title: '退货实售金额', dataIndex: 'totalRealAmount', width: 120, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
+        { title: '市级价金额', dataIndex: 'totalWholesalePrice2', width: 120, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
+        { title: '直接差价', dataIndex: 'directRebateAmount', width: 120, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
+        { title: '间接差价', dataIndex: 'indirectRebateAmount', width: 120, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
+        { title: '再入库单价', dataIndex: 'cost', width: 120, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
+        { title: '正常退货数量', dataIndex: 'normalQty', width: 120, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
+        { title: '正常退货金额', dataIndex: 'totalNormalPrice', width: 120, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
+        { title: '正常再入库金额', dataIndex: 'totalNormalCost', width: 120, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
+        { title: '正常退货入库差额', dataIndex: 'totalNormalBalance', width: 150, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } }
       ],
-	  columnsTotal: [
-		  { title: '退货数量', dataIndex: 'printCsountss', width: 200, align: 'center', customRender: function (text) { return text || '--' } },
-		  { title: '开单退货金额', dataIndex: 'prinftCounts', width: 200, align: 'center', customRender: function (text) { return text || '--' } },
-		  { title: '实售退货金额', dataIndex: 'prisntCogunts', width: 100, align: 'center', customRender: function (text) { return text || '--' } },
-		  { title: '返库数量', dataIndex: 'prinxtCounts', width: 120, align: 'center', customRender: function (text) { return text || '--' } },
-		  { title: '坏件数量', dataIndex: 'printCocunts', width: 120, align: 'center', customRender: function (text) { return text || '--' } },
-		  { title: '正常退货数量', dataIndex: 'printCvounts', width: 120, align: 'center', customRender: function (text) { return text || '--' } },
-		  { title: '正常退货金额', dataIndex: 'printCgounts', width: 120, align: 'center', customRender: function (text) { return text || '--' } },
-		  { title: '正常再入库金额', dataIndex: 'printCouhnts', width: 120, align: 'center', customRender: function (text) { return text || '--' } },
-		  { title: '正常退货入库差额', dataIndex: 'printCournts', width: 120, align: 'center', customRender: function (text) { return text || '--' } }
-	  ],
       // 加载数据方法 必须为 Promise 对象
       loadData: parameter => {
         this.disabled = true
-        // return allocateBillList(Object.assign(parameter, this.queryParam)).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: reportData.salesReturnDetailReportList,
-            count: 10
-          }
+        this.spinning = true
+        const params = Object.assign(parameter, this.queryParam)
+        delete params.time
+        return reportSalesReturnDetailList(params).then(res => {
+          this.getCount(params)
+          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
+            data.list[i].no = no + i + 1
           }
-          _this.disabled = false
-          resolve(data)
+          this.disabled = false
+          this.spinning = false
+          return data
         })
       },
-      allocateTypeList: [], //  调拨类型
-      openModal: false //  新增编辑  弹框
+      totalData: null,
+      addrProvinceList: [], //  省下拉
+      addrCityList: [], //  市下拉
+      addrDistrictList: [], //  区下拉
+      productBrandList: [], //  品牌下拉数据
+      productTypeList: [] //  分类下拉数据
     }
   },
   methods: {
+    // 盘点库存日期
+    handleStock () {
+      this.$message.info('无盘点区间的起始/终止时间,请自行选择日期区间查询!')
+    },
+    // 总计
+    getCount (params) {
+      reportSalesReturnDetailCount(params).then(res => {
+        if (res.status == 200 && res.data) {
+          this.totalData = res.data
+        } else {
+          this.totalData = null
+        }
+      })
+    },
+    handleSearch () {
+      const _this = this
+      this.$refs.ruleForm.validate(valid => {
+        if (valid) {
+          _this.$refs.table.refresh(true)
+        } else {
+          return false
+        }
+      })
+    },
     //  创建时间  change
     dateChange (date) {
-      this.queryParam.beginDate = date[0]
-      this.queryParam.endDate = date[1]
+      if (date.length) {
+        if (date[0] == '' && date[1] == '') {
+          this.resetSearchForm()
+        } else {
+          this.queryParam.time = date
+        }
+      }
+      this.queryParam.beginDate = date[0] || ''
+      this.queryParam.endDate = date[1] || ''
+    },
+    custChange (val) {
+      this.queryParam.dealerSn = val.key
     },
     //  重置
     resetSearchForm () {
-      this.$refs.rangeDate.resetDate()
-      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.time = [
+        getDate.getCurrMonthDays().starttime,
+        getDate.getCurrMonthDays().endtime
+      ]
+      this.$refs.rangeDate.resetDate(this.queryParam.time)
+      this.queryParam.beginDate = getDate.getCurrMonthDays().starttime
+      this.queryParam.endDate = getDate.getCurrMonthDays().endtime
+      this.queryParam.salesReturnBillNo = ''
+      this.queryParam.productCode = ''
+      this.queryParam.productName = ''
+      this.queryParam.dealerName = ''
+      this.queryParam.dealerLevel = undefined
+      this.queryParam.productBrandTypeSn = undefined
+      this.queryParam.productBrandSn = undefined
+      this.queryParam.productTypeSn1 = ''
+      this.queryParam.productTypeSn2 = ''
+      this.queryParam.productTypeSn3 = ''
+      this.queryParam.subareaSn = undefined
+      this.queryParam.dealerProvinceSn = undefined
+      this.queryParam.dealerCitySn = undefined
+      this.queryParam.dealerCountySn = undefined
+      this.productType = []
+      if (this.advanced) {
+        this.$refs.custList.resetForm()
+      }
+      this.totalData = null
+      this.$refs.ruleForm.resetFields()
+      this.$refs.table.clearTable()
+    },
+    //  导出
+    handleExport () {
+      const _this = this
+      const params = this.queryParam
+      this.exportLoading = true
+      _this.spinning = true
+      reportSalesReturnDetailExport(params).then(res => {
+        this.exportLoading = false
+        _this.spinning = false
+        if (res.type == 'application/json') {
+          var reader = new FileReader()
+          reader.addEventListener('loadend', function () {
+            const obj = JSON.parse(reader.result)
+            _this.$notification.error({
+              message: '提示',
+              description: obj.message
+            })
+          })
+          reader.readAsText(res)
+        } else {
+          this.download(res)
+        }
+      })
+    },
+    download (data) {
+      if (!data) { return }
+      const url = window.URL.createObjectURL(new Blob([data]))
+      const link = document.createElement('a')
+      link.style.display = 'none'
+      link.href = url
+      const a = moment().format('YYYYMMDDHHmmss')
+      const fname = '销售退货明细报表' + a
+      link.setAttribute('download', fname + '.xlsx')
+      document.body.appendChild(link)
+      link.click()
+    },
+    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] : ''
+    },
+    //  产品品牌  列表
+    getProductBrand () {
+      productBrandQuery({}).then(res => {
+        if (res.status == 200) {
+          this.productBrandList = res.data
+        } else {
+          this.productBrandList = []
+        }
+      })
+    },
+    //  产品分类  列表
+    getProductType () {
+      productTypeQuery({}).then(res => {
+        if (res.status == 200) {
+          this.productTypeList = res.data
+        } else {
+          this.productTypeList = []
+        }
+      })
+    },
+    // 获取城市列表
+    getCityList (val) {
+      this.addrCityList = []
+      this.addrDistrictList = []
+      this.queryParam.dealerCitySn = undefined
+      this.queryParam.dealerCountySn = undefined
+      this.getArea('city', val)
+    },
+    // 获取区县列表
+    getAreaList (val) {
+      this.addrDistrictList = []
+      this.queryParam.dealerCountySn = undefined
+      this.getArea('district', val)
+    },
+    //  省/市/区
+    getArea (leve, sn) {
+      let params
+      if (leve == 'province') {
+        params = { type: '2' }
+      } else {
+        params = { parentId: sn, type: leve == 'city' ? '3' : '4' }
+      }
+      getArea(params).then(res => {
+        if (res.status == 200) {
+          if (leve == 'province') {
+            this.addrProvinceList = res.data || []
+          } else if (leve == 'city') {
+            this.addrCityList = res.data || []
+          } else if (leve == 'district') {
+            this.addrDistrictList = res.data || []
+          }
+        } else {
+          if (leve == 'province') {
+            this.addrProvinceList = []
+          } else if (leve == 'city') {
+            this.addrCityList = []
+          } else if (leve == 'district') {
+            this.addrDistrictList = []
+          }
+        }
+      })
     }
   },
   beforeRouteEnter (to, from, next) {
-    next(vm => {})
+    next(vm => {
+      vm.getProductBrand()
+      vm.getProductType()
+      vm.getArea('province')
+    })
   }
 }
 </script>