子模块

This commit is contained in:
2025-09-08 17:11:29 +08:00
parent a6d5afad1d
commit 363f7d1a2f
10 changed files with 859 additions and 367 deletions

View File

@@ -0,0 +1,199 @@
package com.ruoyi.models.controller;
import java.util.List;
import java.util.Map;
import java.util.HashMap;
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.common.core.page.TableDataInfo;
import com.ruoyi.models.domain.BizSubModule;
import com.ruoyi.models.domain.BizModule;
import com.ruoyi.models.service.IBizSubModuleService;
import com.ruoyi.models.service.IBizModuleService;
import com.ruoyi.project.service.IBizProjectService;
/**
* 子模块Controller
*/
@RestController
@RequestMapping("/project/submodule")
public class BizSubModuleController extends BaseController
{
@Autowired
private IBizSubModuleService subService;
@Autowired
private IBizModuleService moduleService;
@Autowired
private IBizProjectService projectService;
/**
* 查询子模块列表(按条件)
*/
@PreAuthorize("@ss.hasPermi('project:module:list')")
@GetMapping("/list")
public TableDataInfo list(BizSubModule subModule)
{
startPage();
List<BizSubModule> list = subService.selectBizSubModuleList(subModule);
return getDataTable(list);
}
/**
* 按模块ID查询子模块
*/
@PreAuthorize("@ss.hasPermi('project:module:list')")
@GetMapping("/byModule/{moduleId}")
public TableDataInfo listByModule(@PathVariable Long moduleId)
{
startPage();
List<BizSubModule> list = subService.selectByModuleId(moduleId);
return getDataTable(list);
}
/** 获取详情 */
@PreAuthorize("@ss.hasPermi('project:module:query')")
@GetMapping(value = "/{subId}")
public AjaxResult getInfo(@PathVariable("subId") Long subId)
{
return success(subService.selectBizSubModuleBySubId(subId));
}
/** 新增子模块(仅父模块接取人,且父模块需处于进行中)*/
@PreAuthorize("@ss.hasPermi('project:module:add')")
@Log(title = "子模块", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody BizSubModule subModule)
{
if (subModule.getModuleId() == null)
{
return AjaxResult.error("缺少所属模块");
}
BizModule module = moduleService.selectBizModuleByModuleId(subModule.getModuleId());
if (module == null)
{
return AjaxResult.error("父模块不存在");
}
// 仅模块接取人可新增子模块
if (!String.valueOf(getUserId()).equals(module.getAssignee()))
{
return AjaxResult.error("仅接取人可在该模块下新增子模块");
}
// 父模块需处于进行中
if (!"1".equals(module.getStatus()))
{
return AjaxResult.error("父模块未处于进行中,无法新增子模块");
}
subModule.setStatus("0");
return toAjax(subService.insertBizSubModule(subModule));
}
/** 修改子模块(仅模块接取人) */
@PreAuthorize("@ss.hasPermi('project:module:edit')")
@Log(title = "子模块", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody BizSubModule subModule)
{
BizSubModule current = subService.selectBizSubModuleBySubId(subModule.getSubId());
if (current == null)
{
return AjaxResult.error("子模块不存在");
}
BizModule module = moduleService.selectBizModuleByModuleId(current.getModuleId());
if (!String.valueOf(getUserId()).equals(module.getAssignee()))
{
return AjaxResult.error("仅接取人可修改子模块");
}
return toAjax(subService.updateBizSubModule(subModule));
}
/** 删除子模块(软删除,且仅模块接取人,有状态限制:非进行中/已完成可删或随需) */
@PreAuthorize("@ss.hasPermi('project:module:remove')")
@Log(title = "子模块", businessType = BusinessType.DELETE)
@DeleteMapping("/{subIds}")
public AjaxResult remove(@PathVariable Long[] subIds)
{
for (Long subId : subIds)
{
BizSubModule sub = subService.selectBizSubModuleBySubId(subId);
if (sub == null)
{
return AjaxResult.error("子模块不存在");
}
BizModule module = moduleService.selectBizModuleByModuleId(sub.getModuleId());
if (!String.valueOf(getUserId()).equals(module.getAssignee()))
{
return AjaxResult.error("仅接取人可删除子模块");
}
}
return toAjax(subService.deleteBizSubModuleBySubIds(subIds));
}
/** 接取子模块(仅模块接取人) */
@PreAuthorize("@ss.hasPermi('project:module:claim')")
@Log(title = "子模块接取", businessType = BusinessType.UPDATE)
@PostMapping("/receive/{subId}")
public AjaxResult receive(@PathVariable Long subId)
{
return toAjax(subService.receiveSubModule(subId, getUserId()));
}
/** 完成子模块(仅模块接取人) */
@PreAuthorize("@ss.hasPermi('project:module:complete')")
@Log(title = "子模块完成", businessType = BusinessType.UPDATE)
@PostMapping("/complete/{subId}")
public AjaxResult complete(@PathVariable Long subId)
{
return toAjax(subService.completeSubModule(subId, getUserId()));
}
/**
* 管理员或项目管理员:查看项目下模块及其子模块
*/
@PreAuthorize("@ss.hasPermi('project:module:list')")
@GetMapping("/treeByProject/{projectId}")
public AjaxResult treeByProject(@PathVariable Long projectId)
{
com.ruoyi.project.domain.BizProject project = projectService.selectBizProjectByProjectId(projectId);
if (project == null)
{
return AjaxResult.error("项目不存在");
}
Long currentUserId = getUserId();
boolean isOwner = project.getOwnerId() != null && project.getOwnerId().equals(currentUserId);
boolean isAdmin = com.ruoyi.common.utils.SecurityUtils.isAdmin(currentUserId);
if (!isOwner && !isAdmin)
{
return AjaxResult.error("无权查看该项目结构");
}
com.ruoyi.models.domain.BizModule query = new com.ruoyi.models.domain.BizModule();
query.setProjectId(projectId);
List<com.ruoyi.models.domain.BizModule> modules = moduleService.selectBizModuleList(query);
java.util.List<java.util.Map<String, Object>> result = new java.util.ArrayList<>();
for (com.ruoyi.models.domain.BizModule m : modules)
{
Map<String, Object> item = new HashMap<>();
item.put("module", m);
item.put("subModules", subService.selectByModuleId(m.getModuleId()));
result.add(item);
}
return AjaxResult.success(result);
}
}

View File

@@ -0,0 +1,115 @@
package com.ruoyi.models.domain;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
/**
* 子模块对象 biz_sub_module
*/
public class BizSubModule extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 子模块ID */
private Long subId;
/** 所属模块ID */
@Excel(name = "所属模块ID")
private Long moduleId;
/** 子模块名称 */
@Excel(name = "子模块名称")
private String subName;
/** 状态0待处理 1进行中 2已完成 */
@Excel(name = "状态0待处理 1进行中 2已完成")
private String status;
/** 描述 */
@Excel(name = "描述")
private String description;
/** 删除标志0=正常,2=软删除 */
private String delFlag;
public Long getSubId()
{
return subId;
}
public void setSubId(Long subId)
{
this.subId = subId;
}
public Long getModuleId()
{
return moduleId;
}
public void setModuleId(Long moduleId)
{
this.moduleId = moduleId;
}
public String getSubName()
{
return subName;
}
public void setSubName(String subName)
{
this.subName = subName;
}
public String getStatus()
{
return status;
}
public void setStatus(String status)
{
this.status = status;
}
public String getDescription()
{
return description;
}
public void setDescription(String description)
{
this.description = description;
}
public String getDelFlag()
{
return delFlag;
}
public void setDelFlag(String delFlag)
{
this.delFlag = delFlag;
}
@Override
public String toString()
{
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
.append("subId", getSubId())
.append("moduleId", getModuleId())
.append("subName", getSubName())
.append("status", getStatus())
.append("description", getDescription())
.append("delFlag", getDelFlag())
.append("createBy", getCreateBy())
.append("createTime", getCreateTime())
.append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime())
.toString();
}
}

View File

@@ -0,0 +1,26 @@
package com.ruoyi.models.mapper;
import java.util.List;
import com.ruoyi.models.domain.BizSubModule;
/**
* 子模块Mapper接口
*/
public interface BizSubModuleMapper
{
public BizSubModule selectBizSubModuleBySubId(Long subId);
public List<BizSubModule> selectBizSubModuleList(BizSubModule subModule);
public int insertBizSubModule(BizSubModule subModule);
public int updateBizSubModule(BizSubModule subModule);
public int deleteBizSubModuleBySubId(Long subId);
public int deleteBizSubModuleBySubIds(Long[] subIds);
public List<BizSubModule> selectByModuleId(Long moduleId);
}

View File

@@ -0,0 +1,36 @@
package com.ruoyi.models.service;
import java.util.List;
import com.ruoyi.models.domain.BizSubModule;
/**
* 子模块Service接口
*/
public interface IBizSubModuleService
{
public BizSubModule selectBizSubModuleBySubId(Long subId);
public List<BizSubModule> selectBizSubModuleList(BizSubModule subModule);
public int insertBizSubModule(BizSubModule subModule);
public int updateBizSubModule(BizSubModule subModule);
public int deleteBizSubModuleBySubIds(Long[] subIds);
public int deleteBizSubModuleBySubId(Long subId);
public List<BizSubModule> selectByModuleId(Long moduleId);
/**
* 用户接取子模块(仅父模块接取人有权)
*/
public int receiveSubModule(Long subId, Long userId);
/**
* 用户完成子模块(仅接取人有权)
*/
public int completeSubModule(Long subId, Long userId);
}

View File

@@ -0,0 +1,122 @@
package com.ruoyi.models.service.impl;
import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.models.mapper.BizSubModuleMapper;
import com.ruoyi.models.mapper.BizModuleMapper;
import com.ruoyi.models.domain.BizSubModule;
import com.ruoyi.models.domain.BizModule;
import com.ruoyi.models.service.IBizSubModuleService;
/**
* 子模块Service业务层处理
*/
@Service
public class BizSubModuleServiceImpl implements IBizSubModuleService
{
@Autowired
private BizSubModuleMapper subMapper;
@Autowired
private BizModuleMapper moduleMapper;
@Override
public BizSubModule selectBizSubModuleBySubId(Long subId)
{
return subMapper.selectBizSubModuleBySubId(subId);
}
@Override
public List<BizSubModule> selectBizSubModuleList(BizSubModule subModule)
{
return subMapper.selectBizSubModuleList(subModule);
}
@Override
public int insertBizSubModule(BizSubModule subModule)
{
subModule.setCreateTime(DateUtils.getNowDate());
subModule.setStatus(subModule.getStatus() == null ? "0" : subModule.getStatus());
return subMapper.insertBizSubModule(subModule);
}
@Override
public int updateBizSubModule(BizSubModule subModule)
{
subModule.setUpdateTime(DateUtils.getNowDate());
return subMapper.updateBizSubModule(subModule);
}
@Override
public int deleteBizSubModuleBySubIds(Long[] subIds)
{
return subMapper.deleteBizSubModuleBySubIds(subIds);
}
@Override
public int deleteBizSubModuleBySubId(Long subId)
{
return subMapper.deleteBizSubModuleBySubId(subId);
}
@Override
public List<BizSubModule> selectByModuleId(Long moduleId)
{
return subMapper.selectByModuleId(moduleId);
}
@Override
public int receiveSubModule(Long subId, Long userId)
{
BizSubModule sub = selectBizSubModuleBySubId(subId);
if (sub == null || !"0".equals(sub.getStatus()))
{
throw new RuntimeException("子模块不存在或状态异常");
}
BizModule module = moduleMapper.selectBizModuleByModuleId(sub.getModuleId());
if (module == null)
{
throw new RuntimeException("父模块不存在");
}
if (!String.valueOf(userId).equals(module.getAssignee()))
{
throw new RuntimeException("仅父模块接取人可接取子模块");
}
sub.setStatus("1");
sub.setUpdateBy(String.valueOf(userId));
sub.setUpdateTime(DateUtils.getNowDate());
return updateBizSubModule(sub);
}
@Override
public int completeSubModule(Long subId, Long userId)
{
BizSubModule sub = selectBizSubModuleBySubId(subId);
if (sub == null || !"1".equals(sub.getStatus()))
{
throw new RuntimeException("子模块不存在或状态异常");
}
BizModule module = moduleMapper.selectBizModuleByModuleId(sub.getModuleId());
if (module == null)
{
throw new RuntimeException("父模块不存在");
}
if (!String.valueOf(userId).equals(module.getAssignee()))
{
throw new RuntimeException("仅父模块接取人可完成子模块");
}
sub.setStatus("2");
sub.setUpdateBy(String.valueOf(userId));
sub.setUpdateTime(DateUtils.getNowDate());
return updateBizSubModule(sub);
}
}

View File

@@ -0,0 +1,99 @@
<?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.models.mapper.BizSubModuleMapper">
<resultMap type="BizSubModule" id="BizSubModuleResult">
<result property="subId" column="sub_id" />
<result property="moduleId" column="module_id" />
<result property="subName" column="sub_name" />
<result property="status" column="status" />
<result property="description" column="description" />
<result property="delFlag" column="del_flag" />
<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>
<sql id="selectBizSubModuleVo">
select sub_id, module_id, sub_name, status, description, del_flag, create_by, create_time, update_by, update_time
from biz_sub_module
</sql>
<select id="selectBizSubModuleBySubId" parameterType="Long" resultMap="BizSubModuleResult">
<include refid="selectBizSubModuleVo"/>
where sub_id = #{subId}
</select>
<select id="selectBizSubModuleList" parameterType="BizSubModule" resultMap="BizSubModuleResult">
<include refid="selectBizSubModuleVo"/>
<where>
<if test="moduleId != null"> and module_id = #{moduleId}</if>
<if test="subName != null and subName != ''"> and sub_name like concat('%', #{subName}, '%')</if>
<if test="status != null and status != ''"> and status = #{status}</if>
and del_flag = '0'
</where>
order by create_time desc
</select>
<select id="selectByModuleId" parameterType="Long" resultMap="BizSubModuleResult">
<include refid="selectBizSubModuleVo"/>
<where>
<if test="_parameter != null"> and module_id = #{_parameter}</if>
and del_flag = '0'
</where>
order by create_time asc
</select>
<insert id="insertBizSubModule" parameterType="BizSubModule" useGeneratedKeys="true" keyProperty="subId">
insert into biz_sub_module
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="moduleId != null">module_id,</if>
<if test="subName != null">sub_name,</if>
<if test="status != null">status,</if>
<if test="description != null">description,</if>
<if test="delFlag != null">del_flag,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="moduleId != null">#{moduleId},</if>
<if test="subName != null">#{subName},</if>
<if test="status != null">#{status},</if>
<if test="description != null">#{description},</if>
<if test="delFlag != null">#{delFlag},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
</trim>
</insert>
<update id="updateBizSubModule" parameterType="BizSubModule">
update biz_sub_module
<trim prefix="SET" suffixOverrides=",">
<if test="moduleId != null">module_id = #{moduleId},</if>
<if test="subName != null">sub_name = #{subName},</if>
<if test="status != null">status = #{status},</if>
<if test="description != null">description = #{description},</if>
<if test="delFlag != null">del_flag = #{delFlag},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
</trim>
where sub_id = #{subId}
</update>
<delete id="deleteBizSubModuleBySubId" parameterType="Long">
update biz_sub_module set del_flag = '2' where sub_id = #{subId}
</delete>
<delete id="deleteBizSubModuleBySubIds" parameterType="String">
update biz_sub_module set del_flag = '2' where sub_id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>

View File

@@ -0,0 +1,79 @@
import request from '@/utils/request'
// 查询子模块列表
export function listSubmodule(query) {
return request({
url: '/project/submodule/list',
method: 'get',
params: query
})
}
// 按模块查询子模块
export function listSubmoduleByModule(moduleId, query) {
return request({
url: '/project/submodule/byModule/' + moduleId,
method: 'get',
params: query
})
}
// 获取子模块详情
export function getSubmodule(subId) {
return request({
url: '/project/submodule/' + subId,
method: 'get'
})
}
// 新增子模块
export function addSubmodule(data) {
return request({
url: '/project/submodule',
method: 'post',
data: data
})
}
// 修改子模块
export function updateSubmodule(data) {
return request({
url: '/project/submodule',
method: 'put',
data: data
})
}
// 删除子模块(软删)
export function delSubmodule(subIds) {
return request({
url: '/project/submodule/' + subIds,
method: 'delete'
})
}
// 接取子模块
export function receiveSubmodule(subId) {
return request({
url: '/project/submodule/receive/' + subId,
method: 'post'
})
}
// 完成子模块
export function completeSubmodule(subId) {
return request({
url: '/project/submodule/complete/' + subId,
method: 'post'
})
}
// 管理员查看项目下模块及子模块树
export function treeByProject(projectId) {
return request({
url: '/project/submodule/treeByProject/' + projectId,
method: 'get'
})
}

View File

@@ -1,316 +0,0 @@
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="模块名称" prop="moduleName">
<el-input
v-model="queryParams.moduleName"
placeholder="请输入模块名称"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="接取人" prop="assignee">
<el-input
v-model="queryParams.assignee"
placeholder="请输入接取人"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="接取时间" prop="assignTime">
<el-date-picker clearable
v-model="queryParams.assignTime"
type="date"
value-format="yyyy-MM-dd"
placeholder="请选择接取时间">
</el-date-picker>
</el-form-item>
<el-form-item label="完成时间" prop="finishTime">
<el-date-picker clearable
v-model="queryParams.finishTime"
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="['models:models: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="['models:models: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="['models:models: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="['models:models:export']"
>导出</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="modelsList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="模块名称" align="center" prop="moduleName" />
<el-table-column label="接取状态" align="center" prop="status" />
<el-table-column label="接取人" align="center" prop="assignee" />
<el-table-column label="接取时间" align="center" prop="assignTime" width="180">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.assignTime, '{y}-{m}-{d}') }}</span>
</template>
</el-table-column>
<el-table-column label="完成时间" align="center" prop="finishTime" width="180">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.finishTime, '{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="['models:models:edit']"
>修改</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
v-hasPermi="['models:models: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="moduleName">
<el-input v-model="form.moduleName" placeholder="请输入模块名称" />
</el-form-item>
<el-form-item label="接取人" prop="assignee">
<el-input v-model="form.assignee" placeholder="请输入接取人" />
</el-form-item>
<el-form-item label="接取时间" prop="assignTime">
<el-date-picker clearable
v-model="form.assignTime"
type="date"
value-format="yyyy-MM-dd"
placeholder="请选择接取时间">
</el-date-picker>
</el-form-item>
<el-form-item label="完成时间" prop="finishTime">
<el-date-picker clearable
v-model="form.finishTime"
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"/>
</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 { listModels, getModels, delModels, addModels, updateModels } from "@/api/models/models"
export default {
name: "Models",
data() {
return {
// 遮罩层
loading: true,
// 选中数组
ids: [],
// 非单个禁用
single: true,
// 非多个禁用
multiple: true,
// 显示搜索条件
showSearch: true,
// 总条数
total: 0,
// 模块表格数据
modelsList: [],
// 弹出层标题
title: "",
// 是否显示弹出层
open: false,
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 10,
projectId: null,
moduleName: null,
status: null,
assignee: null,
assignTime: null,
finishTime: null,
},
// 表单参数
form: {},
// 表单校验
rules: {
projectId: [
{ required: true, message: "项目id不能为空", trigger: "blur" }
],
}
}
},
created() {
this.getList()
},
methods: {
/** 查询模块列表 */
getList() {
this.loading = true
listModels(this.queryParams).then(response => {
this.modelsList = response.rows
this.total = response.total
this.loading = false
})
},
// 取消按钮
cancel() {
this.open = false
this.reset()
},
// 表单重置
reset() {
this.form = {
moduleName: null,
status: null,
assignee: null,
assignTime: null,
finishTime: null,
delFlag: null,
createBy: null,
createTime: 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.moduleId)
this.single = selection.length!==1
this.multiple = !selection.length
},
/** 新增按钮操作 */
handleAdd() {
this.reset()
this.open = true
this.title = "添加模块"
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset()
const moduleId = row.moduleId || this.ids
getModels(moduleId).then(response => {
this.form = response.data
this.open = true
this.title = "修改模块"
})
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
if (this.form.moduleId != null) {
updateModels(this.form).then(response => {
this.$modal.msgSuccess("修改成功")
this.open = false
this.getList()
})
} else {
addModels(this.form).then(response => {
this.$modal.msgSuccess("新增成功")
this.open = false
this.getList()
})
}
}
})
},
/** 删除按钮操作 */
handleDelete(row) {
const moduleIds = row.moduleId || this.ids
this.$modal.confirm('是否确认删除模块编号为"' + moduleIds + '"的数据项?').then(function() {
return delModels(moduleIds)
}).then(() => {
this.getList()
this.$modal.msgSuccess("删除成功")
}).catch(() => {})
},
/** 导出按钮操作 */
handleExport() {
this.download('models/models/export', {
...this.queryParams
}, `models_${new Date().getTime()}.xlsx`)
}
}
}
</script>

View File

@@ -40,55 +40,19 @@
</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="['project:module: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="['project:module: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="['project:module: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="['project:module:export']"-->
<!-- >导出</el-button>-->
<!-- </el-col>-->
<!-- <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>-->
<!-- </el-row>-->
<el-table v-loading="loading" :data="moduleList" @selection-change="handleSelectionChange">
<el-table
v-loading="loading"
:data="moduleList"
@selection-change="handleSelectionChange"
@row-click="handleRowClick"
@cell-click="handleCellClick"
>
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="模块名称" align="center" prop="moduleName" />
<el-table-column label="模块名称" align="center" prop="moduleName">
<template slot-scope="scope">
<el-link type="primary" @click.stop="openSubDrawer(scope.row)">{{ scope.row.moduleName }}</el-link>
</template>
</el-table-column>
<el-table-column label="所属项目" align="center" prop="projectName" />
<el-table-column label="接取状态" align="center" prop="status">
<template slot-scope="scope">
@@ -221,6 +185,7 @@
import { listModule, getModule, delModule, addModule, updateModule, assignModule, claimModule, giveupModule } from "@/api/project/module"
import { listProject } from "@/api/project/project"
import { listUser } from "@/api/system/user"
import { listSubmoduleByModule, addSubmodule } from "@/api/project/submodule"
export default {
name: "Module",
@@ -250,6 +215,18 @@ export default {
title: "",
// 是否显示弹出层
open: false,
currentModule: null,
// 新增子模块弹窗
subOpen: false,
subTitle: "新增子模块",
subForm: {
subName: null,
description: null
},
subRules: {
subName: [{ required: true, message: "子模块名称不能为空", trigger: "blur" }]
},
// 指派弹出层
assignOpen: false,
// 查询参数

View File

@@ -43,10 +43,14 @@
</div>
</el-form>
<el-table v-loading="loading" :data="moduleList" @selection-change="handleSelectionChange">
<el-table v-loading="loading" :data="moduleList" @selection-change="handleSelectionChange" @row-click="handleRowClick" @cell-click="handleCellClick">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="模块ID" align="center" prop="moduleId" />
<el-table-column label="模块名称" align="center" prop="moduleName" />
<el-table-column label="模块名称" align="center" prop="moduleName">
<template slot-scope="scope">
<el-link type="primary" @click.stop="openSubDrawer(scope.row)">{{ scope.row.moduleName }}</el-link>
</template>
</el-table-column>
<el-table-column label="项目名称" align="center" prop="projectName" />
<el-table-column label="状态" align="center" prop="status">
<template slot-scope="scope">
@@ -137,11 +141,53 @@
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
<!-- 子模块抽屉 -->
<el-drawer :title="currentModule ? ('子模块 - ' + currentModule.moduleName) : '子模块'" :visible.sync="subDrawerOpen" size="60%" append-to-body>
<div>
<el-button type="primary" size="mini" icon="el-icon-plus" @click="handleOpenAddSub" v-if="currentModule && currentModule.status==='1' && (String(currentModule.assignee)===String(userId) || currentModule.assignee===userName)" style="margin-bottom: 12px;">新增子模块</el-button>
<el-table v-loading="subLoading" :data="subList">
<el-table-column label="子模块名称" prop="subName" />
<el-table-column label="状态" prop="status">
<template slot-scope="scope">
<el-tag :type="scope.row.status==='0' ? 'info' : scope.row.status==='1' ? 'warning' : 'success'">
{{ {0:'待处理',1:'进行中',2:'已完成'}[scope.row.status] }}
</el-tag>
</template>
</el-table-column>
<el-table-column label="描述" prop="description" />
<el-table-column label="操作" align="center" width="220">
<template slot-scope="scope">
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleEditSub(scope.row)" v-if="canOperateSub()">修改</el-button>
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDeleteSub(scope.row)" v-if="canOperateSub()">删除</el-button>
<el-button size="mini" type="text" icon="el-icon-check" @click="handleCompleteSub(scope.row)" v-if="canOperateSub() && scope.row.status==='1'">完成</el-button>
</template>
</el-table-column>
</el-table>
</div>
</el-drawer>
<!-- 新增子模块对话框 -->
<el-dialog :title="subTitle" :visible.sync="subOpen" width="480px" append-to-body>
<el-form ref="subForm" :model="subForm" :rules="subRules" label-width="88px">
<el-form-item label="子模块名称" prop="subName">
<el-input v-model="subForm.subName" placeholder="请输入子模块名称" />
</el-form-item>
<el-form-item label="描述" prop="description">
<el-input v-model="subForm.description" type="textarea" placeholder="请输入描述" />
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitSubForm"> </el-button>
<el-button @click="subOpen=false"> </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { getMyModules, claimModule, giveupModule, completeModule } from "@/api/project/module"
import { listSubmoduleByModule, addSubmodule, updateSubmodule, delSubmodule, completeSubmodule } from "@/api/project/submodule"
export default {
name: "MyModules",
@@ -183,7 +229,16 @@ export default {
moduleName: null,
projectName: null,
status: null,
}
},
// 子模块抽屉/表单
subDrawerOpen: false,
subLoading: false,
subList: [],
currentModule: null,
subOpen: false,
subTitle: '新增子模块',
subForm: { subName: null, description: null },
subRules: { subName: [{ required: true, message: '子模块名称不能为空', trigger: 'blur' }] }
};
},
created() {
@@ -191,6 +246,106 @@ export default {
this.getList();
},
methods: {
/** 打开子模块抽屉(统一入口) */
openSubDrawer(row) {
this.currentModule = row
this.subDrawerOpen = true
this.loadSubList()
},
/** 行点击触发展开 */
handleRowClick(row, column) {
if (column && column.type === 'selection') return
this.openSubDrawer(row)
},
/** 单元格点击兜底触发 */
handleCellClick(row, column) {
if (column && column.type === 'selection') return
if (!this.subDrawerOpen || !this.currentModule || this.currentModule.moduleId !== row.moduleId) {
this.openSubDrawer(row)
}
},
/** 拉取子模块列表 */
loadSubList() {
if (!this.currentModule) return
this.subLoading = true
listSubmoduleByModule(this.currentModule.moduleId).then(res => {
this.subList = res.rows || []
this.subLoading = false
}).catch(() => { this.subLoading = false })
},
/** 打开新增子模块 */
handleOpenAddSub() {
this.subForm = { subId: null, subName: null, description: null }
this.subOpen = true
},
/** 提交新增子模块 */
submitSubForm() {
this.$refs['subForm'].validate(valid => {
if (!valid) return
// 新增或修改
if (!this.subForm.subId) {
const payload = {
moduleId: this.currentModule.moduleId,
subName: this.subForm.subName,
description: this.subForm.description,
status: '0'
}
addSubmodule(payload).then(() => {
this.$modal.msgSuccess('新增子模块成功')
this.subOpen = false
this.loadSubList()
})
} else {
const payload = {
subId: this.subForm.subId,
moduleId: this.currentModule.moduleId,
subName: this.subForm.subName,
description: this.subForm.description
}
updateSubmodule(payload).then(() => {
this.$modal.msgSuccess('修改子模块成功')
this.subOpen = false
this.loadSubList()
})
}
})
},
/** 可操作判定(仅父模块接取人) */
canOperateSub() {
if (!this.currentModule) return false
return String(this.currentModule.assignee) === String(this.userId) || this.currentModule.assignee === this.userName
},
/** 编辑子模块 */
handleEditSub(row) {
if (!this.canOperateSub()) return
this.subForm = { subId: row.subId, subName: row.subName, description: row.description }
this.subTitle = '修改子模块'
this.subOpen = true
},
/** 删除子模块 */
handleDeleteSub(row) {
if (!this.canOperateSub()) return
this.$modal.confirm('确认删除子模块 "' + row.subName + '" ').then(() => {
return delSubmodule(row.subId)
}).then(() => {
this.$modal.msgSuccess('删除成功')
this.loadSubList()
})
},
/** 完成子模块 */
handleCompleteSub(row) {
if (!this.canOperateSub()) return
if (row.status !== '1') {
this.$modal.msgError('仅进行中的子模块可完成')
return
}
this.$modal.confirm('确认将子模块 "' + row.subName + '" 标记为完成?').then(() => {
return completeSubmodule(row.subId)
}).then(() => {
this.$modal.msgSuccess('已完成')
this.loadSubList()
})
},
/** 将角色英文key转换为中文展示 */
buildUserRolesText() {
const roles = this.$store.state.user.roles || [];