获取地址列表 和 类型列表

This commit is contained in:
wlikett 2023-12-08 15:18:34 +08:00
parent 5691c044ad
commit ce5beac1d1
2 changed files with 124 additions and 75 deletions

View File

@ -29,5 +29,5 @@ export const apiGetEquipTypeList = (params = {}) => {
}
//获取省市区列表 (级联)
export const apiGetAddressList = (params = {}) => {
return post('/zlpt-company/baseAddress/selectAddress',params)
return post('/zlpt-system/baseAddress/selectAddress',params)
}

View File

@ -8,7 +8,7 @@
<div class="tags">
<el-tag
v-for="(tag,i) in screenTags"
:key="tag.id"
:key="i"
class="item"
@close="handleClose(tag,i)"
closable
@ -50,8 +50,12 @@
v-for="(v,i) in screenOptionList" :key="i">
{{ v.name }}
<template v-if="v.sort">
<el-icon class="icon" v-show="v.sort == 'asc' && v.id == optionActive"><CaretTop /></el-icon>
<el-icon class="icon" v-show="v.sort == 'desc' && v.id == optionActive"><CaretBottom /></el-icon>
<el-icon class="icon" v-show="v.sort == 'asc' && v.id == optionActive">
<CaretTop/>
</el-icon>
<el-icon class="icon" v-show="v.sort == 'desc' && v.id == optionActive">
<CaretBottom/>
</el-icon>
</template>
</div>
</div>
@ -59,20 +63,20 @@
<div class="showList" v-if="pageData.total > 0">
<equip-card
class="card"
v-for="(v,i) in equipList"
:key="i"
:url="v.picUrl"
:company="v.companyName"
:tags="[v.maStatus,v.location || '合肥市']"
:name="`${v.modelName}${v.deviceName}`"
:price="v.monthLeasePrice"
:id="v.maId"
time-unit="月"
@on-click="toDetail"></equip-card>
class="card"
v-for="(v,i) in equipList"
:key="i"
:url="v.picUrl"
:company="v.companyName"
:tags="[v.maStatus,v.city || '合肥市']"
:name="`${v.modelName}${v.deviceName}`"
:price="v.monthLeasePrice"
:id="v.maId"
time-unit="月"
@on-click="toDetail"></equip-card>
</div>
<div class="noData" v-else>
<el-empty :image-size="200" />
<el-empty :image-size="200"/>
</div>
<div class="pagination" v-if="pageData.total > 0">
@ -156,19 +160,19 @@ const screenChooseList = reactive([
select: [{
id: 1,
name: '5千元以下',
value:['',5000]
value: [0, 5000]
}, {
id: 1,
name: '5千-1万',
value:[5000,10000]
value: [5000, 10000]
}, {
id: 1,
name: '1万-5万',
value: [10000,50000]
value: [10000, 50000]
}, {
id: 1,
name: '5万-10万',
value: [50000,100000]
value: [50000, 100000]
},]
}
]
@ -185,19 +189,19 @@ const screenChooseList = reactive([
select: [{
id: 1,
name: '一年以下',
value: ['',1]
value: [0, 1]
}, {
id: 1,
name: '1年-3年',
value: [1,3]
value: [1, 3]
}, {
id: 1,
name: '3年-6年',
value: [3,6]
value: [3, 6]
}, {
id: 1,
name: '10年以上',
value: [10,'']
value: [10, 99999999]
}]
}
]
@ -213,19 +217,24 @@ const screenChooseList = reactive([
parent: 'time',
select: [{
id: 1,
name: '500小时以内'
name: '500小时以内',
value: [0, 500]
}, {
id: 1,
name: '500-2000小时'
name: '500-2000小时',
value: [500, 2000]
}, {
id: 1,
name: '2000-5000小时'
name: '2000-5000小时',
value: [2000, 5000]
}, {
id: 1,
name: '5000-10000小时'
name: '5000-10000小时',
value: [5000, 10000]
}, {
id: 1,
name: '10000小时以上'
name: '10000小时以上',
value: [10000, 9999999]
},]
}
]
@ -242,12 +251,10 @@ const screenOptionList = reactive([
name: '更新时间',
id: '2',
sort: 'asc', //asc or desc
key:'updateTimeOrderBy'
}, {
name: '月租金',
id: '3',
sort: 'asc',
key:'monthLeasePriceOrderBy'
},
])
//
@ -256,7 +263,7 @@ const optionActive = ref('1')
const screenTags = computed<Array<any>>(() => {
let arr = []
screenChooseList.forEach(key => {
arr = [...arr,...key.select]
arr = [...arr, ...key.select]
})
return arr
})
@ -265,7 +272,7 @@ const screenTags = computed<Array<any>>(() => {
const pageData = reactive({
pageNum: 1,
pageSize: 9,
total:0
total: 0
})
//
@ -273,7 +280,7 @@ const equipList = ref([])
onMounted(() => {
$bus.on('search',(val) => {
$bus.on('search', (val) => {
getData(val)
})
})
@ -284,6 +291,8 @@ onUnmounted(() => {
const handleClose = (tag, index) => {
screenChooseList[tag.parentIndex].select.splice(tag.index)
screenChooseList[tag.parentIndex].index = tag.index
getData()
}
//
const tagClear = () => {
@ -291,10 +300,12 @@ const tagClear = () => {
key.select = []
key.index = 0
})
getData()
}
const changeOption = (val) => {
if(val.sort && optionActive.value == val.id){
if (val.sort && optionActive.value == val.id) {
val.sort = val.sort == 'asc' ? 'desc' : 'asc'
}
optionActive.value = val.id
@ -312,23 +323,29 @@ const selectScreen = (parentIndex, val, index) => {
)
screenChooseList[parentIndex].index++
if(screenChooseList[parentIndex].index == screenChooseList[parentIndex].list.length){
getData()
if (screenChooseList[parentIndex].index == screenChooseList[parentIndex].list.length) {
return
}
switch (screenChooseList[parentIndex].name){
switch (screenChooseList[parentIndex].name) {
case 'address':
getAddressData(val.code)
break;
case 'type':
getTypeData(val.typeId)
break;
default:
break;
}
}
//card
const toDetail = (data) => {
router.push({
path:`/equipDetail/${data.id}`
path: `/equipDetail/${data.id}`
})
}
@ -340,57 +357,88 @@ const pageChange = (val) => {
//
const getAddressData = async (code = null) => {
let params = {}
if(code){
if (code) {
params = {
code
}
}
const res = await apiGetAddressList(params)
const index = screenChooseList.findIndex(key => key.name == 'address')
screenChooseList[index].list[ screenChooseList[index].index ].select = res.data
screenChooseList[index].list[screenChooseList[index].index].select = res.data
}
//
const getTypeData = async (typeId = null) => {
let params = {}
if(typeId){
if (typeId) {
params = {typeId}
}
const res = await apiGetEquipTypeList(params)
console.log('getTypeData ===============',res)
const list = res.rows.map(
item => {
return {
...item,
name:item.typeName,
id:item.typeId
}
}
)
const index = screenChooseList.findIndex(key => key.name == 'type')
screenChooseList[index].list[screenChooseList[index].index].select = list
console.log('getTypeData ===============', list)
}
//
const getData = async (text = '') => {
//
const address = screenChooseList.find(key => key.name == 'address').select
const address = screenChooseList.find(key => key.name == 'address').select.slice(-1)[0] || null
//
const type = screenChooseList.find(key => key.name == 'type').select
const type = screenChooseList.find(key => key.name == 'type').select.slice(-1)[0] || null
//
const rent = screenChooseList.find(key => key.name == 'rent').select.slice(-1)[0] || null
//
const age = screenChooseList.find(key => key.name == 'age').select.slice(-1)[0] || null
//
const time = screenChooseList.find(key => key.name == 'time').select.slice(-1)[0] || null
const params = {
keyWord: text,
pageSize:pageData.pageSize,
pageNum:pageData.pageNum,
updateTimeOrderBy:'',
monthLeasePriceOrderBy:'',
location: address && address.length > 0 ? address[address.length - 1] : '',
typeId: type && type.length > 0 ? type[address.length - 1] : '',
monthLeasePriceMin:0,
monthLeasePriceMax:'',
ageMin:'',
ageMax:'',
workingHoursMin:'',
workingHoursMax:''
pageSize: pageData.pageSize,
pageNum: pageData.pageNum,
updateTimeOrderBy: '',
monthLeasePriceOrderBy: '',
location: address ? address.id : '',
typeId: type ? type.typeId : '',
monthLeasePriceMin: '',
monthLeasePriceMax: '',
ageMin: '',
ageMax: '',
workingHoursMin: '',
workingHoursMax: ''
}
if(optionActive.value == '1'){
}else if(optionActive.value == '2'){
if (optionActive.value == '2') {
params.updateTimeOrderBy = screenOptionList[1].sort.toUpperCase()
} else if (optionActive.value == '3') {
params.monthLeasePriceOrderBy = screenOptionList[2].sort.toUpperCase()
}
if(rent){
params.monthLeasePriceMin = rent.value[0]
params.monthLeasePriceMax = rent.value[1]
}
if(age){
params.ageMin = age.value[0]
params.ageMax = age.value[1]
}
if(time){
params.workingHoursMin = time.value[0]
params.workingHoursMax = time.value[1]
}
console.log('getList =============',params)
const res = await getList(params)
pageData.total = res.total || 0
@ -401,37 +449,36 @@ const getParams = () => {
const paramsKey = ['keyWord']
let params = {}
paramsKey.forEach(key => {
if (history.state[key]){
if (history.state[key]) {
params[key] = history.state[key]
}
})
return params
}
const init = async () => {
const init = () => {
const params = getParams()
if(params && params.keyWord){
$bus.emit('callBackText',params.keyWord)
if (params && params.keyWord) {
$bus.emit('callBackText', params.keyWord)
$bus.off('callBackText')
}
await getTypeData()
await getAddressData()
await getData()
getTypeData()
getAddressData()
getData()
}
init()
</script>
<style lang="scss" scoped>
.equipList {
.showScreen {
margin-top: 20px;
margin-top: 20px;
display: flex;
align-items: center;
height: 30px;
.title {
font-size: 16px;
font-weight: 500;
@ -474,6 +521,7 @@ init()
color: #939393;
font-size: 15px;
line-height: 25px;
&:hover {
color: red;
}
@ -502,9 +550,10 @@ init()
margin-right: 10px;
cursor: pointer;
user-select: none;
.icon{
font-size: 15px;
}
.icon {
font-size: 15px;
}
}
}
}