diff --git a/api/modules/exhibit.js b/api/modules/exhibit.js index 2ceccb2..5af8ef2 100644 --- a/api/modules/exhibit.js +++ b/api/modules/exhibit.js @@ -35,6 +35,7 @@ export default { url: '/showpiece/addMaintenance', method: 'POST', data, + showLoading: true, needToken: true }) }, @@ -48,5 +49,45 @@ export default { }) }, - // chakan -} \ No newline at end of file + // 报修- 新增报修单 + async addMalfunction(data) { + return http({ + url: '/showpiece/addMalfunction', + method: 'POST', + data, + showLoading: true, + needToken: true + }) + }, + + // 查看保修单详情 + async queryMalfunctionById(data) { + return http({ + url: '/showpiece/queryMalfunctionById', + method: 'GET', + data + }) + }, + + // 修改保修单 + async updateMalfunction(data) { + return http({ + url: '/showpiece/updateMalfunction', + method: 'POST', + data, + showLoading: true, + needToken: true + }) + }, + + // 新增维修记录 + async addRepair(data) { + return http({ + url: '/showpiece/addRepair', + method: 'POST', + data, + showLoading: true, + needToken: true + }) + } +} diff --git a/pages/index/maintain.vue b/pages/index/maintain.vue index 24cf5ab..830973a 100644 --- a/pages/index/maintain.vue +++ b/pages/index/maintain.vue @@ -116,7 +116,6 @@ export default { mixinListApi: 'exhibit.queryMalfunctionList', urgencyColumns: [ [ - '一般', '紧急', '非常紧急' diff --git a/subPages/home/repairSubmit.vue b/subPages/home/repairSubmit.vue index b5d3b9d..29fef75 100644 --- a/subPages/home/repairSubmit.vue +++ b/subPages/home/repairSubmit.vue @@ -11,16 +11,19 @@ - + 报修日期 - {{ repairDate }} + + {{ malfunctionDate || '请选择' }} + + 故障紧急程度 - {{ urgencyLevel || '请选择' }} + {{ urgency.label || '请选择' }} @@ -34,7 +37,7 @@ 故障情况 - {{ faultSituation || '请选择' }} + {{ malfunctionStatus.label || '请选择' }} @@ -45,7 +48,7 @@ 故障图片 - + @@ -72,10 +75,10 @@ - + 故障首次发生时间 - {{ firstOccurTime || '请选择' }} + {{ firstDate || '请选择' }} @@ -103,7 +106,7 @@ --> 是否影响使用 - {{ impactUsage || '请选择' }} + {{ isAffectUse.label || '请选择' }} @@ -132,7 +135,7 @@ - - + + - - + + - - + + - - + + @@ -231,6 +234,7 @@ confirm-color="#C70019" ref="urgencyPicker" :columns="urgencyColumns" + keyName="label" @confirm="confirmUrgency" @cancel="cancelUrgency" > @@ -243,21 +247,31 @@ @cancel="cancelFault" > - + + + + + @@ -266,41 +280,56 @@ export default { data() { return { // 表单数据 - repairDate: '2025/03/31', - urgencyLevel: '', - faultSituation: '', - faultDescription: '', - imageList: [], - firstOccurTime: '', - frequency: '', - faultCondition: '', - impactUsage: '', - temporaryMeasures: '', - hasTakenMeasures: null, - impactExperience: null, + malfunctionDate: '', + urgency: '', + malfunctionStatus: '', + malfunctionDesc: '', + malfunctionImage: [], + firstDate: '', + frequency: '1', + reason: '', + isAffectUse: '0', + malfunctionName: '', + isMeasure: '0', + isAffectExperience: '0', remark: '', - - // 选择器显示状态(保留用于其他可能的用途) - // showUrgency: false, - // showFault: false, - // showTime: false, - // showImpact: false, + showpieceId: '', + // 频率选项 frequencyOptions: [ - { label: '持续性问题', value: 'continuous' }, - { label: '间歇性问题', value: 'intermittent' } + { label: '持续性问题', value: '0' }, + { label: '间歇性问题', value: '1' } ], // 选择器数据 - urgencyColumns: [['一般', '紧急', '非常紧急']], + urgencyColumns: [ + [ + { label: '一般', value: '0' }, + { label: '紧急', value: '1'} + ] + ], + faultColumns: [['硬件故障', '软件故障', '网络故障', '其他']], - timeColumns: [['今天', '昨天', '一周内', '一个月内', '更早']], - impactColumns: [['是', '否']] + impactColumns: [[ + { label: '是', value: '1' }, + { label: '否', value: '0' } + ]], } }, methods: { + // 显示日期选择器 + showDatePicker() { + this.$refs.datePicker.open() + }, + + // 确认日期选择 + confirmDate(e) { + const date = new Date(e.value) + this.malfunctionDate = `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, '0')}-${String(date.getDate()).padStart(2, '0')}` + }, + // 显示紧急程度选择器 showUrgencyPicker() { this.$refs.urgencyPicker.open() @@ -308,7 +337,7 @@ export default { // 确认紧急程度 confirmUrgency(e) { - this.urgencyLevel = e.value[0] + this.urgency = e.value[0] }, // 取消紧急程度选择 @@ -323,7 +352,7 @@ export default { // 确认故障情况 confirmFault(e) { - this.faultSituation = e.value[0] + this.malfunctionStatus = e.value[0] }, // 取消故障情况选择 @@ -331,19 +360,15 @@ export default { // 取消操作 }, - // 显示时间选择器 - showTimePicker() { - this.$refs.timePicker.open() - }, - - // 确认时间 - confirmTime(e) { - this.firstOccurTime = e.value[0] + // 显示故障首次发生时间选择器 + showFirstOccurTimePicker() { + this.$refs.firstOccurTimePicker.open() }, - // 取消时间选择 - cancelTime() { - // 取消操作 + // 确认故障首次发生时间 + confirmFirstOccurTime(e) { + const date = new Date(e.value) + this.firstDate = `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, '0')}-${String(date.getDate()).padStart(2, '0')}` }, // 显示影响使用选择器 @@ -353,7 +378,7 @@ export default { // 确认影响使用 confirmImpact(e) { - this.impactUsage = e.value[0] + this.isAffectUse = e.value[0] }, // 取消影响使用选择 @@ -368,12 +393,12 @@ export default { // 选择是否采取措施 selectMeasures(value) { - this.hasTakenMeasures = value + this.isMeasure = value }, // 选择是否影响体验 selectExperience(value) { - this.impactExperience = value + this.isAffectExperience = value }, // 上传图片 @@ -383,7 +408,7 @@ export default { if (result && result.success) { console.log(result); - this.imageList.push(result.url) + this.malfunctionImage.push(result.url) } } catch (error) { console.error('头像上传失败:', error) @@ -396,58 +421,66 @@ export default { // 删除图片 deleteImage(index) { - this.imageList.splice(index, 1) + this.malfunctionImage.splice(index, 1) }, // 预览图片 previewImage(url) { uni.previewImage({ - urls: this.imageList, + urls: this.malfunctionImage, current: url }) }, // 提交报修 - submitRepair() { + async submitRepair() { // 表单验证 - if (!this.urgencyLevel) { + if (!this.urgency) { uni.showToast({ title: '请选择故障紧急程度', icon: 'none' }) return } - if (!this.faultSituation) { - uni.showToast({ title: '请选择故障情况', icon: 'none' }) - return - } - if (!this.faultDescription.trim()) { + // if (!this.malfunctionStatus) { + // uni.showToast({ title: '请选择故障情况', icon: 'none' }) + // return + // } + if (!this.malfunctionDesc.trim()) { uni.showToast({ title: '请填写故障情况描述', icon: 'none' }) return } // 提交数据 const formData = { - repairDate: this.repairDate, - urgencyLevel: this.urgencyLevel, - faultSituation: this.faultSituation, - faultDescription: this.faultDescription, - imageList: this.imageList, - firstOccurTime: this.firstOccurTime, + showpieceId: this.showpieceId, + malfunctionDate: this.malfunctionDate, + urgency: this.urgency.value, + malfunctionStatus: this.malfunctionStatus.id, + malfunctionDesc: this.malfunctionDesc, + malfunctionImage: this.malfunctionImage.join(','), + firstDate: this.firstDate, frequency: this.frequency, - faultCondition: this.faultCondition, - impactUsage: this.impactUsage, - temporaryMeasures: this.temporaryMeasures, - hasTakenMeasures: this.hasTakenMeasures, - impactExperience: this.impactExperience, + reason: this.reason, + isAffectUse: this.isAffectUse.value, + malfunctionName: this.malfunctionName, + isMeasure: this.isMeasure, + isAffectExperience: this.isAffectExperience, remark: this.remark } - console.log('提交数据:', formData) - uni.showToast({ title: '提交成功', icon: 'success' }) - - // 返回上一页 - setTimeout(() => { - uni.navigateBack() - }, 1500) + // console.log('提交数据:', formData) + // uni.showToast({ title: '提交成功', icon: 'success' }) + const subRes = await this.$api.exhibit.addMalfunction(formData) + if (subRes.code === 200) { + uni.showToast({ title: subRes.message}) + setTimeout(() => { + uni.navigateBack() + }, 1000) + }else{ + uni.showToast({ title: subRes.message, icon: 'none' }) + } } + }, + onLoad(args) { + this.showpieceId = args.id } } diff --git a/subPages/repair/maintainSubmit.vue b/subPages/repair/maintainSubmit.vue index 217ec58..e8ce08a 100644 --- a/subPages/repair/maintainSubmit.vue +++ b/subPages/repair/maintainSubmit.vue @@ -12,7 +12,7 @@ - @@ -27,13 +27,13 @@ 报修日期 - {{ repairData.repairDate }} + {{ repairData.malfunctionDate }} 故障紧急程度 - {{ repairData.urgencyLevel }} + {{ repairData.urgency === '1' ? '紧急' : '一般' }} @@ -43,9 +43,8 @@ - 故障首次发生时间 - {{ repairData.firstOccurTime }} + {{ repairData.firstDate }} 发生频率 - {{ repairData.frequency }} + {{ repairData.frequency === '1' ? '间歇性问题' : '持续性问题' }} - - + 是否影响使用 - {{ repairData.impactUsage }} + {{ repairData.isAffectUse === '1' ? '是' : '否' }} 是否采取临时措施 - {{ repairData.hasTakenMeasures ? '是' : '否' }} + {{ repairData.isTakeMeasure === '1' ? '是' : '否' }} - - - 是否影响体验 - {{ repairData.impactExperience ? '是' : '否' }} + {{ repairData.isAffectUsage === '1' ? '是' : '否' }} @@ -147,7 +138,7 @@ - + - + @@ -182,7 +173,7 @@ 维修人 联系方式 @@ -235,8 +225,8 @@ 上传图片 - - + + @@ -252,30 +242,31 @@ - - + + - - + + - + 产生费用 @@ -283,7 +274,7 @@ - + 费用名称 数量 @@ -333,19 +324,19 @@ - - + + - - + + @@ -378,13 +369,12 @@ - + > @@ -395,52 +385,165 @@ export default { statusType: 'modify', selectedStatus: '故障中', isCollapsed: true, - + id: '', + // 映射表 + statusMap: { + '故障中': '0', + '维修中': '1', + '已解决': '2' + }, // 报修基本信息(只读) repairData: { - repairDate: '2025/03/31', - urgencyLevel: '一般', - faultDescription: '展品故障情况', - imageList: [ - '/static/商城_商品2.png', - '/static/商城_商品2.png' - ], - firstOccurTime: '2025/03/31', - frequency: '持续性问题', - faultCondition: '故障发生频率的触发条件说明', - impactUsage: '是', - hasTakenMeasures: true, - temporaryMeasures: '已采取临时措施说明', - impactExperience: true, - remark: '备注信息' + malfunctionDate: '2025-08-28', // 从接口 malfunctionDate 字段获取 + urgency: '0', // 从接口 urgency 字段映射:0-一般,1-紧急,2-非常紧急 + malfunctionDesc: '故障描述', // 从接口 malfunctionDesc 字段获取 + malfunctionImage: '', // 从接口 malfunctionImage 字段获取(字符串格式,多张图片用逗号分隔) + firstDate: '2025-08-27', // 从接口 firstDate 字段获取 + frequency: '0', // 从接口 frequency 字段映射:0-偶发性,1-持续性 + reason: '发生频率触发条件', // 从接口 reason 字段获取 + isAffectUse: '0', // 从接口 isAffectUse 字段映射:0-否,1-是 + isMeasure: '0', // 从接口 isMeasure 字段映射:0-否,1-是 + measureDesc: '措施说明', // 从接口 measureDesc 字段获取 + isAffectExperience: '0', // 从接口 isAffectExperience 字段映射:0-否,1-是 + remark: '备注' // 从接口 remark 字段获取 }, // 处理内容(可编辑) processData: { - repairPerson: '', - contactPhone: '', + repairName: '', + phone: '', repairDate: '', - processContent: '', - imageList: [], - hasCost: null, - totalCost: '', + content: '', + image: '', + isExpend: '0', costDetails: [ { name: '', quantity: '', amount: '' } ], - isResolved: null, + isFix: '0', remark: '' }, - - // 日期选择器数据 - dateColumns: [] } }, - - onLoad() { - this.initDatePicker() + computed: { + // 计算总金额 + amount() { + return this.processData.costDetails.reduce((sum, item) => { + return sum + (Number(item.quantity) * Number(item.amount)) + }, 0) + } + }, + async onShow(){ + await this.getRepairDetail() + }, + onLoad(args){ + this.id = args.id }, - methods: { + // 修改状态 + async modifyStatus(){ + const res = await this.$api.exhibit.updateMalfunction({ + id: this.id, + status: this.statusMap[this.selectedStatus] + }) + if (res.code === 200) { + uni.showToast({ + title: '修改成功', + icon: 'success' + }) + } + }, + + // 获取报修详情 + async getRepairDetail() { + const queryRes = await this.$api.exhibit.queryMalfunctionById({ + malfunctionId: this.id + }) + if (queryRes.code === 200) { + this.repairData = queryRes.result + } + }, + // 立即维修 + async startRepair() { + // 验证必填项 + if (!this.processData.repairName) { + uni.showToast({ + title: '请输入维修人', + icon: 'none' + }) + return + } + + if (!this.processData.phone) { + uni.showToast({ + title: '请输入联系方式', + icon: 'none' + }) + return + } + + if (!this.processData.repairDate) { + uni.showToast({ + title: '请选择维修日期', + icon: 'none' + }) + return + } + + if (!this.processData.content) { + uni.showToast({ + title: '请输入处理内容', + icon: 'none' + }) + return + } + + if (this.processData.isFix === null) { + uni.showToast({ + title: '请选择问题是否解决', + icon: 'none' + }) + return + } + + if (this.processData.isExpend === '1') { + // 如果总金额为0则没有消费信息 + if (!this.amount) { + uni.showToast({ + title: '请添加费用明细', + icon: 'none' + }) + return + } + } + const tempData = {...this.processData} + const tempDataList = [...this.processData.costDetails] + const submitRes = await this.$api.exhibit.addRepair({ + id: this.id, + ...tempData, + amount: this.amount, + expenseList: tempDataList.map(item => `${item.name},${item.quantity},${item.amount}`).join(';') + }) + + if (submitRes.code === 200) { + uni.showToast({ + title: submitRes.message, + icon: 'none' + }) + }else { + uni.showToast({ + title: submitRes.message, + icon: 'none' + }) + } + }, + + // 获取图片列表 + getImageList(imageStr) { + if (!imageStr || typeof imageStr !== 'string') { + return [] + } + return imageStr.split(',').filter(img => img && img.trim()) + }, // 切换折叠状态 toggleCollapse() { this.isCollapsed = !this.isCollapsed @@ -461,38 +564,11 @@ export default { // 确认日期 confirmDate(e) { - const { indexs, value } = e - this.processData.repairDate = value.join('/') - }, - - // 取消日期选择 - cancelDate() { - // 取消选择 - }, - - // 初始化日期选择器 - initDatePicker() { - const currentYear = new Date().getFullYear() - const years = [] - const months = [] - const days = [] - - // 生成年份 - for (let i = currentYear - 10; i <= currentYear + 10; i++) { - years.push(i + '年') - } - - // 生成月份 - for (let i = 1; i <= 12; i++) { - months.push(i.toString().padStart(2, '0') + '月') - } - - // 生成日期 - for (let i = 1; i <= 31; i++) { - days.push(i.toString().padStart(2, '0') + '日') - } - - this.dateColumns = [years, months, days] + const date = new Date(e.value) + const year = date.getFullYear() + const month = String(date.getMonth() + 1).padStart(2, '0') + const day = String(date.getDate()).padStart(2, '0') + this.processData.repairDate = `${year}-${month}-${day}` }, // 上传图片 @@ -502,7 +578,12 @@ export default { if (result && result.success) { console.log(result); - this.processData.imageList.push(result.url) + // 将新图片URL添加到字符串中 + if (this.processData.image) { + this.processData.image += ',' + result.url + } else { + this.processData.image = result.url + } } } catch (error) { console.error('图片上传失败:', error) @@ -515,14 +596,16 @@ export default { // 删除图片 deleteImage(index) { - this.processData.imageList.splice(index, 1) + const imageList = this.getImageList(this.processData.image) + imageList.splice(index, 1) + this.processData.image = imageList.join(',') }, // 选择是否产生费用 selectCost(value) { - this.processData.hasCost = value + this.processData.isExpend = value if (!value) { - this.processData.totalCost = '' + this.processData.amount = 0 this.processData.costDetails = [{ name: '', quantity: '', amount: '' }] } }, @@ -539,81 +622,21 @@ export default { // 选择问题是否解决 selectResolved(value) { - this.processData.isResolved = value + this.processData.isFix = value }, // 显示状态选择器 showStatusPicker() { uni.showActionSheet({ - itemList: ['故障中', '维修中', '已完成', '暂停维修'], + itemList: ['故障中', '维修中', '已解决'], success: (res) => { - const statusList = ['故障中', '维修中', '已完成', '暂停维修'] + const statusList = ['故障中', '维修中', '已解决'] this.selectedStatus = statusList[res.tapIndex] } }) }, - // 立即维修 - startRepair() { - // 验证必填项 - if (!this.processData.repairPerson) { - uni.showToast({ - title: '请输入维修人', - icon: 'none' - }) - return - } - - if (!this.processData.contactPhone) { - uni.showToast({ - title: '请输入联系方式', - icon: 'none' - }) - return - } - - if (!this.processData.repairDate) { - uni.showToast({ - title: '请选择维修日期', - icon: 'none' - }) - return - } - - if (!this.processData.processContent) { - uni.showToast({ - title: '请输入处理内容', - icon: 'none' - }) - return - } - - if (this.processData.isResolved === null) { - uni.showToast({ - title: '请选择问题是否解决', - icon: 'none' - }) - return - } - - // 提交数据 - uni.showLoading({ - title: '提交中...' - }) - - // 模拟提交 - setTimeout(() => { - uni.hideLoading() - uni.showToast({ - title: '提交成功', - icon: 'success' - }) - - setTimeout(() => { - uni.navigateBack() - }, 1500) - }, 2000) - } + } }