|
@@ -0,0 +1,100 @@
|
|
|
|
|
+<template>
|
|
|
|
|
+ <div class="goods">
|
|
|
|
|
+ <van-dialog v-model:show="goodsTrueFalseBy"
|
|
|
|
|
+ :beforeClose="beforeClose"
|
|
|
|
|
+ title="组合商品包含"
|
|
|
|
|
+ show-cancel-button>
|
|
|
|
|
+ <div style="width:100%;max-height:150px;overflow:auto">
|
|
|
|
|
+ <div v-for="(item,index) in matchedSkuList" :key="index">
|
|
|
|
|
+ <van-cell center :title="item.matchedJson.barcode" :label="item.matchedJson.skuName">
|
|
|
|
|
+ <template #value>
|
|
|
|
|
+ <div>{{ item.matchedJson.quantity }}件</div>
|
|
|
|
|
+ <div class="goods-tips">预期数量:{{ (item.expectedQuantity || 0) - (item.receivedQuantity || 0) }}件</div>
|
|
|
|
|
+ </template>
|
|
|
|
|
+ </van-cell>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <div class="goods-number">应收数量:{{ maxCount }}</div>
|
|
|
|
|
+ <van-field label="实收数" type="number" class="code-input" v-model="count" ref="countRef" placeholder="实收数" />
|
|
|
|
|
+ </van-dialog>
|
|
|
|
|
+ </div>
|
|
|
|
|
+</template>
|
|
|
|
|
+<script setup>
|
|
|
|
|
+/** 组合商品弹框 */
|
|
|
|
|
+import { computed, ref } from 'vue'
|
|
|
|
|
+import { showToast } from 'vant'
|
|
|
|
|
+const goodsTrueFalseBy = ref(false)
|
|
|
|
|
+const countRef = ref(null)
|
|
|
|
|
+const count = ref('')
|
|
|
|
|
+const props = defineProps({
|
|
|
|
|
+ matchedSku: { type: Array, default: () => [] },
|
|
|
|
|
+ container: { type: String, default: '' }
|
|
|
|
|
+})
|
|
|
|
|
+const matchedSkuList = computed(() => props.matchedSku)
|
|
|
|
|
+const maxCount = computed(() => {
|
|
|
|
|
+ const min = Math.min(
|
|
|
|
|
+ ...props.matchedSku.map((item) => ((item.expectedQuantity || 0) - (item.receivedQuantity || 0)) / (item.matchedJson?.quantity || 1))
|
|
|
|
|
+ )
|
|
|
|
|
+ return Number.isFinite(min) ? Math.floor(min) : 0
|
|
|
|
|
+})
|
|
|
|
|
+const show = () => {
|
|
|
|
|
+ count.value = ''
|
|
|
|
|
+ goodsTrueFalseBy.value = true
|
|
|
|
|
+ setTimeout(() => {
|
|
|
|
|
+ countRef.value?.focus()
|
|
|
|
|
+ }, 200)
|
|
|
|
|
+}
|
|
|
|
|
+const dataResult = (data) =>
|
|
|
|
|
+ data.map((item) => {
|
|
|
|
|
+ const { matchedJson, ...rest } = item
|
|
|
|
|
+ return { ...rest, quantity: matchedJson.quantity * Number(count.value), containerId: props.container }
|
|
|
|
|
+ })
|
|
|
|
|
+const emit = defineEmits(['setCombine', 'cancel'])
|
|
|
|
|
+const beforeClose = (action) =>
|
|
|
|
|
+ new Promise((resolve) => {
|
|
|
|
|
+ if (action === 'confirm') {
|
|
|
|
|
+ if (count.value == '') {
|
|
|
|
|
+ showToast('请输入收货数量')
|
|
|
|
|
+ return resolve(false)
|
|
|
|
|
+ }
|
|
|
|
|
+ if (Number(count.value) <= 0) {
|
|
|
|
|
+ showToast('请输入标准收货数量')
|
|
|
|
|
+ return resolve(false)
|
|
|
|
|
+ }
|
|
|
|
|
+ if (Number(count.value) > maxCount.value) {
|
|
|
|
|
+ showToast({ duration: 3000, message: '收货数量不能大于应收数量' })
|
|
|
|
|
+ return resolve(false)
|
|
|
|
|
+ }
|
|
|
|
|
+ const dataList = dataResult(matchedSkuList.value)
|
|
|
|
|
+ emit('setCombine', { dataList, count: Number(count.value) })
|
|
|
|
|
+ } else {
|
|
|
|
|
+ emit('cancel')
|
|
|
|
|
+ }
|
|
|
|
|
+ resolve(true)
|
|
|
|
|
+ })
|
|
|
|
|
+defineExpose({ show })
|
|
|
|
|
+</script>
|
|
|
|
|
+<style scoped lang="sass">
|
|
|
|
|
+.goods
|
|
|
|
|
+ .code-input
|
|
|
|
|
+ font-size: 16px
|
|
|
|
|
+ font-weight: bold
|
|
|
|
|
+ border-bottom: 2px solid #0077ff
|
|
|
|
|
+ :deep(.van-cell--center)
|
|
|
|
|
+ padding: 5px 20px
|
|
|
|
|
+ :deep(.van-cell__title)
|
|
|
|
|
+ text-align: left !important
|
|
|
|
|
+ :deep(.van-cell__value)
|
|
|
|
|
+ width: 40% !important
|
|
|
|
|
+ flex: 0 0 40% !important
|
|
|
|
|
+ color: #000
|
|
|
|
|
+ .goods-number
|
|
|
|
|
+ text-align: left
|
|
|
|
|
+ font-size: 16px
|
|
|
|
|
+ padding-left: 20px
|
|
|
|
|
+ margin-top: 5px
|
|
|
|
|
+ .goods-tips
|
|
|
|
|
+ font-size: 12px
|
|
|
|
|
+ text-align: right
|
|
|
|
|
+ color: #333
|
|
|
|
|
+</style>
|