新增 报备进展记录

This commit is contained in:
wanglongjie 2026-01-28 16:04:49 +08:00
parent ac74fa9204
commit 1759de5af3
13 changed files with 639 additions and 24 deletions

View File

@ -10,7 +10,8 @@
"Bash(git push:*)",
"Bash(git config:*)",
"Bash(pnpm run build)",
"Bash(mvn compile:*)"
"Bash(mvn compile:*)",
"Bash(dir:*)"
]
}
}

25
.gitignore vendored
View File

@ -4,27 +4,6 @@
/frontend/node_modules/
/frontend/node_modules/*
/KEY_GENERATOR.md
/backend/tmpclaude-*
/frontend/tmpclaude-*
/tmpclaude-*
/tmpclaude-6f5d-cwd
/tmpclaude-006c-cwd
/tmpclaude-27a4-cwd
/tmpclaude-2246-cwd
/tmpclaude-a7d6-cwd
/tmpclaude-b78e-cwd
/tmpclaude-2a25-cwd
/tmpclaude-45c6-cwd
/tmpclaude-62fc-cwd
/tmpclaude-65b0-cwd
/tmpclaude-4540-cwd
/tmpclaude-b9f7-cwd
/tmpclaude-b842-cwd
/tmpclaude-c399-cwd
/tmpclaude-d1b4-cwd
/backend/target/
/mysql/data/
@ -56,3 +35,7 @@ Thumbs.db
Dockerfile
.dockerignore
**/tmpclaude-*
/backend/tmpclaude-*
/frontend/tmpclaude-*
/tmpclaude-*

View File

@ -0,0 +1,91 @@
package com.bycrm.controller;
import com.bycrm.common.Result;
import com.bycrm.dto.ReportProgressDTO;
import com.bycrm.entity.ReportProgress;
import com.bycrm.service.ReportProgressService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import java.util.List;
/**
* 报备进展记录控制器
*/
@Api(tags = "报备进展管理")
@RestController
@RequestMapping("/report-progress")
public class ReportProgressController {
private final ReportProgressService reportProgressService;
public ReportProgressController(ReportProgressService reportProgressService) {
this.reportProgressService = reportProgressService;
}
/**
* 根据报备ID获取进展记录列表
*/
@ApiOperation("根据报备ID获取进展记录列表")
@GetMapping("/report/{reportId}")
public Result<List<ReportProgress>> getProgressByReportId(
@ApiParam("报备ID") @PathVariable Long reportId) {
List<ReportProgress> progressList = reportProgressService.getProgressByReportId(reportId);
return Result.success(progressList);
}
/**
* 根据ID获取进展记录
*/
@ApiOperation("根据ID获取进展记录")
@GetMapping("/{id}")
public Result<ReportProgress> getProgressById(
@ApiParam("进展ID") @PathVariable Long id) {
ReportProgress progress = reportProgressService.getProgressById(id);
return Result.success(progress);
}
/**
* 创建进展记录
*/
@ApiOperation("创建进展记录")
@PostMapping
public Result<Void> createProgress(
@ApiParam("进展记录数据") @RequestBody @Valid ReportProgressDTO progressDTO,
HttpServletRequest request) {
Long currentUserId = (Long) request.getAttribute("currentUserId");
reportProgressService.createProgress(progressDTO, currentUserId);
return Result.success();
}
/**
* 更新进展记录
*/
@ApiOperation("更新进展记录")
@PutMapping("/{id}")
public Result<Void> updateProgress(
@ApiParam("进展ID") @PathVariable Long id,
@ApiParam("进展记录数据") @RequestBody @Valid ReportProgressDTO progressDTO,
HttpServletRequest request) {
Long currentUserId = (Long) request.getAttribute("currentUserId");
reportProgressService.updateProgress(id, progressDTO, currentUserId);
return Result.success();
}
/**
* 删除进展记录根据需求不可删除所以不提供该接口
*/
// @ApiOperation("删除进展记录")
// @DeleteMapping("/{id}")
// public Result<Void> deleteProgress(
// @ApiParam("进展ID") @PathVariable Long id,
// HttpServletRequest request) {
// Long currentUserId = (Long) request.getAttribute("currentUserId");
// reportProgressService.deleteProgress(id, currentUserId);
// return Result.success();
// }
}

View File

@ -0,0 +1,25 @@
package com.bycrm.dto;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
/**
* 报备进展记录 DTO
*/
@Data
public class ReportProgressDTO {
/**
* 关联报备ID
*/
@NotNull(message = "报备ID不能为空")
private Long reportId;
/**
* 进展内容
*/
@NotBlank(message = "进展内容不能为空")
private String progressContent;
}

View File

@ -0,0 +1,53 @@
package com.bycrm.entity;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import java.io.Serializable;
import java.time.LocalDateTime;
/**
* 报备进展记录实体
*/
@Data
public class ReportProgress implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 进展ID
*/
private Long id;
/**
* 关联报备ID
*/
private Long reportId;
/**
* 进展内容
*/
private String progressContent;
/**
* 创建人ID
*/
private Long createdBy;
/**
* 创建时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime createdAt;
/**
* 更新时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime updatedAt;
/**
* 关联查询字段 - 创建人姓名
*/
private String creatorName;
}

View File

@ -0,0 +1,39 @@
package com.bycrm.mapper;
import com.bycrm.entity.ReportProgress;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 报备进展记录 Mapper
*/
@Mapper
public interface ReportProgressMapper {
/**
* 根据ID查询进展记录
*/
ReportProgress selectById(@Param("id") Long id);
/**
* 根据报备ID查询进展记录列表
*/
List<ReportProgress> selectByReportId(@Param("reportId") Long reportId);
/**
* 插入进展记录
*/
int insert(ReportProgress reportProgress);
/**
* 更新进展记录
*/
int update(ReportProgress reportProgress);
/**
* 根据ID删除进展记录
*/
int deleteById(@Param("id") Long id);
}

View File

@ -0,0 +1,37 @@
package com.bycrm.service;
import com.bycrm.entity.ReportProgress;
import com.bycrm.dto.ReportProgressDTO;
import java.util.List;
/**
* 报备进展记录服务接口
*/
public interface ReportProgressService {
/**
* 根据报备ID获取进展记录列表
*/
List<ReportProgress> getProgressByReportId(Long reportId);
/**
* 根据ID获取进展记录
*/
ReportProgress getProgressById(Long id);
/**
* 创建进展记录
*/
void createProgress(ReportProgressDTO progressDTO, Long currentUserId);
/**
* 更新进展记录
*/
void updateProgress(Long id, ReportProgressDTO progressDTO, Long currentUserId);
/**
* 删除进展记录不提供删除功能根据需求不可删除
*/
// void deleteProgress(Long id, Long currentUserId);
}

View File

@ -0,0 +1,119 @@
package com.bycrm.service.impl;
import com.bycrm.common.Constants;
import com.bycrm.dto.ReportProgressDTO;
import com.bycrm.entity.Report;
import com.bycrm.entity.ReportProgress;
import com.bycrm.entity.User;
import com.bycrm.exception.BusinessException;
import com.bycrm.mapper.ReportMapper;
import com.bycrm.mapper.ReportProgressMapper;
import com.bycrm.mapper.UserMapper;
import com.bycrm.service.ReportProgressService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDateTime;
import java.util.List;
/**
* 报备进展记录服务实现
*/
@Service
public class ReportProgressServiceImpl implements ReportProgressService {
private final ReportProgressMapper reportProgressMapper;
private final ReportMapper reportMapper;
private final UserMapper userMapper;
public ReportProgressServiceImpl(ReportProgressMapper reportProgressMapper,
ReportMapper reportMapper,
UserMapper userMapper) {
this.reportProgressMapper = reportProgressMapper;
this.reportMapper = reportMapper;
this.userMapper = userMapper;
}
@Override
public List<ReportProgress> getProgressByReportId(Long reportId) {
return reportProgressMapper.selectByReportId(reportId);
}
@Override
public ReportProgress getProgressById(Long id) {
return reportProgressMapper.selectById(id);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void createProgress(ReportProgressDTO progressDTO, Long currentUserId) {
// 获取当前用户
User currentUser = userMapper.selectById(currentUserId);
// 检查报备是否存在
Report report = reportMapper.selectById(progressDTO.getReportId());
if (report == null) {
throw new BusinessException("报备不存在");
}
// 检查权限经销商只能操作自己的报备
if (currentUser.getRole() == Constants.USER_ROLE_DEALER) {
if (!report.getDealerId().equals(currentUser.getDealerId())) {
throw new BusinessException("您只能操作自己报备的进展记录");
}
}
// 检查报备状态是否为已通过
if (report.getStatus() != Constants.REPORT_STATUS_APPROVED) {
throw new BusinessException("只有审核通过的报备才能添加进展记录");
}
// 创建进展记录
ReportProgress progress = new ReportProgress();
progress.setReportId(progressDTO.getReportId());
progress.setProgressContent(progressDTO.getProgressContent());
progress.setCreatedBy(currentUserId);
progress.setCreatedAt(LocalDateTime.now());
progress.setUpdatedAt(LocalDateTime.now());
reportProgressMapper.insert(progress);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void updateProgress(Long id, ReportProgressDTO progressDTO, Long currentUserId) {
// 获取当前用户
User currentUser = userMapper.selectById(currentUserId);
// 检查进展记录是否存在
ReportProgress existingProgress = reportProgressMapper.selectById(id);
if (existingProgress == null) {
throw new BusinessException("进展记录不存在");
}
// 检查报备是否存在
Report report = reportMapper.selectById(existingProgress.getReportId());
if (report == null) {
throw new BusinessException("关联的报备不存在");
}
// 检查权限经销商只能操作自己的报备
if (currentUser.getRole() == Constants.USER_ROLE_DEALER) {
if (!report.getDealerId().equals(currentUser.getDealerId())) {
throw new BusinessException("您只能操作自己报备的进展记录");
}
}
// 更新进展记录
existingProgress.setProgressContent(progressDTO.getProgressContent());
existingProgress.setUpdatedAt(LocalDateTime.now());
reportProgressMapper.update(existingProgress);
}
// 根据需求不提供删除功能
// @Override
// public void deleteProgress(Long id, Long currentUserId) {
// throw new BusinessException("进展记录不可删除");
// }
}

View File

@ -0,0 +1,71 @@
<?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.bycrm.mapper.ReportProgressMapper">
<!-- 结果映射 -->
<resultMap id="BaseResultMap" type="com.bycrm.entity.ReportProgress">
<id column="id" property="id"/>
<result column="report_id" property="reportId"/>
<result column="progress_content" property="progressContent"/>
<result column="created_by" property="createdBy"/>
<result column="created_at" property="createdAt"/>
<result column="updated_at" property="updatedAt"/>
<result column="creator_name" property="creatorName"/>
</resultMap>
<!-- 基础字段 -->
<sql id="Base_Column_List">
id, report_id, progress_content, created_by, created_at, updated_at
</sql>
<!-- 根据ID查询 -->
<select id="selectById" resultMap="BaseResultMap">
SELECT
rp.*, u.real_name as creator_name
FROM
crm_report_progress rp
LEFT JOIN
crm_user u ON rp.created_by = u.id
WHERE
rp.id = #{id}
</select>
<!-- 根据报备ID查询 -->
<select id="selectByReportId" resultMap="BaseResultMap">
SELECT
rp.*, u.real_name as creator_name
FROM
crm_report_progress rp
LEFT JOIN
crm_user u ON rp.created_by = u.id
WHERE
rp.report_id = #{reportId}
ORDER BY
rp.created_at DESC
</select>
<!-- 插入 -->
<insert id="insert" parameterType="com.bycrm.entity.ReportProgress" useGeneratedKeys="true" keyProperty="id">
INSERT INTO crm_report_progress (
report_id, progress_content, created_by, created_at, updated_at
) VALUES (
#{reportId}, #{progressContent}, #{createdBy}, #{createdAt}, #{updatedAt}
)
</insert>
<!-- 更新 -->
<update id="update" parameterType="com.bycrm.entity.ReportProgress">
UPDATE crm_report_progress
SET
progress_content = #{progressContent},
updated_at = #{updatedAt}
WHERE
id = #{id}
</update>
<!-- 删除 -->
<delete id="deleteById">
DELETE FROM crm_report_progress WHERE id = #{id}
</delete>
</mapper>

View File

@ -0,0 +1,27 @@
import { http } from '@/utils/request'
import type { ReportProgress, ReportProgressForm } from '@/types'
// 根据报备ID获取进展记录列表
export const getProgressByReportId = (reportId: number) => {
return http.get<ReportProgress[]>(`/report-progress/report/${reportId}`)
}
// 根据ID获取进展记录
export const getProgressById = (id: number) => {
return http.get<ReportProgress>(`/report-progress/${id}`)
}
// 创建进展记录
export const createProgress = (data: ReportProgressForm) => {
return http.post('/report-progress', data)
}
// 更新进展记录
export const updateProgress = (id: number, data: ReportProgressForm) => {
return http.put(`/report-progress/${id}`, data)
}
// 删除进展记录(根据需求不可删除,所以不提供该接口)
// export const deleteProgress = (id: number) => {
// return http.delete(`/report-progress/${id}`)
// }

View File

@ -104,6 +104,22 @@ export interface DictItem {
value: string | number
}
// 报备进展记录相关类型
export interface ReportProgress {
id: number
reportId: number
progressContent: string
createdBy: number
creatorName?: string
createdAt: string
updatedAt: string
}
export interface ReportProgressForm {
reportId: number
progressContent: string
}
// 系统配置相关类型
export interface SystemConfig {
id: number

View File

@ -58,9 +58,17 @@
</template>
</el-table-column>
<el-table-column prop="createdAt" label="创建时间" width="180" />
<el-table-column label="操作" width="200" fixed="right">
<el-table-column label="操作" width="250" fixed="right">
<template #default="{ row }">
<el-button link type="primary" @click="handleView(row)">查看</el-button>
<el-button
v-if="row.status === 1"
link
type="info"
@click="handleShowProgress(row)"
>
进展
</el-button>
<el-button
v-if="userStore.isAdmin && row.status === 0"
link
@ -157,6 +165,51 @@
<el-button type="primary" @click="handleAuditSubmit">确定</el-button>
</template>
</el-dialog>
<!-- 进展记录对话框 -->
<el-dialog v-model="progressDialogVisible" title="报备进展记录" width="1000px" @close="handleProgressDialogClose">
<el-card>
<template #header>
<div class="card-header">
<span>添加进展记录</span>
</div>
</template>
<el-form ref="progressFormRef" :model="progressFormData" :rules="progressRules" label-width="100px">
<el-form-item label="进展内容" prop="progressContent">
<el-input
v-model="progressFormData.progressContent"
type="textarea"
:rows="4"
placeholder="请输入进展内容"
/>
</el-form-item>
</el-form>
<template #footer>
<el-button v-if="editingProgressId" @click="handleCancelEdit">取消编辑</el-button>
<el-button type="primary" @click="handleSaveProgress">{{ editingProgressId ? '保存修改' : '添加' }}</el-button>
</template>
</el-card>
<el-divider content-position="left">进展记录列表</el-divider>
<el-table :data="progressList" border stripe v-loading="progressLoading">
<el-table-column prop="progressContent" label="进展内容" show-overflow-tooltip />
<el-table-column prop="createdAt" label="创建时间" width="180" />
<el-table-column prop="updatedAt" label="更新时间" width="180" />
<el-table-column label="操作" width="150" fixed="right">
<template #default="{ row }">
<el-button
v-if="!userStore.isAdmin"
link
type="primary"
@click="handleEditProgress(row)"
>
编辑
</el-button>
</template>
</el-table-column>
</el-table>
</el-dialog>
</div>
</template>
@ -166,9 +219,10 @@ import { ElMessage, ElMessageBox, type FormInstance, type FormRules } from 'elem
import { useUserStore } from '@/stores/user'
import zhCn from 'element-plus/dist/locale/zh-cn.mjs'
import { getReportPage, createReport, auditReport, withdrawReport } from '@/api/report'
import { getProgressByReportId, createProgress, updateProgress } from '@/api/report-progress'
import { searchCustomerByName } from '@/api/customer'
import { getConfigValue } from '@/api/system'
import type { Report, ReportForm } from '@/types'
import type { Report, ReportForm, ReportProgress, ReportProgressForm } from '@/types'
const userStore = useUserStore()
@ -184,6 +238,21 @@ const formRef = ref<FormInstance>()
const searchLoading = ref(false)
const customerOptions = ref<Array<{ id: number; name: string }>>([])
//
const progressDialogVisible = ref(false)
const progressFormRef = ref<FormInstance>()
const progressFormData = reactive<ReportProgressForm>({
reportId: 0,
progressContent: ''
})
const progressList = ref<ReportProgress[]>([])
const editingProgressId = ref<number | undefined>()
const progressLoading = ref(false)
const progressRules: FormRules = {
progressContent: [{ required: true, message: '请输入进展内容', trigger: 'blur' }]
}
const queryForm = reactive({
current: 1,
size: 10,
@ -211,6 +280,77 @@ const formatDate = (dateStr: string | null | undefined) => {
return dateStr.split(' ')[0] //
}
//
const handleShowProgress = async (row: Report) => {
progressFormData.reportId = row.id
progressFormData.progressContent = ''
editingProgressId.value = undefined
await fetchProgressList(row.id)
progressDialogVisible.value = true
}
//
const fetchProgressList = async (reportId: number) => {
progressLoading.value = true
try {
const res = await getProgressByReportId(reportId)
progressList.value = res
} catch (error) {
console.error('获取进展记录失败', error)
progressList.value = []
} finally {
progressLoading.value = false
}
}
//
const handleSaveProgress = async () => {
if (!progressFormRef.value) return
await progressFormRef.value.validate(async (valid) => {
if (valid) {
try {
if (editingProgressId.value) {
//
await updateProgress(editingProgressId.value, progressFormData)
ElMessage.success('更新成功')
} else {
//
await createProgress(progressFormData)
ElMessage.success('添加成功')
}
//
await fetchProgressList(progressFormData.reportId)
//
progressFormData.progressContent = ''
editingProgressId.value = undefined
} catch (error) {
console.error('保存进展记录失败', error)
}
}
})
}
//
const handleEditProgress = (row: ReportProgress) => {
editingProgressId.value = row.id
progressFormData.progressContent = row.progressContent
}
//
const handleCancelEdit = () => {
editingProgressId.value = undefined
progressFormData.progressContent = ''
}
//
const handleProgressDialogClose = () => {
progressDialogVisible.value = false
progressFormRef.value?.resetFields()
progressFormData.progressContent = ''
editingProgressId.value = undefined
progressList.value = []
}
//
const fetchData = async () => {
loading.value = true

View File

@ -174,3 +174,16 @@ CREATE TABLE IF NOT EXISTS crm_school (
INDEX idx_school_name (school_name),
INDEX idx_location (location)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='学校表';
-- 报备进展记录表
CREATE TABLE IF NOT EXISTS crm_report_progress (
id BIGINT AUTO_INCREMENT PRIMARY KEY COMMENT '进展ID',
report_id BIGINT NOT NULL COMMENT '关联报备ID',
progress_content VARCHAR(500) NOT NULL COMMENT '进展内容',
created_by BIGINT NOT NULL COMMENT '创建人ID',
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
INDEX idx_report_id (report_id),
INDEX idx_created_by (created_by),
INDEX idx_created_at (created_at)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='报备进展记录表';