mirror of
				https://github.com/dromara/RuoYi-Vue-Plus.git
				synced 2025-11-04 16:23:42 +08:00 
			
		
		
		
	add 增加demo模块 单表演示案例(包含数据权限)
This commit is contained in:
		@@ -0,0 +1,43 @@
 | 
			
		||||
package com.ruoyi.demo.bo;
 | 
			
		||||
 | 
			
		||||
import io.swagger.annotations.ApiModel;
 | 
			
		||||
import io.swagger.annotations.ApiModelProperty;
 | 
			
		||||
import lombok.Data;
 | 
			
		||||
 | 
			
		||||
import javax.validation.constraints.NotBlank;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 测试单表添加对象 test_demo
 | 
			
		||||
 *
 | 
			
		||||
 * @author Lion Li
 | 
			
		||||
 * @date 2021-05-30
 | 
			
		||||
 */
 | 
			
		||||
@Data
 | 
			
		||||
@ApiModel("测试单表添加对象")
 | 
			
		||||
public class TestDemoAddBo {
 | 
			
		||||
 | 
			
		||||
    /** 部门id */
 | 
			
		||||
    @ApiModelProperty("部门id")
 | 
			
		||||
    private Long deptId;
 | 
			
		||||
 | 
			
		||||
    /** 用户id */
 | 
			
		||||
    @ApiModelProperty("用户id")
 | 
			
		||||
    private Long userId;
 | 
			
		||||
 | 
			
		||||
    /** 排序号 */
 | 
			
		||||
    @ApiModelProperty("排序号")
 | 
			
		||||
    private Long orderNum;
 | 
			
		||||
 | 
			
		||||
    /** key键 */
 | 
			
		||||
    @ApiModelProperty("key键")
 | 
			
		||||
    @NotBlank(message = "key键不能为空")
 | 
			
		||||
    private String testKey;
 | 
			
		||||
 | 
			
		||||
    /** 值 */
 | 
			
		||||
    @ApiModelProperty("值")
 | 
			
		||||
    @NotBlank(message = "值不能为空")
 | 
			
		||||
    private String value;
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,52 @@
 | 
			
		||||
package com.ruoyi.demo.bo;
 | 
			
		||||
 | 
			
		||||
import io.swagger.annotations.ApiModel;
 | 
			
		||||
import io.swagger.annotations.ApiModelProperty;
 | 
			
		||||
import lombok.Data;
 | 
			
		||||
 | 
			
		||||
import javax.validation.constraints.NotBlank;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 测试单表编辑对象 test_demo
 | 
			
		||||
 *
 | 
			
		||||
 * @author Lion Li
 | 
			
		||||
 * @date 2021-05-30
 | 
			
		||||
 */
 | 
			
		||||
@Data
 | 
			
		||||
@ApiModel("测试单表编辑对象")
 | 
			
		||||
public class TestDemoEditBo {
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    /** 主键 */
 | 
			
		||||
    @ApiModelProperty("主键")
 | 
			
		||||
    private Long id;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    /** 部门id */
 | 
			
		||||
    @ApiModelProperty("部门id")
 | 
			
		||||
    private Long deptId;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    /** 用户id */
 | 
			
		||||
    @ApiModelProperty("用户id")
 | 
			
		||||
    private Long userId;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    /** 排序号 */
 | 
			
		||||
    @ApiModelProperty("排序号")
 | 
			
		||||
    private Long orderNum;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    /** key键 */
 | 
			
		||||
    @ApiModelProperty("key键")
 | 
			
		||||
    @NotBlank(message = "key键不能为空")
 | 
			
		||||
    private String testKey;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    /** 值 */
 | 
			
		||||
    @ApiModelProperty("值")
 | 
			
		||||
    @NotBlank(message = "值不能为空")
 | 
			
		||||
    private String value;
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,42 @@
 | 
			
		||||
package com.ruoyi.demo.bo;
 | 
			
		||||
 | 
			
		||||
import com.ruoyi.common.core.domain.BaseEntity;
 | 
			
		||||
import io.swagger.annotations.ApiModel;
 | 
			
		||||
import io.swagger.annotations.ApiModelProperty;
 | 
			
		||||
import lombok.Data;
 | 
			
		||||
import lombok.EqualsAndHashCode;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 测试单表分页查询对象 test_demo
 | 
			
		||||
 *
 | 
			
		||||
 * @author Lion Li
 | 
			
		||||
 * @date 2021-05-30
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
@Data
 | 
			
		||||
@EqualsAndHashCode(callSuper = true)
 | 
			
		||||
@ApiModel("测试单表分页查询对象")
 | 
			
		||||
public class TestDemoQueryBo extends BaseEntity {
 | 
			
		||||
 | 
			
		||||
	/** 分页大小 */
 | 
			
		||||
	@ApiModelProperty("分页大小")
 | 
			
		||||
	private Integer pageSize;
 | 
			
		||||
	/** 当前页数 */
 | 
			
		||||
	@ApiModelProperty("当前页数")
 | 
			
		||||
	private Integer pageNum;
 | 
			
		||||
	/** 排序列 */
 | 
			
		||||
	@ApiModelProperty("排序列")
 | 
			
		||||
	private String orderByColumn;
 | 
			
		||||
	/** 排序的方向desc或者asc */
 | 
			
		||||
	@ApiModelProperty(value = "排序的方向", example = "asc,desc")
 | 
			
		||||
	private String isAsc;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	/** key键 */
 | 
			
		||||
	@ApiModelProperty("key键")
 | 
			
		||||
	private String testKey;
 | 
			
		||||
	/** 值 */
 | 
			
		||||
	@ApiModelProperty("值")
 | 
			
		||||
	private String value;
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,108 @@
 | 
			
		||||
package com.ruoyi.demo.controller;
 | 
			
		||||
 | 
			
		||||
import com.ruoyi.common.annotation.Log;
 | 
			
		||||
import com.ruoyi.common.core.controller.BaseController;
 | 
			
		||||
import com.ruoyi.common.core.domain.AjaxResult;
 | 
			
		||||
import com.ruoyi.common.core.page.TableDataInfo;
 | 
			
		||||
import com.ruoyi.common.enums.BusinessType;
 | 
			
		||||
import com.ruoyi.common.utils.poi.ExcelUtil;
 | 
			
		||||
import com.ruoyi.demo.bo.TestDemoAddBo;
 | 
			
		||||
import com.ruoyi.demo.bo.TestDemoEditBo;
 | 
			
		||||
import com.ruoyi.demo.bo.TestDemoQueryBo;
 | 
			
		||||
import com.ruoyi.demo.service.ITestDemoService;
 | 
			
		||||
import com.ruoyi.demo.vo.TestDemoVo;
 | 
			
		||||
import io.swagger.annotations.Api;
 | 
			
		||||
import io.swagger.annotations.ApiOperation;
 | 
			
		||||
import lombok.RequiredArgsConstructor;
 | 
			
		||||
import org.springframework.beans.factory.annotation.Autowired;
 | 
			
		||||
import org.springframework.security.access.prepost.PreAuthorize;
 | 
			
		||||
import org.springframework.validation.annotation.Validated;
 | 
			
		||||
import org.springframework.web.bind.annotation.*;
 | 
			
		||||
 | 
			
		||||
import javax.validation.constraints.NotEmpty;
 | 
			
		||||
import javax.validation.constraints.NotNull;
 | 
			
		||||
import java.util.Arrays;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 测试单表Controller
 | 
			
		||||
 *
 | 
			
		||||
 * @author Lion Li
 | 
			
		||||
 * @date 2021-05-30
 | 
			
		||||
 */
 | 
			
		||||
@Api(value = "测试单表控制器", tags = {"测试单表管理"})
 | 
			
		||||
@RequiredArgsConstructor(onConstructor_ = @Autowired)
 | 
			
		||||
@RestController
 | 
			
		||||
@RequestMapping("/demo/demo")
 | 
			
		||||
public class TestDemoController extends BaseController {
 | 
			
		||||
 | 
			
		||||
    private final ITestDemoService iTestDemoService;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 查询测试单表列表
 | 
			
		||||
     */
 | 
			
		||||
    @ApiOperation("查询测试单表列表")
 | 
			
		||||
    @PreAuthorize("@ss.hasPermi('demo:demo:list')")
 | 
			
		||||
    @GetMapping("/list")
 | 
			
		||||
    public TableDataInfo<TestDemoVo> list(@Validated TestDemoQueryBo bo) {
 | 
			
		||||
        return iTestDemoService.queryPageList(bo);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 导出测试单表列表
 | 
			
		||||
     */
 | 
			
		||||
    @ApiOperation("导出测试单表列表")
 | 
			
		||||
    @PreAuthorize("@ss.hasPermi('demo:demo:export')")
 | 
			
		||||
    @Log(title = "测试单表", businessType = BusinessType.EXPORT)
 | 
			
		||||
    @GetMapping("/export")
 | 
			
		||||
    public AjaxResult<TestDemoVo> export(@Validated TestDemoQueryBo bo) {
 | 
			
		||||
        List<TestDemoVo> list = iTestDemoService.queryList(bo);
 | 
			
		||||
        ExcelUtil<TestDemoVo> util = new ExcelUtil<TestDemoVo>(TestDemoVo.class);
 | 
			
		||||
        return util.exportExcel(list, "测试单表");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 获取测试单表详细信息
 | 
			
		||||
     */
 | 
			
		||||
    @ApiOperation("获取测试单表详细信息")
 | 
			
		||||
    @PreAuthorize("@ss.hasPermi('demo:demo:query')")
 | 
			
		||||
    @GetMapping("/{id}")
 | 
			
		||||
    public AjaxResult<TestDemoVo> getInfo(@NotNull(message = "主键不能为空")
 | 
			
		||||
                                                  @PathVariable("id") Long id) {
 | 
			
		||||
        return AjaxResult.success(iTestDemoService.queryById(id));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 新增测试单表
 | 
			
		||||
     */
 | 
			
		||||
    @ApiOperation("新增测试单表")
 | 
			
		||||
    @PreAuthorize("@ss.hasPermi('demo:demo:add')")
 | 
			
		||||
    @Log(title = "测试单表", businessType = BusinessType.INSERT)
 | 
			
		||||
    @PostMapping()
 | 
			
		||||
    public AjaxResult<Void> add(@Validated @RequestBody TestDemoAddBo bo) {
 | 
			
		||||
        return toAjax(iTestDemoService.insertByAddBo(bo) ? 1 : 0);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 修改测试单表
 | 
			
		||||
     */
 | 
			
		||||
    @ApiOperation("修改测试单表")
 | 
			
		||||
    @PreAuthorize("@ss.hasPermi('demo:demo:edit')")
 | 
			
		||||
    @Log(title = "测试单表", businessType = BusinessType.UPDATE)
 | 
			
		||||
    @PutMapping()
 | 
			
		||||
    public AjaxResult<Void> edit(@Validated @RequestBody TestDemoEditBo bo) {
 | 
			
		||||
        return toAjax(iTestDemoService.updateByEditBo(bo) ? 1 : 0);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 删除测试单表
 | 
			
		||||
     */
 | 
			
		||||
    @ApiOperation("删除测试单表")
 | 
			
		||||
    @PreAuthorize("@ss.hasPermi('demo:demo:remove')")
 | 
			
		||||
    @Log(title = "测试单表" , businessType = BusinessType.DELETE)
 | 
			
		||||
    @DeleteMapping("/{ids}")
 | 
			
		||||
    public AjaxResult<Void> remove(@NotEmpty(message = "主键不能为空")
 | 
			
		||||
                                       @PathVariable Long[] ids) {
 | 
			
		||||
        return toAjax(iTestDemoService.deleteWithValidByIds(Arrays.asList(ids), true) ? 1 : 0);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										70
									
								
								ruoyi-demo/src/main/java/com/ruoyi/demo/domain/TestDemo.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										70
									
								
								ruoyi-demo/src/main/java/com/ruoyi/demo/domain/TestDemo.java
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,70 @@
 | 
			
		||||
package com.ruoyi.demo.domain;
 | 
			
		||||
 | 
			
		||||
import com.baomidou.mybatisplus.annotation.*;
 | 
			
		||||
import lombok.Data;
 | 
			
		||||
import lombok.NoArgsConstructor;
 | 
			
		||||
import lombok.experimental.Accessors;
 | 
			
		||||
 | 
			
		||||
import java.io.Serializable;
 | 
			
		||||
import java.util.Date;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 测试单表对象 test_demo
 | 
			
		||||
 *
 | 
			
		||||
 * @author Lion Li
 | 
			
		||||
 * @date 2021-05-30
 | 
			
		||||
 */
 | 
			
		||||
@Data
 | 
			
		||||
@NoArgsConstructor
 | 
			
		||||
@Accessors(chain = true)
 | 
			
		||||
@TableName("test_demo")
 | 
			
		||||
public class TestDemo implements Serializable {
 | 
			
		||||
 | 
			
		||||
    private static final long serialVersionUID=1L;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    /** 主键 */
 | 
			
		||||
    @TableId(value = "id")
 | 
			
		||||
    private Long id;
 | 
			
		||||
 | 
			
		||||
    /** 部门id */
 | 
			
		||||
    private Long deptId;
 | 
			
		||||
 | 
			
		||||
    /** 用户id */
 | 
			
		||||
    private Long userId;
 | 
			
		||||
 | 
			
		||||
    /** 排序号 */
 | 
			
		||||
    @OrderBy(isDesc = false, sort = 1)
 | 
			
		||||
    private Long orderNum;
 | 
			
		||||
 | 
			
		||||
    /** key键 */
 | 
			
		||||
    private String testKey;
 | 
			
		||||
 | 
			
		||||
    /** 值 */
 | 
			
		||||
    private String value;
 | 
			
		||||
 | 
			
		||||
    /** 版本 */
 | 
			
		||||
    @Version
 | 
			
		||||
    private Long version;
 | 
			
		||||
 | 
			
		||||
    /** 创建时间 */
 | 
			
		||||
    @TableField(fill = FieldFill.INSERT)
 | 
			
		||||
    private Date createTime;
 | 
			
		||||
 | 
			
		||||
    /** 创建人 */
 | 
			
		||||
    @TableField(fill = FieldFill.INSERT)
 | 
			
		||||
    private String createBy;
 | 
			
		||||
 | 
			
		||||
    /** 更新时间 */
 | 
			
		||||
    @TableField(fill = FieldFill.INSERT_UPDATE)
 | 
			
		||||
    private Date updateTime;
 | 
			
		||||
 | 
			
		||||
    /** 更新人 */
 | 
			
		||||
    @TableField(fill = FieldFill.INSERT_UPDATE)
 | 
			
		||||
    private String updateBy;
 | 
			
		||||
 | 
			
		||||
    /** 删除标志 */
 | 
			
		||||
    @TableLogic
 | 
			
		||||
    private Long delFlag;
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,14 @@
 | 
			
		||||
package com.ruoyi.demo.mapper;
 | 
			
		||||
 | 
			
		||||
import com.ruoyi.demo.domain.TestDemo;
 | 
			
		||||
import com.ruoyi.common.core.page.BaseMapperPlus;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 测试单表Mapper接口
 | 
			
		||||
 *
 | 
			
		||||
 * @author Lion Li
 | 
			
		||||
 * @date 2021-05-30
 | 
			
		||||
 */
 | 
			
		||||
public interface TestDemoMapper extends BaseMapperPlus<TestDemo> {
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,57 @@
 | 
			
		||||
package com.ruoyi.demo.service;
 | 
			
		||||
 | 
			
		||||
import com.ruoyi.demo.domain.TestDemo;
 | 
			
		||||
import com.ruoyi.demo.vo.TestDemoVo;
 | 
			
		||||
import com.ruoyi.demo.bo.TestDemoQueryBo;
 | 
			
		||||
import com.ruoyi.demo.bo.TestDemoAddBo;
 | 
			
		||||
import com.ruoyi.demo.bo.TestDemoEditBo;
 | 
			
		||||
import com.ruoyi.common.core.page.IServicePlus;
 | 
			
		||||
import com.ruoyi.common.core.page.TableDataInfo;
 | 
			
		||||
 | 
			
		||||
import java.util.Collection;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 测试单表Service接口
 | 
			
		||||
 *
 | 
			
		||||
 * @author Lion Li
 | 
			
		||||
 * @date 2021-05-30
 | 
			
		||||
 */
 | 
			
		||||
public interface ITestDemoService extends IServicePlus<TestDemo> {
 | 
			
		||||
	/**
 | 
			
		||||
	 * 查询单个
 | 
			
		||||
	 * @return
 | 
			
		||||
	 */
 | 
			
		||||
	TestDemoVo queryById(Long id);
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * 查询列表
 | 
			
		||||
	 */
 | 
			
		||||
    TableDataInfo<TestDemoVo> queryPageList(TestDemoQueryBo bo);
 | 
			
		||||
	/**
 | 
			
		||||
	 * 查询列表
 | 
			
		||||
	 */
 | 
			
		||||
	List<TestDemoVo> queryList(TestDemoQueryBo bo);
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * 根据新增业务对象插入测试单表
 | 
			
		||||
	 * @param bo 测试单表新增业务对象
 | 
			
		||||
	 * @return
 | 
			
		||||
	 */
 | 
			
		||||
	Boolean insertByAddBo(TestDemoAddBo bo);
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * 根据编辑业务对象修改测试单表
 | 
			
		||||
	 * @param bo 测试单表编辑业务对象
 | 
			
		||||
	 * @return
 | 
			
		||||
	 */
 | 
			
		||||
	Boolean updateByEditBo(TestDemoEditBo bo);
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * 校验并删除数据
 | 
			
		||||
	 * @param ids 主键集合
 | 
			
		||||
	 * @param isValid 是否校验,true-删除前校验,false-不校验
 | 
			
		||||
	 * @return
 | 
			
		||||
	 */
 | 
			
		||||
	Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,95 @@
 | 
			
		||||
package com.ruoyi.demo.service.impl;
 | 
			
		||||
 | 
			
		||||
import cn.hutool.core.bean.BeanUtil;
 | 
			
		||||
import cn.hutool.core.util.StrUtil;
 | 
			
		||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 | 
			
		||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 | 
			
		||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 | 
			
		||||
import com.ruoyi.common.annotation.DataScope;
 | 
			
		||||
import com.ruoyi.common.core.page.PagePlus;
 | 
			
		||||
import com.ruoyi.common.core.page.TableDataInfo;
 | 
			
		||||
import com.ruoyi.common.utils.PageUtils;
 | 
			
		||||
import com.ruoyi.demo.bo.TestDemoAddBo;
 | 
			
		||||
import com.ruoyi.demo.bo.TestDemoEditBo;
 | 
			
		||||
import com.ruoyi.demo.bo.TestDemoQueryBo;
 | 
			
		||||
import com.ruoyi.demo.domain.TestDemo;
 | 
			
		||||
import com.ruoyi.demo.mapper.TestDemoMapper;
 | 
			
		||||
import com.ruoyi.demo.service.ITestDemoService;
 | 
			
		||||
import com.ruoyi.demo.vo.TestDemoVo;
 | 
			
		||||
import org.springframework.stereotype.Service;
 | 
			
		||||
 | 
			
		||||
import java.util.Collection;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 测试单表Service业务层处理
 | 
			
		||||
 *
 | 
			
		||||
 * @author Lion Li
 | 
			
		||||
 * @date 2021-05-30
 | 
			
		||||
 */
 | 
			
		||||
@Service
 | 
			
		||||
public class TestDemoServiceImpl extends ServiceImpl<TestDemoMapper, TestDemo> implements ITestDemoService {
 | 
			
		||||
 | 
			
		||||
	@Override
 | 
			
		||||
	public TestDemoVo queryById(Long id) {
 | 
			
		||||
		return getVoById(id, TestDemoVo.class);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	@DataScope(isUser = true)
 | 
			
		||||
	@Override
 | 
			
		||||
	public TableDataInfo<TestDemoVo> queryPageList(TestDemoQueryBo bo) {
 | 
			
		||||
		PagePlus<TestDemo, TestDemoVo> result = pageVo(PageUtils.buildPagePlus(), buildQueryWrapper(bo), TestDemoVo.class);
 | 
			
		||||
		return PageUtils.buildDataInfo(result);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	@DataScope(isUser = true)
 | 
			
		||||
	@Override
 | 
			
		||||
	public List<TestDemoVo> queryList(TestDemoQueryBo bo) {
 | 
			
		||||
		return listVo(buildQueryWrapper(bo), TestDemoVo.class);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	private LambdaQueryWrapper<TestDemo> buildQueryWrapper(TestDemoQueryBo bo) {
 | 
			
		||||
		Map<String, Object> params = bo.getParams();
 | 
			
		||||
		Object dataScope = params.get("dataScope");
 | 
			
		||||
		LambdaQueryWrapper<TestDemo> lqw = Wrappers.lambdaQuery();
 | 
			
		||||
		lqw.like(StrUtil.isNotBlank(bo.getTestKey()), TestDemo::getTestKey, bo.getTestKey());
 | 
			
		||||
		lqw.eq(StrUtil.isNotBlank(bo.getValue()), TestDemo::getValue, bo.getValue());
 | 
			
		||||
		lqw.between(params.get("beginCreateTime") != null && params.get("endCreateTime") != null,
 | 
			
		||||
			TestDemo::getCreateTime, params.get("beginCreateTime"), params.get("endCreateTime"));
 | 
			
		||||
		lqw.apply(dataScope != null && StrUtil.isNotBlank(dataScope.toString()),
 | 
			
		||||
			dataScope != null ? dataScope.toString() : null);
 | 
			
		||||
		return lqw;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	@Override
 | 
			
		||||
	public Boolean insertByAddBo(TestDemoAddBo bo) {
 | 
			
		||||
		TestDemo add = BeanUtil.toBean(bo, TestDemo.class);
 | 
			
		||||
		validEntityBeforeSave(add);
 | 
			
		||||
		return save(add);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	@Override
 | 
			
		||||
	public Boolean updateByEditBo(TestDemoEditBo bo) {
 | 
			
		||||
		TestDemo update = BeanUtil.toBean(bo, TestDemo.class);
 | 
			
		||||
		validEntityBeforeSave(update);
 | 
			
		||||
		return updateById(update);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * 保存前的数据校验
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param entity 实体类数据
 | 
			
		||||
	 */
 | 
			
		||||
	private void validEntityBeforeSave(TestDemo entity) {
 | 
			
		||||
		//TODO 做一些数据校验,如唯一约束
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	@Override
 | 
			
		||||
	public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
 | 
			
		||||
		if (isValid) {
 | 
			
		||||
			//TODO 做一些业务上的校验,判断是否需要校验
 | 
			
		||||
		}
 | 
			
		||||
		return removeByIds(ids);
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										76
									
								
								ruoyi-demo/src/main/java/com/ruoyi/demo/vo/TestDemoVo.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										76
									
								
								ruoyi-demo/src/main/java/com/ruoyi/demo/vo/TestDemoVo.java
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,76 @@
 | 
			
		||||
package com.ruoyi.demo.vo;
 | 
			
		||||
 | 
			
		||||
import com.ruoyi.common.annotation.Excel;
 | 
			
		||||
import com.fasterxml.jackson.annotation.JsonFormat;
 | 
			
		||||
import io.swagger.annotations.ApiModel;
 | 
			
		||||
import io.swagger.annotations.ApiModelProperty;
 | 
			
		||||
import lombok.Data;
 | 
			
		||||
import java.util.Date;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 测试单表视图对象 test_demo
 | 
			
		||||
 *
 | 
			
		||||
 * @author Lion Li
 | 
			
		||||
 * @date 2021-05-30
 | 
			
		||||
 */
 | 
			
		||||
@Data
 | 
			
		||||
@ApiModel("测试单表视图对象")
 | 
			
		||||
public class TestDemoVo {
 | 
			
		||||
 | 
			
		||||
	private static final long serialVersionUID = 1L;
 | 
			
		||||
 | 
			
		||||
	/** 主键 */
 | 
			
		||||
	@ApiModelProperty("主键")
 | 
			
		||||
	private Long id;
 | 
			
		||||
 | 
			
		||||
	/** 部门id */
 | 
			
		||||
	@Excel(name = "部门id")
 | 
			
		||||
	@ApiModelProperty("部门id")
 | 
			
		||||
	private Long deptId;
 | 
			
		||||
 | 
			
		||||
	/** 用户id */
 | 
			
		||||
	@Excel(name = "用户id")
 | 
			
		||||
	@ApiModelProperty("用户id")
 | 
			
		||||
	private Long userId;
 | 
			
		||||
 | 
			
		||||
	/** 排序号 */
 | 
			
		||||
	@Excel(name = "排序号")
 | 
			
		||||
	@ApiModelProperty("排序号")
 | 
			
		||||
	private Long orderNum;
 | 
			
		||||
 | 
			
		||||
	/** key键 */
 | 
			
		||||
	@Excel(name = "key键")
 | 
			
		||||
	@ApiModelProperty("key键")
 | 
			
		||||
	private String testKey;
 | 
			
		||||
 | 
			
		||||
	/** 值 */
 | 
			
		||||
	@Excel(name = "值")
 | 
			
		||||
	@ApiModelProperty("值")
 | 
			
		||||
	private String value;
 | 
			
		||||
 | 
			
		||||
	/** 创建时间 */
 | 
			
		||||
	@Excel(name = "创建时间" , width = 30, dateFormat = "yyyy-MM-dd")
 | 
			
		||||
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
 | 
			
		||||
	@ApiModelProperty("创建时间")
 | 
			
		||||
	private Date createTime;
 | 
			
		||||
 | 
			
		||||
	/** 创建人 */
 | 
			
		||||
	@Excel(name = "创建人")
 | 
			
		||||
	@ApiModelProperty("创建人")
 | 
			
		||||
	private String createBy;
 | 
			
		||||
 | 
			
		||||
	/** 更新时间 */
 | 
			
		||||
	@Excel(name = "更新时间" , width = 30, dateFormat = "yyyy-MM-dd")
 | 
			
		||||
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
 | 
			
		||||
	@ApiModelProperty("更新时间")
 | 
			
		||||
	private Date updateTime;
 | 
			
		||||
 | 
			
		||||
	/** 更新人 */
 | 
			
		||||
	@Excel(name = "更新人")
 | 
			
		||||
	@ApiModelProperty("更新人")
 | 
			
		||||
	private String updateBy;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										23
									
								
								ruoyi-demo/src/main/resources/mapper/demo/TestDemoMapper.xml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								ruoyi-demo/src/main/resources/mapper/demo/TestDemoMapper.xml
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,23 @@
 | 
			
		||||
<?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.demo.mapper.TestDemoMapper">
 | 
			
		||||
 | 
			
		||||
    <resultMap type="com.ruoyi.demo.domain.TestDemo" id="TestDemoResult">
 | 
			
		||||
        <result property="id" column="id"/>
 | 
			
		||||
        <result property="deptId" column="dept_id"/>
 | 
			
		||||
        <result property="userId" column="user_id"/>
 | 
			
		||||
        <result property="orderNum" column="order_num"/>
 | 
			
		||||
        <result property="testKey" column="test_key"/>
 | 
			
		||||
        <result property="value" column="value"/>
 | 
			
		||||
        <result property="version" column="version"/>
 | 
			
		||||
        <result property="createTime" column="create_time"/>
 | 
			
		||||
        <result property="createBy" column="create_by"/>
 | 
			
		||||
        <result property="updateTime" column="update_time"/>
 | 
			
		||||
        <result property="updateBy" column="update_by"/>
 | 
			
		||||
        <result property="delFlag" column="del_flag"/>
 | 
			
		||||
    </resultMap>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
</mapper>
 | 
			
		||||
							
								
								
									
										53
									
								
								ruoyi-ui/src/api/demo/demo.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										53
									
								
								ruoyi-ui/src/api/demo/demo.js
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,53 @@
 | 
			
		||||
import request from '@/utils/request'
 | 
			
		||||
 | 
			
		||||
// 查询测试单表列表
 | 
			
		||||
export function listDemo(query) {
 | 
			
		||||
  return request({
 | 
			
		||||
    url: '/demo/demo/list',
 | 
			
		||||
    method: 'get',
 | 
			
		||||
    params: query
 | 
			
		||||
  })
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// 查询测试单表详细
 | 
			
		||||
export function getDemo(id) {
 | 
			
		||||
  return request({
 | 
			
		||||
    url: '/demo/demo/' + id,
 | 
			
		||||
    method: 'get'
 | 
			
		||||
  })
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// 新增测试单表
 | 
			
		||||
export function addDemo(data) {
 | 
			
		||||
  return request({
 | 
			
		||||
    url: '/demo/demo',
 | 
			
		||||
    method: 'post',
 | 
			
		||||
    data: data
 | 
			
		||||
  })
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// 修改测试单表
 | 
			
		||||
export function updateDemo(data) {
 | 
			
		||||
  return request({
 | 
			
		||||
    url: '/demo/demo',
 | 
			
		||||
    method: 'put',
 | 
			
		||||
    data: data
 | 
			
		||||
  })
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// 删除测试单表
 | 
			
		||||
export function delDemo(id) {
 | 
			
		||||
  return request({
 | 
			
		||||
    url: '/demo/demo/' + id,
 | 
			
		||||
    method: 'delete'
 | 
			
		||||
  })
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// 导出测试单表
 | 
			
		||||
export function exportDemo(query) {
 | 
			
		||||
  return request({
 | 
			
		||||
    url: '/demo/demo/export',
 | 
			
		||||
    method: 'get',
 | 
			
		||||
    params: query
 | 
			
		||||
  })
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										339
									
								
								ruoyi-ui/src/views/demo/demo/index.vue
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										339
									
								
								ruoyi-ui/src/views/demo/demo/index.vue
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,339 @@
 | 
			
		||||
<template>
 | 
			
		||||
  <div class="app-container">
 | 
			
		||||
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
 | 
			
		||||
      <el-form-item label="key键" prop="testKey">
 | 
			
		||||
        <el-input
 | 
			
		||||
          v-model="queryParams.testKey"
 | 
			
		||||
          placeholder="请输入key键"
 | 
			
		||||
          clearable
 | 
			
		||||
          size="small"
 | 
			
		||||
          @keyup.enter.native="handleQuery"
 | 
			
		||||
        />
 | 
			
		||||
      </el-form-item>
 | 
			
		||||
      <el-form-item label="值" prop="value">
 | 
			
		||||
        <el-input
 | 
			
		||||
          v-model="queryParams.value"
 | 
			
		||||
          placeholder="请输入值"
 | 
			
		||||
          clearable
 | 
			
		||||
          size="small"
 | 
			
		||||
          @keyup.enter.native="handleQuery"
 | 
			
		||||
        />
 | 
			
		||||
      </el-form-item>
 | 
			
		||||
      <el-form-item label="创建时间">
 | 
			
		||||
        <el-date-picker
 | 
			
		||||
          v-model="daterangeCreateTime"
 | 
			
		||||
          size="small"
 | 
			
		||||
          style="width: 240px"
 | 
			
		||||
          value-format="yyyy-MM-dd"
 | 
			
		||||
          type="daterange"
 | 
			
		||||
          range-separator="-"
 | 
			
		||||
          start-placeholder="开始日期"
 | 
			
		||||
          end-placeholder="结束日期"
 | 
			
		||||
        ></el-date-picker>
 | 
			
		||||
      </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"
 | 
			
		||||
          v-hasPermi="['demo:demo:add']"
 | 
			
		||||
        >新增</el-button>
 | 
			
		||||
      </el-col>
 | 
			
		||||
      <el-col :span="1.5">
 | 
			
		||||
        <el-button
 | 
			
		||||
          type="success"
 | 
			
		||||
          plain
 | 
			
		||||
          icon="el-icon-edit"
 | 
			
		||||
          size="mini"
 | 
			
		||||
          :disabled="single"
 | 
			
		||||
          @click="handleUpdate"
 | 
			
		||||
          v-hasPermi="['demo:demo:edit']"
 | 
			
		||||
        >修改</el-button>
 | 
			
		||||
      </el-col>
 | 
			
		||||
      <el-col :span="1.5">
 | 
			
		||||
        <el-button
 | 
			
		||||
          type="danger"
 | 
			
		||||
          plain
 | 
			
		||||
          icon="el-icon-delete"
 | 
			
		||||
          size="mini"
 | 
			
		||||
          :disabled="multiple"
 | 
			
		||||
          @click="handleDelete"
 | 
			
		||||
          v-hasPermi="['demo:demo:remove']"
 | 
			
		||||
        >删除</el-button>
 | 
			
		||||
      </el-col>
 | 
			
		||||
      <el-col :span="1.5">
 | 
			
		||||
        <el-button
 | 
			
		||||
          type="warning"
 | 
			
		||||
          plain
 | 
			
		||||
          icon="el-icon-download"
 | 
			
		||||
          size="mini"
 | 
			
		||||
          :loading="exportLoading"
 | 
			
		||||
          @click="handleExport"
 | 
			
		||||
          v-hasPermi="['demo:demo:export']"
 | 
			
		||||
        >导出</el-button>
 | 
			
		||||
      </el-col>
 | 
			
		||||
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
 | 
			
		||||
    </el-row>
 | 
			
		||||
 | 
			
		||||
    <el-table v-loading="loading" :data="demoList" @selection-change="handleSelectionChange">
 | 
			
		||||
      <el-table-column type="selection" width="55" align="center" />
 | 
			
		||||
      <el-table-column label="主键" align="center" prop="id" v-if="false"/>
 | 
			
		||||
      <el-table-column label="部门id" align="center" prop="deptId" />
 | 
			
		||||
      <el-table-column label="用户id" align="center" prop="userId" />
 | 
			
		||||
      <el-table-column label="排序号" align="center" prop="orderNum" />
 | 
			
		||||
      <el-table-column label="key键" align="center" prop="testKey" />
 | 
			
		||||
      <el-table-column label="值" align="center" prop="value" />
 | 
			
		||||
      <el-table-column label="创建时间" align="center" prop="createTime" width="180">
 | 
			
		||||
        <template slot-scope="scope">
 | 
			
		||||
          <span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span>
 | 
			
		||||
        </template>
 | 
			
		||||
      </el-table-column>
 | 
			
		||||
      <el-table-column label="创建人" align="center" prop="createBy" />
 | 
			
		||||
      <el-table-column label="更新时间" align="center" prop="updateTime" width="180">
 | 
			
		||||
        <template slot-scope="scope">
 | 
			
		||||
          <span>{{ parseTime(scope.row.updateTime, '{y}-{m}-{d}') }}</span>
 | 
			
		||||
        </template>
 | 
			
		||||
      </el-table-column>
 | 
			
		||||
      <el-table-column label="更新人" align="center" prop="updateBy" />
 | 
			
		||||
      <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="['demo:demo:edit']"
 | 
			
		||||
          >修改</el-button>
 | 
			
		||||
          <el-button
 | 
			
		||||
            size="mini"
 | 
			
		||||
            type="text"
 | 
			
		||||
            icon="el-icon-delete"
 | 
			
		||||
            @click="handleDelete(scope.row)"
 | 
			
		||||
            v-hasPermi="['demo:demo: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="部门id" prop="deptId">
 | 
			
		||||
          <el-input v-model="form.deptId" placeholder="请输入部门id" />
 | 
			
		||||
        </el-form-item>
 | 
			
		||||
        <el-form-item label="用户id" prop="userId">
 | 
			
		||||
          <el-input v-model="form.userId" placeholder="请输入用户id" />
 | 
			
		||||
        </el-form-item>
 | 
			
		||||
        <el-form-item label="排序号" prop="orderNum">
 | 
			
		||||
          <el-input v-model="form.orderNum" placeholder="请输入排序号" />
 | 
			
		||||
        </el-form-item>
 | 
			
		||||
        <el-form-item label="key键" prop="testKey">
 | 
			
		||||
          <el-input v-model="form.testKey" placeholder="请输入key键" />
 | 
			
		||||
        </el-form-item>
 | 
			
		||||
        <el-form-item label="值" prop="value">
 | 
			
		||||
          <el-input v-model="form.value" 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 { listDemo, getDemo, delDemo, addDemo, updateDemo, exportDemo } from "@/api/demo/demo";
 | 
			
		||||
 | 
			
		||||
export default {
 | 
			
		||||
  name: "Demo",
 | 
			
		||||
  components: {
 | 
			
		||||
  },
 | 
			
		||||
  data() {
 | 
			
		||||
    return {
 | 
			
		||||
      // 遮罩层
 | 
			
		||||
      loading: true,
 | 
			
		||||
      // 导出遮罩层
 | 
			
		||||
      exportLoading: false,
 | 
			
		||||
      // 选中数组
 | 
			
		||||
      ids: [],
 | 
			
		||||
      // 非单个禁用
 | 
			
		||||
      single: true,
 | 
			
		||||
      // 非多个禁用
 | 
			
		||||
      multiple: true,
 | 
			
		||||
      // 显示搜索条件
 | 
			
		||||
      showSearch: true,
 | 
			
		||||
      // 总条数
 | 
			
		||||
      total: 0,
 | 
			
		||||
      // 测试单表表格数据
 | 
			
		||||
      demoList: [],
 | 
			
		||||
      // 弹出层标题
 | 
			
		||||
      title: "",
 | 
			
		||||
      // 是否显示弹出层
 | 
			
		||||
      open: false,
 | 
			
		||||
      // 创建时间时间范围
 | 
			
		||||
      daterangeCreateTime: [],
 | 
			
		||||
      // 查询参数
 | 
			
		||||
      queryParams: {
 | 
			
		||||
        pageNum: 1,
 | 
			
		||||
        pageSize: 10,
 | 
			
		||||
        testKey: undefined,
 | 
			
		||||
        value: undefined,
 | 
			
		||||
        createTime: undefined,
 | 
			
		||||
      },
 | 
			
		||||
      // 表单参数
 | 
			
		||||
      form: {},
 | 
			
		||||
      // 表单校验
 | 
			
		||||
      rules: {
 | 
			
		||||
        testKey: [
 | 
			
		||||
          { required: true, message: "key键不能为空", trigger: "blur" }
 | 
			
		||||
        ],
 | 
			
		||||
        value: [
 | 
			
		||||
          { required: true, message: "值不能为空", trigger: "blur" }
 | 
			
		||||
        ],
 | 
			
		||||
      }
 | 
			
		||||
    };
 | 
			
		||||
  },
 | 
			
		||||
  created() {
 | 
			
		||||
    this.getList();
 | 
			
		||||
  },
 | 
			
		||||
  methods: {
 | 
			
		||||
    /** 查询测试单表列表 */
 | 
			
		||||
    getList() {
 | 
			
		||||
      this.loading = true;
 | 
			
		||||
      this.queryParams.params = {};
 | 
			
		||||
      if (null != this.daterangeCreateTime && '' != this.daterangeCreateTime) {
 | 
			
		||||
        this.queryParams.params["beginCreateTime"] = this.daterangeCreateTime[0];
 | 
			
		||||
        this.queryParams.params["endCreateTime"] = this.daterangeCreateTime[1];
 | 
			
		||||
      }
 | 
			
		||||
      listDemo(this.queryParams).then(response => {
 | 
			
		||||
        this.demoList = response.rows;
 | 
			
		||||
        this.total = response.total;
 | 
			
		||||
        this.loading = false;
 | 
			
		||||
      });
 | 
			
		||||
    },
 | 
			
		||||
    // 取消按钮
 | 
			
		||||
    cancel() {
 | 
			
		||||
      this.open = false;
 | 
			
		||||
      this.reset();
 | 
			
		||||
    },
 | 
			
		||||
    // 表单重置
 | 
			
		||||
    reset() {
 | 
			
		||||
      this.form = {
 | 
			
		||||
        id: undefined,
 | 
			
		||||
        deptId: undefined,
 | 
			
		||||
        userId: undefined,
 | 
			
		||||
        orderNum: undefined,
 | 
			
		||||
        testKey: undefined,
 | 
			
		||||
        value: undefined,
 | 
			
		||||
        version: undefined,
 | 
			
		||||
        createTime: undefined,
 | 
			
		||||
        createBy: undefined,
 | 
			
		||||
        updateTime: undefined,
 | 
			
		||||
        updateBy: undefined,
 | 
			
		||||
        delFlag: undefined
 | 
			
		||||
      };
 | 
			
		||||
      this.resetForm("form");
 | 
			
		||||
    },
 | 
			
		||||
    /** 搜索按钮操作 */
 | 
			
		||||
    handleQuery() {
 | 
			
		||||
      this.queryParams.pageNum = 1;
 | 
			
		||||
      this.getList();
 | 
			
		||||
    },
 | 
			
		||||
    /** 重置按钮操作 */
 | 
			
		||||
    resetQuery() {
 | 
			
		||||
      this.daterangeCreateTime = [];
 | 
			
		||||
      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
 | 
			
		||||
      getDemo(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) {
 | 
			
		||||
            updateDemo(this.form).then(response => {
 | 
			
		||||
              this.msgSuccess("修改成功");
 | 
			
		||||
              this.open = false;
 | 
			
		||||
              this.getList();
 | 
			
		||||
            });
 | 
			
		||||
          } else {
 | 
			
		||||
            addDemo(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 delDemo(ids);
 | 
			
		||||
      }).then(() => {
 | 
			
		||||
        this.getList();
 | 
			
		||||
        this.msgSuccess("删除成功");
 | 
			
		||||
      })
 | 
			
		||||
    },
 | 
			
		||||
    /** 导出按钮操作 */
 | 
			
		||||
    handleExport() {
 | 
			
		||||
      const queryParams = this.queryParams;
 | 
			
		||||
      this.$confirm('是否确认导出所有测试单表数据项?', "警告", {
 | 
			
		||||
        confirmButtonText: "确定",
 | 
			
		||||
        cancelButtonText: "取消",
 | 
			
		||||
        type: "warning"
 | 
			
		||||
      }).then(() => {
 | 
			
		||||
        this.exportLoading = true;
 | 
			
		||||
        return exportDemo(queryParams);
 | 
			
		||||
      }).then(response => {
 | 
			
		||||
        this.download(response.msg);
 | 
			
		||||
        this.exportLoading = false;
 | 
			
		||||
      })
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
};
 | 
			
		||||
</script>
 | 
			
		||||
		Reference in New Issue
	
	Block a user