333 lines
10 KiB
Vue
333 lines
10 KiB
Vue
<template>
|
|
<div class="app-container">
|
|
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
|
|
<el-form-item label="宝箱ID" prop="boxId">
|
|
<el-input
|
|
v-model="queryParams.boxId"
|
|
placeholder="请输入宝箱ID"
|
|
clearable
|
|
@keyup.enter.native="handleQuery"
|
|
/>
|
|
</el-form-item>
|
|
<el-form-item>
|
|
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
|
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
|
</el-form-item>
|
|
</el-form>
|
|
|
|
<el-row :gutter="10" class="mb8">
|
|
<el-col :span="1.5">
|
|
<el-button
|
|
type="primary"
|
|
plain
|
|
icon="el-icon-plus"
|
|
size="mini"
|
|
@click="handleAdd"
|
|
v-hasPermi="['admin:box:add']"
|
|
>新增</el-button>
|
|
</el-col>
|
|
<el-col :span="1.5">
|
|
<el-button
|
|
type="success"
|
|
plain
|
|
icon="el-icon-edit"
|
|
size="mini"
|
|
:disabled="single"
|
|
@click="handleUpdate"
|
|
v-hasPermi="['admin:box:edit']"
|
|
>修改</el-button>
|
|
</el-col>
|
|
<el-col :span="1.5">
|
|
<el-button
|
|
type="danger"
|
|
plain
|
|
icon="el-icon-delete"
|
|
size="mini"
|
|
:disabled="multiple"
|
|
@click="handleDelete"
|
|
v-hasPermi="['admin:box:remove']"
|
|
>删除</el-button>
|
|
</el-col>
|
|
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
|
</el-row>
|
|
|
|
<el-table v-loading="loading" :data="boxGroupList" @selection-change="handleSelectionChange">
|
|
<el-table-column type="selection" width="55" align="center" />
|
|
<el-table-column label="分组ID" align="center" prop="groupId" />
|
|
<el-table-column label="宝箱ID" align="center" prop="boxId" />
|
|
<el-table-column label="宝箱名称" align="center" prop="boxName" />
|
|
<el-table-column label="宝箱数量" align="center" prop="boxNum" />
|
|
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
|
<template slot-scope="scope">
|
|
<el-button
|
|
size="mini"
|
|
type="text"
|
|
icon="el-icon-edit"
|
|
@click="handleUpdate(scope.row)"
|
|
v-hasPermi="['admin:box:edit']"
|
|
>修改</el-button>
|
|
<el-button
|
|
size="mini"
|
|
type="text"
|
|
icon="el-icon-delete"
|
|
@click="handleDelete(scope.row)"
|
|
v-hasPermi="['admin:box:remove']"
|
|
>删除</el-button>
|
|
</template>
|
|
</el-table-column>
|
|
</el-table>
|
|
|
|
<pagination
|
|
v-show="total>0"
|
|
:total="total"
|
|
:page.sync="queryParams.pageNum"
|
|
:limit.sync="queryParams.pageSize"
|
|
@pagination="getList"
|
|
/>
|
|
|
|
<!-- 添加或修改机器人对战分组宝箱对话框 -->
|
|
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
|
|
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
|
|
<el-form-item label="宝箱ID" prop="boxId">
|
|
<el-popover placement="bottom-start" width="460" trigger="hover" ref="morePop">
|
|
<el-input
|
|
slot="reference"
|
|
v-model="form.boxId"
|
|
placeholder="请选择箱子"
|
|
suffix-icon="el-icon-caret-bottom"
|
|
readonly
|
|
clearable
|
|
></el-input>
|
|
<el-form>
|
|
<el-row>
|
|
<el-form v-if="boxList">
|
|
<div class="magicbox" @scroll="scrollEventFn" v-if="boxList.length > 0">
|
|
<div class="magic"
|
|
v-for="(item, index) in boxList"
|
|
:key="index"
|
|
@click="selectBox(item)">
|
|
<div>{{item.boxName}}</div>
|
|
<div>¥{{item.price}}</div>
|
|
<div>{{item.boxId}}</div>
|
|
</div>
|
|
</div>
|
|
<div v-else>
|
|
<div style="margin: 0 auto; text-align: center">暂无箱子数据</div>
|
|
</div>
|
|
</el-form>
|
|
</el-row>
|
|
</el-form>
|
|
</el-popover>
|
|
</el-form-item>
|
|
<el-form-item label="宝箱数量" prop="boxNum">
|
|
<el-input-number v-model="form.boxNum" :min="0" :max="15" />
|
|
</el-form-item>
|
|
</el-form>
|
|
<div slot="footer" class="dialog-footer">
|
|
<el-button type="primary" @click="submitForm">确 定</el-button>
|
|
<el-button @click="cancel">取 消</el-button>
|
|
</div>
|
|
</el-dialog>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
import { listGroupBox, getGroupBox, delGroupBox, addGroupBox, updateGroupBox } from "@/api/skins/ttFight/robotFightGroupBox";
|
|
import { listBox } from "@/api/skins/ttBox/api";
|
|
|
|
export default {
|
|
name: 'RobotFightGroupBox',
|
|
data() {
|
|
return {
|
|
// 遮罩层
|
|
loading: true,
|
|
// 选中数组
|
|
ids: [],
|
|
// 非单个禁用
|
|
single: true,
|
|
// 非多个禁用
|
|
multiple: true,
|
|
// 显示搜索条件
|
|
showSearch: true,
|
|
// 总条数
|
|
total: 0,
|
|
// 机器人对战分组宝箱表格数据
|
|
boxGroupList: [],
|
|
// 宝箱列表数据
|
|
boxList: [],
|
|
// 弹出层标题
|
|
title: "",
|
|
// 是否显示弹出层
|
|
open: false,
|
|
// 是否编辑模式(true=修改,false=新增)
|
|
isEdit: false,
|
|
// 查询参数
|
|
queryParams: {
|
|
pageNum: 1,
|
|
pageSize: 10,
|
|
groupId: this.$route.params.groupId,
|
|
boxId: null,
|
|
boxNum: null
|
|
},
|
|
// 箱子列表查询参数
|
|
boxListQueryParams: {
|
|
pageNum: 1,
|
|
pageSize: 10,
|
|
status: '0',
|
|
isFight: '0'
|
|
},
|
|
// 表单参数
|
|
form: {},
|
|
// 表单校验
|
|
rules: {
|
|
}
|
|
};
|
|
},
|
|
created() {
|
|
this.getList();
|
|
},
|
|
methods: {
|
|
/** 查询机器人对战分组宝箱列表 */
|
|
getList() {
|
|
this.loading = true;
|
|
listGroupBox(this.$route.params.groupId, this.queryParams).then(response => {
|
|
this.boxGroupList = response.rows;
|
|
this.total = response.total;
|
|
this.loading = false;
|
|
});
|
|
},
|
|
/** 查询箱子列表 */
|
|
getBoxList() {
|
|
this.boxListQueryParams.pageNum = 1;
|
|
listBox(this.boxListQueryParams).then(response => {
|
|
this.boxList = response.rows;
|
|
this.boxListTotal = response.total;
|
|
});
|
|
},
|
|
// 取消按钮
|
|
cancel() {
|
|
this.open = false;
|
|
this.reset();
|
|
},
|
|
// 表单重置
|
|
reset() {
|
|
this.form = {
|
|
groupId: null,
|
|
boxId: null,
|
|
boxNum: 1
|
|
};
|
|
this.resetForm("form");
|
|
},
|
|
/** 搜索按钮操作 */
|
|
handleQuery() {
|
|
this.queryParams.pageNum = 1;
|
|
this.getList();
|
|
},
|
|
/** 重置按钮操作 */
|
|
resetQuery() {
|
|
this.resetForm("queryForm");
|
|
this.handleQuery();
|
|
},
|
|
// 多选框选中数据
|
|
handleSelectionChange(selection) {
|
|
this.ids = selection.map(item => item.boxId)
|
|
this.single = selection.length!==1
|
|
this.multiple = !selection.length
|
|
},
|
|
/** 新增按钮操作 */
|
|
handleAdd() {
|
|
this.reset();
|
|
this.isEdit = false;
|
|
this.open = true;
|
|
this.title = "添加机器人对战分组宝箱";
|
|
this.getBoxList();
|
|
},
|
|
/** 修改按钮操作 */
|
|
handleUpdate(row) {
|
|
this.reset();
|
|
this.isEdit = true;
|
|
const boxId = row.boxId || this.ids
|
|
getGroupBox(this.$route.params.groupId, boxId).then(response => {
|
|
this.form = response.data;
|
|
this.form.oldBoxId = this.form.boxId;
|
|
this.open = true;
|
|
this.title = "修改机器人对战分组宝箱";
|
|
this.getBoxList();
|
|
});
|
|
},
|
|
/** 提交按钮 */
|
|
submitForm() {
|
|
this.$refs["form"].validate(valid => {
|
|
if (valid) {
|
|
if (this.isEdit) {
|
|
updateGroupBox(this.form).then(response => {
|
|
this.$modal.msgSuccess("修改成功");
|
|
this.open = false;
|
|
this.getList();
|
|
});
|
|
} else {
|
|
this.form.groupId = parseInt(this.$route.params.groupId);
|
|
addGroupBox(this.form).then(response => {
|
|
this.$modal.msgSuccess("新增成功");
|
|
this.open = false;
|
|
this.getList();
|
|
});
|
|
}
|
|
}
|
|
});
|
|
},
|
|
/** 删除按钮操作 */
|
|
handleDelete(row) {
|
|
const boxIds = row.boxId || this.ids;
|
|
const self = this;
|
|
this.$modal.confirm('是否确认删除机器人对战分组宝箱编号为"' + boxIds + '"的数据项?').then(function() {
|
|
return delGroupBox(self.$route.params.groupId, boxIds);
|
|
}).then(() => {
|
|
this.getList();
|
|
this.$modal.msgSuccess("删除成功");
|
|
}).catch(() => {});
|
|
},
|
|
scrollEventFn(e) {
|
|
// 判断滚动条是否到达底部
|
|
let b = e.srcElement.scrollTop + e.srcElement.clientHeight >= e.srcElement.scrollHeight;
|
|
if (b) {
|
|
// 计算总页数(向上取整)
|
|
let totalPage = Math.ceil(this.boxListTotal / this.boxListQueryParams.pageSize);
|
|
this.boxListQueryParams.pageNum += 1;
|
|
if (this.boxListQueryParams.pageNum <= totalPage) {
|
|
listBox(this.boxListQueryParams).then(response => {
|
|
this.boxList.push.apply(this.boxList, response.rows);
|
|
});
|
|
} else {
|
|
this.$modal.msgWarning("没有更多箱子了");
|
|
}
|
|
}
|
|
},
|
|
selectBox(boxData) {
|
|
this.form.boxId = boxData.boxId;
|
|
this.$refs.morePop.doClose();
|
|
}
|
|
}
|
|
};
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
.magicbox {
|
|
margin: 0 auto;
|
|
margin-top: 5px;
|
|
height: 300px;
|
|
overflow-y: scroll;
|
|
.magic {
|
|
height: 32px;
|
|
padding: 2px 5px;
|
|
line-height: 32px;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: space-between;
|
|
&:hover {
|
|
background-color: #9a5c35;
|
|
transition: all ease 0.3s;
|
|
}
|
|
}
|
|
}
|
|
</style> |