Parcourir la source

feat: 生产企业管理对接

赖奇 il y a 1 an
Parent
commit
eec915c8da

+ 47 - 0
apps/web-ele/src/api/scqy-manage/index.ts

@@ -0,0 +1,47 @@
+import type { PageConfig, ScqyEntity } from '@vben/types';
+
+import { adaptBackendRequest } from '@vben/utils';
+
+import { requestClient } from '#/api/request';
+
+interface ScqyPartialEntity extends Partial<Omit<ScqyEntity, 'scqyinfomc'>> {
+  scqyinfomc?: string;
+}
+
+interface ScqyQueryParams extends PageConfig, ScqyPartialEntity {}
+
+/**
+ * 生产企业信息_列表
+ */
+export async function getScqyListApi(params: ScqyQueryParams) {
+  return requestClient.post<any>('/api/query/list?pagevalue=28', {
+    ...params,
+  });
+}
+
+/**
+ * 生产企业信息_详情
+ */
+export async function getScqyDetailApi(data: { scqyinfoid: string }) {
+  return requestClient.post<any>(
+    '/api/query/view?pagevalue=29',
+    {
+      ...adaptBackendRequest(data),
+    },
+    { formatData: true }, // 格式化返回数据
+  );
+}
+
+/**
+ * 生产企业信息_新增
+ */
+export async function addScqyApi(data: ScqyEntity) {
+  return requestClient.post<any>('/api/add?pagevalue=30', { ...data });
+}
+
+/**
+ * 生产企业信息_编辑
+ */
+export async function editScqyApi(data: ScqyEntity) {
+  return requestClient.post<any>('/api/up?pagevalue=31', { ...data });
+}

+ 79 - 94
apps/web-ele/src/views/scqy-manage/form.vue

@@ -1,151 +1,112 @@
 <script lang="ts" setup>
+import type { ScqyEntity } from '@vben/types';
+
 import { computed, ref } from 'vue';
 
 import { useVbenModal } from '@vben/common-ui';
 
+import { ElMessage } from 'element-plus';
+
 import { useVbenForm, z } from '#/adapter/form';
-import { getCustomerDetailApi } from '#/api/customer-manage';
+import { addScqyApi, editScqyApi, getScqyDetailApi } from '#/api/scqy-manage';
 
+const emit = defineEmits(['finish']);
 const data = ref();
+const formType = ref<'create' | 'detail' | 'edit'>('create');
+
+const titleMap = {
+  create: '新增生产企业',
+  detail: '生产企业详情',
+  edit: '编辑生产企业',
+} as const;
 
-const getTitle = computed(() => (data.value?.create ? '新增客户' : '编辑客户'));
+const getTitle = computed(() => titleMap[formType.value]);
 
 const [BaseForm, baseFormApi] = useVbenForm({
   showDefaultActions: false,
   // 所有表单项共用,可单独在表单内覆盖
   commonConfig: {
-    labelWidth: 120,
+    labelWidth: 140,
     // 所有表单项
     componentProps: {
       class: 'w-full',
     },
   },
+  wrapperClass: 'grid-cols-1 lg:grid-cols-2',
   schema: [
-    // { title: '用户名称', field: 'usersname' },
-    // { title: '用户性质', field: 'usersnature' },
-    // { title: '用户证件号码', field: 'usersidcardnumber' },
-    // { title: '用户开户银行名称', field: 'usersbankname' },
-    // { title: '用户开户银行账号', field: 'usersbanknumber' },
-    // { title: '用户手机号', field: 'usersphone' },
-    // { title: '用户邮箱', field: 'usersemail' },
-    // { title: '用户地址', field: 'usersaddress' },
-    // { title: '用户联系手机号', field: 'userscontactphone' },
-    // { title: '用户联系邮箱', field: 'userscontactemail' },
-    // { title: '用户联系地址', field: 'userscontactaddress' },
-    {
-      component: 'Input',
-      fieldName: 'usersname',
-      label: '用户名称',
-      componentProps: {
-        placeholder: '请输入用户名称',
-        allowClear: true,
-      },
-      rules: z.string().min(1, { message: '请输入用户名称' }),
-    },
-    {
-      component: 'Input',
-      fieldName: 'usersnature',
-      label: '用户性质',
-      componentProps: {
-        placeholder: '请输入用户性质',
-        allowClear: true,
-      },
-      rules: z.number().min(1, { message: '请输入用户性质' }),
-    },
-    {
-      component: 'Input',
-      fieldName: 'usersidcardnumber',
-      label: '用户证件号码',
-      componentProps: {
-        placeholder: '请输入用户证件号码',
-        allowClear: true,
-      },
-      rules: z.string().min(1, { message: '请输入用户证件号码' }),
-    },
-    {
-      component: 'Input',
-      fieldName: 'usersbankname',
-      label: '用户开户银行名称',
-      componentProps: {
-        placeholder: '请输入用户开户银行名称',
-        allowClear: true,
-      },
-      rules: z.string().min(1, { message: '请输入用户开户银行名称' }),
-    },
-    {
-      component: 'Input',
-      fieldName: 'usersbanknumber',
-      label: '用户开户银行账号',
-      componentProps: {
-        placeholder: '请输入用户开户银行账号',
-        allowClear: true,
-      },
-      rules: z.string().min(1, { message: '请输入用户开户银行账号' }),
-    },
+    // { title: '生产企业名称', field: 'scqyinfomc' },
+    // { title: '生产企业地址', field: 'scqyinfoaddress' },
+    // { title: '生产企业法人姓名', field: 'scqyinfofrmc' },
+    // { title: '生产企业电子邮箱', field: 'scqyinfomail' },
+    // { title: '生产企业销售联系人', field: 'scqyinfoxsmc' },
+    // { title: '生产企业销售联系手机号', field: 'scqyinfoxsphone' },
     {
       component: 'Input',
-      fieldName: 'usersphone',
-      label: '用户手机号',
+      fieldName: 'scqyinfomc',
+      label: '企业名称',
       componentProps: {
-        placeholder: '请输入用户手机号',
+        placeholder: '请输入生产企业名称',
         allowClear: true,
       },
-      rules: z.string().min(1, { message: '请输入用户手机号' }),
+      rules: z.string().min(1, { message: '请输入生产企业名称' }),
     },
     {
       component: 'Input',
-      fieldName: 'usersemail',
-      label: '用户邮箱',
+      fieldName: 'scqyinfoaddress',
+      label: '企业地址',
       componentProps: {
-        placeholder: '请输入用户邮箱',
+        placeholder: '请输入生产企业地址',
         allowClear: true,
       },
-      rules: z.string().min(1, { message: '请输入用户邮箱' }),
+      rules: z.string().min(1, { message: '请输入生产企业地址' }),
     },
     {
       component: 'Input',
-      fieldName: 'usersaddress',
-      label: '用户地址',
+      fieldName: 'scqyinfofrmc',
+      label: '法人姓名',
       componentProps: {
-        placeholder: '请输入用户地址',
+        placeholder: '请输入生产企业法人姓名',
         allowClear: true,
       },
-      rules: z.string().min(1, { message: '请输入用户地址' }),
+      rules: z.string().min(1, { message: '请输入生产企业法人姓名' }),
     },
     {
       component: 'Input',
-      fieldName: 'userscontactphone',
-      label: '用户联系手机号',
+      fieldName: 'scqyinfomail',
+      label: '电子邮箱',
       componentProps: {
-        placeholder: '请输入用户联系手机号',
+        placeholder: '请输入生产企业电子邮箱',
         allowClear: true,
       },
-      rules: z.string().min(1, { message: '请输入用户联系手机号' }),
+      rules: z.string().email({ message: '请输入正确的电子邮箱格式' }),
     },
     {
       component: 'Input',
-      fieldName: 'userscontactemail',
-      label: '用户联系邮箱',
+      fieldName: 'scqyinfoxsmc',
+      label: '销售联系人',
       componentProps: {
-        placeholder: '请输入用户联系邮箱',
+        placeholder: '请输入生产企业销售联系人',
         allowClear: true,
       },
-      rules: z.string().min(1, { message: '请输入用户联系邮箱' }),
+      rules: z.string().min(1, { message: '请输入生产企业销售联系人' }),
     },
     {
       component: 'Input',
-      fieldName: 'userscontactaddress',
-      label: '用户联系地址',
+      fieldName: 'scqyinfoxsphone',
+      label: '销售联系手机号',
       componentProps: {
-        placeholder: '请输入用户联系地址',
+        placeholder: '请输入生产企业销售联系手机号',
         allowClear: true,
       },
-      rules: z.string().min(1, { message: '请输入用户联系地址' }),
+      rules: z
+        .string()
+        .regex(/^1[3-9]\d{9}$/, { message: '请输入正确的手机号格式' }),
     },
   ],
 });
 
 const [Modal, modalApi] = useVbenModal({
+  class: 'w-7/12',
   onCancel() {
     modalApi.close();
   },
@@ -156,23 +117,47 @@ const [Modal, modalApi] = useVbenModal({
       return;
     }
 
-    modalApi.close();
-    // const values = await baseFormApi.getValues();
+    try {
+      // 调用新增或编辑接口
+      const apiMap = {
+        create: () => addScqyApi(validate.values as ScqyEntity),
+        edit: () =>
+          editScqyApi({
+            ...validate.values,
+            'scqyinfoid.value': data.value.row.scqyinfoid,
+          } as any),
+      };
+
+      if (formType.value === 'detail') {
+        modalApi.close();
+        return;
+      }
+
+      await apiMap[formType.value]();
+      ElMessage.success('操作成功');
 
-    // console.log(Object.keys(values));
+      emit('finish');
+      modalApi.close();
+    } catch {}
   },
   async onOpenChange(isOpen) {
     if (isOpen) {
       data.value = modalApi.getData();
 
-      if (data.value.create) {
+      formType.value = data.value.formType;
+
+      baseFormApi.setState({
+        commonConfig: { disabled: formType.value === 'detail' },
+      });
+
+      if (data.value.formType === 'create') {
         return;
       }
 
       try {
         modalApi.setState({ loading: true });
-        const detailData = await getCustomerDetailApi({
-          usersid: data.value.row.usersid,
+        const detailData = await getScqyDetailApi({
+          scqyinfoid: data.value.row.scqyinfoid,
         });
 
         baseFormApi.setValues(detailData);

+ 31 - 41
apps/web-ele/src/views/scqy-manage/index.vue

@@ -7,10 +7,10 @@ import { Page, useVbenModal } from '@vben/common-ui';
 import { MdiDetail, MdiEdit } from '@vben/icons';
 
 import { useVbenVxeGrid } from '#/adapter/vxe-table';
-// import { getCustomerListApi } from '#/api/customer-manage';
+import { getScqyListApi } from '#/api/scqy-manage';
 import { $t } from '#/locales';
 
-import CustomerForm from './form.vue';
+import ScqyForm from './form.vue';
 
 const formOptions: VbenFormProps = {
   // 默认展开
@@ -22,23 +22,15 @@ const formOptions: VbenFormProps = {
   schema: [
     {
       component: 'Input',
-      fieldName: 'usersname',
-      label: '用户名称',
-      componentProps: {
-        placeholder: $t('ui.placeholder.input'),
-        allowClear: true,
-      },
-    },
-    {
-      component: 'Input',
-      fieldName: 'usersphone',
-      label: '用户手机号',
+      fieldName: 'scqyinfomc',
+      label: '企业名称',
       componentProps: {
         placeholder: $t('ui.placeholder.input'),
         allowClear: true,
       },
     },
   ],
+  wrapperClass: 'grid-cols-1 md:grid-cols-3 lg:grid-cols-5',
 };
 
 const gridOptions: VxeGridProps<any> = {
@@ -62,29 +54,24 @@ const gridOptions: VxeGridProps<any> = {
       result: 'Data',
       total: 'Total',
     },
-    // ajax: {
-    //   query: async ({ page }, formValues) => {
-    //     return await getCustomerListApi({
-    //       pageindex: page.currentPage,
-    //       rows: page.pageSize,
-    //       ...formValues,
-    //     });
-    //   },
-    // },
+    ajax: {
+      query: async ({ page }, formValues) => {
+        return await getScqyListApi({
+          pageindex: page.currentPage,
+          rows: page.pageSize,
+          ...formValues,
+        });
+      },
+    },
   },
 
   columns: [
-    { title: '用户名称', field: 'usersname' },
-    { title: '用户性质', field: 'usersnature' },
-    { title: '用户证件号码', field: 'usersidcardnumber' },
-    { title: '用户开户银行名称', field: 'usersbankname' },
-    { title: '用户开户银行账号', field: 'usersbanknumber' },
-    { title: '用户手机号', field: 'usersphone' },
-    { title: '用户邮箱', field: 'usersemail' },
-    { title: '用户地址', field: 'usersaddress' },
-    { title: '用户联系手机号', field: 'userscontactphone' },
-    { title: '用户联系邮箱', field: 'userscontactemail' },
-    { title: '用户联系地址', field: 'userscontactaddress' },
+    { title: '企业名称', field: 'scqyinfomc' },
+    { title: '企业地址', field: 'scqyinfoaddress' },
+    { title: '法人姓名', field: 'scqyinfofrmc' },
+    { title: '电子邮箱', field: 'scqyinfomail' },
+    { title: '销售联系人', field: 'scqyinfoxsmc' },
+    { title: '销售联系手机号', field: 'scqyinfoxsphone' },
     {
       title: '操作',
       field: 'action',
@@ -95,35 +82,38 @@ const gridOptions: VxeGridProps<any> = {
   ],
 };
 
-const [Grid] = useVbenVxeGrid({ gridOptions, formOptions });
+const [Grid, gridApi] = useVbenVxeGrid({ gridOptions, formOptions });
 
 const [Modal, modalApi] = useVbenModal({
   fullscreenButton: false,
   closeOnClickModal: false,
   closeOnPressEscape: false,
-  connectedComponent: CustomerForm,
+  connectedComponent: ScqyForm,
 });
 
 /* 创建 */
 function handleCreate() {
-  modalApi.setData({ create: true }).open();
+  modalApi.setData({ formType: 'create' }).open();
 }
 
 /* 编辑 */
 function handleEdit(row: any) {
-  modalApi.setData({ row }).open();
+  modalApi.setData({ formType: 'edit', row }).open();
 }
 
 /* 详情 */
 function handleDetail(row: any) {
-  modalApi.setData({ row }).open();
-  // router.push(`/system/users/detail/${row.userName}`);
+  modalApi.setData({ formType: 'detail', row }).open();
+}
+
+function handleFinish() {
+  gridApi.reload();
 }
 </script>
 
 <template>
   <Page auto-content-height>
-    <Grid table-title="供应商列表">
+    <Grid table-title="生产企业列表">
       <template #toolbar-tools>
         <el-button type="primary" @click="handleCreate"> 新增 </el-button>
       </template>
@@ -142,6 +132,6 @@ function handleDetail(row: any) {
         />
       </template>
     </Grid>
-    <Modal />
+    <Modal @finish="handleFinish" />
   </Page>
 </template>

+ 1 - 0
packages/types/src/index.ts

@@ -1,4 +1,5 @@
 export type * from './base';
 export type * from './product';
+export type * from './scqy';
 export type * from './user';
 export type * from '@vben-core/typings';

+ 33 - 0
packages/types/src/scqy.ts

@@ -0,0 +1,33 @@
+/** 生产企业信息*/
+// CREATE TABLE `scqyinfo` (
+//   `scqyinfoid` varchar(50) NOT NULL COMMENT '生产企业信息流水号',
+//   `scqyinfomc` varchar(100) DEFAULT NULL COMMENT '生产企业名称',
+//   `scqyinfoaddress` varchar(255) DEFAULT NULL COMMENT '生产企业地址',
+//   `scqyinfofrmc` varchar(50) DEFAULT NULL COMMENT '生产企业法人姓名',
+//   `scqyinfomail` varchar(50) DEFAULT NULL COMMENT '生产企业电子邮箱',
+//   `scqyinfoxsmc` varchar(50) DEFAULT NULL COMMENT '生产企业销售联系人',
+//   `scqyinfoxsphone` varchar(50) DEFAULT NULL COMMENT '生产企业销售联系手机号',
+//   `scqyinfodate` datetime DEFAULT NULL COMMENT '生产企业信息创建日期',
+//   PRIMARY KEY (`scqyinfoid`) USING BTREE
+// ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='生产企业信息';
+
+interface ScqyEntity {
+  /** 生产企业信息流水号 */
+  scqyinfoid: string;
+  /** 生产企业名称 */
+  scqyinfomc: string;
+  /** 生产企业地址 */
+  scqyinfoaddress: string;
+  /** 生产企业法人姓名 */
+  scqyinfofrmc: string;
+  /** 生产企业电子邮箱 */
+  scqyinfomail: string;
+  /** 生产企业销售联系人 */
+  scqyinfoxsmc: string;
+  /** 生产企业销售联系手机号 */
+  scqyinfoxsphone: string;
+  /** 生产企业信息创建日期 */
+  scqyinfodate: string;
+}
+
+export type { ScqyEntity };