vue-quokit 0.1.9 → 0.1.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  (function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode(".qukt-toolbar{display:flex;align-items:center;gap:10px;margin-bottom:12px;flex-wrap:wrap}.qukt-tip{color:#909399;font-size:13px;margin-right:auto}.qukt-tip code{background:#f5f7fa;padding:1px 6px;border-radius:3px}.qukt-btn-group-inline{display:flex;gap:6px}.qukt-btn{padding:6px 14px;border:1px solid #dcdfe6;border-radius:4px;background:#fff;cursor:pointer;font-size:13px}.qukt-btn:hover{border-color:#409eff;color:#409eff}.qukt-btn-primary{background:#409eff;border-color:#409eff;color:#fff}.qukt-btn-primary:hover{background:#66b1ff;color:#fff}.qukt-btn-ghost{background:transparent;border:1px dashed #dcdfe6;color:#909399;margin-top:8px}.qukt-mini-btn{background:transparent;border:1px solid #dcdfe6;border-radius:3px;padding:2px 8px;cursor:pointer;font-size:12px;margin-right:3px}.qukt-mini-btn:hover{border-color:#409eff;color:#409eff}.qukt-mini-btn:disabled{opacity:.3;cursor:not-allowed}.qukt-mini-btn.danger:hover{border-color:#f56c6c;color:#f56c6c}.qukt-muted{color:#c0c4cc;font-size:12px}.qukt-cell-input{flex:1;width:100%;border:1px solid #dcdfe6;border-radius:3px;padding:4px 8px;font-size:13px;outline:none;min-width:0;box-sizing:border-box}.qukt-cell-input:focus{border-color:#409eff}.qukt-cell-input.small{flex:0 0 160px;max-width:100%}.qukt-cell-input.tiny{width:56px;height:22px;font-size:11px;padding:0 4px;flex:none}.qukt-color-input{width:24px;height:22px;border:1px solid #dcdfe6;border-radius:3px;padding:0;cursor:pointer;background:#fff}.qukt-chk-label{font-size:12px;color:#606266;display:inline-flex;align-items:center;gap:3px;flex-shrink:0}.qukt-designer{padding:0;display:flex;flex-direction:column;height:100%;min-height:0}.qukt-tabs{display:flex;gap:0;border-bottom:2px solid #ebeef5;margin-bottom:16px;flex-shrink:0}.qukt-tab{padding:10px 20px;cursor:pointer;font-size:14px;color:#909399;border-bottom:2px solid transparent;margin-bottom:-2px;transition:all .2s}.qukt-tab:hover{color:#409eff}.qukt-tab.active{color:#409eff;border-bottom-color:#409eff;font-weight:600}.qukt-tab-content{padding:10px 0;flex:1;min-height:0;display:flex;flex-direction:column;overflow:hidden}.qukt-tab-content>*{flex:1;min-height:0;display:flex;flex-direction:column}.qukt-tab-content-preview{overflow-y:auto}.qukt-tab-content-preview>*{flex:none;min-height:0}.qukt-page{padding:20px;background:#fff;border-radius:8px;height:100%;overflow-y:auto}.qukt-empty-tip{text-align:center;padding:60px 20px;background:#fafbfc;border:2px dashed #dcdfe6;border-radius:8px}.qukt-empty-icon{font-size:48px;margin-bottom:12px}.qukt-empty-text{color:#909399;font-size:14px;margin-bottom:16px}.qukt-data-table{border:1px solid #ebeef5;border-radius:6px;overflow:hidden;margin-bottom:16px}.qukt-main-table{width:100%;border-collapse:collapse;font-size:13px}.qukt-main-table th{background:#f5f7fa;padding:10px 12px;text-align:left;font-weight:600;color:#303133;border:1px solid #ebeef5}.qukt-main-table td{padding:10px 12px;border:1px solid #ebeef5;color:#606266}.qukt-main-table tbody tr{cursor:pointer;transition:background .15s}.qukt-main-table tbody tr:hover{background:#f5f7fa}.qukt-subtotal{color:#67c23a;font-weight:500;text-align:right;display:block}.qukt-op-cell{white-space:nowrap}.qukt-row-btn{background:none;border:none;cursor:pointer;font-size:13px;color:#409eff;margin-right:10px;padding:2px 4px;border-radius:3px}.qukt-row-btn:hover{text-decoration:underline}.qukt-row-btn.danger{color:#f56c6c}.qukt-de-mask,.qukt-gr-mask{position:fixed;top:0;right:0;bottom:0;left:0;background:#00000080;display:flex;align-items:center;justify-content:center;z-index:1000}.qukt-de-dialog{background:#fff;border-radius:10px;width:420px;max-width:92vw;max-height:86vh;display:flex;flex-direction:column;box-shadow:0 10px 40px #00000040}.qukt-de-header{padding:16px 20px;border-bottom:1px solid #ebeef5;display:flex;justify-content:space-between;align-items:center;font-size:15px;font-weight:600;color:#303133;flex-shrink:0}.qukt-de-close{border:none;background:transparent;cursor:pointer;font-size:16px;color:#909399}.qukt-de-close:hover{color:#f56c6c}.qukt-de-content{padding:16px 20px;flex:1;overflow-y:auto}.qukt-de-footer{padding:12px 20px;border-top:1px solid #ebeef5;text-align:right;flex-shrink:0}.qukt-form-grid{display:grid;grid-template-columns:1fr 1fr;gap:12px}.qukt-form-cell.full{grid-column:1 / -1}.qukt-form-cell-label{display:block;font-size:13px;color:#606266;margin-bottom:6px}.qukt-gr-dialog{width:380px;background:#fff;border-radius:8px;box-shadow:0 8px 28px #0003}.qukt-gr-header{padding:12px 16px;border-bottom:1px solid #ebeef5;display:flex;justify-content:space-between;align-items:center;font-size:15px;font-weight:600;color:#303133}.qukt-gr-close{border:none;background:transparent;cursor:pointer;font-size:16px;color:#909399}.qukt-gr-close:hover{color:#f56c6c}.qukt-gr-content{padding:14px 16px;max-height:70vh;overflow-y:auto}.qukt-gr-footer{padding:10px 16px;border-top:1px solid #ebeef5;text-align:right}.qukt-gr-tips{background:#ecf5ff;border:1px solid #d9ecff;border-radius:6px;padding:8px 10px;margin-bottom:14px}.qukt-gr-tips p{font-size:12px;color:#606266;margin:4px 0;line-height:1.6}.qukt-gr-tips code{background:#fff;padding:1px 6px;border-radius:3px;font-size:11px}.qukt-gr-form{display:flex;flex-direction:column;gap:10px}.qukt-gr-form-row{display:flex;align-items:center;gap:10px}.qukt-gr-form-label{width:80px;text-align:right;font-size:12px;color:#606266;flex-shrink:0}.qukt-table-wrap{width:100%;overflow:auto;flex:1;min-height:0}.qukt-design-table{width:100%;min-width:var(--qukt-cols-min-width, 960px);border-collapse:collapse;font-size:13px}.qukt-design-table--fixed{table-layout:fixed;width:auto;border-collapse:collapse;font-size:13px}.qukt-design-table th,.qukt-design-table td,.qukt-design-table--fixed th,.qukt-design-table--fixed td{border:1px solid #ebeef5;padding:6px 8px;text-align:center}.qukt-design-table th,.qukt-design-table--fixed th{background:#f5f7fa;font-weight:600;color:#303133}.qukt-design-table td.idx,.qukt-design-table--fixed td.idx{color:#909399;background:#fafbfc;width:50px;text-align:center}.qukt-design-table tbody tr:hover,.qukt-design-table--fixed tbody tr:hover{background:#fafbfc}.qukt-col-merge label{display:flex;align-items:center;gap:4px;font-size:12px;cursor:pointer}.qukt-title-group{display:flex;gap:2px;align-items:center}.qukt-title-group .qukt-cell-input{min-width:0}.qukt-title-group .pref-suf{flex:0 0 36px;max-width:48px;background:#fafbfc;font-size:12px;color:#606266}.qukt-title-group .pref-suf::placeholder{color:#c0c4cc;font-size:11px}.qukt-quote-sheet{background:#fff;padding:32px 40px;border-radius:4px}.qukt-q-title{margin:0 0 12px;font-size:18px;font-weight:700;color:#303133;text-align:center}.qukt-q-divider{border-top:1px solid #dcdfe6;margin:10px 0}.qukt-q-text{margin:4px 0;font-size:13px;color:#606266}.qukt-q-row{display:flex;margin-bottom:4px}.qukt-q-cell{padding:8px 12px;font-size:13px;background:#fff;box-sizing:border-box}.qukt-q-label{color:#909399}.qukt-q-value{color:#303133;font-weight:500}.qukt-q-table-wrap{margin-top:10px}.qukt-q-table{width:100%;border-collapse:collapse;font-size:13px}.qukt-q-table th{background:#f5f7fa;padding:10px 12px;border:1px solid #dcdfe6;text-align:center;font-weight:600;color:#303133;white-space:pre-wrap}.qukt-q-table td{padding:9px 12px;border:1px solid #dcdfe6;color:#606266;text-align:center;vertical-align:middle;white-space:pre-wrap}.qukt-q-table td.merged-cell{background:#fafbfc;font-weight:500}.qukt-q-table tr.subtotal-row td.subtotal-label{background:#f0f9ff;color:#409eff;font-weight:600;text-align:right;padding-right:16px;font-style:italic;white-space:pre}.qukt-q-table tr.subtotal-row td.subtotal-value{background:#f0f9ff;color:#409eff;font-weight:600;text-align:right;white-space:pre}.qukt-q-empty{text-align:center;padding:30px;color:#c0c4cc;font-size:14px}.qukt-q-summary{margin-top:10px;margin-left:auto;width:320px}.qukt-q-summary-row{display:flex;justify-content:space-between;padding:6px 0;border-bottom:1px dashed #ebeef5;font-size:13px}.qukt-q-summary-label{color:#606266}.qukt-q-summary-value{font-variant-numeric:tabular-nums;white-space:pre}.qukt-q-footer{margin-top:10px}.qukt-help-modal{position:fixed;top:0;left:0;right:0;bottom:0;background:#00000073;z-index:9999;display:flex;align-items:center;justify-content:center}.qukt-help-dialog{background:#fff;border-radius:10px;width:780px;max-width:92vw;max-height:86vh;display:flex;flex-direction:column;box-shadow:0 10px 40px #00000040}.qukt-help-header{padding:16px 24px;border-bottom:1px solid #ebeef5;display:flex;justify-content:space-between;align-items:center}.qukt-help-header h3{margin:0;font-size:17px;color:#303133}.qukt-close-btn{background:transparent;border:none;font-size:20px;cursor:pointer;color:#909399;padding:4px 10px;border-radius:4px}.qukt-close-btn:hover{background:#f5f7fa;color:#303133}.qukt-help-body{padding:20px 28px 28px;overflow-y:auto;font-size:13px;color:#606266;line-height:1.7}.qukt-help-section{margin-bottom:24px}.qukt-help-section h4{font-size:15px;color:#409eff;margin:0 0 10px;padding-bottom:6px;border-bottom:1px dashed #dcdfe6}.qukt-help-section p{margin:6px 0}.qukt-help-section ul,.qukt-help-section ol{margin:6px 0 6px 22px;padding:0}.qukt-help-section li{margin:3px 0}.qukt-help-section code{background:#f0f2f5;color:#d63384;padding:1px 6px;border-radius:3px;font-size:12px;font-family:Consolas,monospace}.qukt-help-section pre.code{background:#f5f7fa;border:1px solid #ebeef5;border-radius:5px;padding:10px 14px;overflow-x:auto;font-size:12px;font-family:Consolas,Monaco,monospace;line-height:1.55;margin:8px 0;color:#495057}.qukt-help-table{width:100%;border-collapse:collapse;margin:10px 0;font-size:12.5px}.qukt-help-table th,.qukt-help-table td{border:1px solid #ebeef5;padding:7px 10px;text-align:left}.qukt-help-table th{background:#f5f7fa;font-weight:600;color:#303133}.qukt-help-table td:first-child{white-space:nowrap;font-weight:500}.qukt-tip-box{background:#ecf5ff;border-left:3px solid #409eff;padding:8px 14px;border-radius:3px;color:#606266;margin:10px 0;font-size:12.5px}.qukt-tip-box.final-tip{background:#f0f9eb;border-left-color:#67c23a;font-size:13px;padding:14px 18px}.qukt-steps{padding-left:22px}.qukt-steps li{margin-bottom:4px}.qukt-two-col{display:flex;gap:16px;flex:1;min-height:0;overflow:hidden}.qukt-col-left{flex:1;min-width:0;overflow-y:auto;padding-right:4px}.qukt-col-right{width:360px;flex-shrink:0;overflow-y:auto;max-height:100%}.qukt-two-col.is-narrow{flex-direction:column;overflow-y:auto}.qukt-two-col.is-narrow .qukt-col-right{width:100%;flex-shrink:0;overflow:visible}.qukt-two-col.is-narrow .qukt-col-left{overflow:visible}.qukt-sec-block{border:1px solid #ebeef5;border-radius:6px;padding:12px;margin-bottom:10px;background:#fafbfc}.qukt-sec-block--divider .qukt-sec-header{margin-bottom:0}.qukt-sec-header{display:flex;justify-content:space-between;align-items:center;margin-bottom:10px}.qukt-sec-type{font-size:13px;font-weight:600;color:#409eff;background:#ecf5ff;padding:2px 8px;border-radius:3px}.qukt-sec-actions{display:flex;gap:2px}.qukt-sec-row{display:flex;align-items:center;gap:6px;margin-bottom:6px;flex-wrap:wrap}.qukt-sec-row label,.qukt-sec-row .label{font-size:12px;color:#606266;min-width:54px;flex-shrink:0}.qukt-inline-group{display:inline-flex;align-items:center;gap:6px;flex-shrink:0}.qukt-cells-list{display:flex;flex-direction:column;gap:8px}.qukt-cell-block{border:1px dashed #dcdfe6;border-radius:4px;padding:8px;background:#fff}.qukt-cell-toolbar{display:flex;justify-content:space-between;align-items:center;margin-bottom:6px;font-size:12px;color:#909399}.qukt-border-config{flex-wrap:wrap}.qukt-border-config>.label{width:100%;margin-bottom:4px}.qukt-border-group{display:flex;flex-wrap:wrap;gap:4px;flex:1}.qukt-border-item{display:flex;align-items:center;gap:2px;padding:2px 4px;background:#f8f9fb;border-radius:3px;font-size:11px;color:#606266}.qukt-border-item>span{min-width:12px;text-align:center}.qukt-border-config .qukt-mini-btn{margin-left:4px}.qukt-preview-box{border:1px solid #dcdfe6;border-radius:6px;overflow:hidden;background:#fff;top:20px}.qukt-preview-label{padding:8px 12px;background:#f5f7fa;font-size:13px;font-weight:600;color:#606266;border-bottom:1px solid #ebeef5}.qukt-preview-inner{padding:14px}.qukt-p-title{margin:6px 0 10px}.qukt-p-divider{height:1px;background:#dcdfe6;margin:8px 0}.qukt-p-text{margin:4px 0}.qukt-p-row{display:flex;margin-bottom:6px}.qukt-p-cell{padding:6px 10px;background:#fff}.qukt-p-label{opacity:.8}.qukt-p-bind-placeholder{opacity:.7}.qukt-empty-hint{text-align:center;padding:20px;color:#c0c4cc;font-size:13px}.qukt-preview-title{font-size:13px;font-weight:600;color:#606266;margin:0 0 10px}.qukt-summary-preview{border:1px solid #ebeef5;border-radius:6px;padding:12px;background:#fff}.qukt-sp-row{display:flex;justify-content:space-between;align-items:center;padding:6px 0;font-size:13px}.qukt-sp-label{color:#606266}.qukt-sp-value{font-weight:500;font-size:12px;white-space:pre}.qukt-preview-help{margin-top:12px;padding:10px 12px;background:#f4f4f5;border-radius:6px;font-size:12px;color:#909399;line-height:1.8}.qukt-preview-help b{color:#606266}.qukt-preview-help code{background:#e9e9eb;padding:1px 5px;border-radius:3px;color:#606266;font-family:monospace}.qukt-bind-section{margin-bottom:16px;background:#f4f9ff;border:1px solid #dbe8fb;border-radius:8px;padding:14px 16px}.qukt-bind-title{font-size:13px;font-weight:600;color:#409eff;margin-bottom:10px}.qukt-bind-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(220px,1fr));gap:10px 16px}.qukt-bind-item{display:flex;flex-direction:row;align-items:center;gap:8px}.qukt-bind-label{font-size:12px;color:#606266;font-weight:500;white-space:nowrap;min-width:60px;flex-shrink:0}.qukt-bind-item .qukt-cell-input{flex:1}.qukt-preview-mask[data-v-8a922e81]{position:fixed;top:0;right:0;bottom:0;left:0;background:#00000073;display:flex;align-items:flex-start;justify-content:center;padding:40px 24px;overflow-y:auto;z-index:9999}.qukt-preview-box[data-v-8a922e81]{width:min(1100px,96vw);background:#fff;border-radius:8px;display:flex;flex-direction:column;box-shadow:0 10px 40px #0000002e}.qukt-preview-header[data-v-8a922e81]{display:flex;justify-content:space-between;align-items:center;padding:12px 16px;border-bottom:1px solid #ebeef5;flex-shrink:0}.qukt-preview-title[data-v-8a922e81]{font-size:15px;font-weight:600;color:#303133}.qukt-preview-close[data-v-8a922e81]{cursor:pointer;color:#909399;font-size:16px;padding:2px 6px;border-radius:3px}.qukt-preview-close[data-v-8a922e81]:hover{background:#f5f7fa;color:#f56c6c}.qukt-preview-body[data-v-8a922e81]{padding:20px;background:#f5f7fa;max-height:75vh;overflow:auto}.qukt-preview-footer[data-v-8a922e81]{display:flex;justify-content:flex-end;gap:8px;flex-wrap:wrap;padding:10px 16px;border-top:1px solid #ebeef5;flex-shrink:0}.tool-btn[data-v-8a922e81]{padding:7px 14px;border:1px solid #dcdfe6;border-radius:4px;background:#fff;cursor:pointer;font-size:13px;color:#606266;transition:all .15s}.tool-btn[data-v-8a922e81]:hover{border-color:#409eff;color:#409eff}.qukt-preview-json-mask[data-v-8a922e81]{position:fixed;top:0;right:0;bottom:0;left:0;background:#00000073;display:flex;align-items:center;justify-content:center;z-index:10000}.qukt-preview-json-box[data-v-8a922e81]{width:min(720px,92vw);max-height:80vh;background:#fff;border-radius:8px;display:flex;flex-direction:column;box-shadow:0 10px 40px #0000002e}.qukt-preview-json-body[data-v-8a922e81]{flex:1;overflow:auto;margin:0;padding:14px 16px;background:#1e1e1e;color:#d4d4d4;font-family:Consolas,Monaco,Courier New,monospace;font-size:12.5px;line-height:1.6;white-space:pre}")),document.head.appendChild(e)}}catch(t){console.error("vite-plugin-css-injected-by-js",t)}})();
2
2
  (function(R,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue"),require("exceljs")):typeof define=="function"&&define.amd?define(["exports","vue","exceljs"],e):(R=typeof globalThis<"u"?globalThis:R||self,e(R.VueQuokit={},R.Vue,R.ExcelJS))})(this,function(R,e,He){"use strict";function G(t,o){if(!t)return 0;const l=String(t).replace(/\s+/g,"");if(!l)return 0;let a=0;function k(){return l[a]}function p(){return l[a++]}function m(d){if(k()!==d)throw new Error("公式解析错误: 期望 "+d+" at "+a);a++}function N(){const d=k();if(d==="("){p();const f=q();return m(")"),f}if(d==="-")return p(),-N();if(d==="+")return p(),N();if(d>="0"&&d<="9"||d==="."){let f="";for(;a<l.length&&(l[a]>="0"&&l[a]<="9"||l[a]===".");)f+=l[a++];return parseFloat(f)}if(d>="a"&&d<="z"||d>="A"&&d<="Z"||d==="_"){let f="";for(;a<l.length&&(l[a]>="a"&&l[a]<="z"||l[a]>="A"&&l[a]<="Z"||l[a]==="_"||l[a]>="0"&&l[a]<="9");)f+=l[a++];return Number(o[f]||0)}throw new Error('公式解析错误: 非法字符 "'+d+'" at '+a)}function g(){let d=N();for(;a<l.length&&(k()==="*"||k()==="/");){const f=p(),V=N();d=f==="*"?d*V:V===0?0:d/V}return d}function q(){let d=g();for(;a<l.length&&(k()==="+"||k()==="-");){const f=p(),V=g();d=f==="+"?d+V:d-V}return d}try{const d=q();return Math.round(d*100)/100}catch{return 0}}const W={AUTO_SEQ:{value:"AUTO_SEQ",label:"自动序号",defaultWidth:60,defaultTitle:"序号",defaultFieldBase:"seq",hasDict:!1,hasFormula:!1,canMerge:!1,editable:!1},AUTO_CALC:{value:"AUTO_CALC",label:"公式计算",defaultWidth:120,defaultTitle:"计算值",defaultFieldBase:"subtotal",hasDict:!1,hasFormula:!0,canMerge:!1,editable:!1},INPUT:{value:"INPUT",label:"文本输入",defaultWidth:130,defaultTitle:"文本",defaultFieldBase:"custom",hasDict:!1,hasFormula:!1,canMerge:!0,editable:!0},NUMBER:{value:"NUMBER",label:"数字输入",defaultWidth:100,defaultTitle:"数值",defaultFieldBase:"custom",hasDict:!1,hasFormula:!1,canMerge:!0,editable:!0},TEXTAREA:{value:"TEXTAREA",label:"多行文本",defaultWidth:200,defaultTitle:"说明",defaultFieldBase:"custom",hasDict:!1,hasFormula:!1,canMerge:!0,editable:!0},SELECT_DICT:{value:"SELECT_DICT",label:"下拉选择",defaultWidth:130,defaultTitle:"选项",defaultFieldBase:"custom",hasDict:!0,defaultDictStr:"选项1,选项2",hasFormula:!1,canMerge:!0,editable:!0}};Object.keys(W).map(t=>W[t].value);function I(t){return W[t]||W.INPUT}const H={MANUAL_INPUT:{value:"MANUAL_INPUT",label:"手动数值",hasDefault:!0,hasFormula:!1,hasText:!1},AUTO_CALC:{value:"AUTO_CALC",label:"自动计算",hasDefault:!1,hasFormula:!0,hasText:!1},PLAIN_TEXT:{value:"PLAIN_TEXT",label:"纯文本",hasDefault:!1,hasFormula:!1,hasText:!0}};Object.keys(H).map(t=>H[t].value);function j(t){return H[t]||H.MANUAL_INPUT}const ye={TEXT:{value:"text",label:"纯文本"},ROW:{value:"row",label:"表格行"},DIVIDER:{value:"divider",label:"分割线"}};Object.keys(ye).map(t=>ye[t].value);const te={FIELD:{value:"field",label:"绑定字段"},TEXT:{value:"text",label:"纯文本"},IMAGE:{value:"image",label:"图片"}};Object.keys(te).map(t=>te[t].value);function J(t){let o="";for(;t>=0;)o=String.fromCharCode(65+t%26)+o,t=Math.floor(t/26)-1;return o}function Ee(t){return typeof t=="string"?parseFloat(t)/100:0}const le={style:"thin",color:{argb:"FFDCDFE6"}},oe={style:"medium",color:{argb:"FF606266"}},ge=11;function Ve(t){if(!t)return null;const o=t.replace("#","").toUpperCase();return o.length===6?"FF"+o:o}function Ne(t,o){if(!o)return;const l={name:"微软雅黑"};if(o.fontSize&&(l.size=o.fontSize),o.bold&&(l.bold=!0),o.italic&&(l.italic=!0),o.color){const a=Ve(o.color);a&&(l.color={argb:a})}if(t.font=l,o.align&&(t.alignment={horizontal:o.align,vertical:"middle",wrapText:!0,indent:1}),o.border){const a={};for(const k of["top","bottom","left","right"]){const p=o.border[k];if(p&&p.style&&p.width>0){const m=Ve(p.color)||"FFDCDFE6";let N=p.style;N==="solid"&&(N="thin"),a[k]={style:N,color:{argb:m}}}}Object.keys(a).length>0&&(t.border=a)}}function _e(t){if(t==null)return 0;if(typeof t=="number")return String(t).length;const o=String(t);let l=0;for(const a of o)a!==`
3
3
  `&&(/[\u4e00-\u9fa5\u3000-\u303f\uff00-\uffef\u2e80-\u2fdf\u31c0-\u31ef]/.test(a)?l+=2:l+=1);return l}function qe(t,o=11){let l=1;for(const p of t){const m=String(p??""),N=m.split(`
4
- `).length,g=_e(m),d=m.length===0?1:Math.ceil(g/12);l=Math.max(l,N,d)}const a=o+8;return Math.max(50,l*a+16*2)}function we(t,o,l,a,k){for(let p=o;p<=l;p++)for(let m=a;m<=k;m++){const N=t.getCell(p,m),g=N.border||{};N.border={top:g.top||le,left:g.left||le,right:g.right||le,bottom:g.bottom||le}}}function Be(t,o,l,a,k){for(let p=a;p<=k;p++)t.getCell(o,p).border={...t.getCell(o,p).border||{},top:oe},t.getCell(l,p).border={...t.getCell(l,p).border||{},bottom:oe};for(let p=o;p<=l;p++)t.getCell(p,a).border={...t.getCell(p,a).border||{},left:oe},t.getCell(p,k).border={...t.getCell(p,k).border||{},right:oe}}function xe(t,o){return t.bindEnabled&&t.bindField?o[t.bindField]??"":t.text??""}function $e(t,o){const l=t.type===te.FIELD.value&&t.label&&!t.hideLabel;if(t.bindEnabled&&t.bindField){const a=o[t.bindField]??"";return l?t.label+a:a}return t.type===te.FIELD.value?(l?t.label:"")+(t.value??""):t.text??""}async function Ye(t,o,l={}){var E;if(!t||!Array.isArray(t.columns)||t.columns.length===0)throw new Error("模板为空或缺少列定义");const a=(o==null?void 0:o.headerData)||{},k=(o==null?void 0:o.footerData)||{};let p=(o==null?void 0:o.rows)||o||[];Array.isArray(p)||(p=[]);const m=l.layout||"auto-wrap",N=m==="auto-wrap",g=new He.Workbook,q=g.addWorksheet("报价单"),d=t.columns.length,f=J(d-1);let V=1;const U=()=>(t.columns||[]).find(r=>I(r.editor).hasFormula),A=r=>{const u=U(),y=(u==null?void 0:u.formula)||"quantity * unit_price";return G(y,r)};if(t.header_sections){for(const r of t.header_sections)if(r.type==="divider")V++;else if(r.type==="text"){q.mergeCells(`A${V}:${f}${V}`);const u=q.getCell(`A${V}`);u.value=xe(r,a);const y=r.style||{},_=y.fontSize||13;if(u.font={size:_,bold:y.bold===!0,italic:y.italic===!0,name:"微软雅黑"},y.color){const w=y.color.replace("#","").toUpperCase();u.font.color={argb:w.length===6?"FF"+w:w}}u.alignment={horizontal:y.align||"left",vertical:"middle"},q.getRow(V).height=_*2+10,V++}else if(r.type==="row"&&r.cells){const u=r.cells.map(w=>{var B;return Ee((B=w.style)==null?void 0:B.width)||1/r.cells.length});let y=0;const _=u.map(w=>{const B=Math.round(y*d);y+=w;const D=Math.round(y*d)-1;return{start:B,end:Math.max(D,B)}});for(let w=0;w<r.cells.length;w++){const B=r.cells[w],D=_[w],S=`${J(D.start)}${V}`,z=`${J(D.end)}${V}`;S!==z&&q.mergeCells(`${S}:${z}`);const M=q.getCell(S);M.value=$e(B,a);const C=B.style||{},O=C.fontSize||11;if(M.font={size:O,bold:C.bold===!0,italic:C.italic===!0,name:"微软雅黑"},C.color){const F=C.color.replace("#","").toUpperCase();M.font.color={argb:F.length===6?"FF"+F:F}}M.alignment={horizontal:C.align||"left",vertical:"middle"}}q.getRow(V).height=22,V++}}const L=V,x=q.getRow(V);x.values=t.columns.map(r=>r.title),x.font={bold:!0,name:"微软雅黑",size:12},x.fill={type:"pattern",pattern:"solid",fgColor:{argb:"FFE0E0E0"}},x.alignment={horizontal:"center",vertical:"middle",wrapText:N,indent:1},x.height=N?48:44,V++;const b=t.group_rules,c=b==null?void 0:b.merge_field,i=t.columns;if(c){let r=0,u=0;for(;r<p.length;){const y=[];let _=r;for(;_<p.length&&p[_][c]===p[r][c];)y.push(p[_]),_++;const w=V;for(let S=0;S<y.length;S++){u++;const z=y[S],M=i.map(F=>F.editor===W.AUTO_SEQ.value?u:I(F.editor).hasFormula?A(z):z[F.field]??""),C=M.map((F,T)=>(i[T].prefix||"")+F+(i[T].suffix||"")),O=q.getRow(V);O.values=M,O.height=N?qe(C,11):36;for(let F=0;F<i.length;F++){const T=i[F],Q=O.getCell(F+1);Ne(Q,T.cellStyle),(T.prefix||T.suffix)&&(Q.value=C[F])}V++}const B=V-1;for(let S=0;S<i.length;S++){const z=i[S];if(z.merge_on_group!==!0)continue;let M=w;for(let C=1;C<y.length;C++)y[C][z.field]!==y[C-1][z.field]&&(w+C-1>M&&q.mergeCells(`${J(S)}${M}:${J(S)}${w+C-1}`),M=w+C);B>M&&q.mergeCells(`${J(S)}${M}:${J(S)}${B}`)}if(b.show_detail_subtotal!==!1&&p[r][c]!==void 0&&p[r][c]!==null&&p[r][c]!==""){const S=y.reduce((Q,Z)=>Q+Number(A(Z)||0),0),z=J(Math.max(0,d-2));q.mergeCells(`A${V}:${z}${V}`);const M=q.getCell(`A${V}`);M.value=`小计(${p[r][c]})`,M.alignment={horizontal:"right",vertical:"middle"},M.font={bold:!0,italic:!0,color:{argb:"FF409EFF"},name:"微软雅黑",size:11};const C=q.getCell(`${f}${V}`),O=b.subtotal_prefix??"",F=b.subtotal_suffix??"";C.value=O+S.toFixed(2)+F,C.alignment={horizontal:"right",vertical:"middle"},C.font={bold:!0,italic:!0,color:{argb:"FF409EFF"},name:"微软雅黑",size:11};const T=q.getRow(V);T.fill={type:"pattern",pattern:"solid",fgColor:{argb:"FFF0F9FF"}},T.alignment={horizontal:"right",vertical:"middle",wrapText:!0},T.height=32,V++}r=_}}else for(let r=0;r<p.length;r++){const u=p[r],y=i.map(B=>B.editor===W.AUTO_SEQ.value?r+1:I(B.editor).hasFormula?A(u):u[B.field]??""),_=y.map((B,D)=>(i[D].prefix||"")+B+(i[D].suffix||"")),w=q.getRow(V);w.values=y,w.height=N?qe(_,11):36;for(let B=0;B<i.length;B++){const D=i[B],S=w.getCell(B+1);Ne(S,D.cellStyle),(D.prefix||D.suffix)&&(S.value=_[B])}V++}const h=V-1;if(t.summary_fields){V+=1;const r=J(Math.max(0,d-2)),u=J(d-1),y=p.reduce((B,D)=>B+Number(A(D)||0),0),_={group_total:y};for(const B of t.summary_fields)j(B.type).hasDefault&&(_[B.field]=Number(B.default??0));_.grand_total=y+t.summary_fields.filter(B=>j(B.type).hasDefault).reduce((B,D)=>B+_[D.field],0);for(const B of t.summary_fields)j(B.type).hasFormula&&(_[B.field]=G(B.formula||"group_total",_));for(const B of t.summary_fields){const D=j(B.type);let S;D.hasFormula?S=G(B.formula||"group_total",_):D.hasText?S=B.text||"":S=Number(B.default??0);const z=((E=B.style)==null?void 0:E.fontSize)||ge,M=q.getCell(`${r}${V}`),C=q.getCell(`${u}${V}`);M.value=B.label,M.alignment={horizontal:"right",vertical:"middle",indent:1},M.font={name:"微软雅黑",size:ge};const O=B.style||{},F=()=>{const Z={name:"微软雅黑",size:z,bold:!!O.bold,italic:!!O.italic};if(O.color){const he=O.color.replace("#","").toUpperCase();Z.color={argb:he.length===6?"FF"+he:he}}return Z},T=B.prefix||"",Q=B.suffix||"";if(typeof S=="number"){const Z=S.toLocaleString("zh-CN",{minimumFractionDigits:2,maximumFractionDigits:2});C.value=T+Z+Q,C.alignment={horizontal:"right",vertical:"middle",indent:1}}else C.value=T+(S??"")+Q,C.alignment={horizontal:"right",vertical:"middle",indent:1};C.font=F(),q.getRow(V).height=Math.max(28,z*2+12),V++}const w=V-1;we(q,L,w,1,d),Be(q,L,w,1,d)}else we(q,L,h,1,d),Be(q,L,h,1,d);if(t.footer_sections){V+=1;for(const r of t.footer_sections)if(r.type==="divider")V++;else if(r.type==="text"){q.mergeCells(`A${V}:${f}${V}`);const u=q.getCell(`A${V}`);u.value=xe(r,k);const y=r.style||{},_=y.fontSize||13;if(u.font={size:_,bold:y.bold===!0,italic:y.italic===!0,name:"微软雅黑"},y.color){const w=y.color.replace("#","").toUpperCase();u.font.color={argb:w.length===6?"FF"+w:w}}u.alignment={horizontal:y.align||"left",vertical:"middle"},q.getRow(V).height=_*2+10,V++}else if(r.type==="row"&&r.cells){const u=r.cells.map(w=>{var B;return Ee((B=w.style)==null?void 0:B.width)||1/r.cells.length});let y=0;const _=u.map(w=>{const B=Math.round(y*d);y+=w;const D=Math.round(y*d)-1;return{start:B,end:Math.max(D,B)}});for(let w=0;w<r.cells.length;w++){const B=r.cells[w],D=_[w],S=`${J(D.start)}${V}`,z=`${J(D.end)}${V}`;S!==z&&q.mergeCells(`${S}:${z}`);const M=q.getCell(S);M.value=$e(B,k);const C=B.style||{};M.alignment={horizontal:C.align||"left",vertical:"middle"};const O={name:"微软雅黑",size:C.fontSize||11,bold:C.bold===!0,italic:C.italic===!0};if(C.color){const F=C.color.replace("#","").toUpperCase();O.color={argb:F.length===6?"FF"+F:F}}M.font=O}q.getRow(V).height=22,V++}}const n=50,$=6;for(let r=0;r<d;r++){const u=t.columns[r],y=r+1;if(m==="auto-wrap")q.getColumn(y).width=u.width?Math.max(u.width/7,8):12;else{let _=0;for(let D=1;D<V;D++)_=Math.max(_,_e(q.getCell(D,y).value));const w=u.width?Math.max(u.width/7,10):12,B=Math.min(Math.max(_+2,$),n);q.getColumn(y).width=Math.max(B,w)}}const s=await g.xlsx.writeBuffer();return new Blob([s],{type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"})}function P(t){return JSON.parse(JSON.stringify(t))}function Y(t,o){try{return JSON.stringify(t)===JSON.stringify(o)}catch{return!1}}function Ke(t,o){let l=null;const a=function(...k){clearTimeout(l),l=setTimeout(()=>t.apply(this,k),o)};return a.cancel=()=>{clearTimeout(l),l=null},Object.defineProperty(a,"timer",{get(){return l},configurable:!0}),a}const Ce={color:"#303133",fontSize:13,bold:!1,italic:!1,align:"center"};function Se(t=[]){return Array.isArray(t)?t.map(o=>{const l=I(o.editor),a=Array.isArray(o.dict)?o.dict:[];return{...o,field:o.field||"",title:o.title||l.defaultTitle,editor:o.editor||W.INPUT.value,width:o.width??l.defaultWidth,dictStr:a.length?a.join(","):o.dictStr||"",formula:o.formula||"",merge_on_group:l.canMerge?o.merge_on_group??!1:!1,cellStyle:{...P(Ce),...o.cellStyle||{}},prefix:o.prefix||"",suffix:o.suffix||""}}):[]}function De(t){return t.map(o=>{const l=I(o.editor),a={field:o.field,title:o.title,editor:o.editor,width:o.width};return l.hasDict&&(a.dict=(o.dictStr||"").split(",").map(k=>k.trim()).filter(Boolean)),l.hasFormula&&(a.formula=o.formula||""),l.canMerge&&(a.merge_on_group=!!o.merge_on_group),o.cellStyle&&(a.cellStyle=o.cellStyle),o.prefix&&(a.prefix=o.prefix),o.suffix&&(a.suffix=o.suffix),a})}function ne(t={}){const o=t&&typeof t=="object"?t:{},l=o.merge_field||"";return l?{merge_field:l,show_detail_subtotal:o.show_detail_subtotal??!0,subtotal_prefix:o.subtotal_prefix??"",subtotal_suffix:o.subtotal_suffix??""}:{}}function Ze(t,o,l){const a=I(t);return{field:o,title:a.defaultTitle||l||"新列",editor:t,width:a.defaultWidth,dictStr:a.hasDict&&a.defaultDictStr||"",formula:"",merge_on_group:!1,cellStyle:P(Ce),prefix:"",suffix:""}}function Fe(){return{top:{style:"",width:1,color:"#dcdfe6"},bottom:{style:"",width:1,color:"#dcdfe6"},left:{style:"",width:1,color:"#dcdfe6"},right:{style:"",width:1,color:"#dcdfe6"}}}function v(t="auto"){return{width:t,color:"#303133",fontSize:13,bold:!1,italic:!1,align:"left",border:Fe()}}function ie(t){const o=t.style||{},l={width:o.width||"auto"};l.textAlign=o.align||"left",o.color!=null&&o.color!==""&&(l.color=o.color),o.fontSize!=null&&(l.fontSize=Number(o.fontSize)+"px"),o.bold&&(l.fontWeight="bold"),o.italic&&(l.fontStyle="italic");const a=o.border;if(a)for(const k of["top","bottom","left","right"]){const p=a[k];p&&p.style&&p.width>0&&(l["border-"+k]=`${p.width}px ${p.style} ${p.color||"#dcdfe6"}`)}return l}function ve(t){const o=new Set;for(const l of t||[])if(l.type==="text"&&l.bindField)o.add(l.bindField);else if(l.type==="row"&&l.cells)for(const a of l.cells)a.bindField&&o.add(a.bindField);return o}function Te(t,o){const l=ve(o);let a=0;const k=new RegExp("^"+t+"(\\d+)$");for(const N of l){const g=k.exec(N);g&&(a=Math.max(a,parseInt(g[1],10)))}let p=a+1,m=t+String(p).padStart(4,"0");for(;l.has(m);)p++,m=t+String(p).padStart(4,"0");return m}function Ue(t){const o={},l=t&&t.style||{};return l.color&&(o.color=l.color),l.fontSize&&(o.fontSize=Number(l.fontSize)+"px"),l.bold&&(o.fontWeight="bold"),l.italic&&(o.fontStyle="italic"),o}function K(t){const o=Ue(t),l=t&&t.style||{};return l.align?o.textAlign=l.align:t&&t.align&&(o.textAlign=t.align),o}function Me(t){return Ue(t)}function Ae(t,o,l){t.bindEnabled=!t.bindEnabled,t.bindEnabled?(t.text="",t.bindField=t.bindField||Te(o,l)):t.bindField=""}function Le(t,o,l){t.bindEnabled=!t.bindEnabled,t.bindEnabled?(t.text="",t.value="",t.bindField=t.bindField||Te(o,l)):t.bindField=""}function et(t,o){let l=t,a=2;for(;o.has(l);)l=t+"_"+a++;return l}function tt(t=[]){for(const o of t)o.type==="title"&&(o.type="text",o.style=o.style||{color:"#303133",fontSize:18,bold:!0,italic:!1,align:"center"},o.align&&!o.style.align&&(o.style.align=o.align,delete o.align)),o.type==="text"&&(o.style=o.style||{},o.align&&!o.style.align&&(o.style.align=o.align,delete o.align),o.style.color===void 0&&(o.style.color="#303133"),o.style.fontSize===void 0&&(o.style.fontSize=14),o.style.bold===void 0&&(o.style.bold=!1),o.style.italic===void 0&&(o.style.italic=!1),o.style.align===void 0&&(o.style.align="left"),o.bindEnabled===void 0&&(o.bindEnabled=!1),o.bindField===void 0&&(o.bindField=""),o.bindEnabled&&(o.text=""))}function lt(t=[]){for(const o of t)if(o.type==="row"&&o.cells)for(const l of o.cells)l.style||(l.style=v()),l.style.width===void 0&&(l.style.width="auto"),l.style.color===void 0&&(l.style.color="#303133"),l.style.fontSize===void 0&&(l.style.fontSize=13),l.style.bold===void 0&&(l.style.bold=!1),l.style.italic===void 0&&(l.style.italic=!1),l.style.align===void 0&&(l.style.align="left"),l.style.border===void 0&&(l.style.border=Fe()),l.bindEnabled===void 0&&(l.bindEnabled=!1),l.bindField===void 0&&(l.bindField=""),l.hideLabel===void 0&&(l.hideLabel=!1),l.bindEnabled&&(l.text="",l.value="")}function ze(t){const o=[];for(const l of t||[])if(l.type==="text"&&l.bindEnabled)o.push({field:l.bindField,label:l.label||""});else if(l.type==="row"&&l.cells)for(const a of l.cells)a.bindEnabled&&o.push({field:a.bindField,label:a.label||""});return o.filter(l=>l.field)}function ae(t){return!t||t.length===0?[]:(tt(t),lt(t),t)}const Oe="sum_";let ce=0;function Re(){return ce++,Oe+String(ce).padStart(4,"0")}function ot(t){const o=j(t),l={color:"#606266",fontSize:13,bold:!1,italic:!1},k={field:Re(),label:"标签",prefix:"",suffix:"",style:l};return o.hasFormula?{...k,type:o.value,formula:""}:o.hasText?{...k,type:o.value,text:""}:{...k,type:H.MANUAL_INPUT.value,default:0}}function me(t=[]){let o=0;for(const l of t)if(l.field){const a=new RegExp("^"+Oe+"(\\d+)$").exec(l.field);a&&(o=Math.max(o,parseInt(a[1],10)))}ce=o;for(const l of t)l.field==null&&(l.field=Re()),l.prefix===void 0&&(l.prefix=""),l.suffix===void 0&&(l.suffix=""),l.style===void 0&&(l.style={color:"#606266",fontSize:13,bold:!1,italic:!1}),l.style.color===void 0&&(l.style.color="#606266"),l.style.fontSize===void 0&&(l.style.fontSize=13),l.style.bold===void 0&&(l.style.bold=!1),l.style.italic===void 0&&(l.style.italic=!1)}function pe(){return{columns:[],group_rules:{},header_sections:[],footer_sections:[],summary_fields:[]}}function se(t){const o=t&&typeof t=="object"?t:{},l=De(Se(o.columns||[])),a=ne(o.group_rules||{}),k=ae(P(o.header_sections||[])),p=ae(P(o.footer_sections||[])),m=P(o.summary_fields||[]);return me(m),{columns:l,group_rules:a,header_sections:k,footer_sections:p,summary_fields:m}}const nt={class:"qukt-quote-sheet"},it={key:1,class:"qukt-q-divider"},at={key:3,class:"qukt-q-row"},st={key:0,class:"qukt-q-table-wrap"},rt={class:"qukt-q-table"},dt={key:0,class:"subtotal-row"},ct=["colspan"],mt={class:"subtotal-value"},pt={key:1},ut=["rowspan"],ft={key:0,class:"empty-row"},kt=["colspan"],bt={key:1,class:"qukt-q-summary"},ht={class:"qukt-q-summary-label"},yt={class:"qukt-q-footer"},Et={key:0,class:"qukt-q-divider"},gt={key:2,class:"qukt-q-row"},ue={__name:"QuokitSheet",props:{tpl:{type:Object,default:pe},data:{type:Object,default:()=>({headerData:{},rows:[],footerData:{}})},placeholder:{type:String,default:"-"}},setup(t,{expose:o}){const l=t,a=e.computed(()=>se(l.tpl)),k=e.computed(()=>{var s;return((s=l.data)==null?void 0:s.headerData)||{}}),p=e.computed(()=>{var s;return((s=l.data)==null?void 0:s.footerData)||{}}),m=e.computed(()=>{var s;return((s=l.data)==null?void 0:s.rows)||[]});function N(s,E){return s.bindEnabled&&s.bindField?(E==="footer"?p.value:k.value)[s.bindField]??s.bindField:s.text||""}function g(s,E){const r=s.type==="field"&&s.label&&!s.hideLabel;if(s.bindEnabled&&s.bindField){const _=(E==="footer"?p.value:k.value)[s.bindField]??s.bindField;return r?s.label+_:_}return s.type==="field"?(r?s.label:"")+(s.value??""):s.text||""}function q(s){const E={width:(s.width||100)+"px"},r=s.cellStyle||{};r.color!=null&&r.color!==""&&(E.color=r.color),r.fontSize!=null&&(E.fontSize=Number(r.fontSize)+"px"),r.bold&&(E.fontWeight="bold"),r.italic&&(E.fontStyle="italic"),r.align&&(E.textAlign=r.align);const u=r.border;if(u)for(const y of["top","bottom","left","right"]){const _=u[y];_&&_.style&&_.width>0&&(E["border-"+y]=`${_.width}px ${_.style} ${_.color||"#dcdfe6"}`)}return E}function d(s){return(Number(s)||0).toFixed(2)}const f=e.computed(()=>a.value.columns.find(s=>I(s.editor).hasFormula));function V(s){var r;const E=((r=f.value)==null?void 0:r.formula)||"quantity * unit_price";return G(E,s)}const U=e.computed(()=>m.value.reduce((s,E)=>s+Number(V(E)||0),0));function A(){let s=U.value;for(const E of a.value.summary_fields)j(E.type).hasDefault&&(s+=L(E));return s}function L(s){return Number(s.default??0)}function x(){const s={group_total:U.value},E=a.value.summary_fields;for(const r of E)j(r.type).hasDefault&&(s[r.field]=L(r));for(const r of E)if(j(r.type).hasFormula&&r.formula)try{s[r.field]=G(r.formula,s)}catch{s[r.field]=0}return s.grand_total=A(),s}function b(s){const E=j(s.type);return E.hasText?s.text||"":E.hasFormula?s.formula?x()[s.field]??0:0:L(s)}function c(s){if(j(s.type).hasText)return s.text||"";const E=Number(b(s))||0,r=Number.isInteger(E)?E:E.toFixed(2);return(s.prefix||"")+r+(s.suffix||"")}const i=e.computed(()=>{const s=m.value.map(_=>({..._})),E=a.value.group_rules;if(!(E!=null&&E.merge_field))return s;const r=[],u=E.merge_field;let y=0;for(;y<s.length;){const _=[s[y]];let w=y+1;for(;w<s.length&&s[w][u]===s[y][u];)_.push(s[w]),w++;if(r.push(..._),(E.show_detail_subtotal??!0)&&s[y][u]!==void 0&&s[y][u]!==null&&s[y][u]!==""){const D=_.reduce((S,z)=>S+Number(V(z)||0),0);r.push({__is_subtotal:!0,__group_key:s[y][u],__group_sum:D})}y=w}return r});function h(s,E){var z,M,C;const r=i.value,u=r[s];if(!u||u.__is_subtotal)return 1;const y=a.value.group_rules,_=y==null?void 0:y.merge_field,w=a.value.columns.find(O=>O.field===E),B=_&&E===_,D=(w==null?void 0:w.merge_on_group)===!0;if(!B&&!D)return 1;const S=(()=>{var T,Q;if(!_)return r.length;const O=u[_];let F=s+1;for(;F<r.length&&((T=r[F])==null?void 0:T[_])===O&&!((Q=r[F])!=null&&Q.__is_subtotal);)F++;return F})();if(B)return s>0&&((z=r[s-1])==null?void 0:z[_])===u[_]&&!((M=r[s-1])!=null&&M.__is_subtotal)?0:S-s;if(D){const O=u[E];if(s>0){const T=r[s-1];if((!_||(T==null?void 0:T[_])===u[_]&&!(T!=null&&T.__is_subtotal))&&(T==null?void 0:T[E])===O)return 0}let F=1;for(let T=s+1;T<S&&((C=r[T])==null?void 0:C[E])===O;T++)F++;return F}return 1}async function n(s=!1){const E=a.value;if(!E||E.columns.length===0){console.warn("[QuokitSheet] exportExcel skipped: template has no columns");return}const r=await Ye(E,l.data||{},s?{layout:"auto-width"}:void 0),u=URL.createObjectURL(r),y=document.createElement("a");y.href=u,y.download=`${Date.now()}.xlsx`,document.body.appendChild(y),y.click(),document.body.removeChild(y),setTimeout(()=>URL.revokeObjectURL(u),100)}function $(s=!1){const E=document.querySelector(".qukt-quote-sheet");if(!E)return;const r=s!==!0,u=window.open("","_blank",r?"width=1200,height=900":"width=900,height=1200");if(!u)return;const y=Array.from(document.styleSheets).map(w=>{try{return Array.from(w.cssRules).map(B=>B.cssText).join(`
4
+ `).length,g=_e(m),d=m.length===0?1:Math.ceil(g/12);l=Math.max(l,N,d)}const a=o+8;return Math.max(50,l*a+16*2)}function we(t,o,l,a,k){for(let p=o;p<=l;p++)for(let m=a;m<=k;m++){const N=t.getCell(p,m),g=N.border||{};N.border={top:g.top||le,left:g.left||le,right:g.right||le,bottom:g.bottom||le}}}function Be(t,o,l,a,k){for(let p=a;p<=k;p++)t.getCell(o,p).border={...t.getCell(o,p).border||{},top:oe},t.getCell(l,p).border={...t.getCell(l,p).border||{},bottom:oe};for(let p=o;p<=l;p++)t.getCell(p,a).border={...t.getCell(p,a).border||{},left:oe},t.getCell(p,k).border={...t.getCell(p,k).border||{},right:oe}}function xe(t,o){return t.bindEnabled&&t.bindField?o[t.bindField]??"":t.text??""}function $e(t,o){const l=t.type===te.FIELD.value&&t.label&&!t.hideLabel;if(t.bindEnabled&&t.bindField){const a=o[t.bindField]??"";return l?t.label+a:a}return t.type===te.FIELD.value?(l?t.label:"")+(t.value??""):t.text??""}async function Ye(t,o,l={}){var E;if(!t||!Array.isArray(t.columns)||t.columns.length===0)throw new Error("模板为空或缺少列定义");const a=(o==null?void 0:o.headerData)||{},k=(o==null?void 0:o.footerData)||{};let p=(o==null?void 0:o.rows)||o||[];Array.isArray(p)||(p=[]);const m=l.layout||"auto-wrap",N=m==="auto-wrap",g=new He.Workbook,q=g.addWorksheet("报价单"),d=t.columns.length,f=J(d-1);let V=1;const U=()=>(t.columns||[]).find(r=>I(r.editor).hasFormula),A=r=>{const u=U(),y=(u==null?void 0:u.formula)||"quantity * unit_price";return G(y,r)};if(t.header_sections){for(const r of t.header_sections)if(r.type==="divider")V++;else if(r.type==="text"){q.mergeCells(`A${V}:${f}${V}`);const u=q.getCell(`A${V}`);u.value=xe(r,a);const y=r.style||{},_=y.fontSize||13;if(u.font={size:_,bold:y.bold===!0,italic:y.italic===!0,name:"微软雅黑"},y.color){const w=y.color.replace("#","").toUpperCase();u.font.color={argb:w.length===6?"FF"+w:w}}u.alignment={horizontal:y.align||"left",vertical:"middle"},q.getRow(V).height=_*2+10,V++}else if(r.type==="row"&&r.cells){const u=r.cells.map(w=>{var B;return Ee((B=w.style)==null?void 0:B.width)||1/r.cells.length});let y=0;const _=u.map(w=>{const B=Math.round(y*d);y+=w;const D=Math.round(y*d)-1;return{start:B,end:Math.max(D,B)}});for(let w=0;w<r.cells.length;w++){const B=r.cells[w],D=_[w],S=`${J(D.start)}${V}`,z=`${J(D.end)}${V}`;S!==z&&q.mergeCells(`${S}:${z}`);const M=q.getCell(S);M.value=$e(B,a);const C=B.style||{},O=C.fontSize||11;if(M.font={size:O,bold:C.bold===!0,italic:C.italic===!0,name:"微软雅黑"},C.color){const F=C.color.replace("#","").toUpperCase();M.font.color={argb:F.length===6?"FF"+F:F}}M.alignment={horizontal:C.align||"left",vertical:"middle"}}q.getRow(V).height=22,V++}}const L=V,x=q.getRow(V);x.values=t.columns.map(r=>r.title),x.font={bold:!0,name:"微软雅黑",size:12},x.fill={type:"pattern",pattern:"solid",fgColor:{argb:"FFE0E0E0"}},x.alignment={horizontal:"center",vertical:"middle",wrapText:N,indent:1},x.height=N?48:44,V++;const b=t.group_rules,c=b==null?void 0:b.merge_field,i=t.columns;if(c){let r=0,u=0;for(;r<p.length;){const y=[];let _=r;for(;_<p.length&&p[_][c]===p[r][c];)y.push(p[_]),_++;const w=V;for(let S=0;S<y.length;S++){u++;const z=y[S],M=i.map(F=>F.editor===W.AUTO_SEQ.value?u:I(F.editor).hasFormula?A(z):z[F.field]??""),C=M.map((F,T)=>(i[T].prefix||"")+F+(i[T].suffix||"")),O=q.getRow(V);O.values=M,O.height=N?qe(C,11):36;for(let F=0;F<i.length;F++){const T=i[F],Q=O.getCell(F+1);Ne(Q,T.cellStyle),(T.prefix||T.suffix)&&(Q.value=C[F])}V++}const B=V-1;for(let S=0;S<i.length;S++){const z=i[S];if(z.merge_on_group!==!0)continue;let M=w;for(let C=1;C<y.length;C++)y[C][z.field]!==y[C-1][z.field]&&(w+C-1>M&&q.mergeCells(`${J(S)}${M}:${J(S)}${w+C-1}`),M=w+C);B>M&&q.mergeCells(`${J(S)}${M}:${J(S)}${B}`)}if(b.show_detail_subtotal!==!1&&p[r][c]!==void 0&&p[r][c]!==null&&p[r][c]!==""){const S=y.reduce((Q,Z)=>Q+Number(A(Z)||0),0),z=J(Math.max(0,d-2));q.mergeCells(`A${V}:${z}${V}`);const M=q.getCell(`A${V}`);M.value=`小计(${p[r][c]})`,M.alignment={horizontal:"right",vertical:"middle"},M.font={bold:!0,italic:!0,color:{argb:"FF409EFF"},name:"微软雅黑",size:11};const C=q.getCell(`${f}${V}`),O=b.subtotal_prefix??"",F=b.subtotal_suffix??"";C.value=O+S.toFixed(2)+F,C.alignment={horizontal:"right",vertical:"middle"},C.font={bold:!0,italic:!0,color:{argb:"FF409EFF"},name:"微软雅黑",size:11};const T=q.getRow(V);T.fill={type:"pattern",pattern:"solid",fgColor:{argb:"FFF0F9FF"}},T.alignment={horizontal:"right",vertical:"middle",wrapText:!0},T.height=32,V++}r=_}}else for(let r=0;r<p.length;r++){const u=p[r],y=i.map(B=>B.editor===W.AUTO_SEQ.value?r+1:I(B.editor).hasFormula?A(u):u[B.field]??""),_=y.map((B,D)=>(i[D].prefix||"")+B+(i[D].suffix||"")),w=q.getRow(V);w.values=y,w.height=N?qe(_,11):36;for(let B=0;B<i.length;B++){const D=i[B],S=w.getCell(B+1);Ne(S,D.cellStyle),(D.prefix||D.suffix)&&(S.value=_[B])}V++}const h=V-1;if(t.summary_fields){V+=1;const r=J(Math.max(0,d-2)),u=J(d-1),y=p.reduce((B,D)=>B+Number(A(D)||0),0),_={group_total:y};for(const B of t.summary_fields)j(B.type).hasDefault&&(_[B.field]=Number(B.default??0));_.grand_total=y+t.summary_fields.filter(B=>j(B.type).hasDefault).reduce((B,D)=>B+_[D.field],0);for(const B of t.summary_fields)j(B.type).hasFormula&&(_[B.field]=G(B.formula||"group_total",_));for(const B of t.summary_fields){const D=j(B.type);let S;D.hasFormula?S=G(B.formula||"group_total",_):D.hasText?S=B.text||"":S=Number(B.default??0);const z=((E=B.style)==null?void 0:E.fontSize)||ge,M=q.getCell(`${r}${V}`),C=q.getCell(`${u}${V}`);M.value=B.label,M.alignment={horizontal:"right",vertical:"middle",indent:1},M.font={name:"微软雅黑",size:ge};const O=B.style||{},F=()=>{const Z={name:"微软雅黑",size:z,bold:!!O.bold,italic:!!O.italic};if(O.color){const he=O.color.replace("#","").toUpperCase();Z.color={argb:he.length===6?"FF"+he:he}}return Z},T=B.prefix||"",Q=B.suffix||"";if(typeof S=="number"){const Z=S.toLocaleString("zh-CN",{minimumFractionDigits:2,maximumFractionDigits:2});C.value=T+Z+Q,C.alignment={horizontal:"right",vertical:"middle",indent:1}}else C.value=T+(S??"")+Q,C.alignment={horizontal:"right",vertical:"middle",indent:1};C.font=F(),q.getRow(V).height=Math.max(28,z*2+12),V++}const w=V-1;we(q,L,w,1,d),Be(q,L,w,1,d)}else we(q,L,h,1,d),Be(q,L,h,1,d);if(t.footer_sections){V+=1;for(const r of t.footer_sections)if(r.type==="divider")V++;else if(r.type==="text"){q.mergeCells(`A${V}:${f}${V}`);const u=q.getCell(`A${V}`);u.value=xe(r,k);const y=r.style||{},_=y.fontSize||13;if(u.font={size:_,bold:y.bold===!0,italic:y.italic===!0,name:"微软雅黑"},y.color){const w=y.color.replace("#","").toUpperCase();u.font.color={argb:w.length===6?"FF"+w:w}}u.alignment={horizontal:y.align||"left",vertical:"middle"},q.getRow(V).height=_*2+10,V++}else if(r.type==="row"&&r.cells){const u=r.cells.map(w=>{var B;return Ee((B=w.style)==null?void 0:B.width)||1/r.cells.length});let y=0;const _=u.map(w=>{const B=Math.round(y*d);y+=w;const D=Math.round(y*d)-1;return{start:B,end:Math.max(D,B)}});for(let w=0;w<r.cells.length;w++){const B=r.cells[w],D=_[w],S=`${J(D.start)}${V}`,z=`${J(D.end)}${V}`;S!==z&&q.mergeCells(`${S}:${z}`);const M=q.getCell(S);M.value=$e(B,k);const C=B.style||{};M.alignment={horizontal:C.align||"left",vertical:"middle"};const O={name:"微软雅黑",size:C.fontSize||11,bold:C.bold===!0,italic:C.italic===!0};if(C.color){const F=C.color.replace("#","").toUpperCase();O.color={argb:F.length===6?"FF"+F:F}}M.font=O}q.getRow(V).height=22,V++}}const n=50,$=6;for(let r=0;r<d;r++){const u=t.columns[r],y=r+1;if(m==="auto-wrap")q.getColumn(y).width=u.width?Math.max(u.width/7,8):12;else{let _=0;for(let D=1;D<V;D++)_=Math.max(_,_e(q.getCell(D,y).value));const w=u.width?Math.max(u.width/7,10):12,B=Math.min(Math.max(_+2,$),n);q.getColumn(y).width=Math.max(B,w)}}const s=await g.xlsx.writeBuffer();return new Blob([s],{type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"})}function P(t){return JSON.parse(JSON.stringify(t))}function Y(t,o){try{return JSON.stringify(t)===JSON.stringify(o)}catch{return!1}}function Ke(t,o){let l=null;const a=function(...k){clearTimeout(l),l=setTimeout(()=>t.apply(this,k),o)};return a.cancel=()=>{clearTimeout(l),l=null},Object.defineProperty(a,"timer",{get(){return l},configurable:!0}),a}const Ce={color:"#303133",fontSize:13,bold:!1,italic:!1,align:"center"};function Se(t=[]){return Array.isArray(t)?t.map(o=>{const l=I(o.editor),a=Array.isArray(o.dict)?o.dict:[];return{...o,field:o.field??"",title:o.title??l.defaultTitle,editor:o.editor??W.INPUT.value,width:o.width??l.defaultWidth,dictStr:a.length?a.join(","):o.dictStr||"",formula:o.formula||"",merge_on_group:l.canMerge?o.merge_on_group??!1:!1,cellStyle:{...P(Ce),...o.cellStyle||{}},prefix:o.prefix||"",suffix:o.suffix||""}}):[]}function De(t){return t.map(o=>{const l=I(o.editor),a={field:o.field,title:o.title,editor:o.editor,width:o.width};return l.hasDict&&(a.dict=(o.dictStr||"").split(",").map(k=>k.trim()).filter(Boolean)),l.hasFormula&&(a.formula=o.formula||""),l.canMerge&&(a.merge_on_group=!!o.merge_on_group),o.cellStyle&&(a.cellStyle=o.cellStyle),o.prefix&&(a.prefix=o.prefix),o.suffix&&(a.suffix=o.suffix),a})}function ne(t={}){const o=t&&typeof t=="object"?t:{},l=o.merge_field||"";return l?{merge_field:l,show_detail_subtotal:o.show_detail_subtotal??!0,subtotal_prefix:o.subtotal_prefix??"",subtotal_suffix:o.subtotal_suffix??""}:{}}function Ze(t,o,l){const a=I(t);return{field:o,title:a.defaultTitle||l||"新列",editor:t,width:a.defaultWidth,dictStr:a.hasDict&&a.defaultDictStr||"",formula:"",merge_on_group:!1,cellStyle:P(Ce),prefix:"",suffix:""}}function Fe(){return{top:{style:"",width:1,color:"#dcdfe6"},bottom:{style:"",width:1,color:"#dcdfe6"},left:{style:"",width:1,color:"#dcdfe6"},right:{style:"",width:1,color:"#dcdfe6"}}}function v(t="auto"){return{width:t,color:"#303133",fontSize:13,bold:!1,italic:!1,align:"left",border:Fe()}}function ie(t){const o=t.style||{},l={width:o.width||"auto"};l.textAlign=o.align||"left",o.color!=null&&o.color!==""&&(l.color=o.color),o.fontSize!=null&&(l.fontSize=Number(o.fontSize)+"px"),o.bold&&(l.fontWeight="bold"),o.italic&&(l.fontStyle="italic");const a=o.border;if(a)for(const k of["top","bottom","left","right"]){const p=a[k];p&&p.style&&p.width>0&&(l["border-"+k]=`${p.width}px ${p.style} ${p.color||"#dcdfe6"}`)}return l}function ve(t){const o=new Set;for(const l of t||[])if(l.type==="text"&&l.bindField)o.add(l.bindField);else if(l.type==="row"&&l.cells)for(const a of l.cells)a.bindField&&o.add(a.bindField);return o}function Te(t,o){const l=ve(o);let a=0;const k=new RegExp("^"+t+"(\\d+)$");for(const N of l){const g=k.exec(N);g&&(a=Math.max(a,parseInt(g[1],10)))}let p=a+1,m=t+String(p).padStart(4,"0");for(;l.has(m);)p++,m=t+String(p).padStart(4,"0");return m}function Ue(t){const o={},l=t&&t.style||{};return l.color&&(o.color=l.color),l.fontSize&&(o.fontSize=Number(l.fontSize)+"px"),l.bold&&(o.fontWeight="bold"),l.italic&&(o.fontStyle="italic"),o}function K(t){const o=Ue(t),l=t&&t.style||{};return l.align?o.textAlign=l.align:t&&t.align&&(o.textAlign=t.align),o}function Me(t){return Ue(t)}function Ae(t,o,l){t.bindEnabled=!t.bindEnabled,t.bindEnabled?(t.text="",t.bindField=t.bindField||Te(o,l)):t.bindField=""}function Le(t,o,l){t.bindEnabled=!t.bindEnabled,t.bindEnabled?(t.text="",t.value="",t.bindField=t.bindField||Te(o,l)):t.bindField=""}function et(t,o){let l=t,a=2;for(;o.has(l);)l=t+"_"+a++;return l}function tt(t=[]){for(const o of t)o.type==="title"&&(o.type="text",o.style=o.style||{color:"#303133",fontSize:18,bold:!0,italic:!1,align:"center"},o.align&&!o.style.align&&(o.style.align=o.align,delete o.align)),o.type==="text"&&(o.style=o.style||{},o.align&&!o.style.align&&(o.style.align=o.align,delete o.align),o.style.color===void 0&&(o.style.color="#303133"),o.style.fontSize===void 0&&(o.style.fontSize=14),o.style.bold===void 0&&(o.style.bold=!1),o.style.italic===void 0&&(o.style.italic=!1),o.style.align===void 0&&(o.style.align="left"),o.bindEnabled===void 0&&(o.bindEnabled=!1),o.bindField===void 0&&(o.bindField=""),o.bindEnabled&&(o.text=""))}function lt(t=[]){for(const o of t)if(o.type==="row"&&o.cells)for(const l of o.cells)l.style||(l.style=v()),l.style.width===void 0&&(l.style.width="auto"),l.style.color===void 0&&(l.style.color="#303133"),l.style.fontSize===void 0&&(l.style.fontSize=13),l.style.bold===void 0&&(l.style.bold=!1),l.style.italic===void 0&&(l.style.italic=!1),l.style.align===void 0&&(l.style.align="left"),l.style.border===void 0&&(l.style.border=Fe()),l.bindEnabled===void 0&&(l.bindEnabled=!1),l.bindField===void 0&&(l.bindField=""),l.hideLabel===void 0&&(l.hideLabel=!1),l.bindEnabled&&(l.text="",l.value="")}function ze(t){const o=[];for(const l of t||[])if(l.type==="text"&&l.bindEnabled)o.push({field:l.bindField,label:l.label||""});else if(l.type==="row"&&l.cells)for(const a of l.cells)a.bindEnabled&&o.push({field:a.bindField,label:a.label||""});return o.filter(l=>l.field)}function ae(t){return!t||t.length===0?[]:(tt(t),lt(t),t)}const Oe="sum_";let ce=0;function Re(){return ce++,Oe+String(ce).padStart(4,"0")}function ot(t){const o=j(t),l={color:"#606266",fontSize:13,bold:!1,italic:!1},k={field:Re(),label:"标签",prefix:"",suffix:"",style:l};return o.hasFormula?{...k,type:o.value,formula:""}:o.hasText?{...k,type:o.value,text:""}:{...k,type:H.MANUAL_INPUT.value,default:0}}function me(t=[]){let o=0;for(const l of t)if(l.field){const a=new RegExp("^"+Oe+"(\\d+)$").exec(l.field);a&&(o=Math.max(o,parseInt(a[1],10)))}ce=o;for(const l of t)l.field==null&&(l.field=Re()),l.prefix===void 0&&(l.prefix=""),l.suffix===void 0&&(l.suffix=""),l.style===void 0&&(l.style={color:"#606266",fontSize:13,bold:!1,italic:!1}),l.style.color===void 0&&(l.style.color="#606266"),l.style.fontSize===void 0&&(l.style.fontSize=13),l.style.bold===void 0&&(l.style.bold=!1),l.style.italic===void 0&&(l.style.italic=!1)}function pe(){return{columns:[],group_rules:{},header_sections:[],footer_sections:[],summary_fields:[]}}function se(t){const o=t&&typeof t=="object"?t:{},l=De(Se(o.columns||[])),a=ne(o.group_rules||{}),k=ae(P(o.header_sections||[])),p=ae(P(o.footer_sections||[])),m=P(o.summary_fields||[]);return me(m),{columns:l,group_rules:a,header_sections:k,footer_sections:p,summary_fields:m}}const nt={class:"qukt-quote-sheet"},it={key:1,class:"qukt-q-divider"},at={key:3,class:"qukt-q-row"},st={key:0,class:"qukt-q-table-wrap"},rt={class:"qukt-q-table"},dt={key:0,class:"subtotal-row"},ct=["colspan"],mt={class:"subtotal-value"},pt={key:1},ut=["rowspan"],ft={key:0,class:"empty-row"},kt=["colspan"],bt={key:1,class:"qukt-q-summary"},ht={class:"qukt-q-summary-label"},yt={class:"qukt-q-footer"},Et={key:0,class:"qukt-q-divider"},gt={key:2,class:"qukt-q-row"},ue={__name:"QuokitSheet",props:{tpl:{type:Object,default:pe},data:{type:Object,default:()=>({headerData:{},rows:[],footerData:{}})},placeholder:{type:String,default:"-"}},setup(t,{expose:o}){const l=t,a=e.computed(()=>se(l.tpl)),k=e.computed(()=>{var s;return((s=l.data)==null?void 0:s.headerData)||{}}),p=e.computed(()=>{var s;return((s=l.data)==null?void 0:s.footerData)||{}}),m=e.computed(()=>{var s;return((s=l.data)==null?void 0:s.rows)||[]});function N(s,E){return s.bindEnabled&&s.bindField?(E==="footer"?p.value:k.value)[s.bindField]??s.bindField:s.text||""}function g(s,E){const r=s.type==="field"&&s.label&&!s.hideLabel;if(s.bindEnabled&&s.bindField){const _=(E==="footer"?p.value:k.value)[s.bindField]??s.bindField;return r?s.label+_:_}return s.type==="field"?(r?s.label:"")+(s.value??""):s.text||""}function q(s){const E={width:(s.width||100)+"px"},r=s.cellStyle||{};r.color!=null&&r.color!==""&&(E.color=r.color),r.fontSize!=null&&(E.fontSize=Number(r.fontSize)+"px"),r.bold&&(E.fontWeight="bold"),r.italic&&(E.fontStyle="italic"),r.align&&(E.textAlign=r.align);const u=r.border;if(u)for(const y of["top","bottom","left","right"]){const _=u[y];_&&_.style&&_.width>0&&(E["border-"+y]=`${_.width}px ${_.style} ${_.color||"#dcdfe6"}`)}return E}function d(s){return(Number(s)||0).toFixed(2)}const f=e.computed(()=>a.value.columns.find(s=>I(s.editor).hasFormula));function V(s){var r;const E=((r=f.value)==null?void 0:r.formula)||"quantity * unit_price";return G(E,s)}const U=e.computed(()=>m.value.reduce((s,E)=>s+Number(V(E)||0),0));function A(){let s=U.value;for(const E of a.value.summary_fields)j(E.type).hasDefault&&(s+=L(E));return s}function L(s){return Number(s.default??0)}function x(){const s={group_total:U.value},E=a.value.summary_fields;for(const r of E)j(r.type).hasDefault&&(s[r.field]=L(r));for(const r of E)if(j(r.type).hasFormula&&r.formula)try{s[r.field]=G(r.formula,s)}catch{s[r.field]=0}return s.grand_total=A(),s}function b(s){const E=j(s.type);return E.hasText?s.text||"":E.hasFormula?s.formula?x()[s.field]??0:0:L(s)}function c(s){if(j(s.type).hasText)return s.text||"";const E=Number(b(s))||0,r=Number.isInteger(E)?E:E.toFixed(2);return(s.prefix||"")+r+(s.suffix||"")}const i=e.computed(()=>{const s=m.value.map(_=>({..._})),E=a.value.group_rules;if(!(E!=null&&E.merge_field))return s;const r=[],u=E.merge_field;let y=0;for(;y<s.length;){const _=[s[y]];let w=y+1;for(;w<s.length&&s[w][u]===s[y][u];)_.push(s[w]),w++;if(r.push(..._),(E.show_detail_subtotal??!0)&&s[y][u]!==void 0&&s[y][u]!==null&&s[y][u]!==""){const D=_.reduce((S,z)=>S+Number(V(z)||0),0);r.push({__is_subtotal:!0,__group_key:s[y][u],__group_sum:D})}y=w}return r});function h(s,E){var z,M,C;const r=i.value,u=r[s];if(!u||u.__is_subtotal)return 1;const y=a.value.group_rules,_=y==null?void 0:y.merge_field,w=a.value.columns.find(O=>O.field===E),B=_&&E===_,D=(w==null?void 0:w.merge_on_group)===!0;if(!B&&!D)return 1;const S=(()=>{var T,Q;if(!_)return r.length;const O=u[_];let F=s+1;for(;F<r.length&&((T=r[F])==null?void 0:T[_])===O&&!((Q=r[F])!=null&&Q.__is_subtotal);)F++;return F})();if(B)return s>0&&((z=r[s-1])==null?void 0:z[_])===u[_]&&!((M=r[s-1])!=null&&M.__is_subtotal)?0:S-s;if(D){const O=u[E];if(s>0){const T=r[s-1];if((!_||(T==null?void 0:T[_])===u[_]&&!(T!=null&&T.__is_subtotal))&&(T==null?void 0:T[E])===O)return 0}let F=1;for(let T=s+1;T<S&&((C=r[T])==null?void 0:C[E])===O;T++)F++;return F}return 1}async function n(s=!1){const E=a.value;if(!E||E.columns.length===0){console.warn("[QuokitSheet] exportExcel skipped: template has no columns");return}const r=await Ye(E,l.data||{},s?{layout:"auto-width"}:void 0),u=URL.createObjectURL(r),y=document.createElement("a");y.href=u,y.download=`${Date.now()}.xlsx`,document.body.appendChild(y),y.click(),document.body.removeChild(y),setTimeout(()=>URL.revokeObjectURL(u),100)}function $(s=!1){const E=document.querySelector(".qukt-quote-sheet");if(!E)return;const r=s!==!0,u=window.open("","_blank",r?"width=1200,height=900":"width=900,height=1200");if(!u)return;const y=Array.from(document.styleSheets).map(w=>{try{return Array.from(w.cssRules).map(B=>B.cssText).join(`
5
5
  `)}catch{return""}}).join(`
6
6
  `),_=E.outerHTML;u.document.write(`<!doctype html>
7
7
  <html><head><meta charset="utf-8"><title>报价单打印</title>
@@ -0,0 +1,284 @@
1
+ import type { Ref, ComputedRef, Reactive } from 'vue';
2
+
3
+ /* ---------- 数据结构 ---------- */
4
+
5
+ export interface ColumnDef {
6
+ field: string;
7
+ title: string;
8
+ editor: 'INPUT' | 'NUMBER' | 'SELECT' | 'TEXTAREA' | 'DATE' | 'CHECKBOX' | 'AUTO_SEQ' | 'AUTO_CALC' | string;
9
+ width: number;
10
+ dict?: string[];
11
+ formula?: string;
12
+ merge_on_group?: boolean;
13
+ dictStr?: string;
14
+ [key: string]: any;
15
+ }
16
+
17
+ export interface GroupRules {
18
+ merge_field?: string;
19
+ show_detail_subtotal?: boolean;
20
+ }
21
+
22
+ export interface SectionCell {
23
+ type: 'text' | 'image' | 'field' | 'separator';
24
+ text?: string;
25
+ field?: string;
26
+ width?: string | number;
27
+ align?: 'left' | 'center' | 'right';
28
+ bold?: boolean;
29
+ italic?: boolean;
30
+ fontSize?: number;
31
+ color?: string;
32
+ border?: { top: string; bottom: string; left: string; right: string };
33
+ colspan?: number;
34
+ rowspan?: number;
35
+ [key: string]: any;
36
+ }
37
+
38
+ export interface SectionRow {
39
+ cells: SectionCell[];
40
+ [key: string]: any;
41
+ }
42
+
43
+ export interface SummaryField {
44
+ field: string;
45
+ label: string;
46
+ type: 'MANUAL_INPUT' | 'AUTO_CALC' | 'AUTO_SUM' | string;
47
+ default?: any;
48
+ formula?: string;
49
+ [key: string]: any;
50
+ }
51
+
52
+ export interface QuokitTemplateData {
53
+ columns: ColumnDef[];
54
+ group_rules?: GroupRules | null;
55
+ header_sections?: SectionRow[];
56
+ footer_sections?: SectionRow[];
57
+ summary_fields?: SummaryField[];
58
+ }
59
+
60
+ export interface QuokitDataModel {
61
+ headerData?: Record<string, any>;
62
+ rows?: Record<string, any>[];
63
+ footerData?: Record<string, any>;
64
+ }
65
+
66
+ /* ---------- 全局配置 ---------- */
67
+
68
+ export interface TemplateColConfig {
69
+ key: string;
70
+ label: string;
71
+ width: number;
72
+ }
73
+
74
+ export interface TemplateColsConfig {
75
+ layout: 'auto' | 'fixed';
76
+ minWidth: number;
77
+ columns: TemplateColConfig[];
78
+ }
79
+
80
+ export interface QuokitUserConfig {
81
+ templateCols?: Partial<TemplateColsConfig> & {
82
+ columns?: TemplateColConfig[];
83
+ };
84
+ [key: string]: any;
85
+ }
86
+
87
+ export function setConfig(userConfig: QuokitUserConfig): void;
88
+ export function getConfig(): QuokitUserConfig;
89
+ export function resetConfig(): void;
90
+
91
+ /* ---------- Composables ---------- */
92
+
93
+ export interface UseColumnsReturn {
94
+ columns: Ref<ColumnDef[]>;
95
+ groupRules: Ref<Required<GroupRules>>;
96
+ tpl: ComputedRef<{ columns: ColumnDef[]; group_rules: GroupRules | null }>;
97
+ setColumns(raw: ColumnDef[]): void;
98
+ setGroupRules(raw: GroupRules): void;
99
+ }
100
+
101
+ export function useColumns(
102
+ initialColumns?: ColumnDef[],
103
+ initialGroupRules?: GroupRules
104
+ ): UseColumnsReturn;
105
+
106
+ export interface UseSectionsReturn {
107
+ sections: Ref<SectionRow[]>;
108
+ setSections(raw: SectionRow[]): void;
109
+ toTpl(): SectionRow[];
110
+ }
111
+
112
+ export function useSections(
113
+ initialSections?: SectionRow[]
114
+ ): UseSectionsReturn;
115
+
116
+ export interface UseSummaryReturn {
117
+ fields: Ref<SummaryField[]>;
118
+ tpl: ComputedRef<SummaryField[]>;
119
+ setFields(raw: SummaryField[]): void;
120
+ toTpl(): SummaryField[];
121
+ }
122
+
123
+ export function useSummary(initialFields?: SummaryField[]): UseSummaryReturn;
124
+
125
+ export interface PreviewDialogConfig {
126
+ title?: string;
127
+ excel?: boolean;
128
+ print?: boolean;
129
+ json?: boolean;
130
+ [key: string]: any;
131
+ }
132
+
133
+ export interface UsePreviewReturn {
134
+ open: Ref<boolean>;
135
+ current: Reactive<{
136
+ tpl: QuokitTemplateData | null;
137
+ data: QuokitDataModel | null;
138
+ config: Required<PreviewDialogConfig>;
139
+ }>;
140
+ openPreview(tpl: QuokitTemplateData, data: QuokitDataModel, config?: PreviewDialogConfig): void;
141
+ closePreview(): void;
142
+ }
143
+
144
+ export function usePreview(): UsePreviewReturn;
145
+
146
+ export function openPreview(
147
+ tpl: QuokitTemplateData,
148
+ data: QuokitDataModel,
149
+ config?: PreviewDialogConfig
150
+ ): void;
151
+
152
+ export function openTemplatePreview(
153
+ tpl: QuokitTemplateData,
154
+ config?: { title?: string }
155
+ ): void;
156
+
157
+ /* ---------- Vue 组件 ---------- */
158
+
159
+ type Comp<P = {}, X = {}> = {
160
+ __name?: string;
161
+ __props?: P;
162
+ new (): X;
163
+ };
164
+
165
+ /**
166
+ * 报价单模板设计器(整体容器,5 个 tab)
167
+ *
168
+ * @example
169
+ * ```vue
170
+ * <script setup lang="ts">
171
+ * import { ref } from 'vue';
172
+ * import { QuokitTemplate, type QuokitTemplateData } from 'vue-quokit';
173
+ *
174
+ * const tpl = ref<QuokitTemplateData>({ columns: [], group_rules: null });
175
+ * const designerRef = ref<InstanceType<typeof QuokitTemplate> | null>(null);
176
+ *
177
+ * function handleSave() {
178
+ * const json = designerRef.value?.getTemplateJSON();
179
+ * console.log(json);
180
+ * }
181
+ * </script>
182
+ *
183
+ * <template>
184
+ * <QuokitTemplate ref="designerRef" v-model:tpl="tpl" />
185
+ * </template>
186
+ * ```
187
+ */
188
+ export declare const QuokitTemplate: Comp<
189
+ { tpl?: QuokitTemplateData; breakpoint?: number },
190
+ {
191
+ /** 取当前设计器里的完整模板 JSON */
192
+ getTemplateJSON(): QuokitTemplateData;
193
+ /** 弹出帮助对话框 */
194
+ showHelp(): void;
195
+ }
196
+ >;
197
+
198
+ /**
199
+ * 报价单数据填写器
200
+ *
201
+ * @example
202
+ * ```vue
203
+ * <script setup lang="ts">
204
+ * import { ref } from 'vue';
205
+ * import { QuokitData, type QuokitTemplateData } from 'vue-quokit';
206
+ *
207
+ * const tpl = ref<QuokitTemplateData>({ columns: [], group_rules: null });
208
+ * const data = ref<Record<string, any>[]>([]);
209
+ * </script>
210
+ *
211
+ * <template>
212
+ * <QuokitData :tpl="tpl" v-model:data="data" />
213
+ * </template>
214
+ * ```
215
+ */
216
+ export declare const QuokitData: Comp<{
217
+ tpl: QuokitTemplateData;
218
+ data?: Record<string, any>[];
219
+ }>;
220
+
221
+ /**
222
+ * 报价单预览 / 导出 / 打印
223
+ *
224
+ * @example
225
+ * ```vue
226
+ * <script setup lang="ts">
227
+ * import { ref } from 'vue';
228
+ * import { QuokitSheet, type QuokitTemplateData } from 'vue-quokit';
229
+ *
230
+ * const tpl = ref<QuokitTemplateData>({ columns: [], group_rules: null });
231
+ * const data = ref<Record<string, any>[]>([]);
232
+ * const sheetRef = ref<InstanceType<typeof QuokitSheet> | null>(null);
233
+ *
234
+ * function doExport() {
235
+ * sheetRef.value?.exportExcel();
236
+ * }
237
+ * function doPrint() {
238
+ * sheetRef.value?.print();
239
+ * }
240
+ * </script>
241
+ *
242
+ * <template>
243
+ * <QuokitSheet ref="sheetRef" :tpl="tpl" :data="data" />
244
+ * </template>
245
+ * ```
246
+ */
247
+ export declare const QuokitSheet: Comp<
248
+ { tpl: QuokitTemplateData; data?: QuokitDataModel; placeholder?: string },
249
+ {
250
+ /** 导出 Excel。撑长模式下会自动加高行高。 */
251
+ exportExcel(expandRowHeight?: boolean): Promise<void>;
252
+ /** 打印报价单。竖版时 width 设为 800。 */
253
+ print(vertical?: boolean): void;
254
+ }
255
+ >;
256
+
257
+ /**
258
+ * 报价单总体预览对话框(含导出/打印/JSON查看按钮)
259
+ *
260
+ * 通常不需要直接使用,而是通过 `openPreview()` 或 `usePreview()` 来触发。
261
+ *
262
+ * @example
263
+ * ```vue
264
+ * <script setup lang="ts">
265
+ * import { ref } from 'vue';
266
+ * import { QuokitPreview, type QuokitTemplateData } from 'vue-quokit';
267
+ *
268
+ * const tpl = ref<QuokitTemplateData>({ columns: [], group_rules: null });
269
+ * const data = ref({ headerData: {}, rows: [], footerData: {} });
270
+ * const visible = ref(true);
271
+ * </script>
272
+ *
273
+ * <template>
274
+ * <QuokitPreview v-if="visible" :tpl="tpl" :data="data" :config="{ title: '我的报价单' }" @close="visible = false" />
275
+ * </template>
276
+ * ```
277
+ */
278
+ export declare const QuokitPreview: Comp<
279
+ {
280
+ tpl: QuokitTemplateData;
281
+ data?: QuokitDataModel;
282
+ config?: PreviewDialogConfig;
283
+ }
284
+ >;
package/dist/index.mjs CHANGED
@@ -536,9 +536,9 @@ function te(e = []) {
536
536
  const l = Y(o.editor), i = Array.isArray(o.dict) ? o.dict : [];
537
537
  return {
538
538
  ...o,
539
- field: o.field || "",
540
- title: o.title || l.defaultTitle,
541
- editor: o.editor || tt.INPUT.value,
539
+ field: o.field ?? "",
540
+ title: o.title ?? l.defaultTitle,
541
+ editor: o.editor ?? tt.INPUT.value,
542
542
  width: o.width ?? l.defaultWidth,
543
543
  dictStr: i.length ? i.join(",") : o.dictStr || "",
544
544
  formula: o.formula || "",
package/package.json CHANGED
@@ -1,13 +1,15 @@
1
1
  {
2
2
  "name": "vue-quokit",
3
- "version": "0.1.9",
3
+ "version": "0.1.11",
4
4
  "type": "module",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.mjs",
7
+ "types": "./dist/index.d.ts",
7
8
  "exports": {
8
9
  ".": {
9
10
  "import": "./dist/index.mjs",
10
- "require": "./dist/index.cjs"
11
+ "require": "./dist/index.cjs",
12
+ "types": "./dist/index.d.ts"
11
13
  }
12
14
  },
13
15
  "files": [
@@ -30,4 +32,4 @@
30
32
  "vite-plugin-css-injected-by-js": "^5.0.2",
31
33
  "vue": "^3.4.21"
32
34
  }
33
- }
35
+ }