Commit 384009e4 authored by Damon's avatar Damon

refactor: 物料选择-交互修改

parent 21ad03c9
<template> <template>
<view class="u-flex content"> <view class="u-flex content">
<view class="categary" v-if="type === '2'">
<view class="u-flex u-col-center">
<view :class="['txt', {'active': categoryId === item.categoryId }]" v-for="item in categary" :key="item.categoryId" @click="changeCategary(item)">{{item.label}}</view>
</view>
</view>
<view class="search"> <view class="search">
<u-search <u-search
:clearabled="true" :clearabled="true"
...@@ -11,15 +17,6 @@ ...@@ -11,15 +17,6 @@
></u-search> ></u-search>
</view> </view>
<view class="categary" v-if="type === '2'">
<view class="u-flex u-col-center">
<picker mode="selector" :value="categaryIndex" range-key="label" :range="categary" @click="show = true" @change="changeCategary">
<view class="txt">{{categary[categaryIndex].label || '请选择'}}</view>
</picker>
<u-icon class="input-icon" color="#2272FF" :name="show ? 'arrow-up' : 'arrow-down'"></u-icon>
</view>
</view>
<view class="warp u-flex"> <view class="warp u-flex">
<view class="brand u-flex" v-if="brand.length > 0"> <view class="brand u-flex" v-if="brand.length > 0">
<view class="label-content u-flex"> <view class="label-content u-flex">
...@@ -40,6 +37,25 @@ ...@@ -40,6 +37,25 @@
</view> </view>
</view> </view>
<view class="model u-flex" v-if="brand.length > 0">
<view class="label-content u-flex">
<scroll-view
style="width:100%;white-space: nowrap;"
scroll-x="true"
class="u-flex"
:scroll-into-view="scrollId"
>
<view :id="`brand${item.brandId}`" :class="['label-title', { selected: item.brandId == brandId }]" v-for="(item, index) in brand" :key="index" @click="selectBrand(item, index)">{{ item.label }}</view>
</scroll-view>
</view>
<view class="more u-flex" @click="handleClick">
<!-- <picker mode="selector" :value="brandIndex" range-key="label" :range="brand" @click="show = true" @change="changeBrand"> -->
<!-- <view class="more-text">更多</view> -->
<!-- </picker> -->
<u-icon class="input-icon" color="#666" name="arrow-down"></u-icon>
</view>
</view>
<view class="lists"> <view class="lists">
<scroll-view <scroll-view
style="height:100%;" style="height:100%;"
...@@ -92,7 +108,7 @@ export default { ...@@ -92,7 +108,7 @@ export default {
categary: [], categary: [],
brand: [], brand: [],
categaryIndex: 0, categaryIndex: 0,
categaryId: '', categoryId: '',
brandIndex: 0, brandIndex: 0,
brandId: 0, brandId: 0,
scrollId: '', scrollId: '',
...@@ -131,7 +147,7 @@ export default { ...@@ -131,7 +147,7 @@ export default {
getApp().trackPage('选择配件页') getApp().trackPage('选择配件页')
if (e) { if (e) {
if (e.type == 1) { if (e.type == 1) {
this.categaryId = e.categaryId || '' this.categoryId = e.categaryId || ''
this.type = e.type this.type = e.type
this.getBrandList(e.brandId) this.getBrandList(e.brandId)
} else if (e.type == 2) { } else if (e.type == 2) {
...@@ -161,7 +177,11 @@ export default { ...@@ -161,7 +177,11 @@ export default {
v.label = v.categoryName v.label = v.categoryName
return v return v
}) })
this.categaryId = this.categary[0].categoryId this.categary.push({
categoryId: 2,
label: '非桩类',
})
this.categoryId = this.categary[0].categoryId
this.getBrandList() this.getBrandList()
} else { } else {
this.getPartsList() this.getPartsList()
...@@ -171,10 +191,9 @@ export default { ...@@ -171,10 +191,9 @@ export default {
}, },
// 获取品牌 // 获取品牌
getBrandList(id) { getBrandList(id) {
this.$u.api.getBrandList({categoryId: this.categaryId}).then(res => { this.$u.api.getBrandList({categoryId: this.categoryId}).then(res => {
if (res.code === 200) { if (res.code === 200) {
const data = res.data const data = res.data
if (data.length > 0) {
let item, index let item, index
this.brand = data.map((v, i) => { this.brand = data.map((v, i) => {
if (id && parseInt(id) === v.brandId) { if (id && parseInt(id) === v.brandId) {
...@@ -189,12 +208,11 @@ export default { ...@@ -189,12 +208,11 @@ export default {
this.selectBrand(item, index) this.selectBrand(item, index)
this.scrollId = `brand${item.brandId}` this.scrollId = `brand${item.brandId}`
} else { } else {
this.brandId = this.brand[0].brandId this.brandId = this.brand?.[0]?.brandId
this.lists = [] this.lists = []
this.getPartsList() this.getPartsList()
} }
} }
}
}) })
}, },
// 获取配件列表 // 获取配件列表
...@@ -204,7 +222,7 @@ export default { ...@@ -204,7 +222,7 @@ export default {
const params = { const params = {
pageNumber: this.pageNumber, pageNumber: this.pageNumber,
pageSize: this.pageSize, pageSize: this.pageSize,
categoryId: this.categaryId || '', categoryId: this.categoryId || '',
brandId: this.brandId || '', brandId: this.brandId || '',
keyword: this.keyword keyword: this.keyword
} }
...@@ -239,8 +257,7 @@ export default { ...@@ -239,8 +257,7 @@ export default {
}, },
// 选择品类 // 选择品类
changeCategary(data) { changeCategary(data) {
this.categaryIndex = data.detail.value this.categoryId = data.categoryId
this.categaryId = this.categary[this.categaryIndex || 0].categoryId
this.brandIndex = '' this.brandIndex = ''
this.show = false this.show = false
this.pageNumber = 1 this.pageNumber = 1
...@@ -272,7 +289,7 @@ export default { ...@@ -272,7 +289,7 @@ export default {
}, },
// 点击更多 // 点击更多
handleClick() { handleClick() {
this.$u.route({url: 'pages/order/document-tag' + '?categoryId=' + this.categaryId + '&selectedId=' + this.brandId}) this.$u.route({url: 'pages/order/document-tag' + '?categoryId=' + this.categoryId + '&selectedId=' + this.brandId})
}, },
// 加入申请 // 加入申请
apply(item, index) { apply(item, index) {
...@@ -319,12 +336,17 @@ export default { ...@@ -319,12 +336,17 @@ export default {
} }
.categary { .categary {
width: 100%; width: 100%;
padding: 0 30rpx 30rpx; padding: 20rpx 30rpx 0rpx;
.txt { .txt {
font-size: 32rpx; font-size: 36rpx;
color: #333;
margin-right: 30rpx;
}
.active {
font-size: 48rpx;
color: #333; color: #333;
font-weight: bold; font-weight: bold;
margin-right: 15rpx; margin-right: 30rpx;
} }
} }
...@@ -339,7 +361,6 @@ export default { ...@@ -339,7 +361,6 @@ export default {
overflow: hidden; overflow: hidden;
.brand { .brand {
width: 100%; width: 100%;
border-bottom: 2rpx solid #F4F5F7;
padding-bottom: 20rpx; padding-bottom: 20rpx;
.label-content { .label-content {
flex: 1; flex: 1;
...@@ -348,19 +369,50 @@ export default { ...@@ -348,19 +369,50 @@ export default {
border-right: 2rpx solid #F4F5F7; border-right: 2rpx solid #F4F5F7;
.label-title { .label-title {
color:#666; color:#666;
padding: 10rpx 0rpx;
margin-right: 40rpx;
display:inline-block;
font-size: 32rpx;
&.selected {
color: #2272ff;
border-bottom: 4rpx solid #2272ff;
font-size: 36rpx;
font-weight: bold;
}
}
}
.more {
width: 100rpx;
padding-left: 20rpx;
.more-text {
color: #2272FF;
font-size: 26rpx;
}
}
}
.model {
width: 100%;
padding: 20rpx 0;
.label-content {
flex: 1;
overflow: hidden;
padding-right: 20rpx;
border-right: 2rpx solid #F4F5F7;
.label-title {
background: #F4F5F7; background: #F4F5F7;
padding: 12rpx 40rpx; color: #999;
padding: 7rpx 30rpx;
margin-right: 20rpx; margin-right: 20rpx;
border-radius: 10rpx; display: inline-block;
display:inline-block; font-size: 26rpx;
border-radius: 30rpx;
&.selected { &.selected {
color: #fff; color: #fff;
background: #2272ff; background: #2272FF;
} }
} }
} }
.more { .more {
width: 100rpx;
padding-left: 20rpx; padding-left: 20rpx;
.more-text { .more-text {
color: #2272FF; color: #2272FF;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment