flame-plus 0.1.13 → 0.1.14
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/package.json +2 -1
- package/packages/components/base/flmButton/flmButton.vue +3 -3
- package/packages/components/base/flmCascader/flmCascader.vue +2 -2
- package/packages/components/base/flmCheckbox/flmCheckbox.vue +2 -2
- package/packages/components/base/flmCheckbox/flmCheckboxGroup.vue +3 -3
- package/packages/components/base/flmColorPicker/flmColorPicker.vue +2 -2
- package/packages/components/base/flmDatePicker/flmDatePicker.vue +2 -2
- package/packages/components/base/flmDialog/flmDialog.vue +2 -2
- package/packages/components/base/flmInput/flmInput.vue +2 -2
- package/packages/components/base/flmInputNumber/flmInputNumber.vue +2 -2
- package/packages/components/base/flmPagination/flmPagination.vue +2 -2
- package/packages/components/base/flmRadio/flmRadio.vue +2 -2
- package/packages/components/base/flmRate/flmRate.vue +2 -2
- package/packages/components/base/flmRead/flmRead.vue +1 -1
- package/packages/components/base/flmSelect/flmSelect.vue +2 -2
- package/packages/components/base/flmSlider/flmSlider.vue +2 -2
- package/packages/components/base/flmSwitch/flmSwitch.vue +2 -2
- package/packages/components/base/flmTimePicker/flmTimePicker.vue +2 -2
- package/packages/components/base/flmTimeSelect/flmTimeSelect.vue +2 -2
- package/packages/components/base/flmTransfer/flmTransfer.vue +2 -2
- package/packages/components/complex/flmForm/flmForm.vue +23 -20
- package/packages/components/complex/flmSearch/flmSearch.vue +36 -33
- package/packages/components/complex/flmTable/flmTable.vue +43 -27
- package/packages/components/complex/flmToolbar/flmToolbar.vue +4 -4
- package/packages/components/index.ts +2 -2
- package/packages/components/page/flmReportPage/flmReportPage.vue +97 -381
- package/packages/model/flmComponentConfig/base/flmButton.ts +5 -2
- package/packages/model/flmComponentConfig/base/flmCascader.ts +1 -1
- package/packages/model/flmComponentConfig/base/flmCheckbox.ts +1 -1
- package/packages/model/flmComponentConfig/base/flmColorPicker.ts +1 -1
- package/packages/model/flmComponentConfig/base/flmDatePicker.ts +1 -1
- package/packages/model/flmComponentConfig/base/flmInput.ts +1 -1
- package/packages/model/flmComponentConfig/base/flmInputNumber.ts +1 -1
- package/packages/model/flmComponentConfig/base/flmPagination.ts +0 -1
- package/packages/model/flmComponentConfig/base/flmRadio.ts +1 -1
- package/packages/model/flmComponentConfig/base/flmRate.ts +1 -1
- package/packages/model/flmComponentConfig/base/flmSelect.ts +1 -1
- package/packages/model/flmComponentConfig/base/flmSlider.ts +1 -1
- package/packages/model/flmComponentConfig/base/flmSwitch.ts +1 -1
- package/packages/model/flmComponentConfig/base/flmTimePicker.ts +1 -1
- package/packages/model/flmComponentConfig/base/flmTimeSelect.ts +1 -1
- package/packages/model/flmComponentConfig/complex/flmForm.ts +1 -1
- package/packages/model/flmComponentConfig/complex/flmSearch.ts +5 -0
- package/packages/model/flmComponentConfig/complex/flmTable.ts +23 -1
- package/packages/model/flmComponentConfig/complex/flmToolbar.ts +1 -1
- package/packages/model/flmComponentConfig/index.ts +1 -0
- package/packages/model/flmComponentConfig/page/flmReportPage.ts +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "flame-plus",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.14",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "基于 element-plus 的组件库",
|
|
6
6
|
"main": "packages/index.ts",
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
"core-js": "^3.6.5",
|
|
21
21
|
"editor": "1.0.0",
|
|
22
22
|
"element-plus": "^2.1.8",
|
|
23
|
+
"flame-request": "^1.0.1",
|
|
23
24
|
"html-loader": "^3.1.0",
|
|
24
25
|
"monaco-editor": "0.30.*",
|
|
25
26
|
"monaco-editor-esm-webpack-plugin": "^2.0.2",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script lang="tsx">
|
|
2
2
|
import { defineComponent, PropType, computed } from 'vue'
|
|
3
|
-
import { ButtonConfig, buttonDefaultConfig } from '
|
|
4
|
-
import { filterConfig } from '
|
|
3
|
+
import { ButtonConfig, buttonDefaultConfig } from '@/model/flmComponentConfig'
|
|
4
|
+
import { filterConfig } from '@/utils'
|
|
5
5
|
|
|
6
6
|
export default defineComponent({
|
|
7
7
|
emits: ['buttonClick'],
|
|
@@ -22,7 +22,7 @@ export default defineComponent({
|
|
|
22
22
|
<el-button
|
|
23
23
|
{...buttonConfig.value}
|
|
24
24
|
onClick={() => ctx.emit('buttonClick')}
|
|
25
|
-
>{buttonConfig.value.
|
|
25
|
+
>{buttonConfig.value.buttonText || '点击'}</el-button>
|
|
26
26
|
)
|
|
27
27
|
},
|
|
28
28
|
})
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script lang="tsx">
|
|
2
2
|
import { defineComponent, PropType, computed, reactive } from 'vue'
|
|
3
|
-
import { CascaderConfig, CascaderDefaultEvent, cascaderDefaultConfig } from '
|
|
4
|
-
import { filterConfig } from '
|
|
3
|
+
import { CascaderConfig, CascaderDefaultEvent, cascaderDefaultConfig } from '@/model/flmComponentConfig'
|
|
4
|
+
import { filterConfig } from '@/utils'
|
|
5
5
|
|
|
6
6
|
export default defineComponent({
|
|
7
7
|
emits: ['change', 'expand-change', 'blur', 'focus', 'visible-change', 'remove-tag'],
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script lang="tsx">
|
|
2
2
|
import { defineComponent, PropType, reactive, computed } from 'vue'
|
|
3
|
-
import { CheckboxConfig, CheckboxDefaultEvent, checkboxDefaultConfig } from '
|
|
4
|
-
import { filterConfig } from '
|
|
3
|
+
import { CheckboxConfig, CheckboxDefaultEvent, checkboxDefaultConfig } from '@/model/flmComponentConfig'
|
|
4
|
+
import { filterConfig } from '@/utils'
|
|
5
5
|
|
|
6
6
|
export default defineComponent({
|
|
7
7
|
emits: ['change'],
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
<script lang="tsx">
|
|
2
2
|
import { defineComponent, PropType, ref, Ref, computed } from 'vue'
|
|
3
|
-
import { flmCheckbox } from '
|
|
3
|
+
import { flmCheckbox } from '@/components'
|
|
4
4
|
import {
|
|
5
5
|
CheckboxConfig,
|
|
6
6
|
CheckboxGroupConfig,
|
|
7
7
|
checkboxGroupDefaultConfig
|
|
8
|
-
} from '
|
|
9
|
-
import { filterConfig } from '
|
|
8
|
+
} from '@/model/flmComponentConfig'
|
|
9
|
+
import { filterConfig } from '@/utils'
|
|
10
10
|
|
|
11
11
|
export default defineComponent({
|
|
12
12
|
components: { flmCheckbox },
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script lang="tsx">
|
|
2
2
|
import { defineComponent, PropType, reactive, computed } from 'vue'
|
|
3
|
-
import { ColorPickerConfig, ColorPickerDefaultEvent, colorPickerDefaultConfig } from '
|
|
4
|
-
import { filterConfig } from '
|
|
3
|
+
import { ColorPickerConfig, ColorPickerDefaultEvent, colorPickerDefaultConfig } from '@/model/flmComponentConfig'
|
|
4
|
+
import { filterConfig } from '@/utils'
|
|
5
5
|
|
|
6
6
|
export default defineComponent({
|
|
7
7
|
emits: ['change'],
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script lang="tsx">
|
|
2
2
|
import { defineComponent, PropType, computed, reactive } from 'vue'
|
|
3
|
-
import { DatePickerConfig, DatePickerDefaultEvent, datePickerDefaultConfig } from '
|
|
4
|
-
import { filterConfig } from '
|
|
3
|
+
import { DatePickerConfig, DatePickerDefaultEvent, datePickerDefaultConfig } from '@/model/flmComponentConfig'
|
|
4
|
+
import { filterConfig } from '@/utils'
|
|
5
5
|
|
|
6
6
|
export default defineComponent({
|
|
7
7
|
emits: [
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script lang="tsx">
|
|
2
2
|
import { defineComponent, PropType, reactive, computed } from 'vue'
|
|
3
|
-
import { DialogConfig, DialogDefaultEvent, dialogDefaultConfig } from '
|
|
4
|
-
import { filterConfig } from '
|
|
3
|
+
import { DialogConfig, DialogDefaultEvent, dialogDefaultConfig } from '@/model/flmComponentConfig'
|
|
4
|
+
import { filterConfig } from '@/utils'
|
|
5
5
|
|
|
6
6
|
export default defineComponent({
|
|
7
7
|
emits: ['open', 'opened', 'close', 'closed', 'open-auto-focus', 'close-auto-focus'],
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script lang="tsx">
|
|
2
2
|
import { defineComponent, PropType, reactive, computed } from 'vue'
|
|
3
|
-
import { InputConfig, InputDefaultEvent, inputDefaultConfig } from '
|
|
4
|
-
import { filterConfig } from '
|
|
3
|
+
import { InputConfig, InputDefaultEvent, inputDefaultConfig } from '@/model/flmComponentConfig'
|
|
4
|
+
import { filterConfig } from '@/utils'
|
|
5
5
|
|
|
6
6
|
export default defineComponent({
|
|
7
7
|
emits: ['blur', 'focus', 'change', 'input', 'clear'],
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script lang="tsx">
|
|
2
2
|
import { defineComponent, PropType, computed, reactive } from 'vue'
|
|
3
|
-
import { InputNumberConfig, InputNumberDefaultEvent, inputNumberDefaultConfig } from '
|
|
4
|
-
import { filterConfig } from '
|
|
3
|
+
import { InputNumberConfig, InputNumberDefaultEvent, inputNumberDefaultConfig } from '@/model/flmComponentConfig'
|
|
4
|
+
import { filterConfig } from '@/utils'
|
|
5
5
|
|
|
6
6
|
export default defineComponent({
|
|
7
7
|
emits: ['change', 'blur', 'focus'],
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script lang="tsx">
|
|
2
2
|
import { defineComponent, PropType, reactive, computed } from 'vue'
|
|
3
|
-
import { PaginationConfig, PaginationDefaultEvent, paginationDefaultConfig } from '
|
|
4
|
-
import { filterConfig } from '
|
|
3
|
+
import { PaginationConfig, PaginationDefaultEvent, paginationDefaultConfig } from '@/model/flmComponentConfig'
|
|
4
|
+
import { filterConfig } from '@/utils'
|
|
5
5
|
|
|
6
6
|
export default defineComponent({
|
|
7
7
|
emits: ['size-change', 'current-change', 'prev-click', 'next-click'],
|
|
@@ -6,8 +6,8 @@ import {
|
|
|
6
6
|
RadioGroupDefaultEvent,
|
|
7
7
|
radioDefaultConfig,
|
|
8
8
|
radioGroupDefaultConfig
|
|
9
|
-
} from '
|
|
10
|
-
import { filterConfig } from '
|
|
9
|
+
} from '@/model/flmComponentConfig'
|
|
10
|
+
import { filterConfig } from '@/utils'
|
|
11
11
|
|
|
12
12
|
export default defineComponent({
|
|
13
13
|
emits: ['change'],
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script lang="tsx">
|
|
2
2
|
import { defineComponent, PropType, computed, reactive } from 'vue'
|
|
3
|
-
import { RateConfig, RateDefaultEvent, rateDefaultConfig } from '
|
|
4
|
-
import { filterConfig } from '
|
|
3
|
+
import { RateConfig, RateDefaultEvent, rateDefaultConfig } from '@/model/flmComponentConfig'
|
|
4
|
+
import { filterConfig } from '@/utils'
|
|
5
5
|
|
|
6
6
|
export default defineComponent({
|
|
7
7
|
emits: ['change'],
|
|
@@ -6,8 +6,8 @@ import {
|
|
|
6
6
|
OptionGroupConfig,
|
|
7
7
|
OptionConfig,
|
|
8
8
|
selectDefaultConfig
|
|
9
|
-
} from '
|
|
10
|
-
import { filterConfig } from '
|
|
9
|
+
} from '@/model/flmComponentConfig'
|
|
10
|
+
import { filterConfig } from '@/utils'
|
|
11
11
|
|
|
12
12
|
export default defineComponent({
|
|
13
13
|
emits: ['change', 'visible-change', 'remove-tag', 'clear', 'blur', 'focus'],
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script lang="tsx">
|
|
2
2
|
import { defineComponent, PropType, computed, reactive } from 'vue'
|
|
3
|
-
import { SliderConfig, SliderDefaultEvent, sliderDefaultConfig } from '
|
|
4
|
-
import { filterConfig } from '
|
|
3
|
+
import { SliderConfig, SliderDefaultEvent, sliderDefaultConfig } from '@/model/flmComponentConfig'
|
|
4
|
+
import { filterConfig } from '@/utils'
|
|
5
5
|
|
|
6
6
|
export default defineComponent({
|
|
7
7
|
emits: ['change', 'input'],
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script lang="tsx">
|
|
2
2
|
import { defineComponent, PropType, computed } from 'vue'
|
|
3
|
-
import { SwitchConfig, switchDefaultConfig } from '
|
|
4
|
-
import { filterConfig } from '
|
|
3
|
+
import { SwitchConfig, switchDefaultConfig } from '@/model/flmComponentConfig'
|
|
4
|
+
import { filterConfig } from '@/utils'
|
|
5
5
|
|
|
6
6
|
export default defineComponent({
|
|
7
7
|
emits: ['change'],
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script lang="tsx">
|
|
2
2
|
import { defineComponent, PropType, computed, reactive } from 'vue'
|
|
3
|
-
import { TimePickerConfig, TimePickerDefaultEvent, timePickerDefaultConfig } from '
|
|
4
|
-
import { filterConfig } from '
|
|
3
|
+
import { TimePickerConfig, TimePickerDefaultEvent, timePickerDefaultConfig } from '@/model/flmComponentConfig'
|
|
4
|
+
import { filterConfig } from '@/utils'
|
|
5
5
|
|
|
6
6
|
export default defineComponent({
|
|
7
7
|
emits: ['change', 'blur', 'focus', 'visible-change' ],
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script lang="tsx">
|
|
2
2
|
import { defineComponent, PropType, computed, reactive } from 'vue'
|
|
3
|
-
import { TimeSelectConfig, timeSelectDefaultConfig } from '
|
|
4
|
-
import { filterConfig } from '
|
|
3
|
+
import { TimeSelectConfig, timeSelectDefaultConfig } from '@/model/flmComponentConfig'
|
|
4
|
+
import { filterConfig } from '@/utils'
|
|
5
5
|
|
|
6
6
|
export default defineComponent({
|
|
7
7
|
emits: ['change', 'blur', 'focus'],
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script lang="tsx">
|
|
2
2
|
import { defineComponent, PropType, computed, reactive } from 'vue'
|
|
3
|
-
import { TransferConfig, TransferDefaultEvent, transferDefaultConfig } from '
|
|
4
|
-
import { filterConfig } from '
|
|
3
|
+
import { TransferConfig, TransferDefaultEvent, transferDefaultConfig } from '@/model/flmComponentConfig'
|
|
4
|
+
import { filterConfig } from '@/utils'
|
|
5
5
|
|
|
6
6
|
export default defineComponent({
|
|
7
7
|
emits: ['change', 'left-check-change', 'right-check-change'],
|
|
@@ -27,7 +27,7 @@ import {
|
|
|
27
27
|
flmTimePicker,
|
|
28
28
|
flmTimeSelect,
|
|
29
29
|
flmTransfer,
|
|
30
|
-
} from '
|
|
30
|
+
} from '@/components'
|
|
31
31
|
import {
|
|
32
32
|
ControlTypes,
|
|
33
33
|
ControlConfig,
|
|
@@ -37,8 +37,8 @@ import {
|
|
|
37
37
|
FormItemConfig,
|
|
38
38
|
FormButtonConfig,
|
|
39
39
|
formDefaultConfig
|
|
40
|
-
} from '
|
|
41
|
-
import { filterConfig, isValidKey } from '
|
|
40
|
+
} from '@/model/flmComponentConfig'
|
|
41
|
+
import { filterConfig, isValidKey } from '@/utils'
|
|
42
42
|
|
|
43
43
|
export default defineComponent({
|
|
44
44
|
components: {
|
|
@@ -59,7 +59,7 @@ export default defineComponent({
|
|
|
59
59
|
flmTimeSelect,
|
|
60
60
|
flmTransfer,
|
|
61
61
|
},
|
|
62
|
-
emits: ['submit', 'cancel', 'customEvent'],
|
|
62
|
+
emits: ['submit', 'cancel', 'reset', 'customEvent'],
|
|
63
63
|
props: {
|
|
64
64
|
// 默认设置
|
|
65
65
|
config: {
|
|
@@ -72,7 +72,7 @@ export default defineComponent({
|
|
|
72
72
|
let formModel: FormModel = reactive({}) // 表单数据
|
|
73
73
|
|
|
74
74
|
// 监听表单配置的 model,变化后更新组件内部 formModel
|
|
75
|
-
watch(() => props.config.model, (newModel: FormModel) =>
|
|
75
|
+
watch(() => props.config.model, (newModel: FormModel) => updateFormModel(newModel))
|
|
76
76
|
|
|
77
77
|
// 监听组件内部 formModel,变化后更新控件 value
|
|
78
78
|
watch(formModel, (newModel: FormModel) => updateControl(newModel))
|
|
@@ -80,7 +80,7 @@ export default defineComponent({
|
|
|
80
80
|
onMounted(() => {
|
|
81
81
|
if (props.config?.model && Object.keys(props.config?.model).length) {
|
|
82
82
|
updateControl(props.config.model)
|
|
83
|
-
|
|
83
|
+
updateFormModel(props.config.model)
|
|
84
84
|
}
|
|
85
85
|
})
|
|
86
86
|
|
|
@@ -107,7 +107,7 @@ export default defineComponent({
|
|
|
107
107
|
* @date 2022-05-09
|
|
108
108
|
* @param {FormModel} model
|
|
109
109
|
*/
|
|
110
|
-
const
|
|
110
|
+
const updateFormModel = (model: FormModel) => {
|
|
111
111
|
Object.entries(model).forEach(([key, value]: Array<any>) => formModel[key] = value)
|
|
112
112
|
}
|
|
113
113
|
|
|
@@ -122,10 +122,10 @@ export default defineComponent({
|
|
|
122
122
|
/**
|
|
123
123
|
* 表单方法调用
|
|
124
124
|
* @date 2022-04-14
|
|
125
|
-
* @param {'submit' | 'cancel' | string} event 方法名(默认方法直接调用;自定义方法回传方法名及表单数据)
|
|
125
|
+
* @param {'submit' | 'cancel' | 'reset' | string} event 方法名(默认方法直接调用;自定义方法回传方法名及表单数据)
|
|
126
126
|
*/
|
|
127
127
|
const formEvent = (event: FormButtonConfig['event']) => {
|
|
128
|
-
const defaultEvent: Record<FormButtonConfig['event'], Function> = { submit, cancel }
|
|
128
|
+
const defaultEvent: Record<FormButtonConfig['event'], Function> = { submit, cancel, reset }
|
|
129
129
|
isValidKey(event, defaultEvent)
|
|
130
130
|
? defaultEvent[event]()
|
|
131
131
|
: emit('customEvent', { event, formModel })
|
|
@@ -142,7 +142,6 @@ export default defineComponent({
|
|
|
142
142
|
|
|
143
143
|
// 取消
|
|
144
144
|
const cancel = () => {
|
|
145
|
-
reset()
|
|
146
145
|
emit('cancel', formModel)
|
|
147
146
|
}
|
|
148
147
|
|
|
@@ -151,6 +150,7 @@ export default defineComponent({
|
|
|
151
150
|
const formRef: any = instance?.refs['formRef']
|
|
152
151
|
if (!formRef) return
|
|
153
152
|
formRef.resetFields()
|
|
153
|
+
emit('reset', formModel)
|
|
154
154
|
}
|
|
155
155
|
|
|
156
156
|
/**
|
|
@@ -171,7 +171,7 @@ export default defineComponent({
|
|
|
171
171
|
if (isValidKey('isSlot', item)) {
|
|
172
172
|
const { isSlot, ...itemConfig } = item
|
|
173
173
|
return (
|
|
174
|
-
<el-form-item {...itemConfig}>
|
|
174
|
+
<el-form-item class={`form-${item.prop}`} {...itemConfig}>
|
|
175
175
|
{(slots[item.prop]?.({ prop: item.prop, formModel }))}
|
|
176
176
|
</el-form-item>
|
|
177
177
|
)
|
|
@@ -179,7 +179,7 @@ export default defineComponent({
|
|
|
179
179
|
const { controlType, controlConfig, ...itemConfig } = item
|
|
180
180
|
if (controlType && controlConfig) {
|
|
181
181
|
return (
|
|
182
|
-
<el-form-item {...itemConfig}>
|
|
182
|
+
<el-form-item class={`form-${item.prop}`} {...itemConfig}>
|
|
183
183
|
{controlDom(item.prop, controlType, controlConfig)}
|
|
184
184
|
</el-form-item>
|
|
185
185
|
)
|
|
@@ -198,7 +198,7 @@ export default defineComponent({
|
|
|
198
198
|
const buttonsDom = (buttons: FormConfig['buttons'] = []) => {
|
|
199
199
|
if (buttons.length) {
|
|
200
200
|
return (
|
|
201
|
-
<el-form-item>
|
|
201
|
+
<el-form-item class="form-buttons">
|
|
202
202
|
{buttons.map(({ event, ...config }: FormButtonConfig) =>
|
|
203
203
|
<flm-button config={config} onButtonClick={() => formEvent(event)} />
|
|
204
204
|
)}
|
|
@@ -211,13 +211,16 @@ export default defineComponent({
|
|
|
211
211
|
|
|
212
212
|
// 表单设置
|
|
213
213
|
const formConfig = computed((): FormConfig => filterConfig(formDefaultConfig, props.config))
|
|
214
|
-
const
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
{
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
214
|
+
const formDom = () => {
|
|
215
|
+
const { items = [], buttons = [], model, ...defaultConfig } = formConfig.value
|
|
216
|
+
return (
|
|
217
|
+
<el-form ref='formRef' {...defaultConfig} model={formModel}>
|
|
218
|
+
{formItemsDom(items)}
|
|
219
|
+
{buttonsDom(buttons)}
|
|
220
|
+
</el-form>
|
|
221
|
+
)
|
|
222
|
+
}
|
|
223
|
+
return () => (formDom())
|
|
221
224
|
},
|
|
222
225
|
})
|
|
223
226
|
</script>
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
ref="searchDefaultRef"
|
|
6
6
|
:config="defaultConfig"
|
|
7
7
|
@submit="searchSubmit"
|
|
8
|
-
@
|
|
8
|
+
@reset="searchReset"
|
|
9
9
|
@customEvent="searchCustomEvent"
|
|
10
10
|
>
|
|
11
11
|
<template v-for="defaultSlot in defaultSlots" #[defaultSlot]="{ prop, formModel }">
|
|
@@ -37,15 +37,15 @@
|
|
|
37
37
|
</template>
|
|
38
38
|
|
|
39
39
|
<script lang="ts" setup>
|
|
40
|
-
import {
|
|
41
|
-
import { flmForm } from '
|
|
42
|
-
import {
|
|
43
|
-
import { isValidKey } from '
|
|
40
|
+
import { PropType, ref, Ref, computed, ComputedRef } from 'vue'
|
|
41
|
+
import { flmForm } from '@/components'
|
|
42
|
+
import { ButtonType, FormItemConfig, SearchConfig } from '@/model/flmComponentConfig'
|
|
43
|
+
import { isValidKey } from '@/utils'
|
|
44
44
|
|
|
45
|
-
const emit = defineEmits(['searchSubmit', '
|
|
45
|
+
const emit = defineEmits(['searchSubmit', 'searchReset', 'searchCustomEvent'])
|
|
46
46
|
const props = defineProps({
|
|
47
47
|
config: {
|
|
48
|
-
type: Object as PropType<
|
|
48
|
+
type: Object as PropType<SearchConfig>,
|
|
49
49
|
default() {
|
|
50
50
|
return {}
|
|
51
51
|
}
|
|
@@ -57,38 +57,38 @@ const searchExtraRef: Ref<any> = ref() // 额外搜索栏实例
|
|
|
57
57
|
|
|
58
58
|
let showExtra: Ref<boolean> = ref(false) // 显示额外搜索条件
|
|
59
59
|
let hasExtra: Ref<boolean> = ref(false) // 有额外搜索条件
|
|
60
|
-
let extraFormModel: Ref<
|
|
60
|
+
let extraFormModel: Ref<SearchConfig> = ref({}) // 额外搜索条件
|
|
61
61
|
|
|
62
|
-
const maxFormItem = 3
|
|
62
|
+
const maxFormItem = computed(() => props.config.maxFormItem || 3) // 默认搜索栏最大条件数
|
|
63
63
|
|
|
64
64
|
// 默认搜索栏设置
|
|
65
|
-
const defaultConfig: ComputedRef<
|
|
65
|
+
const defaultConfig: ComputedRef<SearchConfig> = computed(() => {
|
|
66
66
|
const { items = [], buttons, ...config } = props.config
|
|
67
|
-
hasExtra.value = items.length > maxFormItem
|
|
68
|
-
hasExtra.value && buttons?.unshift({ '
|
|
67
|
+
hasExtra.value = items.length > maxFormItem.value
|
|
68
|
+
hasExtra.value && buttons?.unshift({ 'buttonText': '更多', 'event': 'openDrawer' }) // 搜索条件大于最大数量,插入更多按钮
|
|
69
69
|
return {
|
|
70
70
|
...config,
|
|
71
71
|
inline: true,
|
|
72
|
-
items: items.slice(0, maxFormItem),
|
|
72
|
+
items: items.slice(0, maxFormItem.value),
|
|
73
73
|
buttons
|
|
74
74
|
}
|
|
75
75
|
})
|
|
76
76
|
// 额外搜索栏设置
|
|
77
|
-
const extraConfig: ComputedRef<
|
|
77
|
+
const extraConfig: ComputedRef<SearchConfig> = computed(() => {
|
|
78
78
|
const { items, buttons, ...config } = props.config
|
|
79
79
|
return {
|
|
80
80
|
...config,
|
|
81
81
|
inline: false,
|
|
82
|
-
items: items?.slice(maxFormItem),
|
|
82
|
+
items: items?.slice(maxFormItem.value),
|
|
83
83
|
// 插入额外搜索栏按钮
|
|
84
84
|
buttons: [
|
|
85
85
|
{
|
|
86
|
-
'
|
|
86
|
+
'buttonText': '取消',
|
|
87
87
|
'event': 'cancel'
|
|
88
88
|
},
|
|
89
89
|
{
|
|
90
|
-
'type': 'primary',
|
|
91
|
-
'
|
|
90
|
+
'type': ButtonType['primary'],
|
|
91
|
+
'buttonText': '搜索',
|
|
92
92
|
'event': 'submit'
|
|
93
93
|
}
|
|
94
94
|
]
|
|
@@ -96,30 +96,35 @@ const extraConfig: ComputedRef<FormConfig> = computed(() => {
|
|
|
96
96
|
})
|
|
97
97
|
|
|
98
98
|
// 获取表格插槽
|
|
99
|
-
const getFormSlots = (items:
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
99
|
+
const getFormSlots = (items: SearchConfig['items'] = []): Array<string> => {
|
|
100
|
+
let slots: Array<string> = []
|
|
101
|
+
items.forEach((item: FormItemConfig) => {
|
|
102
|
+
if (isValidKey('isSlot', item)) {
|
|
103
|
+
const { prop } = item
|
|
104
|
+
prop && typeof(prop) === 'string' && slots.push(prop)
|
|
105
|
+
}
|
|
106
|
+
})
|
|
107
|
+
return slots
|
|
103
108
|
}
|
|
104
109
|
// 默认搜索栏插槽
|
|
105
|
-
const defaultSlots = computed((): Array<string> => getFormSlots(props.config.items
|
|
110
|
+
const defaultSlots = computed((): Array<string> => getFormSlots(props.config.items?.slice(0, maxFormItem.value)) ?? [])
|
|
106
111
|
// 额外搜索栏插槽
|
|
107
|
-
const extraSlots = computed((): Array<string> => getFormSlots(props.config.items
|
|
112
|
+
const extraSlots = computed((): Array<string> => getFormSlots(props.config.items?.slice(maxFormItem.value)) ?? [])
|
|
108
113
|
|
|
109
114
|
// 搜索栏提交
|
|
110
|
-
const searchSubmit = (formModel:
|
|
115
|
+
const searchSubmit = (formModel: SearchConfig['model']) => {
|
|
111
116
|
emit('searchSubmit', { ...formModel, ...extraFormModel.value })
|
|
112
117
|
}
|
|
113
118
|
|
|
114
119
|
// 搜索栏取消
|
|
115
|
-
const
|
|
120
|
+
const searchReset = () => {
|
|
116
121
|
searchExtraRef.value?.reset()
|
|
117
|
-
const
|
|
118
|
-
emit('
|
|
122
|
+
const extraFormModel = searchExtraRef.value?.formModel ?? {}
|
|
123
|
+
emit('searchReset', { ...extraFormModel, ...searchDefaultRef.value.formModel })
|
|
119
124
|
}
|
|
120
125
|
|
|
121
126
|
// 搜索栏自定义操作
|
|
122
|
-
const searchCustomEvent = ({ event, formModel }: { event: string, formModel:
|
|
127
|
+
const searchCustomEvent = ({ event, formModel }: { event: string, formModel: SearchConfig['model']}) => {
|
|
123
128
|
const customEvent: Record<string, Function> = { openDrawer }
|
|
124
129
|
if (isValidKey(event, customEvent)) {
|
|
125
130
|
customEvent[event](formModel)
|
|
@@ -132,11 +137,9 @@ const openDrawer = () => showExtra.value = true // 打开额外搜索栏弹
|
|
|
132
137
|
const closeDrawer = () => showExtra.value = false // 关闭额外搜索栏弹窗
|
|
133
138
|
|
|
134
139
|
// 额外搜索栏提交
|
|
135
|
-
const drawerSubmit = (formModel:
|
|
140
|
+
const drawerSubmit = (formModel: SearchConfig['model']) => {
|
|
136
141
|
formModel && (extraFormModel.value = formModel)
|
|
137
142
|
emit('searchSubmit', { ...searchDefaultRef.value.formModel, ...formModel })
|
|
138
143
|
closeDrawer()
|
|
139
144
|
}
|
|
140
|
-
</script>
|
|
141
|
-
|
|
142
|
-
<style lang="scss"></style>
|
|
145
|
+
</script>
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
<script lang="tsx">
|
|
2
|
-
import { defineComponent, PropType, computed } from 'vue'
|
|
2
|
+
import { defineComponent, PropType, reactive, computed } from 'vue'
|
|
3
3
|
import {
|
|
4
4
|
TableConfig,
|
|
5
5
|
TableColumnConfig,
|
|
6
|
+
TableDefaultEvent,
|
|
6
7
|
tableDefaultConfig,
|
|
7
8
|
tableColumnDefaultConfig
|
|
8
|
-
} from '
|
|
9
|
-
import { filterConfig } from '
|
|
9
|
+
} from '@/model/flmComponentConfig'
|
|
10
|
+
import { filterConfig } from '@/utils'
|
|
10
11
|
|
|
11
12
|
export default defineComponent({
|
|
12
13
|
emits: [
|
|
@@ -37,6 +38,44 @@ export default defineComponent({
|
|
|
37
38
|
},
|
|
38
39
|
},
|
|
39
40
|
setup(props, { slots, emit }) {
|
|
41
|
+
// 表格默认事件
|
|
42
|
+
const tableDefaultEvent: TableDefaultEvent = reactive({
|
|
43
|
+
onSelect: (selection: any, row: any) => emit('select', { selection, row }),
|
|
44
|
+
onSelectAll: (selection: any) => emit('select-all', selection),
|
|
45
|
+
onSelectionChange: (row: any, column: any, cell: any, event: any) => emit('selection-change', { row, column, cell, event }),
|
|
46
|
+
onCellMouseEnter: (row: any, column: any, cell: any, event: any) => emit('cell-mouse-enter', { row, column, cell, event }),
|
|
47
|
+
onCellMouseLeave: (row: any, column: any, cell: any, event: any) => emit('cell-mouse-leave', { row, column, cell, event }),
|
|
48
|
+
onCellClick: (row: any, column: any, cell: any, event: any) => emit('cell-click', { row, column, cell, event }),
|
|
49
|
+
onCellDblclick: (row: any, column: any, cell: any, event: any) => emit('cell-dblclick', { row, column, cell, event }),
|
|
50
|
+
onCellContextmenu: (row: any, column: any, cell: any, event: any) => emit('cell-contextmenu', { row, column, cell, event }),
|
|
51
|
+
onRowClick: (row: any, column: any, event: any) => emit('row-click', { row, column, event }),
|
|
52
|
+
onRowContextmenu: (row: any, column: any, event: any) => emit('row-contextmenu', { row, column, event }),
|
|
53
|
+
onRowDblclick: (row: any, column: any, event: any) => emit('row-dblclick', { row, column, event }),
|
|
54
|
+
onHeaderClick: (column: any, event: any) => emit('header-click', { column, event }),
|
|
55
|
+
onHeaderContextmenu: (column: any, event: any) => emit('header-contextmenu', { column, event }),
|
|
56
|
+
onSortChange: ({ column, prop, order }: any) => emit('sort-change', { column, prop, order }),
|
|
57
|
+
onFilterChange: (filters: any) => emit('filter-change', filters),
|
|
58
|
+
onCurrentChange: (currentRow: any, oldCurrentRow: any) => emit('current-change', { currentRow, oldCurrentRow }),
|
|
59
|
+
onHeaderDragend: (newWidth: any, oldWidth: any, column: any, event: any) => emit('header-dragend', { newWidth, oldWidth, column, event }),
|
|
60
|
+
onExpandChange: (row: any, expanded: any) => emit('expand-change', { row, expanded }),
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* 表格
|
|
65
|
+
* @date 2022-09-29
|
|
66
|
+
* @param {TableConfig} tableConfig 表格配置
|
|
67
|
+
* @returns {any} 表格dom
|
|
68
|
+
*/
|
|
69
|
+
const tableDom = (tableConfig: TableConfig) => {
|
|
70
|
+
const { columns = [], ...defaultConfig } = tableConfig
|
|
71
|
+
return (
|
|
72
|
+
<el-table
|
|
73
|
+
{...defaultConfig}
|
|
74
|
+
{...tableDefaultEvent}
|
|
75
|
+
>{tableColumnDom(columns)}</el-table>
|
|
76
|
+
)
|
|
77
|
+
}
|
|
78
|
+
|
|
40
79
|
/**
|
|
41
80
|
* 表格元素
|
|
42
81
|
* @date 2022-04-14
|
|
@@ -61,30 +100,7 @@ export default defineComponent({
|
|
|
61
100
|
|
|
62
101
|
// 表单设置
|
|
63
102
|
const tableConfig = computed((): TableConfig => filterConfig(tableDefaultConfig, props.config))
|
|
64
|
-
|
|
65
|
-
return () => (
|
|
66
|
-
<el-table
|
|
67
|
-
{...defaultConfig}
|
|
68
|
-
onSelect={(selection: any, row: any) => emit('select', { selection, row })}
|
|
69
|
-
onSelectAll={(selection: any) => emit('select-all', selection)}
|
|
70
|
-
onSelectionChange={(row: any, column: any, cell: any, event: any) => emit('selection-change', { row, column, cell, event })}
|
|
71
|
-
onCellMouseEnter={(row: any, column: any, cell: any, event: any) => emit('cell-mouse-enter', { row, column, cell, event })}
|
|
72
|
-
onCellMouseLeave={(row: any, column: any, cell: any, event: any) => emit('cell-mouse-leave', { row, column, cell, event })}
|
|
73
|
-
onCellClick={(row: any, column: any, cell: any, event: any) => emit('cell-click', { row, column, cell, event })}
|
|
74
|
-
onCellDblclick={(row: any, column: any, cell: any, event: any) => emit('cell-dblclick', { row, column, cell, event })}
|
|
75
|
-
onCellContextmenu={(row: any, column: any, cell: any, event: any) => emit('cell-contextmenu', { row, column, cell, event })}
|
|
76
|
-
onRowClick={(row: any, column: any, event: any) => emit('row-click', { row, column, event })}
|
|
77
|
-
onRowContextmenu={(row: any, column: any, event: any) => emit('row-contextmenu', { row, column, event })}
|
|
78
|
-
onRowDblclick={(row: any, column: any, event: any) => emit('row-dblclick', { row, column, event })}
|
|
79
|
-
onHeaderClick={(column: any, event: any) => emit('header-click', { column, event })}
|
|
80
|
-
onHeaderContextmenu={(column: any, event: any) => emit('header-contextmenu', { column, event })}
|
|
81
|
-
onSortChange={({ column, prop, order }: any) => emit('sort-change', { column, prop, order })}
|
|
82
|
-
onFilterChange={(filters: any) => emit('filter-change', filters)}
|
|
83
|
-
onCurrentChange={(currentRow: any, oldCurrentRow: any) => emit('current-change', { currentRow, oldCurrentRow })}
|
|
84
|
-
onHeaderDragend={(newWidth: any, oldWidth: any, column: any, event: any) => emit('header-dragend', { newWidth, oldWidth, column, event })}
|
|
85
|
-
onExpandChange={(row: any, expanded: any) => emit('expand-change', { row, expanded })}
|
|
86
|
-
>{tableColumnDom(columns)}</el-table>
|
|
87
|
-
)
|
|
103
|
+
return () => (tableDom(tableConfig.value))
|
|
88
104
|
},
|
|
89
105
|
})
|
|
90
106
|
</script>
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
trigger="click"
|
|
13
13
|
@command="toolbarClick"
|
|
14
14
|
>
|
|
15
|
-
<flm-button :config="{ ...config.publicConfig,
|
|
15
|
+
<flm-button :config="{ ...config.publicConfig, buttonText: '更多' }" />
|
|
16
16
|
<template #dropdown>
|
|
17
17
|
<el-dropdown-menu>
|
|
18
18
|
<el-dropdown-item
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
:config="buttonConfig"
|
|
21
21
|
:key="buttonConfig.event"
|
|
22
22
|
:command="buttonConfig.event"
|
|
23
|
-
>{{ buttonConfig.
|
|
23
|
+
>{{ buttonConfig.buttonText }}</el-dropdown-item>
|
|
24
24
|
</el-dropdown-menu>
|
|
25
25
|
</template>
|
|
26
26
|
</el-dropdown>
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
|
|
30
30
|
<script lang="ts" setup>
|
|
31
31
|
import { defineEmits, defineProps, PropType, computed, ComputedRef } from 'vue'
|
|
32
|
-
import { flmButton } from '
|
|
33
|
-
import { ToolbarConfig, ToolbarButtonConfig } from '
|
|
32
|
+
import { flmButton } from '@/components'
|
|
33
|
+
import { ToolbarConfig, ToolbarButtonConfig } from '@/model/flmComponentConfig'
|
|
34
34
|
|
|
35
35
|
const emit = defineEmits(['toolbarClick'])
|
|
36
36
|
const props = defineProps({
|