zhangwencui
5 天以前 84c3ee28516c5f2905ef5d15fae66026a1b6def3
退料仓库选择,及库存选中物料名带出问题
已修改8个文件
166 ■■■■■ 文件已修改
src/api/mes/wm/returnissue/detail/index.ts 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/mes/workbench/components/tabs/ReturnIssueLineFormModal.vue 20 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/wls/returnissue/data.ts 58 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/wls/returnissue/modules/detail-form.vue 9 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/wls/returnissue/modules/line-form.vue 9 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/wls/warehouse/components/area-select.vue 24 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/wls/warehouse/components/location-select.vue 24 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/wls/warehouse/components/select.vue 20 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/api/mes/wm/returnissue/detail/index.ts
@@ -8,6 +8,8 @@
    lineId?: number; // 退料单行编号
    materialStockId?: number; // 库存记录编号
    itemId?: number; // 物料编号
    itemName?: string; // 物料名称
    specification?: string; // 规格型号
    quantity?: number; // 数量
    batchId?: number; // 批次编号
    batchCode?: string; // 批次号
src/views/mes/workbench/components/tabs/ReturnIssueLineFormModal.vue
@@ -16,7 +16,6 @@
  getReturnIssueLine,
  updateReturnIssueLine,
} from '#/api/mes/wm/returnissue/line';
import { MdItemSelect } from '#/views/mes/md/item/components';
import { WmMaterialStockSelect } from '#/views/wls/materialstock/components';
const emit = defineEmits(['success']);
@@ -40,6 +39,9 @@
            batchCode: stock?.batchCode,
            batchId: stock?.batchId,
            itemId: stock?.itemId,
            materialDisplayName: stock
              ? [stock.itemName, stock.specification].filter(Boolean).join(' | ')
              : undefined,
            quantity: stock?.quantity,
            quantityMax: stock?.quantity,
          });
@@ -83,9 +85,14 @@
    },
    {
      fieldName: 'itemId',
      component: 'Input',
      dependencies: { triggerFields: [''], show: () => false },
    },
    {
      fieldName: 'materialDisplayName',
      label: '物料',
      component: markRaw(MdItemSelect),
      componentProps: { disabled: true },
      component: 'Input',
      componentProps: { disabled: true, placeholder: '选择库存后自动带出' },
    },
    {
      fieldName: 'batchCode',
@@ -145,7 +152,12 @@
    modalApi.lock();
    try {
      formData.value = await getReturnIssueLine(data.id);
      await formApi.setValues(formData.value);
      await formApi.setValues({
        ...formData.value,
        materialDisplayName: [formData.value.itemName, formData.value.specification]
          .filter(Boolean)
          .join(' | '),
      });
    } finally {
      modalApi.unlock();
    }
src/views/wls/returnissue/data.ts
@@ -18,7 +18,6 @@
import { z } from '#/adapter/form';
import { generateAutoCode } from '#/api/mes/md/autocode/record';
import { MdItemSelect } from '#/views/mes/md/item/components';
import { MdWorkstationSelect } from '#/views/mes/md/workstation/components';
import { ProWorkOrderSelect } from '#/views/mes/pro/workorder/components';
import { WmMaterialStockSelect } from '#/views/wls/materialstock/components';
@@ -330,6 +329,9 @@
            batchCode: stock?.batchCode,
            batchId: stock?.batchId,
            itemId: stock?.itemId,
            materialDisplayName: stock
              ? [stock.itemName, stock.specification].filter(Boolean).join(' | ')
              : undefined,
            quantity: stock?.quantity,
            quantityMax: stock?.quantity,
          });
@@ -376,10 +378,19 @@
    },
    {
      fieldName: 'itemId',
      component: 'Input',
      dependencies: {
        triggerFields: [''],
        show: () => false,
      },
    },
    {
      fieldName: 'materialDisplayName',
      label: '物料',
      component: markRaw(MdItemSelect),
      component: 'Input',
      componentProps: {
        disabled: true,
        placeholder: '选择库存后自动带出',
      },
    },
    {
@@ -460,28 +471,37 @@
    },
    {
      fieldName: 'itemId',
      component: 'Input',
      dependencies: {
        triggerFields: [''],
        show: () => false,
      },
    },
    {
      fieldName: 'materialDisplayName',
      label: '物料',
      component: markRaw(MdItemSelect),
      component: 'Input',
      componentProps: {
        disabled: true,
        placeholder: '选择库存后自动带出',
      },
      rules: 'selectRequired',
    },
    {
      fieldName: 'materialStockId',
      label: '库存记录',
      component: markRaw(WmMaterialStockSelect),
      componentProps: {
        // 选择库存记录后,自动回填仓库/库区/库位/批次/数量
        // 选择库存记录后,自动回填物料/批次/数量(不再带入仓库信息)
        onChange: async (stock?: MesWmMaterialStockApi.MaterialStock) => {
          await formApi?.setValues({
            areaId: stock?.areaId,
            batchCode: stock?.batchCode,
            batchId: stock?.batchId,
            locationId: stock?.locationId,
            itemId: stock?.itemId,
            materialDisplayName: stock
              ? [stock.itemName, stock.specification].filter(Boolean).join(' | ')
              : undefined,
            quantity: stock?.quantity,
            quantityMax: stock?.quantity,
            warehouseId: stock?.warehouseId,
          });
        },
        virtualFilter: 'only',
@@ -519,38 +539,32 @@
    },
    {
      fieldName: 'warehouseId',
      label: '入库仓库',
      label: '上架目标仓库',
      component: markRaw(WmWarehouseSelect),
      componentProps: {
        disabled: true,
      },
      // componentProps: {
      //   excludeCodes: ['WIP_VIRTUAL_WAREHOUSE'],
      // },
    },
    {
      fieldName: 'locationId',
      label: '库区',
      label: '上架目标库区',
      component: markRaw(WmWarehouseLocationSelect),
      componentProps: {
        disabled: true,
      },
      dependencies: {
        triggerFields: ['warehouseId'],
        componentProps: (values) => ({
          disabled: true,
          disabled: !values.warehouseId,
          warehouseId: values.warehouseId,
        }),
      },
    },
    {
      fieldName: 'areaId',
      label: '库位',
      label: '上架目标库位',
      component: markRaw(WmWarehouseAreaSelect),
      componentProps: {
        disabled: true,
      },
      dependencies: {
        triggerFields: ['locationId'],
        componentProps: (values) => ({
          disabled: true,
          disabled: !values.locationId,
          locationId: values.locationId,
        }),
      },
src/views/wls/returnissue/modules/detail-form.vue
@@ -85,8 +85,13 @@
      modalApi.lock();
      try {
        formData.value = await getReturnIssueDetail(data.detailId);
        // 设置到 values
        await formApi.setValues(formData.value);
        // 设置到 values,并构建物料展示名
        await formApi.setValues({
          ...formData.value,
          materialDisplayName: [formData.value.itemName, formData.value.specification]
            .filter(Boolean)
            .join(' | '),
        });
      } finally {
        modalApi.unlock();
      }
src/views/wls/returnissue/modules/line-form.vue
@@ -79,8 +79,13 @@
    modalApi.lock();
    try {
      formData.value = await getReturnIssueLine(data.id);
      // 设置到 values
      await formApi.setValues(formData.value);
      // 设置到 values,并构建物料展示名
      await formApi.setValues({
        ...formData.value,
        materialDisplayName: [formData.value.itemName, formData.value.specification]
          .filter(Boolean)
          .join(' | '),
      });
    } finally {
      modalApi.unlock();
    }
src/views/wls/warehouse/components/area-select.vue
@@ -3,7 +3,7 @@
import { computed, ref, useAttrs, watch, watchEffect } from 'vue';
import { Select, SelectOption, Tag, Tooltip } from 'ant-design-vue';
import { Select, SelectOption, Tooltip } from 'ant-design-vue';
import { getWarehouseAreaSimpleList } from '#/api/mes/wm/warehouse/area';
@@ -73,11 +73,21 @@
  },
);
/** 库区变更或初始化时重新加载库位列表 */
/** 库区变更时清空已选库位并重新加载列表 */
watchEffect(async () => {
  if (!props.locationId) {
    allList.value = [];
    return;
  }
  allList.value = await getWarehouseAreaSimpleList(props.locationId);
  if (props.modelValue !== null) {
    selectedItem.value = allList.value.find((o) => o.id === props.modelValue);
  // 库区变更时清空已选的库位
  if (props.modelValue !== null && props.modelValue !== undefined) {
    const stillExists = allList.value.find((o) => o.id === props.modelValue);
    if (!stillExists) {
      selectedItem.value = undefined;
      emit('update:modelValue', undefined);
      emit('change', undefined);
    }
  }
});
</script>
@@ -100,14 +110,12 @@
      :disabled="disabled"
      :filter-option="filterOption"
      :placeholder="placeholder"
      :popup-match-select-width="false"
      show-search
      @change="handleChange"
    >
      <SelectOption v-for="item in allList" :key="item.id" :value="item.id">
        <div class="flex items-center gap-2">
          <span>{{ item.name }}</span>
          <Tag v-if="item.code" color="blue">编号: {{ item.code }}</Tag>
        </div>
        {{ item.name }}
      </SelectOption>
    </Select>
  </Tooltip>
src/views/wls/warehouse/components/location-select.vue
@@ -3,7 +3,7 @@
import { computed, ref, useAttrs, watch, watchEffect } from 'vue';
import { Select, SelectOption, Tag, Tooltip } from 'ant-design-vue';
import { Select, SelectOption, Tooltip } from 'ant-design-vue';
import { getWarehouseLocationSimpleList } from '#/api/mes/wm/warehouse/location';
@@ -73,11 +73,21 @@
  },
);
/** 仓库变更或初始化时重新加载库区列表 */
/** 仓库变更时清空已选库区并重新加载列表 */
watchEffect(async () => {
  if (!props.warehouseId) {
    allList.value = [];
    return;
  }
  allList.value = await getWarehouseLocationSimpleList(props.warehouseId);
  if (props.modelValue !== null) {
    selectedItem.value = allList.value.find((o) => o.id === props.modelValue);
  // 仓库变更时清空已选的库区
  if (props.modelValue !== null && props.modelValue !== undefined) {
    const stillExists = allList.value.find((o) => o.id === props.modelValue);
    if (!stillExists) {
      selectedItem.value = undefined;
      emit('update:modelValue', undefined);
      emit('change', undefined);
    }
  }
});
</script>
@@ -99,14 +109,12 @@
      :disabled="disabled"
      :filter-option="filterOption"
      :placeholder="placeholder"
      :popup-match-select-width="false"
      show-search
      @change="handleChange"
    >
      <SelectOption v-for="item in allList" :key="item.id" :value="item.id">
        <div class="flex items-center gap-2">
          <span>{{ item.name }}</span>
          <Tag v-if="item.code" color="blue">编号: {{ item.code }}</Tag>
        </div>
        {{ item.name }}
      </SelectOption>
    </Select>
  </Tooltip>
src/views/wls/warehouse/components/select.vue
@@ -3,7 +3,7 @@
import { computed, onMounted, ref, useAttrs, watch } from 'vue';
import { Select, SelectOption, Tag, Tooltip } from 'ant-design-vue';
import { Select, SelectOption, Tooltip } from 'ant-design-vue';
import { getWarehouseSimpleList } from '#/api/mes/wm/warehouse';
@@ -13,12 +13,14 @@
  defineProps<{
    allowClear?: boolean;
    disabled?: boolean;
    excludeCodes?: string[];
    modelValue?: number;
    placeholder?: string;
  }>(),
  {
    allowClear: true,
    disabled: false,
    excludeCodes: undefined,
    modelValue: undefined,
    placeholder: '请选择仓库',
  },
@@ -32,6 +34,14 @@
const attrs = useAttrs();
const allList = ref<MesWmWarehouseApi.Warehouse[]>([]);
const selectedItem = ref<MesWmWarehouseApi.Warehouse>();
/** 按 excludeCodes 过滤后的仓库列表 */
const filteredList = computed(() => {
  if (!props.excludeCodes?.length) {
    return allList.value;
  }
  return allList.value.filter((w) => !props.excludeCodes!.includes(w.code ?? ''));
});
const selectValue = computed({
  get: () => props.modelValue,
@@ -96,14 +106,12 @@
      :disabled="disabled"
      :filter-option="filterOption"
      :placeholder="placeholder"
      :popup-match-select-width="false"
      show-search
      @change="handleChange"
    >
      <SelectOption v-for="item in allList" :key="item.id" :value="item.id">
        <div class="flex items-center gap-2">
          <span>{{ item.name }}</span>
          <Tag v-if="item.code" color="blue">编号: {{ item.code }}</Tag>
        </div>
      <SelectOption v-for="item in filteredList" :key="item.id" :value="item.id">
        {{ item.name }}
      </SelectOption>
    </Select>
  </Tooltip>