flying-monkey/pagesA/mountingsList/mountingsList.vue

344 lines
9.8 KiB
Vue

<template>
<view class="content">
<statusNav returnColor="#c2c2c2" navBarTitle="配件列表"></statusNav>
<container-subgroup-two>
<view slot="content" style="margin: -26rpx -25rpx 0rpx" :style="{paddingTop:statusBarHeight + 'px'}">
<view class="mountingsList-input" :style="{top:statusBarHeight + 'px'}">
<input type="text" class="int fon24" value="" placeholder="请输入关键字" />
<image class="search" src="../../static/iocn/ss.png" mode="" lazy-load></image>
<view class="xian"></view>
</view>
<view class="mountings-list">
<view class="li radius10 animated fadeIn" v-for="(item,index) in dataList.data" :key="index">
<view class="textCon" style="padding: 0rpx 16rpx;">
<view class="imgCon">
<image :src="item.images" class="img radius10" mode="aspectFill" lazy-load></image>
<!-- <image src="/static/del/img001.png" class="img radius10" mode="aspectFill"></image> -->
</view>
<view class="text" style="104rpx">
<view class="title disjbac posir">
<view class="clips1 mar-y40 bold fon24">{{item.name}}</view>
<view class="ispitchOn" @click="ispitchOnFun(item)" style="position: absolute;right: 0;">
<image v-if="item.isJob" src="../../static/iocn/pxz.png" class="icon1" mode="" lazy-load></image>
<view v-else class="icon"></view>
</view>
</view>
<view class="brand p scal09" style="margin-left: -20rpx;">配件品牌:{{item.brand}}</view>
<view class="model p scal09" style="margin-left: -20rpx;">规格型号:{{item.model}}</view>
<view class="num p">
<view class="scal09" style="margin-left: -8rpx;">已用数量:{{item.remark || 0}}张</view>
<view class="numBtn">
<view class="subtract" @click="addDelEv(item,0)">-</view>
<view class="sum">{{item.num}}</view>
<view class="add" @click="addDelEv(item,1)">+</view>
</view>
</view>
</view>
</view>
<view class="bottom line-h40">
<view class="p scal09 width100" style="margin-left: -20rpx;">*请注意规格型号的选择,不同型号不同价格。</view>
<view class="sum fon24 bold flexs">费用合计:¥{{item.sum}}</view>
</view>
</view>
<pitera v-if="dataList.data.length" textStr="暂无更多配件列表数据"></pitera>
<nothing-page v-if="dataList.data.length==0 && !ifLoading"></nothing-page>
</view>
<button v-show="dbtn" class="submit-button" @tap="submitEv" type="default"></button>
</view>
</container-subgroup-two>
</view>
</template>
<script>
import statusNav from '../../components/status-nav.vue';
import containerSubgroupTwo from '@/components/containers/container-subgroup-two.vue';
import pitera from '@/components/nothing/pitera.vue';
export default {
components: {
statusNav,
containerSubgroupTwo,
pitera
},
data() {
return {
statusBarHeight:uni.getSystemInfoSync().statusBarHeight+40,
dataList: {
list_rows: 10,
page: 1,
data:[],
},
total:0,
temporaryList:[] ,// 暂时存储选中的配件列表
ifLoading:true,
dbtn:false
}
},
onReachBottom() {
if(this.total!=this.dataList.data.length) {
this.dataList.page++;
this.getData();
}
},
onLoad() {
// 调用获取配件列表事件
this.getData()
},
methods: {
// 切换选取配件事件
ispitchOnFun(item) {
item.isJob = !item.isJob;
// 调用暂存配件列表事件
this.temporaryEv();
},
// 将选中的配件存储到暂存配件数组
temporaryEv(){
this.temporaryList = [];
this.dataList.data.forEach(item=>{
if(item.isJob) {
this.temporaryList.push(item);
}
})
uni.setStorageSync('partsList',this.temporaryList);
this.temporaryList.length ? this.dbtn = true : this.dbtn = false;
},
// 配件数量加减事件
addDelEv(item,index) {
if (index==0) {
// 减数量
if(item.num!=1) {
item.num--;
item.sum = this.$toolAll.tools.operationEv(item.price*1, item.num*1, '*',2);
}
} else {
// 加数量
item.num++;
item.sum = this.$toolAll.tools.operationEv(item.price*1, item.num*1, '*',2);
}
// 调用暂存配件列表事件
this.temporaryEv();
},
// 获取配件列表事件
getData() {
uni.showLoading({
title:'加载中...',
mask:true
})
this.$requst.get('/universal/api.accessory/accessory_list', {
list_rows: this.dataList.list_rows,
page: this.dataList.page,
}).then(res => {
if (res.code == 1) {
this.dataList.data = res.data.data;
this.total = res.data.total;
console.log(res,'配件数据')
for (var i = 0; i < this.dataList.data.length; i++) {
this.$set(this.dataList.data,i,{num:1,...this.dataList.data[i],sum:this.dataList.data[i].price,isJob:false})
}
// 获取处理工单下的配件列表
let newList = uni.getStorageSync('partsList');
// 如果配件列表页面的列表数据不为空
if(this.dataList.data.length) {
this.dataList.data.forEach(item1=>{
// 如果处理工单下的配件列表不为空
if(newList.length!=0) {
newList.forEach((item,index)=>{
// 如果配件列表页面的配件id等于处理工单下的配件列表的配件id
if(item1.id==item.id) {
// 选中配件列表页面下的对应配件
item1.isJob = true;
// 设置配件列表页面下的配件数量
item1.num = item.num;
// 设置配件列表页面下的费用合计
item1.sum = item.sum;
// 删除临时处理工单下的配件列表对应数据
newList.splice(index,1)
}
})
// 调用暂存配件列表事件
this.temporaryEv();
}
})
}
}
uni.hideLoading();
this.ifLoading = false;
})
},
// 确认提交事件
submitEv(){
console.log(uni.getStorageSync('partsList'),146);
uni.navigateBack({delta:1})
}
}
}
</script>
<style>
.content {
padding-top: 70rpx;
}
.mountingsList-input .xian {
width: 3rpx;
height: 35rpx;
z-index: 100;
position: absolute;
background-color: #EAEAEA;
right: 100rpx;
top: 50%;
margin-top: -14rpx;
}
.submit-button {
position: fixed;
bottom: 20rpx;
left: 50%;
transform: translateX(-50%);
width: 686rpx;
border-radius: 50rpx;
margin-top: 60rpx;
height: 90rpx;
background-color: #02A2ea;
line-height: 90rpx;
color: #FFFFFF;
text-align: center;
font-size: 30rpx;
}
.mountingsList-input {
width: 100%;
position: fixed;
padding: 40rpx 16rpx;
z-index: 2;
box-sizing: border-box;
background-color: #FFFFFF
}
.mountingsList-input .int {
width: 100%;
background-color: #F7F7F7;
padding: 0 25rpx;
height: 67rpx;
box-sizing: border-box;
border-radius: 36rpx;
}
.mountingsList-input .search {
width: 28rpx;
height: 28rpx;
position: absolute;
right: 43rpx;
top: 50%;
margin-top: -14rpx;
}
.mountings-list .li {
width: 680rpx;
margin: auto;
margin-top: 20rpx;
background-color: #FFFFFF;
padding: 30rpx 20rpx 0rpx;
}
.mountings-list .li .textCon {
display: flex;
border-bottom: 2rpx solid #F5F5F5;
}
.mountings-list .li .imgCon {
width: 217rpx;
height: 140rpx;
background-color: #CCCCCC;
border-radius: 5rpx;
display: flex;
align-items: center;
justify-content: center;
margin-right: 18rpx;
padding: 20rpx;
box-sizing: border-box;
}
.mountings-list .li .text {
flex: 1;
}
.mountings-list .li .imgCon .img {
width: 169rpx;
height: 104rpx;
position: relative;
z-index: 1;
}
.mountings-list .li .title .ispitchOn .icon {
width: 26rpx;
height: 26rpx;
border: 2rpx solid #CCCCCC;
box-sizing: border-box;
border-radius: 50%;
}
.mountings-list .li .title .ispitchOn .icon1 {
width: 26rpx;
height: 26rpx;
border-radius: 50%;
}
.mountings-list .li .text .p {
color: #999999;
font-size: 24rpx;
margin-top: 5rpx;
}
.mountings-list .li .text .num {
display: flex;
justify-content: space-between;
}
.mountings-list .li .text {
padding-bottom: 20rpx;
}
.numBtn {
display: flex;
align-items: center;
}
.numBtn .subtract {
border: 2rpx solid #F5F5F5;
width: 36rpx;
height: 36rpx;
border-radius: 50%;
text-align: center;
line-height: 25rpx;
color: #333333;
font-size: 50rpx
}
.numBtn .sum {
color: #333333;
padding: 0 15rpx;
}
.numBtn .add {
width: 36rpx;
height: 36rpx;
border-radius: 50%;
text-align: center;
line-height: 35rpx;
font-size: 35rpx;
background-color: #f82a34;
color: #FFFFFF;
}
.mountings-list .li .bottom {
padding: 14rpx;
display: flex;
justify-content: space-between;
font-size: 24rpx;
}
.mountings-list .li .bottom .sum {
color: #ff0000;
}
</style>