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>
相关推荐
2401_857600951 小时前
SSM 与 Vue 共筑电脑测评系统:精准洞察电脑世界
前端·javascript·vue.js
2401_857600951 小时前
数字时代的医疗挂号变革:SSM+Vue 系统设计与实现之道
前端·javascript·vue.js
GDAL1 小时前
vue入门教程:组件透传 Attributes
前端·javascript·vue.js
轻口味1 小时前
Vue.js 核心概念:模板、指令、数据绑定
vue.js
2402_857583491 小时前
基于 SSM 框架的 Vue 电脑测评系统:照亮电脑品质之路
前端·javascript·vue.js
java_heartLake2 小时前
Vue3之性能优化
javascript·vue.js·性能优化
ddd君317743 小时前
组件的声明、创建、渲染
vue.js
前端没钱4 小时前
从 Vue 迈向 React:平滑过渡与关键注意点全解析
前端·vue.js·react.js
顽疲4 小时前
springboot vue 会员收银系统 含源码 开发流程
vue.js·spring boot·后端
羊小猪~~4 小时前
前端入门之VUE--ajax、vuex、router,最后的前端总结
前端·javascript·css·vue.js·vscode·ajax·html5