@gis_victory/curd-form 0.0.24 → 0.0.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/curd-form.es.js +1 -1
- package/dist/curd-form.umd.js +1 -1
- package/package.json +1 -1
package/dist/curd-form.es.js
CHANGED
|
@@ -83583,7 +83583,7 @@ class gU {
|
|
|
83583
83583
|
return this.dictionaryMap;
|
|
83584
83584
|
const t = this.tableConfig.columns.filter((n) => ["code", "table"].includes(n.dictType || "") && n.dictService).map((n) => {
|
|
83585
83585
|
let r = n.fieldType || "String";
|
|
83586
|
-
return r === "integer" && (r = "Integer"), (n.dictType === "code" ? this.serverConfig?.dict({ dictCode: n.dictService, itemIdType: r }) : this.serverConfig?.dictServer(n.dictService, {})).then((o) => {
|
|
83586
|
+
return r === "integer" && (r = "Integer"), (n.dictType === "code" ? this.serverConfig?.dict({ dictCode: n.dictService, itemIdType: r }) : this.serverConfig?.dictServer(n.dictService, { key: n.dictionary?.name || "" })).then((o) => {
|
|
83587
83587
|
o && n.dictService && this.dictionaryMap.set(n.dictService, o || []);
|
|
83588
83588
|
}).catch((o) => {
|
|
83589
83589
|
console.error(`加载字典 ${n.dictService} 失败:`, o);
|
package/dist/curd-form.umd.js
CHANGED
|
@@ -674,4 +674,4 @@ ${re("ai-append")}</button>
|
|
|
674
674
|
`+e.trim()+`
|
|
675
675
|
:::
|
|
676
676
|
`}});const zs=e=>{if(!e)return e;const t=Qd.render(e).trim();return t?Ji(t.includes("<pre")?t:t.replace(/\n/g,"")):e},D3=e=>{if(!e)return e;const t=new DOMParser().parseFromString(e,"text/html");t.querySelectorAll("colgroup").forEach(r=>r.remove()),t.querySelectorAll("li").forEach(r=>{const i=r.querySelector("div");if(i&&!i.querySelector("img")&&i.firstElementChild){const o=document.createDocumentFragment();o.append(" "),i.firstElementChild.childNodes.forEach(a=>{o.append(a.cloneNode(!0))}),i.replaceWith(o)}});const n=t.body.innerHTML;return Nr.turndown(n)};ce("aie-header",l_),ce("aie-footer",c_);const k3={theme:"light",lang:"zh",contentRetentionKey:"ai-editor-content",editable:!0,draggable:!0,placeholder:"",toolbarSize:"small"};class M3 extends yT{constructor(t,n={}){super(n),D(this,"aiEditor"),this.aiEditor=t}parseHtml(t){function n(r){return new window.DOMParser().parseFromString(`<body>${r}</body>`,"text/html").body}return Ar.fromSchema(this.schema).parse(n(t),{}).content}parseMarkdown(t){const n=zs(t);return this.parseHtml(n)}insertMarkdown(t){this.commands.insertContent(zs(t))}}class L3{constructor(t){D(this,"customLayout",!1),D(this,"innerEditor"),D(this,"container"),D(this,"header"),D(this,"mainEl"),D(this,"footer"),D(this,"options"),D(this,"eventComponents",[]),this.options={...k3,...t},this.initI18nAndInnerEditor()}initI18nAndInnerEditor(){const t=this.options.i18n||{},n={de:{translation:{...$2,...t.de}},en:{translation:{...z2,...t.en}},pt:{translation:{...Y2,...t.pt}},zh:{translation:{...G2,...t.zh}},es:{translation:{...q2,...t.es}},hi:{translation:{...j2,...t.hi}},id:{translation:{...W2,...t.id}},ja:{translation:{...K2,...t.ja}},ko:{translation:{...Q2,...t.ko}},th:{translation:{...Z2,...t.th}},vi:{translation:{...X2,...t.vi}}};for(let r of Object.keys(t))r!="de"&&r!="en"&&r!="pt"&&r!="zh"&&(n[r]={translation:{...t[r]}});Xe.init({lng:this.options.lang,resources:n},(r,i)=>{this.initInnerEditor()})}initInnerEditor(){const t=typeof this.options.element=="string"?document.querySelector(this.options.element):this.options.element;t.classList.add(`aie-theme-${this.options.theme}`),this.container=t.querySelector(".aie-container"),this.container?this.customLayout=!0:(this.container=document.createElement("div"),this.container.classList.add("aie-container")),t.appendChild(this.container),this.mainEl=document.createElement("div"),this.mainEl.style.flexGrow="1",this.mainEl.style.overflow="auto",this.header=new l_,this.eventComponents.push(this.header),this.footer=new c_,this.footer.initDraggable(this.options.draggable),this.eventComponents.push(this.footer);let n=this.options.content;if(typeof n=="string"&&(this.options.contentIsMarkdown?n=zs(n):n=Ji(n)),this.options.contentRetention&&this.options.contentRetentionKey){const r=localStorage.getItem(this.options.contentRetentionKey);if(r)try{n=JSON.parse(r)}catch(i){console.error(i,"Can not parse the cache content from localStorage.")}}this.innerEditor=new M3(this,{...this.options,element:this.mainEl,content:n,editable:this.options.editable,extensions:this.getExtensions(),onCreate:r=>this.onCreate(r),onTransaction:r=>this.onTransaction(r),onFocus:()=>{var r,i;return(i=(r=this.options)==null?void 0:r.onFocus)==null?void 0:i.call(r,this)},onBlur:()=>{var r,i;return(i=(r=this.options)==null?void 0:r.onBlur)==null?void 0:i.call(r,this)},onDestroy:()=>{var r,i;return(i=(r=this.options)==null?void 0:r.onDestroy)==null?void 0:i.call(r,this)},editorProps:{attributes:{class:"aie-content"}}})}getExtensions(){let t=V2(this,this.options);if(this.options.onCreateBefore){const n=this.options.onCreateBefore(this,t);n&&(t=n)}return t}onCreate(t){this.innerEditor.view.dom.style.height="calc(100% - 20px)",this.eventComponents.forEach(n=>{n.onCreate&&n.onCreate(t,this.options)}),(this.container.querySelector(".aie-container-header")||this.container).appendChild(this.header),(this.container.querySelector(".aie-container-main")||this.container).appendChild(this.mainEl),(this.container.querySelector(".aie-container-footer")||this.container).appendChild(this.footer),this.options.ai&&Hn.init(this.innerEditor,this.options.ai),this.options.onCreated&&this.options.onCreated(this)}onTransaction(t){var n,r;if(this.eventComponents.forEach(i=>{i.onTransaction&&i.onTransaction(t)}),!t.transaction.getMeta("ignoreChanged")&&((r=(n=this.options).onTransaction)==null||r.call(n,this,t.transaction),t.transaction.docChanged&&this.options.onChange&&this.options.onChange(this),t.transaction.docChanged&&this.options.contentRetention&&this.options.contentRetentionKey)){const i=t.editor.getHTML();if(i==="<p></p>"||i==="")localStorage.removeItem(this.options.contentRetentionKey);else{const o=t.editor.getJSON();localStorage.setItem(this.options.contentRetentionKey,JSON.stringify(o))}}}getHtml(){return this.innerEditor.getHTML()}getJson(){return this.innerEditor.getJSON()}getText(){return this.innerEditor.getText()}getSelectedText(){const t=this.innerEditor.state.selection;return t.empty?"":sa(this.innerEditor.state.doc,{from:t.from,to:t.to})}getMarkdown(){return D3(this.getHtml())}getOptions(){return this.options}getAttributes(t){return this.innerEditor.getAttributes(t)}setAttributes(t,n){this.innerEditor.commands.updateAttributes(t,n)}isActive(t,n){return typeof t=="object"||!n?this.innerEditor.isActive(t):this.innerEditor.isActive(t,n)}commands(){return this.innerEditor.commands}commandsChain(){return this.innerEditor.chain()}getOutline(){const t=this.innerEditor.state.doc,n=[];return t.descendants((r,i)=>{if(r.type.name==="heading"){const o=`aie-heading-${n.length+1}`;if(r.attrs.id!==o){const{state:{tr:s},view:{dispatch:l}}=this.innerEditor;l(s.setNodeMarkup(i,void 0,{...r.attrs,id:o}).setMeta("ignoreChanged",!0))}let a="";r.descendants(s=>{s.text&&(a+=s.text)}),n.push({id:o,text:a,level:r.attrs.level,pos:i,size:r.nodeSize})}}),n}focus(){return this.innerEditor.commands.focus(),this}focusPos(t){return this.innerEditor.commands.focus(t),this}focusStart(){return this.innerEditor.commands.focus("start"),this}focusEnd(){return this.innerEditor.commands.focus("end"),this}isFocused(){return this.innerEditor.isFocused}blur(){return this.innerEditor.commands.blur(),this}insert(t){return typeof t=="string"&&(t=Ji(t)),this.innerEditor.commands.insertContent(t),this}insertMarkdown(t){return this.innerEditor.insertMarkdown(t),this}setEditable(t){return this.options.editable=t,this.innerEditor.setEditable(t,!0),this.eventComponents.forEach(n=>{n.onEditableChange(t)}),this}setContent(t,n){return typeof t=="string"&&(t=Ji(t)),n===!1?this.clear().insert(t):this.focus().clear().insert(t),this}setMarkdownContent(t){const n=zs(t);return this.setContent(n)}clear(){return this.innerEditor.commands.clearContent(!0),this}isEmpty(){return this.innerEditor.isEmpty}changeLang(t){return this.destroy(),this.options.lang=t,Xe.changeLanguage(t),this.initInnerEditor(),this}changeTheme(t){const n=typeof this.options.element=="string"?document.querySelector(this.options.element):this.options.element;t||(t=this.options.theme==="dark"?"light":"dark"),n.classList.remove(`aie-theme-${this.options.theme}`),n.classList.add(`aie-theme-${t}`),this.options.theme=t}removeRetention(){return this.options.contentRetentionKey&&localStorage.removeItem(this.options.contentRetentionKey),this}destroy(){var t,n,r,i;(n=(t=this.options).onDestroy)==null||n.call(t,this),this.innerEditor.destroy(),this.eventComponents=[],this.customLayout?((r=this.header)==null||r.remove(),this.mainEl.remove(),(i=this.footer)==null||i.remove()):this.container.remove()}isDestroyed(){return this.innerEditor.isDestroyed}}const P3={name:"FormItemEditor"},F3=g.defineComponent({...P3,props:{modelValue:{type:[String],default:()=>""},item:{type:Object,default:()=>({})},currentOperationType:{type:String,default:"default"}},emits:["update:modelValue"],setup(e,{emit:t}){const n=e,r=g.ref(null);let i=null;const o=g.ref(n.modelValue),a=t;return g.computed(()=>{switch(n.currentOperationType){case"default":return!1;case"details":return!0;case"add":return n.item.createFormStatus=="disabled";case"edit":return n.item.updateFormStatus=="disabled"}return!1}),g.computed(()=>{switch(n.currentOperationType){case"default":return!1;case"details":return!0;case"add":return n.item.createFormStatus=="disabled";case"edit":return n.item.updateFormStatus=="disabled"}return!1}),g.watch(o,s=>{a("update:modelValue",s)}),g.watch(()=>n.modelValue,s=>{let l=s;o.value=l}),g.onMounted(()=>{i=new L3({element:r.value,placeholder:"点击输入内容...",content:o.value,onBlur:s=>{o.value=s.getHtml()}})}),g.onUnmounted(()=>{i&&i.destroy()}),(s,l)=>(g.openBlock(),g.createElementBlock("div",{ref_key:"editorRef",ref:r,style:{height:"400px"}},null,512))}}),B3={name:"FormItemDetail"},U3=g.defineComponent({...B3,props:{modelValue:{type:[String,Number,Array,Object],default:()=>""},item:{type:Object,default:()=>({})},dropdownOptions:{type:Array,default:()=>[]}},setup(e){const t=e;let n=t.modelValue;const r=t.item.type==="multiple-select"||t.item.type==="checkbox"||t.item.searchFormType==="multiple-select"||t.item.searchFormType==="checkbox";typeof n=="object"&&n!==null&&!Array.isArray(n)&&(n=Object.values(n).join(",")),r&&typeof n=="string"&&n&&(n=n.split(","));const i=g.ref(n);return g.onMounted(()=>{switch(t.item.type){case"select":case"radio":const o=t.dropdownOptions.find(l=>l.id===t.modelValue);i.value=o?.name||"";break;case"checkbox":case"multiple-select":const s=(Array.isArray(i.value)?i.value:i.value?.split(",")||[]).map(l=>t.dropdownOptions.find(d=>d.id===l)?.name||l).filter(Boolean);i.value=s.join(",")||"";break;case"date":i.value=t.modelValue?B.dayjs(t.modelValue).format(t.item.formatter||"YYYY-MM-DD"):"";break;case"datetime":i.value=t.modelValue?B.dayjs(t.modelValue).format(t.item.formatter||"YYYY-MM-DD HH:mm:ss"):"";break;default:i.value=t.modelValue;break}}),(o,a)=>(g.openBlock(),g.createElementBlock("span",null,g.toDisplayString(i.value),1))}});var wo={exports:{}},zE;function H3(){if(zE)return wo.exports;zE=1,wo.exports=n,wo.exports.parse=n,wo.exports.stringify=r;var e=/[-+]?([0-9]*\.[0-9]+|[0-9]+)([eE][-+]?[0-9]+)?/,t=new RegExp("^"+e.source+"(\\s"+e.source+"){1,}");function n(i){var o=i.split(";"),a=o.pop(),s=(o.shift()||"").split("=").pop(),l=0;function c(v){var N=a.substring(l).match(v);return N?(l+=N[0].length,N[0]):null}function d(v){return v&&s.match(/\d+/)&&(v.crs={type:"name",properties:{name:"urn:ogc:def:crs:EPSG::"+s}}),v}function u(){c(/^\s*/)}function p(){u();for(var v=0,N=[],w=[N],O=N,L;L=c(/^(\()/)||c(/^(\))/)||c(/^(,)/)||c(t);){if(L==="(")w.push(O),O=[],w[w.length-1].push(O),v++;else if(L===")"){if(O.length===0||(O=w.pop(),!O))return null;if(v--,v===0)break}else if(L===",")O=[],w[w.length-1].push(O);else if(!L.split(/\s/g).some(isNaN))Array.prototype.push.apply(O,L.split(/\s/g).map(parseFloat));else return null;u()}return v!==0?null:N}function m(){for(var v=[],N,w;w=c(t)||c(/^(,)/);)w===","?(v.push(N),N=[]):w.split(/\s/g).some(isNaN)||(N||(N=[]),Array.prototype.push.apply(N,w.split(/\s/g).map(parseFloat))),u();if(N)v.push(N);else return null;return v.length?v:null}function h(){if(!c(/^(point(\sz)?)/i)||(u(),!c(/^(\()/)))return null;var v=m();return!v||(u(),!c(/^(\))/))?null:{type:"Point",coordinates:v[0]}}function _(){if(!c(/^(multipoint)/i))return null;u();var v=a.substring(a.indexOf("(")+1,a.length-1).replace(/\(/g,"").replace(/\)/g,"");a="MULTIPOINT ("+v+")";var N=p();return N?(u(),{type:"MultiPoint",coordinates:N}):null}function f(){if(!c(/^(multilinestring)/i))return null;u();var v=p();return v?(u(),{type:"MultiLineString",coordinates:v}):null}function b(){if(!c(/^(linestring(\sz)?)/i)||(u(),!c(/^(\()/)))return null;var v=m();return!v||!c(/^(\))/)?null:{type:"LineString",coordinates:v}}function S(){if(!c(/^(polygon(\sz)?)/i))return null;u();var v=p();return v?{type:"Polygon",coordinates:v}:null}function y(){if(!c(/^(multipolygon)/i))return null;u();var v=p();return v?{type:"MultiPolygon",coordinates:v}:null}function E(){var v=[],N;if(!c(/^(geometrycollection)/i)||(u(),!c(/^(\()/)))return null;for(;N=C();)v.push(N),u(),c(/^(,)/),u();return c(/^(\))/)?{type:"GeometryCollection",geometries:v}:null}function C(){return h()||b()||S()||_()||f()||y()||E()}return d(C())}function r(i){i.type==="Feature"&&(i=i.geometry);function o(d){return d.join(" ")}function a(d){return d.map(o).join(", ")}function s(d){return d.map(a).map(c).join(", ")}function l(d){return d.map(s).map(c).join(", ")}function c(d){return"("+d+")"}switch(i.type){case"Point":return"POINT ("+o(i.coordinates)+")";case"LineString":return"LINESTRING ("+a(i.coordinates)+")";case"Polygon":return"POLYGON ("+s(i.coordinates)+")";case"MultiPoint":return"MULTIPOINT ("+a(i.coordinates)+")";case"MultiPolygon":return"MULTIPOLYGON ("+l(i.coordinates)+")";case"MultiLineString":return"MULTILINESTRING ("+s(i.coordinates)+")";case"GeometryCollection":return"GEOMETRYCOLLECTION ("+i.geometries.map(r).join(", ")+")";default:throw new Error("stringify requires a valid GeoJSON Feature or geometry object as input")}}return wo.exports}var Zd=H3();function V3(e,t,n={}){const r={type:"Feature"};return(n.id===0||n.id)&&(r.id=n.id),n.bbox&&(r.bbox=n.bbox),r.properties=t||{},r.geometry=e,r}function G3(e,t,n={}){if(!e)throw new Error("coordinates is required");if(!Array.isArray(e))throw new Error("coordinates must be an Array");if(e.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!$E(e[0])||!$E(e[1]))throw new Error("coordinates must contain numbers");return V3({type:"Point",coordinates:e},t,n)}function $E(e){return!isNaN(e)&&e!==null&&!Array.isArray(e)}function YE(e,t,n){if(e!==null)for(var r,i,o,a,s,l,c,d=0,u=0,p,m=e.type,h=m==="FeatureCollection",_=m==="Feature",f=h?e.features.length:1,b=0;b<f;b++){c=h?e.features[b].geometry:_?e.geometry:e,p=c?c.type==="GeometryCollection":!1,s=p?c.geometries.length:1;for(var S=0;S<s;S++){var y=0,E=0;if(a=p?c.geometries[S]:c,a!==null){l=a.coordinates;var C=a.type;switch(d=C==="Polygon"||C==="MultiPolygon"?1:0,C){case null:break;case"Point":if(t(l,u,b,y,E)===!1)return!1;u++,y++;break;case"LineString":case"MultiPoint":for(r=0;r<l.length;r++){if(t(l[r],u,b,y,E)===!1)return!1;u++,C==="MultiPoint"&&y++}C==="LineString"&&y++;break;case"Polygon":case"MultiLineString":for(r=0;r<l.length;r++){for(i=0;i<l[r].length-d;i++){if(t(l[r][i],u,b,y,E)===!1)return!1;u++}C==="MultiLineString"&&y++,C==="Polygon"&&E++}C==="Polygon"&&y++;break;case"MultiPolygon":for(r=0;r<l.length;r++){for(E=0,i=0;i<l[r].length;i++){for(o=0;o<l[r][i].length-d;o++){if(t(l[r][i][o],u,b,y,E)===!1)return!1;u++}E++}y++}break;case"GeometryCollection":for(r=0;r<a.geometries.length;r++)if(YE(a.geometries[r],t)===!1)return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function z3(e,t={}){let n=0,r=0,i=0;return YE(e,function(o){n+=o[0],r+=o[1],i++}),G3([n/i,r/i],t.properties)}class $3{map;sourceId="curd-map-source";layerId="curd-map-layer";featureCollection={type:"FeatureCollection",features:[]};constructor(t){this.map=t,this.setSource()}setSource(){this.map.addSource(this.sourceId,{type:"geojson",data:this.featureCollection})}setLayer(t){if(!this.map.getLayer(this.layerId))switch(t.toLowerCase()){case"polygon":case"multipolygon":this.map.addLayer({id:this.layerId,type:"fill",source:this.sourceId,paint:{"fill-color":"#ff0000","fill-opacity":.5}});break;case"linestring":case"multilinestring":this.map.addLayer({id:this.layerId,type:"line",source:this.sourceId,paint:{"line-color":"#ff0000","line-opacity":.8,"line-width":3}});break;case"point":this.map.addLayer({id:this.layerId,type:"circle",source:this.sourceId,paint:{"circle-color":"#ff0000","circle-opacity":.8,"circle-radius":5,"circle-stroke-color":"#fff","circle-stroke-width":2,"circle-stroke-opacity":1}});break}}setData(t){if(!t)return;const n={type:"Feature",geometry:t},r=this.map.getSource(this.sourceId);r&&(this.featureCollection.features=[n],r?.setData(this.featureCollection))}flyTo(){if(this.featureCollection.features.length!==0)try{let t=this.featureCollection.features[0];if(!t)return;let n=null;if(t.geometry.type.toLowerCase()==="point"?n=t.geometry.coordinates:n=z3(this.featureCollection)?.geometry?.coordinates||null,!n)return;this.map.panTo(n)}catch(t){console.error("计算外包边框中心点失败:",t)}}formatWktToGeoJson(t){if(!t)return null;try{return Zd.parse(t)}catch(n){return console.error("WKT 转换为 GeoJSON 失败:",n),null}}formatGeoJsonToWkt(t){if(!t)return"";try{return Zd.stringify(t)}catch(n){return console.error("GeoJSON 转换为 WKT 失败:",n),""}}clear(){this.map.removeLayer(this.layerId),this.map.removeSource(this.sourceId)}}class Y3{map;drawSourceId="curd-map-draw-source";drawLayerId="curd-map-draw-layer";drawLineLayerId="curd-map-draw-line-layer";drawPointLayerId="curd-map-draw-point-layer";drawFeatureCollection={type:"FeatureCollection",features:[]};drawType="none";drawCoordinates=[];drawCallback=null;constructor(t){this.map=t,this.initDrawSource()}initDrawSource(){this.map.getSource(this.drawSourceId)||this.map.addSource(this.drawSourceId,{type:"geojson",data:this.drawFeatureCollection})}startDraw(t,n){this.clearDraw(),this.drawType=t,this.drawCallback=n,this.drawCoordinates=[],this.setupDrawLayers(),this.setupDrawEvents(),this.map.getCanvas().style.cursor="crosshair"}stopDraw(){this.drawType="none",this.drawCallback=null,this.clearDraw(),this.removeDrawEvents(),this.map.getCanvas().style.cursor=""}clearDraw(){this.drawCoordinates=[],this.drawFeatureCollection.features=[];const t=this.map.getSource(this.drawSourceId);t&&t.setData(this.drawFeatureCollection),[this.drawLayerId,this.drawLineLayerId,this.drawPointLayerId,`${this.drawLayerId}-outline`].forEach(n=>{this.map.getLayer(n)&&this.map.removeLayer(n)})}setupDrawLayers(){[this.drawLayerId,this.drawLineLayerId,this.drawPointLayerId,`${this.drawLayerId}-outline`].forEach(n=>{this.map.getLayer(n)&&this.map.removeLayer(n)});const t="#ff0000";this.drawType==="point"&&this.map.addLayer({id:this.drawLayerId,type:"circle",source:this.drawSourceId,paint:{"circle-color":t,"circle-opacity":.8,"circle-radius":6,"circle-stroke-color":"#fff","circle-stroke-width":2,"circle-stroke-opacity":1}}),(this.drawType==="line"||this.drawType==="polygon")&&(this.map.addLayer({id:this.drawLineLayerId,type:"line",source:this.drawSourceId,paint:{"line-color":t,"line-opacity":.8,"line-width":3}}),this.map.addLayer({id:this.drawPointLayerId,type:"circle",source:this.drawSourceId,paint:{"circle-color":t,"circle-opacity":.8,"circle-radius":4,"circle-stroke-color":"#fff","circle-stroke-width":2,"circle-stroke-opacity":1}})),this.drawType==="polygon"&&(this.map.addLayer({id:this.drawLayerId,type:"fill",source:this.drawSourceId,paint:{"fill-color":t,"fill-opacity":.3}}),this.map.addLayer({id:`${this.drawLayerId}-outline`,type:"line",source:this.drawSourceId,paint:{"line-color":t,"line-opacity":.8,"line-width":2}}))}setupDrawEvents(){this.map.on("click",this.handleMapClick.bind(this)),this.map.on("mousemove",this.handleMapMouseMove.bind(this)),this.map.on("dblclick",this.handleMapDoubleClick.bind(this)),this.map.doubleClickZoom.disable()}removeDrawEvents(){this.map.off("click",this.handleMapClick.bind(this)),this.map.off("mousemove",this.handleMapMouseMove.bind(this)),this.map.off("dblclick",this.handleMapDoubleClick.bind(this)),this.map.doubleClickZoom.enable()}handleMapClick(t){const n=t.lngLat.toArray();this.drawCoordinates.push(n),this.updateDrawFeature(),this.drawType==="point"&&this.finishDraw()}handleMapMouseMove(t){if(this.drawType==="none"||this.drawCoordinates.length===0)return;const n=t.lngLat.toArray(),r=[...this.drawCoordinates,n];this.updateDrawFeature(r)}handleMapDoubleClick(){(this.drawType==="line"||this.drawType==="polygon")&&this.finishDraw()}updateDrawFeature(t){const n=t||this.drawCoordinates;if(n.length===0)return;let r=null;switch(this.drawType){case"point":r={type:"Point",coordinates:n[0]};break;case"line":r={type:"LineString",coordinates:n};break;case"polygon":r={type:"Polygon",coordinates:[n]};break}if(r){this.drawFeatureCollection.features=[{type:"Feature",geometry:r}];const i=this.map.getSource(this.drawSourceId);i&&i.setData(this.drawFeatureCollection)}}finishDraw(){if(this.drawCoordinates.length===0)return;let t=null;switch(this.drawType){case"point":t={type:"Point",coordinates:this.drawCoordinates[0]};break;case"line":if(this.drawCoordinates.length<2){this.clearDraw();return}t={type:"LineString",coordinates:this.drawCoordinates};break;case"polygon":if(this.drawCoordinates.length<3){this.clearDraw();return}t={type:"Polygon",coordinates:[[...this.drawCoordinates,this.drawCoordinates[0]]]};break}if(t&&this.drawCallback){const n=Zd.stringify(t);this.drawCallback(this.drawType,t,n),this.map.getCanvas().style.cursor="",this.drawType="none",this.map.off("click",this.handleMapClick.bind(this)),this.map.off("mousemove",this.handleMapMouseMove.bind(this)),this.map.off("dblclick",this.handleMapDoubleClick.bind(this)),setTimeout(()=>{this.map.doubleClickZoom.enable()},0)}}destroy(){this.stopDraw(),this.map.getSource(this.drawSourceId)&&this.map.removeSource(this.drawSourceId)}}const q3={class:"map-draw-container"},j3={name:"FormItemMapDraw"},W3=g.defineComponent({...j3,props:{geomType:{type:String,default:"point"}},emits:["draw-start","draw-end","draw-cancel"],setup(e,{emit:t}){const n=t,r=g.ref("none");g.ref(!1),g.ref(null);const i=XE,o=iS,a=uS,s=l=>{r.value=l,l==="none"?n("draw-cancel"):n("draw-start",l)};return(l,c)=>(g.openBlock(),g.createElementBlock("div",q3,[e.geomType==="point"?(g.openBlock(),g.createBlock(g.unref(B.ElButton),{key:0,type:"primary",size:"small",circle:"",onClick:c[0]||(c[0]=d=>s("point")),icon:g.unref(i),class:g.normalizeClass({active:r.value==="point"})},null,8,["icon","class"])):g.createCommentVNode("",!0),e.geomType==="linestring"?(g.openBlock(),g.createBlock(g.unref(B.ElButton),{key:1,type:"primary",size:"small",circle:"",onClick:c[1]||(c[1]=d=>s("line")),icon:g.unref(o),class:g.normalizeClass({active:r.value==="line"})},null,8,["icon","class"])):g.createCommentVNode("",!0),e.geomType==="polygon"?(g.openBlock(),g.createBlock(g.unref(B.ElButton),{key:2,type:"primary",size:"small",circle:"",onClick:c[2]||(c[2]=d=>s("polygon")),icon:g.unref(a),class:g.normalizeClass({active:r.value==="polygon"})},null,8,["icon","class"])):g.createCommentVNode("",!0)]))}}),K3=Rr(W3,[["__scopeId","data-v-c4ff065e"]]),Q3={class:"curd-map"},Z3={name:"FormItemMap"},X3=g.defineComponent({...Z3,props:{modelValue:{type:String||void 0,default:()=>""},glyphs:{type:String||void 0,default:()=>""},mapViewData:{type:Object||void 0,default:()=>({})},currentOperationType:{type:String,default:()=>"details"}},emits:["update:modelValue"],setup(e,{emit:t}){const n=e,r=g.ref(n.modelValue);let i,o;const a=g.reactive({mapViewData:{zoom:n.mapViewData.zoom||13,center:n.mapViewData.center||[120.656774,29.8],maxPitch:n.mapViewData.maxPitch||0,dragRotate:n.mapViewData.dragRotate||!1,style:{glyphs:n.glyphs},...n.mapViewData},switchData:{layers:[{name:"tdt-vec",label:"地图",iconName:"vector",checked:!0},{name:"tdt-img",label:"影像",iconName:"satellite",checked:!1}],extensions:[{name:"tdt-cia",label:"注记",checked:!0}]}}),s=t;g.watch(r,u=>{s("update:modelValue",u)}),g.watch(()=>n.modelValue,u=>{r.value=u});const l=u=>{i=new $3(u),o=new Y3(u);const p=i.formatWktToGeoJson(r.value);p&&(i.setLayer(p.type),i.setData(p),i.flyTo())},c=u=>{o&&o.startDraw(u,(p,m,h)=>{r.value=h})},d=()=>{o&&o.stopDraw()};return g.onUnmounted(()=>{o&&(o.destroy(),o=void 0)}),(u,p)=>(g.openBlock(),g.createElementBlock("div",Q3,[g.createVNode(g.unref(iu.GisMapView),{options:a.mapViewData,onLoad:l},{"top-left":g.withCtx(()=>[e.currentOperationType!=="details"?(g.openBlock(),g.createBlock(K3,{key:0,onDrawStart:c,onDrawCancel:d})):g.createCommentVNode("",!0)]),"bottom-right":g.withCtx(()=>[g.createVNode(g.unref(iu.GisMapSwitch),{data:a.switchData},null,8,["data"])]),default:g.withCtx(()=>[g.renderSlot(u.$slots,"default",{},void 0,!0)]),_:3},8,["options"])]))}}),J3=Rr(X3,[["__scopeId","data-v-e1f42b56"]]),e4={class:"field-select-container"},t4={name:"ExportButton"},n4=g.defineComponent({...t4,props:{columns:{type:Array,default:()=>[]},visibleColumns:{type:Array,default:()=>[]},data:{type:Array,default:()=>[]}},setup(e){const t=e,n=g.ref(null),r=g.ref(!1),i=g.reactive({filename:"",dataType:"current",selectedFields:[]}),o=g.reactive({filename:[{required:!0,message:"请输入文件名称",trigger:["blur"]}]}),a=g.computed(()=>(t?.columns||[]).filter(c=>c.checkedFields.indexOf("exportable")>-1));g.onMounted(()=>{i.selectedFields=t?.visibleColumns||[]});const s=async()=>{if(!await n.value?.validate()){B.ElMessage.error("请填写正确的文件名称");return}let d=[...t.data];if(d.length===0){B.ElMessage.warning("没有数据可导出");return}const u={};t.columns.forEach(S=>{u[S.columnProperty]=S.columnLabel||S.columnProperty});const p=d.map(S=>{const y={};return i.selectedFields.forEach(E=>{y[E]=S[E]}),y}),m=i.filename||`导出数据_${new Date().getTime()}`,h=l(p,u),_=new Blob([h],{type:"text/csv;charset=utf-8;"}),f=document.createElement("a"),b=URL.createObjectURL(_);f.setAttribute("href",b),f.setAttribute("download",`${m}.csv`),f.style.visibility="hidden",document.body.appendChild(f),f.click(),document.body.removeChild(f),r.value=!1,B.ElMessage.success("导出成功")},l=(c,d)=>{if(c.length===0)return"";const u=Object.keys(c[0])||[],p=[],m=u.map(h=>d[h]||h);p.push(m.join(","));for(const h of c){const _=u.map(f=>{const b=h[f];return typeof b=="string"?`"${b.replace(/"/g,'""')}"`:b});p.push(_.join(","))}return p.join(`
|
|
677
|
-
`)};return(c,d)=>(g.openBlock(),g.createElementBlock("div",null,[g.createVNode(g.unref(B.ElButton),{type:"default",round:"",onClick:d[0]||(d[0]=u=>r.value=!0)},{default:g.withCtx(()=>[g.createVNode(g.unref(B.ElIcon),null,{default:g.withCtx(()=>[g.createVNode(g.unref(nS))]),_:1})]),_:1}),g.createVNode(g.unref(B.ElDialog),{modelValue:r.value,"onUpdate:modelValue":d[4]||(d[4]=u=>r.value=u),title:"导出数据",width:"400px","close-on-click-modal":!1},{footer:g.withCtx(()=>[g.createVNode(g.unref(B.ElButton),{onClick:d[3]||(d[3]=u=>r.value=!1)},{default:g.withCtx(()=>[...d[5]||(d[5]=[g.createTextVNode("取消",-1)])]),_:1}),g.createVNode(g.unref(B.ElButton),{type:"primary",onClick:s},{default:g.withCtx(()=>[...d[6]||(d[6]=[g.createTextVNode("导出",-1)])]),_:1})]),default:g.withCtx(()=>[g.createVNode(g.unref(B.ElForm),{ref_key:"exportFormRef",ref:n,model:i,"label-width":"100px",rules:o},{default:g.withCtx(()=>[g.createVNode(g.unref(B.ElFormItem),{label:"文件名称",prop:"filename"},{default:g.withCtx(()=>[g.createVNode(g.unref(B.ElInput),{modelValue:i.filename,"onUpdate:modelValue":d[1]||(d[1]=u=>i.filename=u),placeholder:"请输入文件名称"},null,8,["modelValue"])]),_:1}),g.createVNode(g.unref(B.ElFormItem),{label:"选择字段"},{default:g.withCtx(()=>[g.createElementVNode("div",e4,[g.createVNode(g.unref(B.ElCheckboxGroup),{modelValue:i.selectedFields,"onUpdate:modelValue":d[2]||(d[2]=u=>i.selectedFields=u)},{default:g.withCtx(()=>[(g.openBlock(!0),g.createElementBlock(g.Fragment,null,g.renderList(a.value,u=>(g.openBlock(),g.createElementBlock("div",{key:u.columnProperty,class:"column-item"},[g.createVNode(g.unref(B.ElCheckbox),{value:u.columnProperty},{default:g.withCtx(()=>[g.createTextVNode(g.toDisplayString(u.columnLabel),1)]),_:2},1032,["value"])]))),128))]),_:1},8,["modelValue"])])]),_:1})]),_:1},8,["model","rules"])]),_:1},8,["modelValue"])]))}}),r4=Rr(n4,[["__scopeId","data-v-551fc665"]]),i4={class:"column-manager"},o4={name:"ColumnManager"},a4=g.defineComponent({...o4,props:{tableColumns:{type:Array,default:()=>({columns:[]})},visibleColumns:{type:Array,default:()=>[]}},emits:["update:visibleColumns","update:columns"],setup(e,{emit:t}){const n=e,r=t,i=g.ref(!1),o=g.ref([...n.visibleColumns]),a=(s,l)=>{l?o.value.push(s):o.value=o.value.filter(c=>c!==s),r("update:visibleColumns",o.value)};return g.watch(()=>n.visibleColumns,s=>{o.value=[...s]},{deep:!0}),(s,l)=>(g.openBlock(),g.createElementBlock("div",null,[g.createVNode(g.unref(B.ElPopover),{visible:i.value,"onUpdate:visible":l[0]||(l[0]=c=>i.value=c),placement:"bottom-end",width:220,trigger:"click","popper-class":"column-manager-popover"},{reference:g.withCtx(()=>[g.createVNode(g.unref(B.ElButton),{type:"default",round:""},{default:g.withCtx(()=>[g.createVNode(g.unref(B.ElIcon),null,{default:g.withCtx(()=>[g.createVNode(g.unref(cS))]),_:1})]),_:1})]),default:g.withCtx(()=>[g.createElementVNode("div",i4,[(g.openBlock(!0),g.createElementBlock(g.Fragment,null,g.renderList(e.tableColumns,c=>(g.openBlock(),g.createElementBlock("div",{class:"column-item",key:c.columnProperty},[g.createVNode(g.unref(B.ElCheckbox),{modelValue:o.value.includes(c.columnProperty),onChange:d=>a(c.columnProperty,d)},{default:g.withCtx(()=>[g.createTextVNode(g.toDisplayString(c.columnLabel||c.columnProperty),1)]),_:2},1032,["modelValue","onChange"])]))),128))])]),_:1},8,["visible"])]))}}),s4=Rr(a4,[["__scopeId","data-v-3bb66278"]]);class l4{serverConfig;curdConfig={};searchConfig={};tableConfig={};editorConfig={};searchFormMap=new Map;cloneSearchForm="{}";cloneFormData="{}";dictionaryMap=new Map;columnMap=new Map;constructor({serverConfig:t}){this.serverConfig=t}setConfig({curdConfig:t,searchConfig:n,tableConfig:r,editorConfig:i}){this.curdConfig=t||this.curdConfig,this.searchConfig=n||this.searchConfig,this.tableConfig=r||this.tableConfig,this.editorConfig=i||this.editorConfig,this.columnMap?.clear(),this.tableConfig?.columns?.forEach(o=>{this.columnMap?.set(o.columnProperty,o)})}async loadDictionary(){if(!this.tableConfig?.columns)return this.dictionaryMap;const t=this.tableConfig.columns.filter(n=>["code","table"].includes(n.dictType||"")&&n.dictService).map(n=>{let r=n.fieldType||"String";return r==="integer"&&(r="Integer"),(n.dictType==="code"?this.serverConfig?.dict({dictCode:n.dictService,itemIdType:r}):this.serverConfig?.dictServer(n.dictService,{})).then(o=>{o&&n.dictService&&this.dictionaryMap.set(n.dictService,o||[])}).catch(o=>{console.error(`加载字典 ${n.dictService} 失败:`,o)})});return await Promise.all(t),this.dictionaryMap}getDictOptionsByCode(t){return t?this.dictionaryMap.get(t)||[]:[]}getDictOptionsByColumnProperty(t){if(!t)return[];const n=this.tableConfig?.columns?.find(r=>r.columnProperty===t)?.dictService;return this.getDictOptionsByCode(n||void 0)}formatColumnValue(t,n){if(n==null||n==="")return n;if(t.dictType&&t.dictService){const r=this.dictionaryMap.get(t.dictService)||[];if(!r||r.length===0)return n;const i=r.find(o=>o.id===n);return i?i.name:n}if(!t.formatter||t.formatter==="")return n;switch(t.fieldType){case"date":return n?B.dayjs(n).format(t.formatter||"YYYY-MM-DD"):"";case"datetime":return n?B.dayjs(n).format(t.formatter||"YYYY-MM-DD HH:mm:ss"):"";default:return n}}formatFormRules(){const t={};return(this.editorConfig?.columns||[]).forEach(n=>{t[n.columnProperty]=[],n.isRequired&&t[n.columnProperty].push({required:!0,message:"请输入"+n.columnLabel,trigger:"blur"})}),t}formatSearchConfigForm(){this.searchConfig.columns=this.tableConfig?.columns?.filter(n=>n.searchable!="no")||[],this.searchConfig?.columns.forEach(n=>{this.searchFormMap.set(n.columnProperty,n)});const t={};return this.searchConfig?.columns.forEach(n=>{let r=n.searchDefaultValue;r!=null&&r!==""&&(r=this.formatValueByColumnProperty(r,n.columnProperty)),t[n.columnProperty]=r}),this.cloneSearchForm=JSON.stringify(t),t}formatFormConfigData(){const t={};return(this.editorConfig?.columns||[]).filter(r=>r.columnProperty===this.curdConfig?.priKey?!0:r.type!=="hidden").forEach(r=>{let i=r.defaultValue;i!=null&&i!==""&&(i=this.formatValueByColumnProperty(i,r.columnProperty)),t[r.columnProperty]=i}),this.cloneFormData=JSON.stringify(t),t}formatSearchForm(t){const n={};return this.searchFormMap.forEach((r,i)=>{const o=t[i];if(o!=null&&o!==""){let a="";switch(r.searchable){case"=":a=`= '${o}'`;break;case"like":a=`like '%${o}%'`;break;case"in":a=`in (${o})`;break}n[i]=a}}),n}formatFormData(t){if(!t||Object.keys(t).length===0)return{};let n={};return(this.tableConfig?.columns||[]).forEach(r=>{r?.fieldType==="integer"?n[r.columnProperty]=Number(t[r.columnProperty]):n[r.columnProperty]=t[r.columnProperty]}),t.wktstr&&(n.wktstr=t.wktstr),n}initVisibleColumns(){return(this.tableConfig?.columns||[]).filter(t=>t.showMethod!="hidden").map(t=>t.columnProperty)}getFormItems(t=""){let n=[];switch(t){case"details":n=(this.editorConfig?.columns||[]).filter(r=>r.type!=="hidden"&&r.updateFormStatus!=="hidden"&&r.type!=="shape");break;case"add":n=(this.editorConfig?.columns||[]).filter(r=>r.type!=="hidden"&&r.createFormStatus!=="hidden"&&r.type!=="shape");break;case"update":n=(this.editorConfig?.columns||[]).filter(r=>r.type!=="hidden"&&r.updateFormStatus!=="hidden"&&r.type!=="shape");break}return n}hasGeometryField(){return(this.editorConfig?.columns||[]).find(n=>n.type==="shape")||void 0}formatValueByColumnProperty(t,n){const r=this.columnMap?.get(n);if(!r)return t;switch(r?.fieldType){case"integer":case"float":case"double":case"number":return Number(t);default:return t}}}const c4={class:"curd-container"},d4={class:"curd-search"},u4={key:0,class:"table-actions"},p4={class:"table-actions-left"},m4={class:"table-actions-right"},h4={key:1,class:"curd-pagination"},_4={name:"CurdForm"},g4=g.defineComponent({..._4,props:{size:{type:String,default:"default"},title:{type:String,default:"信息管理"},permissions:{type:Object,default:()=>({add:!1,edit:!1,delete:!1,deleteBatch:!1,export:!1})},serverConfig:{type:Object,default:()=>({init:Function,list:Function,view:Function,add:Function,delete:Function,deleteBatch:Function,update:Function,dict:Function,dictServer:Function,upload:Function,download:Function,headers:Function})},mapViewData:{type:Object,default:()=>({})}},emits:["loadDataSuccess","switchChange"],setup(e,{expose:t,emit:n}){const r=e,i=g.ref(!1),o=g.ref(null),a=g.ref(null),s=n,l=g.ref(),c=new l4({serverConfig:r.serverConfig}),d=g.ref(""),u=g.ref("details"),p=g.reactive({priKey:"id",priKeyType:"string",sortField:"id",sortOrder:0,geomType:"point",webFunction:[],dataExt:"{}"}),m=g.reactive({showIndex:!0,indexWidth:50,showCheckbox:!0,showOperation:!0,operationWidth:120,operationLocation:"right",operationButtons:[],visibleOperationButtons:[],operationAlign:"center",showPagination:!0,defaultPageSize:10,pageUISize:"default",showExpand:!1,columns:[]}),h=g.reactive({total:0,pageSize:m.defaultPageSize,currentPage:1}),_=g.reactive({title:"弹框表单",formDialogWidth:"800px",labelWidth:"120px"}),f=g.reactive({columns:[],formColumns:[]}),b=g.reactive({searchLabelWidth:"80",searchFormWidth:"290",columns:[]}),S=g.ref({}),y=g.ref(!1),E=g.ref([]),C=g.reactive({data:{}}),v=g.ref({}),N=g.ref(!1),w=g.ref(!1),O=g.ref(),L=g.ref([]),H=async()=>{if(r.serverConfig?.list)try{i.value=!0;const G=await r.serverConfig?.list({whereClause:c.formatSearchForm(S.value),orderParam:[{fieldName:p.sortField,asc:p.sortOrder===0}],pageParam:{pageNum:h.currentPage,pageSize:h.pageSize}});if(G){const j=G.data;E.value=j.dataList||[],h.total=j.totalCount,s("loadDataSuccess",E.value)}}catch{}finally{i.value=!1}},V=()=>{S.value=JSON.parse(c.cloneSearchForm),H()},q=async()=>{r.serverConfig?.add&&(u.value="add",f.formColumns=c.getFormItems("add"),_.title="新增信息",y.value=!0,C.data=JSON.parse(c.cloneFormData))},K=async()=>{if(r.serverConfig?.deleteBatch&&a?.value){const G=a.value.getSelectionRows();if(G.length===0){B.ElMessage.warning("请选择要删除的项");return}const j=G.map(k=>k[p.priKey||"id"]);j.length>0&&B.ElMessageBox.confirm("确定删除选中项吗?","提示",{confirmButtonText:"确定",cancelButtonText:"取消",type:"warning"}).then(async()=>{await r.serverConfig?.deleteBatch?.(j.join(","))?B.ElMessage.success("删除成功"):B.ElMessage.error("删除失败"),H()})}},Q=G=>{h.pageSize=Number(G),H()},A=G=>{h.currentPage=G,H()},T=async G=>{if(r.serverConfig?.view){u.value="details",f.formColumns=c.getFormItems("details"),_.title="查看详情";try{const j=G[p.priKey||"id"];if(!j){B.ElMessage.error("查看失败,未获取到主键值");return}const k=await r.serverConfig?.view?.({key:j});debugger;k.success&&k.data?(C.data={...k.data},y.value=!0):B.ElMessage.error("查询失败")}catch{B.ElMessage.error("查询失败")}}},R=async G=>{r.serverConfig?.update&&(u.value="update",f.formColumns=c.getFormItems("update"),_.title="编辑信息",y.value=!0,C.data={...G})},P=G=>{r.serverConfig?.delete&&B.ElMessageBox.confirm("确定删除选中项吗?","提示",{confirmButtonText:"确定",cancelButtonText:"取消",type:"warning"}).then(async()=>{const j=G[p.priKey||"id"];if(!j){B.ElMessage.error("删除失败,未获取到主键值");return}await r.serverConfig?.delete?.(j)?(B.ElMessage.success("删除成功"),H()):B.ElMessage.error("删除失败")})},Y=()=>{N.value=!0,l.value?.validate(async(G,j)=>{if(G){let k=u.value==="add"?r.serverConfig?.add:r.serverConfig?.update;if(k)try{const le=await k({params:{...c.formatFormData(C.data)}});le.success?(B.ElMessage.success(u.value==="add"?"新增成功":"编辑成功"),y.value=!1,H()):B.ElMessage.error("保存失败"+le.msg)}catch(le){B.ElMessage.error("保存失败"+le.message)}finally{N.value=!1}}else N.value=!1})},X=G=>{s("switchChange",G)};g.onMounted(async()=>{if(r.serverConfig?.init){const G=await r.serverConfig.init();if(G.success&&G.data){const j=G.data||{},k=j.dataExt?JSON.parse(j.dataExt):{};Object.assign(p,j||{}),Object.assign(m,k?.tableConfig||{}),Object.assign(_,k?.dialogConfig||{}),Object.assign(f?.columns||[],k?.editorConfig||{}),h.pageSize=m.defaultPageSize||h.pageSize,m.visibleOperationButtons=(m.operationButtons||[]).map(le=>le.type),console.log("curdConfig",p),console.log("tableConfig",m),console.log("dialogConfig",_),console.log("editorConfig",f),b.searchFormWidth=m.searchFormWidth&&m.searchFormWidth!==""?m.searchFormWidth:b.searchFormWidth,b.searchLabelWidth=m.searchLabelWidth&&m.searchLabelWidth!==""?m.searchLabelWidth:b.searchLabelWidth,c.setConfig({curdConfig:p,searchConfig:b,tableConfig:m,editorConfig:f}),await c.loadDictionary(),L.value=c.initVisibleColumns(),S.value=c.formatSearchConfigForm(),C.data=c.formatFormConfigData(),v.value=c.formatFormRules(),O.value=c.hasGeometryField(),await c.loadDictionary(),requestAnimationFrame(()=>{d.value=o.value?.clientHeight+"px"}),setTimeout(()=>{H()},500)}else B.ElMessage.error("未查询到有效配置")}else B.ElMessage.error("请配置init方法");window.addEventListener("resize",se)});const se=()=>{d.value="100px",requestAnimationFrame(()=>{d.value=o.value?.clientHeight+"px"})};g.onUnmounted(()=>{window.removeEventListener("resize",se)}),g.watch(y,G=>{G?g.nextTick(()=>{w.value=!0}):w.value=!1});const Ce=G=>{E.value=G},Se=G=>{m.columns=G};return t({setTableData:Ce,getTableData:()=>E.value}),(G,j)=>(g.openBlock(),g.createElementBlock(g.Fragment,null,[g.createElementVNode("div",c4,[g.createElementVNode("div",d4,[g.createVNode(g.unref(B.ElForm),{inline:!0,class:"form-inline","label-width":b.searchLabelWidth},{default:g.withCtx(()=>[(g.openBlock(!0),g.createElementBlock(g.Fragment,null,g.renderList(b.columns,k=>(g.openBlock(),g.createBlock(g.unref(B.ElFormItem),{key:k.columnProperty,label:k.searchFormLabel||k.columnLabel,style:g.normalizeStyle(`width: ${b.searchFormWidth}px;`)},{default:g.withCtx(()=>[k.showMethod==="slot"?g.renderSlot(G.$slots,"search-"+k.columnProperty,{key:0,scope:{...G.scope,searchForm:S.value,data:S.value[k.columnProperty]}},void 0,!0):(g.openBlock(),g.createBlock(ou,{key:1,modelValue:S.value[k.columnProperty],"onUpdate:modelValue":le=>S.value[k.columnProperty]=le,item:k,dropdownOptions:g.unref(c).getDictOptionsByCode(k.dictService)},null,8,["modelValue","onUpdate:modelValue","item","dropdownOptions"]))]),_:2},1032,["label","style"]))),128)),g.createVNode(g.unref(B.ElFormItem),{style:{"margin-left":"10px"}},{default:g.withCtx(()=>[g.createVNode(g.unref(B.ElButton),{type:"primary",size:e.size,icon:"Search",onClick:H},{default:g.withCtx(()=>[...j[6]||(j[6]=[g.createTextVNode("查询",-1)])]),_:1},8,["size"]),g.createVNode(g.unref(B.ElButton),{type:"default",size:e.size,icon:"Refresh",onClick:V},{default:g.withCtx(()=>[...j[7]||(j[7]=[g.createTextVNode("重置",-1)])]),_:1},8,["size"])]),_:1})]),_:3},8,["label-width"])]),p.webFunction.length>0?(g.openBlock(),g.createElementBlock("div",u4,[g.createElementVNode("div",p4,[e.permissions.add&&p.webFunction.includes("add")?(g.openBlock(),g.createBlock(g.unref(B.ElButton),{key:0,type:"primary",size:e.size,icon:"CirclePlus",onClick:q},{default:g.withCtx(()=>[...j[8]||(j[8]=[g.createTextVNode("新增",-1)])]),_:1},8,["size"])):g.createCommentVNode("",!0),e.permissions.delete&&p.webFunction.includes("batchDelete")?(g.openBlock(),g.createBlock(g.unref(B.ElButton),{key:1,type:"danger",size:e.size,icon:"Delete",onClick:K},{default:g.withCtx(()=>[...j[9]||(j[9]=[g.createTextVNode("批量删除",-1)])]),_:1},8,["size"])):g.createCommentVNode("",!0),g.renderSlot(G.$slots,"table-actions",{},void 0,!0)]),g.createElementVNode("div",m4,[g.renderSlot(G.$slots,"table-actions-right",{},void 0,!0),p.webFunction.includes("export")?(g.openBlock(),g.createBlock(r4,{key:0,columns:m.columns,"visible-columns":L.value,data:E.value},null,8,["columns","visible-columns","data"])):g.createCommentVNode("",!0),g.createVNode(s4,{"table-columns":m.columns,"visible-columns":L.value,"onUpdate:visibleColumns":j[0]||(j[0]=k=>L.value=k),"onUpdate:columns":Se},null,8,["table-columns","visible-columns"])])])):g.createCommentVNode("",!0),g.createElementVNode("div",{ref_key:"curdTableContainerRef",ref:o,class:"curd-table"},[g.createVNode(g.unref(B.ElTable),{ref_key:"tableRef",ref:a,data:E.value,border:"",stripe:"",size:e.size,height:d.value,"header-cell-style":{background:"#F5F7FA"}},{default:g.withCtx(()=>[m.showIndex?(g.openBlock(),g.createBlock(g.unref(B.ElTableColumn),{key:0,type:"index",width:m.indexWidth,label:"#",align:"center"},null,8,["width"])):g.createCommentVNode("",!0),e.permissions.delete&&p.webFunction.includes("batchDelete")?(g.openBlock(),g.createBlock(g.unref(B.ElTableColumn),{key:1,type:"selection",width:"55",align:"center"})):g.createCommentVNode("",!0),(g.openBlock(!0),g.createElementBlock(g.Fragment,null,g.renderList(m.columns,k=>(g.openBlock(),g.createElementBlock(g.Fragment,{key:k.prop},[L.value.includes(k.columnProperty)?(g.openBlock(),g.createBlock(g.unref(B.ElTableColumn),{key:0,label:k.columnLabel,width:(k.width||"")+"px",fixed:k.fixed,"show-overflow-tooltip":k.noWrap,align:k.align,"header-align":k.headerAlign},{default:g.withCtx(le=>[k.showMethod==="slot"?g.renderSlot(G.$slots,"table-column-"+k.columnProperty,{key:0,scope:le},void 0,!0):k.showMethod==="upload"?(g.openBlock(),g.createBlock(Ws,{key:1,item:k,modelValue:le.row[k.columnProperty],"onUpdate:modelValue":ot=>le.row[k.columnProperty]=ot,currentOperationType:"column",headers:e.serverConfig.headers(),download:e.serverConfig.download()},null,8,["item","modelValue","onUpdate:modelValue","headers","download"])):k.showMethod==="tag"?(g.openBlock(),g.createBlock(g.unref(B.ElTag),{key:2,type:le?.row[k.columnProperty]===1||le?.row[k.columnProperty]==="1"?"success":k.tagType||"info"},{default:g.withCtx(()=>[g.createTextVNode(g.toDisplayString(g.unref(c).formatColumnValue(k,le?.row[k.columnProperty])),1)]),_:2},1032,["type"])):k.showMethod==="switch"?(g.openBlock(),g.createBlock(g.unref(B.ElSwitch),{key:3,modelValue:le.row[k.columnProperty],"onUpdate:modelValue":ot=>le.row[k.columnProperty]=ot,"active-value":"1","inactive-value":"0","active-text":"是","inactive-text":"否",onChange:ot=>X(le)},null,8,["modelValue","onUpdate:modelValue","onChange"])):(g.openBlock(),g.createElementBlock(g.Fragment,{key:4},[g.createTextVNode(g.toDisplayString(g.unref(c).formatColumnValue(k,le?.row[k.columnProperty])),1)],64))]),_:2},1032,["label","width","fixed","show-overflow-tooltip","align","header-align"])):g.createCommentVNode("",!0)],64))),128)),g.createVNode(g.unref(B.ElTableColumn),{align:m.operationAlign,fixed:"right",width:m.operationWidth,label:"操作"},{default:g.withCtx(k=>[m.visibleOperationButtons.includes("detail")?(g.openBlock(),g.createBlock(g.unref(B.ElButton),{key:0,type:"primary",plain:"",size:m.operationSize,onClick:le=>T(k.row)},{default:g.withCtx(()=>[...j[10]||(j[10]=[g.createTextVNode("详情",-1)])]),_:1},8,["size","onClick"])):g.createCommentVNode("",!0),m.visibleOperationButtons.includes("edit")&&e.permissions.edit?(g.openBlock(),g.createBlock(g.unref(B.ElButton),{key:1,type:"success",plain:"",size:m.operationSize,onClick:le=>R(k.row)},{default:g.withCtx(()=>[...j[11]||(j[11]=[g.createTextVNode("编辑",-1)])]),_:1},8,["size","onClick"])):g.createCommentVNode("",!0),m.visibleOperationButtons.includes("delete")&&e.permissions.delete?(g.openBlock(),g.createBlock(g.unref(B.ElButton),{key:2,type:"danger",plain:"",size:m.operationSize,onClick:le=>P(k.row)},{default:g.withCtx(()=>[...j[12]||(j[12]=[g.createTextVNode("删除",-1)])]),_:1},8,["size","onClick"])):g.createCommentVNode("",!0),g.renderSlot(G.$slots,"table-column-action",{scope:k},void 0,!0)]),_:3},8,["align","width"])]),_:3},8,["data","size","height"])],512),m.showPagination?(g.openBlock(),g.createElementBlock("div",h4,[g.createVNode(g.unref(B.ElPagination),{"current-page":h.currentPage,"onUpdate:currentPage":j[1]||(j[1]=k=>h.currentPage=k),"page-size":h.pageSize,"onUpdate:pageSize":j[2]||(j[2]=k=>h.pageSize=k),total:h.total,layout:"total, sizes, prev, pager, next",background:"",size:e.size,onSizeChange:Q,onCurrentChange:A},null,8,["current-page","page-size","total","size"])])):g.createCommentVNode("",!0)]),g.createVNode(g.unref(B.ElDialog),{title:_.title,"close-on-click-modal":!1,"close-on-press-escape":!1,width:_.formDialogWidth,modelValue:y.value,"onUpdate:modelValue":j[5]||(j[5]=k=>y.value=k),"destroy-on-close":!0,draggable:"","append-to-body":!0,"align-center":""},g.createSlots({default:g.withCtx(()=>[g.createVNode(g.unref(B.ElRow),null,{default:g.withCtx(()=>[g.createVNode(g.unref(B.ElCol),{span:O.value?24-O.value.span:24},{default:g.withCtx(()=>[g.createVNode(g.unref(B.ElForm),{ref_key:"formRef",ref:l,model:C.data,rules:v.value,size:"default","label-width":_.labelWidth,"label-suffix":":",class:g.normalizeClass({"curd-form-details":u.value==="details"})},{default:g.withCtx(()=>[g.createVNode(g.unref(B.ElRow),null,{default:g.withCtx(()=>[g.createVNode(g.unref(B.ElCol),{span:24},{default:g.withCtx(()=>[g.createVNode(g.unref(B.ElRow),null,{default:g.withCtx(()=>[(g.openBlock(!0),g.createElementBlock(g.Fragment,null,g.renderList(f.formColumns,k=>(g.openBlock(),g.createBlock(g.unref(B.ElCol),{key:k.columnProperty,span:k.span||12},{default:g.withCtx(()=>[g.createVNode(g.unref(B.ElFormItem),{label:k.columnLabel,prop:k.columnProperty},{default:g.withCtx(()=>[u.value==="details"?(g.openBlock(),g.createElementBlock(g.Fragment,{key:0},[k.type==="upload"?(g.openBlock(),g.createBlock(Ws,{key:0,item:k,modelValue:C.data[k.columnProperty],"onUpdate:modelValue":le=>C.data[k.columnProperty]=le,currentOperationType:u.value,headers:e.serverConfig.headers(),upload:e.serverConfig.upload(),download:e.serverConfig.download()},null,8,["item","modelValue","onUpdate:modelValue","currentOperationType","headers","upload","download"])):(g.openBlock(),g.createBlock(U3,{key:1,item:k,modelValue:C.data[k.columnProperty],"onUpdate:modelValue":le=>C.data[k.columnProperty]=le,dropdownOptions:g.unref(c).getDictOptionsByColumnProperty(k.columnProperty)},null,8,["item","modelValue","onUpdate:modelValue","dropdownOptions"]))],64)):(g.openBlock(),g.createElementBlock(g.Fragment,{key:1},[k.showMethod==="slot"?g.renderSlot(G.$slots,"form-"+k.columnProperty,{key:0,item:k,scope:{...G.scope,formData:C.data,data:C.data[k.columnProperty]}},void 0,!0):k.type==="upload"?(g.openBlock(),g.createBlock(Ws,{key:1,item:k,modelValue:C.data[k.columnProperty],"onUpdate:modelValue":le=>C.data[k.columnProperty]=le,currentOperationType:u.value,headers:e.serverConfig.headers(),upload:e.serverConfig.upload(),download:e.serverConfig.download()},null,8,["item","modelValue","onUpdate:modelValue","currentOperationType","headers","upload","download"])):k.type==="editor"?(g.openBlock(),g.createBlock(F3,{key:2,item:k,modelValue:C.data[k.columnProperty],"onUpdate:modelValue":le=>C.data[k.columnProperty]=le,currentOperationType:u.value},null,8,["item","modelValue","onUpdate:modelValue","currentOperationType"])):(g.openBlock(),g.createBlock(ou,{key:3,item:k,modelValue:C.data[k.columnProperty],"onUpdate:modelValue":le=>C.data[k.columnProperty]=le,dropdownOptions:g.unref(c).getDictOptionsByColumnProperty(k.columnProperty),currentOperationType:u.value},null,8,["item","modelValue","onUpdate:modelValue","dropdownOptions","currentOperationType"]))],64))]),_:2},1032,["label","prop"])]),_:2},1032,["span"]))),128))]),_:3})]),_:3})]),_:3})]),_:3},8,["model","rules","label-width","class"])]),_:3},8,["span"]),O.value?(g.openBlock(),g.createBlock(g.unref(B.ElCol),{key:0,span:O.value?O.value.span:0,style:{padding:"0 10px"}},{default:g.withCtx(()=>[w.value?(g.openBlock(),g.createBlock(J3,{key:0,modelValue:C.data.wktstr,"onUpdate:modelValue":j[3]||(j[3]=k=>C.data.wktstr=k),currentOperationType:u.value,mapViewData:e.mapViewData,geomType:p.geomType},null,8,["modelValue","currentOperationType","mapViewData","geomType"])):g.createCommentVNode("",!0)]),_:1},8,["span"])):g.createCommentVNode("",!0)]),_:3})]),_:2},[u.value!=="details"?{name:"footer",fn:g.withCtx(()=>[g.createVNode(g.unref(B.ElButton),{type:"primary",onClick:Y,loading:N.value},{default:g.withCtx(()=>[...j[13]||(j[13]=[g.createTextVNode("确定",-1)])]),_:1},8,["loading"]),g.createVNode(g.unref(B.ElButton),{onClick:j[4]||(j[4]=k=>y.value=!1)},{default:g.withCtx(()=>[...j[14]||(j[14]=[g.createTextVNode("取消",-1)])]),_:1})]),key:"0"}:void 0]),1032,["title","width","modelValue"])],64))}}),qE=Rr(g4,[["__scopeId","data-v-2a77cfe9"]]);qt.CurdForm=qE,qt.default=qE,Object.defineProperties(qt,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
|
|
677
|
+
`)};return(c,d)=>(g.openBlock(),g.createElementBlock("div",null,[g.createVNode(g.unref(B.ElButton),{type:"default",round:"",onClick:d[0]||(d[0]=u=>r.value=!0)},{default:g.withCtx(()=>[g.createVNode(g.unref(B.ElIcon),null,{default:g.withCtx(()=>[g.createVNode(g.unref(nS))]),_:1})]),_:1}),g.createVNode(g.unref(B.ElDialog),{modelValue:r.value,"onUpdate:modelValue":d[4]||(d[4]=u=>r.value=u),title:"导出数据",width:"400px","close-on-click-modal":!1},{footer:g.withCtx(()=>[g.createVNode(g.unref(B.ElButton),{onClick:d[3]||(d[3]=u=>r.value=!1)},{default:g.withCtx(()=>[...d[5]||(d[5]=[g.createTextVNode("取消",-1)])]),_:1}),g.createVNode(g.unref(B.ElButton),{type:"primary",onClick:s},{default:g.withCtx(()=>[...d[6]||(d[6]=[g.createTextVNode("导出",-1)])]),_:1})]),default:g.withCtx(()=>[g.createVNode(g.unref(B.ElForm),{ref_key:"exportFormRef",ref:n,model:i,"label-width":"100px",rules:o},{default:g.withCtx(()=>[g.createVNode(g.unref(B.ElFormItem),{label:"文件名称",prop:"filename"},{default:g.withCtx(()=>[g.createVNode(g.unref(B.ElInput),{modelValue:i.filename,"onUpdate:modelValue":d[1]||(d[1]=u=>i.filename=u),placeholder:"请输入文件名称"},null,8,["modelValue"])]),_:1}),g.createVNode(g.unref(B.ElFormItem),{label:"选择字段"},{default:g.withCtx(()=>[g.createElementVNode("div",e4,[g.createVNode(g.unref(B.ElCheckboxGroup),{modelValue:i.selectedFields,"onUpdate:modelValue":d[2]||(d[2]=u=>i.selectedFields=u)},{default:g.withCtx(()=>[(g.openBlock(!0),g.createElementBlock(g.Fragment,null,g.renderList(a.value,u=>(g.openBlock(),g.createElementBlock("div",{key:u.columnProperty,class:"column-item"},[g.createVNode(g.unref(B.ElCheckbox),{value:u.columnProperty},{default:g.withCtx(()=>[g.createTextVNode(g.toDisplayString(u.columnLabel),1)]),_:2},1032,["value"])]))),128))]),_:1},8,["modelValue"])])]),_:1})]),_:1},8,["model","rules"])]),_:1},8,["modelValue"])]))}}),r4=Rr(n4,[["__scopeId","data-v-551fc665"]]),i4={class:"column-manager"},o4={name:"ColumnManager"},a4=g.defineComponent({...o4,props:{tableColumns:{type:Array,default:()=>({columns:[]})},visibleColumns:{type:Array,default:()=>[]}},emits:["update:visibleColumns","update:columns"],setup(e,{emit:t}){const n=e,r=t,i=g.ref(!1),o=g.ref([...n.visibleColumns]),a=(s,l)=>{l?o.value.push(s):o.value=o.value.filter(c=>c!==s),r("update:visibleColumns",o.value)};return g.watch(()=>n.visibleColumns,s=>{o.value=[...s]},{deep:!0}),(s,l)=>(g.openBlock(),g.createElementBlock("div",null,[g.createVNode(g.unref(B.ElPopover),{visible:i.value,"onUpdate:visible":l[0]||(l[0]=c=>i.value=c),placement:"bottom-end",width:220,trigger:"click","popper-class":"column-manager-popover"},{reference:g.withCtx(()=>[g.createVNode(g.unref(B.ElButton),{type:"default",round:""},{default:g.withCtx(()=>[g.createVNode(g.unref(B.ElIcon),null,{default:g.withCtx(()=>[g.createVNode(g.unref(cS))]),_:1})]),_:1})]),default:g.withCtx(()=>[g.createElementVNode("div",i4,[(g.openBlock(!0),g.createElementBlock(g.Fragment,null,g.renderList(e.tableColumns,c=>(g.openBlock(),g.createElementBlock("div",{class:"column-item",key:c.columnProperty},[g.createVNode(g.unref(B.ElCheckbox),{modelValue:o.value.includes(c.columnProperty),onChange:d=>a(c.columnProperty,d)},{default:g.withCtx(()=>[g.createTextVNode(g.toDisplayString(c.columnLabel||c.columnProperty),1)]),_:2},1032,["modelValue","onChange"])]))),128))])]),_:1},8,["visible"])]))}}),s4=Rr(a4,[["__scopeId","data-v-3bb66278"]]);class l4{serverConfig;curdConfig={};searchConfig={};tableConfig={};editorConfig={};searchFormMap=new Map;cloneSearchForm="{}";cloneFormData="{}";dictionaryMap=new Map;columnMap=new Map;constructor({serverConfig:t}){this.serverConfig=t}setConfig({curdConfig:t,searchConfig:n,tableConfig:r,editorConfig:i}){this.curdConfig=t||this.curdConfig,this.searchConfig=n||this.searchConfig,this.tableConfig=r||this.tableConfig,this.editorConfig=i||this.editorConfig,this.columnMap?.clear(),this.tableConfig?.columns?.forEach(o=>{this.columnMap?.set(o.columnProperty,o)})}async loadDictionary(){if(!this.tableConfig?.columns)return this.dictionaryMap;const t=this.tableConfig.columns.filter(n=>["code","table"].includes(n.dictType||"")&&n.dictService).map(n=>{let r=n.fieldType||"String";return r==="integer"&&(r="Integer"),(n.dictType==="code"?this.serverConfig?.dict({dictCode:n.dictService,itemIdType:r}):this.serverConfig?.dictServer(n.dictService,{key:n.dictionary?.name||""})).then(o=>{o&&n.dictService&&this.dictionaryMap.set(n.dictService,o||[])}).catch(o=>{console.error(`加载字典 ${n.dictService} 失败:`,o)})});return await Promise.all(t),this.dictionaryMap}getDictOptionsByCode(t){return t?this.dictionaryMap.get(t)||[]:[]}getDictOptionsByColumnProperty(t){if(!t)return[];const n=this.tableConfig?.columns?.find(r=>r.columnProperty===t)?.dictService;return this.getDictOptionsByCode(n||void 0)}formatColumnValue(t,n){if(n==null||n==="")return n;if(t.dictType&&t.dictService){const r=this.dictionaryMap.get(t.dictService)||[];if(!r||r.length===0)return n;const i=r.find(o=>o.id===n);return i?i.name:n}if(!t.formatter||t.formatter==="")return n;switch(t.fieldType){case"date":return n?B.dayjs(n).format(t.formatter||"YYYY-MM-DD"):"";case"datetime":return n?B.dayjs(n).format(t.formatter||"YYYY-MM-DD HH:mm:ss"):"";default:return n}}formatFormRules(){const t={};return(this.editorConfig?.columns||[]).forEach(n=>{t[n.columnProperty]=[],n.isRequired&&t[n.columnProperty].push({required:!0,message:"请输入"+n.columnLabel,trigger:"blur"})}),t}formatSearchConfigForm(){this.searchConfig.columns=this.tableConfig?.columns?.filter(n=>n.searchable!="no")||[],this.searchConfig?.columns.forEach(n=>{this.searchFormMap.set(n.columnProperty,n)});const t={};return this.searchConfig?.columns.forEach(n=>{let r=n.searchDefaultValue;r!=null&&r!==""&&(r=this.formatValueByColumnProperty(r,n.columnProperty)),t[n.columnProperty]=r}),this.cloneSearchForm=JSON.stringify(t),t}formatFormConfigData(){const t={};return(this.editorConfig?.columns||[]).filter(r=>r.columnProperty===this.curdConfig?.priKey?!0:r.type!=="hidden").forEach(r=>{let i=r.defaultValue;i!=null&&i!==""&&(i=this.formatValueByColumnProperty(i,r.columnProperty)),t[r.columnProperty]=i}),this.cloneFormData=JSON.stringify(t),t}formatSearchForm(t){const n={};return this.searchFormMap.forEach((r,i)=>{const o=t[i];if(o!=null&&o!==""){let a="";switch(r.searchable){case"=":a=`= '${o}'`;break;case"like":a=`like '%${o}%'`;break;case"in":a=`in (${o})`;break}n[i]=a}}),n}formatFormData(t){if(!t||Object.keys(t).length===0)return{};let n={};return(this.tableConfig?.columns||[]).forEach(r=>{r?.fieldType==="integer"?n[r.columnProperty]=Number(t[r.columnProperty]):n[r.columnProperty]=t[r.columnProperty]}),t.wktstr&&(n.wktstr=t.wktstr),n}initVisibleColumns(){return(this.tableConfig?.columns||[]).filter(t=>t.showMethod!="hidden").map(t=>t.columnProperty)}getFormItems(t=""){let n=[];switch(t){case"details":n=(this.editorConfig?.columns||[]).filter(r=>r.type!=="hidden"&&r.updateFormStatus!=="hidden"&&r.type!=="shape");break;case"add":n=(this.editorConfig?.columns||[]).filter(r=>r.type!=="hidden"&&r.createFormStatus!=="hidden"&&r.type!=="shape");break;case"update":n=(this.editorConfig?.columns||[]).filter(r=>r.type!=="hidden"&&r.updateFormStatus!=="hidden"&&r.type!=="shape");break}return n}hasGeometryField(){return(this.editorConfig?.columns||[]).find(n=>n.type==="shape")||void 0}formatValueByColumnProperty(t,n){const r=this.columnMap?.get(n);if(!r)return t;switch(r?.fieldType){case"integer":case"float":case"double":case"number":return Number(t);default:return t}}}const c4={class:"curd-container"},d4={class:"curd-search"},u4={key:0,class:"table-actions"},p4={class:"table-actions-left"},m4={class:"table-actions-right"},h4={key:1,class:"curd-pagination"},_4={name:"CurdForm"},g4=g.defineComponent({..._4,props:{size:{type:String,default:"default"},title:{type:String,default:"信息管理"},permissions:{type:Object,default:()=>({add:!1,edit:!1,delete:!1,deleteBatch:!1,export:!1})},serverConfig:{type:Object,default:()=>({init:Function,list:Function,view:Function,add:Function,delete:Function,deleteBatch:Function,update:Function,dict:Function,dictServer:Function,upload:Function,download:Function,headers:Function})},mapViewData:{type:Object,default:()=>({})}},emits:["loadDataSuccess","switchChange"],setup(e,{expose:t,emit:n}){const r=e,i=g.ref(!1),o=g.ref(null),a=g.ref(null),s=n,l=g.ref(),c=new l4({serverConfig:r.serverConfig}),d=g.ref(""),u=g.ref("details"),p=g.reactive({priKey:"id",priKeyType:"string",sortField:"id",sortOrder:0,geomType:"point",webFunction:[],dataExt:"{}"}),m=g.reactive({showIndex:!0,indexWidth:50,showCheckbox:!0,showOperation:!0,operationWidth:120,operationLocation:"right",operationButtons:[],visibleOperationButtons:[],operationAlign:"center",showPagination:!0,defaultPageSize:10,pageUISize:"default",showExpand:!1,columns:[]}),h=g.reactive({total:0,pageSize:m.defaultPageSize,currentPage:1}),_=g.reactive({title:"弹框表单",formDialogWidth:"800px",labelWidth:"120px"}),f=g.reactive({columns:[],formColumns:[]}),b=g.reactive({searchLabelWidth:"80",searchFormWidth:"290",columns:[]}),S=g.ref({}),y=g.ref(!1),E=g.ref([]),C=g.reactive({data:{}}),v=g.ref({}),N=g.ref(!1),w=g.ref(!1),O=g.ref(),L=g.ref([]),H=async()=>{if(r.serverConfig?.list)try{i.value=!0;const G=await r.serverConfig?.list({whereClause:c.formatSearchForm(S.value),orderParam:[{fieldName:p.sortField,asc:p.sortOrder===0}],pageParam:{pageNum:h.currentPage,pageSize:h.pageSize}});if(G){const j=G.data;E.value=j.dataList||[],h.total=j.totalCount,s("loadDataSuccess",E.value)}}catch{}finally{i.value=!1}},V=()=>{S.value=JSON.parse(c.cloneSearchForm),H()},q=async()=>{r.serverConfig?.add&&(u.value="add",f.formColumns=c.getFormItems("add"),_.title="新增信息",y.value=!0,C.data=JSON.parse(c.cloneFormData))},K=async()=>{if(r.serverConfig?.deleteBatch&&a?.value){const G=a.value.getSelectionRows();if(G.length===0){B.ElMessage.warning("请选择要删除的项");return}const j=G.map(k=>k[p.priKey||"id"]);j.length>0&&B.ElMessageBox.confirm("确定删除选中项吗?","提示",{confirmButtonText:"确定",cancelButtonText:"取消",type:"warning"}).then(async()=>{await r.serverConfig?.deleteBatch?.(j.join(","))?B.ElMessage.success("删除成功"):B.ElMessage.error("删除失败"),H()})}},Q=G=>{h.pageSize=Number(G),H()},A=G=>{h.currentPage=G,H()},T=async G=>{if(r.serverConfig?.view){u.value="details",f.formColumns=c.getFormItems("details"),_.title="查看详情";try{const j=G[p.priKey||"id"];if(!j){B.ElMessage.error("查看失败,未获取到主键值");return}const k=await r.serverConfig?.view?.({key:j});debugger;k.success&&k.data?(C.data={...k.data},y.value=!0):B.ElMessage.error("查询失败")}catch{B.ElMessage.error("查询失败")}}},R=async G=>{r.serverConfig?.update&&(u.value="update",f.formColumns=c.getFormItems("update"),_.title="编辑信息",y.value=!0,C.data={...G})},P=G=>{r.serverConfig?.delete&&B.ElMessageBox.confirm("确定删除选中项吗?","提示",{confirmButtonText:"确定",cancelButtonText:"取消",type:"warning"}).then(async()=>{const j=G[p.priKey||"id"];if(!j){B.ElMessage.error("删除失败,未获取到主键值");return}await r.serverConfig?.delete?.(j)?(B.ElMessage.success("删除成功"),H()):B.ElMessage.error("删除失败")})},Y=()=>{N.value=!0,l.value?.validate(async(G,j)=>{if(G){let k=u.value==="add"?r.serverConfig?.add:r.serverConfig?.update;if(k)try{const le=await k({params:{...c.formatFormData(C.data)}});le.success?(B.ElMessage.success(u.value==="add"?"新增成功":"编辑成功"),y.value=!1,H()):B.ElMessage.error("保存失败"+le.msg)}catch(le){B.ElMessage.error("保存失败"+le.message)}finally{N.value=!1}}else N.value=!1})},X=G=>{s("switchChange",G)};g.onMounted(async()=>{if(r.serverConfig?.init){const G=await r.serverConfig.init();if(G.success&&G.data){const j=G.data||{},k=j.dataExt?JSON.parse(j.dataExt):{};Object.assign(p,j||{}),Object.assign(m,k?.tableConfig||{}),Object.assign(_,k?.dialogConfig||{}),Object.assign(f?.columns||[],k?.editorConfig||{}),h.pageSize=m.defaultPageSize||h.pageSize,m.visibleOperationButtons=(m.operationButtons||[]).map(le=>le.type),console.log("curdConfig",p),console.log("tableConfig",m),console.log("dialogConfig",_),console.log("editorConfig",f),b.searchFormWidth=m.searchFormWidth&&m.searchFormWidth!==""?m.searchFormWidth:b.searchFormWidth,b.searchLabelWidth=m.searchLabelWidth&&m.searchLabelWidth!==""?m.searchLabelWidth:b.searchLabelWidth,c.setConfig({curdConfig:p,searchConfig:b,tableConfig:m,editorConfig:f}),await c.loadDictionary(),L.value=c.initVisibleColumns(),S.value=c.formatSearchConfigForm(),C.data=c.formatFormConfigData(),v.value=c.formatFormRules(),O.value=c.hasGeometryField(),await c.loadDictionary(),requestAnimationFrame(()=>{d.value=o.value?.clientHeight+"px"}),setTimeout(()=>{H()},500)}else B.ElMessage.error("未查询到有效配置")}else B.ElMessage.error("请配置init方法");window.addEventListener("resize",se)});const se=()=>{d.value="100px",requestAnimationFrame(()=>{d.value=o.value?.clientHeight+"px"})};g.onUnmounted(()=>{window.removeEventListener("resize",se)}),g.watch(y,G=>{G?g.nextTick(()=>{w.value=!0}):w.value=!1});const Ce=G=>{E.value=G},Se=G=>{m.columns=G};return t({setTableData:Ce,getTableData:()=>E.value}),(G,j)=>(g.openBlock(),g.createElementBlock(g.Fragment,null,[g.createElementVNode("div",c4,[g.createElementVNode("div",d4,[g.createVNode(g.unref(B.ElForm),{inline:!0,class:"form-inline","label-width":b.searchLabelWidth},{default:g.withCtx(()=>[(g.openBlock(!0),g.createElementBlock(g.Fragment,null,g.renderList(b.columns,k=>(g.openBlock(),g.createBlock(g.unref(B.ElFormItem),{key:k.columnProperty,label:k.searchFormLabel||k.columnLabel,style:g.normalizeStyle(`width: ${b.searchFormWidth}px;`)},{default:g.withCtx(()=>[k.showMethod==="slot"?g.renderSlot(G.$slots,"search-"+k.columnProperty,{key:0,scope:{...G.scope,searchForm:S.value,data:S.value[k.columnProperty]}},void 0,!0):(g.openBlock(),g.createBlock(ou,{key:1,modelValue:S.value[k.columnProperty],"onUpdate:modelValue":le=>S.value[k.columnProperty]=le,item:k,dropdownOptions:g.unref(c).getDictOptionsByCode(k.dictService)},null,8,["modelValue","onUpdate:modelValue","item","dropdownOptions"]))]),_:2},1032,["label","style"]))),128)),g.createVNode(g.unref(B.ElFormItem),{style:{"margin-left":"10px"}},{default:g.withCtx(()=>[g.createVNode(g.unref(B.ElButton),{type:"primary",size:e.size,icon:"Search",onClick:H},{default:g.withCtx(()=>[...j[6]||(j[6]=[g.createTextVNode("查询",-1)])]),_:1},8,["size"]),g.createVNode(g.unref(B.ElButton),{type:"default",size:e.size,icon:"Refresh",onClick:V},{default:g.withCtx(()=>[...j[7]||(j[7]=[g.createTextVNode("重置",-1)])]),_:1},8,["size"])]),_:1})]),_:3},8,["label-width"])]),p.webFunction.length>0?(g.openBlock(),g.createElementBlock("div",u4,[g.createElementVNode("div",p4,[e.permissions.add&&p.webFunction.includes("add")?(g.openBlock(),g.createBlock(g.unref(B.ElButton),{key:0,type:"primary",size:e.size,icon:"CirclePlus",onClick:q},{default:g.withCtx(()=>[...j[8]||(j[8]=[g.createTextVNode("新增",-1)])]),_:1},8,["size"])):g.createCommentVNode("",!0),e.permissions.delete&&p.webFunction.includes("batchDelete")?(g.openBlock(),g.createBlock(g.unref(B.ElButton),{key:1,type:"danger",size:e.size,icon:"Delete",onClick:K},{default:g.withCtx(()=>[...j[9]||(j[9]=[g.createTextVNode("批量删除",-1)])]),_:1},8,["size"])):g.createCommentVNode("",!0),g.renderSlot(G.$slots,"table-actions",{},void 0,!0)]),g.createElementVNode("div",m4,[g.renderSlot(G.$slots,"table-actions-right",{},void 0,!0),p.webFunction.includes("export")?(g.openBlock(),g.createBlock(r4,{key:0,columns:m.columns,"visible-columns":L.value,data:E.value},null,8,["columns","visible-columns","data"])):g.createCommentVNode("",!0),g.createVNode(s4,{"table-columns":m.columns,"visible-columns":L.value,"onUpdate:visibleColumns":j[0]||(j[0]=k=>L.value=k),"onUpdate:columns":Se},null,8,["table-columns","visible-columns"])])])):g.createCommentVNode("",!0),g.createElementVNode("div",{ref_key:"curdTableContainerRef",ref:o,class:"curd-table"},[g.createVNode(g.unref(B.ElTable),{ref_key:"tableRef",ref:a,data:E.value,border:"",stripe:"",size:e.size,height:d.value,"header-cell-style":{background:"#F5F7FA"}},{default:g.withCtx(()=>[m.showIndex?(g.openBlock(),g.createBlock(g.unref(B.ElTableColumn),{key:0,type:"index",width:m.indexWidth,label:"#",align:"center"},null,8,["width"])):g.createCommentVNode("",!0),e.permissions.delete&&p.webFunction.includes("batchDelete")?(g.openBlock(),g.createBlock(g.unref(B.ElTableColumn),{key:1,type:"selection",width:"55",align:"center"})):g.createCommentVNode("",!0),(g.openBlock(!0),g.createElementBlock(g.Fragment,null,g.renderList(m.columns,k=>(g.openBlock(),g.createElementBlock(g.Fragment,{key:k.prop},[L.value.includes(k.columnProperty)?(g.openBlock(),g.createBlock(g.unref(B.ElTableColumn),{key:0,label:k.columnLabel,width:(k.width||"")+"px",fixed:k.fixed,"show-overflow-tooltip":k.noWrap,align:k.align,"header-align":k.headerAlign},{default:g.withCtx(le=>[k.showMethod==="slot"?g.renderSlot(G.$slots,"table-column-"+k.columnProperty,{key:0,scope:le},void 0,!0):k.showMethod==="upload"?(g.openBlock(),g.createBlock(Ws,{key:1,item:k,modelValue:le.row[k.columnProperty],"onUpdate:modelValue":ot=>le.row[k.columnProperty]=ot,currentOperationType:"column",headers:e.serverConfig.headers(),download:e.serverConfig.download()},null,8,["item","modelValue","onUpdate:modelValue","headers","download"])):k.showMethod==="tag"?(g.openBlock(),g.createBlock(g.unref(B.ElTag),{key:2,type:le?.row[k.columnProperty]===1||le?.row[k.columnProperty]==="1"?"success":k.tagType||"info"},{default:g.withCtx(()=>[g.createTextVNode(g.toDisplayString(g.unref(c).formatColumnValue(k,le?.row[k.columnProperty])),1)]),_:2},1032,["type"])):k.showMethod==="switch"?(g.openBlock(),g.createBlock(g.unref(B.ElSwitch),{key:3,modelValue:le.row[k.columnProperty],"onUpdate:modelValue":ot=>le.row[k.columnProperty]=ot,"active-value":"1","inactive-value":"0","active-text":"是","inactive-text":"否",onChange:ot=>X(le)},null,8,["modelValue","onUpdate:modelValue","onChange"])):(g.openBlock(),g.createElementBlock(g.Fragment,{key:4},[g.createTextVNode(g.toDisplayString(g.unref(c).formatColumnValue(k,le?.row[k.columnProperty])),1)],64))]),_:2},1032,["label","width","fixed","show-overflow-tooltip","align","header-align"])):g.createCommentVNode("",!0)],64))),128)),g.createVNode(g.unref(B.ElTableColumn),{align:m.operationAlign,fixed:"right",width:m.operationWidth,label:"操作"},{default:g.withCtx(k=>[m.visibleOperationButtons.includes("detail")?(g.openBlock(),g.createBlock(g.unref(B.ElButton),{key:0,type:"primary",plain:"",size:m.operationSize,onClick:le=>T(k.row)},{default:g.withCtx(()=>[...j[10]||(j[10]=[g.createTextVNode("详情",-1)])]),_:1},8,["size","onClick"])):g.createCommentVNode("",!0),m.visibleOperationButtons.includes("edit")&&e.permissions.edit?(g.openBlock(),g.createBlock(g.unref(B.ElButton),{key:1,type:"success",plain:"",size:m.operationSize,onClick:le=>R(k.row)},{default:g.withCtx(()=>[...j[11]||(j[11]=[g.createTextVNode("编辑",-1)])]),_:1},8,["size","onClick"])):g.createCommentVNode("",!0),m.visibleOperationButtons.includes("delete")&&e.permissions.delete?(g.openBlock(),g.createBlock(g.unref(B.ElButton),{key:2,type:"danger",plain:"",size:m.operationSize,onClick:le=>P(k.row)},{default:g.withCtx(()=>[...j[12]||(j[12]=[g.createTextVNode("删除",-1)])]),_:1},8,["size","onClick"])):g.createCommentVNode("",!0),g.renderSlot(G.$slots,"table-column-action",{scope:k},void 0,!0)]),_:3},8,["align","width"])]),_:3},8,["data","size","height"])],512),m.showPagination?(g.openBlock(),g.createElementBlock("div",h4,[g.createVNode(g.unref(B.ElPagination),{"current-page":h.currentPage,"onUpdate:currentPage":j[1]||(j[1]=k=>h.currentPage=k),"page-size":h.pageSize,"onUpdate:pageSize":j[2]||(j[2]=k=>h.pageSize=k),total:h.total,layout:"total, sizes, prev, pager, next",background:"",size:e.size,onSizeChange:Q,onCurrentChange:A},null,8,["current-page","page-size","total","size"])])):g.createCommentVNode("",!0)]),g.createVNode(g.unref(B.ElDialog),{title:_.title,"close-on-click-modal":!1,"close-on-press-escape":!1,width:_.formDialogWidth,modelValue:y.value,"onUpdate:modelValue":j[5]||(j[5]=k=>y.value=k),"destroy-on-close":!0,draggable:"","append-to-body":!0,"align-center":""},g.createSlots({default:g.withCtx(()=>[g.createVNode(g.unref(B.ElRow),null,{default:g.withCtx(()=>[g.createVNode(g.unref(B.ElCol),{span:O.value?24-O.value.span:24},{default:g.withCtx(()=>[g.createVNode(g.unref(B.ElForm),{ref_key:"formRef",ref:l,model:C.data,rules:v.value,size:"default","label-width":_.labelWidth,"label-suffix":":",class:g.normalizeClass({"curd-form-details":u.value==="details"})},{default:g.withCtx(()=>[g.createVNode(g.unref(B.ElRow),null,{default:g.withCtx(()=>[g.createVNode(g.unref(B.ElCol),{span:24},{default:g.withCtx(()=>[g.createVNode(g.unref(B.ElRow),null,{default:g.withCtx(()=>[(g.openBlock(!0),g.createElementBlock(g.Fragment,null,g.renderList(f.formColumns,k=>(g.openBlock(),g.createBlock(g.unref(B.ElCol),{key:k.columnProperty,span:k.span||12},{default:g.withCtx(()=>[g.createVNode(g.unref(B.ElFormItem),{label:k.columnLabel,prop:k.columnProperty},{default:g.withCtx(()=>[u.value==="details"?(g.openBlock(),g.createElementBlock(g.Fragment,{key:0},[k.type==="upload"?(g.openBlock(),g.createBlock(Ws,{key:0,item:k,modelValue:C.data[k.columnProperty],"onUpdate:modelValue":le=>C.data[k.columnProperty]=le,currentOperationType:u.value,headers:e.serverConfig.headers(),upload:e.serverConfig.upload(),download:e.serverConfig.download()},null,8,["item","modelValue","onUpdate:modelValue","currentOperationType","headers","upload","download"])):(g.openBlock(),g.createBlock(U3,{key:1,item:k,modelValue:C.data[k.columnProperty],"onUpdate:modelValue":le=>C.data[k.columnProperty]=le,dropdownOptions:g.unref(c).getDictOptionsByColumnProperty(k.columnProperty)},null,8,["item","modelValue","onUpdate:modelValue","dropdownOptions"]))],64)):(g.openBlock(),g.createElementBlock(g.Fragment,{key:1},[k.showMethod==="slot"?g.renderSlot(G.$slots,"form-"+k.columnProperty,{key:0,item:k,scope:{...G.scope,formData:C.data,data:C.data[k.columnProperty]}},void 0,!0):k.type==="upload"?(g.openBlock(),g.createBlock(Ws,{key:1,item:k,modelValue:C.data[k.columnProperty],"onUpdate:modelValue":le=>C.data[k.columnProperty]=le,currentOperationType:u.value,headers:e.serverConfig.headers(),upload:e.serverConfig.upload(),download:e.serverConfig.download()},null,8,["item","modelValue","onUpdate:modelValue","currentOperationType","headers","upload","download"])):k.type==="editor"?(g.openBlock(),g.createBlock(F3,{key:2,item:k,modelValue:C.data[k.columnProperty],"onUpdate:modelValue":le=>C.data[k.columnProperty]=le,currentOperationType:u.value},null,8,["item","modelValue","onUpdate:modelValue","currentOperationType"])):(g.openBlock(),g.createBlock(ou,{key:3,item:k,modelValue:C.data[k.columnProperty],"onUpdate:modelValue":le=>C.data[k.columnProperty]=le,dropdownOptions:g.unref(c).getDictOptionsByColumnProperty(k.columnProperty),currentOperationType:u.value},null,8,["item","modelValue","onUpdate:modelValue","dropdownOptions","currentOperationType"]))],64))]),_:2},1032,["label","prop"])]),_:2},1032,["span"]))),128))]),_:3})]),_:3})]),_:3})]),_:3},8,["model","rules","label-width","class"])]),_:3},8,["span"]),O.value?(g.openBlock(),g.createBlock(g.unref(B.ElCol),{key:0,span:O.value?O.value.span:0,style:{padding:"0 10px"}},{default:g.withCtx(()=>[w.value?(g.openBlock(),g.createBlock(J3,{key:0,modelValue:C.data.wktstr,"onUpdate:modelValue":j[3]||(j[3]=k=>C.data.wktstr=k),currentOperationType:u.value,mapViewData:e.mapViewData,geomType:p.geomType},null,8,["modelValue","currentOperationType","mapViewData","geomType"])):g.createCommentVNode("",!0)]),_:1},8,["span"])):g.createCommentVNode("",!0)]),_:3})]),_:2},[u.value!=="details"?{name:"footer",fn:g.withCtx(()=>[g.createVNode(g.unref(B.ElButton),{type:"primary",onClick:Y,loading:N.value},{default:g.withCtx(()=>[...j[13]||(j[13]=[g.createTextVNode("确定",-1)])]),_:1},8,["loading"]),g.createVNode(g.unref(B.ElButton),{onClick:j[4]||(j[4]=k=>y.value=!1)},{default:g.withCtx(()=>[...j[14]||(j[14]=[g.createTextVNode("取消",-1)])]),_:1})]),key:"0"}:void 0]),1032,["title","width","modelValue"])],64))}}),qE=Rr(g4,[["__scopeId","data-v-2a77cfe9"]]);qt.CurdForm=qE,qt.default=qE,Object.defineProperties(qt,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
|