@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.
- package/.eslintignore +3 -0
- package/.eslintrc +67 -0
- package/.gitattributes +1 -0
- package/README.md +2 -3
- package/app/controller/base.js +39 -0
- package/app/controller/project.js +100 -0
- package/app/controller/view.js +21 -0
- package/app/extend/logger.js +36 -0
- package/app/middleware/api-params-verify.js +85 -0
- package/app/middleware/api-sign-verify.js +32 -0
- package/app/middleware/error-handler.js +35 -0
- package/app/middleware/project-handler.js +31 -0
- package/app/middleware.js +40 -0
- package/app/pages/assets/custom.css +11 -0
- package/app/pages/boot.js +50 -0
- package/app/pages/common/curl.js +88 -0
- package/app/pages/common/utils.js +5 -0
- package/app/pages/dashboard/complex-view/header-view/complex-view/sub-menu/sub-menu.vue +28 -0
- package/app/pages/dashboard/complex-view/header-view/header-view.vue +125 -0
- package/app/pages/dashboard/complex-view/iframe-view/iframe-view.vue +48 -0
- package/app/pages/dashboard/complex-view/schema-view/complex-view/search-panel/search-panel.vue +42 -0
- package/app/pages/dashboard/complex-view/schema-view/complex-view/table-panel/table-panel.vue +157 -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 +122 -0
- package/app/pages/dashboard/complex-view/schema-view/components/detail-panel/detail-panel.vue +118 -0
- package/app/pages/dashboard/complex-view/schema-view/components/edit-form/edit-form.vue +150 -0
- package/app/pages/dashboard/complex-view/schema-view/hook/schema.js +184 -0
- package/app/pages/dashboard/complex-view/schema-view/schema-view.vue +120 -0
- package/app/pages/dashboard/complex-view/sider-view/complex-view/sub-menu/sub-menu.vue +30 -0
- package/app/pages/dashboard/complex-view/sider-view/sider-view.vue +132 -0
- package/app/pages/dashboard/dashboard.vue +100 -0
- package/app/pages/dashboard/entry.dashboard.js +52 -0
- package/app/pages/dashboard/readme.md +4 -0
- package/app/pages/store/index.js +5 -0
- package/app/pages/store/menu.js +61 -0
- package/app/pages/store/project.js +18 -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 +105 -0
- package/app/pages/widgets/schema-form/complex-view/input/input.vue +143 -0
- package/app/pages/widgets/schema-form/complex-view/input-number/input-number.vue +143 -0
- package/app/pages/widgets/schema-form/complex-view/select/select.vue +133 -0
- package/app/pages/widgets/schema-form/form-item-config.js +25 -0
- package/app/pages/widgets/schema-form/schema-form.vue +152 -0
- package/app/pages/widgets/schema-search-bar/complex-view/date-range/date-range.vue +63 -0
- package/app/pages/widgets/schema-search-bar/complex-view/dynamic-select/dynamic-select.vue +85 -0
- package/app/pages/widgets/schema-search-bar/complex-view/input/input.vue +59 -0
- package/app/pages/widgets/schema-search-bar/complex-view/select/select.vue +66 -0
- package/app/pages/widgets/schema-search-bar/schema-config.js +30 -0
- package/app/pages/widgets/schema-search-bar/schema-search-bar.vue +145 -0
- package/app/pages/widgets/schema-table/schema-table.vue +275 -0
- package/app/pages/widgets/sider-container/sider-container.vue +29 -0
- package/app/router/project.js +11 -0
- package/app/router/view.js +9 -0
- package/app/router-schema/project.js +55 -0
- package/app/service/base.js +12 -0
- package/app/service/project.js +78 -0
- package/app/view/entry.tpl +29 -0
- package/app/webpack/config/webpack.base.js +223 -0
- package/app/webpack/config/webpack.dev.js +59 -0
- package/app/webpack/config/webpack.prod.js +128 -0
- package/app/webpack/dev.js +60 -0
- package/app/webpack/libs/blank.js +1 -0
- package/app/webpack/prod.js +22 -0
- package/config/config.default.js +4 -0
- package/docs/dashboard-model.js +193 -0
- package/elpis-core/env.js +24 -0
- package/elpis-core/index.js +95 -0
- package/elpis-core/loader/config.js +66 -0
- package/elpis-core/loader/controller.js +74 -0
- package/elpis-core/loader/extend.js +62 -0
- package/elpis-core/loader/middleware.js +74 -0
- package/elpis-core/loader/router-schema.js +50 -0
- package/elpis-core/loader/router.js +50 -0
- package/elpis-core/loader/service.js +69 -0
- package/index.js +48 -0
- package/model/business/model.js +210 -0
- package/model/business/project/jd.js +62 -0
- package/model/business/project/pdd.js +86 -0
- package/model/business/project/taobao.js +45 -0
- package/model/course/model.js +21 -0
- package/model/course/project/bilibili.js +49 -0
- package/model/course/project/douyin.js +29 -0
- package/model/demo.json +246 -0
- package/model/index.js +153 -0
- package/package.json +103 -4
- package/test/controller/project.test.js +220 -0
- package/testmain/project.test.js +228 -0
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<el-drawer
|
|
3
|
+
v-model="isShow"
|
|
4
|
+
direction="rtl"
|
|
5
|
+
:destory-on-close="true"
|
|
6
|
+
:size="550"
|
|
7
|
+
>
|
|
8
|
+
<template #header>
|
|
9
|
+
<h2 class="title">{{ title }}</h2>
|
|
10
|
+
</template>
|
|
11
|
+
<template #default>
|
|
12
|
+
<schema-form
|
|
13
|
+
ref="schemaFormRef"
|
|
14
|
+
:schema="components[name].schema"
|
|
15
|
+
v-loading="loading"
|
|
16
|
+
:model="dtoModel"
|
|
17
|
+
>
|
|
18
|
+
|
|
19
|
+
</schema-form>
|
|
20
|
+
</template>
|
|
21
|
+
<template #footer>
|
|
22
|
+
<el-button type="primary" @click="save">
|
|
23
|
+
{{ saveBtnText }}
|
|
24
|
+
</el-button>
|
|
25
|
+
</template>
|
|
26
|
+
</el-drawer>
|
|
27
|
+
|
|
28
|
+
</template>
|
|
29
|
+
|
|
30
|
+
<script setup>
|
|
31
|
+
import { ref, inject } from 'vue'
|
|
32
|
+
import { ElNotification } from 'element-plus';
|
|
33
|
+
import $curl from '$elpisCommon/curl'
|
|
34
|
+
import schemaForm from '$elpisWidgets/schema-form/schema-form.vue';
|
|
35
|
+
|
|
36
|
+
const {
|
|
37
|
+
api,
|
|
38
|
+
components
|
|
39
|
+
} = inject('schemaViewData')
|
|
40
|
+
|
|
41
|
+
const emit = defineEmits([ 'command' ])
|
|
42
|
+
|
|
43
|
+
// 接收属性, props
|
|
44
|
+
// 释放事件 emit
|
|
45
|
+
// 提供方法 defineExpose
|
|
46
|
+
|
|
47
|
+
// 接收的参数
|
|
48
|
+
// const { components } = 'xxx'
|
|
49
|
+
const name = ref('editForm')
|
|
50
|
+
|
|
51
|
+
const schemaFormRef = ref(null)
|
|
52
|
+
const isShow = ref(false)
|
|
53
|
+
const loading = ref(false)
|
|
54
|
+
const title = ref('')
|
|
55
|
+
const saveBtnText = ref('')
|
|
56
|
+
const mainKey = ref('')
|
|
57
|
+
const mainValue = ref()
|
|
58
|
+
const dtoModel = ref({})
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* components.value[name.value]
|
|
62
|
+
* schema: {
|
|
63
|
+
*
|
|
64
|
+
* },
|
|
65
|
+
config: {
|
|
66
|
+
title: '', // 表单标题
|
|
67
|
+
saveBtnText: '' // 保存按钮文案
|
|
68
|
+
},
|
|
69
|
+
*/
|
|
70
|
+
const show = (rowData) => {
|
|
71
|
+
const { config } = components.value[name.value]
|
|
72
|
+
|
|
73
|
+
title.value = config.title
|
|
74
|
+
saveBtnText.value = config.saveBtnText
|
|
75
|
+
mainKey.value = config.mainKey // 表单主键
|
|
76
|
+
mainValue.value = rowData[config.mainKey] // 表单主键值
|
|
77
|
+
dtoModel.value = {}
|
|
78
|
+
|
|
79
|
+
isShow.value = true
|
|
80
|
+
fetchFormData()
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const fetchFormData = async () => {
|
|
84
|
+
// 防止重复提交
|
|
85
|
+
if (loading.value) return
|
|
86
|
+
loading.value = true
|
|
87
|
+
|
|
88
|
+
const res = await $curl({
|
|
89
|
+
method: 'get',
|
|
90
|
+
url: api.value,
|
|
91
|
+
query: {
|
|
92
|
+
[mainKey.value]: mainValue.value
|
|
93
|
+
}
|
|
94
|
+
})
|
|
95
|
+
loading.value = false
|
|
96
|
+
|
|
97
|
+
if (!res || !res.data || !res.success) return
|
|
98
|
+
dtoModel.value = res.data
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const close = () => {
|
|
102
|
+
isShow.value = false
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const save = async () => {
|
|
106
|
+
if (loading.value) return
|
|
107
|
+
if (!schemaFormRef.value.validate()) return
|
|
108
|
+
loading.value = true
|
|
109
|
+
|
|
110
|
+
const res = await $curl({
|
|
111
|
+
method: 'put',
|
|
112
|
+
url: api.value,
|
|
113
|
+
// dtoObj = {
|
|
114
|
+
// ...dtoObj,
|
|
115
|
+
// {
|
|
116
|
+
// [schemaKey]: dtoValue.value
|
|
117
|
+
// input: dtoValue.value
|
|
118
|
+
// }
|
|
119
|
+
// }
|
|
120
|
+
data: {
|
|
121
|
+
[mainKey.value]: mainValue.value,
|
|
122
|
+
...schemaFormRef.value.getValue()
|
|
123
|
+
}
|
|
124
|
+
})
|
|
125
|
+
|
|
126
|
+
loading.value = false
|
|
127
|
+
if (!res || !res.success) return
|
|
128
|
+
ElNotification({
|
|
129
|
+
title: '修改成功',
|
|
130
|
+
message: '修改成功',
|
|
131
|
+
type: 'success'
|
|
132
|
+
})
|
|
133
|
+
close()
|
|
134
|
+
|
|
135
|
+
emit('command', {
|
|
136
|
+
event: 'loadTableData'
|
|
137
|
+
})
|
|
138
|
+
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
defineExpose({
|
|
142
|
+
name,
|
|
143
|
+
show,
|
|
144
|
+
})
|
|
145
|
+
|
|
146
|
+
</script>
|
|
147
|
+
|
|
148
|
+
<style lang="less" scoped>
|
|
149
|
+
|
|
150
|
+
</style>
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import { ref, watch, onMounted, nextTick } from 'vue'
|
|
2
|
+
import { useMenuStore } from '$elpisStore/menu.js'
|
|
3
|
+
import { useRoute } from 'vue-router'
|
|
4
|
+
|
|
5
|
+
export const useSchema = () => {
|
|
6
|
+
const menuStore = useMenuStore()
|
|
7
|
+
const route = useRoute()
|
|
8
|
+
const api = ref('')
|
|
9
|
+
const tableSchema = ref({}) // table schema
|
|
10
|
+
const tableConfig = ref() // table config
|
|
11
|
+
|
|
12
|
+
const searchSchema = ref({}) // search schema
|
|
13
|
+
const searchConfig = ref() // search config
|
|
14
|
+
|
|
15
|
+
const components = ref({})
|
|
16
|
+
|
|
17
|
+
// 构造 schemaConfig 相关配置,输送给schema-view解析
|
|
18
|
+
const buildData = () => {
|
|
19
|
+
const { key, sider_key: siderKey } = route.query
|
|
20
|
+
// console.log(route.query, 'route.query')
|
|
21
|
+
const mItem = menuStore.findMenuItem({
|
|
22
|
+
key: 'key',
|
|
23
|
+
value: siderKey ?? key
|
|
24
|
+
})
|
|
25
|
+
// console.log(mItem, 'mItem')
|
|
26
|
+
if (mItem && mItem.schemaConfig) {
|
|
27
|
+
const { schemaConfig: sConfig } = mItem
|
|
28
|
+
const configSchema = JSON.parse(JSON.stringify(sConfig.schema ?? {}))
|
|
29
|
+
api.value = sConfig.api ?? ''
|
|
30
|
+
|
|
31
|
+
// 表格
|
|
32
|
+
tableSchema.value = {}
|
|
33
|
+
tableConfig.value = undefined
|
|
34
|
+
|
|
35
|
+
// searchBar
|
|
36
|
+
searchSchema.value = {}
|
|
37
|
+
searchConfig.value = undefined
|
|
38
|
+
|
|
39
|
+
// component
|
|
40
|
+
components.value = {}
|
|
41
|
+
|
|
42
|
+
// console.log(tableSchema.value, 'tableSchema.value')
|
|
43
|
+
// 慢一步再赋值
|
|
44
|
+
nextTick(() => {
|
|
45
|
+
// 构造tableSchema 和 tableConfig
|
|
46
|
+
tableSchema.value = buildDtoSchema(configSchema, 'table')
|
|
47
|
+
// // console.log(tableSchema.value, 'tableSchema.value')
|
|
48
|
+
tableConfig.value = sConfig.tableConfig
|
|
49
|
+
|
|
50
|
+
// // console.log()
|
|
51
|
+
// 构造searchSchema 和 searchConfig
|
|
52
|
+
const dtoSearchSchema = buildDtoSchema(configSchema, 'search')
|
|
53
|
+
// // console.log(dtoSearchSchema, 'dtoSearchSchema')
|
|
54
|
+
// 让搜索框带上路由参数的值
|
|
55
|
+
for (const key in dtoSearchSchema.properties) {
|
|
56
|
+
if (route.query[key] !== undefined) {
|
|
57
|
+
// option 即 searchOption
|
|
58
|
+
dtoSearchSchema.properties[key].option.default = route.query[key]
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
searchSchema.value = dtoSearchSchema
|
|
62
|
+
searchConfig.value = sConfig.searchConfig
|
|
63
|
+
|
|
64
|
+
// 构造 Components = { comkey: { schema, config }}
|
|
65
|
+
/**
|
|
66
|
+
* components: {
|
|
67
|
+
createForm: {
|
|
68
|
+
schema: {},
|
|
69
|
+
config: {},
|
|
70
|
+
|
|
71
|
+
},
|
|
72
|
+
comB: {
|
|
73
|
+
schema: {},
|
|
74
|
+
config: {},
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
*/
|
|
78
|
+
|
|
79
|
+
const { componentConfig } = sConfig
|
|
80
|
+
/**
|
|
81
|
+
* componentConfig: {
|
|
82
|
+
// create-form 表单配置
|
|
83
|
+
createForm: {
|
|
84
|
+
title: '', // 表单标题
|
|
85
|
+
saveBtnText: '' // 保存按钮文案
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
*/
|
|
89
|
+
if (componentConfig && Object.keys(componentConfig).length > 0) {
|
|
90
|
+
const dtoComponents = {}
|
|
91
|
+
for (const comName in componentConfig) {
|
|
92
|
+
dtoComponents[comName] = {
|
|
93
|
+
// 形成option,比如说,这里是处理component的,并且依据 comName ,那就把[comName]Option,变成 option
|
|
94
|
+
schema: buildDtoSchema(configSchema, comName),
|
|
95
|
+
config: componentConfig[comName]
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
components.value = dtoComponents
|
|
99
|
+
}
|
|
100
|
+
})
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// 构建通用schema方法,清除噪音
|
|
105
|
+
// 把只是 search 或者 table用到的option拿出来,其他option去调
|
|
106
|
+
const buildDtoSchema = (_schema, comName) => {
|
|
107
|
+
// // console.log(_schema, comName, '_schema, comName')
|
|
108
|
+
if (!_schema || !_schema.properties) return {}
|
|
109
|
+
const dtoSchema = {
|
|
110
|
+
type: 'object',
|
|
111
|
+
properties: {}
|
|
112
|
+
}
|
|
113
|
+
// 提取有效 schema 信息
|
|
114
|
+
// // console.log('提取有效 schema 信息', _schema.properties, comName)
|
|
115
|
+
for (const key in _schema.properties) {
|
|
116
|
+
// key: key
|
|
117
|
+
const props = _schema.properties[key]
|
|
118
|
+
if (comName === 'search') {
|
|
119
|
+
// // console.log(props, 'props')
|
|
120
|
+
}
|
|
121
|
+
// tableOptions searchBarOptions formOptions
|
|
122
|
+
if (props[`${comName}Option`]) {
|
|
123
|
+
// props[`${comName}Option`]:
|
|
124
|
+
// tableOptions: {
|
|
125
|
+
// ...elTableColumnConfig, // 标准的el-table-column 配置
|
|
126
|
+
// visible: true, // 默认true,(false或不配置时表示不在表单中显示)
|
|
127
|
+
// },
|
|
128
|
+
// 把除去option的属性提取出来,作为dtoSchema的属性
|
|
129
|
+
let dtoProps = {}
|
|
130
|
+
// console.log('------------------', dtoProps)
|
|
131
|
+
for (const pKey in props) { // tableOptions formOptions xxxOptions
|
|
132
|
+
if (pKey.indexOf('Option') < 0) {
|
|
133
|
+
dtoProps[pKey] = props[pKey]
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
// console.log(comName, 'comName')
|
|
137
|
+
if (comName === 'search') {
|
|
138
|
+
// console.log('------------------', dtoProps)
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// 处理 comName Option,将tableOption名字改为option
|
|
142
|
+
dtoProps = Object.assign({}, dtoProps, { option: props[`${comName}Option`] })
|
|
143
|
+
if (comName === 'search') {
|
|
144
|
+
// console.log(dtoProps, 'dtoProps')
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
// 处理 required 字段,针对 componentForm
|
|
149
|
+
// key: product_name、price
|
|
150
|
+
const { required } = _schema
|
|
151
|
+
if (required && required.find(pk => pk === key)) {
|
|
152
|
+
dtoProps.option.required = true
|
|
153
|
+
}
|
|
154
|
+
dtoSchema.properties[key] = dtoProps
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
return dtoSchema
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
watch([
|
|
163
|
+
() => route.query.key,
|
|
164
|
+
() => route.query.sider_key,
|
|
165
|
+
() => menuStore.menuList
|
|
166
|
+
], () => {
|
|
167
|
+
buildData()
|
|
168
|
+
}, {
|
|
169
|
+
deep: true
|
|
170
|
+
})
|
|
171
|
+
|
|
172
|
+
onMounted(() => {
|
|
173
|
+
buildData()
|
|
174
|
+
})
|
|
175
|
+
|
|
176
|
+
return {
|
|
177
|
+
api,
|
|
178
|
+
tableSchema,
|
|
179
|
+
tableConfig,
|
|
180
|
+
searchSchema,
|
|
181
|
+
searchConfig,
|
|
182
|
+
components,
|
|
183
|
+
}
|
|
184
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<el-row class="schema-view">
|
|
3
|
+
<search-panel
|
|
4
|
+
v-if="searchSchema?.properties && Object.keys(searchSchema.properties).length > 0"
|
|
5
|
+
@search="onSearch"
|
|
6
|
+
></search-panel>
|
|
7
|
+
<table-panel
|
|
8
|
+
@operate="onTableOperate"
|
|
9
|
+
ref="tablePanelRef"
|
|
10
|
+
></table-panel>
|
|
11
|
+
<component
|
|
12
|
+
v-for="(item, key) in components"
|
|
13
|
+
:key="key"
|
|
14
|
+
:is="ComponentConfig[key]?.component"
|
|
15
|
+
ref="comListRef"
|
|
16
|
+
@command=" onComponentCommand"
|
|
17
|
+
></component>
|
|
18
|
+
</el-row>
|
|
19
|
+
|
|
20
|
+
</template>
|
|
21
|
+
|
|
22
|
+
<script setup>
|
|
23
|
+
import SearchPanel from './complex-view/search-panel/search-panel.vue'
|
|
24
|
+
import TablePanel from './complex-view/table-panel/table-panel.vue'
|
|
25
|
+
import ComponentConfig from './components/component.config.js'
|
|
26
|
+
import { useSchema } from './hook/schema.js'
|
|
27
|
+
import { ref, provide } from 'vue'
|
|
28
|
+
|
|
29
|
+
const {
|
|
30
|
+
api,
|
|
31
|
+
tableSchema,
|
|
32
|
+
tableConfig,
|
|
33
|
+
searchSchema,
|
|
34
|
+
searchConfig,
|
|
35
|
+
components
|
|
36
|
+
} = useSchema()
|
|
37
|
+
|
|
38
|
+
const apiParams = ref({})
|
|
39
|
+
provide('schemaViewData', {
|
|
40
|
+
api,
|
|
41
|
+
apiParams,
|
|
42
|
+
tableSchema,
|
|
43
|
+
tableConfig,
|
|
44
|
+
searchSchema,
|
|
45
|
+
searchConfig,
|
|
46
|
+
components,
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
const tablePanelRef = ref(null)
|
|
51
|
+
const comListRef = ref([])
|
|
52
|
+
|
|
53
|
+
const onSearch = (searchValObj) => {
|
|
54
|
+
// console.log(searchValObj, 'searchvalObj')
|
|
55
|
+
apiParams.value = searchValObj
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// table事件映射
|
|
59
|
+
// showComponent,delete
|
|
60
|
+
const EventHandlerMap = {
|
|
61
|
+
showComponent: showComponent
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const onTableOperate = ({ btnConfig, rowData }) => {
|
|
65
|
+
/**
|
|
66
|
+
* {
|
|
67
|
+
label: '', // 按钮中文名
|
|
68
|
+
eventKey: '', // 按钮事件名
|
|
69
|
+
eventOption: {
|
|
70
|
+
// 当 eventKey === showConponent
|
|
71
|
+
comName: '',
|
|
72
|
+
// 当eventKey === 'remove'
|
|
73
|
+
params: {
|
|
74
|
+
// paramKey 等于参数的键值,请求api要带的参数
|
|
75
|
+
// rowValueKey 参数值 (当格式为schema:: tableKey,到table中找相应字段
|
|
76
|
+
paramKey: rowValueKey
|
|
77
|
+
}
|
|
78
|
+
}, // 按钮配置
|
|
79
|
+
...elButtonConfig, // 标准 el-button 配置
|
|
80
|
+
}
|
|
81
|
+
*/
|
|
82
|
+
const { eventKey } = btnConfig
|
|
83
|
+
console.log(eventKey, 'onTableOperate eventkey')
|
|
84
|
+
if (EventHandlerMap[eventKey]) {
|
|
85
|
+
EventHandlerMap[eventKey]({ btnConfig, rowData })
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function showComponent({ btnConfig, rowData }) {
|
|
91
|
+
const { comName } = btnConfig.eventOption
|
|
92
|
+
if (!comName) {
|
|
93
|
+
console.log('找不到 com')
|
|
94
|
+
return
|
|
95
|
+
}
|
|
96
|
+
// name 就是组件内定义的变量
|
|
97
|
+
const comRef = comListRef.value.find(item => item.name === comName)
|
|
98
|
+
if (!comRef || typeof comRef.show !== 'function') return
|
|
99
|
+
|
|
100
|
+
comRef.show(rowData)
|
|
101
|
+
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
const onComponentCommand = (data) => {
|
|
105
|
+
const { event } = data
|
|
106
|
+
// 等于说进行 schema-form 操作时(比如保存),要进行一下读取表格操作
|
|
107
|
+
if (event === 'loadTableData') {
|
|
108
|
+
tablePanelRef.value.loadTableData()
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
</script>
|
|
112
|
+
|
|
113
|
+
<style lang="less" scoped>
|
|
114
|
+
.schema-view {
|
|
115
|
+
display: flex;
|
|
116
|
+
flex-direction: column;
|
|
117
|
+
height: 100%;
|
|
118
|
+
width: 100%;
|
|
119
|
+
}
|
|
120
|
+
</style>
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<el-sub-menu :index="menuItem.key">
|
|
3
|
+
<template #title>
|
|
4
|
+
<span>{{ menuItem.name }}</span>
|
|
5
|
+
</template>
|
|
6
|
+
<div
|
|
7
|
+
:key="item.key"
|
|
8
|
+
v-for="item in menuItem.subMenu"
|
|
9
|
+
>
|
|
10
|
+
<sub-menu
|
|
11
|
+
v-if="item.subMenu && item.subMenu.length > 0"
|
|
12
|
+
:menu-item="item"
|
|
13
|
+
></sub-menu>
|
|
14
|
+
<el-menu-item
|
|
15
|
+
v-else
|
|
16
|
+
:index="item.key"
|
|
17
|
+
>
|
|
18
|
+
{{ item.name }}
|
|
19
|
+
</el-menu-item>
|
|
20
|
+
</div>
|
|
21
|
+
</el-sub-menu>
|
|
22
|
+
</template>
|
|
23
|
+
|
|
24
|
+
<script setup>
|
|
25
|
+
const { menuItem } = defineProps(['menuItem'])
|
|
26
|
+
</script>
|
|
27
|
+
|
|
28
|
+
<style lang="less" scoped>
|
|
29
|
+
|
|
30
|
+
</style>
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<sider-container>
|
|
3
|
+
<template #menu-content>
|
|
4
|
+
<el-menu
|
|
5
|
+
:default-active="activeKey"
|
|
6
|
+
:ellipsis="false"
|
|
7
|
+
@select="onMenuSelect"
|
|
8
|
+
>
|
|
9
|
+
<template v-for="item in menuList">
|
|
10
|
+
<!-- group -->
|
|
11
|
+
<sub-menu
|
|
12
|
+
v-if="item.subMenu && item.subMenu.length > 0"
|
|
13
|
+
:menu-item="item"
|
|
14
|
+
></sub-menu>
|
|
15
|
+
<!-- module -->
|
|
16
|
+
<el-menu-item
|
|
17
|
+
v-else
|
|
18
|
+
:index="item.key"
|
|
19
|
+
>
|
|
20
|
+
{{ item.name }}
|
|
21
|
+
</el-menu-item>
|
|
22
|
+
</template>
|
|
23
|
+
</el-menu>
|
|
24
|
+
</template>
|
|
25
|
+
<template #main-content>
|
|
26
|
+
<router-view></router-view>
|
|
27
|
+
</template>
|
|
28
|
+
</sider-container>
|
|
29
|
+
</template>
|
|
30
|
+
|
|
31
|
+
<script setup>
|
|
32
|
+
import { ref, watch, onMounted } from 'vue'
|
|
33
|
+
import { useRoute, useRouter } from 'vue-router'
|
|
34
|
+
import { useMenuStore } from '$elpisStore/menu.js'
|
|
35
|
+
|
|
36
|
+
import SiderContainer from '$elpisWidgets/sider-container/sider-container.vue'
|
|
37
|
+
import SubMenu from './complex-view/sub-menu/sub-menu.vue'
|
|
38
|
+
|
|
39
|
+
const route = useRoute()
|
|
40
|
+
const router = useRouter()
|
|
41
|
+
const menuStore = useMenuStore()
|
|
42
|
+
|
|
43
|
+
const activeKey = ref('')
|
|
44
|
+
const menuList = ref([])
|
|
45
|
+
|
|
46
|
+
const setActiveKey = function () {
|
|
47
|
+
let siderMenuItem = menuStore.findMenuItem({
|
|
48
|
+
key: 'key',
|
|
49
|
+
value: route.query.sider_key,
|
|
50
|
+
})
|
|
51
|
+
// 如果首次加载siderview,sider_key可能为空,导致activeKey为空,无法高亮,需要默认选中第一个
|
|
52
|
+
if (!siderMenuItem) {
|
|
53
|
+
const hMenuItem = menuStore.findMenuItem({
|
|
54
|
+
key: 'key',
|
|
55
|
+
value: route.query.key,
|
|
56
|
+
})
|
|
57
|
+
if (hMenuItem && hMenuItem.siderConfig && hMenuItem.siderConfig.menu) {
|
|
58
|
+
const siderMenuList = hMenuItem.siderConfig.menu
|
|
59
|
+
siderMenuItem = menuStore.findFirstMenuItem(siderMenuList)
|
|
60
|
+
if (siderMenuItem) {
|
|
61
|
+
// TODO处理选中菜单逻辑
|
|
62
|
+
handleMenuSelect(siderMenuItem.key)
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
activeKey.value = siderMenuItem?.key || ''
|
|
67
|
+
console.log(siderMenuItem, 'siderMenuItem')
|
|
68
|
+
}
|
|
69
|
+
const setMenuList = function () {
|
|
70
|
+
const menuItem = menuStore.findMenuItem({
|
|
71
|
+
key: 'key',
|
|
72
|
+
value: route.query.key,
|
|
73
|
+
})
|
|
74
|
+
console.log(menuItem, 'menuItem')
|
|
75
|
+
if (menuItem && menuItem.siderConfig && menuItem.siderConfig.menu) {
|
|
76
|
+
menuList.value = menuItem.siderConfig.menu
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
watch(() => route.query.key, () => {
|
|
81
|
+
setMenuList()
|
|
82
|
+
setActiveKey()
|
|
83
|
+
})
|
|
84
|
+
watch(() => menuStore.menuList, () => {
|
|
85
|
+
setMenuList()
|
|
86
|
+
setActiveKey()
|
|
87
|
+
}, { deep: true })
|
|
88
|
+
const onMenuSelect = function (menuKey) {
|
|
89
|
+
console.log(menuKey, 'menuKey')
|
|
90
|
+
console.log(route.query.sider_key, 'route.query.sider_key')
|
|
91
|
+
handleMenuSelect(menuKey)
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const handleMenuSelect = function (menuKey) {
|
|
95
|
+
// TODO处理选中菜单逻辑
|
|
96
|
+
const menuItem = menuStore.findMenuItem({
|
|
97
|
+
key: 'key',
|
|
98
|
+
value: menuKey,
|
|
99
|
+
})
|
|
100
|
+
|
|
101
|
+
const { moduleType, key, customConfig } = menuItem
|
|
102
|
+
console.log(menuKey, 'handleMenuSelect menuKey')
|
|
103
|
+
console.log(menuItem, 'handleMenuSelect menuItem')
|
|
104
|
+
// 当前页面不处理
|
|
105
|
+
if (key === route.query.sider_key) {
|
|
106
|
+
return
|
|
107
|
+
}
|
|
108
|
+
const pathMap = {
|
|
109
|
+
iframe: '/iframe',
|
|
110
|
+
schema: '/schema',
|
|
111
|
+
custom: customConfig?.path
|
|
112
|
+
}
|
|
113
|
+
router.push({
|
|
114
|
+
path: `/view/dashboard/sider${pathMap[moduleType]}`,
|
|
115
|
+
query: {
|
|
116
|
+
key: route.query.key,
|
|
117
|
+
sider_key: key,
|
|
118
|
+
proj_key: route.query.proj_key,
|
|
119
|
+
}
|
|
120
|
+
})
|
|
121
|
+
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
onMounted(() => {
|
|
125
|
+
setMenuList()
|
|
126
|
+
setActiveKey()
|
|
127
|
+
})
|
|
128
|
+
</script>
|
|
129
|
+
|
|
130
|
+
<style lang="less" scoped>
|
|
131
|
+
|
|
132
|
+
</style>
|