refactor: 统一确认弹窗调用并优化开发代理配置

pull/350/head
YunaiV 2026-05-28 23:22:44 +08:00
parent 177cf37c1f
commit 0ec301cfb3
17 changed files with 225 additions and 279 deletions

View File

@ -38,11 +38,13 @@ async function handleUpdatePublicStatusChange(
row: AiImageApi.Image, row: AiImageApi.Image,
): Promise<boolean | undefined> { ): Promise<boolean | undefined> {
const text = newStatus ? '公开' : '私有'; const text = newStatus ? '公开' : '私有';
return new Promise((resolve, reject) => { try {
confirm({ await confirm({
content: `确认要将该图片切换为【${text}】吗?`, content: `确认要将该图片切换为【${text}】吗?`,
}) });
.then(async () => { } catch {
return false;
}
// //
await updateImage({ await updateImage({
id: row.id, id: row.id,
@ -50,12 +52,7 @@ async function handleUpdatePublicStatusChange(
}); });
// //
message.success($t('ui.actionMessage.operationSuccess')); message.success($t('ui.actionMessage.operationSuccess'));
resolve(true); return true;
})
.catch(() => {
reject(new Error('取消操作'));
});
});
} }
const [Grid, gridApi] = useVbenVxeGrid({ const [Grid, gridApi] = useVbenVxeGrid({

View File

@ -76,11 +76,13 @@ async function handleStatusChange(
newStatus: number, newStatus: number,
row: AiKnowledgeDocumentApi.KnowledgeDocument, row: AiKnowledgeDocumentApi.KnowledgeDocument,
): Promise<boolean | undefined> { ): Promise<boolean | undefined> {
return new Promise((resolve, reject) => { try {
confirm({ await confirm({
content: `你要将${row.name}的状态切换为【${getDictLabel(DICT_TYPE.COMMON_STATUS, newStatus)}】吗?`, content: `你要将${row.name}的状态切换为【${getDictLabel(DICT_TYPE.COMMON_STATUS, newStatus)}】吗?`,
}) });
.then(async () => { } catch {
return false;
}
// //
await updateKnowledgeDocumentStatus({ await updateKnowledgeDocumentStatus({
id: row.id, id: row.id,
@ -88,12 +90,7 @@ async function handleStatusChange(
}); });
// //
message.success($t('ui.actionMessage.operationSuccess')); message.success($t('ui.actionMessage.operationSuccess'));
resolve(true); return true;
})
.catch(() => {
reject(new Error('取消操作'));
});
});
} }
const [Grid, gridApi] = useVbenVxeGrid({ const [Grid, gridApi] = useVbenVxeGrid({

View File

@ -64,21 +64,18 @@ async function handleStatusChange(
newStatus: number, newStatus: number,
row: AiKnowledgeSegmentApi.KnowledgeSegment, row: AiKnowledgeSegmentApi.KnowledgeSegment,
): Promise<boolean | undefined> { ): Promise<boolean | undefined> {
return new Promise((resolve, reject) => { try {
confirm({ await confirm({
content: `你要将片段 ${row.id} 的状态切换为【${getDictLabel(DICT_TYPE.COMMON_STATUS, newStatus)}】吗?`, content: `你要将片段 ${row.id} 的状态切换为【${getDictLabel(DICT_TYPE.COMMON_STATUS, newStatus)}】吗?`,
}) });
.then(async () => { } catch {
return false;
}
// //
await updateKnowledgeSegmentStatus(row.id!, newStatus); await updateKnowledgeSegmentStatus(row.id!, newStatus);
// //
message.success($t('ui.actionMessage.operationSuccess')); message.success($t('ui.actionMessage.operationSuccess'));
resolve(true); return true;
})
.catch(() => {
reject(new Error('取消操作'));
});
});
} }
const [Grid, gridApi] = useVbenVxeGrid({ const [Grid, gridApi] = useVbenVxeGrid({

View File

@ -38,11 +38,13 @@ async function handleUpdatePublicStatusChange(
row: AiMusicApi.Music, row: AiMusicApi.Music,
): Promise<boolean | undefined> { ): Promise<boolean | undefined> {
const text = newStatus ? '公开' : '私有'; const text = newStatus ? '公开' : '私有';
return new Promise((resolve, reject) => { try {
confirm({ await confirm({
content: `确认要将该音乐切换为【${text}】吗?`, content: `确认要将该音乐切换为【${text}】吗?`,
}) });
.then(async () => { } catch {
return false;
}
// //
await updateMusic({ await updateMusic({
id: row.id, id: row.id,
@ -50,12 +52,7 @@ async function handleUpdatePublicStatusChange(
}); });
// //
message.success($t('ui.actionMessage.operationSuccess')); message.success($t('ui.actionMessage.operationSuccess'));
resolve(true); return true;
})
.catch(() => {
reject(new Error('取消操作'));
});
});
} }
const [Grid, gridApi] = useVbenVxeGrid({ const [Grid, gridApi] = useVbenVxeGrid({

View File

@ -74,28 +74,24 @@ async function handleDeleteContactBusinessList() {
message.error('请先选择商机后操作!'); message.error('请先选择商机后操作!');
return; return;
} }
return new Promise((resolve, reject) => { try {
confirm({ await confirm({
content: `确定要将${checkedRows.value.map((item) => item.name).join(',')}解除关联吗?`, content: `确定要将${checkedRows.value.map((item) => item.name).join(',')}解除关联吗?`,
}) });
.then(async () => { } catch {
return false;
}
const res = await deleteContactBusinessList({ const res = await deleteContactBusinessList({
contactId: props.bizId, contactId: props.bizId,
businessIds: checkedRows.value.map((item) => item.id), businessIds: checkedRows.value.map((item) => item.id),
}); });
if (res) { if (!res) {
throw new Error($t('ui.actionMessage.operationFailed'));
}
// //
message.success($t('ui.actionMessage.operationSuccess')); message.success($t('ui.actionMessage.operationSuccess'));
handleRefresh(); handleRefresh();
resolve(true); return true;
} else {
reject(new Error($t('ui.actionMessage.operationFailed')));
}
})
.catch(() => {
reject(new Error('取消操作'));
});
});
} }
/** 查看商机详情 */ /** 查看商机详情 */

View File

@ -71,28 +71,24 @@ async function handleDeleteContactBusinessList() {
message.error('请先选择联系人后操作!'); message.error('请先选择联系人后操作!');
return; return;
} }
return new Promise((resolve, reject) => { try {
confirm({ await confirm({
content: `确定要将${checkedRows.value.map((item) => item.name).join(',')}解除关联吗?`, content: `确定要将${checkedRows.value.map((item) => item.name).join(',')}解除关联吗?`,
}) });
.then(async () => { } catch {
return false;
}
const res = await deleteBusinessContactList({ const res = await deleteBusinessContactList({
businessId: props.bizId, businessId: props.bizId,
contactIds: checkedRows.value.map((item) => item.id), contactIds: checkedRows.value.map((item) => item.id),
}); });
if (res) { if (!res) {
throw new Error($t('ui.actionMessage.operationFailed'));
}
// //
message.success($t('ui.actionMessage.operationSuccess')); message.success($t('ui.actionMessage.operationSuccess'));
handleRefresh(); handleRefresh();
resolve(true); return true;
} else {
reject(new Error($t('ui.actionMessage.operationFailed')));
}
})
.catch(() => {
reject(new Error('取消操作'));
});
});
} }
/** 创建商机联系人关联 */ /** 创建商机联系人关联 */

View File

@ -94,32 +94,28 @@ function handleEdit() {
} }
/** 删除团队成员 */ /** 删除团队成员 */
function handleDelete() { async function handleDelete() {
if (checkedRows.value.length === 0) { if (checkedRows.value.length === 0) {
message.error('请先选择团队成员后操作!'); message.error('请先选择团队成员后操作!');
return; return;
} }
return new Promise((resolve, reject) => { try {
confirm({ await confirm({
content: `你要将${checkedRows.value.map((item) => item.nickname).join(',')}移出团队吗?`, content: `你要将${checkedRows.value.map((item) => item.nickname).join(',')}移出团队吗?`,
}) });
.then(async () => { } catch {
return false;
}
const res = await deletePermissionBatch( const res = await deletePermissionBatch(
checkedRows.value.map((item) => item.id!), checkedRows.value.map((item) => item.id!),
); );
if (res) { if (!res) {
throw new Error('移出失败');
}
// //
message.success($t('ui.actionMessage.operationSuccess')); message.success($t('ui.actionMessage.operationSuccess'));
handleRefresh(); handleRefresh();
resolve(true); return true;
} else {
reject(new Error('移出失败'));
}
})
.catch(() => {
reject(new Error('取消操作'));
});
});
} }
/** 退出团队 */ /** 退出团队 */

View File

@ -65,23 +65,20 @@ async function handleDefaultStatusChange(
newStatus: boolean, newStatus: boolean,
row: ErpAccountApi.Account, row: ErpAccountApi.Account,
): Promise<boolean | undefined> { ): Promise<boolean | undefined> {
return new Promise((resolve, reject) => {
const text = newStatus ? '设置' : '取消'; const text = newStatus ? '设置' : '取消';
confirm({ try {
await confirm({
content: `确认要${text}"${row.name}"默认吗?`, content: `确认要${text}"${row.name}"默认吗?`,
}) });
.then(async () => { } catch {
return false;
}
// //
await updateAccountDefaultStatus(row.id!, newStatus); await updateAccountDefaultStatus(row.id!, newStatus);
// //
message.success(`${text}默认成功`); message.success(`${text}默认成功`);
handleRefresh(); handleRefresh();
resolve(true); return true;
})
.catch(() => {
reject(new Error('取消操作'));
});
});
} }
const [Grid, gridApi] = useVbenVxeGrid({ const [Grid, gridApi] = useVbenVxeGrid({

View File

@ -63,23 +63,20 @@ async function handleDefaultStatusChange(
newStatus: boolean, newStatus: boolean,
row: ErpWarehouseApi.Warehouse, row: ErpWarehouseApi.Warehouse,
): Promise<boolean | undefined> { ): Promise<boolean | undefined> {
return new Promise((resolve, reject) => {
const text = newStatus ? '设置' : '取消'; const text = newStatus ? '设置' : '取消';
confirm({ try {
await confirm({
content: `确认要${text}"${row.name}"默认吗?`, content: `确认要${text}"${row.name}"默认吗?`,
}) });
.then(async () => { } catch {
return false;
}
// //
await updateWarehouseDefaultStatus(row.id!, newStatus); await updateWarehouseDefaultStatus(row.id!, newStatus);
// //
message.success(`${text}默认成功`); message.success(`${text}默认成功`);
handleRefresh(); handleRefresh();
resolve(true); return true;
})
.catch(() => {
reject(new Error('取消操作'));
});
});
} }
const [FormModal, formModalApi] = useVbenModal({ const [FormModal, formModalApi] = useVbenModal({

View File

@ -63,12 +63,14 @@ async function handleStatusChange(
newStatus: boolean, newStatus: boolean,
row: MallCommentApi.Comment, row: MallCommentApi.Comment,
): Promise<boolean | undefined> { ): Promise<boolean | undefined> {
return new Promise((resolve, reject) => {
const text = newStatus ? '展示' : '隐藏'; const text = newStatus ? '展示' : '隐藏';
confirm({ try {
await confirm({
content: `确认要${text}该评论吗?`, content: `确认要${text}该评论吗?`,
}) });
.then(async () => { } catch {
return false;
}
// //
await updateCommentVisible({ await updateCommentVisible({
id: row.id!, id: row.id!,
@ -76,12 +78,7 @@ async function handleStatusChange(
}); });
// //
message.success(`${text}成功`); message.success(`${text}成功`);
resolve(true); return true;
})
.catch(() => {
reject(new Error('取消操作'));
});
});
} }
const [Grid, gridApi] = useVbenVxeGrid({ const [Grid, gridApi] = useVbenVxeGrid({

View File

@ -60,21 +60,18 @@ async function handleStatusChange(
newStatus: number, newStatus: number,
row: MallCouponTemplateApi.CouponTemplate, row: MallCouponTemplateApi.CouponTemplate,
): Promise<boolean | undefined> { ): Promise<boolean | undefined> {
return new Promise((resolve, reject) => { try {
confirm({ await confirm({
content: `你要将${row.name}的状态切换为【${newStatus === CommonStatusEnum.ENABLE ? '启用' : '停用'}】吗?`, content: `你要将${row.name}的状态切换为【${newStatus === CommonStatusEnum.ENABLE ? '启用' : '停用'}】吗?`,
}) });
.then(async () => { } catch {
return false;
}
// //
await updateCouponTemplateStatus(row.id!, newStatus); await updateCouponTemplateStatus(row.id!, newStatus);
// //
message.success($t('ui.actionMessage.operationSuccess')); message.success($t('ui.actionMessage.operationSuccess'));
resolve(true); return true;
})
.catch(() => {
reject(new Error('取消操作'));
});
});
} }
const [Grid, gridApi] = useVbenVxeGrid({ const [Grid, gridApi] = useVbenVxeGrid({

View File

@ -59,23 +59,20 @@ async function handleStatusChange(
newStatus: number, newStatus: number,
row: MallSeckillConfigApi.SeckillConfig, row: MallSeckillConfigApi.SeckillConfig,
): Promise<boolean | undefined> { ): Promise<boolean | undefined> {
return new Promise((resolve, reject) => {
// //
const text = row.status === 0 ? '启用' : '停用'; const text = row.status === 0 ? '启用' : '停用';
confirm({ try {
await confirm({
content: `确认要${text + row.name}吗?`, content: `确认要${text + row.name}吗?`,
}) });
.then(async () => { } catch {
return false;
}
// //
await updateSeckillConfigStatus(row.id, newStatus); await updateSeckillConfigStatus(row.id, newStatus);
// //
message.success(`${text}成功`); message.success(`${text}成功`);
resolve(true); return true;
})
.catch(() => {
reject(new Error('取消操作'));
});
});
} }
const [Grid, gridApi] = useVbenVxeGrid({ const [Grid, gridApi] = useVbenVxeGrid({

View File

@ -87,12 +87,14 @@ async function handleBrokerageEnabledChange(
newEnabled: boolean, newEnabled: boolean,
row: MallBrokerageUserApi.BrokerageUser, row: MallBrokerageUserApi.BrokerageUser,
): Promise<boolean | undefined> { ): Promise<boolean | undefined> {
return new Promise((resolve, reject) => {
const text = newEnabled ? '开通' : '关闭'; const text = newEnabled ? '开通' : '关闭';
confirm({ try {
await confirm({
content: `你要将${row.nickname}的推广资格切换为【${text}】吗?`, content: `你要将${row.nickname}的推广资格切换为【${text}】吗?`,
}) });
.then(async () => { } catch {
return false;
}
// 广 // 广
await updateBrokerageEnabled({ await updateBrokerageEnabled({
id: row.id!, id: row.id!,
@ -101,12 +103,7 @@ async function handleBrokerageEnabledChange(
// //
message.success($t('ui.actionMessage.operationSuccess')); message.success($t('ui.actionMessage.operationSuccess'));
handleRefresh(); handleRefresh();
resolve(true); return true;
})
.catch(() => {
reject(new Error('取消操作'));
});
});
} }
const [Grid, gridApi] = useVbenVxeGrid({ const [Grid, gridApi] = useVbenVxeGrid({

View File

@ -65,12 +65,14 @@ async function handleStatusChange(
newStatus: number, newStatus: number,
row: PayAppApi.App, row: PayAppApi.App,
): Promise<boolean | undefined> { ): Promise<boolean | undefined> {
return new Promise((resolve, reject) => {
const text = newStatus === CommonStatusEnum.ENABLE ? '启用' : '停用'; const text = newStatus === CommonStatusEnum.ENABLE ? '启用' : '停用';
confirm({ try {
await confirm({
content: `确认要${text + row.name}应用吗?`, content: `确认要${text + row.name}应用吗?`,
}) });
.then(async () => { } catch {
return false;
}
// //
await updateAppStatus({ await updateAppStatus({
id: row.id!, id: row.id!,
@ -78,12 +80,7 @@ async function handleStatusChange(
}); });
// //
message.success(`${text}成功`); message.success(`${text}成功`);
resolve(true); return true;
})
.catch(() => {
reject(new Error('取消操作'));
});
});
} }
/** 生成渠道配置按钮 */ /** 生成渠道配置按钮 */

View File

@ -138,21 +138,18 @@ async function handleStatusChange(
newStatus: number, newStatus: number,
row: SystemUserApi.User, row: SystemUserApi.User,
): Promise<boolean | undefined> { ): Promise<boolean | undefined> {
return new Promise((resolve, reject) => { try {
confirm({ await confirm({
content: `你要将${row.username}的状态切换为【${getDictLabel(DICT_TYPE.COMMON_STATUS, newStatus)}】吗?`, content: `你要将${row.username}的状态切换为【${getDictLabel(DICT_TYPE.COMMON_STATUS, newStatus)}】吗?`,
}) });
.then(async () => { } catch {
return false;
}
// //
await updateUserStatus(row.id!, newStatus); await updateUserStatus(row.id!, newStatus);
// //
message.success($t('ui.actionMessage.operationSuccess')); message.success($t('ui.actionMessage.operationSuccess'));
resolve(true); return true;
})
.catch(() => {
reject(new Error('取消操作'));
});
});
} }
const [Grid, gridApi] = useVbenVxeGrid({ const [Grid, gridApi] = useVbenVxeGrid({

View File

@ -138,21 +138,18 @@ async function handleStatusChange(
newStatus: number, newStatus: number,
row: SystemUserApi.User, row: SystemUserApi.User,
): Promise<boolean | undefined> { ): Promise<boolean | undefined> {
return new Promise((resolve, reject) => { try {
confirm({ await confirm({
content: `你要将${row.username}的状态切换为【${getDictLabel(DICT_TYPE.COMMON_STATUS, newStatus)}】吗?`, content: `你要将${row.username}的状态切换为【${getDictLabel(DICT_TYPE.COMMON_STATUS, newStatus)}】吗?`,
}) });
.then(async () => { } catch {
return false;
}
// //
await updateUserStatus(row.id!, newStatus); await updateUserStatus(row.id!, newStatus);
// //
message.success($t('ui.actionMessage.operationSuccess')); message.success($t('ui.actionMessage.operationSuccess'));
resolve(true); return true;
})
.catch(() => {
reject(new Error('取消操作'));
});
});
} }
const [Grid, gridApi] = useVbenVxeGrid({ const [Grid, gridApi] = useVbenVxeGrid({

View File

@ -139,21 +139,18 @@ async function handleStatusChange(
newStatus: number, newStatus: number,
row: SystemUserApi.User, row: SystemUserApi.User,
): Promise<boolean | undefined> { ): Promise<boolean | undefined> {
return new Promise((resolve, reject) => { try {
confirm({ await confirm({
content: `你要将${row.username}的状态切换为【${getDictLabel(DICT_TYPE.COMMON_STATUS, newStatus)}】吗?`, content: `你要将${row.username}的状态切换为【${getDictLabel(DICT_TYPE.COMMON_STATUS, newStatus)}】吗?`,
}) });
.then(async () => { } catch {
return false;
}
// //
await updateUserStatus(row.id!, newStatus); await updateUserStatus(row.id!, newStatus);
// //
message.success($t('ui.actionMessage.operationSuccess')); message.success($t('ui.actionMessage.operationSuccess'));
resolve(true); return true;
})
.catch(() => {
reject(new Error('取消操作'));
});
});
} }
const [Grid, gridApi] = useVbenVxeGrid({ const [Grid, gridApi] = useVbenVxeGrid({