Commit c21bb82d authored by Facius's avatar Facius

备件选择

parent 83b2f6e3
<template> <template>
<view class="spare-item"> <view class="spare-item">
<view class="left-view"> <view class="left-view">
<u-checkbox v-if="showChecked" icon-size="28" size="40" v-model="item.selected" @change="handleChange" shape="circle"/> <u-checkbox v-if="showChecked" icon-size="28" size="40" v-model="check" @change="handleChange" shape="circle"/>
<image class="image-view" :src="imageUrl"></image> <image class="image-view" :src="imageUrl"></image>
<view class="info-view"> <view class="info-view">
<view class="name-text">{{item.name}}</view> <view class="name-text">{{item.name}}</view>
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
</view> </view>
<view class="count-view"> <view class="count-view">
<view v-if="showChecked"> <view v-if="showChecked">
<u-number-box v-model="item.quantity" :min="item.min || 0" :max="item.max || item[type]" @change="numChange"></u-number-box> <u-number-box v-model="value" :min="item.min || 0" :max="item.max || item[type]" @change="numChange"></u-number-box>
</view> </view>
<text v-else>x{{item[type]|| 0}}</text> <text v-else>x{{item[type]|| 0}}</text>
</view> </view>
...@@ -39,10 +39,12 @@ ...@@ -39,10 +39,12 @@
noteText: { noteText: {
type: String, type: String,
default: '' default: ''
} },
}, },
data() { data() {
return { return {
value: 0,
check: false,
oldCount: 0 oldCount: 0
} }
}, },
...@@ -60,21 +62,27 @@ ...@@ -60,21 +62,27 @@
watch: { watch: {
showChecked(val) { showChecked(val) {
this.oldCount = 0 this.oldCount = 0
} },
'item.quantity'(val) {
this.value = val
},
'item.selected'(val) {
this.check = val
this.value= val ? this.item.stock : 0
},
}, },
methods: { methods: {
handleChange() { handleChange(event) {
this.item.selected = !this.item.selected this.value= event.value ? this.item.stock : 0
this.$emit('change', this.item.selected) this.$emit('change', event.value)
}, },
numChange(event) { numChange(event) {
if (event.value == 0 && this.oldCount > 0) { if (event.value == 0 && this.oldCount > 0) {
this.item.selected = false this.check = false
this.$emit('change', this.item.selected) this.$emit('change', this.check)
} else if (event.value > 0 && this.oldCount == 0) { } else if (event.value > 0 && this.oldCount == 0) {
this.item.selected = true this.check = true
this.$emit('change', this.item.selected) this.$emit('change', this.check)
} }
this.oldCount = event.value this.oldCount = event.value
this.$emit('numChange', event.value) this.$emit('numChange', event.value)
......
...@@ -145,6 +145,7 @@ ...@@ -145,6 +145,7 @@
let list = res.data || [] let list = res.data || []
for (var item of list) { for (var item of list) {
item.selected = false item.selected = false
item.quantity = 0
this.partsList.push(item) this.partsList.push(item)
} }
......
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