提交
This commit is contained in:
1 parent
33c038b8d9
commit
54b27a3f0e
253 files changed
+30060
-14298
No files matched your search
@@ -174,7 +174,11 @@
|
||||
<el-button @click="handleBack">
|
||||
<el-icon><Close /></el-icon>返回
|
||||
</el-button>
|
||||
<el-button v-if="plan.archiveStatus !== 'archived'" type="primary" @click="handleEdit">
|
||||
<el-button
|
||||
v-if="plan.archiveStatus !== 'archived' && plan.followStatus !== 'cancelled'"
|
||||
type="primary"
|
||||
@click="handleEdit"
|
||||
>
|
||||
<el-icon><Edit /></el-icon>编辑
|
||||
</el-button>
|
||||
<el-button
|
||||
@@ -189,7 +193,7 @@
|
||||
<el-icon><Van /></el-icon>{{ plan.transportStatus === 'arranged' ? '调整运输' : '安排运输' }}
|
||||
</el-button>
|
||||
<el-button v-if="plan.followStatus !== 'cancelled'" type="danger" @click="handleCancel">
|
||||
<el-icon><CircleClose /></el-icon>取消
|
||||
<el-icon><CircleClose /></el-icon>作废
|
||||
</el-button>
|
||||
</div>
|
||||
</section>
|
||||
@@ -244,7 +248,7 @@ function getFollowStatusTagType(status: string) {
|
||||
}
|
||||
|
||||
function getFollowStatusLabel(status: string) {
|
||||
const map: Record<string, string> = { draft: '草稿', processing: '进行中', completed: '已完成', cancelled: '已取消' }
|
||||
const map: Record<string, string> = { draft: '草稿', processing: '进行中', completed: '已完成', cancelled: '已作废' }
|
||||
return map[status] || status
|
||||
}
|
||||
|
||||
@@ -283,9 +287,11 @@ function handleArrange() {
|
||||
}
|
||||
|
||||
async function handleCancel() {
|
||||
await ElMessageBox.confirm('确定取消该计划吗?', '提示', { type: 'warning' })
|
||||
await ElMessageBox.confirm('确认作废该运输计划吗?作废后将无法恢复。', '作废运输计划', {
|
||||
type: 'warning'
|
||||
})
|
||||
await planApi.cancel(planId.value)
|
||||
ElMessage.success('取消成功')
|
||||
ElMessage.success('作废成功')
|
||||
fetchDetail()
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
<el-option label="草稿" value="draft" />
|
||||
<el-option label="进行中" value="processing" />
|
||||
<el-option label="已完成" value="completed" />
|
||||
<el-option label="已取消" value="cancelled" />
|
||||
<el-option label="已作废" value="cancelled" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="运输状态">
|
||||
@@ -39,46 +39,27 @@
|
||||
<el-option label="已安排" value="arranged" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</div>
|
||||
<div v-show="filterExpanded" id="pl-plan-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>
|
||||
</div>
|
||||
<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">
|
||||
<button
|
||||
v-if="showFilterToggle"
|
||||
type="button"
|
||||
class="btn-link btn-filter-toggle"
|
||||
:aria-expanded="filterExpanded"
|
||||
aria-controls="pl-plan-filter-extra"
|
||||
@click="filterExpanded = !filterExpanded"
|
||||
>
|
||||
{{ filterExpanded ? '收起更多' : '展开更多' }}
|
||||
<el-icon>
|
||||
<ArrowUpBold v-if="filterExpanded" />
|
||||
<ArrowDownBold v-else />
|
||||
</el-icon>
|
||||
</button>
|
||||
</div>
|
||||
<div class="filter-actions-start" />
|
||||
<div class="filter-actions-end">
|
||||
<el-button class="btn-ghost" :loading="loading" @click="handleReset">
|
||||
<el-icon><RefreshLeft /></el-icon>重置
|
||||
@@ -102,37 +83,23 @@
|
||||
aria-label="计划日期快捷筛选"
|
||||
@change="handleDateShortcut"
|
||||
/>
|
||||
<el-input
|
||||
<ListQuickSearchInput
|
||||
v-model="quickSearch"
|
||||
class="quick-search-input"
|
||||
placeholder="计划编号/客户名称"
|
||||
clearable
|
||||
@keyup.enter="handleQuickSearch"
|
||||
@search="handleQuickSearch"
|
||||
@clear="handleQuickSearchClear"
|
||||
>
|
||||
<template #suffix>
|
||||
<el-icon class="quick-search-icon" @click="handleQuickSearch"><Search /></el-icon>
|
||||
</template>
|
||||
</el-input>
|
||||
/>
|
||||
<el-button class="btn-main" type="primary" @click="handleAdd">
|
||||
<el-icon><Plus /></el-icon>新增计划
|
||||
</el-button>
|
||||
<el-button
|
||||
v-if="selectedPlan && selectedPlan.archiveStatus !== 'archived'"
|
||||
v-if="selectedPlan && canEditPlan(selectedPlan)"
|
||||
class="btn-ghost"
|
||||
:disabled="selectedRows.length !== 1"
|
||||
@click="handleToolbarEdit"
|
||||
>
|
||||
<el-icon><Edit /></el-icon>编辑
|
||||
</el-button>
|
||||
<el-button
|
||||
v-if="selectedPlan && selectedPlan.archiveStatus !== 'archived' && selectedPlan.followStatus !== 'cancelled'"
|
||||
class="btn-ghost"
|
||||
:disabled="selectedRows.length !== 1"
|
||||
@click="handleToolbarUploadCert"
|
||||
>
|
||||
<el-icon><Upload /></el-icon>上传证书
|
||||
</el-button>
|
||||
<el-button
|
||||
v-if="selectedPlan && canArrangeTransport(selectedPlan)"
|
||||
class="btn-ghost"
|
||||
@@ -151,6 +118,23 @@
|
||||
>
|
||||
<el-icon><CircleClose /></el-icon>作废
|
||||
</el-button>
|
||||
<el-button
|
||||
v-if="selectedPlan && canDeletePlan(selectedPlan)"
|
||||
class="btn-ghost"
|
||||
type="danger"
|
||||
:disabled="
|
||||
selectedRows.length !== 1 || !canDeleteByCreator(selectedPlan)
|
||||
"
|
||||
:title="
|
||||
selectedRows.length === 1
|
||||
? getDeletePlanDisabledTitle(selectedPlan)
|
||||
: ''
|
||||
"
|
||||
:loading="deleteLoading"
|
||||
@click="handleToolbarDelete"
|
||||
>
|
||||
<el-icon><Delete /></el-icon>删除
|
||||
</el-button>
|
||||
|
||||
<ListToolbarEndActions
|
||||
:loading="loading"
|
||||
@@ -242,14 +226,15 @@
|
||||
min-width="180"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
<el-table-column v-if="isColumnVisible('products')" label="产品信息" min-width="240">
|
||||
<el-table-column
|
||||
v-if="isColumnVisible('products')"
|
||||
label="产品信息"
|
||||
min-width="280"
|
||||
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="240">
|
||||
<template #default="{ row }">
|
||||
<PlPlanListCertCell :products="row.products" />
|
||||
<PlPlanListProductCell show-cert-status :products="row.products" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
@@ -293,26 +278,23 @@
|
||||
<PlPlanFormDialog
|
||||
v-model:visible="formDialogVisible"
|
||||
:plan-id="editingPlanId"
|
||||
@success="fetchData"
|
||||
@success="handlePlanMutationSuccess"
|
||||
/>
|
||||
|
||||
<PlPlanViewDialog v-model:visible="viewVisible" :plan-id="viewPlanId">
|
||||
<PlPlanViewDialog
|
||||
ref="viewDialogRef"
|
||||
v-model:visible="viewVisible"
|
||||
:plan-id="viewPlanId"
|
||||
>
|
||||
<template v-if="viewingPlan" #hero-actions>
|
||||
<el-button
|
||||
v-if="viewingPlan.archiveStatus !== 'archived'"
|
||||
v-if="canEditPlan(viewingPlan)"
|
||||
class="btn-main"
|
||||
type="primary"
|
||||
@click="handleEdit(viewingPlan)"
|
||||
>
|
||||
<el-icon><Edit /></el-icon>编辑
|
||||
</el-button>
|
||||
<el-button
|
||||
v-if="viewingPlan.archiveStatus !== 'archived' && viewingPlan.followStatus !== 'cancelled'"
|
||||
class="btn-ghost"
|
||||
@click="handleUploadCert(viewingPlan)"
|
||||
>
|
||||
<el-icon><Upload /></el-icon>上传证书
|
||||
</el-button>
|
||||
<el-button
|
||||
v-if="canArrangeTransport(viewingPlan)"
|
||||
class="btn-ghost"
|
||||
@@ -329,61 +311,64 @@
|
||||
>
|
||||
<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>
|
||||
|
||||
<PlPlanCertUploadDialog
|
||||
v-model:visible="certDialogVisible"
|
||||
:plan-id="certPlanId"
|
||||
@success="fetchData"
|
||||
/>
|
||||
|
||||
<PlPlanArrangeDialog
|
||||
v-model:visible="arrangeDialogVisible"
|
||||
:plan-id="arrangePlanId"
|
||||
@success="fetchData"
|
||||
@success="handlePlanMutationSuccess"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
ArrowDownBold,
|
||||
ArrowUpBold,
|
||||
CircleClose,
|
||||
Delete,
|
||||
Edit,
|
||||
Plus,
|
||||
RefreshLeft,
|
||||
Search,
|
||||
Upload,
|
||||
Van
|
||||
} from '@element-plus/icons-vue'
|
||||
import { planApi, type Plan } from '@/api/pl'
|
||||
import PlPlanArrangeDialog from '@/components/business/pl-plan-arrange-dialog/index.vue'
|
||||
import PlPlanCertUploadDialog from '@/components/business/pl-plan-cert-upload-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 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 { 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 certDialogVisible = ref(false)
|
||||
const certPlanId = ref('')
|
||||
const viewDialogRef = ref<InstanceType<typeof PlPlanViewDialog>>()
|
||||
const arrangeDialogVisible = ref(false)
|
||||
const arrangePlanId = ref('')
|
||||
const filterExpanded = ref(false)
|
||||
const planList = ref<Plan[]>([])
|
||||
|
||||
const listColumnDefs = [
|
||||
@@ -393,7 +378,6 @@ const listColumnDefs = [
|
||||
{ prop: 'planType', label: '单据类型' },
|
||||
{ prop: 'customerName', label: '客户名称' },
|
||||
{ prop: 'products', label: '产品信息' },
|
||||
{ prop: 'planAttachments', label: '计划附件' },
|
||||
{ prop: 'licensePlate', label: '车牌号' },
|
||||
{ prop: 'personnelSummary', label: '人员' },
|
||||
{ prop: 'followUserName', label: '跟进人', defaultVisible: false }
|
||||
@@ -409,6 +393,22 @@ const {
|
||||
|
||||
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() {
|
||||
await fetchData()
|
||||
await refreshViewIfOpen()
|
||||
}
|
||||
|
||||
const selectedPlan = computed(() => (selectedRows.value.length === 1 ? selectedRows.value[0] : null))
|
||||
const dateRange = ref<string[]>([])
|
||||
const quickSearch = ref('')
|
||||
@@ -427,9 +427,6 @@ const pagination = reactive({
|
||||
total: 0
|
||||
})
|
||||
|
||||
const PLAN_FILTER_FIELD_COUNT = 6
|
||||
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'
|
||||
@@ -455,7 +452,7 @@ function getFollowStatusLabel(status: string) {
|
||||
draft: '草稿',
|
||||
processing: '进行中',
|
||||
completed: '已完成',
|
||||
cancelled: '已取消'
|
||||
cancelled: '已作废'
|
||||
}
|
||||
return map[status] || status
|
||||
}
|
||||
@@ -497,7 +494,6 @@ function handleReset() {
|
||||
searchForm.customerName = ''
|
||||
quickSearch.value = ''
|
||||
resetDateShortcut()
|
||||
filterExpanded.value = false
|
||||
pagination.page = 1
|
||||
fetchData()
|
||||
}
|
||||
@@ -548,6 +544,10 @@ function handleEdit(row: Plan) {
|
||||
formDialogVisible.value = true
|
||||
}
|
||||
|
||||
function canEditPlan(row: Plan) {
|
||||
return row.archiveStatus !== 'archived' && row.followStatus !== 'cancelled'
|
||||
}
|
||||
|
||||
function canArrangeTransport(row: Plan) {
|
||||
return (
|
||||
(row.transportStatus === 'pending' || row.transportStatus === 'arranged') &&
|
||||
@@ -564,6 +564,49 @@ 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'
|
||||
@@ -583,11 +626,6 @@ async function handleVoid(row: Plan) {
|
||||
}
|
||||
}
|
||||
|
||||
function handleUploadCert(row: Plan) {
|
||||
certPlanId.value = row.id
|
||||
certDialogVisible.value = true
|
||||
}
|
||||
|
||||
function handleArrange(row: Plan) {
|
||||
arrangePlanId.value = row.id
|
||||
arrangeDialogVisible.value = true
|
||||
@@ -598,11 +636,6 @@ function handleToolbarEdit() {
|
||||
handleEdit(selectedRows.value[0])
|
||||
}
|
||||
|
||||
function handleToolbarUploadCert() {
|
||||
if (selectedRows.value.length !== 1) return
|
||||
handleUploadCert(selectedRows.value[0])
|
||||
}
|
||||
|
||||
function handleToolbarArrange() {
|
||||
if (selectedRows.value.length !== 1) return
|
||||
handleArrange(selectedRows.value[0])
|
||||
@@ -613,6 +646,11 @@ function handleToolbarVoid() {
|
||||
handleVoid(selectedRows.value[0])
|
||||
}
|
||||
|
||||
function handleToolbarDelete() {
|
||||
if (selectedRows.value.length !== 1) return
|
||||
handleDelete(selectedRows.value[0])
|
||||
}
|
||||
|
||||
useDbInstantSearch(
|
||||
() => ({
|
||||
planNo: searchForm.planNo,
|
||||
@@ -645,13 +683,4 @@ function openArrangeFromQuery() {
|
||||
.pl-plan-list-toolbar-row {
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.quick-search-input {
|
||||
width: 280px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.quick-search-icon {
|
||||
cursor: pointer;
|
||||
}
|
||||
</style>
|
||||
Reference in new issue
Block a user