完成订单中心及需求大厅的搜索功能

This commit is contained in:
donqi 2022-07-04 22:31:08 +08:00
parent c7ac112bdf
commit 5e6476967c
2 changed files with 254 additions and 85 deletions

View File

@ -10,7 +10,7 @@
<view class="cu-bar search bg-white">
<view class="search-form round">
<text class="cuIcon-search"></text>
<input @confirm="searchTasks" :adjust-position="true" v-model="searchInputVal" type="text" placeholder="输入搜索的内容"
<input @confirm="searchTasks" v-model="inputGoodsName" :adjust-position="true" type="text" placeholder="输入搜索的内容"
confirm-type="search"></input>
</view>
<view class="action">
@ -23,26 +23,35 @@
<view class="cu-item" v-for="(item,index) in taskConditions" v-if="item.type !== 1" :key="index"
@tap="tabSelect" :data-id="index">
<!-- 区域筛选picker -->
<picker v-if="item.code === 'area'" :mode="'multiSelector'" @change="regionChange"
:value="areaMultiIndex" :range-key="'name'" :range="areaList">
{{item.title}}
<picker v-if="item.code === 'countryId'" :mode="'multiSelector'" @change="regionChange" @columnchange="regionColChange"
:value="areaMultiIndex" :range-key="'areaName'" :range="areaList">
<view class="flex justify-start">
<view class="text-cut search-nav-item-text">
{{chosenArea && chosenArea.length ? chosenArea[2].areaName : item.title}}
</view>
<text class="text-lg"><text class="cuIcon-triangledownfill"></text></text>
</view>
</picker>
<!-- 品类筛选picker -->
<picker v-else-if="item.code === 'category'" :mode="'multiSelector'" @change="categoryChange"
:value="categoryMultiIndex" :range-key="'name'" :range="categoryList">
{{item.title}}
<picker v-else-if="item.code === 'goodsCategoryId'" :mode="'multiSelector'" @change="categoryChange"
@columnchange="categoryColChange" :value="categoryMultiIndex" :range-key="'goodsCategoryName'"
:range="categoryList">
<view class="flex justify-start">
<view class="text-cut search-nav-item-text">
{{chosenCategory && chosenCategory.length ? chosenCategory[2].goodsCategoryName : item.title}}
</view>
<text class="text-lg"><text class="cuIcon-triangledownfill"></text></text>
</view>
</picker>
<text v-else>
{{item.title}}
<view v-else class="flex justify-start">
<view class="search-nav-item-text">{{item.title}}</view>
<text v-if="item.type === 0" class="text-lg"><text
:class="item.value === 0 ? 'cuIcon-triangleupfill' : 'cuIcon-triangledownfill'"></text></text>
<text v-else class="text-lg"><text class="cuIcon-triangledownfill"></text></text>
</text>
</view>
</view>
<view class="cu-item" v-else>
<button class="cu-btn bg-grey round shadow-blur">{{item.title}}</button>
<button class="cu-btn bg-grey round shadow-blur" @click="barBtnClick(index)">{{item.title}}</button>
</view>
</scroll-view>
</view>
@ -189,27 +198,57 @@
pageSize: 0,
// type: 0=1=order: 0=1=
taskConditions: [{
code: 'area',
title: '区域'
code: 'countryId',
title: '区域',
type: 2
}, {
code: 'category',
title: '品类'
}, {
code: 'distance',
title: '距离',
type: 0,
value: 0,
}, {
code: 'time',
code: 'goodsCategoryId',
title: '品类',
type: 2
},
// {
// code: 'distance',
// title: '',
// type: 0,
// value: 0,
// },
{
code: 'createTimeSort',
title: '时间',
type: 0,
value: 0,
value: 1,
}, {
code: 'reset',
type: 1,
title: '重置'
title: '重置',
action: 'resetConditions'
}],
originTaskConditions: [{
code: 'countryId',
title: '区域',
type: 2
}, {
code: 'goodsCategoryId',
title: '品类',
type: 2
},
// {
// code: 'distance',
// title: '',
// type: 0,
// value: 0,
// },
{
code: 'createTimeSort',
title: '时间',
type: 0,
value: 1,
}, {
code: 'reset',
type: 1,
title: '重置',
action: 'resetConditions'
}],
searchInputVal: '',
tasks: [],
curTask: null,
takeCertify: false,
@ -217,11 +256,14 @@
showForwardModal: false,
showTakeCertifiedModal: false,
showTakeSuccessModal: false,
curUserInfo: {},
inputGoodsName: null,
areaList: [],
areaMultiIndex: [0, 0, 0],
chosenArea: [],
categoryList: [],
categoryMultiIndex: [0, 0, 0],
curUserInfo: {}
chosenCategory: []
}
},
onShow() {
@ -232,15 +274,26 @@
// this.tasks = await this.$api.data('tasks');
this.curUserInfo = this.$request.getCurUserInfo();
this.reloadMasterOrderPage();
this.takeCertify = await this.$api.data('takeCertify');
this.areaList = await this.$api.data('areaList');
this.categoryList = await this.$api.data('categoryList');
// this.takeCertify = await this.$api.data('takeCertify');
// this.areaList = await this.$api.data('areaList');
// this.categoryList = await this.$api.data('categoryList');
this.loadCategoryList();
this.loadRegionList();
},
async loadMasterOrderPage(params = {}) {
params.pageSize = this.$globalData.initPageSize;
params.pageNum = this.pageNum;
params.orderStatus = 0;
params.workerId = -1;
params.goodsName = this.inputGoodsName;
this.taskConditions.forEach((condition) => {
if (condition.type === 2) {
params[condition.code] = condition.value;
} else if (condition.type === 0) {
params.params = params.params ? params.params : {};
params.params[condition.code] = condition.value === 1 ? 'desc' : 'asc';
}
})
this.$refs.loadStatusBar.showLoading();
try {
@ -280,16 +333,62 @@
//
let orderVal = this.taskConditions[this.tabCur].value;
this.taskConditions[this.tabCur].value = orderVal === 0 ? 1 : 0;
}
this.searchTasks();
}
},
barBtnClick(index) {
this[this.taskConditions[index].action]();
},
async loadCategoryList(idArr) {
let typeList = await this.$request.listByStep();
typeList = typeList.data;
let col1Id = idArr ? idArr[0] : typeList[0].goodsCategoryId;
let subTypeList = await this.$request.listByStep({
goodsCategoryId: col1Id
});
subTypeList = subTypeList.data;
let col2Id = idArr ? idArr[1] : subTypeList[0].goodsCategoryId;
let subSubTypeList = await this.$request.listByStep({
goodsCategoryId: col2Id
});
subSubTypeList = subSubTypeList.data;
this.categoryList.push(typeList);
this.categoryList.push(subTypeList);
this.categoryList.push(subSubTypeList);
},
async loadRegionList() {
let regionList = await this.$request.areaListByStep();
regionList = regionList.data;
let subRegionList = [];
let subSubRegionList = [];
if (regionList && regionList.length > 0) {
subRegionList = await this.$request.areaListByStep({
parentCode: regionList[0].areaCode
});
subRegionList = subRegionList.data;
}
if (subRegionList && subRegionList.length > 0) {
subSubRegionList = await this.$request.areaListByStep({
parentCode: subRegionList[0].areaCode
});
subSubRegionList = subSubRegionList.data;
}
this.areaList.push(regionList);
this.areaList.push(subRegionList);
this.areaList.push(subSubRegionList);
},
searchTasks() {
let qryObj = {};
this.taskConditions.forEach((condition) => {
qryObj[condition.code] = condition.value;
})
qryObj.name = this.searchInputVal;
//TODO: tasks
this.reloadMasterOrderPage();
},
resetConditions() {
this.inputGoodsName = null;
for(let i = 0; i < this.originTaskConditions.length; i++) {
this.taskConditions[i].value = this.originTaskConditions[i].value;
}
this.chosenArea = [];
this.chosenCategory = [];
// this.$forceUpdate();
this.reloadMasterOrderPage();
},
regionChange(e) {
this.areaMultiIndex = e.detail.value;
@ -297,15 +396,72 @@
for (let i = 0; i < this.areaList.length; i++) {
chosenArea.push(this.areaList[i][this.areaMultiIndex[i]]);
}
this.taskConditions[this.tabCur].value = chosenArea;
this.chosenArea = chosenArea;
this.taskConditions[this.tabCur].value = chosenArea[chosenArea.length - 1].areaId;
this.searchTasks();
},
categoryChange(e) {
async regionColChange(e) {
let colObj = e.detail;
if (colObj.column == 0) {
//
let subAreaList = await this.$request.areaListByStep({parentCode: this.areaList[0][colObj.value].areaCode});
subAreaList = subAreaList.data;
let subSubAreaList = [];
if (subAreaList.length) {
subSubAreaList = await this.$request.areaListByStep({parentCode: subAreaList[0].areaCode});
subSubAreaList = subSubAreaList.data;
}
this.areaList.pop();
this.areaList.pop();
this.areaList.push(subAreaList);
this.areaList.push(subSubAreaList);
this.areaMultiIndex = [colObj.value, 0, 0];
} else if (colObj.column == 1) {
//
let subAreaList = await this.$request.areaListByStep({parentCode: this.areaList[1][colObj.value].areaCode});
subAreaList = subAreaList.data;
this.areaList.pop();
this.areaList.push(subAreaList);
this.areaMultiIndex = [this.areaMultiIndex[0], colObj.value, 0];
}
},
async categoryChange(e) {
this.categoryMultiIndex = e.detail.value;
let chosenCategory = [];
for (let i = 0; i < this.categoryList.length; i++) {
chosenCategory.push(this.categoryList[i][this.categoryMultiIndex[i]]);
}
this.taskConditions[this.tabCur].value = chosenCategory;
this.chosenCategory = chosenCategory;
this.taskConditions[this.tabCur].value = chosenCategory[chosenCategory.length - 1].goodsCategoryId;
this.searchTasks();
},
async categoryColChange(e) {
let colObj = e.detail;
if (colObj.column == 0) {
//
let subTypeList = await this.$request.listByStep({
goodsCategoryId: this.categoryList[0][colObj.value].goodsCategoryId
});
subTypeList = subTypeList.data;
let subSubTypeList = await this.$request.listByStep({
goodsCategoryId: subTypeList[0].goodsCategoryId
});
subSubTypeList = subSubTypeList.data;
this.categoryList.pop();
this.categoryList.pop();
this.categoryList.push(subTypeList);
this.categoryList.push(subSubTypeList);
this.categoryMultiIndex = [colObj.value, 0, 0];
} else if (colObj.column == 1) {
//
let subSubTypeList = await this.$request.listByStep({
goodsCategoryId: this.categoryList[1][colObj.value].goodsCategoryId
});
subSubTypeList = subSubTypeList.data;
this.categoryList.pop();
this.categoryList.push(subSubTypeList);
this.categoryMultiIndex = [this.categoryMultiIndex[0], colObj.value, 0];
}
},
showDemandDetail(e, task) {
let paramObj = {
@ -356,5 +512,16 @@
</script>
<style scoped>
.search-nav-item-text {
width: 100rpx;
}
.nav .cu-item {
height: 90rpx;
display: inline-block;
line-height: 90rpx;
margin: 0;
padding: 0 10rpx;
width: 180rpx;
}
</style>

View File

@ -379,6 +379,9 @@
// params.orderStatus = this.subStateList[this.tabCur].code;
// params.pageNum = this.pageParams[this.tabCur].pageNum;
params.pageNum = this.pageNum;
params.goodsName = this.formData.orderKeywords;
params.countryId = this.formData.area && this.formData.area.length > 2 ? this.formData.area[2].areaId : null;
params.goodsCategoryId = this.formData.category && this.formData.category.length > 2 ? this.formData.category[2].goodsCategoryId : null;
if (this.tabCur != null) {
params.orderStatus = this.subStateList[this.tabCur].code;
} else if (this.stateCur != null) {
@ -532,9 +535,8 @@
}
this.formData.category = chosenCategory;
},
searchOrder(e) {
console.log(e)
console.log(this.formData)
searchOrder() {
this.reloadMasterOrderPage();
},
resetConditions() {
this.formData = {