[備忘]element2.x Card和Table都設(shè)置高度

  • el-card 要設(shè)置高度
  • el-table 要設(shè)置高度
<template>
  <el-card class="wait-task-user-box-card">
    <!-- style="padding-top: 10px; padding-left: 10px;" -->
    <div class="opt-task-panel">
      <!-- 查詢區(qū)域 -->
      <div style="border-bottom: 1px solid #d4d2d2;">
        <el-form inline>
          <el-form-item label="客戶名稱:">
            <el-input style="width: 180px" v-model="companyName" clearable></el-input>
          </el-form-item>
          <el-form-item label="地址:">
            <el-cascader v-model="cascade_value" :props="cascade_props" @change="handlerCascadeChange"
                         style="width: 330px">
            </el-cascader>
          </el-form-item>
          <el-form-item label="">
            <el-button type="primary" @click="handleSearch">查詢</el-button>
          </el-form-item>
        </el-form>
        <el-checkbox v-model="stateFlag" style="margin: 5px 5px 10px 0;font-weight: bold;">過濾正在分配中的客戶</el-checkbox>
      </div>


      <!-- table -->
      <el-table :data="tableData" :height="tableHeight">
        <el-table-column type="expand">
          <template slot-scope="props">
            <div v-for="(item, index) of fieldLabelArr" :key="index">
              <span :class="{'field-bold': should_filed_bold(fieldKeyArr[index])}">
                {{ item + ':' }}</span><span>{{ props.row[fieldKeyArr[index]] }}
              </span>
            </div>
          </template>
        </el-table-column>
        <el-table-column label="客戶名稱" prop="companyName" style="width: 10%;"></el-table-column>
        <el-table-column label="" style="width: 10%;">
          <!-- slot-scope="props" -->
          <template slot-scope="props">
            <el-button type="primary" v-if="!props.row['state']" @click="handleTaskAdd(props.row)">分配</el-button>
            <template v-else>
              <el-button v-if="props.row['state'] == 'VALID'" @click="handleTaskCancel(props.row['taskId'])"
                         style="background-color: orange;border-color: orange;">取消任務(wù)</el-button>
              <span v-if="props.row['state'] == 'CANCEL'">已取消</span>
            </template>
          </template>
        </el-table-column>
      </el-table>

      <!-- 分頁條 -->
      <el-pagination layout="prev, pager, next" @current-change="handleCurrentChange"
                     :current-page.sync="currentPage" :total="total" :page-size="pageSize"
                     style="margin: 10px 0 5px 0">
      </el-pagination>

    </div>
  </el-card><!--root-->
</template>
<script>
import { base_url } from "@/common/constant";
import axios from "axios";
export default {
  mame: 'OptTaskPanel',
  props: ['user_num'],
  data() {
    return {
      tableData: [],//table數(shù)據(jù)
      cascade_value: [],
      //cascade_options: [],
      cascade_props: {
        lazy: true,
        checkStrictly: true, //可以選擇任意節(jié)點(diǎn)
        expandTrigger: 'click', //click/hover
        async lazyLoad(node, resolve) {
        },
      },
    }
  },//data
  computed: {
    addr(){
      return `${this.city ? this.city : ''}${this.district ? this.district : ''}${this.street ? this.street : ''}`
    },
    tableHeight(){
      // top:60, tab:60, btn:60, 分頁:60 ;
      return window.innerHeight - 60 - 10 - 60 - 60 - 40;
    },
  },
  async created() {
    this.limitStart = 0;
    this.currentPage = 1;
  },
  methods: {

    //級(jí)聯(lián)選擇器——change
    handlerCascadeChange(value){
      if (value) {
        this.province = value[0] || undefined;
        this.city = value[1] || undefined;
        this.district = value[2] || undefined;
        this.street = value[3] || undefined;
      }
    },

  },//methods
}
</script>
<style lang="scss" scoped>
</style>
<style lang="scss">
.wait-task-user-box-card {
  height: calc(100vh - 60px - 10px);
}
</style>

微信截圖_20220328105831.png
  • 如上圖,兩邊都是使用 card 的
  • 右邊的talbe是有默認(rèn)高度的,這樣,數(shù)據(jù)溢出會(huì)在此 table 內(nèi)上下滾動(dòng),而不影響其他的布局

End

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容