From 0784cec47123022ef0f8b82b4dbe9385746186aa Mon Sep 17 00:00:00 2001 From: v_yutyi Date: Tue, 12 Sep 2023 09:55:52 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=95=B0=E6=8D=AE=E6=BA=90=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E6=A8=A1=E5=9D=97=E8=81=94=E8=B0=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/package.json | 2 + .../notify-editor/NotifyEditor.less | 66 +++ .../notify-editor/NotifyEditorTemplate.vue | 363 ++++++++++++++ .../notify-editor/editorTemplate.vue | 75 +++ src/pages/src/css/index.css | 10 + src/pages/src/css/reset.css | 1 - src/pages/src/hooks/useMenuInfo.ts | 4 + src/pages/src/http/dataSourceFiles.ts | 32 ++ src/pages/src/http/types/dataSourceFiles.ts | 19 + src/pages/src/router/index.ts | 4 +- src/pages/src/utils/index.ts | 72 +++ .../src/views/data-source/LocalDataSource.vue | 202 ++++---- .../data-source/local-details/PswInfo.vue | 209 ++++---- .../data-source/local-details/UserInfo.vue | 99 ++-- .../views/data-source/local-details/index.vue | 106 +--- .../data-source/new-data/NewLocalData.vue | 472 ++++++++++++++---- .../src/views/tenant/group-details/index.vue | 7 +- 17 files changed, 1330 insertions(+), 413 deletions(-) create mode 100644 src/pages/src/components/notify-editor/NotifyEditor.less create mode 100644 src/pages/src/components/notify-editor/NotifyEditorTemplate.vue create mode 100644 src/pages/src/components/notify-editor/editorTemplate.vue diff --git a/src/pages/package.json b/src/pages/package.json index ea803dc5a..513534a31 100644 --- a/src/pages/package.json +++ b/src/pages/package.json @@ -19,6 +19,8 @@ "author": "", "license": "ISC", "dependencies": { + "@wangeditor/editor": "^5.1.23", + "@wangeditor/editor-for-vue": "^5.1.12", "art-template": "^4.13.2", "axios": "^1.4.0", "bkui-vue": "0.0.1-beta.475", diff --git a/src/pages/src/components/notify-editor/NotifyEditor.less b/src/pages/src/components/notify-editor/NotifyEditor.less new file mode 100644 index 000000000..bb0bda9a7 --- /dev/null +++ b/src/pages/src/components/notify-editor/NotifyEditor.less @@ -0,0 +1,66 @@ +.tab-box { + .password-header { + display: flex; + line-height: 50px; + + .bk-checkbox-group { + display: flex; + font-size: 14px; + line-height: 50px; + + .password-tab { + padding-left: 20px; + + .checkbox-item { + display: inline-block; + padding: 0 20px 0 5px; + font-size: 14px; + } + + .bk-checkbox { + vertical-align: middle; + } + } + } + + .checkbox-zh { + width: 85% !important; + } + + .checkbox-en { + width: 75% !important; + } + + .edit-info { + color: #3A84FF; + + :hover { + cursor: pointer; + } + } + } +} + +::v-deep .show-tab-color { + .password-header { + display: flex; + border-bottom: 1px solid #dcdee5; + + .active-tab { + border-bottom: 2px solid #3A84FF; + } + + .password-tab span:hover { + color: #3a84ff; + cursor: pointer; + } + } + + .bk-tab-label-list .bk-tab-label-item.active::after { + height: 2px; + } + + .bk-tab-header { + background-image: linear-gradient(transparent 41px, #dcdee5 0); + } +} diff --git a/src/pages/src/components/notify-editor/NotifyEditorTemplate.vue b/src/pages/src/components/notify-editor/NotifyEditorTemplate.vue new file mode 100644 index 000000000..e7cad0ed4 --- /dev/null +++ b/src/pages/src/components/notify-editor/NotifyEditorTemplate.vue @@ -0,0 +1,363 @@ + + + + + diff --git a/src/pages/src/components/notify-editor/editorTemplate.vue b/src/pages/src/components/notify-editor/editorTemplate.vue new file mode 100644 index 000000000..baedf644d --- /dev/null +++ b/src/pages/src/components/notify-editor/editorTemplate.vue @@ -0,0 +1,75 @@ + + + + + diff --git a/src/pages/src/css/index.css b/src/pages/src/css/index.css index cd4c8d148..931f29c09 100644 --- a/src/pages/src/css/index.css +++ b/src/pages/src/css/index.css @@ -63,3 +63,13 @@ border-radius: 4px; flex-shrink: 0; } + +.clearfix { + &::after { + display: block; + clear: both; + font-size: 0; + content: ''; + visibility: hidden; + } +} diff --git a/src/pages/src/css/reset.css b/src/pages/src/css/reset.css index 80c74a7a8..b5216fd9a 100644 --- a/src/pages/src/css/reset.css +++ b/src/pages/src/css/reset.css @@ -51,7 +51,6 @@ big, cite, -code, del, dfn, diff --git a/src/pages/src/hooks/useMenuInfo.ts b/src/pages/src/hooks/useMenuInfo.ts index 1a47df0ee..8c2c27025 100644 --- a/src/pages/src/hooks/useMenuInfo.ts +++ b/src/pages/src/hooks/useMenuInfo.ts @@ -1,10 +1,13 @@ import { computed, inject } from 'vue'; import { RouteLocationNormalizedLoaded, RouteRecordRaw, useRoute, useRouter } from 'vue-router'; +import { useMainViewStore } from '@/store/mainView'; + export const useMenuInfo = () => { const route = useRoute(); const router = useRouter(); const editLeaveBefore = inject('editLeaveBefore'); + const store = useMainViewStore(); // 获取 menu 相关配置 const { children } = route.matched[0]; @@ -14,6 +17,7 @@ export const useMenuInfo = () => { // 获取 menu 默认激活信息 const activeMenu = computed(() => { + store.breadCrumbsTitle = route.meta.navName; const { activeMenu } = route.meta; if (activeMenu) { return routes.value.find((route: RouteRecordRaw) => route.name === activeMenu); diff --git a/src/pages/src/http/dataSourceFiles.ts b/src/pages/src/http/dataSourceFiles.ts index 803b108fc..b93a1056c 100644 --- a/src/pages/src/http/dataSourceFiles.ts +++ b/src/pages/src/http/dataSourceFiles.ts @@ -2,7 +2,9 @@ import http from './fetch'; import type { DataSourceUsersParams, DataSourceUsersResult, + NewDataSourceParams, NewDataSourceUserParams, + PutDataSourceParams, PutDataSourceUserParams, } from './types/dataSourceFiles'; @@ -38,3 +40,33 @@ export const getDataSourceUserDetails = (id: string) => http.get(`/api/v1/web/da * 更新数据源用户 */ export const putDataSourceUserDetails = (params: PutDataSourceUserParams) => http.put(`/api/v1/web/data-sources/users/${params.id}/`, params); + +/** + * 数据源列表 + */ +export const getDataSourceList = (keyword: string) => http.get(`/api/v1/web/data-sources/?keyword=${keyword}`); + +/** + * 数据源插件列表 + */ +export const getDataSourcePlugins = () => http.get('/api/v1/web/data-sources/plugins/'); + +/** + * 新建数据源 + */ +export const newDataSource = (params: NewDataSourceParams) => http.post('/api/v1/web/data-sources/', params); + +/** + * 数据源详情 + */ +export const getDataSourceDetails = (id: string) => http.get(`/api/v1/web/data-sources/${id}/`); + +/** + * 新建数据源默认配置 + */ +export const getDefaultConfig = (id: string) => http.get(`/api/v1/web/data-sources/plugins/${id}/default-config/`); + +/** + * 更新数据源 + */ +export const putDataSourceDetails = (params: PutDataSourceParams) => http.put(`/api/v1/web/data-sources/${params.id}/`, params); diff --git a/src/pages/src/http/types/dataSourceFiles.ts b/src/pages/src/http/types/dataSourceFiles.ts index 1846f30cb..87e5f85e6 100644 --- a/src/pages/src/http/types/dataSourceFiles.ts +++ b/src/pages/src/http/types/dataSourceFiles.ts @@ -51,3 +51,22 @@ export interface DataSourceUsersParams { page: number, pageSize: number, } + +/** + * 新建数据源参数 + */ +export interface NewDataSourceParams { + name: string, + plugin_id: string, + plugin_config: {}, + field_mapping: [], +} + +/** + * 更新数据源参数 + */ +export interface PutDataSourceParams { + id: string, + plugin_config: {}, + field_mapping: [], +} diff --git a/src/pages/src/router/index.ts b/src/pages/src/router/index.ts index 7addebe55..a62b15aa5 100644 --- a/src/pages/src/router/index.ts +++ b/src/pages/src/router/index.ts @@ -84,7 +84,7 @@ export default createRouter({ ], }, { - path: 'local-details/:name/:type/:id', + path: 'local-details/:id', name: 'dataConfDetails', meta: { routeParentName: 'dataSource', @@ -94,7 +94,7 @@ export default createRouter({ component: () => import('@/views/data-source/local-details/index.vue'), }, { - path: 'new-local/:type', + path: 'new-local/:type/:id?', name: 'newLocal', meta: { routeParentName: 'dataSource', diff --git a/src/pages/src/utils/index.ts b/src/pages/src/utils/index.ts index c44a9124a..b8876a8b7 100644 --- a/src/pages/src/utils/index.ts +++ b/src/pages/src/utils/index.ts @@ -106,3 +106,75 @@ export function dateConvert(value: string) { return value; } } + +// 数据源启用状态 +export const dataSourceStatus = { + enabled: { + icon: normalImg, + text: '正常', + }, + disabled: { + icon: unknownImg, + text: '未启用', + }, +}; + +export const validTime = { + 30: '一个月', + 90: '三个月', + 180: '六个月', + 365: '一年', + '-1': '永久', +}; + +export function validTimeMap(value: number) { + return validTime[value]; +} + +export const noticeTime = { + 1: '1天', + 7: '7天', + 15: '15天', +}; +export function noticeTimeMap(value: any) { + const list: string[] = value?.map(key => noticeTime[key]).filter(Boolean) || []; + return list.join(','); +}; + +export const notification = { + email: '邮箱', + sms: '短信', +}; + +export function notificationMap(value: any) { + const list: string[] = value?.map(key => notification[key]).filter(Boolean) || []; + return list.join(','); +}; + +export const passwordMustIncludes = { + contain_lowercase: '小写字母', + contain_uppercase: '连续字母序', + contain_digit: '数字', + contain_punctuation: '特殊字符(除空格)', +}; + +export function passwordMustIncludesMap(value: any) { + const list: string[] = Object.entries(value) + .filter(([key, val]) => passwordMustIncludes[key] && val) + .map(([key]) => passwordMustIncludes[key]); + return list.join(','); +}; + +export const passwordNotAllowed = { + not_keyboard_order: '键盘序', + not_continuous_letter: '连续字母序', + not_continuous_digit: '连续数字序', + not_repeated_symbol: '重复字母、数字、特殊符号', +}; + +export function passwordNotAllowedMap(value: any) { + const list: string[] = Object.entries(value) + .filter(([key, val]) => passwordNotAllowed[key] && val) + .map(([key]) => passwordNotAllowed[key]); + return list.join(',') || '--'; +}; diff --git a/src/pages/src/views/data-source/LocalDataSource.vue b/src/pages/src/views/data-source/LocalDataSource.vue index 53bf379cd..a8d7400bf 100644 --- a/src/pages/src/views/data-source/LocalDataSource.vue +++ b/src/pages/src/views/data-source/LocalDataSource.vue @@ -10,14 +10,15 @@ - + + @@ -28,105 +29,132 @@ v-model="searchVal" placeholder="搜索数据源名称" type="search" + clearable + @enter="handleEnter" + @clear="handleClear" /> -