feat(wms/attendance): add batch delete attendance schedule function
1. 修改删除排班接口为POST请求方式并调整接口路径为/wms/attendanceSchedule/remove,传递删除id数据 2. 在排班页面添加多选列和批量删除按钮,实现批量删除排班记录功能,包含选中校验、删除确认和操作反馈
This commit is contained in:
@@ -38,8 +38,9 @@ export function updateAttendanceSchedule(data) {
|
||||
// 删除排班记录(支持批量删除,传递csv格式字符串如:1,2,3)
|
||||
export function delAttendanceSchedule(ids) {
|
||||
return request({
|
||||
url: '/wms/attendanceSchedule/' + ids,
|
||||
method: 'delete'
|
||||
url: '/wms/attendanceSchedule/remove',
|
||||
method: 'delete',
|
||||
data: ids,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
<el-button plain type="success" icon="el-icon-setting" @click="showTemplateManager = true">管理模板</el-button>
|
||||
<el-button plain type="warning" icon="el-icon-edit" @click="handleBatchUpdate">批量修改</el-button>
|
||||
<el-button plain type="primary" icon="el-icon-s-grid" @click="enterBatchCellMode">批量编辑</el-button>
|
||||
<el-button plain type="danger" icon="el-icon-delete" :disabled="selectedRows.length === 0" @click="handleBatchDelete">批量删除整行</el-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -53,7 +54,9 @@
|
||||
|
||||
<!-- 排班表格 -->
|
||||
<div class="schedule-table-wrapper">
|
||||
<el-table v-loading="loading" :data="scheduleData" border stripe height="calc(100vh - 200px)">
|
||||
<el-table v-loading="loading" :data="scheduleData" border stripe height="calc(100vh - 200px)" @selection-change="handleSelectionChange">
|
||||
<!-- 多选列 -->
|
||||
<el-table-column type="selection" width="55" fixed="left" />
|
||||
<!-- 员工列 -->
|
||||
<el-table-column prop="employeeName" label="员工" width="120" fixed="left" />
|
||||
<!-- 操作列 -->
|
||||
@@ -405,6 +408,7 @@ export default {
|
||||
batchCellSelection: {},
|
||||
batchCellDialogVisible: false,
|
||||
batchCellEditShiftId: '',
|
||||
selectedRows: [],
|
||||
rules: {
|
||||
dateRange: [
|
||||
{ required: true, message: '请选择时间段', trigger: 'change' }
|
||||
@@ -908,7 +912,52 @@ export default {
|
||||
})
|
||||
},
|
||||
|
||||
// 删除整行排班
|
||||
handleSelectionChange(rows) {
|
||||
this.selectedRows = rows
|
||||
},
|
||||
|
||||
handleBatchDelete() {
|
||||
const selectedRows = this.selectedRows
|
||||
if (selectedRows.length === 0) {
|
||||
this.$message.warning('请至少选择一名员工')
|
||||
return
|
||||
}
|
||||
|
||||
const scheduleIds = []
|
||||
let totalRecords = 0
|
||||
selectedRows.forEach(row => {
|
||||
this.dateList.forEach(date => {
|
||||
if (row[date] && row[date].scheduleId) {
|
||||
scheduleIds.push(row[date].scheduleId)
|
||||
totalRecords++
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
if (scheduleIds.length === 0) {
|
||||
this.$message.info('所选行没有排班记录')
|
||||
return
|
||||
}
|
||||
|
||||
this.$confirm(`确定要删除 ${selectedRows.length} 名员工的共 ${totalRecords} 条排班记录吗?`, '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
delAttendanceSchedule(scheduleIds.join(',')).then(() => {
|
||||
this.$message.success('批量删除成功')
|
||||
this.selectedRows = []
|
||||
this.getScheduleList()
|
||||
}).catch(() => {
|
||||
this.$message.error('批量删除失败,正在重新获取数据')
|
||||
this.selectedRows = []
|
||||
this.getScheduleList()
|
||||
})
|
||||
}).catch(() => {
|
||||
this.$message.info('已取消删除')
|
||||
})
|
||||
},
|
||||
|
||||
handleDeleteRow(row) {
|
||||
const scheduleIds = []
|
||||
this.dateList.forEach(date => {
|
||||
|
||||
Reference in New Issue
Block a user