This commit is contained in:
zlwu committed 2026-07-20 10:50:26 +08:00
1 parent 6d9354a194
commit aff71d296b
2759 files changed
+860425 -13211

No files matched your search

@@ -141,8 +141,8 @@ const emit = defineEmits(['success'])
const dialogVisible = ref(false)
const actionType = ref<'submit' | 'approve' | 'reject' | 'withdraw'>('submit')
const contractId = ref<number>()
const contractIds = ref<number[]>()
const contractId = ref<string | number>()
const contractIds = ref<(string | number)[]>()
const form = ref({
approvalType: 'sequential',
@@ -195,7 +195,7 @@ const confirmButtonText = computed(() => {
return textMap[actionType.value]
})
const open = (id: number, type: 'submit' | 'approve' | 'reject' | 'withdraw' = 'submit') => {
const open = (id: string | number, type: 'submit' | 'approve' | 'reject' | 'withdraw' = 'submit') => {
contractId.value = id
contractIds.value = undefined
actionType.value = type
@@ -206,7 +206,10 @@ const open = (id: number, type: 'submit' | 'approve' | 'reject' | 'withdraw' = '
}
}
const openBatch = (idList: number[], type: 'submit' | 'approve' | 'reject' | 'withdraw' = 'submit') => {
const openBatch = (
idList: (string | number)[],
type: 'submit' | 'approve' | 'reject' | 'withdraw' = 'submit'
) => {
contractIds.value = idList
contractId.value = undefined
actionType.value = type
@@ -258,12 +261,17 @@ const getApproverName = (approverId: string | number): string => {
const handleConfirm = async () => {
await formRef.value?.validate()
const isBatch = !!(contractIds.value && contractIds.value.length > 0)
if (!isBatch && (contractId.value == null || contractId.value === '')) {
$modal.msgError('合同 ID 缺失,请关闭后重新打开提交审批')
return
}
submitLoading.value = true
try {
if (actionType.value === 'submit') {
if (contractIds.value && contractIds.value.length > 0) {
const count = await batchSubmitContract(contractIds.value, form.value.approverIds, form.value.remark)
$modal.msgSuccess(`提交成功,成功 ${count ?? contractIds.value.length} 条`)
if (isBatch) {
const count = await batchSubmitContract(contractIds.value!, form.value.approverIds, form.value.remark)
$modal.msgSuccess(`提交成功,成功 ${count ?? contractIds.value!.length} 条`)
} else {
await submitContract(contractId.value!, form.value.approverIds, form.value.remark)
$modal.msgSuccess('提交成功')
@@ -3,7 +3,7 @@
<el-dialog
v-model="visible"
title="合同详情"
width="1500px"
width="100%"
align-center
append-to-body
destroy-on-close
@@ -111,10 +111,30 @@
</div>
<div class="parties-section">
<div class="parties-section-toolbar">
<el-button text type="primary" size="small" @click="partiesExpanded = !partiesExpanded">
<el-icon>
<ArrowUp v-if="partiesExpanded" />
<ArrowDown v-else />
</el-icon>
{{ partiesExpanded ? '收起供需方' : '展开供需方' }}
</el-button>
</div>
<div class="parties-row">
<div class="party-panel">
<div class="party-panel__title">供方信息</div>
<ViewKvTable :fields="detailSupplierViewFields" mode="dual" />
<div class="party-panel" :class="{ 'is-collapsed': !partiesExpanded }">
<div class="party-panel__header">
<div class="party-panel__title">供方信息</div>
</div>
<div v-if="!partiesExpanded" class="party-panel__summary">
<span class="party-panel__summary-label">单位名称</span>
<span
class="party-panel__summary-value"
:class="{ 'is-empty': !detailContract?.partyA }"
>
{{ detailContract?.partyA || '未填写' }}
</span>
</div>
<ViewKvTable v-show="partiesExpanded" :fields="detailSupplierViewFields" mode="dual" />
</div>
<div class="party-flow-bridge" aria-hidden="true">
@@ -138,9 +158,20 @@
</span>
</div>
<div class="party-panel">
<div class="party-panel__title">需方信息</div>
<ViewKvTable :fields="detailBuyerViewFields" mode="dual" />
<div class="party-panel" :class="{ 'is-collapsed': !partiesExpanded }">
<div class="party-panel__header">
<div class="party-panel__title">需方信息</div>
</div>
<div v-if="!partiesExpanded" class="party-panel__summary">
<span class="party-panel__summary-label">单位名称</span>
<span
class="party-panel__summary-value"
:class="{ 'is-empty': !detailContract?.partyB }"
>
{{ detailContract?.partyB || '未填写' }}
</span>
</div>
<ViewKvTable v-show="partiesExpanded" :fields="detailBuyerViewFields" mode="dual" />
</div>
</div>
</div>
@@ -814,7 +845,9 @@ import {
Promotion,
Upload,
VideoPlay,
View
View,
ArrowDown,
ArrowUp
} from '@element-plus/icons-vue';
import {
getContract as getContractDetail,
@@ -876,6 +909,8 @@ const detailLoading = ref(false);
const detailActiveTab = ref('contract');
const currentDetailId = ref<string | number>();
const detailContract = ref<ContractVO>();
/** 供方 / 需方信息展开状态(默认缩略,两侧共用) */
const partiesExpanded = ref(false);
const detailPaymentList = ref<any[]>([]);
const detailPaymentLoading = ref(false);
const detailInvoiceList = ref<any[]>([]);
@@ -980,6 +1015,7 @@ async function open(id: string | number) {
currentDetailId.value = id;
visible.value = true;
detailActiveTab.value = 'contract';
partiesExpanded.value = false;
await loadDetailData();
}
@@ -1350,8 +1386,8 @@ const detailBasicViewFields = computed<ViewField[]>(() => {
if (!c) return [];
return [
{ label: '合同编号', value: c.contractNo },
{ label: '合同名称', value: c.contractName },
{ label: '合同编号', value: c.contractNo, long: false },
{ label: '合同名称', value: c.contractName, long: false },
detailTagField('合同类型', 'crm_contract_type', c.contractType),
detailTagField('合同模版', 'crm_contract_template', c.contractTemplate, { long: false }),
{ label: '客户名称', value: c.customerName, viewTarget: 'customer', viewId: c.customerId },
@@ -2918,6 +2954,14 @@ onMounted(async () => {
margin: 8px 0 20px;
}
.parties-section-toolbar {
display: flex;
justify-content: flex-end;
align-items: center;
gap: 8px;
margin-bottom: 12px;
}
.parties-row {
display: flex;
align-items: stretch;
@@ -2932,10 +2976,24 @@ onMounted(async () => {
border: 1px solid var(--border, #d9e8e2);
border-radius: 10px;
background: #fff;
&.is-collapsed {
padding: 12px 16px;
}
}
.party-panel__header {
display: flex;
align-items: center;
margin-bottom: 12px;
.party-panel.is-collapsed & {
margin-bottom: 8px;
}
}
.party-panel__title {
margin-bottom: 12px;
margin-bottom: 0;
padding-left: 10px;
font-size: 14px;
font-weight: 600;
@@ -2944,6 +3002,37 @@ onMounted(async () => {
border-left: 3px solid var(--section-bar-border-color, var(--primary, #10b981));
}
.party-panel__summary {
display: flex;
align-items: baseline;
gap: 8px;
min-width: 0;
padding: 2px 0 2px 10px;
}
.party-panel__summary-label {
flex-shrink: 0;
font-size: 12px;
color: var(--mint-text-muted, #64748b);
line-height: 1.5;
}
.party-panel__summary-value {
min-width: 0;
font-size: 14px;
font-weight: 500;
color: var(--mint-text, #0f172a);
line-height: 1.5;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
&.is-empty {
font-weight: 400;
color: var(--mint-text-muted, #94a3b8);
}
}
.party-flow-bridge {
flex: 0 0 88px;
display: flex;
@@ -2,7 +2,7 @@
<el-dialog
v-model="dialogVisible"
:title="formTitle"
width="calc(100vw - 300px)"
width="100%"
top="20px"
class="dialog-form-layout contract-form-dialog"
destroy-on-close
@@ -13,7 +13,7 @@
>
<div class="contract-form-body">
<el-form ref="formRef" :model="form" :rules="rules" label-position="right" label-width="120px" class="crm-dialog-form">
<!-- 合同基础信息(一行 5 列) -->
<!-- 合同基础信息(一行 4 列) -->
<div class="contract-basic-info">
<el-form-item label="合同编号" prop="contractNo">
<el-input v-model="form.contractNo" placeholder="系统自动生成,格式:SX/X-JT20250926002" maxlength="50" />
@@ -117,18 +117,33 @@
</el-form-item>
</div>
<!-- 供方 / 需方信息(左右布局) -->
<!-- 供方 / 需方信息(左右布局,默认缩略、各自独立展开) -->
<div class="parties-section">
<div class="parties-section-toolbar">
<el-button text type="primary" size="small" @click="partiesExpanded = !partiesExpanded">
<el-icon>
<ArrowUp v-if="partiesExpanded" />
<ArrowDown v-else />
</el-icon>
{{ partiesExpanded ? '收起供需方' : '展开供需方' }}
</el-button>
<el-button type="primary" size="small" @click="handleSwapParties">
<el-icon><Sort /></el-icon>
供需方调换
</el-button>
</div>
<div class="parties-row">
<div class="party-panel">
<div class="party-panel__title">供方信息</div>
<div class="form-grid-3">
<div class="party-panel" :class="{ 'is-collapsed': !partiesExpanded }">
<div class="party-panel__header">
<div class="party-panel__title">供方信息</div>
</div>
<div v-if="!partiesExpanded" class="party-panel__summary">
<span class="party-panel__summary-label">单位名称</span>
<span class="party-panel__summary-value" :class="{ 'is-empty': !form.partyA }">
{{ form.partyA || '未填写' }}
</span>
</div>
<div v-show="partiesExpanded" class="form-grid-2">
<el-form-item label="单位名称(章)" prop="partyA">
<el-input v-model="form.partyA" placeholder="请输入单位名称" maxlength="100" />
</el-form-item>
@@ -174,9 +189,17 @@
</span>
</div>
<div class="party-panel">
<div class="party-panel__title">需方信息</div>
<div class="form-grid-3">
<div class="party-panel" :class="{ 'is-collapsed': !partiesExpanded }">
<div class="party-panel__header">
<div class="party-panel__title">需方信息</div>
</div>
<div v-if="!partiesExpanded" class="party-panel__summary">
<span class="party-panel__summary-label">单位名称</span>
<span class="party-panel__summary-value" :class="{ 'is-empty': !form.partyB }">
{{ form.partyB || '未填写' }}
</span>
</div>
<div v-show="partiesExpanded" class="form-grid-2">
<el-form-item label="单位名称(章)" prop="partyB">
<el-input v-model="form.partyB" placeholder="从客户开票信息带出" maxlength="200" />
</el-form-item>
@@ -499,7 +522,9 @@ import {
Close,
FolderChecked,
Promotion,
Loading
Loading,
ArrowDown,
ArrowUp
} from '@element-plus/icons-vue'
import {
buildUploadFileListFromField,
@@ -633,6 +658,22 @@ const form = ref<ExtendedContractForm>({
// 供需方是否已调换的标志
const isPartiesSwapped = ref(false)
/** 供方 / 需方信息展开状态(默认缩略,两侧共用) */
const partiesExpanded = ref(false)
const resetPartyExpand = () => {
partiesExpanded.value = false
}
/** 校验失败时,自动展开供需方面板 */
const expandPartiesForInvalidFields = (invalidFields?: Record<string, unknown>) => {
if (!invalidFields) return
const keys = Object.keys(invalidFields)
if (keys.some((k) => k.startsWith('partyA') || k.startsWith('partyB'))) {
partiesExpanded.value = true
}
}
// 记录原始的模板内容(用于检测是否被意外删除)
const originalTemplateContent = ref<string>('')
@@ -714,6 +755,7 @@ interface QuoteVO {
/** 对话框打开后的初始化 */
const handleOpened = async () => {
resetPartyExpand()
await loadPerms()
await Promise.all([loadSupplierList(), loadUserList()])
@@ -783,6 +825,7 @@ const resetForm = () => {
remark: ''
}
isPartiesSwapped.value = false
resetPartyExpand()
originalTemplateContent.value = ''
customerShortName.value = ''
contractDateRange.value = [] as any
@@ -1793,6 +1836,7 @@ const handleSubmit = async () => {
try {
await formRef.value?.validate()
} catch (error) {
expandPartiesForInvalidFields(error as Record<string, unknown>)
ElMessage.warning({
message: '请填写完整的必填信息',
duration: 3000
@@ -1933,15 +1977,20 @@ const handleSubmit = async () => {
delete data.products
}
let contractId: number
let contractId: string | number
if (form.value.id) {
await updateContract(data)
contractId = form.value.id as number
contractId = form.value.id
$modal.msgSuccess('保存成功')
} else {
const res = await addContract(data)
contractId = res.data
form.value.id = contractId
if (contractId == null || contractId === '') {
$modal.msgError('保存成功但未返回合同 ID,请从列表重新提交审批')
emit('success')
return
}
form.value.id = contractId as any
$modal.msgSuccess('保存成功')
}
@@ -2020,8 +2069,8 @@ const loadSupplierList = async () => {
.contract-basic-info {
display: grid;
grid-template-columns: repeat(5, minmax(0, 1fr));
gap: 12px 16px;
grid-template-columns: repeat(4, minmax(0, 1fr));
gap: 12px 14px;
margin-bottom: 20px;
:deep(.el-form-item) {
@@ -2033,12 +2082,6 @@ const loadSupplierList = async () => {
}
}
@media (max-width: 1400px) {
.contract-basic-info {
grid-template-columns: repeat(4, minmax(0, 1fr));
}
}
@media (max-width: 1100px) {
.contract-basic-info {
grid-template-columns: repeat(2, minmax(0, 1fr));
@@ -2058,6 +2101,8 @@ const loadSupplierList = async () => {
.parties-section-toolbar {
display: flex;
justify-content: flex-end;
align-items: center;
gap: 8px;
margin-bottom: 12px;
}
@@ -2076,13 +2121,27 @@ const loadSupplierList = async () => {
border-radius: 10px;
background: #fff;
&.is-collapsed {
padding: 12px 16px;
}
:deep(.el-form-item) {
margin-bottom: 0;
}
}
.party-panel__title {
.party-panel__header {
display: flex;
align-items: center;
margin-bottom: 12px;
.party-panel.is-collapsed & {
margin-bottom: 8px;
}
}
.party-panel__title {
margin-bottom: 0;
padding-left: 10px;
font-size: 14px;
font-weight: 600;
@@ -2091,6 +2150,37 @@ const loadSupplierList = async () => {
border-left: 3px solid var(--section-bar-border-color, var(--primary, #10b981));
}
.party-panel__summary {
display: flex;
align-items: baseline;
gap: 8px;
min-width: 0;
padding: 2px 0 2px 10px;
}
.party-panel__summary-label {
flex-shrink: 0;
font-size: 12px;
color: var(--mint-text-muted, #64748b);
line-height: 1.5;
}
.party-panel__summary-value {
min-width: 0;
font-size: 14px;
font-weight: 500;
color: var(--mint-text, #0f172a);
line-height: 1.5;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
&.is-empty {
font-weight: 400;
color: var(--mint-text-muted, #94a3b8);
}
}
.party-flow-bridge {
flex: 0 0 88px;
display: flex;
+7 -4
View File
@@ -2377,18 +2377,21 @@ const handleSubmit = async () => {
delete data.products;
}
let contractId: number;
let contractId: string | number;
if (form.value.id) {
// 编辑时更新合同
await updateContract(data);
contractId = form.value.id;
$modal.msgSuccess('保存成功');
} else {
// 新增时创建合同
// 新增时创建合同(addContract 返回 { data: id })
const res = await addContract(data);
// 从返回结果中获取合同ID
contractId = res.data;
form.value.id = contractId;
if (contractId == null || contractId === '') {
$modal.msgError('保存成功但未返回合同 ID,请从列表重新提交审批');
return;
}
form.value.id = contractId as any;
$modal.msgSuccess('保存成功');
}
@@ -101,7 +101,9 @@ import {
const dictStore = useDictStore()
const emit = defineEmits(['success'])
const emit = defineEmits<{
success: [payload?: { id?: string | number }]
}>()
const form = ref({
id: undefined as string | undefined,
@@ -170,12 +172,15 @@ const submitForm = () => {
if (form.value.id) {
await fetchUpdateContact(form.value)
ElMessage.success('修改成功')
dialog.visible = false
emit('success', { id: form.value.id })
} else {
await fetchCreateContact(form.value)
const res = await fetchCreateContact(form.value)
const data = (res as any)?.data ?? res
ElMessage.success('新增成功')
dialog.visible = false
emit('success', { id: data?.id })
}
dialog.visible = false
emit('success')
} catch (error) {
console.error(error)
} finally {
@@ -15,8 +15,7 @@
ref="formRef"
:model="form"
:rules="rules"
label-position="right"
label-width="100px"
label-position="top"
class="crm-dialog-form"
scroll-to-error
:scroll-into-view-options="{ behavior: 'smooth', block: 'center' }"
@@ -405,8 +405,7 @@
ref="submitFormRef"
:model="submitForm"
:rules="submitRules"
label-position="right"
label-width="100px"
label-position="top"
class="crm-dialog-form"
scroll-to-error
:scroll-into-view-options="{ behavior: 'smooth', block: 'center' }"
+2 -36
View File
@@ -98,15 +98,8 @@
/>
<el-button
v-if="selectedPlan && selectedPlan.followStatus !== 'cancelled'"
class="btn-ghost"
:disabled="selectedRows.length !== 1"
@click="handleToolbarEdit"
>
<el-icon><Edit /></el-icon>编辑
</el-button>
<el-button
v-if="selectedPlan && selectedPlan.followStatus !== 'cancelled'"
class="btn-ghost"
class="btn-main"
type="primary"
:disabled="selectedRows.length !== 1"
@click="handleToolbarArchive"
>
@@ -272,12 +265,6 @@
</div>
</section>
<PlPlanFormDialog
v-model:visible="formDialogVisible"
:plan-id="editingPlanId"
@success="handlePlanMutationSuccess"
/>
<PlPlanViewDialog
ref="viewDialogRef"
v-model:visible="viewVisible"
@@ -288,13 +275,6 @@
v-if="viewingPlan.followStatus !== 'cancelled'"
class="btn-main"
type="primary"
@click="handleEdit(viewingPlan)"
>
<el-icon><Edit /></el-icon>编辑
</el-button>
<el-button
v-if="viewingPlan.followStatus !== 'cancelled'"
class="btn-ghost"
@click="handleArchive(viewingPlan)"
>
<el-icon><FolderChecked /></el-icon>{{ archiveButtonLabel(viewingPlan) }}
@@ -315,7 +295,6 @@ import ListQuickSearchInput from '@/components/business/list-quick-search-input/
import ListToolbarEndActions from '@/components/business/list-toolbar-end-actions/index.vue'
import { usePersistedListColumns } from '@/composables/usePersistedListColumns'
import {
Edit,
FolderChecked,
RefreshLeft,
Search
@@ -327,7 +306,6 @@ import {
} from '@/composables/usePlToxicProductCertCheck'
import { pickBxData } from '@/utils/http/bx'
import PlPlanArchiveDialog from '@/components/business/pl-plan-archive-dialog/index.vue'
import PlPlanFormDialog from '@/components/business/pl-plan-form-dialog/index.vue'
import PlPlanListCertCell from '@/components/business/pl-plan-list-cert-cell/index.vue'
import PlPlanListProductCell from '@/components/business/pl-plan-list-product-cell/index.vue'
import PlPlanViewDialog from '@/components/business/pl-plan-view-dialog/index.vue'
@@ -349,8 +327,6 @@ import { useMenuStore } from '@/store/modules/menu'
const menuStore = useMenuStore()
const loading = ref(false)
const formDialogVisible = ref(false)
const editingPlanId = ref('')
const viewVisible = ref(false)
const viewPlanId = ref('')
const viewDialogRef = ref<InstanceType<typeof PlPlanViewDialog>>()
@@ -541,11 +517,6 @@ function archiveButtonLabel(row: Plan) {
return row.archiveStatus === 'archived' ? '调整' : '归档'
}
function handleEdit(row: Plan) {
editingPlanId.value = row.id
formDialogVisible.value = true
}
async function handleArchive(row: Plan) {
if (row.archiveStatus === 'archived') {
archivePlanId.value = row.id
@@ -578,11 +549,6 @@ async function handleArchive(row: Plan) {
archiveDialogVisible.value = true
}
function handleToolbarEdit() {
if (selectedRows.value.length !== 1) return
handleEdit(selectedRows.value[0])
}
function handleToolbarArchive() {
if (selectedRows.value.length !== 1) return
handleArchive(selectedRows.value[0])
+1 -1
View File
@@ -161,7 +161,7 @@
<PlPlanListProductCell :products="row.products" />
</template>
</el-table-column>
<el-table-column v-if="isColumnVisible('planAttachments')" label="计划附件" min-width="220">
<el-table-column v-if="isColumnVisible('planAttachments')" label="计划附件" min-width="280">
<template #default="{ row }">
<PlPlanListCertCell
:products="row.products"
+15 -2
View File
@@ -478,9 +478,13 @@ async function refreshViewIfOpen() {
await viewDialogRef.value?.reload()
}
async function handlePlanMutationSuccess() {
async function handlePlanMutationSuccess(payload?: { planId?: string; openArrange?: boolean }) {
await fetchData()
await refreshViewIfOpen()
if (payload?.openArrange && payload.planId) {
arrangePlanId.value = payload.planId
arrangeDialogVisible.value = true
}
}
const selectedPlan = computed(() => (selectedRows.value.length === 1 ? selectedRows.value[0] : null))
@@ -626,11 +630,20 @@ function handleEdit(row: Plan) {
formDialogVisible.value = true
}
function isIoPlanFrozen(row: Plan) {
return (
row.transportStatus === 'arranged' &&
(row.planType === 'inbound' || row.planType === 'outbound')
)
}
function canEditPlan(row: Plan) {
if (isIoPlanFrozen(row)) return false
return row.archiveStatus !== 'archived' && row.followStatus !== 'cancelled'
}
function canArrangeTransport(row: Plan) {
if (isIoPlanFrozen(row)) return false
return (
(row.transportStatus === 'pending' || row.transportStatus === 'arranged') &&
row.archiveStatus !== 'archived' &&
@@ -692,7 +705,7 @@ async function handleDelete(row: Plan) {
async function handleVoid(row: Plan) {
const hint =
row.transportStatus === 'arranged'
? '作废后将取消运输安排、作废关联地磅出入库单,司机链接将提示计划已作废。是否继续?'
? '作废后将取消运输安排、作废关联入库/出库单与地磅出入库单,现场链接将失效。是否继续?'
: '确认作废该运输计划吗?作废后将无法恢复。'
await ElMessageBox.confirm(hint, '作废运输计划', { type: 'warning' })
voidLoading.value = true