修改羊舍管理页面删除和导出功能
This commit is contained in:
@@ -73,3 +73,43 @@ export function getSeatMap() {
|
|||||||
method: 'get'
|
method: 'get'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 按组合条件删除(单条):匹配Controller的/deleteByCondition
|
||||||
|
export function deleteSheepfoldByCondition(data) {
|
||||||
|
return request({
|
||||||
|
url: '/sheepfold_management/sheepfold_management/deleteByCondition',
|
||||||
|
method: 'delete',
|
||||||
|
data: data // 需包含ranchId/sheepfoldNo/sheepfoldTypeId/sheepfoldName(Controller校验了sheepfoldName)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 批量按组合条件删除:匹配Controller的/batchDeleteByCondition
|
||||||
|
export function batchDeleteSheepfoldByCondition(dataList) {
|
||||||
|
return request({
|
||||||
|
url: '/sheepfold_management/sheepfold_management/batchDeleteByCondition',
|
||||||
|
method: 'delete',
|
||||||
|
data: dataList
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 导出羊舍管理汇总列表(主表格数据)- 新增
|
||||||
|
export function exportSheepfoldSummary(query) {
|
||||||
|
return request({
|
||||||
|
url: '/sheepfold_management/sheepfold_management/exportSummary',
|
||||||
|
method: 'post',
|
||||||
|
params: query,
|
||||||
|
responseType: 'blob'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 导出羊舍管理明细列表(原有)- 保留
|
||||||
|
export function exportSheepfold(query) {
|
||||||
|
return request({
|
||||||
|
url: '/sheepfold_management/sheepfold_management/export',
|
||||||
|
method: 'post',
|
||||||
|
params: query,
|
||||||
|
responseType: 'blob'
|
||||||
|
})
|
||||||
|
}
|
||||||
@@ -43,7 +43,7 @@
|
|||||||
plain
|
plain
|
||||||
icon="Delete"
|
icon="Delete"
|
||||||
:disabled="multiple"
|
:disabled="multiple"
|
||||||
@click="handleDelete"
|
@click="handleBatchDelete"
|
||||||
v-hasPermi="['sheepfold_management:sheepfold_management:remove']"
|
v-hasPermi="['sheepfold_management:sheepfold_management:remove']"
|
||||||
>删除</el-button>
|
>删除</el-button>
|
||||||
</el-col>
|
</el-col>
|
||||||
@@ -272,7 +272,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup name="Sheepfold_management">
|
<script setup name="Sheepfold_management">
|
||||||
import { listSheepfoldSummary, getSeatMap,listSheepfold_management, getSheepfold_management, delSheepfold_management, addSheepfold_management, updateSheepfold_management,checkSheepfoldNoExist } from "@/api/fileManagement/sheepfold_management"
|
import { deleteSheepfoldByCondition,batchDeleteSheepfoldByCondition, listSheepfoldSummary, getSeatMap,listSheepfold_management, getSheepfold_management, delSheepfold_management, addSheepfold_management, updateSheepfold_management,checkSheepfoldNoExist } from "@/api/fileManagement/sheepfold_management"
|
||||||
|
|
||||||
const { proxy } = getCurrentInstance()
|
const { proxy } = getCurrentInstance()
|
||||||
const { bas_sheepfold_type, da_ranch } = proxy.useDict('bas_sheepfold_type', 'da_ranch')
|
const { bas_sheepfold_type, da_ranch } = proxy.useDict('bas_sheepfold_type', 'da_ranch')
|
||||||
@@ -393,10 +393,11 @@ function resetQuery() {
|
|||||||
handleQuery()
|
handleQuery()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 选中事件:正确存储选中数据+更新禁用状态
|
||||||
function handleSelectionChange(selection) {
|
function handleSelectionChange(selection) {
|
||||||
ids.value = selection.map(item => item.id)
|
ids.value = selection; // 存储所有选中的行数据(关键)
|
||||||
single.value = selection.length != 1
|
single.value = selection.length !== 1; // 单条选中判断(不影响批量)
|
||||||
multiple.value = !selection.length
|
multiple.value = selection.length === 0; // 批量按钮禁用逻辑:无选中则禁用
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleAdd() {
|
function handleAdd() {
|
||||||
@@ -487,21 +488,69 @@ function submitForm() {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 单条删除方法(确保调用正确接口,无路径错误)
|
||||||
function handleDelete(row) {
|
function handleDelete(row) {
|
||||||
const _ids = row.id || ids.value
|
const deleteData = {
|
||||||
proxy.$modal.confirm('是否确认删除羊舍管理编号为"' + _ids + '"的数据项?').then(function() {
|
ranchId: row.ranchId,
|
||||||
return delSheepfold_management(_ids)
|
sheepfoldNo: row.sheepfoldNo,
|
||||||
|
sheepfoldTypeId: row.sheepfoldTypeId,
|
||||||
|
}
|
||||||
|
proxy.$modal.confirm(`是否确认删除【${row.sheepfoldName}】的数据?`).then(function() {
|
||||||
|
// 仅调用新的组合条件删除接口,无其他DELETE请求
|
||||||
|
return deleteSheepfoldByCondition(deleteData)
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
getList()
|
getList()
|
||||||
loadSeatMap();
|
loadSeatMap();
|
||||||
proxy.$modal.msgSuccess("删除成功")
|
proxy.$modal.msgSuccess("删除成功")
|
||||||
}).catch(() => {})
|
}).catch((err) => {
|
||||||
|
proxy.$modal.msgError(err.msg || "删除失败")
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 批量删除核心方法(完整逻辑)
|
||||||
|
function handleBatchDelete() {
|
||||||
|
// 1. 校验:是否选中数据
|
||||||
|
if (ids.value.length === 0) {
|
||||||
|
proxy.$modal.msgWarning("请选择要删除的羊舍数据!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2. 组装批量删除参数(每行取核心字段)
|
||||||
|
const deleteList = ids.value.map(row => ({
|
||||||
|
ranchId: row.ranchId,
|
||||||
|
sheepfoldNo: row.sheepfoldNo,
|
||||||
|
sheepfoldTypeId: row.sheepfoldTypeId,
|
||||||
|
sheepfoldName: row.sheepfoldName // 若后端已移除该字段校验,可删除
|
||||||
|
}));
|
||||||
|
|
||||||
|
// 3. 确认删除+调用批量接口
|
||||||
|
proxy.$modal.confirm(
|
||||||
|
`是否确认删除选中的${ids.value.length}条羊舍数据?删除后不可恢复!`,
|
||||||
|
"警告",
|
||||||
|
{
|
||||||
|
confirmButtonText: "确认",
|
||||||
|
cancelButtonText: "取消",
|
||||||
|
type: "warning"
|
||||||
|
}
|
||||||
|
).then(() => {
|
||||||
|
// 调用批量删除接口
|
||||||
|
return batchDeleteSheepfoldByCondition(deleteList);
|
||||||
|
}).then((response) => {
|
||||||
|
// 4. 成功处理:刷新列表+提示
|
||||||
|
proxy.$modal.msgSuccess(response.msg || "批量删除成功");
|
||||||
|
getList(); // 刷新表格数据
|
||||||
|
loadSeatMap(); // 刷新座位图(可选)
|
||||||
|
}).catch((err) => {
|
||||||
|
// 5. 失败处理:提示错误
|
||||||
|
proxy.$modal.msgError(err.msg || "批量删除失败");
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleExport() {
|
function handleExport() {
|
||||||
proxy.download('sheepfold_management/sheepfold_management/export', {
|
// 修改为调用汇总导出接口
|
||||||
|
proxy.download('sheepfold_management/sheepfold_management/exportSummary', {
|
||||||
...queryParams.value
|
...queryParams.value
|
||||||
}, `sheepfold_management_${new Date().getTime()}.xlsx`)
|
}, `羊舍管理汇总数据_${new Date().getTime()}.xlsx`)
|
||||||
}
|
}
|
||||||
|
|
||||||
const loadSeatMap = () => {
|
const loadSeatMap = () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user