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
17 KiB

1 month ago
  1. {"ast":null,"code":"import { ref, reactive, onMounted, computed } from 'vue';\nimport { useRouter } from 'vue-router';\nimport { ElMessage } from 'element-plus';\nimport { Search } from '@element-plus/icons-vue';\nimport { getAllOrders, getOrderById } from '@/api/order';\nimport store from '@/store';\nexport default {\n __name: 'OrderManagement',\n setup(__props, {\n expose: __expose\n }) {\n __expose();\n const router = useRouter();\n const loading = ref(false);\n const orderList = ref([]);\n const currentPage = ref(1);\n const pageSize = ref(10);\n const total = ref(0);\n const searchForm = reactive({\n customerId: '',\n orderId: ''\n });\n const isValidCustomerId = computed(() => {\n if (!searchForm.customerId) return true; // \n const num = Number(searchForm.customerId);\n return Number.isInteger(num) && num > 0; // \n });\n const validateCustomerId = val => {\n if (val === '') {\n // \n searchForm.customerId = '';\n return;\n }\n if (!isValidCustomerId.value) {\n ElMessage.warning('ID');\n searchForm.customerId = '';\n }\n };\n const getStatusText = status => {\n const orderStatus = Number(status);\n switch (orderStatus) {\n case 0:\n return '';\n case 1:\n return '';\n case 2:\n return '';\n case 3:\n return '';\n case 4:\n return '';\n default:\n return '';\n }\n };\n const getStatusType = status => {\n const orderStatus = Number(status);\n switch (orderStatus) {\n case 0:\n return 'info';\n // \n case 1:\n return 'warning';\n // \n case 2:\n return 'warning';\n // \n case 3:\n return 'success';\n // 绿\n case 4:\n return 'danger';\n // \n default:\n return '';\n }\n };\n const hasPermission = computed(() => {\n const userRole = store.state.userInfo.role;\n return ['ROLE_ADMIN', 'ROLE_LOGISTICS_ADMIN'].includes(userRole);\n });\n const loadOrders = async () => {\n loading.value = true;\n try {\n const params = {\n pageNum: currentPage.value,\n pageSize: pageSize.value\n };\n if (searchForm.customerId && searchForm.customerId.trim() !== '') {\n params.customerId = Number(searchForm.customerId);\n }\n const res = await getAllOrders(params);\n if (res.code === 200 && res.data) {\n orderList.value = res.data.records;\n total.value = res.data.total;\n pageSize.value = res.data.size;\n currentPage.value = res.data.current;\n } else {\n throw new Error(res.message || '');\n }\n } catch (error) {\n console.error(':', error);\n if (error.response?.status === 401) {\n ElMessage.error('');\n router.push('/login');\n } else if (error.response?.status === 403) {\n ElMessage.error('访');\n } else {\n ElMessage.error(error.message || '');\n }\n } finally {\n loading.value = false;\n }\n };\n const handleSizeChange = val => {\n pageSize.value = val;\n loadOrders();\n };\n const handleCurrentChange = val => {\n currentPage.value = val;\n loadOrders();\n };\n const handleSearch = () => {\n if (searchForm.customerId && !isValidCustomerId.value) {\n ElMessage.warning('ID');\n return;\n }\n currentPage.value = 1;\n loadOrders();\n };\n const