chenrui 3 éve
szülő
commit
d2062c4861

+ 46 - 0
src/api/reportData.js

@@ -56,3 +56,49 @@ export const reportBigCustomerCount = (params) => {
     method: 'post'
   })
 }
+// 连锁销售报表-分页列表
+export const reportSalesBillList = (params) => {
+  const url = `/report/reportSalesBill/reportPage/${params.pageNo}/${params.pageSize}`
+  delete params.pageNo
+  delete params.pageSize
+  return axios({
+    url: url,
+    data: params,
+    method: 'post'
+  })
+}
+// 连锁销售报表-列表合计
+export const reportSalesBillCount = (params) => {
+  return axios({
+    url: '/report/reportSalesBill/reportCount',
+    data: params,
+    method: 'post'
+  })
+}
+// 连锁销售明细报表-分页列表
+export const reportSalesBillDetailList = (params) => {
+  const url = `/report/reportSalesBill/reportDetailPage/${params.pageNo}/${params.pageSize}`
+  delete params.pageNo
+  delete params.pageSize
+  return axios({
+    url: url,
+    data: params,
+    method: 'post'
+  })
+}
+// 连锁销售明细报表-列表合计
+export const reportSalesBillDetailCount = (params) => {
+  return axios({
+    url: '/report/reportSalesBill/reportDetailCount',
+    data: params,
+    method: 'post'
+  })
+}
+// 连锁店
+export const linkageGroupList = (params) => {
+  return axios({
+    url: '/report/linkageGroup/findListByDealerSn',
+    data: params,
+    method: 'post'
+  })
+}

+ 115 - 159
src/views/reportData/chainReceivedSendStorageReport/list.vue

@@ -13,33 +13,33 @@
           @keyup.enter.native="handleSearch" >
           <a-row :gutter="15">
             <a-col :md="6" :sm="24">
-              <a-form-model-item label="连锁店" prop="targetName">
+              <a-form-model-item label="连锁店" prop="dealerSn">
                 <a-select
                   placeholder="请选择连锁店"
-                  id="sendStorageReportList-targetName"
+                  id="sendStorageReportList-dealerSn"
                   allowClear
-                  v-model="queryParam.targetName"
+                  v-model="queryParam.dealerSn"
                   :showSearch="true"
                   option-filter-prop="children"
                   :filter-option="filterOption">
-                  <a-select-option v-for="item in allocateTypeList" :key="item.brandSn" :value="item.brandSn">{{ item.brandName }}</a-select-option>
+                  <a-select-option v-for="item in linkageGroupData" :key="item.dealerSn" :value="item.dealerSn">{{ item.dealerName }}</a-select-option>
                 </a-select>
               </a-form-model-item>
             </a-col>
             <a-col :md="6" :sm="24">
-              <a-form-model-item label="日期" prop="date">
-                <rangeDate ref="rangeDate" v-model="queryParam.date" @change="dateChange" />
+              <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="产品编码">
-                <a-input id="sendStorageReportList-code" v-model.trim="queryParam.code" allowClear placeholder="请输入产品编码"/>
+                <a-input id="sendStorageReportList-code" v-model.trim="queryParam.productEntity.code" allowClear placeholder="请输入产品编码"/>
               </a-form-model-item>
             </a-col>
             <template v-if="advanced">
               <a-col :md="6" :sm="24">
                 <a-form-model-item label="产品名称">
-                  <a-input id="sendStorageReportList-name" v-model.trim="queryParam.name" allowClear placeholder="请输入产品名称"/>
+                  <a-input id="sendStorageReportList-name" v-model.trim="queryParam.productEntity.name" allowClear placeholder="请输入产品名称"/>
                 </a-form-model-item>
               </a-col>
               <a-col :md="6" :sm="24">
@@ -48,7 +48,7 @@
                     placeholder="请选择产品品牌"
                     id="sendStorageReportList-productBrandSn"
                     allowClear
-                    v-model="queryParam.productBrandSn"
+                    v-model="queryParam.productEntity.productBrandSn"
                     :showSearch="true"
                     option-filter-prop="children"
                     :filter-option="filterOption">
@@ -71,7 +71,7 @@
                 </a-form-model-item>
               </a-col>
             </template>
-            <a-col :md="6" :sm="24">
+            <a-col :md="6" :sm="24" style="margin-top: 3px;">
               <a-button type="primary" @click="handleSearch" :disabled="disabled" id="sendStorageReportList-refresh">查询</a-button>
               <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="sendStorageReportList-reset">重置</a-button>
               <a @click="advanced=!advanced" style="margin-left: 8px">
@@ -91,11 +91,18 @@
         :rowKey="(record) => record.id"
         :columns="columns"
         :data="loadData"
-        :scroll="{ x: 2390 }"
+        :scroll="{ x: 2530 }"
         bordered>
         <template slot="footer" slot-scope="currentPageData">
           <span>
-            合计: 期初数量:{{ totalData.beginQty || '--' }} &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;期初金额:{{ totalData.beginAmount || '--' }} &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 收入数量:{{ totalData.putQty || '--' }} &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 收入金额:{{ totalData.putAmount || '--' }} &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 发出数量:{{ totalData.outQty || '--' }} &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  发出金额:{{ totalData.outAmount || '--' }} &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 结算数量:{{ totalData.endQty || '--' }} &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 结算金额:{{ totalData.endAmount || '--' }}
+            合计: 期初数量:{{ (totalData && (totalData.beginQty || totalData.beginQty==0)) ? totalData.beginQty : '--' }} &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+            期初金额:{{ (totalData && (totalData.beginAmount || totalData.beginAmount==0)) ? totalData.beginAmount : '--' }} &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+            收入数量:{{ (totalData && (totalData.putQty || totalData.putQty==0)) ? totalData.putQty : '--' }} &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+            收入金额:{{ (totalData && (totalData.putAmount || totalData.putAmount==0)) ? totalData.putAmount : '--' }} &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+            发出数量:{{ (totalData && (totalData.outQty || totalData.outQty==0)) ? totalData.outQty : '--' }} &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+            发出金额:{{ (totalData && (totalData.outAmount || totalData.outAmount==0)) ? totalData.outAmount : '--' }} &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+            结算数量:{{ (totalData && (totalData.endQty || totalData.endQty==0)) ? totalData.endQty : '--' }} &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+            结算金额:{{ (totalData && (totalData.endAmount || totalData.endAmount==0)) ? totalData.endAmount : '--' }}
           </span>
         </template>
       </s-table>
@@ -108,7 +115,7 @@ import { STable, VSelect } from '@/components'
 import { dealerProductBrandQuery } from '@/api/dealerProductBrand'
 import { dealerProductTypeList } from '@/api/dealerProductType'
 import rangeDate from '@/views/common/rangeDate.vue'
-import { linkageReportPageList, linkageReportPageTotal } from '@/api/reportData.js'
+import { linkageReportPageList, linkageReportPageTotal, linkageGroupList } from '@/api/reportData'
 export default {
   components: { STable, VSelect, rangeDate },
   data () {
@@ -117,148 +124,96 @@ export default {
       advanced: false, // 高级搜索 展开/关闭
       tableHeight: 0,
       queryParam: { //  查询条件
+        time: [],
         beginDate: '',
         endDate: '',
-        date: [], // 日期
-        targetName: undefined,
-        code: '', //  产品编码
-        name: '', //  产品名称
-        origCode: '', //  原厂编码
-        productBrandSn: undefined, //  产品品牌
-        productTypeSn1: '', //  产品一级分类
-        productTypeSn2: '', //  产品二级分类
-        productTypeSn3: '' //  产品三级分类
+        dealerSn: undefined,
+        productEntity: {
+          code: '', //  产品编码
+          name: '', //  产品名称
+          productBrandSn: undefined, //  产品品牌
+          productTypeSn1: '', //  产品一级分类
+          productTypeSn2: '', //  产品二级分类
+          productTypeSn3: '' //  产品三级分类
+        }
       },
       labelCol: { span: 8 },
       wrapperCol: { span: 16 },
       rules: {
-        'targetName': [{ required: true, message: '请选择连锁店', trigger: 'change' }],
-        'date': [{ required: true, message: '请选择日期', trigger: 'change' }]
+        'dealerSn': [{ required: true, message: '请选择连锁店', trigger: 'change' }],
+        'time': [{ required: true, message: '请选择日期', trigger: 'change' }]
       },
       disabled: false, //  查询、重置按钮是否可操作
       exportLoading: false,
       columns: [
-        { title: '序号',
-          dataIndex: 'no',
-          width: 80,
-          align: 'center'
-          // fixed: 'left'
-        },
-        { title: '产品编码',
-          dataIndex: 'productCode',
-          width: 220,
-          align: 'center',
-		  sorter: true,
-          customRender: function (text) {
-			  return text || '--'
-          }
-        },
-        { title: '产品名称',
-          dataIndex: 'name',
-          width: 220,
-          align: 'center',
-          customRender: function (value, row, index) {
-			  return row.productEntity && row.productEntity.name ? row.productEntity.name : '--'
-          },
-          ellipsis: true
-        },
-        { title: '品牌',
-          dataIndex: 'productBrandName',
-          align: 'center',
-          width: 200,
-          customRender: function (value, row, index) {
-			  return row.productEntity && row.productEntity.productBrandName ? row.productEntity.productBrandName : '--'
-          }
-        },
-        { title: '三级分类',
-          dataIndex: 'productTypeName3',
-          width: 150,
-          align: 'center',
-          customRender: function (value, row, index) {
-			  return row.productEntity && row.productEntity.productTypeName3 ? row.productEntity.productTypeName3 : '--'
-          }
-        },
-        { title: '原厂编码',
-          dataIndex: 'origCode',
-          width: 220,
-          align: 'center',
-          customRender: function (value, row, index) {
-			  return row.productEntity && row.productEntity.origCode ? row.productEntity.origCode : '--'
-          }
-        },
-        { title: '单位',
-          dataIndex: 'unit',
-          width: 100,
-          align: 'center',
-          customRender: function (value, row, index) {
-			  return row.productEntity && row.productEntity.unit ? row.productEntity.unit : '--'
-          }
-        },
+        { title: '序号', dataIndex: 'no', width: 80, align: 'center', fixed: 'left' },
+        { title: '产品编码', dataIndex: 'productCode', width: 220, align: 'center', customRender: function (text) { return text || '--' }, sorter: true },
+        { title: '产品名称', dataIndex: 'productEntity.name', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
+        { title: '品牌', dataIndex: 'productEntity.productBrandName', width: 200, align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '三级分类', dataIndex: 'productEntity.productTypeName3', width: 150, align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '原厂编码', dataIndex: 'productEntity.origCode', width: 200, align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '单位', dataIndex: 'productEntity.unit', width: 100, align: 'center', customRender: function (text) { return text || '--' } },
         { title: '期初数量', dataIndex: 'beginQty', width: 100, align: 'center', sorter: true, customRender: function (text) { return ((text || text == 0) ? text : '--') } },
-        { title: '期初单价(¥)', dataIndex: 'beginPrice', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
-        { title: '期初金额(¥)', dataIndex: 'beginAmount', width: 100, align: 'center', sorter: true, customRender: function (text) { return ((text || text == 0) ? text : '--') } },
+        { title: '期初单价(¥)', dataIndex: 'beginPrice', width: 120, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
+        { title: '期初金额(¥)', dataIndex: 'beginAmount', width: 120, align: 'center', sorter: true, customRender: function (text) { return ((text || text == 0) ? text : '--') } },
         { title: '收入数量', dataIndex: 'putQty', width: 100, align: 'center', sorter: true, customRender: function (text) { return ((text || text == 0) ? text : '--') } },
-        { title: '收入单价(¥)', dataIndex: 'putPrice', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
-        { title: '收入金额(¥)', dataIndex: 'putAmount', width: 100, align: 'center', sorter: true, customRender: function (text) { return ((text || text == 0) ? text : '--') } },
+        { title: '收入单价(¥)', dataIndex: 'putPrice', width: 120, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
+        { title: '收入金额(¥)', dataIndex: 'putAmount', width: 120, align: 'center', sorter: true, customRender: function (text) { return ((text || text == 0) ? text : '--') } },
         { title: '发出数量', dataIndex: 'outQty', width: 100, align: 'center', sorter: true, customRender: function (text) { return ((text || text == 0) ? text : '--') } },
-        { title: '发出单价(¥)', dataIndex: 'outPrice', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
-        { title: '发出金额(¥)', dataIndex: 'outAmount', width: 100, align: 'center', sorter: true, customRender: function (text) { return ((text || text == 0) ? text : '--') } },
+        { title: '发出单价(¥)', dataIndex: 'outPrice', width: 120, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
+        { title: '发出金额(¥)', dataIndex: 'outAmount', width: 120, align: 'center', sorter: true, customRender: function (text) { return ((text || text == 0) ? text : '--') } },
         { title: '结存数量', dataIndex: 'endQty', width: 100, align: 'center', sorter: true, customRender: function (text) { return ((text || text == 0) ? text : '--') } },
-        { title: '结存单价(¥)', dataIndex: 'endPrice', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
-        { title: '结存金额(¥)', dataIndex: 'endAmount', width: 100, align: 'center', sorter: true, customRender: function (text) { return ((text || text == 0) ? text : '--') } }
+        { title: '结存单价(¥)', dataIndex: 'endPrice', width: 120, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
+        { title: '结存金额(¥)', dataIndex: 'endAmount', width: 120, align: 'center', sorter: true, customRender: function (text) { return ((text || text == 0) ? text : '--') } }
       ],
       // 加载数据方法 必须为 Promise 对象
       loadData: parameter => {
-		  if (this.queryParam.beginDate && this.queryParam.targetName) {
-			  this.disabled = true
-			  this.spinning = true
-			  const params = {
-			    beginDate: this.queryParam.beginDate,
-			    endDate: this.queryParam.endDate,
-			    targetName: this.queryParam.targetName,
-			    productEntity: {
-			      code: this.queryParam.code, //  产品编码
-			      name: this.queryParam.name, //  产品名称
-			      origCode: this.queryParam.origCode, //  原厂编码
-			      productBrandSn: this.queryParam.productBrandSn, //  产品品牌
-			      productTypeSn1: this.queryParam.productTypeSn1, //  产品一级分类
-			      productTypeSn2: this.queryParam.productTypeSn2, //  产品二级分类
-			      productTypeSn3: this.queryParam.productTypeSn3 //  产品三级分类
-			    }
-			  }
-			  return linkageReportPageList(Object.assign(parameter, 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
-				  this.spinning = false
-			  	  return data
-			  })
-		  } else {
-			  return new Promise(function (resolve, reject) {
-			   const data = {
-				   pageNo: 1,
-				   pageSize: 10,
-				   list: [],
-				   count: 0
-			   }
-			   resolve(data)
-			  })
-		  }
+        this.disabled = true
+        const params = Object.assign(parameter, this.queryParam)
+        this.spinning = true
+        if (this.queryParam.beginDate && this.queryParam.dealerSn) {
+          if (params.dealerSn == 'all') {
+            params.dealerSn = ''
+          }
+          return linkageReportPageList(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 = no + i + 1
+            }
+            this.disabled = false
+            this.spinning = false
+            return data
+          })
+        } else {
+          const _this = this
+          return new Promise(function (resolve, reject) {
+            const data = {
+              pageNo: 1,
+              pageSize: 10,
+              list: [],
+              count: 0
+            }
+            _this.disabled = false
+            _this.spinning = false
+            _this.$message.info('请选择连锁店和日期')
+            resolve(data)
+          })
+        }
       },
       productType: [],
+      linkageGroupData: [],
       productBrandList: [], //  品牌下拉数据
       productTypeList: [], //  分类下拉数据
-      allocateTypeList: [], //  调拨类型
-      totalData: {} // 合计
+      totalData: null // 合计
     }
   },
   methods: {
     //  时间  change
     dateChange (date) {
-      this.queryParam.date = date
+      this.queryParam.time = date
       this.queryParam.beginDate = date[0] || ''
       this.queryParam.endDate = date[1] || ''
     },
@@ -267,7 +222,6 @@ export default {
       this.$refs.ruleForm.validate(valid => {
         if (valid) {
           this.$refs.table.refresh(true)
-          this.getTotal()
         } else {
           console.log('error submit!!')
           return false
@@ -275,49 +229,38 @@ export default {
       })
     },
     // 查询总计
-    getTotal () {
-      const params = {
-        beginDate: this.queryParam.beginDate,
-        endDate: this.queryParam.endDate,
-        targetName: this.queryParam.targetName,
-        productEntity: {
-          code: this.queryParam.code, //  产品编码
-          name: this.queryParam.name, //  产品名称
-          origCode: this.queryParam.origCode, //  原厂编码
-          productBrandSn: this.queryParam.productBrandSn, //  产品品牌
-          productTypeSn1: this.queryParam.productTypeSn1, //  产品一级分类
-          productTypeSn2: this.queryParam.productTypeSn2, //  产品二级分类
-          productTypeSn3: this.queryParam.productTypeSn3 //  产品三级分类
-        }
-      }
+    getCount (params) {
       linkageReportPageTotal(params).then(res => {
         if (res.status == 200 && res.data) {
           this.totalData = res.data
         } else {
-          this.totalData = {}
+          this.totalData = null
         }
       })
     },
     //  重置
     resetSearchForm () {
-      this.queryParam.targetName = undefined
-      this.queryParam.code = ''
-      this.queryParam.name = ''
-      this.queryParam.origCode = ''
-      this.queryParam.productBrandSn = undefined
-      this.queryParam.productTypeSn1 = ''
-      this.queryParam.productTypeSn2 = ''
-      this.queryParam.productTypeSn3 = ''
-      this.productType = []
+      this.queryParam.dealerSn = undefined
       this.$refs.rangeDate.resetDate()
-      this.totalData = {}
+      this.queryParam.time = []
+      this.queryParam.beginDate = ''
+      this.queryParam.endDate = ''
+      this.queryParam.productEntity.code = ''
+      this.queryParam.productEntity.name = ''
+      this.queryParam.productEntity.productBrandSn = undefined
+      this.queryParam.productEntity.productTypeSn1 = ''
+      this.queryParam.productEntity.productTypeSn2 = ''
+      this.queryParam.productEntity.productTypeSn3 = ''
+      this.productType = []
+      this.$refs.ruleForm.resetFields()
+      this.totalData = null
       this.$refs.table.clearTable()
     },
     //  产品分类  change
     changeProductType (val, opt) {
-      this.queryParam.productTypeSn1 = val[0] ? val[0] : ''
-      this.queryParam.productTypeSn2 = val[1] ? val[1] : ''
-      this.queryParam.productTypeSn3 = val[2] ? val[2] : ''
+      this.queryParam.productEntity.productTypeSn1 = val[0] ? val[0] : ''
+      this.queryParam.productEntity.productTypeSn2 = val[1] ? val[1] : ''
+      this.queryParam.productEntity.productTypeSn3 = val[2] ? val[2] : ''
     },
     //  产品品牌  列表
     getProductBrand () {
@@ -343,10 +286,23 @@ export default {
       return (
         option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
       )
+    },
+    // 连锁店
+    getLinkageGroup () {
+      linkageGroupList({}).then(res => {
+        const all = [{ dealerName: '全部', dealerSn: 'all' }]
+        if (res.status == 200) {
+          const data = res.data || []
+          this.linkageGroupData = [...all, ...data]
+        } else {
+          this.linkageGroupData = all
+        }
+      })
     }
   },
   beforeRouteEnter (to, from, next) {
     next(vm => {
+      vm.getLinkageGroup()
       vm.getProductBrand()
       vm.getProductType()
     })

+ 282 - 218
src/views/reportData/chainSalesDetailReport/list.vue

@@ -1,176 +1,179 @@
 <template>
-  <a-card size="small" :bordered="false" class="chainStockReportList-wrap">
-    <a-alert :show-icon="false" type="error" message="注:连锁销售单报表包含急件销售数量、售价,连锁销售明细报表不包含急件销售数量、成本、售价" banner style="margin-bottom: 10px;" />
-    <!-- 搜索条件 -->
-    <div class="table-page-search-wrapper">
-      <a-form-model
-        id="chainStockReportList-form"
-        ref="ruleForm"
-        :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="targetName">
-              <a-select
-                placeholder="请选择连锁店"
-                id="chainStockReportList-targetName"
-                allowClear
-                v-model="queryParam.targetName"
-                :showSearch="true"
-                option-filter-prop="children"
-                :filter-option="filterOption">
-                <a-select-option v-for="item in allocateTypeList" :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="审核时间">
-              <rangeDate ref="rangeDate" @change="dateChange" />
-            </a-form-model-item>
-          </a-col>
-          <a-col :md="6" :sm="24">
-            <a-form-model-item label="客户名称">
-              <a-input id="chainStockReportList-targetName" v-model.trim="queryParam.code" allowClear placeholder="请输入客户名称"/>
-            </a-form-model-item>
-          </a-col>
-          <template v-if="advanced">
+  <a-card size="small" :bordered="false" class="chainSalesDetailReportList-wrap">
+    <a-spin :spinning="spinning" tip="Loading...">
+      <a-alert :show-icon="false" type="error" message="注:连锁销售单报表包含急件销售数量、售价,连锁销售明细报表不包含急件销售数量、成本、售价" banner style="margin-bottom: 10px;" />
+      <!-- 搜索条件 -->
+      <div class="table-page-search-wrapper">
+        <a-form-model
+          id="chainSalesDetailReportList-form"
+          ref="ruleForm"
+          :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="客户类型">
-                <a-select id="chainStockReportList-customerType" v-model="queryParam.customerTypeSn" allowClear placeholder="请选择客户类型">
-                  <a-select-option v-for="item in custTypeList" :value="item.customerTypeSn" :key="item.customerTypeSn">{{ item.name }}</a-select-option>
-                </a-select>
-              </a-form-model-item>
-            </a-col>
-            <a-col :md="12" :sm="24">
-              <a-row>
-                <a-form-model-item label="客户所在区" :labelCol="{span: 4}" :wrapperCol="{ span: 20 }">
-                  <a-col span="7">
-                    <a-form-model-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-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" @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" 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>
-            <a-col :md="6" :sm="24">
-              <a-form-model-item label="收款方式">
-                <a-select id="chainStockReportList-settleStyleSn" v-model="queryParam.settleStyleSn" allowClear placeholder="请选择收款方式">
-                  <a-select-option v-for="item in settleStyleList" :value="item.settleStyleSn" :key="item.settleStyleSn">{{ item.name }}</a-select-option>
-                </a-select>
-              </a-form-model-item>
-            </a-col>
-            <a-col :md="6" :sm="24">
-              <a-form-item label="产品品牌">
+              <a-form-model-item label="连锁店" prop="dealerSn">
                 <a-select
-                  placeholder="请选择产品品牌"
-                  id="chainStockReportList-productBrandSn"
+                  placeholder="请选择连锁店"
+                  id="chainSalesDetailReportList-dealerSn"
                   allowClear
-                  v-model="queryParam.productBrandSn"
+                  v-model="queryParam.dealerSn"
                   :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-option v-for="item in linkageGroupData" :key="item.dealerSn" :value="item.dealerSn">{{ item.dealerName }}</a-select-option>
                 </a-select>
-              </a-form-item>
-            </a-col>
-            <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="productInfoList-productType"
-                  placeholder="请选择产品分类"
-                  allowClear />
-              </a-form-model-item>
-            </a-col>
-            <a-col :md="6" :sm="24">
-              <a-form-model-item label="产品编码">
-                <a-input id="chainStockReportList-targetName" v-model.trim="queryParam.code" allowClear placeholder="请输入单号"/>
               </a-form-model-item>
             </a-col>
             <a-col :md="6" :sm="24">
-              <a-form-model-item label="产品名称">
-                <a-input id="chainStockReportList-targetName" v-model.trim="queryParam.code" allowClear placeholder="请输入业务员"/>
+              <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="仓库仓位">
-                <a-cascader
-                  v-model="queryParam.warehouseCascade"
-                  expand-trigger="hover"
-                  :allowClear="false"
-                  :options="warehouseCascadeData"
-                  :fieldNames="{ label: 'name', value: 'sn', children: 'warehouseLocationList' }"
-                  id="chainStockReportList-warehouseCascade"
-                  placeholder="请选择仓库仓位"
-                  style="width: 100%;" />
+              <a-form-model-item label="客户名称">
+                <a-input id="chainSalesDetailReportList-salesTargetName" v-model.trim="queryParam.salesTargetName" allowClear placeholder="请输入客户名称"/>
               </a-form-model-item>
             </a-col>
-            <a-col :md="6" :sm="24">
-              <a-form-model-item label="单号">
-                <a-input id="chainStockReportList-targetName" v-model.trim="queryParam.code" allowClear placeholder="请输入单号"/>
-              </a-form-model-item>
-            </a-col>
-            <a-col :md="6" :sm="24">
-              <a-form-model-item label="业务员">
-                <a-input id="chainStockReportList-targetName" v-model.trim="queryParam.code" allowClear placeholder="请输入业务员"/>
-              </a-form-model-item>
+            <template v-if="advanced">
+              <a-col :md="6" :sm="24">
+                <a-form-model-item label="客户类型">
+                  <a-select id="chainSalesReportList-customerType" v-model="queryParam.salesTargetType" allowClear placeholder="请选择客户类型">
+                    <a-select-option v-for="item in custTypeList" :value="item.customerTypeSn" :key="item.customerTypeSn">{{ item.name }}</a-select-option>
+                  </a-select>
+                </a-form-model-item>
+              </a-col>
+              <a-col :md="12" :sm="24">
+                <a-row>
+                  <a-form-model-item label="客户所在区" :labelCol="{span: 4}" :wrapperCol="{ span: 20 }">
+                    <a-col span="7">
+                      <a-form-model-item prop="provinceSn" style="margin: 0;">
+                        <a-select v-model="queryParam.provinceSn" @change="getCityList" placeholder="请选择省" allowClear>
+                          <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="citySn" style="margin: 0;">
+                        <a-select v-model="queryParam.citySn" @change="getAreaList" placeholder="请选择市" allowClear>
+                          <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="countySn" style="margin: 0;">
+                        <a-select v-model="queryParam.countySn" placeholder="请选择区/县" allowClear>
+                          <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>
+              <a-col :md="6" :sm="24">
+                <a-form-model-item label="收款方式">
+                  <a-select id="chainSalesReportList-settleStyleSn" v-model="queryParam.settleStyleSn" allowClear placeholder="请选择收款方式">
+                    <a-select-option v-for="item in settleStyleList" :value="item.settleStyleSn" :key="item.settleStyleSn">{{ item.name }}</a-select-option>
+                  </a-select>
+                </a-form-model-item>
+              </a-col>
+              <a-col :md="6" :sm="24">
+                <a-form-item label="产品品牌">
+                  <a-select
+                    placeholder="请选择产品品牌"
+                    id="chainSalesDetailReportList-productBrandSn"
+                    allowClear
+                    v-model="queryParam.productEntity.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-item>
+              </a-col>
+              <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="productInfoList-productType"
+                    placeholder="请选择产品分类"
+                    allowClear />
+                </a-form-model-item>
+              </a-col>
+              <a-col :md="6" :sm="24">
+                <a-form-model-item label="产品编码">
+                  <a-input id="chainSalesDetailReportList-code" v-model.trim="queryParam.productEntity.code" allowClear placeholder="请输入产品编码"/>
+                </a-form-model-item>
+              </a-col>
+              <a-col :md="6" :sm="24">
+                <a-form-model-item label="产品名称">
+                  <a-input id="chainSalesDetailReportList-name" v-model.trim="queryParam.productEntity.name" allowClear placeholder="请输入产品名称"/>
+                </a-form-model-item>
+              </a-col>
+              <a-col :md="6" :sm="24">
+                <a-form-model-item label="仓库仓位">
+                  <a-cascader
+                    v-model="queryParam.warehouseCascade"
+                    expand-trigger="hover"
+                    :options="warehouseCascadeData"
+                    :fieldNames="{ label: 'name', value: 'sn', children: 'warehouseLocationList' }"
+                    id="chainSalesDetailReportList-warehouseCascade"
+                    placeholder="请选择仓库仓位"
+                    @change="warehouseCascadeChange"
+                    style="width: 100%;" />
+                </a-form-model-item>
+              </a-col>
+              <a-col :md="6" :sm="24">
+                <a-form-model-item label="单号">
+                  <a-input id="chainSalesReportList-salesBillNo" v-model.trim="queryParam.salesBillNo" allowClear placeholder="请输入单号"/>
+                </a-form-model-item>
+              </a-col>
+              <a-col :md="6" :sm="24">
+                <a-form-model-item label="业务员">
+                  <a-input id="chainSalesReportList-salesManName" v-model.trim="queryParam.salesManName" allowClear placeholder="请输入业务员"/>
+                </a-form-model-item>
+              </a-col>
+            </template>
+            <a-col :md="6" :sm="24" style="margin-top: 3px;">
+              <a-button type="primary" @click="handleSearch" :disabled="disabled" id="chainSalesDetailReportList-refresh">查询</a-button>
+              <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="chainSalesDetailReportList-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" style="margin-top: 3px;">
-            <a-button type="primary" @click="handleSearch" :disabled="disabled" id="chainStockReportList-refresh">查询</a-button>
-            <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="chainStockReportList-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>
-    </div>
-    <!-- 合计 -->
-    <a-alert type="info" showIcon style="margin-bottom:15px">
-      <div class="ftext" slot="message">
-        产品总数量:<strong>45</strong>;
-        总成本:<strong>¥33.00</strong>;
-        总售价:<strong>¥48.00</strong>;
-        总毛利:<strong>¥15.00</strong>。
+          </a-row>
+        </a-form-model>
       </div>
-    </a-alert>
-    <!-- 列表 -->
-    <s-table
-      class="sTable"
-      ref="table"
-      size="small"
-      :rowKey="(record) => record.id"
-      :columns="columns"
-      :data="loadData"
-      :scroll="{ x: 1720 }"
-      bordered>
-    </s-table>
+      <!-- 合计 -->
+      <a-alert type="info" showIcon style="margin-bottom:15px">
+        <div class="ftext" slot="message">
+          产品总数量:<strong>{{ (totalData && (totalData.totalQty || totalData.totalQty==0)) ? totalData.totalQty : '--' }}</strong>;
+          总成本:<strong>¥{{ (totalData && (totalData.totalCost || totalData.totalCost==0)) ? totalData.totalCost : '--' }}</strong>;
+          总售价:<strong>¥{{ (totalData && (totalData.totalPrice || totalData.totalPrice==0)) ? totalData.totalPrice : '--' }}</strong>;
+          总毛利:<strong>¥{{ (totalData && (totalData.totalProfit || totalData.totalProfit==0)) ? totalData.totalProfit : '--' }}</strong>。
+        </div>
+      </a-alert>
+      <!-- 列表 -->
+      <s-table
+        class="sTable"
+        ref="table"
+        size="small"
+        :rowKey="(record) => record.id"
+        :columns="columns"
+        :data="loadData"
+        :scroll="{ x: 1770 }"
+        :defaultLoadData="false"
+        bordered>
+      </s-table>
+    </a-spin>
   </a-card>
 </template>
 
@@ -183,77 +186,89 @@ import { settleStyleFindAllList } from '@/api/customer'
 import { dealerProductBrandQuery } from '@/api/dealerProductBrand'
 import { dealerProductTypeList } from '@/api/dealerProductType'
 import { warehouseCascadeList } from '@/api/warehouse'
+import { reportSalesBillDetailList, reportSalesBillDetailCount, linkageGroupList } from '@/api/reportData'
 export default {
   components: { STable, VSelect, rangeDate },
   data () {
     return {
+      spinning: false,
       labelCol: { span: 8 },
       wrapperCol: { span: 16 },
       advanced: false, // 高级搜索 展开/关闭
       tableHeight: 0,
       queryParam: { //  查询条件
+        dealerSn: undefined,
+        time: [],
         beginDate: '',
         endDate: '',
-        targetName: undefined,
-        code: '', //  产品编码
-        name: '', //  产品名称
-        origCode: '', //  原厂编码
-        productBrandSn: undefined, //  产品品牌
-        productTypeSn1: '', //  产品一级分类
-        productTypeSn2: '', //  产品二级分类
-        productTypeSn3: '' //  产品三级分类
+        salesTargetName: '',
+        salesTargetType: undefined,
+        provinceSn: undefined, //  省
+        citySn: undefined, //  市
+        countySn: undefined, //  区
+        settleStyleSn: undefined,
+        productEntity: {
+          productBrandSn: undefined, //  产品品牌
+          productTypeSn1: '', //  产品一级分类
+          productTypeSn2: '', //  产品二级分类
+          productTypeSn3: '', //  产品三级分类
+          code: '', //  产品编码
+          name: '' //  产品名称
+        },
+        warehouseCascade: [],
+        warehouseSn: undefined,
+        warehouseLocationSn: undefined,
+        salesBillNo: '',
+        salesManName: ''
       },
       rules: {
-        'targetName': [{ required: true, message: '请选择连锁店', trigger: 'change' }]
+        'dealerSn': [{ required: true, message: '请选择连锁店', trigger: 'change' }],
+        'time': [{ required: true, message: '请选择审核时间', trigger: 'change' }]
       },
       disabled: false, //  查询、重置按钮是否可操作
       exportLoading: false,
       columns: [
         { title: '序号', dataIndex: 'no', width: 80, align: 'center', fixed: 'left' },
-        { title: '销售单号', dataIndex: 'code', width: 220, align: 'center', customRender: function (text) { return text || '--' } },
-        { title: '客户名称', dataIndex: 'name', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
-        { title: '收款方式', dataIndex: 'currentStockCost', width: 100, align: 'center', customRender: function (text) { return text || '--' } },
-        { title: '产品编码', dataIndex: 'proCode', width: 220, align: 'center', customRender: function (text) { return text || '--' } },
-        { title: '产品名称', dataIndex: 'proName', width: 220, align: 'center', customRender: function (text) { return text || '--' } },
-        { title: '单位', dataIndex: 'unit', width: 100, align: 'center', customRender: function (text) { return text || '--' } },
-        { title: '数量', dataIndex: 'totalQty', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
-        { title: '成本', dataIndex: 'totalCost', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? ('¥' + text) : '--') } },
-        { title: '售价', dataIndex: 'totalAmount', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? ('¥' + text) : '--') } },
-        { title: '毛利', dataIndex: 'totalMl', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? ('¥' + text) : '--') } },
-        { title: '审核时间', dataIndex: 'auditDate', width: 160, align: 'center', customRender: function (text) { return text || '--' } }
+        { title: '销售单号', dataIndex: 'salesBillNo', width: 220, align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '客户名称', dataIndex: 'salesTargetName', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
+        { title: '收款方式', dataIndex: 'settleStyleName', width: 150, align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '产品编码', dataIndex: 'productEntity.code', width: 220, align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '产品名称', dataIndex: 'productEntity.name', width: 220, align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '单位', dataIndex: 'productEntity.unit', width: 100, align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '数量', dataIndex: 'productQty', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
+        { title: '成本', dataIndex: 'productCost', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? ('¥' + text) : '--') } },
+        { title: '售价', dataIndex: 'productPrice', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? ('¥' + text) : '--') } },
+        { title: '毛利', dataIndex: 'productProfit', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? ('¥' + text) : '--') } },
+        { title: '审核时间', dataIndex: 'salesAuditDate', width: 160, 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: [
-              { id: '1', code: '159177', name: '支持市级', orderType: '线下', payType: '货到付款', currentStockCost: '现金', proCode: '00004', proName: 'xl测试00004', unit: '个', totalCategory: '3', totalQty: '3', totalCost: '33.00', totalAmount: '48.00', totalMl: '15.00', billName: '', auditDate: '2021-03-19 18:27:48' }
-            ],
-            count: 10
-          }
+        const params = Object.assign(parameter, this.queryParam)
+        this.spinning = true
+        delete params.time
+        delete params.warehouseCascade
+        if (params.dealerSn == 'all') {
+          params.dealerSn = ''
+        }
+        return reportSalesBillDetailList(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
         })
       },
+      totalData: null, //  合计
       addrProvinceList: [], //  省下拉
       addrCityList: [], //  市下拉
       addrDistrictList: [], //  区下拉
+      linkageGroupData: [],
       allocateTypeList: [], //  调拨类型
       custTypeList: [], //  客户类型 下拉数据
       settleStyleList: [], //  收款方式  下拉数据
@@ -264,10 +279,21 @@ export default {
     }
   },
   methods: {
-    //  时间  change
+    // 合计
+    getCount (params) {
+      reportSalesBillDetailCount(params).then(res => {
+        if (res.status == 200) {
+          this.totalData = res.data
+        } else {
+          this.totalData = null
+        }
+      })
+    },
+    //  创建时间  change
     dateChange (date) {
-      this.queryParam.beginDate = date[0]
-      this.queryParam.endDate = date[1]
+      this.queryParam.time = date
+      this.queryParam.beginDate = date[0] || ''
+      this.queryParam.endDate = date[1] || ''
     },
     //  查询
     handleSearch () {
@@ -282,16 +308,32 @@ export default {
     },
     //  重置
     resetSearchForm () {
-      this.queryParam.targetName = undefined
-      this.queryParam.code = ''
-      this.queryParam.name = ''
-      this.queryParam.origCode = ''
-      this.queryParam.productBrandSn = undefined
-      this.queryParam.productTypeSn1 = ''
-      this.queryParam.productTypeSn2 = ''
-      this.queryParam.productTypeSn3 = ''
+      this.queryParam.dealerSn = undefined
+      this.$refs.rangeDate.resetDate()
+      this.queryParam.time = []
+      this.queryParam.beginDate = ''
+      this.queryParam.endDate = ''
+      this.queryParam.salesTargetName = ''
+      this.queryParam.salesTargetType = undefined
+      this.queryParam.provinceSn = undefined
+      this.queryParam.citySn = undefined
+      this.queryParam.countySn = undefined
+      this.queryParam.settleStyleSn = undefined
+      this.queryParam.productEntity.productBrandSn = undefined
+      this.queryParam.productEntity.productTypeSn1 = ''
+      this.queryParam.productEntity.productTypeSn2 = ''
+      this.queryParam.productEntity.productTypeSn3 = ''
+      this.queryParam.productEntity.code = ''
+      this.queryParam.productEntity.name = ''
+      this.queryParam.warehouseSn = undefined
+      this.queryParam.warehouseLocationSn = undefined
+      this.queryParam.warehouseCascade = []
+      this.queryParam.salesBillNo = ''
+      this.queryParam.salesManName = ''
       this.productType = []
-      this.$refs.table.refresh(true)
+      this.$refs.ruleForm.resetFields()
+      this.totalData = null
+      this.$refs.table.clearTable()
     },
     filterOption (input, option) {
       return (
@@ -321,7 +363,7 @@ export default {
     },
     //  产品品牌  列表
     getProductBrand () {
-      dealerProductBrandQuery({ 'sysFlag': '0' }).then(res => {
+      dealerProductBrandQuery({}).then(res => {
         if (res.status == 200) {
           this.productBrandList = res.data
         } else {
@@ -331,13 +373,13 @@ export default {
     },
     //  产品分类  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] : ''
+      this.queryParam.productEntity.productTypeSn1 = val[0] ? val[0] : ''
+      this.queryParam.productEntity.productTypeSn2 = val[1] ? val[1] : ''
+      this.queryParam.productEntity.productTypeSn3 = val[2] ? val[2] : ''
     },
     //  产品分类  列表
     getProductType () {
-      dealerProductTypeList({ 'sysFlag': '0' }).then(res => {
+      dealerProductTypeList({}).then(res => {
         if (res.status == 200) {
           this.productTypeList = res.data
         } else {
@@ -345,9 +387,20 @@ export default {
         }
       })
     },
+    // 连锁店
+    getLinkageGroup () {
+      linkageGroupList({}).then(res => {
+        const all = [{ dealerName: '全部', dealerSn: 'all' }]
+        if (res.status == 200) {
+          const data = res.data || []
+          this.linkageGroupData = [...all, ...data]
+        } else {
+          this.linkageGroupData = all
+        }
+      })
+    },
     //  仓库仓位  级联  列表
     getWarehouseCascade () {
-      const _this = this
       warehouseCascadeList({}).then(res => {
         if (res.status == 200) {
           res.data.map(item => {
@@ -364,18 +417,28 @@ export default {
         }
       })
     },
+    // 仓库仓位change
+    warehouseCascadeChange (val) {
+      if (val && val.length > 0) {
+        this.queryParam.warehouseSn = val[0] || ''
+        this.queryParam.warehouseLocationSn = val[1] || ''
+      } else {
+        this.queryParam.warehouseSn = ''
+        this.queryParam.warehouseLocationSn = ''
+      }
+    },
     // 获取城市列表
     getCityList (val) {
       this.addrCityList = []
       this.addrDistrictList = []
-      this.queryParam.dealerCitySn = undefined
-      this.queryParam.dealerCountySn = undefined
+      this.queryParam.citySn = undefined
+      this.queryParam.countySn = undefined
       this.getArea('city', val)
     },
     // 获取区县列表
     getAreaList (val) {
       this.addrDistrictList = []
-      this.queryParam.dealerCountySn = undefined
+      this.queryParam.countySn = undefined
       this.getArea('district', val)
     },
     //  省/市/区
@@ -409,6 +472,7 @@ export default {
   },
   beforeRouteEnter (to, from, next) {
     next(vm => {
+      vm.getLinkageGroup()
       vm.getArea('province')
       vm.getCustTypeList()
       vm.getSettleStyleList()

+ 198 - 165
src/views/reportData/chainSalesReport/list.vue

@@ -1,126 +1,129 @@
 <template>
   <a-card size="small" :bordered="false" class="chainSalesReportList-wrap">
-    <a-alert :show-icon="false" type="error" message="注:连锁销售单报表包含急件销售数量、售价,连锁销售明细报表不包含急件销售数量、成本、售价" banner style="margin-bottom: 10px;" />
-    <!-- 搜索条件 -->
-    <div class="table-page-search-wrapper">
-      <a-form-model
-        id="chainSalesReportList-form"
-        ref="ruleForm"
-        :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="targetName">
-              <a-select
-                placeholder="请选择连锁店"
-                id="chainSalesReportList-targetName"
-                allowClear
-                v-model="queryParam.targetName"
-                :showSearch="true"
-                option-filter-prop="children"
-                :filter-option="filterOption">
-                <a-select-option v-for="item in allocateTypeList" :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="审核时间">
-              <rangeDate ref="rangeDate" @change="dateChange" />
-            </a-form-model-item>
-          </a-col>
-          <a-col :md="6" :sm="24">
-            <a-form-model-item label="客户名称">
-              <a-input id="chainSalesReportList-targetName" v-model.trim="queryParam.code" allowClear placeholder="请输入客户名称"/>
-            </a-form-model-item>
-          </a-col>
-          <template v-if="advanced">
+    <a-spin :spinning="spinning" tip="Loading...">
+      <a-alert :show-icon="false" type="error" message="注:连锁销售单报表包含急件销售数量、售价,连锁销售明细报表不包含急件销售数量、成本、售价" banner style="margin-bottom: 10px;" />
+      <!-- 搜索条件 -->
+      <div class="table-page-search-wrapper">
+        <a-form-model
+          id="chainSalesReportList-form"
+          ref="ruleForm"
+          :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="客户类型">
-                <a-select id="chainSalesReportList-customerType" v-model="queryParam.customerTypeSn" allowClear placeholder="请选择客户类型">
-                  <a-select-option v-for="item in custTypeList" :value="item.customerTypeSn" :key="item.customerTypeSn">{{ item.name }}</a-select-option>
+              <a-form-model-item label="连锁店" prop="dealerSn">
+                <a-select
+                  placeholder="请选择连锁店"
+                  id="chainSalesReportList-dealerSn"
+                  allowClear
+                  v-model="queryParam.dealerSn"
+                  :showSearch="true"
+                  option-filter-prop="children"
+                  :filter-option="filterOption">
+                  <a-select-option v-for="item in linkageGroupData" :key="item.dealerSn" :value="item.dealerSn">{{ item.dealerName }}</a-select-option>
                 </a-select>
               </a-form-model-item>
             </a-col>
-            <a-col :md="12" :sm="24">
-              <a-row>
-                <a-form-model-item label="客户所在区" :labelCol="{span: 4}" :wrapperCol="{ span: 20 }">
-                  <a-col span="7">
-                    <a-form-model-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-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" @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" 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>
             <a-col :md="6" :sm="24">
-              <a-form-model-item label="收款方式">
-                <a-select id="chainSalesReportList-settleStyleSn" v-model="queryParam.settleStyleSn" allowClear placeholder="请选择收款方式">
-                  <a-select-option v-for="item in settleStyleList" :value="item.settleStyleSn" :key="item.settleStyleSn">{{ item.name }}</a-select-option>
-                </a-select>
+              <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="单号">
-                <a-input id="chainSalesReportList-targetName" v-model.trim="queryParam.code" allowClear placeholder="请输入单号"/>
+              <a-form-model-item label="客户名称">
+                <a-input id="chainSalesReportList-salesTargetName" v-model.trim="queryParam.salesTargetName" allowClear placeholder="请输入客户名称"/>
               </a-form-model-item>
             </a-col>
-            <a-col :md="6" :sm="24">
-              <a-form-model-item label="业务员">
-                <a-input id="chainSalesReportList-targetName" v-model.trim="queryParam.code" allowClear placeholder="请输入业务员"/>
-              </a-form-model-item>
+            <template v-if="advanced">
+              <a-col :md="6" :sm="24">
+                <a-form-model-item label="客户类型">
+                  <a-select id="chainSalesReportList-salesTargetType" v-model="queryParam.salesTargetType" allowClear placeholder="请选择客户类型">
+                    <a-select-option v-for="item in custTypeList" :value="item.customerTypeSn" :key="item.customerTypeSn">{{ item.name }}</a-select-option>
+                  </a-select>
+                </a-form-model-item>
+              </a-col>
+              <a-col :md="12" :sm="24">
+                <a-row>
+                  <a-form-model-item label="客户所在区" :labelCol="{span: 4}" :wrapperCol="{ span: 20 }">
+                    <a-col span="7">
+                      <a-form-model-item prop="provinceSn" style="margin: 0;">
+                        <a-select v-model="queryParam.provinceSn" @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="citySn" style="margin: 0;">
+                        <a-select v-model="queryParam.citySn" @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="countySn" style="margin: 0;">
+                        <a-select v-model="queryParam.countySn" 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>
+              <a-col :md="6" :sm="24">
+                <a-form-model-item label="收款方式">
+                  <a-select id="chainSalesReportList-settleStyleSn" v-model="queryParam.settleStyleSn" allowClear placeholder="请选择收款方式">
+                    <a-select-option v-for="item in settleStyleList" :value="item.settleStyleSn" :key="item.settleStyleSn">{{ item.name }}</a-select-option>
+                  </a-select>
+                </a-form-model-item>
+              </a-col>
+              <a-col :md="6" :sm="24">
+                <a-form-model-item label="单号">
+                  <a-input id="chainSalesReportList-salesBillNo" v-model.trim="queryParam.salesBillNo" allowClear placeholder="请输入单号"/>
+                </a-form-model-item>
+              </a-col>
+              <a-col :md="6" :sm="24">
+                <a-form-model-item label="业务员">
+                  <a-input id="chainSalesReportList-salesManName" v-model.trim="queryParam.salesManName" allowClear placeholder="请输入业务员"/>
+                </a-form-model-item>
+              </a-col>
+            </template>
+            <a-col :md="6" :sm="24" style="margin-top: 3px;">
+              <a-button type="primary" @click="handleSearch" :disabled="disabled" id="chainSalesReportList-refresh">查询</a-button>
+              <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="chainSalesReportList-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" style="margin-top: 3px;">
-            <a-button type="primary" @click="handleSearch" :disabled="disabled" id="chainSalesReportList-refresh">查询</a-button>
-            <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="chainSalesReportList-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>
-    </div>
-    <!-- 合计 -->
-    <a-alert type="info" showIcon style="margin-bottom:15px">
-      <div class="ftext" slot="message">
-        总单数:<strong>1</strong>;
-        产品总数量:<strong>3</strong>;
-        总成本:<strong>¥33.00</strong>;
-        总售价:<strong>¥48.00</strong>;
-        总毛利:<strong>¥15.00</strong>。
+          </a-row>
+        </a-form-model>
       </div>
-    </a-alert>
-    <!-- 列表 -->
-    <s-table
-      class="sTable"
-      ref="table"
-      size="small"
-      :rowKey="(record) => record.id"
-      :columns="columns"
-      :data="loadData"
-      :scroll="{ x: 1170 }"
-      bordered>
-    </s-table>
+      <!-- 合计 -->
+      <a-alert type="info" showIcon style="margin-bottom:15px">
+        <div class="ftext" slot="message">
+          总单数:<strong>{{ (totalData && (totalData.totalRowSize || totalData.totalRowSize==0)) ? totalData.totalRowSize : '--' }}</strong>;
+          产品总数量:<strong>{{ (totalData && (totalData.totalQty || totalData.totalQty==0)) ? totalData.totalQty : '--' }}</strong>;
+          总成本:<strong>¥{{ (totalData && (totalData.totalCost || totalData.totalCost==0)) ? totalData.totalCost : '--' }}</strong>;
+          总售价:<strong>¥{{ (totalData && (totalData.totalPrice || totalData.totalPrice==0)) ? totalData.totalPrice : '--' }}</strong>;
+          总毛利:<strong>¥{{ (totalData && (totalData.totalProfit || totalData.totalProfit==0)) ? totalData.totalProfit : '--' }}</strong>。
+        </div>
+      </a-alert>
+      <!-- 列表 -->
+      <s-table
+        class="sTable"
+        ref="table"
+        size="small"
+        :rowKey="(record) => record.id"
+        :columns="columns"
+        :data="loadData"
+        :scroll="{ x: 1480 }"
+        :defaultLoadData="false"
+        bordered>
+      </s-table>
+    </a-spin>
   </a-card>
 </template>
 
@@ -130,73 +133,73 @@ import rangeDate from '@/views/common/rangeDate.vue'
 import { getArea } from '@/api/data'
 import { custTypeFindAllList } from '@/api/custType'
 import { settleStyleFindAllList } from '@/api/customer'
+import { reportSalesBillList, reportSalesBillCount, linkageGroupList } from '@/api/reportData'
 export default {
   components: { STable, VSelect, rangeDate },
   data () {
     return {
+      spinning: false,
       labelCol: { span: 8 },
       wrapperCol: { span: 16 },
       advanced: false, // 高级搜索 展开/关闭
       tableHeight: 0,
       queryParam: { //  查询条件
+        dealerSn: undefined,
+        time: [],
         beginDate: '',
         endDate: '',
-        targetName: undefined,
-        code: '', //  产品编码
-        name: '', //  产品名称
-        origCode: '', //  原厂编码
-        productBrandSn: undefined, //  产品品牌
-        productTypeSn1: '', //  产品一级分类
-        productTypeSn2: '', //  产品二级分类
-        productTypeSn3: '' //  产品三级分类
+        salesTargetName: '',
+        salesTargetType: undefined,
+        provinceSn: undefined, //  省
+        citySn: undefined, //  市
+        countySn: undefined, //  区
+        settleStyleSn: undefined,
+        salesBillNo: '',
+        salesManName: ''
       },
       rules: {
-        'targetName': [{ required: true, message: '请选择连锁店', trigger: 'change' }]
+        'dealerSn': [{ required: true, message: '请选择连锁店', trigger: 'change' }],
+        'time': [{ required: true, message: '请选择审核时间', trigger: 'change' }]
       },
       disabled: false, //  查询、重置按钮是否可操作
       exportLoading: false,
       columns: [
         { title: '序号', dataIndex: 'no', width: 80, align: 'center', fixed: 'left' },
-        { title: '销售单号', dataIndex: 'code', width: 220, align: 'center', customRender: function (text) { return text || '--' } },
-        { title: '客户名称', dataIndex: 'name', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
-        { title: '收款方式', dataIndex: 'currentStockCost', width: 165, align: 'center', customRender: function (text) { return text || '--' } },
-        { title: '款数', dataIndex: 'totalCategory', width: 165, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
-        { title: '数量', dataIndex: 'totalQty', width: 165, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
-        { title: '成本', dataIndex: 'totalCost', width: 165, align: 'center', customRender: function (text) { return ((text || text == 0) ? ('¥' + text) : '--') } },
-        { title: '售价', dataIndex: 'totalAmount', width: 165, align: 'center', customRender: function (text) { return ((text || text == 0) ? ('¥' + text) : '--') } },
-        { title: '毛利', dataIndex: 'totalMl', width: 165, align: 'center', customRender: function (text) { return ((text || text == 0) ? ('¥' + text) : '--') } },
-        { title: '业务员', dataIndex: 'billName', width: 165, align: 'center', customRender: function (text) { return text || '--' } },
-        { title: '审核时间', dataIndex: 'auditDate', width: 165, align: 'center', customRender: function (text) { return text || '--' } }
+        { title: '销售单号', dataIndex: 'salesBillNo', width: 220, align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '客户名称', dataIndex: 'salesTargetName', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
+        { title: '收款方式', dataIndex: 'settleStyleName', width: 150, align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '款数', dataIndex: 'totalCategory', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
+        { title: '数量', dataIndex: 'totalQty', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
+        { title: '成本', dataIndex: 'totalCost', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? ('¥' + text) : '--') } },
+        { title: '售价', dataIndex: 'totalPrice', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? ('¥' + text) : '--') } },
+        { title: '毛利', dataIndex: 'totalProfit', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? ('¥' + text) : '--') } },
+        { title: '业务员', dataIndex: 'salesManName', width: 150, align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
+        { title: '审核时间', dataIndex: 'salesAuditDate', width: 160, 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: [
-              { id: '1', code: '159177', name: '支持市级', currentStockCost: '现金', totalCategory: '3', totalQty: '3', totalCost: '33.00', totalAmount: '48.00', totalMl: '15.00', billName: '', auditDate: '2021-03-19 18:27:48' }
-            ],
-            count: 10
-          }
+        const params = Object.assign(parameter, this.queryParam)
+        this.spinning = true
+        delete params.time
+        if (params.dealerSn == 'all') {
+          params.dealerSn = ''
+        }
+        return reportSalesBillList(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
         })
       },
+      totalData: null, //  合计
+      linkageGroupData: [],
       addrProvinceList: [], //  省下拉
       addrCityList: [], //  市下拉
       addrDistrictList: [], //  区下拉
@@ -206,10 +209,21 @@ export default {
     }
   },
   methods: {
+    // 合计
+    getCount (params) {
+      reportSalesBillCount(params).then(res => {
+        if (res.status == 200) {
+          this.totalData = res.data
+        } else {
+          this.totalData = null
+        }
+      })
+    },
     //  创建时间  change
     dateChange (date) {
-      this.queryParam.beginDate = date[0]
-      this.queryParam.endDate = date[1]
+      this.queryParam.time = date
+      this.queryParam.beginDate = date[0] || ''
+      this.queryParam.endDate = date[1] || ''
     },
     //  查询
     handleSearch () {
@@ -224,16 +238,22 @@ export default {
     },
     //  重置
     resetSearchForm () {
-      this.queryParam.targetName = undefined
-      this.queryParam.code = ''
-      this.queryParam.name = ''
-      this.queryParam.origCode = ''
-      this.queryParam.productBrandSn = undefined
-      this.queryParam.productTypeSn1 = ''
-      this.queryParam.productTypeSn2 = ''
-      this.queryParam.productTypeSn3 = ''
-      this.productType = []
-      this.$refs.table.refresh(true)
+      this.queryParam.dealerSn = undefined
+      this.$refs.rangeDate.resetDate()
+      this.queryParam.time = []
+      this.queryParam.beginDate = ''
+      this.queryParam.endDate = ''
+      this.queryParam.salesTargetName = ''
+      this.queryParam.salesTargetType = undefined
+      this.queryParam.provinceSn = undefined
+      this.queryParam.citySn = undefined
+      this.queryParam.countySn = undefined
+      this.queryParam.settleStyleSn = undefined
+      this.queryParam.salesBillNo = ''
+      this.queryParam.salesManName = ''
+      this.$refs.ruleForm.resetFields()
+      this.totalData = null
+      this.$refs.table.clearTable()
     },
     filterOption (input, option) {
       return (
@@ -261,18 +281,30 @@ export default {
         }
       })
     },
+    // 连锁店
+    getLinkageGroup () {
+      linkageGroupList({}).then(res => {
+        const all = [{ dealerName: '全部', dealerSn: 'all' }]
+        if (res.status == 200) {
+          const data = res.data || []
+          this.linkageGroupData = [...all, ...data]
+        } else {
+          this.linkageGroupData = all
+        }
+      })
+    },
     // 获取城市列表
     getCityList (val) {
       this.addrCityList = []
       this.addrDistrictList = []
-      this.queryParam.dealerCitySn = undefined
-      this.queryParam.dealerCountySn = undefined
+      this.queryParam.citySn = undefined
+      this.queryParam.countySn = undefined
       this.getArea('city', val)
     },
     // 获取区县列表
     getAreaList (val) {
       this.addrDistrictList = []
-      this.queryParam.dealerCountySn = undefined
+      this.queryParam.countySn = undefined
       this.getArea('district', val)
     },
     //  省/市/区
@@ -306,6 +338,7 @@ export default {
   },
   beforeRouteEnter (to, from, next) {
     next(vm => {
+      vm.getLinkageGroup()
       vm.getArea('province')
       vm.getCustTypeList()
       vm.getSettleStyleList()

+ 26 - 8
src/views/reportData/chainStockReport/list.vue

@@ -13,16 +13,16 @@
           @keyup.enter.native="handleSearch" >
           <a-row :gutter="15">
             <a-col :md="6" :sm="24">
-              <a-form-model-item label="连锁店" prop="targetName">
+              <a-form-model-item label="连锁店" prop="dealerSn">
                 <a-select
                   placeholder="请选择连锁店"
-                  id="chainStockReportList-targetName"
+                  id="chainStockReportList-dealerSn"
                   allowClear
-                  v-model="queryParam.targetName"
+                  v-model="queryParam.dealerSn"
                   :showSearch="true"
                   option-filter-prop="children"
                   :filter-option="filterOption">
-                  <a-select-option v-for="item in allocateTypeList" :key="item.brandSn" :value="item.brandSn">{{ item.brandName }}</a-select-option>
+                  <a-select-option v-for="item in linkageGroupData" :key="item.dealerSn" :value="item.dealerSn">{{ item.dealerName }}</a-select-option>
                 </a-select>
               </a-form-model-item>
             </a-col>
@@ -124,6 +124,7 @@ import { STable, VSelect } from '@/components'
 import chainStockReportDetailModal from './detailModal.vue'
 import { dealerProductBrandQuery } from '@/api/dealerProductBrand'
 import { dealerProductTypeList } from '@/api/dealerProductType'
+import { linkageGroupList } from '@/api/reportData'
 import { reportStockList, reportStockCount } from '@/api/reportStock'
 export default {
   components: { STable, VSelect, chainStockReportDetailModal },
@@ -133,7 +134,7 @@ export default {
       advanced: false, // 高级搜索 展开/关闭
       tableHeight: 0,
       queryParam: { //  查询条件
-        targetName: undefined,
+        dealerSn: undefined,
         productCode: '', //  产品编码
         productName: '', //  产品名称
         productOrigCode: '', //  原厂编码
@@ -145,7 +146,7 @@ export default {
       labelCol: { span: 8 },
       wrapperCol: { span: 16 },
       rules: {
-        'targetName': [{ required: true, message: '请选择连锁店', trigger: 'change' }]
+        'dealerSn': [{ required: true, message: '请选择连锁店', trigger: 'change' }]
       },
       disabled: false, //  查询、重置按钮是否可操作
       exportLoading: false,
@@ -163,7 +164,10 @@ export default {
         this.disabled = true
         const params = Object.assign(parameter, this.queryParam)
         this.spinning = true
-        if (params.targetName) {
+        if (params.dealerSn) {
+          if (params.dealerSn == 'all') {
+            params.dealerSn = ''
+          }
           return reportStockList(params).then(res => {
             // 总计
             this.getCount(params)
@@ -193,6 +197,7 @@ export default {
         }
       },
       productType: [],
+      linkageGroupData: [],
       productBrandList: [], //  品牌下拉数据
       productTypeList: [], //  分类下拉数据
       allocateTypeList: [], //  调拨类型
@@ -226,7 +231,7 @@ export default {
     },
     //  重置
     resetSearchForm () {
-      this.queryParam.targetName = undefined
+      this.queryParam.dealerSn = undefined
       this.queryParam.productCode = ''
       this.queryParam.productName = ''
       this.queryParam.productOrigCode = ''
@@ -279,10 +284,23 @@ export default {
       return (
         option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
       )
+    },
+    // 连锁店
+    getLinkageGroup () {
+      linkageGroupList({}).then(res => {
+        const all = [{ dealerName: '全部', dealerSn: 'all' }]
+        if (res.status == 200) {
+          const data = res.data || []
+          this.linkageGroupData = [...all, ...data]
+        } else {
+          this.linkageGroupData = all
+        }
+      })
     }
   },
   beforeRouteEnter (to, from, next) {
     next(vm => {
+      vm.getLinkageGroup()
       vm.getProductBrand()
       vm.getProductType()
     })

+ 79 - 141
src/views/reportData/receivedSendStorageReport/list.vue

@@ -1,10 +1,10 @@
 <template>
-  <a-card size="small" :bordered="false" class="chainStockReportList-wrap">
+  <a-card size="small" :bordered="false" class="receivedSendStorageReportList-wrap">
     <!-- 搜索条件 -->
     <a-spin :spinning="spinning" tip="Loading...">
       <div class="table-page-search-wrapper">
         <a-form-model
-          id="chainStockReportList-form"
+          id="receivedSendStorageReportList-form"
           ref="ruleForm"
           :model="queryParam"
           :rules="rules"
@@ -13,18 +13,18 @@
           @keyup.enter.native="handleSearch" >
           <a-row :gutter="15">
             <a-col :md="6" :sm="24">
-              <a-form-model-item label="日期" prop="date">
-                <rangeDate ref="rangeDate" v-model="queryParam.date" @change="dateChange" />
+              <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="产品编码">
-                <a-input id="productInfoList-code" v-model.trim="queryParam.code" allowClear placeholder="请输入产品编码"/>
+                <a-input id="productInfoList-code" v-model.trim="queryParam.productEntity.code" allowClear placeholder="请输入产品编码"/>
               </a-form-model-item>
             </a-col>
             <a-col :md="6" :sm="24">
               <a-form-model-item label="产品名称">
-                <a-input id="productInfoList-name" v-model.trim="queryParam.name" allowClear placeholder="请输入产品名称"/>
+                <a-input id="productInfoList-name" v-model.trim="queryParam.productEntity.name" allowClear placeholder="请输入产品名称"/>
               </a-form-model-item>
             </a-col>
             <template v-if="advanced">
@@ -34,7 +34,7 @@
                     placeholder="请选择产品品牌"
                     id="productInfoList-productBrandSn"
                     allowClear
-                    v-model="queryParam.productBrandSn"
+                    v-model="queryParam.productEntity.productBrandSn"
                     :showSearch="true"
                     option-filter-prop="children"
                     :filter-option="filterOption">
@@ -57,9 +57,9 @@
                 </a-form-model-item>
               </a-col>
             </template>
-            <a-col :md="6" :sm="24">
-              <a-button type="primary" @click="handleSearch" :disabled="disabled" id="chainStockReportList-refresh">查询</a-button>
-              <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="chainStockReportList-reset">重置</a-button>
+            <a-col :md="6" :sm="24" style="margin-top: 3px;">
+              <a-button type="primary" @click="handleSearch" :disabled="disabled" id="receivedSendStorageReportList-refresh">查询</a-button>
+              <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="receivedSendStorageReportList-reset">重置</a-button>
               <a @click="advanced=!advanced" style="margin-left: 8px">
                 {{ advanced ? '收起' : '展开' }}
                 <a-icon :type="advanced ? 'up' : 'down'"/>
@@ -76,11 +76,19 @@
         :rowKey="(record) => record.id"
         :columns="columns"
         :data="loadData"
-        :scroll="{ x: 1170 }"
+        :scroll="{ x: 2530 }"
+        :defaultLoadData="false"
         bordered>
         <template slot="footer" slot-scope="currentPageData">
           <span>
-            合计: 期初数量:{{ totalData.beginQty || '--' }} &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;期初金额:{{ totalData.beginAmount || '--' }} &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 收入数量:{{ totalData.putQty || '--' }} &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 收入金额:{{ totalData.putAmount || '--' }} &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 发出数量:{{ totalData.outQty || '--' }} &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  发出金额:{{ totalData.outAmount || '--' }} &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 结算数量:{{ totalData.endQty || '--' }} &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 结算金额:{{ totalData.endAmount || '--' }}
+            合计: 期初数量:{{ (totalData && (totalData.beginQty || totalData.beginQty==0)) ? totalData.beginQty : '--' }} &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+            期初金额:{{ (totalData && (totalData.beginAmount || totalData.beginAmount==0)) ? totalData.beginAmount : '--' }} &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+            收入数量:{{ (totalData && (totalData.putQty || totalData.putQty==0)) ? totalData.putQty : '--' }} &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+            收入金额:{{ (totalData && (totalData.putAmount || totalData.putAmount==0)) ? totalData.putAmount : '--' }} &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+            发出数量:{{ (totalData && (totalData.outQty || totalData.outQty==0)) ? totalData.outQty : '--' }} &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+            发出金额:{{ (totalData && (totalData.outAmount || totalData.outAmount==0)) ? totalData.outAmount : '--' }} &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+            结算数量:{{ (totalData && (totalData.endQty || totalData.endQty==0)) ? totalData.endQty : '--' }} &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+            结算金额:{{ (totalData && (totalData.endAmount || totalData.endAmount==0)) ? totalData.endAmount : '--' }}
           </span>
         </template>
       </s-table>
@@ -93,124 +101,64 @@ import { STable, VSelect } from '@/components'
 import { dealerProductBrandQuery } from '@/api/dealerProductBrand'
 import { dealerProductTypeList } from '@/api/dealerProductType'
 import rangeDate from '@/views/common/rangeDate.vue'
-import { reportPageList, linkageReportTotal } from '@/api/reportData.js'
-// import { allocateBillList, allocateBillDel, allocateBillAudit, allocateBillExport } from '@/api/allocateBill'
-// import { allocateTypeAllList } from '@/api/allocateType'
+import { reportPageList, linkageReportTotal } from '@/api/reportData'
 export default {
   components: { STable, VSelect, rangeDate },
   data () {
     return {
       advanced: false, // 高级搜索 展开/关闭
-	  spinning: false,
+      spinning: false,
       tableHeight: 0,
       queryParam: { //  查询条件
+        time: [],
         beginDate: '',
         endDate: '',
-        date: [], // 日期
-        code: '', //  产品编码
-        name: '', //  产品名称
-        origCode: '', //  原厂编码
-        productBrandSn: undefined, //  产品品牌
-        productTypeSn1: '', //  产品一级分类
-        productTypeSn2: '', //  产品二级分类
-        productTypeSn3: '' //  产品三级分类
+        productEntity: {
+          code: '', //  产品编码
+          name: '', //  产品名称
+          productBrandSn: undefined, //  产品品牌
+          productTypeSn1: '', //  产品一级分类
+          productTypeSn2: '', //  产品二级分类
+          productTypeSn3: '' //  产品三级分类
+        }
       },
       labelCol: { span: 8 },
       wrapperCol: { span: 16 },
       rules: {
-        'date': [{ required: true, message: '请选择日期', trigger: 'change' }]
+        'time': [{ required: true, message: '请选择日期', trigger: 'change' }]
       },
       disabled: false, //  查询、重置按钮是否可操作
       exportLoading: false,
       columns: [
-        { title: '序号',
-          dataIndex: 'no',
-          width: 80,
-          align: 'center'
-          // fixed: 'left'
-        },
-        { title: '产品编码',
-          dataIndex: 'productCode',
-          width: 220,
-          align: 'center',
-          sorter: true,
-          customRender: function (text) {
-        	  return text || '--'
-          }
-        },
-        { title: '产品名称',
-          dataIndex: 'name',
-          width: 220,
-          align: 'center',
-          customRender: function (value, row, index) {
-        	  return row.productEntity && row.productEntity.name ? row.productEntity.name : '--'
-          },
-          ellipsis: true
-        },
-        { title: '品牌',
-          dataIndex: 'productBrandName',
-          align: 'center',
-          width: 200,
-          customRender: function (value, row, index) {
-        	  return row.productEntity && row.productEntity.productBrandName ? row.productEntity.productBrandName : '--'
-          }
-        },
-        { title: '三级分类',
-          dataIndex: 'productTypeName3',
-          width: 150,
-          align: 'center',
-          customRender: function (value, row, index) {
-        	  return row.productEntity && row.productEntity.productTypeName3 ? row.productEntity.productTypeName3 : '--'
-          }
-        },
-        { title: '原厂编码',
-          dataIndex: 'origCode',
-          width: 220,
-          align: 'center',
-          customRender: function (value, row, index) {
-        	  return row.productEntity && row.productEntity.origCode ? row.productEntity.origCode : '--'
-          }
-        },
-        { title: '单位',
-          dataIndex: 'unit',
-          width: 100,
-          align: 'center',
-          customRender: function (value, row, index) {
-        	  return row.productEntity && row.productEntity.unit ? row.productEntity.unit : '--'
-          }
-        },
+        { title: '序号', dataIndex: 'no', width: 80, align: 'center', fixed: 'left' },
+        { title: '产品编码', dataIndex: 'productCode', width: 220, align: 'center', customRender: function (text) { return text || '--' }, sorter: true },
+        { title: '产品名称', dataIndex: 'productEntity.name', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
+        { title: '品牌', dataIndex: 'productEntity.productBrandName', width: 200, align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '三级分类', dataIndex: 'productEntity.productTypeName3', width: 150, align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '原厂编码', dataIndex: 'productEntity.origCode', width: 200, align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '单位', dataIndex: 'productEntity.unit', width: 100, align: 'center', customRender: function (text) { return text || '--' } },
         { title: '期初数量', dataIndex: 'beginQty', width: 100, align: 'center', sorter: true, customRender: function (text) { return ((text || text == 0) ? text : '--') } },
-        { title: '期初单价(¥)', dataIndex: 'beginPrice', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
-        { title: '期初金额(¥)', dataIndex: 'beginAmount', width: 100, align: 'center', sorter: true, customRender: function (text) { return ((text || text == 0) ? text : '--') } },
+        { title: '期初单价(¥)', dataIndex: 'beginPrice', width: 120, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
+        { title: '期初金额(¥)', dataIndex: 'beginAmount', width: 120, align: 'center', sorter: true, customRender: function (text) { return ((text || text == 0) ? text : '--') } },
         { title: '收入数量', dataIndex: 'putQty', width: 100, align: 'center', sorter: true, customRender: function (text) { return ((text || text == 0) ? text : '--') } },
-        { title: '收入单价(¥)', dataIndex: 'putPrice', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
-        { title: '收入金额(¥)', dataIndex: 'putAmount', width: 100, align: 'center', sorter: true, customRender: function (text) { return ((text || text == 0) ? text : '--') } },
+        { title: '收入单价(¥)', dataIndex: 'putPrice', width: 120, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
+        { title: '收入金额(¥)', dataIndex: 'putAmount', width: 120, align: 'center', sorter: true, customRender: function (text) { return ((text || text == 0) ? text : '--') } },
         { title: '发出数量', dataIndex: 'outQty', width: 100, align: 'center', sorter: true, customRender: function (text) { return ((text || text == 0) ? text : '--') } },
-        { title: '发出单价(¥)', dataIndex: 'outPrice', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
-        { title: '发出金额(¥)', dataIndex: 'outAmount', width: 100, align: 'center', sorter: true, customRender: function (text) { return ((text || text == 0) ? text : '--') } },
+        { title: '发出单价(¥)', dataIndex: 'outPrice', width: 120, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
+        { title: '发出金额(¥)', dataIndex: 'outAmount', width: 120, align: 'center', sorter: true, customRender: function (text) { return ((text || text == 0) ? text : '--') } },
         { title: '结存数量', dataIndex: 'endQty', width: 100, align: 'center', sorter: true, customRender: function (text) { return ((text || text == 0) ? text : '--') } },
-        { title: '结存单价(¥)', dataIndex: 'endPrice', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
-        { title: '结存金额(¥)', dataIndex: 'endAmount', width: 100, align: 'center', sorter: true, customRender: function (text) { return ((text || text == 0) ? text : '--') } }
+        { title: '结存单价(¥)', dataIndex: 'endPrice', width: 120, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
+        { title: '结存金额(¥)', dataIndex: 'endAmount', width: 120, align: 'center', sorter: true, customRender: function (text) { return ((text || text == 0) ? text : '--') } }
       ],
       // 加载数据方法 必须为 Promise 对象
       loadData: parameter => {
+        this.disabled = true
+        const params = Object.assign(parameter, this.queryParam)
+        this.spinning = true
         if (this.queryParam.beginDate) {
-          this.disabled = true
-		  this.spinning = true
-          const params = {
-            beginDate: this.queryParam.beginDate,
-            endDate: this.queryParam.endDate,
-            productEntity: {
-              code: this.queryParam.code, //  产品编码
-              name: this.queryParam.name, //  产品名称
-              origCode: this.queryParam.origCode, //  原厂编码
-              productBrandSn: this.queryParam.productBrandSn, //  产品品牌
-              productTypeSn1: this.queryParam.productTypeSn1, //  产品一级分类
-              productTypeSn2: this.queryParam.productTypeSn2, //  产品二级分类
-              productTypeSn3: this.queryParam.productTypeSn3 //  产品三级分类
-            }
-          }
-          return reportPageList(Object.assign(parameter, params)).then(res => {
+          return reportPageList(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++) {
@@ -221,13 +169,17 @@ export default {
             return data
           })
         } else {
+          const _this = this
           return new Promise(function (resolve, reject) {
             const data = {
-			   pageNo: 1,
-			   pageSize: 10,
-			   list: [],
-			   count: 0
+              pageNo: 1,
+              pageSize: 10,
+              list: [],
+              count: 0
             }
+            _this.disabled = false
+            _this.spinning = false
+            _this.$message.info('请选择日期')
             resolve(data)
           })
         }
@@ -241,7 +193,7 @@ export default {
   methods: {
     //  时间  change
     dateChange (date) {
-      this.queryParam.date = date
+      this.queryParam.time = date
       this.queryParam.beginDate = date[0] || ''
       this.queryParam.endDate = date[1] || ''
     },
@@ -249,11 +201,7 @@ export default {
     handleSearch () {
       this.$refs.ruleForm.validate(valid => {
         if (valid) {
-          if (!this.queryParam.beginDate) {
-            return this.$message.error('请先选择日期')
-          }
           this.$refs.table.refresh(true)
-          this.getTotal()
         } else {
           console.log('error submit!!')
           return false
@@ -261,47 +209,37 @@ export default {
       })
     },
     // 查询总计
-    getTotal () {
-      const params = {
-        beginDate: this.queryParam.beginDate,
-        endDate: this.queryParam.endDate,
-        productEntity: {
-          code: this.queryParam.code, //  产品编码
-          name: this.queryParam.name, //  产品名称
-          origCode: this.queryParam.origCode, //  原厂编码
-          productBrandSn: this.queryParam.productBrandSn, //  产品品牌
-          productTypeSn1: this.queryParam.productTypeSn1, //  产品一级分类
-          productTypeSn2: this.queryParam.productTypeSn2, //  产品二级分类
-          productTypeSn3: this.queryParam.productTypeSn3 //  产品三级分类
-        }
-      }
+    getCount (params) {
       linkageReportTotal(params).then(res => {
         if (res.status == 200 && res.data) {
           this.totalData = res.data
         } else {
-          this.totalData = {}
+          this.totalData = null
         }
       })
     },
     //  重置
     resetSearchForm () {
-      this.queryParam.code = ''
-      this.queryParam.name = ''
-      this.queryParam.origCode = ''
-      this.queryParam.productBrandSn = undefined
-      this.queryParam.productTypeSn1 = ''
-      this.queryParam.productTypeSn2 = ''
-      this.queryParam.productTypeSn3 = ''
-      this.productType = []
       this.$refs.rangeDate.resetDate()
-      this.totalData = {}
+      this.queryParam.time = []
+      this.queryParam.beginDate = ''
+      this.queryParam.endDate = ''
+      this.queryParam.productEntity.code = ''
+      this.queryParam.productEntity.name = ''
+      this.queryParam.productEntity.productBrandSn = undefined
+      this.queryParam.productEntity.productTypeSn1 = ''
+      this.queryParam.productEntity.productTypeSn2 = ''
+      this.queryParam.productEntity.productTypeSn3 = ''
+      this.productType = []
+      this.$refs.ruleForm.resetFields()
+      this.totalData = null
       this.$refs.table.clearTable()
     },
     //  产品分类  change
     changeProductType (val, opt) {
-      this.queryParam.productTypeSn1 = val[0] ? val[0] : ''
-      this.queryParam.productTypeSn2 = val[1] ? val[1] : ''
-      this.queryParam.productTypeSn3 = val[2] ? val[2] : ''
+      this.queryParam.productEntity.productTypeSn1 = val[0] ? val[0] : ''
+      this.queryParam.productEntity.productTypeSn2 = val[1] ? val[1] : ''
+      this.queryParam.productEntity.productTypeSn3 = val[2] ? val[2] : ''
     },
     //  产品品牌  列表
     getProductBrand () {