Browse Source

feat(订单管理): 重构订单管理模块为mixin架构

yz 3 months ago
parent
commit
06a18fb427

+ 256 - 0
src/mixins/order/customerManagementMixin.js

@@ -0,0 +1,256 @@
+/**
+ * 客户管理mixin
+ * 负责客户选项加载、搜索、地址管理等逻辑
+ */
+
+import { getCustomerList } from '@/api/common/index'
+import { getCustomerAddressList } from '@/api/order/order'
+
+/**
+ * 客户选项类型定义
+ * @typedef {Object} CustomerOption
+ * @property {string} value - 客户编码
+ * @property {string} label - 显示标签(客户编码 - 客户名称)
+ * @property {string} customerCode - 客户编码
+ * @property {string} customerName - 客户名称
+ * @property {string} customerId - 客户ID
+ */
+
+/**
+ * 客户地址选项类型定义
+ * @typedef {Object} CustomerAddressOption
+ * @property {number} value - 地址ID
+ * @property {string} label - 地址显示文本
+ * @property {string} receiverName - 收货人姓名
+ * @property {string} receiverPhone - 收货人电话
+ * @property {string} receiverAddress - 收货详细地址
+ * @property {string} receiverRegion - 收货地区
+ * @property {number} isDefault - 是否默认地址 0-否 1-是
+ */
+
+export default {
+  data() {
+    return {
+      /**
+       * 客户选项列表
+       * @type {CustomerOption[]}
+       */
+      customerOptions: [],
+
+      /**
+       * 过滤后的客户选项列表
+       * @type {CustomerOption[]}
+       */
+      filteredCustomerOptions: [],
+
+      /**
+       * 客户选项加载状态
+       * @type {boolean}
+       */
+      customerLoading: false,
+
+      /**
+       * 客户搜索定时器
+       * @type {number|null}
+       */
+      customerSearchTimer: null,
+
+      /**
+       * 客户地址选项列表
+       * @type {CustomerAddressOption[]}
+       */
+      addressOptions: []
+    }
+  },
+
+  methods: {
+    /**
+     * 加载客户选项列表
+     * @param {string} keyword - 搜索关键词
+     * @returns {Promise<void>}
+     */
+    async loadCustomerOptions(keyword = '') {
+      try {
+        this.customerLoading = true
+        const params = {}
+
+        // 如果有搜索关键词,添加到查询参数中
+        if (keyword.trim()) {
+          params.Customer_CODE = keyword
+          params.Customer_NAME = keyword
+        }
+
+        const response = await getCustomerList(1, 50, params)
+
+        if (response.data && response.data.success) {
+          const customers = response.data.data.records || []
+          this.customerOptions = customers.map(customer => ({
+            value: customer.Customer_ID.toString(),
+            label: `${customer.Customer_CODE} - ${customer.Customer_NAME}`,
+            customerCode: customer.Customer_CODE,
+            customerName: customer.Customer_NAME,
+            customerId: customer.Customer_ID.toString()
+          }))
+          this.filteredCustomerOptions = [...this.customerOptions]
+        } else {
+          this.customerOptions = []
+          this.filteredCustomerOptions = []
+          this.$message.warning('获取客户列表失败')
+        }
+      } catch (error) {
+        this.customerOptions = []
+        this.filteredCustomerOptions = []
+        console.error('加载客户选项失败:', error)
+        this.$message.error('加载客户选项失败,请稍后重试')
+      } finally {
+        this.customerLoading = false
+      }
+    },
+
+    /**
+     * 搜索客户(防抖处理)
+     * @param {string} query - 搜索关键词
+     * @returns {void}
+     */
+    searchCustomers(query) {
+      // 清除之前的定时器
+      if (this.customerSearchTimer) {
+        clearTimeout(this.customerSearchTimer)
+      }
+
+      // 设置新的定时器,300ms后执行搜索
+      this.customerSearchTimer = setTimeout(() => {
+        this.loadCustomerOptions(query)
+      }, 300)
+    },
+
+    /**
+     * 本地过滤客户选项
+     * @param {string} query - 搜索关键词
+     * @returns {void}
+     */
+    filterCustomers(query) {
+      if (query) {
+        const keyword = query.toLowerCase()
+        this.filteredCustomerOptions = this.customerOptions.filter(option => {
+          return option.label.toLowerCase().includes(keyword) ||
+                 option.customerCode.toLowerCase().includes(keyword) ||
+                 option.customerName.toLowerCase().includes(keyword)
+        })
+      } else {
+        this.filteredCustomerOptions = [...this.customerOptions]
+      }
+    },
+
+    /**
+     * 客户选择变更处理
+     * @param {string|number} value - 选中的客户ID
+     * @returns {void}
+     */
+    handleCustomerChange(value) {
+      if (value) {
+        const selectedCustomer = this.customerOptions.find(option => option.value === value)
+        if (selectedCustomer) {
+          // 自动填充客户信息
+          this.orderForm.customerId = selectedCustomer.customerId
+          this.orderForm.customerCode = selectedCustomer.customerCode
+          this.orderForm.customerName = selectedCustomer.customerName
+          // 加载客户地址
+          this.loadCustomerAddresses(selectedCustomer.customerCode)
+        } else {
+          this.clearCustomerData()
+        }
+      } else {
+        this.clearCustomerData()
+      }
+    },
+
+    /**
+     * 清除客户相关数据
+     * @returns {void}
+     */
+    clearCustomerData() {
+      this.orderForm.customerName = ''
+      this.orderForm.customerId = ''
+      this.addressOptions = []
+      this.orderForm.addressId = ''
+      this.orderForm.receiverName = ''
+      this.orderForm.receiverPhone = ''
+      this.orderForm.receiverAddress = ''
+      this.orderForm.receiverRegion = ''
+    },
+
+    /**
+     * 根据客户编码加载客户地址列表
+     * @param {string} customerCode - 客户编码
+     * @returns {Promise<void>}
+     */
+    async loadCustomerAddresses(customerCode) {
+      try {
+        const response = await getCustomerAddressList(customerCode)
+        const addresses = response.data.data.records || []
+        this.addressOptions = addresses.map(addr => ({
+          value: addr.id,
+          label: `${addr.receiverName} - ${addr.receiverPhone} - ${addr.regionName} ${addr.detailAddress}`,
+          receiverName: addr.receiverName,
+          receiverPhone: addr.receiverPhone,
+          receiverAddress: addr.detailAddress,
+          receiverRegion: addr.regionName,
+          isDefault: addr.isDefault
+        }))
+      } catch (error) {
+        this.addressOptions = []
+        console.error('加载客户地址失败:', error)
+      }
+    },
+
+    /**
+     * 地址选择变更处理
+     * @param {number} value - 选中的地址ID
+     * @returns {void}
+     */
+    handleAddressChange(value) {
+      if (value) {
+        const selectedAddress = this.addressOptions.find(addr => addr.value === value)
+        if (selectedAddress) {
+          this.orderForm.receiverName = selectedAddress.receiverName
+          this.orderForm.receiverPhone = selectedAddress.receiverPhone
+          this.orderForm.receiverAddress = selectedAddress.receiverAddress
+          this.orderForm.receiverRegion = selectedAddress.receiverRegion
+        }
+      }
+    },
+
+    /**
+     * 确保客户在选项列表中
+     * @param {string|number} customerId - 客户ID
+     * @param {string} customerCode - 客户编码
+     * @param {string} customerName - 客户名称
+     * @returns {void}
+     */
+    ensureCustomerInOptions(customerId, customerCode, customerName) {
+      const existingCustomer = this.customerOptions.find(option => 
+        option.value.toString() === customerId.toString()
+      )
+      
+      // 如果当前客户不在选项列表中,添加它
+      if (!existingCustomer) {
+        this.customerOptions.unshift({
+          value: customerId.toString(),
+          label: `${customerCode} - ${customerName}`,
+          customerCode: customerCode,
+          customerName: customerName,
+          customerId: customerId.toString()
+        })
+        this.filteredCustomerOptions = [...this.customerOptions]
+      }
+    }
+  },
+
+  beforeDestroy() {
+    // 清理定时器
+    if (this.customerSearchTimer) {
+      clearTimeout(this.customerSearchTimer)
+    }
+  }
+}

+ 173 - 0
src/mixins/order/orderDataMixin.js

@@ -0,0 +1,173 @@
+/**
+ * 订单数据管理mixin
+ * 负责管理表格数据、分页信息、选择状态等数据相关逻辑
+ */
+
+/**
+ * 订单列表项类型定义
+ * @typedef {Object} OrderItem
+ * @property {string} id - 订单ID
+ * @property {string} createUser - 创建用户ID
+ * @property {string} createDept - 创建部门ID
+ * @property {string} createTime - 创建时间
+ * @property {string} updateUser - 更新用户ID
+ * @property {string} updateTime - 更新时间
+ * @property {number} status - 订单状态 0-草稿 1-已提交 2-已确认 3-部分发货 4-已完成 5-已取消
+ * @property {number} isDeleted - 是否删除 0-未删除 1-已删除
+ * @property {string} orderCode - 订单编码
+ * @property {number} orgId - 组织ID
+ * @property {string} orgCode - 组织编码
+ * @property {string} orgName - 组织名称
+ * @property {number} customerId - 客户ID
+ * @property {string} customerCode - 客户编码
+ * @property {string} customerName - 客户名称
+ * @property {number} orderType - 订单类型 1-普通订单
+ * @property {string} totalAmount - 订单总金额
+ * @property {string} totalQuantity - 订单总数量
+ * @property {number} addressId - 收货地址ID
+ * @property {string} receiverName - 收货人姓名
+ * @property {string} receiverPhone - 收货人电话
+ * @property {string} receiverAddress - 收货详细地址
+ * @property {string} receiverRegion - 收货地区
+ * @property {string|null} submitTime - 提交时间
+ * @property {string|null} confirmTime - 确认时间
+ */
+
+/**
+ * 分页信息类型定义
+ * @typedef {Object} PaginationInfo
+ * @property {number} currentPage - 当前页码
+ * @property {number} pageSize - 每页条数
+ * @property {number} total - 总条数
+ */
+
+export default {
+  data() {
+    return {
+      /**
+       * 表格数据
+       * @type {OrderItem[]}
+       */
+      tableData: [],
+
+      /**
+       * 加载状态
+       * @type {boolean}
+       */
+      loading: false,
+
+      /**
+       * 分页信息
+       * @type {PaginationInfo}
+       */
+      pagination: {
+        currentPage: 1,
+        pageSize: 10,
+        total: 0
+      },
+
+      /**
+       * 选中的行数据
+       * @type {OrderItem[]}
+       */
+      selectionList: []
+    }
+  },
+
+  computed: {
+    /**
+     * 选中的ID字符串
+     * @returns {string} 逗号分隔的ID字符串
+     */
+    ids() {
+      return this.selectionList.map(item => item.id).join(',')
+    },
+
+    /**
+     * 是否有选中数据
+     * @returns {boolean} 是否有选中的数据
+     */
+    hasSelection() {
+      return this.selectionList.length > 0
+    },
+
+    /**
+     * 选中数据数量
+     * @returns {number} 选中的数据数量
+     */
+    selectionCount() {
+      return this.selectionList.length
+    }
+  },
+
+  methods: {
+    /**
+     * 选择改变处理
+     * @param {OrderItem[]} selection - 选中的数据
+     * @returns {void}
+     */
+    handleSelectionChange(selection) {
+      this.selectionList = selection
+    },
+
+    /**
+     * 页大小改变处理
+     * @param {number} pageSize - 新的页大小
+     * @returns {void}
+     */
+    handleSizeChange(pageSize) {
+      this.pagination.pageSize = pageSize
+      this.pagination.currentPage = 1
+      this.loadTableData()
+    },
+
+    /**
+     * 当前页改变处理
+     * @param {number} currentPage - 新的当前页
+     * @returns {void}
+     */
+    handleCurrentChange(currentPage) {
+      this.pagination.currentPage = currentPage
+      this.loadTableData()
+    },
+
+    /**
+     * 重置分页到第一页
+     * @returns {void}
+     */
+    resetPagination() {
+      this.pagination.currentPage = 1
+    },
+
+    /**
+     * 清空选择
+     * @returns {void}
+     */
+    clearSelection() {
+      this.selectionList = []
+      if (this.$refs.table) {
+        this.$refs.table.clearSelection()
+      }
+    },
+
+    /**
+     * 设置表格数据
+     * @param {OrderItem[]} data - 表格数据
+     * @param {number} total - 总条数
+     * @returns {void}
+     */
+    setTableData(data, total = 0) {
+      this.tableData = data || []
+      this.pagination.total = total
+    },
+
+    /**
+     * 设置加载状态
+     * @param {boolean} loading - 加载状态
+     * @returns {void}
+     */
+    setLoading(loading) {
+      this.loading = loading
+    }
+  }
+}

+ 313 - 0
src/mixins/order/orderFormMixin.js

@@ -0,0 +1,313 @@
+/**
+ * 订单表单管理mixin
+ * 负责管理表单数据、验证规则、表单操作等逻辑
+ */
+
+import {
+  ORDER_TYPES,
+  ORDER_STATUS,
+  ORDER_TYPE_OPTIONS,
+  ORDER_STATUS_OPTIONS
+} from '@/views/order/order/constants'
+
+/**
+ * 订单表单数据类型定义
+ * @typedef {Object} OrderForm
+ * @property {string|number} [id] - 订单ID(修改时必填)
+ * @property {string} [orderCode] - 订单编码(系统自动生成)
+ * @property {string|number} orgId - 组织ID
+ * @property {string} orgCode - 组织编码
+ * @property {string} orgName - 组织名称
+ * @property {string|number} customerId - 客户ID
+ * @property {string} customerCode - 客户编码
+ * @property {string} customerName - 客户名称
+ * @property {number} orderType - 订单类型
+ * @property {number|string} totalAmount - 订单总金额
+ * @property {number|string} totalQuantity - 订单总数量
+ * @property {string|number} addressId - 收货地址ID
+ * @property {string} receiverName - 收货人姓名
+ * @property {string} receiverPhone - 收货人电话
+ * @property {string} receiverAddress - 收货详细地址
+ * @property {string} receiverRegion - 收货地区
+ * @property {number} status - 订单状态
+ * @property {string} createTime - 创建时间
+ * @property {string} updateTime - 更新时间
+ * @property {string} submitTime - 提交时间
+ * @property {string} confirmTime - 确认时间
+ */
+
+/**
+ * 弹窗模式类型定义
+ * @typedef {'add'|'edit'|'view'} DialogMode
+ */
+
+export default {
+  data() {
+    return {
+      /**
+       * 弹窗显示状态
+       * @type {boolean}
+       */
+      dialogVisible: false,
+
+      /**
+       * 弹窗模式
+       * @type {DialogMode}
+       */
+      dialogMode: 'add',
+
+      /**
+       * 弹窗标题
+       * @type {string}
+       */
+      dialogTitle: '',
+
+      /**
+       * 订单表单数据
+       * @type {OrderForm}
+       */
+      orderForm: {
+        id: '',
+        orderCode: '',
+        orgId: '',
+        orgCode: '',
+        orgName: '',
+        customerId: '',
+        customerCode: '',
+        customerName: '',
+        orderType: ORDER_TYPES.NORMAL,
+        totalAmount: 0,
+        totalQuantity: 0,
+        addressId: '',
+        receiverName: '',
+        receiverPhone: '',
+        receiverAddress: '',
+        receiverRegion: '',
+        status: ORDER_STATUS.DRAFT,
+        createTime: '',
+        updateTime: '',
+        submitTime: '',
+        confirmTime: ''
+      },
+
+      /**
+       * 表单验证规则
+       * @type {Object}
+       */
+      formRules: {
+        orgCode: [
+          { required: true, message: '请输入组织编码', trigger: 'blur' }
+        ],
+        orgName: [
+          { required: true, message: '请输入组织名称', trigger: 'blur' }
+        ],
+        orgId: [
+          { required: true, message: '请输入组织ID', trigger: 'blur' }
+        ],
+        customerId: [
+          { required: true, message: '请选择客户', trigger: 'change' }
+        ],
+        customerCode: [
+          { required: true, message: '请输入客户编码', trigger: 'blur' }
+        ],
+        customerName: [
+          { required: true, message: '请输入客户名称', trigger: 'blur' }
+        ],
+        orderType: [
+          { required: true, message: '请选择订单类型', trigger: 'change' }
+        ],
+        totalAmount: [
+          { required: true, message: '请输入订单总金额', trigger: 'blur' },
+          { type: 'number', min: 0, message: '订单总金额不能小于0', trigger: 'blur' }
+        ],
+        totalQuantity: [
+          { required: true, message: '请输入订单总数量', trigger: 'blur' },
+          { type: 'number', min: 0, message: '订单总数量不能小于0', trigger: 'blur' }
+        ],
+        addressId: [
+          { required: true, message: '请选择收货地址', trigger: 'change' }
+        ],
+        receiverName: [
+          { required: true, message: '请输入收货人姓名', trigger: 'blur' }
+        ],
+        receiverPhone: [
+          { required: true, message: '请输入收货人电话', trigger: 'blur' },
+          { pattern: /^1[3-9]\d{9}$/, message: '请输入正确的手机号码', trigger: 'blur' }
+        ],
+        receiverAddress: [
+          { required: true, message: '请输入收货地址详情', trigger: 'blur' }
+        ],
+        receiverRegion: [
+          { required: true, message: '请输入收货地区', trigger: 'blur' }
+        ],
+        status: [
+          { required: true, message: '请选择订单状态', trigger: 'change' }
+        ]
+      },
+
+      /**
+       * 提交加载状态
+       * @type {boolean}
+       */
+      submitLoading: false,
+
+      /**
+       * 订单类型选项
+       * @type {Array<{label: string, value: number}>}
+       */
+      orderTypeOptions: ORDER_TYPE_OPTIONS,
+
+      /**
+       * 订单状态选项
+       * @type {Array<{label: string, value: number}>}
+       */
+      orderStatusOptions: ORDER_STATUS_OPTIONS
+    }
+  },
+
+  computed: {
+    /**
+     * 是否为查看模式
+     * @returns {boolean} 是否为查看模式
+     */
+    isViewMode() {
+      return this.dialogMode === 'view'
+    },
+
+    /**
+     * 是否为编辑模式
+     * @returns {boolean} 是否为编辑模式
+     */
+    isEditMode() {
+      return this.dialogMode === 'edit'
+    },
+
+    /**
+     * 是否为新增模式
+     * @returns {boolean} 是否为新增模式
+     */
+    isAddMode() {
+      return this.dialogMode === 'add'
+    }
+  },
+
+  methods: {
+    /**
+     * 重置订单表单
+     * @returns {void}
+     */
+    resetOrderForm() {
+      this.orderForm = {
+        id: '',
+        orderCode: '',
+        orgId: '',
+        orgCode: '',
+        orgName: '',
+        customerId: '',
+        customerCode: '',
+        customerName: '',
+        orderType: ORDER_TYPES.NORMAL,
+        totalAmount: 0,
+        totalQuantity: 0,
+        addressId: '',
+        receiverName: '',
+        receiverPhone: '',
+        receiverAddress: '',
+        receiverRegion: '',
+        status: ORDER_STATUS.DRAFT,
+        createTime: '',
+        updateTime: '',
+        submitTime: '',
+        confirmTime: ''
+      }
+      
+      // 清除表单验证
+      this.$nextTick(() => {
+        if (this.$refs.orderForm) {
+          this.$refs.orderForm.clearValidate()
+        }
+      })
+    },
+
+    /**
+     * 设置表单数据
+     * @param {OrderForm} formData - 表单数据
+     * @returns {void}
+     */
+    setOrderForm(formData) {
+      this.orderForm = {
+        ...this.orderForm,
+        ...formData
+      }
+    },
+
+    /**
+     * 弹窗关闭处理
+     * @returns {void}
+     */
+    handleDialogClose() {
+      this.dialogVisible = false
+      this.resetOrderForm()
+    },
+
+    /**
+     * 显示新增弹窗
+     * @returns {void}
+     */
+    showAddDialog() {
+      this.dialogMode = 'add'
+      this.dialogTitle = '新增订单'
+      this.resetOrderForm()
+      this.dialogVisible = true
+    },
+
+    /**
+     * 显示编辑弹窗
+     * @param {OrderForm} orderData - 订单数据
+     * @returns {void}
+     */
+    showEditDialog(orderData) {
+      this.dialogMode = 'edit'
+      this.dialogTitle = '编辑订单'
+      this.setOrderForm(orderData)
+      this.dialogVisible = true
+    },
+
+    /**
+     * 显示查看弹窗
+     * @param {OrderForm} orderData - 订单数据
+     * @returns {void}
+     */
+    showViewDialog(orderData) {
+      this.dialogMode = 'view'
+      this.dialogTitle = '查看订单'
+      this.setOrderForm(orderData)
+      this.dialogVisible = true
+    },
+
+    /**
+     * 表单验证
+     * @returns {Promise<boolean>} 验证结果
+     */
+    async validateForm() {
+      try {
+        await this.$refs.orderForm.validate()
+        return true
+      } catch (error) {
+        if (error.fields) {
+          this.$message.warning('请检查表单填写是否正确')
+        }
+        return false
+      }
+    },
+
+    /**
+     * 设置提交加载状态
+     * @param {boolean} loading - 加载状态
+     * @returns {void}
+     */
+    setSubmitLoading(loading) {
+      this.submitLoading = loading
+    }
+  }
+}

+ 228 - 0
src/mixins/order/orderOperationsMixin.js

@@ -0,0 +1,228 @@
+/**
+ * 订单操作管理mixin
+ * 负责增删改查、批量操作等业务逻辑
+ */
+
+import { getList, add, update, remove, getDetail } from '@/api/order/order'
+
+export default {
+  data() {
+    return {
+      /**
+       * 明细管理弹窗显示状态
+       * @type {boolean}
+       */
+      itemDialogVisible: false,
+
+      /**
+       * 当前选中的订单
+       * @type {OrderItem|null}
+       */
+      currentOrder: null
+    }
+  },
+
+  methods: {
+    /**
+     * 加载订单列表数据
+     * @returns {Promise<void>}
+     */
+    async loadTableData() {
+      this.setLoading(true)
+      try {
+        const params = this.getSearchParams()
+        
+        const response = await getList(
+          this.pagination.currentPage,
+          this.pagination.pageSize,
+          params
+        )
+
+        if (response.data && response.data.success) {
+          const data = response.data.data
+          this.setTableData(data.records || [], data.total || 0)
+        } else {
+          this.$message.error('获取订单列表失败')
+          this.setTableData([], 0)
+        }
+      } catch (error) {
+        console.error('加载订单列表失败:', error)
+        this.$message.error('加载订单列表失败,请稍后重试')
+        this.setTableData([], 0)
+      } finally {
+        this.setLoading(false)
+      }
+    },
+
+    /**
+     * 新增订单处理
+     * @returns {void}
+     */
+    handleAdd() {
+      this.showAddDialog()
+      this.loadCustomerOptions()
+    },
+
+    /**
+     * 查看订单处理
+     * @param {OrderItem} row - 订单数据
+     * @returns {Promise<void>}
+     */
+    async handleView(row) {
+      await this.loadOrderDetail(row.id)
+      this.showViewDialog(this.orderForm)
+    },
+
+    /**
+     * 编辑订单处理
+     * @param {OrderItem} row - 订单数据
+     * @returns {Promise<void>}
+     */
+    async handleEdit(row) {
+      await this.loadOrderDetail(row.id)
+      
+      // 先加载客户选项
+      await this.loadCustomerOptions()
+      
+      // 如果当前订单有客户ID,确保该客户在选项列表中
+      if (this.orderForm.customerId && this.orderForm.customerCode) {
+        this.ensureCustomerInOptions(
+          this.orderForm.customerId,
+          this.orderForm.customerCode,
+          this.orderForm.customerName
+        )
+      }
+      
+      this.showEditDialog(this.orderForm)
+    },
+
+    /**
+     * 删除订单处理
+     * @param {OrderItem} row - 订单数据
+     * @returns {Promise<void>}
+     */
+    async handleDelete(row) {
+      try {
+        await this.$confirm('确定要删除这条订单记录吗?', '提示', {
+          confirmButtonText: '确定',
+          cancelButtonText: '取消',
+          type: 'warning'
+        })
+
+        await remove(row.id)
+        this.$message.success('删除成功')
+        this.loadTableData()
+      } catch (error) {
+        if (error !== 'cancel') {
+          console.error('删除订单失败:', error)
+          this.$message.error('删除失败,请稍后重试')
+        }
+      }
+    },
+
+    /**
+     * 批量删除处理
+     * @returns {Promise<void>}
+     */
+    async handleBatchDelete() {
+      if (!this.hasSelection) {
+        this.$message.warning('请选择要删除的订单')
+        return
+      }
+
+      try {
+        await this.$confirm(`确定要删除选中的 ${this.selectionCount} 条订单记录吗?`, '提示', {
+          confirmButtonText: '确定',
+          cancelButtonText: '取消',
+          type: 'warning'
+        })
+
+        await remove(this.ids)
+        this.$message.success('批量删除成功')
+        this.loadTableData()
+      } catch (error) {
+        if (error !== 'cancel') {
+          console.error('批量删除订单失败:', error)
+          this.$message.error('批量删除失败,请稍后重试')
+        }
+      }
+    },
+
+    /**
+     * 明细管理处理
+     * @param {OrderItem} row - 订单数据
+     * @returns {void}
+     */
+    handleItemManagement(row) {
+      this.currentOrder = row
+      this.itemDialogVisible = true
+    },
+
+    /**
+     * 明细变化处理
+     * @returns {void}
+     */
+    handleItemChanged() {
+      console.log('订单明细已更新')
+      // 可以在这里刷新订单列表或执行其他操作
+      // this.loadTableData()
+    },
+
+    /**
+     * 加载订单详情
+     * @param {string|number} orderId - 订单ID
+     * @returns {Promise<void>}
+     */
+    async loadOrderDetail(orderId) {
+      try {
+        const response = await getDetail(orderId)
+        if (response.data && response.data.success) {
+          const orderData = response.data.data
+          this.setOrderForm(orderData)
+          
+          // 如果有客户编码,加载对应的地址列表
+          if (this.orderForm.customerCode) {
+            await this.loadCustomerAddresses(this.orderForm.customerCode)
+          }
+        } else {
+          this.$message.error('获取订单详情失败')
+        }
+      } catch (error) {
+        console.error('加载订单详情失败:', error)
+        this.$message.error('加载订单详情失败,请稍后重试')
+      }
+    },
+
+    /**
+     * 表单提交处理
+     * @returns {Promise<void>}
+     */
+    async handleSubmit() {
+      try {
+        // 表单验证
+        const isValid = await this.validateForm()
+        if (!isValid) {
+          return
+        }
+        
+        this.setSubmitLoading(true)
+        
+        if (this.isAddMode) {
+          await add(this.orderForm)
+          this.$message.success('新增订单成功')
+        } else if (this.isEditMode) {
+          await update(this.orderForm)
+          this.$message.success('更新订单成功')
+        }
+        
+        this.dialogVisible = false
+        this.loadTableData()
+      } catch (error) {
+        console.error('提交订单失败:', error)
+        this.$message.error('操作失败,请稍后重试')
+      } finally {
+        this.setSubmitLoading(false)
+      }
+    }
+  }
+}

+ 125 - 0
src/mixins/order/orderSearchMixin.js

@@ -0,0 +1,125 @@
+/**
+ * 订单搜索管理mixin
+ * 负责管理搜索表单、搜索逻辑、重置等功能
+ */
+
+/**
+ * 订单查询参数类型定义
+ * @typedef {Object} OrderQueryParams
+ * @property {string} [orderCode] - 订单编码
+ * @property {string} [orgCode] - 组织编码
+ * @property {string} [orgName] - 组织名称
+ * @property {string} [customerCode] - 客户编码
+ * @property {string} [customerName] - 客户名称
+ * @property {number} [orderType] - 订单类型
+ * @property {number} [status] - 订单状态
+ * @property {string} [receiverName] - 收货人姓名
+ * @property {string} [receiverPhone] - 收货人电话
+ * @property {string} [createTimeStart] - 创建时间开始
+ * @property {string} [createTimeEnd] - 创建时间结束
+ */
+
+export default {
+  data() {
+    return {
+      /**
+       * 搜索表单数据
+       * @type {OrderQueryParams}
+       */
+      searchForm: {
+        orderCode: '',
+        orgCode: '',
+        orgName: '',
+        customerCode: '',
+        customerName: '',
+        orderType: '',
+        status: '',
+        receiverName: '',
+        receiverPhone: ''
+      }
+    }
+  },
+
+  methods: {
+    /**
+     * 搜索处理
+     * @returns {void}
+     */
+    handleSearch() {
+      this.resetPagination()
+      this.loadTableData()
+    },
+
+    /**
+     * 重置搜索
+     * @returns {void}
+     */
+    handleResetSearch() {
+      if (this.$refs.searchForm) {
+        this.$refs.searchForm.resetFields()
+      }
+      
+      this.searchForm = {
+        orderCode: '',
+        orgCode: '',
+        orgName: '',
+        customerCode: '',
+        customerName: '',
+        orderType: '',
+        status: '',
+        receiverName: '',
+        receiverPhone: ''
+      }
+      
+      this.resetPagination()
+      this.loadTableData()
+    },
+
+    /**
+     * 获取搜索参数
+     * @returns {OrderQueryParams} 过滤后的搜索参数
+     */
+    getSearchParams() {
+      const params = { ...this.searchForm }
+      
+      // 移除空值参数
+      Object.keys(params).forEach(key => {
+        if (params[key] === '' || params[key] === null || params[key] === undefined) {
+          delete params[key]
+        }
+      })
+      
+      return params
+    },
+
+    /**
+     * 设置搜索表单数据
+     * @param {OrderQueryParams} searchData - 搜索数据
+     * @returns {void}
+     */
+    setSearchForm(searchData) {
+      this.searchForm = {
+        ...this.searchForm,
+        ...searchData
+      }
+    },
+
+    /**
+     * 清空搜索表单
+     * @returns {void}
+     */
+    clearSearchForm() {
+      this.searchForm = {
+        orderCode: '',
+        orgCode: '',
+        orgName: '',
+        customerCode: '',
+        customerName: '',
+        orderType: '',
+        status: '',
+        receiverName: '',
+        receiverPhone: ''
+      }
+    }
+  }
+}

+ 176 - 0
src/mixins/order/orderUtilsMixin.js

@@ -0,0 +1,176 @@
+/**
+ * 订单工具函数mixin
+ * 负责格式化、状态转换等工具方法
+ */
+
+import {
+  getOrderTypeLabel,
+  getOrderTypeTagType,
+  getOrderStatusLabel,
+  getOrderStatusTagType
+} from '@/views/order/order/constants'
+
+export default {
+  methods: {
+    /**
+     * 获取订单类型标签
+     * @param {number} orderType - 订单类型值
+     * @returns {string} 订单类型标签
+     */
+    getOrderTypeLabel,
+
+    /**
+     * 获取订单类型标签类型
+     * @param {number} orderType - 订单类型值
+     * @returns {string} 标签类型
+     */
+    getOrderTypeTagType,
+
+    /**
+     * 获取状态标签
+     * @param {number} status - 状态值
+     * @returns {string} 状态标签
+     */
+    getStatusText: getOrderStatusLabel,
+
+    /**
+     * 获取状态标签类型
+     * @param {number} status - 状态值
+     * @returns {string} 状态标签类型
+     */
+    getStatusType: getOrderStatusTagType,
+
+    /**
+     * 格式化金额显示
+     * @param {string|number} amount - 金额
+     * @returns {string} 格式化后的金额
+     */
+    formatAmount(amount) {
+      return `¥${parseFloat(amount || 0).toFixed(2)}`
+    },
+
+    /**
+     * 格式化数量显示
+     * @param {string|number} quantity - 数量
+     * @returns {string} 格式化后的数量
+     */
+    formatQuantity(quantity) {
+      return parseFloat(quantity || 0).toFixed(4)
+    },
+
+    /**
+     * 格式化日期时间
+     * @param {string} dateTime - 日期时间字符串
+     * @returns {string} 格式化后的日期时间
+     */
+    formatDateTime(dateTime) {
+      if (!dateTime) return '-'
+      return new Date(dateTime).toLocaleString('zh-CN', {
+        year: 'numeric',
+        month: '2-digit',
+        day: '2-digit',
+        hour: '2-digit',
+        minute: '2-digit',
+        second: '2-digit'
+      })
+    },
+
+    /**
+     * 格式化日期
+     * @param {string} date - 日期字符串
+     * @returns {string} 格式化后的日期
+     */
+    formatDate(date) {
+      if (!date) return '-'
+      return new Date(date).toLocaleDateString('zh-CN')
+    },
+
+    /**
+     * 验证手机号码
+     * @param {string} phone - 手机号码
+     * @returns {boolean} 是否有效
+     */
+    validatePhone(phone) {
+      const phoneRegex = /^1[3-9]\d{9}$/
+      return phoneRegex.test(phone)
+    },
+
+    /**
+     * 验证邮箱
+     * @param {string} email - 邮箱地址
+     * @returns {boolean} 是否有效
+     */
+    validateEmail(email) {
+      const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/
+      return emailRegex.test(email)
+    },
+
+    /**
+     * 生成唯一ID
+     * @returns {string} 唯一ID
+     */
+    generateId() {
+      return Date.now().toString(36) + Math.random().toString(36).substr(2)
+    },
+
+    /**
+     * 深拷贝对象
+     * @param {Object} obj - 要拷贝的对象
+     * @returns {Object} 拷贝后的对象
+     */
+    deepClone(obj) {
+      if (obj === null || typeof obj !== 'object') {
+        return obj
+      }
+      
+      if (obj instanceof Date) {
+        return new Date(obj.getTime())
+      }
+      
+      if (obj instanceof Array) {
+        return obj.map(item => this.deepClone(item))
+      }
+      
+      if (typeof obj === 'object') {
+        const clonedObj = {}
+        for (const key in obj) {
+          if (obj.hasOwnProperty(key)) {
+            clonedObj[key] = this.deepClone(obj[key])
+          }
+        }
+        return clonedObj
+      }
+    },
+
+    /**
+     * 防抖函数
+     * @param {Function} func - 要防抖的函数
+     * @param {number} delay - 延迟时间(毫秒)
+     * @returns {Function} 防抖后的函数
+     */
+    debounce(func, delay) {
+      let timeoutId
+      return function (...args) {
+        clearTimeout(timeoutId)
+        timeoutId = setTimeout(() => func.apply(this, args), delay)
+      }
+    },
+
+    /**
+     * 节流函数
+     * @param {Function} func - 要节流的函数
+     * @param {number} delay - 延迟时间(毫秒)
+     * @returns {Function} 节流后的函数
+     */
+    throttle(func, delay) {
+      let lastCall = 0
+      return function (...args) {
+        const now = Date.now()
+        if (now - lastCall >= delay) {
+          lastCall = now
+          return func.apply(this, args)
+        }
+      }
+    }
+  }
+}

+ 17 - 863
src/views/order/order/index.vue

@@ -539,126 +539,17 @@
   </basic-container>
 </template>
 
-<script >
-import { getList, add, update, remove, getDetail, getCustomerAddressList } from '@/api/order/order'
-import { getCustomerList } from '@/api/common/index'
+<script>
 import OrderItemManagement from '@/components/order-item-management'
 import { mapGetters } from 'vuex'
-import {
-    ORDER_TYPES,
-    ORDER_STATUS,
-    ORDER_TYPE_OPTIONS,
-    ORDER_STATUS_OPTIONS,
-    getOrderTypeLabel,
-    getOrderTypeTagType,
-    getOrderStatusLabel,
-    getOrderStatusTagType
-} from '@/views/order/order/constants'
 
-/**
- * 订单类型枚举
- * @typedef {1} OrderType - 1普通订单
- */
-
-/**
- * 订单状态枚举
- * @typedef {0|1|2|3|4|5} OrderStatus - 0草稿 1已提交 2已确认 3部分发货 4已完成 5已取消
- */
-
-/**
- * 订单查询参数类型定义
- * @typedef {Object} OrderQueryParams
- * @property {string} [orderCode] - 订单编码
- * @property {string} [orgCode] - 组织编码
- * @property {string} [orgName] - 组织名称
- * @property {string} [customerCode] - 客户编码
- * @property {string} [customerName] - 客户名称
- * @property {OrderType} [orderType] - 订单类型
- * @property {OrderStatus} [status] - 订单状态
- * @property {string} [receiverName] - 收货人姓名
- * @property {string} [receiverPhone] - 收货人电话
- * @property {string} [createTimeStart] - 创建时间开始
- * @property {string} [createTimeEnd] - 创建时间结束
- */
-
-/**
- * 订单表单数据类型定义
- * @typedef {Object} OrderForm
- * @property {string|number} [id] - 订单ID(修改时必填)
- * @property {string} [orderCode] - 订单编码(系统自动生成)
- * @property {string|number} orgId - 组织ID
- * @property {string} orgCode - 组织编码
- * @property {string} orgName - 组织名称
- * @property {string|number} customerId - 客户ID
- * @property {string} customerCode - 客户编码
- * @property {string} customerName - 客户名称
- * @property {OrderType} orderType - 订单类型
- * @property {number|string} totalAmount - 订单总金额
- * @property {number|string} totalQuantity - 订单总数量
- * @property {string|number} addressId - 收货地址ID
- * @property {string} receiverName - 收货人姓名
- * @property {string} receiverPhone - 收货人电话
- * @property {string} receiverAddress - 收货详细地址
- * @property {string} receiverRegion - 收货地区
- * @property {OrderStatus} status - 订单状态
- */
-
-/**
- * 订单列表项类型定义
- * @typedef {Object} OrderItem
- * @property {string} id - 订单ID
- * @property {string} createUser - 创建用户ID
- * @property {string} createDept - 创建部门ID
- * @property {string} createTime - 创建时间
- * @property {string} updateUser - 更新用户ID
- * @property {string} updateTime - 更新时间
- * @property {number} status - 订单状态 0-草稿 1-已提交 2-已确认 3-已完成 4-已取消
- * @property {number} isDeleted - 是否删除 0-未删除 1-已删除
- * @property {string} orderCode - 订单编码
- * @property {number} orgId - 组织ID
- * @property {string} orgCode - 组织编码
- * @property {string} orgName - 组织名称
- * @property {number} customerId - 客户ID
- * @property {string} customerCode - 客户编码
- * @property {string} customerName - 客户名称
- * @property {number} orderType - 订单类型 0-采购订单 1-销售订单
- * @property {string} totalAmount - 订单总金额
- * @property {string} totalQuantity - 订单总数量
- * @property {number} addressId - 收货地址ID
- * @property {string} receiverName - 收货人姓名
- * @property {string} receiverPhone - 收货人电话
- * @property {string} receiverAddress - 收货详细地址
- * @property {string} receiverRegion - 收货地区
- * @property {string|null} submitTime - 提交时间
- * @property {string|null} confirmTime - 确认时间
- */
-
-/**
- * 客户选项类型定义
- * @typedef {Object} CustomerOption
- * @property {string} value - 客户编码
- * @property {string} label - 显示标签(客户编码 - 客户名称)
- * @property {string} customerCode - 客户编码
- * @property {string} customerName - 客户名称
- * @property {string} customerId - 客户ID
- */
-
-/**
- * 客户地址选项类型定义
- * @typedef {Object} CustomerAddressOption
- * @property {number} value - 地址ID
- * @property {string} label - 地址显示文本
- * @property {string} receiverName - 收货人姓名
- * @property {string} receiverPhone - 收货人电话
- * @property {string} receiverAddress - 收货详细地址
- * @property {string} receiverRegion - 收货地区
- * @property {number} isDefault - 是否默认地址 0-否 1-是
- */
-
-/**
- * 弹窗模式类型定义
- * @typedef {'add'|'edit'|'view'} DialogMode
- */
+// 导入所有mixin
+import orderDataMixin from '@/mixins/order/orderDataMixin'
+import orderSearchMixin from '@/mixins/order/orderSearchMixin'
+import orderFormMixin from '@/mixins/order/orderFormMixin'
+import customerManagementMixin from '@/mixins/order/customerManagementMixin'
+import orderOperationsMixin from '@/mixins/order/orderOperationsMixin'
+import orderUtilsMixin from '@/mixins/order/orderUtilsMixin'
 
 export default {
   name: 'OrderManagement',
@@ -667,760 +558,23 @@ export default {
     OrderItemManagement
   },
 
-  data() {
-    return {
-      /**
-       * 过滤后的客户选项列表
-       * @type {CustomerOption[]}
-       */
-      filteredCustomerOptions: [],
-      /**
-       * 表格数据
-       * @type {OrderItem[]}
-       */
-      tableData: [],
-
-      /**
-       * 加载状态
-       * @type {boolean}
-       */
-      loading: false,
-
-      /**
-       * 搜索表单数据
-       * @type {OrderQueryParams}
-       */
-      searchForm: {
-        orderCode: '',
-        orgCode: '',
-        orgName: '',
-        customerCode: '',
-        customerName: '',
-        orderType: '',
-        status: '',
-        receiverName: '',
-        receiverPhone: ''
-      },
-
-      /**
-       * 分页信息
-       * @type {{currentPage: number, pageSize: number, total: number}}
-       */
-      pagination: {
-        currentPage: 1,
-        pageSize: 10,
-        total: 0
-      },
-
-      /**
-       * 选中的行数据
-       * @type {OrderItem[]}
-       */
-      selectionList: [],
-
-      /**
-       * 弹窗显示状态
-       * @type {boolean}
-       */
-      dialogVisible: false,
-
-      /**
-       * 弹窗模式
-       * @type {DialogMode}
-       */
-      dialogMode: 'add',
-
-      /**
-       * 弹窗标题
-       * @type {string}
-       */
-      dialogTitle: '',
-
-      /**
-       * 订单表单数据
-       * @type {OrderForm}
-       */
-      orderForm: {
-        id: '',
-        orderCode: '',
-        orgId: '',
-        orgCode: '',
-        orgName: '',
-        customerId: '',
-        customerCode: '',
-        customerName: '',
-        orderType: ORDER_TYPES.NORMAL,
-        totalAmount: 0,
-        totalQuantity: 0,
-        addressId: '',
-        receiverName: '',
-        receiverPhone: '',
-        receiverAddress: '',
-        receiverRegion: '',
-        status: ORDER_STATUS.DRAFT,
-        createTime: '',
-        updateTime: '',
-        submitTime: '',
-        confirmTime: ''
-      },
-
-      /**
-       * 表单验证规则
-       * @type {Object}
-       */
-      formRules: {
-        orgCode: [
-          { required: true, message: '请输入组织编码', trigger: 'blur' }
-        ],
-        orgName: [
-          { required: true, message: '请输入组织名称', trigger: 'blur' }
-        ],
-        orgId: [
-          { required: true, message: '请输入组织ID', trigger: 'blur' }
-        ],
-        customerId: [
-          { required: true, message: '请选择客户', trigger: 'change' }
-        ],
-        customerCode: [
-          { required: true, message: '请输入客户编码', trigger: 'blur' }
-        ],
-        customerName: [
-          { required: true, message: '请输入客户名称', trigger: 'blur' }
-        ],
-        orderType: [
-          { required: true, message: '请选择订单类型', trigger: 'change' }
-        ],
-        totalAmount: [
-          { required: true, message: '请输入订单总金额', trigger: 'blur' },
-          { type: 'number', min: 0, message: '订单总金额不能小于0', trigger: 'blur' }
-        ],
-        totalQuantity: [
-          { required: true, message: '请输入订单总数量', trigger: 'blur' },
-          { type: 'number', min: 0, message: '订单总数量不能小于0', trigger: 'blur' }
-        ],
-        addressId: [
-          { required: true, message: '请选择收货地址', trigger: 'change' }
-        ],
-        receiverName: [
-          { required: true, message: '请输入收货人姓名', trigger: 'blur' }
-        ],
-        receiverPhone: [
-          { required: true, message: '请输入收货人电话', trigger: 'blur' },
-          { pattern: /^1[3-9]\d{9}$/, message: '请输入正确的手机号码', trigger: 'blur' }
-        ],
-        receiverAddress: [
-          { required: true, message: '请输入收货地址详情', trigger: 'blur' }
-        ],
-        receiverRegion: [
-          { required: true, message: '请输入收货地区', trigger: 'blur' }
-        ],
-        status: [
-          { required: true, message: '请选择订单状态', trigger: 'change' }
-        ]
-      },
-
-      /**
-       * 提交加载状态
-       * @type {boolean}
-       */
-      submitLoading: false,
-
-      /**
-       * 客户选项列表
-       * @type {CustomerOption[]}
-       */
-      customerOptions: [],
-
-      /**
-       * 客户选项加载状态
-       * @type {boolean}
-       */
-      customerLoading: false,
-
-      /**
-       * 客户搜索定时器
-       * @type {number|null}
-       */
-      customerSearchTimer: null,
-
-      /**
-       * 客户地址选项列表
-       * @type {CustomerAddressOption[]}
-       */
-      addressOptions: [],
-
-      /**
-       * 订单类型选项
-       * @type {Array<{label: string, value: number}>}
-       */
-      orderTypeOptions: ORDER_TYPE_OPTIONS,
-
-      /**
-       * 订单状态选项
-       * @type {Array<{label: string, value: number}>}
-       */
-      orderStatusOptions: ORDER_STATUS_OPTIONS,
-
-      /**
-       * 明细管理弹窗显示状态
-       * @type {boolean}
-       */
-      itemDialogVisible: false,
-
-      /**
-       * 当前选中的订单
-       * @type {OrderItem|null}
-       */
-      currentOrder: null
-    }
-  },
+  mixins: [
+    orderDataMixin,
+    orderSearchMixin,
+    orderFormMixin,
+    customerManagementMixin,
+    orderOperationsMixin,
+    orderUtilsMixin
+  ],
 
   computed: {
-    ...mapGetters(['permission']),
-
-    /**
-     * 选中的ID字符串
-     * @returns {string} 逗号分隔的ID字符串
-     */
-    ids() {
-      return this.selectionList.map(item => item.id).join(',')
-    }
-  },
-
-  methods: {
-
-  /**
-   * 本地过滤客户选项
-   * @param {string} query - 搜索关键词
-   * @returns {void}
-   */
-  filterCustomers(query) {
-    if (query) {
-      const keyword = query.toLowerCase()
-      this.filteredCustomerOptions = this.customerOptions.filter(option => {
-        return option.label.toLowerCase().includes(keyword) ||
-               option.customerCode.toLowerCase().includes(keyword) ||
-               option.customerName.toLowerCase().includes(keyword)
-      })
-    } else {
-      this.filteredCustomerOptions = [...this.customerOptions]
-    }
-  },
-    /**
-     * 获取订单类型标签
-     * @param {OrderType} orderType - 订单类型值
-     * @returns {string} 订单类型标签
-     */
-    getOrderTypeLabel,
-
-    /**
-     * 获取订单类型标签类型
-     * @param {OrderType} orderType - 订单类型值
-     * @returns {string} 标签类型
-     */
-    getOrderTypeTagType,
-
-    /**
-     * 获取状态标签
-     * @param {OrderStatus} status - 状态值
-     * @returns {string} 状态标签
-     */
-    getStatusText: getOrderStatusLabel,
-
-    /**
-     * 获取状态标签类型
-     * @param {OrderStatus} status - 状态值
-     * @returns {string} 状态标签类型
-     */
-    getStatusType: getOrderStatusTagType,
-
-    /**
-     * 加载订单列表数据
-     * @returns {Promise<void>}
-     */
-    async loadTableData() {
-      this.loading = true
-      try {
-        const params = {
-          ...this.searchForm
-        }
-        
-        // 移除空值参数
-        Object.keys(params).forEach(key => {
-          if (params[key] === '' || params[key] === null || params[key] === undefined) {
-            delete params[key]
-          }
-        })
-
-        const response = await getList(
-          this.pagination.currentPage,
-          this.pagination.pageSize,
-          params
-        )
-
-        if (response.data && response.data.success) {
-          const data = response.data.data
-          this.tableData = data.records || []
-          this.pagination.total = data.total || 0
-        } else {
-          this.$message.error('获取订单列表失败')
-          this.tableData = []
-          this.pagination.total = 0
-        }
-      } catch (error) {
-        console.error('加载订单列表失败:', error)
-        this.$message.error('加载订单列表失败,请稍后重试')
-        this.tableData = []
-        this.pagination.total = 0
-      } finally {
-        this.loading = false
-      }
-    },
-
-    /**
-     * 搜索处理
-     * @returns {void}
-     */
-    handleSearch() {
-      this.pagination.currentPage = 1
-      this.loadTableData()
-    },
-
-    /**
-     * 重置搜索
-     * @returns {void}
-     */
-    handleResetSearch() {
-      this.$refs.searchForm.resetFields()
-      this.searchForm = {
-        orderCode: '',
-        orgCode: '',
-        orgName: '',
-        customerCode: '',
-        customerName: '',
-        orderType: '',
-        status: '',
-        receiverName: '',
-        receiverPhone: ''
-      }
-      this.pagination.currentPage = 1
-      this.loadTableData()
-    },
-
-    /**
-     * 选择改变处理
-     * @param {OrderItem[]} selection - 选中的数据
-     * @returns {void}
-     */
-    handleSelectionChange(selection) {
-      this.selectionList = selection
-    },
-
-    /**
-     * 页大小改变处理
-     * @param {number} pageSize - 新的页大小
-     * @returns {void}
-     */
-    handleSizeChange(pageSize) {
-      this.pagination.pageSize = pageSize
-      this.pagination.currentPage = 1
-      this.loadTableData()
-    },
-
-    /**
-     * 当前页改变处理
-     * @param {number} currentPage - 新的当前页
-     * @returns {void}
-     */
-    handleCurrentChange(currentPage) {
-      this.pagination.currentPage = currentPage
-      this.loadTableData()
-    },
-
-    /**
-     * 新增订单处理
-     * @returns {void}
-     */
-    handleAdd() {
-      this.dialogMode = 'add'
-      this.dialogTitle = '新增订单'
-      this.resetOrderForm()
-      this.dialogVisible = true
-      this.loadCustomerOptions()
-    },
-
-    /**
-     * 查看订单处理
-     * @param {OrderItem} row - 订单数据
-     * @returns {Promise<void>}
-     */
-    async handleView(row) {
-      this.dialogMode = 'view'
-      this.dialogTitle = '查看订单'
-      await this.loadOrderDetail(row.id)
-      this.dialogVisible = true
-    },
-
-    /**
-     * 编辑订单处理
-     * @param {OrderItem} row - 订单数据
-     * @returns {Promise<void>}
-     */
-    async handleEdit(row) {
-      this.dialogMode = 'edit'
-      this.dialogTitle = '编辑订单'
-      await this.loadOrderDetail(row.id)
-      
-      // 先加载客户选项
-      await this.loadCustomerOptions()
-      
-      // 如果当前订单有客户ID,确保该客户在选项列表中
-      if (this.orderForm.customerId && this.orderForm.customerCode) {
-        const existingCustomer = this.customerOptions.find(option => 
-          option.value.toString() === this.orderForm.customerId.toString()
-        )
-        
-        // 如果当前客户不在选项列表中,添加它
-        if (!existingCustomer) {
-          this.customerOptions.unshift({
-            value: this.orderForm.customerId.toString(),
-            label: `${this.orderForm.customerCode} - ${this.orderForm.customerName}`,
-            customerCode: this.orderForm.customerCode,
-            customerName: this.orderForm.customerName,
-            customerId: this.orderForm.customerId.toString()
-          })
-        }
-      }
-      
-      this.dialogVisible = true
-    },
-
-    /**
-     * 删除订单处理
-     * @param {OrderItem} row - 订单数据
-     * @returns {Promise<void>}
-     */
-    async handleDelete(row) {
-      try {
-        await this.$confirm('确定要删除这条订单记录吗?', '提示', {
-          confirmButtonText: '确定',
-          cancelButtonText: '取消',
-          type: 'warning'
-        })
-
-        await remove(row.id)
-        this.$message.success('删除成功')
-        this.loadTableData()
-      } catch (error) {
-        if (error !== 'cancel') {
-          console.error('删除订单失败:', error)
-          this.$message.error('删除失败,请稍后重试')
-        }
-      }
-    },
-
-    /**
-     * 批量删除处理
-     * @returns {Promise<void>}
-     */
-    async handleBatchDelete() {
-      if (this.selectionList.length === 0) {
-        this.$message.warning('请选择要删除的订单')
-        return
-      }
-
-      try {
-        await this.$confirm(`确定要删除选中的 ${this.selectionList.length} 条订单记录吗?`, '提示', {
-          confirmButtonText: '确定',
-          cancelButtonText: '取消',
-          type: 'warning'
-        })
-
-        await remove(this.ids)
-        this.$message.success('批量删除成功')
-        this.loadTableData()
-      } catch (error) {
-        if (error !== 'cancel') {
-          console.error('批量删除订单失败:', error)
-          this.$message.error('批量删除失败,请稍后重试')
-        }
-      }
-    },
-
-    /**
-     * 明细管理处理
-     * @param {OrderItem} row - 订单数据
-     * @returns {void}
-     */
-    handleItemManagement(row) {
-      this.currentOrder = row
-      this.itemDialogVisible = true
-    },
-
-    /**
-     * 明细变化处理
-     * @returns {void}
-     */
-    handleItemChanged() {
-      console.log('订单明细已更新')
-      // 可以在这里刷新订单列表或执行其他操作
-      // this.loadTableData()
-    },
-
-    /**
-     * 加载订单详情
-     * @param {string|number} orderId - 订单ID
-     * @returns {Promise<void>}
-     */
-    async loadOrderDetail(orderId) {
-      try {
-        const response = await getDetail(orderId)
-        if (response.data && response.data.success) {
-          const orderData = response.data.data
-          this.orderForm = { ...orderData }
-          
-          // 如果有客户编码,加载对应的地址列表
-          if (this.orderForm.customerCode) {
-            await this.loadCustomerAddresses(this.orderForm.customerCode)
-          }
-        } else {
-          this.$message.error('获取订单详情失败')
-        }
-      } catch (error) {
-        console.error('加载订单详情失败:', error)
-        this.$message.error('加载订单详情失败,请稍后重试')
-      }
-    },
-
-    /**
-     * 重置订单表单
-     * @returns {void}
-     */
-    resetOrderForm() {
-      this.orderForm = {
-        id: '',
-        orderCode: '',
-        orgId: '',
-        orgCode: '',
-        orgName: '',
-        customerId: '',
-        customerCode: '',
-        customerName: '',
-        orderType: ORDER_TYPES.NORMAL,
-        totalAmount: 0,
-        totalQuantity: 0,
-        addressId: '',
-        receiverName: '',
-        receiverPhone: '',
-        receiverAddress: '',
-        receiverRegion: '',
-        status: ORDER_STATUS.DRAFT,
-        createTime: '',
-        updateTime: '',
-        submitTime: '',
-        confirmTime: ''
-      }
-      this.addressOptions = []
-      
-      // 清除表单验证
-      this.$nextTick(() => {
-        if (this.$refs.orderForm) {
-          this.$refs.orderForm.clearValidate()
-        }
-      })
-    },
-
-    /**
-     * 弹窗关闭处理
-     * @returns {void}
-     */
-    handleDialogClose() {
-      this.dialogVisible = false
-      this.resetOrderForm()
-    },
-
-    /**
-     * 表单提交处理
-     * @returns {Promise<void>}
-     */
-    async handleSubmit() {
-      try {
-        // 表单验证
-        await this.$refs.orderForm.validate()
-        
-        this.submitLoading = true
-        
-        if (this.dialogMode === 'add') {
-          await add(this.orderForm)
-          this.$message.success('新增订单成功')
-        } else if (this.dialogMode === 'edit') {
-          await update(this.orderForm)
-          this.$message.success('更新订单成功')
-        }
-        
-        this.dialogVisible = false
-        this.loadTableData()
-      } catch (error) {
-        if (error.fields) {
-          // 表单验证失败
-          this.$message.warning('请检查表单填写是否正确')
-        } else {
-          console.error('提交订单失败:', error)
-          this.$message.error('操作失败,请稍后重试')
-        }
-      } finally {
-        this.submitLoading = false
-      }
-    },
-
-    /**
-     * 加载客户选项列表
-     * @param {string} keyword - 搜索关键词
-     * @returns {Promise<void>}
-     */
-    async loadCustomerOptions(keyword = '') {
-      try {
-        this.customerLoading = true
-        const params = {}
-
-        // 如果有搜索关键词,添加到查询参数中
-        if (keyword.trim()) {
-          params.Customer_CODE = keyword
-          params.Customer_NAME = keyword
-        }
-
-        const response = await getCustomerList(1, 50, params)
-
-        if (response.data && response.data.success) {
-          const customers = response.data.data.records || []
-          this.customerOptions = customers.map(customer => ({
-            value: customer.Customer_ID.toString(), // 统一转换为字符串
-            label: `${customer.Customer_CODE} - ${customer.Customer_NAME}`,
-            customerCode: customer.Customer_CODE,
-            customerName: customer.Customer_NAME,
-            customerId: customer.Customer_ID.toString()
-          }))
-        } else {
-          this.customerOptions = []
-          this.$message.warning('获取客户列表失败')
-        }
-      } catch (error) {
-        this.customerOptions = []
-        console.error('加载客户选项失败:', error)
-        this.$message.error('加载客户选项失败,请稍后重试')
-      } finally {
-        this.customerLoading = false
-      }
-    },
-
-    /**
-     * 搜索客户(防抖处理)
-     * @param {string} query - 搜索关键词
-     * @returns {void}
-     */
-    searchCustomers(query) {
-      // 清除之前的定时器
-      if (this.customerSearchTimer) {
-        clearTimeout(this.customerSearchTimer)
-      }
-
-      // 设置新的定时器,300ms后执行搜索
-      this.customerSearchTimer = setTimeout(() => {
-        this.loadCustomerOptions(query)
-      }, 300)
-    },
-
-    /**
-     * 客户选择变更处理
-     * @param {string|number} value - 选中的客户ID
-     * @returns {void}
-     */
-    handleCustomerChange(value) {
-      if (value) {
-        const selectedCustomer = this.customerOptions.find(option => option.value === value)
-        if (selectedCustomer) {
-          // 自动填充客户信息
-          this.orderForm.customerId = selectedCustomer.customerId
-          this.orderForm.customerCode = selectedCustomer.customerCode
-          this.orderForm.customerName = selectedCustomer.customerName
-          // 加载客户地址
-          this.loadCustomerAddresses(selectedCustomer.customerCode)
-        } else {
-          this.clearCustomerData()
-        }
-      } else {
-        this.clearCustomerData()
-      }
-    },
-
-    /**
-     * 清除客户相关数据
-     * @returns {void}
-     */
-    clearCustomerData() {
-      this.orderForm.customerName = ''
-      this.orderForm.customerId = ''
-      this.addressOptions = []
-      this.orderForm.addressId = ''
-      this.orderForm.receiverName = ''
-      this.orderForm.receiverPhone = ''
-      this.orderForm.receiverAddress = ''
-      this.orderForm.receiverRegion = ''
-    },
-
-    /**
-     * 根据客户编码加载客户地址列表
-     * @param {string} customerCode - 客户编码
-     * @returns {Promise<void>}
-     */
-    async loadCustomerAddresses(customerCode) {
-      try {
-        const response = await getCustomerAddressList(customerCode)
-        const addresses = response.data.data.records || []
-        this.addressOptions = addresses.map(addr => ({
-          value: addr.id,
-          label: `${addr.receiverName} - ${addr.receiverPhone} - ${addr.regionName} ${addr.detailAddress}`,
-          receiverName: addr.receiverName,
-          receiverPhone: addr.receiverPhone,
-          receiverAddress: addr.detailAddress,
-          receiverRegion: addr.regionName,
-          isDefault: addr.isDefault
-        }))
-      } catch (error) {
-        this.addressOptions = []
-        console.error('加载客户地址失败:', error)
-      }
-    },
-
-    /**
-     * 地址选择变更处理
-     * @param {number} value - 选中的地址ID
-     * @returns {void}
-     */
-    handleAddressChange(value) {
-      if (value) {
-        const selectedAddress = this.addressOptions.find(addr => addr.value === value)
-        if (selectedAddress) {
-          this.orderForm.receiverName = selectedAddress.receiverName
-          this.orderForm.receiverPhone = selectedAddress.receiverPhone
-          this.orderForm.receiverAddress = selectedAddress.receiverAddress
-          this.orderForm.receiverRegion = selectedAddress.receiverRegion
-        }
-      }
-    }
+    ...mapGetters(['permission'])
   },
 
   mounted() {
     // 初始化加载数据
     this.loadTableData()
     this.loadCustomerOptions()
-  },
-
-  beforeDestroy() {
-    // 清理定时器
-    if (this.customerSearchTimer) {
-      clearTimeout(this.customerSearchTimer)
-    }
   }
 }
 </script>