Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MeterSphere
metersphere
提交
2eaad9c3
M
metersphere
项目概览
MeterSphere
/
metersphere
上一次同步 大约 3 年
通知
25
Star
1
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
metersphere
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
2eaad9c3
编写于
5月 10, 2021
作者:
C
Captain.B
提交者:
BugKing
5月 13, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor(性能测试): 性能测试编辑时可以重新上传文件
上级
bc487a89
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
100 addition
and
12 deletion
+100
-12
frontend/src/business/components/performance/test/components/ExistFiles.vue
...ess/components/performance/test/components/ExistFiles.vue
+100
-12
未找到文件。
frontend/src/business/components/performance/test/components/ExistFiles.vue
浏览文件 @
2eaad9c3
...
...
@@ -3,7 +3,8 @@
:destroy-on-close=
"true"
:title=
"$t('load_test.exist_jmx')"
width=
"70%"
:visible.sync=
"loadFileVisible"
>
<ms-table-header
:is-tester-permission=
"true"
title=
""
:condition.sync=
"condition"
@
search=
"getProjectFiles"
:show-create=
"false"
>
<ms-table-header
:is-tester-permission=
"true"
title=
""
:condition.sync=
"condition"
@
search=
"getProjectFiles"
:show-create=
"false"
>
<template
v-slot:button
>
<el-upload
v-if=
"loadType === 'jmx'"
...
...
@@ -61,6 +62,34 @@
<span
class=
"last-modified"
>
{{
scope
.
row
.
updateTime
|
timestampFormatDate
}}
</span>
</
template
>
</el-table-column>
<el-table-column
:label=
"$t('commons.operating')"
>
<
template
v-slot:default=
"scope"
>
<el-upload
style=
"width: 38px; float: left;"
accept=
".jmx,.jar,.csv,.json,.pdf,.jpg,.png,.jpeg,.doc,.docx,.xlsx,.txt"
action=
""
:limit=
"fileNumLimit"
:show-file-list=
"false"
:before-upload=
"beforeUpdateUploadFile"
:http-request=
"handleUpdateUpload"
:on-exceed=
"handleExceed"
>
<el-tooltip
effect=
"dark"
:content=
"$t('project.upload_file_again')"
placement=
"bottom"
>
<el-button
circle
type=
"success"
:disabled=
"!checkoutTestManagerOrTestUser()"
icon=
"el-icon-upload"
@
click=
"handleEdit(scope.row)"
size=
"mini"
/>
</el-tooltip>
</el-upload>
<ms-table-operator-button
:is-tester-permission=
"true"
icon=
"el-icon-delete"
type=
"danger"
:tip=
"$t('commons.delete')"
@
exec=
"handleDelete(scope.row)"
>
</ms-table-operator-button>
</
template
>
</el-table-column>
</el-table>
<ms-table-pagination
:change=
"getProjectFiles"
:current-page.sync=
"currentPage"
:page-size.sync=
"pageSize"
:total=
"total"
/>
...
...
@@ -74,15 +103,17 @@
<
script
>
import
MsDialogFooter
from
"
@/business/components/common/components/MsDialogFooter
"
;
import
MsTablePagination
from
"
@/business/components/common/pagination/TablePagination
"
;
import
{
getCurrentProjectID
}
from
"
@/common/js/utils
"
;
import
{
checkoutTestManagerOrTestUser
,
getCurrentProjectID
}
from
"
@/common/js/utils
"
;
import
{
findThreadGroup
}
from
"
@/business/components/performance/test/model/ThreadGroup
"
;
import
MsTableButton
from
"
@/business/components/common/components/MsTableButton
"
;
import
axios
from
"
axios
"
;
import
MsTableHeader
from
"
@/business/components/common/components/MsTableHeader
"
;
import
{
Message
}
from
"
element-ui
"
;
import
MsTableOperatorButton
from
"
@/business/components/common/components/MsTableOperatorButton
"
;
export
default
{
name
:
"
ExistFiles
"
,
components
:
{
MsTableHeader
,
MsTableButton
,
MsTablePagination
,
MsDialogFooter
},
components
:
{
MsTable
OperatorButton
,
MsTable
Header
,
MsTableButton
,
MsTablePagination
,
MsDialogFooter
},
props
:
{
fileList
:
Array
,
tableData
:
Array
,
...
...
@@ -102,9 +133,10 @@ export default {
selectIds
:
new
Set
,
fileNumLimit
:
10
,
condition
:
{}
}
}
;
},
methods
:
{
checkoutTestManagerOrTestUser
,
open
(
loadType
)
{
this
.
loadFileVisible
=
true
;
this
.
loadType
=
loadType
;
...
...
@@ -139,11 +171,10 @@ export default {
let
data
=
res
.
data
;
this
.
total
=
data
.
itemCount
;
this
.
existFiles
=
data
.
listObject
;
})
})
;
},
handleImport
(
file
)
{
if
(
file
)
{
// 接口测试创建的性能测试
console
.
log
(
file
);
this
.
selectIds
.
add
(
file
.
id
);
this
.
getJmxContents
();
return
;
...
...
@@ -176,7 +207,7 @@ export default {
//
rows
.
forEach
(
row
=>
{
this
.
fileList
.
push
(
row
);
})
})
;
if
(
this
.
loadType
===
'
resource
'
)
{
this
.
$success
(
this
.
$t
(
'
test_track.case.import.success
'
));
...
...
@@ -216,10 +247,18 @@ export default {
return
false
;
}
},
beforeUpdateUploadFile
(
file
)
{
if
(
!
this
.
fileValidator
(
file
))
{
/// todo: 显示错误信息
return
false
;
}
return
true
;
},
checkFileExist
(
file
,
callback
)
{
// 检查数据库是否存在同名文件
async
function
f
()
{
return
await
axios
.
post
(
'
/performance/file/
'
+
getCurrentProjectID
()
+
'
/getMetadataByName
'
,
{
name
:
file
.
name
})
return
await
axios
.
post
(
'
/performance/file/
'
+
getCurrentProjectID
()
+
'
/getMetadataByName
'
,
{
name
:
file
.
name
})
;
}
f
().
then
(
res
=>
{
...
...
@@ -237,7 +276,7 @@ export default {
let
file
=
uploadResources
.
file
;
this
.
checkFileExist
(
file
,
()
=>
{
let
formData
=
new
FormData
();
let
url
=
'
/project/upload/files/
'
+
getCurrentProjectID
()
let
url
=
'
/project/upload/files/
'
+
getCurrentProjectID
()
;
formData
.
append
(
"
file
"
,
file
);
let
options
=
{
method
:
'
POST
'
,
...
...
@@ -246,7 +285,7 @@ export default {
headers
:
{
'
Content-Type
'
:
undefined
}
}
}
;
self
.
$request
(
options
,
(
response
)
=>
{
self
.
$success
(
this
.
$t
(
'
commons.save_success
'
));
self
.
getProjectFiles
();
...
...
@@ -255,7 +294,56 @@ export default {
self
.
handleImport
(
row
);
}
});
})
});
},
handleUpdateUpload
(
uploadResources
)
{
let
file
=
uploadResources
.
file
;
let
i1
=
file
.
name
.
lastIndexOf
(
"
.
"
);
let
i2
=
this
.
currentRow
.
name
.
lastIndexOf
(
"
.
"
);
let
suffix1
=
file
.
name
.
substring
(
i1
);
let
suffix2
=
this
.
currentRow
.
name
.
substring
(
i2
);
if
(
suffix1
!==
suffix2
)
{
this
.
$error
(
this
.
$t
(
'
load_test.project_file_update_type_error
'
));
return
;
}
let
formData
=
new
FormData
();
let
url
=
'
/project/update/file/
'
+
this
.
currentRow
.
id
;
formData
.
append
(
"
file
"
,
file
);
let
options
=
{
method
:
'
POST
'
,
url
:
url
,
data
:
formData
,
headers
:
{
'
Content-Type
'
:
undefined
}
};
this
.
$request
(
options
,
(
response
)
=>
{
this
.
$success
(
this
.
$t
(
'
commons.save_success
'
));
this
.
getProjectFiles
();
// 刷新页面上的线程组
if
(
this
.
tableData
.
filter
(
f
=>
f
.
id
===
this
.
currentRow
.
id
).
length
>
0
)
{
window
.
location
.
reload
();
}
this
.
currentRow
=
null
;
});
},
handleEdit
(
row
)
{
this
.
currentRow
=
row
;
},
handleDelete
(
row
)
{
this
.
$confirm
(
this
.
$t
(
'
project.file_delete_tip
'
,
[
row
.
name
]),
''
,
{
confirmButtonText
:
this
.
$t
(
'
commons.confirm
'
),
cancelButtonText
:
this
.
$t
(
'
commons.cancel
'
),
type
:
'
warning
'
}).
then
(()
=>
{
this
.
$get
(
'
/project/delete/file/
'
+
row
.
id
,
response
=>
{
Message
.
success
(
this
.
$t
(
'
commons.delete_success
'
));
this
.
getProjectFiles
();
});
}).
catch
(()
=>
{
});
},
handleExceed
()
{
this
.
$error
(
this
.
$t
(
'
load_test.file_size_limit
'
));
...
...
@@ -265,7 +353,7 @@ export default {
return
file
.
size
>
0
;
},
}
}
}
;
</
script
>
<
style
scoped
>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录