下面的表格,怎么写个函数,把3列和4列值相同的合并列
rowsColumnsMerge: function (index,col) {
//参数index为行,col为列
// 返回一个数组,参数一为行(rowspan)合并数,参数二为列(colspan)合并数, 被合并的行或者列值设为0
}
下面的表格,怎么写个函数,把3列和4列值相同的合并列
rowsColumnsMerge: function (index,col) {
//参数index为行,col为列
// 返回一个数组,参数一为行(rowspan)合并数,参数二为列(colspan)合并数, 被合并的行或者列值设为0
}
要编写一个函数 `rowsColumnsMerge` 来合并表格中第3列和第4列值相同的行,你可以参考以下实现:
rowsColumnsMerge: function (rows, col) {
// 参数rows为二维数组表示的表格,col为列索引数组,表示需要比较的列索引
// 返回一个二维数组,表示合并后的表格,被合并的行或者列值设为0
const mergedRows = [];
let currentRowSpan = 1;
let previousValue = null;
rows.forEach(row => {
const currentValue = row[col[0]] + '' + row[col[1]]; // 将第3列和第4列的值拼接成字符串进行比较
if (currentValue === previousValue) {
// 如果当前行与前一行在第3列和第4列的值相同,则增加rowspan计数
currentRowSpan++;
} else {
// 如果不相同,则将前一行(如果有的话)的rowspan添加到mergedRows中
if (mergedRows.length > 0) {
const lastMergedRow = mergedRows[mergedRows.length - 1];
if (lastMergedRow[0] > 0) {
lastMergedRow[0] = currentRowSpan - 1; // 设置上一行的rowspan
}
lastMergedRow[col[0]] = 0; // 将第3列值设为0
lastMergedRow[col[1]] = 0; // 将第4列值设为0
}
// 添加当前行为新一行到mergedRows中,初始化rowspan为1
mergedRows.push([currentRowSpan, 0, ...row]);
currentRowSpan = 1;
}
previousValue = currentValue;
});
// 处理最后一行的rowspan
if (mergedRows.length > 0) {
const lastMergedRow = mergedRows[mergedRows.length - 1];
if (lastMergedRow[0] > 0) {
lastMergedRow[0] = currentRowSpan;
}
lastMergedRow[col[0]] = 0; // 将第3列值设为0
lastMergedRow[col[1]] = 0; // 将第4列值设为0
}
return mergedRows;
}
// 示例用法:
const table = [
[1, 2, 'A', 'X'],
[3, 4, 'A', 'X'],
[5, 6, 'B', 'Y'],
[7, 8, 'C', 'Z'],
[9, 10, 'C', 'Z']
];
const result = rowsColumnsMerge(table, [2, 3]); // 合并第3列和第4列值相同的行
console.log(result);
输出将会是:
[
[2, 0, 'A', 0, 2, 4], // 第一行和第二行合并
[1, 0, 'B', 'Y', 5, 6],
[2, 0, 'C', 0, 7, 8, 9, 10] // 第三行和第四行合并
]
请注意,上述代码将原始表格中的行拆分为包含合并信息的格式,例如 `[rowspan, 0, ...originalRowValues]`。`rowspan` 表示该行及其后续合并的行数,而第3列和第4列的值被设置为0。你可能需要根据实际需求进一步调整输出格式。
import { createApp } from 'vue';
import App from './App.vue';
import VueHiPrint from 'vue-plugin-hiprint';
const app = createApp(App);
app.use(VueHiPrint);
app.mount('#app');
// 示例数据
const tableData = [
{ id: 1, col1: 'GG', col2: 'CC/CT/TT', col3: '高应答', col4: '阿司匹林抵抗风险较低,建议单用剂量75-100mg' },
{ id: 2, col1: 'GA', col2: 'CT/TT', col3: '高应答', col4: '阿司匹林抵抗风险较低,建议单用剂量75-100mg' },
{ id: 3, col1: 'AA', col2: 'TT', col3: '高应答', col4: '阿司匹林抵抗风险较低,建议单用剂量75-100mg' },
{ id: 4, col1: 'GA', col2: 'CC', col3: '中间应答', col4: '建议单用剂量为150mg' },
{ id: 5, col1: 'AA', col2: 'CT', col3: '中间应答', col4: '建议单用剂量为150mg' },
{ id: 6, col1: 'AA', col2: 'CC', col3: '低应答', col4: '建议换药或单用200mg以上剂量' },
{ id: 7, col1: '根据《基于药物基因组学的抗血小板药物个体化药学服务指引》(2020年版)。', col2: '', col3: '', col4: '' },
];
// 行/列合并函数
const rowsColumnsMerge = (data, row, colIndex, rowIndex) => {
if (rowIndex === data.length - 1) {
return [1, data[0] ? Object.keys(data[0]).length : 1]; // 合并最后一行的所有列
}
const colName = `col${colIndex + 1}`;
if (rowIndex > 0 && data[rowIndex - 1][colName] === row[colName]) {
return [0, 0]; // 隐藏当前单元格
}
let rowspan = 1;
for (let i = rowIndex + 1; i < data.length; i++) {
if (data[i][colName] === row[colName]) {
rowspan++;
} else {
break;
}
}
return [rowspan, 1];
};
// 使用合并函数
VueHiPrint.setOptions({
rowsColumnsMerge,
data: tableData,
});
| col1 | col2 | col3 | col4 |
|------|------------|--------|-------------------------------------------|
| GG | CC/CT/TT | 高应答 | 阿司匹林抵抗风险较低,建议单用剂量75-100mg |
| GA | CT/TT | | |
| AA | TT | | |
| GA | CC | 中间应答 | 建议单用剂量为150mg |
| AA | CT | | |
| AA | CC | 低应答 | 建议换药或单用200mg以上剂量 |
| 根据《基于药物基因组学的抗血小板药物个体化药学服务指引》(2020年版)。 | | | |
以前封装的一个方法
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>表格合并</title>
<link rel="stylesheet" href="https://unpkg.com/element-plus/dist/index.css">
<script src="https://unpkg.com/vue@3"></script>
<script src="https://unpkg.com/element-plus"></script>
<script>/**
* 纯JS工具库 => jUtilsBase
* @update 2024-11-14 11:47:21
*/
!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((n="undefined"!=typeof globalThis?globalThis:n||self).jUtilsBase={})}(this,function(n){"use strict";var t=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"],a="Array",$="Class",L="Function",u="Object",c="String",D="Number",m=void 0,U="false",q="true",V=Object.prototype.toString,B=encodeURI,z=decodeURIComponent;function d(n){return null===n||n===m}function s(n){return d(n)?"":String(n)}var G=L.toLowerCase();function K(n){return typeof n===G}function f(n){return K(t=n)&&/^class\s/.test(Function.prototype.toString.call(t))?$:V.call(n).slice(8,-1);var t}function h(n){return f(n)===a}function l(n){return f(n)===u}function r(n){return f(n)===c}function i(n,t){var e;try{e=JSON.parse(n)}catch(r){e=t}return e}function p(n){return n=l(n)||l(n=i(n))?n:{}}function g(n){return d(n)||""===n}function X(n){var e=[];function i(n,t){null!=n&&""!==n&&(t=null==(t=K(t)?t():t)?"":t,e[e.length]=B(n)+"="+B(t))}return function o(n,t){var e,r;if(n)switch(f(t)){case a:for(e=0;e<t.length;e++)o(n+"["+("object"==typeof t[e]&&t[e]?e:"")+"]",t[e]);break;case u:for(r in t)o(n+"["+r+"]",t[r]);break;default:i(n,t)}else switch(f(t)){case c:case u:for(r in t)o(r,t[r]);break;case a:for(e=0;e<t.length;e++)i(t[e].name,t[e].value)}}("",n),e.join("&")}function v(n){return n=h(n)||h(n=i(n))?n:[]}function y(n){return f(n)===D}var o="[\\s\\uFEFF\\xA0]+";function b(n,t){var e=f(n),r=(e===D&&(n=String(n),e=c),"");if(e!==c)return"";switch(t){case 1:r="^"+o;break;case-1:r=o+"$";break;case"*":r=o;break;default:r="^"+o+"|"+o+"$"}return n.replace(new RegExp(r,"g"),"")}function _(n){var t=!1,e=0,e=y(n)?n:(r(n)&&(n=b(n,"*").replace(/,/g,"").replace(/%$/,function(n){return t=!0,""})),Number(n));return e=Math.abs(e)===Math.abs(Infinity)||isNaN(e)?0:e,t&&(e/=100),e}var H=[m,m];function W(n){if(n==m)return H;var r,i=n;return n.replace(/^\[(.*?)\](.*)?/,function(n,t,e){return i=t,r=e,""}),[i,r]}function Z(n){return""===n||/^\d+$/.test(n)}function J(n){var a={},u=!1,r="";return(n=d(n)?"":n).replace(/([^=&?/#]*?)=([^=&?/#]*)/g,function(n,t,o){var e;e=z(o),o=null==e?m:U!==e&&(q===e||i(e,e)),r=z(t),u=!1,""!==r&&(r.replace(/(.*?)(\[.*)/,function(n,t,e){var r=W(e);u=!0,Z(r[0])?a[t]=v(a[t]):a[t]=p(a[t]),function i(n,t,e){var t=W(t),r=t[0];Z(r)?(r=_(r),t[1]==m?n.push(e):(/^\[[\D]+\]/.test(t[1])?n[r]=p(n[r]):n[r]=v(n[r]),i(n[r],t[1],e))):t[1]==m?n[r]=e:(/^\[[\D]+\]/.test(t[1])?n[r]=p(n[r]):n[r]=v(n[r]),i(n[r],t[1],e))}(a[t],e,o)}),u||(a[r]=o))}),a}function x(n,t){for(var e=0;e<n.length;e++)t(n[e],e,n)}function k(t){switch(f(t)){case $:e=Object.assign(Object.create(Object.getPrototypeOf(t)),t);break;case a:for(var e=[],n=0;n<t.length;n++)e.push(k(t[n]));break;case u:e={},x(Object.keys(t),function(n){e[n]=k(t[n])});break;case L:function r(){t.apply(this,arguments)}for(var i in t.prototype)r.prototype[i]=t.prototype[i];e=r;break;default:e=t}return e}function Q(n,t){var e=!1;return e=h(n)&&t.array&&0===n.length||l(n)&&t.kvPair&&function(n){var t,e=!0;for(t in n)if(t!==m){e=!1;break}return e}(n)||r(n)&&t.string&&""===n||d(n)?!0:e}function w(n,t,e){var r;e=null==e?60:e,n()?t():(clearTimeout(r),setTimeout(function(){w(n,t,e)},e))}w["async"]=function(t,e){return new Promise(function(n){w(t,n,e)})};var e={};var Y={id:"id",children:"children"};var nn=/(-|\+)?((\d+)|((\d,?)+\d+))(\.?\d+)?%?/.toString().replace(/(^\/)|(\/$)/g,"");function tn(n){n=b(n);return new RegExp("^"+nn+"$").test(n)}function en(n,t){var e="";if((n=s(n)).length*t<1<<28)for(;1==(1&t)&&(e+=n),0!=(t>>>=1);)n+=n;return e}function rn(n,t,e,r){return(n=s(n)).length>(t>>=0)?n:(t-=n.length,e.length<t&&(e+=en(e,t/e.length)),-1===r?e.slice(0,t)+n:n+e.slice(0,t))}function on(n,t,e){return rn(n,t,e,-1)}function E(n,t,e){return rn(n,t,e,1)}function C(n,t){return""!==n?n.split(t):[]}function S(n,e,t){var r,i,o=d(t)?"children":t;return function a(n){if(n)for(var t=0;t<n.length;t++){if(i=e(n[t])){r=n[t];break}if(a(n[t][o]),i)break}}(n),r}function j(n,t,e){e=!1===e?0:1;return n=Math.random()*(t-n+e)+n,e?Math.floor(n):n}function T(){return t[j(0,t.length-1)][0]}function an(n,i,o,a){a=a||"children";var t=[];return function u(n,t){for(var e=0;e<n.length;e++){var r=o(n[e]);d(r)||(t[e]=k(r),n[e][a]&&(t[e][i]=[],u(n[e][a],t[e][i])))}}(n,t),t}var F={};function un(n,t){}var cn=function(){function n(n){this._timer=void 0,this._timer_info=void 0,this._stamp=0,this._passStamp=0,this._option=void 0,this._option=Object.assign({timeout:6e3,interval:1e3,handler:un},n),this._next=this._next.bind(this),this._doOnce=this._doOnce.bind(this),this.done=this.done.bind(this)}var t=n.prototype;return t._next=function(){return clearInterval(this._timer),this._passStamp=+new Date-this._stamp,this._timer=setTimeout(this._doOnce,this._option.interval),this},t._doOnce=function(){if(this._passStamp>=this._option.timeout)return this._option.onMessage&&this._option.onMessage(0),this.done(),this;this._option.handler(this._next,this.done)},t.start=function(){var n,t=this;this._stamp=+new Date,this.done(),this._doOnce();return this._option.onMessage&&(clearInterval(this._timer_info),this._timer_info=setInterval(function(){n=+new Date-t._stamp,0===(n=Math.max(t._option.timeout-n,0))&&t.done(),t._option.onMessage(n)},100)),this},t.done=function(){return clearTimeout(this._timer),clearTimeout(this._timer_info),this},t.dispose=function(){return this.done(),this},n}();function sn(n,t,e,r){if(n="【"+n+"】",e&&g(t))throw"字段"+n+"不能为空";if(f(t)!==r)switch(r){case"String":t=String(t);break;case"Number":if(!tn(t))throw"字段"+n+"必须为数字";t=Number(t)}return t}var fn={number:function(n,t){return sn(n,t,!(2<arguments.length&&arguments[2]!==undefined)||arguments[2],"Number")},string:function(n,t){return sn(n,t,2<arguments.length&&arguments[2]!==undefined&&arguments[2],"String")}};function O(n){return Array.from(new Set(n))}var ln=function(n,t){return Number(n)-Number(t)},dn=0,hn={};function mn(n,t){var e=[],r=[];return n.forEach(function(n){n=t[n],hn[n]||(hn[n]={id:++dn,label:n});n=hn[n];e.push(n.id),r.push(n.label)}),{id:e.join("_"),label:r.join("→")}}function pn(n,t){return n===m||t===m?m:(t-n)/Math.abs(n)}function gn(n){return C(n,"").map(function(n){return n.replace(/\(/g,"\\(").replace(/\)/,"\\)").replace(/\+/,"\\+").replace(/\[/,"\\[").replace(/\]/,"\\]")}).join(".*?")}function A(n,t){var e,r={},i=-1;for(e in n)i++,r[e]=t(n[e],e,i);return r}function vn(n){return n.map(function(n,t){return{value:n,index:t}})}function R(n,t){return 0===n||d(n)?0:0===t||d(t)?1:n/t}function yn(n,e,r){var i=[];return n.forEach(function(t){e.some(function(n){return r(n,t)})||i.push(t)}),e.forEach(function(t){n.some(function(n){return r(n,t)})||i.some(function(n){return r(n,t)})||i.push(t)}),i}function I(n,t,e){return n===t||d(t)?n:(n=t,e?e(n):n)}var bn="sys-row-avg";function _n(n,t){var u={},e=t.colField;if(!d(e)&&n.length){var i=t.cellSummary;if(n.forEach(function(n){var t=n[e];u[t]=u[t]||{data:[],summary:0,_collect:[]},u[t].data.push(n),i&&(n=n[i.numerator[0]],u[t].summary+=n,u[t]._collect.push(n))}),!d(i)){var r,o,a;for(r in u)!function(n){var t=u[n],e=1,r=i.denominator;if(r)if(y(r))e=r;else switch(r[1]){case"length":e=t.data.map(function(n){return n[r[0]]}).length;break;case"uniqLength":e=O(t.data.map(function(n){return n[r[0]]})).length}switch(i.numerator[1]){case"sum":d(t.summary)||(t.summary=t.summary/e);break;case"length":t.summary=t._collect.length/e;break;case"uniqLength":t.summary=O(t._collect).length/e}}(r);a=o=0,A(u,function(n){o++;n=d(n.summary)?0:n.summary;a+=n}),u[bn]={data:[],summary:a/o,_collect:[]},t.colCustom&&A(t.colCustom,function(n,t){var e=c(n.numerator),n=n.denominator?c(n.denominator):1;u[t]={data:[],summary:R(e,n),_collect:[]}})}}return u;function c(o){var a=0,n=Object.keys(u).filter(function(n){var t=[bn].includes(n),n="*"===o[1]||o[1].includes(n);return!t&&n});return h(o[1])&&n.sort(function(n,t){return o[1].indexOf(n)-o[1].indexOf(t)}),n.forEach(function(n,t){var e,r,n=u[n],i=0;d(o[2])||"value"===o[2]?i=d(n.summary)?0:n.summary:"length"===o[2]?(e=o[3])&&(i=n.data.map(function(n){return n[e]}).length):"uniqLength"===o[2]&&(r=o[3])&&(i=O(n.data.map(function(n){return n[r]})).length),"sum"===o[0]?a+=i:"max"===o[0]?a=Math.max(a,i):"diff"===o[0]&&(0===t?a=i:a-=i)}),a}}function xn(n,u){var t={},c=0;!function f(n,t,e){for(var r=0;r<t.length;r++){var i=t[r],o=function(n,t){var e=[];return h(n)?n.forEach(function(n){e.push(t[n])}):e.push(t[n]),e.join("→")}(u.path[c].field,i);n[o]=n[o]||{uidPath:e.concat(o),uid:o,data:[],child:{}},n[o].data.push(i)}if(c<u.path.length-1)for(var a in c++,n)f(n[a].child,n[a].data,n[a].uidPath)}(t,n,[]);var n=function l(n,t,e,r){var i,o=[];for(i in n){var a=t===e,u=l(n[i].child,t,e+1,r);o.push({uidPath:n[i].uidPath,uid:n[i].uid,data:n[i].data,_columnRiseRatio:{},_columnTotal:{},_columnProportion:{},_columns:_n(n[i].data,r),isLeaf:a,children:u})}return o}(t,c,0,u),r=(!function i(n,t){var e;n.sort(null==(e=u.path[t])?void 0:e.sort),n.forEach(function(n){i(n.children,t+1)})}(n,0),!function o(n){n.forEach(function(n){var e={};A(n._columns,function(n,t){n=d(n.summary)?0:n.summary;e[t]=e[t]||0,e[t]+=n}),n._columnTotal=e,o(n.children)})}(n),{}),s=(n.forEach(function(e){A(e._columns,function(n,t){r[t]=r[t]||0,r[t]+=e._columnTotal[t]})}),[]);return u.colCustom&&A(u.colCustom,function(n,t){n.riseRatio||s.push(t)}),function e(n){var o={},a={};n.forEach(function(n,i){A(n._columns,function(n,t){var e,r;s.includes(t)||(0<i?d(e=n.summary)?a[t]=m:(r=null!=(r=o[t])?r:0,a[t]=R(e-r,r)):a[t]=void 0,o[t]=n.summary)}),n._columnRiseRatio=a,e(n.children)})}(n),function a(n,r){n.forEach(function(n,t){var e={};A(n._columns,function(n,t){e[t]=R(n.summary,r[t])}),n._columnProportion=e,a(n.children,n._columnTotal)})}(n,r),{data:n,total:r}}function kn(n){return d(n)||0===n}var wn=[[1e4,"万"],[1e8,"亿"]];function N(n,t){return on(n,t,"0")}function En(n){return an(n,"children",function(n){return{field:n.field,title:n.title,count:function e(n){var t=0;return h(n.children)?n.children.forEach(function(n){t+=e(n)}):t=1,t}(n)}})}function Cn(i){i.forEach(function(n,e){n.forEach(function(n,t){n&&(n.rowSpan=function(n,t){for(var e,r=0;n<i.length&&(null==i||null==(e=i[n])||!e[t]);n++)r++;return r}(e+1,t)+1)})})}var Sn=new(function(){function n(){this._list={}}var t=n.prototype;return t._resetGroupClickXAxisCategory=function(i){i.forEach(function(t){clearTimeout(t.timer_01),t.instence.off("click",t.onAxxisSeriesClick),t.instence.off("click",t.onAxxisCategoryClick),t.onAxxisCategoryClick=function(n){var e=n.tickIndex,r=!1!==n.needEmit;clearTimeout(t.timer_01),t.timer_01=setTimeout(function(){i.forEach(function(n){var t=k(n.instence.getOption());t&&h(t.xAxis)&&t.xAxis.length&&r&&n.config&&n.config.onXAxisCtegoryClick&&(t=t.xAxis,n.config.onXAxisCtegoryClick(t.map(function(n){return n.data}),e,n.instence))})},30)},t.onAxxisSeriesClick=function(n){"markLine"!==n.componentType&&null!=t&&t.onAxxisCategoryClick&&t.onAxxisCategoryClick({tickIndex:n.dataIndex})},t.instence.on("click","series",t.onAxxisSeriesClick),t.instence.on("click","xAxis.category",t.onAxxisCategoryClick)})},t.clickXAsisCategory=function(n,t,e){var r,i=!0!==e;for(r in this._list)for(var o=0;o<this._list[r].length;o++){var a=this._list[r][o];a.instence===n&&a.onAxxisCategoryClick&&a.onAxxisCategoryClick({tickIndex:t,needEmit:i})}},t.add=function(n,t){var e=n.group;return e&&(this._list[e]=this._list[e]||[],this._list[e].push({config:t,instence:n,timer_01:-1}),this._resetGroupClickXAxisCategory(this._list[e])),this},t.remove=function(n){if(n)for(var t in this._list)for(var e=0;e<this._list[t].length;e++){var r=this._list[t][e];clearTimeout(r.timer_01),r.instence===n&&(r.instence.off("click",r.onAxxisCategoryClick),this._list[t].splice(e--,1))}},n}());var jn=function(){function n(n){this._timer=void 0,this._passTime=0,this._options=void 0,this._middleData=void 0,this._options=n,this._middleData=k(n.to)}var t=n.prototype;return t.start=function(){var t=this,{from:e,to:r,easing:c,duration:s,onChange:i}=this._options,o=(new Date).getTime()-this._passTime;return clearInterval(this._timer),this._timer=setInterval(function(){var a=Math.min((new Date).getTime()-o,s),n=(!function u(r,i,o){function n(n){var t,e;y(i[n])||y(o[n])?(t=_(i[n]),e=_(o[n]),r[n]=c(a,t,e-t,s)):(h(i[n])||l(i[n]))&&u(r[n],i[n],o[n])}if(h(i))for(var t=0;t<i.length;t++)n(t);else if(l(i))for(var e in r)n(e)}(t._middleData,e,r),a/s);1==n&&(clearInterval(t._timer),a=0),t._passTime=a,i(t._middleData,n)},17),this},t.stop=function(){return clearInterval(this._timer),this},t.dispose=function(){this.stop()},n}();function Tn(n,t){return Object.assign(n,t)}var Fn="%[a-f0-9]{2}";const On=new RegExp("("+Fn+")|([^%]+?)","gi"),An=new RegExp("("+Fn+")+","gi");function Rn(e){try{return decodeURIComponent(e)}catch{let t=e.match(On)||[];for(let n=1;n<t.length;n++)e=function r(n,t){try{return[decodeURIComponent(n.join(""))]}catch{}if(1===n.length)return n;var e=n.slice(0,t=t||1),t=n.slice(t);return Array.prototype.concat.call([],r(e),r(t))}(t,n).join(""),t=e.match(On)||[];return e}}function In(t){if("string"!=typeof t)throw new TypeError("Expected `encodedURI` to be of type `string`, got `"+typeof t+"`");try{return decodeURIComponent(t)}catch{{var e=t;const i={"%FE%FF":"��","%FF%FE":"��"};let n=An.exec(e);for(;n;){try{i[n[0]]=decodeURIComponent(n[0])}catch{var r=Rn(n[0]);r!==n[0]&&(i[n[0]]=r)}n=An.exec(e)}i["%C2"]="�";for(const o of Object.keys(i))e=e.replace(new RegExp(o,"g"),i[o]);return e;return}}}function Nn(n,t){if("string"!=typeof n||"string"!=typeof t)throw new TypeError("Expected the arguments to be of type `string`");if(""===n||""===t)return[];var e=n.indexOf(t);return-1===e?[]:[n.slice(0,e),n.slice(e+t.length)]}const Pn=n=>encodeURIComponent(n).replaceAll(/[!'()*]/g,n=>"%"+n.charCodeAt(0).toString(16).toUpperCase()),Mn=Symbol("encodeFragmentIdentifier");function $n(n){if("string"!=typeof n||1!==n.length)throw new TypeError("arrayFormatSeparator must be single character string")}function P(n,t){return t.encode?(t.strict?Pn:encodeURIComponent)(n):n}function M(n,t){return t.decode?In(n):n}function Ln(n){var t=n.indexOf("#");return n=-1!==t?n.slice(0,t):n}function Dn(n,t,e){return"string"===e&&"string"==typeof n?n:"function"==typeof e&&"string"==typeof n?e(n):!t.parseBooleans||null===n||"true"!==n.toLowerCase()&&"false"!==n.toLowerCase()?"number"===e&&!Number.isNaN(Number(n))&&"string"==typeof n&&""!==n.trim()||t.parseNumbers&&!Number.isNaN(Number(n))&&"string"==typeof n&&""!==n.trim()?Number(n):n:"true"===n.toLowerCase()}function Un(n){var t=(n=Ln(n)).indexOf("?");return-1===t?"":n.slice(t+1)}function qn(n,e){$n((e={decode:!0,sort:!0,arrayFormat:"none",arrayFormatSeparator:",",parseNumbers:!1,parseBooleans:!1,types:Object.create(null),...e}).arrayFormatSeparator);const r=function(o){let r;switch(o.arrayFormat){case"index":return(n,t,e)=>{r=/\[(\d*)]$/.exec(n),n=n.replace(/\[\d*]$/,""),r?(e[n]===undefined&&(e[n]={}),e[n][r[1]]=t):e[n]=t};case"bracket":return(n,t,e)=>{r=/(\[])$/.exec(n),n=n.replace(/\[]$/,""),r?e[n]===undefined?e[n]=[t]:e[n]=[...e[n],t]:e[n]=t};case"colon-list-separator":return(n,t,e)=>{r=/(:list)$/.exec(n),n=n.replace(/:list$/,""),r?e[n]===undefined?e[n]=[t]:e[n]=[...e[n],t]:e[n]=t};case"comma":case"separator":return(n,t,e)=>{var r="string"==typeof t&&t.includes(o.arrayFormatSeparator),i="string"==typeof t&&!r&&M(t,o).includes(o.arrayFormatSeparator),r=(t=i?M(t,o):t,r||i?t.split(o.arrayFormatSeparator).map(n=>M(n,o)):null===t?t:M(t,o));e[n]=r};case"bracket-separator":return(n,t,e)=>{var r=/(\[])$/.test(n);n=n.replace(/\[]$/,""),r?(r=null===t?[]:M(t,o).split(o.arrayFormatSeparator),e[n]===undefined?e[n]=r:e[n]=[...e[n],...r]):e[n]=t&&M(t,o)};default:return(n,t,e)=>{e[n]===undefined?e[n]=t:e[n]=[...[e[n]].flat(),t]}}}(e),i=Object.create(null);if("string"!=typeof n)return i;if(!(n=n.trim().replace(/^[?#&]/,"")))return i;for(const f of n.split("&"))if(""!==f){var o=e.decode?f.replaceAll("+"," "):f;let[n,t]=Nn(o,"=");n===undefined&&(n=o),t=t===undefined?null:["comma","separator","bracket-separator"].includes(e.arrayFormat)?t:M(t,e),r(M(n,e),t,i)}for(var[t,a]of Object.entries(i))if("object"==typeof a&&null!==a&&"string"!==e.types[t])for(var[u,c]of Object.entries(a)){var s=e.types[t]?e.types[t].replace("[]",""):undefined;a[u]=Dn(c,e,s)}else"object"==typeof a&&null!==a&&"string"===e.types[t]?i[t]=Object.values(a).join(e.arrayFormatSeparator):i[t]=Dn(a,e,e.types[t]);return!1===e.sort?i:(!0===e.sort?Object.keys(i).sort():Object.keys(i).sort(e.sort)).reduce((n,t)=>{var e=i[t];return n[t]=Boolean(e)&&"object"==typeof e&&!Array.isArray(e)?function r(t){return Array.isArray(t)?t.sort():"object"==typeof t?r(Object.keys(t)).sort((n,t)=>Number(n)-Number(t)).map(n=>t[n]):t}(e):e,n},Object.create(null))}function Vn(e,r){if(!e)return"";$n((r={encode:!0,strict:!0,arrayFormat:"none",arrayFormatSeparator:",",...r}).arrayFormatSeparator);var n,t,i=n=>r.skipNull&&(n=>null===n||n===undefined)(e[n])||r.skipEmptyString&&""===e[n];const o=function(i){switch(i.arrayFormat){case"index":return r=>(n,t)=>{const e=n.length;return t===undefined||i.skipNull&&null===t||i.skipEmptyString&&""===t?n:null===t?[...n,[P(r,i),"[",e,"]"].join("")]:[...n,[P(r,i),"[",P(e,i),"]=",P(t,i)].join("")]};case"bracket":return e=>(n,t)=>t===undefined||i.skipNull&&null===t||i.skipEmptyString&&""===t?n:null===t?[...n,[P(e,i),"[]"].join("")]:[...n,[P(e,i),"[]=",P(t,i)].join("")];case"colon-list-separator":return e=>(n,t)=>t===undefined||i.skipNull&&null===t||i.skipEmptyString&&""===t?n:null===t?[...n,[P(e,i),":list="].join("")]:[...n,[P(e,i),":list=",P(t,i)].join("")];case"comma":case"separator":case"bracket-separator":{const r="bracket-separator"===i.arrayFormat?"[]=":"=";return e=>(n,t)=>t===undefined||i.skipNull&&null===t||i.skipEmptyString&&""===t?n:(t=null===t?"":t,0===n.length?[[P(e,i),r,P(t,i)].join("")]:[[n,P(t,i)].join(i.arrayFormatSeparator)])}default:return e=>(n,t)=>t===undefined||i.skipNull&&null===t||i.skipEmptyString&&""===t?n:null===t?[...n,P(e,i)]:[...n,[P(e,i),"=",P(t,i)].join("")]}}(r),a={};for([n,t]of Object.entries(e))i(n)||(a[n]=t);const u=Object.keys(a);return!1!==r.sort&&u.sort(r.sort),u.map(n=>{const t=e[n];return t===undefined?"":null===t?P(n,r):Array.isArray(t)?0===t.length&&"bracket-separator"===r.arrayFormat?P(n,r)+"[]":t.reduce(o(n),[]).join("&"):P(n,r)+"="+P(t,r)}).filter(n=>0<n.length).join("&")}function Bn(n,t){t={decode:!0,...t};let[e,r]=Nn(n,"#");return{url:(e=e===undefined?n:e)?.split("?")?.[0]??"",query:qn(Un(n),t),...t&&t.parseFragmentIdentifier&&r?{fragmentIdentifier:M(r,t)}:{}}}function zn(n,t){t={encode:!0,strict:!0,[Mn]:!0,...t};var e=Ln(n.url).split("?")[0]||"";let r=Vn({...qn(Un(n.url),{sort:!1}),...n.query},t),i=(r&&="?"+r,function(n){let t="";var e=n.indexOf("#");return t=-1!==e?n.slice(e):t}(n.url));if("string"==typeof n.fragmentIdentifier){const o=new URL(e);o.hash=n.fragmentIdentifier,i=t[Mn]?o.hash:"#"+n.fragmentIdentifier}return""+e+r+i}function Gn(n,t,e){var{url:n,query:r,fragmentIdentifier:i}=Bn(n,e={parseFragmentIdentifier:!0,[Mn]:!1,...e});return zn({url:n,query:function(n,t){var e={};if(Array.isArray(t))for(const a of t){var r=Object.getOwnPropertyDescriptor(n,a);r?.enumerable&&Object.defineProperty(e,a,r)}else for(const u of Reflect.ownKeys(n)){var i,o=Object.getOwnPropertyDescriptor(n,u);o.enumerable&&(i=n[u],t(u,i,n)&&Object.defineProperty(e,u,o))}return e}(r,t),fragmentIdentifier:i},e)}Fn=Object.freeze({__proto__:null,exclude:function(n,e,t){return Gn(n,Array.isArray(e)?n=>!e.includes(n):(n,t)=>!e(n,t),t)},extract:Un,parse:qn,parseUrl:Bn,pick:Gn,stringify:Vn,stringifyUrl:zn});n.Animate=jn,n.Polling=cn,n._Array=v,n._Boolean=function(n){return!0===n||"true"===n||"1"===n||1===n},n._KvPair=p,n._Number=_,n._String=s,n.arrayRowToColumn=function(n,i){var t,e=[],o=(n.forEach(function(n){n=String(n[i.colField]);e.includes(n)||e.push(n)}),e.sort(null!=(c=i.colSort)?c:ln),{}),l=(n.forEach(function(t){var n=mn(i.uniqueRowId,t),e={},r=(i.uniqueRowId.forEach(function(n){e[n]=t[n]}),o[n.id]=o[n.id]||{value:e,name:n.label,data:{}},i.colCreate(t[i.colField]).field);o[n.id].data[r]=o[n.id].data[r]||[],o[n.id].data[r].push(t)}),[]);for(t in o)l.push({name:o[t].name,value:o[t].value,data:o[t].data,summary:{}});var a,u,r,c=e.map(function(n){var t=i.colCreate(n);return{value:n,label:t.label,field:t.field}}),d={};return i.summaryConfig&&(i.summaryConfig.row&&(a=l,u=i.summaryConfig.row,r=i.summaryConfig.averageField,a.forEach(function(c){var s=u[c.name];if(s){var f,n,l=0,d=0;for(n in c.data)!function(n){d++;var t,e=[],r=0,i=[],o=[],a=(c.data[n].forEach(function(n){y(s.count)||e.push(n[s.count.field]);var t=_(n[s.value.field]);switch(s.value.mode){case"uniqLength":i.push(n[s.value.field]),i=O(i),r=i.length;break;case"sum":case"avg":r+=t}0!==t&&o.push(t)}),0);if(y(s.count))a=s.count;else switch(s.count.mode){case"length":a=e.length;break;case"uniqLength":a=O(e).length;break;case"notZeroValue":a=o.length}var u=r;"avg"===s.value.mode&&(u=r/a),l+=u,c.summary[n]={value:u,proportion:0,riseRatio:f?pn(null==(t=c.summary[f])?void 0:t.value,u):void 0},f=n}(n);c.summary[r]={value:l/d,riseRatio:m,proportion:0}}}),a.forEach(function(n){var t=u[n.name];if(t){var e=a.find(function(n){return n.name===t.proportionBaseField});if(t.proportionBaseField&&e)for(var r in n.summary)n.summary[r].proportion=n.summary[r].value/e.summary[r].value}}),l=a),i.summaryConfig.column&&(d=function(s,f,l){var n,d={},h={},t=function(i){h[i]={},d[i]={};var n,o=f[i],t=(s.forEach(function(r){for(var n in r.data)!function(n){d[i][n]=d[i][n]||{data:[],sum:0};var t=[],e=0;switch(r.data[n].forEach(function(n){switch(t.push(n[o.field]),o.mode){case"uniqLength":t=O(t);break;case"avg":case"sum":e+=n[o.field];break;case"notZeroLength":0!==_(n[o.field])&&e++}}),o.mode){case"uniqLength":t=O(t);break;case"avg":e/=r.data[n].length}d[i][n].data=d[i][n].data.concat(t),d[i][n].sum+=e}(n)}),void 0);for(n in d[i]){var e,r=0;switch(o.mode){case"avg":r=d[i][n].sum/s.length;break;case"uniqLength":r=O(d[i][n].data).length;break;case"notZeroLength":case"sum":r=d[i][n].sum}h[i][n]={value:r,proportion:0,riseRatio:t?pn(null==(e=h[i][t])?void 0:e.value,r):void 0},t=n}var a,u=0,c=0;for(a in h[i])u+=h[i][a].value,c++;h[i][l]={value:u/c,riseRatio:m,proportion:0}};for(n in f)t(n);return h}(l,i.summaryConfig.column,i.summaryConfig.averageField))),{columns:c,data:l,colSummary:d,getExtRow:function(t,n,e){var r,i=l.find(function(n){return n.name===t}),o={};if(!i){var a=n,u=e,c=d[t],s={};if(c)for(var f in c)s[f]=u(c[f][a]);return s}for(r in i.summary)o[r]=e(i.summary[r][n]);return o}}},n.changeIndex=function(n,t,e){return n<0?t:((t=(t+e)%(n+=1))<0&&(t+=n),-0===t?0:t)},n.cloneEasy=k,n.connectEcharts=Sn,n.dataCache=function(n){e[n]=e[n]||{count:0,complete:!1,data:null};var t=e[n];return t.count++,{isExist:function(){return 1<t.count},set:function(n){t.complete=!0,t.data=JSON.stringify(n)},get:function(n){w(function(){return t.complete},function(){n(i(t.data))},100)},logs:e}},n.dataPage=function(n,t,e){if(e<1)throw"页码必须大于0";var r=(e-1)*t,i=r+t;return{current:e,total:n.length,size:t,pages:Math.ceil(n.length/t),data:k(n.slice(r,i))}},n.debounce=function(r,n,t){var e,i,o,a,u=I(500,n),{leading:c,trailing:s}=Tn({leading:!1,trailing:!0},t),f=!1,l=!1;function d(){clearTimeout(e),e=setTimeout(h,u)}function h(){f=!1}function m(){f=!0,d(),r.apply(self,a)}function p(){if(!l){o=this;for(var n=arguments.length,t=new Array(n),e=0;e<n;e++)t[e]=arguments[e];a=t,c&&(f||(f=!0,r.apply(o,a)),d()),s&&(clearTimeout(i),i=setTimeout(m,u))}}return p.cancel=function(){clearTimeout(e),clearTimeout(i)},p.dispose=function(){clearTimeout(e),clearTimeout(i),l=!0},p},n.deepFindItem=S,n.deepFindTreePath=function(n,t,e){e=Object.assign(Y,e);for(var r=[],i=k(n),o=new Set,a=e["children"];i.length;){var u=i[0];if(o.has(u))r.pop(),i.shift();else if(o.add(u),u[a]&&i.unshift.apply(i,u[a]),r.push(u),t(u))return r}return undefined},n.defineEventBus=function(i){if(F[i])throw'"'+i+'" Has already been registered!';return F[i]=F[i]||[],{on:function(n){F[i].push(n)},emit:function(){for(var n=arguments.length,t=new Array(n),e=0;e<n;e++)t[e]=arguments[e];for(var r=0;r<F[i].length;r++)F[i][r].apply(m,t)},off:function(n){if(!n)throw"the hander of off is required!";for(var t=0;t<F[i].length;t++)F[i][t]===n&&F[i].splice(t--,1)},dispose:function(){for(var n=0;n<F[i].length;n++)F[i].splice(n--,1);delete F[i]},eventList:function(){return F[i]}}},n.defualtFormatter=I,n.difference=yn,n.fieldCheck=fn,n.filterWithMove=function(n,t){for(var e=[],r=0;r<n.length;r++){var i=n[r];t(i,r,n)&&(e.push(i),n.splice(r--,1))}return e},n.findLast=function(n,t){for(var e=n.length-1;0<=e;e--)if(t(n[e],e,n))return n[e]},n.floorFixed=function(n,t,e){var r=(n=C(n=b(_(n)),"."))[1]||"";return r.length<t&&(r=E(r,t,"0"),e&&(r=r.replace(/0+$/,""))),t<1||!r?n[0]:n[0]+"."+r.substring(0,t)},n.forEach=x,n.forEachKvPair=A,n.forEachTree=function(n,i,o){o=o||"children",function a(n,t){for(var e=0;e<n.length;e++){var r=k(t);i(n[e],r),h(n[e][o])&&(r.push(n[e]),a(n[e][o],r))}}(n,[])},n.formatTime=function(n){var t=(n=new Date(n)).getFullYear(),e=n.getMonth()+1,r=n.getDate(),i=n.getHours(),o=n.getMinutes(),a=n.getSeconds(),n=n.getMilliseconds();return N(t,4)+"/"+N(e,2)+"/"+N(r,2)+" "+N(i,2)+":"+N(o,2)+":"+N(a,2)+":"+N(n,3)},n.fuzzyReplace=function(n,t,e){return d(n)||d(t)||(n=b(n,"*"))&&(n=gn(n),n=new RegExp(n,s(e)),t=t.replace(n,function(n){return'<em class="g_search_highlight">'+n+"</em>"})),t},n.getLikeNumberRegExp=function(){return nn},n.getPiecesWithIndex=function(n,r){var i=[];return x(n,function(t,n){var e=r.find(function(n){return t>=n.min&&t<n.max});e&&i.push({gte:n,lt:n+1,color:e.color})}),i},n.getRandom=j,n.getRatio=R,n.getRiseRatio=function(n,t){return kn(n)&&kn(t)?0:kn(n)?1:kn(t)?-1:(t-n)/n},n.getSortIndex=function(n,e){var t=vn(n),r=vn(n);return r.sort(function(n,t){return e(n.value,t.value)}),t.map(function(t){return r.findIndex(function(n){return t.index===n.index})})},n.getType=f,n.isArray=h,n.isEmpty=g,n.isFunction=K,n.isFuzzyMatch=function(n,t,e){if(d(n)||d(t))return!1;var r=!0;return(n=b(n,"*"))&&(n=gn(n),r=new RegExp(n,s(e)).test(t)),r},n.isKvPair=l,n.isLikeNumber=tn,n.isNull=d,n.isString=r,n.listGroup=function(n,t){var f=xn(n,t);function o(n,t,e,r,i){var o=S(f.data,function(n){return 0===yn(n.uidPath,t,function(n,t){return n===t}).length}),a=I("",i);if(o)try{switch(n){case"_columnRiseRatio":case"_columnTotal":case"_columnProportion":var u=o[n][e];return d(u)?a:r(u);default:var c=o[n][e].summary;return d(c)?a:r(c,o[n][e].data)}}catch(s){return a}return a}function a(n,t,e,r){return o("_columns",n,t,e,r)}function u(n,t,e,r){return o("_columnProportion",n,t,e,r)}return{data:f.data,getCellValue:a,getCellVerticalRiseRatio:function(n,t,e,r){return o("_columnRiseRatio",n,t,e,r)},getCellVerticalTotal:function(n,t,e,r){var i;return"*"===n?d(i=f.total[t])?I("",r):e(i):o("_columnTotal",n,t,e,r)},getCellVerticalProportion:u,getRowCellValue:function(t,n,e,r){var i={};return n.forEach(function(n){i[n.id]=a(t,n.field,e,r)}),i},getRowVerticalProportion:function(t,n,e,r){var i={};return n.forEach(function(n){i[n.id]=u(t,n.field,e,r)}),i},getOriginGroupData:function(t,n){var e=S(f.data,function(n){return 0===yn(n.uidPath,t,function(n,t){return n===t}).length});return e&&null!=(e=null==(n=e._columns[n])?void 0:n.data)?e:[]},getOriginAllData:function(){return n}}},n.mapKvPair=function(n,t){var e,r={};for(e in n)r[e]=t(k(n[e]),e);return r},n.mapTree=an,n.mixInZeroWidthUnicode=function(n){return C(n,"").join("")},n.padEnd=E,n.padMinMax=function(n){for(var t,e,r,i=arguments.length,o=new Array(1<i?i-1:0),a=1;a<i;a++)o[a-1]=arguments[a];return o.forEach(function(n){n.forEach(function(n){n=_(n);t=d(t)?n:Math.min(t,n),e=d(e)?n:Math.max(e,n)})}),d(t)||d(e)||(t-=(r=e-t)*n,e+=r*n),{min:t,max:e}},n.padStart=on,n.param=X,n.parseQuery=J,n.parseTreeToTableHeader=function(n){return Cn(n=function u(n,i,o,a){return i[o]||(i[o]=[]),--a,n.forEach(function(n){var t=a+1,e=(a=t+n.count-1)-t+1,e={colStart:t,colEnd:a,colSpan:e,count:n.count,field:n.field,title:n.title,rowSpan:1};i[o][t]=e;for(var r=1;r<n.count;r++)i[o][t+r]=void 0;h(n.children)&&0<n.children.length&&u(n.children,i,o+1,t)}),i.forEach(function(n){for(var t=0;t<i[0].length;t++)n[t]||(n[t]=void 0)}),i}(En(n),[],0,0)),{columns:function(n){for(var e=[],t=n.length-1;0<=t;t--)n[t].forEach(function(n,t){n&&n.field&&d(e[t])&&(e[t]=n.field)});return e}(n),data:n}},n.randomColor=function(){return"rgba("+j(0,255,!0)+","+j(0,255,!0)+","+j(0,255,!0)+",1)"},n.repeatString=en,n.roundFixed=function(n,t,e){n=_(n);var r,i=Math.pow(10,t),n=(n<0?"-":"")+s(Math.round(Math.abs(n*i))/i);return 0<t&&(r=(i=C(n,"."))[0],(i=i[1]||"").length<t&&(i=E(i,t,"0"),n=(i=e?i.replace(/0+$/,""):i)?r+"."+i:r)),n},n.shake=function(n,t){return t=Object.assign({string:!0,array:!0,kvPair:!0},t),function i(n,t){if(l(n))for(var e in n){var r=n[e];(h(r)||l(r))&&i(r,t),Q(r,t)&&delete n[e]}}(n=k(n),t),n},n.shortNumber=function(n,t,e){for(var r=d(e)?wn:e,i=(r.sort(function(n,t){return t[0]-n[0]}),n),o="",a=0;a<r.length;a++){var u=r[a],c=n/u[0];if(1<=Math.abs(c)){i=c,o=u[1];break}}return{value:i,fmtValue:t(i),unit:o}},n.sortWithIndex=function(n,t){for(var e=[],r=0;r<n.length;r++)e[r]=n[t[r]];return e},n.spanTable=function(n,o){var u=k(n),c={};function e(i,o){var a=0;u.forEach(function(n,t){n.$rowSpan=null!=(r=n.$rowSpan)?r:{};var e,r=n[i];c[i]=null!=(e=c[i])?e:0,1<c[i]?(n.$rowSpan[i]=0,c[i]--):(e=function(n,t,e,r){var i=1;for(n++;n<r.length;n++){var o=r[n][t];if(o!==e&&!g(o))break;i++}return i}(t,i,r,u),void 0!==o&&(r=function(n,t,e){for(var r=0;0<=t&&!(0<(r=n[t].$rowSpan[e]));t--);return r}(u,t,o),0<a?r<=a+e?(e=r-a,a=0):a+=e:e<r?a=e:e=r),c[i]=e,n.$rowSpan[i]=c[i])})}return o.forEach(function(n,t){e(n,o[t-1])}),u.forEach(function(r){r.$colField={};var i=0;o.forEach(function(n,t){var e=r[n];1<i?(r.$colField[n]=0,i--):(i=function(n,t,e,r){var i=1;for(n++;n<r.length;n++){var o=b(e[r[n]]);if(o!==t&&!g(o))break;i++}return i}(t,e,r,o),r.$colField[n]=i)})}),u},n.split=C,n.test=Fn,n.thousands=function(n,i,o){i=i||3,o=o||",";var n=r(n)?n:s(n),t=!1,e=(tn(n)&&(t=(e=_(n))<0,n=Math.abs(e).toString()),n.replace(/([^.]*)?(\.)?(.*)?/,function(n,t,e,r){return s(t).replace(new RegExp("(.(?=(.{"+i+"})+$))","g"),"$1"+o)+s(e)+s(r)}));return e=t?"-"+e:e},n.throttle=function(n,t,e){var r,i,o,a,u,c=I(500,t),{leading:s,trailing:f}=Tn({leading:!0,trailing:!0},e),l=0,d=0,h=!1;function m(){d=l=0}function p(){f&&(1<d||!s)?(g(),u=setTimeout(m,c)):m()}function g(){l=+new Date,n.apply(i,a)}function v(){if(!h){d++;for(var n=arguments.length,t=new Array(n),e=0;e<n;e++)t[e]=arguments[e];a=t,i=this,r=+new Date,clearTimeout(o),clearTimeout(u),0===l?s?g():l=r:c<=r-l&&g(),o=setTimeout(p,c)}}return v.cancel=function(){clearTimeout(o),clearTimeout(u)},v.dispose=function(){clearTimeout(o),clearTimeout(u),h=!0},v},n.tree=function(n,t){for(var e=(t=p(t)).id||"id",r=t.pid||"pid",i=t.children||"children",o=0;o<n.length;o++){var a,u=n[o];(a=S(n,function(n){return null!=n[e]&&n[e]!=u[e]&&n[e]===u[r]},i))&&(a[i]=v(a[i]),a[i].push(u),n.splice(o--,1))}return n},n.treeFilter=function(n,a){var t=[];return function u(n,t){for(var e=0;e<n.length;e++){var r=n[e];if(a(r)){var i,o={};for(i in r)"children"!==i&&(o[i]=r[i]);h(r.children)&&(o.children=[],u(r.children,o.children)),t.push(o)}}}(n,t),t},n.treeLeafs=function(n){var t=[];return function e(n,t){x(n,function(n){h(n.children)?e(n.children,t):t.push(n)})}(n,t),t},n.trim=b,n.union=function(){for(var n=arguments.length,t=new Array(n),e=0;e<n;e++)t[e]=arguments[e];var r=new Set(t);return Array.from(r)},n.urlToGet=function(n,t){n=s(n);var o=l(t)?t:J(t),t=J(n=n.replace(/({{)(.*?)(}})/g,function(n,t,e,r){e=b(e);var i=o[e];return delete o[e],i})),t=X(o=Object.assign(t,o));return n=t?(n=n.replace(/\?.*/,""))+"?"+t:n},n.uuid=function(n){n=_(n);for(var t="",e=0;e<13;e++)t+=j(1,9);return n=(new Date).getTime()*j(1,100),E(T()+Number(t).toString(32)+n.toString(32),20,T()+T()+T())},n.variableHasValue=w});
</script>
</head>
<body>
<div id="app" style="width: 100%;">
<el-table :data="tableData" border style="width: 100%;" :span-method="arraySpanMethod">
<el-table-column prop="col_01" label="名称"></el-table-column>
<el-table-column prop="col_02" label="表型"></el-table-column>
<el-table-column prop="col_03" label="建议"></el-table-column>
</el-table>
</div>
<script>
function getApiData () {
return [
{ id: 1, col_01: 'GG', col_02: '高应答', col_03: '1111111111' },
{ id: 2, col_01: 'MM', col_02: '高应答', col_03: '1111111111' },
{ id: 3, col_01: 'YY', col_02: '高应答', col_03: '1111111111' },
{ id: 4, col_01: 'UU', col_02: '中间应答', col_03: '4444444444' },
{ id: 5, col_01: 'PO', col_02: '中间应答', col_03: '5555555555' },
{ id: 6, col_01: 'VG', col_02: '低应答', col_03: '6666666666' },
]
}
const { ref } = Vue
const App = {
setup() {
// 原始数据
const res = getApiData()
// 统一计算合并
const cvtData = jUtilsBase.spanTable(res, ['col_02', 'col_03'])
const tableData = ref(cvtData)
function arraySpanMethod ({row, column, rowIndex,columnIndex}) {
return {
colspan: row.$colField[column.property] ?? 1,
rowspan: row.$rowSpan[column.property] ?? 1
}
}
return {
tableData,
arraySpanMethod
};
},
};
const app = Vue.createApp(App);
app.use(ElementPlus);
app.mount("#app");
</script>
</body>
</html>
首先与上面的行比,看是否一样,一样表示是要隐藏的,合并行为0
再循环与下面的行比,看是否一样,每有一个一样的,代表需要合并的行+1
大概是下面的代码,没有测试,你自己测试下,主要看下两个return返回的数据对不对