sunlupeng 1 year ago
parent
commit
c884bc9a0c

+ 75 - 0
src/api/raffleManage.js

@@ -0,0 +1,75 @@
+import request from '@/utils/request'
+
+export function createItem(data) {
+  return request({
+    url: '/mall-pool-type/add',
+    method: 'post',
+    data
+  })
+}
+
+export function updateItem(data) {
+  return request({
+    url: '/mall-pool-type/edit',
+    method: 'post',
+    data
+  })
+}
+
+export function list(query) {
+  return request({
+    url: '/mall-pool-type/list',
+    method: 'get',
+    params:query
+  })
+}
+
+export function deleteitem(query) {
+  return request({
+    url: '/mall-pool-type/remove',
+    method: 'post',
+    params:query
+  })
+}
+
+export function optionSelect(data) {
+  return request({
+    url: '/mall-pool-type/optionselect',
+    method: 'get',
+    data
+  })
+}
+export function dataList(query) {
+  return request({
+    url: '/mall-pool-data/list',
+    method: 'get',
+    params:query
+  })
+}
+export function dataAdd(data) {
+  return request({
+    url: '/mall-pool-data/add',
+    method: 'post',
+    data
+  })
+}
+export function dataEdit(data) {
+  return request({
+    url: '/mall-pool-data/edit',
+    method: 'post',
+    data
+  })
+}
+export function dataRemove(query) {
+  return request({
+    url: '/mall-pool-data/remove',
+    method: 'post',
+    params:query
+  })
+}
+
+
+
+
+
+

+ 4 - 1
src/permission.js

@@ -42,7 +42,10 @@ const myRoles = [
   'activityManage', 
   'answerGame', 
   'answerList', 
-  'noticeList', 
+  'answerGame', 
+  'raffleManage', 
+  'raffleList', 
+  'raffleDataList', 
   'ranking',
   'rankingList',
   'medalManage', 

+ 14 - 0
src/router/index.js

@@ -195,6 +195,20 @@ export const asyncRouterMap = [
       { path: 'medalDataList/:id', component: _import('medalManage/medalDataList'), name: 'medalDataList', meta: { title: '勋章等级列表', noCache: false, hideTag: true, hidden: true }},
     ]
   },
+  {
+    path: '/raffleManage',
+    component: Layout,
+    redirect: 'noredirect',
+    name: 'raffleManage',
+    meta: {
+      title: '抽奖管理',
+      icon: 'huodong'
+    },
+    children: [
+      { path: 'raffleList', component: _import('raffleManage/raffleList'), name: 'raffleList', meta: { title: '奖池列表', noCache: true }},
+      { path: 'raffleDataList/:id', component: _import('raffleManage/raffleDataList'), name: 'raffleDataList', meta: { title: '奖池奖品', noCache: false, hideTag: true, hidden: true }},
+    ]
+  },
   {
     path: '/commendManage',
     component: Layout,

+ 370 - 0
src/views/raffleManage/raffleDataList.vue

@@ -0,0 +1,370 @@
+<template>
+    <div class="app-container calendar-list-container">
+
+        <!-- 查询和其他操作 -->
+        <div class="filter-container">
+            <el-select @change="changepoolId" v-model="listQuery.poolId" placeholder="奖池" class="filter-item" style="width: 200px">
+                <el-option :key="item.id" v-for="item in dictNameList" :label="item.title" :value="item.id">
+                </el-option>
+            </el-select>
+            <el-button class="filter-item" type="primary" v-waves icon="el-icon-search" @click="handleFilter">查找</el-button>
+            <el-button class="filter-item" type="primary" @click="handleCreate" icon="el-icon-edit">添加</el-button>
+            <el-button class="filter-item" type="warning" icon="el-icon-delete" @click="delAll">批量删除</el-button>
+
+        </div>
+
+        <!-- 查询结果 -->
+        <el-table size="small" :data="list" v-loading="listLoading" @selection-change="handleSelectionChange"
+            element-loading-text="正在查询中。。。" border fit highlight-current-row>
+            <el-table-column type="selection" width="55px"> </el-table-column>
+            <el-table-column align="center" min-width="100px" label="奖品类型" prop="prizeTypeName">
+            </el-table-column>
+            <el-table-column align="center" min-width="150px" label="奖品名称" prop="prizeName">
+            </el-table-column>
+            <el-table-column align="center" min-width="150px" label="关联商品" prop="skuId">
+            </el-table-column>
+            <el-table-column align="center" min-width="100px" label="积分" prop="integral">
+            </el-table-column>
+            <el-table-column align="center" min-width="100px" label="奖品权重" prop="prizeWeight">
+            </el-table-column>
+            <el-table-column align="center" min-width="100px" label="奖品数量" prop="prizeActualStock">
+            </el-table-column>
+            <el-table-column align="center" min-width="100px" label="剩余数量" prop="prizeStock">
+            </el-table-column>
+            <el-table-column align="center" min-width="100px" label="状态">
+            <template slot-scope="scope">
+                <span v-if="scope.row.status == '0'">正常</span>
+                <span v-else>停用</span>
+            </template>
+        </el-table-column>
+        <el-table-column align="center" min-width="100px" label="创建时间" prop="createTime">
+        </el-table-column>
+            <el-table-column align="center" label="操作" width="240px" class-name="small-padding fixed-width">
+                <template slot-scope="scope">
+                    <el-button type="primary" size="small" @click="handleUpdate(scope.row, false)">编辑</el-button>
+
+                    <el-button type="danger" size="mini" @click="handleDelete(scope.row)">删除</el-button>
+                </template>
+            </el-table-column>
+        </el-table>
+
+        <!-- 分页 -->
+        <div class="pagination-container">
+            <el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange"
+                :current-page="listQuery.page" :page-sizes="[10, 20, 30, 50]" :page-size="listQuery.limit"
+                layout="total, sizes, prev, pager, next, jumper" :total="total">
+            </el-pagination>
+        </div>
+
+        <!-- 添加或修改对话框 -->
+        <el-dialog
+        :close-on-click-modal="false"
+        :title="textMap[dialogStatus]"
+        :visible.sync="dialogFormVisible"
+        width="40%"
+      >
+        <el-form :rules="rules" ref="dataForm" :model="dataForm" status-icon label-position="left" label-width="80px" style='width: 700px; margin-left:50px;'>
+            <el-form-item  label="字典类型" prop="poolId">
+              <el-input disabled style="width: 300px" v-model="dataForm.poolId"></el-input>
+            </el-form-item>
+            <el-form-item  label="字典标签" prop="dictLabel">
+              <el-input style="width: 300px" v-model="dataForm.dictLabel"></el-input>
+            </el-form-item>
+            <el-form-item  label="字典键值" prop="dictValue">
+              <el-input style="width: 300px" v-model="dataForm.dictValue"></el-input>
+            </el-form-item>
+            <el-form-item label="显示排序" prop="dictSort">
+                <el-input-number
+                  :precision="0"
+                  :step="1"
+                  v-model="dataForm.dictSort"
+                ></el-input-number>
+              </el-form-item>
+            <el-form-item  label="状态">
+                <el-radio-group v-model="dataForm.status">
+                    <el-radio :label="'0'">正常</el-radio>
+                    <el-radio :label="'1'">停用</el-radio>
+                </el-radio-group>
+            </el-form-item>
+            
+            
+        </el-form>
+        <div slot="footer" class="dialog-footer">
+          <el-button @click="dialogFormVisible = false">取消</el-button>
+          <el-button v-if="dialogStatus == 'create'" type="primary" @click="createData">确定</el-button>
+          <el-button v-else type="primary" @click="updateData">确定</el-button>
+        </div>
+      </el-dialog>
+
+    </div>
+</template>
+  
+<style>
+.demo-table-expand {
+    font-size: 0;
+}
+
+.demo-table-expand label {
+    width: 200px;
+    color: #99a9bf;
+}
+
+.demo-table-expand .el-form-item {
+    margin-right: 0;
+    margin-bottom: 0;
+}
+</style>
+  
+<script>
+import { dataList, dataAdd, dataEdit, dataRemove, optionSelect } from "@/api/raffleManage";
+import waves from "@/directive/waves"; // 水波纹指令
+import Tinymce from '@/components/Tinymce'
+
+export default {
+    components: { Tinymce },
+    directives: { waves },
+    data() {
+        return {
+            poolId:'',
+            dictNameList: [],
+            typeList: [
+                {
+                    type: '0',
+                    name: "正常",
+                },
+                {
+                    type: '1',
+                    name: "停用",
+                },
+            ],
+            list: [
+            ],
+            delarr: [],
+            multipleSelection: [],
+            total: 0,
+            listLoading: false,
+            listQuery: {
+                page: 1,
+                limit: 10,
+                poolId: '',
+            },
+            dataForm: {
+                poolId: undefined,
+                dictLabel: undefined,
+                dictValue: undefined,
+                dictSort: undefined,
+                status: '0',
+            },
+            dialogFormVisible: false,
+            dialogStatus: '',
+            textMap: {
+                update: "编辑",
+                create: "创建",
+            },
+            imageUrl: undefined,
+            rules: {
+                dictLabel: [{ required: true, message: "字典标签不能为空", trigger: "blur" }],
+                dictValue: [{ required: true, message: "字典键值不能为空", trigger: "blur" }],
+                dictSort: [{ required: true, message: "显示排序不能为空", trigger: "blur" }],
+            },
+        }
+    },
+    created() {
+        this.poolId = this.$route.params.id;
+        this.getOptionSelect();
+    },
+    methods: {
+        changepoolId(val){
+            this.poolId = val;
+            this.listQuery.poolId = val;
+            this.getList();
+        },
+        getOptionSelect(){
+            optionSelect().then(response => {
+                this.dictNameList = response.data.data;
+                this.listQuery.poolId = this.poolId;
+                this.getList();
+            }).catch(() => {})
+        },
+        resetForm() {
+            this.dataForm = {
+                poolId: undefined,
+                dictLabel: undefined,
+                dictValue: undefined,
+                dictSort: undefined,
+                status: '0',
+            };
+        },
+        handleCreate() {
+            this.resetForm();
+            this.dataForm.poolId = this.poolId;
+            this.dialogFormVisible = true;
+            this.dialogStatus = "create";
+            this.$nextTick(() => {
+                this.$refs["dataForm"].clearValidate();
+            });
+        },
+        createData() {
+            this.$refs["dataForm"].validate((valid) => {
+                if (valid) {
+                    dataAdd(this.dataForm)
+                        .then(() => {
+                            this.getList();
+                            this.dialogFormVisible = false;
+
+                            this.$notify({
+                                title: "成功",
+                                message: "创建成功",
+                                type: "success",
+                                duration: 2000,
+                            });
+                            this.getList()
+                        })
+                }
+            });
+        },
+        getList() {
+            this.listLoading = true
+            dataList(this.listQuery).then(response => {
+                this.list = response.data.data.items
+                this.total = response.data.data.total
+                this.listLoading = false
+            }).catch(() => {
+                this.list = []
+                this.total = 0
+                this.listLoading = false
+            })
+        },
+
+        handleFilter() {
+            this.listQuery.page = 1
+            this.getList()
+        },
+
+        handleSizeChange(val) {
+            this.listQuery.limit = val
+            this.getList()
+        },
+
+        handleCurrentChange(val) {
+            this.listQuery.page = val
+            this.getList()
+        },
+
+        handleUpdate(row) {
+            this.dataForm = Object.assign({}, row);
+            this.dialogStatus = 'update'
+            this.dialogFormVisible = true
+            this.$nextTick(() => {
+                this.$refs['dataForm'].clearValidate()
+            })
+        },
+
+        updateData() {
+            this.$refs['dataForm'].validate((valid) => {
+                if (valid) {
+                    dataEdit(this.dataForm).then(() => {
+                        this.dialogFormVisible = false
+                        this.$notify({
+                            title: '成功',
+                            message: '更新成功',
+                            type: 'success',
+                            duration: 2000
+                        })
+                        this.getList()
+                    })
+
+                }
+            })
+        },
+
+        handleDelete(row) {
+
+            this.$confirm('确认删除吗?', '提示', {
+                confirmButtonText: '确定',
+                cancelButtonText: '取消',
+                type: 'warning'
+            }).then(() => {
+                dataRemove({ dictCodes:row.dictCode}).then(response => {
+                    this.$notify({
+                        title: '成功',
+                        message: '删除成功',
+                        type: 'success',
+                        duration: 2000
+                    })
+                    const index = this.list.indexOf(row)
+                    this.list.splice(index, 1)
+                })
+            }).catch(() => {
+
+            })
+
+        },
+        delAll() {
+            this.$confirm("确认删除吗?", "提示", {
+                confirmButtonText: "确定",
+                cancelButtonText: "取消",
+                type: "warning",
+            })
+                .then(() => {
+                    const length = this.multipleSelection.length;
+
+                    if (length > 0) {
+                        for (let i = 0; i < length; i++) {
+                            this.delarr.push(this.multipleSelection[i].dictCode);
+                        }
+                        const  dictCodes = this.delarr.join(",");
+                        dataRemove({  dictCodes:  dictCodes })
+                            .then(() => {
+                                this.$notify({
+                                    title: "成功",
+                                    message: "删除成功",
+                                    type: "success",
+                                    duration: 2000,
+                                });
+                                this.getList();
+                            })
+                            .catch(() => { });
+                    } else {
+                        this.$notify({
+                            title: "警告提示",
+                            message: "请选择要删除的信息!",
+                            type: "warning",
+                        });
+                    }
+                })
+                .catch(() => { });
+        },
+        handleSelectionChange(val) {
+            this.multipleSelection = val;
+        },
+    }
+}
+</script>
+<style>
+.ad-avatar-uploader .el-upload {
+    border: 1px dashed #d9d9d9;
+    border-radius: 6px;
+    cursor: pointer;
+    position: relative;
+    overflow: hidden;
+}
+
+.ad-avatar-uploader .el-upload:hover {
+    border-color: #409EFF;
+}
+
+.ad-avatar-uploader-icon {
+    font-size: 28px;
+    color: #8c939d;
+    width: 178px;
+    height: 178px;
+    line-height: 178px;
+    text-align: center;
+}
+
+.ad-avatar {
+    display: block;
+}
+</style>
+  

+ 347 - 0
src/views/raffleManage/raffleList.vue

@@ -0,0 +1,347 @@
+<template>
+  <div class="app-container calendar-list-container">
+
+    <!-- 查询和其他操作 -->
+    <div class="filter-container">
+      <el-input clearable class="filter-item" style="width: 200px;" placeholder="请输入奖池名称" v-model="listQuery.title"></el-input>
+      <el-select v-model="listQuery.status" clearable placeholder="状态" class="filter-item" style="width: 200px">
+          <el-option :key="item.type" v-for="item in typeList" :label="item.name" :value="item.type">
+          </el-option>
+      </el-select>
+      <el-button class="filter-item" type="primary" v-waves icon="el-icon-search" @click="handleFilter">查找</el-button>
+      <el-button class="filter-item" type="primary" @click="handleCreate" icon="el-icon-edit">添加</el-button>
+      <el-button class="filter-item" type="warning" icon="el-icon-delete" @click="delAll">批量删除</el-button>
+    </div>
+
+    <!-- 查询结果 -->
+    <el-table
+      size="small"
+      :data="list"
+      @selection-change="handleSelectionChange"
+      v-loading="listLoading"
+      element-loading-text="正在查询中。。。"
+      border
+      fit
+      highlight-current-row
+    >
+      <el-table-column type="selection" width="55px"> </el-table-column>
+      <el-table-column type="index" label="序号" header-align="center" align="center">
+      </el-table-column>
+
+      <el-table-column align="center" min-width="100px" label="奖池名称">
+        <template slot-scope="scope">
+              <router-link :to="{name: 'raffleDataList', params: { id: scope.row.id }}">
+                  <div style="color: #337ab7;cursor: pointer;">{{ scope.row.title }}</div>
+              </router-link>
+          </template>
+      </el-table-column>
+      <el-table-column align="center" min-width="100px" label="状态">
+            <template slot-scope="scope">
+                <span v-if="scope.row.status === '1'">停用</span>
+                <span v-else>正常</span>
+            </template>
+            
+        </el-table-column>
+      <el-table-column align="center" min-width="200px" label="备注" prop="content">
+      </el-table-column>
+      <el-table-column align="center" min-width="150px" label="创建时间" prop="createTime">
+      </el-table-column>
+      <el-table-column align="center" label="操作" width="240px" class-name="small-padding fixed-width">
+        <template slot-scope="scope">
+          <el-button
+            type="primary"
+            size="small"
+            @click="handleUpdate(scope.row, false)"
+            >编辑</el-button
+          >
+
+          <el-button type="danger" size="mini"  @click="handleDelete(scope.row)">删除</el-button>
+        </template>
+      </el-table-column>
+    </el-table>
+
+    <!-- 分页 -->
+    <div class="pagination-container">
+      <el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="listQuery.page"
+        :page-sizes="[10,20,30,50]" :page-size="listQuery.limit" layout="total, sizes, prev, pager, next, jumper" :total="total">
+      </el-pagination>
+    </div>
+
+    <!-- 添加或修改对话框 -->
+    <el-dialog
+    :close-on-click-modal="false"
+      :title="textMap[dialogStatus]"
+      :visible.sync="dialogFormVisible"
+      width="40%"
+    >
+      <el-form :rules="rules" ref="dataForm" :model="dataForm" status-icon label-position="left" label-width="80px" style='width: 700px; margin-left:50px;'>
+          <el-form-item  label="奖池名称" prop="title">
+            <el-input style="width: 300px" v-model="dataForm.title"></el-input>
+          </el-form-item>
+          <el-form-item  label="状态">
+              <el-radio-group v-model="dataForm.status">
+                  <el-radio :label="'0'">正常</el-radio>
+                  <el-radio :label="'1'">停用</el-radio>
+              </el-radio-group>
+          </el-form-item>
+          <el-form-item  label="备注">
+            <el-input type="textarea" :rows="2" style="width: 300px" v-model="dataForm.content"></el-input>
+          </el-form-item>
+          
+          
+      </el-form>
+      <div slot="footer" class="dialog-footer">
+        <el-button @click="dialogFormVisible = false">取消</el-button>
+        <el-button v-if="dialogStatus == 'create'" type="primary" @click="createData">确定</el-button>
+        <el-button v-else type="primary" @click="updateData">确定</el-button>
+      </div>
+    </el-dialog>
+
+  </div>
+</template>
+
+<style>
+  .demo-table-expand {
+    font-size: 0;
+  }
+  .demo-table-expand label {
+    width: 200px;
+    color: #99a9bf;
+  }
+  .demo-table-expand .el-form-item {
+    margin-right: 0;
+    margin-bottom: 0;
+  }
+</style>
+
+<script>
+  import { list, createItem, updateItem, deleteitem } from "@/api/raffleManage";
+  import waves from "@/directive/waves"; // 水波纹指令
+  import Tinymce from '@/components/Tinymce'
+
+export default {
+  components: { Tinymce },
+  directives: { waves },
+  data() {
+    return {
+      typeList: [
+      {
+        type: "0",
+        name: "正常",
+      },
+      {
+        type: "1",
+        name: "停用",
+      },
+    ],
+      list: [
+        
+      ],
+      delarr: [],
+      multipleSelection: [],
+      total: 0,
+      listLoading: false,
+      listQuery: {
+        page: 1,
+        limit: 10,
+        title: '',
+        status: '',
+      },
+      dataForm: {
+        title: undefined,
+        status: '1',
+        content: undefined,
+      },
+      dialogFormVisible: false,
+      dialogStatus: '',
+      textMap: {
+        update: "编辑",
+        create: "创建",
+      },
+      imageUrl: undefined,
+      rules: {
+        title: [{ required: true, message: "字典名称不能为空", trigger: "blur" }],
+      },
+    }
+  },
+  created() {
+      this.getList();
+  },
+  methods: {
+      handleDictData(row){
+
+      },
+    resetForm() {
+      this.dataForm = {
+          title: undefined,
+          status: '1',
+          content: undefined,
+      };
+    },
+    handleCreate() {
+      this.resetForm();
+      this.dialogFormVisible = true;
+      this.dialogStatus = "create";
+      this.$nextTick(() => {
+        this.$refs["dataForm"].clearValidate();
+      });
+    },
+    createData() {
+      this.$refs["dataForm"].validate((valid) => {
+        if (valid) {
+          createItem(this.dataForm)
+                .then(() => {
+                  this.getList();
+                  this.dialogFormVisible = false;
+
+                  this.$notify({
+                    title: "成功",
+                    message: "创建成功",
+                    type: "success",
+                    duration: 2000,
+                  });
+                  this.getList()
+                })
+        }
+      });
+    },
+    getList() {
+      this.listLoading = true
+      list(this.listQuery).then(response => {
+        this.list = response.data.data.items
+        this.total = response.data.data.total
+        this.listLoading = false
+      }).catch(() => {
+        this.list = []
+        this.total = 0
+        this.listLoading = false
+      })
+    },
+
+    handleFilter() {
+      this.listQuery.page = 1
+      this.getList()
+    },
+
+    handleSizeChange(val) {
+      this.listQuery.limit = val
+      this.getList()
+    },
+
+    handleCurrentChange(val) {
+      this.listQuery.page = val
+      this.getList()
+    },
+
+    handleUpdate(row) {
+      this.dataForm = Object.assign({}, row);
+      this.dialogStatus = 'update'
+      this.dialogFormVisible = true
+      this.$nextTick(() => {
+        this.$refs['dataForm'].clearValidate()
+      })
+    },
+
+    updateData() {
+      this.$refs['dataForm'].validate((valid) => {
+        if (valid) {
+          updateItem(this.dataForm).then(() => {
+              this.dialogFormVisible = false
+              this.$notify({
+                title: '成功',
+                message: '更新成功',
+                type: 'success',
+                duration: 2000
+              })
+              this.getList()
+            })
+          
+        }
+      })
+    },
+
+    handleDelete(row) {
+
+      this.$confirm('确认删除吗?', '提示', {
+        confirmButtonText: '确定',
+        cancelButtonText: '取消',
+        type: 'warning'
+      }).then(() => {
+        deleteitem({dictIds:row.dictId}).then(response => {
+          this.$notify({
+            title: '成功',
+            message: '删除成功',
+            type: 'success',
+            duration: 2000
+          })
+          this.getList()
+        })
+      }).catch(() => {
+
+      })
+
+    },
+    delAll() {
+          this.$confirm("确认删除吗?", "提示", {
+              confirmButtonText: "确定",
+              cancelButtonText: "取消",
+              type: "warning",
+          })
+              .then(() => {
+                  const length = this.multipleSelection.length;
+
+                  if (length > 0) {
+                      for (let i = 0; i < length; i++) {
+                          this.delarr.push(this.multipleSelection[i].dictId);
+                      }
+                      const dictIds = this.delarr.join(",");
+                      deleteitem({ dictIds: dictIds })
+                          .then(() => {
+                              this.$notify({
+                                  title: "成功",
+                                  message: "删除成功",
+                                  type: "success",
+                                  duration: 2000,
+                              });
+                              this.getList();
+                          })
+                          .catch(() => { });
+                  } else {
+                      this.$notify({
+                          title: "警告提示",
+                          message: "请选择要删除的信息!",
+                          type: "warning",
+                      });
+                  }
+              })
+              .catch(() => { });
+      },
+      handleSelectionChange(val) {
+          this.multipleSelection = val;
+      },
+  }
+}
+</script>
+<style>
+  .ad-avatar-uploader .el-upload {
+    border: 1px dashed #d9d9d9;
+    border-radius: 6px;
+    cursor: pointer;
+    position: relative;
+    overflow: hidden;
+  }
+  .ad-avatar-uploader .el-upload:hover {
+    border-color: #409EFF;
+  }
+  .ad-avatar-uploader-icon {
+    font-size: 28px;
+    color: #8c939d;
+    width: 178px;
+    height: 178px;
+    line-height: 178px;
+    text-align: center;
+  }
+  .ad-avatar {
+    display: block;
+  }
+</style>