mirror of
https://gitee.com/yudaocode/yudao-ui-admin-vben.git
synced 2025-12-30 10:32:25 +00:00
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('取消操作'));
|
||||
|
||||
@@ -73,6 +73,7 @@ async function handleDefaultStatusChange(
|
||||
.then(async () => {
|
||||
// 更新默认状态
|
||||
await updateAccountDefaultStatus(row.id!, newStatus);
|
||||
// 提示并返回成功
|
||||
message.success(`${text}默认成功`);
|
||||
resolve(true);
|
||||
})
|
||||
|
||||
@@ -71,6 +71,7 @@ async function handleDefaultStatusChange(
|
||||
.then(async () => {
|
||||
// 更新默认状态
|
||||
await updateWarehouseDefaultStatus(row.id!, newStatus);
|
||||
// 提示并返回成功
|
||||
message.success(`${text}默认成功`);
|
||||
resolve(true);
|
||||
})
|
||||
|
||||
@@ -70,17 +70,13 @@ async function handleStatusChange(
|
||||
})
|
||||
.then(async () => {
|
||||
// 更新状态
|
||||
const res = await updateCommentVisible({
|
||||
await updateCommentVisible({
|
||||
id: row.id!,
|
||||
visible: newStatus,
|
||||
});
|
||||
if (res) {
|
||||
// 提示并返回成功
|
||||
message.success(`${text}成功`);
|
||||
resolve(true);
|
||||
} else {
|
||||
reject(new Error($t('ui.actionMessage.operationFailed')));
|
||||
}
|
||||
// 提示并返回成功
|
||||
message.success(`${text}成功`);
|
||||
resolve(true);
|
||||
})
|
||||
.catch(() => {
|
||||
reject(new Error('取消操作'));
|
||||
|
||||
@@ -115,17 +115,13 @@ async function handleStatusChange(
|
||||
})
|
||||
.then(async () => {
|
||||
// 更新状态
|
||||
const res = await updateStatus({
|
||||
await updateStatus({
|
||||
id: row.id!,
|
||||
status: newStatus,
|
||||
});
|
||||
if (res) {
|
||||
// 提示并返回成功
|
||||
message.success(`${text}成功`);
|
||||
resolve(true);
|
||||
} else {
|
||||
reject(new Error($t('ui.actionMessage.operationFailed')));
|
||||
}
|
||||
// 提示并返回成功
|
||||
message.success(`${text}成功`);
|
||||
resolve(true);
|
||||
})
|
||||
.catch(() => {
|
||||
reject(new Error('取消操作'));
|
||||
|
||||
@@ -66,14 +66,10 @@ async function handleStatusChange(
|
||||
})
|
||||
.then(async () => {
|
||||
// 更新优惠券模板状态
|
||||
const res = await updateCouponTemplateStatus(row.id!, newStatus);
|
||||
if (res) {
|
||||
// 提示并返回成功
|
||||
message.success($t('ui.actionMessage.operationSuccess'));
|
||||
resolve(true);
|
||||
} else {
|
||||
reject(new Error('更新失败'));
|
||||
}
|
||||
await updateCouponTemplateStatus(row.id!, newStatus);
|
||||
// 提示并返回成功
|
||||
message.success($t('ui.actionMessage.operationSuccess'));
|
||||
resolve(true);
|
||||
})
|
||||
.catch(() => {
|
||||
reject(new Error('取消操作'));
|
||||
|
||||
@@ -67,14 +67,10 @@ async function handleStatusChange(
|
||||
})
|
||||
.then(async () => {
|
||||
// 更新状态
|
||||
const res = await updateSeckillConfigStatus(row.id, newStatus);
|
||||
if (res) {
|
||||
// 提示并返回成功
|
||||
message.success(`${text}成功`);
|
||||
resolve(true);
|
||||
} else {
|
||||
reject(new Error($t('ui.actionMessage.operationFailed')));
|
||||
}
|
||||
await updateSeckillConfigStatus(row.id, newStatus);
|
||||
// 提示并返回成功
|
||||
message.success(`${text}成功`);
|
||||
resolve(true);
|
||||
})
|
||||
.catch(() => {
|
||||
reject(new Error('取消操作'));
|
||||
|
||||
@@ -94,18 +94,14 @@ async function handleBrokerageEnabledChange(
|
||||
})
|
||||
.then(async () => {
|
||||
// 更新推广资格
|
||||
const res = await updateBrokerageEnabled({
|
||||
await updateBrokerageEnabled({
|
||||
id: row.id!,
|
||||
enabled: newEnabled,
|
||||
});
|
||||
if (res) {
|
||||
// 提示并返回成功
|
||||
message.success($t('ui.actionMessage.operationSuccess'));
|
||||
handleRefresh();
|
||||
resolve(true);
|
||||
} else {
|
||||
reject(new Error('更新失败'));
|
||||
}
|
||||
// 提示并返回成功
|
||||
message.success($t('ui.actionMessage.operationSuccess'));
|
||||
handleRefresh();
|
||||
resolve(true);
|
||||
})
|
||||
.catch(() => {
|
||||
reject(new Error('取消操作'));
|
||||
|
||||
@@ -72,17 +72,13 @@ async function handleStatusChange(
|
||||
})
|
||||
.then(async () => {
|
||||
// 更新状态
|
||||
const res = await updateAppStatus({
|
||||
await updateAppStatus({
|
||||
id: row.id!,
|
||||
status: newStatus,
|
||||
});
|
||||
if (res) {
|
||||
// 提示并返回成功
|
||||
message.success(`${text}成功`);
|
||||
resolve(true);
|
||||
} else {
|
||||
reject(new Error('更新失败'));
|
||||
}
|
||||
// 提示并返回成功
|
||||
message.success(`${text}成功`);
|
||||
resolve(true);
|
||||
})
|
||||
.catch(() => {
|
||||
reject(new Error('取消操作'));
|
||||
|
||||
@@ -3,6 +3,7 @@ import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { AiMusicApi } from '#/api/ai/music';
|
||||
|
||||
import { confirm, DocAlert, Page } from '@vben/common-ui';
|
||||
import { AiMusicStatusEnum } from '@vben/constants';
|
||||
|
||||
import { ElButton, ElLoading, ElMessage } from 'element-plus';
|
||||
|
||||
|
||||
@@ -71,17 +71,13 @@ async function handleStatusChange(
|
||||
})
|
||||
.then(async () => {
|
||||
// 更新状态
|
||||
const res = await updateCommentVisible({
|
||||
await updateCommentVisible({
|
||||
id: row.id!,
|
||||
visible: newStatus,
|
||||
});
|
||||
if (res) {
|
||||
// 提示并返回成功
|
||||
ElMessage.success(`${text}成功`);
|
||||
resolve(true);
|
||||
} else {
|
||||
reject(new Error($t('ui.actionMessage.operationFailed')));
|
||||
}
|
||||
// 提示并返回成功
|
||||
ElMessage.success(`${text}成功`);
|
||||
resolve(true);
|
||||
})
|
||||
.catch(() => {
|
||||
reject(new Error('取消操作'));
|
||||
|
||||
@@ -136,17 +136,13 @@ async function handleStatusChange(
|
||||
})
|
||||
.then(async () => {
|
||||
// 更新状态
|
||||
const res = await updateStatus({
|
||||
await updateStatus({
|
||||
id: row.id as number,
|
||||
status: newStatus,
|
||||
});
|
||||
if (res) {
|
||||
// 提示并返回成功
|
||||
ElMessage.success(`${text}成功`);
|
||||
resolve(true);
|
||||
} else {
|
||||
reject(new Error($t('ui.actionMessage.operationFailed')));
|
||||
}
|
||||
// 提示并返回成功
|
||||
ElMessage.success(`${text}成功`);
|
||||
resolve(true);
|
||||
})
|
||||
.catch(() => {
|
||||
reject(new Error('取消操作'));
|
||||
|
||||
@@ -65,14 +65,10 @@ async function handleStatusChange(
|
||||
})
|
||||
.then(async () => {
|
||||
// 更新优惠券模板状态
|
||||
const res = await updateCouponTemplateStatus(row.id!, newStatus);
|
||||
if (res) {
|
||||
// 提示并返回成功
|
||||
ElMessage.success($t('ui.actionMessage.operationSuccess'));
|
||||
resolve(true);
|
||||
} else {
|
||||
reject(new Error('更新失败'));
|
||||
}
|
||||
await updateCouponTemplateStatus(row.id!, newStatus);
|
||||
// 提示并返回成功
|
||||
ElMessage.success($t('ui.actionMessage.operationSuccess'));
|
||||
resolve(true);
|
||||
})
|
||||
.catch(() => {
|
||||
reject(new Error('取消操作'));
|
||||
|
||||
@@ -64,14 +64,10 @@ async function handleStatusChange(
|
||||
})
|
||||
.then(async () => {
|
||||
// 更新状态
|
||||
const res = await updateSeckillConfigStatus(row.id, newStatus);
|
||||
if (res) {
|
||||
// 提示并返回成功
|
||||
ElMessage.success(`${text}成功`);
|
||||
resolve(true);
|
||||
} else {
|
||||
reject(new Error($t('ui.actionMessage.operationFailed')));
|
||||
}
|
||||
await updateSeckillConfigStatus(row.id, newStatus);
|
||||
// 提示并返回成功
|
||||
ElMessage.success(`${text}成功`);
|
||||
resolve(true);
|
||||
})
|
||||
.catch(() => {
|
||||
reject(new Error('取消操作'));
|
||||
|
||||
@@ -71,17 +71,13 @@ async function handleStatusChange(
|
||||
})
|
||||
.then(async () => {
|
||||
// 更新状态
|
||||
const res = await updateAppStatus({
|
||||
await updateAppStatus({
|
||||
id: row.id!,
|
||||
status: newStatus,
|
||||
});
|
||||
if (res) {
|
||||
// 提示并返回成功
|
||||
ElMessage.success(`${text}成功`);
|
||||
resolve(true);
|
||||
} else {
|
||||
reject(new Error('更新失败'));
|
||||
}
|
||||
// 提示并返回成功
|
||||
ElMessage.success(`${text}成功`);
|
||||
resolve(true);
|
||||
})
|
||||
.catch(() => {
|
||||
reject(new Error('取消操作'));
|
||||
|
||||
@@ -142,14 +142,10 @@ async function handleStatusChange(
|
||||
})
|
||||
.then(async () => {
|
||||
// 更新用户状态
|
||||
const res = await updateUserStatus(row.id!, newStatus);
|
||||
if (res) {
|
||||
// 提示并返回成功
|
||||
ElMessage.success($t('ui.actionMessage.operationSuccess'));
|
||||
resolve(true);
|
||||
} else {
|
||||
reject(new Error('更新失败'));
|
||||
}
|
||||
await updateUserStatus(row.id!, newStatus);
|
||||
// 提示并返回成功
|
||||
ElMessage.success($t('ui.actionMessage.operationSuccess'));
|
||||
resolve(true);
|
||||
})
|
||||
.catch(() => {
|
||||
reject(new Error('取消操作'));
|
||||
|
||||
@@ -144,14 +144,10 @@ async function handleStatusChange(
|
||||
})
|
||||
.then(async () => {
|
||||
// 更新用户状态
|
||||
const res = await updateUserStatus(row.id!, newStatus);
|
||||
if (res) {
|
||||
// 提示并返回成功
|
||||
message.success($t('ui.actionMessage.operationSuccess'));
|
||||
resolve(true);
|
||||
} else {
|
||||
reject(new Error('更新失败'));
|
||||
}
|
||||
await updateUserStatus(row.id!, newStatus);
|
||||
// 提示并返回成功
|
||||
message.success($t('ui.actionMessage.operationSuccess'));
|
||||
resolve(true);
|
||||
})
|
||||
.catch(() => {
|
||||
reject(new Error('取消操作'));
|
||||
|
||||
Reference in New Issue
Block a user