前端在表单中修改数据

第一步

 第二步(添加使用输入框)

第三步(添加按钮)

第四步(让input和span)只显示一个

第五步(让编辑显示,其他隐藏)

第六步(√  提交 和 ×  刷新   )

第七步 (修改价格后,变成付费视频)

 第八步(下架后才能修改)

第一步 

<el-table-column label="视频定价" align="center" prop="videoPrice" show-overflow-tooltip>
</el-table-column>

第二步

<el-table-column label="视频定价" align="center" prop="videoPrice" show-overflow-tooltip>
  <template slot-scope="scope">
    <span>¥</span><span > {{scope.row.videoPrice}}</span>
    <el-input  style="width:60px;" v-model="scope.row.videoPrice"/>
  </template>
</el-table-column>

 第三步

<el-table-column label="视频定价" align="center" prop="videoPrice" show-overflow-tooltip>
  <template slot-scope="scope">
    <span>¥</span><span> {{scope.row.videoPrice}}</span>
    <el-input  style="width:60px;" v-model="scope.row.videoPrice"/>
    <el-button icon="el-icon-edit" type="text"></el-button>
    <el-button icon="el-icon-check" type="text"></el-button>
    <el-button icon="el-icon-close" type="text"></el-button>
  </template>
</el-table-column>

第四步

在data中先定义一个modifyPrice(默认为true)

modifyPrice: true,
<el-table-column label="视频定价" align="center" prop="videoPrice" show-overflow-tooltip>
  <template slot-scope="scope">
    <span>¥</span><span  v-show="modifyPrice"> {{scope.row.videoPrice}}</span>
    <el-input  style="width:60px;"  v-show="!modifyPrice" v-model="scope.row.videoPrice"/>
    <el-button icon="el-icon-edit"  type="text"></el-button>
    <el-button icon="el-icon-check" type="text"></el-button>
    <el-button icon="el-icon-close" type="text"></el-button>
  </template>
</el-table-column>

给编辑一个点击事件(点击为false)

<el-table-column label="视频定价" align="center" prop="videoPrice" show-overflow-tooltip>
  <template slot-scope="scope">
    <span>¥</span><span  v-show="modifyPrice"> {{scope.row.videoPrice}}</span>
    <el-input  style="width:60px;"  v-show="!modifyPrice" v-model="scope.row.videoPrice"/>
    <el-button icon="el-icon-edit"  type="text" v-model="scope.row.videoPrice" @click="modifyPrice = false"/>
    <el-button icon="el-icon-check" type="text"/>
    <el-button icon="el-icon-close" type="text"/>
  </template>
</el-table-column>

第五步

<template slot-scope="scope">
  <span>¥</span><span  v-show="modifyPrice"> {{scope.row.videoPrice}}</span>
  <el-input  style="width:60px;"  v-show="!modifyPrice" v-model="scope.row.videoPrice"/>
  <el-button icon="el-icon-edit"  type="text" v-if="modifyPrice==true " v-model="scope.row.videoPrice" @click="modifyPrice = false"/>
  <el-button icon="el-icon-check" type="text" v-else-if="!modifyPrice"/>
  <el-button icon="el-icon-close" type="text" v-if="!modifyPrice"/>
</template>

第六步

<template slot-scope="scope">
  <span>¥</span><span  v-show="modifyPrice"> {{scope.row.videoPrice}}</span>
  <el-input  style="width:60px;"  v-show="!modifyPrice" v-model="scope.row.videoPrice"/>
  <el-button icon="el-icon-edit"  type="text" v-if="modifyPrice==true " v-model="scope.row.videoPrice" @click="modifyPrice = false"/>
  <el-button icon="el-icon-check" type="text" v-else-if="!modifyPrice" @click="updatePrice(scope.row) "/>
  <el-button icon="el-icon-close" type="text"v-if="!modifyPrice" @click="resetPrice"/>
</template>
//关闭刷新
resetPrice() {
  this.getList();
  this.modifyPrice = true;
},
//修改价格
updatePrice(val) {
  this.form.id = val.id;                       
  this.form.videoPrice = val.videoPrice       //将id和价格传过去
  this.modifyPrice = true;                    //关闭√和× 
  if (this.form.id != null) {                 //id为空判断
    updateVideo(this.form).then(res => {      //调用提交接口
      if (res.code === 200) {
        this.msgSuccess("修改成功");
        this.getList();
      }
    })
  }
},

第七步

//修改价格
updatePrice(val) {
  this.form.id = val.id;
  this.form.videoPrice = val.videoPrice
  this.modifyPrice = true;
  if (val.videoPrice <= 0) {
    this.form.videoStatus = '2'  //价格小于等于0 变成付费
  } else {
    this.form.videoStatus = '1'
  }
  if (this.form.id != null) {
    updateVideo(this.form).then(res => {
      if (res.code === 200) {
        this.msgSuccess("修改成功");
        this.getList();
      }
    })
  }
},

 第八步

<template slot-scope="scope">
  <span>¥</span><span  v-show="modifyPrice || scope.row.isPutaway == '1'"> {{scope.row.videoPrice}}</span>
  <el-input  style="width:60px;"  v-show="!modifyPrice && scope.row.isPutaway == '0'" v-model="scope.row.videoPrice"/>
  <el-button icon="el-icon-edit"  type="text" v-if="modifyPrice==true && scope.row.isPutaway == '0' " v-model="scope.row.videoPrice" @click="modifyPrice = false"/>
  <el-button icon="el-icon-check" type="text" v-else-if="!modifyPrice && scope.row.isPutaway == '0'" @click="updatePrice(scope.row) "/>
  <el-button icon="el-icon-close" type="text"v-if="!modifyPrice && scope.row.isPutaway == '0'" @click="resetPrice"/>
</template>
  • 17
    点赞
  • 22
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值