feat:【全局】简化 handleStatusChange 类型逻辑的写法!
This commit is contained in:
@@ -89,13 +89,11 @@ async function handleTransform(): Promise<boolean | undefined> {
|
||||
content: '确定将该线索转化为客户吗?',
|
||||
})
|
||||
.then(async () => {
|
||||
const res = await transformClue(clueId.value);
|
||||
if (res) {
|
||||
message.success('转化客户成功');
|
||||
resolve(true);
|
||||
} else {
|
||||
reject(new Error('转化失败'));
|
||||
}
|
||||
// 转化为客户
|
||||
await transformClue(clueId.value);
|
||||
// 提示并返回成功
|
||||
message.success('转化客户成功');
|
||||
resolve(true);
|
||||
})
|
||||
.catch(() => {
|
||||
reject(new Error('取消操作'));
|
||||
|
||||
@@ -107,13 +107,11 @@ function handleLock(lockStatus: boolean): Promise<boolean | undefined> {
|
||||
content: `确定锁定客户【${customer.value.name}】吗?`,
|
||||
})
|
||||
.then(async () => {
|
||||
const res = await lockCustomer(customerId.value, lockStatus);
|
||||
if (res) {
|
||||
message.success(lockStatus ? '锁定客户成功' : '解锁客户成功');
|
||||
resolve(true);
|
||||
} else {
|
||||
reject(new Error(lockStatus ? '锁定客户失败' : '解锁客户失败'));
|
||||
}
|
||||
// 锁定客户
|
||||
await lockCustomer(customerId.value, lockStatus);
|
||||
// 提示并返回成功
|
||||
message.success(lockStatus ? '锁定客户成功' : '解锁客户成功');
|
||||
resolve(true);
|
||||
})
|
||||
.catch(() => {
|
||||
reject(new Error('取消操作'));
|
||||
@@ -128,13 +126,11 @@ function handleReceive(): Promise<boolean | undefined> {
|
||||
content: `确定领取客户【${customer.value.name}】吗?`,
|
||||
})
|
||||
.then(async () => {
|
||||
const res = await receiveCustomer([customerId.value]);
|
||||
if (res) {
|
||||
message.success('领取客户成功');
|
||||
resolve(true);
|
||||
} else {
|
||||
reject(new Error('领取客户失败'));
|
||||
}
|
||||
// 领取客户
|
||||
await receiveCustomer([customerId.value]);
|
||||
// 提示并返回成功
|
||||
message.success('领取客户成功');
|
||||
resolve(true);
|
||||
})
|
||||
.catch(() => {
|
||||
reject(new Error('取消操作'));
|
||||
@@ -154,13 +150,11 @@ function handlePutPool(): Promise<boolean | undefined> {
|
||||
content: `确定将客户【${customer.value.name}】放入公海吗?`,
|
||||
})
|
||||
.then(async () => {
|
||||
const res = await putCustomerPool(customerId.value);
|
||||
if (res) {
|
||||
message.success('放入公海成功');
|
||||
resolve(true);
|
||||
} else {
|
||||
reject(new Error('放入公海失败'));
|
||||
}
|
||||
// 放入公海
|
||||
await putCustomerPool(customerId.value);
|
||||
// 提示并返回成功
|
||||
message.success('放入公海成功');
|
||||
resolve(true);
|
||||
})
|
||||
.catch(() => {
|
||||
reject(new Error('取消操作'));
|
||||
@@ -176,16 +170,11 @@ async function handleUpdateDealStatus(): Promise<boolean | undefined> {
|
||||
content: `确定更新成交状态为【${dealStatus ? '已成交' : '未成交'}】吗?`,
|
||||
})
|
||||
.then(async () => {
|
||||
const res = await updateCustomerDealStatus(
|
||||
customerId.value,
|
||||
dealStatus,
|
||||
);
|
||||
if (res) {
|
||||
message.success('更新成交状态成功');
|
||||
resolve(true);
|
||||
} else {
|
||||
reject(new Error('更新成交状态失败'));
|
||||
}
|
||||
// 更新成交状态
|
||||
await updateCustomerDealStatus(customerId.value, dealStatus);
|
||||
// 提示并返回成功
|
||||
message.success('更新成交状态成功');
|
||||
resolve(true);
|
||||
})
|
||||
.catch(() => {
|
||||
reject(new Error('取消操作'));
|
||||
|
||||
Reference in New Issue
Block a user