This commit is contained in:
zlwu committed 2026-08-19 22:20:42 +08:00
1 parent a52fe77e34
commit 1938a9b76a
62 files changed
+612436 -10819

No files matched your search

@@ -174,6 +174,7 @@ import {
downloadAttachmentFile,
resolveAttachmentPreviewUrl
} from '@/utils/download-attachment'
import { buildAttachmentUploadFormData, type CrmUploadBizType } from '@/utils/crm-upload'
type AttachmentItem = {
id: string
@@ -195,6 +196,8 @@ const props = withDefaults(
compact?: boolean
/** 附件 URL → 分类名称,用于查看态在缩略图上展示分类标签 */
categoryLabels?: Record<string, string>
/** CRM 等业务上传 bizType(与 folder 二选一或同时传) */
bizType?: CrmUploadBizType | string
}>(),
{
modelValue: '',
@@ -379,11 +382,19 @@ async function uploadRawFile(rawFile: File) {
}
attachments.value.push(item)
const formData = new FormData()
formData.append('file', rawFile)
if (props.folder) {
formData.append('folder', props.folder)
}
const formData = props.bizType
? buildAttachmentUploadFormData(rawFile, {
bizType: props.bizType,
folder: props.folder || undefined
})
: (() => {
const fd = new FormData()
fd.append('file', rawFile)
if (props.folder) {
fd.append('folder', props.folder)
}
return fd
})()
try {
const res = await fetchUploadAttachment(formData)
@@ -138,11 +138,12 @@
personnelApi,
vehicleApi,
type Carrier,
type PasteCommitResult,
type PasteConflictAction,
type PasteConflictItem
} from '@/api/pl'
import { pickBxData, pickBxPageResult } from '@/utils/http/bx'
import { usePlRemoteCarrierOptions } from '@/composables/usePlRemoteOptions'
import { pickBxPageResult } from '@/utils/http/bx'
import {
PL_PASTE_SAMPLE_TEXT,
parsePlCustomerVehicleText,
@@ -162,7 +163,7 @@
const emit = defineEmits<{
'update:visible': [boolean]
done: []
done: [result?: PasteCommitResult]
}>()
const innerVisible = computed({
@@ -171,7 +172,7 @@
})
const dialogTitle = computed(() =>
props.mode === 'vehicle-bundle' ? '粘贴识别(整车套装)' : '粘贴识别(以人为主)'
props.mode === 'vehicle-bundle' ? '快速识别创建(整车套装)' : '快速识别创建(以人为主)'
)
const rawText = ref(PL_PASTE_SAMPLE_TEXT)
@@ -338,7 +339,7 @@
const carrier = carrierOptions.value.find(c => c.id === carrierId.value)
const needVehicle = showVehicleFields.value
await pasteRecognizeApi.commit({
const res = await pasteRecognizeApi.commit({
mode: props.mode === 'vehicle-bundle' ? 'vehicle_bundle' : 'personnel_first',
createVehicle: needVehicle,
vehicle: needVehicle
@@ -370,7 +371,7 @@
})
ElMessage.success('生成成功')
emit('done')
emit('done', pickBxData<PasteCommitResult>(res))
innerVisible.value = false
} catch (e: any) {
const msg = e?.response?.data?.detail || e?.message || '生成失败'
@@ -0,0 +1,398 @@
<template>
<el-dialog
v-model="visible"
:title="dialogTitle"
width="1320px"
align-center
append-to-body
destroy-on-close
class="dialog-form-layout"
modal-class="order-module-dialog-mask"
style="backdrop-filter: none"
:close-on-click-modal="false"
@close="handleDialogClose"
>
<el-form
ref="formRef"
v-loading="dialogLoading"
:model="formData"
:rules="formRules"
label-position="right"
label-width="100px"
class="pl-dialog-form"
scroll-to-error
:scroll-into-view-options="{ behavior: 'smooth', block: 'center' }"
>
<div class="form-grid-3">
<el-form-item label="姓名" prop="personnelName">
<el-input v-model="formData.personnelName" placeholder="请输入姓名" maxlength="100" />
</el-form-item>
<el-form-item label="手机号" prop="phoneNo">
<el-input v-model="formData.phoneNo" placeholder="请输入手机号(选填)" maxlength="32" />
</el-form-item>
<el-form-item label="年龄" prop="age">
<el-input-number
v-model="formData.age"
:min="0"
:max="120"
placeholder="年龄"
style="width: 100%"
/>
</el-form-item>
<el-form-item label="身份证号" prop="idCardNo">
<el-input
v-model="formData.idCardNo"
placeholder="请输入身份证号"
maxlength="32"
@input="handleIdCardNoInput"
/>
</el-form-item>
<el-form-item label="人员类型" prop="personnelType">
<el-select v-model="formData.personnelType" placeholder="请选择人员类型">
<el-option
v-for="option in PL_PERSONNEL_TYPE_OPTIONS"
:key="option.value"
:label="option.label"
:value="option.value"
/>
</el-select>
</el-form-item>
<el-form-item label="状态" prop="status">
<el-select v-model="formData.status" placeholder="请选择">
<el-option label="在职" value="1" />
<el-option label="停用" value="0" />
</el-select>
</el-form-item>
<el-form-item label="备注" prop="remark">
<el-input
v-model="formData.remark"
type="textarea"
:rows="2"
placeholder="请输入备注"
maxlength="512"
/>
</el-form-item>
<el-form-item label="人员照片" style="grid-column: 1 / -1">
<AttachmentUploadField
ref="photoUploadRef"
v-model="formData.photoUrls"
accept="image/*"
folder="pl/personnel-photo"
hint="支持图片,可上传多张;可拖拽或在此区域粘贴上传"
/>
</el-form-item>
</div>
<PlCertFormList
ref="certFormListRef"
v-model="certList"
title="人员证书"
upload-folder="pl/personnel-cert"
:cert-name-options="certNameOptions"
:required-cert-names="requiredPersonnelCertNames"
:strip-managed-cert-names="PL_PERSONNEL_BOTH_REQUIRED_CERT_NAMES"
layout="table"
@id-card-recognized="handleIdCardRecognized"
/>
</el-form>
<template #footer>
<div class="dialog-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>
</div>
</template>
</el-dialog>
</template>
<script setup lang="ts">
import { Check, Close } from '@element-plus/icons-vue'
import { personnelApi, type CertRow, type PersonnelDetail } from '@/api/pl'
import AttachmentUploadField from '@/components/business/attachment-upload-field/index.vue'
import PlCertFormList from '@/components/business/pl-cert-form-list/index.vue'
import { pickBxData } from '@/utils/http/bx'
import { calcAgeFromChineseIdCard } from '@/utils/id-card'
import {
collectRequiredCertSlotErrors,
formatRequiredCertErrors,
mergeCertListWithRequiredSlots
} from '@/utils/pl-cert-slots'
import {
getRequiredPersonnelCertNamesByType,
PL_PERSONNEL_BOTH_REQUIRED_CERT_NAMES,
PL_PERSONNEL_TYPE_OPTIONS
} from '@/utils/pl-personnel-cert'
type CertListItem = CertRow & { _key?: string }
type CertFormListRef = InstanceType<typeof PlCertFormList>
const props = defineProps<{
modelValue: boolean
/** carrier=三方,self=山峡;锁定归属,不可切换 */
affiliation: 'carrier' | 'self'
/** 有值则为编辑,无值则为新增 */
personnelId?: string | null
}>()
const emit = defineEmits<{
'update:modelValue': [value: boolean]
saved: [payload: { mode: 'create' | 'edit'; personnel: PersonnelDetail }]
}>()
const visible = computed({
get: () => props.modelValue,
set: (value: boolean) => emit('update:modelValue', value)
})
const isCarrierPersonnel = computed(() => props.affiliation === 'carrier')
const isEdit = computed(() => Boolean(props.personnelId))
const dialogTitle = computed(() => {
if (isEdit.value) {
return isCarrierPersonnel.value ? '编辑人员' : '编辑山峡人员'
}
return isCarrierPersonnel.value ? '新增人员' : '新增山峡人员'
})
const submitLoading = ref(false)
const dialogLoading = ref(false)
const formRef = ref()
const photoUploadRef = ref<InstanceType<typeof AttachmentUploadField>>()
const certList = ref<CertListItem[]>([])
const certFormListRef = ref<CertFormListRef>()
const certNameOptions = [
'身份证',
'驾驶证',
'驾驶员从业资格证',
'押运员从业资格证',
'押运员证',
'健康证'
]
const formData = reactive({
id: '',
personnelName: '',
phoneNo: '',
age: null as number | null,
idCardNo: '',
personnelType: '',
personnelAffiliation: props.affiliation,
status: '1',
remark: '',
photoUrls: ''
})
const requiredPersonnelCertNames = computed(() =>
isCarrierPersonnel.value
? []
: formData.personnelType
? getRequiredPersonnelCertNamesByType(formData.personnelType)
: []
)
const formRules = {
personnelName: [{ required: true, message: '请输入姓名', trigger: 'blur' }],
personnelType: [{ required: true, message: '请选择人员类型', trigger: 'change' }],
status: [{ required: true, message: '请选择状态', trigger: 'change' }]
}
function mergePersonnelCertSlots(list: CertListItem[]) {
if (isCarrierPersonnel.value || !formData.personnelType) return list
return mergeCertListWithRequiredSlots(
list,
getRequiredPersonnelCertNamesByType(formData.personnelType),
{ stripManagedNames: PL_PERSONNEL_BOTH_REQUIRED_CERT_NAMES }
)
}
function resetCertList() {
certList.value = []
certFormListRef.value?.clearUploadRefs()
}
function resetForm() {
Object.assign(formData, {
id: '',
personnelName: '',
phoneNo: '',
age: null,
idCardNo: '',
personnelType: '',
personnelAffiliation: props.affiliation,
status: '1',
remark: '',
photoUrls: ''
})
resetCertList()
}
function applyAgeFromIdCard(idCard?: string) {
const age = calcAgeFromChineseIdCard(idCard)
if (age != null) {
formData.age = age
}
}
function handleIdCardNoInput(val: string | number) {
applyAgeFromIdCard(String(val ?? ''))
}
function handleIdCardRecognized(certNo: string) {
if (certNo) {
formData.idCardNo = certNo
applyAgeFromIdCard(certNo)
}
}
function validateCerts(): boolean {
if (!formData.personnelType) {
ElMessage.warning('请选择人员类型')
return false
}
if (!isCarrierPersonnel.value) {
const errors = collectRequiredCertSlotErrors(certList.value, requiredPersonnelCertNames.value)
if (errors.length) {
ElMessage.warning(formatRequiredCertErrors(errors))
return false
}
}
for (const cert of certList.value) {
if (!cert._required && !cert.certName?.trim()) {
ElMessage.warning('其他证书名称不能为空')
return false
}
}
return true
}
async function loadDetail(personnelId: string) {
dialogLoading.value = true
try {
const res = await personnelApi.get(personnelId)
const detail = pickBxData<PersonnelDetail>(res)
Object.assign(formData, {
id: detail.id,
personnelName: detail.personnelName,
phoneNo: detail.phoneNo || '',
age: detail.age ?? null,
idCardNo: detail.idCardNo || '',
personnelType: detail.personnelType || 'both',
personnelAffiliation: props.affiliation,
status: detail.status,
remark: detail.remark || '',
photoUrls: detail.photoUrls || ''
})
certList.value = mergePersonnelCertSlots(
(detail.certList || []).map(c => ({
_key: c.id || c.certId || `cert-${Math.random().toString(36).slice(2, 10)}`,
certId: c.id || c.certId,
certName: c.certName,
certNo: c.certNo,
expireDate: c.expireDate,
remindDays: c.remindDays ?? 30,
attachmentUrls: c.attachmentUrls || ''
}))
)
certFormListRef.value?.refreshRequiredSlots?.()
} catch {
ElMessage.error('加载人员详情失败')
visible.value = false
} finally {
dialogLoading.value = false
}
}
async function openDialog() {
resetForm()
if (props.personnelId) {
await loadDetail(props.personnelId)
}
}
async function handleSubmit() {
const valid = await formRef.value.validate().catch(() => false)
if (!valid || !validateCerts()) return
if (certFormListRef.value?.hasUploading?.()) {
ElMessage.warning('证书附件上传中,请稍候')
return
}
if (photoUploadRef.value?.hasUploading?.()) {
ElMessage.warning('附件上传中,请稍候')
return
}
submitLoading.value = true
try {
const payload = {
personnelName: formData.personnelName.trim(),
phoneNo: formData.phoneNo || undefined,
age: formData.age ?? undefined,
idCardNo: formData.idCardNo || undefined,
personnelType: formData.personnelType,
personnelAffiliation: props.affiliation,
status: formData.status,
remark: formData.remark || undefined,
photoUrls: formData.photoUrls ?? '',
certList: certList.value.map(c => ({
certId: c.certId,
certName: c.certName.trim(),
certNo: c.certNo || undefined,
expireDate: c.expireDate || undefined,
remindDays: c.remindDays ?? 30,
attachmentUrls: c.attachmentUrls || undefined
}))
}
if (isEdit.value) {
await personnelApi.update(formData.id, payload)
const res = await personnelApi.get(formData.id)
const detail = pickBxData<PersonnelDetail>(res)
if (!detail?.id) {
ElMessage.error('编辑成功但未返回人员信息')
return
}
ElMessage.success('编辑成功')
emit('saved', { mode: 'edit', personnel: detail })
} else {
const res = await personnelApi.create(payload)
const detail = pickBxData<PersonnelDetail>(res)
if (!detail?.id) {
ElMessage.error('新增成功但未返回人员信息')
return
}
ElMessage.success('新增成功')
emit('saved', { mode: 'create', personnel: detail })
}
visible.value = false
} finally {
submitLoading.value = false
}
}
function handleDialogClose() {
formRef.value?.resetFields()
resetCertList()
}
watch(
() => formData.personnelType,
() => {
if (!formData.personnelType) return
certList.value = mergePersonnelCertSlots(certList.value)
certFormListRef.value?.refreshRequiredSlots?.()
}
)
watch(
() => props.modelValue,
async open => {
if (open) {
await openDialog()
}
}
)
</script>
@@ -0,0 +1,371 @@
<template>
<div class="pl-personnel-library-select-panel">
<div class="list-toolbar">
<div class="list-toolbar-row pl-personnel-library-select-toolbar">
<el-input
v-model="keyword"
class="pl-personnel-library-select-search"
placeholder="搜索姓名或手机号"
clearable
@keyup.enter="handleSearch"
@clear="handleSearch"
>
<template #prefix>
<el-icon><Search /></el-icon>
</template>
</el-input>
<el-button class="btn-main" type="primary" @click="handleOpenCreate">
<el-icon><Plus /></el-icon>新增人员
</el-button>
</div>
</div>
<div class="list-body list-wrap dialog-list-body-only">
<ListTable
:table-key="`business-pl-personnel-library-${affiliation}`"
class="list-table pl-personnel-library-select-table"
:data="rows"
v-loading="loading"
stripe
row-key="id"
highlight-current-row
:max-height="560"
empty-text="暂无人员"
@row-dblclick="handleView"
>
<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="personnelName" label="姓名" min-width="140" show-overflow-tooltip>
<template #default="{ row }">
<el-link type="primary" @click="handleView(row)">{{ row.personnelName }}</el-link>
</template>
</el-table-column>
<el-table-column label="人员类型" min-width="120" align="center" header-align="center">
<template #default="{ row }">
<el-tag :type="getPersonnelTypeTagType(row.personnelType)" size="small">
{{ getPersonnelTypeLabel(row.personnelType) }}
</el-tag>
</template>
</el-table-column>
<el-table-column
prop="phoneNo"
label="手机号"
min-width="130"
align="center"
header-align="center"
show-overflow-tooltip
/>
<el-table-column label="身份证号" min-width="180" align="center" header-align="center">
<template #default="{ row }">
{{ maskIdCard(row.idCardNo) }}
</template>
</el-table-column>
<el-table-column label="状态" min-width="90" align="center" header-align="center">
<template #default="{ row }">
<el-tag :type="row.status === '1' ? 'success' : 'info'" size="small">
{{ row.status === '1' ? '在职' : '停用' }}
</el-tag>
</template>
</el-table-column>
<el-table-column
label="操作"
min-width="180"
align="center"
header-align="center"
fixed="right"
class-name="col-actions"
>
<template #default="{ row }">
<el-button link type="primary" @click="handleView(row)">
<el-icon><View /></el-icon>查看
</el-button>
<el-button link type="primary" @click="handleOpenEdit(row)">
<el-icon><Edit /></el-icon>编辑
</el-button>
</template>
</el-table-column>
</ListTable>
<ListPagination
v-show="pagination.total > 0"
:total="pagination.total"
v-model:page="pagination.page"
v-model:limit="pagination.pageSize"
@pagination="fetchList"
/>
</div>
<PlPersonnelFormDialog
v-model="formVisible"
:affiliation="affiliation"
:personnel-id="editingId"
@saved="handleFormSaved"
/>
<SystemViewDialog
v-model:visible="viewVisible"
:title="viewDialogTitle"
:icon="User"
:meta="viewHeroMeta"
:sections="viewSections"
:loading="viewLoading"
width="1040px"
modal-class="order-module-dialog-mask"
append-to-body
>
<template v-if="viewDetail" #hero-actions>
<el-button class="btn-main" type="primary" @click="handleEditFromView">
<el-icon><Edit /></el-icon>编辑
</el-button>
</template>
<template #photo>
<AttachmentUploadField
v-if="viewDetail?.photoUrls"
:model-value="viewDetail.photoUrls"
disabled
accept="image/*"
/>
<span v-else>—</span>
</template>
<template #certs>
<PlCertViewList :cert-list="viewDetail?.certList || []" layout="table" />
</template>
</SystemViewDialog>
</div>
</template>
<script setup lang="ts">
import { Edit, Plus, Search, User, View } from '@element-plus/icons-vue'
import { personnelApi, type Personnel, type PersonnelDetail } from '@/api/pl'
import AttachmentUploadField from '@/components/business/attachment-upload-field/index.vue'
import PlCertViewList from '@/components/business/pl-cert-view-list/index.vue'
import PlPersonnelFormDialog from '@/components/business/pl-personnel-form-dialog/index.vue'
import SystemViewDialog, { type ViewSection } from '@/components/business/system-view-dialog/index.vue'
import ListPagination from '@/components/ListPagination/index.vue'
import { pickBxData, pickBxPageResult } from '@/utils/http/bx'
import { formatDateTime } from '@/utils/format'
import {
getPersonnelAffiliationLabel,
getPersonnelAffiliationTagType,
getPersonnelCertMissingSuffix,
getPersonnelTypeLabel,
getPersonnelTypeTagType
} from '@/utils/pl-personnel-cert'
import { DEFAULT_LIST_PAGE_SIZE } from '@/utils/table/tableConfig'
const props = defineProps<{
affiliation: 'carrier' | 'self'
}>()
const isCarrierPersonnel = computed(() => props.affiliation === 'carrier')
const loading = ref(false)
const keyword = ref('')
const rows = ref<Personnel[]>([])
const pagination = reactive({
page: 1,
pageSize: DEFAULT_LIST_PAGE_SIZE,
total: 0
})
const formVisible = ref(false)
const editingId = ref<string | null>(null)
const viewVisible = ref(false)
const viewLoading = ref(false)
const viewDetail = ref<PersonnelDetail | null>(null)
function maskIdCard(idCard: string | undefined) {
if (!idCard || idCard.length < 8) return idCard || '—'
return idCard.slice(0, 4) + '**********' + idCard.slice(-4)
}
function getExpireTagType(dateStr: string | undefined) {
if (!dateStr) return 'info'
const expDate = new Date(dateStr)
const today = new Date()
const diffDays = Math.ceil((expDate.getTime() - today.getTime()) / (1000 * 60 * 60 * 24))
if (diffDays <= 0) return 'danger'
if (diffDays <= 30) return 'warning'
return 'success'
}
const viewHeroMeta = computed(() => {
if (!viewDetail.value) return ''
return [viewDetail.value.phoneNo || '未填写手机号', viewDetail.value.status === '1' ? '在职' : '停用'].join(
' · '
)
})
const viewDialogTitle = computed(() => {
const name = viewDetail.value?.personnelName || '人员详情'
if (!viewDetail.value || isCarrierPersonnel.value) return name
return (
name +
getPersonnelCertMissingSuffix(viewDetail.value.certList || [], undefined, viewDetail.value.personnelType)
)
})
const viewSections = computed<ViewSection[]>(() => {
const d = viewDetail.value
if (!d) return []
return [
{
title: '基本信息',
fields: [
{ label: '姓名', value: d.personnelName },
{ label: '手机号', value: d.phoneNo || '—' },
{
label: '人员归属',
value: getPersonnelAffiliationLabel(d.personnelAffiliation),
tagType: getPersonnelAffiliationTagType(d.personnelAffiliation)
},
{
label: '人员类型',
value: getPersonnelTypeLabel(d.personnelType),
tagType: getPersonnelTypeTagType(d.personnelType)
},
{ label: '年龄', value: d.age ?? '—' },
{ label: '身份证号', value: maskIdCard(d.idCardNo) },
{
label: '状态',
value: d.status === '1' ? '在职' : '停用',
tagType: d.status === '1' ? 'success' : 'info'
},
{
label: '最近到期',
value: d.nearestExpireDate || '—',
tagType: d.nearestExpireDate ? getExpireTagType(d.nearestExpireDate) : undefined
},
{ label: '创建时间', value: formatDateTime(d.createTime) },
{ label: '更新时间', value: formatDateTime(d.updateTime) },
{ label: '备注', value: d.remark || '—', span: 'full' }
],
fieldLayout: 'table',
tableMode: 'triple'
},
{
title: '人员照片',
fields: [],
slot: 'photo'
},
{
title: `人员证书${
viewDetail.value && !isCarrierPersonnel.value
? getPersonnelCertMissingSuffix(viewDetail.value.certList || [], undefined, viewDetail.value.personnelType)
: ''
}`,
fields: [],
slot: 'certs'
}
]
})
async function fetchList() {
loading.value = true
try {
const res = await personnelApi.list({
q: keyword.value.trim() || undefined,
personnelAffiliation: props.affiliation,
page: pagination.page,
pageSize: pagination.pageSize
})
const { list, total } = pickBxPageResult<Personnel>(res)
rows.value = list
pagination.total = total
} finally {
loading.value = false
}
}
function handleSearch() {
pagination.page = 1
fetchList()
}
function resetPanel() {
keyword.value = ''
pagination.page = 1
pagination.pageSize = DEFAULT_LIST_PAGE_SIZE
pagination.total = 0
rows.value = []
formVisible.value = false
editingId.value = null
viewVisible.value = false
viewDetail.value = null
}
function handleOpenCreate() {
editingId.value = null
formVisible.value = true
}
function handleOpenEdit(row: Personnel) {
editingId.value = row.id
formVisible.value = true
}
function handleFormSaved() {
formVisible.value = false
editingId.value = null
fetchList()
}
async function handleView(row: Personnel) {
viewVisible.value = true
viewLoading.value = true
viewDetail.value = null
try {
const res = await personnelApi.get(row.id)
viewDetail.value = pickBxData<PersonnelDetail>(res)
} catch {
viewVisible.value = false
ElMessage.error('加载人员详情失败')
} finally {
viewLoading.value = false
}
}
function handleEditFromView() {
if (!viewDetail.value) return
viewVisible.value = false
handleOpenEdit(viewDetail.value)
}
defineExpose({
resetPanel,
fetchList
})
onMounted(() => {
fetchList()
})
</script>
<style scoped lang="scss">
.pl-personnel-library-select-panel {
.list-toolbar {
margin-bottom: 0;
padding: 10px 0 12px;
}
}
.pl-personnel-library-select-toolbar {
display: flex;
align-items: center;
gap: 8px;
flex-wrap: wrap;
}
.pl-personnel-library-select-search {
width: 280px;
max-width: 100%;
}
</style>
@@ -98,6 +98,8 @@
<el-select
v-model="formData.supplierId"
class="customer-select-row__select"
name="pl-plan-supplier-customer"
autocomplete="new-password"
filterable
remote
clearable
@@ -189,6 +191,8 @@
<el-select
v-model="formData.customerId"
class="customer-select-row__select"
name="pl-plan-demander-customer"
autocomplete="new-password"
filterable
remote
clearable
@@ -278,6 +282,12 @@
>
<el-icon><FolderOpened /></el-icon>从车辆库选择
</el-button>
<el-button
class="pl-plan-vehicle-with-library__btn btn-ghost"
@click="pasteRecognizeVisible = true"
>
<el-icon><DocumentCopy /></el-icon>三方人车快速创建
</el-button>
</div>
</el-form-item>
<el-form-item label="运输公司" class="pl-plan-vehicle-carrier-row__carrier">
@@ -457,11 +467,16 @@
v-model="carrierLibraryVisible"
@select="handleCarrierLibrarySelect"
/>
<PlPasteRecognizeDialog
v-model:visible="pasteRecognizeVisible"
mode="vehicle-bundle"
@done="handlePasteRecognizeDone"
/>
</el-dialog>
</template>
<script setup lang="ts">
import { Check, Close, FolderOpened, Plus, Search, Van } from '@element-plus/icons-vue'
import { Check, Close, DocumentCopy, FolderOpened, Plus, Search, Van } from '@element-plus/icons-vue'
import {
planApi,
transportApi,
@@ -470,6 +485,7 @@ import {
type PlanProduct,
type PlanUpdatePayload,
type Carrier,
type PasteCommitResult,
type Vehicle,
type VehiclePersonnelRow
} from '@/api/pl'
@@ -485,6 +501,7 @@ import PlVehicleSummaryStrip from '@/components/business/pl-vehicle-summary-stri
import PlVehicleViewDialog from '@/components/business/pl-vehicle-view-dialog/index.vue'
import PlVehicleLibrarySelectDialog from '@/components/business/pl-vehicle-library-select-dialog/index.vue'
import PlCarrierLibrarySelectDialog from '@/components/business/pl-carrier-library-select-dialog/index.vue'
import PlPasteRecognizeDialog from '@/components/business/pl-paste-recognize-dialog/index.vue'
import PlAddressWithLibrary from '@/components/business/pl-address-with-library/index.vue'
import PlPlanFormProductTable from './PlPlanFormProductTable.vue'
import {
@@ -585,6 +602,7 @@ const productSelectorVisible = ref(false)
const vehicleViewVisible = ref(false)
const vehicleLibraryVisible = ref(false)
const carrierLibraryVisible = ref(false)
const pasteRecognizeVisible = ref(false)
const vehicleLoading = ref(false)
const basicFormRef = ref()
const {
@@ -1274,6 +1292,11 @@ async function handleVehicleLibrarySelect(vehicle: Vehicle) {
}
}
async function handlePasteRecognizeDone(result?: PasteCommitResult) {
if (!result?.vehicleId) return
await handleVehicleLibrarySelect({ id: result.vehicleId } as Vehicle)
}
async function handleCarrierLibrarySelect(carrier: Carrier) {
if (!carrier?.id) return
await ensureSelectedCarrierOption(carrier.id)
@@ -15,147 +15,176 @@
<div class="panel dialog-list-panel">
<el-tabs v-model="activeTab" class="pl-vehicle-library-select-tabs" @tab-change="handleTabChange">
<el-tab-pane label="三方车辆" name="carrier" />
<el-tab-pane label="自有车辆" name="self" />
<el-tab-pane label="三方驾押人员" name="carrier_personnel" />
<el-tab-pane label="山峡车辆" name="self" />
<el-tab-pane label="山峡驾押人员" name="self_personnel" />
</el-tabs>
<div class="list-toolbar">
<div class="list-toolbar-row pl-vehicle-library-select-toolbar">
<el-input
v-model="keyword"
class="pl-vehicle-library-select-search"
placeholder="搜索车牌号"
clearable
@keyup.enter="handleSearch"
@clear="handleSearch"
>
<template #prefix>
<el-icon><Search /></el-icon>
</template>
</el-input>
<el-button class="btn-main" type="primary" @click="handleOpenCreate">
<el-icon><Plus /></el-icon>新增车辆
</el-button>
<template v-if="isVehicleTab">
<div class="list-toolbar">
<div class="list-toolbar-row pl-vehicle-library-select-toolbar">
<el-input
v-model="keyword"
class="pl-vehicle-library-select-search"
placeholder="搜索车牌号"
clearable
@keyup.enter="handleSearch"
@clear="handleSearch"
>
<template #prefix>
<el-icon><Search /></el-icon>
</template>
</el-input>
<el-button
v-if="activeTab === 'carrier'"
class="btn-ghost"
@click="pasteRecognizeVisible = true"
>
<el-icon><DocumentCopy /></el-icon>三方人车快速创建
</el-button>
<el-button class="btn-main" type="primary" @click="handleOpenCreate">
<el-icon><Plus /></el-icon>新增车辆
</el-button>
</div>
</div>
</div>
<div class="list-body list-wrap dialog-list-body-only">
<ListTable
table-key="business-pl-vehicle-library-select-dialog"
class="list-table pl-vehicle-library-select-table"
:data="rows"
v-loading="loading"
stripe
row-key="id"
highlight-current-row
:max-height="560"
empty-text="暂无可用车辆"
@row-dblclick="handleConfirm"
>
<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="licensePlate" label="车牌号" min-width="120" show-overflow-tooltip>
<template #default="{ row }">
<el-link type="primary" @click="handleConfirm(row)">{{ row.licensePlate }}</el-link>
</template>
</el-table-column>
<el-table-column
prop="trailerNo"
label="挂车号"
min-width="110"
align="center"
header-align="center"
show-overflow-tooltip
/>
<el-table-column
label="车辆状态"
min-width="100"
align="center"
header-align="center"
<div class="list-body list-wrap dialog-list-body-only">
<ListTable
table-key="business-pl-vehicle-library-select-dialog"
class="list-table pl-vehicle-library-select-table"
:data="rows"
v-loading="loading"
stripe
row-key="id"
highlight-current-row
:max-height="560"
empty-text="暂无可用车辆"
@row-dblclick="handleConfirm"
>
<template #default="{ row }">
<el-tag :type="getPlVehicleStatusTagType(row.vehicleStatus)" size="small">
{{ getPlVehicleStatusLabel(row.vehicleStatus) }}
</el-tag>
</template>
</el-table-column>
<el-table-column
prop="loadCapacity"
label="载重(吨)"
min-width="100"
align="center"
header-align="center"
/>
<el-table-column
v-if="activeTab === 'carrier'"
prop="carrierName"
label="承运商"
min-width="140"
align="center"
header-align="center"
show-overflow-tooltip
/>
<el-table-column
prop="personnelSummary"
label="关联人员摘要"
min-width="160"
align="center"
header-align="center"
show-overflow-tooltip
>
<template #default="{ row }">
{{ normalizePlPersonnelSummaryDisplay(row.personnelSummary) }}
</template>
</el-table-column>
<el-table-column
label="操作"
min-width="160"
align="center"
header-align="center"
fixed="right"
class-name="col-actions"
>
<template #default="{ row }">
<el-button link type="primary" @click="handleOpenEdit(row)">
<el-icon><Edit /></el-icon>编辑
</el-button>
<el-button link type="primary" @click="handleConfirm(row)">
<el-icon><Select /></el-icon>选择
</el-button>
</template>
</el-table-column>
</ListTable>
<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="licensePlate" label="车牌号" min-width="120" show-overflow-tooltip>
<template #default="{ row }">
<el-link type="primary" @click="handleConfirm(row)">{{ row.licensePlate }}</el-link>
</template>
</el-table-column>
<el-table-column
prop="trailerNo"
label="挂车号"
min-width="110"
align="center"
header-align="center"
show-overflow-tooltip
/>
<el-table-column label="车辆状态" min-width="100" align="center" header-align="center">
<template #default="{ row }">
<el-tag :type="getPlVehicleStatusTagType(row.vehicleStatus)" size="small">
{{ getPlVehicleStatusLabel(row.vehicleStatus) }}
</el-tag>
</template>
</el-table-column>
<el-table-column
prop="loadCapacity"
label="载重(吨)"
min-width="100"
align="center"
header-align="center"
/>
<el-table-column
v-if="activeTab === 'carrier'"
prop="carrierName"
label="承运商"
min-width="140"
align="center"
header-align="center"
show-overflow-tooltip
/>
<el-table-column
prop="personnelSummary"
label="关联人员摘要"
min-width="160"
align="center"
header-align="center"
show-overflow-tooltip
>
<template #default="{ row }">
{{ normalizePlPersonnelSummaryDisplay(row.personnelSummary) }}
</template>
</el-table-column>
<el-table-column
label="操作"
min-width="160"
align="center"
header-align="center"
fixed="right"
class-name="col-actions"
>
<template #default="{ row }">
<el-button link type="primary" @click="handleOpenEdit(row)">
<el-icon><Edit /></el-icon>编辑
</el-button>
<el-button link type="primary" @click="handleConfirm(row)">
<el-icon><Select /></el-icon>选择
</el-button>
</template>
</el-table-column>
</ListTable>
<ListPagination
v-show="pagination.total > 0"
:total="pagination.total"
v-model:page="pagination.page"
v-model:limit="pagination.pageSize"
@pagination="fetchList"
/>
</div>
<ListPagination
v-show="pagination.total > 0"
:total="pagination.total"
v-model:page="pagination.page"
v-model:limit="pagination.pageSize"
@pagination="fetchList"
/>
</div>
</template>
<PlPersonnelLibrarySelectPanel
v-else-if="activeTab === 'carrier_personnel'"
ref="carrierPersonnelPanelRef"
affiliation="carrier"
/>
<PlPersonnelLibrarySelectPanel
v-else-if="activeTab === 'self_personnel'"
ref="selfPersonnelPanelRef"
affiliation="self"
/>
</div>
<PlVehicleFormDialog
v-model="formVisible"
:vehicle-type="activeTab"
:vehicle-type="vehicleTab"
:vehicle-id="editingId"
@saved="handleFormSaved"
/>
<PlPasteRecognizeDialog
v-model:visible="pasteRecognizeVisible"
mode="vehicle-bundle"
@done="handlePasteRecognizeDone"
/>
</el-dialog>
</template>
<script setup lang="ts">
import { Edit, Plus, Search, Select } from '@element-plus/icons-vue'
import { vehicleApi, type Vehicle, type VehicleDetail } from '@/api/pl/index'
import { DocumentCopy, Edit, Plus, Search, Select } from '@element-plus/icons-vue'
import {
vehicleApi,
type PasteCommitResult,
type Vehicle,
type VehicleDetail
} from '@/api/pl/index'
import PlPasteRecognizeDialog from '@/components/business/pl-paste-recognize-dialog/index.vue'
import PlPersonnelLibrarySelectPanel from '@/components/business/pl-personnel-library-select-panel/index.vue'
import PlVehicleFormDialog from '@/components/business/pl-vehicle-form-dialog/index.vue'
import ListPagination from '@/components/ListPagination/index.vue'
import { pickBxPageResult } from '@/utils/http/bx'
import { pickBxData, pickBxPageResult } from '@/utils/http/bx'
import {
getPlVehicleStatusLabel,
getPlVehicleStatusTagType,
@@ -163,6 +192,7 @@ import {
} from '@/utils/pl-display'
import { DEFAULT_LIST_PAGE_SIZE } from '@/utils/table/tableConfig'
type LibraryTab = 'carrier' | 'carrier_personnel' | 'self' | 'self_personnel'
type VehicleTab = 'carrier' | 'self'
const props = defineProps<{
@@ -181,7 +211,7 @@ const innerVisible = computed({
const loading = ref(false)
const keyword = ref('')
const activeTab = ref<VehicleTab>('carrier')
const activeTab = ref<LibraryTab>('carrier')
const rows = ref<Vehicle[]>([])
const pagination = reactive({
@@ -192,12 +222,19 @@ const pagination = reactive({
const formVisible = ref(false)
const editingId = ref<string | null>(null)
const pasteRecognizeVisible = ref(false)
const carrierPersonnelPanelRef = ref<InstanceType<typeof PlPersonnelLibrarySelectPanel>>()
const selfPersonnelPanelRef = ref<InstanceType<typeof PlPersonnelLibrarySelectPanel>>()
const isVehicleTab = computed(() => activeTab.value === 'carrier' || activeTab.value === 'self')
const vehicleTab = computed<VehicleTab>(() => (activeTab.value === 'self' ? 'self' : 'carrier'))
async function fetchList() {
if (!isVehicleTab.value) return
loading.value = true
try {
const res = await vehicleApi.list({
vehicleType: activeTab.value,
vehicleType: vehicleTab.value,
q: keyword.value.trim() || undefined,
page: pagination.page,
pageSize: pagination.pageSize
@@ -215,11 +252,28 @@ function handleSearch() {
fetchList()
}
function refreshPersonnelPanel() {
if (activeTab.value === 'carrier_personnel') {
carrierPersonnelPanelRef.value?.resetPanel()
carrierPersonnelPanelRef.value?.fetchList()
} else if (activeTab.value === 'self_personnel') {
selfPersonnelPanelRef.value?.resetPanel()
selfPersonnelPanelRef.value?.fetchList()
}
}
function handleTabChange() {
pagination.page = 1
formVisible.value = false
editingId.value = null
fetchList()
keyword.value = ''
if (isVehicleTab.value) {
fetchList()
return
}
nextTick(() => {
refreshPersonnelPanel()
})
}
function handleOpen() {
@@ -254,6 +308,24 @@ function handleFormSaved(payload: { mode: 'create' | 'edit'; vehicle: VehicleDet
fetchList()
}
async function handlePasteRecognizeDone(result?: PasteCommitResult) {
if (!result?.vehicleId) {
fetchList()
return
}
try {
const res = await vehicleApi.get(result.vehicleId)
const vehicle = pickBxData<VehicleDetail>(res)
if (vehicle?.id) {
handleConfirm(vehicle)
return
}
} catch {
// ignore
}
fetchList()
}
function handleConfirm(row: Vehicle) {
emit('select', row)
innerVisible.value = false