parent
75818fc75e
commit
7b04efc107
@ -0,0 +1,100 @@
|
||||
package com.ruoyi.web.controller.system;
|
||||
|
||||
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.SecurityUtils;
|
||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
import com.ruoyi.system.domain.SysProject;
|
||||
import com.ruoyi.system.service.ISysProjectService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 项目Controller
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2022-12-30
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/system/project")
|
||||
public class SysProjectController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private ISysProjectService sysProjectService;
|
||||
|
||||
/**
|
||||
* 查询项目列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:project:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(SysProject sysProject)
|
||||
{
|
||||
startPage();
|
||||
List<SysProject> list = sysProjectService.selectSysProjectList(sysProject);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出项目列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:project:export')")
|
||||
@Log(title = "项目", businessType = BusinessType.EXPORT)
|
||||
@GetMapping("/export")
|
||||
public AjaxResult export(SysProject sysProject)
|
||||
{
|
||||
List<SysProject> list = sysProjectService.selectSysProjectList(sysProject);
|
||||
ExcelUtil<SysProject> util = new ExcelUtil<SysProject>(SysProject.class);
|
||||
return util.exportExcel(list, "project");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取项目详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:project:query')")
|
||||
@GetMapping(value = "/{projectId}")
|
||||
public AjaxResult getInfo(@PathVariable("projectId") Long projectId)
|
||||
{
|
||||
return AjaxResult.success(sysProjectService.selectSysProjectById(projectId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增项目
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:project:add')")
|
||||
@Log(title = "项目", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody SysProject sysProject)
|
||||
{
|
||||
sysProject.setUpdateBy(SecurityUtils.getUsername());
|
||||
return toAjax(sysProjectService.insertSysProject(sysProject));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改项目
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:project:edit')")
|
||||
@Log(title = "项目", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody SysProject sysProject)
|
||||
{
|
||||
sysProject.setUpdateBy(SecurityUtils.getUsername());
|
||||
return toAjax(sysProjectService.updateSysProject(sysProject));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除项目
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:project:remove')")
|
||||
@Log(title = "项目", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{projectIds}")
|
||||
public AjaxResult remove(@PathVariable Long[] projectIds)
|
||||
{
|
||||
return toAjax(sysProjectService.deleteSysProjectByIds(projectIds));
|
||||
}
|
||||
}
|
@ -0,0 +1,62 @@
|
||||
package com.ruoyi.system.mapper;
|
||||
|
||||
import com.ruoyi.system.domain.SysProject;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 项目Mapper接口
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2022-12-30
|
||||
*/
|
||||
public interface SysProjectMapper
|
||||
{
|
||||
/**
|
||||
* 查询项目
|
||||
*
|
||||
* @param projectId 项目ID
|
||||
* @return 项目
|
||||
*/
|
||||
public SysProject selectSysProjectById(Long projectId);
|
||||
|
||||
/**
|
||||
* 查询项目列表
|
||||
*
|
||||
* @param sysProject 项目
|
||||
* @return 项目集合
|
||||
*/
|
||||
public List<SysProject> selectSysProjectList(SysProject sysProject);
|
||||
|
||||
/**
|
||||
* 新增项目
|
||||
*
|
||||
* @param sysProject 项目
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertSysProject(SysProject sysProject);
|
||||
|
||||
/**
|
||||
* 修改项目
|
||||
*
|
||||
* @param sysProject 项目
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateSysProject(SysProject sysProject);
|
||||
|
||||
/**
|
||||
* 删除项目
|
||||
*
|
||||
* @param projectId 项目ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteSysProjectById(Long projectId);
|
||||
|
||||
/**
|
||||
* 批量删除项目
|
||||
*
|
||||
* @param projectIds 需要删除的数据ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteSysProjectByIds(Long[] projectIds);
|
||||
}
|
@ -0,0 +1,62 @@
|
||||
package com.ruoyi.system.service;
|
||||
|
||||
import com.ruoyi.system.domain.SysProject;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 项目Service接口
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2022-12-30
|
||||
*/
|
||||
public interface ISysProjectService
|
||||
{
|
||||
/**
|
||||
* 查询项目
|
||||
*
|
||||
* @param projectId 项目ID
|
||||
* @return 项目
|
||||
*/
|
||||
public SysProject selectSysProjectById(Long projectId);
|
||||
|
||||
/**
|
||||
* 查询项目列表
|
||||
*
|
||||
* @param sysProject 项目
|
||||
* @return 项目集合
|
||||
*/
|
||||
public List<SysProject> selectSysProjectList(SysProject sysProject);
|
||||
|
||||
/**
|
||||
* 新增项目
|
||||
*
|
||||
* @param sysProject 项目
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertSysProject(SysProject sysProject);
|
||||
|
||||
/**
|
||||
* 修改项目
|
||||
*
|
||||
* @param sysProject 项目
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateSysProject(SysProject sysProject);
|
||||
|
||||
/**
|
||||
* 批量删除项目
|
||||
*
|
||||
* @param projectIds 需要删除的项目ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteSysProjectByIds(Long[] projectIds);
|
||||
|
||||
/**
|
||||
* 删除项目信息
|
||||
*
|
||||
* @param projectId 项目ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteSysProjectById(Long projectId);
|
||||
}
|
@ -0,0 +1,97 @@
|
||||
package com.ruoyi.system.service.impl;
|
||||
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import com.ruoyi.system.domain.SysProject;
|
||||
import com.ruoyi.system.mapper.SysProjectMapper;
|
||||
import com.ruoyi.system.service.ISysProjectService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 项目Service业务层处理
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2022-12-30
|
||||
*/
|
||||
@Service
|
||||
public class SysProjectServiceImpl implements ISysProjectService
|
||||
{
|
||||
@Autowired
|
||||
private SysProjectMapper sysProjectMapper;
|
||||
|
||||
/**
|
||||
* 查询项目
|
||||
*
|
||||
* @param projectId 项目ID
|
||||
* @return 项目
|
||||
*/
|
||||
@Override
|
||||
public SysProject selectSysProjectById(Long projectId)
|
||||
{
|
||||
return sysProjectMapper.selectSysProjectById(projectId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询项目列表
|
||||
*
|
||||
* @param sysProject 项目
|
||||
* @return 项目
|
||||
*/
|
||||
@Override
|
||||
public List<SysProject> selectSysProjectList(SysProject sysProject)
|
||||
{
|
||||
return sysProjectMapper.selectSysProjectList(sysProject);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增项目
|
||||
*
|
||||
* @param sysProject 项目
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertSysProject(SysProject sysProject)
|
||||
{
|
||||
sysProject.setCreateTime(DateUtils.getNowDate());
|
||||
return sysProjectMapper.insertSysProject(sysProject);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改项目
|
||||
*
|
||||
* @param sysProject 项目
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateSysProject(SysProject sysProject)
|
||||
{
|
||||
sysProject.setUpdateTime(DateUtils.getNowDate());
|
||||
return sysProjectMapper.updateSysProject(sysProject);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除项目
|
||||
*
|
||||
* @param projectIds 需要删除的项目ID
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteSysProjectByIds(Long[] projectIds)
|
||||
{
|
||||
return sysProjectMapper.deleteSysProjectByIds(projectIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除项目信息
|
||||
*
|
||||
* @param projectId 项目ID
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteSysProjectById(Long projectId)
|
||||
{
|
||||
return sysProjectMapper.deleteSysProjectById(projectId);
|
||||
}
|
||||
}
|
@ -0,0 +1,87 @@
|
||||
<?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.system.mapper.SysProjectMapper">
|
||||
|
||||
<resultMap type="SysProject" id="SysProjectResult">
|
||||
<result property="projectId" column="project_id" />
|
||||
<result property="name" column="name" />
|
||||
<result property="introduction" column="introduction" />
|
||||
<result property="startDate" column="start_date" />
|
||||
<result property="endDate" column="end_date" />
|
||||
<result property="delFlag" column="del_flag" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectSysProjectVo">
|
||||
select project_id, name, introduction, start_date, end_date, del_flag, create_time, update_time, update_by from sys_project
|
||||
</sql>
|
||||
|
||||
<select id="selectSysProjectList" parameterType="SysProject" resultMap="SysProjectResult">
|
||||
<include refid="selectSysProjectVo"/>
|
||||
<where>
|
||||
<if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
|
||||
<if test="introduction != null and introduction != ''"> and introduction = #{introduction}</if>
|
||||
<if test="startDate != null "> and start_date = #{startDate}</if>
|
||||
<if test="endDate != null "> and end_date = #{endDate}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectSysProjectById" parameterType="Long" resultMap="SysProjectResult">
|
||||
<include refid="selectSysProjectVo"/>
|
||||
where project_id = #{projectId}
|
||||
</select>
|
||||
|
||||
<insert id="insertSysProject" parameterType="SysProject" useGeneratedKeys="true" keyProperty="projectId">
|
||||
insert into sys_project
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="name != null and name != ''">name,</if>
|
||||
<if test="introduction != null">introduction,</if>
|
||||
<if test="startDate != null">start_date,</if>
|
||||
<if test="endDate != null">end_date,</if>
|
||||
<if test="delFlag != null">del_flag,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
<if test="updateTime != null">update_time,</if>
|
||||
<if test="updateBy != null">update_by,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="name != null and name != ''">#{name},</if>
|
||||
<if test="introduction != null">#{introduction},</if>
|
||||
<if test="startDate != null">#{startDate},</if>
|
||||
<if test="endDate != null">#{endDate},</if>
|
||||
<if test="delFlag != null">#{delFlag},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
<if test="updateTime != null">#{updateTime},</if>
|
||||
<if test="updateBy != null">#{updateBy},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateSysProject" parameterType="SysProject">
|
||||
update sys_project
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="name != null and name != ''">name = #{name},</if>
|
||||
<if test="introduction != null">introduction = #{introduction},</if>
|
||||
<if test="startDate != null">start_date = #{startDate},</if>
|
||||
<if test="endDate != null">end_date = #{endDate},</if>
|
||||
<if test="delFlag != null">del_flag = #{delFlag},</if>
|
||||
<if test="createTime != null">create_time = #{createTime},</if>
|
||||
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||
</trim>
|
||||
where project_id = #{projectId}
|
||||
</update>
|
||||
|
||||
<delete id="deleteSysProjectById" parameterType="Long">
|
||||
delete from sys_project where project_id = #{projectId}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteSysProjectByIds" parameterType="String">
|
||||
delete from sys_project where project_id in
|
||||
<foreach item="projectId" collection="array" open="(" separator="," close=")">
|
||||
#{projectId}
|
||||
</foreach>
|
||||
</delete>
|
||||
</mapper>
|
@ -0,0 +1,53 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
// 查询项目列表
|
||||
export function listProject(query) {
|
||||
return request({
|
||||
url: '/system/project/list',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
// 查询项目详细
|
||||
export function getProject(projectId) {
|
||||
return request({
|
||||
url: '/system/project/' + projectId,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
// 新增项目
|
||||
export function addProject(data) {
|
||||
return request({
|
||||
url: '/system/project',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 修改项目
|
||||
export function updateProject(data) {
|
||||
return request({
|
||||
url: '/system/project',
|
||||
method: 'put',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 删除项目
|
||||
export function delProject(projectId) {
|
||||
return request({
|
||||
url: '/system/project/' + projectId,
|
||||
method: 'delete'
|
||||
})
|
||||
}
|
||||
|
||||
// 导出项目
|
||||
export function exportProject(query) {
|
||||
return request({
|
||||
url: '/system/project/export',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
@ -0,0 +1,333 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
|
||||
<el-form-item label="项目名称" prop="name">
|
||||
<el-input
|
||||
v-model="queryParams.name"
|
||||
placeholder="请输入项目名称"
|
||||
clearable
|
||||
size="small"
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="项目开始时间" prop="startDate">
|
||||
<el-date-picker clearable size="small"
|
||||
v-model="queryParams.startDate"
|
||||
type="date"
|
||||
value-format="yyyy-MM-dd"
|
||||
placeholder="选择项目开始时间">
|
||||
</el-date-picker>
|
||||
</el-form-item>
|
||||
<el-form-item label="项目结束时间" prop="endDate">
|
||||
<el-date-picker clearable size="small"
|
||||
v-model="queryParams.endDate"
|
||||
type="date"
|
||||
value-format="yyyy-MM-dd"
|
||||
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="['system:project: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="['system:project: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="['system:project:remove']"
|
||||
>删除</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="warning"
|
||||
plain
|
||||
icon="el-icon-download"
|
||||
size="mini"
|
||||
@click="handleExport"
|
||||
v-hasPermi="['system:project:export']"
|
||||
>导出</el-button>
|
||||
</el-col>
|
||||
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||
</el-row>
|
||||
|
||||
<el-table v-loading="loading" :data="projectList" @selection-change="handleSelectionChange">
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column label="项目id" align="center" prop="projectId" />
|
||||
<el-table-column label="项目名称" align="center" prop="name" />
|
||||
<el-table-column label="项目介绍" align="center" prop="introduction" />
|
||||
<el-table-column label="项目开始时间" align="center" prop="startDate" width="180">
|
||||
<template slot-scope="scope">
|
||||
<span>{{ parseTime(scope.row.startDate, '{y}-{m}-{d}') }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="项目结束时间" align="center" prop="endDate" width="180">
|
||||
<template slot-scope="scope">
|
||||
<span>{{ parseTime(scope.row.endDate, '{y}-{m}-{d}') }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||
<template slot-scope="scope">
|
||||
<el-button
|
||||
size="mini"
|
||||
type="text"
|
||||
icon="el-icon-edit"
|
||||
@click="handleUpdate(scope.row)"
|
||||
v-hasPermi="['system:project:edit']"
|
||||
>修改</el-button>
|
||||
<el-button
|
||||
size="mini"
|
||||
type="text"
|
||||
icon="el-icon-delete"
|
||||
@click="handleDelete(scope.row)"
|
||||
v-hasPermi="['system:project: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="name">
|
||||
<el-input v-model="form.name" placeholder="请输入项目名称" />
|
||||
</el-form-item>
|
||||
<el-form-item label="项目介绍" prop="introduction">
|
||||
<el-input v-model="form.introduction" type="textarea" placeholder="请输入内容" />
|
||||
</el-form-item>
|
||||
<el-form-item label="项目开始时间" prop="startDate">
|
||||
<el-date-picker clearable size="small"
|
||||
v-model="form.startDate"
|
||||
type="date"
|
||||
value-format="yyyy-MM-dd"
|
||||
placeholder="选择项目开始时间">
|
||||
</el-date-picker>
|
||||
</el-form-item>
|
||||
<el-form-item label="项目结束时间" prop="endDate">
|
||||
<el-date-picker clearable size="small"
|
||||
v-model="form.endDate"
|
||||
type="date"
|
||||
value-format="yyyy-MM-dd"
|
||||
placeholder="选择项目结束时间">
|
||||
</el-date-picker>
|
||||
</el-form-item>
|
||||
<el-form-item label="删除标志" prop="delFlag">
|
||||
<el-input v-model="form.delFlag" 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 { listProject, getProject, delProject, addProject, updateProject, exportProject } from "@/api/system/project";
|
||||
|
||||
export default {
|
||||
name: "Project",
|
||||
components: {
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
// 遮罩层
|
||||
loading: true,
|
||||
// 选中数组
|
||||
ids: [],
|
||||
// 非单个禁用
|
||||
single: true,
|
||||
// 非多个禁用
|
||||
multiple: true,
|
||||
// 显示搜索条件
|
||||
showSearch: true,
|
||||
// 总条数
|
||||
total: 0,
|
||||
// 项目表格数据
|
||||
projectList: [],
|
||||
// 弹出层标题
|
||||
title: "",
|
||||
// 是否显示弹出层
|
||||
open: false,
|
||||
// 查询参数
|
||||
queryParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
name: null,
|
||||
introduction: null,
|
||||
startDate: null,
|
||||
endDate: null,
|
||||
},
|
||||
// 表单参数
|
||||
form: {},
|
||||
// 表单校验
|
||||
rules: {
|
||||
name: [
|
||||
{ required: true, message: "项目名称不能为空", trigger: "blur" }
|
||||
],
|
||||
startDate: [
|
||||
{ required: true, message: "项目开始时间不能为空", trigger: "blur" }
|
||||
],
|
||||
delFlag: [
|
||||
{ required: true, message: "删除标志不能为空", trigger: "blur" }
|
||||
],
|
||||
updateTime: [
|
||||
{ required: true, message: "更新时间不能为空", trigger: "blur" }
|
||||
],
|
||||
updateBy: [
|
||||
{ required: true, message: "更新人不能为空", trigger: "blur" }
|
||||
]
|
||||
}
|
||||
};
|
||||
},
|
||||
created() {
|
||||
this.getList();
|
||||
},
|
||||
methods: {
|
||||
/** 查询项目列表 */
|
||||
getList() {
|
||||
this.loading = true;
|
||||
listProject(this.queryParams).then(response => {
|
||||
this.projectList = response.rows;
|
||||
this.total = response.total;
|
||||
this.loading = false;
|
||||
});
|
||||
},
|
||||
// 取消按钮
|
||||
cancel() {
|
||||
this.open = false;
|
||||
this.reset();
|
||||
},
|
||||
// 表单重置
|
||||
reset() {
|
||||
this.form = {
|
||||
projectId: null,
|
||||
name: null,
|
||||
introduction: null,
|
||||
startDate: null,
|
||||
endDate: null,
|
||||
delFlag: null,
|
||||
createTime: null,
|
||||
updateTime: null,
|
||||
updateBy: null
|
||||
};
|
||||
this.resetForm("form");
|
||||
},
|
||||
/** 搜索按钮操作 */
|
||||
handleQuery() {
|
||||
this.queryParams.pageNum = 1;
|
||||
this.getList();
|
||||
},
|
||||
/** 重置按钮操作 */
|
||||
resetQuery() {
|
||||
this.resetForm("queryForm");
|
||||
this.handleQuery();
|
||||
},
|
||||
// 多选框选中数据
|
||||
handleSelectionChange(selection) {
|
||||
this.ids = selection.map(item => item.projectId)
|
||||
this.single = selection.length!==1
|
||||
this.multiple = !selection.length
|
||||
},
|
||||
/** 新增按钮操作 */
|
||||
handleAdd() {
|
||||
this.reset();
|
||||
this.open = true;
|
||||
this.title = "添加项目";
|
||||
},
|
||||
/** 修改按钮操作 */
|
||||
handleUpdate(row) {
|
||||
this.reset();
|
||||
const projectId = row.projectId || this.ids
|
||||
getProject(projectId).then(response => {
|
||||
this.form = response.data;
|
||||
this.open = true;
|
||||
this.title = "修改项目";
|
||||
});
|
||||
},
|
||||
/** 提交按钮 */
|
||||
submitForm() {
|
||||
this.$refs["form"].validate(valid => {
|
||||
if (valid) {
|
||||
if (this.form.projectId != undefined) {
|
||||
updateProject(this.form).then(response => {
|
||||
this.msgSuccess("修改成功");
|
||||
this.open = false;
|
||||
this.getList();
|
||||
});
|
||||
} else {
|
||||
addProject(this.form).then(response => {
|
||||
this.msgSuccess("新增成功");
|
||||
this.open = false;
|
||||
this.getList();
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
/** 删除按钮操作 */
|
||||
handleDelete(row) {
|
||||
const projectIds = row.projectId || this.ids;
|
||||
this.$confirm('是否确认删除项目编号为"' + projectIds + '"的数据项?', "警告", {
|
||||
confirmButtonText: "确定",
|
||||
cancelButtonText: "取消",
|
||||
type: "warning"
|
||||
}).then(function() {
|
||||
return delProject(projectIds);
|
||||
}).then(() => {
|
||||
this.getList();
|
||||
this.msgSuccess("删除成功");
|
||||
})
|
||||
},
|
||||
/** 导出按钮操作 */
|
||||
handleExport() {
|
||||
const queryParams = this.queryParams;
|
||||
this.$confirm('是否确认导出所有项目数据项?', "警告", {
|
||||
confirmButtonText: "确定",
|
||||
cancelButtonText: "取消",
|
||||
type: "warning"
|
||||
}).then(function() {
|
||||
return exportProject(queryParams);
|
||||
}).then(response => {
|
||||
this.download(response.msg);
|
||||
})
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
Loading…
Reference in new issue