@dmqweb/elpis 1.0.0
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/.eslintignore +3 -0
- package/.eslintrc +59 -0
- package/.vscode/settings.json +15 -0
- package/README.md +198 -0
- package/app/controller/base.js +41 -0
- package/app/controller/project.js +98 -0
- package/app/controller/view.js +24 -0
- package/app/extend/logger.js +43 -0
- package/app/middleware/api-params-verify.js +89 -0
- package/app/middleware/api-sign-verify.js +47 -0
- package/app/middleware/error-handler.js +41 -0
- package/app/middleware/project-handler.js +27 -0
- package/app/middleware.js +40 -0
- package/app/pages/asserts/custom.css +12 -0
- package/app/pages/boot.js +59 -0
- package/app/pages/common/curl.js +88 -0
- package/app/pages/common/util.js +3 -0
- package/app/pages/dashboard/complex-view/header-view/complex-view/sub-menu/sub-menu.vue +40 -0
- package/app/pages/dashboard/complex-view/header-view/header-view.vue +141 -0
- package/app/pages/dashboard/complex-view/iframe-view/iframe-view.vue +43 -0
- package/app/pages/dashboard/complex-view/schema-view/complex-view/search-panel/search-panel.vue +39 -0
- package/app/pages/dashboard/complex-view/schema-view/complex-view/table-panel/table-panel.vue +146 -0
- package/app/pages/dashboard/complex-view/schema-view/components/component-config.js +24 -0
- package/app/pages/dashboard/complex-view/schema-view/components/create-form/create-form.vue +118 -0
- package/app/pages/dashboard/complex-view/schema-view/components/detail-panel/detail-panel.vue +177 -0
- package/app/pages/dashboard/complex-view/schema-view/components/edit-form/edit-form.vue +157 -0
- package/app/pages/dashboard/complex-view/schema-view/hook/schema.js +150 -0
- package/app/pages/dashboard/complex-view/schema-view/schema-view.vue +113 -0
- package/app/pages/dashboard/complex-view/sider-view/complex-view/sub-menu/sub-menu.vue +35 -0
- package/app/pages/dashboard/complex-view/sider-view/sider-view.vue +134 -0
- package/app/pages/dashboard/dashboard.vue +127 -0
- package/app/pages/dashboard/entry.dashboard.js +46 -0
- package/app/pages/store/index.js +5 -0
- package/app/pages/store/menu.js +61 -0
- package/app/pages/store/project.js +13 -0
- package/app/pages/widgets/header-container/asserts/avatar.png +0 -0
- package/app/pages/widgets/header-container/asserts/logo.png +0 -0
- package/app/pages/widgets/header-container/header-container.vue +144 -0
- package/app/pages/widgets/schema-form/complex-view/input/input.vue +165 -0
- package/app/pages/widgets/schema-form/complex-view/input-number/input-number.vue +166 -0
- package/app/pages/widgets/schema-form/complex-view/select/select.vue +144 -0
- package/app/pages/widgets/schema-form/form-item.config.js +24 -0
- package/app/pages/widgets/schema-form/schema-form.vue +144 -0
- package/app/pages/widgets/schema-search-bar/complex-view/date-range/date-range.vue +57 -0
- package/app/pages/widgets/schema-search-bar/complex-view/dynamic-select/dynamic-select.vue +77 -0
- package/app/pages/widgets/schema-search-bar/complex-view/input/input.vue +51 -0
- package/app/pages/widgets/schema-search-bar/complex-view/select/select.vue +58 -0
- package/app/pages/widgets/schema-search-bar/schema-search-bar.vue +138 -0
- package/app/pages/widgets/schema-search-bar/search-item-config.js +27 -0
- package/app/pages/widgets/schema-table/schema-table.vue +254 -0
- package/app/pages/widgets/sider-container/sider-container.vue +32 -0
- package/app/router/business.js +15 -0
- package/app/router/project.js +10 -0
- package/app/router/view.js +11 -0
- package/app/router-schema/business.js +82 -0
- package/app/router-schema/project.js +40 -0
- package/app/service/base.js +13 -0
- package/app/service/project.js +55 -0
- package/app/view/entry.tpl +27 -0
- package/app/webpack/config/blank.js +3 -0
- package/app/webpack/config/webpack.base.js +269 -0
- package/app/webpack/config/webpack.dev.js +61 -0
- package/app/webpack/config/webpack.prod.js +149 -0
- package/app/webpack/dev.js +58 -0
- package/app/webpack/prod.js +21 -0
- package/config/config.default.js +3 -0
- package/elpis-core/env.js +22 -0
- package/elpis-core/index.js +99 -0
- package/elpis-core/loader/config.js +51 -0
- package/elpis-core/loader/controller.js +75 -0
- package/elpis-core/loader/extend.js +54 -0
- package/elpis-core/loader/middleware.js +69 -0
- package/elpis-core/loader/router-schema.js +50 -0
- package/elpis-core/loader/router.js +52 -0
- package/elpis-core/loader/service.js +74 -0
- package/index.js +29 -0
- package/jsconfig.json +16 -0
- package/logs/applocation.log +3 -0
- package/model/index.js +119 -0
- package/package.json +93 -0
- package/test/controller/project.test.js +216 -0
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<el-row
|
|
3
|
+
type="flex"
|
|
4
|
+
align="top"
|
|
5
|
+
class="form-item"
|
|
6
|
+
>
|
|
7
|
+
<!-- label -->
|
|
8
|
+
<el-row
|
|
9
|
+
class="item-label"
|
|
10
|
+
justify="start"
|
|
11
|
+
>
|
|
12
|
+
<el-row
|
|
13
|
+
v-if="schema.option?.required"
|
|
14
|
+
type="flex"
|
|
15
|
+
class="required"
|
|
16
|
+
>
|
|
17
|
+
*
|
|
18
|
+
</el-row>
|
|
19
|
+
{{ schema.label }}
|
|
20
|
+
</el-row>
|
|
21
|
+
<!-- value -->
|
|
22
|
+
<el-row
|
|
23
|
+
class="item-value"
|
|
24
|
+
>
|
|
25
|
+
<el-input
|
|
26
|
+
v-model="dotValue"
|
|
27
|
+
v-bind="schema.option"
|
|
28
|
+
class="component"
|
|
29
|
+
:class=" validTips ? 'valid-border' : '' "
|
|
30
|
+
:placeholder="placeholder"
|
|
31
|
+
@focus="onFocus"
|
|
32
|
+
@blur="onBlur"
|
|
33
|
+
/>
|
|
34
|
+
</el-row>
|
|
35
|
+
<el-row
|
|
36
|
+
v-if="validTips"
|
|
37
|
+
class="valid-tips"
|
|
38
|
+
>
|
|
39
|
+
{{ validTips }}
|
|
40
|
+
</el-row>
|
|
41
|
+
</el-row>
|
|
42
|
+
</template>
|
|
43
|
+
|
|
44
|
+
<script setup>
|
|
45
|
+
import { ref, toRefs, watch, onMounted, inject} from 'vue'
|
|
46
|
+
const ajv = inject('ajv')
|
|
47
|
+
const props = defineProps({
|
|
48
|
+
schema: {
|
|
49
|
+
type: Object,
|
|
50
|
+
default: () => ({})
|
|
51
|
+
},
|
|
52
|
+
schemaKey: {
|
|
53
|
+
type: String,
|
|
54
|
+
default: ''
|
|
55
|
+
},
|
|
56
|
+
model: {
|
|
57
|
+
type: [String, Number, Boolean, Object],
|
|
58
|
+
default: undefined
|
|
59
|
+
},
|
|
60
|
+
})
|
|
61
|
+
const { schema, schemaKey} = props
|
|
62
|
+
const { model } = toRefs(props)
|
|
63
|
+
|
|
64
|
+
const name = ref('input')
|
|
65
|
+
const dotValue = ref()
|
|
66
|
+
const validTips = ref(null)
|
|
67
|
+
const placeholder = ref('')
|
|
68
|
+
|
|
69
|
+
// 初始化数据
|
|
70
|
+
const initData = () => {
|
|
71
|
+
// 如果有model值,使用model值,否则使用schema中定义的默认值
|
|
72
|
+
dotValue.value = model.value !== undefined ? model.value : schema.option?.default
|
|
73
|
+
validTips.value = null
|
|
74
|
+
|
|
75
|
+
const { minLength, maxLength, pattern } = schema
|
|
76
|
+
|
|
77
|
+
const ruleList = []
|
|
78
|
+
if(schema.option?.placeholder){
|
|
79
|
+
ruleList.value = schema.option.placeholder
|
|
80
|
+
}
|
|
81
|
+
if(minLength) {
|
|
82
|
+
ruleList.push(`最小长度: ${minLength}`)
|
|
83
|
+
}
|
|
84
|
+
if(maxLength) {
|
|
85
|
+
ruleList.push(`最大长度:${maxLength}`)
|
|
86
|
+
}
|
|
87
|
+
if(pattern) {
|
|
88
|
+
ruleList.push(`格式: ${pattern}`)
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
placeholder.value = ruleList.join('|')
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
onMounted(() => {
|
|
96
|
+
initData()
|
|
97
|
+
})
|
|
98
|
+
watch([model, schema], () => {
|
|
99
|
+
initData()
|
|
100
|
+
},{
|
|
101
|
+
deep: true,
|
|
102
|
+
immediate: true
|
|
103
|
+
})
|
|
104
|
+
|
|
105
|
+
// 获取表单值
|
|
106
|
+
const getValue = () => {
|
|
107
|
+
return dotValue.value !== null ? {
|
|
108
|
+
[schemaKey]: dotValue.value
|
|
109
|
+
} : {}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// 表单校验
|
|
113
|
+
const validate = () => {
|
|
114
|
+
validTips.value = null
|
|
115
|
+
|
|
116
|
+
const { type } = schema
|
|
117
|
+
|
|
118
|
+
if(schema.option?.required && !dotValue.value){
|
|
119
|
+
validTips.value = '请输入内容'
|
|
120
|
+
return false
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// 调用ajv校验schema
|
|
124
|
+
if(dotValue.value) {
|
|
125
|
+
const validate = ajv.compile(schema)
|
|
126
|
+
const valid = validate(dotValue.value)
|
|
127
|
+
if(!valid && validate.errors && validate.errors[0]) {
|
|
128
|
+
const { keyword, params} = validate.errors[0]
|
|
129
|
+
if(keyword === 'type') {
|
|
130
|
+
validTips.value = `类型必须为${type},请检查输入`
|
|
131
|
+
} else if(keyword === 'minLength') {
|
|
132
|
+
validTips.value = `长度不能小于${params.limit}`
|
|
133
|
+
} else if(keyword === 'maxLength') {
|
|
134
|
+
validTips.value = `长度不能大于${params.limit}`
|
|
135
|
+
} else if(keyword === 'pattern') {
|
|
136
|
+
validTips.value = `格式错误,请检查输入`
|
|
137
|
+
} else {
|
|
138
|
+
console.log(validate.errors[0])
|
|
139
|
+
validTips.value = '格式错误,请检查输入'
|
|
140
|
+
}
|
|
141
|
+
return false
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
return true
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// 输入框聚焦事件
|
|
148
|
+
const onFocus = () => {
|
|
149
|
+
validTips.value = null
|
|
150
|
+
}
|
|
151
|
+
// 输入框失焦事件
|
|
152
|
+
const onBlur = () => {
|
|
153
|
+
validate()
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
defineExpose({
|
|
157
|
+
getValue,
|
|
158
|
+
validate,
|
|
159
|
+
name
|
|
160
|
+
})
|
|
161
|
+
</script>
|
|
162
|
+
|
|
163
|
+
<style lang="less" scoped>
|
|
164
|
+
|
|
165
|
+
</style>
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<el-row
|
|
3
|
+
type="flex"
|
|
4
|
+
align="top"
|
|
5
|
+
class="form-item"
|
|
6
|
+
>
|
|
7
|
+
<!-- label -->
|
|
8
|
+
<el-row
|
|
9
|
+
class="item-label"
|
|
10
|
+
justify="start"
|
|
11
|
+
>
|
|
12
|
+
<el-row
|
|
13
|
+
v-if="schema.option?.required"
|
|
14
|
+
type="flex"
|
|
15
|
+
class="required"
|
|
16
|
+
>
|
|
17
|
+
*
|
|
18
|
+
</el-row>
|
|
19
|
+
{{ schema.label }}
|
|
20
|
+
</el-row>
|
|
21
|
+
<!-- value -->
|
|
22
|
+
<el-row
|
|
23
|
+
class="item-value"
|
|
24
|
+
>
|
|
25
|
+
<el-input-number
|
|
26
|
+
v-model="dotValue"
|
|
27
|
+
v-bind="schema.option"
|
|
28
|
+
:controls="false"
|
|
29
|
+
class="component"
|
|
30
|
+
:class=" validTips ? 'valid-border' : '' "
|
|
31
|
+
:placeholder="placeholder"
|
|
32
|
+
@focus="onFocus"
|
|
33
|
+
@blur="onBlur"
|
|
34
|
+
/>
|
|
35
|
+
</el-row>
|
|
36
|
+
<el-row
|
|
37
|
+
v-if="validTips"
|
|
38
|
+
class="valid-tips"
|
|
39
|
+
>
|
|
40
|
+
{{ validTips }}
|
|
41
|
+
</el-row>
|
|
42
|
+
</el-row>
|
|
43
|
+
</template>
|
|
44
|
+
|
|
45
|
+
<script setup>
|
|
46
|
+
import { ref, toRefs, watch, onMounted, inject} from 'vue'
|
|
47
|
+
const ajv = inject('ajv')
|
|
48
|
+
const props = defineProps({
|
|
49
|
+
schema: {
|
|
50
|
+
type: Object,
|
|
51
|
+
default: () => ({})
|
|
52
|
+
},
|
|
53
|
+
schemaKey: {
|
|
54
|
+
type: String,
|
|
55
|
+
default: ''
|
|
56
|
+
},
|
|
57
|
+
model: {
|
|
58
|
+
type: [String, Number, Boolean, Object],
|
|
59
|
+
default: undefined
|
|
60
|
+
},
|
|
61
|
+
})
|
|
62
|
+
const { schema, schemaKey} = props
|
|
63
|
+
const { model } = toRefs(props)
|
|
64
|
+
|
|
65
|
+
const name = ref('inputNumber')
|
|
66
|
+
const dotValue = ref()
|
|
67
|
+
const validTips = ref(null)
|
|
68
|
+
const placeholder = ref('')
|
|
69
|
+
|
|
70
|
+
// 初始化数据
|
|
71
|
+
const initData = () => {
|
|
72
|
+
// 如果有model值,使用model值,否则使用schema中定义的默认值
|
|
73
|
+
dotValue.value = model.value !== undefined ? model.value : schema.option?.default
|
|
74
|
+
validTips.value = null
|
|
75
|
+
|
|
76
|
+
const {
|
|
77
|
+
minium,
|
|
78
|
+
maximum
|
|
79
|
+
} = schema
|
|
80
|
+
|
|
81
|
+
const ruleList = []
|
|
82
|
+
if(schema.option?.placeholder){
|
|
83
|
+
ruleList.value = schema.option.placeholder
|
|
84
|
+
}
|
|
85
|
+
if(minium !== undefined) {
|
|
86
|
+
ruleList.push(`最小值: ${minium}`)
|
|
87
|
+
}
|
|
88
|
+
if(maximum !== undefined) {
|
|
89
|
+
ruleList.push(`最大值:${maximum}`)
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
placeholder.value = ruleList.join('|')
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
onMounted(() => {
|
|
97
|
+
initData()
|
|
98
|
+
})
|
|
99
|
+
watch([model, schema], () => {
|
|
100
|
+
initData()
|
|
101
|
+
},{
|
|
102
|
+
deep: true,
|
|
103
|
+
immediate: true
|
|
104
|
+
})
|
|
105
|
+
|
|
106
|
+
// 获取表单值
|
|
107
|
+
const getValue = () => {
|
|
108
|
+
return dotValue.value !== null ? {
|
|
109
|
+
[schemaKey]: dotValue.value
|
|
110
|
+
} : {}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// 表单校验
|
|
114
|
+
const validate = () => {
|
|
115
|
+
validTips.value = null
|
|
116
|
+
|
|
117
|
+
const { type } = schema
|
|
118
|
+
|
|
119
|
+
if(schema.option?.required && !dotValue.value){
|
|
120
|
+
validTips.value = '请输入内容'
|
|
121
|
+
return false
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// 调用ajv校验schema
|
|
125
|
+
if(dotValue.value) {
|
|
126
|
+
const validate = ajv.compile(schema)
|
|
127
|
+
const valid = validate(dotValue.value)
|
|
128
|
+
if(!valid && validate.errors && validate.errors[0]) {
|
|
129
|
+
const { keyword, params} = validate.errors[0]
|
|
130
|
+
if(keyword === 'type') {
|
|
131
|
+
validTips.value = `类型必须为${type},请检查输入`
|
|
132
|
+
} else if(keyword === 'minimum') {
|
|
133
|
+
validTips.value = `数值不能小于${params.limit}`
|
|
134
|
+
} else if(keyword === 'maximum') {
|
|
135
|
+
validTips.value = `数值不能大于${params.limit}`
|
|
136
|
+
} else {
|
|
137
|
+
console.log(validate.errors[0])
|
|
138
|
+
validTips.value = '格式错误,请检查输入'
|
|
139
|
+
}
|
|
140
|
+
return false
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
return true
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// 输入框聚焦事件
|
|
147
|
+
const onFocus = () => {
|
|
148
|
+
validTips.value = null
|
|
149
|
+
}
|
|
150
|
+
// 输入框失焦事件
|
|
151
|
+
const onBlur = () => {
|
|
152
|
+
validate()
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
defineExpose({
|
|
156
|
+
getValue,
|
|
157
|
+
validate,
|
|
158
|
+
name
|
|
159
|
+
})
|
|
160
|
+
</script>
|
|
161
|
+
|
|
162
|
+
<style lang="less" scoped>
|
|
163
|
+
:deep(.el-input-number .el-input__inner) {
|
|
164
|
+
text-align: left;
|
|
165
|
+
}
|
|
166
|
+
</style>
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<el-row
|
|
3
|
+
type="flex"
|
|
4
|
+
align="top"
|
|
5
|
+
class="form-item"
|
|
6
|
+
>
|
|
7
|
+
<!-- label -->
|
|
8
|
+
<el-row
|
|
9
|
+
class="item-label"
|
|
10
|
+
justify="start"
|
|
11
|
+
>
|
|
12
|
+
<el-row
|
|
13
|
+
v-if="schema.option?.required"
|
|
14
|
+
type="flex"
|
|
15
|
+
class="required"
|
|
16
|
+
>
|
|
17
|
+
*
|
|
18
|
+
</el-row>
|
|
19
|
+
{{ schema.label }}
|
|
20
|
+
</el-row>
|
|
21
|
+
<!-- value -->
|
|
22
|
+
<el-row
|
|
23
|
+
class="item-value"
|
|
24
|
+
>
|
|
25
|
+
<el-select
|
|
26
|
+
v-model="dotValue"
|
|
27
|
+
v-bind="schema.option"
|
|
28
|
+
class="component"
|
|
29
|
+
:class="validTips ? 'valid-border' : '' "
|
|
30
|
+
@change="onChange"
|
|
31
|
+
>
|
|
32
|
+
<el-option
|
|
33
|
+
v-for="item in schema.option?.enumList"
|
|
34
|
+
:key="item.value"
|
|
35
|
+
:label="item.label"
|
|
36
|
+
:value="item.value"
|
|
37
|
+
/>
|
|
38
|
+
</el-select>
|
|
39
|
+
</el-row>
|
|
40
|
+
<el-row
|
|
41
|
+
v-if="validTips"
|
|
42
|
+
class="valid-tips"
|
|
43
|
+
>
|
|
44
|
+
{{ validTips }}
|
|
45
|
+
</el-row>
|
|
46
|
+
</el-row>
|
|
47
|
+
</template>
|
|
48
|
+
|
|
49
|
+
<script setup>
|
|
50
|
+
import { ref, toRefs, watch, onMounted, inject} from 'vue'
|
|
51
|
+
const ajv = inject('ajv')
|
|
52
|
+
const props = defineProps({
|
|
53
|
+
schema: {
|
|
54
|
+
type: Object,
|
|
55
|
+
default: () => ({})
|
|
56
|
+
},
|
|
57
|
+
schemaKey: {
|
|
58
|
+
type: String,
|
|
59
|
+
default: ''
|
|
60
|
+
},
|
|
61
|
+
model: {
|
|
62
|
+
type: [String, Number, Boolean, Object],
|
|
63
|
+
default: undefined
|
|
64
|
+
},
|
|
65
|
+
})
|
|
66
|
+
const { schema, schemaKey} = props
|
|
67
|
+
const { model } = toRefs(props)
|
|
68
|
+
|
|
69
|
+
const name = ref('select')
|
|
70
|
+
const dotValue = ref()
|
|
71
|
+
const validTips = ref(null)
|
|
72
|
+
|
|
73
|
+
// 初始化数据
|
|
74
|
+
const initData = () => {
|
|
75
|
+
// 如果有model值,使用model值,否则使用schema中定义的默认值
|
|
76
|
+
dotValue.value = model.value !== undefined ? model.value : schema.option?.default
|
|
77
|
+
validTips.value = null
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
onMounted(() => {
|
|
82
|
+
initData()
|
|
83
|
+
})
|
|
84
|
+
watch([model, schema], () => {
|
|
85
|
+
initData()
|
|
86
|
+
},{
|
|
87
|
+
deep: true,
|
|
88
|
+
immediate: true
|
|
89
|
+
})
|
|
90
|
+
|
|
91
|
+
// 获取表单值
|
|
92
|
+
const getValue = () => {
|
|
93
|
+
return dotValue.value !== null ? {
|
|
94
|
+
[schemaKey]: dotValue.value
|
|
95
|
+
} : {}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// 表单校验
|
|
99
|
+
const validate = () => {
|
|
100
|
+
validTips.value = null
|
|
101
|
+
|
|
102
|
+
if(schema.option?.required && !dotValue.value){
|
|
103
|
+
validTips.value = '请输入内容'
|
|
104
|
+
return false
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// 调用ajv校验schema
|
|
108
|
+
if(dotValue.value) {
|
|
109
|
+
let dtoEnum = []
|
|
110
|
+
if(schema.option?.enumList) {
|
|
111
|
+
dtoEnum = schema.option.enumList.map(item => item.value)
|
|
112
|
+
}
|
|
113
|
+
const validate = ajv.compile({
|
|
114
|
+
schema,
|
|
115
|
+
...{ enum : dtoEnum }
|
|
116
|
+
})
|
|
117
|
+
const valid = validate(dotValue.value)
|
|
118
|
+
if(!valid && validate.errors && validate.errors[0]) {
|
|
119
|
+
if(validate.errors[0].keyword === 'enum') {
|
|
120
|
+
validTips.value = `请选择正确的选项`
|
|
121
|
+
} else {
|
|
122
|
+
console.log(validate.errors[0])
|
|
123
|
+
validTips.value = '不符合要求'
|
|
124
|
+
}
|
|
125
|
+
return false
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
return true
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
const onChange = () => {
|
|
132
|
+
validate()
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
defineExpose({
|
|
136
|
+
getValue,
|
|
137
|
+
validate,
|
|
138
|
+
name
|
|
139
|
+
})
|
|
140
|
+
</script>
|
|
141
|
+
|
|
142
|
+
<style lang="less" scoped>
|
|
143
|
+
|
|
144
|
+
</style>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import input from "./complex-view/input/input.vue"
|
|
2
|
+
import inputNumber from "./complex-view/input-number/input-number.vue"
|
|
3
|
+
import select from "./complex-view/select/select.vue"
|
|
4
|
+
|
|
5
|
+
// 自定义form-item组件配置
|
|
6
|
+
import BusinessFormItemConfig from "$businessFormItemConfig";
|
|
7
|
+
console.log('%cdmq:::%s',`color:green;font-weight:bold;`,`businessFormItemCOnfi`,BusinessFormItemConfig);
|
|
8
|
+
|
|
9
|
+
const FormItemConfig = {
|
|
10
|
+
input: {
|
|
11
|
+
component: input
|
|
12
|
+
},
|
|
13
|
+
'input-number': {
|
|
14
|
+
component: inputNumber
|
|
15
|
+
},
|
|
16
|
+
select: {
|
|
17
|
+
component: select
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export default {
|
|
22
|
+
...FormItemConfig,
|
|
23
|
+
...BusinessFormItemConfig
|
|
24
|
+
}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
v-if="schema && schema.properties"
|
|
4
|
+
class="schema-form"
|
|
5
|
+
>
|
|
6
|
+
<template
|
|
7
|
+
v-for="(schemaItem, key) in schema.properties"
|
|
8
|
+
>
|
|
9
|
+
<component
|
|
10
|
+
:is="FormItemConfig[schemaItem.option?.comType].component "
|
|
11
|
+
v-show="schemaItem.option?.visible !== false"
|
|
12
|
+
ref="formComList"
|
|
13
|
+
:schema-key="key"
|
|
14
|
+
:schema="schemaItem"
|
|
15
|
+
:model="model ? model[key] : undefined "
|
|
16
|
+
/>
|
|
17
|
+
</template>
|
|
18
|
+
</div>
|
|
19
|
+
</template>
|
|
20
|
+
|
|
21
|
+
<script setup>
|
|
22
|
+
import { toRefs, ref, provide } from 'vue';
|
|
23
|
+
import FormItemConfig from './form-item.config';
|
|
24
|
+
|
|
25
|
+
const Ajv = require('ajv')
|
|
26
|
+
const ajv = new Ajv()
|
|
27
|
+
provide('ajv', ajv)
|
|
28
|
+
const props = defineProps({
|
|
29
|
+
/**
|
|
30
|
+
* schema 配置, 结构如下
|
|
31
|
+
* {
|
|
32
|
+
type: 'object',
|
|
33
|
+
properties: { // 板块属性
|
|
34
|
+
key: {
|
|
35
|
+
// 标准 schema 配置(占位)
|
|
36
|
+
type: '', // 字段类型
|
|
37
|
+
label: '', // 字段名称
|
|
38
|
+
option: {
|
|
39
|
+
// 标准 el-component-column 配置(占位)
|
|
40
|
+
comType: '', // 控件类型 input/select....
|
|
41
|
+
visible: true, // 是否在 表单 中显示 默认true
|
|
42
|
+
disabled: false, // 是否禁用
|
|
43
|
+
required: false, // 是否必填
|
|
44
|
+
default: '', // 默认值
|
|
45
|
+
|
|
46
|
+
// 当 comType 为 select时
|
|
47
|
+
enumList: [], // 下拉框可选值
|
|
48
|
+
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
// ... 用户可扩展
|
|
52
|
+
},
|
|
53
|
+
}
|
|
54
|
+
*/
|
|
55
|
+
schema: {
|
|
56
|
+
type: Object,
|
|
57
|
+
default: () => ({})
|
|
58
|
+
},
|
|
59
|
+
/**
|
|
60
|
+
* 表单数据
|
|
61
|
+
*/
|
|
62
|
+
model: {
|
|
63
|
+
type: Object,
|
|
64
|
+
default: () => ({})
|
|
65
|
+
},
|
|
66
|
+
})
|
|
67
|
+
|
|
68
|
+
const { schema } = toRefs(props)
|
|
69
|
+
|
|
70
|
+
const formComList = ref([])
|
|
71
|
+
// 获取表单值
|
|
72
|
+
const getValue = () => {
|
|
73
|
+
return formComList.value.reduce((dtoObj, component) => {
|
|
74
|
+
return dtoObj = {
|
|
75
|
+
...dtoObj,
|
|
76
|
+
...component.getValue()
|
|
77
|
+
}
|
|
78
|
+
}, {})
|
|
79
|
+
}
|
|
80
|
+
// 表单校验
|
|
81
|
+
const validate = () => {
|
|
82
|
+
return formComList.value.every(item => {
|
|
83
|
+
return item.validate()
|
|
84
|
+
})
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
defineExpose({
|
|
88
|
+
getValue,
|
|
89
|
+
validate
|
|
90
|
+
})
|
|
91
|
+
</script>
|
|
92
|
+
|
|
93
|
+
<style lang="less">
|
|
94
|
+
.schema-form {
|
|
95
|
+
display: flex;
|
|
96
|
+
flex-direction: column;
|
|
97
|
+
gap: 20px;
|
|
98
|
+
|
|
99
|
+
.form-item {
|
|
100
|
+
display: flex;
|
|
101
|
+
align-items: flex-start;
|
|
102
|
+
margin-bottom: 20px;
|
|
103
|
+
min-width: 500px;
|
|
104
|
+
|
|
105
|
+
.item-label {
|
|
106
|
+
margin-right: 15px;
|
|
107
|
+
min-width: 70px;
|
|
108
|
+
text-align: left;
|
|
109
|
+
font-size: 14px;
|
|
110
|
+
color: #606266;
|
|
111
|
+
word-break: break-all;
|
|
112
|
+
|
|
113
|
+
.required{
|
|
114
|
+
top: 2px;
|
|
115
|
+
padding-left: 4px;
|
|
116
|
+
font-size: 20px;
|
|
117
|
+
color: #f56c6c;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
.item-value {
|
|
121
|
+
.component{
|
|
122
|
+
width: 500px;
|
|
123
|
+
}
|
|
124
|
+
.valid-border{
|
|
125
|
+
.el-input__wrapper{
|
|
126
|
+
border: 1px solid #F93F3F;
|
|
127
|
+
box-shadow: 0 0 0 0;
|
|
128
|
+
}
|
|
129
|
+
.el-select__wrapper{
|
|
130
|
+
border: 1px solid #F93F3F;
|
|
131
|
+
box-shadow: 0 0 0 0;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
.valid-tips{
|
|
136
|
+
margin-left: 10px;
|
|
137
|
+
height: 36px;
|
|
138
|
+
line-height: 36px;
|
|
139
|
+
overflow: hidden;
|
|
140
|
+
color: #F93F3F;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
</style>
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<el-date-picker
|
|
3
|
+
v-model="dtoValue"
|
|
4
|
+
v-bind="schema.option"
|
|
5
|
+
type="daterange"
|
|
6
|
+
range-separator="至"
|
|
7
|
+
:start-placeholder="schema.label + '开始日期'"
|
|
8
|
+
:end-placeholder="schema.label + '结束日期'"
|
|
9
|
+
class="date-range"
|
|
10
|
+
/>
|
|
11
|
+
</template>
|
|
12
|
+
|
|
13
|
+
<script setup>
|
|
14
|
+
import { ref, onMounted} from 'vue'
|
|
15
|
+
import moment from 'moment'
|
|
16
|
+
|
|
17
|
+
const { schema, schemaKey} = defineProps({
|
|
18
|
+
schema: {
|
|
19
|
+
type: Object,
|
|
20
|
+
default: () => ({})
|
|
21
|
+
},
|
|
22
|
+
schemaKey: {
|
|
23
|
+
type: String,
|
|
24
|
+
default: ''
|
|
25
|
+
}
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
const emit = defineEmits(['loaded'])
|
|
29
|
+
|
|
30
|
+
const dtoValue = ref([])
|
|
31
|
+
|
|
32
|
+
const getValue = () => {
|
|
33
|
+
return dtoValue.value?.length >= 2 ? {
|
|
34
|
+
[`${schemaKey}_start`]: moment(dtoValue.value[0]).format('YYYY-MM-DD'),
|
|
35
|
+
[`${schemaKey}_end`]: moment(dtoValue.value[1]).format('YYYY-MM-DD'),
|
|
36
|
+
} : {}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const reset = () => {
|
|
40
|
+
dtoValue.value = []
|
|
41
|
+
return
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
onMounted(() => {
|
|
45
|
+
reset()
|
|
46
|
+
emit('loaded')
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
defineExpose({
|
|
50
|
+
getValue,
|
|
51
|
+
reset
|
|
52
|
+
})
|
|
53
|
+
</script>
|
|
54
|
+
|
|
55
|
+
<style lang="less" scoped>
|
|
56
|
+
|
|
57
|
+
</style>
|