|
@@ -1,10 +1,23 @@
|
|
|
-import { getList, add, update, remove, getDetail, updateStatus, batchUpdateStatus } from '@/api/complaint'
|
|
|
+import {
|
|
|
+ getList,
|
|
|
+ add,
|
|
|
+ update,
|
|
|
+ remove,
|
|
|
+ getDetail,
|
|
|
+ updateStatus,
|
|
|
+ batchUpdateStatus
|
|
|
+} from '@/api/complaint'
|
|
|
+import {
|
|
|
+ getReplyList,
|
|
|
+ addReply
|
|
|
+} from '@/api/complaint/reply'
|
|
|
import { mapGetters } from 'vuex'
|
|
|
import {
|
|
|
COMPLAINANT_TYPE_OPTIONS,
|
|
|
COMPLAINT_TYPE_OPTIONS,
|
|
|
COMPLAINT_STATUS_OPTIONS,
|
|
|
REPLY_STATUS_OPTIONS,
|
|
|
+ REPLY_TYPE_OPTIONS,
|
|
|
getComplainantTypeLabel,
|
|
|
getComplaintTypeLabel,
|
|
|
getComplainantTypeType,
|
|
@@ -12,8 +25,10 @@ import {
|
|
|
getComplaintStatusType,
|
|
|
getReplyStatusLabel,
|
|
|
getReplyStatusType,
|
|
|
+ getReplyTypeLabel,
|
|
|
+ getReplyTypeType,
|
|
|
+ getReplyTypeColor,
|
|
|
isComplaintEditable,
|
|
|
- // getComplainantTypeText,
|
|
|
isComplaintProcessable,
|
|
|
isComplaintClosable,
|
|
|
isValidComplaintStatus,
|
|
@@ -83,6 +98,30 @@ export default {
|
|
|
{ required: true, message: '请输入关闭原因', trigger: 'blur' }
|
|
|
]
|
|
|
},
|
|
|
+ // 回复列表相关数据
|
|
|
+ replyListVisible: false,
|
|
|
+ replyList: [],
|
|
|
+ replyListLoading: false,
|
|
|
+ replyPage: {
|
|
|
+ current: 1,
|
|
|
+ size: 10
|
|
|
+ },
|
|
|
+ replyTotal: 0,
|
|
|
+ currentComplaintId: '',
|
|
|
+ currentComplaintNo: '',
|
|
|
+ // 新增回复相关数据
|
|
|
+ addReplyVisible: false,
|
|
|
+ replyForm: {
|
|
|
+ complaintId: '',
|
|
|
+ replyType: 1,
|
|
|
+ replyContent: '',
|
|
|
+ replyAttachUrl: ''
|
|
|
+ },
|
|
|
+ replyRules: {
|
|
|
+ replyType: [{ required: true, message: '请选择回复类型', trigger: 'change' }],
|
|
|
+ replyContent: [{ required: true, message: '请输入回复内容', trigger: 'blur' }]
|
|
|
+ },
|
|
|
+ addReplyLoading: false,
|
|
|
option: {
|
|
|
height: 'auto',
|
|
|
calcHeight: 30,
|
|
@@ -203,6 +242,13 @@ export default {
|
|
|
ids.push(ele.id)
|
|
|
})
|
|
|
return ids.join(',')
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * 回复类型选项
|
|
|
+ * @returns {Array<{label: string, value: number}>} 回复类型选项数组
|
|
|
+ */
|
|
|
+ replyTypeOptions() {
|
|
|
+ return REPLY_TYPE_OPTIONS
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
@@ -406,10 +452,11 @@ export default {
|
|
|
handleProcess(row) {
|
|
|
this.statusDialogTitle = '处理投诉'
|
|
|
this.statusForm = {
|
|
|
- status: 2,
|
|
|
+ id: row.id,
|
|
|
+ status: 1,
|
|
|
closeReason: ''
|
|
|
}
|
|
|
- this.currentIds = [row.id]
|
|
|
+ this.currentIds = null
|
|
|
this.statusVisible = true
|
|
|
},
|
|
|
|
|
@@ -420,14 +467,147 @@ export default {
|
|
|
handleClose(row) {
|
|
|
this.statusDialogTitle = '关闭投诉'
|
|
|
this.statusForm = {
|
|
|
- status: 4,
|
|
|
+ id: row.id,
|
|
|
+ status: 3,
|
|
|
closeReason: ''
|
|
|
}
|
|
|
- this.currentIds = [row.id]
|
|
|
+ this.currentIds = null
|
|
|
this.statusVisible = true
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
+ * 打开回复列表
|
|
|
+ * @param {Object} row - 投诉数据行
|
|
|
+ */
|
|
|
+ async handleReplyList(row) {
|
|
|
+ this.currentComplaintId = row.id
|
|
|
+ this.currentComplaintNo = row.complaintNo
|
|
|
+ this.replyListVisible = true
|
|
|
+ this.replyPage.current = 1
|
|
|
+ await this.loadReplyList()
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 加载回复列表
|
|
|
+ */
|
|
|
+ async loadReplyList() {
|
|
|
+ if (!this.currentComplaintId) return
|
|
|
+
|
|
|
+ this.replyListLoading = true
|
|
|
+ try {
|
|
|
+ const params = {
|
|
|
+ current: this.replyPage.current,
|
|
|
+ size: this.replyPage.size,
|
|
|
+ complaintId: this.currentComplaintId
|
|
|
+ }
|
|
|
+
|
|
|
+ const response = await getReplyList(params)
|
|
|
+ const { records, total } = response.data.data
|
|
|
+
|
|
|
+ this.replyList = records || []
|
|
|
+ this.replyTotal = total || 0
|
|
|
+ } catch (error) {
|
|
|
+ this.$message.error('获取回复列表失败')
|
|
|
+ console.error('获取回复列表失败:', error)
|
|
|
+ } finally {
|
|
|
+ this.replyListLoading = false
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 回复列表分页大小变化
|
|
|
+ * @param {number} size - 新的分页大小
|
|
|
+ */
|
|
|
+ async handleReplyPageSizeChange(size) {
|
|
|
+ this.replyPage.size = size
|
|
|
+ this.replyPage.current = 1
|
|
|
+ await this.loadReplyList()
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 回复列表页码变化
|
|
|
+ * @param {number} current - 新的页码
|
|
|
+ */
|
|
|
+ async handleReplyPageChange(current) {
|
|
|
+ this.replyPage.current = current
|
|
|
+ await this.loadReplyList()
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 打开新增回复对话框
|
|
|
+ */
|
|
|
+ handleAddReply() {
|
|
|
+ this.replyForm = {
|
|
|
+ complaintId: this.currentComplaintId,
|
|
|
+ complaintNo: this.currentComplaintNo,
|
|
|
+ replyType: 1,
|
|
|
+ replyContent: '',
|
|
|
+ replyAttachUrl: ''
|
|
|
+ }
|
|
|
+ this.addReplyVisible = true
|
|
|
+ this.$nextTick(() => {
|
|
|
+ this.$refs.replyForm && this.$refs.replyForm.clearValidate()
|
|
|
+ })
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 确认新增回复
|
|
|
+ */
|
|
|
+ async confirmAddReply() {
|
|
|
+ try {
|
|
|
+ const valid = await this.$refs.replyForm.validate()
|
|
|
+ if (!valid) return
|
|
|
+
|
|
|
+ this.addReplyLoading = true
|
|
|
+
|
|
|
+ const formData = {
|
|
|
+ ...this.replyForm
|
|
|
+ }
|
|
|
+
|
|
|
+ const response = await addReply(formData)
|
|
|
+
|
|
|
+ if (response.data.success) {
|
|
|
+ this.$message.success('新增回复成功')
|
|
|
+ this.addReplyVisible = false
|
|
|
+
|
|
|
+ // 重新加载回复列表
|
|
|
+ await this.loadReplyList()
|
|
|
+
|
|
|
+ // 重新加载投诉列表以更新回复状态
|
|
|
+ this.onLoad(this.page)
|
|
|
+ } else {
|
|
|
+ this.$message.error(response.data.msg || '新增回复失败')
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ this.$message.error('新增回复失败')
|
|
|
+ console.error('新增回复失败:', error)
|
|
|
+ } finally {
|
|
|
+ this.addReplyLoading = false
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取回复类型标签
|
|
|
+ * @param {number} replyType - 回复类型
|
|
|
+ * @returns {string} 回复类型标签
|
|
|
+ */
|
|
|
+ getReplyTypeLabel,
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取回复类型Element UI标签类型
|
|
|
+ * @param {number} replyType - 回复类型
|
|
|
+ * @returns {string} Element UI标签类型
|
|
|
+ */
|
|
|
+ getReplyTypeType,
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取回复类型颜色
|
|
|
+ * @param {number} replyType - 回复类型
|
|
|
+ * @returns {string} 回复类型颜色
|
|
|
+ */
|
|
|
+ getReplyTypeColor,
|
|
|
+
|
|
|
+ /**
|
|
|
* 批量状态处理
|
|
|
*/
|
|
|
handleBatchStatus() {
|
|
@@ -437,7 +617,7 @@ export default {
|
|
|
}
|
|
|
this.statusDialogTitle = '批量处理投诉'
|
|
|
this.statusForm = {
|
|
|
- status: 2,
|
|
|
+ status: 1,
|
|
|
closeReason: ''
|
|
|
}
|
|
|
this.currentIds = this.selectionList.map(item => item.id)
|
|
@@ -453,10 +633,12 @@ export default {
|
|
|
this.statusLoading = true
|
|
|
|
|
|
let res
|
|
|
- if (this.currentIds.length === 1) {
|
|
|
- res = await updateStatus(this.currentIds[0], this.statusForm.status, this.statusForm.closeReason)
|
|
|
- } else {
|
|
|
+ if (this.currentIds && this.currentIds.length > 0) {
|
|
|
+ // 批量处理
|
|
|
res = await batchUpdateStatus(this.currentIds, this.statusForm.status, this.statusForm.closeReason)
|
|
|
+ } else {
|
|
|
+ // 单个处理
|
|
|
+ res = await updateStatus(this.statusForm.id, this.statusForm.status, this.statusForm.closeReason)
|
|
|
}
|
|
|
|
|
|
if (res.data.success) {
|