提交
This commit is contained in:
1 parent
012a2ad68e
commit
5fe53c5481
4775 files changed
+2190111
-40277
No files matched your search
@@ -27,7 +27,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { fetchCustomerList } from '@/api/crm/customer'
|
||||
import { fetchCustomerOptions } from '@/api/crm/customer'
|
||||
|
||||
defineOptions({ name: 'DbCrmCustomerSelect' })
|
||||
|
||||
@@ -53,17 +53,18 @@
|
||||
const loading = ref(false)
|
||||
const options = ref<CustomerOption[]>([])
|
||||
|
||||
const extractList = (res: unknown): CustomerOption[] => {
|
||||
const data = (res as { data?: { list?: CustomerOption[]; rows?: CustomerOption[] } })?.data ?? res ?? {}
|
||||
const payload = data as { list?: CustomerOption[]; rows?: CustomerOption[] }
|
||||
const extractOptions = (res: unknown): CustomerOption[] => {
|
||||
const unwrapped = (res as { data?: unknown })?.data ?? res
|
||||
if (Array.isArray(unwrapped)) return unwrapped as CustomerOption[]
|
||||
const payload = (unwrapped as { list?: CustomerOption[]; rows?: CustomerOption[] }) || {}
|
||||
return payload.list || payload.rows || []
|
||||
}
|
||||
|
||||
const loadDefault = async () => {
|
||||
loading.value = true
|
||||
try {
|
||||
const res = await fetchCustomerList({ page: 1, pageSize: 20 })
|
||||
options.value = extractList(res)
|
||||
const res = await fetchCustomerOptions({ limit: 20 })
|
||||
options.value = extractOptions(res)
|
||||
} catch (error) {
|
||||
console.error('加载 CRM 客户列表失败', error)
|
||||
options.value = []
|
||||
@@ -79,12 +80,11 @@
|
||||
}
|
||||
loading.value = true
|
||||
try {
|
||||
const res = await fetchCustomerList({
|
||||
customerName: query.trim(),
|
||||
page: 1,
|
||||
pageSize: 50
|
||||
const res = await fetchCustomerOptions({
|
||||
keyword: query.trim(),
|
||||
limit: 50
|
||||
})
|
||||
options.value = extractList(res)
|
||||
options.value = extractOptions(res)
|
||||
} catch (error) {
|
||||
console.error('搜索 CRM 客户失败', error)
|
||||
options.value = []
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { fetchProductDetail, fetchProductList } from '@/api/crm/product'
|
||||
import { fetchProductDetail, fetchProductOptions } from '@/api/crm/product'
|
||||
import { useDictStore } from '@/store/modules/dict'
|
||||
|
||||
defineOptions({ name: 'DbCrmProductSelect' })
|
||||
@@ -71,10 +71,15 @@
|
||||
return parts.join(' · ')
|
||||
}
|
||||
|
||||
const extractList = (res: unknown): ProductOption[] => {
|
||||
const data =
|
||||
(res as { data?: { list?: ProductOption[]; rows?: ProductOption[] } })?.data ?? res ?? {}
|
||||
const payload = data as { list?: ProductOption[]; rows?: ProductOption[] }
|
||||
const extractOptions = (res: unknown): ProductOption[] => {
|
||||
const unwrapped = (res as { data?: unknown })?.data ?? res
|
||||
if (Array.isArray(unwrapped)) {
|
||||
return (unwrapped as Array<ProductOption & { label?: string }>).map((item) => ({
|
||||
...item,
|
||||
productName: item.productName || item.label || ''
|
||||
}))
|
||||
}
|
||||
const payload = (unwrapped as { list?: ProductOption[]; rows?: ProductOption[] }) || {}
|
||||
return payload.list || payload.rows || []
|
||||
}
|
||||
|
||||
@@ -108,8 +113,8 @@
|
||||
const loadDefault = async () => {
|
||||
loading.value = true
|
||||
try {
|
||||
const res = await fetchProductList({ page: 1, pageSize: 20, status: 'on' })
|
||||
options.value = extractList(res)
|
||||
const res = await fetchProductOptions({ limit: 20 })
|
||||
options.value = extractOptions(res)
|
||||
await ensureCurrentOption()
|
||||
} catch (error) {
|
||||
console.error('加载 CRM 产品列表失败', error)
|
||||
@@ -126,13 +131,11 @@
|
||||
}
|
||||
loading.value = true
|
||||
try {
|
||||
const res = await fetchProductList({
|
||||
const res = await fetchProductOptions({
|
||||
keyword: query.trim(),
|
||||
page: 1,
|
||||
pageSize: 50,
|
||||
status: 'on'
|
||||
limit: 50
|
||||
})
|
||||
options.value = extractList(res)
|
||||
options.value = extractOptions(res)
|
||||
await ensureCurrentOption()
|
||||
} catch (error) {
|
||||
console.error('搜索 CRM 产品失败', error)
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
</el-form-item>
|
||||
|
||||
<div v-if="showVehicleFields" class="form-grid-4">
|
||||
<el-form-item label="承运商" required>
|
||||
<el-form-item label="承运商">
|
||||
<el-select
|
||||
v-model="carrierId"
|
||||
placeholder="请选择承运商"
|
||||
@@ -301,10 +301,6 @@
|
||||
ElMessage.warning('请填写主车车牌')
|
||||
return
|
||||
}
|
||||
if (showVehicleFields.value && !carrierId.value) {
|
||||
ElMessage.warning('请选择承运商')
|
||||
return
|
||||
}
|
||||
if (
|
||||
props.mode === 'personnel-first' &&
|
||||
!driverForm.personnelName.trim() &&
|
||||
@@ -342,7 +338,7 @@
|
||||
licensePlate: vehicleForm.licensePlate.trim(),
|
||||
trailerNo: vehicleForm.trailerNo || undefined,
|
||||
loadCapacity: vehicleForm.loadCapacity ?? undefined,
|
||||
carrierId: carrierId.value,
|
||||
carrierId: carrierId.value || undefined,
|
||||
carrierName: carrier?.carrierName
|
||||
}
|
||||
: null,
|
||||
|
||||
Reference in new issue
Block a user