|
|
|
@ -27,7 +27,7 @@
|
|
|
|
<text class="label">物资选择</text>
|
|
|
|
<text class="label">物资选择</text>
|
|
|
|
<view class="multi-select">
|
|
|
|
<view class="multi-select">
|
|
|
|
<view class="selected-items" v-if="selectedMaterials.length > 0">
|
|
|
|
<view class="selected-items" v-if="selectedMaterials.length > 0">
|
|
|
|
<view class="selected-item" v-for="(item, index) in selectedMaterials" :key="item.cargoId">
|
|
|
|
<view class="selected-item" v-for="(item, index) in selectedMaterials" :key="item.id">
|
|
|
|
<text>{{ item.cargoName }} ({{ item.cargoSpec }}) x {{ item.quantity }}</text>
|
|
|
|
<text>{{ item.cargoName }} ({{ item.cargoSpec }}) x {{ item.quantity }}</text>
|
|
|
|
<text class="remove-btn" @click="removeMaterial(index)">x</text>
|
|
|
|
<text class="remove-btn" @click="removeMaterial(index)">x</text>
|
|
|
|
</view>
|
|
|
|
</view>
|
|
|
|
@ -81,26 +81,26 @@
|
|
|
|
<view
|
|
|
|
<view
|
|
|
|
class="material-item"
|
|
|
|
class="material-item"
|
|
|
|
v-for="material in filteredMaterials"
|
|
|
|
v-for="material in filteredMaterials"
|
|
|
|
:key="material.cargoId"
|
|
|
|
:key="material.id"
|
|
|
|
>
|
|
|
|
>
|
|
|
|
<view class="material-info">
|
|
|
|
<view class="material-info">
|
|
|
|
<text class="material-name">{{ material.cargoName }}</text>
|
|
|
|
<text class="material-name">{{ material.cargoName }}</text>
|
|
|
|
<text class="material-spec">{{ material.cargoSpec }}</text>
|
|
|
|
<text class="material-spec">{{ material.cargoSpec }}</text>
|
|
|
|
</view>
|
|
|
|
</view>
|
|
|
|
<view class="item-actions">
|
|
|
|
<view class="item-actions">
|
|
|
|
<view v-if="isMaterialSelected(material.cargoId)" class="quantity-input">
|
|
|
|
<view v-if="isMaterialSelected(material.id)" class="quantity-input">
|
|
|
|
<text class="quantity-btn" @click="decreaseQuantity(material.cargoId)">-</text>
|
|
|
|
<text class="quantity-btn" @click="decreaseQuantity(material.id)">-</text>
|
|
|
|
<input
|
|
|
|
<input
|
|
|
|
type="number"
|
|
|
|
type="number"
|
|
|
|
:value="getMaterialQuantity(material.cargoId)"
|
|
|
|
:value="getMaterialQuantity(material.id)"
|
|
|
|
class="quantity-input-box"
|
|
|
|
class="quantity-input-box"
|
|
|
|
min="1"
|
|
|
|
min="1"
|
|
|
|
@input="updateQuantity(material.cargoId, $event)"
|
|
|
|
@input="updateQuantity(material.id, $event)"
|
|
|
|
/>
|
|
|
|
/>
|
|
|
|
<text class="quantity-btn" @click="increaseQuantity(material.cargoId)">+</text>
|
|
|
|
<text class="quantity-btn" @click="increaseQuantity(material.id)">+</text>
|
|
|
|
</view>
|
|
|
|
</view>
|
|
|
|
<view class="checkbox" :class="{ checked: isMaterialSelected(material.cargoId) }" @click="toggleMaterial(material)">
|
|
|
|
<view class="checkbox" :class="{ checked: isMaterialSelected(material.id) }" @click="toggleMaterial(material)">
|
|
|
|
<text v-if="isMaterialSelected(material.cargoId)">✓</text>
|
|
|
|
<text v-if="isMaterialSelected(material.id)">✓</text>
|
|
|
|
</view>
|
|
|
|
</view>
|
|
|
|
</view>
|
|
|
|
</view>
|
|
|
|
</view>
|
|
|
|
</view>
|
|
|
|
@ -286,7 +286,7 @@ export default {
|
|
|
|
},
|
|
|
|
},
|
|
|
|
// 切换物资选择状态
|
|
|
|
// 切换物资选择状态
|
|
|
|
toggleMaterial(material) {
|
|
|
|
toggleMaterial(material) {
|
|
|
|
const index = this.tempSelectedMaterials.findIndex(item => item.cargoId === material.cargoId);
|
|
|
|
const index = this.tempSelectedMaterials.findIndex(item => item.id === material.id);
|
|
|
|
if (index > -1) {
|
|
|
|
if (index > -1) {
|
|
|
|
this.tempSelectedMaterials.splice(index, 1);
|
|
|
|
this.tempSelectedMaterials.splice(index, 1);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
@ -295,31 +295,31 @@ export default {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
// 检查物资是否已选择
|
|
|
|
// 检查物资是否已选择
|
|
|
|
isMaterialSelected(cargoId) {
|
|
|
|
isMaterialSelected(id) {
|
|
|
|
return this.tempSelectedMaterials.some(item => item.cargoId === cargoId);
|
|
|
|
return this.tempSelectedMaterials.some(item => item.id === id);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
// 获取物资数量
|
|
|
|
// 获取物资数量
|
|
|
|
getMaterialQuantity(cargoId) {
|
|
|
|
getMaterialQuantity(id) {
|
|
|
|
const item = this.tempSelectedMaterials.find(item => item.cargoId === cargoId);
|
|
|
|
const item = this.tempSelectedMaterials.find(item => item.id === id);
|
|
|
|
return item ? item.quantity : 1;
|
|
|
|
return item ? item.quantity : 1;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
// 增加数量
|
|
|
|
// 增加数量
|
|
|
|
increaseQuantity(cargoId) {
|
|
|
|
increaseQuantity(id) {
|
|
|
|
const item = this.tempSelectedMaterials.find(item => item.cargoId === cargoId);
|
|
|
|
const item = this.tempSelectedMaterials.find(item => item.id === id);
|
|
|
|
if (item) {
|
|
|
|
if (item) {
|
|
|
|
item.quantity += 1;
|
|
|
|
item.quantity += 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
// 减少数量
|
|
|
|
// 减少数量
|
|
|
|
decreaseQuantity(cargoId) {
|
|
|
|
decreaseQuantity(id) {
|
|
|
|
const item = this.tempSelectedMaterials.find(item => item.cargoId === cargoId);
|
|
|
|
const item = this.tempSelectedMaterials.find(item => item.id === id);
|
|
|
|
if (item && item.quantity > 1) {
|
|
|
|
if (item && item.quantity > 1) {
|
|
|
|
item.quantity -= 1;
|
|
|
|
item.quantity -= 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
// 更新数量
|
|
|
|
// 更新数量
|
|
|
|
updateQuantity(cargoId, event) {
|
|
|
|
updateQuantity(id, event) {
|
|
|
|
const item = this.tempSelectedMaterials.find(item => item.cargoId === cargoId);
|
|
|
|
const item = this.tempSelectedMaterials.find(item => item.id === id);
|
|
|
|
if (item) {
|
|
|
|
if (item) {
|
|
|
|
const value = parseInt(event.target.value) || 1;
|
|
|
|
const value = parseInt(event.target.value) || 1;
|
|
|
|
item.quantity = Math.max(1, value);
|
|
|
|
item.quantity = Math.max(1, value);
|
|
|
|
|