提交
This commit is contained in:
1 parent
6b6c80f182
commit
86450f38a1
53 files changed
+20800
-5339
No files matched your search
@@ -385,6 +385,26 @@ export interface PlanCreateFullPayload {
|
||||
|
||||
export type PlanUpdatePayload = Partial<Omit<PlanCreateFullPayload, 'contractId'>>
|
||||
|
||||
export interface PlanArchiveProductItem {
|
||||
id: string
|
||||
actualQty: number
|
||||
}
|
||||
|
||||
export interface PlanArchiveFreightBlock {
|
||||
hasFreight: number
|
||||
distanceKm?: number
|
||||
freightType?: string
|
||||
freightPrice?: number
|
||||
freightAmount?: number
|
||||
transportQty?: number
|
||||
hasInvoice?: number
|
||||
}
|
||||
|
||||
export interface PlanArchiveBody {
|
||||
products: PlanArchiveProductItem[]
|
||||
freight?: PlanArchiveFreightBlock
|
||||
}
|
||||
|
||||
export const planApi = {
|
||||
list: (params?: PlanQuery) => request.get<PlanListResponse>('/transport/plan/', { params }),
|
||||
get: (id: string) => request.get<Plan>(`/transport/plan/${id}`),
|
||||
@@ -401,7 +421,8 @@ export const planApi = {
|
||||
) => request.patch<Plan>(`/transport/plan/${id}/product-certs`, { products }),
|
||||
cancel: (id: string) => request.post<Plan>(`/transport/plan/${id}/cancel`),
|
||||
getArrangeInfo: (id: string) => request.get<PlanArrangeInfo>(`/transport/plan/${id}/arrange-info`),
|
||||
archive: (id: string) => request.post<Plan>(`/transport/plan/${id}/archive`),
|
||||
archive: (id: string, data?: PlanArchiveBody) =>
|
||||
request.post<Plan>(`/transport/plan/${id}/archive`, data),
|
||||
delete: (id: string) => request.delete(`/transport/plan/${id}`),
|
||||
createFromContract: (data: { contractId: string; planDate: string; followUserId?: string; followUserName?: string }) =>
|
||||
request.post<Plan>('/transport/plan/create-from-contract', data)
|
||||
@@ -539,6 +560,63 @@ export const transportApi = {
|
||||
// 运费结算 API
|
||||
// =============================================================================
|
||||
|
||||
export interface UnsettledPlanItem {
|
||||
id: string
|
||||
planNo: string
|
||||
planDate: string
|
||||
planType: string
|
||||
customerName?: string
|
||||
supplierName?: string
|
||||
licensePlate?: string
|
||||
transportCompany?: string
|
||||
freightAmount: number
|
||||
archiveTime?: string
|
||||
}
|
||||
|
||||
export interface UnsettledPlanQuery {
|
||||
q?: string
|
||||
planType?: string
|
||||
licensePlate?: string
|
||||
page?: number
|
||||
pageSize?: number
|
||||
}
|
||||
|
||||
export interface UnsettledPlanListResponse {
|
||||
total: number
|
||||
list: UnsettledPlanItem[]
|
||||
}
|
||||
|
||||
export interface SettlementPlanSummary {
|
||||
id: string
|
||||
planNo: string
|
||||
planDate?: string
|
||||
licensePlate?: string
|
||||
freightAmount?: number
|
||||
}
|
||||
|
||||
export interface SettlementApprovalFlowItem {
|
||||
id: string
|
||||
step: number
|
||||
stepName?: string
|
||||
approverId: string
|
||||
approverName?: string
|
||||
approvalType?: string
|
||||
approvalResult: string
|
||||
approvalOpinion?: string
|
||||
approvalTime?: string
|
||||
isCurrent: number
|
||||
}
|
||||
|
||||
export interface RemittanceVoucher {
|
||||
id: string
|
||||
settlementId: string
|
||||
remittanceDate?: string
|
||||
remittanceAmount?: number
|
||||
voucherUrls?: string
|
||||
remark?: string
|
||||
createTime?: string
|
||||
}
|
||||
|
||||
export interface FreightSettlement {
|
||||
id: string
|
||||
settlementNo: string
|
||||
@@ -548,13 +626,29 @@ export interface FreightSettlement {
|
||||
invoiceDate?: string
|
||||
settlementStatus: string
|
||||
remark?: string
|
||||
createBy?: string
|
||||
createTime: string
|
||||
updateTime?: string
|
||||
planCount?: number
|
||||
licensePlateSummary?: string
|
||||
currentApproverName?: string
|
||||
canApprove?: boolean
|
||||
canWithdraw?: boolean
|
||||
currentApprovalId?: string
|
||||
approvalFinishedTime?: string
|
||||
disburseTime?: string
|
||||
disburseAmount?: number
|
||||
submitterName?: string
|
||||
transports?: Transport[]
|
||||
plans?: SettlementPlanSummary[]
|
||||
approvalFlow?: SettlementApprovalFlowItem[]
|
||||
vouchers?: RemittanceVoucher[]
|
||||
}
|
||||
|
||||
export interface FreightSettlementQuery {
|
||||
q?: string
|
||||
settlementStatus?: string
|
||||
tab?: 'bills' | 'disburse' | 'settled'
|
||||
page?: number
|
||||
pageSize?: number
|
||||
}
|
||||
@@ -564,15 +658,48 @@ export interface FreightSettlementListResponse {
|
||||
list: FreightSettlement[]
|
||||
}
|
||||
|
||||
export interface FreightSettlementSubmitBody {
|
||||
approvalType: 'sequential' | 'parallel' | 'or'
|
||||
approverIds: string[]
|
||||
remark?: string
|
||||
}
|
||||
|
||||
export interface FreightSettlementApprovalBody {
|
||||
action: 'approve' | 'reject'
|
||||
comment?: string
|
||||
}
|
||||
|
||||
export interface FreightSettlementDisburseBody {
|
||||
remittanceDate: string
|
||||
remittanceAmount: number
|
||||
voucherUrls: string[]
|
||||
remark?: string
|
||||
}
|
||||
|
||||
export const freightApi = {
|
||||
listUnsettledPlans: (params?: UnsettledPlanQuery) =>
|
||||
request.get<UnsettledPlanListResponse>('/transport/freight/unsettled-plans', { params }),
|
||||
list: (params?: FreightSettlementQuery) =>
|
||||
request.get<FreightSettlementListResponse>('/transport/freight/', { params }),
|
||||
get: (id: string) => request.get<FreightSettlement>(`/transport/freight/${id}`),
|
||||
create: (transportIds: string[]) =>
|
||||
request.post<FreightSettlement>('/transport/freight/', { transportIds }),
|
||||
create: (data: { planIds?: string[]; transportIds?: string[] }) =>
|
||||
request.post<FreightSettlement>('/transport/freight/', data),
|
||||
update: (id: string, data: Partial<FreightSettlement>) =>
|
||||
request.put<FreightSettlement>(`/transport/freight/${id}`, data),
|
||||
delete: (id: string) => request.delete(`/transport/freight/${id}`),
|
||||
submitApproval: (id: string, data: FreightSettlementSubmitBody) =>
|
||||
request.post<FreightSettlement>(`/transport/freight/${id}/submit-approval`, data),
|
||||
processApproval: (approvalId: string, data: FreightSettlementApprovalBody) =>
|
||||
request.post<FreightSettlement>(`/transport/freight/approval/${approvalId}`, data),
|
||||
withdrawApproval: (id: string) =>
|
||||
request.post<FreightSettlement>(`/transport/freight/${id}/withdraw-approval`),
|
||||
getApprovalFlow: (id: string) =>
|
||||
request.get<SettlementApprovalFlowItem[]>(`/transport/freight/${id}/approval-flow`),
|
||||
disburse: (id: string, data: FreightSettlementDisburseBody) =>
|
||||
request.post<FreightSettlement>(`/transport/freight/${id}/disburse`, data),
|
||||
/** @deprecated 请使用 submitApproval */
|
||||
submit: (id: string) => request.post<FreightSettlement>(`/transport/freight/${id}/submit`),
|
||||
/** @deprecated 请使用 processApproval */
|
||||
approve: (id: string) => request.post<FreightSettlement>(`/transport/freight/${id}/approve`)
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,310 @@
|
||||
<template>
|
||||
<el-dialog
|
||||
v-model="dialogVisible"
|
||||
:title="dialogTitle"
|
||||
width="640px"
|
||||
align-center
|
||||
append-to-body
|
||||
destroy-on-close
|
||||
class="dialog-form-layout"
|
||||
modal-class="order-module-dialog-mask"
|
||||
:close-on-click-modal="false"
|
||||
>
|
||||
<el-form
|
||||
ref="formRef"
|
||||
:model="form"
|
||||
:rules="rules"
|
||||
label-position="top"
|
||||
scroll-to-error
|
||||
:scroll-into-view-options="{ behavior: 'smooth', block: 'center' }"
|
||||
>
|
||||
<div class="form-grid-2">
|
||||
<el-form-item v-if="actionType === 'submit'" label="审批类型" class="form-col-span-2">
|
||||
<el-radio-group v-model="form.approvalType">
|
||||
<el-radio value="sequential">顺序审批</el-radio>
|
||||
<el-radio value="parallel">会签审批</el-radio>
|
||||
<el-radio value="or">或签审批</el-radio>
|
||||
</el-radio-group>
|
||||
<div class="form-label-tip form-tip-block">
|
||||
顺序审批:按顺序依次审批;会签:所有人都需审批;或签:任一人审批即可
|
||||
</div>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item v-if="actionType === 'submit'" prop="approverIds" class="form-col-span-2">
|
||||
<template #label>
|
||||
选择审批人<span class="form-label-tip">支持搜索用户姓名</span>
|
||||
</template>
|
||||
<el-select
|
||||
v-model="form.approverIds"
|
||||
multiple
|
||||
filterable
|
||||
remote
|
||||
reserve-keyword
|
||||
placeholder="请选择审批人"
|
||||
:remote-method="handleSearchUser"
|
||||
:loading="userLoading"
|
||||
style="width: 100%"
|
||||
>
|
||||
<el-option
|
||||
v-for="user in approverList"
|
||||
:key="user.userId"
|
||||
:label="`${user.nickName}(${user.userName})`"
|
||||
:value="String(user.userId)"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item
|
||||
v-if="actionType === 'approve' || actionType === 'reject'"
|
||||
label="审批意见"
|
||||
prop="comment"
|
||||
class="form-col-span-2"
|
||||
>
|
||||
<el-input
|
||||
v-model="form.comment"
|
||||
type="textarea"
|
||||
:rows="5"
|
||||
placeholder="请输入审批意见"
|
||||
maxlength="500"
|
||||
show-word-limit
|
||||
/>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item v-if="actionType === 'submit'" prop="remark" class="form-col-span-2">
|
||||
<template #label>
|
||||
提交说明<span class="form-label-tip">可选</span>
|
||||
</template>
|
||||
<el-input
|
||||
v-model="form.remark"
|
||||
type="textarea"
|
||||
:rows="5"
|
||||
placeholder="请输入提交说明"
|
||||
maxlength="500"
|
||||
show-word-limit
|
||||
/>
|
||||
</el-form-item>
|
||||
</div>
|
||||
</el-form>
|
||||
|
||||
<section v-if="actionType === 'submit' && form.approverIds.length > 0" class="approval-dialog-section">
|
||||
<h3 class="approval-section-title">审批流程预览</h3>
|
||||
<div class="approval-flow">
|
||||
<el-steps :active="0" align-center>
|
||||
<el-step
|
||||
v-for="(approverId, index) in form.approverIds"
|
||||
:key="index"
|
||||
:title="getApproverName(approverId)"
|
||||
/>
|
||||
</el-steps>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<template #footer>
|
||||
<div class="approval-dialog-actions">
|
||||
<el-button @click="handleClose">
|
||||
<el-icon><Close /></el-icon>取消
|
||||
</el-button>
|
||||
<el-button type="primary" :loading="submitLoading" @click="handleConfirm">
|
||||
<el-icon><Check /></el-icon>{{ confirmButtonText }}
|
||||
</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { Check, Close } from '@element-plus/icons-vue'
|
||||
import { freightApi } from '@/api/pl'
|
||||
import { fetchUserOptions } from '@/api/admin'
|
||||
|
||||
interface ApproverUser {
|
||||
userId: string
|
||||
nickName: string
|
||||
userName: string
|
||||
}
|
||||
|
||||
const emit = defineEmits<{ success: [] }>()
|
||||
|
||||
const dialogVisible = ref(false)
|
||||
const actionType = ref<'submit' | 'approve' | 'reject'>('submit')
|
||||
const settlementId = ref('')
|
||||
const approvalId = ref('')
|
||||
|
||||
const form = ref({
|
||||
approvalType: 'sequential' as 'sequential' | 'parallel' | 'or',
|
||||
approverIds: [] as string[],
|
||||
comment: '',
|
||||
remark: ''
|
||||
})
|
||||
|
||||
const approverList = ref<ApproverUser[]>([])
|
||||
const submitLoading = ref(false)
|
||||
const userLoading = ref(false)
|
||||
const formRef = ref<ElFormInstance>()
|
||||
|
||||
const rules = computed(() => {
|
||||
const baseRules: Record<string, unknown[]> = {}
|
||||
if (actionType.value === 'submit') {
|
||||
baseRules.approverIds = [{ required: true, message: '请选择审批人', trigger: 'change' }]
|
||||
}
|
||||
if (actionType.value === 'approve' || actionType.value === 'reject') {
|
||||
baseRules.comment = [{ required: true, message: '请输入审批意见', trigger: 'blur' }]
|
||||
}
|
||||
return baseRules
|
||||
})
|
||||
|
||||
const dialogTitle = computed(() => {
|
||||
const titleMap = {
|
||||
submit: '提交审批',
|
||||
approve: '审批通过',
|
||||
reject: '审批驳回'
|
||||
}
|
||||
return titleMap[actionType.value]
|
||||
})
|
||||
|
||||
const confirmButtonText = computed(() => {
|
||||
const textMap = {
|
||||
submit: '提交',
|
||||
approve: '通过',
|
||||
reject: '驳回'
|
||||
}
|
||||
return textMap[actionType.value]
|
||||
})
|
||||
|
||||
function openSubmit(id: string) {
|
||||
settlementId.value = id
|
||||
approvalId.value = ''
|
||||
actionType.value = 'submit'
|
||||
dialogVisible.value = true
|
||||
resetForm()
|
||||
loadApproverList()
|
||||
}
|
||||
|
||||
function openApprove(id: string, currentApprovalId: string) {
|
||||
settlementId.value = id
|
||||
approvalId.value = currentApprovalId
|
||||
actionType.value = 'approve'
|
||||
dialogVisible.value = true
|
||||
resetForm()
|
||||
}
|
||||
|
||||
function openReject(id: string, currentApprovalId: string) {
|
||||
settlementId.value = id
|
||||
approvalId.value = currentApprovalId
|
||||
actionType.value = 'reject'
|
||||
dialogVisible.value = true
|
||||
resetForm()
|
||||
}
|
||||
|
||||
async function loadApproverList(nickName?: string) {
|
||||
userLoading.value = true
|
||||
try {
|
||||
const res = await fetchUserOptions()
|
||||
const options = (res as { data?: unknown })?.data ?? res ?? []
|
||||
let list = (Array.isArray(options) ? options : []).map((item: Record<string, unknown>) => ({
|
||||
userId: String(item.value ?? item.userId ?? item.id ?? ''),
|
||||
nickName: String(item.label ?? item.nickName ?? item.userName ?? ''),
|
||||
userName: String(item.userNo ?? item.userName ?? '')
|
||||
}))
|
||||
if (nickName) {
|
||||
const q = nickName.toLowerCase()
|
||||
list = list.filter(
|
||||
(u) => u.nickName.toLowerCase().includes(q) || u.userName.toLowerCase().includes(q)
|
||||
)
|
||||
}
|
||||
approverList.value = list
|
||||
} catch {
|
||||
ElMessage.error('获取审批人列表失败')
|
||||
approverList.value = []
|
||||
} finally {
|
||||
userLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function handleSearchUser(query: string) {
|
||||
loadApproverList(query || undefined)
|
||||
}
|
||||
|
||||
function getApproverName(approverId: string): string {
|
||||
const approver = approverList.value.find((item) => item.userId === approverId)
|
||||
return approver ? approver.nickName : ''
|
||||
}
|
||||
|
||||
async function handleConfirm() {
|
||||
await formRef.value?.validate()
|
||||
submitLoading.value = true
|
||||
try {
|
||||
if (actionType.value === 'submit') {
|
||||
await freightApi.submitApproval(settlementId.value, {
|
||||
approvalType: form.value.approvalType,
|
||||
approverIds: form.value.approverIds,
|
||||
remark: form.value.remark || undefined
|
||||
})
|
||||
ElMessage.success('提交成功')
|
||||
} else if (actionType.value === 'approve') {
|
||||
await freightApi.processApproval(approvalId.value, {
|
||||
action: 'approve',
|
||||
comment: form.value.comment
|
||||
})
|
||||
ElMessage.success('审批通过')
|
||||
} else if (actionType.value === 'reject') {
|
||||
await freightApi.processApproval(approvalId.value, {
|
||||
action: 'reject',
|
||||
comment: form.value.comment
|
||||
})
|
||||
ElMessage.success('已驳回')
|
||||
}
|
||||
dialogVisible.value = false
|
||||
emit('success')
|
||||
} finally {
|
||||
submitLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function handleClose() {
|
||||
dialogVisible.value = false
|
||||
resetForm()
|
||||
}
|
||||
|
||||
function resetForm() {
|
||||
form.value = {
|
||||
approvalType: 'sequential',
|
||||
approverIds: [],
|
||||
comment: '',
|
||||
remark: ''
|
||||
}
|
||||
formRef.value?.clearValidate()
|
||||
}
|
||||
|
||||
defineExpose({ openSubmit, openApprove, openReject })
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.form-tip-block {
|
||||
display: block;
|
||||
margin-top: 6px;
|
||||
}
|
||||
|
||||
.approval-dialog-section {
|
||||
margin-top: 8px;
|
||||
padding-top: 16px;
|
||||
border-top: 1px solid var(--border, #d9e8e2);
|
||||
}
|
||||
|
||||
.approval-section-title {
|
||||
margin: 0 0 12px;
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
color: var(--text, #1e293b);
|
||||
}
|
||||
|
||||
.approval-flow {
|
||||
padding: 8px 0;
|
||||
}
|
||||
|
||||
.approval-dialog-actions {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
gap: 8px;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,163 @@
|
||||
<template>
|
||||
<el-dialog
|
||||
v-model="visible"
|
||||
title="财务发放登记"
|
||||
width="640px"
|
||||
align-center
|
||||
append-to-body
|
||||
destroy-on-close
|
||||
class="dialog-form-layout"
|
||||
modal-class="order-module-dialog-mask"
|
||||
:close-on-click-modal="false"
|
||||
>
|
||||
<el-form
|
||||
ref="formRef"
|
||||
v-loading="loading"
|
||||
:model="form"
|
||||
:rules="rules"
|
||||
label-position="top"
|
||||
scroll-to-error
|
||||
:scroll-into-view-options="{ behavior: 'smooth', block: 'center' }"
|
||||
>
|
||||
<div class="form-grid-2">
|
||||
<el-form-item label="结算单号">
|
||||
<el-input :model-value="settlement?.settlementNo" disabled />
|
||||
</el-form-item>
|
||||
<el-form-item label="运费合计(元)">
|
||||
<el-input :model-value="formatAmount(settlement?.totalFreight)" disabled />
|
||||
</el-form-item>
|
||||
<el-form-item label="汇款日期" prop="remittanceDate">
|
||||
<el-date-picker
|
||||
v-model="form.remittanceDate"
|
||||
type="date"
|
||||
value-format="YYYY-MM-DD"
|
||||
placeholder="选择汇款日期"
|
||||
style="width: 100%"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="汇款金额(元)" prop="remittanceAmount">
|
||||
<el-input-number
|
||||
v-model="form.remittanceAmount"
|
||||
:min="0.01"
|
||||
:precision="2"
|
||||
:controls="false"
|
||||
placeholder="请输入汇款金额"
|
||||
style="width: 100%"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="汇款凭证" prop="voucherUrls" class="form-col-span-2">
|
||||
<AttachmentUploadField
|
||||
v-model="voucherUrlsStr"
|
||||
folder="pl/freight-voucher"
|
||||
hint="请上传汇款凭证,至少 1 个附件"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="备注" prop="remark" class="form-col-span-2">
|
||||
<el-input
|
||||
v-model="form.remark"
|
||||
type="textarea"
|
||||
:rows="3"
|
||||
placeholder="请输入备注"
|
||||
maxlength="500"
|
||||
show-word-limit
|
||||
/>
|
||||
</el-form-item>
|
||||
</div>
|
||||
</el-form>
|
||||
|
||||
<template #footer>
|
||||
<el-button @click="visible = false">
|
||||
<el-icon><Close /></el-icon>取消
|
||||
</el-button>
|
||||
<el-button type="primary" :loading="submitLoading" @click="handleSubmit">
|
||||
<el-icon><Check /></el-icon>确认发放
|
||||
</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { Check, Close } from '@element-plus/icons-vue'
|
||||
import { freightApi, type FreightSettlement } from '@/api/pl'
|
||||
import AttachmentUploadField from '@/components/business/attachment-upload-field/index.vue'
|
||||
import { formatMoneyDisplay } from '@/utils/money-format'
|
||||
|
||||
const emit = defineEmits<{ success: [] }>()
|
||||
|
||||
const visible = ref(false)
|
||||
const loading = ref(false)
|
||||
const submitLoading = ref(false)
|
||||
const settlement = ref<FreightSettlement | null>(null)
|
||||
const formRef = ref<ElFormInstance>()
|
||||
const voucherUrlsStr = ref('')
|
||||
|
||||
const form = reactive({
|
||||
remittanceDate: '',
|
||||
remittanceAmount: undefined as number | undefined,
|
||||
remark: ''
|
||||
})
|
||||
|
||||
const rules = {
|
||||
remittanceDate: [{ required: true, message: '请选择汇款日期', trigger: 'change' }],
|
||||
remittanceAmount: [{ required: true, message: '请输入汇款金额', trigger: 'blur' }],
|
||||
voucherUrls: [
|
||||
{
|
||||
validator: (_rule: unknown, _value: unknown, callback: (err?: Error) => void) => {
|
||||
const urls = voucherUrlsStr.value
|
||||
.split(',')
|
||||
.map((s) => s.trim())
|
||||
.filter(Boolean)
|
||||
if (!urls.length) callback(new Error('请上传至少一个汇款凭证'))
|
||||
else callback()
|
||||
},
|
||||
trigger: 'change'
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
function formatAmount(amount?: number) {
|
||||
if (!amount) return '¥0.00'
|
||||
return formatMoneyDisplay(amount)
|
||||
}
|
||||
|
||||
async function open(id: string) {
|
||||
visible.value = true
|
||||
loading.value = true
|
||||
form.remittanceDate = ''
|
||||
form.remittanceAmount = undefined
|
||||
form.remark = ''
|
||||
voucherUrlsStr.value = ''
|
||||
try {
|
||||
const res = await freightApi.get(id)
|
||||
settlement.value = (res.data ?? res) as FreightSettlement
|
||||
form.remittanceAmount = settlement.value.totalFreight
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function handleSubmit() {
|
||||
if (!settlement.value) return
|
||||
await formRef.value?.validate()
|
||||
const voucherUrls = voucherUrlsStr.value
|
||||
.split(',')
|
||||
.map((s) => s.trim())
|
||||
.filter(Boolean)
|
||||
submitLoading.value = true
|
||||
try {
|
||||
await freightApi.disburse(settlement.value.id, {
|
||||
remittanceDate: form.remittanceDate,
|
||||
remittanceAmount: form.remittanceAmount!,
|
||||
voucherUrls,
|
||||
remark: form.remark || undefined
|
||||
})
|
||||
ElMessage.success('发放登记成功')
|
||||
visible.value = false
|
||||
emit('success')
|
||||
} finally {
|
||||
submitLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
defineExpose({ open })
|
||||
</script>
|
||||
@@ -0,0 +1,162 @@
|
||||
<template>
|
||||
<el-dialog
|
||||
v-model="visible"
|
||||
title="编辑结算单"
|
||||
width="720px"
|
||||
align-center
|
||||
append-to-body
|
||||
destroy-on-close
|
||||
class="dialog-form-layout"
|
||||
modal-class="order-module-dialog-mask"
|
||||
:close-on-click-modal="false"
|
||||
>
|
||||
<el-form
|
||||
ref="formRef"
|
||||
v-loading="loading"
|
||||
:model="form"
|
||||
:rules="rules"
|
||||
label-position="top"
|
||||
scroll-to-error
|
||||
:scroll-into-view-options="{ behavior: 'smooth', block: 'center' }"
|
||||
>
|
||||
<div class="form-grid-2">
|
||||
<el-form-item label="结算单号">
|
||||
<el-input :model-value="settlement?.settlementNo" disabled />
|
||||
</el-form-item>
|
||||
<el-form-item label="运费合计(元)">
|
||||
<el-input :model-value="formatAmount(settlement?.totalFreight)" disabled />
|
||||
</el-form-item>
|
||||
<el-form-item label="发票号" prop="invoiceNo">
|
||||
<el-input v-model="form.invoiceNo" placeholder="请输入发票号" clearable />
|
||||
</el-form-item>
|
||||
<el-form-item label="开票日期" prop="invoiceDate">
|
||||
<el-date-picker
|
||||
v-model="form.invoiceDate"
|
||||
type="date"
|
||||
value-format="YYYY-MM-DD"
|
||||
placeholder="选择开票日期"
|
||||
style="width: 100%"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="发票金额(元)" prop="invoiceAmount">
|
||||
<el-input-number
|
||||
v-model="form.invoiceAmount"
|
||||
:min="0"
|
||||
:precision="2"
|
||||
:controls="false"
|
||||
placeholder="请输入发票金额"
|
||||
style="width: 100%"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="备注" prop="remark" class="form-col-span-2">
|
||||
<el-input
|
||||
v-model="form.remark"
|
||||
type="textarea"
|
||||
:rows="3"
|
||||
placeholder="请输入备注"
|
||||
maxlength="500"
|
||||
show-word-limit
|
||||
/>
|
||||
</el-form-item>
|
||||
</div>
|
||||
</el-form>
|
||||
|
||||
<section class="dialog-section">
|
||||
<h3 class="dialog-section-title">关联运输明细</h3>
|
||||
<div class="list-body list-wrap dialog-list-body-only">
|
||||
<el-table :data="settlement?.transports || []" class="list-table" stripe empty-text="暂无数据">
|
||||
<el-table-column type="index" label="序号" min-width="60" align="center" />
|
||||
<el-table-column prop="transportNo" label="运输编号" min-width="160" show-overflow-tooltip />
|
||||
<el-table-column prop="licensePlate" label="车牌号" min-width="120" align="center" />
|
||||
<el-table-column prop="freightAmount" label="运费(元)" min-width="120" align="right">
|
||||
<template #default="{ row }">{{ formatAmount(row.freightAmount) }}</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<template #footer>
|
||||
<el-button @click="visible = false">
|
||||
<el-icon><Close /></el-icon>取消
|
||||
</el-button>
|
||||
<el-button type="primary" :loading="submitLoading" @click="handleSubmit">
|
||||
<el-icon><Check /></el-icon>保存
|
||||
</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { Check, Close } from '@element-plus/icons-vue'
|
||||
import { freightApi, type FreightSettlement } from '@/api/pl'
|
||||
import { formatMoneyDisplay } from '@/utils/money-format'
|
||||
|
||||
const emit = defineEmits<{ success: [] }>()
|
||||
|
||||
const visible = ref(false)
|
||||
const loading = ref(false)
|
||||
const submitLoading = ref(false)
|
||||
const settlement = ref<FreightSettlement | null>(null)
|
||||
const formRef = ref<ElFormInstance>()
|
||||
|
||||
const form = reactive({
|
||||
invoiceNo: '',
|
||||
invoiceDate: '',
|
||||
invoiceAmount: undefined as number | undefined,
|
||||
remark: ''
|
||||
})
|
||||
|
||||
const rules = {}
|
||||
|
||||
function formatAmount(amount?: number) {
|
||||
if (!amount) return '¥0.00'
|
||||
return formatMoneyDisplay(amount)
|
||||
}
|
||||
|
||||
async function open(id: string) {
|
||||
visible.value = true
|
||||
loading.value = true
|
||||
try {
|
||||
const res = await freightApi.get(id)
|
||||
settlement.value = (res.data ?? res) as FreightSettlement
|
||||
form.invoiceNo = settlement.value.invoiceNo || ''
|
||||
form.invoiceDate = settlement.value.invoiceDate || ''
|
||||
form.invoiceAmount = settlement.value.invoiceAmount
|
||||
form.remark = settlement.value.remark || ''
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function handleSubmit() {
|
||||
if (!settlement.value) return
|
||||
submitLoading.value = true
|
||||
try {
|
||||
await freightApi.update(settlement.value.id, {
|
||||
invoiceNo: form.invoiceNo || undefined,
|
||||
invoiceDate: form.invoiceDate || undefined,
|
||||
invoiceAmount: form.invoiceAmount,
|
||||
remark: form.remark || undefined
|
||||
})
|
||||
ElMessage.success('保存成功')
|
||||
visible.value = false
|
||||
emit('success')
|
||||
} finally {
|
||||
submitLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
defineExpose({ open })
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.dialog-section {
|
||||
margin-top: 16px;
|
||||
}
|
||||
|
||||
.dialog-section-title {
|
||||
margin: 0 0 12px;
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,230 @@
|
||||
<template>
|
||||
<el-dialog
|
||||
v-model="visible"
|
||||
:title="settlement?.settlementNo || '结算单详情'"
|
||||
width="calc(100vw - 100px)"
|
||||
align-center
|
||||
append-to-body
|
||||
destroy-on-close
|
||||
class="dialog-form-layout pl-freight-view-dialog"
|
||||
modal-class="order-module-dialog-mask"
|
||||
>
|
||||
<div v-loading="loading" class="view-dialog-body">
|
||||
<div v-if="settlement" class="view-hero">
|
||||
<div class="view-hero-main">
|
||||
<h3 class="view-hero-title">{{ settlement.settlementNo }}</h3>
|
||||
<el-tag :type="getSettlementStatusTagType(settlement.settlementStatus)" size="small">
|
||||
{{ getSettlementStatusLabel(settlement.settlementStatus) }}
|
||||
</el-tag>
|
||||
</div>
|
||||
<div class="view-hero-summary">
|
||||
<span class="view-hero-label">运费合计</span>
|
||||
<span class="view-hero-amount">{{ formatAmount(settlement.totalFreight) }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<section v-if="settlement" class="view-section">
|
||||
<h4 class="view-section-title">发票信息</h4>
|
||||
<div class="view-kv-grid">
|
||||
<div class="view-kv-item">
|
||||
<span class="view-kv-label">发票号</span>
|
||||
<span class="view-kv-value">{{ settlement.invoiceNo || '—' }}</span>
|
||||
</div>
|
||||
<div class="view-kv-item">
|
||||
<span class="view-kv-label">开票日期</span>
|
||||
<span class="view-kv-value">{{ settlement.invoiceDate || '—' }}</span>
|
||||
</div>
|
||||
<div class="view-kv-item">
|
||||
<span class="view-kv-label">发票金额</span>
|
||||
<span class="view-kv-value">{{
|
||||
settlement.invoiceAmount ? formatAmount(settlement.invoiceAmount) : '—'
|
||||
}}</span>
|
||||
</div>
|
||||
<div class="view-kv-item">
|
||||
<span class="view-kv-label">创建时间</span>
|
||||
<span class="view-kv-value">{{ formatDateTime(settlement.createTime) }}</span>
|
||||
</div>
|
||||
<div class="view-kv-item view-kv-item--full">
|
||||
<span class="view-kv-label">备注</span>
|
||||
<span class="view-kv-value">{{ settlement.remark || '—' }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section v-if="settlement" class="view-section">
|
||||
<h4 class="view-section-title">关联运输明细</h4>
|
||||
<div class="list-body list-wrap dialog-list-body-only">
|
||||
<el-table :data="settlement.transports || []" class="list-table" stripe empty-text="暂无数据">
|
||||
<el-table-column type="index" label="序号" min-width="60" align="center" />
|
||||
<el-table-column prop="transportNo" label="运输编号" min-width="160" show-overflow-tooltip />
|
||||
<el-table-column prop="licensePlate" label="车牌号" min-width="120" align="center" />
|
||||
<el-table-column prop="driverName" label="司机" min-width="100" align="center" />
|
||||
<el-table-column prop="freightAmount" label="运费(元)" min-width="120" align="right">
|
||||
<template #default="{ row }">{{ formatAmount(row.freightAmount) }}</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section v-if="settlement?.approvalFlow?.length" class="view-section">
|
||||
<h4 class="view-section-title">审批流程</h4>
|
||||
<ApprovalFlowView :nodes="approvalNodes" :loading="false" />
|
||||
</section>
|
||||
|
||||
<section
|
||||
v-if="settlement?.settlementStatus === 'confirmed' && settlement.vouchers?.length"
|
||||
class="view-section"
|
||||
>
|
||||
<h4 class="view-section-title">汇款凭证</h4>
|
||||
<div class="list-body list-wrap dialog-list-body-only">
|
||||
<el-table :data="settlement.vouchers" class="list-table" stripe>
|
||||
<el-table-column prop="remittanceDate" label="汇款日期" min-width="120" align="center" />
|
||||
<el-table-column prop="remittanceAmount" label="汇款金额" min-width="120" align="right">
|
||||
<template #default="{ row }">{{ formatAmount(row.remittanceAmount) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="remark" label="备注" min-width="160" show-overflow-tooltip />
|
||||
<el-table-column prop="createTime" label="登记时间" min-width="160" align="center">
|
||||
<template #default="{ row }">{{ formatDateTime(row.createTime) }}</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
<template #footer>
|
||||
<el-button @click="visible = false">
|
||||
<el-icon><Close /></el-icon>关闭
|
||||
</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { Close } from '@element-plus/icons-vue'
|
||||
import { freightApi, type FreightSettlement } from '@/api/pl'
|
||||
import ApprovalFlowView from '@/components/bx/base/ApprovalFlowView.vue'
|
||||
import {
|
||||
getSettlementStatusLabel,
|
||||
getSettlementStatusTagType,
|
||||
mapApprovalFlowToNodes
|
||||
} from '@/views/pl/freight/freight-status'
|
||||
import { formatMoneyDisplay } from '@/utils/money-format'
|
||||
import { formatDateTime } from '@/utils/format'
|
||||
|
||||
const visible = ref(false)
|
||||
const loading = ref(false)
|
||||
const settlement = ref<FreightSettlement | null>(null)
|
||||
|
||||
const approvalNodes = computed(() =>
|
||||
mapApprovalFlowToNodes(settlement.value?.approvalFlow || [])
|
||||
)
|
||||
|
||||
function formatAmount(amount?: number) {
|
||||
if (!amount) return '¥0.00'
|
||||
return formatMoneyDisplay(amount)
|
||||
}
|
||||
|
||||
async function open(id: string) {
|
||||
visible.value = true
|
||||
loading.value = true
|
||||
try {
|
||||
const res = await freightApi.get(id)
|
||||
settlement.value = (res.data ?? res) as FreightSettlement
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
defineExpose({ open })
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.view-dialog-body {
|
||||
min-height: 120px;
|
||||
}
|
||||
|
||||
.view-hero {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
justify-content: space-between;
|
||||
gap: 16px;
|
||||
padding: 16px;
|
||||
margin-bottom: 16px;
|
||||
border-radius: 10px;
|
||||
background: var(--primary-bg, #ecfdf5);
|
||||
border: 1px solid #a7f3d0;
|
||||
}
|
||||
|
||||
.view-hero-main {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.view-hero-title {
|
||||
margin: 0;
|
||||
font-size: 18px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.view-hero-summary {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-end;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.view-hero-label {
|
||||
font-size: 12px;
|
||||
color: var(--text-muted, #64748b);
|
||||
}
|
||||
|
||||
.view-hero-amount {
|
||||
font-size: 20px;
|
||||
font-weight: 700;
|
||||
color: var(--primary-dark, #059669);
|
||||
}
|
||||
|
||||
.view-section {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.view-section-title {
|
||||
margin: 0 0 12px;
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.view-kv-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: 12px 24px;
|
||||
}
|
||||
|
||||
.view-kv-item {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.view-kv-item--full {
|
||||
grid-column: 1 / -1;
|
||||
}
|
||||
|
||||
.view-kv-label {
|
||||
font-size: 12px;
|
||||
color: var(--text-muted, #64748b);
|
||||
}
|
||||
|
||||
.view-kv-value {
|
||||
font-size: 14px;
|
||||
color: var(--text, #1e293b);
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
@media (max-width: 640px) {
|
||||
.view-kv-grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,400 @@
|
||||
<!-- eslint-disable vue/no-v-model-argument -->
|
||||
<template>
|
||||
<el-dialog
|
||||
v-model="innerVisible"
|
||||
:title="dialogTitle"
|
||||
align-center
|
||||
destroy-on-close
|
||||
append-to-body
|
||||
class="dialog-form-layout pl-plan-archive-dialog"
|
||||
modal-class="order-module-dialog-mask"
|
||||
:close-on-click-modal="false"
|
||||
style="backdrop-filter: none"
|
||||
@closed="handleClosed"
|
||||
@opened="handleOpened"
|
||||
>
|
||||
<div class="pl-arrange-layout">
|
||||
<section class="pl-arrange-form-panel">
|
||||
<div v-loading="loading" class="pl-arrange-form-scroll">
|
||||
<section class="pl-plan-form-section">
|
||||
<h3 class="pl-plan-form-section-title">产品实际数量</h3>
|
||||
<PlPlanFormProductTable
|
||||
:products="productRows"
|
||||
show-actual-qty
|
||||
editable-actual-qty-only
|
||||
/>
|
||||
</section>
|
||||
|
||||
<section class="pl-plan-form-section">
|
||||
<h4 class="pl-plan-subtitle">运费信息</h4>
|
||||
<div class="form-grid-4">
|
||||
<el-form-item label="是否有运输费用">
|
||||
<el-switch v-model="formData.hasFreight" :active-value="1" :inactive-value="0" />
|
||||
</el-form-item>
|
||||
<template v-if="formData.hasFreight === 1">
|
||||
<el-form-item label="运输公里数">
|
||||
<el-input-number
|
||||
v-model="formData.distanceKm"
|
||||
:min="0"
|
||||
:precision="2"
|
||||
style="width: 100%"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="运费计算方式">
|
||||
<el-select v-model="formData.freightType">
|
||||
<el-option label="按重量" value="by_weight" />
|
||||
<el-option label="按趟" value="by_trip" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item
|
||||
v-if="formData.freightType === 'by_weight'"
|
||||
:label="`运输量(${freightUnitLabel})`"
|
||||
>
|
||||
<el-input-number
|
||||
v-model="freightCalc.transportQty.value"
|
||||
:min="0"
|
||||
:precision="3"
|
||||
style="width: 100%"
|
||||
@change="freightCalc.markTransportQtyTouched()"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item
|
||||
v-if="formData.freightType === 'by_weight'"
|
||||
:label="`运输单价(元/${freightUnitLabel})`"
|
||||
>
|
||||
<el-input-number
|
||||
v-model="freightCalc.freightPrice.value"
|
||||
:min="0"
|
||||
:precision="2"
|
||||
style="width: 100%"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="运费金额(元)">
|
||||
<el-input-number
|
||||
v-model="freightCalc.freightAmount.value"
|
||||
:min="0"
|
||||
:precision="2"
|
||||
style="width: 100%"
|
||||
@change="freightCalc.markFreightAmountTouched()"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="是否开票">
|
||||
<el-switch v-model="formData.hasInvoice" :active-value="1" :inactive-value="0" />
|
||||
</el-form-item>
|
||||
</template>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="pl-arrange-view-panel">
|
||||
<h3 class="pl-arrange-view-title">计划单查看</h3>
|
||||
<PlPlanViewTabs v-if="planId" ref="tabsRef" :plan-id="planId" embedded />
|
||||
</section>
|
||||
</div>
|
||||
|
||||
<template #footer>
|
||||
<div class="dialog-footer pl-arrange-footer">
|
||||
<el-button @click="innerVisible = false">
|
||||
<el-icon><Close /></el-icon>取消
|
||||
</el-button>
|
||||
<el-button type="primary" :loading="submitLoading" @click="handleSubmit">
|
||||
<el-icon><Check /></el-icon>{{ submitLabel }}
|
||||
</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { Check, Close } from '@element-plus/icons-vue'
|
||||
import {
|
||||
planApi,
|
||||
transportApi,
|
||||
type Plan,
|
||||
type PlanArchiveBody,
|
||||
type PlanProduct,
|
||||
type Transport
|
||||
} from '@/api/pl'
|
||||
import PlPlanFormProductTable from '@/components/business/pl-plan-form-dialog/PlPlanFormProductTable.vue'
|
||||
import PlPlanViewTabs from '@/components/business/pl-plan-view-tabs/index.vue'
|
||||
import type { PlanFormProductRow } from '@/composables/usePlContractToPlan'
|
||||
import { usePlFreightCalc, resolveFreightUnitLabel } from '@/composables/usePlFreightCalc'
|
||||
import { pickBxData } from '@/utils/http/bx'
|
||||
|
||||
const props = defineProps<{
|
||||
visible: boolean
|
||||
planId: string
|
||||
}>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
'update:visible': [value: boolean]
|
||||
success: []
|
||||
}>()
|
||||
|
||||
const innerVisible = computed({
|
||||
get: () => props.visible,
|
||||
set: value => emit('update:visible', value)
|
||||
})
|
||||
|
||||
const loading = ref(false)
|
||||
const submitLoading = ref(false)
|
||||
const tabsRef = ref<InstanceType<typeof PlPlanViewTabs> | null>(null)
|
||||
const plan = ref<Partial<Plan>>({})
|
||||
const productRows = ref<PlanFormProductRow[]>([])
|
||||
|
||||
const formData = reactive({
|
||||
hasFreight: 0,
|
||||
distanceKm: null as number | null,
|
||||
freightType: 'by_weight',
|
||||
hasInvoice: 0
|
||||
})
|
||||
|
||||
const hasFreightRef = computed(() => formData.hasFreight)
|
||||
const freightTypeRef = computed(() => formData.freightType)
|
||||
const freightCalc = usePlFreightCalc({
|
||||
products: productRows,
|
||||
hasFreight: hasFreightRef,
|
||||
freightType: freightTypeRef
|
||||
})
|
||||
|
||||
const freightUnitLabel = computed(() => resolveFreightUnitLabel(productRows.value))
|
||||
|
||||
const isAdjustMode = computed(() => plan.value.archiveStatus === 'archived')
|
||||
|
||||
const dialogTitle = computed(() => {
|
||||
const no = plan.value.planNo || ''
|
||||
return isAdjustMode.value
|
||||
? no
|
||||
? `调整归档内容 · ${no}`
|
||||
: '调整归档内容'
|
||||
: no
|
||||
? `运输计划归档 · ${no}`
|
||||
: '运输计划归档'
|
||||
})
|
||||
|
||||
const submitLabel = computed(() => (isAdjustMode.value ? '确认保存' : '确认归档'))
|
||||
|
||||
function mapPlanProducts(products: PlanProduct[]): PlanFormProductRow[] {
|
||||
return products.map((item, index) => ({
|
||||
id: item.id,
|
||||
productId: String(item.productId || index),
|
||||
productNo: item.productNo || String(item.productId || index),
|
||||
productName: item.productName || '',
|
||||
model: item.model,
|
||||
categoryName: item.categoryName,
|
||||
unit: item.unit || '吨',
|
||||
quantity: Number(item.quantity ?? item.inboundEstimateQty ?? item.outboundEstimateQty ?? 0),
|
||||
actualQty: Number(
|
||||
item.actualQty ?? item.quantity ?? item.inboundEstimateQty ?? item.outboundEstimateQty ?? 0
|
||||
),
|
||||
packageSpec: item.packageSpec,
|
||||
deliveryMethod: item.deliveryMethod,
|
||||
taxPrice: item.taxPrice != null ? Number(item.taxPrice) : undefined,
|
||||
taxAmount: item.taxAmount != null ? Number(item.taxAmount) : undefined,
|
||||
taxSubtotal: item.taxSubtotal != null ? Number(item.taxSubtotal) : undefined,
|
||||
remark: item.remark,
|
||||
isExplosive: Number(item.isExplosive ?? 0),
|
||||
isToxic: Number(item.isToxic ?? 0)
|
||||
}))
|
||||
}
|
||||
|
||||
function resetState() {
|
||||
plan.value = {}
|
||||
productRows.value = []
|
||||
Object.assign(formData, {
|
||||
hasFreight: 0,
|
||||
distanceKm: null,
|
||||
freightType: 'by_weight',
|
||||
hasInvoice: 0
|
||||
})
|
||||
freightCalc.resetFreightCalc()
|
||||
}
|
||||
|
||||
async function applyFreightPrefill(data: Plan) {
|
||||
formData.hasFreight = data.hasFreight ?? 0
|
||||
freightCalc.resetFreightCalc()
|
||||
|
||||
if (data.freightAmount != null && data.hasFreight === 1) {
|
||||
freightCalc.freightAmount.value = Number(data.freightAmount)
|
||||
freightCalc.freightAmountTouched.value = true
|
||||
}
|
||||
|
||||
if (!data.transportId) return
|
||||
|
||||
try {
|
||||
const transportRes = await transportApi.get(data.transportId)
|
||||
const transport = pickBxData<Transport>(transportRes)
|
||||
formData.distanceKm = transport.distanceKm != null ? Number(transport.distanceKm) : null
|
||||
formData.freightType = transport.freightType || 'by_weight'
|
||||
formData.hasInvoice = transport.hasInvoice ?? 0
|
||||
|
||||
if (transport.transportQty != null) {
|
||||
freightCalc.transportQty.value = Number(transport.transportQty)
|
||||
freightCalc.transportQtyTouched.value = true
|
||||
}
|
||||
if (transport.freightPrice != null) {
|
||||
freightCalc.freightPrice.value = Number(transport.freightPrice)
|
||||
}
|
||||
if (transport.freightAmount != null) {
|
||||
freightCalc.freightAmount.value = Number(transport.freightAmount)
|
||||
freightCalc.freightAmountTouched.value = true
|
||||
}
|
||||
} catch {
|
||||
// 回退计划主表冗余字段
|
||||
}
|
||||
}
|
||||
|
||||
async function handleOpened() {
|
||||
if (!props.planId) return
|
||||
loading.value = true
|
||||
resetState()
|
||||
try {
|
||||
const res = await planApi.get(props.planId)
|
||||
const data = pickBxData<Plan>(res)
|
||||
if (!data?.id) {
|
||||
throw new Error('运输计划数据无效')
|
||||
}
|
||||
plan.value = data
|
||||
productRows.value = mapPlanProducts(Array.isArray(data.products) ? data.products : [])
|
||||
await applyFreightPrefill(data)
|
||||
} catch (error) {
|
||||
innerVisible.value = false
|
||||
const message = error instanceof Error ? error.message : '加载运输计划失败'
|
||||
ElMessage.error(message.includes('加载') ? message : `加载运输计划失败:${message}`)
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function handleClosed() {
|
||||
resetState()
|
||||
}
|
||||
|
||||
async function handleSubmit() {
|
||||
if (!productRows.value.length) {
|
||||
ElMessage.warning('暂无产品明细')
|
||||
return
|
||||
}
|
||||
if (productRows.value.some(row => !row.id)) {
|
||||
ElMessage.error('产品明细缺少行 ID,无法提交')
|
||||
return
|
||||
}
|
||||
if (productRows.value.some(row => row.actualQty == null || Number(row.actualQty) < 0)) {
|
||||
ElMessage.warning('请填写有效的实际数量')
|
||||
return
|
||||
}
|
||||
if (formData.hasFreight === 1 && !plan.value.transportId) {
|
||||
ElMessage.warning('计划有运输费用但未安排运输,请先安排运输')
|
||||
return
|
||||
}
|
||||
|
||||
submitLoading.value = true
|
||||
try {
|
||||
const body: PlanArchiveBody = {
|
||||
products: productRows.value.map(row => ({
|
||||
id: row.id!,
|
||||
actualQty: Number(row.actualQty ?? 0)
|
||||
})),
|
||||
freight: {
|
||||
hasFreight: formData.hasFreight,
|
||||
...(formData.hasFreight === 1
|
||||
? {
|
||||
distanceKm: formData.distanceKm ?? undefined,
|
||||
freightType: formData.freightType,
|
||||
freightPrice:
|
||||
formData.freightType === 'by_weight'
|
||||
? freightCalc.freightPrice.value ?? undefined
|
||||
: undefined,
|
||||
freightAmount:
|
||||
freightCalc.calculatedFreight.value || freightCalc.freightAmount.value || undefined,
|
||||
transportQty:
|
||||
formData.freightType === 'by_weight'
|
||||
? freightCalc.transportQty.value ?? undefined
|
||||
: undefined,
|
||||
hasInvoice: formData.hasInvoice
|
||||
}
|
||||
: {})
|
||||
}
|
||||
}
|
||||
|
||||
await planApi.archive(props.planId, body)
|
||||
ElMessage.success(isAdjustMode.value ? '保存成功' : '归档成功')
|
||||
tabsRef.value?.reload()
|
||||
emit('success')
|
||||
innerVisible.value = false
|
||||
} catch (e: unknown) {
|
||||
const message = e instanceof Error ? e.message : isAdjustMode.value ? '保存失败' : '归档失败'
|
||||
ElMessage.error(message)
|
||||
} finally {
|
||||
submitLoading.value = false
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.pl-arrange-layout {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 16px;
|
||||
min-height: 480px;
|
||||
}
|
||||
|
||||
.pl-arrange-form-panel {
|
||||
flex: 0 0 auto;
|
||||
max-height: 52vh;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.pl-arrange-form-scroll {
|
||||
max-height: 52vh;
|
||||
overflow-y: auto;
|
||||
padding-right: 4px;
|
||||
}
|
||||
|
||||
.pl-arrange-view-panel {
|
||||
flex: 1 1 auto;
|
||||
min-height: 280px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.pl-arrange-view-title {
|
||||
margin: 0 0 12px;
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
color: #1e293b;
|
||||
}
|
||||
|
||||
.pl-plan-subtitle {
|
||||
margin: 16px 0 10px;
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
color: #475569;
|
||||
}
|
||||
|
||||
.pl-plan-subtitle:first-of-type {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
.pl-arrange-freight-muted {
|
||||
margin-bottom: 12px;
|
||||
font-size: 13px;
|
||||
color: #64748b;
|
||||
}
|
||||
|
||||
.pl-arrange-footer {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
</style>
|
||||
|
||||
<style lang="scss">
|
||||
.el-dialog.pl-plan-archive-dialog.dialog-form-layout {
|
||||
width: min(1680px, calc(100vw - 80px)) !important;
|
||||
max-height: calc(100vh - 48px);
|
||||
}
|
||||
</style>
|
||||
@@ -27,7 +27,7 @@
|
||||
<el-table-column label="计划数量" min-width="110" align="right">
|
||||
<template #default="{ row }">
|
||||
<el-input-number
|
||||
v-if="editableQty"
|
||||
v-if="editableQty && !editableActualQtyOnly"
|
||||
v-model="row.quantity"
|
||||
:min="0"
|
||||
:precision="3"
|
||||
@@ -40,7 +40,7 @@
|
||||
<el-table-column v-if="showActualQty" label="实际数量" min-width="110" align="right">
|
||||
<template #default="{ row }">
|
||||
<el-input-number
|
||||
v-if="editableQty"
|
||||
v-if="(editableQty && showActualQty) || editableActualQtyOnly"
|
||||
v-model="row.actualQty"
|
||||
:min="0"
|
||||
:precision="3"
|
||||
@@ -98,6 +98,8 @@ defineProps<{
|
||||
editableQty?: boolean
|
||||
/** 新增/编辑弹窗默认不展示实际数量 */
|
||||
showActualQty?: boolean
|
||||
/** 仅实际数量可编辑,计划数量只读(归档弹窗) */
|
||||
editableActualQtyOnly?: boolean
|
||||
}>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
|
||||
@@ -53,6 +53,13 @@ export const plRoutes: AppRouteRecord[] = [
|
||||
component: '/pl/plan/index',
|
||||
meta: { title: '运输计划', keepAlive: true, menuCode: 'pl:plan:list' }
|
||||
},
|
||||
{
|
||||
id: 'PL00000000000000000000000000016',
|
||||
name: 'PlPlanArchive',
|
||||
path: 'plan-archive',
|
||||
component: '/pl/plan-archive/index',
|
||||
meta: { title: '运输计划归档', keepAlive: true, menuCode: 'pl:plan-archive:list' }
|
||||
},
|
||||
{
|
||||
id: 'PL00000000000000000000000000015',
|
||||
name: 'PlPlanCert',
|
||||
|
||||
@@ -117,6 +117,7 @@ export const SIDEBAR_MENU_ICON_BY_CODE: Record<string, string> = {
|
||||
'pl:self-vehicle:list': 'ri:car-line',
|
||||
'pl:driver:list': 'ri:user-settings-line',
|
||||
'pl:plan:list': 'ri:route-line',
|
||||
'pl:plan-archive:list': 'ri:folder-check-line',
|
||||
'pl:plan-cert:list': 'ri:shield-check-line',
|
||||
'pl:freight:list': 'ri:money-cny-box-line',
|
||||
'pl:document:list': 'ri:alarm-warning-line'
|
||||
|
||||
@@ -0,0 +1,171 @@
|
||||
<template>
|
||||
<div class="freight-tab-panel">
|
||||
<div class="filter-block">
|
||||
<el-form :model="searchForm" class="filter-form" @submit.prevent>
|
||||
<div class="filter-grid">
|
||||
<el-form-item label="结算单号">
|
||||
<el-input
|
||||
v-model="searchForm.q"
|
||||
placeholder="搜索结算单号"
|
||||
clearable
|
||||
@keyup.enter="handleSearch"
|
||||
/>
|
||||
</el-form-item>
|
||||
</div>
|
||||
<div class="filter-actions">
|
||||
<div class="filter-actions-end">
|
||||
<el-button class="btn-ghost" :loading="loading" @click="handleReset">
|
||||
<el-icon><RefreshLeft /></el-icon>重置
|
||||
</el-button>
|
||||
<el-button class="btn-main" type="primary" :loading="loading" @click="handleSearch">
|
||||
<el-icon><Search /></el-icon>搜索
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</el-form>
|
||||
</div>
|
||||
|
||||
<div class="list-toolbar">
|
||||
<div class="list-toolbar-row">
|
||||
<div class="list-toolbar-selected">已选 <span class="sel-num">0</span> 项</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="list-body list-wrap">
|
||||
<el-table class="list-table" :data="settlementList" v-loading="loading" stripe row-key="id">
|
||||
<el-table-column prop="settlementNo" label="结算单号" min-width="180" show-overflow-tooltip>
|
||||
<template #default="{ row }">
|
||||
<el-link type="primary" @click="handleView(row)">{{ row.settlementNo }}</el-link>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="totalFreight" label="运费合计(元)" min-width="130" align="right">
|
||||
<template #default="{ row }">{{ formatAmount(row.totalFreight) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="planCount" label="关联计划数" min-width="110" align="center" />
|
||||
<el-table-column prop="licensePlateSummary" label="车牌摘要" min-width="140" show-overflow-tooltip />
|
||||
<el-table-column prop="approvalFinishedTime" label="审批完成时间" min-width="160" align="center">
|
||||
<template #default="{ row }">{{
|
||||
row.approvalFinishedTime ? formatDateTime(row.approvalFinishedTime) : '—'
|
||||
}}</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="submitterName" label="提交人" min-width="100" align="center">
|
||||
<template #default="{ row }">{{ row.submitterName || '—' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" min-width="200" fixed="right" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-button link type="primary" @click="handleView(row)">
|
||||
<el-icon><View /></el-icon>查看
|
||||
</el-button>
|
||||
<el-button link type="primary" @click="handleDisburse(row)">
|
||||
<el-icon><Money /></el-icon>发放登记
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<div class="pagination list-pager-bar">
|
||||
<el-pagination
|
||||
v-model:current-page="pagination.page"
|
||||
v-model:page-size="pagination.pageSize"
|
||||
:total="pagination.total"
|
||||
:page-sizes="[10, 20, 50, 100]"
|
||||
layout="total, sizes, prev, pager, next"
|
||||
@size-change="handleSizeChange"
|
||||
@current-change="handlePageChange"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<PlFreightSettlementViewDialog ref="viewDialogRef" />
|
||||
<PlFreightDisburseDialog ref="disburseDialogRef" @success="handleDisburseSuccess" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { Money, RefreshLeft, Search, View } from '@element-plus/icons-vue'
|
||||
import { freightApi, type FreightSettlement } from '@/api/pl'
|
||||
import PlFreightDisburseDialog from '@/components/business/pl-freight-disburse-dialog/index.vue'
|
||||
import PlFreightSettlementViewDialog from '@/components/business/pl-freight-settlement-view-dialog/index.vue'
|
||||
import { formatMoneyDisplay } from '@/utils/money-format'
|
||||
import { formatDateTime } from '@/utils/format'
|
||||
|
||||
const emit = defineEmits<{ disbursed: [] }>()
|
||||
|
||||
const loading = ref(false)
|
||||
const settlementList = ref<FreightSettlement[]>([])
|
||||
const viewDialogRef = ref<InstanceType<typeof PlFreightSettlementViewDialog>>()
|
||||
const disburseDialogRef = ref<InstanceType<typeof PlFreightDisburseDialog>>()
|
||||
|
||||
const searchForm = reactive({ q: '' })
|
||||
|
||||
const pagination = reactive({
|
||||
page: 1,
|
||||
pageSize: 20,
|
||||
total: 0
|
||||
})
|
||||
|
||||
function formatAmount(amount: number) {
|
||||
if (!amount) return '¥0.00'
|
||||
return formatMoneyDisplay(amount)
|
||||
}
|
||||
|
||||
async function fetchData() {
|
||||
loading.value = true
|
||||
try {
|
||||
const res = await freightApi.list({
|
||||
tab: 'disburse',
|
||||
q: searchForm.q || undefined,
|
||||
page: pagination.page,
|
||||
pageSize: pagination.pageSize
|
||||
})
|
||||
const data = res.data ?? res
|
||||
settlementList.value = data.list || []
|
||||
pagination.total = data.total || 0
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function handleSearch() {
|
||||
pagination.page = 1
|
||||
fetchData()
|
||||
}
|
||||
|
||||
function handleReset() {
|
||||
searchForm.q = ''
|
||||
pagination.page = 1
|
||||
fetchData()
|
||||
}
|
||||
|
||||
function handlePageChange() {
|
||||
fetchData()
|
||||
}
|
||||
|
||||
function handleSizeChange() {
|
||||
pagination.page = 1
|
||||
fetchData()
|
||||
}
|
||||
|
||||
function handleView(row: FreightSettlement) {
|
||||
viewDialogRef.value?.open(row.id)
|
||||
}
|
||||
|
||||
function handleDisburse(row: FreightSettlement) {
|
||||
disburseDialogRef.value?.open(row.id)
|
||||
}
|
||||
|
||||
function handleDisburseSuccess() {
|
||||
fetchData()
|
||||
emit('disbursed')
|
||||
}
|
||||
|
||||
function refresh() {
|
||||
fetchData()
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
fetchData()
|
||||
})
|
||||
|
||||
defineExpose({ refresh })
|
||||
</script>
|
||||
@@ -0,0 +1,165 @@
|
||||
<template>
|
||||
<div class="freight-tab-panel">
|
||||
<div class="filter-block">
|
||||
<el-form :model="searchForm" class="filter-form" @submit.prevent>
|
||||
<div class="filter-grid">
|
||||
<el-form-item label="结算单号">
|
||||
<el-input
|
||||
v-model="searchForm.q"
|
||||
placeholder="搜索结算单号"
|
||||
clearable
|
||||
@keyup.enter="handleSearch"
|
||||
/>
|
||||
</el-form-item>
|
||||
</div>
|
||||
<div class="filter-actions">
|
||||
<div class="filter-actions-end">
|
||||
<el-button class="btn-ghost" :loading="loading" @click="handleReset">
|
||||
<el-icon><RefreshLeft /></el-icon>重置
|
||||
</el-button>
|
||||
<el-button class="btn-main" type="primary" :loading="loading" @click="handleSearch">
|
||||
<el-icon><Search /></el-icon>搜索
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</el-form>
|
||||
</div>
|
||||
|
||||
<div class="list-toolbar">
|
||||
<div class="list-toolbar-row">
|
||||
<div class="list-toolbar-selected">已选 <span class="sel-num">0</span> 项</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="list-body list-wrap">
|
||||
<el-table class="list-table" :data="settlementList" v-loading="loading" stripe row-key="id">
|
||||
<el-table-column prop="settlementNo" label="结算单号" min-width="180" show-overflow-tooltip>
|
||||
<template #default="{ row }">
|
||||
<el-link type="primary" @click="handleView(row)">{{ row.settlementNo }}</el-link>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="totalFreight" label="运费合计(元)" min-width="130" align="right">
|
||||
<template #default="{ row }">{{ formatAmount(row.totalFreight) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="disburseAmount" label="发放金额(元)" min-width="130" align="right">
|
||||
<template #default="{ row }">{{
|
||||
row.disburseAmount ? formatAmount(row.disburseAmount) : '—'
|
||||
}}</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="disburseTime" label="发放时间" min-width="160" align="center">
|
||||
<template #default="{ row }">{{
|
||||
row.disburseTime ? formatDateTime(row.disburseTime) : '—'
|
||||
}}</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="settlementStatus" label="结算状态" min-width="100" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-tag :type="getSettlementStatusTagType(row.settlementStatus)" size="small">
|
||||
{{ getSettlementStatusLabel(row.settlementStatus) }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" min-width="120" fixed="right" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-button link type="primary" @click="handleView(row)">
|
||||
<el-icon><View /></el-icon>查看
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<div class="pagination list-pager-bar">
|
||||
<el-pagination
|
||||
v-model:current-page="pagination.page"
|
||||
v-model:page-size="pagination.pageSize"
|
||||
:total="pagination.total"
|
||||
:page-sizes="[10, 20, 50, 100]"
|
||||
layout="total, sizes, prev, pager, next"
|
||||
@size-change="handleSizeChange"
|
||||
@current-change="handlePageChange"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<PlFreightSettlementViewDialog ref="viewDialogRef" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { RefreshLeft, Search, View } from '@element-plus/icons-vue'
|
||||
import { freightApi, type FreightSettlement } from '@/api/pl'
|
||||
import PlFreightSettlementViewDialog from '@/components/business/pl-freight-settlement-view-dialog/index.vue'
|
||||
import {
|
||||
getSettlementStatusLabel,
|
||||
getSettlementStatusTagType
|
||||
} from '@/views/pl/freight/freight-status'
|
||||
import { formatMoneyDisplay } from '@/utils/money-format'
|
||||
import { formatDateTime } from '@/utils/format'
|
||||
|
||||
const loading = ref(false)
|
||||
const settlementList = ref<FreightSettlement[]>([])
|
||||
const viewDialogRef = ref<InstanceType<typeof PlFreightSettlementViewDialog>>()
|
||||
|
||||
const searchForm = reactive({ q: '' })
|
||||
|
||||
const pagination = reactive({
|
||||
page: 1,
|
||||
pageSize: 20,
|
||||
total: 0
|
||||
})
|
||||
|
||||
function formatAmount(amount: number) {
|
||||
if (!amount) return '¥0.00'
|
||||
return formatMoneyDisplay(amount)
|
||||
}
|
||||
|
||||
async function fetchData() {
|
||||
loading.value = true
|
||||
try {
|
||||
const res = await freightApi.list({
|
||||
tab: 'settled',
|
||||
q: searchForm.q || undefined,
|
||||
page: pagination.page,
|
||||
pageSize: pagination.pageSize
|
||||
})
|
||||
const data = res.data ?? res
|
||||
settlementList.value = data.list || []
|
||||
pagination.total = data.total || 0
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function handleSearch() {
|
||||
pagination.page = 1
|
||||
fetchData()
|
||||
}
|
||||
|
||||
function handleReset() {
|
||||
searchForm.q = ''
|
||||
pagination.page = 1
|
||||
fetchData()
|
||||
}
|
||||
|
||||
function handlePageChange() {
|
||||
fetchData()
|
||||
}
|
||||
|
||||
function handleSizeChange() {
|
||||
pagination.page = 1
|
||||
fetchData()
|
||||
}
|
||||
|
||||
function handleView(row: FreightSettlement) {
|
||||
viewDialogRef.value?.open(row.id)
|
||||
}
|
||||
|
||||
function refresh() {
|
||||
fetchData()
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
fetchData()
|
||||
})
|
||||
|
||||
defineExpose({ refresh })
|
||||
</script>
|
||||
@@ -0,0 +1,274 @@
|
||||
<template>
|
||||
<div class="freight-tab-panel">
|
||||
<div class="filter-block">
|
||||
<el-form :model="searchForm" class="filter-form" @submit.prevent>
|
||||
<div class="filter-grid">
|
||||
<el-form-item label="结算单号">
|
||||
<el-input
|
||||
v-model="searchForm.q"
|
||||
placeholder="搜索结算单号"
|
||||
clearable
|
||||
@keyup.enter="handleSearch"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="结算状态">
|
||||
<el-select v-model="searchForm.settlementStatus" placeholder="全部" clearable>
|
||||
<el-option label="草稿" value="pending" />
|
||||
<el-option label="审批中" value="approving" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</div>
|
||||
<div class="filter-actions">
|
||||
<div class="filter-actions-end">
|
||||
<el-button class="btn-ghost" :loading="loading" @click="handleReset">
|
||||
<el-icon><RefreshLeft /></el-icon>重置
|
||||
</el-button>
|
||||
<el-button class="btn-main" type="primary" :loading="loading" @click="handleSearch">
|
||||
<el-icon><Search /></el-icon>搜索
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</el-form>
|
||||
</div>
|
||||
|
||||
<div class="list-toolbar">
|
||||
<div class="list-toolbar-row">
|
||||
<div class="list-toolbar-selected">已选 <span class="sel-num">0</span> 项</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="list-body list-wrap">
|
||||
<el-table class="list-table" :data="settlementList" v-loading="loading" stripe row-key="id">
|
||||
<el-table-column prop="settlementNo" label="结算单号" min-width="180" show-overflow-tooltip>
|
||||
<template #default="{ row }">
|
||||
<el-link type="primary" @click="handleView(row)">{{ row.settlementNo }}</el-link>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="totalFreight" label="运费合计(元)" min-width="130" align="right">
|
||||
<template #default="{ row }">{{ formatAmount(row.totalFreight) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="planCount" label="关联计划数" min-width="110" align="center" />
|
||||
<el-table-column prop="licensePlateSummary" label="车牌摘要" min-width="140" show-overflow-tooltip />
|
||||
<el-table-column prop="settlementStatus" label="结算状态" min-width="100" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-tag :type="getSettlementStatusTagType(row.settlementStatus)" size="small">
|
||||
{{ getSettlementStatusLabel(row.settlementStatus) }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="currentApproverName" label="当前审批人" min-width="110" align="center">
|
||||
<template #default="{ row }">{{ row.currentApproverName || '—' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="submitterName" label="创建人" min-width="100" align="center">
|
||||
<template #default="{ row }">{{ row.submitterName || '—' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="createTime" label="创建时间" min-width="160" align="center">
|
||||
<template #default="{ row }">{{ formatDateTime(row.createTime) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" min-width="320" fixed="right" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-button link type="primary" @click="handleView(row)">
|
||||
<el-icon><View /></el-icon>查看
|
||||
</el-button>
|
||||
<el-button
|
||||
v-if="row.settlementStatus === 'pending'"
|
||||
link
|
||||
type="primary"
|
||||
@click="handleEdit(row)"
|
||||
>
|
||||
<el-icon><Edit /></el-icon>编辑
|
||||
</el-button>
|
||||
<el-button
|
||||
v-if="row.settlementStatus === 'pending'"
|
||||
link
|
||||
type="primary"
|
||||
@click="handleSubmit(row)"
|
||||
>
|
||||
<el-icon><Promotion /></el-icon>提交审批
|
||||
</el-button>
|
||||
<el-button
|
||||
v-if="row.settlementStatus === 'pending'"
|
||||
link
|
||||
type="danger"
|
||||
@click="handleDelete(row)"
|
||||
>
|
||||
<el-icon><Delete /></el-icon>删除
|
||||
</el-button>
|
||||
<el-button
|
||||
v-if="row.canWithdraw"
|
||||
link
|
||||
type="warning"
|
||||
@click="handleWithdraw(row)"
|
||||
>
|
||||
<el-icon><RefreshLeft /></el-icon>撤回
|
||||
</el-button>
|
||||
<el-button
|
||||
v-if="row.canApprove && row.currentApprovalId"
|
||||
link
|
||||
type="success"
|
||||
@click="handleApprove(row)"
|
||||
>
|
||||
<el-icon><CircleCheck /></el-icon>审批
|
||||
</el-button>
|
||||
<el-button
|
||||
v-if="row.canApprove && row.currentApprovalId"
|
||||
link
|
||||
type="danger"
|
||||
@click="handleReject(row)"
|
||||
>
|
||||
<el-icon><CircleClose /></el-icon>驳回
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<div class="pagination list-pager-bar">
|
||||
<el-pagination
|
||||
v-model:current-page="pagination.page"
|
||||
v-model:page-size="pagination.pageSize"
|
||||
:total="pagination.total"
|
||||
:page-sizes="[10, 20, 50, 100]"
|
||||
layout="total, sizes, prev, pager, next"
|
||||
@size-change="handleSizeChange"
|
||||
@current-change="handlePageChange"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<PlFreightSettlementViewDialog ref="viewDialogRef" />
|
||||
<PlFreightSettlementFormDialog ref="formDialogRef" @success="fetchData" />
|
||||
<PlFreightApprovalDialog ref="approvalDialogRef" @success="fetchData" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
CircleCheck,
|
||||
CircleClose,
|
||||
Delete,
|
||||
Edit,
|
||||
Promotion,
|
||||
RefreshLeft,
|
||||
Search,
|
||||
View
|
||||
} from '@element-plus/icons-vue'
|
||||
import { freightApi, type FreightSettlement } from '@/api/pl'
|
||||
import PlFreightApprovalDialog from '@/components/business/pl-freight-approval-dialog/index.vue'
|
||||
import PlFreightSettlementFormDialog from '@/components/business/pl-freight-settlement-form-dialog/index.vue'
|
||||
import PlFreightSettlementViewDialog from '@/components/business/pl-freight-settlement-view-dialog/index.vue'
|
||||
import {
|
||||
getSettlementStatusLabel,
|
||||
getSettlementStatusTagType
|
||||
} from '@/views/pl/freight/freight-status'
|
||||
import { formatMoneyDisplay } from '@/utils/money-format'
|
||||
import { formatDateTime } from '@/utils/format'
|
||||
|
||||
const loading = ref(false)
|
||||
const settlementList = ref<FreightSettlement[]>([])
|
||||
const viewDialogRef = ref<InstanceType<typeof PlFreightSettlementViewDialog>>()
|
||||
const formDialogRef = ref<InstanceType<typeof PlFreightSettlementFormDialog>>()
|
||||
const approvalDialogRef = ref<InstanceType<typeof PlFreightApprovalDialog>>()
|
||||
|
||||
const searchForm = reactive({
|
||||
q: '',
|
||||
settlementStatus: ''
|
||||
})
|
||||
|
||||
const pagination = reactive({
|
||||
page: 1,
|
||||
pageSize: 20,
|
||||
total: 0
|
||||
})
|
||||
|
||||
function formatAmount(amount: number) {
|
||||
if (!amount) return '¥0.00'
|
||||
return formatMoneyDisplay(amount)
|
||||
}
|
||||
|
||||
async function fetchData() {
|
||||
loading.value = true
|
||||
try {
|
||||
const res = await freightApi.list({
|
||||
tab: 'bills',
|
||||
q: searchForm.q || undefined,
|
||||
settlementStatus: searchForm.settlementStatus || undefined,
|
||||
page: pagination.page,
|
||||
pageSize: pagination.pageSize
|
||||
})
|
||||
const data = res.data ?? res
|
||||
settlementList.value = data.list || []
|
||||
pagination.total = data.total || 0
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function handleSearch() {
|
||||
pagination.page = 1
|
||||
fetchData()
|
||||
}
|
||||
|
||||
function handleReset() {
|
||||
searchForm.q = ''
|
||||
searchForm.settlementStatus = ''
|
||||
pagination.page = 1
|
||||
fetchData()
|
||||
}
|
||||
|
||||
function handlePageChange() {
|
||||
fetchData()
|
||||
}
|
||||
|
||||
function handleSizeChange() {
|
||||
pagination.page = 1
|
||||
fetchData()
|
||||
}
|
||||
|
||||
function handleView(row: FreightSettlement) {
|
||||
viewDialogRef.value?.open(row.id)
|
||||
}
|
||||
|
||||
function handleEdit(row: FreightSettlement) {
|
||||
formDialogRef.value?.open(row.id)
|
||||
}
|
||||
|
||||
function handleSubmit(row: FreightSettlement) {
|
||||
approvalDialogRef.value?.openSubmit(row.id)
|
||||
}
|
||||
|
||||
function handleApprove(row: FreightSettlement) {
|
||||
if (!row.currentApprovalId) return
|
||||
approvalDialogRef.value?.openApprove(row.id, row.currentApprovalId)
|
||||
}
|
||||
|
||||
function handleReject(row: FreightSettlement) {
|
||||
if (!row.currentApprovalId) return
|
||||
approvalDialogRef.value?.openReject(row.id, row.currentApprovalId)
|
||||
}
|
||||
|
||||
async function handleWithdraw(row: FreightSettlement) {
|
||||
await ElMessageBox.confirm('确定撤回该结算单的审批吗?', '提示', { type: 'warning' })
|
||||
await freightApi.withdrawApproval(row.id)
|
||||
ElMessage.success('已撤回')
|
||||
fetchData()
|
||||
}
|
||||
|
||||
async function handleDelete(row: FreightSettlement) {
|
||||
await ElMessageBox.confirm('确定删除该草稿结算单吗?关联运输单将释放。', '提示', {
|
||||
type: 'warning'
|
||||
})
|
||||
await freightApi.delete(row.id)
|
||||
ElMessage.success('删除成功')
|
||||
fetchData()
|
||||
}
|
||||
|
||||
function refresh() {
|
||||
fetchData()
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
fetchData()
|
||||
})
|
||||
|
||||
defineExpose({ refresh })
|
||||
</script>
|
||||
@@ -0,0 +1,229 @@
|
||||
<template>
|
||||
<div class="freight-tab-panel">
|
||||
<div class="filter-block">
|
||||
<el-form :model="searchForm" class="filter-form" @submit.prevent>
|
||||
<div class="filter-grid">
|
||||
<el-form-item label="计划编号">
|
||||
<el-input
|
||||
v-model="searchForm.q"
|
||||
placeholder="搜索计划编号/客户"
|
||||
clearable
|
||||
@keyup.enter="handleSearch"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="单据类型">
|
||||
<el-select v-model="searchForm.planType" placeholder="全部" clearable>
|
||||
<el-option label="直销单" value="direct" />
|
||||
<el-option label="入库单" value="inbound" />
|
||||
<el-option label="出库单" value="outbound" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="车牌号">
|
||||
<el-input v-model="searchForm.licensePlate" placeholder="搜索车牌号" clearable />
|
||||
</el-form-item>
|
||||
</div>
|
||||
<div class="filter-actions">
|
||||
<div class="filter-actions-end">
|
||||
<el-button class="btn-ghost" :loading="loading" @click="handleReset">
|
||||
<el-icon><RefreshLeft /></el-icon>重置
|
||||
</el-button>
|
||||
<el-button class="btn-main" type="primary" :loading="loading" @click="handleSearch">
|
||||
<el-icon><Search /></el-icon>搜索
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</el-form>
|
||||
</div>
|
||||
|
||||
<div class="list-toolbar">
|
||||
<div class="list-toolbar-row">
|
||||
<div class="list-toolbar-selected">
|
||||
已选 <span class="sel-num">{{ selectedRows.length }}</span> 项
|
||||
</div>
|
||||
<el-button
|
||||
class="btn-main"
|
||||
type="primary"
|
||||
:disabled="!selectedRows.length"
|
||||
:loading="createLoading"
|
||||
@click="handleCreateSettlement"
|
||||
>
|
||||
<el-icon><DocumentAdd /></el-icon>生成结算单
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="list-body list-wrap">
|
||||
<el-table
|
||||
class="list-table"
|
||||
:data="planList"
|
||||
v-loading="loading"
|
||||
stripe
|
||||
row-key="id"
|
||||
@selection-change="handleSelectionChange"
|
||||
>
|
||||
<el-table-column type="selection" min-width="48" align="center" />
|
||||
<el-table-column prop="planNo" label="计划编号" min-width="160" show-overflow-tooltip />
|
||||
<el-table-column prop="planDate" label="计划日期" min-width="120" align="center" />
|
||||
<el-table-column prop="planType" label="单据类型" min-width="100" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-tag :type="getPlanTypeTagType(row.planType)" size="small">
|
||||
{{ getPlanTypeLabel(row.planType) }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="客户/供应商" min-width="140" show-overflow-tooltip>
|
||||
<template #default="{ row }">
|
||||
{{ row.customerName || row.supplierName || '—' }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="licensePlate" label="车牌号" min-width="110" align="center" />
|
||||
<el-table-column prop="transportCompany" label="运输公司" min-width="140" show-overflow-tooltip />
|
||||
<el-table-column prop="freightAmount" label="运费(元)" min-width="120" align="right">
|
||||
<template #default="{ row }">{{ formatAmount(row.freightAmount) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="archiveTime" label="归档时间" min-width="160" align="center">
|
||||
<template #default="{ row }">{{
|
||||
row.archiveTime ? formatDateTime(row.archiveTime) : '—'
|
||||
}}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" min-width="100" fixed="right" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-button link type="primary" @click="handleViewPlan(row)">
|
||||
<el-icon><View /></el-icon>查看
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<div class="pagination list-pager-bar">
|
||||
<el-pagination
|
||||
v-model:current-page="pagination.page"
|
||||
v-model:page-size="pagination.pageSize"
|
||||
:total="pagination.total"
|
||||
:page-sizes="[10, 20, 50, 100]"
|
||||
layout="total, sizes, prev, pager, next"
|
||||
@size-change="handleSizeChange"
|
||||
@current-change="handlePageChange"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<PlPlanViewDialog v-model:visible="planViewVisible" :plan-id="viewPlanId" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { DocumentAdd, RefreshLeft, Search, View } from '@element-plus/icons-vue'
|
||||
import { freightApi, type UnsettledPlanItem } from '@/api/pl'
|
||||
import PlPlanViewDialog from '@/components/business/pl-plan-view-dialog/index.vue'
|
||||
import { getPlanTypeLabel, getPlanTypeTagType } from '@/views/pl/freight/freight-status'
|
||||
import { formatMoneyDisplay } from '@/utils/money-format'
|
||||
import { formatDateTime } from '@/utils/format'
|
||||
|
||||
const emit = defineEmits<{ created: [settlementId: string] }>()
|
||||
|
||||
const loading = ref(false)
|
||||
const createLoading = ref(false)
|
||||
const planList = ref<UnsettledPlanItem[]>([])
|
||||
const selectedRows = ref<UnsettledPlanItem[]>([])
|
||||
const planViewVisible = ref(false)
|
||||
const viewPlanId = ref('')
|
||||
|
||||
const searchForm = reactive({
|
||||
q: '',
|
||||
planType: '',
|
||||
licensePlate: ''
|
||||
})
|
||||
|
||||
const pagination = reactive({
|
||||
page: 1,
|
||||
pageSize: 20,
|
||||
total: 0
|
||||
})
|
||||
|
||||
function formatAmount(amount: number) {
|
||||
if (!amount) return '¥0.00'
|
||||
return formatMoneyDisplay(amount)
|
||||
}
|
||||
|
||||
async function fetchData() {
|
||||
loading.value = true
|
||||
try {
|
||||
const res = await freightApi.listUnsettledPlans({
|
||||
q: searchForm.q || undefined,
|
||||
planType: searchForm.planType || undefined,
|
||||
licensePlate: searchForm.licensePlate || undefined,
|
||||
page: pagination.page,
|
||||
pageSize: pagination.pageSize
|
||||
})
|
||||
const data = res.data ?? res
|
||||
planList.value = data.list || []
|
||||
pagination.total = data.total || 0
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function handleSearch() {
|
||||
pagination.page = 1
|
||||
fetchData()
|
||||
}
|
||||
|
||||
function handleReset() {
|
||||
searchForm.q = ''
|
||||
searchForm.planType = ''
|
||||
searchForm.licensePlate = ''
|
||||
pagination.page = 1
|
||||
fetchData()
|
||||
}
|
||||
|
||||
function handlePageChange() {
|
||||
fetchData()
|
||||
}
|
||||
|
||||
function handleSizeChange() {
|
||||
pagination.page = 1
|
||||
fetchData()
|
||||
}
|
||||
|
||||
function handleSelectionChange(rows: UnsettledPlanItem[]) {
|
||||
selectedRows.value = rows
|
||||
}
|
||||
|
||||
function handleViewPlan(row: UnsettledPlanItem) {
|
||||
viewPlanId.value = row.id
|
||||
planViewVisible.value = true
|
||||
}
|
||||
|
||||
async function handleCreateSettlement() {
|
||||
if (!selectedRows.value.length) return
|
||||
await ElMessageBox.confirm(
|
||||
`确定将选中的 ${selectedRows.value.length} 条计划生成一张结算单吗?`,
|
||||
'提示',
|
||||
{ type: 'warning' }
|
||||
)
|
||||
createLoading.value = true
|
||||
try {
|
||||
const res = await freightApi.create({
|
||||
planIds: selectedRows.value.map((r) => r.id)
|
||||
})
|
||||
const settlement = (res.data ?? res) as { id: string; settlementNo?: string }
|
||||
ElMessage.success(`结算单 ${settlement.settlementNo || ''} 创建成功`)
|
||||
selectedRows.value = []
|
||||
emit('created', settlement.id)
|
||||
fetchData()
|
||||
} finally {
|
||||
createLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function refresh() {
|
||||
fetchData()
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
fetchData()
|
||||
})
|
||||
|
||||
defineExpose({ refresh })
|
||||
</script>
|
||||
@@ -0,0 +1,63 @@
|
||||
export type SettlementStatus = 'pending' | 'approving' | 'approved' | 'confirmed'
|
||||
|
||||
export function getSettlementStatusTagType(
|
||||
status: string
|
||||
): 'info' | 'warning' | 'success' | 'primary' {
|
||||
const map: Record<string, 'info' | 'warning' | 'success' | 'primary'> = {
|
||||
pending: 'info',
|
||||
approving: 'warning',
|
||||
approved: 'primary',
|
||||
confirmed: 'success'
|
||||
}
|
||||
return map[status] || 'info'
|
||||
}
|
||||
|
||||
export function getSettlementStatusLabel(status: string) {
|
||||
const map: Record<string, string> = {
|
||||
pending: '草稿',
|
||||
approving: '审批中',
|
||||
approved: '待发放',
|
||||
confirmed: '已结算'
|
||||
}
|
||||
return map[status] || status
|
||||
}
|
||||
|
||||
export function getPlanTypeTagType(planType: string): 'primary' | 'success' | 'warning' | 'info' {
|
||||
const map: Record<string, 'primary' | 'success' | 'warning' | 'info'> = {
|
||||
direct: 'primary',
|
||||
inbound: 'success',
|
||||
outbound: 'warning'
|
||||
}
|
||||
return map[planType] || 'info'
|
||||
}
|
||||
|
||||
export function getPlanTypeLabel(planType: string) {
|
||||
const map: Record<string, string> = {
|
||||
direct: '直销单',
|
||||
inbound: '入库单',
|
||||
outbound: '出库单'
|
||||
}
|
||||
return map[planType] || planType
|
||||
}
|
||||
|
||||
export function mapApprovalFlowToNodes(
|
||||
flow: Array<{
|
||||
id: string
|
||||
step: number
|
||||
stepName?: string
|
||||
approverName?: string
|
||||
approvalResult: string
|
||||
approvalOpinion?: string
|
||||
approvalTime?: string
|
||||
}>
|
||||
) {
|
||||
return flow.map((item) => ({
|
||||
id: item.id as unknown as number,
|
||||
nodeName: item.stepName || item.approverName || `步骤${item.step}`,
|
||||
nodeOrder: item.step,
|
||||
approvalStatus: item.approvalResult,
|
||||
approvalOpinion: item.approvalOpinion,
|
||||
approverName: item.approverName || '',
|
||||
approvalTime: item.approvalTime
|
||||
}))
|
||||
}
|
||||
@@ -3,356 +3,62 @@
|
||||
<div class="page-container">
|
||||
<section class="panel">
|
||||
<div class="panel-top">
|
||||
<h2 class="title-bar-heading">运费结算列表</h2>
|
||||
<h2 class="title-bar-heading">运费结算</h2>
|
||||
</div>
|
||||
|
||||
<div class="filter-block">
|
||||
<el-form :model="searchForm" class="filter-form" @submit.prevent>
|
||||
<div class="filter-grid">
|
||||
<el-form-item label="结算单号">
|
||||
<el-input
|
||||
v-model="searchForm.q"
|
||||
placeholder="搜索结算单号"
|
||||
clearable
|
||||
@keyup.enter="handleSearch"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="结算状态">
|
||||
<el-select v-model="searchForm.settlementStatus" placeholder="全部" clearable>
|
||||
<el-option label="待提交" value="pending" />
|
||||
<el-option label="已提交" value="submitted" />
|
||||
<el-option label="已审核" value="confirmed" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</div>
|
||||
<div class="filter-actions">
|
||||
<div class="filter-actions-end">
|
||||
<el-button class="btn-ghost" :loading="loading" @click="handleReset">
|
||||
<el-icon><RefreshLeft /></el-icon>重置
|
||||
</el-button>
|
||||
<el-button class="btn-main" type="primary" :loading="loading" @click="handleSearch">
|
||||
<el-icon><Search /></el-icon>搜索
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</el-form>
|
||||
</div>
|
||||
|
||||
<div class="list-toolbar">
|
||||
<div class="list-toolbar-row">
|
||||
<div class="list-toolbar-selected">已选 <span class="sel-num">0</span> 项</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="list-body list-wrap">
|
||||
<el-table
|
||||
class="list-table"
|
||||
:data="settlementList"
|
||||
v-loading="loading"
|
||||
stripe
|
||||
row-key="id"
|
||||
>
|
||||
<el-table-column prop="settlementNo" label="结算单号" min-width="180" show-overflow-tooltip>
|
||||
<template #default="{ row }">
|
||||
<el-link type="primary" @click="handleView(row)">{{ row.settlementNo }}</el-link>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="totalFreight" label="运费合计(元)" min-width="140" align="right">
|
||||
<template #default="{ row }">
|
||||
{{ formatAmount(row.totalFreight) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="invoiceNo" label="发票号" min-width="140" align="center" />
|
||||
<el-table-column prop="invoiceAmount" label="发票金额" min-width="120" align="right">
|
||||
<template #default="{ row }">
|
||||
{{ row.invoiceAmount ? formatAmount(row.invoiceAmount) : '-' }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="settlementStatus" label="结算状态" min-width="100" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-tag :type="getStatusTagType(row.settlementStatus)" size="small">
|
||||
{{ getStatusLabel(row.settlementStatus) }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="createTime" label="创建时间" min-width="160" align="center">
|
||||
<template #default="{ row }">
|
||||
{{ formatDateTime(row.createTime) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" min-width="260" fixed="right" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-button link type="primary" @click="handleView(row)">
|
||||
<el-icon><View /></el-icon>查看
|
||||
</el-button>
|
||||
<el-button
|
||||
v-if="row.settlementStatus === 'pending'"
|
||||
link
|
||||
type="primary"
|
||||
@click="handleSubmit(row)"
|
||||
>
|
||||
<el-icon><Promotion /></el-icon>提交
|
||||
</el-button>
|
||||
<el-button
|
||||
v-if="row.settlementStatus === 'submitted'"
|
||||
link
|
||||
type="success"
|
||||
@click="handleApprove(row)"
|
||||
>
|
||||
<el-icon><CircleCheck /></el-icon>审核
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<div class="pagination list-pager-bar">
|
||||
<el-pagination
|
||||
v-model:current-page="pagination.page"
|
||||
v-model:page-size="pagination.pageSize"
|
||||
:total="pagination.total"
|
||||
:page-sizes="[10, 20, 50, 100]"
|
||||
layout="total, sizes, prev, pager, next"
|
||||
@size-change="handleSizeChange"
|
||||
@current-change="handlePageChange"
|
||||
/>
|
||||
</div>
|
||||
<div class="panel-tabs">
|
||||
<el-tabs v-model="activeTab" @tab-change="handleTabChange">
|
||||
<el-tab-pane label="未结算计划" name="unsettled">
|
||||
<UnsettledPlanPanel ref="unsettledRef" @created="handleSettlementCreated" />
|
||||
</el-tab-pane>
|
||||
<el-tab-pane label="结算单" name="bills">
|
||||
<SettlementBillPanel ref="billsRef" />
|
||||
</el-tab-pane>
|
||||
<el-tab-pane label="待财务发放" name="disburse">
|
||||
<DisbursePanel ref="disburseRef" @disbursed="handleDisbursed" />
|
||||
</el-tab-pane>
|
||||
<el-tab-pane label="已结算" name="settled">
|
||||
<SettledPanel ref="settledRef" />
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<SystemViewDialog
|
||||
v-model:visible="detailVisible"
|
||||
:title="currentSettlement?.settlementNo || '结算单详情'"
|
||||
:icon="Wallet"
|
||||
:code="currentSettlement?.settlementNo"
|
||||
code-label="结算单号"
|
||||
:sections="viewSections"
|
||||
:loading="detailLoading"
|
||||
width="calc(100vw - 100px)"
|
||||
modal-class="order-module-dialog-mask"
|
||||
append-to-body
|
||||
>
|
||||
<template #transports>
|
||||
<div class="panel dialog-list-panel">
|
||||
<div class="list-body list-wrap dialog-list-body-only">
|
||||
<el-table
|
||||
:data="currentSettlement?.transports || []"
|
||||
class="list-table"
|
||||
stripe
|
||||
empty-text="暂无关联运输单"
|
||||
>
|
||||
<el-table-column type="index" label="序号" min-width="60" align="center" />
|
||||
<el-table-column prop="transportNo" label="运输编号" min-width="160" show-overflow-tooltip />
|
||||
<el-table-column prop="licensePlate" label="车牌号" min-width="120" align="center" />
|
||||
<el-table-column prop="driverName" label="司机" min-width="100" align="center" />
|
||||
<el-table-column prop="freightAmount" label="运费(元)" min-width="120" align="right">
|
||||
<template #default="{ row }">
|
||||
{{ formatAmount(row.freightAmount) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="transportStatus" label="运输状态" min-width="100" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-tag :type="getTransportStatusTagType(row.transportStatus)" size="small">
|
||||
{{ getTransportStatusLabel(row.transportStatus) }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</SystemViewDialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
CircleCheck,
|
||||
Promotion,
|
||||
RefreshLeft,
|
||||
Search,
|
||||
View,
|
||||
Wallet
|
||||
} from '@element-plus/icons-vue'
|
||||
import SystemViewDialog, {
|
||||
type ViewSection
|
||||
} from '@/components/business/system-view-dialog/index.vue'
|
||||
import { freightApi, type FreightSettlement } from '@/api/pl'
|
||||
import { useDbInstantSearch } from '@/composables/useDbInstantSearch'
|
||||
import { formatMoneyDisplay } from '@/utils/money-format'
|
||||
import { formatDateTime } from '@/utils/format'
|
||||
import UnsettledPlanPanel from './components/UnsettledPlanPanel.vue'
|
||||
import SettlementBillPanel from './components/SettlementBillPanel.vue'
|
||||
import DisbursePanel from './components/DisbursePanel.vue'
|
||||
import SettledPanel from './components/SettledPanel.vue'
|
||||
|
||||
const loading = ref(false)
|
||||
const detailLoading = ref(false)
|
||||
const settlementList = ref<FreightSettlement[]>([])
|
||||
const detailVisible = ref(false)
|
||||
const currentSettlement = ref<FreightSettlement | null>(null)
|
||||
type FreightTab = 'unsettled' | 'bills' | 'disburse' | 'settled'
|
||||
|
||||
const searchForm = reactive({
|
||||
q: '',
|
||||
settlementStatus: ''
|
||||
})
|
||||
const activeTab = ref<FreightTab>('unsettled')
|
||||
const unsettledRef = ref<InstanceType<typeof UnsettledPlanPanel>>()
|
||||
const billsRef = ref<InstanceType<typeof SettlementBillPanel>>()
|
||||
const disburseRef = ref<InstanceType<typeof DisbursePanel>>()
|
||||
const settledRef = ref<InstanceType<typeof SettledPanel>>()
|
||||
|
||||
const pagination = reactive({
|
||||
page: 1,
|
||||
pageSize: 20,
|
||||
total: 0
|
||||
})
|
||||
|
||||
const viewSections = computed<ViewSection[]>(() => {
|
||||
const s = currentSettlement.value
|
||||
if (!s) return []
|
||||
|
||||
return [
|
||||
{
|
||||
title: '结算信息',
|
||||
fields: [
|
||||
{
|
||||
label: '结算状态',
|
||||
value: getStatusLabel(s.settlementStatus),
|
||||
tagType: getStatusTagType(s.settlementStatus)
|
||||
},
|
||||
{
|
||||
label: '运费合计',
|
||||
value: formatAmount(s.totalFreight),
|
||||
money: true
|
||||
},
|
||||
{ label: '发票号', value: s.invoiceNo },
|
||||
{
|
||||
label: '发票金额',
|
||||
value: s.invoiceAmount ? formatAmount(s.invoiceAmount) : undefined,
|
||||
money: Boolean(s.invoiceAmount)
|
||||
},
|
||||
{ label: '发票日期', value: s.invoiceDate },
|
||||
{ label: '创建时间', value: formatDateTime(s.createTime) },
|
||||
{ label: '备注', value: s.remark, span: true }
|
||||
]
|
||||
},
|
||||
{
|
||||
title: '关联运输单',
|
||||
fields: [],
|
||||
slot: 'transports'
|
||||
}
|
||||
]
|
||||
})
|
||||
|
||||
function getStatusTagType(status: string) {
|
||||
const map: Record<string, 'info' | 'warning' | 'success'> = {
|
||||
pending: 'info',
|
||||
submitted: 'warning',
|
||||
confirmed: 'success'
|
||||
}
|
||||
return map[status] || 'info'
|
||||
function refreshTab(name: FreightTab) {
|
||||
if (name === 'unsettled') unsettledRef.value?.refresh()
|
||||
else if (name === 'bills') billsRef.value?.refresh()
|
||||
else if (name === 'disburse') disburseRef.value?.refresh()
|
||||
else if (name === 'settled') settledRef.value?.refresh()
|
||||
}
|
||||
|
||||
function getStatusLabel(status: string) {
|
||||
const map: Record<string, string> = {
|
||||
pending: '待提交',
|
||||
submitted: '已提交',
|
||||
confirmed: '已审核'
|
||||
}
|
||||
return map[status] || status
|
||||
function handleTabChange(name: string | number) {
|
||||
refreshTab(String(name) as FreightTab)
|
||||
}
|
||||
|
||||
function getTransportStatusTagType(status: string) {
|
||||
const map: Record<string, 'info' | 'warning' | 'primary' | 'success' | 'danger'> = {
|
||||
draft: 'info',
|
||||
pending: 'warning',
|
||||
executing: 'primary',
|
||||
completed: 'success',
|
||||
cancelled: 'danger'
|
||||
}
|
||||
return map[status] || 'info'
|
||||
function handleSettlementCreated() {
|
||||
activeTab.value = 'bills'
|
||||
nextTick(() => {
|
||||
billsRef.value?.refresh()
|
||||
})
|
||||
}
|
||||
|
||||
function getTransportStatusLabel(status: string) {
|
||||
const map: Record<string, string> = {
|
||||
draft: '草稿',
|
||||
pending: '待执行',
|
||||
executing: '执行中',
|
||||
completed: '已完成',
|
||||
cancelled: '已取消'
|
||||
}
|
||||
return map[status] || status
|
||||
function handleDisbursed() {
|
||||
settledRef.value?.refresh()
|
||||
}
|
||||
|
||||
function formatAmount(amount: number) {
|
||||
if (!amount) return '¥0.00'
|
||||
return formatMoneyDisplay(amount)
|
||||
}
|
||||
|
||||
async function fetchData() {
|
||||
loading.value = true
|
||||
try {
|
||||
const res = await freightApi.list({
|
||||
q: searchForm.q || undefined,
|
||||
settlementStatus: searchForm.settlementStatus || undefined,
|
||||
page: pagination.page,
|
||||
pageSize: pagination.pageSize
|
||||
})
|
||||
const data = res.data ?? res
|
||||
settlementList.value = data.list || []
|
||||
pagination.total = data.total || 0
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function handleSearch() {
|
||||
pagination.page = 1
|
||||
fetchData()
|
||||
}
|
||||
|
||||
function handleReset() {
|
||||
searchForm.q = ''
|
||||
searchForm.settlementStatus = ''
|
||||
pagination.page = 1
|
||||
fetchData()
|
||||
}
|
||||
|
||||
function handlePageChange() {
|
||||
fetchData()
|
||||
}
|
||||
|
||||
function handleSizeChange() {
|
||||
pagination.page = 1
|
||||
fetchData()
|
||||
}
|
||||
|
||||
async function handleView(row: FreightSettlement) {
|
||||
detailVisible.value = true
|
||||
detailLoading.value = true
|
||||
currentSettlement.value = row
|
||||
try {
|
||||
const res = await freightApi.get(row.id)
|
||||
currentSettlement.value = (res.data ?? res) as FreightSettlement
|
||||
} finally {
|
||||
detailLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function handleSubmit(row: FreightSettlement) {
|
||||
await ElMessageBox.confirm('确定提交该结算单吗?', '提示', { type: 'warning' })
|
||||
await freightApi.submit(row.id)
|
||||
ElMessage.success('提交成功')
|
||||
fetchData()
|
||||
}
|
||||
|
||||
async function handleApprove(row: FreightSettlement) {
|
||||
await ElMessageBox.confirm('确定审核通过该结算单吗?', '提示', { type: 'warning' })
|
||||
await freightApi.approve(row.id)
|
||||
ElMessage.success('审核成功')
|
||||
fetchData()
|
||||
}
|
||||
|
||||
useDbInstantSearch(
|
||||
() => ({
|
||||
q: searchForm.q,
|
||||
settlementStatus: searchForm.settlementStatus
|
||||
}),
|
||||
handleSearch
|
||||
)
|
||||
|
||||
onMounted(() => {
|
||||
fetchData()
|
||||
})
|
||||
</script>
|
||||
@@ -0,0 +1,398 @@
|
||||
<!-- 运输计划归档 -->
|
||||
<template>
|
||||
<div class="page-container">
|
||||
<section class="panel">
|
||||
<div class="panel-top">
|
||||
<h2 class="title-bar-heading">运输计划归档</h2>
|
||||
</div>
|
||||
|
||||
<div class="filter-block">
|
||||
<el-form :model="searchForm" class="filter-form" @submit.prevent>
|
||||
<div class="filter-grid">
|
||||
<el-form-item label="计划编号">
|
||||
<el-input
|
||||
v-model="searchForm.planNo"
|
||||
placeholder="搜索计划编号"
|
||||
clearable
|
||||
@keyup.enter="handleSearch"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="单据类型">
|
||||
<el-select v-model="searchForm.planType" placeholder="全部" clearable>
|
||||
<el-option label="直销单" value="direct" />
|
||||
<el-option label="入库单" value="inbound" />
|
||||
<el-option label="出库单" value="outbound" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="跟进状态">
|
||||
<el-select v-model="searchForm.followStatus" placeholder="全部" clearable>
|
||||
<el-option label="草稿" value="draft" />
|
||||
<el-option label="进行中" value="processing" />
|
||||
<el-option label="已完成" value="completed" />
|
||||
<el-option label="已取消" value="cancelled" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="运输状态">
|
||||
<el-select v-model="searchForm.transportStatus" placeholder="全部" clearable>
|
||||
<el-option label="待安排" value="pending" />
|
||||
<el-option label="已安排" value="arranged" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</div>
|
||||
<div v-show="filterExpanded" id="pl-plan-archive-filter-extra" class="filter-extra">
|
||||
<div class="filter-grid">
|
||||
<el-form-item label="客户名称">
|
||||
<el-input
|
||||
v-model="searchForm.customerName"
|
||||
placeholder="搜索客户名称"
|
||||
clearable
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="计划日期">
|
||||
<el-date-picker
|
||||
v-model="dateRange"
|
||||
type="daterange"
|
||||
range-separator="-"
|
||||
start-placeholder="开始日期"
|
||||
end-placeholder="结束日期"
|
||||
value-format="YYYY-MM-DD"
|
||||
style="width: 100%"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="归档状态">
|
||||
<el-select v-model="searchForm.archiveStatus" placeholder="全部" clearable>
|
||||
<el-option label="未归档" value="unarchived" />
|
||||
<el-option label="已归档" value="archived" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</div>
|
||||
</div>
|
||||
<div class="filter-actions">
|
||||
<div class="filter-actions-start">
|
||||
<button
|
||||
v-if="showFilterToggle"
|
||||
type="button"
|
||||
class="btn-link btn-filter-toggle"
|
||||
:aria-expanded="filterExpanded"
|
||||
aria-controls="pl-plan-archive-filter-extra"
|
||||
@click="filterExpanded = !filterExpanded"
|
||||
>
|
||||
{{ filterExpanded ? '收起更多' : '展开更多' }}
|
||||
<el-icon>
|
||||
<ArrowUpBold v-if="filterExpanded" />
|
||||
<ArrowDownBold v-else />
|
||||
</el-icon>
|
||||
</button>
|
||||
</div>
|
||||
<div class="filter-actions-end">
|
||||
<el-button class="btn-ghost" :loading="loading" @click="handleReset">
|
||||
<el-icon><RefreshLeft /></el-icon>重置
|
||||
</el-button>
|
||||
<el-button class="btn-main" type="primary" :loading="loading" @click="handleSearch">
|
||||
<el-icon><Search /></el-icon>搜索
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</el-form>
|
||||
</div>
|
||||
|
||||
<div class="list-toolbar">
|
||||
<div class="list-toolbar-row">
|
||||
<div class="list-toolbar-selected">
|
||||
已选 <span class="sel-num">{{ selectedRows.length }}</span> 项
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="list-body list-wrap">
|
||||
<el-table
|
||||
class="list-table"
|
||||
:data="planList"
|
||||
v-loading="loading"
|
||||
stripe
|
||||
row-key="id"
|
||||
@selection-change="handleSelectionChange"
|
||||
>
|
||||
<el-table-column type="selection" min-width="55" align="center" header-align="center" />
|
||||
<el-table-column prop="planNo" label="计划编号" min-width="180" show-overflow-tooltip>
|
||||
<template #default="{ row }">
|
||||
<el-link type="primary" @click="handleView(row)">{{ row.planNo }}</el-link>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="planDate" label="计划日期" min-width="120" align="center" />
|
||||
<el-table-column prop="planType" label="单据类型" min-width="100" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-tag :type="getPlanTypeTagType(row.planType)" size="small">
|
||||
{{ getPlanTypeLabel(row.planType) }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="customerName" label="客户名称" min-width="180" show-overflow-tooltip />
|
||||
<el-table-column label="产品信息" min-width="240">
|
||||
<template #default="{ row }">
|
||||
<PlPlanListProductCell :products="row.products" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="计划附件" min-width="400">
|
||||
<template #default="{ row }">
|
||||
<PlPlanListCertCell :products="row.products" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="archiveStatus" label="归档状态" min-width="100" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-tag :type="getPlPlanArchiveStatusTagType(row.archiveStatus)" size="small">
|
||||
{{ getPlPlanArchiveStatusLabel(row.archiveStatus) }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="followStatus" label="跟进状态" min-width="100" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-tag :type="getFollowStatusTagType(row.followStatus)" size="small">
|
||||
{{ getFollowStatusLabel(row.followStatus) }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="transportStatus" label="运输状态" min-width="100" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-tag :type="row.transportStatus === 'arranged' ? 'success' : 'info'" size="small">
|
||||
{{ row.transportStatus === 'arranged' ? '已安排' : '待安排' }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="totalAmount" label="计划金额" min-width="120" align="right">
|
||||
<template #default="{ row }">
|
||||
{{ formatAmount(row.totalAmount) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="licensePlate" label="车牌号" min-width="120" align="center" />
|
||||
<el-table-column prop="driverName" label="司机" min-width="100" align="center" />
|
||||
<el-table-column prop="followUserName" label="跟进人" min-width="100" align="center" />
|
||||
<el-table-column label="操作" min-width="260" fixed="right" align="center" class-name="col-actions">
|
||||
<template #default="{ row }">
|
||||
<el-button link type="primary" @click="handleView(row)">
|
||||
<el-icon><View /></el-icon>查看
|
||||
</el-button>
|
||||
<el-button
|
||||
v-if="row.followStatus !== 'cancelled'"
|
||||
link
|
||||
type="primary"
|
||||
@click="handleEdit(row)"
|
||||
>
|
||||
<el-icon><Edit /></el-icon>编辑
|
||||
</el-button>
|
||||
<el-button
|
||||
v-if="row.followStatus !== 'cancelled'"
|
||||
link
|
||||
type="success"
|
||||
@click="handleArchive(row)"
|
||||
>
|
||||
<el-icon><FolderChecked /></el-icon>{{ row.archiveStatus === 'archived' ? '调整' : '归档' }}
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<div class="pagination list-pager-bar">
|
||||
<el-pagination
|
||||
v-model:current-page="pagination.page"
|
||||
v-model:page-size="pagination.pageSize"
|
||||
:total="pagination.total"
|
||||
:page-sizes="[10, 20, 50, 100]"
|
||||
layout="total, sizes, prev, pager, next"
|
||||
@size-change="handleSizeChange"
|
||||
@current-change="handlePageChange"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<PlPlanFormDialog
|
||||
v-model:visible="formDialogVisible"
|
||||
:plan-id="editingPlanId"
|
||||
@success="fetchData"
|
||||
/>
|
||||
|
||||
<PlPlanViewDialog v-model:visible="viewVisible" :plan-id="viewPlanId" />
|
||||
|
||||
<PlPlanArchiveDialog
|
||||
v-model:visible="archiveDialogVisible"
|
||||
:plan-id="archivePlanId"
|
||||
@success="fetchData"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
ArrowDownBold,
|
||||
ArrowUpBold,
|
||||
Edit,
|
||||
FolderChecked,
|
||||
RefreshLeft,
|
||||
Search,
|
||||
View
|
||||
} from '@element-plus/icons-vue'
|
||||
import { planApi, type Plan } from '@/api/pl'
|
||||
import PlPlanArchiveDialog from '@/components/business/pl-plan-archive-dialog/index.vue'
|
||||
import PlPlanFormDialog from '@/components/business/pl-plan-form-dialog/index.vue'
|
||||
import PlPlanListCertCell from '@/components/business/pl-plan-list-cert-cell/index.vue'
|
||||
import PlPlanListProductCell from '@/components/business/pl-plan-list-product-cell/index.vue'
|
||||
import PlPlanViewDialog from '@/components/business/pl-plan-view-dialog/index.vue'
|
||||
import { useDbInstantSearch } from '@/composables/useDbInstantSearch'
|
||||
import {
|
||||
getPlPlanArchiveStatusLabel,
|
||||
getPlPlanArchiveStatusTagType
|
||||
} from '@/utils/pl-display'
|
||||
import { formatMoneyDisplay } from '@/utils/money-format'
|
||||
|
||||
const loading = ref(false)
|
||||
const formDialogVisible = ref(false)
|
||||
const editingPlanId = ref('')
|
||||
const viewVisible = ref(false)
|
||||
const viewPlanId = ref('')
|
||||
const archiveDialogVisible = ref(false)
|
||||
const archivePlanId = ref('')
|
||||
const filterExpanded = ref(false)
|
||||
const planList = ref<Plan[]>([])
|
||||
const selectedRows = ref<Plan[]>([])
|
||||
const dateRange = ref<string[]>([])
|
||||
|
||||
const searchForm = reactive({
|
||||
planNo: '',
|
||||
planType: '',
|
||||
followStatus: '',
|
||||
transportStatus: '',
|
||||
customerName: '',
|
||||
archiveStatus: ''
|
||||
})
|
||||
|
||||
const pagination = reactive({
|
||||
page: 1,
|
||||
pageSize: 20,
|
||||
total: 0
|
||||
})
|
||||
|
||||
const PLAN_FILTER_FIELD_COUNT = 7
|
||||
const showFilterToggle = computed(() => PLAN_FILTER_FIELD_COUNT > 4)
|
||||
|
||||
function getPlanTypeTagType(type: string) {
|
||||
const map: Record<string, string> = { direct: 'primary', inbound: 'success', outbound: 'warning' }
|
||||
return map[type] || 'info'
|
||||
}
|
||||
|
||||
function getPlanTypeLabel(type: string) {
|
||||
const map: Record<string, string> = { direct: '直销单', inbound: '入库单', outbound: '出库单' }
|
||||
return map[type] || type
|
||||
}
|
||||
|
||||
function getFollowStatusTagType(status: string) {
|
||||
const map: Record<string, string> = {
|
||||
draft: 'info',
|
||||
processing: 'warning',
|
||||
completed: 'success',
|
||||
cancelled: 'danger'
|
||||
}
|
||||
return map[status] || 'info'
|
||||
}
|
||||
|
||||
function getFollowStatusLabel(status: string) {
|
||||
const map: Record<string, string> = {
|
||||
draft: '草稿',
|
||||
processing: '进行中',
|
||||
completed: '已完成',
|
||||
cancelled: '已取消'
|
||||
}
|
||||
return map[status] || status
|
||||
}
|
||||
|
||||
function formatAmount(amount: number) {
|
||||
if (!amount) return '¥0.00'
|
||||
return formatMoneyDisplay(amount)
|
||||
}
|
||||
|
||||
async function fetchData() {
|
||||
loading.value = true
|
||||
try {
|
||||
const res = await planApi.list({
|
||||
planNo: searchForm.planNo || undefined,
|
||||
planType: searchForm.planType || undefined,
|
||||
followStatus: searchForm.followStatus || undefined,
|
||||
transportStatus: searchForm.transportStatus || undefined,
|
||||
customerName: searchForm.customerName || undefined,
|
||||
archiveStatus: searchForm.archiveStatus || undefined,
|
||||
planDateFrom: dateRange.value?.[0] || undefined,
|
||||
planDateTo: dateRange.value?.[1] || undefined,
|
||||
page: pagination.page,
|
||||
pageSize: pagination.pageSize
|
||||
})
|
||||
const data = res.data ?? res
|
||||
planList.value = data.list || []
|
||||
pagination.total = data.total || 0
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function handleSearch() {
|
||||
pagination.page = 1
|
||||
fetchData()
|
||||
}
|
||||
|
||||
function handleReset() {
|
||||
searchForm.planNo = ''
|
||||
searchForm.planType = ''
|
||||
searchForm.followStatus = ''
|
||||
searchForm.transportStatus = ''
|
||||
searchForm.customerName = ''
|
||||
searchForm.archiveStatus = ''
|
||||
dateRange.value = []
|
||||
filterExpanded.value = false
|
||||
pagination.page = 1
|
||||
fetchData()
|
||||
}
|
||||
|
||||
function handleSelectionChange(selection: Plan[]) {
|
||||
selectedRows.value = selection
|
||||
}
|
||||
|
||||
function handlePageChange() {
|
||||
fetchData()
|
||||
}
|
||||
|
||||
function handleSizeChange() {
|
||||
pagination.page = 1
|
||||
fetchData()
|
||||
}
|
||||
|
||||
function handleView(row: Plan) {
|
||||
viewPlanId.value = row.id
|
||||
viewVisible.value = true
|
||||
}
|
||||
|
||||
function handleEdit(row: Plan) {
|
||||
editingPlanId.value = row.id
|
||||
formDialogVisible.value = true
|
||||
}
|
||||
|
||||
function handleArchive(row: Plan) {
|
||||
archivePlanId.value = row.id
|
||||
archiveDialogVisible.value = true
|
||||
}
|
||||
|
||||
useDbInstantSearch(
|
||||
() => ({
|
||||
planNo: searchForm.planNo,
|
||||
planType: searchForm.planType,
|
||||
followStatus: searchForm.followStatus,
|
||||
transportStatus: searchForm.transportStatus,
|
||||
customerName: searchForm.customerName,
|
||||
archiveStatus: searchForm.archiveStatus,
|
||||
dateRange: dateRange.value
|
||||
}),
|
||||
handleSearch
|
||||
)
|
||||
|
||||
onMounted(() => {
|
||||
fetchData()
|
||||
})
|
||||
</script>
|
||||
@@ -187,9 +187,6 @@
|
||||
>
|
||||
<el-icon><Van /></el-icon>{{ plan.transportStatus === 'arranged' ? '调整运输' : '安排运输' }}
|
||||
</el-button>
|
||||
<el-button v-if="plan.archiveStatus !== 'archived'" type="info" @click="handleArchive">
|
||||
<el-icon><FolderChecked /></el-icon>归档
|
||||
</el-button>
|
||||
<el-button v-if="plan.followStatus !== 'cancelled'" type="danger" @click="handleCancel">
|
||||
<el-icon><CircleClose /></el-icon>取消
|
||||
</el-button>
|
||||
@@ -209,7 +206,6 @@ import {
|
||||
CircleClose,
|
||||
Close,
|
||||
Edit,
|
||||
FolderChecked,
|
||||
Van
|
||||
} from '@element-plus/icons-vue'
|
||||
import { planApi, type Plan, type PlanProduct } from '@/api/pl'
|
||||
@@ -285,13 +281,6 @@ function handleArrange() {
|
||||
arrangeDialogVisible.value = true
|
||||
}
|
||||
|
||||
async function handleArchive() {
|
||||
await ElMessageBox.confirm('确定归档该计划吗?', '提示', { type: 'warning' })
|
||||
await planApi.archive(planId.value)
|
||||
ElMessage.success('归档成功')
|
||||
fetchDetail()
|
||||
}
|
||||
|
||||
async function handleCancel() {
|
||||
await ElMessageBox.confirm('确定取消该计划吗?', '提示', { type: 'warning' })
|
||||
await planApi.cancel(planId.value)
|
||||
|
||||
@@ -100,9 +100,6 @@
|
||||
<el-button class="btn-main" type="primary" @click="handleAdd">
|
||||
<el-icon><Plus /></el-icon>新增计划
|
||||
</el-button>
|
||||
<el-button class="btn-ghost" :disabled="multiple" @click="handleBatchArchive">
|
||||
<el-icon><FolderChecked /></el-icon>批量归档
|
||||
</el-button>
|
||||
<el-button
|
||||
class="btn-ghost"
|
||||
type="danger"
|
||||
@@ -254,7 +251,6 @@ import {
|
||||
CircleClose,
|
||||
Delete,
|
||||
Edit,
|
||||
FolderChecked,
|
||||
Plus,
|
||||
RefreshLeft,
|
||||
Search,
|
||||
@@ -457,19 +453,6 @@ function handleArrange(row: Plan) {
|
||||
arrangeDialogVisible.value = true
|
||||
}
|
||||
|
||||
async function handleBatchArchive() {
|
||||
const ids = selectedRows.value.map(r => r.id)
|
||||
try {
|
||||
for (const id of ids) {
|
||||
await planApi.archive(id)
|
||||
}
|
||||
ElMessage.success('归档成功')
|
||||
fetchData()
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
}
|
||||
}
|
||||
|
||||
async function handleDelete(row: Plan) {
|
||||
await ElMessageBox.confirm(`确定删除运输计划「${row.planNo}」吗?`, '提示', { type: 'warning' })
|
||||
deleteLoading.value = true
|
||||
|
||||
Reference in new issue
Block a user