提交
This commit is contained in:
1 parent
dacfdc9ff6
commit
f9676f8759
906 files changed
+533306
-12946
No files matched your search
@@ -35,7 +35,7 @@
|
||||
:loading="loading"
|
||||
style="width: 100%"
|
||||
>
|
||||
<el-option v-for="user in userList" :key="user.userId" :label="`${user.nickName} (${user.userName})`" :value="user.userId">
|
||||
<el-option v-for="user in userList" :key="user.userId" :label="formatApproverOptionLabel(user)" :value="user.userId">
|
||||
<span style="float: left">{{ user.nickName }}</span>
|
||||
<span style="float: right; color: var(--mint-text-muted, #64748b); font-size: 13px">
|
||||
{{ user.deptName }}
|
||||
@@ -113,6 +113,13 @@ const handleClose = () => {
|
||||
emit('close')
|
||||
}
|
||||
|
||||
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 loadUsers = async (nickName?: string) => {
|
||||
loading.value = true
|
||||
try {
|
||||
@@ -120,8 +127,8 @@ const loadUsers = async (nickName?: string) => {
|
||||
const options = (res as any)?.data ?? res ?? []
|
||||
const mapped = (Array.isArray(options) ? options : []).map((item: any) => ({
|
||||
userId: item.value ?? item.userId ?? item.id,
|
||||
nickName: item.label ?? item.nickName ?? item.userName ?? '',
|
||||
userName: item.userNo ?? item.userName ?? '',
|
||||
nickName: item.nickName ?? item.label ?? item.userName ?? '',
|
||||
userName: item.userNo ?? item.user_no ?? item.userName ?? '',
|
||||
deptName: item.deptName ?? ''
|
||||
}))
|
||||
userList.value = nickName
|
||||
|
||||
@@ -1,5 +1,14 @@
|
||||
<template>
|
||||
<el-dialog title="选择产品" v-model="dialogVisible" width="80%" :close-on-click-modal="false" append-to-body>
|
||||
<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">
|
||||
@@ -24,8 +33,12 @@
|
||||
<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 label="在售" value="on" />
|
||||
<el-option label="下架" value="off" />
|
||||
<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>
|
||||
@@ -43,49 +56,53 @@
|
||||
</el-form>
|
||||
|
||||
<!-- 产品列表 -->
|
||||
<el-table
|
||||
ref="tableRef"
|
||||
v-loading="loading"
|
||||
:data="productList"
|
||||
@selection-change="handleSelectionChange"
|
||||
@row-dblclick="handleRowDblClick"
|
||||
:max-height="400"
|
||||
border
|
||||
>
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column type="index" label="序号" width="60" align="center" />
|
||||
<el-table-column label="产品编号" prop="productNo" width="140" align="center" :show-overflow-tooltip="true" />
|
||||
<el-table-column label="产品名称" prop="productName" min-width="120" :show-overflow-tooltip="true" />
|
||||
<el-table-column label="产品分类" prop="categoryName" width="120" />
|
||||
<el-table-column label="规格型号" prop="model" width="120" :show-overflow-tooltip="true" />
|
||||
<el-table-column label="计量单位" prop="unit" width="100" 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" width="90" align="center">
|
||||
<template #default="scope">
|
||||
<span>{{ scope.row.taxRate || 0 }}%</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="状态" prop="status" width="90" align="center">
|
||||
<template #default="scope">
|
||||
<el-tag :type="scope.row.status === 'on' ? 'success' : 'info'">
|
||||
{{ scope.row.status === 'on' ? '在售' : '下架' }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<div class="panel dialog-list-panel">
|
||||
<div class="list-body list-wrap dialog-list-body-only">
|
||||
<el-table
|
||||
ref="tableRef"
|
||||
v-loading="loading"
|
||||
:data="productList"
|
||||
class="list-table"
|
||||
stripe
|
||||
@selection-change="handleSelectionChange"
|
||||
@row-click="handleRowClick"
|
||||
: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="180" align="center" header-align="center" :show-overflow-tooltip="true" />
|
||||
<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>
|
||||
</el-table>
|
||||
|
||||
<!-- 分页 -->
|
||||
<ListPagination
|
||||
v-show="total > 0"
|
||||
:total="total"
|
||||
v-model:page="queryParams.pageNum"
|
||||
v-model:limit="queryParams.pageSize"
|
||||
@pagination="getList"
|
||||
class="mt-3"
|
||||
/>
|
||||
<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>
|
||||
@@ -181,13 +198,13 @@ const getList = async () => {
|
||||
const res = await fetchProductList({
|
||||
page: queryParams.value.pageNum,
|
||||
pageSize: queryParams.value.pageSize,
|
||||
productName: queryParams.value.productName,
|
||||
keyword: queryParams.value.productName,
|
||||
categoryId: queryParams.value.categoryId,
|
||||
status: queryParams.value.status
|
||||
});
|
||||
const data = (res as any)?.list ?? (res as any)?.rows ?? [];
|
||||
productList.value = data;
|
||||
total.value = (res as any)?.total ?? data.length;
|
||||
const data = (res as any)?.data || res || {};
|
||||
productList.value = data.list || data.rows || [];
|
||||
total.value = data.total ?? 0;
|
||||
} catch (error) {
|
||||
console.error('获取产品列表失败:', error);
|
||||
} finally {
|
||||
@@ -227,16 +244,30 @@ const resetQuery = () => {
|
||||
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 handleRowDblClick = (row: ProductVO) => {
|
||||
// 切换行的选中状态
|
||||
tableRef.value?.toggleRowSelection(row);
|
||||
};
|
||||
/** 单击行选中/取消选中产品(点击复选框列时不重复切换) */
|
||||
const handleRowClick = (row: any, _column: unknown, event: MouseEvent) => {
|
||||
const target = event.target as HTMLElement
|
||||
if (target.closest('.el-checkbox')) return
|
||||
tableRef.value?.toggleRowSelection(row)
|
||||
}
|
||||
|
||||
/** 移除已选产品 */
|
||||
const handleRemoveSelection = (product: ProductVO) => {
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
:grid-columns="2"
|
||||
dialog-class="quote-view-dialog"
|
||||
modal-class="order-module-dialog-mask"
|
||||
append-to-body
|
||||
>
|
||||
<template #hero-actions>
|
||||
<div class="quote-view-hero-actions">
|
||||
@@ -64,14 +65,15 @@
|
||||
</template>
|
||||
|
||||
<template #products>
|
||||
<div class="view-subtable-wrap">
|
||||
<el-table
|
||||
:data="quoteInfo.productList || []"
|
||||
class="view-subtable"
|
||||
stripe
|
||||
empty-text="暂无产品明细"
|
||||
>
|
||||
<el-table-column type="index" label="序号" width="60" align="center" />
|
||||
<div class="panel dialog-list-panel">
|
||||
<div class="list-body list-wrap dialog-list-body-only">
|
||||
<el-table
|
||||
:data="quoteInfo.productList || []"
|
||||
class="list-table"
|
||||
stripe
|
||||
empty-text="暂无产品明细"
|
||||
>
|
||||
<el-table-column type="index" label="序号" min-width="60" align="center" header-align="center" />
|
||||
<el-table-column label="产品名称" prop="productName" min-width="120" align="center" header-align="center" show-overflow-tooltip />
|
||||
<el-table-column label="型号/规格" prop="model" min-width="130" align="center" header-align="center" show-overflow-tooltip>
|
||||
<template #default="{ row }">
|
||||
@@ -134,6 +136,7 @@
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="(quoteInfo.productList?.length || 0) > 0" class="quote-product-summary">
|
||||
<div class="quote-product-summary-item">
|
||||
@@ -689,9 +692,5 @@ defineExpose({ open, refresh })
|
||||
margin: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.view-section-slot .view-subtable-wrap {
|
||||
margin-top: 0;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -45,11 +45,16 @@ const emit = defineEmits<{
|
||||
}>()
|
||||
|
||||
const visible = ref(false)
|
||||
const dialogMode = ref<'add' | 'edit'>('add')
|
||||
const dialogMode = ref<'add' | 'edit' | 'copy'>('add')
|
||||
const editId = ref<string | number>('')
|
||||
const copyId = ref<string | number>('')
|
||||
const panelRef = ref<InstanceType<typeof QuoteFormPanel> | null>(null)
|
||||
const saveLoading = computed(() => Boolean(panelRef.value?.saveLoading))
|
||||
const dialogTitle = computed(() => (dialogMode.value === 'edit' ? '编辑报价单' : '新增报价单'))
|
||||
const dialogTitle = computed(() => {
|
||||
if (dialogMode.value === 'edit') return '编辑报价单'
|
||||
if (dialogMode.value === 'copy') return '复制新增报价单'
|
||||
return '新增报价单'
|
||||
})
|
||||
|
||||
const handleOpened = async () => {
|
||||
await nextTick()
|
||||
@@ -57,6 +62,10 @@ const handleOpened = async () => {
|
||||
await panelRef.value?.initEdit(editId.value)
|
||||
return
|
||||
}
|
||||
if (dialogMode.value === 'copy' && copyId.value) {
|
||||
await panelRef.value?.initCopy(copyId.value)
|
||||
return
|
||||
}
|
||||
await panelRef.value?.initNew()
|
||||
}
|
||||
|
||||
@@ -76,16 +85,25 @@ const handleSuccess = () => {
|
||||
const open = () => {
|
||||
dialogMode.value = 'add'
|
||||
editId.value = ''
|
||||
copyId.value = ''
|
||||
visible.value = true
|
||||
}
|
||||
|
||||
const openEdit = (id: string | number) => {
|
||||
dialogMode.value = 'edit'
|
||||
editId.value = id
|
||||
copyId.value = ''
|
||||
visible.value = true
|
||||
}
|
||||
|
||||
defineExpose({ open, openEdit })
|
||||
const openCopy = (id: string | number) => {
|
||||
dialogMode.value = 'copy'
|
||||
copyId.value = id
|
||||
editId.value = ''
|
||||
visible.value = true
|
||||
}
|
||||
|
||||
defineExpose({ open, openEdit, openCopy })
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
|
||||
@@ -98,19 +98,31 @@
|
||||
</span>
|
||||
</el-divider>
|
||||
<div>
|
||||
<div class="product-toolbar mb-3">
|
||||
<el-button class="btn-main" type="primary" @click="handleAddProduct">
|
||||
<el-icon><Plus /></el-icon>添加产品
|
||||
</el-button>
|
||||
<el-button class="btn-ghost" :disabled="selectedProducts.length === 0" @click="handleDeleteProducts">
|
||||
<el-icon><Delete /></el-icon>删除选中
|
||||
</el-button>
|
||||
</div>
|
||||
<div class="panel dialog-list-panel">
|
||||
<div class="list-toolbar">
|
||||
<div class="list-toolbar-row">
|
||||
<div class="list-toolbar-selected">
|
||||
<el-button class="btn-main" type="primary" @click="handleAddProduct">
|
||||
<el-icon><Plus /></el-icon>添加产品
|
||||
</el-button>
|
||||
<el-button class="btn-ghost" :disabled="selectedProducts.length === 0" @click="handleDeleteProducts">
|
||||
<el-icon><Delete /></el-icon>删除选中
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 产品列表 -->
|
||||
<el-table :data="form.products" border @selection-change="handleProductSelection" :max-height="400" style="width: 100%">
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column type="index" label="序号" width="60" align="center" />
|
||||
<div class="list-body list-wrap">
|
||||
<el-table
|
||||
:data="form.products"
|
||||
class="list-table"
|
||||
stripe
|
||||
@selection-change="handleProductSelection"
|
||||
:max-height="400"
|
||||
style="width: 100%"
|
||||
>
|
||||
<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="productName" min-width="160" :show-overflow-tooltip="true">
|
||||
<template #default="scope">
|
||||
<el-input v-model="scope.row.productName" placeholder="请输入产品名称" clearable readonly />
|
||||
@@ -152,7 +164,13 @@
|
||||
<el-table-column prop="price" width="130">
|
||||
<template #header> <span style="color: #f56c6c">*</span> 含税单价/元</template>
|
||||
<template #default="scope">
|
||||
<el-input v-model="scope.row.price" placeholder="含税单价" @input="handlePriceChange(scope.row)" clearable />
|
||||
<el-input
|
||||
v-model="scope.row.price"
|
||||
class="money-field-input"
|
||||
placeholder="含税单价"
|
||||
@input="handlePriceChange(scope.row)"
|
||||
clearable
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="subtotal" width="130" align="right">
|
||||
@@ -192,14 +210,16 @@
|
||||
</el-select>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" min-width="80" align="center" fixed="right">
|
||||
<el-table-column label="操作" min-width="80" align="center" header-align="center" fixed="right" class-name="col-actions">
|
||||
<template #default="scope">
|
||||
<el-button link type="danger" @click="handleRemoveProduct(scope.$index)">
|
||||
<el-icon><Delete /></el-icon>删除
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</el-table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 合计信息 -->
|
||||
<el-row class="mt-4">
|
||||
@@ -389,7 +409,7 @@
|
||||
选择审批人<span class="form-label-tip">可选择多个审批人,按顺序依次审批</span>
|
||||
</template>
|
||||
<el-select v-model="submitForm.approverIds" multiple placeholder="请选择审批人" style="width: 100%">
|
||||
<el-option v-for="user in userList" :key="user.userId" :label="`${user.nickName}(${user.userName})`" :value="user.userId" />
|
||||
<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="备注说明" prop="remark" class="form-col-span-2">
|
||||
@@ -940,6 +960,13 @@ const handleOwnerChange = (userId: string | number | undefined) => {
|
||||
form.value.ownerUserName = user?.nickName || ''
|
||||
}
|
||||
|
||||
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 {
|
||||
@@ -947,8 +974,8 @@ const loadUserList = async () => {
|
||||
const options = (res as any)?.data ?? res ?? [];
|
||||
userList.value = (Array.isArray(options) ? options : []).map((item: any) => ({
|
||||
userId: item.value ?? item.userId ?? item.id,
|
||||
nickName: item.label ?? item.nickName ?? item.userName ?? '',
|
||||
userName: item.userNo ?? item.userName ?? '',
|
||||
nickName: item.nickName ?? item.label ?? item.userName ?? '',
|
||||
userName: item.userNo ?? item.user_no ?? item.userName ?? '',
|
||||
deptName: item.deptName ?? ''
|
||||
}));
|
||||
} catch (error) {
|
||||
@@ -1079,12 +1106,11 @@ const handleProductConfirm = (products: any[]) => {
|
||||
categoryName: product.categoryName,
|
||||
model: product.model, // 型号/规格
|
||||
unit: product.unit, // 单位
|
||||
price: product.price || 0,
|
||||
quantity: 1,
|
||||
discount: 0,
|
||||
taxRate: normalizeTaxRateDisplay(product.taxRate, 13), // 税率:整数不显示小数位
|
||||
taxAmount: 0,
|
||||
subtotal: product.price || 0,
|
||||
subtotal: 0,
|
||||
packageSpec: '',
|
||||
deliveryMethod: ''
|
||||
};
|
||||
@@ -1590,6 +1616,13 @@ const initEdit = async (id: string | number) => {
|
||||
await getQuoteInfo(id);
|
||||
};
|
||||
|
||||
const initCopy = async (copyId: string | number) => {
|
||||
resetPanelState();
|
||||
await dictStore.loadAllDict();
|
||||
await Promise.all([loadSupplierList(), loadUserList()]);
|
||||
await getQuoteInfoForCopy(copyId);
|
||||
};
|
||||
|
||||
const finishClose = () => {
|
||||
if (props.hideFooter) {
|
||||
emit('close');
|
||||
@@ -1615,6 +1648,7 @@ defineExpose({
|
||||
formTitle,
|
||||
initNew,
|
||||
initEdit,
|
||||
initCopy,
|
||||
handleSaveDraft,
|
||||
handleSubmit,
|
||||
saveLoading
|
||||
|
||||
@@ -245,7 +245,7 @@
|
||||
</el-table-column>
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column label="报价单号" align="center" prop="quoteNo" min-width="150" show-overflow-tooltip />
|
||||
<el-table-column label="报价主题" prop="quoteTitle" show-overflow-tooltip min-width="200" align="center" header-align="center">
|
||||
<el-table-column label="报价主题" prop="quoteTitle" show-overflow-tooltip min-width="260" align="center" header-align="center">
|
||||
<template #default="scope">
|
||||
<el-link type="primary" @click="handleView(scope.row)">{{ scope.row.quoteTitle }}</el-link>
|
||||
</template>
|
||||
@@ -459,7 +459,7 @@
|
||||
选择审批人<span class="form-label-tip">可选择多个审批人,按顺序依次审批</span>
|
||||
</template>
|
||||
<el-select v-model="submitForm.approverIds" multiple placeholder="请选择审批人" style="width: 100%">
|
||||
<el-option v-for="user in userList" :key="user.userId" :label="`${user.nickName}(${user.userName})`" :value="user.userId" />
|
||||
<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="备注说明" prop="remark" class="form-col-span-2">
|
||||
@@ -985,7 +985,41 @@ const handleSaveColumnSetting = () => {
|
||||
}
|
||||
};
|
||||
|
||||
// 查询参数
|
||||
type QuoteViewName = 'my' | 'all' | 'submitted' | 'accepted'
|
||||
|
||||
interface TabFilterState {
|
||||
queryParams: QuoteQuery
|
||||
dateRange: string[]
|
||||
quickSearch: string
|
||||
activeDateShortcut: 'all' | 'today' | 'tomorrow' | 'yesterday' | 'week'
|
||||
}
|
||||
|
||||
const createDefaultTabFilter = (): TabFilterState => ({
|
||||
queryParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
keyword: undefined,
|
||||
quoteNo: undefined,
|
||||
quoteTitle: undefined,
|
||||
customerName: undefined,
|
||||
quoteType: undefined,
|
||||
status: undefined,
|
||||
quoteDateBegin: undefined,
|
||||
quoteDateEnd: undefined
|
||||
},
|
||||
dateRange: [],
|
||||
quickSearch: '',
|
||||
activeDateShortcut: 'all'
|
||||
})
|
||||
|
||||
const tabFilterMap = reactive<Record<QuoteViewName, TabFilterState>>({
|
||||
my: createDefaultTabFilter(),
|
||||
all: createDefaultTabFilter(),
|
||||
submitted: createDefaultTabFilter(),
|
||||
accepted: createDefaultTabFilter()
|
||||
})
|
||||
|
||||
// 查询参数(当前 tab 的检索条件)
|
||||
const queryParams = ref<QuoteQuery>({
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
@@ -1019,7 +1053,84 @@ const quickSearch = ref('');
|
||||
const activeDateShortcut = ref<'all' | 'today' | 'tomorrow' | 'yesterday' | 'week'>('all');
|
||||
|
||||
// 视图切换
|
||||
const activeView = ref('my');
|
||||
const activeView = ref<QuoteViewName>('my');
|
||||
const previousView = ref<QuoteViewName>('my');
|
||||
|
||||
/** 保存当前 tab 的检索条件(仅用户可见筛选项,不含视图隐式参数) */
|
||||
const saveTabFilter = (view: QuoteViewName) => {
|
||||
tabFilterMap[view] = {
|
||||
queryParams: {
|
||||
pageNum: queryParams.value.pageNum,
|
||||
pageSize: queryParams.value.pageSize,
|
||||
keyword: queryParams.value.keyword,
|
||||
quoteNo: queryParams.value.quoteNo,
|
||||
quoteTitle: queryParams.value.quoteTitle,
|
||||
customerName: queryParams.value.customerName,
|
||||
quoteType: queryParams.value.quoteType,
|
||||
status: queryParams.value.status,
|
||||
quoteDateBegin: queryParams.value.quoteDateBegin,
|
||||
quoteDateEnd: queryParams.value.quoteDateEnd
|
||||
},
|
||||
dateRange: [...dateRange.value],
|
||||
quickSearch: quickSearch.value,
|
||||
activeDateShortcut: activeDateShortcut.value
|
||||
}
|
||||
}
|
||||
|
||||
/** 恢复目标 tab 的检索条件 */
|
||||
const restoreTabFilter = (view: QuoteViewName) => {
|
||||
const saved = tabFilterMap[view]
|
||||
queryParams.value = { ...saved.queryParams }
|
||||
dateRange.value = [...saved.dateRange]
|
||||
quickSearch.value = saved.quickSearch
|
||||
activeDateShortcut.value = saved.activeDateShortcut
|
||||
}
|
||||
|
||||
/** 组装列表/导出请求参数(视图隐式条件不污染 UI 绑定的 queryParams) */
|
||||
const buildListQueryParams = (): QuoteQuery => {
|
||||
const params: QuoteQuery = { ...queryParams.value }
|
||||
|
||||
if (dateRange.value && dateRange.value.length === 2) {
|
||||
params.quoteDateBegin = dateRange.value[0]
|
||||
params.quoteDateEnd = dateRange.value[1]
|
||||
} else {
|
||||
params.quoteDateBegin = undefined
|
||||
params.quoteDateEnd = undefined
|
||||
}
|
||||
|
||||
const selectedStatus = params.status
|
||||
|
||||
if (!selectedStatus) {
|
||||
params.excludeStatus = 'invalid'
|
||||
} else {
|
||||
params.excludeStatus = undefined
|
||||
}
|
||||
|
||||
if (activeView.value === 'my') {
|
||||
params.ownerUserId = resolveCurrentUserId() as unknown as number
|
||||
params.status = selectedStatus
|
||||
params.approvedByUserId = undefined
|
||||
params.pendingApprovalUserId = undefined
|
||||
} else if (activeView.value === 'accepted') {
|
||||
params.ownerUserId = undefined
|
||||
params.status = selectedStatus
|
||||
params.approvedByUserId = resolveCurrentUserId() as unknown as number
|
||||
params.pendingApprovalUserId = undefined
|
||||
} else if (activeView.value === 'submitted') {
|
||||
// 待审批:仅展示当前轮到本人审批的报价单
|
||||
params.ownerUserId = undefined
|
||||
params.status = selectedStatus || 'submitted'
|
||||
params.approvedByUserId = undefined
|
||||
params.pendingApprovalUserId = resolveCurrentUserId() as unknown as number
|
||||
} else {
|
||||
params.ownerUserId = undefined
|
||||
params.status = selectedStatus
|
||||
params.approvedByUserId = undefined
|
||||
params.pendingApprovalUserId = undefined
|
||||
}
|
||||
|
||||
return params
|
||||
}
|
||||
|
||||
// 提交审批对话框
|
||||
const submitDialog = reactive({
|
||||
@@ -1116,48 +1227,7 @@ const approvalFormRef = ref<FormInstance>();
|
||||
const getList = async () => {
|
||||
loading.value = true;
|
||||
try {
|
||||
// 处理日期范围
|
||||
if (dateRange.value && dateRange.value.length === 2) {
|
||||
queryParams.value.quoteDateBegin = dateRange.value[0];
|
||||
queryParams.value.quoteDateEnd = dateRange.value[1];
|
||||
} else {
|
||||
queryParams.value.quoteDateBegin = undefined;
|
||||
queryParams.value.quoteDateEnd = undefined;
|
||||
}
|
||||
|
||||
const selectedStatus = queryParams.value.status;
|
||||
|
||||
// 默认排除已作废的记录,除非用户显式选择了状态
|
||||
if (!selectedStatus) {
|
||||
queryParams.value.excludeStatus = 'invalid';
|
||||
} else {
|
||||
queryParams.value.excludeStatus = undefined;
|
||||
}
|
||||
|
||||
// 根据视图设置状态过滤
|
||||
if (activeView.value === 'my') {
|
||||
// 只查询当前用户负责的报价单
|
||||
queryParams.value.ownerUserId = resolveCurrentUserId() as unknown as number;
|
||||
queryParams.value.status = selectedStatus;
|
||||
queryParams.value.approvedByUserId = undefined;
|
||||
} else if (activeView.value === 'accepted') {
|
||||
// 查询当前用户已审批过的报价单(包括审批通过和审批拒绝)
|
||||
queryParams.value.ownerUserId = undefined;
|
||||
queryParams.value.status = selectedStatus;
|
||||
queryParams.value.approvedByUserId = resolveCurrentUserId() as unknown as number;
|
||||
} else if (activeView.value === 'submitted') {
|
||||
// 待审批视图:默认submitted,若用户选择状态则按用户选择
|
||||
queryParams.value.ownerUserId = undefined;
|
||||
queryParams.value.status = selectedStatus || activeView.value;
|
||||
queryParams.value.approvedByUserId = undefined;
|
||||
} else {
|
||||
// 查看全部报价单,清空视图相关限制
|
||||
queryParams.value.ownerUserId = undefined;
|
||||
queryParams.value.status = selectedStatus;
|
||||
queryParams.value.approvedByUserId = undefined;
|
||||
}
|
||||
|
||||
const res = await listQuote(queryParams.value);
|
||||
const res = await listQuote(buildListQueryParams());
|
||||
quoteList.value = res.rows;
|
||||
total.value = res.total;
|
||||
} finally {
|
||||
@@ -1239,8 +1309,14 @@ const handleDateShortcut = (type: 'all' | 'today' | 'tomorrow' | 'yesterday' | '
|
||||
|
||||
/** 视图切换 */
|
||||
const handleViewChange = () => {
|
||||
queryParams.value.pageNum = 1;
|
||||
getList();
|
||||
const newView = activeView.value
|
||||
if (previousView.value !== newView) {
|
||||
saveTabFilter(previousView.value)
|
||||
restoreTabFilter(newView)
|
||||
previousView.value = newView
|
||||
}
|
||||
queryParams.value.pageNum = 1
|
||||
getList()
|
||||
};
|
||||
|
||||
/** 多选框选中数据 */
|
||||
@@ -1287,17 +1363,13 @@ const handleAdd = () => {
|
||||
};
|
||||
|
||||
/** 复制新增按钮操作 */
|
||||
const handleCopyAdd = async (row?: QuoteVO) => {
|
||||
const handleCopyAdd = (row?: QuoteVO) => {
|
||||
if (!row && ids.value.length !== 1) {
|
||||
$modal.msgWarning('请选择一条数据进行复制新增');
|
||||
return;
|
||||
}
|
||||
const id = row?.id || ids.value[0];
|
||||
// 跳转到表单页面,并传递copyId参数
|
||||
router.push({
|
||||
path: '/crm/quote/form',
|
||||
query: { copyId: id }
|
||||
});
|
||||
quoteFormDialogRef.value?.openCopy(id);
|
||||
};
|
||||
|
||||
/** 修改按钮操作 */
|
||||
@@ -1369,7 +1441,7 @@ const handleQuickSearchClear = () => {
|
||||
const handleExport = async () => {
|
||||
exportLoading.value = true;
|
||||
try {
|
||||
const res = await exportQuote(queryParams.value)
|
||||
const res = await exportQuote(buildListQueryParams())
|
||||
const blob =
|
||||
res instanceof Blob
|
||||
? res
|
||||
@@ -1394,6 +1466,13 @@ const handleStatistics = () => {
|
||||
router.push('/crm/quote/statistics');
|
||||
};
|
||||
|
||||
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 {
|
||||
@@ -1401,8 +1480,8 @@ const loadUserList = async () => {
|
||||
const options = (res as any)?.data ?? res ?? [];
|
||||
userList.value = (Array.isArray(options) ? options : []).map((item: any) => ({
|
||||
userId: item.value ?? item.userId ?? item.id,
|
||||
nickName: item.label ?? item.nickName ?? item.userName ?? '',
|
||||
userName: item.userNo ?? item.userName ?? '',
|
||||
nickName: item.nickName ?? item.label ?? item.userName ?? '',
|
||||
userName: item.userNo ?? item.user_no ?? item.userName ?? '',
|
||||
deptName: item.deptName ?? ''
|
||||
}));
|
||||
} catch (error) {
|
||||
@@ -1504,10 +1583,7 @@ const handleCopyLink = async () => {
|
||||
|
||||
/** 复制报价单 */
|
||||
const handleCopy = (row: QuoteVO) => {
|
||||
router.push({
|
||||
path: '/crm/quote/form',
|
||||
query: { copyId: row.id }
|
||||
});
|
||||
quoteFormDialogRef.value?.openCopy(row.id);
|
||||
};
|
||||
|
||||
/** 查看版本历史 */
|
||||
@@ -1677,94 +1753,189 @@ const getExpireDays = (expireDate: string): number => {
|
||||
return Math.ceil(diffTime / (1000 * 3600 * 24));
|
||||
};
|
||||
|
||||
const TEMPLATE_SUPPLIER_MARKER = /<!--\s*quote-template-supplier:([A-Z]+)\s*-->/
|
||||
const TEMPLATE_DYNAMIC_PRODUCTS_PATTERN =
|
||||
/<!--\s*quote-dynamic-products-start\s*-->[\s\S]*?<!--\s*quote-dynamic-products-end\s*-->/
|
||||
|
||||
/** 从供方名称推断编码(与合同模块一致,供 API 未返回 supplierCode 时兜底) */
|
||||
const inferSupplierCodeFromName = (name?: string): string => {
|
||||
if (!name) return 'SX';
|
||||
if (name.includes('云栋') || name.includes('安徽云栋化工有限公司')) return 'YD';
|
||||
if (name.includes('山峡') || name.includes('安庆市山峡')) return 'SX';
|
||||
return 'SX';
|
||||
};
|
||||
|
||||
const resolveSupplierCode = (quote: QuoteVO, supplierInfo?: SupplierInfoVO): string => {
|
||||
const name = supplierInfo?.supplierName || quote.supplierName || '';
|
||||
return (supplierInfo?.supplierCode || quote.supplierCode || inferSupplierCodeFromName(name) || 'SX').trim();
|
||||
};
|
||||
|
||||
const extractTemplateSupplierCode = (html: string): string | null => {
|
||||
const match = html.match(TEMPLATE_SUPPLIER_MARKER);
|
||||
return match?.[1] ?? null;
|
||||
};
|
||||
|
||||
/** 已保存模板是否与当前报价主体不一致(供方变更时需整页重新生成) */
|
||||
const isStaleQuoteTemplate = (saved: string, expectedCode: string, expectedSupplyName: string): boolean => {
|
||||
if (!saved?.trim()) return false;
|
||||
const markedCode = extractTemplateSupplierCode(saved);
|
||||
if (markedCode) return markedCode !== expectedCode;
|
||||
if (expectedCode !== 'SX' && (saved.includes('安庆市山峡化工有限公司') || saved.includes('山峡销售报价单') || saved.includes('山峡采购报价单'))) {
|
||||
return true;
|
||||
}
|
||||
if (expectedSupplyName && saved.includes('安庆市山峡化工有限公司') && expectedSupplyName.includes('云栋')) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
const formatQuoteTemplateNumber = (value: any, decimals: number = 2): string => {
|
||||
const num = parseFloat(value || 0);
|
||||
return isNaN(num) ? '0.00' : num.toFixed(decimals);
|
||||
};
|
||||
|
||||
const getQuoteProductUnitLabel = (dictValue: string): string => {
|
||||
if (!dictValue) return '';
|
||||
const dict = dictStore.getOptions('crm_product_unit').find((item) => item.value === dictValue);
|
||||
return dict?.label || dictValue;
|
||||
};
|
||||
|
||||
const calcQuoteProductTotal = (quote: QuoteVO): number =>
|
||||
quote.productList?.reduce((sum, item) => {
|
||||
const subtotal = parseFloat(String(item.subtotal || 0));
|
||||
return sum + (isNaN(subtotal) ? 0 : subtotal);
|
||||
}, 0) || 0;
|
||||
|
||||
/** 将数字转换为人民币大写(适用于展示合计金额) */
|
||||
const numberToRMBUpper = (n: number | string): string => {
|
||||
const num = Number(n) || 0;
|
||||
if (num === 0) return '零元整';
|
||||
const digit = ['零', '壹', '贰', '叁', '肆', '伍', '陆', '柒', '捌', '玖'];
|
||||
const unitMajor = ['', '万', '亿'];
|
||||
const unitMinor = ['', '拾', '佰', '仟'];
|
||||
const head = num < 0 ? '负' : '';
|
||||
const money = Math.abs(Math.round(num * 100));
|
||||
const integer = Math.floor(money / 100);
|
||||
const dec = money % 100;
|
||||
|
||||
let s = '';
|
||||
if (integer > 0) {
|
||||
let intStr = '';
|
||||
let unitPos = 0;
|
||||
let temp = integer;
|
||||
while (temp > 0) {
|
||||
let section = temp % 10000;
|
||||
let sectionStr = '';
|
||||
let pos = 0;
|
||||
while (section > 0 && pos < 4) {
|
||||
const v = section % 10;
|
||||
if (v !== 0) {
|
||||
sectionStr = digit[v] + (pos ? unitMinor[pos] : '') + sectionStr;
|
||||
} else if (sectionStr && !sectionStr.startsWith('零')) {
|
||||
sectionStr = '零' + sectionStr;
|
||||
}
|
||||
section = Math.floor(section / 10);
|
||||
pos++;
|
||||
}
|
||||
if (sectionStr) {
|
||||
const major = unitMajor[unitPos] || '';
|
||||
intStr = sectionStr + major + intStr;
|
||||
}
|
||||
temp = Math.floor(temp / 10000);
|
||||
unitPos++;
|
||||
}
|
||||
s += intStr.replace(/零+/g, '零').replace(/零$/, '');
|
||||
s += '元';
|
||||
} else {
|
||||
s += '零元';
|
||||
}
|
||||
|
||||
if (dec === 0) {
|
||||
s += '整';
|
||||
} else {
|
||||
const jiao = Math.floor(dec / 10);
|
||||
const fen = dec % 10;
|
||||
if (jiao > 0) s += digit[jiao] + '角';
|
||||
if (fen > 0) s += digit[fen] + '分';
|
||||
}
|
||||
|
||||
return head + s;
|
||||
};
|
||||
|
||||
const DEFAULT_QUOTE_TABLE_REMARK_ROW = `<tr>
|
||||
<td colspan="10" style="padding: 8px; border: 1px solid #000; background-color: #f9f9f9; text-align: center; font-size: 13px;"> </td>
|
||||
</tr>`;
|
||||
|
||||
/** 生成可替换的产品明细区块(产品行 + 合计行,每次从数据库数据渲染) */
|
||||
const buildQuoteDynamicProductSection = (quote: QuoteVO): string => {
|
||||
const productRows =
|
||||
quote.productList
|
||||
?.map(
|
||||
(product, index) => `
|
||||
<tr>
|
||||
<td style="padding: 8px; border: 1px solid #000; text-align: center;">${index + 1}</td>
|
||||
<td style="padding: 8px; border: 1px solid #000;">${product.productName || ''}</td>
|
||||
<td style="padding: 8px; border: 1px solid #000; text-align: center;">${product.model || ''}</td>
|
||||
<td style="padding: 8px; border: 1px solid #000; text-align: center;">${getQuoteProductUnitLabel(product.unit || '')}</td>
|
||||
<td style="padding: 8px; border: 1px solid #000; text-align: center;">${formatQuoteTemplateNumber(product.quantity, 4)}</td>
|
||||
<td style="padding: 8px; border: 1px solid #000; text-align: right;">${formatQuoteTemplateNumber(product.price)}</td>
|
||||
<td style="padding: 8px; border: 1px solid #000; text-align: right;">${formatQuoteTemplateNumber(product.taxAmount)}</td>
|
||||
<td style="padding: 8px; border: 1px solid #000; text-align: right;">${formatQuoteTemplateNumber(product.subtotal)}</td>
|
||||
<td style="padding: 8px; border: 1px solid #000; text-align: center;">${product.packageSpec || ''}</td>
|
||||
<td style="padding: 8px; border: 1px solid #000; text-align: center;">${product.deliveryMethod || '自提'}</td>
|
||||
</tr>
|
||||
`
|
||||
)
|
||||
.join('') || '<tr><td colspan="10" style="padding: 8px; border: 1px solid #000; text-align: center;">暂无产品信息</td></tr>';
|
||||
|
||||
const productTotal = calcQuoteProductTotal(quote);
|
||||
const totalRow = `<!-- 合计行 -->
|
||||
<tr>
|
||||
<td colspan="2" style="padding: 8px; border: 1px solid #000; background-color: #fff; text-align: center;"><strong>合计(元):</strong></td>
|
||||
<td colspan="8" style="padding: 8px; border: 1px solid #000; text-align: center; font-size: 16px;">
|
||||
${numberToRMBUpper(productTotal)}(¥${formatQuoteTemplateNumber(productTotal)})
|
||||
</td>
|
||||
</tr>`;
|
||||
|
||||
return `<!-- quote-dynamic-products-start -->
|
||||
${productRows}
|
||||
${totalRow}
|
||||
<!-- quote-dynamic-products-end -->`;
|
||||
};
|
||||
|
||||
/** 将已保存模板中的产品明细区块替换为当前数据库产品数据 */
|
||||
const applyQuoteProductDataToTemplate = (
|
||||
savedTemplate: string,
|
||||
quote: QuoteVO,
|
||||
supplierInfo?: SupplierInfoVO
|
||||
): string => {
|
||||
const dynamicSection = buildQuoteDynamicProductSection(quote);
|
||||
if (TEMPLATE_DYNAMIC_PRODUCTS_PATTERN.test(savedTemplate)) {
|
||||
return savedTemplate.replace(TEMPLATE_DYNAMIC_PRODUCTS_PATTERN, dynamicSection);
|
||||
}
|
||||
|
||||
if (!/<tbody[\s\S]*?<\/tbody>/i.test(savedTemplate)) {
|
||||
return generateQuoteTemplate(quote, supplierInfo);
|
||||
}
|
||||
|
||||
return savedTemplate.replace(/<tbody>([\s\S]*?)<\/tbody>/i, (_match, body: string) => {
|
||||
const remarkRow =
|
||||
body.match(/<tr>[\s\S]*?colspan=["']10["'][\s\S]*?<\/tr>/i)?.[0] || DEFAULT_QUOTE_TABLE_REMARK_ROW;
|
||||
return `<tbody>
|
||||
${dynamicSection}
|
||||
<!-- 备注行 -->
|
||||
${remarkRow}
|
||||
</tbody>`;
|
||||
});
|
||||
};
|
||||
|
||||
/** 生成报价单HTML模版 */
|
||||
const generateQuoteTemplate = (quote: QuoteVO, supplierInfo?: SupplierInfoVO): string => {
|
||||
// 辅助函数:安全地将值转换为数字并格式化
|
||||
const formatNumber = (value: any, decimals: number = 2): string => {
|
||||
const num = parseFloat(value || 0);
|
||||
return isNaN(num) ? '0.00' : num.toFixed(decimals);
|
||||
};
|
||||
|
||||
// 字典值转换为标签
|
||||
const getDictLabel = (dictValue: string): string => {
|
||||
if (!dictValue) return '';
|
||||
const dict = dictStore.getOptions('crm_product_unit').find((item) => item.value === dictValue);
|
||||
return dict?.label || dictValue;
|
||||
};
|
||||
|
||||
// 辅助函数:在每个汉字之间添加空格
|
||||
const addSpaceBetweenChars = (str: string): string => {
|
||||
if (!str) return '';
|
||||
return str.split('').join(' ');
|
||||
};
|
||||
|
||||
// 辅助函数:将数字转换为人民币大写(适用于展示合计金额)
|
||||
const numberToRMBUpper = (n: number | string): string => {
|
||||
const num = Number(n) || 0;
|
||||
if (num === 0) return '零元整';
|
||||
const digit = ['零', '壹', '贰', '叁', '肆', '伍', '陆', '柒', '捌', '玖'];
|
||||
const unitMajor = ['', '万', '亿'];
|
||||
const unitMinor = ['', '拾', '佰', '仟'];
|
||||
const head = num < 0 ? '负' : '';
|
||||
const money = Math.abs(Math.round(num * 100));
|
||||
const integer = Math.floor(money / 100);
|
||||
const dec = money % 100;
|
||||
|
||||
let s = '';
|
||||
// integer part
|
||||
if (integer > 0) {
|
||||
let intStr = '';
|
||||
let unitPos = 0;
|
||||
let temp = integer;
|
||||
while (temp > 0) {
|
||||
let section = temp % 10000;
|
||||
let sectionStr = '';
|
||||
let pos = 0;
|
||||
// iterate only while there are digits in this section to avoid leading zeros
|
||||
while (section > 0 && pos < 4) {
|
||||
const v = section % 10;
|
||||
if (v !== 0) {
|
||||
sectionStr = digit[v] + (pos ? unitMinor[pos] : '') + sectionStr;
|
||||
} else if (sectionStr && !sectionStr.startsWith('零')) {
|
||||
sectionStr = '零' + sectionStr;
|
||||
}
|
||||
section = Math.floor(section / 10);
|
||||
pos++;
|
||||
}
|
||||
if (sectionStr) {
|
||||
const major = unitMajor[unitPos] || '';
|
||||
intStr = sectionStr + major + intStr;
|
||||
}
|
||||
temp = Math.floor(temp / 10000);
|
||||
unitPos++;
|
||||
}
|
||||
s += intStr.replace(/零+/g, '零').replace(/零$/, '');
|
||||
s += '元';
|
||||
} else {
|
||||
s += '零元';
|
||||
}
|
||||
|
||||
// decimal part
|
||||
if (dec === 0) {
|
||||
s += '整';
|
||||
} else {
|
||||
const jiao = Math.floor(dec / 10);
|
||||
const fen = dec % 10;
|
||||
if (jiao > 0) s += digit[jiao] + '角';
|
||||
if (fen > 0) s += digit[fen] + '分';
|
||||
}
|
||||
|
||||
return head + s;
|
||||
};
|
||||
|
||||
// 计算产品总金额
|
||||
const productTotal =
|
||||
quote.productList?.reduce((sum, item) => {
|
||||
const subtotal = parseFloat(String(item.subtotal || 0));
|
||||
return sum + (isNaN(subtotal) ? 0 : subtotal);
|
||||
}, 0) || 0;
|
||||
|
||||
// 格式化日期(从创建时间获取日期)
|
||||
const formatDate = (dateStr: string): string => {
|
||||
if (!dateStr) return '';
|
||||
const date = new Date(dateStr);
|
||||
@@ -1774,9 +1945,7 @@ const generateQuoteTemplate = (quote: QuoteVO, supplierInfo?: SupplierInfoVO): s
|
||||
return `${year}/${month}/${day}`;
|
||||
};
|
||||
|
||||
// 获取供应商编码,默认为SX
|
||||
const supplierCode = supplierInfo?.supplierCode || quote.supplierCode || 'SX';
|
||||
// 获取供应商简称和名称
|
||||
const supplierCode = resolveSupplierCode(quote, supplierInfo);
|
||||
const supplierShortName = supplierInfo?.shortName || quote.supplierShortName || '';
|
||||
const supplierName = supplierInfo?.supplierName || quote.supplierName || '安庆市山峡化工有限公司';
|
||||
|
||||
@@ -1796,36 +1965,14 @@ const generateQuoteTemplate = (quote: QuoteVO, supplierInfo?: SupplierInfoVO): s
|
||||
const supplyContactDisplayName = addSpaceBetweenChars(isPurchaseQuote ? customerContactName : supplierContactName);
|
||||
const supplyContactPhone = isPurchaseQuote ? customerContactPhone : supplierContactPhone;
|
||||
|
||||
// 根据供应商编码决定是否显示Logo和背景图片
|
||||
const showLogo = supplierCode === 'SX';
|
||||
const brandName = showLogo ? '山峡' : supplierShortName || supplierName || '山峡';
|
||||
const quoteTitle = `${brandName}${quoteTypeLabel}报价单`;
|
||||
// 根据供应商编码选择印章图片
|
||||
const sealImg = supplierCode === 'SX' ? yzImg : supplierCode === 'YD' ? ydImg : null;
|
||||
const dynamicProductSection = buildQuoteDynamicProductSection(quote);
|
||||
|
||||
// 构建产品明细表格行
|
||||
const productRows =
|
||||
quote.productList
|
||||
?.map(
|
||||
(product, index) => `
|
||||
<tr>
|
||||
<td style="padding: 8px; border: 1px solid #000; text-align: center;">${index + 1}</td>
|
||||
<td style="padding: 8px; border: 1px solid #000;">${product.productName || ''}</td>
|
||||
<td style="padding: 8px; border: 1px solid #000; text-align: center;">${product.model || ''}</td>
|
||||
<td style="padding: 8px; border: 1px solid #000; text-align: center;">${getDictLabel(product.unit)}</td>
|
||||
<td style="padding: 8px; border: 1px solid #000; text-align: center;">${formatNumber(product.quantity, 4)}</td>
|
||||
<td style="padding: 8px; border: 1px solid #000; text-align: right;">${formatNumber(product.price)}</td>
|
||||
<td style="padding: 8px; border: 1px solid #000; text-align: right;">${formatNumber(product.taxAmount)}</td>
|
||||
<td style="padding: 8px; border: 1px solid #000; text-align: right;">${formatNumber(product.subtotal)}</td>
|
||||
<td style="padding: 8px; border: 1px solid #000; text-align: center;">${product.packageSpec || ''}</td>
|
||||
<td style="padding: 8px; border: 1px solid #000; text-align: center;">${product.deliveryMethod || '自提'}</td>
|
||||
</tr>
|
||||
`
|
||||
)
|
||||
.join('') || '<tr><td colspan="10" style="padding: 8px; border: 1px solid #000; text-align: center;">暂无产品信息</td></tr>';
|
||||
|
||||
// 注意:水印已在TinyMCE编辑器中统一设置,这里无需重复添加
|
||||
return `
|
||||
<!-- quote-template-supplier:${supplierCode} -->
|
||||
<div style="max-width: 794px; margin: 0 auto; padding: 20px; font-family: Arial, '微软雅黑', sans-serif; font-size: 13px;">
|
||||
${
|
||||
showLogo
|
||||
@@ -1885,18 +2032,9 @@ const generateQuoteTemplate = (quote: QuoteVO, supplierInfo?: SupplierInfoVO): s
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
${productRows}
|
||||
${dynamicProductSection}
|
||||
<!-- 备注行 -->
|
||||
<tr>
|
||||
<td colspan="10" style="padding: 8px; border: 1px solid #000; background-color: #f9f9f9; text-align: center; font-size: 13px;"> </td>
|
||||
</tr>
|
||||
<!-- 合计行 -->
|
||||
<tr>
|
||||
<td colspan="2" style="padding: 8px; border: 1px solid #000; background-color: #fff; text-align: center;"><strong>合计(元):</strong></td>
|
||||
<td colspan="8" style="padding: 8px; border: 1px solid #000; text-align: center; font-size: 16px;">
|
||||
${numberToRMBUpper(productTotal)}(¥${formatNumber(productTotal)})
|
||||
</td>
|
||||
</tr>
|
||||
${DEFAULT_QUOTE_TABLE_REMARK_ROW}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
@@ -1965,23 +2103,32 @@ const handleGenerateQuote = async (row?: QuoteVO) => {
|
||||
|
||||
console.log('报价单详情数据:', quoteDetail);
|
||||
|
||||
// 获取供应商详细信息
|
||||
// 获取供应商详细信息(详情接口已带 supplierCode,此处再拉一次供方主数据兜底)
|
||||
let supplierInfo: SupplierInfoVO | undefined = undefined;
|
||||
if (quoteDetail.supplierId) {
|
||||
try {
|
||||
const supplierRes = await getSupplierInfo(quoteDetail.supplierId);
|
||||
supplierInfo = supplierRes.data;
|
||||
console.log('供应商信息:', supplierInfo);
|
||||
// 设置当前供应商编码,用于控制TinyMCE编辑器的背景图片和Logo显示
|
||||
currentSupplierCode.value = supplierInfo?.supplierCode || 'SX';
|
||||
} catch (error) {
|
||||
console.warn('获取供应商信息失败:', error);
|
||||
currentSupplierCode.value = 'SX'; // 默认值
|
||||
console.warn('获取供应商信息失败,将使用报价单详情中的供方字段:', error);
|
||||
}
|
||||
} else {
|
||||
currentSupplierCode.value = 'SX'; // 默认值
|
||||
}
|
||||
|
||||
if (supplierInfo) {
|
||||
if (supplierInfo.supplierCode) quoteDetail.supplierCode = supplierInfo.supplierCode;
|
||||
if (supplierInfo.shortName) quoteDetail.supplierShortName = supplierInfo.shortName;
|
||||
if (supplierInfo.supplierName) quoteDetail.supplierName = supplierInfo.supplierName;
|
||||
}
|
||||
|
||||
const supplierCode = resolveSupplierCode(quoteDetail, supplierInfo);
|
||||
currentSupplierCode.value = supplierCode;
|
||||
|
||||
const quoteType = (quoteDetail.quoteType as string) || 'sales';
|
||||
const isPurchaseQuote = quoteType === 'purchase';
|
||||
const supplierName = supplierInfo?.supplierName || quoteDetail.supplierName || '';
|
||||
const expectedSupplyName = isPurchaseQuote ? quoteDetail.customerName || '' : supplierName;
|
||||
|
||||
// 先尝试从数据库获取已保存的模板
|
||||
let htmlContent = '';
|
||||
try {
|
||||
@@ -1989,13 +2136,16 @@ const handleGenerateQuote = async (row?: QuoteVO) => {
|
||||
const templateRes = await getTemplate(id);
|
||||
console.log('获取模板响应:', templateRes);
|
||||
|
||||
if (templateRes.data && templateRes.data.trim()) {
|
||||
htmlContent = templateRes.data;
|
||||
console.log('✅ 从数据库加载模板成功,长度:', htmlContent.length);
|
||||
const savedTemplate = templateRes.data?.trim() || '';
|
||||
if (savedTemplate && !isStaleQuoteTemplate(savedTemplate, supplierCode, expectedSupplyName)) {
|
||||
htmlContent = applyQuoteProductDataToTemplate(savedTemplate, quoteDetail, supplierInfo);
|
||||
console.log('✅ 已保存模板加载成功,产品明细已按数据库数据替换');
|
||||
} else {
|
||||
// 如果没有保存的模板,则生成新的HTML内容
|
||||
if (savedTemplate) {
|
||||
console.log('⚠️ 已保存模板与当前报价主体不一致,整页重新生成');
|
||||
}
|
||||
htmlContent = generateQuoteTemplate(quoteDetail, supplierInfo);
|
||||
console.log('❌ 数据库无模板,生成新的HTML内容,长度:', htmlContent.length);
|
||||
console.log('生成新的HTML内容,长度:', htmlContent.length);
|
||||
}
|
||||
} catch (error) {
|
||||
// 如果获取模板失败,则生成新的HTML内容
|
||||
@@ -2334,6 +2484,23 @@ const handleInvalid = async (row?: QuoteVO) => {
|
||||
}
|
||||
};
|
||||
|
||||
watchDebounced(
|
||||
() => ({
|
||||
quoteNo: queryParams.value.quoteNo,
|
||||
quoteTitle: queryParams.value.quoteTitle,
|
||||
customerName: queryParams.value.customerName,
|
||||
quoteType: queryParams.value.quoteType,
|
||||
status: queryParams.value.status,
|
||||
dateRange: dateRange.value,
|
||||
}),
|
||||
() => {
|
||||
queryParams.value.keyword = undefined;
|
||||
queryParams.value.pageNum = 1;
|
||||
getList();
|
||||
},
|
||||
{ debounce: 300, deep: true }
|
||||
);
|
||||
|
||||
onMounted(() => {
|
||||
loadPerms()
|
||||
initColumnSetting();
|
||||
|
||||
Reference in new issue
Block a user