Compare commits

...

2 Commits

2 changed files with 203 additions and 89 deletions

View File

@ -43,47 +43,18 @@
@confirm = 'handleSearchDialogConfirm'
/>
</el-button>
<el-button class = 'btnPlus' @click="addOneClue">
<el-tooltip content = '添加'>
<el-icon><Plus /></el-icon>
</el-tooltip>
</el-button>
<AddDialog
ref="addDialog"
:addClueCols="clueCols"
:id="MaxId"
:tableId="clueId"
>
</AddDialog>
<el-button class = 'btnPlus' @click="addOneClue">
<el-tooltip content = '添加'>
<el-icon><Plus /></el-icon>
</el-tooltip>
</el-button>
<AddDialog
ref="addDialog"
:addClueCols="clueCols"
:id="MaxId"
:tableId="clueId"
>
</AddDialog>
<el-button class = 'btnMore' @click="dochart">
<el-tooltip content = '更多'>
<el-icon><More /></el-icon>
</el-tooltip>
</el-button>
</el-header>
<EditDialog :columns="cols" ref="editDialog" :editDataID="currentEditDataID"></EditDialog>
<!-- 编辑线索的对话框 -->
<EditDialog
:columns="cols"
ref="editDialog"
:editDataID="currentEditDataID"
/>
<el-main class = 'containerMain'>
<el-table
class = 'containerTable'
@ -114,17 +85,17 @@
<!-- </el-main> -->
<el-footer>
<el-button class = 'btnPlus' @click="addOneClue">
<el-tooltip content = '添加'>
<el-tooltip content = '添加一条线索'>
<el-icon><Plus /></el-icon>
</el-tooltip>
</el-button>
<!-- 添加线索的对话框 -->
<AddDialog
ref="addDialog"
:addClueCols="clueCols"
:id="MaxId"
:tableId="clueId"
>
</AddDialog>
/>
</el-footer>
</el-main>
</el-container>

View File

@ -1,18 +1,44 @@
<template>
<el-table :data="tableData" style="width: 100%">
<!-- 动态生成表格列 -->
<el-table-column v-for="column in tableColumns" :key="column.prop" :prop="column.prop" :label="column.label">
<template v-slot="scope">
<span>{{ formatValue(scope.row,column.prop) }}</span>
</template>
</el-table-column>
<!-- 添加删除按钮 -->
<el-table-column label="操作">
<template v-slot:default="scope">
<el-button type="text" @click="withdrawRow(scope.row)">撤销</el-button>
</template>
</el-table-column>
</el-table>
<el-container>
<el-header class="withrawHeader">
<h1 class="headerText">回收站</h1>
</el-header>
<el-main>
<!-- 工具栏 -->
<el-header class="toolbar">
<el-tooltip class="withdrawToolTip" content="撤销对选中线索的删除">
<el-button class='btnWithdraw' @click="withdrawSelected">
<el-icon><Delete /></el-icon>
</el-button>
</el-tooltip>
<el-tooltip class="deleteToolTip" content = '彻底删除选中线索'>
<el-button class = 'btnDelete' @click="deleteSelected">
<el-icon><DeleteFilled /></el-icon>
</el-button>
</el-tooltip>
</el-header>
<el-table
:data="tableData"
style="width: 100%"
@selection-change="handleSelectionChange"
>
<el-table-column type="selection" class="withdrawSelectionCol"></el-table-column>
<!-- 动态生成表格列 -->
<el-table-column v-for="column in tableColumns" :key="column.prop" :prop="column.prop" :label="column.label">
<template v-slot="scope">
<span>{{ formatValue(scope.row,column.prop) }}</span>
</template>
</el-table-column>
<!-- 添加删除按钮 -->
<el-table-column label="操作">
<template v-slot:default="scope">
<el-button type="text" @click="withdrawRow(scope.row)">撤销</el-button>
<el-button type="text" @click="deleteClue(scope.row)">删除</el-button>
</template>
</el-table-column>
</el-table>
</el-main>
</el-container>
</template>
<script>
@ -30,44 +56,12 @@ export default {
{ prop: "table_id", label: "表ID" },
{ prop: "clue_id", label: "线索ID" },
{ prop: "del_time", label: "时间" }
] //
], //
deleteClues:[], //
};
},
methods: {
getDelete() {
//
axios.get('http://localhost:8000/showDelRecords/')
.then(res => {
console.log(res.data)
if(res.data.message=='没有删除记录')
{
return
}
this.tableData = res.data; //
})
.catch(error => {
console.error(error);
});
},
withdrawRow(row) {
const index = this.tableData.indexOf(row);
if (index !== -1) {
// ID
axios.post('http://localhost:8000/withDraw/', { id: row.id })
.then(response => {
console.log('撤销成功:', response.data);
//
this.tableData.splice(index, 1);
})
.catch(error => {
console.error('撤销失败:', error);
});
}
}
},
formatValue(row, prop) {
formatValue(row, prop) {
// type
if (prop === 'type' && row[prop] === '0') {
if (row['clue_id']) {
@ -79,12 +73,161 @@ export default {
return '线索'
return row[prop];
},
getDelete() {
//
axios.get('http://localhost:8000/showDelRecords/').then(res => {
if(res.data.message=='没有删除记录')
{
return
}
this.tableData = res.data.data; // data
})
.catch(error => {
this.$handleNetError(error); //
});
},
withdrawRow(row) {
const index = this.tableData.indexOf(row);
if (index !== -1) {
// ID
axios.post('http://localhost:8000/withDraw/', { id: row.id }).then(response => {
console.log('撤销成功:', response.data);
//
this.tableData.splice(index, 1);
})
.catch(error => {
this.$handleNetError(error);
});
}
},
handleSelectionChange(selection){
this.deleteClues = selection; //
},
//
withdrawSelected(){
//
if(this.deleteClues.length == 0){
this.$message({
type: 'warning',
message: '请选择要撤销的线索'
});
return;
}
for(let i = 0;i < this.deleteClues.length;i++){
this.$axios.post('http://localhost:8000/withDraw/',{ id:this.deleteClues[i].id })
.catch(error => {
this.$handleNetError(error);
return;
});
}
this.$message({
type: 'success',
message: '撤销成功,即将刷新界面'
});
//
location.reload();
},
// 线
deleteClue(row){
const deleteItem = {
table_id: row.table_id,
clue_id: row.clue_id
}
this.$axios.post('http:localhosat:8000/deleteSelected/',{deleteData:deleteItem}).then(response=>{
if(response.data.message == '删除成功'){
//
this.$message({
type: 'success',
message: '删除成功,即将刷新界面'
});
location.reload(); //
}else{
this.$message({
type: 'error',
message: '删除失败'
});
}
})
.catch(error=>{
this.$handleNetError(error); //
})
},
// 线
deleteSelected(){
//
if(this.deleteClues.length == 0){
this.$message({
type: 'warning',
message: '请选择要删除的线索'
});
return;
}
// deleteItems
const deleteItems = this.deleteClues.map(row => ({
table_id: row.table_id, //
clue_id: row.clue_id,
}));
//
for(let i = 0; i < deleteItems.length; i++){
this.$axios.post('http://localhost:8000/deleteSelected/',
{table_id:deleteItems[i].table_id, clue_id:deleteItems[i].clue_id}).then(response=>{
if(response.data.message == '删除成功'){
//
this.$message({
type: 'success',
message: '删除成功'
});
}else{
this.$message({
type: 'error',
message: '删除失败'
});
}
})
.catch(error=>{
this.$handleNetError(error); //
return;
})
}
this.$message({
type: 'success',
message: '删除成功,即将刷新界面'
});
//
location.reload();
}
},
mounted() {
this.getDelete(); //
}
};
</script>
<style>
/* 可以添加一些自定义样式 */
<style scoped>
.withdrawSelectionCol{
width: 50px;
}
.headerText{
font-size: 24px;
text-align: center;
}
.toolbar{
height:6%;
padding:2%;
display:flex;
justify-content: flex-end;
align-items: center;
}
.btnDelete, .btnWithdraw{
text-align: start;
padding: 0.6%;
margin: 0;
}
.deleteToolTip, .withdrawToolTip .el-tooltip__content{
color: red !important;
}
</style>