wiser-components 1.0.7 → 1.0.8

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/lib/index.esm.js CHANGED
@@ -1 +1 @@
1
- function e(e,t){void 0===t&&(t={});var i=t.insertAt;if(e&&"undefined"!=typeof document){var a=document.head||document.getElementsByTagName("head")[0],l=document.createElement("style");l.type="text/css","top"===i&&a.firstChild?a.insertBefore(l,a.firstChild):a.appendChild(l),l.styleSheet?l.styleSheet.cssText=e:l.appendChild(document.createTextNode(e))}}function t(e){return e?e.replace(/([A-Z])/g,"-$1").toLowerCase().replace(/^-/,""):e}import{utils as i,read as a}from"xlsx";import{saveAs as l}from"file-saver";import s from"@/assets/icon-search.png";e(".long-input-wrapper{background-color:#fff;border:1px solid #e0e0e0;border-radius:4px;padding:8px}.intTxt{width:80%}");var r={render(){var e=this,t=e.$createElement;return(e.i.t||t)("el-input",e.l(e.o({staticClass:"intTxt",attrs:{"show-word-limit":e.showWordLimit,placeholder:e.placeholder,"auto-complete":"new-password",disabled:e.disabled},on:{input(t){return e.$emit("input",t)}}},"el-input",e.$attrs,!1),e.$listeners),[e.p(Object.keys(this.$slots),function(t){return e.h(t,null,{slot:t})})],2)},staticRenderFns:[],name:"LongInput",props:{showWordLimit:{type:Boolean,default:!0},disabled:{type:Boolean,default:!1},placeholder:{type:String,default:"请输入"}},install(e){e.component(r.name,r)}};e("");var o={render(){var e=this,t=e.$createElement,i=e.i.t||t;return i("el-select",e.l(e.o({attrs:{value:e.value,placeholder:e.placeholder}},"el-select",e.$attrs,!1),e.$listeners),[e.h("unshift"),e.u(" "),e.h("default",function(){return e.p(e.options,function(t,a){return i("el-option",{key:a,attrs:{value:t[e.valueKey],label:t[e.labelKey],disabled:t[e.disabledOption]}})})},{slot:"default"}),e.u(" "),e.h("prefix",null,{slot:"prefix"}),e.u(" "),e.h("empty",null,{slot:"empty"})],2)},staticRenderFns:[],name:"LongSelect",props:{value:{type:[String,Number],default:""},dataList:{type:Array,default(){return[]}},disabledOption:{type:[Boolean,Number],default:!1},valueKey:{type:[String,Number],default:"value"},labelKey:{type:[String,Number],default:"label"},mode:{type:String,default:"local"},dict:{type:String,default:""},url:{type:String,default:""},requestParams:{type:Object,default(){}},placeholder:{type:String,default:"请选择"}},data:()=>({options:[]}),watch:{dataList:{deep:!0,immediate:!0,handler(e){"local"===this.mode&&(this.options=e)}},dict:{deep:!0,handler(e){this.init()}}},created(){this.init()},methods:{init(){"remote"===this.mode&&this.dict&&this.getDicts(this.dict).then(e=>{this.options=(e.data||[]).map(e=>({[this.valueKey]:e.dictCode,[this.labelKey]:e.dictLabel}))})}},install(e){e.component(o.name,o)}};e(".variable-config-dialog :deep(.el-dialog__body){padding:20px}.variable-config-dialog :deep(.el-dialog__header){padding:20px 20px 10px}.dialog-title{align-items:center;color:#303133;display:flex;font-size:16px;font-weight:700;gap:24px;padding:0 20px}.dialog-title .title-left{color:#303133;flex:1;min-width:500px}.dialog-title .title-separator{color:#dcdfe6;flex-shrink:0;font-weight:400}.dialog-title .title-right{color:#303133;flex:1;min-width:400px}.dialog-body{display:flex;gap:24px;min-height:500px}.left-section{flex:1;min-width:500px}.section-title{color:#303133;font-size:16px;font-weight:700;margin-bottom:16px}.variable-selector{align-items:flex-start;display:flex;gap:16px}.variable-panel{border:1px solid #dcdfe6;border-radius:4px;display:flex;flex:1;flex-direction:column;height:500px;overflow:hidden}.panel-header{align-items:center;background:#f5f7fa;border-bottom:1px solid #dcdfe6;display:flex;justify-content:space-between;padding:12px 16px}.select-all-checkbox :deep(.el-checkbox__label){padding-left:8px}.panel-title{color:#303133;font-weight:500}.panel-count{color:#909399;font-size:12px}.panel-search{border-bottom:1px solid #dcdfe6;padding:12px}.panel-list{flex:1;overflow-y:auto;padding:8px}.variable-item{border-radius:4px;cursor:pointer;padding:8px 12px;transition:background-color .2s}.variable-item:hover{background-color:#f5f7fa}.variable-item :deep(.el-checkbox){width:100%}.variable-item :deep(.el-checkbox__label){width:100%}.arrow-buttons{display:flex;flex-direction:column;gap:12px;justify-content:center;padding-top:100px}.arrow-buttons .el-button{margin-left:0!important}.right-section{display:flex;flex:1;flex-direction:column;min-width:400px;overflow:hidden}.config-desc{color:#909399;flex-shrink:0;font-size:13px;line-height:1.5;margin-bottom:24px}.config-group{margin-bottom:32px}.config-group:last-child{margin-bottom:0}.config-label{color:#303133;font-size:14px;font-weight:500;margin-bottom:12px}.config-options{display:flex;flex:1;flex-direction:column;gap:16px;margin-top:16px;overflow-x:hidden;overflow-y:auto;padding-right:8px}.config-options::-webkit-scrollbar{width:6px}.config-options::-webkit-scrollbar-track{background:#f1f1f1;border-radius:3px}.config-options::-webkit-scrollbar-thumb{background:#c1c1c1;border-radius:3px}.config-options::-webkit-scrollbar-thumb:hover{background:#a8a8a8}.config-option-row{align-items:center;display:flex;gap:12px;margin-bottom:8px}.config-option-row.is-parent .option-label{color:#303133;font-weight:500}.config-option-row.is-leaf .option-label{color:#606266}.option-label{color:#606266;flex:1;font-size:13px;min-width:0;white-space:normal;word-break:break-all}.option-label.required{color:#303133;font-weight:500}.option-label .required-mark{color:#f56c6c;margin-left:2px}.config-select{flex-shrink:0;width:350px}.non-leaf-label{color:#909399;font-size:13px;font-style:italic}.disabled-option{cursor:not-allowed!important}.disabled-option,.disabled-text{color:#c0c4cc!important}:deep(.el-select-dropdown__item.is-disabled){color:#c0c4cc!important;cursor:not-allowed!important}:deep(.el-select-dropdown__item.is-disabled) span{color:#c0c4cc!important}.checkbox-list{border:1px solid #dcdfe6;border-radius:4px;display:flex;flex:1;flex-direction:column;gap:8px;max-height:200px;overflow-y:auto;padding:8px}.dialog-footer{text-align:right}");var n={render(){var e=this,t=e.$createElement,i=e.i.t||t;return i("div",[i("el-dialog",{staticClass:"variable-config-dialog",staticStyle:{"max-height":"90vh"},attrs:{visible:e.dialogVisible,width:"1200px"},on:{"update:visible"(t){e.dialogVisible=t},close:e.handleClose}},[i("div",{staticClass:"dialog-title",attrs:{slot:"title"},slot:"title"},[i("span",{staticClass:"title-left"},[e.u("选择分析变量")]),e.u(" "),i("span",{staticClass:"title-separator"},[e.u("|")]),e.u(" "),i("span",{staticClass:"title-right"},[e.u("配置变量")])]),e.u(" "),i("div",{staticClass:"dialog-body"},[i("div",{staticClass:"left-section"},[i("div",{staticClass:"variable-selector"},[i("div",{staticClass:"variable-panel"},[i("div",{staticClass:"panel-header"},[i("el-checkbox",{staticClass:"select-all-checkbox",attrs:{indeterminate:e.leftIndeterminate},on:{change:e.handleLeftSelectAll},model:{value:e.leftSelectAll,callback(t){e.leftSelectAll=t},expression:"leftSelectAll"}},[i("span",{staticClass:"panel-title"},[e.u("全选")])]),e.u(" "),i("span",{staticClass:"panel-count"},[e.u(e.m(e.selectedAllCount)+"/"+e.m(e.allVariables.length))])],1),e.u(" "),i("div",{staticClass:"panel-search"},[i("el-input",{attrs:{placeholder:"请输入关键字","suffix-icon":"el-icon-search",size:"small"},on:{input:e.handleLeftSearch},model:{value:e.leftKeyword,callback(t){e.leftKeyword=t},expression:"leftKeyword"}})],1),e.u(" "),i("div",{staticClass:"panel-list"},e.p(e.filteredLeftVariables,function(t){return i("div",{key:t.field,staticClass:"variable-item"},[i("el-checkbox",{on:{change(i){return e.handleLeftCheckChange(t)}},model:{value:t.checked,callback(i){e.$set(t,"checked",i)},expression:"item.checked"}},[e.u("\n "+e.m(t.field)+"\n ")])],1)}),0)]),e.u(" "),i("div",{staticClass:"arrow-buttons"},[i("el-button",{attrs:{type:"primary",icon:"el-icon-arrow-right",size:"small",disabled:!e.hasLeftSelected},on:{click:e.moveToRight}}),e.u(" "),i("el-button",{attrs:{type:"danger",icon:"el-icon-arrow-left",size:"small",disabled:!e.hasRightSelected},on:{click:e.moveToLeft}})],1),e.u(" "),i("div",{staticClass:"variable-panel"},[i("div",{staticClass:"panel-header"},[i("el-checkbox",{staticClass:"select-all-checkbox",attrs:{indeterminate:e.rightIndeterminate},on:{change:e.handleRightSelectAll},model:{value:e.rightSelectAll,callback(t){e.rightSelectAll=t},expression:"rightSelectAll"}},[i("span",{staticClass:"panel-title"},[e.u("已选")])]),e.u(" "),i("span",{staticClass:"panel-count"},[e.u(e.m(e.selectedRightCount)+"/"+e.m(e.selectedVariables.length))])],1),e.u(" "),i("div",{staticClass:"panel-search"},[i("el-input",{attrs:{placeholder:"请输入关键字","suffix-icon":"el-icon-search",size:"small"},on:{input:e.handleRightSearch},model:{value:e.rightKeyword,callback(t){e.rightKeyword=t},expression:"rightKeyword"}})],1),e.u(" "),i("div",{staticClass:"panel-list"},e.p(e.filteredRightVariables,function(t){return i("div",{key:t.field,staticClass:"variable-item"},[i("el-checkbox",{on:{change(i){return e.handleRightCheckChange(t)}},model:{value:t.checked,callback(i){e.$set(t,"checked",i)},expression:"item.checked"}},[e.u("\n "+e.m(t.field)+"\n ")])],1)}),0)])])]),e.u(" "),i("div",{staticClass:"right-section"},[i("div",{staticClass:"config-desc"},[e.u("\n 数据文件中因变量的值,需赋予参考值,方便精准进行数据分析。\n ")]),e.u(" "),i("div",{staticClass:"config-options"},e.p(e.flatMenuItems,function(t){return i("div",{key:t.pathString,staticClass:"config-option-row"},[i("span",{staticClass:"option-label",class:{required:t.required}},[e.u("\n "+e.m(t.pathString)+"\n "),t.required?i("span",{staticClass:"required-mark"},[e.u("*")]):e.v()]),e.u(" "),i("el-select",{staticClass:"config-select",attrs:{placeholder:e.getPlaceholder(t),clearable:t.nullable,multiple:t.multiple},on:{change(i){return e.handleConfigChange(t.pathString,i)}},model:{value:e.configValues[t.pathString],callback(i){e.$set(e.configValues,t.pathString,i)},expression:"configValues[menuItem.pathString]"}},e.p(e.getAvailableOptions(t.pathString,t.multiple),function(t){return i("el-option",{key:t.value,class:{"disabled-option":t.disabled},attrs:{label:t.label,value:t.value,disabled:t.disabled}},[i("span",{class:{"disabled-text":t.disabled}},[e.u(e.m(t.label))])])}),1)],1)}),0)])]),e.u(" "),i("div",{staticClass:"dialog-footer",attrs:{slot:"footer"},slot:"footer"},[i("el-button",{on:{click:e.handleClose}},[e.u("取消")]),e.u(" "),i("el-button",{staticStyle:{color:"#fff"},attrs:{type:"primary"},on:{click:e.handleSave}},[e.u("保存")])],1)])],1)},staticRenderFns:[],name:"LongVariableViewer",props:{visible:{type:Boolean,default:!1},values:{type:Array,default(){return[]}},menus:{type:Array,default(){return[]}}},data:()=>({dialogVisible:!1,leftKeyword:"",rightKeyword:"",allVariables:[],selectedVariables:[],configValues:{},configChangeTimer:null}),computed:{filteredLeftVariables(){return this.leftKeyword?this.allVariables.filter(e=>e.field.toLowerCase().includes(this.leftKeyword.toLowerCase())):this.allVariables},filteredRightVariables(){return this.rightKeyword?this.selectedVariables.filter(e=>e.field.toLowerCase().includes(this.rightKeyword.toLowerCase())):this.selectedVariables},selectedAllCount(){return this.allVariables.filter(e=>e.checked).length},selectedRightCount(){return this.selectedVariables.filter(e=>e.checked).length},hasLeftSelected(){return this.allVariables.some(e=>e.checked)},hasRightSelected(){return this.selectedVariables.some(e=>e.checked)},leftSelectAll:{get(){const e=this.filteredLeftVariables;return 0!==e.length&&e.every(e=>e.checked)},set(){}},leftIndeterminate(){const e=this.filteredLeftVariables;if(0===e.length)return!1;const t=e.filter(e=>e.checked).length;return t>0&&t<e.length},rightSelectAll:{get(){const e=this.filteredRightVariables;return 0!==e.length&&e.every(e=>e.checked)},set(){}},rightIndeterminate(){const e=this.filteredRightVariables;if(0===e.length)return!1;const t=e.filter(e=>e.checked).length;return t>0&&t<e.length},flatMenuItems(){if(!this.menus||0===this.menus.length)return[];const e=[],t=(i,a=[])=>{const l=[...a,i.label];if(i.children&&0!==i.children.length)i.children&&i.children.length>0&&i.children.forEach(e=>{t(e,l)});else{const t=l.join("/");e.push({label:i.label,path:l,pathString:t,isLeaf:!0,id:i.id,fieldName:i.fieldName,required:i.required,nullable:i.nullable,multiple:i.multiple,originalMenu:i})}};return this.menus.forEach(e=>{t(e)}),e},tableData(){const e=[];return Object.keys(this.configValues).forEach(t=>{const i=this.configValues[t];if(!i||Array.isArray(i)&&0===i.length)return;const a=this.flatMenuItems.find(e=>e.pathString===t);if(!a)return;const l=a.pathString;(Array.isArray(i)?i:[i]).forEach(t=>{const i=t+"";i&&e.push({field:i,fullPath:l,varType:a.path&&a.path.length>0?a.path[0]:l,attr:a.path&&a.path.length>0?a.path[a.path.length-1]:""})})}),e}},watch:{visible:{handler(e){this.dialogVisible=e},immediate:!0},dialogVisible(e){this.$emit("update:visible",e)},values:{handler(e){this.handleValuesChange(e)},immediate:!0,deep:!0},selectedVariables:{handler(){const e=this.selectedVariables.map(e=>e.field),t={...this.configValues};let i=!1;Object.keys(t).forEach(a=>{const l=t[a];if(Array.isArray(l)){const s=l.filter(t=>e.includes(t));s.length!==l.length&&(t[a]=s,i=!0)}else l&&!e.includes(l)&&(t[a]="",i=!0)}),i&&(this.configValues=t)},deep:!0},configValues:{handler(){this.configChangeTimer&&clearTimeout(this.configChangeTimer),this.configChangeTimer=setTimeout(()=>{this.$nextTick(()=>{this.$emit("config-changed",this.tableData)})},100)},deep:!0}},methods:{handleValuesChange(e){if(!e||0===e.length)return this.allVariables=[],this.selectedVariables=[],void 0;const t=[];if(e.length>0){const i=e[0];"object"==typeof i&&null!==i&&t.push(...Object.keys(i))}this.allVariables=t.map(e=>({field:e,checked:!1})),this.selectedVariables=[]},handleLeftSearch(){},handleRightSearch(){},handleLeftCheckChange(){},handleRightCheckChange(){},handleLeftSelectAll(e){this.filteredLeftVariables.forEach(t=>{t.checked=e})},handleRightSelectAll(e){this.filteredRightVariables.forEach(t=>{t.checked=e})},moveToRight(){const e=this.allVariables.filter(e=>e.checked);0!==e.length&&(e.forEach(e=>{e.checked=!1,this.selectedVariables.find(t=>t.field===e.field)||this.selectedVariables.push({field:e.field,checked:!1})}),this.allVariables=this.allVariables.filter(t=>!e.some(e=>e.field===t.field)))},moveToLeft(){const e=this.selectedVariables.filter(e=>e.checked);0!==e.length&&(e.forEach(e=>{e.checked=!1,this.allVariables.find(t=>t.field===e.field)||this.allVariables.push({field:e.field,checked:!1})}),this.selectedVariables=this.selectedVariables.filter(t=>!e.some(e=>e.field===t.field)))},handleClose(){this.dialogVisible=!1},getPlaceholder:e=>e.required?"必选":e.nullable?"请选择":"必选",getAvailableOptions(e,t=!1){const i=this.selectedVariables.map(e=>e.field),a=this.configValues[e],l=t?Array.isArray(a)?a:[]:a?[a]:[],s=[];return Object.keys(this.configValues).forEach(t=>{if(t!==e&&this.configValues[t]){const e=this.configValues[t];Array.isArray(e)?s.push(...e):s.push(e)}}),i.map(e=>l.includes(e)?{label:e,value:e,disabled:!1}:{label:e,value:e,disabled:s.includes(e)})},handleConfigChange(e,t){this.$set(this.configValues,e,t);const i=this.flatMenuItems.find(t=>t.pathString===e);i&&i.multiple&&!Array.isArray(t)&&this.$set(this.configValues,e,t?[t]:[])},generateConfigFromMenus(){return this.flatMenuItems.forEach(e=>{e.pathString in this.configValues||(e.multiple?this.$set(this.configValues,e.pathString,[]):this.$set(this.configValues,e.pathString,""))}),{...this.configValues}},handleSave(){const e={config:this.generateConfigFromMenus(),selectedVariables:this.selectedVariables.map(e=>e.field)};this.$emit("save",e),this.dialogVisible=!1},$restoreConfig(e){if(!e||"object"!=typeof e)return;const t=new Set;Object.keys(e).forEach(i=>{const a=e[i];a&&a.values&&Array.isArray(a.values)&&a.values.forEach(e=>t.add(e))}),t.forEach(e=>{this.selectedVariables.find(t=>t.field===e)||this.selectedVariables.push({field:e,checked:!1})}),this.configValues={},Object.keys(e).forEach(t=>{const i=e[t];if(!i||!i.values||!Array.isArray(i.values)||0===i.values.length)return;const a=this.flatMenuItems.filter(e=>e.fieldName===t);if(0!==a.length)if(1===a.length){const e=a[0],t=e.pathString;e.multiple?this.$set(this.configValues,t,[...i.values]):this.$set(this.configValues,t,i.values[0])}else{const e=a.filter(e=>!e.multiple),t=a.filter(e=>e.multiple);if(t.length>0){const e=t[0];this.$set(this.configValues,e.pathString,[...i.values])}else e.length>0&&i.values.forEach((t,i)=>{if(i<e.length){const a=e[i];this.$set(this.configValues,a.pathString,t)}})}})},$getValues(){const e={};return Object.keys(this.configValues).forEach(t=>{const i=this.configValues[t];if(!i||Array.isArray(i)&&0===i.length)return;const a=this.flatMenuItems.find(e=>e.pathString===t);if(!a||!a.fieldName)return;const l=a.fieldName;e[l]||(e[l]={values:[]}),(Array.isArray(i)?i:[i]).forEach(t=>{e[l].values.includes(t)||e[l].values.push(t)})}),e},$getTableData(){return this.generateConfigFromMenus(),void 0,this.tableData}},install(e){e.component(n.name,n)}};e(".long-excel-viewer :deep(.el-dialog__body){padding:0 10px 10px}");var d={render(){var e=this,t=e.$createElement,i=e.i.t||t;return i("div",{staticClass:"long-excel-viewer"},[i("el-dialog",{attrs:{visible:e.dialogVisible,title:"示例文件",width:"1000px"},on:{"update:visible"(t){e.dialogVisible=t},close:e.handleClose},scopedSlots:e.k([{key:"title",fn(){return[i("div",{staticStyle:{display:"flex","justify-content":"space-between"}},[i("div",{staticStyle:{display:"flex","align-items":"center",gap:"10px"}},[i("img",{attrs:{src:e.searchIcon}}),e.u(" "),i("div",{staticStyle:{"font-weight":"bold"}},[e.u("文件预览")])]),e.u(" "),i("div",{staticStyle:{"margin-right":"30px"}},[i("el-button",{attrs:{type:"primary",icon:"el-icon-download",size:"mini",disabled:!e.tableData.length||e.downloading,loading:e.downloading},on:{click:e.downloadExcel}},[e.u("下载")])],1)])]},proxy:!0}])},[e.u(" "),e.tableData.length?i("el-table",{staticStyle:{width:"100%","margin-top":"20px"},attrs:{data:e.tableData,border:"",height:"500px"}},e.p(e.columns,function(e){return i("el-table-column",{key:e,attrs:{prop:e,label:e}})}),1):e.v(),e.u(" "),e.pagination.total>0?i("el-pagination",{staticStyle:{"margin-top":"20px","text-align":"center"},attrs:{"current-page":e.pagination.current,"page-sizes":[10,20,50,100],"page-size":e.pagination.pageSize,layout:"total, sizes, prev, pager, next, jumper",total:e.pagination.total},on:{"size-change":e.handleSizeChange,"current-change":e.handleCurrentChange}}):e.v()],1)],1)},staticRenderFns:[],name:"LongExcelViewer",props:{visible:{type:Boolean,default:!1},url:{type:String,default:""}},data:()=>({searchIcon:s,tableData:[],columns:[],rawWorkbook:null,downloading:!1,VUE_APP_BASE_API:process.env.VUE_APP_BASE_API,pagination:{total:0,current:1,pageSize:20},queryParams:{fileId:"",pageNum:1,pageSize:20}}),computed:{dialogVisible:{get(){return this.visible},set(e){this.$emit("update:visible",e)}}},watch:{visible(e){e&&this.url&&this.loadExcelFromUrl()},url(e){e&&this.visible&&this.loadExcelFromUrl()}},methods:{async loadExcelFromUrl(){if(!this.url)return;const e=this.url.split("/").pop();this.queryParams.fileId=e;try{const e=await this.$api.dataAnalysis.filePreview(this.queryParams);void 0,e&&e.data&&e.data.records&&Array.isArray(e.data.records)?(this.processTableData(e.data.records),this.pagination.total=e.data.total||0,this.pagination.current=e.data.current||1,this.pagination.pageSize=e.data.size||20):this.$message.error("数据格式错误")}catch(t){void 0,this.$message.error("加载Excel文件失败: "+t.message)}},processTableData(e){const t=e[0];t&&t.headers&&t.data&&(1==this.pagination.current&&(this.columns=t.headers||[]),this.tableData=t.data||[])},processWorkbook(e){this.rawWorkbook=e;const t=e.Sheets[e.SheetNames[0]],a=i.sheet_to_json(t,{header:1});a.length&&(this.columns=a[0],this.tableData=a.slice(1).map(e=>{const t={};return this.columns.forEach((i,a)=>{t[i]=e[a]}),t}))},handleFileChange(e){const t=new FileReader;return t.onload=e=>{const t=new Uint8Array(e.target.result),i=a(t,{type:"array"});this.processWorkbook(i)},t.readAsArrayBuffer(e.raw),!1},downloadExcel(){if(!this.url||this.downloading)return;this.downloading=!0;const e=require("axios").create({baseURL:this.VUE_APP_BASE_API,timeout:3e4,responseType:"blob"});e.interceptors.request.use(e=>{const t=this.$store.getters.token||localStorage.getItem("token");return t&&(e.headers.Authorization="Bearer "+t),e}),e.interceptors.response.use(e=>("blob"===e.config.responseType,e),e=>Promise.reject(e));const t=this.url.split("/").pop();e.get("/file/upload/"+t).then(e=>{const t=e.data;let i="示例文件.xlsx";const a=e.headers["content-disposition"];if(a){const e=a.match(/filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/);if(e&&e[1]){i=e[1].replace(/['"]/g,"");try{i=decodeURIComponent(i)}catch(s){void 0}}}l(t,i),this.$message.success("下载成功")}).catch(e=>{void 0,this.$message.error("下载失败,请重试")}).finally(()=>{this.downloading=!1})},closeDialog(){this.dialogVisible=!1},handleClose(){this.closeDialog(),this.tableData=[],this.columns=[],this.rawWorkbook=null},handleSizeChange(e){this.queryParams.pageSize=e,this.queryParams.pageNum=1,this.loadExcelFromUrl()},handleCurrentChange(e){this.queryParams.pageNum=e,this.loadExcelFromUrl()}},install(e){e.component(d.name,d)}};e("");var c={render(){var e=this,t=e.$createElement,i=e.i.t||t;return i("div",[i("el-button",{attrs:{size:"small",type:"primary",icon:"el-icon-setting"},on:{click:e.onAdjust}},[e.u("\n 调整变量\n ")]),e.u(" "),i("long-variable-viewer",{ref:"variableViewerRef",attrs:{visible:e.modalVisiable,values:e.values,menus:e.menus},on:{"update:visible"(t){e.modalVisiable=t},"config-changed":e.handleConfigChanged}})],1)},staticRenderFns:[],name:"LongVariableViewerButton",props:{values:{type:Array,default(){return[]}},menus:{type:Array,default(){return[]}}},data:()=>({modalVisiable:!1,tableDataCache:[],updateTimer:null,valuesUpdateTimer:null,menusUpdateTimer:null,updatingTableData:!1}),mounted(){void 0,this.$nextTick(()=>{this.updateTableData()})},beforeDestroy(){this.updateTimer&&clearInterval(this.updateTimer),this.valuesUpdateTimer&&clearTimeout(this.valuesUpdateTimer),this.menusUpdateTimer&&clearTimeout(this.menusUpdateTimer)},watch:{modalVisiable(e){e||(this.$emit("update:columns",this.$refs.variableViewerRef.$getValues()),this.$nextTick(()=>{this.updateTableData()}))},values:{handler(){this.valuesUpdateTimer&&clearTimeout(this.valuesUpdateTimer),this.valuesUpdateTimer=setTimeout(()=>{this.updateTableData()},300)},deep:!0},menus:{handler(){this.menusUpdateTimer&&clearTimeout(this.menusUpdateTimer),this.menusUpdateTimer=setTimeout(()=>{this.updateTableData()},300)},deep:!0}},computed:{tableData(){return this.tableDataCache}},methods:{onAdjust(){this.modalVisiable=!0},$getValues(){return this.$refs.variableViewerRef.$getValues()},$triggerUpdate(){this.$emit("update:columns",this.$getValues()),this.$nextTick(()=>{this.updateTableData()})},$restoreConfig(e){this.$refs.variableViewerRef&&this.$refs.variableViewerRef.$restoreConfig&&(this.$refs.variableViewerRef.$restoreConfig(e),this.$nextTick(()=>{this.updateTableData()}))},handleConfigChanged(e){Array.isArray(e)&&(this.tableDataCache=e,this.$emit("table-data-updated",e))},updateTableData(){if(!this.updatingTableData)if(this.updatingTableData=!0,this.$refs.variableViewerRef&&this.$refs.variableViewerRef.$getTableData){const e=this.$refs.variableViewerRef.$getTableData()||[],t=JSON.parse(JSON.stringify(e)),i=JSON.parse(JSON.stringify(this.tableDataCache));JSON.stringify(t)!==JSON.stringify(i)?(this.tableDataCache=e,this.$nextTick(()=>{this.$emit("table-data-updated",e),this.updatingTableData=!1})):this.updatingTableData=!1}else this.tableDataCache.length>0&&(this.tableDataCache=[]),this.updatingTableData=!1}},install(e){e.component(c.name,c)}};e("");var p={render(){var e=this,t=e.$createElement,i=e.i.t||t;return i("div",{staticStyle:{display:"inline-block","margin-left":"4px"},on:{click(e){e.stopPropagation()}}},[i("el-button",{attrs:{type:"text",size:"small",icon:"el-icon-document"},on:{click:e.onExample}},[e.u("示例文件")]),e.u(" "),i("long-excel-viewer",{attrs:{visible:e.modalVisiable,url:e.url},on:{"update:visible"(t){e.modalVisiable=t}}})],1)},staticRenderFns:[],name:"LongExcelViewerButton",props:{url:{type:String,default:""}},data:()=>({modalVisiable:!1}),methods:{onExample(e){e.stopPropagation(),e.preventDefault(),this.modalVisiable=!0}},install(e){e.component(p.name,p)}};e(".long-uploader-wrapper .el-form-item{margin-bottom:0}.long-uploader-wrapper :deep(.el-upload) .el-upload-dragger{height:130px!important}.long-uploader-wrapper :deep(.el-upload) .el-upload-dragger .el-icon-upload{margin:8px 0}.variable-config-section{background-color:#f8f9fa;border:1px solid #e9ecef;border-radius:4px;margin-top:16px}.config-header{align-items:center;background-color:#e8e9f2;border-bottom:1px solid #e9ecef;cursor:pointer;display:flex;justify-content:space-between;padding:0 12px;transition:background-color .2s}.config-header:hover{background-color:#f0f0f0}.config-title{color:#303133;font-size:14px;margin:0}.collapse-arrow{color:#909399;font-size:12px;transition:transform .3s ease}.collapse-arrow.is-collapsed{transform:rotate(-90deg)}.config-content{padding:12px}.variable-config-section .el-table{font-size:12px}.variable-config-section .el-table th{background-color:#f5f7fa;color:#606266;font-weight:600}.variable-config-section .el-table td{padding:8px 0}.no-data{color:#909399;font-size:14px;padding:20px;text-align:center}");var h={render(){var e=this,t=e.$createElement,i=e.i.t||t;return i("div",{staticClass:"long-uploader-wrapper"},[i("div",[i("div",{staticStyle:{float:"right","margin-top":"-80px"}},[e.options.example&&e.options.example.value?i("long-excel-viewer-button",{attrs:{url:e.options.example.value}}):e.v()],1),e.u(" "),i("div",{staticStyle:{display:"flex","align-items":"center","justify-content":"space-between","margin-bottom":"12px"}},[i("div",{staticStyle:{display:"flex","align-items":"center",gap:"12px",position:"relative"}},[i("el-upload",{attrs:{action:e.uploadUrl,headers:{Authorization:"Bearer "+e.token},"on-preview":e.handlePreview,"on-remove":e.handleRemove,"before-remove":e.beforeRemove,"on-change":e.handleChange,"before-upload":e.beforeUpload,accept:e.fileType,drag:"","on-exceed":e.handleExceed,"file-list":e.fileList}},[i("i",{staticClass:"el-icon-upload",staticStyle:{color:"#6C1537"}}),e.u(" "),i("div",{staticClass:"el-upload__text"},[i("div",{staticStyle:{"line-height":"18px"}},[e.u("将文件拖到此处,或"),i("em",[e.u("点击上传")])]),e.u(" "),i("div",{staticStyle:{"line-height":"18px"}},[e.u("\n 支持上传"),i("em",[e.u("xlsx")]),e.u("、"),i("em",[e.u("xls")]),e.u("、"),i("em",[e.u("csv")])])])])],1)]),e.u(" "),e.fileList.length>0?i("div",{staticStyle:{"margin-top":"-20px"}},[e.C(0),e.u(" "),i("div",[e.p(e.fileList,function(t){return i("el-tag",{key:t.uid,staticStyle:{"margin-right":"8px",cursor:"pointer"},attrs:{closable:""},on:{close(i){return e.handleRemove(t)},click(i){return e.handleFileClick(t)}}},[e.u("\n "+e.m(t.name)+"\n ")])}),e.u(" "),e.fileList.length>0&&e.options.variable&&e.options.variable.enable?i("div",{staticStyle:{display:"flex","align-items":"center"}},[i("span",{staticStyle:{color:"#f56c6c","margin-right":"5px"}},[e.u("*")]),e.u(" "),i("long-variable-viewer-button",{ref:"variableViewerRef",attrs:{values:e.fileData,menus:e.options.variable.menus},on:{"update:columns":e.handleUpdateColumns,"table-data-updated":e.handleTableDataUpdated}})],1):e.v()],2)]):e.v()]),e.u(" "),e.fileList.length>0&&e.options.variable&&e.options.variable.enable&&e.hasConfiguredVariables?i("div",{staticClass:"variable-config-section"},[i("div",{staticClass:"config-header",on:{click:e.toggleCollapse}},[i("span",{staticClass:"config-title"},[e.u("当前变量配置")]),e.u(" "),i("i",{staticClass:"el-icon-caret-bottom collapse-arrow",class:{"is-collapsed":e.isCollapsed}})]),e.u(" "),i("div",{directives:[{name:"show",rawName:"v-show",value:!e.isCollapsed,expression:"!isCollapsed"}],staticClass:"config-content"},[0===e.currentVariableValues.length?i("div",{staticClass:"no-data"},[e.u("\n 暂无数据\n ")]):i("el-table",{staticStyle:{width:"100%"},attrs:{data:e.currentVariableValues,size:"mini","max-height":"300",border:""}},[i("el-table-column",{attrs:{prop:"field",label:"字段名","show-overflow-tooltip":""}}),e.u(" "),i("el-table-column",{attrs:{prop:"fullPath",label:"属性","show-overflow-tooltip":""}})],1),e.u(" "),i("div",{staticClass:"debug-info",staticStyle:{"margin-top":"8px","font-size":"12px",color:"#999"}},[e.u("\n 数据条数: "+e.m(e.currentVariableValues.length)+"\n ")])],1)]):e.v(),e.u(" "),i("long-excel-viewer",{attrs:{visible:e.previewVisible,url:e.previewUrl},on:{"update:visible"(t){e.previewVisible=t}}})],1)},staticRenderFns:[function(){var e=this,t=e.$createElement,i=e.i.t||t;return i("div",{staticStyle:{"font-size":"12px",color:"#999","line-height":"20px"}},[i("i",{staticClass:"el-icon-info",staticStyle:{"margin-right":"5px"}}),e.u(" "),i("span",[e.u("点击文件名称可预览文件")])])}],name:"LongUploader",props:{options:{type:Object,default(){return{variable:{enable:!1,values:[],menus:[]},example:{value:""},file:{id:"",name:""}}}},value:{type:Object,default(){return{fileId:"",columns:[],fileName:""}}},fileId:{type:String,default:""},limit:{type:Number,default:1},fileSize:{type:Number,default:3},fileType:{type:String,default:".xlsx,.xls,.csv"}},data:()=>({uploadUrl:process.env.VUE_APP_BASE_API+"/file/upload",fileList:[],token:"",fileData:[],fileToken:"",variableViewerRef:null,isCollapsed:!0,hasTriggerUpdate:!1,previewVisible:!1,previewUrl:"",tableDataCache:[]}),computed:{currentVariableValues(){return this.tableDataCache.map(e=>({field:e.field||"",fullPath:e.fullPath||"",varType:e.varType||"",attr:e.attr||""}))},hasConfiguredVariables(){return this.currentVariableValues.length>0}},created(){this.token=localStorage.getItem("token")},watch:{fileId:{handler(e){this.fileToken=e},immediate:!0,deep:!0},value:{handler(e,t){void 0,!e||!e.fileId||t&&t.fileId===e.fileId||(this.fileToken=e.fileId,this.downloadFile(e.fileId,e.columns||{})),!e||!e.fileName||t&&t.fileName===e.fileName||(this.fileList=[{name:e.fileName,uid:e.fileId}])},immediate:!0,deep:!0}},methods:{downloadFile(e,t={}){this.$api.dataAnalysis.filePreview({fileId:e}).then(e=>{if(e&&e.data&&e.data.records&&e.data.records.length>0){const i=e.data.records[0].headers||[];this.$emit("update:headers",i);const a=this.options.variable.menus||[],l={};i.forEach(e=>{l[e]={field:e,varType:"",attr:""}}),t&&"object"==typeof t&&Object.keys(t).forEach(e=>{const i=t[e];if(void 0,i&&i.values&&Array.isArray(i.values)){const t=a.find(t=>t.fieldName===e);void 0,t&&i.values.forEach(i=>{l[i]&&(l[i]={field:i,varType:t.label||e,attr:t.label||e})})}}),this.fileData=[{...l}],this.$nextTick(()=>{if(this.$refs.variableViewerRef&&t&&Object.keys(t).length>0&&"function"==typeof this.$refs.variableViewerRef.$restoreConfig&&(this.$refs.variableViewerRef.$restoreConfig(t),this.$nextTick(()=>{this.$refs.variableViewerRef&&"function"==typeof this.$refs.variableViewerRef.updateTableData&&this.$refs.variableViewerRef.updateTableData()})),this.$route.query.id){if(this.hasTriggerUpdate)return;"function"==typeof this.$refs.variableViewerRef.$triggerUpdate&&this.$refs.variableViewerRef.$triggerUpdate(),this.hasTriggerUpdate=!0}})}}).catch(e=>{this.$message.error(e.message||"数据文件内容不匹配,请重新上传")}).finally(()=>{this.loading=!1})},handleColumns(e=[]){const t=this.options.variable.menus||[];void 0,0!=t.length&&e.forEach(e=>{void 0;const i=t.find(t=>t.fieldName==e.fieldName);void 0,e.varType=i.label,e.attr=i.attr})},handleTableDataUpdated(e){Array.isArray(e)&&(this.tableDataCache=e)},handleUpdateColumns(e){void 0,this.$emit("update:columns",e)},beforeUpload(e){if(void 0,e.size>1048576*this.fileSize)return this.$message.error(`上传文件大小不能超过 ${this.fileSize} MB!`),!1;const t=e.type,i=e.name.toLowerCase();return!!(["application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/vnd.ms-excel","text/csv"].includes(t)||i.endsWith(".xlsx")||i.endsWith(".xls")||i.endsWith(".csv"))||(this.$message.error("只支持上传 xlsx、xls、csv 格式的文件!"),!1)},handleChange(e,t){if(t.length>1?this.fileList=[t[t.length-1]]:this.fileList=t.filter(e=>void 0!==e.raw),"success"===e.status){const t=e.response;t&&200===t.code&&(this.fileToken=t.data.id,this.$emit("update:fileId",this.fileToken),this.loadFromUrl(this.fileToken))}},loadFromUrl(e){this.$api.dataAnalysis.filePreview({fileId:e}).then(e=>{if(e&&e.data&&e.data.records&&e.data.records.length>0){const t=(e.data.records[0]||{data:[],headers:[]}).headers||[];if(t.length>0){this.$emit("update:headers",t);const e={};t.forEach(t=>{e[t]={field:t,varType:"",attr:""}}),this.fileData=[{...e}]}else this.$emit("update:headers",[]),this.fileData=[]}})},handleRemove(e){this.fileList=this.fileList.filter(t=>t.uid!==e.uid),this.fileToken="",this.fileData=[],this.$emit("update:fileId",""),this.$emit("update:headers",[])},onAdjust(){this.$emit("adjust")},handleRemove1(e,t){void 0},handlePreview(e){void 0},handleExceed(e,t){this.$message.warning(`上传文件数量不能超过 ${this.limit} 个!`),t.length>this.limit&&(this.fileList=t.slice(-this.limit))},beforeRemove:()=>!0,toggleCollapse(){this.isCollapsed=!this.isCollapsed},handleFileClick(){event.stopPropagation(),this.fileToken?(this.previewUrl=`${process.env.VUE_APP_BASE_API}/file/preview/${this.fileToken}`,this.previewVisible=!0):this.$message.warning("文件ID不存在,无法预览")}},install(e){e.component(h.name,h)}};e(".long-radio-wrapper{display:flex;flex-wrap:wrap}.long-radio-wrapper ::v-deep .el-radio{line-height:24px;margin-bottom:0}.long-radio-wrapper ::v-deep .el-radio__label{display:inline-block;vertical-align:middle;white-space:normal;word-break:break-all}.long-radio-item{margin:4px 12px 4px 0;width:100px}");var u={render(){var e=this,t=e.$createElement,i=e.i.t||t;return i("el-radio-group",e.l(e.o({staticClass:"long-radio-wrapper"},"el-radio-group",e.$attrs,!1),e.$listeners),e.p(e.options,function(t,a){return i("el-radio",{key:a,staticClass:"long-radio-item",attrs:{label:t[e.valueKey],disabled:t[e.disabledOption]}},[e.u("\n "+e.m(t[e.labelKey])+"\n ")])}),1)},staticRenderFns:[],name:"LongRadio",props:{dataList:{type:Array,default(){return[]}},disabledOption:{type:[Boolean,Number],default:!1},valueKey:{type:[String,Number],default:"value"},labelKey:{type:[String,Number],default:"label"},mode:{type:String,default:"local"},dict:{type:String,default:""},url:{type:String,default:""},requestParams:{type:Object,default(){}},placeholder:{type:String,default:"请选择"}},data:()=>({options:[]}),watch:{dataList:{deep:!0,immediate:!0,handler(e){"local"===this.mode&&(this.options=e)}},dict:{deep:!0,handler(e){this.init()}}},created(){this.init()},methods:{init(){"remote"===this.mode&&this.dict&&this.getDicts(this.dict).then(e=>{this.options=(e.data||[]).map(e=>({[this.valueKey]:e.dictCode,[this.labelKey]:e.dictLabel}))})}},install(e){e.component(u.name,u)}};e(".long-group{background-color:#f8f8f8;box-sizing:border-box;height:100%;padding:10px;width:100%}.long-group .group-header{color:#333;font-size:14px;font-weight:700}");var f={render(){var e=this,t=e.$createElement,i=e.i.t||t;return i("div",{staticClass:"long-group"},[i("div",{staticClass:"group-header"},[e.u(e.m(e.label))]),e.u(" "),e.h("default")],2)},staticRenderFns:[],name:"LongGroup",props:{label:{type:String,default:""}},install(e){e.component(f.name,f)}};e(".long-color-picker{width:200px}.long-color-picker .el-color-picker__trigger{width:100%}.long-color-picker .el-color-picker__trigger .el-color-picker__icon{left:unset!important;right:5px!important;width:unset!important}");var g={render(){var e=this,t=e.$createElement;return(e.i.t||t)("el-color-picker",e.l(e.o({staticClass:"long-color-picker"},"el-color-picker",e.$attrs,!1),e.$listeners))},staticRenderFns:[],name:"LongColorPicker",install(e){e.component(g.name,g)}};e("");var b={render(){var e=this,t=e.$createElement;return(e.i.t||t)("el-input-number",e.l(e.o({staticClass:"long-number-input",attrs:{"controls-position":"right",step:e.stepValue,value:e.value,max:e.maxValue,min:e.minValue},on:{input(t){return e.$emit("input",t)}}},"el-input-number",e.$attrs,!1),e.$listeners))},staticRenderFns:[],name:"LongNumberInput",props:{value:{type:[String,Number],default:0},placeholder:{type:String,default:"请输入"},max:{type:[Number,String],default:""},min:{type:[Number,String],default:""},step:{type:[Number,String],default:1}},data(){return{maxValue:""===this.max?Number.MAX_SAFE_INTEGER:+this.max,minValue:""===this.min?Number.MIN_SAFE_INTEGER:+this.min,stepValue:+this.step}},watch:{max:{handler(e){this.maxValue=""===e?Number.MAX_SAFE_INTEGER:+e},immediate:!0},min:{handler(e){this.minValue=""===e?Number.MIN_SAFE_INTEGER:+e},immediate:!0},step:{handler(e){this.stepValue=+e},immediate:!0}},install(e){e.component(b.name,b)}};e(".long-checkbox-wrapper{display:flex;flex-wrap:wrap}.long-checkbox-wrapper ::v-deep .el-checkbox{line-height:24px;margin-bottom:0}.long-checkbox-item{margin:1px 6px 1px 0;min-width:50px}");var m={render(){var e=this,t=e.$createElement,i=e.i.t||t;return i("el-checkbox-group",e.l(e.o({staticClass:"long-checkbox-wrapper",attrs:{value:e.value},on:{change:e.handleInput}},"el-checkbox-group",e.$attrs,!1),e.$listeners),e.p(e.options,function(t,a){return i("el-checkbox",{key:a,staticClass:"long-checkbox-item",attrs:{label:t[e.valueKey],disabled:e.getDisabled(t)}},[e.u("\n "+e.m(t[e.labelKey])+"\n ")])}),1)},staticRenderFns:[],name:"LongCheckBox",props:{value:{type:Array,default(){return[]}},dataList:{type:Array,default(){return[]}},disabledOption:{type:[String,Boolean,Number],default:!1},valueKey:{type:[String,Number],default:"value"},labelKey:{type:[String,Number],default:"label"},mode:{type:String,default:"local"},dict:{type:String,default:""},url:{type:String,default:""},requestParams:{type:Object,default(){}},placeholder:{type:String,default:"请选择"}},data:()=>({options:[]}),watch:{dataList:{deep:!0,immediate:!0,handler(e){"local"===this.mode&&(this.options=e)}},dict:{deep:!0,handler(e){this.init()}}},created(){this.init()},methods:{init(){"remote"===this.mode&&this.dict&&this.getDicts(this.dict).then(e=>{this.options=(e.data||[]).map(e=>({[this.valueKey]:e.dictCode,[this.labelKey]:e.dictLabel}))})},handleInput(e){this.$emit("input",e),this.$emit("change",e)},getDisabled(e){return"string"==typeof this.disabledOption?e[this.disabledOption]||!1:"boolean"==typeof this.disabledOption?this.disabledOption:"number"==typeof this.disabledOption&&e[this.disabledOption]||!1}},install(e){e.component(m.name,m)}},x=[r,o,n,d,c,p,h,u,f,g,b,m],v=function(e){if(!v.installed){v.installed=!0;var i=["ElInput","ElSelect","ElOption","ElCheckbox","ElCheckboxGroup","ElRadio","ElRadioGroup","ElButton","ElDialog","ElTable","ElTableColumn","ElUpload","ElTag","ElPagination","ElInputNumber","ElColorPicker","ElForm","ElFormItem","ElIcon"];i.forEach(function(i){var a=e.options.components[i];if(!a){var l=t(i);a=e.options.components[l]}if(a){var s=t(i);s&&s!==i&&(e.options.components[s]||e.component(s,a)),e.options.components[i]||e.component(i,a)}else"production"!==process.env.NODE_ENV,0}),e.nextTick(function(){i.forEach(function(i){var a=e.options.components[i];if(a){var l=t(i);l&&l!==i&&(e.options.components[l]||e.component(l,a))}})}),x.forEach(function(i){if(i){var a=i.name||i.options&&i.options.name;if(a){e.component(a,i);var l=t(a);l&&l!==a&&e.component(l,i)}}})}};"undefined"!=typeof window&&window.Vue&&v(window.Vue);var y={version:"1.0.0",install:v,Input:r,Select:o,VariableViewer:n,ExcelViewer:d,VariableViewerButton:c,ExcelViewerButton:p,Uploader:h,Radio:u,Group:f,ColorPicker:g,NumberInput:b,CheckBox:m};export{m as CheckBox,g as ColorPicker,d as ExcelViewer,p as ExcelViewerButton,f as Group,r as Input,b as NumberInput,u as Radio,o as Select,h as Uploader,n as VariableViewer,c as VariableViewerButton,y as default};
1
+ import{utils,read}from"xlsx";import{saveAs}from"file-saver";function styleInject(css,ref){if(void 0===ref)ref={};var insertAt=ref.insertAt;if(!css||"undefined"===typeof document)return;var head=document.head||document.getElementsByTagName("head")[0];var style=document.createElement("style");style.type="text/css";if("top"===insertAt)if(head.firstChild)head.insertBefore(style,head.firstChild);else head.appendChild(style);else head.appendChild(style);if(style.styleSheet)style.styleSheet.cssText=css;else style.appendChild(document.createTextNode(css))}var css_248z$b=".long-input-wrapper{background-color:#fff;border:1px solid #e0e0e0;border-radius:4px;padding:8px}.intTxt{width:80%}";styleInject(css_248z$b);var Input={render:function(){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c("el-input",_vm._g(_vm._b({staticClass:"intTxt",attrs:{"show-word-limit":_vm.showWordLimit,placeholder:_vm.placeholder,"auto-complete":"new-password",disabled:_vm.disabled},on:{input:function($event){return _vm.$emit("input",$event)}}},"el-input",_vm.$attrs,false),_vm.$listeners),[_vm._l(Object.keys(this.$slots),function(name){return _vm._t(name,null,{slot:name})})],2)},staticRenderFns:[],name:"LongInput",props:{showWordLimit:{type:Boolean,default:true},disabled:{type:Boolean,default:false},placeholder:{type:String,default:"请输入"}}};Input.install=function install(Vue){Vue.component(Input.name,Input)};var css_248z$a="";styleInject(css_248z$a);var Select={render:function(){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c("el-select",_vm._g(_vm._b({attrs:{value:_vm.value,placeholder:_vm.placeholder}},"el-select",_vm.$attrs,false),_vm.$listeners),[_vm._t("unshift"),_vm._v(" "),_vm._t("default",function(){return _vm._l(_vm.options,function(item,index){return _c("el-option",{key:index,attrs:{value:item[_vm.valueKey],label:item[_vm.labelKey],disabled:item[_vm.disabledOption]}})})},{slot:"default"}),_vm._v(" "),_vm._t("prefix",null,{slot:"prefix"}),_vm._v(" "),_vm._t("empty",null,{slot:"empty"})],2)},staticRenderFns:[],name:"LongSelect",props:{value:{type:[String,Number],default:""},dataList:{type:Array,default:()=>[]},disabledOption:{type:[Boolean,Number],default:false},valueKey:{type:[String,Number],default:"value"},labelKey:{type:[String,Number],default:"label"},mode:{type:String,default:"local"},dict:{type:String,default:""},url:{type:String,default:""},requestParams:{type:Object,default:()=>{}},placeholder:{type:String,default:"请选择"}},data:()=>({options:[]}),watch:{dataList:{deep:true,immediate:true,handler(val){if("local"===this.mode)this.options=val}},dict:{deep:true,handler(val){this.init()}}},created(){this.init()},methods:{init(){if("remote"===this.mode&&this.dict)this.getDicts(this.dict).then(res=>{this.options=(res.data||[]).map(item=>({[this.valueKey]:item.dictCode,[this.labelKey]:item.dictLabel}))})}}};Select.install=function install(Vue){Vue.component(Select.name,Select)};var css_248z$9=".variable-config-dialog :deep(.el-dialog__body){padding:20px}.variable-config-dialog :deep(.el-dialog__header){padding:20px 20px 10px}.dialog-title{align-items:center;color:#303133;display:flex;font-size:16px;font-weight:700;gap:24px;padding:0 20px}.dialog-title .title-left{color:#303133;flex:1;min-width:500px}.dialog-title .title-separator{color:#dcdfe6;flex-shrink:0;font-weight:400}.dialog-title .title-right{color:#303133;flex:1;min-width:400px}.dialog-body{display:flex;gap:24px;min-height:500px}.left-section{flex:1;min-width:500px}.section-title{color:#303133;font-size:16px;font-weight:700;margin-bottom:16px}.variable-selector{align-items:flex-start;display:flex;gap:16px}.variable-panel{border:1px solid #dcdfe6;border-radius:4px;display:flex;flex:1;flex-direction:column;height:500px;overflow:hidden}.panel-header{align-items:center;background:#f5f7fa;border-bottom:1px solid #dcdfe6;display:flex;justify-content:space-between;padding:12px 16px}.select-all-checkbox :deep(.el-checkbox__label){padding-left:8px}.panel-title{color:#303133;font-weight:500}.panel-count{color:#909399;font-size:12px}.panel-search{border-bottom:1px solid #dcdfe6;padding:12px}.panel-list{flex:1;overflow-y:auto;padding:8px}.variable-item{border-radius:4px;cursor:pointer;padding:8px 12px;transition:background-color .2s}.variable-item:hover{background-color:#f5f7fa}.variable-item :deep(.el-checkbox){width:100%}.variable-item :deep(.el-checkbox__label){width:100%}.arrow-buttons{display:flex;flex-direction:column;gap:12px;justify-content:center;padding-top:100px}.arrow-buttons .el-button{margin-left:0!important}.right-section{display:flex;flex:1;flex-direction:column;min-width:400px;overflow:hidden}.config-desc{color:#909399;flex-shrink:0;font-size:13px;line-height:1.5;margin-bottom:24px}.config-group{margin-bottom:32px}.config-group:last-child{margin-bottom:0}.config-label{color:#303133;font-size:14px;font-weight:500;margin-bottom:12px}.config-options{display:flex;flex:1;flex-direction:column;gap:16px;margin-top:16px;overflow-x:hidden;overflow-y:auto;padding-right:8px}.config-options::-webkit-scrollbar{width:6px}.config-options::-webkit-scrollbar-track{background:#f1f1f1;border-radius:3px}.config-options::-webkit-scrollbar-thumb{background:#c1c1c1;border-radius:3px}.config-options::-webkit-scrollbar-thumb:hover{background:#a8a8a8}.config-option-row{align-items:center;display:flex;gap:12px;margin-bottom:8px}.config-option-row.is-parent .option-label{color:#303133;font-weight:500}.config-option-row.is-leaf .option-label{color:#606266}.option-label{color:#606266;flex:1;font-size:13px;min-width:0;white-space:normal;word-break:break-all}.option-label.required{color:#303133;font-weight:500}.option-label .required-mark{color:#f56c6c;margin-left:2px}.config-select{flex-shrink:0;width:350px}.non-leaf-label{color:#909399;font-size:13px;font-style:italic}.disabled-option{cursor:not-allowed!important}.disabled-option,.disabled-text{color:#c0c4cc!important}:deep(.el-select-dropdown__item.is-disabled){color:#c0c4cc!important;cursor:not-allowed!important}:deep(.el-select-dropdown__item.is-disabled) span{color:#c0c4cc!important}.checkbox-list{border:1px solid #dcdfe6;border-radius:4px;display:flex;flex:1;flex-direction:column;gap:8px;max-height:200px;overflow-y:auto;padding:8px}.dialog-footer{text-align:right}";styleInject(css_248z$9);var VariableViewer={render:function(){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c("div",[_c("el-dialog",{staticClass:"variable-config-dialog",staticStyle:{"max-height":"90vh"},attrs:{visible:_vm.dialogVisible,width:"1200px"},on:{"update:visible":function($event){_vm.dialogVisible=$event},close:_vm.handleClose}},[_c("div",{staticClass:"dialog-title",attrs:{slot:"title"},slot:"title"},[_c("span",{staticClass:"title-left"},[_vm._v("选择分析变量")]),_vm._v(" "),_c("span",{staticClass:"title-separator"},[_vm._v("|")]),_vm._v(" "),_c("span",{staticClass:"title-right"},[_vm._v("配置变量")])]),_vm._v(" "),_c("div",{staticClass:"dialog-body"},[_c("div",{staticClass:"left-section"},[_c("div",{staticClass:"variable-selector"},[_c("div",{staticClass:"variable-panel"},[_c("div",{staticClass:"panel-header"},[_c("el-checkbox",{staticClass:"select-all-checkbox",attrs:{indeterminate:_vm.leftIndeterminate},on:{change:_vm.handleLeftSelectAll},model:{value:_vm.leftSelectAll,callback:function($$v){_vm.leftSelectAll=$$v},expression:"leftSelectAll"}},[_c("span",{staticClass:"panel-title"},[_vm._v("全选")])]),_vm._v(" "),_c("span",{staticClass:"panel-count"},[_vm._v(_vm._s(_vm.selectedAllCount)+"/"+_vm._s(_vm.allVariables.length))])],1),_vm._v(" "),_c("div",{staticClass:"panel-search"},[_c("el-input",{attrs:{placeholder:"请输入关键字","suffix-icon":"el-icon-search",size:"small"},on:{input:_vm.handleLeftSearch},model:{value:_vm.leftKeyword,callback:function($$v){_vm.leftKeyword=$$v},expression:"leftKeyword"}})],1),_vm._v(" "),_c("div",{staticClass:"panel-list"},_vm._l(_vm.filteredLeftVariables,function(item){return _c("div",{key:item.field,staticClass:"variable-item"},[_c("el-checkbox",{on:{change:function($event){return _vm.handleLeftCheckChange(item)}},model:{value:item.checked,callback:function($$v){_vm.$set(item,"checked",$$v)},expression:"item.checked"}},[_vm._v("\n "+_vm._s(item.field)+"\n ")])],1)}),0)]),_vm._v(" "),_c("div",{staticClass:"arrow-buttons"},[_c("el-button",{attrs:{type:"primary",icon:"el-icon-arrow-right",size:"small",disabled:!_vm.hasLeftSelected},on:{click:_vm.moveToRight}}),_vm._v(" "),_c("el-button",{attrs:{type:"danger",icon:"el-icon-arrow-left",size:"small",disabled:!_vm.hasRightSelected},on:{click:_vm.moveToLeft}})],1),_vm._v(" "),_c("div",{staticClass:"variable-panel"},[_c("div",{staticClass:"panel-header"},[_c("el-checkbox",{staticClass:"select-all-checkbox",attrs:{indeterminate:_vm.rightIndeterminate},on:{change:_vm.handleRightSelectAll},model:{value:_vm.rightSelectAll,callback:function($$v){_vm.rightSelectAll=$$v},expression:"rightSelectAll"}},[_c("span",{staticClass:"panel-title"},[_vm._v("已选")])]),_vm._v(" "),_c("span",{staticClass:"panel-count"},[_vm._v(_vm._s(_vm.selectedRightCount)+"/"+_vm._s(_vm.selectedVariables.length))])],1),_vm._v(" "),_c("div",{staticClass:"panel-search"},[_c("el-input",{attrs:{placeholder:"请输入关键字","suffix-icon":"el-icon-search",size:"small"},on:{input:_vm.handleRightSearch},model:{value:_vm.rightKeyword,callback:function($$v){_vm.rightKeyword=$$v},expression:"rightKeyword"}})],1),_vm._v(" "),_c("div",{staticClass:"panel-list"},_vm._l(_vm.filteredRightVariables,function(item){return _c("div",{key:item.field,staticClass:"variable-item"},[_c("el-checkbox",{on:{change:function($event){return _vm.handleRightCheckChange(item)}},model:{value:item.checked,callback:function($$v){_vm.$set(item,"checked",$$v)},expression:"item.checked"}},[_vm._v("\n "+_vm._s(item.field)+"\n ")])],1)}),0)])])]),_vm._v(" "),_c("div",{staticClass:"right-section"},[_c("div",{staticClass:"config-desc"},[_vm._v("\n 数据文件中因变量的值,需赋予参考值,方便精准进行数据分析。\n ")]),_vm._v(" "),_c("div",{staticClass:"config-options"},_vm._l(_vm.flatMenuItems,function(menuItem){return _c("div",{key:menuItem.pathString,staticClass:"config-option-row"},[_c("span",{staticClass:"option-label",class:{required:menuItem.required}},[_vm._v("\n "+_vm._s(menuItem.pathString)+"\n "),menuItem.required?_c("span",{staticClass:"required-mark"},[_vm._v("*")]):_vm._e()]),_vm._v(" "),_c("el-select",{staticClass:"config-select",attrs:{placeholder:_vm.getPlaceholder(menuItem),clearable:menuItem.nullable,multiple:menuItem.multiple},on:{change:function($event){return _vm.handleConfigChange(menuItem.pathString,$event)}},model:{value:_vm.configValues[menuItem.pathString],callback:function($$v){_vm.$set(_vm.configValues,menuItem.pathString,$$v)},expression:"configValues[menuItem.pathString]"}},_vm._l(_vm.getAvailableOptions(menuItem.pathString,menuItem.multiple),function(option){return _c("el-option",{key:option.value,class:{"disabled-option":option.disabled},attrs:{label:option.label,value:option.value,disabled:option.disabled}},[_c("span",{class:{"disabled-text":option.disabled}},[_vm._v(_vm._s(option.label))])])}),1)],1)}),0)])]),_vm._v(" "),_c("div",{staticClass:"dialog-footer",attrs:{slot:"footer"},slot:"footer"},[_c("el-button",{on:{click:_vm.handleClose}},[_vm._v("取消")]),_vm._v(" "),_c("el-button",{staticStyle:{color:"#fff"},attrs:{type:"primary"},on:{click:_vm.handleSave}},[_vm._v("保存")])],1)])],1)},staticRenderFns:[],name:"LongVariableViewer",props:{visible:{type:Boolean,default:false},values:{type:Array,default:()=>[]},menus:{type:Array,default:()=>[]}},data:()=>({dialogVisible:false,leftKeyword:"",rightKeyword:"",allVariables:[],selectedVariables:[],configValues:{},configChangeTimer:null}),computed:{filteredLeftVariables(){if(!this.leftKeyword)return this.allVariables;return this.allVariables.filter(item=>item.field.toLowerCase().includes(this.leftKeyword.toLowerCase()))},filteredRightVariables(){if(!this.rightKeyword)return this.selectedVariables;return this.selectedVariables.filter(item=>item.field.toLowerCase().includes(this.rightKeyword.toLowerCase()))},selectedAllCount(){return this.allVariables.filter(item=>item.checked).length},selectedRightCount(){return this.selectedVariables.filter(item=>item.checked).length},hasLeftSelected(){return this.allVariables.some(item=>item.checked)},hasRightSelected(){return this.selectedVariables.some(item=>item.checked)},leftSelectAll:{get(){const filtered=this.filteredLeftVariables;if(0===filtered.length)return false;return filtered.every(item=>item.checked)},set(){}},leftIndeterminate(){const filtered=this.filteredLeftVariables;if(0===filtered.length)return false;const checkedCount=filtered.filter(item=>item.checked).length;return checkedCount>0&&checkedCount<filtered.length},rightSelectAll:{get(){const filtered=this.filteredRightVariables;if(0===filtered.length)return false;return filtered.every(item=>item.checked)},set(){}},rightIndeterminate(){const filtered=this.filteredRightVariables;if(0===filtered.length)return false;const checkedCount=filtered.filter(item=>item.checked).length;return checkedCount>0&&checkedCount<filtered.length},flatMenuItems(){if(!this.menus||0===this.menus.length)return[];const result=[];const traverse=(menu,parentPath=[])=>{const currentPath=[...parentPath,menu.label];const isLeaf=!menu.children||0===menu.children.length;if(isLeaf){const pathString=currentPath.join("/");result.push({label:menu.label,path:currentPath,pathString,isLeaf:true,id:menu.id,fieldName:menu.fieldName,required:menu.required,nullable:menu.nullable,multiple:menu.multiple,originalMenu:menu})}else if(menu.children&&menu.children.length>0)menu.children.forEach(child=>{traverse(child,currentPath)})};this.menus.forEach(menu=>{traverse(menu)});return result},tableData(){const result=[];Object.keys(this.configValues).forEach(pathString=>{const value=this.configValues[pathString];if(!value||Array.isArray(value)&&0===value.length)return;const menuItem=this.flatMenuItems.find(item=>item.pathString===pathString);if(!menuItem)return;const fullPath=menuItem.pathString;const fields=Array.isArray(value)?value:[value];fields.forEach(field=>{const fieldName=String(field);if(!fieldName)return;result.push({field:fieldName,fullPath,varType:menuItem.path&&menuItem.path.length>0?menuItem.path[0]:fullPath,attr:menuItem.path&&menuItem.path.length>0?menuItem.path[menuItem.path.length-1]:""})})});return result}},watch:{visible:{handler(val){this.dialogVisible=val},immediate:true},dialogVisible(val){this.$emit("update:visible",val)},values:{handler(val){this.handleValuesChange(val)},immediate:true,deep:true},selectedVariables:{handler(){const selectedFields=this.selectedVariables.map(item=>item.field);const newConfigValues={...this.configValues};let hasChange=false;Object.keys(newConfigValues).forEach(key=>{const value=newConfigValues[key];if(Array.isArray(value)){const filtered=value.filter(v=>selectedFields.includes(v));if(filtered.length!==value.length){newConfigValues[key]=filtered;hasChange=true}}else if(value&&!selectedFields.includes(value)){newConfigValues[key]="";hasChange=true}});if(hasChange)this.configValues=newConfigValues},deep:true},configValues:{handler(){if(this.configChangeTimer)clearTimeout(this.configChangeTimer);this.configChangeTimer=setTimeout(()=>{this.$nextTick(()=>{this.$emit("config-changed",this.tableData)})},100)},deep:true}},methods:{handleValuesChange(val){if(!val||0===val.length){this.allVariables=[];this.selectedVariables=[];return}const fields=[];if(val.length>0){const firstRow=val[0];if("object"===typeof firstRow&&null!==firstRow)fields.push(...Object.keys(firstRow))}this.allVariables=fields.map(field=>({field,checked:false}));this.selectedVariables=[]},handleLeftSearch(){},handleRightSearch(){},handleLeftCheckChange(){},handleRightCheckChange(){},handleLeftSelectAll(val){this.filteredLeftVariables.forEach(item=>{item.checked=val})},handleRightSelectAll(val){this.filteredRightVariables.forEach(item=>{item.checked=val})},moveToRight(){const selectedItems=this.allVariables.filter(item=>item.checked);if(0===selectedItems.length)return;selectedItems.forEach(item=>{item.checked=false;if(!this.selectedVariables.find(v=>v.field===item.field))this.selectedVariables.push({field:item.field,checked:false})});this.allVariables=this.allVariables.filter(item=>!selectedItems.some(selected=>selected.field===item.field))},moveToLeft(){const selectedItems=this.selectedVariables.filter(item=>item.checked);if(0===selectedItems.length)return;selectedItems.forEach(item=>{item.checked=false;if(!this.allVariables.find(v=>v.field===item.field))this.allVariables.push({field:item.field,checked:false})});this.selectedVariables=this.selectedVariables.filter(item=>!selectedItems.some(selected=>selected.field===item.field))},handleClose(){this.dialogVisible=false},getPlaceholder(menuItem){if(menuItem.required)return"必选";return menuItem.nullable?"请选择":"必选"},getAvailableOptions(pathString,isMultiple=false){const allSelectedFields=this.selectedVariables.map(item=>item.field);const currentValue=this.configValues[pathString];const currentValues=isMultiple?Array.isArray(currentValue)?currentValue:[]:currentValue?[currentValue]:[];const otherSelectedValues=[];Object.keys(this.configValues).forEach(key=>{if(key!==pathString&&this.configValues[key]){const value=this.configValues[key];if(Array.isArray(value))otherSelectedValues.push(...value);else otherSelectedValues.push(value)}});return allSelectedFields.map(field=>{if(currentValues.includes(field))return{label:field,value:field,disabled:false};return{label:field,value:field,disabled:otherSelectedValues.includes(field)}})},handleConfigChange(pathString,value){this.$set(this.configValues,pathString,value);const menuItem=this.flatMenuItems.find(item=>item.pathString===pathString);if(menuItem&&menuItem.multiple&&!Array.isArray(value))this.$set(this.configValues,pathString,value?[value]:[])},generateConfigFromMenus(){this.flatMenuItems.forEach(menuItem=>{if(!(menuItem.pathString in this.configValues))if(menuItem.multiple)this.$set(this.configValues,menuItem.pathString,[]);else this.$set(this.configValues,menuItem.pathString,"")});return{...this.configValues}},handleSave(){const config=this.generateConfigFromMenus();const result={config,selectedVariables:this.selectedVariables.map(item=>item.field)};this.$emit("save",result);this.dialogVisible=false},$restoreConfig(columns){if(!columns||"object"!==typeof columns)return;const allFields=new Set;Object.keys(columns).forEach(fieldName=>{const columnData=columns[fieldName];if(columnData&&columnData.values&&Array.isArray(columnData.values))columnData.values.forEach(field=>allFields.add(field))});allFields.forEach(field=>{if(!this.selectedVariables.find(item=>item.field===field))this.selectedVariables.push({field,checked:false})});this.configValues={};Object.keys(columns).forEach(fieldName=>{const columnData=columns[fieldName];if(!columnData||!columnData.values||!Array.isArray(columnData.values)||0===columnData.values.length)return;const menuItems=this.flatMenuItems.filter(item=>item.fieldName===fieldName);if(0===menuItems.length)return;if(1===menuItems.length){const menuItem=menuItems[0];const pathString=menuItem.pathString;if(menuItem.multiple)this.$set(this.configValues,pathString,[...columnData.values]);else this.$set(this.configValues,pathString,columnData.values[0])}else{const singleSelectItems=menuItems.filter(item=>!item.multiple);const multiSelectItems=menuItems.filter(item=>item.multiple);if(multiSelectItems.length>0){const menuItem=multiSelectItems[0];this.$set(this.configValues,menuItem.pathString,[...columnData.values])}else if(singleSelectItems.length>0)columnData.values.forEach((value,index)=>{if(index<singleSelectItems.length){const menuItem=singleSelectItems[index];this.$set(this.configValues,menuItem.pathString,value)}})}})},$getValues(){const result={};Object.keys(this.configValues).forEach(pathString=>{const value=this.configValues[pathString];if(!value||Array.isArray(value)&&0===value.length)return;const menuItem=this.flatMenuItems.find(item=>item.pathString===pathString);if(!menuItem||!menuItem.fieldName)return;const fieldName=menuItem.fieldName;if(!result[fieldName])result[fieldName]={values:[]};const fields=Array.isArray(value)?value:[value];fields.forEach(field=>{if(!result[fieldName].values.includes(field))result[fieldName].values.push(field)})});return result},$getTableData(){this.generateConfigFromMenus();const data=this.tableData;console.log("VariableViewer - $getTableData - configValues:",this.configValues);console.log("VariableViewer - $getTableData - tableData:",data);return data}}};VariableViewer.install=function install(Vue){Vue.component(VariableViewer.name,VariableViewer)};var css_248z$8=".long-excel-viewer :deep(.el-dialog__body){padding:0 10px 10px}";styleInject(css_248z$8);var ExcelViewer={render:function(){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c("div",{staticClass:"long-excel-viewer"},[_c("el-dialog",{attrs:{visible:_vm.dialogVisible,title:"示例文件",width:"1000px"},on:{"update:visible":function($event){_vm.dialogVisible=$event},close:_vm.handleClose},scopedSlots:_vm._u([{key:"title",fn:function(){return[_c("div",{staticStyle:{display:"flex","justify-content":"space-between"}},[_c("div",{staticStyle:{display:"flex","align-items":"center",gap:"10px"}},[_c("img",{attrs:{src:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAARzQklUCAgICHwIZIgAAALwSURBVFiF7VdNUuJAFP5eY8UAC/EE5gjMDeAE6glGTqDukmxsNyE7hhOIJ9A5gXiCyZxg8ATgYoCkKv1mQRIbTKIEnZrFfFUUvH6P977q7vfTBACOs7wAcE5EFj4PAaCGnlcf6YvkuqEEcPWJgdeglOr6fn2cygLA8d8KDgBCiK+6vAegnQrMfMnMwccHRQcQV6sYZG0SyMDMgb49HwXHiY6IOJ/cRwfbFv8J7BUpbHthCSEeAFgV/AaGMe9KeTirTKBWq50zc5XgANAOw+YxgFsAYI6fiMQIAIjip3cRiOP4uxDioiKBGXP8mApJZo3zDAsJ+H59LOX0cLk020U2eRCiNjOM35P3bH8pAQBInIy3IbAt/t0sAADXXUhAHL3WqMfNrgYAUk5bYdg8FmJV3pnjZ6UwLquu5LphViP1TuW6izNA3BT9UbeVctqKIvMCEOcAWjnmE2Ye9vvmt01F2RFYJboMtr2woqjxI2k2ecEBwCKigeuGd+8m4Hl1CagegNHrj+olWdLKKVYzAAGA++Rbx4nrhmu7WnoHknMeFemjqDkA1orVvWHMe3oK5lTUM9te3KbHVzkLbHthAXz2skIjz9s/3cx/369PDGP+BcAksyTKJrDKBIjEWoFSKr4uspXycKaU6mkEOlJOWzsSUNokRWPfr0/K7JMtz3YnDBudHQnUDl5+c2nwFMysHQ8d7ESAOX7WxDf7hZTTlj72M6+6YmUCSq31iPbqUhYjiswTXTbNZbATgc0zJaLCqrkiJ7S3B43SbCmtA2+Bma+JaJAQ6Lhu+AugU88zAiDtDY0OEW6wXiWHGRXXDaeaMmCm0j5OpH56npkNKo6zfCCiTg65SclTLxvZqMhBEZhp3O8bXX3NcaIBEW87PQWGMe8KZu5Bq1JV0O8bl0nfyH1VMfOYGacb+nYY1u8olWx70SGq5fT+V+6e+/39+yJtkg0WUe2IOX4yzWWQXrhV2248QEtbKvDzaViRaA4APgEw/AN35ky/nKIj9wAAAABJRU5ErkJggg=="}}),_vm._v(" "),_c("div",{staticStyle:{"font-weight":"bold"}},[_vm._v("文件预览")])]),_vm._v(" "),_c("div",{staticStyle:{"margin-right":"30px"}},[_c("el-button",{attrs:{type:"primary",icon:"el-icon-download",size:"mini",disabled:!_vm.tableData.length||_vm.downloading,loading:_vm.downloading},on:{click:_vm.downloadExcel}},[_vm._v("下载")])],1)])]},proxy:true}])},[_vm._v(" "),_vm.tableData.length?_c("el-table",{staticStyle:{width:"100%","margin-top":"20px"},attrs:{data:_vm.tableData,border:"",height:"500px"}},_vm._l(_vm.columns,function(col){return _c("el-table-column",{key:col,attrs:{prop:col,label:col}})}),1):_vm._e(),_vm._v(" "),_vm.pagination.total>0?_c("el-pagination",{staticStyle:{"margin-top":"20px","text-align":"center"},attrs:{"current-page":_vm.pagination.current,"page-sizes":[10,20,50,100],"page-size":_vm.pagination.pageSize,layout:"total, sizes, prev, pager, next, jumper",total:_vm.pagination.total},on:{"size-change":_vm.handleSizeChange,"current-change":_vm.handleCurrentChange}}):_vm._e()],1)],1)},staticRenderFns:[],name:"LongExcelViewer",props:{visible:{type:Boolean,default:false},url:{type:String,default:""}},data:()=>({tableData:[],columns:[],rawWorkbook:null,downloading:false,VUE_APP_BASE_API:process.env.VUE_APP_BASE_API,pagination:{total:0,current:1,pageSize:20},queryParams:{fileId:"",pageNum:1,pageSize:20}}),computed:{dialogVisible:{get(){return this.visible},set(value){this.$emit("update:visible",value)}}},watch:{visible(newVal){if(newVal&&this.url)this.loadExcelFromUrl()},url(newVal){if(newVal&&this.visible)this.loadExcelFromUrl()}},methods:{async loadExcelFromUrl(){if(!this.url)return;const fileId=this.url.split("/").pop();this.queryParams.fileId=fileId;try{const response=await this.$api.dataAnalysis.filePreview(this.queryParams);console.log("response",response);if(response&&response.data&&response.data.records&&Array.isArray(response.data.records)){this.processTableData(response.data.records);this.pagination.total=response.data.total||0;this.pagination.current=response.data.current||1;this.pagination.pageSize=response.data.size||20}else this.$message.error("数据格式错误")}catch(error){console.error("Error loading Excel file from URL:",error);this.$message.error("加载Excel文件失败: "+error.message)}},processTableData(data){const resultData=data[0];if(resultData&&resultData.headers&&resultData.data){if(1==this.pagination.current)this.columns=resultData.headers||[];this.tableData=resultData.data||[]}},processWorkbook(workbook){this.rawWorkbook=workbook;const firstSheet=workbook.Sheets[workbook.SheetNames[0]];const json=utils.sheet_to_json(firstSheet,{header:1});if(json.length){this.columns=json[0];this.tableData=json.slice(1).map(row=>{const obj={};this.columns.forEach((col,idx)=>{obj[col]=row[idx]});return obj})}},handleFileChange(file){const reader=new FileReader;reader.onload=e=>{const data=new Uint8Array(e.target.result);const workbook=read(data,{type:"array"});this.processWorkbook(workbook)};reader.readAsArrayBuffer(file.raw);return false},downloadExcel(){if(!this.url||this.downloading)return;this.downloading=true;const axios=require("axios");const instance=axios.create({baseURL:this.VUE_APP_BASE_API,timeout:3e4,responseType:"blob"});instance.interceptors.request.use(config=>{const token=this.$store.getters.token||localStorage.getItem("token");if(token)config.headers["Authorization"]=`Bearer ${token}`;return config});instance.interceptors.response.use(response=>{if("blob"===response.config.responseType)return response;return response},error=>Promise.reject(error));const fileId=this.url.split("/").pop();instance.get(`/file/upload/${fileId}`).then(response=>{const blob=response.data;let filename="示例文件.xlsx";const contentDisposition=response.headers["content-disposition"];if(contentDisposition){const filenameMatch=contentDisposition.match(/filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/);if(filenameMatch&&filenameMatch[1]){filename=filenameMatch[1].replace(/['"]/g,"");try{filename=decodeURIComponent(filename)}catch(e){console.warn("文件名解码失败:",e)}}}saveAs(blob,filename);this.$message.success("下载成功")}).catch(error=>{console.error("下载失败:",error);this.$message.error("下载失败,请重试")}).finally(()=>{this.downloading=false})},closeDialog(){this.dialogVisible=false},handleClose(){this.closeDialog();this.tableData=[];this.columns=[];this.rawWorkbook=null},handleSizeChange(val){this.queryParams.pageSize=val;this.queryParams.pageNum=1;this.loadExcelFromUrl()},handleCurrentChange(val){this.queryParams.pageNum=val;this.loadExcelFromUrl()}}};ExcelViewer.install=function install(Vue){Vue.component(ExcelViewer.name,ExcelViewer)};var css_248z$7="";styleInject(css_248z$7);var VariableViewerButton={render:function(){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c("div",[_c("el-button",{attrs:{size:"small",type:"primary",icon:"el-icon-setting"},on:{click:_vm.onAdjust}},[_vm._v("\n 调整变量\n ")]),_vm._v(" "),_c("long-variable-viewer",{ref:"variableViewerRef",attrs:{visible:_vm.modalVisiable,values:_vm.values,menus:_vm.menus},on:{"update:visible":function($event){_vm.modalVisiable=$event},"config-changed":_vm.handleConfigChanged}})],1)},staticRenderFns:[],name:"LongVariableViewerButton",props:{values:{type:Array,default:()=>[]},menus:{type:Array,default:()=>[]}},data:()=>({modalVisiable:false,tableDataCache:[],updateTimer:null,valuesUpdateTimer:null,menusUpdateTimer:null,updatingTableData:false}),mounted(){console.log("VariableViewerButton mounted, menus:",this.menus,"values:",this.values);this.$nextTick(()=>{this.updateTableData()})},beforeDestroy(){if(this.updateTimer)clearInterval(this.updateTimer);if(this.valuesUpdateTimer)clearTimeout(this.valuesUpdateTimer);if(this.menusUpdateTimer)clearTimeout(this.menusUpdateTimer)},watch:{modalVisiable(val){if(!val){this.$emit("update:columns",this.$refs.variableViewerRef.$getValues());this.$nextTick(()=>{this.updateTableData()})}},values:{handler(){if(this.valuesUpdateTimer)clearTimeout(this.valuesUpdateTimer);this.valuesUpdateTimer=setTimeout(()=>{this.updateTableData()},300)},deep:true},menus:{handler(){if(this.menusUpdateTimer)clearTimeout(this.menusUpdateTimer);this.menusUpdateTimer=setTimeout(()=>{this.updateTableData()},300)},deep:true}},computed:{tableData(){return this.tableDataCache}},methods:{onAdjust(){this.modalVisiable=true},$getValues(){return this.$refs.variableViewerRef.$getValues()},$triggerUpdate(){this.$emit("update:columns",this.$getValues());this.$nextTick(()=>{this.updateTableData()})},$restoreConfig(columns){if(this.$refs.variableViewerRef&&this.$refs.variableViewerRef.$restoreConfig){this.$refs.variableViewerRef.$restoreConfig(columns);this.$nextTick(()=>{this.updateTableData()})}},handleConfigChanged(tableData){if(Array.isArray(tableData)){this.tableDataCache=tableData;console.log("VariableViewerButton - config changed, tableData:",this.tableDataCache);this.$emit("table-data-updated",tableData)}},updateTableData(){if(this.updatingTableData)return;this.updatingTableData=true;if(this.$refs.variableViewerRef&&this.$refs.variableViewerRef.$getTableData){const newData=this.$refs.variableViewerRef.$getTableData()||[];const cleanNewData=JSON.parse(JSON.stringify(newData));const cleanCache=JSON.parse(JSON.stringify(this.tableDataCache));if(JSON.stringify(cleanNewData)!==JSON.stringify(cleanCache)){this.tableDataCache=newData;console.log("VariableViewerButton - tableData updated:",this.tableDataCache);this.$nextTick(()=>{this.$emit("table-data-updated",newData);this.updatingTableData=false})}else this.updatingTableData=false}else{if(this.tableDataCache.length>0)this.tableDataCache=[];this.updatingTableData=false}}}};VariableViewerButton.install=function install(Vue){Vue.component(VariableViewerButton.name,VariableViewerButton)};var css_248z$6="";styleInject(css_248z$6);var ExcelViewerButton={render:function(){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c("div",{staticStyle:{display:"inline-block","margin-left":"4px"},on:{click:function($event){$event.stopPropagation()}}},[_c("el-button",{attrs:{type:"text",size:"small",icon:"el-icon-document"},on:{click:_vm.onExample}},[_vm._v("示例文件")]),_vm._v(" "),_c("long-excel-viewer",{attrs:{visible:_vm.modalVisiable,url:_vm.url},on:{"update:visible":function($event){_vm.modalVisiable=$event}}})],1)},staticRenderFns:[],name:"LongExcelViewerButton",props:{url:{type:String,default:""}},data:()=>({modalVisiable:false}),methods:{onExample(event){event.stopPropagation();event.preventDefault();this.modalVisiable=true}}};ExcelViewerButton.install=function install(Vue){Vue.component(ExcelViewerButton.name,ExcelViewerButton)};var css_248z$5=".long-uploader-wrapper .el-form-item{margin-bottom:0}.long-uploader-wrapper :deep(.el-upload) .el-upload-dragger{height:130px!important}.long-uploader-wrapper :deep(.el-upload) .el-upload-dragger .el-icon-upload{margin:8px 0}.variable-config-section{background-color:#f8f9fa;border:1px solid #e9ecef;border-radius:4px;margin-top:16px}.config-header{align-items:center;background-color:#e8e9f2;border-bottom:1px solid #e9ecef;cursor:pointer;display:flex;justify-content:space-between;padding:0 12px;transition:background-color .2s}.config-header:hover{background-color:#f0f0f0}.config-title{color:#303133;font-size:14px;margin:0}.collapse-arrow{color:#909399;font-size:12px;transition:transform .3s ease}.collapse-arrow.is-collapsed{transform:rotate(-90deg)}.config-content{padding:12px}.variable-config-section .el-table{font-size:12px}.variable-config-section .el-table th{background-color:#f5f7fa;color:#606266;font-weight:600}.variable-config-section .el-table td{padding:8px 0}.no-data{color:#909399;font-size:14px;padding:20px;text-align:center}";styleInject(css_248z$5);var LongUploader={render:function(){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c("div",{staticClass:"long-uploader-wrapper"},[_c("div",[_c("div",{staticStyle:{float:"right","margin-top":"-80px"}},[_vm.options.example&&_vm.options.example.value?_c("long-excel-viewer-button",{attrs:{url:_vm.options.example.value}}):_vm._e()],1),_vm._v(" "),_c("div",{staticStyle:{display:"flex","align-items":"center","justify-content":"space-between","margin-bottom":"12px"}},[_c("div",{staticStyle:{display:"flex","align-items":"center",gap:"12px",position:"relative"}},[_c("el-upload",{attrs:{action:_vm.uploadUrl,headers:{Authorization:"Bearer "+_vm.token},"on-preview":_vm.handlePreview,"on-remove":_vm.handleRemove,"before-remove":_vm.beforeRemove,"on-change":_vm.handleChange,"before-upload":_vm.beforeUpload,accept:_vm.fileType,drag:"","on-exceed":_vm.handleExceed,"file-list":_vm.fileList}},[_c("i",{staticClass:"el-icon-upload",staticStyle:{color:"#6C1537"}}),_vm._v(" "),_c("div",{staticClass:"el-upload__text"},[_c("div",{staticStyle:{"line-height":"18px"}},[_vm._v("将文件拖到此处,或"),_c("em",[_vm._v("点击上传")])]),_vm._v(" "),_c("div",{staticStyle:{"line-height":"18px"}},[_vm._v("\n 支持上传"),_c("em",[_vm._v("xlsx")]),_vm._v("、"),_c("em",[_vm._v("xls")]),_vm._v("、"),_c("em",[_vm._v("csv")])])])])],1)]),_vm._v(" "),_vm.fileList.length>0?_c("div",{staticStyle:{"margin-top":"-20px"}},[_vm._m(0),_vm._v(" "),_c("div",[_vm._l(_vm.fileList,function(file){return _c("el-tag",{key:file.uid,staticStyle:{"margin-right":"8px",cursor:"pointer"},attrs:{closable:""},on:{close:function($event){return _vm.handleRemove(file)},click:function($event){return _vm.handleFileClick(file)}}},[_vm._v("\n "+_vm._s(file.name)+"\n ")])}),_vm._v(" "),_vm.fileList.length>0&&_vm.options.variable&&_vm.options.variable.enable?_c("div",{staticStyle:{display:"flex","align-items":"center"}},[_c("span",{staticStyle:{color:"#f56c6c","margin-right":"5px"}},[_vm._v("*")]),_vm._v(" "),_c("long-variable-viewer-button",{ref:"variableViewerRef",attrs:{values:_vm.fileData,menus:_vm.options.variable.menus},on:{"update:columns":_vm.handleUpdateColumns,"table-data-updated":_vm.handleTableDataUpdated}})],1):_vm._e()],2)]):_vm._e()]),_vm._v(" "),_vm.fileList.length>0&&_vm.options.variable&&_vm.options.variable.enable&&_vm.hasConfiguredVariables?_c("div",{staticClass:"variable-config-section"},[_c("div",{staticClass:"config-header",on:{click:_vm.toggleCollapse}},[_c("span",{staticClass:"config-title"},[_vm._v("当前变量配置")]),_vm._v(" "),_c("i",{staticClass:"el-icon-caret-bottom collapse-arrow",class:{"is-collapsed":_vm.isCollapsed}})]),_vm._v(" "),_c("div",{directives:[{name:"show",rawName:"v-show",value:!_vm.isCollapsed,expression:"!isCollapsed"}],staticClass:"config-content"},[0===_vm.currentVariableValues.length?_c("div",{staticClass:"no-data"},[_vm._v("\n 暂无数据\n ")]):_c("el-table",{staticStyle:{width:"100%"},attrs:{data:_vm.currentVariableValues,size:"mini","max-height":"300",border:""}},[_c("el-table-column",{attrs:{prop:"field",label:"字段名","show-overflow-tooltip":""}}),_vm._v(" "),_c("el-table-column",{attrs:{prop:"fullPath",label:"属性","show-overflow-tooltip":""}})],1),_vm._v(" "),_c("div",{staticClass:"debug-info",staticStyle:{"margin-top":"8px","font-size":"12px",color:"#999"}},[_vm._v("\n 数据条数: "+_vm._s(_vm.currentVariableValues.length)+"\n ")])],1)]):_vm._e(),_vm._v(" "),_c("long-excel-viewer",{attrs:{visible:_vm.previewVisible,url:_vm.previewUrl},on:{"update:visible":function($event){_vm.previewVisible=$event}}})],1)},staticRenderFns:[function(){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c("div",{staticStyle:{"font-size":"12px",color:"#999","line-height":"20px"}},[_c("i",{staticClass:"el-icon-info",staticStyle:{"margin-right":"5px"}}),_vm._v(" "),_c("span",[_vm._v("点击文件名称可预览文件")])])}],name:"LongUploader",props:{options:{type:Object,default:()=>({variable:{enable:false,values:[],menus:[]},example:{value:""},file:{id:"",name:""}})},value:{type:Object,default:()=>({fileId:"",columns:[],fileName:""})},fileId:{type:String,default:""},limit:{type:Number,default:1},fileSize:{type:Number,default:3},fileType:{type:String,default:".xlsx,.xls,.csv"}},data:()=>({uploadUrl:`${process.env.VUE_APP_BASE_API}/file/upload`,fileList:[],token:"",fileData:[],fileToken:"",variableViewerRef:null,isCollapsed:true,hasTriggerUpdate:false,previewVisible:false,previewUrl:"",tableDataCache:[]}),computed:{currentVariableValues(){return this.tableDataCache.map(item=>({field:item.field||"",fullPath:item.fullPath||"",varType:item.varType||"",attr:item.attr||""}))},hasConfiguredVariables(){return this.currentVariableValues.length>0}},created(){this.token=localStorage.getItem("token")},watch:{fileId:{handler(val){this.fileToken=val},immediate:true,deep:true},value:{handler(val,oldVal){console.log("value",val,oldVal);if(val&&val.fileId&&(!oldVal||oldVal.fileId!==val.fileId)){this.fileToken=val.fileId;this.downloadFile(val.fileId,val.columns||{})}if(val&&val.fileName&&(!oldVal||oldVal.fileName!==val.fileName))this.fileList=[{name:val.fileName,uid:val.fileId}]},immediate:true,deep:true}},methods:{downloadFile(fileId,columns={}){this.$api.dataAnalysis.filePreview({fileId}).then(res=>{if(res&&res.data&&res.data.records&&res.data.records.length>0){const headers=res.data.records[0].headers||[];this.$emit("update:headers",headers);const menus=this.options.variable.menus||[];const obj={};headers.forEach(o=>{obj[o]={field:o,varType:"",attr:""}});console.log("Parsing columns:",columns);if(columns&&"object"===typeof columns)Object.keys(columns).forEach(columnKey=>{const columnData=columns[columnKey];console.log(`Processing column ${columnKey}:`,columnData);if(columnData&&columnData.values&&Array.isArray(columnData.values)){const menu=menus.find(menu=>menu.fieldName===columnKey);console.log(`Found menu for ${columnKey}:`,menu);if(menu)columnData.values.forEach(fieldName=>{if(obj[fieldName]){obj[fieldName]={field:fieldName,varType:menu.label||columnKey,attr:menu.label||columnKey};console.log(`Set field ${fieldName} with varType: ${menu.label||columnKey}`)}})}});this.fileData=[{...obj}];console.log("Final fileData:",this.fileData);this.$nextTick(()=>{if(this.$refs.variableViewerRef&&columns&&Object.keys(columns).length>0)if("function"===typeof this.$refs.variableViewerRef.$restoreConfig){this.$refs.variableViewerRef.$restoreConfig(columns);this.$nextTick(()=>{if(this.$refs.variableViewerRef&&"function"===typeof this.$refs.variableViewerRef.updateTableData)this.$refs.variableViewerRef.updateTableData()})}const id=this.$route.query.id;if(id){if(this.hasTriggerUpdate)return;if("function"===typeof this.$refs.variableViewerRef.$triggerUpdate)this.$refs.variableViewerRef.$triggerUpdate();this.hasTriggerUpdate=true}})}}).catch(err=>{this.$message.error(err.message||"数据文件内容不匹配,请重新上传");console.log("err",err)}).finally(()=>{this.loading=false})},handleColumns(fileData=[]){const menus=this.options.variable.menus||[];console.log("menus",menus);if(0==menus.length)return;fileData.forEach(item=>{console.log("item",item);const menu=menus.find(menu=>menu.fieldName==item.fieldName);console.log("menu",menu);item.varType=menu.label;item.attr=menu.attr})},handleTableDataUpdated(tableData){if(Array.isArray(tableData)){this.tableDataCache=tableData;console.log("Uploader - tableDataCache updated from event:",this.tableDataCache)}},handleUpdateColumns(columns){console.log("columns",columns);this.$emit("update:columns",columns)},beforeUpload(file){console.log(file);if(file.size>1024*this.fileSize*1024){this.$message.error(`上传文件大小不能超过 ${this.fileSize} MB!`);return false}const allowedTypes=["application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/vnd.ms-excel","text/csv"];const fileType=file.type;const fileName=file.name.toLowerCase();if(!allowedTypes.includes(fileType)&&!fileName.endsWith(".xlsx")&&!fileName.endsWith(".xls")&&!fileName.endsWith(".csv")){this.$message.error("只支持上传 xlsx、xls、csv 格式的文件!");return false}return true},handleChange(file,fileList){if(fileList.length>1)this.fileList=[fileList[fileList.length-1]];else this.fileList=fileList.filter(o=>void 0!==o.raw);console.log("file",file,fileList);if("success"===file.status){const response=file.response;if(response&&200===response.code){this.fileToken=response.data.id;this.$emit("update:fileId",this.fileToken);this.loadFromUrl(this.fileToken)}}},loadFromUrl(fileId){this.$api.dataAnalysis.filePreview({fileId}).then(res=>{if(res&&res.data&&res.data.records&&res.data.records.length>0){const firstRow=res.data.records[0]||{data:[],headers:[]};const headers=firstRow.headers||[];if(headers.length>0){this.$emit("update:headers",headers);const obj={};headers.forEach(o=>{obj[o]={field:o,varType:"",attr:""}});this.fileData=[{...obj}]}else{this.$emit("update:headers",[]);this.fileData=[]}}})},handleRemove(file){this.fileList=this.fileList.filter(f=>f.uid!==file.uid);this.fileToken="";this.fileData=[];this.$emit("update:fileId","");this.$emit("update:headers",[])},onAdjust(){this.$emit("adjust")},handleRemove1(file,fileList){console.log(file,fileList)},handlePreview(file){console.log(file)},handleExceed(files,fileList){this.$message.warning(`上传文件数量不能超过 ${this.limit} 个!`);if(fileList.length>this.limit)this.fileList=fileList.slice(-this.limit)},beforeRemove:()=>true,toggleCollapse(){this.isCollapsed=!this.isCollapsed},handleFileClick(){event.stopPropagation();if(this.fileToken){this.previewUrl=`${process.env.VUE_APP_BASE_API}/file/preview/${this.fileToken}`;this.previewVisible=true}else this.$message.warning("文件ID不存在,无法预览")}}};LongUploader.install=function install(Vue){Vue.component(LongUploader.name,LongUploader)};var css_248z$4=".long-radio-wrapper{display:flex;flex-wrap:wrap}.long-radio-wrapper ::v-deep .el-radio{line-height:24px;margin-bottom:0}.long-radio-wrapper ::v-deep .el-radio__label{display:inline-block;vertical-align:middle;white-space:normal;word-break:break-all}.long-radio-item{margin:4px 12px 4px 0;width:100px}";styleInject(css_248z$4);var Radio={render:function(){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c("el-radio-group",_vm._g(_vm._b({staticClass:"long-radio-wrapper"},"el-radio-group",_vm.$attrs,false),_vm.$listeners),_vm._l(_vm.options,function(item,index){return _c("el-radio",{key:index,staticClass:"long-radio-item",attrs:{label:item[_vm.valueKey],disabled:item[_vm.disabledOption]}},[_vm._v("\n "+_vm._s(item[_vm.labelKey])+"\n ")])}),1)},staticRenderFns:[],name:"LongRadio",props:{dataList:{type:Array,default:()=>[]},disabledOption:{type:[Boolean,Number],default:false},valueKey:{type:[String,Number],default:"value"},labelKey:{type:[String,Number],default:"label"},mode:{type:String,default:"local"},dict:{type:String,default:""},url:{type:String,default:""},requestParams:{type:Object,default:()=>{}},placeholder:{type:String,default:"请选择"}},data:()=>({options:[]}),watch:{dataList:{deep:true,immediate:true,handler(val){if("local"===this.mode)this.options=val}},dict:{deep:true,handler(val){this.init()}}},created(){this.init()},methods:{init(){if("remote"===this.mode&&this.dict)this.getDicts(this.dict).then(res=>{this.options=(res.data||[]).map(item=>({[this.valueKey]:item.dictCode,[this.labelKey]:item.dictLabel}))})}}};Radio.install=function install(Vue){Vue.component(Radio.name,Radio)};var css_248z$3=".long-group{background-color:#f8f8f8;box-sizing:border-box;height:100%;padding:10px;width:100%}.long-group .group-header{color:#333;font-size:14px;font-weight:700}";styleInject(css_248z$3);var Group={render:function(){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c("div",{staticClass:"long-group"},[_c("div",{staticClass:"group-header"},[_vm._v(_vm._s(_vm.label))]),_vm._v(" "),_vm._t("default")],2)},staticRenderFns:[],name:"LongGroup",props:{label:{type:String,default:""}}};Group.install=function install(Vue){Vue.component(Group.name,Group)};var css_248z$2=".long-color-picker{width:200px}.long-color-picker .el-color-picker__trigger{width:100%}.long-color-picker .el-color-picker__trigger .el-color-picker__icon{left:unset!important;right:5px!important;width:unset!important}";styleInject(css_248z$2);var ColorPicker={render:function(){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c("el-color-picker",_vm._g(_vm._b({staticClass:"long-color-picker"},"el-color-picker",_vm.$attrs,false),_vm.$listeners))},staticRenderFns:[],name:"LongColorPicker"};ColorPicker.install=function install(Vue){Vue.component(ColorPicker.name,ColorPicker)};var css_248z$1="";styleInject(css_248z$1);var NumberInput={render:function(){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c("el-input-number",_vm._g(_vm._b({staticClass:"long-number-input",attrs:{"controls-position":"right",step:_vm.stepValue,value:_vm.value,max:_vm.maxValue,min:_vm.minValue},on:{input:function($event){return _vm.$emit("input",$event)}}},"el-input-number",_vm.$attrs,false),_vm.$listeners))},staticRenderFns:[],name:"LongNumberInput",props:{value:{type:[String,Number],default:0},placeholder:{type:String,default:"请输入"},max:{type:[Number,String],default:""},min:{type:[Number,String],default:""},step:{type:[Number,String],default:1}},data(){return{maxValue:""===this.max?Number.MAX_SAFE_INTEGER:Number(this.max),minValue:""===this.min?Number.MIN_SAFE_INTEGER:Number(this.min),stepValue:Number(this.step)}},watch:{max:{handler(val){this.maxValue=""===val?Number.MAX_SAFE_INTEGER:Number(val)},immediate:true},min:{handler(val){this.minValue=""===val?Number.MIN_SAFE_INTEGER:Number(val)},immediate:true},step:{handler(val){this.stepValue=Number(val)},immediate:true}}};NumberInput.install=function install(Vue){Vue.component(NumberInput.name,NumberInput)};var css_248z=".long-checkbox-wrapper{display:flex;flex-wrap:wrap}.long-checkbox-wrapper ::v-deep .el-checkbox{line-height:24px;margin-bottom:0}.long-checkbox-item{margin:1px 6px 1px 0;min-width:50px}";styleInject(css_248z);var CheckBox={render:function(){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c("el-checkbox-group",_vm._g(_vm._b({staticClass:"long-checkbox-wrapper",attrs:{value:_vm.value},on:{change:_vm.handleInput}},"el-checkbox-group",_vm.$attrs,false),_vm.$listeners),_vm._l(_vm.options,function(item,index){return _c("el-checkbox",{key:index,staticClass:"long-checkbox-item",attrs:{label:item[_vm.valueKey],disabled:_vm.getDisabled(item)}},[_vm._v("\n "+_vm._s(item[_vm.labelKey])+"\n ")])}),1)},staticRenderFns:[],name:"LongCheckBox",props:{value:{type:Array,default:()=>[]},dataList:{type:Array,default:()=>[]},disabledOption:{type:[String,Boolean,Number],default:false},valueKey:{type:[String,Number],default:"value"},labelKey:{type:[String,Number],default:"label"},mode:{type:String,default:"local"},dict:{type:String,default:""},url:{type:String,default:""},requestParams:{type:Object,default:()=>{}},placeholder:{type:String,default:"请选择"}},data:()=>({options:[]}),watch:{dataList:{deep:true,immediate:true,handler(val){if("local"===this.mode)this.options=val}},dict:{deep:true,handler(val){this.init()}}},created(){this.init()},methods:{init(){if("remote"===this.mode&&this.dict)this.getDicts(this.dict).then(res=>{this.options=(res.data||[]).map(item=>({[this.valueKey]:item.dictCode,[this.labelKey]:item.dictLabel}))})},handleInput(value){this.$emit("input",value);this.$emit("change",value);console.log(value,999)},getDisabled(item){if("string"===typeof this.disabledOption)return item[this.disabledOption]||false;if("boolean"===typeof this.disabledOption)return this.disabledOption;if("number"===typeof this.disabledOption)return item[this.disabledOption]||false;return false}}};CheckBox.install=function install(Vue){Vue.component(CheckBox.name,CheckBox)};var components=[Input,Select,VariableViewer,ExcelViewer,VariableViewerButton,ExcelViewerButton,LongUploader,Radio,Group,ColorPicker,NumberInput,CheckBox];function toKebabCase(str){if(!str)return str;return str.replace(/([A-Z])/g,"-$1").toLowerCase().replace(/^-/,"")}var _install=function install(Vue){if(_install.installed)return;_install.installed=true;var elementUIComponents=["ElInput","ElSelect","ElOption","ElCheckbox","ElCheckboxGroup","ElRadio","ElRadioGroup","ElButton","ElDialog","ElTable","ElTableColumn","ElUpload","ElTag","ElPagination","ElInputNumber","ElColorPicker","ElForm","ElFormItem","ElIcon"];elementUIComponents.forEach(function(componentName){var component=Vue.options.components[componentName];if(!component){var kebabName=toKebabCase(componentName);component=Vue.options.components[kebabName]}if(component){var _kebabName=toKebabCase(componentName);if(_kebabName&&_kebabName!==componentName)if(!Vue.options.components[_kebabName])Vue.component(_kebabName,component);if(!Vue.options.components[componentName])Vue.component(componentName,component)}else if("production"!==process.env.NODE_ENV)console.warn("[WiserComponents] Element-UI component ".concat(componentName," not found. Make sure Element-UI is installed and registered before using WiserComponents."))});if("function"===typeof Vue.nextTick)Vue.nextTick(function(){elementUIComponents.forEach(function(componentName){var component=Vue.options.components[componentName];if(component){var kebabName=toKebabCase(componentName);if(kebabName&&kebabName!==componentName)if(!Vue.options.components[kebabName])Vue.component(kebabName,component)}})});components.forEach(function(component){if(!component)return;var componentName=component.name||component.options&&component.options.name;if(!componentName)return;Vue.component(componentName,component);var kebabName=toKebabCase(componentName);if(kebabName&&kebabName!==componentName)Vue.component(kebabName,component)})};if("undefined"!==typeof window&&window.Vue)_install(window.Vue);var index={version:"1.0.0",install:_install,Input,Select,VariableViewer,ExcelViewer,VariableViewerButton,ExcelViewerButton,Uploader:LongUploader,Radio,Group,ColorPicker,NumberInput,CheckBox};export{CheckBox,ColorPicker,ExcelViewer,ExcelViewerButton,Group,Input,NumberInput,Radio,Select,LongUploader as Uploader,VariableViewer,VariableViewerButton,index as default};
package/lib/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";function e(e,t){void 0===t&&(t={});var i=t.insertAt;if(e&&"undefined"!=typeof document){var a=document.head||document.getElementsByTagName("head")[0],l=document.createElement("style");l.type="text/css","top"===i&&a.firstChild?a.insertBefore(l,a.firstChild):a.appendChild(l),l.styleSheet?l.styleSheet.cssText=e:l.appendChild(document.createTextNode(e))}}function t(e){return e?e.replace(/([A-Z])/g,"-$1").toLowerCase().replace(/^-/,""):e}Object.defineProperty(exports,"t",{value:!0});var i=require("xlsx"),a=require("file-saver"),l=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(require("@/assets/icon-search.png"));e(".long-input-wrapper{background-color:#fff;border:1px solid #e0e0e0;border-radius:4px;padding:8px}.intTxt{width:80%}");var s={render(){var e=this,t=e.$createElement;return(e.l.i||t)("el-input",e.o(e.p({staticClass:"intTxt",attrs:{"show-word-limit":e.showWordLimit,placeholder:e.placeholder,"auto-complete":"new-password",disabled:e.disabled},on:{input(t){return e.$emit("input",t)}}},"el-input",e.$attrs,!1),e.$listeners),[e.h(Object.keys(this.$slots),function(t){return e.u(t,null,{slot:t})})],2)},staticRenderFns:[],name:"LongInput",props:{showWordLimit:{type:Boolean,default:!0},disabled:{type:Boolean,default:!1},placeholder:{type:String,default:"请输入"}},install(e){e.component(s.name,s)}};e("");var r={render(){var e=this,t=e.$createElement,i=e.l.i||t;return i("el-select",e.o(e.p({attrs:{value:e.value,placeholder:e.placeholder}},"el-select",e.$attrs,!1),e.$listeners),[e.u("unshift"),e.m(" "),e.u("default",function(){return e.h(e.options,function(t,a){return i("el-option",{key:a,attrs:{value:t[e.valueKey],label:t[e.labelKey],disabled:t[e.disabledOption]}})})},{slot:"default"}),e.m(" "),e.u("prefix",null,{slot:"prefix"}),e.m(" "),e.u("empty",null,{slot:"empty"})],2)},staticRenderFns:[],name:"LongSelect",props:{value:{type:[String,Number],default:""},dataList:{type:Array,default(){return[]}},disabledOption:{type:[Boolean,Number],default:!1},valueKey:{type:[String,Number],default:"value"},labelKey:{type:[String,Number],default:"label"},mode:{type:String,default:"local"},dict:{type:String,default:""},url:{type:String,default:""},requestParams:{type:Object,default(){}},placeholder:{type:String,default:"请选择"}},data:()=>({options:[]}),watch:{dataList:{deep:!0,immediate:!0,handler(e){"local"===this.mode&&(this.options=e)}},dict:{deep:!0,handler(e){this.init()}}},created(){this.init()},methods:{init(){"remote"===this.mode&&this.dict&&this.getDicts(this.dict).then(e=>{this.options=(e.data||[]).map(e=>({[this.valueKey]:e.dictCode,[this.labelKey]:e.dictLabel}))})}},install(e){e.component(r.name,r)}};e(".variable-config-dialog :deep(.el-dialog__body){padding:20px}.variable-config-dialog :deep(.el-dialog__header){padding:20px 20px 10px}.dialog-title{align-items:center;color:#303133;display:flex;font-size:16px;font-weight:700;gap:24px;padding:0 20px}.dialog-title .title-left{color:#303133;flex:1;min-width:500px}.dialog-title .title-separator{color:#dcdfe6;flex-shrink:0;font-weight:400}.dialog-title .title-right{color:#303133;flex:1;min-width:400px}.dialog-body{display:flex;gap:24px;min-height:500px}.left-section{flex:1;min-width:500px}.section-title{color:#303133;font-size:16px;font-weight:700;margin-bottom:16px}.variable-selector{align-items:flex-start;display:flex;gap:16px}.variable-panel{border:1px solid #dcdfe6;border-radius:4px;display:flex;flex:1;flex-direction:column;height:500px;overflow:hidden}.panel-header{align-items:center;background:#f5f7fa;border-bottom:1px solid #dcdfe6;display:flex;justify-content:space-between;padding:12px 16px}.select-all-checkbox :deep(.el-checkbox__label){padding-left:8px}.panel-title{color:#303133;font-weight:500}.panel-count{color:#909399;font-size:12px}.panel-search{border-bottom:1px solid #dcdfe6;padding:12px}.panel-list{flex:1;overflow-y:auto;padding:8px}.variable-item{border-radius:4px;cursor:pointer;padding:8px 12px;transition:background-color .2s}.variable-item:hover{background-color:#f5f7fa}.variable-item :deep(.el-checkbox){width:100%}.variable-item :deep(.el-checkbox__label){width:100%}.arrow-buttons{display:flex;flex-direction:column;gap:12px;justify-content:center;padding-top:100px}.arrow-buttons .el-button{margin-left:0!important}.right-section{display:flex;flex:1;flex-direction:column;min-width:400px;overflow:hidden}.config-desc{color:#909399;flex-shrink:0;font-size:13px;line-height:1.5;margin-bottom:24px}.config-group{margin-bottom:32px}.config-group:last-child{margin-bottom:0}.config-label{color:#303133;font-size:14px;font-weight:500;margin-bottom:12px}.config-options{display:flex;flex:1;flex-direction:column;gap:16px;margin-top:16px;overflow-x:hidden;overflow-y:auto;padding-right:8px}.config-options::-webkit-scrollbar{width:6px}.config-options::-webkit-scrollbar-track{background:#f1f1f1;border-radius:3px}.config-options::-webkit-scrollbar-thumb{background:#c1c1c1;border-radius:3px}.config-options::-webkit-scrollbar-thumb:hover{background:#a8a8a8}.config-option-row{align-items:center;display:flex;gap:12px;margin-bottom:8px}.config-option-row.is-parent .option-label{color:#303133;font-weight:500}.config-option-row.is-leaf .option-label{color:#606266}.option-label{color:#606266;flex:1;font-size:13px;min-width:0;white-space:normal;word-break:break-all}.option-label.required{color:#303133;font-weight:500}.option-label .required-mark{color:#f56c6c;margin-left:2px}.config-select{flex-shrink:0;width:350px}.non-leaf-label{color:#909399;font-size:13px;font-style:italic}.disabled-option{cursor:not-allowed!important}.disabled-option,.disabled-text{color:#c0c4cc!important}:deep(.el-select-dropdown__item.is-disabled){color:#c0c4cc!important;cursor:not-allowed!important}:deep(.el-select-dropdown__item.is-disabled) span{color:#c0c4cc!important}.checkbox-list{border:1px solid #dcdfe6;border-radius:4px;display:flex;flex:1;flex-direction:column;gap:8px;max-height:200px;overflow-y:auto;padding:8px}.dialog-footer{text-align:right}");var o={render(){var e=this,t=e.$createElement,i=e.l.i||t;return i("div",[i("el-dialog",{staticClass:"variable-config-dialog",staticStyle:{"max-height":"90vh"},attrs:{visible:e.dialogVisible,width:"1200px"},on:{"update:visible"(t){e.dialogVisible=t},close:e.handleClose}},[i("div",{staticClass:"dialog-title",attrs:{slot:"title"},slot:"title"},[i("span",{staticClass:"title-left"},[e.m("选择分析变量")]),e.m(" "),i("span",{staticClass:"title-separator"},[e.m("|")]),e.m(" "),i("span",{staticClass:"title-right"},[e.m("配置变量")])]),e.m(" "),i("div",{staticClass:"dialog-body"},[i("div",{staticClass:"left-section"},[i("div",{staticClass:"variable-selector"},[i("div",{staticClass:"variable-panel"},[i("div",{staticClass:"panel-header"},[i("el-checkbox",{staticClass:"select-all-checkbox",attrs:{indeterminate:e.leftIndeterminate},on:{change:e.handleLeftSelectAll},model:{value:e.leftSelectAll,callback(t){e.leftSelectAll=t},expression:"leftSelectAll"}},[i("span",{staticClass:"panel-title"},[e.m("全选")])]),e.m(" "),i("span",{staticClass:"panel-count"},[e.m(e.v(e.selectedAllCount)+"/"+e.v(e.allVariables.length))])],1),e.m(" "),i("div",{staticClass:"panel-search"},[i("el-input",{attrs:{placeholder:"请输入关键字","suffix-icon":"el-icon-search",size:"small"},on:{input:e.handleLeftSearch},model:{value:e.leftKeyword,callback(t){e.leftKeyword=t},expression:"leftKeyword"}})],1),e.m(" "),i("div",{staticClass:"panel-list"},e.h(e.filteredLeftVariables,function(t){return i("div",{key:t.field,staticClass:"variable-item"},[i("el-checkbox",{on:{change(i){return e.handleLeftCheckChange(t)}},model:{value:t.checked,callback(i){e.$set(t,"checked",i)},expression:"item.checked"}},[e.m("\n "+e.v(t.field)+"\n ")])],1)}),0)]),e.m(" "),i("div",{staticClass:"arrow-buttons"},[i("el-button",{attrs:{type:"primary",icon:"el-icon-arrow-right",size:"small",disabled:!e.hasLeftSelected},on:{click:e.moveToRight}}),e.m(" "),i("el-button",{attrs:{type:"danger",icon:"el-icon-arrow-left",size:"small",disabled:!e.hasRightSelected},on:{click:e.moveToLeft}})],1),e.m(" "),i("div",{staticClass:"variable-panel"},[i("div",{staticClass:"panel-header"},[i("el-checkbox",{staticClass:"select-all-checkbox",attrs:{indeterminate:e.rightIndeterminate},on:{change:e.handleRightSelectAll},model:{value:e.rightSelectAll,callback(t){e.rightSelectAll=t},expression:"rightSelectAll"}},[i("span",{staticClass:"panel-title"},[e.m("已选")])]),e.m(" "),i("span",{staticClass:"panel-count"},[e.m(e.v(e.selectedRightCount)+"/"+e.v(e.selectedVariables.length))])],1),e.m(" "),i("div",{staticClass:"panel-search"},[i("el-input",{attrs:{placeholder:"请输入关键字","suffix-icon":"el-icon-search",size:"small"},on:{input:e.handleRightSearch},model:{value:e.rightKeyword,callback(t){e.rightKeyword=t},expression:"rightKeyword"}})],1),e.m(" "),i("div",{staticClass:"panel-list"},e.h(e.filteredRightVariables,function(t){return i("div",{key:t.field,staticClass:"variable-item"},[i("el-checkbox",{on:{change(i){return e.handleRightCheckChange(t)}},model:{value:t.checked,callback(i){e.$set(t,"checked",i)},expression:"item.checked"}},[e.m("\n "+e.v(t.field)+"\n ")])],1)}),0)])])]),e.m(" "),i("div",{staticClass:"right-section"},[i("div",{staticClass:"config-desc"},[e.m("\n 数据文件中因变量的值,需赋予参考值,方便精准进行数据分析。\n ")]),e.m(" "),i("div",{staticClass:"config-options"},e.h(e.flatMenuItems,function(t){return i("div",{key:t.pathString,staticClass:"config-option-row"},[i("span",{staticClass:"option-label",class:{required:t.required}},[e.m("\n "+e.v(t.pathString)+"\n "),t.required?i("span",{staticClass:"required-mark"},[e.m("*")]):e.k()]),e.m(" "),i("el-select",{staticClass:"config-select",attrs:{placeholder:e.getPlaceholder(t),clearable:t.nullable,multiple:t.multiple},on:{change(i){return e.handleConfigChange(t.pathString,i)}},model:{value:e.configValues[t.pathString],callback(i){e.$set(e.configValues,t.pathString,i)},expression:"configValues[menuItem.pathString]"}},e.h(e.getAvailableOptions(t.pathString,t.multiple),function(t){return i("el-option",{key:t.value,class:{"disabled-option":t.disabled},attrs:{label:t.label,value:t.value,disabled:t.disabled}},[i("span",{class:{"disabled-text":t.disabled}},[e.m(e.v(t.label))])])}),1)],1)}),0)])]),e.m(" "),i("div",{staticClass:"dialog-footer",attrs:{slot:"footer"},slot:"footer"},[i("el-button",{on:{click:e.handleClose}},[e.m("取消")]),e.m(" "),i("el-button",{staticStyle:{color:"#fff"},attrs:{type:"primary"},on:{click:e.handleSave}},[e.m("保存")])],1)])],1)},staticRenderFns:[],name:"LongVariableViewer",props:{visible:{type:Boolean,default:!1},values:{type:Array,default(){return[]}},menus:{type:Array,default(){return[]}}},data:()=>({dialogVisible:!1,leftKeyword:"",rightKeyword:"",allVariables:[],selectedVariables:[],configValues:{},configChangeTimer:null}),computed:{filteredLeftVariables(){return this.leftKeyword?this.allVariables.filter(e=>e.field.toLowerCase().includes(this.leftKeyword.toLowerCase())):this.allVariables},filteredRightVariables(){return this.rightKeyword?this.selectedVariables.filter(e=>e.field.toLowerCase().includes(this.rightKeyword.toLowerCase())):this.selectedVariables},selectedAllCount(){return this.allVariables.filter(e=>e.checked).length},selectedRightCount(){return this.selectedVariables.filter(e=>e.checked).length},hasLeftSelected(){return this.allVariables.some(e=>e.checked)},hasRightSelected(){return this.selectedVariables.some(e=>e.checked)},leftSelectAll:{get(){const e=this.filteredLeftVariables;return 0!==e.length&&e.every(e=>e.checked)},set(){}},leftIndeterminate(){const e=this.filteredLeftVariables;if(0===e.length)return!1;const t=e.filter(e=>e.checked).length;return t>0&&t<e.length},rightSelectAll:{get(){const e=this.filteredRightVariables;return 0!==e.length&&e.every(e=>e.checked)},set(){}},rightIndeterminate(){const e=this.filteredRightVariables;if(0===e.length)return!1;const t=e.filter(e=>e.checked).length;return t>0&&t<e.length},flatMenuItems(){if(!this.menus||0===this.menus.length)return[];const e=[],t=(i,a=[])=>{const l=[...a,i.label];if(i.children&&0!==i.children.length)i.children&&i.children.length>0&&i.children.forEach(e=>{t(e,l)});else{const t=l.join("/");e.push({label:i.label,path:l,pathString:t,isLeaf:!0,id:i.id,fieldName:i.fieldName,required:i.required,nullable:i.nullable,multiple:i.multiple,originalMenu:i})}};return this.menus.forEach(e=>{t(e)}),e},tableData(){const e=[];return Object.keys(this.configValues).forEach(t=>{const i=this.configValues[t];if(!i||Array.isArray(i)&&0===i.length)return;const a=this.flatMenuItems.find(e=>e.pathString===t);if(!a)return;const l=a.pathString;(Array.isArray(i)?i:[i]).forEach(t=>{const i=t+"";i&&e.push({field:i,fullPath:l,varType:a.path&&a.path.length>0?a.path[0]:l,attr:a.path&&a.path.length>0?a.path[a.path.length-1]:""})})}),e}},watch:{visible:{handler(e){this.dialogVisible=e},immediate:!0},dialogVisible(e){this.$emit("update:visible",e)},values:{handler(e){this.handleValuesChange(e)},immediate:!0,deep:!0},selectedVariables:{handler(){const e=this.selectedVariables.map(e=>e.field),t={...this.configValues};let i=!1;Object.keys(t).forEach(a=>{const l=t[a];if(Array.isArray(l)){const s=l.filter(t=>e.includes(t));s.length!==l.length&&(t[a]=s,i=!0)}else l&&!e.includes(l)&&(t[a]="",i=!0)}),i&&(this.configValues=t)},deep:!0},configValues:{handler(){this.configChangeTimer&&clearTimeout(this.configChangeTimer),this.configChangeTimer=setTimeout(()=>{this.$nextTick(()=>{this.$emit("config-changed",this.tableData)})},100)},deep:!0}},methods:{handleValuesChange(e){if(!e||0===e.length)return this.allVariables=[],this.selectedVariables=[],void 0;const t=[];if(e.length>0){const i=e[0];"object"==typeof i&&null!==i&&t.push(...Object.keys(i))}this.allVariables=t.map(e=>({field:e,checked:!1})),this.selectedVariables=[]},handleLeftSearch(){},handleRightSearch(){},handleLeftCheckChange(){},handleRightCheckChange(){},handleLeftSelectAll(e){this.filteredLeftVariables.forEach(t=>{t.checked=e})},handleRightSelectAll(e){this.filteredRightVariables.forEach(t=>{t.checked=e})},moveToRight(){const e=this.allVariables.filter(e=>e.checked);0!==e.length&&(e.forEach(e=>{e.checked=!1,this.selectedVariables.find(t=>t.field===e.field)||this.selectedVariables.push({field:e.field,checked:!1})}),this.allVariables=this.allVariables.filter(t=>!e.some(e=>e.field===t.field)))},moveToLeft(){const e=this.selectedVariables.filter(e=>e.checked);0!==e.length&&(e.forEach(e=>{e.checked=!1,this.allVariables.find(t=>t.field===e.field)||this.allVariables.push({field:e.field,checked:!1})}),this.selectedVariables=this.selectedVariables.filter(t=>!e.some(e=>e.field===t.field)))},handleClose(){this.dialogVisible=!1},getPlaceholder:e=>e.required?"必选":e.nullable?"请选择":"必选",getAvailableOptions(e,t=!1){const i=this.selectedVariables.map(e=>e.field),a=this.configValues[e],l=t?Array.isArray(a)?a:[]:a?[a]:[],s=[];return Object.keys(this.configValues).forEach(t=>{if(t!==e&&this.configValues[t]){const e=this.configValues[t];Array.isArray(e)?s.push(...e):s.push(e)}}),i.map(e=>l.includes(e)?{label:e,value:e,disabled:!1}:{label:e,value:e,disabled:s.includes(e)})},handleConfigChange(e,t){this.$set(this.configValues,e,t);const i=this.flatMenuItems.find(t=>t.pathString===e);i&&i.multiple&&!Array.isArray(t)&&this.$set(this.configValues,e,t?[t]:[])},generateConfigFromMenus(){return this.flatMenuItems.forEach(e=>{e.pathString in this.configValues||(e.multiple?this.$set(this.configValues,e.pathString,[]):this.$set(this.configValues,e.pathString,""))}),{...this.configValues}},handleSave(){const e={config:this.generateConfigFromMenus(),selectedVariables:this.selectedVariables.map(e=>e.field)};this.$emit("save",e),this.dialogVisible=!1},$restoreConfig(e){if(!e||"object"!=typeof e)return;const t=new Set;Object.keys(e).forEach(i=>{const a=e[i];a&&a.values&&Array.isArray(a.values)&&a.values.forEach(e=>t.add(e))}),t.forEach(e=>{this.selectedVariables.find(t=>t.field===e)||this.selectedVariables.push({field:e,checked:!1})}),this.configValues={},Object.keys(e).forEach(t=>{const i=e[t];if(!i||!i.values||!Array.isArray(i.values)||0===i.values.length)return;const a=this.flatMenuItems.filter(e=>e.fieldName===t);if(0!==a.length)if(1===a.length){const e=a[0],t=e.pathString;e.multiple?this.$set(this.configValues,t,[...i.values]):this.$set(this.configValues,t,i.values[0])}else{const e=a.filter(e=>!e.multiple),t=a.filter(e=>e.multiple);if(t.length>0){const e=t[0];this.$set(this.configValues,e.pathString,[...i.values])}else e.length>0&&i.values.forEach((t,i)=>{if(i<e.length){const a=e[i];this.$set(this.configValues,a.pathString,t)}})}})},$getValues(){const e={};return Object.keys(this.configValues).forEach(t=>{const i=this.configValues[t];if(!i||Array.isArray(i)&&0===i.length)return;const a=this.flatMenuItems.find(e=>e.pathString===t);if(!a||!a.fieldName)return;const l=a.fieldName;e[l]||(e[l]={values:[]}),(Array.isArray(i)?i:[i]).forEach(t=>{e[l].values.includes(t)||e[l].values.push(t)})}),e},$getTableData(){return this.generateConfigFromMenus(),void 0,this.tableData}},install(e){e.component(o.name,o)}};e(".long-excel-viewer :deep(.el-dialog__body){padding:0 10px 10px}");var n={render(){var e=this,t=e.$createElement,i=e.l.i||t;return i("div",{staticClass:"long-excel-viewer"},[i("el-dialog",{attrs:{visible:e.dialogVisible,title:"示例文件",width:"1000px"},on:{"update:visible"(t){e.dialogVisible=t},close:e.handleClose},scopedSlots:e.C([{key:"title",fn(){return[i("div",{staticStyle:{display:"flex","justify-content":"space-between"}},[i("div",{staticStyle:{display:"flex","align-items":"center",gap:"10px"}},[i("img",{attrs:{src:e.searchIcon}}),e.m(" "),i("div",{staticStyle:{"font-weight":"bold"}},[e.m("文件预览")])]),e.m(" "),i("div",{staticStyle:{"margin-right":"30px"}},[i("el-button",{attrs:{type:"primary",icon:"el-icon-download",size:"mini",disabled:!e.tableData.length||e.downloading,loading:e.downloading},on:{click:e.downloadExcel}},[e.m("下载")])],1)])]},proxy:!0}])},[e.m(" "),e.tableData.length?i("el-table",{staticStyle:{width:"100%","margin-top":"20px"},attrs:{data:e.tableData,border:"",height:"500px"}},e.h(e.columns,function(e){return i("el-table-column",{key:e,attrs:{prop:e,label:e}})}),1):e.k(),e.m(" "),e.pagination.total>0?i("el-pagination",{staticStyle:{"margin-top":"20px","text-align":"center"},attrs:{"current-page":e.pagination.current,"page-sizes":[10,20,50,100],"page-size":e.pagination.pageSize,layout:"total, sizes, prev, pager, next, jumper",total:e.pagination.total},on:{"size-change":e.handleSizeChange,"current-change":e.handleCurrentChange}}):e.k()],1)],1)},staticRenderFns:[],name:"LongExcelViewer",props:{visible:{type:Boolean,default:!1},url:{type:String,default:""}},data:()=>({searchIcon:l.default,tableData:[],columns:[],rawWorkbook:null,downloading:!1,VUE_APP_BASE_API:process.env.VUE_APP_BASE_API,pagination:{total:0,current:1,pageSize:20},queryParams:{fileId:"",pageNum:1,pageSize:20}}),computed:{dialogVisible:{get(){return this.visible},set(e){this.$emit("update:visible",e)}}},watch:{visible(e){e&&this.url&&this.loadExcelFromUrl()},url(e){e&&this.visible&&this.loadExcelFromUrl()}},methods:{async loadExcelFromUrl(){if(!this.url)return;const e=this.url.split("/").pop();this.queryParams.fileId=e;try{const e=await this.$api.dataAnalysis.filePreview(this.queryParams);void 0,e&&e.data&&e.data.records&&Array.isArray(e.data.records)?(this.processTableData(e.data.records),this.pagination.total=e.data.total||0,this.pagination.current=e.data.current||1,this.pagination.pageSize=e.data.size||20):this.$message.error("数据格式错误")}catch(t){void 0,this.$message.error("加载Excel文件失败: "+t.message)}},processTableData(e){const t=e[0];t&&t.headers&&t.data&&(1==this.pagination.current&&(this.columns=t.headers||[]),this.tableData=t.data||[])},processWorkbook(e){this.rawWorkbook=e;const t=e.Sheets[e.SheetNames[0]],a=i.utils.sheet_to_json(t,{header:1});a.length&&(this.columns=a[0],this.tableData=a.slice(1).map(e=>{const t={};return this.columns.forEach((i,a)=>{t[i]=e[a]}),t}))},handleFileChange(e){const t=new FileReader;return t.onload=e=>{const t=new Uint8Array(e.target.result),a=i.read(t,{type:"array"});this.processWorkbook(a)},t.readAsArrayBuffer(e.raw),!1},downloadExcel(){if(!this.url||this.downloading)return;this.downloading=!0;const e=require("axios").create({baseURL:this.VUE_APP_BASE_API,timeout:3e4,responseType:"blob"});e.interceptors.request.use(e=>{const t=this.$store.getters.token||localStorage.getItem("token");return t&&(e.headers.Authorization="Bearer "+t),e}),e.interceptors.response.use(e=>("blob"===e.config.responseType,e),e=>Promise.reject(e));const t=this.url.split("/").pop();e.get("/file/upload/"+t).then(e=>{const t=e.data;let i="示例文件.xlsx";const l=e.headers["content-disposition"];if(l){const e=l.match(/filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/);if(e&&e[1]){i=e[1].replace(/['"]/g,"");try{i=decodeURIComponent(i)}catch(s){void 0}}}a.saveAs(t,i),this.$message.success("下载成功")}).catch(e=>{void 0,this.$message.error("下载失败,请重试")}).finally(()=>{this.downloading=!1})},closeDialog(){this.dialogVisible=!1},handleClose(){this.closeDialog(),this.tableData=[],this.columns=[],this.rawWorkbook=null},handleSizeChange(e){this.queryParams.pageSize=e,this.queryParams.pageNum=1,this.loadExcelFromUrl()},handleCurrentChange(e){this.queryParams.pageNum=e,this.loadExcelFromUrl()}},install(e){e.component(n.name,n)}};e("");var d={render(){var e=this,t=e.$createElement,i=e.l.i||t;return i("div",[i("el-button",{attrs:{size:"small",type:"primary",icon:"el-icon-setting"},on:{click:e.onAdjust}},[e.m("\n 调整变量\n ")]),e.m(" "),i("long-variable-viewer",{ref:"variableViewerRef",attrs:{visible:e.modalVisiable,values:e.values,menus:e.menus},on:{"update:visible"(t){e.modalVisiable=t},"config-changed":e.handleConfigChanged}})],1)},staticRenderFns:[],name:"LongVariableViewerButton",props:{values:{type:Array,default(){return[]}},menus:{type:Array,default(){return[]}}},data:()=>({modalVisiable:!1,tableDataCache:[],updateTimer:null,valuesUpdateTimer:null,menusUpdateTimer:null,updatingTableData:!1}),mounted(){void 0,this.$nextTick(()=>{this.updateTableData()})},beforeDestroy(){this.updateTimer&&clearInterval(this.updateTimer),this.valuesUpdateTimer&&clearTimeout(this.valuesUpdateTimer),this.menusUpdateTimer&&clearTimeout(this.menusUpdateTimer)},watch:{modalVisiable(e){e||(this.$emit("update:columns",this.$refs.variableViewerRef.$getValues()),this.$nextTick(()=>{this.updateTableData()}))},values:{handler(){this.valuesUpdateTimer&&clearTimeout(this.valuesUpdateTimer),this.valuesUpdateTimer=setTimeout(()=>{this.updateTableData()},300)},deep:!0},menus:{handler(){this.menusUpdateTimer&&clearTimeout(this.menusUpdateTimer),this.menusUpdateTimer=setTimeout(()=>{this.updateTableData()},300)},deep:!0}},computed:{tableData(){return this.tableDataCache}},methods:{onAdjust(){this.modalVisiable=!0},$getValues(){return this.$refs.variableViewerRef.$getValues()},$triggerUpdate(){this.$emit("update:columns",this.$getValues()),this.$nextTick(()=>{this.updateTableData()})},$restoreConfig(e){this.$refs.variableViewerRef&&this.$refs.variableViewerRef.$restoreConfig&&(this.$refs.variableViewerRef.$restoreConfig(e),this.$nextTick(()=>{this.updateTableData()}))},handleConfigChanged(e){Array.isArray(e)&&(this.tableDataCache=e,this.$emit("table-data-updated",e))},updateTableData(){if(!this.updatingTableData)if(this.updatingTableData=!0,this.$refs.variableViewerRef&&this.$refs.variableViewerRef.$getTableData){const e=this.$refs.variableViewerRef.$getTableData()||[],t=JSON.parse(JSON.stringify(e)),i=JSON.parse(JSON.stringify(this.tableDataCache));JSON.stringify(t)!==JSON.stringify(i)?(this.tableDataCache=e,this.$nextTick(()=>{this.$emit("table-data-updated",e),this.updatingTableData=!1})):this.updatingTableData=!1}else this.tableDataCache.length>0&&(this.tableDataCache=[]),this.updatingTableData=!1}},install(e){e.component(d.name,d)}};e("");var c={render(){var e=this,t=e.$createElement,i=e.l.i||t;return i("div",{staticStyle:{display:"inline-block","margin-left":"4px"},on:{click(e){e.stopPropagation()}}},[i("el-button",{attrs:{type:"text",size:"small",icon:"el-icon-document"},on:{click:e.onExample}},[e.m("示例文件")]),e.m(" "),i("long-excel-viewer",{attrs:{visible:e.modalVisiable,url:e.url},on:{"update:visible"(t){e.modalVisiable=t}}})],1)},staticRenderFns:[],name:"LongExcelViewerButton",props:{url:{type:String,default:""}},data:()=>({modalVisiable:!1}),methods:{onExample(e){e.stopPropagation(),e.preventDefault(),this.modalVisiable=!0}},install(e){e.component(c.name,c)}};e(".long-uploader-wrapper .el-form-item{margin-bottom:0}.long-uploader-wrapper :deep(.el-upload) .el-upload-dragger{height:130px!important}.long-uploader-wrapper :deep(.el-upload) .el-upload-dragger .el-icon-upload{margin:8px 0}.variable-config-section{background-color:#f8f9fa;border:1px solid #e9ecef;border-radius:4px;margin-top:16px}.config-header{align-items:center;background-color:#e8e9f2;border-bottom:1px solid #e9ecef;cursor:pointer;display:flex;justify-content:space-between;padding:0 12px;transition:background-color .2s}.config-header:hover{background-color:#f0f0f0}.config-title{color:#303133;font-size:14px;margin:0}.collapse-arrow{color:#909399;font-size:12px;transition:transform .3s ease}.collapse-arrow.is-collapsed{transform:rotate(-90deg)}.config-content{padding:12px}.variable-config-section .el-table{font-size:12px}.variable-config-section .el-table th{background-color:#f5f7fa;color:#606266;font-weight:600}.variable-config-section .el-table td{padding:8px 0}.no-data{color:#909399;font-size:14px;padding:20px;text-align:center}");var p={render(){var e=this,t=e.$createElement,i=e.l.i||t;return i("div",{staticClass:"long-uploader-wrapper"},[i("div",[i("div",{staticStyle:{float:"right","margin-top":"-80px"}},[e.options.example&&e.options.example.value?i("long-excel-viewer-button",{attrs:{url:e.options.example.value}}):e.k()],1),e.m(" "),i("div",{staticStyle:{display:"flex","align-items":"center","justify-content":"space-between","margin-bottom":"12px"}},[i("div",{staticStyle:{display:"flex","align-items":"center",gap:"12px",position:"relative"}},[i("el-upload",{attrs:{action:e.uploadUrl,headers:{Authorization:"Bearer "+e.token},"on-preview":e.handlePreview,"on-remove":e.handleRemove,"before-remove":e.beforeRemove,"on-change":e.handleChange,"before-upload":e.beforeUpload,accept:e.fileType,drag:"","on-exceed":e.handleExceed,"file-list":e.fileList}},[i("i",{staticClass:"el-icon-upload",staticStyle:{color:"#6C1537"}}),e.m(" "),i("div",{staticClass:"el-upload__text"},[i("div",{staticStyle:{"line-height":"18px"}},[e.m("将文件拖到此处,或"),i("em",[e.m("点击上传")])]),e.m(" "),i("div",{staticStyle:{"line-height":"18px"}},[e.m("\n 支持上传"),i("em",[e.m("xlsx")]),e.m("、"),i("em",[e.m("xls")]),e.m("、"),i("em",[e.m("csv")])])])])],1)]),e.m(" "),e.fileList.length>0?i("div",{staticStyle:{"margin-top":"-20px"}},[e.S(0),e.m(" "),i("div",[e.h(e.fileList,function(t){return i("el-tag",{key:t.uid,staticStyle:{"margin-right":"8px",cursor:"pointer"},attrs:{closable:""},on:{close(i){return e.handleRemove(t)},click(i){return e.handleFileClick(t)}}},[e.m("\n "+e.v(t.name)+"\n ")])}),e.m(" "),e.fileList.length>0&&e.options.variable&&e.options.variable.enable?i("div",{staticStyle:{display:"flex","align-items":"center"}},[i("span",{staticStyle:{color:"#f56c6c","margin-right":"5px"}},[e.m("*")]),e.m(" "),i("long-variable-viewer-button",{ref:"variableViewerRef",attrs:{values:e.fileData,menus:e.options.variable.menus},on:{"update:columns":e.handleUpdateColumns,"table-data-updated":e.handleTableDataUpdated}})],1):e.k()],2)]):e.k()]),e.m(" "),e.fileList.length>0&&e.options.variable&&e.options.variable.enable&&e.hasConfiguredVariables?i("div",{staticClass:"variable-config-section"},[i("div",{staticClass:"config-header",on:{click:e.toggleCollapse}},[i("span",{staticClass:"config-title"},[e.m("当前变量配置")]),e.m(" "),i("i",{staticClass:"el-icon-caret-bottom collapse-arrow",class:{"is-collapsed":e.isCollapsed}})]),e.m(" "),i("div",{directives:[{name:"show",rawName:"v-show",value:!e.isCollapsed,expression:"!isCollapsed"}],staticClass:"config-content"},[0===e.currentVariableValues.length?i("div",{staticClass:"no-data"},[e.m("\n 暂无数据\n ")]):i("el-table",{staticStyle:{width:"100%"},attrs:{data:e.currentVariableValues,size:"mini","max-height":"300",border:""}},[i("el-table-column",{attrs:{prop:"field",label:"字段名","show-overflow-tooltip":""}}),e.m(" "),i("el-table-column",{attrs:{prop:"fullPath",label:"属性","show-overflow-tooltip":""}})],1),e.m(" "),i("div",{staticClass:"debug-info",staticStyle:{"margin-top":"8px","font-size":"12px",color:"#999"}},[e.m("\n 数据条数: "+e.v(e.currentVariableValues.length)+"\n ")])],1)]):e.k(),e.m(" "),i("long-excel-viewer",{attrs:{visible:e.previewVisible,url:e.previewUrl},on:{"update:visible"(t){e.previewVisible=t}}})],1)},staticRenderFns:[function(){var e=this,t=e.$createElement,i=e.l.i||t;return i("div",{staticStyle:{"font-size":"12px",color:"#999","line-height":"20px"}},[i("i",{staticClass:"el-icon-info",staticStyle:{"margin-right":"5px"}}),e.m(" "),i("span",[e.m("点击文件名称可预览文件")])])}],name:"LongUploader",props:{options:{type:Object,default(){return{variable:{enable:!1,values:[],menus:[]},example:{value:""},file:{id:"",name:""}}}},value:{type:Object,default(){return{fileId:"",columns:[],fileName:""}}},fileId:{type:String,default:""},limit:{type:Number,default:1},fileSize:{type:Number,default:3},fileType:{type:String,default:".xlsx,.xls,.csv"}},data:()=>({uploadUrl:process.env.VUE_APP_BASE_API+"/file/upload",fileList:[],token:"",fileData:[],fileToken:"",variableViewerRef:null,isCollapsed:!0,hasTriggerUpdate:!1,previewVisible:!1,previewUrl:"",tableDataCache:[]}),computed:{currentVariableValues(){return this.tableDataCache.map(e=>({field:e.field||"",fullPath:e.fullPath||"",varType:e.varType||"",attr:e.attr||""}))},hasConfiguredVariables(){return this.currentVariableValues.length>0}},created(){this.token=localStorage.getItem("token")},watch:{fileId:{handler(e){this.fileToken=e},immediate:!0,deep:!0},value:{handler(e,t){void 0,!e||!e.fileId||t&&t.fileId===e.fileId||(this.fileToken=e.fileId,this.downloadFile(e.fileId,e.columns||{})),!e||!e.fileName||t&&t.fileName===e.fileName||(this.fileList=[{name:e.fileName,uid:e.fileId}])},immediate:!0,deep:!0}},methods:{downloadFile(e,t={}){this.$api.dataAnalysis.filePreview({fileId:e}).then(e=>{if(e&&e.data&&e.data.records&&e.data.records.length>0){const i=e.data.records[0].headers||[];this.$emit("update:headers",i);const a=this.options.variable.menus||[],l={};i.forEach(e=>{l[e]={field:e,varType:"",attr:""}}),t&&"object"==typeof t&&Object.keys(t).forEach(e=>{const i=t[e];if(void 0,i&&i.values&&Array.isArray(i.values)){const t=a.find(t=>t.fieldName===e);void 0,t&&i.values.forEach(i=>{l[i]&&(l[i]={field:i,varType:t.label||e,attr:t.label||e})})}}),this.fileData=[{...l}],this.$nextTick(()=>{if(this.$refs.variableViewerRef&&t&&Object.keys(t).length>0&&"function"==typeof this.$refs.variableViewerRef.$restoreConfig&&(this.$refs.variableViewerRef.$restoreConfig(t),this.$nextTick(()=>{this.$refs.variableViewerRef&&"function"==typeof this.$refs.variableViewerRef.updateTableData&&this.$refs.variableViewerRef.updateTableData()})),this.$route.query.id){if(this.hasTriggerUpdate)return;"function"==typeof this.$refs.variableViewerRef.$triggerUpdate&&this.$refs.variableViewerRef.$triggerUpdate(),this.hasTriggerUpdate=!0}})}}).catch(e=>{this.$message.error(e.message||"数据文件内容不匹配,请重新上传")}).finally(()=>{this.loading=!1})},handleColumns(e=[]){const t=this.options.variable.menus||[];void 0,0!=t.length&&e.forEach(e=>{void 0;const i=t.find(t=>t.fieldName==e.fieldName);void 0,e.varType=i.label,e.attr=i.attr})},handleTableDataUpdated(e){Array.isArray(e)&&(this.tableDataCache=e)},handleUpdateColumns(e){void 0,this.$emit("update:columns",e)},beforeUpload(e){if(void 0,e.size>1048576*this.fileSize)return this.$message.error(`上传文件大小不能超过 ${this.fileSize} MB!`),!1;const t=e.type,i=e.name.toLowerCase();return!!(["application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/vnd.ms-excel","text/csv"].includes(t)||i.endsWith(".xlsx")||i.endsWith(".xls")||i.endsWith(".csv"))||(this.$message.error("只支持上传 xlsx、xls、csv 格式的文件!"),!1)},handleChange(e,t){if(t.length>1?this.fileList=[t[t.length-1]]:this.fileList=t.filter(e=>void 0!==e.raw),"success"===e.status){const t=e.response;t&&200===t.code&&(this.fileToken=t.data.id,this.$emit("update:fileId",this.fileToken),this.loadFromUrl(this.fileToken))}},loadFromUrl(e){this.$api.dataAnalysis.filePreview({fileId:e}).then(e=>{if(e&&e.data&&e.data.records&&e.data.records.length>0){const t=(e.data.records[0]||{data:[],headers:[]}).headers||[];if(t.length>0){this.$emit("update:headers",t);const e={};t.forEach(t=>{e[t]={field:t,varType:"",attr:""}}),this.fileData=[{...e}]}else this.$emit("update:headers",[]),this.fileData=[]}})},handleRemove(e){this.fileList=this.fileList.filter(t=>t.uid!==e.uid),this.fileToken="",this.fileData=[],this.$emit("update:fileId",""),this.$emit("update:headers",[])},onAdjust(){this.$emit("adjust")},handleRemove1(e,t){void 0},handlePreview(e){void 0},handleExceed(e,t){this.$message.warning(`上传文件数量不能超过 ${this.limit} 个!`),t.length>this.limit&&(this.fileList=t.slice(-this.limit))},beforeRemove:()=>!0,toggleCollapse(){this.isCollapsed=!this.isCollapsed},handleFileClick(){event.stopPropagation(),this.fileToken?(this.previewUrl=`${process.env.VUE_APP_BASE_API}/file/preview/${this.fileToken}`,this.previewVisible=!0):this.$message.warning("文件ID不存在,无法预览")}},install(e){e.component(p.name,p)}};e(".long-radio-wrapper{display:flex;flex-wrap:wrap}.long-radio-wrapper ::v-deep .el-radio{line-height:24px;margin-bottom:0}.long-radio-wrapper ::v-deep .el-radio__label{display:inline-block;vertical-align:middle;white-space:normal;word-break:break-all}.long-radio-item{margin:4px 12px 4px 0;width:100px}");var h={render(){var e=this,t=e.$createElement,i=e.l.i||t;return i("el-radio-group",e.o(e.p({staticClass:"long-radio-wrapper"},"el-radio-group",e.$attrs,!1),e.$listeners),e.h(e.options,function(t,a){return i("el-radio",{key:a,staticClass:"long-radio-item",attrs:{label:t[e.valueKey],disabled:t[e.disabledOption]}},[e.m("\n "+e.v(t[e.labelKey])+"\n ")])}),1)},staticRenderFns:[],name:"LongRadio",props:{dataList:{type:Array,default(){return[]}},disabledOption:{type:[Boolean,Number],default:!1},valueKey:{type:[String,Number],default:"value"},labelKey:{type:[String,Number],default:"label"},mode:{type:String,default:"local"},dict:{type:String,default:""},url:{type:String,default:""},requestParams:{type:Object,default(){}},placeholder:{type:String,default:"请选择"}},data:()=>({options:[]}),watch:{dataList:{deep:!0,immediate:!0,handler(e){"local"===this.mode&&(this.options=e)}},dict:{deep:!0,handler(e){this.init()}}},created(){this.init()},methods:{init(){"remote"===this.mode&&this.dict&&this.getDicts(this.dict).then(e=>{this.options=(e.data||[]).map(e=>({[this.valueKey]:e.dictCode,[this.labelKey]:e.dictLabel}))})}},install(e){e.component(h.name,h)}};e(".long-group{background-color:#f8f8f8;box-sizing:border-box;height:100%;padding:10px;width:100%}.long-group .group-header{color:#333;font-size:14px;font-weight:700}");var u={render(){var e=this,t=e.$createElement,i=e.l.i||t;return i("div",{staticClass:"long-group"},[i("div",{staticClass:"group-header"},[e.m(e.v(e.label))]),e.m(" "),e.u("default")],2)},staticRenderFns:[],name:"LongGroup",props:{label:{type:String,default:""}},install(e){e.component(u.name,u)}};e(".long-color-picker{width:200px}.long-color-picker .el-color-picker__trigger{width:100%}.long-color-picker .el-color-picker__trigger .el-color-picker__icon{left:unset!important;right:5px!important;width:unset!important}");var f={render(){var e=this,t=e.$createElement;return(e.l.i||t)("el-color-picker",e.o(e.p({staticClass:"long-color-picker"},"el-color-picker",e.$attrs,!1),e.$listeners))},staticRenderFns:[],name:"LongColorPicker",install(e){e.component(f.name,f)}};e("");var g={render(){var e=this,t=e.$createElement;return(e.l.i||t)("el-input-number",e.o(e.p({staticClass:"long-number-input",attrs:{"controls-position":"right",step:e.stepValue,value:e.value,max:e.maxValue,min:e.minValue},on:{input(t){return e.$emit("input",t)}}},"el-input-number",e.$attrs,!1),e.$listeners))},staticRenderFns:[],name:"LongNumberInput",props:{value:{type:[String,Number],default:0},placeholder:{type:String,default:"请输入"},max:{type:[Number,String],default:""},min:{type:[Number,String],default:""},step:{type:[Number,String],default:1}},data(){return{maxValue:""===this.max?Number.MAX_SAFE_INTEGER:+this.max,minValue:""===this.min?Number.MIN_SAFE_INTEGER:+this.min,stepValue:+this.step}},watch:{max:{handler(e){this.maxValue=""===e?Number.MAX_SAFE_INTEGER:+e},immediate:!0},min:{handler(e){this.minValue=""===e?Number.MIN_SAFE_INTEGER:+e},immediate:!0},step:{handler(e){this.stepValue=+e},immediate:!0}},install(e){e.component(g.name,g)}};e(".long-checkbox-wrapper{display:flex;flex-wrap:wrap}.long-checkbox-wrapper ::v-deep .el-checkbox{line-height:24px;margin-bottom:0}.long-checkbox-item{margin:1px 6px 1px 0;min-width:50px}");var b={render(){var e=this,t=e.$createElement,i=e.l.i||t;return i("el-checkbox-group",e.o(e.p({staticClass:"long-checkbox-wrapper",attrs:{value:e.value},on:{change:e.handleInput}},"el-checkbox-group",e.$attrs,!1),e.$listeners),e.h(e.options,function(t,a){return i("el-checkbox",{key:a,staticClass:"long-checkbox-item",attrs:{label:t[e.valueKey],disabled:e.getDisabled(t)}},[e.m("\n "+e.v(t[e.labelKey])+"\n ")])}),1)},staticRenderFns:[],name:"LongCheckBox",props:{value:{type:Array,default(){return[]}},dataList:{type:Array,default(){return[]}},disabledOption:{type:[String,Boolean,Number],default:!1},valueKey:{type:[String,Number],default:"value"},labelKey:{type:[String,Number],default:"label"},mode:{type:String,default:"local"},dict:{type:String,default:""},url:{type:String,default:""},requestParams:{type:Object,default(){}},placeholder:{type:String,default:"请选择"}},data:()=>({options:[]}),watch:{dataList:{deep:!0,immediate:!0,handler(e){"local"===this.mode&&(this.options=e)}},dict:{deep:!0,handler(e){this.init()}}},created(){this.init()},methods:{init(){"remote"===this.mode&&this.dict&&this.getDicts(this.dict).then(e=>{this.options=(e.data||[]).map(e=>({[this.valueKey]:e.dictCode,[this.labelKey]:e.dictLabel}))})},handleInput(e){this.$emit("input",e),this.$emit("change",e)},getDisabled(e){return"string"==typeof this.disabledOption?e[this.disabledOption]||!1:"boolean"==typeof this.disabledOption?this.disabledOption:"number"==typeof this.disabledOption&&e[this.disabledOption]||!1}},install(e){e.component(b.name,b)}},m=[s,r,o,n,d,c,p,h,u,f,g,b],x=function(e){if(!x.installed){x.installed=!0;var i=["ElInput","ElSelect","ElOption","ElCheckbox","ElCheckboxGroup","ElRadio","ElRadioGroup","ElButton","ElDialog","ElTable","ElTableColumn","ElUpload","ElTag","ElPagination","ElInputNumber","ElColorPicker","ElForm","ElFormItem","ElIcon"];i.forEach(function(i){var a=e.options.components[i];if(!a){var l=t(i);a=e.options.components[l]}if(a){var s=t(i);s&&s!==i&&(e.options.components[s]||e.component(s,a)),e.options.components[i]||e.component(i,a)}else"production"!==process.env.NODE_ENV,0}),e.nextTick(function(){i.forEach(function(i){var a=e.options.components[i];if(a){var l=t(i);l&&l!==i&&(e.options.components[l]||e.component(l,a))}})}),m.forEach(function(i){if(i){var a=i.name||i.options&&i.options.name;if(a){e.component(a,i);var l=t(a);l&&l!==a&&e.component(l,i)}}})}};"undefined"!=typeof window&&window.Vue&&x(window.Vue);var v={version:"1.0.0",install:x,Input:s,Select:r,VariableViewer:o,ExcelViewer:n,VariableViewerButton:d,ExcelViewerButton:c,Uploader:p,Radio:h,Group:u,ColorPicker:f,NumberInput:g,CheckBox:b};exports.CheckBox=b,exports.ColorPicker=f,exports.ExcelViewer=n,exports.ExcelViewerButton=c,exports.Group=u,exports.Input=s,exports.NumberInput=g,exports.Radio=h,exports.Select=r,exports.Uploader=p,exports.VariableViewer=o,exports.VariableViewerButton=d,exports.default=v;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});var xlsx=require("xlsx");var fileSaver=require("file-saver");function styleInject(css,ref){if(void 0===ref)ref={};var insertAt=ref.insertAt;if(!css||"undefined"===typeof document)return;var head=document.head||document.getElementsByTagName("head")[0];var style=document.createElement("style");style.type="text/css";if("top"===insertAt)if(head.firstChild)head.insertBefore(style,head.firstChild);else head.appendChild(style);else head.appendChild(style);if(style.styleSheet)style.styleSheet.cssText=css;else style.appendChild(document.createTextNode(css))}var css_248z$b=".long-input-wrapper{background-color:#fff;border:1px solid #e0e0e0;border-radius:4px;padding:8px}.intTxt{width:80%}";styleInject(css_248z$b);var Input={render:function(){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c("el-input",_vm._g(_vm._b({staticClass:"intTxt",attrs:{"show-word-limit":_vm.showWordLimit,placeholder:_vm.placeholder,"auto-complete":"new-password",disabled:_vm.disabled},on:{input:function($event){return _vm.$emit("input",$event)}}},"el-input",_vm.$attrs,false),_vm.$listeners),[_vm._l(Object.keys(this.$slots),function(name){return _vm._t(name,null,{slot:name})})],2)},staticRenderFns:[],name:"LongInput",props:{showWordLimit:{type:Boolean,default:true},disabled:{type:Boolean,default:false},placeholder:{type:String,default:"请输入"}}};Input.install=function install(Vue){Vue.component(Input.name,Input)};var css_248z$a="";styleInject(css_248z$a);var Select={render:function(){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c("el-select",_vm._g(_vm._b({attrs:{value:_vm.value,placeholder:_vm.placeholder}},"el-select",_vm.$attrs,false),_vm.$listeners),[_vm._t("unshift"),_vm._v(" "),_vm._t("default",function(){return _vm._l(_vm.options,function(item,index){return _c("el-option",{key:index,attrs:{value:item[_vm.valueKey],label:item[_vm.labelKey],disabled:item[_vm.disabledOption]}})})},{slot:"default"}),_vm._v(" "),_vm._t("prefix",null,{slot:"prefix"}),_vm._v(" "),_vm._t("empty",null,{slot:"empty"})],2)},staticRenderFns:[],name:"LongSelect",props:{value:{type:[String,Number],default:""},dataList:{type:Array,default:()=>[]},disabledOption:{type:[Boolean,Number],default:false},valueKey:{type:[String,Number],default:"value"},labelKey:{type:[String,Number],default:"label"},mode:{type:String,default:"local"},dict:{type:String,default:""},url:{type:String,default:""},requestParams:{type:Object,default:()=>{}},placeholder:{type:String,default:"请选择"}},data:()=>({options:[]}),watch:{dataList:{deep:true,immediate:true,handler(val){if("local"===this.mode)this.options=val}},dict:{deep:true,handler(val){this.init()}}},created(){this.init()},methods:{init(){if("remote"===this.mode&&this.dict)this.getDicts(this.dict).then(res=>{this.options=(res.data||[]).map(item=>({[this.valueKey]:item.dictCode,[this.labelKey]:item.dictLabel}))})}}};Select.install=function install(Vue){Vue.component(Select.name,Select)};var css_248z$9=".variable-config-dialog :deep(.el-dialog__body){padding:20px}.variable-config-dialog :deep(.el-dialog__header){padding:20px 20px 10px}.dialog-title{align-items:center;color:#303133;display:flex;font-size:16px;font-weight:700;gap:24px;padding:0 20px}.dialog-title .title-left{color:#303133;flex:1;min-width:500px}.dialog-title .title-separator{color:#dcdfe6;flex-shrink:0;font-weight:400}.dialog-title .title-right{color:#303133;flex:1;min-width:400px}.dialog-body{display:flex;gap:24px;min-height:500px}.left-section{flex:1;min-width:500px}.section-title{color:#303133;font-size:16px;font-weight:700;margin-bottom:16px}.variable-selector{align-items:flex-start;display:flex;gap:16px}.variable-panel{border:1px solid #dcdfe6;border-radius:4px;display:flex;flex:1;flex-direction:column;height:500px;overflow:hidden}.panel-header{align-items:center;background:#f5f7fa;border-bottom:1px solid #dcdfe6;display:flex;justify-content:space-between;padding:12px 16px}.select-all-checkbox :deep(.el-checkbox__label){padding-left:8px}.panel-title{color:#303133;font-weight:500}.panel-count{color:#909399;font-size:12px}.panel-search{border-bottom:1px solid #dcdfe6;padding:12px}.panel-list{flex:1;overflow-y:auto;padding:8px}.variable-item{border-radius:4px;cursor:pointer;padding:8px 12px;transition:background-color .2s}.variable-item:hover{background-color:#f5f7fa}.variable-item :deep(.el-checkbox){width:100%}.variable-item :deep(.el-checkbox__label){width:100%}.arrow-buttons{display:flex;flex-direction:column;gap:12px;justify-content:center;padding-top:100px}.arrow-buttons .el-button{margin-left:0!important}.right-section{display:flex;flex:1;flex-direction:column;min-width:400px;overflow:hidden}.config-desc{color:#909399;flex-shrink:0;font-size:13px;line-height:1.5;margin-bottom:24px}.config-group{margin-bottom:32px}.config-group:last-child{margin-bottom:0}.config-label{color:#303133;font-size:14px;font-weight:500;margin-bottom:12px}.config-options{display:flex;flex:1;flex-direction:column;gap:16px;margin-top:16px;overflow-x:hidden;overflow-y:auto;padding-right:8px}.config-options::-webkit-scrollbar{width:6px}.config-options::-webkit-scrollbar-track{background:#f1f1f1;border-radius:3px}.config-options::-webkit-scrollbar-thumb{background:#c1c1c1;border-radius:3px}.config-options::-webkit-scrollbar-thumb:hover{background:#a8a8a8}.config-option-row{align-items:center;display:flex;gap:12px;margin-bottom:8px}.config-option-row.is-parent .option-label{color:#303133;font-weight:500}.config-option-row.is-leaf .option-label{color:#606266}.option-label{color:#606266;flex:1;font-size:13px;min-width:0;white-space:normal;word-break:break-all}.option-label.required{color:#303133;font-weight:500}.option-label .required-mark{color:#f56c6c;margin-left:2px}.config-select{flex-shrink:0;width:350px}.non-leaf-label{color:#909399;font-size:13px;font-style:italic}.disabled-option{cursor:not-allowed!important}.disabled-option,.disabled-text{color:#c0c4cc!important}:deep(.el-select-dropdown__item.is-disabled){color:#c0c4cc!important;cursor:not-allowed!important}:deep(.el-select-dropdown__item.is-disabled) span{color:#c0c4cc!important}.checkbox-list{border:1px solid #dcdfe6;border-radius:4px;display:flex;flex:1;flex-direction:column;gap:8px;max-height:200px;overflow-y:auto;padding:8px}.dialog-footer{text-align:right}";styleInject(css_248z$9);var VariableViewer={render:function(){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c("div",[_c("el-dialog",{staticClass:"variable-config-dialog",staticStyle:{"max-height":"90vh"},attrs:{visible:_vm.dialogVisible,width:"1200px"},on:{"update:visible":function($event){_vm.dialogVisible=$event},close:_vm.handleClose}},[_c("div",{staticClass:"dialog-title",attrs:{slot:"title"},slot:"title"},[_c("span",{staticClass:"title-left"},[_vm._v("选择分析变量")]),_vm._v(" "),_c("span",{staticClass:"title-separator"},[_vm._v("|")]),_vm._v(" "),_c("span",{staticClass:"title-right"},[_vm._v("配置变量")])]),_vm._v(" "),_c("div",{staticClass:"dialog-body"},[_c("div",{staticClass:"left-section"},[_c("div",{staticClass:"variable-selector"},[_c("div",{staticClass:"variable-panel"},[_c("div",{staticClass:"panel-header"},[_c("el-checkbox",{staticClass:"select-all-checkbox",attrs:{indeterminate:_vm.leftIndeterminate},on:{change:_vm.handleLeftSelectAll},model:{value:_vm.leftSelectAll,callback:function($$v){_vm.leftSelectAll=$$v},expression:"leftSelectAll"}},[_c("span",{staticClass:"panel-title"},[_vm._v("全选")])]),_vm._v(" "),_c("span",{staticClass:"panel-count"},[_vm._v(_vm._s(_vm.selectedAllCount)+"/"+_vm._s(_vm.allVariables.length))])],1),_vm._v(" "),_c("div",{staticClass:"panel-search"},[_c("el-input",{attrs:{placeholder:"请输入关键字","suffix-icon":"el-icon-search",size:"small"},on:{input:_vm.handleLeftSearch},model:{value:_vm.leftKeyword,callback:function($$v){_vm.leftKeyword=$$v},expression:"leftKeyword"}})],1),_vm._v(" "),_c("div",{staticClass:"panel-list"},_vm._l(_vm.filteredLeftVariables,function(item){return _c("div",{key:item.field,staticClass:"variable-item"},[_c("el-checkbox",{on:{change:function($event){return _vm.handleLeftCheckChange(item)}},model:{value:item.checked,callback:function($$v){_vm.$set(item,"checked",$$v)},expression:"item.checked"}},[_vm._v("\n "+_vm._s(item.field)+"\n ")])],1)}),0)]),_vm._v(" "),_c("div",{staticClass:"arrow-buttons"},[_c("el-button",{attrs:{type:"primary",icon:"el-icon-arrow-right",size:"small",disabled:!_vm.hasLeftSelected},on:{click:_vm.moveToRight}}),_vm._v(" "),_c("el-button",{attrs:{type:"danger",icon:"el-icon-arrow-left",size:"small",disabled:!_vm.hasRightSelected},on:{click:_vm.moveToLeft}})],1),_vm._v(" "),_c("div",{staticClass:"variable-panel"},[_c("div",{staticClass:"panel-header"},[_c("el-checkbox",{staticClass:"select-all-checkbox",attrs:{indeterminate:_vm.rightIndeterminate},on:{change:_vm.handleRightSelectAll},model:{value:_vm.rightSelectAll,callback:function($$v){_vm.rightSelectAll=$$v},expression:"rightSelectAll"}},[_c("span",{staticClass:"panel-title"},[_vm._v("已选")])]),_vm._v(" "),_c("span",{staticClass:"panel-count"},[_vm._v(_vm._s(_vm.selectedRightCount)+"/"+_vm._s(_vm.selectedVariables.length))])],1),_vm._v(" "),_c("div",{staticClass:"panel-search"},[_c("el-input",{attrs:{placeholder:"请输入关键字","suffix-icon":"el-icon-search",size:"small"},on:{input:_vm.handleRightSearch},model:{value:_vm.rightKeyword,callback:function($$v){_vm.rightKeyword=$$v},expression:"rightKeyword"}})],1),_vm._v(" "),_c("div",{staticClass:"panel-list"},_vm._l(_vm.filteredRightVariables,function(item){return _c("div",{key:item.field,staticClass:"variable-item"},[_c("el-checkbox",{on:{change:function($event){return _vm.handleRightCheckChange(item)}},model:{value:item.checked,callback:function($$v){_vm.$set(item,"checked",$$v)},expression:"item.checked"}},[_vm._v("\n "+_vm._s(item.field)+"\n ")])],1)}),0)])])]),_vm._v(" "),_c("div",{staticClass:"right-section"},[_c("div",{staticClass:"config-desc"},[_vm._v("\n 数据文件中因变量的值,需赋予参考值,方便精准进行数据分析。\n ")]),_vm._v(" "),_c("div",{staticClass:"config-options"},_vm._l(_vm.flatMenuItems,function(menuItem){return _c("div",{key:menuItem.pathString,staticClass:"config-option-row"},[_c("span",{staticClass:"option-label",class:{required:menuItem.required}},[_vm._v("\n "+_vm._s(menuItem.pathString)+"\n "),menuItem.required?_c("span",{staticClass:"required-mark"},[_vm._v("*")]):_vm._e()]),_vm._v(" "),_c("el-select",{staticClass:"config-select",attrs:{placeholder:_vm.getPlaceholder(menuItem),clearable:menuItem.nullable,multiple:menuItem.multiple},on:{change:function($event){return _vm.handleConfigChange(menuItem.pathString,$event)}},model:{value:_vm.configValues[menuItem.pathString],callback:function($$v){_vm.$set(_vm.configValues,menuItem.pathString,$$v)},expression:"configValues[menuItem.pathString]"}},_vm._l(_vm.getAvailableOptions(menuItem.pathString,menuItem.multiple),function(option){return _c("el-option",{key:option.value,class:{"disabled-option":option.disabled},attrs:{label:option.label,value:option.value,disabled:option.disabled}},[_c("span",{class:{"disabled-text":option.disabled}},[_vm._v(_vm._s(option.label))])])}),1)],1)}),0)])]),_vm._v(" "),_c("div",{staticClass:"dialog-footer",attrs:{slot:"footer"},slot:"footer"},[_c("el-button",{on:{click:_vm.handleClose}},[_vm._v("取消")]),_vm._v(" "),_c("el-button",{staticStyle:{color:"#fff"},attrs:{type:"primary"},on:{click:_vm.handleSave}},[_vm._v("保存")])],1)])],1)},staticRenderFns:[],name:"LongVariableViewer",props:{visible:{type:Boolean,default:false},values:{type:Array,default:()=>[]},menus:{type:Array,default:()=>[]}},data:()=>({dialogVisible:false,leftKeyword:"",rightKeyword:"",allVariables:[],selectedVariables:[],configValues:{},configChangeTimer:null}),computed:{filteredLeftVariables(){if(!this.leftKeyword)return this.allVariables;return this.allVariables.filter(item=>item.field.toLowerCase().includes(this.leftKeyword.toLowerCase()))},filteredRightVariables(){if(!this.rightKeyword)return this.selectedVariables;return this.selectedVariables.filter(item=>item.field.toLowerCase().includes(this.rightKeyword.toLowerCase()))},selectedAllCount(){return this.allVariables.filter(item=>item.checked).length},selectedRightCount(){return this.selectedVariables.filter(item=>item.checked).length},hasLeftSelected(){return this.allVariables.some(item=>item.checked)},hasRightSelected(){return this.selectedVariables.some(item=>item.checked)},leftSelectAll:{get(){const filtered=this.filteredLeftVariables;if(0===filtered.length)return false;return filtered.every(item=>item.checked)},set(){}},leftIndeterminate(){const filtered=this.filteredLeftVariables;if(0===filtered.length)return false;const checkedCount=filtered.filter(item=>item.checked).length;return checkedCount>0&&checkedCount<filtered.length},rightSelectAll:{get(){const filtered=this.filteredRightVariables;if(0===filtered.length)return false;return filtered.every(item=>item.checked)},set(){}},rightIndeterminate(){const filtered=this.filteredRightVariables;if(0===filtered.length)return false;const checkedCount=filtered.filter(item=>item.checked).length;return checkedCount>0&&checkedCount<filtered.length},flatMenuItems(){if(!this.menus||0===this.menus.length)return[];const result=[];const traverse=(menu,parentPath=[])=>{const currentPath=[...parentPath,menu.label];const isLeaf=!menu.children||0===menu.children.length;if(isLeaf){const pathString=currentPath.join("/");result.push({label:menu.label,path:currentPath,pathString,isLeaf:true,id:menu.id,fieldName:menu.fieldName,required:menu.required,nullable:menu.nullable,multiple:menu.multiple,originalMenu:menu})}else if(menu.children&&menu.children.length>0)menu.children.forEach(child=>{traverse(child,currentPath)})};this.menus.forEach(menu=>{traverse(menu)});return result},tableData(){const result=[];Object.keys(this.configValues).forEach(pathString=>{const value=this.configValues[pathString];if(!value||Array.isArray(value)&&0===value.length)return;const menuItem=this.flatMenuItems.find(item=>item.pathString===pathString);if(!menuItem)return;const fullPath=menuItem.pathString;const fields=Array.isArray(value)?value:[value];fields.forEach(field=>{const fieldName=String(field);if(!fieldName)return;result.push({field:fieldName,fullPath,varType:menuItem.path&&menuItem.path.length>0?menuItem.path[0]:fullPath,attr:menuItem.path&&menuItem.path.length>0?menuItem.path[menuItem.path.length-1]:""})})});return result}},watch:{visible:{handler(val){this.dialogVisible=val},immediate:true},dialogVisible(val){this.$emit("update:visible",val)},values:{handler(val){this.handleValuesChange(val)},immediate:true,deep:true},selectedVariables:{handler(){const selectedFields=this.selectedVariables.map(item=>item.field);const newConfigValues={...this.configValues};let hasChange=false;Object.keys(newConfigValues).forEach(key=>{const value=newConfigValues[key];if(Array.isArray(value)){const filtered=value.filter(v=>selectedFields.includes(v));if(filtered.length!==value.length){newConfigValues[key]=filtered;hasChange=true}}else if(value&&!selectedFields.includes(value)){newConfigValues[key]="";hasChange=true}});if(hasChange)this.configValues=newConfigValues},deep:true},configValues:{handler(){if(this.configChangeTimer)clearTimeout(this.configChangeTimer);this.configChangeTimer=setTimeout(()=>{this.$nextTick(()=>{this.$emit("config-changed",this.tableData)})},100)},deep:true}},methods:{handleValuesChange(val){if(!val||0===val.length){this.allVariables=[];this.selectedVariables=[];return}const fields=[];if(val.length>0){const firstRow=val[0];if("object"===typeof firstRow&&null!==firstRow)fields.push(...Object.keys(firstRow))}this.allVariables=fields.map(field=>({field,checked:false}));this.selectedVariables=[]},handleLeftSearch(){},handleRightSearch(){},handleLeftCheckChange(){},handleRightCheckChange(){},handleLeftSelectAll(val){this.filteredLeftVariables.forEach(item=>{item.checked=val})},handleRightSelectAll(val){this.filteredRightVariables.forEach(item=>{item.checked=val})},moveToRight(){const selectedItems=this.allVariables.filter(item=>item.checked);if(0===selectedItems.length)return;selectedItems.forEach(item=>{item.checked=false;if(!this.selectedVariables.find(v=>v.field===item.field))this.selectedVariables.push({field:item.field,checked:false})});this.allVariables=this.allVariables.filter(item=>!selectedItems.some(selected=>selected.field===item.field))},moveToLeft(){const selectedItems=this.selectedVariables.filter(item=>item.checked);if(0===selectedItems.length)return;selectedItems.forEach(item=>{item.checked=false;if(!this.allVariables.find(v=>v.field===item.field))this.allVariables.push({field:item.field,checked:false})});this.selectedVariables=this.selectedVariables.filter(item=>!selectedItems.some(selected=>selected.field===item.field))},handleClose(){this.dialogVisible=false},getPlaceholder(menuItem){if(menuItem.required)return"必选";return menuItem.nullable?"请选择":"必选"},getAvailableOptions(pathString,isMultiple=false){const allSelectedFields=this.selectedVariables.map(item=>item.field);const currentValue=this.configValues[pathString];const currentValues=isMultiple?Array.isArray(currentValue)?currentValue:[]:currentValue?[currentValue]:[];const otherSelectedValues=[];Object.keys(this.configValues).forEach(key=>{if(key!==pathString&&this.configValues[key]){const value=this.configValues[key];if(Array.isArray(value))otherSelectedValues.push(...value);else otherSelectedValues.push(value)}});return allSelectedFields.map(field=>{if(currentValues.includes(field))return{label:field,value:field,disabled:false};return{label:field,value:field,disabled:otherSelectedValues.includes(field)}})},handleConfigChange(pathString,value){this.$set(this.configValues,pathString,value);const menuItem=this.flatMenuItems.find(item=>item.pathString===pathString);if(menuItem&&menuItem.multiple&&!Array.isArray(value))this.$set(this.configValues,pathString,value?[value]:[])},generateConfigFromMenus(){this.flatMenuItems.forEach(menuItem=>{if(!(menuItem.pathString in this.configValues))if(menuItem.multiple)this.$set(this.configValues,menuItem.pathString,[]);else this.$set(this.configValues,menuItem.pathString,"")});return{...this.configValues}},handleSave(){const config=this.generateConfigFromMenus();const result={config,selectedVariables:this.selectedVariables.map(item=>item.field)};this.$emit("save",result);this.dialogVisible=false},$restoreConfig(columns){if(!columns||"object"!==typeof columns)return;const allFields=new Set;Object.keys(columns).forEach(fieldName=>{const columnData=columns[fieldName];if(columnData&&columnData.values&&Array.isArray(columnData.values))columnData.values.forEach(field=>allFields.add(field))});allFields.forEach(field=>{if(!this.selectedVariables.find(item=>item.field===field))this.selectedVariables.push({field,checked:false})});this.configValues={};Object.keys(columns).forEach(fieldName=>{const columnData=columns[fieldName];if(!columnData||!columnData.values||!Array.isArray(columnData.values)||0===columnData.values.length)return;const menuItems=this.flatMenuItems.filter(item=>item.fieldName===fieldName);if(0===menuItems.length)return;if(1===menuItems.length){const menuItem=menuItems[0];const pathString=menuItem.pathString;if(menuItem.multiple)this.$set(this.configValues,pathString,[...columnData.values]);else this.$set(this.configValues,pathString,columnData.values[0])}else{const singleSelectItems=menuItems.filter(item=>!item.multiple);const multiSelectItems=menuItems.filter(item=>item.multiple);if(multiSelectItems.length>0){const menuItem=multiSelectItems[0];this.$set(this.configValues,menuItem.pathString,[...columnData.values])}else if(singleSelectItems.length>0)columnData.values.forEach((value,index)=>{if(index<singleSelectItems.length){const menuItem=singleSelectItems[index];this.$set(this.configValues,menuItem.pathString,value)}})}})},$getValues(){const result={};Object.keys(this.configValues).forEach(pathString=>{const value=this.configValues[pathString];if(!value||Array.isArray(value)&&0===value.length)return;const menuItem=this.flatMenuItems.find(item=>item.pathString===pathString);if(!menuItem||!menuItem.fieldName)return;const fieldName=menuItem.fieldName;if(!result[fieldName])result[fieldName]={values:[]};const fields=Array.isArray(value)?value:[value];fields.forEach(field=>{if(!result[fieldName].values.includes(field))result[fieldName].values.push(field)})});return result},$getTableData(){this.generateConfigFromMenus();const data=this.tableData;console.log("VariableViewer - $getTableData - configValues:",this.configValues);console.log("VariableViewer - $getTableData - tableData:",data);return data}}};VariableViewer.install=function install(Vue){Vue.component(VariableViewer.name,VariableViewer)};var css_248z$8=".long-excel-viewer :deep(.el-dialog__body){padding:0 10px 10px}";styleInject(css_248z$8);var ExcelViewer={render:function(){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c("div",{staticClass:"long-excel-viewer"},[_c("el-dialog",{attrs:{visible:_vm.dialogVisible,title:"示例文件",width:"1000px"},on:{"update:visible":function($event){_vm.dialogVisible=$event},close:_vm.handleClose},scopedSlots:_vm._u([{key:"title",fn:function(){return[_c("div",{staticStyle:{display:"flex","justify-content":"space-between"}},[_c("div",{staticStyle:{display:"flex","align-items":"center",gap:"10px"}},[_c("img",{attrs:{src:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAARzQklUCAgICHwIZIgAAALwSURBVFiF7VdNUuJAFP5eY8UAC/EE5gjMDeAE6glGTqDukmxsNyE7hhOIJ9A5gXiCyZxg8ATgYoCkKv1mQRIbTKIEnZrFfFUUvH6P977q7vfTBACOs7wAcE5EFj4PAaCGnlcf6YvkuqEEcPWJgdeglOr6fn2cygLA8d8KDgBCiK+6vAegnQrMfMnMwccHRQcQV6sYZG0SyMDMgb49HwXHiY6IOJ/cRwfbFv8J7BUpbHthCSEeAFgV/AaGMe9KeTirTKBWq50zc5XgANAOw+YxgFsAYI6fiMQIAIjip3cRiOP4uxDioiKBGXP8mApJZo3zDAsJ+H59LOX0cLk020U2eRCiNjOM35P3bH8pAQBInIy3IbAt/t0sAADXXUhAHL3WqMfNrgYAUk5bYdg8FmJV3pnjZ6UwLquu5LphViP1TuW6izNA3BT9UbeVctqKIvMCEOcAWjnmE2Ye9vvmt01F2RFYJboMtr2woqjxI2k2ecEBwCKigeuGd+8m4Hl1CagegNHrj+olWdLKKVYzAAGA++Rbx4nrhmu7WnoHknMeFemjqDkA1orVvWHMe3oK5lTUM9te3KbHVzkLbHthAXz2skIjz9s/3cx/369PDGP+BcAksyTKJrDKBIjEWoFSKr4uspXycKaU6mkEOlJOWzsSUNokRWPfr0/K7JMtz3YnDBudHQnUDl5+c2nwFMysHQ8d7ESAOX7WxDf7hZTTlj72M6+6YmUCSq31iPbqUhYjiswTXTbNZbATgc0zJaLCqrkiJ7S3B43SbCmtA2+Bma+JaJAQ6Lhu+AugU88zAiDtDY0OEW6wXiWHGRXXDaeaMmCm0j5OpH56npkNKo6zfCCiTg65SclTLxvZqMhBEZhp3O8bXX3NcaIBEW87PQWGMe8KZu5Bq1JV0O8bl0nfyH1VMfOYGacb+nYY1u8olWx70SGq5fT+V+6e+/39+yJtkg0WUe2IOX4yzWWQXrhV2248QEtbKvDzaViRaA4APgEw/AN35ky/nKIj9wAAAABJRU5ErkJggg=="}}),_vm._v(" "),_c("div",{staticStyle:{"font-weight":"bold"}},[_vm._v("文件预览")])]),_vm._v(" "),_c("div",{staticStyle:{"margin-right":"30px"}},[_c("el-button",{attrs:{type:"primary",icon:"el-icon-download",size:"mini",disabled:!_vm.tableData.length||_vm.downloading,loading:_vm.downloading},on:{click:_vm.downloadExcel}},[_vm._v("下载")])],1)])]},proxy:true}])},[_vm._v(" "),_vm.tableData.length?_c("el-table",{staticStyle:{width:"100%","margin-top":"20px"},attrs:{data:_vm.tableData,border:"",height:"500px"}},_vm._l(_vm.columns,function(col){return _c("el-table-column",{key:col,attrs:{prop:col,label:col}})}),1):_vm._e(),_vm._v(" "),_vm.pagination.total>0?_c("el-pagination",{staticStyle:{"margin-top":"20px","text-align":"center"},attrs:{"current-page":_vm.pagination.current,"page-sizes":[10,20,50,100],"page-size":_vm.pagination.pageSize,layout:"total, sizes, prev, pager, next, jumper",total:_vm.pagination.total},on:{"size-change":_vm.handleSizeChange,"current-change":_vm.handleCurrentChange}}):_vm._e()],1)],1)},staticRenderFns:[],name:"LongExcelViewer",props:{visible:{type:Boolean,default:false},url:{type:String,default:""}},data:()=>({tableData:[],columns:[],rawWorkbook:null,downloading:false,VUE_APP_BASE_API:process.env.VUE_APP_BASE_API,pagination:{total:0,current:1,pageSize:20},queryParams:{fileId:"",pageNum:1,pageSize:20}}),computed:{dialogVisible:{get(){return this.visible},set(value){this.$emit("update:visible",value)}}},watch:{visible(newVal){if(newVal&&this.url)this.loadExcelFromUrl()},url(newVal){if(newVal&&this.visible)this.loadExcelFromUrl()}},methods:{async loadExcelFromUrl(){if(!this.url)return;const fileId=this.url.split("/").pop();this.queryParams.fileId=fileId;try{const response=await this.$api.dataAnalysis.filePreview(this.queryParams);console.log("response",response);if(response&&response.data&&response.data.records&&Array.isArray(response.data.records)){this.processTableData(response.data.records);this.pagination.total=response.data.total||0;this.pagination.current=response.data.current||1;this.pagination.pageSize=response.data.size||20}else this.$message.error("数据格式错误")}catch(error){console.error("Error loading Excel file from URL:",error);this.$message.error("加载Excel文件失败: "+error.message)}},processTableData(data){const resultData=data[0];if(resultData&&resultData.headers&&resultData.data){if(1==this.pagination.current)this.columns=resultData.headers||[];this.tableData=resultData.data||[]}},processWorkbook(workbook){this.rawWorkbook=workbook;const firstSheet=workbook.Sheets[workbook.SheetNames[0]];const json=xlsx.utils.sheet_to_json(firstSheet,{header:1});if(json.length){this.columns=json[0];this.tableData=json.slice(1).map(row=>{const obj={};this.columns.forEach((col,idx)=>{obj[col]=row[idx]});return obj})}},handleFileChange(file){const reader=new FileReader;reader.onload=e=>{const data=new Uint8Array(e.target.result);const workbook=xlsx.read(data,{type:"array"});this.processWorkbook(workbook)};reader.readAsArrayBuffer(file.raw);return false},downloadExcel(){if(!this.url||this.downloading)return;this.downloading=true;const axios=require("axios");const instance=axios.create({baseURL:this.VUE_APP_BASE_API,timeout:3e4,responseType:"blob"});instance.interceptors.request.use(config=>{const token=this.$store.getters.token||localStorage.getItem("token");if(token)config.headers["Authorization"]=`Bearer ${token}`;return config});instance.interceptors.response.use(response=>{if("blob"===response.config.responseType)return response;return response},error=>Promise.reject(error));const fileId=this.url.split("/").pop();instance.get(`/file/upload/${fileId}`).then(response=>{const blob=response.data;let filename="示例文件.xlsx";const contentDisposition=response.headers["content-disposition"];if(contentDisposition){const filenameMatch=contentDisposition.match(/filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/);if(filenameMatch&&filenameMatch[1]){filename=filenameMatch[1].replace(/['"]/g,"");try{filename=decodeURIComponent(filename)}catch(e){console.warn("文件名解码失败:",e)}}}fileSaver.saveAs(blob,filename);this.$message.success("下载成功")}).catch(error=>{console.error("下载失败:",error);this.$message.error("下载失败,请重试")}).finally(()=>{this.downloading=false})},closeDialog(){this.dialogVisible=false},handleClose(){this.closeDialog();this.tableData=[];this.columns=[];this.rawWorkbook=null},handleSizeChange(val){this.queryParams.pageSize=val;this.queryParams.pageNum=1;this.loadExcelFromUrl()},handleCurrentChange(val){this.queryParams.pageNum=val;this.loadExcelFromUrl()}}};ExcelViewer.install=function install(Vue){Vue.component(ExcelViewer.name,ExcelViewer)};var css_248z$7="";styleInject(css_248z$7);var VariableViewerButton={render:function(){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c("div",[_c("el-button",{attrs:{size:"small",type:"primary",icon:"el-icon-setting"},on:{click:_vm.onAdjust}},[_vm._v("\n 调整变量\n ")]),_vm._v(" "),_c("long-variable-viewer",{ref:"variableViewerRef",attrs:{visible:_vm.modalVisiable,values:_vm.values,menus:_vm.menus},on:{"update:visible":function($event){_vm.modalVisiable=$event},"config-changed":_vm.handleConfigChanged}})],1)},staticRenderFns:[],name:"LongVariableViewerButton",props:{values:{type:Array,default:()=>[]},menus:{type:Array,default:()=>[]}},data:()=>({modalVisiable:false,tableDataCache:[],updateTimer:null,valuesUpdateTimer:null,menusUpdateTimer:null,updatingTableData:false}),mounted(){console.log("VariableViewerButton mounted, menus:",this.menus,"values:",this.values);this.$nextTick(()=>{this.updateTableData()})},beforeDestroy(){if(this.updateTimer)clearInterval(this.updateTimer);if(this.valuesUpdateTimer)clearTimeout(this.valuesUpdateTimer);if(this.menusUpdateTimer)clearTimeout(this.menusUpdateTimer)},watch:{modalVisiable(val){if(!val){this.$emit("update:columns",this.$refs.variableViewerRef.$getValues());this.$nextTick(()=>{this.updateTableData()})}},values:{handler(){if(this.valuesUpdateTimer)clearTimeout(this.valuesUpdateTimer);this.valuesUpdateTimer=setTimeout(()=>{this.updateTableData()},300)},deep:true},menus:{handler(){if(this.menusUpdateTimer)clearTimeout(this.menusUpdateTimer);this.menusUpdateTimer=setTimeout(()=>{this.updateTableData()},300)},deep:true}},computed:{tableData(){return this.tableDataCache}},methods:{onAdjust(){this.modalVisiable=true},$getValues(){return this.$refs.variableViewerRef.$getValues()},$triggerUpdate(){this.$emit("update:columns",this.$getValues());this.$nextTick(()=>{this.updateTableData()})},$restoreConfig(columns){if(this.$refs.variableViewerRef&&this.$refs.variableViewerRef.$restoreConfig){this.$refs.variableViewerRef.$restoreConfig(columns);this.$nextTick(()=>{this.updateTableData()})}},handleConfigChanged(tableData){if(Array.isArray(tableData)){this.tableDataCache=tableData;console.log("VariableViewerButton - config changed, tableData:",this.tableDataCache);this.$emit("table-data-updated",tableData)}},updateTableData(){if(this.updatingTableData)return;this.updatingTableData=true;if(this.$refs.variableViewerRef&&this.$refs.variableViewerRef.$getTableData){const newData=this.$refs.variableViewerRef.$getTableData()||[];const cleanNewData=JSON.parse(JSON.stringify(newData));const cleanCache=JSON.parse(JSON.stringify(this.tableDataCache));if(JSON.stringify(cleanNewData)!==JSON.stringify(cleanCache)){this.tableDataCache=newData;console.log("VariableViewerButton - tableData updated:",this.tableDataCache);this.$nextTick(()=>{this.$emit("table-data-updated",newData);this.updatingTableData=false})}else this.updatingTableData=false}else{if(this.tableDataCache.length>0)this.tableDataCache=[];this.updatingTableData=false}}}};VariableViewerButton.install=function install(Vue){Vue.component(VariableViewerButton.name,VariableViewerButton)};var css_248z$6="";styleInject(css_248z$6);var ExcelViewerButton={render:function(){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c("div",{staticStyle:{display:"inline-block","margin-left":"4px"},on:{click:function($event){$event.stopPropagation()}}},[_c("el-button",{attrs:{type:"text",size:"small",icon:"el-icon-document"},on:{click:_vm.onExample}},[_vm._v("示例文件")]),_vm._v(" "),_c("long-excel-viewer",{attrs:{visible:_vm.modalVisiable,url:_vm.url},on:{"update:visible":function($event){_vm.modalVisiable=$event}}})],1)},staticRenderFns:[],name:"LongExcelViewerButton",props:{url:{type:String,default:""}},data:()=>({modalVisiable:false}),methods:{onExample(event){event.stopPropagation();event.preventDefault();this.modalVisiable=true}}};ExcelViewerButton.install=function install(Vue){Vue.component(ExcelViewerButton.name,ExcelViewerButton)};var css_248z$5=".long-uploader-wrapper .el-form-item{margin-bottom:0}.long-uploader-wrapper :deep(.el-upload) .el-upload-dragger{height:130px!important}.long-uploader-wrapper :deep(.el-upload) .el-upload-dragger .el-icon-upload{margin:8px 0}.variable-config-section{background-color:#f8f9fa;border:1px solid #e9ecef;border-radius:4px;margin-top:16px}.config-header{align-items:center;background-color:#e8e9f2;border-bottom:1px solid #e9ecef;cursor:pointer;display:flex;justify-content:space-between;padding:0 12px;transition:background-color .2s}.config-header:hover{background-color:#f0f0f0}.config-title{color:#303133;font-size:14px;margin:0}.collapse-arrow{color:#909399;font-size:12px;transition:transform .3s ease}.collapse-arrow.is-collapsed{transform:rotate(-90deg)}.config-content{padding:12px}.variable-config-section .el-table{font-size:12px}.variable-config-section .el-table th{background-color:#f5f7fa;color:#606266;font-weight:600}.variable-config-section .el-table td{padding:8px 0}.no-data{color:#909399;font-size:14px;padding:20px;text-align:center}";styleInject(css_248z$5);var LongUploader={render:function(){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c("div",{staticClass:"long-uploader-wrapper"},[_c("div",[_c("div",{staticStyle:{float:"right","margin-top":"-80px"}},[_vm.options.example&&_vm.options.example.value?_c("long-excel-viewer-button",{attrs:{url:_vm.options.example.value}}):_vm._e()],1),_vm._v(" "),_c("div",{staticStyle:{display:"flex","align-items":"center","justify-content":"space-between","margin-bottom":"12px"}},[_c("div",{staticStyle:{display:"flex","align-items":"center",gap:"12px",position:"relative"}},[_c("el-upload",{attrs:{action:_vm.uploadUrl,headers:{Authorization:"Bearer "+_vm.token},"on-preview":_vm.handlePreview,"on-remove":_vm.handleRemove,"before-remove":_vm.beforeRemove,"on-change":_vm.handleChange,"before-upload":_vm.beforeUpload,accept:_vm.fileType,drag:"","on-exceed":_vm.handleExceed,"file-list":_vm.fileList}},[_c("i",{staticClass:"el-icon-upload",staticStyle:{color:"#6C1537"}}),_vm._v(" "),_c("div",{staticClass:"el-upload__text"},[_c("div",{staticStyle:{"line-height":"18px"}},[_vm._v("将文件拖到此处,或"),_c("em",[_vm._v("点击上传")])]),_vm._v(" "),_c("div",{staticStyle:{"line-height":"18px"}},[_vm._v("\n 支持上传"),_c("em",[_vm._v("xlsx")]),_vm._v("、"),_c("em",[_vm._v("xls")]),_vm._v("、"),_c("em",[_vm._v("csv")])])])])],1)]),_vm._v(" "),_vm.fileList.length>0?_c("div",{staticStyle:{"margin-top":"-20px"}},[_vm._m(0),_vm._v(" "),_c("div",[_vm._l(_vm.fileList,function(file){return _c("el-tag",{key:file.uid,staticStyle:{"margin-right":"8px",cursor:"pointer"},attrs:{closable:""},on:{close:function($event){return _vm.handleRemove(file)},click:function($event){return _vm.handleFileClick(file)}}},[_vm._v("\n "+_vm._s(file.name)+"\n ")])}),_vm._v(" "),_vm.fileList.length>0&&_vm.options.variable&&_vm.options.variable.enable?_c("div",{staticStyle:{display:"flex","align-items":"center"}},[_c("span",{staticStyle:{color:"#f56c6c","margin-right":"5px"}},[_vm._v("*")]),_vm._v(" "),_c("long-variable-viewer-button",{ref:"variableViewerRef",attrs:{values:_vm.fileData,menus:_vm.options.variable.menus},on:{"update:columns":_vm.handleUpdateColumns,"table-data-updated":_vm.handleTableDataUpdated}})],1):_vm._e()],2)]):_vm._e()]),_vm._v(" "),_vm.fileList.length>0&&_vm.options.variable&&_vm.options.variable.enable&&_vm.hasConfiguredVariables?_c("div",{staticClass:"variable-config-section"},[_c("div",{staticClass:"config-header",on:{click:_vm.toggleCollapse}},[_c("span",{staticClass:"config-title"},[_vm._v("当前变量配置")]),_vm._v(" "),_c("i",{staticClass:"el-icon-caret-bottom collapse-arrow",class:{"is-collapsed":_vm.isCollapsed}})]),_vm._v(" "),_c("div",{directives:[{name:"show",rawName:"v-show",value:!_vm.isCollapsed,expression:"!isCollapsed"}],staticClass:"config-content"},[0===_vm.currentVariableValues.length?_c("div",{staticClass:"no-data"},[_vm._v("\n 暂无数据\n ")]):_c("el-table",{staticStyle:{width:"100%"},attrs:{data:_vm.currentVariableValues,size:"mini","max-height":"300",border:""}},[_c("el-table-column",{attrs:{prop:"field",label:"字段名","show-overflow-tooltip":""}}),_vm._v(" "),_c("el-table-column",{attrs:{prop:"fullPath",label:"属性","show-overflow-tooltip":""}})],1),_vm._v(" "),_c("div",{staticClass:"debug-info",staticStyle:{"margin-top":"8px","font-size":"12px",color:"#999"}},[_vm._v("\n 数据条数: "+_vm._s(_vm.currentVariableValues.length)+"\n ")])],1)]):_vm._e(),_vm._v(" "),_c("long-excel-viewer",{attrs:{visible:_vm.previewVisible,url:_vm.previewUrl},on:{"update:visible":function($event){_vm.previewVisible=$event}}})],1)},staticRenderFns:[function(){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c("div",{staticStyle:{"font-size":"12px",color:"#999","line-height":"20px"}},[_c("i",{staticClass:"el-icon-info",staticStyle:{"margin-right":"5px"}}),_vm._v(" "),_c("span",[_vm._v("点击文件名称可预览文件")])])}],name:"LongUploader",props:{options:{type:Object,default:()=>({variable:{enable:false,values:[],menus:[]},example:{value:""},file:{id:"",name:""}})},value:{type:Object,default:()=>({fileId:"",columns:[],fileName:""})},fileId:{type:String,default:""},limit:{type:Number,default:1},fileSize:{type:Number,default:3},fileType:{type:String,default:".xlsx,.xls,.csv"}},data:()=>({uploadUrl:`${process.env.VUE_APP_BASE_API}/file/upload`,fileList:[],token:"",fileData:[],fileToken:"",variableViewerRef:null,isCollapsed:true,hasTriggerUpdate:false,previewVisible:false,previewUrl:"",tableDataCache:[]}),computed:{currentVariableValues(){return this.tableDataCache.map(item=>({field:item.field||"",fullPath:item.fullPath||"",varType:item.varType||"",attr:item.attr||""}))},hasConfiguredVariables(){return this.currentVariableValues.length>0}},created(){this.token=localStorage.getItem("token")},watch:{fileId:{handler(val){this.fileToken=val},immediate:true,deep:true},value:{handler(val,oldVal){console.log("value",val,oldVal);if(val&&val.fileId&&(!oldVal||oldVal.fileId!==val.fileId)){this.fileToken=val.fileId;this.downloadFile(val.fileId,val.columns||{})}if(val&&val.fileName&&(!oldVal||oldVal.fileName!==val.fileName))this.fileList=[{name:val.fileName,uid:val.fileId}]},immediate:true,deep:true}},methods:{downloadFile(fileId,columns={}){this.$api.dataAnalysis.filePreview({fileId}).then(res=>{if(res&&res.data&&res.data.records&&res.data.records.length>0){const headers=res.data.records[0].headers||[];this.$emit("update:headers",headers);const menus=this.options.variable.menus||[];const obj={};headers.forEach(o=>{obj[o]={field:o,varType:"",attr:""}});console.log("Parsing columns:",columns);if(columns&&"object"===typeof columns)Object.keys(columns).forEach(columnKey=>{const columnData=columns[columnKey];console.log(`Processing column ${columnKey}:`,columnData);if(columnData&&columnData.values&&Array.isArray(columnData.values)){const menu=menus.find(menu=>menu.fieldName===columnKey);console.log(`Found menu for ${columnKey}:`,menu);if(menu)columnData.values.forEach(fieldName=>{if(obj[fieldName]){obj[fieldName]={field:fieldName,varType:menu.label||columnKey,attr:menu.label||columnKey};console.log(`Set field ${fieldName} with varType: ${menu.label||columnKey}`)}})}});this.fileData=[{...obj}];console.log("Final fileData:",this.fileData);this.$nextTick(()=>{if(this.$refs.variableViewerRef&&columns&&Object.keys(columns).length>0)if("function"===typeof this.$refs.variableViewerRef.$restoreConfig){this.$refs.variableViewerRef.$restoreConfig(columns);this.$nextTick(()=>{if(this.$refs.variableViewerRef&&"function"===typeof this.$refs.variableViewerRef.updateTableData)this.$refs.variableViewerRef.updateTableData()})}const id=this.$route.query.id;if(id){if(this.hasTriggerUpdate)return;if("function"===typeof this.$refs.variableViewerRef.$triggerUpdate)this.$refs.variableViewerRef.$triggerUpdate();this.hasTriggerUpdate=true}})}}).catch(err=>{this.$message.error(err.message||"数据文件内容不匹配,请重新上传");console.log("err",err)}).finally(()=>{this.loading=false})},handleColumns(fileData=[]){const menus=this.options.variable.menus||[];console.log("menus",menus);if(0==menus.length)return;fileData.forEach(item=>{console.log("item",item);const menu=menus.find(menu=>menu.fieldName==item.fieldName);console.log("menu",menu);item.varType=menu.label;item.attr=menu.attr})},handleTableDataUpdated(tableData){if(Array.isArray(tableData)){this.tableDataCache=tableData;console.log("Uploader - tableDataCache updated from event:",this.tableDataCache)}},handleUpdateColumns(columns){console.log("columns",columns);this.$emit("update:columns",columns)},beforeUpload(file){console.log(file);if(file.size>1024*this.fileSize*1024){this.$message.error(`上传文件大小不能超过 ${this.fileSize} MB!`);return false}const allowedTypes=["application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/vnd.ms-excel","text/csv"];const fileType=file.type;const fileName=file.name.toLowerCase();if(!allowedTypes.includes(fileType)&&!fileName.endsWith(".xlsx")&&!fileName.endsWith(".xls")&&!fileName.endsWith(".csv")){this.$message.error("只支持上传 xlsx、xls、csv 格式的文件!");return false}return true},handleChange(file,fileList){if(fileList.length>1)this.fileList=[fileList[fileList.length-1]];else this.fileList=fileList.filter(o=>void 0!==o.raw);console.log("file",file,fileList);if("success"===file.status){const response=file.response;if(response&&200===response.code){this.fileToken=response.data.id;this.$emit("update:fileId",this.fileToken);this.loadFromUrl(this.fileToken)}}},loadFromUrl(fileId){this.$api.dataAnalysis.filePreview({fileId}).then(res=>{if(res&&res.data&&res.data.records&&res.data.records.length>0){const firstRow=res.data.records[0]||{data:[],headers:[]};const headers=firstRow.headers||[];if(headers.length>0){this.$emit("update:headers",headers);const obj={};headers.forEach(o=>{obj[o]={field:o,varType:"",attr:""}});this.fileData=[{...obj}]}else{this.$emit("update:headers",[]);this.fileData=[]}}})},handleRemove(file){this.fileList=this.fileList.filter(f=>f.uid!==file.uid);this.fileToken="";this.fileData=[];this.$emit("update:fileId","");this.$emit("update:headers",[])},onAdjust(){this.$emit("adjust")},handleRemove1(file,fileList){console.log(file,fileList)},handlePreview(file){console.log(file)},handleExceed(files,fileList){this.$message.warning(`上传文件数量不能超过 ${this.limit} 个!`);if(fileList.length>this.limit)this.fileList=fileList.slice(-this.limit)},beforeRemove:()=>true,toggleCollapse(){this.isCollapsed=!this.isCollapsed},handleFileClick(){event.stopPropagation();if(this.fileToken){this.previewUrl=`${process.env.VUE_APP_BASE_API}/file/preview/${this.fileToken}`;this.previewVisible=true}else this.$message.warning("文件ID不存在,无法预览")}}};LongUploader.install=function install(Vue){Vue.component(LongUploader.name,LongUploader)};var css_248z$4=".long-radio-wrapper{display:flex;flex-wrap:wrap}.long-radio-wrapper ::v-deep .el-radio{line-height:24px;margin-bottom:0}.long-radio-wrapper ::v-deep .el-radio__label{display:inline-block;vertical-align:middle;white-space:normal;word-break:break-all}.long-radio-item{margin:4px 12px 4px 0;width:100px}";styleInject(css_248z$4);var Radio={render:function(){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c("el-radio-group",_vm._g(_vm._b({staticClass:"long-radio-wrapper"},"el-radio-group",_vm.$attrs,false),_vm.$listeners),_vm._l(_vm.options,function(item,index){return _c("el-radio",{key:index,staticClass:"long-radio-item",attrs:{label:item[_vm.valueKey],disabled:item[_vm.disabledOption]}},[_vm._v("\n "+_vm._s(item[_vm.labelKey])+"\n ")])}),1)},staticRenderFns:[],name:"LongRadio",props:{dataList:{type:Array,default:()=>[]},disabledOption:{type:[Boolean,Number],default:false},valueKey:{type:[String,Number],default:"value"},labelKey:{type:[String,Number],default:"label"},mode:{type:String,default:"local"},dict:{type:String,default:""},url:{type:String,default:""},requestParams:{type:Object,default:()=>{}},placeholder:{type:String,default:"请选择"}},data:()=>({options:[]}),watch:{dataList:{deep:true,immediate:true,handler(val){if("local"===this.mode)this.options=val}},dict:{deep:true,handler(val){this.init()}}},created(){this.init()},methods:{init(){if("remote"===this.mode&&this.dict)this.getDicts(this.dict).then(res=>{this.options=(res.data||[]).map(item=>({[this.valueKey]:item.dictCode,[this.labelKey]:item.dictLabel}))})}}};Radio.install=function install(Vue){Vue.component(Radio.name,Radio)};var css_248z$3=".long-group{background-color:#f8f8f8;box-sizing:border-box;height:100%;padding:10px;width:100%}.long-group .group-header{color:#333;font-size:14px;font-weight:700}";styleInject(css_248z$3);var Group={render:function(){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c("div",{staticClass:"long-group"},[_c("div",{staticClass:"group-header"},[_vm._v(_vm._s(_vm.label))]),_vm._v(" "),_vm._t("default")],2)},staticRenderFns:[],name:"LongGroup",props:{label:{type:String,default:""}}};Group.install=function install(Vue){Vue.component(Group.name,Group)};var css_248z$2=".long-color-picker{width:200px}.long-color-picker .el-color-picker__trigger{width:100%}.long-color-picker .el-color-picker__trigger .el-color-picker__icon{left:unset!important;right:5px!important;width:unset!important}";styleInject(css_248z$2);var ColorPicker={render:function(){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c("el-color-picker",_vm._g(_vm._b({staticClass:"long-color-picker"},"el-color-picker",_vm.$attrs,false),_vm.$listeners))},staticRenderFns:[],name:"LongColorPicker"};ColorPicker.install=function install(Vue){Vue.component(ColorPicker.name,ColorPicker)};var css_248z$1="";styleInject(css_248z$1);var NumberInput={render:function(){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c("el-input-number",_vm._g(_vm._b({staticClass:"long-number-input",attrs:{"controls-position":"right",step:_vm.stepValue,value:_vm.value,max:_vm.maxValue,min:_vm.minValue},on:{input:function($event){return _vm.$emit("input",$event)}}},"el-input-number",_vm.$attrs,false),_vm.$listeners))},staticRenderFns:[],name:"LongNumberInput",props:{value:{type:[String,Number],default:0},placeholder:{type:String,default:"请输入"},max:{type:[Number,String],default:""},min:{type:[Number,String],default:""},step:{type:[Number,String],default:1}},data(){return{maxValue:""===this.max?Number.MAX_SAFE_INTEGER:Number(this.max),minValue:""===this.min?Number.MIN_SAFE_INTEGER:Number(this.min),stepValue:Number(this.step)}},watch:{max:{handler(val){this.maxValue=""===val?Number.MAX_SAFE_INTEGER:Number(val)},immediate:true},min:{handler(val){this.minValue=""===val?Number.MIN_SAFE_INTEGER:Number(val)},immediate:true},step:{handler(val){this.stepValue=Number(val)},immediate:true}}};NumberInput.install=function install(Vue){Vue.component(NumberInput.name,NumberInput)};var css_248z=".long-checkbox-wrapper{display:flex;flex-wrap:wrap}.long-checkbox-wrapper ::v-deep .el-checkbox{line-height:24px;margin-bottom:0}.long-checkbox-item{margin:1px 6px 1px 0;min-width:50px}";styleInject(css_248z);var CheckBox={render:function(){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c("el-checkbox-group",_vm._g(_vm._b({staticClass:"long-checkbox-wrapper",attrs:{value:_vm.value},on:{change:_vm.handleInput}},"el-checkbox-group",_vm.$attrs,false),_vm.$listeners),_vm._l(_vm.options,function(item,index){return _c("el-checkbox",{key:index,staticClass:"long-checkbox-item",attrs:{label:item[_vm.valueKey],disabled:_vm.getDisabled(item)}},[_vm._v("\n "+_vm._s(item[_vm.labelKey])+"\n ")])}),1)},staticRenderFns:[],name:"LongCheckBox",props:{value:{type:Array,default:()=>[]},dataList:{type:Array,default:()=>[]},disabledOption:{type:[String,Boolean,Number],default:false},valueKey:{type:[String,Number],default:"value"},labelKey:{type:[String,Number],default:"label"},mode:{type:String,default:"local"},dict:{type:String,default:""},url:{type:String,default:""},requestParams:{type:Object,default:()=>{}},placeholder:{type:String,default:"请选择"}},data:()=>({options:[]}),watch:{dataList:{deep:true,immediate:true,handler(val){if("local"===this.mode)this.options=val}},dict:{deep:true,handler(val){this.init()}}},created(){this.init()},methods:{init(){if("remote"===this.mode&&this.dict)this.getDicts(this.dict).then(res=>{this.options=(res.data||[]).map(item=>({[this.valueKey]:item.dictCode,[this.labelKey]:item.dictLabel}))})},handleInput(value){this.$emit("input",value);this.$emit("change",value);console.log(value,999)},getDisabled(item){if("string"===typeof this.disabledOption)return item[this.disabledOption]||false;if("boolean"===typeof this.disabledOption)return this.disabledOption;if("number"===typeof this.disabledOption)return item[this.disabledOption]||false;return false}}};CheckBox.install=function install(Vue){Vue.component(CheckBox.name,CheckBox)};var components=[Input,Select,VariableViewer,ExcelViewer,VariableViewerButton,ExcelViewerButton,LongUploader,Radio,Group,ColorPicker,NumberInput,CheckBox];function toKebabCase(str){if(!str)return str;return str.replace(/([A-Z])/g,"-$1").toLowerCase().replace(/^-/,"")}var _install=function install(Vue){if(_install.installed)return;_install.installed=true;var elementUIComponents=["ElInput","ElSelect","ElOption","ElCheckbox","ElCheckboxGroup","ElRadio","ElRadioGroup","ElButton","ElDialog","ElTable","ElTableColumn","ElUpload","ElTag","ElPagination","ElInputNumber","ElColorPicker","ElForm","ElFormItem","ElIcon"];elementUIComponents.forEach(function(componentName){var component=Vue.options.components[componentName];if(!component){var kebabName=toKebabCase(componentName);component=Vue.options.components[kebabName]}if(component){var _kebabName=toKebabCase(componentName);if(_kebabName&&_kebabName!==componentName)if(!Vue.options.components[_kebabName])Vue.component(_kebabName,component);if(!Vue.options.components[componentName])Vue.component(componentName,component)}else if("production"!==process.env.NODE_ENV)console.warn("[WiserComponents] Element-UI component ".concat(componentName," not found. Make sure Element-UI is installed and registered before using WiserComponents."))});if("function"===typeof Vue.nextTick)Vue.nextTick(function(){elementUIComponents.forEach(function(componentName){var component=Vue.options.components[componentName];if(component){var kebabName=toKebabCase(componentName);if(kebabName&&kebabName!==componentName)if(!Vue.options.components[kebabName])Vue.component(kebabName,component)}})});components.forEach(function(component){if(!component)return;var componentName=component.name||component.options&&component.options.name;if(!componentName)return;Vue.component(componentName,component);var kebabName=toKebabCase(componentName);if(kebabName&&kebabName!==componentName)Vue.component(kebabName,component)})};if("undefined"!==typeof window&&window.Vue)_install(window.Vue);var index={version:"1.0.0",install:_install,Input,Select,VariableViewer,ExcelViewer,VariableViewerButton,ExcelViewerButton,Uploader:LongUploader,Radio,Group,ColorPicker,NumberInput,CheckBox};exports.CheckBox=CheckBox;exports.ColorPicker=ColorPicker;exports.ExcelViewer=ExcelViewer;exports.ExcelViewerButton=ExcelViewerButton;exports.Group=Group;exports.Input=Input;exports.NumberInput=NumberInput;exports.Radio=Radio;exports.Select=Select;exports.Uploader=LongUploader;exports.VariableViewer=VariableViewer;exports.VariableViewerButton=VariableViewerButton;exports["default"]=index;
package/lib/index.umd.js CHANGED
@@ -1 +1 @@
1
- var e,t;e=this,t=function(e,t,i,a){"use strict";function l(e,t){void 0===t&&(t={});var i=t.insertAt;if(e&&"undefined"!=typeof document){var a=document.head||document.getElementsByTagName("head")[0],l=document.createElement("style");l.type="text/css","top"===i&&a.firstChild?a.insertBefore(l,a.firstChild):a.appendChild(l),l.styleSheet?l.styleSheet.cssText=e:l.appendChild(document.createTextNode(e))}}function s(e){return e?e.replace(/([A-Z])/g,"-$1").toLowerCase().replace(/^-/,""):e}var o=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(a);l(".long-input-wrapper{background-color:#fff;border:1px solid #e0e0e0;border-radius:4px;padding:8px}.intTxt{width:80%}");var r={render(){var e=this,t=e.$createElement;return(e.i.t||t)("el-input",e.l(e.o({staticClass:"intTxt",attrs:{"show-word-limit":e.showWordLimit,placeholder:e.placeholder,"auto-complete":"new-password",disabled:e.disabled},on:{input:t=>e.$emit("input",t)}},"el-input",e.$attrs,!1),e.$listeners),[e.p(Object.keys(this.$slots),function(t){return e.h(t,null,{slot:t})})],2)},staticRenderFns:[],name:"LongInput",props:{showWordLimit:{type:Boolean,default:!0},disabled:{type:Boolean,default:!1},placeholder:{type:String,default:"请输入"}},install(e){e.component(r.name,r)}};l("");var n={render(){var e=this,t=e.$createElement,i=e.i.t||t;return i("el-select",e.l(e.o({attrs:{value:e.value,placeholder:e.placeholder}},"el-select",e.$attrs,!1),e.$listeners),[e.h("unshift"),e.u(" "),e.h("default",function(){return e.p(e.options,function(t,a){return i("el-option",{key:a,attrs:{value:t[e.valueKey],label:t[e.labelKey],disabled:t[e.disabledOption]}})})},{slot:"default"}),e.u(" "),e.h("prefix",null,{slot:"prefix"}),e.u(" "),e.h("empty",null,{slot:"empty"})],2)},staticRenderFns:[],name:"LongSelect",props:{value:{type:[String,Number],default:""},dataList:{type:Array,default:()=>[]},disabledOption:{type:[Boolean,Number],default:!1},valueKey:{type:[String,Number],default:"value"},labelKey:{type:[String,Number],default:"label"},mode:{type:String,default:"local"},dict:{type:String,default:""},url:{type:String,default:""},requestParams:{type:Object,default(){}},placeholder:{type:String,default:"请选择"}},data(){return{options:[]}},watch:{dataList:{deep:!0,immediate:!0,handler(e){"local"===this.mode&&(this.options=e)}},dict:{deep:!0,handler(e){this.init()}}},created(){this.init()},methods:{init(){"remote"===this.mode&&this.dict&&this.getDicts(this.dict).then(e=>{this.options=(e.data||[]).map(e=>({[this.valueKey]:e.dictCode,[this.labelKey]:e.dictLabel}))})}},install(e){e.component(n.name,n)}};l(".variable-config-dialog :deep(.el-dialog__body){padding:20px}.variable-config-dialog :deep(.el-dialog__header){padding:20px 20px 10px}.dialog-title{align-items:center;color:#303133;display:flex;font-size:16px;font-weight:700;gap:24px;padding:0 20px}.dialog-title .title-left{color:#303133;flex:1;min-width:500px}.dialog-title .title-separator{color:#dcdfe6;flex-shrink:0;font-weight:400}.dialog-title .title-right{color:#303133;flex:1;min-width:400px}.dialog-body{display:flex;gap:24px;min-height:500px}.left-section{flex:1;min-width:500px}.section-title{color:#303133;font-size:16px;font-weight:700;margin-bottom:16px}.variable-selector{align-items:flex-start;display:flex;gap:16px}.variable-panel{border:1px solid #dcdfe6;border-radius:4px;display:flex;flex:1;flex-direction:column;height:500px;overflow:hidden}.panel-header{align-items:center;background:#f5f7fa;border-bottom:1px solid #dcdfe6;display:flex;justify-content:space-between;padding:12px 16px}.select-all-checkbox :deep(.el-checkbox__label){padding-left:8px}.panel-title{color:#303133;font-weight:500}.panel-count{color:#909399;font-size:12px}.panel-search{border-bottom:1px solid #dcdfe6;padding:12px}.panel-list{flex:1;overflow-y:auto;padding:8px}.variable-item{border-radius:4px;cursor:pointer;padding:8px 12px;transition:background-color .2s}.variable-item:hover{background-color:#f5f7fa}.variable-item :deep(.el-checkbox){width:100%}.variable-item :deep(.el-checkbox__label){width:100%}.arrow-buttons{display:flex;flex-direction:column;gap:12px;justify-content:center;padding-top:100px}.arrow-buttons .el-button{margin-left:0!important}.right-section{display:flex;flex:1;flex-direction:column;min-width:400px;overflow:hidden}.config-desc{color:#909399;flex-shrink:0;font-size:13px;line-height:1.5;margin-bottom:24px}.config-group{margin-bottom:32px}.config-group:last-child{margin-bottom:0}.config-label{color:#303133;font-size:14px;font-weight:500;margin-bottom:12px}.config-options{display:flex;flex:1;flex-direction:column;gap:16px;margin-top:16px;overflow-x:hidden;overflow-y:auto;padding-right:8px}.config-options::-webkit-scrollbar{width:6px}.config-options::-webkit-scrollbar-track{background:#f1f1f1;border-radius:3px}.config-options::-webkit-scrollbar-thumb{background:#c1c1c1;border-radius:3px}.config-options::-webkit-scrollbar-thumb:hover{background:#a8a8a8}.config-option-row{align-items:center;display:flex;gap:12px;margin-bottom:8px}.config-option-row.is-parent .option-label{color:#303133;font-weight:500}.config-option-row.is-leaf .option-label{color:#606266}.option-label{color:#606266;flex:1;font-size:13px;min-width:0;white-space:normal;word-break:break-all}.option-label.required{color:#303133;font-weight:500}.option-label .required-mark{color:#f56c6c;margin-left:2px}.config-select{flex-shrink:0;width:350px}.non-leaf-label{color:#909399;font-size:13px;font-style:italic}.disabled-option{cursor:not-allowed!important}.disabled-option,.disabled-text{color:#c0c4cc!important}:deep(.el-select-dropdown__item.is-disabled){color:#c0c4cc!important;cursor:not-allowed!important}:deep(.el-select-dropdown__item.is-disabled) span{color:#c0c4cc!important}.checkbox-list{border:1px solid #dcdfe6;border-radius:4px;display:flex;flex:1;flex-direction:column;gap:8px;max-height:200px;overflow-y:auto;padding:8px}.dialog-footer{text-align:right}");var d={render(){var e=this,t=e.$createElement,i=e.i.t||t;return i("div",[i("el-dialog",{staticClass:"variable-config-dialog",staticStyle:{"max-height":"90vh"},attrs:{visible:e.dialogVisible,width:"1200px"},on:{"update:visible"(t){e.dialogVisible=t},close:e.handleClose}},[i("div",{staticClass:"dialog-title",attrs:{slot:"title"},slot:"title"},[i("span",{staticClass:"title-left"},[e.u("选择分析变量")]),e.u(" "),i("span",{staticClass:"title-separator"},[e.u("|")]),e.u(" "),i("span",{staticClass:"title-right"},[e.u("配置变量")])]),e.u(" "),i("div",{staticClass:"dialog-body"},[i("div",{staticClass:"left-section"},[i("div",{staticClass:"variable-selector"},[i("div",{staticClass:"variable-panel"},[i("div",{staticClass:"panel-header"},[i("el-checkbox",{staticClass:"select-all-checkbox",attrs:{indeterminate:e.leftIndeterminate},on:{change:e.handleLeftSelectAll},model:{value:e.leftSelectAll,callback(t){e.leftSelectAll=t},expression:"leftSelectAll"}},[i("span",{staticClass:"panel-title"},[e.u("全选")])]),e.u(" "),i("span",{staticClass:"panel-count"},[e.u(e.m(e.selectedAllCount)+"/"+e.m(e.allVariables.length))])],1),e.u(" "),i("div",{staticClass:"panel-search"},[i("el-input",{attrs:{placeholder:"请输入关键字","suffix-icon":"el-icon-search",size:"small"},on:{input:e.handleLeftSearch},model:{value:e.leftKeyword,callback(t){e.leftKeyword=t},expression:"leftKeyword"}})],1),e.u(" "),i("div",{staticClass:"panel-list"},e.p(e.filteredLeftVariables,function(t){return i("div",{key:t.field,staticClass:"variable-item"},[i("el-checkbox",{on:{change:i=>e.handleLeftCheckChange(t)},model:{value:t.checked,callback(i){e.$set(t,"checked",i)},expression:"item.checked"}},[e.u("\n "+e.m(t.field)+"\n ")])],1)}),0)]),e.u(" "),i("div",{staticClass:"arrow-buttons"},[i("el-button",{attrs:{type:"primary",icon:"el-icon-arrow-right",size:"small",disabled:!e.hasLeftSelected},on:{click:e.moveToRight}}),e.u(" "),i("el-button",{attrs:{type:"danger",icon:"el-icon-arrow-left",size:"small",disabled:!e.hasRightSelected},on:{click:e.moveToLeft}})],1),e.u(" "),i("div",{staticClass:"variable-panel"},[i("div",{staticClass:"panel-header"},[i("el-checkbox",{staticClass:"select-all-checkbox",attrs:{indeterminate:e.rightIndeterminate},on:{change:e.handleRightSelectAll},model:{value:e.rightSelectAll,callback(t){e.rightSelectAll=t},expression:"rightSelectAll"}},[i("span",{staticClass:"panel-title"},[e.u("已选")])]),e.u(" "),i("span",{staticClass:"panel-count"},[e.u(e.m(e.selectedRightCount)+"/"+e.m(e.selectedVariables.length))])],1),e.u(" "),i("div",{staticClass:"panel-search"},[i("el-input",{attrs:{placeholder:"请输入关键字","suffix-icon":"el-icon-search",size:"small"},on:{input:e.handleRightSearch},model:{value:e.rightKeyword,callback(t){e.rightKeyword=t},expression:"rightKeyword"}})],1),e.u(" "),i("div",{staticClass:"panel-list"},e.p(e.filteredRightVariables,function(t){return i("div",{key:t.field,staticClass:"variable-item"},[i("el-checkbox",{on:{change:i=>e.handleRightCheckChange(t)},model:{value:t.checked,callback(i){e.$set(t,"checked",i)},expression:"item.checked"}},[e.u("\n "+e.m(t.field)+"\n ")])],1)}),0)])])]),e.u(" "),i("div",{staticClass:"right-section"},[i("div",{staticClass:"config-desc"},[e.u("\n 数据文件中因变量的值,需赋予参考值,方便精准进行数据分析。\n ")]),e.u(" "),i("div",{staticClass:"config-options"},e.p(e.flatMenuItems,function(t){return i("div",{key:t.pathString,staticClass:"config-option-row"},[i("span",{staticClass:"option-label",class:{required:t.required}},[e.u("\n "+e.m(t.pathString)+"\n "),t.required?i("span",{staticClass:"required-mark"},[e.u("*")]):e.v()]),e.u(" "),i("el-select",{staticClass:"config-select",attrs:{placeholder:e.getPlaceholder(t),clearable:t.nullable,multiple:t.multiple},on:{change:i=>e.handleConfigChange(t.pathString,i)},model:{value:e.configValues[t.pathString],callback(i){e.$set(e.configValues,t.pathString,i)},expression:"configValues[menuItem.pathString]"}},e.p(e.getAvailableOptions(t.pathString,t.multiple),function(t){return i("el-option",{key:t.value,class:{"disabled-option":t.disabled},attrs:{label:t.label,value:t.value,disabled:t.disabled}},[i("span",{class:{"disabled-text":t.disabled}},[e.u(e.m(t.label))])])}),1)],1)}),0)])]),e.u(" "),i("div",{staticClass:"dialog-footer",attrs:{slot:"footer"},slot:"footer"},[i("el-button",{on:{click:e.handleClose}},[e.u("取消")]),e.u(" "),i("el-button",{staticStyle:{color:"#fff"},attrs:{type:"primary"},on:{click:e.handleSave}},[e.u("保存")])],1)])],1)},staticRenderFns:[],name:"LongVariableViewer",props:{visible:{type:Boolean,default:!1},values:{type:Array,default:()=>[]},menus:{type:Array,default:()=>[]}},data(){return{dialogVisible:!1,leftKeyword:"",rightKeyword:"",allVariables:[],selectedVariables:[],configValues:{},configChangeTimer:null}},computed:{filteredLeftVariables(){return this.leftKeyword?this.allVariables.filter(e=>e.field.toLowerCase().includes(this.leftKeyword.toLowerCase())):this.allVariables},filteredRightVariables(){return this.rightKeyword?this.selectedVariables.filter(e=>e.field.toLowerCase().includes(this.rightKeyword.toLowerCase())):this.selectedVariables},selectedAllCount(){return this.allVariables.filter(e=>e.checked).length},selectedRightCount(){return this.selectedVariables.filter(e=>e.checked).length},hasLeftSelected(){return this.allVariables.some(e=>e.checked)},hasRightSelected(){return this.selectedVariables.some(e=>e.checked)},leftSelectAll:{get(){const e=this.filteredLeftVariables;return 0!==e.length&&e.every(e=>e.checked)},set(){}},leftIndeterminate(){const e=this.filteredLeftVariables;if(0===e.length)return!1;const t=e.filter(e=>e.checked).length;return t>0&&t<e.length},rightSelectAll:{get(){const e=this.filteredRightVariables;return 0!==e.length&&e.every(e=>e.checked)},set(){}},rightIndeterminate(){const e=this.filteredRightVariables;if(0===e.length)return!1;const t=e.filter(e=>e.checked).length;return t>0&&t<e.length},flatMenuItems(){if(!this.menus||0===this.menus.length)return[];const e=[],t=(i,a=[])=>{const l=[...a,i.label];if(i.children&&0!==i.children.length)i.children&&i.children.length>0&&i.children.forEach(e=>{t(e,l)});else{const t=l.join("/");e.push({label:i.label,path:l,pathString:t,isLeaf:!0,id:i.id,fieldName:i.fieldName,required:i.required,nullable:i.nullable,multiple:i.multiple,originalMenu:i})}};return this.menus.forEach(e=>{t(e)}),e},tableData(){const e=[];return Object.keys(this.configValues).forEach(t=>{const i=this.configValues[t];if(!i||Array.isArray(i)&&0===i.length)return;const a=this.flatMenuItems.find(e=>e.pathString===t);if(!a)return;const l=a.pathString;(Array.isArray(i)?i:[i]).forEach(t=>{const i=t+"";i&&e.push({field:i,fullPath:l,varType:a.path&&a.path.length>0?a.path[0]:l,attr:a.path&&a.path.length>0?a.path[a.path.length-1]:""})})}),e}},watch:{visible:{handler(e){this.dialogVisible=e},immediate:!0},dialogVisible(e){this.$emit("update:visible",e)},values:{handler(e){this.handleValuesChange(e)},immediate:!0,deep:!0},selectedVariables:{handler(){const e=this.selectedVariables.map(e=>e.field),t={...this.configValues};let i=!1;Object.keys(t).forEach(a=>{const l=t[a];if(Array.isArray(l)){const s=l.filter(t=>e.includes(t));s.length!==l.length&&(t[a]=s,i=!0)}else l&&!e.includes(l)&&(t[a]="",i=!0)}),i&&(this.configValues=t)},deep:!0},configValues:{handler(){this.configChangeTimer&&clearTimeout(this.configChangeTimer),this.configChangeTimer=setTimeout(()=>{this.$nextTick(()=>{this.$emit("config-changed",this.tableData)})},100)},deep:!0}},methods:{handleValuesChange(e){if(!e||0===e.length)return this.allVariables=[],this.selectedVariables=[],void 0;const t=[];if(e.length>0){const i=e[0];"object"==typeof i&&null!==i&&t.push(...Object.keys(i))}this.allVariables=t.map(e=>({field:e,checked:!1})),this.selectedVariables=[]},handleLeftSearch(){},handleRightSearch(){},handleLeftCheckChange(){},handleRightCheckChange(){},handleLeftSelectAll(e){this.filteredLeftVariables.forEach(t=>{t.checked=e})},handleRightSelectAll(e){this.filteredRightVariables.forEach(t=>{t.checked=e})},moveToRight(){const e=this.allVariables.filter(e=>e.checked);0!==e.length&&(e.forEach(e=>{e.checked=!1,this.selectedVariables.find(t=>t.field===e.field)||this.selectedVariables.push({field:e.field,checked:!1})}),this.allVariables=this.allVariables.filter(t=>!e.some(e=>e.field===t.field)))},moveToLeft(){const e=this.selectedVariables.filter(e=>e.checked);0!==e.length&&(e.forEach(e=>{e.checked=!1,this.allVariables.find(t=>t.field===e.field)||this.allVariables.push({field:e.field,checked:!1})}),this.selectedVariables=this.selectedVariables.filter(t=>!e.some(e=>e.field===t.field)))},handleClose(){this.dialogVisible=!1},getPlaceholder(e){return e.required?"必选":e.nullable?"请选择":"必选"},getAvailableOptions(e,t=!1){const i=this.selectedVariables.map(e=>e.field),a=this.configValues[e],l=t?Array.isArray(a)?a:[]:a?[a]:[],s=[];return Object.keys(this.configValues).forEach(t=>{if(t!==e&&this.configValues[t]){const e=this.configValues[t];Array.isArray(e)?s.push(...e):s.push(e)}}),i.map(e=>l.includes(e)?{label:e,value:e,disabled:!1}:{label:e,value:e,disabled:s.includes(e)})},handleConfigChange(e,t){this.$set(this.configValues,e,t);const i=this.flatMenuItems.find(t=>t.pathString===e);i&&i.multiple&&!Array.isArray(t)&&this.$set(this.configValues,e,t?[t]:[])},generateConfigFromMenus(){return this.flatMenuItems.forEach(e=>{e.pathString in this.configValues||(e.multiple?this.$set(this.configValues,e.pathString,[]):this.$set(this.configValues,e.pathString,""))}),{...this.configValues}},handleSave(){const e={config:this.generateConfigFromMenus(),selectedVariables:this.selectedVariables.map(e=>e.field)};this.$emit("save",e),this.dialogVisible=!1},$restoreConfig(e){if(!e||"object"!=typeof e)return;const t=new Set;Object.keys(e).forEach(i=>{const a=e[i];a&&a.values&&Array.isArray(a.values)&&a.values.forEach(e=>t.add(e))}),t.forEach(e=>{this.selectedVariables.find(t=>t.field===e)||this.selectedVariables.push({field:e,checked:!1})}),this.configValues={},Object.keys(e).forEach(t=>{const i=e[t];if(!i||!i.values||!Array.isArray(i.values)||0===i.values.length)return;const a=this.flatMenuItems.filter(e=>e.fieldName===t);if(0!==a.length)if(1===a.length){const e=a[0],t=e.pathString;e.multiple?this.$set(this.configValues,t,[...i.values]):this.$set(this.configValues,t,i.values[0])}else{const e=a.filter(e=>!e.multiple),t=a.filter(e=>e.multiple);if(t.length>0){const e=t[0];this.$set(this.configValues,e.pathString,[...i.values])}else e.length>0&&i.values.forEach((t,i)=>{if(i<e.length){const a=e[i];this.$set(this.configValues,a.pathString,t)}})}})},$getValues(){const e={};return Object.keys(this.configValues).forEach(t=>{const i=this.configValues[t];if(!i||Array.isArray(i)&&0===i.length)return;const a=this.flatMenuItems.find(e=>e.pathString===t);if(!a||!a.fieldName)return;const l=a.fieldName;e[l]||(e[l]={values:[]}),(Array.isArray(i)?i:[i]).forEach(t=>{e[l].values.includes(t)||e[l].values.push(t)})}),e},$getTableData(){return this.generateConfigFromMenus(),void 0,this.tableData}},install(e){e.component(d.name,d)}};l(".long-excel-viewer :deep(.el-dialog__body){padding:0 10px 10px}");var c={render(){var e=this,t=e.$createElement,i=e.i.t||t;return i("div",{staticClass:"long-excel-viewer"},[i("el-dialog",{attrs:{visible:e.dialogVisible,title:"示例文件",width:"1000px"},on:{"update:visible"(t){e.dialogVisible=t},close:e.handleClose},scopedSlots:e.k([{key:"title",fn:()=>[i("div",{staticStyle:{display:"flex","justify-content":"space-between"}},[i("div",{staticStyle:{display:"flex","align-items":"center",gap:"10px"}},[i("img",{attrs:{src:e.searchIcon}}),e.u(" "),i("div",{staticStyle:{"font-weight":"bold"}},[e.u("文件预览")])]),e.u(" "),i("div",{staticStyle:{"margin-right":"30px"}},[i("el-button",{attrs:{type:"primary",icon:"el-icon-download",size:"mini",disabled:!e.tableData.length||e.downloading,loading:e.downloading},on:{click:e.downloadExcel}},[e.u("下载")])],1)])],proxy:!0}])},[e.u(" "),e.tableData.length?i("el-table",{staticStyle:{width:"100%","margin-top":"20px"},attrs:{data:e.tableData,border:"",height:"500px"}},e.p(e.columns,function(e){return i("el-table-column",{key:e,attrs:{prop:e,label:e}})}),1):e.v(),e.u(" "),e.pagination.total>0?i("el-pagination",{staticStyle:{"margin-top":"20px","text-align":"center"},attrs:{"current-page":e.pagination.current,"page-sizes":[10,20,50,100],"page-size":e.pagination.pageSize,layout:"total, sizes, prev, pager, next, jumper",total:e.pagination.total},on:{"size-change":e.handleSizeChange,"current-change":e.handleCurrentChange}}):e.v()],1)],1)},staticRenderFns:[],name:"LongExcelViewer",props:{visible:{type:Boolean,default:!1},url:{type:String,default:""}},data(){return{searchIcon:o.default,tableData:[],columns:[],rawWorkbook:null,downloading:!1,VUE_APP_BASE_API:process.env.VUE_APP_BASE_API,pagination:{total:0,current:1,pageSize:20},queryParams:{fileId:"",pageNum:1,pageSize:20}}},computed:{dialogVisible:{get(){return this.visible},set(e){this.$emit("update:visible",e)}}},watch:{visible(e){e&&this.url&&this.loadExcelFromUrl()},url(e){e&&this.visible&&this.loadExcelFromUrl()}},methods:{async loadExcelFromUrl(){if(!this.url)return;const e=this.url.split("/").pop();this.queryParams.fileId=e;try{const e=await this.$api.dataAnalysis.filePreview(this.queryParams);void 0,e&&e.data&&e.data.records&&Array.isArray(e.data.records)?(this.processTableData(e.data.records),this.pagination.total=e.data.total||0,this.pagination.current=e.data.current||1,this.pagination.pageSize=e.data.size||20):this.$message.error("数据格式错误")}catch(t){void 0,this.$message.error("加载Excel文件失败: "+t.message)}},processTableData(e){const t=e[0];t&&t.headers&&t.data&&(1==this.pagination.current&&(this.columns=t.headers||[]),this.tableData=t.data||[])},processWorkbook(e){this.rawWorkbook=e;const i=e.Sheets[e.SheetNames[0]],a=t.utils.sheet_to_json(i,{header:1});a.length&&(this.columns=a[0],this.tableData=a.slice(1).map(e=>{const t={};return this.columns.forEach((i,a)=>{t[i]=e[a]}),t}))},handleFileChange(e){const i=new FileReader;return i.onload=e=>{const i=new Uint8Array(e.target.result),a=t.read(i,{type:"array"});this.processWorkbook(a)},i.readAsArrayBuffer(e.raw),!1},downloadExcel(){if(!this.url||this.downloading)return;this.downloading=!0;const e=require("axios").create({baseURL:this.VUE_APP_BASE_API,timeout:3e4,responseType:"blob"});e.interceptors.request.use(e=>{const t=this.$store.getters.token||localStorage.getItem("token");return t&&(e.headers.Authorization="Bearer "+t),e}),e.interceptors.response.use(e=>("blob"===e.config.responseType,e),e=>Promise.reject(e));const t=this.url.split("/").pop();e.get("/file/upload/"+t).then(e=>{const t=e.data;let a="示例文件.xlsx";const l=e.headers["content-disposition"];if(l){const e=l.match(/filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/);if(e&&e[1]){a=e[1].replace(/['"]/g,"");try{a=decodeURIComponent(a)}catch(s){void 0}}}i.saveAs(t,a),this.$message.success("下载成功")}).catch(e=>{void 0,this.$message.error("下载失败,请重试")}).finally(()=>{this.downloading=!1})},closeDialog(){this.dialogVisible=!1},handleClose(){this.closeDialog(),this.tableData=[],this.columns=[],this.rawWorkbook=null},handleSizeChange(e){this.queryParams.pageSize=e,this.queryParams.pageNum=1,this.loadExcelFromUrl()},handleCurrentChange(e){this.queryParams.pageNum=e,this.loadExcelFromUrl()}},install(e){e.component(c.name,c)}};l("");var p={render(){var e=this,t=e.$createElement,i=e.i.t||t;return i("div",[i("el-button",{attrs:{size:"small",type:"primary",icon:"el-icon-setting"},on:{click:e.onAdjust}},[e.u("\n 调整变量\n ")]),e.u(" "),i("long-variable-viewer",{ref:"variableViewerRef",attrs:{visible:e.modalVisiable,values:e.values,menus:e.menus},on:{"update:visible"(t){e.modalVisiable=t},"config-changed":e.handleConfigChanged}})],1)},staticRenderFns:[],name:"LongVariableViewerButton",props:{values:{type:Array,default:()=>[]},menus:{type:Array,default:()=>[]}},data(){return{modalVisiable:!1,tableDataCache:[],updateTimer:null,valuesUpdateTimer:null,menusUpdateTimer:null,updatingTableData:!1}},mounted(){void 0,this.$nextTick(()=>{this.updateTableData()})},beforeDestroy(){this.updateTimer&&clearInterval(this.updateTimer),this.valuesUpdateTimer&&clearTimeout(this.valuesUpdateTimer),this.menusUpdateTimer&&clearTimeout(this.menusUpdateTimer)},watch:{modalVisiable(e){e||(this.$emit("update:columns",this.$refs.variableViewerRef.$getValues()),this.$nextTick(()=>{this.updateTableData()}))},values:{handler(){this.valuesUpdateTimer&&clearTimeout(this.valuesUpdateTimer),this.valuesUpdateTimer=setTimeout(()=>{this.updateTableData()},300)},deep:!0},menus:{handler(){this.menusUpdateTimer&&clearTimeout(this.menusUpdateTimer),this.menusUpdateTimer=setTimeout(()=>{this.updateTableData()},300)},deep:!0}},computed:{tableData(){return this.tableDataCache}},methods:{onAdjust(){this.modalVisiable=!0},$getValues(){return this.$refs.variableViewerRef.$getValues()},$triggerUpdate(){this.$emit("update:columns",this.$getValues()),this.$nextTick(()=>{this.updateTableData()})},$restoreConfig(e){this.$refs.variableViewerRef&&this.$refs.variableViewerRef.$restoreConfig&&(this.$refs.variableViewerRef.$restoreConfig(e),this.$nextTick(()=>{this.updateTableData()}))},handleConfigChanged(e){Array.isArray(e)&&(this.tableDataCache=e,this.$emit("table-data-updated",e))},updateTableData(){if(!this.updatingTableData)if(this.updatingTableData=!0,this.$refs.variableViewerRef&&this.$refs.variableViewerRef.$getTableData){const e=this.$refs.variableViewerRef.$getTableData()||[],t=JSON.parse(JSON.stringify(e)),i=JSON.parse(JSON.stringify(this.tableDataCache));JSON.stringify(t)!==JSON.stringify(i)?(this.tableDataCache=e,this.$nextTick(()=>{this.$emit("table-data-updated",e),this.updatingTableData=!1})):this.updatingTableData=!1}else this.tableDataCache.length>0&&(this.tableDataCache=[]),this.updatingTableData=!1}},install(e){e.component(p.name,p)}};l("");var h={render(){var e=this,t=e.$createElement,i=e.i.t||t;return i("div",{staticStyle:{display:"inline-block","margin-left":"4px"},on:{click(e){e.stopPropagation()}}},[i("el-button",{attrs:{type:"text",size:"small",icon:"el-icon-document"},on:{click:e.onExample}},[e.u("示例文件")]),e.u(" "),i("long-excel-viewer",{attrs:{visible:e.modalVisiable,url:e.url},on:{"update:visible"(t){e.modalVisiable=t}}})],1)},staticRenderFns:[],name:"LongExcelViewerButton",props:{url:{type:String,default:""}},data(){return{modalVisiable:!1}},methods:{onExample(e){e.stopPropagation(),e.preventDefault(),this.modalVisiable=!0}},install(e){e.component(h.name,h)}};l(".long-uploader-wrapper .el-form-item{margin-bottom:0}.long-uploader-wrapper :deep(.el-upload) .el-upload-dragger{height:130px!important}.long-uploader-wrapper :deep(.el-upload) .el-upload-dragger .el-icon-upload{margin:8px 0}.variable-config-section{background-color:#f8f9fa;border:1px solid #e9ecef;border-radius:4px;margin-top:16px}.config-header{align-items:center;background-color:#e8e9f2;border-bottom:1px solid #e9ecef;cursor:pointer;display:flex;justify-content:space-between;padding:0 12px;transition:background-color .2s}.config-header:hover{background-color:#f0f0f0}.config-title{color:#303133;font-size:14px;margin:0}.collapse-arrow{color:#909399;font-size:12px;transition:transform .3s ease}.collapse-arrow.is-collapsed{transform:rotate(-90deg)}.config-content{padding:12px}.variable-config-section .el-table{font-size:12px}.variable-config-section .el-table th{background-color:#f5f7fa;color:#606266;font-weight:600}.variable-config-section .el-table td{padding:8px 0}.no-data{color:#909399;font-size:14px;padding:20px;text-align:center}");var u={render(){var e=this,t=e.$createElement,i=e.i.t||t;return i("div",{staticClass:"long-uploader-wrapper"},[i("div",[i("div",{staticStyle:{float:"right","margin-top":"-80px"}},[e.options.example&&e.options.example.value?i("long-excel-viewer-button",{attrs:{url:e.options.example.value}}):e.v()],1),e.u(" "),i("div",{staticStyle:{display:"flex","align-items":"center","justify-content":"space-between","margin-bottom":"12px"}},[i("div",{staticStyle:{display:"flex","align-items":"center",gap:"12px",position:"relative"}},[i("el-upload",{attrs:{action:e.uploadUrl,headers:{Authorization:"Bearer "+e.token},"on-preview":e.handlePreview,"on-remove":e.handleRemove,"before-remove":e.beforeRemove,"on-change":e.handleChange,"before-upload":e.beforeUpload,accept:e.fileType,drag:"","on-exceed":e.handleExceed,"file-list":e.fileList}},[i("i",{staticClass:"el-icon-upload",staticStyle:{color:"#6C1537"}}),e.u(" "),i("div",{staticClass:"el-upload__text"},[i("div",{staticStyle:{"line-height":"18px"}},[e.u("将文件拖到此处,或"),i("em",[e.u("点击上传")])]),e.u(" "),i("div",{staticStyle:{"line-height":"18px"}},[e.u("\n 支持上传"),i("em",[e.u("xlsx")]),e.u("、"),i("em",[e.u("xls")]),e.u("、"),i("em",[e.u("csv")])])])])],1)]),e.u(" "),e.fileList.length>0?i("div",{staticStyle:{"margin-top":"-20px"}},[e.C(0),e.u(" "),i("div",[e.p(e.fileList,function(t){return i("el-tag",{key:t.uid,staticStyle:{"margin-right":"8px",cursor:"pointer"},attrs:{closable:""},on:{close:i=>e.handleRemove(t),click:i=>e.handleFileClick(t)}},[e.u("\n "+e.m(t.name)+"\n ")])}),e.u(" "),e.fileList.length>0&&e.options.variable&&e.options.variable.enable?i("div",{staticStyle:{display:"flex","align-items":"center"}},[i("span",{staticStyle:{color:"#f56c6c","margin-right":"5px"}},[e.u("*")]),e.u(" "),i("long-variable-viewer-button",{ref:"variableViewerRef",attrs:{values:e.fileData,menus:e.options.variable.menus},on:{"update:columns":e.handleUpdateColumns,"table-data-updated":e.handleTableDataUpdated}})],1):e.v()],2)]):e.v()]),e.u(" "),e.fileList.length>0&&e.options.variable&&e.options.variable.enable&&e.hasConfiguredVariables?i("div",{staticClass:"variable-config-section"},[i("div",{staticClass:"config-header",on:{click:e.toggleCollapse}},[i("span",{staticClass:"config-title"},[e.u("当前变量配置")]),e.u(" "),i("i",{staticClass:"el-icon-caret-bottom collapse-arrow",class:{"is-collapsed":e.isCollapsed}})]),e.u(" "),i("div",{directives:[{name:"show",rawName:"v-show",value:!e.isCollapsed,expression:"!isCollapsed"}],staticClass:"config-content"},[0===e.currentVariableValues.length?i("div",{staticClass:"no-data"},[e.u("\n 暂无数据\n ")]):i("el-table",{staticStyle:{width:"100%"},attrs:{data:e.currentVariableValues,size:"mini","max-height":"300",border:""}},[i("el-table-column",{attrs:{prop:"field",label:"字段名","show-overflow-tooltip":""}}),e.u(" "),i("el-table-column",{attrs:{prop:"fullPath",label:"属性","show-overflow-tooltip":""}})],1),e.u(" "),i("div",{staticClass:"debug-info",staticStyle:{"margin-top":"8px","font-size":"12px",color:"#999"}},[e.u("\n 数据条数: "+e.m(e.currentVariableValues.length)+"\n ")])],1)]):e.v(),e.u(" "),i("long-excel-viewer",{attrs:{visible:e.previewVisible,url:e.previewUrl},on:{"update:visible"(t){e.previewVisible=t}}})],1)},staticRenderFns:[function(){var e=this,t=e.$createElement,i=e.i.t||t;return i("div",{staticStyle:{"font-size":"12px",color:"#999","line-height":"20px"}},[i("i",{staticClass:"el-icon-info",staticStyle:{"margin-right":"5px"}}),e.u(" "),i("span",[e.u("点击文件名称可预览文件")])])}],name:"LongUploader",props:{options:{type:Object,default:()=>({variable:{enable:!1,values:[],menus:[]},example:{value:""},file:{id:"",name:""}})},value:{type:Object,default:()=>({fileId:"",columns:[],fileName:""})},fileId:{type:String,default:""},limit:{type:Number,default:1},fileSize:{type:Number,default:3},fileType:{type:String,default:".xlsx,.xls,.csv"}},data(){return{uploadUrl:process.env.VUE_APP_BASE_API+"/file/upload",fileList:[],token:"",fileData:[],fileToken:"",variableViewerRef:null,isCollapsed:!0,hasTriggerUpdate:!1,previewVisible:!1,previewUrl:"",tableDataCache:[]}},computed:{currentVariableValues(){return this.tableDataCache.map(e=>({field:e.field||"",fullPath:e.fullPath||"",varType:e.varType||"",attr:e.attr||""}))},hasConfiguredVariables(){return this.currentVariableValues.length>0}},created(){this.token=localStorage.getItem("token")},watch:{fileId:{handler(e){this.fileToken=e},immediate:!0,deep:!0},value:{handler(e,t){void 0,!e||!e.fileId||t&&t.fileId===e.fileId||(this.fileToken=e.fileId,this.downloadFile(e.fileId,e.columns||{})),!e||!e.fileName||t&&t.fileName===e.fileName||(this.fileList=[{name:e.fileName,uid:e.fileId}])},immediate:!0,deep:!0}},methods:{downloadFile(e,t={}){this.$api.dataAnalysis.filePreview({fileId:e}).then(e=>{if(e&&e.data&&e.data.records&&e.data.records.length>0){const i=e.data.records[0].headers||[];this.$emit("update:headers",i);const a=this.options.variable.menus||[],l={};i.forEach(e=>{l[e]={field:e,varType:"",attr:""}}),t&&"object"==typeof t&&Object.keys(t).forEach(e=>{const i=t[e];if(void 0,i&&i.values&&Array.isArray(i.values)){const t=a.find(t=>t.fieldName===e);void 0,t&&i.values.forEach(i=>{l[i]&&(l[i]={field:i,varType:t.label||e,attr:t.label||e})})}}),this.fileData=[{...l}],this.$nextTick(()=>{if(this.$refs.variableViewerRef&&t&&Object.keys(t).length>0&&"function"==typeof this.$refs.variableViewerRef.$restoreConfig&&(this.$refs.variableViewerRef.$restoreConfig(t),this.$nextTick(()=>{this.$refs.variableViewerRef&&"function"==typeof this.$refs.variableViewerRef.updateTableData&&this.$refs.variableViewerRef.updateTableData()})),this.$route.query.id){if(this.hasTriggerUpdate)return;"function"==typeof this.$refs.variableViewerRef.$triggerUpdate&&this.$refs.variableViewerRef.$triggerUpdate(),this.hasTriggerUpdate=!0}})}}).catch(e=>{this.$message.error(e.message||"数据文件内容不匹配,请重新上传")}).finally(()=>{this.loading=!1})},handleColumns(e=[]){const t=this.options.variable.menus||[];void 0,0!=t.length&&e.forEach(e=>{void 0;const i=t.find(t=>t.fieldName==e.fieldName);void 0,e.varType=i.label,e.attr=i.attr})},handleTableDataUpdated(e){Array.isArray(e)&&(this.tableDataCache=e)},handleUpdateColumns(e){void 0,this.$emit("update:columns",e)},beforeUpload(e){if(void 0,e.size>1048576*this.fileSize)return this.$message.error(`上传文件大小不能超过 ${this.fileSize} MB!`),!1;const t=e.type,i=e.name.toLowerCase();return!!(["application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/vnd.ms-excel","text/csv"].includes(t)||i.endsWith(".xlsx")||i.endsWith(".xls")||i.endsWith(".csv"))||(this.$message.error("只支持上传 xlsx、xls、csv 格式的文件!"),!1)},handleChange(e,t){if(t.length>1?this.fileList=[t[t.length-1]]:this.fileList=t.filter(e=>void 0!==e.raw),"success"===e.status){const t=e.response;t&&200===t.code&&(this.fileToken=t.data.id,this.$emit("update:fileId",this.fileToken),this.loadFromUrl(this.fileToken))}},loadFromUrl(e){this.$api.dataAnalysis.filePreview({fileId:e}).then(e=>{if(e&&e.data&&e.data.records&&e.data.records.length>0){const t=(e.data.records[0]||{data:[],headers:[]}).headers||[];if(t.length>0){this.$emit("update:headers",t);const e={};t.forEach(t=>{e[t]={field:t,varType:"",attr:""}}),this.fileData=[{...e}]}else this.$emit("update:headers",[]),this.fileData=[]}})},handleRemove(e){this.fileList=this.fileList.filter(t=>t.uid!==e.uid),this.fileToken="",this.fileData=[],this.$emit("update:fileId",""),this.$emit("update:headers",[])},onAdjust(){this.$emit("adjust")},handleRemove1(e,t){void 0},handlePreview(e){void 0},handleExceed(e,t){this.$message.warning(`上传文件数量不能超过 ${this.limit} 个!`),t.length>this.limit&&(this.fileList=t.slice(-this.limit))},beforeRemove(){return!0},toggleCollapse(){this.isCollapsed=!this.isCollapsed},handleFileClick(){event.stopPropagation(),this.fileToken?(this.previewUrl=`${process.env.VUE_APP_BASE_API}/file/preview/${this.fileToken}`,this.previewVisible=!0):this.$message.warning("文件ID不存在,无法预览")}},install(e){e.component(u.name,u)}};l(".long-radio-wrapper{display:flex;flex-wrap:wrap}.long-radio-wrapper ::v-deep .el-radio{line-height:24px;margin-bottom:0}.long-radio-wrapper ::v-deep .el-radio__label{display:inline-block;vertical-align:middle;white-space:normal;word-break:break-all}.long-radio-item{margin:4px 12px 4px 0;width:100px}");var f={render(){var e=this,t=e.$createElement,i=e.i.t||t;return i("el-radio-group",e.l(e.o({staticClass:"long-radio-wrapper"},"el-radio-group",e.$attrs,!1),e.$listeners),e.p(e.options,function(t,a){return i("el-radio",{key:a,staticClass:"long-radio-item",attrs:{label:t[e.valueKey],disabled:t[e.disabledOption]}},[e.u("\n "+e.m(t[e.labelKey])+"\n ")])}),1)},staticRenderFns:[],name:"LongRadio",props:{dataList:{type:Array,default:()=>[]},disabledOption:{type:[Boolean,Number],default:!1},valueKey:{type:[String,Number],default:"value"},labelKey:{type:[String,Number],default:"label"},mode:{type:String,default:"local"},dict:{type:String,default:""},url:{type:String,default:""},requestParams:{type:Object,default(){}},placeholder:{type:String,default:"请选择"}},data(){return{options:[]}},watch:{dataList:{deep:!0,immediate:!0,handler(e){"local"===this.mode&&(this.options=e)}},dict:{deep:!0,handler(e){this.init()}}},created(){this.init()},methods:{init(){"remote"===this.mode&&this.dict&&this.getDicts(this.dict).then(e=>{this.options=(e.data||[]).map(e=>({[this.valueKey]:e.dictCode,[this.labelKey]:e.dictLabel}))})}},install(e){e.component(f.name,f)}};l(".long-group{background-color:#f8f8f8;box-sizing:border-box;height:100%;padding:10px;width:100%}.long-group .group-header{color:#333;font-size:14px;font-weight:700}");var g={render(){var e=this,t=e.$createElement,i=e.i.t||t;return i("div",{staticClass:"long-group"},[i("div",{staticClass:"group-header"},[e.u(e.m(e.label))]),e.u(" "),e.h("default")],2)},staticRenderFns:[],name:"LongGroup",props:{label:{type:String,default:""}},install(e){e.component(g.name,g)}};l(".long-color-picker{width:200px}.long-color-picker .el-color-picker__trigger{width:100%}.long-color-picker .el-color-picker__trigger .el-color-picker__icon{left:unset!important;right:5px!important;width:unset!important}");var b={render(){var e=this,t=e.$createElement;return(e.i.t||t)("el-color-picker",e.l(e.o({staticClass:"long-color-picker"},"el-color-picker",e.$attrs,!1),e.$listeners))},staticRenderFns:[],name:"LongColorPicker",install(e){e.component(b.name,b)}};l("");var m={render(){var e=this,t=e.$createElement;return(e.i.t||t)("el-input-number",e.l(e.o({staticClass:"long-number-input",attrs:{"controls-position":"right",step:e.stepValue,value:e.value,max:e.maxValue,min:e.minValue},on:{input:t=>e.$emit("input",t)}},"el-input-number",e.$attrs,!1),e.$listeners))},staticRenderFns:[],name:"LongNumberInput",props:{value:{type:[String,Number],default:0},placeholder:{type:String,default:"请输入"},max:{type:[Number,String],default:""},min:{type:[Number,String],default:""},step:{type:[Number,String],default:1}},data(){return{maxValue:""===this.max?Number.MAX_SAFE_INTEGER:+this.max,minValue:""===this.min?Number.MIN_SAFE_INTEGER:+this.min,stepValue:+this.step}},watch:{max:{handler(e){this.maxValue=""===e?Number.MAX_SAFE_INTEGER:+e},immediate:!0},min:{handler(e){this.minValue=""===e?Number.MIN_SAFE_INTEGER:+e},immediate:!0},step:{handler(e){this.stepValue=+e},immediate:!0}},install(e){e.component(m.name,m)}};l(".long-checkbox-wrapper{display:flex;flex-wrap:wrap}.long-checkbox-wrapper ::v-deep .el-checkbox{line-height:24px;margin-bottom:0}.long-checkbox-item{margin:1px 6px 1px 0;min-width:50px}");var x={render(){var e=this,t=e.$createElement,i=e.i.t||t;return i("el-checkbox-group",e.l(e.o({staticClass:"long-checkbox-wrapper",attrs:{value:e.value},on:{change:e.handleInput}},"el-checkbox-group",e.$attrs,!1),e.$listeners),e.p(e.options,function(t,a){return i("el-checkbox",{key:a,staticClass:"long-checkbox-item",attrs:{label:t[e.valueKey],disabled:e.getDisabled(t)}},[e.u("\n "+e.m(t[e.labelKey])+"\n ")])}),1)},staticRenderFns:[],name:"LongCheckBox",props:{value:{type:Array,default:()=>[]},dataList:{type:Array,default:()=>[]},disabledOption:{type:[String,Boolean,Number],default:!1},valueKey:{type:[String,Number],default:"value"},labelKey:{type:[String,Number],default:"label"},mode:{type:String,default:"local"},dict:{type:String,default:""},url:{type:String,default:""},requestParams:{type:Object,default(){}},placeholder:{type:String,default:"请选择"}},data(){return{options:[]}},watch:{dataList:{deep:!0,immediate:!0,handler(e){"local"===this.mode&&(this.options=e)}},dict:{deep:!0,handler(e){this.init()}}},created(){this.init()},methods:{init(){"remote"===this.mode&&this.dict&&this.getDicts(this.dict).then(e=>{this.options=(e.data||[]).map(e=>({[this.valueKey]:e.dictCode,[this.labelKey]:e.dictLabel}))})},handleInput(e){this.$emit("input",e),this.$emit("change",e)},getDisabled(e){return"string"==typeof this.disabledOption?e[this.disabledOption]||!1:"boolean"==typeof this.disabledOption?this.disabledOption:"number"==typeof this.disabledOption&&e[this.disabledOption]||!1}},install(e){e.component(x.name,x)}},v=[r,n,d,c,p,h,u,f,g,b,m,x],y=function(e){if(!y.installed){y.installed=!0;var t=["ElInput","ElSelect","ElOption","ElCheckbox","ElCheckboxGroup","ElRadio","ElRadioGroup","ElButton","ElDialog","ElTable","ElTableColumn","ElUpload","ElTag","ElPagination","ElInputNumber","ElColorPicker","ElForm","ElFormItem","ElIcon"];t.forEach(function(t){var i=e.options.components[t];if(!i){var a=s(t);i=e.options.components[a]}if(i){var l=s(t);l&&l!==t&&(e.options.components[l]||e.component(l,i)),e.options.components[t]||e.component(t,i)}else"production"!==process.env.NODE_ENV,0}),e.nextTick(function(){t.forEach(function(t){var i=e.options.components[t];if(i){var a=s(t);a&&a!==t&&(e.options.components[a]||e.component(a,i))}})}),v.forEach(function(t){if(t){var i=t.name||t.options&&t.options.name;if(i){e.component(i,t);var a=s(i);a&&a!==i&&e.component(a,t)}}})}};"undefined"!=typeof window&&window.Vue&&y(window.Vue);var w={version:"1.0.0",install:y,Input:r,Select:n,VariableViewer:d,ExcelViewer:c,VariableViewerButton:p,ExcelViewerButton:h,Uploader:u,Radio:f,Group:g,ColorPicker:b,NumberInput:m,CheckBox:x};e.CheckBox=x,e.ColorPicker=b,e.ExcelViewer=c,e.ExcelViewerButton=h,e.Group=g,e.Input=r,e.NumberInput=m,e.Radio=f,e.Select=n,e.Uploader=u,e.VariableViewer=d,e.VariableViewerButton=p,e.default=w,Object.defineProperty(e,"S",{value:!0})},void("object"==typeof exports&&"undefined"!=typeof module?t(exports,require("xlsx"),require("file-saver"),require("@/assets/icon-search.png")):"function"==typeof define&&define.amd?define(["exports","xlsx","file-saver","@/assets/icon-search.png"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).WiserComponents={},e.xlsx,e.fileSaver,e.searchIcon));
1
+ !function(global,factory){"object"===typeof exports&&"undefined"!==typeof module?factory(exports,require("xlsx"),require("file-saver")):"function"===typeof define&&define.amd?define(["exports","xlsx","file-saver"],factory):(global="undefined"!==typeof globalThis?globalThis:global||self,factory(global.WiserComponents={},global.xlsx,global.fileSaver))}(this,function(exports,xlsx,fileSaver){"use strict";function styleInject(css,ref){if(void 0===ref)ref={};var insertAt=ref.insertAt;if(!css||"undefined"===typeof document)return;var head=document.head||document.getElementsByTagName("head")[0];var style=document.createElement("style");style.type="text/css";if("top"===insertAt)if(head.firstChild)head.insertBefore(style,head.firstChild);else head.appendChild(style);else head.appendChild(style);if(style.styleSheet)style.styleSheet.cssText=css;else style.appendChild(document.createTextNode(css))}var css_248z$b=".long-input-wrapper{background-color:#fff;border:1px solid #e0e0e0;border-radius:4px;padding:8px}.intTxt{width:80%}";styleInject(css_248z$b);var Input={render:function(){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c("el-input",_vm._g(_vm._b({staticClass:"intTxt",attrs:{"show-word-limit":_vm.showWordLimit,placeholder:_vm.placeholder,"auto-complete":"new-password",disabled:_vm.disabled},on:{input:function($event){return _vm.$emit("input",$event)}}},"el-input",_vm.$attrs,false),_vm.$listeners),[_vm._l(Object.keys(this.$slots),function(name){return _vm._t(name,null,{slot:name})})],2)},staticRenderFns:[],name:"LongInput",props:{showWordLimit:{type:Boolean,default:true},disabled:{type:Boolean,default:false},placeholder:{type:String,default:"请输入"}}};Input.install=function install(Vue){Vue.component(Input.name,Input)};var css_248z$a="";styleInject(css_248z$a);var Select={render:function(){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c("el-select",_vm._g(_vm._b({attrs:{value:_vm.value,placeholder:_vm.placeholder}},"el-select",_vm.$attrs,false),_vm.$listeners),[_vm._t("unshift"),_vm._v(" "),_vm._t("default",function(){return _vm._l(_vm.options,function(item,index){return _c("el-option",{key:index,attrs:{value:item[_vm.valueKey],label:item[_vm.labelKey],disabled:item[_vm.disabledOption]}})})},{slot:"default"}),_vm._v(" "),_vm._t("prefix",null,{slot:"prefix"}),_vm._v(" "),_vm._t("empty",null,{slot:"empty"})],2)},staticRenderFns:[],name:"LongSelect",props:{value:{type:[String,Number],default:""},dataList:{type:Array,default:()=>[]},disabledOption:{type:[Boolean,Number],default:false},valueKey:{type:[String,Number],default:"value"},labelKey:{type:[String,Number],default:"label"},mode:{type:String,default:"local"},dict:{type:String,default:""},url:{type:String,default:""},requestParams:{type:Object,default:()=>{}},placeholder:{type:String,default:"请选择"}},data:()=>({options:[]}),watch:{dataList:{deep:true,immediate:true,handler(val){if("local"===this.mode)this.options=val}},dict:{deep:true,handler(val){this.init()}}},created(){this.init()},methods:{init(){if("remote"===this.mode&&this.dict)this.getDicts(this.dict).then(res=>{this.options=(res.data||[]).map(item=>({[this.valueKey]:item.dictCode,[this.labelKey]:item.dictLabel}))})}}};Select.install=function install(Vue){Vue.component(Select.name,Select)};var css_248z$9=".variable-config-dialog :deep(.el-dialog__body){padding:20px}.variable-config-dialog :deep(.el-dialog__header){padding:20px 20px 10px}.dialog-title{align-items:center;color:#303133;display:flex;font-size:16px;font-weight:700;gap:24px;padding:0 20px}.dialog-title .title-left{color:#303133;flex:1;min-width:500px}.dialog-title .title-separator{color:#dcdfe6;flex-shrink:0;font-weight:400}.dialog-title .title-right{color:#303133;flex:1;min-width:400px}.dialog-body{display:flex;gap:24px;min-height:500px}.left-section{flex:1;min-width:500px}.section-title{color:#303133;font-size:16px;font-weight:700;margin-bottom:16px}.variable-selector{align-items:flex-start;display:flex;gap:16px}.variable-panel{border:1px solid #dcdfe6;border-radius:4px;display:flex;flex:1;flex-direction:column;height:500px;overflow:hidden}.panel-header{align-items:center;background:#f5f7fa;border-bottom:1px solid #dcdfe6;display:flex;justify-content:space-between;padding:12px 16px}.select-all-checkbox :deep(.el-checkbox__label){padding-left:8px}.panel-title{color:#303133;font-weight:500}.panel-count{color:#909399;font-size:12px}.panel-search{border-bottom:1px solid #dcdfe6;padding:12px}.panel-list{flex:1;overflow-y:auto;padding:8px}.variable-item{border-radius:4px;cursor:pointer;padding:8px 12px;transition:background-color .2s}.variable-item:hover{background-color:#f5f7fa}.variable-item :deep(.el-checkbox){width:100%}.variable-item :deep(.el-checkbox__label){width:100%}.arrow-buttons{display:flex;flex-direction:column;gap:12px;justify-content:center;padding-top:100px}.arrow-buttons .el-button{margin-left:0!important}.right-section{display:flex;flex:1;flex-direction:column;min-width:400px;overflow:hidden}.config-desc{color:#909399;flex-shrink:0;font-size:13px;line-height:1.5;margin-bottom:24px}.config-group{margin-bottom:32px}.config-group:last-child{margin-bottom:0}.config-label{color:#303133;font-size:14px;font-weight:500;margin-bottom:12px}.config-options{display:flex;flex:1;flex-direction:column;gap:16px;margin-top:16px;overflow-x:hidden;overflow-y:auto;padding-right:8px}.config-options::-webkit-scrollbar{width:6px}.config-options::-webkit-scrollbar-track{background:#f1f1f1;border-radius:3px}.config-options::-webkit-scrollbar-thumb{background:#c1c1c1;border-radius:3px}.config-options::-webkit-scrollbar-thumb:hover{background:#a8a8a8}.config-option-row{align-items:center;display:flex;gap:12px;margin-bottom:8px}.config-option-row.is-parent .option-label{color:#303133;font-weight:500}.config-option-row.is-leaf .option-label{color:#606266}.option-label{color:#606266;flex:1;font-size:13px;min-width:0;white-space:normal;word-break:break-all}.option-label.required{color:#303133;font-weight:500}.option-label .required-mark{color:#f56c6c;margin-left:2px}.config-select{flex-shrink:0;width:350px}.non-leaf-label{color:#909399;font-size:13px;font-style:italic}.disabled-option{cursor:not-allowed!important}.disabled-option,.disabled-text{color:#c0c4cc!important}:deep(.el-select-dropdown__item.is-disabled){color:#c0c4cc!important;cursor:not-allowed!important}:deep(.el-select-dropdown__item.is-disabled) span{color:#c0c4cc!important}.checkbox-list{border:1px solid #dcdfe6;border-radius:4px;display:flex;flex:1;flex-direction:column;gap:8px;max-height:200px;overflow-y:auto;padding:8px}.dialog-footer{text-align:right}";styleInject(css_248z$9);var VariableViewer={render:function(){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c("div",[_c("el-dialog",{staticClass:"variable-config-dialog",staticStyle:{"max-height":"90vh"},attrs:{visible:_vm.dialogVisible,width:"1200px"},on:{"update:visible":function($event){_vm.dialogVisible=$event},close:_vm.handleClose}},[_c("div",{staticClass:"dialog-title",attrs:{slot:"title"},slot:"title"},[_c("span",{staticClass:"title-left"},[_vm._v("选择分析变量")]),_vm._v(" "),_c("span",{staticClass:"title-separator"},[_vm._v("|")]),_vm._v(" "),_c("span",{staticClass:"title-right"},[_vm._v("配置变量")])]),_vm._v(" "),_c("div",{staticClass:"dialog-body"},[_c("div",{staticClass:"left-section"},[_c("div",{staticClass:"variable-selector"},[_c("div",{staticClass:"variable-panel"},[_c("div",{staticClass:"panel-header"},[_c("el-checkbox",{staticClass:"select-all-checkbox",attrs:{indeterminate:_vm.leftIndeterminate},on:{change:_vm.handleLeftSelectAll},model:{value:_vm.leftSelectAll,callback:function($$v){_vm.leftSelectAll=$$v},expression:"leftSelectAll"}},[_c("span",{staticClass:"panel-title"},[_vm._v("全选")])]),_vm._v(" "),_c("span",{staticClass:"panel-count"},[_vm._v(_vm._s(_vm.selectedAllCount)+"/"+_vm._s(_vm.allVariables.length))])],1),_vm._v(" "),_c("div",{staticClass:"panel-search"},[_c("el-input",{attrs:{placeholder:"请输入关键字","suffix-icon":"el-icon-search",size:"small"},on:{input:_vm.handleLeftSearch},model:{value:_vm.leftKeyword,callback:function($$v){_vm.leftKeyword=$$v},expression:"leftKeyword"}})],1),_vm._v(" "),_c("div",{staticClass:"panel-list"},_vm._l(_vm.filteredLeftVariables,function(item){return _c("div",{key:item.field,staticClass:"variable-item"},[_c("el-checkbox",{on:{change:function($event){return _vm.handleLeftCheckChange(item)}},model:{value:item.checked,callback:function($$v){_vm.$set(item,"checked",$$v)},expression:"item.checked"}},[_vm._v("\n "+_vm._s(item.field)+"\n ")])],1)}),0)]),_vm._v(" "),_c("div",{staticClass:"arrow-buttons"},[_c("el-button",{attrs:{type:"primary",icon:"el-icon-arrow-right",size:"small",disabled:!_vm.hasLeftSelected},on:{click:_vm.moveToRight}}),_vm._v(" "),_c("el-button",{attrs:{type:"danger",icon:"el-icon-arrow-left",size:"small",disabled:!_vm.hasRightSelected},on:{click:_vm.moveToLeft}})],1),_vm._v(" "),_c("div",{staticClass:"variable-panel"},[_c("div",{staticClass:"panel-header"},[_c("el-checkbox",{staticClass:"select-all-checkbox",attrs:{indeterminate:_vm.rightIndeterminate},on:{change:_vm.handleRightSelectAll},model:{value:_vm.rightSelectAll,callback:function($$v){_vm.rightSelectAll=$$v},expression:"rightSelectAll"}},[_c("span",{staticClass:"panel-title"},[_vm._v("已选")])]),_vm._v(" "),_c("span",{staticClass:"panel-count"},[_vm._v(_vm._s(_vm.selectedRightCount)+"/"+_vm._s(_vm.selectedVariables.length))])],1),_vm._v(" "),_c("div",{staticClass:"panel-search"},[_c("el-input",{attrs:{placeholder:"请输入关键字","suffix-icon":"el-icon-search",size:"small"},on:{input:_vm.handleRightSearch},model:{value:_vm.rightKeyword,callback:function($$v){_vm.rightKeyword=$$v},expression:"rightKeyword"}})],1),_vm._v(" "),_c("div",{staticClass:"panel-list"},_vm._l(_vm.filteredRightVariables,function(item){return _c("div",{key:item.field,staticClass:"variable-item"},[_c("el-checkbox",{on:{change:function($event){return _vm.handleRightCheckChange(item)}},model:{value:item.checked,callback:function($$v){_vm.$set(item,"checked",$$v)},expression:"item.checked"}},[_vm._v("\n "+_vm._s(item.field)+"\n ")])],1)}),0)])])]),_vm._v(" "),_c("div",{staticClass:"right-section"},[_c("div",{staticClass:"config-desc"},[_vm._v("\n 数据文件中因变量的值,需赋予参考值,方便精准进行数据分析。\n ")]),_vm._v(" "),_c("div",{staticClass:"config-options"},_vm._l(_vm.flatMenuItems,function(menuItem){return _c("div",{key:menuItem.pathString,staticClass:"config-option-row"},[_c("span",{staticClass:"option-label",class:{required:menuItem.required}},[_vm._v("\n "+_vm._s(menuItem.pathString)+"\n "),menuItem.required?_c("span",{staticClass:"required-mark"},[_vm._v("*")]):_vm._e()]),_vm._v(" "),_c("el-select",{staticClass:"config-select",attrs:{placeholder:_vm.getPlaceholder(menuItem),clearable:menuItem.nullable,multiple:menuItem.multiple},on:{change:function($event){return _vm.handleConfigChange(menuItem.pathString,$event)}},model:{value:_vm.configValues[menuItem.pathString],callback:function($$v){_vm.$set(_vm.configValues,menuItem.pathString,$$v)},expression:"configValues[menuItem.pathString]"}},_vm._l(_vm.getAvailableOptions(menuItem.pathString,menuItem.multiple),function(option){return _c("el-option",{key:option.value,class:{"disabled-option":option.disabled},attrs:{label:option.label,value:option.value,disabled:option.disabled}},[_c("span",{class:{"disabled-text":option.disabled}},[_vm._v(_vm._s(option.label))])])}),1)],1)}),0)])]),_vm._v(" "),_c("div",{staticClass:"dialog-footer",attrs:{slot:"footer"},slot:"footer"},[_c("el-button",{on:{click:_vm.handleClose}},[_vm._v("取消")]),_vm._v(" "),_c("el-button",{staticStyle:{color:"#fff"},attrs:{type:"primary"},on:{click:_vm.handleSave}},[_vm._v("保存")])],1)])],1)},staticRenderFns:[],name:"LongVariableViewer",props:{visible:{type:Boolean,default:false},values:{type:Array,default:()=>[]},menus:{type:Array,default:()=>[]}},data:()=>({dialogVisible:false,leftKeyword:"",rightKeyword:"",allVariables:[],selectedVariables:[],configValues:{},configChangeTimer:null}),computed:{filteredLeftVariables(){if(!this.leftKeyword)return this.allVariables;return this.allVariables.filter(item=>item.field.toLowerCase().includes(this.leftKeyword.toLowerCase()))},filteredRightVariables(){if(!this.rightKeyword)return this.selectedVariables;return this.selectedVariables.filter(item=>item.field.toLowerCase().includes(this.rightKeyword.toLowerCase()))},selectedAllCount(){return this.allVariables.filter(item=>item.checked).length},selectedRightCount(){return this.selectedVariables.filter(item=>item.checked).length},hasLeftSelected(){return this.allVariables.some(item=>item.checked)},hasRightSelected(){return this.selectedVariables.some(item=>item.checked)},leftSelectAll:{get(){const filtered=this.filteredLeftVariables;if(0===filtered.length)return false;return filtered.every(item=>item.checked)},set(){}},leftIndeterminate(){const filtered=this.filteredLeftVariables;if(0===filtered.length)return false;const checkedCount=filtered.filter(item=>item.checked).length;return checkedCount>0&&checkedCount<filtered.length},rightSelectAll:{get(){const filtered=this.filteredRightVariables;if(0===filtered.length)return false;return filtered.every(item=>item.checked)},set(){}},rightIndeterminate(){const filtered=this.filteredRightVariables;if(0===filtered.length)return false;const checkedCount=filtered.filter(item=>item.checked).length;return checkedCount>0&&checkedCount<filtered.length},flatMenuItems(){if(!this.menus||0===this.menus.length)return[];const result=[];const traverse=(menu,parentPath=[])=>{const currentPath=[...parentPath,menu.label];const isLeaf=!menu.children||0===menu.children.length;if(isLeaf){const pathString=currentPath.join("/");result.push({label:menu.label,path:currentPath,pathString,isLeaf:true,id:menu.id,fieldName:menu.fieldName,required:menu.required,nullable:menu.nullable,multiple:menu.multiple,originalMenu:menu})}else if(menu.children&&menu.children.length>0)menu.children.forEach(child=>{traverse(child,currentPath)})};this.menus.forEach(menu=>{traverse(menu)});return result},tableData(){const result=[];Object.keys(this.configValues).forEach(pathString=>{const value=this.configValues[pathString];if(!value||Array.isArray(value)&&0===value.length)return;const menuItem=this.flatMenuItems.find(item=>item.pathString===pathString);if(!menuItem)return;const fullPath=menuItem.pathString;const fields=Array.isArray(value)?value:[value];fields.forEach(field=>{const fieldName=String(field);if(!fieldName)return;result.push({field:fieldName,fullPath,varType:menuItem.path&&menuItem.path.length>0?menuItem.path[0]:fullPath,attr:menuItem.path&&menuItem.path.length>0?menuItem.path[menuItem.path.length-1]:""})})});return result}},watch:{visible:{handler(val){this.dialogVisible=val},immediate:true},dialogVisible(val){this.$emit("update:visible",val)},values:{handler(val){this.handleValuesChange(val)},immediate:true,deep:true},selectedVariables:{handler(){const selectedFields=this.selectedVariables.map(item=>item.field);const newConfigValues={...this.configValues};let hasChange=false;Object.keys(newConfigValues).forEach(key=>{const value=newConfigValues[key];if(Array.isArray(value)){const filtered=value.filter(v=>selectedFields.includes(v));if(filtered.length!==value.length){newConfigValues[key]=filtered;hasChange=true}}else if(value&&!selectedFields.includes(value)){newConfigValues[key]="";hasChange=true}});if(hasChange)this.configValues=newConfigValues},deep:true},configValues:{handler(){if(this.configChangeTimer)clearTimeout(this.configChangeTimer);this.configChangeTimer=setTimeout(()=>{this.$nextTick(()=>{this.$emit("config-changed",this.tableData)})},100)},deep:true}},methods:{handleValuesChange(val){if(!val||0===val.length){this.allVariables=[];this.selectedVariables=[];return}const fields=[];if(val.length>0){const firstRow=val[0];if("object"===typeof firstRow&&null!==firstRow)fields.push(...Object.keys(firstRow))}this.allVariables=fields.map(field=>({field,checked:false}));this.selectedVariables=[]},handleLeftSearch(){},handleRightSearch(){},handleLeftCheckChange(){},handleRightCheckChange(){},handleLeftSelectAll(val){this.filteredLeftVariables.forEach(item=>{item.checked=val})},handleRightSelectAll(val){this.filteredRightVariables.forEach(item=>{item.checked=val})},moveToRight(){const selectedItems=this.allVariables.filter(item=>item.checked);if(0===selectedItems.length)return;selectedItems.forEach(item=>{item.checked=false;if(!this.selectedVariables.find(v=>v.field===item.field))this.selectedVariables.push({field:item.field,checked:false})});this.allVariables=this.allVariables.filter(item=>!selectedItems.some(selected=>selected.field===item.field))},moveToLeft(){const selectedItems=this.selectedVariables.filter(item=>item.checked);if(0===selectedItems.length)return;selectedItems.forEach(item=>{item.checked=false;if(!this.allVariables.find(v=>v.field===item.field))this.allVariables.push({field:item.field,checked:false})});this.selectedVariables=this.selectedVariables.filter(item=>!selectedItems.some(selected=>selected.field===item.field))},handleClose(){this.dialogVisible=false},getPlaceholder(menuItem){if(menuItem.required)return"必选";return menuItem.nullable?"请选择":"必选"},getAvailableOptions(pathString,isMultiple=false){const allSelectedFields=this.selectedVariables.map(item=>item.field);const currentValue=this.configValues[pathString];const currentValues=isMultiple?Array.isArray(currentValue)?currentValue:[]:currentValue?[currentValue]:[];const otherSelectedValues=[];Object.keys(this.configValues).forEach(key=>{if(key!==pathString&&this.configValues[key]){const value=this.configValues[key];if(Array.isArray(value))otherSelectedValues.push(...value);else otherSelectedValues.push(value)}});return allSelectedFields.map(field=>{if(currentValues.includes(field))return{label:field,value:field,disabled:false};return{label:field,value:field,disabled:otherSelectedValues.includes(field)}})},handleConfigChange(pathString,value){this.$set(this.configValues,pathString,value);const menuItem=this.flatMenuItems.find(item=>item.pathString===pathString);if(menuItem&&menuItem.multiple&&!Array.isArray(value))this.$set(this.configValues,pathString,value?[value]:[])},generateConfigFromMenus(){this.flatMenuItems.forEach(menuItem=>{if(!(menuItem.pathString in this.configValues))if(menuItem.multiple)this.$set(this.configValues,menuItem.pathString,[]);else this.$set(this.configValues,menuItem.pathString,"")});return{...this.configValues}},handleSave(){const config=this.generateConfigFromMenus();const result={config,selectedVariables:this.selectedVariables.map(item=>item.field)};this.$emit("save",result);this.dialogVisible=false},$restoreConfig(columns){if(!columns||"object"!==typeof columns)return;const allFields=new Set;Object.keys(columns).forEach(fieldName=>{const columnData=columns[fieldName];if(columnData&&columnData.values&&Array.isArray(columnData.values))columnData.values.forEach(field=>allFields.add(field))});allFields.forEach(field=>{if(!this.selectedVariables.find(item=>item.field===field))this.selectedVariables.push({field,checked:false})});this.configValues={};Object.keys(columns).forEach(fieldName=>{const columnData=columns[fieldName];if(!columnData||!columnData.values||!Array.isArray(columnData.values)||0===columnData.values.length)return;const menuItems=this.flatMenuItems.filter(item=>item.fieldName===fieldName);if(0===menuItems.length)return;if(1===menuItems.length){const menuItem=menuItems[0];const pathString=menuItem.pathString;if(menuItem.multiple)this.$set(this.configValues,pathString,[...columnData.values]);else this.$set(this.configValues,pathString,columnData.values[0])}else{const singleSelectItems=menuItems.filter(item=>!item.multiple);const multiSelectItems=menuItems.filter(item=>item.multiple);if(multiSelectItems.length>0){const menuItem=multiSelectItems[0];this.$set(this.configValues,menuItem.pathString,[...columnData.values])}else if(singleSelectItems.length>0)columnData.values.forEach((value,index)=>{if(index<singleSelectItems.length){const menuItem=singleSelectItems[index];this.$set(this.configValues,menuItem.pathString,value)}})}})},$getValues(){const result={};Object.keys(this.configValues).forEach(pathString=>{const value=this.configValues[pathString];if(!value||Array.isArray(value)&&0===value.length)return;const menuItem=this.flatMenuItems.find(item=>item.pathString===pathString);if(!menuItem||!menuItem.fieldName)return;const fieldName=menuItem.fieldName;if(!result[fieldName])result[fieldName]={values:[]};const fields=Array.isArray(value)?value:[value];fields.forEach(field=>{if(!result[fieldName].values.includes(field))result[fieldName].values.push(field)})});return result},$getTableData(){this.generateConfigFromMenus();const data=this.tableData;console.log("VariableViewer - $getTableData - configValues:",this.configValues);console.log("VariableViewer - $getTableData - tableData:",data);return data}}};VariableViewer.install=function install(Vue){Vue.component(VariableViewer.name,VariableViewer)};var css_248z$8=".long-excel-viewer :deep(.el-dialog__body){padding:0 10px 10px}";styleInject(css_248z$8);var ExcelViewer={render:function(){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c("div",{staticClass:"long-excel-viewer"},[_c("el-dialog",{attrs:{visible:_vm.dialogVisible,title:"示例文件",width:"1000px"},on:{"update:visible":function($event){_vm.dialogVisible=$event},close:_vm.handleClose},scopedSlots:_vm._u([{key:"title",fn:function(){return[_c("div",{staticStyle:{display:"flex","justify-content":"space-between"}},[_c("div",{staticStyle:{display:"flex","align-items":"center",gap:"10px"}},[_c("img",{attrs:{src:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAARzQklUCAgICHwIZIgAAALwSURBVFiF7VdNUuJAFP5eY8UAC/EE5gjMDeAE6glGTqDukmxsNyE7hhOIJ9A5gXiCyZxg8ATgYoCkKv1mQRIbTKIEnZrFfFUUvH6P977q7vfTBACOs7wAcE5EFj4PAaCGnlcf6YvkuqEEcPWJgdeglOr6fn2cygLA8d8KDgBCiK+6vAegnQrMfMnMwccHRQcQV6sYZG0SyMDMgb49HwXHiY6IOJ/cRwfbFv8J7BUpbHthCSEeAFgV/AaGMe9KeTirTKBWq50zc5XgANAOw+YxgFsAYI6fiMQIAIjip3cRiOP4uxDioiKBGXP8mApJZo3zDAsJ+H59LOX0cLk020U2eRCiNjOM35P3bH8pAQBInIy3IbAt/t0sAADXXUhAHL3WqMfNrgYAUk5bYdg8FmJV3pnjZ6UwLquu5LphViP1TuW6izNA3BT9UbeVctqKIvMCEOcAWjnmE2Ye9vvmt01F2RFYJboMtr2woqjxI2k2ecEBwCKigeuGd+8m4Hl1CagegNHrj+olWdLKKVYzAAGA++Rbx4nrhmu7WnoHknMeFemjqDkA1orVvWHMe3oK5lTUM9te3KbHVzkLbHthAXz2skIjz9s/3cx/369PDGP+BcAksyTKJrDKBIjEWoFSKr4uspXycKaU6mkEOlJOWzsSUNokRWPfr0/K7JMtz3YnDBudHQnUDl5+c2nwFMysHQ8d7ESAOX7WxDf7hZTTlj72M6+6YmUCSq31iPbqUhYjiswTXTbNZbATgc0zJaLCqrkiJ7S3B43SbCmtA2+Bma+JaJAQ6Lhu+AugU88zAiDtDY0OEW6wXiWHGRXXDaeaMmCm0j5OpH56npkNKo6zfCCiTg65SclTLxvZqMhBEZhp3O8bXX3NcaIBEW87PQWGMe8KZu5Bq1JV0O8bl0nfyH1VMfOYGacb+nYY1u8olWx70SGq5fT+V+6e+/39+yJtkg0WUe2IOX4yzWWQXrhV2248QEtbKvDzaViRaA4APgEw/AN35ky/nKIj9wAAAABJRU5ErkJggg=="}}),_vm._v(" "),_c("div",{staticStyle:{"font-weight":"bold"}},[_vm._v("文件预览")])]),_vm._v(" "),_c("div",{staticStyle:{"margin-right":"30px"}},[_c("el-button",{attrs:{type:"primary",icon:"el-icon-download",size:"mini",disabled:!_vm.tableData.length||_vm.downloading,loading:_vm.downloading},on:{click:_vm.downloadExcel}},[_vm._v("下载")])],1)])]},proxy:true}])},[_vm._v(" "),_vm.tableData.length?_c("el-table",{staticStyle:{width:"100%","margin-top":"20px"},attrs:{data:_vm.tableData,border:"",height:"500px"}},_vm._l(_vm.columns,function(col){return _c("el-table-column",{key:col,attrs:{prop:col,label:col}})}),1):_vm._e(),_vm._v(" "),_vm.pagination.total>0?_c("el-pagination",{staticStyle:{"margin-top":"20px","text-align":"center"},attrs:{"current-page":_vm.pagination.current,"page-sizes":[10,20,50,100],"page-size":_vm.pagination.pageSize,layout:"total, sizes, prev, pager, next, jumper",total:_vm.pagination.total},on:{"size-change":_vm.handleSizeChange,"current-change":_vm.handleCurrentChange}}):_vm._e()],1)],1)},staticRenderFns:[],name:"LongExcelViewer",props:{visible:{type:Boolean,default:false},url:{type:String,default:""}},data:()=>({tableData:[],columns:[],rawWorkbook:null,downloading:false,VUE_APP_BASE_API:process.env.VUE_APP_BASE_API,pagination:{total:0,current:1,pageSize:20},queryParams:{fileId:"",pageNum:1,pageSize:20}}),computed:{dialogVisible:{get(){return this.visible},set(value){this.$emit("update:visible",value)}}},watch:{visible(newVal){if(newVal&&this.url)this.loadExcelFromUrl()},url(newVal){if(newVal&&this.visible)this.loadExcelFromUrl()}},methods:{async loadExcelFromUrl(){if(!this.url)return;const fileId=this.url.split("/").pop();this.queryParams.fileId=fileId;try{const response=await this.$api.dataAnalysis.filePreview(this.queryParams);console.log("response",response);if(response&&response.data&&response.data.records&&Array.isArray(response.data.records)){this.processTableData(response.data.records);this.pagination.total=response.data.total||0;this.pagination.current=response.data.current||1;this.pagination.pageSize=response.data.size||20}else this.$message.error("数据格式错误")}catch(error){console.error("Error loading Excel file from URL:",error);this.$message.error("加载Excel文件失败: "+error.message)}},processTableData(data){const resultData=data[0];if(resultData&&resultData.headers&&resultData.data){if(1==this.pagination.current)this.columns=resultData.headers||[];this.tableData=resultData.data||[]}},processWorkbook(workbook){this.rawWorkbook=workbook;const firstSheet=workbook.Sheets[workbook.SheetNames[0]];const json=xlsx.utils.sheet_to_json(firstSheet,{header:1});if(json.length){this.columns=json[0];this.tableData=json.slice(1).map(row=>{const obj={};this.columns.forEach((col,idx)=>{obj[col]=row[idx]});return obj})}},handleFileChange(file){const reader=new FileReader;reader.onload=e=>{const data=new Uint8Array(e.target.result);const workbook=xlsx.read(data,{type:"array"});this.processWorkbook(workbook)};reader.readAsArrayBuffer(file.raw);return false},downloadExcel(){if(!this.url||this.downloading)return;this.downloading=true;const axios=require("axios");const instance=axios.create({baseURL:this.VUE_APP_BASE_API,timeout:3e4,responseType:"blob"});instance.interceptors.request.use(config=>{const token=this.$store.getters.token||localStorage.getItem("token");if(token)config.headers["Authorization"]=`Bearer ${token}`;return config});instance.interceptors.response.use(response=>{if("blob"===response.config.responseType)return response;return response},error=>Promise.reject(error));const fileId=this.url.split("/").pop();instance.get(`/file/upload/${fileId}`).then(response=>{const blob=response.data;let filename="示例文件.xlsx";const contentDisposition=response.headers["content-disposition"];if(contentDisposition){const filenameMatch=contentDisposition.match(/filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/);if(filenameMatch&&filenameMatch[1]){filename=filenameMatch[1].replace(/['"]/g,"");try{filename=decodeURIComponent(filename)}catch(e){console.warn("文件名解码失败:",e)}}}fileSaver.saveAs(blob,filename);this.$message.success("下载成功")}).catch(error=>{console.error("下载失败:",error);this.$message.error("下载失败,请重试")}).finally(()=>{this.downloading=false})},closeDialog(){this.dialogVisible=false},handleClose(){this.closeDialog();this.tableData=[];this.columns=[];this.rawWorkbook=null},handleSizeChange(val){this.queryParams.pageSize=val;this.queryParams.pageNum=1;this.loadExcelFromUrl()},handleCurrentChange(val){this.queryParams.pageNum=val;this.loadExcelFromUrl()}}};ExcelViewer.install=function install(Vue){Vue.component(ExcelViewer.name,ExcelViewer)};var css_248z$7="";styleInject(css_248z$7);var VariableViewerButton={render:function(){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c("div",[_c("el-button",{attrs:{size:"small",type:"primary",icon:"el-icon-setting"},on:{click:_vm.onAdjust}},[_vm._v("\n 调整变量\n ")]),_vm._v(" "),_c("long-variable-viewer",{ref:"variableViewerRef",attrs:{visible:_vm.modalVisiable,values:_vm.values,menus:_vm.menus},on:{"update:visible":function($event){_vm.modalVisiable=$event},"config-changed":_vm.handleConfigChanged}})],1)},staticRenderFns:[],name:"LongVariableViewerButton",props:{values:{type:Array,default:()=>[]},menus:{type:Array,default:()=>[]}},data:()=>({modalVisiable:false,tableDataCache:[],updateTimer:null,valuesUpdateTimer:null,menusUpdateTimer:null,updatingTableData:false}),mounted(){console.log("VariableViewerButton mounted, menus:",this.menus,"values:",this.values);this.$nextTick(()=>{this.updateTableData()})},beforeDestroy(){if(this.updateTimer)clearInterval(this.updateTimer);if(this.valuesUpdateTimer)clearTimeout(this.valuesUpdateTimer);if(this.menusUpdateTimer)clearTimeout(this.menusUpdateTimer)},watch:{modalVisiable(val){if(!val){this.$emit("update:columns",this.$refs.variableViewerRef.$getValues());this.$nextTick(()=>{this.updateTableData()})}},values:{handler(){if(this.valuesUpdateTimer)clearTimeout(this.valuesUpdateTimer);this.valuesUpdateTimer=setTimeout(()=>{this.updateTableData()},300)},deep:true},menus:{handler(){if(this.menusUpdateTimer)clearTimeout(this.menusUpdateTimer);this.menusUpdateTimer=setTimeout(()=>{this.updateTableData()},300)},deep:true}},computed:{tableData(){return this.tableDataCache}},methods:{onAdjust(){this.modalVisiable=true},$getValues(){return this.$refs.variableViewerRef.$getValues()},$triggerUpdate(){this.$emit("update:columns",this.$getValues());this.$nextTick(()=>{this.updateTableData()})},$restoreConfig(columns){if(this.$refs.variableViewerRef&&this.$refs.variableViewerRef.$restoreConfig){this.$refs.variableViewerRef.$restoreConfig(columns);this.$nextTick(()=>{this.updateTableData()})}},handleConfigChanged(tableData){if(Array.isArray(tableData)){this.tableDataCache=tableData;console.log("VariableViewerButton - config changed, tableData:",this.tableDataCache);this.$emit("table-data-updated",tableData)}},updateTableData(){if(this.updatingTableData)return;this.updatingTableData=true;if(this.$refs.variableViewerRef&&this.$refs.variableViewerRef.$getTableData){const newData=this.$refs.variableViewerRef.$getTableData()||[];const cleanNewData=JSON.parse(JSON.stringify(newData));const cleanCache=JSON.parse(JSON.stringify(this.tableDataCache));if(JSON.stringify(cleanNewData)!==JSON.stringify(cleanCache)){this.tableDataCache=newData;console.log("VariableViewerButton - tableData updated:",this.tableDataCache);this.$nextTick(()=>{this.$emit("table-data-updated",newData);this.updatingTableData=false})}else this.updatingTableData=false}else{if(this.tableDataCache.length>0)this.tableDataCache=[];this.updatingTableData=false}}}};VariableViewerButton.install=function install(Vue){Vue.component(VariableViewerButton.name,VariableViewerButton)};var css_248z$6="";styleInject(css_248z$6);var ExcelViewerButton={render:function(){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c("div",{staticStyle:{display:"inline-block","margin-left":"4px"},on:{click:function($event){$event.stopPropagation()}}},[_c("el-button",{attrs:{type:"text",size:"small",icon:"el-icon-document"},on:{click:_vm.onExample}},[_vm._v("示例文件")]),_vm._v(" "),_c("long-excel-viewer",{attrs:{visible:_vm.modalVisiable,url:_vm.url},on:{"update:visible":function($event){_vm.modalVisiable=$event}}})],1)},staticRenderFns:[],name:"LongExcelViewerButton",props:{url:{type:String,default:""}},data:()=>({modalVisiable:false}),methods:{onExample(event){event.stopPropagation();event.preventDefault();this.modalVisiable=true}}};ExcelViewerButton.install=function install(Vue){Vue.component(ExcelViewerButton.name,ExcelViewerButton)};var css_248z$5=".long-uploader-wrapper .el-form-item{margin-bottom:0}.long-uploader-wrapper :deep(.el-upload) .el-upload-dragger{height:130px!important}.long-uploader-wrapper :deep(.el-upload) .el-upload-dragger .el-icon-upload{margin:8px 0}.variable-config-section{background-color:#f8f9fa;border:1px solid #e9ecef;border-radius:4px;margin-top:16px}.config-header{align-items:center;background-color:#e8e9f2;border-bottom:1px solid #e9ecef;cursor:pointer;display:flex;justify-content:space-between;padding:0 12px;transition:background-color .2s}.config-header:hover{background-color:#f0f0f0}.config-title{color:#303133;font-size:14px;margin:0}.collapse-arrow{color:#909399;font-size:12px;transition:transform .3s ease}.collapse-arrow.is-collapsed{transform:rotate(-90deg)}.config-content{padding:12px}.variable-config-section .el-table{font-size:12px}.variable-config-section .el-table th{background-color:#f5f7fa;color:#606266;font-weight:600}.variable-config-section .el-table td{padding:8px 0}.no-data{color:#909399;font-size:14px;padding:20px;text-align:center}";styleInject(css_248z$5);var LongUploader={render:function(){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c("div",{staticClass:"long-uploader-wrapper"},[_c("div",[_c("div",{staticStyle:{float:"right","margin-top":"-80px"}},[_vm.options.example&&_vm.options.example.value?_c("long-excel-viewer-button",{attrs:{url:_vm.options.example.value}}):_vm._e()],1),_vm._v(" "),_c("div",{staticStyle:{display:"flex","align-items":"center","justify-content":"space-between","margin-bottom":"12px"}},[_c("div",{staticStyle:{display:"flex","align-items":"center",gap:"12px",position:"relative"}},[_c("el-upload",{attrs:{action:_vm.uploadUrl,headers:{Authorization:"Bearer "+_vm.token},"on-preview":_vm.handlePreview,"on-remove":_vm.handleRemove,"before-remove":_vm.beforeRemove,"on-change":_vm.handleChange,"before-upload":_vm.beforeUpload,accept:_vm.fileType,drag:"","on-exceed":_vm.handleExceed,"file-list":_vm.fileList}},[_c("i",{staticClass:"el-icon-upload",staticStyle:{color:"#6C1537"}}),_vm._v(" "),_c("div",{staticClass:"el-upload__text"},[_c("div",{staticStyle:{"line-height":"18px"}},[_vm._v("将文件拖到此处,或"),_c("em",[_vm._v("点击上传")])]),_vm._v(" "),_c("div",{staticStyle:{"line-height":"18px"}},[_vm._v("\n 支持上传"),_c("em",[_vm._v("xlsx")]),_vm._v("、"),_c("em",[_vm._v("xls")]),_vm._v("、"),_c("em",[_vm._v("csv")])])])])],1)]),_vm._v(" "),_vm.fileList.length>0?_c("div",{staticStyle:{"margin-top":"-20px"}},[_vm._m(0),_vm._v(" "),_c("div",[_vm._l(_vm.fileList,function(file){return _c("el-tag",{key:file.uid,staticStyle:{"margin-right":"8px",cursor:"pointer"},attrs:{closable:""},on:{close:function($event){return _vm.handleRemove(file)},click:function($event){return _vm.handleFileClick(file)}}},[_vm._v("\n "+_vm._s(file.name)+"\n ")])}),_vm._v(" "),_vm.fileList.length>0&&_vm.options.variable&&_vm.options.variable.enable?_c("div",{staticStyle:{display:"flex","align-items":"center"}},[_c("span",{staticStyle:{color:"#f56c6c","margin-right":"5px"}},[_vm._v("*")]),_vm._v(" "),_c("long-variable-viewer-button",{ref:"variableViewerRef",attrs:{values:_vm.fileData,menus:_vm.options.variable.menus},on:{"update:columns":_vm.handleUpdateColumns,"table-data-updated":_vm.handleTableDataUpdated}})],1):_vm._e()],2)]):_vm._e()]),_vm._v(" "),_vm.fileList.length>0&&_vm.options.variable&&_vm.options.variable.enable&&_vm.hasConfiguredVariables?_c("div",{staticClass:"variable-config-section"},[_c("div",{staticClass:"config-header",on:{click:_vm.toggleCollapse}},[_c("span",{staticClass:"config-title"},[_vm._v("当前变量配置")]),_vm._v(" "),_c("i",{staticClass:"el-icon-caret-bottom collapse-arrow",class:{"is-collapsed":_vm.isCollapsed}})]),_vm._v(" "),_c("div",{directives:[{name:"show",rawName:"v-show",value:!_vm.isCollapsed,expression:"!isCollapsed"}],staticClass:"config-content"},[0===_vm.currentVariableValues.length?_c("div",{staticClass:"no-data"},[_vm._v("\n 暂无数据\n ")]):_c("el-table",{staticStyle:{width:"100%"},attrs:{data:_vm.currentVariableValues,size:"mini","max-height":"300",border:""}},[_c("el-table-column",{attrs:{prop:"field",label:"字段名","show-overflow-tooltip":""}}),_vm._v(" "),_c("el-table-column",{attrs:{prop:"fullPath",label:"属性","show-overflow-tooltip":""}})],1),_vm._v(" "),_c("div",{staticClass:"debug-info",staticStyle:{"margin-top":"8px","font-size":"12px",color:"#999"}},[_vm._v("\n 数据条数: "+_vm._s(_vm.currentVariableValues.length)+"\n ")])],1)]):_vm._e(),_vm._v(" "),_c("long-excel-viewer",{attrs:{visible:_vm.previewVisible,url:_vm.previewUrl},on:{"update:visible":function($event){_vm.previewVisible=$event}}})],1)},staticRenderFns:[function(){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c("div",{staticStyle:{"font-size":"12px",color:"#999","line-height":"20px"}},[_c("i",{staticClass:"el-icon-info",staticStyle:{"margin-right":"5px"}}),_vm._v(" "),_c("span",[_vm._v("点击文件名称可预览文件")])])}],name:"LongUploader",props:{options:{type:Object,default:()=>({variable:{enable:false,values:[],menus:[]},example:{value:""},file:{id:"",name:""}})},value:{type:Object,default:()=>({fileId:"",columns:[],fileName:""})},fileId:{type:String,default:""},limit:{type:Number,default:1},fileSize:{type:Number,default:3},fileType:{type:String,default:".xlsx,.xls,.csv"}},data:()=>({uploadUrl:`${process.env.VUE_APP_BASE_API}/file/upload`,fileList:[],token:"",fileData:[],fileToken:"",variableViewerRef:null,isCollapsed:true,hasTriggerUpdate:false,previewVisible:false,previewUrl:"",tableDataCache:[]}),computed:{currentVariableValues(){return this.tableDataCache.map(item=>({field:item.field||"",fullPath:item.fullPath||"",varType:item.varType||"",attr:item.attr||""}))},hasConfiguredVariables(){return this.currentVariableValues.length>0}},created(){this.token=localStorage.getItem("token")},watch:{fileId:{handler(val){this.fileToken=val},immediate:true,deep:true},value:{handler(val,oldVal){console.log("value",val,oldVal);if(val&&val.fileId&&(!oldVal||oldVal.fileId!==val.fileId)){this.fileToken=val.fileId;this.downloadFile(val.fileId,val.columns||{})}if(val&&val.fileName&&(!oldVal||oldVal.fileName!==val.fileName))this.fileList=[{name:val.fileName,uid:val.fileId}]},immediate:true,deep:true}},methods:{downloadFile(fileId,columns={}){this.$api.dataAnalysis.filePreview({fileId}).then(res=>{if(res&&res.data&&res.data.records&&res.data.records.length>0){const headers=res.data.records[0].headers||[];this.$emit("update:headers",headers);const menus=this.options.variable.menus||[];const obj={};headers.forEach(o=>{obj[o]={field:o,varType:"",attr:""}});console.log("Parsing columns:",columns);if(columns&&"object"===typeof columns)Object.keys(columns).forEach(columnKey=>{const columnData=columns[columnKey];console.log(`Processing column ${columnKey}:`,columnData);if(columnData&&columnData.values&&Array.isArray(columnData.values)){const menu=menus.find(menu=>menu.fieldName===columnKey);console.log(`Found menu for ${columnKey}:`,menu);if(menu)columnData.values.forEach(fieldName=>{if(obj[fieldName]){obj[fieldName]={field:fieldName,varType:menu.label||columnKey,attr:menu.label||columnKey};console.log(`Set field ${fieldName} with varType: ${menu.label||columnKey}`)}})}});this.fileData=[{...obj}];console.log("Final fileData:",this.fileData);this.$nextTick(()=>{if(this.$refs.variableViewerRef&&columns&&Object.keys(columns).length>0)if("function"===typeof this.$refs.variableViewerRef.$restoreConfig){this.$refs.variableViewerRef.$restoreConfig(columns);this.$nextTick(()=>{if(this.$refs.variableViewerRef&&"function"===typeof this.$refs.variableViewerRef.updateTableData)this.$refs.variableViewerRef.updateTableData()})}const id=this.$route.query.id;if(id){if(this.hasTriggerUpdate)return;if("function"===typeof this.$refs.variableViewerRef.$triggerUpdate)this.$refs.variableViewerRef.$triggerUpdate();this.hasTriggerUpdate=true}})}}).catch(err=>{this.$message.error(err.message||"数据文件内容不匹配,请重新上传");console.log("err",err)}).finally(()=>{this.loading=false})},handleColumns(fileData=[]){const menus=this.options.variable.menus||[];console.log("menus",menus);if(0==menus.length)return;fileData.forEach(item=>{console.log("item",item);const menu=menus.find(menu=>menu.fieldName==item.fieldName);console.log("menu",menu);item.varType=menu.label;item.attr=menu.attr})},handleTableDataUpdated(tableData){if(Array.isArray(tableData)){this.tableDataCache=tableData;console.log("Uploader - tableDataCache updated from event:",this.tableDataCache)}},handleUpdateColumns(columns){console.log("columns",columns);this.$emit("update:columns",columns)},beforeUpload(file){console.log(file);if(file.size>1024*this.fileSize*1024){this.$message.error(`上传文件大小不能超过 ${this.fileSize} MB!`);return false}const allowedTypes=["application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/vnd.ms-excel","text/csv"];const fileType=file.type;const fileName=file.name.toLowerCase();if(!allowedTypes.includes(fileType)&&!fileName.endsWith(".xlsx")&&!fileName.endsWith(".xls")&&!fileName.endsWith(".csv")){this.$message.error("只支持上传 xlsx、xls、csv 格式的文件!");return false}return true},handleChange(file,fileList){if(fileList.length>1)this.fileList=[fileList[fileList.length-1]];else this.fileList=fileList.filter(o=>void 0!==o.raw);console.log("file",file,fileList);if("success"===file.status){const response=file.response;if(response&&200===response.code){this.fileToken=response.data.id;this.$emit("update:fileId",this.fileToken);this.loadFromUrl(this.fileToken)}}},loadFromUrl(fileId){this.$api.dataAnalysis.filePreview({fileId}).then(res=>{if(res&&res.data&&res.data.records&&res.data.records.length>0){const firstRow=res.data.records[0]||{data:[],headers:[]};const headers=firstRow.headers||[];if(headers.length>0){this.$emit("update:headers",headers);const obj={};headers.forEach(o=>{obj[o]={field:o,varType:"",attr:""}});this.fileData=[{...obj}]}else{this.$emit("update:headers",[]);this.fileData=[]}}})},handleRemove(file){this.fileList=this.fileList.filter(f=>f.uid!==file.uid);this.fileToken="";this.fileData=[];this.$emit("update:fileId","");this.$emit("update:headers",[])},onAdjust(){this.$emit("adjust")},handleRemove1(file,fileList){console.log(file,fileList)},handlePreview(file){console.log(file)},handleExceed(files,fileList){this.$message.warning(`上传文件数量不能超过 ${this.limit} 个!`);if(fileList.length>this.limit)this.fileList=fileList.slice(-this.limit)},beforeRemove:()=>true,toggleCollapse(){this.isCollapsed=!this.isCollapsed},handleFileClick(){event.stopPropagation();if(this.fileToken){this.previewUrl=`${process.env.VUE_APP_BASE_API}/file/preview/${this.fileToken}`;this.previewVisible=true}else this.$message.warning("文件ID不存在,无法预览")}}};LongUploader.install=function install(Vue){Vue.component(LongUploader.name,LongUploader)};var css_248z$4=".long-radio-wrapper{display:flex;flex-wrap:wrap}.long-radio-wrapper ::v-deep .el-radio{line-height:24px;margin-bottom:0}.long-radio-wrapper ::v-deep .el-radio__label{display:inline-block;vertical-align:middle;white-space:normal;word-break:break-all}.long-radio-item{margin:4px 12px 4px 0;width:100px}";styleInject(css_248z$4);var Radio={render:function(){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c("el-radio-group",_vm._g(_vm._b({staticClass:"long-radio-wrapper"},"el-radio-group",_vm.$attrs,false),_vm.$listeners),_vm._l(_vm.options,function(item,index){return _c("el-radio",{key:index,staticClass:"long-radio-item",attrs:{label:item[_vm.valueKey],disabled:item[_vm.disabledOption]}},[_vm._v("\n "+_vm._s(item[_vm.labelKey])+"\n ")])}),1)},staticRenderFns:[],name:"LongRadio",props:{dataList:{type:Array,default:()=>[]},disabledOption:{type:[Boolean,Number],default:false},valueKey:{type:[String,Number],default:"value"},labelKey:{type:[String,Number],default:"label"},mode:{type:String,default:"local"},dict:{type:String,default:""},url:{type:String,default:""},requestParams:{type:Object,default:()=>{}},placeholder:{type:String,default:"请选择"}},data:()=>({options:[]}),watch:{dataList:{deep:true,immediate:true,handler(val){if("local"===this.mode)this.options=val}},dict:{deep:true,handler(val){this.init()}}},created(){this.init()},methods:{init(){if("remote"===this.mode&&this.dict)this.getDicts(this.dict).then(res=>{this.options=(res.data||[]).map(item=>({[this.valueKey]:item.dictCode,[this.labelKey]:item.dictLabel}))})}}};Radio.install=function install(Vue){Vue.component(Radio.name,Radio)};var css_248z$3=".long-group{background-color:#f8f8f8;box-sizing:border-box;height:100%;padding:10px;width:100%}.long-group .group-header{color:#333;font-size:14px;font-weight:700}";styleInject(css_248z$3);var Group={render:function(){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c("div",{staticClass:"long-group"},[_c("div",{staticClass:"group-header"},[_vm._v(_vm._s(_vm.label))]),_vm._v(" "),_vm._t("default")],2)},staticRenderFns:[],name:"LongGroup",props:{label:{type:String,default:""}}};Group.install=function install(Vue){Vue.component(Group.name,Group)};var css_248z$2=".long-color-picker{width:200px}.long-color-picker .el-color-picker__trigger{width:100%}.long-color-picker .el-color-picker__trigger .el-color-picker__icon{left:unset!important;right:5px!important;width:unset!important}";styleInject(css_248z$2);var ColorPicker={render:function(){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c("el-color-picker",_vm._g(_vm._b({staticClass:"long-color-picker"},"el-color-picker",_vm.$attrs,false),_vm.$listeners))},staticRenderFns:[],name:"LongColorPicker"};ColorPicker.install=function install(Vue){Vue.component(ColorPicker.name,ColorPicker)};var css_248z$1="";styleInject(css_248z$1);var NumberInput={render:function(){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c("el-input-number",_vm._g(_vm._b({staticClass:"long-number-input",attrs:{"controls-position":"right",step:_vm.stepValue,value:_vm.value,max:_vm.maxValue,min:_vm.minValue},on:{input:function($event){return _vm.$emit("input",$event)}}},"el-input-number",_vm.$attrs,false),_vm.$listeners))},staticRenderFns:[],name:"LongNumberInput",props:{value:{type:[String,Number],default:0},placeholder:{type:String,default:"请输入"},max:{type:[Number,String],default:""},min:{type:[Number,String],default:""},step:{type:[Number,String],default:1}},data(){return{maxValue:""===this.max?Number.MAX_SAFE_INTEGER:Number(this.max),minValue:""===this.min?Number.MIN_SAFE_INTEGER:Number(this.min),stepValue:Number(this.step)}},watch:{max:{handler(val){this.maxValue=""===val?Number.MAX_SAFE_INTEGER:Number(val)},immediate:true},min:{handler(val){this.minValue=""===val?Number.MIN_SAFE_INTEGER:Number(val)},immediate:true},step:{handler(val){this.stepValue=Number(val)},immediate:true}}};NumberInput.install=function install(Vue){Vue.component(NumberInput.name,NumberInput)};var css_248z=".long-checkbox-wrapper{display:flex;flex-wrap:wrap}.long-checkbox-wrapper ::v-deep .el-checkbox{line-height:24px;margin-bottom:0}.long-checkbox-item{margin:1px 6px 1px 0;min-width:50px}";styleInject(css_248z);var CheckBox={render:function(){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c("el-checkbox-group",_vm._g(_vm._b({staticClass:"long-checkbox-wrapper",attrs:{value:_vm.value},on:{change:_vm.handleInput}},"el-checkbox-group",_vm.$attrs,false),_vm.$listeners),_vm._l(_vm.options,function(item,index){return _c("el-checkbox",{key:index,staticClass:"long-checkbox-item",attrs:{label:item[_vm.valueKey],disabled:_vm.getDisabled(item)}},[_vm._v("\n "+_vm._s(item[_vm.labelKey])+"\n ")])}),1)},staticRenderFns:[],name:"LongCheckBox",props:{value:{type:Array,default:()=>[]},dataList:{type:Array,default:()=>[]},disabledOption:{type:[String,Boolean,Number],default:false},valueKey:{type:[String,Number],default:"value"},labelKey:{type:[String,Number],default:"label"},mode:{type:String,default:"local"},dict:{type:String,default:""},url:{type:String,default:""},requestParams:{type:Object,default:()=>{}},placeholder:{type:String,default:"请选择"}},data:()=>({options:[]}),watch:{dataList:{deep:true,immediate:true,handler(val){if("local"===this.mode)this.options=val}},dict:{deep:true,handler(val){this.init()}}},created(){this.init()},methods:{init(){if("remote"===this.mode&&this.dict)this.getDicts(this.dict).then(res=>{this.options=(res.data||[]).map(item=>({[this.valueKey]:item.dictCode,[this.labelKey]:item.dictLabel}))})},handleInput(value){this.$emit("input",value);this.$emit("change",value);console.log(value,999)},getDisabled(item){if("string"===typeof this.disabledOption)return item[this.disabledOption]||false;if("boolean"===typeof this.disabledOption)return this.disabledOption;if("number"===typeof this.disabledOption)return item[this.disabledOption]||false;return false}}};CheckBox.install=function install(Vue){Vue.component(CheckBox.name,CheckBox)};var components=[Input,Select,VariableViewer,ExcelViewer,VariableViewerButton,ExcelViewerButton,LongUploader,Radio,Group,ColorPicker,NumberInput,CheckBox];function toKebabCase(str){if(!str)return str;return str.replace(/([A-Z])/g,"-$1").toLowerCase().replace(/^-/,"")}var _install=function install(Vue){if(_install.installed)return;_install.installed=true;var elementUIComponents=["ElInput","ElSelect","ElOption","ElCheckbox","ElCheckboxGroup","ElRadio","ElRadioGroup","ElButton","ElDialog","ElTable","ElTableColumn","ElUpload","ElTag","ElPagination","ElInputNumber","ElColorPicker","ElForm","ElFormItem","ElIcon"];elementUIComponents.forEach(function(componentName){var component=Vue.options.components[componentName];if(!component){var kebabName=toKebabCase(componentName);component=Vue.options.components[kebabName]}if(component){var _kebabName=toKebabCase(componentName);if(_kebabName&&_kebabName!==componentName)if(!Vue.options.components[_kebabName])Vue.component(_kebabName,component);if(!Vue.options.components[componentName])Vue.component(componentName,component)}else if("production"!==process.env.NODE_ENV)console.warn("[WiserComponents] Element-UI component ".concat(componentName," not found. Make sure Element-UI is installed and registered before using WiserComponents."))});if("function"===typeof Vue.nextTick)Vue.nextTick(function(){elementUIComponents.forEach(function(componentName){var component=Vue.options.components[componentName];if(component){var kebabName=toKebabCase(componentName);if(kebabName&&kebabName!==componentName)if(!Vue.options.components[kebabName])Vue.component(kebabName,component)}})});components.forEach(function(component){if(!component)return;var componentName=component.name||component.options&&component.options.name;if(!componentName)return;Vue.component(componentName,component);var kebabName=toKebabCase(componentName);if(kebabName&&kebabName!==componentName)Vue.component(kebabName,component)})};if("undefined"!==typeof window&&window.Vue)_install(window.Vue);var index={version:"1.0.0",install:_install,Input,Select,VariableViewer,ExcelViewer,VariableViewerButton,ExcelViewerButton,Uploader:LongUploader,Radio,Group,ColorPicker,NumberInput,CheckBox};exports.CheckBox=CheckBox;exports.ColorPicker=ColorPicker;exports.ExcelViewer=ExcelViewer;exports.ExcelViewerButton=ExcelViewerButton;exports.Group=Group;exports.Input=Input;exports.NumberInput=NumberInput;exports.Radio=Radio;exports.Select=Select;exports.Uploader=LongUploader;exports.VariableViewer=VariableViewer;exports.VariableViewerButton=VariableViewerButton;exports["default"]=index;Object.defineProperty(exports,"__esModule",{value:true})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wiser-components",
3
- "version": "1.0.7",
3
+ "version": "1.0.8",
4
4
  "description": "A Vue2 component library",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib/index.esm.js",