diff --git a/src/api/system/apply.ts b/src/api/system/apply.ts index 9bf97443..b3b4c218 100644 --- a/src/api/system/apply.ts +++ b/src/api/system/apply.ts @@ -4,17 +4,30 @@ import server from '@/utils/request'; // 获取应用管理列表 export const getApplyList_api = (data: any) => server.post(`/application/_query/`, data) // 修改应用状态 -export const changeApplyStatus_api = (id:string,data: any) => server.put(`/application/${id}`, data) +export const changeApplyStatus_api = (id: string, data: any) => server.put(`/application/${id}`, data) // 删除应用 -export const delApply_api = (id:string) => server.remove(`/application/${id}`) +export const delApply_api = (id: string) => server.remove(`/application/${id}`) // 获取组织列表 export const getDepartmentList_api = () => server.get(`/organization/_all/tree`); // 获取组织列表 -export const getAppInfo_api = (id:string) => server.get(`/application/${id}`); +export const getAppInfo_api = (id: string) => server.get(`/application/${id}`); // 新增应用 -export const addApp_api = (data:object) => server.post(`/application`, data); +export const addApp_api = (data: object) => server.post(`/application`, data); // 更新应用 -export const updateApp_api = (id:string, data:object) => server.put(`/application/${id}`, data); \ No newline at end of file +export const updateApp_api = (id: string, data: object) => server.put(`/application/${id}`, data); + + +// ---------集成菜单----------- + +// 获取所属系统 +export const getOwner_api = (data: object) => server.post(`/menu/owner`, data); +export const getOwnerStandalone_api = (appId: string, data: object) => server.post(`/application/${appId}/_/api/menu/owner`, data); + +// 获取对应系统菜单树 +export const getOwnerTree_api = (owner: string) => server.post(`/menu/owner/tree/${owner}`, {}); +export const getOwnerTreeStandalone_api = (appId: string, owner: string) => server.post(`/application/${appId}/_/api/menu/owner/tree/${owner}`, {}); +// 保存集成菜单 +export const saveOwnerMenu_api = (owner: string, appId: string, data: object) => server.patch(`/menu/owner/${owner}/${appId}/_all`, data); diff --git a/src/components/CardBox/index.vue b/src/components/CardBox/index.vue index dee607c8..bfe32ab1 100644 --- a/src/components/CardBox/index.vue +++ b/src/components/CardBox/index.vue @@ -40,11 +40,19 @@ +
+
+ +
+
-
+
- - + + + + + diff --git a/src/views/media/Device/Channel/index.vue b/src/views/media/Device/Channel/index.vue index 6ca977e2..0e17cec7 100644 --- a/src/views/media/Device/Channel/index.vue +++ b/src/views/media/Device/Channel/index.vue @@ -76,6 +76,12 @@ + + @@ -84,6 +90,7 @@ import ChannelApi from '@/api/media/channel'; import type { ActionsType } from '@/components/Table/index.vue'; import { useMenuStore } from 'store/menu'; import { message } from 'ant-design-vue'; +import Save from './Save.vue'; const menuStory = useMenuStore(); const route = useRoute(); @@ -163,6 +170,8 @@ const handleAdd = () => { const listRef = ref(); const playVis = ref(false); +const channelData = ref(); + const getActions = ( data: Partial>, type: 'card' | 'table', @@ -178,6 +187,7 @@ const getActions = ( icon: 'EditOutlined', onClick: () => { saveVis.value = true; + channelData.value = data; }, }, { diff --git a/src/views/system/Apply/Save/components/EditForm.vue b/src/views/system/Apply/Save/components/EditForm.vue index 7ba9c83b..2e0be394 100644 --- a/src/views/system/Apply/Save/components/EditForm.vue +++ b/src/views/system/Apply/Save/components/EditForm.vue @@ -710,6 +710,7 @@
@@ -1372,7 +1374,10 @@
- +
@@ -1389,7 +1394,7 @@ import { } from '@/api/system/apply'; import FormLabel from './FormLabel.vue'; import RequestTable from './RequestTable.vue'; -import MenuDialog from './MenuDialog.vue'; +import MenuDialog from '../../componenets/MenuDialog.vue'; import { getImage } from '@/utils/comm'; import type { formType, dictType, optionsType } from '../typing'; import { getRoleList_api } from '@/api/system/user'; @@ -1400,32 +1405,34 @@ import { UploadFile, } from 'ant-design-vue'; import { randomString } from '@/utils/utils'; -import { cloneDeep } from 'lodash'; +import { cloneDeep, difference } from 'lodash'; +import { useMenuStore } from '@/store/menu'; const emit = defineEmits(['changeApplyType']); const routeQuery = useRoute().query; +const menuStory = useMenuStore(); const deptPermission = 'system/Department'; const rolePermission = 'system/Role'; const dialogRef = ref(); +// 初始化表单 const initForm: formType = { name: '', provider: 'internal-standalone', integrationModes: [], - config: '', description: '', page: { // 页面集成 baseUrl: '', routeType: 'hash', - parameters: [{ label: '', value: '' }], + parameters: [], }, apiClient: { // API客户端 baseUrl: '', - headers: [{ label: '', value: '' }], // 请求头 - parameters: [{ label: '', value: '' }], // 请求参数 + headers: [], // 请求头 + parameters: [], // 请求参数 authConfig: { // API客户端 type: 'oauth2', // 类型, 可选值:none, bearer, oauth2, basic, other @@ -1447,13 +1454,12 @@ const initForm: formType = { }, apiServer: { // API服务 - appId: '', + appId: randomString(16), secureKey: randomString(), // 密钥 redirectUri: '', // 重定向URL roleIdList: [], // 角色列表 orgIdList: [], // 部门列表 ipWhiteList: '', // IP白名单 - signature: '', // 签名方式, 可选值:MD5,SHA256 enableOAuth2: false, // 是否启用OAuth2 }, sso: { @@ -1497,9 +1503,9 @@ const initForm: formType = { const formRef = ref(); const form = reactive({ data: { ...initForm }, - integrationModesISO: [] as string[], - roleIdList: [] as optionsType, - orgIdList: [] as dictType, + integrationModesISO: [] as string[], // 接入方式镜像 折叠面板使用 + roleIdList: [] as optionsType, // 角色列表 + orgIdList: [] as dictType, // 组织列表 errorNumInfo: { page: new Set(), @@ -1509,7 +1515,6 @@ const form = reactive({ }, fileList: [] as any[], - fileUrlList: [] as string[], uploadLoading: false, }); // 接入方式的选项 @@ -1591,6 +1596,7 @@ function init() { () => form.data.provider, (n) => { emit('changeApplyType', n); + if (routeQuery.id) return; if (n === 'wechat-webapp' || n === 'dingtalk-ent-app') { form.data.integrationModes = ['ssoClient']; form.integrationModesISO = ['ssoClient']; @@ -1616,6 +1622,7 @@ function getInfo(id: string) { (item: any) => item.value, ), } as formType; + form.data.apiServer && (form.data.apiServer.appId = id); }); } // 获取角色列表 @@ -1651,6 +1658,23 @@ function clickAddItem(data: string[], target: string) { function clickSave() { formRef.value?.validate().then(() => { const params = cloneDeep(form.data); + // 删除多余的参数 + const list = ['page', 'apiClient', 'apiServer', 'ssoClient']; + difference(list, params.integrationModes).forEach((item) => { + if (item === 'ssoClient') { + // @ts-ignore + delete params['sso']; + } + delete params[item]; + }); + clearNullProp(params); + if ( + params.provider === 'internal-standalone' && + params.integrationModes.includes('page') + ) { + // @ts-ignore + delete params.page.parameters; + } if ( params.provider === 'internal-standalone' && @@ -1674,15 +1698,19 @@ function clickSave() { const request = routeQuery.id ? updateApp_api(routeQuery.id as string, params) : addApp_api(params); - request.then((resp) => { + request.then((resp: any) => { if (resp.status === 200) { const isPage = params.integrationModes.includes('page'); if (isPage) { form.data = params; - dialogRef.value && dialogRef.value.openDialog(); + dialogRef.value && + dialogRef.value.openDialog( + routeQuery.id || resp.result.id, + form.data.provider, + ); } else { message.success('保存成功'); - jumpPage('system/Apply'); + menuStory.jumpPage('system/Apply'); } } }); @@ -1722,9 +1750,15 @@ function changeBackUpload(info: UploadChangeParam>) { function test(...args: any[]) { console.log('test:', args); } - -function jumpPage(arg0: string) { - throw new Error('Function not implemented.'); +function clearNullProp(obj: object) { + if (typeof obj !== 'object') return; + for (const prop in obj) { + if (Object.prototype.hasOwnProperty.call(obj, prop)) { + const val = obj[prop]; + if (val === '') delete obj[prop]; + else if (typeof val === 'object') clearNullProp(obj[prop]); + } + } } diff --git a/src/views/system/Apply/Save/components/MenuDialog.vue b/src/views/system/Apply/Save/components/MenuDialog.vue deleted file mode 100644 index b706bf1e..00000000 --- a/src/views/system/Apply/Save/components/MenuDialog.vue +++ /dev/null @@ -1,49 +0,0 @@ - - - - - \ No newline at end of file diff --git a/src/views/system/Apply/Save/components/RequestTable.vue b/src/views/system/Apply/Save/components/RequestTable.vue index 888d5e76..4c8ff9ee 100644 --- a/src/views/system/Apply/Save/components/RequestTable.vue +++ b/src/views/system/Apply/Save/components/RequestTable.vue @@ -88,6 +88,7 @@ const tableData = computed(() => { return props.value.slice((current.value - 1) * 10, current.value * 10); }); +if(props.value.length < 1) addRow() watch( () => props.value, (n, o) => { diff --git a/src/views/system/Apply/Save/typing.d.ts b/src/views/system/Apply/Save/typing.d.ts index af68633c..2bc07a2f 100644 --- a/src/views/system/Apply/Save/typing.d.ts +++ b/src/views/system/Apply/Save/typing.d.ts @@ -19,7 +19,7 @@ export type formType = { name: string; provider: applyType; integrationModes: string[]; - config: string; + config?: string; description: string; page: { // 页面集成 baseUrl: string, @@ -54,7 +54,7 @@ export type formType = { roleIdList: string[], // 角色列表 orgIdList: string[], // 部门列表 ipWhiteList: string, // IP白名单 - signature: 'MD5' | 'SHA256' | '', // 签名方式, 可选值:MD5,SHA256 + signature?: 'MD5' | 'SHA256' | '', // 签名方式, 可选值:MD5,SHA256 enableOAuth2: boolean, // 是否启用OAuth2 }, sso: { // 统一单点登陆集成 diff --git a/src/views/system/Apply/componenets/MenuDialog.vue b/src/views/system/Apply/componenets/MenuDialog.vue new file mode 100644 index 00000000..bc4a5d7a --- /dev/null +++ b/src/views/system/Apply/componenets/MenuDialog.vue @@ -0,0 +1,196 @@ + + + + + diff --git a/src/views/system/Apply/index.vue b/src/views/system/Apply/index.vue index aa8d8021..d5b557f9 100644 --- a/src/views/system/Apply/index.vue +++ b/src/views/system/Apply/index.vue @@ -42,6 +42,7 @@ enabled: 'success', disabled: 'error', }" + hasMark > + + @@ -151,11 +160,15 @@
+
+ +