This commit is contained in:
zlwu committed 2026-08-08 20:43:48 +08:00
1 parent 2df2ef0808
commit 683f14828f
388 files changed
+2738488 -81306

No files matched your search

@@ -3,12 +3,8 @@
<template>
<div class="page-container">
<section class="panel">
<div class="panel-top">
<h2 class="title-bar-heading">备用金申请列表</h2>
</div>
<div class="filter-block">
<el-form :model="filterForm" class="filter-form" @submit.prevent>
<el-form :model="filterForm" class="filter-form" @submit.prevent style="--filter-label-width: 130px">
<div class="filter-grid">
<el-form-item label="申请单号">
<el-input v-model="filterForm.keyword" placeholder="请输入申请单号" clearable />
@@ -3,10 +3,6 @@
<template>
<div class="page-container">
<section class="panel">
<div class="panel-top">
<h2 class="title-bar-heading">备用金审批</h2>
</div>
<el-tabs
v-model="activeTab"
class="panel-tabs"
@@ -3,10 +3,6 @@
<template>
<div class="page-container">
<section class="panel">
<div class="panel-top">
<h2 class="title-bar-heading">备用金发放</h2>
</div>
<el-tabs
v-model="activeTab"
class="panel-tabs"
@@ -3,10 +3,6 @@
<template>
<div class="page-container">
<section class="panel">
<div class="panel-top">
<h2 class="title-bar-heading">费用项目列表</h2>
</div>
<div class="filter-block">
<el-form :model="searchForm" class="filter-form" @submit.prevent>
<div class="filter-grid">
@@ -2,10 +2,6 @@
<template>
<div class="page-container">
<section class="panel">
<div class="panel-top">
<h2 class="title-bar-heading">发票夹管理</h2>
</div>
<div class="filter-block">
<el-form :model="filterForm" class="filter-form" @submit.prevent>
<div class="filter-grid">
@@ -2,9 +2,8 @@
<template>
<div class="page-container">
<section class="panel">
<div class="panel-top">
<h2 class="title-bar-heading">我的发票夹</h2>
<p v-if="summary" class="panel-top-meta">
<div v-if="summary" class="panel-top">
<p class="panel-top-meta">
总额 {{ formatMoneyYuan(summary.totalAmount) }} 元 · 已报销占用
{{ formatMoneyYuan(summary.usedAmount) }} 元 · 余额
<b class="money-em">{{ formatMoneyYuan(summary.balance) }}</b> 元 · 发票
-4
View File
@@ -3,10 +3,6 @@
<template>
<div class="page-container">
<section class="panel">
<div class="panel-top">
<h2 class="title-bar-heading">支付管理</h2>
</div>
<el-tabs
v-model="activeTab"
class="panel-tabs"
@@ -3,10 +3,6 @@
<template>
<div class="page-container">
<section class="panel">
<div class="panel-top">
<h2 class="title-bar-heading">报销申请列表</h2>
</div>
<div class="filter-block">
<el-form :model="filterForm" class="filter-form" @submit.prevent>
<div class="filter-grid">
@@ -3,10 +3,6 @@
<template>
<div class="page-container">
<section class="panel">
<div class="panel-top">
<h2 class="title-bar-heading">报销审批</h2>
</div>
<el-tabs
v-model="activeTab"
class="panel-tabs"
@@ -15,7 +11,7 @@
<!-- 待我审批 -->
<el-tab-pane label="待我审批" name="pending">
<div class="filter-block">
<el-form :model="pendingFilterForm" class="filter-form" @submit.prevent>
<el-form :model="pendingFilterForm" class="filter-form" @submit.prevent style="--filter-label-width: 110px">
<div class="filter-grid">
<el-form-item label="报销单号">
<el-input v-model="pendingFilterForm.code" placeholder="请输入报销单号" clearable />
@@ -238,7 +234,7 @@
<!-- 我已审批 -->
<el-tab-pane label="我已审批" name="approved">
<div class="filter-block">
<el-form :model="approvedFilterForm" class="filter-form" @submit.prevent>
<el-form :model="approvedFilterForm" class="filter-form" @submit.prevent style="--filter-label-width: 110px">
<div class="filter-grid">
<el-form-item label="报销单号">
<el-input v-model="approvedFilterForm.code" placeholder="请输入报销单号" clearable />
+1 -5
View File
@@ -3,12 +3,8 @@
<template>
<div class="page-container">
<section class="panel">
<div class="panel-top">
<h2 class="title-bar-heading">全部申请单</h2>
</div>
<div class="filter-block">
<el-form :model="filterForm" class="filter-form" @submit.prevent>
<el-form :model="filterForm" class="filter-form" @submit.prevent style="--filter-label-width: 110px">
<div class="filter-grid">
<el-form-item label="单号">
<el-input v-model="filterForm.code" placeholder="请输入单号" clearable />
+1 -5
View File
@@ -3,12 +3,8 @@
<template>
<div class="page-container">
<section class="panel">
<div class="panel-top">
<h2 class="title-bar-heading">我的申请单</h2>
</div>
<div class="filter-block">
<el-form :model="filterForm" class="filter-form" @submit.prevent>
<el-form :model="filterForm" class="filter-form" @submit.prevent style="--filter-label-width: 110px">
<div class="filter-grid">
<el-form-item label="单号">
<el-input v-model="filterForm.code" placeholder="请输入单号" clearable />
+1 -5
View File
@@ -3,12 +3,8 @@
<template>
<div class="page-container">
<section class="panel">
<div class="panel-top">
<h2 class="title-bar-heading">待我审批</h2>
</div>
<div class="filter-block">
<el-form :model="filterForm" class="filter-form" @submit.prevent>
<el-form :model="filterForm" class="filter-form" @submit.prevent style="--filter-label-width: 110px">
<div class="filter-grid">
<el-form-item label="单号">
<el-input v-model="filterForm.code" placeholder="请输入单号" clearable />
@@ -3,10 +3,6 @@
<template>
<div class="page-container">
<section class="panel">
<div class="panel-top">
<h2 class="title-bar-heading">审批流程节点</h2>
</div>
<div class="wf-info-bar">
<span><b>流程名称:</b>{{ wfDef.wfName || '-' }}</span>
<span>
@@ -3,10 +3,6 @@
<template>
<div class="page-container">
<section class="panel">
<div class="panel-top">
<h2 class="title-bar-heading">审批流程节点</h2>
</div>
<div class="wf-info-bar">
<span><b>流程名称:</b>{{ wfDef.wfName || '-' }}</span>
<span>
+1 -4
View File
@@ -2,9 +2,6 @@
<template>
<div class="page-container">
<section class="panel">
<div class="panel-top">
<h2 class="title-bar-heading">线索详情</h2>
</div>
<el-button class="btn-ghost" @click="goBack">
<el-icon><ArrowLeft /></el-icon>返回列表
</el-button>
@@ -23,7 +20,7 @@
const detailDrawerRef = ref<InstanceType<typeof DetailDrawer>>()
function goBack() {
router.push({ path: '/crm/clue' })
router.push({ path: '/system/clue' })
}
onMounted(() => {
-4
View File
@@ -2,10 +2,6 @@
<template>
<div class="page-container">
<section class="panel">
<div class="panel-top">
<h2 class="title-bar-heading">线索管理</h2>
</div>
<el-tabs
v-model="activeView"
class="panel-tabs"
@@ -1,10 +1,6 @@
<template>
<div class="page-container">
<section class="panel">
<div class="panel-top">
<h2 class="title-bar-heading">线索统计</h2>
</div>
<div class="filter-block">
<el-form class="filter-form" @submit.prevent>
<div class="filter-grid">
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,596 @@
<!-- 合同审批记录 -->
<template>
<div class="page-container">
<section class="panel">
<div class="filter-block">
<el-form ref="queryFormRef" :model="queryParams" class="filter-form" @submit.prevent>
<div class="filter-grid">
<el-form-item label="合同编号" prop="contractNo">
<el-input
v-model="queryParams.contractNo"
placeholder="合同编号"
clearable
@keyup.enter="handleQuery"
/>
</el-form-item>
<el-form-item label="合同名称" prop="contractName">
<el-input
v-model="queryParams.contractName"
placeholder="合同名称"
clearable
@keyup.enter="handleQuery"
/>
</el-form-item>
<el-form-item label="审批人" prop="approverName">
<el-input
v-model="queryParams.approverName"
placeholder="审批人"
clearable
@keyup.enter="handleQuery"
/>
</el-form-item>
<el-form-item label="审批结果" prop="approvalResult">
<el-select v-model="queryParams.approvalResult" placeholder="全部" clearable>
<el-option label="通过" value="approved" />
<el-option label="驳回" value="rejected" />
<el-option label="待审批" value="pending" />
</el-select>
</el-form-item>
<el-form-item label="审批时间" class="form-col-span-2">
<el-date-picker
v-model="dateRange"
type="daterange"
range-separator="-"
start-placeholder="开始日期"
end-placeholder="结束日期"
value-format="YYYY-MM-DD"
style="width: 100%"
/>
</el-form-item>
</div>
<div class="filter-actions-row">
<span class="filter-hint">按合同、审批人、结果及时间筛选。</span>
<div class="filter-actions-end">
<el-button class="btn-ghost" :loading="loading" @click="resetQuery">
<el-icon><RefreshLeft /></el-icon>重置
</el-button>
<el-button class="btn-main" type="primary" :loading="loading" @click="handleQuery">
<el-icon><Search /></el-icon>搜索
</el-button>
</div>
</div>
</el-form>
</div>
<div class="list-toolbar">
<div class="list-toolbar-row">
<ListQuickSearchInput
v-model="quickSearchKeyword"
placeholder="合同编号/合同名称/审批人"
@search="handleQuickSearch"
@clear="handleQuickSearchClear"
/>
<el-button
class="btn-ghost"
:loading="exportLoading"
@click="handleExport"
>
<el-icon><Download /></el-icon>导出
</el-button>
<ListToolbarEndActions
:loading="loading"
:column-defs="listColumnDefs"
v-model:visible-columns="visibleColumns"
v-model:check-all="checkAll"
:is-indeterminate="isIndeterminate"
@refresh="getList"
@reset-columns="resetToDefault"
/>
</div>
</div>
<div class="list-body list-wrap">
<ListTable table-key="crm-contract-approval"
class="list-table"
v-loading="loading"
:data="approvalList"
stripe
row-key="id"
@row-dblclick="handleView"
@selection-change="handleSelectionChange"
>
<el-table-column type="selection" min-width="55" align="center" header-align="center" />
<el-table-column
type="index"
label="序号"
min-width="68"
align="center"
header-align="center"
:index="(index) => (queryParams.pageNum - 1) * queryParams.pageSize + index + 1"
/>
<el-table-column
prop="contractNo"
label="合同编号"
min-width="150"
align="center"
header-align="center"
show-overflow-tooltip
>
<template #default="{ row }">
<el-link type="primary" @click="handleViewContract(row)">{{
row.contractNo
}}</el-link>
</template>
</el-table-column>
<el-table-column
v-if="isColumnVisible('contractName')"
prop="contractName"
label="合同名称"
min-width="240"
align="left"
header-align="left"
class-name="col-name-wrap"
label-class-name="col-name-wrap"
/>
<el-table-column label="审批级别" v-if="isColumnVisible('step')" min-width="100" align="center" header-align="center">
<template #default="{ row }">第{{ row.step }}级</template>
</el-table-column>
<el-table-column
v-if="isColumnVisible('approverName')"
prop="approverName"
label="审批人"
min-width="120"
align="center"
header-align="center"
/>
<el-table-column label="审批结果" v-if="isColumnVisible('approvalResult')" min-width="100" align="center" header-align="center">
<template #default="{ row }">
<el-tag v-if="row.approvalResult === 'approved'" type="success" size="small"
>通过</el-tag
>
<el-tag v-else-if="row.approvalResult === 'rejected'" type="danger" size="small"
>驳回</el-tag
>
<el-tag v-else type="warning" size="small">待审批</el-tag>
</template>
</el-table-column>
<el-table-column
v-if="isColumnVisible('approvalOpinion')"
prop="approvalOpinion"
label="审批意见"
min-width="200"
align="center"
header-align="center"
show-overflow-tooltip
/>
<el-table-column label="审批时间" v-if="isColumnVisible('approvalTime')" min-width="160" align="center" header-align="center">
<template #default="{ row }">{{ parseTime(row.approvalTime) }}</template>
</el-table-column>
</ListTable>
<div class="pagination list-pager-bar">
<el-pagination
v-model:current-page="queryParams.pageNum"
v-model:page-size="queryParams.pageSize"
:page-sizes="[10, 20, 30, 50]"
layout="total, sizes, prev, pager, next, jumper"
:total="total"
@size-change="getList"
@current-change="getList"
/>
</div>
</div>
<SystemViewDialog
v-model:visible="viewDialog.visible"
title="审批详情"
:icon="Document"
:code="viewDialog.data.contractNo"
code-label="合同编号"
:meta="viewDialog.data.contractName"
:sections="approvalViewSections"
append-to-body
>
<template #hero-actions>
<div class="approval-view-hero-actions">
<el-button
v-if="viewDialog.data.approvalResult === 'pending'"
class="btn-main"
type="primary"
@click="handleApprove(viewDialog.data)"
>
<el-icon><EditPen /></el-icon>审批
</el-button>
</div>
</template>
</SystemViewDialog>
<el-dialog
v-model="approvalDialog.visible"
title="审批"
width="600px"
class="dialog-form-layout"
modal-class="order-module-dialog-mask"
align-center
destroy-on-close
:close-on-click-modal="false"
append-to-body
>
<el-form
ref="approvalFormRef"
:model="approvalForm"
:rules="approvalRules"
label-position="right"
label-width="100px"
class="crm-dialog-form"
scroll-to-error
>
<div class="form-grid-2">
<el-form-item label="审批结果" prop="approvalResult" class="form-col-span-2">
<el-radio-group v-model="approvalForm.approvalResult">
<el-radio value="approved">通过</el-radio>
<el-radio value="rejected">驳回</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="审批意见" prop="approvalOpinion" class="form-col-span-2">
<el-input
v-model="approvalForm.approvalOpinion"
type="textarea"
:rows="5"
:placeholder="
approvalForm.approvalResult === 'rejected'
? '请输入驳回原因'
: '请输入审批意见(可选)'
"
/>
</el-form-item>
</div>
</el-form>
<template #footer>
<el-button class="btn-ghost" @click="approvalDialog.visible = false">
<el-icon><Close /></el-icon>取消
</el-button>
<el-button
class="btn-main"
type="primary"
:loading="submitLoading"
@click="submitApproval"
>
<el-icon><Check /></el-icon>确定
</el-button>
</template>
</el-dialog>
</section>
</div>
</template>
<script setup lang="ts" name="ContractApproval">
import ListToolbarEndActions from '@/components/business/list-toolbar-end-actions/index.vue'
import { usePersistedListColumns } from '@/composables/usePersistedListColumns'
import { ref, reactive, computed, onMounted, watch } from 'vue'
import { watchDebounced } from '@vueuse/core'
import { useRouter } from 'vue-router'
import {
Document,
Download,
Search,
RefreshLeft,
Close,
Check,
EditPen
} from '@element-plus/icons-vue'
import SystemViewDialog, {
type ViewField,
type ViewSection
} from '@/components/business/system-view-dialog/index.vue'
import { crmField, crmLongField, crmTagField } from '@/utils/crm/view-fields'
import {
listApproval,
getApproval,
approvePass,
approveReject,
exportApproval,
type ApprovalQuery,
type ApprovalVO
} from '@/api/crm/contract/approval'
import { parseTime } from '@/utils/format'
import { $modal } from '@/utils/modal'
import ListQuickSearchInput from '@/components/business/list-quick-search-input/index.vue'
const router = useRouter()
const quickSearchKeyword = ref('')
const listColumnDefs = [
{ prop: 'contractName', label: '合同名称' },
{ prop: 'step', label: '审批级别' },
{ prop: 'approverName', label: '审批人' },
{ prop: 'approvalResult', label: '审批结果' },
{ prop: 'approvalOpinion', label: '审批意见' },
{ prop: 'approvalTime', label: '审批时间' }
]
const {
visibleColumns,
checkAll,
isIndeterminate,
isColumnVisible,
resetToDefault
} = usePersistedListColumns('crm_contract_approval_visible_columns', listColumnDefs)
const queryParams = ref<ApprovalQuery>({
pageNum: 1,
pageSize: 20,
contractNo: undefined,
contractName: undefined,
approverName: undefined,
approvalResult: undefined,
beginTime: undefined,
endTime: undefined
})
const approvalForm = ref({
id: undefined as number | undefined,
approvalResult: 'approved',
approvalOpinion: ''
})
const approvalRules = ref({
approvalResult: [{ required: true, message: '请选择审批结果', trigger: 'change' }],
approvalOpinion: [
{
validator: (_rule: unknown, value: string, callback: (err?: Error) => void) => {
if (approvalForm.value.approvalResult === 'rejected' && !value) {
callback(new Error('驳回时必须填写驳回原因'))
} else {
callback()
}
},
trigger: 'blur'
}
]
})
const approvalList = ref<ApprovalVO[]>([])
const loading = ref(true)
const selectedRows = ref<ApprovalVO[]>([])
const submitLoading = ref(false)
const exportLoading = ref(false)
const total = ref(0)
const dateRange = ref<[string, string]>()
const viewDialog = reactive({
visible: false,
data: {} as ApprovalVO
})
function approvalResultTag(result?: string) {
if (result === 'approved') return { label: '通过', type: 'success' as const }
if (result === 'rejected') return { label: '驳回', type: 'danger' as const }
return { label: '待审批', type: 'warning' as const }
}
const approvalViewSections = computed<ViewSection[]>(() => {
const d = viewDialog.data
if (!d?.id && !d?.contractNo) return []
const result = approvalResultTag(d.approvalResult)
const basicFields: ViewField[] = [
crmField('合同名称', d.contractName),
crmField('审批流程 ID', d.flowId),
crmField('审批级别', d.step != null ? `第${d.step}级` : undefined),
crmField('步骤名称', d.stepName),
crmField('审批人部门', d.approverDept),
crmField('审批人', d.approverName),
crmTagField('审批结果', result.label, result.type)
]
const detailFields: ViewField[] = [
crmLongField('审批意见', d.approvalOpinion, { fullSpan: true }),
crmField('审批时间', parseTime(d.approvalTime)),
crmField('创建时间', parseTime(d.createTime)),
crmLongField('备注', d.remark, { fullSpan: true })
]
return [
{ title: '基本信息', fields: basicFields },
{ title: '审批详情', fields: detailFields }
]
})
const approvalDialog = reactive({
visible: false
})
const queryFormRef = ref<ElFormInstance>()
const approvalFormRef = ref<ElFormInstance>()
const getList = async () => {
loading.value = true
try {
if (dateRange.value && dateRange.value.length === 2) {
queryParams.value.beginTime = dateRange.value[0]
queryParams.value.endTime = dateRange.value[1]
} else {
queryParams.value.beginTime = undefined
queryParams.value.endTime = undefined
}
const res = await listApproval(queryParams.value)
approvalList.value = res.rows
total.value = res.total
} finally {
loading.value = false
}
}
const handleQuery = () => {
quickSearchKeyword.value = ''
queryParams.value.pageNum = 1
getList()
}
const resetQuery = () => {
dateRange.value = undefined
quickSearchKeyword.value = ''
queryFormRef.value?.resetFields()
handleQuery()
}
const handleQuickSearch = () => {
const keyword = quickSearchKeyword.value?.trim()
if (keyword) {
queryParams.value.contractNo = keyword
queryParams.value.contractName = keyword
queryParams.value.approverName = keyword
}
queryParams.value.pageNum = 1
getList()
}
const handleQuickSearchClear = () => {
quickSearchKeyword.value = ''
queryParams.value.contractNo = undefined
queryParams.value.contractName = undefined
queryParams.value.approverName = undefined
queryParams.value.pageNum = 1
getList()
}
const handleSelectionChange = (rows: ApprovalVO[]) => {
selectedRows.value = rows
}
const handleView = async (row: ApprovalVO) => {
const res = await getApproval(row.id)
viewDialog.data = res.data
viewDialog.visible = true
}
const handleViewContract = (row: ApprovalVO) => {
router.push({
path: '/crm/contract/detail',
query: { id: row.contractId }
})
}
const DEFAULT_OPINIONS = ['审批通过', '审批驳回'] as const
const defaultOpinion = (result: string) => (result === 'rejected' ? '审批驳回' : '审批通过')
watch(
() => approvalForm.value.approvalResult,
(result) => {
if (
!approvalForm.value.approvalOpinion.trim() ||
DEFAULT_OPINIONS.includes(
approvalForm.value.approvalOpinion as (typeof DEFAULT_OPINIONS)[number]
)
) {
approvalForm.value.approvalOpinion = defaultOpinion(result)
}
}
)
const handleApprove = (row: ApprovalVO) => {
approvalForm.value = {
id: row.id,
approvalResult: 'approved',
approvalOpinion: defaultOpinion('approved')
}
approvalDialog.visible = true
}
const submitApproval = () => {
approvalFormRef.value?.validate(async (valid) => {
if (!valid) return
submitLoading.value = true
try {
if (approvalForm.value.approvalResult === 'approved') {
await approvePass({
id: approvalForm.value.id!,
approvalOpinion: approvalForm.value.approvalOpinion
})
$modal.msgSuccess('审批通过')
} else {
await approveReject({
id: approvalForm.value.id!,
approvalOpinion: approvalForm.value.approvalOpinion
})
$modal.msgSuccess('已驳回')
}
approvalDialog.visible = false
await getList()
await refreshViewDialogIfOpen()
} catch (error) {
console.error(error)
} finally {
submitLoading.value = false
}
})
}
async function refreshViewDialogIfOpen() {
if (!viewDialog.visible || !viewDialog.data?.id) return
const res = await getApproval(viewDialog.data.id)
viewDialog.data = res.data
}
const handleExport = async () => {
if (dateRange.value && dateRange.value.length === 2) {
queryParams.value.beginTime = dateRange.value[0]
queryParams.value.endTime = dateRange.value[1]
} else {
queryParams.value.beginTime = undefined
queryParams.value.endTime = undefined
}
exportLoading.value = true
try {
const res = await exportApproval(queryParams.value)
const blob =
res instanceof Blob
? res
: new Blob([res as BlobPart], {
type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
})
const url = URL.createObjectURL(blob)
const link = document.createElement('a')
link.href = url
link.download = `contract_approval_${new Date().getTime()}.xlsx`
link.click()
URL.revokeObjectURL(url)
} catch (error) {
console.error(error)
$modal.msgError('导出失败')
} finally {
exportLoading.value = false
}
}
onMounted(() => {
getList()
})
watchDebounced(
() => {
const snapshot: Record<string, unknown> = {
approvalResult: queryParams.value.approvalResult,
dateRange: dateRange.value
}
if (!quickSearchKeyword.value.trim()) {
snapshot.contractNo = queryParams.value.contractNo
snapshot.contractName = queryParams.value.contractName
snapshot.approverName = queryParams.value.approverName
}
return snapshot
},
() => {
quickSearchKeyword.value = ''
queryParams.value.pageNum = 1
getList()
},
{ debounce: 300, deep: true }
)
</script>
@@ -1,600 +1,7 @@
<!-- 合同审批记录 -->
<template>
<div class="page-container">
<section class="panel">
<div class="panel-top">
<h2 class="title-bar-heading">合同审批记录</h2>
</div>
<div class="filter-block">
<el-form ref="queryFormRef" :model="queryParams" class="filter-form" @submit.prevent>
<div class="filter-grid">
<el-form-item label="合同编号" prop="contractNo">
<el-input
v-model="queryParams.contractNo"
placeholder="合同编号"
clearable
@keyup.enter="handleQuery"
/>
</el-form-item>
<el-form-item label="合同名称" prop="contractName">
<el-input
v-model="queryParams.contractName"
placeholder="合同名称"
clearable
@keyup.enter="handleQuery"
/>
</el-form-item>
<el-form-item label="审批人" prop="approverName">
<el-input
v-model="queryParams.approverName"
placeholder="审批人"
clearable
@keyup.enter="handleQuery"
/>
</el-form-item>
<el-form-item label="审批结果" prop="approvalResult">
<el-select v-model="queryParams.approvalResult" placeholder="全部" clearable>
<el-option label="通过" value="approved" />
<el-option label="驳回" value="rejected" />
<el-option label="待审批" value="pending" />
</el-select>
</el-form-item>
<el-form-item label="审批时间" class="form-col-span-2">
<el-date-picker
v-model="dateRange"
type="daterange"
range-separator="-"
start-placeholder="开始日期"
end-placeholder="结束日期"
value-format="YYYY-MM-DD"
style="width: 100%"
/>
</el-form-item>
</div>
<div class="filter-actions-row">
<span class="filter-hint">按合同、审批人、结果及时间筛选。</span>
<div class="filter-actions-end">
<el-button class="btn-ghost" :loading="loading" @click="resetQuery">
<el-icon><RefreshLeft /></el-icon>重置
</el-button>
<el-button class="btn-main" type="primary" :loading="loading" @click="handleQuery">
<el-icon><Search /></el-icon>搜索
</el-button>
</div>
</div>
</el-form>
</div>
<div class="list-toolbar">
<div class="list-toolbar-row">
<ListQuickSearchInput
v-model="quickSearchKeyword"
placeholder="合同编号/合同名称/审批人"
@search="handleQuickSearch"
@clear="handleQuickSearchClear"
/>
<el-button
class="btn-ghost"
:loading="exportLoading"
@click="handleExport"
>
<el-icon><Download /></el-icon>导出
</el-button>
<ListToolbarEndActions
:loading="loading"
:column-defs="listColumnDefs"
v-model:visible-columns="visibleColumns"
v-model:check-all="checkAll"
:is-indeterminate="isIndeterminate"
@refresh="getList"
@reset-columns="resetToDefault"
/>
</div>
</div>
<div class="list-body list-wrap">
<ListTable table-key="crm-contract-approval"
class="list-table"
v-loading="loading"
:data="approvalList"
stripe
row-key="id"
@row-dblclick="handleView"
@selection-change="handleSelectionChange"
>
<el-table-column type="selection" min-width="55" align="center" header-align="center" />
<el-table-column
type="index"
label="序号"
min-width="68"
align="center"
header-align="center"
:index="(index) => (queryParams.pageNum - 1) * queryParams.pageSize + index + 1"
/>
<el-table-column
prop="contractNo"
label="合同编号"
min-width="150"
align="center"
header-align="center"
show-overflow-tooltip
>
<template #default="{ row }">
<el-link type="primary" @click="handleViewContract(row)">{{
row.contractNo
}}</el-link>
</template>
</el-table-column>
<el-table-column
v-if="isColumnVisible('contractName')"
prop="contractName"
label="合同名称"
min-width="240"
align="left"
header-align="left"
class-name="col-name-wrap"
label-class-name="col-name-wrap"
/>
<el-table-column label="审批级别" v-if="isColumnVisible('step')" min-width="100" align="center" header-align="center">
<template #default="{ row }">第{{ row.step }}级</template>
</el-table-column>
<el-table-column
v-if="isColumnVisible('approverName')"
prop="approverName"
label="审批人"
min-width="120"
align="center"
header-align="center"
/>
<el-table-column label="审批结果" v-if="isColumnVisible('approvalResult')" min-width="100" align="center" header-align="center">
<template #default="{ row }">
<el-tag v-if="row.approvalResult === 'approved'" type="success" size="small"
>通过</el-tag
>
<el-tag v-else-if="row.approvalResult === 'rejected'" type="danger" size="small"
>驳回</el-tag
>
<el-tag v-else type="warning" size="small">待审批</el-tag>
</template>
</el-table-column>
<el-table-column
v-if="isColumnVisible('approvalOpinion')"
prop="approvalOpinion"
label="审批意见"
min-width="200"
align="center"
header-align="center"
show-overflow-tooltip
/>
<el-table-column label="审批时间" v-if="isColumnVisible('approvalTime')" min-width="160" align="center" header-align="center">
<template #default="{ row }">{{ parseTime(row.approvalTime) }}</template>
</el-table-column>
</ListTable>
<div class="pagination list-pager-bar">
<el-pagination
v-model:current-page="queryParams.pageNum"
v-model:page-size="queryParams.pageSize"
:page-sizes="[10, 20, 30, 50]"
layout="total, sizes, prev, pager, next, jumper"
:total="total"
@size-change="getList"
@current-change="getList"
/>
</div>
</div>
<SystemViewDialog
v-model:visible="viewDialog.visible"
title="审批详情"
:icon="Document"
:code="viewDialog.data.contractNo"
code-label="合同编号"
:meta="viewDialog.data.contractName"
:sections="approvalViewSections"
append-to-body
>
<template #hero-actions>
<div class="approval-view-hero-actions">
<el-button
v-if="viewDialog.data.approvalResult === 'pending'"
class="btn-main"
type="primary"
@click="handleApprove(viewDialog.data)"
>
<el-icon><EditPen /></el-icon>审批
</el-button>
</div>
</template>
</SystemViewDialog>
<el-dialog
v-model="approvalDialog.visible"
title="审批"
width="600px"
class="dialog-form-layout"
modal-class="order-module-dialog-mask"
align-center
destroy-on-close
:close-on-click-modal="false"
append-to-body
>
<el-form
ref="approvalFormRef"
:model="approvalForm"
:rules="approvalRules"
label-position="right"
label-width="100px"
class="crm-dialog-form"
scroll-to-error
>
<div class="form-grid-2">
<el-form-item label="审批结果" prop="approvalResult" class="form-col-span-2">
<el-radio-group v-model="approvalForm.approvalResult">
<el-radio value="approved">通过</el-radio>
<el-radio value="rejected">驳回</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="审批意见" prop="approvalOpinion" class="form-col-span-2">
<el-input
v-model="approvalForm.approvalOpinion"
type="textarea"
:rows="5"
:placeholder="
approvalForm.approvalResult === 'rejected'
? '请输入驳回原因'
: '请输入审批意见(可选)'
"
/>
</el-form-item>
</div>
</el-form>
<template #footer>
<el-button class="btn-ghost" @click="approvalDialog.visible = false">
<el-icon><Close /></el-icon>取消
</el-button>
<el-button
class="btn-main"
type="primary"
:loading="submitLoading"
@click="submitApproval"
>
<el-icon><Check /></el-icon>确定
</el-button>
</template>
</el-dialog>
</section>
</div>
<ContractListPage mode="approve" />
</template>
<script setup lang="ts" name="ContractApproval">
import ListToolbarEndActions from '@/components/business/list-toolbar-end-actions/index.vue'
import { usePersistedListColumns } from '@/composables/usePersistedListColumns'
import { ref, reactive, computed, onMounted, watch } from 'vue'
import { watchDebounced } from '@vueuse/core'
import { useRouter } from 'vue-router'
import {
Document,
Download,
Search,
RefreshLeft,
Close,
Check,
EditPen
} from '@element-plus/icons-vue'
import SystemViewDialog, {
type ViewField,
type ViewSection
} from '@/components/business/system-view-dialog/index.vue'
import { crmField, crmLongField, crmTagField } from '@/utils/crm/view-fields'
import {
listApproval,
getApproval,
approvePass,
approveReject,
exportApproval,
type ApprovalQuery,
type ApprovalVO
} from '@/api/crm/contract/approval'
import { parseTime } from '@/utils/format'
import { $modal } from '@/utils/modal'
import ListQuickSearchInput from '@/components/business/list-quick-search-input/index.vue'
const router = useRouter()
const quickSearchKeyword = ref('')
const listColumnDefs = [
{ prop: 'contractName', label: '合同名称' },
{ prop: 'step', label: '审批级别' },
{ prop: 'approverName', label: '审批人' },
{ prop: 'approvalResult', label: '审批结果' },
{ prop: 'approvalOpinion', label: '审批意见' },
{ prop: 'approvalTime', label: '审批时间' }
]
const {
visibleColumns,
checkAll,
isIndeterminate,
isColumnVisible,
resetToDefault
} = usePersistedListColumns('crm_contract_approval_visible_columns', listColumnDefs)
const queryParams = ref<ApprovalQuery>({
pageNum: 1,
pageSize: 20,
contractNo: undefined,
contractName: undefined,
approverName: undefined,
approvalResult: undefined,
beginTime: undefined,
endTime: undefined
})
const approvalForm = ref({
id: undefined as number | undefined,
approvalResult: 'approved',
approvalOpinion: ''
})
const approvalRules = ref({
approvalResult: [{ required: true, message: '请选择审批结果', trigger: 'change' }],
approvalOpinion: [
{
validator: (_rule: unknown, value: string, callback: (err?: Error) => void) => {
if (approvalForm.value.approvalResult === 'rejected' && !value) {
callback(new Error('驳回时必须填写驳回原因'))
} else {
callback()
}
},
trigger: 'blur'
}
]
})
const approvalList = ref<ApprovalVO[]>([])
const loading = ref(true)
const selectedRows = ref<ApprovalVO[]>([])
const submitLoading = ref(false)
const exportLoading = ref(false)
const total = ref(0)
const dateRange = ref<[string, string]>()
const viewDialog = reactive({
visible: false,
data: {} as ApprovalVO
})
function approvalResultTag(result?: string) {
if (result === 'approved') return { label: '通过', type: 'success' as const }
if (result === 'rejected') return { label: '驳回', type: 'danger' as const }
return { label: '待审批', type: 'warning' as const }
}
const approvalViewSections = computed<ViewSection[]>(() => {
const d = viewDialog.data
if (!d?.id && !d?.contractNo) return []
const result = approvalResultTag(d.approvalResult)
const basicFields: ViewField[] = [
crmField('合同名称', d.contractName),
crmField('审批流程 ID', d.flowId),
crmField('审批级别', d.step != null ? `第${d.step}级` : undefined),
crmField('步骤名称', d.stepName),
crmField('审批人部门', d.approverDept),
crmField('审批人', d.approverName),
crmTagField('审批结果', result.label, result.type)
]
const detailFields: ViewField[] = [
crmLongField('审批意见', d.approvalOpinion, { fullSpan: true }),
crmField('审批时间', parseTime(d.approvalTime)),
crmField('创建时间', parseTime(d.createTime)),
crmLongField('备注', d.remark, { fullSpan: true })
]
return [
{ title: '基本信息', fields: basicFields },
{ title: '审批详情', fields: detailFields }
]
})
const approvalDialog = reactive({
visible: false
})
const queryFormRef = ref<ElFormInstance>()
const approvalFormRef = ref<ElFormInstance>()
const getList = async () => {
loading.value = true
try {
if (dateRange.value && dateRange.value.length === 2) {
queryParams.value.beginTime = dateRange.value[0]
queryParams.value.endTime = dateRange.value[1]
} else {
queryParams.value.beginTime = undefined
queryParams.value.endTime = undefined
}
const res = await listApproval(queryParams.value)
approvalList.value = res.rows
total.value = res.total
} finally {
loading.value = false
}
}
const handleQuery = () => {
quickSearchKeyword.value = ''
queryParams.value.pageNum = 1
getList()
}
const resetQuery = () => {
dateRange.value = undefined
quickSearchKeyword.value = ''
queryFormRef.value?.resetFields()
handleQuery()
}
const handleQuickSearch = () => {
const keyword = quickSearchKeyword.value?.trim()
if (keyword) {
queryParams.value.contractNo = keyword
queryParams.value.contractName = keyword
queryParams.value.approverName = keyword
}
queryParams.value.pageNum = 1
getList()
}
const handleQuickSearchClear = () => {
quickSearchKeyword.value = ''
queryParams.value.contractNo = undefined
queryParams.value.contractName = undefined
queryParams.value.approverName = undefined
queryParams.value.pageNum = 1
getList()
}
const handleSelectionChange = (rows: ApprovalVO[]) => {
selectedRows.value = rows
}
const handleView = async (row: ApprovalVO) => {
const res = await getApproval(row.id)
viewDialog.data = res.data
viewDialog.visible = true
}
const handleViewContract = (row: ApprovalVO) => {
router.push({
path: '/crm/contract/detail',
query: { id: row.contractId }
})
}
const DEFAULT_OPINIONS = ['审批通过', '审批驳回'] as const
const defaultOpinion = (result: string) => (result === 'rejected' ? '审批驳回' : '审批通过')
watch(
() => approvalForm.value.approvalResult,
(result) => {
if (
!approvalForm.value.approvalOpinion.trim() ||
DEFAULT_OPINIONS.includes(
approvalForm.value.approvalOpinion as (typeof DEFAULT_OPINIONS)[number]
)
) {
approvalForm.value.approvalOpinion = defaultOpinion(result)
}
}
)
const handleApprove = (row: ApprovalVO) => {
approvalForm.value = {
id: row.id,
approvalResult: 'approved',
approvalOpinion: defaultOpinion('approved')
}
approvalDialog.visible = true
}
const submitApproval = () => {
approvalFormRef.value?.validate(async (valid) => {
if (!valid) return
submitLoading.value = true
try {
if (approvalForm.value.approvalResult === 'approved') {
await approvePass({
id: approvalForm.value.id!,
approvalOpinion: approvalForm.value.approvalOpinion
})
$modal.msgSuccess('审批通过')
} else {
await approveReject({
id: approvalForm.value.id!,
approvalOpinion: approvalForm.value.approvalOpinion
})
$modal.msgSuccess('已驳回')
}
approvalDialog.visible = false
await getList()
await refreshViewDialogIfOpen()
} catch (error) {
console.error(error)
} finally {
submitLoading.value = false
}
})
}
async function refreshViewDialogIfOpen() {
if (!viewDialog.visible || !viewDialog.data?.id) return
const res = await getApproval(viewDialog.data.id)
viewDialog.data = res.data
}
const handleExport = async () => {
if (dateRange.value && dateRange.value.length === 2) {
queryParams.value.beginTime = dateRange.value[0]
queryParams.value.endTime = dateRange.value[1]
} else {
queryParams.value.beginTime = undefined
queryParams.value.endTime = undefined
}
exportLoading.value = true
try {
const res = await exportApproval(queryParams.value)
const blob =
res instanceof Blob
? res
: new Blob([res as BlobPart], {
type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
})
const url = URL.createObjectURL(blob)
const link = document.createElement('a')
link.href = url
link.download = `contract_approval_${new Date().getTime()}.xlsx`
link.click()
URL.revokeObjectURL(url)
} catch (error) {
console.error(error)
$modal.msgError('导出失败')
} finally {
exportLoading.value = false
}
}
onMounted(() => {
getList()
})
watchDebounced(
() => {
const snapshot: Record<string, unknown> = {
approvalResult: queryParams.value.approvalResult,
dateRange: dateRange.value
}
if (!quickSearchKeyword.value.trim()) {
snapshot.contractNo = queryParams.value.contractNo
snapshot.contractName = queryParams.value.contractName
snapshot.approverName = queryParams.value.approverName
}
return snapshot
},
() => {
quickSearchKeyword.value = ''
queryParams.value.pageNum = 1
getList()
},
{ debounce: 300, deep: true }
)
<script setup lang="ts" name="CrmContractApproval">
import ContractListPage from '../ContractListPage.vue'
</script>
@@ -1,9 +1,6 @@
<template>
<div class="page-container">
<section class="panel">
<div class="panel-top">
<h2 class="title-bar-heading">合同审批人设置</h2>
</div>
<div class="panel-body contract-approver-setting-body">
<el-form ref="formRef" :model="form" label-position="top" class="crm-dialog-form">
<div class="form-grid-2">
@@ -2,10 +2,6 @@
<template>
<div class="page-container">
<section class="panel">
<div class="panel-top">
<h2 class="title-bar-heading">合同变更</h2>
</div>
<div class="filter-block">
<el-form ref="queryFormRef" :model="queryParams" class="filter-form" @submit.prevent>
<div class="filter-grid">
@@ -121,8 +121,10 @@ import {
downloadCrmAttachment,
isCrmImageFile,
isCrmPdfFile,
openCrmAttachmentPreviewInNewTab,
resolveCrmAttachmentUrl
} from '@/utils/crm-attachment'
import { resolveAttachmentPreviewUrl } from '@/utils/download-attachment'
import { buildAttachmentUploadFormData, type CrmUploadBizType } from '@/utils/crm-upload'
const props = withDefaults(
@@ -263,13 +265,30 @@ const handleAttachmentUpload = async (options: UploadRequestOptions) => {
}
}
const handleFilePreview = (file: ContractAttachmentItem) => {
const handleFilePreview = async (file: ContractAttachmentItem) => {
if (!canPreviewAttachment(file)) {
$modal.msgWarning('文件尚未上传完成')
return
}
// 本地未上传完的图片仍用弹窗;已落库附件走新标签页(与列表/详情一致)
if (file.localPreview && !getAttachmentOssId(file)) {
attachmentPreviewFile.value = file
attachmentPreviewSrc.value = file.localPreview
attachmentPreviewVisible.value = true
return
}
if (getAttachmentOssId(file) && (isCrmImageFile(file) || isCrmPdfFile(file))) {
await openCrmAttachmentPreviewInNewTab(file)
return
}
attachmentPreviewFile.value = file
attachmentPreviewSrc.value = resolveAttachmentPreviewSrc(file)
const ossId = getAttachmentOssId(file)
attachmentPreviewSrc.value = ossId
? await resolveAttachmentPreviewUrl(
{ fileUrl: ossId, fileName: file.name },
{ fullFileUrl: resolveCrmAttachmentUrl }
)
: resolveAttachmentPreviewSrc(file)
attachmentPreviewVisible.value = true
}
@@ -31,45 +31,18 @@
</div>
<div class="detail-actions">
<el-button
v-if="isContractEditableStatus(detailContract?.status)"
v-if="manageActions && isContractEditableStatus(detailContract?.status)"
class="btn-ghost"
@click="handleDetailEdit"
>
<el-icon><Edit /></el-icon>修改
</el-button>
<el-button
v-if="
detailContract?.status === 'draft' &&
canDeleteByCreator(detailContract)
"
class="btn-ghost"
@click="handleDetailDelete"
:disabled="detailContract?.contractTemplate === 'customer'"
@click="handleDetailPrint"
>
<el-icon><Delete /></el-icon>删除
</el-button>
<el-button
v-if="detailContract?.status === 'draft'"
class="btn-ghost"
@click="handleDetailSubmit"
>
<el-icon><Promotion /></el-icon>提交审批
</el-button>
<el-button
v-if="
detailContract?.status === 'approved' &&
detailContract?.approvalStatus === 'approved'
"
class="btn-ghost"
@click="handleDetailExecute"
>
<el-icon><VideoPlay /></el-icon>开始执行
</el-button>
<el-button
v-if="detailContract?.status === 'executing'"
class="btn-ghost"
@click="handleDetailComplete"
>
<el-icon><CircleCheck /></el-icon>完成合同
<el-icon><Printer /></el-icon>打印
</el-button>
<el-button
v-if="
@@ -81,11 +54,40 @@
<el-icon><CircleClose /></el-icon>作废
</el-button>
<el-button
v-if="
manageActions &&
detailContract?.status === 'approved' &&
detailContract?.approvalStatus === 'approved'
"
class="btn-ghost"
:disabled="detailContract?.contractTemplate === 'customer'"
@click="handleDetailPrint"
@click="handleDetailExecute"
>
<el-icon><Printer /></el-icon>打印
<el-icon><VideoPlay /></el-icon>开始执行
</el-button>
<el-button
v-if="
manageActions &&
detailContract?.status === 'draft' &&
canDeleteByCreator(detailContract)
"
class="btn-ghost"
@click="handleDetailDelete"
>
<el-icon><Delete /></el-icon>删除
</el-button>
<el-button
v-if="manageActions && detailContract?.status === 'draft'"
class="btn-ghost"
@click="handleDetailSubmit"
>
<el-icon><Promotion /></el-icon>提交审批
</el-button>
<el-button
v-if="manageActions && detailContract?.status === 'executing'"
class="btn-ghost"
@click="handleDetailComplete"
>
<el-icon><CircleCheck /></el-icon>完成合同
</el-button>
</div>
</div>
@@ -98,7 +100,7 @@
<h3>基本信息</h3>
<ViewKvTable
:fields="detailBasicViewFields"
mode="triple"
mode="quad"
@field-view="handleBasicFieldView"
/>
<p v-if="detailContract.contractTemplate === 'customer'" class="contract-template-hint">
@@ -183,12 +185,12 @@
<span>{{ row.standardProductName || row.productName || '—' }}</span>
</template>
</el-table-column>
<el-table-column label="别名" min-width="120" :show-overflow-tooltip="true">
<el-table-column label="别名" min-width="80" :show-overflow-tooltip="true">
<template #default="{ row }">
<span>{{ row.aliasName || '—' }}</span>
</template>
</el-table-column>
<el-table-column label="品牌" min-width="100" :show-overflow-tooltip="true">
<el-table-column label="品牌" min-width="72" :show-overflow-tooltip="true">
<template #default="{ row }">
<span>{{ formatBrandConstraintLabel(row.brandMode, row.brandName) }}</span>
</template>
@@ -199,17 +201,17 @@
</template>
</el-table-column>
<el-table-column label="产品分类" prop="categoryName" min-width="110" :show-overflow-tooltip="true" />
<el-table-column label="税率(%)" prop="taxRate" width="110" align="center">
<el-table-column label="税率(%)" prop="taxRate" min-width="72" align="center">
<template #default="scope">
<span>{{ scope.row.taxRate || 0 }}%</span>
</template>
</el-table-column>
<el-table-column label="单位" prop="unit" width="80" align="center">
<el-table-column label="单位" prop="unit" min-width="56" align="center">
<template #default="scope">
<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" min-width="72" align="right" />
<el-table-column
v-if="!hideProductPrice"
label="含税单价(元)"
@@ -313,23 +315,11 @@
</div>
</template>
<!-- 合计金额 -->
<!-- 合计金额:合计总金额 = 合计金额 + 运费 + 桶押金 -->
<template v-if="!hideProductPrice">
<el-divider />
<div class="total-section">
<el-row :gutter="20">
<el-col :span="16"></el-col>
<el-col :span="8">
<div class="total-item">
<span class="total-label">合计金额(元):</span>
<span class="total-value money-display"
>¥{{
parseFloat(detailContract.amount || 0).toLocaleString('zh-CN', { minimumFractionDigits: 2, maximumFractionDigits: 2 })
}}</span
>
</div>
</el-col>
</el-row>
<ViewKvTable :fields="detailTotalSummaryFields" mode="quad" />
</div>
<!-- 金额统计 -->
@@ -748,11 +738,15 @@
</template>
<div v-if="detailReadonlyAttachmentList.length > 0" class="detail-attachment-list">
<div v-for="(file, index) in detailReadonlyAttachmentList" :key="`${file.ossId}-${index}`" class="detail-attachment-item">
<div class="detail-attachment-preview">
<div
class="detail-attachment-preview"
:title="isDetailImageFile(file) || isDetailPdfFile(file) ? '点击在新标签页查看' : '点击查看'"
@click.stop="handleDetailPreviewFile(file)"
>
<ImagePreview
v-if="isDetailImageFile(file)"
:src="file.ossId"
class="detail-attachment-thumb-img"
class="detail-attachment-thumb-img detail-attachment-thumb-img--passive"
:isOssId="true"
/>
<div v-else class="detail-attachment-preview__icon detail-attachment-preview__icon--doc">
@@ -764,6 +758,10 @@
<span class="detail-attachment-name" :title="getDetailDisplayFileName(file)">{{ getDetailShortFileName(getDetailDisplayFileName(file)) }}</span>
<div class="detail-attachment-category">{{ getDetailAttachmentCategoryLabel(file.category) }}</div>
<div class="detail-attachment-actions">
<el-button type="primary" size="small" @click.stop="handleDetailPreviewFile(file)">
<el-icon><View /></el-icon>
查看
</el-button>
<el-button type="success" size="small" @click.stop="handleDetailDownloadFile(file)">
<el-icon><Download /></el-icon>
下载
@@ -916,6 +914,8 @@ import { fitRichTextTablesToMaxWidth } from '@/utils/tinymce-table-excel-resize'
import {
downloadCrmAttachment,
getCrmAttachmentCategoryLabel,
isCrmPdfFile,
openCrmAttachmentPreviewInNewTab,
resolveCrmAttachmentFiles
} from '@/utils/crm-attachment';
@@ -925,9 +925,12 @@ const router = useRouter();
const props = withDefaults(
defineProps<{
hideProductPrice?: boolean
/** 是否展示制单/履约类操作(修改、删除、提交审批、执行等) */
manageActions?: boolean
}>(),
{
hideProductPrice: false
hideProductPrice: false,
manageActions: true
}
)
@@ -1332,8 +1335,6 @@ const handleDetailPrint = async () => {
console.warn('⚠️ 获取最新合同数据失败,使用详情抽屉中的数据:', fetchError);
}
const quoteFreight = await fetchQuoteFreight(contractData.quoteId);
// 先尝试从数据库获取已保存的模板
let htmlContent = '';
try {
@@ -1358,7 +1359,7 @@ const handleDetailPrint = async () => {
// 统一用数据库最新数据替换占位符(无论模板来自数据库还是新生成的,都可能含占位符)
try {
htmlContent = replacePlaceholders(htmlContent, contractData, quoteFreight);
htmlContent = replacePlaceholders(htmlContent, contractData);
console.log('占位符替换完成');
} catch (replaceError) {
console.error('替换占位符失败,使用原始内容:', replaceError);
@@ -1427,6 +1428,22 @@ const formatDetailAmount = (amount: number | undefined): string => {
return amount.toLocaleString('zh-CN', { minimumFractionDigits: 2, maximumFractionDigits: 2 });
};
/** 产品明细下方合计:合计总金额 = 合计金额(产品)+ 运费 + 桶押金 */
const detailTotalSummaryFields = computed<ViewField[]>(() => {
const c = detailContract.value
if (!c) return []
const productAmount = Number(c.amount) || 0
const freight = Number(c.freight) || 0
const barrelDeposit = Number(c.barrelDeposit) || 0
const grandTotal = productAmount + freight + barrelDeposit
return [
{ label: '合计总金额(元)', value: `¥${formatDetailAmount(grandTotal)}`, money: true },
{ label: '合计金额(元)', value: `¥${formatDetailAmount(productAmount)}`, money: true },
{ label: '运费(元)', value: `¥${formatDetailAmount(freight)}`, money: true },
{ label: '桶押金(元)', value: `¥${formatDetailAmount(barrelDeposit)}`, money: true }
]
})
function detailTagField(
label: string,
dictType: string,
@@ -1475,7 +1492,11 @@ const detailBasicViewFields = computed<ViewField[]>(() => {
{ label: '负责人', value: c.ownerUserName },
...(props.hideProductPrice
? []
: [{ label: '合同金额(元)', value: `¥${formatDetailAmount(c.amount)}`, money: true }]),
: [
{ label: '合同金额(元)', value: `¥${formatDetailAmount(c.amount)}`, money: true },
{ label: '运费(元)', value: `¥${formatDetailAmount(c.freight)}`, money: true },
{ label: '桶押金(元)', value: `¥${formatDetailAmount(c.barrelDeposit)}`, money: true }
]),
{ label: '交易主体', value: c.supplierName },
{
label: '结算方式',
@@ -1591,6 +1612,13 @@ const isDetailImageFile = (file: any) => {
return imageExts.includes(ext);
};
const isDetailPdfFile = (file: any) =>
isCrmPdfFile({
name: getDetailDisplayFileName(file),
ossId: file?.ossId,
url: file?.url
});
/** 详情抽屉 - 获取文件扩展名 */
const getDetailFileExt = (fileName: string) => {
if (!fileName) return 'FILE';
@@ -1650,6 +1678,14 @@ const handleDetailDownloadTierLetter = (ossId: string | number | undefined) => {
handleDetailDownloadFile({ ossId: String(ossId), name: '调价函' });
};
/** 详情抽屉 - 新标签页预览 */
const handleDetailPreviewFile = async (file: any) => {
await openCrmAttachmentPreviewInNewTab({
...file,
name: getDetailDisplayFileName(file)
});
};
/** 详情抽屉 - 下载文件 */
const handleDetailDownloadFile = async (file: any) => {
if (!file.ossId && !file.url) {
@@ -1666,25 +1702,12 @@ const handleDetailDownloadFile = async (file: any) => {
}
};
/** 获取合同关联报价单的运费(无关联或获取失败时返回 0) */
const fetchQuoteFreight = async (quoteId?: number): Promise<number> => {
if (!quoteId) return 0;
try {
const quoteRes = await getQuote(quoteId);
const freight = Number(quoteRes?.data?.freight);
return Number.isFinite(freight) && freight > 0 ? freight : 0;
} catch (error) {
console.warn('获取报价单运费失败:', error);
return 0;
}
};
/** 产品明细中是否含「自提」送货方式(字典 crm_shfs) */
const hasSelfPickupProduct = (products?: Array<{ deliveryMethod?: string }> | null): boolean =>
!!products?.some((p) => String(p.deliveryMethod || '').trim() === '自提');
/** 替换模板中的占位符为数据库最新数据 */
const replacePlaceholders = (htmlContent: string, contractData: ContractVO | undefined, quoteFreight = 0): string => {
/** 替换模板中的占位符为数据库最新数据(运费取合同自身 freight) */
const replacePlaceholders = (htmlContent: string, contractData: ContractVO | undefined): string => {
if (!htmlContent || !contractData) return htmlContent;
let result = htmlContent;
@@ -1936,21 +1959,31 @@ const replacePlaceholders = (htmlContent: string, contractData: ContractVO | und
}
// 替换产品合计行(左侧运费,右侧合计=产品金额+运费)
const freightAmount = Number(quoteFreight) || 0;
const totalWithFreight = productTotal + freightAmount;
const totalWithFreightChinese = numberToChinese(totalWithFreight);
// 合计区(11 列):第 1 行左右对半运费/桶押金;第 2 行合计;第 3 行提示
const freightRaw = Number(contractData.freight);
const freightAmount = Number.isFinite(freightRaw) && freightRaw > 0 ? freightRaw : 0;
const depositRaw = Number(contractData.barrelDeposit);
const barrelDepositAmount = Number.isFinite(depositRaw) && depositRaw > 0 ? depositRaw : 0;
const totalWithExtras = productTotal + freightAmount + barrelDepositAmount;
const totalWithExtrasChinese = numberToChinese(totalWithExtras);
const freightText = freightAmount > 0 ? `¥${formatNumber(freightAmount)}` : '-';
const totalWithFreightText = isFrameworkContract ? '随行就市' : `${totalWithFreightChinese}(¥${formatNumber(totalWithFreight)})`;
const barrelDepositText = barrelDepositAmount > 0 ? `¥${formatNumber(barrelDepositAmount)}` : '-';
const totalWithExtrasText = isFrameworkContract
? '随行就市'
: `${totalWithExtrasChinese}(¥${formatNumber(totalWithExtras)})`;
const tipRowText = hasSelfPickupProduct(contractData.products)
? '含税、客户自提结算以实际到货吨位为准'
: '含税、含运费、装卸费(一票制)&nbsp;&nbsp;&nbsp;&nbsp;结算以实际到货吨位为准';
const productTotalRow = `
<tr style="background-color: #fff; font-weight: bold;">
<td colspan="2" style="padding: 5px 6px; border: 0.3px solid #000; text-align: center; font-size: 12px;">运费</td>
<td colspan="2" style="padding: 5px 6px; border: 0.3px solid #000; text-align: center; font-size: 12px;">${freightText}</td>
<td colspan="2" style="padding: 5px 6px; border: 0.3px solid #000; text-align: center; font-size: 12px;">运费(元)</td>
<td colspan="4" style="padding: 5px 6px; border: 0.3px solid #000; text-align: center; font-size: 12px;">${freightText}</td>
<td colspan="2" style="padding: 5px 6px; border: 0.3px solid #000; text-align: center; font-size: 12px;">桶押金(元)</td>
<td colspan="3" style="padding: 5px 6px; border: 0.3px solid #000; text-align: center; font-size: 12px;">${barrelDepositText}</td>
</tr>
<tr style="background-color: #fff; font-weight: bold;">
<td colspan="2" style="padding: 5px 6px; border: 0.3px solid #000; text-align: center; font-size: 12px;">合计(人民币)</td>
<td colspan="5" style="padding: 5px 6px; border: 0.3px solid #000; text-align: center; font-size: 12px;">${totalWithFreightText}</td>
<td colspan="9" style="padding: 5px 6px; border: 0.3px solid #000; text-align: center; font-size: 12px;">${totalWithExtrasText}</td>
</tr>
<tr>
<td colspan="11" style="padding: 5px 6px; border: 0.3px solid #000; text-align: center; font-size: 11px; background-color: #fff;">
@@ -2460,8 +2493,10 @@ const handleSaveTemplate = async () => {
const productTableMatch = templateWithPlaceholders.match(/<tbody>[\s\S]*?<\/tbody>/);
const productTableHtml = productTableMatch ? productTableMatch[0] : '';
// 2. 提取合计行
const totalRowMatch = templateWithPlaceholders.match(/<tr style="background-color: #fff; font-weight: bold;">[\s\S]*?<\/tr>/);
// 2. 提取运费/桶押金行 + 合计行(连续两行加粗)
const totalRowMatch = templateWithPlaceholders.match(
/(?:<tr style="background-color: #fff; font-weight: bold;">[\s\S]*?<\/tr>\s*){2}/
);
const totalRowHtml = totalRowMatch ? totalRowMatch[0] : '';
// 3. 提取提示行(兼容一票制 / 客户自提文案,以及 colspan 10/11)
@@ -2479,9 +2514,10 @@ const handleSaveTemplate = async () => {
);
}
// 替换合计行(如果存在)
// 替换运费/桶押金行 + 合计行(兼容旧版单行合计)
if (totalRowHtml) {
const totalRowPattern = /<tr style="background-color: #fff; font-weight: bold;">[\s\S]*?<\/tr>/;
const totalRowPattern =
/(?:<tr style="background-color: #fff; font-weight: bold;">[\s\S]*?<\/tr>\s*){1,2}/;
if (totalRowPattern.test(finalTemplate)) {
finalTemplate = finalTemplate.replace(totalRowPattern, totalRowHtml);
}
@@ -2857,8 +2893,7 @@ const handleGeneratePdfFromDialog = async () => {
if (htmlContent.includes('{{') || htmlContent.includes('SETTLEMENT_METHOD_CONTENT')) {
// 重新获取最新合同数据来替换占位符
const res = await getContractDetail(detailContract.value.id);
const quoteFreight = await fetchQuoteFreight(res.data?.quoteId);
htmlContent = replacePlaceholders(htmlContent, res.data, quoteFreight);
htmlContent = replacePlaceholders(htmlContent, res.data);
}
// 1. 创建临时容器(border-box:794 含 padding)
@@ -3303,23 +3338,7 @@ onMounted(async () => {
}
.total-section {
padding: 20px 0;
.total-item {
display: flex;
justify-content: flex-end;
align-items: center;
font-size: 16px;
.total-label {
font-weight: bold;
margin-right: 10px;
}
.total-value {
font-size: 24px;
}
}
padding: 12px 0;
}
.amount-cards {
@@ -3834,12 +3853,17 @@ onMounted(async () => {
justify-content: center;
background: #f8fafc;
overflow: hidden;
cursor: pointer;
}
.detail-attachment-thumb-img {
width: 100%;
height: 100%;
display: block;
&--passive {
pointer-events: none;
}
}
.detail-attachment-preview__icon {
@@ -27,7 +27,7 @@
>
<!-- 合同基础信息(一行 4 列) -->
<div class="contract-basic-info">
<el-form-item label="合同编号" prop="contractNo">
<el-form-item v-if="isEditMode" label="合同编号" prop="contractNo">
<el-input v-model="form.contractNo" placeholder="系统自动生成,格式:SX/X-JT20250926002" maxlength="50" />
</el-form-item>
<el-form-item label="合同名称" prop="contractName">
@@ -49,13 +49,35 @@
</el-select>
</el-form-item>
<el-form-item label="客户名称" prop="customerId" required>
<el-input v-model="form.customerName" placeholder="请选择客户" readonly>
<template #append>
<el-button text @click="handleSelectCustomer">
<el-icon><Search /></el-icon>
</el-button>
</template>
</el-input>
<div class="customer-select-row">
<el-select
v-model="form.customerId"
class="customer-select-row__select"
filterable
remote
clearable
:remote-method="searchCustomerOptions"
:loading="customerOptionsLoading"
placeholder="请输入客户名称/拼音首字母搜索"
@focus="handleCustomerSelectFocus"
@change="handleCustomerSelectChange"
>
<el-option
v-for="item in customerOptions"
:key="item.id"
:label="item.customerName"
:value="item.id"
>
<div class="customer-option-row">
<span>{{ item.customerName }}</span>
<span v-if="item.customerNo" class="customer-option-row__meta">{{ item.customerNo }}</span>
</div>
</el-option>
</el-select>
<el-button text class="customer-select-row__search" @click="handleSelectCustomer">
<el-icon><Search /></el-icon>
</el-button>
</div>
</el-form-item>
<el-form-item label="关联报价单" prop="quoteId">
<el-input v-model="form.quoteNo" placeholder="请选择报价单(可选)" readonly clearable>
@@ -67,13 +89,42 @@
</el-input>
</el-form-item>
<el-form-item label="联系人" prop="contactId" required>
<el-input v-model="form.contactsName" placeholder="请选择联系人" maxlength="50">
<template #append>
<el-button text @click="handleSelectContact" :disabled="!form.customerId">
<el-icon><Search /></el-icon>
</el-button>
</template>
</el-input>
<div class="customer-select-row">
<el-select
v-model="form.contactId"
class="customer-select-row__select"
filterable
clearable
:disabled="!form.customerId"
:loading="contactOptionsLoading"
:placeholder="form.customerId ? '请选择联系人' : '请先选择客户'"
@visible-change="handleContactSelectVisible"
@change="handleContactSelectChange"
>
<el-option
v-for="item in contactOptions"
:key="item.id"
:label="item.contactName"
:value="item.id"
>
<div class="customer-option-row">
<span>
{{ item.contactName }}
<el-tag v-if="item.isPrimary === 1" type="success" size="small" style="margin-left: 6px">主要</el-tag>
</span>
<span v-if="item.mobile" class="customer-option-row__meta">{{ item.mobile }}</span>
</div>
</el-option>
</el-select>
<el-button
text
class="customer-select-row__search"
:disabled="!form.customerId"
@click="handleSelectContact"
>
<el-icon><Search /></el-icon>
</el-button>
</div>
</el-form-item>
<el-form-item label="联系电话" prop="contactsPhone">
<el-input v-model="form.contactsPhone" placeholder="从客户/联系人带出" maxlength="20" />
@@ -97,7 +148,12 @@
style="width: 100%"
@change="handleOwnerChange"
>
<el-option v-for="user in userList" :key="user.userId" :label="user.nickName" :value="user.userId" />
<el-option
v-for="user in ownerUserList"
:key="user.userId"
:label="user.nickName"
:value="user.userId"
/>
</el-select>
</el-form-item>
<el-form-item label="合同金额(元)" prop="amount">
@@ -110,6 +166,26 @@
class="money-field-input"
/>
</el-form-item>
<el-form-item label="运费(元)" prop="freight">
<el-input-number
v-model="form.freight"
:precision="2"
:min="0"
placeholder="可选,选择报价单后可自动带入"
style="width: 100%"
class="money-field-input"
/>
</el-form-item>
<el-form-item label="桶押金(元)" prop="barrelDeposit">
<el-input-number
v-model="form.barrelDeposit"
:precision="2"
:min="0"
placeholder="可选,选择报价单后可自动带入"
style="width: 100%"
class="money-field-input"
/>
</el-form-item>
<el-form-item label="合同期限" prop="startDate" required>
<el-date-picker
v-model="contractDateRange"
@@ -127,7 +203,7 @@
<el-option v-for="supplier in supplierList" :key="supplier.id" :label="supplier.supplierName" :value="supplier.id" />
</el-select>
</el-form-item>
<el-form-item label="结算方式" prop="settlementMethod">
<el-form-item label="结算方式" prop="settlementMethod" required>
<el-select v-model="form.settlementMethod" placeholder="请选择结算方式" clearable style="width: 100%">
<el-option v-for="dict in dictStore.getOptions('crm_settlement_method')" :key="dict.value" :label="dict.label" :value="dict.value" />
</el-select>
@@ -300,7 +376,7 @@
class="line-meta-cell__btn"
@click="openAliasBrandManage(scope.row, 'alias')"
>
<el-icon><Setting /></el-icon>
<el-icon><Plus /></el-icon>
</el-button>
</div>
</template>
@@ -333,7 +409,7 @@
class="line-meta-cell__btn"
@click="openAliasBrandManage(scope.row, 'brand')"
>
<el-icon><Setting /></el-icon>
<el-icon><Plus /></el-icon>
</el-button>
</div>
</template>
@@ -579,7 +655,55 @@
/>
<!-- 客户选择器 -->
<CustomerSelector :visible="customerSelectorVisible" @update:visible="customerSelectorVisible = $event" @confirm="handleCustomerConfirm" />
<CustomerSelector
:visible="customerSelectorVisible"
@update:visible="customerSelectorVisible = $event"
@confirm="handleCustomerSelectorConfirm"
/>
<!-- 下拉选客户时补填简称 -->
<el-dialog
v-model="shortNameDialogVisible"
title="填写客户简称"
width="480px"
align-center
class="dialog-form-layout"
modal-class="order-module-dialog-mask"
:close-on-click-modal="false"
append-to-body
@closed="handleShortNameDialogClosed"
>
<el-form
ref="shortNameFormRef"
:model="shortNameForm"
:rules="shortNameRules"
label-position="top"
class="crm-dialog-form"
>
<el-form-item label="客户名称">
<el-input :model-value="shortNameForm.customerName" disabled />
</el-form-item>
<el-form-item label="客户简称" prop="shortName">
<el-input
v-model="shortNameForm.shortName"
placeholder="请输入客户简称"
maxlength="100"
show-word-limit
clearable
/>
</el-form-item>
</el-form>
<template #footer>
<div class="dialog-footer">
<el-button class="btn-ghost" @click="shortNameDialogVisible = false">
<el-icon><Close /></el-icon>取消
</el-button>
<el-button class="btn-main" type="primary" :loading="shortNameSaving" @click="handleSaveShortName">
<el-icon><Check /></el-icon>确定
</el-button>
</div>
</template>
</el-dialog>
<!-- 联系人选择器 -->
<ContactSelector
@@ -589,6 +713,9 @@
@confirm="handleContactConfirm"
/>
<!-- 下拉无联系人时补充 -->
<ContactFormDialog ref="contactFormRef" @success="handleContactFormSuccess" />
<!-- 报价单选择器 -->
<QuoteSelector
:visible="quoteSelectorVisible"
@@ -606,7 +733,7 @@
<script setup lang="ts">
import { ref, reactive, computed, nextTick, watch } from 'vue'
import type { FormInstance, UploadRequestOptions } from 'element-plus'
import type { FormInstance, FormItemRule, UploadRequestOptions } from 'element-plus'
import { ElMessage } from 'element-plus'
import {
getContract,
@@ -627,12 +754,12 @@ import {
Plus,
Search,
Close,
Check,
FolderChecked,
Promotion,
Loading,
ArrowDown,
ArrowUp,
Setting
ArrowUp
} from '@element-plus/icons-vue'
import {
buildUploadFileListFromField,
@@ -644,11 +771,13 @@ import { buildAttachmentUploadFormData, CRM_UPLOAD_BIZ_TYPE } from '@/utils/crm-
import ContractAttachmentPanel from './ContractAttachmentPanel.vue'
import { getOpportunity } from '@/api/crm/opportunity'
import { getQuote } from '@/api/crm/quote'
import ProductSelector from './ProductSelector.vue'
import ProductSelector from '@/components/business/product-selector/index.vue'
import ProductAliasBrandDialog from '@/components/business/product-alias-brand-dialog/index.vue'
import CustomerSelector from '@/components/CustomerSelector.vue'
import ContactSelector from '@/components/ContactSelector.vue'
import ContactFormDialog from '@/views/crm/customer/components/ContactFormDialog.vue'
import QuoteSelector from '@/components/QuoteSelector.vue'
import { fetchContactsByCustomerId } from '@/api/crm/contact'
import { removeProductsNotAllowedByHazard } from '@/utils/crm-supplier-hazard'
import {
applyBrandSelectChange,
@@ -660,11 +789,16 @@ import {
import { fetchProductDetail } from '@/api/crm/product'
import ApprovalDialog from './ApprovalDialog.vue'
import { omitEmptyExceptPartyFields } from '../partyFields'
import { getContactByCustomerId, fetchCustomerDetail } from '@/api/crm/customer'
import {
fetchCustomerList,
fetchCustomerDetail,
fetchUpdateCustomer
} from '@/api/crm/customer'
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 { filterOwnerCandidates, findDefaultOwnerUser } from '@/utils/crm-owner-candidates'
interface UserVO {
userId: string | number
@@ -720,6 +854,9 @@ const formTitle = computed(() => {
return form.value.id ? '编辑合同' : '新增合同'
})
/** 编辑模式(有 editId);新增时隐藏合同编号 */
const isEditMode = computed(() => !!props.editId)
// 合同期限日期范围
const contractDateRange = ref<[string, string]>([])
@@ -730,7 +867,7 @@ const form = ref<ExtendedContractForm>({
contractName: '',
contractType: 'sale',
contractTemplate: 'shanxia',
customerId: 0,
customerId: undefined,
customerName: '',
contactId: undefined,
opportunityId: undefined,
@@ -745,6 +882,8 @@ const form = ref<ExtendedContractForm>({
ownerUserId: undefined,
ownerUserName: '',
amount: 0,
freight: 0,
barrelDeposit: 0,
supplierId: undefined,
settlementMethod: undefined,
partyA: '',
@@ -809,6 +948,7 @@ const rules = ref({
signDate: [{ required: true, message: '签订日期不能为空', trigger: 'change' }],
ownerUserId: [{ required: true, message: '负责人不能为空', trigger: 'change' }],
supplierId: [{ required: true, message: '交易主体不能为空', trigger: 'change' }],
settlementMethod: [{ required: true, message: '结算方式不能为空', trigger: 'change' }],
startDate: [
{
validator: (_rule: any, _value: any, callback: any) => {
@@ -858,8 +998,227 @@ const quoteSelectorVisible = ref(false)
const userSelectorVisible = ref(false)
const productSelectorVisible = ref(false)
// 用户列表(负责人下拉)
// 客户下拉(远程模糊检索)
const customerOptions = ref<CustomerVO[]>([])
const customerOptionsLoading = ref(false)
/** 已确认选定的客户(用于简称弹窗取消时回滚下拉值) */
const confirmedCustomerId = ref<string | number | undefined>(undefined)
const shortNameDialogVisible = ref(false)
const shortNameSaving = ref(false)
const shortNameFormRef = ref<FormInstance>()
const shortNameForm = ref({
id: '' as string | number,
customerName: '',
shortName: ''
})
const shortNameRules: Record<string, FormItemRule[]> = {
shortName: [{ required: true, message: '客户简称不能为空', trigger: 'blur' }]
}
const pendingCustomerForShortName = ref<CustomerVO | null>(null)
const shortNameSavedSuccessfully = ref(false)
// 联系人下拉
const contactOptions = ref<ContactVO[]>([])
const contactOptionsLoading = ref(false)
const contactFormRef = ref<InstanceType<typeof ContactFormDialog>>()
/** 避免 visible-change 重复弹出补充联系人弹窗 */
const contactEmptyPrompted = ref(false)
const hasCustomerShortName = (row?: { shortName?: string } | null) =>
Boolean(String(row?.shortName || '').trim())
const ensureCustomerOption = (customer?: Partial<CustomerVO> | null) => {
if (!customer?.id) return
const exists = customerOptions.value.some((item) => String(item.id) === String(customer.id))
if (exists) {
customerOptions.value = customerOptions.value.map((item) =>
String(item.id) === String(customer.id)
? {
...item,
customerName: customer.customerName || item.customerName,
customerNo: customer.customerNo ?? item.customerNo,
shortName: customer.shortName ?? item.shortName
}
: item
)
return
}
customerOptions.value = [
{
id: customer.id,
customerName: customer.customerName || '',
customerNo: customer.customerNo,
shortName: customer.shortName
} as CustomerVO,
...customerOptions.value
]
}
const extractCustomerList = (res: unknown): CustomerVO[] => {
const data = (res as { data?: unknown })?.data ?? res ?? {}
const list = (data as { list?: CustomerVO[]; rows?: CustomerVO[] }).list
|| (data as { rows?: CustomerVO[] }).rows
|| []
return Array.isArray(list) ? list : []
}
const loadDefaultCustomerOptions = async () => {
customerOptionsLoading.value = true
try {
const res = await fetchCustomerList({ page: 1, pageSize: 20 })
customerOptions.value = extractCustomerList(res)
if (form.value.customerId) {
ensureCustomerOption({
id: form.value.customerId,
customerName: form.value.customerName,
shortName: customerShortName.value
})
}
} catch (error) {
console.error('加载客户列表失败:', error)
customerOptions.value = []
} finally {
customerOptionsLoading.value = false
}
}
const searchCustomerOptions = async (query: string) => {
const keyword = query?.trim()
if (!keyword) {
await loadDefaultCustomerOptions()
return
}
customerOptionsLoading.value = true
try {
const res = await fetchCustomerList({
customerName: keyword,
page: 1,
pageSize: 50
})
customerOptions.value = extractCustomerList(res)
if (form.value.customerId) {
ensureCustomerOption({
id: form.value.customerId,
customerName: form.value.customerName,
shortName: customerShortName.value
})
}
} catch (error) {
console.error('搜索客户失败:', error)
customerOptions.value = []
} finally {
customerOptionsLoading.value = false
}
}
const handleCustomerSelectFocus = () => {
if (customerOptions.value.length === 0) {
loadDefaultCustomerOptions()
}
}
const extractContactList = (res: unknown): ContactVO[] => {
const unwrapped = (res as { data?: unknown })?.data ?? res ?? []
if (Array.isArray(unwrapped)) return unwrapped as ContactVO[]
const payload = (unwrapped as { list?: ContactVO[]; rows?: ContactVO[] }) || {}
return payload.list || payload.rows || []
}
const ensureContactOption = (contact?: Partial<ContactVO> | null) => {
if (!contact?.id) return
const exists = contactOptions.value.some((item) => String(item.id) === String(contact.id))
if (exists) {
contactOptions.value = contactOptions.value.map((item) =>
String(item.id) === String(contact.id)
? {
...item,
contactName: contact.contactName || item.contactName,
mobile: contact.mobile ?? item.mobile,
isPrimary: contact.isPrimary ?? item.isPrimary
}
: item
)
return
}
contactOptions.value = [
{
id: contact.id,
contactName: contact.contactName || '',
mobile: contact.mobile,
isPrimary: contact.isPrimary
} as ContactVO,
...contactOptions.value
]
}
const loadContactOptions = async (customerId?: string | number) => {
if (!customerId) {
contactOptions.value = []
return []
}
contactOptionsLoading.value = true
try {
const res = await fetchContactsByCustomerId({ customerId })
contactOptions.value = extractContactList(res)
if (form.value.contactId) {
ensureContactOption({
id: form.value.contactId,
contactName: form.value.contactsName
})
}
return contactOptions.value
} catch (error) {
console.error('加载联系人列表失败:', error)
contactOptions.value = []
return []
} finally {
contactOptionsLoading.value = false
}
}
const openContactFormDialog = () => {
if (!form.value.customerId) {
$modal.msgWarning('请先选择客户')
return
}
contactFormRef.value?.open(undefined, form.value.customerId)
}
const openShortNameDialog = (customer: CustomerVO) => {
pendingCustomerForShortName.value = customer
shortNameSavedSuccessfully.value = false
shortNameForm.value = {
id: customer.id,
customerName: customer.customerName || '',
shortName: customer.shortName || ''
}
shortNameDialogVisible.value = true
nextTick(() => shortNameFormRef.value?.clearValidate())
}
const clearCustomerSelection = () => {
form.value.customerId = undefined
form.value.customerName = ''
customerShortName.value = ''
customerInvoiceName.value = ''
confirmedCustomerId.value = undefined
form.value.contactId = undefined
form.value.contactsName = ''
form.value.contactsPhone = ''
contactOptions.value = []
contactEmptyPrompted.value = false
form.value.opportunityId = undefined
form.value.opportunityName = ''
form.value.quoteId = undefined
form.value.quoteNo = ''
form.value.freight = 0
form.value.barrelDeposit = 0
rebuildContractName()
}
// 用户列表(负责人下拉仅方金强 / 吴九华)
const userList = ref<any[]>([])
const ownerUserList = computed(() => filterOwnerCandidates(userList.value))
// 选中的产品列表
const selectedProducts = ref<ExtendedContractProductForm[]>([])
@@ -900,6 +1259,7 @@ const handleOpened = async () => {
resetForm()
form.value.signDate = new Date().toISOString().split('T')[0]
handleSignDateChange(form.value.signDate)
applyDefaultOwnerUser()
// 设置默认供方主体为"SX"
const defaultSupplier = supplierList.value.find((supplier) => supplier.supplierCode === 'SX')
@@ -927,7 +1287,7 @@ const resetForm = () => {
contractName: '',
contractType: 'sale',
contractTemplate: 'shanxia',
customerId: 0,
customerId: undefined,
customerName: '',
contactId: undefined,
opportunityId: undefined,
@@ -942,6 +1302,8 @@ const resetForm = () => {
ownerUserId: undefined,
ownerUserName: '',
amount: 0,
freight: 0,
barrelDeposit: 0,
supplierId: undefined,
settlementMethod: undefined,
partyA: '',
@@ -973,6 +1335,13 @@ const resetForm = () => {
originalTemplateContent.value = ''
customerShortName.value = ''
customerInvoiceName.value = ''
confirmedCustomerId.value = undefined
customerOptions.value = []
contactOptions.value = []
contactEmptyPrompted.value = false
pendingCustomerForShortName.value = null
shortNameDialogVisible.value = false
shortNameSavedSuccessfully.value = false
contractDateRange.value = [] as any
attachmentList.value = []
selectedProducts.value = []
@@ -1079,6 +1448,8 @@ const loadContractDetail = async (id: number | string) => {
customerShortName.value = ''
customerInvoiceName.value = ''
confirmedCustomerId.value = form.value.customerId || undefined
contactEmptyPrompted.value = false
if (form.value.customerId) {
try {
const [invoiceRes, customerRes] = await Promise.all([
@@ -1090,9 +1461,31 @@ const loadContractDetail = async (id: number | string) => {
if (!form.value.customerName && customerRes?.data?.customerName) {
form.value.customerName = customerRes.data.customerName
}
ensureCustomerOption({
id: form.value.customerId,
customerName: form.value.customerName || customerRes?.data?.customerName,
shortName: customerShortName.value,
customerNo: customerRes?.data?.customerNo
})
} catch {
customerInvoiceName.value = ''
ensureCustomerOption({
id: form.value.customerId,
customerName: form.value.customerName,
shortName: customerShortName.value
})
}
await loadContactOptions(form.value.customerId)
if (form.value.contactId) {
ensureContactOption({
id: form.value.contactId,
contactName: form.value.contactsName,
mobile: form.value.contactsPhone
})
}
} else {
customerOptions.value = []
contactOptions.value = []
}
syncPartiesSwappedFlagFromPanels()
rebuildContractName()
@@ -1103,11 +1496,62 @@ const handleSelectCustomer = () => {
customerSelectorVisible.value = true
}
/** 下拉选择客户 */
const handleCustomerSelectChange = async (customerId?: string | number) => {
if (!customerId) {
clearCustomerSelection()
return
}
if (
confirmedCustomerId.value !== undefined
&& confirmedCustomerId.value !== null
&& String(customerId) === String(confirmedCustomerId.value)
) {
return
}
const customer = customerOptions.value.find((item) => String(item.id) === String(customerId))
if (!customer) return
if (!hasCustomerShortName(customer)) {
ElMessage.warning('该客户尚未配置简称,请先填写客户简称后再继续')
form.value.customerId = confirmedCustomerId.value as any
openShortNameDialog(customer)
return
}
await handleCustomerConfirm(customer)
}
/** 客户选择器确认(无简称时先补填) */
const handleCustomerSelectorConfirm = async (customer: CustomerVO) => {
let enriched: CustomerVO = { ...customer }
if (!hasCustomerShortName(enriched)) {
try {
const customerRes = await fetchCustomerDetail({ id: String(customer.id) })
enriched = {
...enriched,
customerName: customerRes?.data?.customerName || enriched.customerName,
shortName: customerRes?.data?.shortName || enriched.shortName
}
} catch {
// ignore,后续走简称弹窗
}
}
if (!hasCustomerShortName(enriched)) {
ElMessage.warning('该客户尚未配置简称,请先填写客户简称后再继续')
openShortNameDialog(enriched)
return
}
await handleCustomerConfirm(enriched)
}
/** 客户选择确认 */
const handleCustomerConfirm = async (customer: CustomerVO) => {
if (customer) {
ensureCustomerOption(customer)
form.value.customerId = customer.id
form.value.customerName = customer.customerName
confirmedCustomerId.value = customer.id
const addressParts: string[] = []
if (customer.province) addressParts.push(customer.province)
@@ -1117,10 +1561,15 @@ const handleCustomerConfirm = async (customer: CustomerVO) => {
const fullAddress = addressParts.join('')
form.value.contactId = undefined
form.value.contactsName = ''
contactOptions.value = []
contactEmptyPrompted.value = false
form.value.opportunityId = undefined
form.value.opportunityName = ''
form.value.quoteId = undefined
form.value.quoteNo = ''
form.value.freight = 0
form.value.barrelDeposit = 0
try {
const [invoiceRes, customerRes] = await Promise.all([
@@ -1134,6 +1583,12 @@ const handleCustomerConfirm = async (customer: CustomerVO) => {
if (customerRes?.data?.customerName) {
form.value.customerName = customerRes.data.customerName
}
ensureCustomerOption({
id: customer.id,
customerName: form.value.customerName,
shortName: customerShortName.value,
customerNo: customer.customerNo
})
customerInvoiceName.value = invoiceData?.companyName || ''
if (invoiceData && invoiceData.companyName) {
@@ -1176,6 +1631,7 @@ const handleCustomerConfirm = async (customer: CustomerVO) => {
} catch (error) {
console.error('获取客户开票信息失败:', error)
customerInvoiceName.value = ''
customerShortName.value = (customer.shortName || '').trim()
if (isPartiesSwapped.value) {
form.value.partyA = customer.customerName
form.value.partyAAddress = fullAddress
@@ -1205,26 +1661,18 @@ const handleCustomerConfirm = async (customer: CustomerVO) => {
form.value.contactsName = ''
form.value.contactsPhone = customer.mobile || customer.telephone || ''
try {
const res = await getContactByCustomerId(customer.id)
if (res.data && res.data.length > 0) {
const primaryContact = res.data.find((contact: any) => contact.isPrimary === 1)
const contact = primaryContact || res.data[0]
form.value.contactId = contact.id
form.value.contactsName = contact.contactName
form.value.contactsPhone = contact.mobile || contact.telephone || ''
if (isPartiesSwapped.value) {
form.value.partyAContact = contact.contactName
form.value.partyAMobile = contact.mobile || contact.telephone || ''
} else {
form.value.partyBContact = contact.contactName
form.value.partyBMobile = contact.mobile || contact.telephone || ''
}
// 自动加载该客户的联系人并设置默认联系人;无联系人时立即引导补充
const contacts = await loadContactOptions(customer.id)
if (contacts.length > 0) {
const primaryContact = contacts.find((c) => c.isPrimary === 1)
const contact = primaryContact || contacts[0]
if (contact) {
handleContactConfirm(contact)
}
} catch (error) {
console.error('获取客户联系人失败:', error)
} else {
contactEmptyPrompted.value = true
ElMessage.warning('该客户暂无联系人,请先补充联系人信息')
nextTick(() => openContactFormDialog())
}
if (!customerShortName.value) {
@@ -1234,6 +1682,46 @@ const handleCustomerConfirm = async (customer: CustomerVO) => {
}
}
const handleSaveShortName = async () => {
const valid = await shortNameFormRef.value?.validate().catch(() => false)
if (!valid) return
shortNameSaving.value = true
try {
const trimmedShortName = shortNameForm.value.shortName.trim()
await fetchUpdateCustomer({
id: shortNameForm.value.id,
shortName: trimmedShortName
})
ElMessage.success('客户简称保存成功')
const pending = pendingCustomerForShortName.value
const customer: CustomerVO = {
id: shortNameForm.value.id,
customerName: shortNameForm.value.customerName || pending?.customerName || '',
customerNo: pending?.customerNo,
shortName: trimmedShortName
} as CustomerVO
ensureCustomerOption(customer)
shortNameSavedSuccessfully.value = true
shortNameDialogVisible.value = false
await handleCustomerConfirm(customer)
} catch (error) {
console.error('保存客户简称失败:', error)
ElMessage.error('保存客户简称失败')
} finally {
shortNameSaving.value = false
}
}
const handleShortNameDialogClosed = () => {
pendingCustomerForShortName.value = null
if (!shortNameSavedSuccessfully.value) {
form.value.customerId = confirmedCustomerId.value as any
}
shortNameSavedSuccessfully.value = false
}
/** 选择联系人 */
const handleSelectContact = () => {
if (!form.value.customerId) {
@@ -1243,9 +1731,38 @@ const handleSelectContact = () => {
contactSelectorVisible.value = true
}
const handleContactSelectVisible = async (visible: boolean) => {
if (!visible) {
contactEmptyPrompted.value = false
return
}
if (!form.value.customerId) return
const list = await loadContactOptions(form.value.customerId)
if (list.length === 0 && !contactEmptyPrompted.value) {
contactEmptyPrompted.value = true
ElMessage.warning('该客户暂无联系人,请先补充联系人信息')
nextTick(() => openContactFormDialog())
}
}
const handleContactSelectChange = (contactId?: string | number) => {
if (!contactId) {
form.value.contactId = undefined
form.value.contactsName = ''
form.value.contactsPhone = ''
return
}
const contact = contactOptions.value.find((item) => String(item.id) === String(contactId))
if (contact) {
handleContactConfirm(contact)
}
}
/** 联系人选择确认 */
const handleContactConfirm = (contact: ContactVO) => {
if (contact) {
ensureContactOption(contact)
form.value.contactId = contact.id
form.value.contactsName = contact.contactName
form.value.contactsPhone = contact.mobile || contact.telephone || ''
@@ -1262,6 +1779,22 @@ const handleContactConfirm = (contact: ContactVO) => {
}
}
const handleContactFormSuccess = async (payload?: { id?: string | number }) => {
contactEmptyPrompted.value = false
const list = await loadContactOptions(form.value.customerId)
const createdId = payload?.id
if (createdId) {
const created = list.find((item) => String(item.id) === String(createdId))
if (created) {
handleContactConfirm(created)
return
}
}
if (list.length === 1) {
handleContactConfirm(list[0])
}
}
/** 选择商机 */
const handleSelectOpportunity = () => {
opportunitySelectorVisible.value = true
@@ -1290,6 +1823,8 @@ const handleQuoteConfirm = (quote: QuoteVO) => {
if (quote) {
form.value.quoteId = quote.id
form.value.quoteNo = quote.quoteNo
form.value.freight = Number(quote.freight) || 0
form.value.barrelDeposit = Number(quote.barrelDeposit) || 0
if (quote.customerId && !form.value.customerId) {
form.value.customerId = quote.customerId
@@ -1361,9 +1896,17 @@ const loadUserList = async () => {
}
}
/** 新增时默认负责人为方金强 */
const applyDefaultOwnerUser = () => {
const matched = findDefaultOwnerUser(ownerUserList.value)
if (!matched) return
form.value.ownerUserId = matched.userId as ContractForm['ownerUserId']
form.value.ownerUserName = matched.nickName || ''
}
/** 负责人变化 */
const handleOwnerChange = (userId: string | number) => {
const user = userList.value.find((item: any) => String(item.userId) === String(userId))
const user = ownerUserList.value.find((item: any) => String(item.userId) === String(userId))
form.value.ownerUserName = user?.nickName || ''
}
@@ -2052,7 +2595,7 @@ const handleAttachmentData = async () => {
/** 保存草稿 */
const handleSaveDraft = async () => {
if (!form.value.customerId || form.value.customerId === 0) {
if (!form.value.customerId) {
$modal.msgWarning('客户名称不能为空')
return
}
@@ -2672,4 +3215,35 @@ const loadSupplierList = async () => {
flex-shrink: 0;
padding: 4px;
}
.customer-select-row {
display: flex;
align-items: center;
gap: 4px;
width: 100%;
}
.customer-select-row__select {
flex: 1;
min-width: 0;
}
.customer-select-row__search {
flex-shrink: 0;
padding: 0 8px;
}
.customer-option-row {
display: flex;
justify-content: space-between;
align-items: center;
gap: 12px;
min-width: 0;
}
.customer-option-row__meta {
flex-shrink: 0;
font-size: 12px;
color: var(--mint-text-muted, #8492a6);
}
</style>
@@ -1,373 +0,0 @@
<template>
<el-dialog
title="选择产品"
v-model="dialogVisible"
width="80%"
align-center
append-to-body
class="dialog-form-layout"
modal-class="order-module-dialog-mask"
:close-on-click-modal="false"
>
<!-- 查询表单 -->
<el-form :model="queryParams" ref="queryFormRef" label-width="90px" class="mb-3">
<el-row :gutter="20">
<el-col :xl="4" :lg="6" :md="8" :sm="12" :xs="24">
<el-form-item label="产品名称" prop="productName">
<el-input v-model="queryParams.productName" placeholder="请输入产品名称" clearable @keyup.enter="handleQuery" />
</el-form-item>
</el-col>
<el-col :xl="4" :lg="6" :md="8" :sm="12" :xs="24">
<el-form-item label="产品分类" prop="categoryId">
<el-tree-select
v-model="queryParams.categoryId"
:data="categoryTree"
placeholder="请选择产品分类"
clearable
check-strictly
:render-after-expand="false"
style="width: 100%"
/>
</el-form-item>
</el-col>
<el-col :xl="4" :lg="6" :md="8" :sm="12" :xs="24">
<el-form-item label="产品状态" prop="status">
<el-select v-model="queryParams.status" placeholder="请选择状态" clearable style="width: 100%">
<el-option
v-for="opt in dictStore.getOptions('crm_product_status')"
:key="opt.value"
:label="opt.label"
:value="opt.value"
/>
</el-select>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="24" style="text-align: right">
<el-button type="primary" :loading="loading" @click="handleQuery">
<el-icon><Search /></el-icon>搜索
</el-button>
<el-button :loading="loading" @click="resetQuery">
<el-icon><Refresh /></el-icon>重置
</el-button>
</el-col>
</el-row>
</el-form>
<!-- 产品列表 -->
<div class="panel dialog-list-panel">
<div class="list-body list-wrap dialog-list-body-only">
<ListTable table-key="crm-contract-components-product-selector"
ref="tableRef"
v-loading="loading"
:data="productList"
class="list-table"
stripe
@selection-change="handleSelectionChange"
:max-height="400"
>
<el-table-column type="selection" min-width="55" align="center" header-align="center" />
<el-table-column type="index" label="序号" min-width="60" align="center" header-align="center" />
<el-table-column label="产品编号" prop="productNo" min-width="140" align="center" header-align="center" :show-overflow-tooltip="true" />
<el-table-column
label="产品名称"
prop="productName"
min-width="240"
align="left"
header-align="left"
class-name="col-name-wrap"
label-class-name="col-name-wrap"
/>
<el-table-column label="产品分类" prop="categoryName" min-width="120" align="center" header-align="center" />
<el-table-column label="规格型号" prop="model" min-width="120" align="center" header-align="center" :show-overflow-tooltip="true" />
<el-table-column label="计量单位" prop="unit" min-width="100" align="center" header-align="center">
<template #default="scope">
<DictTag dict-type="crm_product_unit" :value="scope.row.unit" />
</template>
</el-table-column>
<el-table-column label="税率(%)" prop="taxRate" min-width="90" align="center" header-align="center">
<template #default="scope">
<span>{{ scope.row.taxRate || 0 }}%</span>
</template>
</el-table-column>
<el-table-column label="状态" prop="status" min-width="90" align="center" header-align="center">
<template #default="scope">
<el-tag :type="dictStore.getTagType('crm_product_status', scope.row.status)" size="small">
{{ dictStore.getLabel('crm_product_status', scope.row.status) }}
</el-tag>
</template>
</el-table-column>
</ListTable>
<pagination
v-show="total > 0"
:total="total"
v-model:page="queryParams.pageNum"
v-model:limit="queryParams.pageSize"
@pagination="getList"
class="pagination list-pager-bar"
/>
</div>
</div>
<!-- 已选产品 -->
<el-divider content-position="left">已选产品 ({{ selectedProducts.length }})</el-divider>
<div class="selected-products">
<el-tag v-for="product in selectedProducts" :key="product.id" closable @close="handleRemoveSelection(product)" class="mr-2 mb-2">
{{ product.productName }}
</el-tag>
<span v-if="selectedProducts.length === 0" class="text-muted">暂无选择</span>
</div>
<template #footer>
<div class="dialog-footer">
<el-button class="btn-ghost" @click="handleClose">
<el-icon><Close /></el-icon>取消
</el-button>
<el-button class="btn-main" type="primary" @click="handleConfirm" :disabled="selectedProducts.length === 0">
<el-icon><Check /></el-icon>确定 ({{ selectedProducts.length }})
</el-button>
</div>
</template>
</el-dialog>
</template>
<script setup lang="ts" name="ProductSelector">
import { ref, watch } from 'vue'
import type { ElFormInstance } from 'element-plus'
import { Check, Close, Refresh, Search } from '@element-plus/icons-vue'
import { fetchProductList, fetchCategoryTree } from '@/api/crm/product'
import DictTag from '@/components/DictTag/index.vue'
import { useDictStore } from '@/store/modules/dict'
const dictStore = useDictStore()
interface ProductVO {
id: string | number
productNo?: string
productName?: string
categoryId?: string | number
categoryName?: string
model?: string
unit?: string
taxRate?: number
status?: string
}
interface ProductCategoryVO {
id: string | number
categoryName: string
children?: ProductCategoryVO[]
}
// 定义组件属性
interface Props {
visible: boolean
supplierId?: string | number
}
const props = defineProps<Props>();
// 定义事件
const emit = defineEmits(['update:visible', 'confirm']);
// 对话框显示状态
const dialogVisible = ref(false);
// 监听visible变化
watch(
() => props.visible,
(val) => {
dialogVisible.value = val;
if (val) {
// 打开对话框时加载数据
getList();
loadCategoryTree();
}
}
);
// 监听dialogVisible变化
watch(dialogVisible, (val) => {
emit('update:visible', val);
});
// 查询参数
const queryParams = ref({
pageNum: 1,
pageSize: 20,
productName: undefined,
categoryId: undefined,
status: 'on' // on-上架 off-下架
});
// 产品列表
const productList = ref<ProductVO[]>([]);
const loading = ref(false);
const total = ref(0);
// 产品分类树
const categoryTree = ref<any[]>([]);
// 已选产品
const selectedProducts = ref<ProductVO[]>([]);
const queryFormRef = ref<ElFormInstance>();
const tableRef = ref<any>();
/** 查询产品列表 */
const getList = async () => {
loading.value = true;
try {
const res = await fetchProductList({
page: queryParams.value.pageNum,
pageSize: queryParams.value.pageSize,
keyword: queryParams.value.productName,
categoryId: queryParams.value.categoryId,
status: queryParams.value.status,
supplierId: props.supplierId != null && props.supplierId !== '' ? String(props.supplierId) : undefined
});
const data = (res as any)?.data || res || {};
productList.value = data.list || data.rows || [];
total.value = data.total ?? 0;
// 如果分类树已加载,立即补全 categoryName
if (categoryTree.value.length > 0) {
resolveCategoryNames()
}
} catch (error) {
console.error('获取产品列表失败:', error);
} finally {
loading.value = false;
}
};
/** 加载产品分类树 */
const loadCategoryTree = async () => {
try {
const res = await fetchCategoryTree();
const tree = (res as any)?.data || res || [];
categoryTree.value = convertTreeData(tree);
// 分类树加载后,补全已有产品的 categoryName
resolveCategoryNames()
} catch (error) {
console.error('获取产品分类失败:', error);
}
};
/** 转换树形数据格式 */
const convertTreeData = (data: ProductCategoryVO[]): any[] => {
return data.map((item) => ({
value: item.id,
label: item.categoryName,
children: item.children ? convertTreeData(item.children) : undefined
}));
};
/** 从分类树中解析分类名称 */
const resolveCategoryName = (categoryId: any, tree: any[]): string => {
for (const node of tree) {
if (node.value === categoryId || node.id === categoryId) return node.label || ''
if (node.children) {
const found = resolveCategoryName(categoryId, node.children)
if (found) return found
}
}
return ''
}
/** 补全产品列表中缺失的 categoryName */
const resolveCategoryNames = () => {
if (!categoryTree.value.length) return
productList.value.forEach((product) => {
if (!product.categoryName && product.categoryId != null) {
const catId = (product as any).categoryId
product.categoryName = resolveCategoryName(catId, categoryTree.value)
}
})
}
/** 搜索按钮操作 */
const handleQuery = () => {
queryParams.value.pageNum = 1;
getList();
};
/** 重置按钮操作 */
const resetQuery = () => {
queryFormRef.value?.resetFields();
handleQuery();
};
watchDebounced(
() => ({
productName: queryParams.value.productName,
categoryId: queryParams.value.categoryId,
status: queryParams.value.status,
}),
() => {
queryParams.value.pageNum = 1;
getList();
},
{ debounce: 300, deep: true }
);
/** 多选框选中数据 */
const handleSelectionChange = (selection: ProductVO[]) => {
selectedProducts.value = selection;
};
/** 移除已选产品 */
const handleRemoveSelection = (product: ProductVO) => {
const index = selectedProducts.value.findIndex((p) => p.id === product.id);
if (index > -1) {
selectedProducts.value.splice(index, 1);
}
};
/** 确认选择 */
const handleConfirm = () => {
emit('confirm', selectedProducts.value);
handleClose();
};
/** 关闭对话框 */
const handleClose = () => {
selectedProducts.value = [];
dialogVisible.value = false;
};
</script>
<style scoped lang="scss">
.selected-products {
min-height: 40px;
padding: 10px;
background-color: #f5f7fa;
border-radius: 4px;
}
.text-primary {
color: #409eff;
font-weight: 500;
}
.text-muted {
color: #1e293b;
}
.mr-2 {
margin-right: 8px;
}
.mb-2 {
margin-bottom: 8px;
}
.mt-3 {
margin-top: 16px;
}
.mb-3 {
margin-bottom: 16px;
}
</style>
+122 -21
View File
@@ -3,7 +3,6 @@
<section class="panel" v-loading="loading">
<div class="panel-top panel-top-with-actions">
<div class="panel-top-main">
<h2 class="title-bar-heading">合同详情</h2>
<div v-if="contract" class="header-left header-tags">
<el-tag
v-if="contract?.status"
@@ -769,8 +768,17 @@
<div class="attachment-list">
<div v-for="(file, index) in contractFileList" :key="index" class="upload-file-card">
<!-- 缩略图区域 -->
<div class="upload-file-thumb">
<ImagePreview v-if="isImageFile(file)" :src="file.ossId" class="upload-thumb-image" :isOssId="true" />
<div
class="upload-file-thumb"
:title="isImageFile(file) || isPdfFile(file) ? '点击在新标签页查看' : '点击查看'"
@click.stop="handlePreviewFile(file)"
>
<ImagePreview
v-if="isImageFile(file)"
:src="file.ossId"
class="upload-thumb-image upload-thumb-image--passive"
:isOssId="true"
/>
<div v-else class="upload-file-placeholder">
<el-icon><Document /></el-icon>
<span class="file-ext">{{ getFileExt(file.name) }}</span>
@@ -782,8 +790,12 @@
{{ getShortFileName(file.name) }}
</div>
<!-- 下载按钮 -->
<!-- 查看 / 下载 -->
<div class="upload-file-card-actions">
<el-button type="primary" size="small" @click.stop="handlePreviewFile(file)">
<el-icon><View /></el-icon>
查看
</el-button>
<el-button type="success" size="small" @click.stop="handleDownloadFile(file)">
<el-icon><Download /></el-icon>
下载
@@ -810,8 +822,17 @@
</div>
<div class="attachment-list">
<div v-for="(file, index) in getAttachmentsByCategory('single_seal')" :key="index" class="upload-file-card">
<div class="upload-file-thumb">
<ImagePreview v-if="isImageFile(file)" :src="file.ossId" class="upload-thumb-image" :isOssId="true" />
<div
class="upload-file-thumb"
:title="isImageFile(file) || isPdfFile(file) ? '点击在新标签页查看' : '点击查看'"
@click.stop="handlePreviewFile(file)"
>
<ImagePreview
v-if="isImageFile(file)"
:src="file.ossId"
class="upload-thumb-image upload-thumb-image--passive"
:isOssId="true"
/>
<div v-else class="upload-file-placeholder">
<el-icon><Document /></el-icon>
<span class="file-ext">{{ getFileExt(file.name) }}</span>
@@ -821,6 +842,10 @@
{{ getShortFileName(file.name) }}
</div>
<div class="upload-file-card-actions">
<el-button type="primary" size="small" @click.stop="handlePreviewFile(file)">
<el-icon><View /></el-icon>
查看
</el-button>
<el-button type="success" size="small" @click.stop="handleDownloadFile(file)">
<el-icon><Download /></el-icon>
下载
@@ -845,8 +870,17 @@
</div>
<div class="attachment-list">
<div v-for="(file, index) in getAttachmentsByCategory('double_seal')" :key="index" class="upload-file-card">
<div class="upload-file-thumb">
<ImagePreview v-if="isImageFile(file)" :src="file.ossId" class="upload-thumb-image" :isOssId="true" />
<div
class="upload-file-thumb"
:title="isImageFile(file) || isPdfFile(file) ? '点击在新标签页查看' : '点击查看'"
@click.stop="handlePreviewFile(file)"
>
<ImagePreview
v-if="isImageFile(file)"
:src="file.ossId"
class="upload-thumb-image upload-thumb-image--passive"
:isOssId="true"
/>
<div v-else class="upload-file-placeholder">
<el-icon><Document /></el-icon>
<span class="file-ext">{{ getFileExt(file.name) }}</span>
@@ -856,6 +890,10 @@
{{ getShortFileName(file.name) }}
</div>
<div class="upload-file-card-actions">
<el-button type="primary" size="small" @click.stop="handlePreviewFile(file)">
<el-icon><View /></el-icon>
查看
</el-button>
<el-button type="success" size="small" @click.stop="handleDownloadFile(file)">
<el-icon><Download /></el-icon>
下载
@@ -882,8 +920,17 @@
</div>
<div class="attachment-list">
<div v-for="(file, index) in getAttachmentsByCategory('other')" :key="index" class="upload-file-card">
<div class="upload-file-thumb">
<ImagePreview v-if="isImageFile(file)" :src="file.ossId" class="upload-thumb-image" :isOssId="true" />
<div
class="upload-file-thumb"
:title="isImageFile(file) || isPdfFile(file) ? '点击在新标签页查看' : '点击查看'"
@click.stop="handlePreviewFile(file)"
>
<ImagePreview
v-if="isImageFile(file)"
:src="file.ossId"
class="upload-thumb-image upload-thumb-image--passive"
:isOssId="true"
/>
<div v-else class="upload-file-placeholder">
<el-icon><Document /></el-icon>
<span class="file-ext">{{ getFileExt(file.name) }}</span>
@@ -893,6 +940,10 @@
{{ getShortFileName(file.name) }}
</div>
<div class="upload-file-card-actions">
<el-button type="primary" size="small" @click.stop="handlePreviewFile(file)">
<el-icon><View /></el-icon>
查看
</el-button>
<el-button type="success" size="small" @click.stop="handleDownloadFile(file)">
<el-icon><Download /></el-icon>
下载
@@ -1037,7 +1088,9 @@ import { isFrameworkContractType, isContractEditableStatus, getContractReeditCon
import {
parseCrmAttachmentField,
resolveCrmAttachmentFiles,
downloadCrmAttachment
downloadCrmAttachment,
isCrmPdfFile,
openCrmAttachmentPreviewInNewTab
} from '@/utils/crm-attachment';
import { canDeleteByCreator } from '@/utils/creator-delete';
import html2canvas from 'html2canvas';
@@ -1634,14 +1687,32 @@ const replacePlaceholders = (htmlContent: string, contractData: ContractVO | und
)
}
// 替换产品合计行
// 合计区(11 列):第 1 行左右对半运费/桶押金;第 2 行合计;第 3 行提示
const freightRaw = Number(contractData.freight);
const freightAmount = Number.isFinite(freightRaw) && freightRaw > 0 ? freightRaw : 0;
const depositRaw = Number(contractData.barrelDeposit);
const barrelDepositAmount = Number.isFinite(depositRaw) && depositRaw > 0 ? depositRaw : 0;
const totalWithExtras = productTotal + freightAmount + barrelDepositAmount;
const totalWithExtrasChinese = numberToChinese(totalWithExtras);
const freightText = freightAmount > 0 ? `¥${formatNumber(freightAmount)}` : '-';
const barrelDepositText = barrelDepositAmount > 0 ? `¥${formatNumber(barrelDepositAmount)}` : '-';
const isFrameworkContract = isFrameworkContractType(contractData.contractType);
const totalWithExtrasText = isFrameworkContract
? '随行就市'
: `${totalWithExtrasChinese}(¥${formatNumber(totalWithExtras)})`;
const tipRowText = hasSelfPickupProduct(contractData.products)
? '含税、客户自提结算以实际到货吨位为准'
: '含税、含运费、装卸费(一票制)&nbsp;&nbsp;&nbsp;&nbsp;结算以实际到货吨位为准';
const productTotalRow = `
<tr style="background-color: #fff; font-weight: bold;">
<td colspan="4" style="padding: 5px 6px; border: 1px solid #000; text-align: center; font-size: 12px;">合计(人民币)</td>
<td colspan="7" style="padding: 5px 6px; border: 1px solid #000; text-align: center; font-size: 12px;">${productTotalChinese}(¥${formatNumber(productTotal)})</td>
<td colspan="2" style="padding: 5px 6px; border: 1px solid #000; text-align: center; font-size: 12px;">运费(元)</td>
<td colspan="4" style="padding: 5px 6px; border: 1px solid #000; text-align: center; font-size: 12px;">${freightText}</td>
<td colspan="2" style="padding: 5px 6px; border: 1px solid #000; text-align: center; font-size: 12px;">桶押金(元)</td>
<td colspan="3" style="padding: 5px 6px; border: 1px solid #000; text-align: center; font-size: 12px;">${barrelDepositText}</td>
</tr>
<tr style="background-color: #fff; font-weight: bold;">
<td colspan="2" style="padding: 5px 6px; border: 1px solid #000; text-align: center; font-size: 12px;">合计(人民币)</td>
<td colspan="9" style="padding: 5px 6px; border: 1px solid #000; text-align: center; font-size: 12px;">${totalWithExtrasText}</td>
</tr>
<tr>
<td colspan="11" style="padding: 5px 6px; border: 1px solid #000; text-align: center; font-size: 11px; background-color: #fff;">
@@ -1857,9 +1928,21 @@ const generateContractTemplate = (contractData: ContractVO | undefined): string
return sum + (isNaN(taxAmount) ? 0 : taxAmount);
}, 0) || 0;
// 计算产品总金额(含税)
// 计算产品总金额(含税)与合同运费、桶押金
const productTotal = parseFloat(String(contractData.amount || 0));
const productTotalChinese = numberToChinese(productTotal);
const freightRaw = Number(contractData.freight);
const freightAmount = Number.isFinite(freightRaw) && freightRaw > 0 ? freightRaw : 0;
const depositRaw = Number(contractData.barrelDeposit);
const barrelDepositAmount = Number.isFinite(depositRaw) && depositRaw > 0 ? depositRaw : 0;
const totalWithExtras = productTotal + freightAmount + barrelDepositAmount;
const totalWithExtrasChinese = numberToChinese(totalWithExtras);
const freightText = freightAmount > 0 ? `¥${formatNumber(freightAmount)}` : '-';
const barrelDepositText = barrelDepositAmount > 0 ? `¥${formatNumber(barrelDepositAmount)}` : '-';
const isFrameworkContract = isFrameworkContractType(contractData.contractType);
const totalWithExtrasText = isFrameworkContract
? '随行就市'
: `${totalWithExtrasChinese}(¥${formatNumber(totalWithExtras)})`;
// 构建产品明细表格行
const productRows =
@@ -1938,10 +2021,16 @@ const generateContractTemplate = (contractData: ContractVO | undefined): string
</thead>
<tbody>
${productRows}
<!-- 合计行 -->
<!-- 运费/桶押金一行(10 列对半),合计单独一行 -->
<tr style="background-color: #fff; font-weight: bold;">
<td colspan="4" style="padding: 5px 6px; border: 1px solid #000; text-align: center; font-size: 12px;">合计(人民币)</td>
<td colspan="6" style="padding: 5px 6px; border: 1px solid #000; text-align: center; font-size: 12px;">${productTotalChinese}(¥${formatNumber(productTotal)})</td>
<td colspan="2" style="padding: 5px 6px; border: 1px solid #000; text-align: center; font-size: 12px;">运费(元)</td>
<td colspan="3" style="padding: 5px 6px; border: 1px solid #000; text-align: center; font-size: 12px;">${freightText}</td>
<td colspan="2" style="padding: 5px 6px; border: 1px solid #000; text-align: center; font-size: 12px;">桶押金(元)</td>
<td colspan="3" style="padding: 5px 6px; border: 1px solid #000; text-align: center; font-size: 12px;">${barrelDepositText}</td>
</tr>
<tr style="background-color: #fff; font-weight: bold;">
<td colspan="2" style="padding: 5px 6px; border: 1px solid #000; text-align: center; font-size: 12px;">合计(人民币)</td>
<td colspan="8" style="padding: 5px 6px; border: 1px solid #000; text-align: center; font-size: 12px;">${totalWithExtrasText}</td>
</tr>
<!-- 提示行 -->
<tr>
@@ -2147,7 +2236,7 @@ const handleViewCustomer = () => {
/** 查看商机 */
const handleViewOpportunity = () => {
router.push({
path: '/crm/opportunity/detail',
path: '/system/opportunity/detail',
query: { id: contract.value?.opportunityId }
});
};
@@ -2192,9 +2281,14 @@ const handleViewInvoice = (row: any) => {
});
};
/** 预览附件 */
/** 预览附件(新标签页) */
const handlePreviewFile = async (file: any) => {
await openCrmAttachmentPreviewInNewTab(file);
};
/** @deprecated 兼容旧调用 */
const handlePreview = (file: any) => {
window.open(file.url, '_blank');
handlePreviewFile(file);
};
/** 查看原合同 */
@@ -2349,6 +2443,8 @@ const isImageFile = (file: any) => {
return imageExts.includes(ext);
};
const isPdfFile = (file: any) => isCrmPdfFile({ name: file?.name, ossId: file?.ossId, url: file?.url });
/** 获取文件扩展名 */
const getFileExt = (fileName: string) => {
if (!fileName) return 'FILE';
@@ -3046,12 +3142,17 @@ const handleGeneratePdfFile = async () => {
align-items: center;
justify-content: center;
overflow: hidden;
cursor: pointer;
}
.upload-thumb-image {
width: 100%;
height: 100%;
object-fit: cover;
&--passive {
pointer-events: none;
}
}
.upload-file-placeholder {
+17 -7
View File
@@ -2,7 +2,6 @@
<div class="page-container contract-form-page">
<section class="panel">
<div class="panel-top panel-top-with-actions">
<h2 class="title-bar-heading">{{ formTitle }}</h2>
<el-button class="btn-ghost" @click="handleBack">
<el-icon><Back /></el-icon>返回
</el-button>
@@ -107,6 +106,16 @@
<el-input-number v-model="form.amount" :precision="2" :min="0" placeholder="可选填,留空则从产品明细自动计算" style="width: 100%" />
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item label="运费(元)" prop="freight">
<el-input-number v-model="form.freight" :precision="2" :min="0" placeholder="可选,选择报价单后可自动带入" style="width: 100%" />
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item label="桶押金(元)" prop="barrelDeposit">
<el-input-number v-model="form.barrelDeposit" :precision="2" :min="0" placeholder="可选,选择报价单后可自动带入" style="width: 100%" />
</el-form-item>
</el-col>
</el-row>
<!-- 第三行:合同期限(单独一行) -->
@@ -600,7 +609,7 @@ import {
} from '@/utils/crm-attachment';
import { getOpportunity } from '@/api/crm/opportunity';
import { getQuote } from '@/api/crm/quote';
import ProductSelector from './components/ProductSelector.vue';
import ProductSelector from '@/components/business/product-selector/index.vue';
import CustomerSelector from '@/components/CustomerSelector.vue';
import ContactSelector from '@/components/ContactSelector.vue';
import QuoteSelector from '@/components/QuoteSelector.vue';
@@ -649,11 +658,6 @@ const route = useRoute();
const dictStore = useDictStore();
const userStore = useUserStore();
// 表单标题
const formTitle = computed(() => {
return form.value.id ? '编辑合同' : '新增合同';
});
// 合同期限日期范围
const contractDateRange = ref<[string, string]>([]);
@@ -679,6 +683,8 @@ const form = ref<ExtendedContractForm>({
ownerUserId: undefined,
ownerUserName: '',
amount: 0,
freight: 0,
barrelDeposit: 0,
supplierId: undefined,
settlementMethod: undefined,
partyA: '',
@@ -933,6 +939,8 @@ const handleCustomerConfirm = async (customer: CustomerVO) => {
form.value.opportunityName = '';
form.value.quoteId = undefined;
form.value.quoteNo = '';
form.value.freight = 0;
form.value.barrelDeposit = 0;
// 自动获取客户的默认开票信息并填充到需方信息(乙方)
try {
@@ -1165,6 +1173,8 @@ const handleQuoteConfirm = (quote: QuoteVO) => {
if (quote) {
form.value.quoteId = quote.id;
form.value.quoteNo = quote.quoteNo;
form.value.freight = Number(quote.freight) || 0;
form.value.barrelDeposit = Number(quote.barrelDeposit) || 0;
// 自动带出客户信息
if (quote.customerId && !form.value.customerId) {
File diff suppressed because it is too large. Load diff
@@ -2,10 +2,6 @@
<template>
<div class="page-container">
<section class="panel">
<div class="panel-top">
<h2 class="title-bar-heading">合同模板</h2>
</div>
<div class="filter-block">
<el-form ref="queryFormRef" :model="queryParams" class="filter-form" @submit.prevent>
<div class="filter-grid">
@@ -6,6 +6,8 @@
class="dialog-form-layout"
align-center
destroy-on-close
append-to-body
modal-class="order-module-dialog-mask"
:close-on-click-modal="false"
@close="reset"
>
@@ -20,11 +22,11 @@
:scroll-into-view-options="{ behavior: 'smooth', block: 'center' }"
>
<el-divider content-position="left">基本信息</el-divider>
<div class="form-grid-4">
<div class="form-grid-2">
<el-form-item label="客户名称" prop="customerName">
<el-input v-model="form.customerName" placeholder="请输入客户名称" maxlength="200" />
</el-form-item>
<el-form-item label="拼音首字母" class="form-field-span-2">
<el-form-item label="拼音首字母">
<div class="pinyin-abbr-row">
<el-input
v-model="form.namePinyinAbbr"
@@ -38,6 +40,8 @@
</el-button>
</div>
</el-form-item>
</div>
<div class="form-grid-4">
<el-form-item label="客户简称" prop="shortName">
<el-input v-model="form.shortName" placeholder="请输入客户简称" maxlength="100" />
</el-form-item>
@@ -64,6 +68,8 @@
<el-form-item label="手机号" prop="mobile">
<el-input v-model="form.mobile" placeholder="请输入手机号" maxlength="11" />
</el-form-item>
</div>
<div class="form-grid-4">
<el-form-item label="固定电话" prop="telephone">
<el-input v-model="form.telephone" placeholder="请输入固定电话" maxlength="30" />
</el-form-item>
@@ -11,12 +11,20 @@
</div>
<div class="list-body list-wrap">
<el-alert
v-if="!loading && invoiceInfoList.length === 0"
class="invoice-empty-alert"
type="info"
:closable="false"
show-icon
title="暂无开票信息,请点击上方「添加开票信息」进行维护;可维护多条并设置默认,合同等业务将按默认开票信息带出。"
/>
<ListTable table-key="crm-customer-components-invoice-info"
:data="invoiceInfoList"
v-loading="loading"
stripe
class="list-table"
empty-text=""
empty-text="暂无开票信息,请点击「添加开票信息」维护"
>
<el-table-column type="index" label="序号" min-width="68" align="center" header-align="center" />
<el-table-column
@@ -114,8 +122,18 @@
</ListTable>
</div>
<el-dialog :title="dialog.title" v-model="dialog.visible" width="800px" class="dialog-form-layout" align-center append-to-body @close="handleClose">
<el-form ref="formRef" :model="form" :rules="rules" label-position="right" label-width="100px" class="crm-dialog-form">
<el-dialog
:title="dialog.title"
v-model="dialog.visible"
width="800px"
class="dialog-form-layout"
align-center
append-to-body
modal-class="order-module-dialog-mask"
:close-on-click-modal="false"
@close="handleClose"
>
<el-form ref="formRef" :model="form" :rules="rules" label-position="top" class="crm-dialog-form">
<div class="form-grid-2">
<el-form-item label="单位名称(章)" prop="companyName" class="form-col-span-2">
<el-input v-model="form.companyName" placeholder="请输入单位名称" maxlength="200" />
@@ -153,12 +171,14 @@
</div>
</el-form>
<template #footer>
<el-button @click="handleClose">
<el-icon><Close /></el-icon>取消
</el-button>
<el-button type="primary" :loading="submitLoading" @click="submitForm">
<el-icon><Check /></el-icon>确定
</el-button>
<div class="dialog-footer">
<el-button class="btn-ghost" @click="handleClose">
<el-icon><Close /></el-icon>取消
</el-button>
<el-button class="btn-main" type="primary" :loading="submitLoading" @click="submitForm">
<el-icon><Check /></el-icon>确定
</el-button>
</div>
</template>
</el-dialog>
</div>
@@ -360,4 +380,8 @@ defineExpose({ getList })
.invoice-info-container {
margin: 0;
}
.invoice-empty-alert {
margin-bottom: 12px;
}
</style>
+2 -6
View File
@@ -2,17 +2,13 @@
<template>
<div class="page-container">
<section class="panel">
<div class="panel-top">
<h2 class="title-bar-heading">客户列表</h2>
</div>
<el-tabs
v-model="activeView"
class="panel-tabs"
@tab-change="handleViewChange"
>
<el-tab-pane label="我的客户" name="mine" />
<el-tab-pane label="全部客户" name="all" />
<el-tab-pane label="我的客户" name="mine" />
<el-tab-pane label="待跟进" name="toFollow" />
<el-tab-pane label="重点客户" name="key" />
</el-tabs>
@@ -707,7 +703,7 @@ const dateRange = ref<[string, string]>()
const quickSearchKeyword = ref('')
// 视图类型
const activeView = ref('mine')
const activeView = ref('all')
// 数据列表
const customerList = ref<any[]>([])
@@ -2,10 +2,6 @@
<template>
<div class="page-container">
<section class="panel">
<div class="panel-top">
<h2 class="title-bar-heading">公海池规则</h2>
</div>
<!-- 筛选区 -->
<div class="filter-block">
<el-form :model="searchForm" class="filter-form" @submit.prevent>
@@ -2,10 +2,6 @@
<template>
<div class="page-container">
<section class="panel">
<div class="panel-top">
<h2 class="title-bar-heading">公海池</h2>
</div>
<!-- 筛选区 -->
<div class="filter-block">
<el-form :model="searchForm" class="filter-form" @submit.prevent>
@@ -2,9 +2,6 @@
<template>
<div class="page-container">
<section class="panel">
<div class="panel-top">
<h2 class="title-bar-heading">商机详情</h2>
</div>
<el-button class="btn-ghost" @click="goBack">
<el-icon><ArrowLeft /></el-icon>返回列表
</el-button>
@@ -26,7 +23,7 @@
const opportunityId = ref<string>('')
function goBack() {
router.push({ path: '/crm/opportunity' })
router.push({ path: '/system/opportunity' })
}
onMounted(() => {
@@ -1,10 +1,6 @@
<template>
<div class="page-container opportunity-funnel-page">
<section class="panel">
<div class="panel-top">
<h2 class="title-bar-heading">销售漏斗</h2>
</div>
<div class="filter-block">
<el-form ref="queryFormRef" class="filter-form" :model="queryParams" @submit.prevent>
<div class="filter-grid">
@@ -2,10 +2,6 @@
<template>
<div class="page-container">
<section class="panel">
<div class="panel-top">
<h2 class="title-bar-heading">商机管理</h2>
</div>
<el-tabs
v-model="activeView"
class="panel-tabs"
@@ -1033,7 +1029,7 @@
/** 切换视图模式 */
const switchView = (mode: 'list' | 'kanban') => {
if (mode === 'kanban') {
router.push('/crm/opportunity/kanban')
router.push('/system/opportunity/kanban')
} else {
viewMode.value = mode
}
@@ -1041,7 +1037,7 @@
/** 跳转到漏斗分析 */
const goToFunnel = () => {
router.push('/crm/opportunity/funnel')
router.push('/system/opportunity/funnel')
}
watchDebounced(
@@ -1,10 +1,6 @@
<template>
<div class="page-container opportunity-kanban-page">
<section class="panel kanban-panel">
<div class="panel-top">
<h2 class="title-bar-heading">商机看板</h2>
</div>
<div class="filter-block">
<el-form ref="queryFormRef" class="filter-form" :model="queryParams" @submit.prevent>
<div class="filter-grid">
@@ -189,13 +185,13 @@ const resetQuery = () => {
}
const handleViewDetail = (id: number) => {
router.push({ path: '/crm/opportunity/detail', query: { id } })
router.push({ path: '/system/opportunity/detail', query: { id } })
}
const handleCardAction = (command: string, opp: OpportunityVO) => {
switch (command) {
case 'edit':
router.push({ path: '/crm/opportunity', query: { id: opp.id, action: 'edit' } })
router.push({ path: '/system/opportunity', query: { id: opp.id, action: 'edit' } })
break
case 'stage':
changeStageDialogRef.value?.open(opp.id)
@@ -2,7 +2,6 @@
<div class="page-container opportunity-statistics-page">
<section class="panel">
<div class="panel-top panel-top-with-actions">
<h2 class="title-bar-heading">商机统计分析</h2>
<el-button class="btn-ghost" @click="goBack">
<el-icon><Back /></el-icon>返回列表
</el-button>
@@ -240,7 +239,7 @@ let winRateChart: echarts.ECharts | null = null
let ownerChart: echarts.ECharts | null = null
const goBack = () => {
router.push('/crm/opportunity')
router.push('/system/opportunity')
}
const handleQuery = () => {
+317 -63
View File
@@ -3,10 +3,6 @@
<template>
<div class="page-container">
<section class="panel">
<div class="panel-top">
<h2 class="title-bar-heading">调价函管理</h2>
</div>
<el-tabs v-model="activeView" class="panel-tabs" @tab-change="handleTabChange">
<el-tab-pane label="全部" name="all" />
<el-tab-pane label="已作废" name="invalid" />
@@ -54,7 +50,6 @@
</el-form-item>
</div>
<div class="filter-actions-row">
<span class="filter-hint">独立档案,不关联合同/报价单,不回写产品价格。</span>
<div class="filter-actions-end">
<el-button class="btn-ghost" :loading="loading" @click="handleReset">
<el-icon><RefreshLeft /></el-icon>重置
@@ -70,7 +65,7 @@
<div class="list-toolbar">
<div class="list-toolbar-row price-letter-list-toolbar-row">
<ListToolbarDateShortcuts
variant="select"
variant="pills"
:active="activeDateShortcut"
aria-label="调价日期快捷筛选"
@change="handleDateShortcut"
@@ -268,7 +263,7 @@
<el-dialog
v-model="formDialogVisible"
:title="isEdit ? '编辑调价函' : '新增调价函'"
:width="formData.letterType === 'send' ? '1380px' : '720px'"
:width="formData.letterType === 'send' ? '1380px' : '960px'"
align-center
destroy-on-close
class="dialog-form-layout price-letter-form-dialog"
@@ -292,66 +287,181 @@
<el-radio value="send">发出调价函</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="调价日期" prop="adjustDate">
<el-date-picker
v-model="formData.adjustDate"
type="date"
value-format="YYYY-MM-DD"
placeholder="请选择调价日期"
style="width: 100%"
/>
</el-form-item>
<el-form-item label="供应商名称(客户)" prop="customerId">
<el-input v-model="formData.customerName" placeholder="请选择客户" readonly>
<template #append>
<el-button @click="customerSelectorVisible = true">
<!-- 接受:日期+客户一行;产品+现金+汇票一行 -->
<template v-if="formData.letterType === 'receive'">
<div class="form-grid-2">
<el-form-item label="调价日期" prop="adjustDate">
<el-date-picker
v-model="formData.adjustDate"
type="date"
value-format="YYYY-MM-DD"
placeholder="请选择调价日期"
style="width: 100%"
/>
</el-form-item>
<el-form-item label="供应商名称(客户)" prop="customerId">
<div class="customer-select-row">
<el-select
v-model="formData.customerId"
class="customer-select-row__select"
filterable
remote
clearable
:remote-method="searchCustomerOptions"
:loading="customerOptionsLoading"
placeholder="请输入客户名称/拼音首字母搜索"
@focus="handleCustomerSelectFocus"
@change="handleCustomerSelectChange"
>
<el-option
v-for="item in customerOptions"
:key="item.id"
:label="item.customerName"
:value="item.id"
>
<div class="customer-option-row">
<span>{{ item.customerName }}</span>
<span v-if="item.customerNo" class="customer-option-row__meta">{{ item.customerNo }}</span>
</div>
</el-option>
</el-select>
<el-button text class="customer-select-row__search" @click="customerSelectorVisible = true">
<el-icon><Search /></el-icon>
</el-button>
</div>
</el-form-item>
</div>
<div class="form-grid-3">
<el-form-item label="产品名称" prop="productId">
<el-select
v-model="formData.productId"
filterable
remote
clearable
placeholder="请选择产品"
:remote-method="searchProducts"
:loading="productLoading"
style="width: 100%"
@change="handleProductChange"
>
<el-option
v-for="p in productOptions"
:key="p.id"
:label="p.label || p.productName"
:value="p.id"
/>
</el-select>
</el-form-item>
<el-form-item label="调整后现金价格(元)" prop="price">
<el-input-number
v-model="formData.price"
:min="0"
:precision="2"
:step="0.01"
controls-position="right"
style="width: 100%"
/>
</el-form-item>
<el-form-item label="调整后汇票价格(元)" prop="billPrice">
<el-input-number
v-model="formData.billPrice"
:min="0"
:precision="2"
:step="0.01"
controls-position="right"
style="width: 100%"
/>
</el-form-item>
</div>
</template>
<!-- 发出:保持原纵向布局 -->
<template v-else>
<el-form-item label="调价日期" prop="adjustDate">
<el-date-picker
v-model="formData.adjustDate"
type="date"
value-format="YYYY-MM-DD"
placeholder="请选择调价日期"
style="width: 100%"
/>
</el-form-item>
<el-form-item label="供应商名称(客户)" prop="customerId">
<div class="customer-select-row">
<el-select
v-model="formData.customerId"
class="customer-select-row__select"
filterable
remote
clearable
:remote-method="searchCustomerOptions"
:loading="customerOptionsLoading"
placeholder="请输入客户名称/拼音首字母搜索"
@focus="handleCustomerSelectFocus"
@change="handleCustomerSelectChange"
>
<el-option
v-for="item in customerOptions"
:key="item.id"
:label="item.customerName"
:value="item.id"
>
<div class="customer-option-row">
<span>{{ item.customerName }}</span>
<span v-if="item.customerNo" class="customer-option-row__meta">{{ item.customerNo }}</span>
</div>
</el-option>
</el-select>
<el-button text class="customer-select-row__search" @click="customerSelectorVisible = true">
<el-icon><Search /></el-icon>
</el-button>
</template>
</el-input>
</el-form-item>
<el-form-item label="产品名称" prop="productId">
<el-select
v-model="formData.productId"
filterable
remote
clearable
placeholder="请选择产品"
:remote-method="searchProducts"
:loading="productLoading"
style="width: 100%"
@change="handleProductChange"
>
<el-option
v-for="p in productOptions"
:key="p.id"
:label="p.label || p.productName"
:value="p.id"
/>
</el-select>
</el-form-item>
<div class="price-letter-price-row">
<el-form-item label="调整后现金价格(元)" prop="price">
<el-input-number
v-model="formData.price"
:min="0"
:precision="2"
:step="0.01"
controls-position="right"
style="width: 100%"
/>
</div>
</el-form-item>
<el-form-item label="调整后汇票价格(元)" prop="billPrice">
<el-input-number
v-model="formData.billPrice"
:min="0"
:precision="2"
:step="0.01"
controls-position="right"
<el-form-item label="产品名称" prop="productId">
<el-select
v-model="formData.productId"
filterable
remote
clearable
placeholder="请选择产品"
:remote-method="searchProducts"
:loading="productLoading"
style="width: 100%"
/>
@change="handleProductChange"
>
<el-option
v-for="p in productOptions"
:key="p.id"
:label="p.label || p.productName"
:value="p.id"
/>
</el-select>
</el-form-item>
</div>
<div class="price-letter-price-row">
<el-form-item label="调整后现金价格(元)" prop="price">
<el-input-number
v-model="formData.price"
:min="0"
:precision="2"
:step="0.01"
controls-position="right"
style="width: 100%"
/>
</el-form-item>
<el-form-item label="调整后汇票价格(元)" prop="billPrice">
<el-input-number
v-model="formData.billPrice"
:min="0"
:precision="2"
:step="0.01"
controls-position="right"
style="width: 100%"
/>
</el-form-item>
</div>
</template>
<el-form-item
:label="formData.letterType === 'receive' ? '调价函附件' : '附件(可选,如盖章扫描件)'"
prop="attachmentUrls"
@@ -505,7 +615,7 @@
import { formatMoneyDisplay } from '@/utils/money-format'
import { $modal } from '@/utils/modal'
import { fetchProductOptions } from '@/api/crm/product'
import { fetchCustomerDetail } from '@/api/crm/customer'
import { fetchCustomerDetail, fetchCustomerList } from '@/api/crm/customer'
import {
fetchPriceLetterList,
fetchPriceLetterDetail,
@@ -601,6 +711,104 @@
const productOptions = ref<any[]>([])
const productLoading = ref(false)
const customerSelectorVisible = ref(false)
const customerOptions = ref<Array<{ id: string; customerName: string; customerNo?: string }>>([])
const customerOptionsLoading = ref(false)
function extractCustomerList(res: unknown): Array<{ id: string; customerName: string; customerNo?: string }> {
const data = (res as { data?: unknown })?.data ?? res ?? {}
const list =
(data as { list?: any[]; rows?: any[] }).list || (data as { rows?: any[] }).rows || []
return Array.isArray(list) ? list : []
}
function ensureCustomerOption(customer?: { id?: string; customerName?: string; customerNo?: string } | null) {
if (!customer?.id) return
const exists = customerOptions.value.some((item) => String(item.id) === String(customer.id))
if (exists) {
customerOptions.value = customerOptions.value.map((item) =>
String(item.id) === String(customer.id)
? {
...item,
customerName: customer.customerName || item.customerName,
customerNo: customer.customerNo ?? item.customerNo
}
: item
)
return
}
customerOptions.value = [
{
id: customer.id,
customerName: customer.customerName || '',
customerNo: customer.customerNo
},
...customerOptions.value
]
}
async function loadDefaultCustomerOptions() {
customerOptionsLoading.value = true
try {
const res = await fetchCustomerList({ page: 1, pageSize: 20 })
customerOptions.value = extractCustomerList(res)
if (formData.customerId) {
ensureCustomerOption({
id: formData.customerId,
customerName: formData.customerName
})
}
} catch (error) {
console.error('加载客户列表失败:', error)
customerOptions.value = []
} finally {
customerOptionsLoading.value = false
}
}
async function searchCustomerOptions(query: string) {
const keyword = query?.trim()
if (!keyword) {
await loadDefaultCustomerOptions()
return
}
customerOptionsLoading.value = true
try {
const res = await fetchCustomerList({
keyword,
page: 1,
pageSize: 50
})
customerOptions.value = extractCustomerList(res)
if (formData.customerId) {
ensureCustomerOption({
id: formData.customerId,
customerName: formData.customerName
})
}
} catch (error) {
console.error('搜索客户失败:', error)
customerOptions.value = []
} finally {
customerOptionsLoading.value = false
}
}
function handleCustomerSelectFocus() {
if (customerOptions.value.length === 0) {
loadDefaultCustomerOptions()
}
}
function handleCustomerSelectChange(customerId?: string) {
if (!customerId) {
formData.customerId = ''
formData.customerName = ''
return
}
const customer = customerOptions.value.find((item) => String(item.id) === String(customerId))
formData.customerId = customerId
formData.customerName = customer?.customerName || formData.customerName || ''
}
const detailDialogVisible = ref(false)
const detailData = ref<any>(null)
@@ -843,7 +1051,9 @@
function handleAdd() {
isEdit.value = false
resetForm()
customerOptions.value = []
formDialogVisible.value = true
loadDefaultCustomerOptions()
}
async function openEdit(row: any) {
@@ -870,7 +1080,15 @@
{ id: res.productId, productName: res.productName, label: res.productName }
]
}
customerOptions.value = []
if (res.customerId) {
ensureCustomerOption({
id: res.customerId,
customerName: res.customerName || ''
})
}
formDialogVisible.value = true
loadDefaultCustomerOptions()
}
function handleToolbarEdit() {
@@ -896,6 +1114,11 @@
if (!customer) return
formData.customerId = customer.id
formData.customerName = customer.customerName || ''
ensureCustomerOption({
id: customer.id,
customerName: customer.customerName || '',
customerNo: customer.customerNo
})
}
async function searchProducts(keyword: string) {
@@ -1175,6 +1398,37 @@ ${preparedHtml}
gap: 12px 16px;
}
.customer-select-row {
display: flex;
align-items: center;
gap: 4px;
width: 100%;
}
.customer-select-row__select {
flex: 1;
min-width: 0;
}
.customer-select-row__search {
flex-shrink: 0;
padding: 0 8px;
}
.customer-option-row {
display: flex;
justify-content: space-between;
align-items: center;
gap: 12px;
min-width: 0;
}
.customer-option-row__meta {
flex-shrink: 0;
font-size: 12px;
color: var(--mint-text-muted, #8492a6);
}
.price-letter-list-toolbar-row {
flex-wrap: nowrap;
overflow-x: auto;
@@ -1,549 +1,12 @@
<!-- 产品分类管理 -->
<!-- eslint-disable vue/no-v-model-argument -->
<!-- 产品分类管理(侧栏已软隐藏;路由直链仍可用) -->
<template>
<div class="page-container">
<section class="panel">
<div class="panel-top">
<h2 class="title-bar-heading">产品分类</h2>
</div>
<!-- 筛选区 -->
<div class="filter-block">
<el-form :model="searchForm" class="filter-form" @submit.prevent>
<div class="filter-grid">
<el-form-item label="分类名称">
<el-input
v-model="searchForm.categoryName"
placeholder="分类名称"
clearable
@keyup.enter="handleSearch"
/>
</el-form-item>
<el-form-item label="状态">
<el-select v-model="searchForm.status" placeholder="全部" clearable>
<el-option
v-for="opt in dictStore.getOptions('sys_normal_disable')"
:key="opt.value"
:label="opt.label"
:value="opt.value"
/>
</el-select>
</el-form-item>
</div>
<div class="filter-actions-row">
<span class="filter-hint">按分类名称模糊查询。</span>
<div class="filter-actions-end">
<el-button class="btn-ghost" :loading="loading" @click="handleReset">
<el-icon><RefreshLeft /></el-icon>重置
</el-button>
<el-button class="btn-main" type="primary" :loading="loading" @click="handleSearch">
<el-icon><Search /></el-icon>搜索
</el-button>
</div>
</div>
</el-form>
</div>
<!-- 工具栏 -->
<div class="list-toolbar">
<div class="list-toolbar-row">
<ListQuickSearchInput
v-model="quickSearchKeyword"
placeholder="分类名称"
@search="handleQuickSearch"
@clear="handleQuickSearchClear"
/>
<el-button class="btn-main" type="primary" @click="handleAdd()">
<el-icon><Plus /></el-icon>
新增
</el-button>
<el-button class="btn-ghost" @click="toggleExpandAll">
{{ isExpandAll ? '全部折叠' : '全部展开' }}
</el-button>
<el-button
class="btn-ghost"
:disabled="!selectedId"
@click="handleUpdate()"
>
<el-icon><Edit /></el-icon>
修改
</el-button>
<el-button
class="btn-ghost"
:disabled="!selectedId"
@click="handleAddChild()"
>
<el-icon><Plus /></el-icon>
新增子分类
</el-button>
<el-button
class="btn-ghost"
:disabled="!selectedId || !canDeleteSelectedCategory"
:title="canDeleteSelectedCategory ? '' : CREATOR_DELETE_TIP"
@click="handleDelete()"
>
<el-icon><Delete /></el-icon>
删除
</el-button>
<ListToolbarEndActions
:loading="loading"
:column-defs="listColumnDefs"
v-model:visible-columns="visibleColumns"
v-model:check-all="checkAll"
:is-indeterminate="isIndeterminate"
@refresh="getList"
@reset-columns="resetToDefault"
/>
</div>
</div>
<!-- 树形表格 -->
<div class="list-body list-wrap">
<ListTable table-key="crm-product-category"
v-if="refreshTable"
ref="tableRef"
class="list-table"
:data="categoryList"
v-loading="loading"
stripe
row-key="id"
:default-expand-all="isExpandAll"
:tree-props="{ children: 'children', hasChildren: 'hasChildren' }"
highlight-current-row
@selection-change="handleSelectionChange"
@row-dblclick="handleRowEdit"
>
<el-table-column type="selection" min-width="55" align="center" header-align="center" />
<el-table-column type="index" label="序号" min-width="68" align="center" header-align="center" />
<el-table-column
prop="categoryName"
label="分类名称"
min-width="200"
align="left"
header-align="left"
show-overflow-tooltip
/>
<el-table-column
v-if="isColumnVisible('orderNum')"
prop="orderNum"
label="排序"
min-width="80"
align="center"
header-align="center"
/>
<el-table-column
v-if="isColumnVisible('status')"
prop="status"
label="状态"
min-width="80"
align="center"
header-align="center"
>
<template #default="{ row }">
<el-tag
:type="dictStore.getTagType('sys_normal_disable', row.status)"
size="small"
>
{{ dictStore.getLabel('sys_normal_disable', row.status) }}
</el-tag>
</template>
</el-table-column>
<el-table-column
v-if="isColumnVisible('createTime')"
prop="createTime"
label="创建时间"
min-width="160"
align="center"
header-align="center"
show-overflow-tooltip
/>
</ListTable>
</div>
<div class="pagination list-pager-bar">
<div class="list-pager-selected">
已选 <span class="sel-num">{{ selectedRows.length }}</span> 项
</div>
</div>
<!-- 新增/编辑分类弹窗(内联) -->
<el-dialog
v-model="dialogVisible"
:title="dialogTitle"
width="640px"
class="dialog-form-layout"
align-center
destroy-on-close
:close-on-click-modal="false"
@close="handleDialogClose"
>
<el-form
ref="formRef"
:model="formData"
:rules="formRules"
label-position="right"
label-width="100px"
class="crm-dialog-form"
scroll-to-error
:scroll-into-view-options="{ behavior: 'smooth', block: 'center' }"
>
<div class="form-grid-2">
<el-form-item label="上级分类" style="grid-column: 1 / -1">
<el-tree-select
v-model="formData.parentId"
:data="categoryTreeOptions"
node-key="id"
:props="{ label: 'categoryName', children: 'children' }"
value-key="id"
check-strictly
filterable
clearable
placeholder="选择上级分类(留空为顶级)"
style="width: 100%"
/>
</el-form-item>
<el-form-item label="分类名称" prop="categoryName">
<el-input v-model="formData.categoryName" placeholder="请输入分类名称" />
</el-form-item>
<el-form-item label="排序号">
<el-input-number
v-model="formData.orderNum"
controls-position="right"
:min="0"
style="width: 100%"
/>
</el-form-item>
<el-form-item label="状态">
<el-select v-model="formData.status" placeholder="请选择状态" style="width: 100%">
<el-option
v-for="opt in dictStore.getOptions('sys_normal_disable')"
:key="opt.value"
:label="opt.label"
:value="opt.value"
/>
</el-select>
</el-form-item>
<el-form-item label="备注">
<el-input
v-model="formData.remark"
type="textarea"
placeholder="请输入备注"
/>
</el-form-item>
</div>
</el-form>
<template #footer>
<el-button class="btn-ghost" @click="dialogVisible = false">
<el-icon><Close /></el-icon>取消
</el-button>
<el-button class="btn-main" type="primary" :loading="submitLoading" @click="submitForm">
<el-icon><Check /></el-icon>确定
</el-button>
</template>
</el-dialog>
<ProductCategoryMaintainPanel />
</section>
</div>
</template>
<script setup lang="ts">
import ListToolbarEndActions from '@/components/business/list-toolbar-end-actions/index.vue'
import ListQuickSearchInput from '@/components/business/list-quick-search-input/index.vue'
import { usePersistedListColumns } from '@/composables/usePersistedListColumns'
import { ref, reactive, onMounted, nextTick, computed } from 'vue'
import { ElMessage, ElMessageBox } from 'element-plus'
import type { FormInstance } from 'element-plus'
import {
Plus,
Edit,
Delete,
Close,
Check,
Search,
RefreshLeft,
} from '@element-plus/icons-vue'
import { useDictStore } from '@/store/modules/dict'
import { canDeleteByCreator, CREATOR_DELETE_TIP } from '@/utils/creator-delete'
import {
fetchCategoryTree,
fetchCreateCategory,
fetchUpdateCategory,
fetchDeleteCategory,
} from '@/api/crm/product'
const dictStore = useDictStore()
const listColumnDefs = [
{ prop: 'orderNum', label: '排序' },
{ prop: 'status', label: '状态' },
{ prop: 'createTime', label: '创建时间' }
]
const {
visibleColumns,
checkAll,
isIndeterminate,
isColumnVisible,
resetToDefault
} = usePersistedListColumns('crm_product_category_visible_columns', listColumnDefs)
// ── 列表数据 ──
const categoryList = ref<any[]>([])
const loading = ref(false)
const isExpandAll = ref(true)
const refreshTable = ref(true)
const selectedId = ref<string>()
const selectedRows = ref<any[]>([])
const canDeleteSelectedCategory = computed(() => {
if (!selectedId.value) return false
const node = findNodeById(categoryList.value, selectedId.value)
return canDeleteByCreator(node)
})
// ── 弹窗数据 ──
const dialogVisible = ref(false)
const dialogTitle = ref('')
const submitLoading = ref(false)
const formData = reactive({
id: '',
parentId: '',
categoryName: '',
orderNum: 0,
status: '0',
remark: '',
})
const formRules = {
categoryName: [{ required: true, message: '分类名称不能为空', trigger: 'blur' }],
}
const formRef = ref<FormInstance>()
const categoryTreeOptions = ref<any[]>([])
// ── 筛选 ──
const searchForm = reactive({
categoryName: '',
status: '',
})
const quickSearchKeyword = ref('')
// ── 获取列表(树形) ──
async function getList() {
loading.value = true
try {
const params: Record<string, any> = {}
const quickKeyword = quickSearchKeyword.value?.trim()
if (quickKeyword) {
params.categoryName = quickKeyword
} else if (searchForm.categoryName) {
params.categoryName = searchForm.categoryName
}
if (searchForm.status) params.status = searchForm.status
const res = await fetchCategoryTree(params)
categoryList.value = (res as any)?.data || res || []
} finally {
loading.value = false
}
}
// ── 获取上级分类下拉树 ──
async function getCategoryTreeSelect() {
const res = await fetchCategoryTree({})
const data = (res as any)?.data || res || []
// 加一个顶级分类虚拟节点
categoryTreeOptions.value = [
{
id: '0',
categoryName: '顶级分类',
parentId: '0',
children: data,
},
]
}
// ── 筛选操作 ──
function handleSearch() {
quickSearchKeyword.value = ''
getList()
}
function handleReset() {
searchForm.categoryName = ''
searchForm.status = ''
quickSearchKeyword.value = ''
getList()
}
function handleQuickSearch() {
getList()
}
function handleQuickSearchClear() {
quickSearchKeyword.value = ''
getList()
}
// ── 表格行选中 ──
function handleSelectionChange(rows: any[]) {
selectedRows.value = rows
selectedId.value = rows.length === 1 ? rows[0]?.id : undefined
}
// ── 展开/折叠 ──
function toggleExpandAll() {
refreshTable.value = false
isExpandAll.value = !isExpandAll.value
nextTick(() => {
refreshTable.value = true
})
}
// ── 新增 ──
function handleAdd(parentRow?: any) {
resetForm()
getCategoryTreeSelect()
if (parentRow?.id) {
formData.parentId = parentRow.id
}
dialogTitle.value = '新增产品分类'
dialogVisible.value = true
}
// ── 新增子分类 ──
function handleAddChild() {
if (!selectedId.value) {
ElMessage.warning('请先选择一条分类')
return
}
const parentRow = findNodeById(categoryList.value, selectedId.value)
handleAdd(parentRow)
}
// ── 修改 ──
async function handleUpdate() {
await openEditForRow()
}
async function handleRowEdit(row: any) {
await openEditForRow(row)
}
async function openEditForRow(row?: any) {
const targetId = row?.id ?? selectedId.value
if (!targetId) {
ElMessage.warning('请选择一条数据进行修改')
return
}
resetForm()
await getCategoryTreeSelect()
const node = row ?? findNodeById(categoryList.value, targetId)
if (!node) {
ElMessage.warning('未找到选中的数据')
return
}
selectedId.value = node.id
formData.id = node.id
formData.parentId = node.parentId || ''
formData.categoryName = node.categoryName
formData.orderNum = node.orderNum ?? 0
formData.status = node.status ?? '0'
formData.remark = node.remark ?? ''
dialogTitle.value = '修改产品分类'
dialogVisible.value = true
}
// ── 删除 ──
async function handleDelete() {
if (!selectedId.value) {
ElMessage.warning('请选择一条数据进行删除')
return
}
const node = findNodeById(categoryList.value, selectedId.value)
if (!canDeleteByCreator(node)) {
ElMessage.warning(CREATOR_DELETE_TIP)
return
}
await ElMessageBox.confirm('是否确认删除该产品分类?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
await fetchDeleteCategory({ id: selectedId.value })
ElMessage.success('删除成功')
selectedId.value = undefined
await getList()
}
// ── 提交表单 ──
async function submitForm() {
const valid = await formRef.value?.validate().catch(() => false)
if (!valid) return
submitLoading.value = true
try {
if (formData.id) {
await fetchUpdateCategory({
id: formData.id,
parentId: formData.parentId || '0',
categoryName: formData.categoryName,
orderNum: formData.orderNum,
status: formData.status,
remark: formData.remark,
})
ElMessage.success('修改成功')
} else {
await fetchCreateCategory({
parentId: formData.parentId || '0',
categoryName: formData.categoryName,
orderNum: formData.orderNum,
status: formData.status,
remark: formData.remark,
})
ElMessage.success('新增成功')
}
dialogVisible.value = false
await getList()
} finally {
submitLoading.value = false
}
}
// ── 弹窗关闭 ──
function handleDialogClose() {
resetForm()
}
// ── 重置表单 ──
function resetForm() {
formData.id = ''
formData.parentId = ''
formData.categoryName = ''
formData.orderNum = 0
formData.status = '0'
formData.remark = ''
formRef.value?.resetFields()
}
// ── 工具函数:在树中查找节点 ──
function findNodeById(tree: any[], id: string): any {
for (const node of tree) {
if (node.id === id) return node
if (node.children?.length) {
const found = findNodeById(node.children, id)
if (found) return found
}
}
return null
}
// 输入检索条件时自动搜索(防抖 300ms,对齐租户/菜单管理)
watchDebounced(
searchForm,
() => {
quickSearchKeyword.value = ''
getList()
},
{ debounce: 300, deep: true }
)
onMounted(() => {
getList()
})
import ProductCategoryMaintainPanel from '@/components/business/product-category-maintain-panel/index.vue'
</script>
+34 -5
View File
@@ -3,10 +3,6 @@
<template>
<div class="page-container">
<section class="panel">
<div class="panel-top">
<h2 class="title-bar-heading">产品管理</h2>
</div>
<!-- 筛选区 -->
<div class="filter-block">
<el-form :model="searchForm" class="filter-form" @submit.prevent>
@@ -109,6 +105,10 @@
<el-icon><Download /></el-icon>
导出
</el-button>
<el-button class="btn-ghost" @click="categoryMaintainVisible = true">
<el-icon><Folder /></el-icon>
产品分类
</el-button>
<ListToolbarEndActions
:loading="loading"
@@ -289,6 +289,11 @@
@success="handleFormSuccess"
/>
<ProductCategoryMaintainDialog
v-model="categoryMaintainVisible"
@closed="handleCategoryMaintainClosed"
/>
<!-- 详情弹窗 -->
<SystemViewDialog
v-model:visible="detailDialogVisible"
@@ -398,13 +403,15 @@
Upload,
Top,
Bottom,
Box
Box,
Folder
} from '@element-plus/icons-vue'
import SystemViewDialog, {
type ViewField,
type ViewSection
} from '@/components/business/system-view-dialog/index.vue'
import ProductFormDialog from '@/components/business/product-form-dialog/index.vue'
import ProductCategoryMaintainDialog from '@/components/business/product-category-maintain-dialog/index.vue'
import { crmDictField, crmField, crmLongField, crmTagField } from '@/utils/crm/view-fields'
import { useDictStore } from '@/store/modules/dict'
import { formatMoneyDisplay } from '@/utils/money-format'
@@ -459,6 +466,7 @@
const productList = ref<any[]>([])
const categoryOptions = ref<any[]>([])
const loading = ref(false)
const categoryMaintainVisible = ref(false)
const listColumnDefs = [
{ prop: 'productNo', label: '产品编号' },
@@ -577,6 +585,27 @@
categoryOptions.value = (res as any)?.data || res || []
}
function findCategoryNodeById(tree: any[], id: string): any {
for (const node of tree) {
if (node.id === id) return node
if (node.children?.length) {
const found = findCategoryNodeById(node.children, id)
if (found) return found
}
}
return null
}
async function handleCategoryMaintainClosed() {
await getCategoryOptions()
const selectedId = searchForm.categoryId
if (selectedId && !findCategoryNodeById(categoryOptions.value, selectedId)) {
searchForm.categoryId = ''
pagination.page = 1
await getList()
}
}
function handleSearch() {
quickSearchKeyword.value = ''
pagination.page = 1
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,7 @@
<template>
<QuoteListPage mode="approve" />
</template>
<script setup lang="ts" name="CrmQuoteApproval">
import QuoteListPage from '../QuoteListPage.vue'
</script>
@@ -1,9 +1,6 @@
<template>
<div class="page-container">
<section class="panel">
<div class="panel-top">
<h2 class="title-bar-heading">报价单审批人设置</h2>
</div>
<div class="panel-body quote-approver-setting-body">
<el-form ref="formRef" :model="form" label-position="top" class="crm-dialog-form">
<div class="form-grid-2">
@@ -1,331 +0,0 @@
<template>
<el-dialog
title="选择产品"
v-model="dialogVisible"
width="80%"
align-center
append-to-body
class="dialog-form-layout"
modal-class="order-module-dialog-mask"
:close-on-click-modal="false"
>
<!-- 查询表单 -->
<el-form :model="queryParams" ref="queryFormRef" label-width="90px" class="mb-3">
<el-row :gutter="20">
<el-col :xl="4" :lg="6" :md="8" :sm="12" :xs="24">
<el-form-item label="产品名称" prop="productName">
<el-input v-model="queryParams.productName" placeholder="请输入产品名称" clearable @keyup.enter="handleQuery" />
</el-form-item>
</el-col>
<el-col :xl="4" :lg="6" :md="8" :sm="12" :xs="24">
<el-form-item label="产品分类" prop="categoryId">
<el-tree-select
v-model="queryParams.categoryId"
:data="categoryTree"
placeholder="请选择产品分类"
clearable
check-strictly
:render-after-expand="false"
style="width: 100%"
/>
</el-form-item>
</el-col>
<el-col :xl="4" :lg="6" :md="8" :sm="12" :xs="24">
<el-form-item label="产品状态" prop="status">
<el-select v-model="queryParams.status" placeholder="请选择状态" clearable style="width: 100%">
<el-option
v-for="opt in dictStore.getOptions('crm_product_status')"
:key="opt.value"
:label="opt.label"
:value="opt.value"
/>
</el-select>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="24" style="text-align: right">
<el-button type="primary" :loading="loading" @click="handleQuery">
<el-icon><Search /></el-icon>搜索
</el-button>
<el-button :loading="loading" @click="resetQuery">
<el-icon><Refresh /></el-icon>重置
</el-button>
</el-col>
</el-row>
</el-form>
<!-- 产品列表 -->
<div class="panel dialog-list-panel">
<div class="list-body list-wrap dialog-list-body-only">
<ListTable table-key="crm-quote-components-product-selector"
ref="tableRef"
v-loading="loading"
:data="productList"
class="list-table"
stripe
@selection-change="handleSelectionChange"
:max-height="400"
>
<el-table-column type="selection" min-width="55" align="center" header-align="center" />
<el-table-column type="index" label="序号" min-width="60" align="center" header-align="center" />
<el-table-column label="产品编号" prop="productNo" min-width="140" align="center" header-align="center" :show-overflow-tooltip="true" />
<el-table-column
label="产品名称"
prop="productName"
min-width="240"
align="left"
header-align="left"
class-name="col-name-wrap"
label-class-name="col-name-wrap"
/>
<el-table-column label="产品分类" prop="categoryName" min-width="120" align="center" header-align="center" />
<el-table-column label="规格型号" prop="model" min-width="120" align="center" header-align="center" :show-overflow-tooltip="true" />
<el-table-column label="计量单位" prop="unit" min-width="100" align="center" header-align="center">
<template #default="scope">
<DictTag dict-type="crm_product_unit" :value="scope.row.unit" />
</template>
</el-table-column>
<el-table-column label="税率(%)" prop="taxRate" min-width="90" align="center" header-align="center">
<template #default="scope">
<span>{{ scope.row.taxRate || 0 }}%</span>
</template>
</el-table-column>
<el-table-column label="状态" prop="status" min-width="90" align="center" header-align="center">
<template #default="scope">
<el-tag :type="dictStore.getTagType('crm_product_status', scope.row.status)" size="small">
{{ dictStore.getLabel('crm_product_status', scope.row.status) }}
</el-tag>
</template>
</el-table-column>
</ListTable>
<ListPagination
v-show="total > 0"
:total="total"
v-model:page="queryParams.pageNum"
v-model:limit="queryParams.pageSize"
@pagination="getList"
class="pagination list-pager-bar"
/>
</div>
</div>
<!-- 已选产品 -->
<el-divider content-position="left">已选产品 ({{ selectedProducts.length }})</el-divider>
<div class="selected-products">
<el-tag v-for="product in selectedProducts" :key="product.id" closable @close="handleRemoveSelection(product)" class="mr-2 mb-2">
{{ product.productName }}
</el-tag>
<span v-if="selectedProducts.length === 0" class="text-muted">暂无选择</span>
</div>
<template #footer>
<div class="dialog-footer">
<el-button class="btn-ghost" @click="handleClose">
<el-icon><Close /></el-icon>取消
</el-button>
<el-button class="btn-main" type="primary" @click="handleConfirm" :disabled="selectedProducts.length === 0">
<el-icon><Check /></el-icon>确定 ({{ selectedProducts.length }})
</el-button>
</div>
</template>
</el-dialog>
</template>
<script setup lang="ts" name="ProductSelector">
import { useDictStore } from '@/store/modules/dict'
const dictStore = useDictStore()
import DictTag from '@/components/DictTag/index.vue'
import ListPagination from '@/components/ListPagination/index.vue'
import { $modal } from '@/utils/modal'
import { Check, Close, Refresh, Search } from '@element-plus/icons-vue'
import { ref, watch } from 'vue';
import type { ElFormInstance } from 'element-plus';
import { fetchProductList, fetchCategoryTree } from '@/api/crm/product';
// 定义组件属性
interface Props {
visible: boolean
supplierId?: string | number
}
const props = defineProps<Props>();
// 定义事件
const emit = defineEmits(['update:visible', 'confirm']);
// 对话框显示状态
const dialogVisible = ref(false);
// 监听visible变化
watch(
() => props.visible,
(val) => {
dialogVisible.value = val;
if (val) {
// 打开对话框时加载数据
getList();
loadCategoryTree();
}
}
);
// 监听dialogVisible变化
watch(dialogVisible, (val) => {
emit('update:visible', val);
});
// 查询参数
const queryParams = ref({
pageNum: 1,
pageSize: 20,
productName: undefined,
categoryId: undefined,
status: 'on' // on-上架 off-下架
});
// 产品列表
const productList = ref<any[]>([]);
const loading = ref(false);
const total = ref(0);
// 产品分类树
const categoryTree = ref<any[]>([]);
// 已选产品
const selectedProducts = ref<any[]>([]);
const queryFormRef = ref<ElFormInstance>();
const tableRef = ref<any>();
/** 查询产品列表 */
const getList = async () => {
loading.value = true;
try {
const res = await fetchProductList({
page: queryParams.value.pageNum,
pageSize: queryParams.value.pageSize,
keyword: queryParams.value.productName,
categoryId: queryParams.value.categoryId,
status: queryParams.value.status,
supplierId: props.supplierId != null && props.supplierId !== '' ? String(props.supplierId) : undefined
});
const data = (res as any)?.data || res || {};
productList.value = data.list || data.rows || [];
total.value = data.total ?? 0;
} catch (error) {
console.error('获取产品列表失败:', error);
} finally {
loading.value = false;
}
};
/** 加载产品分类树 */
const loadCategoryTree = async () => {
try {
const res = await fetchCategoryTree({});
const treeData = (res as any)?.data ?? res ?? [];
categoryTree.value = convertTreeData(treeData);
} catch (error) {
console.error('获取产品分类失败:', error);
}
};
/** 转换树形数据格式 */
const convertTreeData = (data: any[]): any[] => {
return data.map((item) => ({
value: item.id,
label: item.categoryName,
children: item.children ? convertTreeData(item.children) : undefined
}));
};
/** 搜索按钮操作 */
const handleQuery = () => {
queryParams.value.pageNum = 1;
getList();
};
/** 重置按钮操作 */
const resetQuery = () => {
queryFormRef.value?.resetFields();
handleQuery();
};
watchDebounced(
() => ({
productName: queryParams.value.productName,
categoryId: queryParams.value.categoryId,
status: queryParams.value.status,
}),
() => {
queryParams.value.pageNum = 1;
getList();
},
{ debounce: 300, deep: true }
);
/** 多选框选中数据 */
const handleSelectionChange = (selection: ProductVO[]) => {
selectedProducts.value = selection;
};
/** 移除已选产品 */
const handleRemoveSelection = (product: ProductVO) => {
const index = selectedProducts.value.findIndex((p) => p.id === product.id);
if (index > -1) {
selectedProducts.value.splice(index, 1);
}
};
/** 确认选择 */
const handleConfirm = () => {
emit('confirm', selectedProducts.value);
handleClose();
};
/** 关闭对话框 */
const handleClose = () => {
selectedProducts.value = [];
dialogVisible.value = false;
};
</script>
<style scoped lang="scss">
.selected-products {
min-height: 40px;
padding: 10px;
background-color: #f5f7fa;
border-radius: 4px;
}
.text-primary {
color: #409eff;
font-weight: 500;
}
.text-muted {
color: #1e293b;
}
.mr-2 {
margin-right: 8px;
}
.mb-2 {
margin-bottom: 8px;
}
.mt-3 {
margin-top: 16px;
}
.mb-3 {
margin-bottom: 16px;
}
.black-icon-btn :deep(.el-icon) {
color: #000 !important;
}
</style>
@@ -12,31 +12,22 @@
dialog-class="quote-view-dialog"
modal-class="order-module-dialog-mask"
append-to-body
@field-view="handleFieldView"
>
<template #hero-actions>
<div class="quote-view-hero-actions">
<el-button
class="btn-ghost"
@click="handleGenerate"
>
<el-button class="btn-ghost" @click="handleGenerate">
<el-icon><Document /></el-icon>生成报价单
</el-button>
<el-button
v-if="quoteInfo.customerId"
class="btn-ghost"
@click="handleViewCustomer"
>
<el-icon><User /></el-icon>查看客户
</el-button>
<el-button
v-if="quoteInfo.status === 'draft'"
v-if="manageActions && isQuoteEditableStatus(quoteInfo.status)"
class="btn-ghost"
@click="handleEdit"
>
<el-icon><Edit /></el-icon>修改
</el-button>
<el-button
v-if="quoteInfo.status === 'draft'"
v-if="manageActions && quoteInfo.status === 'draft'"
class="btn-main"
type="primary"
@click="handleSubmit"
@@ -51,15 +42,6 @@
>
<el-icon><CircleClose /></el-icon>作废
</el-button>
<el-button
v-if="quoteInfo.status !== 'invalid' && canDeleteByCreator(quoteInfo)"
class="btn-ghost"
type="danger"
:title="canDeleteByCreator(quoteInfo) ? '' : CREATOR_DELETE_TIP"
@click="handleDelete"
>
<el-icon><Delete /></el-icon>删除
</el-button>
</div>
</template>
@@ -151,20 +133,6 @@
</ListTable>
</div>
</div>
<div v-if="(quoteInfo.productList?.length || 0) > 0" class="quote-product-summary">
<div class="quote-product-summary-item">
<span class="quote-product-summary-label">产品数量</span>
<strong>{{ quoteInfo.productList?.length || 0 }} 个</strong>
</div>
<div class="quote-product-summary-item">
<span class="quote-product-summary-label">产品总金额</span>
<strong class="money-display">¥{{ formatAmount(quoteInfo.totalAmount) }}</strong>
</div>
<div class="quote-product-summary-item">
<span class="quote-product-summary-label">最终金额</span>
<strong class="money-display">¥{{ formatAmount(quoteInfo.finalAmount) }}</strong>
</div>
</div>
</template>
<template #attachments>
@@ -312,11 +280,9 @@
import { computed, ref, defineAsyncComponent, nextTick } from 'vue'
import {
CircleClose,
Delete,
Document,
DocumentChecked,
Edit,
User
Edit
} from '@element-plus/icons-vue'
import SystemViewDialog, {
type ViewField,
@@ -328,13 +294,12 @@ const CustomerDetailDialog = defineAsyncComponent(
() => import('@/views/crm/customer/CustomerDetailDialog.vue')
)
import { useDictStore } from '@/store/modules/dict'
import { canDeleteByCreator, CREATOR_DELETE_TIP } from '@/utils/creator-delete'
import { $modal } from '@/utils/modal'
import { isQuoteEditableStatus, getQuoteReeditConfirmMessage } from '../quoteStatus'
import { applyAliasDisplayMeta, formatBrandConstraintLabel } from '@/utils/crm-product-brand'
import { parseTime } from '@/utils/format'
import {
getQuote,
delQuote,
invalidQuote,
listApproval,
type QuoteVO,
@@ -342,6 +307,14 @@ import {
} from '@/api/crm/quote'
import { fetchProductDetail } from '@/api/crm/product'
withDefaults(
defineProps<{
/** 是否展示制单类操作(修改/提交审批) */
manageActions?: boolean
}>(),
{ manageActions: true }
)
const quoteTypeMap: Record<string, { label: string; tag: 'success' | 'warning' }> = {
sales: { label: '销售', tag: 'success' },
purchase: { label: '采购', tag: 'warning' }
@@ -442,7 +415,12 @@ const viewSections = computed<ViewSection[]>(() => {
value: getQuoteTypeLabel(q.quoteType),
tagType: getQuoteTypeTag(q.quoteType)
},
{ label: labels.customerName, value: q.customerName },
{
label: labels.customerName,
value: q.customerName,
viewTarget: 'customer',
viewId: q.customerId
},
{ label: labels.contactName, value: q.contactName },
{ label: '联系手机', value: q.contactMobile },
{ label: '联系邮箱', value: q.contactEmail },
@@ -458,15 +436,22 @@ const viewSections = computed<ViewSection[]>(() => {
},
{ label: labels.quoteDate, value: q.quoteDate },
{ label: '有效期至', value: expireText },
{ label: '运费(元)', value: q.freight != null ? `¥${formatAmount(q.freight)}` : '—', money: true },
{ label: labels.ownerUser, value: q.ownerUserName },
{ label: labels.supplier, value: q.supplierName || '—' },
{ label: '创建时间', value: parseTime(q.createTime) }
]
const productTotal = Number(q.totalAmount) || 0
const freightAmount = Number(q.freight) || 0
const barrelDepositAmount = Number(q.barrelDeposit) || 0
// 最终金额 = 产品总金额 + 运费 + 桶押金
const finalAmount = productTotal + freightAmount + barrelDepositAmount
const amountFields: ViewField[] = [
{ label: '产品总金额(元)', value: `¥${formatAmount(q.totalAmount)}`, money: true },
{ label: '最终金额(元)', value: `¥${formatAmount(q.finalAmount)}`, money: true }
{ label: '最终金额(元)', value: `¥${formatAmount(finalAmount)}`, money: true },
{ label: '产品总金额(元)', value: `¥${formatAmount(productTotal)}`, money: true },
{ label: '运费(元)', value: `¥${formatAmount(freightAmount)}`, money: true },
{ label: '桶押金(元)', value: `¥${formatAmount(barrelDepositAmount)}`, money: true }
]
const sections: ViewSection[] = [
@@ -566,15 +551,27 @@ async function refresh() {
await loadDetail(currentQuoteId.value)
}
async function handleViewCustomer() {
if (!quoteInfo.value?.customerId) return
async function handleFieldView(field: ViewField) {
if (field.viewTarget !== 'customer' || !field.viewId) return
customerDialogActive.value = true
await nextTick()
customerDetailRef.value?.open(quoteInfo.value.customerId as number)
await customerDetailRef.value?.open(field.viewId)
}
function handleEdit() {
async function handleEdit() {
if (!quoteInfo.value?.id) return
if (!isQuoteEditableStatus(quoteInfo.value.status)) {
$modal.msgWarning('仅草稿、已提交、审批通过或审批失败的报价单才能修改')
return
}
const confirmMsg = getQuoteReeditConfirmMessage(quoteInfo.value.status)
if (confirmMsg) {
try {
await $modal.confirm(confirmMsg)
} catch {
return
}
}
visible.value = false
emit('edit', quoteInfo.value.id)
}
@@ -587,23 +584,6 @@ function handleSubmit() {
emit('submit', quoteInfo.value)
}
async function handleDelete() {
if (!quoteInfo.value?.id) return
if (quoteInfo.value.status !== 'draft') {
$modal.msgWarning('只能删除草稿状态的报价单')
return
}
try {
await $modal.confirm('是否确认删除该报价单?删除后将无法恢复。')
await delQuote([quoteInfo.value.id])
$modal.msgSuccess('删除成功')
visible.value = false
emit('success')
} catch {
// 用户取消
}
}
async function handleInvalid() {
if (!quoteInfo.value?.id) return
if (quoteInfo.value.status === 'invalid') {
@@ -625,29 +605,6 @@ defineExpose({ open, refresh })
</script>
<style scoped lang="scss">
.quote-product-summary {
display: grid;
grid-template-columns: repeat(3, minmax(0, 1fr));
gap: 12px;
margin-top: 12px;
padding: 12px 14px;
border: 1px solid var(--border, #d9e8e2);
border-radius: 8px;
background: var(--mint-table-head, #f8fafc);
}
.quote-product-summary-item {
display: flex;
flex-direction: column;
gap: 4px;
font-size: 13px;
color: var(--mint-text);
}
.quote-product-summary-label {
font-size: 12px;
}
.quote-approval-alert {
margin-bottom: 12px;
}
@@ -50,22 +50,73 @@
</el-select>
</el-form-item>
<el-form-item :label="basicLabels.customerName" prop="customerId" required>
<el-input v-model="form.customerName" placeholder="请选择客户" readonly>
<template #append>
<el-button text @click="handleSelectCustomer">
<el-icon><Search /></el-icon>
</el-button>
</template>
</el-input>
<div class="customer-select-row">
<el-select
v-model="form.customerId"
class="customer-select-row__select"
filterable
remote
clearable
:remote-method="searchCustomerOptions"
:loading="customerOptionsLoading"
:placeholder="`请输入${basicLabels.customerName}/拼音首字母搜索`"
@focus="handleCustomerSelectFocus"
@change="handleCustomerSelectChange"
>
<el-option
v-for="item in customerOptions"
:key="item.id"
:label="item.customerName"
:value="item.id"
>
<div class="customer-option-row">
<span>{{ item.customerName }}</span>
<span v-if="item.customerNo" class="customer-option-row__meta">{{ item.customerNo }}</span>
</div>
</el-option>
</el-select>
<el-button text class="customer-select-row__search" @click="handleSelectCustomer">
<el-icon><Search /></el-icon>
</el-button>
</div>
</el-form-item>
<el-form-item :label="basicLabels.contactName" prop="contactId" required>
<el-input v-model="form.contactName" placeholder="请选择联系人" readonly :disabled="!form.customerId">
<template #append>
<el-button text :disabled="!form.customerId" @click="handleSelectContact">
<el-icon><Search /></el-icon>
</el-button>
</template>
</el-input>
<div class="customer-select-row">
<el-select
v-model="form.contactId"
class="customer-select-row__select"
filterable
clearable
:disabled="!form.customerId"
:loading="contactOptionsLoading"
:placeholder="form.customerId ? `请选择${basicLabels.contactName}` : '请先选择客户'"
@visible-change="handleContactSelectVisible"
@change="handleContactSelectChange"
>
<el-option
v-for="item in contactOptions"
:key="item.id"
:label="item.contactName"
:value="item.id"
>
<div class="customer-option-row">
<span>
{{ item.contactName }}
<el-tag v-if="item.isPrimary === 1" type="success" size="small" style="margin-left: 6px">主要</el-tag>
</span>
<span v-if="item.mobile" class="customer-option-row__meta">{{ item.mobile }}</span>
</div>
</el-option>
</el-select>
<el-button
text
class="customer-select-row__search"
:disabled="!form.customerId"
@click="handleSelectContact"
>
<el-icon><Search /></el-icon>
</el-button>
</div>
</el-form-item>
<el-form-item :label="basicLabels.ownerUser" prop="ownerUserId" required>
<el-select
@@ -88,6 +139,9 @@
<el-form-item label="运费(元)" prop="freight">
<el-input-number v-model="form.freight" :min="0" :step="0.01" style="width: 100%" />
</el-form-item>
<el-form-item label="桶押金(元)" prop="barrelDeposit">
<el-input-number v-model="form.barrelDeposit" :min="0" :step="0.01" style="width: 100%" />
</el-form-item>
<el-form-item :label="basicLabels.quoteDate" prop="quoteDate" required>
<el-date-picker
v-model="form.quoteDate"
@@ -171,7 +225,7 @@
class="line-meta-cell__btn"
@click="openAliasBrandManage(scope.row, 'alias')"
>
<el-icon><Setting /></el-icon>
<el-icon><Plus /></el-icon>
</el-button>
</div>
</template>
@@ -204,7 +258,7 @@
class="line-meta-cell__btn"
@click="openAliasBrandManage(scope.row, 'brand')"
>
<el-icon><Setting /></el-icon>
<el-icon><Plus /></el-icon>
</el-button>
</div>
</template>
@@ -459,6 +513,50 @@
<!-- 客户选择器 -->
<CustomerSelector :visible="customerSelectorVisible" @update:visible="customerSelectorVisible = $event" @confirm="handleCustomerConfirm" />
<!-- 下拉选客户时补填简称 -->
<el-dialog
v-model="shortNameDialogVisible"
title="填写客户简称"
width="480px"
align-center
class="dialog-form-layout"
modal-class="order-module-dialog-mask"
:close-on-click-modal="false"
append-to-body
@closed="handleShortNameDialogClosed"
>
<el-form
ref="shortNameFormRef"
:model="shortNameForm"
:rules="shortNameRules"
label-position="top"
class="crm-dialog-form"
>
<el-form-item label="客户名称">
<el-input :model-value="shortNameForm.customerName" disabled />
</el-form-item>
<el-form-item label="客户简称" prop="shortName">
<el-input
v-model="shortNameForm.shortName"
placeholder="请输入客户简称"
maxlength="100"
show-word-limit
clearable
/>
</el-form-item>
</el-form>
<template #footer>
<div class="dialog-footer">
<el-button class="btn-ghost" @click="shortNameDialogVisible = false">
<el-icon><Close /></el-icon>取消
</el-button>
<el-button class="btn-main" type="primary" :loading="shortNameSaving" @click="handleSaveShortName">
<el-icon><Check /></el-icon>确定
</el-button>
</div>
</template>
</el-dialog>
<!-- 联系人选择器 -->
<ContactSelector
:visible="contactSelectorVisible"
@@ -467,6 +565,9 @@
@confirm="handleContactConfirm"
/>
<!-- 下拉无联系人时补充 -->
<ContactFormDialog ref="contactFormRef" @success="handleContactFormSuccess" />
<!-- 商机选择器 -->
<OpportunitySelector
:visible="opportunitySelectorVisible"
@@ -528,10 +629,10 @@
<script setup lang="ts" name="CrmQuoteFormPanel">
import { useDictStore } from '@/store/modules/dict'
import { $modal } from '@/utils/modal'
import { ref, computed, onMounted, type ComponentInternalInstance } from 'vue';
import { ref, computed, nextTick, onMounted, type ComponentInternalInstance } from 'vue';
import { getQuote, addQuote, updateQuote, submitQuote, getQuoteApproverSetting } from '@/api/crm/quote';
import type { QuoteForm, QuoteProductForm } from '@/api/crm/quote';
import type { FormInstance } from 'element-plus';
import type { FormInstance, FormItemRule } from 'element-plus';
import { useRouter, useRoute } from 'vue-router';
import { useUserStore } from '@/store/modules/user';
import request from '@/utils/http';
@@ -548,7 +649,6 @@ import {
Loading,
Plus,
Search,
Setting,
UploadFilled
} from '@element-plus/icons-vue'
import ImagePreview from '@/components/ImagePreview/index.vue';
@@ -556,9 +656,11 @@ import ProductSelector from '@/components/business/product-selector/index.vue';
import ProductAliasBrandDialog from '@/components/business/product-alias-brand-dialog/index.vue'
import CustomerSelector from '@/components/CustomerSelector.vue';
import ContactSelector from '@/components/ContactSelector.vue';
import ContactFormDialog from '@/views/crm/customer/components/ContactFormDialog.vue'
import OpportunitySelector from '@/components/OpportunitySelector.vue';
import { fetchUserOptions } from '@/api/admin';
import { fetchContactsByCustomerId } from '@/api/crm/contact';
import { fetchCustomerList, fetchUpdateCustomer } from '@/api/crm/customer'
import { listAllSupplierInfo, type SupplierInfoVO } from '@/api/crm/supplierInfo';
import { filterOwnerCandidates, findDefaultOwnerUser } from '@/utils/crm-owner-candidates';
import { removeProductsNotAllowedByHazard } from '@/utils/crm-supplier-hazard'
@@ -592,14 +694,16 @@ const userStore = useUserStore()
// 临时类型声明
interface CustomerVO {
id: number;
id: string | number;
customerName: string;
customerNo?: string;
shortName?: string;
}
interface ContactVO {
id: number;
id: string | number;
contactName: string;
mobile?: string;
isPrimary?: number;
}
@@ -638,6 +742,7 @@ const createDefaultForm = (): QuoteForm => ({
supplierId: undefined,
supplierName: '',
freight: 0,
barrelDeposit: 0,
remark: defaultRemark,
products: []
})
@@ -691,6 +796,23 @@ const rules = ref({
trigger: 'change'
}
],
barrelDeposit: [
{
validator: (_rule: any, value: any, callback: any) => {
if (value === null || value === undefined || value === '') {
callback();
} else {
const numValue = Number(value);
if (isNaN(numValue) || numValue < 0) {
callback(new Error('桶押金需大于等于0'));
} else {
callback();
}
}
},
trigger: 'change'
}
],
ownerUserId: [{ required: true, message: '请选择负责人', trigger: 'change' }],
supplierId: [{ required: true, message: '请选择报价主体', trigger: 'change' }],
quoteType: [{ required: true, message: '请选择报价类型', trigger: 'change' }]
@@ -707,9 +829,286 @@ const selectedProducts = ref<QuoteProductForm[]>([]);
// 客户选择器
const customerSelectorVisible = ref(false);
const customerOptions = ref<CustomerVO[]>([]);
const customerOptionsLoading = ref(false);
/** 已确认选定的客户(用于简称弹窗取消时回滚下拉值) */
const confirmedCustomerId = ref<string | number | undefined>(undefined);
const shortNameDialogVisible = ref(false);
const shortNameSaving = ref(false);
const shortNameFormRef = ref<FormInstance>();
const shortNameForm = ref({
id: '' as string | number,
customerName: '',
shortName: ''
});
const shortNameRules: Record<string, FormItemRule[]> = {
shortName: [{ required: true, message: '客户简称不能为空', trigger: 'blur' }]
};
const pendingCustomerForShortName = ref<CustomerVO | null>(null);
const shortNameSavedSuccessfully = ref(false);
const hasCustomerShortName = (row?: { shortName?: string } | null) =>
Boolean(String(row?.shortName || '').trim());
const ensureCustomerOption = (customer?: Partial<CustomerVO> | null) => {
if (!customer?.id) return;
const exists = customerOptions.value.some((item) => String(item.id) === String(customer.id));
if (exists) {
customerOptions.value = customerOptions.value.map((item) =>
String(item.id) === String(customer.id)
? {
...item,
customerName: customer.customerName || item.customerName,
customerNo: customer.customerNo ?? item.customerNo,
shortName: customer.shortName ?? item.shortName
}
: item
);
return;
}
customerOptions.value = [
{
id: customer.id,
customerName: customer.customerName || '',
customerNo: customer.customerNo,
shortName: customer.shortName
},
...customerOptions.value
];
};
const extractCustomerList = (res: unknown): CustomerVO[] => {
const data = (res as { data?: unknown })?.data ?? res ?? {};
const list = (data as { list?: CustomerVO[]; rows?: CustomerVO[] }).list
|| (data as { rows?: CustomerVO[] }).rows
|| [];
return Array.isArray(list) ? list : [];
};
const loadDefaultCustomerOptions = async () => {
customerOptionsLoading.value = true;
try {
const res = await fetchCustomerList({ page: 1, pageSize: 20 });
customerOptions.value = extractCustomerList(res);
if (form.value.customerId) {
ensureCustomerOption({
id: form.value.customerId,
customerName: form.value.customerName,
shortName: customerShortName.value
});
}
} catch (error) {
console.error('加载客户列表失败:', error);
customerOptions.value = [];
} finally {
customerOptionsLoading.value = false;
}
};
const searchCustomerOptions = async (query: string) => {
const keyword = query?.trim();
if (!keyword) {
await loadDefaultCustomerOptions();
return;
}
customerOptionsLoading.value = true;
try {
const res = await fetchCustomerList({
customerName: keyword,
page: 1,
pageSize: 50
});
customerOptions.value = extractCustomerList(res);
if (form.value.customerId) {
ensureCustomerOption({
id: form.value.customerId,
customerName: form.value.customerName,
shortName: customerShortName.value
});
}
} catch (error) {
console.error('搜索客户失败:', error);
customerOptions.value = [];
} finally {
customerOptionsLoading.value = false;
}
};
const handleCustomerSelectFocus = () => {
if (customerOptions.value.length === 0) {
loadDefaultCustomerOptions();
}
};
const clearCustomerSelection = () => {
form.value.customerId = undefined;
form.value.customerName = '';
customerShortName.value = '';
confirmedCustomerId.value = undefined;
form.value.contactId = undefined;
form.value.contactName = '';
contactOptions.value = [];
form.value.opportunityId = undefined;
opportunityDisplayName.value = '';
updateQuoteTitleAndNo();
};
const openShortNameDialog = (customer: CustomerVO) => {
pendingCustomerForShortName.value = customer;
shortNameSavedSuccessfully.value = false;
shortNameForm.value = {
id: customer.id,
customerName: customer.customerName || '',
shortName: customer.shortName || ''
};
shortNameDialogVisible.value = true;
nextTick(() => shortNameFormRef.value?.clearValidate());
};
const handleCustomerSelectChange = async (customerId?: string | number) => {
if (!customerId) {
clearCustomerSelection();
return;
}
// 回滚到已确认客户时会再次触发 change,直接忽略
if (
confirmedCustomerId.value !== undefined
&& confirmedCustomerId.value !== null
&& String(customerId) === String(confirmedCustomerId.value)
) {
return;
}
const customer = customerOptions.value.find((item) => String(item.id) === String(customerId));
if (!customer) return;
if (!hasCustomerShortName(customer)) {
ElMessage.warning('该客户尚未配置简称,请先填写客户简称后再继续');
// 先回滚到已确认客户,待简称保存成功后再选定
form.value.customerId = confirmedCustomerId.value;
openShortNameDialog(customer);
return;
}
await handleCustomerConfirm(customer);
};
// 联系人选择器
const contactSelectorVisible = ref(false);
const contactOptions = ref<ContactVO[]>([]);
const contactOptionsLoading = ref(false);
const contactFormRef = ref<InstanceType<typeof ContactFormDialog>>();
/** 避免 visible-change 重复弹出补充联系人弹窗 */
const contactEmptyPrompted = ref(false);
const extractContactList = (res: unknown): ContactVO[] => {
const unwrapped = (res as { data?: unknown })?.data ?? res ?? [];
if (Array.isArray(unwrapped)) return unwrapped as ContactVO[];
const payload = (unwrapped as { list?: ContactVO[]; rows?: ContactVO[] }) || {};
return payload.list || payload.rows || [];
};
const ensureContactOption = (contact?: Partial<ContactVO> | null) => {
if (!contact?.id) return;
const exists = contactOptions.value.some((item) => String(item.id) === String(contact.id));
if (exists) {
contactOptions.value = contactOptions.value.map((item) =>
String(item.id) === String(contact.id)
? {
...item,
contactName: contact.contactName || item.contactName,
mobile: contact.mobile ?? item.mobile,
isPrimary: contact.isPrimary ?? item.isPrimary
}
: item
);
return;
}
contactOptions.value = [
{
id: contact.id,
contactName: contact.contactName || '',
mobile: contact.mobile,
isPrimary: contact.isPrimary
},
...contactOptions.value
];
};
const loadContactOptions = async (customerId?: string | number) => {
if (!customerId) {
contactOptions.value = [];
return [];
}
contactOptionsLoading.value = true;
try {
const res = await fetchContactsByCustomerId({ customerId });
contactOptions.value = extractContactList(res);
if (form.value.contactId) {
ensureContactOption({
id: form.value.contactId,
contactName: form.value.contactName
});
}
return contactOptions.value;
} catch (error) {
console.error('加载联系人列表失败:', error);
contactOptions.value = [];
return [];
} finally {
contactOptionsLoading.value = false;
}
};
const openContactFormDialog = () => {
if (!form.value.customerId) {
$modal.msgWarning('请先选择客户');
return;
}
contactFormRef.value?.open(undefined, form.value.customerId);
};
const handleContactSelectVisible = async (visible: boolean) => {
if (!visible) {
contactEmptyPrompted.value = false;
return;
}
if (!form.value.customerId) return;
const list = await loadContactOptions(form.value.customerId);
if (list.length === 0 && !contactEmptyPrompted.value) {
contactEmptyPrompted.value = true;
ElMessage.warning(`该客户暂无${basicLabels.value.contactName},请先补充联系人信息`);
nextTick(() => openContactFormDialog());
}
};
const handleContactSelectChange = (contactId?: string | number) => {
if (!contactId) {
form.value.contactId = undefined;
form.value.contactName = '';
return;
}
const contact = contactOptions.value.find((item) => String(item.id) === String(contactId));
if (contact) {
form.value.contactName = contact.contactName;
}
};
const handleContactFormSuccess = async (payload?: { id?: string | number }) => {
contactEmptyPrompted.value = false;
const list = await loadContactOptions(form.value.customerId);
const createdId = payload?.id;
if (createdId) {
const created = list.find((item) => String(item.id) === String(createdId));
if (created) {
handleContactConfirm(created);
return;
}
}
if (list.length === 1) {
handleContactConfirm(list[0]);
}
};
// 商机选择器
const opportunitySelectorVisible = ref(false);
@@ -851,6 +1250,7 @@ const getQuoteInfo = async (id: string | number) => {
}
// 确保运费是数字类型(后端可能返回字符串或null)
form.value.freight = Number(form.value.freight) || 0;
form.value.barrelDeposit = Number(form.value.barrelDeposit) || 0;
// 加载客户简称(从报价主题中提取,或从客户信息中获取)
// 报价主题格式:供方简称-客户简称(报价单号)
@@ -865,6 +1265,20 @@ const getQuoteInfo = async (id: string | number) => {
customerShortName.value = quoteData.customerName;
}
confirmedCustomerId.value = form.value.customerId;
ensureCustomerOption({
id: form.value.customerId,
customerName: form.value.customerName,
shortName: customerShortName.value
});
if (form.value.customerId) {
await loadContactOptions(form.value.customerId);
ensureContactOption({
id: form.value.contactId,
contactName: form.value.contactName
});
}
// 回显商机名称(如果有关联商机)
if (quoteData.opportunityId) {
// 直接使用后端返回的商机名称
@@ -943,6 +1357,7 @@ const getQuoteInfoForCopy = async (copyId: string | number) => {
form.value.supplierId = quoteData.supplierId;
form.value.supplierName = quoteData.supplierName;
form.value.freight = Number(quoteData.freight) || 0;
form.value.barrelDeposit = Number(quoteData.barrelDeposit) || 0;
form.value.remark = quoteData.remark || '';
form.value.validityDays = quoteData.validityDays || 30;
@@ -957,6 +1372,20 @@ const getQuoteInfoForCopy = async (copyId: string | number) => {
customerShortName.value = quoteData.customerName;
}
confirmedCustomerId.value = form.value.customerId;
ensureCustomerOption({
id: form.value.customerId,
customerName: form.value.customerName,
shortName: customerShortName.value
});
if (form.value.customerId) {
await loadContactOptions(form.value.customerId);
ensureContactOption({
id: form.value.contactId,
contactName: form.value.contactName
});
}
// 复制产品明细 - 将产品数量设置为0,其他信息完全复制
if (quoteData.productList && Array.isArray(quoteData.productList)) {
form.value.products = quoteData.productList.map((item: any) => ({
@@ -1007,32 +1436,33 @@ const handleSelectCustomer = () => {
/** 客户选择确认 */
const handleCustomerConfirm = async (customer: CustomerVO) => {
if (customer) {
ensureCustomerOption(customer);
form.value.customerId = customer.id;
form.value.customerName = customer.customerName;
confirmedCustomerId.value = customer.id;
// 保存客户简称(报价主题依赖简称,不可回退为客户全称)
customerShortName.value = customer.shortName?.trim() || '';
// 清空联系人和商机
form.value.contactId = undefined;
form.value.contactName = '';
contactOptions.value = [];
contactEmptyPrompted.value = false;
form.value.opportunityId = undefined;
opportunityDisplayName.value = '';
// 自动加载该客户的联系人并设置默认联系人
try {
const res = await fetchContactsByCustomerId({ customerId: customer.id });
const contacts = (res as any)?.list ?? (res as any)?.data ?? res ?? [];
if (contacts.length > 0) {
// 优先选择主要联系人,如果没有主要联系人,选择第一个
const primaryContact = contacts.find((c: ContactVO) => c.isPrimary === 1);
const defaultContact = primaryContact || contacts[0];
if (defaultContact) {
form.value.contactId = defaultContact.id;
form.value.contactName = defaultContact.contactName;
}
// 自动加载该客户的联系人并设置默认联系人;无联系人时立即引导补充
const contacts = await loadContactOptions(customer.id);
if (contacts.length > 0) {
const primaryContact = contacts.find((c) => c.isPrimary === 1);
const defaultContact = primaryContact || contacts[0];
if (defaultContact) {
form.value.contactId = defaultContact.id;
form.value.contactName = defaultContact.contactName;
}
} catch (error) {
console.error('加载联系人列表失败:', error);
// 加载失败不影响客户选择,只是不自动填充联系人
} else {
contactEmptyPrompted.value = true;
ElMessage.warning(`该客户暂无${basicLabels.value.contactName},请先补充联系人信息`);
nextTick(() => openContactFormDialog());
}
// 更新报价主题和报价单号
@@ -1040,6 +1470,46 @@ const handleCustomerConfirm = async (customer: CustomerVO) => {
}
};
const handleSaveShortName = async () => {
const valid = await shortNameFormRef.value?.validate().catch(() => false);
if (!valid) return;
shortNameSaving.value = true;
try {
const trimmedShortName = shortNameForm.value.shortName.trim();
await fetchUpdateCustomer({
id: shortNameForm.value.id,
shortName: trimmedShortName
});
ElMessage.success('客户简称保存成功');
const pending = pendingCustomerForShortName.value;
const customer: CustomerVO = {
id: shortNameForm.value.id,
customerName: shortNameForm.value.customerName || pending?.customerName || '',
customerNo: pending?.customerNo,
shortName: trimmedShortName
};
ensureCustomerOption(customer);
shortNameSavedSuccessfully.value = true;
shortNameDialogVisible.value = false;
await handleCustomerConfirm(customer);
} catch (error) {
console.error('保存客户简称失败:', error);
ElMessage.error('保存客户简称失败');
} finally {
shortNameSaving.value = false;
}
};
const handleShortNameDialogClosed = () => {
pendingCustomerForShortName.value = null;
if (!shortNameSavedSuccessfully.value) {
form.value.customerId = confirmedCustomerId.value;
}
shortNameSavedSuccessfully.value = false;
};
/** 打开联系人选择器 */
const handleSelectContact = () => {
if (!form.value.customerId) {
@@ -1052,6 +1522,7 @@ const handleSelectContact = () => {
/** 联系人选择确认 */
const handleContactConfirm = (contact: ContactVO) => {
if (contact) {
ensureContactOption(contact);
form.value.contactId = contact.id;
form.value.contactName = contact.contactName;
}
@@ -1071,6 +1542,11 @@ const handleOpportunityConfirm = (opportunity: OpportunityVO) => {
if (opportunity.customerId && !form.value.customerId) {
form.value.customerId = opportunity.customerId;
form.value.customerName = opportunity.customerName;
confirmedCustomerId.value = opportunity.customerId;
ensureCustomerOption({
id: opportunity.customerId,
customerName: opportunity.customerName || ''
});
}
}
};
@@ -1818,6 +2294,12 @@ const handleConfirmApproval = async () => {
const resetPanelState = () => {
form.value = createDefaultForm();
customerShortName.value = '';
confirmedCustomerId.value = undefined;
customerOptions.value = [];
contactOptions.value = [];
contactEmptyPrompted.value = false;
pendingCustomerForShortName.value = null;
shortNameDialogVisible.value = false;
opportunityDisplayName.value = '';
attachmentList.value = [];
selectedProducts.value = [];
@@ -2281,6 +2763,37 @@ onMounted(async () => {
width: 100%;
}
.customer-select-row {
display: flex;
align-items: center;
gap: 4px;
width: 100%;
}
.customer-select-row__select {
flex: 1;
min-width: 0;
}
.customer-select-row__search {
flex-shrink: 0;
padding: 0 8px;
}
.customer-option-row {
display: flex;
justify-content: space-between;
align-items: center;
gap: 12px;
min-width: 0;
}
.customer-option-row__meta {
flex-shrink: 0;
font-size: 12px;
color: var(--mint-text-muted, #8492a6);
}
/* 去除输入框后置按钮的边框和背景 */
:deep(.el-input-group__append) {
background: transparent !important;
@@ -207,6 +207,8 @@ const handleSubmit = async () => {
customerId: props.quoteInfo!.customerId,
contractType: 'sale',
amount: props.quoteInfo!.finalAmount || props.quoteInfo!.totalAmount,
freight: Number(props.quoteInfo!.freight) || 0,
barrelDeposit: Number(props.quoteInfo!.barrelDeposit) || 0,
signDate: form.signDate,
startDate: form.startDate,
endDate: form.endDate,
+25 -5
View File
@@ -2,7 +2,6 @@
<div class="page-container">
<section class="panel" v-loading="loading">
<div class="panel-top panel-top-with-actions">
<h2 class="title-bar-heading">报价单详情</h2>
<div class="detail-toolbar">
<el-button link type="primary" @click="goBack">
<el-icon><Back /></el-icon>返回列表
@@ -10,7 +9,12 @@
<el-button link type="primary" @click="handleGenerateQuote">
<el-icon><Document /></el-icon>生成报价单
</el-button>
<el-button v-if="quote?.status === 'draft'" link type="primary" @click="handleEdit">
<el-button
v-if="isQuoteEditableStatus(quote?.status)"
link
type="primary"
@click="handleEdit"
>
<el-icon><Edit /></el-icon>修改
</el-button>
<el-button v-if="quote?.status === 'draft'" link type="primary" @click="handleSubmit">
@@ -64,6 +68,9 @@
<el-descriptions-item label="运费(元)">
<span>¥{{ formatAmount(quote?.freight) }}</span>
</el-descriptions-item>
<el-descriptions-item label="桶押金(元)">
<span>¥{{ formatAmount(quote?.barrelDeposit) }}</span>
</el-descriptions-item>
<el-descriptions-item :label="detailLabels.ownerUser">{{ quote?.ownerUserName }}</el-descriptions-item>
<el-descriptions-item :label="detailLabels.supplier">{{ quote?.supplierName || '-' }}</el-descriptions-item>
<el-descriptions-item label="创建时间">{{ parseTime(quote?.createTime) }}</el-descriptions-item>
@@ -391,6 +398,7 @@ import ListPagination from '@/components/ListPagination/index.vue'
import { $modal } from '@/utils/modal'
import { formatBrandForPrint } from '@/utils/crm-product-brand'
import { canDeleteByCreator } from '@/utils/creator-delete'
import { isQuoteEditableStatus, getQuoteReeditConfirmMessage } from './quoteStatus'
import { ref, onMounted } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import { Back, CircleCheck, Close, Delete, Document, Download, Edit, Printer } from '@element-plus/icons-vue'
@@ -518,12 +526,24 @@ const goBack = () => {
};
/** 编辑 */
const handleEdit = () => {
const handleEdit = async () => {
if (!isQuoteEditableStatus(quote.value?.status)) {
$modal.msgWarning('仅草稿、已提交、审批通过或审批失败的报价单才能修改')
return
}
const confirmMsg = getQuoteReeditConfirmMessage(quote.value?.status)
if (confirmMsg) {
try {
await $modal.confirm(confirmMsg)
} catch {
return
}
}
router.push({
path: '/crm/quote/form',
query: { id: quote.value?.id }
});
};
})
}
/** 删除报价单 */
const handleDelete = async () => {
+2 -10
View File
@@ -2,7 +2,6 @@
<div class="page-container">
<section class="panel">
<div class="panel-top panel-top-with-actions">
<h2 class="title-bar-heading">{{ pageTitle }}</h2>
<el-button class="btn-ghost" @click="handleBack">
<el-icon><Back /></el-icon>返回列表
</el-button>
@@ -13,21 +12,14 @@
</template>
<script setup lang="ts" name="CrmQuoteForm">
import { computed, ref } from 'vue'
import { useRouter, useRoute } from 'vue-router'
import { ref } from 'vue'
import { useRouter } from 'vue-router'
import { Back } from '@element-plus/icons-vue'
import QuoteFormPanel from './components/QuoteFormPanel.vue'
const router = useRouter()
const route = useRoute()
const panelRef = ref<InstanceType<typeof QuoteFormPanel> | null>(null)
const pageTitle = computed(() => {
if (route.query.id) return '编辑报价单'
if (route.query.copyId) return '复制新增报价单'
return '新建报价单'
})
const handleBack = () => {
router.back()
}
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,20 @@
/** 允许打开编辑的报价单状态(保存后回草稿) */
export const QUOTE_EDITABLE_STATUSES = ['draft', 'submitted', 'accepted', 'rejected'] as const
export type QuoteEditableStatus = (typeof QUOTE_EDITABLE_STATUSES)[number]
export function isQuoteEditableStatus(status?: string | null): boolean {
return QUOTE_EDITABLE_STATUSES.includes((status || '').trim() as QuoteEditableStatus)
}
/** 已提交 / 审批通过 / 审批失败打开编辑前的确认文案;草稿返回 null(无需确认) */
export function getQuoteReeditConfirmMessage(status?: string | null): string | null {
const s = (status || '').trim()
if (s === 'submitted') {
return '编辑保存后将作废当前审批流,报价单变回草稿,需重新提交审批'
}
if (s === 'accepted' || s === 'rejected') {
return '编辑保存后报价单将变回草稿,需重新提交审批'
}
return null
}
@@ -2,7 +2,6 @@
<div class="page-container">
<section class="panel" v-loading="loading">
<div class="panel-top panel-top-with-actions">
<h2 class="title-bar-heading">报价单统计分析</h2>
<el-button class="btn-ghost" @click="goBack">
<el-icon><Back /></el-icon>返回列表
</el-button>
@@ -2,10 +2,6 @@
<template>
<div class="page-container">
<section class="panel">
<div class="panel-top">
<h2 class="title-bar-heading">主体危化品能力</h2>
</div>
<div class="filter-block">
<el-form :model="searchForm" class="filter-form" @submit.prevent>
<div class="filter-grid">
@@ -2,9 +2,6 @@
<template>
<div class="console-container console-lite">
<section class="panel">
<div class="panel-top">
<h2 class="title-bar-heading">Demo 模板页</h2>
</div>
<div class="console-lite__body">
<p class="console-lite__hint">
以下页面为 Fresh Mint UI 参考模板,数据为本地 Mock,不影响业务模块。详见
@@ -1,10 +1,6 @@
<template>
<div class="page-container db-page">
<section class="panel">
<div class="panel-top">
<h2 class="title-bar-heading">仪表盘</h2>
</div>
<div class="db-dashboard-body" v-loading="loading">
<div class="db-dashboard-stats">
<div v-for="stat in statsList" :key="stat.title" class="db-stat-card">
+1 -5
View File
@@ -1,12 +1,8 @@
<template>
<div class="page-container">
<section class="panel">
<div class="panel-top">
<h2 class="title-bar-heading">地磅出入库</h2>
</div>
<div class="filter-block">
<el-form :model="filters" class="filter-form" @submit.prevent>
<el-form :model="filters" class="filter-form" @submit.prevent style="--filter-label-width: 80px">
<div class="filter-grid">
<el-form-item label="日期范围">
<el-date-picker
-4
View File
@@ -1,10 +1,6 @@
<template>
<div class="page-container">
<section class="panel">
<div class="panel-top">
<h2 class="title-bar-heading">地磅计划</h2>
</div>
<div class="filter-block">
<el-form :model="filters" class="filter-form" @submit.prevent>
<div class="filter-grid">
+1 -5
View File
@@ -1,12 +1,8 @@
<template>
<div class="page-container">
<section class="panel">
<div class="panel-top">
<h2 class="title-bar-heading">地磅单管理</h2>
</div>
<div class="filter-block">
<el-form :model="filters" class="filter-form" @submit.prevent>
<el-form :model="filters" class="filter-form" @submit.prevent style="--filter-label-width: 80px">
<div class="filter-grid">
<el-form-item label="日期范围">
<el-date-picker
@@ -3,10 +3,6 @@
<template>
<div class="page-container">
<section class="panel">
<div class="panel-top">
<h2 class="title-bar-heading">分类列表</h2>
</div>
<div class="filter-block">
<el-form :model="searchForm" class="filter-form" @submit.prevent>
<div class="filter-grid">
-4
View File
@@ -22,10 +22,6 @@
</div>
<section class="panel">
<div class="panel-top">
<h2 class="title-bar-heading">订单列表</h2>
</div>
<div class="filter-block">
<el-form :model="searchForm" class="filter-form" label-position="top">
<p class="filter-hint">支持按订单状态、配送状态、支付状态等维度快速筛选。</p>
@@ -3,9 +3,6 @@
<template>
<div class="page-container">
<div class="panel">
<div class="panel-top">
<h2 class="title-bar-heading">商品列表</h2>
</div>
<div class="filter-block">
<el-form :model="searchForm" class="filter-form" @submit.prevent>
<div class="filter-grid">
-4
View File
@@ -3,10 +3,6 @@
<template>
<div class="page-container">
<section class="panel">
<div class="panel-top">
<h2 class="title-bar-heading">单位列表</h2>
</div>
<div class="filter-block">
<el-form :model="searchForm" class="filter-form" @submit.prevent>
<div class="filter-grid">
+3 -1
View File
@@ -3,7 +3,9 @@
<div v-if="isPortalLayout" class="app-layout app-layout-portal" :style="appLayoutStyle">
<div id="app-portal-header">
<ArtPortalHeader />
<ArtWorkTab />
<div id="app-worktab">
<ArtWorkTab />
</div>
</div>
<div id="app-portal-body">
+5 -2
View File
@@ -36,8 +36,11 @@
#app-worktab {
flex-shrink: 0;
width: 100%;
padding-top: 8px;
background: var(--mint-surface, #fff);
background: #f1f5f9;
:deep(.worktab-strip) {
margin-bottom: 0 !important;
}
}
#app-content {
@@ -2,10 +2,6 @@
<template>
<div class="page-container">
<section class="panel">
<div class="panel-top">
<h2 class="title-bar-heading">{{ title }}</h2>
</div>
<div class="filter-block">
<el-form :model="searchForm" class="filter-form" @submit.prevent>
<div class="filter-grid">
+1 -5
View File
@@ -2,13 +2,9 @@
<template>
<div class="page-container">
<section class="panel">
<div class="panel-top">
<h2 class="title-bar-heading">承运商列表</h2>
</div>
<!-- 筛选区 -->
<div class="filter-block">
<el-form :model="searchForm" class="filter-form" @submit.prevent>
<el-form :model="searchForm" class="filter-form" @submit.prevent style="--filter-label-width: 80px">
<div class="filter-grid">
<el-form-item label="承运商名称">
<el-input
+1 -5
View File
@@ -2,13 +2,9 @@
<template>
<div class="page-container">
<section class="panel">
<div class="panel-top">
<h2 class="title-bar-heading">司机列表</h2>
</div>
<!-- 筛选区 -->
<div class="filter-block">
<el-form :model="searchForm" class="filter-form" @submit.prevent>
<el-form :model="searchForm" class="filter-form" @submit.prevent style="--filter-label-width: 110px">
<div class="filter-grid">
<el-form-item label="司机姓名/手机">
<el-input
@@ -2,10 +2,6 @@
<template>
<div class="page-container">
<section class="panel">
<div class="panel-top">
<h2 class="title-bar-heading">运费结算审批</h2>
</div>
<el-tabs
v-model="activeTab"
class="panel-tabs"
@@ -2,10 +2,6 @@
<template>
<div class="page-container">
<section class="panel">
<div class="panel-top">
<h2 class="title-bar-heading">运费财务发放</h2>
</div>
<el-tabs
v-model="activeTab"
class="panel-tabs"
-4
View File
@@ -2,10 +2,6 @@
<template>
<div class="page-container">
<section class="panel">
<div class="panel-top">
<h2 class="title-bar-heading">运费结算</h2>
</div>
<el-tabs
v-model="activeTab"
class="panel-tabs"
@@ -2,10 +2,6 @@
<template>
<div class="page-container">
<section class="panel">
<div class="panel-top">
<h2 class="title-bar-heading">证件到期提醒</h2>
</div>
<div class="filter-block">
<el-form :model="searchForm" class="filter-form" @submit.prevent>
<div class="filter-grid">
@@ -2,10 +2,6 @@
<template>
<div class="page-container">
<section class="panel">
<div class="panel-top">
<h2 class="title-bar-heading">库存台账</h2>
</div>
<div class="filter-block">
<el-form :model="searchForm" class="filter-form" @submit.prevent>
<div class="filter-grid">
+58 -15
View File
@@ -2,13 +2,9 @@
<template>
<div class="page-container">
<section class="panel">
<div class="panel-top">
<h2 class="title-bar-heading">{{ isCarrierPersonnel ? '三方驾押人员' : '山峡驾押人员' }}</h2>
</div>
<!-- 筛选区 -->
<div class="filter-block">
<el-form :model="searchForm" class="filter-form" @submit.prevent>
<el-form :model="searchForm" class="filter-form" @submit.prevent style="--filter-label-width: 80px">
<div class="filter-grid">
<el-form-item label="姓名/手机">
<el-input
@@ -113,14 +109,24 @@
header-align="center"
>
<template #default="{ row }">
<img
v-if="firstPhotoUrl(row.photoUrls)"
class="pl-photo-thumb"
:src="mediaActive ? resolvePhotoDisplayUrl(firstPhotoUrl(row.photoUrls)) : ''"
alt="人员照片"
loading="lazy"
decoding="async"
/>
<div v-if="firstPhotoUrl(row.photoUrls)" class="pl-photo-thumb-wrap">
<img
class="pl-photo-thumb"
:src="mediaActive ? resolvePhotoDisplayUrl(firstPhotoUrl(row.photoUrls)) : ''"
alt="人员照片"
title="点击在新标签页查看"
loading="lazy"
decoding="async"
@click.stop="handlePhotoPreview(row.photoUrls)"
/>
<el-icon
class="pl-photo-download"
title="下载"
@click.stop="handlePhotoDownload(row.photoUrls)"
>
<Download />
</el-icon>
</div>
<span v-else class="pl-photo-thumb pl-photo-thumb--empty">未上传</span>
</template>
</el-table-column>
@@ -404,7 +410,7 @@
</template>
<script setup lang="ts">
import { Check, Close, Delete, DocumentCopy, Edit, Plus, RefreshLeft, Search, User } from '@element-plus/icons-vue'
import { Check, Close, Delete, DocumentCopy, Download, Edit, Plus, RefreshLeft, Search, User } from '@element-plus/icons-vue'
import { personnelApi, type Personnel, type PersonnelDetail, type CertRow } from '@/api/pl'
import PlCertFormList from '@/components/business/pl-cert-form-list/index.vue'
import PlPasteRecognizeDialog from '@/components/business/pl-paste-recognize-dialog/index.vue'
@@ -423,7 +429,15 @@ 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 { firstPhotoUrl, resolvePhotoDisplayUrl } from '@/utils/pl-photo'
import {
downloadListPhoto,
firstPhotoUrl,
previewListPhoto,
resolvePhotoDisplayUrl
} from '@/utils/pl-photo'
const handlePhotoPreview = (raw?: string | null) => previewListPhoto(raw)
const handlePhotoDownload = (raw?: string | null) => downloadListPhoto(raw)
import { canDeleteByCreator, filterDeletableByCreator, allRowsDeletableByCreator, CREATOR_DELETE_TIP } from '@/utils/creator-delete'
import {
collectRequiredCertSlotErrors,
@@ -936,6 +950,14 @@ onMounted(() => {
gap: 6px;
}
.pl-photo-thumb-wrap {
position: relative;
display: inline-block;
vertical-align: middle;
width: 48px;
height: 48px;
}
.pl-photo-thumb {
width: 48px;
height: 48px;
@@ -945,6 +967,27 @@ onMounted(() => {
display: inline-block;
vertical-align: middle;
background: #f8fafc;
cursor: pointer;
}
.pl-photo-download {
position: absolute;
right: -4px;
bottom: -4px;
z-index: 2;
width: 18px;
height: 18px;
border-radius: 50%;
background: #fff;
border: 1px solid #e2e8f0;
color: #1e293b;
cursor: pointer;
&:hover {
color: #1ca851;
border-color: #1ca851;
background: #e6f8ed;
}
}
.pl-photo-thumb--empty {
@@ -2,10 +2,6 @@
<template>
<div class="page-container">
<section class="panel">
<div class="panel-top">
<h2 class="title-bar-heading">运输计划归档</h2>
</div>
<PlPlanTypeTabs v-model="activePlanTypeTab" @change="handlePlanTypeTabChange" />
<div class="filter-block">
@@ -2,10 +2,6 @@
<template>
<div class="page-container">
<section class="panel">
<div class="panel-top">
<h2 class="title-bar-heading">危化品证上传</h2>
</div>
<PlPlanTypeTabs
v-model="activePlanTypeTab"
:tabs="PL_PLAN_CERT_TABS"
-4
View File
@@ -2,10 +2,6 @@
<template>
<div class="page-container">
<section class="panel">
<div class="panel-top">
<h2 class="title-bar-heading">运输计划详情</h2>
</div>
<!-- 基本信息 -->
<div class="detail-section">
<h3 class="section-title">基本信息</h3>
-4
View File
@@ -2,10 +2,6 @@
<template>
<div class="page-container">
<section class="panel">
<div class="panel-top">
<h2 class="title-bar-heading">{{ isEdit ? '编辑运输计划' : '新增运输计划' }}</h2>
</div>
<!-- 基本信息 -->
<div class="form-section">
<h3 class="section-title">基本信息</h3>
-4
View File
@@ -2,10 +2,6 @@
<template>
<div class="page-container">
<section class="panel">
<div class="panel-top">
<h2 class="title-bar-heading">运输计划列表</h2>
</div>
<PlPlanTypeTabs v-model="activePlanTypeTab" @change="handlePlanTypeTabChange" />
<!-- 筛选区 -->
+57 -14
View File
@@ -2,10 +2,6 @@
<template>
<div class="page-container">
<section class="panel">
<div class="panel-top">
<h2 class="title-bar-heading">山峡自有车辆</h2>
</div>
<div class="filter-block">
<el-form :model="searchForm" class="filter-form" @submit.prevent>
<div class="filter-grid">
@@ -124,14 +120,24 @@
header-align="center"
>
<template #default="{ row }">
<img
v-if="firstPhotoUrl(row.photoUrls)"
class="pl-photo-thumb"
:src="mediaActive ? resolvePhotoDisplayUrl(firstPhotoUrl(row.photoUrls)) : ''"
alt="车辆照片"
loading="lazy"
decoding="async"
/>
<div v-if="firstPhotoUrl(row.photoUrls)" class="pl-photo-thumb-wrap">
<img
class="pl-photo-thumb"
:src="mediaActive ? resolvePhotoDisplayUrl(firstPhotoUrl(row.photoUrls)) : ''"
alt="车辆照片"
title="点击在新标签页查看"
loading="lazy"
decoding="async"
@click.stop="handlePhotoPreview(row.photoUrls)"
/>
<el-icon
class="pl-photo-download"
title="下载"
@click.stop="handlePhotoDownload(row.photoUrls)"
>
<Download />
</el-icon>
</div>
<span v-else class="pl-photo-thumb pl-photo-thumb--empty">未上传</span>
</template>
</el-table-column>
@@ -459,7 +465,7 @@ import ListToolbarEndActions from '@/components/business/list-toolbar-end-action
import ListQuickSearchInput from '@/components/business/list-quick-search-input/index.vue'
import AttachmentUploadField from '@/components/business/attachment-upload-field/index.vue'
import { usePersistedListColumns } from '@/composables/usePersistedListColumns'
import { Check, Close, Delete, Edit, Plus, RefreshLeft, Search, Van } from '@element-plus/icons-vue'
import { Check, Close, Delete, Download, Edit, Plus, RefreshLeft, Search, Van } from '@element-plus/icons-vue'
import {
vehicleApi,
type Vehicle,
@@ -494,7 +500,15 @@ import {
getPlVehicleStatusTagType,
normalizePlPersonnelSummaryDisplay
} from '@/utils/pl-display'
import { firstPhotoUrl, resolvePhotoDisplayUrl } from '@/utils/pl-photo'
import {
downloadListPhoto,
firstPhotoUrl,
previewListPhoto,
resolvePhotoDisplayUrl
} from '@/utils/pl-photo'
const handlePhotoPreview = (raw?: string | null) => previewListPhoto(raw)
const handlePhotoDownload = (raw?: string | null) => downloadListPhoto(raw)
import {
collectSelfVehicleRequiredCertErrors,
ensureSelfVehicleCertSlots,
@@ -1169,6 +1183,14 @@ onMounted(() => {
gap: 6px;
}
.pl-photo-thumb-wrap {
position: relative;
display: inline-block;
vertical-align: middle;
width: 48px;
height: 48px;
}
.pl-photo-thumb {
width: 48px;
height: 48px;
@@ -1178,6 +1200,27 @@ onMounted(() => {
display: inline-block;
vertical-align: middle;
background: #f8fafc;
cursor: pointer;
}
.pl-photo-download {
position: absolute;
right: -4px;
bottom: -4px;
z-index: 2;
width: 18px;
height: 18px;
border-radius: 50%;
background: #fff;
border: 1px solid #e2e8f0;
color: #1e293b;
cursor: pointer;
&:hover {
color: #1ca851;
border-color: #1ca851;
background: #e6f8ed;
}
}
.pl-photo-thumb--empty {
@@ -2,12 +2,8 @@
<template>
<div class="page-container">
<section class="panel">
<div class="panel-top">
<h2 class="title-bar-heading">地址库</h2>
</div>
<div class="filter-block">
<el-form :model="searchForm" class="filter-form" @submit.prevent>
<el-form :model="searchForm" class="filter-form" @submit.prevent style="--filter-label-width: 80px">
<div class="filter-grid">
<el-form-item label="名称/地址">
<el-input
@@ -2,10 +2,6 @@
<template>
<div class="page-container">
<section class="panel">
<div class="panel-top">
<h2 class="title-bar-heading">运输列表</h2>
</div>
<div class="filter-block">
<el-form :model="searchForm" class="filter-form" @submit.prevent>
<div class="filter-grid">
@@ -2,12 +2,8 @@
<template>
<div class="page-container">
<section class="panel">
<div class="panel-top">
<h2 class="title-bar-heading">车辆维保申请</h2>
</div>
<div class="filter-block">
<el-form :model="searchForm" class="filter-form" @submit.prevent>
<el-form :model="searchForm" class="filter-form" @submit.prevent style="--filter-label-width: 110px">
<div class="filter-grid">
<el-form-item label="申请单号/车牌">
<el-input v-model="searchForm.q" placeholder="搜索申请单号或车牌" clearable @keyup.enter="handleSearch" />
@@ -2,12 +2,8 @@
<template>
<div class="page-container">
<section class="panel">
<div class="panel-top">
<h2 class="title-bar-heading">车辆维保处理登记</h2>
</div>
<div class="filter-block">
<el-form :model="searchForm" class="filter-form" @submit.prevent>
<el-form :model="searchForm" class="filter-form" @submit.prevent style="--filter-label-width: 170px">
<div class="filter-grid">
<el-form-item label="申请单号/车牌/处理单号">
<el-input v-model="searchForm.q" placeholder="搜索关键词" clearable @keyup.enter="handleSearch" />
@@ -2,12 +2,8 @@
<template>
<div class="page-container">
<section class="panel">
<div class="panel-top">
<h2 class="title-bar-heading">ETC加油申请</h2>
</div>
<div class="filter-block">
<el-form :model="searchForm" class="filter-form" @submit.prevent>
<el-form :model="searchForm" class="filter-form" @submit.prevent style="--filter-label-width: 110px">
<div class="filter-grid">
<el-form-item label="申请单号/车牌">
<el-input v-model="searchForm.q" placeholder="搜索申请单号或车牌" clearable @keyup.enter="handleSearch" />
@@ -2,12 +2,8 @@
<template>
<div class="page-container">
<section class="panel">
<div class="panel-top">
<h2 class="title-bar-heading">ETC加油发放登记</h2>
</div>
<div class="filter-block">
<el-form :model="searchForm" class="filter-form" @submit.prevent>
<el-form :model="searchForm" class="filter-form" @submit.prevent style="--filter-label-width: 160px">
<div class="filter-grid">
<el-form-item label="申请单号/车牌/订单号">
<el-input v-model="searchForm.q" placeholder="搜索关键词" clearable @keyup.enter="handleSearch" />
@@ -2,12 +2,8 @@
<template>
<div class="page-container">
<section class="panel">
<div class="panel-top">
<h2 class="title-bar-heading">车辆尿素申请</h2>
</div>
<div class="filter-block">
<el-form :model="searchForm" class="filter-form" @submit.prevent>
<el-form :model="searchForm" class="filter-form" @submit.prevent style="--filter-label-width: 110px">
<div class="filter-grid">
<el-form-item label="申请单号/车牌">
<el-input v-model="searchForm.q" placeholder="搜索申请单号或车牌" clearable @keyup.enter="handleSearch" />
@@ -2,12 +2,8 @@
<template>
<div class="page-container">
<section class="panel">
<div class="panel-top">
<h2 class="title-bar-heading">车辆尿素发放登记</h2>
</div>
<div class="filter-block">
<el-form :model="searchForm" class="filter-form" @submit.prevent>
<el-form :model="searchForm" class="filter-form" @submit.prevent style="--filter-label-width: 170px">
<div class="filter-grid">
<el-form-item label="申请单号/车牌/发放单号">
<el-input v-model="searchForm.q" placeholder="搜索关键词" clearable @keyup.enter="handleSearch" />
+57 -14
View File
@@ -2,10 +2,6 @@
<template>
<div class="page-container">
<section class="panel">
<div class="panel-top">
<h2 class="title-bar-heading">三方车辆</h2>
</div>
<!-- 筛选区 -->
<div class="filter-block">
<el-form :model="searchForm" class="filter-form" @submit.prevent>
@@ -129,14 +125,24 @@
header-align="center"
>
<template #default="{ row }">
<img
v-if="firstPhotoUrl(row.photoUrls)"
class="pl-photo-thumb"
:src="mediaActive ? resolvePhotoDisplayUrl(firstPhotoUrl(row.photoUrls)) : ''"
alt="车辆照片"
loading="lazy"
decoding="async"
/>
<div v-if="firstPhotoUrl(row.photoUrls)" class="pl-photo-thumb-wrap">
<img
class="pl-photo-thumb"
:src="mediaActive ? resolvePhotoDisplayUrl(firstPhotoUrl(row.photoUrls)) : ''"
alt="车辆照片"
title="点击在新标签页查看"
loading="lazy"
decoding="async"
@click.stop="handlePhotoPreview(row.photoUrls)"
/>
<el-icon
class="pl-photo-download"
title="下载"
@click.stop="handlePhotoDownload(row.photoUrls)"
>
<Download />
</el-icon>
</div>
<span v-else class="pl-photo-thumb pl-photo-thumb--empty">未上传</span>
</template>
</el-table-column>
@@ -477,7 +483,7 @@ import ListToolbarEndActions from '@/components/business/list-toolbar-end-action
import ListQuickSearchInput from '@/components/business/list-quick-search-input/index.vue'
import AttachmentUploadField from '@/components/business/attachment-upload-field/index.vue'
import { usePersistedListColumns } from '@/composables/usePersistedListColumns'
import { Check, Close, Delete, DocumentCopy, Edit, Plus, RefreshLeft, Search, Van } from '@element-plus/icons-vue'
import { Check, Close, Delete, DocumentCopy, Download, Edit, Plus, RefreshLeft, Search, Van } from '@element-plus/icons-vue'
import {
vehicleApi,
personnelApi,
@@ -508,7 +514,15 @@ import { pickBxData, pickBxPageResult } from '@/utils/http/bx'
import { DEFAULT_LIST_PAGE_SIZE } from '@/utils/table/tableConfig'
import { formatDateTime } from '@/utils/format'
import { formatPlVehiclePlateDisplay, normalizePlPersonnelSummaryDisplay } from '@/utils/pl-display'
import { firstPhotoUrl, resolvePhotoDisplayUrl } from '@/utils/pl-photo'
import {
downloadListPhoto,
firstPhotoUrl,
previewListPhoto,
resolvePhotoDisplayUrl
} from '@/utils/pl-photo'
const handlePhotoPreview = (raw?: string | null) => previewListPhoto(raw)
const handlePhotoDownload = (raw?: string | null) => downloadListPhoto(raw)
import { ensureVehicleCertSlots } from '@/utils/pl-cert-slots'
import {
PL_VEHICLE_CERT_NAME_OPTIONS,
@@ -1234,6 +1248,14 @@ onMounted(() => {
gap: 6px;
}
.pl-photo-thumb-wrap {
position: relative;
display: inline-block;
vertical-align: middle;
width: 48px;
height: 48px;
}
.pl-photo-thumb {
width: 48px;
height: 48px;
@@ -1243,6 +1265,27 @@ onMounted(() => {
display: inline-block;
vertical-align: middle;
background: #f8fafc;
cursor: pointer;
}
.pl-photo-download {
position: absolute;
right: -4px;
bottom: -4px;
z-index: 2;
width: 18px;
height: 18px;
border-radius: 50%;
background: #fff;
border: 1px solid #e2e8f0;
color: #1e293b;
cursor: pointer;
&:hover {
color: #1ca851;
border-color: #1ca851;
background: #e6f8ed;
}
}
.pl-photo-thumb--empty {
+281 -63
View File
@@ -1,69 +1,92 @@
<template>
<div class="portal-home">
<section v-if="favoriteCards.length" class="portal-home-section">
<h2 class="title-bar-heading">收藏</h2>
<div class="portal-home-grid">
<button
v-for="card in favoriteCards"
:key="'fav-' + card.path"
type="button"
class="portal-home-card"
@click="openCard(card.path)"
>
<span class="portal-home-card__title">{{ card.title }}</span>
<button
type="button"
class="portal-home-card__star is-on"
aria-label="取消收藏"
@click.stop="onToggleStar(card.path)"
>
<ElIcon><StarFilled /></ElIcon>
</button>
</button>
<div class="portal-home-hero">
<div>
<h3>{{ greetText }},{{ displayName }}</h3>
<p>{{ dateText }} · 点击卡片进入业务,星标加入收藏</p>
</div>
</section>
</div>
<section v-for="sec in sections" :key="sec.modulePath" class="portal-home-section">
<h2 class="title-bar-heading">{{ sec.moduleTitle }}</h2>
<div class="portal-home-grid">
<button
v-for="card in sec.cards"
:key="card.path"
type="button"
class="portal-home-card"
@click="openCard(card.path)"
<div class="portal-home-cards-area">
<section v-if="favoriteList.length" class="portal-home-section">
<div class="portal-home-section__head">
<h2 class="title-bar-heading">收藏</h2>
<span class="portal-home-section__tip">可拖拽调整顺序</span>
</div>
<VueDraggable
v-model="favoriteList"
class="portal-home-grid"
ghost-class="portal-home-card--ghost"
chosen-class="portal-home-card--chosen"
:animation="180"
@start="onFavDragStart"
@end="onFavDragEnd"
>
<span class="portal-home-card__title">{{ card.title }}</span>
<button
v-for="card in favoriteList"
:key="'fav-' + card.path"
type="button"
class="portal-home-card__star"
:class="{ 'is-on': favStore.isFavorite(card.path) }"
:aria-label="favStore.isFavorite(card.path) ? '取消收藏' : '收藏'"
@click.stop="onToggleStar(card.path)"
class="portal-home-card portal-home-card--fav"
@click="onFavCardClick(card.path)"
>
<ElIcon>
<StarFilled v-if="favStore.isFavorite(card.path)" />
<Star v-else />
</ElIcon>
<span class="portal-home-card__title">{{ card.title }}</span>
<button
type="button"
class="portal-home-card__star is-on"
aria-label="取消收藏"
@click.stop="onToggleStar(card.path)"
>
<ElIcon><StarFilled /></ElIcon>
</button>
</button>
</button>
</div>
</section>
</VueDraggable>
</section>
<p v-if="!sections.length" class="portal-home-empty">暂无可用菜单</p>
<section
v-for="sec in visibleSections"
:key="sec.modulePath"
class="portal-home-section"
>
<h2 class="title-bar-heading">{{ sec.moduleTitle }}</h2>
<div class="portal-home-grid">
<button
v-for="card in sec.cards"
:key="card.path"
type="button"
class="portal-home-card"
@click="openCard(card.path)"
>
<span class="portal-home-card__title">{{ card.title }}</span>
<button
type="button"
class="portal-home-card__star"
aria-label="收藏"
@click.stop="onToggleStar(card.path)"
>
<ElIcon><Star /></ElIcon>
</button>
</button>
</div>
</section>
<p v-if="!sections.length" class="portal-home-empty">暂无可用菜单</p>
</div>
</div>
</template>
<script setup lang="ts">
import { computed, onMounted } from 'vue'
import { computed, onMounted, ref, watch } from 'vue'
import { useRouter } from 'vue-router'
import { storeToRefs } from 'pinia'
import { Star, StarFilled } from '@element-plus/icons-vue'
import { VueDraggable } from 'vue-draggable-plus'
import { useMenuStore } from '@/store/modules/menu'
import { useMenuFavoriteStore } from '@/store/modules/menuFavorite'
import { useUserStore } from '@/store/modules/user'
import {
collectPortalHomeSections,
findHomeCardByPath
findHomeCardByPath,
type PortalHomeCardItem
} from '@/utils/router/portal-home-cards'
defineOptions({ name: 'PortalHome' })
@@ -71,14 +94,54 @@
const router = useRouter()
const menuStore = useMenuStore()
const favStore = useMenuFavoriteStore()
const userStore = useUserStore()
const { menuList } = storeToRefs(menuStore)
const { items: favItems } = storeToRefs(favStore)
const sections = computed(() => collectPortalHomeSections(menuList.value || []))
const favoriteCards = computed(() =>
favStore.items.map(
const favoritePathSet = computed(() => new Set(favItems.value.map((i) => i.path)))
/** 模块区隐藏已在收藏中展示的菜单,避免重复 */
const visibleSections = computed(() =>
sections.value
.map((sec) => ({
...sec,
cards: sec.cards.filter((c) => !favoritePathSet.value.has(c.path))
}))
.filter((sec) => sec.cards.length > 0)
)
const favoriteList = ref<PortalHomeCardItem[]>([])
const favDragging = ref(false)
const suppressFavClick = ref(false)
const syncFavoriteList = () => {
favoriteList.value = favItems.value.map(
(i) => findHomeCardByPath(sections.value, i.path) || { path: i.path, title: i.path }
)
}
watch([favItems, sections], syncFavoriteList, { immediate: true, deep: true })
const displayName = computed(() => {
const info = userStore.getUserInfo || ({} as Api.Auth.UserInfo)
return String(info.realName || info.userName || info.username || '').trim() || '管理员'
})
const greetText = computed(() => {
const h = new Date().getHours()
if (h < 12) return '上午好'
if (h < 18) return '下午好'
return '晚上好'
})
const dateText = computed(() =>
new Date().toLocaleDateString('zh-CN', {
month: 'long',
day: 'numeric',
weekday: 'short'
})
)
onMounted(async () => {
@@ -91,6 +154,32 @@
router.push(path)
}
const onFavCardClick = (path: string) => {
if (favDragging.value || suppressFavClick.value) return
openCard(path)
}
const onFavDragStart = () => {
favDragging.value = true
}
const onFavDragEnd = async () => {
favDragging.value = false
suppressFavClick.value = true
window.setTimeout(() => {
suppressFavClick.value = false
}, 0)
const ordered = favoriteList.value.map((c) => c.path)
const prev = favItems.value.map((i) => i.path).join('\0')
const next = ordered.join('\0')
if (prev === next) return
try {
await favStore.reorderFavorites(ordered)
} catch {
syncFavoriteList()
}
}
const onToggleStar = async (path: string) => {
await favStore.toggleFavorite(path)
}
@@ -98,17 +187,89 @@
<style scoped lang="scss">
.portal-home {
padding: 0 0 24px;
padding: 16px 0 24px;
}
.portal-home-hero {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
margin-bottom: 4px;
padding: 12px 14px;
border: 1px solid #bbf7d0;
border-radius: 10px;
background:
radial-gradient(100% 120% at 100% 0%, rgba(16, 185, 129, 0.14), transparent 55%),
linear-gradient(135deg, #ecfdf5 0%, #ffffff 60%, #f8fafc 100%);
h3 {
margin: 0 0 2px;
font-size: 16px;
font-weight: 700;
color: var(--mint-text, #1e293b);
}
p {
margin: 0;
font-size: 12px;
color: var(--mint-text-muted, #64748b);
}
}
/* 卡片区:与问候条拉开,左右留白 */
.portal-home-cards-area {
margin-top: 4px;
padding: 12px 16px 8px;
}
.portal-home-section {
margin-bottom: 28px;
margin-bottom: 22px;
&:last-child {
margin-bottom: 4px;
}
}
.portal-home-section__head {
display: flex;
flex-wrap: wrap;
gap: 8px;
align-items: center;
}
.portal-home-section__tip {
font-size: 12px;
font-weight: 400;
color: var(--mint-text-muted, #94a3b8);
}
/* 不在 .panel-top 内,自行补绿色竖条 */
.title-bar-heading {
position: relative;
display: inline-flex;
align-items: center;
gap: 8px;
margin: 0;
padding-left: 0;
font-size: 15px;
font-weight: 600;
color: var(--mint-text, #1e293b);
&::before {
content: '';
flex-shrink: 0;
width: 3px;
height: 14px;
border-radius: 2px;
background: var(--mint-primary, #10b981);
}
}
.portal-home-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
gap: 12px;
grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
gap: 8px;
margin-top: 12px;
}
@@ -116,49 +277,106 @@
position: relative;
display: flex;
align-items: center;
min-height: 72px;
padding: 12px 36px 12px 14px;
text-align: left;
justify-content: center;
min-height: 56px;
padding: 12px 22px 12px 10px;
text-align: center;
cursor: pointer;
background: #fff;
border: 1px solid var(--mint-border, #e2e8f0);
border-radius: 10px;
transition:
background 0.15s ease,
border-color 0.15s ease;
transform 0.15s ease,
box-shadow 0.15s ease,
border-color 0.15s ease,
background 0.15s ease;
&:hover {
background: var(--mint-primary-bg, #ecfdf5);
border-color: #a7f3d0;
border-color: #6ee7b7;
box-shadow: 0 4px 12px rgba(16, 185, 129, 0.1);
transform: translateY(-1px);
}
&:active {
transform: translateY(0);
}
&--fav {
cursor: grab;
&:active {
cursor: grabbing;
}
}
}
/* Sortable 幽灵节点可能无 scoped 属性 */
:deep(.portal-home-card--ghost) {
background: var(--mint-primary-bg, #ecfdf5);
border-style: dashed;
border-color: #6ee7b7;
opacity: 0.65;
}
:deep(.portal-home-card--chosen) {
border-color: #6ee7b7;
box-shadow: 0 6px 16px rgba(16, 185, 129, 0.16);
}
.portal-home-card__title {
font-size: 14px;
font-weight: 500;
display: -webkit-box;
width: 100%;
overflow: hidden;
font-size: 13px;
font-weight: 600;
line-height: 1.35;
color: var(--mint-text, #1e293b);
text-align: center;
word-break: break-all;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
}
.portal-home-card__star {
position: absolute;
top: 8px;
right: 8px;
top: 4px;
right: 4px;
display: inline-flex;
align-items: center;
justify-content: center;
padding: 4px;
font-size: 16px;
width: 22px;
height: 22px;
padding: 0;
font-size: 13px;
line-height: 1;
color: var(--mint-text-muted, #94a3b8);
cursor: pointer;
background: transparent;
border: 0;
border-radius: 6px;
opacity: 0.55;
transition:
background 0.15s ease,
color 0.15s ease,
opacity 0.15s ease;
&:hover {
color: #d97706;
background: #f1f5f9;
opacity: 1;
}
&.is-on {
color: #d97706;
opacity: 1;
}
}
.portal-home-card:hover .portal-home-card__star {
opacity: 1;
}
.portal-home-empty {
margin-top: 48px;
color: var(--mint-text-muted, #94a3b8);
@@ -0,0 +1,243 @@
<template>
<div class="page-container approver-setting-page">
<section class="panel">
<div class="panel-top">
<h2 class="title-bar-heading">报价单审批人</h2>
</div>
<div class="panel-body approver-setting-body">
<el-form :model="quoteForm" label-position="top" class="crm-dialog-form">
<div class="form-grid-2">
<el-form-item class="form-col-span-2">
<template #label>
默认审批人<span class="form-label-tip">支持多人,按选择顺序依次审批</span>
</template>
<el-select
v-model="quoteForm.approverIds"
multiple
filterable
placeholder="请选择审批人"
style="width: 100%"
>
<el-option
v-for="user in userList"
:key="user.userId"
:label="formatApproverOptionLabel(user)"
:value="user.userId"
/>
</el-select>
</el-form-item>
<el-form-item label="状态">
<el-radio-group v-model="quoteForm.status">
<el-radio value="0">启用</el-radio>
<el-radio value="1">停用</el-radio>
</el-radio-group>
</el-form-item>
</div>
</el-form>
<div class="approver-setting-actions">
<el-button class="btn-ghost" :loading="quoteLoading" @click="loadQuoteSetting">
<el-icon><RefreshLeft /></el-icon>重置
</el-button>
<el-button class="btn-main" type="primary" :loading="quoteSaving" @click="handleSaveQuote">
<el-icon><Check /></el-icon>保存设置
</el-button>
</div>
</div>
</section>
<section class="panel">
<div class="panel-top">
<h2 class="title-bar-heading">合同审批人</h2>
</div>
<div class="panel-body approver-setting-body">
<el-form :model="contractForm" label-position="top" class="crm-dialog-form">
<div class="form-grid-2">
<el-form-item class="form-col-span-2">
<template #label>
默认审批人<span class="form-label-tip">支持多人,按选择顺序依次审批</span>
</template>
<el-select
v-model="contractForm.approverIds"
multiple
filterable
placeholder="请选择审批人"
style="width: 100%"
>
<el-option
v-for="user in userList"
:key="user.userId"
:label="formatApproverOptionLabel(user)"
:value="user.userId"
/>
</el-select>
</el-form-item>
<el-form-item label="状态">
<el-radio-group v-model="contractForm.status">
<el-radio value="0">启用</el-radio>
<el-radio value="1">停用</el-radio>
</el-radio-group>
</el-form-item>
</div>
</el-form>
<div class="approver-setting-actions">
<el-button class="btn-ghost" :loading="contractLoading" @click="loadContractSetting">
<el-icon><RefreshLeft /></el-icon>重置
</el-button>
<el-button
class="btn-main"
type="primary"
:loading="contractSaving"
@click="handleSaveContract"
>
<el-icon><Check /></el-icon>保存设置
</el-button>
</div>
</div>
</section>
</div>
</template>
<script setup lang="ts" name="SystemApproverSetting">
import { RefreshLeft, Check } from '@element-plus/icons-vue'
import { fetchUserOptions } from '@/api/admin'
import { getQuoteApproverSetting, saveQuoteApproverSetting } from '@/api/crm/quote'
import type { QuoteApproverSettingForm } from '@/api/crm/quote/types'
import { getContractApproverSetting, saveContractApproverSetting } from '@/api/crm/contract'
import type { ContractApproverSettingForm } from '@/api/crm/contract/types'
import { $modal } from '@/utils/modal'
interface UserOption {
userId: string
nickName: string
userName: string
}
const userList = ref<UserOption[]>([])
const quoteLoading = ref(false)
const quoteSaving = ref(false)
const quoteForm = ref<QuoteApproverSettingForm>({
approverIds: [],
status: '0'
})
const contractLoading = ref(false)
const contractSaving = ref(false)
const contractForm = ref<ContractApproverSettingForm>({
approverIds: [],
status: '0'
})
const formatApproverOptionLabel = (user: { nickName?: string; userName?: string }) => {
const nick = (user.nickName || '').trim()
const account = (user.userName || '').trim()
if (nick && account) return `${nick}(${account})`
return nick || account
}
const loadUserList = async () => {
try {
const res = await fetchUserOptions()
const options = (res as any)?.data ?? res ?? []
userList.value = (Array.isArray(options) ? options : [])
.map((item: any) => ({
userId: String(item.value ?? item.userId ?? item.id ?? ''),
nickName: item.nickName ?? item.label ?? item.userName ?? '',
userName: item.userNo ?? item.user_no ?? item.userName ?? ''
}))
.filter((u) => u.userId)
} catch (error) {
console.error('加载用户列表失败:', error)
userList.value = []
}
}
const loadQuoteSetting = async () => {
quoteLoading.value = true
try {
const { data } = await getQuoteApproverSetting()
quoteForm.value = {
approverIds: (data.approverIds || []).map(String),
status: (data.status === '1' ? '1' : '0') as '0' | '1'
}
} catch (error: any) {
console.error('加载报价审批人设置失败:', error)
$modal.msgError(error?.msg || '加载报价审批人设置失败,请稍后重试')
} finally {
quoteLoading.value = false
}
}
const loadContractSetting = async () => {
contractLoading.value = true
try {
const { data } = await getContractApproverSetting()
contractForm.value = {
approverIds: (data.approverIds || []).map(String),
status: (data.status === '1' ? '1' : '0') as '0' | '1'
}
} catch (error: any) {
console.error('加载合同审批人设置失败:', error)
$modal.msgError(error?.msg || '加载合同审批人设置失败,请稍后重试')
} finally {
contractLoading.value = false
}
}
const handleSaveQuote = async () => {
quoteSaving.value = true
try {
await saveQuoteApproverSetting({
approverIds: quoteForm.value.approverIds || [],
status: quoteForm.value.status
})
$modal.msgSuccess('保存成功')
await loadQuoteSetting()
} catch (error: any) {
console.error('保存报价审批人设置失败:', error)
$modal.msgError(error?.msg || '保存失败,请稍后重试')
} finally {
quoteSaving.value = false
}
}
const handleSaveContract = async () => {
contractSaving.value = true
try {
await saveContractApproverSetting({
approverIds: contractForm.value.approverIds || [],
status: contractForm.value.status
})
$modal.msgSuccess('保存成功')
await loadContractSetting()
} catch (error: any) {
console.error('保存合同审批人设置失败:', error)
$modal.msgError(error?.msg || '保存失败,请稍后重试')
} finally {
contractSaving.value = false
}
}
onMounted(async () => {
await Promise.all([loadUserList(), loadQuoteSetting(), loadContractSetting()])
})
</script>
<style scoped lang="scss">
.approver-setting-page {
display: flex;
flex-direction: column;
gap: 16px;
}
.approver-setting-body {
padding: 16px 20px 24px;
}
.approver-setting-actions {
display: flex;
justify-content: flex-end;
gap: 8px;
margin-top: 16px;
}
</style>
@@ -3,10 +3,6 @@
<template>
<div class="page-container">
<section class="panel">
<div class="panel-top">
<h2 class="title-bar-heading">组织管理</h2>
</div>
<div class="filter-block">
<el-form :model="searchForm" class="filter-form" @submit.prevent>
<div class="filter-grid">
@@ -2,10 +2,6 @@
<template>
<div class="page-container">
<section class="panel">
<div class="panel-top">
<h2 class="title-bar-heading">字典类型</h2>
</div>
<div class="filter-block">
<el-form :model="searchForm" class="filter-form" @submit.prevent>
<div class="filter-grid">
@@ -2,10 +2,6 @@
<template>
<div class="page-container">
<section class="panel">
<div class="panel-top">
<h2 class="title-bar-heading">请假列表</h2>
</div>
<div class="filter-block">
<el-form :model="filterForm" class="filter-form" @submit.prevent>
<div class="filter-grid">
@@ -2,10 +2,6 @@
<template>
<div class="page-container">
<section class="panel">
<div class="panel-top">
<h2 class="title-bar-heading">菜单列表</h2>
</div>
<div class="filter-block">
<el-form :model="searchForm" class="filter-form" @submit.prevent>
<div class="filter-grid">
@@ -2,10 +2,6 @@
<template>
<div class="page-container">
<section class="panel">
<div class="panel-top">
<h2 class="title-bar-heading">操作日志</h2>
</div>
<div class="filter-block">
<el-form :model="searchForm" class="filter-form" @submit.prevent>
<div class="filter-grid">
@@ -3,10 +3,6 @@
<template>
<div class="page-container">
<section class="panel">
<div class="panel-top">
<h2 class="title-bar-heading">职位列表</h2>
</div>
<div class="filter-block">
<el-form :model="searchForm" class="filter-form" @submit.prevent>
<div class="filter-grid">
@@ -3,10 +3,6 @@
<template>
<div class="page-container">
<section class="panel">
<div class="panel-top">
<h2 class="title-bar-heading">角色列表</h2>
</div>
<div class="filter-block">
<el-form :model="searchForm" class="filter-form" @submit.prevent>
<div class="filter-grid">
Loaded 100 of 388 files, more files were not shown because too many files have changed in this diff. Show more