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

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="cu-bar search bg-white">
<view class="search-form round"> <view class="search-form round">
<text class="cuIcon-search"></text> <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> confirm-type="search"></input>
</view> </view>
<view class="action"> <view class="action">
@ -23,26 +23,35 @@
<view class="cu-item" v-for="(item,index) in taskConditions" v-if="item.type !== 1" :key="index" <view class="cu-item" v-for="(item,index) in taskConditions" v-if="item.type !== 1" :key="index"
@tap="tabSelect" :data-id="index"> @tap="tabSelect" :data-id="index">
<!-- 区域筛选picker --> <!-- 区域筛选picker -->
<picker v-if="item.code === 'area'" :mode="'multiSelector'" @change="regionChange" <picker v-if="item.code === 'countryId'" :mode="'multiSelector'" @change="regionChange" @columnchange="regionColChange"
:value="areaMultiIndex" :range-key="'name'" :range="areaList"> :value="areaMultiIndex" :range-key="'areaName'" :range="areaList">
{{item.title}} <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> <text class="text-lg"><text class="cuIcon-triangledownfill"></text></text>
</view>
</picker> </picker>
<!-- 品类筛选picker --> <!-- 品类筛选picker -->
<picker v-else-if="item.code === 'category'" :mode="'multiSelector'" @change="categoryChange" <picker v-else-if="item.code === 'goodsCategoryId'" :mode="'multiSelector'" @change="categoryChange"
:value="categoryMultiIndex" :range-key="'name'" :range="categoryList"> @columnchange="categoryColChange" :value="categoryMultiIndex" :range-key="'goodsCategoryName'"
{{item.title}} :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> <text class="text-lg"><text class="cuIcon-triangledownfill"></text></text>
</view>
</picker> </picker>
<text v-else> <view v-else class="flex justify-start">
{{item.title}} <view class="search-nav-item-text">{{item.title}}</view>
<text v-if="item.type === 0" class="text-lg"><text <text v-if="item.type === 0" class="text-lg"><text
:class="item.value === 0 ? 'cuIcon-triangleupfill' : 'cuIcon-triangledownfill'"></text></text> :class="item.value === 0 ? 'cuIcon-triangleupfill' : 'cuIcon-triangledownfill'"></text></text>
<text v-else class="text-lg"><text class="cuIcon-triangledownfill"></text></text> <text v-else class="text-lg"><text class="cuIcon-triangledownfill"></text></text>
</text> </view>
</view> </view>
<view class="cu-item" v-else> <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> </view>
</scroll-view> </scroll-view>
</view> </view>
@ -189,27 +198,57 @@
pageSize: 0, pageSize: 0,
// type: 0=1=order: 0=1= // type: 0=1=order: 0=1=
taskConditions: [{ taskConditions: [{
code: 'area', code: 'countryId',
title: '区域' title: '区域',
type: 2
}, { }, {
code: 'category', code: 'goodsCategoryId',
title: '品类' title: '品类',
}, { type: 2
code: 'distance', },
title: '距离', // {
type: 0, // code: 'distance',
value: 0, // title: '',
}, { // type: 0,
code: 'time', // value: 0,
// },
{
code: 'createTimeSort',
title: '时间', title: '时间',
type: 0, type: 0,
value: 0, value: 1,
}, { }, {
code: 'reset', code: 'reset',
type: 1, 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: [], tasks: [],
curTask: null, curTask: null,
takeCertify: false, takeCertify: false,
@ -217,11 +256,14 @@
showForwardModal: false, showForwardModal: false,
showTakeCertifiedModal: false, showTakeCertifiedModal: false,
showTakeSuccessModal: false, showTakeSuccessModal: false,
curUserInfo: {},
inputGoodsName: null,
areaList: [], areaList: [],
areaMultiIndex: [0, 0, 0], areaMultiIndex: [0, 0, 0],
chosenArea: [],
categoryList: [], categoryList: [],
categoryMultiIndex: [0, 0, 0], categoryMultiIndex: [0, 0, 0],
curUserInfo: {} chosenCategory: []
} }
}, },
onShow() { onShow() {
@ -232,15 +274,26 @@
// this.tasks = await this.$api.data('tasks'); // this.tasks = await this.$api.data('tasks');
this.curUserInfo = this.$request.getCurUserInfo(); this.curUserInfo = this.$request.getCurUserInfo();
this.reloadMasterOrderPage(); this.reloadMasterOrderPage();
this.takeCertify = await this.$api.data('takeCertify'); // this.takeCertify = await this.$api.data('takeCertify');
this.areaList = await this.$api.data('areaList'); // this.areaList = await this.$api.data('areaList');
this.categoryList = await this.$api.data('categoryList'); // this.categoryList = await this.$api.data('categoryList');
this.loadCategoryList();
this.loadRegionList();
}, },
async loadMasterOrderPage(params = {}) { async loadMasterOrderPage(params = {}) {
params.pageSize = this.$globalData.initPageSize; params.pageSize = this.$globalData.initPageSize;
params.pageNum = this.pageNum; params.pageNum = this.pageNum;
params.orderStatus = 0; params.orderStatus = 0;
params.workerId = -1; 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(); this.$refs.loadStatusBar.showLoading();
try { try {
@ -280,16 +333,62 @@
// //
let orderVal = this.taskConditions[this.tabCur].value; let orderVal = this.taskConditions[this.tabCur].value;
this.taskConditions[this.tabCur].value = orderVal === 0 ? 1 : 0; this.taskConditions[this.tabCur].value = orderVal === 0 ? 1 : 0;
}
this.searchTasks(); 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() { searchTasks() {
let qryObj = {}; this.reloadMasterOrderPage();
this.taskConditions.forEach((condition) => { },
qryObj[condition.code] = condition.value; resetConditions() {
}) this.inputGoodsName = null;
qryObj.name = this.searchInputVal; for(let i = 0; i < this.originTaskConditions.length; i++) {
//TODO: tasks this.taskConditions[i].value = this.originTaskConditions[i].value;
}
this.chosenArea = [];
this.chosenCategory = [];
// this.$forceUpdate();
this.reloadMasterOrderPage();
}, },
regionChange(e) { regionChange(e) {
this.areaMultiIndex = e.detail.value; this.areaMultiIndex = e.detail.value;
@ -297,15 +396,72 @@
for (let i = 0; i < this.areaList.length; i++) { for (let i = 0; i < this.areaList.length; i++) {
chosenArea.push(this.areaList[i][this.areaMultiIndex[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; this.categoryMultiIndex = e.detail.value;
let chosenCategory = []; let chosenCategory = [];
for (let i = 0; i < this.categoryList.length; i++) { for (let i = 0; i < this.categoryList.length; i++) {
chosenCategory.push(this.categoryList[i][this.categoryMultiIndex[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) { showDemandDetail(e, task) {
let paramObj = { let paramObj = {
@ -356,5 +512,16 @@
</script> </script>
<style scoped> <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> </style>

View File

@ -379,6 +379,9 @@
// params.orderStatus = this.subStateList[this.tabCur].code; // params.orderStatus = this.subStateList[this.tabCur].code;
// params.pageNum = this.pageParams[this.tabCur].pageNum; // params.pageNum = this.pageParams[this.tabCur].pageNum;
params.pageNum = this.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) { if (this.tabCur != null) {
params.orderStatus = this.subStateList[this.tabCur].code; params.orderStatus = this.subStateList[this.tabCur].code;
} else if (this.stateCur != null) { } else if (this.stateCur != null) {
@ -532,9 +535,8 @@
} }
this.formData.category = chosenCategory; this.formData.category = chosenCategory;
}, },
searchOrder(e) { searchOrder() {
console.log(e) this.reloadMasterOrderPage();
console.log(this.formData)
}, },
resetConditions() { resetConditions() {
this.formData = { this.formData = {