@mangjuxiong/elpis 1.0.2
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/.babelrc +5 -0
- package/.eslintignore +3 -0
- package/.eslintrc +66 -0
- package/README.md +214 -0
- package/app/controller/base.js +39 -0
- package/app/controller/project.js +75 -0
- package/app/controller/view.js +19 -0
- package/app/extend/database.js +5 -0
- package/app/extend/logger.js +38 -0
- package/app/middleware/api-params-verify.js +74 -0
- package/app/middleware/api-sign-verify.js +36 -0
- package/app/middleware/error-handle.js +32 -0
- package/app/middleware/project-handler.js +26 -0
- package/app/middleware.js +39 -0
- package/app/pages/asserts/custom.css +14 -0
- package/app/pages/boot.js +48 -0
- package/app/pages/common/curl.js +80 -0
- package/app/pages/common/utils.js +34 -0
- package/app/pages/dashboard/complex-view/header-view/complex-view/sub-menu/sub-menu.vue +24 -0
- package/app/pages/dashboard/complex-view/header-view/head-view.vue +113 -0
- package/app/pages/dashboard/complex-view/iframe-view/iframe-view.vue +43 -0
- package/app/pages/dashboard/complex-view/schema-view/complex-view/search-panel/search-panel.vue +35 -0
- package/app/pages/dashboard/complex-view/schema-view/complex-view/table-panel/table-panel.vue +118 -0
- package/app/pages/dashboard/complex-view/schema-view/components/components-config.js +23 -0
- package/app/pages/dashboard/complex-view/schema-view/components/create-form/create-form.vue +85 -0
- package/app/pages/dashboard/complex-view/schema-view/components/detail-panel/detail-panel.vue +103 -0
- package/app/pages/dashboard/complex-view/schema-view/components/edit-form/edit-form.vue +112 -0
- package/app/pages/dashboard/complex-view/schema-view/hook/schema.js +124 -0
- package/app/pages/dashboard/complex-view/schema-view/schema-view.vue +90 -0
- package/app/pages/dashboard/complex-view/sider-view/complex-view/sub-menu/sub-menu.vue +22 -0
- package/app/pages/dashboard/complex-view/sider-view/sider-view.vue +113 -0
- package/app/pages/dashboard/dashboard.vue +85 -0
- package/app/pages/dashboard/entry.dashboard.js +46 -0
- package/app/pages/store/index.js +4 -0
- package/app/pages/store/menu.js +54 -0
- package/app/pages/store/project.js +13 -0
- package/app/pages/widgets/head-container/asserts/logo.png +0 -0
- package/app/pages/widgets/head-container/head-container.vue +77 -0
- package/app/pages/widgets/schema-form/complex-view/input/input.vue +134 -0
- package/app/pages/widgets/schema-form/complex-view/input-number/input-number.vue +135 -0
- package/app/pages/widgets/schema-form/complex-view/select/select.vue +120 -0
- package/app/pages/widgets/schema-form/form-item-config.js +23 -0
- package/app/pages/widgets/schema-form/schema-form.vue +130 -0
- package/app/pages/widgets/schema-search-bar/complex-view/date-range/date-range.vue +51 -0
- package/app/pages/widgets/schema-search-bar/complex-view/dynamic-select/dynamic-select.vue +55 -0
- package/app/pages/widgets/schema-search-bar/complex-view/input/input.vue +38 -0
- package/app/pages/widgets/schema-search-bar/complex-view/select/select.vue +40 -0
- package/app/pages/widgets/schema-search-bar/schema-search-bar.vue +100 -0
- package/app/pages/widgets/schema-search-bar/search-item-config.js +31 -0
- package/app/pages/widgets/schema-table/schema-table.vue +225 -0
- package/app/pages/widgets/sider-container/sider-container.vue +27 -0
- package/app/public/output/entry.page1.tpl +42 -0
- package/app/public/static/logo.jpg +0 -0
- package/app/public/static/normalize.css +267 -0
- package/app/router/project.js +6 -0
- package/app/router/view.js +7 -0
- package/app/router-schema/project.js +30 -0
- package/app/service/base.js +13 -0
- package/app/service/project.js +42 -0
- package/app/view/entry.tpl +25 -0
- package/app/webpack/config/babel.config.js +4 -0
- package/app/webpack/config/webpack.base.js +229 -0
- package/app/webpack/config/webpack.dev.js +57 -0
- package/app/webpack/config/webpack.prod.js +120 -0
- package/app/webpack/libs/blank.js +1 -0
- package/app/webpack/libs/dev.js +53 -0
- package/app/webpack/libs/prod.js +22 -0
- package/config/config.default.js +4 -0
- package/elpis-core/env.js +20 -0
- package/elpis-core/index.js +81 -0
- package/elpis-core/loader/config.js +52 -0
- package/elpis-core/loader/controller.js +59 -0
- package/elpis-core/loader/extend.js +47 -0
- package/elpis-core/loader/middleware.js +57 -0
- package/elpis-core/loader/router-schema.js +41 -0
- package/elpis-core/loader/router.js +42 -0
- package/elpis-core/loader/service.js +59 -0
- package/index.js +39 -0
- package/model/index.js +107 -0
- package/package.json +90 -0
- package/test/controller/project.test.js +194 -0
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { createApp } from 'vue';
|
|
2
|
+
import pinia from '@elpisStore';
|
|
3
|
+
import { createRouter, createWebHistory } from 'vue-router';
|
|
4
|
+
import './asserts/custom.css';
|
|
5
|
+
|
|
6
|
+
// 引入elementui
|
|
7
|
+
import ElementPlus from 'element-plus';
|
|
8
|
+
import 'element-plus/theme-chalk/index.css';
|
|
9
|
+
import 'element-plus/theme-chalk/dark/css-vars.css';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* vue页面的主入口,用于启动vue
|
|
13
|
+
* @params pageComponent vue 入口组件
|
|
14
|
+
* @params routes 路由列表
|
|
15
|
+
* @params libs 页面依赖的第三方包
|
|
16
|
+
*/
|
|
17
|
+
export default (pageComponent, { routes, libs } = {}) => {
|
|
18
|
+
const app = createApp(pageComponent);
|
|
19
|
+
|
|
20
|
+
// 应用elementui
|
|
21
|
+
app.use(ElementPlus);
|
|
22
|
+
|
|
23
|
+
// 引入 pinia
|
|
24
|
+
app.use(pinia);
|
|
25
|
+
|
|
26
|
+
// 引入第三方包
|
|
27
|
+
if (libs && libs.length) {
|
|
28
|
+
for (let i = 0; i < libs.length; i++) {
|
|
29
|
+
app.use(libs[i]);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// 引入页面路由
|
|
34
|
+
if (routes && routes.length) {
|
|
35
|
+
const router = createRouter({
|
|
36
|
+
history: createWebHistory(), // 采用history模式
|
|
37
|
+
routes,
|
|
38
|
+
});
|
|
39
|
+
app.use(router);
|
|
40
|
+
// 等待路由初始化完成
|
|
41
|
+
router.isReady().then(() => {
|
|
42
|
+
// 挂载到dom
|
|
43
|
+
app.mount('#root');
|
|
44
|
+
});
|
|
45
|
+
} else {
|
|
46
|
+
app.mount('#root');
|
|
47
|
+
}
|
|
48
|
+
};
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
const md5 = require('md5');
|
|
2
|
+
import { ElMessage } from 'element-plus';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* 前端封装的curl方法
|
|
6
|
+
* @param {Object} options 请求参数
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
const curl = ({
|
|
10
|
+
url = '', // 请求地址
|
|
11
|
+
method = 'get', // 请求方法
|
|
12
|
+
headers = {}, // 请求头
|
|
13
|
+
query = {}, // 请求参数 url query
|
|
14
|
+
data = {}, // post body
|
|
15
|
+
timeout = 30000, // 超时
|
|
16
|
+
responseType = 'json', // 返回数据类型
|
|
17
|
+
errorMessage = '网络异常',
|
|
18
|
+
}) => {
|
|
19
|
+
// 接口签名处理(让接口变动态)
|
|
20
|
+
const signKey = 'mshsiksjksnnmsma';
|
|
21
|
+
const st = Date.now();
|
|
22
|
+
const dtoHeaders = {
|
|
23
|
+
...headers,
|
|
24
|
+
s_t: st,
|
|
25
|
+
s_sign: md5(`${signKey}_${st}`),
|
|
26
|
+
};
|
|
27
|
+
if (url.indexOf('/api/proj/') > -1 && window.projKey) {
|
|
28
|
+
dtoHeaders.proj_key = window.projKey;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// 构造请求参数(把参数转换为axios参数)
|
|
32
|
+
const ajaxSettings = {
|
|
33
|
+
url,
|
|
34
|
+
method,
|
|
35
|
+
params: query,
|
|
36
|
+
data,
|
|
37
|
+
timeout,
|
|
38
|
+
responseType,
|
|
39
|
+
headers: dtoHeaders,
|
|
40
|
+
};
|
|
41
|
+
return axios
|
|
42
|
+
.request(ajaxSettings)
|
|
43
|
+
.then((res) => {
|
|
44
|
+
const resData = res.data || {};
|
|
45
|
+
// 后端API返回数据格式
|
|
46
|
+
const { success } = resData;
|
|
47
|
+
// 失败
|
|
48
|
+
if (!success) {
|
|
49
|
+
const { message, code } = resData;
|
|
50
|
+
console.log('🚀 ~ returnaxios.request ~ message:', message);
|
|
51
|
+
if (code === 442) {
|
|
52
|
+
ElMessage.error('请求参数异常');
|
|
53
|
+
} else if (code === 445) {
|
|
54
|
+
ElMessage.error('请求不合法');
|
|
55
|
+
} else if (code === 446) {
|
|
56
|
+
ElMessage.error('项目标识不存在');
|
|
57
|
+
} else if (code === 5000) {
|
|
58
|
+
ElMessage.error(message);
|
|
59
|
+
} else {
|
|
60
|
+
ElMessage.error(errorMessage);
|
|
61
|
+
}
|
|
62
|
+
return Promise.resolve({ success, message, code });
|
|
63
|
+
}
|
|
64
|
+
// 成功
|
|
65
|
+
const { data, metadatas } = resData;
|
|
66
|
+
return Promise.resolve({ success, data, metadatas });
|
|
67
|
+
})
|
|
68
|
+
.catch((err) => {
|
|
69
|
+
const { message } = err;
|
|
70
|
+
if (message.match(/timeout/)) {
|
|
71
|
+
return Promise.resolve({
|
|
72
|
+
message: 'Request timeout',
|
|
73
|
+
code: 504,
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
return Promise.resolve(err);
|
|
77
|
+
});
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
export default curl;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
const utils = {
|
|
2
|
+
/**
|
|
3
|
+
* 防抖
|
|
4
|
+
* @param {防抖的方法} fn
|
|
5
|
+
* @param {防抖的时间} delay
|
|
6
|
+
*/
|
|
7
|
+
debounce: (fn, delay=0) => {
|
|
8
|
+
let timer = null;
|
|
9
|
+
return function (...args) {
|
|
10
|
+
if (timer) clearTimeout(timer);
|
|
11
|
+
timer = setTimeout(() => {
|
|
12
|
+
fn.apply(this, args);
|
|
13
|
+
timer = null;
|
|
14
|
+
}, delay);
|
|
15
|
+
};
|
|
16
|
+
},
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* 节流
|
|
20
|
+
* @param {节流的方法} fn
|
|
21
|
+
* @param {节流的时间} delay
|
|
22
|
+
*/
|
|
23
|
+
throttle: (fn, delay=0) => {
|
|
24
|
+
let lastTime = 0;
|
|
25
|
+
return function (...args) {
|
|
26
|
+
const now = Date.now();
|
|
27
|
+
if (now - lastTime > delay) {
|
|
28
|
+
fn.apply(this, args);
|
|
29
|
+
lastTime = now;
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
export default utils;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<el-sub-menu :index="menuItem.key || ''">
|
|
3
|
+
<template #title>
|
|
4
|
+
{{ menuItem.name }}
|
|
5
|
+
</template>
|
|
6
|
+
<div v-for="subMenuItem in menuItem.subMenu" :key="subMenuItem.key">
|
|
7
|
+
<sub-menu v-if="subMenuItem.subMenu && subMenuItem.subMenu.length > 0" :menu-item="subMenuItem" />
|
|
8
|
+
<el-menu-item v-else :index="subMenuItem.key">
|
|
9
|
+
{{ subMenuItem.name }}
|
|
10
|
+
</el-menu-item>
|
|
11
|
+
</div>
|
|
12
|
+
</el-sub-menu>
|
|
13
|
+
</template>
|
|
14
|
+
|
|
15
|
+
<script setup>
|
|
16
|
+
const { menuItem } = defineProps({
|
|
17
|
+
menuItem: {
|
|
18
|
+
type: Object,
|
|
19
|
+
default: () => {},
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
</script>
|
|
23
|
+
|
|
24
|
+
<style lang="less" scoped></style>
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<header-container :title="projectName">
|
|
3
|
+
<template #menu-content>
|
|
4
|
+
<!-- 根据menuStore的menuList的渲染 -->
|
|
5
|
+
<el-menu :default-active="activeMenuKey" :ellipsis="false" mode="horizontal" @select="onMenuSelect">
|
|
6
|
+
<template v-for="menuItem in menuStore.menuList">
|
|
7
|
+
<sub-menu v-if="menuItem.subMenu && menuItem.subMenu.length > 0" :menu-item="menuItem" />
|
|
8
|
+
<el-menu-item v-else :index="menuItem.key">
|
|
9
|
+
{{ menuItem.name }}
|
|
10
|
+
</el-menu-item>
|
|
11
|
+
</template>
|
|
12
|
+
</el-menu>
|
|
13
|
+
</template>
|
|
14
|
+
<template #setting-content>
|
|
15
|
+
<!-- 根据projectStore的projectList的渲染 -->
|
|
16
|
+
<el-dropdown @command="handleProjectCommand">
|
|
17
|
+
<span class="project-list">
|
|
18
|
+
{{ projectName }}
|
|
19
|
+
<el-icon v-if="projectStore.projectList.length > 1" class="el-icon-right">
|
|
20
|
+
<ArrowDown />
|
|
21
|
+
</el-icon>
|
|
22
|
+
</span>
|
|
23
|
+
<template v-if="projectStore.projectList.length > 1" #dropdown>
|
|
24
|
+
<el-dropdown-menu>
|
|
25
|
+
<el-dropdown-item
|
|
26
|
+
v-for="projectItem in projectStore.projectList"
|
|
27
|
+
:command="projectItem.key"
|
|
28
|
+
:disabled="projectItem.name === projectName"
|
|
29
|
+
>
|
|
30
|
+
{{ projectItem.name }}
|
|
31
|
+
</el-dropdown-item>
|
|
32
|
+
</el-dropdown-menu>
|
|
33
|
+
</template>
|
|
34
|
+
<el-dropdown-menu slot="dropdown" />
|
|
35
|
+
</el-dropdown>
|
|
36
|
+
</template>
|
|
37
|
+
<template #main-content>
|
|
38
|
+
<slot name="main-content" />
|
|
39
|
+
</template>
|
|
40
|
+
</header-container>
|
|
41
|
+
</template>
|
|
42
|
+
|
|
43
|
+
<script setup>
|
|
44
|
+
import HeaderContainer from '@elpisWidgets/head-container/head-container';
|
|
45
|
+
import { ref, watch, onMounted } from 'vue';
|
|
46
|
+
import { ArrowDown } from '@element-plus/icons-vue';
|
|
47
|
+
import SubMenu from './complex-view/sub-menu/sub-menu';
|
|
48
|
+
import { useMenuStore } from '@elpisStore/menu.js';
|
|
49
|
+
import { useProjectStore } from '@elpisStore/project.js';
|
|
50
|
+
import { useRoute } from 'vue-router';
|
|
51
|
+
|
|
52
|
+
const menuStore = useMenuStore();
|
|
53
|
+
const projectStore = useProjectStore();
|
|
54
|
+
const route = useRoute();
|
|
55
|
+
|
|
56
|
+
defineProps({
|
|
57
|
+
projectName: {
|
|
58
|
+
type: String,
|
|
59
|
+
default: '',
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
const emit = defineEmits(['menu-select']);
|
|
64
|
+
|
|
65
|
+
const activeMenuKey = ref('');
|
|
66
|
+
const setActiveMenuKey = () => {
|
|
67
|
+
const menuItem = menuStore.findMenuItem({
|
|
68
|
+
key: 'key',
|
|
69
|
+
value: route.query.key,
|
|
70
|
+
});
|
|
71
|
+
activeMenuKey.value = menuItem?.key;
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
watch(
|
|
75
|
+
[() => route.query.key, () => menuStore.menuList],
|
|
76
|
+
() => {
|
|
77
|
+
setActiveMenuKey();
|
|
78
|
+
},
|
|
79
|
+
{ deep: true }
|
|
80
|
+
);
|
|
81
|
+
onMounted(() => {
|
|
82
|
+
setActiveMenuKey();
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
const onMenuSelect = (menuKey) => {
|
|
86
|
+
const menuItem = menuStore.findMenuItem({
|
|
87
|
+
key: 'key',
|
|
88
|
+
value: menuKey,
|
|
89
|
+
});
|
|
90
|
+
emit('menu-select', menuItem);
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
const handleProjectCommand = (command) => {
|
|
94
|
+
const projectItem = projectStore.projectList.find((item) => item.key === command);
|
|
95
|
+
if (!projectItem || !projectItem.homePage) return;
|
|
96
|
+
const { origin } = window.location;
|
|
97
|
+
window.location.replace(`${origin}/view/dashboard${projectItem.homePage}`);
|
|
98
|
+
};
|
|
99
|
+
</script>
|
|
100
|
+
|
|
101
|
+
<style lang="less" scoped>
|
|
102
|
+
.project-list {
|
|
103
|
+
margin-right: 20px;
|
|
104
|
+
cursor: pointer;
|
|
105
|
+
color: var(--el-color-primary);
|
|
106
|
+
display: flex;
|
|
107
|
+
align-items: center;
|
|
108
|
+
outline: none;
|
|
109
|
+
}
|
|
110
|
+
:deep(.el-menu--horizontal) {
|
|
111
|
+
border-bottom: 0;
|
|
112
|
+
}
|
|
113
|
+
</style>
|
|
@@ -0,0 +1,43 @@
|
|
|
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';
|
|
9
|
+
|
|
10
|
+
const route = useRoute();
|
|
11
|
+
const menuStore = useMenuStore();
|
|
12
|
+
|
|
13
|
+
const path = ref('');
|
|
14
|
+
const setPath = () => {
|
|
15
|
+
const { key, sider_key } = route.query;
|
|
16
|
+
|
|
17
|
+
const menuItem = menuStore.findMenuItem({
|
|
18
|
+
key: 'key',
|
|
19
|
+
value: sider_key ?? key,
|
|
20
|
+
});
|
|
21
|
+
path.value = menuItem?.iframeConfig?.path ?? '';
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
watch(
|
|
25
|
+
[() => route.query.key, () => route.query.sider_key, () => menuStore.menuList],
|
|
26
|
+
() => {
|
|
27
|
+
setPath();
|
|
28
|
+
},
|
|
29
|
+
{ deep: true }
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
onMounted(() => {
|
|
33
|
+
setPath();
|
|
34
|
+
});
|
|
35
|
+
</script>
|
|
36
|
+
|
|
37
|
+
<style lang="less" scoped>
|
|
38
|
+
.iframe {
|
|
39
|
+
border: 0;
|
|
40
|
+
width: 100%;
|
|
41
|
+
height: 100%;
|
|
42
|
+
}
|
|
43
|
+
</style>
|
package/app/pages/dashboard/complex-view/schema-view/complex-view/search-panel/search-panel.vue
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<el-card class="search-panel">
|
|
3
|
+
<schema-search-bar :schema="searchSchema" @loaded="onLoad" @search="onSearch" @reset="onReset" />
|
|
4
|
+
</el-card>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<script setup>
|
|
8
|
+
import { inject } from 'vue';
|
|
9
|
+
import SchemaSearchBar from '@elpisWidgets/schema-search-bar/schema-search-bar';
|
|
10
|
+
|
|
11
|
+
const { searchSchema } = inject('schemaViewData');
|
|
12
|
+
|
|
13
|
+
const emit = defineEmits(['search']);
|
|
14
|
+
|
|
15
|
+
const onLoad = (searchObj) => {
|
|
16
|
+
emit('search', searchObj);
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const onSearch = (searchObj) => {
|
|
20
|
+
emit('search', searchObj);
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const onReset = () => {
|
|
24
|
+
emit('search', {});
|
|
25
|
+
};
|
|
26
|
+
</script>
|
|
27
|
+
|
|
28
|
+
<style lang="less" scoped>
|
|
29
|
+
.search-panel {
|
|
30
|
+
margin: 10px 10px 0 10px;
|
|
31
|
+
}
|
|
32
|
+
:deep(.el-card__body) {
|
|
33
|
+
padding-bottom: 2px;
|
|
34
|
+
}
|
|
35
|
+
</style>
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<el-card class="table-panel">
|
|
3
|
+
<!-- operation-panel -->
|
|
4
|
+
<el-row v-if="tableConfig?.headerButtons?.length > 0" justify="end" class="operation-panel">
|
|
5
|
+
<el-button
|
|
6
|
+
v-for="(btn, index) in tableConfig.headerButtons"
|
|
7
|
+
:key="index"
|
|
8
|
+
v-bind="btn"
|
|
9
|
+
@click="operationHandler({ btnConfig: btn })"
|
|
10
|
+
>
|
|
11
|
+
{{ btn.label }}
|
|
12
|
+
</el-button>
|
|
13
|
+
</el-row>
|
|
14
|
+
<!-- schema-table(组件widgets) -->
|
|
15
|
+
<schema-table
|
|
16
|
+
ref="SchemaTableRef"
|
|
17
|
+
:schema="tableSchema"
|
|
18
|
+
:api="api"
|
|
19
|
+
:buttons="tableConfig?.rowButtons ?? []"
|
|
20
|
+
:api-params="apiParams"
|
|
21
|
+
@operate="operationHandler"
|
|
22
|
+
/>
|
|
23
|
+
</el-card>
|
|
24
|
+
</template>
|
|
25
|
+
|
|
26
|
+
<script setup>
|
|
27
|
+
import { ref, inject } from 'vue';
|
|
28
|
+
import $curl from '@elpisCommon/curl';
|
|
29
|
+
import { ElMessageBox, ElNotification } from 'element-plus';
|
|
30
|
+
import SchemaTable from '@elpisWidgets/schema-table/schema-table.vue';
|
|
31
|
+
|
|
32
|
+
const emit = defineEmits(['operate']);
|
|
33
|
+
|
|
34
|
+
const { api, tableSchema, tableConfig, apiParams } = inject('schemaViewData');
|
|
35
|
+
|
|
36
|
+
const SchemaTableRef = ref(null);
|
|
37
|
+
|
|
38
|
+
const EventHandlerMap = {
|
|
39
|
+
remove: removeData,
|
|
40
|
+
};
|
|
41
|
+
const operationHandler = ({ rowData, btnConfig }) => {
|
|
42
|
+
const { eventKey } = btnConfig;
|
|
43
|
+
if (EventHandlerMap[eventKey]) {
|
|
44
|
+
EventHandlerMap[eventKey]({ rowData, btnConfig });
|
|
45
|
+
} else {
|
|
46
|
+
emit('operate', { btnConfig, rowData });
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
function removeData({ rowData, btnConfig }) {
|
|
51
|
+
console.log('🚀 ~ removeData ~ rowData:', rowData);
|
|
52
|
+
const { eventOptions } = btnConfig;
|
|
53
|
+
const { params } = eventOptions;
|
|
54
|
+
const removeKey = Object.keys(params)[0];
|
|
55
|
+
|
|
56
|
+
if (!eventOptions?.params || !removeKey) return;
|
|
57
|
+
|
|
58
|
+
let removeValue = rowData[params[removeKey]] || '';
|
|
59
|
+
const removeValueList = params[removeKey].split('::');
|
|
60
|
+
if (removeValueList[0] === 'schema' && removeValueList[1]) {
|
|
61
|
+
removeValue = rowData[removeValueList[1]];
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
ElMessageBox.confirm(`确认删除${removeKey}为:${removeValue} 的数据?`, 'Warning', {
|
|
65
|
+
confirmButtonText: '确认',
|
|
66
|
+
cancleButtonText: '取消',
|
|
67
|
+
type: 'warning',
|
|
68
|
+
}).then(async () => {
|
|
69
|
+
SchemaTableRef.value.showLoading();
|
|
70
|
+
const res = await $curl({
|
|
71
|
+
url: api.value,
|
|
72
|
+
method: 'delete',
|
|
73
|
+
data: {
|
|
74
|
+
[removeKey]: removeValue,
|
|
75
|
+
},
|
|
76
|
+
errorMessage: '删除失败',
|
|
77
|
+
});
|
|
78
|
+
SchemaTableRef.value.hideLoading();
|
|
79
|
+
|
|
80
|
+
if (!res || !res.success || !res.data) return;
|
|
81
|
+
|
|
82
|
+
ElNotification({
|
|
83
|
+
title: '成功',
|
|
84
|
+
message: '删除成功',
|
|
85
|
+
type: 'success',
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
initTableData();
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const initTableData = () => {
|
|
93
|
+
SchemaTableRef.value.initData();
|
|
94
|
+
};
|
|
95
|
+
const loadTableData = () => {
|
|
96
|
+
SchemaTableRef.value.loadTableData();
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
defineExpose({
|
|
100
|
+
loadTableData,
|
|
101
|
+
});
|
|
102
|
+
</script>
|
|
103
|
+
|
|
104
|
+
<style lang="less" scoped>
|
|
105
|
+
.table-panel {
|
|
106
|
+
flex: 1;
|
|
107
|
+
margin: 10px;
|
|
108
|
+
.operation-panel {
|
|
109
|
+
margin-bottom: 10px;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
:deep(.el-card__body) {
|
|
114
|
+
height: 98%;
|
|
115
|
+
display: flex;
|
|
116
|
+
flex-direction: column;
|
|
117
|
+
}
|
|
118
|
+
</style>
|
|
@@ -0,0 +1,23 @@
|
|
|
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
|
+
// 业务拓展 component 配置
|
|
6
|
+
import BusinessComponentConfig from '@businessComponentConfig';
|
|
7
|
+
|
|
8
|
+
const componentConfig = {
|
|
9
|
+
createForm: {
|
|
10
|
+
component: createForm,
|
|
11
|
+
},
|
|
12
|
+
editForm: {
|
|
13
|
+
component: editForm,
|
|
14
|
+
},
|
|
15
|
+
detailPanel: {
|
|
16
|
+
component: detailPanel,
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export default {
|
|
21
|
+
...componentConfig,
|
|
22
|
+
...BusinessComponentConfig,
|
|
23
|
+
};
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<el-drawer v-model="isShow" direction="rtl" :destory-on-close="true" :size="550">
|
|
3
|
+
<template #header>
|
|
4
|
+
<h3>{{ title }}</h3>
|
|
5
|
+
</template>
|
|
6
|
+
<template #default>
|
|
7
|
+
<schema-form ref="schemaFormRef" v-loading="loading" :schema="components[name]?.schema" />
|
|
8
|
+
</template>
|
|
9
|
+
<template #footer>
|
|
10
|
+
<el-button type="primary" @click="save">
|
|
11
|
+
{{ saveBtnText }}
|
|
12
|
+
</el-button>
|
|
13
|
+
</template>
|
|
14
|
+
</el-drawer>
|
|
15
|
+
</template>
|
|
16
|
+
|
|
17
|
+
<script setup>
|
|
18
|
+
import { ref, inject } from 'vue';
|
|
19
|
+
import SchemaForm from '@elpisWidgets/schema-form/schema-form.vue';
|
|
20
|
+
import $curl from '@elpisCommon/curl.js';
|
|
21
|
+
import { ElNotification } from 'element-plus';
|
|
22
|
+
|
|
23
|
+
// 接收的参数
|
|
24
|
+
const { api, components } = inject('schemaViewData');
|
|
25
|
+
|
|
26
|
+
const emit = defineEmits(['command']);
|
|
27
|
+
|
|
28
|
+
const name = ref('createForm');
|
|
29
|
+
|
|
30
|
+
const schemaFormRef = ref(null);
|
|
31
|
+
const isShow = ref(false);
|
|
32
|
+
const title = ref('');
|
|
33
|
+
const saveBtnText = ref('');
|
|
34
|
+
const loading = ref(false);
|
|
35
|
+
|
|
36
|
+
const show = (rowData) => {
|
|
37
|
+
const { config } = components.value[name.value];
|
|
38
|
+
|
|
39
|
+
title.value = config.title;
|
|
40
|
+
saveBtnText.value = config.saveBtnText;
|
|
41
|
+
|
|
42
|
+
isShow.value = true;
|
|
43
|
+
console.log(rowData);
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const close = () => {
|
|
47
|
+
isShow.value = false;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const save = async () => {
|
|
51
|
+
if (loading.value) return;
|
|
52
|
+
// 校验表单
|
|
53
|
+
if (!schemaFormRef.value.validate()) return;
|
|
54
|
+
|
|
55
|
+
loading.value = true;
|
|
56
|
+
|
|
57
|
+
const res = await $curl({
|
|
58
|
+
method: 'post',
|
|
59
|
+
url: api.value,
|
|
60
|
+
data: {
|
|
61
|
+
...schemaFormRef.value.getValue(),
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
loading.value = false;
|
|
66
|
+
|
|
67
|
+
if (!res || !res.success) return;
|
|
68
|
+
ElNotification({
|
|
69
|
+
title: '创建成功',
|
|
70
|
+
message: '创建成功',
|
|
71
|
+
type: 'success',
|
|
72
|
+
});
|
|
73
|
+
close();
|
|
74
|
+
emit('command', {
|
|
75
|
+
event: 'loadTableData',
|
|
76
|
+
});
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
defineExpose({
|
|
80
|
+
name,
|
|
81
|
+
show,
|
|
82
|
+
});
|
|
83
|
+
</script>
|
|
84
|
+
|
|
85
|
+
<style lang="less" scoped></style>
|