@isxiaoyuan/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.
Files changed (85) hide show
  1. package/.eslintignore +3 -0
  2. package/.eslintrc +52 -0
  3. package/.vscode/settings.json +8 -0
  4. package/REMADE.md +228 -0
  5. package/app/controller/base.js +43 -0
  6. package/app/controller/project.js +106 -0
  7. package/app/controller/view.js +21 -0
  8. package/app/extend/logger.js +36 -0
  9. package/app/middleware/api-params-verify.js +73 -0
  10. package/app/middleware/api-sign-verify.js +43 -0
  11. package/app/middleware/error-handler.js +33 -0
  12. package/app/middleware/project-handle.js +26 -0
  13. package/app/middleware.js +41 -0
  14. package/app/pages/asserts/custom.css +11 -0
  15. package/app/pages/boot.js +43 -0
  16. package/app/pages/common/curl.js +88 -0
  17. package/app/pages/common/utils.js +2 -0
  18. package/app/pages/dashboard/complex-view/header-view/complex-view/sub-menu/sub-menu.vue +19 -0
  19. package/app/pages/dashboard/complex-view/header-view/header-view.vue +138 -0
  20. package/app/pages/dashboard/complex-view/iframe-view/iframe-view.vue +51 -0
  21. package/app/pages/dashboard/complex-view/schema-view/complex-view/search-panel/search-panel.vue +41 -0
  22. package/app/pages/dashboard/complex-view/schema-view/complex-view/table-panel/table-panel.vue +128 -0
  23. package/app/pages/dashboard/complex-view/schema-view/components/component-config.js +20 -0
  24. package/app/pages/dashboard/complex-view/schema-view/components/create-form/create-form.vue +95 -0
  25. package/app/pages/dashboard/complex-view/schema-view/components/detail-panel/detail-panel.vue +98 -0
  26. package/app/pages/dashboard/complex-view/schema-view/components/edit-form/edit-form.vue +123 -0
  27. package/app/pages/dashboard/complex-view/schema-view/hook/schema.js +129 -0
  28. package/app/pages/dashboard/complex-view/schema-view/schema-view.vue +98 -0
  29. package/app/pages/dashboard/complex-view/silder-view/silder-view.vue +127 -0
  30. package/app/pages/dashboard/dashboard.vue +96 -0
  31. package/app/pages/dashboard/entry.dashboard.js +48 -0
  32. package/app/pages/store/index.js +5 -0
  33. package/app/pages/store/menu.js +70 -0
  34. package/app/pages/store/project.js +17 -0
  35. package/app/pages/widgets/header-container/asserts/avatar.png +0 -0
  36. package/app/pages/widgets/header-container/asserts/logo.png +0 -0
  37. package/app/pages/widgets/header-container/header-container.vue +102 -0
  38. package/app/pages/widgets/schema-form/complex-view/input/input.vue +137 -0
  39. package/app/pages/widgets/schema-form/complex-view/input-number/input-number.vue +136 -0
  40. package/app/pages/widgets/schema-form/complex-view/select/select.vue +122 -0
  41. package/app/pages/widgets/schema-form/form-item-config.js +20 -0
  42. package/app/pages/widgets/schema-form/schema-form.vue +136 -0
  43. package/app/pages/widgets/schema-search-bar/complex-view/date-range/date-range.vue +55 -0
  44. package/app/pages/widgets/schema-search-bar/complex-view/dynamic-select/dynamic-select.vue +69 -0
  45. package/app/pages/widgets/schema-search-bar/complex-view/input/input.vue +45 -0
  46. package/app/pages/widgets/schema-search-bar/complex-view/select/select.vue +53 -0
  47. package/app/pages/widgets/schema-search-bar/schema-item-config.js +24 -0
  48. package/app/pages/widgets/schema-search-bar/schema-search-bar.vue +115 -0
  49. package/app/pages/widgets/schema-table/schema-table.vue +255 -0
  50. package/app/pages/widgets/sider-container/complex-view/sub-menu/sub-menu.vue +18 -0
  51. package/app/pages/widgets/sider-container/sider-container.vue +29 -0
  52. package/app/public/dist/entry.dashboard.tpl +27 -0
  53. package/app/public/dist/entry.page1.tpl +25 -0
  54. package/app/public/dist/entry.page2.tpl +25 -0
  55. package/app/public/dist/entry.project-list.tpl +27 -0
  56. package/app/public/static/logo.png +0 -0
  57. package/app/public/static/normalize.css +239 -0
  58. package/app/router/project.js +12 -0
  59. package/app/router/view.js +7 -0
  60. package/app/router-schema/project.js +30 -0
  61. package/app/service/base.js +13 -0
  62. package/app/service/project.js +58 -0
  63. package/app/view/entry.tpl +27 -0
  64. package/app/webpack/config/webpack.base.js +305 -0
  65. package/app/webpack/config/webpack.dev.js +62 -0
  66. package/app/webpack/config/webpack.prod.js +120 -0
  67. package/app/webpack/dev.js +62 -0
  68. package/app/webpack/libs/blank.js +1 -0
  69. package/app/webpack/prod.js +22 -0
  70. package/config/config.beta.js +3 -0
  71. package/config/config.default.js +3 -0
  72. package/config/config.prod.js +3 -0
  73. package/elpis-core/env.js +20 -0
  74. package/elpis-core/index.js +97 -0
  75. package/elpis-core/loader/config.js +66 -0
  76. package/elpis-core/loader/controller.js +86 -0
  77. package/elpis-core/loader/extend.js +66 -0
  78. package/elpis-core/loader/middleware.js +74 -0
  79. package/elpis-core/loader/router-schema.js +56 -0
  80. package/elpis-core/loader/router.js +49 -0
  81. package/elpis-core/loader/service.js +82 -0
  82. package/index.js +42 -0
  83. package/model/index.js +109 -0
  84. package/package.json +92 -0
  85. package/test/controller/project.test.js +188 -0
@@ -0,0 +1,136 @@
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="formComListRef"
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配置在doc dashboard文档下的 schemaConfig下的 schema
27
+ schema: {
28
+ // 板块数据结构
29
+ type: "object",
30
+ properties: {
31
+ key: {
32
+ ...schema,
33
+ type: "", // 字段类型
34
+ label: "", // 字段中文名
35
+ // 字段在table 中的相关配置
36
+ option: {
37
+ ...elTableColumnConfig, // 标准 el-table-cloumn 配置
38
+ toFixed: 0, // 数字类型字段保留小数位数
39
+ comType: "", // 配置控件类型
40
+ required: false, // 是否必填
41
+ visible: true, // 是否在 table 中显示(不配置就展示)
42
+ disabled: false, // 是否禁用
43
+ default: "", // 默认值
44
+ },
45
+ // 字段在 search-bar 中的相关配置
46
+ }
47
+ },
48
+ */
49
+ schema: {
50
+ type: Object,
51
+ default: () => {},
52
+ },
53
+ // 表单数据
54
+ model: {
55
+ type: [Object, Number, String],
56
+ },
57
+ });
58
+
59
+ const { schema } = toRefs(props);
60
+
61
+ const formComListRef = ref([]);
62
+
63
+ //表单校验
64
+ const validate = () => {
65
+ return formComListRef.value.every((item) => item.validate());
66
+ };
67
+
68
+ // 获取表单值
69
+ const getValue = () => {
70
+ return formComListRef.value.reduce((dtoObj, item) => {
71
+ return {
72
+ ...dtoObj,
73
+ ...item.getValue(),
74
+ };
75
+ }, {});
76
+ // let dtoObj = {};
77
+ // formComListRef.value.forEach((item) => {
78
+ // dtoObj = {
79
+ // ...dtoObj,
80
+ // ...item.getValue(),
81
+ // };
82
+ // });
83
+ // return dtoObj;
84
+ };
85
+
86
+ defineExpose({
87
+ validate,
88
+ getValue,
89
+ });
90
+ </script>
91
+
92
+ <style lang="less">
93
+ .schema-form {
94
+ .form-item {
95
+ margin-bottom: 20px;
96
+ min-width: 500px;
97
+ .item-label {
98
+ margin-right: 15px;
99
+ min-width: 70px;
100
+ text-align: right;
101
+ font-size: 14px;
102
+ color: #fff;
103
+ word-break: break-all;
104
+ .required {
105
+ top: 2px;
106
+ padding-left: 4px;
107
+ color: #f56c6c;
108
+ font-size: 20px;
109
+ }
110
+ }
111
+ .item-value {
112
+ .component {
113
+ width: 320px;
114
+ }
115
+ .valid-border {
116
+ .el-input_wrapper {
117
+ border: 1px solid #f93f3f;
118
+ box-shadow: 0 0 0 0;
119
+ }
120
+ .el-select_wrapper {
121
+ border: 1px solid #f93f3f;
122
+ box-shadow: 0 0 0 0;
123
+ }
124
+ }
125
+ }
126
+ .valid-tips {
127
+ margin-left: 10px;
128
+ height: 36px;
129
+ line-height: 36px;
130
+ overflow: hidden;
131
+ font-size: 12px;
132
+ color: #f93f3f;
133
+ }
134
+ }
135
+ }
136
+ </style>
@@ -0,0 +1,55 @@
1
+ <template>
2
+ <el-date-picker
3
+ v-model="dtoValue"
4
+ v-bind="schema.option"
5
+ class="date-range"
6
+ type="daterange"
7
+ range-separator="至"
8
+ :start-placeholder="schema.label + '开始'"
9
+ :end-placeholder="schema.label + '结束'"
10
+ />
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: {
19
+ type: String,
20
+ default: "",
21
+ },
22
+ schema: {
23
+ type: Object,
24
+ default: () => {},
25
+ },
26
+ });
27
+
28
+ const emit = defineEmits(["loaded"]);
29
+
30
+ const dtoValue = ref([]);
31
+ const getValue = () => {
32
+ return dtoValue.value?.length === 2
33
+ ? {
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
+
40
+ const reset = () => {
41
+ dtoValue.value = [];
42
+ };
43
+
44
+ onMounted(() => {
45
+ reset();
46
+ emit("loaded");
47
+ });
48
+
49
+ defineExpose({
50
+ getValue,
51
+ reset,
52
+ });
53
+ </script>
54
+
55
+ <style scoped lang="less"></style>
@@ -0,0 +1,69 @@
1
+ <template>
2
+ <el-select v-model="dtoValue" v-bind="schema.option" class="dynamic-select">
3
+ <el-option
4
+ v-for="item in enumList"
5
+ :key="item.value"
6
+ :label="item.label"
7
+ :value="item.value"
8
+ />
9
+ </el-select>
10
+ </template>
11
+
12
+ <script setup>
13
+ import { ref, onMounted } from "vue";
14
+ import $curl from "$elpisCommon/curl.js";
15
+
16
+ const { schemaKey, schema } = defineProps({
17
+ schemaKey: {
18
+ type: String,
19
+ default: "",
20
+ },
21
+ schema: {
22
+ type: Object,
23
+ default: () => {},
24
+ },
25
+ });
26
+
27
+ const emit = defineEmits(["loaded"]);
28
+
29
+ const dtoValue = ref();
30
+ const getValue = () => {
31
+ return dtoValue.value !== undefined
32
+ ? {
33
+ [schemaKey]: dtoValue.value,
34
+ }
35
+ : {};
36
+ };
37
+
38
+ const reset = () => {
39
+ dtoValue.value = schema?.option?.default ?? enumList.value[0]?.value;
40
+ };
41
+
42
+ const enumList = ref([]);
43
+ const fetchEnumList = async () => {
44
+ try {
45
+ const res = await $curl({
46
+ url: schema.option?.api,
47
+ method: "get",
48
+ data: {},
49
+ });
50
+ enumList.value = res.data || [];
51
+ // enumList.value.push(...(res.data || []))
52
+ } catch (error) {
53
+ console.log(error);
54
+ }
55
+ };
56
+
57
+ onMounted(async () => {
58
+ await fetchEnumList();
59
+ reset();
60
+ emit("loaded");
61
+ });
62
+
63
+ defineExpose({
64
+ getValue,
65
+ reset,
66
+ });
67
+ </script>
68
+
69
+ <style scoped lang="less"></style>
@@ -0,0 +1,45 @@
1
+ <template>
2
+ <el-input v-model="dtoValue" v-bind="schema.option" class="input" />
3
+ </template>
4
+
5
+ <script setup>
6
+ import { ref, onMounted } from "vue";
7
+
8
+ const { schemaKey, schema } = defineProps({
9
+ schemaKey: {
10
+ type: String,
11
+ default: "",
12
+ },
13
+ schema: {
14
+ type: Object,
15
+ default: () => {},
16
+ },
17
+ });
18
+
19
+ const emit = defineEmits(["loaded"]);
20
+
21
+ const dtoValue = ref();
22
+ const getValue = () => {
23
+ return dtoValue.value !== undefined
24
+ ? {
25
+ [schemaKey]: dtoValue.value,
26
+ }
27
+ : {};
28
+ };
29
+
30
+ const reset = () => {
31
+ dtoValue.value = schema?.option?.default;
32
+ };
33
+
34
+ onMounted(() => {
35
+ reset();
36
+ emit("loaded");
37
+ });
38
+
39
+ defineExpose({
40
+ getValue,
41
+ reset,
42
+ });
43
+ </script>
44
+
45
+ <style scoped lang="less"></style>
@@ -0,0 +1,53 @@
1
+ <template>
2
+ <el-select v-model="dtoValue" v-bind="schema.option" class="select">
3
+ <el-option
4
+ v-for="item in schema.option?.enumList"
5
+ :key="item.value"
6
+ :label="item.label"
7
+ :value="item.value"
8
+ />
9
+ </el-select>
10
+ </template>
11
+
12
+ <script setup>
13
+ import { ref, onMounted } from "vue";
14
+
15
+ const { schemaKey, schema } = defineProps({
16
+ schemaKey: {
17
+ type: String,
18
+ default: "",
19
+ },
20
+ schema: {
21
+ type: Object,
22
+ default: () => {},
23
+ },
24
+ });
25
+
26
+ const emit = defineEmits(["loaded"]);
27
+
28
+ const dtoValue = ref();
29
+ const getValue = () => {
30
+ return dtoValue.value !== undefined
31
+ ? {
32
+ [schemaKey]: dtoValue.value,
33
+ }
34
+ : {};
35
+ };
36
+
37
+ const reset = () => {
38
+ dtoValue.value =
39
+ schema?.option?.default ?? schema.option?.enumList?.[0]?.value;
40
+ };
41
+
42
+ onMounted(() => {
43
+ reset();
44
+ emit("loaded");
45
+ });
46
+
47
+ defineExpose({
48
+ getValue,
49
+ reset,
50
+ });
51
+ </script>
52
+
53
+ <style scoped lang="less"></style>
@@ -0,0 +1,24 @@
1
+ import input from "./complex-view/input/input.vue";
2
+ import select from "./complex-view/select/select.vue";
3
+ import dynamicSelect from "./complex-view/dynamic-select/dynamic-select.vue";
4
+ import dateRange from "./complex-view/date-range/date-range.vue";
5
+
6
+ // 业务拓展 component 配置
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 { ...SearchItemConfig, ...BusinessSearchItemConfig };
@@ -0,0 +1,115 @@
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
+ <component
14
+ ref="searchComList"
15
+ :is="SearchItemConfig[schemaItem.option?.comType]?.component"
16
+ :schemaKey="key"
17
+ :schema="schemaItem"
18
+ @loaded="handleChildLoaded"
19
+ />
20
+ </el-form-item>
21
+ <!-- 操作区域 -->
22
+ <el-form-item>
23
+ <el-button type="primary" plain class="search-btn" @click="search"
24
+ >搜索</el-button
25
+ >
26
+ <el-button plain class="reset-btn" @click="reset">重置</el-button>
27
+ </el-form-item>
28
+ </el-form>
29
+ </template>
30
+
31
+ <script setup>
32
+ import { ref, toRefs } from "vue";
33
+ import SearchItemConfig from "./schema-item-config.js";
34
+
35
+ const props = defineProps({
36
+ /*
37
+ * schema配置在doc dashboard文档下的 schemaConfig下
38
+ */
39
+ schema: {
40
+ type: Object,
41
+ default: () => {},
42
+ },
43
+ });
44
+
45
+ const { schema } = toRefs(props);
46
+
47
+ const emit = defineEmits(["load", "search", "reset"]);
48
+
49
+ const searchComList = ref([]);
50
+
51
+ const getValue = () => {
52
+ let dtoObj = {};
53
+ searchComList.value.forEach((component) => {
54
+ dtoObj = {
55
+ ...dtoObj,
56
+ ...component?.getValue(),
57
+ };
58
+ });
59
+ return dtoObj;
60
+ };
61
+
62
+ let childComLoadedCount = 0;
63
+ const handleChildLoaded = () => {
64
+ childComLoadedCount++;
65
+ // 判断是否完成
66
+ if (childComLoadedCount >= Object.keys(schema.value.properties).length) {
67
+ emit("load", getValue());
68
+ }
69
+ };
70
+
71
+ const search = () => {
72
+ emit("search", getValue());
73
+ };
74
+ const reset = () => {
75
+ searchComList.value.forEach((component) => {
76
+ component?.reset();
77
+ });
78
+ emit("reset");
79
+ };
80
+
81
+ defineExpose({
82
+ reset,
83
+ getValue,
84
+ });
85
+ </script>
86
+
87
+ <style lang="less">
88
+ .schema-search-bar {
89
+ min-width: 500px;
90
+
91
+ .input {
92
+ width: 280px;
93
+ }
94
+
95
+ .select {
96
+ width: 180px;
97
+ }
98
+
99
+ .dynamic-select {
100
+ width: 180px;
101
+ }
102
+
103
+ .date-range {
104
+ width: 280px;
105
+ }
106
+
107
+ .search-btn {
108
+ width: 100px;
109
+ }
110
+
111
+ .reset-btn {
112
+ width: 100px;
113
+ }
114
+ }
115
+ </style>