feat(miniprogram): add driver-plan list and receipt pages
Wire workbench menu, login APIs, calendar list without plate search, and native receipt detail aligned with site-plan shell. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
7f9be18ab6
commit
74ed4ba534
7 files changed
+973
-14
No files matched your search
@@ -0,0 +1,91 @@
|
||||
/**
|
||||
* 运输加油登记 API(复用门户 /transport/vehicle-fuel-register)
|
||||
*/
|
||||
import db from '@/utils/dbRequest'
|
||||
import { fetchVehicleOptions } from '@/api/dbOptions'
|
||||
|
||||
function unwrapList(data) {
|
||||
if (!data || typeof data !== 'object') {
|
||||
return { items: [], total: 0 }
|
||||
}
|
||||
// 兼容门户信封 { code, data: { items, total } }
|
||||
const payload =
|
||||
data.data && typeof data.data === 'object' && data.items == null
|
||||
? data.data
|
||||
: data
|
||||
const items = payload.items || payload.rows || payload.list || []
|
||||
const total = Number(payload.total || 0)
|
||||
return { items: Array.isArray(items) ? items : [], total }
|
||||
}
|
||||
|
||||
function unwrapEntity(data) {
|
||||
if (!data || typeof data !== 'object') return data
|
||||
if (data.data && typeof data.data === 'object' && data.id == null && data.registerNo == null) {
|
||||
return data.data
|
||||
}
|
||||
return data
|
||||
}
|
||||
|
||||
export const fuelRegisterApi = {
|
||||
list: async (params = {}) => {
|
||||
const data = await db.get('/transport/vehicle-fuel-register/', {
|
||||
mineOnly: true,
|
||||
...params
|
||||
})
|
||||
return unwrapList(data)
|
||||
},
|
||||
get: async (id) => unwrapEntity(await db.get(`/transport/vehicle-fuel-register/${id}`)),
|
||||
create: (payload) =>
|
||||
db.post('/transport/vehicle-fuel-register/', payload, {
|
||||
params: { mineOnly: true }
|
||||
}),
|
||||
update: (id, payload) =>
|
||||
db.put(`/transport/vehicle-fuel-register/${id}`, payload, {
|
||||
params: { mineOnly: true }
|
||||
}),
|
||||
cancel: (id) =>
|
||||
db.post(
|
||||
`/transport/vehicle-fuel-register/${id}/cancel`,
|
||||
{},
|
||||
{ params: { mineOnly: true } }
|
||||
)
|
||||
}
|
||||
|
||||
function unwrapData(data) {
|
||||
if (!data || typeof data !== 'object') return data
|
||||
if (data.code != null && data.data !== undefined) return data.data
|
||||
return data
|
||||
}
|
||||
|
||||
export const sitePlanApi = {
|
||||
history: async (params = {}) => {
|
||||
const data = unwrapData(await db.get('/transport/site-plan/history', params))
|
||||
return {
|
||||
date: data?.date || params.date,
|
||||
keyword: data?.keyword || '',
|
||||
records: Array.isArray(data?.records) ? data.records : []
|
||||
}
|
||||
},
|
||||
get: async (planId) => unwrapData(await db.get(`/transport/site-plan/${planId}`)),
|
||||
saveFeedback: (planId, payload) =>
|
||||
db.post(`/transport/site-plan/${planId}/feedback`, payload)
|
||||
}
|
||||
|
||||
export const driverPlanApi = {
|
||||
history: async (params = {}) => {
|
||||
const data = unwrapData(await db.get('/transport/driver-plan/history', params))
|
||||
return {
|
||||
date: data?.date || params.date,
|
||||
records: Array.isArray(data?.records) ? data.records : []
|
||||
}
|
||||
},
|
||||
get: async (planId) => unwrapData(await db.get(`/transport/driver-plan/${planId}`)),
|
||||
saveFeedback: (planId, payload) =>
|
||||
db.post(`/transport/driver-plan/${planId}/feedback`, payload),
|
||||
saveDriverFeedback: (planId, payload) =>
|
||||
db.post(`/transport/driver-plan/${planId}/driver-feedback`, payload)
|
||||
}
|
||||
|
||||
export { fetchVehicleOptions }
|
||||
|
||||
export default fuelRegisterApi
|
||||
@@ -63,7 +63,13 @@ export const PAGE_PATHS = {
|
||||
bxInvoiceAdmin: '/pages/bx/invoice/admin',
|
||||
bxExpenseItem: '/pages/bx/admin/expense-item',
|
||||
bxWfAdvance: '/pages/bx/admin/wf-advance',
|
||||
bxWfReimburse: '/pages/bx/admin/wf-reimburse'
|
||||
bxWfReimburse: '/pages/bx/admin/wf-reimburse',
|
||||
plFuelRegister: '/pages/pl/fuel-register/list',
|
||||
plFuelRegisterForm: '/pages/pl/fuel-register/form',
|
||||
plTransportPlan: '/pages/pl/transport-plan/list',
|
||||
plTransportPlanDetail: '/pages/pl/transport-plan/detail',
|
||||
plDriverPlan: '/pages/pl/driver-plan/list',
|
||||
plDriverPlanDetail: '/pages/pl/driver-plan/detail'
|
||||
}
|
||||
|
||||
/** 工作台菜单 code → 页面路径 */
|
||||
@@ -80,7 +86,10 @@ export const WORKBENCH_ROUTE_MAP = {
|
||||
'bx-invoice-admin': PAGE_PATHS.bxInvoiceAdmin,
|
||||
'bx-expense-item': PAGE_PATHS.bxExpenseItem,
|
||||
'bx-wf-advance': PAGE_PATHS.bxWfAdvance,
|
||||
'bx-wf-reimburse': PAGE_PATHS.bxWfReimburse
|
||||
'bx-wf-reimburse': PAGE_PATHS.bxWfReimburse,
|
||||
'pl-fuel-register': PAGE_PATHS.plFuelRegister,
|
||||
'pl-transport-plan': PAGE_PATHS.plTransportPlan,
|
||||
'pl-driver-plan': PAGE_PATHS.plDriverPlan
|
||||
}
|
||||
|
||||
export const TOKEN_KEY = 'sx_token'
|
||||
|
||||
@@ -56,19 +56,31 @@ export const WORKBENCH_MODULES = [
|
||||
{
|
||||
key: 'pl',
|
||||
title: '运输管理',
|
||||
desc: '计划 · 运费 · 车辆事务',
|
||||
desc: '加油登记 · 运输计划单 · 司机运输计划单',
|
||||
iconText: '运输',
|
||||
visible: false,
|
||||
visible: true,
|
||||
menus: [
|
||||
{ name: '运输计划', enabled: false, code: 'pl-plan', icon: '🚚' },
|
||||
{ name: '计划归档', enabled: false, code: 'pl-plan-archive', icon: '🗂️' },
|
||||
{ name: '购买证上传', enabled: false, code: 'pl-plan-cert', icon: '📜' },
|
||||
{ name: '运费结算', enabled: false, code: 'pl-freight', icon: '💵' },
|
||||
{ name: '运费审批', enabled: false, code: 'pl-freight-approval', icon: '🔏' },
|
||||
{ name: '财务发放', enabled: false, icon: '💰' },
|
||||
{ name: '车辆充值', enabled: false, icon: '⛽' },
|
||||
{ name: '车辆维修', enabled: false, icon: '🔧' },
|
||||
{ name: '运输地址库', enabled: false, icon: '📍' }
|
||||
{
|
||||
name: '加油登记',
|
||||
enabled: true,
|
||||
code: 'pl-fuel-register',
|
||||
icon: '⛽',
|
||||
perms: 'mini:pl:fuelRegister:list'
|
||||
},
|
||||
{
|
||||
name: '运输计划单',
|
||||
enabled: true,
|
||||
code: 'pl-transport-plan',
|
||||
icon: '📋',
|
||||
perms: 'mini:pl:transportPlan:list'
|
||||
},
|
||||
{
|
||||
name: '司机运输计划单',
|
||||
enabled: true,
|
||||
code: 'pl-driver-plan',
|
||||
icon: '🚛',
|
||||
perms: 'mini:pl:driverPlan:list'
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
+31
-1
@@ -172,12 +172,42 @@
|
||||
"style": { "navigationStyle": "custom", "navigationBarTitleText": "工作流(报销)" }
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"root": "pages/pl",
|
||||
"name": "pl",
|
||||
"pages": [
|
||||
{
|
||||
"path": "fuel-register/list",
|
||||
"style": { "navigationStyle": "custom", "navigationBarTitleText": "加油登记" }
|
||||
},
|
||||
{
|
||||
"path": "fuel-register/form",
|
||||
"style": { "navigationStyle": "custom", "navigationBarTitleText": "加油登记" }
|
||||
},
|
||||
{
|
||||
"path": "transport-plan/list",
|
||||
"style": { "navigationStyle": "custom", "navigationBarTitleText": "运输计划单" }
|
||||
},
|
||||
{
|
||||
"path": "transport-plan/detail",
|
||||
"style": { "navigationStyle": "custom", "navigationBarTitleText": "现场回传" }
|
||||
},
|
||||
{
|
||||
"path": "driver-plan/list",
|
||||
"style": { "navigationStyle": "custom", "navigationBarTitleText": "司机运输计划单" }
|
||||
},
|
||||
{
|
||||
"path": "driver-plan/detail",
|
||||
"style": { "navigationStyle": "custom", "navigationBarTitleText": "司机回执" }
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"preloadRule": {
|
||||
"pages/workbench/workbench": {
|
||||
"network": "all",
|
||||
"packages": ["db", "bx"]
|
||||
"packages": ["db", "bx", "pl"]
|
||||
}
|
||||
},
|
||||
"globalStyle": {
|
||||
|
||||
@@ -0,0 +1,324 @@
|
||||
<template>
|
||||
<view class="bx-page pl-driver-plan-page pl-driver-plan-detail">
|
||||
<view class="topbar" :style="safeAreaStyle">
|
||||
<view class="topbar-left">
|
||||
<text class="topbar-back" @click="goBack">←</text>
|
||||
<text class="topbar-title">司机回执</text>
|
||||
</view>
|
||||
<view class="topbar-right" />
|
||||
</view>
|
||||
|
||||
<view v-if="loading" class="page-loading">加载中...</view>
|
||||
<view v-else-if="errorMessage" class="empty-hint">{{ errorMessage }}</view>
|
||||
<view v-else-if="page?.planVoided" class="empty-hint">运输计划已作废</view>
|
||||
<view v-else-if="page?.planArchived" class="empty-hint">运输计划已归档完成</view>
|
||||
<template v-else-if="page">
|
||||
<view class="section-card">
|
||||
<view class="kv-row">
|
||||
<text class="kv-k">计划编号</text>
|
||||
<text class="kv-v">{{ page.planNo || '—' }}</text>
|
||||
</view>
|
||||
<view class="kv-row">
|
||||
<text class="kv-k">计划日期</text>
|
||||
<text class="kv-v">{{ page.planDate || '—' }}</text>
|
||||
</view>
|
||||
<view class="kv-row">
|
||||
<text class="kv-k">车牌</text>
|
||||
<text class="kv-v">{{ page.licensePlate || '—' }}</text>
|
||||
</view>
|
||||
<view class="kv-row">
|
||||
<text class="kv-k">司机</text>
|
||||
<text class="kv-v">{{ page.driverName || '—' }} {{ page.driverPhone || '' }}</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view
|
||||
v-for="stop in stopStates"
|
||||
:key="`${stop.stopType}-${stop.stopId}`"
|
||||
class="section-card"
|
||||
>
|
||||
<view class="stop-title"
|
||||
>{{ stop.label }} · {{ stop.customerName || '—'
|
||||
}}<text v-if="stop.businessType" class="meta">({{ stop.businessType }})</text></view
|
||||
>
|
||||
|
||||
<view class="kv-row">
|
||||
<text class="kv-k">地址</text>
|
||||
<view class="addr-row kv-v">
|
||||
<text>{{ stop.address || '—' }}</text>
|
||||
<text v-if="canNavigate(stop)" class="nav-btn" @click="openNavigation(stop)"
|
||||
>导航</text
|
||||
>
|
||||
</view>
|
||||
</view>
|
||||
<view class="kv-row">
|
||||
<text class="kv-k">联系方式</text>
|
||||
<text class="kv-v">{{ stop.contact || '—' }}</text>
|
||||
</view>
|
||||
<view class="kv-row">
|
||||
<text class="kv-k">注意事项</text>
|
||||
<text class="kv-v">{{ stop.notes || '—' }}</text>
|
||||
</view>
|
||||
|
||||
<view v-for="(item, idx) in stop.products || []" :key="item.stopProductId || idx" class="product-card">
|
||||
<view class="product-name"
|
||||
>{{ idx + 1 }}/{{ (stop.products || []).length }} {{ item.productName || '产品' }}</view
|
||||
>
|
||||
<view class="meta">计划:{{ formatPlanQty(item) }}</view>
|
||||
<view class="meta">规格型号:{{ item.model || '—' }}</view>
|
||||
<view class="meta">包装规格:{{ item.packageSpec || '—' }}</view>
|
||||
<view v-if="stop.showProductQty && !readonly" class="actual-box">
|
||||
<view class="actual-label">实际数量</view>
|
||||
<view class="actual-row">
|
||||
<input
|
||||
class="actual-input"
|
||||
type="digit"
|
||||
v-model="item.actualQtyText"
|
||||
placeholder="请输入"
|
||||
/>
|
||||
<text>{{ item.unit || '' }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="attach-label">附件上传</view>
|
||||
<view class="attach-row">
|
||||
<image
|
||||
v-for="(url, i) in stop.attachmentUrls"
|
||||
:key="`${url}-${i}`"
|
||||
class="attach-thumb"
|
||||
:src="resolveFileUrl(url)"
|
||||
mode="aspectFill"
|
||||
@click="previewStopImages(stop, i)"
|
||||
@longpress="removeAttachment(stop, i)"
|
||||
/>
|
||||
<view
|
||||
v-if="!readonly && stop.attachmentUrls.length < 9"
|
||||
class="attach-add"
|
||||
@click="uploadForStop(stop)"
|
||||
>+</view
|
||||
>
|
||||
</view>
|
||||
|
||||
<textarea
|
||||
class="remark-input"
|
||||
v-model="stop.remark"
|
||||
:disabled="readonly"
|
||||
maxlength="500"
|
||||
placeholder="填写备注(可选)"
|
||||
/>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<view v-if="page && !errorMessage && !loading" class="page-footer">
|
||||
<view class="footer-btn footer-btn--ghost" @click="goList">运输记录</view>
|
||||
<view
|
||||
v-if="(page.stops || []).length && !readonly"
|
||||
class="footer-btn footer-btn--primary"
|
||||
@click="handleSave"
|
||||
>{{ saving ? '保存中...' : '保存回执' }}</view
|
||||
>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed, ref } from 'vue'
|
||||
import { onLoad } from '@dcloudio/uni-app'
|
||||
import { API_BASE, PAGE_PATHS, TOKEN_KEY } from '@/config/api'
|
||||
import { MINIO_BASE_URL } from '@/config/env'
|
||||
import { driverPlanApi } from '@/api/pl'
|
||||
import { getSafeAreaStyle } from '@/utils/safeArea'
|
||||
import { previewImages } from '@/utils/upload'
|
||||
|
||||
import '@/styles/bx-theme.scss'
|
||||
import '@/styles/pl-driver-plan.scss'
|
||||
|
||||
const safeAreaStyle = getSafeAreaStyle()
|
||||
const planId = ref('')
|
||||
const page = ref(null)
|
||||
const stopStates = ref([])
|
||||
const loading = ref(true)
|
||||
const saving = ref(false)
|
||||
const errorMessage = ref('')
|
||||
|
||||
const readonly = computed(() => !!(page.value?.planVoided || page.value?.planArchived))
|
||||
|
||||
function formatPlanQty(item) {
|
||||
const qty = item.planQty != null ? item.planQty : item.quantity
|
||||
const unit = item.unit || ''
|
||||
if (qty == null) return '—'
|
||||
return unit ? `${qty} ${unit}` : String(qty)
|
||||
}
|
||||
|
||||
function canNavigate(stop) {
|
||||
return stop.lng != null && stop.lat != null
|
||||
}
|
||||
|
||||
function openNavigation(stop) {
|
||||
const lat = Number(stop.lat)
|
||||
const lng = Number(stop.lng)
|
||||
if (Number.isNaN(lat) || Number.isNaN(lng)) return
|
||||
uni.openLocation({
|
||||
latitude: lat,
|
||||
longitude: lng,
|
||||
name: stop.label || '目的地',
|
||||
address: stop.address || '',
|
||||
fail: () => uni.showToast({ title: '无法打开导航', icon: 'none' })
|
||||
})
|
||||
}
|
||||
|
||||
function resolveFileUrl(url) {
|
||||
if (!url) return ''
|
||||
if (/^https?:\/\//i.test(url)) return url
|
||||
const base = String(MINIO_BASE_URL || '').replace(/\/$/, '')
|
||||
return base ? `${base}/${String(url).replace(/^\//, '')}` : url
|
||||
}
|
||||
|
||||
function previewStopImages(stop, index) {
|
||||
const urls = (stop.attachmentUrls || []).map(resolveFileUrl)
|
||||
previewImages(urls, urls[index])
|
||||
}
|
||||
|
||||
function removeAttachment(stop, index) {
|
||||
if (readonly.value) return
|
||||
uni.showModal({
|
||||
title: '删除附件',
|
||||
content: '确定删除该附件吗?',
|
||||
success: (res) => {
|
||||
if (res.confirm) stop.attachmentUrls.splice(index, 1)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
async function uploadForStop(stop) {
|
||||
if (readonly.value) return
|
||||
const remain = 9 - (stop.attachmentUrls?.length || 0)
|
||||
if (remain <= 0) return
|
||||
|
||||
const choose = await new Promise((resolve) => {
|
||||
uni.chooseImage({
|
||||
count: remain,
|
||||
sizeType: ['compressed'],
|
||||
sourceType: ['album', 'camera'],
|
||||
success: resolve,
|
||||
fail: () => resolve(null)
|
||||
})
|
||||
})
|
||||
if (!choose?.tempFilePaths?.length) return
|
||||
|
||||
const token = uni.getStorageSync(TOKEN_KEY) || ''
|
||||
const uploadUrl = `${API_BASE}/transport/driver-plan/${planId.value}/attachments`
|
||||
uni.showLoading({ title: '上传中...' })
|
||||
try {
|
||||
for (const filePath of choose.tempFilePaths) {
|
||||
const uploadRes = await new Promise((ok, fail) => {
|
||||
uni.uploadFile({
|
||||
url: uploadUrl,
|
||||
filePath,
|
||||
name: 'file',
|
||||
header: { Authorization: token ? `Bearer ${token}` : '' },
|
||||
formData: { folder: 'pl/transport/driver-feedback' },
|
||||
success: ok,
|
||||
fail
|
||||
})
|
||||
})
|
||||
let body = {}
|
||||
try {
|
||||
body = JSON.parse(uploadRes.data || '{}')
|
||||
} catch (e) {
|
||||
body = {}
|
||||
}
|
||||
const data = body.data || {}
|
||||
const url = data.url || data.fileUrl || data.file_url
|
||||
if (body.code !== 200 && body.code !== 0) {
|
||||
uni.showToast({ title: body.message || '上传失败', icon: 'none' })
|
||||
break
|
||||
}
|
||||
if (!url) {
|
||||
uni.showToast({ title: body.message || '上传失败', icon: 'none' })
|
||||
break
|
||||
}
|
||||
stop.attachmentUrls.push(String(url))
|
||||
}
|
||||
} catch (e) {
|
||||
uni.showToast({ title: '上传失败', icon: 'none' })
|
||||
} finally {
|
||||
uni.hideLoading()
|
||||
}
|
||||
}
|
||||
|
||||
async function loadDetail() {
|
||||
if (!planId.value) {
|
||||
errorMessage.value = '缺少计划 ID'
|
||||
loading.value = false
|
||||
return
|
||||
}
|
||||
loading.value = true
|
||||
errorMessage.value = ''
|
||||
try {
|
||||
const data = await driverPlanApi.get(planId.value)
|
||||
page.value = data
|
||||
stopStates.value = (data.stops || []).map((s) => ({
|
||||
...s,
|
||||
remark: s.remark || '',
|
||||
attachmentUrls: [...(s.attachmentUrls || [])],
|
||||
products: (s.products || []).map((p) => ({
|
||||
...p,
|
||||
actualQtyText: p.actualQty != null ? String(p.actualQty) : ''
|
||||
}))
|
||||
}))
|
||||
} catch (e) {
|
||||
errorMessage.value = e?.message || '加载失败'
|
||||
page.value = null
|
||||
stopStates.value = []
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function handleSave() {
|
||||
if (readonly.value || saving.value) return
|
||||
if (!stopStates.value.length) return
|
||||
saving.value = true
|
||||
try {
|
||||
for (const stop of stopStates.value) {
|
||||
const products =
|
||||
stop.showProductQty
|
||||
? (stop.products || []).map((p) => ({
|
||||
stopProductId: p.stopProductId,
|
||||
actualQty: Number(p.actualQtyText || 0)
|
||||
}))
|
||||
: undefined
|
||||
await driverPlanApi.saveDriverFeedback(planId.value, {
|
||||
stopType: stop.stopType,
|
||||
stopId: stop.stopId,
|
||||
attachmentUrls: stop.attachmentUrls,
|
||||
remark: (stop.remark || '').trim() || undefined,
|
||||
products
|
||||
})
|
||||
}
|
||||
uni.showToast({ title: '保存成功', icon: 'success' })
|
||||
await loadDetail()
|
||||
} catch (e) {
|
||||
// dbRequest already toasted
|
||||
} finally {
|
||||
saving.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function goList() {
|
||||
uni.navigateBack({
|
||||
fail: () => uni.redirectTo({ url: PAGE_PATHS.plDriverPlan })
|
||||
})
|
||||
}
|
||||
|
||||
function goBack() {
|
||||
goList()
|
||||
}
|
||||
|
||||
onLoad((q) => {
|
||||
planId.value = (q && q.planId) || ''
|
||||
loadDetail()
|
||||
})
|
||||
</script>
|
||||
@@ -0,0 +1,177 @@
|
||||
<template>
|
||||
<view class="bx-page pl-driver-plan-page">
|
||||
<view class="topbar" :style="safeAreaStyle">
|
||||
<view class="topbar-left">
|
||||
<text class="topbar-back" @click="goBack">←</text>
|
||||
<text class="topbar-title">司机运输计划单</text>
|
||||
</view>
|
||||
<view class="topbar-right" />
|
||||
</view>
|
||||
|
||||
<view class="filters">
|
||||
<uni-calendar
|
||||
:insert="true"
|
||||
:date="selectedDate"
|
||||
:showMonth="false"
|
||||
@change="onCalendarChange"
|
||||
/>
|
||||
</view>
|
||||
|
||||
<view class="list-body">
|
||||
<view v-if="loading" class="page-loading">加载中...</view>
|
||||
<view v-else-if="!records.length" class="empty-hint">暂无运输记录</view>
|
||||
<view
|
||||
v-for="(row, index) in records"
|
||||
:key="row.planId || index"
|
||||
class="record-card"
|
||||
@click="openRecord(row)"
|
||||
>
|
||||
<text class="index-tag">{{ index + 1 }}</text>
|
||||
<view class="record-top">
|
||||
<text class="card-title">{{ cardTitle(row) }}</text>
|
||||
<text class="tag" :class="tagClass(row)">{{ row.statusLabel || '进行中' }}</text>
|
||||
</view>
|
||||
<view class="meta">
|
||||
车牌:<text class="plate-hl">{{ row.licensePlate || '—' }}</text>
|
||||
</view>
|
||||
<template v-if="(row.stops || []).length">
|
||||
<view
|
||||
v-for="(stop, sIndex) in row.stops"
|
||||
:key="`${stop.stopType}-${stop.seq ?? sIndex}`"
|
||||
class="stop-block"
|
||||
>
|
||||
<view class="stop-block__title"
|
||||
>{{ stop.label }} · {{ stop.customerName || '—' }}</view
|
||||
>
|
||||
<view class="meta">时间:{{ formatDay(stop.stopTime) }}</view>
|
||||
<view class="meta">地址:{{ stop.address || '—' }}</view>
|
||||
<template v-if="!(stop.products || []).length">
|
||||
<view class="meta">产品:—</view>
|
||||
</template>
|
||||
<template v-for="(prod, pIndex) in stop.products || []" :key="pIndex">
|
||||
<view class="meta">产品:{{ prod.productName || '—' }}</view>
|
||||
<view class="meta">规格型号:{{ prod.model || '—' }}</view>
|
||||
<view class="meta">包装规格:{{ prod.packageSpec || '—' }}</view>
|
||||
<view class="meta"
|
||||
>数量:{{ formatQty(prod.quantity) }} · 单位:{{ prod.unit || '—' }}</view
|
||||
>
|
||||
</template>
|
||||
</view>
|
||||
</template>
|
||||
<view class="meta">运输计划号:{{ row.planNo || '—' }}</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref } from 'vue'
|
||||
import { onShow } from '@dcloudio/uni-app'
|
||||
import { PAGE_PATHS } from '@/config/api'
|
||||
import { driverPlanApi } from '@/api/pl'
|
||||
import { getSafeAreaStyle } from '@/utils/safeArea'
|
||||
|
||||
import '@/styles/bx-theme.scss'
|
||||
import '@/styles/pl-driver-plan.scss'
|
||||
|
||||
const safeAreaStyle = getSafeAreaStyle()
|
||||
|
||||
function todayStr() {
|
||||
const d = new Date()
|
||||
const m = `${d.getMonth() + 1}`.padStart(2, '0')
|
||||
const day = `${d.getDate()}`.padStart(2, '0')
|
||||
return `${d.getFullYear()}-${m}-${day}`
|
||||
}
|
||||
|
||||
const selectedDate = ref(todayStr())
|
||||
const records = ref([])
|
||||
const loading = ref(false)
|
||||
|
||||
function formatDay(value) {
|
||||
if (!value) return '—'
|
||||
const normalized = String(value).replace('T', ' ')
|
||||
return normalized.length >= 10 ? normalized.slice(0, 10) : normalized
|
||||
}
|
||||
|
||||
function formatQty(value) {
|
||||
if (value == null || value === '') return '—'
|
||||
return String(value)
|
||||
}
|
||||
|
||||
function cardTitleDate(row) {
|
||||
const stopTimes = (row.stops || [])
|
||||
.map((stop) => formatDay(stop.stopTime))
|
||||
.filter((value) => value !== '—')
|
||||
if (stopTimes.length) return stopTimes[0]
|
||||
const fromPickup = formatDay(row.pickupTime)
|
||||
if (fromPickup !== '—') return fromPickup
|
||||
const fromDelivery = formatDay(row.deliveryTime)
|
||||
if (fromDelivery !== '—') return fromDelivery
|
||||
return selectedDate.value
|
||||
}
|
||||
|
||||
function cardTitle(row) {
|
||||
return cardTitleDate(row)
|
||||
}
|
||||
|
||||
function tagClass(row) {
|
||||
if (row.planVoided || row.statusLabel === '已作废') return 'tag--danger'
|
||||
if (row.planArchived || row.statusLabel === '已归档') return 'tag--muted'
|
||||
return 'tag--success'
|
||||
}
|
||||
|
||||
async function loadList() {
|
||||
loading.value = true
|
||||
try {
|
||||
const res = await driverPlanApi.history({ date: selectedDate.value })
|
||||
records.value = res.records || []
|
||||
} catch (e) {
|
||||
records.value = []
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function onCalendarChange(e) {
|
||||
const v = e?.fulldate || e?.date || (typeof e === 'string' ? e : '')
|
||||
if (typeof v === 'string' && /^\d{4}-\d{2}-\d{2}/.test(v)) {
|
||||
selectedDate.value = v.slice(0, 10)
|
||||
loadList()
|
||||
}
|
||||
}
|
||||
|
||||
function openRecord(row) {
|
||||
const id = row.planId || row.plan_id
|
||||
if (!id) {
|
||||
uni.showToast({ title: '计划无效', icon: 'none' })
|
||||
return
|
||||
}
|
||||
uni.navigateTo({ url: `${PAGE_PATHS.plDriverPlanDetail}?planId=${id}` })
|
||||
}
|
||||
|
||||
function goBack() {
|
||||
uni.navigateBack({ fail: () => uni.reLaunch({ url: PAGE_PATHS.workbench }) })
|
||||
}
|
||||
|
||||
onShow(() => {
|
||||
loadList()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
:deep(.uni-calendar-item--checked),
|
||||
:deep(.uni-calendar-item--isDay),
|
||||
:deep(.uni-calendar-item--multiple) {
|
||||
background-color: #0a9f6d !important;
|
||||
color: #fff !important;
|
||||
}
|
||||
|
||||
:deep(.uni-calendar-item--isDay-text) {
|
||||
color: #0a9f6d !important;
|
||||
}
|
||||
|
||||
:deep(.uni-calendar-item--checked.uni-calendar-item--isDay-text),
|
||||
:deep(.uni-calendar-item--isDay.uni-calendar-item--isDay-text) {
|
||||
color: #fff !important;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,316 @@
|
||||
/* 司机运输计划单 · 运输记录/回执正文(三墙绿;顶栏样式见 bx-theme) */
|
||||
.pl-driver-plan-page {
|
||||
--pl-driver-primary: #059669;
|
||||
--pl-driver-brand: #0a9f6d;
|
||||
padding-bottom: 24px;
|
||||
background: #f8fafc;
|
||||
min-height: 100vh;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.pl-driver-plan-page .filters {
|
||||
margin: 12px 16px;
|
||||
padding: 4px 4px 10px;
|
||||
border-radius: 12px;
|
||||
background: #fff;
|
||||
border: 1px solid #e2e8f0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.pl-driver-plan-page .search-input {
|
||||
display: block;
|
||||
width: calc(100% - 8px);
|
||||
height: 36px;
|
||||
margin: 8px 4px 0;
|
||||
padding: 0 12px;
|
||||
border: 1px solid #cbd5e1;
|
||||
border-radius: 8px;
|
||||
font-size: 14px;
|
||||
color: #0f172a;
|
||||
background: #fff;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.pl-driver-plan-page .list-body {
|
||||
padding: 0 16px 24px;
|
||||
}
|
||||
|
||||
.pl-driver-plan-page .record-card {
|
||||
position: relative;
|
||||
margin-bottom: 10px;
|
||||
padding: 16px 14px 14px;
|
||||
border-radius: 12px;
|
||||
background: #fff;
|
||||
border: 1px solid #e2e8f0;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.pl-driver-plan-page .index-tag {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
min-width: 24px;
|
||||
height: 22px;
|
||||
padding: 0 8px;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border-radius: 12px 0 10px 0;
|
||||
background: var(--pl-driver-primary);
|
||||
color: #fff;
|
||||
font-size: 12px;
|
||||
font-weight: 700;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.pl-driver-plan-page .record-top {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 8px;
|
||||
margin-bottom: 8px;
|
||||
padding-left: 4px;
|
||||
}
|
||||
|
||||
.pl-driver-plan-page .card-title {
|
||||
font-size: 15px;
|
||||
font-weight: 700;
|
||||
color: #0f172a;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.pl-driver-plan-page .tag {
|
||||
flex-shrink: 0;
|
||||
font-size: 11px;
|
||||
font-weight: 600;
|
||||
padding: 2px 8px;
|
||||
border-radius: 999px;
|
||||
}
|
||||
|
||||
.pl-driver-plan-page .tag--success {
|
||||
background: #ecfdf5;
|
||||
color: #047857;
|
||||
}
|
||||
|
||||
.pl-driver-plan-page .tag--danger {
|
||||
background: #fef2f2;
|
||||
color: #dc2626;
|
||||
}
|
||||
|
||||
.pl-driver-plan-page .tag--muted {
|
||||
background: #f1f5f9;
|
||||
color: #64748b;
|
||||
}
|
||||
|
||||
.pl-driver-plan-page .meta {
|
||||
font-size: 13px;
|
||||
color: #475569;
|
||||
line-height: 1.5;
|
||||
margin-top: 2px;
|
||||
}
|
||||
|
||||
.pl-driver-plan-page .plate-hl {
|
||||
color: var(--pl-driver-primary);
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.pl-driver-plan-page .stop-block {
|
||||
margin-top: 8px;
|
||||
padding-top: 8px;
|
||||
border-top: 1px dashed #e2e8f0;
|
||||
}
|
||||
|
||||
.pl-driver-plan-page .stop-block__title {
|
||||
font-size: 13px;
|
||||
font-weight: 700;
|
||||
color: #0f172a;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
.pl-driver-plan-page .page-loading,
|
||||
.pl-driver-plan-page .empty-hint {
|
||||
text-align: center;
|
||||
color: #94a3b8;
|
||||
padding: 48px 16px;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
/* detail */
|
||||
.pl-driver-plan-detail {
|
||||
padding-bottom: 100px;
|
||||
}
|
||||
|
||||
.pl-driver-plan-detail .section-card {
|
||||
margin: 12px 16px;
|
||||
padding: 12px 14px;
|
||||
border-radius: 12px;
|
||||
background: #fff;
|
||||
border: 1px solid #e2e8f0;
|
||||
}
|
||||
|
||||
.pl-driver-plan-detail .kv-row {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
padding: 8px 0;
|
||||
border-bottom: 1px solid #f1f5f9;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.pl-driver-plan-detail .kv-row:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.pl-driver-plan-detail .kv-k {
|
||||
color: #64748b;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.pl-driver-plan-detail .kv-v {
|
||||
color: #0f172a;
|
||||
text-align: right;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.pl-driver-plan-detail .stop-title {
|
||||
font-size: 15px;
|
||||
font-weight: 700;
|
||||
color: #0f172a;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.pl-driver-plan-detail .addr-row {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.pl-driver-plan-detail .nav-btn {
|
||||
flex-shrink: 0;
|
||||
font-size: 12px;
|
||||
color: #fff;
|
||||
background: var(--pl-driver-primary);
|
||||
border-radius: 999px;
|
||||
padding: 4px 10px;
|
||||
}
|
||||
|
||||
.pl-driver-plan-detail .product-card {
|
||||
margin-top: 10px;
|
||||
padding: 10px;
|
||||
border-radius: 10px;
|
||||
background: #f8fafc;
|
||||
border: 1px solid #e2e8f0;
|
||||
}
|
||||
|
||||
.pl-driver-plan-detail .product-name {
|
||||
font-weight: 700;
|
||||
color: #0f172a;
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
|
||||
.pl-driver-plan-detail .actual-box {
|
||||
margin-top: 12px;
|
||||
padding: 10px;
|
||||
border-radius: 10px;
|
||||
background: #ecfdf5;
|
||||
}
|
||||
|
||||
.pl-driver-plan-detail .actual-label {
|
||||
font-size: 13px;
|
||||
font-weight: 700;
|
||||
color: #047857;
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
|
||||
.pl-driver-plan-detail .actual-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.pl-driver-plan-detail .actual-input {
|
||||
flex: 1;
|
||||
height: 40px;
|
||||
padding: 0 12px;
|
||||
border: 1px solid #a7f3d0;
|
||||
border-radius: 8px;
|
||||
background: #fff;
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.pl-driver-plan-detail .remark-input {
|
||||
width: 100%;
|
||||
min-height: 64px;
|
||||
margin-top: 10px;
|
||||
padding: 10px 12px;
|
||||
border: 1px solid #e2e8f0;
|
||||
border-radius: 8px;
|
||||
font-size: 14px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.pl-driver-plan-detail .attach-label {
|
||||
margin-top: 12px;
|
||||
font-size: 13px;
|
||||
color: #64748b;
|
||||
}
|
||||
|
||||
.pl-driver-plan-detail .attach-row {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
margin-top: 8px;
|
||||
}
|
||||
|
||||
.pl-driver-plan-detail .attach-thumb {
|
||||
width: 72px;
|
||||
height: 72px;
|
||||
border-radius: 8px;
|
||||
background: #f1f5f9;
|
||||
}
|
||||
|
||||
.pl-driver-plan-detail .attach-add {
|
||||
width: 72px;
|
||||
height: 72px;
|
||||
border-radius: 8px;
|
||||
border: 1px dashed #a7f3d0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: var(--pl-driver-primary);
|
||||
font-size: 28px;
|
||||
}
|
||||
|
||||
.pl-driver-plan-detail .page-footer {
|
||||
position: fixed;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
|
||||
background: #fff;
|
||||
border-top: 1px solid #e2e8f0;
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
z-index: 20;
|
||||
}
|
||||
|
||||
.pl-driver-plan-detail .footer-btn {
|
||||
flex: 1;
|
||||
height: 44px;
|
||||
border-radius: 999px;
|
||||
font-size: 15px;
|
||||
font-weight: 600;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.pl-driver-plan-detail .footer-btn--ghost {
|
||||
background: #ecfdf5;
|
||||
color: #047857;
|
||||
}
|
||||
|
||||
.pl-driver-plan-detail .footer-btn--primary {
|
||||
background: var(--pl-driver-primary);
|
||||
color: #fff;
|
||||
}
|
||||
Reference in new issue
Block a user