Explorar el Código

Merge branch 'master' of https://git.steerinfo.com/DAL-DAZHOU/icore-pass

liyg hace 2 años
padre
commit
df2aa01ffe

+ 177 - 28
src/views/sale/components/transportFreight/saleTruckSettlement/bmsTruckDetailsOrderNew.vue

@@ -144,6 +144,7 @@
               :data="visibleList"
               :span-method="objectSpanMethod"
               ref="tableRef"
+              class="untable"
               border
               style="width: 100%"
               :height="maxHeight"
@@ -160,6 +161,7 @@
               @resetTable="reset"
               @select="selectOne"
               @selection-change="handleSelectionChange()"
+              @select-all="unSetteleAllselect"
             >
               <el-table-column type="selection" width="30" label="选择">
               </el-table-column>
@@ -370,6 +372,7 @@
             <el-table
               :data="visibleList1"
               :span-method="objectSpanMethod1"
+              class="tabled"
               ref="tableRef1"
               border
               style="width: 100%"
@@ -378,6 +381,7 @@
               @filter-change="filterChange"
               id="salesLogisticsStat_saleSteelReports_table"
               individual-panel
+              @select-all="setteldAllselect"
             >
               <el-table-column
                 type="selection"
@@ -839,6 +843,7 @@ export default {
       //单选框
       tableRadio: '',
       debounceS: false,
+      debounceS1: false,
       carNumber: '',
       activeName: 'first',
       //弹出框
@@ -1115,7 +1120,15 @@ export default {
       excludeTax: null,
       statementList: [],
       showStatementUpLoad: false,
-      selecteddetailsOrderAmount: 0
+      selecteddetailsOrderAmount: 0,
+      scrollLeft: 0,
+      scrollLeft1: 0,
+      scrollTop1: 0,
+      scrollLeftFlag1: 0,
+      scrollLeftFlag: 0,
+      //全选事件
+      setteldAllselectValue: 0,
+      unSetteleAllselectValue: 0
     }
   },
   created() {
@@ -1163,12 +1176,34 @@ export default {
         this.scrollLeftFlag = 1
       }
     },
+    scrollLeft1: {
+      immediate: true,
+      deep: true,
+      handler(val) {
+        this.scrollLeftFlag1 = 1
+      }
+    },
     tableData: {
       handler(oldVal, newVal) {
-        this.filterListChange()
+        this.$nextTick(() => {
+          if (this.activeName == 'first') {
+            this.filterListChange(newVal)
+          }
+        })
+      },
+      deep: true,
+      immediate: false
+    },
+    tableData1: {
+      handler(oldVal, newVal) {
+        this.$nextTick(() => {
+          if (this.activeName == 'second') {
+            this.filterListChange(newVal)
+          }
+        })
       },
       deep: true,
-      immediate: true
+      immediate: false
     },
     scrollTop: {
       immediate: true,
@@ -1178,31 +1213,73 @@ export default {
           if (
             val >=
             this.tableData.length * 30 -
-              document.querySelector('.el-table__body-wrapper').offsetHeight -
+              document.querySelector('.untable .el-table__body-wrapper')
+                .offsetHeight -
               20
           ) {
             val =
               this.tableData.length * 30 -
-              document.querySelector('.el-table__body-wrapper').offsetHeight
+              document.querySelector('.untable .el-table__body-wrapper')
+                .offsetHeight
           }
           if (val <= 0) {
             val = 0
           }
           document.querySelector(
-            '.el-table__body-wrapper .el-table__body'
+            '.untable .el-table__body-wrapper .el-table__body'
           ).style.transform = `translateY(${val}px)`
           const start = Math.floor(val / this.itemHeight)
           this.visibleList = this.tableData.slice(
             start,
             start + Math.floor(this.maxHeight / this.itemHeight) + 1
           )
+          this.getSpanArr(this.visibleList)
+          this.debounceS = false
+        })
+      }
+    },
+    scrollTop1: {
+      immediate: true,
+      deep: true,
+      handler(val) {
+        this.$nextTick(() => {
+          if (
+            val >=
+            this.tableData1.length * 30 -
+              document.querySelector('.tabled .el-table__body-wrapper')
+                .offsetHeight -
+              20
+          ) {
+            val =
+              this.tableData1.length * 30 -
+              document.querySelector('.tabled .el-table__body-wrapper')
+                .offsetHeight
+          }
+          if (val <= 0) {
+            val = 0
+          }
+          document.querySelector(
+            '.tabled .el-table__body-wrapper .el-table__body'
+          ).style.transform = `translateY(${val}px)`
+          const start = Math.floor(val / this.itemHeight)
           this.visibleList1 = this.tableData1.slice(
             start,
             start + Math.floor(this.maxHeight / this.itemHeight) + 1
           )
-          this.getSpanArr(this.visibleList)
-          this.getSpanArr1(this.visibleList1)
-          this.debounceS = false
+          this.getSpanArr(this.visibleList1)
+          this.debounceS1 = false
+        })
+      }
+    },
+    activeName: {
+      immediate: true,
+      handler(oldVal, newVal) {
+        this.$nextTick(() => {
+          if (newVal == 'first') {
+            this.filterListChange(this.tableData)
+          } else {
+            this.filterListChange(this.tableData1)
+          }
         })
       }
     }
@@ -1230,6 +1307,16 @@ export default {
       this.scrollLeft = e.target.scrollLeft
       this.scrollUpdateSelectFlag = 1
     })
+    this.$refs.tableRef1.bodyWrapper.addEventListener('scroll', e => {
+      if (this.scrollLeftFlag1 == 1 && this.debounceS1 == true) {
+        this.debounceS1 = false
+      }
+      if (this.debounceS1) return
+      this.debounceS1 = true
+      this.scrollTop1 = e.target.scrollTop
+      this.scrollLeft1 = e.target.scrollLeft
+      this.scrollUpdateSelectFlag1 = 1
+    })
   },
   activated() {
     this.maxHeight =
@@ -1237,6 +1324,22 @@ export default {
   },
   computed: {},
   methods: {
+    unSetteleAllselect() {
+      console.log('监听全选事件')
+      if (this.unSetteleAllselectValue == 0) {
+        this.unSetteleAllselectValue = 1
+      } else {
+        this.unSetteleAllselectValue = 0
+      }
+    },
+    setteldAllselect() {
+      console.log('监听全选事件')
+      if (this.setteldAllselectValue == 0) {
+        this.setteldAllselectValue = 1
+      } else {
+        this.setteldAllselectValue = 0
+      }
+    },
     selectOne(selection, row) {
       console.log('selection:', row)
       this.rowClick(row)
@@ -1245,7 +1348,13 @@ export default {
       this.amsPriceList = []
       this.makeSurePriceOrderList = []
       this.someOnePriceValueList = []
+      let data = []
       console.log(this.$refs.tableRef.selection, 'selection')
+      if (this.unSetteleAllselectValue == 1) {
+        data = this.tableData
+      } else {
+        data = this.$refs.tableRef.selection
+      }
       let mapvalue = {
         placeId: '',
         priceValue: '',
@@ -1254,7 +1363,7 @@ export default {
       let mapValue1 = {
         detailsAmount: ''
       }
-      this.makeSurePriceOrderList = this.$refs.tableRef.selection.map(e => {
+      this.makeSurePriceOrderList = data.map(e => {
         //运价判断
         mapValue1.detailsAmount = e.detailsAmount
         this.someOnePriceValueList.push(mapValue1)
@@ -1300,7 +1409,13 @@ export default {
         })
         return
       }
-      let orderList = this.$refs.tableRef1.selection.map(e => {
+      let data = []
+      if (this.setteldAllselectValue == 1) {
+        data = this.tableData1
+      } else {
+        data = this.$refs.tableRef1.selection
+      }
+      let orderList = data.map(e => {
         return e.orderId
       })
       let map = {
@@ -1318,6 +1433,7 @@ export default {
               this.$refs.tableRef.clearSelection()
               this.getSteelReport()
               this.makeSurePriceOrderList = []
+              this.setteldAllselectValue = 0
               this.$message({
                 type: 'success',
                 message: '取消确认执行价成功',
@@ -1377,6 +1493,7 @@ export default {
             this.$refs.tableRef.clearSelection()
             this.getSteelReport()
             this.makeSurePriceOrderList = []
+            this.unSetteleAllselectValue = 0
             this.$message({
               type: 'success',
               message: '确认执行价成功',
@@ -1412,11 +1529,17 @@ export default {
       } else {
         this.excludeTax = null
         this.statementList = []
-        this.selecteddetailsOrderAmount = this.$refs.tableRef1.selection.reduce(
-          (prev, item) => {
-            return item.detailsAmount + prev
-          },
-          0
+        let data = []
+        if (this.setteldAllselectValue == 1) {
+          data = this.tableData1
+        } else {
+          data = this.$refs.tableRef1.selection
+        }
+        this.selecteddetailsOrderAmount = data.reduce((prev, item) => {
+          return item.detailsAmount + prev
+        }, 0)
+        this.selecteddetailsOrderAmount = this.selecteddetailsOrderAmount.toFixed(
+          2
         )
         console.log(
           this.selecteddetailsOrderAmount,
@@ -1434,7 +1557,12 @@ export default {
         this.$message.warning('请上传发票')
         this.isLoading = false
       } else {
-        let orderList = this.$refs.tableRef1.selection.map(e => {
+        if (this.setteldAllselectValue == 1) {
+          data = this.tableData1
+        } else {
+          data = this.$refs.tableRef1.selection
+        }
+        let orderList = data.map(e => {
           return e.orderId
         })
         let formData = new window.FormData()
@@ -1456,6 +1584,7 @@ export default {
           console.log('uploadRes:', res)
           if (res.data.status == 'succeed') {
             this.$message.success('上传成功!')
+            this.setteldAllselectValue = 0
             this.closeUpload()
           } else {
             this.$message.error(res.data.data)
@@ -2016,21 +2145,28 @@ export default {
       this.onclick(this.filterMap)
     },
     //控制筛选数组变化
-    filterListChange() {
+    filterListChange(data) {
+      if (data.length == 0) {
+        if (this.activeName == 'first') {
+          data = this.tableData
+        } else {
+          data = this.tableData1
+        }
+      }
       //客户筛选数组
-      let consigneeNameList = this.tableData.map(e => {
+      let consigneeNameList = data.map(e => {
         return e.consigneeName
       })
       //承运商筛选数组
-      let carrierNameList = this.tableData.map(e => {
+      let carrierNameList = data.map(e => {
         return e.carrierName
       })
       //车号筛选数组
-      let capacityList = this.tableData.map(e => {
+      let capacityList = data.map(e => {
         return e.newCapacityNo
       })
       //物资筛选数组
-      let materialNameList = this.tableData
+      let materialNameList = data
         .map(e => {
           return e.materialName
         })
@@ -2038,38 +2174,38 @@ export default {
           return e != null
         })
       //销售片区筛选数组
-      let saleAreaList = this.tableData
+      let saleAreaList = data
         .map(e => {
           return e.areaName
         })
         .filter(e => {
           return e != null
         })
-      let addressPlaceList = this.tableData
+      let addressPlaceList = data
         .map(e => {
           return e.addressPlace
         })
         .filter(e => {
           return e != null
         })
-      let orderStatusList = this.tableData
+      let orderStatusList = data
         .map(e => {
           return e.orderStatus
         })
         .filter(e => {
           return e != null
         })
-      let materialSpeList = this.tableData
+      let materialSpeList = data
         .map(e => {
           return e.materialSpe
         })
         .filter(e => {
           return e != null
         })
-      let saleOrderStatusList = this.tableData.map(e => {
+      let saleOrderStatusList = data.map(e => {
         return e.saleOrderStatus
       })
-      let saleRemarkList = this.tableData.map(e => {
+      let saleRemarkList = data.map(e => {
         return e.saleRemark
       })
       this.filterConsigneeList = []
@@ -3201,6 +3337,7 @@ export default {
             )
             this.getSpanArr(this.visibleList)
             this.getTotalNum(this.tableData)
+            this.filterListChange(this.tableData)
             loading.close()
           })
           .catch(() => {
@@ -3312,6 +3449,7 @@ export default {
             console.log(this.visibleList1, 'this.visibleList1')
             this.getSpanArr1(this.visibleList1)
             this.getTotalNum(this.tableData1)
+            this.filterListChange(this.tableData1)
             loading.close()
           })
           .catch(() => {
@@ -3486,6 +3624,11 @@ export default {
           console.log(this.visibleList)
           this.getSpanArr(this.visibleList)
           this.getTotalNum(this.tableData)
+          if (this.activeName == 'first') {
+            this.filterListChange(this.tableData)
+          } else {
+            this.filterListChange(this.tableData1)
+          }
           loading.close()
         })
         .catch(() => {
@@ -3532,6 +3675,11 @@ export default {
           console.log(this.visibleList1)
           this.getSpanArr1(this.visibleList1)
           this.getTotalNum(this.tableData1)
+          if (this.activeName == 'first') {
+            this.filterListChange(this.tableData)
+          } else {
+            this.filterListChange(this.tableData1)
+          }
         })
         .catch(() => {
           loading.close()
@@ -3561,6 +3709,7 @@ export default {
 
     ::-webkit-scrollbar {
       height: 20px;
+      width: 10px;
       background-color: transparent;
     }
   }