活动管理
This commit is contained in:
parent
a423661c5e
commit
ce3627ce11
@ -0,0 +1,119 @@
|
|||||||
|
package com.ruoyi.winery.controller;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PutMapping;
|
||||||
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
import com.ruoyi.common.annotation.Log;
|
||||||
|
import com.ruoyi.common.core.controller.BaseController;
|
||||||
|
import com.ruoyi.common.core.domain.AjaxResult;
|
||||||
|
import com.ruoyi.common.enums.BusinessType;
|
||||||
|
import com.ruoyi.winery.domain.AppActivity;
|
||||||
|
import com.ruoyi.winery.service.IAppActivityService;
|
||||||
|
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||||
|
import com.ruoyi.common.core.page.TableDataInfo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 活动Controller
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
* @date 2021-01-20
|
||||||
|
*/
|
||||||
|
@RequiredArgsConstructor(onConstructor_ = @Autowired)
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/winery/activity" )
|
||||||
|
public class AppActivityController extends BaseController {
|
||||||
|
|
||||||
|
private final IAppActivityService iAppActivityService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询活动列表
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('winery:activity:list')")
|
||||||
|
@GetMapping("/list")
|
||||||
|
public TableDataInfo list(AppActivity appActivity)
|
||||||
|
{
|
||||||
|
startPage();
|
||||||
|
LambdaQueryWrapper<AppActivity> lqw = Wrappers.lambdaQuery(appActivity);
|
||||||
|
if (StringUtils.isNotBlank(appActivity.getUrl())){
|
||||||
|
lqw.eq(AppActivity::getUrl ,appActivity.getUrl());
|
||||||
|
}
|
||||||
|
if (appActivity.getType() != null){
|
||||||
|
lqw.eq(AppActivity::getType ,appActivity.getType());
|
||||||
|
}
|
||||||
|
if (StringUtils.isNotBlank(appActivity.getImage())){
|
||||||
|
lqw.eq(AppActivity::getImage ,appActivity.getImage());
|
||||||
|
}
|
||||||
|
if (appActivity.getImageHeight() != null){
|
||||||
|
lqw.eq(AppActivity::getImageHeight ,appActivity.getImageHeight());
|
||||||
|
}
|
||||||
|
List<AppActivity> list = iAppActivityService.list(lqw);
|
||||||
|
return getDataTable(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出活动列表
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('winery:activity:export')" )
|
||||||
|
@Log(title = "活动" , businessType = BusinessType.EXPORT)
|
||||||
|
@GetMapping("/export" )
|
||||||
|
public AjaxResult export(AppActivity appActivity) {
|
||||||
|
LambdaQueryWrapper<AppActivity> lqw = new LambdaQueryWrapper<AppActivity>(appActivity);
|
||||||
|
List<AppActivity> list = iAppActivityService.list(lqw);
|
||||||
|
ExcelUtil<AppActivity> util = new ExcelUtil<AppActivity>(AppActivity. class);
|
||||||
|
return util.exportExcel(list, "activity" );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取活动详细信息
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('winery:activity:query')" )
|
||||||
|
@GetMapping(value = "/{id}" )
|
||||||
|
public AjaxResult getInfo(@PathVariable("id" ) Long id) {
|
||||||
|
return AjaxResult.success(iAppActivityService.getById(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增活动
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('winery:activity:add')" )
|
||||||
|
@Log(title = "活动" , businessType = BusinessType.INSERT)
|
||||||
|
@PostMapping
|
||||||
|
public AjaxResult add(@RequestBody AppActivity appActivity) {
|
||||||
|
return toAjax(iAppActivityService.save(appActivity) ? 1 : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改活动
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('winery:activity:edit')" )
|
||||||
|
@Log(title = "活动" , businessType = BusinessType.UPDATE)
|
||||||
|
@PutMapping
|
||||||
|
public AjaxResult edit(@RequestBody AppActivity appActivity) {
|
||||||
|
return toAjax(iAppActivityService.updateById(appActivity) ? 1 : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除活动
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('winery:activity:remove')" )
|
||||||
|
@Log(title = "活动" , businessType = BusinessType.DELETE)
|
||||||
|
@DeleteMapping("/{ids}" )
|
||||||
|
public AjaxResult remove(@PathVariable Long[] ids) {
|
||||||
|
return toAjax(iAppActivityService.removeByIds(Arrays.asList(ids)) ? 1 : 0);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,66 @@
|
|||||||
|
package com.ruoyi.winery.domain;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.ToString;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
import com.ruoyi.common.annotation.Excel;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import com.ruoyi.common.core.domain.BaseEntity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 活动对象 app_activity
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
* @date 2021-01-20
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@ToString
|
||||||
|
@EqualsAndHashCode
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Accessors(chain = true)
|
||||||
|
@TableName("app_activity")
|
||||||
|
public class AppActivity implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID=1L;
|
||||||
|
|
||||||
|
|
||||||
|
/** ID */
|
||||||
|
@TableId(value = "id", type = IdType.ASSIGN_UUID)
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
/** 链接 */
|
||||||
|
@Excel(name = "链接")
|
||||||
|
private String url;
|
||||||
|
|
||||||
|
/** 1每日精选2热门活动 */
|
||||||
|
@Excel(name = "1每日精选2热门活动")
|
||||||
|
private Integer type;
|
||||||
|
|
||||||
|
/** 图片 */
|
||||||
|
@Excel(name = "图片")
|
||||||
|
private String image;
|
||||||
|
|
||||||
|
/** 高度 */
|
||||||
|
@Excel(name = "高度")
|
||||||
|
private Integer imageHeight;
|
||||||
|
|
||||||
|
/** 创建者 */
|
||||||
|
private String createBy;
|
||||||
|
|
||||||
|
/** 创建时间 */
|
||||||
|
private Date createTime;
|
||||||
|
|
||||||
|
/** 更新者 */
|
||||||
|
private String updateBy;
|
||||||
|
|
||||||
|
/** 更新时间 */
|
||||||
|
private Date updateTime;
|
||||||
|
}
|
@ -0,0 +1,14 @@
|
|||||||
|
package com.ruoyi.winery.mapper;
|
||||||
|
|
||||||
|
import com.ruoyi.winery.domain.AppActivity;
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 活动Mapper接口
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
* @date 2021-01-20
|
||||||
|
*/
|
||||||
|
public interface AppActivityMapper extends BaseMapper<AppActivity> {
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,14 @@
|
|||||||
|
package com.ruoyi.winery.service;
|
||||||
|
|
||||||
|
import com.ruoyi.winery.domain.AppActivity;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 活动Service接口
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
* @date 2021-01-20
|
||||||
|
*/
|
||||||
|
public interface IAppActivityService extends IService<AppActivity> {
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,18 @@
|
|||||||
|
package com.ruoyi.winery.service.impl;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.ruoyi.winery.mapper.AppActivityMapper;
|
||||||
|
import com.ruoyi.winery.domain.AppActivity;
|
||||||
|
import com.ruoyi.winery.service.IAppActivityService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 活动Service业务层处理
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
* @date 2021-01-20
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class AppActivityServiceImpl extends ServiceImpl<AppActivityMapper, AppActivity> implements IAppActivityService {
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,20 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<!DOCTYPE mapper
|
||||||
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.ruoyi.winery.mapper.AppActivityMapper">
|
||||||
|
|
||||||
|
<resultMap type="AppActivity" id="AppActivityResult">
|
||||||
|
<result property="id" column="id" />
|
||||||
|
<result property="url" column="url" />
|
||||||
|
<result property="type" column="type" />
|
||||||
|
<result property="image" column="image" />
|
||||||
|
<result property="imageHeight" column="image_height" />
|
||||||
|
<result property="createBy" column="create_by" />
|
||||||
|
<result property="createTime" column="create_time" />
|
||||||
|
<result property="updateBy" column="update_by" />
|
||||||
|
<result property="updateTime" column="update_time" />
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
|
||||||
|
</mapper>
|
53
ruoyi-ui/src/api/winery/activity.js
Normal file
53
ruoyi-ui/src/api/winery/activity.js
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
import request from '@/utils/request'
|
||||||
|
|
||||||
|
// 查询活动列表
|
||||||
|
export function listActivity(query) {
|
||||||
|
return request({
|
||||||
|
url: '/winery/activity/list',
|
||||||
|
method: 'get',
|
||||||
|
params: query
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 查询活动详细
|
||||||
|
export function getActivity(id) {
|
||||||
|
return request({
|
||||||
|
url: '/winery/activity/' + id,
|
||||||
|
method: 'get'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 新增活动
|
||||||
|
export function addActivity(data) {
|
||||||
|
return request({
|
||||||
|
url: '/winery/activity',
|
||||||
|
method: 'post',
|
||||||
|
data: data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 修改活动
|
||||||
|
export function updateActivity(data) {
|
||||||
|
return request({
|
||||||
|
url: '/winery/activity',
|
||||||
|
method: 'put',
|
||||||
|
data: data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除活动
|
||||||
|
export function delActivity(id) {
|
||||||
|
return request({
|
||||||
|
url: '/winery/activity/' + id,
|
||||||
|
method: 'delete'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 导出活动
|
||||||
|
export function exportActivity(query) {
|
||||||
|
return request({
|
||||||
|
url: '/winery/activity/export',
|
||||||
|
method: 'get',
|
||||||
|
params: query
|
||||||
|
})
|
||||||
|
}
|
328
ruoyi-ui/src/views/winery/activity/index.vue
Normal file
328
ruoyi-ui/src/views/winery/activity/index.vue
Normal file
@ -0,0 +1,328 @@
|
|||||||
|
<template>
|
||||||
|
<div class="app-container">
|
||||||
|
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
|
||||||
|
<el-form-item label="链接" prop="url">
|
||||||
|
<el-input
|
||||||
|
v-model="queryParams.url"
|
||||||
|
placeholder="请输入链接"
|
||||||
|
clearable
|
||||||
|
size="small"
|
||||||
|
@keyup.enter.native="handleQuery"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="活动类型" prop="type">
|
||||||
|
<el-select v-model="queryParams.type" placeholder="请选择活动类型" clearable size="small">
|
||||||
|
<el-option
|
||||||
|
v-for="dict in actTypeOptions"
|
||||||
|
:key="dict.dictValue"
|
||||||
|
:label="dict.dictLabel"
|
||||||
|
:value="dict.dictValue"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="高度" prop="imageHeight">
|
||||||
|
<el-input
|
||||||
|
v-model="queryParams.imageHeight"
|
||||||
|
placeholder="请输入高度"
|
||||||
|
clearable
|
||||||
|
size="small"
|
||||||
|
@keyup.enter.native="handleQuery"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item>
|
||||||
|
<el-button type="cyan" 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"
|
||||||
|
icon="el-icon-plus"
|
||||||
|
size="mini"
|
||||||
|
@click="handleAdd"
|
||||||
|
v-hasPermi="['winery:activity:add']"
|
||||||
|
>新增</el-button>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button
|
||||||
|
type="success"
|
||||||
|
icon="el-icon-edit"
|
||||||
|
size="mini"
|
||||||
|
:disabled="single"
|
||||||
|
@click="handleUpdate"
|
||||||
|
v-hasPermi="['winery:activity:edit']"
|
||||||
|
>修改</el-button>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button
|
||||||
|
type="danger"
|
||||||
|
icon="el-icon-delete"
|
||||||
|
size="mini"
|
||||||
|
:disabled="multiple"
|
||||||
|
@click="handleDelete"
|
||||||
|
v-hasPermi="['winery:activity:remove']"
|
||||||
|
>删除</el-button>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button
|
||||||
|
type="warning"
|
||||||
|
icon="el-icon-download"
|
||||||
|
size="mini"
|
||||||
|
@click="handleExport"
|
||||||
|
v-hasPermi="['winery:activity:export']"
|
||||||
|
>导出</el-button>
|
||||||
|
</el-col>
|
||||||
|
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||||
|
</el-row>
|
||||||
|
|
||||||
|
<el-table v-loading="loading" :data="activityList" @selection-change="handleSelectionChange">
|
||||||
|
<el-table-column type="selection" width="55" align="center" />
|
||||||
|
<el-table-column label="ID" align="center" prop="id" v-if="false"/>
|
||||||
|
<el-table-column label="链接" align="center" prop="url" />
|
||||||
|
<el-table-column label="活动类型" align="center" :formatter="actTypeFormat" prop="type" />
|
||||||
|
<el-table-column label="图片" align="center" prop="image">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<el-image :src="scope.row.image | getImageForKey"
|
||||||
|
style="width: 60px; height: 60px"/>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="高度" align="center" prop="imageHeight" />
|
||||||
|
<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="['winery:activity:edit']"
|
||||||
|
>修改</el-button>
|
||||||
|
<el-button
|
||||||
|
size="mini"
|
||||||
|
type="text"
|
||||||
|
icon="el-icon-delete"
|
||||||
|
@click="handleDelete(scope.row)"
|
||||||
|
v-hasPermi="['winery:activity: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="url">
|
||||||
|
<el-input v-model="form.url" placeholder="请输入链接" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="活动类型" prop="type">
|
||||||
|
<el-select v-model="form.type" placeholder="请选择活动类型" clearable size="small">
|
||||||
|
<el-option
|
||||||
|
v-for="dict in actTypeOptions"
|
||||||
|
:key="dict.dictValue"
|
||||||
|
:label="dict.dictLabel"
|
||||||
|
:value="dict.dictValue"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="图片">
|
||||||
|
<uploadImage v-model="form.image"/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="高度" prop="imageHeight">
|
||||||
|
<el-input v-model="form.imageHeight" 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 { listActivity, getActivity, delActivity, addActivity, updateActivity, exportActivity } from "@/api/winery/activity";
|
||||||
|
import UploadImage from '@/components/UploadImage';
|
||||||
|
import CommonMixin from "@/mixin/common";
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: "Activity",
|
||||||
|
components: {
|
||||||
|
UploadImage,
|
||||||
|
},
|
||||||
|
mixins: {
|
||||||
|
CommonMixin
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
// 遮罩层
|
||||||
|
loading: true,
|
||||||
|
// 选中数组
|
||||||
|
ids: [],
|
||||||
|
// 非单个禁用
|
||||||
|
single: true,
|
||||||
|
// 非多个禁用
|
||||||
|
multiple: true,
|
||||||
|
// 显示搜索条件
|
||||||
|
showSearch: true,
|
||||||
|
// 总条数
|
||||||
|
total: 0,
|
||||||
|
// 活动表格数据
|
||||||
|
activityList: [],
|
||||||
|
actTypeOptions: [],
|
||||||
|
// 弹出层标题
|
||||||
|
title: "",
|
||||||
|
// 是否显示弹出层
|
||||||
|
open: false,
|
||||||
|
// 查询参数
|
||||||
|
queryParams: {
|
||||||
|
pageNum: 1,
|
||||||
|
pageSize: 10,
|
||||||
|
url: undefined,
|
||||||
|
type: undefined,
|
||||||
|
image: undefined,
|
||||||
|
imageHeight: undefined,
|
||||||
|
},
|
||||||
|
// 表单参数
|
||||||
|
form: {},
|
||||||
|
// 表单校验
|
||||||
|
rules: {
|
||||||
|
createBy: [
|
||||||
|
{ required: true, message: "创建者不能为空", trigger: "blur" }
|
||||||
|
],
|
||||||
|
createTime: [
|
||||||
|
{ required: true, message: "创建时间不能为空", trigger: "blur" }
|
||||||
|
],
|
||||||
|
}
|
||||||
|
};
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
this.getList();
|
||||||
|
this.getDicts("act_type").then(response => {
|
||||||
|
this.actTypeOptions = response.data;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
/** 查询活动列表 */
|
||||||
|
getList() {
|
||||||
|
this.loading = true;
|
||||||
|
listActivity(this.queryParams).then(response => {
|
||||||
|
this.activityList = response.rows;
|
||||||
|
this.total = response.total;
|
||||||
|
this.loading = false;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
actTypeFormat(row, column) {
|
||||||
|
return this.selectDictLabel(this.actTypeOptions, row.type);
|
||||||
|
},
|
||||||
|
// 取消按钮
|
||||||
|
cancel() {
|
||||||
|
this.open = false;
|
||||||
|
this.reset();
|
||||||
|
},
|
||||||
|
// 表单重置
|
||||||
|
reset() {
|
||||||
|
this.form = {
|
||||||
|
id: undefined,
|
||||||
|
url: undefined,
|
||||||
|
type: undefined,
|
||||||
|
image: undefined,
|
||||||
|
imageHeight: undefined,
|
||||||
|
createBy: undefined,
|
||||||
|
createTime: undefined,
|
||||||
|
updateBy: undefined,
|
||||||
|
updateTime: undefined
|
||||||
|
};
|
||||||
|
this.resetForm("form");
|
||||||
|
},
|
||||||
|
/** 搜索按钮操作 */
|
||||||
|
handleQuery() {
|
||||||
|
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
|
||||||
|
getActivity(id).then(response => {
|
||||||
|
this.form = response.data;
|
||||||
|
this.open = true;
|
||||||
|
this.title = "修改活动";
|
||||||
|
});
|
||||||
|
},
|
||||||
|
/** 提交按钮 */
|
||||||
|
submitForm() {
|
||||||
|
this.$refs["form"].validate(valid => {
|
||||||
|
if (valid) {
|
||||||
|
if (this.form.id != null) {
|
||||||
|
updateActivity(this.form).then(response => {
|
||||||
|
this.msgSuccess("修改成功");
|
||||||
|
this.open = false;
|
||||||
|
this.getList();
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
addActivity(this.form).then(response => {
|
||||||
|
this.msgSuccess("新增成功");
|
||||||
|
this.open = false;
|
||||||
|
this.getList();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
/** 删除按钮操作 */
|
||||||
|
handleDelete(row) {
|
||||||
|
const ids = row.id || this.ids;
|
||||||
|
this.$confirm('是否确认删除活动编号为"' + ids + '"的数据项?', "警告", {
|
||||||
|
confirmButtonText: "确定",
|
||||||
|
cancelButtonText: "取消",
|
||||||
|
type: "warning"
|
||||||
|
}).then(function() {
|
||||||
|
return delActivity(ids);
|
||||||
|
}).then(() => {
|
||||||
|
this.getList();
|
||||||
|
this.msgSuccess("删除成功");
|
||||||
|
})
|
||||||
|
},
|
||||||
|
/** 导出按钮操作 */
|
||||||
|
handleExport() {
|
||||||
|
const queryParams = this.queryParams;
|
||||||
|
this.$confirm('是否确认导出所有活动数据项?', "警告", {
|
||||||
|
confirmButtonText: "确定",
|
||||||
|
cancelButtonText: "取消",
|
||||||
|
type: "warning"
|
||||||
|
}).then(function() {
|
||||||
|
return exportActivity(queryParams);
|
||||||
|
}).then(response => {
|
||||||
|
this.download(response.msg);
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
Loading…
x
Reference in New Issue
Block a user