flame-plus 0.1.22 → 0.1.23
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 +1 -1
- package/packages/components/complex/flmForm/flmForm.vue +307 -225
- package/packages/components/complex/flmSearch/flmSearch.vue +1 -1
- package/packages/components/page/flmReportPage/flmReportPage.vue +17 -80
- package/packages/model/flmComponentConfig/complex/flmForm.ts +1 -0
- package/packages/model/flmComponentConfig/complex/flmSearch.ts +1 -9
- package/packages/model/flmComponentConfig/page/flmReportPage.ts +1 -10
package/package.json
CHANGED
|
@@ -1,226 +1,308 @@
|
|
|
1
|
-
<script lang="tsx">
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
} from 'vue'
|
|
13
|
-
import {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
} from '../../index'
|
|
31
|
-
import {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
} from '../../../model/flmComponentConfig'
|
|
41
|
-
import {
|
|
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 '../../../model/flmComponentConfig'
|
|
41
|
+
import {
|
|
42
|
+
filterConfig,
|
|
43
|
+
isValidKey
|
|
44
|
+
} from '../../../utils'
|
|
45
|
+
|
|
46
|
+
export default defineComponent({
|
|
47
|
+
components: {
|
|
48
|
+
flmButton,
|
|
49
|
+
flmCascader,
|
|
50
|
+
flmCheckbox,
|
|
51
|
+
flmColorPicker,
|
|
52
|
+
flmDatePicker,
|
|
53
|
+
flmInput,
|
|
54
|
+
flmInputNumber,
|
|
55
|
+
flmRadio,
|
|
56
|
+
flmRate,
|
|
57
|
+
flmRead,
|
|
58
|
+
flmSelect,
|
|
59
|
+
flmSlider,
|
|
60
|
+
flmSwitch,
|
|
61
|
+
flmTimePicker,
|
|
62
|
+
flmTimeSelect,
|
|
63
|
+
flmTransfer,
|
|
64
|
+
},
|
|
65
|
+
emits: ['submit', 'cancel', 'reset', 'customEvent'],
|
|
66
|
+
props: {
|
|
67
|
+
// 默认设置
|
|
68
|
+
config: {
|
|
69
|
+
type: Object as PropType < FormConfig > ,
|
|
70
|
+
default: {}
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
computed: {
|
|
74
|
+
columnNumber(): number | boolean {
|
|
75
|
+
const {
|
|
76
|
+
inline = false, columnNumber = 0
|
|
77
|
+
} = this.config
|
|
78
|
+
return inline && columnNumber > 1 ?
|
|
79
|
+
columnNumber :
|
|
80
|
+
false
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
setup(props, {
|
|
84
|
+
slots,
|
|
85
|
+
emit,
|
|
86
|
+
expose
|
|
87
|
+
}) {
|
|
88
|
+
const instance = getCurrentInstance() // 实例,必须在最外层声明
|
|
89
|
+
let formModel: FormModel = reactive({}) // 表单数据
|
|
90
|
+
|
|
91
|
+
// 监听表单配置的 model,变化后更新组件内部 formModel
|
|
92
|
+
watch(() => props.config.model, (newModel: FormModel) => updateFormModel(newModel))
|
|
93
|
+
|
|
94
|
+
// 监听组件内部 formModel,变化后更新控件 value
|
|
95
|
+
watch(formModel, (newModel: FormModel) => updateControl(newModel))
|
|
96
|
+
|
|
97
|
+
onMounted(() => {
|
|
98
|
+
if (props.config?.model && Object.keys(props.config?.model).length) {
|
|
99
|
+
updateControl(props.config.model)
|
|
100
|
+
updateFormModel(props.config.model)
|
|
101
|
+
}
|
|
102
|
+
})
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* 更新控件值
|
|
106
|
+
* @date 2022-05-09
|
|
107
|
+
* @param {FormModel} model
|
|
108
|
+
*/
|
|
109
|
+
const updateControl = (model: FormModel) => {
|
|
110
|
+
props.config.items?.forEach((formItem: FormItemConfig) => {
|
|
111
|
+
if (!isValidKey('isSlot', formItem) && typeof(formItem.prop) === 'string') {
|
|
112
|
+
const {
|
|
113
|
+
controlConfig
|
|
114
|
+
} = formItem
|
|
115
|
+
controlConfig && (
|
|
116
|
+
isInputControl(controlConfig) ?
|
|
117
|
+
controlConfig['modelValue'] = model[formItem.prop] :
|
|
118
|
+
controlConfig['model-value'] = model[formItem.prop]
|
|
119
|
+
)
|
|
120
|
+
}
|
|
121
|
+
})
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* 更新表单值
|
|
126
|
+
* @date 2022-05-09
|
|
127
|
+
* @param {FormModel} model
|
|
128
|
+
*/
|
|
129
|
+
const updateFormModel = (model: FormModel) => {
|
|
130
|
+
Object.entries(model).forEach(([key, value]: Array < any > ) => formModel[key] = value)
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* 表单修改
|
|
135
|
+
* @date 2022-04-14
|
|
136
|
+
* @param {any} value 修改值
|
|
137
|
+
* @param {string} prop 修改键名
|
|
138
|
+
*/
|
|
139
|
+
const formChange = (value: any, prop: string) => formModel[prop] = value
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* 表单方法调用
|
|
143
|
+
* @date 2022-04-14
|
|
144
|
+
* @param {'submit' | 'cancel' | 'reset' | string} event 方法名(默认方法直接调用;自定义方法回传方法名及表单数据)
|
|
145
|
+
*/
|
|
146
|
+
const formEvent = (event: FormButtonConfig['event']) => {
|
|
147
|
+
const defaultEvent: Record < FormButtonConfig['event'], Function > = {
|
|
148
|
+
submit,
|
|
149
|
+
cancel,
|
|
150
|
+
reset
|
|
151
|
+
}
|
|
152
|
+
isValidKey(event, defaultEvent) ?
|
|
153
|
+
defaultEvent[event]() :
|
|
154
|
+
emit('customEvent', {
|
|
155
|
+
event,
|
|
156
|
+
formModel
|
|
157
|
+
})
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
// 提交
|
|
161
|
+
const submit = () => {
|
|
162
|
+
const formRef: any = instance?.refs['formRef']
|
|
163
|
+
if (!formRef) return
|
|
164
|
+
formRef.validate((valid: boolean) => {
|
|
165
|
+
valid && emit('submit', formModel)
|
|
166
|
+
})
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// 取消
|
|
170
|
+
const cancel = () => {
|
|
171
|
+
emit('cancel', formModel)
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
// 重置
|
|
175
|
+
const reset = () => {
|
|
176
|
+
const formRef: any = instance?.refs['formRef']
|
|
177
|
+
if (!formRef) return
|
|
178
|
+
formRef.resetFields()
|
|
179
|
+
emit('reset', formModel)
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* 表单元素
|
|
184
|
+
* @date 2022-04-14
|
|
185
|
+
* @param {Array} items 表单项配置
|
|
186
|
+
* @returns {any} 表单项dom
|
|
187
|
+
*/
|
|
188
|
+
const formItemsDom = (items: FormConfig['items'] = []) => {
|
|
189
|
+
const controlDom = (prop: string, controlType: ControlTypes, controlConfig: ControlConfig) => {
|
|
190
|
+
const config: FormModel = {
|
|
191
|
+
...controlConfig
|
|
192
|
+
}
|
|
193
|
+
const event = controlType === ControlTypes['flmInput'] ? 'onInput' : 'onChange'
|
|
194
|
+
config[event] = (value: any) => formChange(value, prop)
|
|
195
|
+
return h(resolveComponent(controlType), {
|
|
196
|
+
config
|
|
197
|
+
})
|
|
198
|
+
}
|
|
199
|
+
return items.map((item: FormItemConfig) => {
|
|
200
|
+
if (typeof(item.prop) === 'string') {
|
|
201
|
+
if (isValidKey('isSlot', item)) {
|
|
202
|
+
const {
|
|
203
|
+
isSlot,
|
|
204
|
+
...itemConfig
|
|
205
|
+
} = item
|
|
206
|
+
return ( <
|
|
207
|
+
el - form - item class = {
|
|
208
|
+
`form-${item.prop}`
|
|
209
|
+
} {
|
|
210
|
+
...itemConfig
|
|
211
|
+
} > {
|
|
212
|
+
(slots[item.prop]?.({
|
|
213
|
+
prop: item.prop,
|
|
214
|
+
formModel
|
|
215
|
+
}))
|
|
216
|
+
} <
|
|
217
|
+
/el-form-item>
|
|
218
|
+
)
|
|
219
|
+
} else {
|
|
220
|
+
const {
|
|
221
|
+
controlType,
|
|
222
|
+
controlConfig,
|
|
223
|
+
...itemConfig
|
|
224
|
+
} = item
|
|
225
|
+
if (controlType && controlConfig) {
|
|
226
|
+
return ( <
|
|
227
|
+
el - form - item class = {
|
|
228
|
+
`form-${item.prop}`
|
|
229
|
+
} {
|
|
230
|
+
...itemConfig
|
|
231
|
+
} > {
|
|
232
|
+
controlDom(item.prop, controlType, controlConfig)
|
|
233
|
+
} <
|
|
234
|
+
/el-form-item>
|
|
235
|
+
)
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
})
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* 表单按钮
|
|
244
|
+
* @date 2022-04-14
|
|
245
|
+
* @param {Array} buttons 表单按钮配置
|
|
246
|
+
* @returns {any} 表单按钮dom
|
|
247
|
+
*/
|
|
248
|
+
const buttonsDom = (buttons: FormConfig['buttons'] = []) => {
|
|
249
|
+
if (buttons.length) {
|
|
250
|
+
return ( <
|
|
251
|
+
el - form - item class = "form-buttons" > {
|
|
252
|
+
buttons.map(({
|
|
253
|
+
event,
|
|
254
|
+
...config
|
|
255
|
+
}: FormButtonConfig) =>
|
|
256
|
+
<
|
|
257
|
+
flm - button config = {
|
|
258
|
+
config
|
|
259
|
+
}
|
|
260
|
+
onButtonClick = {
|
|
261
|
+
() => formEvent(event)
|
|
262
|
+
}
|
|
263
|
+
/>
|
|
264
|
+
)
|
|
265
|
+
} <
|
|
266
|
+
/el-form-item>
|
|
267
|
+
)
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
expose({
|
|
272
|
+
formModel,
|
|
273
|
+
reset
|
|
274
|
+
})
|
|
275
|
+
|
|
276
|
+
// 表单设置
|
|
277
|
+
const formConfig = computed((): FormConfig => filterConfig(formDefaultConfig, props.config))
|
|
278
|
+
const formDom = () => {
|
|
279
|
+
const {
|
|
280
|
+
items = [], buttons = [], model, ...defaultConfig
|
|
281
|
+
} = formConfig.value
|
|
282
|
+
return ( <
|
|
283
|
+
el - form ref = 'formRef' {
|
|
284
|
+
...defaultConfig
|
|
285
|
+
}
|
|
286
|
+
model = {
|
|
287
|
+
formModel
|
|
288
|
+
} > {
|
|
289
|
+
formItemsDom(items)
|
|
290
|
+
} {
|
|
291
|
+
buttonsDom(buttons)
|
|
292
|
+
} <
|
|
293
|
+
/el-form>
|
|
294
|
+
)
|
|
295
|
+
}
|
|
296
|
+
return () => (formDom())
|
|
297
|
+
},
|
|
298
|
+
})
|
|
299
|
+
</script>
|
|
42
300
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
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
|
-
setup(props, { slots, emit, expose }) {
|
|
71
|
-
const instance = getCurrentInstance() // 实例,必须在最外层声明
|
|
72
|
-
let formModel: FormModel = reactive({}) // 表单数据
|
|
73
|
-
|
|
74
|
-
// 监听表单配置的 model,变化后更新组件内部 formModel
|
|
75
|
-
watch(() => props.config.model, (newModel: FormModel) => updateFormModel(newModel))
|
|
76
|
-
|
|
77
|
-
// 监听组件内部 formModel,变化后更新控件 value
|
|
78
|
-
watch(formModel, (newModel: FormModel) => updateControl(newModel))
|
|
79
|
-
|
|
80
|
-
onMounted(() => {
|
|
81
|
-
if (props.config?.model && Object.keys(props.config?.model).length) {
|
|
82
|
-
updateControl(props.config.model)
|
|
83
|
-
updateFormModel(props.config.model)
|
|
84
|
-
}
|
|
85
|
-
})
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* 更新控件值
|
|
89
|
-
* @date 2022-05-09
|
|
90
|
-
* @param {FormModel} model
|
|
91
|
-
*/
|
|
92
|
-
const updateControl = (model: FormModel) => {
|
|
93
|
-
props.config.items?.forEach((formItem: FormItemConfig) => {
|
|
94
|
-
if (!isValidKey('isSlot', formItem) && typeof(formItem.prop) === 'string') {
|
|
95
|
-
const { controlConfig } = formItem
|
|
96
|
-
controlConfig && (
|
|
97
|
-
isInputControl(controlConfig)
|
|
98
|
-
? controlConfig['modelValue'] = model[formItem.prop]
|
|
99
|
-
: controlConfig['model-value'] = model[formItem.prop]
|
|
100
|
-
)
|
|
101
|
-
}
|
|
102
|
-
})
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* 更新表单值
|
|
107
|
-
* @date 2022-05-09
|
|
108
|
-
* @param {FormModel} model
|
|
109
|
-
*/
|
|
110
|
-
const updateFormModel = (model: FormModel) => {
|
|
111
|
-
Object.entries(model).forEach(([key, value]: Array<any>) => formModel[key] = value)
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* 表单修改
|
|
116
|
-
* @date 2022-04-14
|
|
117
|
-
* @param {any} value 修改值
|
|
118
|
-
* @param {string} prop 修改键名
|
|
119
|
-
*/
|
|
120
|
-
const formChange = (value: any, prop: string) => formModel[prop] = value
|
|
121
|
-
|
|
122
|
-
/**
|
|
123
|
-
* 表单方法调用
|
|
124
|
-
* @date 2022-04-14
|
|
125
|
-
* @param {'submit' | 'cancel' | 'reset' | string} event 方法名(默认方法直接调用;自定义方法回传方法名及表单数据)
|
|
126
|
-
*/
|
|
127
|
-
const formEvent = (event: FormButtonConfig['event']) => {
|
|
128
|
-
const defaultEvent: Record<FormButtonConfig['event'], Function> = { submit, cancel, reset }
|
|
129
|
-
isValidKey(event, defaultEvent)
|
|
130
|
-
? defaultEvent[event]()
|
|
131
|
-
: emit('customEvent', { event, formModel })
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
// 提交
|
|
135
|
-
const submit = () => {
|
|
136
|
-
const formRef: any = instance?.refs['formRef']
|
|
137
|
-
if (!formRef) return
|
|
138
|
-
formRef.validate((valid: boolean) => {
|
|
139
|
-
valid && emit('submit', formModel)
|
|
140
|
-
})
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
// 取消
|
|
144
|
-
const cancel = () => {
|
|
145
|
-
emit('cancel', formModel)
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
// 重置
|
|
149
|
-
const reset = () => {
|
|
150
|
-
const formRef: any = instance?.refs['formRef']
|
|
151
|
-
if (!formRef) return
|
|
152
|
-
formRef.resetFields()
|
|
153
|
-
emit('reset', formModel)
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
/**
|
|
157
|
-
* 表单元素
|
|
158
|
-
* @date 2022-04-14
|
|
159
|
-
* @param {Array} items 表单项配置
|
|
160
|
-
* @returns {any} 表单项dom
|
|
161
|
-
*/
|
|
162
|
-
const formItemsDom = (items: FormConfig['items'] = []) => {
|
|
163
|
-
const controlDom = (prop: string, controlType: ControlTypes, controlConfig: ControlConfig) => {
|
|
164
|
-
const config: FormModel = { ...controlConfig }
|
|
165
|
-
const event = controlType === ControlTypes['flmInput'] ? 'onInput' : 'onChange'
|
|
166
|
-
config[event] = (value: any) => formChange(value, prop)
|
|
167
|
-
return h(resolveComponent(controlType), { config })
|
|
168
|
-
}
|
|
169
|
-
return items.map((item: FormItemConfig) => {
|
|
170
|
-
if (typeof(item.prop) === 'string') {
|
|
171
|
-
if (isValidKey('isSlot', item)) {
|
|
172
|
-
const { isSlot, ...itemConfig } = item
|
|
173
|
-
return (
|
|
174
|
-
<el-form-item class={`form-${item.prop}`} {...itemConfig}>
|
|
175
|
-
{(slots[item.prop]?.({ prop: item.prop, formModel }))}
|
|
176
|
-
</el-form-item>
|
|
177
|
-
)
|
|
178
|
-
} else {
|
|
179
|
-
const { controlType, controlConfig, ...itemConfig } = item
|
|
180
|
-
if (controlType && controlConfig) {
|
|
181
|
-
return (
|
|
182
|
-
<el-form-item class={`form-${item.prop}`} {...itemConfig}>
|
|
183
|
-
{controlDom(item.prop, controlType, controlConfig)}
|
|
184
|
-
</el-form-item>
|
|
185
|
-
)
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
})
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
/**
|
|
193
|
-
* 表单按钮
|
|
194
|
-
* @date 2022-04-14
|
|
195
|
-
* @param {Array} buttons 表单按钮配置
|
|
196
|
-
* @returns {any} 表单按钮dom
|
|
197
|
-
*/
|
|
198
|
-
const buttonsDom = (buttons: FormConfig['buttons'] = []) => {
|
|
199
|
-
if (buttons.length) {
|
|
200
|
-
return (
|
|
201
|
-
<el-form-item class="form-buttons">
|
|
202
|
-
{buttons.map(({ event, ...config }: FormButtonConfig) =>
|
|
203
|
-
<flm-button config={config} onButtonClick={() => formEvent(event)} />
|
|
204
|
-
)}
|
|
205
|
-
</el-form-item>
|
|
206
|
-
)
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
expose({ formModel, reset })
|
|
211
|
-
|
|
212
|
-
// 表单设置
|
|
213
|
-
const formConfig = computed((): FormConfig => filterConfig(formDefaultConfig, props.config))
|
|
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())
|
|
224
|
-
},
|
|
225
|
-
})
|
|
226
|
-
</script>
|
|
301
|
+
<style lang="scss" scoped>
|
|
302
|
+
$columnNumber: v-bind(columnNumber);
|
|
303
|
+
:deep(.el-form-item) {
|
|
304
|
+
@if $columnNumber != false {
|
|
305
|
+
width: calc((100% - 32px * $columnNumber) / $columnNumber);
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
</style>
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
<script lang="ts" setup>
|
|
40
40
|
import { PropType, ref, Ref, computed, ComputedRef } from 'vue'
|
|
41
41
|
import { flmForm } from '../../index'
|
|
42
|
-
import { SearchConfig, FormItemConfig
|
|
42
|
+
import { SearchConfig, FormItemConfig } from '../../../model/flmComponentConfig'
|
|
43
43
|
import { isValidKey } from '../../../utils'
|
|
44
44
|
|
|
45
45
|
const emit = defineEmits(['searchSubmit', 'searchReset', 'searchCustomEvent'])
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
<slot :name="`search-${searchSlot}`" :prop="prop" :formModel="formModel"></slot>
|
|
11
11
|
</template>
|
|
12
12
|
</flmSearch>
|
|
13
|
-
<flmToolbar
|
|
13
|
+
<flmToolbar class="page-toolbar" :config="reportPageConfig.toolbar" @toolbarClick="toolbarClick" />
|
|
14
14
|
<flmTable
|
|
15
15
|
class="page-table"
|
|
16
16
|
:config="reportPageConfig.table"
|
|
@@ -31,7 +31,9 @@
|
|
|
31
31
|
/>
|
|
32
32
|
</template>
|
|
33
33
|
<flmDialog :config="reportPageConfig.readDialog" @close="pageDefaultEvent.closeReadDialog">
|
|
34
|
-
<flmForm
|
|
34
|
+
<flmForm
|
|
35
|
+
class="form-read"
|
|
36
|
+
:config="reportPageConfig.readForm" @cancel="pageDefaultEvent.closeReadDialog">
|
|
35
37
|
<template v-for="readFormSlot in readFormSlots" #[readFormSlot]="{ prop, formModel }">
|
|
36
38
|
<slot :name="`read-${readFormSlot}`" :prop="prop" :formModel="formModel"></slot>
|
|
37
39
|
</template>
|
|
@@ -39,6 +41,7 @@
|
|
|
39
41
|
</flmDialog>
|
|
40
42
|
<flmDialog :config="reportPageConfig.addDialog" @close="pageDefaultEvent.closeAddDialog">
|
|
41
43
|
<flmForm
|
|
44
|
+
class="form-add"
|
|
42
45
|
:config="reportPageConfig.addForm"
|
|
43
46
|
@submit="pageDefaultEvent.pageAdd"
|
|
44
47
|
@cancel="pageDefaultEvent.closeAddDialog"
|
|
@@ -50,6 +53,7 @@
|
|
|
50
53
|
</flmDialog>
|
|
51
54
|
<flmDialog :config="reportPageConfig.editDialog" @close="pageDefaultEvent.closeEditDialog">
|
|
52
55
|
<flmForm
|
|
56
|
+
class="form-edit"
|
|
53
57
|
:config="reportPageConfig.editForm"
|
|
54
58
|
@submit="pageDefaultEvent.pageEdit"
|
|
55
59
|
@cancel="pageDefaultEvent.closeEditDialog"
|
|
@@ -63,7 +67,7 @@
|
|
|
63
67
|
</template>
|
|
64
68
|
|
|
65
69
|
<script lang="ts" setup>
|
|
66
|
-
import { ref, Ref, computed, onMounted
|
|
70
|
+
import { ref, Ref, computed, onMounted } from 'vue'
|
|
67
71
|
import { ElMessage, ElMessageBox } from 'element-plus'
|
|
68
72
|
import {
|
|
69
73
|
flmForm,
|
|
@@ -72,26 +76,21 @@ import {
|
|
|
72
76
|
flmTable,
|
|
73
77
|
flmPagination,
|
|
74
78
|
flmDialog
|
|
75
|
-
} from '
|
|
79
|
+
} from '@/components'
|
|
76
80
|
import {
|
|
77
81
|
FormItemConfig,
|
|
78
82
|
FormConfig,
|
|
79
83
|
TableColumnConfig,
|
|
80
84
|
ReportPageSetting,
|
|
81
|
-
} from '
|
|
82
|
-
import { isValidKey } from '
|
|
85
|
+
} from '@/model/flmComponentConfig'
|
|
86
|
+
import { isValidKey } from '@/utils'
|
|
83
87
|
import request from '@/plugins/request'
|
|
84
|
-
import { is } from '@babel/types'
|
|
85
88
|
|
|
86
89
|
const props = defineProps({
|
|
87
90
|
// 表名
|
|
88
91
|
tableName: {
|
|
89
92
|
type: String,
|
|
90
93
|
required: true
|
|
91
|
-
},
|
|
92
|
-
isDialog:{
|
|
93
|
-
type:Boolean,
|
|
94
|
-
default:false,
|
|
95
94
|
}
|
|
96
95
|
})
|
|
97
96
|
|
|
@@ -157,21 +156,14 @@ const queryPageSetting = () => {
|
|
|
157
156
|
const reportPageSetting: ReportPageSetting = items
|
|
158
157
|
reportPageSetting.table['height'] = tableHeight()
|
|
159
158
|
reportPageSetting.table['max-height'] = tableHeight()
|
|
160
|
-
|
|
161
|
-
reportPageSetting.tableAction.buttons.length && reportPageSetting.table.columns?.push({
|
|
159
|
+
reportPageSetting.tableAction.buttons.length && reportPageSetting.table.columns?.push({
|
|
162
160
|
prop: 'tableAction',
|
|
163
161
|
label: '操作',
|
|
164
162
|
isSlot: true,
|
|
165
|
-
align: 'center',
|
|
166
|
-
'header-align':'center',
|
|
167
163
|
fixed: 'right',
|
|
168
|
-
'min-width': '200px'
|
|
169
|
-
'width': '200px'
|
|
164
|
+
'min-width': '200px'
|
|
170
165
|
})
|
|
171
|
-
}
|
|
172
|
-
|
|
173
166
|
reportPageConfig.value = reportPageSetting
|
|
174
|
-
isLoaded.value =true;
|
|
175
167
|
queryPageData()
|
|
176
168
|
})
|
|
177
169
|
}
|
|
@@ -195,6 +187,7 @@ const queryPageData = () => {
|
|
|
195
187
|
.then(({ items, total }: any) => {
|
|
196
188
|
reportPageConfig.value.table.data = items
|
|
197
189
|
reportPageConfig.value.pagination['total'] = total
|
|
190
|
+
isLoaded.value = true
|
|
198
191
|
})
|
|
199
192
|
}
|
|
200
193
|
|
|
@@ -214,15 +207,16 @@ const searchSubmit = (event: object) => {
|
|
|
214
207
|
const toolbarClick = (event: string) => {
|
|
215
208
|
isValidKey(event, pageDefaultEvent)
|
|
216
209
|
? pageDefaultEvent[event]()
|
|
217
|
-
: emit('customEvent',
|
|
210
|
+
: emit('customEvent', event)
|
|
218
211
|
}
|
|
219
212
|
|
|
220
213
|
// 表格操作栏点击
|
|
221
214
|
const tableActionClick = (event: string, scope: any) => {
|
|
222
215
|
isValidKey(event, pageDefaultEvent)
|
|
223
216
|
? pageDefaultEvent[event](scope)
|
|
224
|
-
: emit('customEvent', { event,
|
|
217
|
+
: emit('customEvent', { event, scope })
|
|
225
218
|
}
|
|
219
|
+
|
|
226
220
|
// 表格操作
|
|
227
221
|
const tableEvent: Record<string, (event?: any) => void> = {
|
|
228
222
|
// 表格勾选项变化
|
|
@@ -252,7 +246,7 @@ const pageDefaultEvent: Record<string, (event?: any) => void> = {
|
|
|
252
246
|
openReadDialog:(scope: any) => {
|
|
253
247
|
request.flameApi.singleSearch({
|
|
254
248
|
tableName: safeTableName.value,
|
|
255
|
-
data: { key: scope.row.flame_id
|
|
249
|
+
data: { key: scope.row.flame_id }
|
|
256
250
|
})
|
|
257
251
|
.then(({ items }: any) => {
|
|
258
252
|
reportPageConfig.value.readForm['model'] = items
|
|
@@ -294,63 +288,6 @@ const pageDefaultEvent: Record<string, (event?: any) => void> = {
|
|
|
294
288
|
pageDefaultEvent.closeAddDialog()
|
|
295
289
|
})
|
|
296
290
|
},
|
|
297
|
-
// 页面导入
|
|
298
|
-
pageImport:() => {
|
|
299
|
-
const inputFile: any = document.createElement('input')
|
|
300
|
-
inputFile.type = 'file'
|
|
301
|
-
inputFile.style.display = 'none'
|
|
302
|
-
document.body.appendChild(inputFile)
|
|
303
|
-
inputFile.click()
|
|
304
|
-
inputFile.addEventListener('change', () => {
|
|
305
|
-
const file = inputFile.files[0]
|
|
306
|
-
var fileType = file.name.substring(file.name.lastIndexOf('.') + 1)
|
|
307
|
-
if (!['xls', 'xlsx', 'et'].includes(fileType)) {
|
|
308
|
-
ElMessage.warning('请上传 xls、xlsx、et 格式的文件!')
|
|
309
|
-
document.body.removeChild(inputFile)
|
|
310
|
-
return false
|
|
311
|
-
}
|
|
312
|
-
const formData = new FormData()
|
|
313
|
-
formData.append("file", file)
|
|
314
|
-
request.flameAxios({
|
|
315
|
-
headers: { 'Content-Type': 'multipart/form-data' },
|
|
316
|
-
method: 'post',
|
|
317
|
-
url: `/resource-service/upload_file?source=mongo&token=${request.token}`,
|
|
318
|
-
data: formData
|
|
319
|
-
})
|
|
320
|
-
.then(({ key: code }: any) => {
|
|
321
|
-
request.flameRequest({
|
|
322
|
-
tableName: safeTableName.value,
|
|
323
|
-
flameMethod: 'importfile',
|
|
324
|
-
data: { code }
|
|
325
|
-
})
|
|
326
|
-
.then((res: any) => {
|
|
327
|
-
if(res.result){
|
|
328
|
-
ElMessage.success('导入成功!')
|
|
329
|
-
pageRefresh()
|
|
330
|
-
}
|
|
331
|
-
else{
|
|
332
|
-
ElMessage.error(res.message)
|
|
333
|
-
}
|
|
334
|
-
})
|
|
335
|
-
})
|
|
336
|
-
.finally(() => document.body.removeChild(inputFile))
|
|
337
|
-
})
|
|
338
|
-
},
|
|
339
|
-
// 页面导出
|
|
340
|
-
pageExport:() => {
|
|
341
|
-
request.flameApi.exportFile({
|
|
342
|
-
tableName: safeTableName.value,
|
|
343
|
-
data: {
|
|
344
|
-
conditions: searchParams.value,
|
|
345
|
-
ref_level: 1,
|
|
346
|
-
order_by: "flame_id DESC"
|
|
347
|
-
}
|
|
348
|
-
})
|
|
349
|
-
.then(({ items }: any) => {
|
|
350
|
-
window.open(items.download_url)
|
|
351
|
-
ElMessage.success('导出成功')
|
|
352
|
-
})
|
|
353
|
-
},
|
|
354
291
|
// 页面删除
|
|
355
292
|
pageDelete:(scope: any) => {
|
|
356
293
|
ElMessageBox.confirm(
|
|
@@ -1,12 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
* @Author: 关羽 xiaobing525@163.com
|
|
3
|
-
* @Date: 2023-01-04 22:32:16
|
|
4
|
-
* @LastEditors: 关羽 xiaobing525@163.com
|
|
5
|
-
* @LastEditTime: 2023-01-05 19:54:43
|
|
6
|
-
* @FilePath: /flame-components/packages/model/flmComponentConfig/complex/flmSearch.ts
|
|
7
|
-
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
|
|
8
|
-
*/
|
|
9
|
-
import { FormConfig } from '../../../model/flmComponentConfig'
|
|
1
|
+
import { FormConfig } from '@/model/flmComponentConfig'
|
|
10
2
|
|
|
11
3
|
export interface SearchConfig extends FormConfig {
|
|
12
4
|
maxFormItem?: number
|
|
@@ -1,14 +1,5 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* @Author: 关羽 xiaobing525@163.com
|
|
3
|
-
* @Date: 2023-01-04 22:32:16
|
|
4
|
-
* @LastEditors: 关羽 xiaobing525@163.com
|
|
5
|
-
* @LastEditTime: 2023-01-11 21:37:39
|
|
6
|
-
* @FilePath: /flame-components/packages/model/flmComponentConfig/page/flmReportPage.ts
|
|
7
|
-
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
|
|
8
|
-
*/
|
|
9
1
|
import {
|
|
10
2
|
FormConfig,
|
|
11
|
-
SearchConfig,
|
|
12
3
|
ToolbarConfig,
|
|
13
4
|
TableConfig,
|
|
14
5
|
PaginationConfig,
|
|
@@ -17,7 +8,7 @@ import {
|
|
|
17
8
|
|
|
18
9
|
// 报表页面设置
|
|
19
10
|
export interface ReportPageSetting {
|
|
20
|
-
'search':
|
|
11
|
+
'search': FormConfig
|
|
21
12
|
'toolbar': ToolbarConfig
|
|
22
13
|
'table': TableConfig
|
|
23
14
|
'tableAction': ToolbarConfig
|