element ui table 每行不同状态

table 每行定义值

tableData: [ { name: '',type:'',location:'', ziduan:'',createtype:'',ziduanvalue:'',checkAll:true,checkedCities: ['空', 'null', 'str随机', 'int随机'],isIndeterminate: 'true',table_id:'single',downloaddisabled:'true',deldisabled:'true'}

],

table column

v-model="scope.row.checkedCities

本来一个入参改成两个入参,需要传入index

@change="(val) => handleCheckAllChange(val,scope.$index)"

设置table某行值

this.tableData[id].ziduanvalue = " "

列某时只显示一个,v-show table内不起作用,用v-if 可以

v-if="tableisDisabled"

<template>
    <div>
       <el-container style="height:100%;">
           <el-container>
              <el-main >
                <br>
               <div style="width:40%">
                  
                   <template>
                        <el-table :data="tableData" border style="width: 100%">
                       
                          <el-table-column prop="ziduanvalue" label="字段值" width="300" v-if="tableisDisabled">
                              <template slot="header" slot-scope="scope" >
                                  <el-tooltip class="item" effect="dark" placement="top">
                                  <div slot="content">多个字段值用英文;隔开,字段多个数值用英文逗号,隔开</div>
                                  <span>字段值<i class="el-icon-info"></i></span>
                                  </el-tooltip>
                             </template>
                               <template slot-scope="scope" >
                                     <el-input v-model="scope.row.ziduanvalue" placeholder="请输入内容"></el-input>
                               </template>

                             </el-table-column>
                          <el-table-column prop="ziduanvalue" label="字段值" width="300"  v-if="tableisDisabled2">
                              <template slot="header" slot-scope="scope" >
                                  <el-tooltip class="item" effect="dark" placement="top">
                                  <div slot="content">多个字段值用英文;隔开,字段多个数值用英文逗号,隔开</div>
                                  <span>字段值<i class="el-icon-info"></i></span>
                                  </el-tooltip>
                             </template>

                                <template slot-scope="scope" >
                                  <el-checkbox :indeterminate="isIndeterminate" v-model="scope.row.checkAll" @change="(val) => handleCheckAllChange(val,scope.$index)">全选</el-checkbox>
                                  <div style="margin: 15px 0;"></div>
                                  <el-checkbox-group v-model="scope.row.checkedCities" @change="(value) => handleCheckedCitiesChange(value,scope.$index)">
                                    <el-checkbox v-for="city in cities" :label="city" :key="city">{{city}}</el-checkbox>
                                  </el-checkbox-group>
                                </template>

                             </el-table-column>
                            
                                              </el-table>
                                                  
                                            </template>


               </el-main>
           </el-container>
       </el-container>
    </div>
</template>

<script>
    const cityOptions = ['空', 'null', 'str随机', 'int随机'];
    import axios from 'axios'
    const instance = axios.create({
       timeout: 1000*60*10 // 设置超时时间为10分钟
    });
    export default{
        name:"CreatJmx",
            data() {
               return {
                    //dialogcreateVisible:false,
                    //isDisabled:false,
                    downloaddisabled:true,
                    deldisabled:true,
                    tableData: [
                          {  name: '',type:'',location:'', ziduan:'',createtype:'',ziduanvalue:'',checkAll:true,checkedCities: ['空', 'null', 'str随机', 'int随机'],isIndeterminate: 'true',table_id:'single',downloaddisabled:'true',deldisabled:'true'}
                    ],
                     

                    form: {
                            filename:'',
                    },
                    fileList: [] ,// 绑定的文件列表
                    tableidall:'all',
                    //checkAll: true,
                   // checkedCities: ['空', 'null', 'str随机', 'int随机'],
                    cities: cityOptions,
                   // isIndeterminate: true,
                    tableisDisabled:true,
                    tableisDisabled2:false

                }
            },
            components:{

            },
            mounted:function(){

            // mounted关闭
            },
             methods: {
              handleCheckAllChange(val,id) {
                console.log(val,id)
                this.tableData[id].checkedCities = val ? cityOptions : [];
                this.tableData[id].isIndeterminate = false;
                this.tableData[id].ziduanvalue = this.tableData[id].checkedCities.join(',')
                console.log(this.tableData[id].checkedCities.join(','))
              },
              handleCheckedCitiesChange(value,id) {
                console.log(value,id)
                let checkedCount = value.length;
                this.tableData[id].checkAll = checkedCount === this.cities.length;
                this.tableData[id].isIndeterminate = checkedCount > 0 && checkedCount < this.cities.length;
                this.tableData[id].ziduanvalue = this.tableData[id].checkedCities.join(',')
                console.log(this.tableData[id].checkedCities.join(','))

              },
                   
                 selectchange(value,id) {
                    console.log('生成类型',value)
                    if(value === "yichang"){
                        console.log('异常')
                        console.log(this.tableData[id].checkedCities.join(','))
                        this.tableData[id].ziduanvalue = this.tableData[id].checkedCities.join(',')
                        //this.tableData[id].isDisabled = true
                        //console.log(this.tableData[id].isDisabled)
                        this.tableisDisabled2 = true
                        this.tableisDisabled = false
                        console.log(this.tableisDisabled,this.tableisDisabled2)
                    }
                    else{
                        this.tableData[id].ziduanvalue = " "
                        //this.tableData[id].isDisabled = false
                        //console.log(this.tableData[id].isDisabled)
                        this.tableisDisabled = true
                        this.tableisDisabled2 = false
                        console.log(this.tableisDisabled,this.tableisDisabled2)
                    }

                 }
             //methods结束
             }
    }
</script>
相关推荐
刚刚好ā43 分钟前
js作用域超全介绍--全局作用域、局部作用、块级作用域
前端·javascript·vue.js·vue
芋芋qwq2 小时前
Unity UI射线检测 道具拖拽
ui·unity·游戏引擎
会发光的猪。3 小时前
css使用弹性盒,让每个子元素平均等分父元素的4/1大小
前端·javascript·vue.js
鸿蒙自习室3 小时前
鸿蒙多线程开发——线程间数据通信对象02
ui·harmonyos·鸿蒙
天下代码客3 小时前
【vue】vue中.sync修饰符如何使用--详细代码对比
前端·javascript·vue.js
周全全4 小时前
Spring Boot + Vue 基于 RSA 的用户身份认证加密机制实现
java·vue.js·spring boot·安全·php
ZwaterZ4 小时前
vue el-table表格点击某行触发事件&&操作栏点击和row-click冲突问题
前端·vue.js·elementui·c#·vue
码农六六4 小时前
vue3封装Element Plus table表格组件
javascript·vue.js·elementui
徐同保4 小时前
el-table 多选改成单选
javascript·vue.js·elementui
快乐小土豆~~4 小时前
el-input绑定点击回车事件意外触发页面刷新
javascript·vue.js·elementui