|
@@ -20,6 +20,10 @@
|
|
|
placeholder="请选择"
|
|
placeholder="请选择"
|
|
|
style="width: 100%"
|
|
style="width: 100%"
|
|
|
filterable
|
|
filterable
|
|
|
|
|
+ remote
|
|
|
|
|
+ reserve-keyword
|
|
|
|
|
+ :remote-method="remoteLoadCustomers"
|
|
|
|
|
+ :loading="selectLoading"
|
|
|
clearable
|
|
clearable
|
|
|
@change="handleCustomerChange"
|
|
@change="handleCustomerChange"
|
|
|
>
|
|
>
|
|
@@ -51,7 +55,18 @@
|
|
|
</el-col>
|
|
</el-col>
|
|
|
<el-col :span="12">
|
|
<el-col :span="12">
|
|
|
<el-form-item label="业务员:" prop="salesman">
|
|
<el-form-item label="业务员:" prop="salesman">
|
|
|
- <el-select v-model="form.salesman" placeholder="请选择" style="width: 100%" clearable>
|
|
|
|
|
|
|
+ <el-select
|
|
|
|
|
+ v-model="form.salesman"
|
|
|
|
|
+ placeholder="请选择"
|
|
|
|
|
+ style="width: 100%"
|
|
|
|
|
+ filterable
|
|
|
|
|
+ remote
|
|
|
|
|
+ reserve-keyword
|
|
|
|
|
+ :remote-method="remoteLoadStaffs"
|
|
|
|
|
+ :loading="staffLoading"
|
|
|
|
|
+ clearable
|
|
|
|
|
+ @change="handleSalesmanChange"
|
|
|
|
|
+ >
|
|
|
<el-option v-for="item in staffOptions" :key="item.staffId" :label="(item.staffCode ? '(' + item.staffCode + ') ' : '') + item.staffName" :value="item.staffName" />
|
|
<el-option v-for="item in staffOptions" :key="item.staffId" :label="(item.staffCode ? '(' + item.staffCode + ') ' : '') + item.staffName" :value="item.staffName" />
|
|
|
</el-select>
|
|
</el-select>
|
|
|
</el-form-item>
|
|
</el-form-item>
|
|
@@ -65,11 +80,11 @@
|
|
|
placeholder="请选择"
|
|
placeholder="请选择"
|
|
|
style="width: 100%"
|
|
style="width: 100%"
|
|
|
filterable
|
|
filterable
|
|
|
|
|
+ remote
|
|
|
|
|
+ reserve-keyword
|
|
|
|
|
+ :remote-method="remoteLoadContacts"
|
|
|
|
|
+ :loading="contactLoading"
|
|
|
clearable
|
|
clearable
|
|
|
- remote
|
|
|
|
|
- :remote-method="remoteSearchContacts"
|
|
|
|
|
- :loading="contactSearchLoading"
|
|
|
|
|
- @focus="onContactFocus"
|
|
|
|
|
@change="handleContactChange"
|
|
@change="handleContactChange"
|
|
|
>
|
|
>
|
|
|
<el-option v-for="item in contactOptions" :key="item.id" :label="item.label" :value="item.label" />
|
|
<el-option v-for="item in contactOptions" :key="item.id" :label="item.label" :value="item.label" />
|
|
@@ -173,6 +188,8 @@ const router = useRouter();
|
|
|
|
|
|
|
|
const visible = ref(false);
|
|
const visible = ref(false);
|
|
|
const selectLoading = ref(false);
|
|
const selectLoading = ref(false);
|
|
|
|
|
+const staffLoading = ref(false);
|
|
|
|
|
+const contactLoading = ref(false);
|
|
|
const contactSearchLoading = ref(false);
|
|
const contactSearchLoading = ref(false);
|
|
|
const customerOptions = ref([]);
|
|
const customerOptions = ref([]);
|
|
|
const contactOptions = ref([]);
|
|
const contactOptions = ref([]);
|
|
@@ -203,20 +220,48 @@ const form = reactive({
|
|
|
auditStatus: 0
|
|
auditStatus: 0
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
-/** 打开抽屉 */
|
|
|
|
|
-const open = (data = {}) => {
|
|
|
|
|
|
|
+const open = async (data = {}) => {
|
|
|
visible.value = true;
|
|
visible.value = true;
|
|
|
|
|
+
|
|
|
|
|
+ // 识别传入的 data 是客户对象还是其他格式
|
|
|
|
|
+ const initCustomerId = data.customerId ? String(data.customerId) : (data.id ? String(data.id) : undefined);
|
|
|
|
|
+ const initCustomerName = data.customerName || data.customName || data.companyName || '';
|
|
|
|
|
+
|
|
|
Object.assign(form, {
|
|
Object.assign(form, {
|
|
|
- customerName: data.customerName || '',
|
|
|
|
|
- customerId: data.customerId ? String(data.customerId) : undefined,
|
|
|
|
|
- profession: data.profession || '',
|
|
|
|
|
- department: data.department || '',
|
|
|
|
|
- salesman: data.salesman || '',
|
|
|
|
|
- contactPerson: data.contactName || '',
|
|
|
|
|
- personnelNumber: data.contactId ? String(data.contactId) : undefined,
|
|
|
|
|
- phone: data.phone || '',
|
|
|
|
|
- telephone: data.officePhone || ''
|
|
|
|
|
|
|
+ id: undefined,
|
|
|
|
|
+ customerId: initCustomerId,
|
|
|
|
|
+ personnelNumber: undefined,
|
|
|
|
|
+ customerName: initCustomerName,
|
|
|
|
|
+ profession: '',
|
|
|
|
|
+ department: '',
|
|
|
|
|
+ salesman: '',
|
|
|
|
|
+ contactPerson: '',
|
|
|
|
|
+ phone: '',
|
|
|
|
|
+ telephone: '',
|
|
|
|
|
+ concernType: '',
|
|
|
|
|
+ amount: undefined,
|
|
|
|
|
+ requirementDate: undefined,
|
|
|
|
|
+ fileNo: '',
|
|
|
|
|
+ giftDesc: '',
|
|
|
|
|
+ concernArgument: '',
|
|
|
|
|
+ receiptId: '',
|
|
|
|
|
+ platformCode: 'crm',
|
|
|
|
|
+ auditStatus: 0
|
|
|
});
|
|
});
|
|
|
|
|
+
|
|
|
|
|
+ if (initCustomerId) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ const res = await getCustomerInfo(initCustomerId);
|
|
|
|
|
+ const detail = res.data;
|
|
|
|
|
+ if (detail) {
|
|
|
|
|
+ form.profession = detail.industryCategory || '';
|
|
|
|
|
+ if (detail.customerSalesInfoVo) {
|
|
|
|
|
+ form.salesman = detail.customerSalesInfoVo.salesPerson || '';
|
|
|
|
|
+ form.department = detail.customerSalesInfoVo.belongingDepartment || '';
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (error) {}
|
|
|
|
|
+ }
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
defineExpose({ open });
|
|
defineExpose({ open });
|
|
@@ -247,10 +292,10 @@ const rules = reactive({
|
|
|
]
|
|
]
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
-/** 加载客户列表 (500条) */
|
|
|
|
|
|
|
+/** 加载客户列表 (远程搜索) */
|
|
|
const remoteLoadCustomers = (query) => {
|
|
const remoteLoadCustomers = (query) => {
|
|
|
selectLoading.value = true;
|
|
selectLoading.value = true;
|
|
|
- listCustomerInfo({ pageNum: 1, pageSize: 500, isHighSeas: 'all' }).then(res => {
|
|
|
|
|
|
|
+ listCustomerInfo({ pageNum: 1, pageSize: 20, isHighSeas: 'all', customerName: query || undefined }).then(res => {
|
|
|
customerOptions.value = (res.rows || []).map(item => ({
|
|
customerOptions.value = (res.rows || []).map(item => ({
|
|
|
label: item.customerName,
|
|
label: item.customerName,
|
|
|
value: item.customerName,
|
|
value: item.customerName,
|
|
@@ -263,6 +308,29 @@ const remoteLoadCustomers = (query) => {
|
|
|
});
|
|
});
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
+/** 加载业务员 (远程搜索) */
|
|
|
|
|
+const remoteLoadStaffs = (query) => {
|
|
|
|
|
+ staffLoading.value = true;
|
|
|
|
|
+ listComStaff({ pageNum: 1, pageSize: 20, staffName: query || undefined }).then(res => {
|
|
|
|
|
+ staffOptions.value = res.rows || res.data || [];
|
|
|
|
|
+ staffLoading.value = false;
|
|
|
|
|
+ }).catch(() => { staffLoading.value = false; });
|
|
|
|
|
+};
|
|
|
|
|
+
|
|
|
|
|
+/** 加载联系人 (远程搜索) */
|
|
|
|
|
+const remoteLoadContacts = (query) => {
|
|
|
|
|
+ contactLoading.value = true;
|
|
|
|
|
+ listContact({ pageNum: 1, pageSize: 20, contactName: query || undefined }).then(res => {
|
|
|
|
|
+ contactOptions.value = (res.rows || []).map(item => ({
|
|
|
|
|
+ label: item.contactName,
|
|
|
|
|
+ value: item.contactName,
|
|
|
|
|
+ id: item.id,
|
|
|
|
|
+ ...item
|
|
|
|
|
+ }));
|
|
|
|
|
+ contactLoading.value = false;
|
|
|
|
|
+ }).catch(() => { contactLoading.value = false; });
|
|
|
|
|
+};
|
|
|
|
|
+
|
|
|
/** 客户选中处理 */
|
|
/** 客户选中处理 */
|
|
|
const handleCustomerChange = async (val) => {
|
|
const handleCustomerChange = async (val) => {
|
|
|
const customer = customerOptions.value.find(item => item.label === val);
|
|
const customer = customerOptions.value.find(item => item.label === val);
|
|
@@ -283,33 +351,30 @@ const handleCustomerChange = async (val) => {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
} catch (error) {}
|
|
} catch (error) {}
|
|
|
|
|
+
|
|
|
|
|
+ // 不再根据客户ID过滤,保持显示所有的联系人
|
|
|
|
|
+ remoteLoadContacts('');
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // 清空客户时,加载所有联系人
|
|
|
|
|
+ remoteLoadContacts('');
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
-/** 远程搜索联系人 */
|
|
|
|
|
-const remoteSearchContacts = (query) => {
|
|
|
|
|
- contactSearchLoading.value = true;
|
|
|
|
|
- const params = { pageSize: 50 };
|
|
|
|
|
- if (query) params.contactName = query;
|
|
|
|
|
-
|
|
|
|
|
- listContact(params).then(res => {
|
|
|
|
|
- contactOptions.value = (res.rows || []).map(item => ({
|
|
|
|
|
- label: item.contactName,
|
|
|
|
|
- value: item.contactName,
|
|
|
|
|
- id: item.id,
|
|
|
|
|
- ...item
|
|
|
|
|
- }));
|
|
|
|
|
- }).finally(() => {
|
|
|
|
|
- contactSearchLoading.value = false;
|
|
|
|
|
- });
|
|
|
|
|
-};
|
|
|
|
|
-
|
|
|
|
|
-const onContactFocus = () => {
|
|
|
|
|
- if (contactOptions.value.length === 0) remoteSearchContacts('');
|
|
|
|
|
|
|
+const handleSalesmanChange = (val) => {
|
|
|
|
|
+ const staff = staffOptions.value.find(item => item.staffName === val);
|
|
|
|
|
+ if (staff) {
|
|
|
|
|
+ form.department = staff.deptName || staff.departmentName || '';
|
|
|
|
|
+ } else {
|
|
|
|
|
+ form.department = '';
|
|
|
|
|
+ }
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
const handleContactChange = (val) => {
|
|
const handleContactChange = (val) => {
|
|
|
- // 不再自动填充手机号和固定电话,由用户手动维护
|
|
|
|
|
|
|
+ const contact = contactOptions.value.find(item => item.label === val);
|
|
|
|
|
+ if (contact) {
|
|
|
|
|
+ form.phone = contact.phone || '';
|
|
|
|
|
+ form.telephone = contact.officePhone || contact.telephone || '';
|
|
|
|
|
+ }
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
/** 生成单据编号: YYYYMMDD + 4位流水号 */
|
|
/** 生成单据编号: YYYYMMDD + 4位流水号 */
|
|
@@ -350,16 +415,19 @@ function handleClose() {
|
|
|
/** 加载基础选项 */
|
|
/** 加载基础选项 */
|
|
|
const initBaseOptions = () => {
|
|
const initBaseOptions = () => {
|
|
|
listIndustryCategory().then(res => { industryOptions.value = res.data || res.rows || []; });
|
|
listIndustryCategory().then(res => { industryOptions.value = res.data || res.rows || []; });
|
|
|
- listComStaff({ pageSize: 1000 }).then(res => { staffOptions.value = res.rows || res.data || []; });
|
|
|
|
|
deptTreeSelect().then(res => {
|
|
deptTreeSelect().then(res => {
|
|
|
const data = res.data || [];
|
|
const data = res.data || [];
|
|
|
deptOptions.value = proxy.handleTree(data, "id");
|
|
deptOptions.value = proxy.handleTree(data, "id");
|
|
|
});
|
|
});
|
|
|
|
|
+
|
|
|
|
|
+ // 初始加载少量数据,用户可根据输入远程搜索
|
|
|
|
|
+ remoteLoadCustomers('');
|
|
|
|
|
+ remoteLoadStaffs('');
|
|
|
|
|
+ remoteLoadContacts('');
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
onMounted(() => {
|
|
onMounted(() => {
|
|
|
initBaseOptions();
|
|
initBaseOptions();
|
|
|
- remoteLoadCustomers('');
|
|
|
|
|
});
|
|
});
|
|
|
</script>
|
|
</script>
|
|
|
|
|
|