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>
相关推荐
ElasticPDF-新国产PDF编辑器4 小时前
Vue use pdf.js and Elasticpdf tutorial
vue.js·pdf
Billy Qin6 小时前
Tree - Shaking
前端·javascript·vue.js
月明长歌6 小时前
Vue + Axios + Mock.js 全链路实操:从封装到数据模拟的深度解析
前端·javascript·vue.js·elementui·es6
头顶秃成一缕光6 小时前
若依——基于AI+若依框架的实战项目(实战篇(下))
java·前端·vue.js·elementui·aigc
冴羽yayujs7 小时前
SvelteKit 最新中文文档教程(17)—— 仅服务端模块和快照
前端·javascript·vue.js·前端框架·react
海石7 小时前
vue2升级vue3踩坑——【依赖注入】可能成功了,但【依赖注入】成功了不太可能
前端·vue.js·响应式设计
cypking8 小时前
解决 axios get请求瞎转义问题
vue.js
向阳2568 小时前
SpringBoot+vue前后端分离整合sa-token(无cookie登录态 & 详细的登录流程)
java·vue.js·spring boot·后端·sa-token·springboot·登录流程
艾克马斯奎普特8 小时前
Vue.js 3 渐进式实现之响应式系统——第一节:系列开篇与响应式基本实现
vue.js
梅子酱~9 小时前
Vue 学习随笔系列二十二 —— 表格高度自适应
javascript·vue.js·学习