flame-plus 0.1.33 → 0.1.36
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/flameDist/flame-plus.es.js +4 -4
- package/flameDist/flame-plus.es.js.map +1 -1
- package/flameDist/flame-plus.umd.js +1 -1
- package/flameDist/flame-plus.umd.js.map +1 -1
- package/flameDist/style.css +1 -1
- package/package.json +2 -2
- package/.vscode/extensions.json +0 -3
- package/index.html +0 -13
- package/pnpm-lock.yaml +0 -2107
- package/src/App.vue +0 -10
- package/src/assets/vue.svg +0 -1
- package/src/components/HelloWorld.vue +0 -33
- package/src/main.ts +0 -19
- package/src/packages/components/base/flmButton/flmButton.vue +0 -29
- package/src/packages/components/base/flmCascader/flmCascader.vue +0 -39
- package/src/packages/components/base/flmCheckbox/flmCheckbox.vue +0 -34
- package/src/packages/components/base/flmCheckbox/flmCheckboxGroup.vue +0 -71
- package/src/packages/components/base/flmColorPicker/flmColorPicker.vue +0 -34
- package/src/packages/components/base/flmDatePicker/flmDatePicker.vue +0 -47
- package/src/packages/components/base/flmDialog/flmDialog.vue +0 -39
- package/src/packages/components/base/flmInput/flmInput.vue +0 -38
- package/src/packages/components/base/flmInputNumber/flmInputNumber.vue +0 -36
- package/src/packages/components/base/flmPagination/flmPagination.vue +0 -37
- package/src/packages/components/base/flmRadio/flmRadio.vue +0 -64
- package/src/packages/components/base/flmRate/flmRate.vue +0 -34
- package/src/packages/components/base/flmRead/flmRead.vue +0 -18
- package/src/packages/components/base/flmSelect/flmSelect.vue +0 -74
- package/src/packages/components/base/flmSlider/flmSlider.vue +0 -35
- package/src/packages/components/base/flmSwitch/flmSwitch.vue +0 -29
- package/src/packages/components/base/flmTimePicker/flmTimePicker.vue +0 -37
- package/src/packages/components/base/flmTimeSelect/flmTimeSelect.vue +0 -36
- package/src/packages/components/base/flmTransfer/flmTransfer.vue +0 -42
- package/src/packages/components/complex/flmForm/flmForm.vue +0 -243
- package/src/packages/components/complex/flmSearch/flmSearch.vue +0 -145
- package/src/packages/components/complex/flmTable/flmTable.vue +0 -106
- package/src/packages/components/complex/flmToolbar/flmToolbar.vue +0 -55
- package/src/packages/components/index.ts +0 -30
- package/src/packages/components/page/flmExportPage/flmExportPage.vue +0 -219
- package/src/packages/components/page/flmReportPage/flmReportPage.vue +0 -496
- package/src/packages/index.ts +0 -96
- package/src/packages/utils/filterConfig.ts +0 -39
- package/src/packages/utils/index.ts +0 -2
- package/src/packages/utils/isValidKey.ts +0 -13
- package/src/shims-vue.d.ts +0 -9
- package/tsconfig.json +0 -39
- package/vite.config.js +0 -37
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
<script lang="tsx">
|
|
2
|
-
import { defineComponent, PropType, computed, reactive } from 'vue'
|
|
3
|
-
import { SliderConfig, SliderDefaultEvent, sliderDefaultConfig } from 'flame-types'
|
|
4
|
-
import { filterConfig } from '../../../utils'
|
|
5
|
-
|
|
6
|
-
export default defineComponent({
|
|
7
|
-
emits: ['change', 'input'],
|
|
8
|
-
props: {
|
|
9
|
-
// 默认设置
|
|
10
|
-
config: {
|
|
11
|
-
type: Object as PropType<SliderConfig>,
|
|
12
|
-
default: {}
|
|
13
|
-
},
|
|
14
|
-
},
|
|
15
|
-
setup(props, ctx) {
|
|
16
|
-
// 滑块设置
|
|
17
|
-
const sliderConfig = computed((): SliderConfig => {
|
|
18
|
-
return filterConfig(sliderDefaultConfig, props.config)
|
|
19
|
-
})
|
|
20
|
-
|
|
21
|
-
// 滑块默认事件
|
|
22
|
-
const sliderDefaultEvent: SliderDefaultEvent = reactive({
|
|
23
|
-
onChange: (value: SliderConfig['model-value']) => ctx.emit('change', value),
|
|
24
|
-
onInput: (value: SliderConfig['model-value']) => ctx.emit('input', value),
|
|
25
|
-
})
|
|
26
|
-
|
|
27
|
-
return () => (
|
|
28
|
-
<el-slider
|
|
29
|
-
{...sliderConfig.value}
|
|
30
|
-
{...sliderDefaultEvent}
|
|
31
|
-
></el-slider>
|
|
32
|
-
)
|
|
33
|
-
},
|
|
34
|
-
})
|
|
35
|
-
</script>
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
<script lang="tsx">
|
|
2
|
-
import { defineComponent, PropType, computed } from 'vue'
|
|
3
|
-
import { SwitchConfig, switchDefaultConfig } from 'flame-types'
|
|
4
|
-
import { filterConfig } from '../../../utils'
|
|
5
|
-
|
|
6
|
-
export default defineComponent({
|
|
7
|
-
emits: ['change'],
|
|
8
|
-
props: {
|
|
9
|
-
// 默认设置
|
|
10
|
-
config: {
|
|
11
|
-
type: Object as PropType<SwitchConfig>,
|
|
12
|
-
default: {}
|
|
13
|
-
},
|
|
14
|
-
},
|
|
15
|
-
setup(props, ctx) {
|
|
16
|
-
// 开关设置
|
|
17
|
-
const switchConfig = computed((): SwitchConfig => {
|
|
18
|
-
return filterConfig(switchDefaultConfig, props.config)
|
|
19
|
-
})
|
|
20
|
-
|
|
21
|
-
return () => (
|
|
22
|
-
<el-switch
|
|
23
|
-
{...switchConfig.value}
|
|
24
|
-
onChange={(value: SwitchConfig['model-value']) => ctx.emit('change', value)}
|
|
25
|
-
></el-switch>
|
|
26
|
-
)
|
|
27
|
-
},
|
|
28
|
-
})
|
|
29
|
-
</script>
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
<script lang="tsx">
|
|
2
|
-
import { defineComponent, PropType, computed, reactive } from 'vue'
|
|
3
|
-
import { TimePickerConfig, TimePickerDefaultEvent, timePickerDefaultConfig } from 'flame-types'
|
|
4
|
-
import { filterConfig } from '../../../utils'
|
|
5
|
-
|
|
6
|
-
export default defineComponent({
|
|
7
|
-
emits: ['change', 'blur', 'focus', 'visible-change' ],
|
|
8
|
-
props: {
|
|
9
|
-
// 默认设置
|
|
10
|
-
config: {
|
|
11
|
-
type: Object as PropType<TimePickerConfig>,
|
|
12
|
-
default: {}
|
|
13
|
-
},
|
|
14
|
-
},
|
|
15
|
-
setup(props, ctx) {
|
|
16
|
-
// 时间选择器设置
|
|
17
|
-
const timePickerConfig = computed((): TimePickerConfig => {
|
|
18
|
-
return filterConfig(timePickerDefaultConfig, props.config)
|
|
19
|
-
})
|
|
20
|
-
|
|
21
|
-
// 时间选择器事件
|
|
22
|
-
const timePickerDefaultEvent: TimePickerDefaultEvent = reactive({
|
|
23
|
-
'onUpdate:modelValue': (value: TimePickerConfig['model-value']) => ctx.emit('change', value), // v-model 不用改不了值
|
|
24
|
-
onBlur: (event: any) => ctx.emit('blur', event),
|
|
25
|
-
onFocus: (event: any) => ctx.emit('focus', event),
|
|
26
|
-
onVisibleChange: (event: boolean) => ctx.emit('visible-change', event),
|
|
27
|
-
})
|
|
28
|
-
|
|
29
|
-
return () => (
|
|
30
|
-
<el-time-picker
|
|
31
|
-
{...timePickerConfig.value}
|
|
32
|
-
{...timePickerDefaultEvent}
|
|
33
|
-
/>
|
|
34
|
-
)
|
|
35
|
-
},
|
|
36
|
-
})
|
|
37
|
-
</script>
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
<script lang="tsx">
|
|
2
|
-
import { defineComponent, PropType, computed, reactive } from 'vue'
|
|
3
|
-
import { TimeSelectConfig, timeSelectDefaultConfig } from 'flame-types'
|
|
4
|
-
import { filterConfig } from '../../../utils'
|
|
5
|
-
|
|
6
|
-
export default defineComponent({
|
|
7
|
-
emits: ['change', 'blur', 'focus'],
|
|
8
|
-
props: {
|
|
9
|
-
// 默认设置
|
|
10
|
-
config: {
|
|
11
|
-
type: Object as PropType<TimeSelectConfig>,
|
|
12
|
-
default: {}
|
|
13
|
-
},
|
|
14
|
-
},
|
|
15
|
-
setup(props, ctx) {
|
|
16
|
-
// 时间选择设置
|
|
17
|
-
const timeSelectConfig = computed((): TimeSelectConfig => {
|
|
18
|
-
return filterConfig(timeSelectDefaultConfig, props.config)
|
|
19
|
-
})
|
|
20
|
-
|
|
21
|
-
// 时间选择默认事件
|
|
22
|
-
const timeSelectDefaultEvent: any = reactive({
|
|
23
|
-
onChange: (value: TimeSelectConfig['model-value']) => ctx.emit('change', value),
|
|
24
|
-
onBlur: () => ctx.emit('blur'),
|
|
25
|
-
onFocus: () => ctx.emit('focus'),
|
|
26
|
-
})
|
|
27
|
-
|
|
28
|
-
return () => (
|
|
29
|
-
<el-timeSelect
|
|
30
|
-
{...timeSelectConfig.value}
|
|
31
|
-
{...timeSelectDefaultEvent}
|
|
32
|
-
/>
|
|
33
|
-
)
|
|
34
|
-
},
|
|
35
|
-
})
|
|
36
|
-
</script>
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
<script lang="tsx">
|
|
2
|
-
import { defineComponent, PropType, computed, reactive } from 'vue'
|
|
3
|
-
import { TransferConfig, TransferDefaultEvent, transferDefaultConfig } from 'flame-types'
|
|
4
|
-
import { filterConfig } from '../../../utils'
|
|
5
|
-
|
|
6
|
-
export default defineComponent({
|
|
7
|
-
emits: ['change', 'left-check-change', 'right-check-change'],
|
|
8
|
-
props: {
|
|
9
|
-
// 默认设置
|
|
10
|
-
config: {
|
|
11
|
-
type: Object as PropType<TransferConfig>,
|
|
12
|
-
default: {}
|
|
13
|
-
},
|
|
14
|
-
},
|
|
15
|
-
setup(props, ctx) {
|
|
16
|
-
// 穿梭框设置
|
|
17
|
-
const transferConfig = computed((): TransferConfig => {
|
|
18
|
-
return filterConfig(transferDefaultConfig, props.config)
|
|
19
|
-
})
|
|
20
|
-
|
|
21
|
-
// 穿梭框默认事件
|
|
22
|
-
const transferDefaultEvent: TransferDefaultEvent = reactive({
|
|
23
|
-
onChange: (value: TransferConfig['model-value']) => ctx.emit('change', value),
|
|
24
|
-
onLeftCheckChange: (value: TransferConfig['model-value']) => ctx.emit('left-check-change', value),
|
|
25
|
-
onRightCheckChange: (value: TransferConfig['model-value']) => ctx.emit('right-check-change', value),
|
|
26
|
-
})
|
|
27
|
-
|
|
28
|
-
return () => (
|
|
29
|
-
<el-transfer
|
|
30
|
-
{...transferConfig.value}
|
|
31
|
-
{...transferDefaultEvent}
|
|
32
|
-
>
|
|
33
|
-
{{
|
|
34
|
-
'default': ({ option }: any) => ctx.slots['default']?.({ option }),
|
|
35
|
-
'left-footer': () => ctx.slots['left-footer']?.(),
|
|
36
|
-
'right-footer': () => ctx.slots['right-footer']?.(),
|
|
37
|
-
}}
|
|
38
|
-
</el-transfer>
|
|
39
|
-
)
|
|
40
|
-
},
|
|
41
|
-
})
|
|
42
|
-
</script>
|
|
@@ -1,243 +0,0 @@
|
|
|
1
|
-
<script lang="tsx">
|
|
2
|
-
import {
|
|
3
|
-
defineComponent,
|
|
4
|
-
getCurrentInstance,
|
|
5
|
-
PropType,
|
|
6
|
-
reactive,
|
|
7
|
-
computed,
|
|
8
|
-
watch,
|
|
9
|
-
h,
|
|
10
|
-
resolveComponent,
|
|
11
|
-
onMounted
|
|
12
|
-
} from 'vue'
|
|
13
|
-
import {
|
|
14
|
-
flmButton,
|
|
15
|
-
flmCascader,
|
|
16
|
-
flmCheckbox,
|
|
17
|
-
flmColorPicker,
|
|
18
|
-
flmDatePicker,
|
|
19
|
-
flmInput,
|
|
20
|
-
flmInputNumber,
|
|
21
|
-
flmRadio,
|
|
22
|
-
flmRate,
|
|
23
|
-
flmRead,
|
|
24
|
-
flmSelect,
|
|
25
|
-
flmSlider,
|
|
26
|
-
flmSwitch,
|
|
27
|
-
flmTimePicker,
|
|
28
|
-
flmTimeSelect,
|
|
29
|
-
flmTransfer,
|
|
30
|
-
} from '../../index'
|
|
31
|
-
import {
|
|
32
|
-
ControlTypes,
|
|
33
|
-
ControlConfig,
|
|
34
|
-
isInputControl,
|
|
35
|
-
FormModel,
|
|
36
|
-
FormConfig,
|
|
37
|
-
FormItemConfig,
|
|
38
|
-
FormButtonConfig,
|
|
39
|
-
formDefaultConfig
|
|
40
|
-
} from 'flame-types'
|
|
41
|
-
import { filterConfig, isValidKey } from '../../../utils'
|
|
42
|
-
|
|
43
|
-
export default defineComponent({
|
|
44
|
-
components: {
|
|
45
|
-
flmButton,
|
|
46
|
-
flmCascader,
|
|
47
|
-
flmCheckbox,
|
|
48
|
-
flmColorPicker,
|
|
49
|
-
flmDatePicker,
|
|
50
|
-
flmInput,
|
|
51
|
-
flmInputNumber,
|
|
52
|
-
flmRadio,
|
|
53
|
-
flmRate,
|
|
54
|
-
flmRead,
|
|
55
|
-
flmSelect,
|
|
56
|
-
flmSlider,
|
|
57
|
-
flmSwitch,
|
|
58
|
-
flmTimePicker,
|
|
59
|
-
flmTimeSelect,
|
|
60
|
-
flmTransfer,
|
|
61
|
-
},
|
|
62
|
-
emits: ['submit', 'cancel', 'reset', 'customEvent'],
|
|
63
|
-
props: {
|
|
64
|
-
// 默认设置
|
|
65
|
-
config: {
|
|
66
|
-
type: Object as PropType<FormConfig>,
|
|
67
|
-
default: {}
|
|
68
|
-
},
|
|
69
|
-
},
|
|
70
|
-
computed: {
|
|
71
|
-
columnNumber(): number | boolean {
|
|
72
|
-
const { inline = false, columnNumber = 0 } = this.config
|
|
73
|
-
return inline && columnNumber > 1
|
|
74
|
-
? columnNumber
|
|
75
|
-
: false
|
|
76
|
-
}
|
|
77
|
-
},
|
|
78
|
-
setup(props, { slots, emit, expose }) {
|
|
79
|
-
const instance = getCurrentInstance() // 实例,必须在最外层声明
|
|
80
|
-
let formModel: FormModel = reactive({}) // 表单数据
|
|
81
|
-
|
|
82
|
-
// 监听表单配置的 model,变化后更新组件内部 formModel
|
|
83
|
-
watch(() => props.config.model, (newModel: FormModel) => updateFormModel(newModel))
|
|
84
|
-
|
|
85
|
-
// 监听组件内部 formModel,变化后更新控件 value
|
|
86
|
-
watch(formModel, (newModel: FormModel) => updateControl(newModel))
|
|
87
|
-
|
|
88
|
-
onMounted(() => {
|
|
89
|
-
if (props.config?.model && Object.keys(props.config?.model).length) {
|
|
90
|
-
updateControl(props.config.model)
|
|
91
|
-
updateFormModel(props.config.model)
|
|
92
|
-
}
|
|
93
|
-
})
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* 更新控件值
|
|
97
|
-
* @date 2022-05-09
|
|
98
|
-
* @param {FormModel} model
|
|
99
|
-
*/
|
|
100
|
-
const updateControl = (model: FormModel) => {
|
|
101
|
-
props.config.items?.forEach((formItem: FormItemConfig) => {
|
|
102
|
-
if (!isValidKey('isSlot', formItem) && typeof(formItem.prop) === 'string') {
|
|
103
|
-
const { controlConfig } = formItem
|
|
104
|
-
controlConfig && (
|
|
105
|
-
isInputControl(controlConfig)
|
|
106
|
-
? controlConfig['modelValue'] = model[formItem.prop]
|
|
107
|
-
: controlConfig['model-value'] = model[formItem.prop]
|
|
108
|
-
)
|
|
109
|
-
}
|
|
110
|
-
})
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
/**
|
|
114
|
-
* 更新表单值
|
|
115
|
-
* @date 2022-05-09
|
|
116
|
-
* @param {FormModel} model
|
|
117
|
-
*/
|
|
118
|
-
const updateFormModel = (model: FormModel) => {
|
|
119
|
-
Object.entries(model).forEach(([key, value]: Array<any>) => formModel[key] = value)
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
/**
|
|
123
|
-
* 表单修改
|
|
124
|
-
* @date 2022-04-14
|
|
125
|
-
* @param {any} value 修改值
|
|
126
|
-
* @param {string} prop 修改键名
|
|
127
|
-
*/
|
|
128
|
-
const formChange = (value: any, prop: string) => formModel[prop] = value
|
|
129
|
-
|
|
130
|
-
/**
|
|
131
|
-
* 表单方法调用
|
|
132
|
-
* @date 2022-04-14
|
|
133
|
-
* @param {'submit' | 'cancel' | 'reset' | string} event 方法名(默认方法直接调用;自定义方法回传方法名及表单数据)
|
|
134
|
-
*/
|
|
135
|
-
const formEvent = (event: FormButtonConfig['event']) => {
|
|
136
|
-
const defaultEvent: Record<FormButtonConfig['event'], Function> = { submit, cancel, reset }
|
|
137
|
-
isValidKey(event, defaultEvent)
|
|
138
|
-
? defaultEvent[event]()
|
|
139
|
-
: emit('customEvent', { event, formModel })
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
// 提交
|
|
143
|
-
const submit = () => {
|
|
144
|
-
const formRef: any = instance?.refs['formRef']
|
|
145
|
-
if (!formRef) return
|
|
146
|
-
formRef.validate((valid: boolean) => {
|
|
147
|
-
valid && emit('submit', formModel)
|
|
148
|
-
})
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
// 取消
|
|
152
|
-
const cancel = () => {
|
|
153
|
-
emit('cancel', formModel)
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
// 重置
|
|
157
|
-
const reset = () => {
|
|
158
|
-
const formRef: any = instance?.refs['formRef']
|
|
159
|
-
if (!formRef) return
|
|
160
|
-
formRef.resetFields()
|
|
161
|
-
emit('reset', formModel)
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
/**
|
|
165
|
-
* 表单元素
|
|
166
|
-
* @date 2022-04-14
|
|
167
|
-
* @param {Array} items 表单项配置
|
|
168
|
-
* @returns {any} 表单项dom
|
|
169
|
-
*/
|
|
170
|
-
const formItemsDom = (items: FormConfig['items'] = []) => {
|
|
171
|
-
const controlDom = (prop: string, controlType: ControlTypes, controlConfig: ControlConfig) => {
|
|
172
|
-
const config: FormModel = { ...controlConfig }
|
|
173
|
-
const event = controlType === ControlTypes['flmInput'] ? 'onInput' : 'onChange'
|
|
174
|
-
config[event] = (value: any) => formChange(value, prop)
|
|
175
|
-
return h(resolveComponent(controlType), { config })
|
|
176
|
-
}
|
|
177
|
-
return items.map((item: FormItemConfig) => {
|
|
178
|
-
if (typeof(item.prop) === 'string') {
|
|
179
|
-
if (isValidKey('isSlot', item)) {
|
|
180
|
-
const { isSlot, ...itemConfig } = item
|
|
181
|
-
return (
|
|
182
|
-
<el-form-item class={`form-${item.prop}`} {...itemConfig}>
|
|
183
|
-
{(slots[item.prop]?.({ prop: item.prop, formModel }))}
|
|
184
|
-
</el-form-item>
|
|
185
|
-
)
|
|
186
|
-
} else {
|
|
187
|
-
const { controlType, controlConfig, ...itemConfig } = item
|
|
188
|
-
if (controlType && controlConfig) {
|
|
189
|
-
return (
|
|
190
|
-
<el-form-item class={`form-${item.prop}`} {...itemConfig}>
|
|
191
|
-
{controlDom(item.prop, controlType, controlConfig)}
|
|
192
|
-
</el-form-item>
|
|
193
|
-
)
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
})
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
/**
|
|
201
|
-
* 表单按钮
|
|
202
|
-
* @date 2022-04-14
|
|
203
|
-
* @param {Array} buttons 表单按钮配置
|
|
204
|
-
* @returns {any} 表单按钮dom
|
|
205
|
-
*/
|
|
206
|
-
const buttonsDom = (buttons: FormConfig['buttons'] = []) => {
|
|
207
|
-
if (buttons.length) {
|
|
208
|
-
return (
|
|
209
|
-
<el-form-item class="form-buttons">
|
|
210
|
-
{buttons.map(({ event, ...config }: FormButtonConfig) =>
|
|
211
|
-
<flm-button config={config} onButtonClick={() => formEvent(event)} />
|
|
212
|
-
)}
|
|
213
|
-
</el-form-item>
|
|
214
|
-
)
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
expose({ formModel, reset })
|
|
219
|
-
|
|
220
|
-
// 表单设置
|
|
221
|
-
const formConfig = computed((): FormConfig => filterConfig(formDefaultConfig, props.config))
|
|
222
|
-
const formDom = () => {
|
|
223
|
-
const { items = [], buttons = [], model, ...defaultConfig } = formConfig.value
|
|
224
|
-
return (
|
|
225
|
-
<el-form ref='formRef' {...defaultConfig} model={formModel}>
|
|
226
|
-
{formItemsDom(items)}
|
|
227
|
-
{buttonsDom(buttons)}
|
|
228
|
-
</el-form>
|
|
229
|
-
)
|
|
230
|
-
}
|
|
231
|
-
return () => (formDom())
|
|
232
|
-
},
|
|
233
|
-
})
|
|
234
|
-
</script>
|
|
235
|
-
|
|
236
|
-
<style lang="scss" scoped>
|
|
237
|
-
$columnNumber: v-bind(columnNumber);
|
|
238
|
-
:deep(.el-form-item) {
|
|
239
|
-
@if $columnNumber != false {
|
|
240
|
-
width: calc((100% - 32px * $columnNumber) / $columnNumber);
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
</style>
|
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div>
|
|
3
|
-
<flmForm
|
|
4
|
-
class="search-default"
|
|
5
|
-
ref="searchDefaultRef"
|
|
6
|
-
:config="defaultConfig"
|
|
7
|
-
@submit="searchSubmit"
|
|
8
|
-
@reset="searchReset"
|
|
9
|
-
@customEvent="searchCustomEvent"
|
|
10
|
-
>
|
|
11
|
-
<template v-for="defaultSlot in defaultSlots" #[defaultSlot]="{ prop, formModel }">
|
|
12
|
-
<slot :name="defaultSlot" :prop="prop" :formModel="formModel"></slot>
|
|
13
|
-
</template>
|
|
14
|
-
</flmForm>
|
|
15
|
-
<el-drawer
|
|
16
|
-
v-if="hasExtra"
|
|
17
|
-
v-model="showExtra"
|
|
18
|
-
title="搜索"
|
|
19
|
-
:before-close="closeDrawer"
|
|
20
|
-
:close-on-click-modal="false"
|
|
21
|
-
:close-on-press-escape="false"
|
|
22
|
-
:show-close="false"
|
|
23
|
-
direction="ltr"
|
|
24
|
-
>
|
|
25
|
-
<flmForm
|
|
26
|
-
ref="searchExtraRef"
|
|
27
|
-
:config="extraConfig"
|
|
28
|
-
@submit="drawerSubmit"
|
|
29
|
-
@cancel="closeDrawer"
|
|
30
|
-
>
|
|
31
|
-
<template v-for="extraSlot in extraSlots" #[extraSlot]="{ prop, formModel }">
|
|
32
|
-
<slot :name="extraSlot" :prop="prop" :formModel="formModel"></slot>
|
|
33
|
-
</template>
|
|
34
|
-
</flmForm>
|
|
35
|
-
</el-drawer>
|
|
36
|
-
</div>
|
|
37
|
-
</template>
|
|
38
|
-
|
|
39
|
-
<script lang="ts" setup>
|
|
40
|
-
import { PropType, ref, Ref, computed, ComputedRef } from 'vue'
|
|
41
|
-
import { flmForm } from '../../index'
|
|
42
|
-
import { ButtonType, FormItemConfig, SearchConfig } from 'flame-types'
|
|
43
|
-
import { isValidKey } from '../../../utils'
|
|
44
|
-
|
|
45
|
-
const emit = defineEmits(['searchSubmit', 'searchReset', 'searchCustomEvent'])
|
|
46
|
-
const props = defineProps({
|
|
47
|
-
config: {
|
|
48
|
-
type: Object as PropType<SearchConfig>,
|
|
49
|
-
default() {
|
|
50
|
-
return {}
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
})
|
|
54
|
-
|
|
55
|
-
const searchDefaultRef: Ref<any> = ref() // 默认搜索栏实例
|
|
56
|
-
const searchExtraRef: Ref<any> = ref() // 额外搜索栏实例
|
|
57
|
-
|
|
58
|
-
let showExtra: Ref<boolean> = ref(false) // 显示额外搜索条件
|
|
59
|
-
let hasExtra: Ref<boolean> = ref(false) // 有额外搜索条件
|
|
60
|
-
let extraFormModel: Ref<SearchConfig> = ref({}) // 额外搜索条件
|
|
61
|
-
|
|
62
|
-
const maxFormItem = computed(() => props.config.maxFormItem || 3) // 默认搜索栏最大条件数
|
|
63
|
-
|
|
64
|
-
// 默认搜索栏设置
|
|
65
|
-
const defaultConfig: ComputedRef<SearchConfig> = computed(() => {
|
|
66
|
-
const { items = [], buttons, ...config } = props.config
|
|
67
|
-
hasExtra.value = items.length > maxFormItem.value
|
|
68
|
-
hasExtra.value && buttons?.unshift({ 'buttonText': '更多', 'event': 'openDrawer' }) // 搜索条件大于最大数量,插入更多按钮
|
|
69
|
-
return {
|
|
70
|
-
...config,
|
|
71
|
-
inline: true,
|
|
72
|
-
items: items.slice(0, maxFormItem.value),
|
|
73
|
-
buttons
|
|
74
|
-
}
|
|
75
|
-
})
|
|
76
|
-
// 额外搜索栏设置
|
|
77
|
-
const extraConfig: ComputedRef<SearchConfig> = computed(() => {
|
|
78
|
-
const { items, buttons, ...config } = props.config
|
|
79
|
-
return {
|
|
80
|
-
...config,
|
|
81
|
-
inline: false,
|
|
82
|
-
items: items?.slice(maxFormItem.value),
|
|
83
|
-
// 插入额外搜索栏按钮
|
|
84
|
-
buttons: [
|
|
85
|
-
{
|
|
86
|
-
'buttonText': '取消',
|
|
87
|
-
'event': 'cancel'
|
|
88
|
-
},
|
|
89
|
-
{
|
|
90
|
-
'type': ButtonType['primary'],
|
|
91
|
-
'buttonText': '搜索',
|
|
92
|
-
'event': 'submit'
|
|
93
|
-
}
|
|
94
|
-
]
|
|
95
|
-
}
|
|
96
|
-
})
|
|
97
|
-
|
|
98
|
-
// 获取表格插槽
|
|
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
|
|
108
|
-
}
|
|
109
|
-
// 默认搜索栏插槽
|
|
110
|
-
const defaultSlots = computed((): Array<string> => getFormSlots(props.config.items?.slice(0, maxFormItem.value)) ?? [])
|
|
111
|
-
// 额外搜索栏插槽
|
|
112
|
-
const extraSlots = computed((): Array<string> => getFormSlots(props.config.items?.slice(maxFormItem.value)) ?? [])
|
|
113
|
-
|
|
114
|
-
// 搜索栏提交
|
|
115
|
-
const searchSubmit = (formModel: SearchConfig['model']) => {
|
|
116
|
-
emit('searchSubmit', { ...formModel, ...extraFormModel.value })
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
// 搜索栏取消
|
|
120
|
-
const searchReset = () => {
|
|
121
|
-
searchExtraRef.value?.reset()
|
|
122
|
-
const extraFormModel = searchExtraRef.value?.formModel ?? {}
|
|
123
|
-
emit('searchReset', { ...extraFormModel, ...searchDefaultRef.value.formModel })
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
// 搜索栏自定义操作
|
|
127
|
-
const searchCustomEvent = ({ event, formModel }: { event: string, formModel: SearchConfig['model']}) => {
|
|
128
|
-
const customEvent: Record<string, Function> = { openDrawer }
|
|
129
|
-
if (isValidKey(event, customEvent)) {
|
|
130
|
-
customEvent[event](formModel)
|
|
131
|
-
} else {
|
|
132
|
-
emit('searchCustomEvent', event)
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
const openDrawer = () => showExtra.value = true // 打开额外搜索栏弹窗
|
|
137
|
-
const closeDrawer = () => showExtra.value = false // 关闭额外搜索栏弹窗
|
|
138
|
-
|
|
139
|
-
// 额外搜索栏提交
|
|
140
|
-
const drawerSubmit = (formModel: SearchConfig['model']) => {
|
|
141
|
-
formModel && (extraFormModel.value = formModel)
|
|
142
|
-
emit('searchSubmit', { ...searchDefaultRef.value.formModel, ...formModel })
|
|
143
|
-
closeDrawer()
|
|
144
|
-
}
|
|
145
|
-
</script>
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
<script lang="tsx">
|
|
2
|
-
import { defineComponent, PropType, reactive, computed } from 'vue'
|
|
3
|
-
import {
|
|
4
|
-
TableConfig,
|
|
5
|
-
TableColumnConfig,
|
|
6
|
-
TableDefaultEvent,
|
|
7
|
-
tableDefaultConfig,
|
|
8
|
-
tableColumnDefaultConfig
|
|
9
|
-
} from 'flame-types'
|
|
10
|
-
import { filterConfig } from '../../../utils'
|
|
11
|
-
|
|
12
|
-
export default defineComponent({
|
|
13
|
-
emits: [
|
|
14
|
-
'select',
|
|
15
|
-
'select-all',
|
|
16
|
-
'selection-change',
|
|
17
|
-
'cell-mouse-enter',
|
|
18
|
-
'cell-mouse-leave',
|
|
19
|
-
'cell-click',
|
|
20
|
-
'cell-dblclick',
|
|
21
|
-
'cell-contextmenu',
|
|
22
|
-
'row-click',
|
|
23
|
-
'row-contextmenu',
|
|
24
|
-
'row-dblclick',
|
|
25
|
-
'header-click',
|
|
26
|
-
'header-contextmenu',
|
|
27
|
-
'sort-change',
|
|
28
|
-
'filter-change',
|
|
29
|
-
'current-change',
|
|
30
|
-
'header-dragend',
|
|
31
|
-
'expand-change',
|
|
32
|
-
],
|
|
33
|
-
props: {
|
|
34
|
-
// 默认设置
|
|
35
|
-
config: {
|
|
36
|
-
type: Object as PropType<TableConfig>,
|
|
37
|
-
default: {}
|
|
38
|
-
},
|
|
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
|
-
|
|
79
|
-
/**
|
|
80
|
-
* 表格元素
|
|
81
|
-
* @date 2022-04-14
|
|
82
|
-
* @param {Array} tableColumns 表格列配置
|
|
83
|
-
* @returns {any} 表格列dom
|
|
84
|
-
*/
|
|
85
|
-
const tableColumnDom = (childColumns: TableConfig['columns'] = []) => {
|
|
86
|
-
return childColumns.map(({ isSlot, columns = [], ...childColumnConfig }: TableColumnConfig) => {
|
|
87
|
-
let childDom: any
|
|
88
|
-
if (columns.length) {
|
|
89
|
-
childDom = tableColumnDom(columns)
|
|
90
|
-
} else if (isSlot) {
|
|
91
|
-
childDom = { default: ({ $index: index, row, column }: any) => childColumnConfig.prop && slots[childColumnConfig.prop]?.({ index, row, column }) }
|
|
92
|
-
}
|
|
93
|
-
return (
|
|
94
|
-
<el-table-column {...filterConfig(tableColumnDefaultConfig, childColumnConfig)}>
|
|
95
|
-
{childDom}
|
|
96
|
-
</el-table-column>
|
|
97
|
-
)
|
|
98
|
-
})
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
// 表单设置
|
|
102
|
-
const tableConfig = computed((): TableConfig => filterConfig(tableDefaultConfig, props.config))
|
|
103
|
-
return () => (tableDom(tableConfig.value))
|
|
104
|
-
},
|
|
105
|
-
})
|
|
106
|
-
</script>
|