@zhangnpm302/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 (88) hide show
  1. package/.eslintignore +3 -0
  2. package/.eslintrc +67 -0
  3. package/.gitattributes +1 -0
  4. package/README.md +2 -3
  5. package/app/controller/base.js +39 -0
  6. package/app/controller/project.js +100 -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 +85 -0
  10. package/app/middleware/api-sign-verify.js +32 -0
  11. package/app/middleware/error-handler.js +35 -0
  12. package/app/middleware/project-handler.js +31 -0
  13. package/app/middleware.js +40 -0
  14. package/app/pages/assets/custom.css +11 -0
  15. package/app/pages/boot.js +50 -0
  16. package/app/pages/common/curl.js +88 -0
  17. package/app/pages/common/utils.js +5 -0
  18. package/app/pages/dashboard/complex-view/header-view/complex-view/sub-menu/sub-menu.vue +28 -0
  19. package/app/pages/dashboard/complex-view/header-view/header-view.vue +125 -0
  20. package/app/pages/dashboard/complex-view/iframe-view/iframe-view.vue +48 -0
  21. package/app/pages/dashboard/complex-view/schema-view/complex-view/search-panel/search-panel.vue +42 -0
  22. package/app/pages/dashboard/complex-view/schema-view/complex-view/table-panel/table-panel.vue +157 -0
  23. package/app/pages/dashboard/complex-view/schema-view/components/component.config.js +24 -0
  24. package/app/pages/dashboard/complex-view/schema-view/components/create-form/create-form.vue +122 -0
  25. package/app/pages/dashboard/complex-view/schema-view/components/detail-panel/detail-panel.vue +118 -0
  26. package/app/pages/dashboard/complex-view/schema-view/components/edit-form/edit-form.vue +150 -0
  27. package/app/pages/dashboard/complex-view/schema-view/hook/schema.js +184 -0
  28. package/app/pages/dashboard/complex-view/schema-view/schema-view.vue +120 -0
  29. package/app/pages/dashboard/complex-view/sider-view/complex-view/sub-menu/sub-menu.vue +30 -0
  30. package/app/pages/dashboard/complex-view/sider-view/sider-view.vue +132 -0
  31. package/app/pages/dashboard/dashboard.vue +100 -0
  32. package/app/pages/dashboard/entry.dashboard.js +52 -0
  33. package/app/pages/dashboard/readme.md +4 -0
  34. package/app/pages/store/index.js +5 -0
  35. package/app/pages/store/menu.js +61 -0
  36. package/app/pages/store/project.js +18 -0
  37. package/app/pages/widgets/header-container/asserts/avatar.png +0 -0
  38. package/app/pages/widgets/header-container/asserts/logo.png +0 -0
  39. package/app/pages/widgets/header-container/header-container.vue +105 -0
  40. package/app/pages/widgets/schema-form/complex-view/input/input.vue +143 -0
  41. package/app/pages/widgets/schema-form/complex-view/input-number/input-number.vue +143 -0
  42. package/app/pages/widgets/schema-form/complex-view/select/select.vue +133 -0
  43. package/app/pages/widgets/schema-form/form-item-config.js +25 -0
  44. package/app/pages/widgets/schema-form/schema-form.vue +152 -0
  45. package/app/pages/widgets/schema-search-bar/complex-view/date-range/date-range.vue +63 -0
  46. package/app/pages/widgets/schema-search-bar/complex-view/dynamic-select/dynamic-select.vue +85 -0
  47. package/app/pages/widgets/schema-search-bar/complex-view/input/input.vue +59 -0
  48. package/app/pages/widgets/schema-search-bar/complex-view/select/select.vue +66 -0
  49. package/app/pages/widgets/schema-search-bar/schema-config.js +30 -0
  50. package/app/pages/widgets/schema-search-bar/schema-search-bar.vue +145 -0
  51. package/app/pages/widgets/schema-table/schema-table.vue +275 -0
  52. package/app/pages/widgets/sider-container/sider-container.vue +29 -0
  53. package/app/router/project.js +11 -0
  54. package/app/router/view.js +9 -0
  55. package/app/router-schema/project.js +55 -0
  56. package/app/service/base.js +12 -0
  57. package/app/service/project.js +78 -0
  58. package/app/view/entry.tpl +29 -0
  59. package/app/webpack/config/webpack.base.js +223 -0
  60. package/app/webpack/config/webpack.dev.js +59 -0
  61. package/app/webpack/config/webpack.prod.js +128 -0
  62. package/app/webpack/dev.js +60 -0
  63. package/app/webpack/libs/blank.js +1 -0
  64. package/app/webpack/prod.js +22 -0
  65. package/config/config.default.js +4 -0
  66. package/docs/dashboard-model.js +193 -0
  67. package/elpis-core/env.js +24 -0
  68. package/elpis-core/index.js +95 -0
  69. package/elpis-core/loader/config.js +66 -0
  70. package/elpis-core/loader/controller.js +74 -0
  71. package/elpis-core/loader/extend.js +62 -0
  72. package/elpis-core/loader/middleware.js +74 -0
  73. package/elpis-core/loader/router-schema.js +50 -0
  74. package/elpis-core/loader/router.js +50 -0
  75. package/elpis-core/loader/service.js +69 -0
  76. package/index.js +48 -0
  77. package/model/business/model.js +210 -0
  78. package/model/business/project/jd.js +62 -0
  79. package/model/business/project/pdd.js +86 -0
  80. package/model/business/project/taobao.js +45 -0
  81. package/model/course/model.js +21 -0
  82. package/model/course/project/bilibili.js +49 -0
  83. package/model/course/project/douyin.js +29 -0
  84. package/model/demo.json +246 -0
  85. package/model/index.js +153 -0
  86. package/package.json +103 -4
  87. package/test/controller/project.test.js +220 -0
  88. package/testmain/project.test.js +228 -0
@@ -0,0 +1,133 @@
1
+ <template>
2
+ <el-row type="flex" align="middle" class="form-item">
3
+ <!-- label -->
4
+ <el-row class="item-label" justify="end">
5
+ <el-row
6
+ v-if="schema.option?.required"
7
+ type="flex"
8
+ class="required"
9
+ >*</el-row>
10
+ {{ schema.label }}
11
+ </el-row>
12
+ <!-- value -->
13
+ <el-row class="item-value">
14
+ <el-select
15
+ v-model="dtoValue"
16
+ v-bind="schema.option"
17
+ class="component"
18
+ :class="validTips ? 'valid-border' : ''"
19
+ @change="onChange"
20
+ >
21
+ <el-option
22
+ v-for="item in schema.option?.enumList"
23
+ :key="item.value"
24
+ :label="item.label"
25
+ :value="item.value"
26
+ >
27
+
28
+ </el-option>
29
+ </el-select>
30
+ </el-row>
31
+ <!-- 呈现错误信息 -->
32
+ <el-row v-if="validTips" class="valid-tips">
33
+ {{ validTips }}
34
+ </el-row>
35
+ </el-row>
36
+ </template>
37
+
38
+ <script setup>
39
+ import { ref, toRefs, watch, onMounted, inject } from 'vue'
40
+ const ajv = inject('ajv')
41
+ const props = defineProps({
42
+ schemaKey: String,
43
+ schema: Object,
44
+ model: null
45
+ })
46
+
47
+ const { schemaKey, schema } = props
48
+ const { model } = toRefs(props)
49
+
50
+ const name = ref('select')
51
+ // dtoValue最好改成undefined
52
+ const dtoValue = ref()
53
+ const validTips = ref('')
54
+
55
+
56
+ const initData = () => {
57
+ dtoValue.value = model.value ?? schema.option?.default
58
+ validTips.value = null
59
+
60
+ }
61
+
62
+ onMounted(() => {
63
+ initData()
64
+ })
65
+
66
+ watch([model, schema], () => {
67
+ initData()
68
+ }, { deep: true })
69
+
70
+
71
+
72
+ // 便于父组件 遍历 validate 方法
73
+ const validate = () => {
74
+ validTips.value = null
75
+ // const { type } = schema
76
+ // 校验是否必填
77
+ if (schema.option?.required && !dtoValue.value) {
78
+ validTips.value = '不能为空'
79
+ return false
80
+ }
81
+
82
+ // enumList: [{
83
+ // label: '',
84
+ // value: ''
85
+ // }]
86
+
87
+ // ajv 校验 schema
88
+ if (dtoValue.value) {
89
+ // 处理
90
+ let dtoEnum = []
91
+ if (schema.option?.enumList) {
92
+ dtoEnum = schema.option?.enumList.map(item => item.value)
93
+ }
94
+ const validate = ajv.compile({
95
+ schema,
96
+ ... { enum: dtoEnum }
97
+ })
98
+ const valid = validate(dtoValue.value)
99
+ if (!valid && validate.errors && validate.errors[0]) {
100
+ if (validate.errors[0].keyword === 'enum') {
101
+ validTips.value = '取值超出枚举范围'
102
+ } else {
103
+ console.log(validate.errors[0])
104
+ validTips.value = '不符合要求'
105
+ }
106
+ return false
107
+ }
108
+ }
109
+ return true
110
+ }
111
+
112
+ const getValue = () => {
113
+ return dtoValue.value !== undefined ? {
114
+ [schemaKey]: dtoValue.value
115
+ } : {}
116
+ }
117
+
118
+
119
+ const onChange = () => {
120
+
121
+ }
122
+ defineExpose({
123
+ name,
124
+ validate,
125
+ getValue
126
+ })
127
+ </script>
128
+
129
+ <style lang="less" scoped>
130
+ :deep(.el-input-number .el-input__inner ) {
131
+ text-align: left;
132
+ }
133
+ </style>
@@ -0,0 +1,25 @@
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
+
8
+ // 组件间的关系
9
+ const FormItemConfig = {
10
+ input: {
11
+ component: input
12
+ },
13
+ inputNumber: {
14
+ component: inputNumber
15
+ },
16
+ select: {
17
+ component: select
18
+ },
19
+ }
20
+
21
+ // 如遇同名拓展,外面覆盖里面
22
+ export default {
23
+ ...FormItemConfig,
24
+ ...BusinessFormItemConfig
25
+ }
@@ -0,0 +1,152 @@
1
+ <template>
2
+ <el-row
3
+ v-if="schema && schema.properties"
4
+ class="schema-form"
5
+ >
6
+ <template
7
+ v-for="(itemSchema, key) in schema.properties"
8
+ >
9
+ <component
10
+ v-show="itemSchema.option.visible !== false"
11
+ ref="formComList"
12
+ :is="FormItemConfig[itemSchema.option?.comType]?.component"
13
+ :schemaKey="key"
14
+ :schema="itemSchema"
15
+ :model="model ? model[key] : undefined"
16
+ ></component>
17
+ </template>
18
+ </el-row>
19
+ </template>
20
+
21
+ <script setup>
22
+ // 接收的属性
23
+ // 返回什么事件
24
+ // 暴露什么方法
25
+ import { ref, toRefs, provide } from 'vue'
26
+ import FormItemConfig from './form-item-config';
27
+
28
+ console.log(FormItemConfig, 'FormItemConfig')
29
+ // 为避免重复new ajv,所以在父组件new 一次 ajv
30
+ const Ajv = require('ajv')
31
+ const ajv = new Ajv()
32
+
33
+ provide('ajv', ajv)
34
+
35
+
36
+ const props = defineProps({
37
+ // 渲染内容
38
+ /**
39
+ * schema 配置结构如下
40
+ * schema: {
41
+ type: 'object',
42
+ properties: {
43
+ key1: {
44
+ ...schema, // 继承标准schema
45
+ type: '', // 字段类型
46
+ label: '', // 字段名称
47
+ // 字段在不同动态 component 中的相关配置,前缀对应 componentConfig 中的键值
48
+ // 如 componentConfig.createForm ,这里对应 createFormOption
49
+
50
+ option: {
51
+ ...eleComponentConfig, // 标准 el-component 配置
52
+ comType: '', // 控件类型,input/select/input-number
53
+ required: false, //
54
+ visible: true, // 是否展示 (true/false),默认为true
55
+ disabled: false, // 是否禁用 ,默认false
56
+ default: '', // 默认值
57
+
58
+ // comType === select 生效
59
+ enumList: [], // 枚举列表
60
+
61
+ },
62
+ },
63
+ },
64
+ },
65
+ */
66
+ schema: Object,
67
+ /**
68
+ * 表单数据
69
+ */
70
+ model: Object,
71
+ })
72
+
73
+ const { schema } = toRefs(props)
74
+
75
+ const formComList = ref([])
76
+ // 事件
77
+ const validate = () => {
78
+ return formComList.value.every(component => {
79
+ const result = component.validate()
80
+ console.log(component.name, result)
81
+ return result
82
+ })
83
+ }
84
+
85
+ // 获取表单值
86
+ const getValue = () => {
87
+ let dtoObj = {}
88
+
89
+ formComList.value.forEach(component => {
90
+ dtoObj = {
91
+ ...dtoObj,
92
+ ...component.getValue()
93
+ }
94
+ })
95
+
96
+ return dtoObj
97
+ }
98
+
99
+
100
+ defineExpose({
101
+ validate,
102
+ getValue
103
+ })
104
+ </script>
105
+
106
+ <style lang="less">
107
+ .schema-form {
108
+ .form-item {
109
+ margin-bottom: 20px;
110
+ min-width: 500px;
111
+ .item-label {
112
+ margin-right: 15px;
113
+ min-width: 70px;
114
+ text-align: right;
115
+ font-size: 14px;
116
+ color: #ffffff;
117
+ word-break: break-all;
118
+ .required {
119
+ top: 2px;
120
+ padding-left: 4px;
121
+ color: #f56c6c;
122
+ font-size: 20px;
123
+ }
124
+ }
125
+
126
+ .item-value {
127
+ .component {
128
+ width: 320px;
129
+ }
130
+ .valid-border {
131
+ .el-input__wrapper {
132
+ border: 1px solid #f93f3f;
133
+ box-shadow: 0 0 0 0;
134
+ }
135
+ .el-select__wrapper {
136
+ border: 1px solid #f93f3f;
137
+ box-shadow: 0 0 0 0;
138
+ }
139
+ }
140
+ }
141
+
142
+ .valid-tips {
143
+ margin-left: 10px;
144
+ height: 36px;
145
+ line-height: 36px;
146
+ overflow: hidden;
147
+ font-size: 12px;
148
+ color: f93f3f;
149
+ }
150
+ }
151
+ }
152
+ </style>
@@ -0,0 +1,63 @@
1
+
2
+ <template>
3
+ <el-date-picker
4
+ v-model="dtoValue"
5
+ v-bind="schema.option"
6
+ type="daterange"
7
+ range-separator="至"
8
+ :start-placeholder="schema.label + '(开始)'"
9
+ :end-placeholder="schema.label + '(结束)'"
10
+ class="date-range"
11
+ ></el-date-picker>
12
+ </template>
13
+
14
+ <script setup>
15
+ import { ref, onMounted } from 'vue'
16
+ import moment from 'moment';
17
+
18
+ const { schemaKey, schema } = defineProps({
19
+ schemaKey: String,
20
+ /**
21
+ *
22
+ * key2: {
23
+ ...schema, // 继承标准schema
24
+ type: '', // 字段类型
25
+ label: '', // 字段名称
26
+ // 字段在table的相关配置
27
+ otions: {
28
+ ...eleComponentConfig,
29
+ comType: '', // 配置控件类型 input/select/,
30
+ default: '', // 默认值
31
+
32
+ },
33
+ },
34
+ */
35
+ schema: Object
36
+ })
37
+
38
+ const emit = defineEmits([ 'loaded' ])
39
+
40
+ const dtoValue = ref([])
41
+ const getValue = () => {
42
+ return dtoValue.value?.length === 2 ? {
43
+ [`${schemaKey}_start`] : moment(dtoValue.value[0]).format('YYYY-MM-DD'),
44
+ [`${schemaKey}_end`] : moment(dtoValue.value[1]).format('YYYY-MM-DD'),
45
+ } : {}
46
+ }
47
+
48
+ const reset = () => {
49
+ dtoValue.value = []
50
+ }
51
+ // 监听每一个子组件的loaded
52
+ onMounted(() => {
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,85 @@
1
+
2
+ <template>
3
+ <el-select
4
+ v-model="dtoValue"
5
+ v-bind="schema.option"
6
+ class="dynamic-select"
7
+ >
8
+ <el-option
9
+ v-for="item in enumList"
10
+ :key="item.value"
11
+ :label="item.label"
12
+ :value="item.value"
13
+ >
14
+
15
+ </el-option>
16
+ </el-select>
17
+ </template>
18
+
19
+ <script setup>
20
+ import { ref, onMounted } from 'vue'
21
+ import $curl from '$elpisCommon/curl'
22
+ const { schemaKey, schema } = defineProps({
23
+ schemaKey: String,
24
+ /**
25
+ *
26
+ * key2: {
27
+ ...schema, // 继承标准schema
28
+ type: '', // 字段类型
29
+ label: '', // 字段名称
30
+ // 字段在table的相关配置
31
+ otions: {
32
+ ...eleComponentConfig,
33
+ comType: '', // 配置控件类型 input/select/,
34
+ default: '', // 默认值
35
+
36
+ },
37
+ },
38
+ */
39
+ schema: Object
40
+ })
41
+ const emit = defineEmits([ 'loaded' ])
42
+
43
+ // 1.为什么这里定义初始值要用undefined?
44
+ const dtoValue = ref()
45
+ const getValue = () => {
46
+ return dtoValue.value !== undefined ? {
47
+ [schemaKey]: dtoValue.value
48
+ }: {}
49
+ }
50
+ const enumList = ref([])
51
+
52
+ const reset = () => {
53
+ dtoValue.value = schema?.option?.default ?? enumList.value[0].value
54
+ }
55
+
56
+
57
+ // 获取动态列表
58
+ const fetchEnumList = async () => {
59
+ const res = await $curl({
60
+ method: 'get',
61
+ url: schema.option?.api,
62
+ data: {}
63
+ })
64
+
65
+ if (res?.data?.length > 0) {
66
+ enumList.value.push(...res?.data)
67
+ }
68
+ }
69
+
70
+ // 监听每一个子组件的loaded
71
+ onMounted(async () => {
72
+ await fetchEnumList()
73
+ reset()
74
+ emit('loaded')
75
+ })
76
+
77
+
78
+
79
+ defineExpose({
80
+ getValue,
81
+ reset
82
+ })
83
+ </script>
84
+
85
+ <style lang="less" scoped></style>
@@ -0,0 +1,59 @@
1
+ <template>
2
+ <el-input
3
+ v-model="dtoValue"
4
+ v-bind="schema.option"
5
+ class="input"
6
+ >
7
+
8
+ </el-input>
9
+ </template>
10
+
11
+ <script setup>
12
+ import { ref, onMounted } from 'vue'
13
+ const { schemaKey, schema } = defineProps({
14
+ schemaKey: String,
15
+ /**
16
+ *
17
+ * key2: {
18
+ ...schema, // 继承标准schema
19
+ type: '', // 字段类型
20
+ label: '', // 字段名称
21
+ // 字段在table的相关配置
22
+ otions: {
23
+ ...eleComponentConfig,
24
+ comType: '', // 配置控件类型 input/select/,
25
+ default: '', // 默认值
26
+
27
+ },
28
+ },
29
+ */
30
+ schema: Object
31
+ })
32
+ // product_name
33
+ const emit = defineEmits([ 'loaded' ])
34
+
35
+ // 1.为什么这里定义初始值要用undefined?
36
+ const dtoValue = ref()
37
+ const getValue = () => {
38
+ return dtoValue.value !== undefined ? {
39
+ [schemaKey]: dtoValue.value
40
+ }: {}
41
+ }
42
+
43
+ const reset = () => {
44
+ dtoValue.value = schema?.option?.default
45
+ }
46
+
47
+ // 监听每一个子组件的loaded
48
+ onMounted(() => {
49
+ reset()
50
+ emit('loaded')
51
+ })
52
+
53
+ defineExpose({
54
+ getValue,
55
+ reset
56
+ })
57
+ </script>
58
+
59
+ <style lang="less" scoped></style>
@@ -0,0 +1,66 @@
1
+
2
+ <template>
3
+ <el-select
4
+ v-model="dtoValue"
5
+ v-bind="schema.option"
6
+ class="select"
7
+ >
8
+ <el-option
9
+ v-for="item in schema.option?.enumList"
10
+ :key="item.value"
11
+ :label="item.label"
12
+ :value="item.value"
13
+ >
14
+
15
+ </el-option>
16
+ </el-select>
17
+ </template>
18
+
19
+ <script setup>
20
+ import { ref, onMounted } from 'vue'
21
+ const { schemaKey, schema } = defineProps({
22
+ schemaKey: String,
23
+ /**
24
+ *
25
+ * key2: {
26
+ ...schema, // 继承标准schema
27
+ type: '', // 字段类型
28
+ label: '', // 字段名称
29
+ // 字段在table的相关配置
30
+ otions: {
31
+ ...eleComponentConfig,
32
+ comType: '', // 配置控件类型 input/select/,
33
+ default: '', // 默认值
34
+
35
+ },
36
+ },
37
+ */
38
+ schema: Object
39
+ })
40
+ const emit = defineEmits([ 'loaded' ])
41
+
42
+ // 1.为什么这里定义初始值要用undefined?
43
+ const dtoValue = ref()
44
+ const getValue = () => {
45
+ return dtoValue.value !== undefined ? {
46
+ [schemaKey]: dtoValue.value
47
+ }: {}
48
+ }
49
+
50
+ const reset = () => {
51
+ dtoValue.value = schema?.option?.default ?? schema.option.enumList[0].value
52
+ }
53
+
54
+ // 监听每一个子组件的loaded
55
+ onMounted(() => {
56
+ reset()
57
+ emit('loaded')
58
+ })
59
+
60
+ defineExpose({
61
+ getValue,
62
+ reset
63
+ })
64
+ </script>
65
+
66
+ <style lang="less" scoped></style>
@@ -0,0 +1,30 @@
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
+ // 业务拓展
7
+ // search-item 配置
8
+ import BusinessSearchItemConfig from '$BusinessSearchItemConfig'
9
+
10
+ const SearchItemConfig = {
11
+ input: {
12
+ component: input
13
+ },
14
+ select: {
15
+ component: select
16
+ },
17
+ dynamicSelect: {
18
+ component: dynamicSelect
19
+ },
20
+ dateRange: {
21
+ component: dateRange
22
+ },
23
+ }
24
+
25
+ export default {
26
+ ...SearchItemConfig,
27
+ ...BusinessSearchItemConfig
28
+
29
+ }
30
+