最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

vue實現(xiàn)樹形表格

 更新時間:2021年09月18日 09:05:00   作者:Yasmine_ss  
這篇文章主要為大家詳細介紹了vue實現(xiàn)樹形表格,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下

本文實例為大家分享了vue實現(xiàn)樹形表格的具體代碼,,供大家參考,具體內容如下

效果如下:

居中的圖片:

代碼如下:

<template>
  <div class="treeTable">
    <table>
      <tr>
        <th>設備類型</th>
        <th>產品名稱</th>
        <th>版本</th>
        <th>檢查項</th>
        <th>檢查子項</th>
        <th>檢查大類</th>
        <th>設備小類</th>
        <th>備注</th>
      </tr>
      <tbody>
        <tr v-for="(item,index) in datas" :key="index" v-show="item.display">
          <td :style="{paddingLeft:item.left}"><span  @click="nodeClick(index)" v-if="item.branch" :class="item.expand? 'expand':'collapse'"></span>{{item.type}}</td>
          <td>{{item.name}}</td>
          <td>{{item.version}}</td>
          <td>{{item.checkItem}}</td>
          <td>{{item.checkSubItem}}</td>
          <td v-if="item.branch">{{item.BigItem}}</td>
          <td v-else><input type="text"  v-model="item.BigItem"></td>
          <td v-if="item.branch">{{item.smallItem}}</td>
          <td v-else><input type="text"  v-model="item.smallItem"></td>
          <td v-if="item.branch">{{item.remark}}</td>
          <td v-else><input type="text"  v-model="item.remark"></td>
        </tr>
      </tbody>
    </table>
  </div>
</template>

<script>
/* eslint-disable */ 
export default {
  name: 'treeTable',
  data () {
    return {
      msg: 'Welcome to Your Vue.js App',
      datas:[
          {left:'0',branch:true,expand:true,display:true,id:'1',pid:'0',type:'防火墻',name:'',version:'',checkItem:'',checkSubItem:'',BigItem:'',smallItem:'',remark:''},
          {left:'0.5rem',branch:true,expand:true,display:true,id:'1_1',pid:'1',type:'防火墻',name:'CE001',version:'',checkItem:'',checkSubItem:'',BigItem:'',smallItem:'',remark:''},
          {left:'1rem',branch:true,expand:true,display:true,id:'1_1_1',pid:'1_1',type:'防火墻',name:'CE001',version:'VR001',checkItem:'',checkSubItem:'',BigItem:'',smallItem:'',remark:''},
          {left:'1.5rem',branch:true,expand:true,display:true,id:'1_1_1_1',pid:'1_1_1',type:'防火墻',name:'CE001',version:'VR001',checkItem:'檢查項A',checkSubItem:'',BigItem:'',smallItem:'',remark:''},
          {left:'3rem',branch:false,expand:true,display:true,id:'1_1_1_1_1',pid:'1_1_1_1',type:'防火墻',name:'CE001',version:'VR001',checkItem:'檢查項A',checkSubItem:'檢查子項A',BigItem:'軟件版本',smallItem:'檢查項A',remark:'備注信息'},
          {left:'0',branch:true,expand:true,display:true,id:'2',pid:'0',type:'數(shù)據交換中心',name:'',version:'',checkItem:'',checkSubItem:'',BigItem:'',smallItem:'',remark:''},
          {left:'0.5rem',branch:true,expand:true,display:true,id:'2_1',pid:'2',type:'數(shù)據交換中心',name:'CE001',version:'',checkItem:'',checkSubItem:'',BigItem:'',smallItem:'',remark:''},
          {left:'1rem',branch:true,expand:true,display:true,id:'2_1_1',pid:'2_1',type:'數(shù)據交換中心',name:'CE001',version:'VR001',checkItem:'',checkSubItem:'',BigItem:'',smallItem:'',remark:''},
          {left:'1.5rem',branch:true,expand:true,display:true,id:'2_1_1_1',pid:'2_1_1',type:'數(shù)據交換中心',name:'CE001',version:'VR001',checkItem:'檢查項A',checkSubItem:'',BigItem:'',smallItem:'',remark:''},
          {left:'3rem',branch:false,expand:true,display:true,id:'2_1_1_1_1',pid:'2_1_1_1',type:'數(shù)據交換中心',name:'CE001',version:'VR001',checkItem:'檢查項A',checkSubItem:'檢查子項A',BigItem:'軟件版本',smallItem:'檢查項A',remark:'備注信息'},
        ],
    }
  },
  methods:{
    nodeClick(index){
      this.datas[index].expand = this.datas[index].expand ? false : true
      let pid =  this.datas[index].id 
      if(this.datas[index].expand){
        for(let i = index +1;i<this.datas.length;i++){
          let reg = new RegExp('^'+pid)
          if(this.datas[i].pid == pid){
            this.datas[i].display = true
            this.datas[i].expand = false 
          }else if(reg.test(this.datas[i].id)){
            this.datas[i].display = false
            this.datas[i].expand = false
          }else{
            break
          }
        }
      }else{
        for(let i = index +1;i<this.datas.length;i++){
          let reg = new RegExp('^'+pid)
          if(reg.test(this.datas[i].id)){
            this.datas[i].display = false
            this.datas[i].expand = false 
          }else{
            break
          }
        }
      }
      // for(let i = index +1;i<this.datas.length;i++){
      //   let reg = new RegExp('^'+pid)
      //   if(reg.test(this.datas[i].id)){
      //     if(this.datas[index].expand){
      //       this.datas[i].display = true
      //     }else{
      //       this.datas[i].display = false
      //       this.datas[i].expand = false 
      //     }
      //   }
      // }
    }
  }
}
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
th,td{
  width: 150px;
}
td:first-child{
  text-align: left;
}
td span{
  display: inline-block;
  width: 1.5rem;
  height: 1rem;
}
td span.expand{
  background-image: url('./folder_open.png');
}
td span.collapse{
  background-image: url('./folder.png');
}
</style>

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。

相關文章

  • 簡單的Vue SSR的示例代碼

    簡單的Vue SSR的示例代碼

    本篇文章主要介紹了簡單的 Vue SSR的示例代碼,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2018-01-01
  • 用vue實現(xiàn)注冊頁效果?vue實現(xiàn)短信驗證碼登錄

    用vue實現(xiàn)注冊頁效果?vue實現(xiàn)短信驗證碼登錄

    這篇文章主要為大家詳細介紹了用vue實現(xiàn)注冊頁,短信驗證碼登錄,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2021-11-11
  • vue使用技巧及vue項目中遇到的問題

    vue使用技巧及vue項目中遇到的問題

    這篇文章主要介紹了vue使用技巧及vue項目中遇到的問題,本文給大家?guī)淼闹皇且徊糠?,后續(xù)還會持續(xù)更新,感興趣的朋友跟隨腳本之家小編一起學習吧
    2018-06-06
  • Vue3+Element?Plus實現(xiàn)el-table跨行顯示(非腳手架)

    Vue3+Element?Plus實現(xiàn)el-table跨行顯示(非腳手架)

    這篇文章主要介紹了Vue3+Element Plus實現(xiàn)el-table跨行顯示(非腳手架),本文通過示例代碼給大家介紹的非常詳細,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2023-09-09
  • vue 動態(tài)設置img的src地址無效,npm run build 后找不到文件的解決

    vue 動態(tài)設置img的src地址無效,npm run build 后找不到文件的解決

    這篇文章主要介紹了vue 動態(tài)設置img的src地址無效,npm run build 后找不到文件的解決,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2020-07-07
  • vue實現(xiàn)數(shù)字動態(tài)翻牌的效果(開箱即用)

    vue實現(xiàn)數(shù)字動態(tài)翻牌的效果(開箱即用)

    這篇文章主要介紹了vue實現(xiàn)數(shù)字動態(tài)翻牌的效果(開箱即用),實現(xiàn)原理是激將1到9的數(shù)字豎直排版,通過translate移動位置顯示不同數(shù)字,本文通過實例代碼講解,需要的朋友可以參考下
    2019-12-12
  • vue實現(xiàn)簡潔文件上傳進度條功能

    vue實現(xiàn)簡潔文件上傳進度條功能

    這篇文章主要介紹了vue實現(xiàn)簡潔文件上傳進度條功能,實現(xiàn)原理是通過performance.now()獲取動畫的時間戳,用于創(chuàng)建流暢的動畫,結合示例代碼介紹的非常詳細,需要的朋友可以參考下
    2024-06-06
  • vant中如何修改用戶的頭像

    vant中如何修改用戶的頭像

    這篇文章主要介紹了vant中如何修改用戶的頭像,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2022-08-08
  • 詳解Vue2 無限級分類(添加,刪除,修改)

    詳解Vue2 無限級分類(添加,刪除,修改)

    本篇文章主要介紹了詳解Vue2 無限級分類(添加,刪除,修改) ,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2017-03-03
  • vue3+element-plus?Dialog對話框的使用與setup?寫法的用法

    vue3+element-plus?Dialog對話框的使用與setup?寫法的用法

    這篇文章主要介紹了vue3+element-plus?Dialog對話框的使用?與?setup?寫法的使用,本文通過兩種方式結合實例代碼給大家介紹的非常詳細,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2023-04-04

最新評論

西昌市| 阜阳市| 垦利县| 福州市| 茂名市| 西和县| 阳谷县| 丰镇市| 威宁| 沧源| 沂水县| 昌江| 阿拉善右旗| 中超| 巴东县| 蓝山县| 山西省| 高安市| 肃宁县| 榆林市| 新邵县| 马公市| 靖安县| 宝兴县| 拉孜县| 平山县| 永兴县| 琼结县| 洛川县| 乳源| 澜沧| 广南县| 贡山| 广水市| 洛阳市| 潜江市| 襄城县| 隆尧县| 师宗县| 乐安县| 古交市|