提交
This commit is contained in:
1 parent
a52fe77e34
commit
1938a9b76a
62 files changed
+612436
-10819
No files matched your search
@@ -55,7 +55,9 @@ export interface ContractProductForm {
|
||||
categoryName?: string
|
||||
unit?: string
|
||||
quantity: number
|
||||
quantityMode?: string
|
||||
price: number
|
||||
priceMode?: string
|
||||
taxRate?: number
|
||||
taxAmount?: number
|
||||
subtotal?: number
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
/**
|
||||
* 从中国大陆 18 位身份证号解析出生日期并计算周岁年龄。
|
||||
* 号码不足 18 位或出生日期无效时返回 null(不强制校验码,便于输入过程中回填)。
|
||||
*/
|
||||
export function calcAgeFromChineseIdCard(idCard: string | null | undefined): number | null {
|
||||
if (!idCard || typeof idCard !== 'string') return null
|
||||
const s = idCard.trim().toUpperCase()
|
||||
if (!/^\d{17}[\dX]$/.test(s)) return null
|
||||
|
||||
const year = Number(s.slice(6, 10))
|
||||
const month = Number(s.slice(10, 12))
|
||||
const day = Number(s.slice(12, 14))
|
||||
if (!Number.isFinite(year) || !Number.isFinite(month) || !Number.isFinite(day)) return null
|
||||
if (month < 1 || month > 12 || day < 1 || day > 31) return null
|
||||
|
||||
const birth = new Date(year, month - 1, day)
|
||||
if (
|
||||
birth.getFullYear() !== year ||
|
||||
birth.getMonth() !== month - 1 ||
|
||||
birth.getDate() !== day
|
||||
) {
|
||||
return null
|
||||
}
|
||||
|
||||
const today = new Date()
|
||||
let age = today.getFullYear() - year
|
||||
const beforeBirthday =
|
||||
today.getMonth() < month - 1 ||
|
||||
(today.getMonth() === month - 1 && today.getDate() < day)
|
||||
if (beforeBirthday) age -= 1
|
||||
|
||||
if (age < 0 || age > 120) return null
|
||||
return age
|
||||
}
|
||||
@@ -8,14 +8,14 @@
|
||||
* 姓名保留姓、手机保留前 3 后 4、身份证保留前 6 后 4、车牌保留省份简称后打码
|
||||
*/
|
||||
export const PL_PASTE_SAMPLE_TEXT = [
|
||||
'皖****** 皖******',
|
||||
'车牌:皖******皖******挂',
|
||||
'核载:34 吨',
|
||||
'驾驶员:张**',
|
||||
'身份证号:340000********0000',
|
||||
'手机号:138****0000',
|
||||
'身份证:340000********0000',
|
||||
'押运员:李**',
|
||||
'电话:139****0000',
|
||||
'身份证:340000********0000'
|
||||
'身份证号:340000********0000',
|
||||
'电话:139****0000'
|
||||
].join('\n')
|
||||
|
||||
export interface PlPastePersonnelDraft {
|
||||
@@ -38,8 +38,47 @@ export interface PlPasteRecognizeResult {
|
||||
warnings: string[]
|
||||
}
|
||||
|
||||
const PLATE_LINE =
|
||||
/^[\u4e00-\u9fa5A-Z]{1,2}[A-Z0-9]+(?:\s+[\u4e00-\u9fa5A-Z]{1,2}[A-Z0-9]+)?$/i
|
||||
/** 普通蓝牌 7 位、挂车带「挂」、新能源约 8 位;每次新建避免 lastIndex 残留 */
|
||||
function plateTokenRe() {
|
||||
return /[\u4e00-\u9fa5][A-HJ-NP-Z][A-HJ-NP-Z0-9]{4,6}挂?/gi
|
||||
}
|
||||
|
||||
const PLATE_LINE_LABEL = /^(?:车牌号|车牌|主车号|主车|号牌)[::]\s*/i
|
||||
const TRAILER_LINE_LABEL = /^(?:挂车号|挂车)[::]\s*/i
|
||||
const ID_CARD_LINE = /^(?:身份证号码|身份证号|身份证|证件号)[::]?\s*([0-9Xx]{15,18})$/
|
||||
|
||||
function extractPlates(text: string): string[] {
|
||||
const compact = text.replace(/\s+/g, '').toUpperCase()
|
||||
const found = compact.match(plateTokenRe()) || []
|
||||
return found
|
||||
}
|
||||
|
||||
function remainderAfterPlates(text: string, plates: string[]): string {
|
||||
let rest = text.replace(/\s+/g, '').toUpperCase()
|
||||
for (const plate of plates) {
|
||||
rest = rest.replace(plate.toUpperCase(), '')
|
||||
}
|
||||
return rest.replace(/[,,、;;\-_//]/g, '')
|
||||
}
|
||||
|
||||
function applyPlatesToVehicle(
|
||||
vehicle: PlPasteVehicleDraft | undefined,
|
||||
plates: string[]
|
||||
): PlPasteVehicleDraft {
|
||||
const next = vehicle || { licensePlate: '' }
|
||||
if (plates[0] && !next.licensePlate) {
|
||||
next.licensePlate = plates[0]
|
||||
}
|
||||
if (plates[1] && !next.trailerNo) {
|
||||
next.trailerNo = plates[1]
|
||||
} else if (plates.length === 1 && plates[0].endsWith('挂') && next.licensePlate && !next.trailerNo) {
|
||||
next.trailerNo = plates[0]
|
||||
if (next.licensePlate === plates[0]) {
|
||||
next.licensePlate = ''
|
||||
}
|
||||
}
|
||||
return next
|
||||
}
|
||||
|
||||
export function parsePlCustomerVehicleText(raw: string): PlPasteRecognizeResult {
|
||||
const warnings: string[] = []
|
||||
@@ -54,13 +93,20 @@ export function parsePlCustomerVehicleText(raw: string): PlPasteRecognizeResult
|
||||
let section: 'none' | 'driver' | 'escort' = 'none'
|
||||
|
||||
for (const line of lines) {
|
||||
const normalizedPlateLine = line.replace(/\s+/g, ' ')
|
||||
if (!vehicle && PLATE_LINE.test(normalizedPlateLine)) {
|
||||
const parts = normalizedPlateLine.split(/\s+/).filter(Boolean)
|
||||
vehicle = {
|
||||
licensePlate: parts[0] || '',
|
||||
trailerNo: parts[1] || undefined
|
||||
if (TRAILER_LINE_LABEL.test(line)) {
|
||||
const plates = extractPlates(line.replace(TRAILER_LINE_LABEL, ''))
|
||||
if (plates.length) {
|
||||
if (!vehicle) vehicle = { licensePlate: '' }
|
||||
vehicle.trailerNo = plates[0]
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
const plateLabeled = PLATE_LINE_LABEL.test(line)
|
||||
const plateSource = plateLabeled ? line.replace(PLATE_LINE_LABEL, '') : line
|
||||
const plates = extractPlates(plateSource)
|
||||
if (plates.length && (plateLabeled || !remainderAfterPlates(plateSource, plates))) {
|
||||
vehicle = applyPlatesToVehicle(vehicle, plates)
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -103,7 +149,7 @@ export function parsePlCustomerVehicleText(raw: string): PlPasteRecognizeResult
|
||||
}
|
||||
}
|
||||
|
||||
const idCard = line.match(/^身份证[::]?\s*([0-9Xx]{15,18})$/)
|
||||
const idCard = line.match(ID_CARD_LINE)
|
||||
if (idCard) {
|
||||
const no = idCard[1].toUpperCase()
|
||||
if (section === 'driver' && driver) {
|
||||
|
||||
@@ -1,19 +1,32 @@
|
||||
<template>
|
||||
<div class="attachment-upload">
|
||||
<div
|
||||
ref="rootRef"
|
||||
class="attachment-upload"
|
||||
:class="{ 'attachment-upload--drag-over': isDragOver && !disabled }"
|
||||
:tabindex="disabled ? undefined : 0"
|
||||
@mouseenter="handlePointerEnter"
|
||||
@mouseleave="handlePointerLeave"
|
||||
@focusin="handlePointerEnter"
|
||||
@focusout="handleFocusOut"
|
||||
@dragenter="handleDragEnter"
|
||||
@dragleave="handleDragLeave"
|
||||
@dragover="handleDragOver"
|
||||
@drop="handleDrop"
|
||||
>
|
||||
<div class="attachment-list">
|
||||
<el-upload
|
||||
v-if="!disabled"
|
||||
ref="uploadRef"
|
||||
:http-request="handleAttachmentUpload"
|
||||
:auto-upload="false"
|
||||
:show-file-list="false"
|
||||
:before-upload="handleBeforeUpload"
|
||||
:disabled="disabled"
|
||||
multiple
|
||||
:limit="limit"
|
||||
:accept="accept"
|
||||
@change="handleAttachmentChange"
|
||||
>
|
||||
<div class="upload-card">
|
||||
<el-icon :size="28" color="#1ca851"><Plus /></el-icon>
|
||||
<span class="upload-card-text">上传附件</span>
|
||||
<span class="upload-card-text">{{ isDragOver ? '松开上传' : '上传附件' }}</span>
|
||||
</div>
|
||||
</el-upload>
|
||||
<div
|
||||
@@ -110,8 +123,8 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { nextTick, ref } from 'vue'
|
||||
import type { UploadInstance, UploadRequestOptions } from 'element-plus'
|
||||
import { nextTick, onBeforeUnmount, onMounted, ref } from 'vue'
|
||||
import type { UploadFile, UploadInstance } from 'element-plus'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { Plus, Document, Loading, Download, Delete, ZoomIn } from '@element-plus/icons-vue'
|
||||
import { fetchUploadAttachment } from '@/api/admin'
|
||||
@@ -138,14 +151,18 @@ const props = withDefaults(
|
||||
{
|
||||
limit: 10,
|
||||
accept: 'image/*,.pdf,.doc,.docx',
|
||||
hint: '支持上传图片、PDF、Word文档等,最多10个文件',
|
||||
hint: '支持上传图片、PDF、Word文档等,最多10个文件;可拖拽或在此区域粘贴上传',
|
||||
disabled: false
|
||||
}
|
||||
)
|
||||
|
||||
const attachmentList = defineModel<ContractAttachmentItem[]>({ default: () => [] })
|
||||
|
||||
const rootRef = ref<HTMLElement>()
|
||||
const uploadRef = ref<UploadInstance>()
|
||||
const isPointerInside = ref(false)
|
||||
const isDragOver = ref(false)
|
||||
let dragEnterDepth = 0
|
||||
const attachmentPreviewVisible = ref(false)
|
||||
const attachmentPreviewFile = ref<ContractAttachmentItem | null>(null)
|
||||
const attachmentPreviewSrc = ref('')
|
||||
@@ -207,35 +224,59 @@ const getShortFileName = (fileName: string) => {
|
||||
return name.substring(0, 8) + '...' + ext
|
||||
}
|
||||
|
||||
const handleBeforeUpload = (file: File) => {
|
||||
const isValidType = /\.(jpg|jpeg|png|gif|bmp|webp|pdf|doc|docx|txt|mp4|avi|mov)$/i.test(file.name)
|
||||
if (!isValidType) {
|
||||
const isFileAccepted = (file: File) => {
|
||||
return /\.(jpg|jpeg|png|gif|bmp|webp|pdf|doc|docx|txt|mp4|avi|mov)$/i.test(file.name)
|
||||
}
|
||||
|
||||
const normalizeIncomingFile = (file: File, index = 0) => {
|
||||
if (file.name && file.name.trim()) return file
|
||||
const ext = (file.type || '').split('/')[1] || 'bin'
|
||||
return new File([file], `paste-${Date.now()}-${index}.${ext}`, {
|
||||
type: file.type || 'application/octet-stream'
|
||||
})
|
||||
}
|
||||
|
||||
const collectClipboardFiles = (event: ClipboardEvent) => {
|
||||
const files: File[] = []
|
||||
const items = event.clipboardData?.items
|
||||
if (items?.length) {
|
||||
Array.from(items).forEach((item, index) => {
|
||||
if (item.kind !== 'file') return
|
||||
const file = item.getAsFile()
|
||||
if (file) files.push(normalizeIncomingFile(file, index))
|
||||
})
|
||||
}
|
||||
if (!files.length && event.clipboardData?.files?.length) {
|
||||
Array.from(event.clipboardData.files).forEach((file, index) => {
|
||||
files.push(normalizeIncomingFile(file, index))
|
||||
})
|
||||
}
|
||||
return files
|
||||
}
|
||||
|
||||
const uploadRawFile = async (rawFile: File) => {
|
||||
if (attachmentList.value.length >= props.limit) {
|
||||
ElMessage.warning(`最多上传 ${props.limit} 个附件`)
|
||||
return false
|
||||
}
|
||||
if (!isFileAccepted(rawFile)) {
|
||||
$modal.msgError('上传文件格式不正确!')
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
const handleAttachmentUpload = async (options: UploadRequestOptions) => {
|
||||
if (attachmentList.value.length >= props.limit) {
|
||||
ElMessage.warning(`最多上传 ${props.limit} 个附件`)
|
||||
options.onError?.(new Error('超出数量限制'))
|
||||
return
|
||||
}
|
||||
|
||||
const uid = `upload-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`
|
||||
const localPreview = isCrmImageFile({ name: options.file.name })
|
||||
? URL.createObjectURL(options.file)
|
||||
const localPreview = isCrmImageFile({ name: rawFile.name })
|
||||
? URL.createObjectURL(rawFile)
|
||||
: undefined
|
||||
attachmentList.value.push({
|
||||
uid,
|
||||
name: options.file.name,
|
||||
name: rawFile.name,
|
||||
status: 'uploading',
|
||||
category: 'other',
|
||||
localPreview
|
||||
})
|
||||
|
||||
const formData = buildAttachmentUploadFormData(options.file, { bizType: props.bizType })
|
||||
const formData = buildAttachmentUploadFormData(rawFile, { bizType: props.bizType })
|
||||
|
||||
try {
|
||||
const res = await fetchUploadAttachment(formData)
|
||||
@@ -246,11 +287,11 @@ const handleAttachmentUpload = async (options: UploadRequestOptions) => {
|
||||
patchAttachmentFile(uid, {
|
||||
ossId: fileUrl,
|
||||
url: fileUrl,
|
||||
name: res?.fileName || options.file.name,
|
||||
name: res?.fileName || rawFile.name,
|
||||
status: 'success'
|
||||
})
|
||||
options.onSuccess?.(res)
|
||||
$modal.msgSuccess('文件上传成功')
|
||||
return true
|
||||
} catch (error: any) {
|
||||
const failed = attachmentList.value.find((item) => item.uid === uid)
|
||||
if (failed?.localPreview) {
|
||||
@@ -258,13 +299,95 @@ const handleAttachmentUpload = async (options: UploadRequestOptions) => {
|
||||
}
|
||||
attachmentList.value = attachmentList.value.filter((item) => item.uid !== uid)
|
||||
$modal.msgError(error?.message || '文件上传失败')
|
||||
options.onError?.(error)
|
||||
} finally {
|
||||
await nextTick()
|
||||
uploadRef.value?.clearFiles()
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
const uploadFiles = async (files: File[]) => {
|
||||
if (!files.length || props.disabled) return
|
||||
for (const file of files) {
|
||||
if (attachmentList.value.length >= props.limit) {
|
||||
ElMessage.warning(`最多上传 ${props.limit} 个附件`)
|
||||
break
|
||||
}
|
||||
await uploadRawFile(file)
|
||||
}
|
||||
}
|
||||
|
||||
const handleAttachmentChange = async (uploadFile: UploadFile) => {
|
||||
const rawFile = uploadFile.raw
|
||||
if (!rawFile) return
|
||||
await uploadRawFile(rawFile)
|
||||
await nextTick()
|
||||
uploadRef.value?.clearFiles()
|
||||
}
|
||||
|
||||
const handlePointerEnter = () => {
|
||||
if (props.disabled) return
|
||||
isPointerInside.value = true
|
||||
}
|
||||
|
||||
const handlePointerLeave = () => {
|
||||
isPointerInside.value = false
|
||||
}
|
||||
|
||||
const handleFocusOut = (event: FocusEvent) => {
|
||||
const next = event.relatedTarget as Node | null
|
||||
if (next && rootRef.value?.contains(next)) return
|
||||
isPointerInside.value = false
|
||||
}
|
||||
|
||||
const handleDragEnter = (event: DragEvent) => {
|
||||
if (props.disabled) return
|
||||
event.preventDefault()
|
||||
dragEnterDepth += 1
|
||||
isDragOver.value = true
|
||||
isPointerInside.value = true
|
||||
}
|
||||
|
||||
const handleDragLeave = (event: DragEvent) => {
|
||||
if (props.disabled) return
|
||||
event.preventDefault()
|
||||
dragEnterDepth = Math.max(0, dragEnterDepth - 1)
|
||||
if (dragEnterDepth === 0) {
|
||||
isDragOver.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const handleDragOver = (event: DragEvent) => {
|
||||
if (props.disabled) return
|
||||
event.preventDefault()
|
||||
if (event.dataTransfer) {
|
||||
event.dataTransfer.dropEffect = 'copy'
|
||||
}
|
||||
}
|
||||
|
||||
const handleDrop = async (event: DragEvent) => {
|
||||
if (props.disabled) return
|
||||
event.preventDefault()
|
||||
dragEnterDepth = 0
|
||||
isDragOver.value = false
|
||||
const files = Array.from(event.dataTransfer?.files || [])
|
||||
await uploadFiles(files)
|
||||
}
|
||||
|
||||
const handleDocumentPaste = async (event: ClipboardEvent) => {
|
||||
if (props.disabled || !isPointerInside.value) return
|
||||
const files = collectClipboardFiles(event)
|
||||
if (!files.length) return
|
||||
event.preventDefault()
|
||||
event.stopPropagation()
|
||||
await uploadFiles(files)
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
document.addEventListener('paste', handleDocumentPaste, true)
|
||||
})
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
document.removeEventListener('paste', handleDocumentPaste, true)
|
||||
})
|
||||
|
||||
const handleFilePreview = async (file: ContractAttachmentItem) => {
|
||||
if (!canPreviewAttachment(file)) {
|
||||
$modal.msgWarning('文件尚未上传完成')
|
||||
@@ -330,6 +453,33 @@ defineExpose({ hasUploading })
|
||||
<style scoped lang="scss">
|
||||
.attachment-upload {
|
||||
width: 100%;
|
||||
outline: none;
|
||||
border-radius: 8px;
|
||||
|
||||
&:focus-visible {
|
||||
box-shadow: 0 0 0 2px rgba(28, 168, 81, 0.25);
|
||||
}
|
||||
|
||||
&--drag-over {
|
||||
.attachment-list {
|
||||
border-radius: 8px;
|
||||
background: rgba(16, 185, 129, 0.06);
|
||||
outline: 2px dashed #1ca851;
|
||||
outline-offset: 4px;
|
||||
padding: 4px;
|
||||
}
|
||||
|
||||
.upload-card {
|
||||
border-color: #1ca851;
|
||||
border-style: solid;
|
||||
background: #e6f8ed;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
:deep(.el-upload) {
|
||||
display: inline-flex;
|
||||
flex: 0 0 auto;
|
||||
}
|
||||
|
||||
.attachment-list {
|
||||
|
||||
@@ -205,7 +205,14 @@
|
||||
<DictTag dict-type="crm_product_unit" :value="scope.row.unit" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="数量" prop="quantity" min-width="72" align="right" />
|
||||
<el-table-column label="数量" prop="quantity" min-width="96" align="right">
|
||||
<template #default="scope">
|
||||
<span v-if="isFrameworkContractType(detailContract.contractType)" class="text-muted">
|
||||
{{ displayFrameworkQuantity(scope.row, true) }}
|
||||
</span>
|
||||
<span v-else>{{ scope.row.quantity }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
v-if="!hideProductPrice"
|
||||
label="含税单价(元)"
|
||||
@@ -214,7 +221,9 @@
|
||||
align="right"
|
||||
>
|
||||
<template #default="scope">
|
||||
<span v-if="isFrameworkContractType(detailContract.contractType)" class="text-muted">随行就市</span>
|
||||
<span v-if="isFrameworkContractType(detailContract.contractType)" class="text-muted">
|
||||
{{ displayFrameworkMoney(scope.row, 'price', true) }}
|
||||
</span>
|
||||
<span v-else class="money-display">¥{{ parseFloat(scope.row.price || 0).toFixed(2) }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
@@ -226,7 +235,9 @@
|
||||
align="right"
|
||||
>
|
||||
<template #default="scope">
|
||||
<span v-if="isFrameworkContractType(detailContract.contractType)" class="text-muted">随行就市</span>
|
||||
<span v-if="isFrameworkContractType(detailContract.contractType)" class="text-muted">
|
||||
{{ displayFrameworkMoney(scope.row, 'subtotal', true) }}
|
||||
</span>
|
||||
<span v-else class="money-display">¥{{ parseFloat(scope.row.subtotal || 0).toFixed(2) }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
@@ -238,7 +249,9 @@
|
||||
align="right"
|
||||
>
|
||||
<template #default="scope">
|
||||
<span v-if="isFrameworkContractType(detailContract.contractType)" class="text-muted">随行就市</span>
|
||||
<span v-if="isFrameworkContractType(detailContract.contractType)" class="text-muted">
|
||||
{{ displayFrameworkMoney(scope.row, 'taxAmount', true) }}
|
||||
</span>
|
||||
<span v-else class="money-display">¥{{ parseFloat(scope.row.taxAmount || 0).toFixed(2) }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
@@ -843,6 +856,7 @@
|
||||
import { ref, reactive, computed, onMounted, defineAsyncComponent, nextTick } from 'vue';
|
||||
import { useRouter } from 'vue-router';
|
||||
import { isFrameworkContractType, isContractEditableStatus, getContractReeditConfirmMessage } from '../contractType'
|
||||
import { displayFrameworkMoney, displayFrameworkQuantity } from '../frameworkProductPricing'
|
||||
import {
|
||||
CircleCheck,
|
||||
CircleClose,
|
||||
|
||||
@@ -438,19 +438,86 @@
|
||||
</el-select>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="quantity" width="110">
|
||||
<el-table-column prop="quantity" width="130">
|
||||
<template #header> <span style="color: #f56c6c">*</span> 数量</template>
|
||||
<template #default="scope">
|
||||
<el-input v-model="scope.row.quantity" placeholder="数量" @input="handleQuantityChange(scope.row)" clearable size="small" />
|
||||
<div v-if="isFrameworkContract" class="framework-pricing-cell">
|
||||
<template v-if="isFrameworkQuantityCustomerDemand(scope.row)">
|
||||
<span class="text-muted framework-pricing-cell__label">{{ FRAMEWORK_QUANTITY_LABEL }}</span>
|
||||
<el-button
|
||||
link
|
||||
type="primary"
|
||||
class="framework-pricing-cell__action"
|
||||
@click="handleEnableFrameworkQuantityFixed(scope.row)"
|
||||
>
|
||||
填数字
|
||||
</el-button>
|
||||
</template>
|
||||
<template v-else>
|
||||
<el-input
|
||||
v-model="scope.row.quantity"
|
||||
placeholder="数量"
|
||||
@input="handleQuantityChange(scope.row)"
|
||||
clearable
|
||||
size="small"
|
||||
/>
|
||||
<el-button
|
||||
link
|
||||
type="primary"
|
||||
class="framework-pricing-cell__action"
|
||||
@click="handleResetFrameworkQuantity(scope.row)"
|
||||
>
|
||||
按客户需求
|
||||
</el-button>
|
||||
</template>
|
||||
</div>
|
||||
<el-input
|
||||
v-else
|
||||
v-model="scope.row.quantity"
|
||||
placeholder="数量"
|
||||
@input="handleQuantityChange(scope.row)"
|
||||
clearable
|
||||
size="small"
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="price" width="130">
|
||||
<el-table-column prop="price" width="150">
|
||||
<template #header>
|
||||
<span v-if="isFrameworkContract">含税单价(元)</span>
|
||||
<span v-else><span style="color: #f56c6c">*</span> 含税单价(元)</span>
|
||||
</template>
|
||||
<template #default="scope">
|
||||
<span v-if="isFrameworkContract" class="text-muted">随行就市</span>
|
||||
<div v-if="isFrameworkContract" class="framework-pricing-cell">
|
||||
<template v-if="isFrameworkPriceMarket(scope.row)">
|
||||
<span class="text-muted framework-pricing-cell__label">{{ FRAMEWORK_PRICE_LABEL }}</span>
|
||||
<el-button
|
||||
link
|
||||
type="primary"
|
||||
class="framework-pricing-cell__action"
|
||||
@click="handleEnableFrameworkPriceFixed(scope.row)"
|
||||
>
|
||||
填数字
|
||||
</el-button>
|
||||
</template>
|
||||
<template v-else>
|
||||
<el-input
|
||||
v-model="scope.row.price"
|
||||
placeholder="含税单价"
|
||||
@input="handlePriceChange(scope.row)"
|
||||
clearable
|
||||
size="small"
|
||||
class="money-field-input"
|
||||
/>
|
||||
<el-button
|
||||
link
|
||||
type="primary"
|
||||
class="framework-pricing-cell__action"
|
||||
@click="handleResetFrameworkPrice(scope.row)"
|
||||
>
|
||||
随行就市
|
||||
</el-button>
|
||||
</template>
|
||||
</div>
|
||||
<el-input
|
||||
v-else
|
||||
v-model="scope.row.price"
|
||||
@@ -462,19 +529,45 @@
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="subtotal" width="130" align="right">
|
||||
<el-table-column prop="subtotal" width="150" align="right">
|
||||
<template #header>
|
||||
<span v-if="isFrameworkContract">含税总价(元)</span>
|
||||
<span v-else><span style="color: #f56c6c">*</span> 含税总价(元)</span>
|
||||
</template>
|
||||
<template #default="scope">
|
||||
<span v-if="isFrameworkContract" class="text-muted">随行就市</span>
|
||||
<div v-if="isFrameworkContract" class="framework-pricing-cell framework-pricing-cell--money">
|
||||
<template v-if="isFrameworkPriceMarket(scope.row)">
|
||||
<span class="text-muted framework-pricing-cell__label">{{ FRAMEWORK_PRICE_LABEL }}</span>
|
||||
<el-button
|
||||
link
|
||||
type="primary"
|
||||
class="framework-pricing-cell__action"
|
||||
@click="handleEnableFrameworkPriceFixed(scope.row)"
|
||||
>
|
||||
填数字
|
||||
</el-button>
|
||||
</template>
|
||||
<span v-else class="money-display">{{ formatFrameworkMoneyDisplay(scope.row, 'subtotal') }}</span>
|
||||
</div>
|
||||
<span v-else class="money-display">¥{{ parseFloat(scope.row.subtotal || 0).toFixed(2) }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="税费(元)" prop="taxAmount" min-width="90" align="right">
|
||||
<el-table-column label="税费(元)" prop="taxAmount" min-width="120" align="right">
|
||||
<template #default="scope">
|
||||
<span v-if="isFrameworkContract" class="text-muted">随行就市</span>
|
||||
<div v-if="isFrameworkContract" class="framework-pricing-cell framework-pricing-cell--money">
|
||||
<template v-if="isFrameworkPriceMarket(scope.row)">
|
||||
<span class="text-muted framework-pricing-cell__label">{{ FRAMEWORK_PRICE_LABEL }}</span>
|
||||
<el-button
|
||||
link
|
||||
type="primary"
|
||||
class="framework-pricing-cell__action"
|
||||
@click="handleEnableFrameworkPriceFixed(scope.row)"
|
||||
>
|
||||
填数字
|
||||
</el-button>
|
||||
</template>
|
||||
<span v-else class="money-display">{{ formatFrameworkMoneyDisplay(scope.row, 'taxAmount') }}</span>
|
||||
</div>
|
||||
<span v-else class="money-display">¥{{ parseFloat(scope.row.taxAmount || 0).toFixed(2) }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
@@ -542,7 +635,7 @@
|
||||
</el-button>
|
||||
<div class="panel dialog-list-panel mb-3">
|
||||
<div class="list-body list-wrap dialog-list-body-only">
|
||||
<ListTable table-key="crm-contract-components-contract-form-dialog-2" :data="prod.priceTiers || []" class="list-table" stripe empty-text="暂无调价区间">
|
||||
<ListTable table-key="crm-contract-components-contract-form-dialog-2" :data="prod.priceTiers || []" class="list-table fw-price-tier-table" stripe empty-text="暂无调价区间">
|
||||
<el-table-column type="index" label="#" min-width="50" align="center" header-align="center" />
|
||||
<el-table-column label="开始日期" min-width="150">
|
||||
<template #default="scope">
|
||||
@@ -559,21 +652,16 @@
|
||||
<el-input v-model="scope.row.price" placeholder="含税单价" clearable size="small" class="money-field-input" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="调价函" min-width="300">
|
||||
<el-table-column label="调价函" min-width="220">
|
||||
<template #default="scope">
|
||||
<el-upload
|
||||
:http-request="(opt) => handleTierLetterUploadRequest(opt, pIdx, scope.$index)"
|
||||
list-type="picture-card"
|
||||
:limit="20"
|
||||
multiple
|
||||
<AttachmentUploadField
|
||||
:model-value="tierLetterCsv(scope.row)"
|
||||
accept="image/*"
|
||||
:file-list="scope.row._letterFiles || []"
|
||||
:on-remove="(file) => handleTierLetterRemove(file, pIdx, scope.$index)"
|
||||
class="tier-letter-upload"
|
||||
>
|
||||
<el-icon><Plus /></el-icon>
|
||||
</el-upload>
|
||||
<div class="text-muted" style="font-size: 11px; margin-top: 4px">支持多张图片</div>
|
||||
:limit="20"
|
||||
compact
|
||||
:biz-type="CRM_UPLOAD_BIZ_TYPE.CONTRACT_PRICE_LETTER"
|
||||
@update:model-value="syncTierLetterCsv(scope.row, $event)"
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" min-width="70" align="center" header-align="center" fixed="right" class-name="col-actions">
|
||||
@@ -733,7 +821,7 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive, computed, nextTick, watch } from 'vue'
|
||||
import type { FormInstance, FormItemRule, UploadRequestOptions } from 'element-plus'
|
||||
import type { FormInstance, FormItemRule } from 'element-plus'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import {
|
||||
getContract,
|
||||
@@ -744,6 +832,24 @@ import {
|
||||
type ContractProductPriceTierForm
|
||||
} from '@/api/crm/contract/index'
|
||||
import { isFrameworkContractType } from '../contractType'
|
||||
import {
|
||||
FRAMEWORK_QUANTITY_LABEL,
|
||||
FRAMEWORK_PRICE_LABEL,
|
||||
applyFrameworkDefaultsToProduct,
|
||||
createFrameworkProductPricingDefaults,
|
||||
enableFrameworkPriceFixed,
|
||||
enableFrameworkQuantityFixed,
|
||||
formatFrameworkMoneyDisplay,
|
||||
isBlankNumeric,
|
||||
isFrameworkPriceMarket,
|
||||
isFrameworkQuantityCustomerDemand,
|
||||
isNegativeNumeric,
|
||||
confirmZeroPricingIfNeeded,
|
||||
normalizeFrameworkProductPricing,
|
||||
prepareFrameworkProductForSubmit,
|
||||
resetFrameworkPriceToMarket,
|
||||
resetFrameworkQuantityToCustomerDemand
|
||||
} from '../frameworkProductPricing'
|
||||
import { useDictStore } from '@/store/modules/dict'
|
||||
import { useUserStore } from '@/store/modules/user'
|
||||
import { $modal } from '@/utils/modal'
|
||||
@@ -763,12 +869,12 @@ import {
|
||||
} from '@element-plus/icons-vue'
|
||||
import {
|
||||
buildUploadFileListFromField,
|
||||
fillAttachmentInfoCache,
|
||||
serializeContractAttachments,
|
||||
type ContractAttachmentItem
|
||||
} from '@/utils/crm-attachment'
|
||||
import { buildAttachmentUploadFormData, CRM_UPLOAD_BIZ_TYPE } from '@/utils/crm-upload'
|
||||
import { CRM_UPLOAD_BIZ_TYPE } from '@/utils/crm-upload'
|
||||
import ContractAttachmentPanel from './ContractAttachmentPanel.vue'
|
||||
import AttachmentUploadField from '@/components/business/attachment-upload-field/index.vue'
|
||||
import { getOpportunity } from '@/api/crm/opportunity'
|
||||
import { getQuote } from '@/api/crm/quote'
|
||||
import ProductSelector from '@/components/business/product-selector/index.vue'
|
||||
@@ -797,7 +903,7 @@ import {
|
||||
import type { CustomerVO, ContactVO } from '@/api/crm/customer/types'
|
||||
import { getDefaultInvoiceInfoByCustomerId } from '@/api/crm/invoiceInfo'
|
||||
import { listAllSupplierInfo, type SupplierInfoVO } from '@/api/crm/supplierInfo'
|
||||
import { fetchUploadAttachment, fetchUserOptions } from '@/api/admin'
|
||||
import { fetchUserOptions } from '@/api/admin'
|
||||
import { filterOwnerCandidates, findDefaultOwnerUser } from '@/utils/crm-owner-candidates'
|
||||
|
||||
interface UserVO {
|
||||
@@ -820,7 +926,7 @@ type ExtendedContractForm = ContractForm & {
|
||||
}
|
||||
|
||||
// 扩展产品类型,添加显示字段
|
||||
type PriceTierRow = ContractProductPriceTierForm & { _letterFiles?: any[] }
|
||||
type PriceTierRow = ContractProductPriceTierForm
|
||||
|
||||
type ExtendedContractProductForm = ContractProductForm & {
|
||||
productName?: string
|
||||
@@ -1408,30 +1514,28 @@ const loadContractDetail = async (id: number | string) => {
|
||||
}
|
||||
return {
|
||||
...t,
|
||||
letterOssIds: ids,
|
||||
_letterFiles: [] as any[]
|
||||
letterOssIds: ids
|
||||
}
|
||||
}),
|
||||
taxRate: product.taxRate || 6,
|
||||
taxAmount: 0,
|
||||
taxAmount: product.taxAmount ?? 0,
|
||||
packageSpec: product.packageSpec || '',
|
||||
deliveryMethod: product.deliveryMethod || ''
|
||||
}))
|
||||
|
||||
await enrichContractProductBrandMeta(form.value.products)
|
||||
|
||||
if (isFrameworkContractType(contractData.contractType)) {
|
||||
form.value.products.forEach((product: any) => {
|
||||
product.price = 0
|
||||
product.subtotal = 0
|
||||
product.taxAmount = 0
|
||||
})
|
||||
form.value.amount = 0
|
||||
await enrichFrameworkTierLetterFiles()
|
||||
} else {
|
||||
form.value.products.forEach((product: any) => {
|
||||
const isFw = isFrameworkContractType(contractData.contractType)
|
||||
form.value.products.forEach((product: any) => {
|
||||
normalizeFrameworkProductPricing(product, isFw)
|
||||
if (!isFw || !isFrameworkPriceMarket(product)) {
|
||||
calculateProductAmount(product)
|
||||
})
|
||||
}
|
||||
})
|
||||
if (isFw) {
|
||||
form.value.amount = 0
|
||||
} else {
|
||||
calculateTotalAmount()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1844,20 +1948,39 @@ const handleQuoteConfirm = (quote: QuoteVO) => {
|
||||
.confirm('是否要从报价单中带入产品明细?')
|
||||
.then(async () => {
|
||||
const isFw = isFrameworkContractType(form.value.contractType)
|
||||
form.value.products = quote.productList!.map((item: any) => ({
|
||||
productId: item.productId,
|
||||
productName: item.productName,
|
||||
productModel: item.model,
|
||||
categoryId: item.categoryId,
|
||||
categoryName: item.categoryName || '',
|
||||
unit: item.unit || '个',
|
||||
quantity: item.quantity || 1,
|
||||
price: isFw ? 0 : item.price || 0,
|
||||
unitPrice: isFw ? 0 : item.price || 0,
|
||||
taxRate: item.taxRate || 13,
|
||||
taxAmount: isFw ? 0 : item.taxAmount || 0,
|
||||
discount: item.discount || 0,
|
||||
subtotal: isFw ? 0 : item.subtotal || (item.quantity || 1) * (item.price || 0) * (1 - (item.discount || 0) / 100),
|
||||
form.value.products = quote.productList!.map((item: any) => {
|
||||
const hasQuotePrice = Number(item.price) > 0 || Number(item.subtotal) > 0
|
||||
const hasQuoteQty = Number(item.quantity) > 0
|
||||
const fwDefaults = createFrameworkProductPricingDefaults()
|
||||
return {
|
||||
productId: item.productId,
|
||||
productName: item.productName,
|
||||
productModel: item.model,
|
||||
categoryId: item.categoryId,
|
||||
categoryName: item.categoryName || '',
|
||||
unit: item.unit || '个',
|
||||
...(isFw
|
||||
? {
|
||||
...fwDefaults,
|
||||
quantityMode: hasQuoteQty ? 'fixed' : fwDefaults.quantityMode,
|
||||
quantity: hasQuoteQty ? item.quantity || 1 : 0,
|
||||
priceMode: hasQuotePrice ? 'fixed' : fwDefaults.priceMode,
|
||||
price: hasQuotePrice ? item.price || 0 : 0,
|
||||
taxAmount: hasQuotePrice ? item.taxAmount || 0 : 0,
|
||||
subtotal: hasQuotePrice
|
||||
? item.subtotal || (item.quantity || 1) * (item.price || 0) * (1 - (item.discount || 0) / 100)
|
||||
: 0
|
||||
}
|
||||
: {
|
||||
quantity: item.quantity || 1,
|
||||
price: item.price || 0,
|
||||
unitPrice: item.price || 0,
|
||||
taxAmount: item.taxAmount || 0,
|
||||
subtotal:
|
||||
item.subtotal || (item.quantity || 1) * (item.price || 0) * (1 - (item.discount || 0) / 100)
|
||||
}),
|
||||
taxRate: item.taxRate || 13,
|
||||
discount: item.discount || 0,
|
||||
packageSpec: item.packageSpec || '',
|
||||
deliveryMethod: item.deliveryMethod || '',
|
||||
deliveryDate: '',
|
||||
@@ -1869,8 +1992,10 @@ const handleQuoteConfirm = (quote: QuoteVO) => {
|
||||
brandName: item.brandName || undefined,
|
||||
brandOptions: [],
|
||||
priceTiers: isFw ? [] : undefined
|
||||
}))
|
||||
}
|
||||
})
|
||||
await enrichContractProductBrandMeta(form.value.products)
|
||||
form.value.products.forEach((p) => calculateProductAmount(p))
|
||||
calculateTotalAmount()
|
||||
})
|
||||
.catch(() => {})
|
||||
@@ -2131,13 +2256,17 @@ const handleContractTypeChange = (value: string) => {
|
||||
if (isFrameworkContractType(value)) {
|
||||
form.value.amount = 0
|
||||
form.value.products?.forEach((p) => {
|
||||
p.price = 0
|
||||
p.subtotal = 0
|
||||
p.taxAmount = 0
|
||||
applyFrameworkDefaultsToProduct(p)
|
||||
if (!p.priceTiers) {
|
||||
p.priceTiers = []
|
||||
}
|
||||
})
|
||||
} else {
|
||||
form.value.products?.forEach((p) => {
|
||||
normalizeFrameworkProductPricing(p, false)
|
||||
calculateProductAmount(p)
|
||||
})
|
||||
calculateTotalAmount()
|
||||
}
|
||||
if (value === 'purchase' && !isPartiesSwapped.value) {
|
||||
$modal
|
||||
@@ -2230,11 +2359,8 @@ const handleProductSelected = (products: any[]) => {
|
||||
categoryId: product.categoryId,
|
||||
categoryName: product.categoryName || '',
|
||||
unit: product.unit || '个',
|
||||
quantity: 1,
|
||||
price: isFw ? 0 : product.price || 0,
|
||||
...(isFw ? createFrameworkProductPricingDefaults() : { quantity: 1, price: product.price || 0, taxAmount: 0, subtotal: product.price || 0 }),
|
||||
taxRate: normalizeTaxRateDisplay(product.taxRate, 13),
|
||||
taxAmount: 0,
|
||||
subtotal: isFw ? 0 : product.price || 0,
|
||||
packageSpec: '',
|
||||
deliveryMethod: '',
|
||||
description: product.description || '',
|
||||
@@ -2386,9 +2512,32 @@ const handlePackageSpecChange = (product: ExtendedContractProductForm, value: st
|
||||
product.packageSpec = value
|
||||
}
|
||||
|
||||
const handleEnableFrameworkQuantityFixed = (row: ExtendedContractProductForm) => {
|
||||
enableFrameworkQuantityFixed(row)
|
||||
calculateProductAmount(row)
|
||||
calculateTotalAmount()
|
||||
}
|
||||
|
||||
const handleResetFrameworkQuantity = (row: ExtendedContractProductForm) => {
|
||||
resetFrameworkQuantityToCustomerDemand(row)
|
||||
calculateProductAmount(row)
|
||||
calculateTotalAmount()
|
||||
}
|
||||
|
||||
const handleEnableFrameworkPriceFixed = (row: ExtendedContractProductForm) => {
|
||||
enableFrameworkPriceFixed(row)
|
||||
calculateProductAmount(row)
|
||||
calculateTotalAmount()
|
||||
}
|
||||
|
||||
const handleResetFrameworkPrice = (row: ExtendedContractProductForm) => {
|
||||
resetFrameworkPriceToMarket(row)
|
||||
calculateTotalAmount()
|
||||
}
|
||||
|
||||
/** 计算产品金额 */
|
||||
const calculateProductAmount = (product: ExtendedContractProductForm) => {
|
||||
if (isFrameworkContractType(form.value.contractType)) {
|
||||
if (isFrameworkContractType(form.value.contractType) && isFrameworkPriceMarket(product)) {
|
||||
product.price = 0
|
||||
product.subtotal = 0
|
||||
product.taxAmount = 0
|
||||
@@ -2428,35 +2577,14 @@ const calculateTotalAmount = () => {
|
||||
form.value.amount = total
|
||||
}
|
||||
|
||||
/** 框架合同:批量解析调价函 URL */
|
||||
const enrichFrameworkTierLetterFiles = async () => {
|
||||
const products = form.value.products || []
|
||||
const idSet = new Set<string>()
|
||||
products.forEach((p: any) => {
|
||||
;(p.priceTiers || []).forEach((t: any) => {
|
||||
;(t.letterOssIds || []).forEach((id: string) => idSet.add(String(id)))
|
||||
})
|
||||
})
|
||||
if (idSet.size === 0) return
|
||||
/** 框架合同调价函:逗号分隔 URL 与 letterOssIds 互转 */
|
||||
const tierLetterCsv = (row: PriceTierRow) => (row.letterOssIds || []).join(',')
|
||||
|
||||
const cache = new Map<string, { name: string; url: string }>()
|
||||
fillAttachmentInfoCache([...idSet], cache)
|
||||
|
||||
products.forEach((p: any) => {
|
||||
;(p.priceTiers || []).forEach((t: any) => {
|
||||
const ids = t.letterOssIds || []
|
||||
t._letterFiles = ids.map((ossId: string, i: number) => {
|
||||
const info = cache.get(String(ossId))
|
||||
return {
|
||||
name: info?.name || `调价函${i + 1}`,
|
||||
ossId: String(ossId),
|
||||
url: info?.url || ossId,
|
||||
uid: `tier-prev-${t.id ?? 'n'}-${i}-${ossId}`,
|
||||
status: 'success'
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
const syncTierLetterCsv = (row: PriceTierRow, val: string) => {
|
||||
row.letterOssIds = String(val || '')
|
||||
.split(',')
|
||||
.map((item) => item.trim())
|
||||
.filter(Boolean)
|
||||
}
|
||||
|
||||
/** 组装提交/保存的产品明细 */
|
||||
@@ -2493,9 +2621,8 @@ const buildProductsPayload = () => {
|
||||
base.id = product.id
|
||||
}
|
||||
if (isFrameworkContractType(form.value.contractType)) {
|
||||
base.price = 0
|
||||
base.subtotal = 0
|
||||
base.taxAmount = 0
|
||||
const fwPricing = prepareFrameworkProductForSubmit(product)
|
||||
Object.assign(base, fwPricing)
|
||||
base.priceTiers = (product.priceTiers || [])
|
||||
.filter(
|
||||
(t: any) => t.startDate && t.endDate && t.price != null && t.price !== '' && Array.isArray(t.letterOssIds) && t.letterOssIds.length > 0
|
||||
@@ -2519,7 +2646,7 @@ const addPriceTierRow = (pIdx: number) => {
|
||||
if (!p.priceTiers) {
|
||||
p.priceTiers = []
|
||||
}
|
||||
p.priceTiers.push({ startDate: '', endDate: '', price: undefined, letterOssIds: [], _letterFiles: [] })
|
||||
p.priceTiers.push({ startDate: '', endDate: '', price: undefined, letterOssIds: [] })
|
||||
}
|
||||
|
||||
const removePriceTierRow = (pIdx: number, tIdx: number) => {
|
||||
@@ -2528,61 +2655,6 @@ const removePriceTierRow = (pIdx: number, tIdx: number) => {
|
||||
p.priceTiers.splice(tIdx, 1)
|
||||
}
|
||||
|
||||
const handleTierLetterUploadRequest = async (
|
||||
options: UploadRequestOptions,
|
||||
pIdx: number,
|
||||
tIdx: number
|
||||
) => {
|
||||
const p = form.value.products[pIdx]
|
||||
const tiers = p?.priceTiers
|
||||
if (!tiers || !tiers[tIdx]) {
|
||||
options.onError?.(new Error('调价区间不存在'))
|
||||
return
|
||||
}
|
||||
const row = tiers[tIdx]
|
||||
const formData = buildAttachmentUploadFormData(options.file, {
|
||||
bizType: CRM_UPLOAD_BIZ_TYPE.CONTRACT_PRICE_LETTER
|
||||
})
|
||||
try {
|
||||
const res = await fetchUploadAttachment(formData)
|
||||
const fileUrl = res?.fileUrl
|
||||
if (!fileUrl) {
|
||||
throw new Error('上传失败')
|
||||
}
|
||||
const oid = String(fileUrl)
|
||||
row.letterOssIds = row.letterOssIds || []
|
||||
row.letterOssIds.push(oid)
|
||||
row._letterFiles = row._letterFiles || []
|
||||
row._letterFiles.push({
|
||||
name: options.file.name || `调价函${row._letterFiles.length + 1}`,
|
||||
ossId: oid,
|
||||
url: oid,
|
||||
uid: options.file.uid,
|
||||
status: 'success'
|
||||
})
|
||||
options.onSuccess?.(res)
|
||||
} catch (error: any) {
|
||||
ElMessage.error(error?.message || '上传失败')
|
||||
options.onError?.(error)
|
||||
}
|
||||
}
|
||||
|
||||
const handleTierLetterRemove = (file: any, pIdx: number, tIdx: number) => {
|
||||
const p = form.value.products[pIdx]
|
||||
const tiers = p?.priceTiers
|
||||
if (!tiers || !tiers[tIdx]) return
|
||||
const row = tiers[tIdx]
|
||||
const uid = file.uid
|
||||
const idx = (row._letterFiles || []).findIndex((f: any) => f.uid === uid)
|
||||
if (idx >= 0) {
|
||||
const removed = row._letterFiles[idx]
|
||||
row._letterFiles.splice(idx, 1)
|
||||
if (removed?.ossId) {
|
||||
row.letterOssIds = (row.letterOssIds || []).filter((id: string) => String(id) !== String(removed.ossId))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** 处理附件数据 */
|
||||
const handleAttachmentData = async () => {
|
||||
attachmentList.value = buildUploadFileListFromField(
|
||||
@@ -2601,6 +2673,12 @@ const handleSaveDraft = async () => {
|
||||
return
|
||||
}
|
||||
|
||||
const confirmedZero = await confirmZeroPricingIfNeeded(
|
||||
form.value.products,
|
||||
isFrameworkContractType(form.value.contractType)
|
||||
)
|
||||
if (!confirmedZero) return
|
||||
|
||||
rebuildContractName()
|
||||
saveDraftLoading.value = true
|
||||
try {
|
||||
@@ -2690,8 +2768,23 @@ const handleSubmit = async () => {
|
||||
$modal.msgWarning(`第${rowNum}行产品的产品名称不能为空`)
|
||||
return false
|
||||
}
|
||||
if (!product.quantity || Number(product.quantity) <= 0) {
|
||||
$modal.msgWarning(`第${rowNum}行产品的数量不能为空且必须大于0`)
|
||||
const isFwRow = isFrameworkContractType(form.value.contractType)
|
||||
if (isFwRow) {
|
||||
if (product.quantityMode === 'fixed') {
|
||||
if (isBlankNumeric(product.quantity)) {
|
||||
$modal.msgWarning(`第${rowNum}行产品的数量不能为空`)
|
||||
return false
|
||||
}
|
||||
if (isNegativeNumeric(product.quantity)) {
|
||||
$modal.msgWarning(`第${rowNum}行产品的数量不能为负数`)
|
||||
return false
|
||||
}
|
||||
}
|
||||
} else if (isBlankNumeric(product.quantity)) {
|
||||
$modal.msgWarning(`第${rowNum}行产品的数量不能为空`)
|
||||
return false
|
||||
} else if (isNegativeNumeric(product.quantity)) {
|
||||
$modal.msgWarning(`第${rowNum}行产品的数量不能为负数`)
|
||||
return false
|
||||
}
|
||||
if (!product.packageSpec || String(product.packageSpec).trim() === '') {
|
||||
@@ -2717,15 +2810,25 @@ const handleSubmit = async () => {
|
||||
if (!validateProductRowCommon(product, rowNum)) return
|
||||
const isFw = isFrameworkContractType(form.value.contractType)
|
||||
if (!isFw) {
|
||||
if (!product.price || Number(product.price) <= 0) {
|
||||
$modal.msgWarning(`第${rowNum}行产品的含税单价不能为空且必须大于0`)
|
||||
if (isBlankNumeric(product.price)) {
|
||||
$modal.msgWarning(`第${rowNum}行产品的含税单价不能为空`)
|
||||
return
|
||||
}
|
||||
if (!product.subtotal || Number(product.subtotal) <= 0) {
|
||||
$modal.msgWarning(`第${rowNum}行产品的含税总价不能为空且必须大于0`)
|
||||
if (isNegativeNumeric(product.price) || isNegativeNumeric(product.subtotal) || isNegativeNumeric(product.taxAmount)) {
|
||||
$modal.msgWarning(`第${rowNum}行产品的含税单价、含税总价、税费不能为负数`)
|
||||
return
|
||||
}
|
||||
} else {
|
||||
if (product.priceMode === 'fixed') {
|
||||
if (isBlankNumeric(product.price)) {
|
||||
$modal.msgWarning(`第${rowNum}行产品的含税单价不能为空`)
|
||||
return
|
||||
}
|
||||
if (isNegativeNumeric(product.price) || isNegativeNumeric(product.subtotal) || isNegativeNumeric(product.taxAmount)) {
|
||||
$modal.msgWarning(`第${rowNum}行产品的含税单价、含税总价、税费不能为负数`)
|
||||
return
|
||||
}
|
||||
}
|
||||
const tiers = product.priceTiers || []
|
||||
for (let j = 0; j < tiers.length; j++) {
|
||||
const t = tiers[j]
|
||||
@@ -2756,17 +2859,23 @@ const handleSubmit = async () => {
|
||||
const product = form.value.products[i]
|
||||
const rowNum = i + 1
|
||||
if (!validateProductRowCommon(product, rowNum)) return
|
||||
if (!product.price || Number(product.price) <= 0) {
|
||||
$modal.msgWarning(`第${rowNum}行产品的含税单价不能为空且必须大于0`)
|
||||
if (isBlankNumeric(product.price)) {
|
||||
$modal.msgWarning(`第${rowNum}行产品的含税单价不能为空`)
|
||||
return
|
||||
}
|
||||
if (!product.subtotal || Number(product.subtotal) <= 0) {
|
||||
$modal.msgWarning(`第${rowNum}行产品的含税总价不能为空且必须大于0`)
|
||||
if (isNegativeNumeric(product.price) || isNegativeNumeric(product.subtotal) || isNegativeNumeric(product.taxAmount)) {
|
||||
$modal.msgWarning(`第${rowNum}行产品的含税单价、含税总价、税费不能为负数`)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const confirmedZero = await confirmZeroPricingIfNeeded(
|
||||
form.value.products,
|
||||
isFrameworkContractType(form.value.contractType)
|
||||
)
|
||||
if (!confirmedZero) return
|
||||
|
||||
submitLoading.value = true
|
||||
try {
|
||||
rebuildContractName()
|
||||
@@ -3155,23 +3264,43 @@ const loadSupplierList = async () => {
|
||||
border: none !important;
|
||||
}
|
||||
|
||||
/* 框架合同调价函:表格内多图卡片上传 */
|
||||
.tier-letter-upload :deep(.el-upload-list--picture-card) {
|
||||
/* 框架合同产品明细:默认文案 + 可切换填数字 */
|
||||
.framework-pricing-cell {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
gap: 2px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.tier-letter-upload :deep(.el-upload--picture-card) {
|
||||
width: 72px;
|
||||
height: 72px;
|
||||
line-height: 72px;
|
||||
.framework-pricing-cell--money {
|
||||
align-items: flex-end;
|
||||
}
|
||||
|
||||
.tier-letter-upload :deep(.el-upload-list--picture-card .el-upload-list__item) {
|
||||
width: 72px;
|
||||
height: 72px;
|
||||
margin: 0;
|
||||
.framework-pricing-cell__label {
|
||||
font-size: 13px;
|
||||
line-height: 1.4;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.framework-pricing-cell__action {
|
||||
padding: 0 !important;
|
||||
height: auto !important;
|
||||
font-size: 12px !important;
|
||||
}
|
||||
|
||||
/* 框架合同调价函:表格内紧凑附件上传 */
|
||||
.fw-price-tier-table :deep(.attachment-upload--compact:not(.attachment-upload--readonly)) {
|
||||
min-width: 0;
|
||||
|
||||
.attachment-upload {
|
||||
width: auto;
|
||||
}
|
||||
|
||||
.attachment-list {
|
||||
flex-wrap: wrap;
|
||||
align-items: flex-start;
|
||||
}
|
||||
}
|
||||
|
||||
/* 框架合同:增加「调价函」行内按钮可点区域宽度 */
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
<ContractAttachmentPanel
|
||||
v-model="attachmentList"
|
||||
:biz-type="CRM_UPLOAD_BIZ_TYPE.CONTRACT_ATTACHMENT"
|
||||
hint="支持上传图片、PDF、Word文档等,最多10个文件"
|
||||
hint="支持上传图片、PDF、Word文档等,最多10个文件;可拖拽或在此区域粘贴上传"
|
||||
/>
|
||||
|
||||
<template #footer>
|
||||
|
||||
@@ -304,22 +304,35 @@
|
||||
<DictTag dict-type="crm_product_unit" :value="scope.row.unit" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="数量" prop="quantity" width="110" align="right" />
|
||||
<el-table-column label="数量" prop="quantity" width="110" align="right">
|
||||
<template #default="scope">
|
||||
<span v-if="isFrameworkContractType(contract.contractType)" class="text-muted">
|
||||
{{ displayFrameworkQuantity(scope.row, true) }}
|
||||
</span>
|
||||
<span v-else>{{ scope.row.quantity }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="含税单价/元" prop="price" width="130" align="right">
|
||||
<template #default="scope">
|
||||
<span v-if="isFrameworkContractType(contract.contractType)" class="text-muted">随行就市</span>
|
||||
<span v-if="isFrameworkContractType(contract.contractType)" class="text-muted">
|
||||
{{ displayFrameworkMoney(scope.row, 'price', true) }}
|
||||
</span>
|
||||
<template v-else>¥{{ parseFloat(scope.row.price || 0).toFixed(2) }}</template>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="含税总价/元" prop="subtotal" width="130" align="right">
|
||||
<template #default="scope">
|
||||
<span v-if="isFrameworkContractType(contract.contractType)" class="text-muted">随行就市</span>
|
||||
<span v-if="isFrameworkContractType(contract.contractType)" class="text-muted">
|
||||
{{ displayFrameworkMoney(scope.row, 'subtotal', true) }}
|
||||
</span>
|
||||
<span v-else class="text-success font-weight-bold">¥{{ parseFloat(scope.row.subtotal || 0).toFixed(2) }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="税费/元" prop="taxAmount" width="120" align="right">
|
||||
<template #default="scope">
|
||||
<span v-if="isFrameworkContractType(contract.contractType)" class="text-muted">随行就市</span>
|
||||
<span v-if="isFrameworkContractType(contract.contractType)" class="text-muted">
|
||||
{{ displayFrameworkMoney(scope.row, 'taxAmount', true) }}
|
||||
</span>
|
||||
<span v-else>¥{{ parseFloat(scope.row.taxAmount || 0).toFixed(2) }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
@@ -1085,6 +1098,7 @@ import TinyMceEditor from '@/components/TinyMceEditor/index.vue';
|
||||
import { getOpportunity } from '@/api/crm/opportunity';
|
||||
import { getQuote } from '@/api/crm/quote';
|
||||
import { isFrameworkContractType, isContractEditableStatus, getContractReeditConfirmMessage } from './contractType';
|
||||
import { displayFrameworkMoney, displayFrameworkQuantity } from './frameworkProductPricing';
|
||||
import {
|
||||
parseSettlementClauseDrafts,
|
||||
resolveSettlementClauseContent
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,233 @@
|
||||
/** 框架合同产品明细:数量/价格模式常量与工具 */
|
||||
|
||||
import { ElMessageBox } from 'element-plus'
|
||||
|
||||
export const FRAMEWORK_QUANTITY_MODE = {
|
||||
CUSTOMER_DEMAND: 'customer_demand',
|
||||
FIXED: 'fixed'
|
||||
} as const
|
||||
|
||||
export const FRAMEWORK_PRICE_MODE = {
|
||||
MARKET: 'market',
|
||||
FIXED: 'fixed'
|
||||
} as const
|
||||
|
||||
export type FrameworkQuantityMode =
|
||||
(typeof FRAMEWORK_QUANTITY_MODE)[keyof typeof FRAMEWORK_QUANTITY_MODE]
|
||||
export type FrameworkPriceMode =
|
||||
(typeof FRAMEWORK_PRICE_MODE)[keyof typeof FRAMEWORK_PRICE_MODE]
|
||||
|
||||
export const FRAMEWORK_QUANTITY_LABEL = '按客户需求'
|
||||
export const FRAMEWORK_PRICE_LABEL = '随行就市'
|
||||
|
||||
export type FrameworkPricingProduct = {
|
||||
quantity?: number | string | null
|
||||
quantityMode?: FrameworkQuantityMode | string | null
|
||||
quantity_mode?: FrameworkQuantityMode | string | null
|
||||
price?: number | string | null
|
||||
subtotal?: number | string | null
|
||||
taxAmount?: number | string | null
|
||||
priceMode?: FrameworkPriceMode | string | null
|
||||
price_mode?: FrameworkPriceMode | string | null
|
||||
}
|
||||
|
||||
export function createFrameworkProductPricingDefaults() {
|
||||
return {
|
||||
quantity: 0,
|
||||
quantityMode: FRAMEWORK_QUANTITY_MODE.CUSTOMER_DEMAND,
|
||||
price: 0,
|
||||
subtotal: 0,
|
||||
taxAmount: 0,
|
||||
priceMode: FRAMEWORK_PRICE_MODE.MARKET
|
||||
}
|
||||
}
|
||||
|
||||
export function normalizeFrameworkProductPricing(product: FrameworkPricingProduct, isFramework: boolean) {
|
||||
if (!isFramework) {
|
||||
product.quantityMode = FRAMEWORK_QUANTITY_MODE.FIXED
|
||||
product.priceMode = FRAMEWORK_PRICE_MODE.FIXED
|
||||
return product
|
||||
}
|
||||
|
||||
const rawQuantityMode = product.quantityMode || product.quantity_mode
|
||||
const rawPriceMode = product.priceMode || product.price_mode
|
||||
|
||||
product.quantityMode =
|
||||
rawQuantityMode === FRAMEWORK_QUANTITY_MODE.FIXED
|
||||
? FRAMEWORK_QUANTITY_MODE.FIXED
|
||||
: rawQuantityMode === FRAMEWORK_QUANTITY_MODE.CUSTOMER_DEMAND
|
||||
? FRAMEWORK_QUANTITY_MODE.CUSTOMER_DEMAND
|
||||
: Number(product.quantity) > 0
|
||||
? FRAMEWORK_QUANTITY_MODE.FIXED
|
||||
: FRAMEWORK_QUANTITY_MODE.CUSTOMER_DEMAND
|
||||
|
||||
product.priceMode =
|
||||
rawPriceMode === FRAMEWORK_PRICE_MODE.FIXED
|
||||
? FRAMEWORK_PRICE_MODE.FIXED
|
||||
: rawPriceMode === FRAMEWORK_PRICE_MODE.MARKET
|
||||
? FRAMEWORK_PRICE_MODE.MARKET
|
||||
: Number(product.price) > 0 || Number(product.subtotal) > 0
|
||||
? FRAMEWORK_PRICE_MODE.FIXED
|
||||
: FRAMEWORK_PRICE_MODE.MARKET
|
||||
|
||||
if (product.quantityMode === FRAMEWORK_QUANTITY_MODE.CUSTOMER_DEMAND) {
|
||||
product.quantity = 0
|
||||
}
|
||||
if (product.priceMode === FRAMEWORK_PRICE_MODE.MARKET) {
|
||||
product.price = 0
|
||||
product.subtotal = 0
|
||||
product.taxAmount = 0
|
||||
}
|
||||
return product
|
||||
}
|
||||
|
||||
export function applyFrameworkDefaultsToProduct(product: FrameworkPricingProduct) {
|
||||
Object.assign(product, createFrameworkProductPricingDefaults())
|
||||
return product
|
||||
}
|
||||
|
||||
export function isBlankNumeric(value: unknown) {
|
||||
return value === null || value === undefined || value === ''
|
||||
}
|
||||
|
||||
export function isFilledZero(value: unknown) {
|
||||
if (isBlankNumeric(value)) return false
|
||||
return Number(value) === 0
|
||||
}
|
||||
|
||||
export function isNegativeNumeric(value: unknown) {
|
||||
if (isBlankNumeric(value)) return false
|
||||
return Number(value) < 0
|
||||
}
|
||||
|
||||
export function enableFrameworkQuantityFixed(product: FrameworkPricingProduct) {
|
||||
product.quantityMode = FRAMEWORK_QUANTITY_MODE.FIXED
|
||||
if (isBlankNumeric(product.quantity)) {
|
||||
product.quantity = 0
|
||||
}
|
||||
}
|
||||
|
||||
export function resetFrameworkQuantityToCustomerDemand(product: FrameworkPricingProduct) {
|
||||
product.quantityMode = FRAMEWORK_QUANTITY_MODE.CUSTOMER_DEMAND
|
||||
product.quantity = 0
|
||||
}
|
||||
|
||||
export function enableFrameworkPriceFixed(product: FrameworkPricingProduct) {
|
||||
product.priceMode = FRAMEWORK_PRICE_MODE.FIXED
|
||||
if (!product.price || Number(product.price) <= 0) {
|
||||
product.price = 0
|
||||
}
|
||||
}
|
||||
|
||||
export function resetFrameworkPriceToMarket(product: FrameworkPricingProduct) {
|
||||
product.priceMode = FRAMEWORK_PRICE_MODE.MARKET
|
||||
product.price = 0
|
||||
product.subtotal = 0
|
||||
product.taxAmount = 0
|
||||
}
|
||||
|
||||
export function isFrameworkQuantityCustomerDemand(product: FrameworkPricingProduct) {
|
||||
return product.quantityMode === FRAMEWORK_QUANTITY_MODE.CUSTOMER_DEMAND
|
||||
}
|
||||
|
||||
export function isFrameworkPriceMarket(product: FrameworkPricingProduct) {
|
||||
return product.priceMode === FRAMEWORK_PRICE_MODE.MARKET
|
||||
}
|
||||
|
||||
export function formatFrameworkQuantityDisplay(product: FrameworkPricingProduct) {
|
||||
if (isFrameworkQuantityCustomerDemand(product)) {
|
||||
return FRAMEWORK_QUANTITY_LABEL
|
||||
}
|
||||
const qty = Number(product.quantity)
|
||||
if (Number.isNaN(qty)) return '-'
|
||||
return String(qty)
|
||||
}
|
||||
|
||||
export function formatFrameworkMoneyDisplay(product: FrameworkPricingProduct, field: 'price' | 'subtotal' | 'taxAmount') {
|
||||
if (isFrameworkPriceMarket(product)) {
|
||||
return FRAMEWORK_PRICE_LABEL
|
||||
}
|
||||
const val = Number(product[field] ?? 0)
|
||||
if (Number.isNaN(val)) return '-'
|
||||
return `¥${val.toFixed(2)}`
|
||||
}
|
||||
|
||||
export function displayFrameworkQuantity(product: FrameworkPricingProduct, isFramework: boolean) {
|
||||
if (!isFramework) {
|
||||
const qty = Number(product.quantity)
|
||||
return Number.isNaN(qty) ? '-' : String(qty)
|
||||
}
|
||||
return formatFrameworkQuantityDisplay(normalizeFrameworkProductPricing({ ...product }, true))
|
||||
}
|
||||
|
||||
export function displayFrameworkMoney(
|
||||
product: FrameworkPricingProduct,
|
||||
field: 'price' | 'subtotal' | 'taxAmount',
|
||||
isFramework: boolean
|
||||
) {
|
||||
if (!isFramework) {
|
||||
const val = Number(product[field] ?? 0)
|
||||
return Number.isNaN(val) ? '-' : `¥${val.toFixed(2)}`
|
||||
}
|
||||
return formatFrameworkMoneyDisplay(normalizeFrameworkProductPricing({ ...product }, true), field)
|
||||
}
|
||||
|
||||
export function prepareFrameworkProductForSubmit(product: FrameworkPricingProduct) {
|
||||
const quantityMode = product.quantityMode || FRAMEWORK_QUANTITY_MODE.CUSTOMER_DEMAND
|
||||
const priceMode = product.priceMode || FRAMEWORK_PRICE_MODE.MARKET
|
||||
return {
|
||||
quantityMode,
|
||||
priceMode,
|
||||
quantity: quantityMode === FRAMEWORK_QUANTITY_MODE.CUSTOMER_DEMAND ? 0 : product.quantity,
|
||||
price: priceMode === FRAMEWORK_PRICE_MODE.MARKET ? 0 : product.price,
|
||||
subtotal: priceMode === FRAMEWORK_PRICE_MODE.MARKET ? 0 : product.subtotal,
|
||||
taxAmount: priceMode === FRAMEWORK_PRICE_MODE.MARKET ? 0 : product.taxAmount
|
||||
}
|
||||
}
|
||||
|
||||
type ZeroPricingProduct = FrameworkPricingProduct & {
|
||||
productName?: string | null
|
||||
}
|
||||
|
||||
/** 收集用户填写为 0 的数量/价格字段(不含「按客户需求」「随行就市」) */
|
||||
export function collectZeroPricingReminders(products: ZeroPricingProduct[] | undefined, isFramework: boolean) {
|
||||
const lines: string[] = []
|
||||
;(products || []).forEach((product, index) => {
|
||||
const fields: string[] = []
|
||||
const quantityIsNumeric = !isFramework || product.quantityMode === FRAMEWORK_QUANTITY_MODE.FIXED
|
||||
const priceIsNumeric = !isFramework || product.priceMode === FRAMEWORK_PRICE_MODE.FIXED
|
||||
if (quantityIsNumeric && isFilledZero(product.quantity)) {
|
||||
fields.push('数量')
|
||||
}
|
||||
if (priceIsNumeric) {
|
||||
if (isFilledZero(product.price)) fields.push('含税单价')
|
||||
if (isFilledZero(product.subtotal)) fields.push('含税总价')
|
||||
if (isFilledZero(product.taxAmount)) fields.push('税费')
|
||||
}
|
||||
if (fields.length) {
|
||||
const name = String(product.productName || '').trim() || '未命名产品'
|
||||
lines.push(`第${index + 1}行「${name}」:${fields.join('、')}为 0`)
|
||||
}
|
||||
})
|
||||
return lines
|
||||
}
|
||||
|
||||
export async function confirmZeroPricingIfNeeded(products: ZeroPricingProduct[] | undefined, isFramework: boolean) {
|
||||
const lines = collectZeroPricingReminders(products, isFramework)
|
||||
if (!lines.length) return true
|
||||
try {
|
||||
await ElMessageBox.confirm(
|
||||
`以下产品明细填写了 <strong>0</strong>,请确认后继续:<br/><br/>${lines.map((line) => `· ${line}`).join('<br/>')}`,
|
||||
'零值提醒',
|
||||
{
|
||||
type: 'warning',
|
||||
dangerouslyUseHTMLString: true,
|
||||
confirmButtonText: '确定保存',
|
||||
cancelButtonText: '返回修改'
|
||||
}
|
||||
)
|
||||
return true
|
||||
} catch {
|
||||
return false
|
||||
}
|
||||
}
|
||||
@@ -273,27 +273,13 @@
|
||||
</div>
|
||||
</el-form-item>
|
||||
<el-form-item label="分类图片" class="flex-1">
|
||||
<div class="category-image-row">
|
||||
<el-image
|
||||
v-if="formData.imageUrl"
|
||||
:src="formData.imageUrl"
|
||||
fit="cover"
|
||||
style="width: 80px; height: 80px; border-radius: 8px"
|
||||
/>
|
||||
<div v-else class="category-image-placeholder">暂无</div>
|
||||
|
||||
<el-upload
|
||||
ref="categoryImageUploadRef"
|
||||
accept="image/*"
|
||||
:show-file-list="false"
|
||||
:auto-upload="false"
|
||||
:limit="1"
|
||||
:on-change="handleCategoryImageChange"
|
||||
:on-exceed="handleCategoryImageExceed"
|
||||
>
|
||||
<el-button type="primary" plain>上传图片</el-button>
|
||||
</el-upload>
|
||||
</div>
|
||||
<AttachmentUploadField
|
||||
v-model="formData.imageUrl"
|
||||
accept="image/*"
|
||||
:limit="1"
|
||||
folder="categories"
|
||||
hint="支持图片;可拖拽或在此区域粘贴上传"
|
||||
/>
|
||||
</el-form-item>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
@@ -525,6 +511,7 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import ListToolbarEndActions from '@/components/business/list-toolbar-end-actions/index.vue'
|
||||
import AttachmentUploadField from '@/components/business/attachment-upload-field/index.vue'
|
||||
import { useListMediaActive } from '@/composables/useListMediaActive'
|
||||
/* eslint-disable vue/no-v-model-argument */
|
||||
import { ref, reactive, onMounted, nextTick, watch, computed } from 'vue'
|
||||
@@ -543,14 +530,12 @@ import ListToolbarEndActions from '@/components/business/list-toolbar-end-action
|
||||
Delete
|
||||
} from '@element-plus/icons-vue'
|
||||
import { VueDraggable as draggable } from 'vue-draggable-plus'
|
||||
import type { UploadFile } from 'element-plus'
|
||||
import SystemViewDialog from '@/components/business/system-view-dialog/index.vue'
|
||||
import {
|
||||
fetchCategoryList,
|
||||
fetchCreateCategory,
|
||||
fetchUpdateCategory,
|
||||
fetchDeleteCategory,
|
||||
fetchUploadCategoryImage,
|
||||
fetchProductParameterSimple,
|
||||
fetchCategoryParameters,
|
||||
fetchUpdateCategoryParameters
|
||||
@@ -830,7 +815,6 @@ import ListToolbarEndActions from '@/components/business/list-toolbar-end-action
|
||||
const isEdit = ref(false)
|
||||
const submitLoading = ref(false)
|
||||
const formRef = ref()
|
||||
const categoryImageUploadRef = ref<{ clearFiles: () => void } | null>(null)
|
||||
|
||||
const formData = reactive({
|
||||
id: '',
|
||||
@@ -929,40 +913,6 @@ import ListToolbarEndActions from '@/components/business/list-toolbar-end-action
|
||||
}
|
||||
}
|
||||
|
||||
const uploadCategoryImageFile = async (file: File) => {
|
||||
try {
|
||||
ElMessage.info('图片正在上传...')
|
||||
const fd = new FormData()
|
||||
fd.append('folder', 'categories')
|
||||
fd.append('file', file)
|
||||
|
||||
const res: any = await fetchUploadCategoryImage(fd)
|
||||
formData.imageUrl = res?.url || ''
|
||||
ElMessage.success('图片上传成功')
|
||||
} catch (e) {
|
||||
console.error('分类图片上传失败:', e)
|
||||
ElMessage.error('图片上传失败')
|
||||
} finally {
|
||||
categoryImageUploadRef.value?.clearFiles()
|
||||
}
|
||||
}
|
||||
|
||||
// 上传分类图片(limit=1 时第二次选文件会走 on-exceed,不会进 on-change)
|
||||
const handleCategoryImageChange = async (uploadFile: UploadFile) => {
|
||||
const file: any = (uploadFile as any).raw
|
||||
if (!file) return
|
||||
|
||||
const status = (uploadFile as any).status
|
||||
if (status && status !== 'ready') return
|
||||
|
||||
await uploadCategoryImageFile(file)
|
||||
}
|
||||
|
||||
const handleCategoryImageExceed = (files: File[]) => {
|
||||
const file = files[0]
|
||||
if (file) uploadCategoryImageFile(file)
|
||||
}
|
||||
|
||||
const loadData = async () => {
|
||||
selectedRows.value = []
|
||||
loading.value = true
|
||||
|
||||
@@ -1371,16 +1371,13 @@
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="佐证图片">
|
||||
<el-upload
|
||||
action="#"
|
||||
list-type="picture-card"
|
||||
:auto-upload="false"
|
||||
:on-change="handleCancelEvidenceChange"
|
||||
:on-remove="handleCancelEvidenceRemove"
|
||||
<AttachmentUploadField
|
||||
v-model="cancelEvidenceCsv"
|
||||
accept="image/*"
|
||||
:limit="6"
|
||||
>
|
||||
<el-icon><Plus /></el-icon>
|
||||
</el-upload>
|
||||
folder="demo/order-cancel"
|
||||
hint="支持图片;可拖拽或在此区域粘贴上传,最多6张"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
@@ -1706,6 +1703,7 @@
|
||||
WarningFilled
|
||||
} from '@element-plus/icons-vue'
|
||||
import ProductViewDialog from '@/components/business/product-view-dialog/index.vue'
|
||||
import AttachmentUploadField from '@/components/business/attachment-upload-field/index.vue'
|
||||
import {
|
||||
fetchOrderList,
|
||||
fetchOrderDetail,
|
||||
@@ -1714,7 +1712,6 @@
|
||||
fetchCancelOrder,
|
||||
fetchOrderItems,
|
||||
fetchAdjustOrder,
|
||||
fetchUploadAttachment,
|
||||
fetchOrderAdjusts,
|
||||
fetchPriceVersionDetail,
|
||||
fetchSystemConfig,
|
||||
@@ -1958,6 +1955,15 @@
|
||||
evidenceImageUrls: [] as string[]
|
||||
})
|
||||
const cancelDialogLoading = ref(false)
|
||||
const cancelEvidenceCsv = computed({
|
||||
get: () => (cancelDialogForm.evidenceImageUrls || []).join(','),
|
||||
set: (val: string) => {
|
||||
cancelDialogForm.evidenceImageUrls = String(val || '')
|
||||
.split(',')
|
||||
.map((item) => item.trim())
|
||||
.filter(Boolean)
|
||||
}
|
||||
})
|
||||
const cancelDialogRules = {
|
||||
reason: [{ required: true, message: '请输入取消原因', trigger: 'blur' }]
|
||||
}
|
||||
@@ -2642,22 +2648,6 @@
|
||||
cancelDialogVisible.value = true
|
||||
}
|
||||
|
||||
const handleCancelEvidenceChange = async (uploadFile: any) => {
|
||||
const file = uploadFile?.raw
|
||||
if (!file) return
|
||||
const fd = new FormData()
|
||||
fd.append('business_type', 'order')
|
||||
fd.append('business_id', cancelDialogForm.orderId)
|
||||
fd.append('file', file)
|
||||
const res: any = await fetchUploadAttachment(fd)
|
||||
if (res?.fileUrl) cancelDialogForm.evidenceImageUrls.push(res.fileUrl)
|
||||
}
|
||||
|
||||
const handleCancelEvidenceRemove = (_file: any, fileList: any[]) => {
|
||||
const urls = fileList.map((f: any) => f?.response?.fileUrl || f?.url).filter(Boolean)
|
||||
cancelDialogForm.evidenceImageUrls = urls
|
||||
}
|
||||
|
||||
const confirmCancelOrder = async () => {
|
||||
if (!cancelDialogForm.reason) {
|
||||
ElMessage.warning('请输入取消原因')
|
||||
|
||||
@@ -347,51 +347,13 @@
|
||||
<el-row :gutter="20">
|
||||
<el-col :span="12">
|
||||
<el-form-item label="商品图片">
|
||||
<div class="image-upload-row">
|
||||
<div class="main-image-card">
|
||||
<template v-if="mainImageUploading">
|
||||
<div class="banner-media-loading main-image-as-banner">
|
||||
<el-image
|
||||
v-if="mainImageLocalPreview"
|
||||
:src="mainImageLocalPreview"
|
||||
fit="cover"
|
||||
class="banner-image banner-image--behind"
|
||||
/>
|
||||
<div v-else class="banner-media-placeholder main-image-ph" />
|
||||
<div class="banner-loading-mask">
|
||||
<el-icon class="banner-loading-icon is-loading"><Loading /></el-icon>
|
||||
<span class="banner-loading-text">上传中…</span>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<template v-else>
|
||||
<div class="main-image-as-banner main-image-done">
|
||||
<el-image
|
||||
v-if="formData.imageUrl"
|
||||
:src="formData.imageUrl"
|
||||
fit="cover"
|
||||
class="banner-image main-image-done-img"
|
||||
:preview-src-list="[formData.imageUrl]"
|
||||
:z-index="3000"
|
||||
/>
|
||||
<div v-else class="image-placeholder image-placeholder--banner">暂无</div>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
<el-upload
|
||||
ref="mainImageUploadRef"
|
||||
accept="image/*"
|
||||
:show-file-list="false"
|
||||
:auto-upload="false"
|
||||
:limit="1"
|
||||
:disabled="mainImageUploading"
|
||||
:on-change="handleMainImageChange"
|
||||
>
|
||||
<el-button type="primary" plain :disabled="mainImageUploading"
|
||||
>上传图片</el-button
|
||||
>
|
||||
</el-upload>
|
||||
</div>
|
||||
<AttachmentUploadField
|
||||
v-model="formData.imageUrl"
|
||||
accept="image/*"
|
||||
:limit="1"
|
||||
folder="products"
|
||||
hint="支持图片;可拖拽或在此区域粘贴上传"
|
||||
/>
|
||||
<div class="media-spec-hint">
|
||||
尺寸要求:请上传 1:1 正方形主图(推荐 800×800 至 2000×2000
|
||||
像素,JPG/PNG/WebP);小程序商品卡片会按固定方图展示,非 1:1
|
||||
@@ -437,7 +399,20 @@
|
||||
750×562);小程序端详情页顶部轮播区域按 4:3 展示,非 4:3
|
||||
图片会以「居中裁切填充」方式展示。
|
||||
</p>
|
||||
<div class="banner-upload-section">
|
||||
<div
|
||||
ref="bannerDropRef"
|
||||
class="banner-upload-section"
|
||||
:class="{ 'media-drop-zone--over': bannerDragOver }"
|
||||
tabindex="0"
|
||||
@mouseenter="bannerPointerInside = true"
|
||||
@mouseleave="bannerPointerInside = false"
|
||||
@focusin="bannerPointerInside = true"
|
||||
@focusout="onBannerFocusOut"
|
||||
@dragenter="onBannerDragEnter"
|
||||
@dragleave="onBannerDragLeave"
|
||||
@dragover="onBannerDragOver"
|
||||
@drop="onBannerDrop"
|
||||
>
|
||||
<div v-if="bannerList.length > 0" class="banner-list">
|
||||
<draggable
|
||||
v-model="bannerList"
|
||||
@@ -522,8 +497,9 @@
|
||||
<div class="banner-add-btn">
|
||||
<el-button type="primary" plain @click="handleAddBanner">
|
||||
<el-icon><Plus /></el-icon>
|
||||
添加图片/视频
|
||||
{{ bannerDragOver ? '松开上传' : '添加图片/视频' }}
|
||||
</el-button>
|
||||
<span class="media-drop-hint">可拖拽文件到此区域,或聚焦后粘贴上传</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -556,7 +532,20 @@
|
||||
750px,小程序端以「宽度自适应高度(widthFix)」方式展示,不强制比例;建议保证主体内容居中,避免边缘关键信息被不同机型裁切/遮挡。视频建议
|
||||
720p 内并尽量缩短时长以利加载;图片单张不超过 10MB,视频单文件不超过 100MB。
|
||||
</p>
|
||||
<div class="banner-upload-section">
|
||||
<div
|
||||
ref="detailDropRef"
|
||||
class="banner-upload-section"
|
||||
:class="{ 'media-drop-zone--over': detailDragOver }"
|
||||
tabindex="0"
|
||||
@mouseenter="detailPointerInside = true"
|
||||
@mouseleave="detailPointerInside = false"
|
||||
@focusin="detailPointerInside = true"
|
||||
@focusout="onDetailFocusOut"
|
||||
@dragenter="onDetailDragEnter"
|
||||
@dragleave="onDetailDragLeave"
|
||||
@dragover="onDetailDragOver"
|
||||
@drop="onDetailDrop"
|
||||
>
|
||||
<div v-if="detailMediaList.length > 0" class="banner-list">
|
||||
<draggable
|
||||
v-model="detailMediaList"
|
||||
@@ -641,8 +630,9 @@
|
||||
<div class="banner-add-btn">
|
||||
<el-button type="primary" plain @click="handleAddDetailMedia">
|
||||
<el-icon><Plus /></el-icon>
|
||||
添加图片/视频
|
||||
{{ detailDragOver ? '松开上传' : '添加图片/视频' }}
|
||||
</el-button>
|
||||
<span class="media-drop-hint">可拖拽文件到此区域,或聚焦后粘贴上传</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -906,7 +896,7 @@
|
||||
<script setup lang="ts">
|
||||
import ListToolbarEndActions from '@/components/business/list-toolbar-end-actions/index.vue'
|
||||
import { useListMediaActive } from '@/composables/useListMediaActive'
|
||||
import { ref, reactive, onMounted, computed, watch, nextTick } from 'vue'
|
||||
import { ref, reactive, onMounted, onBeforeUnmount, computed, watch, nextTick } from 'vue'
|
||||
import {
|
||||
ElMessage,
|
||||
ElMessageBox,
|
||||
@@ -935,6 +925,7 @@ import ListToolbarEndActions from '@/components/business/list-toolbar-end-action
|
||||
} from '@element-plus/icons-vue'
|
||||
import { VueDraggable as draggable } from 'vue-draggable-plus'
|
||||
import ProductViewDialog from '@/components/business/product-view-dialog/index.vue'
|
||||
import AttachmentUploadField from '@/components/business/attachment-upload-field/index.vue'
|
||||
import {
|
||||
fetchProductList,
|
||||
fetchProductDetail,
|
||||
@@ -1310,10 +1301,6 @@ import ListToolbarEndActions from '@/components/business/list-toolbar-end-action
|
||||
m.sortOrder = i
|
||||
})
|
||||
}
|
||||
const mainImageUploadRef = ref<{ clearFiles: () => void } | null>(null)
|
||||
const mainImageUploading = ref(false)
|
||||
const mainImageLocalPreview = ref('')
|
||||
|
||||
/** 上传接口返回的 data 可能为 { url } 或字段别名,与列表项引用无关时也必须能解析到地址 */
|
||||
const pickProductUploadUrl = (res: any): string => {
|
||||
if (res == null) return ''
|
||||
@@ -1322,17 +1309,6 @@ import ListToolbarEndActions from '@/components/business/list-toolbar-end-action
|
||||
return typeof u === 'string' && u ? u : ''
|
||||
}
|
||||
|
||||
const revokeMainImageLocalPreview = () => {
|
||||
if (mainImageLocalPreview.value) {
|
||||
try {
|
||||
URL.revokeObjectURL(mainImageLocalPreview.value)
|
||||
} catch {
|
||||
/* ignore */
|
||||
}
|
||||
mainImageLocalPreview.value = ''
|
||||
}
|
||||
}
|
||||
|
||||
const revokeLocalPreview = (item: any) => {
|
||||
if (item?._localPreview) {
|
||||
try {
|
||||
@@ -1769,10 +1745,6 @@ import ListToolbarEndActions from '@/components/business/list-toolbar-end-action
|
||||
// 提交
|
||||
const handleSubmit = async () => {
|
||||
if (!basicFormRef.value) return
|
||||
if (mainImageUploading.value) {
|
||||
ElMessage.warning('商品图片正在上传,请稍候再保存')
|
||||
return
|
||||
}
|
||||
if (bannerList.value.some((b) => b._uploading)) {
|
||||
ElMessage.warning('轮播图正在上传,请稍候再保存')
|
||||
return
|
||||
@@ -1952,8 +1924,6 @@ import ListToolbarEndActions from '@/components/business/list-toolbar-end-action
|
||||
lastAutoCategoryId.value = ''
|
||||
revokeListLocalPreviews(bannerList.value)
|
||||
revokeListLocalPreviews(detailMediaList.value)
|
||||
mainImageUploading.value = false
|
||||
revokeMainImageLocalPreview()
|
||||
bannerList.value = []
|
||||
detailMediaList.value = []
|
||||
categoryParameters.value = []
|
||||
@@ -1961,7 +1931,6 @@ import ListToolbarEndActions from '@/components/business/list-toolbar-end-action
|
||||
// 勿用 resetFields():会把表单项恢复为「首次挂载」时的初始值,若先编辑过其它商品,新增时会回填旧名称等
|
||||
nextTick(() => {
|
||||
basicFormRef.value?.clearValidate()
|
||||
mainImageUploadRef.value?.clearFiles()
|
||||
})
|
||||
}
|
||||
|
||||
@@ -2159,40 +2128,6 @@ import ListToolbarEndActions from '@/components/business/list-toolbar-end-action
|
||||
}
|
||||
}
|
||||
|
||||
// 主图上传(limit=1 时内部会保留已选文件,再次选择会走 on-exceed 而非 on-change,需在每次处理后 clearFiles)
|
||||
const handleMainImageChange = async (uploadFile: UploadFile) => {
|
||||
const file: any = (uploadFile as any).raw
|
||||
if (!file) return
|
||||
|
||||
const status = (uploadFile as any).status
|
||||
if (status && status !== 'ready') return
|
||||
|
||||
mainImageUploading.value = true
|
||||
revokeMainImageLocalPreview()
|
||||
mainImageLocalPreview.value = URL.createObjectURL(file)
|
||||
try {
|
||||
const fd = new FormData()
|
||||
fd.append('folder', 'products')
|
||||
fd.append('file', file)
|
||||
|
||||
const res: any = await fetchUploadProductImage(fd)
|
||||
const url = pickProductUploadUrl(res)
|
||||
if (url) {
|
||||
formData.imageUrl = url
|
||||
ElMessage.success('图片上传成功')
|
||||
} else {
|
||||
ElMessage.error('上传成功但未返回图片地址')
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('图片上传失败:', e)
|
||||
ElMessage.error('图片上传失败')
|
||||
} finally {
|
||||
mainImageUploading.value = false
|
||||
revokeMainImageLocalPreview()
|
||||
nextTick(() => mainImageUploadRef.value?.clearFiles())
|
||||
}
|
||||
}
|
||||
|
||||
// 添加轮播图
|
||||
const handleAddBanner = () => {
|
||||
// 获取 el-upload 内部的 input 元素并触发点击
|
||||
@@ -2251,7 +2186,12 @@ import ListToolbarEndActions from '@/components/business/list-toolbar-end-action
|
||||
|
||||
const status = (uploadFile as any).status
|
||||
if (status && status !== 'ready') return
|
||||
await uploadBannerRawFile(file)
|
||||
await nextTick()
|
||||
bannerUploadRef.value?.clearFiles?.()
|
||||
}
|
||||
|
||||
const uploadBannerRawFile = async (file: File) => {
|
||||
// 判断文件类型
|
||||
const isVideo = file.type.startsWith('video/')
|
||||
|
||||
@@ -2345,7 +2285,12 @@ import ListToolbarEndActions from '@/components/business/list-toolbar-end-action
|
||||
|
||||
const status = (uploadFile as any).status
|
||||
if (status && status !== 'ready') return
|
||||
await uploadDetailMediaRawFile(file)
|
||||
await nextTick()
|
||||
detailMediaUploadRef.value?.clearFiles?.()
|
||||
}
|
||||
|
||||
const uploadDetailMediaRawFile = async (file: File) => {
|
||||
const isVideo = file.type.startsWith('video/')
|
||||
|
||||
const allowedImageTypes = [
|
||||
@@ -2478,14 +2423,164 @@ import ListToolbarEndActions from '@/components/business/list-toolbar-end-action
|
||||
{ debounce: 300, deep: true }
|
||||
)
|
||||
|
||||
|
||||
// 轮播图 / 详情媒体:拖拽与粘贴上传
|
||||
const bannerDropRef = ref<HTMLElement>()
|
||||
const detailDropRef = ref<HTMLElement>()
|
||||
const bannerPointerInside = ref(false)
|
||||
const detailPointerInside = ref(false)
|
||||
const bannerDragOver = ref(false)
|
||||
const detailDragOver = ref(false)
|
||||
let bannerDragDepth = 0
|
||||
let detailDragDepth = 0
|
||||
|
||||
const normalizeIncomingFile = (file: File, index = 0) => {
|
||||
if (file.name && file.name.trim()) return file
|
||||
const ext = (file.type || '').split('/')[1] || 'bin'
|
||||
return new File([file], `paste-${Date.now()}-${index}.${ext}`, {
|
||||
type: file.type || 'application/octet-stream'
|
||||
})
|
||||
}
|
||||
|
||||
const collectClipboardFiles = (event: ClipboardEvent) => {
|
||||
const files: File[] = []
|
||||
const items = event.clipboardData?.items
|
||||
if (items?.length) {
|
||||
Array.from(items).forEach((item, index) => {
|
||||
if (item.kind !== 'file') return
|
||||
const file = item.getAsFile()
|
||||
if (file) files.push(normalizeIncomingFile(file, index))
|
||||
})
|
||||
}
|
||||
if (!files.length && event.clipboardData?.files?.length) {
|
||||
Array.from(event.clipboardData.files).forEach((file, index) => {
|
||||
files.push(normalizeIncomingFile(file, index))
|
||||
})
|
||||
}
|
||||
return files
|
||||
}
|
||||
|
||||
const onBannerFocusOut = (event: FocusEvent) => {
|
||||
const next = event.relatedTarget as Node | null
|
||||
if (next && bannerDropRef.value?.contains(next)) return
|
||||
bannerPointerInside.value = false
|
||||
}
|
||||
const onDetailFocusOut = (event: FocusEvent) => {
|
||||
const next = event.relatedTarget as Node | null
|
||||
if (next && detailDropRef.value?.contains(next)) return
|
||||
detailPointerInside.value = false
|
||||
}
|
||||
|
||||
const onBannerDragEnter = (event: DragEvent) => {
|
||||
event.preventDefault()
|
||||
bannerDragDepth += 1
|
||||
bannerDragOver.value = true
|
||||
bannerPointerInside.value = true
|
||||
}
|
||||
const onBannerDragLeave = (event: DragEvent) => {
|
||||
event.preventDefault()
|
||||
bannerDragDepth = Math.max(0, bannerDragDepth - 1)
|
||||
if (bannerDragDepth === 0) bannerDragOver.value = false
|
||||
}
|
||||
const onBannerDragOver = (event: DragEvent) => {
|
||||
event.preventDefault()
|
||||
if (event.dataTransfer) event.dataTransfer.dropEffect = 'copy'
|
||||
}
|
||||
const onBannerDrop = async (event: DragEvent) => {
|
||||
event.preventDefault()
|
||||
bannerDragDepth = 0
|
||||
bannerDragOver.value = false
|
||||
const files = Array.from(event.dataTransfer?.files || [])
|
||||
for (const file of files) {
|
||||
if (bannerList.value.length >= 9) {
|
||||
ElMessage.warning('最多上传9张轮播图')
|
||||
break
|
||||
}
|
||||
await uploadBannerRawFile(file)
|
||||
}
|
||||
}
|
||||
|
||||
const onDetailDragEnter = (event: DragEvent) => {
|
||||
event.preventDefault()
|
||||
detailDragDepth += 1
|
||||
detailDragOver.value = true
|
||||
detailPointerInside.value = true
|
||||
}
|
||||
const onDetailDragLeave = (event: DragEvent) => {
|
||||
event.preventDefault()
|
||||
detailDragDepth = Math.max(0, detailDragDepth - 1)
|
||||
if (detailDragDepth === 0) detailDragOver.value = false
|
||||
}
|
||||
const onDetailDragOver = (event: DragEvent) => {
|
||||
event.preventDefault()
|
||||
if (event.dataTransfer) event.dataTransfer.dropEffect = 'copy'
|
||||
}
|
||||
const onDetailDrop = async (event: DragEvent) => {
|
||||
event.preventDefault()
|
||||
detailDragDepth = 0
|
||||
detailDragOver.value = false
|
||||
const files = Array.from(event.dataTransfer?.files || [])
|
||||
for (const file of files) {
|
||||
await uploadDetailMediaRawFile(file)
|
||||
}
|
||||
}
|
||||
|
||||
const handleProductMediaPaste = async (event: ClipboardEvent) => {
|
||||
const files = collectClipboardFiles(event)
|
||||
if (!files.length) return
|
||||
if (bannerPointerInside.value) {
|
||||
event.preventDefault()
|
||||
event.stopPropagation()
|
||||
for (const file of files) {
|
||||
if (bannerList.value.length >= 9) {
|
||||
ElMessage.warning('最多上传9张轮播图')
|
||||
break
|
||||
}
|
||||
await uploadBannerRawFile(file)
|
||||
}
|
||||
return
|
||||
}
|
||||
if (detailPointerInside.value) {
|
||||
event.preventDefault()
|
||||
event.stopPropagation()
|
||||
for (const file of files) {
|
||||
await uploadDetailMediaRawFile(file)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
document.addEventListener('paste', handleProductMediaPaste, true)
|
||||
loadData()
|
||||
loadCategories()
|
||||
loadUnits()
|
||||
})
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
document.removeEventListener('paste', handleProductMediaPaste, true)
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
||||
.media-drop-hint {
|
||||
margin-left: 12px;
|
||||
font-size: 12px;
|
||||
color: #64748b;
|
||||
}
|
||||
|
||||
.banner-upload-section {
|
||||
outline: none;
|
||||
border-radius: 8px;
|
||||
|
||||
&.media-drop-zone--over {
|
||||
background: rgba(16, 185, 129, 0.06);
|
||||
outline: 2px dashed #1ca851;
|
||||
outline-offset: 4px;
|
||||
padding: 8px;
|
||||
}
|
||||
}
|
||||
|
||||
.search-form {
|
||||
:deep(.el-form-item) {
|
||||
margin-bottom: 0;
|
||||
|
||||
@@ -43,15 +43,15 @@
|
||||
@search="handleQuickSearch"
|
||||
@clear="handleQuickSearchClear"
|
||||
/>
|
||||
<el-button class="btn-main" type="primary" @click="handleAdd">
|
||||
<el-icon><Plus /></el-icon>新增人员
|
||||
</el-button>
|
||||
<el-button
|
||||
v-if="isCarrierPersonnel"
|
||||
class="btn-ghost"
|
||||
@click="pasteVisible = true"
|
||||
>
|
||||
<el-icon><DocumentCopy /></el-icon>粘贴识别
|
||||
<el-icon><DocumentCopy /></el-icon>快速识别创建
|
||||
</el-button>
|
||||
<el-button class="btn-main" type="primary" @click="handleAdd">
|
||||
<el-icon><Plus /></el-icon>新增人员
|
||||
</el-button>
|
||||
<el-button
|
||||
class="btn-ghost"
|
||||
@@ -298,7 +298,12 @@
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="身份证号" prop="idCardNo">
|
||||
<el-input v-model="formData.idCardNo" placeholder="请输入身份证号" maxlength="32" />
|
||||
<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="请选择人员类型">
|
||||
@@ -429,6 +434,7 @@ import { useListMediaActive } from '@/composables/useListMediaActive'
|
||||
import { pickBxPageResult } from '@/utils/http/bx'
|
||||
import { DEFAULT_LIST_PAGE_SIZE } from '@/utils/table/tableConfig'
|
||||
import { formatDateTime } from '@/utils/format'
|
||||
import { calcAgeFromChineseIdCard } from '@/utils/id-card'
|
||||
import {
|
||||
downloadListPhoto,
|
||||
firstPhotoUrl,
|
||||
@@ -795,9 +801,21 @@ async function handleView(row: Personnel) {
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -167,6 +167,13 @@
|
||||
>
|
||||
<el-icon><CircleClose /></el-icon>作废
|
||||
</el-button>
|
||||
<el-button
|
||||
type="danger"
|
||||
class="pl-plan-paste-create-btn"
|
||||
@click="pasteVisible = true"
|
||||
>
|
||||
<el-icon><DocumentCopy /></el-icon>三方人车快速创建
|
||||
</el-button>
|
||||
|
||||
<ListToolbarEndActions
|
||||
:loading="loading"
|
||||
@@ -522,6 +529,8 @@
|
||||
<PlInboundSlipPrintDialog ref="inboundSlipPrintRef" />
|
||||
<PlDeliverySlipPrintDialog ref="deliverySlipPrintRef" />
|
||||
<PlSubpackSlipPrintDialog ref="subpackSlipPrintRef" />
|
||||
|
||||
<PlPasteRecognizeDialog v-model:visible="pasteVisible" mode="vehicle-bundle" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -531,6 +540,7 @@ import {
|
||||
Bell,
|
||||
CircleClose,
|
||||
CopyDocument,
|
||||
DocumentCopy,
|
||||
Edit,
|
||||
Plus,
|
||||
Printer,
|
||||
@@ -543,6 +553,7 @@ import PlInboundSlipPrintDialog from '@/components/business/pl-inbound-slip-prin
|
||||
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 PlPasteRecognizeDialog from '@/components/business/pl-paste-recognize-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'
|
||||
@@ -577,6 +588,7 @@ const loading = ref(false)
|
||||
const voidLoading = ref(false)
|
||||
const waitNoticeLoading = ref(false)
|
||||
const formDialogVisible = ref(false)
|
||||
const pasteVisible = ref(false)
|
||||
const editingPlanId = ref('')
|
||||
const copyFromPlanId = ref('')
|
||||
const viewVisible = ref(false)
|
||||
@@ -1110,6 +1122,20 @@ async function openArrangeFromQuery() {
|
||||
> .el-dropdown {
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
/* 工具栏全局把按钮刷成描边,需单独盖住才能显示危险实心红 */
|
||||
> .el-button.pl-plan-paste-create-btn {
|
||||
color: #fff !important;
|
||||
background: var(--danger, #dc2626) !important;
|
||||
border-color: var(--danger, #dc2626) !important;
|
||||
|
||||
&:hover,
|
||||
&:focus {
|
||||
color: #fff !important;
|
||||
background: #b91c1c !important;
|
||||
border-color: #b91c1c !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.pl-plan-list-pager-bar {
|
||||
|
||||
@@ -63,12 +63,12 @@
|
||||
@search="handleQuickSearch"
|
||||
@clear="handleQuickSearchClear"
|
||||
/>
|
||||
<el-button class="btn-ghost" @click="pasteVisible = true">
|
||||
<el-icon><DocumentCopy /></el-icon>快速识别创建
|
||||
</el-button>
|
||||
<el-button class="btn-main" type="primary" @click="handleAdd">
|
||||
<el-icon><Plus /></el-icon>新增车辆
|
||||
</el-button>
|
||||
<el-button class="btn-ghost" @click="pasteVisible = true">
|
||||
<el-icon><DocumentCopy /></el-icon>粘贴识别
|
||||
</el-button>
|
||||
<el-button
|
||||
class="btn-ghost"
|
||||
:disabled="selectedRows.length !== 1"
|
||||
|
||||
Reference in new issue
Block a user