|
|
|
@ -28,7 +28,7 @@ |
|
|
|
|
<template slot-scope="scope"> |
|
|
|
|
<el-button v-if="!scope.row.operate" type="text" @click="operateIt(scope.row)">编辑</el-button> |
|
|
|
|
<el-button v-else type="text" @click="saveData(scope.row)">保存</el-button> |
|
|
|
|
<el-button type="text" @click="handleDelete(scope.row)">删除</el-button> |
|
|
|
|
<el-button type="text" @click="handleDelete(scope.row, scope.$index)">删除</el-button> |
|
|
|
|
</template> |
|
|
|
|
</el-table-column> |
|
|
|
|
</el-table> |
|
|
|
@ -74,39 +74,13 @@ export default { |
|
|
|
|
mounted() { |
|
|
|
|
this.getData(); |
|
|
|
|
console.log(this.listData) |
|
|
|
|
EventBus.$on("tabClickWait", () => this.waitSave()); |
|
|
|
|
EventBus.$on("tabClickWait1", () => this.waitSave()); |
|
|
|
|
}, |
|
|
|
|
methods: { |
|
|
|
|
operateIt(row) { |
|
|
|
|
this.$store.commit("match/setWait", 1); |
|
|
|
|
row.operate = true |
|
|
|
|
}, |
|
|
|
|
blur(row) { |
|
|
|
|
// if(this.save) { |
|
|
|
|
// console.log('are you save?') |
|
|
|
|
// } |
|
|
|
|
this.timeOut = setTimeout(() => { |
|
|
|
|
this.$confirm('暂未保存,是否保存本次编辑?', '提示', { |
|
|
|
|
confirmButtonText: '确定', |
|
|
|
|
cancelButtonText: '取消', |
|
|
|
|
type: 'warning' |
|
|
|
|
}).then(() => { |
|
|
|
|
this.saveData(row) |
|
|
|
|
|
|
|
|
|
}).catch(() => { |
|
|
|
|
this.$message({ |
|
|
|
|
type: 'success', |
|
|
|
|
message: '已取消保存' |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
}, 500) |
|
|
|
|
|
|
|
|
|
}, |
|
|
|
|
focus() { |
|
|
|
|
|
|
|
|
|
clearInterval(this.timeOut) |
|
|
|
|
// this.save = false |
|
|
|
|
}, |
|
|
|
|
getData() { |
|
|
|
|
this.$get(`${this.api.getContestProgress}/${this.id}`).then(res => { |
|
|
|
|
this.listData = res.contestProgressList; |
|
|
|
@ -152,20 +126,29 @@ export default { |
|
|
|
|
this.pageNo = val; |
|
|
|
|
this.getData(); |
|
|
|
|
}, |
|
|
|
|
handleDelete(row) { |
|
|
|
|
handleDelete(row, index) { |
|
|
|
|
this.$confirm("此删除操作不可逆,是否确认删除选中项?", "提示", { |
|
|
|
|
type: "warning" |
|
|
|
|
}).then(() => { |
|
|
|
|
this.touchTime = this.touchTime+1 |
|
|
|
|
this.$del(`${this.api.deleteContestProgress}/${row.id}`).then(res => { |
|
|
|
|
if(row.id === "") { |
|
|
|
|
this.listData.splice(index, 1) |
|
|
|
|
util.successMsg("删除成功"); |
|
|
|
|
this.getData(); |
|
|
|
|
}).catch(res => { |
|
|
|
|
}); |
|
|
|
|
console.log(this.listData) |
|
|
|
|
console.log(this.hasEdit) |
|
|
|
|
}else { |
|
|
|
|
this.touchTime = this.touchTime+1 |
|
|
|
|
this.$del(`${this.api.deleteContestProgress}/${row.id}`).then(res => { |
|
|
|
|
util.successMsg("删除成功"); |
|
|
|
|
this.getData(); |
|
|
|
|
}).catch(res => { |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
}).catch(() => { |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
addData() { |
|
|
|
|
// this.$store.commit("match/setWait", 1); |
|
|
|
|
this.touchTime = this.touchTime+1 |
|
|
|
|
if (this.listData.length) { |
|
|
|
|
if (this.listData[this.listData.length - 1].id) { |
|
|
|
@ -177,7 +160,7 @@ export default { |
|
|
|
|
status: 0, |
|
|
|
|
operate: true |
|
|
|
|
}); |
|
|
|
|
console.log(this.listData) |
|
|
|
|
this.operateIt(this.listData[this.listData.length - 1]) |
|
|
|
|
} else { |
|
|
|
|
util.warningMsg("请先保存新数据"); |
|
|
|
|
} |
|
|
|
@ -240,8 +223,7 @@ export default { |
|
|
|
|
}, |
|
|
|
|
computed: { |
|
|
|
|
hasEdit() { |
|
|
|
|
const judge = this.listData.some(item => item.operate) |
|
|
|
|
return judge |
|
|
|
|
return this.listData.some(item => item.operate) |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
beforeDestroy() { |
|
|
|
|