@bsgoal/common 1.8.3 → 1.8.5
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
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @Author: canlong.shen
|
|
3
3
|
* @Date: 2023-04-10 15:00:00
|
|
4
4
|
* @LastEditors: canlong.shen
|
|
5
|
-
* @LastEditTime: 2023-05-
|
|
5
|
+
* @LastEditTime: 2023-05-22 11:21:29
|
|
6
6
|
* @FilePath: \common\src\components\bsgoal-base-form\demo.vue
|
|
7
7
|
* @Description: 表单公共组件演示组件
|
|
8
8
|
*
|
|
@@ -16,7 +16,7 @@ import { ref, computed, toRefs, watch, unref } from 'vue'
|
|
|
16
16
|
import EnumType from '../../enums/enumType.js'
|
|
17
17
|
|
|
18
18
|
const values = ref({
|
|
19
|
-
prop1:'222',
|
|
19
|
+
prop1: '222',
|
|
20
20
|
prop2: 'select1',
|
|
21
21
|
prop20: ''
|
|
22
22
|
})
|
|
@@ -29,12 +29,17 @@ const confirm = () => {
|
|
|
29
29
|
})
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
const bindModel = ref({prop1:'111'})
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
const bindModel = ref({ prop1: '111',prop99:1 })
|
|
35
33
|
|
|
36
34
|
// 配置项
|
|
37
35
|
const configOptions = ref([
|
|
36
|
+
{
|
|
37
|
+
label: 'prop99',
|
|
38
|
+
prop: 'prop99',
|
|
39
|
+
value: 0,
|
|
40
|
+
type: EnumType.INPUT_NUMBER,
|
|
41
|
+
max: 'max'
|
|
42
|
+
},
|
|
38
43
|
{
|
|
39
44
|
label: 'prop1',
|
|
40
45
|
// value: '111',
|
|
@@ -88,7 +93,11 @@ const configOptions = ref([
|
|
|
88
93
|
label: 'prop4',
|
|
89
94
|
// value: '111',
|
|
90
95
|
type: EnumType.SWITCH,
|
|
91
|
-
prop: 'prop4'
|
|
96
|
+
prop: 'prop4',
|
|
97
|
+
range: [
|
|
98
|
+
{ label: '是', value: 1 },
|
|
99
|
+
{ label: '否', value: 0 }
|
|
100
|
+
]
|
|
92
101
|
},
|
|
93
102
|
{
|
|
94
103
|
label: 'prop5',
|
|
@@ -193,9 +202,9 @@ export default {
|
|
|
193
202
|
none="--"
|
|
194
203
|
:limits="10"
|
|
195
204
|
:config-options="configOptions"
|
|
196
|
-
:
|
|
205
|
+
:bind-model="bindModel"
|
|
197
206
|
>
|
|
198
|
-
|
|
207
|
+
<!-- <template #prop1="{option}">
|
|
199
208
|
<div>666 {{ option }} </div>
|
|
200
209
|
</template> -->
|
|
201
210
|
</BsgoalBaseForm>
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @Author: canlong.shen
|
|
3
3
|
* @Date: 2023-04-17 11:44:29
|
|
4
4
|
* @LastEditors: canlong.shen
|
|
5
|
-
* @LastEditTime: 2023-05-
|
|
5
|
+
* @LastEditTime: 2023-05-22 11:23:57
|
|
6
6
|
* @FilePath: \common\src\components\bsgoal-base-form\index.vue
|
|
7
7
|
* @Description: 表单公共组件
|
|
8
8
|
*
|
|
@@ -119,8 +119,7 @@ watchEffect(() => {
|
|
|
119
119
|
watchPropList.push(prop)
|
|
120
120
|
}
|
|
121
121
|
const bindValue = unref(model)[prop]
|
|
122
|
-
console.log('
|
|
123
|
-
console.log('valuesModel[prop]',valuesModel[prop]);
|
|
122
|
+
// console.log(prop,'valuesModel[prop]',bindValue)
|
|
124
123
|
model.value[prop] = bindValue || valuesModel[prop] || value
|
|
125
124
|
})
|
|
126
125
|
})
|
|
@@ -303,6 +302,37 @@ const validateForm = (callback = () => {}) => {
|
|
|
303
302
|
})
|
|
304
303
|
}
|
|
305
304
|
|
|
305
|
+
// ---> S switch active/inactive 的设置 <---
|
|
306
|
+
|
|
307
|
+
/**
|
|
308
|
+
* @Author: canlong.shen
|
|
309
|
+
* @description: 设置 active 值
|
|
310
|
+
* @param {*} range 入参
|
|
311
|
+
* @param {*} type 'active' / 'inactive'
|
|
312
|
+
* @default:
|
|
313
|
+
* @return {*}
|
|
314
|
+
*/
|
|
315
|
+
const setActiveValueText = (range = [], type = '') => {
|
|
316
|
+
const { 0: startOption = {}, 1: endOption = {} } = range
|
|
317
|
+
const { value: startValue = false, label: startText = '' } = startOption
|
|
318
|
+
const { value: endValue = false, label: endText = '' } = endOption
|
|
319
|
+
|
|
320
|
+
switch (type) {
|
|
321
|
+
case 'active-value':
|
|
322
|
+
return startValue
|
|
323
|
+
case 'inactive-value':
|
|
324
|
+
return endValue
|
|
325
|
+
case 'active-text':
|
|
326
|
+
return startText
|
|
327
|
+
case 'inactive-text':
|
|
328
|
+
return endText
|
|
329
|
+
default:
|
|
330
|
+
break
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
// ---> E switch active/inactive 的设置 <---
|
|
335
|
+
|
|
306
336
|
defineExpose({
|
|
307
337
|
triggerOperationClear,
|
|
308
338
|
triggerOperationForm,
|
|
@@ -313,7 +343,7 @@ defineExpose({
|
|
|
313
343
|
<div class="bsgoal-base-form">
|
|
314
344
|
<div class="base_form">
|
|
315
345
|
<!-- / 表单内容 -->
|
|
316
|
-
<el-form ref="EL_FORM_REF" label-suffix=":" :model="model" v-align>
|
|
346
|
+
<el-form ref="EL_FORM_REF" label-suffix=":" :model="model" v-align >
|
|
317
347
|
<el-row>
|
|
318
348
|
<template
|
|
319
349
|
v-for="(
|
|
@@ -365,7 +395,8 @@ defineExpose({
|
|
|
365
395
|
<!-- / textarea 输入框组件 -->
|
|
366
396
|
<template v-if="type === EnumType.INPUT_NUMBER">
|
|
367
397
|
<el-input-number
|
|
368
|
-
v-model="
|
|
398
|
+
v-model="model[prop]"
|
|
399
|
+
controls-position="right"
|
|
369
400
|
:min="min"
|
|
370
401
|
:max="max"
|
|
371
402
|
@change="triggerValueChange"
|
|
@@ -412,8 +443,10 @@ defineExpose({
|
|
|
412
443
|
<template v-if="type === EnumType.SWITCH">
|
|
413
444
|
<el-switch
|
|
414
445
|
v-model="model[prop]"
|
|
415
|
-
:active-value="range
|
|
416
|
-
:inactive-value="range
|
|
446
|
+
:active-value="setActiveValueText(range, 'active-value')"
|
|
447
|
+
:inactive-value="setActiveValueText(range, 'inactive-value')"
|
|
448
|
+
:active-text="setActiveValueText(range, 'active-text')"
|
|
449
|
+
:inactive-text="setActiveValueText(range, 'inactive-text')"
|
|
417
450
|
@change="triggerValueChange(type, prop)"
|
|
418
451
|
/>
|
|
419
452
|
</template>
|