434 lines
14 KiB
Vue
434 lines
14 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="大赛名称" prop="competitionName">
|
|
<el-input
|
|
v-model="queryParams.competitionName"
|
|
placeholder="请输入大赛名称"
|
|
clearable
|
|
@keyup.enter.native="handleQuery"
|
|
/>
|
|
</el-form-item>
|
|
<el-form-item label="大赛类型" prop="competitionType">
|
|
<el-select
|
|
v-model="queryParams.competitionType"
|
|
placeholder="大赛类型"
|
|
clearable
|
|
style="width: 125px">
|
|
<el-option
|
|
v-for="dict in dict.type.competition_type"
|
|
:key="dict.value"
|
|
:label="dict.label"
|
|
:value="dict.value"
|
|
/>
|
|
</el-select>
|
|
</el-form-item>
|
|
<el-form-item label="报名时间">
|
|
<el-date-picker
|
|
format="yyyy-MM-dd HH:mm"
|
|
:picker-options="pickerOptions"
|
|
v-model="regDate"
|
|
type="datetimerange"
|
|
range-separator="至"
|
|
start-placeholder="开始日期"
|
|
end-placeholder="结束日期">
|
|
</el-date-picker>
|
|
</el-form-item>
|
|
<el-form-item label="大赛时间">
|
|
<el-date-picker
|
|
format="yyyy-MM-dd HH:mm"
|
|
:picker-options="pickerOptions"
|
|
v-model="cpDate"
|
|
type="datetimerange"
|
|
range-separator="至"
|
|
start-placeholder="开始日期"
|
|
end-placeholder="结束日期">
|
|
</el-date-picker>
|
|
</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="['competition:competition: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="['competition:competition: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="['competition:competition:remove']"
|
|
>删除</el-button>
|
|
</el-col>
|
|
<el-col :span="1.5">
|
|
<el-button
|
|
type="warning"
|
|
plain
|
|
icon="el-icon-download"
|
|
size="mini"
|
|
@click="handleExport"
|
|
v-hasPermi="['competition:competition:export']"
|
|
>导出</el-button>
|
|
</el-col>
|
|
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
|
</el-row>
|
|
|
|
<el-table v-loading="loading" :data="HitCompetitionList" @selection-change="handleSelectionChange">
|
|
<el-table-column type="selection" width="55" align="center" />
|
|
<el-table-column label="大赛名称" align="center" prop="competitionName" />
|
|
<el-table-column label="报名开始时间" align="center" prop="regBeginTime" width="180">
|
|
<template slot-scope="scope">
|
|
<span>{{ parseTime(scope.row.regBeginTime, '{y}-{m}-{d}') }}</span>
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column label="报名结束时间" align="center" prop="regEndTime" width="180">
|
|
<template slot-scope="scope">
|
|
<span>{{ parseTime(scope.row.regEndTime, '{y}-{m}-{d}') }}</span>
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column label="开始时间" align="center" prop="cpBeginTime" width="180">
|
|
<template slot-scope="scope">
|
|
<span>{{ parseTime(scope.row.cpBeginTime, '{y}-{m}-{d}') }}</span>
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column label="结束时间" align="center" prop="cpEndTime" width="180">
|
|
<template slot-scope="scope">
|
|
<span>{{ parseTime(scope.row.cpEndTime, '{y}-{m}-{d}') }}</span>
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column label="大赛类型" align="center" prop="competitionType">
|
|
<template slot-scope="scope">
|
|
<dict-tag :options="dict.type.competition_type" :value="scope.row.competitionType"/>
|
|
</template>
|
|
</el-table-column>
|
|
<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="['competition:competition:edit']"
|
|
>修改</el-button>
|
|
<el-button
|
|
size="mini"
|
|
type="text"
|
|
icon="el-icon-delete"
|
|
@click="handleDelete(scope.row)"
|
|
v-hasPermi="['competition:competition: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="大赛名称" prop="competitionName">
|
|
<el-input v-model="form.competitionName" placeholder="请输入大赛名称" />
|
|
</el-form-item>
|
|
<el-form-item label="报名时间" prop="inRegDate">
|
|
<el-date-picker
|
|
format="yyyy-MM-dd HH:mm"
|
|
:picker-options="pickerOptions"
|
|
v-model="form.inRegDate"
|
|
type="datetimerange"
|
|
range-separator="至"
|
|
start-placeholder="开始日期"
|
|
end-placeholder="结束日期">
|
|
</el-date-picker>
|
|
</el-form-item>
|
|
<el-form-item label="大赛时间" prop="inCpDate">
|
|
<el-date-picker
|
|
format="yyyy-MM-dd HH:mm"
|
|
:picker-options="pickerOptions"
|
|
v-model="form.inCpDate"
|
|
type="datetimerange"
|
|
range-separator="至"
|
|
start-placeholder="开始日期"
|
|
end-placeholder="结束日期">
|
|
</el-date-picker>
|
|
</el-form-item>
|
|
<el-form-item label="大赛类型" prop="competitionType">
|
|
<el-radio-group v-model="form.competitionType">
|
|
<el-radio-button label="0">团队赛</el-radio-button>
|
|
<el-radio-button label="1">个人赛</el-radio-button>
|
|
</el-radio-group>
|
|
</el-form-item>
|
|
<el-form-item label="备注" prop="remark">
|
|
<el-input v-model="form.remark" placeholder="请输入备注" />
|
|
</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 { listHitCompetition, getHitCompetition, delHitCompetition, addHitCompetition, updateHitCompetition } from "@/api/hit/competition";
|
|
|
|
export default {
|
|
name: "HitCompetition",
|
|
dicts: ['competition_type'],
|
|
data() {
|
|
return {
|
|
// 遮罩层
|
|
loading: true,
|
|
// 选中数组
|
|
ids: [],
|
|
// 非单个禁用
|
|
single: true,
|
|
// 非多个禁用
|
|
multiple: true,
|
|
// 显示搜索条件
|
|
showSearch: true,
|
|
// 总条数
|
|
total: 0,
|
|
// 大赛信息表格数据
|
|
HitCompetitionList: [],
|
|
// 弹出层标题
|
|
title: "",
|
|
// 是否显示弹出层
|
|
open: false,
|
|
// 查询参数
|
|
queryParams: {
|
|
pageNum: 1,
|
|
pageSize: 10,
|
|
competitionName: null,
|
|
cpBeginTime: null,
|
|
cpEndTime: null,
|
|
regBeginTime: null,
|
|
regEndTime: null,
|
|
competitionType: null,
|
|
},
|
|
// 表单参数
|
|
form: {
|
|
},
|
|
// 表单校验
|
|
rules: {
|
|
competitionName: [
|
|
{ required: true, message: "大赛名称不能为空", trigger: "blur" }
|
|
],
|
|
inCpDate: [
|
|
{ required: true, message: "大赛时间不能为空", trigger: "blur" }
|
|
],
|
|
inRegDate: [
|
|
{ required: true, message: "报名时间不能为空", trigger: "blur" }
|
|
],
|
|
competitionType: [
|
|
{ required: true, message: "大赛类型不能为空", trigger: "change" }
|
|
],
|
|
},
|
|
cpDate:[],
|
|
regDate: [],
|
|
inCpDate:[],
|
|
inRegDate: [],
|
|
pickerOptions: {
|
|
disabledDate(time) {
|
|
return time.getTime() < Date.now() - 8.64e7;
|
|
}
|
|
},
|
|
};
|
|
},
|
|
created() {
|
|
this.getList();
|
|
},
|
|
methods: {
|
|
/** 查询大赛信息列表 */
|
|
getList() {
|
|
this.loading = true;
|
|
listHitCompetition(this.queryParams).then(response => {
|
|
this.HitCompetitionList = response.rows;
|
|
this.total = response.total;
|
|
this.loading = false;
|
|
});
|
|
},
|
|
// 取消按钮
|
|
cancel() {
|
|
this.open = false;
|
|
this.reset();
|
|
},
|
|
// 表单重置
|
|
reset() {
|
|
this.form = {
|
|
id: null,
|
|
competitionName: null,
|
|
cpBeginTime: null,
|
|
cpEndTime: null,
|
|
regBeginTime: null,
|
|
regEndTime: null,
|
|
competitionType: "0",
|
|
remark: null,
|
|
delFlag: null,
|
|
createTime: null,
|
|
createBy: null,
|
|
updateTime: null,
|
|
updateBy: null
|
|
};
|
|
this.resetForm("form");
|
|
},
|
|
/** 搜索按钮操作 */
|
|
handleQuery() {
|
|
this.dateToQueryDate()
|
|
this.queryParams.pageNum = 1;
|
|
this.getList();
|
|
},
|
|
/** 重置按钮操作 */
|
|
resetQuery() {
|
|
this.resetForm("queryForm");
|
|
this.handleQuery();
|
|
},
|
|
// 多选框选中数据
|
|
handleSelectionChange(selection) {
|
|
this.ids = selection.map(item => item.id)
|
|
this.single = selection.length!==1
|
|
this.multiple = !selection.length
|
|
},
|
|
/** 新增按钮操作 */
|
|
handleAdd() {
|
|
this.reset();
|
|
this.open = true;
|
|
this.title = "添加大赛信息";
|
|
},
|
|
/** 修改按钮操作 */
|
|
handleUpdate(row) {
|
|
this.reset();
|
|
const id = row.id || this.ids
|
|
getHitCompetition(id).then(response => {
|
|
this.form = response.data;
|
|
this.formDateToDate()
|
|
this.open = true;
|
|
this.title = "修改大赛信息";
|
|
});
|
|
},
|
|
/** 提交按钮 */
|
|
submitForm() {
|
|
this.$refs["form"].validate(valid => {
|
|
if (valid) {
|
|
this.dateToFromDate()
|
|
const flag = this.judgeRegTime()
|
|
if (flag){
|
|
if (this.form.id != null) {
|
|
updateHitCompetition(this.form).then(response => {
|
|
this.$modal.msgSuccess("修改成功");
|
|
this.open = false;
|
|
this.getList();
|
|
});
|
|
} else {
|
|
addHitCompetition(this.form).then(response => {
|
|
this.$modal.msgSuccess("新增成功");
|
|
this.open = false;
|
|
this.getList();
|
|
});
|
|
}
|
|
}
|
|
}
|
|
});
|
|
},
|
|
/** 删除按钮操作 */
|
|
handleDelete(row) {
|
|
const ids = row.id || this.ids;
|
|
this.$modal.confirm('该操作不可逆转,是否确认删除?').then(function() {
|
|
return delHitCompetition(ids);
|
|
}).then(() => {
|
|
this.getList();
|
|
this.$modal.msgSuccess("删除成功");
|
|
}).catch(() => {});
|
|
},
|
|
/** 导出按钮操作 */
|
|
handleExport() {
|
|
this.download('hit/hitCompetition/export', {
|
|
...this.queryParams
|
|
}, `HitCompetition_${new Date().getTime()}.xlsx`)
|
|
},
|
|
dateToQueryDate(){
|
|
if (this.cpDate !== null && this.cpDate.length !== 0){
|
|
[this.queryParams.cpBeginTime, this.queryParams.cpEndTime] = this.cpDate
|
|
this.queryParams.cpBeginTime = this.formatTimer(this.queryParams.cpBeginTime)
|
|
this.queryParams.cpEndTime = this.formatTimer(this.queryParams.cpEndTime)
|
|
}
|
|
if (this.regDate !== null && this.regDate.length !== 0){
|
|
[this.queryParams.regBeginTime, this.queryParams.regEndTime] = this.regDate
|
|
this.queryParams.regBeginTime = this.formatTimer(this.queryParams.regBeginTime)
|
|
this.queryParams.regEndTime = this.formatTimer(this.queryParams.regEndTime)
|
|
}
|
|
},
|
|
dateToFromDate(){
|
|
[this.form.cpBeginTime, this.form.cpEndTime] = this.form.inCpDate;
|
|
[this.form.regBeginTime, this.form.regEndTime] = this.form.inRegDate;
|
|
this.form.cpBeginTime = this.formatTimer(this.form.cpBeginTime)
|
|
this.form.cpEndTime = this.formatTimer(this.form.cpEndTime)
|
|
this.form.regBeginTime = this.formatTimer(this.form.regBeginTime)
|
|
this.form.regEndTime = this.formatTimer(this.form.regEndTime)
|
|
},
|
|
formDateToDate(){
|
|
this.form.inCpDate = [this.form.cpBeginTime, this.form.cpEndTime];
|
|
this.form.inRegDate = [this.form.regBeginTime, this.form.regEndTime];
|
|
},
|
|
judgeRegTime(){
|
|
if (this.form.regEndTime > this.form.cpBeginTime){
|
|
this.$modal.msgError("新增失败,报名结束时间在大赛开始时间之前")
|
|
return false
|
|
}
|
|
return true
|
|
},
|
|
formatTimer: function(value) {
|
|
let date = new Date(value);
|
|
let y = date.getFullYear();
|
|
let MM = date.getMonth() + 1;
|
|
MM = MM < 10 ? "0" + MM : MM;
|
|
let d = date.getDate();
|
|
d = d < 10 ? "0" + d : d;
|
|
let h = date.getHours();
|
|
h = h < 10 ? "0" + h : h;
|
|
let m = date.getMinutes();
|
|
m = m < 10 ? "0" + m : m;
|
|
let s = date.getSeconds();
|
|
s = s < 10 ? "0" + s : s;
|
|
return y + "-" + MM + "-" + d + " " + h + ":" + m;
|
|
}
|
|
}
|
|
};
|
|
</script>
|
|
|
|
<style scoped lang="scss">
|
|
::v-deep .el-date-editor--datetimerange.el-input, .el-date-editor--datetimerange.el-input__inner{
|
|
width: 380px;
|
|
}
|
|
</style>
|