<template>
|
<div>
|
<el-dialog
|
v-model="isShow"
|
title="新增产品"
|
width="1200"
|
@close="closeModal"
|
>
|
<div class="table_list" v-loading="tableLoading">
|
<el-table :data="tableData"
|
border
|
row-key="id"
|
@selection-change="handleChangeSelection">
|
<el-table-column align="center"
|
type="selection"
|
width="55" />
|
<el-table-column align="center"
|
label="序号"
|
type="index"
|
width="60" />
|
<el-table-column label="入库单号"
|
prop="inboundBatches"
|
width="150" />
|
<el-table-column label="批次号"
|
prop="batchNo"
|
width="150" />
|
<el-table-column label="产品大类"
|
prop="productCategory" />
|
<el-table-column label="规格型号"
|
prop="specificationModel" />
|
<el-table-column label="单位"
|
prop="unit"
|
width="70" />
|
<el-table-column label="数量"
|
prop="stockInNum"
|
width="70" />
|
<el-table-column label="可退货数量"
|
prop="unQuantity"
|
width="130" />
|
<el-table-column label="已退货数量"
|
prop="totalReturnNum"
|
width="130" />
|
<!-- <el-table-column label="库存预警数量"
|
prop="warnNum"
|
width="120"
|
show-overflow-tooltip />
|
<el-table-column label="税率(%)"
|
prop="taxRate"
|
width="80" /> -->
|
<el-table-column label="含税单价(元)"
|
prop="taxInclusiveUnitPrice"
|
:formatter="formattedNumber"
|
width="150" />
|
<!-- <el-table-column label="含税总价(元)"
|
prop="taxInclusiveTotalPrice"
|
:formatter="formattedNumber"
|
width="150" />
|
<el-table-column label="不含税总价(元)"
|
prop="taxExclusiveTotalPrice"
|
:formatter="formattedNumber"
|
width="150" /> -->
|
<el-table-column label="是否质检"
|
prop="isChecked"
|
width="150">
|
<template #default="scope">
|
<el-tag :type="scope.row.isChecked ? 'success' : 'info'">
|
{{ scope.row.isChecked ? '是' : '否' }}
|
</el-tag>
|
</template>
|
</el-table-column>
|
</el-table>
|
</div>
|
|
<template #footer>
|
<div class="dialog-footer">
|
<el-button type="primary" :disabled="selectedRows.length === 0" @click="handleSubmit">确认</el-button>
|
<el-button @click="closeModal">取消</el-button>
|
</div>
|
</template>
|
</el-dialog>
|
</div>
|
</template>
|
|
<script setup>
|
import {computed, ref, onMounted} from "vue";
|
import {getPurchaseReturnOrderByPurchaseLedgerId} from "@/api/procurementManagement/purchase_return_order.js";
|
import {ElMessage} from "element-plus";
|
|
const props = defineProps({
|
visible: {
|
type: Boolean,
|
required: true,
|
},
|
|
purchaseLedgerId: {
|
type: [Number, String],
|
required: true,
|
}
|
});
|
|
const emit = defineEmits(['update:visible', 'completed']);
|
|
const isShow = computed({
|
get() {
|
return props.visible;
|
},
|
set(val) {
|
emit('update:visible', val);
|
},
|
});
|
|
const tableData = ref([])
|
const selectedRows = ref([])
|
const tableLoading = ref(false)
|
const formattedNumber = (row, column, cellValue) => {
|
return parseFloat(cellValue).toFixed(2);
|
};
|
|
const handleChangeSelection = (val) => {
|
selectedRows.value = val;
|
}
|
|
/** 与 New.vue 中采购台账变更时解析 getByPurchaseLedgerId 的规则一致 */
|
const parseProductRowsFromLedgerResponse = (res) => {
|
const payload = res?.data
|
let list = []
|
if (Array.isArray(payload)) {
|
list = payload
|
} else if (payload && typeof payload === 'object') {
|
const nested =
|
payload.purchaseReturnOrderProductsDtos ||
|
payload.purchaseReturnOrderProductsDetailVoList
|
list = Array.isArray(nested) ? nested : []
|
if (list.length && list[0]?.salesLedgerProduct) {
|
list = list.map((item) => ({ ...item, ...item.salesLedgerProduct }))
|
}
|
}
|
return list
|
}
|
|
const fetchData = () => {
|
if (props.purchaseLedgerId === undefined || props.purchaseLedgerId === null || props.purchaseLedgerId === '') {
|
tableData.value = []
|
return
|
}
|
tableLoading.value = true
|
getPurchaseReturnOrderByPurchaseLedgerId({
|
purchaseLedgerId: props.purchaseLedgerId,
|
})
|
.then((res) => {
|
const list = parseProductRowsFromLedgerResponse(res)
|
tableData.value = list
|
})
|
.catch(() => {
|
tableData.value = []
|
})
|
.finally(() => {
|
tableLoading.value = false
|
})
|
}
|
|
const handleSubmit = () => {
|
if (selectedRows.value.length === 0) {
|
ElMessage.warning("请选择一条产品");
|
return;
|
}
|
|
emit('completed', selectedRows.value);
|
closeModal()
|
}
|
|
const closeModal = () => {
|
isShow.value = false;
|
};
|
|
onMounted(() => {
|
fetchData()
|
})
|
|
</script>
|