国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

ant-design-vue的table表格行合并和列合并

這篇具有很好參考價值的文章主要介紹了ant-design-vue的table表格行合并和列合并。希望對大家有所幫助。如果存在錯誤或未考慮完全的地方,請大家不吝賜教,您也可以點(diǎn)擊"舉報違法"按鈕提交疑問。

  • 場景說明:
    1、列合并:需要在表格最后一列進(jìn)行合并,如圖:
    antdesignvue表格合并列,隨手記,vue.js,javascript,前端
    思路:相當(dāng)于是第二列的最后一欄(colSpan )占比5列,第2列后面的4列最后一行(colSpan )占比0。
  • 代碼示例
<----html部分---->
 <a-table
        ref="table"
        size="middle"
        bordered
        :rowKey="(record, index) => index"
        :columns="columnsPart"
        :dataSource="dataSourcePart"
        :pagination="false"
        :loading="loading"
        :scroll="{ y: 'calc(100vh - 430px)' }">
      </a-table>
  columnsPart: [
          {
            title: "序號",
            dataIndex: "rowIndex",
            width: 60,
            align: "center",
            customRender: (text, r, index) => {
              return this.changeCellFunc(text, index, "rowIndex");
            }
          },
          {
            title: "第二列",
            align: "center",
            dataIndex: "structureName",
            ellipsis: true,
            customRender: (text, r, index) => {
              return this.changeCellFunc(text, index, "structureName");
            }
          },
          {
            title: "第三列",
            align: "center",
            dataIndex: "jobnoName",
            ellipsis: true,
            customRender: (text, r, index) => {
              return this.changeCellFunc(text, index);
            }
          },
          {
            title: "第四列",
            align: "center",
            dataIndex: "afterTaxPrice",
            scopedSlots: { customRender: "afterTaxPrice" },
            ellipsis: true,
            customRender: (text, r, index) => {
              return this.changeCellFunc(text, index);
            }
          },
          {
            title: "第五列",
            align: "center",
            dataIndex: "preTaxPrice",
            ellipsis: true,
            customRender: (text, r, index) => {
              return this.changeCellFunc(text, index);
            }
          },
          {
            title: "第六列",
            align: "center",
            dataIndex: "imgNum",
            ellipsis: true,
            customRender: (text, r, index) => {
              return this.changeCellFunc(text, index);
            }
          },
          {
            title: "第七列",
            align: "center",
            dataIndex: "preTaxAmount",
            ellipsis: true,
            customRender: (text, r, index) => {
              return this.changeCellFunc(text, index, "preTaxAmount");
            }
          },
          {
            title: "第八列",
            align: "center",
            dataIndex: "taxRate",
            ellipsis: true,
            customRender: (text, r, index) => {
              return this.changeCellFunc(text, index, "taxRate");
            }
          },
          {
            title: "第九列",
            align: "center",
            dataIndex: "taxAmount",
            ellipsis: true,
            customRender: (text, r, index) => {
              return this.changeCellFunc(text, index);
            }
          },
          {
            title: "第十列",
            align: "center",
            dataIndex: "afterTaxAmount",
            ellipsis: true,
            customRender: (text, r, index) => {
              return this.changeCellFunc(text, index, "afterTaxAmount");
            }
          },
          {
            title: "備注",
            align: "center",
            dataIndex: "remark",
            scopedSlots: { customRender: "remark" },
            ellipsis: true,
            customRender: (text, r, index) => {
              return this.changeCellFunc(text, index, "remark");
            }
          }
        ]

// 合并列
      changeCellFunc(text, index, type) {
        let temIndex = parseInt(index) + 1;
        const obj = {
          children: text,
          attrs: {}
        };
        if (type == "rowIndex") {
          return temIndex < this.dataSourcePart.length ? temIndex : "合計";
        }
        if (temIndex == this.dataSourcePart.length) {
          if (type == "taxRate") obj.attrs.colSpan = 2;
          if (type == "structureName") obj.attrs.colSpan = 5;
        }
        if (!type && temIndex == this.dataSourcePart.length) {
          obj.attrs.colSpan = 0;
        }
        return obj;
      },
  • 行合并需求如圖:將指定列的多行合并成一行antdesignvue表格合并列,隨手記,vue.js,javascript,前端
    思路:和合并列差不多;第一列的第一行和第二行要合并成一行,需要將第一列的第一行的占比(rowSpan )調(diào)整成 2,將第一列的第二行的占比(rowSpan )調(diào)整成 0 ,如果不將第二行的占比調(diào)整成 0 的話,后面的列會按順序往后排。舉個例子,我們現(xiàn)在要將一些橘子放進(jìn)箱子里,為了防止顛簸,需要用那種井字隔板將水果整齊隔開放置,可以放置9個,但是有一個橘子長得太胖了,一個格子放不下,要占兩個格子,只能放8個,這時候如果硬要放9個,橘子們就會往后擠。(ps:例子舉得不太好,請各位湊合著理解一下哈哈哈)
  • 代碼
 <a-table
   :rowKey="(record, index) => index"
    :bordered="true"
    size="middle"
    :columns="columns"
    :pagination="false"
    :data-source="tableData"
    :scroll="{ x: 1500, y: 'calc(100vh - 650px)' }">
    <template slot="useReason" slot-scope="text, record">
      {{ (dispatchReasonList[text] && dispatchReasonList[text].title) || "" }}
    </template>
  </a-table>
	columns: [
        {
          title: "第一列",
          dataIndex: "zyProviderName",
          width: 150,
          customCell: (record, rowIndex) => {
            return this.mergeCellsSlot(record, rowIndex);
          }
        },
        {
          title: "第2列",
          dataIndex: "zrProviderName",
          width: 150,
          customCell: (record, rowIndex) => {
            return this.mergeCellsSlot(record, rowIndex);
          }
        },
        {
          title: "第3列",
          dataIndex: "contName",
          width: 150,
          customCell: (record, rowIndex) => {
            return this.mergeCellsSlot(record, rowIndex);
          }
        },
        {
          title: "第4列",
          dataIndex: "useReason",
          width: 150,
          scopedSlots: {
            customRender: "useReason"
          },
          customCell: (record, rowIndex) => {
            return this.mergeCellsSlot(record, rowIndex);
          }
        },
        {
          title: "第5列",
          dataIndex: "profName",
          width: 220
        },
        {
          title: "第6列",
          dataIndex: "daysNum",
          width: 150
        },
        {
          title: "第7列",
          dataIndex: "daysPrice",
          width: 150
        },
        {
          title: "第8列",
          dataIndex: "amount",
          width: 150
        }
      ]
      // 合并單元格
      mergeCellsSlot(record, rowIndex) {
        // 開始下標(biāo)
        const index = this.tableData.findIndex((item) => item.id == record.id);
        // 需要合并的單元格數(shù)
        let rowSpanNum = 0;
        this.tableData.forEach((item) => {
          if (item.id == record.id) {
            rowSpanNum++;
          }
        });
        // 結(jié)束下標(biāo)
        let indexIdLength = index + rowSpanNum;
        return {
          style: {
            display: index < rowIndex && rowIndex < indexIdLength ? "none" : undefined
          },
          attrs: {
            rowSpan: rowIndex === index ? rowSpanNum : 1
          }
        };
      }

文章來源地址http://www.zghlxwxcb.cn/news/detail-559965.html

到了這里,關(guān)于ant-design-vue的table表格行合并和列合并的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點(diǎn)僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實不符,請點(diǎn)擊違法舉報進(jìn)行投訴反饋,一經(jīng)查實,立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費(fèi)用

相關(guān)文章

  • Ant Design Vue表格(Table)及分頁(Pagination )使用

    Ant Design Vue表格(Table)及分頁(Pagination )使用

    最近在寫一個新項目,UI框架用的是 Ant Design Vue ,因為之前一直用的 Element UI ,沒有用過這個組件庫,沒想到二者區(qū)別這么大,因此踩了不少坑,其中就有 Table 和 Pagination ,花了一會時間才弄明白,在此記錄并分享一下此次經(jīng)歷。 注意:是 Vue3 項目。 Table 的使用相對比較簡

    2024年02月10日
    瀏覽(35)
  • Ant Design Vue Table 嵌套子表格的數(shù)據(jù)刷新方法

    父子組件各自負(fù)責(zé),在table中嵌套了子表格后,首次加載表格時,父組件會實例化子組件并傳遞參數(shù),折疊后再次展開時,只會傳遞參數(shù),子組件的數(shù)據(jù)刷新就屬于子表格了。如 @@@code template #expandedRowRender=\\\"{ record }\\\" originIndex style= \\\"margin-left: 55px; margin-right: 50px; background-color:

    2024年02月09日
    瀏覽(21)
  • ant vue table表格數(shù)據(jù)動態(tài)合并

    ant vue table表格數(shù)據(jù)動態(tài)合并

    antd 表格動態(tài)行合并 合并效果 步驟方法 1.在computed節(jié)點(diǎn)下動態(tài)計算每次要合并的行數(shù) 2.在methods節(jié)點(diǎn)下定義合并單元格的方法 3.如果是一次性獲取所有數(shù)據(jù)進(jìn)行分頁的話,計算columns的時候需要進(jìn)行修改一下 參考文章:ant design vue 動態(tài)表格合并 合并效果 如果我們想要實現(xiàn)名稱

    2024年02月10日
    瀏覽(20)
  • Vue 3 中 Ant Design Vue 如何自定義表格 Table 的表頭(列頭)內(nèi)容?

    Vue 3 中 Ant Design Vue 如何自定義表格 Table 的表頭(列頭)內(nèi)容?

    項目用到的是 Ant Design Vue (2.2.8) 組件庫,開發(fā)中遇到一個如下圖的表格,有些表頭文本后面會有一些自定義圖標(biāo),鼠標(biāo)移入圖標(biāo)時顯示對應(yīng)的審批時間提示。當(dāng)前列如果沒有審批時間就會隱藏圖標(biāo),只展示列頭文本。 使用 Ant Design Vue 基礎(chǔ)的 Table 組件是無法滿足這個場景的

    2024年02月16日
    瀏覽(24)
  • 保姆級教程:Ant Design Vue中 a-table 嵌套子表格

    保姆級教程:Ant Design Vue中 a-table 嵌套子表格

    前端為Ant Design Vue 版本為1.6.2,使用的是vue2 Ant Design Vue中 a-table 嵌套子表格,說的可能稍微墨跡了點(diǎn),不過重點(diǎn)內(nèi)容都說的比較詳細(xì),利于新人理解,高手可以自取完整代碼 下圖為官網(wǎng)圖,會在每行最前面多一個加號,點(diǎn)擊后會展開,看到子表格的數(shù)據(jù) 子格嵌套從代碼層簡

    2024年02月01日
    瀏覽(31)
  • Ant Design Vue 中將 Table 表格中的數(shù)字類型轉(zhuǎn)換為文字的方法詳解

    在使用 Ant Design Vue 開發(fā)時,有時需要將 Table 表格中的數(shù)字類型字段轉(zhuǎn)換為對應(yīng)的文字表示,以提供更直觀的數(shù)據(jù)展示。本文將詳細(xì)介紹在 Ant Design Vue 中將 Table 表格中的數(shù)字類型轉(zhuǎn)換為文字的方法,幫助您靈活地處理數(shù)據(jù)展示需求。 在實際的應(yīng)用中,我們經(jīng)常會遇到需要將

    2024年02月11日
    瀏覽(49)
  • vue3+ant design vue+ts實戰(zhàn)【ant-design-vue組件庫引入】

    vue3+ant design vue+ts實戰(zhàn)【ant-design-vue組件庫引入】

    ????更多內(nèi)容見Ant Design Vue官方文檔 ??點(diǎn)擊復(fù)習(xí)vue3【watch檢測/監(jiān)聽】相關(guān)內(nèi)容 ??????一個好項目的編寫不僅需要完美的邏輯,以及相應(yīng)的技術(shù),同時也需要一個 設(shè)計規(guī)范的高質(zhì)量UI組件庫 。??????本期文章將會詳細(xì)講解 Ant Design of Vue 組件庫的 安裝、使用、引入 。

    2024年02月02日
    瀏覽(49)
  • vue3 組合式 ant.design組件Table嵌套表格,從后端獲取數(shù)據(jù)并動態(tài)渲染

    在根據(jù)官方文檔使用ant.design中的嵌套表格時,發(fā)現(xiàn)官方文檔很多地方都不夠詳細(xì)。在過程中踩了不少坑,例如: 子表如何獲取父表的數(shù)據(jù)? 如何獲取子表的行索引? 如何讓子表的數(shù)據(jù)源來自父表該行的數(shù)據(jù)? 總之,最后還是磕磕絆絆做完了功能,于是第一時間把代碼整理

    2024年02月15日
    瀏覽(22)
  • 按需引入ant-design-vue組件

    一、首先創(chuàng)建一個新的Vue項目 選擇default含有babel和eslint?;蛘咦远xManually select features。 babel是一個轉(zhuǎn)碼器,主要用于ES2015+ 代碼轉(zhuǎn)換為 JavaScript 向后兼容版本的代碼 eslint是一個代碼檢測工具。用來規(guī)范編碼規(guī)范用。 自定義可選的插件有,Babel,TypeScript,Progressive Web App (P

    2024年02月13日
    瀏覽(34)
  • 關(guān)于 ant-design-vue resetFields 失效

    關(guān)于 ant-design-vue resetFields 失效

    關(guān)于 ant-design-vue resetFields 失效 背景: 遇到這樣的問題使用 ant-design-vue useForm 來制作表單的時候, resetFields()失效 場景: 編輯 -賦值 新增 -初始值(問題點(diǎn):新增的時候他就不 初始化 ) 方案: 1、調(diào)用 resetFields() 傳參 2、要么使用 reactive 明確定義初始值 解釋: 首先我這里講

    2024年01月17日
    瀏覽(23)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包