@charming_dans/elpis 0.0.0-stage → 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.
Files changed (78) hide show
  1. package/.eslintignore +3 -0
  2. package/.eslintrc +55 -0
  3. package/README.md +294 -2
  4. package/app/controller/base.js +39 -0
  5. package/app/controller/project.js +77 -0
  6. package/app/controller/view.js +19 -0
  7. package/app/extend/database.js +5 -0
  8. package/app/extend/logger.js +38 -0
  9. package/app/middleware/api-params-verify.js +75 -0
  10. package/app/middleware/api-sign-verify.js +38 -0
  11. package/app/middleware/error-handler.js +34 -0
  12. package/app/middleware/project-handler.js +28 -0
  13. package/app/middleware.js +38 -0
  14. package/app/pages/asserts/custom.css +12 -0
  15. package/app/pages/boot.js +49 -0
  16. package/app/pages/common/curl.js +85 -0
  17. package/app/pages/common/utils.js +3 -0
  18. package/app/pages/dashboard/complex-view/header-view/complex-view/sub-menu/sub-menu.vue +20 -0
  19. package/app/pages/dashboard/complex-view/header-view/header-view.vue +118 -0
  20. package/app/pages/dashboard/complex-view/iframe-view/iframe-view.vue +44 -0
  21. package/app/pages/dashboard/complex-view/schema-view/complex-view/search-panel/search-panel.vue +39 -0
  22. package/app/pages/dashboard/complex-view/schema-view/complex-view/table-panel/table-panel.vue +130 -0
  23. package/app/pages/dashboard/complex-view/schema-view/components/component-config.js +23 -0
  24. package/app/pages/dashboard/complex-view/schema-view/components/create-form/create-form.vue +99 -0
  25. package/app/pages/dashboard/complex-view/schema-view/components/detail-panel/detail-panel.vue +113 -0
  26. package/app/pages/dashboard/complex-view/schema-view/components/edit-form/edit-form.vue +129 -0
  27. package/app/pages/dashboard/complex-view/schema-view/hook/schema.js +128 -0
  28. package/app/pages/dashboard/complex-view/schema-view/schema-view.vue +98 -0
  29. package/app/pages/dashboard/complex-view/sider-view/complex-view/sub-menu/sub-menu.vue +25 -0
  30. package/app/pages/dashboard/complex-view/sider-view/sider-view.vue +120 -0
  31. package/app/pages/dashboard/dashboard.vue +98 -0
  32. package/app/pages/dashboard/entry.dashboard.js +42 -0
  33. package/app/pages/store/index.js +3 -0
  34. package/app/pages/store/menu.js +61 -0
  35. package/app/pages/store/project.js +17 -0
  36. package/app/pages/widgets/header-container/asserts/logo.png +0 -0
  37. package/app/pages/widgets/header-container/header-container.vue +81 -0
  38. package/app/pages/widgets/schema-form/complex-view/input/input.vue +139 -0
  39. package/app/pages/widgets/schema-form/complex-view/input-number/input-number.vue +138 -0
  40. package/app/pages/widgets/schema-form/complex-view/select/select.vue +116 -0
  41. package/app/pages/widgets/schema-form/form-item-config.js +23 -0
  42. package/app/pages/widgets/schema-form/schema-form.vue +131 -0
  43. package/app/pages/widgets/schema-search-bar/complex-view/date-range/date-range.vue +47 -0
  44. package/app/pages/widgets/schema-search-bar/complex-view/dynamic-select/dynamic-select.vue +63 -0
  45. package/app/pages/widgets/schema-search-bar/complex-view/input/input.vue +41 -0
  46. package/app/pages/widgets/schema-search-bar/complex-view/select/select.vue +48 -0
  47. package/app/pages/widgets/schema-search-bar/schema-search-bar.vue +130 -0
  48. package/app/pages/widgets/schema-search-bar/search-item-config.js +27 -0
  49. package/app/pages/widgets/schema-table/schema-table.vue +237 -0
  50. package/app/pages/widgets/sider-container/sider-container.vue +30 -0
  51. package/app/public/static/logo.png +0 -0
  52. package/app/public/static/normalize.css +239 -0
  53. package/app/router/project.js +6 -0
  54. package/app/router/view.js +8 -0
  55. package/app/router-schema/project.js +30 -0
  56. package/app/service/base.js +12 -0
  57. package/app/service/project.js +47 -0
  58. package/app/view/entry.tpl +25 -0
  59. package/app/webpack/config/webpack.base.js +210 -0
  60. package/app/webpack/config/webpack.dev.js +58 -0
  61. package/app/webpack/config/webpack.prod.js +113 -0
  62. package/app/webpack/dev.js +56 -0
  63. package/app/webpack/libs/blank.js +1 -0
  64. package/app/webpack/prod.js +21 -0
  65. package/config/config.default.js +3 -0
  66. package/elpis-core/env.js +23 -0
  67. package/elpis-core/index.js +95 -0
  68. package/elpis-core/loader/config.js +50 -0
  69. package/elpis-core/loader/controller.js +66 -0
  70. package/elpis-core/loader/extend.js +56 -0
  71. package/elpis-core/loader/middleware.js +65 -0
  72. package/elpis-core/loader/router-schema.js +48 -0
  73. package/elpis-core/loader/router.js +41 -0
  74. package/elpis-core/loader/service.js +66 -0
  75. package/index.js +38 -0
  76. package/model/index.js +99 -0
  77. package/package.json +90 -4
  78. package/test/controller/project.test.js +205 -0
@@ -0,0 +1,131 @@
1
+ <template>
2
+ <el-row v-if="schema && schema.properties" class="schema-form">
3
+ <template v-for="(itemSchema, key) in schema.properties">
4
+ <component
5
+ v-show="itemSchema.option.visible !== false"
6
+ ref="formComList"
7
+ :is="FormItemConfig[itemSchema.option?.comType]?.component"
8
+ :schemaKey="key"
9
+ :schema="itemSchema"
10
+ :model="model ? model[key] : undefined"
11
+ ></component>
12
+ </template>
13
+ </el-row>
14
+ </template>
15
+
16
+ <script setup>
17
+ import { ref, toRefs, provide } from 'vue';
18
+ import FormItemConfig from './form-item-config.js';
19
+
20
+ const Ajv = require('ajv');
21
+ const ajv = new Ajv();
22
+ provide('ajv', ajv);
23
+
24
+ const props = defineProps({
25
+ /**
26
+ * schema 配置,结构如下:
27
+ {
28
+ type: 'object',
29
+ properties: {
30
+ key: {
31
+ ...schema, // 标准 schema 配置
32
+ type: '', // 字段类型
33
+ label: '', // 字段的中文名
34
+ option: {
35
+ ...eleComponentConfig, // 标准 el-component 配置
36
+ comType: '', // 控件类型 input/selct/input-number
37
+ required: false, // 表单项是否必填,默认 false
38
+ visible: true, // 是否展示 (true/false),默认为 true
39
+ disabled: false, // 是否禁用 (true/false),默认为 false
40
+ default: '', // 默认值
41
+
42
+ // comType === 'select' 时生效
43
+ enumList: [] // 枚举列表
44
+ }
45
+ },
46
+ ...
47
+ },
48
+ }
49
+ */
50
+ schema: Object,
51
+
52
+ /**
53
+ * 表单数据
54
+ */
55
+ model: Object
56
+ });
57
+ const { schema } = toRefs(props);
58
+
59
+ const formComList = ref([]);
60
+
61
+ // 表单校验
62
+ const validate = () => {
63
+ return formComList.value.every(component => {
64
+ return component.validate();
65
+ });
66
+ }
67
+
68
+ // 获取表单值
69
+ const getValue = () => {
70
+ return formComList.value.reduce((dtoObj, component) => {
71
+ return {
72
+ ...dtoObj,
73
+ ...component.getValue()
74
+ }
75
+ }, {});
76
+ }
77
+
78
+ defineExpose({
79
+ validate,
80
+ getValue
81
+ });
82
+ </script>
83
+
84
+ <style lang="less">
85
+ .schema-form {
86
+ .form-item {
87
+ margin-bottom: 20px;
88
+ min-width: 500px;
89
+
90
+ .item-label {
91
+ margin-right: 15px;
92
+ min-width: 70px;
93
+ text-align: right;
94
+ font-size: 14px;
95
+ color: #ffffff;
96
+ word-break: break-all;
97
+
98
+ .required {
99
+ top: 2px;
100
+ padding-left: 4px;
101
+ color: #f56c6c;
102
+ font-size: 20px;
103
+ }
104
+ }
105
+
106
+ .item-value {
107
+ .component {
108
+ width: 320px;
109
+ }
110
+ .valid-border {
111
+ .el-input__wrapper {
112
+ border: 1px solid #F93F3F;
113
+ box-shadow: 0 0 0 0 ;
114
+ }
115
+ .el-select__wrapper {
116
+ border: 1px solid #F93F3F;
117
+ box-shadow: 0 0 0 0 ;
118
+ }
119
+ }
120
+ }
121
+ .valid-tips {
122
+ margin-left: 10px;
123
+ height: 36px;
124
+ line-height: 36px;
125
+ overflow: hidden;
126
+ font-size: 12px;
127
+ color: #F93F3F;
128
+ }
129
+ }
130
+ }
131
+ </style>
@@ -0,0 +1,47 @@
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
+ ></el-date-picker>
11
+ </template>
12
+
13
+ <script setup>
14
+ import { ref, onMounted } from 'vue';
15
+ import moment from 'moment';
16
+
17
+ const { schemaKey, schema } = defineProps({
18
+ schemaKey: String,
19
+ schema: Object
20
+ });
21
+
22
+ const emit = defineEmits([ 'loaded' ]);
23
+
24
+ const dtoValue = ref([]);
25
+ const getValue = () => {
26
+ return dtoValue.value?.length === 2 ? {
27
+ [`${schemaKey}_start`]: moment(dtoValue.value[0]).format('YYYY-MM-DD'),
28
+ [`${schemaKey}_end`]:moment(dtoValue.value[1]).format('YYYY-MM-DD')
29
+ } : {}
30
+ }
31
+
32
+ const reset = () => {
33
+ dtoValue.value = [];
34
+ }
35
+
36
+ onMounted(() => {
37
+ reset();
38
+ emit('loaded');
39
+ });
40
+
41
+ defineExpose({
42
+ getValue,
43
+ reset
44
+ });
45
+ </script>
46
+
47
+ <style lang="less" scoped></style>
@@ -0,0 +1,63 @@
1
+ <template>
2
+ <el-select
3
+ v-model="dtoValue"
4
+ v-bind="schema.option"
5
+ class="dynamic-select"
6
+ >
7
+ <el-option
8
+ v-for="item in enumList"
9
+ :key="item.value"
10
+ :label="item.label"
11
+ :value="item.value"
12
+ ></el-option>
13
+ </el-select>
14
+ </template>
15
+
16
+ <script setup>
17
+ import { ref, onMounted } from 'vue';
18
+ import $curl from '$elpisCommon/curl.js';
19
+
20
+ const { schemaKey, schema } = defineProps({
21
+ schemaKey: String,
22
+ schema: Object
23
+ });
24
+
25
+ const emit = defineEmits([ 'loaded' ]);
26
+
27
+ const dtoValue = ref();
28
+ const getValue = () => {
29
+ return dtoValue.value !== undefined ? {
30
+ [schemaKey]: dtoValue.value
31
+ } : {}
32
+ }
33
+
34
+ const reset = () => {
35
+ dtoValue.value = schema?.option?.default ?? enumList.value[0]?.value;
36
+ }
37
+
38
+ const enumList = ref([]);
39
+ const fetchEnumList = async () => {
40
+ const res = await $curl({
41
+ method: 'get',
42
+ url: schema.option?.api,
43
+ data: {}
44
+ });
45
+
46
+ if (res?.data?.length > 0) {
47
+ enumList.value.push(...res?.data);
48
+ }
49
+ }
50
+
51
+ onMounted(async () => {
52
+ await fetchEnumList();
53
+ reset();
54
+ emit('loaded');
55
+ });
56
+
57
+ defineExpose({
58
+ getValue,
59
+ reset
60
+ });
61
+ </script>
62
+
63
+ <style lang="less" scoped></style>
@@ -0,0 +1,41 @@
1
+ <template>
2
+ <el-input
3
+ v-model="dtoValue"
4
+ v-bind="schema.option"
5
+ class="input"
6
+ ></el-input>
7
+ </template>
8
+
9
+ <script setup>
10
+ import { ref, onMounted } from 'vue';
11
+
12
+ const { schemaKey, schema } = defineProps({
13
+ schemaKey: String,
14
+ schema: Object
15
+ });
16
+
17
+ const emit = defineEmits([ 'loaded' ]);
18
+
19
+ const dtoValue = ref();
20
+ const getValue = () => {
21
+ return dtoValue.value !== undefined ? {
22
+ [schemaKey]: dtoValue.value
23
+ } : {}
24
+ }
25
+
26
+ const reset = () => {
27
+ dtoValue.value = schema?.option?.default;
28
+ }
29
+
30
+ onMounted(() => {
31
+ reset();
32
+ emit('loaded');
33
+ });
34
+
35
+ defineExpose({
36
+ getValue,
37
+ reset
38
+ });
39
+ </script>
40
+
41
+ <style lang="less" scoped></style>
@@ -0,0 +1,48 @@
1
+ <template>
2
+ <el-select
3
+ v-model="dtoValue"
4
+ v-bind="schema.option"
5
+ class="select"
6
+ >
7
+ <el-option
8
+ v-for="item in schema.option?.enumList"
9
+ :key="item.value"
10
+ :label="item.label"
11
+ :value="item.value"
12
+ ></el-option>
13
+ </el-select>
14
+ </template>
15
+
16
+ <script setup>
17
+ import { ref, onMounted } from 'vue';
18
+
19
+ const { schemaKey, schema } = defineProps({
20
+ schemaKey: String,
21
+ schema: Object
22
+ });
23
+
24
+ const emit = defineEmits([ 'loaded' ]);
25
+
26
+ const dtoValue = ref();
27
+ const getValue = () => {
28
+ return dtoValue.value !== undefined ? {
29
+ [schemaKey]: dtoValue.value
30
+ } : {}
31
+ }
32
+
33
+ const reset = () => {
34
+ dtoValue.value = schema?.option?.default ?? schema.option?.enumList[0]?.value;
35
+ }
36
+
37
+ onMounted(() => {
38
+ reset();
39
+ emit('loaded');
40
+ });
41
+
42
+ defineExpose({
43
+ getValue,
44
+ reset
45
+ });
46
+ </script>
47
+
48
+ <style lang="less" scoped></style>
@@ -0,0 +1,130 @@
1
+ <template>
2
+ <el-form
3
+ v-if="schema && schema.properties"
4
+ :inline="true"
5
+ class="schema-search-bar"
6
+ >
7
+ <!-- 动态组件 -->
8
+ <el-form-item
9
+ v-for="(schemaItem, key) in schema.properties"
10
+ :key="key"
11
+ :label="schemaItem.label"
12
+ >
13
+ <!-- 展示子组件 -->
14
+ <component
15
+ ref="searchComList"
16
+ :is="SearchItemConfig[schemaItem.option?.comType]?.component"
17
+ :schemaKey="key"
18
+ :schema="schemaItem"
19
+ @loaded="handleChildLoaded"
20
+ ></component>
21
+ </el-form-item>
22
+ <!-- 操作区域 -->
23
+ <el-form-item>
24
+ <el-button
25
+ type="primary"
26
+ plain
27
+ class="search-btn"
28
+ @click="search"
29
+ >搜索</el-button>
30
+ <el-button
31
+ plain
32
+ class="reset-btn"
33
+ @click="reset"
34
+ >重置</el-button>
35
+ </el-form-item>
36
+ </el-form>
37
+ </template>
38
+
39
+ <script setup>
40
+ import { ref, toRefs } from 'vue';
41
+ import SearchItemConfig from './search-item-config.js';
42
+
43
+ const props = defineProps({
44
+ /**
45
+ * schema 配置,结构如下:
46
+ {
47
+ type: 'object',
48
+ properties: {
49
+ key: {
50
+ ...schema, // 标准 schema 配置
51
+ type: '', // 字段类型
52
+ label: '', // 字段的中文名
53
+ // 字段在 search-bar 中的相关配置
54
+ option: {
55
+ ...eleComponentConfig, // 标准 el-component-column 配置
56
+ comType: '', // 配置组件类型 input/select/.....
57
+ default: '', // 默认值
58
+ }
59
+ },
60
+ ...
61
+ }
62
+ }
63
+ */
64
+ schema: Object
65
+ });
66
+ const { schema } = toRefs(props);
67
+
68
+ const emit = defineEmits([ 'load', 'search', 'reset' ]);
69
+
70
+ const searchComList = ref([]);
71
+
72
+ const getValue = () => {
73
+ let dtoObj = {};
74
+ searchComList.value.forEach(component => {
75
+ dtoObj = {
76
+ ...dtoObj,
77
+ ...component?.getValue()
78
+ }
79
+ });
80
+ return dtoObj;
81
+ }
82
+
83
+ let childComLoadedCount = 0;
84
+ const handleChildLoaded = () => {
85
+ childComLoadedCount++;
86
+ if (childComLoadedCount >= Object.keys(schema?.value?.properties).length) {
87
+ emit('load', getValue());
88
+ }
89
+ }
90
+
91
+ const search = () => {
92
+ emit('search', getValue());
93
+ }
94
+
95
+ const reset = () => {
96
+ searchComList.value.forEach(component => component?.reset());
97
+ emit('reset');
98
+ }
99
+
100
+ defineExpose({
101
+ reset,
102
+ getValue
103
+ });
104
+ </script>
105
+
106
+ <style lang="less">
107
+ .schema-search-bar {
108
+ min-width: 500px;
109
+
110
+ .input {
111
+ width: 180px;
112
+ }
113
+
114
+ .select {
115
+ width: 180px;
116
+ }
117
+
118
+ .dynamic-select {
119
+ width: 180px;
120
+ }
121
+
122
+ .search-btn {
123
+ width: 100px;
124
+ }
125
+
126
+ .reset-btn {
127
+ width: 100px;
128
+ }
129
+ }
130
+ </style>
@@ -0,0 +1,27 @@
1
+ import input from './complex-view/input/input';
2
+ import select from './complex-view/select/select';
3
+ import dynamicSelect from './complex-view/dynamic-select/dynamic-select';
4
+ import dateRange from './complex-view/date-range/date-range';
5
+
6
+ // 业务扩展 search-item 配置
7
+ import BusinessSearchItemConfig from '$businessSearchItemConfig';
8
+
9
+ const SearchItemConfig = {
10
+ input: {
11
+ component: input
12
+ },
13
+ select: {
14
+ component: select
15
+ },
16
+ dynamicSelect: {
17
+ component: dynamicSelect
18
+ },
19
+ dateRange: {
20
+ component: dateRange
21
+ }
22
+ }
23
+
24
+ export default {
25
+ ...SearchItemConfig,
26
+ ...BusinessSearchItemConfig
27
+ }