小小儁爺
2024-07-30 aeecb103cf6fe1ba8ad5eb1fb22672853172db6a
1.增加列表数据求和功能
已修改3个文件
101 ■■■■■ 文件已修改
src/views/workOrder/produceOrderList.vue 41 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/workOrder/workOrderList.vue 30 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/workOrder/workOrderSend.vue 30 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/workOrder/produceOrderList.vue
@@ -172,6 +172,8 @@
          highlight-current-row
          :header-cell-style="this.$headerCellStyle"
          :cell-style="this.$cellStyle"
          :summary-method="getSummaries"
          show-summary
          @sort-change="sortChange"
          @selection-change="handleSelectionChange"
        >
@@ -1078,6 +1080,45 @@
    },
    tableRowClassName({ row, rowIndex }) {
      return 'custom-row'
    },
    getSummaries(param) {
      const { columns, data } = param
      const sums = []
      const i = 7
      columns.forEach((column, index) => {
        if (index === i) {
          sums[index] = '总数'
          return
        }
        const values = data.map(item => Number(item[column.property]))
        if (column.property === 'qty') {
          sums[index] = values.reduce((prev, curr) => {
            const value = Number(curr)
            if (!isNaN(value)) {
              return prev + curr
              // return Math.round(prev * 100) / 100 + Math.round(curr * 100) / 100
            }
          }, 0)
          sums[index] += ' 单'
        }
        if (column.property === 'relse_qty') {
          sums[index] = values.reduce((prev, curr) => {
            const value = Number(curr)
            if (!isNaN(value)) {
              return prev + curr
              // return Math.round(prev * 100) / 100 + Math.round(curr * 100) / 100
            }
          }, 0)
          sums[index] += ' 单'
        }
      })
      this.$nextTick(() => {
        this.$refs.tableDataRef.doLayout()
      })
      return sums
    }
  }
}
src/views/workOrder/workOrderList.vue
@@ -135,6 +135,8 @@
          :data="tableData"
          :height="isExpandForm?tableHeight:(tableHeight+80)+'px'"
          border
          :summary-method="getSummaries"
          show-summary
          :row-class-name="tableRowClassName"
          :style="{width: 100+'%',height:isExpandForm?tableHeight:(tableHeight+80)+'px'}"
          highlight-current-row
@@ -3657,6 +3659,34 @@
    },
    stepSelectedValueChange(val) {
      // console.log(val, 123)
    },
    getSummaries(param) {
      const { columns, data } = param
      const sums = []
      const i = 9
      columns.forEach((column, index) => {
        if (index === i) {
          sums[index] = '总数'
          return
        }
        const values = data.map(item => Number(item[column.property]))
        if (column.property === 'plan_qty') {
          sums[index] = values.reduce((prev, curr) => {
            const value = Number(curr)
            if (!isNaN(value)) {
              return prev + curr
              // return Math.round(prev * 100) / 100 + Math.round(curr * 100) / 100
            }
          }, 0)
          sums[index] += ' 单'
        }
      })
      this.$nextTick(() => {
        this.$refs.tableDataRef.doLayout()
      })
      return sums
    }
  }
}
src/views/workOrder/workOrderSend.vue
@@ -148,6 +148,8 @@
          :data="tableData"
          :height="isExpandForm?tableHeight:(tableHeight+80)+'px'"
          border
          :summary-method="getSummaries"
          show-summary
          :row-class-name="tableRowClassName"
          :style="{width: 100+'%',height:isExpandForm?tableHeight:(tableHeight+80)+'px'}"
          highlight-current-row
@@ -3105,6 +3107,34 @@
    },
    stepSelectedValueChange(val) {
      // console.log(val, 123)
    },
    getSummaries(param) {
      const { columns, data } = param
      const sums = []
      const i = 8
      columns.forEach((column, index) => {
        if (index === i) {
          sums[index] = '总数'
          return
        }
        const values = data.map(item => Number(item[column.property]))
        if (column.property === 'plan_qty') {
          sums[index] = values.reduce((prev, curr) => {
            const value = Number(curr)
            if (!isNaN(value)) {
              return prev + curr
              // return Math.round(prev * 100) / 100 + Math.round(curr * 100) / 100
            }
          }, 0)
          sums[index] += ' 单'
        }
      })
      this.$nextTick(() => {
        this.$refs.tableDataRef.doLayout()
      })
      return sums
    }
  }
}