114
This commit is contained in:
@@ -10,7 +10,6 @@
|
||||
<view class="zd-col-17">
|
||||
<search-box
|
||||
v-model="point"
|
||||
@handleChange="handlePointChange"
|
||||
/>
|
||||
</view>
|
||||
</view>
|
||||
@@ -21,10 +20,10 @@
|
||||
<view class="zd-col-17">
|
||||
<search-box
|
||||
v-model="vehicle"
|
||||
@handleChange="handleVehicleChange"
|
||||
/>
|
||||
</view>
|
||||
</view>
|
||||
<button type="primary" class="mgt20" @tap="handleAddItem">添加</button>
|
||||
</view>
|
||||
<view class="zd_wrapper grid-wraper">
|
||||
<view class="slide_new">
|
||||
@@ -42,21 +41,14 @@
|
||||
<td>{{e.vehicle_code}}</td>
|
||||
<td><view class="delete-btn" @tap="deleteItem(i)">删除</view></td>
|
||||
</tr>
|
||||
<tr v-if="uncompletedItem" class="uncompleted-row">
|
||||
<td>{{uncompletedItem.point_code || '待扫描'}}</td>
|
||||
<td>{{uncompletedItem.vehicle_code || '待扫描'}}</td>
|
||||
<td>
|
||||
<view class="clear-btn" @tap="clearUncompleted">清空</view>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<view v-if="dataList.length === 0 && !uncompletedItem" class="tip">请扫描点位和载具编码</view>
|
||||
<view v-if="dataList.length === 0" class="tip">请扫描点位和载具编码</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="zd-row submit-bar">
|
||||
<button class="zd-col-24 button-primary" :class="{'button-info': !dataList.length}" :disabled="disabled" @tap="_emptyVehicleWarehousing">提交</button>
|
||||
<button class="zd-col-24 button-primary" :class="{'button-info': !canSubmit}" :disabled="disabled" @tap="_emptyVehicleWarehousing">提交</button>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
@@ -75,87 +67,89 @@
|
||||
title: '',
|
||||
point: '',
|
||||
vehicle: '',
|
||||
uncompletedItem: null,
|
||||
dataList: [],
|
||||
disabled: false
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
canSubmit() {
|
||||
return this.dataList.length > 0 || (this.point && this.vehicle);
|
||||
}
|
||||
},
|
||||
onLoad (options) {
|
||||
this.title = options.title
|
||||
},
|
||||
methods: {
|
||||
handlePointChange(value) {
|
||||
if (value) {
|
||||
setTimeout(() => { this.point = '' }, 500)
|
||||
if (!this.uncompletedItem) {
|
||||
this.uncompletedItem = { point_code: value }
|
||||
} else {
|
||||
this.uncompletedItem.point_code = value
|
||||
}
|
||||
this.checkAndAddToList()
|
||||
handleAddItem() {
|
||||
if (!this.point || !this.vehicle) {
|
||||
uni.showToast({
|
||||
title: '请完整填写点位和载具编码',
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
},
|
||||
handleVehicleChange(value) {
|
||||
if (value) {
|
||||
setTimeout(() => { this.vehicle = '' }, 500)
|
||||
if (!this.uncompletedItem) {
|
||||
this.uncompletedItem = { vehicle_code: value }
|
||||
} else {
|
||||
this.uncompletedItem.vehicle_code = value
|
||||
}
|
||||
this.checkAndAddToList()
|
||||
|
||||
const exists = this.dataList.some(item =>
|
||||
item.point_code === this.point && item.vehicle_code === this.vehicle
|
||||
)
|
||||
|
||||
if (exists) {
|
||||
uni.showToast({
|
||||
title: '该组合已存在',
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
},
|
||||
checkAndAddToList() {
|
||||
if (!this.uncompletedItem) return
|
||||
const { point_code, vehicle_code } = this.uncompletedItem
|
||||
if (point_code && vehicle_code) {
|
||||
const exists = this.dataList.some(item =>
|
||||
item.point_code === point_code && item.vehicle_code === vehicle_code
|
||||
)
|
||||
if (!exists) {
|
||||
this.dataList.push({
|
||||
point_code,
|
||||
vehicle_code
|
||||
})
|
||||
this.uncompletedItem = null
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: '该组合已存在',
|
||||
icon: 'none'
|
||||
})
|
||||
this.uncompletedItem = null
|
||||
}
|
||||
}
|
||||
},
|
||||
clearUncompleted() {
|
||||
this.uncompletedItem = null
|
||||
|
||||
this.dataList.push({
|
||||
point_code: this.point,
|
||||
vehicle_code: this.vehicle
|
||||
})
|
||||
|
||||
this.$nextTick(() => {
|
||||
this.point = ''
|
||||
this.vehicle = ''
|
||||
})
|
||||
},
|
||||
deleteItem(index) {
|
||||
this.dataList.splice(index, 1)
|
||||
},
|
||||
async _emptyVehicleWarehousing () {
|
||||
this.disabled = true
|
||||
if (!this.dataList.length) {
|
||||
this.disabled = false
|
||||
return
|
||||
}
|
||||
try {
|
||||
let res = await emptyVehicleWarehousing(this.dataList)
|
||||
this.clearUp()
|
||||
uni.showToast({
|
||||
title: res.message,
|
||||
icon: 'none'
|
||||
})
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
this.disabled = false
|
||||
}
|
||||
this.disabled = true
|
||||
let submitData = []
|
||||
if (this.dataList.length > 0) {
|
||||
submitData = this.dataList
|
||||
}
|
||||
else if (this.point && this.vehicle) {
|
||||
submitData = [{
|
||||
point_code: this.point,
|
||||
vehicle_code: this.vehicle
|
||||
}]
|
||||
}
|
||||
else {
|
||||
uni.showToast({
|
||||
title: '请填写点位和载具编码或添加列表数据',
|
||||
icon: 'none'
|
||||
})
|
||||
this.disabled = false
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
let res = await emptyVehicleWarehousing(submitData)
|
||||
this.clearUp()
|
||||
uni.showToast({
|
||||
title: res.message,
|
||||
icon: 'none'
|
||||
})
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
this.disabled = false
|
||||
}
|
||||
},
|
||||
clearUp () {
|
||||
this.point = ''
|
||||
this.vehicle = ''
|
||||
this.uncompletedItem = null
|
||||
this.disabled = false
|
||||
this.dataList = []
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user