mirror of
https://gitee.com/fit2cloud-feizhiyun/MeterSphere.git
synced 2024-12-05 21:49:23 +08:00
fix(项目设置): 优化自定义代码片段的权限判断方式
--bug=1027190 --user=宋天阳 【项目设置】自定义代码片段只开启查看和创建两个权限,受限制账号创建后再次点击保存页面跳转至系统设置 https://www.tapd.cn/55049933/s/1387288
This commit is contained in:
parent
0960fb2f52
commit
65e50c118f
@ -96,6 +96,7 @@ import MsCodeEdit from "metersphere-frontend/src/components/MsCodeEdit";
|
||||
import MsDropdown from "metersphere-frontend/src/components/MsDropdown";
|
||||
import {FUNC_TEMPLATE} from "metersphere-frontend/src/components/environment/snippet/custom-function";
|
||||
import {getCurrentProjectID} from "metersphere-frontend/src/utils/token";
|
||||
import {hasPermission} from "metersphere-frontend/src/utils/permission";
|
||||
import {getUUID} from "metersphere-frontend/src/utils";
|
||||
import {JSR223Processor} from "metersphere-frontend/src/model/ApiTestModel";
|
||||
import CustomFunctionRelate from "metersphere-frontend/src/components/environment/snippet/CustomFunctionRelate";
|
||||
@ -263,13 +264,19 @@ export default {
|
||||
});
|
||||
},
|
||||
update(obj) {
|
||||
if (!obj.projectId) {
|
||||
obj.projectId = getCurrentProjectID();
|
||||
let hasEditPermission = hasPermission('PROJECT_CUSTOM_CODE:READ+EDIT');
|
||||
if (!hasEditPermission) {
|
||||
this.$warning(this.$t('commons.no_permission'));
|
||||
return;
|
||||
} else {
|
||||
if (!obj.projectId) {
|
||||
obj.projectId = getCurrentProjectID();
|
||||
}
|
||||
this.loading = modifyCodeSnippet(obj).then(() => {
|
||||
this.$emit("refresh");
|
||||
this.$success(this.$t('commons.modify_success'));
|
||||
});
|
||||
}
|
||||
this.loading = modifyCodeSnippet(obj).then(() => {
|
||||
this.$emit("refresh");
|
||||
this.$success(this.$t('commons.modify_success'));
|
||||
});
|
||||
},
|
||||
handleTest() {
|
||||
if (this.apiReviewTestScript) {
|
||||
|
@ -4,8 +4,8 @@
|
||||
<el-row type="flex" justify="end" class="info">
|
||||
<el-col :span="24">
|
||||
<div class="time">
|
||||
{{ $t('api_report.start_time') }}:{{ result.startTime | timestampFormatDate(true) }}
|
||||
{{ $t('report.test_end_time') }}:{{ result.endTime | timestampFormatDate(true) }}
|
||||
{{ $t('api_report.start_time') }}:{{ startTime }}
|
||||
{{ $t('report.test_end_time') }}:{{ endTime }}
|
||||
</div>
|
||||
</el-col>
|
||||
</el-row>
|
||||
@ -36,10 +36,11 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import MsAssertionResults from "@/business/plan/view/comonents/report/detail/ui/AssertionResults.vue";
|
||||
|
||||
export default {
|
||||
name: "UiCommandResultDetail",
|
||||
components: {
|
||||
},
|
||||
components: {MsAssertionResults},
|
||||
props: {
|
||||
request: Object,
|
||||
scenarioName: String,
|
||||
@ -64,6 +65,46 @@ export default {
|
||||
},
|
||||
|
||||
methods: {
|
||||
formatDate(time, cFormat) {
|
||||
if (arguments.length === 0) {
|
||||
return null;
|
||||
}
|
||||
const format = cFormat || '{y}-{m}-{d} {h}:{i}:{s}:{t}';
|
||||
let date;
|
||||
if (typeof time === 'object') {
|
||||
date = time;
|
||||
} else {
|
||||
if (typeof time === 'string' && /^[0-9]+$/.test(time)) {
|
||||
time = parseInt(time);
|
||||
}
|
||||
if (typeof time === 'number' && time.toString().length === 10) {
|
||||
time = time * 1000;
|
||||
}
|
||||
date = new Date(time);
|
||||
}
|
||||
const formatObj = {
|
||||
y: date.getFullYear(),
|
||||
m: date.getMonth() + 1,
|
||||
d: date.getDate(),
|
||||
h: date.getHours(),
|
||||
i: date.getMinutes(),
|
||||
s: date.getSeconds(),
|
||||
a: date.getDay(),
|
||||
t: date.getMilliseconds()
|
||||
};
|
||||
const timeStr = format.replace(/{(y|m|d|h|i|s|a|t)+}/g, (result, key) => {
|
||||
let value = formatObj[key];
|
||||
// Note: getDay() returns 0 on Sunday
|
||||
if (key === 'a') {
|
||||
return ['日', '一', '二', '三', '四', '五', '六'][value];
|
||||
}
|
||||
if (result.length > 0 && value < 10) {
|
||||
value = '0' + value;
|
||||
}
|
||||
return value || 0;
|
||||
});
|
||||
return timeStr;
|
||||
},
|
||||
active() {
|
||||
this.isActive = !this.isActive;
|
||||
},
|
||||
@ -99,7 +140,19 @@ export default {
|
||||
hasSub() {
|
||||
return this.request.subRequestResults.length > 0;
|
||||
},
|
||||
}
|
||||
startTime() {
|
||||
if (this.result.startTime) {
|
||||
return this.formatDate(this.result.startTime);
|
||||
}
|
||||
return "--";
|
||||
},
|
||||
endTime() {
|
||||
if (this.result.endTime) {
|
||||
return this.formatDate(this.result.endTime);
|
||||
}
|
||||
return "--";
|
||||
}
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user