vue3 如何封装一个方法调用不同接口

const workSign = () => {
	if (lclx.value == "1") {
		signforWorkOrder(hdlcid).then(res => {
			workSignRes(res);
		});
	} else {
		signforWorkFlow(hdlcid).then(res => {
			workSignRes(res);
		});
	}
};
const workSignRes = (res: any) => {
	ElMessage.success({ message: res.msg });
	ElMessageBox.confirm("是否跳转到办理页面", "提示", {
		confirmButtonText: "确认",
		cancelButtonText: "取消",
		type: "warning"
	})
		.then(() => {
			instance?.proxy?.$Bus.emit("closeCurrentTab");
			router.push({
				path: "/workManage/common/index",
				query: { hdlcid: hdlcid }
			});
		})
		.catch(() => {
			instance?.proxy?.$Bus.emit("closeCurrentTab");
			instance?.proxy?.$Bus.emit("loadToDoData");
		});
};

你可能感兴趣的:(前端,javascript,vue.js)