@bsgoal/common 2.16.6 → 2.17.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.mjs +1815 -1695
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +9 -9
- package/dist/index.umd.js.map +1 -1
- package/dist/style.css +1 -1
- package/package.json +2 -3
- package/src/App.vue +0 -9
- package/src/combines/useComs.js +0 -41
- package/src/combines/useFetchs.js +0 -55
- package/src/components/bsgoal-baes-popover/demo.vue +0 -35
- package/src/components/bsgoal-baes-popover/index.vue +0 -66
- package/src/components/bsgoal-base-alert/demo.vue +0 -39
- package/src/components/bsgoal-base-alert/index.vue +0 -49
- package/src/components/bsgoal-base-button/demo.vue +0 -54
- package/src/components/bsgoal-base-button/index.vue +0 -166
- package/src/components/bsgoal-base-cascader/demo.vue +0 -128
- package/src/components/bsgoal-base-cascader/index.vue +0 -95
- package/src/components/bsgoal-base-dialog/demo.vue +0 -350
- package/src/components/bsgoal-base-dialog/index.vue +0 -260
- package/src/components/bsgoal-base-form/demo.vue +0 -290
- package/src/components/bsgoal-base-form/index.vue +0 -732
- package/src/components/bsgoal-base-frame/demo.vue +0 -35
- package/src/components/bsgoal-base-frame/index.vue +0 -28
- package/src/components/bsgoal-base-input/demo.vue +0 -48
- package/src/components/bsgoal-base-input/index.vue +0 -174
- package/src/components/bsgoal-base-item/demo.vue +0 -46
- package/src/components/bsgoal-base-item/index.vue +0 -66
- package/src/components/bsgoal-base-layout/demo.vue +0 -48
- package/src/components/bsgoal-base-layout/index.vue +0 -57
- package/src/components/bsgoal-base-line/demo.vue +0 -41
- package/src/components/bsgoal-base-line/index.vue +0 -70
- package/src/components/bsgoal-base-link/demo.vue +0 -38
- package/src/components/bsgoal-base-link/index.vue +0 -73
- package/src/components/bsgoal-base-search/demo.vue +0 -215
- package/src/components/bsgoal-base-search/index.vue +0 -534
- package/src/components/bsgoal-base-search-operation/index.vue +0 -77
- package/src/components/bsgoal-base-search-table/demo.vue +0 -784
- package/src/components/bsgoal-base-search-table/index.vue +0 -291
- package/src/components/bsgoal-base-select/demo.vue +0 -71
- package/src/components/bsgoal-base-select/index.vue +0 -111
- package/src/components/bsgoal-base-sizes/demo.vue +0 -34
- package/src/components/bsgoal-base-sizes/index.vue +0 -178
- package/src/components/bsgoal-base-switch/demo.vue +0 -39
- package/src/components/bsgoal-base-switch/index.vue +0 -76
- package/src/components/bsgoal-base-table/demo.vue +0 -302
- package/src/components/bsgoal-base-table/index.vue +0 -461
- package/src/components/bsgoal-base-table-content/index.vue +0 -64
- package/src/components/bsgoal-base-table-empty/demo.vue +0 -37
- package/src/components/bsgoal-base-table-empty/index.vue +0 -48
- package/src/components/bsgoal-base-table-pagination/demo.vue +0 -35
- package/src/components/bsgoal-base-table-pagination/index.vue +0 -110
- package/src/components/bsgoal-base-tabs/debug.log +0 -1
- package/src/components/bsgoal-base-tabs/demo.vue +0 -65
- package/src/components/bsgoal-base-tabs/index.vue +0 -122
- package/src/components/bsgoal-base-time/demo.vue +0 -69
- package/src/components/bsgoal-base-time/index.vue +0 -177
- package/src/components/bsgoal-base-time-range/demo.vue +0 -62
- package/src/components/bsgoal-base-time-range/index.vue +0 -170
- package/src/components/bsgoal-base-tooltip/demo.vue +0 -38
- package/src/components/bsgoal-base-tooltip/index.vue +0 -103
- package/src/components/bsgoal-base-tree/demo.vue +0 -141
- package/src/components/bsgoal-base-tree/index.vue +0 -286
- package/src/components/bsgoal-base-tree-fold/index.vue +0 -64
- package/src/components/bsgoal-base-tree-table/debug.log +0 -1
- package/src/components/bsgoal-base-tree-table/demo.vue +0 -859
- package/src/components/bsgoal-base-tree-table/index.vue +0 -351
- package/src/components/bsgoal-base-viewer/assets/upload_default.svg +0 -13
- package/src/components/bsgoal-base-viewer/demo.vue +0 -35
- package/src/components/bsgoal-base-viewer/index.vue +0 -66
- package/src/components/layout/layout-home.vue +0 -60
- package/src/components/layout/layout-left-menu.vue +0 -54
- package/src/components/layout/layout-right-container.vue +0 -39
- package/src/components/layout/layout-top-header.vue +0 -38
- package/src/debug.log +0 -1
- package/src/directives/directiveBase.js +0 -96
- package/src/entry.js +0 -77
- package/src/enums/componentTypeEnums.js +0 -35
- package/src/main.js +0 -11
- package/src/router/index.js +0 -161
- package/src/styles/index.css +0 -14
- package/src/utils/common.js +0 -56
|
@@ -1,732 +0,0 @@
|
|
|
1
|
-
<!--
|
|
2
|
-
* @Author: canlong.shen
|
|
3
|
-
* @Date: 2023-04-17 11:44:29
|
|
4
|
-
* @LastEditors: canlong.shen
|
|
5
|
-
* @LastEditTime: 2023-07-12 14:33:02
|
|
6
|
-
* @FilePath: \common\src\components\bsgoal-base-form\index.vue
|
|
7
|
-
* @Description: 表单公共组件
|
|
8
|
-
*
|
|
9
|
-
-->
|
|
10
|
-
|
|
11
|
-
<script setup>
|
|
12
|
-
/* setup模板
|
|
13
|
-
---------------------------------------------------------------- */
|
|
14
|
-
import { ref, computed, unref, watchEffect, watch } from 'vue'
|
|
15
|
-
import ComponentTypeEnums from '../../enums/componentTypeEnums.js'
|
|
16
|
-
import baseDirective from '../../directives/directiveBase.js'
|
|
17
|
-
import BsgoalBaseTooltip from '../bsgoal-base-tooltip/index.vue'
|
|
18
|
-
import { ElMessage } from 'element-plus'
|
|
19
|
-
import { isObject } from '../../utils/common.js'
|
|
20
|
-
import { isBoolean } from 'lodash'
|
|
21
|
-
|
|
22
|
-
defineOptions({
|
|
23
|
-
name: 'BsgoalBaseForm'
|
|
24
|
-
})
|
|
25
|
-
|
|
26
|
-
const props = defineProps({
|
|
27
|
-
/**
|
|
28
|
-
* >----------props----------<
|
|
29
|
-
* {
|
|
30
|
-
* label:'' // 名称
|
|
31
|
-
* value:'' // 值
|
|
32
|
-
* prop:'' // 绑定字段
|
|
33
|
-
* type:'text' // 内容组件的类型 : 参照 componentTypeEnums
|
|
34
|
-
* placeholder:'' // placeholder 提示文本
|
|
35
|
-
* readonly: false // 是否为只读文本
|
|
36
|
-
* clearable: true //是否为可清空
|
|
37
|
-
* }
|
|
38
|
-
*
|
|
39
|
-
* >----------events----------<
|
|
40
|
-
*
|
|
41
|
-
* on-form // 触发查询
|
|
42
|
-
* on-clear // 触发清空
|
|
43
|
-
* on-change // 触发查询变动
|
|
44
|
-
* on-fold // 触发折叠
|
|
45
|
-
*/
|
|
46
|
-
configOptions: {
|
|
47
|
-
type: [Array],
|
|
48
|
-
default: () => []
|
|
49
|
-
},
|
|
50
|
-
/**
|
|
51
|
-
* 中屏设备宽度的比例
|
|
52
|
-
*/
|
|
53
|
-
medium: {
|
|
54
|
-
type: [Number, String],
|
|
55
|
-
default: 24
|
|
56
|
-
},
|
|
57
|
-
/**
|
|
58
|
-
* 初始值
|
|
59
|
-
*/
|
|
60
|
-
values: {
|
|
61
|
-
type: [Object],
|
|
62
|
-
default: () => ({})
|
|
63
|
-
},
|
|
64
|
-
/**
|
|
65
|
-
* 全局字数限制
|
|
66
|
-
*/
|
|
67
|
-
limits: {
|
|
68
|
-
type: [Number],
|
|
69
|
-
default: 0
|
|
70
|
-
},
|
|
71
|
-
/**
|
|
72
|
-
* 全局只读
|
|
73
|
-
*/
|
|
74
|
-
readonlys: {
|
|
75
|
-
type: [Boolean],
|
|
76
|
-
default: false
|
|
77
|
-
},
|
|
78
|
-
/**
|
|
79
|
-
* 空字段 默认值
|
|
80
|
-
*/
|
|
81
|
-
none: {
|
|
82
|
-
type: [String],
|
|
83
|
-
default: '无'
|
|
84
|
-
},
|
|
85
|
-
/**
|
|
86
|
-
* 绑定的 mdel
|
|
87
|
-
*/
|
|
88
|
-
bindModel: {
|
|
89
|
-
type: [Object],
|
|
90
|
-
default: () => ({})
|
|
91
|
-
},
|
|
92
|
-
/**
|
|
93
|
-
* label 位置
|
|
94
|
-
*/
|
|
95
|
-
labelPosition: {
|
|
96
|
-
type: [String],
|
|
97
|
-
default: 'right',
|
|
98
|
-
validator: (v) => ['left', 'rightn', 'top'].includes(v)
|
|
99
|
-
},
|
|
100
|
-
/**
|
|
101
|
-
* base_form 绑定的 style 对象
|
|
102
|
-
*/
|
|
103
|
-
styler: {
|
|
104
|
-
type: [Object],
|
|
105
|
-
default: () => ({})
|
|
106
|
-
},
|
|
107
|
-
/**
|
|
108
|
-
* el_form_item 绑定的 style 对象
|
|
109
|
-
*/
|
|
110
|
-
itemStyler: {
|
|
111
|
-
type: [Object],
|
|
112
|
-
default: () => ({})
|
|
113
|
-
},
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* 紧凑型
|
|
117
|
-
*/
|
|
118
|
-
compact: {
|
|
119
|
-
type: [Boolean],
|
|
120
|
-
default: false
|
|
121
|
-
},
|
|
122
|
-
/**
|
|
123
|
-
* 失效
|
|
124
|
-
*/
|
|
125
|
-
disabled: {
|
|
126
|
-
type: [Boolean],
|
|
127
|
-
default: false
|
|
128
|
-
}
|
|
129
|
-
})
|
|
130
|
-
|
|
131
|
-
// emits
|
|
132
|
-
const emits = defineEmits(['on-form', 'on-clear', 'on-change', 'on-fold'])
|
|
133
|
-
|
|
134
|
-
// el-from 的引用
|
|
135
|
-
const EL_FORM_REF = ref(null)
|
|
136
|
-
|
|
137
|
-
// 自定义指令
|
|
138
|
-
const vAlign = baseDirective.align
|
|
139
|
-
|
|
140
|
-
const model = ref()
|
|
141
|
-
const watchPropList = []
|
|
142
|
-
|
|
143
|
-
// ---> S 初始值 <---
|
|
144
|
-
|
|
145
|
-
watchEffect(() => {
|
|
146
|
-
const { bindModel = {} } = props
|
|
147
|
-
model.value = bindModel
|
|
148
|
-
})
|
|
149
|
-
|
|
150
|
-
/**
|
|
151
|
-
* @Author: canlong.shen
|
|
152
|
-
* @description:
|
|
153
|
-
* @default:
|
|
154
|
-
* @return {*}
|
|
155
|
-
*/
|
|
156
|
-
const watchPropsForShow = (show = {}, model = {}, prop = '') => {
|
|
157
|
-
// { prop1:[1,2,3] , prop2: [4,5,6] }
|
|
158
|
-
watchEffect(() => {
|
|
159
|
-
const resultList = []
|
|
160
|
-
for (const [name = '', values = []] of Object.entries(show)) {
|
|
161
|
-
resultList.push(values.includes(`${model[name]}`))
|
|
162
|
-
}
|
|
163
|
-
const { configOptions } = props
|
|
164
|
-
const options = unref(configOptions)
|
|
165
|
-
const findProp = options.find((fi) => fi.prop === prop)
|
|
166
|
-
if (resultList.every((ei) => !!ei)) {
|
|
167
|
-
findProp.visible = true
|
|
168
|
-
} else {
|
|
169
|
-
findProp.visible = false
|
|
170
|
-
}
|
|
171
|
-
})
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
/**
|
|
175
|
-
* @Author: canlong.shen
|
|
176
|
-
* @description: 绑定的对象
|
|
177
|
-
* @param {*} computed
|
|
178
|
-
* @default:
|
|
179
|
-
* @return {*} model
|
|
180
|
-
*/
|
|
181
|
-
watchEffect(() => {
|
|
182
|
-
const { configOptions, values } = props
|
|
183
|
-
const options = unref(configOptions)
|
|
184
|
-
const valuesModel = unref(values)
|
|
185
|
-
options.forEach((fei) => {
|
|
186
|
-
const { value = '', prop = '', type = '', show = null } = fei
|
|
187
|
-
if (![ComponentTypeEnums.INPUT, ComponentTypeEnums.INPUT_TEXT_AREA].includes(type)) {
|
|
188
|
-
watchPropList.push(prop)
|
|
189
|
-
}
|
|
190
|
-
const bindValue = model.value[prop]
|
|
191
|
-
if (prop.startsWith('_')) {
|
|
192
|
-
model.value[prop] = `${prop}`
|
|
193
|
-
} else {
|
|
194
|
-
model.value[prop] = bindValue || valuesModel[prop] || value
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
if (isObject(show)) {
|
|
198
|
-
watchPropsForShow(show, unref(model), prop)
|
|
199
|
-
}
|
|
200
|
-
})
|
|
201
|
-
})
|
|
202
|
-
|
|
203
|
-
// ---> E 初始值 <---
|
|
204
|
-
|
|
205
|
-
/**
|
|
206
|
-
* @Author: canlong.shen
|
|
207
|
-
* @description: 配置项
|
|
208
|
-
* @param {*} computed
|
|
209
|
-
* @default:
|
|
210
|
-
* @return {*}
|
|
211
|
-
*/
|
|
212
|
-
const configOptionsGet = computed(() => {
|
|
213
|
-
const { configOptions } = props
|
|
214
|
-
const options = unref(configOptions)
|
|
215
|
-
const reOptions = options.map((option) => {
|
|
216
|
-
let { rules = [], label = '', prop = '' } = option
|
|
217
|
-
const requiredRule = { required: true, message: `${label}不能为空`, trigger: 'blur' }
|
|
218
|
-
if (isBoolean(rules) && rules) {
|
|
219
|
-
rules = [requiredRule]
|
|
220
|
-
} else if (Array.isArray(rules) && !!rules.length) {
|
|
221
|
-
rules = [requiredRule, ...rules]
|
|
222
|
-
}
|
|
223
|
-
option.rules = rules
|
|
224
|
-
return option
|
|
225
|
-
})
|
|
226
|
-
return reOptions
|
|
227
|
-
})
|
|
228
|
-
|
|
229
|
-
/**
|
|
230
|
-
* @Author: canlong.shen
|
|
231
|
-
* @description: 设置 placeholder
|
|
232
|
-
* @param {*} type
|
|
233
|
-
* @param {*} placeholder
|
|
234
|
-
* @default:
|
|
235
|
-
* @return {*}
|
|
236
|
-
*/
|
|
237
|
-
const placeholderSet = (type = '', label = '', placeholder = '') => {
|
|
238
|
-
if (!placeholder) {
|
|
239
|
-
switch (type) {
|
|
240
|
-
case ComponentTypeEnums.INPUT:
|
|
241
|
-
case ComponentTypeEnums.INPUT_TEXT_AREA:
|
|
242
|
-
return `请输入${label}`
|
|
243
|
-
case ComponentTypeEnums.SELECT:
|
|
244
|
-
case ComponentTypeEnums.DATE:
|
|
245
|
-
case ComponentTypeEnums.WEEK:
|
|
246
|
-
case ComponentTypeEnums.MONTH:
|
|
247
|
-
case ComponentTypeEnums.YEAR:
|
|
248
|
-
case ComponentTypeEnums.DATE_TIME:
|
|
249
|
-
case ComponentTypeEnums.TIME:
|
|
250
|
-
return `请选择${label}`
|
|
251
|
-
case ComponentTypeEnums.DATE_RANGE:
|
|
252
|
-
case ComponentTypeEnums.DATE_TIME_RANGE:
|
|
253
|
-
return ['开始日期', '结束日期']
|
|
254
|
-
case ComponentTypeEnums.TIME_RANGE:
|
|
255
|
-
return ['开始时间', '结束时间']
|
|
256
|
-
case ComponentTypeEnums.MONTH_RANGE:
|
|
257
|
-
return ['开始月份', '结束月份']
|
|
258
|
-
default:
|
|
259
|
-
break
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
return placeholder
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
/**
|
|
267
|
-
* @Author: canlong.shen
|
|
268
|
-
* @description: 时间格式
|
|
269
|
-
* @param {*} type
|
|
270
|
-
* @param {*} format
|
|
271
|
-
* @default:
|
|
272
|
-
* @return {*}
|
|
273
|
-
*/
|
|
274
|
-
const formatSet = (type = '', format = '') => {
|
|
275
|
-
if (!format) {
|
|
276
|
-
switch (type) {
|
|
277
|
-
case ComponentTypeEnums.WEEK:
|
|
278
|
-
return 'ww'
|
|
279
|
-
case ComponentTypeEnums.DATE:
|
|
280
|
-
case ComponentTypeEnums.DATE_RANGE:
|
|
281
|
-
return 'YYYY-MM-DD'
|
|
282
|
-
case ComponentTypeEnums.MONTH:
|
|
283
|
-
return 'MM'
|
|
284
|
-
case ComponentTypeEnums.YEAR:
|
|
285
|
-
return 'YYYY'
|
|
286
|
-
case ComponentTypeEnums.MONTH_RANGE:
|
|
287
|
-
return 'YYYY-MM'
|
|
288
|
-
case ComponentTypeEnums.TIME:
|
|
289
|
-
case ComponentTypeEnums.TIME_RANGE:
|
|
290
|
-
return 'HH:mm:ss'
|
|
291
|
-
case ComponentTypeEnums.DATE_TIME:
|
|
292
|
-
case ComponentTypeEnums.DATE_TIME_RANGE:
|
|
293
|
-
return 'YYYY-MM-DD HH:mm:ss'
|
|
294
|
-
default:
|
|
295
|
-
break
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
return format
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
/**
|
|
303
|
-
* @Author: canlong.shen
|
|
304
|
-
* @description: 触发查询
|
|
305
|
-
* @default:
|
|
306
|
-
* @return {*}
|
|
307
|
-
*/
|
|
308
|
-
const triggerOperationForm = () => {
|
|
309
|
-
const modelValue = unref(model)
|
|
310
|
-
const { configOptions } = props
|
|
311
|
-
const options = unref(configOptions)
|
|
312
|
-
for (const option of options) {
|
|
313
|
-
const { type = '', range = [], prop = '' } = option
|
|
314
|
-
if (type.endsWith('range') && range && range.length === 2) {
|
|
315
|
-
const { 0: startValue = '', 1: endValue = '' } = modelValue[prop]
|
|
316
|
-
const { 0: startProp = '', 1: endProp = '' } = range
|
|
317
|
-
modelValue[startProp] = startValue
|
|
318
|
-
modelValue[endProp] = endValue
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
emits('on-form', modelValue)
|
|
322
|
-
return modelValue
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
/**
|
|
326
|
-
* @Author: canlong.shen
|
|
327
|
-
* @description: 触发清空
|
|
328
|
-
* @default:
|
|
329
|
-
* @return {*}
|
|
330
|
-
*/
|
|
331
|
-
const triggerOperationClear = () => {
|
|
332
|
-
EL_FORM_REF.value.resetFields()
|
|
333
|
-
emits('on-clear', model.value)
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
/**
|
|
337
|
-
* @Author: canlong.shen
|
|
338
|
-
* @description: 触发 值 变化
|
|
339
|
-
* @param {*} type
|
|
340
|
-
* @param {*} prop
|
|
341
|
-
* @default:
|
|
342
|
-
* @return {*}
|
|
343
|
-
*/
|
|
344
|
-
const triggerValueChange = (type, prop) => {
|
|
345
|
-
// 触发查询
|
|
346
|
-
const emitValue = {
|
|
347
|
-
type,
|
|
348
|
-
prop,
|
|
349
|
-
value: model.value[prop] || ''
|
|
350
|
-
}
|
|
351
|
-
emits('on-change', emitValue)
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
/**
|
|
355
|
-
* @Author: canlong.shen
|
|
356
|
-
* @description: 过滤掉插槽字段
|
|
357
|
-
* @default:
|
|
358
|
-
* @return {*}
|
|
359
|
-
*/
|
|
360
|
-
const filterSlotProps = (model = {}) => {
|
|
361
|
-
const rebuildModel = {}
|
|
362
|
-
for (const prop of Object.keys(model)) {
|
|
363
|
-
if (!prop.startsWith('_')) {
|
|
364
|
-
const value = model[prop]
|
|
365
|
-
const valueInt = Number.parseFloat(value)
|
|
366
|
-
rebuildModel[prop] =
|
|
367
|
-
(valueInt || ['0', 0].includes(value)) && !/^0.+/i.test(`${value}`) ? valueInt : value
|
|
368
|
-
}
|
|
369
|
-
}
|
|
370
|
-
return rebuildModel
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
/**
|
|
374
|
-
* @Author: canlong.shen
|
|
375
|
-
* @description: 表单校验
|
|
376
|
-
* @default:
|
|
377
|
-
* @return {*}
|
|
378
|
-
*/
|
|
379
|
-
const validateForm = (callback = () => {}) => {
|
|
380
|
-
EL_FORM_REF.value.validate((valid = false, field = {}) => {
|
|
381
|
-
if (valid) {
|
|
382
|
-
const validModel = triggerOperationForm()
|
|
383
|
-
const cleanModel = filterSlotProps(validModel)
|
|
384
|
-
callback(cleanModel)
|
|
385
|
-
} else {
|
|
386
|
-
callback(false)
|
|
387
|
-
|
|
388
|
-
const firstProp = Object.keys(field)[0]
|
|
389
|
-
const {
|
|
390
|
-
[firstProp]: {
|
|
391
|
-
0: { message = '' }
|
|
392
|
-
}
|
|
393
|
-
} = field
|
|
394
|
-
ElMessage.error(message)
|
|
395
|
-
}
|
|
396
|
-
})
|
|
397
|
-
}
|
|
398
|
-
|
|
399
|
-
// ---> S switch active/inactive 的设置 <---
|
|
400
|
-
|
|
401
|
-
/**
|
|
402
|
-
* @Author: canlong.shen
|
|
403
|
-
* @description: 设置 active 值
|
|
404
|
-
* @param {*} range 入参
|
|
405
|
-
* @param {*} type 'active' / 'inactive'
|
|
406
|
-
* @default:
|
|
407
|
-
* @return {*}
|
|
408
|
-
*/
|
|
409
|
-
const setActiveValueText = (range = [], type = '') => {
|
|
410
|
-
const { 0: startOption = {}, 1: endOption = {} } = range
|
|
411
|
-
const { value: startValue = false, label: startText = '' } = startOption
|
|
412
|
-
const { value: endValue = false, label: endText = '' } = endOption
|
|
413
|
-
|
|
414
|
-
switch (type) {
|
|
415
|
-
case 'active-value':
|
|
416
|
-
return startValue
|
|
417
|
-
case 'inactive-value':
|
|
418
|
-
return endValue
|
|
419
|
-
case 'active-text':
|
|
420
|
-
return startText
|
|
421
|
-
case 'inactive-text':
|
|
422
|
-
return endText
|
|
423
|
-
default:
|
|
424
|
-
break
|
|
425
|
-
}
|
|
426
|
-
}
|
|
427
|
-
|
|
428
|
-
// ---> E switch active/inactive 的设置 <---
|
|
429
|
-
|
|
430
|
-
// ---> S styles <---
|
|
431
|
-
const colStyle = computed(() => {
|
|
432
|
-
const styler = {}
|
|
433
|
-
const { compact = false } = props
|
|
434
|
-
if (compact) {
|
|
435
|
-
styler.marginBottom = '0px'
|
|
436
|
-
}
|
|
437
|
-
return styler
|
|
438
|
-
})
|
|
439
|
-
const itemStyle = computed(() => {
|
|
440
|
-
const styler = {}
|
|
441
|
-
const { compact = false, itemStyler = {} } = props
|
|
442
|
-
if (compact) {
|
|
443
|
-
styler.marginBottom = '0px'
|
|
444
|
-
}
|
|
445
|
-
|
|
446
|
-
return { ...styler, ...itemStyler }
|
|
447
|
-
})
|
|
448
|
-
|
|
449
|
-
// ---> E styles <---
|
|
450
|
-
|
|
451
|
-
defineExpose({
|
|
452
|
-
triggerOperationClear,
|
|
453
|
-
triggerOperationForm,
|
|
454
|
-
validateForm,
|
|
455
|
-
resetFields: triggerOperationClear
|
|
456
|
-
})
|
|
457
|
-
</script>
|
|
458
|
-
<template>
|
|
459
|
-
<div class="bsgoal-base-form">
|
|
460
|
-
<div class="base_form" :style="styler">
|
|
461
|
-
<!-- / 表单内容 -->
|
|
462
|
-
<el-form
|
|
463
|
-
ref="EL_FORM_REF"
|
|
464
|
-
label-suffix=":"
|
|
465
|
-
style="padding: 0px"
|
|
466
|
-
:disabled="disabled"
|
|
467
|
-
:label-position="labelPosition"
|
|
468
|
-
:model="model"
|
|
469
|
-
v-align
|
|
470
|
-
>
|
|
471
|
-
<el-row>
|
|
472
|
-
<template
|
|
473
|
-
v-for="(
|
|
474
|
-
{
|
|
475
|
-
md = 0,
|
|
476
|
-
label = '',
|
|
477
|
-
prop = '',
|
|
478
|
-
type = 'text',
|
|
479
|
-
placeholder = '',
|
|
480
|
-
readonly = readonlys,
|
|
481
|
-
clearable = true,
|
|
482
|
-
rows = 2,
|
|
483
|
-
min = 1,
|
|
484
|
-
max = 10,
|
|
485
|
-
range = [],
|
|
486
|
-
format = '',
|
|
487
|
-
rules = [],
|
|
488
|
-
limit = limits,
|
|
489
|
-
length = 255,
|
|
490
|
-
visible = true,
|
|
491
|
-
multiple = false,
|
|
492
|
-
formatter = (v) => {
|
|
493
|
-
return v
|
|
494
|
-
},
|
|
495
|
-
parser = (v) => {
|
|
496
|
-
return v
|
|
497
|
-
}
|
|
498
|
-
} = {},
|
|
499
|
-
key
|
|
500
|
-
) of configOptionsGet"
|
|
501
|
-
:key="key"
|
|
502
|
-
>
|
|
503
|
-
<el-col
|
|
504
|
-
:class="{ 'base_form--visible': !visible }"
|
|
505
|
-
:xs="24"
|
|
506
|
-
:sm="24"
|
|
507
|
-
:md="md || medium"
|
|
508
|
-
:style="colStyle"
|
|
509
|
-
>
|
|
510
|
-
<el-form-item :style="itemStyle" :label="label" :prop="prop" :rules="rules">
|
|
511
|
-
<slot :name="[prop]" :option="{ readonly, value: model[prop], values: model }">
|
|
512
|
-
<!-- S 内容组件 -->
|
|
513
|
-
<template v-if="!readonly">
|
|
514
|
-
<!-- / input 输入框组件 -->
|
|
515
|
-
<template v-if="type === ComponentTypeEnums.INPUT">
|
|
516
|
-
<el-input
|
|
517
|
-
v-model="model[prop]"
|
|
518
|
-
:placeholder="placeholderSet(type, label, placeholder)"
|
|
519
|
-
:clearable="clearable"
|
|
520
|
-
:formatter="formatter"
|
|
521
|
-
:parser="parser"
|
|
522
|
-
@change="triggerValueChange(type, prop)"
|
|
523
|
-
/>
|
|
524
|
-
</template>
|
|
525
|
-
<!-- / input 输入框组件 -->
|
|
526
|
-
<!-- / textarea 输入框组件 -->
|
|
527
|
-
<template v-if="type === ComponentTypeEnums.INPUT_TEXT_AREA">
|
|
528
|
-
<el-input
|
|
529
|
-
v-model="model[prop]"
|
|
530
|
-
show-word-limit
|
|
531
|
-
type="textarea"
|
|
532
|
-
:autosize="{ minRows: rows }"
|
|
533
|
-
:maxlength="length"
|
|
534
|
-
:clearable="clearable"
|
|
535
|
-
:placeholder="placeholderSet(type, label, placeholder)"
|
|
536
|
-
@change="triggerValueChange(type, prop)"
|
|
537
|
-
/>
|
|
538
|
-
</template>
|
|
539
|
-
<!-- / textarea 输入框组件 -->
|
|
540
|
-
<template v-if="type === ComponentTypeEnums.INPUT_NUMBER">
|
|
541
|
-
<el-input-number
|
|
542
|
-
v-model="model[prop]"
|
|
543
|
-
controls-position="right"
|
|
544
|
-
:min="min"
|
|
545
|
-
:max="max"
|
|
546
|
-
@change="triggerValueChange"
|
|
547
|
-
/>
|
|
548
|
-
</template>
|
|
549
|
-
<!-- / 数字输入框 -->
|
|
550
|
-
|
|
551
|
-
<!-- / 单选框 -->
|
|
552
|
-
<template v-if="type === ComponentTypeEnums.RADIO">
|
|
553
|
-
<el-radio-group
|
|
554
|
-
v-model="model[prop]"
|
|
555
|
-
@change="triggerValueChange(type, prop)"
|
|
556
|
-
>
|
|
557
|
-
<template v-for="(item, itemIndex) of range" :key="itemIndex">
|
|
558
|
-
<el-radio :label="item.value">{{ item.label }}</el-radio>
|
|
559
|
-
</template>
|
|
560
|
-
</el-radio-group>
|
|
561
|
-
</template>
|
|
562
|
-
<!-- / 单选框 -->
|
|
563
|
-
<!-- / select 选择器 -->
|
|
564
|
-
<template v-if="type === ComponentTypeEnums.SELECT">
|
|
565
|
-
<el-select
|
|
566
|
-
v-model="model[prop]"
|
|
567
|
-
no-data-text="暂无数据"
|
|
568
|
-
:multiple="multiple"
|
|
569
|
-
:placeholder="placeholderSet(type, label, placeholder)"
|
|
570
|
-
@change="triggerValueChange(type, prop)"
|
|
571
|
-
>
|
|
572
|
-
<template v-for="(item, itemIndex) of range" :key="itemIndex">
|
|
573
|
-
<el-option :label="item.label" :value="item.value" />
|
|
574
|
-
</template>
|
|
575
|
-
</el-select>
|
|
576
|
-
</template>
|
|
577
|
-
<!-- / select 选择器 -->
|
|
578
|
-
<!-- / 滑块 -->
|
|
579
|
-
<template v-if="type === ComponentTypeEnums.SLIDER">
|
|
580
|
-
<el-slider
|
|
581
|
-
v-model="model[prop]"
|
|
582
|
-
:min="min"
|
|
583
|
-
:max="max"
|
|
584
|
-
@change="triggerValueChange(type, prop)"
|
|
585
|
-
/>
|
|
586
|
-
</template>
|
|
587
|
-
<!-- / 滑块 -->
|
|
588
|
-
<!-- / Switch 开关 -->
|
|
589
|
-
<template v-if="type === ComponentTypeEnums.SWITCH">
|
|
590
|
-
<el-switch
|
|
591
|
-
v-model="model[prop]"
|
|
592
|
-
:active-value="setActiveValueText(range, 'active-value')"
|
|
593
|
-
:inactive-value="setActiveValueText(range, 'inactive-value')"
|
|
594
|
-
:active-text="setActiveValueText(range, 'active-text')"
|
|
595
|
-
:inactive-text="setActiveValueText(range, 'inactive-text')"
|
|
596
|
-
@change="triggerValueChange(type, prop)"
|
|
597
|
-
/>
|
|
598
|
-
</template>
|
|
599
|
-
<!-- / Switch 开关 -->
|
|
600
|
-
<!-- / 日期选择器 -->
|
|
601
|
-
<template
|
|
602
|
-
v-if="
|
|
603
|
-
[
|
|
604
|
-
ComponentTypeEnums.DATE,
|
|
605
|
-
ComponentTypeEnums.MONTH,
|
|
606
|
-
ComponentTypeEnums.YEAR,
|
|
607
|
-
ComponentTypeEnums.DATE_TIME
|
|
608
|
-
].includes(type)
|
|
609
|
-
"
|
|
610
|
-
>
|
|
611
|
-
<el-date-picker
|
|
612
|
-
v-model="model[prop]"
|
|
613
|
-
:format="formatSet(type, format)"
|
|
614
|
-
:value-format="formatSet(type, format)"
|
|
615
|
-
:type="type"
|
|
616
|
-
:placeholder="placeholderSet(type, label, placeholder)"
|
|
617
|
-
@change="triggerValueChange(type, prop)"
|
|
618
|
-
/>
|
|
619
|
-
</template>
|
|
620
|
-
<!-- / 日期选择器 -->
|
|
621
|
-
<!-- / 日期时间区域选择器 -->
|
|
622
|
-
<template
|
|
623
|
-
v-if="
|
|
624
|
-
[
|
|
625
|
-
ComponentTypeEnums.DATE_RANGE,
|
|
626
|
-
ComponentTypeEnums.MONTH_RANGE,
|
|
627
|
-
ComponentTypeEnums.DATE_TIME_RANGE
|
|
628
|
-
].includes(type)
|
|
629
|
-
"
|
|
630
|
-
>
|
|
631
|
-
<el-date-picker
|
|
632
|
-
v-model="model[prop]"
|
|
633
|
-
:type="type"
|
|
634
|
-
:value-format="formatSet(type, format)"
|
|
635
|
-
:start-placeholder="placeholderSet(type, label, placeholder)[0]"
|
|
636
|
-
:end-placeholder="placeholderSet(type, label, placeholder)[1]"
|
|
637
|
-
@change="triggerValueChange(type, prop)"
|
|
638
|
-
/>
|
|
639
|
-
</template>
|
|
640
|
-
<!-- / 日期时间区域选择器 -->
|
|
641
|
-
<!-- / 时间选择器 -->
|
|
642
|
-
<template v-if="[ComponentTypeEnums.TIME].includes(type)">
|
|
643
|
-
<el-time-picker
|
|
644
|
-
v-model="model[prop]"
|
|
645
|
-
arrow-control
|
|
646
|
-
:value-format="formatSet(type, format)"
|
|
647
|
-
:placeholder="placeholderSet(type, label, placeholder)"
|
|
648
|
-
@change="triggerValueChange(type, prop)"
|
|
649
|
-
/>
|
|
650
|
-
</template>
|
|
651
|
-
<!-- / 时间选择器 -->
|
|
652
|
-
<!-- / 时间区域选择器 -->
|
|
653
|
-
<template v-if="[ComponentTypeEnums.TIME_RANGE].includes(type)">
|
|
654
|
-
<el-time-picker
|
|
655
|
-
v-model="model[prop]"
|
|
656
|
-
is-range
|
|
657
|
-
:value-format="formatSet(type, format)"
|
|
658
|
-
:start-placeholder="placeholderSet(type, label, placeholder)[0]"
|
|
659
|
-
:end-placeholder="placeholderSet(type, label, placeholder)[1]"
|
|
660
|
-
@change="triggerValueChange(type, prop)"
|
|
661
|
-
/>
|
|
662
|
-
</template>
|
|
663
|
-
<!-- / 时间区域选择器 -->
|
|
664
|
-
<!-- / 复选框 -->
|
|
665
|
-
<template v-if="[ComponentTypeEnums.CHECKBOX].includes(type)">
|
|
666
|
-
<el-checkbox-group
|
|
667
|
-
v-model="model[prop]"
|
|
668
|
-
@change="triggerValueChange(type, prop)"
|
|
669
|
-
>
|
|
670
|
-
<template v-for="(item, itemIndex) of range" :key="itemIndex">
|
|
671
|
-
<el-checkbox :label="item.value">{{ item.label }}</el-checkbox>
|
|
672
|
-
</template>
|
|
673
|
-
</el-checkbox-group>
|
|
674
|
-
</template>
|
|
675
|
-
<!-- / 复选框 -->
|
|
676
|
-
<!-- / 复选框单选 -->
|
|
677
|
-
<template v-if="[ComponentTypeEnums.CHECKBOX_SINGLE].includes(type)">
|
|
678
|
-
<el-checkbox
|
|
679
|
-
v-model="model[prop]"
|
|
680
|
-
:true-label="range[0] ? range[0].value : '1'"
|
|
681
|
-
:false-label="range[1] ? range[1].value : '0'"
|
|
682
|
-
@change="triggerValueChange(type, prop)"
|
|
683
|
-
/>
|
|
684
|
-
</template>
|
|
685
|
-
<!-- / 复选框单选 -->
|
|
686
|
-
<!-- / 模板 -->
|
|
687
|
-
<template v-if="[].includes(type)"> </template>
|
|
688
|
-
<!-- / 模板 -->
|
|
689
|
-
</template>
|
|
690
|
-
<!-- E 内容组件 -->
|
|
691
|
-
|
|
692
|
-
<!-- S 文本内容 -->
|
|
693
|
-
<template v-else>
|
|
694
|
-
<div>
|
|
695
|
-
<BsgoalBaseTooltip :content="model[prop]" :limit="limit" :none="none" />
|
|
696
|
-
</div>
|
|
697
|
-
</template>
|
|
698
|
-
<!-- E 文本内容 -->
|
|
699
|
-
</slot>
|
|
700
|
-
</el-form-item>
|
|
701
|
-
</el-col>
|
|
702
|
-
</template>
|
|
703
|
-
</el-row>
|
|
704
|
-
</el-form>
|
|
705
|
-
<!-- / 表单内容 -->
|
|
706
|
-
</div>
|
|
707
|
-
</div>
|
|
708
|
-
</template>
|
|
709
|
-
<style lang="scss">
|
|
710
|
-
/* 覆盖样式
|
|
711
|
-
---------------------------------------------------------------- */
|
|
712
|
-
.bsgoal-base-form {
|
|
713
|
-
.base_form {
|
|
714
|
-
/* padding: 16px 6px 8px 16px; */
|
|
715
|
-
|
|
716
|
-
.el-form-item {
|
|
717
|
-
// margin-bottom: 8px;
|
|
718
|
-
margin-right: 10px;
|
|
719
|
-
}
|
|
720
|
-
|
|
721
|
-
div.el-input,
|
|
722
|
-
div.el-select {
|
|
723
|
-
width: 100%;
|
|
724
|
-
}
|
|
725
|
-
}
|
|
726
|
-
.base_form--visible {
|
|
727
|
-
width: 0px;
|
|
728
|
-
height: 0px;
|
|
729
|
-
overflow: hidden;
|
|
730
|
-
}
|
|
731
|
-
}
|
|
732
|
-
</style>
|