140 lines
5.1 KiB
Vue
140 lines
5.1 KiB
Vue
<script setup>
|
||
import { ref } from 'vue'
|
||
import { onLoad, onShow } from '@dcloudio/uni-app'
|
||
import { getPlan, getPlanRelated, createInventoryLinkForPlan } from '@/api/db'
|
||
import { planStatusLabel, dash, formatWeight } from '@/utils/dbLabels'
|
||
import { PAGE_PATHS } from '@/config/api'
|
||
|
||
const id = ref('')
|
||
const detail = ref(null)
|
||
const related = ref({ inventories: [], weighings: [] })
|
||
const acting = ref(false)
|
||
|
||
const goBack = () => {
|
||
uni.navigateBack({
|
||
fail: () => uni.navigateTo({ url: PAGE_PATHS.dbPlansList })
|
||
})
|
||
}
|
||
|
||
const load = async () => {
|
||
if (!id.value) return
|
||
try {
|
||
detail.value = await getPlan(id.value)
|
||
related.value = await getPlanRelated(id.value)
|
||
} catch (e) {
|
||
uni.showToast({ title: e.message || '加载失败', icon: 'none' })
|
||
}
|
||
}
|
||
|
||
const createLink = () => {
|
||
uni.showModal({
|
||
title: '生成出入库单',
|
||
content: '为该计划创建可填写的出入库关联单?',
|
||
success: async (r) => {
|
||
if (!r.confirm) return
|
||
acting.value = true
|
||
try {
|
||
const inv = await createInventoryLinkForPlan(id.value)
|
||
uni.showToast({ title: '已生成', icon: 'success' })
|
||
if (inv?.id) {
|
||
uni.navigateTo({ url: `${PAGE_PATHS.dbInventoryDetail}?id=${inv.id}` })
|
||
} else {
|
||
load()
|
||
}
|
||
} catch (e) {
|
||
uni.showToast({ title: e.message || '操作失败', icon: 'none' })
|
||
} finally {
|
||
acting.value = false
|
||
}
|
||
}
|
||
})
|
||
}
|
||
|
||
const openWeighing = (w) =>
|
||
uni.navigateTo({ url: `${PAGE_PATHS.dbWeighingDetail}?id=${w.id}` })
|
||
const openInventory = (inv) =>
|
||
uni.navigateTo({ url: `${PAGE_PATHS.dbInventoryDetail}?id=${inv.id}` })
|
||
|
||
onLoad((q) => {
|
||
id.value = q?.id || ''
|
||
})
|
||
onShow(() => load())
|
||
</script>
|
||
|
||
<template>
|
||
<view class="mp-page mp-page--sub mp-page--with-bottom">
|
||
<view class="mp-header mp-header--db">
|
||
<text class="mp-subpage-back" @click="goBack">← 返回</text>
|
||
<text class="mp-header__title" style="margin-top: 16rpx">计划详情</text>
|
||
</view>
|
||
|
||
<view v-if="detail" class="mp-detail-hero">
|
||
<view class="mp-detail-hero__top">
|
||
<view>
|
||
<text class="mp-detail-hero__title">{{ dash(detail.planNo) }}</text>
|
||
<text class="mp-detail-hero__sub">{{ dash(detail.product) }}</text>
|
||
</view>
|
||
<text class="mp-tag" :class="'mp-tag--' + planStatusLabel(detail.executionStatus).tag">
|
||
{{ planStatusLabel(detail.executionStatus).text }}
|
||
</text>
|
||
</view>
|
||
<view class="mp-detail-hero__meta">
|
||
<text class="mp-detail-hero__chip">{{ dash(detail.businessType) }}</text>
|
||
<text class="mp-detail-hero__chip">
|
||
{{ formatWeight(detail.executedQuantity) }} / {{ formatWeight(detail.plannedQuantity) }}
|
||
</text>
|
||
</view>
|
||
</view>
|
||
|
||
<view class="mp-block">
|
||
<text class="mp-block__title">基本信息</text>
|
||
<view class="mp-block__panel">
|
||
<view class="mp-kv"><text class="mp-kv__label">计划日期</text><text class="mp-kv__value">{{ dash(detail?.planDate) }}</text></view>
|
||
<view class="mp-kv"><text class="mp-kv__label">起止</text><text class="mp-kv__value">{{ dash(detail?.startDate) }} ~ {{ dash(detail?.endDate) }}</text></view>
|
||
<view class="mp-kv"><text class="mp-kv__label">规格</text><text class="mp-kv__value">{{ dash(detail?.specification) }}</text></view>
|
||
<view class="mp-kv"><text class="mp-kv__label">车牌</text><text class="mp-kv__value">{{ dash(detail?.vehicleNo) }}</text></view>
|
||
<view class="mp-kv"><text class="mp-kv__label">客户</text><text class="mp-kv__value">{{ dash(detail?.customerName) }}</text></view>
|
||
<view class="mp-kv"><text class="mp-kv__label">备注</text><text class="mp-kv__value">{{ dash(detail?.remarks) }}</text></view>
|
||
</view>
|
||
</view>
|
||
|
||
<view class="mp-block">
|
||
<text class="mp-block__title">关联出入库({{ related.inventories?.length || 0 }})</text>
|
||
<mp-empty v-if="!related.inventories?.length" compact title="暂无出入库单" />
|
||
<view v-else class="mp-list">
|
||
<view
|
||
v-for="inv in related.inventories"
|
||
:key="inv.id"
|
||
class="mp-card"
|
||
@click="openInventory(inv)"
|
||
>
|
||
<text class="mp-card__title">{{ dash(inv.batchNo || inv.id) }}</text>
|
||
<text class="mp-card__sub">{{ dash(inv.vehicleNo) }} · {{ dash(inv.status) }}</text>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
|
||
<view class="mp-block">
|
||
<text class="mp-block__title">关联地磅单({{ related.weighings?.length || 0 }})</text>
|
||
<mp-empty v-if="!related.weighings?.length" compact title="暂无地磅单" />
|
||
<view v-else class="mp-list">
|
||
<view
|
||
v-for="w in related.weighings"
|
||
:key="w.id"
|
||
class="mp-card"
|
||
@click="openWeighing(w)"
|
||
>
|
||
<text class="mp-card__title">{{ dash(w.vehicleNo) }}</text>
|
||
<text class="mp-card__sub">净重 {{ formatWeight(w.netWeight) }}</text>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
|
||
<view class="mp-bottom-bar">
|
||
<view class="mp-btn mp-btn--primary" @click="createLink">
|
||
{{ acting ? '…' : '生成出入库关联单' }}
|
||
</view>
|
||
</view>
|
||
</view>
|
||
</template>
|