|
@@ -0,0 +1,252 @@
|
|
|
+<!-- -->
|
|
|
+<template>
|
|
|
+ <div class="m-container">
|
|
|
+ <h2>
|
|
|
+ <div class="squrt"></div>奖品设置
|
|
|
+ </h2>
|
|
|
+ <div class="newBand" v-permission="'luckDrawPrize/add'" @click="onOperationTrophy('create')">添加</div>
|
|
|
+ <!-- 搜索标题 -->
|
|
|
+ <el-form :inline="true"
|
|
|
+ class="searchForm"
|
|
|
+ v-model.trim="searchForm">
|
|
|
+ <el-form-item>
|
|
|
+ <el-input v-model.trim="searchForm.search"
|
|
|
+ placeholder="请输入奖品名称"></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item>
|
|
|
+ <el-select v-model.trim="searchForm.groupId"
|
|
|
+ style="width: 100% !important"
|
|
|
+ placeholder="请选择所属活动">
|
|
|
+ <el-option value="reg" label="未缴费"></el-option>
|
|
|
+ <el-option value="pay" label="已缴费"></el-option>
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item>
|
|
|
+ <el-button @click="getList"
|
|
|
+ type="danger">搜索</el-button>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ <!-- 列表 -->
|
|
|
+ <div class="tableWrap">
|
|
|
+ <el-table :data="tableList"
|
|
|
+ :header-cell-style="{background:'#EDEEF0',color:'#444'}">
|
|
|
+ <el-table-column align="center"
|
|
|
+ prop="name"
|
|
|
+ label="奖品名称"></el-table-column>
|
|
|
+ <el-table-column align="center"
|
|
|
+ prop="groupName"
|
|
|
+ label="所属活动"></el-table-column>
|
|
|
+ <el-table-column align="center"
|
|
|
+ prop="chances"
|
|
|
+ label="中奖概率">
|
|
|
+ <template slot-scope="scope">
|
|
|
+ {{ scope.row.chances }}%
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column align="center"
|
|
|
+ prop="stock"
|
|
|
+ label="库存"></el-table-column>
|
|
|
+ <el-table-column align="center"
|
|
|
+ prop="enabled"
|
|
|
+ label="是否启用">
|
|
|
+ <template slot-scope="scope">
|
|
|
+ {{ scope.row.enabled ? '启用' : '不启用' }}
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column align="center"
|
|
|
+ prop="rewardType"
|
|
|
+ label="奖品类型"></el-table-column>
|
|
|
+ <el-table-column align="center"
|
|
|
+ prop="memo"
|
|
|
+ label="备注">
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <tool-tip :content="scope.row.memo" />
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column align="center" label="操作">
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <el-button @click="onOperationTrophy(scope.row)" v-permission="'luckDrawPrize/update'" type="text">修改</el-button>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
+ <pagination :total="pageInfo.total"
|
|
|
+ :page.sync="pageInfo.page"
|
|
|
+ :limit.sync="pageInfo.limit"
|
|
|
+ :page-sizes="pageInfo.page_size"
|
|
|
+ @pagination="getList" />
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <el-dialog :title="formTitle[formActionTitle]"
|
|
|
+ :visible.sync="lotteryStatus"
|
|
|
+ @close="onFormClose('ruleForm')"
|
|
|
+ width="500px">
|
|
|
+ <el-form :model="form"
|
|
|
+ :rules="rules"
|
|
|
+ label-width="100PX"
|
|
|
+ ref="ruleForm">
|
|
|
+ <el-form-item label="奖品名称"
|
|
|
+ prop="name">
|
|
|
+ <el-input v-model.trim="form.name"
|
|
|
+ autocomplete="off"
|
|
|
+ placeholder="请输入奖品名称"></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="所属活动" prop="groupId">
|
|
|
+ <el-select v-model.trim="form.groupId"
|
|
|
+ style="width: 100% !important"
|
|
|
+ placeholder="请选择所属活动">
|
|
|
+ <el-option value="reg" label="未缴费"></el-option>
|
|
|
+ <el-option value="pay" label="已缴费"></el-option>
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="中奖概率"
|
|
|
+ prop="chances">
|
|
|
+ <el-input v-model.trim="form.chances"
|
|
|
+ type="number"
|
|
|
+ autocomplete="off"
|
|
|
+ placeholder="请输入中奖概率">
|
|
|
+ <template slot="append">%</template>
|
|
|
+ </el-input>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="库存"
|
|
|
+ prop="stock">
|
|
|
+ <el-input v-model.trim="form.stock"
|
|
|
+ type="number"
|
|
|
+ autocomplete="off"
|
|
|
+ placeholder="请输入库存">
|
|
|
+ </el-input>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="备注"
|
|
|
+ prop="memo">
|
|
|
+ <el-input type="textarea" :rows="2" v-model.trim="form.memo"
|
|
|
+ autocomplete="off"
|
|
|
+ placeholder="请输入备注"></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ <span slot="footer"
|
|
|
+ class="dialog-footer">
|
|
|
+ <el-button @click="lotteryStatus = false">取 消</el-button>
|
|
|
+ <el-button type="primary" @click="onSubmit('ruleForm')">确 定</el-button>
|
|
|
+ </span>
|
|
|
+ </el-dialog>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+import Tooltip from '@/components/Tooltip/index'
|
|
|
+import pagination from "@/components/Pagination/index";
|
|
|
+import dayjs from 'dayjs';
|
|
|
+import cleanDeep from 'clean-deep';
|
|
|
+import { luckDrawPrizeList, luckDrawPrizeAdd, luckDrawPrizeUpdate } from './api'
|
|
|
+export default {
|
|
|
+ components: { pagination, Tooltip, },
|
|
|
+ data () {
|
|
|
+ return {
|
|
|
+ searchForm: {
|
|
|
+ search: null,
|
|
|
+ groupId: null,
|
|
|
+ enabled: null
|
|
|
+ },
|
|
|
+ formTitle: {
|
|
|
+ create: "添加奖品",
|
|
|
+ update: "修改奖品"
|
|
|
+ },
|
|
|
+ formActionTitle: 'create',
|
|
|
+ lotteryStatus: false,
|
|
|
+ tableList: [],
|
|
|
+ form: {
|
|
|
+ name: null,
|
|
|
+ groupId: null,
|
|
|
+ chances: null,
|
|
|
+ stock: null,
|
|
|
+ memo: null
|
|
|
+ },
|
|
|
+ rules: {
|
|
|
+ name: [{required: true, message:'请输入活动名称', trigger: 'blur'}],
|
|
|
+ groupId: [{required: true, message:'请选择所属活动', trigger: 'change'}],
|
|
|
+ chances: [{required: true, message:'请输入中奖概率', trigger: 'blur'}],
|
|
|
+ stock: [{required: true, message:'请输入库存', trigger: 'blur'}],
|
|
|
+ enabled: [{required: true, message:'请选择是否启用', trigger: 'change'}]
|
|
|
+ },
|
|
|
+ pageInfo: {
|
|
|
+ // 分页规则
|
|
|
+ limit: 10, // 限制显示条数
|
|
|
+ page: 1, // 当前页
|
|
|
+ total: 1, // 总条数
|
|
|
+ page_size: [10, 20, 40, 50] // 选择限制显示条数
|
|
|
+ }
|
|
|
+ };
|
|
|
+ },
|
|
|
+ //生命周期 - 创建完成(可以访问当前this实例)
|
|
|
+ created () {
|
|
|
+ // 设置默认为当前周
|
|
|
+ },
|
|
|
+ //生命周期 - 挂载完成(可以访问DOM元素)
|
|
|
+ mounted () {
|
|
|
+ this.getList()
|
|
|
+ },
|
|
|
+ activated () {
|
|
|
+ // this.getList()
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ onOperationTrophy(type, data) {
|
|
|
+ this.formActionTitle = type
|
|
|
+
|
|
|
+ this.lotteryStatus = true
|
|
|
+ },
|
|
|
+ onSubmit(formName) {
|
|
|
+ this.$refs[formName].validate(item => {
|
|
|
+ if(item) {
|
|
|
+ console.log(this.form)
|
|
|
+ let form = Object.assign({}, this.form)
|
|
|
+ let params = {
|
|
|
+ name: form.name,
|
|
|
+ groupId: form.groupId,
|
|
|
+ chances: form.chances,
|
|
|
+ stock: form.stock,
|
|
|
+ memo: form.memo,
|
|
|
+ enabled: 1
|
|
|
+ }
|
|
|
+ if(this.formActionTitle == 'create') {
|
|
|
+ luckDrawPrizeAdd(params).then(res => {
|
|
|
+ this.messageTips('添加', res)
|
|
|
+ })
|
|
|
+ } else if(this.formActionTitle == 'update') {
|
|
|
+ params.id = form.id
|
|
|
+ luckDrawPrizeUpdate(params).then(res => {
|
|
|
+ this.messageTips('修改', res)
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ messageTips (title, res) {
|
|
|
+ if (res.code == 200) {
|
|
|
+ this.$message.success(title + '成功')
|
|
|
+ this.branchStatus = false
|
|
|
+ this.getList()
|
|
|
+ } else {
|
|
|
+ this.$message.error(res.msg)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ getList() {
|
|
|
+ let params = Object.assign({}, this.searchForm)
|
|
|
+ params.rows = this.pageInfo.limit
|
|
|
+ params.page = this.pageInfo.page
|
|
|
+ luckDrawPrizeList(cleanDeep(params)).then(res => {
|
|
|
+ if (res.code == 200 && res.data) {
|
|
|
+ this.tableList = res.data.rows
|
|
|
+ this.pageInfo.total = res.data.total
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+};
|
|
|
+</script>
|
|
|
+<style lang='scss' scoped>
|
|
|
+.micon {
|
|
|
+ position: absolute;
|
|
|
+ top: 3px;
|
|
|
+ right: 2px;
|
|
|
+}
|
|
|
+</style>
|