|
| 1 | +<template> |
| 2 | + <div class="app-container"> |
| 3 | + |
| 4 | + <!-- 搜索工作栏 --> |
| 5 | + <!-- <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="100px"> |
| 6 | + <el-form-item label="秒杀时段名称" prop="name"> |
| 7 | + <el-input v-model="queryParams.name" placeholder="请输入秒杀时段名称" clearable @keyup.enter.native="handleQuery" /> |
| 8 | + </el-form-item> |
| 9 | +
|
| 10 | + <el-form-item label="开始时间点" prop="startTime"> |
| 11 | + <el-time-picker v-model="queryParams.startTime" placeholder="选择开始时间" value-format="HH:mm:ss" /> |
| 12 | + </el-form-item> |
| 13 | +
|
| 14 | + <el-form-item label="结束时间点" prop="endTime"> |
| 15 | + <el-time-picker v-model="queryParams.endTime" placeholder="选择结束时间" value-format="HH:mm:ss" /> |
| 16 | + </el-form-item> |
| 17 | +
|
| 18 | + <el-form-item> |
| 19 | + <el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button> |
| 20 | + <el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button> |
| 21 | + </el-form-item> |
| 22 | + </el-form> --> |
| 23 | + |
| 24 | + <!-- 操作工具栏 --> |
| 25 | + <el-row :gutter="10" class="mb8"> |
| 26 | + <el-col :span="1.5"> |
| 27 | + <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd" |
| 28 | + v-hasPermi="['promotion:seckill-time:create']">新增</el-button> |
| 29 | + </el-col> |
| 30 | + <!-- <el-col :span="1.5"> |
| 31 | + <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport" |
| 32 | + :loading="exportLoading" v-hasPermi="['promotion:seckill-time:export']">导出</el-button> |
| 33 | + </el-col> --> |
| 34 | + <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> |
| 35 | + </el-row> |
| 36 | + |
| 37 | + <!-- 列表 --> |
| 38 | + <el-table v-loading="loading" :data="list"> |
| 39 | + <el-table-column label="秒杀时段名称" align="center" prop="name" /> |
| 40 | + <el-table-column label="开始时间点" align="center" prop="startTime" width="180"> |
| 41 | + <template slot-scope="scope"> |
| 42 | + <span>{{ scope.row.startTime }}</span> |
| 43 | + </template> |
| 44 | + </el-table-column> |
| 45 | + <el-table-column label="结束时间点" align="center" prop="endTime" width="180"> |
| 46 | + <template slot-scope="scope"> |
| 47 | + <span>{{ scope.row.endTime }}</span> |
| 48 | + </template> |
| 49 | + </el-table-column> |
| 50 | + <el-table-column label="商品数量" align="center" prop="productCount" /> |
| 51 | + <el-table-column label="创建时间" align="center" prop="createTime" width="180"> |
| 52 | + <template slot-scope="scope"> |
| 53 | + <span>{{ parseTime(scope.row.createTime) }}</span> |
| 54 | + </template> |
| 55 | + </el-table-column> |
| 56 | + <el-table-column label="操作" align="center" class-name="small-padding fixed-width"> |
| 57 | + <template slot-scope="scope"> |
| 58 | + <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)" |
| 59 | + v-hasPermi="['promotion:seckill-time:update']">修改</el-button> |
| 60 | + <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)" |
| 61 | + v-hasPermi="['promotion:seckill-time:delete']">删除</el-button> |
| 62 | + </template> |
| 63 | + </el-table-column> |
| 64 | + </el-table> |
| 65 | + <!-- 分页组件 --> |
| 66 | + <!-- <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize" |
| 67 | + @pagination="getList" /> --> |
| 68 | + |
| 69 | + <!-- 对话框(添加 / 修改) --> |
| 70 | + <el-dialog :title="title" :visible.sync="open" width="600px" v-dialogDrag append-to-body> |
| 71 | + <el-form ref="form" :model="form" :rules="rules" label-width="140px"> |
| 72 | + <el-form-item label="秒杀场次名称" prop="name"> |
| 73 | + <el-input v-model="form.name" placeholder="请输入秒杀时段名称" clearable /> |
| 74 | + </el-form-item> |
| 75 | + <el-form-item label="秒杀时间段" prop="startAndEndTime"> |
| 76 | + <el-time-picker is-range v-model="form.startAndEndTime" range-separator="至" start-placeholder="开始时间" |
| 77 | + end-placeholder="结束时间" placeholder="选择时间范围" value-format="HH:mm:ss"> |
| 78 | + </el-time-picker> |
| 79 | + </el-form-item> |
| 80 | + </el-form> |
| 81 | + <div slot="footer" class="dialog-footer"> |
| 82 | + <el-button type="primary" @click="submitForm">确 定</el-button> |
| 83 | + <el-button @click="cancel">取 消</el-button> |
| 84 | + </div> |
| 85 | + </el-dialog> |
| 86 | + </div> |
| 87 | +</template> |
| 88 | + |
| 89 | +<script> |
| 90 | +import { createSeckillTime, updateSeckillTime, deleteSeckillTime, getSeckillTime, getSeckillTimePage, exportSeckillTimeExcel, getSeckillTimeList } from "@/api/promotion/seckillTime"; |
| 91 | +import { deepClone } from "@/utils"; |
| 92 | +
|
| 93 | +export default { |
| 94 | + name: "SeckillTime", |
| 95 | + components: { |
| 96 | + }, |
| 97 | + data() { |
| 98 | + return { |
| 99 | + // 遮罩层 |
| 100 | + loading: true, |
| 101 | + // 导出遮罩层 |
| 102 | + exportLoading: false, |
| 103 | + // 显示搜索条件 |
| 104 | + showSearch: true, |
| 105 | + // 总条数 |
| 106 | + // total: 0, |
| 107 | + // 秒杀时段列表 |
| 108 | + list: [], |
| 109 | + // 弹出层标题 |
| 110 | + title: "", |
| 111 | + // 是否显示弹出层 |
| 112 | + open: false, |
| 113 | + // 查询参数 |
| 114 | + // queryParams: { |
| 115 | + // pageNo: 1, |
| 116 | + // pageSize: 10, |
| 117 | + // name: null, |
| 118 | + // startTime: null, |
| 119 | + // endTime: null, |
| 120 | + // }, |
| 121 | + // 表单参数 |
| 122 | + form: {}, |
| 123 | + // 表单校验 |
| 124 | + rules: { |
| 125 | + name: [{ required: true, message: "秒杀时段名称不能为空", trigger: "blur" }], |
| 126 | + startAndEndTime: [{ required: true, message: "秒杀时间段不能为空", trigger: "blur" }], |
| 127 | + } |
| 128 | + }; |
| 129 | + }, |
| 130 | + created() { |
| 131 | + this.getList(); |
| 132 | + }, |
| 133 | + methods: { |
| 134 | + /** 查询列表 */ |
| 135 | + getList() { |
| 136 | + this.loading = true; |
| 137 | + // 执行查询 |
| 138 | + getSeckillTimeList().then(response => { |
| 139 | + console.log(response, "返回的数据") |
| 140 | + this.list = response.data; |
| 141 | + // this.total = response.data.total; |
| 142 | + this.loading = false; |
| 143 | + }); |
| 144 | + }, |
| 145 | + /** 取消按钮 */ |
| 146 | + cancel() { |
| 147 | + this.open = false; |
| 148 | + this.reset(); |
| 149 | + }, |
| 150 | + /** 表单重置 */ |
| 151 | + reset() { |
| 152 | + this.form = { |
| 153 | + id: undefined, |
| 154 | + name: undefined, |
| 155 | + startAndEndTime: undefined, |
| 156 | + startTime: undefined, |
| 157 | + endTime: undefined, |
| 158 | + }; |
| 159 | + this.resetForm("form"); |
| 160 | + }, |
| 161 | + /** 搜索按钮操作 */ |
| 162 | + handleQuery() { |
| 163 | + // this.queryParams.pageNo = 1; |
| 164 | + this.getList(); |
| 165 | + }, |
| 166 | + /** 重置按钮操作 */ |
| 167 | + resetQuery() { |
| 168 | + this.resetForm("queryForm"); |
| 169 | + this.handleQuery(); |
| 170 | + }, |
| 171 | + /** 新增按钮操作 */ |
| 172 | + handleAdd() { |
| 173 | + this.reset(); |
| 174 | + console.log(this.form, "点击新增时的form"); |
| 175 | + this.open = true; |
| 176 | + this.title = "添加秒杀时段"; |
| 177 | + }, |
| 178 | + /** 修改按钮操作 */ |
| 179 | + handleUpdate(row) { |
| 180 | + this.reset(); |
| 181 | + const id = row.id; |
| 182 | + getSeckillTime(id).then(response => { |
| 183 | + response.data.startAndEndTime = [response.data.startTime, response.data.endTime] |
| 184 | + this.form = response.data; |
| 185 | + this.open = true; |
| 186 | + this.title = "修改秒杀时段"; |
| 187 | + }); |
| 188 | + }, |
| 189 | + /** 提交按钮 */ |
| 190 | + submitForm() { |
| 191 | + this.$refs["form"].validate(valid => { |
| 192 | + console.log(valid, "是否通过"); |
| 193 | + if (!valid) { |
| 194 | + return; |
| 195 | + } |
| 196 | + // 处理数据 |
| 197 | + const data = deepClone(this.form); |
| 198 | + data.startTime = this.form.startAndEndTime[0]; |
| 199 | + data.endTime = this.form.startAndEndTime[1]; |
| 200 | + // 修改的提交 |
| 201 | + if (this.form.id != null) { |
| 202 | + updateSeckillTime(data).then(response => { |
| 203 | + this.$modal.msgSuccess("修改成功"); |
| 204 | + this.open = false; |
| 205 | + this.getList(); |
| 206 | + }); |
| 207 | + return; |
| 208 | + } |
| 209 | + // 添加的提交 |
| 210 | + createSeckillTime(data).then(response => { |
| 211 | + this.$modal.msgSuccess("新增成功"); |
| 212 | + this.open = false; |
| 213 | + this.getList(); |
| 214 | + }); |
| 215 | + }); |
| 216 | + }, |
| 217 | + /** 删除按钮操作 */ |
| 218 | + handleDelete(row) { |
| 219 | + const id = row.id; |
| 220 | + this.$modal.confirm('是否确认删除秒杀时段编号为"' + id + '"的数据项?').then(function () { |
| 221 | + return deleteSeckillTime(id); |
| 222 | + }).then(() => { |
| 223 | + this.getList(); |
| 224 | + this.$modal.msgSuccess("删除成功"); |
| 225 | + }).catch(() => { }); |
| 226 | + }, |
| 227 | + /** 导出按钮操作 */ |
| 228 | + // handleExport() { |
| 229 | + // // 处理查询参数 |
| 230 | + // let params = { ...this.queryParams }; |
| 231 | + // params.pageNo = undefined; |
| 232 | + // params.pageSize = undefined; |
| 233 | + // this.$modal.confirm('是否确认导出所有秒杀时段数据项?').then(() => { |
| 234 | + // this.exportLoading = true; |
| 235 | + // return exportSeckillTimeExcel(params); |
| 236 | + // }).then(response => { |
| 237 | + // this.$download.excel(response, '秒杀时段.xls'); |
| 238 | + // this.exportLoading = false; |
| 239 | + // }).catch(() => { }); |
| 240 | + // } |
| 241 | + } |
| 242 | +}; |
| 243 | +</script> |
0 commit comments