You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

0 lines
27 KiB

1 month ago
  1. {"ast":null,"code":"import { ref, reactive, computed } from 'vue';\nimport { useRouter } from 'vue-router';\nimport { useStore } from 'vuex';\nimport { ElMessage, ElMessageBox } from 'element-plus';\nimport { getAllOrders, updateOrderStatus } from '@/api/order';\nexport default {\n __name: 'OrderManagement',\n setup(__props, {\n expose: __expose\n }) {\n __expose();\n const router = useRouter();\n const store = useStore();\n const loading = ref(false);\n const updating = ref(false);\n const orderList = ref([]);\n const total = ref(0);\n const currentPage = ref(1);\n const pageSize = ref(10);\n const statusDialogVisible = ref(false);\n const currentOrder = ref(null);\n const searchForm = reactive({\n orderNo: '',\n customerName: '',\n status: '',\n startTime: '',\n endTime: ''\n });\n const statusForm = reactive({\n status: ''\n });\n const dateRange = ref([]);\n\n // 状态选项\n const statusOptions = computed(() => {\n const userRoles = store.state.userInfo?.roles || [];\n const currentStatus = currentOrder.value?.status;\n\n // 基础状态映射\n const baseOptions = {\n 0: '待处理',\n 1: '待发货',\n 2: '已发货',\n 3: '运输中',\n 4: '已送达',\n 5: '已完成',\n 6: '已取消'\n };\n\n // 系统管理员可以修改为任意状态\n if (userRoles.includes('ROLE_ADMIN')) {\n return baseOptions;\n }\n\n // 仓库管理员只能将订单从\"待处理\"改为\"待发货\"\n if (userRoles.includes('ROLE_WAREHOUSE_ADMIN')) {\n return currentStatus === 0 ? {\n 1: ''\n } : {};\n }\n\n // \n if (userRoles.includes('ROLE_LOGISTICS_ADMIN')) {\n switch (currentStatus) {\n case 1:\n return {\n 2: ''\n };\n case 2:\n return {\n 3: ''\n };\n case 3:\n return {\n 4: ''\n };\n case 4:\n return {\n 5: ''\n };\n default:\n return {};\n }\n }\n return {};\n });\n\n // \n const canUpdateStatus = status => {\n const userRoles = store.state.userInfo?.roles || [];\n\n // \n if (userRoles.includes('ROLE_ADMIN')) {\n return status !== 5 && status !== 6; // \n }\n\n // \n if (userRoles.includes('ROLE_WAREHOUSE_ADMIN')) {\n return status === 0;\n }\n\n // \n if (userRoles.includes('ROLE_LOGISTICS_ADMIN')) {\n return status >= 1 && status <= 4; // \n }\n return false;\n };\n\n // \n const getStatusText = status => {\n const statusMap = {\n 0: '',\n 1: '',\n 2: '',\n 3: '',\n 4: '',\n 5: '',\n 6: ''\n };\n return statusMap[status] || '';\n };\n\n // \n const availableSearchStatusOptions = computed(() => {\n const userRoles = store.state.userInfo?.roles || [];\n const baseOptions = {\n 0: '',\n 1: '',\n 2: '',\n 3: '',\n 4: '',\n 5: '',\n 6: ''\n };\n\n // \n if (userRoles.includes('ROLE_WAREHOUSE_ADMIN')) {\n return {\n 0: '',\n 1: ''\n };\n }\n return baseOptions;\n });\n\n // \n const handleDateChange = val => {\