charles
2024-08-06 5ecb7958c96d3f0b6d47b79aff7eb306c2cf690f
src/components/makepager/TableCommonView.vue
@@ -22,7 +22,7 @@
      :summary-method="getSummaries"
      :show-summary="showSummary"
    >
      <el-table-column v-if="tableList.selectBox" type="selection" width="40"> </el-table-column>
      <el-table-column v-if="tableList.selectBox" type="selection" width="40" :selectable="selectable"> </el-table-column>
      <el-table-column v-if="tableList.selectIndex" type="index" label="序号" width="50"> </el-table-column>
      <el-table-column
        v-for="(item, i) in tableList.tableColumn"
@@ -102,6 +102,10 @@
export default {
  name: "TableCommonView",
  props: {
      warehouseId:{
        type:Number,
        default:0
      },
    tableList: {
      type: Object,
      default: () => {
@@ -151,6 +155,15 @@
    showSummary: {
      type: Boolean,
      default: false
    },
    // 列表不可选的数据
    selectBoxList: {
      type: Array,
      default: () => []
    },
    name:{
      type:String,
      default:''
    }
  },
  data() {
@@ -210,12 +223,20 @@
    },
    // 单选行相关
    tableRowClassName({ row }) {
      if (Object.keys(this.selectClassRow).length > 0) {
        if (row.id == this.selectClassRow.id) {
          return "onSelect"
        if(this.$route.query.workType!=1){
            if(Object.keys(this.selectClassRow).length>0&&this.selectClassRow.location){
                if(this.selectClassRow.id==row.id&&this.selectClassRow.location.warehouseId==row.location.warehouseId&&row.location.name==this.selectClassRow.location.name){
                    return "onSelect";
                }
            }
        } else{
            if (Object.keys(this.selectClassRow).length > 0) {
                if (row.id == this.selectClassRow.id) {
                    return "onSelect"
                }
            }
        }
      }
      this.$emit("tableRowClassName", row)
      this.$emit("tableRowClassName", row);
    },
    timeAgo(val) {
      return timeago(val)
@@ -232,7 +253,7 @@
          }
          this.tableList.countcol.forEach((countcols) => {
            if (column.label === countcols) {
              const values = data.map((item) => Number(item[column.property]))
              const values = (data||[]).map((item) => Number(item[column.property]))
              if (!values.every((value) => isNaN(value))) {
                sums[index] = values.reduce((prev, curr) => {
                  const value = Number(curr)
@@ -253,6 +274,28 @@
          })
        })
        return sums
      }
    },
    selectable(row) {
      let prop='id'
      if(this.name=='product'){
        prop='productId'
      }
      if(this.$route.query.workType!=1){
         const flag= this.selectBoxList.some(item=>{
             if(item.location){
                 return item[prop]==row.id&&item.location.warehouseId==row.location.warehouseId&&item.location.name==row.location.name;
             }
            return false;
         })
          return !flag;
      }else{
          let list = (this.selectBoxList||[]).map((item) => item[prop])
          if (list.findIndex((v) => v == row.id) == -1) {
              return true
          } else {
              return false
          }
      }
    }
  }
@@ -392,6 +435,7 @@
  .el-table__cell.is-right {
    text-align: right !important;
  }
  .el-table::before{ width: 0px; }
}
.overSpread1 {
  width: 100%;