Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
陆宇天
/
config-center-front
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
1
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 3bade8f9
authored
Sep 18, 2023
by
匡雅琴
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
已知bug修复
1 parent
f97edfb4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
96 additions
and
70 deletions
src/api/publicApi.ts
src/views/publicConfig/AddConfig.vue
src/views/publicConfig/AddModel.vue
src/views/publicConfig/index.vue
src/api/publicApi.ts
View file @
3bade8f
...
@@ -13,7 +13,8 @@ const modelUrl = {
...
@@ -13,7 +13,8 @@ const modelUrl = {
list
:
"/config/list"
,
list
:
"/config/list"
,
add
:
"/config/add"
,
add
:
"/config/add"
,
edit
:
"/config/edit"
,
edit
:
"/config/edit"
,
delete
:
"/config/delete"
delete
:
"/config/delete"
,
isUniqueName
:
"/config/isUnique"
};
};
export
const
getmodelList
=
()
=>
{
export
const
getmodelList
=
()
=>
{
...
@@ -41,4 +42,7 @@ const modelUrl = {
...
@@ -41,4 +42,7 @@ const modelUrl = {
};
};
export
const
configApiDelete
=
(
params
:
ModelDelete
)
=>
{
export
const
configApiDelete
=
(
params
:
ModelDelete
)
=>
{
return
request
.
post
(
configUrl
.
delete
,
params
);
return
request
.
post
(
configUrl
.
delete
,
params
);
};
export
const
configApiisUniqueName
=
(
params
:
any
)
=>
{
return
request
.
get
(
configUrl
.
isUniqueName
,
params
);
};
};
\ No newline at end of file
\ No newline at end of file
src/views/publicConfig/AddConfig.vue
View file @
3bade8f
...
@@ -9,7 +9,7 @@ import {
...
@@ -9,7 +9,7 @@ import {
}
from
"vue"
;
}
from
"vue"
;
import
type
{
FormInstance
,
FormRules
}
from
"element-plus"
;
import
type
{
FormInstance
,
FormRules
}
from
"element-plus"
;
import
{
ElMessage
,
ElMessageBox
}
from
"element-plus"
;
import
{
ElMessage
,
ElMessageBox
}
from
"element-plus"
;
import
{
configApiAdd
,
configApiEdit
,
configApiDelete
}
from
"@/api/publicApi"
;
import
{
configApiAdd
,
configApiEdit
,
configApiDelete
,
configApiisUniqueName
}
from
"@/api/publicApi"
;
import
{
Delete
}
from
"@element-plus/icons-vue"
;
import
{
Delete
}
from
"@element-plus/icons-vue"
;
import
AceEditor
from
"@/components/AceEditor.vue"
;
import
AceEditor
from
"@/components/AceEditor.vue"
;
...
@@ -92,82 +92,88 @@ const submitForm = async (formEl: FormInstance | undefined) => {
...
@@ -92,82 +92,88 @@ const submitForm = async (formEl: FormInstance | undefined) => {
await
formEl
.
validate
(
async
(
valid
)
=>
{
await
formEl
.
validate
(
async
(
valid
)
=>
{
if
(
valid
)
{
if
(
valid
)
{
//发起请求(新增或编辑)
//发起请求(新增或编辑)
let
m
essage
;
let
statusM
essage
;
let
statusCode
;
let
statusCode
;
// 新增
// 新增
if
(
!
isEdit
.
value
)
{
if
(
!
isEdit
.
value
)
{
let
{
code
}
=
await
configApiAdd
(
ruleForm
);
ruleForm
.
uniqueName
=
'@'
+
ruleForm
.
uniqueName
;
console
.
log
(
ruleForm
);
let
{
code
,
message
}
=
await
configApiAdd
(
ruleForm
);
statusCode
=
code
;
statusCode
=
code
;
message
=
code
===
200
?
"添加成功"
:
"添加失败,请稍后再试"
;
statusMessage
=
code
===
200
?
"添加成功"
:
message
;
}
else
{
}
else
{
// 编辑
// 编辑
let
_params
=
{
let
_params
=
{
...
ruleForm
,
...
ruleForm
,
id
:
props
.
data
.
id
,
id
:
props
.
data
.
id
,
};
};
let
{
code
}
=
await
configApiEdit
(
_params
);
_params
.
uniqueName
=
'@'
+
_params
.
uniqueName
;
let
{
code
,
message
}
=
await
configApiEdit
(
_params
);
statusCode
=
code
;
statusCode
=
code
;
message
=
code
===
200
?
"编辑成功"
:
"编辑失败,请稍后再试"
;
statusMessage
=
code
===
200
?
"编辑成功"
:
message
;
}
}
if
(
statusCode
===
200
)
{
if
(
statusCode
===
200
)
{
ElMessage
({
ElMessage
.
success
(
statusMessage
);
type
:
"success"
,
message
,
});
emit
(
"configRefresh"
);
emit
(
"configRefresh"
);
}
else
{
}
else
{
ElMessage
({
ElMessage
.
error
(
statusMessage
);
type
:
"info"
,
message
,
});
}
}
}
}
});
});
};
};
// 删除表单
// 删除表单
const
deletConfig
=
()
=>
{
// const deletConfig = () => {
ElMessageBox
.
confirm
(
"确认删除此公共模板吗?"
,
"删除"
,
{
// ElMessageBox.confirm("确认删除此公共模板吗?", "删除", {
distinguishCancelAndClose
:
true
,
// distinguishCancelAndClose: true,
confirmButtonText
:
"确认"
,
// confirmButtonText: "确认",
cancelButtonText
:
"取消"
,
// cancelButtonText: "取消",
})
// })
.
then
(
async
()
=>
{
// .then(async () => {
let
_params
=
{
// let _params = {
id
:
props
.
data
.
id
,
// id: props.data.id,
};
// };
let
{
code
}
=
await
configApiDelete
(
_params
);
// let { code } = await configApiDelete(_params);
if
(
code
===
200
)
{
// if (code === 200) {
ElMessage
({
// ElMessage({
type
:
"success"
,
// type: "success",
message
:
"删除成功"
,
// message: "删除成功",
});
// });
emit
(
"configRefresh"
);
// emit("configRefresh");
}
// }
})
// })
.
catch
((
action
)
=>
{
// .catch((action) => {
// ElMessage({
// // ElMessage({
// type: 'info',
// // type: 'info',
// message:
// // message:
// action === 'cancel'
// // action === 'cancel'
// ? 'Changes discarded. Proceeding to a new route.'
// // ? 'Changes discarded. Proceeding to a new route.'
// : 'Stay in the current route',
// // : 'Stay in the current route',
// })
// // })
});
// });
};
// };
// 校验配置项是否唯一
const
isUniqueName
=
async
()
=>
{
const
_params
=
'@'
+
ruleForm
.
uniqueName
let
{
code
,
message
}
=
await
configApiisUniqueName
(
_params
);
console
.
log
(
code
,
message
);
}
</
script
>
</
script
>
<
template
>
<
template
>
<div
class=
"add-config"
>
<div
class=
"add-config"
>
<div
class=
"add-top"
>
<div
class=
"add-top"
>
<h3>
项目环境配置添加
</h3>
<h3>
项目环境配置添加
</h3>
<el-button
<
!--
<
el-button
v-if=
"isEdit"
v-if=
"isEdit"
@
click=
"deletConfig"
@
click=
"deletConfig"
type=
"danger"
type=
"danger"
:icon=
"Delete"
:icon=
"Delete"
circle
circle
/>
/>
-->
</div>
</div>
<el-form
<el-form
ref=
"ruleFormRef"
ref=
"ruleFormRef"
...
@@ -177,10 +183,10 @@ const deletConfig = () => {
...
@@ -177,10 +183,10 @@ const deletConfig = () => {
class=
"demo-ruleForm"
class=
"demo-ruleForm"
>
>
<el-form-item
label=
"公共配置项名称"
prop=
"name"
>
<el-form-item
label=
"公共配置项名称"
prop=
"name"
>
<el-input
v-model=
"ruleForm.name"
/>
<el-input
v-model=
"ruleForm.name"
maxlength=
"20"
/>
</el-form-item>
</el-form-item>
<el-form-item
label=
"公共配置项标识"
prop=
"uniqueName"
>
<el-form-item
label=
"公共配置项标识"
prop=
"uniqueName"
>
<el-input
v-model=
"ruleForm.uniqueName"
>
<el-input
v-model=
"ruleForm.uniqueName"
:disabled=
"isEdit"
@
blur=
"isUniqueName"
>
<template
#
prepend
>
@
</
template
>
<template
#
prepend
>
@
</
template
>
</el-input>
</el-input>
</el-form-item>
</el-form-item>
...
...
src/views/publicConfig/AddModel.vue
View file @
3bade8f
...
@@ -74,7 +74,7 @@ const rules = reactive<FormRules>({
...
@@ -74,7 +74,7 @@ const rules = reactive<FormRules>({
message
:
"请输入模板内容"
,
message
:
"请输入模板内容"
,
trigger
:
"blur"
,
trigger
:
"blur"
,
},
},
desc
:
{
required
:
true
,
message
:
"请输入描述"
,
trigger
:
"blur"
},
remark
:
{
required
:
true
,
message
:
"请输入描述"
,
trigger
:
"blur"
},
});
});
// 重置表单
// 重置表单
...
@@ -92,34 +92,28 @@ const submitForm = async (formEl: FormInstance | undefined) => {
...
@@ -92,34 +92,28 @@ const submitForm = async (formEl: FormInstance | undefined) => {
await
formEl
.
validate
(
async
(
valid
)
=>
{
await
formEl
.
validate
(
async
(
valid
)
=>
{
if
(
valid
)
{
if
(
valid
)
{
//发起请求(新增或编辑)
//发起请求(新增或编辑)
let
m
essage
;
let
statusM
essage
;
let
statusCode
;
let
statusCode
;
// 新增
// 新增
if
(
!
isEdit
.
value
)
{
if
(
!
isEdit
.
value
)
{
let
{
code
}
=
await
modelApiAdd
(
ruleForm
);
let
{
code
,
message
}
=
await
modelApiAdd
(
ruleForm
);
statusCode
=
code
;
statusCode
=
code
;
message
=
code
===
200
?
"添加成功"
:
"添加失败,请稍后再试"
;
statusMessage
=
code
===
200
?
"添加成功"
:
message
;
}
else
{
}
else
{
// 编辑
// 编辑
let
_params
=
{
let
_params
=
{
...
ruleForm
,
...
ruleForm
,
id
:
props
.
data
.
id
,
id
:
props
.
data
.
id
,
};
};
let
{
code
}
=
await
modelApiEdit
(
_params
);
let
{
code
,
message
}
=
await
modelApiEdit
(
_params
);
statusCode
=
code
;
statusCode
=
code
;
message
=
code
===
200
?
"编辑成功"
:
"编辑失败,请稍后再试"
;
statusMessage
=
code
===
200
?
"编辑成功"
:
message
;
}
}
if
(
statusCode
===
200
)
{
if
(
statusCode
===
200
)
{
ElMessage
({
ElMessage
.
success
(
statusMessage
);
type
:
"success"
,
message
,
});
emit
(
"modelRefresh"
);
emit
(
"modelRefresh"
);
}
else
{
}
else
{
ElMessage
({
ElMessage
.
error
(
statusMessage
);
type
:
"info"
,
message
,
});
}
}
}
}
});
});
...
@@ -181,7 +175,7 @@ onUnmounted(() =>{
...
@@ -181,7 +175,7 @@ onUnmounted(() =>{
class=
"demo-ruleForm"
class=
"demo-ruleForm"
>
>
<el-form-item
label=
"模板名称"
prop=
"templateName"
>
<el-form-item
label=
"模板名称"
prop=
"templateName"
>
<el-input
v-model=
"ruleForm.templateName"
/>
<el-input
v-model=
"ruleForm.templateName"
maxlength=
"20"
/>
</el-form-item>
</el-form-item>
<el-form-item
label=
"模板内容"
prop=
"templateContent"
>
<el-form-item
label=
"模板内容"
prop=
"templateContent"
>
<!--
<el-input
v-model=
"ruleForm.templateContent"
type=
"textarea"
/>
-->
<!--
<el-input
v-model=
"ruleForm.templateContent"
type=
"textarea"
/>
-->
...
...
src/views/publicConfig/index.vue
View file @
3bade8f
<
script
setup
lang=
"ts"
>
<
script
setup
lang=
"ts"
>
import
{
onBeforeMount
,
reactive
,
markRaw
}
from
"vue"
;
import
{
onBeforeMount
,
reactive
,
markRaw
,
nextTick
}
from
"vue"
;
import
ConfigAdd
from
"./AddConfig.vue"
;
import
ConfigAdd
from
"./AddConfig.vue"
;
import
ModelAdd
from
"./AddModel.vue"
;
import
ModelAdd
from
"./AddModel.vue"
;
import
OperationRecord
from
"./OperationRecord.vue"
;
import
OperationRecord
from
"./OperationRecord.vue"
;
import
{
CirclePlus
,
ArrowDown
}
from
"@element-plus/icons"
;
import
{
CirclePlus
,
ArrowDown
,
ArrowUp
}
from
"@element-plus/icons"
;
import
{
getmodelList
,
getconfigList
}
from
"@/api/publicApi"
;
import
{
getmodelList
,
getconfigList
}
from
"@/api/publicApi"
;
import
Public
from
'./Public.vue'
;
import
Public
from
'./Public.vue'
;
...
@@ -11,6 +11,7 @@ type tabType = {
...
@@ -11,6 +11,7 @@ type tabType = {
label
:
string
;
label
:
string
;
tabComp
:
any
;
tabComp
:
any
;
children
?:
any
;
children
?:
any
;
tabShow
?:
boolean
;
};
};
type
Comp
=
Pick
<
tabType
,
"tabComp"
>
;
type
Comp
=
Pick
<
tabType
,
"tabComp"
>
;
...
@@ -23,11 +24,13 @@ const tabData = reactive<tabType[]>([
...
@@ -23,11 +24,13 @@ const tabData = reactive<tabType[]>([
// 必须使用markRaw跳过对组件的代理,否则vue会给警告
// 必须使用markRaw跳过对组件的代理,否则vue会给警告
tabComp
:
markRaw
(
ConfigAdd
),
tabComp
:
markRaw
(
ConfigAdd
),
children
:
[],
children
:
[],
tabShow
:
true
},
},
{
{
label
:
"公共模板"
,
label
:
"公共模板"
,
tabComp
:
markRaw
(
ModelAdd
),
tabComp
:
markRaw
(
ModelAdd
),
children
:
[],
children
:
[],
tabShow
:
true
},
},
// {
// {
// label: "操作记录",
// label: "操作记录",
...
@@ -46,9 +49,12 @@ let currentTab = reactive<Comp>({
...
@@ -46,9 +49,12 @@ let currentTab = reactive<Comp>({
// 添加公共模板
// 添加公共模板
const
addConfig
=
(
index
:
number
)
=>
{
const
addConfig
=
(
index
:
number
)
=>
{
propsData
=
{}
console
.
log
(
index
);
console
.
log
(
index
);
currentTab
.
tabComp
=
tabData
[
index
].
tabComp
;
propsData
=
{}
currentTab
.
tabComp
=
''
nextTick
(()
=>
{
currentTab
.
tabComp
=
tabData
[
index
].
tabComp
;
});
};
};
// 页面加载
// 页面加载
...
@@ -100,6 +106,12 @@ const clickSubItem = (index: number, item: any) => {
...
@@ -100,6 +106,12 @@ const clickSubItem = (index: number, item: any) => {
currentTab
.
tabComp
=
''
currentTab
.
tabComp
=
''
currentTab
.
tabComp
=
tabData
[
index
].
tabComp
;
currentTab
.
tabComp
=
tabData
[
index
].
tabComp
;
}
}
// 菜单展开收起
const
clickTabShow
=
(
index
:
number
)
=>
{
tabData
[
index
].
tabShow
=
!
tabData
[
index
].
tabShow
;
}
</
script
>
</
script
>
<
template
>
<
template
>
...
@@ -117,13 +129,16 @@ const clickSubItem = (index: number, item: any) => {
...
@@ -117,13 +129,16 @@ const clickSubItem = (index: number, item: any) => {
</el-tabs>
-->
</el-tabs>
-->
<div
v-for=
"(item, index) in tabData"
:key=
"index"
>
<div
v-for=
"(item, index) in tabData"
:key=
"index"
>
<div
class=
"menu-item"
v-if=
"index !== tabData.length-1"
>
<div
class=
"menu-item"
v-if=
"index !== tabData.length-1"
>
<div>
<div
class=
"menu-icon"
>
<el-icon><ArrowDown
/></el-icon>
<div
@
click=
"clickTabShow(index)"
>
<el-icon
v-show=
"item.tabShow"
><ArrowDown
/></el-icon>
<el-icon
v-show=
"!item.tabShow"
><ArrowUp
/></el-icon>
</div>
{{
item
.
label
}}
{{
item
.
label
}}
</div>
</div>
<el-icon
@
click=
"addConfig(index)"
><CirclePlus
/></el-icon>
<el-icon
@
click=
"addConfig(index)"
><CirclePlus
/></el-icon>
</div>
</div>
<template
v-if=
"item.children?.length"
>
<template
v-if=
"item.children?.length
&& item.tabShow
"
>
<div
<div
class=
"submenu-item"
class=
"submenu-item"
v-for=
"(itm, inx) in item.children"
v-for=
"(itm, inx) in item.children"
...
@@ -154,11 +169,18 @@ const clickSubItem = (index: number, item: any) => {
...
@@ -154,11 +169,18 @@ const clickSubItem = (index: number, item: any) => {
font-size
:
20px
;
font-size
:
20px
;
line-height
:
30px
;
line-height
:
30px
;
}
}
.menu-icon
{
display
:
flex
;
}
.submenu-item
{
.submenu-item
{
margin-left
:
30px
;
margin-left
:
30px
;
font-size
:
18px
;
font-size
:
18px
;
line-height
:
30px
;
line-height
:
30px
;
color
:
#555555
;
color
:
#555555
;
overflow
:
hidden
;
white-space
:
nowrap
;
text-overflow
:
ellipsis
;
-o-text-overflow
:
ellipsis
;
}
}
.submenu-item
:hover
{
.submenu-item
:hover
{
color
:
#34AFFF
;
color
:
#34AFFF
;
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment