element vue表格单选

表格内容

 <el-dialog
        :visible.sync="dialogVisible"
        :title="$t('新增批次')"
        width="50%"
        top="15vh">
        <el-form ref="lineForm" :model="lineForm" :rules="rules" label-width="100px" class="lineForm" style="display: flex;">
          <el-form-item :label="$t('计划时间')" prop="planDate" style="flex: 2;">
            <el-date-picker v-model="lineForm.planDate" :clearable="false" :start-placeholder="$t('LBL072STARTDATE')" :end-placeholder="$t('LBL072ENDDATE')" type="datetimerange" range-separator="-" format="yyyy-MM-dd HH:mm" value-format="yyyy-MM-dd HH:mm" @change="planDateChange"/>
          </el-form-item>
          <el-form-item :label="$t('单批数量')" prop="mainQty" style="flex: 1;">
            <el-input-number v-model="lineForm.mainQty" :min="1" class="input-number"/>
          </el-form-item>
          <el-button type="primary" @click="confirmSave()" style="margin-left: 20px;">保存</el-button>
        </el-form>
        <div style="text-align: right;padding-top: 40px">
          <el-input
            v-model="addSearchForm.woId"
            clearable
            :placeholder="$t('订单号')"
            style="width: 200px;"
          />
          <el-input
            v-model="addSearchForm.partNo"
            clearable
            :placeholder="$t('产品料号')"
            style="width: 200px;"
          />
          <el-button type="primary" style="margin-left: 20px;">查询</el-button>
        </div>
        <el-table
          :header-cell-style="{background:'#3eb6d8',color:'#fff'}"
          ref="multipleTable"
          :data="tableDataList"
          tooltip-effect="dark"
          style="width: 100%"
          border
          stripe
          :row-key="getRowKey"
          @selection-change="selectItem"
          @row-click="onSelectOp">
          <el-table-column
            type="selection"
            width="55">
          </el-table-column>
          <el-table-column
            label="工单号"
            prop="woId"
            width="120">
          </el-table-column>
          <el-table-column
            prop="partNo"
            label="产品料号"
            width="120">
          </el-table-column>
          <el-table-column
            prop="partName"
            label="产品描述"
            show-overflow-tooltip>
          </el-table-column>
          <el-table-column
            prop="totalQty"
            label="工单数量"
            show-overflow-tooltip>
          </el-table-column>
          <el-table-column
            prop="woStatus"
            label="状态"
            show-overflow-tooltip>
          </el-table-column>
          <el-table-column
            prop="releaseDate"
            label="下达时间"
            show-overflow-tooltip>
          </el-table-column>
          <el-table-column
            prop="createTime"
            label="创建时间"
            show-overflow-tooltip>
          </el-table-column>
        </el-table>

        <div class="block" style="padding-bottom: 40px; text-align: right;">
          <el-pagination
            :current-page="pagination.page"
            :page-sizes="[2, 5, 10, 20, 30, 40]"
            :page-size="pagination.size"
            layout="total, sizes, prev, pager, next, jumper"
            class="pagination"
            :total="pagination.total"
            @size-change="handlePaginationSizeChange"
            @current-change="handlePaginationCurrentChange"
          />
        </div>

      </el-dialog>

方法

/** 保存选中的数据编号 */
getRowKey(row) {
  return row.id
},

selectItem(rows) {
  if (rows.length > 1) {
    const newRows = rows.filter((it, index) => {
      if (index == rows.length - 1) {
        this.$refs.multipleTable.toggleRowSelection(it, true);
        return true;
      } else {
        this.$refs.multipleTable.toggleRowSelection(it, false);
        return false;
      }
    });
    this.multipleSelection = newRows;
  } else {
    this.multipleSelection = rows;
  }
},

onSelectOp(row) {
  this.$refs.multipleTable.clearSelection();
  this.$refs.multipleTable.toggleRowSelection(row, true);
  this.multipleSelection = [];
  this.multipleSelection.push(row);
},
  • 4
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值