element UI的el-table-column获取index

我们是的后台管理系统是用的vue 框架和element ui开发的,其中有一个表格页面,点击表格行数拿到index进行操作,需求是点击‘对此发奖’按钮,拿到当前行对应的基金代码名称这些,所有需要拿到index
element UI的el-table-column获取index_第1张图片

页面代码如下:


@click="handleDelete(scope. i n d e x , s c o p e . r o w ) " 这 个 点 击 方 法 里 面 的 s c o p e . index, scope.row)" 这个点击方法里面的scope. index,scope.row)"scope.index就是当前行的索引,scope.row可以拿到当前行的数据,如果想要传参给后台,就可以使用这两个数据,

handleDelete(idnex, row) {
    // 使用$confirm方法前端体验更好
      this.$confirm("确认是否发奖?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "success"
      })
      //$confirm 点确定执行方法
        .then(() => {
        //点击确定请求接口
          this.axios(
            api.experiencePrize,
            {
              fundCode: row.fundCode, //基金名称
              transAmount: row.transAmount, //体验金额
            },
            "post"
          )
            .then(data => {
            // 接口请求成功
              if (data.code === "000000") {
                this.$message({
                  message: data.msg ? "成功" + data.msg : "成功",
                  type: "warning",
                  duration: "2000"
                });
              } else {
                this.$message({
                  message: data.msg ? "失败" + data.msg : "失败",
                  type: "warning"
                });
              }
            })
            // 接口请求失败
            .catch(data => {
              this.$message({
                message: data.msg ? "更新失败 " + data.msg : "更新失败",
                type: "warning"
              });
            });
        })
        // $confirm 点取消执行方法
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消删除"
          });
        });
    },

接口返回的1、2、3 分别代表是、否、其他,则在页面展示使用:formatter=“formatterStatus”
代码如下:

formatterBannerOs: function(row, column, cellValue) {
      if (cellValue == "F") {
        return "否";
      } else if (cellValue == "T") {
        return " 是";
      } else if (cellValue == "S") {
        return "用户页面已展示";
      } else {
        return cellValue;
      }
    },

今天的分享就到这里,有更好的建议请在评论去留言,谢谢!

你可能感兴趣的:(vue)