|
@@ -1,212 +1,120 @@
|
|
|
<script setup lang="ts">
|
|
<script setup lang="ts">
|
|
|
import { ref, watch } from 'vue'
|
|
import { ref, watch } from 'vue'
|
|
|
import IconDropDown from '@/components/IconDropDown'
|
|
import IconDropDown from '@/components/IconDropDown'
|
|
|
-interface TypeItem {
|
|
|
|
|
- partyType: ''
|
|
|
|
|
- partyname: []
|
|
|
|
|
-}
|
|
|
|
|
-interface ListItem {
|
|
|
|
|
- value: string
|
|
|
|
|
- label: string
|
|
|
|
|
-}
|
|
|
|
|
-interface dateoptions {
|
|
|
|
|
- value: string
|
|
|
|
|
- label: string
|
|
|
|
|
-}
|
|
|
|
|
|
|
+import { cloneDeep } from 'lodash'
|
|
|
|
|
+import { useFiltersStore } from '@/stores/modules/filtersList'
|
|
|
|
|
+import { useRoute } from 'vue-router'
|
|
|
|
|
+
|
|
|
|
|
+const route = useRoute()
|
|
|
|
|
+const searchMode = route.path.includes('booking') ? 'booking' : 'tracking'
|
|
|
|
|
+const filtersStore = useFiltersStore()
|
|
|
|
|
+
|
|
|
interface Props {
|
|
interface Props {
|
|
|
- AddDateType: TypeItem[]
|
|
|
|
|
- ASPlaceholder: string
|
|
|
|
|
- DateTypeoptions: dateoptions[]
|
|
|
|
|
- selectedPartyTypeoptions: Array<string>
|
|
|
|
|
- ASSearchMode: String
|
|
|
|
|
- ASSearchObj: Object
|
|
|
|
|
-}
|
|
|
|
|
-interface optionsItem {
|
|
|
|
|
- value: string
|
|
|
|
|
- label: string
|
|
|
|
|
- checked: boolean
|
|
|
|
|
|
|
+ placeholder: string
|
|
|
|
|
+ typeOptions: Array<any>
|
|
|
|
|
+ pageData: Array<any>
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-const list = ref<ListItem[]>([])
|
|
|
|
|
-const options = ref<ListItem[]>([])
|
|
|
|
|
const loading = ref(false)
|
|
const loading = ref(false)
|
|
|
const props = withDefaults(defineProps<Props>(), {})
|
|
const props = withDefaults(defineProps<Props>(), {})
|
|
|
-const AddType = ref(props.AddDateType)
|
|
|
|
|
|
|
+// 搜索得到的值列表
|
|
|
|
|
+const detailsData = ref([])
|
|
|
|
|
+const typeData = ref(cloneDeep(props.pageData))
|
|
|
watch(
|
|
watch(
|
|
|
- () => props.AddDateType,
|
|
|
|
|
- (val) => {
|
|
|
|
|
- AddType.value = val
|
|
|
|
|
|
|
+ () => props.pageData,
|
|
|
|
|
+ (newVal) => {
|
|
|
|
|
+ typeData.value = cloneDeep(newVal)
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
- immediate: true,
|
|
|
|
|
deep: true
|
|
deep: true
|
|
|
}
|
|
}
|
|
|
)
|
|
)
|
|
|
-// const ErrorNumber = ref(0)
|
|
|
|
|
-const dataTypeoptions = ref<optionsItem[]>([])
|
|
|
|
|
-const typeSelectIndex = ref(-1)
|
|
|
|
|
-watch(
|
|
|
|
|
- () => props.selectedPartyTypeoptions,
|
|
|
|
|
- (newV) => {
|
|
|
|
|
- let arr: any = []
|
|
|
|
|
- if (newV.length == 0) {
|
|
|
|
|
- arr = props.DateTypeoptions
|
|
|
|
|
- } else {
|
|
|
|
|
- props.DateTypeoptions.forEach((item: any) => {
|
|
|
|
|
- let index = newV.findIndex((con: any) => {
|
|
|
|
|
- return con == item.value
|
|
|
|
|
- })
|
|
|
|
|
- if (index < 0) {
|
|
|
|
|
- arr.push(item)
|
|
|
|
|
- }
|
|
|
|
|
- })
|
|
|
|
|
- }
|
|
|
|
|
- dataTypeoptions.value = arr
|
|
|
|
|
- },
|
|
|
|
|
- {
|
|
|
|
|
- immediate: true,
|
|
|
|
|
- deep: true
|
|
|
|
|
- }
|
|
|
|
|
-)
|
|
|
|
|
-const ErrorNumber = ref(false)
|
|
|
|
|
-const str = ref()
|
|
|
|
|
-const search_field = ref()
|
|
|
|
|
-const InputAutoSelect = (val: any) => {
|
|
|
|
|
- search_field.value = val
|
|
|
|
|
- if (val.includes('Agent')) {
|
|
|
|
|
- str.value = 'apex'
|
|
|
|
|
- } else {
|
|
|
|
|
- str.value = 'sales'
|
|
|
|
|
- }
|
|
|
|
|
-}
|
|
|
|
|
-const remoteMethod = (query: string) => {
|
|
|
|
|
- if (query) {
|
|
|
|
|
- loading.value = true
|
|
|
|
|
- setTimeout(() => {
|
|
|
|
|
- $api
|
|
|
|
|
- .getMoreFiltersData({
|
|
|
|
|
- term: query,
|
|
|
|
|
- type: str.value,
|
|
|
|
|
- search_field: search_field.value,
|
|
|
|
|
- search_mode: props.ASSearchMode,
|
|
|
|
|
- ...props.ASSearchObj
|
|
|
|
|
- })
|
|
|
|
|
- .then((res: any) => {
|
|
|
|
|
- if (res.code == 200) {
|
|
|
|
|
- loading.value = false
|
|
|
|
|
- list.value = res.data.map((item: any) => {
|
|
|
|
|
- return { value: item, label: item, checked: testAuto.value?.includes(item) }
|
|
|
|
|
- })
|
|
|
|
|
- options.value = list.value.filter((item) => {
|
|
|
|
|
- return item.label.toLowerCase().includes(query.toLowerCase())
|
|
|
|
|
- })
|
|
|
|
|
- }
|
|
|
|
|
- })
|
|
|
|
|
- }, 200)
|
|
|
|
|
- } else {
|
|
|
|
|
- options.value = []
|
|
|
|
|
- }
|
|
|
|
|
-}
|
|
|
|
|
-// 删除当前more type
|
|
|
|
|
-const deleteType = (i: any) => {
|
|
|
|
|
- emit('delSelect', i, AddType.value[i].partyType)
|
|
|
|
|
- AddType.value.splice(i, 1)
|
|
|
|
|
-}
|
|
|
|
|
-// 选中type改变
|
|
|
|
|
-const changeSelect = (val: any) => {
|
|
|
|
|
- emit('changeAutoSelectAddType', typeSelectIndex.value, val)
|
|
|
|
|
|
|
+
|
|
|
|
|
+const originnalTypeOptions = ref(props.typeOptions)
|
|
|
|
|
+
|
|
|
|
|
+// 计算排除其他已选项后的可用选项
|
|
|
|
|
+const getAvailableOptions = (curTitle: string) => {
|
|
|
|
|
+ // 获取其他下拉已选的值(排除自己)
|
|
|
|
|
+ const otherTypeOptions = typeData.value
|
|
|
|
|
+ .filter((type) => {
|
|
|
|
|
+ return type.title !== curTitle
|
|
|
|
|
+ })
|
|
|
|
|
+ .map((type) => {
|
|
|
|
|
+ return type.title
|
|
|
|
|
+ })
|
|
|
|
|
+ return originnalTypeOptions.value.filter((type) => {
|
|
|
|
|
+ return !otherTypeOptions.includes(type.title)
|
|
|
|
|
+ })
|
|
|
}
|
|
}
|
|
|
-// 选中name改变
|
|
|
|
|
-const emit = defineEmits(['changeAutoSelectAddType', 'delSelect', 'changeAutoSelect'])
|
|
|
|
|
-let AutoSelectObj: any = {}
|
|
|
|
|
-let AutoSelectObj2: any = {}
|
|
|
|
|
-const testAuto = ref()
|
|
|
|
|
-const changeAutoSelect = (val: any, value: any) => {
|
|
|
|
|
- testAuto.value = value
|
|
|
|
|
- AutoSelectObj[val] = value.join()
|
|
|
|
|
- AutoSelectObj2[val] = value
|
|
|
|
|
- if (value.length) {
|
|
|
|
|
- ErrorNumber.value = true
|
|
|
|
|
- } else {
|
|
|
|
|
- ErrorNumber.value = false
|
|
|
|
|
- }
|
|
|
|
|
- emit('changeAutoSelect', AutoSelectObj, AutoSelectObj2, ErrorNumber.value)
|
|
|
|
|
|
|
+const emit = defineEmits(['deleteType', 'changeType'])
|
|
|
|
|
+
|
|
|
|
|
+const changeData = (item: any) => {
|
|
|
|
|
+ item.value = []
|
|
|
|
|
+ emit('changeType', item)
|
|
|
}
|
|
}
|
|
|
-const typeSelectFocus = (index: any, e: any) => {
|
|
|
|
|
- typeSelectIndex.value = index
|
|
|
|
|
|
|
+
|
|
|
|
|
+const deleteType = (title: string) => {
|
|
|
|
|
+ emit('deleteType', title)
|
|
|
}
|
|
}
|
|
|
-const typeSelectBlur = () => {
|
|
|
|
|
- typeSelectIndex.value = -1
|
|
|
|
|
- let arr: any = []
|
|
|
|
|
- if (props.selectedPartyTypeoptions.length == 0) {
|
|
|
|
|
- arr = props.DateTypeoptions
|
|
|
|
|
- } else {
|
|
|
|
|
- props.DateTypeoptions.forEach((item: any) => {
|
|
|
|
|
- let index = props.selectedPartyTypeoptions.findIndex((con: any) => {
|
|
|
|
|
- return con == item.value
|
|
|
|
|
- })
|
|
|
|
|
- if (index < 0) {
|
|
|
|
|
- arr.push(item)
|
|
|
|
|
- }
|
|
|
|
|
- })
|
|
|
|
|
|
|
+
|
|
|
|
|
+const visibleChange = (val: boolean) => {
|
|
|
|
|
+ if (!val) {
|
|
|
|
|
+ detailsData.value = []
|
|
|
}
|
|
}
|
|
|
- dataTypeoptions.value = arr
|
|
|
|
|
}
|
|
}
|
|
|
-const typeSelectClick = (index: any, val: any) => {
|
|
|
|
|
- if (AddType.value[index].partyType) {
|
|
|
|
|
- let j = props.DateTypeoptions.findIndex((item: any) => {
|
|
|
|
|
- return item.value == AddType.value[index].partyType
|
|
|
|
|
|
|
+const createQueryHandler = (title: string, curValue: string[]) => {
|
|
|
|
|
+ return (query: string) => {
|
|
|
|
|
+ const curType = originnalTypeOptions.value.find((type) => {
|
|
|
|
|
+ return type.title === title
|
|
|
})
|
|
})
|
|
|
- let i = dataTypeoptions.value.findIndex((item: any) => {
|
|
|
|
|
- return item.value == AddType.value[index].partyType
|
|
|
|
|
- })
|
|
|
|
|
- if (i < 0) {
|
|
|
|
|
- dataTypeoptions.value.push(props.DateTypeoptions[j])
|
|
|
|
|
- }
|
|
|
|
|
- } else {
|
|
|
|
|
- let arr: any = []
|
|
|
|
|
- if (props.selectedPartyTypeoptions.length == 0) {
|
|
|
|
|
- arr = props.DateTypeoptions
|
|
|
|
|
- } else {
|
|
|
|
|
- props.DateTypeoptions.forEach((item: any) => {
|
|
|
|
|
- let index = props.selectedPartyTypeoptions.findIndex((con: any) => {
|
|
|
|
|
- return con == item.value
|
|
|
|
|
- })
|
|
|
|
|
- if (index < 0) {
|
|
|
|
|
- arr.push(item)
|
|
|
|
|
- }
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ if (query) {
|
|
|
|
|
+ loading.value = true
|
|
|
|
|
+ const queryData = filtersStore.getQueryData
|
|
|
|
|
+ setTimeout(() => {
|
|
|
|
|
+ $api
|
|
|
|
|
+ .getMoreFiltersData({
|
|
|
|
|
+ term: query,
|
|
|
|
|
+ type: curType.type,
|
|
|
|
|
+ search_field: title,
|
|
|
|
|
+ search_mode: searchMode,
|
|
|
|
|
+ ...queryData
|
|
|
|
|
+ })
|
|
|
|
|
+ .then((res: any) => {
|
|
|
|
|
+ if (res.code == 200) {
|
|
|
|
|
+ loading.value = false
|
|
|
|
|
+ detailsData.value = res.data.map((item: any) => {
|
|
|
|
|
+ return { value: item, label: item, checked: curValue?.includes(item) }
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ }, 200)
|
|
|
}
|
|
}
|
|
|
- dataTypeoptions.value = arr
|
|
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
</script>
|
|
</script>
|
|
|
<template>
|
|
<template>
|
|
|
- <div class="AddType" v-for="(item, index) in AddType" :key="index">
|
|
|
|
|
|
|
+ <div class="addType" v-for="item in pageData" :key="item.id">
|
|
|
<div>
|
|
<div>
|
|
|
<div class="Date_Title">
|
|
<div class="Date_Title">
|
|
|
<div class="ETD_title">Party Type</div>
|
|
<div class="ETD_title">Party Type</div>
|
|
|
- <span class="iconfont_icon" @click="deleteType(index)">
|
|
|
|
|
|
|
+ <span class="iconfont_icon" @click="deleteType(item.title)">
|
|
|
<svg class="iconfont icon_delete" aria-hidden="true">
|
|
<svg class="iconfont icon_delete" aria-hidden="true">
|
|
|
<use xlink:href="#icon-icon_delete_b"></use>
|
|
<use xlink:href="#icon-icon_delete_b"></use>
|
|
|
</svg>
|
|
</svg>
|
|
|
</span>
|
|
</span>
|
|
|
</div>
|
|
</div>
|
|
|
<el-select
|
|
<el-select
|
|
|
- v-model="AddType[index].partyType"
|
|
|
|
|
|
|
+ v-model="item.title"
|
|
|
:suffix-icon="IconDropDown"
|
|
:suffix-icon="IconDropDown"
|
|
|
- @blur="typeSelectBlur"
|
|
|
|
|
class="testname"
|
|
class="testname"
|
|
|
- @focus="typeSelectFocus(index, $event)"
|
|
|
|
|
- @click="typeSelectClick(index, $event)"
|
|
|
|
|
- @change="changeSelect(AddType[index].partyType)"
|
|
|
|
|
|
|
+ @change="changeData(item)"
|
|
|
placeholder="Please Select Party Type"
|
|
placeholder="Please Select Party Type"
|
|
|
>
|
|
>
|
|
|
<el-option
|
|
<el-option
|
|
|
- v-for="item in dataTypeoptions"
|
|
|
|
|
- :key="item.value"
|
|
|
|
|
- :label="item.label"
|
|
|
|
|
- :value="item.value"
|
|
|
|
|
|
|
+ v-for="type in getAvailableOptions(item.title)"
|
|
|
|
|
+ :key="type.title"
|
|
|
|
|
+ :label="type.title"
|
|
|
|
|
+ :value="type.title"
|
|
|
>
|
|
>
|
|
|
</el-option>
|
|
</el-option>
|
|
|
</el-select>
|
|
</el-select>
|
|
@@ -214,39 +122,37 @@ const typeSelectClick = (index: any, val: any) => {
|
|
|
<div style="margin-top: 16px">
|
|
<div style="margin-top: 16px">
|
|
|
<div class="ETD_title">Party Details</div>
|
|
<div class="ETD_title">Party Details</div>
|
|
|
<el-select
|
|
<el-select
|
|
|
- v-model="AddType[index].partyname"
|
|
|
|
|
|
|
+ v-model="item.value"
|
|
|
multiple
|
|
multiple
|
|
|
filterable
|
|
filterable
|
|
|
remote
|
|
remote
|
|
|
:class="{
|
|
:class="{
|
|
|
- is_error: AddType[index].partyType != '' && AddType[index].partyname.length == 0
|
|
|
|
|
|
|
+ is_error: item.value != '' && item.title
|
|
|
}"
|
|
}"
|
|
|
reserve-keyword
|
|
reserve-keyword
|
|
|
- :placeholder="props.ASPlaceholder"
|
|
|
|
|
|
|
+ :placeholder="props.placeholder"
|
|
|
collapse-tags
|
|
collapse-tags
|
|
|
- @input="InputAutoSelect(AddType[index].partyType)"
|
|
|
|
|
- @change="changeAutoSelect(AddType[index].partyType, AddType[index].partyname)"
|
|
|
|
|
- :disabled="AddType[index].partyType ? false : true"
|
|
|
|
|
|
|
+ :disabled="item.title ? false : true"
|
|
|
collapse-tags-tooltip
|
|
collapse-tags-tooltip
|
|
|
:max-collapse-tags="3"
|
|
:max-collapse-tags="3"
|
|
|
- :remote-method="remoteMethod"
|
|
|
|
|
|
|
+ :remote-method="createQueryHandler(item.title, item.value)"
|
|
|
:loading="loading"
|
|
:loading="loading"
|
|
|
|
|
+ @visible-change="visibleChange"
|
|
|
>
|
|
>
|
|
|
<el-option
|
|
<el-option
|
|
|
- v-for="item in options"
|
|
|
|
|
- :key="item.value"
|
|
|
|
|
- :label="item.label"
|
|
|
|
|
- :value="item.value"
|
|
|
|
|
|
|
+ v-for="infoItem in detailsData"
|
|
|
|
|
+ :key="infoItem.label"
|
|
|
|
|
+ :label="infoItem.label"
|
|
|
|
|
+ :value="infoItem.label"
|
|
|
>
|
|
>
|
|
|
- <el-checkbox :checked="item.checked">
|
|
|
|
|
- <span class="label" @click="item.checked = !item.checked">{{ item.value }}</span>
|
|
|
|
|
|
|
+ <el-checkbox :checked="infoItem.checked">
|
|
|
|
|
+ <span class="label" @click="infoItem.checked = !infoItem.checked">{{
|
|
|
|
|
+ infoItem.label
|
|
|
|
|
+ }}</span>
|
|
|
</el-checkbox>
|
|
</el-checkbox>
|
|
|
</el-option>
|
|
</el-option>
|
|
|
</el-select>
|
|
</el-select>
|
|
|
- <div
|
|
|
|
|
- class="error"
|
|
|
|
|
- v-if="AddType[index].partyType != '' && AddType[index].partyname.length == 0"
|
|
|
|
|
- >
|
|
|
|
|
|
|
+ <div class="error" v-if="item.value.length === 0 && item.title">
|
|
|
Please Input Party Details
|
|
Please Input Party Details
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|
|
@@ -254,7 +160,7 @@ const typeSelectClick = (index: any, val: any) => {
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
<style lang="scss" scoped>
|
|
|
-.AddType {
|
|
|
|
|
|
|
+.addType {
|
|
|
background-color: var(--addparties-background-color);
|
|
background-color: var(--addparties-background-color);
|
|
|
margin: 0 16px 8px 16px;
|
|
margin: 0 16px 8px 16px;
|
|
|
padding: 8px;
|
|
padding: 8px;
|
|
@@ -312,4 +218,4 @@ const typeSelectClick = (index: any, val: any) => {
|
|
|
line-height: 14px;
|
|
line-height: 14px;
|
|
|
margin-top: 5px;
|
|
margin-top: 5px;
|
|
|
}
|
|
}
|
|
|
-</style>
|
|
|
|
|
|
|
+</style>
|