refactor(项目设置): 优化删除误报的提示

--bug=1019782 --user=王孝刚 【项目设置】删除误报提示优化
https://www.tapd.cn/55049933/s/1300816
This commit is contained in:
wxg0103 2022-11-22 13:51:11 +08:00 committed by fit2-zhao
parent ab63f3867e
commit 4ff72c0b7f
1 changed files with 160 additions and 110 deletions

View File

@ -1,13 +1,18 @@
<template>
<div>
<el-card class="table-card" v-loading="loading">
<ms-table-header :condition.sync="condition" @search="initTableData"
<ms-table-header
:condition.sync="condition"
@search="initTableData"
style="margin-bottom: 10px"
v-permission="['PROJECT_ERROR_REPORT_LIBRARY:READ+CREATE']"
@create="createErrorReport"
:createTip="$t('error_report_library.option.create')">
:createTip="$t('error_report_library.option.create')"
>
<template v-slot:button>
<span style="margin-left: 10px;">{{$t("error_report_library.tips")}}</span>
<span style="margin-left: 10px">{{
$t("error_report_library.tips")
}}</span>
</template>
</ms-table-header>
@ -27,18 +32,30 @@
@refresh="initTableData"
ref="caseTable"
>
<ms-table-column
min-width="300"
prop="errorCode"
:label="$t('error_report_library.option.error_code')"
:show-overflow-tooltip="true"
/>
<ms-table-column min-width="300" prop="errorCode" :label="$t('error_report_library.option.error_code')"
:show-overflow-tooltip="true"/>
<ms-table-column prop="matchType" :label="$t('error_report_library.option.match_type')">
<ms-table-column
prop="matchType"
:label="$t('error_report_library.option.match_type')"
>
<template v-slot:default="scope">
<ms-tag v-if="scope.row.matchType == 'Text'" effect="plain"
:content="$t('error_report_library.match_type.text')"/>
<ms-tag
v-if="scope.row.matchType == 'Text'"
effect="plain"
:content="$t('error_report_library.match_type.text')"
/>
</template>
</ms-table-column>
<ms-table-column width="100" :label="$t('error_report_library.option.status')">
<ms-table-column
width="100"
:label="$t('error_report_library.option.status')"
>
<template v-slot:default="scope">
<div>
<el-switch
@ -50,42 +67,64 @@
</template>
</ms-table-column>
<ms-table-column prop="createTime"
<ms-table-column
prop="createTime"
:label="$t('commons.create_time')"
show-overflow-tooltip>
show-overflow-tooltip
>
<template v-slot:default="scope">
<span>{{ scope.row.createTime | datetimeFormat }}</span>
</template>
</ms-table-column>
<ms-table-column prop="updateTime"
<ms-table-column
prop="updateTime"
:label="$t('commons.update_time')"
show-overflow-tooltip>
show-overflow-tooltip
>
<template v-slot:default="scope">
<span>{{ scope.row.updateTime | datetimeFormat }}</span>
</template>
</ms-table-column>
<ms-table-column prop="createUser" :label="$t('commons.create_user')" show-overflow-tooltip/>
<ms-table-column prop="description" :label="$t('commons.description')" show-overflow-tooltip/>
<ms-table-column
prop="createUser"
:label="$t('commons.create_user')"
show-overflow-tooltip
/>
<ms-table-column
prop="description"
:label="$t('commons.description')"
show-overflow-tooltip
/>
<ms-table-column min-width="150" :label="$t('commons.operating')">
<template v-slot:default="scope">
<div>
<ms-table-operator-button :tip="$t('commons.edit')" icon="el-icon-edit"
<ms-table-operator-button
:tip="$t('commons.edit')"
icon="el-icon-edit"
:disabled="scope.row.status === 'SENDED'"
v-permission="['PROJECT_ERROR_REPORT_LIBRARY:READ+EDIT']"
@exec="editErrorReport(scope.row)"/>
<ms-table-operator-button type="danger"
@exec="editErrorReport(scope.row)"
/>
<ms-table-operator-button
type="danger"
@exec="deleteReport(scope.row)"
v-permission="['PROJECT_ERROR_REPORT_LIBRARY:READ+DELETE']"
:tip="$t('commons.delete')" icon="el-icon-delete"/>
:tip="$t('commons.delete')"
icon="el-icon-delete"
/>
</div>
</template>
</ms-table-column>
</ms-table>
<ms-table-pagination :change="initTableData" :current-page.sync="page.currentPage" :page-size.sync="page.pageSize"
:total="page.total"/>
<ms-table-pagination
:change="initTableData"
:current-page.sync="page.currentPage"
:page-size.sync="page.pageSize"
:total="page.total"
/>
</el-card>
</div>
</template>
@ -103,13 +142,20 @@ import MsTablePagination from "metersphere-frontend/src/components/pagination/Ta
import {
deleteErrorReportLibrary,
getErrorReportLibraryById,
getErrorReportLibraryPages, modifyErrorReportLibrary
getErrorReportLibraryPages,
modifyErrorReportLibrary,
} from "../../../../../api/error-report-library";
import { operationConfirm } from "metersphere-frontend/src/utils";
export default {
name: "ProjectReportList",
components: {
MsTable, MsTableColumn, ShowMoreBtn, MsTableHeader, MsTableOperatorButton, MsTag, MsTablePagination
MsTable,
MsTableColumn,
ShowMoreBtn,
MsTableHeader,
MsTableOperatorButton,
MsTag,
MsTablePagination,
},
data() {
return {
@ -118,29 +164,31 @@ export default {
page: getPageInfo(),
condition: {
filters: {},
orders: [{name: "create_time", type: "desc"}]
orders: [{ name: "create_time", type: "desc" }],
},
tableData: [],
buttons: [{
name: this.$t('api_test.definition.request.batch_delete'),
buttons: [
{
name: this.$t("api_test.definition.request.batch_delete"),
handleClick: this.handleBatchDelete,
permissions: ['PROJECT_ERROR_REPORT_LIBRARY:READ+BATCH_DELETE']
}],
permissions: ["PROJECT_ERROR_REPORT_LIBRARY:READ+BATCH_DELETE"],
},
],
selectNodeIds: [],
screenHeight: 'calc(100vh - 150px)',//
screenHeight: "calc(100vh - 150px)", //
selectRows: new Set(),
selectDataCounts: 0,
}
};
},
created() {
this.initTableData();
},
methods: {
callBackSelectAll(selections) {
this.selectNodeIds = Array.from(selections).map(o => o.id);
this.selectNodeIds = Array.from(selections).map((o) => o.id);
},
callBackSelect(selections) {
this.selectNodeIds = Array.from(selections).map(o => o.id);
this.selectNodeIds = Array.from(selections).map((o) => o.id);
},
initTableData() {
if (!getCurrentProjectID()) {
@ -149,12 +197,15 @@ export default {
this.selectDataCounts = 0;
this.selectRows = new Set();
this.condition.projectId = getCurrentProjectID();
let selectParam = {"condition":this.condition};
let selectParam = { condition: this.condition };
if (this.condition.name) {
selectParam.errorCode = this.condition.name;
}
this.loading = getErrorReportLibraryPages(this.page.currentPage, this.page.pageSize, selectParam)
.then(response => {
this.loading = getErrorReportLibraryPages(
this.page.currentPage,
this.page.pageSize,
selectParam
).then((response) => {
let data = response.data;
this.page.total = data.itemCount;
this.tableData = data.listObject;
@ -164,38 +215,39 @@ export default {
this.$emit("createErrorReport");
},
deleteReport(row) {
this.$alert(this.$t('commons.confirm') + this.$t('commons.delete') + row.errorCode + "", '', {
confirmButtonText: this.$t('commons.confirm'),
callback: (action) => {
if (action === 'confirm') {
operationConfirm(
this,
this.$t("commons.confirm") +
this.$t("commons.delete") +
row.errorCode +
"",
() => {
let param = { id: row.id, projectId: getCurrentProjectID() };
deleteErrorReportLibrary(param).then(() => {
this.$success(this.$t('commons.delete_success'));
this.$success(this.$t("commons.delete_success"));
this.initTableData();
})
}
}
});
}
);
},
handleBatchDelete() {
this.$alert(this.$t('pj_batch_delete.error_library') + "", '', {
confirmButtonText: this.$t('commons.confirm'),
callback: (action) => {
if (action === 'confirm') {
operationConfirm(
this,
this.$t("pj_batch_delete.error_library") + "",
() => {
let sendParam = {};
sendParam.ids = this.selectNodeIds;
sendParam.projectId = getCurrentProjectID();
sendParam.condition = this.condition;
deleteErrorReportLibrary(sendParam).then(() => {
this.$success(this.$t('commons.delete_success'));
this.$success(this.$t("commons.delete_success"));
this.initTableData();
})
}
}
});
}
);
},
editErrorReport(row) {
getErrorReportLibraryById(row.id).then(response => {
getErrorReportLibraryById(row.id).then((response) => {
if (response.data) {
let libraryData = response.data;
this.$emit("editErrorReport", libraryData);
@ -203,23 +255,22 @@ export default {
});
},
changeStatus(row) {
if (!hasPermission('PROJECT_ERROR_REPORT_LIBRARY:READ+EDIT')) {
if (!hasPermission("PROJECT_ERROR_REPORT_LIBRARY:READ+EDIT")) {
row.status = !row.status;
this.$alert(this.$t('commons.project_permission'));
this.$alert(this.$t("commons.project_permission"));
return false;
} else {
let param = { id: row.id, status: row.status };
this.loading = modifyErrorReportLibrary(param).then(() => {
this.$success(this.$t('commons.save_success'));
this.$success(this.$t("commons.save_success"));
});
}
}
}
}
},
},
};
</script>
<style scoped>
.table-page {
padding-top: 20px;
margin-right: -9px;
@ -237,7 +288,6 @@ export default {
.request-method {
padding: 0 5px;
color: #1E90FF;
color: #1e90ff;
}
</style>