zhangwencui
17 小时以前 95dc87fc483106b108b35ea6ec5343b1d4b09e00
新增入库时选择字段及来源修改
已修改2个文件
102 ■■■■■ 文件已修改
src/views/inventoryManagement/stockManagement/BatchNoQtyDetail.vue 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/inventoryManagement/stockManagement/New.vue 100 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/inventoryManagement/stockManagement/BatchNoQtyDetail.vue
@@ -18,7 +18,7 @@
          <el-table-column label="规格型号"
                           prop="model"
                           show-overflow-tooltip />
          <el-table-column label="厂家"
          <el-table-column label="供应商"
                           prop="manufacturerName"
                           show-overflow-tooltip>
            <template #default="scope">
src/views/inventoryManagement/stockManagement/New.vue
@@ -32,8 +32,37 @@
          <el-input v-model="formState.unit"
                    disabled />
        </el-form-item>
        <el-form-item label="厂家"
                      prop="manufacturerId">
        <el-form-item v-if="shouldSelectSupplier"
                      label="供应商"
                      prop="supplierId"
                      :rules="[
                {
                required: true,
                message: '请选择供应商',
                trigger: 'change',
              }
            ]">
          <el-select v-model="formState.supplierId"
                     placeholder="请选择供应商"
                     clearable
                     filterable
                     style="width: 100%">
            <el-option v-for="item in supplierOptions"
                       :key="item.value ?? item.id ?? item.supplierId"
                       :label="item.label ?? item.supplierName ?? item.name"
                       :value="item.value ?? item.id ?? item.supplierId" />
          </el-select>
        </el-form-item>
        <el-form-item v-if="shouldSelectManufacturer"
                      label="厂家"
                      prop="manufacturerId"
                      :rules="[
                {
                required: true,
                message: '请选择厂家',
                trigger: 'change',
              }
            ]">
          <el-select v-model="formState.manufacturerId"
                     placeholder="请选择厂家"
                     clearable
@@ -129,11 +158,12 @@
</template>
<script setup>
  import { ref, computed, watch, getCurrentInstance, onMounted } from "vue";
  import { ref, computed, watch, getCurrentInstance } from "vue";
  import ProductSelectDialog from "@/views/basicData/product/ProductSelectDialog.vue";
  import { addStockInRecordOnly } from "@/api/inventoryManagement/stockInventory.js";
  import { createStockUnInventory } from "@/api/inventoryManagement/stockUninventory.js";
  import { getManufacturerOptions } from "@/api/inspectionManagement/manufacturerManageFile.js";
  import { getOptions as getSupplierOptions } from "@/api/procurementManagement/procurementLedger.js";
  const props = defineProps({
    visible: {
@@ -158,6 +188,7 @@
    unit: "",
    type: undefined,
    manufacturerId: "",
    supplierId: "",
    source: "",
    qualitity: 0,
    batchNo: null,
@@ -185,6 +216,8 @@
  const handleTypeChange = val => {
    formState.value.source = "";
    formState.value.manufacturerId = "";
    formState.value.supplierId = "";
  };
  const isShow = computed({
@@ -198,6 +231,21 @@
  const showProductSelectDialog = ref(false);
  const manufacturerOptions = ref([]);
  const supplierOptions = ref([]);
  const shouldSelectSupplier = computed(() => {
    return (
      formState.value.type === "qualified" &&
      formState.value.source === "purchaseReceipt"
    );
  });
  const shouldSelectManufacturer = computed(() => {
    return (
      formState.value.type === "qualified" &&
      formState.value.source === "outsourcedReceipt"
    );
  });
  const loadManufacturerOptions = () => {
    getManufacturerOptions().then(res => {
@@ -205,9 +253,48 @@
    });
  };
  onMounted(() => {
    loadManufacturerOptions();
  });
  const loadSupplierOptions = () => {
    getSupplierOptions({})
      .then(res => {
        const raw = res?.data;
        if (Array.isArray(raw)) {
          supplierOptions.value = raw;
          return;
        }
        supplierOptions.value = raw?.records || raw?.list || [];
      })
      .catch(() => {
        supplierOptions.value = [];
      });
  };
  watch(
    () => shouldSelectManufacturer.value,
    val => {
      if (val && manufacturerOptions.value.length === 0) {
        loadManufacturerOptions();
      }
    },
    { immediate: true }
  );
  watch(
    () => shouldSelectSupplier.value,
    val => {
      if (val && supplierOptions.value.length === 0) {
        loadSupplierOptions();
      }
    },
    { immediate: true }
  );
  watch(
    () => formState.value.source,
    () => {
      formState.value.manufacturerId = "";
      formState.value.supplierId = "";
    }
  );
  // 批号为空时转为 null
  watch(
@@ -231,6 +318,7 @@
      unit: "",
      type: undefined,
      manufacturerId: "",
      supplierId: "",
      source: "",
      qualitity: 0,
      batchNo: null,