Commit 3ea91751 authored by Facius's avatar Facius

备件库备注

parent 8774a90e
......@@ -2,46 +2,56 @@
<!-- 我的备件 -->
<view class="ware-house-spare">
<u-navbar back-icon-color="#333333" background="#FFFFFF" title="备件库" titleColor="#333333"
:border-bottom="false" title-bold></u-navbar>
:border-bottom="false" title-bold></u-navbar>
<!-- 搜索 -->
<view class="search-view">
<u-search v-model="keyword" :action-text="searchButtonText" @search="handleClickSearch" @clear="handleClear"
@custom="handleClickButton" placeholder="请输入关键字" :action-style="actionStyle" placeholder-color="#999999"
color="#333333" bg-color="#FFFFFF" height="72" search-icon-color="#999999">
</u-search>
</view>
<NoOrder v-if="noParts" imageName="wupeijianxinxi.png" text="当前暂无备件信息" :customStyle="noPartsCustomStyle" />
</view>
<!-- 无结果 -->
<NoOrder v-if="noParts" imageName="wupeijianxinxi.png" text="当前暂无备件信息" :customStyle="noPartsCustomStyle" />
<!-- 备件 -->
<template v-else>
<view class="title-view" v-if="loaded">
<view>备件列表</view>
<view class="title-right-view">
<view class="bounce-view" v-if="!showBounce" @click="showBounce = true">退件</view>
<u-button v-else :custom-style="buttonStyle" shape="circle" @click="handleClickBounce">退件 ×
</u-button>
<view class="title-right-view">
<!-- 开启退件模式 -->
<view class="bounce-view" v-if="!showBounce" @click="showBounce = true">退件</view>
<!-- 取消退件模式 -->
<u-button v-else :custom-style="buttonStyle" shape="circle" @click="handleClickBounce">退件 ×</u-button>
</view>
</view>
</view>
<!-- 备件列表 -->
<view class="tab-view">
<scroll-view scroll-y style="height: 100%;width: 100%;" scroll-anchoring enable-back-to-top @scroll="scroll">
<!-- 加载转圈页面 -->
<view class="loading-view" v-if="!loaded">
<u-loading mode="flower"></u-loading>
</view>
</view>
<!-- 列表 -->
<template v-else>
<view class="list-item" v-for="(item, index) in partsList" :key="item.id">
<SpareCell :item="item" :showChecked="showBounce" type="stock"
@change="handleChange($event, index)"@numChange="handleNumChange($event, index)" />
</view>
</view>
<!-- 底部加载状态 -->
<view class="load-more-view">
<u-loadmore v-show="partsList.length > 0" status="nomore" bgColor="#F4F5F7">
</u-loadmore>
</view>
</template>
</scroll-view>
</view>
</view>
<!-- 底部按钮控件 -->
<view class="bar" v-if="showBounce">
<SubmitBar :partNum="subBarInfo.partNum" :num="subBarInfo.num" :btnStatus="subBarInfo.btnStatus"
submitTxt="退件" :allChecked="subBarInfo.allChecked" :customStyle="customStyle" @select="allSelect"
@submit="$u.throttle(handleSubmit, 500)" />
</view>
</template>
</template>
<!-- 悬浮申请按钮 -->
<view class="fixed-button" v-show="!showBounce">
<ApplyButton :type.sync="buttonType" @click="handleClickApply"/>
</view>
......@@ -65,25 +75,28 @@
},
data() {
return {
partsList: [],
loaded: false,
showBounce: false,
keyword: '',
searchedKeyword: '',
selectedParts: [],
partsList: [], // 备件列表
loaded: false, // 加载状态
showBounce: false, // 是否进入推荐模式
keyword: '', // 搜索框内的关键字
searchedKeyword: '', // 最新向后台传过的关键字
buttonType: 'expand' // 申请按钮宽 collapse': '80rpx', 'expand': '220rpx''
};
},
computed: {
computed: {
// 搜索图标
sousuoImage() {
return process.uniEnv.qn_base_url + 'sousuo.png'
},
},
// 无结果,展示无结果页面
noParts() {
return this.partsList.length == 0 && this.loaded
},
},
// 无结果页面样式
noPartsCustomStyle() {
return 'margin-top: 100rpx;background-color: #F4F5F7'
},
},
// 取消退件模式按钮风格
buttonStyle() {
return {
width: '100rpx',
......@@ -92,14 +105,16 @@
color: '#2272FF',
fontSize: '26rpx',
}
},
},
// 搜索控件右面'搜索'/'取消'按钮风格
actionStyle() {
return {
'font-size': '32rpx',
'color': '#2272FF',
'margin-left': '20rpx'
}
},
},
// 底部按钮控件数据
subBarInfo() {
var i = 0
var j = 0
......@@ -110,24 +125,33 @@
}
}
return {
partNum: j,
num: i,
btnStatus: j > 0,
allChecked: j > 0 && j == this.partsList.length
partNum: j, // 种类
num: i, // 总数
btnStatus: j > 0, // 提交按钮可以点击
allChecked: j > 0 && j == this.partsList.length // 勾选了全选
}
},
},
// 底部按钮控件样式
customStyle() {
return 'background-color: #F4F5F7;padding: 0rpx;'
},
},
// 搜索控件右面按钮文字 已经搜索过 && 搜多过的文字和传入后台的文字相同:取消;其他:搜索
searchButtonText() {
return this.searchedKeyword == this.keyword && this.keyword ? '取消' : '搜索'
},
},
// 选中的退件
selectedParts() {
return this.partsList.filter((item)=> {
return item.selected == true
})
}
},
onLoad(e) {
getApp().trackPage('备件库页')
this.getReserveList()
this.getReserveList() // 获取备件列表
},
onShow() {
onShow() {
// 退件之后刷新页面
let pages = getCurrentPages();
let page = pages[pages.length - 1];
let needRefresh = page.needRefresh;
......@@ -151,7 +175,7 @@
this.partsList = []
let list = res.data || []
for (var item of list) {
item.selected = false
item.selected = false // 添加新属性 勾选:false
this.partsList.push(item)
}
......@@ -165,51 +189,48 @@
this.getReserveList()
},
handleClear() { // 清空搜索
if (this.searchedKeyword) {
if (this.searchedKeyword) { // 已经搜索过,清空就重新初始搜索
this.getReserveList()
}
},
handleClickButton() { // 点了搜索按钮
if (this.searchedKeyword == this.keyword) {
this.keyword = ''
handleClickButton() { // 点了搜索/取消按钮
if (this.searchedKeyword == this.keyword) { // 取消按钮
this.keyword = '' // 初始化搜索条件
}
this.getReserveList()
},
handleClickBounce() {
handleClickBounce() { // 关闭退件模式
this.showBounce = false
for (var item of this.partsList) {
item.selected = false
item.quantity = 0
}
},
allSelect(value) {
allSelect(value) { // 底部勾选全选
console.log(value)
for (var item of this.partsList) {
item.selected = value
item.quantity = value ? item.stock : 0
}
},
handleChange(value, index) {
handleChange(value, index) { // 备件cell勾选改变
this.partsList[index].selected = value
},
handleNumChange(value, index) {
handleNumChange(value, index) { // 备件cell内数量改变
this.partsList[index].quantity = value
},
handleSubmit() {
const getSelected = (element) => {
return (element.selected);
}
let parts = this.partsList.filter(getSelected);
this.selectedParts = parts
handleSubmit() { // 提交
this.$u.route({
url: 'pages/parts/returnParts',
})
},
},
// 点击了申请备件按钮
handleClickApply() {
uni.navigateTo({
url: 'pages/parts/application?applyType=1'
})
},
},
// 滚动是悬浮按钮收起
scroll() {
this.buttonType = 'collapse'
},
......
......@@ -21,7 +21,7 @@
return {
labels: [], // 标签列表
selectedId: '', // 已选中标签的id
type: '1', // '1': '合作商', '2': '品牌'
type: '1', // '1': '合作商', '2': '品牌', '9': '备件品牌'
};
},
onLoad(e) {
......@@ -44,21 +44,21 @@
return {
'1': '合作商',
'2': '品牌',
'9': ' ' // 配件品牌
'9': ' ' // 备件品牌
}
},
keys() {
return {
'1': 'id', // 合作商
'2': 'id', // 品牌
'9': 'brandId' // 配件品牌
'9': 'brandId' // 备件品牌
}
},
nameKeys() {
return {
'1': 'name', // 合作商
'2': 'name', // 品牌
'9': 'brandName' // 配件品牌
'9': 'brandName' // 备件品牌
}
}
},
......
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