@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,28 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<el-sub-menu :index="menuItem.key">
|
|
3
|
+
<template #title>
|
|
4
|
+
{{ menuItem.name }}
|
|
5
|
+
</template>
|
|
6
|
+
<div :key="item.key" v-for="item in menuItem.subMenu">
|
|
7
|
+
<sub-menu
|
|
8
|
+
v-if="item.subMenu && item.subMenu.length > 0"
|
|
9
|
+
:menuItem="item"
|
|
10
|
+
>
|
|
11
|
+
|
|
12
|
+
</sub-menu>
|
|
13
|
+
<el-menu-item
|
|
14
|
+
v-else
|
|
15
|
+
:index="item.key"
|
|
16
|
+
>
|
|
17
|
+
{{ item.name }}
|
|
18
|
+
</el-menu-item>
|
|
19
|
+
</div>
|
|
20
|
+
</el-sub-menu>
|
|
21
|
+
|
|
22
|
+
</template>
|
|
23
|
+
|
|
24
|
+
<script setup>
|
|
25
|
+
const { menuItem } = defineProps([ 'menuItem' ])
|
|
26
|
+
</script>
|
|
27
|
+
|
|
28
|
+
<style lang="less" scoped></style>
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<header-container :title="projName">
|
|
3
|
+
<template #menu-content>
|
|
4
|
+
<!-- 根据menuStore.menuList渲染 -->
|
|
5
|
+
<el-menu
|
|
6
|
+
:default-active="activeKey"
|
|
7
|
+
:ellipsis="false"
|
|
8
|
+
mode="horizontal"
|
|
9
|
+
@select="onMenuSelect"
|
|
10
|
+
>
|
|
11
|
+
<template v-for="item in menuStore.menuList">
|
|
12
|
+
<sub-menu
|
|
13
|
+
v-if="item.subMenu && item.subMenu.length > 0"
|
|
14
|
+
:menuItem="item"
|
|
15
|
+
>
|
|
16
|
+
|
|
17
|
+
</sub-menu>
|
|
18
|
+
<el-menu-item
|
|
19
|
+
v-else
|
|
20
|
+
:index="item.key"
|
|
21
|
+
>
|
|
22
|
+
{{ item.name }}
|
|
23
|
+
</el-menu-item>
|
|
24
|
+
</template>
|
|
25
|
+
</el-menu>
|
|
26
|
+
</template>
|
|
27
|
+
<template #setting-content>
|
|
28
|
+
<!-- 根据projectStore.projectList 渲染 -->
|
|
29
|
+
<el-dropdown @command="handleProjectCommand">
|
|
30
|
+
<span class="project-list">
|
|
31
|
+
{{ projName }}
|
|
32
|
+
<el-icon v-if="projectStore.projectList.length > 1" class="el-icon--right">
|
|
33
|
+
<ArrowDown />
|
|
34
|
+
</el-icon>
|
|
35
|
+
</span>
|
|
36
|
+
<template v-if="projectStore.projectList.length > 1" #dropdown>
|
|
37
|
+
<el-dropdown-menu>
|
|
38
|
+
<el-dropdown-item
|
|
39
|
+
v-for="item in projectStore.projectList"
|
|
40
|
+
:key="item.key"
|
|
41
|
+
:command="item.key"
|
|
42
|
+
:disabled="item.name === projName"
|
|
43
|
+
>
|
|
44
|
+
{{ item.name }}
|
|
45
|
+
</el-dropdown-item>
|
|
46
|
+
</el-dropdown-menu>
|
|
47
|
+
</template>
|
|
48
|
+
|
|
49
|
+
</el-dropdown>
|
|
50
|
+
</template>
|
|
51
|
+
<template #main-content>
|
|
52
|
+
<slot name="main-content"></slot>
|
|
53
|
+
</template>
|
|
54
|
+
</header-container>
|
|
55
|
+
</template>
|
|
56
|
+
<script setup>
|
|
57
|
+
import { ref, watch, onMounted } from 'vue'
|
|
58
|
+
import { useRoute } from 'vue-router'
|
|
59
|
+
import { ArrowDown } from '@element-plus/icons-vue'
|
|
60
|
+
import HeaderContainer from '$elpisWidgets/header-container/header-container.vue'
|
|
61
|
+
import SubMenu from './complex-view/sub-menu/sub-menu.vue'
|
|
62
|
+
import { useMenuStore } from '$elpisStore/menu.js'
|
|
63
|
+
import { useProjectStore } from '$elpisStore/project.js'
|
|
64
|
+
|
|
65
|
+
const route = useRoute()
|
|
66
|
+
// console.log(route, 'route')
|
|
67
|
+
const menuStore = useMenuStore()
|
|
68
|
+
const projectStore = useProjectStore()
|
|
69
|
+
|
|
70
|
+
defineProps({
|
|
71
|
+
projName: String
|
|
72
|
+
})
|
|
73
|
+
|
|
74
|
+
const emit = defineEmits([ 'menu-select' ])
|
|
75
|
+
const activeKey = ref('')
|
|
76
|
+
|
|
77
|
+
watch(() => route.query.key, () => setActiveKey())
|
|
78
|
+
watch(() => menuStore.menuList, () => setActiveKey())
|
|
79
|
+
|
|
80
|
+
onMounted(() => {
|
|
81
|
+
setActiveKey()
|
|
82
|
+
})
|
|
83
|
+
const setActiveKey = function() {
|
|
84
|
+
const menuItem = menuStore.findMenuItem({
|
|
85
|
+
key: 'key',
|
|
86
|
+
value: route.query.key
|
|
87
|
+
})
|
|
88
|
+
activeKey.value = menuItem?.key
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const onMenuSelect = function(menuKey) {
|
|
92
|
+
const menuItem = menuStore.findMenuItem({
|
|
93
|
+
key: 'key',
|
|
94
|
+
value: menuKey
|
|
95
|
+
})
|
|
96
|
+
emit('menu-select', menuItem)
|
|
97
|
+
}
|
|
98
|
+
const handleProjectCommand = function(event) {
|
|
99
|
+
const projectItem = projectStore.projectList.find(item => item.key === event)
|
|
100
|
+
|
|
101
|
+
if (!projectItem || !projectItem.homePage) return
|
|
102
|
+
|
|
103
|
+
// hash模式请求
|
|
104
|
+
// const { origin, pathname } = window.location
|
|
105
|
+
// window.location.replace(`${origin}${pathname}#${projectItem.homePage}`)
|
|
106
|
+
// window.location.reload()
|
|
107
|
+
const { host } = window.location
|
|
108
|
+
window.location.replace(`http://${host}/view/dashboard${projectItem.homePage}`)
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
</script>
|
|
112
|
+
<style lang="less" scoped>
|
|
113
|
+
.project-list {
|
|
114
|
+
margin-right: 20px;
|
|
115
|
+
cursor: pointer;
|
|
116
|
+
color: var(--el-color-primary);
|
|
117
|
+
display: flex;
|
|
118
|
+
align-items: center;
|
|
119
|
+
outline: none;
|
|
120
|
+
}
|
|
121
|
+
:deep(.el-menu--horizontal.el-menu) {
|
|
122
|
+
// border-bottom: 0;
|
|
123
|
+
border-bottom: 1px solid;
|
|
124
|
+
}
|
|
125
|
+
</style>
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<iframe :src="path" class="iframe"></iframe>
|
|
3
|
+
</template>
|
|
4
|
+
|
|
5
|
+
<script setup>
|
|
6
|
+
import { ref, watch, onMounted } from 'vue'
|
|
7
|
+
import { useRoute } from 'vue-router'
|
|
8
|
+
import {useMenuStore} from '$elpisStore/menu.js'
|
|
9
|
+
|
|
10
|
+
const route = useRoute()
|
|
11
|
+
const menuStore = useMenuStore()
|
|
12
|
+
|
|
13
|
+
const path = ref('')
|
|
14
|
+
const setPath = function () {
|
|
15
|
+
const { key, sider_key: siderKey } = route.query
|
|
16
|
+
const menuItem = menuStore.findMenuItem({
|
|
17
|
+
key: 'key',
|
|
18
|
+
// 应该是层级不一样
|
|
19
|
+
value: siderKey ?? key,
|
|
20
|
+
})
|
|
21
|
+
// 找到这个item
|
|
22
|
+
path.value = menuItem?.iframeConfig?.path ?? ''
|
|
23
|
+
}
|
|
24
|
+
watch(
|
|
25
|
+
[
|
|
26
|
+
() => route.query.key,
|
|
27
|
+
() => route.query.sider_key,
|
|
28
|
+
() => menuStore.menuList
|
|
29
|
+
],
|
|
30
|
+
() => {
|
|
31
|
+
setPath()
|
|
32
|
+
},
|
|
33
|
+
// 监听menuList深度改变
|
|
34
|
+
{ deep: true }
|
|
35
|
+
)
|
|
36
|
+
onMounted(() => {
|
|
37
|
+
setPath()
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
</script>
|
|
41
|
+
|
|
42
|
+
<style lang="less" scoped>
|
|
43
|
+
.iframe {
|
|
44
|
+
width: 100%;
|
|
45
|
+
height: 100%;
|
|
46
|
+
border: none;
|
|
47
|
+
}
|
|
48
|
+
</style>
|
package/app/pages/dashboard/complex-view/schema-view/complex-view/search-panel/search-panel.vue
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<el-card class="search-panel">
|
|
3
|
+
<schema-search-bar
|
|
4
|
+
:schema="searchSchema"
|
|
5
|
+
@load="onLoad"
|
|
6
|
+
@search="onSearch"
|
|
7
|
+
@reset="onReset"
|
|
8
|
+
></schema-search-bar>
|
|
9
|
+
</el-card>
|
|
10
|
+
</template>
|
|
11
|
+
|
|
12
|
+
<script setup>
|
|
13
|
+
import { inject } from 'vue'
|
|
14
|
+
import SchemaSearchBar from '$elpisWidgets/schema-search-bar/schema-search-bar.vue';
|
|
15
|
+
|
|
16
|
+
const { searchSchema } = inject('schemaViewData')
|
|
17
|
+
const emit = defineEmits([ 'search' ])
|
|
18
|
+
|
|
19
|
+
const onLoad = (searchValObj) => {
|
|
20
|
+
// 再抛到schemaView上
|
|
21
|
+
emit('search', searchValObj)
|
|
22
|
+
}
|
|
23
|
+
const onSearch = (searchValObj) => {
|
|
24
|
+
emit('search', searchValObj)
|
|
25
|
+
}
|
|
26
|
+
const onReset = () => {
|
|
27
|
+
emit('search', {})
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
</script>
|
|
31
|
+
|
|
32
|
+
<style lang="less" scoped>
|
|
33
|
+
.search-panel {
|
|
34
|
+
margin: 10px 10px 0 10px;
|
|
35
|
+
}
|
|
36
|
+
.el-card {
|
|
37
|
+
:deep(.el-card__body) {
|
|
38
|
+
padding-bottom: 2px;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
</style>
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<el-card class="table-panel">
|
|
3
|
+
<!-- operation-panel -->
|
|
4
|
+
<!-- headerButtons: [{
|
|
5
|
+
label: '', // 按钮中文名
|
|
6
|
+
eventKey: '', // 按钮事件名
|
|
7
|
+
eventOption: {}, // 按钮配置
|
|
8
|
+
...elButtonConfig, // 标准 el-button 配置
|
|
9
|
+
}, ...] -->
|
|
10
|
+
<el-row
|
|
11
|
+
v-if="tableConfig?.headerButtons?.length > 0"
|
|
12
|
+
justify="end"
|
|
13
|
+
class="operation-panel"
|
|
14
|
+
>
|
|
15
|
+
<el-button
|
|
16
|
+
v-for="item in tableConfig?.headerButtons"
|
|
17
|
+
v-bind="item"
|
|
18
|
+
@click="operationHandler({ btnConfig: item })"
|
|
19
|
+
>
|
|
20
|
+
{{ item.label }}
|
|
21
|
+
</el-button>
|
|
22
|
+
</el-row>
|
|
23
|
+
<!-- schema-panel(组件 widget) -->
|
|
24
|
+
<schema-table
|
|
25
|
+
ref="schemaTableRef"
|
|
26
|
+
:buttons="tableConfig?.rowButtons ?? []"
|
|
27
|
+
:schema="tableSchema"
|
|
28
|
+
:api="api"
|
|
29
|
+
:apiParams="apiParams"
|
|
30
|
+
@operate="operationHandler"
|
|
31
|
+
></schema-table>
|
|
32
|
+
</el-card>
|
|
33
|
+
</template>
|
|
34
|
+
|
|
35
|
+
<script setup>
|
|
36
|
+
import SchemaTable from '$elpisWidgets/schema-table/schema-table.vue'
|
|
37
|
+
|
|
38
|
+
import { ref, inject } from 'vue'
|
|
39
|
+
import $curl from '$elpisCommon/curl.js'
|
|
40
|
+
import { ElMessageBox, ElNotification } from 'element-plus';
|
|
41
|
+
|
|
42
|
+
const emit = defineEmits([ 'operate' ])
|
|
43
|
+
const {
|
|
44
|
+
api,
|
|
45
|
+
apiParams,
|
|
46
|
+
tableSchema,
|
|
47
|
+
tableConfig
|
|
48
|
+
} = inject('schemaViewData')
|
|
49
|
+
|
|
50
|
+
const schemaTableRef = ref(null)
|
|
51
|
+
|
|
52
|
+
// 事件分发
|
|
53
|
+
const EventHandlerMap = {
|
|
54
|
+
remove: removeData
|
|
55
|
+
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const operationHandler = ({ btnConfig, rowData }) => {
|
|
59
|
+
// 按钮事件名
|
|
60
|
+
const { eventKey } = btnConfig
|
|
61
|
+
console.log(eventKey, 'eventKey')
|
|
62
|
+
if (EventHandlerMap[eventKey]) {
|
|
63
|
+
EventHandlerMap[eventKey]({ btnConfig, rowData })
|
|
64
|
+
} else {
|
|
65
|
+
emit('operate', { btnConfig, rowData })
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function removeData({ btnConfig, rowData }) {
|
|
70
|
+
// 把 eventOption 提出来
|
|
71
|
+
const { eventOption } = btnConfig
|
|
72
|
+
// btnConfig
|
|
73
|
+
// label: '', // 按钮中文名
|
|
74
|
+
// eventKey: '', // 按钮事件名
|
|
75
|
+
// eventOption: {
|
|
76
|
+
// 当eventKey === 'remove'
|
|
77
|
+
// params: {
|
|
78
|
+
// // paramKey 等于参数的键值,请求api要带的参数
|
|
79
|
+
// // rowValueKey 参数值 (当格式为schema:: tableKey
|
|
80
|
+
// paramKey: rowValueKey
|
|
81
|
+
// }
|
|
82
|
+
// }, // 按钮配置
|
|
83
|
+
// 删除一定要有param
|
|
84
|
+
if (!eventOption?.params) return
|
|
85
|
+
|
|
86
|
+
const { params } = eventOption
|
|
87
|
+
const removeKey = Object.keys(params)[0]
|
|
88
|
+
let removeValue
|
|
89
|
+
const removeValueList = params[removeKey].split('::')
|
|
90
|
+
if (removeValueList[0] === 'schema' && removeValueList[1]) {
|
|
91
|
+
removeValue = rowData[removeValueList[1]]
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
ElMessageBox.confirm(
|
|
95
|
+
`确认删除${removeKey} 为:${removeValue} 数据`,
|
|
96
|
+
'warning',
|
|
97
|
+
{
|
|
98
|
+
confirmButtonText: '确认',
|
|
99
|
+
cancelButtonText: '取消',
|
|
100
|
+
type: 'warning'
|
|
101
|
+
}
|
|
102
|
+
).then(async () => {
|
|
103
|
+
schemaTableRef.value.showLoading()
|
|
104
|
+
const res = await $curl({
|
|
105
|
+
method: 'delete',
|
|
106
|
+
// url: `${api.value}/list`
|
|
107
|
+
url: api.value,
|
|
108
|
+
data: {
|
|
109
|
+
[removeKey]: removeValue
|
|
110
|
+
},
|
|
111
|
+
errorMessage: '删除失败'
|
|
112
|
+
})
|
|
113
|
+
schemaTableRef.value.hideLoading()
|
|
114
|
+
|
|
115
|
+
if (!res || !res.success || !res.data) {
|
|
116
|
+
return
|
|
117
|
+
}
|
|
118
|
+
ElNotification({
|
|
119
|
+
title: '删除成功',
|
|
120
|
+
message: '删除成功',
|
|
121
|
+
type: 'success'
|
|
122
|
+
})
|
|
123
|
+
|
|
124
|
+
await initTableData()
|
|
125
|
+
})
|
|
126
|
+
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// 当删除只有一条数据的页的数据,
|
|
130
|
+
const initTableData = async () => {
|
|
131
|
+
await schemaTableRef.value.initData()
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
const loadTableData = async () => {
|
|
135
|
+
await schemaTableRef.value.loadTableData()
|
|
136
|
+
}
|
|
137
|
+
defineExpose({
|
|
138
|
+
loadTableData
|
|
139
|
+
})
|
|
140
|
+
|
|
141
|
+
</script>
|
|
142
|
+
|
|
143
|
+
<style lang="less" scoped>
|
|
144
|
+
.table-panel {
|
|
145
|
+
flex: 1;
|
|
146
|
+
margin: 10px;
|
|
147
|
+
.operation-panel {
|
|
148
|
+
margin-bottom: 10px;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
:deep(.el-card__body) {
|
|
153
|
+
height: 98%;
|
|
154
|
+
display: flex;
|
|
155
|
+
flex-direction: column;
|
|
156
|
+
}
|
|
157
|
+
</style>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import createForm from "./create-form/create-form.vue";
|
|
2
|
+
import editForm from "./edit-form/edit-form.vue";
|
|
3
|
+
import detailPanel from "./detail-panel/detail-panel.vue";
|
|
4
|
+
|
|
5
|
+
// 拓展
|
|
6
|
+
// 读取,加载,业务拓展 component 配置
|
|
7
|
+
import BusinessComponentConfig from '$businessComponentConfig'
|
|
8
|
+
|
|
9
|
+
const ComponentConfig = {
|
|
10
|
+
createForm: {
|
|
11
|
+
component: createForm
|
|
12
|
+
},
|
|
13
|
+
editForm: {
|
|
14
|
+
component: editForm
|
|
15
|
+
},
|
|
16
|
+
detailPanel: {
|
|
17
|
+
component: detailPanel
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export default {
|
|
22
|
+
...ComponentConfig,
|
|
23
|
+
...BusinessComponentConfig
|
|
24
|
+
}
|
|
@@ -0,0 +1,122 @@
|
|
|
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
|
+
>
|
|
17
|
+
|
|
18
|
+
</schema-form>
|
|
19
|
+
</template>
|
|
20
|
+
<template #footer>
|
|
21
|
+
<el-button type="primary" @click="save">
|
|
22
|
+
{{ saveBtnText }}
|
|
23
|
+
</el-button>
|
|
24
|
+
</template>
|
|
25
|
+
</el-drawer>
|
|
26
|
+
|
|
27
|
+
</template>
|
|
28
|
+
|
|
29
|
+
<script setup>
|
|
30
|
+
import { ref, inject } from 'vue'
|
|
31
|
+
import { ElNotification } from 'element-plus';
|
|
32
|
+
import $curl from '$elpisCommon/curl'
|
|
33
|
+
import schemaForm from '$elpisWidgets/schema-form/schema-form.vue';
|
|
34
|
+
|
|
35
|
+
const {
|
|
36
|
+
api,
|
|
37
|
+
components
|
|
38
|
+
} = inject('schemaViewData')
|
|
39
|
+
|
|
40
|
+
const emit = defineEmits([ 'command' ])
|
|
41
|
+
|
|
42
|
+
// 接收属性, props
|
|
43
|
+
// 释放事件 emit
|
|
44
|
+
// 提供方法 defineExpose
|
|
45
|
+
|
|
46
|
+
// 接收的参数
|
|
47
|
+
// const { components } = 'xxx'
|
|
48
|
+
const name = ref('createForm')
|
|
49
|
+
|
|
50
|
+
const schemaFormRef = ref(null)
|
|
51
|
+
const isShow = ref(false)
|
|
52
|
+
const loading = ref(false)
|
|
53
|
+
const title = ref('')
|
|
54
|
+
const saveBtnText = ref('')
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* components.value[name.value]
|
|
58
|
+
* schema: {
|
|
59
|
+
*
|
|
60
|
+
* },
|
|
61
|
+
config: {
|
|
62
|
+
title: '', // 表单标题
|
|
63
|
+
saveBtnText: '' // 保存按钮文案
|
|
64
|
+
},
|
|
65
|
+
*/
|
|
66
|
+
const show = (rowData) => {
|
|
67
|
+
const { config } = components.value[name.value]
|
|
68
|
+
|
|
69
|
+
title.value = config.title
|
|
70
|
+
saveBtnText.value = config.saveBtnText
|
|
71
|
+
|
|
72
|
+
isShow.value = true
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const close = () => {
|
|
76
|
+
isShow.value = false
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const save = async () => {
|
|
80
|
+
if (!schemaFormRef.value.validate()) return
|
|
81
|
+
loading.value = true
|
|
82
|
+
|
|
83
|
+
const res = await $curl({
|
|
84
|
+
method: 'post',
|
|
85
|
+
url: api.value,
|
|
86
|
+
// dtoObj = {
|
|
87
|
+
// ...dtoObj,
|
|
88
|
+
// {
|
|
89
|
+
// [schemaKey]: dtoValue.value
|
|
90
|
+
// input: dtoValue.value
|
|
91
|
+
// }
|
|
92
|
+
// }
|
|
93
|
+
data: {
|
|
94
|
+
...schemaFormRef.value.getValue()
|
|
95
|
+
}
|
|
96
|
+
})
|
|
97
|
+
|
|
98
|
+
loading.value = false
|
|
99
|
+
if (!res || !res.success) return
|
|
100
|
+
ElNotification({
|
|
101
|
+
title: '创建成功',
|
|
102
|
+
message: '创建成功',
|
|
103
|
+
type: 'success'
|
|
104
|
+
})
|
|
105
|
+
close()
|
|
106
|
+
|
|
107
|
+
emit('command', {
|
|
108
|
+
event: 'loadTableData'
|
|
109
|
+
})
|
|
110
|
+
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
defineExpose({
|
|
114
|
+
name,
|
|
115
|
+
show,
|
|
116
|
+
})
|
|
117
|
+
|
|
118
|
+
</script>
|
|
119
|
+
|
|
120
|
+
<style lang="less" scoped>
|
|
121
|
+
|
|
122
|
+
</style>
|
|
@@ -0,0 +1,118 @@
|
|
|
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
|
+
<h3>{{ title }}</h3>
|
|
10
|
+
</template>
|
|
11
|
+
<!-- <template #default>
|
|
12
|
+
|
|
13
|
+
</template> -->
|
|
14
|
+
<el-card
|
|
15
|
+
v-loading="loading"
|
|
16
|
+
shadow="always"
|
|
17
|
+
class="detail-panel"
|
|
18
|
+
>
|
|
19
|
+
<el-row
|
|
20
|
+
v-for="(item, key) in components[name]?.schema?.properties"
|
|
21
|
+
:key="key"
|
|
22
|
+
type="flex"
|
|
23
|
+
align="middle"
|
|
24
|
+
class="row-item"
|
|
25
|
+
>
|
|
26
|
+
<el-row
|
|
27
|
+
class="item-label"
|
|
28
|
+
>
|
|
29
|
+
{{ item.label }}:
|
|
30
|
+
</el-row>
|
|
31
|
+
<el-row
|
|
32
|
+
class="item-value"
|
|
33
|
+
>
|
|
34
|
+
{{ dtoModel[key] }}
|
|
35
|
+
</el-row>
|
|
36
|
+
</el-row>
|
|
37
|
+
</el-card>
|
|
38
|
+
</el-drawer>
|
|
39
|
+
</template>
|
|
40
|
+
|
|
41
|
+
<script setup>
|
|
42
|
+
import { ref, inject } from 'vue'
|
|
43
|
+
import $curl from '$elpisCommon/curl.js'
|
|
44
|
+
|
|
45
|
+
const {
|
|
46
|
+
api,
|
|
47
|
+
components
|
|
48
|
+
} = inject('schemaViewData')
|
|
49
|
+
|
|
50
|
+
const name = 'detailPanel'
|
|
51
|
+
const isShow = ref(false)
|
|
52
|
+
const loading = ref(false)
|
|
53
|
+
const title = ref('')
|
|
54
|
+
const mainKey = ref('')
|
|
55
|
+
const mainValue = ref()
|
|
56
|
+
const dtoModel = ref({})
|
|
57
|
+
|
|
58
|
+
const show = rowData => {
|
|
59
|
+
const { config } = components.value[name]
|
|
60
|
+
title.value = config.title
|
|
61
|
+
mainKey.value = config.mainKey
|
|
62
|
+
mainValue.value = rowData[config.mainKey]
|
|
63
|
+
dtoModel.value = {}
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
isShow.value = true
|
|
67
|
+
console.log('fetch')
|
|
68
|
+
fetchFormData()
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// const close = () => {
|
|
72
|
+
// isShow.value = false
|
|
73
|
+
// }
|
|
74
|
+
|
|
75
|
+
const fetchFormData = async () => {
|
|
76
|
+
if (loading.value) return
|
|
77
|
+
loading.value = true
|
|
78
|
+
const res = await $curl({
|
|
79
|
+
method: 'get',
|
|
80
|
+
url: api.value,
|
|
81
|
+
query: {
|
|
82
|
+
[mainKey.value]: mainValue.value
|
|
83
|
+
}
|
|
84
|
+
})
|
|
85
|
+
loading.value = false
|
|
86
|
+
|
|
87
|
+
if (!res || !res.success || !res.data) return
|
|
88
|
+
|
|
89
|
+
dtoModel.value = res.data
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
defineExpose({
|
|
93
|
+
name,
|
|
94
|
+
show,
|
|
95
|
+
})
|
|
96
|
+
|
|
97
|
+
</script>
|
|
98
|
+
|
|
99
|
+
<style lang="less" scoped>
|
|
100
|
+
.detail-panel {
|
|
101
|
+
border: 1px solid #a6a6a6;
|
|
102
|
+
padding: 30px;
|
|
103
|
+
.row-item {
|
|
104
|
+
height: 40px;
|
|
105
|
+
line-height: 40px;
|
|
106
|
+
font-size: 20px;
|
|
107
|
+
.item-label {
|
|
108
|
+
margin-right: 20px;
|
|
109
|
+
width: 120px;
|
|
110
|
+
color: #fff;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
.item-value {
|
|
114
|
+
color: #d2dae4;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
</style>
|