ソースを参照

feat: 客户管理-新增调试1/2

赖奇 1 年間 前
コミット
05bef8da2f

+ 14 - 0
apps/web-ele/src/api/customer-manage/index.ts

@@ -33,3 +33,17 @@ export async function getCustomerDetailApi(data: { usersid: string }) {
     { formatData: true }, // 格式化返回数据
   );
 }
+
+/**
+ * 客户信息_新增
+ */
+export async function addCustomerApi(data: CustomerEntity) {
+  return requestClient.post<any>('/api/add?pagevalue=20', { ...data });
+}
+
+/**
+ * 客户信息_编辑
+ */
+export async function editCustomerApi(data: CustomerEntity) {
+  return requestClient.post<any>('/api/edit?pagevalue=21', { ...data });
+}

+ 79 - 7
apps/web-ele/src/views/customer-manage/form.vue

@@ -1,10 +1,16 @@
 <script lang="ts" setup>
+import type { CustomerEntity } from '@vben/types';
+
 import { computed, ref } from 'vue';
 
 import { useVbenModal } from '@vben/common-ui';
 
 import { useVbenForm, z } from '#/adapter/form';
-import { getCustomerDetailApi } from '#/api/customer-manage';
+import {
+  addCustomerApi,
+  editCustomerApi,
+  getCustomerDetailApi,
+} from '#/api/customer-manage';
 
 const data = ref();
 
@@ -23,6 +29,7 @@ const [BaseForm, baseFormApi] = useVbenForm({
   schema: [
     // { title: '用户名称', field: 'usersname' },
     // { title: '用户性质', field: 'usersnature' },
+    // { title: '用户类型', field: 'userstype' },
     // { title: '用户证件号码', field: 'usersidcardnumber' },
     // { title: '用户开户银行名称', field: 'usersbankname' },
     // { title: '用户开户银行账号', field: 'usersbanknumber' },
@@ -43,24 +50,77 @@ const [BaseForm, baseFormApi] = useVbenForm({
       rules: z.string().min(1, { message: '请输入用户名称' }),
     },
     {
-      component: 'Input',
+      component: 'Select',
       fieldName: 'usersnature',
       label: '用户性质',
       componentProps: {
         placeholder: '请输入用户性质',
         allowClear: true,
+        options: [
+          {
+            label: '用户',
+            value: '用户',
+          },
+          {
+            label: '渠道',
+            value: '渠道',
+          },
+        ],
+      },
+      rules: z.string().min(1, { message: '请输入用户性质' }),
+    },
+    {
+      component: 'Select',
+      fieldName: 'userstype',
+      label: '用户类型',
+      defaultValue: '个人',
+      componentProps: {
+        placeholder: '请输入用户类型',
+        allowClear: true,
+        options: [
+          {
+            label: '个人',
+            value: '个人',
+          },
+          {
+            label: '企业',
+            value: '企业',
+          },
+        ],
+      },
+      rules: z.string().min(1, { message: '请输入用户类型' }),
+    },
+    {
+      component: 'Input',
+      fieldName: 'usersidcardnumber',
+      label: '用户身份证号码',
+      componentProps: {
+        placeholder: '请输入用户身份证号码',
+        allowClear: true,
+      },
+      rules: z.string().min(1, { message: '请输入用户身份证号码' }),
+      dependencies: {
+        if(values) {
+          return values.userstype && values.userstype === '个人';
+        },
+        triggerFields: ['userstype'],
       },
-      rules: z.number().min(1, { message: '请输入用户性质' }),
     },
     {
       component: 'Input',
       fieldName: 'usersidcardnumber',
-      label: '用户证件号码',
+      label: '纳税人识别号',
       componentProps: {
-        placeholder: '请输入用户证件号码',
+        placeholder: '请输入纳税人识别号',
         allowClear: true,
       },
-      rules: z.string().min(1, { message: '请输入用户证件号码' }),
+      rules: z.string().min(1, { message: '请输入纳税人识别号' }),
+      dependencies: {
+        if(values) {
+          return values.userstype && values.userstype === '企业';
+        },
+        triggerFields: ['userstype'],
+      },
     },
     {
       component: 'Input',
@@ -156,7 +216,19 @@ const [Modal, modalApi] = useVbenModal({
       return;
     }
 
-    modalApi.close();
+    // 调用新增或编辑接口
+    const res = await (data.value.create
+      ? addCustomerApi(validate.values as CustomerEntity)
+      : editCustomerApi(validate.values as CustomerEntity));
+
+    // eslint-disable-next-line no-console
+    console.log(res);
+
+    // if (res.code === 200) {
+    //   modalApi.close();
+    // }
+
+    // modalApi.close();
     // const values = await baseFormApi.getValues();
 
     // console.log(Object.keys(values));

+ 1 - 0
apps/web-ele/src/views/customer-manage/index.vue

@@ -76,6 +76,7 @@ const gridOptions: VxeGridProps<any> = {
   columns: [
     { title: '用户名称', field: 'usersname' },
     { title: '用户性质', field: 'usersnature' },
+    { title: '用户类型', field: 'userstype' },
     { title: '用户证件号码', field: 'usersidcardnumber' },
     { title: '用户开户银行名称', field: 'usersbankname' },
     { title: '用户开户银行账号', field: 'usersbanknumber' },

+ 5 - 3
packages/types/src/user.ts

@@ -9,9 +9,9 @@ interface UserInfo extends BasicUserInfo {
 // CREATE TABLE `users` (
 //   `usersid` varchar(50) NOT NULL COMMENT '用户id',
 //   `usersname` varchar(50) DEFAULT NULL COMMENT '用户名称',
-//   `usersnature` tinyint(2) DEFAULT NULL COMMENT '用户性质',
+//   `usersnature` tinyint(2) DEFAULT NULL COMMENT '用户性质(用户/渠道)',
 //   `userssuperiorid` varchar(50) DEFAULT NULL COMMENT '用户关联上级id',
-//   `usersidcardnumber` varchar(50) DEFAULT NULL COMMENT '用户证件号码',
+//   `usersidcardnumber` varchar(50) DEFAULT NULL COMMENT '用户证件号码(个人用户-身份证号,企业-纳税号)',
 //   `usersbankname` varchar(50) DEFAULT NULL COMMENT '用户开户银行名称',
 //   `usersbanknumber` varchar(50) DEFAULT NULL COMMENT '用户开户银行账号',
 //   `usersphone` varchar(50) DEFAULT NULL COMMENT '用户手机号',
@@ -23,10 +23,11 @@ interface UserInfo extends BasicUserInfo {
 //   `usersopenid` varchar(50) DEFAULT NULL COMMENT '用户微信openid',
 //   `usersauthstatus` tinyint(2) DEFAULT NULL COMMENT '用户是否实名(0:未认证,1:已认证)',
 //   `usersdate` datetime DEFAULT NULL COMMENT '用户创建时间',
+//   `userstype` varchar(50) DEFAULT NULL COMMENT '用户类型(个人/企业)\n)',
 //   PRIMARY KEY (`usersid`)
 // ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='用户信息';
 
-// const stats = 'usersid,usersname,usersnature,userssuperiorid,usersidcardnumber,usersbankname,usersbanknumber,usersphone,usersemail,usersaddress,userscontactphone,userscontactemail,userscontactaddress,usersopenid,usersauthstatus,usersdate';
+// const stats = 'usersid,usersname,usersnature,userssuperiorid,usersidcardnumber,usersbankname,usersbanknumber,usersphone,usersemail,usersaddress,userscontactphone,userscontactemail,userscontactaddress,usersopenid,usersauthstatus,usersdate,userstype';
 
 /** 用户认证状态 */
 type UserAuthStatusType = 0 | 1;
@@ -34,6 +35,7 @@ type UserAuthStatusType = 0 | 1;
 interface CustomerEntity {
   usersid: number;
   usersname: string;
+  userstype: string;
   usersnature: number;
   userssuperiorid: string;
   usersidcardnumber: string;