批量更新功能

This commit is contained in:
2026-09-14 16:15:44 +08:00
parent 6f106e43af
commit a26c98b92b
79 changed files with 4529 additions and 724 deletions
+50 -2
View File
@@ -68,6 +68,8 @@
<div class="name-cell-wrapper">
<span class="name-cell name-link" @click="openDetail(row)">{{ row.customer_name }}</span>
<el-tag v-if="row.is_draft === 1" type="warning" size="small" effect="plain">草稿</el-tag>
<!-- 同一家单位可能既是客户又是供应商(已建供应商档案) -->
<el-tag v-if="row.also_supplier" type="warning" size="small" effect="plain">也是供应商</el-tag>
</div>
</template>
</el-table-column>
@@ -101,10 +103,11 @@
{{ formatDateTime(row.update_time) }}
</template>
</el-table-column>
<el-table-column label="操作" width="240" align="center" fixed="right">
<el-table-column label="操作" width="300" align="center" fixed="right">
<template #default="{ row }">
<el-button link type="primary" size="small" @click="openContactBook(row)">通讯录</el-button>
<el-button link type="primary" size="small" @click="openEdit(row)">编辑</el-button>
<el-button link type="success" size="small" @click="handleConvertSupplier(row)">转为供应商</el-button>
<el-button link type="primary" size="small" @click="handleToggleStatus(row)">
{{ row.status === '1' ? '禁用' : '启用' }}
</el-button>
@@ -140,6 +143,10 @@
size="560px"
>
<div v-if="detailData" class="detail-content">
<div class="detail-actions">
<el-button type="success" size="small" @click="handleConvertSupplier(detailData)">转为供应商</el-button>
<span class="detail-actions-tip">同一家单位可能既是客户又是供应商,转化后原客户记录保留</span>
</div>
<el-descriptions title="基本信息" :column="2" border size="small" label-width="120px">
<el-descriptions-item label="客户名称" :span="2">{{ detailData.customer_name }}</el-descriptions-item>
<el-descriptions-item label="客户类型">{{ customerTypeText(detailData.customer_type) }}</el-descriptions-item>
@@ -206,7 +213,7 @@
import { ref, reactive, onMounted } from 'vue'
import { ElMessage, ElMessageBox } from 'element-plus'
import { Plus, Search, Refresh, Cpu } from '@element-plus/icons-vue'
import { getCustomerList, deleteCustomer, toggleCustomerStatus } from '@/api/customer'
import { getCustomerList, deleteCustomer, toggleCustomerStatus, convertCustomerToSupplier } from '@/api/customer'
import CustomerEdit from './components/edit.vue'
import ContactBook from '../components/contactBook.vue'
import SmartAddCompany from '../components/smartAddCompany.vue'
@@ -377,6 +384,35 @@ async function handleDelete(row) {
}
}
/**
* 客户转供应商:把客户的企业资料与联系人复制一套到供应商库。
* 同一家单位可能既是客户又是供应商,原客户记录保留;供应商库已有同名企业时只补同步联系人,不重复建档。
*/
async function handleConvertSupplier(row) {
try {
await ElMessageBox.confirm(
`将客户「${row.customer_name}」的企业资料与联系人复制一套到供应商库?原客户记录会保留,可在供应商管理中继续完善。`,
'转为供应商',
{ type: 'warning', confirmButtonText: '确认转化' }
)
} catch (e) {
return // 取消
}
try {
const res = await convertCustomerToSupplier(row.id)
const data = res?.data || {}
const c = data.contacts || {}
ElMessage.success(
data.existed
? `供应商库已有同名企业,已同步联系人(新增 ${c.inserted || 0}、补充 ${c.merged || 0}),未重复建档`
: `已转为供应商,并同步联系人(新增 ${c.inserted || 0})`
)
fetchList()
} catch (e) {
ElMessage.error(e.message || '转化失败')
}
}
function customerTypeText(type) {
const map = { '1': '企业', '2': '政府机构', '3': '国企', '4': '教育机构', '5':'个人' }
return map[type] || type
@@ -479,4 +515,16 @@ function statusTag(status) {
display: flex;
justify-content: flex-end;
}
.detail-actions {
display: flex;
align-items: center;
gap: 10px;
margin-bottom: 16px;
}
.detail-actions-tip {
font-size: 12px;
color: var(--el-text-color-secondary);
}
</style>