|
@@ -4,26 +4,45 @@ import axios from 'axios'
|
|
|
|
|
|
|
|
const props = defineProps({
|
|
const props = defineProps({
|
|
|
data: {
|
|
data: {
|
|
|
- type: Array as () => string[],
|
|
|
|
|
- default: () => []
|
|
|
|
|
|
|
+ type: Object as () => {
|
|
|
|
|
+ customerCode: string[]
|
|
|
|
|
+ customerType: string[]
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ default: () => {
|
|
|
|
|
+ return {
|
|
|
|
|
+ customerCode: [],
|
|
|
|
|
+ customerType: []
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
-const selectData = ref<string[]>([])
|
|
|
|
|
|
|
+const customerInfo = ref({
|
|
|
|
|
+ customerCode: [] as string[],
|
|
|
|
|
+ customerType: [] as string[]
|
|
|
|
|
+})
|
|
|
|
|
+// const customerCode = ref<string[]>([])
|
|
|
|
|
+// const customerType = ref<string[]>([])
|
|
|
watch(
|
|
watch(
|
|
|
() => props.data,
|
|
() => props.data,
|
|
|
(newValue) => {
|
|
(newValue) => {
|
|
|
- selectData.value = cloneDeep(newValue) || []
|
|
|
|
|
|
|
+ // customerCode.value = cloneDeep(newValue.customerCode) || []
|
|
|
|
|
+ // customerType.value = cloneDeep(newValue.customerType) || []
|
|
|
|
|
+ console.log(newValue, 'newValue')
|
|
|
|
|
+ customerInfo.value = cloneDeep(newValue) || {
|
|
|
|
|
+ customerCode: [],
|
|
|
|
|
+ customerType: []
|
|
|
|
|
+ }
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
deep: true,
|
|
deep: true,
|
|
|
immediate: true
|
|
immediate: true
|
|
|
}
|
|
}
|
|
|
)
|
|
)
|
|
|
-const emit = defineEmits(['changeData'])
|
|
|
|
|
-const changeData = (val: string[]) => {
|
|
|
|
|
|
|
+const emit = defineEmits(['changeCustomerData'])
|
|
|
|
|
+const changeData = (val: string[], type: string) => {
|
|
|
// 同步选中状态
|
|
// 同步选中状态
|
|
|
- emit('changeData', val)
|
|
|
|
|
|
|
+ emit('changeCustomerData', val, type)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
interface ListItem {
|
|
interface ListItem {
|
|
@@ -35,6 +54,9 @@ const options = ref<ListItem[]>([])
|
|
|
const loading = ref(false)
|
|
const loading = ref(false)
|
|
|
const currentController = ref<AbortController | null>(null)
|
|
const currentController = ref<AbortController | null>(null)
|
|
|
|
|
|
|
|
|
|
+const handleVisibleChange = (visible) => {
|
|
|
|
|
+ !visible && (options.value = [])
|
|
|
|
|
+}
|
|
|
const remoteMethod = (query: string) => {
|
|
const remoteMethod = (query: string) => {
|
|
|
currentController.value?.abort()
|
|
currentController.value?.abort()
|
|
|
|
|
|
|
@@ -73,7 +95,6 @@ onUnmounted(() => {
|
|
|
currentController.value?.abort()
|
|
currentController.value?.abort()
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
-const type = ref('')
|
|
|
|
|
const typeOptions = ref([
|
|
const typeOptions = ref([
|
|
|
{
|
|
{
|
|
|
label: 'Shipper',
|
|
label: 'Shipper',
|
|
@@ -101,16 +122,20 @@ const typeOptions = ref([
|
|
|
<template>
|
|
<template>
|
|
|
<div class="customer-filter">
|
|
<div class="customer-filter">
|
|
|
<el-select
|
|
<el-select
|
|
|
- :model-value="selectData"
|
|
|
|
|
|
|
+ :model-value="customerInfo.customerCode"
|
|
|
multiple
|
|
multiple
|
|
|
filterable
|
|
filterable
|
|
|
reserve-keyword
|
|
reserve-keyword
|
|
|
placeholder="Search by Customer code, Customer name"
|
|
placeholder="Search by Customer code, Customer name"
|
|
|
:loading="loading"
|
|
:loading="loading"
|
|
|
style="width: 400px"
|
|
style="width: 400px"
|
|
|
|
|
+ collapse-tags
|
|
|
|
|
+ :max-collapse-tags="2"
|
|
|
|
|
+ collapse-tags-tooltip
|
|
|
popper-class="part-id-select-popper"
|
|
popper-class="part-id-select-popper"
|
|
|
:filter-method="debouncedRemoteMethod"
|
|
:filter-method="debouncedRemoteMethod"
|
|
|
- @change="changeData"
|
|
|
|
|
|
|
+ @change="changeData($event, 'customerCode')"
|
|
|
|
|
+ @visible-change="handleVisibleChange"
|
|
|
>
|
|
>
|
|
|
<el-option
|
|
<el-option
|
|
|
v-for="item in options"
|
|
v-for="item in options"
|
|
@@ -119,14 +144,22 @@ const typeOptions = ref([
|
|
|
:value="item.label"
|
|
:value="item.label"
|
|
|
>
|
|
>
|
|
|
<div class="select-option">
|
|
<div class="select-option">
|
|
|
- <el-checkbox :model-value="selectData.includes(item.label)" style="flex: 1">
|
|
|
|
|
|
|
+ <el-checkbox
|
|
|
|
|
+ :model-value="customerInfo.customerCode.includes(item.label)"
|
|
|
|
|
+ style="flex: 1"
|
|
|
|
|
+ >
|
|
|
<span style="display: inline-block; width: 220px">{{ item.label }}</span>
|
|
<span style="display: inline-block; width: 220px">{{ item.label }}</span>
|
|
|
<span class="text-ellipsis" style="flex: 1; width: 200px">{{ item.id }}</span>
|
|
<span class="text-ellipsis" style="flex: 1; width: 200px">{{ item.id }}</span>
|
|
|
</el-checkbox>
|
|
</el-checkbox>
|
|
|
</div>
|
|
</div>
|
|
|
</el-option>
|
|
</el-option>
|
|
|
</el-select>
|
|
</el-select>
|
|
|
- <el-select placeholder="Customer Type" v-model="type" style="width: 240px; margin-left: 8px">
|
|
|
|
|
|
|
+ <el-select
|
|
|
|
|
+ placeholder="Customer Type"
|
|
|
|
|
+ :model-value="customerInfo.customerType"
|
|
|
|
|
+ @change="changeData($event, 'customerType')"
|
|
|
|
|
+ style="width: 240px; margin-left: 8px"
|
|
|
|
|
+ >
|
|
|
<el-option
|
|
<el-option
|
|
|
v-for="item in typeOptions"
|
|
v-for="item in typeOptions"
|
|
|
:key="item.value"
|
|
:key="item.value"
|