avue-crud中双击表格变成输入框进行输入

二、使用步骤

1.引入库

代码如下(示例):

<avue-crud
              :option="ladderCarOption"
              :table-loading="loading"
              ref="ladderCarForm"
              @row-dblclick="handleRowDBLClick1"
            >
 <template slot="price" slot-scope="scope">
                <div v-if="row1 == scope.row.$index">
                  <el-input
                    placeholder="请输入收费标准(元)"
                    v-model="scope.row.price"
                    oninput="if(isNaN(value)) { value=value.replace(value,'')} if(value.length > 10) {value=value.slice(0,10)} if(value < 0) {value=value.replace(value,'')} if(value.indexOf('.')>0){value=value.slice(0,value.indexOf('.')+3)}"
                    @blur="updateData(scope.row.price, scope.row.$index, scope.row)"
                    v-focus
                  ></el-input>
                </div>
                <div v-else>
                  {{ scope.row.price }}
                </div>
              </template>
              </avue-crud>

2.读入数据

代码如下(示例):

data(){
row1 :-1,
a:'',
tmpRow :{},
},
methods:{
 handleRowDBLClick1(row, event, column) {
      this.tmpRow = {}
      console.log(this.row, row, row.$index, column)
      this.row1 = row.$index
      this.tmpRow = row
      this.tmpRow.id = row.$index
      this.a = this.ladderCarData[row.$index].price
    },
     updateData(value, index, row) {
      console.log(value, this.a, '----')
      this.$confirm('请确认是否更改收费标准', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
      })
        .then(() => {
          this.ladderCarData[index].price = value
          this.row1 = -1
        })
        .catch(() => {
          console.log('00000000', this.tmpRow.price)
          this.row1 = -1
          this.ladderCarData[index].price = this.a
        })
    },
},

  • 3
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值