znyg-frontend-common 1.0.77 → 1.0.78

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.
Files changed (29) hide show
  1. package/es/components/znForm/src/components/ZnFormItem.vue2.mjs +2 -2
  2. package/es/components/znForm/src/components/ZnFormItem.vue2.mjs.map +1 -1
  3. package/es/components/znTable/src/index.vue2.mjs +1 -1
  4. package/es/components/znTable/src/index.vue2.mjs.map +1 -1
  5. package/es/components/znTreeFilter/index.d.ts +11 -0
  6. package/es/components/znTreeFilter/src/index.vue.d.ts +11 -0
  7. package/es/components/znTreeFilter/src/index.vue2.mjs +5 -5
  8. package/es/components/znTreeFilter/src/index.vue2.mjs.map +1 -1
  9. package/es/components/znVirtualTable/src/components/SearchForm/index.vue2.mjs +8 -8
  10. package/es/components/znVirtualTable/src/components/SearchForm/index.vue2.mjs.map +1 -1
  11. package/es/components/znVirtualTable/src/index.vue2.mjs +4 -4
  12. package/es/components/znVirtualTable/src/index.vue2.mjs.map +1 -1
  13. package/es/index.mjs +1 -1
  14. package/es/index.mjs.map +1 -1
  15. package/lib/components/znForm/src/components/ZnFormItem.vue2.js +2 -2
  16. package/lib/components/znForm/src/components/ZnFormItem.vue2.js.map +1 -1
  17. package/lib/components/znTable/src/index.vue2.js +1 -1
  18. package/lib/components/znTable/src/index.vue2.js.map +1 -1
  19. package/lib/components/znTreeFilter/index.d.ts +11 -0
  20. package/lib/components/znTreeFilter/src/index.vue.d.ts +11 -0
  21. package/lib/components/znTreeFilter/src/index.vue2.js +4 -4
  22. package/lib/components/znTreeFilter/src/index.vue2.js.map +1 -1
  23. package/lib/components/znVirtualTable/src/components/SearchForm/index.vue2.js +5 -5
  24. package/lib/components/znVirtualTable/src/components/SearchForm/index.vue2.js.map +1 -1
  25. package/lib/components/znVirtualTable/src/index.vue2.js +2 -2
  26. package/lib/components/znVirtualTable/src/index.vue2.js.map +1 -1
  27. package/lib/index.js +1 -1
  28. package/lib/index.js.map +1 -1
  29. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- import{defineComponent as e,useModel as l,computed as t,inject as o,ref as r,unref as n,shallowRef as a,resolveComponent as u,createVNode as s,mergeProps as i,createBlock as d,openBlock as m,normalizeStyle as p,mergeModels as c}from"vue";import"./Tree.vue.mjs";import{hyphenToCamelCase as f,getFormProp as E,setComponentSlots as _,setFormProp as v}from"../helper/index.mjs";import{componentMap as y}from"../helper/componentMap.mjs";import{formEnumMapKey as C,ComponentNameEnum as L}from"../interface/index.mjs";import{useRenderCheckbox as b}from"./useRenderCheckbox.mjs";import{useRenderComponent as h}from"./useRenderComponent.mjs";import{useRenderRadio as R}from"./useRenderRadio.mjs";import{useRenderSelect as V}from"./useRenderSelect.mjs";import{useLocalStorage as g}from"@vueuse/core";import T from"./Tree.vue2.mjs";var D=Object.defineProperty,S=(e,l)=>D(e,"name",{value:l,configurable:!0}),O=e({name:"ZnFormItem",__name:"ZnFormItem",props:c({column:{required:!0},style:{required:!1},isView:{type:Boolean,skipCheck:!0,required:!1,default:!1}},{modelValue:{required:!0},modelModifiers:{}}),emits:["update:modelValue"],setup(e,{expose:c}){const D=e,O=g("znyg",{dictMap:{}}),M=l(e,"modelValue"),j=new Map,w=t((()=>{const{dictCode:e}=D.column;let l=D.column.fieldNames?.label??"label",t=D.column.fieldNames?.value??"value";return e&&(l="name",t="code"),{label:l,value:t,children:D.column.fieldNames?.children??"children",disabled:D.column.fieldNames?.disabled??"disabled"}})),I=o(C,r(new Map)),P=t((()=>D.column.enum)),U=t((()=>{const{useEnumMap:e,enumKey:l,prop:t,el:o,dictCode:r}=D.column,a=n(I),u=n(P);let s;if(r&&O&&O.value?.dictMap&&(s=O.value.dictMap[r]??[]),e)if("function"==typeof e)s=e(a);else{const t=a.get(e);s=t?l?t[l]||[]:t:[]}if(!s)if(Array.isArray(u)&&u.length>0)s=u;else{let e=a.get(t);s=e?f(o)===L.EL_SELECT_V2?e.map((e=>({...e,label:e[n(w).label],value:e[n(w).value]}))):l?e[l]||[]:e:[]}return s||[]})),$=t((()=>{const e=n(w).label,l=n(w).value,t=n(w).children,o=f(D.column?.el);let r=D.column.props??{};const a=`formProps_${o}_${JSON.stringify(r)}_${e}_${l}_${t}`;if(j.has(a))return j.get(a);let u={...r};return o===L.EL_TREE_SELECT&&(u={...u,props:{...u.props,label:e,children:t},nodeKey:l}),o===L.EL_CASCADER&&(u={...u,props:{...u.props,label:e,value:l,children:t}}),o===L.EL_DATE_PICKER&&("datetime"===u.type&&(u={valueFormat:"YYYY-MM-DD HH:mm:ss",...u}),u=(u.type,{valueFormat:"YYYY-MM-DD",...u})),o===L.EL_TIME_PICKER&&(u={valueFormat:"HH:mm:ss",...u}),j.set(a,u),u})),A=t((()=>{const{props:{type:e,isRange:l,placeholder:t,notDefaultPlaceholder:o}={},el:r}=D.column?.props?D.column:{props:{},el:D.column?.el},n=`placeholder_${r}_${e}_${l}_${t}_${o}`;if(j.has(n))return j.get(n);let a;if(!["datetimerange","daterange","monthrange"].includes(e)&&!l||o){a={placeholder:t??(f(r)?.includes(L.EL_INPUT)?"请输入":"请选择")}}else a={rangeSeparator:"至",startPlaceholder:"开始时间",endPlaceholder:"结束时间"};return j.set(n,a),a})),N=t((()=>{const{props:{clearable:e}={},defaultValue:l}=D.column;return e??null==l})),k=S((()=>{const{isDisabled:e}=D.column;if("function"!=typeof e)return e;const l=`isDisabled_${JSON.stringify(n(M))}`;if(j.has(l))return j.get(l);const t=e(n(M));return j.set(l,t),t}),"isDisabled"),{renderComponent:Y}=h(M,$,D.column),{renderSelectOptions:x}=V(),{renderRadioOptions:F}=R(),{renderCheckboxOptions:H}=b(),K=S((()=>{const{column:e}=D;return D.isView&&e.renderInView?e.renderInView({model:n(M),data:E(n(M),e.prop),enumData:n(U)}):e.render({model:n(M),data:E(n(M),e.prop),enumData:n(U)})}),"RenderSlots"),B=a(),q=S((()=>{const{column:e,style:l}=D,{el:o,prop:r,valueFormat:a,slots:d={},props:m}=e,p=f(o)||"",c={..._(d)},C=G(p);C&&(c.default=C);const b=y[p]||u(p),h=t({get:S((()=>E(n(M),r,a)),"get"),set:S((e=>{v(n(M),r,e)}),"set")}),R=S((()=>{const e=h.value;if(p!==L.EL_SELECT||!D.isView)return e;if(m?.multiple){return U.value.filter((l=>e.includes(l[n(w).value]))).map((e=>e[n(w).label])).join(",")}{const l=U.value.find((l=>l[n(w).value]===e));return l?l[n(w).label]:e}}),"getShowValue");return b?
1
+ import{defineComponent as e,useModel as l,computed as t,inject as o,ref as r,unref as n,shallowRef as a,resolveComponent as u,createVNode as s,mergeProps as i,createBlock as d,openBlock as m,normalizeStyle as p,mergeModels as c}from"vue";import"./Tree.vue.mjs";import{hyphenToCamelCase as f,getFormProp as E,setComponentSlots as _,setFormProp as v}from"../helper/index.mjs";import{componentMap as y}from"../helper/componentMap.mjs";import{formEnumMapKey as C,ComponentNameEnum as L}from"../interface/index.mjs";import{useRenderCheckbox as b}from"./useRenderCheckbox.mjs";import{useRenderComponent as h}from"./useRenderComponent.mjs";import{useRenderRadio as R}from"./useRenderRadio.mjs";import{useRenderSelect as g}from"./useRenderSelect.mjs";import{useLocalStorage as V}from"@vueuse/core";import T from"./Tree.vue2.mjs";var S=Object.defineProperty,D=(e,l)=>S(e,"name",{value:l,configurable:!0}),O=e({name:"ZnFormItem",__name:"ZnFormItem",props:c({column:{required:!0},style:{required:!1},isView:{type:Boolean,skipCheck:!0,required:!1,default:!1}},{modelValue:{required:!0},modelModifiers:{}}),emits:["update:modelValue"],setup(e,{expose:c}){const S=e,O=V("znyg",{dictMap:{}}),M=l(e,"modelValue"),j=new Map,w=t((()=>{const{dictCode:e}=S.column;let l=S.column.fieldNames?.label??"label",t=S.column.fieldNames?.value??"value";return e&&(l="name",t="code"),{label:l,value:t,children:S.column.fieldNames?.children??"children",disabled:S.column.fieldNames?.disabled??"disabled"}})),I=o(C,r(new Map)),P=t((()=>S.column.enum)),U=t((()=>{const{useEnumMap:e,enumKey:l,prop:t,el:o,dictCode:r}=S.column,a=n(I),u=n(P);let s;if(r&&O&&O.value?.dictMap&&(s=O.value.dictMap[r?.toString()]??[]),e)if("function"==typeof e)s=e(a);else{const t=a.get(e);s=t?l?t[l]||[]:t:[]}if(!s)if(Array.isArray(u)&&u.length>0)s=u;else{let e=a.get(t);s=e?f(o)===L.EL_SELECT_V2?e.map((e=>({...e,label:e[n(w).label],value:e[n(w).value]}))):l?e[l]||[]:e:[]}return s||[]})),$=t((()=>{const e=n(w).label,l=n(w).value,t=n(w).children,o=f(S.column?.el);let r=S.column.props??{};const a=`formProps_${o}_${JSON.stringify(r)}_${e}_${l}_${t}`;if(j.has(a))return j.get(a);let u={...r};return o===L.EL_TREE_SELECT&&(u={...u,props:{...u.props,label:e,children:t},nodeKey:l}),o===L.EL_CASCADER&&(u={...u,props:{...u.props,label:e,value:l,children:t}}),o===L.EL_DATE_PICKER&&("datetime"===u.type&&(u={valueFormat:"YYYY-MM-DD HH:mm:ss",...u}),u=(u.type,{valueFormat:"YYYY-MM-DD",...u})),o===L.EL_TIME_PICKER&&(u={valueFormat:"HH:mm:ss",...u}),j.set(a,u),u})),A=t((()=>{const{props:{type:e,isRange:l,placeholder:t,notDefaultPlaceholder:o}={},el:r}=S.column?.props?S.column:{props:{},el:S.column?.el},n=`placeholder_${r}_${e}_${l}_${t}_${o}`;if(j.has(n))return j.get(n);let a;if(!["datetimerange","daterange","monthrange"].includes(e)&&!l||o){a={placeholder:t??(f(r)?.includes(L.EL_INPUT)?"请输入":"请选择")}}else a={rangeSeparator:"至",startPlaceholder:"开始时间",endPlaceholder:"结束时间"};return j.set(n,a),a})),N=t((()=>{const{props:{clearable:e}={},defaultValue:l}=S.column;return e??null==l})),k=D((()=>{const{isDisabled:e}=S.column;if("function"!=typeof e)return e;const l=`isDisabled_${JSON.stringify(n(M))}`;if(j.has(l))return j.get(l);const t=e(n(M));return j.set(l,t),t}),"isDisabled"),{renderComponent:Y}=h(M,$,S.column),{renderSelectOptions:x}=g(),{renderRadioOptions:F}=R(),{renderCheckboxOptions:H}=b(),K=D((()=>{const{column:e}=S;return S.isView&&e.renderInView?e.renderInView({model:n(M),data:E(n(M),e.prop),enumData:n(U)}):e.render({model:n(M),data:E(n(M),e.prop),enumData:n(U)})}),"RenderSlots"),B=a(),q=D((()=>{const{column:e,style:l}=S,{el:o,prop:r,valueFormat:a,slots:d={},props:m}=e,p=f(o)||"",c={..._(d)},C=G(p);C&&(c.default=C);const b=y[p]||u(p),h=t({get:D((()=>E(n(M),r,a)),"get"),set:D((e=>{v(n(M),r,e)}),"set")}),R=D((()=>{const e=h.value;if(p!==L.EL_SELECT||!S.isView)return e;if(m?.multiple){return U.value.filter((l=>e.includes(l[n(w).value]))).map((e=>e[n(w).label])).join(",")}{const l=U.value.find((l=>l[n(w).value]===e));return l?l[n(w).label]:e}}),"getShowValue");return b?
2
2
  // EP 上传组件绑定的是 v-model:file-list 而不是 v-model
3
- p===L.EL_UPLOAD?s(b,i({"file-list":h.value,"onUpdate:file-list":S((e=>h.value=e),"onUpdate:file-list"),ref:B,disabled:k(),clearable:n(N)},n($),n(A),{style:l}),c):D.isView?s("span",null,[R()]):s(b,i({modelValue:h.value,"onUpdate:modelValue":S((e=>h.value=e),"onUpdate:modelValue"),ref:B,disabled:k(),clearable:n(N)},n($),n(A),{data:p===L.EL_TREE_SELECT?n(U):[],options:[L.EL_CASCADER,L.EL_SELECT_V2].includes(p)?n(U):[],style:l}),c):void 0}),"RenderElComponents"),G=S((e=>{const{column:l}=D,{slots:t={}}=l;return t.default?()=>t.default(n(U),n(w)):e===L.EL_SELECT?()=>x(n(U),n(w)):[L.EL_RADIO_GROUP,L.EL_RADIO_BUTTON].includes(e)?()=>F(n(U),n(w),l):[L.EL_CHECKBOX_GROUP,L.EL_CHECKBOX_BUTTON].includes(e)?()=>H(n(U),n(w),l):e===L.EL_SELECT_V2&&t.default?({item:e})=>t.default(e):void 0}),"getDefaultSlot");return c({formComponentRef:B}),(l,t)=>e.column?.render||e.isView&&e.column.renderInView?(m(),d(K,{key:0,style:p(e.style)},null,8,["style"])):n(f)(e.column.el)===n(L).EL_TREE?(m(),d(T,i({key:1,data:U.value,"model-value":n(E)(M.value,e.column.prop),"onUpdate:modelValue":t[0]||(t[0]=l=>n(v)(M.value,e.column.prop,l))},{...$.value}),null,16,["data","model-value"])):n(f)(e.column.el)?.startsWith("El")?(m(),d(q,{key:2})):(m(),d(n(Y),{key:3,style:p(e.style)},null,8,["style"]))}});export{O as default};
3
+ p===L.EL_UPLOAD?s(b,i({"file-list":h.value,"onUpdate:file-list":D((e=>h.value=e),"onUpdate:file-list"),ref:B,disabled:k(),clearable:n(N)},n($),n(A),{style:l}),c):S.isView?s("span",null,[R()]):s(b,i({modelValue:h.value,"onUpdate:modelValue":D((e=>h.value=e),"onUpdate:modelValue"),ref:B,disabled:k(),clearable:n(N)},n($),n(A),{data:p===L.EL_TREE_SELECT?n(U):[],options:[L.EL_CASCADER,L.EL_SELECT_V2].includes(p)?n(U):[],style:l}),c):void 0}),"RenderElComponents"),G=D((e=>{const{column:l}=S,{slots:t={}}=l;return t.default?()=>t.default(n(U),n(w)):e===L.EL_SELECT?()=>x(n(U),n(w)):[L.EL_RADIO_GROUP,L.EL_RADIO_BUTTON].includes(e)?()=>F(n(U),n(w),l):[L.EL_CHECKBOX_GROUP,L.EL_CHECKBOX_BUTTON].includes(e)?()=>H(n(U),n(w),l):e===L.EL_SELECT_V2&&t.default?({item:e})=>t.default(e):void 0}),"getDefaultSlot");return c({formComponentRef:B}),(l,t)=>e.column?.render||e.isView&&e.column.renderInView?(m(),d(K,{key:0,style:p(e.style)},null,8,["style"])):n(f)(e.column.el)===n(L).EL_TREE?(m(),d(T,i({key:1,data:U.value,"model-value":n(E)(M.value,e.column.prop),"onUpdate:modelValue":t[0]||(t[0]=l=>n(v)(M.value,e.column.prop,l))},{...$.value}),null,16,["data","model-value"])):n(f)(e.column.el)?.startsWith("El")?(m(),d(q,{key:2})):(m(),d(n(Y),{key:3,style:p(e.style)},null,8,["style"]))}});export{O as default};
4
4
  //# sourceMappingURL=ZnFormItem.vue2.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"ZnFormItem.vue2.mjs","sources":["../../../../../../../packages/components/znForm/src/components/ZnFormItem.vue"],"sourcesContent":["<template>\n <RenderSlots v-if=\"column?.render || (isView && column.renderInView)\" :style=\"style\" />\n\n <Tree\n v-else-if=\"hyphenToCamelCase(column.el) === ComponentNameEnum.EL_TREE\"\n :data=\"columnEnum\"\n :model-value=\"getFormProp(model, column.prop)\"\n @update:model-value=\"(v) => setFormProp(model, column.prop, v)\"\n v-bind=\"{ ...formProps }\" />\n\n <RenderElComponents v-else-if=\"hyphenToCamelCase(column.el)?.startsWith('El')\" />\n\n <RenderComponent v-else :style=\"style\" />\n</template>\n\n<script setup lang=\"tsx\">\n import { computed, inject, markRaw, ref, resolveComponent, unref, Ref, shallowRef, nextTick } from 'vue'\n\n import Tree from './Tree.vue'\n\n import { getFormProp, hyphenToCamelCase, setComponentSlots, setFormProp } from '../helper'\n import { componentMap } from '../helper/componentMap'\n import { ComponentNameEnum, formEnumMapKey, type ZnFormSchemaProps, type PascalCaseComponentName } from '../interface'\n import { useRenderCheckbox } from './useRenderCheckbox'\n import { useRenderComponent } from './useRenderComponent'\n import { useRenderRadio } from './useRenderRadio'\n import { useRenderSelect } from './useRenderSelect'\n import type { Component, defineComponent } from 'vue'\n import { useLocalStorage } from '@vueuse/core'\n\n defineOptions({ name: 'ZnFormItem' })\n\n interface ZnFormItemProps {\n column: ZnFormSchemaProps\n style?: CSSStyleDeclaration\n isView?: boolean | Ref<boolean>\n }\n\n const props = defineProps({\n column: { required: true },\n style: { required: false },\n isView: { type: Boolean, skipCheck: true, required: false, default: false }\n})\n const znygStore = useLocalStorage('znyg', { dictMap: {} })\n\n const model = defineModel<Record<string, any>>({ required: true })\n\n // 缓存计算结果\n const cachedResults = new Map()\n\n // 判断 fieldNames 设置 label && value && children 的 key 值\n const fieldNames = computed(() => {\n const { dictCode } = props.column\n let label = props.column.fieldNames?.label ?? 'label'\n let value = props.column.fieldNames?.value ?? 'value'\n if (dictCode) {\n label = 'name'\n value = 'code'\n }\n\n return {\n label: label,\n value: value,\n children: props.column.fieldNames?.children ?? 'children',\n disabled: props.column.fieldNames?.disabled ?? 'disabled'\n }\n })\n\n // 接收 enumMap (el 为 select-v 2 需单独处理 enumData)\n const enumMap = inject(formEnumMapKey, ref(new Map()))\n\n // 添加对column.enum的直接引用,提高响应性\n const rawEnum = computed(() => props.column.enum)\n\n const columnEnum = computed(() => {\n const { useEnumMap, enumKey, prop, el, dictCode } = props.column\n\n // 确保从enumMap获取最新数据\n const currentEnumMap = unref(enumMap)\n\n // 通过获取原始enum来确保依赖收集\n const currentRawEnum = unref(rawEnum)\n\n let result\n if (dictCode) {\n // 如果存在dictCode,则直接从字典中获取\n if (znygStore && znygStore.value?.dictMap) {\n result = znygStore.value.dictMap[dictCode] ?? []\n }\n }\n\n if (useEnumMap) {\n if (typeof useEnumMap === 'function') {\n result = useEnumMap(currentEnumMap)\n } else {\n const data = currentEnumMap.get(useEnumMap)\n if (!data) {\n result = []\n } else if (enumKey) {\n result = data[enumKey] || []\n } else {\n result = data\n }\n }\n }\n\n if (!result) {\n // 如果直接的enum是数组且不为空,优先使用它\n if (Array.isArray(currentRawEnum) && currentRawEnum.length > 0) {\n result = currentRawEnum\n } else {\n // 否则从enumMap中获取\n let enumData = currentEnumMap.get(prop)\n\n if (!enumData) {\n result = []\n } else if (hyphenToCamelCase(el) === ComponentNameEnum.EL_SELECT_V2) {\n result = enumData.map((item: Record<string, any>) => {\n return { ...item, label: item[unref(fieldNames).label], value: item[unref(fieldNames).value] }\n })\n } else if (enumKey) {\n result = enumData[enumKey] || []\n } else {\n result = enumData\n }\n }\n }\n\n return result || []\n })\n\n // 处理透传的 formProps (el 为 tree-select、cascader 的时候需要给下默认 label && value && children)\n const formProps = computed(() => {\n const label = unref(fieldNames).label\n const value = unref(fieldNames).value\n const children = unref(fieldNames).children\n const formEl = hyphenToCamelCase(props.column?.el)\n let formProps = props.column.props ?? {}\n\n // 创建缓存键\n const cacheKey = `formProps_${formEl}_${JSON.stringify(formProps)}_${label}_${value}_${children}`\n\n // 检查缓存\n if (cachedResults.has(cacheKey)) {\n return cachedResults.get(cacheKey)\n }\n\n let result = { ...formProps }\n if (formEl === ComponentNameEnum.EL_TREE_SELECT) {\n result = { ...result, props: { ...result.props, label, children }, nodeKey: value }\n }\n\n if (formEl === ComponentNameEnum.EL_CASCADER) {\n result = { ...result, props: { ...result.props, label, value, children } }\n }\n\n if (formEl === ComponentNameEnum.EL_DATE_PICKER) {\n if (result.type === 'datetime') result = { valueFormat: 'YYYY-MM-DD HH:mm:ss', ...result }\n if (result.type === 'date') result = { valueFormat: 'YYYY-MM-DD', ...result }\n else result = { valueFormat: 'YYYY-MM-DD', ...result }\n }\n\n if (formEl === ComponentNameEnum.EL_TIME_PICKER) result = { valueFormat: 'HH:mm:ss', ...result }\n\n // 缓存结果\n cachedResults.set(cacheKey, result)\n return result\n })\n\n // 处理默认 placeholder\n const placeholder = computed(() => {\n const { props: { type, isRange, placeholder, notDefaultPlaceholder } = {}, el } = props.column?.props ? props.column : { props: {}, el: props.column?.el }\n\n // 创建缓存键\n const cacheKey = `placeholder_${el}_${type}_${isRange}_${placeholder}_${notDefaultPlaceholder}`\n\n // 检查缓存\n if (cachedResults.has(cacheKey)) {\n return cachedResults.get(cacheKey)\n }\n\n let result\n if ((['datetimerange', 'daterange', 'monthrange'].includes(type) || isRange) && !notDefaultPlaceholder) {\n result = { rangeSeparator: '至', startPlaceholder: '开始时间', endPlaceholder: '结束时间' }\n } else {\n const placeholderConst = placeholder ?? (hyphenToCamelCase(el)?.includes(ComponentNameEnum.EL_INPUT) ? '请输入' : '请选择')\n result = { placeholder: placeholderConst }\n }\n\n // 缓存结果\n cachedResults.set(cacheKey, result)\n return result\n })\n\n // 是否有清除按钮 (当有默认值时,清除按钮不显示)\n const clearable = computed(() => {\n const { props: { clearable } = {}, defaultValue } = props.column\n return clearable ?? (defaultValue === null || defaultValue === undefined)\n })\n\n // 是否禁用 - 缓存结果提高性能\n const isDisabled = () => {\n const { isDisabled } = props.column\n if (typeof isDisabled !== 'function') return isDisabled\n\n // 创建缓存键\n const cacheKey = `isDisabled_${JSON.stringify(unref(model))}`\n\n // 检查缓存\n if (cachedResults.has(cacheKey)) {\n return cachedResults.get(cacheKey)\n }\n\n const result = isDisabled(unref(model))\n cachedResults.set(cacheKey, result)\n return result\n }\n\n const { renderComponent: RenderComponent } = useRenderComponent(model, formProps, props.column)\n const { renderSelectOptions } = useRenderSelect()\n const { renderRadioOptions } = useRenderRadio()\n const { renderCheckboxOptions } = useRenderCheckbox()\n\n // 渲染插槽\n const RenderSlots = () => {\n const { column } = props\n return props.isView && column.renderInView\n ? column.renderInView!({\n model: unref(model),\n data: getFormProp(unref(model), column.prop),\n enumData: unref(columnEnum)\n })\n : column.render!({\n model: unref(model),\n data: getFormProp(unref(model), column.prop),\n enumData: unref(columnEnum)\n })\n }\n\n // 存储组件实例\n const formComponentRef = shallowRef<Component | any>()\n\n // 渲染 Element Plus 的组件\n const RenderElComponents = () => {\n const { column, style } = props\n const { el, prop, valueFormat, slots = {}, props: columnProps } = column\n\n const rootEl = hyphenToCamelCase(el) || ''\n\n // 初始化组件的插槽(如果有自定义插槽)\n const slotsMap = { ...setComponentSlots(slots) }\n // 获取 default 默认插槽\n const defaultSlot = getDefaultSlot(rootEl)\n\n defaultSlot && (slotsMap.default = defaultSlot)\n\n // TSX 不能直接使用 Vue3 内置组件 <component></component>,因此通过内置 resolveComponent 函数获取\n const Component = (componentMap[rootEl as PascalCaseComponentName] as ReturnType<typeof defineComponent>) || resolveComponent(rootEl)\n\n const componentModel = computed({\n get: () => {\n return getFormProp(unref(model), prop, valueFormat)\n },\n set: (val) => {\n setFormProp(unref(model), prop, val)\n }\n })\n\n // 计算要显示的值\n const getShowValue = () => {\n const val = componentModel.value\n if (rootEl !== ComponentNameEnum.EL_SELECT || !props.isView) return val\n\n if (columnProps?.multiple) {\n // 多选下拉框\n const selectedItemList = columnEnum.value.filter((_) => val.includes(_[unref(fieldNames).value]))\n return selectedItemList.map((_) => _[unref(fieldNames).label]).join(',')\n } else {\n const selectedItem = columnEnum.value.find((_) => _[unref(fieldNames).value] === val)\n return selectedItem ? selectedItem[unref(fieldNames).label] : val\n }\n }\n\n return Component ? (\n // EP 上传组件绑定的是 v-model:file-list 而不是 v-model\n rootEl === ComponentNameEnum.EL_UPLOAD ? (\n <Component\n v-model:file-list={componentModel.value}\n ref={formComponentRef}\n disabled={isDisabled()}\n clearable={unref(clearable)}\n {...unref(formProps)}\n {...unref(placeholder)}\n style={style}\n v-slots={slotsMap} />\n ) : props.isView ? (\n <span>{getShowValue()}</span>\n ) : (\n <Component\n v-model={componentModel.value}\n ref={formComponentRef}\n disabled={isDisabled()}\n clearable={unref(clearable)}\n {...unref(formProps)}\n {...unref(placeholder)}\n data={rootEl === ComponentNameEnum.EL_TREE_SELECT ? unref(columnEnum) : []}\n options={[ComponentNameEnum.EL_CASCADER, ComponentNameEnum.EL_SELECT_V2].includes(rootEl as ComponentNameEnum) ? unref(columnEnum) : []}\n style={style}\n v-slots={slotsMap} />\n )\n ) : undefined\n }\n\n const getDefaultSlot = (rootEl: string) => {\n const { column } = props\n const { slots = {} } = column\n\n // 如果自定义插槽,则返回自定义插槽\n if (slots.default) return () => slots.default(unref(columnEnum), unref(fieldNames))\n\n // 下拉框\n if (rootEl === ComponentNameEnum.EL_SELECT) return () => renderSelectOptions(unref(columnEnum), unref(fieldNames))\n\n // 单选框组和按钮样式\n if ([ComponentNameEnum.EL_RADIO_GROUP, ComponentNameEnum.EL_RADIO_BUTTON].includes(rootEl as ComponentNameEnum)) {\n return () => renderRadioOptions(unref(columnEnum), unref(fieldNames), column)\n }\n\n // 多选框组和按钮样式\n if ([ComponentNameEnum.EL_CHECKBOX_GROUP, ComponentNameEnum.EL_CHECKBOX_BUTTON].includes(rootEl as ComponentNameEnum)) {\n return () => renderCheckboxOptions(unref(columnEnum), unref(fieldNames), column)\n }\n\n // 虚拟列表\n if (rootEl === ComponentNameEnum.EL_SELECT_V2 && slots.default) return ({ item }) => slots.default(item)\n }\n\n defineExpose({\n formComponentRef\n })\n</script>\n"],"names":["props","__props","znygStore","useLocalStorage","dictMap","model","_useModel","cachedResults","Map","fieldNames","computed","dictCode","column","label","value","children","disabled","enumMap","inject","formEnumMapKey","ref","rawEnum","enum","columnEnum","useEnumMap","enumKey","prop","el","currentEnumMap","unref","currentRawEnum","result","data","get","Array","isArray","length","enumData","hyphenToCamelCase","ComponentNameEnum","EL_SELECT_V2","map","item","formProps","formEl","cacheKey","JSON","stringify","has","EL_TREE_SELECT","nodeKey","EL_CASCADER","EL_DATE_PICKER","type","valueFormat","EL_TIME_PICKER","set","placeholder","isRange","notDefaultPlaceholder","includes","EL_INPUT","rangeSeparator","startPlaceholder","endPlaceholder","clearable","defaultValue","undefined","isDisabled","__name","renderComponent","RenderComponent","useRenderComponent","renderSelectOptions","useRenderSelect","renderRadioOptions","useRenderRadio","renderCheckboxOptions","useRenderCheckbox","RenderSlots","isView","renderInView","getFormProp","render","formComponentRef","shallowRef","RenderElComponents","style","slots","columnProps","rootEl","slotsMap","setComponentSlots","defaultSlot","getDefaultSlot","default","Component","componentMap","resolveComponent","componentModel","val","setFormProp","getShowValue","EL_SELECT","multiple","selectedItemList","filter","_","join","selectedItem","find","EL_UPLOAD","_createVNode","_mergeProps2","$event","modelValue","options","EL_RADIO_GROUP","EL_RADIO_BUTTON","EL_CHECKBOX_GROUP","EL_CHECKBOX_BUTTON","__expose"],"mappings":"snCAsCE,MAAMA,EAAQC,EAKRC,EAAYC,EAAgB,OAAQ,CAAEC,QAAS,CAAA,IAE/CC,EAAQC,EAAmDL,EAAA,cAG3DM,MAAoBC,IAGpBC,EAAaC,GAAS,KACpB,MAAAC,SAAEA,GAAaX,EAAMY,OAC3B,IAAIC,EAAQb,EAAMY,OAAOH,YAAYI,OAAS,QAC1CC,EAAQd,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D,EAAkBU,eAAiBpB,EAAMN,GAAc,GAAE6F,QACjE,CAAC7E,EAAkBY,YAAaZ,EAAkBC,cAAcoB,SAAS8B,GAA+B7D,EAAMN,GAAc,GAAEgE,MAChIA,IACEI,QAEXxB,CAAAA,GAnEqBmB,sBAsErBQ,EAAqCzB,GAAAqB,IACnC,MAAA9E,OAAEA,GAAWZ,GACbwF,MAAEA,EAAQ,CAAA,GAAO5E,EAGnB4E,OAAAA,EAAMO,QAAgB,IAAMP,EAAMO,QAAQlE,EAAMN,GAAaM,EAAMpB,IAGnEiF,IAAWnD,EAAkBgE,UAAkB,IAAM9B,EAAoB5C,EAAMN,GAAaM,EAAMpB,IAGlG,CAAC8B,EAAkB8E,eAAgB9E,EAAkB+E,iBAAiB1D,SAAS8B,GAC1E,IAAMf,EAAmB9C,EAAMN,GAAaM,EAAMpB,GAAaG,GAIpE,CAAC2B,EAAkBgF,kBAAmBhF,EAAkBiF,oBAAoB5D,SAAS8B,GAChF,IAAMb,EAAsBhD,EAAMN,GAAaM,EAAMpB,GAAaG,GAIvE8E,IAAWnD,EAAkBC,cAAgBgD,EAAMO,QAAgB,EAAGrD,UAAW8C,EAAMO,QAAQrD,QAAnG,CAAuG,GArBjFgD,yBAwBX+B,EAAA,CACXrC"}
1
+ {"version":3,"file":"ZnFormItem.vue2.mjs","sources":["../../../../../../../packages/components/znForm/src/components/ZnFormItem.vue"],"sourcesContent":["<template>\n <RenderSlots v-if=\"column?.render || (isView && column.renderInView)\" :style=\"style\" />\n\n <Tree\n v-else-if=\"hyphenToCamelCase(column.el) === ComponentNameEnum.EL_TREE\"\n :data=\"columnEnum\"\n :model-value=\"getFormProp(model, column.prop)\"\n @update:model-value=\"(v) => setFormProp(model, column.prop, v)\"\n v-bind=\"{ ...formProps }\" />\n\n <RenderElComponents v-else-if=\"hyphenToCamelCase(column.el)?.startsWith('El')\" />\n\n <RenderComponent v-else :style=\"style\" />\n</template>\n\n<script setup lang=\"tsx\">\n import { computed, inject, markRaw, ref, resolveComponent, unref, Ref, shallowRef, nextTick } from 'vue'\n\n import Tree from './Tree.vue'\n\n import { getFormProp, hyphenToCamelCase, setComponentSlots, setFormProp } from '../helper'\n import { componentMap } from '../helper/componentMap'\n import { ComponentNameEnum, formEnumMapKey, type ZnFormSchemaProps, type PascalCaseComponentName } from '../interface'\n import { useRenderCheckbox } from './useRenderCheckbox'\n import { useRenderComponent } from './useRenderComponent'\n import { useRenderRadio } from './useRenderRadio'\n import { useRenderSelect } from './useRenderSelect'\n import type { Component, defineComponent } from 'vue'\n import { useLocalStorage } from '@vueuse/core'\n\n defineOptions({ name: 'ZnFormItem' })\n\n interface ZnFormItemProps {\n column: ZnFormSchemaProps\n style?: CSSStyleDeclaration\n isView?: boolean | Ref<boolean>\n }\n\n const props = defineProps({\n column: { required: true },\n style: { required: false },\n isView: { type: Boolean, skipCheck: true, required: false, default: false }\n})\n const znygStore = useLocalStorage('znyg', { dictMap: {} })\n\n const model = defineModel<Record<string, any>>({ required: true })\n\n // 缓存计算结果\n const cachedResults = new Map()\n\n // 判断 fieldNames 设置 label && value && children 的 key 值\n const fieldNames = computed(() => {\n const { dictCode } = props.column\n let label = props.column.fieldNames?.label ?? 'label'\n let value = props.column.fieldNames?.value ?? 'value'\n if (dictCode) {\n label = 'name'\n value = 'code'\n }\n\n return {\n label: label,\n value: value,\n children: props.column.fieldNames?.children ?? 'children',\n disabled: props.column.fieldNames?.disabled ?? 'disabled'\n }\n })\n\n // 接收 enumMap (el 为 select-v 2 需单独处理 enumData)\n const enumMap = inject(formEnumMapKey, ref(new Map()))\n\n // 添加对column.enum的直接引用,提高响应性\n const rawEnum = computed(() => props.column.enum)\n\n const columnEnum = computed(() => {\n const { useEnumMap, enumKey, prop, el, dictCode } = props.column\n\n // 确保从enumMap获取最新数据\n const currentEnumMap = unref(enumMap)\n\n // 通过获取原始enum来确保依赖收集\n const currentRawEnum = unref(rawEnum)\n\n let result\n if (dictCode) {\n // 如果存在dictCode,则直接从字典中获取\n if (znygStore && znygStore.value?.dictMap) {\n result = znygStore.value.dictMap[dictCode?.toString()] ?? []\n }\n }\n\n if (useEnumMap) {\n if (typeof useEnumMap === 'function') {\n result = useEnumMap(currentEnumMap)\n } else {\n const data = currentEnumMap.get(useEnumMap)\n if (!data) {\n result = []\n } else if (enumKey) {\n result = data[enumKey] || []\n } else {\n result = data\n }\n }\n }\n\n if (!result) {\n // 如果直接的enum是数组且不为空,优先使用它\n if (Array.isArray(currentRawEnum) && currentRawEnum.length > 0) {\n result = currentRawEnum\n } else {\n // 否则从enumMap中获取\n let enumData = currentEnumMap.get(prop)\n\n if (!enumData) {\n result = []\n } else if (hyphenToCamelCase(el) === ComponentNameEnum.EL_SELECT_V2) {\n result = enumData.map((item: Record<string, any>) => {\n return { ...item, label: item[unref(fieldNames).label], value: item[unref(fieldNames).value] }\n })\n } else if (enumKey) {\n result = enumData[enumKey] || []\n } else {\n result = enumData\n }\n }\n }\n\n return result || []\n })\n\n // 处理透传的 formProps (el 为 tree-select、cascader 的时候需要给下默认 label && value && children)\n const formProps = computed(() => {\n const label = unref(fieldNames).label\n const value = unref(fieldNames).value\n const children = unref(fieldNames).children\n const formEl = hyphenToCamelCase(props.column?.el)\n let formProps = props.column.props ?? {}\n\n // 创建缓存键\n const cacheKey = `formProps_${formEl}_${JSON.stringify(formProps)}_${label}_${value}_${children}`\n\n // 检查缓存\n if (cachedResults.has(cacheKey)) {\n return cachedResults.get(cacheKey)\n }\n\n let result = { ...formProps }\n if (formEl === ComponentNameEnum.EL_TREE_SELECT) {\n result = { ...result, props: { ...result.props, label, children }, nodeKey: value }\n }\n\n if (formEl === ComponentNameEnum.EL_CASCADER) {\n result = { ...result, props: { ...result.props, label, value, children } }\n }\n\n if (formEl === ComponentNameEnum.EL_DATE_PICKER) {\n if (result.type === 'datetime') result = { valueFormat: 'YYYY-MM-DD HH:mm:ss', ...result }\n if (result.type === 'date') result = { valueFormat: 'YYYY-MM-DD', ...result }\n else result = { valueFormat: 'YYYY-MM-DD', ...result }\n }\n\n if (formEl === ComponentNameEnum.EL_TIME_PICKER) result = { valueFormat: 'HH:mm:ss', ...result }\n\n // 缓存结果\n cachedResults.set(cacheKey, result)\n return result\n })\n\n // 处理默认 placeholder\n const placeholder = computed(() => {\n const { props: { type, isRange, placeholder, notDefaultPlaceholder } = {}, el } = props.column?.props ? props.column : { props: {}, el: props.column?.el }\n\n // 创建缓存键\n const cacheKey = `placeholder_${el}_${type}_${isRange}_${placeholder}_${notDefaultPlaceholder}`\n\n // 检查缓存\n if (cachedResults.has(cacheKey)) {\n return cachedResults.get(cacheKey)\n }\n\n let result\n if ((['datetimerange', 'daterange', 'monthrange'].includes(type) || isRange) && !notDefaultPlaceholder) {\n result = { rangeSeparator: '至', startPlaceholder: '开始时间', endPlaceholder: '结束时间' }\n } else {\n const placeholderConst = placeholder ?? (hyphenToCamelCase(el)?.includes(ComponentNameEnum.EL_INPUT) ? '请输入' : '请选择')\n result = { placeholder: placeholderConst }\n }\n\n // 缓存结果\n cachedResults.set(cacheKey, result)\n return result\n })\n\n // 是否有清除按钮 (当有默认值时,清除按钮不显示)\n const clearable = computed(() => {\n const { props: { clearable } = {}, defaultValue } = props.column\n return clearable ?? (defaultValue === null || defaultValue === undefined)\n })\n\n // 是否禁用 - 缓存结果提高性能\n const isDisabled = () => {\n const { isDisabled } = props.column\n if (typeof isDisabled !== 'function') return isDisabled\n\n // 创建缓存键\n const cacheKey = `isDisabled_${JSON.stringify(unref(model))}`\n\n // 检查缓存\n if (cachedResults.has(cacheKey)) {\n return cachedResults.get(cacheKey)\n }\n\n const result = isDisabled(unref(model))\n cachedResults.set(cacheKey, result)\n return result\n }\n\n const { renderComponent: RenderComponent } = useRenderComponent(model, formProps, props.column)\n const { renderSelectOptions } = useRenderSelect()\n const { renderRadioOptions } = useRenderRadio()\n const { renderCheckboxOptions } = useRenderCheckbox()\n\n // 渲染插槽\n const RenderSlots = () => {\n const { column } = props\n return props.isView && column.renderInView\n ? column.renderInView!({\n model: unref(model),\n data: getFormProp(unref(model), column.prop),\n enumData: unref(columnEnum)\n })\n : column.render!({\n model: unref(model),\n data: getFormProp(unref(model), column.prop),\n enumData: unref(columnEnum)\n })\n }\n\n // 存储组件实例\n const formComponentRef = shallowRef<Component | any>()\n\n // 渲染 Element Plus 的组件\n const RenderElComponents = () => {\n const { column, style } = props\n const { el, prop, valueFormat, slots = {}, props: columnProps } = column\n\n const rootEl = hyphenToCamelCase(el) || ''\n\n // 初始化组件的插槽(如果有自定义插槽)\n const slotsMap = { ...setComponentSlots(slots) }\n // 获取 default 默认插槽\n const defaultSlot = getDefaultSlot(rootEl)\n\n defaultSlot && (slotsMap.default = defaultSlot)\n\n // TSX 不能直接使用 Vue3 内置组件 <component></component>,因此通过内置 resolveComponent 函数获取\n const Component = (componentMap[rootEl as PascalCaseComponentName] as ReturnType<typeof defineComponent>) || resolveComponent(rootEl)\n\n const componentModel = computed({\n get: () => {\n return getFormProp(unref(model), prop, valueFormat)\n },\n set: (val) => {\n setFormProp(unref(model), prop, val)\n }\n })\n\n // 计算要显示的值\n const getShowValue = () => {\n const val = componentModel.value\n if (rootEl !== ComponentNameEnum.EL_SELECT || !props.isView) return val\n\n if (columnProps?.multiple) {\n // 多选下拉框\n const selectedItemList = columnEnum.value.filter((_) => val.includes(_[unref(fieldNames).value]))\n return selectedItemList.map((_) => _[unref(fieldNames).label]).join(',')\n } else {\n const selectedItem = columnEnum.value.find((_) => _[unref(fieldNames).value] === val)\n return selectedItem ? selectedItem[unref(fieldNames).label] : val\n }\n }\n\n return Component ? (\n // EP 上传组件绑定的是 v-model:file-list 而不是 v-model\n rootEl === ComponentNameEnum.EL_UPLOAD ? (\n <Component\n v-model:file-list={componentModel.value}\n ref={formComponentRef}\n disabled={isDisabled()}\n clearable={unref(clearable)}\n {...unref(formProps)}\n {...unref(placeholder)}\n style={style}\n v-slots={slotsMap} />\n ) : props.isView ? (\n <span>{getShowValue()}</span>\n ) : (\n <Component\n v-model={componentModel.value}\n ref={formComponentRef}\n disabled={isDisabled()}\n clearable={unref(clearable)}\n {...unref(formProps)}\n {...unref(placeholder)}\n data={rootEl === ComponentNameEnum.EL_TREE_SELECT ? unref(columnEnum) : []}\n options={[ComponentNameEnum.EL_CASCADER, ComponentNameEnum.EL_SELECT_V2].includes(rootEl as ComponentNameEnum) ? unref(columnEnum) : []}\n style={style}\n v-slots={slotsMap} />\n )\n ) : undefined\n }\n\n const getDefaultSlot = (rootEl: string) => {\n const { column } = props\n const { slots = {} } = column\n\n // 如果自定义插槽,则返回自定义插槽\n if (slots.default) return () => slots.default(unref(columnEnum), unref(fieldNames))\n\n // 下拉框\n if (rootEl === ComponentNameEnum.EL_SELECT) return () => renderSelectOptions(unref(columnEnum), unref(fieldNames))\n\n // 单选框组和按钮样式\n if ([ComponentNameEnum.EL_RADIO_GROUP, ComponentNameEnum.EL_RADIO_BUTTON].includes(rootEl as ComponentNameEnum)) {\n return () => renderRadioOptions(unref(columnEnum), unref(fieldNames), column)\n }\n\n // 多选框组和按钮样式\n if ([ComponentNameEnum.EL_CHECKBOX_GROUP, ComponentNameEnum.EL_CHECKBOX_BUTTON].includes(rootEl as ComponentNameEnum)) {\n return () => renderCheckboxOptions(unref(columnEnum), unref(fieldNames), column)\n }\n\n // 虚拟列表\n if (rootEl === ComponentNameEnum.EL_SELECT_V2 && slots.default) return ({ item }) => slots.default(item)\n }\n\n defineExpose({\n formComponentRef\n })\n</script>\n"],"names":["props","__props","znygStore","useLocalStorage","dictMap","model","_useModel","cachedResults","Map","fieldNames","computed","dictCode","column","label","value","children","disabled","enumMap","inject","formEnumMapKey","ref","rawEnum","enum","columnEnum","useEnumMap","enumKey","prop","el","currentEnumMap","unref","currentRawEnum","result","toString","data","get","Array","isArray","length","enumData","hyphenToCamelCase","ComponentNameEnum","EL_SELECT_V2","map","item","formProps","formEl","cacheKey","JSON","stringify","has","EL_TREE_SELECT","nodeKey","EL_CASCADER","EL_DATE_PICKER","type","valueFormat","EL_TIME_PICKER","set","placeholder","isRange","notDefaultPlaceholder","includes","EL_INPUT","rangeSeparator","startPlaceholder","endPlaceholder","clearable","defaultValue","undefined","isDisabled","__name","renderComponent","RenderComponent","useRenderComponent","renderSelectOptions","useRenderSelect","renderRadioOptions","useRenderRadio","renderCheckboxOptions","useRenderCheckbox","RenderSlots","isView","renderInView","getFormProp","render","formComponentRef","shallowRef","RenderElComponents","style","slots","columnProps","rootEl","slotsMap","setComponentSlots","defaultSlot","getDefaultSlot","default","Component","componentMap","resolveComponent","componentModel","val","setFormProp","getShowValue","EL_SELECT","multiple","selectedItemList","filter","_","join","selectedItem","find","EL_UPLOAD","_createVNode","_mergeProps2","$event","modelValue","options","EL_RADIO_GROUP","EL_RADIO_BUTTON","EL_CHECKBOX_GROUP","EL_CHECKBOX_BUTTON","__expose"],"mappings":"snCAsCE,MAAMA,EAAQC,EAKRC,EAAYC,EAAgB,OAAQ,CAAEC,QAAS,CAAA,IAE/CC,EAAQC,EAAmDL,EAAA,cAG3DM,MAAoBC,IAGpBC,EAAaC,GAAS,KACpB,MAAAC,SAAEA,GAAaX,EAAMY,OAC3B,IAAIC,EAAQb,EAAMY,OAAOH,YAAYI,OAAS,QAC1CC,EAAQd,EAAMY,OAAOH,YAAYK,OAAS,QAMvC,OALHH,IACME,EAAA,OACAC,EAAA,QAGH,CACLD,QACAC,QACAC,SAAUf,EAAMY,OAAOH,YAAYM,UAAY,WAC/CC,SAAUhB,EAAMY,OAAOH,YAAYO,UAAY,WACjD,IAIIC,EAAUC,EAAOC,EAAgBC,EAAQZ,IAAAA,MAGzCa,EAAUX,GAAS,IAAMV,EAAMY,OAAOU,OAEtCC,EAAab,GAAS,KACpB,MAAAc,WAAEA,EAAAA,QAAYC,EAAAA,KAASC,EAAAA,GAAMC,EAAAA,SAAIhB,GAAaX,EAAMY,OAGpDgB,EAAiBC,EAAMZ,GAGvBa,EAAiBD,EAAMR,GAEzBU,IAAAA,EAQJ,GAPIpB,GAEET,GAAaA,EAAUY,OAAOV,UAChC2B,EAAS7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,EAAmB/C,EAAMN,GAAaM,EAAMpB,GAAaG,GAIpE,CAAC4B,EAAkBgF,kBAAmBhF,EAAkBiF,oBAAoB5D,SAAS8B,GAChF,IAAMb,EAAsBjD,EAAMN,GAAaM,EAAMpB,GAAaG,GAIvE+E,IAAWnD,EAAkBC,cAAgBgD,EAAMO,QAAgB,EAAGrD,UAAW8C,EAAMO,QAAQrD,QAAnG,CAAuG,GArBjFgD,yBAwBX+B,EAAA,CACXrC"}
@@ -8,7 +8,7 @@ EXCLUDE_FROM_SETTING:{props:["operation"],
8
8
  // 按 prop 排除
9
9
  types:[],
10
10
  // 按 type 排除(会自动包含所有特殊列类型)
11
- fixed:!0}},ie=[...ne.FRONT_COLUMNS,...ne.BACK_COLUMNS],se=K((e=>e&&ne.FRONT_COLUMNS.includes(e)),"isFrontSpecialColumn"),ue=K((e=>e&&ne.BACK_COLUMNS.includes(e)),"isBackSpecialColumn"),ce=K((e=>{const{type:t,prop:a,fixed:o}=e;return!(!t||!ie.includes(t))||(!(!a||!ne.EXCLUDE_FROM_SETTING.props.includes(a))||!(!ne.EXCLUDE_FROM_SETTING.fixed||!o))}),"shouldExcludeFromSetting"),pe=a(Y.searchFormShow),de=K((e=>Array.isArray(Y.toolButton)?Y.toolButton.includes(e):Y.toolButton),"showToolButton"),me=a(""),{selectionChange:he,selectedList:fe,selectedListIds:ge,isSelected:ye}=x(Y.rowKey),{tableData:ve,pageable:Se,searchParam:be,searchInitParam:Ce,getTableList:we,search:ke,reset:_e,handleSizeChange:Be,handleCurrentChange:qe,loading:Oe}=E(Y.requestApi,Y.initParam,Y.pagination,Y.dataCallback,Y.requestError),Te=K((()=>{le.value&&le.value.clearSelection()}),"clearSelection");l((()=>{Y.requestAuto&&we(),Y.data&&(Se.value.total=Y.data.length)}));const xe=o((()=>{if(!Y.data)return ve.value;if(!Y.pagination)return Y.data;let e=r(Y.data).slice((Se.value.pageNum-1)*Se.value.pageSize,Se.value.pageSize*Se.value.pageNum);return n(e)}));i((()=>Y.initParam),we,{deep:!0});let Ee=n(Y.columns);const Ne=o((()=>je(Ee))),Fe=a(new Map),Ae=K((async({prop:e,enum:t,dictCode:a})=>{if(a&&te&&te.value?.dictMap)return void Fe.value.set(e,te.value.dictMap[a]??[]);if(!t)return;if(Fe.value.has(e)&&("function"==typeof t||Fe.value.get(e)===t))return;if("function"!=typeof t)return Fe.value.set(e,s(t));Fe.value.set(e,[]);let o=await t();o=o?.result||o,Fe.value.set(e,o)}),"setEnumMap");u("enumMap",Fe);const je=K(((e,t=[])=>(e.forEach((async e=>{e._children?.length&&t.push(...je(e._children)),t.push(e),e.isShow=e.isShow??!0,e.isShowInView=e.isShowInView??!0,e.isFilterEnum=e.isFilterEnum??!0,await Ae(e)})),t.filter((e=>!e._children?.length)))),"flatColumnsFunc"),Le=o((()=>Ne.value?.filter((e=>e.search?.el||e.search?.render)).sort(((e,t)=>e.search.order-t.search.order))));Le.value?.forEach(((e,t)=>{e.search.order=e.search?.order??t+2;const a=e.search?.key??F(e.prop),o=e.search?.defaultValue;null!=o&&(Ce.value[a]=o,be.value[a]=o)}));const Me=a(),Ue=a([]),Ie=a(!1),ze=K((()=>{Ue.value=Ee.filter((e=>!ce(e)))}),"initColSetting");ze(),i((()=>Ee),(()=>{Ie.value||(console.log("检测到 tableColumns 变化,同步更新 colSetting"),ze())}),{deep:!0});const Ve=K((e=>{if(!Ie.value)if(ee&&!ee.isUnmounted)try{if(Ie.value=!0,!e||!Array.isArray(e)||0===e.length)return void console.warn("updateTableColumns: 无效的列设置数据",{hasNewColSetting:!!e,isArray:Array.isArray(e),length:e?.length});let t;try{t=JSON.parse(JSON.stringify(e))}catch(a){console.warn("深拷贝列设置数据失败,使用浅拷贝"),t=[...e]}const a=new Map,o=[...Ee];o.forEach((e=>{e&&e.prop&&a.set(e.prop,e)}));const l=[],r=new Set;o.forEach((e=>{e&&(se(e.type)||"left"===e.fixed)&&(l.push(e),e.prop&&r.add(e.prop))})),t.forEach((e=>{if(e&&e.prop&&a.has(e.prop)&&!r.has(e.prop)){const t=a.get(e.prop);if(t)try{const a={...t};a.isShow=e.isShow,a.sortable=e.sortable,l.push(a),r.add(e.prop)}catch(a){console.warn("更新列配置时出错:",a),l.push(t),r.add(e.prop)}}})),o.forEach((e=>{!e||e.prop&&r.has(e.prop)||!ue(e.type)&&(ie.includes(e.type)||"left"===e.fixed)||l.push(e)})),setTimeout((()=>{if(ee&&!ee.isUnmounted)try{Ee.length=0,l.forEach((e=>{e&&Ee.push(e)})),Ue.value=t}catch(e){console.warn("更新表格列时出错:",e)}finally{Ie.value=!1}else console.warn("延迟更新时组件已销毁")}),50)}catch(e){console.warn("updateTableColumns执行时出错:",e),Ie.value=!1}else console.warn("组件已销毁,跳过列更新")}),"updateTableColumns"),$e=K((()=>{Me.value.openColSetting()}),"openColSetting"),Pe=K((()=>{Me.value.closeColSetting()}),"closeColSetting"),Re=W,De=K((()=>{ke(),Re("search")}),"_search"),He=K((()=>{_e(),Re("reset")}),"_reset"),Ke=K(((e,t,a)=>{Re("handleOperateBtnsClick",e,t,a)}),"handleOperateBtnsClick"),Ge=K((()=>{we()}),"refreshTable");return H({element:le,tableData:xe,radio:me,pageable:Se,searchParam:be,searchInitParam:Ce,getTableList:we,search:ke,reset:_e,handleSizeChange:Be,handleCurrentChange:qe,clearSelection:Te,enumMap:Fe,isSelected:ye,selectedList:fe,selectedListIds:ge,refreshTable:Ge,setSearchFormShow:K((e=>{pe.value=e}),"setSearchFormShow"),getColumns:K((()=>Ee),"getColumns"),getColSetting:K((()=>Ue.value),"getColSetting"),openColSetting:$e,closeColSetting:Pe}),(t,a)=>{const o=c("el-button"),l=c("el-radio"),r=c("el-icon"),n=c("el-tag"),i=c("el-table-column"),u=p("loading");return m(),d("div",G,[h(" 查询表单 "),f(v(V,{search:De,reset:He,columns:Le.value,"search-param":s(be),"search-col":e.searchCol},null,8,["columns","search-param","search-col"]),[[S,pe.value]]),h(" 表格主体 "),g("div",{class:b([e.onlyTable?"only-table":"card table-main"])},[h(" 表格头部 操作按钮 "),g("div",X,[g("div",J,[C(t.$slots,"tableHeader",{selectedList:s(fe),selectedListIds:s(ge),isSelected:s(ye)})]),e.toolButton?(m(),d("div",Z,[C(t.$slots,"toolButton",{},(()=>[de("refresh")?(m(),y(o,{key:0,icon:s(A),circle:"",onClick:s(we)},null,8,["icon","onClick"])):h("v-if",!0),de("setting")&&e.columns.length?(m(),y(o,{key:1,icon:s(j),circle:"",onClick:$e},null,8,["icon"])):h("v-if",!0),de("search")&&Le.value?.length?(m(),y(o,{key:2,icon:s(L),circle:"",onClick:a[0]||(a[0]=e=>pe.value=!pe.value)},null,8,["icon"])):h("v-if",!0)]))])):h("v-if",!0)]),h(" 表格主体 "),f((m(),y(s(U),w({ref_key:"tableRef",ref:le},t.$attrs,{data:xe.value,border:e.border,id:re.value,"row-key":e.rowKey,height:oe.value,onSelectionChange:s(he)}),{append:k((()=>[C(t.$slots,"append")])),empty:k((()=>[g("div",Q,[C(t.$slots,"empty",{},(()=>[a[3]||(a[3]=g("img",{src:T,alt:"notData"},null,-1
11
+ fixed:!0}},ie=[...ne.FRONT_COLUMNS,...ne.BACK_COLUMNS],se=K((e=>e&&ne.FRONT_COLUMNS.includes(e)),"isFrontSpecialColumn"),ue=K((e=>e&&ne.BACK_COLUMNS.includes(e)),"isBackSpecialColumn"),ce=K((e=>{const{type:t,prop:a,fixed:o}=e;return!(!t||!ie.includes(t))||(!(!a||!ne.EXCLUDE_FROM_SETTING.props.includes(a))||!(!ne.EXCLUDE_FROM_SETTING.fixed||!o))}),"shouldExcludeFromSetting"),pe=a(Y.searchFormShow),de=K((e=>Array.isArray(Y.toolButton)?Y.toolButton.includes(e):Y.toolButton),"showToolButton"),me=a(""),{selectionChange:he,selectedList:fe,selectedListIds:ge,isSelected:ye}=x(Y.rowKey),{tableData:ve,pageable:Se,searchParam:be,searchInitParam:Ce,getTableList:we,search:ke,reset:_e,handleSizeChange:Be,handleCurrentChange:qe,loading:Oe}=E(Y.requestApi,Y.initParam,Y.pagination,Y.dataCallback,Y.requestError),Te=K((()=>{le.value&&le.value.clearSelection()}),"clearSelection");l((()=>{Y.requestAuto&&we(),Y.data&&(Se.value.total=Y.data.length)}));const xe=o((()=>{if(!Y.data)return ve.value;if(!Y.pagination)return Y.data;let e=r(Y.data).slice((Se.value.pageNum-1)*Se.value.pageSize,Se.value.pageSize*Se.value.pageNum);return n(e)}));i((()=>Y.initParam),we,{deep:!0});let Ee=n(Y.columns);const Ne=o((()=>je(Ee))),Fe=a(new Map),Ae=K((async({prop:e,enum:t,dictCode:a})=>{if(a&&te&&te.value?.dictMap)return void Fe.value.set(e,te.value.dictMap[a?.toString()]??[]);if(!t)return;if(Fe.value.has(e)&&("function"==typeof t||Fe.value.get(e)===t))return;if("function"!=typeof t)return Fe.value.set(e,s(t));Fe.value.set(e,[]);let o=await t();o=o?.result||o,Fe.value.set(e,o)}),"setEnumMap");u("enumMap",Fe);const je=K(((e,t=[])=>(e.forEach((async e=>{e._children?.length&&t.push(...je(e._children)),t.push(e),e.isShow=e.isShow??!0,e.isShowInView=e.isShowInView??!0,e.isFilterEnum=e.isFilterEnum??!0,await Ae(e)})),t.filter((e=>!e._children?.length)))),"flatColumnsFunc"),Le=o((()=>Ne.value?.filter((e=>e.search?.el||e.search?.render)).sort(((e,t)=>e.search.order-t.search.order))));Le.value?.forEach(((e,t)=>{e.search.order=e.search?.order??t+2;const a=e.search?.key??F(e.prop),o=e.search?.defaultValue;null!=o&&(Ce.value[a]=o,be.value[a]=o)}));const Me=a(),Ue=a([]),Ie=a(!1),ze=K((()=>{Ue.value=Ee.filter((e=>!ce(e)))}),"initColSetting");ze(),i((()=>Ee),(()=>{Ie.value||(console.log("检测到 tableColumns 变化,同步更新 colSetting"),ze())}),{deep:!0});const Ve=K((e=>{if(!Ie.value)if(ee&&!ee.isUnmounted)try{if(Ie.value=!0,!e||!Array.isArray(e)||0===e.length)return void console.warn("updateTableColumns: 无效的列设置数据",{hasNewColSetting:!!e,isArray:Array.isArray(e),length:e?.length});let t;try{t=JSON.parse(JSON.stringify(e))}catch(a){console.warn("深拷贝列设置数据失败,使用浅拷贝"),t=[...e]}const a=new Map,o=[...Ee];o.forEach((e=>{e&&e.prop&&a.set(e.prop,e)}));const l=[],r=new Set;o.forEach((e=>{e&&(se(e.type)||"left"===e.fixed)&&(l.push(e),e.prop&&r.add(e.prop))})),t.forEach((e=>{if(e&&e.prop&&a.has(e.prop)&&!r.has(e.prop)){const t=a.get(e.prop);if(t)try{const a={...t};a.isShow=e.isShow,a.sortable=e.sortable,l.push(a),r.add(e.prop)}catch(a){console.warn("更新列配置时出错:",a),l.push(t),r.add(e.prop)}}})),o.forEach((e=>{!e||e.prop&&r.has(e.prop)||!ue(e.type)&&(ie.includes(e.type)||"left"===e.fixed)||l.push(e)})),setTimeout((()=>{if(ee&&!ee.isUnmounted)try{Ee.length=0,l.forEach((e=>{e&&Ee.push(e)})),Ue.value=t}catch(e){console.warn("更新表格列时出错:",e)}finally{Ie.value=!1}else console.warn("延迟更新时组件已销毁")}),50)}catch(e){console.warn("updateTableColumns执行时出错:",e),Ie.value=!1}else console.warn("组件已销毁,跳过列更新")}),"updateTableColumns"),$e=K((()=>{Me.value.openColSetting()}),"openColSetting"),Pe=K((()=>{Me.value.closeColSetting()}),"closeColSetting"),Re=W,De=K((()=>{ke(),Re("search")}),"_search"),He=K((()=>{_e(),Re("reset")}),"_reset"),Ke=K(((e,t,a)=>{Re("handleOperateBtnsClick",e,t,a)}),"handleOperateBtnsClick"),Ge=K((()=>{we()}),"refreshTable");return H({element:le,tableData:xe,radio:me,pageable:Se,searchParam:be,searchInitParam:Ce,getTableList:we,search:ke,reset:_e,handleSizeChange:Be,handleCurrentChange:qe,clearSelection:Te,enumMap:Fe,isSelected:ye,selectedList:fe,selectedListIds:ge,refreshTable:Ge,setSearchFormShow:K((e=>{pe.value=e}),"setSearchFormShow"),getColumns:K((()=>Ee),"getColumns"),getColSetting:K((()=>Ue.value),"getColSetting"),openColSetting:$e,closeColSetting:Pe}),(t,a)=>{const o=c("el-button"),l=c("el-radio"),r=c("el-icon"),n=c("el-tag"),i=c("el-table-column"),u=p("loading");return m(),d("div",G,[h(" 查询表单 "),f(v(V,{search:De,reset:He,columns:Le.value,"search-param":s(be),"search-col":e.searchCol},null,8,["columns","search-param","search-col"]),[[S,pe.value]]),h(" 表格主体 "),g("div",{class:b([e.onlyTable?"only-table":"card table-main"])},[h(" 表格头部 操作按钮 "),g("div",X,[g("div",J,[C(t.$slots,"tableHeader",{selectedList:s(fe),selectedListIds:s(ge),isSelected:s(ye)})]),e.toolButton?(m(),d("div",Z,[C(t.$slots,"toolButton",{},(()=>[de("refresh")?(m(),y(o,{key:0,icon:s(A),circle:"",onClick:s(we)},null,8,["icon","onClick"])):h("v-if",!0),de("setting")&&e.columns.length?(m(),y(o,{key:1,icon:s(j),circle:"",onClick:$e},null,8,["icon"])):h("v-if",!0),de("search")&&Le.value?.length?(m(),y(o,{key:2,icon:s(L),circle:"",onClick:a[0]||(a[0]=e=>pe.value=!pe.value)},null,8,["icon"])):h("v-if",!0)]))])):h("v-if",!0)]),h(" 表格主体 "),f((m(),y(s(U),w({ref_key:"tableRef",ref:le},t.$attrs,{data:xe.value,border:e.border,id:re.value,"row-key":e.rowKey,height:oe.value,onSelectionChange:s(he)}),{append:k((()=>[C(t.$slots,"append")])),empty:k((()=>[g("div",Q,[C(t.$slots,"empty",{},(()=>[a[3]||(a[3]=g("img",{src:T,alt:"notData"},null,-1
12
12
  /* HOISTED */)),a[4]||(a[4]=g("div",null,"暂无数据",-1
13
13
  /* HOISTED */))]))])])),default:k((()=>[C(t.$slots,"default"),(m(!0),d(_,null,B(s(Ee),(o=>(m(),d(_,{key:o},[h(" selection || radio || index || expand || sort "),o.type&&ie.includes(o.type)?(m(),y(i,w({key:0,ref_for:!0},o,{selectable:K((e=>null==e.selectable||null==e.selectable||e.selectable),"selectable"),align:o.align??"center","reserve-selection":"selection"==o.type}),{default:k((i=>[h(" expand "),"expand"==o.type?(m(),d(_,{key:0},[o.render?(m(),y(q(o.render),w({key:0,ref_for:!0},i),null,16
14
14
  /* FULL_PROPS */)):C(t.$slots,o.type,w({key:1,ref_for:!0},i))],64
@@ -1 +1 @@
1
- {"version":3,"file":"index.vue2.mjs","sources":["../../../../../../packages/components/znTable/src/index.vue"],"sourcesContent":["<!-- 📚📚📚 Pro-Table 文档: https://juejin.cn/post/7166068828202336263 -->\n\n<template>\n <div class=\"table-box\">\n <!-- 查询表单 -->\n <SearchForm v-show=\"isShowSearch\" :search=\"_search\" :reset=\"_reset\" :columns=\"searchColumns\" :search-param=\"searchParam\" :search-col=\"searchCol\" />\n\n <!-- 表格主体 -->\n <div :class=\"[onlyTable ? 'only-table' : 'card table-main']\">\n <!-- 表格头部 操作按钮 -->\n <div class=\"table-header\">\n <div class=\"header-button-lf\">\n <slot name=\"tableHeader\" :selected-list=\"selectedList\" :selected-list-ids=\"selectedListIds\" :is-selected=\"isSelected\"></slot>\n </div>\n <div v-if=\"toolButton\" class=\"header-button-ri\">\n <slot name=\"toolButton\">\n <el-button v-if=\"showToolButton('refresh')\" :icon=\"Refresh\" circle @click=\"getTableList\" />\n <el-button v-if=\"showToolButton('setting') && columns.length\" :icon=\"Operation\" circle @click=\"openColSetting\" />\n <el-button v-if=\"showToolButton('search') && searchColumns?.length\" :icon=\"Search\" circle @click=\"isShowSearch = !isShowSearch\" />\n </slot>\n </div>\n </div>\n <!-- 表格主体 -->\n <el-table\n ref=\"tableRef\"\n v-bind=\"$attrs\"\n :data=\"processTableData\"\n :border=\"border\"\n :id=\"uuid\"\n :row-key=\"rowKey\"\n :height=\"tableHeight\"\n v-loading=\"loading\"\n @selection-change=\"selectionChange\">\n <!-- 默认插槽 -->\n <slot></slot>\n <template v-for=\"item in tableColumns\" :key=\"item\">\n <!-- selection || radio || index || expand || sort -->\n <el-table-column\n v-if=\"item.type && columnTypes.includes(item.type)\"\n v-bind=\"item\"\n :selectable=\"(row: any) => (row.selectable != null && row.selectable != undefined ? row.selectable : true)\"\n :align=\"item.align ?? 'center'\"\n :reserve-selection=\"item.type == 'selection'\">\n <template #default=\"scope\">\n <!-- expand -->\n <template v-if=\"item.type == 'expand'\">\n <component :is=\"item.render\" v-bind=\"scope\" v-if=\"item.render\" />\n <slot v-else :name=\"item.type\" v-bind=\"scope\"></slot>\n </template>\n <!-- radio -->\n <el-radio v-if=\"item.type == 'radio'\" v-model=\"radio\" :label=\"scope.row[rowKey]\">\n <i></i>\n </el-radio>\n <!-- sort -->\n <el-tag v-if=\"item.type == 'sort'\" class=\"move\">\n <el-icon><DCaret /></el-icon>\n </el-tag>\n <!-- operationBtns -->\n <OperationBtns\n v-if=\"item.type == 'operationBtns'\"\n v-bind=\"item.props\"\n :row=\"scope.row\"\n @btn-click=\"handleOperateBtnsClick\" />\n </template>\n </el-table-column>\n <!-- other -->\n <TableColumn\n v-if=\"!item.type && item.prop && item.isShow && (!unref(isView) || (unref(isView) && item.isShowInView))\"\n :column=\"item\"\n :is-view=\"isView\">\n <template v-for=\"slot in Object.keys($slots)\" #[slot]=\"scope\">\n <slot :name=\"slot\" v-bind=\"scope\"></slot>\n </template>\n </TableColumn>\n </template>\n <!-- 插入表格最后一行之后的插槽 -->\n <template #append>\n <slot name=\"append\"></slot>\n </template>\n <!-- 无数据 -->\n <template #empty>\n <div class=\"table-empty\">\n <slot name=\"empty\">\n <img src=\"./assets/notData.png\" alt=\"notData\" />\n <div>暂无数据</div>\n </slot>\n </div>\n </template>\n </el-table>\n <!-- 分页组件 -->\n <slot name=\"pagination\">\n <Pagination v-if=\"pagination\" :pageable=\"pageable\" :handle-size-change=\"handleSizeChange\" :handle-current-change=\"handleCurrentChange\" :page-size-options=\"pageSizeOptions\" />\n </slot>\n </div>\n <!-- 列设置 -->\n <ColSetting v-if=\"toolButton\" ref=\"colRef\" :col-setting=\"colSetting\" @update-columns=\"updateTableColumns\">\n <!-- 列设置头部插槽 -->\n <template #colSettingHeader>\n <slot name=\"colSettingHeader\"></slot>\n </template>\n </ColSetting>\n </div>\n</template>\n\n<script setup lang=\"ts\" name=\"ZnTable\">\n import { computed, onMounted, provide, reactive, ref, toRaw, unref, watch, nextTick, getCurrentInstance } from 'vue'\n\n import ColSetting from './components/ColSetting.vue'\n import Pagination from './components/Pagination.vue'\n import TableColumn from './components/TableColumn.vue'\n import SearchForm from './components/SearchForm/index.vue'\n import OperationBtns from './components/OperationBtns/index.vue'\n\n import { BreakPoint } from './components/Grid/interface'\n import { ColumnProps, TypeProps, OperationBtnProps } from './interface'\n import { useSelection } from './hooks/useSelection'\n import { useTable } from './hooks/useTable'\n import { generateUUID, handleProp } from './utils'\n import { Operation, Refresh, Search, DCaret } from '@element-plus/icons-vue'\n import { ElTable } from 'element-plus'\n // import Sortable from 'sortablejs'\n import { useResizeObserver, useLocalStorage } from '@vueuse/core'\n defineOptions({\n name: 'ZnTable'\n })\n\n export interface ZnTableProps {\n columns: ColumnProps[] // 列配置项 ==> 必传\n data?: any[] // 静态 table data 数据,若存在则不会使用 requestApi 返回的 data ==> 非必传\n requestApi?: (params: any) => Promise<any> // 请求表格数据的 api ==> 非必传\n requestAuto?: boolean // 是否自动执行请求 api ==> 非必传(默认为true)\n requestError?: (params: any) => void // 表格 api 请求错误监听 ==> 非必传\n dataCallback?: (data: any) => any // 返回数据的回调函数,可以对数据进行处理 ==> 非必传\n title?: string // 表格标题 ==> 非必传\n pagination?: boolean // 是否需要分页组件 ==> 非必传(默认为true)\n pageSizeOptions?: number[] // 分页每页条数选项 ==> 非必传(默认为[10, 25, 50, 100])\n initParam?: any // 初始化请求参数 ==> 非必传(默认为{})\n border?: boolean // 是否带有纵向边框 ==> 非必传(默认为true)\n toolButton?: ('refresh' | 'setting' | 'search')[] | boolean // 是否显示表格功能按钮 ==> 非必传(默认为true)\n rowKey?: string // 行数据的 Key,用来优化 Table 的渲染,当表格数据多选时,所指定的 id ==> 非必传(默认为 id)\n searchCol?: number | Record<BreakPoint, number> // 表格搜索项 每列占比配置 ==> 非必传 { xs: 1, sm: 2, md: 2, lg: 3, xl: 4 }\n height?: string | number // 表格高度,如果传了,则直接使用这个高度 未传则自动计算\n heightOffset?: number // 如果没传height,自动计算时,去除的高度\n minHeight?: string | number // 表格最小高度 ==> 非必传(默认为200)\n // hiddenTableHeader?: boolean // 隐藏表格头部\n onlyTable?: boolean // 只展示el-table部分\n isView?: boolean // 是否查看,默认为否\n searchFormShow?: boolean // 是否显示筛选行,默认为true\n }\n\n // 接受父组件参数,配置默认值\n const props = defineProps({\n columns: { type: Array, required: true, default: () => [] },\n data: { type: Array, required: false },\n requestApi: { type: Function, required: false },\n requestAuto: { type: Boolean, required: false, default: true },\n requestError: { type: Function, required: false },\n dataCallback: { type: Function, required: false },\n title: { type: String, required: false },\n pagination: { type: Boolean, required: false, default: true },\n pageSizeOptions: { type: Array, required: false, default: () => [10, 25, 50, 100] },\n initParam: { required: false, default: {} },\n border: { type: Boolean, required: false, default: true },\n toolButton: { type: [Array, Boolean], required: false, default: true },\n rowKey: { type: String, required: false, default: 'id' },\n searchCol: { type: [Number, Object], required: false, default: () => ({ xs: 1, sm: 2, md: 2, lg: 3, xl: 4 }) },\n height: { type: [String, Number], required: false },\n heightOffset: { type: Number, required: false, default: 0 },\n minHeight: { type: [String, Number], required: false, default: 200 },\n onlyTable: { type: Boolean, required: false, default: false },\n isView: { type: Boolean, required: false, default: false },\n searchFormShow: { type: Boolean, required: false, default: true }\n})\n\n // 在 setup 顶层获取组件实例,确保能正确获取\n const componentInstance = getCurrentInstance()\n\n const znygStore = useLocalStorage('znyg', { dictMap: {} })\n\n const bodyHeight = ref(0)\n useResizeObserver(document.body, (entries) => {\n const entry = entries[0]\n const { height } = entry.contentRect\n bodyHeight.value = height\n })\n // 计算表格高度\n const tableHeight = computed(() => {\n if (props.height) {\n return props.height\n }\n const ret = bodyHeight.value - 100 - (isShowSearch.value ? 120 : 40) - (props.pagination ? 150 : 0) - props.heightOffset\n // console.log(bodyHeight.value + '-' + 100 + '-' + (isShowSearch.value ? 120 : 0) + '-' + (props.pagination ? 70 : 0))\n // console.log('bodyHeight:' + bodyHeight.value, 'isShowSearch:' + (isShowSearch.value ? 80 : 0), 'ret:' + ret)\n \n // 确保返回的高度不小于最小高度\n const minHeightValue = typeof props.minHeight === 'number' ? props.minHeight : parseInt(props.minHeight.toString())\n return ret > minHeightValue ? ret : minHeightValue\n })\n\n // table 实例\n const tableRef = ref<InstanceType<typeof ElTable>>()\n\n // 生成组件唯一id\n const uuid = ref('id-' + generateUUID())\n\n /**\n * 特殊列配置管理\n * \n * 如何添加新的特殊列类型:\n * 1. 在 interface/index.ts 中的 TypeProps 类型中添加新的列类型\n * 2. 根据列的显示位置,将新类型添加到 FRONT_COLUMNS 或 BACK_COLUMNS 数组中\n * 3. 如果需要从列设置中排除特定的 prop,添加到 EXCLUDE_FROM_SETTING.props 中\n * 4. 在模板中添加对应的渲染逻辑\n * \n * 就这样!不需要在其他地方修改代码了。\n */\n const SPECIAL_COLUMN_CONFIG = {\n // 前置特殊列(显示在表格最前面)\n FRONT_COLUMNS: ['selection', 'radio', 'index', 'expand', 'sort'] as TypeProps[],\n // 后置特殊列(显示在表格最后面)\n BACK_COLUMNS: ['operationBtns'] as TypeProps[],\n // 需要从列设置中排除的列(除了特殊列类型,还可以包括特定的 prop)\n EXCLUDE_FROM_SETTING: {\n props: ['operation'], // 按 prop 排除\n types: [] as TypeProps[], // 按 type 排除(会自动包含所有特殊列类型)\n fixed: true // 排除固定列\n }\n }\n\n // 所有特殊列类型(合并前置和后置)\n const columnTypes: TypeProps[] = [...SPECIAL_COLUMN_CONFIG.FRONT_COLUMNS, ...SPECIAL_COLUMN_CONFIG.BACK_COLUMNS]\n\n // 判断是否为前置特殊列\n const isFrontSpecialColumn = (type?: TypeProps) => {\n return type && SPECIAL_COLUMN_CONFIG.FRONT_COLUMNS.includes(type)\n }\n\n // 判断是否为后置特殊列\n const isBackSpecialColumn = (type?: TypeProps) => {\n return type && SPECIAL_COLUMN_CONFIG.BACK_COLUMNS.includes(type)\n }\n\n // 判断是否应该从列设置中排除\n const shouldExcludeFromSetting = (column: ColumnProps) => {\n const { type, prop, fixed } = column\n \n // 排除所有特殊列类型\n if (type && columnTypes.includes(type)) return true\n \n // 排除指定的 prop\n if (prop && SPECIAL_COLUMN_CONFIG.EXCLUDE_FROM_SETTING.props.includes(prop)) return true\n \n // 排除固定列\n if (SPECIAL_COLUMN_CONFIG.EXCLUDE_FROM_SETTING.fixed && fixed) return true\n \n return false\n }\n\n // 是否显示搜索模块\n const isShowSearch = ref(props.searchFormShow)\n\n // 控制 ToolButton 显示\n const showToolButton = (key: 'refresh' | 'setting' | 'search') => {\n return Array.isArray(props.toolButton) ? props.toolButton.includes(key) : props.toolButton\n }\n\n // 单选值\n const radio = ref('')\n\n // 表格多选 Hooks\n const { selectionChange, selectedList, selectedListIds, isSelected } = useSelection(props.rowKey)\n\n // 表格操作 Hooks\n const { tableData, pageable, searchParam, searchInitParam, getTableList, search, reset, handleSizeChange, handleCurrentChange, loading } = useTable(\n props.requestApi,\n props.initParam,\n props.pagination,\n props.dataCallback,\n props.requestError\n )\n\n // 清空选中数据列表\n const clearSelection = () => {\n if (!tableRef.value) return\n tableRef.value!.clearSelection()\n }\n // 初始化表格数据 && 拖拽排序\n onMounted(() => {\n // dragSort()\n props.requestAuto && getTableList()\n props.data && (pageable.value.total = props.data.length)\n })\n\n // 处理表格数据\n const processTableData = computed(() => {\n if (!props.data) return tableData.value\n if (!props.pagination) return props.data\n // return props.data.slice((pageable.value.pageNum - 1) * pageable.value.pageSize, pageable.value.pageSize * pageable.value.pageNum)\n // todo 处理当使用静态tableData数据,表格在拖拽排序后,hover进入默认样式问题\n const rawData = toRaw(props.data)\n let slicedData = rawData.slice((pageable.value.pageNum - 1) * pageable.value.pageSize, pageable.value.pageSize * pageable.value.pageNum)\n\n const reactiveData = reactive(slicedData)\n return reactiveData\n })\n\n // 监听页面 initParam 改化,重新获取表格数据\n watch(() => props.initParam, getTableList, { deep: true })\n\n // 接收 columns 并设置为响应式\n let tableColumns = reactive<ColumnProps[]>(props.columns)\n\n // 扁平化 columns\n const flatColumns = computed(() => flatColumnsFunc(tableColumns))\n\n // 定义 enumMap 存储 enum 值(避免异步请求无法格式化单元格内容 || 无法填充搜索下拉选择)\n const enumMap = ref(new Map<string, { [key: string]: any }[]>())\n const setEnumMap = async ({ prop, enum: enumValue, dictCode }: ColumnProps) => {\n if (dictCode) {\n // let znygStore = globalThis.localStorage.getItem('znyg')\n // if (znygStore) znygStore = JSON.parse(znygStore)\n if (znygStore && znygStore.value?.dictMap) {\n enumMap.value.set(prop!, znygStore.value.dictMap[dictCode] ?? [])\n return\n }\n }\n if (!enumValue) return\n\n // 如果当前 enumMap 存在相同的值 return\n if (enumMap.value.has(prop!) && (typeof enumValue === 'function' || enumMap.value.get(prop!) === enumValue)) return\n\n // 当前 enum 为静态数据,则直接存储到 enumMap\n if (typeof enumValue !== 'function') return enumMap.value.set(prop!, unref(enumValue!))\n\n // 为了防止接口执行慢,而存储慢,导致重复请求,所以预先存储为[],接口返回后再二次存储\n enumMap.value.set(prop!, [])\n\n // 当前 enum 为后台数据需要请求数据,则调用该请求接口,并存储到 enumMap\n // const { data } = await enumValue()\n // 如果当前 enum 为后台数据需要请求数据,则调用该请求接口,并存储到 enumMap\n let data = await enumValue()\n // 适配 enum 接口返回 data 以及自定义函数返回数组\n data = data?.result || data\n enumMap.value.set(prop!, data)\n }\n // 注入 enumMap\n provide('enumMap', enumMap)\n\n // 扁平化 columns 的方法\n const flatColumnsFunc = (columns: ColumnProps[], flatArr: ColumnProps[] = []) => {\n columns.forEach(async (col) => {\n if (col._children?.length) flatArr.push(...flatColumnsFunc(col._children))\n flatArr.push(col)\n\n // column 添加默认 isShow && isFilterEnum 属性值\n col.isShow = col.isShow ?? true\n col.isShowInView = col.isShowInView ?? true\n col.isFilterEnum = col.isFilterEnum ?? true\n\n // 设置 enumMap\n await setEnumMap(col)\n })\n return flatArr.filter((item) => !item._children?.length)\n }\n\n // 过滤需要搜索的配置项 && 排序\n const searchColumns = computed(() => {\n return flatColumns.value?.filter((item) => item.search?.el || item.search?.render).sort((a, b) => a.search!.order! - b.search!.order!)\n })\n\n // 设置 搜索表单默认排序 && 搜索表单项的默认值\n searchColumns.value?.forEach((column, index) => {\n column.search!.order = column.search?.order ?? index + 2\n const key = column.search?.key ?? handleProp(column.prop!)\n const defaultValue = column.search?.defaultValue\n if (defaultValue !== undefined && defaultValue !== null) {\n searchInitParam.value[key] = defaultValue\n searchParam.value[key] = defaultValue\n }\n })\n\n // 列设置\n const colRef = ref()\n const colSetting = ref<ColumnProps[]>([])\n // 添加更新标志,避免循环更新\n const isUpdatingColumns = ref(false)\n \n // const colSetting = computed(() => {\n // return tableColumns.filter((item) => !shouldExcludeFromSetting(item))\n // })\n\n // 初始化列设置数据\n const initColSetting = () => {\n colSetting.value = tableColumns.filter((item) => !shouldExcludeFromSetting(item))\n }\n\n // 初始化时设置列配置\n initColSetting()\n \n // 监听 tableColumns 变化,同步更新 colSetting\n watch(\n () => tableColumns,\n () => {\n // 如果正在更新中,跳过同步\n if (isUpdatingColumns.value) {\n return\n }\n \n console.log('检测到 tableColumns 变化,同步更新 colSetting')\n initColSetting()\n },\n { deep: true }\n )\n\n // 手动更新表格列顺序的函数\n const updateTableColumns = (newColSetting: ColumnProps[]) => {\n // 如果正在更新中,避免循环调用\n if (isUpdatingColumns.value) {\n return\n }\n \n // console.log('updateTableColumns调用:', {\n // hasNewColSetting: !!newColSetting,\n // newColSettingLength: Array.isArray(newColSetting) ? newColSetting.length : 'not array',\n // currentTableColumnsLength: tableColumns.length\n // })\n\n // console.log('组件实例状态:', {\n // hasInstance: !!componentInstance,\n // isUnmounted: componentInstance?.isUnmounted\n // })\n\n if (!componentInstance || componentInstance.isUnmounted) {\n console.warn('组件已销毁,跳过列更新')\n return\n }\n\n try {\n // 设置更新标志\n isUpdatingColumns.value = true\n \n // 安全检查\n if (!newColSetting || !Array.isArray(newColSetting) || newColSetting.length === 0) {\n console.warn('updateTableColumns: 无效的列设置数据', {\n hasNewColSetting: !!newColSetting,\n isArray: Array.isArray(newColSetting),\n length: newColSetting?.length\n })\n return\n }\n\n // console.log('开始处理列设置数据')\n\n // 深拷贝输入数据,避免响应式问题\n let clonedColSetting: ColumnProps[]\n try {\n clonedColSetting = JSON.parse(JSON.stringify(newColSetting))\n // console.log('深拷贝成功')\n } catch (error) {\n console.warn('深拷贝列设置数据失败,使用浅拷贝')\n clonedColSetting = [...newColSetting]\n }\n\n // 创建一个映射,用于快速查找列配置\n const colMap = new Map()\n const currentColumns = [...tableColumns] // 创建当前列的副本\n\n currentColumns.forEach(col => {\n if (col && col.prop) {\n colMap.set(col.prop, col)\n }\n })\n\n // console.log('创建列映射完成:', {\n // colMapSize: colMap.size,\n // currentColumnsLength: currentColumns.length\n // })\n\n // 根据新的列设置顺序重新排列列\n const reorderedColumns: ColumnProps[] = []\n const processedProps = new Set()\n\n // 首先添加前置特殊列(selection, radio, index 等)\n currentColumns.forEach(col => {\n if (col && (isFrontSpecialColumn(col.type) || col.fixed === 'left')) {\n // console.log('添加前置特殊列:', { type: col.type, prop: col.prop, label: col.label })\n reorderedColumns.push(col)\n if (col.prop) {\n processedProps.add(col.prop)\n }\n }\n })\n\n // console.log('前置特殊列添加完成,当前列数:', reorderedColumns.length)\n\n // 然后添加按新顺序排列的普通列\n clonedColSetting.forEach(colSetting => {\n if (colSetting && colSetting.prop && colMap.has(colSetting.prop) && !processedProps.has(colSetting.prop)) {\n const originalCol = colMap.get(colSetting.prop)\n if (originalCol) {\n // console.log('添加普通列:', { prop: colSetting.prop, label: colSetting.label, isShow: colSetting.isShow })\n try {\n // 创建列的副本并更新属性\n const updatedCol = { ...originalCol }\n updatedCol.isShow = colSetting.isShow\n updatedCol.sortable = colSetting.sortable\n reorderedColumns.push(updatedCol)\n processedProps.add(colSetting.prop)\n } catch (error) {\n console.warn('更新列配置时出错:', error)\n // 如果更新失败,使用原始列\n reorderedColumns.push(originalCol)\n processedProps.add(colSetting.prop)\n }\n }\n }\n })\n\n // console.log('普通列添加完成,当前列数:', reorderedColumns.length)\n\n // 最后添加后置特殊列(如操作列、operationBtns、右侧固定列等)\n currentColumns.forEach(col => {\n if (col && (!col.prop || !processedProps.has(col.prop)) &&\n (isBackSpecialColumn(col.type) || (!columnTypes.includes(col.type!) && col.fixed !== 'left'))) {\n // console.log('添加后置特殊列:', { type: col.type, prop: col.prop, label: col.label })\n reorderedColumns.push(col)\n }\n })\n\n // console.log('列重排完成:', {\n // reorderedColumnsLength: reorderedColumns.length,\n // processedPropsSize: processedProps.size\n // })\n\n // 使用setTimeout而不是nextTick,确保在下一个事件循环中更新\n setTimeout(() => {\n // console.log('开始更新表格列,检查组件状态:', {\n // hasInstance: !!componentInstance,\n // isUnmounted: componentInstance?.isUnmounted\n // })\n\n if (!componentInstance || componentInstance.isUnmounted) {\n console.warn('延迟更新时组件已销毁')\n return\n }\n\n try {\n // console.log('执行表格列更新')\n // 简单直接的数组替换方法\n tableColumns.length = 0\n reorderedColumns.forEach(col => {\n if (col) {\n tableColumns.push(col as any)\n }\n })\n \n // 同步更新 colSetting,但不触发新的更新\n colSetting.value = clonedColSetting\n \n // console.log('表格列更新完成:', {\n // newLength: tableColumns.length\n // })\n } catch (error) {\n console.warn('更新表格列时出错:', error)\n } finally {\n // 重置更新标志\n isUpdatingColumns.value = false\n }\n }, 50) // 50ms延迟\n } catch (error) {\n console.warn('updateTableColumns执行时出错:', error)\n // 确保在出错时也重置标志\n isUpdatingColumns.value = false\n }\n }\n\n const openColSetting = () => {\n // 直接打开列设置,不重新初始化以避免递归更新\n colRef.value.openColSetting()\n }\n\n const closeColSetting = () => {\n // 关闭列设置\n colRef.value.closeColSetting()\n }\n\n // 定义 emit 事件\n const emit = defineEmits([\"search\", \"reset\", \"dragSort\", \"handleOperateBtnsClick\"])\n\n const _search = () => {\n search()\n emit('search')\n }\n\n const _reset = () => {\n reset()\n emit('reset')\n }\n\n // 处理操作按钮点击事件\n const handleOperateBtnsClick = (btnName: string, row: any, btn: OperationBtnProps) => {\n emit('handleOperateBtnsClick', btnName, row, btn)\n }\n\n // 拖拽排序 // ! 列表数据需要有id\n const dragSort = () => {\n // const tbody = document.querySelector(`#${uuid.value} tbody`) as HTMLElement\n // Sortable.create(tbody, {\n // handle: '.move',\n // animation: 300,\n // onEnd({ newIndex, oldIndex }) {\n // const [removedItem] = processTableData.value.splice(oldIndex!, 1)\n // processTableData.value.splice(newIndex!, 0, removedItem)\n // console.log('newIndex', newIndex, 'oldIndex', oldIndex)\n // emit('dragSort', { newIndex, oldIndex })\n // }\n // })\n }\n\n const refreshTable = () => {\n getTableList()\n }\n\n const setSearchFormShow = (show: boolean) => {\n isShowSearch.value = show\n }\n\n // 获取当前列配置\n const getColumns = () => {\n return tableColumns\n }\n\n // 获取当前列设置配置\n const getColSetting = () => {\n return colSetting.value\n }\n\n // 暴露给父组件的参数和方法 (外部需要什么,都可以从这里暴露出去)\n defineExpose({\n element: tableRef,\n tableData: processTableData,\n radio,\n pageable,\n searchParam,\n searchInitParam,\n getTableList,\n search,\n reset,\n handleSizeChange,\n handleCurrentChange,\n clearSelection,\n enumMap,\n isSelected,\n selectedList,\n selectedListIds,\n refreshTable,\n setSearchFormShow,\n getColumns,\n getColSetting,\n openColSetting,\n closeColSetting\n })\n</script>\n"],"names":["props","__props","componentInstance","getCurrentInstance","znygStore","useLocalStorage","dictMap","bodyHeight","ref","useResizeObserver","document","body","entries","entry","height","contentRect","value","tableHeight","computed","ret","isShowSearch","pagination","heightOffset","minHeightValue","minHeight","parseInt","toString","tableRef","uuid","generateUUID","SPECIAL_COLUMN_CONFIG","FRONT_COLUMNS","BACK_COLUMNS","EXCLUDE_FROM_SETTING","types","fixed","columnTypes","isFrontSpecialColumn","type","includes","isBackSpecialColumn","shouldExcludeFromSetting","column","prop","searchFormShow","showToolButton","key","Array","isArray","toolButton","radio","selectionChange","selectedList","selectedListIds","isSelected","useSelection","rowKey","tableData","pageable","searchParam","searchInitParam","getTableList","search","reset","handleSizeChange","handleCurrentChange","loading","useTable","requestApi","initParam","dataCallback","requestError","clearSelection","__name","onMounted","requestAuto","data","total","length","processTableData","slicedData","toRaw","slice","pageNum","pageSize","reactive","watch","deep","tableColumns","columns","flatColumns","flatColumnsFunc","enumMap","Map","setEnumMap","async","enum","enumValue","dictCode","set","has","get","unref","result","provide","flatArr","forEach","col","_children","push","isShow","isShowInView","isFilterEnum","filter","item","searchColumns","el","render","sort","a","b","order","index","handleProp","defaultValue","colRef","colSetting","isUpdatingColumns","initColSetting","console","log","updateTableColumns","newColSetting","isUnmounted","warn","hasNewColSetting","clonedColSetting","JSON","parse","stringify","error","colMap","currentColumns","reorderedColumns","processedProps","Set","add","originalCol","updatedCol","sortable","setTimeout","openColSetting","closeColSetting","emit","__emit","_search","_reset","handleOperateBtnsClick","btnName","row","btn","refreshTable","__expose","element","setSearchFormShow","show","getColumns","getColSetting"],"mappings":"uqFAuJE,MAAMA,EAAQC,EAwBRC,GAAoBC,IAEpBC,GAAYC,EAAgB,OAAQ,CAAEC,QAAS,KAE/CC,GAAaC,EAAI,GACLC,EAAAC,SAASC,MAAOC,IAC1B,MAAAC,EAAQD,EAAQ,IAChBE,OAAEA,GAAWD,EAAME,YACzBR,GAAWS,MAAQF,CAAA,IAGf,MAAAG,GAAcC,GAAS,KAC3B,GAAIlB,EAAMc,OACR,OAAOd,EAAMc,OAEf,MAAMK,EAAMZ,GAAWS,MAAQ,KAAOI,GAAaJ,MAAQ,IAAM,KAAOhB,EAAMqB,WAAa,IAAM,GAAKrB,EAAMsB,aAKtGC,EAA4C,iBAApBvB,EAAMwB,UAAyBxB,EAAMwB,UAAYC,SAASzB,EAAMwB,UAAUE,YACjG,OAAAP,EAAMI,EAAiBJ,EAAMI,CAAA,IAIhCI,GAAWnB,IAGXoB,GAAOpB,EAAI,MAAQqB,KAanBC,GAAwB;;AAE5BC,cAAe,CAAC,YAAa,QAAS,QAAS,SAAU;;AAEzDC,aAAc,CAAC;;AAEfC,qBAAs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G,OAAQ,CAAA,MA3I1BiH,QAAQK,KAAK,cA2Ia,GA7JH,sBAiKrBiB,GAAuB9E,GAAA,KAE3BoD,GAAO7G,MAAMuI,gBAAe,GAFP,kBAKjBC,GAAwB/E,GAAA,KAE5BoD,GAAO7G,MAAMwI,iBAAgB,GAFP,mBAMlBC,GAAOC,EAEPC,GAAgBlF,GAAA,KACbX,KACP2F,GAAK,SAAQ,GAFC,WAKVG,GAAenF,GAAA,KACbV,KACN0F,GAAK,QAAO,GAFC,UAMTI,GAAyBpF,GAAA,CAACqF,EAAiBC,EAAUC,KACpDP,GAAA,yBAA0BK,EAASC,EAAKC,EAAG,GADnB,0BAmBzBC,GAAqBxF,GAAA,KACZZ,IAAA,GADM,uBAmBRqG,EAAA,CACXC,QAASxI,GACT8B,UAAWsB,GACX7B,SACAQ,YACAC,eACAC,mBACAC,gBACAC,UACAC,SACAC,oBACAC,uBACAO,kBACAoB,WACAtC,cACAF,gBACAC,mBACA4G,gBACAG,qBAjCyBC,IACzBjJ,GAAaJ,MAAQqJ,CAAA,GADG,qBAkCxBC,WA7BuB7F,GAAA,IAChBe,IADU,cA8BjB+E,cAzB0B9F,GAAA,IACnBqD,GAAW9G,OADE,iBA0BpBuI,kBACAC;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.vue2.mjs","sources":["../../../../../../packages/components/znTable/src/index.vue"],"sourcesContent":["<!-- 📚📚📚 Pro-Table 文档: https://juejin.cn/post/7166068828202336263 -->\n\n<template>\n <div class=\"table-box\">\n <!-- 查询表单 -->\n <SearchForm v-show=\"isShowSearch\" :search=\"_search\" :reset=\"_reset\" :columns=\"searchColumns\" :search-param=\"searchParam\" :search-col=\"searchCol\" />\n\n <!-- 表格主体 -->\n <div :class=\"[onlyTable ? 'only-table' : 'card table-main']\">\n <!-- 表格头部 操作按钮 -->\n <div class=\"table-header\">\n <div class=\"header-button-lf\">\n <slot name=\"tableHeader\" :selected-list=\"selectedList\" :selected-list-ids=\"selectedListIds\" :is-selected=\"isSelected\"></slot>\n </div>\n <div v-if=\"toolButton\" class=\"header-button-ri\">\n <slot name=\"toolButton\">\n <el-button v-if=\"showToolButton('refresh')\" :icon=\"Refresh\" circle @click=\"getTableList\" />\n <el-button v-if=\"showToolButton('setting') && columns.length\" :icon=\"Operation\" circle @click=\"openColSetting\" />\n <el-button v-if=\"showToolButton('search') && searchColumns?.length\" :icon=\"Search\" circle @click=\"isShowSearch = !isShowSearch\" />\n </slot>\n </div>\n </div>\n <!-- 表格主体 -->\n <el-table\n ref=\"tableRef\"\n v-bind=\"$attrs\"\n :data=\"processTableData\"\n :border=\"border\"\n :id=\"uuid\"\n :row-key=\"rowKey\"\n :height=\"tableHeight\"\n v-loading=\"loading\"\n @selection-change=\"selectionChange\">\n <!-- 默认插槽 -->\n <slot></slot>\n <template v-for=\"item in tableColumns\" :key=\"item\">\n <!-- selection || radio || index || expand || sort -->\n <el-table-column\n v-if=\"item.type && columnTypes.includes(item.type)\"\n v-bind=\"item\"\n :selectable=\"(row: any) => (row.selectable != null && row.selectable != undefined ? row.selectable : true)\"\n :align=\"item.align ?? 'center'\"\n :reserve-selection=\"item.type == 'selection'\">\n <template #default=\"scope\">\n <!-- expand -->\n <template v-if=\"item.type == 'expand'\">\n <component :is=\"item.render\" v-bind=\"scope\" v-if=\"item.render\" />\n <slot v-else :name=\"item.type\" v-bind=\"scope\"></slot>\n </template>\n <!-- radio -->\n <el-radio v-if=\"item.type == 'radio'\" v-model=\"radio\" :label=\"scope.row[rowKey]\">\n <i></i>\n </el-radio>\n <!-- sort -->\n <el-tag v-if=\"item.type == 'sort'\" class=\"move\">\n <el-icon><DCaret /></el-icon>\n </el-tag>\n <!-- operationBtns -->\n <OperationBtns\n v-if=\"item.type == 'operationBtns'\"\n v-bind=\"item.props\"\n :row=\"scope.row\"\n @btn-click=\"handleOperateBtnsClick\" />\n </template>\n </el-table-column>\n <!-- other -->\n <TableColumn\n v-if=\"!item.type && item.prop && item.isShow && (!unref(isView) || (unref(isView) && item.isShowInView))\"\n :column=\"item\"\n :is-view=\"isView\">\n <template v-for=\"slot in Object.keys($slots)\" #[slot]=\"scope\">\n <slot :name=\"slot\" v-bind=\"scope\"></slot>\n </template>\n </TableColumn>\n </template>\n <!-- 插入表格最后一行之后的插槽 -->\n <template #append>\n <slot name=\"append\"></slot>\n </template>\n <!-- 无数据 -->\n <template #empty>\n <div class=\"table-empty\">\n <slot name=\"empty\">\n <img src=\"./assets/notData.png\" alt=\"notData\" />\n <div>暂无数据</div>\n </slot>\n </div>\n </template>\n </el-table>\n <!-- 分页组件 -->\n <slot name=\"pagination\">\n <Pagination v-if=\"pagination\" :pageable=\"pageable\" :handle-size-change=\"handleSizeChange\" :handle-current-change=\"handleCurrentChange\" :page-size-options=\"pageSizeOptions\" />\n </slot>\n </div>\n <!-- 列设置 -->\n <ColSetting v-if=\"toolButton\" ref=\"colRef\" :col-setting=\"colSetting\" @update-columns=\"updateTableColumns\">\n <!-- 列设置头部插槽 -->\n <template #colSettingHeader>\n <slot name=\"colSettingHeader\"></slot>\n </template>\n </ColSetting>\n </div>\n</template>\n\n<script setup lang=\"ts\" name=\"ZnTable\">\n import { computed, onMounted, provide, reactive, ref, toRaw, unref, watch, nextTick, getCurrentInstance } from 'vue'\n\n import ColSetting from './components/ColSetting.vue'\n import Pagination from './components/Pagination.vue'\n import TableColumn from './components/TableColumn.vue'\n import SearchForm from './components/SearchForm/index.vue'\n import OperationBtns from './components/OperationBtns/index.vue'\n\n import { BreakPoint } from './components/Grid/interface'\n import { ColumnProps, TypeProps, OperationBtnProps } from './interface'\n import { useSelection } from './hooks/useSelection'\n import { useTable } from './hooks/useTable'\n import { generateUUID, handleProp } from './utils'\n import { Operation, Refresh, Search, DCaret } from '@element-plus/icons-vue'\n import { ElTable } from 'element-plus'\n // import Sortable from 'sortablejs'\n import { useResizeObserver, useLocalStorage } from '@vueuse/core'\n defineOptions({\n name: 'ZnTable'\n })\n\n export interface ZnTableProps {\n columns: ColumnProps[] // 列配置项 ==> 必传\n data?: any[] // 静态 table data 数据,若存在则不会使用 requestApi 返回的 data ==> 非必传\n requestApi?: (params: any) => Promise<any> // 请求表格数据的 api ==> 非必传\n requestAuto?: boolean // 是否自动执行请求 api ==> 非必传(默认为true)\n requestError?: (params: any) => void // 表格 api 请求错误监听 ==> 非必传\n dataCallback?: (data: any) => any // 返回数据的回调函数,可以对数据进行处理 ==> 非必传\n title?: string // 表格标题 ==> 非必传\n pagination?: boolean // 是否需要分页组件 ==> 非必传(默认为true)\n pageSizeOptions?: number[] // 分页每页条数选项 ==> 非必传(默认为[10, 25, 50, 100])\n initParam?: any // 初始化请求参数 ==> 非必传(默认为{})\n border?: boolean // 是否带有纵向边框 ==> 非必传(默认为true)\n toolButton?: ('refresh' | 'setting' | 'search')[] | boolean // 是否显示表格功能按钮 ==> 非必传(默认为true)\n rowKey?: string // 行数据的 Key,用来优化 Table 的渲染,当表格数据多选时,所指定的 id ==> 非必传(默认为 id)\n searchCol?: number | Record<BreakPoint, number> // 表格搜索项 每列占比配置 ==> 非必传 { xs: 1, sm: 2, md: 2, lg: 3, xl: 4 }\n height?: string | number // 表格高度,如果传了,则直接使用这个高度 未传则自动计算\n heightOffset?: number // 如果没传height,自动计算时,去除的高度\n minHeight?: string | number // 表格最小高度 ==> 非必传(默认为200)\n // hiddenTableHeader?: boolean // 隐藏表格头部\n onlyTable?: boolean // 只展示el-table部分\n isView?: boolean // 是否查看,默认为否\n searchFormShow?: boolean // 是否显示筛选行,默认为true\n }\n\n // 接受父组件参数,配置默认值\n const props = defineProps({\n columns: { type: Array, required: true, default: () => [] },\n data: { type: Array, required: false },\n requestApi: { type: Function, required: false },\n requestAuto: { type: Boolean, required: false, default: true },\n requestError: { type: Function, required: false },\n dataCallback: { type: Function, required: false },\n title: { type: String, required: false },\n pagination: { type: Boolean, required: false, default: true },\n pageSizeOptions: { type: Array, required: false, default: () => [10, 25, 50, 100] },\n initParam: { required: false, default: {} },\n border: { type: Boolean, required: false, default: true },\n toolButton: { type: [Array, Boolean], required: false, default: true },\n rowKey: { type: String, required: false, default: 'id' },\n searchCol: { type: [Number, Object], required: false, default: () => ({ xs: 1, sm: 2, md: 2, lg: 3, xl: 4 }) },\n height: { type: [String, Number], required: false },\n heightOffset: { type: Number, required: false, default: 0 },\n minHeight: { type: [String, Number], required: false, default: 200 },\n onlyTable: { type: Boolean, required: false, default: false },\n isView: { type: Boolean, required: false, default: false },\n searchFormShow: { type: Boolean, required: false, default: true }\n})\n\n // 在 setup 顶层获取组件实例,确保能正确获取\n const componentInstance = getCurrentInstance()\n\n const znygStore = useLocalStorage('znyg', { dictMap: {} })\n\n const bodyHeight = ref(0)\n useResizeObserver(document.body, (entries) => {\n const entry = entries[0]\n const { height } = entry.contentRect\n bodyHeight.value = height\n })\n // 计算表格高度\n const tableHeight = computed(() => {\n if (props.height) {\n return props.height\n }\n const ret = bodyHeight.value - 100 - (isShowSearch.value ? 120 : 40) - (props.pagination ? 150 : 0) - props.heightOffset\n // console.log(bodyHeight.value + '-' + 100 + '-' + (isShowSearch.value ? 120 : 0) + '-' + (props.pagination ? 70 : 0))\n // console.log('bodyHeight:' + bodyHeight.value, 'isShowSearch:' + (isShowSearch.value ? 80 : 0), 'ret:' + ret)\n \n // 确保返回的高度不小于最小高度\n const minHeightValue = typeof props.minHeight === 'number' ? props.minHeight : parseInt(props.minHeight.toString())\n return ret > minHeightValue ? ret : minHeightValue\n })\n\n // table 实例\n const tableRef = ref<InstanceType<typeof ElTable>>()\n\n // 生成组件唯一id\n const uuid = ref('id-' + generateUUID())\n\n /**\n * 特殊列配置管理\n * \n * 如何添加新的特殊列类型:\n * 1. 在 interface/index.ts 中的 TypeProps 类型中添加新的列类型\n * 2. 根据列的显示位置,将新类型添加到 FRONT_COLUMNS 或 BACK_COLUMNS 数组中\n * 3. 如果需要从列设置中排除特定的 prop,添加到 EXCLUDE_FROM_SETTING.props 中\n * 4. 在模板中添加对应的渲染逻辑\n * \n * 就这样!不需要在其他地方修改代码了。\n */\n const SPECIAL_COLUMN_CONFIG = {\n // 前置特殊列(显示在表格最前面)\n FRONT_COLUMNS: ['selection', 'radio', 'index', 'expand', 'sort'] as TypeProps[],\n // 后置特殊列(显示在表格最后面)\n BACK_COLUMNS: ['operationBtns'] as TypeProps[],\n // 需要从列设置中排除的列(除了特殊列类型,还可以包括特定的 prop)\n EXCLUDE_FROM_SETTING: {\n props: ['operation'], // 按 prop 排除\n types: [] as TypeProps[], // 按 type 排除(会自动包含所有特殊列类型)\n fixed: true // 排除固定列\n }\n }\n\n // 所有特殊列类型(合并前置和后置)\n const columnTypes: TypeProps[] = [...SPECIAL_COLUMN_CONFIG.FRONT_COLUMNS, ...SPECIAL_COLUMN_CONFIG.BACK_COLUMNS]\n\n // 判断是否为前置特殊列\n const isFrontSpecialColumn = (type?: TypeProps) => {\n return type && SPECIAL_COLUMN_CONFIG.FRONT_COLUMNS.includes(type)\n }\n\n // 判断是否为后置特殊列\n const isBackSpecialColumn = (type?: TypeProps) => {\n return type && SPECIAL_COLUMN_CONFIG.BACK_COLUMNS.includes(type)\n }\n\n // 判断是否应该从列设置中排除\n const shouldExcludeFromSetting = (column: ColumnProps) => {\n const { type, prop, fixed } = column\n \n // 排除所有特殊列类型\n if (type && columnTypes.includes(type)) return true\n \n // 排除指定的 prop\n if (prop && SPECIAL_COLUMN_CONFIG.EXCLUDE_FROM_SETTING.props.includes(prop)) return true\n \n // 排除固定列\n if (SPECIAL_COLUMN_CONFIG.EXCLUDE_FROM_SETTING.fixed && fixed) return true\n \n return false\n }\n\n // 是否显示搜索模块\n const isShowSearch = ref(props.searchFormShow)\n\n // 控制 ToolButton 显示\n const showToolButton = (key: 'refresh' | 'setting' | 'search') => {\n return Array.isArray(props.toolButton) ? props.toolButton.includes(key) : props.toolButton\n }\n\n // 单选值\n const radio = ref('')\n\n // 表格多选 Hooks\n const { selectionChange, selectedList, selectedListIds, isSelected } = useSelection(props.rowKey)\n\n // 表格操作 Hooks\n const { tableData, pageable, searchParam, searchInitParam, getTableList, search, reset, handleSizeChange, handleCurrentChange, loading } = useTable(\n props.requestApi,\n props.initParam,\n props.pagination,\n props.dataCallback,\n props.requestError\n )\n\n // 清空选中数据列表\n const clearSelection = () => {\n if (!tableRef.value) return\n tableRef.value!.clearSelection()\n }\n // 初始化表格数据 && 拖拽排序\n onMounted(() => {\n // dragSort()\n props.requestAuto && getTableList()\n props.data && (pageable.value.total = props.data.length)\n })\n\n // 处理表格数据\n const processTableData = computed(() => {\n if (!props.data) return tableData.value\n if (!props.pagination) return props.data\n // return props.data.slice((pageable.value.pageNum - 1) * pageable.value.pageSize, pageable.value.pageSize * pageable.value.pageNum)\n // todo 处理当使用静态tableData数据,表格在拖拽排序后,hover进入默认样式问题\n const rawData = toRaw(props.data)\n let slicedData = rawData.slice((pageable.value.pageNum - 1) * pageable.value.pageSize, pageable.value.pageSize * pageable.value.pageNum)\n\n const reactiveData = reactive(slicedData)\n return reactiveData\n })\n\n // 监听页面 initParam 改化,重新获取表格数据\n watch(() => props.initParam, getTableList, { deep: true })\n\n // 接收 columns 并设置为响应式\n let tableColumns = reactive<ColumnProps[]>(props.columns)\n\n // 扁平化 columns\n const flatColumns = computed(() => flatColumnsFunc(tableColumns))\n\n // 定义 enumMap 存储 enum 值(避免异步请求无法格式化单元格内容 || 无法填充搜索下拉选择)\n const enumMap = ref(new Map<string, { [key: string]: any }[]>())\n const setEnumMap = async ({ prop, enum: enumValue, dictCode }: ColumnProps) => {\n if (dictCode) {\n // let znygStore = globalThis.localStorage.getItem('znyg')\n // if (znygStore) znygStore = JSON.parse(znygStore)\n if (znygStore && znygStore.value?.dictMap) {\n enumMap.value.set(prop!, znygStore.value.dictMap[dictCode?.toString()] ?? [])\n return\n }\n }\n if (!enumValue) return\n\n // 如果当前 enumMap 存在相同的值 return\n if (enumMap.value.has(prop!) && (typeof enumValue === 'function' || enumMap.value.get(prop!) === enumValue)) return\n\n // 当前 enum 为静态数据,则直接存储到 enumMap\n if (typeof enumValue !== 'function') return enumMap.value.set(prop!, unref(enumValue!))\n\n // 为了防止接口执行慢,而存储慢,导致重复请求,所以预先存储为[],接口返回后再二次存储\n enumMap.value.set(prop!, [])\n\n // 当前 enum 为后台数据需要请求数据,则调用该请求接口,并存储到 enumMap\n // const { data } = await enumValue()\n // 如果当前 enum 为后台数据需要请求数据,则调用该请求接口,并存储到 enumMap\n let data = await enumValue()\n // 适配 enum 接口返回 data 以及自定义函数返回数组\n data = data?.result || data\n enumMap.value.set(prop!, data)\n }\n // 注入 enumMap\n provide('enumMap', enumMap)\n\n // 扁平化 columns 的方法\n const flatColumnsFunc = (columns: ColumnProps[], flatArr: ColumnProps[] = []) => {\n columns.forEach(async (col) => {\n if (col._children?.length) flatArr.push(...flatColumnsFunc(col._children))\n flatArr.push(col)\n\n // column 添加默认 isShow && isFilterEnum 属性值\n col.isShow = col.isShow ?? true\n col.isShowInView = col.isShowInView ?? true\n col.isFilterEnum = col.isFilterEnum ?? true\n\n // 设置 enumMap\n await setEnumMap(col)\n })\n return flatArr.filter((item) => !item._children?.length)\n }\n\n // 过滤需要搜索的配置项 && 排序\n const searchColumns = computed(() => {\n return flatColumns.value?.filter((item) => item.search?.el || item.search?.render).sort((a, b) => a.search!.order! - b.search!.order!)\n })\n\n // 设置 搜索表单默认排序 && 搜索表单项的默认值\n searchColumns.value?.forEach((column, index) => {\n column.search!.order = column.search?.order ?? index + 2\n const key = column.search?.key ?? handleProp(column.prop!)\n const defaultValue = column.search?.defaultValue\n if (defaultValue !== undefined && defaultValue !== null) {\n searchInitParam.value[key] = defaultValue\n searchParam.value[key] = defaultValue\n }\n })\n\n // 列设置\n const colRef = ref()\n const colSetting = ref<ColumnProps[]>([])\n // 添加更新标志,避免循环更新\n const isUpdatingColumns = ref(false)\n \n // const colSetting = computed(() => {\n // return tableColumns.filter((item) => !shouldExcludeFromSetting(item))\n // })\n\n // 初始化列设置数据\n const initColSetting = () => {\n colSetting.value = tableColumns.filter((item) => !shouldExcludeFromSetting(item))\n }\n\n // 初始化时设置列配置\n initColSetting()\n \n // 监听 tableColumns 变化,同步更新 colSetting\n watch(\n () => tableColumns,\n () => {\n // 如果正在更新中,跳过同步\n if (isUpdatingColumns.value) {\n return\n }\n \n console.log('检测到 tableColumns 变化,同步更新 colSetting')\n initColSetting()\n },\n { deep: true }\n )\n\n // 手动更新表格列顺序的函数\n const updateTableColumns = (newColSetting: ColumnProps[]) => {\n // 如果正在更新中,避免循环调用\n if (isUpdatingColumns.value) {\n return\n }\n \n // console.log('updateTableColumns调用:', {\n // hasNewColSetting: !!newColSetting,\n // newColSettingLength: Array.isArray(newColSetting) ? newColSetting.length : 'not array',\n // currentTableColumnsLength: tableColumns.length\n // })\n\n // console.log('组件实例状态:', {\n // hasInstance: !!componentInstance,\n // isUnmounted: componentInstance?.isUnmounted\n // })\n\n if (!componentInstance || componentInstance.isUnmounted) {\n console.warn('组件已销毁,跳过列更新')\n return\n }\n\n try {\n // 设置更新标志\n isUpdatingColumns.value = true\n \n // 安全检查\n if (!newColSetting || !Array.isArray(newColSetting) || newColSetting.length === 0) {\n console.warn('updateTableColumns: 无效的列设置数据', {\n hasNewColSetting: !!newColSetting,\n isArray: Array.isArray(newColSetting),\n length: newColSetting?.length\n })\n return\n }\n\n // console.log('开始处理列设置数据')\n\n // 深拷贝输入数据,避免响应式问题\n let clonedColSetting: ColumnProps[]\n try {\n clonedColSetting = JSON.parse(JSON.stringify(newColSetting))\n // console.log('深拷贝成功')\n } catch (error) {\n console.warn('深拷贝列设置数据失败,使用浅拷贝')\n clonedColSetting = [...newColSetting]\n }\n\n // 创建一个映射,用于快速查找列配置\n const colMap = new Map()\n const currentColumns = [...tableColumns] // 创建当前列的副本\n\n currentColumns.forEach(col => {\n if (col && col.prop) {\n colMap.set(col.prop, col)\n }\n })\n\n // console.log('创建列映射完成:', {\n // colMapSize: colMap.size,\n // currentColumnsLength: currentColumns.length\n // })\n\n // 根据新的列设置顺序重新排列列\n const reorderedColumns: ColumnProps[] = []\n const processedProps = new Set()\n\n // 首先添加前置特殊列(selection, radio, index 等)\n currentColumns.forEach(col => {\n if (col && (isFrontSpecialColumn(col.type) || col.fixed === 'left')) {\n // console.log('添加前置特殊列:', { type: col.type, prop: col.prop, label: col.label })\n reorderedColumns.push(col)\n if (col.prop) {\n processedProps.add(col.prop)\n }\n }\n })\n\n // console.log('前置特殊列添加完成,当前列数:', reorderedColumns.length)\n\n // 然后添加按新顺序排列的普通列\n clonedColSetting.forEach(colSetting => {\n if (colSetting && colSetting.prop && colMap.has(colSetting.prop) && !processedProps.has(colSetting.prop)) {\n const originalCol = colMap.get(colSetting.prop)\n if (originalCol) {\n // console.log('添加普通列:', { prop: colSetting.prop, label: colSetting.label, isShow: colSetting.isShow })\n try {\n // 创建列的副本并更新属性\n const updatedCol = { ...originalCol }\n updatedCol.isShow = colSetting.isShow\n updatedCol.sortable = colSetting.sortable\n reorderedColumns.push(updatedCol)\n processedProps.add(colSetting.prop)\n } catch (error) {\n console.warn('更新列配置时出错:', error)\n // 如果更新失败,使用原始列\n reorderedColumns.push(originalCol)\n processedProps.add(colSetting.prop)\n }\n }\n }\n })\n\n // console.log('普通列添加完成,当前列数:', reorderedColumns.length)\n\n // 最后添加后置特殊列(如操作列、operationBtns、右侧固定列等)\n currentColumns.forEach(col => {\n if (col && (!col.prop || !processedProps.has(col.prop)) &&\n (isBackSpecialColumn(col.type) || (!columnTypes.includes(col.type!) && col.fixed !== 'left'))) {\n // console.log('添加后置特殊列:', { type: col.type, prop: col.prop, label: col.label })\n reorderedColumns.push(col)\n }\n })\n\n // console.log('列重排完成:', {\n // reorderedColumnsLength: reorderedColumns.length,\n // processedPropsSize: processedProps.size\n // })\n\n // 使用setTimeout而不是nextTick,确保在下一个事件循环中更新\n setTimeout(() => {\n // console.log('开始更新表格列,检查组件状态:', {\n // hasInstance: !!componentInstance,\n // isUnmounted: componentInstance?.isUnmounted\n // })\n\n if (!componentInstance || componentInstance.isUnmounted) {\n console.warn('延迟更新时组件已销毁')\n return\n }\n\n try {\n // console.log('执行表格列更新')\n // 简单直接的数组替换方法\n tableColumns.length = 0\n reorderedColumns.forEach(col => {\n if (col) {\n tableColumns.push(col as any)\n }\n })\n \n // 同步更新 colSetting,但不触发新的更新\n colSetting.value = clonedColSetting\n \n // console.log('表格列更新完成:', {\n // newLength: tableColumns.length\n // })\n } catch (error) {\n console.warn('更新表格列时出错:', error)\n } finally {\n // 重置更新标志\n isUpdatingColumns.value = false\n }\n }, 50) // 50ms延迟\n } catch (error) {\n console.warn('updateTableColumns执行时出错:', error)\n // 确保在出错时也重置标志\n isUpdatingColumns.value = false\n }\n }\n\n const openColSetting = () => {\n // 直接打开列设置,不重新初始化以避免递归更新\n colRef.value.openColSetting()\n }\n\n const closeColSetting = () => {\n // 关闭列设置\n colRef.value.closeColSetting()\n }\n\n // 定义 emit 事件\n const emit = defineEmits([\"search\", \"reset\", \"dragSort\", \"handleOperateBtnsClick\"])\n\n const _search = () => {\n search()\n emit('search')\n }\n\n const _reset = () => {\n reset()\n emit('reset')\n }\n\n // 处理操作按钮点击事件\n const handleOperateBtnsClick = (btnName: string, row: any, btn: OperationBtnProps) => {\n emit('handleOperateBtnsClick', btnName, row, btn)\n }\n\n // 拖拽排序 // ! 列表数据需要有id\n const dragSort = () => {\n // const tbody = document.querySelector(`#${uuid.value} tbody`) as HTMLElement\n // Sortable.create(tbody, {\n // handle: '.move',\n // animation: 300,\n // onEnd({ newIndex, oldIndex }) {\n // const [removedItem] = processTableData.value.splice(oldIndex!, 1)\n // processTableData.value.splice(newIndex!, 0, removedItem)\n // console.log('newIndex', newIndex, 'oldIndex', oldIndex)\n // emit('dragSort', { newIndex, oldIndex })\n // }\n // })\n }\n\n const refreshTable = () => {\n getTableList()\n }\n\n const setSearchFormShow = (show: boolean) => {\n isShowSearch.value = show\n }\n\n // 获取当前列配置\n const getColumns = () => {\n return tableColumns\n }\n\n // 获取当前列设置配置\n const getColSetting = () => {\n return colSetting.value\n }\n\n // 暴露给父组件的参数和方法 (外部需要什么,都可以从这里暴露出去)\n defineExpose({\n element: tableRef,\n tableData: processTableData,\n radio,\n pageable,\n searchParam,\n searchInitParam,\n getTableList,\n search,\n reset,\n handleSizeChange,\n handleCurrentChange,\n clearSelection,\n enumMap,\n isSelected,\n selectedList,\n selectedListIds,\n refreshTable,\n setSearchFormShow,\n getColumns,\n getColSetting,\n openColSetting,\n closeColSetting\n })\n</script>\n"],"names":["props","__props","componentInstance","getCurrentInstance","znygStore","useLocalStorage","dictMap","bodyHeight","ref","useResizeObserver","document","body","entries","entry","height","contentRect","value","tableHeight","computed","ret","isShowSearch","pagination","heightOffset","minHeightValue","minHeight","parseInt","toString","tableRef","uuid","generateUUID","SPECIAL_COLUMN_CONFIG","FRONT_COLUMNS","BACK_COLUMNS","EXCLUDE_FROM_SETTING","types","fixed","columnTypes","isFrontSpecialColumn","type","includes","isBackSpecialColumn","shouldExcludeFromSetting","column","prop","searchFormShow","showToolButton","key","Array","isArray","toolButton","radio","selectionChange","selectedList","selectedListIds","isSelected","useSelection","rowKey","tableData","pageable","searchParam","searchInitParam","getTableList","search","reset","handleSizeChange","handleCurrentChange","loading","useTable","requestApi","initParam","dataCallback","requestError","clearSelection","__name","onMounted","requestAuto","data","total","length","processTableData","slicedData","toRaw","slice","pageNum","pageSize","reactive","watch","deep","tableColumns","columns","flatColumns","flatColumnsFunc","enumMap","Map","setEnumMap","async","enum","enumValue","dictCode","set","has","get","unref","result","provide","flatArr","forEach","col","_children","push","isShow","isShowInView","isFilterEnum","filter","item","searchColumns","el","render","sort","a","b","order","index","handleProp","defaultValue","colRef","colSetting","isUpdatingColumns","initColSetting","console","log","updateTableColumns","newColSetting","isUnmounted","warn","hasNewColSetting","clonedColSetting","JSON","parse","stringify","error","colMap","currentColumns","reorderedColumns","processedProps","Set","add","originalCol","updatedCol","sortable","setTimeout","openColSetting","closeColSetting","emit","__emit","_search","_reset","handleOperateBtnsClick","btnName","row","btn","refreshTable","__expose","element","setSearchFormShow","show","getColumns","getColSetting"],"mappings":"uqFAuJE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BACAoB,WACAtC,cACAF,gBACAC,mBACA4G,gBACAG,qBAjCyBC,IACzBjJ,GAAaJ,MAAQqJ,CAAA,GADG,qBAkCxBC,WA7BuB7F,GAAA,IAChBe,IADU,cA8BjB+E,cAzB0B9F,GAAA,IACnBqD,GAAW9G,OADE,iBA0BpBuI,kBACAC;;;;;;;;;;;;;;;"}
@@ -60,6 +60,11 @@ export declare const ZnTreeFilter: import("../../types").SFCWithInstall<import("
60
60
  required: false;
61
61
  default: any[];
62
62
  };
63
+ expandOnClickNode: {
64
+ type: BooleanConstructor;
65
+ required: false;
66
+ default: boolean;
67
+ };
63
68
  render: {
64
69
  type: FunctionConstructor;
65
70
  required: false;
@@ -2145,6 +2150,11 @@ export declare const ZnTreeFilter: import("../../types").SFCWithInstall<import("
2145
2150
  required: false;
2146
2151
  default: any[];
2147
2152
  };
2153
+ expandOnClickNode: {
2154
+ type: BooleanConstructor;
2155
+ required: false;
2156
+ default: boolean;
2157
+ };
2148
2158
  render: {
2149
2159
  type: FunctionConstructor;
2150
2160
  required: false;
@@ -2160,6 +2170,7 @@ export declare const ZnTreeFilter: import("../../types").SFCWithInstall<import("
2160
2170
  defaultExpandAll: boolean;
2161
2171
  defaultValue: any;
2162
2172
  multiple: boolean;
2173
+ expandOnClickNode: boolean;
2163
2174
  requestParams: any;
2164
2175
  transformDataToTree: boolean;
2165
2176
  defaultExpandKeys: any;
@@ -60,6 +60,11 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
60
60
  required: false;
61
61
  default: any[];
62
62
  };
63
+ expandOnClickNode: {
64
+ type: BooleanConstructor;
65
+ required: false;
66
+ default: boolean;
67
+ };
63
68
  render: {
64
69
  type: FunctionConstructor;
65
70
  required: false;
@@ -2145,6 +2150,11 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
2145
2150
  required: false;
2146
2151
  default: any[];
2147
2152
  };
2153
+ expandOnClickNode: {
2154
+ type: BooleanConstructor;
2155
+ required: false;
2156
+ default: boolean;
2157
+ };
2148
2158
  render: {
2149
2159
  type: FunctionConstructor;
2150
2160
  required: false;
@@ -2160,6 +2170,7 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
2160
2170
  defaultExpandAll: boolean;
2161
2171
  defaultValue: any;
2162
2172
  multiple: boolean;
2173
+ expandOnClickNode: boolean;
2163
2174
  requestParams: any;
2164
2175
  transformDataToTree: boolean;
2165
2176
  defaultExpandKeys: any;
@@ -1,8 +1,8 @@
1
- import{defineComponent as e,ref as t,onBeforeMount as l,watch as a,nextTick as d,resolveComponent as r,createElementBlock as u,openBlock as i,normalizeStyle as n,createCommentVNode as s,createElementVNode as o,createVNode as c,toDisplayString as p,renderSlot as f,withCtx as h,unref as m,createBlock as y,resolveDynamicComponent as k,normalizeProps as v,mergeProps as g,guardReactiveProps as x,createTextVNode as q}from"vue";import{ElTree as b}from"element-plus";import"../../../functions/index.mjs";import V from"../../../functions/modules/uitls.mjs";var A=Object.defineProperty,C=(e,t)=>A(e,"name",{value:t,configurable:!0});const _={key:0,class:"title sle"},w={class:"flex gap-10"},S={key:1,class:"el-tree-node__label"};var K=e({name:"ZnTreeFilter",__name:"index",props:{requestApi:{type:Function,required:!1},requestParams:{required:!1,default:{}},data:{type:Array,required:!1},title:{type:String,required:!1},id:{type:String,required:!1,default:"id"},label:{type:String,required:!1,default:"label"},multiple:{type:Boolean,required:!1,default:!1},defaultValue:{required:!1},transformDataToTree:{type:Boolean,required:!1,default:!0},width:{type:String,required:!1,default:"400px"},height:{type:String,required:!1,default:"600px"},defaultExpandAll:{type:Boolean,required:!1,default:!0},defaultExpandKeys:{required:!1,default:[]},render:{type:Function,required:!1}},emits:["dataReady","change"],setup(e,{expose:A,emit:K}){const T=e,B={children:"children",label:T.label},D=t(),E=t([]),L=t([]),N=K,P=t(),R=C((()=>{T.multiple?P.value=Array.isArray(T.defaultValue)?T.defaultValue:[T.defaultValue]:P.value="string"==typeof T.defaultValue?T.defaultValue:""}),"setSelected"),$=C((async()=>{if(T.requestApi){const e=await T.requestApi(T.requestParams);let t=e.result.list??e.result;t.map(((e,t)=>{e.id||(e.id=`${e.treeLevel}-${t}`)})),T.transformDataToTree?E.value=V.treeListUtil(t):E.value=t,L.value=[...E.value],N("dataReady",t)}}),"getList");l((()=>{R(),$()})),a((()=>T.requestParams),(e=>{e&&$()}),{deep:!0}),a((()=>T.defaultValue),(()=>d((()=>R()))),{deep:!0,immediate:!0}),a((()=>T.data),(()=>{T.data?.length&&(E.value=T.data,L.value=[...T.data])}),{deep:!0,immediate:!0});const j=t("");a(j,(e=>{D.value.filter(e)}));const F=C(((e,t,l)=>{if(!e)return!0;let a=l.parent,d=[l.label],r=1;for(;r<l.level;)d=[...d,a.label],a=a.parent,r++;return d.some((t=>-1!==t.indexOf(e)))}),"filterNode"),O=C((e=>{T.multiple||N("change",e[T.id],e)}),"handleNodeClick"),U=C((()=>{N("change",D.value?.getCheckedNodes())}),"handleCheckChange"),z=C((e=>{D.value?.setCheckedKeys(e)}),"setCheckedKeys");return A({treeData:E,treeAllData:L,treeRef:D,setCheckedKeys:z,getList:$}),(t,l)=>{const a=r("el-input"),d=r("el-scrollbar");return i(),u("div",{class:"zn-tree-filter",style:n({width:e.width,height:e.height})},[e.title?(i(),u("h4",_,p(e.title),1
2
- /* TEXT */)):s("v-if",!0),o("div",w,[c(a,{modelValue:j.value,"onUpdate:modelValue":l[0]||(l[0]=e=>j.value=e),placeholder:"输入关键字进行过滤",clearable:""},null,8,["modelValue"]),f(t.$slots,"toolButton")]),c(d,{style:n({height:e.title?"calc(100% - 95px)":"calc(100% - 56px)"})},{default:h((()=>[c(m(b),{ref_key:"treeRef",ref:D,"default-expand-all":e.defaultExpandAll,"node-key":e.id,data:e.multiple?E.value:L.value,"show-checkbox":e.multiple,"check-strictly":!1,"current-node-key":e.multiple?"":P.value,"highlight-current":!e.multiple,"expand-on-click-node":!1,"check-on-click-node":e.multiple,props:B,"filter-node-method":F,"default-checked-keys":e.multiple?P.value:[],"default-expanded-keys":e.defaultExpandKeys,onNodeClick:O,onCheck:U},{default:h((e=>[T.data?(i(),y(k(T.render),v(g({key:0},e)),null,16
3
- /* FULL_PROPS */)):(i(),u("span",S,[f(t.$slots,"default",v(x(e)),(()=>[q(p(e.node.label),1
1
+ import{defineComponent as e,ref as t,onBeforeMount as l,watch as a,nextTick as d,resolveComponent as r,createElementBlock as u,openBlock as i,normalizeStyle as n,createCommentVNode as o,createElementVNode as s,createVNode as c,toDisplayString as p,renderSlot as f,withCtx as h,unref as y,createBlock as m,resolveDynamicComponent as k,normalizeProps as v,mergeProps as g,guardReactiveProps as x,createTextVNode as q}from"vue";import{ElTree as b}from"element-plus";import"../../../functions/index.mjs";import C from"../../../functions/modules/uitls.mjs";var V=Object.defineProperty,A=(e,t)=>V(e,"name",{value:t,configurable:!0});const _={key:0,class:"title sle"},w={class:"flex gap-10"},N={key:1,class:"el-tree-node__label"};var S=e({name:"ZnTreeFilter",__name:"index",props:{requestApi:{type:Function,required:!1},requestParams:{required:!1,default:{}},data:{type:Array,required:!1},title:{type:String,required:!1},id:{type:String,required:!1,default:"id"},label:{type:String,required:!1,default:"label"},multiple:{type:Boolean,required:!1,default:!1},defaultValue:{required:!1},transformDataToTree:{type:Boolean,required:!1,default:!0},width:{type:String,required:!1,default:"400px"},height:{type:String,required:!1,default:"600px"},defaultExpandAll:{type:Boolean,required:!1,default:!0},defaultExpandKeys:{required:!1,default:[]},expandOnClickNode:{type:Boolean,required:!1,default:!1},render:{type:Function,required:!1}},emits:["dataReady","change"],setup(e,{expose:V,emit:S}){const B=e,K={children:"children",label:B.label},T=t(),D=t([]),E=t([]),L=S,O=t(),P=A((()=>{B.multiple?O.value=Array.isArray(B.defaultValue)?B.defaultValue:[B.defaultValue]:O.value="string"==typeof B.defaultValue?B.defaultValue:""}),"setSelected"),R=A((async()=>{if(B.requestApi){const e=await B.requestApi(B.requestParams);let t=e.result.list??e.result;t.map(((e,t)=>{e.id||(e.id=`${e.treeLevel}-${t}`)})),B.transformDataToTree?D.value=C.treeListUtil(t):D.value=t,E.value=[...D.value],L("dataReady",t)}}),"getList");l((()=>{P(),R()})),a((()=>B.requestParams),(e=>{e&&R()}),{deep:!0}),a((()=>B.defaultValue),(()=>d((()=>P()))),{deep:!0,immediate:!0}),a((()=>B.data),(()=>{B.data?.length&&(D.value=B.data,E.value=[...B.data])}),{deep:!0,immediate:!0});const $=t("");a($,(e=>{T.value.filter(e)}));const j=A(((e,t,l)=>{if(!e)return!0;let a=l.parent,d=[l.label],r=1;for(;r<l.level;)d=[...d,a.label],a=a.parent,r++;return d.some((t=>-1!==t.indexOf(e)))}),"filterNode"),F=A((e=>{B.multiple||L("change",e[B.id],e)}),"handleNodeClick"),U=A((()=>{L("change",T.value?.getCheckedNodes())}),"handleCheckChange"),z=A((e=>{T.value?.setCheckedKeys(e)}),"setCheckedKeys");return V({treeData:D,treeAllData:E,treeRef:T,setCheckedKeys:z,getList:R}),(t,l)=>{const a=r("el-input"),d=r("el-scrollbar");return i(),u("div",{class:"zn-tree-filter",style:n({width:e.width,height:e.height})},[e.title?(i(),u("h4",_,p(e.title),1
2
+ /* TEXT */)):o("v-if",!0),s("div",w,[c(a,{modelValue:$.value,"onUpdate:modelValue":l[0]||(l[0]=e=>$.value=e),placeholder:"输入关键字进行过滤",clearable:""},null,8,["modelValue"]),f(t.$slots,"toolButton")]),c(d,{style:n({height:e.title?"calc(100% - 95px)":"calc(100% - 56px)"})},{default:h((()=>[c(y(b),{ref_key:"treeRef",ref:T,"default-expand-all":e.defaultExpandAll,"node-key":e.id,data:e.multiple?D.value:E.value,"show-checkbox":e.multiple,"check-strictly":!1,"current-node-key":e.multiple?"":O.value,"highlight-current":!e.multiple,"expand-on-click-node":e.expandOnClickNode,"check-on-click-node":e.multiple,props:K,"filter-node-method":j,"default-checked-keys":e.multiple?O.value:[],"default-expanded-keys":e.defaultExpandKeys,onNodeClick:F,onCheck:U},{default:h((e=>[B.data?(i(),m(k(B.render),v(g({key:0},e)),null,16
3
+ /* FULL_PROPS */)):(i(),u("span",N,[f(t.$slots,"default",v(x(e)),(()=>[q(p(e.node.label),1
4
4
  /* TEXT */)]))]))])),_:3
5
- /* FORWARDED */},8,["default-expand-all","node-key","data","show-checkbox","current-node-key","highlight-current","check-on-click-node","default-checked-keys","default-expanded-keys"])])),_:3
5
+ /* FORWARDED */},8,["default-expand-all","node-key","data","show-checkbox","current-node-key","highlight-current","expand-on-click-node","check-on-click-node","default-checked-keys","default-expanded-keys"])])),_:3
6
6
  /* FORWARDED */},8,["style"])],4
7
- /* STYLE */)}}});export{K as default};
7
+ /* STYLE */)}}});export{S as default};
8
8
  //# sourceMappingURL=index.vue2.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.vue2.mjs","sources":["../../../../../../packages/components/znTreeFilter/src/index.vue"],"sourcesContent":["<template>\n <div class=\"zn-tree-filter\" :style=\"{ width, height }\">\n <h4 v-if=\"title\" class=\"title sle\">\n {{ title }}\n </h4>\n <div class=\"flex gap-10\">\n <el-input v-model=\"filterText\" placeholder=\"输入关键字进行过滤\" clearable />\n <slot name=\"toolButton\"></slot>\n </div>\n <el-scrollbar :style=\"{ height: title ? `calc(100% - 95px)` : `calc(100% - 56px)` }\">\n <el-tree\n ref=\"treeRef\"\n :default-expand-all=\"defaultExpandAll\"\n :node-key=\"id\"\n :data=\"multiple ? treeData : treeAllData\"\n :show-checkbox=\"multiple\"\n :check-strictly=\"false\"\n :current-node-key=\"!multiple ? selected : ''\"\n :highlight-current=\"!multiple\"\n :expand-on-click-node=\"false\"\n :check-on-click-node=\"multiple\"\n :props=\"defaultProps\"\n :filter-node-method=\"filterNode\"\n :default-checked-keys=\"multiple ? selected : []\"\n :default-expanded-keys=\"defaultExpandKeys\"\n @node-click=\"handleNodeClick\"\n @check=\"handleCheckChange\">\n <template #default=\"scope\">\n <component :is=\"props.render\" v-bind=\"scope\" v-if=\"props.data\" />\n <span class=\"el-tree-node__label\" v-else>\n <slot v-bind=\"scope\">\n {{ scope.node.label }}\n </slot>\n </span>\n </template>\n </el-tree>\n </el-scrollbar>\n </div>\n</template>\n\n<script setup lang=\"ts\" name=\"ZnTreeFilter\">\n import { nextTick, onBeforeMount, ref, watch, VNode } from 'vue'\n\n import { ElTree } from 'element-plus'\n import { utils } from '../../../functions'\n defineOptions({ name: 'ZnTreeFilter' })\n // 接收父组件参数并设置默认值\n interface TreeFilterProps {\n requestApi?: (data?: any) => Promise<any> /** 请求分类数据的 api ==> 非必传 */\n requestParams?: any /** 请求分类数据的参数 ==> 非必传 */\n data?: { [key: string]: any }[] /** 分类数据,如果有分类数据,则不会执行 api 请求 ==> 非必传 */\n title?: string /** treeFilter 标题 ==> 非必传 */\n id?: string /** 选择的id ==> 非必传,默认为 “id” */\n label?: string /** 显示的label ==> 非必传,默认为 “label” */\n multiple?: boolean /** 是否为多选 ==> 非必传,默认为 false */\n defaultValue?: any /** 默认选中的值 ==> 非必传 */\n transformDataToTree?: boolean /** 是否将数据转换为树形结构 ==> 非必传,默认为 true */\n width?: string /** 默认400px */\n height?: string /** 默认600px */\n defaultExpandAll?: boolean /** 默认全部展开 */\n defaultExpandKeys?: any\n render?: (scope: any) => VNode\n }\n const props = defineProps({\n requestApi: { type: Function, required: false },\n requestParams: { required: false, default: {} },\n data: { type: Array, required: false },\n title: { type: String, required: false },\n id: { type: String, required: false, default: 'id' },\n label: { type: String, required: false, default: 'label' },\n multiple: { type: Boolean, required: false, default: false },\n defaultValue: { required: false },\n transformDataToTree: { type: Boolean, required: false, default: true },\n width: { type: String, required: false, default: '400px' },\n height: { type: String, required: false, default: '600px' },\n defaultExpandAll: { type: Boolean, required: false, default: true },\n defaultExpandKeys: { required: false, default: [] },\n render: { type: Function, required: false }\n})\n\n const defaultProps = {\n children: 'children',\n label: props.label\n }\n\n const treeRef = ref<InstanceType<typeof ElTree>>()\n const treeData = ref<{ [key: string]: any }[]>([])\n const treeAllData = ref<{ [key: string]: any }[]>([])\n\n const emits = defineEmits(['dataReady', 'change'])\n\n const selected = ref()\n const setSelected = () => {\n if (props.multiple) selected.value = Array.isArray(props.defaultValue) ? props.defaultValue : [props.defaultValue]\n else selected.value = typeof props.defaultValue === 'string' ? props.defaultValue : ''\n }\n\n const getList = async () => {\n if (props.requestApi) {\n const res = await props.requestApi!(props.requestParams)\n let list = res.result.list ?? res.result\n // 后端说第六层没有id,所以补上 转树形的时候要用到\n list.map((item: any, index: number) => {\n if (!item.id) {\n item.id = `${item.treeLevel}-${index}`\n }\n })\n if (props.transformDataToTree) {\n treeData.value = utils.treeListUtil(list)\n } else {\n treeData.value = list\n }\n // treeAllData.value = [{ id: '', [props.label]: '全部' }, ...treeData.value]\n treeAllData.value = [...treeData.value]\n emits('dataReady', list)\n }\n }\n\n onBeforeMount(() => {\n setSelected()\n getList()\n })\n\n watch(\n () => props.requestParams,\n (val) => {\n if (val) {\n getList()\n }\n },\n {\n deep: true\n }\n )\n\n // 使用 nextTick 防止打包后赋值不生效,开发环境是正常的\n watch(\n () => props.defaultValue,\n () => nextTick(() => setSelected()),\n { deep: true, immediate: true }\n )\n\n watch(\n () => props.data,\n () => {\n if (props.data?.length) {\n treeData.value = props.data\n // treeAllData.value = [{ id: '', [props.label]: '全部' }, ...props.data]\n treeAllData.value = [...props.data]\n }\n },\n { deep: true, immediate: true }\n )\n\n const filterText = ref('')\n watch(filterText, (val) => {\n treeRef.value!.filter(val)\n })\n\n // 过滤\n const filterNode = (value: string, data: { [key: string]: any }, node: any) => {\n if (!value) return true\n let parentNode = node.parent\n let labels = [node.label]\n let level = 1\n while (level < node.level) {\n labels = [...labels, parentNode.label]\n parentNode = parentNode.parent\n level++\n }\n return labels.some((label) => label.indexOf(value) !== -1)\n }\n\n // emit\n // const emit = defineEmits<{\n // change: [value: any],\n // }>()\n\n // 单选\n const handleNodeClick = (data: { [key: string]: any }) => {\n if (props.multiple) return\n emits('change', data[props.id], data)\n }\n\n // 多选\n const handleCheckChange = () => {\n emits('change', treeRef.value?.getCheckedNodes())\n }\n\n const setCheckedKeys = (keys) => {\n treeRef.value?.setCheckedKeys(keys)\n }\n\n // 暴露给父组件使用\n defineExpose({ treeData, treeAllData, treeRef, setCheckedKeys, getList })\n</script>\n\n<style scoped lang=\"scss\"></style>\n"],"names":["props","__props","defaultProps","children","label","treeRef","ref","treeData","treeAllData","emits","__emit","selected","setSelected","__name","multiple","value","Array","isArray","defaultValue","getList","async","requestApi","res","requestParams","list","result","map","item","index","id","treeLevel","transformDataToTree","utils","treeListUtil","onBeforeMount","watch","val","deep","nextTick","immediate","data","length","filterText","filter","filterNode","node","parentNode","parent","labels","level","some","indexOf","handleNodeClick","handleCheckChange","getCheckedNodes","setCheckedKeys","keys","__expose"],"mappings":"+4CA+DE,MAAMA,EAAQC,EAiBRC,EAAe,CACnBC,SAAU,WACVC,MAAOJ,EAAMI,OAGTC,EAAUC,IACVC,EAAWD,EAA8B,IACzCE,EAAcF,EAA8B,IAE5CG,EAAQC,EAERC,EAAWL,IACXM,EAAoBC,GAAA,KACpBb,EAAMc,SAAmBH,EAAAI,MAAQC,MAAMC,QAAQjB,EAAMkB,cAAgBlB,EAAMkB,aAAe,CAAClB,EAAMkB,gBACvFH,MAAsC,iBAAvBf,EAAMkB,aAA4BlB,EAAMkB,aAAe,EAAA,GAFlE,eAKdC,EAAsBN,GAAAO,UAC1B,GAAIpB,EAAMqB,WAAY,CACpB,MAAMC,QAAYtB,EAAMqB,WAAYrB,EAAMuB,eAC1C,IAAIC,EAAOF,EAAIG,OAAOD,MAAQF,EAAIG,OAE7BD,EAAAE,KAAI,CAACC,EAAWC,KACdD,EAAKE,KACRF,EAAKE,GAAK,GAAGF,EAAKG,aAAaF,IAAK,IAGpC5B,EAAM+B,oBACCxB,EAAAQ,MAAQiB,EAAMC,aAAaT,GAEpCjB,EAASQ,MAAQS,EAGnBhB,EAAYO,MAAQ,IAAIR,EAASQ,OACjCN,EAAM,YAAae,EAAI,IAjBX,WAqBhBU,GAAc,KACAtB,IACJO,GAAA,IAGVgB,GACE,IAAMnC,EAAMuB,gBACXa,IACKA,GACMjB,GAAA,GAGZ,CACEkB,MAAM,IAKVF,GACE,IAAMnC,EAAMkB,eACZ,IAAMoB,GAAS,IAAM1B,OACrB,CAAEyB,MAAM,EAAME,WAAW,IAG3BJ,GACE,IAAMnC,EAAMwC,OACZ,KACMxC,EAAMwC,MAAMC,SACdlC,EAASQ,MAAQf,EAAMwC,KAEvBhC,EAAYO,MAAQ,IAAIf,EAAMwC,MAAI,GAGtC,CAAEH,MAAM,EAAME,WAAW,IAGrB,MAAAG,EAAapC,EAAI,IACjB6B,EAAAO,GAAaN,IACT/B,EAAAU,MAAO4B,OAAOP,EAAG,IAI3B,MAAMQ,EAAa/B,GAAA,CAACE,EAAeyB,EAA8BK,KAC3D,IAAC9B,EAAc,OAAA,EACnB,IAAI+B,EAAaD,EAAKE,OAClBC,EAAS,CAACH,EAAKzC,OACf6C,EAAQ,EACL,KAAAA,EAAQJ,EAAKI,OAClBD,EAAS,IAAIA,EAAQF,EAAW1C,OAChC0C,EAAaA,EAAWC,OACxBE,IAEK,OAAAD,EAAOE,MAAM9C,IAAqC,IAA3BA,EAAM+C,QAAQpC,IAAa,GAVxC,cAmBbqC,KAAmBZ,IACnBxC,EAAMc,UACVL,EAAM,SAAU+B,EAAKxC,EAAM6B,IAAKW,EAAI,GAFd,mBAMlBa,EAA0BxC,GAAA,KAC9BJ,EAAM,SAAUJ,EAAQU,OAAOuC,kBAAiB,GADxB,qBAIpBC,KAAkBC,IACdnD,EAAAU,OAAOwC,eAAeC,EAAI,GADb,yBAKvBC,EAAa,CAAElD,WAAUC,cAAaH,UAASkD,iBAAgBpC;;;;;;"}
1
+ {"version":3,"file":"index.vue2.mjs","sources":["../../../../../../packages/components/znTreeFilter/src/index.vue"],"sourcesContent":["<template>\n <div class=\"zn-tree-filter\" :style=\"{ width, height }\">\n <h4 v-if=\"title\" class=\"title sle\">\n {{ title }}\n </h4>\n <div class=\"flex gap-10\">\n <el-input v-model=\"filterText\" placeholder=\"输入关键字进行过滤\" clearable />\n <slot name=\"toolButton\"></slot>\n </div>\n <el-scrollbar :style=\"{ height: title ? `calc(100% - 95px)` : `calc(100% - 56px)` }\">\n <el-tree\n ref=\"treeRef\"\n :default-expand-all=\"defaultExpandAll\"\n :node-key=\"id\"\n :data=\"multiple ? treeData : treeAllData\"\n :show-checkbox=\"multiple\"\n :check-strictly=\"false\"\n :current-node-key=\"!multiple ? selected : ''\"\n :highlight-current=\"!multiple\"\n :expand-on-click-node=\"expandOnClickNode\"\n :check-on-click-node=\"multiple\"\n :props=\"defaultProps\"\n :filter-node-method=\"filterNode\"\n :default-checked-keys=\"multiple ? selected : []\"\n :default-expanded-keys=\"defaultExpandKeys\"\n @node-click=\"handleNodeClick\"\n @check=\"handleCheckChange\">\n <template #default=\"scope\">\n <component :is=\"props.render\" v-bind=\"scope\" v-if=\"props.data\" />\n <span class=\"el-tree-node__label\" v-else>\n <slot v-bind=\"scope\">\n {{ scope.node.label }}\n </slot>\n </span>\n </template>\n </el-tree>\n </el-scrollbar>\n </div>\n</template>\n\n<script setup lang=\"ts\" name=\"ZnTreeFilter\">\n import { nextTick, onBeforeMount, ref, watch, VNode } from 'vue'\n\n import { ElTree } from 'element-plus'\n import { utils } from '../../../functions'\n defineOptions({ name: 'ZnTreeFilter' })\n // 接收父组件参数并设置默认值\n interface TreeFilterProps {\n requestApi?: (data?: any) => Promise<any> /** 请求分类数据的 api ==> 非必传 */\n requestParams?: any /** 请求分类数据的参数 ==> 非必传 */\n data?: { [key: string]: any }[] /** 分类数据,如果有分类数据,则不会执行 api 请求 ==> 非必传 */\n title?: string /** treeFilter 标题 ==> 非必传 */\n id?: string /** 选择的id ==> 非必传,默认为 “id” */\n label?: string /** 显示的label ==> 非必传,默认为 “label” */\n multiple?: boolean /** 是否为多选 ==> 非必传,默认为 false */\n defaultValue?: any /** 默认选中的值 ==> 非必传 */\n transformDataToTree?: boolean /** 是否将数据转换为树形结构 ==> 非必传,默认为 true */\n width?: string /** 默认400px */\n height?: string /** 默认600px */\n defaultExpandAll?: boolean /** 默认全部展开 */\n defaultExpandKeys?: any\n expandOnClickNode?: boolean\n render?: (scope: any) => VNode\n }\n const props = defineProps({\n requestApi: { type: Function, required: false },\n requestParams: { required: false, default: {} },\n data: { type: Array, required: false },\n title: { type: String, required: false },\n id: { type: String, required: false, default: 'id' },\n label: { type: String, required: false, default: 'label' },\n multiple: { type: Boolean, required: false, default: false },\n defaultValue: { required: false },\n transformDataToTree: { type: Boolean, required: false, default: true },\n width: { type: String, required: false, default: '400px' },\n height: { type: String, required: false, default: '600px' },\n defaultExpandAll: { type: Boolean, required: false, default: true },\n defaultExpandKeys: { required: false, default: [] },\n expandOnClickNode: { type: Boolean, required: false, default: false },\n render: { type: Function, required: false }\n})\n\n const defaultProps = {\n children: 'children',\n label: props.label\n }\n\n const treeRef = ref<InstanceType<typeof ElTree>>()\n const treeData = ref<{ [key: string]: any }[]>([])\n const treeAllData = ref<{ [key: string]: any }[]>([])\n\n const emits = defineEmits(['dataReady', 'change'])\n\n const selected = ref()\n const setSelected = () => {\n if (props.multiple) selected.value = Array.isArray(props.defaultValue) ? props.defaultValue : [props.defaultValue]\n else selected.value = typeof props.defaultValue === 'string' ? props.defaultValue : ''\n }\n\n const getList = async () => {\n if (props.requestApi) {\n const res = await props.requestApi!(props.requestParams)\n let list = res.result.list ?? res.result\n // 后端说第六层没有id,所以补上 转树形的时候要用到\n list.map((item: any, index: number) => {\n if (!item.id) {\n item.id = `${item.treeLevel}-${index}`\n }\n })\n if (props.transformDataToTree) {\n treeData.value = utils.treeListUtil(list)\n } else {\n treeData.value = list\n }\n // treeAllData.value = [{ id: '', [props.label]: '全部' }, ...treeData.value]\n treeAllData.value = [...treeData.value]\n emits('dataReady', list)\n }\n }\n\n onBeforeMount(() => {\n setSelected()\n getList()\n })\n\n watch(\n () => props.requestParams,\n (val) => {\n if (val) {\n getList()\n }\n },\n {\n deep: true\n }\n )\n\n // 使用 nextTick 防止打包后赋值不生效,开发环境是正常的\n watch(\n () => props.defaultValue,\n () => nextTick(() => setSelected()),\n { deep: true, immediate: true }\n )\n\n watch(\n () => props.data,\n () => {\n if (props.data?.length) {\n treeData.value = props.data\n // treeAllData.value = [{ id: '', [props.label]: '全部' }, ...props.data]\n treeAllData.value = [...props.data]\n }\n },\n { deep: true, immediate: true }\n )\n\n const filterText = ref('')\n watch(filterText, (val) => {\n treeRef.value!.filter(val)\n })\n\n // 过滤\n const filterNode = (value: string, data: { [key: string]: any }, node: any) => {\n if (!value) return true\n let parentNode = node.parent\n let labels = [node.label]\n let level = 1\n while (level < node.level) {\n labels = [...labels, parentNode.label]\n parentNode = parentNode.parent\n level++\n }\n return labels.some((label) => label.indexOf(value) !== -1)\n }\n\n // emit\n // const emit = defineEmits<{\n // change: [value: any],\n // }>()\n\n // 单选\n const handleNodeClick = (data: { [key: string]: any }) => {\n if (props.multiple) return\n emits('change', data[props.id], data)\n }\n\n // 多选\n const handleCheckChange = () => {\n emits('change', treeRef.value?.getCheckedNodes())\n }\n\n const setCheckedKeys = (keys) => {\n treeRef.value?.setCheckedKeys(keys)\n }\n\n // 暴露给父组件使用\n defineExpose({ treeData, treeAllData, treeRef, setCheckedKeys, getList })\n</script>\n\n<style scoped lang=\"scss\"></style>\n"],"names":["props","__props","defaultProps","children","label","treeRef","ref","treeData","treeAllData","emits","__emit","selected","setSelected","__name","multiple","value","Array","isArray","defaultValue","getList","async","requestApi","res","requestParams","list","result","map","item","index","id","treeLevel","transformDataToTree","utils","treeListUtil","onBeforeMount","watch","val","deep","nextTick","immediate","data","length","filterText","filter","filterNode","node","parentNode","parent","labels","level","some","indexOf","handleNodeClick","handleCheckChange","getCheckedNodes","setCheckedKeys","keys","__expose"],"mappings":"u8CAgEE,MAAMA,EAAQC,EAkBRC,EAAe,CACnBC,SAAU,WACVC,MAAOJ,EAAMI,OAGTC,EAAUC,IACVC,EAAWD,EAA8B,IACzCE,EAAcF,EAA8B,IAE5CG,EAAQC,EAERC,EAAWL,IACXM,EAAoBC,GAAA,KACpBb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W1C,OAChC0C,EAAaA,EAAWC,OACxBE,IAEK,OAAAD,EAAOE,MAAM9C,IAAqC,IAA3BA,EAAM+C,QAAQpC,IAAa,GAVxC,cAmBbqC,KAAmBZ,IACnBxC,EAAMc,UACVL,EAAM,SAAU+B,EAAKxC,EAAM6B,IAAKW,EAAI,GAFd,mBAMlBa,EAA0BxC,GAAA,KAC9BJ,EAAM,SAAUJ,EAAQU,OAAOuC,kBAAiB,GADxB,qBAIpBC,KAAkBC,IACdnD,EAAAU,OAAOwC,eAAeC,EAAI,GADb,yBAKvBC,EAAa,CAAElD,WAAUC,cAAaH,UAASkD,iBAAgBpC;;;;;;"}
@@ -1,19 +1,19 @@
1
- import{defineComponent as e,watch as a,ref as l,computed as o,resolveComponent as r,createElementBlock as p,createCommentVNode as n,openBlock as t,createVNode as u,withCtx as c,Fragment as s,renderList as d,createBlock as i,createElementVNode as m,toDisplayString as h,unref as f,createTextVNode as v,resolveDynamicComponent as y}from"vue";import{Search as g,Delete as b,ArrowDown as V,ArrowUp as M}from"@element-plus/icons-vue";import{useLocalStorage as k}from"@vueuse/core";var P=Object.defineProperty,U=(e,a)=>P(e,"name",{value:a,configurable:!0});const C={key:0,class:"card table-search"},$={class:"operation"};var _=e({__name:"index",props:{columns:{type:Array,required:!1,default:U((()=>[]),"default")},searchParam:{required:!1,default:U((()=>({})),"default")},searchCol:{type:[Number,Object],required:!0},search:{type:Function,required:!0},reset:{type:Function,required:!0},enumMap:{type:Map,required:!1,default:U((()=>new Map),"default")}},setup(e){const P=e,_=k("znyg",{dictMap:{}});a((()=>P.columns),(e=>{console.log("SearchForm 接收到的搜索列:",e)}),{immediate:!0}),a((()=>P.enumMap),(e=>{console.log("SearchForm 接收到的 enumMap:",e),e&&console.log("enumMap 内容:",Array.from(e.entries()))}),{immediate:!0}),a((()=>_.value.dictMap),(e=>{console.log("SearchForm localStorage 字典数据:",e)}),{immediate:!0});const A=U((e=>Array.isArray(e)?e.map((e=>void 0!==e.label&&void 0!==e.value?e:{label:e.name||e.label||e.text||e.title||String(e.value||e.code||e.id),value:e.code||e.value||e.id||e.key})):[]),"formatOptions"),S=U((e=>{if(console.log(`获取 ${e.prop} 的选项数据:`,{dictCode:e.dictCode,searchPropsOptions:e.search?.props?.options,enum:e.enum,enumMapHasProp:!!e.prop&&P.enumMap?.has(e.prop),enumMapData:e.prop?P.enumMap?.get(e.prop):null,localStorageData:e.dictCode?_.value?.dictMap?.[e.dictCode]:null}),e.search?.props?.options&&Array.isArray(e.search.props.options))return console.log(`${e.prop} 使用 search.props.options:`,e.search.props.options),A(e.search.props.options);if(e.enum&&Array.isArray(e.enum))return console.log(`${e.prop} 使用 enum:`,e.enum),A(e.enum);if(e.prop&&P.enumMap&&P.enumMap.has(e.prop)){const a=P.enumMap.get(e.prop);if(console.log(`${e.prop} enumData 详细信息:`,{enumData:a,isArray:Array.isArray(a),length:a?.length,firstItem:a?.[0],stringified:JSON.stringify(a)}),a&&a.length>0){const l=A(a);return console.log(`${e.prop} 使用 enumMap (格式化后):`,l),l}}if(e.dictCode&&_.value?.dictMap?.[e.dictCode]){const a=_.value.dictMap[e.dictCode];return console.log(`${e.prop} 使用 localStorage 字典:`,a),A(a)}return console.log(`${e.prop} 没有找到选项数据`),[]}),"getSelectOptions"),D=U((e=>{if(!e)return 6;const a=e.search?.span||6;return Math.min(a,24)}),"getColSpan"),Y=l(!1),O=o((()=>P.columns.length>3)),q=o((()=>O.value&&Y.value?P.columns.slice(0,3):P.columns));return(a,l)=>{const o=r("el-input"),k=r("el-option"),P=r("el-select"),_=r("el-date-picker"),A=r("el-input-number"),F=r("el-form-item"),x=r("el-col"),j=r("el-button"),w=r("el-icon"),N=r("el-row"),z=r("el-form");return q.value.length?(t(),p("div",C,[u(z,{ref:"formRef",model:e.searchParam},{default:c((()=>[u(N,{gutter:20},{default:c((()=>[(t(!0),p(s,null,d(q.value,((a,r)=>(t(),i(x,{key:a.prop,span:D(a),class:"search-col"},{default:c((()=>[u(F,null,{label:c((()=>[m("span",null,h(`${a.search?.label??a.label}`),1
1
+ import{defineComponent as e,watch as a,ref as l,computed as o,resolveComponent as r,createElementBlock as p,createCommentVNode as t,openBlock as n,createVNode as u,withCtx as c,Fragment as s,renderList as d,createBlock as i,createElementVNode as m,toDisplayString as h,unref as f,createTextVNode as v,resolveDynamicComponent as y}from"vue";import{Search as g,Delete as b,ArrowDown as V,ArrowUp as M}from"@element-plus/icons-vue";import{useLocalStorage as k}from"@vueuse/core";var P=Object.defineProperty,U=(e,a)=>P(e,"name",{value:a,configurable:!0});const C={key:0,class:"card table-search"},$={class:"operation"};var _=e({__name:"index",props:{columns:{type:Array,required:!1,default:U((()=>[]),"default")},searchParam:{required:!1,default:U((()=>({})),"default")},searchCol:{type:[Number,Object],required:!0},search:{type:Function,required:!0},reset:{type:Function,required:!0},enumMap:{type:Map,required:!1,default:U((()=>new Map),"default")}},setup(e){const P=e,_=k("znyg",{dictMap:{}});a((()=>P.columns),(e=>{console.log("SearchForm 接收到的搜索列:",e)}),{immediate:!0}),a((()=>P.enumMap),(e=>{console.log("SearchForm 接收到的 enumMap:",e),e&&console.log("enumMap 内容:",Array.from(e.entries()))}),{immediate:!0}),a((()=>_.value.dictMap),(e=>{console.log("SearchForm localStorage 字典数据:",e)}),{immediate:!0});const A=U((e=>Array.isArray(e)?e.map((e=>void 0!==e.label&&void 0!==e.value?e:{label:e.name||e.label||e.text||e.title||String(e.value||e.code||e.id),value:e.code||e.value||e.id||e.key})):[]),"formatOptions"),S=U((e=>{if(console.log(`获取 ${e.prop} 的选项数据:`,{dictCode:e.dictCode,searchPropsOptions:e.search?.props?.options,enum:e.enum,enumMapHasProp:!!e.prop&&P.enumMap?.has(e.prop),enumMapData:e.prop?P.enumMap?.get(e.prop):null,localStorageData:e.dictCode?_.value?.dictMap?.[e.dictCode]:null}),e.search?.props?.options&&Array.isArray(e.search.props.options))return console.log(`${e.prop} 使用 search.props.options:`,e.search.props.options),A(e.search.props.options);if(e.enum&&Array.isArray(e.enum))return console.log(`${e.prop} 使用 enum:`,e.enum),A(e.enum);if(e.prop&&P.enumMap&&P.enumMap.has(e.prop)){const a=P.enumMap.get(e.prop);if(console.log(`${e.prop} enumData 详细信息:`,{enumData:a,isArray:Array.isArray(a),length:a?.length,firstItem:a?.[0],stringified:JSON.stringify(a)}),a&&a.length>0){const l=A(a);return console.log(`${e.prop} 使用 enumMap (格式化后):`,l),l}}if(e.dictCode&&_.value?.dictMap?.[e.dictCode]){const a=_.value.dictMap[e.dictCode?.toString()];return console.log(`${e.prop} 使用 localStorage 字典:`,a),A(a)}return console.log(`${e.prop} 没有找到选项数据`),[]}),"getSelectOptions"),D=U((e=>{if(!e)return 6;const a=e.search?.span||6;return Math.min(a,24)}),"getColSpan"),Y=l(!1),O=o((()=>P.columns.length>3)),q=o((()=>O.value&&Y.value?P.columns.slice(0,3):P.columns));return(a,l)=>{const o=r("el-input"),k=r("el-option"),P=r("el-select"),_=r("el-date-picker"),A=r("el-input-number"),F=r("el-form-item"),x=r("el-col"),j=r("el-button"),w=r("el-icon"),N=r("el-row"),z=r("el-form");return q.value.length?(n(),p("div",C,[u(z,{ref:"formRef",model:e.searchParam},{default:c((()=>[u(N,{gutter:20},{default:c((()=>[(n(!0),p(s,null,d(q.value,((a,r)=>(n(),i(x,{key:a.prop,span:D(a),class:"search-col"},{default:c((()=>[u(F,null,{label:c((()=>[m("span",null,h(`${a.search?.label??a.label}`),1
2
2
  /* TEXT */),l[1]||(l[1]=m("span",null," :",-1
3
- /* HOISTED */))])),default:c((()=>[a.search?.el&&"input"!==a.search?.el?"select"===a.search?.el?(t(),i(P,{key:1,modelValue:e.searchParam[a.prop],"onUpdate:modelValue":U((l=>e.searchParam[a.prop]=l),"onUpdate:modelValue"),placeholder:`请选择${a.label}`,clearable:""},{default:c((()=>[(t(!0),p(s,null,d(S(a),(e=>(t(),i(k,{key:e.value,label:e.label,value:e.value},null,8,["label","value"])))),128
3
+ /* HOISTED */))])),default:c((()=>[a.search?.el&&"input"!==a.search?.el?"select"===a.search?.el?(n(),i(P,{key:1,modelValue:e.searchParam[a.prop],"onUpdate:modelValue":U((l=>e.searchParam[a.prop]=l),"onUpdate:modelValue"),placeholder:`请选择${a.label}`,clearable:""},{default:c((()=>[(n(!0),p(s,null,d(S(a),(e=>(n(),i(k,{key:e.value,label:e.label,value:e.value},null,8,["label","value"])))),128
4
4
  /* KEYED_FRAGMENT */))])),_:2
5
- /* DYNAMIC */},1032,["modelValue","onUpdate:modelValue","placeholder"])):"date-picker"===a.search?.el?(t(),i(_,{key:2,modelValue:e.searchParam[a.prop],"onUpdate:modelValue":U((l=>e.searchParam[a.prop]=l),"onUpdate:modelValue"),type:"date",placeholder:`请选择${a.label}`,format:"YYYY-MM-DD","value-format":"YYYY-MM-DD"},null,8,["modelValue","onUpdate:modelValue","placeholder"])):"input-number"===a.search?.el?(t(),i(A,{key:3,modelValue:e.searchParam[a.prop],"onUpdate:modelValue":U((l=>e.searchParam[a.prop]=l),"onUpdate:modelValue"),placeholder:`请输入${a.label}`,"controls-position":"right"},null,8,["modelValue","onUpdate:modelValue","placeholder"])):(t(),p(s,{key:4},[n(" 默认使用 input "),u(o,{modelValue:e.searchParam[a.prop],"onUpdate:modelValue":U((l=>e.searchParam[a.prop]=l),"onUpdate:modelValue"),placeholder:`请输入${a.label}`,clearable:""},null,8,["modelValue","onUpdate:modelValue","placeholder"])],2112
6
- /* STABLE_FRAGMENT, DEV_ROOT_FRAGMENT */)):(t(),i(o,{key:0,modelValue:e.searchParam[a.prop],"onUpdate:modelValue":U((l=>e.searchParam[a.prop]=l),"onUpdate:modelValue"),placeholder:`请输入${a.label}`,clearable:""},null,8,["modelValue","onUpdate:modelValue","placeholder"]))])),_:2
5
+ /* DYNAMIC */},1032,["modelValue","onUpdate:modelValue","placeholder"])):"date-picker"===a.search?.el?(n(),i(_,{key:2,modelValue:e.searchParam[a.prop],"onUpdate:modelValue":U((l=>e.searchParam[a.prop]=l),"onUpdate:modelValue"),type:"date",placeholder:`请选择${a.label}`,format:"YYYY-MM-DD","value-format":"YYYY-MM-DD"},null,8,["modelValue","onUpdate:modelValue","placeholder"])):"input-number"===a.search?.el?(n(),i(A,{key:3,modelValue:e.searchParam[a.prop],"onUpdate:modelValue":U((l=>e.searchParam[a.prop]=l),"onUpdate:modelValue"),placeholder:`请输入${a.label}`,"controls-position":"right"},null,8,["modelValue","onUpdate:modelValue","placeholder"])):(n(),p(s,{key:4},[t(" 默认使用 input "),u(o,{modelValue:e.searchParam[a.prop],"onUpdate:modelValue":U((l=>e.searchParam[a.prop]=l),"onUpdate:modelValue"),placeholder:`请输入${a.label}`,clearable:""},null,8,["modelValue","onUpdate:modelValue","placeholder"])],2112
6
+ /* STABLE_FRAGMENT, DEV_ROOT_FRAGMENT */)):(n(),i(o,{key:0,modelValue:e.searchParam[a.prop],"onUpdate:modelValue":U((l=>e.searchParam[a.prop]=l),"onUpdate:modelValue"),placeholder:`请输入${a.label}`,clearable:""},null,8,["modelValue","onUpdate:modelValue","placeholder"]))])),_:2
7
7
  /* DYNAMIC */},1024
8
8
  /* DYNAMIC_SLOTS */)])),_:2
9
9
  /* DYNAMIC */},1032,["span"])))),128
10
10
  /* KEYED_FRAGMENT */)),u(x,{span:D(),class:"search-operation"},{default:c((()=>[m("div",$,[u(j,{type:"primary",icon:f(g),onClick:e.search},{default:c((()=>l[2]||(l[2]=[v("搜索")]))),_:1
11
11
  /* STABLE */},8,["icon","onClick"]),u(j,{icon:f(b),onClick:e.reset},{default:c((()=>l[3]||(l[3]=[v("重置")]))),_:1
12
- /* STABLE */},8,["icon","onClick"]),O.value?(t(),i(j,{key:0,type:"primary",link:"",class:"search-isOpen",onClick:l[0]||(l[0]=e=>Y.value=!Y.value)},{default:c((()=>[v(h(Y.value?"展开":"合并")+" ",1
13
- /* TEXT */),u(w,{class:"el-icon--right"},{default:c((()=>[(t(),i(y(Y.value?f(V):f(M))))])),_:1
12
+ /* STABLE */},8,["icon","onClick"]),O.value?(n(),i(j,{key:0,type:"primary",link:"",class:"search-isOpen",onClick:l[0]||(l[0]=e=>Y.value=!Y.value)},{default:c((()=>[v(h(Y.value?"展开":"合并")+" ",1
13
+ /* TEXT */),u(w,{class:"el-icon--right"},{default:c((()=>[(n(),i(y(Y.value?f(V):f(M))))])),_:1
14
14
  /* STABLE */})])),_:1
15
- /* STABLE */})):n("v-if",!0)])])),_:1
15
+ /* STABLE */})):t("v-if",!0)])])),_:1
16
16
  /* STABLE */},8,["span"])])),_:1
17
17
  /* STABLE */})])),_:1
18
- /* STABLE */},8,["model"])])):n("v-if",!0)}}});export{_ as default};
18
+ /* STABLE */},8,["model"])])):t("v-if",!0)}}});export{_ as default};
19
19
  //# sourceMappingURL=index.vue2.mjs.map