| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489 |
- <template>
- <view>
- <u-navbar title="备件信息搜索" :background="{ background: '#0082FF' }" title-color="#F8F8F8" back-icon-color="#F8F8F8">
- <template #right>
- <view class="px3" style="color: #F8F8F8;" @tap="save">保存</view>
- </template>
- </u-navbar>
- <view class="u-wrap">
- <view class="fixed-box">
- <!-- 搜索 -->
- <view class="d-flex a-center mt-3 search ">
- <view class="pl-3 flex1">
- <u-input v-model="keyword" placeholder="名称/规格/原厂编号" :clearable="false" />
- </view>
- <view @click="search" class="main-linear d-flex a-center text-color-white f-size-26 j-center search-txt">
- 搜索</view>
- </view>
- <!-- 筛选 -->
- <view class="d-flex j-end a-center flex1 my3 screen-box">
- <view class="ml-3 line1" style="" @click="handleScreen">
- <text style="color: #535B67;">类型筛选</text>
- <image src="/static/images/select.png" class="ml-1 w20"></image>
- </view>
- </view>
- </view>
- <view class="page-view">
- <view class="class-item">
- <view class="item-container">
- <!-- 列表 -->
- <view @click="handleBack(item)" class="d-flex list-box border-radius-3 p3 mb-2" v-for="item in listData" :key="item.id">
- <view class="left d-flex j-center a-center mr-2">
- <image v-if="item.image" :src="$BaseTool.UserUtil.getFileUrl(item.image)" class="bg-color-light img"></image>
- <image v-else :src="spare_default" class="bg-color-light img"></image>
- </view>
- <view class="right d-flex f-column flex1">
- <view class="f-size-30 f-weight-6 one-ellipsis" :class="{'main-color-text':goods.find(good=>good.id===item.id)}">{{ item.name }}</view>
- <view class="f-size-22 text-color-9 my2 one-ellipsis">
- {{ item.no }} / {{ item.ggxh }}
- </view>
- <view class="f-size-20 ">
- <text class="main-color-text mr-1 list-box-item">{{ selectTypeName }}</text>
- </view>
- <view class="d-flex j-between a-center mt-1 text-color-6">
- <text>单价:¥{{ $BaseTool.Amount.formatter(item.initialValue) }} </text>
- <text>当前库存:{{ item.num }} </text>
- </view>
- </view>
- <u-checkbox :value="Boolean(goods.find(good=>good.id===item.id))"></u-checkbox>
- </view>
- </view>
- </view>
- </view>
- <!-- 弹出层 -->
- <u-popup v-model="show" mode="right" width="600rpx" safe-area-inset-bottom>
- <view class="mx2 py3 popup" style="padding-bottom: 120rpx;">
- <view class="wrap">
- <view class="f-size-30 f-weight-6 py3">一级类别</view>
- <view class="d-flex f-wrap a-center box">
- <block v-for="item in parentTypeList" :key="item.id">
- <view class="col3">
- <view class="d-flex j-center a-center border-radius-1 mb-2 py1 item f-size-22" @click="handleSelect(item)" :class="active == item.id?"item_s":""">{{ item.name }}
- </view>
- </view>
- </block>
- </view>
- </view>
- <view class="wrap">
- <view class="f-size-30 f-weight-6 py3">二级类别</view>
- <view class="d-flex f-wrap a-center box">
- <block v-for="item in middleTypeList" :key="item.id">
- <view class="col3">
- <view class="d-flex j-center a-center border-radius-1 mb-2 py1 item f-size-22" @click="handleSelectTwo(item)" :class="activeTwo == item.id?"item_s":""">
- {{ item.name }}</view>
- </view>
- </block>
- </view>
- </view>
- <view class="wrap">
- <view v-if="childTypeList.length > 0" class="f-size-30 f-weight-6 py3">三级类别</view>
- <view class="d-flex f-wrap a-center box">
- <block v-for="item in childTypeList" :key="item.id">
- <view class="col3">
- <view class="d-flex j-center a-center border-radius-1 mb-2 py1 item f-size-22" @click="handleSelectThree(item)" :class="activeThree == item.id?"item_s":""">
- {{ item.name }}</view>
- </view>
- </block>
- </view>
- </view>
- <!-- 按钮 -->
- <view class="d-flex j-around a-center p-fixed left0 right0 bottom0 bg-color-white py2 button-box">
- <view @click="resetSelect()" class="main-color-text d-flex a-center j-center f-size-30" style="">重置</view>
- <view @click="search()" class="main-linear text-color-white d-flex a-center j-center f-size-30">确认</view>
- </view>
- </view>
- </u-popup>
- </view>
- </view>
- </template>
- <script>
- import spareDefault from '@/static/images/spare_default.png'
- export default {
- data() {
- return {
- goods: [],
- keyword: '',
- selectTypeName: '',
- listData: [],
- status: 'loadmore',
- page: 1,
- active: 0,
- activeTwo: 0,
- activeThree: 0,
- limit: 20,
- parentTypeId: '',
- middleTypeId: '',
- childTypeId: '',
- parentTypeName: '',
- middleTypeName: '',
- childTypeName: '',
- typeId: '',
- spare_default: spareDefault,
- parentTypeList: [],
- middleTypeList: [],
- childTypeList: [],
- storeId: null,
- spareId: null,
- spareName: null,
- price: 0,
- num: 0,
- loadMore: true,
- show: false
- }
- },
- onLoad(option) {
- // this.storeId = JSON.parse(decodeURIComponent(option.storeId))
- if (this.parentTypeList.length == 0) {
- this.$Http
- .querySpareType({
- filter: 1
- })
- .then(res => {
- this.parentTypeList = res.data
- this.parentTypeId = this.parentTypeList[0].id
- this.selectTypeName = this.parentTypeList[0].name
- this.initData()
- })
- }
- },
- onPullDownRefresh() {
- // 请求结束取消刷新
- this.page = 1
- this.loadMore = true
- this.listData = []
- this.initData()
- uni.stopPullDownRefresh()
- },
- onReachBottom() {
- if (this.loadMore) {
- this.page++
- this.initData()
- }
- },
- methods: {
- /* handleSelect(item) {
- item.selected = !item.selected
- }, */
- handleScreen() {
- this.show = true
- },
- initData() {
- const that = this
- that.status = 'loading'
- this.$Http
- .getSpareBomRecordPage({
- pageNum: that.page,
- pageSize: that.limit,
- typeId: that.typeId,
- keyword: that.keyword,
- dataScope: {
- sortBy: 'desc',
- sortName: 'bom.created_time'
- }
- })
- .then(res => {
- const data = res.data.rows
- if (data && data.length > 0 && data.length < that.limit) {
- that.status = 'nomore'
- that.loadMore = false
- } else if (data.length == that.limit) {
- that.status = 'loadmore'
- } else {
- that.status = 'nomore'
- }
- that.listData = data
- })
- },
- handleSelect(item) {
- this.active = item.id
- this.parentTypeId = item.id
- this.parentTypeName = item.name
- this.selectTypeName = this.parentTypeName
- this.typeId = item.id
- this.$Http
- .querySpareType({
- filter: 2,
- parentId: item.id,
- dataScope: {
- sortBy: 'desc',
- sortName: 'name'
- }
- })
- .then(res => {
- this.middleTypeList = res.data
- this.middleTypeId = null
- this.activeTwo = 0
- this.childTypeList = []
- })
- },
- handleSelectTwo(item) {
- this.activeTwo = item.id
- this.middleTypeId = item.id
- this.middleTypeName = item.name
- this.selectTypeName = this.middleTypeName
- this.typeId = item.id
- this.$Http
- .querySpareType({
- filter: 2,
- parentId: item.id,
- dataScope: {
- sortBy: 'desc',
- sortName: 'name'
- }
- })
- .then(res => {
- this.childTypeList = res.data
- })
- },
- handleSelectThree(item) {
- this.activeThree = item.id
- this.childTypeId = item.id
- this.childTypeName = item.name
- this.selectTypeName = this.childTypeName
- this.typeId = item.id
- },
- search() {
- this.page = 1
- this.show = false
- this.loadMore = true
- this.listData = []
- this.initData()
- },
- resetSelect() {
- this.parentTypeId = ''
- this.middleTypeId = ''
- this.childTypeId = ''
- this.parentTypeName = ''
- this.middleTypeName = ''
- this.childTypeName = ''
- this.typeId = ''
- this.active = 0
- this.activeTwo = 0
- this.activeThree = 0
- },
- handleBack(item) {
- if (this.goods.find(good => good.id === item.id)) {
- this.goods = this.goods.filter(good => good.id !== item.id)
- } else {
- item.num = 1
- item.checked = 2
- this.goods.push(item)
- }
- },
- save() {
- const pages = getCurrentPages()
- const prevPage = pages[pages.length - 2]
- prevPage.goods = this.goods
- this.goods = []
- uni.navigateBack(1)
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .fixed-box {
- position: fixed;
- left: 0;
- right: 0;
- background-color: #fff;
- padding: 0 16px;
- z-index: 1000;
- }
- .u-wrap {
- .list-box {
- box-shadow: 5rpx 5rpx 10rpx rgba(0, 0, 0, 0.2);
- width: 100%;
- .img {
- width: 120rpx;
- height: 120rpx;
- border-radius: 50%;
- }
- &-item {
- padding: 2rpx 15rpx;
- border-radius: 10rpx;
- background-color: #ffeae5;
- color: #fa5445;
- }
- }
- .search {
- border-radius: 50rpx;
- height: 70rpx;
- width: 100%;
- border: 1px solid #0082ff;
- &-txt {
- height: 70rpx;
- border-radius: 50rpx;
- width: 120rpx;
- }
- }
- .screen-box {
- .line1 {
- background-color: #f2f3f4;
- padding: 3rpx 20rpx;
- border-radius: 10rpx;
- }
- .w20 {
- width: 20rpx;
- height: 16rpx;
- }
- }
- }
- .u-wrap {
- height: calc(100vh);
- /* #ifdef H5 */
- height: calc(100vh - var(--window-top));
- /* #endif */
- display: flex;
- flex-direction: column;
- }
- .u-search-box {
- padding: 18rpx 30rpx;
- }
- .u-menu-wrap {
- flex: 1;
- display: flex;
- overflow: hidden;
- }
- .u-search-inner {
- background-color: rgb(234, 234, 234);
- border-radius: 100rpx;
- display: flex;
- align-items: center;
- padding: 10rpx 16rpx;
- }
- .u-search-text {
- font-size: 26rpx;
- color: $u-tips-color;
- margin-left: 10rpx;
- }
- .u-tab-view {
- width: 200rpx;
- height: 100%;
- }
- .u-tab-item {
- height: 110rpx;
- background: #f6f6f6;
- box-sizing: border-box;
- display: flex;
- align-items: center;
- justify-content: center;
- font-size: 26rpx;
- color: #444;
- font-weight: 400;
- line-height: 1;
- }
- .u-tab-item-active {
- position: relative;
- color: #000;
- font-size: 30rpx;
- font-weight: 600;
- background: #fff;
- }
- .u-tab-view {
- height: 100%;
- }
- .right-box {
- background-color: rgb(250, 250, 250);
- }
- .page-view {
- margin-top: 90px;
- padding: 16rpx;
- }
- .class-item {
- margin-bottom: 30rpx;
- background-color: #fff;
- padding: 16rpx;
- border-radius: 8rpx;
- }
- .item-title {
- font-size: 26rpx;
- color: $u-main-color;
- font-weight: bold;
- }
- .item-menu-name {
- font-weight: normal;
- font-size: 24rpx;
- color: $u-main-color;
- }
- .item-container {
- display: flex;
- flex-wrap: wrap;
- }
- .thumb-box {
- width: 33.333333%;
- display: flex;
- align-items: center;
- justify-content: center;
- flex-direction: column;
- margin-top: 20rpx;
- }
- .item-menu-image {
- width: 120rpx;
- height: 120rpx;
- }
- .main-linear {
- background-color: #0082ff;
- }
- .popup {
- .button-box {
- view {
- width: 230rpx;
- height: 80rpx;
- border-radius: 50rpx;
- }
- view.main-color-text {
- border: 1px solid #0082ff;
- color: #0082ff;
- }
- }
- .box {
- .item {
- width: 90%;
- background-color: #f2f3f4;
- color: #0f1021;
- height: 70rpx;
- }
- .item_s {
- width: 90%;
- background-color: #0082ff;
- color: #ffffff;
- height: 70rpx;
- }
- }
- }
- </style>
|