easybill-ui 1.4.1 → 1.4.3
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/_virtual/_plugin-vue_export-helper.js +9 -0
- package/dist/assets/easybill-ui.css +1 -0
- package/dist/components/ConstantStatus/index.d.ts +24 -0
- package/dist/components/ConstantStatus/index.js +7 -0
- package/dist/components/ConstantStatus/src/ConstantStatus.vue.d.ts +25 -0
- package/dist/components/ConstantStatus/src/ConstantStatus.vue.js +76 -0
- package/dist/components/ConstantStatus/src/ConstantStatus.vue2.js +4 -0
- package/dist/components/ConstantStatus/src/index.d.ts +3 -0
- package/dist/components/ConstantStatus/src/index.js +5 -0
- package/dist/components/ConstantStatus/src/types.d.ts +18 -0
- package/dist/components/CurdForm/index.d.ts +49 -0
- package/dist/components/CurdForm/index.js +9 -0
- package/dist/components/CurdForm/src/CurdForm.vue.js +7 -0
- package/dist/components/CurdForm/src/CurdForm.vue2.js +326 -0
- package/dist/components/CurdForm/src/CurdFormItem.vue.d.ts +37 -0
- package/dist/components/CurdForm/src/CurdFormItem.vue.js +55 -0
- package/dist/components/CurdForm/src/CurdFormItem.vue2.js +4 -0
- package/dist/components/CurdForm/src/FormItem.vue.d.ts +44 -0
- package/dist/components/CurdForm/src/FormItem.vue.js +128 -0
- package/dist/components/CurdForm/src/FormItem.vue2.js +4 -0
- package/dist/components/CurdForm/src/FormTooltip.vue.d.ts +33 -0
- package/dist/components/CurdForm/src/FormTooltip.vue.js +63 -0
- package/dist/components/CurdForm/src/FormTooltip.vue2.js +4 -0
- package/dist/components/CurdForm/src/components/index.d.ts +10 -0
- package/dist/components/CurdForm/src/components/index.js +38 -0
- package/dist/components/CurdForm/src/components/schema-form-autocomplete.vue.d.ts +56 -0
- package/dist/components/CurdForm/src/components/schema-form-autocomplete.vue.js +39 -0
- package/dist/components/CurdForm/src/components/schema-form-autocomplete.vue2.js +4 -0
- package/dist/components/CurdForm/src/components/schema-form-cascader.vue.d.ts +56 -0
- package/dist/components/CurdForm/src/components/schema-form-cascader.vue.js +32 -0
- package/dist/components/CurdForm/src/components/schema-form-cascader.vue2.js +4 -0
- package/dist/components/CurdForm/src/components/schema-form-checkbox.vue.d.ts +59 -0
- package/dist/components/CurdForm/src/components/schema-form-checkbox.vue.js +86 -0
- package/dist/components/CurdForm/src/components/schema-form-checkbox.vue2.js +33 -0
- package/dist/components/CurdForm/src/components/schema-form-choose.vue.js +217 -0
- package/dist/components/CurdForm/src/components/schema-form-choose.vue2.js +4 -0
- package/dist/components/CurdForm/src/components/schema-form-color-picker.vue.d.ts +54 -0
- package/dist/components/CurdForm/src/components/schema-form-color-picker.vue.js +15 -0
- package/dist/components/CurdForm/src/components/schema-form-color-picker.vue2.js +19 -0
- package/dist/components/CurdForm/src/components/schema-form-date-picker.vue.d.ts +56 -0
- package/dist/components/CurdForm/src/components/schema-form-date-picker.vue.js +32 -0
- package/dist/components/CurdForm/src/components/schema-form-date-picker.vue2.js +27 -0
- package/dist/components/CurdForm/src/components/schema-form-input-number.vue.d.ts +54 -0
- package/dist/components/CurdForm/src/components/schema-form-input-number.vue.js +39 -0
- package/dist/components/CurdForm/src/components/schema-form-input-number.vue2.js +4 -0
- package/dist/components/CurdForm/src/components/schema-form-input.vue.d.ts +54 -0
- package/dist/components/CurdForm/src/components/schema-form-input.vue.js +44 -0
- package/dist/components/CurdForm/src/components/schema-form-input.vue2.js +4 -0
- package/dist/components/CurdForm/src/components/schema-form-radio.vue.d.ts +54 -0
- package/dist/components/CurdForm/src/components/schema-form-radio.vue.js +114 -0
- package/dist/components/CurdForm/src/components/schema-form-radio.vue2.js +4 -0
- package/dist/components/CurdForm/src/components/schema-form-select-v2.vue.d.ts +54 -0
- package/dist/components/CurdForm/src/components/schema-form-select-v2.vue.js +69 -0
- package/dist/components/CurdForm/src/components/schema-form-select-v2.vue2.js +4 -0
- package/dist/components/CurdForm/src/components/schema-form-select.vue.js +65 -0
- package/dist/components/CurdForm/src/components/schema-form-select.vue2.js +66 -0
- package/dist/components/CurdForm/src/components/schema-form-switch.vue.d.ts +54 -0
- package/dist/components/CurdForm/src/components/schema-form-switch.vue.js +14 -0
- package/dist/components/CurdForm/src/components/schema-form-switch.vue2.js +25 -0
- package/dist/components/CurdForm/src/components/schema-form-time-picker.vue.d.ts +57 -0
- package/dist/components/CurdForm/src/components/schema-form-time-picker.vue.js +29 -0
- package/dist/components/CurdForm/src/components/schema-form-time-picker.vue2.js +30 -0
- package/dist/components/CurdForm/src/components/schema-form-tree-select.vue.d.ts +58 -0
- package/dist/components/CurdForm/src/components/schema-form-tree-select.vue.js +55 -0
- package/dist/components/CurdForm/src/components/schema-form-tree-select.vue2.js +31 -0
- package/dist/components/CurdForm/src/components/schema-form-value.vue.d.ts +54 -0
- package/dist/components/CurdForm/src/components/schema-form-value.vue.js +11 -0
- package/dist/components/CurdForm/src/components/schema-form-value.vue2.js +21 -0
- package/dist/components/CurdForm/src/directive/index.d.ts +12 -0
- package/dist/components/CurdForm/src/directive/index.js +32 -0
- package/dist/components/CurdForm/src/hooks/index.d.ts +4 -0
- package/dist/components/CurdForm/src/hooks/index.js +7 -0
- package/dist/components/CurdForm/src/types.d.ts +150 -0
- package/dist/components/CurdForm/src/types.js +27 -0
- package/dist/components/CurdForm/src/utils/ajax.d.ts +25 -0
- package/dist/components/CurdForm/src/utils/common.d.ts +1 -0
- package/dist/components/CurdForm/src/utils/common.js +13 -0
- package/dist/components/CurdGroupForm/index.d.ts +2 -0
- package/dist/components/CurdGroupForm/src/CurdGroupForm.vue.d.ts +36 -0
- package/dist/components/CurdGroupForm/src/CurdGroupForm.vue.js +113 -0
- package/dist/components/CurdGroupForm/src/CurdGroupForm.vue2.js +4 -0
- package/dist/components/CurdGroupForm/src/components/CurdFormGroup.vue.d.ts +52 -0
- package/dist/components/CurdGroupForm/src/components/CurdFormGroup.vue.js +64 -0
- package/dist/components/CurdGroupForm/src/components/CurdFormGroup.vue2.js +4 -0
- package/dist/components/CurdGroupForm/src/hooks/useFormHook.d.ts +12 -0
- package/dist/components/CurdGroupForm/src/hooks/useFormHook.js +32 -0
- package/dist/components/CurdGroupForm/types.d.ts +33 -0
- package/dist/components/CurdTable/index.d.ts +13 -0
- package/dist/components/CurdTable/index.js +7 -0
- package/dist/components/CurdTable/src/CurdTable.vue.js +562 -0
- package/dist/components/CurdTable/src/CurdTable.vue2.js +4 -0
- package/dist/components/CurdTable/src/STableColumnControl.vue.d.ts +21 -0
- package/dist/components/CurdTable/src/STableColumnControl.vue.js +132 -0
- package/dist/components/CurdTable/src/STableColumnControl.vue2.js +4 -0
- package/dist/components/CurdTable/src/STableDetail.vue.d.ts +9 -0
- package/dist/components/CurdTable/src/STableDetail.vue.js +53 -0
- package/dist/components/CurdTable/src/STableDetail.vue2.js +4 -0
- package/dist/components/CurdTable/src/STableFilter.vue.d.ts +28 -0
- package/dist/components/CurdTable/src/STableFilter.vue.js +40 -0
- package/dist/components/CurdTable/src/STableFilter.vue2.js +4 -0
- package/dist/components/CurdTable/src/STableItem.vue.d.ts +127 -0
- package/dist/components/CurdTable/src/STableItem.vue.js +147 -0
- package/dist/components/CurdTable/src/STableItem.vue2.js +4 -0
- package/dist/components/CurdTable/src/STableItemFilter.vue.d.ts +34 -0
- package/dist/components/CurdTable/src/STableItemFilter.vue.js +71 -0
- package/dist/components/CurdTable/src/STableItemFilter.vue2.js +4 -0
- package/dist/components/CurdTable/src/STableItemFormatter.vue.d.ts +38 -0
- package/dist/components/CurdTable/src/STableItemFormatter.vue.js +34 -0
- package/dist/components/CurdTable/src/STableItemFormatter.vue2.js +4 -0
- package/dist/components/CurdTable/src/STableItemHeader.vue.d.ts +16 -0
- package/dist/components/CurdTable/src/STableItemHeader.vue.js +24 -0
- package/dist/components/CurdTable/src/STableItemHeader.vue2.js +4 -0
- package/dist/components/CurdTable/src/STableItemHeaderTooltip.vue.d.ts +14 -0
- package/dist/components/CurdTable/src/STableItemHeaderTooltip.vue.js +48 -0
- package/dist/components/CurdTable/src/STableItemHeaderTooltip.vue2.js +4 -0
- package/dist/components/CurdTable/src/STableMenu.vue.d.ts +20 -0
- package/dist/components/CurdTable/src/STableMenu.vue.js +120 -0
- package/dist/components/CurdTable/src/STableMenu.vue2.js +4 -0
- package/dist/components/CurdTable/src/hooks/useColumnHook.d.ts +9 -0
- package/dist/components/CurdTable/src/hooks/useColumnHook.js +45 -0
- package/dist/components/CurdTable/src/types.d.ts +178 -0
- package/dist/components/CurdTable/utils/common.d.ts +5 -0
- package/dist/components/CurdTable/utils/common.js +18 -0
- package/dist/components/CurdTable/utils/tabelToExcel.d.ts +4 -0
- package/dist/components/CurdTable/utils/tabelToExcel.js +23 -0
- package/dist/components/DetailInfo/index.d.ts +147 -0
- package/dist/components/DetailInfo/index.js +7 -0
- package/dist/components/DetailInfo/src/DetailInfo.vue.d.ts +77 -0
- package/dist/components/DetailInfo/src/DetailInfo.vue.js +144 -0
- package/dist/components/DetailInfo/src/DetailInfo.vue2.js +4 -0
- package/dist/components/DetailInfo/src/DetailInfoContent.vue.d.ts +16 -0
- package/dist/components/DetailInfo/src/DetailInfoContent.vue.js +43 -0
- package/dist/components/DetailInfo/src/DetailInfoContent.vue2.js +4 -0
- package/dist/components/DetailInfo/src/DetailInfoTooltip.vue.d.ts +15 -0
- package/dist/components/DetailInfo/src/DetailInfoTooltip.vue.js +48 -0
- package/dist/components/DetailInfo/src/DetailInfoTooltip.vue2.js +4 -0
- package/dist/components/DetailInfo/src/types.d.ts +22 -0
- package/dist/components/FormDialog/index.d.ts +7 -0
- package/dist/components/FormDialog/index.js +6 -0
- package/dist/components/FormDialog/src/FormDialog.vue.d.ts +247 -0
- package/dist/components/FormDialog/src/FormDialog.vue.js +117 -0
- package/dist/components/FormDialog/src/FormDialog.vue2.js +191 -0
- package/dist/components/FormDialog/src/hooks/index.d.ts +2 -0
- package/dist/components/FormDialog/src/hooks/useStepList.d.ts +14 -0
- package/dist/components/FormDialog/src/hooks/useStepList.js +27 -0
- package/dist/components/FormDialog/src/hooks/useStepNavigation.d.ts +75 -0
- package/dist/components/FormDialog/src/hooks/useStepNavigation.js +34 -0
- package/dist/components/FormDialog/src/index.d.ts +13 -0
- package/dist/components/FormDialog/src/index.js +23 -0
- package/dist/components/FormDialog/src/types.d.ts +63 -0
- package/dist/components/TableFilter/index.d.ts +6 -0
- package/dist/components/TableFilter/index.js +7 -0
- package/dist/components/TableFilter/src/FilterExternal/FilterExternal.vue.js +91 -0
- package/dist/components/TableFilter/src/FilterExternal/FilterExternal.vue2.js +4 -0
- package/dist/components/TableFilter/src/FilterSearchBox.vue.d.ts +33 -0
- package/dist/components/TableFilter/src/FilterSearchBox.vue.js +71 -0
- package/dist/components/TableFilter/src/FilterSearchBox.vue2.js +4 -0
- package/dist/components/TableFilter/src/TableFilter.vue.js +180 -0
- package/dist/components/TableFilter/src/TableFilter.vue2.js +4 -0
- package/dist/components/TableFilter/src/components/FilterItem.vue.d.ts +37 -0
- package/dist/components/TableFilter/src/components/FilterItem.vue.js +63 -0
- package/dist/components/TableFilter/src/components/FilterItem.vue2.js +4 -0
- package/dist/components/TableFilter/src/components/FilterTags.vue.d.ts +114 -0
- package/dist/components/TableFilter/src/components/FilterTags.vue.js +142 -0
- package/dist/components/TableFilter/src/components/FilterTags.vue2.js +4 -0
- package/dist/components/TableFilter/src/components/FilterToggle.vue.d.ts +29 -0
- package/dist/components/TableFilter/src/components/FilterToggle.vue.js +70 -0
- package/dist/components/TableFilter/src/components/FilterToggle.vue2.js +4 -0
- package/dist/components/TableFilter/src/components/FilterType.vue.d.ts +30 -0
- package/dist/components/TableFilter/src/components/FilterType.vue.js +62 -0
- package/dist/components/TableFilter/src/components/FilterType.vue2.js +4 -0
- package/dist/components/TableFilter/src/components/containers/TagsSelect.vue.d.ts +42 -0
- package/dist/components/TableFilter/src/components/containers/TagsSelect.vue.js +99 -0
- package/dist/components/TableFilter/src/components/containers/TagsSelect.vue2.js +4 -0
- package/dist/components/TableFilter/types.d.ts +34 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.js +35 -0
- package/dist/locale/index.d.ts +9 -0
- package/dist/locale/index.js +6 -0
- package/dist/locale/lang/en.d.ts +49 -0
- package/{locale/lang/en.ts → dist/locale/lang/en.js} +10 -7
- package/dist/locale/lang/zh-cn.d.ts +49 -0
- package/{locale/lang/zh-cn.ts → dist/locale/lang/zh-cn.js} +10 -7
- package/dist/utils/common/index.d.ts +8 -0
- package/dist/utils/common/index.js +13 -0
- package/dist/utils/hooks/useGlobalConfig.d.ts +13 -0
- package/dist/utils/hooks/useGlobalConfig.js +22 -0
- package/dist/utils/hooks/useLocal.d.ts +15 -0
- package/dist/utils/hooks/useLocal.js +33 -0
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.js +6 -0
- package/dist/utils/vue/index.d.ts +2 -0
- package/dist/utils/vue/index.js +4 -0
- package/dist/utils/vue/install.d.ts +2 -0
- package/dist/utils/vue/install.js +14 -0
- package/dist/utils/vue/make-installer.d.ts +5 -0
- package/dist/utils/vue/make-installer.js +9 -0
- package/dist/utils/vue/typescript.d.ts +5 -0
- package/package.json +55 -46
- package/components/ConstantStatus/index.ts +0 -5
- package/components/ConstantStatus/src/ConstantStatus.vue +0 -69
- package/components/ConstantStatus/src/index.ts +0 -3
- package/components/ConstantStatus/src/types.ts +0 -18
- package/components/CurdForm/index.ts +0 -9
- package/components/CurdForm/src/CurdForm.vue +0 -500
- package/components/CurdForm/src/CurdFormItem.vue +0 -70
- package/components/CurdForm/src/FormItem.vue +0 -105
- package/components/CurdForm/src/FormTooltip.vue +0 -54
- package/components/CurdForm/src/components/index.ts +0 -52
- package/components/CurdForm/src/components/schema-form-autocomplete.vue +0 -25
- package/components/CurdForm/src/components/schema-form-cascader.vue +0 -24
- package/components/CurdForm/src/components/schema-form-checkbox.vue +0 -53
- package/components/CurdForm/src/components/schema-form-choose.vue +0 -225
- package/components/CurdForm/src/components/schema-form-color-picker.vue +0 -23
- package/components/CurdForm/src/components/schema-form-date-picker.vue +0 -34
- package/components/CurdForm/src/components/schema-form-input-number.vue +0 -12
- package/components/CurdForm/src/components/schema-form-input.vue +0 -21
- package/components/CurdForm/src/components/schema-form-radio.vue +0 -59
- package/components/CurdForm/src/components/schema-form-select-v2.vue +0 -60
- package/components/CurdForm/src/components/schema-form-select.vue +0 -93
- package/components/CurdForm/src/components/schema-form-switch.vue +0 -29
- package/components/CurdForm/src/components/schema-form-time-picker.vue +0 -37
- package/components/CurdForm/src/components/schema-form-tree-select.vue +0 -45
- package/components/CurdForm/src/components/schema-form-value.vue +0 -25
- package/components/CurdForm/src/directive/index.ts +0 -60
- package/components/CurdForm/src/hooks/index.ts +0 -6
- package/components/CurdForm/src/types.ts +0 -146
- package/components/CurdForm/src/utils/ajax.ts +0 -125
- package/components/CurdForm/src/utils/common.ts +0 -17
- package/components/CurdGroupForm/index.ts +0 -2
- package/components/CurdGroupForm/src/CurdGroupForm.vue +0 -93
- package/components/CurdGroupForm/src/components/CurdFormGroup.vue +0 -39
- package/components/CurdGroupForm/src/hooks/useFormHook.ts +0 -55
- package/components/CurdGroupForm/types.ts +0 -22
- package/components/CurdTable/index.ts +0 -5
- package/components/CurdTable/src/CurdTable.vue +0 -470
- package/components/CurdTable/src/STableColumnControl.vue +0 -88
- package/components/CurdTable/src/STableDetail.vue +0 -52
- package/components/CurdTable/src/STableFilter.vue +0 -50
- package/components/CurdTable/src/STableItem.vue +0 -119
- package/components/CurdTable/src/STableItemFilter.vue +0 -53
- package/components/CurdTable/src/STableItemFormatter.vue +0 -35
- package/components/CurdTable/src/STableItemHeader.vue +0 -33
- package/components/CurdTable/src/STableItemHeaderTooltip.vue +0 -32
- package/components/CurdTable/src/STableMenu.vue +0 -77
- package/components/CurdTable/src/hooks/useColumnHook.ts +0 -77
- package/components/CurdTable/src/types.ts +0 -163
- package/components/CurdTable/utils/common.ts +0 -33
- package/components/CurdTable/utils/tabelToExcel.ts +0 -68
- package/components/DetailInfo/index.ts +0 -5
- package/components/DetailInfo/src/DetailInfo.vue +0 -108
- package/components/DetailInfo/src/DetailInfoContent.vue +0 -27
- package/components/DetailInfo/src/DetailInfoTooltip.vue +0 -33
- package/components/DetailInfo/src/types.ts +0 -23
- package/components/FormDialog/index.ts +0 -3
- package/components/FormDialog/src/FormDialog.vue +0 -276
- package/components/FormDialog/src/hooks/index.ts +0 -2
- package/components/FormDialog/src/hooks/useStepList.ts +0 -49
- package/components/FormDialog/src/hooks/useStepNavigation.ts +0 -74
- package/components/FormDialog/src/index.ts +0 -39
- package/components/FormDialog/src/types.ts +0 -51
- package/components/TableFilter/index.ts +0 -6
- package/components/TableFilter/src/FilterExternal/FilterExternal.vue +0 -121
- package/components/TableFilter/src/FilterSearchBox.vue +0 -65
- package/components/TableFilter/src/TableFilter.vue +0 -236
- package/components/TableFilter/src/components/FilterItem.vue +0 -76
- package/components/TableFilter/src/components/FilterTags.vue +0 -132
- package/components/TableFilter/src/components/FilterToggle.vue +0 -40
- package/components/TableFilter/src/components/FilterType.vue +0 -78
- package/components/TableFilter/src/components/containers/TagsSelect.vue +0 -89
- package/components/TableFilter/types.ts +0 -36
- package/index.ts +0 -25
- package/locale/index.ts +0 -11
- package/utils/common/index.ts +0 -24
- package/utils/hooks/useGlobalConfig.ts +0 -39
- package/utils/hooks/useLocal.ts +0 -61
- package/utils/index.ts +0 -2
- package/utils/vue/index.ts +0 -3
- package/utils/vue/install.ts +0 -18
- package/utils/vue/make-installer.ts +0 -16
- package/utils/vue/typescript.ts +0 -7
|
@@ -1,276 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<component :is="componentName" v-bind="containerProps">
|
|
3
|
-
<el-steps v-if="isGroupMode && hasMultipleSteps && !stepComponent" :active="activeStep" align-center style="margin-bottom: 20px; position: sticky; top: 0; z-index: 2000; background: var(--el-bg-color)" v-bind="stepProps">
|
|
4
|
-
<el-step v-for="(stepItem, i) in stepList" :key="i" :title="stepItem.name" />
|
|
5
|
-
</el-steps>
|
|
6
|
-
<component v-if="stepComponent" :is="stepComponent" :step="activeStep" :steps="stepList" />
|
|
7
|
-
<div v-loading="confirmLoading" class="form-dialog-content">
|
|
8
|
-
<!-- 单表单模式 -->
|
|
9
|
-
<curd-form v-if="isFormMode" ref="curdFormRef" v-model="form" :fields="fields" :form-schema="formSchema" :extend-context="extendContexts" />
|
|
10
|
-
<!-- 分组表单模式 -->
|
|
11
|
-
<template v-else-if="isGroupMode">
|
|
12
|
-
<div v-for="(stepItem, i) in stepList" :key="i" class="form-dialog-step" v-show="activeStep === i">
|
|
13
|
-
<curd-group-form :ref="(el: any) => el && (groupFormRef[i] = el)" v-model="form" :schema="stepItem.schema" :fields="fields" :extend-context="extendContexts" />
|
|
14
|
-
</div>
|
|
15
|
-
</template>
|
|
16
|
-
</div>
|
|
17
|
-
<template #footer>
|
|
18
|
-
<component v-if="footerComponent" :is="footerComponent" />
|
|
19
|
-
<span v-else-if="handleOk" class="dialog-footer">
|
|
20
|
-
<el-button v-if="cancelBtnTextLabel" :disabled="confirmLoading" type="default" @click="onCancel()">{{ cancelBtnTextLabel }}</el-button>
|
|
21
|
-
<el-button v-if="isGroupMode && hasMultipleSteps && canPrev" :disabled="confirmLoading" type="primary" plain @click="prev()">{{ t("el.formDialog.preStep") }}</el-button>
|
|
22
|
-
<el-button v-if="isGroupMode && hasMultipleSteps && canNext" :disabled="confirmLoading" type="primary" plain @click="next()">{{ t("el.formDialog.nextStep") }}</el-button>
|
|
23
|
-
<el-button v-if="(!isGroupMode || isLastStep) && confirmBtnTextLabel" :disabled="confirmLoading" type="primary" :loading="confirmLoading" @click="onOk">{{ confirmBtnTextLabel }}</el-button>
|
|
24
|
-
</span>
|
|
25
|
-
</template>
|
|
26
|
-
</component>
|
|
27
|
-
</template>
|
|
28
|
-
|
|
29
|
-
<script lang="ts">
|
|
30
|
-
import { CurdForm, CurdGroupForm, type CurdGroupFormSchema, useLocale } from "easybill-ui"
|
|
31
|
-
import { type Component, computed, defineComponent, type PropType, provide, reactive, ref, type Ref, toRefs, useAttrs } from "vue"
|
|
32
|
-
import { type Fields, type FormSchema } from "../../CurdForm"
|
|
33
|
-
import { useStepList } from "./hooks/useStepList"
|
|
34
|
-
import { useStepNavigation } from "./hooks/useStepNavigation"
|
|
35
|
-
import type { FormDialogHandleOk } from "./types"
|
|
36
|
-
export default defineComponent({
|
|
37
|
-
name: "FormDialog",
|
|
38
|
-
components: {
|
|
39
|
-
CurdForm,
|
|
40
|
-
CurdGroupForm,
|
|
41
|
-
},
|
|
42
|
-
props: {
|
|
43
|
-
title: {
|
|
44
|
-
type: String,
|
|
45
|
-
default: "",
|
|
46
|
-
},
|
|
47
|
-
remove: {
|
|
48
|
-
// 移除模态框
|
|
49
|
-
type: Function as PropType<() => void>,
|
|
50
|
-
default: null,
|
|
51
|
-
},
|
|
52
|
-
formSchema: {
|
|
53
|
-
// 表单项
|
|
54
|
-
type: Object as PropType<FormSchema>,
|
|
55
|
-
default: () => null,
|
|
56
|
-
},
|
|
57
|
-
groupSchema: {
|
|
58
|
-
// 分组表单项
|
|
59
|
-
type: Object as PropType<CurdGroupFormSchema>,
|
|
60
|
-
default: () => null,
|
|
61
|
-
},
|
|
62
|
-
fields: {
|
|
63
|
-
// 默认值,一般编辑时传入
|
|
64
|
-
type: Object as PropType<Fields>,
|
|
65
|
-
default: () => ({}),
|
|
66
|
-
},
|
|
67
|
-
setForm: {
|
|
68
|
-
type: Function as PropType<(form: Ref<Fields>) => void>,
|
|
69
|
-
default: null,
|
|
70
|
-
},
|
|
71
|
-
// 点击确定
|
|
72
|
-
handleOk: {
|
|
73
|
-
type: Function as PropType<FormDialogHandleOk>,
|
|
74
|
-
default: null,
|
|
75
|
-
},
|
|
76
|
-
// 关闭的回调,通过类型判断是点取消按钮还是右上角关闭按钮
|
|
77
|
-
handleClose: {
|
|
78
|
-
type: Function,
|
|
79
|
-
default: null,
|
|
80
|
-
},
|
|
81
|
-
stepProps: {
|
|
82
|
-
type: Object as PropType<Fields>,
|
|
83
|
-
default: () => ({}),
|
|
84
|
-
},
|
|
85
|
-
extendContext: {
|
|
86
|
-
type: Object,
|
|
87
|
-
default: () => ({}),
|
|
88
|
-
},
|
|
89
|
-
confirmBtnText: {
|
|
90
|
-
type: String,
|
|
91
|
-
default: undefined,
|
|
92
|
-
},
|
|
93
|
-
cancelBtnText: {
|
|
94
|
-
type: String,
|
|
95
|
-
default: undefined,
|
|
96
|
-
},
|
|
97
|
-
mode: {
|
|
98
|
-
// 容器组件类型: 'dialog' | 'drawer'
|
|
99
|
-
type: String as PropType<"dialog" | "drawer">,
|
|
100
|
-
default: "dialog",
|
|
101
|
-
},
|
|
102
|
-
stepComponent: {
|
|
103
|
-
type: Object as PropType<Component>,
|
|
104
|
-
default: null,
|
|
105
|
-
},
|
|
106
|
-
footerComponent: {
|
|
107
|
-
type: Object as PropType<Component>,
|
|
108
|
-
default: null,
|
|
109
|
-
},
|
|
110
|
-
},
|
|
111
|
-
setup(props) {
|
|
112
|
-
const attrs = useAttrs()
|
|
113
|
-
const curdFormRef = ref()
|
|
114
|
-
const form = ref<Fields>({})
|
|
115
|
-
const state = reactive({
|
|
116
|
-
visible: true,
|
|
117
|
-
confirmLoading: false,
|
|
118
|
-
})
|
|
119
|
-
const { t } = useLocale()
|
|
120
|
-
|
|
121
|
-
// 模式判断
|
|
122
|
-
const isGroupMode = computed(() => !!props.groupSchema)
|
|
123
|
-
const isFormMode = computed(() => !!props.formSchema && !isGroupMode.value)
|
|
124
|
-
|
|
125
|
-
// 步骤列表
|
|
126
|
-
const { stepList, stepCount, hasMultipleSteps } = useStepList(computed(() => props.groupSchema))
|
|
127
|
-
|
|
128
|
-
// 步骤导航
|
|
129
|
-
const { activeStep, groupFormRef, canPrev, canNext, isLastStep, prev, next, validateCurrentStep } = useStepNavigation(stepCount)
|
|
130
|
-
|
|
131
|
-
const onOk = () => {
|
|
132
|
-
state.confirmLoading = true
|
|
133
|
-
|
|
134
|
-
const getValidatePromise = (): Promise<boolean> => {
|
|
135
|
-
if (isFormMode.value) {
|
|
136
|
-
return (
|
|
137
|
-
curdFormRef.value
|
|
138
|
-
?.validate()
|
|
139
|
-
.then(() => true)
|
|
140
|
-
.catch(() => false) ?? Promise.resolve(true)
|
|
141
|
-
)
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
return new Promise<boolean>((resolve) => {
|
|
145
|
-
validateCurrentStep((valid) => resolve(valid))
|
|
146
|
-
})
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
getValidatePromise()
|
|
150
|
-
.then(async (valid) => {
|
|
151
|
-
if (!valid) {
|
|
152
|
-
state.confirmLoading = false
|
|
153
|
-
return
|
|
154
|
-
}
|
|
155
|
-
const pass = await Promise.resolve(props.handleOk?.(form.value, state)).finally(() => (state.confirmLoading = false))
|
|
156
|
-
if (typeof pass == "undefined" || pass) {
|
|
157
|
-
state.visible = false
|
|
158
|
-
onCancel()
|
|
159
|
-
}
|
|
160
|
-
})
|
|
161
|
-
.catch(() => {
|
|
162
|
-
state.confirmLoading = false
|
|
163
|
-
})
|
|
164
|
-
}
|
|
165
|
-
const onCancel = () => {
|
|
166
|
-
state.visible = false
|
|
167
|
-
if (props.handleClose) props.handleClose("cancel")
|
|
168
|
-
setTimeout(() => {
|
|
169
|
-
if (props.remove) props.remove()
|
|
170
|
-
}, 300)
|
|
171
|
-
}
|
|
172
|
-
const onBeforeClose = () => {
|
|
173
|
-
state.visible = false
|
|
174
|
-
if (props.handleClose) props.handleClose("close")
|
|
175
|
-
setTimeout(() => {
|
|
176
|
-
if (props.remove) props.remove()
|
|
177
|
-
}, 300)
|
|
178
|
-
}
|
|
179
|
-
const loadOptions = (prop: string, config?: unknown) => {
|
|
180
|
-
if (isFormMode.value) {
|
|
181
|
-
curdFormRef.value?.loadOptions(prop, config)
|
|
182
|
-
} else if (isGroupMode.value) {
|
|
183
|
-
Object.values(groupFormRef.value).forEach((form) => {
|
|
184
|
-
form?.loadOptions(prop, config)
|
|
185
|
-
})
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
const extendContexts = {
|
|
189
|
-
loadOptions,
|
|
190
|
-
...props.extendContext,
|
|
191
|
-
}
|
|
192
|
-
if (props.setForm) {
|
|
193
|
-
props.setForm(form)
|
|
194
|
-
}
|
|
195
|
-
const confirmBtnTextLabel = computed(() => props.confirmBtnText ?? t("el.formDialog.confirm"))
|
|
196
|
-
const cancelBtnTextLabel = computed(() => props.cancelBtnText ?? t("el.formDialog.cancel"))
|
|
197
|
-
const componentName = computed(() => (props.mode === "drawer" ? "el-drawer" : "el-dialog"))
|
|
198
|
-
const containerProps = computed(() => {
|
|
199
|
-
const baseProps = {
|
|
200
|
-
modelValue: state.visible,
|
|
201
|
-
title: props.title,
|
|
202
|
-
"close-on-click-modal": false,
|
|
203
|
-
"before-close": onBeforeClose,
|
|
204
|
-
...attrs,
|
|
205
|
-
}
|
|
206
|
-
if (props.mode === "drawer") {
|
|
207
|
-
return {
|
|
208
|
-
...baseProps,
|
|
209
|
-
size: attrs.size || attrs.width || "60%",
|
|
210
|
-
direction: attrs.direction || "rtl",
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
return {
|
|
214
|
-
...baseProps,
|
|
215
|
-
width: attrs.width || "60%",
|
|
216
|
-
}
|
|
217
|
-
})
|
|
218
|
-
const formDialogContext = reactive({
|
|
219
|
-
form,
|
|
220
|
-
state,
|
|
221
|
-
stepList,
|
|
222
|
-
activeStep,
|
|
223
|
-
loadOptions,
|
|
224
|
-
prev,
|
|
225
|
-
next,
|
|
226
|
-
goTo: (step: number) => {
|
|
227
|
-
if (step >= 0 && step < stepCount.value) {
|
|
228
|
-
// 验证当前步骤
|
|
229
|
-
validateCurrentStep((valid) => {
|
|
230
|
-
if (valid) {
|
|
231
|
-
activeStep.value = step
|
|
232
|
-
}
|
|
233
|
-
})
|
|
234
|
-
}
|
|
235
|
-
},
|
|
236
|
-
close: onBeforeClose,
|
|
237
|
-
handleOk: onOk,
|
|
238
|
-
validateCurrentStep,
|
|
239
|
-
canPrev,
|
|
240
|
-
canNext,
|
|
241
|
-
isLastStep,
|
|
242
|
-
isGroupMode,
|
|
243
|
-
isFormMode,
|
|
244
|
-
confirmBtnTextLabel,
|
|
245
|
-
cancelBtnTextLabel,
|
|
246
|
-
})
|
|
247
|
-
provide("formDialogContext", formDialogContext)
|
|
248
|
-
return {
|
|
249
|
-
...toRefs(state),
|
|
250
|
-
onOk,
|
|
251
|
-
onCancel,
|
|
252
|
-
onBeforeClose,
|
|
253
|
-
curdFormRef,
|
|
254
|
-
stepList,
|
|
255
|
-
form,
|
|
256
|
-
prev,
|
|
257
|
-
next,
|
|
258
|
-
t,
|
|
259
|
-
extendContexts,
|
|
260
|
-
confirmBtnTextLabel,
|
|
261
|
-
cancelBtnTextLabel,
|
|
262
|
-
componentName,
|
|
263
|
-
containerProps,
|
|
264
|
-
isGroupMode,
|
|
265
|
-
isFormMode,
|
|
266
|
-
hasMultipleSteps,
|
|
267
|
-
activeStep,
|
|
268
|
-
groupFormRef,
|
|
269
|
-
canPrev,
|
|
270
|
-
canNext,
|
|
271
|
-
isLastStep,
|
|
272
|
-
validateCurrentStep,
|
|
273
|
-
}
|
|
274
|
-
},
|
|
275
|
-
})
|
|
276
|
-
</script>
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { computed, type ComputedRef } from "vue"
|
|
2
|
-
import type { CurdGroupFormSchema } from "../../../CurdGroupForm/types"
|
|
3
|
-
|
|
4
|
-
export interface StepItem {
|
|
5
|
-
name: string
|
|
6
|
-
stepIndex?: number
|
|
7
|
-
schema: {
|
|
8
|
-
items: CurdGroupFormSchema["items"]
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export function useStepList(groupSchema: ComputedRef<CurdGroupFormSchema | null>) {
|
|
13
|
-
const stepList = computed<StepItem[]>(() => {
|
|
14
|
-
if (!groupSchema.value?.items) return []
|
|
15
|
-
|
|
16
|
-
const groups = new Map<string, StepItem>()
|
|
17
|
-
|
|
18
|
-
groupSchema.value.items.forEach((item) => {
|
|
19
|
-
const stepName = item.step || "其他"
|
|
20
|
-
|
|
21
|
-
if (!groups.has(stepName)) {
|
|
22
|
-
groups.set(stepName, {
|
|
23
|
-
name: stepName,
|
|
24
|
-
stepIndex: item.stepIndex,
|
|
25
|
-
schema: { items: [] }
|
|
26
|
-
})
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
groups.get(stepName)!.schema.items.push(item)
|
|
30
|
-
})
|
|
31
|
-
|
|
32
|
-
// 按 stepIndex 排序(undefined 排最后)
|
|
33
|
-
return Array.from(groups.values()).sort((a, b) => {
|
|
34
|
-
const indexA = a.stepIndex ?? Infinity
|
|
35
|
-
const indexB = b.stepIndex ?? Infinity
|
|
36
|
-
return indexA - indexB
|
|
37
|
-
})
|
|
38
|
-
})
|
|
39
|
-
|
|
40
|
-
const stepCount = computed(() => stepList.value.length)
|
|
41
|
-
|
|
42
|
-
const hasMultipleSteps = computed(() => stepList.value.length > 1)
|
|
43
|
-
|
|
44
|
-
return {
|
|
45
|
-
stepList,
|
|
46
|
-
stepCount,
|
|
47
|
-
hasMultipleSteps
|
|
48
|
-
}
|
|
49
|
-
}
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import { computed, ref, type Ref } from "vue"
|
|
2
|
-
import type { CurdGroupForm } from "../../../CurdGroupForm"
|
|
3
|
-
|
|
4
|
-
interface ValidateFunction {
|
|
5
|
-
validate: (callback: (valid: boolean) => void) => void
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export function useStepNavigation(stepCount: Ref<number>, onStepChange?: (step: number) => void) {
|
|
9
|
-
const activeStep = ref(0)
|
|
10
|
-
const groupFormRef = ref<Record<number, InstanceType<typeof CurdGroupForm>>>({})
|
|
11
|
-
|
|
12
|
-
const canPrev = computed(() => activeStep.value > 0)
|
|
13
|
-
const canNext = computed(() => activeStep.value < stepCount.value - 1)
|
|
14
|
-
const isLastStep = computed(() => activeStep.value >= stepCount.value - 1)
|
|
15
|
-
|
|
16
|
-
const setStep = (newStep: number) => {
|
|
17
|
-
if (newStep >= 0 && newStep < stepCount.value) {
|
|
18
|
-
activeStep.value = newStep
|
|
19
|
-
onStepChange?.(newStep)
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
const prev = () => {
|
|
24
|
-
if (canPrev.value) {
|
|
25
|
-
setStep(activeStep.value - 1)
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
const next = (onValidateFail?: () => void) => {
|
|
30
|
-
if (!canNext.value) return false
|
|
31
|
-
|
|
32
|
-
const currentForm = groupFormRef.value[activeStep.value] as unknown as ValidateFunction | undefined
|
|
33
|
-
if (currentForm?.validate) {
|
|
34
|
-
currentForm.validate((valid: boolean) => {
|
|
35
|
-
if (valid) {
|
|
36
|
-
setStep(activeStep.value + 1)
|
|
37
|
-
} else if (onValidateFail) {
|
|
38
|
-
onValidateFail()
|
|
39
|
-
}
|
|
40
|
-
})
|
|
41
|
-
} else {
|
|
42
|
-
setStep(activeStep.value + 1)
|
|
43
|
-
}
|
|
44
|
-
return true
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const validateCurrentStep = (callback: (valid: boolean) => void) => {
|
|
48
|
-
const currentForm = groupFormRef.value[activeStep.value] as unknown as ValidateFunction | undefined
|
|
49
|
-
if (currentForm?.validate) {
|
|
50
|
-
currentForm.validate(callback)
|
|
51
|
-
} else {
|
|
52
|
-
callback(true)
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
const validateCurrentStepAsync = (): Promise<boolean> => {
|
|
57
|
-
return new Promise((resolve) => {
|
|
58
|
-
validateCurrentStep((valid) => resolve(valid))
|
|
59
|
-
})
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
return {
|
|
63
|
-
activeStep,
|
|
64
|
-
groupFormRef,
|
|
65
|
-
canPrev,
|
|
66
|
-
canNext,
|
|
67
|
-
isLastStep,
|
|
68
|
-
setStep,
|
|
69
|
-
prev,
|
|
70
|
-
next,
|
|
71
|
-
validateCurrentStep,
|
|
72
|
-
validateCurrentStepAsync,
|
|
73
|
-
}
|
|
74
|
-
}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
// create-api.ts
|
|
2
|
-
import { type App, createVNode, nextTick, render, type VNode } from "vue"
|
|
3
|
-
import FormModal from "./FormDialog.vue"
|
|
4
|
-
import type { FormDialogOptions } from "./types"
|
|
5
|
-
let _app: App<Element>
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* 创建表单模态框
|
|
9
|
-
*/
|
|
10
|
-
const FormDialog = {
|
|
11
|
-
show: (options: FormDialogOptions) => {
|
|
12
|
-
// 组件实例
|
|
13
|
-
let formModal: VNode | null
|
|
14
|
-
const container = document.createElement("div")
|
|
15
|
-
// 移除组件
|
|
16
|
-
const remove = () => {
|
|
17
|
-
formModal = null
|
|
18
|
-
render(null, container)
|
|
19
|
-
container.remove()
|
|
20
|
-
}
|
|
21
|
-
formModal = createVNode(FormModal, { ...options, remove })
|
|
22
|
-
// 使当前模态框继承App实例上下文
|
|
23
|
-
nextTick(() => {
|
|
24
|
-
if (_app && formModal) {
|
|
25
|
-
formModal.appContext = _app._instance?.appContext || _app._context || null
|
|
26
|
-
}
|
|
27
|
-
render(formModal, container)
|
|
28
|
-
document.body.appendChild(container)
|
|
29
|
-
})
|
|
30
|
-
return formModal
|
|
31
|
-
},
|
|
32
|
-
// 暴露一个插件 API
|
|
33
|
-
install: (app: App<Element>) => {
|
|
34
|
-
_app = app
|
|
35
|
-
app.config.globalProperties["$formDialog"] = FormDialog
|
|
36
|
-
},
|
|
37
|
-
}
|
|
38
|
-
export { FormDialog }
|
|
39
|
-
export default FormDialog
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import type { DialogProps, StepProps } from "element-plus"
|
|
2
|
-
import type { Component, Ref } from "vue"
|
|
3
|
-
import type { Fields, FormContext, FormSchema } from "../../CurdForm"
|
|
4
|
-
import type { CurdGroupFormSchema } from "../../CurdGroupForm/types"
|
|
5
|
-
import type { StepItem } from "./hooks/useStepList"
|
|
6
|
-
|
|
7
|
-
export interface FormDialogState {
|
|
8
|
-
visible: boolean
|
|
9
|
-
confirmLoading: boolean
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export type FormDialogHandleOk = (modelRef: Fields, state: FormDialogState) => void | boolean | Promise<void | boolean>
|
|
13
|
-
|
|
14
|
-
export interface FormDialogOptions extends Partial<DialogProps> {
|
|
15
|
-
title?: string
|
|
16
|
-
width?: string | number
|
|
17
|
-
fields?: Fields
|
|
18
|
-
formSchema?: FormSchema
|
|
19
|
-
groupSchema?: CurdGroupFormSchema
|
|
20
|
-
handleOk?: FormDialogHandleOk
|
|
21
|
-
handleClose?: (e: "close" | "cancel") => void
|
|
22
|
-
setForm?: (form: Ref<Fields>) => void
|
|
23
|
-
stepProps?: Partial<StepProps & Fields>
|
|
24
|
-
extendContext?: Partial<FormContext>
|
|
25
|
-
confirmBtnText?: string
|
|
26
|
-
cancelBtnText?: string
|
|
27
|
-
stepComponent?: Component
|
|
28
|
-
footerComponent?: Component
|
|
29
|
-
mode?: "dialog" | "drawer"
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export interface FormDialogContext {
|
|
33
|
-
form: Fields
|
|
34
|
-
state: FormDialogState
|
|
35
|
-
stepList: StepItem[]
|
|
36
|
-
activeStep: { value: number }
|
|
37
|
-
loadOptions: (prop: string, config?: unknown) => void
|
|
38
|
-
prev: () => void
|
|
39
|
-
next: () => void
|
|
40
|
-
goTo: (step: number) => void
|
|
41
|
-
close: () => void
|
|
42
|
-
handleOk: () => void
|
|
43
|
-
validateCurrentStep: (callback: (valid: boolean) => void) => void
|
|
44
|
-
canPrev: { value: boolean }
|
|
45
|
-
canNext: { value: boolean }
|
|
46
|
-
isLastStep: { value: boolean }
|
|
47
|
-
isGroupMode: { value: boolean }
|
|
48
|
-
isFormMode: { value: boolean }
|
|
49
|
-
confirmBtnTextLabel: { value: string }
|
|
50
|
-
cancelBtnTextLabel: { value: string }
|
|
51
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { withInstall, type SFCWithInstall } from "../../utils"
|
|
2
|
-
import Instance from "./src/TableFilter.vue"
|
|
3
|
-
export const TableFilter: SFCWithInstall<typeof Instance> = withInstall("TableFilter", Instance)
|
|
4
|
-
export * from "./types"
|
|
5
|
-
|
|
6
|
-
export default TableFilter as SFCWithInstall<typeof Instance>
|
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<CurdForm ref="formRef" v-model="query" inline class="filter-external" :form-schema="formSchema" v-bind="option?.formProps" :extend-context="props.extendContext" @change="onChange">
|
|
3
|
-
<template #defaultFilter>
|
|
4
|
-
<slot></slot>
|
|
5
|
-
</template>
|
|
6
|
-
</CurdForm>
|
|
7
|
-
</template>
|
|
8
|
-
<script lang="ts" setup>
|
|
9
|
-
import { type PropType, inject, ref, watch } from "vue"
|
|
10
|
-
import type { Fields, FormItem, FormSchema } from "../../../CurdForm"
|
|
11
|
-
import CurdForm from "../../../CurdForm"
|
|
12
|
-
import type { FilterOption, ListQuery, ParamsItem } from "../../types"
|
|
13
|
-
const props = defineProps({
|
|
14
|
-
selectParams: {
|
|
15
|
-
type: Array as PropType<Array<ParamsItem>>,
|
|
16
|
-
default: () => {
|
|
17
|
-
return []
|
|
18
|
-
},
|
|
19
|
-
},
|
|
20
|
-
listQuery: {
|
|
21
|
-
type: Object as PropType<ListQuery>,
|
|
22
|
-
default: () => {
|
|
23
|
-
return {}
|
|
24
|
-
},
|
|
25
|
-
},
|
|
26
|
-
hasSlot: {
|
|
27
|
-
type: Boolean,
|
|
28
|
-
default: false,
|
|
29
|
-
},
|
|
30
|
-
extendContext: {
|
|
31
|
-
type: Object,
|
|
32
|
-
default: () => ({}),
|
|
33
|
-
},
|
|
34
|
-
})
|
|
35
|
-
const option = inject<FilterOption>("option")
|
|
36
|
-
const query = ref<ListQuery>({})
|
|
37
|
-
|
|
38
|
-
const formSchema = ref<FormSchema>({
|
|
39
|
-
formItem: [],
|
|
40
|
-
})
|
|
41
|
-
const init = () => {
|
|
42
|
-
// 特殊处理数组
|
|
43
|
-
const formItemLeft = props.selectParams.filter((a) => a.external === true || a.external === "left").sort((a, b) => parseInt(String(b.sortIndex || 0)) - parseInt(String(a.sortIndex || 0))) as FormItem[]
|
|
44
|
-
const formItemRight = props.selectParams.filter((a) => a.external === "right") as FormItem[]
|
|
45
|
-
const as = [...formItemLeft]
|
|
46
|
-
if (props.hasSlot) {
|
|
47
|
-
as.push({ prop: "defaultFilter", type: "defaultFilter" })
|
|
48
|
-
}
|
|
49
|
-
const formItem: FormItem[] = [...as, ...formItemRight]
|
|
50
|
-
formSchema.value.formItem = formItem
|
|
51
|
-
// const query = deepClone(query.value)
|
|
52
|
-
for (let i in formSchema.value.formItem) {
|
|
53
|
-
const item = formSchema.value.formItem[i] as ParamsItem
|
|
54
|
-
if (item.tableKey && props.listQuery[item.tableKey[0]]) {
|
|
55
|
-
const val1 = props.listQuery[item.tableKey[0]] as string
|
|
56
|
-
const val2 = props.listQuery[item.tableKey[1]] as string
|
|
57
|
-
query.value[item.prop] = [val1, val2]
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
const l = props.listQuery
|
|
61
|
-
for (let i in props.listQuery) {
|
|
62
|
-
const cur = formSchema.value.formItem.find((a) => a.prop == i)
|
|
63
|
-
if (cur) {
|
|
64
|
-
query.value[i] = l[i]
|
|
65
|
-
} else {
|
|
66
|
-
// const cur1 = formSchema.value.formItem.find((a) => a.tableKey && a.tableKey.includes(i))
|
|
67
|
-
// if (cur1 && cur1.tableKey) {
|
|
68
|
-
// query[i] = [l[cur1.tableKey[0]], l[cur1.tableKey[1]]]
|
|
69
|
-
// }
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
// query.value = query
|
|
73
|
-
}
|
|
74
|
-
init()
|
|
75
|
-
watch(
|
|
76
|
-
() => props.selectParams,
|
|
77
|
-
() => {
|
|
78
|
-
init()
|
|
79
|
-
},
|
|
80
|
-
)
|
|
81
|
-
|
|
82
|
-
const emit = defineEmits(["change"])
|
|
83
|
-
watch(
|
|
84
|
-
() => query.value,
|
|
85
|
-
(val) => {
|
|
86
|
-
const l = props.listQuery
|
|
87
|
-
for (let i in val) {
|
|
88
|
-
const cur = formSchema.value.formItem.find((a) => a.prop == i) as ParamsItem
|
|
89
|
-
const valItem = val[i]
|
|
90
|
-
if (cur && cur.tableKey && Array.isArray(valItem)) {
|
|
91
|
-
l[cur.tableKey[0]] = valItem[0] || ""
|
|
92
|
-
l[cur.tableKey[1]] = valItem[1] || ""
|
|
93
|
-
} else {
|
|
94
|
-
l[i] = val[i]
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
//
|
|
98
|
-
},
|
|
99
|
-
{ immediate: true, deep: true },
|
|
100
|
-
)
|
|
101
|
-
const onChange = (formModel: Fields, formItem: ParamsItem) => {
|
|
102
|
-
const l = props.listQuery
|
|
103
|
-
const val = formModel[formItem.prop]
|
|
104
|
-
if (formItem.tableKey && Array.isArray(val)) {
|
|
105
|
-
l[formItem.tableKey[0]] = val[0] || ""
|
|
106
|
-
l[formItem.tableKey[1]] = val[1] || ""
|
|
107
|
-
}
|
|
108
|
-
if (!formItem.tableKey) {
|
|
109
|
-
l[formItem.prop] = formModel[formItem.prop] as string
|
|
110
|
-
}
|
|
111
|
-
setTimeout(() => {
|
|
112
|
-
emit("change")
|
|
113
|
-
})
|
|
114
|
-
}
|
|
115
|
-
const formRef = ref()
|
|
116
|
-
const loadOptions = (prop: string, option?: unknown) => {
|
|
117
|
-
return formRef.value.loadOptions(prop, option)
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
defineExpose({ loadOptions })
|
|
121
|
-
</script>
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="filter-search-box" :class="{ 'is-focus': state.isFocus }">
|
|
3
|
-
<FilterToggle v-model:index="currentIndex" :select-params="props.selectParams" />
|
|
4
|
-
<FilterItem ref="filterItemRef" :params-item="props.selectParams[currentIndex]" v-model="query" @search="confirm"></FilterItem>
|
|
5
|
-
<div class="filter-action">
|
|
6
|
-
<div class="search" @click="confirm">
|
|
7
|
-
<el-icon>
|
|
8
|
-
<Search />
|
|
9
|
-
</el-icon>
|
|
10
|
-
</div>
|
|
11
|
-
</div>
|
|
12
|
-
</div>
|
|
13
|
-
</template>
|
|
14
|
-
<script lang="ts" setup>
|
|
15
|
-
import { Search } from "@element-plus/icons-vue"
|
|
16
|
-
import { inject, type PropType, type Ref, ref, watch } from "vue"
|
|
17
|
-
import * as I from "../types"
|
|
18
|
-
import FilterItem from "./components/FilterItem.vue"
|
|
19
|
-
import FilterToggle from "./components/FilterToggle.vue"
|
|
20
|
-
|
|
21
|
-
const props = defineProps({
|
|
22
|
-
selectParams: {
|
|
23
|
-
type: Array as PropType<Array<I.ParamsItem>>,
|
|
24
|
-
default: () => {
|
|
25
|
-
return []
|
|
26
|
-
},
|
|
27
|
-
},
|
|
28
|
-
listQuery: {
|
|
29
|
-
type: Object as PropType<I.ListQuery>,
|
|
30
|
-
default: () => {
|
|
31
|
-
return {}
|
|
32
|
-
},
|
|
33
|
-
},
|
|
34
|
-
})
|
|
35
|
-
const emit = defineEmits(["search"])
|
|
36
|
-
const currentIndex = ref(0)
|
|
37
|
-
const filterItemRef = ref()
|
|
38
|
-
const query = ref(props.listQuery)
|
|
39
|
-
watch(
|
|
40
|
-
() => query.value,
|
|
41
|
-
() => {
|
|
42
|
-
const m = props.listQuery
|
|
43
|
-
for (let i in m) {
|
|
44
|
-
m[i] = query.value[i]
|
|
45
|
-
}
|
|
46
|
-
},
|
|
47
|
-
)
|
|
48
|
-
const confirm = () => {
|
|
49
|
-
const current = props.selectParams[currentIndex.value]
|
|
50
|
-
if (typeof current.type == "undefined" || current.type == "input") {
|
|
51
|
-
filterItemRef.value.setValue(props.selectParams[currentIndex.value].prop)
|
|
52
|
-
}
|
|
53
|
-
emit("search", props.selectParams[currentIndex.value])
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
const state = inject<Ref<I.State>>("state", ref({} as I.State))
|
|
57
|
-
const setIndex = (i: number) => {
|
|
58
|
-
currentIndex.value = i
|
|
59
|
-
// filterItemRef.value.focus()
|
|
60
|
-
}
|
|
61
|
-
const loadOptions = (prop: string, config?: unknown) => {
|
|
62
|
-
return filterItemRef.value.loadOptions(prop, config)
|
|
63
|
-
}
|
|
64
|
-
defineExpose({ currentIndex, setIndex, loadOptions })
|
|
65
|
-
</script>
|