饿了么 ui table 编辑 删除

1 ! 2! 3! pong~~~

先看笑果


el-table.gif

不多bibi, 上代码

<el-table
  style="width: 100%"
  border
  :data="copyData"
  stripe
  @cell-dblclick="dblhandleCurrentChange"
  @cell-click="currentChange"
  :highlight-current-row="true"
>
  <el-table-column
    v-for="(item,index) in tableHead"
    :prop="item.column_name"
    :label="item.column_comment"
    :key="index"
  >
    <template slot-scope="scope">
      <!-- <span>{{ scope.row.isEdit }}</span> -->
      <span v-if="scope.row.isEdit && currentTableId === scope.row.index">
        <el-input v-model="scope.row[item.column_name]" size="mini" placeholder="请输入内容"></el-input>
      </span>
      <span v-else>{{ scope.row[item.column_name] }}</span>
    </template>
  </el-table-column>
  <el-table-column label="操作">
    <template slot-scope="scope">
      <el-button  // 编辑 和 确认
        :type="scope.row.isEdit &&  currentTableId === scope.row.index ? 'success' :'primary'"
        :icon="scope.row.isEdit &&  currentTableId === scope.row.index ? 'el-icon-check' :'el-icon-edit'"
        circle
        @click="(e) => (handleEdit(scope.$index, scope.row,scope.row.isEdit,e))"
      ></el-button>
      <el-button  //  取消编辑
        v-show="scope.row.isEdit &&  currentTableId === scope.row.index"
        type="danger"
        icon="el-icon-close"
        circle
        @click="(e) => cacle(scope.$index, scope.row,scope.row.isEdit,e)"
      ></el-button>
      <el-button  // 删除
        v-if="operation === 1 "
        v-show="!scope.row.isEdit ||  currentTableId != scope.row.index"
        icon="el-icon-delete"
        circle
        type="danger"
        @click="(e) => handleDelete(scope.$index, scope.row,scope.row.isEdit,e)"
      ></el-button>
    </template>
  </el-table-column>
</el-table>

然后再看一哈数据合适

        tableHead: [
          {
            column_name: "stage_name",
            column_comment: "阶段名称"
          },
          {
            column_name: "staring_height",
            column_comment: "持续时间(min)"
          },
          {
            column_name: "end_height",
            column_comment: "开始温度(°C)"
          },
          {
            column_name: "duration",
            column_comment: "结束温度(°C)"
          }
        ],
    
        tableData: [
          {
            stage_name: "新任务1",
            staring_height: "1 ",
            end_height: "1",
            isEdit: false,
            duration: "1",
            index:0
    
          },
        ]
  欢迎指教,感谢打扰  bye ! ! ! !

有问题邮箱聊 2838370086@qq.com

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • (o゜▽゜)o☆ 青椒味的Hello World 没有项目工程,没有vue脚手架,就一个HTML页面;没有干货,纯...
    dobby_l阅读 14,558评论 0 6
  • indexedDB,非关系型数据库,W3C标准推荐 indexedDB是一种轻量级NOSQL数据库,是由浏览器自带...
    HROKKO阅读 13,641评论 1 5
  • 望乡寻踪,少时竟朦胧;庙宇玄妙,秋之零零总总;街巷酒肆,过眼片片是幻;移步又换景,景景触心撩情。乡音无改,吴音不自...
    JoshuaChinnery阅读 1,477评论 0 0
  • 与孩子相处,是不是缺的就是时间,往往工作忙,回家累到瘫,有心无力,实际上并非如此。换句话说,即便不上班,真正给孩子...
    Hellen66阅读 2,271评论 0 1
  • 今日得到 1.如果说,自恋是人类的本质之一,那每个人都需要别人对自己说:你是好的。越是重要的人告诉你,你是好的,这...
    Pheeb阅读 1,580评论 0 0

友情链接更多精彩内容