yyb
2 天以前 b6a007d417bf5eea80ec807d3f1201e220e5f651
src/views/procurementManagement/purchaseReturnOrder/ProductList.vue
@@ -6,9 +6,10 @@
        width="1200"
        @close="closeModal"
    >
      <div class="table_list">
      <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"
@@ -17,6 +18,12 @@
                           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="规格型号"
@@ -25,27 +32,33 @@
                           prop="unit"
                           width="70" />
          <el-table-column label="数量"
                           prop="quantity"
                           prop="stockInNum"
                           width="70" />
          <el-table-column label="库存预警数量"
          <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" />
                           width="80" /> -->
          <el-table-column label="含税单价(元)"
                           prop="taxInclusiveUnitPrice"
                           :formatter="formattedNumber"
                           width="150" />
          <el-table-column label="含税总价(元)"
          <!-- <el-table-column label="含税总价(元)"
                           prop="taxInclusiveTotalPrice"
                           :formatter="formattedNumber"
                           width="150" />
          <el-table-column label="不含税总价(元)"
                           prop="taxExclusiveTotalPrice"
                           :formatter="formattedNumber"
                           width="150" />
                           width="150" /> -->
          <el-table-column label="是否质检"
                           prop="isChecked"
                           width="150">
@@ -56,8 +69,6 @@
            </template>
          </el-table-column>
        </el-table>
        <pagination v-show="total > 0" :total="total" layout="total, sizes, prev, pager, next, jumper"
                    :page="page.current" :limit="page.size" @pagination="paginationChange" />
      </div>
      <template #footer>
@@ -71,8 +82,8 @@
</template>
<script setup>
import {computed, reactive, ref, onMounted} from "vue";
import {productList} from "@/api/procurementManagement/procurementLedger.js";
import {computed, ref, onMounted} from "vue";
import {getPurchaseReturnOrderByPurchaseLedgerId} from "@/api/procurementManagement/purchase_return_order.js";
import {ElMessage} from "element-plus";
const props = defineProps({
@@ -82,7 +93,7 @@
  },
  purchaseLedgerId: {
    type: Number,
    type: [Number, String],
    required: true,
  }
});
@@ -101,32 +112,51 @@
const tableData = ref([])
const selectedRows = ref([])
const tableLoading = ref(false)
const page = reactive({
  current: 1,
  size: 100,
})
const total = ref(0)
const formattedNumber = (row, column, cellValue) => {
  return parseFloat(cellValue).toFixed(2);
};
const paginationChange = (obj) => {
  page.current = obj.page;
  page.size = obj.limit;
  getList()
}
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 = () => {
  tableLoading.value = true;
  productList({salesLedgerId: props.purchaseLedgerId, type: 2}).then((res) => {
    tableData.value = res.data;
  }).finally(() => {
    tableLoading.value = false;
  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 = () => {