|
|
@@ -797,11 +797,29 @@ const findUserName = (id) => {
|
|
|
|
|
|
const loadProjectContacts = () => {
|
|
|
contactLoading.value = true;
|
|
|
- // 按照客户 ID 和项目编号查询(即便 realCustomerId 为空,后端也支持通过 projectNo 进行备注匹配回显)
|
|
|
- listContact({
|
|
|
- customerId: form.value.realCustomerId || form.value.customerId,
|
|
|
- projectNo: form.value.projectNo
|
|
|
- }).then(res => {
|
|
|
+
|
|
|
+ const params = {};
|
|
|
+ // 根据数据库表结构,联系人关联项目的字段是 platform_code,因此这里必须传 platformCode
|
|
|
+ if (form.value.realCustomerId || form.value.customerId) {
|
|
|
+ params.customerId = form.value.realCustomerId || form.value.customerId;
|
|
|
+ }
|
|
|
+ if (form.value.projectNo) {
|
|
|
+ params.platformCode = form.value.projectNo;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 兜底:如果既没有客户ID也没有项目编号,尝试用客户名称
|
|
|
+ if (!params.customerId && !params.platformCode && form.value.customerName) {
|
|
|
+ params.customerName = form.value.customerName;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 必须要有查询条件,避免无条件查询出系统中所有的联系人
|
|
|
+ if (Object.keys(params).length === 0) {
|
|
|
+ contactList.value = [];
|
|
|
+ contactLoading.value = false;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ listContact(params).then(res => {
|
|
|
contactList.value = res.rows || [];
|
|
|
}).finally(() => {
|
|
|
contactLoading.value = false;
|
|
|
@@ -941,8 +959,8 @@ const openAssociateDialog = () => {
|
|
|
}
|
|
|
associateVisible.value = true;
|
|
|
associateLoading.value = true;
|
|
|
- // 根据客户名称查询联系人 (注意:后端参数名为 customName)
|
|
|
- listContact({ customName: form.value.customerName }).then(res => {
|
|
|
+ // 关联客户联系人需要显示系统中所有的联系人供用户选择
|
|
|
+ listContact({}).then(res => {
|
|
|
// 过滤掉已经关联到当前线索的联系人
|
|
|
const currentIds = contactList.value.map(c => c.id);
|
|
|
associateList.value = (res.rows || []).filter(item => !currentIds.includes(item.id));
|
|
|
@@ -966,12 +984,12 @@ const submitAssociate = async () => {
|
|
|
try {
|
|
|
proxy.$modal.loading("正在关联...");
|
|
|
const promises = selectedContacts.value.map(contact => {
|
|
|
- return updateContact({
|
|
|
+ const payload = {
|
|
|
...contact,
|
|
|
customerId: form.value.realCustomerId || form.value.customerId || contact.customerId,
|
|
|
- platformCode: form.value.projectNo || '',
|
|
|
- projectNo: form.value.projectNo || ''
|
|
|
- });
|
|
|
+ platformCode: form.value.projectNo || ''
|
|
|
+ };
|
|
|
+ return updateContact(payload);
|
|
|
});
|
|
|
|
|
|
await Promise.all(promises);
|