diff --git a/src/pages/order/create.vue b/src/pages/order/create.vue
index a2e8ba3..9fb97ff 100644
--- a/src/pages/order/create.vue
+++ b/src/pages/order/create.vue
@@ -6,11 +6,25 @@
👤
客户信息
+
+ 客户种类
+
+
+ {{ selectedTypeLabel || '请选择客户种类' }}
+ ›
+
+
+
客户
@@ -166,6 +180,15 @@ import customerApi from '@/api/customer'
export default {
data() {
return {
+ // 客户种类
+ typeOptions: [
+ { label: '顾客', value: 'customer' },
+ { label: '木匠', value: 'carpenter' },
+ { label: '装修公司', value: 'company' }
+ ],
+ selectedType: 'customer',
+ selectedTypeLabel: '顾客',
+
// 客户相关
customers: [],
selectedCustomer: null,
@@ -188,7 +211,8 @@ export default {
// 编辑模式
editingOrderId: null,
- tempCustomerId: null // 临时保存编辑时的客户ID
+ tempCustomerId: null, // 临时保存编辑时的客户ID
+ tempCustomerType: null // 临时保存编辑时的客户种类
}
},
onLoad(options) {
@@ -204,14 +228,20 @@ export default {
}, 500)
}
},
+ computed: {
+ filteredCustomers() {
+ return this.customers.filter(c => c.type === this.selectedType)
+ }
+ },
methods: {
async loadOrder(orderId) {
try {
const detail = await orderApi.getOrderDetail(orderId)
const order = detail.order
- // 先保存 customerId,等 customers 加载完成后匹配
+ // 先保存 customerId,等客户列表加载完成后再匹配
this.tempCustomerId = order.customerId
+ this.tempCustomerType = order.customerType
this.orderItems = (detail.items || []).map(item => ({
productId: item.productId,
@@ -238,6 +268,13 @@ export default {
matchCustomer() {
if (this.tempCustomerId && this.customers.length > 0) {
this.selectedCustomer = this.customers.find(c => c.customerId === this.tempCustomerId)
+ if (this.tempCustomerType) {
+ this.selectedType = this.tempCustomerType
+ const typeOption = this.typeOptions.find(t => t.value === this.tempCustomerType)
+ if (typeOption) {
+ this.selectedTypeLabel = typeOption.label
+ }
+ }
}
},
async loadCustomers() {
@@ -259,7 +296,14 @@ export default {
}
},
selectCustomer(e) {
- this.selectedCustomer = this.customers[e.detail.value]
+ this.selectedCustomer = this.filteredCustomers[e.detail.value]
+ },
+ selectType(e) {
+ const idx = e.detail.value
+ this.selectedType = this.typeOptions[idx].value
+ this.selectedTypeLabel = this.typeOptions[idx].label
+ // 切换种类后清除已选客户
+ this.selectedCustomer = null
},
goToSelectProduct() {
uni.navigateTo({ url: '/pages/product/select' })