123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570 |
- import { getClaimList, getClaimDetail, getClaimAttachments, getClaimAuditList, addClaimAudit, updateClaimAudit, removeClaimAudit } from '@/api/claim/index'
- import { formatFileSize } from '@/util/util'
- import { mapGetters } from 'vuex'
- export default {
- data() {
- return {
- form: {},
- query: {},
- loading: true,
- page: {
- pageSize: 10,
- currentPage: 1,
- total: 0
- },
- selectionList: [],
- detailVisible: false,
- attachmentVisible: false,
- auditVisible: false,
- auditFormVisible: false,
- claimDetail: null,
- attachmentList: [],
- auditList: [],
- attachmentLoading: false,
- auditLoading: false,
- auditFormLoading: false,
- currentClaimRow: null,
- auditFormMode: 'add', // 'add' | 'edit'
- // 图片预览相关状态
- imagePreviewVisible: false,
- previewImageUrl: '',
- previewImageList: [],
- currentPreviewIndex: 0,
- // 视频预览相关状态
- videoPreviewVisible: false,
- previewVideoUrl: '',
- auditForm: {
- id: null,
- claimId: null,
- claimNo: '',
- auditResult: null,
- auditAmount: 0,
- reasonDetail: '',
- auditorId: null,
- auditorName: '',
- auditTime: '',
- feedbackChannel: '',
- feedbackDesc: '',
- feedbackTime: '',
- appealStatus: 0,
- appealResult: '',
- appealTime: ''
- },
- auditFormRules: {
- auditResult: [
- { required: true, message: '请选择审核结果', trigger: 'change' }
- ],
- auditAmount: [
- { required: true, message: '请输入审核金额', trigger: 'blur' }
- ],
- reasonDetail: [
- { required: true, message: '请输入审核说明', trigger: 'blur' },
- { min: 10, message: '审核说明至少10个字符', trigger: 'blur' }
- ],
- auditorName: [
- { required: true, message: '请输入审核人姓名', trigger: 'blur' }
- ],
- auditTime: [
- { required: true, message: '请选择审核时间', trigger: 'change' }
- ]
- },
- option: {
- height: 'auto',
- calcHeight: 30,
- tip: false,
- searchShow: true,
- searchMenuSpan: 6,
- border: true,
- index: true,
- indexLabel: '序号',
- selection: true,
- viewBtn: false,
- editBtn: false,
- delBtn: false,
- addBtn: false,
- column: [
- {
- label: '理赔编号',
- prop: 'claimNo',
- search: true
- },
- {
- label: '来源类型',
- prop: 'claimSourceType',
- type: 'select',
- dicData: [
- { label: '经销商', value: 1 },
- { label: '门店', value: 2 }
- ],
- search: true,
- slot: true
- },
- {
- label: '来源名称',
- prop: 'sourceName',
- search: true
- },
- {
- label: '来源编码',
- prop: 'sourceCode',
- search: true
- },
- {
- label: '消费者姓名',
- prop: 'consumerName',
- search: true
- },
- {
- label: '消费者电话',
- prop: 'consumerPhone',
- search: true
- },
- {
- label: '轮胎编号',
- prop: 'tyreNo',
- search: true
- },
- {
- label: '轮胎规格',
- prop: 'tyreSpecs'
- },
- {
- label: '理赔金额',
- prop: 'claimAmount',
- type: 'number'
- },
- {
- label: '审核状态',
- prop: 'auditStatus',
- type: 'select',
- dicData: [
- { label: '待审核', value: 0 },
- { label: '审核通过', value: 1 },
- { label: '审核拒绝', value: 2 }
- ],
- search: true,
- slot: true
- },
- {
- label: '提交时间',
- prop: 'submitTime',
- type: 'datetime',
- format: 'yyyy-MM-dd HH:mm:ss',
- valueFormat: 'yyyy-MM-dd HH:mm:ss'
- }
- ]
- },
- data: []
- }
- },
- computed: {
- ...mapGetters(['permission'])
- },
- methods: {
- /**
- * 获取列表数据
- * @param {Object} page - 分页参数
- * @param {Object} params - 查询参数
- */
- async onLoad(page, params = {}) {
- try {
- this.loading = true
- const res = await getClaimList(page.currentPage, page.pageSize, Object.assign(params, this.query))
- const data = res.data.data
- this.page.total = data.total
- this.data = data.records
- } catch (error) {
- console.error('获取理赔列表失败:', error)
- this.$message.error('获取理赔列表失败')
- } finally {
- this.loading = false
- }
- },
- /**
- * 搜索
- * @param {Object} params - 搜索参数
- * @param {Function} done - 完成回调
- */
- searchChange(params, done) {
- this.query = params
- this.onLoad(this.page, params)
- done()
- },
- /**
- * 搜索重置
- */
- searchReset() {
- this.query = {}
- this.onLoad(this.page)
- },
- /**
- * 选择改变
- * @param {Array} list - 选中的列表
- */
- selectionChange(list) {
- this.selectionList = list
- },
- /**
- * 当前页改变
- * @param {number} currentPage - 当前页码
- */
- currentChange(currentPage) {
- this.page.currentPage = currentPage
- },
- /**
- * 页大小改变
- * @param {number} pageSize - 页大小
- */
- sizeChange(pageSize) {
- this.page.pageSize = pageSize
- },
- /**
- * 刷新
- */
- refreshChange() {
- this.onLoad(this.page, this.query)
- },
- /**
- * 查看详情
- * @param {Object} row - 行数据
- */
- async handleDetail(row) {
- try {
- const res = await getClaimDetail(row.id)
- this.claimDetail = res.data.data
- this.detailVisible = true
- } catch (error) {
- console.error('获取理赔详情失败:', error)
- this.$message.error('获取理赔详情失败')
- }
- },
- /**
- * 查看附件
- * @param {Object} row - 行数据
- */
- async handleAttachments(row) {
- try {
- this.attachmentLoading = true
- this.attachmentVisible = true
- const res = await getClaimAttachments(1, 1000, row.id)
- this.attachmentList = res.data.data.records || []
- } catch (error) {
- console.error('获取理赔附件失败:', error)
- this.$message.error('获取理赔附件失败')
- } finally {
- this.attachmentLoading = false
- }
- },
- /**
- * 查看审核记录
- * @param {Object} row - 行数据
- */
- async handleAudit(row) {
- try {
- this.currentClaimRow = row
- this.auditLoading = true
- this.auditVisible = true
- const res = await getClaimAuditList(1, 100, row.id)
- this.auditList = res.data.data.records || []
- } catch (error) {
- console.error('获取审核记录失败:', error)
- this.$message.error('获取审核记录失败')
- } finally {
- this.auditLoading = false
- }
- },
- /**
- * 新增审核记录
- */
- handleAddAudit() {
- this.auditFormMode = 'add'
- this.resetAuditForm()
- this.auditForm.claimId = this.currentClaimRow.id
- this.auditForm.claimNo = this.currentClaimRow.claimNo
- this.auditFormVisible = true
- },
- /**
- * 编辑审核记录
- * @param {Object} row - 审核记录数据
- */
- handleEditAudit(row) {
- this.auditFormMode = 'edit'
- this.auditForm = {
- id: row.id,
- claimId: row.claimId,
- claimNo: row.claimNo,
- auditResult: row.auditResult,
- auditAmount: row.auditAmount,
- reasonDetail: row.reasonDetail,
- auditorId: row.auditorId,
- auditorName: row.auditorName,
- auditTime: row.auditTime,
- feedbackChannel: row.feedbackChannel || '',
- feedbackDesc: row.feedbackDesc || '',
- feedbackTime: row.feedbackTime || '',
- appealStatus: row.appealStatus || 0,
- appealResult: row.appealResult || '',
- appealTime: row.appealTime || ''
- }
- this.auditFormVisible = true
- },
- /**
- * 删除审核记录
- * @param {Object} row - 审核记录数据
- */
- async handleDeleteAudit(row) {
- try {
- await this.$confirm('确定删除该审核记录吗?', '提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning'
- })
- await removeClaimAudit(row.id)
- this.$message.success('删除成功')
- this.refreshAuditList()
- } catch (error) {
- if (error !== 'cancel') {
- console.error('删除审核记录失败:', error)
- this.$message.error('删除审核记录失败')
- }
- }
- },
- /**
- * 保存审核记录
- */
- async handleSaveAudit() {
- try {
- const valid = await this.$refs.auditFormRef.validate()
- if (!valid) return
- this.auditFormLoading = true
- // 设置审核人ID(这里可以从用户信息中获取)
- if (!this.auditForm.auditorId) {
- this.auditForm.auditorId = 10001 // 默认审核人ID,实际应该从当前登录用户获取
- }
- if (this.auditFormMode === 'add') {
- await addClaimAudit(this.auditForm)
- this.$message.success('新增审核记录成功')
- } else {
- await updateClaimAudit(this.auditForm)
- this.$message.success('更新审核记录成功')
- }
- this.auditFormVisible = false
- this.refreshAuditList()
- } catch (error) {
- console.error('保存审核记录失败:', error)
- this.$message.error('保存审核记录失败')
- } finally {
- this.auditFormLoading = false
- }
- },
- /**
- * 重置审核表单
- */
- resetAuditForm() {
- this.auditForm = {
- id: null,
- claimId: null,
- claimNo: '',
- auditResult: null,
- auditAmount: 0,
- reasonDetail: '',
- auditorId: null,
- auditorName: '',
- auditTime: '',
- feedbackChannel: '',
- feedbackDesc: '',
- feedbackTime: '',
- appealStatus: 0,
- appealResult: '',
- appealTime: ''
- }
- this.$nextTick(() => {
- if (this.$refs.auditFormRef) {
- this.$refs.auditFormRef.clearValidate()
- }
- })
- },
- /**
- * 刷新审核记录列表
- */
- async refreshAuditList() {
- if (!this.currentClaimRow) return
- try {
- this.auditLoading = true
- const res = await getClaimAuditList(1, 100, this.currentClaimRow.id)
- this.auditList = res.data.data.records || []
- } catch (error) {
- console.error('刷新审核记录失败:', error)
- this.$message.error('刷新审核记录失败')
- } finally {
- this.auditLoading = false
- }
- },
- /**
- * 下载文件
- * @param {Object} file - 文件信息
- */
- downloadFile(file) {
- window.open(file.fileUrl)
- },
- /**
- * 判断文件是否为图片
- * @param {string} fileName - 文件名
- * @returns {boolean} 是否为图片
- */
- isImageFile(fileName) {
- if (!fileName) return false
- const imageExtensions = ['.jpg', '.jpeg', '.png', '.gif', '.bmp', '.webp', '.svg']
- const extension = fileName.toLowerCase().substring(fileName.lastIndexOf('.'))
- return imageExtensions.includes(extension)
- },
- /**
- * 判断文件是否为视频
- * @param {string} fileName - 文件名
- * @returns {boolean} 是否为视频
- */
- isVideoFile(fileName) {
- if (!fileName) return false
- const videoExtensions = ['.mp4', '.avi', '.mov', '.wmv', '.flv', '.webm', '.mkv']
- const extension = fileName.toLowerCase().substring(fileName.lastIndexOf('.'))
- return videoExtensions.includes(extension)
- },
- /**
- * 预览图片
- * @param {Object} file - 文件信息
- * @param {number} index - 当前图片索引
- */
- previewImage(file, index = 0) {
- if (this.isVideoFile(file.fileName)) {
- // 视频预览
- this.previewVideoUrl = file.fileUrl
- this.videoPreviewVisible = true
- } else if (this.isImageFile(file.fileName)) {
- // 图片预览
- const imageFiles = this.attachmentList.filter(item => this.isImageFile(item.fileName))
- this.previewImageList = imageFiles.map(item => item.fileUrl)
- this.currentPreviewIndex = imageFiles.findIndex(item => item.id === file.id)
- this.previewImageUrl = file.fileUrl
- this.imagePreviewVisible = true
- }
- },
- /**
- * 关闭图片预览
- */
- closeImagePreview() {
- this.imagePreviewVisible = false
- this.previewImageUrl = ''
- this.previewImageList = []
- this.currentPreviewIndex = 0
- },
- /**
- * 关闭视频预览
- */
- closeVideoPreview() {
- this.videoPreviewVisible = false
- this.previewVideoUrl = ''
- },
- /**
- * 处理图片加载错误
- * @param {Event} event - 错误事件
- */
- handleImageError(event) {
- event.target.src = 'data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNDAiIGhlaWdodD0iNDAiIHZpZXdCb3g9IjAgMCA0MCA0MCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHJlY3Qgd2lkdGg9IjQwIiBoZWlnaHQ9IjQwIiBmaWxsPSIjRjVGNUY1Ii8+CjxwYXRoIGQ9Ik0yMCAyNkM5LjUgMjYgMSAxNy41IDEgN0MxIDMuNSA0IDEgNyAxSDMzQzM2IDEgMzkgMy41IDM5IDdDMzkgMTcuNSAzMC41IDI2IDIwIDI2WiIgZmlsbD0iI0NDQ0NDQyIvPgo8L3N2Zz4K'
- },
- // 添加公共方法引用
- formatFileSize,
- /**
- * 获取审核状态类型
- * @param {number} status - 审核状态
- * @returns {string} 状态类型
- */
- getAuditStatusType(status) {
- const typeMap = {
- 0: 'warning',
- 1: 'success',
- 2: 'danger'
- }
- return typeMap[status] || 'info'
- },
- /**
- * 获取审核状态文本
- * @param {number} status - 审核状态
- * @returns {string} 状态文本
- */
- getAuditStatusText(status) {
- const textMap = {
- 0: '待审核',
- 1: '审核通过',
- 2: '审核拒绝'
- }
- return textMap[status] || '未知'
- },
- /**
- * 获取审核结果类型
- * @param {number} result - 审核结果
- * @returns {string} 结果类型
- */
- getAuditResultType(result) {
- const typeMap = {
- 1: 'success',
- 2: 'danger'
- }
- return typeMap[result] || 'info'
- },
- /**
- * 处理视频加载错误
- * @param {Event} event - 错误事件
- */
- handleVideoError(event) {
- console.error('视频加载失败:', event)
- this.$message.error('视频加载失败,请检查视频文件')
- },
- /**
- * 获取审核结果文本
- * @param {number} result - 审核结果
- * @returns {string} 结果文本
- */
- getAuditResultText(result) {
- const textMap = {
- 1: '通过',
- 2: '拒绝'
- }
- return textMap[result] || '未知'
- }
- }
- }
|