批量更新功能
This commit is contained in:
1 parent
6f106e43af
commit
a26c98b92b
79 files changed
+4529
-724
No files matched your search
@@ -21,6 +21,8 @@
|
||||
<el-tag v-if="row.is_primary === 1" type="danger" size="small" effect="plain" style="margin-left:4px">主要</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="department" label="部门" width="90" show-overflow-tooltip />
|
||||
<el-table-column prop="position" label="职位" width="90" show-overflow-tooltip />
|
||||
<el-table-column prop="gender" label="性别" width="60" align="center">
|
||||
<template #default="{ row }">{{ genderText(row.gender) }}</template>
|
||||
</el-table-column>
|
||||
@@ -31,8 +33,6 @@
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="department" label="部门" width="90" show-overflow-tooltip />
|
||||
<el-table-column prop="position" label="职位" width="90" show-overflow-tooltip />
|
||||
<!-- <el-table-column prop="phone" label="座机" width="110" show-overflow-tooltip /> -->
|
||||
<el-table-column label="手机" min-width="130" show-overflow-tooltip>
|
||||
<template #default="{ row }">{{ formatMobiles(row.mobiles) }}</template>
|
||||
|
||||
@@ -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>
|
||||
@@ -67,6 +67,8 @@
|
||||
<div class="name-cell-wrapper">
|
||||
<span class="name-cell name-link" @click="openDetail(row)">{{ row.supplier_name }}</span>
|
||||
<el-tag v-if="row.is_draft === 1" type="warning" size="small" effect="plain">草稿</el-tag>
|
||||
<!-- 同一家单位可能既是供应商又是客户(已建客户档案) -->
|
||||
<el-tag v-if="row.also_customer" type="warning" size="small" effect="plain">也是客户</el-tag>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
@@ -100,10 +102,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="handleConvertCustomer(row)">转为客户</el-button>
|
||||
<el-button link type="primary" size="small" @click="handleToggleStatus(row)">
|
||||
{{ row.status === '1' ? '禁用' : '启用' }}
|
||||
</el-button>
|
||||
@@ -139,6 +142,10 @@
|
||||
size="560px"
|
||||
>
|
||||
<div v-if="detailData" class="detail-content">
|
||||
<div class="detail-actions">
|
||||
<el-button type="success" size="small" @click="handleConvertCustomer(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.supplier_name }}</el-descriptions-item>
|
||||
<el-descriptions-item label="供应商类型">{{ supplierTypeText(detailData.supplier_type) }}</el-descriptions-item>
|
||||
@@ -205,7 +212,7 @@
|
||||
import { ref, reactive, onMounted } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { Plus, Search, Refresh, Cpu } from '@element-plus/icons-vue'
|
||||
import { getSupplierList, deleteSupplier, toggleSupplierStatus } from '@/api/supplier'
|
||||
import { getSupplierList, deleteSupplier, toggleSupplierStatus, convertSupplierToCustomer } from '@/api/supplier'
|
||||
import SupplierEdit from './components/edit.vue'
|
||||
import ContactBook from '../components/contactBook.vue'
|
||||
import SmartAddCompany from '../components/smartAddCompany.vue'
|
||||
@@ -376,6 +383,35 @@ async function handleDelete(row) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 供应商转客户:把供应商的企业资料与联系人复制一套到客户库。
|
||||
* 同一家单位可能既是供应商又是客户,原供应商记录保留;客户库已有同名企业时只补同步联系人,不重复建档。
|
||||
*/
|
||||
async function handleConvertCustomer(row) {
|
||||
try {
|
||||
await ElMessageBox.confirm(
|
||||
`将供应商「${row.supplier_name}」的企业资料与联系人复制一套到客户库?原供应商记录会保留,可在客户管理中继续完善。`,
|
||||
'转为客户',
|
||||
{ type: 'warning', confirmButtonText: '确认转化' }
|
||||
)
|
||||
} catch (e) {
|
||||
return // 取消
|
||||
}
|
||||
try {
|
||||
const res = await convertSupplierToCustomer(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 supplierTypeText(type) {
|
||||
const map = { '1': '原材料供应商', '2': '设备供应商', '3': '服务供应商', '4': '其他' }
|
||||
return map[type] || type
|
||||
@@ -478,4 +514,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>
|
||||
Reference in new issue
Block a user