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 c484e271
authored
Aug 30, 2023
by
匡雅琴
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
接口联调
1 parent
34bd673b
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
405 additions
and
282 deletions
auto-imports.d.ts
components.d.ts
src/api/publicApi.ts
src/main.ts
src/type/index.ts
src/views/publicConfig/AddConfig.vue
src/views/publicConfig/AddModel.vue
src/views/publicConfig/configIndex.vue
src/views/publicConfig/index.vue
src/views/publicConfig/modelIndex.vue
auto-imports.d.ts
View file @
c484e27
...
@@ -26,5 +26,6 @@ declare global {
...
@@ -26,5 +26,6 @@ declare global {
const
ElTableColumn
:
typeof
import
(
'element-plus/es'
)[
'ElTableColumn'
]
const
ElTableColumn
:
typeof
import
(
'element-plus/es'
)[
'ElTableColumn'
]
const
ElTabPane
:
typeof
import
(
'element-plus/es'
)[
'ElTabPane'
]
const
ElTabPane
:
typeof
import
(
'element-plus/es'
)[
'ElTabPane'
]
const
ElTabs
:
typeof
import
(
'element-plus/es'
)[
'ElTabs'
]
const
ElTabs
:
typeof
import
(
'element-plus/es'
)[
'ElTabs'
]
const
ElTree
:
typeof
import
(
'element-plus/es'
)[
'ElTree'
]
}
}
export
{}
export
{}
components.d.ts
View file @
c484e27
...
@@ -33,6 +33,7 @@ declare module '@vue/runtime-core' {
...
@@ -33,6 +33,7 @@ declare module '@vue/runtime-core' {
ElTableColumn
:
typeof
import
(
'element-plus/es'
)[
'ElTableColumn'
]
ElTableColumn
:
typeof
import
(
'element-plus/es'
)[
'ElTableColumn'
]
ElTabPane
:
typeof
import
(
'element-plus/es'
)[
'ElTabPane'
]
ElTabPane
:
typeof
import
(
'element-plus/es'
)[
'ElTabPane'
]
ElTabs
:
typeof
import
(
'element-plus/es'
)[
'ElTabs'
]
ElTabs
:
typeof
import
(
'element-plus/es'
)[
'ElTabs'
]
ElTree
:
typeof
import
(
'element-plus/es'
)[
'ElTree'
]
HelloWorld
:
typeof
import
(
'./src/components/HelloWorld.vue'
)[
'default'
]
HelloWorld
:
typeof
import
(
'./src/components/HelloWorld.vue'
)[
'default'
]
RouterLink
:
typeof
import
(
'vue-router'
)[
'RouterLink'
]
RouterLink
:
typeof
import
(
'vue-router'
)[
'RouterLink'
]
RouterView
:
typeof
import
(
'vue-router'
)[
'RouterView'
]
RouterView
:
typeof
import
(
'vue-router'
)[
'RouterView'
]
...
...
src/api/publicApi.ts
View file @
c484e27
import
request
from
"@/api/request"
;
import
request
from
"@/api/request"
;
import
qs
from
"qs"
;
import
qs
from
"qs"
;
import
{
ModelAdd
,
ProjectApiSearch
}
from
"@/type/index"
;
import
{
ModelAdd
,
ConfigAdd
,
ModelDelete
}
from
"@/type/index"
;
const
modelUrl
=
{
const
modelUrl
=
{
list
:
"/template/list"
,
list
:
"/template/list"
,
add
:
"/template/add"
,
add
:
"/template/add"
,
edit
:
"/template/edit"
edit
:
"/template/edit"
,
delete
:
"/template/delete"
};
const
configUrl
=
{
list
:
"/config/list"
,
add
:
"/config/add"
,
edit
:
"/config/edit"
,
delete
:
"/config/delete"
};
};
export
const
getmodelList
=
()
=>
{
export
const
getmodelList
=
()
=>
{
...
@@ -16,4 +24,21 @@ const modelUrl = {
...
@@ -16,4 +24,21 @@ const modelUrl = {
};
};
export
const
modelApiEdit
=
(
params
:
ModelAdd
)
=>
{
export
const
modelApiEdit
=
(
params
:
ModelAdd
)
=>
{
return
request
.
post
(
modelUrl
.
edit
,
params
);
return
request
.
post
(
modelUrl
.
edit
,
params
);
};
export
const
modelApiDelete
=
(
params
:
ModelDelete
)
=>
{
return
request
.
post
(
modelUrl
.
delete
,
params
);
};
export
const
getconfigList
=
()
=>
{
return
request
.
get
(
configUrl
.
list
);
};
export
const
configApiAdd
=
(
params
:
ConfigAdd
)
=>
{
return
request
.
post
(
configUrl
.
add
,
params
);
};
export
const
configApiEdit
=
(
params
:
ConfigAdd
)
=>
{
return
request
.
post
(
configUrl
.
edit
,
params
);
};
export
const
configApiDelete
=
(
params
:
ModelDelete
)
=>
{
return
request
.
post
(
configUrl
.
delete
,
params
);
};
};
\ No newline at end of file
\ No newline at end of file
src/main.ts
View file @
c484e27
...
@@ -3,6 +3,10 @@ import App from "./App.vue";
...
@@ -3,6 +3,10 @@ import App from "./App.vue";
import
router
from
"./router"
;
import
router
from
"./router"
;
import
store
from
"./store"
;
import
store
from
"./store"
;
import
"element-plus/theme-chalk/src/message.scss"
;
import
"element-plus/theme-chalk/src/message.scss"
;
import
"element-plus/theme-chalk/el-loading.css"
;
import
"element-plus/theme-chalk/el-message.css"
;
import
"element-plus/theme-chalk/el-notification.css"
;
import
"element-plus/theme-chalk/el-message-box.css"
;
const
app
=
createApp
(
App
);
const
app
=
createApp
(
App
);
// 防止重复快速点击自定义全局指令
// 防止重复快速点击自定义全局指令
app
.
directive
(
"preventReClick"
,
{
app
.
directive
(
"preventReClick"
,
{
...
...
src/type/index.ts
View file @
c484e27
...
@@ -95,4 +95,15 @@ export interface ModelAdd {
...
@@ -95,4 +95,15 @@ export interface ModelAdd {
templateName
:
string
,
templateName
:
string
,
templateContent
:
string
,
templateContent
:
string
,
remark
:
string
remark
:
string
}
export
interface
ConfigAdd
{
name
:
string
,
remark
:
string
,
content
:
string
,
uniqueName
:
string
}
export
interface
ModelDelete
{
id
:
number
}
}
\ No newline at end of file
\ No newline at end of file
src/views/publicConfig/AddConfig.vue
View file @
c484e27
<
script
setup
lang=
"ts"
>
<
script
setup
lang=
"ts"
>
import
{
ref
,
reactive
}
from
"vue"
;
import
{
import
BackButton
from
"@/components/BackButton.vue"
;
ref
,
reactive
,
defineEmits
,
defineProps
,
withDefaults
,
watch
,
}
from
"vue"
;
import
type
{
FormInstance
,
FormRules
}
from
"element-plus"
;
import
type
{
FormInstance
,
FormRules
}
from
"element-plus"
;
import
{
onBeforeRouteLeave
,
useRouter
}
from
"vue-router
"
;
import
{
ElMessage
,
ElMessageBox
}
from
"element-plus
"
;
import
{
configApiAdd
,
configApiEdit
,
configApiDelete
}
from
"@/api/publicApi"
;
const
router
=
useRouter
()
;
import
{
Delete
}
from
"@element-plus/icons"
;
const
ruleFormRef
=
ref
<
FormInstance
>
();
const
ruleFormRef
=
ref
<
FormInstance
>
();
const
ruleForm
=
reactive
({
type
Props
=
{
data
:
{
id
:
number
;
name
:
string
;
uniqueName
:
string
;
content
:
string
;
remark
:
string
;
};
};
const
props
=
withDefaults
(
defineProps
<
Props
>
(),
{
data
:
()
=>
{
return
{
id
:
0
,
name
:
""
,
uniqueName
:
""
,
content
:
""
,
remark
:
""
};
},
});
let
ruleForm
=
reactive
({
name
:
""
,
name
:
""
,
identify
:
""
,
uniqueName
:
""
,
content
:
""
,
content
:
""
,
desc
:
""
,
remark
:
""
,
});
});
const
isEdit
=
ref
<
boolean
>
(
false
)
watch
(
()
=>
props
.
data
,
(
val
)
=>
{
console
.
log
(
444
);
// 获取编辑数据
let
keysLength
=
Object
.
keys
(
val
).
length
;
isEdit
.
value
=
true
if
(
keysLength
>
0
)
{
console
.
log
(
3333333333
);
//编辑
ruleForm
.
name
=
val
.
name
as
string
;
ruleForm
.
uniqueName
=
val
.
uniqueName
as
string
;
ruleForm
.
remark
=
val
.
remark
as
string
;
ruleForm
.
content
=
val
.
content
as
string
;
}
},
{
//如果加了这个参数,值为true的话,就消除了惰性,watch会在创建后立即执行一次
//那么首次执行,val为默认值,preVal为undefined
immediate
:
true
,
//这个参数代表监听对象时,可以监听深度嵌套的对象属性
//比如message是一个对象的话,可以监听到message.a.b.c,也就是message下的所有属性
deep
:
true
,
}
);
const
rules
=
reactive
<
FormRules
>
({
const
rules
=
reactive
<
FormRules
>
({
name
:
[{
required
:
true
,
message
:
"请输入公共配置项名称"
,
trigger
:
"blur"
}],
name
:
[{
required
:
true
,
message
:
"请输入公共配置项名称"
,
trigger
:
"blur"
}],
identify
:
{
required
:
true
,
message
:
"请输入公共配置项标识"
,
trigger
:
"blur"
},
uniqueName
:
{
content
:
{
required
:
true
,
message
:
"请输入公共配置项内容"
,
trigger
:
"blur"
},
required
:
true
,
desc
:
{
required
:
true
,
message
:
"请输入描述"
,
trigger
:
"blur"
},
message
:
"请输入公共配置项标识"
,
});
trigger
:
"blur"
,
},
content
:
{
required
:
true
,
message
:
"请输入公共配置项内容"
,
trigger
:
"blur"
},
remark
:
{
required
:
true
,
message
:
"请输入描述"
,
trigger
:
"blur"
},
});
const
resetForm
=
(
formEl
:
FormInstance
|
undefined
)
=>
{
const
resetForm
=
(
formEl
:
FormInstance
|
undefined
)
=>
{
if
(
!
formEl
)
return
;
if
(
!
formEl
)
return
;
formEl
.
resetFields
();
formEl
.
resetFields
();
};
};
const
emit
=
defineEmits
([
"configRefresh"
]);
const
goBack
=
()
=>
{
// 提交表单
router
.
go
(
-
1
);
const
submitForm
=
async
(
formEl
:
FormInstance
|
undefined
)
=>
{
};
if
(
!
formEl
)
return
;
await
formEl
.
validate
(
async
(
valid
)
=>
{
if
(
valid
)
{
// console.log("submit!");
//发起请求(新增或编辑)
let
message
;
let
statusCode
;
// 新增
let
{
code
}
=
await
configApiAdd
(
ruleForm
);
statusCode
=
code
;
message
=
code
===
200
?
"添加成功"
:
"添加失败,请稍后再试"
;
if
(
statusCode
===
200
)
{
ElMessage
({
type
:
"success"
,
message
,
});
emit
(
"configRefresh"
);
}
else
{
ElMessage
({
type
:
"info"
,
message
,
});
}
}
});
};
onBeforeRouteLeave
(()
=>
{
// 删除表单
sessionStorage
.
removeItem
(
"editConfigItem"
);
const
deletConfig
=
()
=>
{
console
.
log
(
props
.
data
.
id
);
ElMessageBox
.
confirm
(
"确认删除此公共模板吗?"
,
"删除"
,
{
distinguishCancelAndClose
:
true
,
confirmButtonText
:
"确认"
,
cancelButtonText
:
"取消"
,
})
.
then
(
async
()
=>
{
let
_params
=
{
id
:
props
.
data
.
id
,
};
let
{
code
}
=
await
configApiDelete
(
_params
);
if
(
code
===
200
)
{
ElMessage
({
type
:
'success'
,
message
:
'删除成功'
,
})
emit
(
"configRefresh"
);
}
})
.
catch
((
action
)
=>
{
// ElMessage({
// type: 'info',
// message:
// action === 'cancel'
// ? 'Changes discarded. Proceeding to a new route.'
// : 'Stay in the current route',
// })
});
});
};
</
script
>
</
script
>
<
template
>
<
template
>
<div
class=
"add-config"
>
<div
class=
"add-config"
>
<div
class=
"add-top"
>
<div
class=
"add-top"
>
<BackButton
v-preventReClick
@
click=
"goBack"
/>
<h3>
项目环境配置添加
</h3>
<h3>
项目环境配置添加
</h3>
<el-button
v-if=
"isEdit"
@
click=
"deletConfig"
type=
"danger"
:icon=
"Delete"
circle
/>
</div>
</div>
<el-form
<el-form
ref=
"ruleFormRef"
ref=
"ruleFormRef"
:model=
"ruleForm"
:model=
"ruleForm"
:rules=
"rules"
:rules=
"rules"
label-width=
"1
2
0px"
label-width=
"1
4
0px"
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"
/>
</el-form-item>
</el-form-item>
<el-form-item
label=
"公共配置项标识"
prop=
"
identify
"
>
<el-form-item
label=
"公共配置项标识"
prop=
"
uniqueName
"
>
<el-input
v-model=
"ruleForm.
identify
"
>
<el-input
v-model=
"ruleForm.
uniqueName
"
>
<template
#
prepend
>
@
</
template
>
<template
#
prepend
>
@
</
template
>
</el-input>
</el-input>
</el-form-item>
</el-form-item>
<el-form-item
label=
"公共配置项内容"
prop=
"content"
>
<el-form-item
label=
"公共配置项内容"
prop=
"content"
>
<el-input
v-model=
"ruleForm.content"
type=
"textarea"
/>
<el-input
v-model=
"ruleForm.content"
type=
"textarea"
/>
</el-form-item>
</el-form-item>
<el-form-item
label=
"描述"
prop=
"
desc
"
>
<el-form-item
label=
"描述"
prop=
"
remark
"
>
<el-input
v-model=
"ruleForm.
desc
"
type=
"textarea"
/>
<el-input
v-model=
"ruleForm.
remark
"
type=
"textarea"
/>
</el-form-item>
</el-form-item>
<el-form-item>
<el-form-item>
<el-button
<el-button
type=
"primary"
type=
"primary"
v-preventReClick
v-preventReClick
@
click=
"submitForm(ruleFormRef)"
@
click=
"submitForm(ruleFormRef)"
>
{{
keysLength > 0
? "编辑" : "创建" }}
</el-button
>
{{
isEdit
? "编辑" : "创建" }}
</el-button
>
>
<el-button
v-preventReClick
@
click=
"resetForm(ruleFormRef)"
<el-button
v-preventReClick
@
click=
"resetForm(ruleFormRef)"
>
重置
</el-button
>
重置
</el-button
...
@@ -85,6 +196,7 @@ const goBack = () => {
...
@@ -85,6 +196,7 @@ const goBack = () => {
//
text-align
:
center
;
//
text-align
:
center
;
.add-top
{
.add-top
{
display
:
flex
;
display
:
flex
;
justify-content
:
space-between
;
padding
:
10px
20px
;
padding
:
10px
20px
;
border-bottom
:
1px
solid
#ccc
;
border-bottom
:
1px
solid
#ccc
;
}
}
...
...
src/views/publicConfig/AddModel.vue
View file @
c484e27
<
script
setup
lang=
"ts"
>
<
script
setup
lang=
"ts"
>
import
{
ref
,
reactive
}
from
"vue"
;
import
{
import
BackButton
from
"@/components/BackButton.vue"
;
ref
,
import
type
{
FormInstance
,
FormRules
}
from
"element-plus"
;
reactive
,
import
{
onBeforeRouteLeave
,
useRouter
}
from
"vue-router"
;
defineEmits
,
import
{
ElMessage
}
from
"element-plus"
;
defineProps
,
import
"element-plus/theme-chalk/el-message.css"
;
withDefaults
,
import
{
modelApiAdd
,
modelApiEdit
}
from
"@/api/publicApi"
;
watch
,
}
from
"vue"
;
const
router
=
useRouter
();
import
type
{
FormInstance
,
FormRules
,
Action
}
from
"element-plus"
;
import
{
ElMessage
,
ElMessageBox
}
from
"element-plus"
;
import
{
modelApiAdd
,
modelApiEdit
,
modelApiDelete
}
from
"@/api/publicApi"
;
import
{
Delete
}
from
"@element-plus/icons"
;
const
ruleFormRef
=
ref
<
FormInstance
>
();
const
ruleFormRef
=
ref
<
FormInstance
>
();
type
Props
=
{
data
:
{
id
:
number
;
templateName
:
string
;
templateContent
:
string
;
remark
:
string
;
};
};
const
props
=
withDefaults
(
defineProps
<
Props
>
(),
{
data
:
()
=>
{
return
{
id
:
0
,
templateName
:
""
,
templateContent
:
""
,
remark
:
""
};
},
});
const
ruleForm
=
reactive
({
const
ruleForm
=
reactive
({
templateName
:
""
,
templateName
:
""
,
templateContent
:
""
,
templateContent
:
""
,
remark
:
""
,
remark
:
""
,
});
});
// 获取编辑数据
const
isEdit
=
ref
<
boolean
>
(
false
);
let
storageEditItem
=
window
.
sessionStorage
.
getItem
(
"editModelItem"
)
&&
JSON
.
parse
(
window
.
sessionStorage
.
getItem
(
"editModelItem"
)
||
""
);
let
routerParams
=
storageEditItem
||
{};
let
keysLength
=
Object
.
keys
(
routerParams
).
length
;
if
(
keysLength
>
0
)
{
watch
(
//编辑
()
=>
props
.
data
,
ruleForm
.
templateName
=
routerParams
.
name
as
string
;
(
val
)
=>
{
ruleForm
.
templateContent
=
routerParams
.
addr
as
string
;
console
.
log
(
555
);
ruleForm
.
remark
=
routerParams
.
remark
as
string
;
}
// 获取编辑数据
let
keysLength
=
Object
.
keys
(
val
).
length
;
isEdit
.
value
=
true
;
if
(
keysLength
>
0
)
{
console
.
log
(
666
);
//编辑
ruleForm
.
templateName
=
val
.
templateName
as
string
;
ruleForm
.
templateContent
=
val
.
templateContent
as
string
;
ruleForm
.
remark
=
val
.
remark
as
string
;
}
},
{
//如果加了这个参数,值为true的话,就消除了惰性,watch会在创建后立即执行一次
//那么首次执行,val为默认值,preVal为undefined
immediate
:
true
,
//这个参数代表监听对象时,可以监听深度嵌套的对象属性
//比如message是一个对象的话,可以监听到message.a.b.c,也就是message下的所有属性
deep
:
true
,
}
);
const
rules
=
reactive
<
FormRules
>
({
const
rules
=
reactive
<
FormRules
>
({
templateName
:
[
templateName
:
[
...
@@ -49,6 +82,8 @@ const resetForm = (formEl: FormInstance | undefined) => {
...
@@ -49,6 +82,8 @@ const resetForm = (formEl: FormInstance | undefined) => {
formEl
.
resetFields
();
formEl
.
resetFields
();
};
};
const
emit
=
defineEmits
([
"modelRefresh"
]);
// 提交表单
// 提交表单
const
submitForm
=
async
(
formEl
:
FormInstance
|
undefined
)
=>
{
const
submitForm
=
async
(
formEl
:
FormInstance
|
undefined
)
=>
{
if
(
!
formEl
)
return
;
if
(
!
formEl
)
return
;
...
@@ -58,31 +93,27 @@ const submitForm = async (formEl: FormInstance | undefined) => {
...
@@ -58,31 +93,27 @@ const submitForm = async (formEl: FormInstance | undefined) => {
//发起请求(新增或编辑)
//发起请求(新增或编辑)
let
message
;
let
message
;
let
statusCode
;
let
statusCode
;
if
(
keysLength
>
0
)
{
// 新增
//编辑
if
(
!
isEdit
.
value
)
{
let
params
=
{
let
{
code
}
=
await
modelApiAdd
(
ruleForm
);
...
routerParams
,
statusCode
=
code
;
message
=
code
===
200
?
"添加成功"
:
"添加失败,请稍后再试"
;
}
else
{
// 编辑
let
_params
=
{
...
ruleForm
,
...
ruleForm
,
id
:
p
arseInt
(
routerParams
.
id
as
string
)
,
id
:
p
rops
.
data
.
id
,
};
};
let
{
code
}
=
await
modelApiEdit
(
params
);
let
{
code
}
=
await
modelApiEdit
(
_
params
);
statusCode
=
code
;
statusCode
=
code
;
message
=
code
===
200
?
"编辑成功"
:
"编辑失败,请稍后再试"
;
message
=
code
===
200
?
"编辑成功"
:
"编辑失败,请稍后再试"
;
}
else
{
// 新增
let
{
code
}
=
await
modelApiAdd
(
ruleForm
);
statusCode
=
code
;
message
=
code
===
200
?
"添加成功"
:
"添加失败,请稍后再试"
;
}
}
if
(
statusCode
===
200
)
{
if
(
statusCode
===
200
)
{
ElMessage
({
ElMessage
({
type
:
"success"
,
type
:
"success"
,
message
,
message
,
});
});
requestAnimationFrame
(()
=>
{
emit
(
"modelRefresh"
);
// router.push({ name: "project" });
router
.
go
(
-
1
);
});
}
else
{
}
else
{
ElMessage
({
ElMessage
({
type
:
"info"
,
type
:
"info"
,
...
@@ -93,20 +124,50 @@ const submitForm = async (formEl: FormInstance | undefined) => {
...
@@ -93,20 +124,50 @@ const submitForm = async (formEl: FormInstance | undefined) => {
});
});
};
};
const
goBack
=
()
=>
{
// 删除表单
router
.
go
(
-
1
);
const
deletModel
=
()
=>
{
console
.
log
(
props
.
data
.
id
);
ElMessageBox
.
confirm
(
"确认删除此公共模板吗?"
,
"删除"
,
{
distinguishCancelAndClose
:
true
,
confirmButtonText
:
"确认"
,
cancelButtonText
:
"取消"
,
})
.
then
(
async
()
=>
{
let
_params
=
{
id
:
props
.
data
.
id
,
};
let
{
code
}
=
await
modelApiDelete
(
_params
);
if
(
code
===
200
)
{
ElMessage
({
type
:
"success"
,
message
:
"删除成功"
,
});
emit
(
"modelRefresh"
);
}
})
.
catch
((
action
:
Action
)
=>
{
// ElMessage({
// type: 'info',
// message:
// action === 'cancel'
// ? 'Changes discarded. Proceeding to a new route.'
// : 'Stay in the current route',
// })
});
};
};
onBeforeRouteLeave
(()
=>
{
sessionStorage
.
removeItem
(
"editModelItem"
);
});
</
script
>
</
script
>
<
template
>
<
template
>
<div
class=
"add-model"
>
<div
class=
"add-model"
>
<div
class=
"add-top"
>
<div
class=
"add-top"
>
<BackButton
v-preventReClick
@
click=
"goBack"
/>
<h3>
新建模板
</h3>
<h3>
新建模板
</h3>
<el-button
@
click=
"deletModel"
v-if=
"isEdit"
type=
"danger"
:icon=
"Delete"
circle
/>
</div>
</div>
<el-form
<el-form
ref=
"ruleFormRef"
ref=
"ruleFormRef"
...
@@ -129,7 +190,7 @@ onBeforeRouteLeave(() => {
...
@@ -129,7 +190,7 @@ onBeforeRouteLeave(() => {
type=
"primary"
type=
"primary"
v-preventReClick
v-preventReClick
@
click=
"submitForm(ruleFormRef)"
@
click=
"submitForm(ruleFormRef)"
>
{{
keysLength
>
0
?
"编辑"
:
"创建"
}}
</el-button
>
{{
isEdit
?
"编辑"
:
"创建"
}}
</el-button
>
>
<el-button
v-preventReClick
@
click=
"resetForm(ruleFormRef)"
<el-button
v-preventReClick
@
click=
"resetForm(ruleFormRef)"
>
重置
</el-button
>
重置
</el-button
...
@@ -143,6 +204,7 @@ onBeforeRouteLeave(() => {
...
@@ -143,6 +204,7 @@ onBeforeRouteLeave(() => {
.add-model
{
.add-model
{
.add-top
{
.add-top
{
display
:
flex
;
display
:
flex
;
justify-content
:
space-between
;
padding
:
10px
20px
;
padding
:
10px
20px
;
border-bottom
:
1px
solid
#ccc
;
border-bottom
:
1px
solid
#ccc
;
}
}
...
...
src/views/publicConfig/configIndex.vue
deleted
100644 → 0
View file @
34bd673
<
script
setup
lang=
"ts"
>
import
AddButton
from
"@/components/AddButton.vue"
;
import
{
reactive
,
ref
}
from
"vue"
;
import
{
ConfigList
}
from
"@/type/index"
;
import
router
from
"@/router"
;
const
state
:
{
configList
:
ConfigList
[]
}
=
reactive
({
configList
:
[]
})
const
addFn
=
(
flag
=
true
,
editorItem
?:
ConfigList
)
=>
{
// 判断是编辑还是新增
if
(
flag
)
{
//新增
router
.
push
({
name
:
"addconfig"
});
}
else
{
//编辑
router
.
push
({
name
:
"addconfig"
,
params
:
{
...
editorItem
}
});
window
.
sessionStorage
.
setItem
(
"editConfigItem"
,
JSON
.
stringify
(
editorItem
)
);
}
};
const
editFn
=
(
item
:
ConfigList
)
=>
{
console
.
log
(
item
);
addFn
(
false
,
item
);
}
const
deleteFn
=
(
item
:
ConfigList
)
=>
{
console
.
log
(
item
);
}
const
handerAddFn
=
()
=>
{
addFn
();
};
</
script
>
<
template
>
<h3>
公共配置项配置
</h3>
<el-row
:gutter=
"20"
>
<el-col
v-for=
"item in configList"
:key=
"item.id"
:xs=
"12"
:sm=
"9"
:md=
"8"
:lg=
"6"
:xl=
"4"
>
<el-card
:body-style=
"
{ padding: '0px' }"
shadow="hover"
v-preventReClick
>
<img
style=
"width: 100%; height: 240px"
src=
"../../assets/project.png"
class=
"image"
/>
<div
style=
"padding: 14px; position: relative"
>
<span>
项目名称:
{{
item
.
name
}}
</span>
<div>
项目描述:
{{
item
.
desc
}}
</div>
<div
class=
"bottom"
>
<el-button
class=
"button"
v-preventReClick
type=
"text"
@
click
.
stop=
"editFn(item)"
>
编辑
</el-button
>
<el-button
class=
"button"
v-preventReClick
type=
"text"
@
click
.
stop=
"deleteFn(item)"
>
删除
</el-button
>
</div>
</div>
</el-card>
</el-col>
</el-row>
<AddButton
@
click=
"handerAddFn"
/>
</
template
>
<
style
lang=
"scss"
scoped
>
h3
{
text-align
:
center
;
margin
:
20px
0
;
}
</
style
>
src/views/publicConfig/index.vue
View file @
c484e27
<
script
setup
lang=
"ts"
>
<
script
setup
lang=
"ts"
>
import
{
reactive
,
markRaw
}
from
"vue"
;
import
{
onBeforeMount
,
reactive
,
markRaw
}
from
"vue"
;
import
Config
Index
from
"./ConfigIndex
.vue"
;
import
Config
Add
from
"./AddConfig
.vue"
;
import
Model
Index
from
"./ModelIndex
.vue"
;
import
Model
Add
from
"./AddModel
.vue"
;
import
OperationRecord
from
"./OperationRecord.vue"
;
import
OperationRecord
from
"./OperationRecord.vue"
;
import
{
CirclePlus
,
ArrowDown
}
from
"@element-plus/icons"
;
import
{
getmodelList
,
getconfigList
}
from
"@/api/publicApi"
;
type
tabType
=
{
type
tabType
=
{
name
:
string
;
label
:
string
;
tabComp
:
any
;
tabComp
:
any
;
children
?:
any
;
};
};
type
Comp
=
Pick
<
tabType
,
"tabComp"
>
;
type
Comp
=
Pick
<
tabType
,
"tabComp"
>
;
const
tabData
=
reactive
<
tabType
[]
>
([
const
tabData
=
reactive
<
tabType
[]
>
([
{
{
name
:
"公共配置项"
,
label
:
"公共配置项"
,
// proxy会代理reactive中的所有内容
// proxy会代理reactive中的所有内容
// 无需对组件进行proxy代理
// 无需对组件进行proxy代理
// 必须使用markRaw跳过对组件的代理,否则vue会给警告
// 必须使用markRaw跳过对组件的代理,否则vue会给警告
tabComp
:
markRaw
(
ConfigIndex
),
tabComp
:
markRaw
(
ConfigAdd
),
children
:
[],
},
},
{
{
name
:
"公共模板"
,
label
:
"公共模板"
,
tabComp
:
markRaw
(
ModelIndex
),
tabComp
:
markRaw
(
ModelAdd
),
},
children
:
[],
{
name
:
"操作记录"
,
tabComp
:
markRaw
(
OperationRecord
),
},
},
// {
// label: "操作记录",
// tabComp: markRaw(OperationRecord),
// },
]);
]);
// 最初展示menu
let
currentTab
=
reactive
<
Comp
>
({
let
currentTab
=
reactive
<
Comp
>
({
tabComp
:
tabData
[
0
].
tabComp
,
tabComp
:
tabData
[
0
].
tabComp
,
});
});
const
switchTab
=
(
tab
:
number
)
=>
{
// 添加公共模板
currentTab
.
tabComp
=
tabData
[
tab
].
tabComp
;
const
addConfig
=
(
index
:
number
)
=>
{
console
.
log
(
index
);
currentTab
.
tabComp
=
tabData
[
index
].
tabComp
;
};
// 页面加载
onBeforeMount
(()
=>
{
getModelData
();
getConfigData
()
});
// 获取模板数据
const
getModelData
=
async
()
=>
{
let
{
code
,
data
}
=
await
getmodelList
();
if
(
code
===
200
)
{
console
.
log
(
data
);
tabData
[
1
].
children
=
[]
tabData
[
1
].
children
.
push
(...
data
)
console
.
log
(
tabData
[
1
]);
}
};
};
// 获取配置项数据
const
getConfigData
=
async
()
=>
{
let
{
code
,
data
}
=
await
getconfigList
();
if
(
code
===
200
)
{
console
.
log
(
data
);
tabData
[
0
].
children
=
[]
tabData
[
0
].
children
.
push
(...
data
)
}
};
// 模板更新
const
modelRefresh
=
()
=>
{
getModelData
()
currentTab
.
tabComp
=
tabData
[
0
].
tabComp
;
}
// 配置项更新
const
configRefresh
=
()
=>
{
getConfigData
()
currentTab
.
tabComp
=
tabData
[
0
].
tabComp
;
}
let
propsData
=
reactive
({})
// 点击子菜单
const
clickSubItem
=
(
index
:
number
,
item
:
any
)
=>
{
console
.
log
(
index
,
item
);
propsData
=
{...
item
}
currentTab
.
tabComp
=
tabData
[
index
].
tabComp
;
}
</
script
>
</
script
>
<
template
>
<
template
>
<el-container>
<el-container>
<el-aside
width=
"2
00px"
>
<el-aside
class=
"side-content"
width=
"3
00px"
>
<el-tabs
<
!--
<
el-tabs
:tab-position=
"'left'"
:tab-position=
"'left'"
style=
"height: 200px"
style=
"height: 200px"
class=
"demo-tabs"
class=
"demo-tabs"
...
@@ -50,12 +107,51 @@ const switchTab = (tab: number) => {
...
@@ -50,12 +107,51 @@ const switchTab = (tab: number) => {
<el-tab-pane
label=
"公共配置项配置"
></el-tab-pane>
<el-tab-pane
label=
"公共配置项配置"
></el-tab-pane>
<el-tab-pane
label=
"公共模板配置"
></el-tab-pane>
<el-tab-pane
label=
"公共模板配置"
></el-tab-pane>
<el-tab-pane
label=
"操作记录"
></el-tab-pane>
<el-tab-pane
label=
"操作记录"
></el-tab-pane>
</el-tabs>
</el-tabs>
-->
<div
v-for=
"(item, index) in tabData"
:key=
"index"
>
<div
class=
"menu-item"
>
<div>
<el-icon><ArrowDown
/></el-icon>
{{
item
.
label
}}
</div>
<el-icon
@
click=
"addConfig(index)"
><CirclePlus
/></el-icon>
</div>
<template
v-if=
"item.children?.length"
>
<div
class=
"submenu-item"
v-for=
"(itm, inx) in item.children"
:key=
"inx"
@
click=
"clickSubItem(index, itm)"
>
{{
itm
.
templateName
||
itm
.
name
}}
</div>
</
template
>
</div>
</el-aside>
</el-aside>
<el-main>
<el-main>
<component
:is=
"currentTab.tabComp"
></component>
<component
@
modelRefresh=
"modelRefresh"
@
configRefresh=
"configRefresh"
:data=
"propsData"
:is=
"currentTab.tabComp"
></component>
</el-main>
</el-main>
</el-container>
</el-container>
</template>
</template>
<
style
lang=
"scss"
scoped
></
style
>
<
style
lang=
"scss"
scoped
>
.side-content
{
padding
:
20px
;
border-right
:
1px
solid
#ccc
;
cursor
:
pointer
;
}
.menu-item
{
display
:
flex
;
justify-content
:
space-between
;
font-weight
:
500
;
font-size
:
20px
;
}
.submenu-item
{
margin-left
:
30px
;
font-size
:
18px
;
color
:
#555555
;
}
.submenu-item
:hover
{
color
:
#34AFFF
;
}
</
style
>
src/views/publicConfig/modelIndex.vue
deleted
100644 → 0
View file @
34bd673
<
script
setup
lang=
"ts"
>
import
AddButton
from
"@/components/AddButton.vue"
;
import
{
onMounted
,
reactive
,
ref
}
from
"vue"
;
import
{
ModelList
}
from
"@/type/index"
;
import
router
from
"@/router"
;
import
{
getmodelList
}
from
"@/api/publicApi"
;
const
state
:
{
ModelList
:
ModelList
[];
}
=
reactive
({
ModelList
:
[],
});
onMounted
(()
=>
{
getData
()
})
// 获取数据
const
getData
=
async
()
=>
{
let
{
code
,
data
}
=
await
getmodelList
();
if
(
code
===
200
)
{
state
.
ModelList
=
data
;
}
};
const
addFn
=
(
flag
=
true
,
editorItem
?:
ModelList
)
=>
{
// 判断是编辑还是新增
if
(
flag
)
{
//新增
router
.
push
({
name
:
"addmodel"
});
}
else
{
//编辑
router
.
push
({
name
:
"addmodel"
,
params
:
{
...
editorItem
}
});
window
.
sessionStorage
.
setItem
(
"editModelItem"
,
JSON
.
stringify
(
editorItem
));
}
};
const
editFn
=
(
item
:
ModelList
)
=>
{
console
.
log
(
item
);
addFn
(
false
,
item
);
};
const
handerAddFn
=
()
=>
{
addFn
();
};
</
script
>
<
template
>
<h3>
公共模板配置
</h3>
{{
ModelList
}}
<el-row
:gutter=
"20"
>
<el-col
v-for=
"item in ModelList"
:key=
"item.id"
:xs=
"12"
:sm=
"9"
:md=
"8"
:lg=
"6"
:xl=
"4"
>
<el-card
:body-style=
"
{ padding: '0px' }" shadow="hover" v-preventReClick>
<img
style=
"width: 100%; height: 240px"
src=
"../../assets/project.png"
class=
"image"
/>
<div
style=
"padding: 14px; position: relative"
>
<span>
项目名称:
{{
item
.
templateName
}}
</span>
<div>
项目描述:
{{
item
.
templateContent
}}
</div>
<div
class=
"bottom"
>
<el-button
class=
"button"
v-preventReClick
type=
"text"
@
click
.
stop=
"editFn(item)"
>
编辑
</el-button
>
</div>
</div>
</el-card>
</el-col>
</el-row>
<AddButton
@
click=
"handerAddFn"
/>
</
template
>
<
style
lang=
"scss"
scoped
>
h3
{
text-align
:
center
;
margin
:
20px
0
;
}
</
style
>
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