Commit 3ea91751 authored by Facius's avatar Facius

备件库备注

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