|
@@ -1,13 +1,14 @@
|
|
|
<script lang="ts" setup>
|
|
<script lang="ts" setup>
|
|
|
import type { CustomerEntity } from '@vben/types';
|
|
import type { CustomerEntity } from '@vben/types';
|
|
|
|
|
|
|
|
-import { computed, ref } from 'vue';
|
|
|
|
|
|
|
+import { computed, onMounted, ref } from 'vue';
|
|
|
|
|
|
|
|
import { useVbenModal } from '@vben/common-ui';
|
|
import { useVbenModal } from '@vben/common-ui';
|
|
|
|
|
|
|
|
import { ElMessage } from 'element-plus';
|
|
import { ElMessage } from 'element-plus';
|
|
|
|
|
|
|
|
import { useVbenForm, z } from '#/adapter/form';
|
|
import { useVbenForm, z } from '#/adapter/form';
|
|
|
|
|
+import { getScqyListApi } from '#/api/scqy';
|
|
|
import {
|
|
import {
|
|
|
addCustomerApi,
|
|
addCustomerApi,
|
|
|
editCustomerApi,
|
|
editCustomerApi,
|
|
@@ -17,6 +18,7 @@ import {
|
|
|
const emit = defineEmits(['finish']);
|
|
const emit = defineEmits(['finish']);
|
|
|
const data = ref();
|
|
const data = ref();
|
|
|
const formType = ref<'create' | 'detail' | 'edit'>('create');
|
|
const formType = ref<'create' | 'detail' | 'edit'>('create');
|
|
|
|
|
+const scqyOptions = ref<{ label: string; value: string }[]>([]);
|
|
|
|
|
|
|
|
const titleMap = {
|
|
const titleMap = {
|
|
|
create: '新增客户',
|
|
create: '新增客户',
|
|
@@ -26,6 +28,25 @@ const titleMap = {
|
|
|
|
|
|
|
|
const getTitle = computed(() => titleMap[formType.value]);
|
|
const getTitle = computed(() => titleMap[formType.value]);
|
|
|
|
|
|
|
|
|
|
+const scqySelectOptions = computed(() => scqyOptions.value);
|
|
|
|
|
+
|
|
|
|
|
+// 获取生产企业列表
|
|
|
|
|
+const fetchScqyList = async () => {
|
|
|
|
|
+ try {
|
|
|
|
|
+ const { Total, Data } = await getScqyListApi({ pageindex: 1, rows: 999 });
|
|
|
|
|
+ const list = Data || [];
|
|
|
|
|
+ if (Total > 0) {
|
|
|
|
|
+ scqyOptions.value = list.map((item: any) => ({
|
|
|
|
|
+ label: item.scqyinfomc,
|
|
|
|
|
+ value: item.scqyinfoid,
|
|
|
|
|
+ }));
|
|
|
|
|
+ }
|
|
|
|
|
+ console.log('获取生产企业列表:', scqyOptions.value);
|
|
|
|
|
+ } catch (error) {
|
|
|
|
|
+ console.error('获取生产企业列表失败:', error);
|
|
|
|
|
+ }
|
|
|
|
|
+};
|
|
|
|
|
+
|
|
|
const [BaseForm, baseFormApi] = useVbenForm({
|
|
const [BaseForm, baseFormApi] = useVbenForm({
|
|
|
showDefaultActions: false,
|
|
showDefaultActions: false,
|
|
|
// 所有表单项共用,可单独在表单内覆盖
|
|
// 所有表单项共用,可单独在表单内覆盖
|
|
@@ -182,6 +203,24 @@ const [BaseForm, baseFormApi] = useVbenForm({
|
|
|
triggerFields: ['userstype'],
|
|
triggerFields: ['userstype'],
|
|
|
},
|
|
},
|
|
|
},
|
|
},
|
|
|
|
|
+ // 生产企业选择
|
|
|
|
|
+ {
|
|
|
|
|
+ component: 'Select',
|
|
|
|
|
+ fieldName: 'usersscqyid',
|
|
|
|
|
+ label: '生产企业',
|
|
|
|
|
+ componentProps: {
|
|
|
|
|
+ placeholder: '请选择生产企业',
|
|
|
|
|
+ allowClear: true,
|
|
|
|
|
+ options: scqySelectOptions,
|
|
|
|
|
+ },
|
|
|
|
|
+ rules: z.string().min(1, { message: '请选择生产企业' }),
|
|
|
|
|
+ dependencies: {
|
|
|
|
|
+ if(values) {
|
|
|
|
|
+ return values.usersnature === '经销商';
|
|
|
|
|
+ },
|
|
|
|
|
+ triggerFields: ['usersnature'],
|
|
|
|
|
+ },
|
|
|
|
|
+ },
|
|
|
// 通用字段
|
|
// 通用字段
|
|
|
{
|
|
{
|
|
|
component: 'Input',
|
|
component: 'Input',
|
|
@@ -232,34 +271,6 @@ const [BaseForm, baseFormApi] = useVbenForm({
|
|
|
allowClear: true,
|
|
allowClear: true,
|
|
|
},
|
|
},
|
|
|
},
|
|
},
|
|
|
- // {
|
|
|
|
|
- // component: 'Input',
|
|
|
|
|
- // fieldName: 'userscontactphone',
|
|
|
|
|
- // label: '联系手机号',
|
|
|
|
|
- // componentProps: {
|
|
|
|
|
- // placeholder: '请输入联系手机号',
|
|
|
|
|
- // allowClear: true,
|
|
|
|
|
- // },
|
|
|
|
|
- // },
|
|
|
|
|
- // {
|
|
|
|
|
- // component: 'Input',
|
|
|
|
|
- // fieldName: 'userscontactemail',
|
|
|
|
|
- // label: '联系邮箱',
|
|
|
|
|
- // componentProps: {
|
|
|
|
|
- // placeholder: '请输入联系邮箱',
|
|
|
|
|
- // allowClear: true,
|
|
|
|
|
- // },
|
|
|
|
|
- // rules: z.string().email({ message: '请输入正确的邮箱格式' }),
|
|
|
|
|
- // },
|
|
|
|
|
- // {
|
|
|
|
|
- // component: 'Input',
|
|
|
|
|
- // fieldName: 'userscontactaddress',
|
|
|
|
|
- // label: '联系地址',
|
|
|
|
|
- // componentProps: {
|
|
|
|
|
- // placeholder: '请输入联系地址',
|
|
|
|
|
- // allowClear: true,
|
|
|
|
|
- // },
|
|
|
|
|
- // },
|
|
|
|
|
{
|
|
{
|
|
|
component: 'Input',
|
|
component: 'Input',
|
|
|
fieldName: 'userscz',
|
|
fieldName: 'userscz',
|
|
@@ -352,6 +363,11 @@ const [Modal, modalApi] = useVbenModal({
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
});
|
|
});
|
|
|
|
|
+
|
|
|
|
|
+// 组件挂载时获取生产企业列表
|
|
|
|
|
+onMounted(() => {
|
|
|
|
|
+ fetchScqyList();
|
|
|
|
|
+});
|
|
|
</script>
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
<template>
|