|
@@ -0,0 +1,252 @@
|
|
|
+<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="name">
|
|
|
+ <el-input v-model="queryParams.name" placeholder="请输入名称" clearable @keyup.enter.native="handleQuery"/>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="种类" prop="name">
|
|
|
+ <el-cascader v-model="queryParams.tags" :options="voucher_category" :props="{emitPath:false}"></el-cascader>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="兑换群体" prop="name">
|
|
|
+ <el-select v-model="queryParams.tags" placeholder="请选择">
|
|
|
+ <el-option v-for="dict in dict.type.user_tags" :key="dict.value" :label="dict.label" :value="dict.value"></el-option>
|
|
|
+ </el-select>
|
|
|
+ </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">新增</el-button>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+
|
|
|
+ <el-table v-loading="loading" :data="taskList">
|
|
|
+ <el-table-column label="名称" align="center" prop="name" />
|
|
|
+ <el-table-column label="种类" align="center" prop="categoryText" />
|
|
|
+ <el-table-column label="可兑换群体" align="center" prop="tags" />
|
|
|
+ <el-table-column label="面额" align="center" prop="money" />
|
|
|
+ <el-table-column label="需要积分" align="center" prop="integral" />
|
|
|
+ <el-table-column label="创建时间" align="center" prop="createTime" width="180">
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
|
|
|
+ </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-plus" @click="handleIncrease(scope.row)">增发</el-button>
|
|
|
+ <el-button size="mini" type="text" icon="el-icon-minus" @click="handleReduce(scope.row)">减发</el-button>
|
|
|
+ <el-button size="mini" type="text" icon="el-icon-edit" @click="handleEdit(scope.row)">修改</el-button>
|
|
|
+ <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)">删除</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="photo">
|
|
|
+ <!-- 图片上传 -->
|
|
|
+ <ImageUpload @input="fileUpload" :value="form.photo" :limit="1" ></ImageUpload>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="名称" prop="name">
|
|
|
+ <el-input v-model="form.name" placeholder="请输入名称" />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="种类" prop="category">
|
|
|
+ <el-cascader v-model="form.tags" :options="voucher_category" :props="{emitPath:false}"></el-cascader>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="可兑换群体" prop="tags">
|
|
|
+ <el-select v-model="form.tags" placeholder="请选择">
|
|
|
+ <el-option v-for="dict in dict.type.user_tags" :key="dict.value" :label="dict.label" :value="dict.value"></el-option>
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="面额" prop="money">
|
|
|
+ <el-input v-model="form.money" type="number" placeholder="请输入面额" />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="需要积分" prop="integral">
|
|
|
+ <el-input v-model="form.integral" type="number" placeholder="请输入需要积分" />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="发放数量" prop="count">
|
|
|
+ <el-input v-model="form.count" type="number" placeholder="请输入发放数量" />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="领取开始时间" prop="startTime">
|
|
|
+ <el-date-picker v-model="form.startTime" type="datetime" placeholder="选择日期时间"></el-date-picker>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="领取结束时间" type="endTime" prop="name">
|
|
|
+ <el-date-picker v-model="form.endTime" type="datetime" placeholder="选择日期时间"></el-date-picker>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="领取地点" prop="location">
|
|
|
+ <el-input v-model="form.location" placeholder="请输入领取地点" />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="详情" prop="details">
|
|
|
+ <editoritem5 :value="form.details" @change="getFileId"></editoritem5>
|
|
|
+ </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 { updateNumber, delVoucher, updateVoucher, addVoucher, getVoucher, listVoucher } from "@/api/goods/voucher/index";
|
|
|
+
|
|
|
+export default {
|
|
|
+ name: "voucher",
|
|
|
+ dicts: ['tags'],
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ // 遮罩层
|
|
|
+ loading: false,
|
|
|
+ // 显示搜索条件
|
|
|
+ showSearch: true,
|
|
|
+ // 总条数
|
|
|
+ total: 0,
|
|
|
+ // 检测代金券管理表格数据
|
|
|
+ taskList: [],
|
|
|
+ // 弹出层标题
|
|
|
+ title: "",
|
|
|
+ // 是否显示弹出层
|
|
|
+ open: false,
|
|
|
+ // 查询参数
|
|
|
+ queryParams: {
|
|
|
+ pageNum: 1,
|
|
|
+ pageSize: 10,
|
|
|
+ },
|
|
|
+ // 表单参数
|
|
|
+ form: {},
|
|
|
+ // 表单校验
|
|
|
+ rules: {},
|
|
|
+ voucher_category: []
|
|
|
+ };
|
|
|
+ },
|
|
|
+ async created() {
|
|
|
+ // this.getList();
|
|
|
+ const dict = await this.getDicts('voucher_category');
|
|
|
+ dict.data = dict.data.map(e => ({ ...e, label: e.dictLabel, value: e.dictValue }))
|
|
|
+ this.voucher_category = dict.data.filter(e => !e.remark).map(e => {
|
|
|
+ const children = dict.data.filter(j => j.remark == e.dictValue);
|
|
|
+ if (children.length > 0) e.children = children;
|
|
|
+ return e;
|
|
|
+ })
|
|
|
+ console.log(this.voucher_category, 'voucher_category');
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ // 减发
|
|
|
+ handleReduce(e) {
|
|
|
+ this.$modal.prompt('请输入减发数量').then(({ value }) => {
|
|
|
+ return updateNumber({ voucherId: e.voucherId, type: 'delete', comment: value });
|
|
|
+ }).then(() => {
|
|
|
+ this.query();
|
|
|
+ this.$modal.msgSuccess("减发成功");
|
|
|
+ }).catch(() => {});
|
|
|
+ },
|
|
|
+ // 增发
|
|
|
+ handleIncrease(e) {
|
|
|
+ this.$modal.prompt('请输入增发数量').then(({ value }) => {
|
|
|
+ return updateNumber({ voucherId: e.voucherId, type: 'add', comment: value });
|
|
|
+ }).then(() => {
|
|
|
+ this.query();
|
|
|
+ this.$modal.msgSuccess("增发成功");
|
|
|
+ }).catch(() => {});
|
|
|
+ },
|
|
|
+ /** 查询检测代金券管理列表 */
|
|
|
+ getList() {
|
|
|
+ this.loading = true;
|
|
|
+ listVoucher(this.queryParams).then(response => {
|
|
|
+ this.taskList = response.rows.map(e => {
|
|
|
+ const dict = this.dict.type.voucher_category.find(j => j.dictValue == e.category)
|
|
|
+ if (dict) e.categoryText = dict.dictLabel;
|
|
|
+ return e;
|
|
|
+ });
|
|
|
+ this.total = response.total;
|
|
|
+ this.loading = false;
|
|
|
+ });
|
|
|
+ },
|
|
|
+ // 取消按钮
|
|
|
+ cancel() {
|
|
|
+ this.open = false;
|
|
|
+ this.reset();
|
|
|
+ },
|
|
|
+ // 表单重置
|
|
|
+ reset() {
|
|
|
+ this.form = {};
|
|
|
+ this.resetForm("form");
|
|
|
+ },
|
|
|
+ /** 搜索按钮操作 */
|
|
|
+ handleQuery() {
|
|
|
+ this.queryParams.pageNum = 1;
|
|
|
+ this.getList();
|
|
|
+ },
|
|
|
+ /** 重置按钮操作 */
|
|
|
+ resetQuery() {
|
|
|
+ this.resetForm("queryForm");
|
|
|
+ this.handleQuery();
|
|
|
+ },
|
|
|
+ /** 新增按钮操作 */
|
|
|
+ handleAdd() {
|
|
|
+ this.reset();
|
|
|
+ this.open = true;
|
|
|
+ this.title = "添加代金券";
|
|
|
+ },
|
|
|
+ /** 提交按钮 */
|
|
|
+ submitForm() {
|
|
|
+ this.$refs["form"].validate(valid => {
|
|
|
+ if (valid) {
|
|
|
+ if (this.form.natTaskId != null) {
|
|
|
+ updateVoucher(this.form).then(response => {
|
|
|
+ this.$modal.msgSuccess("修改成功");
|
|
|
+ this.open = false;
|
|
|
+ this.getList();
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ addVoucher(this.form).then(response => {
|
|
|
+ this.$modal.msgSuccess("新增成功");
|
|
|
+ this.open = false;
|
|
|
+ this.getList();
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ /** 删除按钮操作 */
|
|
|
+ handleDelete(row) {
|
|
|
+ this.$modal.confirm(`是否确认删除代金券名称为${ row.name}的数据项?`).then(function() {
|
|
|
+ return delVoucher(row.voucherId);
|
|
|
+ }).then(() => {
|
|
|
+ this.getList();
|
|
|
+ this.$modal.msgSuccess("删除成功");
|
|
|
+ }).catch(() => {});
|
|
|
+ },
|
|
|
+ /** 修改按钮操作 */
|
|
|
+ handleUpdate(row) {
|
|
|
+ this.reset();
|
|
|
+ getVoucher(row.voucherId).then(response => {
|
|
|
+ this.form = data;
|
|
|
+ this.open = true;
|
|
|
+ this.title = "代金券详情";
|
|
|
+ });
|
|
|
+ },
|
|
|
+ // 富文本改变
|
|
|
+ getFileId(e) {
|
|
|
+ this.$set(this.form, 'details', e);
|
|
|
+ },
|
|
|
+ // 文件上传
|
|
|
+ fileUpload(e) {
|
|
|
+ this.$set(this.form, 'photo', e);
|
|
|
+ },
|
|
|
+ }
|
|
|
+};
|
|
|
+</script>
|