gaoluyang
2 小时以前 a342672f32352c1337b8977c25c101725fccedd5
fix: MOM
1.产品选择组件修改
已修改25个文件
514 ■■■■■ 文件已修改
src/views/crm/saleQuotation/data.ts 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/erp/purchase/in/data.ts 18 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/erp/purchase/in/modules/item-form.vue 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/erp/purchase/order/modules/item-form.vue 35 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/erp/purchase/return/data.ts 18 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/erp/purchase/return/modules/item-form.vue 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/erp/purchase/statistics/price.vue 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/erp/sale/order/data.ts 12 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/erp/sale/out/data.ts 24 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/erp/sale/out/modules/item-form.vue 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/erp/sale/return/data.ts 24 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/erp/sale/return/modules/item-form.vue 41 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/erp/stock/check/data.ts 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/erp/stock/check/modules/item-form.vue 38 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/erp/stock/in/data.ts 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/erp/stock/in/modules/item-form.vue 38 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/erp/stock/move/data.ts 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/erp/stock/move/modules/item-form.vue 38 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/erp/stock/out/data.ts 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/erp/stock/out/modules/item-form.vue 38 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/erp/stock/record/data.ts 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/erp/stock/stock/data.ts 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/mes/qc/template/data.ts 13 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/srm/tender/detail.vue 40 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/wls/arrivalnotice/data.ts 16 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/crm/saleQuotation/data.ts
@@ -6,7 +6,6 @@
import { z } from '#/adapter/form';
import { getSimpleBusinessList } from '#/api/crm/business';
import { getSimpleContactList } from '#/api/crm/contact';
import { getItemPage } from '#/api/mdm/item';
import { getSimpleUserList } from '#/api/system/user';
import { useUserStore } from '#/packages/stores/src';
import CrmCustomerSelect from '#/components/crm-customer-select.vue';
src/views/erp/purchase/in/data.ts
@@ -1,17 +1,19 @@
import type { VbenFormSchema } from '#/adapter/form';
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import { markRaw } from 'vue';
import { DICT_TYPE } from '@vben/constants';
import { getDictOptions } from '@vben/hooks';
import { erpNumberFormatter, erpPriceInputFormatter } from '@vben/utils';
import { z } from '#/adapter/form';
import { getAccountSimpleList } from '#/api/erp/finance/account';
import { getProductSimpleList } from '#/api/erp/product/product';
import { getSupplierSimpleList } from '#/api/srm/supplier';
import { getWarehouseSimpleList } from '#/api/erp/stock/warehouse';
import { getSimpleUserList } from '#/api/system/user';
import { getRangePickerDefaultProps } from '#/utils';
import { MdmItemSelect } from '#/views/basicData/mdm/components';
/** 表单类型 */
export type FormType = 'create' | 'detail' | 'edit';
@@ -314,14 +316,9 @@
    {
      fieldName: 'productId',
      label: '产品',
      component: 'ApiSelect',
      component: markRaw(MdmItemSelect),
      componentProps: {
        placeholder: '请选择产品',
        allowClear: true,
        showSearch: true,
        api: getProductSimpleList,
        labelField: 'name',
        valueField: 'id',
      },
    },
    {
@@ -531,14 +528,9 @@
    {
      fieldName: 'productId',
      label: '产品',
      component: 'ApiSelect',
      component: markRaw(MdmItemSelect),
      componentProps: {
        placeholder: '请选择产品',
        allowClear: true,
        showSearch: true,
        api: getProductSimpleList,
        labelField: 'name',
        valueField: 'id',
      },
    },
    {
src/views/erp/purchase/in/modules/item-form.vue
@@ -12,7 +12,6 @@
import { Input, InputNumber, Select } from 'ant-design-vue';
import { TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
import { getProductSimpleList } from '#/api/erp/product/product';
import { getWarehouseStockCount } from '#/api/erp/stock/stock';
import { getWarehouseSimpleList } from '#/api/erp/stock/warehouse';
@@ -40,7 +39,6 @@
]);
const tableData = ref<ErpPurchaseInApi.PurchaseInItem[]>([]); // 表格数据
const productOptions = ref<any[]>([]); // 产品下拉选项
const warehouseOptions = ref<any[]>([]); // 仓库下拉选项
/** 获取表格合计数据 */
@@ -192,7 +190,6 @@
/** 初始化 */
onMounted(async () => {
  productOptions.value = await getProductSimpleList();
  warehouseOptions.value = await getWarehouseSimpleList();
});
</script>
@@ -212,15 +209,7 @@
      />
    </template>
    <template #productId="{ row }">
      <Select
        disabled
        v-model:value="row.productId"
        :options="productOptions"
        :field-names="{ label: 'name', value: 'id' }"
        class="w-full"
        placeholder="请选择产品"
        show-search
      />
      <span>{{ row.productName || '-' }}</span>
    </template>
    <template #count="{ row }">
      <InputNumber
src/views/erp/purchase/order/modules/item-form.vue
@@ -10,10 +10,10 @@
  erpPriceMultiply,
} from '@vben/utils';
import { Input, InputNumber, Select, Switch } from 'ant-design-vue';
import { Input, InputNumber, Switch } from 'ant-design-vue';
import { TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
import { getItemPage } from '#/api/mdm/item';
import { MdmItemSelect } from '#/views/basicData/mdm/components';
import { useFormItemColumns } from '../data';
@@ -36,7 +36,6 @@
]);
const tableData = ref<ErpPurchaseOrderApi.PurchaseOrderItem[]>([]); // 表格数据
const productOptions = ref<MdmItemApi.Item[]>([]); // 产品下拉选项
/** 获取表格合计数据 */
const summaries = computed(() => {
@@ -150,16 +149,15 @@
}
/** 处理产品变更 */
async function handleProductChange(productId: any, row: any) {
  const product = productOptions.value.find((p) => p.id === productId);
  if (!product) {
function handleProductChange(item: MdmItemApi.Item | undefined, row: any) {
  if (!item?.id) {
    return;
  }
  row.productId = productId;
  row.productUnitId = product.unitMeasureId;
  row.productUnitName = product.unitMeasureName;
  row.productName = product.name;
  row.productPrice = product.purchasePrice || 0;
  row.productId = item.id;
  row.productUnitId = item.unitMeasureId;
  row.productUnitName = item.unitMeasureName;
  row.productName = item.name;
  row.productPrice = item.purchasePrice || 0;
  row.count = row.count || 1;
  handleRowChange(row);
}
@@ -208,9 +206,7 @@
});
/** 初始化 */
onMounted(async () => {
  const res = await getItemPage({ pageNo: 1, pageSize: 100, status: 0 });
  productOptions.value = res.list || [];
onMounted(() => {
  // 目的:新增时,默认添加一行
  if (tableData.value.length === 0) {
    handleAdd();
@@ -221,15 +217,12 @@
<template>
  <Grid class="w-full">
    <template #productId="{ row }">
      <Select
      <MdmItemSelect
        v-if="!disabled"
        v-model:value="row.productId"
        :options="productOptions"
        :field-names="{ label: 'name', value: 'id' }"
        class="w-full"
        v-model:model-value="row.productId"
        :label="row.productName"
        placeholder="请选择产品"
        show-search
        @change="handleProductChange($event, row)"
        @change="(item) => handleProductChange(item, row)"
      />
      <span v-else>{{ row.productName || '-' }}</span>
    </template>
src/views/erp/purchase/return/data.ts
@@ -1,17 +1,19 @@
import type { VbenFormSchema } from '#/adapter/form';
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import { markRaw } from 'vue';
import { DICT_TYPE } from '@vben/constants';
import { getDictOptions } from '@vben/hooks';
import { erpNumberFormatter, erpPriceInputFormatter } from '@vben/utils';
import { z } from '#/adapter/form';
import { getAccountSimpleList } from '#/api/erp/finance/account';
import { getProductSimpleList } from '#/api/erp/product/product';
import { getSupplierSimpleList } from '#/api/srm/supplier';
import { getWarehouseSimpleList } from '#/api/erp/stock/warehouse';
import { getSimpleUserList } from '#/api/system/user';
import { getRangePickerDefaultProps } from '#/utils';
import { MdmItemSelect } from '#/views/basicData/mdm/components';
/** 表单类型 */
export type FormType = 'create' | 'detail' | 'edit';
@@ -314,14 +316,9 @@
    {
      fieldName: 'productId',
      label: '产品',
      component: 'ApiSelect',
      component: markRaw(MdmItemSelect),
      componentProps: {
        placeholder: '请选择产品',
        allowClear: true,
        showSearch: true,
        api: getProductSimpleList,
        labelField: 'name',
        valueField: 'id',
      },
    },
    {
@@ -512,14 +509,9 @@
    {
      fieldName: 'productId',
      label: '产品',
      component: 'ApiSelect',
      component: markRaw(MdmItemSelect),
      componentProps: {
        placeholder: '请选择产品',
        allowClear: true,
        showSearch: true,
        api: getProductSimpleList,
        labelField: 'name',
        valueField: 'id',
      },
    },
    {
src/views/erp/purchase/return/modules/item-form.vue
@@ -12,7 +12,6 @@
import { Input, InputNumber, Select } from 'ant-design-vue';
import { TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
import { getProductSimpleList } from '#/api/erp/product/product';
import { getWarehouseStockCount } from '#/api/erp/stock/stock';
import { getWarehouseSimpleList } from '#/api/erp/stock/warehouse';
@@ -40,7 +39,6 @@
]);
const tableData = ref<ErpPurchaseReturnApi.PurchaseReturnItem[]>([]); // 表格数据
const productOptions = ref<any[]>([]); // 产品下拉选项
const warehouseOptions = ref<any[]>([]); // 仓库下拉选项
/** 获取表格合计数据 */
@@ -195,7 +193,6 @@
/** 初始化 */
onMounted(async () => {
  productOptions.value = await getProductSimpleList();
  warehouseOptions.value = await getWarehouseSimpleList();
});
</script>
@@ -215,15 +212,7 @@
      />
    </template>
    <template #productId="{ row }">
      <Select
        disabled
        v-model:value="row.productId"
        :options="productOptions"
        :field-names="{ label: 'name', value: 'id' }"
        class="w-full"
        placeholder="请选择产品"
        show-search
      />
      <span>{{ row.productName || '-' }}</span>
    </template>
    <template #count="{ row }">
      <InputNumber
src/views/erp/purchase/statistics/price.vue
@@ -2,14 +2,16 @@
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import type { ErpPurchaseStatisticsApi } from '#/api/erp/purchase/statistics';
import { markRaw } from 'vue';
import { Page } from '@vben/common-ui';
import { Tag } from 'ant-design-vue';
import { useVbenVxeGrid } from '#/adapter/vxe-table';
import { getPriceAnalysis } from '#/api/erp/purchase/statistics';
import { getProductSimpleList } from '#/api/erp/product/product';
import { getRangePickerDefaultProps } from '#/utils';
import { MdmItemSelect } from '#/views/basicData/mdm/components';
import type { VbenFormSchema } from '#/adapter/form';
@@ -20,14 +22,9 @@
  {
    fieldName: 'productId',
    label: '产品',
    component: 'ApiSelect',
    component: markRaw(MdmItemSelect),
    componentProps: {
      placeholder: '请选择产品',
      allowClear: true,
      showSearch: true,
      api: getProductSimpleList,
      labelField: 'name',
      valueField: 'id',
    },
  },
  {
src/views/erp/sale/order/data.ts
@@ -5,10 +5,10 @@
import { z } from '#/adapter/form';
import { getAccountSimpleList } from '#/api/erp/finance/account';
import { getItemPage } from '#/api/mdm/item';
import { getSimpleUserList } from '#/api/system/user';
import { getRangePickerDefaultProps, withoutFixedColumns } from '#/utils';
import CrmCustomerSelect from '#/components/crm-customer-select.vue';
import { MdmItemSelect } from '#/views/basicData/mdm/components';
import { markRaw } from 'vue';
@@ -330,17 +330,9 @@
    {
      fieldName: 'productId',
      label: '产品',
      component: 'ApiSelect',
      component: markRaw(MdmItemSelect),
      componentProps: {
        placeholder: '请选择产品',
        allowClear: true,
        showSearch: true,
        api: async () => {
          const res = await getItemPage({ pageNo: 1, pageSize: 100, status: 0 });
          return res.list || [];
        },
        labelField: 'name',
        valueField: 'id',
      },
    },
    {
src/views/erp/sale/out/data.ts
@@ -1,17 +1,19 @@
import type { VbenFormSchema } from '#/adapter/form';
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import { markRaw } from 'vue';
import { DICT_TYPE } from '@vben/constants';
import { getDictOptions } from '@vben/hooks';
import { erpNumberFormatter, erpPriceInputFormatter } from '@vben/utils';
import { z } from '#/adapter/form';
import { getAccountSimpleList } from '#/api/erp/finance/account';
import { getItemPage } from '#/api/mdm/item';
import { getCustomerSimpleList as getCrmCustomerSimpleList } from '#/api/crm/customer';
import { getWarehouseSimpleList } from '#/api/erp/stock/warehouse';
import { getSimpleUserList } from '#/api/system/user';
import { getRangePickerDefaultProps } from '#/utils';
import { MdmItemSelect } from '#/views/basicData/mdm/components';
/** 表单类型 */
export type FormType = 'create' | 'detail' | 'edit';
@@ -335,17 +337,9 @@
    {
      fieldName: 'productId',
      label: '产品',
      component: 'ApiSelect',
      component: markRaw(MdmItemSelect),
      componentProps: {
        placeholder: '请选择产品',
        allowClear: true,
        showSearch: true,
        api: async () => {
          const res = await getItemPage({ pageNo: 1, pageSize: 100, status: 0 });
          return res.list || [];
        },
        labelField: 'name',
        valueField: 'id',
      },
    },
    {
@@ -540,17 +534,9 @@
    {
      fieldName: 'productId',
      label: '产品',
      component: 'ApiSelect',
      component: markRaw(MdmItemSelect),
      componentProps: {
        placeholder: '请选择产品',
        allowClear: true,
        showSearch: true,
        api: async () => {
          const res = await getItemPage({ pageNo: 1, pageSize: 100, status: 0 });
          return res.list || [];
        },
        labelField: 'name',
        valueField: 'id',
      },
    },
    {
src/views/erp/sale/out/modules/item-form.vue
@@ -1,5 +1,4 @@
<script lang="ts" setup>
import type { MdmItemApi } from '#/api/mdm/item';
import type { ErpSaleOutApi } from '#/api/erp/sale/out';
import { computed, nextTick, onMounted, ref, watch } from 'vue';
@@ -13,7 +12,6 @@
import { Input, InputNumber, Select } from 'ant-design-vue';
import { TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
import { getItemPage } from '#/api/mdm/item';
import { getWarehouseStockCount } from '#/api/erp/stock/stock';
import { getWarehouseSimpleList } from '#/api/erp/stock/warehouse';
@@ -41,7 +39,6 @@
]);
const tableData = ref<ErpSaleOutApi.SaleOutItem[]>([]); // 表格数据
const productOptions = ref<MdmItemApi.Item[]>([]); // 物料下拉选项
const warehouseOptions = ref<any[]>([]); // 仓库下拉选项
/** 获取表格合计数据 */
@@ -193,8 +190,6 @@
/** 初始化 */
onMounted(async () => {
  const res = await getItemPage({ pageNo: 1, pageSize: 100, status: 0 });
  productOptions.value = res.list || [];
  warehouseOptions.value = await getWarehouseSimpleList();
});
</script>
@@ -214,15 +209,7 @@
      />
    </template>
    <template #productId="{ row }">
      <Select
        disabled
        v-model:value="row.productId"
        :options="productOptions"
        :field-names="{ label: 'name', value: 'id' }"
        class="w-full"
        placeholder="请选择产品"
        show-search
      />
      <span>{{ row.productName || '-' }}</span>
    </template>
    <template #count="{ row }">
      <InputNumber
src/views/erp/sale/return/data.ts
@@ -1,17 +1,19 @@
import type { VbenFormSchema } from '#/adapter/form';
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import { markRaw } from 'vue';
import { DICT_TYPE } from '@vben/constants';
import { getDictOptions } from '@vben/hooks';
import { erpNumberFormatter, erpPriceInputFormatter } from '@vben/utils';
import { z } from '#/adapter/form';
import { getAccountSimpleList } from '#/api/erp/finance/account';
import { getItemPage } from '#/api/mdm/item';
import { getCustomerSimpleList as getCrmCustomerSimpleList } from '#/api/crm/customer';
import { getWarehouseSimpleList } from '#/api/erp/stock/warehouse';
import { getSimpleUserList } from '#/api/system/user';
import { getRangePickerDefaultProps } from '#/utils';
import { MdmItemSelect } from '#/views/basicData/mdm/components';
/** 表单类型 */
export type FormType = 'create' | 'detail' | 'edit';
@@ -328,17 +330,9 @@
    {
      fieldName: 'productId',
      label: '产品',
      component: 'ApiSelect',
      component: markRaw(MdmItemSelect),
      componentProps: {
        placeholder: '请选择产品',
        allowClear: true,
        showSearch: true,
        api: async () => {
          const res = await getItemPage({ pageNo: 1, pageSize: 100, status: 0 });
          return res.list || [];
        },
        labelField: 'name',
        valueField: 'id',
      },
    },
    {
@@ -529,17 +523,9 @@
    {
      fieldName: 'productId',
      label: '产品',
      component: 'ApiSelect',
      component: markRaw(MdmItemSelect),
      componentProps: {
        placeholder: '请选择产品',
        allowClear: true,
        showSearch: true,
        api: async () => {
          const res = await getItemPage({ pageNo: 1, pageSize: 100, status: 0 });
          return res.list || [];
        },
        labelField: 'name',
        valueField: 'id',
      },
    },
    {
src/views/erp/sale/return/modules/item-form.vue
@@ -14,9 +14,9 @@
import { Input, InputNumber, Select } from 'ant-design-vue';
import { TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
import { getItemPage } from '#/api/mdm/item';
import { getWarehouseStockCount } from '#/api/erp/stock/stock';
import { getWarehouseSimpleList } from '#/api/erp/stock/warehouse';
import { MdmItemSelect } from '#/views/basicData/mdm/components';
import { useFormItemColumns } from '../data';
@@ -44,7 +44,6 @@
]);
const tableData = ref<ErpSaleReturnApi.SaleReturnItem[]>([]); // 表格数据
const productOptions = ref<MdmItemApi.Item[]>([]); // 物料下拉选项
const warehouseOptions = ref<any[]>([]); // 仓库下拉选项
/** 获取表格合计数据 */
@@ -164,11 +163,14 @@
  emit('update:items', [...tableData.value]);
}
/** 处理产品变更:优先从关联订单物料中填充,兜底从全部物料中查找 */
function handleProductChange(row: ErpSaleReturnApi.SaleReturnItem) {
/** 处理产品变更:优先从关联订单物料中填充,兜底使用弹框选中的物料 */
function handleProductChange(
  row: ErpSaleReturnApi.SaleReturnItem,
  item?: MdmItemApi.Item,
) {
  // 优先从关联订单的物料中查找
  const orderItem = props.orderItems.find(
    (item) => item.productId === row.productId,
    (order) => order.productId === row.productId,
  );
  if (orderItem) {
    row.productName = orderItem.productName;
@@ -181,14 +183,12 @@
    handleRowChange(row);
    return;
  }
  // 兜底:从全部物料中查找
  const product = productOptions.value.find((item) => item.id === row.productId);
  if (product) {
    row.productName = product.name || '';
    row.productPrice = product.salesPrice ?? 0;
    row.productUnitId = product.unitMeasureId;
    row.productUnitName = product.unitMeasureName;
    row.productBarCode = product.barCode;
  if (item) {
    row.productName = item.name || '';
    row.productPrice = item.salesPrice ?? 0;
    row.productUnitId = item.unitMeasureId;
    row.productUnitName = item.unitMeasureName;
    row.productBarCode = item.barCode;
    row.taxPercent = 0;
    row.count = row.count || 1;
    handleRowChange(row);
@@ -250,8 +250,6 @@
/** 初始化 */
onMounted(async () => {
  const res = await getItemPage({ pageNo: 1, pageSize: 100, status: 0 });
  productOptions.value = res.list || [];
  warehouseOptions.value = await getWarehouseSimpleList();
});
</script>
@@ -272,15 +270,24 @@
    </template>
    <template #productId="{ row }">
      <Select
        v-if="orderItems?.length"
        :disabled="disabled"
        v-model:value="row.productId"
        :options="orderItems?.length ? orderItems : productOptions"
        :field-names="orderItems?.length ? { label: 'productName', value: 'productId' } : { label: 'name', value: 'id' }"
        :options="orderItems"
        :field-names="{ label: 'productName', value: 'productId' }"
        class="w-full"
        placeholder="请选择产品"
        show-search
        @change="handleProductChange(row)"
      />
      <MdmItemSelect
        v-else
        v-model:model-value="row.productId"
        :label="row.productName"
        :disabled="disabled"
        placeholder="请选择产品"
        @change="(item) => handleProductChange(row, item)"
      />
    </template>
    <template #count="{ row }">
      <InputNumber
src/views/erp/stock/check/data.ts
@@ -1,13 +1,15 @@
import type { VbenFormSchema } from '#/adapter/form';
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import { markRaw } from 'vue';
import { DICT_TYPE } from '@vben/constants';
import { getDictOptions } from '@vben/hooks';
import { getProductSimpleList } from '#/api/erp/product/product';
import { getWarehouseSimpleList } from '#/api/erp/stock/warehouse';
import { getSimpleUserList } from '#/api/system/user';
import { getRangePickerDefaultProps } from '#/utils';
import { MdmItemSelect } from '#/views/basicData/mdm/components';
/** 表单类型 */
export type FormType = 'create' | 'detail' | 'edit';
@@ -171,14 +173,9 @@
    {
      fieldName: 'productId',
      label: '产品',
      component: 'ApiSelect',
      component: markRaw(MdmItemSelect),
      componentProps: {
        placeholder: '请选择产品',
        allowClear: true,
        showSearch: true,
        api: getProductSimpleList,
        labelField: 'name',
        valueField: 'id',
      },
    },
    {
src/views/erp/stock/check/modules/item-form.vue
@@ -1,5 +1,5 @@
<script lang="ts" setup>
import type { ErpProductApi } from '#/api/erp/product/product';
import type { MdmItemApi } from '#/api/mdm/item';
import type { ErpStockCheckApi } from '#/api/erp/stock/check';
import { computed, nextTick, onMounted, ref, watch } from 'vue';
@@ -13,9 +13,9 @@
import { Input, InputNumber, Select } from 'ant-design-vue';
import { TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
import { getProductSimpleList } from '#/api/erp/product/product';
import { getStockCount } from '#/api/erp/stock/stock';
import { getWarehouseSimpleList } from '#/api/erp/stock/warehouse';
import { MdmItemSelect } from '#/views/basicData/mdm/components';
import { useFormItemColumns } from '../data';
@@ -32,7 +32,6 @@
const emit = defineEmits(['update:items']);
const tableData = ref<ErpStockCheckApi.StockCheckItem[]>([]); // 表格数据
const productOptions = ref<ErpProductApi.Product[]>([]); // 产品下拉选项
const warehouseOptions = ref<any[]>([]); // 仓库下拉选项
/** 获取表格合计数据 */
@@ -132,21 +131,20 @@
}
/** 处理产品变更 */
async function handleProductChange(productId: any, row: any) {
  const product = productOptions.value.find((p) => p.id === productId);
  if (!product) {
async function handleProductChange(item: MdmItemApi.Item | undefined, row: any) {
  if (!item?.id) {
    return;
  }
  row.productId = productId;
  row.productUnitId = product.unitId;
  row.productBarCode = product.barCode;
  row.productUnitName = product.unitName;
  row.productName = product.name;
  row.productId = item.id;
  row.productUnitId = item.unitMeasureId;
  row.productBarCode = item.barCode;
  row.productUnitName = item.unitMeasureName;
  row.productName = item.name;
  row.stockCount = row.warehouseId
    ? (await getStockCount(productId, row.warehouseId)) || 0
    : (await getStockCount(productId)) || 0;
    ? (await getStockCount(item.id, row.warehouseId)) || 0
    : (await getStockCount(item.id)) || 0;
  row.actualCount = row.stockCount || 0;
  row.productPrice = product.purchasePrice || 0;
  row.productPrice = item.purchasePrice || 0;
  row.count = row.actualCount - row.stockCount || 0;
  handleRowChange(row);
}
@@ -205,7 +203,6 @@
/** 初始化 */
onMounted(async () => {
  productOptions.value = await getProductSimpleList();
  warehouseOptions.value = await getWarehouseSimpleList();
  // 目的:新增时,默认添加一行
  if (tableData.value.length === 0) {
@@ -229,15 +226,12 @@
      />
    </template>
    <template #productId="{ row }">
      <Select
        v-model:value="row.productId"
        :options="productOptions"
        :field-names="{ label: 'name', value: 'id' }"
        class="w-full"
      <MdmItemSelect
        v-model:model-value="row.productId"
        :label="row.productName"
        placeholder="请选择产品"
        show-search
        :disabled="disabled"
        @change="handleProductChange($event, row)"
        @change="(item) => handleProductChange(item, row)"
      />
    </template>
    <template #actualCount="{ row }">
src/views/erp/stock/in/data.ts
@@ -1,14 +1,16 @@
import type { VbenFormSchema } from '#/adapter/form';
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import { markRaw } from 'vue';
import { DICT_TYPE } from '@vben/constants';
import { getDictOptions } from '@vben/hooks';
import { getProductSimpleList } from '#/api/erp/product/product';
import { getSupplierSimpleList } from '#/api/srm/supplier';
import { getWarehouseSimpleList } from '#/api/erp/stock/warehouse';
import { getSimpleUserList } from '#/api/system/user';
import { getRangePickerDefaultProps } from '#/utils';
import { MdmItemSelect } from '#/views/basicData/mdm/components';
/** 表单类型 */
export type FormType = 'create' | 'detail' | 'edit';
@@ -178,14 +180,9 @@
    {
      fieldName: 'productId',
      label: '产品',
      component: 'ApiSelect',
      component: markRaw(MdmItemSelect),
      componentProps: {
        placeholder: '请选择产品',
        allowClear: true,
        showSearch: true,
        api: getProductSimpleList,
        labelField: 'name',
        valueField: 'id',
      },
    },
    {
src/views/erp/stock/in/modules/item-form.vue
@@ -1,5 +1,5 @@
<script lang="ts" setup>
import type { ErpProductApi } from '#/api/erp/product/product';
import type { MdmItemApi } from '#/api/mdm/item';
import type { ErpStockInApi } from '#/api/erp/stock/in';
import { computed, nextTick, onMounted, ref, watch } from 'vue';
@@ -13,9 +13,9 @@
import { Input, InputNumber, Select } from 'ant-design-vue';
import { TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
import { getProductSimpleList } from '#/api/erp/product/product';
import { getStockCount } from '#/api/erp/stock/stock';
import { getWarehouseSimpleList } from '#/api/erp/stock/warehouse';
import { MdmItemSelect } from '#/views/basicData/mdm/components';
import { useFormItemColumns } from '../data';
@@ -32,7 +32,6 @@
const emit = defineEmits(['update:items']);
const tableData = ref<ErpStockInApi.StockInItem[]>([]); // 表格数据
const productOptions = ref<ErpProductApi.Product[]>([]); // 产品下拉选项
const warehouseOptions = ref<any[]>([]); // 仓库下拉选项
/** 获取表格合计数据 */
@@ -132,20 +131,19 @@
}
/** 处理产品变更 */
async function handleProductChange(productId: any, row: any) {
  const product = productOptions.value.find((p) => p.id === productId);
  if (!product) {
async function handleProductChange(item: MdmItemApi.Item | undefined, row: any) {
  if (!item?.id) {
    return;
  }
  row.productId = productId;
  row.productUnitId = product.unitId;
  row.productBarCode = product.barCode;
  row.productUnitName = product.unitName;
  row.productName = product.name;
  row.productId = item.id;
  row.productUnitId = item.unitMeasureId;
  row.productBarCode = item.barCode;
  row.productUnitName = item.unitMeasureName;
  row.productName = item.name;
  row.stockCount = row.warehouseId
    ? (await getStockCount(productId, row.warehouseId)) || 0
    : (await getStockCount(productId)) || 0;
  row.productPrice = product.purchasePrice || 0;
    ? (await getStockCount(item.id, row.warehouseId)) || 0
    : (await getStockCount(item.id)) || 0;
  row.productPrice = item.purchasePrice || 0;
  row.count = row.count || 1;
  handleRowChange(row);
}
@@ -195,7 +193,6 @@
/** 初始化 */
onMounted(async () => {
  productOptions.value = await getProductSimpleList();
  warehouseOptions.value = await getWarehouseSimpleList();
  // 目的:新增时,默认添加一行
  if (tableData.value.length === 0) {
@@ -219,15 +216,12 @@
      />
    </template>
    <template #productId="{ row }">
      <Select
        v-model:value="row.productId"
        :options="productOptions"
        :field-names="{ label: 'name', value: 'id' }"
        class="w-full"
      <MdmItemSelect
        v-model:model-value="row.productId"
        :label="row.productName"
        placeholder="请选择产品"
        show-search
        :disabled="disabled"
        @change="handleProductChange($event, row)"
        @change="(item) => handleProductChange(item, row)"
      />
    </template>
    <template #count="{ row }">
src/views/erp/stock/move/data.ts
@@ -1,13 +1,15 @@
import type { VbenFormSchema } from '#/adapter/form';
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import { markRaw } from 'vue';
import { DICT_TYPE } from '@vben/constants';
import { getDictOptions } from '@vben/hooks';
import { getProductSimpleList } from '#/api/erp/product/product';
import { getWarehouseSimpleList } from '#/api/erp/stock/warehouse';
import { getSimpleUserList } from '#/api/system/user';
import { getRangePickerDefaultProps } from '#/utils';
import { MdmItemSelect } from '#/views/basicData/mdm/components';
/** 表单类型 */
export type FormType = 'create' | 'detail' | 'edit';
@@ -169,14 +171,9 @@
    {
      fieldName: 'productId',
      label: '产品',
      component: 'ApiSelect',
      component: markRaw(MdmItemSelect),
      componentProps: {
        placeholder: '请选择产品',
        allowClear: true,
        showSearch: true,
        api: getProductSimpleList,
        labelField: 'name',
        valueField: 'id',
      },
    },
    {
src/views/erp/stock/move/modules/item-form.vue
@@ -1,5 +1,5 @@
<script lang="ts" setup>
import type { ErpProductApi } from '#/api/erp/product/product';
import type { MdmItemApi } from '#/api/mdm/item';
import type { ErpStockMoveApi } from '#/api/erp/stock/move';
import { computed, nextTick, onMounted, ref, watch } from 'vue';
@@ -13,9 +13,9 @@
import { Input, InputNumber, Select } from 'ant-design-vue';
import { TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
import { getProductSimpleList } from '#/api/erp/product/product';
import { getStockCount } from '#/api/erp/stock/stock';
import { getWarehouseSimpleList } from '#/api/erp/stock/warehouse';
import { MdmItemSelect } from '#/views/basicData/mdm/components';
import { useFormItemColumns } from '../data';
@@ -32,7 +32,6 @@
const emit = defineEmits(['update:items']);
const tableData = ref<ErpStockMoveApi.StockMoveItem[]>([]); // 表格数据
const productOptions = ref<ErpProductApi.Product[]>([]); // 产品下拉选项
const warehouseOptions = ref<any[]>([]); // 仓库下拉选项
/** 获取表格合计数据 */
@@ -140,20 +139,19 @@
}
/** 处理产品变更 */
async function handleProductChange(productId: any, row: any) {
  const product = productOptions.value.find((p) => p.id === productId);
  if (!product) {
async function handleProductChange(item: MdmItemApi.Item | undefined, row: any) {
  if (!item?.id) {
    return;
  }
  row.productId = productId;
  row.productUnitId = product.unitId;
  row.productBarCode = product.barCode;
  row.productUnitName = product.unitName;
  row.productName = product.name;
  row.productId = item.id;
  row.productUnitId = item.unitMeasureId;
  row.productBarCode = item.barCode;
  row.productUnitName = item.unitMeasureName;
  row.productName = item.name;
  row.stockCount = row.fromWarehouseId
    ? (await getStockCount(productId, row.fromWarehouseId)) || 0
    : (await getStockCount(productId)) || 0;
  row.productPrice = product.purchasePrice || 0;
    ? (await getStockCount(item.id, row.fromWarehouseId)) || 0
    : (await getStockCount(item.id)) || 0;
  row.productPrice = item.purchasePrice || 0;
  row.count = row.count || 1;
  handleRowChange(row);
}
@@ -203,7 +201,6 @@
/** 初始化 */
onMounted(async () => {
  productOptions.value = await getProductSimpleList();
  warehouseOptions.value = await getWarehouseSimpleList();
  // 目的:新增时,默认添加一行
  if (tableData.value.length === 0) {
@@ -239,15 +236,12 @@
      />
    </template>
    <template #productId="{ row }">
      <Select
        v-model:value="row.productId"
        :options="productOptions"
        :field-names="{ label: 'name', value: 'id' }"
        class="w-full"
      <MdmItemSelect
        v-model:model-value="row.productId"
        :label="row.productName"
        placeholder="请选择产品"
        show-search
        :disabled="disabled"
        @change="handleProductChange($event, row)"
        @change="(item) => handleProductChange(item, row)"
      />
    </template>
    <template #count="{ row }">
src/views/erp/stock/out/data.ts
@@ -1,14 +1,16 @@
import type { VbenFormSchema } from '#/adapter/form';
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import { markRaw } from 'vue';
import { DICT_TYPE } from '@vben/constants';
import { getDictOptions } from '@vben/hooks';
import { getProductSimpleList } from '#/api/erp/product/product';
import { getCustomerSimpleList } from '#/api/erp/sale/customer';
import { getWarehouseSimpleList } from '#/api/erp/stock/warehouse';
import { getSimpleUserList } from '#/api/system/user';
import { getRangePickerDefaultProps } from '#/utils';
import { MdmItemSelect } from '#/views/basicData/mdm/components';
/** 表单类型 */
export type FormType = 'create' | 'detail' | 'edit';
@@ -180,16 +182,9 @@
    {
      fieldName: 'productId',
      label: '产品',
      component: 'ApiSelect',
      component: markRaw(MdmItemSelect),
      componentProps: {
        placeholder: '请选择产品',
        allowClear: true,
        showSearch: true,
        api: getProductSimpleList,
        fieldNames: {
          label: 'name',
          value: 'id',
        },
      },
    },
    {
src/views/erp/stock/out/modules/item-form.vue
@@ -1,5 +1,5 @@
<script lang="ts" setup>
import type { ErpProductApi } from '#/api/erp/product/product';
import type { MdmItemApi } from '#/api/mdm/item';
import type { ErpStockOutApi } from '#/api/erp/stock/out';
import { computed, nextTick, onMounted, ref, watch } from 'vue';
@@ -13,9 +13,9 @@
import { Input, InputNumber, Select } from 'ant-design-vue';
import { TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
import { getProductSimpleList } from '#/api/erp/product/product';
import { getStockCount } from '#/api/erp/stock/stock';
import { getWarehouseSimpleList } from '#/api/erp/stock/warehouse';
import { MdmItemSelect } from '#/views/basicData/mdm/components';
import { useFormItemColumns } from '../data';
@@ -32,7 +32,6 @@
const emit = defineEmits(['update:items']);
const tableData = ref<ErpStockOutApi.StockOutItem[]>([]); // 表格数据
const productOptions = ref<ErpProductApi.Product[]>([]); // 产品下拉选项
const warehouseOptions = ref<any[]>([]); // 仓库下拉选项
/** 获取表格合计数据 */
@@ -129,20 +128,19 @@
}
/** 处理产品变更 */
async function handleProductChange(productId: any, row: any) {
  const product = productOptions.value.find((p) => p.id === productId);
  if (!product) {
async function handleProductChange(item: MdmItemApi.Item | undefined, row: any) {
  if (!item?.id) {
    return;
  }
  row.productId = productId;
  row.productUnitId = product.unitId;
  row.productBarCode = product.barCode;
  row.productUnitName = product.unitName;
  row.productName = product.name;
  row.productId = item.id;
  row.productUnitId = item.unitMeasureId;
  row.productBarCode = item.barCode;
  row.productUnitName = item.unitMeasureName;
  row.productName = item.name;
  row.stockCount = row.warehouseId
    ? (await getStockCount(productId, row.warehouseId)) || 0
    : (await getStockCount(productId)) || 0;
  row.productPrice = product.purchasePrice || 0;
    ? (await getStockCount(item.id, row.warehouseId)) || 0
    : (await getStockCount(item.id)) || 0;
  row.productPrice = item.purchasePrice || 0;
  row.count = row.count || 1;
  handleRowChange(row);
}
@@ -192,7 +190,6 @@
/** 初始化 */
onMounted(async () => {
  productOptions.value = await getProductSimpleList();
  warehouseOptions.value = await getWarehouseSimpleList();
  // 目的:新增时,默认添加一行
  if (tableData.value.length === 0) {
@@ -216,15 +213,12 @@
      />
    </template>
    <template #productId="{ row }">
      <Select
        v-model:value="row.productId"
        :options="productOptions"
        :field-names="{ label: 'name', value: 'id' }"
        class="w-full"
      <MdmItemSelect
        v-model:model-value="row.productId"
        :label="row.productName"
        placeholder="请选择产品"
        show-search
        :disabled="disabled"
        @change="handleProductChange($event, row)"
        @change="(item) => handleProductChange(item, row)"
      />
    </template>
    <template #count="{ row }">
src/views/erp/stock/record/data.ts
@@ -4,9 +4,11 @@
import { DICT_TYPE } from '@vben/constants';
import { getDictOptions } from '@vben/hooks';
import { getProductSimpleList } from '#/api/erp/product/product';
import { markRaw } from 'vue';
import { getWarehouseSimpleList } from '#/api/erp/stock/warehouse';
import { getRangePickerDefaultProps } from '#/utils';
import { MdmItemSelect } from '#/views/basicData/mdm/components';
/** 搜索表单 */
export function useGridFormSchema(): VbenFormSchema[] {
@@ -14,14 +16,9 @@
    {
      fieldName: 'productId',
      label: '产品',
      component: 'ApiSelect',
      component: markRaw(MdmItemSelect),
      componentProps: {
        placeholder: '请选择产品',
        allowClear: true,
        showSearch: true,
        api: getProductSimpleList,
        labelField: 'name',
        valueField: 'id',
      },
    },
    {
src/views/erp/stock/stock/data.ts
@@ -1,8 +1,10 @@
import type { VbenFormSchema } from '#/adapter/form';
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import { getProductSimpleList } from '#/api/erp/product/product';
import { markRaw } from 'vue';
import { getWarehouseSimpleList } from '#/api/erp/stock/warehouse';
import { MdmItemSelect } from '#/views/basicData/mdm/components';
/** 搜索表单 */
export function useGridFormSchema(): VbenFormSchema[] {
@@ -10,14 +12,9 @@
    {
      fieldName: 'productId',
      label: '产品',
      component: 'ApiSelect',
      component: markRaw(MdmItemSelect),
      componentProps: {
        placeholder: '请选择产品',
        allowClear: true,
        showSearch: true,
        api: getProductSimpleList,
        labelField: 'name',
        valueField: 'id',
      },
    },
    {
src/views/mes/qc/template/data.ts
@@ -17,7 +17,7 @@
import { z } from '#/adapter/form';
import { generateAutoCode } from '#/api/mes/md/autocode/record';
import { getItemSimpleList } from '#/api/mdm/item';
import { MdmItemSelect } from '#/views/basicData/mdm/components';
import { MdUnitMeasureSelect } from '#/views/mes/md/unitmeasure/components';
import { QcIndicatorSelect } from '#/views/mes/qc/indicator/components';
@@ -421,18 +421,9 @@
    {
      fieldName: 'itemId',
      label: '产品物料',
      component: 'ApiSelect',
      component: markRaw(MdmItemSelect),
      componentProps: {
        placeholder: '请选择产品物料',
        allowClear: true,
        showSearch: true,
        api: getItemSimpleList,
        labelField: 'name',
        valueField: 'id',
        optionRender: (option: any) => {
          const item = option.data;
          return `${item.code} - ${item.name}`;
        },
      },
      formItemClass: 'col-span-3',
      rules: 'required',
src/views/srm/tender/detail.vue
@@ -19,9 +19,10 @@
  createAward, deleteAward, getAward, getAwardByProject, approveAward, generatePurchaseOrder,
  confirmTenderProject,
} from '#/api/srm/tender';
import { getSupplierList } from '#/api/srm/supplier';
import { getItemSimpleList } from '#/api/mdm/item';
import type { MdmItemApi } from '#/api/mdm/item';
import { getSupplierList } from '#/api/srm/supplier';
import { MdmItemSelect } from '#/views/basicData/mdm/components';
import {
  TENDER_STATUS,
  TENDER_STATUS_CELLTAG,
@@ -45,16 +46,10 @@
const activeTab = ref('info');
// ========== 下拉选项数据 ==========
const mdmItemList = ref<MdmItemApi.Item[]>([]);
const supplierList = ref<{ id: number; name: string }[]>([]);
onMounted(async () => {
  const [items, suppliers] = await Promise.all([
    getItemSimpleList(),
    getSupplierList(),
  ]);
  mdmItemList.value = items;
  supplierList.value = suppliers;
  supplierList.value = await getSupplierList();
});
const filterOption = (input: string, option: any) =>
@@ -80,11 +75,6 @@
  return ids;
});
// 物料下拉可选列表(排除已添加的)
const availableMdmItems = computed(() =>
  mdmItemList.value.filter((item) => !addedProductIds.value.has(item.id!)),
);
async function loadProject() {
  project.value = await getTenderProject(projectId);
}
@@ -93,6 +83,11 @@
  try { materialList.value = await getMaterialList(projectId); } finally { materialLoading.value = false; }
}
async function handleSaveMaterial() {
  // 同一招标项目下不允许重复添加同一物料
  if (materialForm.value.productId && addedProductIds.value.has(materialForm.value.productId)) {
    message.warning('该物料已添加,请勿重复添加');
    return;
  }
  if (materialForm.value.id) {
    await updateMaterial(materialForm.value);
  } else {
@@ -101,8 +96,7 @@
  materialFormVisible.value = false;
  loadMaterials();
}
function onMaterialSelect(itemId: number) {
  const item = mdmItemList.value.find((i) => i.id === itemId);
function onMaterialSelect(item?: MdmItemApi.Item) {
  if (item) {
    materialForm.value.productCode = item.code;
    materialForm.value.productName = item.name;
@@ -918,14 +912,12 @@
      <a-modal v-model:open="materialFormVisible" :title="materialForm.id ? '编辑物料' : '添加物料'" :width="560" @ok="handleSaveMaterial">
        <a-form layout="vertical" class="mt-4">
          <a-form-item label="MDM物料" required>
            <a-select v-model:value="materialForm.productId" show-search placeholder="搜索并选择MDM物料" :filter-option="filterOption" option-label-prop="label" @change="onMaterialSelect">
              <a-select-option v-for="item in availableMdmItems" :key="item.id" :value="item.id" :label="`${item.code} ${item.name}`">
                <div class="flex flex-col">
                  <span class="font-medium">{{ item.code }}</span>
                  <span class="text-xs text-gray-400">{{ item.name }}{{ item.specification ? ` · ${item.specification}` : '' }}</span>
                </div>
              </a-select-option>
            </a-select>
            <MdmItemSelect
              v-model:model-value="materialForm.productId"
              :label="materialForm.productName"
              placeholder="请选择MDM物料"
              @change="onMaterialSelect"
            />
          </a-form-item>
          <a-row :gutter="12">
            <a-col :span="12">
src/views/wls/arrivalnotice/data.ts
@@ -11,10 +11,10 @@
import { z } from '#/adapter/form';
import { generateAutoCode } from '#/api/mes/md/autocode/record';
import { getItemPage } from '#/api/mdm/item';
import { getRangePickerDefaultProps } from '#/utils';
import { MdVendorSelect } from '#/views/mes/md/vendor/components';
import { MdmItemSelect } from '#/views/basicData/mdm/components';
import { ErpPurchaseOrderSelect } from '#/views/erp/purchase/order/components';
import { MdVendorSelect } from '#/views/mes/md/vendor/components';
/** 表单类型 */
export type FormType = 'create' | 'detail' | 'update';
@@ -347,19 +347,9 @@
    {
      fieldName: 'itemId',
      label: '物料',
      component: 'ApiSelect',
      component: markRaw(MdmItemSelect),
      componentProps: {
        placeholder: '请选择物料',
        allowClear: true,
        showSearch: true,
        api: getItemPage,
        resultField: 'list',
        labelField: 'name',
        valueField: 'id',
        optionRender: (option: any) => {
          const item = option.data;
          return `${item.code} - ${item.name}`;
        },
      },
      rules: 'required',
    },