lilei 9 kuukautta sitten
vanhempi
commit
24d101c21c
1 muutettua tiedostoa jossa 49 lisäystä ja 80 poistoa
  1. 49 80
      src/views/salesManagement/salesQueryNew/productSalesRecordModal.vue

+ 49 - 80
src/views/salesManagement/salesQueryNew/productSalesRecordModal.vue

@@ -8,41 +8,31 @@
     @close="isShow=false"
     :z-index="150"
     wrapClassName="salesRecord-modal jg-drawer-wrap"
-    width="70%">
+    width="80%">
     <div v-if="isShow">
       <div ref="searchBox">
         <div style="padding: 0 0 10px 0;line-height: 24px;" v-if="baseData">
           <div style="flex:1">产品编码:{{ baseData.productCode }}</div>
           <div style="flex:1">产品名称:{{ baseData.productName }}</div>
         </div>
-        <a-tabs size="small" type="card" v-model="curTab" @change="callback">
-          <a-tab-pane key="1" tab="当前客户">
-          </a-tab-pane>
-          <a-tab-pane key="2" tab="全部客户">
-          </a-tab-pane>
+        <a-tabs id="sales-record-tab" size="small" type="card" v-model="curTab" @change="callback">
+          <a-tab-pane key="1" tab="当前客户" id="sales-record-tab1"></a-tab-pane>
+          <a-tab-pane key="2" tab="全部客户" id="sales-record-tab2"></a-tab-pane>
         </a-tabs>
       </div>
       <!-- 表格 -->
-      <a-table
-        class="sTable"
+      <s-table
+        class="sTable fixPagination"
         ref="table"
+        :style="{ height: tableHeight+84+'px' }"
         size="small"
         :rowKey="(record) => record.id"
-        :scroll="{ y: tableHeight }"
         :columns="columns"
-        :dataSource="list"
-        :loading="loading"
-        :pagination="false"
+        :data="loadData"
+        :scroll="{ y:tableHeight }"
+        :defaultLoadData="false"
         bordered>
-      </a-table>
-      <!-- 分页 -->
-      <tablePagination
-        ref="tablePagination"
-        :total="paginationProps.total"
-        :current="paginationProps.current"
-        :pageSize="paginationProps.pageSize"
-        @changePageSize="changePageSize"
-        @changePage="changePage" />
+      </s-table>
     </div>
   </a-drawer>
 </template>
@@ -61,7 +51,7 @@ export default {
       type: Boolean,
       default: false
     },
-    itemId: {
+    itemId: { // 单据id
       type: [Number, String],
       default: ''
     }
@@ -75,36 +65,51 @@ export default {
     const _this = this
     return {
       isShow: this.openModal, //  是否打开弹框
-      tableHeight: 0,
-      buyerSn: null,
+      tableHeight: 0, // 表格高度
+      buyerSn: null, // 客户sn
       queryParam: {
-        productSn: null
+        productSn: null // 产品sn
       },
       // 表头
       columns: [
-        { title: '销售单号', dataIndex: 'salesBillNo', width: 150, align: 'center', customRender: function (text) { return text || '--' } },
-        { title: '销售时间', dataIndex: 'salesBillEntity.createDate', width: 150, align: 'center', customRender: function (text) { return text || '--' } },
-        { title: '销售价', dataIndex: 'price', width: 100, align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '销售数量', dataIndex: 'qty', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
-        { title: '客户名称', dataIndex: 'salesBillEntity.buyerNameCurrent', width: 200, align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
-        { title: '单据来源', dataIndex: 'salesBillEntity.sourceTypeDictValue', width: 100, align: 'center', customRender: function (text) { return text || '--' } }
+        { title: '序号', dataIndex: 'no', align: 'center', width: '5%' },
+        { title: '销售单号', dataIndex: 'salesBillNo', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '销售时间', dataIndex: 'salesBillEntity.createDate', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '销售价', dataIndex: 'price', width: '10%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
+        { title: '销售数量', dataIndex: 'qty', width: '10%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
+        { title: '客户名称', dataIndex: 'salesBillEntity.buyerNameCurrent', width: '45%', align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '单据来源', dataIndex: 'salesBillEntity.sourceTypeDictValue', width: '10%', align: 'center', customRender: function (text) { return text || '--' } }
       ],
-      list: [],
-      loading: false,
-      curTab: '1',
-      paginationProps: {
-        total: 0, //  分页总条数
-        current: 1,
-        pageSize: 20
+      // 加载数据方法 必须为 Promise 对象
+      loadData: parameter => {
+        this.disabled = true
+        this.spinning = true
+        // 查询列表
+        return salesRecordlList(Object.assign(parameter, this.queryParam)).then(res => {
+          let data
+          if (res.status == 200) {
+            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
+          this.setTableH()
+          return data
+        })
       },
-      baseData: null
+      curTab: '1', // 当前页签
+      baseData: null // 基础信息
     }
   },
   methods: {
+    // 计算表格高度
     setTableH () {
       this.$nextTick(() => {
         const searchBoxH = this.$refs.searchBox.offsetHeight
-        this.tableHeight = window.innerHeight - searchBoxH - 235
+        this.tableHeight = window.innerHeight - searchBoxH - 255
       })
     },
     //  获取详情
@@ -116,45 +121,12 @@ export default {
         delete this.queryParam.buyerSn
       }
       this.queryParam.productSn = productSn
-      this.handelSearch(1)
       this.baseData = row
-    },
-    // 查询列表
-    handelSearch (pageNo) {
-      this.paginationProps.current = pageNo || this.paginationProps.current
-      const params = {
-        pageNo: this.paginationProps.current,
-        pageSize: this.paginationProps.pageSize
-      }
-      // 开始查询
-      this.loading = true
-      salesRecordlList({ ...params, ...this.queryParam }).then(res => {
-        this.loading = false
-        if (res.status == 200) {
-          const data = res.data
-          this.paginationProps.total = Number(res.data.count) || 0
-          this.paginationProps.current = data.pageNo
-          this.list = data.list
-        } else {
-          this.paginationProps.total = 0
-          this.paginationProps.current = 1
-          this.paginationProps.pageSize = 20
-          this.list = []
-        }
-        this.setTableH()
+      this.$nextTick(() => {
+        this.$refs.table.refresh(true)
       })
     },
-    //  分页  一页多少条change
-    changePageSize (current, pageSize) {
-      this.paginationProps.current = current
-      this.paginationProps.pageSize = pageSize
-      this.handelSearch()
-    },
-    //  分页 页码change
-    changePage (current) {
-      this.paginationProps.current = current
-      this.handelSearch()
-    },
+    // 选择选项卡tab后
     callback (key) {
       this.curTab = key
       this.getDetail(this.buyerSn, this.queryParam.productSn, this.baseData)
@@ -172,11 +144,8 @@ export default {
     isShow (newValue, oldValue) {
       if (!newValue) {
         this.$emit('close')
-        this.paginationProps.total = 0
-        this.paginationProps.current = 1
-        this.paginationProps.pageSize = 20
+        // 重置数据
         this.curTab = '1'
-        this.list = []
       }
     }
   }