Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Q
qa-platform-ui
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
QA
qa-platform-ui
Commits
971dbab1
Commit
971dbab1
authored
Mar 22, 2021
by
黎博
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化mock模块
parent
82871958
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
69 additions
and
12 deletions
+69
-12
main.js
src/main.js
+5
-1
Mock.vue
src/views/Mock/Mock.vue
+64
-11
No files found.
src/main.js
View file @
971dbab1
...
...
@@ -36,7 +36,9 @@ import {
Dialog
,
Tabs
,
TabPane
,
Switch
Switch
,
RadioGroup
,
Radio
}
from
'
element-ui
'
Vue
.
config
.
productionTip
=
false
...
...
@@ -76,6 +78,8 @@ Vue.use(Dialog)
Vue
.
use
(
Tabs
)
Vue
.
use
(
TabPane
)
Vue
.
use
(
Switch
)
Vue
.
use
(
RadioGroup
)
Vue
.
use
(
Radio
)
/* eslint-disable no-new */
new
Vue
({
el
:
'
#app
'
,
...
...
src/views/Mock/Mock.vue
View file @
971dbab1
...
...
@@ -81,11 +81,31 @@
<el-form-item
label=
"描述"
>
<el-input
v-model=
"addMockForm.description"
></el-input>
</el-form-item>
<el-form-item
label=
"返回类型"
>
<el-radio-group
v-model=
"addMockForm.type"
>
<el-radio
:label=
"1"
>
json
</el-radio>
<el-radio
:label=
"2"
>
字符串
</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item
label=
"是否加密"
>
<el-radio-group
v-model=
"addMockForm.encrypt"
>
<el-radio
:label=
"0"
>
不加密
</el-radio>
<el-radio
:label=
"1"
>
加密
</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item
label=
"所属模块"
>
<el-select
v-model=
"addMockForm.modlue"
placeholder=
"模块"
clearable
>
<el-option
v-for=
"item in moduleList"
:key=
"item.id"
:label=
"item.name"
:value=
"item.id"
>
</el-option>
</el-select>
</el-form-item>
<el-form-item
label=
"成功响应"
>
<vue-json-editor
v-model=
"addMockForm.success"
:mode=
"'code'"
:showBtns=
"false"
lang=
"zh"
@
json-change=
"onSuccessJsonChange"
@
json-save=
"onSuccessJsonSave"
/>
<vue-json-editor
v-if=
"addMockForm.type === 1"
v-model=
"addMockForm.success"
:mode=
"'code'"
:showBtns=
"false"
lang=
"zh"
@
json-change=
"onSuccessJsonChange"
@
json-save=
"onSuccessJsonSave"
/>
<el-input
v-else-if=
"addMockForm.type === 2"
v-model=
"addMockForm.success"
type=
"textarea"
></el-input>
</el-form-item>
<el-form-item
label=
"失败响应"
>
<vue-json-editor
v-model=
"addMockForm.fail"
:mode=
"'code'"
:showBtns=
"false"
lang=
"zh"
@
json-change=
"onFailJsonChange"
@
json-save=
"onFailJsonSave"
/>
<vue-json-editor
v-if=
"addMockForm.type === 1"
v-model=
"addMockForm.fail"
:mode=
"'code'"
:showBtns=
"false"
lang=
"zh"
@
json-change=
"onFailJsonChange"
@
json-save=
"onFailJsonSave"
/>
<el-input
v-else-if=
"addMockForm.type === 2"
v-model=
"addMockForm.fail"
type=
"textarea"
></el-input>
</el-form-item>
<el-form-item
label=
"当前返回"
>
<el-switch
v-model=
"addMockForm.flag"
active-color=
"#13ce66"
inactive-color=
"#ff4949"
active-value=
"1"
inactive-value=
"0"
>
...
...
@@ -107,11 +127,31 @@
<el-form-item
label=
"描述"
>
<el-input
v-model=
"editMockForm.description"
></el-input>
</el-form-item>
<el-form-item
label=
"返回类型"
>
<el-radio-group
v-model=
"editMockForm.type"
>
<el-radio
:label=
"1"
>
json
</el-radio>
<el-radio
:label=
"2"
>
字符串
</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item
label=
"是否加密"
>
<el-radio-group
v-model=
"editMockForm.encrypt"
>
<el-radio
:label=
"0"
>
不加密
</el-radio>
<el-radio
:label=
"1"
>
加密
</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item
label=
"所属模块"
>
<el-select
v-model=
"editMockForm.modlue"
placeholder=
"模块"
clearable
>
<el-option
v-for=
"item in moduleList"
:key=
"item.id"
:label=
"item.name"
:value=
"item.id"
>
</el-option>
</el-select>
</el-form-item>
<el-form-item
label=
"成功响应"
>
<vue-json-editor
v-model=
"editMockForm.success"
:mode=
"'code'"
:showBtns=
"false"
lang=
"zh"
@
json-change=
"onSuccessJsonChange"
@
json-save=
"onSuccessJsonSave"
/>
<vue-json-editor
v-if=
"editMockForm.type === 1"
v-model=
"editMockForm.success"
:mode=
"'code'"
:showBtns=
"false"
lang=
"zh"
@
json-change=
"onSuccessJsonChange"
@
json-save=
"onSuccessJsonSave"
/>
<el-input
v-else-if=
"editMockForm.type === 2"
v-model=
"editMockForm.success"
type=
"textarea"
></el-input>
</el-form-item>
<el-form-item
label=
"失败响应"
>
<vue-json-editor
v-model=
"editMockForm.fail"
:mode=
"'code'"
:showBtns=
"false"
lang=
"zh"
@
json-change=
"onFailJsonChange"
@
json-save=
"onFailJsonSave"
/>
<vue-json-editor
v-if=
"editMockForm.type === 1"
v-model=
"editMockForm.fail"
:mode=
"'code'"
:showBtns=
"false"
lang=
"zh"
@
json-change=
"onFailJsonChange"
@
json-save=
"onFailJsonSave"
/>
<el-input
v-else-if=
"editMockForm.type === 2"
v-model=
"editMockForm.fail"
type=
"textarea"
></el-input>
</el-form-item>
<el-form-item
label=
"当前返回"
>
<el-switch
v-model=
"editMockForm.flag"
active-color=
"#13ce66"
inactive-color=
"#ff4949"
active-value=
"1"
inactive-value=
"0"
>
...
...
@@ -157,7 +197,10 @@ export default {
description
:
''
,
success
:
''
,
fail
:
''
,
flag
:
''
flag
:
''
,
type
:
1
,
encrypt
:
0
,
module
:
''
},
editMockForm
:
{
id
:
''
,
...
...
@@ -165,7 +208,10 @@ export default {
description
:
''
,
success
:
''
,
fail
:
''
,
flag
:
''
flag
:
''
,
type
:
1
,
encrypt
:
0
,
module
:
''
},
successJson
:
''
,
failJson
:
''
,
...
...
@@ -195,7 +241,6 @@ export default {
},
// 打开mock详情对话框
openDetailDialog
(
row
)
{
console
.
log
(
this
.
activeTab
)
this
.
detailDialogVisible
=
true
this
.
successResponse
=
JSON
.
parse
(
row
.
success
)
this
.
failResponse
=
JSON
.
parse
(
row
.
fail
)
...
...
@@ -204,8 +249,10 @@ export default {
},
// 新增mock
addMock
()
{
if
(
this
.
addMockForm
.
type
===
1
)
{
this
.
addMockForm
.
success
=
JSON
.
stringify
(
this
.
addMockForm
.
success
)
this
.
addMockForm
.
fail
=
JSON
.
stringify
(
this
.
addMockForm
.
fail
)
}
addMock
(
this
.
addMockForm
).
then
((
resp
)
=>
{
if
(
resp
.
data
.
data
===
true
)
{
this
.
addDialogVisible
=
false
...
...
@@ -225,10 +272,16 @@ export default {
this
.
editMockForm
.
success
=
JSON
.
parse
(
row
.
success
)
this
.
editMockForm
.
fail
=
JSON
.
parse
(
row
.
fail
)
this
.
editMockForm
.
flag
=
String
(
row
.
flag
)
this
.
editMockForm
.
type
=
row
.
type
this
.
editMockForm
.
encrypt
=
row
.
encrypt
this
.
editMockForm
.
module
=
row
.
modlue
},
// 修改mock
editMock
()
{
if
(
this
.
editMockForm
.
type
===
1
)
{
this
.
editMockForm
.
success
=
JSON
.
stringify
(
this
.
editMockForm
.
success
)
this
.
editMockForm
.
fail
=
JSON
.
stringify
(
this
.
editMockForm
.
fail
)
}
editMock
(
this
.
editMockForm
).
then
((
resp
)
=>
{
if
(
resp
.
data
.
data
===
true
)
{
this
.
editDialogVisible
=
false
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
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 comment