增加信息反馈

This commit is contained in:
menxipeng
2025-08-21 12:29:41 +08:00
parent d74bc93b2c
commit 3f2de012ec
11 changed files with 1046 additions and 4 deletions

View File

@@ -0,0 +1,98 @@
package com.ruoyi.web.controller.back;
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.domain.entity.UserFeedback;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.service.IUserFeedbackService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**
* 用户反馈Controller
*
* @author ruoyi
* @date 2025-08-21
*/
@RestController
@RequestMapping("/back/feedback")
public class UserFeedbackController extends BaseController
{
@Autowired
private IUserFeedbackService userFeedbackService;
/**
* 查询用户反馈列表
*/
@PreAuthorize("@ss.hasPermi('system:feedback:list')")
@GetMapping("/list")
public TableDataInfo list(UserFeedback userFeedback)
{
startPage();
List<UserFeedback> list = userFeedbackService.selectUserFeedbackList(userFeedback);
return getDataTable(list);
}
/**
* 导出用户反馈列表
*/
@PreAuthorize("@ss.hasPermi('system:feedback:export')")
@Log(title = "用户反馈", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, UserFeedback userFeedback)
{
List<UserFeedback> list = userFeedbackService.selectUserFeedbackList(userFeedback);
ExcelUtil<UserFeedback> util = new ExcelUtil<>(UserFeedback.class);
util.exportExcel(response, list, "用户反馈数据");
}
/**
* 获取用户反馈详细信息
*/
@PreAuthorize("@ss.hasPermi('system:feedback:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") String id)
{
return success(userFeedbackService.selectUserFeedbackById(id));
}
/**
* 新增用户反馈
*/
@PreAuthorize("@ss.hasPermi('system:feedback:add')")
@Log(title = "用户反馈", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody UserFeedback userFeedback)
{
return toAjax(userFeedbackService.insertUserFeedback(userFeedback));
}
/**
* 修改用户反馈
*/
@PreAuthorize("@ss.hasPermi('system:feedback:edit')")
@Log(title = "用户反馈", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody UserFeedback userFeedback)
{
return toAjax(userFeedbackService.updateUserFeedback(userFeedback));
}
/**
* 删除用户反馈
*/
@PreAuthorize("@ss.hasPermi('system:feedback:remove')")
@Log(title = "用户反馈", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable String[] ids)
{
return toAjax(userFeedbackService.deleteUserFeedbackByIds(ids));
}
}

View File

@@ -0,0 +1,85 @@
package com.ruoyi.web.controller.client;
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.domain.entity.UserFeedback;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.ServletUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.ip.IpUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.service.IUserFeedbackService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Date;
import java.util.List;
import java.util.UUID;
/**
* 用户反馈Controller
*
* @author ruoyi
* @date 2025-08-21
*/
@RestController
@RequestMapping("/client/feedback")
public class ClientFeedbackController extends BaseController
{
@Autowired
private IUserFeedbackService userFeedbackService;
/**
* 提交用户反馈
*/
@PostMapping("/submit")
public AjaxResult submit(@RequestBody UserFeedback userFeedback, HttpServletRequest request)
{
// 验证必填字段
if (StringUtils.isEmpty(userFeedback.getFeedbackContent())) {
return AjaxResult.error("反馈内容不能为空");
}
// 设置ID
userFeedback.setId(UUID.randomUUID().toString().replaceAll("-", ""));
// 设置IP地址
userFeedback.setIpAddress(IpUtils.getIpAddr(request));
// 设置用户浏览器信息
userFeedback.setUserAgent(request.getHeader("User-Agent"));
// 设置状态如果未提供则默认为pending
if (StringUtils.isEmpty(userFeedback.getStatus())) {
userFeedback.setStatus("pending");
} else {
// 验证状态值是否合法
String status = userFeedback.getStatus();
if (!status.equals("pending") && !status.equals("processing") &&
!status.equals("resolved") && !status.equals("closed")) {
return AjaxResult.error("状态值无效,必须是 pending、processing、resolved 或 closed");
}
}
// 设置创建时间和更新时间
Date now = new Date();
userFeedback.setCreatedAt(now);
userFeedback.setUpdatedAt(now);
return toAjax(userFeedbackService.insertUserFeedback(userFeedback));
}
/**
* 查询用户反馈详情
*/
@GetMapping("/detail/{id}")
public AjaxResult getInfo(@PathVariable("id") String id)
{
return AjaxResult.success(userFeedbackService.selectUserFeedbackById(id));
}
}

View File

@@ -17,6 +17,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -73,10 +74,10 @@ public class MusicController extends BaseController {
int count = musicService.findLikeNumsByUserId(userId);
// 获取一张音乐图片
String imgUrl = musicService.findLikeMusicImageByUserId(userId);
AjaxResult ajax = AjaxResult.success();
Map<String,Object> ajax = new HashMap<>();
ajax.put("count", count);
ajax.put("imgUrl", imgUrl);
return ajax;
return AjaxResult.success(ajax);
}
// 删除我喜欢的音乐 cancel/like

View File

@@ -14,7 +14,9 @@ import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 用户播放历史Controller
@@ -118,10 +120,10 @@ public class UserHistoryController extends BaseController
// 获取一张音乐图片
String imgUrl = userHistoryService.findHistoryMusicImageByUserId(userId);
AjaxResult ajax = AjaxResult.success();
Map<String,Object> ajax = new HashMap<>();
ajax.put("count", count);
ajax.put("imgUrl", imgUrl);
return ajax;
return AjaxResult.success(ajax);
}
}

View File

@@ -0,0 +1,191 @@
package com.ruoyi.common.core.domain.entity;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
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;
/**
* 用户反馈对象 user_feedback
*
* @author ruoyi
* @date 2025-08-21
*/
public class UserFeedback extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 唯一标识符 */
private String id;
/** 反馈内容 */
@Excel(name = "反馈内容")
private String feedbackContent;
/** 用户姓名 */
@Excel(name = "用户姓名")
private String userName;
/** 联系方式类型 */
@Excel(name = "联系方式类型")
private String contactType;
/** 联系方式信息 */
@Excel(name = "联系方式信息")
private String contactInfo;
/** 处理状态 */
@Excel(name = "处理状态")
private String status;
/** 创建时间 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "创建时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date createdAt;
/** 更新时间 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "更新时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date updatedAt;
/** 用户IP地址 */
@Excel(name = "用户IP地址")
private String ipAddress;
/** 用户浏览器信息 */
@Excel(name = "用户浏览器信息")
private String userAgent;
/** 附件路径(如果有) */
@Excel(name = "附件路径", readConverterExp = "如=果有")
private String attachmentPath;
public void setId(String id)
{
this.id = id;
}
public String getId()
{
return id;
}
public void setFeedbackContent(String feedbackContent)
{
this.feedbackContent = feedbackContent;
}
public String getFeedbackContent()
{
return feedbackContent;
}
public void setUserName(String userName)
{
this.userName = userName;
}
public String getUserName()
{
return userName;
}
public void setContactType(String contactType)
{
this.contactType = contactType;
}
public String getContactType()
{
return contactType;
}
public void setContactInfo(String contactInfo)
{
this.contactInfo = contactInfo;
}
public String getContactInfo()
{
return contactInfo;
}
public void setStatus(String status)
{
this.status = status;
}
public String getStatus()
{
return status;
}
public void setCreatedAt(Date createdAt)
{
this.createdAt = createdAt;
}
public Date getCreatedAt()
{
return createdAt;
}
public void setUpdatedAt(Date updatedAt)
{
this.updatedAt = updatedAt;
}
public Date getUpdatedAt()
{
return updatedAt;
}
public void setIpAddress(String ipAddress)
{
this.ipAddress = ipAddress;
}
public String getIpAddress()
{
return ipAddress;
}
public void setUserAgent(String userAgent)
{
this.userAgent = userAgent;
}
public String getUserAgent()
{
return userAgent;
}
public void setAttachmentPath(String attachmentPath)
{
this.attachmentPath = attachmentPath;
}
public String getAttachmentPath()
{
return attachmentPath;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("feedbackContent", getFeedbackContent())
.append("userName", getUserName())
.append("contactType", getContactType())
.append("contactInfo", getContactInfo())
.append("status", getStatus())
.append("createdAt", getCreatedAt())
.append("updatedAt", getUpdatedAt())
.append("ipAddress", getIpAddress())
.append("userAgent", getUserAgent())
.append("attachmentPath", getAttachmentPath())
.toString();
}
}

View File

@@ -0,0 +1,62 @@
package com.ruoyi.system.mapper;
import com.ruoyi.common.core.domain.entity.UserFeedback;
import java.util.List;
/**
* 用户反馈Mapper接口
*
* @author ruoyi
* @date 2025-08-21
*/
public interface UserFeedbackMapper
{
/**
* 查询用户反馈
*
* @param id 用户反馈主键
* @return 用户反馈
*/
public UserFeedback selectUserFeedbackById(String id);
/**
* 查询用户反馈列表
*
* @param userFeedback 用户反馈
* @return 用户反馈集合
*/
public List<UserFeedback> selectUserFeedbackList(UserFeedback userFeedback);
/**
* 新增用户反馈
*
* @param userFeedback 用户反馈
* @return 结果
*/
public int insertUserFeedback(UserFeedback userFeedback);
/**
* 修改用户反馈
*
* @param userFeedback 用户反馈
* @return 结果
*/
public int updateUserFeedback(UserFeedback userFeedback);
/**
* 删除用户反馈
*
* @param id 用户反馈主键
* @return 结果
*/
public int deleteUserFeedbackById(String id);
/**
* 批量删除用户反馈
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public int deleteUserFeedbackByIds(String[] ids);
}

View File

@@ -0,0 +1,62 @@
package com.ruoyi.system.service;
import com.ruoyi.common.core.domain.entity.UserFeedback;
import java.util.List;
/**
* 用户反馈Service接口
*
* @author ruoyi
* @date 2025-08-21
*/
public interface IUserFeedbackService
{
/**
* 查询用户反馈
*
* @param id 用户反馈主键
* @return 用户反馈
*/
public UserFeedback selectUserFeedbackById(String id);
/**
* 查询用户反馈列表
*
* @param userFeedback 用户反馈
* @return 用户反馈集合
*/
public List<UserFeedback> selectUserFeedbackList(UserFeedback userFeedback);
/**
* 新增用户反馈
*
* @param userFeedback 用户反馈
* @return 结果
*/
public int insertUserFeedback(UserFeedback userFeedback);
/**
* 修改用户反馈
*
* @param userFeedback 用户反馈
* @return 结果
*/
public int updateUserFeedback(UserFeedback userFeedback);
/**
* 批量删除用户反馈
*
* @param ids 需要删除的用户反馈主键集合
* @return 结果
*/
public int deleteUserFeedbackByIds(String[] ids);
/**
* 删除用户反馈信息
*
* @param id 用户反馈主键
* @return 结果
*/
public int deleteUserFeedbackById(String id);
}

View File

@@ -0,0 +1,94 @@
package com.ruoyi.system.service.impl;
import com.ruoyi.common.core.domain.entity.UserFeedback;
import com.ruoyi.system.mapper.UserFeedbackMapper;
import com.ruoyi.system.service.IUserFeedbackService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* 用户反馈Service业务层处理
*
* @author ruoyi
* @date 2025-08-21
*/
@Service
public class UserFeedbackServiceImpl implements IUserFeedbackService
{
@Autowired
private UserFeedbackMapper userFeedbackMapper;
/**
* 查询用户反馈
*
* @param id 用户反馈主键
* @return 用户反馈
*/
@Override
public UserFeedback selectUserFeedbackById(String id)
{
return userFeedbackMapper.selectUserFeedbackById(id);
}
/**
* 查询用户反馈列表
*
* @param userFeedback 用户反馈
* @return 用户反馈
*/
@Override
public List<UserFeedback> selectUserFeedbackList(UserFeedback userFeedback)
{
return userFeedbackMapper.selectUserFeedbackList(userFeedback);
}
/**
* 新增用户反馈
*
* @param userFeedback 用户反馈
* @return 结果
*/
@Override
public int insertUserFeedback(UserFeedback userFeedback)
{
return userFeedbackMapper.insertUserFeedback(userFeedback);
}
/**
* 修改用户反馈
*
* @param userFeedback 用户反馈
* @return 结果
*/
@Override
public int updateUserFeedback(UserFeedback userFeedback)
{
return userFeedbackMapper.updateUserFeedback(userFeedback);
}
/**
* 批量删除用户反馈
*
* @param ids 需要删除的用户反馈主键
* @return 结果
*/
@Override
public int deleteUserFeedbackByIds(String[] ids)
{
return userFeedbackMapper.deleteUserFeedbackByIds(ids);
}
/**
* 删除用户反馈信息
*
* @param id 用户反馈主键
* @return 结果
*/
@Override
public int deleteUserFeedbackById(String id)
{
return userFeedbackMapper.deleteUserFeedbackById(id);
}
}

View File

@@ -0,0 +1,101 @@
<?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.UserFeedbackMapper">
<resultMap type="UserFeedback" id="UserFeedbackResult">
<result property="id" column="id" />
<result property="feedbackContent" column="feedback_content" />
<result property="userName" column="user_name" />
<result property="contactType" column="contact_type" />
<result property="contactInfo" column="contact_info" />
<result property="status" column="status" />
<result property="createdAt" column="created_at" />
<result property="updatedAt" column="updated_at" />
<result property="ipAddress" column="ip_address" />
<result property="userAgent" column="user_agent" />
<result property="attachmentPath" column="attachment_path" />
</resultMap>
<sql id="selectUserFeedbackVo">
select id, feedback_content, user_name, contact_type, contact_info, status, created_at, updated_at, ip_address, user_agent, attachment_path from user_feedback
</sql>
<select id="selectUserFeedbackList" parameterType="UserFeedback" resultMap="UserFeedbackResult">
<include refid="selectUserFeedbackVo"/>
<where>
<if test="feedbackContent != null and feedbackContent != ''"> and feedback_content = #{feedbackContent}</if>
<if test="userName != null and userName != ''"> and user_name like concat('%', #{userName}, '%')</if>
<if test="contactType != null and contactType != ''"> and contact_type = #{contactType}</if>
<if test="contactInfo != null and contactInfo != ''"> and contact_info = #{contactInfo}</if>
<if test="status != null and status != ''"> and status = #{status}</if>
<if test="createdAt != null "> and created_at = #{createdAt}</if>
<if test="updatedAt != null "> and updated_at = #{updatedAt}</if>
<if test="ipAddress != null and ipAddress != ''"> and ip_address = #{ipAddress}</if>
<if test="userAgent != null and userAgent != ''"> and user_agent = #{userAgent}</if>
<if test="attachmentPath != null and attachmentPath != ''"> and attachment_path = #{attachmentPath}</if>
</where>
</select>
<select id="selectUserFeedbackById" parameterType="String" resultMap="UserFeedbackResult">
<include refid="selectUserFeedbackVo"/>
where id = #{id}
</select>
<insert id="insertUserFeedback" parameterType="UserFeedback" useGeneratedKeys="true" keyProperty="id">
insert into user_feedback
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="feedbackContent != null and feedbackContent != ''">feedback_content,</if>
<if test="userName != null">user_name,</if>
<if test="contactType != null">contact_type,</if>
<if test="contactInfo != null">contact_info,</if>
<if test="status != null">status,</if>
<if test="createdAt != null">created_at,</if>
<if test="updatedAt != null">updated_at,</if>
<if test="ipAddress != null">ip_address,</if>
<if test="userAgent != null">user_agent,</if>
<if test="attachmentPath != null">attachment_path,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="feedbackContent != null and feedbackContent != ''">#{feedbackContent},</if>
<if test="userName != null">#{userName},</if>
<if test="contactType != null">#{contactType},</if>
<if test="contactInfo != null">#{contactInfo},</if>
<if test="status != null">#{status},</if>
<if test="createdAt != null">#{createdAt},</if>
<if test="updatedAt != null">#{updatedAt},</if>
<if test="ipAddress != null">#{ipAddress},</if>
<if test="userAgent != null">#{userAgent},</if>
<if test="attachmentPath != null">#{attachmentPath},</if>
</trim>
</insert>
<update id="updateUserFeedback" parameterType="UserFeedback">
update user_feedback
<trim prefix="SET" suffixOverrides=",">
<if test="feedbackContent != null and feedbackContent != ''">feedback_content = #{feedbackContent},</if>
<if test="userName != null">user_name = #{userName},</if>
<if test="contactType != null">contact_type = #{contactType},</if>
<if test="contactInfo != null">contact_info = #{contactInfo},</if>
<if test="status != null">status = #{status},</if>
<if test="createdAt != null">created_at = #{createdAt},</if>
<if test="updatedAt != null">updated_at = #{updatedAt},</if>
<if test="ipAddress != null">ip_address = #{ipAddress},</if>
<if test="userAgent != null">user_agent = #{userAgent},</if>
<if test="attachmentPath != null">attachment_path = #{attachmentPath},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteUserFeedbackById" parameterType="String">
delete from user_feedback where id = #{id}
</delete>
<delete id="deleteUserFeedbackByIds" parameterType="String">
delete from user_feedback where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>

View File

@@ -0,0 +1,44 @@
import request from '@/utils/request'
// 查询用户反馈列表
export function listFeedback(query) {
return request({
url: '/back/feedback/list',
method: 'get',
params: query
})
}
// 查询用户反馈详细
export function getFeedback(id) {
return request({
url: '/back/feedback/' + id,
method: 'get'
})
}
// 新增用户反馈
export function addFeedback(data) {
return request({
url: '/back/feedback',
method: 'post',
data: data
})
}
// 修改用户反馈
export function updateFeedback(data) {
return request({
url: '/back/feedback',
method: 'put',
data: data
})
}
// 删除用户反馈
export function delFeedback(id) {
return request({
url: '/back/feedback/' + id,
method: 'delete'
})
}

View File

@@ -0,0 +1,302 @@
<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="userName">
<el-input
v-model="queryParams.userName"
placeholder="请输入用户姓名"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="联系方式信息" prop="contactInfo">
<el-input
v-model="queryParams.contactInfo"
placeholder="请输入联系方式信息"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="创建时间" prop="createdAt">
<el-date-picker clearable
v-model="queryParams.createdAt"
type="date"
value-format="yyyy-MM-dd"
placeholder="请选择创建时间">
</el-date-picker>
</el-form-item>
<el-form-item label="更新时间" prop="updatedAt">
<el-date-picker clearable
v-model="queryParams.updatedAt"
type="date"
value-format="yyyy-MM-dd"
placeholder="请选择更新时间">
</el-date-picker>
</el-form-item>
<el-form-item label="用户IP地址" prop="ipAddress">
<el-input
v-model="queryParams.ipAddress"
placeholder="请输入用户IP地址"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="处理状态" prop="status">
<el-select v-model="queryParams.status" placeholder="请选择处理状态" clearable>
<el-option
v-for="dict in statusOptions"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</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="danger"
plain
icon="el-icon-delete"
size="mini"
:disabled="multiple"
@click="handleDelete"
v-hasPermi="['system:feedback: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:feedback:export']"
>导出</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="feedbackList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="唯一标识符" align="center" prop="id" />
<el-table-column label="反馈内容" align="center" prop="feedbackContent" />
<el-table-column label="用户姓名" align="center" prop="userName" />
<el-table-column label="联系方式类型" align="center" prop="contactType" />
<el-table-column label="联系方式信息" align="center" prop="contactInfo" />
<el-table-column label="处理状态" align="center" prop="status">
<template slot-scope="scope">
<el-tag :type="getStatusType(scope.row.status)">{{ getStatusLabel(scope.row.status) }}</el-tag>
</template>
</el-table-column>
<el-table-column label="创建时间" align="center" prop="createdAt" width="180">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.createdAt, '{y}-{m}-{d}') }}</span>
</template>
</el-table-column>
<el-table-column label="更新时间" align="center" prop="updatedAt" width="180">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.updatedAt, '{y}-{m}-{d}') }}</span>
</template>
</el-table-column>
<el-table-column label="用户IP地址" align="center" prop="ipAddress" />
<el-table-column label="用户浏览器信息" align="center" prop="userAgent" />
<el-table-column label="附件路径" align="center" prop="attachmentPath" />
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-dropdown @command="(command) => handleStatusChange(command, scope.row)" trigger="click" size="mini">
<el-button type="text" size="mini" class="status-button">
<i class="el-icon-s-tools"></i> 状态管理<i class="el-icon-arrow-down el-icon--right"></i>
</el-button>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item v-if="scope.row.status !== 'pending'" command="pending">
<i class="el-icon-warning-outline" style="color: #E6A23C;"></i> 设为待处理
</el-dropdown-item>
<el-dropdown-item v-if="scope.row.status !== 'processing'" command="processing">
<i class="el-icon-loading" style="color: #409EFF;"></i> 设为处理中
</el-dropdown-item>
<el-dropdown-item v-if="scope.row.status !== 'resolved'" command="resolved">
<i class="el-icon-success" style="color: #67C23A;"></i> 设为已解决
</el-dropdown-item>
<el-dropdown-item v-if="scope.row.status !== 'closed'" command="closed">
<i class="el-icon-finished" style="color: #909399;"></i> 设为已关闭
</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
<el-divider direction="vertical"></el-divider>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
v-hasPermi="['system:feedback: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"
/>
</div>
</template>
<script>
import { listFeedback, getFeedback, delFeedback, updateFeedback } from "@/api/feedback/feedback"
export default {
name: "Feedback",
data() {
return {
// 遮罩层
loading: true,
// 选中数组
ids: [],
// 非单个禁用
single: true,
// 非多个禁用
multiple: true,
// 显示搜索条件
showSearch: true,
// 总条数
total: 0,
// 用户反馈表格数据
feedbackList: [],
// 状态数据字典
statusOptions: [
{ value: "pending", label: "待处理" },
{ value: "processing", label: "处理中" },
{ value: "resolved", label: "已解决" },
{ value: "closed", label: "已关闭" }
],
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 10,
feedbackContent: null,
userName: null,
contactType: null,
contactInfo: null,
status: null,
createdAt: null,
updatedAt: null,
ipAddress: null,
userAgent: null,
attachmentPath: null
}
}
},
created() {
this.getList()
},
methods: {
/** 查询用户反馈列表 */
getList() {
this.loading = true
listFeedback(this.queryParams).then(response => {
this.feedbackList = response.rows
this.total = response.total
this.loading = false
})
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1
this.getList()
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm")
this.handleQuery()
},
// 多选框选中数据
handleSelectionChange(selection) {
this.ids = selection.map(item => item.id)
this.single = selection.length!==1
this.multiple = !selection.length
},
/** 删除按钮操作 */
handleDelete(row) {
const ids = row.id || this.ids
this.$modal.confirm('是否确认删除用户反馈编号为"' + ids + '"的数据项?').then(function() {
return delFeedback(ids)
}).then(() => {
this.getList()
this.$modal.msgSuccess("删除成功")
}).catch(() => {})
},
/** 导出按钮操作 */
handleExport() {
this.download('system/feedback/export', {
...this.queryParams
}, `feedback_${new Date().getTime()}.xlsx`)
},
/** 获取状态标签 */
getStatusLabel(status) {
const statusMap = {
"pending": "待处理",
"processing": "处理中",
"resolved": "已解决",
"closed": "已关闭",
"0": "待处理" // 兼容旧数据
};
return statusMap[status] || status;
},
/** 获取状态类型(用于设置标签颜色) */
getStatusType(status) {
const statusTypeMap = {
"pending": "warning",
"processing": "primary",
"resolved": "success",
"closed": "info",
"0": "warning" // 兼容旧数据
};
return statusTypeMap[status] || "";
},
/** 处理状态变更 */
handleStatusChange(status, row) {
const statusLabels = {
"pending": "待处理",
"processing": "处理中",
"resolved": "已解决",
"closed": "已关闭"
};
this.$modal.confirm('确认将反馈状态修改为"' + statusLabels[status] + '"吗?').then(() => {
// 克隆对象,避免直接修改表格数据
const feedbackData = JSON.parse(JSON.stringify(row));
feedbackData.status = status;
// 更新时间为当前时间
feedbackData.updatedAt = new Date();
return updateFeedback(feedbackData);
}).then(() => {
this.getList();
this.$modal.msgSuccess("状态修改成功");
}).catch(() => {});
}
}
}
</script>
<style scoped>
.status-button {
color: #409EFF;
padding: 5px 10px;
}
.status-button:hover {
color: #66b1ff;
}
.el-dropdown-menu__item i {
margin-right: 5px;
}
</style>