fast-element-plus 1.0.12 → 1.0.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.full.js +4330 -4310
- package/dist/index.full.js.map +1 -1
- package/dist/index.full.min.js +1 -1
- package/dist/index.full.min.js.map +1 -1
- package/dist/index.full.min.mjs +1 -1
- package/dist/index.full.min.mjs.map +1 -1
- package/dist/index.full.mjs +4330 -4310
- package/dist/index.full.mjs.map +1 -1
- package/dist/styles/index.css +6 -6
- package/es/component.mjs +1 -1
- package/es/component.mjs.map +1 -1
- package/es/components/button/index.d.ts +1 -1
- package/es/components/button/index.mjs +1 -1
- package/es/components/button/index.mjs.map +1 -1
- package/es/components/carNumber/index.d.ts +1 -1
- package/es/components/carNumber/index.mjs +1 -1
- package/es/components/carNumber/index.mjs.map +1 -1
- package/es/components/carNumber/src/carNumber.mjs +1 -1
- package/es/components/carNumber/src/carNumber.mjs.map +1 -1
- package/es/components/image/src/image.mjs +1 -1
- package/es/components/image/src/image.mjs.map +1 -1
- package/es/components/inputDialogPage/src/inputDialogPage.d.ts +4 -3
- package/es/components/inputDialogPage/src/inputDialogPage.mjs +1 -1
- package/es/components/inputDialogPage/src/inputDialogPage.mjs.map +1 -1
- package/es/components/select/src/select.d.ts +1 -1
- package/es/components/select/src/select.mjs +1 -1
- package/es/components/select/src/select.mjs.map +1 -1
- package/es/components/selectPage/src/selectPage.d.ts +1 -1
- package/es/components/selectPage/src/selectPage.mjs +1 -1
- package/es/components/selectPage/src/selectPage.mjs.map +1 -1
- package/es/components/selectV2/src/selectV2.d.ts +2 -2
- package/es/components/selectV2/src/selectV2.mjs +1 -1
- package/es/components/selectV2/src/selectV2.mjs.map +1 -1
- package/es/components/table/src/table.d.ts +5 -5
- package/es/components/table/src/table.mjs +1 -1
- package/es/components/table/src/table.mjs.map +1 -1
- package/es/components/table/src/tableSearchFormItem.mjs +1 -1
- package/es/components/table/src/tableSearchFormItem.mjs.map +1 -1
- package/es/components/tree/src/tree.d.ts +3 -3
- package/es/components/tree/src/tree.mjs +1 -1
- package/es/components/tree/src/tree.mjs.map +1 -1
- package/es/components/treeSelect/src/treeSelect.d.ts +4 -4
- package/es/components/treeSelect/src/treeSelect.mjs +1 -1
- package/es/components/treeSelect/src/treeSelect.mjs.map +1 -1
- package/es/version.d.ts +1 -1
- package/es/version.mjs +1 -1
- package/es/version.mjs.map +1 -1
- package/lib/component.js +1 -1
- package/lib/component.js.map +1 -1
- package/lib/components/button/index.d.ts +1 -1
- package/lib/components/button/index.js +1 -1
- package/lib/components/button/index.js.map +1 -1
- package/lib/components/carNumber/index.d.ts +1 -1
- package/lib/components/carNumber/index.js +1 -1
- package/lib/components/carNumber/index.js.map +1 -1
- package/lib/components/carNumber/src/carNumber.js +1 -1
- package/lib/components/carNumber/src/carNumber.js.map +1 -1
- package/lib/components/image/src/image.js +1 -1
- package/lib/components/image/src/image.js.map +1 -1
- package/lib/components/inputDialogPage/src/inputDialogPage.d.ts +4 -3
- package/lib/components/inputDialogPage/src/inputDialogPage.js +1 -1
- package/lib/components/inputDialogPage/src/inputDialogPage.js.map +1 -1
- package/lib/components/select/src/select.d.ts +1 -1
- package/lib/components/select/src/select.js +1 -1
- package/lib/components/select/src/select.js.map +1 -1
- package/lib/components/selectPage/src/selectPage.d.ts +1 -1
- package/lib/components/selectPage/src/selectPage.js +1 -1
- package/lib/components/selectPage/src/selectPage.js.map +1 -1
- package/lib/components/selectV2/src/selectV2.d.ts +2 -2
- package/lib/components/selectV2/src/selectV2.js +1 -1
- package/lib/components/selectV2/src/selectV2.js.map +1 -1
- package/lib/components/table/src/table.d.ts +5 -5
- package/lib/components/table/src/table.js +1 -1
- package/lib/components/table/src/table.js.map +1 -1
- package/lib/components/table/src/tableSearchFormItem.js +1 -1
- package/lib/components/table/src/tableSearchFormItem.js.map +1 -1
- package/lib/components/tree/src/tree.d.ts +3 -3
- package/lib/components/tree/src/tree.js +1 -1
- package/lib/components/tree/src/tree.js.map +1 -1
- package/lib/components/treeSelect/src/treeSelect.d.ts +4 -4
- package/lib/components/treeSelect/src/treeSelect.js +1 -1
- package/lib/components/treeSelect/src/treeSelect.js.map +1 -1
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/lib/version.js.map +1 -1
- package/package.json +1 -1
- package/styles/components/table.scss +6 -6
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{defineComponent as e,reactive as l,ref as a,watch as t,onMounted as o,computed as d,createVNode as i,mergeProps as r,Fragment as
|
|
1
|
+
import{defineComponent as e,reactive as l,ref as a,watch as t,onMounted as o,computed as d,createVNode as i,mergeProps as r,Fragment as s,createTextVNode as u}from"vue";import{selectEmits as n,useGlobalSize as p,ElSelect as c,ElPagination as m,ElOption as f,ElInput as g,ElButton as b}from"element-plus";import{Search as v}from"@element-plus/icons-vue";import{FaSelectOption as h}from"../../select/index.mjs";import{definePropType as y,withDefineType as S,consoleError as V,useProps as x,useEmits as w,useRender as D,addUnit as L,useExpose as C,makeSlots as _}from"@fast-china/utils";import{useVModel as P}from"@vueuse/core";import{isArray as R,isString as A,isNull as B,isNumber as F,isBoolean as I,isObject as z,isFunction as T,isNil as j,isEqual as k}from"lodash-unified";import{SelectProps as N}from"../../select/src/select.mjs";const O={...N,disabled:{type:Boolean,default:void 0},loadingText:{type:String,default:"加载中..."},noMatchText:{type:String,default:"暂无匹配的数据"},noDataText:{type:String,default:"暂无数据"},collapseTags:{type:Boolean,default:!0},collapseTagsTooltip:{type:Boolean,default:!0},modelValue:{type:y([String,Number,Boolean,Object,Array]),default:void 0},label:y([String,Array]),width:{type:[String,Number],default:"100%"},moreDetail:Boolean,props:{type:y(Object),default:()=>({label:"label",hide:"hide",disabled:"disabled",children:"children"})},requestApi:{type:y(Function)},initParam:y([String,Number,Object])},$={...n,"update:modelValue":e=>A(e)||F(e)||I(e)||z(e)||R(e)||B(e),"update:label":e=>A(e)||R(e)||B(e),dataChangeCallBack:e=>R(e),change:(e,l)=>!0},q=/* @__PURE__ */e({name:"FaSelectPage",props:O,emits:$,slots:_(),setup(e,{attrs:y,slots:_,emit:A,expose:B}){const F=P(e,"label",A,{passive:!0}),I=p(),z=l({value:S(),loading:!1,selectorData:S([]),selectedList:S([]),debut:!0,echo:!0,nextRefresh:!1,pageIndex:1,pageSize:15,totalRows:0,searchValue:void 0,defaultSelectorData:S()}),O=a(),$=l=>l?.map(l=>({...l,value:l[e.valueKey],label:T(e.props.label)?e.props.label(l):l[e.props.label??"label"],hide:T(e.props.hide)?e.props.hide(l):l[e.props.hide??"hide"],disabled:T(e.props.disabled)?e.props.disabled(l):l[e.props.disabled??"disabled"],children:T(e.props.children)?$(e.props.children(l)):$(l[e.props.children??"children"])})).filter(e=>!e.hide),q=async l=>{z.loading=!0,z.pageIndex=l??z.pageIndex;const a={...e.initParam??{},pageIndex:z.pageIndex,pageSize:z.pageSize,searchValue:z.searchValue};try{const l=await e.requestApi(a);z.echo=!1,z.totalRows=l.totalRows,z.selectorData=$(l.rows),A("dataChangeCallBack",z.selectorData)}catch(t){V("FaSelectPage",t),z.pageIndex=1,z.totalRows=0,z.selectorData=[]}finally{z.loading=!1}},K=l=>{if(e.multiple){const e=l;if(0===e?.length)return z.value=null,F.value=null,z.selectedList=[],A("update:modelValue",null),void A("change",null,null);const a=z.selectorData.filter(l=>e.includes(l.value));z.value=l,F.value=a.map(e=>e.label),z.selectedList=[...z.selectedList.filter(e=>!a.some(l=>l.value===e.value)),...a].filter(l=>e.includes(l.value)),A("update:modelValue",l),A("change",a,l)}else{if(j(l))return z.value=null,F.value=null,z.selectedList=[],A("update:modelValue",null),void A("change",null,null);const e=z.selectorData.find(e=>e.value===l);z.value=l,F.value=e.label,z.selectedList.some(e=>e.value===l)||(z.selectedList=[e]),A("update:modelValue",l),A("change",e,l)}},M=()=>{z.value=null,F.value=null,z.selectedList=[],A("update:modelValue",null),A("clear")},U=async e=>{e&&(z.debut?(z.debut=!1,await q()):z.nextRefresh&&(z.nextRefresh=!1,await q())),A("visible-change",e)};t(()=>e.modelValue,l=>{if(z.echo&&!j(l)){const a=!j(e.label);if(e.multiple){if(!R(l))return void V("FaSelectPage","当启用 multiple 时,传入的 modelValue 必须是Array。");if(a&&!R(e.label))return void V("FaSelectPage","当启用 multiple 时,传入的 modelValue:label 必须是Array。");z.selectedList=l.slice(0,e.multipleLimit>0?e.multipleLimit:l.length).map((l,t)=>({value:l,label:a?e.label[t]:void 0}))}else{if(R(l))return void V("FaSelectPage","当禁用 multiple 时,传入的 modelValue 不能是Array。");if(a&&R(e.label))return void V("FaSelectPage","当禁用 multiple 时,传入的 modelValue:label 不能是Array。");z.defaultSelectorData={value:l,label:e.label}}}z.value=l},{immediate:!0}),o(()=>{t(()=>e.initParam,(e,l)=>{k(e,l)||(z.nextRefresh=!0,j(z.value)||K())})});const E=x(e,N,["modelValue","popperClass","loading"]),G=w(n,A,["update:modelValue","change","clear","visible-change"]),H=d(()=>{let l=`fa-select-page-dropdown fa-select-page-dropdown-${I.value} ${e.popperClass}`;return e.moreDetail&&(l+=` fa-select-dropdown__more-detail fa-select-dropdown__more-detail-${I.value}`),l});return D(()=>i(c,r(E.value,G.value,{ref:O,class:"fa-select-page",popperClass:H.value,style:{width:L(e.width)},modelValue:z.value,"onUpdate:modelValue":e=>z.value=e,loading:z.loading,onChange:K,onClear:M,onVisibleChange:U}),{default:()=>z.selectorData.map(l=>i(h,{data:l,moreDetail:e.moreDetail},{default:_.default})),header:()=>i(s,null,[z.defaultSelectorData&&i(f,{class:"fa-select-page-dropdown__default-selector",value:z.defaultSelectorData.value,label:z.defaultSelectorData.label,disabled:!0},{default:()=>[i("span",null,[z.defaultSelectorData.label]),i("span",null,[u("Default")])]}),i(g,{class:"fa-select-page-dropdown__search-input",clearable:!0,placeholder:"请输入关键字搜索",modelValue:z.searchValue,modelModifiers:{trim:!0},"onUpdate:modelValue":e=>z.searchValue=e,onKeyup:e=>{"Enter"===e.key&&q(1)}},{append:()=>i(b,{loading:z.loading,icon:v,onClick:()=>q(1)},null)}),_.header&&_.header()]),footer:()=>i(s,null,[i(m,{class:"fa-select-page-dropdown__pagination",size:"small",currentPage:z.pageIndex,pageSize:z.pageSize,total:z.totalRows,layout:"prev, pager, next, total",pagerCount:5,onCurrentChange:q},null),_.footer&&_.footer()]),..._.prefix&&{prefix:()=>_.prefix()},..._.empty&&{empty:()=>_.empty()},..._.tag&&{tag:()=>_.tag()},..._.loading&&{loading:()=>_.loading()},...e.multiple?{label:({label:e,value:l})=>{const a=z.selectedList.find(e=>e.value===l);return _.label?_.label({label:a?.label,value:j(a)?l:a?.value}):a&&i("span",{class:"el-select__tags-text"},[a.label])}}:_.label&&{label:({label:e,value:l})=>_.label({label:e,value:l})}})),C(B,{focus:d(()=>O.value?.focus),blur:d(()=>O.value?.blur),selectedLabel:d(()=>O.value?.selectedLabel),loading:d(()=>z.loading),selectedList:d(()=>z.selectedList),refresh:q,setSelection:e=>K(e),clearSelection:()=>K(null)})}});export{q as default,$ as faSelectPageEmits,O as faSelectPageProps};
|
|
2
2
|
//# sourceMappingURL=selectPage.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"selectPage.mjs","sources":["../../../../../packages/components/selectPage/src/selectPage.tsx"],"sourcesContent":["import { Fragment, computed, defineComponent, onMounted, reactive, ref, watch } from \"vue\";\nimport { ElButton, ElInput, ElOption, ElPagination, ElSelect, selectEmits, useGlobalSize } from \"element-plus\";\nimport { Search } from \"@element-plus/icons-vue\";\nimport { FaSelectOption, SelectProps } from \"@fast-element-plus/components/select\";\nimport { type SelectComponentProps } from \"@fast-element-plus/components/select/src/select\";\nimport { addUnit, consoleError, definePropType, makeSlots, useEmits, useExpose, useProps, useRender, withDefineType } from \"@fast-china/utils\";\nimport { useVModel } from \"@vueuse/core\";\nimport { isArray, isBoolean, isEqual, isFunction, isNil, isNull, isNumber, isObject, isString } from \"lodash-unified\";\nimport type { ElSelectorOutput } from \"@fast-element-plus/components/select\";\nimport type { PagedInput, PagedResult } from \"@fast-element-plus/components/table\";\nimport type { VNode } from \"vue\";\n\nexport const faSelectPageProps = {\n\t...SelectProps,\n\t/** @description whether Select is disabled 重载使其支持 ElForm*/\n\tdisabled: {\n\t\ttype: Boolean,\n\t\tdefault: undefined,\n\t},\n\t/** @description displayed text while loading data from server, default is 'Loading' */\n\tloadingText: {\n\t\ttype: String,\n\t\tdefault: \"加载中...\",\n\t},\n\t/** @description displayed text when no data matches the filtering query, you can also use slot `empty`, default is 'No matching data' */\n\tnoMatchText: {\n\t\ttype: String,\n\t\tdefault: \"暂无匹配的数据\",\n\t},\n\t/** @description displayed text when there is no options, you can also use slot `empty`, default is 'No data' */\n\tnoDataText: {\n\t\ttype: String,\n\t\tdefault: \"暂无数据\",\n\t},\n\t/** @description whether to collapse tags to a text when multiple selecting */\n\tcollapseTags: {\n\t\ttype: Boolean,\n\t\tdefault: true,\n\t},\n\t/** @description whether show all selected tags when mouse hover text of collapse-tags. To use this, `collapse-tags` must be true */\n\tcollapseTagsTooltip: {\n\t\ttype: Boolean,\n\t\tdefault: true,\n\t},\n\t/** @description v-model绑定值 */\n\tmodelValue: {\n\t\ttype: definePropType<string | number | boolean | object | (string | number | boolean | object)[]>([String, Number, Boolean, Object, Array]),\n\t\tdefault: undefined,\n\t},\n\t/** @description v-model:label绑定值 */\n\tlabel: definePropType<string | string[]>([String, Array]),\n\t/** @description 宽度 */\n\twidth: {\n\t\ttype: [String, Number],\n\t\tdefault: \"100%\",\n\t},\n\t/** @description 更多细节,只有使用slot的时候有用 */\n\tmoreDetail: Boolean,\n\t/** @description 配置选项 */\n\tprops: {\n\t\ttype: definePropType<SelectComponentProps>(Object),\n\t\tdefault: (): Partial<SelectComponentProps> => ({\n\t\t\tlabel: \"label\",\n\t\t\thide: \"hide\",\n\t\t\tdisabled: \"disabled\",\n\t\t\tchildren: \"children\",\n\t\t}),\n\t},\n\t/** @description 请求api */\n\trequestApi: {\n\t\ttype: definePropType<(params?: PagedInput) => Promise<PagedResult<ElSelectorOutput>>>(Function),\n\t},\n\t/** 初始化参数 */\n\tinitParam: definePropType<string | number | any>([String, Number, Object]),\n};\n\nexport const faSelectPageEmits = {\n\t...selectEmits,\n\t/** @description v-model 回调 */\n\t\"update:modelValue\": (value: string | number | boolean | object | (string | number | boolean | object)[]): boolean =>\n\t\tisString(value) || isNumber(value) || isBoolean(value) || isObject(value) || isArray(value) || isNull(value),\n\t/** @description v-model:label 回调 */\n\t\"update:label\": (value: string | string[]): boolean => isString(value) || isArray(value) || isNull(value),\n\t/** @description 数据改变 */\n\tdataChangeCallBack: (data: ElSelectorOutput[] | any[]): boolean => isArray(data),\n\t/** @description 改变 */\n\tchange: (\n\t\tdata: ElSelectorOutput | ElSelectorOutput[] | any | any[],\n\t\tvalue?: string | number | boolean | object | (string | number | boolean | object)[]\n\t): boolean => true,\n};\n\ntype FaSelectPageSlots = {\n\t/** @description FaSelectOption 默认内容插槽 */\n\tdefault: ElSelectorOutput;\n\t/** @description 下拉列表顶部的内容 */\n\theader: never;\n\t/** @description 下拉列表底部的内容 */\n\tfooter: never;\n\t/** @description Select 组件头部内容 */\n\tprefix: never;\n\t/** @description 无选项时的列表 */\n\tempty: never;\n\t/** @description select 组件自定义标签内容 */\n\ttag: never;\n\t/** @description select 组件自定义 loading内容 */\n\tloading: never;\n\t/** @description select 组件自定义标签内容 */\n\tlabel: { label: string; value: string | number | boolean | object };\n};\n\nexport default defineComponent({\n\tname: \"FaSelectPage\",\n\tprops: faSelectPageProps,\n\temits: faSelectPageEmits,\n\tslots: makeSlots<FaSelectPageSlots>(),\n\tsetup(props, { attrs, slots, emit, expose }) {\n\t\tconst selectedLabel = useVModel(props, \"label\", emit);\n\t\tconst _globalSize = useGlobalSize();\n\n\t\tconst state = reactive({\n\t\t\tvalue: withDefineType<string | number | boolean | object | (string | number | boolean | object)[]>(),\n\t\t\tloading: false,\n\t\t\tselectorData: withDefineType<ElSelectorOutput[]>([]),\n\t\t\t/** 选中的数据 */\n\t\t\tselectedList: withDefineType<ElSelectorOutput[]>([]),\n\t\t\t/** 首次出现 */\n\t\t\tdebut: true,\n\t\t\t/** 回显 */\n\t\t\techo: true,\n\t\t\t/** 下次刷新 */\n\t\t\tnextRefresh: false,\n\t\t\tpageIndex: 1,\n\t\t\tpageSize: 15,\n\t\t\ttotalRows: 0,\n\t\t\tsearchValue: undefined,\n\t\t\tdefaultSelectorData: withDefineType<ElSelectorOutput>(),\n\t\t});\n\n\t\tconst selectRef = ref<InstanceType<typeof ElSelect>>();\n\n\t\tconst handleData = (data: ElSelectorOutput[]): ElSelectorOutput[] => {\n\t\t\treturn data\n\t\t\t\t?.map((m) => ({\n\t\t\t\t\t...m,\n\t\t\t\t\tvalue: m[props.valueKey],\n\t\t\t\t\tlabel: isFunction(props.props.label) ? props.props.label(m) : m[props.props.label ?? \"label\"],\n\t\t\t\t\thide: isFunction(props.props.hide) ? props.props.hide(m) : m[props.props.hide ?? \"hide\"],\n\t\t\t\t\tdisabled: isFunction(props.props.disabled) ? props.props.disabled(m) : m[props.props.disabled ?? \"disabled\"],\n\t\t\t\t\tchildren: isFunction(props.props.children)\n\t\t\t\t\t\t? handleData(props.props.children(m))\n\t\t\t\t\t\t: handleData(m[props.props.children ?? \"children\"]),\n\t\t\t\t}))\n\t\t\t\t.filter((f) => !f.hide);\n\t\t};\n\n\t\tconst loadData = async (pageIndex?: number): Promise<void> => {\n\t\t\tstate.loading = true;\n\t\t\tstate.pageIndex = pageIndex ?? state.pageIndex;\n\t\t\tconst params: PagedInput = {\n\t\t\t\t...(props.initParam ?? {}),\n\t\t\t\tpageIndex: state.pageIndex,\n\t\t\t\tpageSize: state.pageSize,\n\t\t\t\tsearchValue: state.searchValue,\n\t\t\t};\n\t\t\ttry {\n\t\t\t\tconst resData = await props.requestApi(params);\n\t\t\t\t// 这里不允许回显了\n\t\t\t\tstate.echo = false;\n\t\t\t\tstate.totalRows = resData.totalRows;\n\t\t\t\tstate.selectorData = handleData(resData.rows);\n\t\t\t\temit(\"dataChangeCallBack\", state.selectorData);\n\t\t\t} catch (error) {\n\t\t\t\tconsoleError(\"FaSelectPage\", error);\n\t\t\t\tstate.pageIndex = 1;\n\t\t\t\tstate.totalRows = 0;\n\t\t\t\tstate.selectorData = [];\n\t\t\t} finally {\n\t\t\t\tstate.loading = false;\n\t\t\t}\n\t\t};\n\n\t\tconst handleChange = (value?: string | number | boolean | object | (string | number | boolean | object)[]): void => {\n\t\t\t// 判断是否为多选\n\t\t\tif (props.multiple) {\n\t\t\t\t// value 必然是数组\n\t\t\t\tconst valueArr = value as (string | number | boolean | object)[];\n\t\t\t\tif (valueArr?.length === 0) {\n\t\t\t\t\tstate.value = null;\n\t\t\t\t\tselectedLabel.value = null;\n\t\t\t\t\tstate.selectedList = [];\n\t\t\t\t\temit(\"update:modelValue\", null);\n\t\t\t\t\temit(\"change\", null, null);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst dataList = state.selectorData.filter((f) => valueArr.includes(f.value));\n\t\t\t\tstate.value = value;\n\t\t\t\tselectedLabel.value = dataList.map((m) => m.label);\n\t\t\t\tstate.selectedList = [...state.selectedList.filter((f) => !dataList.some((s) => s.value === f.value)), ...dataList]\n\t\t\t\t\t// 过滤不存在的\n\t\t\t\t\t.filter((f) => valueArr.includes(f.value));\n\t\t\t\temit(\"update:modelValue\", value);\n\t\t\t\temit(\"change\", dataList, value);\n\t\t\t} else {\n\t\t\t\t// value 必然不是数组\n\t\t\t\tif (isNil(value)) {\n\t\t\t\t\tstate.value = null;\n\t\t\t\t\tselectedLabel.value = null;\n\t\t\t\t\tstate.selectedList = [];\n\t\t\t\t\temit(\"update:modelValue\", null);\n\t\t\t\t\temit(\"change\", null, null);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst data = state.selectorData.find((f) => f.value === value);\n\t\t\t\tstate.value = value;\n\t\t\t\tselectedLabel.value = data.label;\n\t\t\t\tif (!state.selectedList.some((s) => s.value === value)) {\n\t\t\t\t\tstate.selectedList = [data];\n\t\t\t\t}\n\t\t\t\temit(\"update:modelValue\", value);\n\t\t\t\temit(\"change\", data, value);\n\t\t\t}\n\t\t};\n\n\t\tconst handleClear = (): void => {\n\t\t\tstate.value = null;\n\t\t\tselectedLabel.value = null;\n\t\t\tstate.selectedList = [];\n\t\t\temit(\"update:modelValue\", null);\n\t\t\temit(\"clear\");\n\t\t};\n\n\t\tconst handleVisibleChange = async (visible: boolean): Promise<void> => {\n\t\t\tif (visible) {\n\t\t\t\tif (state.debut) {\n\t\t\t\t\t// 首次出现\n\t\t\t\t\tstate.debut = false;\n\t\t\t\t\tawait loadData();\n\t\t\t\t} else {\n\t\t\t\t\t// 判断再次出现是否需要刷新数据\n\t\t\t\t\tif (state.nextRefresh) {\n\t\t\t\t\t\tstate.nextRefresh = false;\n\t\t\t\t\t\tawait loadData();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\temit(\"visible-change\", visible);\n\t\t};\n\n\t\twatch(\n\t\t\t() => props.modelValue,\n\t\t\t(newValue) => {\n\t\t\t\tif (state.echo && !isNil(newValue)) {\n\t\t\t\t\tconst hasLabel = !isNil(props.label);\n\t\t\t\t\t// 判断是否为多选\n\t\t\t\t\tif (props.multiple) {\n\t\t\t\t\t\tif (!isArray(newValue)) {\n\t\t\t\t\t\t\tconsoleError(\"FaSelectPage\", \"当启用 multiple 时,传入的 modelValue 必须是Array。\");\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (hasLabel && !isArray(props.label)) {\n\t\t\t\t\t\t\tconsoleError(\"FaSelectPage\", \"当启用 multiple 时,传入的 modelValue:label 必须是Array。\");\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tstate.selectedList = newValue\n\t\t\t\t\t\t\t// 最大选项截取\n\t\t\t\t\t\t\t.slice(0, props.multipleLimit > 0 ? props.multipleLimit : newValue.length)\n\t\t\t\t\t\t\t.map((item, index) => ({\n\t\t\t\t\t\t\t\tvalue: item,\n\t\t\t\t\t\t\t\tlabel: hasLabel ? props.label[index] : undefined,\n\t\t\t\t\t\t\t}));\n\t\t\t\t\t} else {\n\t\t\t\t\t\tif (isArray(newValue)) {\n\t\t\t\t\t\t\tconsoleError(\"FaSelectPage\", \"当禁用 multiple 时,传入的 modelValue 不能是Array。\");\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (hasLabel && isArray(props.label)) {\n\t\t\t\t\t\t\tconsoleError(\"FaSelectPage\", \"当禁用 multiple 时,传入的 modelValue:label 不能是Array。\");\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tstate.defaultSelectorData = {\n\t\t\t\t\t\t\tvalue: newValue,\n\t\t\t\t\t\t\tlabel: props.label,\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tstate.value = newValue;\n\t\t\t},\n\t\t\t{\n\t\t\t\timmediate: true,\n\t\t\t}\n\t\t);\n\n\t\tonMounted(() => {\n\t\t\twatch(\n\t\t\t\t() => props.initParam,\n\t\t\t\t(newValue, oldValue) => {\n\t\t\t\t\tif (!isEqual(newValue, oldValue)) {\n\t\t\t\t\t\tstate.nextRefresh = true;\n\t\t\t\t\t\tif (!isNil(state.value)) {\n\t\t\t\t\t\t\thandleChange();\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t);\n\t\t});\n\n\t\tconst elSelectProps = useProps(props, SelectProps, [\"modelValue\", \"popperClass\", \"loading\"]);\n\t\tconst elSelectEmits = useEmits(selectEmits, emit, [\"update:modelValue\", \"change\", \"clear\", \"visible-change\"]);\n\t\tconst elPopperClass = computed(() => {\n\t\t\tlet localClass = `fa-select-page-dropdown fa-select-page-dropdown-${_globalSize.value} ${props.popperClass}`;\n\t\t\tif (props.moreDetail) {\n\t\t\t\tlocalClass += ` fa-select-dropdown__more-detail fa-select-dropdown__more-detail-${_globalSize.value}`;\n\t\t\t}\n\t\t\treturn localClass;\n\t\t});\n\n\t\tuseRender(() => (\n\t\t\t<ElSelect\n\t\t\t\t{...elSelectProps.value}\n\t\t\t\t{...elSelectEmits.value}\n\t\t\t\tref={selectRef}\n\t\t\t\tclass=\"fa-select-page\"\n\t\t\t\tpopperClass={elPopperClass.value}\n\t\t\t\tstyle={{ width: addUnit(props.width) }}\n\t\t\t\tvModel={state.value}\n\t\t\t\tloading={state.loading}\n\t\t\t\tonChange={handleChange}\n\t\t\t\tonClear={handleClear}\n\t\t\t\tonVisibleChange={handleVisibleChange}\n\t\t\t>\n\t\t\t\t{{\n\t\t\t\t\tdefault: (): VNode[] =>\n\t\t\t\t\t\tstate.selectorData.map((item) => (\n\t\t\t\t\t\t\t<FaSelectOption vSlots={{ default: slots.default }} data={item} moreDetail={props.moreDetail} />\n\t\t\t\t\t\t)),\n\t\t\t\t\theader: (): VNode[] => (\n\t\t\t\t\t\t<Fragment>\n\t\t\t\t\t\t\t{state.defaultSelectorData && (\n\t\t\t\t\t\t\t\t<ElOption\n\t\t\t\t\t\t\t\t\tclass=\"fa-select-page-dropdown__default-selector\"\n\t\t\t\t\t\t\t\t\tvalue={state.defaultSelectorData.value}\n\t\t\t\t\t\t\t\t\tlabel={state.defaultSelectorData.label}\n\t\t\t\t\t\t\t\t\tdisabled={true}\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<span>{state.defaultSelectorData.label}</span>\n\t\t\t\t\t\t\t\t\t<span>Default</span>\n\t\t\t\t\t\t\t\t</ElOption>\n\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t<ElInput\n\t\t\t\t\t\t\t\t\tclass=\"fa-select-page-dropdown__search-input\"\n\t\t\t\t\t\t\t\t\tclearable\n\t\t\t\t\t\t\t\t\tplaceholder=\"请输入关键字搜索\"\n\t\t\t\t\t\t\t\t\tvModel_trim={state.searchValue}\n\t\t\t\t\t\t\t\t\tonKeyup={(event: KeyboardEvent) => {\n\t\t\t\t\t\t\t\t\t\tif (event.key === \"Enter\") {\n\t\t\t\t\t\t\t\t\t\t\tloadData(1);\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{{\n\t\t\t\t\t\t\t\t\t\tappend: () => <ElButton loading={state.loading} icon={Search} onClick={() => loadData(1)}></ElButton>,\n\t\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\t</ElInput>\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t{slots.header && slots.header()}\n\t\t\t\t\t\t</Fragment>\n\t\t\t\t\t),\n\t\t\t\t\tfooter: () => (\n\t\t\t\t\t\t<Fragment>\n\t\t\t\t\t\t\t<ElPagination\n\t\t\t\t\t\t\t\tclass=\"fa-select-page-dropdown__pagination\"\n\t\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\t\tcurrentPage={state.pageIndex}\n\t\t\t\t\t\t\t\tpageSize={state.pageSize}\n\t\t\t\t\t\t\t\ttotal={state.totalRows}\n\t\t\t\t\t\t\t\tlayout=\"prev, pager, next, total\"\n\t\t\t\t\t\t\t\tpagerCount={5}\n\t\t\t\t\t\t\t\tonCurrentChange={loadData}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t{slots.footer && slots.footer()}\n\t\t\t\t\t\t</Fragment>\n\t\t\t\t\t),\n\t\t\t\t\t...(slots.prefix && { prefix: (): VNode[] => slots.prefix() }),\n\t\t\t\t\t...(slots.empty && { empty: (): VNode[] => slots.empty() }),\n\t\t\t\t\t...(slots.tag && { tag: (): VNode[] => slots.tag() }),\n\t\t\t\t\t...(slots.loading && { loading: (): VNode[] => slots.loading() }),\n\t\t\t\t\t...(props.multiple\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\tlabel: ({ label, value }: { label: string; value: string | number | boolean | object }): VNode[] => {\n\t\t\t\t\t\t\t\t\tconst selectedData = state.selectedList.find((f) => f.value === value);\n\t\t\t\t\t\t\t\t\tif (slots.label) {\n\t\t\t\t\t\t\t\t\t\treturn slots.label({ label: selectedData?.label, value: isNil(selectedData) ? value : selectedData?.value });\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\treturn selectedData && <span class=\"el-select__tags-text\">{selectedData.label}</span>;\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t: slots.label && {\n\t\t\t\t\t\t\t\tlabel: ({ label, value }: { label: string; value: string | number | boolean | object }): VNode[] =>\n\t\t\t\t\t\t\t\t\tslots.label({ label, value }),\n\t\t\t\t\t\t\t}),\n\t\t\t\t}}\n\t\t\t</ElSelect>\n\t\t));\n\n\t\treturn useExpose(expose, {\n\t\t\t/** @description 使选择器的输入框获取焦点 */\n\t\t\tfocus: computed(() => selectRef.value?.focus),\n\t\t\t/** @description 使选择器的输入框失去焦点,并隐藏下拉框 */\n\t\t\tblur: computed(() => selectRef.value?.blur),\n\t\t\t/** @description 获取当前选中的标签 */\n\t\t\tselectedLabel: computed(() => selectRef.value?.selectedLabel),\n\t\t\t/** @description 加载状态 */\n\t\t\tloading: computed(() => state.loading),\n\t\t\t/** @description 选中的数据 */\n\t\t\tselectedList: computed(() => state.selectedList),\n\t\t\t/** @description 刷新 */\n\t\t\trefresh: loadData,\n\t\t\t/** @description 设置选择 */\n\t\t\tsetSelection: (value: string | number | boolean | object | (string | number | boolean | object)[]) => handleChange(value),\n\t\t\t/** @description 清除选择 */\n\t\t\tclearSelection: () => handleChange(null),\n\t\t});\n\t},\n});\n"],"names":["faSelectPageProps","SelectProps","disabled","type","Boolean","default","undefined","loadingText","String","noMatchText","noDataText","collapseTags","collapseTagsTooltip","modelValue","definePropType","Number","Object","Array","label","width","moreDetail","props","hide","children","requestApi","Function","initParam","faSelectPageEmits","selectEmits","value","isString","isNumber","isBoolean","isObject","isArray","isNull","dataChangeCallBack","data","change","SelectPage","name","emits","slots","makeSlots","setup","attrs","emit","expose","selectedLabel","useVModel","_globalSize","useGlobalSize","state","reactive","withDefineType","loading","selectorData","selectedList","debut","echo","nextRefresh","pageIndex","pageSize","totalRows","searchValue","defaultSelectorData","selectRef","ref","handleData","map","m","valueKey","isFunction","filter","f","loadData","async","params","resData","rows","error","consoleError","handleChange","multiple","valueArr","length","dataList","includes","some","s","isNil","find","handleClear","handleVisibleChange","visible","watch","newValue","hasLabel","slice","multipleLimit","item","index","immediate","onMounted","oldValue","isEqual","elSelectProps","useProps","elSelectEmits","useEmits","elPopperClass","computed","localClass","popperClass","useRender","_createVNode","ElSelect","_mergeProps","class","style","addUnit","$event","onChange","onClear","onVisibleChange","FaSelectOption","header","_Fragment","ElOption","_createTextVNode","ElInput","clearable","placeholder","modelModifiers","trim","onKeyup","event","key","append","ElButton","icon","Search","onClick","footer","ElPagination","size","currentPage","total","layout","pagerCount","onCurrentChange","prefix","empty","tag","selectedData","useExpose","focus","blur","refresh","setSelection","clearSelection"],"mappings":"i0BAYO,MAAMA,EAAoB,IAC7BC,EAEHC,SAAU,CACTC,KAAMC,QACNC,aAASC,GAGVC,YAAa,CACZJ,KAAMK,OACNH,QAAS,UAGVI,YAAa,CACZN,KAAMK,OACNH,QAAS,WAGVK,WAAY,CACXP,KAAMK,OACNH,QAAS,QAGVM,aAAc,CACbR,KAAMC,QACNC,SAAS,GAGVO,oBAAqB,CACpBT,KAAMC,QACNC,SAAS,GAGVQ,WAAY,CACXV,KAAMW,EAA4F,CAACN,OAAQO,OAAQX,QAASY,OAAQC,QACpIZ,aAASC,GAGVY,MAAOJ,EAAkC,CAACN,OAAQS,QAElDE,MAAO,CACNhB,KAAM,CAACK,OAAQO,QACfV,QAAS,QAGVe,WAAYhB,QAEZiB,MAAO,CACNlB,KAAMW,EAAqCE,QAC3CX,QAASA,KAAAA,CACRa,MAAO,QACPI,KAAM,OACNpB,SAAU,WACVqB,SAAU,cAIZC,WAAY,CACXrB,KAAMW,EAAgFW,WAGvFC,UAAWZ,EAAsC,CAACN,OAAQO,O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,EAAUrC,OAAOgI,MAEtC7G,cAAe+D,EAAS,IAAM7C,EAAUrC,OAAOmB,eAE/CO,QAASwD,EAAS,IAAM3D,EAAMG,SAE9BE,aAAcsD,EAAS,IAAM3D,EAAMK,cAEnCqG,QAASnF,EAEToF,aAAelI,GAAuFqD,EAAarD,GAEnHmI,eAAgBA,IAAM9E,EAAa,OAErC"}
|
|
1
|
+
{"version":3,"file":"selectPage.mjs","sources":["../../../../../packages/components/selectPage/src/selectPage.tsx"],"sourcesContent":["import { Fragment, computed, defineComponent, onMounted, reactive, ref, watch } from \"vue\";\nimport { ElButton, ElInput, ElOption, ElPagination, ElSelect, selectEmits, useGlobalSize } from \"element-plus\";\nimport { Search } from \"@element-plus/icons-vue\";\nimport { FaSelectOption, SelectProps } from \"@fast-element-plus/components/select\";\nimport { type SelectComponentProps } from \"@fast-element-plus/components/select/src/select\";\nimport { addUnit, consoleError, definePropType, makeSlots, useEmits, useExpose, useProps, useRender, withDefineType } from \"@fast-china/utils\";\nimport { useVModel } from \"@vueuse/core\";\nimport { isArray, isBoolean, isEqual, isFunction, isNil, isNull, isNumber, isObject, isString } from \"lodash-unified\";\nimport type { ElSelectorOutput } from \"@fast-element-plus/components/select\";\nimport type { PagedInput, PagedResult } from \"@fast-element-plus/components/table\";\nimport type { VNode } from \"vue\";\n\nexport const faSelectPageProps = {\n\t...SelectProps,\n\t/** @description whether Select is disabled 重载使其支持 ElForm*/\n\tdisabled: {\n\t\ttype: Boolean,\n\t\tdefault: undefined,\n\t},\n\t/** @description displayed text while loading data from server, default is 'Loading' */\n\tloadingText: {\n\t\ttype: String,\n\t\tdefault: \"加载中...\",\n\t},\n\t/** @description displayed text when no data matches the filtering query, you can also use slot `empty`, default is 'No matching data' */\n\tnoMatchText: {\n\t\ttype: String,\n\t\tdefault: \"暂无匹配的数据\",\n\t},\n\t/** @description displayed text when there is no options, you can also use slot `empty`, default is 'No data' */\n\tnoDataText: {\n\t\ttype: String,\n\t\tdefault: \"暂无数据\",\n\t},\n\t/** @description whether to collapse tags to a text when multiple selecting */\n\tcollapseTags: {\n\t\ttype: Boolean,\n\t\tdefault: true,\n\t},\n\t/** @description whether show all selected tags when mouse hover text of collapse-tags. To use this, `collapse-tags` must be true */\n\tcollapseTagsTooltip: {\n\t\ttype: Boolean,\n\t\tdefault: true,\n\t},\n\t/** @description v-model绑定值 */\n\tmodelValue: {\n\t\ttype: definePropType<string | number | boolean | object | (string | number | boolean | object)[]>([String, Number, Boolean, Object, Array]),\n\t\tdefault: undefined,\n\t},\n\t/** @description v-model:label绑定值 */\n\tlabel: definePropType<string | string[]>([String, Array]),\n\t/** @description 宽度 */\n\twidth: {\n\t\ttype: [String, Number],\n\t\tdefault: \"100%\",\n\t},\n\t/** @description 更多细节,只有使用slot的时候有用 */\n\tmoreDetail: Boolean,\n\t/** @description 配置选项 */\n\tprops: {\n\t\ttype: definePropType<SelectComponentProps>(Object),\n\t\tdefault: (): Partial<SelectComponentProps> => ({\n\t\t\tlabel: \"label\",\n\t\t\thide: \"hide\",\n\t\t\tdisabled: \"disabled\",\n\t\t\tchildren: \"children\",\n\t\t}),\n\t},\n\t/** @description 请求api */\n\trequestApi: {\n\t\ttype: definePropType<(params?: PagedInput) => Promise<PagedResult<ElSelectorOutput>>>(Function),\n\t},\n\t/** 初始化参数 */\n\tinitParam: definePropType<string | number | any>([String, Number, Object]),\n};\n\nexport const faSelectPageEmits = {\n\t...selectEmits,\n\t/** @description v-model 回调 */\n\t\"update:modelValue\": (value: string | number | boolean | object | (string | number | boolean | object)[]): boolean =>\n\t\tisString(value) || isNumber(value) || isBoolean(value) || isObject(value) || isArray(value) || isNull(value),\n\t/** @description v-model:label 回调 */\n\t\"update:label\": (value: string | string[]): boolean => isString(value) || isArray(value) || isNull(value),\n\t/** @description 数据改变 */\n\tdataChangeCallBack: (data: ElSelectorOutput[] | any[]): boolean => isArray(data),\n\t/** @description 改变 */\n\tchange: (\n\t\tdata: ElSelectorOutput | ElSelectorOutput[] | any | any[],\n\t\tvalue?: string | number | boolean | object | (string | number | boolean | object)[]\n\t): boolean => true,\n};\n\ntype FaSelectPageSlots = {\n\t/** @description FaSelectOption 默认内容插槽 */\n\tdefault: ElSelectorOutput;\n\t/** @description 下拉列表顶部的内容 */\n\theader: never;\n\t/** @description 下拉列表底部的内容 */\n\tfooter: never;\n\t/** @description Select 组件头部内容 */\n\tprefix: never;\n\t/** @description 无选项时的列表 */\n\tempty: never;\n\t/** @description select 组件自定义标签内容 */\n\ttag: never;\n\t/** @description select 组件自定义 loading内容 */\n\tloading: never;\n\t/** @description select 组件自定义标签内容 */\n\tlabel: { label: string; value: string | number | boolean | object };\n};\n\nexport default defineComponent({\n\tname: \"FaSelectPage\",\n\tprops: faSelectPageProps,\n\temits: faSelectPageEmits,\n\tslots: makeSlots<FaSelectPageSlots>(),\n\tsetup(props, { attrs, slots, emit, expose }) {\n\t\tconst selectedLabel = useVModel(props, \"label\", emit, { passive: true });\n\t\tconst _globalSize = useGlobalSize();\n\n\t\tconst state = reactive({\n\t\t\tvalue: withDefineType<string | number | boolean | object | (string | number | boolean | object)[]>(),\n\t\t\tloading: false,\n\t\t\tselectorData: withDefineType<ElSelectorOutput[]>([]),\n\t\t\t/** 选中的数据 */\n\t\t\tselectedList: withDefineType<ElSelectorOutput[]>([]),\n\t\t\t/** 首次出现 */\n\t\t\tdebut: true,\n\t\t\t/** 回显 */\n\t\t\techo: true,\n\t\t\t/** 下次刷新 */\n\t\t\tnextRefresh: false,\n\t\t\tpageIndex: 1,\n\t\t\tpageSize: 15,\n\t\t\ttotalRows: 0,\n\t\t\tsearchValue: undefined,\n\t\t\tdefaultSelectorData: withDefineType<ElSelectorOutput>(),\n\t\t});\n\n\t\tconst selectRef = ref<InstanceType<typeof ElSelect>>();\n\n\t\tconst handleData = (data: ElSelectorOutput[]): ElSelectorOutput[] => {\n\t\t\treturn data\n\t\t\t\t?.map((m) => ({\n\t\t\t\t\t...m,\n\t\t\t\t\tvalue: m[props.valueKey],\n\t\t\t\t\tlabel: isFunction(props.props.label) ? props.props.label(m) : m[props.props.label ?? \"label\"],\n\t\t\t\t\thide: isFunction(props.props.hide) ? props.props.hide(m) : m[props.props.hide ?? \"hide\"],\n\t\t\t\t\tdisabled: isFunction(props.props.disabled) ? props.props.disabled(m) : m[props.props.disabled ?? \"disabled\"],\n\t\t\t\t\tchildren: isFunction(props.props.children)\n\t\t\t\t\t\t? handleData(props.props.children(m))\n\t\t\t\t\t\t: handleData(m[props.props.children ?? \"children\"]),\n\t\t\t\t}))\n\t\t\t\t.filter((f) => !f.hide);\n\t\t};\n\n\t\tconst loadData = async (pageIndex?: number): Promise<void> => {\n\t\t\tstate.loading = true;\n\t\t\tstate.pageIndex = pageIndex ?? state.pageIndex;\n\t\t\tconst params: PagedInput = {\n\t\t\t\t...(props.initParam ?? {}),\n\t\t\t\tpageIndex: state.pageIndex,\n\t\t\t\tpageSize: state.pageSize,\n\t\t\t\tsearchValue: state.searchValue,\n\t\t\t};\n\t\t\ttry {\n\t\t\t\tconst resData = await props.requestApi(params);\n\t\t\t\t// 这里不允许回显了\n\t\t\t\tstate.echo = false;\n\t\t\t\tstate.totalRows = resData.totalRows;\n\t\t\t\tstate.selectorData = handleData(resData.rows);\n\t\t\t\temit(\"dataChangeCallBack\", state.selectorData);\n\t\t\t} catch (error) {\n\t\t\t\tconsoleError(\"FaSelectPage\", error);\n\t\t\t\tstate.pageIndex = 1;\n\t\t\t\tstate.totalRows = 0;\n\t\t\t\tstate.selectorData = [];\n\t\t\t} finally {\n\t\t\t\tstate.loading = false;\n\t\t\t}\n\t\t};\n\n\t\tconst handleChange = (value?: string | number | boolean | object | (string | number | boolean | object)[]): void => {\n\t\t\t// 判断是否为多选\n\t\t\tif (props.multiple) {\n\t\t\t\t// value 必然是数组\n\t\t\t\tconst valueArr = value as (string | number | boolean | object)[];\n\t\t\t\tif (valueArr?.length === 0) {\n\t\t\t\t\tstate.value = null;\n\t\t\t\t\tselectedLabel.value = null;\n\t\t\t\t\tstate.selectedList = [];\n\t\t\t\t\temit(\"update:modelValue\", null);\n\t\t\t\t\temit(\"change\", null, null);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst dataList = state.selectorData.filter((f) => valueArr.includes(f.value));\n\t\t\t\tstate.value = value;\n\t\t\t\tselectedLabel.value = dataList.map((m) => m.label);\n\t\t\t\tstate.selectedList = [...state.selectedList.filter((f) => !dataList.some((s) => s.value === f.value)), ...dataList]\n\t\t\t\t\t// 过滤不存在的\n\t\t\t\t\t.filter((f) => valueArr.includes(f.value));\n\t\t\t\temit(\"update:modelValue\", value);\n\t\t\t\temit(\"change\", dataList, value);\n\t\t\t} else {\n\t\t\t\t// value 必然不是数组\n\t\t\t\tif (isNil(value)) {\n\t\t\t\t\tstate.value = null;\n\t\t\t\t\tselectedLabel.value = null;\n\t\t\t\t\tstate.selectedList = [];\n\t\t\t\t\temit(\"update:modelValue\", null);\n\t\t\t\t\temit(\"change\", null, null);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst data = state.selectorData.find((f) => f.value === value);\n\t\t\t\tstate.value = value;\n\t\t\t\tselectedLabel.value = data.label;\n\t\t\t\tif (!state.selectedList.some((s) => s.value === value)) {\n\t\t\t\t\tstate.selectedList = [data];\n\t\t\t\t}\n\t\t\t\temit(\"update:modelValue\", value);\n\t\t\t\temit(\"change\", data, value);\n\t\t\t}\n\t\t};\n\n\t\tconst handleClear = (): void => {\n\t\t\tstate.value = null;\n\t\t\tselectedLabel.value = null;\n\t\t\tstate.selectedList = [];\n\t\t\temit(\"update:modelValue\", null);\n\t\t\temit(\"clear\");\n\t\t};\n\n\t\tconst handleVisibleChange = async (visible: boolean): Promise<void> => {\n\t\t\tif (visible) {\n\t\t\t\tif (state.debut) {\n\t\t\t\t\t// 首次出现\n\t\t\t\t\tstate.debut = false;\n\t\t\t\t\tawait loadData();\n\t\t\t\t} else {\n\t\t\t\t\t// 判断再次出现是否需要刷新数据\n\t\t\t\t\tif (state.nextRefresh) {\n\t\t\t\t\t\tstate.nextRefresh = false;\n\t\t\t\t\t\tawait loadData();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\temit(\"visible-change\", visible);\n\t\t};\n\n\t\twatch(\n\t\t\t() => props.modelValue,\n\t\t\t(newValue) => {\n\t\t\t\tif (state.echo && !isNil(newValue)) {\n\t\t\t\t\tconst hasLabel = !isNil(props.label);\n\t\t\t\t\t// 判断是否为多选\n\t\t\t\t\tif (props.multiple) {\n\t\t\t\t\t\tif (!isArray(newValue)) {\n\t\t\t\t\t\t\tconsoleError(\"FaSelectPage\", \"当启用 multiple 时,传入的 modelValue 必须是Array。\");\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (hasLabel && !isArray(props.label)) {\n\t\t\t\t\t\t\tconsoleError(\"FaSelectPage\", \"当启用 multiple 时,传入的 modelValue:label 必须是Array。\");\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tstate.selectedList = newValue\n\t\t\t\t\t\t\t// 最大选项截取\n\t\t\t\t\t\t\t.slice(0, props.multipleLimit > 0 ? props.multipleLimit : newValue.length)\n\t\t\t\t\t\t\t.map((item, index) => ({\n\t\t\t\t\t\t\t\tvalue: item,\n\t\t\t\t\t\t\t\tlabel: hasLabel ? props.label[index] : undefined,\n\t\t\t\t\t\t\t}));\n\t\t\t\t\t} else {\n\t\t\t\t\t\tif (isArray(newValue)) {\n\t\t\t\t\t\t\tconsoleError(\"FaSelectPage\", \"当禁用 multiple 时,传入的 modelValue 不能是Array。\");\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (hasLabel && isArray(props.label)) {\n\t\t\t\t\t\t\tconsoleError(\"FaSelectPage\", \"当禁用 multiple 时,传入的 modelValue:label 不能是Array。\");\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tstate.defaultSelectorData = {\n\t\t\t\t\t\t\tvalue: newValue,\n\t\t\t\t\t\t\tlabel: props.label,\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tstate.value = newValue;\n\t\t\t},\n\t\t\t{\n\t\t\t\timmediate: true,\n\t\t\t}\n\t\t);\n\n\t\tonMounted(() => {\n\t\t\twatch(\n\t\t\t\t() => props.initParam,\n\t\t\t\t(newValue, oldValue) => {\n\t\t\t\t\tif (!isEqual(newValue, oldValue)) {\n\t\t\t\t\t\tstate.nextRefresh = true;\n\t\t\t\t\t\tif (!isNil(state.value)) {\n\t\t\t\t\t\t\thandleChange();\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t);\n\t\t});\n\n\t\tconst elSelectProps = useProps(props, SelectProps, [\"modelValue\", \"popperClass\", \"loading\"]);\n\t\tconst elSelectEmits = useEmits(selectEmits, emit, [\"update:modelValue\", \"change\", \"clear\", \"visible-change\"]);\n\t\tconst elPopperClass = computed(() => {\n\t\t\tlet localClass = `fa-select-page-dropdown fa-select-page-dropdown-${_globalSize.value} ${props.popperClass}`;\n\t\t\tif (props.moreDetail) {\n\t\t\t\tlocalClass += ` fa-select-dropdown__more-detail fa-select-dropdown__more-detail-${_globalSize.value}`;\n\t\t\t}\n\t\t\treturn localClass;\n\t\t});\n\n\t\tuseRender(() => (\n\t\t\t<ElSelect\n\t\t\t\t{...elSelectProps.value}\n\t\t\t\t{...elSelectEmits.value}\n\t\t\t\tref={selectRef}\n\t\t\t\tclass=\"fa-select-page\"\n\t\t\t\tpopperClass={elPopperClass.value}\n\t\t\t\tstyle={{ width: addUnit(props.width) }}\n\t\t\t\tvModel={state.value}\n\t\t\t\tloading={state.loading}\n\t\t\t\tonChange={handleChange}\n\t\t\t\tonClear={handleClear}\n\t\t\t\tonVisibleChange={handleVisibleChange}\n\t\t\t>\n\t\t\t\t{{\n\t\t\t\t\tdefault: (): VNode[] =>\n\t\t\t\t\t\tstate.selectorData.map((item) => (\n\t\t\t\t\t\t\t<FaSelectOption vSlots={{ default: slots.default }} data={item} moreDetail={props.moreDetail} />\n\t\t\t\t\t\t)),\n\t\t\t\t\theader: (): VNode[] => (\n\t\t\t\t\t\t<Fragment>\n\t\t\t\t\t\t\t{state.defaultSelectorData && (\n\t\t\t\t\t\t\t\t<ElOption\n\t\t\t\t\t\t\t\t\tclass=\"fa-select-page-dropdown__default-selector\"\n\t\t\t\t\t\t\t\t\tvalue={state.defaultSelectorData.value}\n\t\t\t\t\t\t\t\t\tlabel={state.defaultSelectorData.label}\n\t\t\t\t\t\t\t\t\tdisabled={true}\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<span>{state.defaultSelectorData.label}</span>\n\t\t\t\t\t\t\t\t\t<span>Default</span>\n\t\t\t\t\t\t\t\t</ElOption>\n\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t<ElInput\n\t\t\t\t\t\t\t\t\tclass=\"fa-select-page-dropdown__search-input\"\n\t\t\t\t\t\t\t\t\tclearable\n\t\t\t\t\t\t\t\t\tplaceholder=\"请输入关键字搜索\"\n\t\t\t\t\t\t\t\t\tvModel_trim={state.searchValue}\n\t\t\t\t\t\t\t\t\tonKeyup={(event: KeyboardEvent) => {\n\t\t\t\t\t\t\t\t\t\tif (event.key === \"Enter\") {\n\t\t\t\t\t\t\t\t\t\t\tloadData(1);\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{{\n\t\t\t\t\t\t\t\t\t\tappend: () => <ElButton loading={state.loading} icon={Search} onClick={() => loadData(1)}></ElButton>,\n\t\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\t</ElInput>\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t{slots.header && slots.header()}\n\t\t\t\t\t\t</Fragment>\n\t\t\t\t\t),\n\t\t\t\t\tfooter: () => (\n\t\t\t\t\t\t<Fragment>\n\t\t\t\t\t\t\t<ElPagination\n\t\t\t\t\t\t\t\tclass=\"fa-select-page-dropdown__pagination\"\n\t\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\t\tcurrentPage={state.pageIndex}\n\t\t\t\t\t\t\t\tpageSize={state.pageSize}\n\t\t\t\t\t\t\t\ttotal={state.totalRows}\n\t\t\t\t\t\t\t\tlayout=\"prev, pager, next, total\"\n\t\t\t\t\t\t\t\tpagerCount={5}\n\t\t\t\t\t\t\t\tonCurrentChange={loadData}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t{slots.footer && slots.footer()}\n\t\t\t\t\t\t</Fragment>\n\t\t\t\t\t),\n\t\t\t\t\t...(slots.prefix && { prefix: (): VNode[] => slots.prefix() }),\n\t\t\t\t\t...(slots.empty && { empty: (): VNode[] => slots.empty() }),\n\t\t\t\t\t...(slots.tag && { tag: (): VNode[] => slots.tag() }),\n\t\t\t\t\t...(slots.loading && { loading: (): VNode[] => slots.loading() }),\n\t\t\t\t\t...(props.multiple\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\tlabel: ({ label, value }: { label: string; value: string | number | boolean | object }): VNode[] => {\n\t\t\t\t\t\t\t\t\tconst selectedData = state.selectedList.find((f) => f.value === value);\n\t\t\t\t\t\t\t\t\tif (slots.label) {\n\t\t\t\t\t\t\t\t\t\treturn slots.label({ label: selectedData?.label, value: isNil(selectedData) ? value : selectedData?.value });\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\treturn selectedData && <span class=\"el-select__tags-text\">{selectedData.label}</span>;\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t: slots.label && {\n\t\t\t\t\t\t\t\tlabel: ({ label, value }: { label: string; value: string | number | boolean | object }): VNode[] =>\n\t\t\t\t\t\t\t\t\tslots.label({ label, value }),\n\t\t\t\t\t\t\t}),\n\t\t\t\t}}\n\t\t\t</ElSelect>\n\t\t));\n\n\t\treturn useExpose(expose, {\n\t\t\t/** @description 使选择器的输入框获取焦点 */\n\t\t\tfocus: computed(() => selectRef.value?.focus),\n\t\t\t/** @description 使选择器的输入框失去焦点,并隐藏下拉框 */\n\t\t\tblur: computed(() => selectRef.value?.blur),\n\t\t\t/** @description 获取当前选中的标签 */\n\t\t\tselectedLabel: computed(() => selectRef.value?.selectedLabel),\n\t\t\t/** @description 加载状态 */\n\t\t\tloading: computed(() => state.loading),\n\t\t\t/** @description 选中的数据 */\n\t\t\tselectedList: computed(() => state.selectedList),\n\t\t\t/** @description 刷新 */\n\t\t\trefresh: loadData,\n\t\t\t/** @description 设置选择 */\n\t\t\tsetSelection: (value: string | number | boolean | object | (string | number | boolean | object)[]) => handleChange(value),\n\t\t\t/** @description 清除选择 */\n\t\t\tclearSelection: () => handleChange(null),\n\t\t});\n\t},\n});\n"],"names":["faSelectPageProps","SelectProps","disabled","type","Boolean","default","undefined","loadingText","String","noMatchText","noDataText","collapseTags","collapseTagsTooltip","modelValue","definePropType","Number","Object","Array","label","width","moreDetail","props","hide","children","requestApi","Function","initParam","faSelectPageEmits","selectEmits","value","isString","isNumber","isBoolean","isObject","isArray","isNull","dataChangeCallBack","data","change","SelectPage","name","emits","slots","makeSlots","setup","attrs","emit","expose","selectedLabel","useVModel","passive","_globalSize","useGlobalSize","state","reactive","withDefineType","loading","selectorData","selectedList","debut","echo","nextRefresh","pageIndex","pageSize","totalRows","searchValue","defaultSelectorData","selectRef","ref","handleData","map","m","valueKey","isFunction","filter","f","loadData","async","params","resData","rows","error","consoleError","handleChange","multiple","valueArr","length","dataList","includes","some","s","isNil","find","handleClear","handleVisibleChange","visible","watch","newValue","hasLabel","slice","multipleLimit","item","index","immediate","onMounted","oldValue","isEqual","elSelectProps","useProps","elSelectEmits","useEmits","elPopperClass","computed","localClass","popperClass","useRender","_createVNode","ElSelect","_mergeProps","class","style","addUnit","$event","onChange","onClear","onVisibleChange","FaSelectOption","header","_Fragment","ElOption","_createTextVNode","ElInput","clearable","placeholder","modelModifiers","trim","onKeyup","event","key","append","ElButton","icon","Search","onClick","footer","ElPagination","size","currentPage","total","layout","pagerCount","onCurrentChange","prefix","empty","tag","selectedData","useExpose","focus","blur","refresh","setSelection","clearSelection"],"mappings":"i0BAYO,MAAMA,EAAoB,IAC7BC,EAEHC,SAAU,CACTC,KAAMC,QACNC,aAASC,GAGVC,YAAa,CACZJ,KAAMK,OACNH,QAAS,UAGVI,YAAa,CACZN,KAAMK,OACNH,QAAS,WAGVK,WAAY,CACXP,KAAMK,OACNH,QAAS,QAGVM,aAAc,CACbR,KAAMC,QACNC,SAAS,GAGVO,oBAAqB,CACpBT,KAAMC,QACNC,SAAS,GAGVQ,WAAY,CACXV,KAAMW,EAA4F,CAACN,OAAQO,OAAQX,QAASY,OAAQC,QACpIZ,aAASC,GAGVY,MAAOJ,EAAkC,CAACN,OAAQS,QAElDE,MAAO,CACNhB,KAAM,CAACK,OAAQO,QACfV,QAAS,QAGVe,WAAYhB,QAEZiB,MAAO,CACNlB,KAAMW,EAAqCE,QAC3CX,QAASA,KAAAA,CACRa,MAAO,QACPI,KAAM,OACNpB,SAAU,WACVqB,SAAU,cAIZC,WAAY,CACXrB,KAAMW,EAAgFW,WAGvFC,UAAWZ,EAAsC,CAACN,OAAQO,OAAQC,UAGtDW,EAAoB,IAC7BC,EAEH,oBAAsBC,GACrBC,EAASD,IAAUE,EAASF,IAAUG,EAAUH,IAAUI,EAASJ,IAAUK,EAAQL,IAAUM,EAAON,GAEvG,kBAAuDC,EAASD,IAAUK,EAAQL,IAAUM,EAAON,GAEnGO,mBAAqBC,GAA8CH,EAAQG,GAE3EC,OAAQA,CACPD,EACAR,KACa,GAsBfU,mBAA+B,CAC9BC,KAAM,eACNnB,MAAOrB,EACPyC,MAAOd,EACPe,MAAOC,IACPC,KAAAA,CAAMvB,GAAOwB,MAAEA,EAAAA,MAAOH,EAAAA,KAAOI,EAAAA,OAAMC,IAClC,MAAMC,EAAgBC,EAAU5B,EAAO,QAASy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UAASqF,OAAA,2BAAAC,WAEV,EAACC,gBACI3E,GAAQ,MAEzBlC,EAAMsG,QAAUtG,EAAMsG,cAGrBtG,EAAM8G,QAAU,CAAEA,OAAQA,IAAe9G,EAAM8G,aAC/C9G,EAAM+G,OAAS,CAAEA,MAAOA,IAAe/G,EAAM+G,YAC7C/G,EAAMgH,KAAO,CAAEA,IAAKA,IAAehH,EAAMgH,UACzChH,EAAMc,SAAW,CAAEA,QAASA,IAAed,EAAMc,cACjDnC,EAAM+D,SACP,CACAlE,MAAOA,EAAGA,QAAOW,YAChB,MAAM8H,EAAetG,EAAMK,aAAakC,KAAMjB,GAAMA,EAAE9C,QAAUA,GAChE,OAAIa,EAAMxB,MACFwB,EAAMxB,MAAM,CAAEA,MAAOyI,GAAczI,MAAOW,MAAO8D,EAAMgE,GAAgB9H,EAAQ8H,GAAc9H,QAE9F8H,GAAYvC,EAAA,OAAA,CAAAG,MAAA,wBAAA,CAAwCoC,EAAazI,UAGzEwB,EAAMxB,OAAS,CACfA,MAAOA,EAAGA,QAAOW,WAChBa,EAAMxB,MAAM,CAAEA,QAAOW,cAMrB+H,EAAU7G,EAAQ,CAExB8G,MAAO7C,EAAS,IAAM7C,EAAUtC,OAAOgI,OAEvCC,KAAM9C,EAAS,IAAM7C,EAAUtC,OAAOiI,MAEtC9G,cAAegE,EAAS,IAAM7C,EAAUtC,OAAOmB,eAE/CQ,QAASwD,EAAS,IAAM3D,EAAMG,SAE9BE,aAAcsD,EAAS,IAAM3D,EAAMK,cAEnCqG,QAASnF,EAEToF,aAAenI,GAAuFsD,EAAatD,GAEnHoI,eAAgBA,IAAM9E,EAAa,OAErC"}
|
|
@@ -1371,6 +1371,7 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
|
|
|
1371
1371
|
persistent: boolean;
|
|
1372
1372
|
height: number;
|
|
1373
1373
|
fallbackPlacements: Placement[];
|
|
1374
|
+
filterable: boolean;
|
|
1374
1375
|
moreDetail: boolean;
|
|
1375
1376
|
loadingText: string;
|
|
1376
1377
|
noMatchText: string;
|
|
@@ -1380,7 +1381,6 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
|
|
|
1380
1381
|
defaultSelected: boolean;
|
|
1381
1382
|
valueOnClear: import('element-plus/es/utils/index.mjs').EpPropMergeType<(new (...args: any[]) => string | number | boolean | Function) | (() => string | number | boolean | Function | null) | ((new (...args: any[]) => string | number | boolean | Function) | (() => string | number | boolean | Function | null))[], unknown, unknown>;
|
|
1382
1383
|
automaticDropdown: boolean;
|
|
1383
|
-
filterable: boolean;
|
|
1384
1384
|
allowCreate: boolean;
|
|
1385
1385
|
remote: boolean;
|
|
1386
1386
|
multiple: boolean;
|
|
@@ -1391,9 +1391,9 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
|
|
|
1391
1391
|
maxCollapseTags: number;
|
|
1392
1392
|
tagType: import('element-plus/es/utils/index.mjs').EpPropMergeType<StringConstructor, "primary" | "success" | "warning" | "info" | "danger", unknown>;
|
|
1393
1393
|
tagEffect: import('element-plus/es/utils/index.mjs').EpPropMergeType<StringConstructor, "plain" | "dark" | "light", unknown>;
|
|
1394
|
-
scrollbarAlwaysOn: boolean;
|
|
1395
1394
|
pageResult: boolean;
|
|
1396
1395
|
estimatedOptionHeight: number;
|
|
1397
1396
|
itemHeight: number;
|
|
1397
|
+
scrollbarAlwaysOn: boolean;
|
|
1398
1398
|
}, import('vue').SlotsType<Partial<import('@fast-china/utils').MakeSlots<FaSelectV2Slots>>>, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
|
|
1399
1399
|
export default _default;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{defineComponent as e,reactive as l,ref as a,watch as t,onMounted as o,computed as i,createVNode as u,mergeProps as n}from"vue";import{useAriaProps as r,useEmptyValuesProps as d,tagProps as p,useSizeProp as s,useTooltipContentProps as c,useGlobalSize as f,ElSelectV2 as m}from"element-plus";import{CircleClose as g}from"@element-plus/icons-vue";import{definePropType as b,withDefineType as y,consoleError as v,useProps as h,useEmits as S,useRender as B,addUnit as V,useExpose as w,makeSlots as x}from"@fast-china/utils";import{useVModel as D}from"@vueuse/core";import{isArray as A,isString as T,isNull as C,isNumber as F,isBoolean as N,isObject as O,isNil as j,isEqual as L}from"lodash-unified";const R={allowCreate:Boolean,autocomplete:{type:b(String),default:"none"},automaticDropdown:Boolean,clearable:Boolean,clearIcon:{type:b([String,Object,Function]),default:g},effect:{type:b(String),default:"light"},collapseTags:Boolean,collapseTagsTooltip:Boolean,maxCollapseTags:{type:Number,default:1},defaultFirstOption:Boolean,disabled:Boolean,estimatedOptionHeight:{type:Number,default:void 0},filterable:Boolean,filterMethod:Function,height:{type:Number,default:274},itemHeight:{type:Number,default:34},id:String,loading:Boolean,loadingText:String,modelValue:{type:b([Array,String,Number,Boolean,Object])},multiple:Boolean,multipleLimit:{type:Number,default:0},name:String,noDataText:String,noMatchText:String,remoteMethod:Function,reserveKeyword:{type:Boolean,default:!0},options:{type:b(Array)},placeholder:{type:String},teleported:c.teleported,persistent:{type:Boolean,default:!0},popperClass:{type:String,default:""},popperOptions:{type:b(Object),default:()=>({})},remote:Boolean,size:s,props:{type:b(Object),default:()=>({label:"label",value:"value",disabled:"disabled",options:"options"})},valueKey:{type:String,default:"value"},scrollbarAlwaysOn:Boolean,validateEvent:{type:Boolean,default:!0},offset:{type:Number,default:12},showArrow:{type:Boolean,default:!0},placement:{type:b(String),default:"bottom-start"},fallbackPlacements:{type:b(Array),default:["bottom-start","top-start","right","left"]},tagType:{...p.type,default:"info"},tagEffect:{...p.effect,default:"light"},tabindex:{type:[String,Number],default:0},appendTo:String,...d,...r(["ariaLabel"])},q={"update:modelValue":e=>!0,change:e=>!0,"remove-tag":e=>!0,"visible-change":e=>!0,focus:e=>!0,blur:e=>!0,clear:()=>!0},H={...R,disabled:{type:Boolean,default:void 0},loadingText:{type:String,default:"加载中..."},noMatchText:{type:String,default:"暂无匹配的数据"},noDataText:{type:String,default:"暂无数据"},collapseTags:{type:Boolean,default:!0},collapseTagsTooltip:{type:Boolean,default:!0},modelValue:{type:b([String,Number,Boolean,Object,Array]),default:void 0},label:b([String,Array]),width:{type:[String,Number],default:"100%"},moreDetail:Boolean,lazy:{type:Boolean,default:!0},defaultSelected:Boolean,data:{type:b(Array),default:()=>[]},pageResult:Boolean,requestApi:{type:b(Function)},initParam:b([String,Number,Object])},z={...q,"update:modelValue":e=>T(e)||F(e)||N(e)||O(e)||A(e)||C(e),"update:label":e=>T(e)||A(e)||C(e),dataChangeCallBack:e=>A(e),change:(e,l)=>!0},M=/* @__PURE__ */e({name:"FaSelectV2",props:H,emits:z,slots:x(),setup(e,{attrs:r,slots:d,emit:p,expose:s}){const c=D(e,"label",p),g=f(),b=l({value:y(),loading:!1,selectorData:y([]),debut:!0,echo:!(e.data?.length>0),nextRefresh:!1}),x=a(),T=async()=>{if(e.requestApi){b.loading=!0;const a=e.initParam??{};try{const l=await e.requestApi(a);b.echo=!1,e.pageResult?b.selectorData=l.rows:b.selectorData=l,p("dataChangeCallBack",b.selectorData)}catch(l){v("FaSelect",l),b.selectorData=[]}finally{b.loading=!1}}else b.echo=!1,b.selectorData=e.data},C=l=>{if(e.multiple){const e=l;if(0===e?.length)return b.value=null,c.value=null,p("update:modelValue",null),void p("change",null,null);const a=b.selectorData.filter(l=>e.includes(l.value));b.value=l,c.value=a.map(e=>e.label),p("update:modelValue",l),p("change",a,l)}else{if(j(l))return b.value=null,c.value=null,p("update:modelValue",null),void p("change",null,null);const e=b.selectorData.find(e=>e.value===l);b.value=l,c.value=e.label,p("update:modelValue",l),p("change",e,l)}},F=()=>{b.value=null,c.value=null,p("update:modelValue",null),p("clear")},N=async l=>{l&&(b.debut?(b.debut=!1,!e.defaultSelected&&e.lazy&&await T()):b.nextRefresh&&(b.nextRefresh=!1,await T())),p("visible-change",l)};t(()=>e.modelValue,l=>{if(b.echo&&!j(l)){const a=!j(e.label);if(e.multiple){if(!A(l))return void v("FaSelectV2","当启用 multiple 时,传入的 modelValue 必须是Array。");if(a&&!A(e.label))return void v("FaSelectV2","当启用 multiple 时,传入的 modelValue:label 必须是Array。");b.selectorData=l.slice(0,e.multipleLimit>0?e.multipleLimit:l.length).map((l,t)=>({value:l,label:a?e.label[t]:void 0}))}else{if(A(l))return void v("FaSelectV2","当禁用 multiple 时,传入的 modelValue 不能是Array。");if(a&&A(e.label))return void v("FaSelectV2","当禁用 multiple 时,传入的 modelValue:label 不能是Array。");b.selectorData=[{value:l,label:e.label}]}}b.value=l},{immediate:!0}),o(async()=>{e.defaultSelected?(await T(),b.selectorData.length>0&&C(e.multiple?[b.selectorData[0].value]:b.selectorData[0].value)):!e.requestApi&&e.data?.length>0?(b.debut=!1,await T()):e.lazy||await T(),t(()=>e.initParam,(e,l)=>{L(e,l)||(b.nextRefresh=!0,j(b.value)||C())}),t(()=>e.data,async()=>{e.requestApi||await T()},{deep:!0})});const O=h(e,R,["modelValue","popperClass","loading","options","itemHeight"]),q=S(z,p,["update:modelValue","change","clear","visible-change"]),H=i(()=>{let l=`fa-select-v2-dropdown ${e.popperClass}`;return e.moreDetail&&(l+=` fa-select-dropdown__more-detail fa-select-dropdown__more-detail-${g.value}`),l});return B(()=>u(m,n(O.value,q.value,{ref:x,class:"fa-select-v2",popperClass:H.value,style:{width:V(e.width)},modelValue:b.value,"onUpdate:modelValue":e=>b.value=e,loading:b.loading,options:b.selectorData,itemHeight:e.itemHeight+("small"===g.value?0:8),onChange:C,onClear:F,onVisibleChange:N}),{...d.default&&{default:({item:e,index:l,disabled:a})=>d.default({item:e,index:l,disabled:a})},...d.header&&{header:()=>d.header()},...d.footer&&{footer:()=>d.footer()},...d.prefix&&{prefix:()=>d.prefix()},...d.empty&&{empty:()=>d.empty()},...d.tag&&{tag:()=>d.tag()},...d.loading&&{loading:()=>d.loading()},...d.label&&{label:({label:e,value:l})=>d.label({label:e,value:l})}})),w(s,{focus:i(()=>x.value?.focus),blur:i(()=>x.value?.blur),selectedLabel:i(()=>x.value?.selectedLabel),loading:i(()=>b.loading),refresh:T,setSelection:e=>C(e),clearSelection:()=>C(null)})}});export{R as SelectV2Props,M as default,z as faSelectV2Emits,H as faSelectV2Props,q as selectV2Emits};
|
|
1
|
+
import{defineComponent as e,reactive as l,ref as a,watch as t,onMounted as o,computed as i,createVNode as u,mergeProps as n}from"vue";import{useAriaProps as r,useEmptyValuesProps as d,tagProps as p,useSizeProp as s,useTooltipContentProps as c,useGlobalSize as f,ElSelectV2 as m}from"element-plus";import{CircleClose as g}from"@element-plus/icons-vue";import{definePropType as b,withDefineType as y,consoleError as v,useProps as h,useEmits as S,useRender as B,addUnit as V,useExpose as w,makeSlots as x}from"@fast-china/utils";import{useVModel as D}from"@vueuse/core";import{isArray as A,isString as T,isNull as C,isNumber as F,isBoolean as N,isObject as O,isNil as j,isEqual as L}from"lodash-unified";const R={allowCreate:Boolean,autocomplete:{type:b(String),default:"none"},automaticDropdown:Boolean,clearable:Boolean,clearIcon:{type:b([String,Object,Function]),default:g},effect:{type:b(String),default:"light"},collapseTags:Boolean,collapseTagsTooltip:Boolean,maxCollapseTags:{type:Number,default:1},defaultFirstOption:Boolean,disabled:Boolean,estimatedOptionHeight:{type:Number,default:void 0},filterable:Boolean,filterMethod:Function,height:{type:Number,default:274},itemHeight:{type:Number,default:34},id:String,loading:Boolean,loadingText:String,modelValue:{type:b([Array,String,Number,Boolean,Object])},multiple:Boolean,multipleLimit:{type:Number,default:0},name:String,noDataText:String,noMatchText:String,remoteMethod:Function,reserveKeyword:{type:Boolean,default:!0},options:{type:b(Array)},placeholder:{type:String},teleported:c.teleported,persistent:{type:Boolean,default:!0},popperClass:{type:String,default:""},popperOptions:{type:b(Object),default:()=>({})},remote:Boolean,size:s,props:{type:b(Object),default:()=>({label:"label",value:"value",disabled:"disabled",options:"options"})},valueKey:{type:String,default:"value"},scrollbarAlwaysOn:Boolean,validateEvent:{type:Boolean,default:!0},offset:{type:Number,default:12},showArrow:{type:Boolean,default:!0},placement:{type:b(String),default:"bottom-start"},fallbackPlacements:{type:b(Array),default:["bottom-start","top-start","right","left"]},tagType:{...p.type,default:"info"},tagEffect:{...p.effect,default:"light"},tabindex:{type:[String,Number],default:0},appendTo:String,...d,...r(["ariaLabel"])},q={"update:modelValue":e=>!0,change:e=>!0,"remove-tag":e=>!0,"visible-change":e=>!0,focus:e=>!0,blur:e=>!0,clear:()=>!0},H={...R,disabled:{type:Boolean,default:void 0},loadingText:{type:String,default:"加载中..."},noMatchText:{type:String,default:"暂无匹配的数据"},noDataText:{type:String,default:"暂无数据"},collapseTags:{type:Boolean,default:!0},collapseTagsTooltip:{type:Boolean,default:!0},modelValue:{type:b([String,Number,Boolean,Object,Array]),default:void 0},label:b([String,Array]),width:{type:[String,Number],default:"100%"},moreDetail:Boolean,lazy:{type:Boolean,default:!0},defaultSelected:Boolean,data:{type:b(Array),default:()=>[]},pageResult:Boolean,requestApi:{type:b(Function)},initParam:b([String,Number,Object])},z={...q,"update:modelValue":e=>T(e)||F(e)||N(e)||O(e)||A(e)||C(e),"update:label":e=>T(e)||A(e)||C(e),dataChangeCallBack:e=>A(e),change:(e,l)=>!0},M=/* @__PURE__ */e({name:"FaSelectV2",props:H,emits:z,slots:x(),setup(e,{attrs:r,slots:d,emit:p,expose:s}){const c=D(e,"label",p,{passive:!0}),g=f(),b=l({value:y(),loading:!1,selectorData:y([]),debut:!0,echo:!(e.data?.length>0),nextRefresh:!1}),x=a(),T=async()=>{if(e.requestApi){b.loading=!0;const a=e.initParam??{};try{const l=await e.requestApi(a);b.echo=!1,e.pageResult?b.selectorData=l.rows:b.selectorData=l,p("dataChangeCallBack",b.selectorData)}catch(l){v("FaSelect",l),b.selectorData=[]}finally{b.loading=!1}}else b.echo=!1,b.selectorData=e.data},C=l=>{if(e.multiple){const e=l;if(0===e?.length)return b.value=null,c.value=null,p("update:modelValue",null),void p("change",null,null);const a=b.selectorData.filter(l=>e.includes(l.value));b.value=l,c.value=a.map(e=>e.label),p("update:modelValue",l),p("change",a,l)}else{if(j(l))return b.value=null,c.value=null,p("update:modelValue",null),void p("change",null,null);const e=b.selectorData.find(e=>e.value===l);b.value=l,c.value=e.label,p("update:modelValue",l),p("change",e,l)}},F=()=>{b.value=null,c.value=null,p("update:modelValue",null),p("clear")},N=async l=>{l&&(b.debut?(b.debut=!1,!e.defaultSelected&&e.lazy&&await T()):b.nextRefresh&&(b.nextRefresh=!1,await T())),p("visible-change",l)};t(()=>e.modelValue,l=>{if(b.echo&&!j(l)){const a=!j(e.label);if(e.multiple){if(!A(l))return void v("FaSelectV2","当启用 multiple 时,传入的 modelValue 必须是Array。");if(a&&!A(e.label))return void v("FaSelectV2","当启用 multiple 时,传入的 modelValue:label 必须是Array。");b.selectorData=l.slice(0,e.multipleLimit>0?e.multipleLimit:l.length).map((l,t)=>({value:l,label:a?e.label[t]:void 0}))}else{if(A(l))return void v("FaSelectV2","当禁用 multiple 时,传入的 modelValue 不能是Array。");if(a&&A(e.label))return void v("FaSelectV2","当禁用 multiple 时,传入的 modelValue:label 不能是Array。");b.selectorData=[{value:l,label:e.label}]}}b.value=l},{immediate:!0}),o(async()=>{e.defaultSelected?(await T(),b.selectorData.length>0&&C(e.multiple?[b.selectorData[0].value]:b.selectorData[0].value)):!e.requestApi&&e.data?.length>0?(b.debut=!1,await T()):e.lazy||await T(),t(()=>e.initParam,(e,l)=>{L(e,l)||(b.nextRefresh=!0,j(b.value)||C())}),t(()=>e.data,async()=>{e.requestApi||await T()},{deep:!0})});const O=h(e,R,["modelValue","popperClass","loading","options","itemHeight"]),q=S(z,p,["update:modelValue","change","clear","visible-change"]),H=i(()=>{let l=`fa-select-v2-dropdown ${e.popperClass}`;return e.moreDetail&&(l+=` fa-select-dropdown__more-detail fa-select-dropdown__more-detail-${g.value}`),l});return B(()=>u(m,n(O.value,q.value,{ref:x,class:"fa-select-v2",popperClass:H.value,style:{width:V(e.width)},modelValue:b.value,"onUpdate:modelValue":e=>b.value=e,loading:b.loading,options:b.selectorData,itemHeight:e.itemHeight+("small"===g.value?0:8),onChange:C,onClear:F,onVisibleChange:N}),{...d.default&&{default:({item:e,index:l,disabled:a})=>d.default({item:e,index:l,disabled:a})},...d.header&&{header:()=>d.header()},...d.footer&&{footer:()=>d.footer()},...d.prefix&&{prefix:()=>d.prefix()},...d.empty&&{empty:()=>d.empty()},...d.tag&&{tag:()=>d.tag()},...d.loading&&{loading:()=>d.loading()},...d.label&&{label:({label:e,value:l})=>d.label({label:e,value:l})}})),w(s,{focus:i(()=>x.value?.focus),blur:i(()=>x.value?.blur),selectedLabel:i(()=>x.value?.selectedLabel),loading:i(()=>b.loading),refresh:T,setSelection:e=>C(e),clearSelection:()=>C(null)})}});export{R as SelectV2Props,M as default,z as faSelectV2Emits,H as faSelectV2Props,q as selectV2Emits};
|
|
2
2
|
//# sourceMappingURL=selectV2.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"selectV2.mjs","sources":["../../../../../packages/components/selectV2/src/selectV2.tsx"],"sourcesContent":["import { computed, defineComponent, onMounted, reactive, ref, watch } from \"vue\";\nimport { ElSelectV2, tagProps, useAriaProps, useEmptyValuesProps, useGlobalSize, useSizeProp, useTooltipContentProps } from \"element-plus\";\nimport { CircleClose } from \"@element-plus/icons-vue\";\nimport { addUnit, consoleError, definePropType, makeSlots, useEmits, useExpose, useProps, useRender, withDefineType } from \"@fast-china/utils\";\nimport { useVModel } from \"@vueuse/core\";\nimport { isArray, isBoolean, isEqual, isNil, isNull, isNumber, isObject, isString } from \"lodash-unified\";\nimport type { ElSelectorOutput } from \"@fast-element-plus/components/select/src/select.type\";\nimport type { PagedInput, PagedResult } from \"@fast-element-plus/components/table\";\nimport type { Options, Placement, PopperEffect } from \"element-plus\";\nimport type { Component, VNode } from \"vue\";\n\ntype Props = {\n\tlabel?: string;\n\tvalue?: string;\n\tdisabled?: string;\n\toptions?: string;\n};\n\nexport const SelectV2Props = {\n\t/**\n\t * @description whether creating new items is allowed. To use this, `filterable` must be true\n\t */\n\tallowCreate: Boolean,\n\t/**\n\t * @description autocomplete of select input\n\t */\n\tautocomplete: {\n\t\ttype: definePropType<\"none\" | \"both\" | \"list\" | \"inline\">(String),\n\t\tdefault: \"none\",\n\t},\n\t/**\n\t * @description for non-filterable Select, this prop decides if the option menu pops up when the input is focused\n\t */\n\tautomaticDropdown: Boolean,\n\t/**\n\t * @description whether select can be cleared\n\t */\n\tclearable: Boolean,\n\t/**\n\t * @description custom clear icon\n\t */\n\tclearIcon: {\n\t\ttype: definePropType<string | Component>([String, Object, Function]),\n\t\tdefault: CircleClose,\n\t},\n\t/**\n\t * @description tooltip theme, built-in theme: `dark` / `light`\n\t */\n\teffect: {\n\t\ttype: definePropType<PopperEffect | string>(String),\n\t\tdefault: \"light\",\n\t},\n\t/**\n\t * @description whether to collapse tags to a text when multiple selecting\n\t */\n\tcollapseTags: Boolean,\n\t/**\n\t * @description whether show all selected tags when mouse hover text of collapse-tags. To use this, `collapse-tags` must be true\n\t */\n\tcollapseTagsTooltip: Boolean,\n\t/**\n\t * @description The max tags number to be shown. To use this, `collapse-tags` must be true\n\t */\n\tmaxCollapseTags: {\n\t\ttype: Number,\n\t\tdefault: 1,\n\t},\n\t/**\n\t * @description\n\t */\n\tdefaultFirstOption: Boolean,\n\t/**\n\t * @description is disabled\n\t */\n\tdisabled: Boolean,\n\t/**\n\t * @description\n\t */\n\testimatedOptionHeight: {\n\t\ttype: Number,\n\t\tdefault: undefined,\n\t},\n\t/**\n\t * @description is filterable\n\t */\n\tfilterable: Boolean,\n\t/**\n\t * @description\n\t */\n\tfilterMethod: Function,\n\t/**\n\t * @description The height of the dropdown panel, 34px for each item\n\t */\n\theight: {\n\t\ttype: Number,\n\t\tdefault: 274, // same as select dropdown menu\n\t},\n\t/**\n\t * @description The height of the dropdown item\n\t */\n\titemHeight: {\n\t\ttype: Number,\n\t\tdefault: 34,\n\t},\n\t/**\n\t * @description\n\t */\n\tid: String,\n\t/**\n\t * @description whether Select is loading data from server\n\t */\n\tloading: Boolean,\n\t/**\n\t * @description displayed text while loading data from server, default is 'Loading'\n\t */\n\tloadingText: String,\n\t/**\n\t * @description biding value\n\t */\n\tmodelValue: {\n\t\ttype: definePropType<any[] | string | number | boolean | Record<string, any> | any>([Array, String, Number, Boolean, Object]),\n\t},\n\t/**\n\t * @description is multiple\n\t */\n\tmultiple: Boolean,\n\t/**\n\t * @description maximum number of options user can select when multiple is true. No limit when set to 0\n\t */\n\tmultipleLimit: {\n\t\ttype: Number,\n\t\tdefault: 0,\n\t},\n\t/**\n\t * @description the name attribute of select input\n\t */\n\tname: String,\n\t/**\n\t * @description displayed text when there is no options, you can also use slot empty, the default is 'No Data'\n\t */\n\tnoDataText: String,\n\t/**\n\t * @description displayed text when no data matches the filtering query, you can also use slot `empty`, default is 'No matching data'\n\t */\n\tnoMatchText: String,\n\t/**\n\t * @description function that gets called when the input value changes. Its parameter is the current input value. To use this, `filterable` must be true\n\t */\n\tremoteMethod: Function,\n\t/**\n\t * @description whether reserve the keyword after select filtered option.\n\t */\n\treserveKeyword: {\n\t\ttype: Boolean,\n\t\tdefault: true,\n\t},\n\t/**\n\t * @description data of the options, the key of `value` and `label` can be customize by `props`\n\t */\n\toptions: {\n\t\ttype: definePropType<\n\t\t\t(\n\t\t\t\t| Record<string, any>\n\t\t\t\t| (Record<string, any> & {\n\t\t\t\t\t\tcreated?: boolean;\n\t\t\t\t })\n\t\t\t)[]\n\t\t>(Array),\n\t\t// required: true,\n\t},\n\t/**\n\t * @description placeholder, the default is 'Please select'\n\t */\n\tplaceholder: {\n\t\ttype: String,\n\t},\n\t/**\n\t * @description whether select dropdown is teleported to the body\n\t */\n\tteleported: useTooltipContentProps.teleported,\n\t/**\n\t * @description when select dropdown is inactive and `persistent` is `false`, select dropdown will be destroyed\n\t */\n\tpersistent: {\n\t\ttype: Boolean,\n\t\tdefault: true,\n\t},\n\t/**\n\t * @description custom class name for Select's dropdown\n\t */\n\tpopperClass: {\n\t\ttype: String,\n\t\tdefault: \"\",\n\t},\n\t/**\n\t * @description [popper.js](https://popper.js.org/docs/v2/) parameters\n\t */\n\tpopperOptions: {\n\t\ttype: definePropType<Partial<Options>>(Object),\n\t\tdefault: (): Partial<Options> => ({}),\n\t},\n\t/**\n\t * @description whether search data from server\n\t */\n\tremote: Boolean,\n\t/**\n\t * @description size of component\n\t */\n\tsize: useSizeProp,\n\t/**\n\t * @description configuration options, see the following table\n\t */\n\tprops: {\n\t\ttype: definePropType<Props>(Object),\n\t\tdefault: (): Required<Props> => ({\n\t\t\tlabel: \"label\",\n\t\t\tvalue: \"value\",\n\t\t\tdisabled: \"disabled\",\n\t\t\toptions: \"options\",\n\t\t}),\n\t},\n\t/**\n\t * @description unique identity key name for value, required when value is an object\n\t */\n\tvalueKey: {\n\t\ttype: String,\n\t\tdefault: \"value\",\n\t},\n\t/**\n\t * @description Controls whether the scrollbar is always displayed\n\t */\n\tscrollbarAlwaysOn: Boolean,\n\t/**\n\t * @description whether to trigger form validation\n\t */\n\tvalidateEvent: {\n\t\ttype: Boolean,\n\t\tdefault: true,\n\t},\n\t/**\n\t * @description offset of the dropdown\n\t */\n\toffset: {\n\t\ttype: Number,\n\t\tdefault: 12,\n\t},\n\t/**\n\t * @description Determines whether the arrow is displayed\n\t */\n\tshowArrow: {\n\t\ttype: Boolean,\n\t\tdefault: true,\n\t},\n\t/**\n\t * @description position of dropdown\n\t */\n\tplacement: {\n\t\ttype: definePropType<Placement>(String),\n\t\tdefault: \"bottom-start\",\n\t},\n\t/**\n\t * @description list of possible positions for dropdown\n\t */\n\tfallbackPlacements: {\n\t\ttype: definePropType<Placement[]>(Array),\n\t\tdefault: [\"bottom-start\", \"top-start\", \"right\", \"left\"],\n\t},\n\t/**\n\t * @description tag type\n\t */\n\ttagType: { ...tagProps.type, default: \"info\" },\n\t/**\n\t * @description tag effect\n\t */\n\ttagEffect: { ...tagProps.effect, default: \"light\" },\n\t/**\n\t * @description tabindex for input\n\t */\n\ttabindex: {\n\t\ttype: [String, Number],\n\t\tdefault: 0,\n\t},\n\t/**\n\t * @description which element the select dropdown appends to\n\t */\n\tappendTo: String,\n\t...useEmptyValuesProps,\n\t...useAriaProps([\"ariaLabel\"]),\n};\n\nexport const selectV2Emits = {\n\t\"update:modelValue\": (value: string | number | boolean | object | (string | number | boolean | object)[]): boolean => true,\n\tchange: (val: string | number | boolean | object | (string | number | boolean | object)[]): boolean => true,\n\t\"remove-tag\": (val: unknown): boolean => true,\n\t\"visible-change\": (visible: boolean): boolean => true,\n\tfocus: (evt: FocusEvent): boolean => true,\n\tblur: (evt: FocusEvent): boolean => true,\n\tclear: (): boolean => true,\n};\n\nexport const faSelectV2Props = {\n\t...SelectV2Props,\n\t/** @description whether Select is disabled 重载使其支持 ElForm*/\n\tdisabled: {\n\t\ttype: Boolean,\n\t\tdefault: undefined,\n\t},\n\t/** @description displayed text while loading data from server, default is 'Loading' */\n\tloadingText: {\n\t\ttype: String,\n\t\tdefault: \"加载中...\",\n\t},\n\t/** @description displayed text when no data matches the filtering query, you can also use slot `empty`, default is 'No matching data' */\n\tnoMatchText: {\n\t\ttype: String,\n\t\tdefault: \"暂无匹配的数据\",\n\t},\n\t/** @description displayed text when there is no options, you can also use slot `empty`, default is 'No data' */\n\tnoDataText: {\n\t\ttype: String,\n\t\tdefault: \"暂无数据\",\n\t},\n\t/** @description whether to collapse tags to a text when multiple selecting */\n\tcollapseTags: {\n\t\ttype: Boolean,\n\t\tdefault: true,\n\t},\n\t/** @description whether show all selected tags when mouse hover text of collapse-tags. To use this, `collapse-tags` must be true */\n\tcollapseTagsTooltip: {\n\t\ttype: Boolean,\n\t\tdefault: true,\n\t},\n\t/** @description v-model绑定值 */\n\tmodelValue: {\n\t\ttype: definePropType<string | number | boolean | object | (string | number | boolean | object)[]>([String, Number, Boolean, Object, Array]),\n\t\tdefault: undefined,\n\t},\n\t/** @description v-model:label绑定值 */\n\tlabel: definePropType<string | string[]>([String, Array]),\n\t/** @description 宽度 */\n\twidth: {\n\t\ttype: [String, Number],\n\t\tdefault: \"100%\",\n\t},\n\t/** @description 更多细节,只有使用slot的时候有用 */\n\tmoreDetail: Boolean,\n\t/** @description 懒加载远程数据,默认 true。当下拉框第一次显示的时候才会加载远程数据*/\n\tlazy: {\n\t\ttype: Boolean,\n\t\tdefault: true,\n\t},\n\t/** @description 默认选中。不能和懒加载一起使用 */\n\tdefaultSelected: Boolean,\n\t/** @description 下拉框数据 */\n\tdata: {\n\t\ttype: definePropType<ElSelectorOutput[]>(Array),\n\t\tdefault: (): ElSelectorOutput[] => [],\n\t},\n\t/** 分页返回 */\n\tpageResult: Boolean,\n\t/** @description 请求api */\n\trequestApi: {\n\t\ttype: definePropType<((params?: any) => Promise<ElSelectorOutput[]>) | ((params?: PagedInput) => Promise<PagedResult<ElSelectorOutput>>)>(\n\t\t\tFunction\n\t\t),\n\t},\n\t/** 初始化参数 */\n\tinitParam: definePropType<string | number | any>([String, Number, Object]),\n};\n\nexport const faSelectV2Emits = {\n\t...selectV2Emits,\n\t/** @description v-model 回调 */\n\t\"update:modelValue\": (value: string | number | boolean | object | (string | number | boolean | object)[]): boolean =>\n\t\tisString(value) || isNumber(value) || isBoolean(value) || isObject(value) || isArray(value) || isNull(value),\n\t/** @description v-model:label 回调 */\n\t\"update:label\": (value: string | string[]): boolean => isString(value) || isArray(value) || isNull(value),\n\t/** @description 数据改变 */\n\tdataChangeCallBack: (data: ElSelectorOutput[] | any[]): boolean => isArray(data),\n\t/** @description 改变 */\n\tchange: (\n\t\tdata: ElSelectorOutput | ElSelectorOutput[] | any | any[],\n\t\tvalue?: string | number | boolean | object | (string | number | boolean | object)[]\n\t): boolean => true,\n};\n\ntype FaSelectV2Slots = {\n\t/** @description FaSelectOption 默认内容插槽 */\n\tdefault: { item: ElSelectorOutput; index: number; disabled: boolean };\n\t/** @description 下拉列表顶部的内容 */\n\theader: never;\n\t/** @description 下拉列表底部的内容 */\n\tfooter: never;\n\t/** @description Select 组件头部内容 */\n\tprefix: never;\n\t/** @description 无选项时的列表 */\n\tempty: never;\n\t/** @description select 组件自定义标签内容 */\n\ttag: never;\n\t/** @description select 组件自定义 loading内容 */\n\tloading: never;\n\t/** @description select 组件自定义标签内容 */\n\tlabel: { label: string; value: string | number | boolean | object };\n};\n\nexport default defineComponent({\n\tname: \"FaSelectV2\",\n\tprops: faSelectV2Props,\n\temits: faSelectV2Emits,\n\tslots: makeSlots<FaSelectV2Slots>(),\n\tsetup(props, { attrs, slots, emit, expose }) {\n\t\tconst selectedLabel = useVModel(props, \"label\", emit);\n\t\tconst _globalSize = useGlobalSize();\n\n\t\tconst state = reactive({\n\t\t\tvalue: withDefineType<string | number | boolean | object | (string | number | boolean | object)[]>(),\n\t\t\tloading: false,\n\t\t\tselectorData: withDefineType<ElSelectorOutput[]>([]),\n\t\t\t/** 首次出现 */\n\t\t\tdebut: true,\n\t\t\t/** 回显 */\n\t\t\techo: props.data?.length > 0 ? false : true,\n\t\t\t/** 下次刷新 */\n\t\t\tnextRefresh: false,\n\t\t});\n\n\t\tconst selectV2Ref = ref<InstanceType<typeof ElSelectV2>>();\n\n\t\tconst loadData = async (): Promise<void> => {\n\t\t\t// 判断是否需要自动请求\n\t\t\tif (props.requestApi) {\n\t\t\t\tstate.loading = true;\n\t\t\t\tconst params = props.initParam ?? {};\n\t\t\t\ttry {\n\t\t\t\t\tconst resData = await props.requestApi(params);\n\t\t\t\t\t// 这里不允许回显了\n\t\t\t\t\tstate.echo = false;\n\t\t\t\t\t// 判断是否为分页返回\n\t\t\t\t\tif (props.pageResult) {\n\t\t\t\t\t\tstate.selectorData = (resData as PagedResult<ElSelectorOutput>).rows;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tstate.selectorData = resData as ElSelectorOutput[];\n\t\t\t\t\t}\n\t\t\t\t\temit(\"dataChangeCallBack\", state.selectorData);\n\t\t\t\t} catch (error) {\n\t\t\t\t\tconsoleError(\"FaSelect\", error);\n\t\t\t\t\tstate.selectorData = [];\n\t\t\t\t} finally {\n\t\t\t\t\tstate.loading = false;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// 这里不允许回显了\n\t\t\t\tstate.echo = false;\n\t\t\t\tstate.selectorData = props.data;\n\t\t\t}\n\t\t};\n\n\t\tconst handleChange = (value?: string | number | boolean | object | (string | number | boolean | object)[]): void => {\n\t\t\t// 判断是否为多选\n\t\t\tif (props.multiple) {\n\t\t\t\t// value 必然是数组\n\t\t\t\tconst valueArr = value as (string | number | boolean | object)[];\n\t\t\t\tif (valueArr?.length === 0) {\n\t\t\t\t\tstate.value = null;\n\t\t\t\t\tselectedLabel.value = null;\n\t\t\t\t\temit(\"update:modelValue\", null);\n\t\t\t\t\temit(\"change\", null, null);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst dataList = state.selectorData.filter((f) => valueArr.includes(f.value));\n\t\t\t\tstate.value = value;\n\t\t\t\tselectedLabel.value = dataList.map((m) => m.label);\n\t\t\t\temit(\"update:modelValue\", value);\n\t\t\t\temit(\"change\", dataList, value);\n\t\t\t} else {\n\t\t\t\t// value 必然不是数组\n\t\t\t\tif (isNil(value)) {\n\t\t\t\t\tstate.value = null;\n\t\t\t\t\tselectedLabel.value = null;\n\t\t\t\t\temit(\"update:modelValue\", null);\n\t\t\t\t\temit(\"change\", null, null);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst data = state.selectorData.find((f) => f.value === value);\n\t\t\t\tstate.value = value;\n\t\t\t\tselectedLabel.value = data.label;\n\t\t\t\temit(\"update:modelValue\", value);\n\t\t\t\temit(\"change\", data, value);\n\t\t\t}\n\t\t};\n\n\t\tconst handleClear = (): void => {\n\t\t\tstate.value = null;\n\t\t\tselectedLabel.value = null;\n\t\t\temit(\"update:modelValue\", null);\n\t\t\temit(\"clear\");\n\t\t};\n\n\t\tconst handleVisibleChange = async (visible: boolean): Promise<void> => {\n\t\t\tif (visible) {\n\t\t\t\tif (state.debut) {\n\t\t\t\t\t// 首次出现\n\t\t\t\t\tstate.debut = false;\n\t\t\t\t\t// 懒加载\n\t\t\t\t\t!props.defaultSelected && props.lazy && (await loadData());\n\t\t\t\t} else {\n\t\t\t\t\t// 判断再次出现是否需要刷新数据\n\t\t\t\t\tif (state.nextRefresh) {\n\t\t\t\t\t\tstate.nextRefresh = false;\n\t\t\t\t\t\tawait loadData();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\temit(\"visible-change\", visible);\n\t\t};\n\n\t\twatch(\n\t\t\t() => props.modelValue,\n\t\t\t(newValue) => {\n\t\t\t\tif (state.echo && !isNil(newValue)) {\n\t\t\t\t\tconst hasLabel = !isNil(props.label);\n\t\t\t\t\t// 判断是否为多选\n\t\t\t\t\tif (props.multiple) {\n\t\t\t\t\t\t// 判断是否为数组\n\t\t\t\t\t\tif (!isArray(newValue)) {\n\t\t\t\t\t\t\tconsoleError(\"FaSelectV2\", \"当启用 multiple 时,传入的 modelValue 必须是Array。\");\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (hasLabel && !isArray(props.label)) {\n\t\t\t\t\t\t\tconsoleError(\"FaSelectV2\", \"当启用 multiple 时,传入的 modelValue:label 必须是Array。\");\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tstate.selectorData = newValue\n\t\t\t\t\t\t\t// 最大选项截取\n\t\t\t\t\t\t\t.slice(0, props.multipleLimit > 0 ? props.multipleLimit : newValue.length)\n\t\t\t\t\t\t\t.map((item, index) => ({\n\t\t\t\t\t\t\t\tvalue: item,\n\t\t\t\t\t\t\t\tlabel: hasLabel ? props.label[index] : undefined,\n\t\t\t\t\t\t\t}));\n\t\t\t\t\t} else {\n\t\t\t\t\t\tif (isArray(newValue)) {\n\t\t\t\t\t\t\tconsoleError(\"FaSelectV2\", \"当禁用 multiple 时,传入的 modelValue 不能是Array。\");\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (hasLabel && isArray(props.label)) {\n\t\t\t\t\t\t\tconsoleError(\"FaSelectV2\", \"当禁用 multiple 时,传入的 modelValue:label 不能是Array。\");\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tstate.selectorData = [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tvalue: newValue,\n\t\t\t\t\t\t\t\tlabel: props.label,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tstate.value = newValue;\n\t\t\t},\n\t\t\t{\n\t\t\t\timmediate: true,\n\t\t\t}\n\t\t);\n\n\t\tonMounted(async () => {\n\t\t\tif (props.defaultSelected) {\n\t\t\t\tawait loadData();\n\t\t\t\tif (state.selectorData.length > 0) {\n\t\t\t\t\thandleChange(props.multiple ? [state.selectorData[0].value] : state.selectorData[0].value);\n\t\t\t\t}\n\t\t\t}\n\t\t\t// 判断是否为本地数据\n\t\t\telse if (!props.requestApi && props.data?.length > 0) {\n\t\t\t\tstate.debut = false;\n\t\t\t\tawait loadData();\n\t\t\t}\n\t\t\t// 判断是否非默认选中,且未启用懒加载\n\t\t\telse if (!props.lazy) {\n\t\t\t\tawait loadData();\n\t\t\t}\n\t\t\twatch(\n\t\t\t\t() => props.initParam,\n\t\t\t\t(newValue, oldValue) => {\n\t\t\t\t\tif (!isEqual(newValue, oldValue)) {\n\t\t\t\t\t\tstate.nextRefresh = true;\n\t\t\t\t\t\tif (!isNil(state.value)) {\n\t\t\t\t\t\t\thandleChange();\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t);\n\t\t\twatch(\n\t\t\t\t() => props.data,\n\t\t\t\tasync () => {\n\t\t\t\t\tif (!props.requestApi) {\n\t\t\t\t\t\tawait loadData();\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\t{ deep: true }\n\t\t\t);\n\t\t});\n\n\t\tconst elSelectV2Props = useProps(props, SelectV2Props, [\"modelValue\", \"popperClass\", \"loading\", \"options\", \"itemHeight\"]);\n\t\tconst elSelectV2Emits = useEmits(faSelectV2Emits, emit, [\"update:modelValue\", \"change\", \"clear\", \"visible-change\"]);\n\t\tconst elPopperClass = computed(() => {\n\t\t\tlet localClass = `fa-select-v2-dropdown ${props.popperClass}`;\n\t\t\tif (props.moreDetail) {\n\t\t\t\tlocalClass += ` fa-select-dropdown__more-detail fa-select-dropdown__more-detail-${_globalSize.value}`;\n\t\t\t}\n\t\t\treturn localClass;\n\t\t});\n\n\t\tuseRender(() => (\n\t\t\t<ElSelectV2\n\t\t\t\t{...elSelectV2Props.value}\n\t\t\t\t{...elSelectV2Emits.value}\n\t\t\t\tref={selectV2Ref}\n\t\t\t\tclass=\"fa-select-v2\"\n\t\t\t\tpopperClass={elPopperClass.value}\n\t\t\t\tstyle={{ width: addUnit(props.width) }}\n\t\t\t\tvModel={state.value}\n\t\t\t\tloading={state.loading}\n\t\t\t\toptions={state.selectorData}\n\t\t\t\titemHeight={props.itemHeight + (_globalSize.value === \"small\" ? 0 : 8)}\n\t\t\t\tonChange={handleChange}\n\t\t\t\tonClear={handleClear}\n\t\t\t\tonVisibleChange={handleVisibleChange}\n\t\t\t>\n\t\t\t\t{{\n\t\t\t\t\t...(slots.default && {\n\t\t\t\t\t\tdefault: ({ item, index, disabled }: { item: ElSelectorOutput; index: number; disabled: boolean }): VNode[] =>\n\t\t\t\t\t\t\tslots.default({ item, index, disabled }),\n\t\t\t\t\t}),\n\t\t\t\t\t...(slots.header && { header: (): VNode[] => slots.header() }),\n\t\t\t\t\t...(slots.footer && { footer: (): VNode[] => slots.footer() }),\n\t\t\t\t\t...(slots.prefix && { prefix: (): VNode[] => slots.prefix() }),\n\t\t\t\t\t...(slots.empty && { empty: (): VNode[] => slots.empty() }),\n\t\t\t\t\t...(slots.tag && { tag: (): VNode[] => slots.tag() }),\n\t\t\t\t\t...(slots.loading && { loading: (): VNode[] => slots.loading() }),\n\t\t\t\t\t...(slots.label && {\n\t\t\t\t\t\tlabel: ({ label, value }: { label: string; value: string | number | boolean | object }): VNode[] =>\n\t\t\t\t\t\t\tslots.label({ label, value }),\n\t\t\t\t\t}),\n\t\t\t\t}}\n\t\t\t</ElSelectV2>\n\t\t));\n\n\t\treturn useExpose(expose, {\n\t\t\t/** @description 使选择器的输入框获取焦点 */\n\t\t\tfocus: computed(() => selectV2Ref.value?.focus),\n\t\t\t/** @description 使选择器的输入框失去焦点,并隐藏下拉框 */\n\t\t\tblur: computed(() => selectV2Ref.value?.blur),\n\t\t\t/** @description 获取当前选中的标签 */\n\t\t\tselectedLabel: computed(() => selectV2Ref.value?.selectedLabel),\n\t\t\t/** @description 加载状态 */\n\t\t\tloading: computed(() => state.loading),\n\t\t\t/** @description 刷新 */\n\t\t\trefresh: loadData,\n\t\t\t/** @description 设置选择 */\n\t\t\tsetSelection: (value: string | number | boolean | object | (string | number | boolean | object)[]) => handleChange(value),\n\t\t\t/** @description 清除选择 */\n\t\t\tclearSelection: () => handleChange(null),\n\t\t});\n\t},\n});\n"],"names":["SelectV2Props","allowCreate","Boolean","autocomplete","type","definePropType","String","default","automaticDropdown","clearable","clearIcon","Object","Function","CircleClose","effect","collapseTags","collapseTagsTooltip","maxCollapseTags","Number","defaultFirstOption","disabled","estimatedOptionHeight","undefined","filterable","filterMethod","height","itemHeight","id","loading","loadingText","modelValue","Array","multiple","multipleLimit","name","noDataText","noMatchText","remoteMethod","reserveKeyword","options","placeholder","teleported","useTooltipContentProps","persistent","popperClass","popperOptions","remote","size","useSizeProp","props","label","value","valueKey","scrollbarAlwaysOn","validateEvent","offset","showArrow","placement","fallbackPlacements","tagType","tagProps","tagEffect","tabindex","appendTo","useEmptyValuesProps","useAriaProps","selectV2Emits","change","val","visible","focus","evt","blur","clear","faSelectV2Props","width","moreDetail","lazy","defaultSelected","data","pageResult","requestApi","initParam","faSelectV2Emits","isString","isNumber","isBoolean","isObject","isArray","isNull","dataChangeCallBack","SelectV2","emits","slots","makeSlots","setup","attrs","emit","expose","selectedLabel","useVModel","_globalSize","useGlobalSize","state","reactive","withDefineType","selectorData","debut","echo","length","nextRefresh","selectV2Ref","ref","loadData","async","params","resData","rows","error","consoleError","handleChange","valueArr","dataList","filter","includes","f","map","m","isNil","find","handleClear","handleVisibleChange","watch","newValue","hasLabel","slice","item","index","immediate","onMounted","oldValue","isEqual","deep","elSelectV2Props","useProps","elSelectV2Emits","useEmits","elPopperClass","computed","localClass","useRender","_createVNode","ElSelectV2","_mergeProps","class","style","addUnit","$event","onChange","onClear","onVisibleChange","header","footer","prefix","empty","tag","useExpose","refresh","setSelection","clearSelection"],"mappings":"6rBAkBO,MAAMA,EAAgB,CAI5BC,YAAaC,QAIbC,aAAc,CACbC,KAAMC,EAAoDC,QAC1DC,QAAS,QAKVC,kBAAmBN,QAInBO,UAAWP,QAIXQ,UAAW,CACVN,KAAMC,EAAmC,CAACC,OAAQK,OAAQC,WAC1DL,QAASM,GAKVC,OAAQ,CACPV,KAAMC,EAAsCC,QAC5CC,QAAS,SAKVQ,aAAcb,QAIdc,oBAAqBd,QAIrBe,gBAAiB,CAChBb,KAAMc,OACNX,QAAS,GAKVY,mBAAoBjB,QAIpBkB,SAAUlB,QAIVmB,sBAAuB,CACtBjB,KAAMc,OACNX,aAASe,GAKVC,WAAYrB,QAIZsB,aAAcZ,SAIda,OAAQ,CACPrB,KAAMc,OACNX,QAAS,KAKVmB,WAAY,CACXtB,KAAMc,OACNX,QAAS,IAKVoB,GAAIrB,OAIJsB,QAAS1B,QAIT2B,YAAavB,OAIbwB,WAAY,CACX1B,KAAMC,EAA8E,CAAC0B,MAAOzB,OAAQY,OAAQhB,QAASS,UAKtHqB,SAAU9B,QAIV+B,cAAe,CACd7B,KAAMc,OACNX,QAAS,GAKV2B,KAAM5B,OAIN6B,WAAY7B,OAIZ8B,YAAa9B,OAIb+B,aAAczB,SAId0B,eAAgB,CACflC,KAAMF,QACNK,SAAS,GAKVgC,QAAS,CACRnC,KAAMC,EAOJ0B,QAMHS,YAAa,CACZpC,KAAME,QAKPmC,WAAYC,EAAuBD,WAInCE,WAAY,C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rC,EAAY5D,OAAOqB,MAExC2B,cAAeiD,EAAS,IAAMrC,EAAY5D,OAAOgD,eAEjDvE,QAASwH,EAAS,IAAM7C,EAAM3E,SAE9B2I,QAAStD,EAETuD,aAAerH,GAAuFqE,EAAarE,GAEnHsH,eAAgBA,IAAMjD,EAAa,OAErC"}
|
|
1
|
+
{"version":3,"file":"selectV2.mjs","sources":["../../../../../packages/components/selectV2/src/selectV2.tsx"],"sourcesContent":["import { computed, defineComponent, onMounted, reactive, ref, watch } from \"vue\";\nimport { ElSelectV2, tagProps, useAriaProps, useEmptyValuesProps, useGlobalSize, useSizeProp, useTooltipContentProps } from \"element-plus\";\nimport { CircleClose } from \"@element-plus/icons-vue\";\nimport { addUnit, consoleError, definePropType, makeSlots, useEmits, useExpose, useProps, useRender, withDefineType } from \"@fast-china/utils\";\nimport { useVModel } from \"@vueuse/core\";\nimport { isArray, isBoolean, isEqual, isNil, isNull, isNumber, isObject, isString } from \"lodash-unified\";\nimport type { ElSelectorOutput } from \"@fast-element-plus/components/select/src/select.type\";\nimport type { PagedInput, PagedResult } from \"@fast-element-plus/components/table\";\nimport type { Options, Placement, PopperEffect } from \"element-plus\";\nimport type { Component, VNode } from \"vue\";\n\ntype Props = {\n\tlabel?: string;\n\tvalue?: string;\n\tdisabled?: string;\n\toptions?: string;\n};\n\nexport const SelectV2Props = {\n\t/**\n\t * @description whether creating new items is allowed. To use this, `filterable` must be true\n\t */\n\tallowCreate: Boolean,\n\t/**\n\t * @description autocomplete of select input\n\t */\n\tautocomplete: {\n\t\ttype: definePropType<\"none\" | \"both\" | \"list\" | \"inline\">(String),\n\t\tdefault: \"none\",\n\t},\n\t/**\n\t * @description for non-filterable Select, this prop decides if the option menu pops up when the input is focused\n\t */\n\tautomaticDropdown: Boolean,\n\t/**\n\t * @description whether select can be cleared\n\t */\n\tclearable: Boolean,\n\t/**\n\t * @description custom clear icon\n\t */\n\tclearIcon: {\n\t\ttype: definePropType<string | Component>([String, Object, Function]),\n\t\tdefault: CircleClose,\n\t},\n\t/**\n\t * @description tooltip theme, built-in theme: `dark` / `light`\n\t */\n\teffect: {\n\t\ttype: definePropType<PopperEffect | string>(String),\n\t\tdefault: \"light\",\n\t},\n\t/**\n\t * @description whether to collapse tags to a text when multiple selecting\n\t */\n\tcollapseTags: Boolean,\n\t/**\n\t * @description whether show all selected tags when mouse hover text of collapse-tags. To use this, `collapse-tags` must be true\n\t */\n\tcollapseTagsTooltip: Boolean,\n\t/**\n\t * @description The max tags number to be shown. To use this, `collapse-tags` must be true\n\t */\n\tmaxCollapseTags: {\n\t\ttype: Number,\n\t\tdefault: 1,\n\t},\n\t/**\n\t * @description\n\t */\n\tdefaultFirstOption: Boolean,\n\t/**\n\t * @description is disabled\n\t */\n\tdisabled: Boolean,\n\t/**\n\t * @description\n\t */\n\testimatedOptionHeight: {\n\t\ttype: Number,\n\t\tdefault: undefined,\n\t},\n\t/**\n\t * @description is filterable\n\t */\n\tfilterable: Boolean,\n\t/**\n\t * @description\n\t */\n\tfilterMethod: Function,\n\t/**\n\t * @description The height of the dropdown panel, 34px for each item\n\t */\n\theight: {\n\t\ttype: Number,\n\t\tdefault: 274, // same as select dropdown menu\n\t},\n\t/**\n\t * @description The height of the dropdown item\n\t */\n\titemHeight: {\n\t\ttype: Number,\n\t\tdefault: 34,\n\t},\n\t/**\n\t * @description\n\t */\n\tid: String,\n\t/**\n\t * @description whether Select is loading data from server\n\t */\n\tloading: Boolean,\n\t/**\n\t * @description displayed text while loading data from server, default is 'Loading'\n\t */\n\tloadingText: String,\n\t/**\n\t * @description biding value\n\t */\n\tmodelValue: {\n\t\ttype: definePropType<any[] | string | number | boolean | Record<string, any> | any>([Array, String, Number, Boolean, Object]),\n\t},\n\t/**\n\t * @description is multiple\n\t */\n\tmultiple: Boolean,\n\t/**\n\t * @description maximum number of options user can select when multiple is true. No limit when set to 0\n\t */\n\tmultipleLimit: {\n\t\ttype: Number,\n\t\tdefault: 0,\n\t},\n\t/**\n\t * @description the name attribute of select input\n\t */\n\tname: String,\n\t/**\n\t * @description displayed text when there is no options, you can also use slot empty, the default is 'No Data'\n\t */\n\tnoDataText: String,\n\t/**\n\t * @description displayed text when no data matches the filtering query, you can also use slot `empty`, default is 'No matching data'\n\t */\n\tnoMatchText: String,\n\t/**\n\t * @description function that gets called when the input value changes. Its parameter is the current input value. To use this, `filterable` must be true\n\t */\n\tremoteMethod: Function,\n\t/**\n\t * @description whether reserve the keyword after select filtered option.\n\t */\n\treserveKeyword: {\n\t\ttype: Boolean,\n\t\tdefault: true,\n\t},\n\t/**\n\t * @description data of the options, the key of `value` and `label` can be customize by `props`\n\t */\n\toptions: {\n\t\ttype: definePropType<\n\t\t\t(\n\t\t\t\t| Record<string, any>\n\t\t\t\t| (Record<string, any> & {\n\t\t\t\t\t\tcreated?: boolean;\n\t\t\t\t })\n\t\t\t)[]\n\t\t>(Array),\n\t\t// required: true,\n\t},\n\t/**\n\t * @description placeholder, the default is 'Please select'\n\t */\n\tplaceholder: {\n\t\ttype: String,\n\t},\n\t/**\n\t * @description whether select dropdown is teleported to the body\n\t */\n\tteleported: useTooltipContentProps.teleported,\n\t/**\n\t * @description when select dropdown is inactive and `persistent` is `false`, select dropdown will be destroyed\n\t */\n\tpersistent: {\n\t\ttype: Boolean,\n\t\tdefault: true,\n\t},\n\t/**\n\t * @description custom class name for Select's dropdown\n\t */\n\tpopperClass: {\n\t\ttype: String,\n\t\tdefault: \"\",\n\t},\n\t/**\n\t * @description [popper.js](https://popper.js.org/docs/v2/) parameters\n\t */\n\tpopperOptions: {\n\t\ttype: definePropType<Partial<Options>>(Object),\n\t\tdefault: (): Partial<Options> => ({}),\n\t},\n\t/**\n\t * @description whether search data from server\n\t */\n\tremote: Boolean,\n\t/**\n\t * @description size of component\n\t */\n\tsize: useSizeProp,\n\t/**\n\t * @description configuration options, see the following table\n\t */\n\tprops: {\n\t\ttype: definePropType<Props>(Object),\n\t\tdefault: (): Required<Props> => ({\n\t\t\tlabel: \"label\",\n\t\t\tvalue: \"value\",\n\t\t\tdisabled: \"disabled\",\n\t\t\toptions: \"options\",\n\t\t}),\n\t},\n\t/**\n\t * @description unique identity key name for value, required when value is an object\n\t */\n\tvalueKey: {\n\t\ttype: String,\n\t\tdefault: \"value\",\n\t},\n\t/**\n\t * @description Controls whether the scrollbar is always displayed\n\t */\n\tscrollbarAlwaysOn: Boolean,\n\t/**\n\t * @description whether to trigger form validation\n\t */\n\tvalidateEvent: {\n\t\ttype: Boolean,\n\t\tdefault: true,\n\t},\n\t/**\n\t * @description offset of the dropdown\n\t */\n\toffset: {\n\t\ttype: Number,\n\t\tdefault: 12,\n\t},\n\t/**\n\t * @description Determines whether the arrow is displayed\n\t */\n\tshowArrow: {\n\t\ttype: Boolean,\n\t\tdefault: true,\n\t},\n\t/**\n\t * @description position of dropdown\n\t */\n\tplacement: {\n\t\ttype: definePropType<Placement>(String),\n\t\tdefault: \"bottom-start\",\n\t},\n\t/**\n\t * @description list of possible positions for dropdown\n\t */\n\tfallbackPlacements: {\n\t\ttype: definePropType<Placement[]>(Array),\n\t\tdefault: [\"bottom-start\", \"top-start\", \"right\", \"left\"],\n\t},\n\t/**\n\t * @description tag type\n\t */\n\ttagType: { ...tagProps.type, default: \"info\" },\n\t/**\n\t * @description tag effect\n\t */\n\ttagEffect: { ...tagProps.effect, default: \"light\" },\n\t/**\n\t * @description tabindex for input\n\t */\n\ttabindex: {\n\t\ttype: [String, Number],\n\t\tdefault: 0,\n\t},\n\t/**\n\t * @description which element the select dropdown appends to\n\t */\n\tappendTo: String,\n\t...useEmptyValuesProps,\n\t...useAriaProps([\"ariaLabel\"]),\n};\n\nexport const selectV2Emits = {\n\t\"update:modelValue\": (value: string | number | boolean | object | (string | number | boolean | object)[]): boolean => true,\n\tchange: (val: string | number | boolean | object | (string | number | boolean | object)[]): boolean => true,\n\t\"remove-tag\": (val: unknown): boolean => true,\n\t\"visible-change\": (visible: boolean): boolean => true,\n\tfocus: (evt: FocusEvent): boolean => true,\n\tblur: (evt: FocusEvent): boolean => true,\n\tclear: (): boolean => true,\n};\n\nexport const faSelectV2Props = {\n\t...SelectV2Props,\n\t/** @description whether Select is disabled 重载使其支持 ElForm*/\n\tdisabled: {\n\t\ttype: Boolean,\n\t\tdefault: undefined,\n\t},\n\t/** @description displayed text while loading data from server, default is 'Loading' */\n\tloadingText: {\n\t\ttype: String,\n\t\tdefault: \"加载中...\",\n\t},\n\t/** @description displayed text when no data matches the filtering query, you can also use slot `empty`, default is 'No matching data' */\n\tnoMatchText: {\n\t\ttype: String,\n\t\tdefault: \"暂无匹配的数据\",\n\t},\n\t/** @description displayed text when there is no options, you can also use slot `empty`, default is 'No data' */\n\tnoDataText: {\n\t\ttype: String,\n\t\tdefault: \"暂无数据\",\n\t},\n\t/** @description whether to collapse tags to a text when multiple selecting */\n\tcollapseTags: {\n\t\ttype: Boolean,\n\t\tdefault: true,\n\t},\n\t/** @description whether show all selected tags when mouse hover text of collapse-tags. To use this, `collapse-tags` must be true */\n\tcollapseTagsTooltip: {\n\t\ttype: Boolean,\n\t\tdefault: true,\n\t},\n\t/** @description v-model绑定值 */\n\tmodelValue: {\n\t\ttype: definePropType<string | number | boolean | object | (string | number | boolean | object)[]>([String, Number, Boolean, Object, Array]),\n\t\tdefault: undefined,\n\t},\n\t/** @description v-model:label绑定值 */\n\tlabel: definePropType<string | string[]>([String, Array]),\n\t/** @description 宽度 */\n\twidth: {\n\t\ttype: [String, Number],\n\t\tdefault: \"100%\",\n\t},\n\t/** @description 更多细节,只有使用slot的时候有用 */\n\tmoreDetail: Boolean,\n\t/** @description 懒加载远程数据,默认 true。当下拉框第一次显示的时候才会加载远程数据*/\n\tlazy: {\n\t\ttype: Boolean,\n\t\tdefault: true,\n\t},\n\t/** @description 默认选中。不能和懒加载一起使用 */\n\tdefaultSelected: Boolean,\n\t/** @description 下拉框数据 */\n\tdata: {\n\t\ttype: definePropType<ElSelectorOutput[]>(Array),\n\t\tdefault: (): ElSelectorOutput[] => [],\n\t},\n\t/** 分页返回 */\n\tpageResult: Boolean,\n\t/** @description 请求api */\n\trequestApi: {\n\t\ttype: definePropType<((params?: any) => Promise<ElSelectorOutput[]>) | ((params?: PagedInput) => Promise<PagedResult<ElSelectorOutput>>)>(\n\t\t\tFunction\n\t\t),\n\t},\n\t/** 初始化参数 */\n\tinitParam: definePropType<string | number | any>([String, Number, Object]),\n};\n\nexport const faSelectV2Emits = {\n\t...selectV2Emits,\n\t/** @description v-model 回调 */\n\t\"update:modelValue\": (value: string | number | boolean | object | (string | number | boolean | object)[]): boolean =>\n\t\tisString(value) || isNumber(value) || isBoolean(value) || isObject(value) || isArray(value) || isNull(value),\n\t/** @description v-model:label 回调 */\n\t\"update:label\": (value: string | string[]): boolean => isString(value) || isArray(value) || isNull(value),\n\t/** @description 数据改变 */\n\tdataChangeCallBack: (data: ElSelectorOutput[] | any[]): boolean => isArray(data),\n\t/** @description 改变 */\n\tchange: (\n\t\tdata: ElSelectorOutput | ElSelectorOutput[] | any | any[],\n\t\tvalue?: string | number | boolean | object | (string | number | boolean | object)[]\n\t): boolean => true,\n};\n\ntype FaSelectV2Slots = {\n\t/** @description FaSelectOption 默认内容插槽 */\n\tdefault: { item: ElSelectorOutput; index: number; disabled: boolean };\n\t/** @description 下拉列表顶部的内容 */\n\theader: never;\n\t/** @description 下拉列表底部的内容 */\n\tfooter: never;\n\t/** @description Select 组件头部内容 */\n\tprefix: never;\n\t/** @description 无选项时的列表 */\n\tempty: never;\n\t/** @description select 组件自定义标签内容 */\n\ttag: never;\n\t/** @description select 组件自定义 loading内容 */\n\tloading: never;\n\t/** @description select 组件自定义标签内容 */\n\tlabel: { label: string; value: string | number | boolean | object };\n};\n\nexport default defineComponent({\n\tname: \"FaSelectV2\",\n\tprops: faSelectV2Props,\n\temits: faSelectV2Emits,\n\tslots: makeSlots<FaSelectV2Slots>(),\n\tsetup(props, { attrs, slots, emit, expose }) {\n\t\tconst selectedLabel = useVModel(props, \"label\", emit, { passive: true });\n\t\tconst _globalSize = useGlobalSize();\n\n\t\tconst state = reactive({\n\t\t\tvalue: withDefineType<string | number | boolean | object | (string | number | boolean | object)[]>(),\n\t\t\tloading: false,\n\t\t\tselectorData: withDefineType<ElSelectorOutput[]>([]),\n\t\t\t/** 首次出现 */\n\t\t\tdebut: true,\n\t\t\t/** 回显 */\n\t\t\techo: props.data?.length > 0 ? false : true,\n\t\t\t/** 下次刷新 */\n\t\t\tnextRefresh: false,\n\t\t});\n\n\t\tconst selectV2Ref = ref<InstanceType<typeof ElSelectV2>>();\n\n\t\tconst loadData = async (): Promise<void> => {\n\t\t\t// 判断是否需要自动请求\n\t\t\tif (props.requestApi) {\n\t\t\t\tstate.loading = true;\n\t\t\t\tconst params = props.initParam ?? {};\n\t\t\t\ttry {\n\t\t\t\t\tconst resData = await props.requestApi(params);\n\t\t\t\t\t// 这里不允许回显了\n\t\t\t\t\tstate.echo = false;\n\t\t\t\t\t// 判断是否为分页返回\n\t\t\t\t\tif (props.pageResult) {\n\t\t\t\t\t\tstate.selectorData = (resData as PagedResult<ElSelectorOutput>).rows;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tstate.selectorData = resData as ElSelectorOutput[];\n\t\t\t\t\t}\n\t\t\t\t\temit(\"dataChangeCallBack\", state.selectorData);\n\t\t\t\t} catch (error) {\n\t\t\t\t\tconsoleError(\"FaSelect\", error);\n\t\t\t\t\tstate.selectorData = [];\n\t\t\t\t} finally {\n\t\t\t\t\tstate.loading = false;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// 这里不允许回显了\n\t\t\t\tstate.echo = false;\n\t\t\t\tstate.selectorData = props.data;\n\t\t\t}\n\t\t};\n\n\t\tconst handleChange = (value?: string | number | boolean | object | (string | number | boolean | object)[]): void => {\n\t\t\t// 判断是否为多选\n\t\t\tif (props.multiple) {\n\t\t\t\t// value 必然是数组\n\t\t\t\tconst valueArr = value as (string | number | boolean | object)[];\n\t\t\t\tif (valueArr?.length === 0) {\n\t\t\t\t\tstate.value = null;\n\t\t\t\t\tselectedLabel.value = null;\n\t\t\t\t\temit(\"update:modelValue\", null);\n\t\t\t\t\temit(\"change\", null, null);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst dataList = state.selectorData.filter((f) => valueArr.includes(f.value));\n\t\t\t\tstate.value = value;\n\t\t\t\tselectedLabel.value = dataList.map((m) => m.label);\n\t\t\t\temit(\"update:modelValue\", value);\n\t\t\t\temit(\"change\", dataList, value);\n\t\t\t} else {\n\t\t\t\t// value 必然不是数组\n\t\t\t\tif (isNil(value)) {\n\t\t\t\t\tstate.value = null;\n\t\t\t\t\tselectedLabel.value = null;\n\t\t\t\t\temit(\"update:modelValue\", null);\n\t\t\t\t\temit(\"change\", null, null);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst data = state.selectorData.find((f) => f.value === value);\n\t\t\t\tstate.value = value;\n\t\t\t\tselectedLabel.value = data.label;\n\t\t\t\temit(\"update:modelValue\", value);\n\t\t\t\temit(\"change\", data, value);\n\t\t\t}\n\t\t};\n\n\t\tconst handleClear = (): void => {\n\t\t\tstate.value = null;\n\t\t\tselectedLabel.value = null;\n\t\t\temit(\"update:modelValue\", null);\n\t\t\temit(\"clear\");\n\t\t};\n\n\t\tconst handleVisibleChange = async (visible: boolean): Promise<void> => {\n\t\t\tif (visible) {\n\t\t\t\tif (state.debut) {\n\t\t\t\t\t// 首次出现\n\t\t\t\t\tstate.debut = false;\n\t\t\t\t\t// 懒加载\n\t\t\t\t\t!props.defaultSelected && props.lazy && (await loadData());\n\t\t\t\t} else {\n\t\t\t\t\t// 判断再次出现是否需要刷新数据\n\t\t\t\t\tif (state.nextRefresh) {\n\t\t\t\t\t\tstate.nextRefresh = false;\n\t\t\t\t\t\tawait loadData();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\temit(\"visible-change\", visible);\n\t\t};\n\n\t\twatch(\n\t\t\t() => props.modelValue,\n\t\t\t(newValue) => {\n\t\t\t\tif (state.echo && !isNil(newValue)) {\n\t\t\t\t\tconst hasLabel = !isNil(props.label);\n\t\t\t\t\t// 判断是否为多选\n\t\t\t\t\tif (props.multiple) {\n\t\t\t\t\t\t// 判断是否为数组\n\t\t\t\t\t\tif (!isArray(newValue)) {\n\t\t\t\t\t\t\tconsoleError(\"FaSelectV2\", \"当启用 multiple 时,传入的 modelValue 必须是Array。\");\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (hasLabel && !isArray(props.label)) {\n\t\t\t\t\t\t\tconsoleError(\"FaSelectV2\", \"当启用 multiple 时,传入的 modelValue:label 必须是Array。\");\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tstate.selectorData = newValue\n\t\t\t\t\t\t\t// 最大选项截取\n\t\t\t\t\t\t\t.slice(0, props.multipleLimit > 0 ? props.multipleLimit : newValue.length)\n\t\t\t\t\t\t\t.map((item, index) => ({\n\t\t\t\t\t\t\t\tvalue: item,\n\t\t\t\t\t\t\t\tlabel: hasLabel ? props.label[index] : undefined,\n\t\t\t\t\t\t\t}));\n\t\t\t\t\t} else {\n\t\t\t\t\t\tif (isArray(newValue)) {\n\t\t\t\t\t\t\tconsoleError(\"FaSelectV2\", \"当禁用 multiple 时,传入的 modelValue 不能是Array。\");\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (hasLabel && isArray(props.label)) {\n\t\t\t\t\t\t\tconsoleError(\"FaSelectV2\", \"当禁用 multiple 时,传入的 modelValue:label 不能是Array。\");\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tstate.selectorData = [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tvalue: newValue,\n\t\t\t\t\t\t\t\tlabel: props.label,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tstate.value = newValue;\n\t\t\t},\n\t\t\t{\n\t\t\t\timmediate: true,\n\t\t\t}\n\t\t);\n\n\t\tonMounted(async () => {\n\t\t\tif (props.defaultSelected) {\n\t\t\t\tawait loadData();\n\t\t\t\tif (state.selectorData.length > 0) {\n\t\t\t\t\thandleChange(props.multiple ? [state.selectorData[0].value] : state.selectorData[0].value);\n\t\t\t\t}\n\t\t\t}\n\t\t\t// 判断是否为本地数据\n\t\t\telse if (!props.requestApi && props.data?.length > 0) {\n\t\t\t\tstate.debut = false;\n\t\t\t\tawait loadData();\n\t\t\t}\n\t\t\t// 判断是否非默认选中,且未启用懒加载\n\t\t\telse if (!props.lazy) {\n\t\t\t\tawait loadData();\n\t\t\t}\n\t\t\twatch(\n\t\t\t\t() => props.initParam,\n\t\t\t\t(newValue, oldValue) => {\n\t\t\t\t\tif (!isEqual(newValue, oldValue)) {\n\t\t\t\t\t\tstate.nextRefresh = true;\n\t\t\t\t\t\tif (!isNil(state.value)) {\n\t\t\t\t\t\t\thandleChange();\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t);\n\t\t\twatch(\n\t\t\t\t() => props.data,\n\t\t\t\tasync () => {\n\t\t\t\t\tif (!props.requestApi) {\n\t\t\t\t\t\tawait loadData();\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\t{ deep: true }\n\t\t\t);\n\t\t});\n\n\t\tconst elSelectV2Props = useProps(props, SelectV2Props, [\"modelValue\", \"popperClass\", \"loading\", \"options\", \"itemHeight\"]);\n\t\tconst elSelectV2Emits = useEmits(faSelectV2Emits, emit, [\"update:modelValue\", \"change\", \"clear\", \"visible-change\"]);\n\t\tconst elPopperClass = computed(() => {\n\t\t\tlet localClass = `fa-select-v2-dropdown ${props.popperClass}`;\n\t\t\tif (props.moreDetail) {\n\t\t\t\tlocalClass += ` fa-select-dropdown__more-detail fa-select-dropdown__more-detail-${_globalSize.value}`;\n\t\t\t}\n\t\t\treturn localClass;\n\t\t});\n\n\t\tuseRender(() => (\n\t\t\t<ElSelectV2\n\t\t\t\t{...elSelectV2Props.value}\n\t\t\t\t{...elSelectV2Emits.value}\n\t\t\t\tref={selectV2Ref}\n\t\t\t\tclass=\"fa-select-v2\"\n\t\t\t\tpopperClass={elPopperClass.value}\n\t\t\t\tstyle={{ width: addUnit(props.width) }}\n\t\t\t\tvModel={state.value}\n\t\t\t\tloading={state.loading}\n\t\t\t\toptions={state.selectorData}\n\t\t\t\titemHeight={props.itemHeight + (_globalSize.value === \"small\" ? 0 : 8)}\n\t\t\t\tonChange={handleChange}\n\t\t\t\tonClear={handleClear}\n\t\t\t\tonVisibleChange={handleVisibleChange}\n\t\t\t>\n\t\t\t\t{{\n\t\t\t\t\t...(slots.default && {\n\t\t\t\t\t\tdefault: ({ item, index, disabled }: { item: ElSelectorOutput; index: number; disabled: boolean }): VNode[] =>\n\t\t\t\t\t\t\tslots.default({ item, index, disabled }),\n\t\t\t\t\t}),\n\t\t\t\t\t...(slots.header && { header: (): VNode[] => slots.header() }),\n\t\t\t\t\t...(slots.footer && { footer: (): VNode[] => slots.footer() }),\n\t\t\t\t\t...(slots.prefix && { prefix: (): VNode[] => slots.prefix() }),\n\t\t\t\t\t...(slots.empty && { empty: (): VNode[] => slots.empty() }),\n\t\t\t\t\t...(slots.tag && { tag: (): VNode[] => slots.tag() }),\n\t\t\t\t\t...(slots.loading && { loading: (): VNode[] => slots.loading() }),\n\t\t\t\t\t...(slots.label && {\n\t\t\t\t\t\tlabel: ({ label, value }: { label: string; value: string | number | boolean | object }): VNode[] =>\n\t\t\t\t\t\t\tslots.label({ label, value }),\n\t\t\t\t\t}),\n\t\t\t\t}}\n\t\t\t</ElSelectV2>\n\t\t));\n\n\t\treturn useExpose(expose, {\n\t\t\t/** @description 使选择器的输入框获取焦点 */\n\t\t\tfocus: computed(() => selectV2Ref.value?.focus),\n\t\t\t/** @description 使选择器的输入框失去焦点,并隐藏下拉框 */\n\t\t\tblur: computed(() => selectV2Ref.value?.blur),\n\t\t\t/** @description 获取当前选中的标签 */\n\t\t\tselectedLabel: computed(() => selectV2Ref.value?.selectedLabel),\n\t\t\t/** @description 加载状态 */\n\t\t\tloading: computed(() => state.loading),\n\t\t\t/** @description 刷新 */\n\t\t\trefresh: loadData,\n\t\t\t/** @description 设置选择 */\n\t\t\tsetSelection: (value: string | number | boolean | object | (string | number | boolean | object)[]) => handleChange(value),\n\t\t\t/** @description 清除选择 */\n\t\t\tclearSelection: () => handleChange(null),\n\t\t});\n\t},\n});\n"],"names":["SelectV2Props","allowCreate","Boolean","autocomplete","type","definePropType","String","default","automaticDropdown","clearable","clearIcon","Object","Function","CircleClose","effect","collapseTags","collapseTagsTooltip","maxCollapseTags","Number","defaultFirstOption","disabled","estimatedOptionHeight","undefined","filterable","filterMethod","height","itemHeight","id","loading","loadingText","modelValue","Array","multiple","multipleLimit","name","noDataText","noMatchText","remoteMethod","reserveKeyword","options","placeholder","teleported","useTooltipContentProps","persistent","popperClass","popperOptions","remote","size","useSizeProp","props","label","value","valueKey","scrollbarAlwaysOn","validateEvent","offset","showArrow","placement","fallbackPlacements","tagType","tagProps","tagEffect","tabindex","appendTo","useEmptyValuesProps","useAriaProps","selectV2Emits","change","val","visible","focus","evt","blur","clear","faSelectV2Props","width","moreDetail","lazy","defaultSelected","data","pageResult","requestApi","initParam","faSelectV2Emits","isString","isNumber","isBoolean","isObject","isArray","isNull","dataChangeCallBack","SelectV2","emits","slots","makeSlots","setup","attrs","emit","expose","selectedLabel","useVModel","passive","_globalSize","useGlobalSize","state","reactive","withDefineType","selectorData","debut","echo","length","nextRefresh","selectV2Ref","ref","loadData","async","params","resData","rows","error","consoleError","handleChange","valueArr","dataList","filter","includes","f","map","m","isNil","find","handleClear","handleVisibleChange","watch","newValue","hasLabel","slice","item","index","immediate","onMounted","oldValue","isEqual","deep","elSelectV2Props","useProps","elSelectV2Emits","useEmits","elPopperClass","computed","localClass","useRender","_createVNode","ElSelectV2","_mergeProps","class","style","addUnit","$event","onChange","onClear","onVisibleChange","header","footer","prefix","empty","tag","useExpose","refresh","setSelection","clear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1387
1387
|
className: string;
|
|
1388
1388
|
columns: false | FaTableColumnCtx[];
|
|
1389
|
+
scrollbarAlwaysOn: boolean;
|
|
1390
|
+
defaultExpandAll: boolean;
|
|
1391
|
+
indent: number;
|
|
1392
|
+
treeData: boolean;
|
|
1393
|
+
pagination: boolean;
|
|
1389
1394
|
rowKey: string | ((row: any) => string);
|
|
1390
1395
|
border: boolean;
|
|
1391
1396
|
highlightCurrentRow: boolean;
|
|
@@ -1402,21 +1407,16 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
|
|
|
1402
1407
|
hideSearchTime: boolean;
|
|
1403
1408
|
futureSearchTime: boolean;
|
|
1404
1409
|
dataSearchRange: FaTableDataRange;
|
|
1405
|
-
pagination: boolean;
|
|
1406
1410
|
hideImage: boolean;
|
|
1407
1411
|
single: boolean;
|
|
1408
1412
|
rowClickSelection: boolean;
|
|
1409
|
-
treeData: boolean;
|
|
1410
1413
|
autoRefresh: boolean;
|
|
1411
1414
|
stripe: boolean;
|
|
1412
1415
|
showHeader: boolean;
|
|
1413
1416
|
showSummary: boolean;
|
|
1414
|
-
defaultExpandAll: boolean;
|
|
1415
1417
|
selectOnIndeterminate: boolean;
|
|
1416
|
-
indent: number;
|
|
1417
1418
|
treeProps: TreeProps;
|
|
1418
1419
|
tableLayout: Layout;
|
|
1419
|
-
scrollbarAlwaysOn: boolean;
|
|
1420
1420
|
flexible: boolean;
|
|
1421
1421
|
scrollbarTabindex: string | number;
|
|
1422
1422
|
}, import('vue').SlotsType<Partial<import('@fast-china/utils').MakeSlots<FaTableSlots>>>, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{isVNode as e,defineComponent as a,ref as t,onMounted as l,watch as n,watchEffect as o,onActivated as i,computed as r,createVNode as s,withDirectives as c,Fragment as d,createTextVNode as u,mergeProps as m,resolveDirective as h}from"vue";import{useSizeProp as g,ElInput as p,ElDatePicker as f,ElButton as b,ElDropdown as C,ElDropdownMenu as S,ElDropdownItem as w,ElTable as y,ElTableColumn as _,ElIcon as v,ElPagination as x,ElImageViewer as P}from"element-plus";import{Search as L,Refresh as I,Eleme as B,Setting as F,More as R}from"@element-plus/icons-vue";import{NotData as O}from"@fast-element-plus/icons-vue";import{definePropType as T,stringUtil as k,consoleWarn as N,clickUtil as D,useProps as E,useRender as j,dateUtil as M,useExpose as z,makeSlots as K}from"@fast-china/utils";import{isNil as A,isString as H,isObject as $,isNumber as V,isBoolean as W,isArray as U,isNull as Y,isFunction as q,pick as G,omit as J}from"lodash-unified";import{getTableDefaultSlots as Q}from"./table.type.mjs";import X from"./tableColumn.mjs";import Z from"./tableColumnSettingDialog.mjs";import ee from"./tablePagination.mjs";import ae from"./tableSearchForm.mjs";import{useTable as te}from"./useTable.mjs";const le={data:{type:Array,default:()=>[]},size:g,width:[String,Number],height:[String,Number],maxHeight:[String,Number],fit:{type:Boolean,default:!0},stripe:Boolean,border:Boolean,rowKey:[String,Function],showHeader:{type:Boolean,default:!0},showSummary:Boolean,sumText:String,summaryMethod:Function,rowClassName:[String,Function],rowStyle:[Object,Function],cellClassName:[String,Function],cellStyle:[Object,Function],headerRowClassName:[String,Function],headerRowStyle:[Object,Function],headerCellClassName:[String,Function],headerCellStyle:[Object,Function],highlightCurrentRow:Boolean,currentRowKey:[String,Number],emptyText:String,expandRowKeys:Array,defaultExpandAll:Boolean,defaultSort:Object,tooltipEffect:String,tooltipOptions:Object,spanMethod:Function,selectOnIndeterminate:{type:Boolean,default:!0},indent:{type:Number,default:16},treeProps:{type:Object,default:()=>({hasChildren:"hasChildren",children:"children",checkStrictly:!1})},lazy:Boolean,load:Function,style:{type:Object,default:()=>({})},className:{type:String,default:""},tableLayout:{type:String,default:"fixed"},scrollbarAlwaysOn:Boolean,flexible:Boolean,showOverflowTooltip:[Boolean,Object],scrollbarTabindex:{type:[Number,String],default:void 0}},ne={...le,border:{type:Boolean,default:!0},highlightCurrentRow:{type:Boolean,default:!0},rowKey:{type:[String,Function],default:"id"},spanMethod:{type:Function,validator:()=>(N("FaTable","'spanMethod' 属性,组件已经封装,外部使用会失效。"),!1)},tableKey:{type:String,default:()=>k.generateRandomString(8)},data:{type:T(Array),default:()=>[]},requestApi:{type:T(Function)},dataCallback:{type:T(Function)},initParam:T([String,Number,Object]),columns:{type:T([Array,Boolean]),default:()=>!1},columnsChange:{type:T(Function)},searchFormCols:{type:T([String,Number,Object]),default:()=>({xs:3,sm:3,md:4,lg:5,xl:6})},collapsedSearch:{type:Boolean,default:!0},advancedSearchDrawer:{type:Boolean,default:!1},searchForm:{type:Boolean,default:!0},headerCard:{type:Boolean,default:!0},refreshBtn:{type:Boolean,default:!0},searchBtn:{type:Boolean,default:!0},columnSettingBtn:{type:Boolean,default:!1},toolBtn:{type:Boolean,default:!0},hideSearchTime:Boolean,futureSearchTime:Boolean,dataSearchRange:{type:T(String),default:"Past3D"},pagination:{type:Boolean,default:!0},hideImage:Boolean,single:Boolean,rowClickSelection:Boolean,treeData:Boolean,props:{type:T(Object),default:()=>({span:void 0,children:"children"})},autoRefresh:{type:Boolean,default:!0},rowSelectable:Function},oe={select:(e,a)=>U(e)&&$(a),selectAll:e=>U(e),selectionChange:e=>U(e),cellMouseEnter:(e,a,t,l)=>$(e)&&$(a)&&t instanceof HTMLTableCellElement&&l instanceof Event,cellMouseLeave:(e,a,t,l)=>$(e)&&$(a)&&t instanceof HTMLTableCellElement&&l instanceof Event,cellClick:(e,a,t,l)=>$(e)&&$(a)&&t instanceof HTMLTableCellElement&&l instanceof Event,cellDblclick:(e,a,t,l)=>$(e)&&$(a)&&t instanceof HTMLTableCellElement&&l instanceof Event,cellContextmenu:(e,a,t,l)=>$(e)&&$(a)&&t instanceof HTMLTableCellElement&&l instanceof Event,rowClick:(e,a,t)=>$(e)&&$(a)&&t instanceof Event,rowContextmenu:(e,a,t)=>$(e)&&$(a)&&t instanceof Event,rowDblclick:(e,a,t)=>$(e)&&$(a)&&t instanceof Event,headerClick:(e,a)=>$(e)&&a instanceof Event,headerContextmenu:(e,a)=>$(e)&&a instanceof Event,sortChange:e=>$(e),filterChange:e=>H(e)||V(e)||W(e)||$(e),currentChange:(e,a)=>$(e)&&(Y(a)||$(a)),headerDragend:(e,a,t,l)=>V(e)&&V(a)&&$(t)&&l instanceof MouseEvent,expandChange:(e,a)=>$(e)&&(W(a)||U(a)),refresh:e=>$(e),reset:e=>$(e),sizeChange:e=>V(e),paginationChange:(e,a)=>V(e)&&V(a),customCellClick:(e,{row:a,column:t,$index:l})=>(A(e)||H(e))&&$(a)&&$(t)&&V(l)},ie=/* @__PURE__ */a({name:"FaTable",props:ne,emits:oe,slots:K(),setup(a,{attrs:g,slots:T,emit:k,expose:N}){const{_globalSize:K,state:A,elementRef:$,tableRef:V,handleTableColumnAutoWidth:W,loadTableColumns:U,handleSizeChange:Y,handlePaginationChange:ne,defaultSearchTime:oe,tableSearch:ie,tableReset:re,doRender:se,doLoading:ce,handleCustomCellClick:de}=te(a,T,k),ue=t();let me=0;const he=e=>{if(0===e&&(me=0),A.spanColumns?.length>0){return 0===Number(A.tableSpanData["__table-index"][e])?me+(A.tablePagination.pageIndex-1)*A.tablePagination.pageSize+1:(me++,me+(A.tablePagination.pageIndex-1)*A.tablePagination.pageSize)}return e+(A.tablePagination.pageIndex-1)*A.tablePagination.pageSize+1},ge=(e,t)=>{a.single&&(V.value.clearSelection(),e.length>0&&t&&V.value.toggleRowSelection(t)),k("select",e,t)},pe=e=>{a.single&&(A.selected?A.tableData.length>0&&(V.value.clearSelection(),V.value.toggleRowSelection(A.tableData[0])):V.value.clearSelection()),k("selectAll",e)},fe=e=>{0===e.length?A.selected=!1:A.selected=!0,a.single&&e.length>0?A.selectedList=[e[e.length-1]]:A.selectedList=e,A.indeterminateSelectedListIds=A.indeterminateSelectedListIds.filter(e=>A.selectedListIds.some(a=>a===e)),k("selectionChange",A.selectedList)},be=({column:e,prop:t,order:l})=>{e.multiOrder?"descending"===e.multiOrder?e.multiOrder="ascending":e.multiOrder=null:e.multiOrder="descending",A.searchParam.sortList=[.../* @__PURE__ */new Set([...a.initParam?.sortList??[],...A.searchParam?.sortList??[]])];const n=A.orgColumns.find(e=>e.prop===t),o=n?.sortableField??n?.prop??e.property,i=A.searchParam.sortList.findIndex(e=>e.enField===o);e.multiOrder?-1===i?A.searchParam.sortList.push({enField:o,cnField:e.label,mode:e.multiOrder}):A.searchParam.sortList[i].mode=e.multiOrder:A.searchParam.sortList.splice(i,1),0===A.searchParam.sortList.length&&delete A.searchParam.sortList,k("sortChange",{column:e,prop:t,order:e.multiOrder}),ie()},Ce=(e,t)=>{e&&(a.rowClickSelection&&(a.single&&t&&V.value.toggleRowSelection(t),V.value.toggleRowSelection(e)),k("currentChange",e,t))},Se=({row:e,column:t,rowIndex:l,columnIndex:n})=>{let o=null;if("selection"===t.type){const t=q(a.rowKey)?a.rowKey(e):e[a.rowKey];A.indeterminateSelectedListIds.some(e=>e===t)&&(o="fa-table__selection-column__indeterminate")}const i=A.tableColumns.find(e=>e.prop===t.property);if(i?.dataDeleteField&&e&&!0===e[i.dataDeleteField]&&(o?o+=" fa-table__data-delete-column":o="fa-table__data-delete-column"),a.cellClassName){let i=null;return i=H(a.cellClassName)?a.cellClassName:a.cellClassName({row:e,column:t,rowIndex:l,columnIndex:n}),i?o?`${o} ${i}`:i:o}return o},we=({row:e,column:t,rowIndex:l,columnIndex:n})=>(t.order=t.multiOrder,a.headerCellClassName?q(a.headerCellClassName)?a.headerCellClassName({row:e,column:t,rowIndex:l,columnIndex:n}):a.headerCellClassName:null),ye=({row:e,column:a,rowIndex:t,columnIndex:l})=>{const n=a.property??a.columnKey;if(-1!==A.spanColumns.findIndex(e=>e.prop===n)){const e=Number(A.tableSpanData[n][t]);return e>0?{rowspan:e,colspan:1}:{rowspan:0,colspan:0}}return{rowspan:1,colspan:1}},_e=async(e,t,l,n)=>{A.orgColumns.forEach(a=>{l.property===a.prop&&(a.width=e,a.smallWidth=e)}),k("headerDragend",e,t,l,n),a.columnsChange&&await D.debounceAsync(()=>a.columnsChange(A.orgColumns),500)},ve=e=>{A.previewList=[e],A.imagePreview=!0};l(async()=>{A.initParam=a.initParam,oe(),Object.keys(a.initParam??{}).forEach(e=>{A.searchParam[e]=a.initParam[e]}),await ie(),n(()=>a.columns,async()=>{U()},{deep:!0,immediate:!0}),n(()=>a.initParam,()=>{Object.keys(a.initParam??{}).forEach(e=>{A.searchParam[e]=a.initParam[e]})},{deep:!0}),n(()=>a.data,async()=>{!a.requestApi&&a.autoRefresh&&await ie()},{deep:!0,immediate:!0}),o(async()=>{const e=$.value;if(e){const a=new ResizeObserver(e=>{for(const a of e){const{width:e,height:t}=a.contentRect;A.tableWidth=e,A.tableHeight=t}D.debounceAsync(async()=>{await W()},100)});return a.observe(e),()=>{a.disconnect()}}})}),i(async()=>{await W()});const xe=r(()=>A.searchColumns.filter(e=>e.search.slot).map(e=>e.search.slot)),Pe=r(()=>A.tableColumns.filter(e=>e.slot).map(e=>e.slot)),Le=["multiOrder","columnId","order","sortableField","disabledSortable","spanProp","pureSearch","search"],Ie=E(a,le,["data","spanMethod","headerCellClassName","cellClassName"]);return j(()=>s("div",{ref:$,class:["fa-table",`fa-table-${K.value}`,`fa-table__${a.tableKey??"notFound"}`,{fa__click__disabled:A.loading}],style:{"--fa-table-width":""+(A.tableWidth?`${A.tableWidth}px`:""),"--fa-table-height":""+(A.tableHeight?`${A.tableHeight}px`:"")}},[s(ae,{show:a.searchForm&&A.searchForm,collapsedSearch:a.collapsedSearch,advancedSearchDrawer:a.advancedSearchDrawer,cols:a.searchFormCols,search:ie,reset:re},G(T,xe.value)),T.topHeader&&s("div",{class:"el-card fa-table__header"},[T.topHeader({search:ie,...Q(A)})]),s("div",{class:"el-card fa-table__main"},[a.headerCard&&s("div",{class:"fa-table__main-header"},[s("div",{class:"fa-table__main-header-left"},[T.header&&T.header({search:ie,...Q(A)})]),s("div",{class:"fa-table__main-header-right"},[a.toolBtn&&s(d,null,[s("div",{class:"fa-table__main-header-right__div-search"},[s(p,{class:"fa-table__main-header-right__input-search",disabled:A.loading,prefixIcon:L,placeholder:"关键字搜索",modelValue:A.searchParam.searchValue,modelModifiers:{trim:!0},"onUpdate:modelValue":e=>A.searchParam.searchValue=e,clearable:!0,onCompositionupdate:e=>{A.searchValueUpdate=e.data},onCompositionend:e=>{A.searchValueUpdate=""},onChange:()=>ie()},null),s("div",{class:"fa-table__main-header-right__div-search__hidden"},[A.searchParam.searchValue,A.searchValueUpdate])]),a.requestApi&&!a.hideSearchTime&&s(f,{class:"fa-table__main-header-right__data-search",popperClass:"fa-table__main-header-right__data-search__popper",disabled:A.loading,type:"daterange",modelValue:A.searchParam.searchTimeList,"onUpdate:modelValue":e=>A.searchParam.searchTimeList=e,defaultTime:M.getDefaultTime(a.futureSearchTime),shortcuts:M.getShortcuts(a.futureSearchTime),valueFormat:"YYYY-MM-DD HH:mm:ss",clearable:!1,teleported:!1,unlinkPanels:!0,onChange:()=>ie()},null),a.refreshBtn&&s(b,{loading:A.loading,loadingIcon:B,title:"刷新",circle:!0,icon:I,onClick:()=>ie()},null),a.searchBtn&&A.searchColumns.length>0&&s(b,{loading:A.loading,loadingIcon:B,title:A.searchForm?"隐藏搜索栏":"显示搜索栏",circle:!0,icon:L,onClick:()=>A.searchForm=!A.searchForm},null),a.columnSettingBtn&&a.columns&&s(C,{title:"表格列配置",trigger:"click"},{default:()=>s(b,{loading:A.loading,loadingIcon:B,circle:!0,icon:F},null),dropdown:()=>s(S,null,{default:()=>[T.columnSetting&&T.columnSetting(),s(w,{title:"表格列配置",divided:!0,onClick:()=>ue.value.open()},{default:()=>[u("表格列配置")]})]})}),T.toolButton&&T.toolButton({search:ie,...Q(A)}),T.toolButtonAdv&&s(C,{title:"高级操作",trigger:"click"},{default:()=>s(b,{loading:A.loading,loadingIcon:B,circle:!0,icon:R},null),dropdown:()=>{let a;return s(S,null,"function"==typeof(t=a=T.toolButtonAdv({search:ie,...Q(A)}))||"[object Object]"===Object.prototype.toString.call(t)&&!e(t)?a:{default:()=>[a]});var t}})])])]),c(s(y,m(Ie.value,{ref:V,"element-loading-text":A.loadingText,data:A.tableData,spanMethod:ye,headerCellClassName:we,cellClassName:Se,onSelectionChange:fe,onSortChange:be,onSelect:ge,onSelectAll:pe,onCurrentChange:Ce,onHeaderDragend:_e,onCellMouseEnter:(e,a,t,l)=>k("cellMouseEnter",e,a,t,l),onCellMouseLeave:(e,a,t,l)=>k("cellMouseLeave",e,a,t,l),onCellClick:(e,a,t,l)=>k("cellClick",e,a,t,l),onCellDblclick:(e,a,t,l)=>k("cellDblclick",e,a,t,l),onCellContextmenu:(e,a,t,l)=>k("cellContextmenu",e,a,t,l),onRowClick:(e,a,t)=>k("rowClick",e,a,t),onRowContextmenu:(e,a,t)=>k("rowContextmenu",e,a,t),onRowDblclick:(e,a,t)=>k("rowDblclick",e,a,t),onHeaderClick:(e,a)=>k("headerClick",e,a),onHeaderContextmenu:(e,a)=>k("headerContextmenu",e,a),onFilterChange:e=>k("filterChange",e),onExpandChange:(e,a)=>k("expandChange",e,a)}),{append:()=>T.append&&T.append(),empty:()=>s("div",{class:"fa-table__empty"},[T.empty?T.empty():s(d,null,[s(v,null,{default:()=>[s(O,null,null)]}),s("div",null,[u("暂无数据")])])]),default:()=>s(d,null,[s(_,{className:"fa-table__index-column",type:"index",fixed:"left",width:A.tablePagination.pageIndex*A.tablePagination.pageSize>=100?A.tablePagination.pageIndex*A.tablePagination.pageSize>=1e3?50:40:30,align:"center",index:he,showOverflowTooltip:!1,resizable:!1,columnKey:"__table-index"},null),s(_,{className:"fa-table__selection-column",type:"selection",fixed:"left",width:35,align:"center",reserveSelection:!0,showOverflowTooltip:!1,resizable:!1,columnKey:"__table-selection",selectable:a.rowSelectable},null),T.operation&&s(_,{fixed:"right",width:A.operationColumnWidth,headerAlign:"center",align:"left",showOverflowTooltip:!1,className:"fa-table__operation-column",resizable:!1,columnKey:"__table-operation"},{header:()=>s("div",{class:"fa-table__auto-width-column__cell-header __fa-table__auto-width-column__cell-header____table-operation"},[s("span",null,[u("操作")])]),default:({row:e,column:a,$index:t})=>s("div",{class:"fa-table__auto-width-column__cell __fa-table__auto-width-column__cell____table-operation"},[T.operation({row:e,column:a,$index:t,search:ie,...Q(A)})])}),0===A.tableColumns?.length?T.default&&T.default():A.tableColumns.map(e=>e.show&&("expand"===e.type?s(_,m(e,{width:35,fixed:e.fixed??"left",resizable:!1}),{default:({row:a,column:t,$index:l})=>s(d,null,[e.render&&e.render({row:a,column:t,$index:l,...Q(A)}),e.slot&&T[e.slot]&&T[e.slot]({row:a,column:t,$index:l,...Q(A)})])}):e.prop&&s(X,m(J(e,Le),{hideImage:a.hideImage,resizable:!0,onImagePreview:ve,onCustomCellClick:de}),G(T,Pe.value))))])}),[[h("loading"),A.loading]]),s("div",{class:"fa-table__main-footer"},[s("div",{class:"fa-table__main-footer__left"},[T.footer&&T.footer({search:ie,...Q(A)})]),T.pagination?T.pagination({pageIndex:A.tablePagination.pageIndex,pageSize:A.tablePagination.pageSize,totalRows:A.tablePagination.totalRows,handleSizeChange:Y,handlePaginationChange:ne}):s(d,null,[a.pagination?s(ee,{onSizeChange:Y,onCurrentChange:ne},null):s(x,{class:"fa-table-pagination",size:"small",layout:"total",total:A.tableData.length},null)])])]),A.imagePreview&&s(P,{closeOnPressEscape:!0,hideOnClickModal:!0,teleported:!0,onClose:()=>A.imagePreview=!1,urlList:A.previewList},null),a.columnSettingBtn&&s(Z,{ref:ue,change:a.columnsChange},null)])),z(N,{clearSelection:r(()=>V.value?.clearSelection),getSelectionRows:r(()=>V.value?.getSelectionRows),toggleRowSelection:r(()=>V.value?.toggleRowSelection),toggleAllSelection:r(()=>V.value?.toggleAllSelection),toggleRowExpansion:r(()=>V.value?.toggleRowExpansion),setCurrentRow:r(()=>V.value?.setCurrentRow),clearSort:r(()=>V.value?.clearSort),clearFilter:r(()=>V.value?.clearFilter),doLayout:r(()=>V.value?.doLayout),sort:r(()=>V.value?.sort),scrollTo:r(()=>V.value?.scrollTo),setScrollTop:r(()=>V.value?.setScrollTop),setScrollLeft:r(()=>V.value?.setScrollLeft),columns:r(()=>V.value?.columns),updateKeyChildren:r(()=>V.value?.updateKeyChildren),loading:r(()=>A.loading),tableData:r(()=>A.tableData),tablePagination:r(()=>A.tablePagination),searchParam:r(()=>A.searchParam),selected:r(()=>A.selected),selectedList:r(()=>A.selectedList),selectedListIds:r(()=>A.selectedListIds),indeterminateSelectedListIds:r(()=>A.indeterminateSelectedListIds),tableWidth:r(()=>A.tableWidth),tableHeight:r(()=>A.tableHeight),toggleRowIndeterminateSelection:(e,t)=>{const l=q(a.rowKey)?a.rowKey(e):e[a.rowKey],n=A.tableData.find(e=>q(a.rowKey)?a.rowKey(e):e[a.rowKey]===l);if(!0===t)A.indeterminateSelectedListIds.some(e=>e===l)||A.indeterminateSelectedListIds.push(l),V.value.toggleRowSelection(n,!0);else if(!1===t){const e=A.indeterminateSelectedListIds.findIndex(e=>e===l);e>=0&&A.indeterminateSelectedListIds.splice(e,1),V.value.toggleRowSelection(n,!1)}else{const e=A.indeterminateSelectedListIds.findIndex(e=>e===l);e>=0?A.indeterminateSelectedListIds.splice(e,1):A.indeterminateSelectedListIds.push(l),V.value.toggleRowSelection(n)}},refresh:ie,reset:re,doRender:se,doLoading:ce})}});export{ie as default,oe as faTableEmits,ne as faTableProps,le as tableProps};
|
|
1
|
+
import{isVNode as e,defineComponent as a,ref as t,onMounted as l,watch as n,watchEffect as o,onActivated as i,computed as r,createVNode as s,withDirectives as c,Fragment as d,createTextVNode as u,mergeProps as m,resolveDirective as h}from"vue";import{useSizeProp as g,ElInput as p,ElDatePicker as f,ElButton as b,ElDropdown as C,ElDropdownMenu as w,ElDropdownItem as S,ElTable as y,ElTableColumn as _,ElIcon as v,ElPagination as x,ElImageViewer as P}from"element-plus";import{Search as L,Refresh as I,Eleme as B,Setting as F,More as R}from"@element-plus/icons-vue";import{NotData as O}from"@fast-element-plus/icons-vue";import{definePropType as T,stringUtil as k,consoleWarn as N,clickUtil as D,useProps as E,useRender as j,dateUtil as M,useExpose as z,makeSlots as K}from"@fast-china/utils";import{isNil as A,isString as H,isObject as $,isNumber as V,isBoolean as W,isArray as U,isNull as Y,isFunction as q,pick as G,omit as J}from"lodash-unified";import{getTableDefaultSlots as Q}from"./table.type.mjs";import X from"./tableColumn.mjs";import Z from"./tableColumnSettingDialog.mjs";import ee from"./tablePagination.mjs";import ae from"./tableSearchForm.mjs";import{useTable as te}from"./useTable.mjs";const le={data:{type:Array,default:()=>[]},size:g,width:[String,Number],height:[String,Number],maxHeight:[String,Number],fit:{type:Boolean,default:!0},stripe:Boolean,border:Boolean,rowKey:[String,Function],showHeader:{type:Boolean,default:!0},showSummary:Boolean,sumText:String,summaryMethod:Function,rowClassName:[String,Function],rowStyle:[Object,Function],cellClassName:[String,Function],cellStyle:[Object,Function],headerRowClassName:[String,Function],headerRowStyle:[Object,Function],headerCellClassName:[String,Function],headerCellStyle:[Object,Function],highlightCurrentRow:Boolean,currentRowKey:[String,Number],emptyText:String,expandRowKeys:Array,defaultExpandAll:Boolean,defaultSort:Object,tooltipEffect:String,tooltipOptions:Object,spanMethod:Function,selectOnIndeterminate:{type:Boolean,default:!0},indent:{type:Number,default:16},treeProps:{type:Object,default:()=>({hasChildren:"hasChildren",children:"children",checkStrictly:!1})},lazy:Boolean,load:Function,style:{type:Object,default:()=>({})},className:{type:String,default:""},tableLayout:{type:String,default:"fixed"},scrollbarAlwaysOn:Boolean,flexible:Boolean,showOverflowTooltip:[Boolean,Object],scrollbarTabindex:{type:[Number,String],default:void 0}},ne={...le,border:{type:Boolean,default:!0},highlightCurrentRow:{type:Boolean,default:!0},rowKey:{type:[String,Function],default:"id"},spanMethod:{type:Function,validator:()=>(N("FaTable","'spanMethod' 属性,组件已经封装,外部使用会失效。"),!1)},tableKey:{type:String,default:()=>k.generateRandomString(8)},data:{type:T(Array),default:()=>[]},requestApi:{type:T(Function)},dataCallback:{type:T(Function)},initParam:T([String,Number,Object]),columns:{type:T([Array,Boolean]),default:()=>!1},columnsChange:{type:T(Function)},searchFormCols:{type:T([String,Number,Object]),default:()=>({xs:3,sm:3,md:4,lg:5,xl:6})},collapsedSearch:{type:Boolean,default:!0},advancedSearchDrawer:{type:Boolean,default:!1},searchForm:{type:Boolean,default:!0},headerCard:{type:Boolean,default:!0},refreshBtn:{type:Boolean,default:!0},searchBtn:{type:Boolean,default:!0},columnSettingBtn:{type:Boolean,default:!1},toolBtn:{type:Boolean,default:!0},hideSearchTime:Boolean,futureSearchTime:Boolean,dataSearchRange:{type:T(String),default:"Past3D"},pagination:{type:Boolean,default:!0},hideImage:Boolean,single:Boolean,rowClickSelection:Boolean,treeData:Boolean,props:{type:T(Object),default:()=>({span:void 0,children:"children"})},autoRefresh:{type:Boolean,default:!0},rowSelectable:Function},oe={select:(e,a)=>U(e)&&$(a),selectAll:e=>U(e),selectionChange:e=>U(e),cellMouseEnter:(e,a,t,l)=>$(e)&&$(a)&&t instanceof HTMLTableCellElement&&l instanceof Event,cellMouseLeave:(e,a,t,l)=>$(e)&&$(a)&&t instanceof HTMLTableCellElement&&l instanceof Event,cellClick:(e,a,t,l)=>$(e)&&$(a)&&t instanceof HTMLTableCellElement&&l instanceof Event,cellDblclick:(e,a,t,l)=>$(e)&&$(a)&&t instanceof HTMLTableCellElement&&l instanceof Event,cellContextmenu:(e,a,t,l)=>$(e)&&$(a)&&t instanceof HTMLTableCellElement&&l instanceof Event,rowClick:(e,a,t)=>$(e)&&$(a)&&t instanceof Event,rowContextmenu:(e,a,t)=>$(e)&&$(a)&&t instanceof Event,rowDblclick:(e,a,t)=>$(e)&&$(a)&&t instanceof Event,headerClick:(e,a)=>$(e)&&a instanceof Event,headerContextmenu:(e,a)=>$(e)&&a instanceof Event,sortChange:e=>$(e),filterChange:e=>H(e)||V(e)||W(e)||$(e),currentChange:(e,a)=>$(e)&&(Y(a)||$(a)),headerDragend:(e,a,t,l)=>V(e)&&V(a)&&$(t)&&l instanceof MouseEvent,expandChange:(e,a)=>$(e)&&(W(a)||U(a)),refresh:e=>$(e),reset:e=>$(e),sizeChange:e=>V(e),paginationChange:(e,a)=>V(e)&&V(a),customCellClick:(e,{row:a,column:t,$index:l})=>(A(e)||H(e))&&$(a)&&$(t)&&V(l)},ie=/* @__PURE__ */a({name:"FaTable",props:ne,emits:oe,slots:K(),setup(a,{attrs:g,slots:T,emit:k,expose:N}){const{_globalSize:K,state:A,elementRef:$,tableRef:V,handleTableColumnAutoWidth:W,loadTableColumns:U,handleSizeChange:Y,handlePaginationChange:ne,defaultSearchTime:oe,tableSearch:ie,tableReset:re,doRender:se,doLoading:ce,handleCustomCellClick:de}=te(a,T,k),ue=t();let me=0;const he=e=>{if(0===e&&(me=0),A.spanColumns?.length>0){return 0===Number(A.tableSpanData["__table-index"][e])?me+(A.tablePagination.pageIndex-1)*A.tablePagination.pageSize+1:(me++,me+(A.tablePagination.pageIndex-1)*A.tablePagination.pageSize)}return e+(A.tablePagination.pageIndex-1)*A.tablePagination.pageSize+1},ge=(e,t)=>{a.single&&(V.value.clearSelection(),e.length>0&&t&&V.value.toggleRowSelection(t)),k("select",e,t)},pe=e=>{a.single&&(A.selected?A.tableData.length>0&&(V.value.clearSelection(),V.value.toggleRowSelection(A.tableData[0])):V.value.clearSelection()),k("selectAll",e)},fe=e=>{0===e.length?A.selected=!1:A.selected=!0,a.single&&e.length>0?A.selectedList=[e[e.length-1]]:A.selectedList=e,A.indeterminateSelectedListIds=A.indeterminateSelectedListIds.filter(e=>A.selectedListIds.some(a=>a===e)),k("selectionChange",A.selectedList)},be=({column:e,prop:t,order:l})=>{e.multiOrder?"descending"===e.multiOrder?e.multiOrder="ascending":e.multiOrder=null:e.multiOrder="descending",A.searchParam.sortList=[.../* @__PURE__ */new Set([...a.initParam?.sortList??[],...A.searchParam?.sortList??[]])];const n=A.orgColumns.find(e=>e.prop===t),o=n?.sortableField??n?.prop??e.property,i=A.searchParam.sortList.findIndex(e=>e.enField===o);e.multiOrder?-1===i?A.searchParam.sortList.push({enField:o,cnField:e.label,mode:e.multiOrder}):A.searchParam.sortList[i].mode=e.multiOrder:A.searchParam.sortList.splice(i,1),0===A.searchParam.sortList.length&&delete A.searchParam.sortList,k("sortChange",{column:e,prop:t,order:e.multiOrder}),ie()},Ce=(e,t)=>{e&&(a.rowClickSelection&&(a.single&&t&&V.value.toggleRowSelection(t),V.value.toggleRowSelection(e)),k("currentChange",e,t))},we=({row:e,column:t,rowIndex:l,columnIndex:n})=>{let o=null;if("selection"===t.type){const t=q(a.rowKey)?a.rowKey(e):e[a.rowKey];A.indeterminateSelectedListIds.some(e=>e===t)&&(o="fa-table__selection-column__indeterminate")}const i=A.tableColumns.find(e=>e.prop===t.property);if(i?.dataDeleteField&&e&&!0===e[i.dataDeleteField]&&(o?o+=" fa-table__data-delete-column":o="fa-table__data-delete-column"),a.cellClassName){let i=null;return i=H(a.cellClassName)?a.cellClassName:a.cellClassName({row:e,column:t,rowIndex:l,columnIndex:n}),i?o?`${o} ${i}`:i:o}return o},Se=({row:e,column:t,rowIndex:l,columnIndex:n})=>(t.order=t.multiOrder,a.headerCellClassName?q(a.headerCellClassName)?a.headerCellClassName({row:e,column:t,rowIndex:l,columnIndex:n}):a.headerCellClassName:null),ye=({row:e,column:a,rowIndex:t,columnIndex:l})=>{const n=a.property??a.columnKey;if(-1!==A.spanColumns.findIndex(e=>e.prop===n)){const e=Number(A.tableSpanData[n][t]);return e>0?{rowspan:e,colspan:1}:{rowspan:0,colspan:0}}return{rowspan:1,colspan:1}},_e=async(e,t,l,n)=>{A.orgColumns.forEach(a=>{l.property===a.prop&&(a.width=e,a.smallWidth=e)}),k("headerDragend",e,t,l,n),a.columnsChange&&await D.debounceAsync(()=>a.columnsChange(A.orgColumns),500)},ve=e=>{A.previewList=[e],A.imagePreview=!0};l(async()=>{A.initParam=a.initParam,oe(),Object.keys(a.initParam??{}).forEach(e=>{A.searchParam[e]=a.initParam[e]}),await ie(),n(()=>a.columns,async()=>{U()},{deep:!0,immediate:!0}),n(()=>a.initParam,()=>{Object.keys(a.initParam??{}).forEach(e=>{A.searchParam[e]=a.initParam[e]})},{deep:!0}),n(()=>a.data,async()=>{!a.requestApi&&a.autoRefresh&&await ie()},{deep:!0,immediate:!0}),o(async()=>{const e=$.value;if(e){const a=new ResizeObserver(e=>{for(const a of e){const{width:e,height:t}=a.contentRect;A.tableWidth=e,A.tableHeight=t}D.debounceAsync(async()=>{await W()},100)});return a.observe(e),()=>{a.disconnect()}}})}),i(async()=>{await W()});const xe=r(()=>A.searchColumns.filter(e=>e.search.slot).map(e=>e.search.slot)),Pe=r(()=>A.tableColumns.filter(e=>e.slot).map(e=>e.slot)),Le=["multiOrder","columnId","order","sortableField","disabledSortable","spanProp","pureSearch","search"],Ie=E(a,le,["data","spanMethod","headerCellClassName","cellClassName"]);return j(()=>s("div",{ref:$,class:["fa-table",`fa-table-${K.value}`,`fa-table__${a.tableKey??"notFound"}`,{fa__click__disabled:A.loading}],style:{"--fa-table-width":""+(A.tableWidth?`${A.tableWidth}px`:""),"--fa-table-height":""+(A.tableHeight?`${A.tableHeight}px`:"")}},[s(ae,{show:a.searchForm&&A.searchForm,collapsedSearch:a.collapsedSearch,advancedSearchDrawer:a.advancedSearchDrawer,cols:a.searchFormCols,search:ie,reset:re},G(T,xe.value)),T.topHeader&&s("div",{class:"el-card fa-table__header"},[T.topHeader({search:ie,...Q(A)})]),s("div",{class:"el-card fa-table__main"},[a.headerCard&&s("div",{class:"fa-table__main-header"},[s("div",{class:"fa-table__main-header-left"},[T.header&&T.header({search:ie,...Q(A)})]),s("div",{class:"fa-table__main-header-right"},[a.toolBtn&&s(d,null,[s("div",{class:"fa-table__main-header-right__div-search"},[s(p,{class:"fa-table__main-header-right__input-search",disabled:A.loading,prefixIcon:L,placeholder:"关键字搜索",modelValue:A.searchParam.searchValue,modelModifiers:{trim:!0},"onUpdate:modelValue":e=>A.searchParam.searchValue=e,clearable:!0,onCompositionupdate:e=>{A.searchValueUpdate=e.data},onCompositionend:e=>{A.searchValueUpdate=""},onChange:()=>ie()},null),s("div",{class:"fa-table__main-header-right__div-search__hidden"},[A.searchParam.searchValue,A.searchValueUpdate])]),a.requestApi&&!a.hideSearchTime&&s(f,{class:"fa-table__main-header-right__data-search",popperClass:"fa-table__main-header-right__data-search__popper",disabled:A.loading,type:"daterange",modelValue:A.searchParam.searchTimeList,"onUpdate:modelValue":e=>A.searchParam.searchTimeList=e,defaultTime:M.getDefaultTime(a.futureSearchTime),shortcuts:M.getShortcuts(a.futureSearchTime),valueFormat:"YYYY-MM-DD HH:mm:ss",clearable:!1,teleported:!1,unlinkPanels:!0,onChange:()=>ie()},null),a.refreshBtn&&s(b,{loading:A.loading,loadingIcon:B,title:"刷新",circle:!0,icon:I,onClick:()=>ie()},null),a.searchBtn&&A.searchColumns.length>0&&s(b,{loading:A.loading,loadingIcon:B,title:A.searchForm?"隐藏搜索栏":"显示搜索栏",circle:!0,icon:L,onClick:()=>A.searchForm=!A.searchForm},null),a.columnSettingBtn&&a.columns&&s(C,{title:"表格列配置",trigger:"click"},{default:()=>s(b,{loading:A.loading,loadingIcon:B,circle:!0,icon:F},null),dropdown:()=>s(w,null,{default:()=>[T.columnSetting&&T.columnSetting(),s(S,{title:"表格列配置",divided:!0,onClick:()=>ue.value.open()},{default:()=>[u("表格列配置")]})]})}),T.toolButton&&T.toolButton({search:ie,...Q(A)}),T.toolButtonAdv&&s(C,{title:"高级操作",trigger:"click"},{default:()=>s(b,{loading:A.loading,loadingIcon:B,circle:!0,icon:R},null),dropdown:()=>{let a;return s(w,null,"function"==typeof(t=a=T.toolButtonAdv({search:ie,...Q(A)}))||"[object Object]"===Object.prototype.toString.call(t)&&!e(t)?a:{default:()=>[a]});var t}})])])]),c(s(y,m(Ie.value,{ref:V,"element-loading-text":A.loadingText,data:A.tableData,spanMethod:ye,headerCellClassName:Se,cellClassName:we,onSelectionChange:fe,onSortChange:be,onSelect:ge,onSelectAll:pe,onCurrentChange:Ce,onHeaderDragend:_e,onCellMouseEnter:(e,a,t,l)=>k("cellMouseEnter",e,a,t,l),onCellMouseLeave:(e,a,t,l)=>k("cellMouseLeave",e,a,t,l),onCellClick:(e,a,t,l)=>k("cellClick",e,a,t,l),onCellDblclick:(e,a,t,l)=>k("cellDblclick",e,a,t,l),onCellContextmenu:(e,a,t,l)=>k("cellContextmenu",e,a,t,l),onRowClick:(e,a,t)=>k("rowClick",e,a,t),onRowContextmenu:(e,a,t)=>k("rowContextmenu",e,a,t),onRowDblclick:(e,a,t)=>k("rowDblclick",e,a,t),onHeaderClick:(e,a)=>k("headerClick",e,a),onHeaderContextmenu:(e,a)=>k("headerContextmenu",e,a),onFilterChange:e=>k("filterChange",e),onExpandChange:(e,a)=>k("expandChange",e,a)}),{append:()=>T.append&&T.append(),empty:()=>s("div",{class:"fa-table__empty"},[T.empty?T.empty():s(d,null,[s(v,null,{default:()=>[s(O,null,null)]}),s("div",null,[u("暂无数据")])])]),default:()=>s(d,null,[s(_,{className:"fa-table__index-column",type:"index",fixed:"left",width:A.tablePagination.pageIndex*A.tablePagination.pageSize>=100?A.tablePagination.pageIndex*A.tablePagination.pageSize>=1e3?50:40:30,align:"center",index:he,showOverflowTooltip:!1,resizable:!1,columnKey:"__table-index"},null),s(_,{className:"fa-table__selection-column",type:"selection",fixed:"left",width:35,align:"center",reserveSelection:!0,showOverflowTooltip:!1,resizable:!1,columnKey:"__table-selection",selectable:a.rowSelectable},null),T.operation&&s(_,{fixed:"right",width:A.operationColumnWidth,headerAlign:"center",align:"left",showOverflowTooltip:!1,className:"fa-table__operation-column",resizable:!1,columnKey:"__table-operation"},{header:()=>s("div",{class:"fa-table__auto-width-column__cell-header __fa-table__auto-width-column__cell-header____table-operation"},[s("span",null,[u("操作")])]),default:({row:e,column:a,$index:t})=>s("div",{class:"fa-table__auto-width-column__cell __fa-table__auto-width-column__cell____table-operation"},[T.operation({row:e,column:a,$index:t,search:ie,...Q(A)})])}),0===A.tableColumns?.length?T.default&&T.default():A.tableColumns.map(e=>e.show&&("expand"===e.type?s(_,m(e,{width:35,fixed:e.fixed??"left",resizable:!1}),{default:({row:a,column:t,$index:l})=>s(d,null,[e.render&&e.render({row:a,column:t,$index:l,...Q(A)}),e.slot&&T[e.slot]&&T[e.slot]({row:a,column:t,$index:l,...Q(A)})])}):e.prop&&s(X,m(J(e,Le),{hideImage:a.hideImage,resizable:!0,onImagePreview:ve,onCustomCellClick:de}),G(T,Pe.value))))])}),[[h("loading"),A.loading]]),s("div",{class:"fa-table__main-footer"},[s("div",{class:"fa-table__main-footer__left"},[T.footer&&T.footer({search:ie,...Q(A)})]),T.pagination?T.pagination({pageIndex:A.tablePagination.pageIndex,pageSize:A.tablePagination.pageSize,totalRows:A.tablePagination.totalRows,handleSizeChange:Y,handlePaginationChange:ne}):s(d,null,[a.pagination?s(ee,{onSizeChange:Y,onCurrentChange:ne},null):s(x,{class:"fa-table-pagination",size:"small",layout:"total",total:A.tableData.length},null)])])]),A.imagePreview&&s(P,{closeOnPressEscape:!0,hideOnClickModal:!0,teleported:!0,showProgress:!0,onClose:()=>A.imagePreview=!1,urlList:A.previewList},null),a.columnSettingBtn&&s(Z,{ref:ue,change:a.columnsChange},null)])),z(N,{clearSelection:r(()=>V.value?.clearSelection),getSelectionRows:r(()=>V.value?.getSelectionRows),toggleRowSelection:r(()=>V.value?.toggleRowSelection),toggleAllSelection:r(()=>V.value?.toggleAllSelection),toggleRowExpansion:r(()=>V.value?.toggleRowExpansion),setCurrentRow:r(()=>V.value?.setCurrentRow),clearSort:r(()=>V.value?.clearSort),clearFilter:r(()=>V.value?.clearFilter),doLayout:r(()=>V.value?.doLayout),sort:r(()=>V.value?.sort),scrollTo:r(()=>V.value?.scrollTo),setScrollTop:r(()=>V.value?.setScrollTop),setScrollLeft:r(()=>V.value?.setScrollLeft),columns:r(()=>V.value?.columns),updateKeyChildren:r(()=>V.value?.updateKeyChildren),loading:r(()=>A.loading),tableData:r(()=>A.tableData),tablePagination:r(()=>A.tablePagination),searchParam:r(()=>A.searchParam),selected:r(()=>A.selected),selectedList:r(()=>A.selectedList),selectedListIds:r(()=>A.selectedListIds),indeterminateSelectedListIds:r(()=>A.indeterminateSelectedListIds),tableWidth:r(()=>A.tableWidth),tableHeight:r(()=>A.tableHeight),toggleRowIndeterminateSelection:(e,t)=>{const l=q(a.rowKey)?a.rowKey(e):e[a.rowKey],n=A.tableData.find(e=>q(a.rowKey)?a.rowKey(e):e[a.rowKey]===l);if(!0===t)A.indeterminateSelectedListIds.some(e=>e===l)||A.indeterminateSelectedListIds.push(l),V.value.toggleRowSelection(n,!0);else if(!1===t){const e=A.indeterminateSelectedListIds.findIndex(e=>e===l);e>=0&&A.indeterminateSelectedListIds.splice(e,1),V.value.toggleRowSelection(n,!1)}else{const e=A.indeterminateSelectedListIds.findIndex(e=>e===l);e>=0?A.indeterminateSelectedListIds.splice(e,1):A.indeterminateSelectedListIds.push(l),V.value.toggleRowSelection(n)}},refresh:ie,reset:re,doRender:se,doLoading:ce})}});export{ie as default,oe as faTableEmits,ne as faTableProps,le as tableProps};
|
|
2
2
|
//# sourceMappingURL=table.mjs.map
|