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

pull/349/head
YunaiV 2026-05-28 10:53:24 +08:00
parent 59cc3bbd61
commit e9cb162aea
47 changed files with 689 additions and 837 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

@ -83,21 +83,18 @@ function handleTransfer() {
/** 转化为客户 */ /** 转化为客户 */
async function handleTransform(): Promise<boolean | undefined> { async function handleTransform(): Promise<boolean | undefined> {
return new Promise((resolve, reject) => { try {
confirm({ await confirm({
content: '确定将该线索转化为客户吗?', content: '确定将该线索转化为客户吗?',
}) });
.then(async () => { } catch {
return false;
}
// //
await transformClue(clueId.value); await transformClue(clueId.value);
// //
message.success('转化客户成功'); message.success('转化客户成功');
resolve(true); return true;
})
.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

@ -100,41 +100,35 @@ function handleTransfer() {
} }
/** 锁定客户 */ /** 锁定客户 */
function handleLock(lockStatus: boolean): Promise<boolean | undefined> { async function handleLock(lockStatus: boolean): Promise<boolean | undefined> {
return new Promise((resolve, reject) => { try {
confirm({ await confirm({
content: `确定锁定客户【${customer.value.name}】吗?`, content: `确定锁定客户【${customer.value.name}】吗?`,
}) });
.then(async () => { } catch {
return false;
}
// //
await lockCustomer(customerId.value, lockStatus); await lockCustomer(customerId.value, lockStatus);
// //
message.success(lockStatus ? '锁定客户成功' : '解锁客户成功'); message.success(lockStatus ? '锁定客户成功' : '解锁客户成功');
resolve(true); return true;
})
.catch(() => {
reject(new Error('取消操作'));
});
});
} }
/** 领取客户 */ /** 领取客户 */
function handleReceive(): Promise<boolean | undefined> { async function handleReceive(): Promise<boolean | undefined> {
return new Promise((resolve, reject) => { try {
confirm({ await confirm({
content: `确定领取客户【${customer.value.name}】吗?`, content: `确定领取客户【${customer.value.name}】吗?`,
}) });
.then(async () => { } catch {
return false;
}
// //
await receiveCustomer([customerId.value]); await receiveCustomer([customerId.value]);
// //
message.success('领取客户成功'); message.success('领取客户成功');
resolve(true); return true;
})
.catch(() => {
reject(new Error('取消操作'));
});
});
} }
/** 分配客户 */ /** 分配客户 */
@ -143,42 +137,36 @@ function handleDistributeForm() {
} }
/** 客户放入公海 */ /** 客户放入公海 */
function handlePutPool(): Promise<boolean | undefined> { async function handlePutPool(): Promise<boolean | undefined> {
return new Promise((resolve, reject) => { try {
confirm({ await confirm({
content: `确定将客户【${customer.value.name}】放入公海吗?`, content: `确定将客户【${customer.value.name}】放入公海吗?`,
}) });
.then(async () => { } catch {
return false;
}
// //
await putCustomerPool(customerId.value); await putCustomerPool(customerId.value);
// //
message.success('放入公海成功'); message.success('放入公海成功');
resolve(true); return true;
})
.catch(() => {
reject(new Error('取消操作'));
});
});
} }
/** 更新成交状态操作 */ /** 更新成交状态操作 */
async function handleUpdateDealStatus(): Promise<boolean | undefined> { async function handleUpdateDealStatus(): Promise<boolean | undefined> {
return new Promise((resolve, reject) => {
const dealStatus = !customer.value.dealStatus; const dealStatus = !customer.value.dealStatus;
confirm({ try {
await confirm({
content: `确定更新成交状态为【${dealStatus ? '已成交' : '未成交'}】吗?`, content: `确定更新成交状态为【${dealStatus ? '已成交' : '未成交'}】吗?`,
}) });
.then(async () => { } catch {
return false;
}
// //
await updateCustomerDealStatus(customerId.value, dealStatus); await updateCustomerDealStatus(customerId.value, dealStatus);
// //
message.success('更新成交状态成功'); message.success('更新成交状态成功');
resolve(true); return true;
})
.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

@ -107,13 +107,15 @@ async function handleStatusChange(
newStatus: number, newStatus: number,
row: MallSpuApi.Spu, row: MallSpuApi.Spu,
): 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 updateStatus({ await updateStatus({
id: row.id!, id: row.id!,
@ -121,12 +123,7 @@ async function handleStatusChange(
}); });
// //
message.success(`${text}成功`); message.success(`${text}成功`);
resolve(true); return true;
})
.catch(() => {
reject(new Error('取消操作'));
});
});
} }
/** 添加到仓库 / 回收站的状态 */ /** 添加到仓库 / 回收站的状态 */

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

@ -113,13 +113,19 @@ function getTableActions(row: MesDvCheckPlanApi.CheckPlan): ActionItem[] {
label: '启用', label: '启用',
type: 'link', type: 'link',
auth: ['mes:dv-check-plan:update'], auth: ['mes:dv-check-plan:update'],
onClick: handleEnable.bind(null, row), popConfirm: {
title: `确认启用"${row.name}"点检保养方案?启用后将不可修改或删除。`,
confirm: handleEnable.bind(null, row),
},
} }
: { : {
label: '停用', label: '停用',
type: 'link', type: 'link',
auth: ['mes:dv-check-plan:update'], auth: ['mes:dv-check-plan:update'],
onClick: handleDisable.bind(null, row), popConfirm: {
title: `确认停用"${row.name}"点检保养方案?`,
confirm: handleDisable.bind(null, row),
},
}, },
); );
return actions; return actions;

View File

@ -96,19 +96,16 @@ async function handleStatusChange(
newStatus: number, newStatus: number,
row: MesMdItemApi.Item, row: MesMdItemApi.Item,
): Promise<boolean | undefined> { ): Promise<boolean | undefined> {
return new Promise((resolve, reject) => { try {
Modal.confirm({ await confirm(
content: `确认要将“${row.name}”物料切换为【${getDictLabel(DICT_TYPE.COMMON_STATUS, newStatus)}】吗?`, `确认要将"${row.name}"物料切换为【${getDictLabel(DICT_TYPE.COMMON_STATUS, newStatus)}】吗?`,
async onOk() { );
} catch {
return false;
}
await updateItemStatus(row.id!, newStatus); await updateItemStatus(row.id!, newStatus);
message.success($t('ui.actionMessage.operationSuccess')); message.success($t('ui.actionMessage.operationSuccess'));
resolve(true); return true;
},
onCancel() {
reject(new Error('取消操作'));
},
});
});
} }
const [Grid, gridApi] = useVbenVxeGrid({ const [Grid, gridApi] = useVbenVxeGrid({

View File

@ -55,9 +55,13 @@ async function handleStatusChange(
newStatus: number, newStatus: number,
row: MesProRouteApi.Route, row: MesProRouteApi.Route,
): Promise<boolean | undefined> { ): Promise<boolean | undefined> {
try {
await confirm( await confirm(
`确认要将"${row.name}"工艺路线切换为【${getDictLabel(DICT_TYPE.COMMON_STATUS, newStatus)}】吗?`, `确认要将"${row.name}"工艺路线切换为【${getDictLabel(DICT_TYPE.COMMON_STATUS, newStatus)}】吗?`,
); );
} catch {
return false;
}
await updateRouteStatus(row.id!, newStatus); await updateRouteStatus(row.id!, newStatus);
message.success($t('ui.actionMessage.operationSuccess')); message.success($t('ui.actionMessage.operationSuccess'));
return true; return true;

View File

@ -55,7 +55,11 @@ async function handleClockIn() {
/** 下工 */ /** 下工 */
async function handleClockOut() { async function handleClockOut() {
try {
await confirm('确认下工当前工作站?'); await confirm('确认下工当前工作站?');
} catch {
return;
}
await clockOutWorkRecord(); await clockOutWorkRecord();
message.success('下工成功'); message.success('下工成功');
await loadMyWorkstation(); await loadMyWorkstation();

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

@ -83,21 +83,18 @@ function handleTransfer() {
/** 转化为客户 */ /** 转化为客户 */
async function handleTransform(): Promise<boolean | undefined> { async function handleTransform(): Promise<boolean | undefined> {
return new Promise((resolve, reject) => { try {
confirm({ await confirm({
content: '确定将该线索转化为客户吗?', content: '确定将该线索转化为客户吗?',
}) });
.then(async () => { } catch {
return false;
}
// //
await transformClue(clueId.value); await transformClue(clueId.value);
// //
message.success('转化客户成功'); message.success('转化客户成功');
resolve(true); return true;
})
.catch(() => {
reject(new Error('取消操作'));
});
});
} }
/** 加载数据 */ /** 加载数据 */

View File

@ -100,41 +100,35 @@ function handleTransfer() {
} }
/** 锁定客户 */ /** 锁定客户 */
function handleLock(lockStatus: boolean): Promise<boolean | undefined> { async function handleLock(lockStatus: boolean): Promise<boolean | undefined> {
return new Promise((resolve, reject) => { try {
confirm({ await confirm({
content: `确定锁定客户【${customer.value.name}】吗?`, content: `确定锁定客户【${customer.value.name}】吗?`,
}) });
.then(async () => { } catch {
return false;
}
// //
await lockCustomer(customerId.value, lockStatus); await lockCustomer(customerId.value, lockStatus);
// //
message.success(lockStatus ? '锁定客户成功' : '解锁客户成功'); message.success(lockStatus ? '锁定客户成功' : '解锁客户成功');
resolve(true); return true;
})
.catch(() => {
reject(new Error('取消操作'));
});
});
} }
/** 领取客户 */ /** 领取客户 */
function handleReceive(): Promise<boolean | undefined> { async function handleReceive(): Promise<boolean | undefined> {
return new Promise((resolve, reject) => { try {
confirm({ await confirm({
content: `确定领取客户【${customer.value.name}】吗?`, content: `确定领取客户【${customer.value.name}】吗?`,
}) });
.then(async () => { } catch {
return false;
}
// //
await receiveCustomer([customerId.value]); await receiveCustomer([customerId.value]);
// //
message.success('领取客户成功'); message.success('领取客户成功');
resolve(true); return true;
})
.catch(() => {
reject(new Error('取消操作'));
});
});
} }
/** 分配客户 */ /** 分配客户 */
@ -143,42 +137,36 @@ function handleDistributeForm() {
} }
/** 客户放入公海 */ /** 客户放入公海 */
function handlePutPool(): Promise<boolean | undefined> { async function handlePutPool(): Promise<boolean | undefined> {
return new Promise((resolve, reject) => { try {
confirm({ await confirm({
content: `确定将客户【${customer.value.name}】放入公海吗?`, content: `确定将客户【${customer.value.name}】放入公海吗?`,
}) });
.then(async () => { } catch {
return false;
}
// //
await putCustomerPool(customerId.value); await putCustomerPool(customerId.value);
// //
message.success('放入公海成功'); message.success('放入公海成功');
resolve(true); return true;
})
.catch(() => {
reject(new Error('取消操作'));
});
});
} }
/** 更新成交状态操作 */ /** 更新成交状态操作 */
async function handleUpdateDealStatus(): Promise<boolean | undefined> { async function handleUpdateDealStatus(): Promise<boolean | undefined> {
return new Promise((resolve, reject) => {
const dealStatus = !customer.value.dealStatus; const dealStatus = !customer.value.dealStatus;
confirm({ try {
await confirm({
content: `确定更新成交状态为【${dealStatus ? '已成交' : '未成交'}】吗?`, content: `确定更新成交状态为【${dealStatus ? '已成交' : '未成交'}】吗?`,
}) });
.then(async () => { } catch {
return false;
}
// //
await updateCustomerDealStatus(customerId.value, dealStatus); await updateCustomerDealStatus(customerId.value, dealStatus);
// //
message.success('更新成交状态成功'); message.success('更新成交状态成功');
resolve(true); return true;
})
.catch(() => {
reject(new Error('取消操作'));
});
});
} }
/** 加载数据 */ /** 加载数据 */

View File

@ -107,13 +107,15 @@ async function handleStatusChange(
newStatus: number, newStatus: number,
row: MallSpuApi.Spu, row: MallSpuApi.Spu,
): 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 updateStatus({ await updateStatus({
id: row.id!, id: row.id!,
@ -121,12 +123,7 @@ async function handleStatusChange(
}); });
// //
message.success(`${text}成功`); message.success(`${text}成功`);
resolve(true); return true;
})
.catch(() => {
reject(new Error('取消操作'));
});
});
} }
/** 添加到仓库 / 回收站的状态 */ /** 添加到仓库 / 回收站的状态 */

View File

@ -37,11 +37,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,
@ -49,12 +51,7 @@ async function handleUpdatePublicStatusChange(
}); });
// //
ElMessage.success($t('ui.actionMessage.operationSuccess')); ElMessage.success($t('ui.actionMessage.operationSuccess'));
resolve(true); return true;
})
.catch(() => {
reject(new Error('取消操作'));
});
});
} }
const [Grid, gridApi] = useVbenVxeGrid({ const [Grid, gridApi] = useVbenVxeGrid({

View File

@ -75,11 +75,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,
@ -87,12 +89,7 @@ async function handleStatusChange(
}); });
// //
ElMessage.success($t('ui.actionMessage.operationSuccess')); ElMessage.success($t('ui.actionMessage.operationSuccess'));
resolve(true); return true;
})
.catch(() => {
reject(new Error('取消操作'));
});
});
} }
const [Grid, gridApi] = useVbenVxeGrid({ const [Grid, gridApi] = useVbenVxeGrid({

View File

@ -63,21 +63,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);
// //
ElMessage.success($t('ui.actionMessage.operationSuccess')); ElMessage.success($t('ui.actionMessage.operationSuccess'));
resolve(true); return true;
})
.catch(() => {
reject(new Error('取消操作'));
});
});
} }
const [Grid, gridApi] = useVbenVxeGrid({ const [Grid, gridApi] = useVbenVxeGrid({

View File

@ -37,11 +37,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,
@ -49,12 +51,7 @@ async function handleUpdatePublicStatusChange(
}); });
// //
ElMessage.success($t('ui.actionMessage.operationSuccess')); ElMessage.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() {
ElMessage.error('请先选择商机后操作!'); ElMessage.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'));
}
// //
ElMessage.success($t('ui.actionMessage.operationSuccess')); ElMessage.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

@ -84,21 +84,18 @@ function handleTransfer() {
/** 转化为客户 */ /** 转化为客户 */
async function handleTransform(): Promise<boolean | undefined> { async function handleTransform(): Promise<boolean | undefined> {
return new Promise((resolve, reject) => { try {
confirm({ await confirm({
content: '确定将该线索转化为客户吗?', content: '确定将该线索转化为客户吗?',
}) });
.then(async () => { } catch {
return false;
}
// //
await transformClue(clueId.value); await transformClue(clueId.value);
// //
ElMessage.success('转化客户成功'); ElMessage.success('转化客户成功');
resolve(true); return true;
})
.catch(() => {
reject(new Error('取消操作'));
});
});
} }
/** 加载数据 */ /** 加载数据 */

View File

@ -71,28 +71,24 @@ async function handleDeleteContactBusinessList() {
ElMessage.error('请先选择联系人后操作!'); ElMessage.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'));
}
// //
ElMessage.success($t('ui.actionMessage.operationSuccess')); ElMessage.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

@ -101,41 +101,35 @@ function handleTransfer() {
} }
/** 锁定客户 */ /** 锁定客户 */
function handleLock(lockStatus: boolean): Promise<boolean | undefined> { async function handleLock(lockStatus: boolean): Promise<boolean | undefined> {
return new Promise((resolve, reject) => { try {
confirm({ await confirm({
content: `确定锁定客户【${customer.value.name}】吗?`, content: `确定锁定客户【${customer.value.name}】吗?`,
}) });
.then(async () => { } catch {
return false;
}
// //
await lockCustomer(customerId.value, lockStatus); await lockCustomer(customerId.value, lockStatus);
// //
ElMessage.success(lockStatus ? '锁定客户成功' : '解锁客户成功'); ElMessage.success(lockStatus ? '锁定客户成功' : '解锁客户成功');
resolve(true); return true;
})
.catch(() => {
reject(new Error('取消操作'));
});
});
} }
/** 领取客户 */ /** 领取客户 */
function handleReceive(): Promise<boolean | undefined> { async function handleReceive(): Promise<boolean | undefined> {
return new Promise((resolve, reject) => { try {
confirm({ await confirm({
content: `确定领取客户【${customer.value.name}】吗?`, content: `确定领取客户【${customer.value.name}】吗?`,
}) });
.then(async () => { } catch {
return false;
}
// //
await receiveCustomer([customerId.value]); await receiveCustomer([customerId.value]);
// //
ElMessage.success('领取客户成功'); ElMessage.success('领取客户成功');
resolve(true); return true;
})
.catch(() => {
reject(new Error('取消操作'));
});
});
} }
/** 分配客户 */ /** 分配客户 */
@ -144,42 +138,36 @@ function handleDistributeForm() {
} }
/** 客户放入公海 */ /** 客户放入公海 */
function handlePutPool(): Promise<boolean | undefined> { async function handlePutPool(): Promise<boolean | undefined> {
return new Promise((resolve, reject) => { try {
confirm({ await confirm({
content: `确定将客户【${customer.value.name}】放入公海吗?`, content: `确定将客户【${customer.value.name}】放入公海吗?`,
}) });
.then(async () => { } catch {
return false;
}
// //
await putCustomerPool(customerId.value); await putCustomerPool(customerId.value);
// //
ElMessage.success('放入公海成功'); ElMessage.success('放入公海成功');
resolve(true); return true;
})
.catch(() => {
reject(new Error('取消操作'));
});
});
} }
/** 更新成交状态操作 */ /** 更新成交状态操作 */
async function handleUpdateDealStatus(): Promise<boolean | undefined> { async function handleUpdateDealStatus(): Promise<boolean | undefined> {
return new Promise((resolve, reject) => {
const dealStatus = !customer.value.dealStatus; const dealStatus = !customer.value.dealStatus;
confirm({ try {
await confirm({
content: `确定更新成交状态为【${dealStatus ? '已成交' : '未成交'}】吗?`, content: `确定更新成交状态为【${dealStatus ? '已成交' : '未成交'}】吗?`,
}) });
.then(async () => { } catch {
return false;
}
// //
await updateCustomerDealStatus(customerId.value, dealStatus); await updateCustomerDealStatus(customerId.value, dealStatus);
// //
ElMessage.success('更新成交状态成功'); ElMessage.success('更新成交状态成功');
resolve(true); return true;
})
.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) {
ElMessage.error('请先选择团队成员后操作!'); ElMessage.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('移出失败');
}
// //
ElMessage.success($t('ui.actionMessage.operationSuccess')); ElMessage.success($t('ui.actionMessage.operationSuccess'));
handleRefresh(); handleRefresh();
resolve(true); return true;
} else {
reject(new Error('移出失败'));
}
})
.catch(() => {
reject(new Error('取消操作'));
});
});
} }
/** 退出团队 */ /** 退出团队 */

View File

@ -64,23 +64,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);
// //
ElMessage.success(`${text}默认成功`); ElMessage.success(`${text}默认成功`);
handleRefresh(); handleRefresh();
resolve(true); return true;
})
.catch(() => {
reject(new Error('取消操作'));
});
});
} }
const [Grid, gridApi] = useVbenVxeGrid({ const [Grid, gridApi] = useVbenVxeGrid({

View File

@ -62,23 +62,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);
// //
ElMessage.success(`${text}默认成功`); ElMessage.success(`${text}默认成功`);
handleRefresh(); handleRefresh();
resolve(true); return true;
})
.catch(() => {
reject(new Error('取消操作'));
});
});
} }
const [FormModal, formModalApi] = useVbenModal({ const [FormModal, formModalApi] = useVbenModal({

View File

@ -62,12 +62,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!,
@ -75,12 +77,7 @@ async function handleStatusChange(
}); });
// //
ElMessage.success(`${text}成功`); ElMessage.success(`${text}成功`);
resolve(true); return true;
})
.catch(() => {
reject(new Error('取消操作'));
});
});
} }
const [Grid, gridApi] = useVbenVxeGrid({ const [Grid, gridApi] = useVbenVxeGrid({

View File

@ -106,13 +106,15 @@ async function handleStatusChange(
newStatus: number, newStatus: number,
row: MallSpuApi.Spu, row: MallSpuApi.Spu,
): 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 updateStatus({ await updateStatus({
id: row.id!, id: row.id!,
@ -120,12 +122,7 @@ async function handleStatusChange(
}); });
// //
ElMessage.success(`${text}成功`); ElMessage.success(`${text}成功`);
resolve(true); return true;
})
.catch(() => {
reject(new Error('取消操作'));
});
});
} }
/** 添加到仓库 / 回收站的状态 */ /** 添加到仓库 / 回收站的状态 */

View File

@ -59,21 +59,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);
// //
ElMessage.success($t('ui.actionMessage.operationSuccess')); ElMessage.success($t('ui.actionMessage.operationSuccess'));
resolve(true); return true;
})
.catch(() => {
reject(new Error('取消操作'));
});
});
} }
const [Grid, gridApi] = useVbenVxeGrid({ const [Grid, gridApi] = useVbenVxeGrid({

View File

@ -56,23 +56,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);
// //
ElMessage.success(`${text}成功`); ElMessage.success(`${text}成功`);
resolve(true); return true;
})
.catch(() => {
reject(new Error('取消操作'));
});
});
} }
const [Grid, gridApi] = useVbenVxeGrid({ const [Grid, gridApi] = useVbenVxeGrid({

View File

@ -86,12 +86,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!,
@ -100,12 +102,7 @@ async function handleBrokerageEnabledChange(
// //
ElMessage.success($t('ui.actionMessage.operationSuccess')); ElMessage.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

@ -112,14 +112,20 @@ function getTableActions(row: MesDvCheckPlanApi.CheckPlan): ActionItem[] {
type: 'warning', type: 'warning',
link: true, link: true,
auth: ['mes:dv-check-plan:update'], auth: ['mes:dv-check-plan:update'],
onClick: handleEnable.bind(null, row), popConfirm: {
title: `确认启用"${row.name}"点检保养方案?启用后将不可修改或删除。`,
confirm: handleEnable.bind(null, row),
},
} }
: { : {
label: '停用', label: '停用',
type: 'warning', type: 'warning',
link: true, link: true,
auth: ['mes:dv-check-plan:update'], auth: ['mes:dv-check-plan:update'],
onClick: handleDisable.bind(null, row), popConfirm: {
title: `确认停用"${row.name}"点检保养方案?`,
confirm: handleDisable.bind(null, row),
},
}, },
); );
return actions; return actions;

View File

@ -5,18 +5,12 @@ import type { MesMdItemTypeApi } from '#/api/mes/md/item/type';
import { ref } from 'vue'; import { ref } from 'vue';
import { DocAlert, Page, useVbenModal } from '@vben/common-ui'; import { confirm, DocAlert, Page, useVbenModal } from '@vben/common-ui';
import { DICT_TYPE } from '@vben/constants'; import { DICT_TYPE } from '@vben/constants';
import { getDictLabel } from '@vben/hooks'; import { getDictLabel } from '@vben/hooks';
import { downloadFileFromBlobPart } from '@vben/utils'; import { downloadFileFromBlobPart } from '@vben/utils';
import { import { ElButton, ElCard, ElLoading, ElMessage } from 'element-plus';
ElButton,
ElCard,
ElLoading,
ElMessage,
ElMessageBox,
} from 'element-plus';
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table'; import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
import { import {
@ -101,21 +95,16 @@ async function handleStatusChange(
newStatus: number, newStatus: number,
row: MesMdItemApi.Item, row: MesMdItemApi.Item,
): Promise<boolean | undefined> { ): Promise<boolean | undefined> {
return new Promise((resolve, reject) => { try {
ElMessageBox.confirm( await confirm(
`确认要将${row.name}物料切换为【${getDictLabel(DICT_TYPE.COMMON_STATUS, newStatus)}】吗?`, `确认要将"${row.name}"物料切换为【${getDictLabel(DICT_TYPE.COMMON_STATUS, newStatus)}】吗?`,
'提示', );
{ type: 'warning' }, } catch {
) return false;
.then(async () => { }
await updateItemStatus(row.id!, newStatus); await updateItemStatus(row.id!, newStatus);
ElMessage.success($t('ui.actionMessage.operationSuccess')); ElMessage.success($t('ui.actionMessage.operationSuccess'));
resolve(true); return true;
})
.catch(() => {
reject(new Error('取消操作'));
});
});
} }
const [Grid, gridApi] = useVbenVxeGrid({ const [Grid, gridApi] = useVbenVxeGrid({

View File

@ -3,18 +3,12 @@ import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import type { MesProRouteApi } from '#/api/mes/pro/route'; import type { MesProRouteApi } from '#/api/mes/pro/route';
import { useAccess } from '@vben/access'; import { useAccess } from '@vben/access';
import { DocAlert, Page, useVbenModal } from '@vben/common-ui'; import { confirm, DocAlert, Page, useVbenModal } from '@vben/common-ui';
import { CommonStatusEnum, DICT_TYPE } from '@vben/constants'; import { CommonStatusEnum, DICT_TYPE } from '@vben/constants';
import { getDictLabel } from '@vben/hooks'; import { getDictLabel } from '@vben/hooks';
import { downloadFileFromBlobPart } from '@vben/utils'; import { downloadFileFromBlobPart } from '@vben/utils';
import { import { ElButton, ElLoading, ElMessage, ElTooltip } from 'element-plus';
ElButton,
ElLoading,
ElMessage,
ElMessageBox,
ElTooltip,
} from 'element-plus';
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table'; import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
import { import {
@ -62,17 +56,15 @@ async function handleStatusChange(
row: MesProRouteApi.Route, row: MesProRouteApi.Route,
): Promise<boolean | undefined> { ): Promise<boolean | undefined> {
try { try {
await ElMessageBox.confirm( await confirm(
`确认要将"${row.name}"工艺路线切换为【${getDictLabel(DICT_TYPE.COMMON_STATUS, newStatus)}】吗?`, `确认要将"${row.name}"工艺路线切换为【${getDictLabel(DICT_TYPE.COMMON_STATUS, newStatus)}】吗?`,
'提示',
{ type: 'warning' },
); );
await updateRouteStatus(row.id!, newStatus);
ElMessage.success($t('ui.actionMessage.operationSuccess'));
return true;
} catch { } catch {
return false; return false;
} }
await updateRouteStatus(row.id!, newStatus);
ElMessage.success($t('ui.actionMessage.operationSuccess'));
return true;
} }
/** 删除(仅停用状态可删除) */ /** 删除(仅停用状态可删除) */

View File

@ -55,7 +55,11 @@ async function handleClockIn() {
/** 下工 */ /** 下工 */
async function handleClockOut() { async function handleClockOut() {
try {
await confirm('确认下工当前工作站?'); await confirm('确认下工当前工作站?');
} catch {
return;
}
await clockOutWorkRecord(); await clockOutWorkRecord();
ElMessage.success('下工成功'); ElMessage.success('下工成功');
await loadMyWorkstation(); await loadMyWorkstation();

View File

@ -64,12 +64,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!,
@ -77,12 +79,7 @@ async function handleStatusChange(
}); });
// //
ElMessage.success(`${text}成功`); ElMessage.success(`${text}成功`);
resolve(true); return true;
})
.catch(() => {
reject(new Error('取消操作'));
});
});
} }
/** 生成渠道配置按钮 */ /** 生成渠道配置按钮 */

View File

@ -136,21 +136,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);
// //
ElMessage.success($t('ui.actionMessage.operationSuccess')); ElMessage.success($t('ui.actionMessage.operationSuccess'));
resolve(true); return true;
})
.catch(() => {
reject(new Error('取消操作'));
});
});
} }
const [Grid, gridApi] = useVbenVxeGrid({ const [Grid, gridApi] = useVbenVxeGrid({