按入库/出库/直销限制可打印单据;送(提)货单信息区改为一行布局,物料表增加单据编号列,并修正条款列宽与类型多选不换行。 Co-authored-by: Cursor <cursoragent@cursor.com>
828 lines
26 KiB
Vue
828 lines
26 KiB
Vue
<!-- 运输计划管理 -->
|
|
<template>
|
|
<div class="page-container">
|
|
<section class="panel">
|
|
<div class="panel-top">
|
|
<h2 class="title-bar-heading">运输计划列表</h2>
|
|
</div>
|
|
|
|
<PlPlanTypeTabs v-model="activePlanTypeTab" @change="handlePlanTypeTabChange" />
|
|
|
|
<!-- 筛选区 -->
|
|
<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.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>
|
|
<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>
|
|
</div>
|
|
<div class="filter-actions">
|
|
<div class="filter-actions-start" />
|
|
<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 pl-plan-list-toolbar-row">
|
|
<div class="list-toolbar-selected">
|
|
已选 <span class="sel-num">{{ selectedRows.length }}</span> 项
|
|
</div>
|
|
<ListToolbarDateShortcuts
|
|
:active="activeDateShortcut"
|
|
aria-label="计划日期快捷筛选"
|
|
@change="handleDateShortcut"
|
|
/>
|
|
<ListQuickSearchInput
|
|
v-model="quickSearch"
|
|
placeholder="计划编号/客户名称"
|
|
@search="handleQuickSearch"
|
|
@clear="handleQuickSearchClear"
|
|
/>
|
|
<el-button class="btn-main" type="primary" @click="handleAdd">
|
|
<el-icon><Plus /></el-icon>新增计划
|
|
</el-button>
|
|
<el-button
|
|
class="btn-ghost"
|
|
:disabled="!selectedPlan || !canEditPlan(selectedPlan)"
|
|
@click="handleToolbarEdit"
|
|
>
|
|
<el-icon><Edit /></el-icon>编辑
|
|
</el-button>
|
|
<el-button
|
|
class="btn-ghost"
|
|
:disabled="!selectedPlan || !canArrangeTransport(selectedPlan)"
|
|
@click="handleToolbarArrange"
|
|
>
|
|
<el-icon><Van /></el-icon>
|
|
{{ selectedPlan ? arrangeTransportLabel(selectedPlan) : '安排运输' }}
|
|
</el-button>
|
|
<el-dropdown
|
|
trigger="click"
|
|
:disabled="!selectedPlan"
|
|
@command="handleToolbarPrintSlip"
|
|
>
|
|
<el-button class="btn-ghost" :disabled="!selectedPlan">
|
|
<el-icon><Printer /></el-icon>打印单据
|
|
<el-icon class="el-icon--right"><ArrowDown /></el-icon>
|
|
</el-button>
|
|
<template #dropdown>
|
|
<el-dropdown-menu>
|
|
<el-dropdown-item
|
|
command="inbound"
|
|
:disabled="!canPrintSlipCommand(selectedPlan?.planType, 'inbound')"
|
|
>
|
|
入库单
|
|
</el-dropdown-item>
|
|
<el-dropdown-item
|
|
command="delivery"
|
|
:disabled="!canPrintSlipCommand(selectedPlan?.planType, 'delivery')"
|
|
>
|
|
送(提)货单
|
|
</el-dropdown-item>
|
|
<el-dropdown-item
|
|
command="subpack"
|
|
:disabled="!canPrintSlipCommand(selectedPlan?.planType, 'subpack')"
|
|
>
|
|
分装单
|
|
</el-dropdown-item>
|
|
</el-dropdown-menu>
|
|
</template>
|
|
</el-dropdown>
|
|
<el-button
|
|
class="btn-ghost"
|
|
type="danger"
|
|
:disabled="!selectedPlan || !canVoidPlan(selectedPlan)"
|
|
:loading="voidLoading"
|
|
@click="handleToolbarVoid"
|
|
>
|
|
<el-icon><CircleClose /></el-icon>作废
|
|
</el-button>
|
|
<el-button
|
|
class="btn-ghost"
|
|
type="danger"
|
|
:disabled="
|
|
!selectedPlan ||
|
|
!canDeletePlan(selectedPlan) ||
|
|
!canDeleteByCreator(selectedPlan)
|
|
"
|
|
:title="selectedPlan ? getDeletePlanDisabledTitle(selectedPlan) : ''"
|
|
:loading="deleteLoading"
|
|
@click="handleToolbarDelete"
|
|
>
|
|
<el-icon><Delete /></el-icon>删除
|
|
</el-button>
|
|
|
|
<ListToolbarEndActions
|
|
:loading="loading"
|
|
:column-defs="listColumnDefs"
|
|
v-model:visible-columns="visibleColumns"
|
|
v-model:check-all="checkAll"
|
|
:is-indeterminate="isIndeterminate"
|
|
@refresh="fetchData"
|
|
@reset-columns="resetToDefault"
|
|
/>
|
|
</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"
|
|
@row-dblclick="handleView"
|
|
>
|
|
<el-table-column type="selection" min-width="55" align="center" header-align="center" />
|
|
<el-table-column
|
|
type="index"
|
|
label="序号"
|
|
min-width="68"
|
|
align="center"
|
|
header-align="center"
|
|
:index="(index) => (pagination.page - 1) * pagination.pageSize + index + 1"
|
|
/>
|
|
<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
|
|
v-if="isColumnVisible('transportStatus')"
|
|
prop="transportStatus"
|
|
label="运输状态"
|
|
min-width="100"
|
|
align="center"
|
|
>
|
|
<template #default="{ row }">
|
|
<el-tag :type="row.transportStatus === 'arranged' ? 'success' : 'danger'" size="small">
|
|
{{ row.transportStatus === 'arranged' ? '已安排' : '待安排' }}
|
|
</el-tag>
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column
|
|
v-if="isColumnVisible('followStatus')"
|
|
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
|
|
v-if="isColumnVisible('planDate')"
|
|
prop="planDate"
|
|
label="计划日期"
|
|
min-width="120"
|
|
align="center"
|
|
/>
|
|
<el-table-column
|
|
v-if="isColumnVisible('planType')"
|
|
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
|
|
v-if="isColumnVisible('customerName')"
|
|
prop="customerName"
|
|
label="客户名称"
|
|
min-width="180"
|
|
show-overflow-tooltip
|
|
/>
|
|
<el-table-column
|
|
v-if="isColumnVisible('products')"
|
|
label="产品信息"
|
|
min-width="240"
|
|
align="left"
|
|
header-align="left"
|
|
>
|
|
<template #default="{ row }">
|
|
<PlPlanListProductCell :products="row.products" />
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column
|
|
v-if="isColumnVisible('planAttachments')"
|
|
label="计划附件"
|
|
min-width="200"
|
|
align="left"
|
|
header-align="left"
|
|
>
|
|
<template #default="{ row }">
|
|
<PlPlanListCertCell :products="row.products" compact hide-product />
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column
|
|
v-if="isColumnVisible('licensePlate')"
|
|
prop="licensePlate"
|
|
label="车牌号"
|
|
min-width="160"
|
|
show-overflow-tooltip
|
|
align="center"
|
|
>
|
|
<template #default="{ row }">
|
|
{{ formatPlVehiclePlateDisplay(row.licensePlate, row.trailerNo) }}
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column
|
|
v-if="isColumnVisible('personnelSummary')"
|
|
prop="personnelSummary"
|
|
label="人员"
|
|
min-width="180"
|
|
show-overflow-tooltip
|
|
align="center"
|
|
>
|
|
<template #default="{ row }">
|
|
{{ normalizePlPersonnelSummaryDisplay(row.personnelSummary) }}
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column
|
|
v-if="isColumnVisible('followUserName')"
|
|
prop="followUserName"
|
|
label="跟进人"
|
|
min-width="100"
|
|
align="center"
|
|
/>
|
|
</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="handlePlanMutationSuccess"
|
|
/>
|
|
|
|
<PlPlanViewDialog
|
|
ref="viewDialogRef"
|
|
v-model:visible="viewVisible"
|
|
:plan-id="viewPlanId"
|
|
>
|
|
<template v-if="viewingPlan" #hero-actions>
|
|
<el-button
|
|
v-if="canEditPlan(viewingPlan)"
|
|
class="btn-main"
|
|
type="primary"
|
|
@click="handleEdit(viewingPlan)"
|
|
>
|
|
<el-icon><Edit /></el-icon>编辑
|
|
</el-button>
|
|
<el-button
|
|
v-if="canArrangeTransport(viewingPlan)"
|
|
class="btn-ghost"
|
|
@click="handleArrange(viewingPlan)"
|
|
>
|
|
<el-icon><Van /></el-icon>{{ arrangeTransportLabel(viewingPlan) }}
|
|
</el-button>
|
|
<el-dropdown trigger="click" @command="handleViewPrintSlipCommand">
|
|
<el-button class="btn-ghost">
|
|
<el-icon><Printer /></el-icon>打印单据
|
|
<el-icon class="el-icon--right"><ArrowDown /></el-icon>
|
|
</el-button>
|
|
<template #dropdown>
|
|
<el-dropdown-menu>
|
|
<el-dropdown-item
|
|
command="inbound"
|
|
:disabled="!canPrintSlipCommand(viewingPlan?.planType, 'inbound')"
|
|
>
|
|
入库单
|
|
</el-dropdown-item>
|
|
<el-dropdown-item
|
|
command="delivery"
|
|
:disabled="!canPrintSlipCommand(viewingPlan?.planType, 'delivery')"
|
|
>
|
|
送(提)货单
|
|
</el-dropdown-item>
|
|
<el-dropdown-item
|
|
command="subpack"
|
|
:disabled="!canPrintSlipCommand(viewingPlan?.planType, 'subpack')"
|
|
>
|
|
分装单
|
|
</el-dropdown-item>
|
|
</el-dropdown-menu>
|
|
</template>
|
|
</el-dropdown>
|
|
<el-button
|
|
v-if="canVoidPlan(viewingPlan)"
|
|
class="btn-ghost"
|
|
type="danger"
|
|
:loading="voidLoading"
|
|
@click="handleVoid(viewingPlan)"
|
|
>
|
|
<el-icon><CircleClose /></el-icon>作废
|
|
</el-button>
|
|
<el-button
|
|
v-if="canDeletePlan(viewingPlan)"
|
|
class="btn-ghost"
|
|
type="danger"
|
|
:disabled="!canDeleteByCreator(viewingPlan)"
|
|
:title="getDeletePlanDisabledTitle(viewingPlan)"
|
|
:loading="deleteLoading"
|
|
@click="handleDelete(viewingPlan)"
|
|
>
|
|
<el-icon><Delete /></el-icon>删除
|
|
</el-button>
|
|
</template>
|
|
</PlPlanViewDialog>
|
|
|
|
<PlPlanArrangeDialog
|
|
v-model:visible="arrangeDialogVisible"
|
|
:plan-id="arrangePlanId"
|
|
@success="handlePlanMutationSuccess"
|
|
/>
|
|
|
|
<PlInboundSlipPrintDialog ref="inboundSlipPrintRef" />
|
|
<PlDeliverySlipPrintDialog ref="deliverySlipPrintRef" />
|
|
<PlSubpackSlipPrintDialog ref="subpackSlipPrintRef" />
|
|
</div>
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
import {
|
|
ArrowDown,
|
|
CircleClose,
|
|
Delete,
|
|
Edit,
|
|
Plus,
|
|
Printer,
|
|
RefreshLeft,
|
|
Search,
|
|
Van
|
|
} from '@element-plus/icons-vue'
|
|
import { planApi, type Plan } from '@/api/pl'
|
|
import PlInboundSlipPrintDialog from '@/components/business/pl-inbound-slip-print-dialog/index.vue'
|
|
import PlDeliverySlipPrintDialog from '@/components/business/pl-delivery-slip-print-dialog/index.vue'
|
|
import PlSubpackSlipPrintDialog from '@/components/business/pl-subpack-slip-print-dialog/index.vue'
|
|
import PlPlanArrangeDialog from '@/components/business/pl-plan-arrange-dialog/index.vue'
|
|
import PlPlanFormDialog from '@/components/business/pl-plan-form-dialog/index.vue'
|
|
import ListQuickSearchInput from '@/components/business/list-quick-search-input/index.vue'
|
|
import ListToolbarEndActions from '@/components/business/list-toolbar-end-actions/index.vue'
|
|
import { usePersistedListColumns } from '@/composables/usePersistedListColumns'
|
|
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 PlPlanTypeTabs from '@/components/business/pl-plan-type-tabs/index.vue'
|
|
import ListToolbarDateShortcuts from '@/components/core/list-toolbar-date-shortcuts/index.vue'
|
|
import { useDbInstantSearch } from '@/composables/useDbInstantSearch'
|
|
import { useListDateShortcut } from '@/composables/useListDateShortcut'
|
|
import { canDeleteByCreator, CREATOR_DELETE_TIP } from '@/utils/creator-delete'
|
|
import {
|
|
canPrintSlipCommand,
|
|
formatPlVehiclePlateDisplay,
|
|
normalizePlPersonnelSummaryDisplay,
|
|
plPlanTypeTabToFilter,
|
|
type PlPlanTypeTab,
|
|
type PlPrintSlipCommand
|
|
} from '@/utils/pl-display'
|
|
import { syncViewRowFromFlatList } from '@/utils/view-dialog-refresh'
|
|
const route = useRoute()
|
|
const router = useRouter()
|
|
|
|
const loading = ref(false)
|
|
const voidLoading = ref(false)
|
|
const deleteLoading = ref(false)
|
|
const formDialogVisible = ref(false)
|
|
const editingPlanId = ref('')
|
|
const viewVisible = ref(false)
|
|
const viewPlanId = ref('')
|
|
const viewDialogRef = ref<InstanceType<typeof PlPlanViewDialog>>()
|
|
const arrangeDialogVisible = ref(false)
|
|
const arrangePlanId = ref('')
|
|
const inboundSlipPrintRef = ref<InstanceType<typeof PlInboundSlipPrintDialog>>()
|
|
const deliverySlipPrintRef = ref<InstanceType<typeof PlDeliverySlipPrintDialog>>()
|
|
const subpackSlipPrintRef = ref<InstanceType<typeof PlSubpackSlipPrintDialog>>()
|
|
const planList = ref<Plan[]>([])
|
|
|
|
const listColumnDefs = [
|
|
{ prop: 'transportStatus', label: '运输状态' },
|
|
{ prop: 'followStatus', label: '跟进状态' },
|
|
{ prop: 'planDate', label: '计划日期' },
|
|
{ prop: 'planType', label: '单据类型' },
|
|
{ prop: 'customerName', label: '客户名称' },
|
|
{ prop: 'products', label: '产品信息' },
|
|
{ prop: 'planAttachments', label: '计划附件' },
|
|
{ prop: 'licensePlate', label: '车牌号' },
|
|
{ prop: 'personnelSummary', label: '人员' },
|
|
{ prop: 'followUserName', label: '跟进人', defaultVisible: false }
|
|
]
|
|
|
|
const {
|
|
visibleColumns,
|
|
checkAll,
|
|
isIndeterminate,
|
|
isColumnVisible,
|
|
resetToDefault
|
|
} = usePersistedListColumns('pl-plan-list-columns', listColumnDefs)
|
|
|
|
const selectedRows = ref<Plan[]>([])
|
|
const viewingPlan = ref<Plan | null>(null)
|
|
|
|
function syncViewingPlanFromList() {
|
|
syncViewRowFromFlatList(viewingPlan, planList.value)
|
|
}
|
|
|
|
async function refreshViewIfOpen() {
|
|
if (!viewVisible.value || !viewPlanId.value) return
|
|
syncViewingPlanFromList()
|
|
await viewDialogRef.value?.reload()
|
|
}
|
|
|
|
async function handlePlanMutationSuccess(payload?: { planId?: string; openArrange?: boolean }) {
|
|
await fetchData()
|
|
await refreshViewIfOpen()
|
|
if (payload?.openArrange && payload.planId) {
|
|
arrangePlanId.value = payload.planId
|
|
arrangeDialogVisible.value = true
|
|
}
|
|
}
|
|
|
|
const selectedPlan = computed(() => (selectedRows.value.length === 1 ? selectedRows.value[0] : null))
|
|
const dateRange = ref<string[]>([])
|
|
const quickSearch = ref('')
|
|
const activePlanTypeTab = ref<PlPlanTypeTab>('all')
|
|
|
|
const searchForm = reactive({
|
|
planNo: '',
|
|
planType: '',
|
|
followStatus: '',
|
|
transportStatus: '',
|
|
customerName: ''
|
|
})
|
|
|
|
const pagination = reactive({
|
|
page: 1,
|
|
pageSize: 20,
|
|
total: 0
|
|
})
|
|
|
|
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
|
|
}
|
|
|
|
async function fetchData() {
|
|
loading.value = true
|
|
try {
|
|
const keyword = quickSearch.value.trim()
|
|
const res = await planApi.list({
|
|
q: keyword || undefined,
|
|
planNo: keyword ? undefined : searchForm.planNo || undefined,
|
|
planType: searchForm.planType || undefined,
|
|
followStatus: searchForm.followStatus || undefined,
|
|
transportStatus: searchForm.transportStatus || undefined,
|
|
customerName: keyword ? undefined : searchForm.customerName || 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 handlePlanTypeTabChange(tab: PlPlanTypeTab) {
|
|
searchForm.planType = plPlanTypeTabToFilter(tab)
|
|
pagination.page = 1
|
|
fetchData()
|
|
}
|
|
|
|
function handleReset() {
|
|
activePlanTypeTab.value = 'all'
|
|
searchForm.planNo = ''
|
|
searchForm.planType = ''
|
|
searchForm.followStatus = ''
|
|
searchForm.transportStatus = ''
|
|
searchForm.customerName = ''
|
|
quickSearch.value = ''
|
|
resetDateShortcut()
|
|
pagination.page = 1
|
|
fetchData()
|
|
}
|
|
|
|
function handleQuickSearch() {
|
|
searchForm.planNo = ''
|
|
searchForm.customerName = ''
|
|
pagination.page = 1
|
|
fetchData()
|
|
}
|
|
|
|
function handleQuickSearchClear() {
|
|
quickSearch.value = ''
|
|
handleQuickSearch()
|
|
}
|
|
|
|
const { activeDateShortcut, handleDateShortcut, resetDateShortcut } = useListDateShortcut(
|
|
dateRange,
|
|
handleSearch
|
|
)
|
|
|
|
function handlePageChange() {
|
|
fetchData()
|
|
}
|
|
|
|
function handleSizeChange() {
|
|
pagination.page = 1
|
|
fetchData()
|
|
}
|
|
|
|
function handleAdd() {
|
|
editingPlanId.value = ''
|
|
formDialogVisible.value = true
|
|
}
|
|
|
|
function handleSelectionChange(selection: Plan[]) {
|
|
selectedRows.value = selection
|
|
}
|
|
|
|
function handleView(row: Plan) {
|
|
viewingPlan.value = row
|
|
viewPlanId.value = row.id
|
|
viewVisible.value = true
|
|
}
|
|
|
|
function handleEdit(row: Plan) {
|
|
editingPlanId.value = row.id
|
|
formDialogVisible.value = true
|
|
}
|
|
|
|
function isIoPlanFrozen(row: Plan) {
|
|
return (
|
|
row.transportStatus === 'arranged' &&
|
|
(row.planType === 'inbound' || row.planType === 'outbound')
|
|
)
|
|
}
|
|
|
|
function canEditPlan(row: Plan) {
|
|
if (isIoPlanFrozen(row)) return false
|
|
return row.archiveStatus !== 'archived' && row.followStatus !== 'cancelled'
|
|
}
|
|
|
|
function canArrangeTransport(row: Plan) {
|
|
if (isIoPlanFrozen(row)) return false
|
|
return (
|
|
(row.transportStatus === 'pending' || row.transportStatus === 'arranged') &&
|
|
row.archiveStatus !== 'archived' &&
|
|
row.followStatus !== 'cancelled'
|
|
)
|
|
}
|
|
|
|
function arrangeTransportLabel(row: Plan) {
|
|
return row.transportStatus === 'arranged' ? '调整运输' : '安排运输'
|
|
}
|
|
|
|
function canVoidPlan(row: Plan) {
|
|
return row.archiveStatus !== 'archived' && row.followStatus !== 'cancelled'
|
|
}
|
|
|
|
function canDeletePlan(row: Plan) {
|
|
return (
|
|
row.followStatus === 'draft' &&
|
|
row.transportStatus === 'pending' &&
|
|
row.archiveStatus !== 'archived'
|
|
)
|
|
}
|
|
|
|
function getDeletePlanDisabledTitle(row: Plan) {
|
|
if (!canDeletePlan(row)) return '只能删除草稿且未安排运输的计划'
|
|
if (!canDeleteByCreator(row)) return CREATOR_DELETE_TIP
|
|
return ''
|
|
}
|
|
|
|
async function handleDelete(row: Plan) {
|
|
if (!canDeletePlan(row)) {
|
|
ElMessage.warning('只能删除草稿且未安排运输的计划')
|
|
return
|
|
}
|
|
if (!canDeleteByCreator(row)) {
|
|
ElMessage.warning(CREATOR_DELETE_TIP)
|
|
return
|
|
}
|
|
await ElMessageBox.confirm('确定删除该运输计划吗?删除后不可恢复。', '删除运输计划', {
|
|
type: 'warning'
|
|
})
|
|
deleteLoading.value = true
|
|
try {
|
|
await planApi.delete(row.id)
|
|
ElMessage.success('删除成功')
|
|
if (viewingPlan.value?.id === row.id) {
|
|
viewVisible.value = false
|
|
viewingPlan.value = null
|
|
}
|
|
fetchData()
|
|
} catch (e) {
|
|
const message = e instanceof Error ? e.message : '删除失败'
|
|
ElMessage.error(message)
|
|
} finally {
|
|
deleteLoading.value = false
|
|
}
|
|
}
|
|
|
|
async function handleVoid(row: Plan) {
|
|
const hint =
|
|
row.transportStatus === 'arranged'
|
|
? '作废后将取消运输安排、作废关联入库/出库单与地磅出入库单,现场链接将失效。是否继续?'
|
|
: '确认作废该运输计划吗?作废后将无法恢复。'
|
|
await ElMessageBox.confirm(hint, '作废运输计划', { type: 'warning' })
|
|
voidLoading.value = true
|
|
try {
|
|
await planApi.cancel(row.id)
|
|
ElMessage.success('作废成功')
|
|
fetchData()
|
|
} catch (e) {
|
|
const message = e instanceof Error ? e.message : '作废失败'
|
|
ElMessage.error(message)
|
|
} finally {
|
|
voidLoading.value = false
|
|
}
|
|
}
|
|
|
|
function handleArrange(row: Plan) {
|
|
arrangePlanId.value = row.id
|
|
arrangeDialogVisible.value = true
|
|
}
|
|
|
|
function handlePrintSlip(command: PlPrintSlipCommand, row: Plan) {
|
|
if (!canPrintSlipCommand(row.planType, command)) {
|
|
ElMessage.warning('当前单据类型不支持打印该单据')
|
|
return
|
|
}
|
|
if (command === 'inbound') {
|
|
inboundSlipPrintRef.value?.open(row.id)
|
|
return
|
|
}
|
|
if (command === 'delivery') {
|
|
deliverySlipPrintRef.value?.open(row.id)
|
|
return
|
|
}
|
|
subpackSlipPrintRef.value?.open(row.id)
|
|
}
|
|
|
|
function handleViewPrintSlipCommand(command: string) {
|
|
if (!viewingPlan.value) return
|
|
handlePrintSlip(command as PlPrintSlipCommand, viewingPlan.value)
|
|
}
|
|
|
|
function handleToolbarPrintSlip(command: string) {
|
|
if (selectedRows.value.length !== 1) return
|
|
handlePrintSlip(command as PlPrintSlipCommand, selectedRows.value[0])
|
|
}
|
|
|
|
function handleToolbarEdit() {
|
|
if (selectedRows.value.length !== 1) return
|
|
handleEdit(selectedRows.value[0])
|
|
}
|
|
|
|
function handleToolbarArrange() {
|
|
if (selectedRows.value.length !== 1) return
|
|
handleArrange(selectedRows.value[0])
|
|
}
|
|
|
|
function handleToolbarVoid() {
|
|
if (selectedRows.value.length !== 1) return
|
|
handleVoid(selectedRows.value[0])
|
|
}
|
|
|
|
function handleToolbarDelete() {
|
|
if (selectedRows.value.length !== 1) return
|
|
handleDelete(selectedRows.value[0])
|
|
}
|
|
|
|
useDbInstantSearch(
|
|
() => ({
|
|
planNo: searchForm.planNo,
|
|
planType: searchForm.planType,
|
|
followStatus: searchForm.followStatus,
|
|
transportStatus: searchForm.transportStatus,
|
|
customerName: searchForm.customerName,
|
|
dateRange: dateRange.value
|
|
}),
|
|
() => {
|
|
quickSearch.value = ''
|
|
handleSearch()
|
|
}
|
|
)
|
|
|
|
onMounted(() => {
|
|
fetchData()
|
|
openArrangeFromQuery()
|
|
})
|
|
|
|
function openArrangeFromQuery() {
|
|
const arrangeId = route.query.arrange as string | undefined
|
|
if (!arrangeId) return
|
|
arrangePlanId.value = arrangeId
|
|
arrangeDialogVisible.value = true
|
|
router.replace({ path: '/pl/plan' })
|
|
}
|
|
</script>
|
|
|
|
<style scoped lang="scss">
|
|
.pl-plan-list-toolbar-row {
|
|
flex-wrap: wrap;
|
|
}
|
|
</style>
|