| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120 |
- import { getCurrentInstance, ref } from 'vue';
- import { ElMessageBox } from 'element-plus/es';
- import { EleMessage } from 'ele-admin-plus/es';
- import { useRouter } from 'vue-router';
- //订单日志
- import orderLog from '@/views/recycleOrder/components/order-log.vue';
- //订单详情
- import orderDetail from '@/views/recycleOrder/components/order-detail.vue';
- export function useOrderOperation(pageRef) {
- const { proxy } = getCurrentInstance();
- const router = useRouter();
-
- // 组件引用
- const orderLogRef = ref(null);
- const orderDetailRef = ref(null);
- function messageBoxConfirm({ message, fetch }) {
- ElMessageBox.confirm(message, '提示', {
- confirmButtonText: '确定',
- cancelButtonText: '关闭',
- type: 'warning'
- }).then(() => {
- fetch().then((res) => {
- if (res.data.code === 200) {
- EleMessage.success('操作成功');
- pageRef.value?.reload();
- } else {
- EleMessage.error(res.data.msg);
- }
- });
- });
- }
- return {
- // 组件引用
- orderLogRef,
- orderDetailRef,
- orderLog,
- orderDetail,
- //订单详情
- toOrderDetail(row) {
- orderDetailRef.value?.handleOpen(row);
- },
- //订单日志
- openOrderLog(row) {
- orderLogRef.value?.handleOpen(row);
- },
- //取消订单
- handleCancelOrder(row) {
- const rows = row == null ? [] : [row];
- if (!rows.length) {
- EleMessage.error('请至少选择一条数据');
- return;
- }
- messageBoxConfirm({
- message: '是否确认取消订单?',
- fetch: () => proxy.$http.post('/order/orderInfo/adminCancel', {
- orderIds: rows.map(item => item.orderId)
- })
- });
- },
- //申请拦截退出
- applyForInterception(row) {
- messageBoxConfirm({
- message: '确认拦截?',
- fetch: () => proxy.$http.post(`/order/orderInfo/intercept/${row.orderId}`)
- });
- },
- //物流签收
- handleLogisticsSigning(row) {
- messageBoxConfirm({
- message: '确认签收?',
- fetch: () => proxy.$http.post('/order/orderInfo/adminSigned', {
- orderIds: [row.orderId]
- })
- });
- },
- //回退状态
- fallbackOrder(row) {
- messageBoxConfirm({
- message: '确认回退?',
- fetch: () => proxy.$http.post(`/order/orderInfo/statusBack/${row.orderId}`)
- });
- },
- //确认收货
- handleConfirmReceipt(row) {
- const rows = row == null ? [] : [row];
- if (!rows.length) {
- EleMessage.error('请至少选择一条数据');
- return;
- }
- messageBoxConfirm({
- message: '确认收货?',
- fetch: () => proxy.$http.post('/order/orderInfo/adminConfirm', {
- orderIds: rows.map(item => item.orderId)
- })
- });
- },
- //物流揽件
- materialPickup(row) {
- messageBoxConfirm({
- message: '确认物流揽件?',
- fetch: () => proxy.$http.post('/order/orderInfo/adminPickup', {
- orderIds: [row.orderId]
- })
- });
- },
- //取消拦截退出
- cancelInterception(row) {
- messageBoxConfirm({
- message: '确认取消拦截?',
- fetch: () => proxy.$http.post(`/order/orderInfo/interceptBack/${row.orderId}`)
- });
- }
- };
- }
|