|
|
@@ -13,12 +13,14 @@ import {
|
|
|
editProductApi,
|
|
|
getProductDetailApi,
|
|
|
} from '#/api/product';
|
|
|
+import { getScqyListApi } from '#/api/scqy';
|
|
|
import { getCustomerListApi } from '#/api/user';
|
|
|
|
|
|
const emit = defineEmits(['finish']);
|
|
|
const data = ref();
|
|
|
const formType = ref<'create' | 'detail' | 'edit'>('create');
|
|
|
const channelOptions = ref<{ label: string; value: string }[]>([]);
|
|
|
+const scqyOptions = ref<{ label: string; value: string }[]>([]);
|
|
|
|
|
|
// 获取渠道商列表
|
|
|
const fetchChannelOptions = async () => {
|
|
|
@@ -44,6 +46,29 @@ const fetchChannelOptions = async () => {
|
|
|
}
|
|
|
};
|
|
|
|
|
|
+// 获取生产企业列表
|
|
|
+const fetchScqyOptions = async () => {
|
|
|
+ try {
|
|
|
+ // 确保清空之前的选项
|
|
|
+ scqyOptions.value = [];
|
|
|
+
|
|
|
+ const response = await getScqyListApi({
|
|
|
+ pageindex: 1,
|
|
|
+ rows: 100,
|
|
|
+ });
|
|
|
+
|
|
|
+ // 从response.Data中获取数据
|
|
|
+ if (response && response.Data && Array.isArray(response.Data)) {
|
|
|
+ scqyOptions.value = response.Data.map((item: any) => ({
|
|
|
+ label: item.scqyinfomc || '未命名生产企业',
|
|
|
+ value: item.scqyinfoid || '',
|
|
|
+ })).filter((item: any) => item.value);
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ console.error('获取生产企业列表失败', error);
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
const titleMap = {
|
|
|
create: '新增产品',
|
|
|
detail: '产品详情',
|
|
|
@@ -167,6 +192,21 @@ const [BaseForm, baseFormApi] = useVbenForm({
|
|
|
rules: z.array(z.string()).min(1, { message: '请选择关联渠道商' }),
|
|
|
},
|
|
|
{
|
|
|
+ component: 'Select',
|
|
|
+ fieldName: 'productsscqyid',
|
|
|
+ label: '关联生产企业',
|
|
|
+ componentProps: {
|
|
|
+ placeholder: '请选择关联生产企业',
|
|
|
+ options: scqyOptions,
|
|
|
+ clearable: true,
|
|
|
+ filterable: true,
|
|
|
+ noDataText: '暂无生产企业数据',
|
|
|
+ loading: false,
|
|
|
+ style: { width: '100%' },
|
|
|
+ },
|
|
|
+ rules: z.string().min(1, { message: '请选择关联生产企业' }),
|
|
|
+ },
|
|
|
+ {
|
|
|
component: 'Input',
|
|
|
fieldName: 'productsfl1',
|
|
|
label: '一级分类',
|
|
|
@@ -281,8 +321,8 @@ const [Modal, modalApi] = useVbenModal({
|
|
|
commonConfig: { disabled: formType.value === 'detail' },
|
|
|
});
|
|
|
|
|
|
- // 获取渠道商列表
|
|
|
- await fetchChannelOptions();
|
|
|
+ // 获取渠道商列表和生产企业列表
|
|
|
+ await Promise.all([fetchChannelOptions(), fetchScqyOptions()]);
|
|
|
|
|
|
if (data.value.formType === 'create') {
|
|
|
return;
|