feat(pl): 完善双端现场日历并支持待派车和直销计划,满足车辆未定及现场查看需求。
This commit is contained in:
1 parent
fcbf8a9b65
commit
142b8fdf48
31 files changed
+1180
-60
No files matched your search
@@ -40,6 +40,10 @@ export interface CalendarPageQuery {
|
||||
}
|
||||
const base = '/transport/dispatch-calendar'
|
||||
export const dispatchCalendarApi = {
|
||||
siteList: (params: CalendarPageQuery & { month: string; vehicleId?: string }) =>
|
||||
request
|
||||
.get('/transport/site-dispatch-calendar', { params })
|
||||
.then(pickBxData<CalendarPage<DispatchCalendarRecord>>),
|
||||
list: (
|
||||
params: CalendarPageQuery & {
|
||||
month: string
|
||||
|
||||
@@ -129,6 +129,12 @@ export const staticRoutes: AppRouteRecordRaw[] = [
|
||||
component: () => import('@views/public/duty/index.vue'),
|
||||
meta: { title: '值班抢班', isHideTab: true, isPublicMobile: true }
|
||||
},
|
||||
{
|
||||
path: '/m/pl/site-dispatch-calendar',
|
||||
name: 'MpSiteDispatchCalendar',
|
||||
component: () => import('@views/m/pl/site-dispatch-calendar/index.vue'),
|
||||
meta: { title: '现场派车日历', isHideTab: true, isMpWebview: true }
|
||||
},
|
||||
{
|
||||
path: '/m/pl/dispatch-calendar',
|
||||
name: 'MpDispatchCalendar',
|
||||
|
||||
@@ -25,9 +25,9 @@
|
||||
>
|
||||
<div v-if="loading" class="mp-manual-empty"><van-loading />正在加载{{ title }}</div>
|
||||
<template v-else>
|
||||
<p v-if="!records.length" class="mp-manual-hint"
|
||||
>本月暂无手工派车计划,可选择任意日期新增。</p
|
||||
>
|
||||
<p v-if="!records.length" class="mp-manual-hint">{{
|
||||
siteReadOnly ? '本月暂无现场派车计划' : '本月暂无手工派车计划,可选择任意日期新增。'
|
||||
}}</p>
|
||||
<van-cell-group
|
||||
v-for="day in days.filter((item) => item.inMonth)"
|
||||
:key="day.date"
|
||||
@@ -69,6 +69,7 @@
|
||||
</van-cell-group>
|
||||
</template>
|
||||
<van-popup
|
||||
v-if="!siteReadOnly"
|
||||
v-model:show="editorOpen"
|
||||
position="bottom"
|
||||
round
|
||||
@@ -137,6 +138,25 @@
|
||||
maxlength="255"
|
||||
placeholder="请输入目的地"
|
||||
/>
|
||||
<van-field
|
||||
v-if="calendarKind === 'site'"
|
||||
v-model="draft.documentType"
|
||||
label="单据类型"
|
||||
maxlength="50"
|
||||
clearable
|
||||
placeholder="选择或输入单据类型"
|
||||
>
|
||||
<template #button>
|
||||
<van-button
|
||||
size="small"
|
||||
native-type="button"
|
||||
aria-label="选择单据类型"
|
||||
:disabled="saving || sessionChanged"
|
||||
@click="documentTypeOpen = true"
|
||||
>选择</van-button
|
||||
>
|
||||
</template>
|
||||
</van-field>
|
||||
<van-field
|
||||
v-model="draft.remark"
|
||||
label="备注"
|
||||
@@ -163,6 +183,15 @@
|
||||
>
|
||||
</van-form>
|
||||
</van-popup>
|
||||
<van-action-sheet
|
||||
v-model:show="documentTypeOpen"
|
||||
title="选择单据类型"
|
||||
:actions="[{ name: '入库计划' }, { name: '出库计划' }, { name: '直销计划' }]"
|
||||
cancel-text="取消"
|
||||
close-on-click-action
|
||||
teleport="body"
|
||||
@select="selectDocumentType"
|
||||
/>
|
||||
<van-popup
|
||||
v-model:show="pickerOpen"
|
||||
position="bottom"
|
||||
@@ -256,12 +285,22 @@
|
||||
><h2>派车计划详情</h2
|
||||
><van-cell-group :border="false">
|
||||
<van-cell title="派车日期" :value="viewRow.dispatchDate" />
|
||||
<van-cell
|
||||
v-if="viewRow.sourceRecordId"
|
||||
title="维护方式"
|
||||
value="自动同步,请在来源派车日历修改或删除"
|
||||
/>
|
||||
<van-cell
|
||||
v-if="calendarKind === 'site'"
|
||||
title="单据类型"
|
||||
:value="viewRow.documentType || '—'"
|
||||
/>
|
||||
<van-cell title="车牌号" :value="viewRow.licensePlate" />
|
||||
<van-cell title="产品名称" :value="viewRow.productName" />
|
||||
<van-cell title="始发地 → 目的地" :value="`${viewRow.origin} → ${viewRow.destination}`" />
|
||||
<van-cell title="数量" :value="manualQuantityLabel(viewRow.quantity) || '—'" />
|
||||
<van-cell title="备注" :value="viewRow.remark || '—'" /> </van-cell-group
|
||||
><div v-if="canManage" class="mp-manual-footer"
|
||||
><div v-if="canManage && !viewRow.sourceRecordId" class="mp-manual-footer"
|
||||
><van-button :disabled="saving" @click="deleteViewed">删除</van-button
|
||||
><van-button type="primary" :disabled="saving" @click="editViewed">编辑</van-button></div
|
||||
></div
|
||||
@@ -278,8 +317,8 @@
|
||||
import { useManualCalendar } from '@/views/pl/dispatch-calendar/useManualCalendar'
|
||||
import type { DispatchCalendarKind, DispatchCalendarRecord } from '@/api/pl/dispatch-calendar'
|
||||
const props = withDefaults(
|
||||
defineProps<{ calendarKind?: DispatchCalendarKind; title?: string }>(),
|
||||
{ calendarKind: 'acid', title: '酸派车日历' }
|
||||
defineProps<{ calendarKind?: DispatchCalendarKind; title?: string; siteReadOnly?: boolean }>(),
|
||||
{ calendarKind: 'acid', title: '酸派车日历', siteReadOnly: false }
|
||||
)
|
||||
const {
|
||||
month,
|
||||
@@ -309,7 +348,11 @@
|
||||
remove,
|
||||
copyDay,
|
||||
locate
|
||||
} = useManualCalendar({ success: showSuccessToast, error: showFailToast }, props.calendarKind)
|
||||
} = useManualCalendar(
|
||||
{ success: showSuccessToast, error: showFailToast },
|
||||
props.calendarKind,
|
||||
props.siteReadOnly
|
||||
)
|
||||
const filterHeader = ref<HTMLElement>()
|
||||
const { height: filterHeight } = useElementSize(filterHeader)
|
||||
const viewRow = ref<DispatchCalendarRecord>()
|
||||
@@ -319,6 +362,11 @@
|
||||
if (!value) viewRow.value = undefined
|
||||
}
|
||||
})
|
||||
const documentTypeOpen = ref(false)
|
||||
function selectDocumentType(action: { name: string }) {
|
||||
if (saving.value || sessionChanged.value) return
|
||||
draft.documentType = action.name
|
||||
}
|
||||
const picker = ref<'vehicle' | 'product'>('vehicle')
|
||||
const pickerOpen = ref(false)
|
||||
const pickerSelectedId = computed(() =>
|
||||
@@ -370,11 +418,12 @@
|
||||
void scrollSelected()
|
||||
}
|
||||
function editViewed() {
|
||||
if (viewRow.value) openEdit(viewRow.value)
|
||||
if (!viewRow.value || viewRow.value.sourceRecordId) return
|
||||
openEdit(viewRow.value)
|
||||
viewRow.value = undefined
|
||||
}
|
||||
async function deleteViewed() {
|
||||
if (!viewRow.value) return
|
||||
if (!viewRow.value || viewRow.value.sourceRecordId) return
|
||||
const row = viewRow.value
|
||||
try {
|
||||
await showConfirmDialog({
|
||||
@@ -392,6 +441,7 @@
|
||||
if (!value) void scrollSelected()
|
||||
})
|
||||
watch(sessionChanged, () => {
|
||||
documentTypeOpen.value = false
|
||||
pickerOpen.value = false
|
||||
dateOpen.value = false
|
||||
viewRow.value = undefined
|
||||
|
||||
@@ -2,18 +2,36 @@
|
||||
<MpWebviewShell class="mp-dispatch-edge-to-edge" @ready="ready = true">
|
||||
<div class="mp-dispatch-tabs" :style="{ '--dispatch-header-height': `${headerHeight}px` }">
|
||||
<div ref="header" class="mp-dispatch-top">
|
||||
<MpBusinessHeader title="派车日历" back-label="返回工作台" @back="goToMiniWorkbench" />
|
||||
<van-tabs v-model:active="active" shrink color="#0a9f6d" title-active-color="#087f57">
|
||||
<MpBusinessHeader
|
||||
:title="siteReadOnly ? '现场派车日历' : '派车日历'"
|
||||
back-label="返回工作台"
|
||||
@back="goToMiniWorkbench"
|
||||
/>
|
||||
<van-tabs
|
||||
v-if="!siteReadOnly"
|
||||
v-model:active="active"
|
||||
shrink
|
||||
color="#0a9f6d"
|
||||
title-active-color="#087f57"
|
||||
>
|
||||
<van-tab title="酸派车日历" name="acid" />
|
||||
<van-tab title="碱派车日历" name="alkali" />
|
||||
<van-tab title="其他日历" name="other" />
|
||||
<van-tab title="现场日历" name="site" />
|
||||
<van-tab title="实际派车信息" name="actual" />
|
||||
</van-tabs>
|
||||
</div>
|
||||
<template v-if="ready">
|
||||
<ManualCalendar v-if="active === 'acid'" calendar-kind="acid" title="酸派车日历" />
|
||||
<ManualCalendar
|
||||
v-if="siteReadOnly"
|
||||
calendar-kind="site"
|
||||
title="现场派车日历"
|
||||
site-read-only
|
||||
/>
|
||||
<ManualCalendar v-else-if="active === 'acid'" calendar-kind="acid" title="酸派车日历" />
|
||||
<ManualCalendar v-else-if="active === 'alkali'" calendar-kind="alkali" title="碱派车日历" />
|
||||
<ManualCalendar v-else-if="active === 'other'" calendar-kind="other" title="其他日历" />
|
||||
<ManualCalendar v-else-if="active === 'site'" calendar-kind="site" title="现场日历" />
|
||||
<ActualCalendar v-else />
|
||||
</template>
|
||||
</div>
|
||||
@@ -26,6 +44,7 @@
|
||||
import ManualCalendar from './ManualCalendar.vue'
|
||||
import ActualCalendar from './ActualCalendar.vue'
|
||||
defineOptions({ name: 'MpDispatchCalendar' })
|
||||
withDefaults(defineProps<{ siteReadOnly?: boolean }>(), { siteReadOnly: false })
|
||||
const header = ref<HTMLElement>()
|
||||
const { height: headerHeight } = useElementSize(header)
|
||||
const ready = ref(false)
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
<template>
|
||||
<DispatchCalendar site-read-only />
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import DispatchCalendar from '../dispatch-calendar/index.vue'
|
||||
defineOptions({ name: 'MpSiteDispatchCalendar' })
|
||||
</script>
|
||||
@@ -181,7 +181,7 @@
|
||||
<el-form-item label="目的地"
|
||||
><el-input v-model="draft.destination" maxlength="255" placeholder="请输入目的地"
|
||||
/></el-form-item>
|
||||
<el-form-item v-if="calendarKind === 'site'" label="单据类型" class="form-col-span-2">
|
||||
<el-form-item v-if="calendarKind === 'site'" label="单据类型">
|
||||
<el-select
|
||||
v-model="draft.documentType"
|
||||
filterable
|
||||
@@ -194,9 +194,10 @@
|
||||
>
|
||||
<el-option label="入库计划" value="入库计划" />
|
||||
<el-option label="出库计划" value="出库计划" />
|
||||
<el-option label="直销计划" value="直销计划" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="备注" class="form-col-span-2"
|
||||
<el-form-item label="备注" :class="{ 'form-col-span-2': calendarKind !== 'site' }"
|
||||
><el-input
|
||||
v-model="draft.remark"
|
||||
type="textarea"
|
||||
|
||||
@@ -35,12 +35,7 @@
|
||||
}}</span>
|
||||
1车</span
|
||||
>
|
||||
<span class="route"
|
||||
>{{ group.rows[0].origin }} → {{ group.rows[0].destination
|
||||
}}<template v-if="group.rows[0].calendarKind === 'site' && group.rows[0].documentType"
|
||||
>({{ group.rows[0].documentType }})</template
|
||||
></span
|
||||
>
|
||||
<span class="route">{{ group.rows[0].origin }} → {{ group.rows[0].destination }}</span>
|
||||
<span v-if="group.rows[0].remark" class="remark">{{ group.rows[0].remark }}</span>
|
||||
</component>
|
||||
<div v-else class="pair">
|
||||
@@ -63,10 +58,7 @@
|
||||
><span v-if="manualQuantityLabel(row.quantity)" class="quantity">{{
|
||||
' ' + manualQuantityLabel(row.quantity)
|
||||
}}</span>
|
||||
· {{ row.origin }} → {{ row.destination
|
||||
}}<template v-if="row.calendarKind === 'site' && row.documentType"
|
||||
>({{ row.documentType }})</template
|
||||
></span
|
||||
· {{ row.origin }} → {{ row.destination }}</span
|
||||
>
|
||||
<span v-if="row.remark" class="remark">{{ row.remark }}</span>
|
||||
</component>
|
||||
|
||||
@@ -99,6 +99,26 @@ function manualTripText(row: DispatchCalendarRecord) {
|
||||
}
|
||||
|
||||
export function manualCopyText(date: string, rows: DispatchCalendarRecord[]) {
|
||||
if (rows.length && rows.every((row) => row.calendarKind === 'site')) {
|
||||
// 与日卡汇总一致:按产品 ID 分组,每条计划计一车,同车多趟不合并。
|
||||
const products = new Map<string, { name: string; rows: DispatchCalendarRecord[] }>()
|
||||
for (const row of rows) {
|
||||
if (!products.has(row.productId)) {
|
||||
products.set(row.productId, { name: row.productName, rows: [] })
|
||||
}
|
||||
products.get(row.productId)!.rows.push(row)
|
||||
}
|
||||
return [
|
||||
`${date} 派车计划:`,
|
||||
'',
|
||||
...[...products.values()].flatMap((group) => [
|
||||
`${group.name}${group.rows.length}车`,
|
||||
...group.rows
|
||||
.sort(byCreateOrder)
|
||||
.map((row) => ` ·${row.licensePlate} ${manualTripText(row)}`)
|
||||
])
|
||||
].join('\n')
|
||||
}
|
||||
return [
|
||||
`${date} 派车计划`,
|
||||
...groupByVehicle(rows).flatMap((group) => [
|
||||
|
||||
@@ -17,12 +17,19 @@ import {
|
||||
} from './manual-model'
|
||||
import { copyTextToClipboard } from '@/utils/clipboard'
|
||||
|
||||
// 日历专用占位值,与后端 PENDING_VEHICLE_ID 保持一致,不创建车辆档案。
|
||||
const PENDING_VEHICLE: CalendarVehicleOption = {
|
||||
id: '__pending_vehicle__',
|
||||
licensePlate: '待派车'
|
||||
}
|
||||
|
||||
export function useManualCalendar(
|
||||
feedback: { success: (message: string) => void; error: (message: string) => void } = {
|
||||
success: (message) => ElMessage.success(message),
|
||||
error: (message) => ElMessage.error(message)
|
||||
},
|
||||
calendarKind: DispatchCalendarKind = 'acid'
|
||||
calendarKind: DispatchCalendarKind = 'acid',
|
||||
siteReadOnly = false
|
||||
) {
|
||||
const user = useUserStore()
|
||||
const sessionKey = () => JSON.stringify([user.accessToken, user.getUserInfo])
|
||||
@@ -77,7 +84,10 @@ export function useManualCalendar(
|
||||
records.value = []
|
||||
try {
|
||||
const data = await loadCalendarPages(
|
||||
(query) => dispatchCalendarApi.list({ ...query, month: month.value, calendarKind }),
|
||||
(query) =>
|
||||
siteReadOnly
|
||||
? dispatchCalendarApi.siteList({ ...query, month: month.value })
|
||||
: dispatchCalendarApi.list({ ...query, month: month.value, calendarKind }),
|
||||
current
|
||||
)
|
||||
if (data && current()) records.value = data
|
||||
@@ -88,7 +98,7 @@ export function useManualCalendar(
|
||||
}
|
||||
}
|
||||
async function loadOptions() {
|
||||
if (!live() || optionsLoading.value) return
|
||||
if (siteReadOnly || !live() || optionsLoading.value) return
|
||||
optionsLoading.value = true
|
||||
optionsError.value = ''
|
||||
try {
|
||||
@@ -97,7 +107,7 @@ export function useManualCalendar(
|
||||
loadCalendarPages(dispatchCalendarApi.products, live)
|
||||
])
|
||||
if (live()) {
|
||||
vehicles.value = v || []
|
||||
vehicles.value = [PENDING_VEHICLE, ...(v || [])]
|
||||
products.value = p || []
|
||||
}
|
||||
} catch {
|
||||
@@ -107,14 +117,14 @@ export function useManualCalendar(
|
||||
}
|
||||
}
|
||||
function openCreate(date = selectedDate.value || `${month.value}-01`) {
|
||||
if (!canManage.value || !live() || saving.value) return
|
||||
if (siteReadOnly || !canManage.value || !live() || saving.value) return
|
||||
editingId.value = ''
|
||||
Object.assign(draft, blank(date))
|
||||
formError.value = ''
|
||||
editorOpen.value = true
|
||||
}
|
||||
function openEdit(row: DispatchCalendarRecord) {
|
||||
if (!canManage.value || !live() || saving.value || row.sourceRecordId) return
|
||||
if (siteReadOnly || !canManage.value || !live() || saving.value || row.sourceRecordId) return
|
||||
editingId.value = row.id
|
||||
Object.assign(draft, {
|
||||
dispatchDate: row.dispatchDate,
|
||||
@@ -131,7 +141,7 @@ export function useManualCalendar(
|
||||
editorOpen.value = true
|
||||
}
|
||||
async function save() {
|
||||
if (!live() || !canManage.value || saving.value) return
|
||||
if (siteReadOnly || !live() || !canManage.value || saving.value) return
|
||||
formError.value = validateManualDraft(draft)
|
||||
if (formError.value) return
|
||||
saving.value = true
|
||||
@@ -160,7 +170,8 @@ export function useManualCalendar(
|
||||
}
|
||||
}
|
||||
async function remove(row: DispatchCalendarRecord) {
|
||||
if (!live() || !canManage.value || saving.value || row.sourceRecordId) return false
|
||||
if (siteReadOnly || !live() || !canManage.value || saving.value || row.sourceRecordId)
|
||||
return false
|
||||
saving.value = true
|
||||
try {
|
||||
await dispatchCalendarApi.delete(row.id)
|
||||
@@ -212,6 +223,7 @@ export function useManualCalendar(
|
||||
)
|
||||
onMounted(() => {
|
||||
void load()
|
||||
if (siteReadOnly) return
|
||||
void loadOptions()
|
||||
void fetchGetMenuCodes()
|
||||
.then((perm) => {
|
||||
|
||||
Reference in new issue
Block a user