@xujingquan/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 (90) hide show
  1. package/.browserslistrc +3 -0
  2. package/.eslintignore +4 -0
  3. package/.eslintrc +63 -0
  4. package/.husky/commit-msg +1 -0
  5. package/.husky/pre-commit +1 -0
  6. package/.prettierignore +16 -0
  7. package/.prettierrc +10 -0
  8. package/README.md +248 -0
  9. package/app/controller/base.js +41 -0
  10. package/app/controller/project.js +75 -0
  11. package/app/controller/view.js +28 -0
  12. package/app/extend/logger.js +39 -0
  13. package/app/middleware/api-params-verify.js +90 -0
  14. package/app/middleware/api-sign-veriyf.js +47 -0
  15. package/app/middleware/error-handler.js +33 -0
  16. package/app/middleware/project-handler.js +30 -0
  17. package/app/middleware.js +45 -0
  18. package/app/pages/asserts/custom.css +13 -0
  19. package/app/pages/boot.js +56 -0
  20. package/app/pages/common/api/business-api.js +19 -0
  21. package/app/pages/common/api/project-api.js +27 -0
  22. package/app/pages/common/request.js +119 -0
  23. package/app/pages/common/utils.js +2 -0
  24. package/app/pages/dashboard/complex-view/header-view/complex-view/sub-menu/sub-menu.vue +20 -0
  25. package/app/pages/dashboard/complex-view/header-view/header-view.vue +116 -0
  26. package/app/pages/dashboard/complex-view/iframe-view/iframe-view.vue +44 -0
  27. package/app/pages/dashboard/complex-view/schema-view/complex-view/search-panel/search-panel.vue +37 -0
  28. package/app/pages/dashboard/complex-view/schema-view/complex-view/table-panel/table-panel.vue +122 -0
  29. package/app/pages/dashboard/complex-view/schema-view/components/component-config.js +23 -0
  30. package/app/pages/dashboard/complex-view/schema-view/components/create-form/create-form.vue +86 -0
  31. package/app/pages/dashboard/complex-view/schema-view/components/detail-panel/detail-panel.vue +82 -0
  32. package/app/pages/dashboard/complex-view/schema-view/components/edit-form/edit-form.vue +115 -0
  33. package/app/pages/dashboard/complex-view/schema-view/hook/schema.js +135 -0
  34. package/app/pages/dashboard/complex-view/schema-view/schema-view.vue +93 -0
  35. package/app/pages/dashboard/complex-view/sider-view/complex-view/sub-menu/sub-menu.vue +21 -0
  36. package/app/pages/dashboard/complex-view/sider-view/sider-view.vue +115 -0
  37. package/app/pages/dashboard/dashboard.vue +93 -0
  38. package/app/pages/dashboard/entry.dashboard.js +45 -0
  39. package/app/pages/store/index.js +4 -0
  40. package/app/pages/store/menu.js +61 -0
  41. package/app/pages/store/project.js +17 -0
  42. package/app/pages/widgets/header-container/asserts/avatar.png +0 -0
  43. package/app/pages/widgets/header-container/asserts/logo.png +0 -0
  44. package/app/pages/widgets/header-container/header-container.vue +111 -0
  45. package/app/pages/widgets/schema-form/complex-view/input/input.vue +141 -0
  46. package/app/pages/widgets/schema-form/complex-view/input-number/input-number.vue +142 -0
  47. package/app/pages/widgets/schema-form/complex-view/select/select.vue +119 -0
  48. package/app/pages/widgets/schema-form/form-item-config.js +23 -0
  49. package/app/pages/widgets/schema-form/schema-form.vue +130 -0
  50. package/app/pages/widgets/schema-search-bar/complex-view/date-range/date-range.vue +50 -0
  51. package/app/pages/widgets/schema-search-bar/complex-view/dynamic-select/dynamic-select.vue +62 -0
  52. package/app/pages/widgets/schema-search-bar/complex-view/input/input.vue +40 -0
  53. package/app/pages/widgets/schema-search-bar/complex-view/select/select.vue +48 -0
  54. package/app/pages/widgets/schema-search-bar/schema-search-bar.vue +121 -0
  55. package/app/pages/widgets/schema-search-bar/search-item-config.js +27 -0
  56. package/app/pages/widgets/schema-table/schema-table.vue +243 -0
  57. package/app/pages/widgets/sider-container/sider-container.vue +26 -0
  58. package/app/public/static/logo.png +0 -0
  59. package/app/public/static/md5.js +950 -0
  60. package/app/public/static/normalize.css +267 -0
  61. package/app/router/project.js +11 -0
  62. package/app/router/view.js +13 -0
  63. package/app/router-schema/project.js +33 -0
  64. package/app/service/base.js +14 -0
  65. package/app/service/project.js +43 -0
  66. package/app/view/entry.tpl +27 -0
  67. package/app/webpack/config/utils.js +49 -0
  68. package/app/webpack/config/webpack-dev.js +55 -0
  69. package/app/webpack/config/webpack-prod.js +192 -0
  70. package/app/webpack/config/webpack.base.js +273 -0
  71. package/app/webpack/dev.js +60 -0
  72. package/app/webpack/libs/blank.js +1 -0
  73. package/app/webpack/prod.js +27 -0
  74. package/babel.config.js +15 -0
  75. package/commitlint.config.js +3 -0
  76. package/config/config.default.js +4 -0
  77. package/elpis-core/env.js +20 -0
  78. package/elpis-core/index.js +86 -0
  79. package/elpis-core/loader/config.js +54 -0
  80. package/elpis-core/loader/controller.js +69 -0
  81. package/elpis-core/loader/extend.js +57 -0
  82. package/elpis-core/loader/middleware.js +66 -0
  83. package/elpis-core/loader/router-schema.js +49 -0
  84. package/elpis-core/loader/router.js +50 -0
  85. package/elpis-core/loader/service.js +69 -0
  86. package/index.js +47 -0
  87. package/jsconfig.json +19 -0
  88. package/model/index.js +103 -0
  89. package/package.json +105 -0
  90. package/test/controller/project.test.js +200 -0
@@ -0,0 +1,243 @@
1
+ <template>
2
+ <div class="schema-table">
3
+ <el-table
4
+ v-if="schema && schema.properties"
5
+ v-loading="loading"
6
+ :data="tableData"
7
+ class="table"
8
+ >
9
+ <template v-for="(schemaItem, key) in schema.properties">
10
+ <!-- v-bind 透传,将 schemaItem.option 内的属性全部传入-->
11
+ <el-table-column
12
+ v-if="schemaItem.option.visible !== false"
13
+ :key="key"
14
+ :prop="key"
15
+ :label="schemaItem.label"
16
+ v-bind="schemaItem.option"
17
+ />
18
+ </template>
19
+ <!-- 操作列 -->
20
+ <el-table-column
21
+ v-if="buttons?.length > 0"
22
+ label="操作"
23
+ fixed="right"
24
+ :width="operationWidth"
25
+ >
26
+ <template #default="scoped">
27
+ <el-button
28
+ v-for="item in buttons"
29
+ link
30
+ v-bind="item"
31
+ @click="
32
+ operationHandler({
33
+ btnConfig: item,
34
+ rowData: scoped.row,
35
+ })
36
+ "
37
+ >{{ item.label }}
38
+ </el-button>
39
+ </template>
40
+ </el-table-column>
41
+ </el-table>
42
+ <el-row justify="end" class="pagination">
43
+ <el-pagination
44
+ :current-page="currentPage"
45
+ :page-sizes="[10, 20, 50, 100]"
46
+ :total="total"
47
+ layout="total, sizes, prev, pager, next, jumper"
48
+ @size-change="onPageSizeChange"
49
+ @current-change="onCurrentChange"
50
+ />
51
+ </el-row>
52
+ </div>
53
+ </template>
54
+
55
+ <script setup>
56
+ import { ref, toRefs, computed, watch, nextTick, onMounted } from 'vue';
57
+ import { tableDataPort } from '$elpisCommon/api/business-api';
58
+
59
+ const emits = defineEmits(['operate']);
60
+ const props = defineProps({
61
+ /**
62
+ * schema 配置,结构如下
63
+ * {
64
+ * type: 'object',
65
+ * properties: {
66
+ * key: {
67
+ * ...schema, // 标准 schema 配置
68
+ * type: '', //字段类型
69
+ * label: '', // 字段的中文名
70
+ * option:{
71
+ * ...elTableColumnConfig, // 标准 el-table-column
72
+ * visible: true, // 默认为 true(false 或 不配置时,表示不在表单中显示)
73
+ * }
74
+ * }
75
+ * ...
76
+ * }
77
+ * }
78
+ */
79
+ schema: Object,
80
+ /**
81
+ * 表格数据源 api
82
+ * */
83
+ api: String,
84
+ /**
85
+ * API 请求参数,请求 API 时携带
86
+ * */
87
+ apiParams: Object,
88
+ /**
89
+ * buttons 操作按钮相关配置,结构如下
90
+ * [{
91
+ * label: '', // 按钮中文名
92
+ * eventKey: '', // 按钮事件名
93
+ * eventOption: {}, // 按钮事件具体配置
94
+ * ...elButtonConfig // 标准的 el-botton 配置
95
+ * },...]
96
+ * */
97
+ buttons: Array,
98
+ });
99
+
100
+ // 把参数变成可响应 Vue version 3.5 前需要,3.5 后不需要,
101
+ const { schema, api, apiParams, buttons } = toRefs(props);
102
+
103
+ const loading = ref(false);
104
+ const tableData = ref([]);
105
+ const currentPage = ref(1);
106
+ const pageSize = ref(50);
107
+ const total = ref(0);
108
+
109
+ const operationWidth = computed(() => {
110
+ return buttons?.value?.length > 0
111
+ ? buttons.value.reduce((pre, cur) => {
112
+ return pre + cur.label.length * 18;
113
+ }, 50)
114
+ : 50;
115
+ });
116
+
117
+ onMounted(() => {
118
+ initData();
119
+ });
120
+
121
+ watch(
122
+ [schema, api, apiParams],
123
+ () => {
124
+ initData();
125
+ },
126
+ { deep: true }
127
+ );
128
+
129
+ const initData = function () {
130
+ currentPage.value = 1;
131
+ pageSize.value = 50;
132
+ nextTick(async () => {
133
+ await loadTableData();
134
+ });
135
+ };
136
+
137
+ // 截流处理
138
+ let timerId = null;
139
+ const loadTableData = function () {
140
+ clearTimeout(timerId);
141
+ timerId = setTimeout(async () => {
142
+ await fetchTableData();
143
+ timerId = null; // 清除内存
144
+ }, 100);
145
+ };
146
+
147
+ const fetchTableData = async function () {
148
+ if (!api.value) return;
149
+
150
+ showLoading();
151
+ try {
152
+ // 请求数据
153
+ const res = await tableDataPort({
154
+ method: 'get',
155
+ url: `${api.value}/list`,
156
+ params: {
157
+ ...apiParams.value,
158
+ page: currentPage.value,
159
+ size: pageSize.value,
160
+ },
161
+ errorMessage: '请求列表失败',
162
+ });
163
+
164
+ if (!res?.success || !Array.isArray(res?.data)) {
165
+ tableData.value = [];
166
+ total.value = 0;
167
+ return;
168
+ }
169
+
170
+ tableData.value = buildTableData(res.data);
171
+ total.value = res.metadata.total ?? 0;
172
+ } finally {
173
+ hideLoading();
174
+ }
175
+ };
176
+
177
+ /**
178
+ * 对后端返回的数据进行渲染前的预处理
179
+ * @param {Object} listData 列表数据
180
+ * */
181
+ const buildTableData = function (listData) {
182
+ if (!schema.value?.properties) return listData;
183
+
184
+ return listData.map((rowData) => {
185
+ for (const dKey in rowData) {
186
+ const schemaItem = schema.value.properties[dKey];
187
+ // 处理 toFixed
188
+ if (schemaItem?.option?.toFixed) {
189
+ rowData[dKey] = rowData[dKey].toFixed && rowData[dKey].toFixed(schemaItem.option.toFixed);
190
+ }
191
+ }
192
+
193
+ return rowData;
194
+ });
195
+ };
196
+
197
+ const showLoading = function () {
198
+ loading.value = true;
199
+ };
200
+
201
+ const hideLoading = function () {
202
+ loading.value = false;
203
+ };
204
+
205
+ const operationHandler = function ({ btnConfig, rowData }) {
206
+ emits('operate', { btnConfig, rowData });
207
+ };
208
+
209
+ const onPageSizeChange = async function (value) {
210
+ pageSize.value = value;
211
+ await loadTableData();
212
+ };
213
+
214
+ const onCurrentChange = async function (value) {
215
+ currentPage.value = value;
216
+ await loadTableData();
217
+ };
218
+
219
+ // 暴露方法给外部使用
220
+ defineExpose({
221
+ initData,
222
+ loadTableData,
223
+ showLoading,
224
+ hideLoading,
225
+ });
226
+ </script>
227
+
228
+ <style lang="less" scoped>
229
+ .schema-table {
230
+ display: flex;
231
+ flex: 1;
232
+ flex-direction: column;
233
+ overflow: auto;
234
+
235
+ .table {
236
+ flex: 1;
237
+ }
238
+
239
+ .pagination {
240
+ margin: 10px 0;
241
+ }
242
+ }
243
+ </style>
@@ -0,0 +1,26 @@
1
+ <template>
2
+ <el-container>
3
+ <el-aside width="200px" class="aside">
4
+ <slot name="menu-content"></slot>
5
+ </el-aside>
6
+ <el-main class="main">
7
+ <slot name="main-content"></slot>
8
+ </el-main>
9
+ </el-container>
10
+ </template>
11
+
12
+ <script setup></script>
13
+
14
+ <style lang="less" scoped>
15
+ .aside {
16
+ border-right: 1px solid #e8e8e8;
17
+ }
18
+
19
+ .main {
20
+ overflow: scroll;
21
+ }
22
+
23
+ :deep(.el-menu) {
24
+ border-right: 0;
25
+ }
26
+ </style>
Binary file