提交roll全部删除功能

This commit is contained in:
2026-07-27 10:38:57 +08:00
parent 9d0693fe19
commit b0487259ab
3 changed files with 81 additions and 16 deletions
+7
View File
@@ -95,6 +95,13 @@ export function delRoll(rollId) {
method: "delete", method: "delete",
}); });
} }
export function delAllRoll() {
return request({
url: `/admin/roll/removeAll`,
method: "delete",
});
}
export function rollJackpotOrnamentDel(jackpotId, rollJackpotOrnamentsIds) { export function rollJackpotOrnamentDel(jackpotId, rollJackpotOrnamentsIds) {
return request({ return request({
url: `/admin/rollJackpotOrnaments/${jackpotId}/${rollJackpotOrnamentsIds}`, url: `/admin/rollJackpotOrnaments/${jackpotId}/${rollJackpotOrnamentsIds}`,
+35 -6
View File
@@ -49,17 +49,27 @@
v-hasPermi="['admin:user:export']" v-hasPermi="['admin:user:export']"
>导出</el-button> >导出</el-button>
</el-col> </el-col>
<!-- <el-col :span="1.5"> <el-col :span="1.5">
<el-button <el-button
type="danger" type="danger"
plain plain
icon="el-icon-edit" icon="el-icon-delete"
size="mini" size="mini"
:disabled="multiple" :disabled="multiple"
@click="handleDelete" @click="handleDelete"
v-hasPermi="['admin:user:edit']" v-hasPermi="['admin:user:edit']"
>删除</el-button> >删除</el-button>
</el-col>--> </el-col>
<el-col :span="1.5">
<el-button
type="danger"
plain
icon="el-icon-warning"
size="mini"
@click="handleDeleteAll"
v-hasPermi="['admin:user:edit']"
>一键删除所有</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row> </el-row>
<el-table <el-table
@@ -314,6 +324,7 @@ import {
rollJackpotList, rollJackpotList,
roll, roll,
delRoll, delRoll,
delAllRoll,
rollChange rollChange
} from "@/api/skins/ttRoll/api"; } from "@/api/skins/ttRoll/api";
import { generateRollCdk, getRollCdkList, deleteRollCdk } from "@/api/skins/ttRoll/api"; import { generateRollCdk, getRollCdkList, deleteRollCdk } from "@/api/skins/ttRoll/api";
@@ -510,21 +521,39 @@ export default {
}; };
}, },
handleSelectionChange(selection) { handleSelectionChange(selection) {
this.ids = selection.map(item => item.userId); this.ids = selection.map(item => item.id);
this.single = selection.length !== 1; this.single = selection.length !== 1;
this.multiple = !selection.length; this.multiple = !selection.length;
}, },
handleDelete(row) { handleDelete(row) {
const ids = row ? [row] : this.ids;
if (!ids || ids.length === 0) {
this.$modal.msgWarning("请至少选择一条数据");
return;
}
this.$modal this.$modal
.confirm('是否确认删除ID为"' + row + '"的Roll房?') .confirm('是否确认删除ID为"' + ids.join(", ") + '"的Roll房?')
.then(() => { .then(() => {
delRoll(row).then(res => { delRoll(ids.join(",")).then(res => {
this.getList(); this.getList();
this.$modal.msgSuccess("删除成功"); this.$modal.msgSuccess("删除成功");
}); });
}) })
.catch(() => {}); .catch(() => {});
}, },
handleDeleteAll() {
this.$modal
.confirm('此操作将删除所有Roll房,且不可恢复,是否继续?', "系统提示", {
type: "warning"
})
.then(() => {
delAllRoll().then(res => {
this.getList();
this.$modal.msgSuccess("一键删除成功");
});
})
.catch(() => {});
},
handleExport() { handleExport() {
this.download( this.download(
"admin/roll/export", "admin/roll/export",
@@ -113,16 +113,45 @@ public class TtRollController extends BaseController {
} }
@ApiOperation("删除roll房") @ApiOperation("删除roll房")
@DeleteMapping("/remove/{rollId}") @DeleteMapping("/remove/{rollIds}")
public AjaxResult remove(@PathVariable Long rollId) { public AjaxResult remove(@PathVariable Long[] rollIds) {
LambdaQueryWrapper<TtRollUser> wrapper = Wrappers.lambdaQuery(); int count = 0;
wrapper.eq(TtRollUser::getRollId, rollId); for (Long rollId : rollIds) {
List<TtRollUser> list = rollUserService.list(wrapper); LambdaQueryWrapper<TtRollUser> wrapper = Wrappers.lambdaQuery();
TtRoll ttRoll = rollService.getById(rollId); wrapper.eq(TtRollUser::getRollId, rollId);
ttRoll.setUpdateBy(getUsername()); List<TtRollUser> list = rollUserService.list(wrapper);
ttRoll.setUpdateTime(DateUtils.getNowDate()); TtRoll ttRoll = rollService.getById(rollId);
rollService.updateById(ttRoll); if (ttRoll == null) {
return toAjax(rollService.removeById(rollId)); continue;
}
ttRoll.setUpdateBy(getUsername());
ttRoll.setUpdateTime(DateUtils.getNowDate());
rollService.updateById(ttRoll);
if (rollService.removeById(rollId)) {
count++;
}
}
return toAjax(count);
}
@ApiOperation("一键删除所有roll房")
@DeleteMapping("/removeAll")
public AjaxResult removeAll() {
List<TtRoll> list = rollService.list();
int count = 0;
for (TtRoll roll : list) {
Long rollId = roll.getId();
LambdaQueryWrapper<TtRollUser> wrapper = Wrappers.lambdaQuery();
wrapper.eq(TtRollUser::getRollId, rollId);
List<TtRollUser> rollUserList = rollUserService.list(wrapper);
roll.setUpdateBy(getUsername());
roll.setUpdateTime(DateUtils.getNowDate());
rollService.updateById(roll);
if (rollService.removeById(rollId)) {
count++;
}
}
return toAjax(count);
} }