补充数据库数据,修改分类栏内容

This commit is contained in:
2026-05-21 11:50:32 +08:00
parent b8b0b453e0
commit 7ba3d313be
32 changed files with 6657 additions and 1684 deletions

View File

@@ -1,84 +1,104 @@
<template>
<ServicePageScaffold title="异常上报" fallback-url="/pages/mall/delivery/orders/detail">
<ServicePanel title="异常类型" subtitle="高风险异常需立即提醒联系家属、调度或 120。">
<view class="type-grid">
<view v-for="item in exceptionTypes" :key="item.value" class="type-item" :class="currentType == item.value ? 'type-active' : ''" @click="currentType = item.value">
<text class="type-text">{{ item.label }}</text>
<view class="page">
<view class="card">
<text class="section-title">异常类型</text>
<view class="type-grid">
<view v-for="item in exceptionTypes" :key="item.value" class="type-item" :class="currentType == item.value ? 'type-active' : ''" @click="currentType = item.value">
<text class="type-text">{{ item.label }}</text>
</view>
</view>
</view>
</ServicePanel>
<ServicePanel title="异常说明" subtitle="说明必填,支持上传图片凭证。">
<textarea class="textarea" v-model="description" placeholder="请填写异常发生情况、现场处置动作和需要协同的事项"></textarea>
<button class="secondary-btn" @click="chooseImage">上传异常图片</button>
<text class="info-text">已选择图片:{{ images.length }} 张</text>
<text v-if="isHighRisk" class="risk-text">高风险异常:请同步联系家属/调度/120并保留处置留痕。</text>
</ServicePanel>
<button class="primary-btn" :disabled="submitting" @click="submitForm">{{ submitting ? '提交中...' : '提交异常' }}</button>
<view class="card">
<text class="section-title">异常说明</text>
<textarea class="textarea" v-model="description" placeholder="请填写异常说明"></textarea>
<input class="field" v-model="occurredAt" placeholder="发生时间,例如 2026-05-20 15:36" />
<input class="field" v-model="locationText" placeholder="当前位置 mock" />
<view class="switch-row"><text class="switch-label">需要平台介入</text><switch :checked="needPlatformIntervention" color="#1f7db4" @change="changePlatformIntervention" /></view>
<view class="switch-row"><text class="switch-label">申请取消订单</text><switch :checked="requestCancelOrder" color="#1f7db4" @change="changeCancelOrder" /></view>
<view class="switch-row"><text class="switch-label">申请改期</text><switch :checked="requestReschedule" color="#1f7db4" @change="changeReschedule" /></view>
<view class="mock-upload" @click="addMockImage"><text class="mock-upload-text">图片上传占位</text></view>
<text class="info-text">已添加图片占位:{{ imageCount }} 张</text>
</view>
<view class="action-row">
<view class="outline-btn" @click="goBack"><text class="outline-btn-text">返回详情</text></view>
<view class="primary-btn" @click="submitForm"><text class="primary-btn-text">提交异常</text></view>
</view>
</view>
</ServicePageScaffold>
</template>
<script setup lang="uts">
import { ref, computed } from 'vue'
import { ref } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
import ServicePageScaffold from '@/components/homeService/ServicePageScaffold.uvue'
import ServicePanel from '@/components/homeService/ServicePanel.uvue'
import { submitException } from '@/services/deliveryService.uts'
import { submitAbnormalReport } from '@/services/deliveryService.uts'
import { requireDeliveryAuth } from '@/utils/deliveryAuth.uts'
import { getDeliveryRouteParam } from '@/utils/deliveryRoute.uts'
const orderId = ref('')
const currentType = ref('cannot_contact_elder')
const currentType = ref('cannot_contact_user')
const description = ref('')
const images = ref([] as Array<string>)
const submitting = ref(false)
const occurredAt = ref(new Date().toISOString().replace('T', ' ').substring(0, 19))
const locationText = ref('当前位置 mock')
const needPlatformIntervention = ref(false)
const requestCancelOrder = ref(false)
const requestReschedule = ref(false)
const imageCount = ref(0)
const exceptionTypes = [
{ label: '无法联系老人', value: 'cannot_contact_elder' },
{ label: '无法入户', value: 'cannot_enter_home' },
{ label: '联系不上用户', value: 'cannot_contact_user' },
{ label: '用户不在家', value: 'user_not_home' },
{ label: '地址错误', value: 'wrong_address' },
{ label: '老人拒绝服务', value: 'elder_refuse_service' },
{ label: '家属要求改期', value: 'family_requests_reschedule' },
{ label: '现场存在安全风险', value: 'safety_risk' },
{ label: '老人身体异常', value: 'elder_health_abnormal' },
{ label: '家属不配合', value: 'family_uncooperative' },
{ label: '服务对象身体异常', value: 'elder_health_abnormal' },
{ label: '环境不适合服务', value: 'safety_risk' },
{ label: '超出服务范围', value: 'outside_service_scope' },
{ label: '服务人员无法继续服务', value: 'staff_cannot_continue' },
{ label: '突发疾病', value: 'emergency_illness' },
{ label: '服务项目无法完成', value: 'item_unavailable' },
{ label: '投诉纠纷', value: 'complaint_dispute' },
{ label: '其他', value: 'other' }
]
const isHighRisk = computed(() => currentType.value == 'safety_risk' || currentType.value == 'elder_health_abnormal' || currentType.value == 'emergency_illness')
function wrapChooseImage(): Promise<Array<string>> {
return new Promise((resolve, reject) => {
uni.chooseImage({
count: 3,
sourceType: ['camera', 'album'],
success: (res) => { resolve(res.tempFilePaths) },
fail: () => { reject(new Error('选择图片失败')) }
})
})
function changePlatformIntervention(event: any) {
needPlatformIntervention.value = event.detail.value === true
}
async function chooseImage() {
try {
images.value = await wrapChooseImage()
} catch (error) {
uni.showToast({ title: '图片选择失败', icon: 'none' })
}
function changeCancelOrder(event: any) {
requestCancelOrder.value = event.detail.value === true
}
function changeReschedule(event: any) {
requestReschedule.value = event.detail.value === true
}
function addMockImage() {
imageCount.value = imageCount.value + 1
uni.showToast({ title: '已添加图片占位', icon: 'success' })
}
async function submitForm() {
if (submitting.value) return
if (description.value.trim() == '') {
uni.showToast({ title: '异常说明不能为空', icon: 'none' })
uni.showToast({ title: '请填写异常说明', icon: 'none' })
return
}
submitting.value = true
try {
await submitException(orderId.value, { exceptionType: currentType.value as any, description: description.value.trim(), images: images.value })
uni.showToast({ title: '异常已上报', icon: 'success' })
uni.setStorageSync('delivery_orders_tab', 'exception')
uni.switchTab({ url: '/pages/mall/delivery/orders/index' })
} finally {
submitting.value = false
}
await submitAbnormalReport(orderId.value, {
exceptionType: currentType.value as any,
description: description.value,
images: imageCount.value > 0 ? ['mock-abnormal-image-' + String(imageCount.value)] : [] as Array<string>,
occurredAt: occurredAt.value,
locationText: locationText.value,
needPlatformIntervention: needPlatformIntervention.value,
requestCancelOrder: requestCancelOrder.value,
requestReschedule: requestReschedule.value
})
uni.showToast({ title: '异常已提交', icon: 'success' })
setTimeout(() => {
uni.redirectTo({ url: '/pages/mall/delivery/orders/detail?id=' + orderId.value })
}, 300)
}
function goBack() {
uni.redirectTo({ url: '/pages/mall/delivery/orders/detail?id=' + orderId.value })
}
onLoad(async (options) => {
@@ -93,6 +113,51 @@ onLoad(async (options) => {
</script>
<style scoped>
.page {
padding-bottom: 32rpx;
}
.card {
margin-bottom: 18rpx;
padding: 24rpx;
border-radius: 24rpx;
background-color: #ffffff;
box-shadow: 0 10rpx 24rpx rgba(15, 35, 55, 0.06);
}
.section-title,
.primary-btn-text,
.type-text {
font-weight: 700;
}
.section-title {
font-size: 30rpx;
color: #16324f;
}
.field,
.textarea {
margin-top: 16rpx;
padding: 0 20rpx;
border-radius: 18rpx;
background-color: #f4f8fb;
font-size: 26rpx;
color: #16324f;
box-sizing: border-box;
}
.field {
height: 84rpx;
}
.textarea {
width: 100%;
min-height: 180rpx;
padding-top: 20rpx;
padding-bottom: 20rpx;
}
.type-grid {
flex-direction: row;
flex-wrap: wrap;
@@ -102,13 +167,13 @@ onLoad(async (options) => {
.type-item {
width: 48%;
padding: 18rpx 16rpx;
margin-bottom: 16rpx;
margin-top: 16rpx;
border-radius: 18rpx;
background: #eef2f6;
}
.type-active {
background: #0f766e;
background: #1f7db4;
}
.type-text {
@@ -121,47 +186,54 @@ onLoad(async (options) => {
color: #ffffff;
}
.textarea {
width: 100%;
min-height: 220rpx;
padding: 24rpx;
border-radius: 20rpx;
background: #f2f7f6;
font-size: 28rpx;
box-sizing: border-box;
}
.secondary-btn,
.primary-btn {
margin-top: 18rpx;
border-radius: 18rpx;
font-size: 28rpx;
}
.secondary-btn {
background: #eaf2f0;
color: #0f766e;
}
.primary-btn {
background: #0f766e;
color: #ffffff;
.switch-row,
.action-row {
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
margin-top: 16rpx;
}
.switch-label,
.info-text,
.risk-text {
display: block;
margin-top: 12rpx;
.outline-btn-text {
font-size: 24rpx;
line-height: 36rpx;
}
.info-text {
color: #5e758c;
}
.risk-text {
color: #b45309;
font-weight: 700;
.mock-upload,
.outline-btn,
.primary-btn {
margin-top: 18rpx;
padding: 18rpx 0;
border-radius: 18rpx;
align-items: center;
justify-content: center;
}
.mock-upload,
.outline-btn {
background: #eaf2f0;
}
.mock-upload-text,
.outline-btn-text {
font-size: 26rpx;
color: #176e97;
}
.outline-btn,
.primary-btn {
width: 48%;
}
.primary-btn {
background: #1f7db4;
}
.primary-btn-text {
font-size: 26rpx;
color: #ffffff;
}
</style>