diff --git a/CHANGELOG.md b/CHANGELOG.md index 12b5dfb..af17fe1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## [1.2.3](https://github.com/peng92055/smart-table/tree/1.2.3) (2020-05-06) + +[Full Changelog](https://github.com/peng92055/smart-table/compare/1.2.2...1.2.3) + +- 优化树形表格含有非法expand-parent +- 优化树形表格支持自定义高度控制 +- 修复expand中多标签bug + ## [1.2.2](https://github.com/peng92055/smart-table/tree/1.2.2) (2020-02-19) [Full Changelog](https://github.com/peng92055/smart-table/compare/1.2.1...1.2.2) diff --git a/config/webpack.dev.js b/config/webpack.dev.js index fff9eb7..a9a2da8 100644 --- a/config/webpack.dev.js +++ b/config/webpack.dev.js @@ -10,7 +10,7 @@ module.exports = merge(common, { inject: 'head' }) ], - devtool: 'inline-source-map', + devtool: 'cheap-module-eval-source-map', devServer: { contentBase: './examples' } diff --git a/config/webpack.example.js b/config/webpack.example.js index 5c0d6d1..3684069 100644 --- a/config/webpack.example.js +++ b/config/webpack.example.js @@ -23,6 +23,7 @@ module.exports = merge(common, { } }], }, + devtool: 'cheap-module-source-map', plugins: [ new CleanWebpackPlugin(), new webpack.BannerPlugin(`smartTable v${pkg.version} | (c) pengyajun 2020 | Released under the MIT License.`), diff --git a/config/webpack.prod.js b/config/webpack.prod.js index b130adb..592c554 100644 --- a/config/webpack.prod.js +++ b/config/webpack.prod.js @@ -21,6 +21,7 @@ module.exports = merge(common, { } }], }, + devtool: 'cheap-module-source-map', plugins: [ new CleanWebpackPlugin(), new webpack.BannerPlugin(`smartTable v${pkg.version} | (c) pengyajun 2020 | Released under the MIT License.`) diff --git a/dist/smartTable.min.js b/dist/smartTable.min.js index b790004..1c17764 100644 --- a/dist/smartTable.min.js +++ b/dist/smartTable.min.js @@ -1 +1,2 @@ -/*! smartTable v1.2.2 | (c) pengyajun 2020 | Released under the MIT License. */!function(e){var t={};function r(o){if(t[o])return t[o].exports;var n=t[o]={i:o,l:!1,exports:{}};return e[o].call(n.exports,n,n.exports,r),n.l=!0,n.exports}r.m=e,r.c=t,r.d=function(e,t,o){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(r.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)r.d(o,n,function(t){return e[t]}.bind(null,n));return o},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=2)}([function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.createElement=function(e,t){var r=document.createElement(e);return t&&(r.className=t),r},t.appendChild=function(e,t){return e.appendChild(t)},t.hasAttribute=function(e,t){return e.hasAttribute(t)},t.setAttribute=function(e,t,r){return e.setAttribute(t,r||!0)},t.getAttribute=function(e,t){return e.getAttribute(t)},t.removeAttribute=function(e,t){return e.removeAttribute(t)},t.appendChildren=function(e,t){return t.forEach((function(t){e.appendChild(t)})),e},t.insertBefore=function(e,t,r){e.insertBefore(t,r)},t.nextSibling=function(e){return e.nextSibling},t.removeChild=function(e,t){e.removeChild(t)},t.cloneNode=function(e,t){return e.cloneNode(t)},t.querySelector=function(e,t){return e.querySelector(t)},t.querySelectorAll=function(e,t){return e.querySelectorAll(t)},t.offsetHeight=function(e){return e.offsetHeight},t.offsetWidth=function(e){return e.offsetWidth},t.styled=function(e,t){for(var r in t)e.style[r]=t[r];return e}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.refactorCell=function(e){var t=e.childNodes,r=(0,o.createElement)("div","stb_cell");for(;t.length;)(0,o.appendChild)(r,t[0]);(0,o.appendChild)(e,r)},t.createCheckbox=function(e,t){if(!e)return;var r=(0,o.createElement)(e);(0,o.setAttribute)(r,"rowspan",t);var n=(0,o.createElement)("label","std-checkbox"),i=(0,o.createElement)("span","std-checkbox_input");return(0,o.appendChild)(i,(0,o.createElement)("span","std-checkbox_inner")),(0,o.appendChild)(n,i),(0,o.appendChild)(r,n),r},t.createExpandTrigger=function(e,t){if(!e)return;var r=(0,o.createElement)(e,"td"===e?"expand-cell":"");(0,o.setAttribute)(r,"rowspan",t);var n=(0,o.createElement)("span","td"===e?"expand-trigger":"");return(0,o.appendChild)(r,n),r},t.createTableWrapper=function(e,t,r,i){var a=(0,o.createElement)("div",e),l=(0,o.createElement)("table","stb_"+r);return(0,o.styled)(l,{width:t.size.tableWidth+"px"}),(0,o.appendChildren)(l,[n(t.colgroup),i]),(0,o.appendChild)(a,l),a},t.replaceColGroup=function(e){(0,o.querySelectorAll)(e.$root,"table").forEach((function(t){(0,o.styled)(t,{width:e.size.tableWidth+"px"}),t.replaceChild(n(e.colgroup),(0,o.querySelector)(t,"colgroup"))}))},t.getAttrNumber=function(e,t,r){return Number.parseInt((0,o.getAttribute)(e,t)||r)},t.getEmptyIndexInArray=function(e){for(var t=0,r=e.length;te?l():r=setTimeout(l,e-i)}},t.debounce=function(e,t){var r=void 0;return function(){var o=this,n=arguments;function i(){t.apply(o,n)}r&&clearTimeout(r),r=setTimeout(i,e)}};var o=r(0);function n(e){if(e){var t=(0,o.createElement)("colgroup");return e.forEach((function(e){var r=(0,o.createElement)("col");(0,o.setAttribute)(r,"width",e),(0,o.appendChild)(t,r)})),t}}},function(e,t,r){"use strict";var o,n=r(3),i=(o=n)&&o.__esModule?o:{default:o};window.SmartTable=i.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),r(4);var o,n=r(8);function i(e){var t=this;this instanceof i||console.error("Smart Table is a constructor and should be called with the `new` keyword"),window.addEventListener("load",(function(){setTimeout(t._init(e),0)}))}(0,((o=n)&&o.__esModule?o:{default:o}).default)(i),t.default=i},function(e,t,r){var o=r(5),n=r(6);"string"==typeof(n=n.__esModule?n.default:n)&&(n=[[e.i,n,""]]);var i={insert:"head",singleton:!1},a=(o(e.i,n,i),n.locals?n.locals:{});e.exports=a},function(e,t,r){"use strict";var o,n=function(){return void 0===o&&(o=Boolean(window&&document&&document.all&&!window.atob)),o},i=function(){var e={};return function(t){if(void 0===e[t]){var r=document.querySelector(t);if(window.HTMLIFrameElement&&r instanceof window.HTMLIFrameElement)try{r=r.contentDocument.head}catch(e){r=null}e[t]=r}return e[t]}}(),a={};function l(e,t,r){for(var o=0;otd:first-child>:before{-webkit-transform:rotate(90deg);transform:rotate(90deg)}.smart-table tbody .expand-trigger{display:inline-block;-webkit-transition:0.35s ease transform;transition:0.35s ease transform;-webkit-transform-origin:25% 50%;transform-origin:25% 50%;width:0;height:0;border-width:6px;border-style:solid;border-color:transparent transparent transparent #c0c4cc;margin-left:5px}.smart-table tbody .expand-cell>.stb_cell{cursor:pointer}.smart-table tbody .expand-cell>.stb_cell[open] .expand-trigger{-webkit-transform:rotate(90deg);transform:rotate(90deg)}.smart-table tbody .expand-cell>.stb_cell[loading] .expand-trigger{margin-left:0;width:1em;height:1em;border-color:none;-webkit-transform-origin:center;transform-origin:center;border:.2em solid transparent;border-left-color:currentcolor;border-right-color:currentcolor;border-radius:50%;-webkit-animation:1s loading linear infinite;animation:1s loading linear infinite}.smart-table tbody.stripe tr:nth-child(2n){background-color:#F9FBFF}.smart-table td,.smart-table th{padding:5px 0;text-overflow:ellipsis;vertical-align:middle;position:relative;border-bottom:1px solid #ECF0F5;border-right:1px solid #ECF0F5;text-align:center}.smart-table td.is-hidden>*,.smart-table th.is-hidden>*{visibility:hidden}.smart-table th{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;overflow:hidden}.smart-table th[sort]{cursor:pointer}.smart-table th[sort] :before,.smart-table th[sort] :after{content:\'\';float:right;width:0;height:0;border-width:5px;border-style:solid}.smart-table th[sort] :before{margin:1px 0 0 -10px;border-color:transparent transparent #c0c4cc transparent}.smart-table th[sort] :after{margin:12px 0 0 4px;border-color:#c0c4cc transparent transparent transparent}.smart-table th[sort].desc :after{border-top-color:#409eff}.smart-table th[sort].asc :before{border-bottom-color:#409eff}.smart-table.stb-cust-large thead{font-size:16px}.smart-table.stb-cust-large tbody{font-size:15px}.smart-table.stb-cust-large td,.smart-table.stb-cust-large th{padding:12px 0}.smart-table.stb-cust-middle thead{font-size:15px}.smart-table.stb-cust-middle tbody{font-size:14px}.smart-table.stb-cust-middle td,.smart-table.stb-cust-middle th{padding:10px 0}.smart-table.stb-cust-left td,.smart-table.stb-cust-left th{text-align:left}.smart-table.stb-cust-right td,.smart-table.stb-cust-right th{text-align:right}.smart-table th[align="left"],.smart-table td[align="left"]{text-align:left}.smart-table th[align="center"],.smart-table td[align="center"]{text-align:center}.smart-table th[align="right"],.smart-table td[align="right"]{text-align:right}.smart-table th[nowrap] .stb_cell,.smart-table td[nowrap] .stb_cell{white-space:nowrap}.smart-table .std-checkbox_inner{display:inline-block;position:relative;border:1px solid #dcdfe6;border-radius:2px;box-sizing:border-box;width:14px;height:14px;background-color:#fff;z-index:1;-webkit-transition:border-color 0.25s cubic-bezier(0.71, -0.46, 0.29, 1.46),background-color 0.25s cubic-bezier(0.71, -0.46, 0.29, 1.46);transition:border-color 0.25s cubic-bezier(0.71, -0.46, 0.29, 1.46),background-color 0.25s cubic-bezier(0.71, -0.46, 0.29, 1.46)}.smart-table .std-checkbox_inner:after{box-sizing:content-box;content:"";border:1px solid #fff;border-left:0;border-top:0;height:7px;left:4px;position:absolute;top:1px;-webkit-transform:rotate(45deg) scaleY(0);transform:rotate(45deg) scaleY(0);width:3px;-webkit-transition:-webkit-transform .15s ease-in .05s;transition:-webkit-transform .15s ease-in .05s;transition:transform .15s ease-in .05s;transition:transform .15s ease-in .05s, -webkit-transform .15s ease-in .05s;-webkit-transform-origin:center;transform-origin:center}.smart-table .std-checkbox_input{white-space:nowrap;cursor:pointer;outline:none;display:inline-block;line-height:1;position:relative;vertical-align:middle}.smart-table .std-checkbox{color:#606266;font-weight:500;font-size:14px;position:relative;cursor:pointer;display:inline-block;white-space:nowrap;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.smart-table .std-checkbox[checked]>.std-checkbox_input>.std-checkbox_inner{background-color:#409eff;border-color:#409eff}.smart-table .std-checkbox[checked]>.std-checkbox_input>.std-checkbox_inner:after{-webkit-transform:rotate(45deg) scaleY(1);transform:rotate(45deg) scaleY(1)}.smart-table .stb_cell{overflow:hidden;text-overflow:ellipsis;white-space:normal;word-break:break-all;padding:0 4px;line-height:23px}.smart-table th>.stb_cell{display:inline-block;position:relative;vertical-align:middle}.smart-table .stb_body,.smart-table .stb_footer,.smart-table .stb_header{table-layout:fixed;border-collapse:separate;background:#fff}.smart-table .stb_header-wrapper{overflow:hidden}.smart-table .stb_body-wrapper{overflow:auto}.smart-table .stb_fixed,.smart-table .stb_fixed-right{position:absolute;top:0;left:0;overflow-x:hidden;overflow-y:hidden;box-shadow:0 -1px 8px rgba(0,0,0,0.08)}.smart-table .stb_fixed-right{top:0;left:auto;right:0;box-shadow:-1px 0 8px rgba(0,0,0,0.08)}.smart-table .stb_fixed-right .stb_fixed-body-wrapper,.smart-table .stb_fixed-right .stb_fixed-footer-wrapper,.smart-table .stb_fixed-right .stb_fixed-header-wrapper{left:auto;right:0}.smart-table .stb_fixed-right-patch{position:absolute;top:-1px;right:0;background-color:#F5F7FB}.smart-table .stb_fixed-header-wrapper{position:absolute;left:0;top:0;z-index:3}.smart-table .stb_fixed-body-wrapper{position:absolute;left:0;top:37px;overflow:hidden;z-index:3}.smart-table ::-webkit-scrollbar{width:8px;height:8px;background-color:#e9edf4}.smart-table ::-webkit-scrollbar-thumb{background-color:#ccc;border-radius:2em}.smart-table ::-webkit-scrollbar-thumb:hover{background-color:#919191}.smart-table *{box-sizing:border-box}@-webkit-keyframes loading{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}100%{-webkit-transform:rotate(360deg);transform:rotate(360deg)}}@keyframes loading{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}100%{-webkit-transform:rotate(360deg);transform:rotate(360deg)}}\n',""]),e.exports=t},function(e,t,r){"use strict";e.exports=function(e){var t=[];return t.toString=function(){return this.map((function(t){var r=function(e,t){var r=e[1]||"",o=e[3];if(!o)return r;if(t&&"function"==typeof btoa){var n=(a=o,l=btoa(unescape(encodeURIComponent(JSON.stringify(a)))),d="sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(l),"/*# ".concat(d," */")),i=o.sources.map((function(e){return"/*# sourceURL=".concat(o.sourceRoot||"").concat(e," */")}));return[r].concat(i).concat([n]).join("\n")}var a,l,d;return[r].join("\n")}(t,e);return t[2]?"@media ".concat(t[2]," {").concat(r,"}"):r})).join("")},t.i=function(e,r){"string"==typeof e&&(e=[[null,e,""]]);for(var o=0;o0&&void 0!==arguments[0]?arguments[0]:{};if(!e.selector)return console.error("Smart Table init need a selector");var t=String(e.selector).trim(),r=(0,n.querySelector)(document,t);if(!r)return console.error("Smart Table "+t+" not found");var o=(0,n.querySelector)(r,"table");if(!o)return console.error("Smart Table init need a table");var a=(0,n.querySelector)(o,"thead");if(!a)return console.error("Smart Table init need a thead");var d=(0,n.querySelector)(o,"tbody");if(!d)return console.error("Smart Table init need a tbody");r.classList.add("smart-table"),e.size&&r.classList.add("stb-cust-"+e.size),e.align&&r.classList.add("stb-cust-"+e.align),(0,n.hasAttribute)(o,"stripe")&&d.classList.add("stripe"),e.expand?((0,n.querySelectorAll)(a,"th[sort]").forEach((function(e){(0,n.removeAttribute)(e,"sort")})),(0,n.querySelectorAll)(a,"th[fixed]").forEach((function(e){(0,n.removeAttribute)(e,"fixed")}))):((0,n.querySelectorAll)(d,"tr[expand]").forEach((function(e){(0,n.removeAttribute)(e,"expand")})),(0,n.querySelectorAll)(a,"tr[expand-parent]").forEach((function(e){(0,n.removeAttribute)(e,"expand-parent")}))),e.expandCallback&&(0,n.querySelectorAll)(a,"th[fixed]").forEach((function(e){(0,n.removeAttribute)(e,"fixed")}));var u=this;u.$root=r,u.$thead=a,u.$tbody=d,u.options=e,u.gutterWidth=(0,l.default)(),u.style={radioBgColor:e.radioBgColor||"#D1E7FF",hoverBgColor:e.hoverBgColor||"#EFF8FF"},u.size={},u.hasCheckbox=!e.expand&&"checkbox"===e.selection,u.hasExpandCb=!!e.expandCallback,u.hasExpandCb&&s(u),u.hasCheckbox&&c(u),x(u),f(u,o),e.expand||(m(u),(0,i.default)(u,a,d)),y(u,d),e.expand&&v(u,d),h(u);var p=(0,n.createElement)("th");(0,n.styled)(p,{display:"none"}),(0,n.setAttribute)(p,"width",u.gutterWidth),(0,n.setAttribute)(p,"rowspan",u.props.shapes.length),(0,n.appendChild)((0,n.querySelector)(u.$thead,"tr"),p),u.$scrollTH=p,u.scrollY&&((0,n.styled)(u.$scrollTH,{display:"table-cell"}),b(u))}};var o=d(r(9)),n=r(0),i=d(r(10)),a=r(1),l=d(r(11));function d(e){return e&&e.__esModule?e:{default:e}}function s(e){var t=e.$thead,r=e.$tbody,o=(0,n.querySelector)(t,"tr"),i=o.querySelector("th"),l=(0,a.createExpandTrigger)("th",(0,a.getAttrNumber)(i,"rowspan",1));(0,n.hasAttribute)(i,"fixed")&&(0,n.setAttribute)(l,"fixed"),(0,n.insertBefore)(o,l,i),(0,n.querySelectorAll)(r,"tr").forEach((function(e){var t=e.querySelector("td");(0,n.insertBefore)(e,(0,a.createExpandTrigger)("td",(0,a.getAttrNumber)(t,"rowspan",1)),t)}))}function c(e){var t=e.$thead,r=e.$tbody,o=(0,n.querySelector)(t,"tr"),i=o.querySelector("th"),l=(0,a.createCheckbox)("th",(0,a.getAttrNumber)(i,"rowspan",1));(0,n.hasAttribute)(i,"fixed")&&(0,n.setAttribute)(l,"fixed"),(0,n.insertBefore)(o,l,i),(0,n.querySelectorAll)(r,"tr").forEach((function(e){var t=e.querySelector("td");(0,n.insertBefore)(e,(0,a.createCheckbox)("td",(0,a.getAttrNumber)(t,"rowspan",1)),t)}))}function f(e,t){var r=e.$root,o=e.$thead,i=e.$tbody,l=e.options.height;(0,n.querySelectorAll)(o,"th").forEach((function(e){return(0,a.refactorCell)(e)})),(0,n.querySelectorAll)(i,"td").forEach((function(e){return(0,a.refactorCell)(e)})),u(e),e.$theadWrapper=(0,a.createTableWrapper)("stb_header-wrapper",e,"header",o),e.$tbodyWrapper=(0,a.createTableWrapper)("stb_body-wrapper",e,"body",i),(0,n.appendChildren)(r,[e.$theadWrapper,e.$tbodyWrapper]);var d=(0,n.offsetHeight)(o),s=("function"==typeof l?l.call():l)||(0,n.offsetHeight)(r),c=s>d?s-d-1:d+150;(0,n.styled)(e.$tbodyWrapper,{height:c+"px"}),e.size.tbodyWrapperHeight=c,e.scrollY=(0,n.offsetHeight)(e.$tbody)>c,(0,n.removeChild)(t.parentNode,t)}function u(e){var t=e.$root,r=e.props,o=(0,n.offsetWidth)(t)-1,i=o-(e.scrollY?e.gutterWidth:0),l=[],d=0;r.shapes.forEach((function(e){e.forEach((function(e,t){e&&(1===(0,a.getAttrNumber)(e,"colspan",1)&&(l[t]=(0,a.getAttrNumber)(e,"width",0)))}))}));var s=0;if(l.forEach((function(e){d+=e,0===e&&s++})),s){var c=Math.floor((i-d)/s),f=c>80?c:80,u=0;d=0,l=l.map((function(t,r){return 0===t&&(t=(e.hasCheckbox||e.hasExpandCb)&&0===r?55:f,u=r),d+=t,t})),i>d&&(l[u]=l[u]+i-d,d=i)}else d=l.reduce((function(e,t){return t+e}),0);e.colgroup=l,e.size.rootWidth=o,e.size.tableWidth=d,e.scrollX=e.size.tableWidth>e.size.rootWidth}function h(e){!function(e){e.$tbodyWrapper.addEventListener("scroll",(function(){return function(e){(0,a.throttle)(20,(function(){e.$theadWrapper.scrollLeft=e.$tbodyWrapper.scrollLeft,e.$fixedLeftBody&&(e.$fixedLeftBody.scrollTop=e.$tbodyWrapper.scrollTop),e.$fixedRightBody&&(e.$fixedRightBody.scrollTop=e.$tbodyWrapper.scrollTop)}))()}(e)}),{passive:!0})}(e),function(e){var t=e.options,r=t.selection,o=t.selectionKey;o=o||0,e.hasExpandCb&&o++;var i=(0,n.querySelector)(e.$fixedLeft||e.$thead,"th>.stb_cell>label.std-checkbox");[].concat(e.data,e.unsortData).forEach((function(t){g(e,t.$el,[t.$fixedLeftEl,t.$fixedRightEl]),t.$fixedLeftEl&&g(e,t.$fixedLeftEl,[t.$el,t.$fixedRightEl]),t.$fixedRightEl&&g(e,t.$fixedRightEl,[t.$el,t.$fixedLeftEl]);var a=t["field-"+o];if(r)switch(r){case"radio":p(e,t.$el,[t.$fixedLeftEl,t.$fixedRightEl],a),t.$fixedLeftEl&&p(e,t.$fixedLeftEl,[t.$el,t.$fixedRightEl],a),t.$fixedRightEl&&p(e,t.$fixedRightEl,[t.$el,t.$fixedLeftEl],a);break;case"checkbox":!function(e,t,r,o){var i=(0,n.querySelector)(t,"label.std-checkbox");if(!i||!r)return;i.addEventListener("click",(function(){var t=e.selected;t=t||[];var a=!(0,n.hasAttribute)(i,"checked");a?(0,n.setAttribute)(i,"checked",!0):(0,n.removeAttribute)(i,"checked"),a?t.push(o):t.splice(t.indexOf(o),1);var l=t.length;l?(0,n.setAttribute)(e.$root,"selected",JSON.stringify(t)):(0,n.removeAttribute)(e.$root,"selected"),l===e.data.length+e.unsortData.length?(0,n.setAttribute)(r,"checked",!0):(0,n.removeAttribute)(r,"checked"),e.selected=t}))}(e,t.$fixedLeftEl||t.$el,i,a)}e.hasExpandCb&&function(e,t,r,o){var i=this,a=e.options,l=(0,n.querySelector)(t,".expand-cell>.stb_cell");if(!l)return;l.addEventListener("click",(function(d){l.hasAttribute("loading")||(l.hasAttribute("open")?((0,n.removeAttribute)(l,"open"),(0,n.querySelectorAll)(e.$root,"tr.expand-"+r).forEach((function(e){(0,n.removeChild)(e.parentNode,e)}))):((0,n.setAttribute)(l,"loading",!0),a.expandCallback.call(i,{open:function(o,i){var a=(0,n.createElement)("td");(0,n.setAttribute)(a,"colspan",e.colgroup.length);var d=(0,n.createElement)("div","std-dialog_content");i?d.innerHTML=o:(0,n.appendChild)(d,o),(0,n.appendChild)(a,d);var s=(0,n.createElement)("tr","std-expand-row expand-"+r);(0,n.appendChild)(s,a),(0,n.insertBefore)(t.parentNode,s,t.nextSibling),(0,n.setAttribute)(l,"open"),(0,n.removeAttribute)(l,"loading")}},o)),d.stopPropagation())}))}(e,t.$fixedLeftEl||t.$el,t.$key,a)})),e.hasCheckbox&&function(e,t){if(!t)return;var r=e.options.selectionKey;t.addEventListener("click",(function(){var o=e.selected;o=[];var i=!(0,n.hasAttribute)(t,"checked");i?(0,n.setAttribute)(t,"checked",!0):(0,n.removeAttribute)(t,"checked"),[].concat(e.data,e.unsortData).forEach((function(e){var t=(0,n.querySelector)(e.$fixedLeftEl||e.$el,"label.std-checkbox");i?(0,n.setAttribute)(t,"checked",!0):(0,n.removeAttribute)(t,"checked"),i&&o.push(e["field-"+(r||0)])})),o.length?(0,n.setAttribute)(e.$root,"selected",JSON.stringify(o)):(0,n.removeAttribute)(e.$root,"selected"),e.selected=o}))}(e,i)}(e),e.options.expand?function(e){!function e(t){t.forEach((function(t){t.expand&&((0,n.querySelector)(t.$el,"td").addEventListener("click",(function(){!function e(t,r){r?(0,n.setAttribute)(t.$el,"expanded"):(0,n.removeAttribute)(t.$el,"expanded"),t.children&&t.children.forEach((function(t){(0,n.styled)(t.$el,{display:r?"":"none"}),e(t,r)}))}(t,!(0,n.hasAttribute)(t.$el,"expanded"))})),t.children&&e(t.children))}))}(e.expandData)}(e):function(e){var t=Array.from((0,n.querySelectorAll)(e.$root,"th[sort]"));if(0===t.length)return;t.forEach((function(r){r.addEventListener("click",(function(i){i.stopPropagation();var a="ASC",l=(0,n.getAttribute)(r,"sort")||"string";r.classList.contains("asc")?(r.classList.remove("asc"),r.classList.add("desc"),a="DESC"):(r.classList.remove("desc"),r.classList.add("asc")),t=t.map((function(e){return r!=e&&e.classList.remove("asc","desc"),e})),(0,n.querySelectorAll)(e.$root,"tr.std-expand-row").forEach((function(e){(0,n.removeChild)(e.parentNode,e)})),(0,n.querySelectorAll)(e.$root,".expand-cell>.stb_cell[open]").forEach((function(e){(0,n.removeAttribute)(e,"open")})),(0,n.querySelectorAll)(e.$root,".expand-cell>.stb_cell[loading]").forEach((function(e){(0,n.removeAttribute)(e,"loading")})),(0,o.default)(e,(0,n.getAttribute)(r,"sortkey"),a,l)}))}))}(e),function(e){window.addEventListener("resize",(function(){return b(e)}),{passive:!0})}(e)}function b(e){(0,a.debounce)(500,(function(){var t=e.props,r=t.fixedLeft,o=t.fixedRight;u(e),(0,a.replaceColGroup)(e),e.scrollY=(0,n.offsetHeight)(e.$tbody)>e.size.tbodyWrapperHeight,(0,n.styled)(e.$scrollTH,{display:e.scrollY?"table-cell":"none"});var i=(0,n.offsetHeight)(e.$root)-(e.scrollX?e.gutterWidth:2),l=(0,n.offsetHeight)(e.$thead)+(0,n.offsetHeight)(e.$tbody);i=l>i?i:l;var d=e.size.tbodyWrapperHeight-(e.scrollX?e.gutterWidth:0),s=(0,n.offsetHeight)(e.$thead),c=0,f=0;e.$fixedLeft&&r.thead.length&&(r.thead.forEach((function(t,r){c+=e.colgroup[r]})),(0,n.styled)(e.$fixedLeftBody,{height:d+"px",top:s+"px"}),(0,n.styled)(e.$fixedLeft,{width:c+"px",height:i+"px"})),e.$fixedRight&&o.thead.length&&(o.thead.forEach((function(t,r){f+=e.colgroup[e.colgroup.length-r-1]})),(0,n.styled)(e.$fixedRightBody,{height:d+"px",top:s+"px"}),(0,n.styled)(e.$fixedRight,{width:f+"px",height:i+"px",right:(e.scrollY?e.gutterWidth:0)+"px"}),(0,n.styled)(e.$rightPatch,{display:e.scrollY?"block":"none",height:(0,n.offsetHeight)(e.$thead)+"px"}))}))()}function p(e,t,r,o){t&&t.addEventListener("click",(function(){var i=e.selected,a=!1;(i!==o||(0,n.hasAttribute)(t,"checked"))&&(i!==o?((0,n.querySelectorAll)(e.$root,"tr[checked]>td").forEach((function(e){return(0,n.styled)(e,{background:""})})),(0,n.querySelectorAll)(e.$root,"tr[checked]").forEach((function(e){return(0,n.removeAttribute)(e,"checked")})),a=!0):(0,n.hasAttribute)(t,"checked")&&(a=!1),i=a?o:null,a?(0,n.setAttribute)(t,"checked",!0):(0,n.removeAttribute)(t,"checked"),t.querySelectorAll("td").forEach((function(t){(0,n.styled)(t,{background:a?e.style.radioBgColor:""})})),r.forEach((function(t){t&&(a?(0,n.setAttribute)(t,"checked",!0):(0,n.removeAttribute)(t,"checked"),t.querySelectorAll("td").forEach((function(t){(0,n.styled)(t,{background:a?e.style.radioBgColor:""})})))})),a?(0,n.setAttribute)(e.$root,"selected",JSON.stringify(i)):(0,n.removeAttribute)(e.$root,"selected"),e.selected=i)}))}function g(e,t,r){t&&(t.addEventListener("mouseenter",(function(){(0,n.styled)(t,{background:e.style.hoverBgColor}),r.forEach((function(t){t&&(0,n.styled)(t,{background:e.style.hoverBgColor})}))})),t.addEventListener("mouseleave",(function(){(0,n.styled)(t,{background:""}),r.forEach((function(e){e&&(0,n.styled)(e,{background:""})}))})))}function x(e){var t={},r=[];(0,n.querySelectorAll)(e.$thead,"tr").forEach((function(e,t){var o=r[t]||[];(0,n.querySelectorAll)(e,"th").forEach((function(e){var i=(0,a.getAttrNumber)(e,"rowspan",1),l=(0,a.getAttrNumber)(e,"colspan",1),d=(0,a.getEmptyIndexInArray)(o)||o.length;if(o[d]=e,(0,n.hasAttribute)(e,"sort")&&(0,n.setAttribute)(e,"sortkey","field-"+d),l>1)for(var s=1;s1)for(var c=1;cth"),s=d.length,c=0;if(0!==s){if((0,n.hasAttribute)(d[0],"fixed"))for(var f=0;f0&&(0,n.hasAttribute)(d[p],"fixed")&&p!==c;p--){l.thead.push("field-"+p);for(var g=(0,a.getAttrNumber)(d[p],"colspan",1),x=0;xt}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t,r){var n=320,d=e.props,s=d.fixedLeft,c=d.fixedRight;if(s.thead.length>0){n=n>s.width?n:s.width;var f=i(e,t,s),u=a(e,r,s,"left");e.$fixedLeft=l(e,f,u,s,"stb_fixed","left"),(0,o.appendChild)(e.$root,e.$fixedLeft),e.$fixedLeftBody=u}if(c.thead.length>0){n+=c.width;var h=i(e,t,c),b=a(e,r,c,"right");e.$fixedRight=l(e,h,b,c,"stb_fixed-right","right"),(0,o.appendChild)(e.$root,e.$fixedRight),e.$fixedRightBody=b;var p=(0,o.createElement)("div","stb_fixed-right-patch");(0,o.styled)(p,{display:"none",width:e.gutterWidth+"px",height:(0,o.offsetHeight)(e.$thead)+"px"}),(0,o.appendChild)(e.$root,p),e.$rightPatch=p,e.scrollY&&(0,o.styled)(e.$rightPatch,{display:"block"})}(0,o.styled)(e.$root,{minWidth:n+"px"})};var o=r(0),n=r(1);function i(e,t,r){var i=(0,o.cloneNode)(t,!0);return(0,o.querySelectorAll)(i,"tr:first-child>th").forEach((function(e,t){-1===r.thead.indexOf("field-"+t)&&e.classList.add("is-hidden")})),(0,n.createTableWrapper)("stb_fixed-header-wrapper",e,"header",i)}function a(e,t,r,i){var a=(0,o.cloneNode)(t,!0);(0,o.querySelectorAll)(a,"tr").forEach((function(e){var t=-1;(0,o.querySelectorAll)(e,"td").forEach((function(e,o){"left"===i?t=o:t+=(0,n.getAttrNumber)(e,"colspan",1),-1===r.tbody.indexOf("field-"+t)&&e.classList.add("is-hidden")}))}));var l=(0,n.createTableWrapper)("stb_fixed-body-wrapper",e,"body",a);return(0,o.styled)(l,{top:(0,o.offsetHeight)(e.$thead)+"px",height:e.size.tbodyWrapperHeight-(e.scrollX?e.gutterWidth:0)+"px"}),l}function l(e,t,r,n,i,a){var l=(0,o.createElement)("div",i);(0,o.appendChildren)(l,[t,r]);var d=(0,o.offsetHeight)(e.$root)-(e.scrollX?e.gutterWidth:2),s=(0,o.offsetHeight)(e.$thead)+(0,o.offsetHeight)(e.$tbody);return(0,o.styled)(l,{width:n.width+"px",height:(s>d?d:s)+"px",right:"right"===a?(e.scrollY?e.gutterWidth:0)+"px":""}),l}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(){if(void 0!==n)return n;var e=(0,o.createElement)("div","smart-table");(0,o.appendChild)(document.body,e);var t=(0,o.createElement)("div");(0,o.styled)(t,{visibility:"hidden",width:"100px",position:"absolute",top:"-9999px"}),(0,o.appendChild)(e,t);var r=(0,o.offsetWidth)(t);(0,o.styled)(t,{overflow:"scroll"});var i=(0,o.createElement)("div");(0,o.styled)(i,{width:"100%"}),(0,o.appendChild)(t,i);var a=(0,o.offsetWidth)(i);return(0,o.removeChild)(e.parentNode,e),n=r-a};var o=r(0),n=void 0}]); \ No newline at end of file +/*! smartTable v1.2.3 | (c) pengyajun 2020 | Released under the MIT License. */!function(e){var t={};function r(o){if(t[o])return t[o].exports;var n=t[o]={i:o,l:!1,exports:{}};return e[o].call(n.exports,n,n.exports,r),n.l=!0,n.exports}r.m=e,r.c=t,r.d=function(e,t,o){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(r.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)r.d(o,n,function(t){return e[t]}.bind(null,n));return o},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=2)}([function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.createElement=function(e,t){var r=document.createElement(e);return t&&(r.className=t),r},t.appendChild=function(e,t){return e.appendChild(t)},t.hasAttribute=function(e,t){return e.hasAttribute(t)},t.setAttribute=function(e,t,r){return e.setAttribute(t,r||!0)},t.getAttribute=function(e,t){return e.getAttribute(t)},t.removeAttribute=function(e,t){return e.removeAttribute(t)},t.appendChildren=function(e,t){return t.forEach((function(t){e.appendChild(t)})),e},t.insertBefore=function(e,t,r){e.insertBefore(t,r)},t.nextSibling=function(e){return e.nextSibling},t.removeChild=function(e,t){e.removeChild(t)},t.cloneNode=function(e,t){return e.cloneNode(t)},t.querySelector=function(e,t){return e.querySelector(t)},t.querySelectorAll=function(e,t){return e.querySelectorAll(t)},t.offsetHeight=function(e){return e.offsetHeight},t.offsetWidth=function(e){return e.offsetWidth},t.styled=function(e,t){for(var r in t)e.style[r]=t[r];return e}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.refactorCell=function(e){var t=e.childNodes,r=(0,o.createElement)("div","stb_cell");for(;t.length;)(0,o.appendChild)(r,t[0]);(0,o.appendChild)(e,r)},t.createCheckbox=function(e,t){if(!e)return;var r=(0,o.createElement)(e);(0,o.setAttribute)(r,"rowspan",t);var n=(0,o.createElement)("label","std-checkbox"),i=(0,o.createElement)("span","std-checkbox_input");return(0,o.appendChild)(i,(0,o.createElement)("span","std-checkbox_inner")),(0,o.appendChild)(n,i),(0,o.appendChild)(r,n),r},t.createExpandTrigger=function(e,t){if(!e)return;var r=(0,o.createElement)(e,"td"===e?"expand-cell":"");(0,o.setAttribute)(r,"rowspan",t);var n=(0,o.createElement)("span","td"===e?"expand-trigger":"");return(0,o.appendChild)(r,n),r},t.createTableWrapper=function(e,t,r,i){var a=(0,o.createElement)("div",e),l=(0,o.createElement)("table","stb_"+r);return(0,o.styled)(l,{width:t.size.tableWidth+"px"}),(0,o.appendChildren)(l,[n(t.colgroup),i]),(0,o.appendChild)(a,l),a},t.replaceColGroup=function(e){(0,o.querySelectorAll)(e.$root,"table").forEach((function(t){(0,o.styled)(t,{width:e.size.tableWidth+"px"}),t.replaceChild(n(e.colgroup),(0,o.querySelector)(t,"colgroup"))}))},t.getAttrNumber=function(e,t,r){return Number.parseInt((0,o.getAttribute)(e,t)||r)},t.getEmptyIndexInArray=function(e){for(var t=0,r=e.length;te?l():r=setTimeout(l,e-i)}},t.debounce=function(e,t){var r=void 0;return function(){var o=this,n=arguments;function i(){t.apply(o,n)}r&&clearTimeout(r),r=setTimeout(i,e)}};var o=r(0);function n(e){if(e){var t=(0,o.createElement)("colgroup");return e.forEach((function(e){var r=(0,o.createElement)("col");(0,o.setAttribute)(r,"width",e),(0,o.appendChild)(t,r)})),t}}},function(e,t,r){"use strict";var o,n=r(3),i=(o=n)&&o.__esModule?o:{default:o};window.SmartTable=i.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),r(4);var o,n=r(8);function i(e){var t=this;this instanceof i||console.error("Smart Table is a constructor and should be called with the `new` keyword"),window.addEventListener("load",(function(){setTimeout(t._init(e),0)}))}(0,((o=n)&&o.__esModule?o:{default:o}).default)(i),t.default=i},function(e,t,r){var o=r(5),n=r(6);"string"==typeof(n=n.__esModule?n.default:n)&&(n=[[e.i,n,""]]);var i={insert:"head",singleton:!1},a=(o(e.i,n,i),n.locals?n.locals:{});e.exports=a},function(e,t,r){"use strict";var o,n=function(){return void 0===o&&(o=Boolean(window&&document&&document.all&&!window.atob)),o},i=function(){var e={};return function(t){if(void 0===e[t]){var r=document.querySelector(t);if(window.HTMLIFrameElement&&r instanceof window.HTMLIFrameElement)try{r=r.contentDocument.head}catch(e){r=null}e[t]=r}return e[t]}}(),a={};function l(e,t,r){for(var o=0;otd:first-child:before{-webkit-transform:rotate(90deg);transform:rotate(90deg)}.smart-table tbody .expand-trigger{display:inline-block;-webkit-transition:0.35s ease transform;transition:0.35s ease transform;-webkit-transform-origin:25% 50%;transform-origin:25% 50%;width:0;height:0;border-width:6px;border-style:solid;border-color:transparent transparent transparent #c0c4cc;margin-left:5px}.smart-table tbody .expand-cell>.stb_cell{cursor:pointer}.smart-table tbody .expand-cell>.stb_cell[open] .expand-trigger{-webkit-transform:rotate(90deg);transform:rotate(90deg)}.smart-table tbody .expand-cell>.stb_cell[loading] .expand-trigger{margin-left:0;width:1em;height:1em;border-color:none;-webkit-transform-origin:center;transform-origin:center;border:.2em solid transparent;border-left-color:currentcolor;border-right-color:currentcolor;border-radius:50%;-webkit-animation:1s loading linear infinite;animation:1s loading linear infinite}.smart-table tbody.stripe tr:nth-child(2n){background-color:#F9FBFF}.smart-table td,.smart-table th{padding:5px 0;text-overflow:ellipsis;vertical-align:middle;position:relative;border-bottom:1px solid #ECF0F5;border-right:1px solid #ECF0F5;text-align:center}.smart-table td.is-hidden>*,.smart-table th.is-hidden>*{visibility:hidden}.smart-table th{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;overflow:hidden}.smart-table th[sort]>.stb_cell{cursor:pointer}.smart-table th[sort]>.stb_cell:before,.smart-table th[sort]>.stb_cell:after{content:\'\';float:right;width:0;height:0;border-width:5px;border-style:solid}.smart-table th[sort]>.stb_cell:before{margin:1px 0 0 -10px;border-color:transparent transparent #c0c4cc transparent}.smart-table th[sort]>.stb_cell:after{margin:12px 0 0 4px;border-color:#c0c4cc transparent transparent transparent}.smart-table th[sort]>.stb_cell.desc:after{border-top-color:#409eff}.smart-table th[sort]>.stb_cell.asc:before{border-bottom-color:#409eff}.smart-table.stb-cust-large thead{font-size:16px}.smart-table.stb-cust-large tbody{font-size:15px}.smart-table.stb-cust-large td,.smart-table.stb-cust-large th{padding:12px 0}.smart-table.stb-cust-middle thead{font-size:15px}.smart-table.stb-cust-middle tbody{font-size:14px}.smart-table.stb-cust-middle td,.smart-table.stb-cust-middle th{padding:10px 0}.smart-table.stb-cust-left td,.smart-table.stb-cust-left th{text-align:left}.smart-table.stb-cust-right td,.smart-table.stb-cust-right th{text-align:right}.smart-table th[align="left"],.smart-table td[align="left"]{text-align:left}.smart-table th[align="center"],.smart-table td[align="center"]{text-align:center}.smart-table th[align="right"],.smart-table td[align="right"]{text-align:right}.smart-table th[nowrap] .stb_cell,.smart-table td[nowrap] .stb_cell{white-space:nowrap}.smart-table .std-checkbox_inner{display:inline-block;position:relative;border:1px solid #dcdfe6;border-radius:2px;box-sizing:border-box;width:14px;height:14px;background-color:#fff;z-index:1;-webkit-transition:border-color 0.25s cubic-bezier(0.71, -0.46, 0.29, 1.46),background-color 0.25s cubic-bezier(0.71, -0.46, 0.29, 1.46);transition:border-color 0.25s cubic-bezier(0.71, -0.46, 0.29, 1.46),background-color 0.25s cubic-bezier(0.71, -0.46, 0.29, 1.46)}.smart-table .std-checkbox_inner:after{box-sizing:content-box;content:"";border:1px solid #fff;border-left:0;border-top:0;height:7px;left:4px;position:absolute;top:1px;-webkit-transform:rotate(45deg) scaleY(0);transform:rotate(45deg) scaleY(0);width:3px;-webkit-transition:-webkit-transform .15s ease-in .05s;transition:-webkit-transform .15s ease-in .05s;transition:transform .15s ease-in .05s;transition:transform .15s ease-in .05s, -webkit-transform .15s ease-in .05s;-webkit-transform-origin:center;transform-origin:center}.smart-table .std-checkbox_input{white-space:nowrap;cursor:pointer;outline:none;display:inline-block;line-height:1;position:relative;vertical-align:middle}.smart-table .std-checkbox{color:#606266;font-weight:500;font-size:14px;position:relative;cursor:pointer;display:inline-block;white-space:nowrap;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.smart-table .std-checkbox[checked]>.std-checkbox_input>.std-checkbox_inner{background-color:#409eff;border-color:#409eff}.smart-table .std-checkbox[checked]>.std-checkbox_input>.std-checkbox_inner:after{-webkit-transform:rotate(45deg) scaleY(1);transform:rotate(45deg) scaleY(1)}.smart-table .stb_cell{overflow:hidden;text-overflow:ellipsis;white-space:normal;word-break:break-all;padding:0 4px;line-height:23px}.smart-table th>.stb_cell{display:inline-block;position:relative;vertical-align:middle}.smart-table .stb_body,.smart-table .stb_footer,.smart-table .stb_header{table-layout:fixed;border-collapse:separate;background:#fff}.smart-table .stb_header-wrapper{overflow:hidden}.smart-table .stb_body-wrapper{overflow:auto}.smart-table .stb_fixed,.smart-table .stb_fixed-right{position:absolute;top:0;left:0;overflow-x:hidden;overflow-y:hidden;box-shadow:0 -1px 8px rgba(0,0,0,0.08)}.smart-table .stb_fixed-right{top:0;left:auto;right:0;box-shadow:-1px 0 8px rgba(0,0,0,0.08)}.smart-table .stb_fixed-right .stb_fixed-body-wrapper,.smart-table .stb_fixed-right .stb_fixed-footer-wrapper,.smart-table .stb_fixed-right .stb_fixed-header-wrapper{left:auto;right:0}.smart-table .stb_fixed-right-patch{position:absolute;top:-1px;right:0;background-color:#F5F7FB}.smart-table .stb_fixed-header-wrapper{position:absolute;left:0;top:0;z-index:3}.smart-table .stb_fixed-body-wrapper{position:absolute;left:0;top:37px;overflow:hidden;z-index:3}.smart-table ::-webkit-scrollbar{width:8px;height:8px;background-color:#e9edf4}.smart-table ::-webkit-scrollbar-thumb{background-color:#ccc;border-radius:2em}.smart-table ::-webkit-scrollbar-thumb:hover{background-color:#919191}.smart-table *{box-sizing:border-box}@-webkit-keyframes loading{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}100%{-webkit-transform:rotate(360deg);transform:rotate(360deg)}}@keyframes loading{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}100%{-webkit-transform:rotate(360deg);transform:rotate(360deg)}}\n',""]),e.exports=t},function(e,t,r){"use strict";e.exports=function(e){var t=[];return t.toString=function(){return this.map((function(t){var r=function(e,t){var r=e[1]||"",o=e[3];if(!o)return r;if(t&&"function"==typeof btoa){var n=(a=o,l=btoa(unescape(encodeURIComponent(JSON.stringify(a)))),d="sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(l),"/*# ".concat(d," */")),i=o.sources.map((function(e){return"/*# sourceURL=".concat(o.sourceRoot||"").concat(e," */")}));return[r].concat(i).concat([n]).join("\n")}var a,l,d;return[r].join("\n")}(t,e);return t[2]?"@media ".concat(t[2]," {").concat(r,"}"):r})).join("")},t.i=function(e,r){"string"==typeof e&&(e=[[null,e,""]]);for(var o=0;o0&&void 0!==arguments[0]?arguments[0]:{};if(!e.selector)return console.error("Smart Table init need a selector");var t=String(e.selector).trim(),r=(0,n.querySelector)(document,t);if(!r)return console.error("Smart Table "+t+" not found");var o=(0,n.querySelector)(r,"table");if(!o)return console.error("Smart Table init need a table");var a=(0,n.querySelector)(o,"thead");if(!a)return console.error("Smart Table init need a thead");var d=(0,n.querySelector)(o,"tbody");if(!d)return console.error("Smart Table init need a tbody");r.classList.add("smart-table"),e.size&&r.classList.add("stb-cust-"+e.size),e.align&&r.classList.add("stb-cust-"+e.align),(0,n.hasAttribute)(o,"stripe")&&d.classList.add("stripe"),e.expand?((0,n.querySelectorAll)(a,"th[sort]").forEach((function(e){(0,n.removeAttribute)(e,"sort")})),(0,n.querySelectorAll)(a,"th[fixed]").forEach((function(e){(0,n.removeAttribute)(e,"fixed")}))):((0,n.querySelectorAll)(d,"tr[expand]").forEach((function(e){(0,n.removeAttribute)(e,"expand")})),(0,n.querySelectorAll)(a,"tr[expand-parent]").forEach((function(e){(0,n.removeAttribute)(e,"expand-parent")}))),e.expandCallback&&(0,n.querySelectorAll)(a,"th[fixed]").forEach((function(e){(0,n.removeAttribute)(e,"fixed")}));var u=this;u.$root=r,u.$thead=a,u.$tbody=d,u.options=e,u.gutterWidth=(0,l.default)(),u.style={radioBgColor:e.radioBgColor||"#D1E7FF",hoverBgColor:e.hoverBgColor||"#EFF8FF"},u.size={},u.hasCheckbox=!e.expand&&"checkbox"===e.selection,u.hasExpandCb=!!e.expandCallback,u.hasExpandCb&&s(u),u.hasCheckbox&&c(u),x(u),f(u,o),e.expand||(m(u),(0,i.default)(u,a,d)),v(u,d),e.expand&&y(u,d),h(u);var p=(0,n.createElement)("th");(0,n.styled)(p,{display:"none"}),(0,n.setAttribute)(p,"width",u.gutterWidth),(0,n.setAttribute)(p,"rowspan",u.props.shapes.length),(0,n.appendChild)((0,n.querySelector)(u.$thead,"tr"),p),u.$scrollTH=p,u.scrollY&&((0,n.styled)(u.$scrollTH,{display:"table-cell"}),b(u))}};var o=d(r(9)),n=r(0),i=d(r(10)),a=r(1),l=d(r(11));function d(e){return e&&e.__esModule?e:{default:e}}function s(e){var t=e.$thead,r=e.$tbody,o=(0,n.querySelector)(t,"tr"),i=o.querySelector("th"),l=(0,a.createExpandTrigger)("th",(0,a.getAttrNumber)(i,"rowspan",1));(0,n.hasAttribute)(i,"fixed")&&(0,n.setAttribute)(l,"fixed"),(0,n.insertBefore)(o,l,i),(0,n.querySelectorAll)(r,"tr").forEach((function(e){var t=e.querySelector("td");(0,n.insertBefore)(e,(0,a.createExpandTrigger)("td",(0,a.getAttrNumber)(t,"rowspan",1)),t)}))}function c(e){var t=e.$thead,r=e.$tbody,o=(0,n.querySelector)(t,"tr"),i=o.querySelector("th"),l=(0,a.createCheckbox)("th",(0,a.getAttrNumber)(i,"rowspan",1));(0,n.hasAttribute)(i,"fixed")&&(0,n.setAttribute)(l,"fixed"),(0,n.insertBefore)(o,l,i),(0,n.querySelectorAll)(r,"tr").forEach((function(e){var t=e.querySelector("td");(0,n.insertBefore)(e,(0,a.createCheckbox)("td",(0,a.getAttrNumber)(t,"rowspan",1)),t)}))}function f(e,t){var r=e.$root,o=e.$thead,i=e.$tbody,l=e.options.height;(0,n.querySelectorAll)(o,"th").forEach((function(e){return(0,a.refactorCell)(e)})),(0,n.querySelectorAll)(i,"td").forEach((function(e){return(0,a.refactorCell)(e)})),u(e),e.$theadWrapper=(0,a.createTableWrapper)("stb_header-wrapper",e,"header",o),e.$tbodyWrapper=(0,a.createTableWrapper)("stb_body-wrapper",e,"body",i),(0,n.appendChildren)(r,[e.$theadWrapper,e.$tbodyWrapper]);var d=(0,n.offsetHeight)(o),s=("function"==typeof l?l.call():l)||(0,n.offsetHeight)(r),c=s>d?s-d-1:d+150;(0,n.styled)(e.$tbodyWrapper,{height:c+"px"}),e.size.tbodyWrapperHeight=c,e.scrollY=(0,n.offsetHeight)(e.$tbody)>c,(0,n.removeChild)(t.parentNode,t)}function u(e){var t=e.$root,r=e.props,o=(0,n.offsetWidth)(t)-1,i=o-(e.scrollY?e.gutterWidth:0),l=[],d=0;r.shapes.forEach((function(e){e.forEach((function(e,t){e&&(1===(0,a.getAttrNumber)(e,"colspan",1)&&(l[t]=(0,a.getAttrNumber)(e,"width",0)))}))}));var s=0;if(l.forEach((function(e){d+=e,0===e&&s++})),s){var c=Math.floor((i-d)/s),f=c>80?c:80,u=0;d=0,l=l.map((function(t,r){return 0===t&&(t=(e.hasCheckbox||e.hasExpandCb)&&0===r?55:f,u=r),d+=t,t})),i>d&&(l[u]=l[u]+i-d,d=i)}else d=l.reduce((function(e,t){return t+e}),0);e.colgroup=l,e.size.rootWidth=o,e.size.tableWidth=d,e.scrollX=e.size.tableWidth>e.size.rootWidth}function h(e){!function(e){e.$tbodyWrapper.addEventListener("scroll",(function(){return function(e){(0,a.throttle)(20,(function(){e.$theadWrapper.scrollLeft=e.$tbodyWrapper.scrollLeft,e.$fixedLeftBody&&(e.$fixedLeftBody.scrollTop=e.$tbodyWrapper.scrollTop),e.$fixedRightBody&&(e.$fixedRightBody.scrollTop=e.$tbodyWrapper.scrollTop)}))()}(e)}),{passive:!0})}(e),function(e){var t=e.options,r=t.selection,o=t.selectionKey;o=o||0,e.hasExpandCb&&o++;var i=(0,n.querySelector)(e.$fixedLeft||e.$thead,"th>.stb_cell>label.std-checkbox");[].concat(e.data,e.unsortData).forEach((function(t){g(e,t.$el,[t.$fixedLeftEl,t.$fixedRightEl]),t.$fixedLeftEl&&g(e,t.$fixedLeftEl,[t.$el,t.$fixedRightEl]),t.$fixedRightEl&&g(e,t.$fixedRightEl,[t.$el,t.$fixedLeftEl]);var a=t["field-"+o];if(r)switch(r){case"radio":p(e,t.$el,[t.$fixedLeftEl,t.$fixedRightEl],a),t.$fixedLeftEl&&p(e,t.$fixedLeftEl,[t.$el,t.$fixedRightEl],a),t.$fixedRightEl&&p(e,t.$fixedRightEl,[t.$el,t.$fixedLeftEl],a);break;case"checkbox":!function(e,t,r,o){var i=(0,n.querySelector)(t,"label.std-checkbox");if(!i||!r)return;i.addEventListener("click",(function(){var t=e.selected;t=t||[];var a=!(0,n.hasAttribute)(i,"checked");a?(0,n.setAttribute)(i,"checked",!0):(0,n.removeAttribute)(i,"checked"),a?t.push(o):t.splice(t.indexOf(o),1);var l=t.length;l?(0,n.setAttribute)(e.$root,"selected",JSON.stringify(t)):(0,n.removeAttribute)(e.$root,"selected"),l===e.data.length+e.unsortData.length?(0,n.setAttribute)(r,"checked",!0):(0,n.removeAttribute)(r,"checked"),e.selected=t}))}(e,t.$fixedLeftEl||t.$el,i,a)}e.hasExpandCb&&function(e,t,r,o){var i=this,a=e.options,l=(0,n.querySelector)(t,".expand-cell>.stb_cell");if(!l)return;l.addEventListener("click",(function(d){l.hasAttribute("loading")||(l.hasAttribute("open")?((0,n.removeAttribute)(l,"open"),(0,n.querySelectorAll)(e.$root,"tr.expand-"+r).forEach((function(e){(0,n.removeChild)(e.parentNode,e)}))):((0,n.setAttribute)(l,"loading",!0),a.expandCallback.call(i,{open:function(o,i){var a=(0,n.createElement)("td");(0,n.setAttribute)(a,"colspan",e.colgroup.length);var d=(0,n.createElement)("div","std-dialog_content");i?d.innerHTML=o:(0,n.appendChild)(d,o),(0,n.appendChild)(a,d);var s=(0,n.createElement)("tr","std-expand-row expand-"+r);(0,n.appendChild)(s,a),(0,n.insertBefore)(t.parentNode,s,t.nextSibling),(0,n.setAttribute)(l,"open"),(0,n.removeAttribute)(l,"loading")}},o)),d.stopPropagation())}))}(e,t.$fixedLeftEl||t.$el,t.$key,a)})),e.hasCheckbox&&function(e,t){if(!t)return;var r=e.options.selectionKey;t.addEventListener("click",(function(){var o=e.selected;o=[];var i=!(0,n.hasAttribute)(t,"checked");i?(0,n.setAttribute)(t,"checked",!0):(0,n.removeAttribute)(t,"checked"),[].concat(e.data,e.unsortData).forEach((function(e){var t=(0,n.querySelector)(e.$fixedLeftEl||e.$el,"label.std-checkbox");i?(0,n.setAttribute)(t,"checked",!0):(0,n.removeAttribute)(t,"checked"),i&&o.push(e["field-"+(r||0)])})),o.length?(0,n.setAttribute)(e.$root,"selected",JSON.stringify(o)):(0,n.removeAttribute)(e.$root,"selected"),e.selected=o}))}(e,i)}(e),e.options.expand?function(e){!function e(t){t.forEach((function(t){t.expand&&((0,n.querySelector)(t.$el,"td").addEventListener("click",(function(){!function e(t,r){r?(0,n.setAttribute)(t.$el,"expanded"):(0,n.removeAttribute)(t.$el,"expanded"),t.children&&t.children.forEach((function(t){(0,n.styled)(t.$el,{display:r?"":"none"}),e(t,r)}))}(t,!(0,n.hasAttribute)(t.$el,"expanded"))})),t.children&&e(t.children))}))}(e.expandData)}(e):function(e){var t=Array.from((0,n.querySelectorAll)(e.$root,"th[sort]"));if(0===t.length)return;t.forEach((function(r){r.addEventListener("click",(function(i){i.stopPropagation();var a="ASC",l=(0,n.getAttribute)(r,"sort")||"string";r.classList.contains("asc")?(r.classList.remove("asc"),r.classList.add("desc"),a="DESC"):(r.classList.remove("desc"),r.classList.add("asc")),t=t.map((function(e){return r!=e&&e.classList.remove("asc","desc"),e})),(0,n.querySelectorAll)(e.$root,"tr.std-expand-row").forEach((function(e){(0,n.removeChild)(e.parentNode,e)})),(0,n.querySelectorAll)(e.$root,".expand-cell>.stb_cell[open]").forEach((function(e){(0,n.removeAttribute)(e,"open")})),(0,n.querySelectorAll)(e.$root,".expand-cell>.stb_cell[loading]").forEach((function(e){(0,n.removeAttribute)(e,"loading")})),(0,o.default)(e,(0,n.getAttribute)(r,"sortkey"),a,l)}))}))}(e),function(e){window.addEventListener("resize",(function(){return b(e)}),{passive:!0})}(e)}function b(e){(0,a.debounce)(500,(function(){var t=e.props,r=t.fixedLeft,o=t.fixedRight;u(e),(0,a.replaceColGroup)(e),e.scrollY=(0,n.offsetHeight)(e.$tbody)>e.size.tbodyWrapperHeight,(0,n.styled)(e.$scrollTH,{display:e.scrollY?"table-cell":"none"});var i=(0,n.offsetHeight)(e.$root)-(e.scrollX?e.gutterWidth:2),l=(0,n.offsetHeight)(e.$thead)+(0,n.offsetHeight)(e.$tbody);i=l>i?i:l;var d=e.size.tbodyWrapperHeight-(e.scrollX?e.gutterWidth:0),s=(0,n.offsetHeight)(e.$thead),c=0,f=0;e.$fixedLeft&&r.thead.length&&(r.thead.forEach((function(t,r){c+=e.colgroup[r]})),(0,n.styled)(e.$fixedLeftBody,{height:d+"px",top:s+"px"}),(0,n.styled)(e.$fixedLeft,{width:c+"px",height:i+"px"})),e.$fixedRight&&o.thead.length&&(o.thead.forEach((function(t,r){f+=e.colgroup[e.colgroup.length-r-1]})),(0,n.styled)(e.$fixedRightBody,{height:d+"px",top:s+"px"}),(0,n.styled)(e.$fixedRight,{width:f+"px",height:i+"px",right:(e.scrollY?e.gutterWidth:0)+"px"}),(0,n.styled)(e.$rightPatch,{display:e.scrollY?"block":"none",height:(0,n.offsetHeight)(e.$thead)+"px"}))}))()}function p(e,t,r,o){t&&t.addEventListener("click",(function(){var i=e.selected,a=!1;(i!==o||(0,n.hasAttribute)(t,"checked"))&&(i!==o?((0,n.querySelectorAll)(e.$root,"tr[checked]>td").forEach((function(e){return(0,n.styled)(e,{background:""})})),(0,n.querySelectorAll)(e.$root,"tr[checked]").forEach((function(e){return(0,n.removeAttribute)(e,"checked")})),a=!0):(0,n.hasAttribute)(t,"checked")&&(a=!1),i=a?o:null,a?(0,n.setAttribute)(t,"checked",!0):(0,n.removeAttribute)(t,"checked"),t.querySelectorAll("td").forEach((function(t){(0,n.styled)(t,{background:a?e.style.radioBgColor:""})})),r.forEach((function(t){t&&(a?(0,n.setAttribute)(t,"checked",!0):(0,n.removeAttribute)(t,"checked"),t.querySelectorAll("td").forEach((function(t){(0,n.styled)(t,{background:a?e.style.radioBgColor:""})})))})),a?(0,n.setAttribute)(e.$root,"selected",JSON.stringify(i)):(0,n.removeAttribute)(e.$root,"selected"),e.selected=i)}))}function g(e,t,r){t&&(t.addEventListener("mouseenter",(function(){(0,n.styled)(t,{background:e.style.hoverBgColor}),r.forEach((function(t){t&&(0,n.styled)(t,{background:e.style.hoverBgColor})}))})),t.addEventListener("mouseleave",(function(){(0,n.styled)(t,{background:""}),r.forEach((function(e){e&&(0,n.styled)(e,{background:""})}))})))}function x(e){var t={},r=[];(0,n.querySelectorAll)(e.$thead,"tr").forEach((function(e,t){var o=r[t]||[];(0,n.querySelectorAll)(e,"th").forEach((function(e){var i=(0,a.getAttrNumber)(e,"rowspan",1),l=(0,a.getAttrNumber)(e,"colspan",1),d=(0,a.getEmptyIndexInArray)(o)||o.length;if(o[d]=e,(0,n.hasAttribute)(e,"sort")&&(0,n.setAttribute)(e,"sortkey","field-"+d),l>1)for(var s=1;s1)for(var c=1;cth"),s=d.length,c=0;if(0!==s){if((0,n.hasAttribute)(d[0],"fixed"))for(var f=0;f0&&(0,n.hasAttribute)(d[p],"fixed")&&p!==c;p--){l.thead.push("field-"+p);for(var g=(0,a.getAttrNumber)(d[p],"colspan",1),x=0;xt}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t,r){var n=320,d=e.props,s=d.fixedLeft,c=d.fixedRight;if(s.thead.length>0){n=n>s.width?n:s.width;var f=i(e,t,s),u=a(e,r,s,"left");e.$fixedLeft=l(e,f,u,s,"stb_fixed","left"),(0,o.appendChild)(e.$root,e.$fixedLeft),e.$fixedLeftBody=u}if(c.thead.length>0){n+=c.width;var h=i(e,t,c),b=a(e,r,c,"right");e.$fixedRight=l(e,h,b,c,"stb_fixed-right","right"),(0,o.appendChild)(e.$root,e.$fixedRight),e.$fixedRightBody=b;var p=(0,o.createElement)("div","stb_fixed-right-patch");(0,o.styled)(p,{display:"none",width:e.gutterWidth+"px",height:(0,o.offsetHeight)(e.$thead)+"px"}),(0,o.appendChild)(e.$root,p),e.$rightPatch=p,e.scrollY&&(0,o.styled)(e.$rightPatch,{display:"block"})}(0,o.styled)(e.$root,{minWidth:n+"px"})};var o=r(0),n=r(1);function i(e,t,r){var i=(0,o.cloneNode)(t,!0);return(0,o.querySelectorAll)(i,"tr:first-child>th").forEach((function(e,t){-1===r.thead.indexOf("field-"+t)&&e.classList.add("is-hidden")})),(0,n.createTableWrapper)("stb_fixed-header-wrapper",e,"header",i)}function a(e,t,r,i){var a=(0,o.cloneNode)(t,!0);(0,o.querySelectorAll)(a,"tr").forEach((function(e){var t=-1;(0,o.querySelectorAll)(e,"td").forEach((function(e,o){"left"===i?t=o:t+=(0,n.getAttrNumber)(e,"colspan",1),-1===r.tbody.indexOf("field-"+t)&&e.classList.add("is-hidden")}))}));var l=(0,n.createTableWrapper)("stb_fixed-body-wrapper",e,"body",a);return(0,o.styled)(l,{top:(0,o.offsetHeight)(e.$thead)+"px",height:e.size.tbodyWrapperHeight-(e.scrollX?e.gutterWidth:0)+"px"}),l}function l(e,t,r,n,i,a){var l=(0,o.createElement)("div",i);(0,o.appendChildren)(l,[t,r]);var d=(0,o.offsetHeight)(e.$root)-(e.scrollX?e.gutterWidth:2),s=(0,o.offsetHeight)(e.$thead)+(0,o.offsetHeight)(e.$tbody);return(0,o.styled)(l,{width:n.width+"px",height:(s>d?d:s)+"px",right:"right"===a?(e.scrollY?e.gutterWidth:0)+"px":""}),l}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(){if(void 0!==n)return n;var e=(0,o.createElement)("div","smart-table");(0,o.appendChild)(document.body,e);var t=(0,o.createElement)("div");(0,o.styled)(t,{visibility:"hidden",width:"100px",position:"absolute",top:"-9999px"}),(0,o.appendChild)(e,t);var r=(0,o.offsetWidth)(t);(0,o.styled)(t,{overflow:"scroll"});var i=(0,o.createElement)("div");(0,o.styled)(i,{width:"100%"}),(0,o.appendChild)(t,i);var a=(0,o.offsetWidth)(i);return(0,o.removeChild)(e.parentNode,e),n=r-a};var o=r(0),n=void 0}]); +//# sourceMappingURL=smartTable.min.js.map \ No newline at end of file diff --git a/dist/smartTable.min.js.map b/dist/smartTable.min.js.map new file mode 100644 index 0000000..2dfe853 --- /dev/null +++ b/dist/smartTable.min.js.map @@ -0,0 +1 @@ +{"version":3,"file":"smartTable.min.js","sources":["webpack:///smartTable.min.js"],"mappings":"AACA","sourceRoot":""} \ No newline at end of file diff --git a/lib/core/core.js b/lib/core/core.js index 98a98a5..c858205 100644 --- a/lib/core/core.js +++ b/lib/core/core.js @@ -174,6 +174,7 @@ function layout(vm, table) { height: tbodyWrapperHeight + "px" }) + vm.size.tbodyWrapperHeight = tbodyWrapperHeight; //垂直方向是否有滚动条 @@ -667,25 +668,28 @@ function initExpand(vm, tbody) { const expandAll = vm.options.defaultExpandAll; let data = []; let parents = []; + let parentIds = []; querySelectorAll(tbody, "tr").forEach(row => { let paddingLength = parents.length; let expand = hasAttribute(row, "expand"); let hasParent = hasAttribute(row, "expand-parent"); + let expandParentId = getAttribute(row, "expand-parent"); + if (parentIds.indexOf(expandParentId) === -1) { + hasParent = false; + } let node = { $el: row, id: getAttribute(row, "expand"), expand: expand }; if (expand) { - if (expandAll) { - setAttribute(row, 'expanded') - } else { - removeAttribute(row, 'expanded') - } + expandAll ? setAttribute(row, 'expanded') : removeAttribute(row, 'expanded'); } + if (expand && !hasParent) { node.children = []; parents = [node]; + parentIds.push(node.id) data.push(node); } else if (hasParent) { let parentId = getAttribute(row, "expand-parent"); @@ -702,6 +706,7 @@ function initExpand(vm, tbody) { parent && parent.children.push(node); if (expand) { parents.push(node) + parentIds.push(node.id) node.children = []; } } else { @@ -720,6 +725,9 @@ function initExpand(vm, tbody) { styled(vm.$tbodyWrapper, { height: '' }) + styled(vm.$tbodyWrapper, { + maxHeight: vm.size.tbodyWrapperHeight + 'px' + }) } function initData(vm, tbody) { diff --git a/package.json b/package.json index ce9d00d..01cce52 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "smart-table", - "version": "1.2.2", + "version": "1.2.3", "description": "smart table for static html", "main": "index.js", "scripts": {