Prechádzať zdrojové kódy

feat: 产品管理相关功能

赖奇 1 rok pred
rodič
commit
de19238ec9

+ 48 - 0
apps/web-ele/src/api/product-manage/index.ts

@@ -0,0 +1,48 @@
+import type { PageConfig, ProductEntity } from '@vben/types';
+
+import { adaptBackendRequest } from '@vben/utils';
+
+import { requestClient } from '#/api/request';
+
+interface ProductPartialEntity
+  extends Partial<Omit<ProductEntity, 'productsname'>> {
+  productsname?: string;
+}
+
+interface ProductQueryParams extends PageConfig, ProductPartialEntity {}
+
+/**
+ * 产品信息_列表
+ */
+export async function getProductListApi(params: ProductQueryParams) {
+  return requestClient.post<any>('/api/query/list?pagevalue=23', {
+    ...params,
+  });
+}
+
+/**
+ * 产品信息_详情
+ */
+export async function getProductDetailApi(data: { productsid: string }) {
+  return requestClient.post<any>(
+    '/api/query/view?pagevalue=24',
+    {
+      ...adaptBackendRequest(data),
+    },
+    { formatData: true }, // 格式化返回数据
+  );
+}
+
+/**
+ * 产品信息_新增
+ */
+export async function addProductApi(data: ProductEntity) {
+  return requestClient.post<any>('/api/add?pagevalue=25', { ...data });
+}
+
+/**
+ * 产品信息_编辑
+ */
+export async function editProductApi(data: ProductEntity) {
+  return requestClient.post<any>('/api/up?pagevalue=26', { ...data });
+}

+ 3 - 3
apps/web-ele/src/locales/langs/en-US/page.json

@@ -19,13 +19,13 @@
     "dataDictionary": "Dictionary",
     "userManage": "User",
     "customerManage": "Customer",
-    "merchantManage": "Merchant",
-    "supplierManage": "Supplier",
+    "subsidyManage": "Subsidy",
+    "scqyManage": "Supplier",
     "productManage": "Product",
     "orderManage": "Order",
     "couponManage": "Coupon",
     "examineManage": "Examine",
-    "examineMerchant": "Merchant",
+    "examineScqy": "Supplier",
     "examineOrder": "Order"
   }
 }

+ 4 - 4
apps/web-ele/src/locales/langs/zh-CN/page.json

@@ -19,13 +19,13 @@
     "dataDictionary": "数据字典",
     "userManage": "用户管理",
     "customerManage": "客户管理",
-    "merchantManage": "商户管理",
-    "supplierManage": "供应商管理",
-    "productManage": "品管理",
+    "subsidyManage": "补贴申请管理",
+    "scqyManage": "生产企业管理",
+    "productManage": "品管理",
     "orderManage": "订单管理",
     "couponManage": "优惠券管理",
     "examineManage": "审核管理",
-    "examineMerchant": "商户审核",
+    "examineScqy": "生产企业审核",
     "examineOrder": "订单审核"
   }
 }

+ 0 - 0
apps/web-ele/src/views/examine-manage/examine-merchant/form.vue → apps/web-ele/src/views/examine-manage/examine-scqy/form.vue


+ 0 - 0
apps/web-ele/src/views/examine-manage/examine-merchant/index.vue → apps/web-ele/src/views/examine-manage/examine-scqy/index.vue


+ 133 - 66
apps/web-ele/src/views/product-manage/form.vue

@@ -1,151 +1,194 @@
 <script lang="ts" setup>
+import type { ProductEntity } 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 {
+  addProductApi,
+  editProductApi,
+  getProductDetailApi,
+} from '#/api/product-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' },
+    // { title: '产品名称', field: 'productsname' },
+    // { title: '产品类别', field: 'productscategory' },
+    // { title: '产品原价', field: 'productsprice' },
+    // { title: '产品型号', field: 'productsmodel' },
+    // { title: '产品sn号', field: 'productssn' },
+    // { title: '品目', field: 'productspm' },
+    // { title: '一级分类', field: 'productsfl1' },
+    // { title: '二级分类', field: 'productsfl2' },
+    // { title: '分档名称', field: 'productsfdmc' },
+    // { title: '分档编号', field: 'productsfdbh' },
+    // { title: '中央补贴金额', field: 'productszybt' },
+    // { title: '特殊县中央补贴金额', field: 'productstsxzybt' },
+    // { title: '机具类型', field: 'productsjjlx' },
     {
       component: 'Input',
-      fieldName: 'usersname',
-      label: '用户名称',
+      fieldName: 'productsname',
+      label: '产品名称',
       componentProps: {
-        placeholder: '请输入用户名称',
+        placeholder: '请输入产品名称',
         allowClear: true,
       },
-      rules: z.string().min(1, { message: '请输入用户名称' }),
+      rules: z.string().min(1, { message: '请输入产品名称' }),
     },
     {
       component: 'Input',
-      fieldName: 'usersnature',
-      label: '用户性质',
+      fieldName: 'productscategory',
+      label: '产品类别',
       componentProps: {
-        placeholder: '请输入用户性质',
+        placeholder: '请输入产品类别',
         allowClear: true,
       },
-      rules: z.number().min(1, { message: '请输入用户性质' }),
+      rules: z.string().min(1, { message: '请输入产品类别' }),
     },
     {
-      component: 'Input',
-      fieldName: 'usersidcardnumber',
-      label: '用户证件号码',
+      component: 'InputNumber',
+      fieldName: 'productsprice',
+      label: '产品原价',
       componentProps: {
-        placeholder: '请输入用户证件号码',
-        allowClear: true,
+        placeholder: '请输入产品原价',
+        min: 0,
+        precision: 2,
       },
-      rules: z.string().min(1, { message: '请输入用户证件号码' }),
+      rules: z.number().min(0, { message: '请输入正确的产品原价' }),
     },
     {
       component: 'Input',
-      fieldName: 'usersbankname',
-      label: '用户开户银行名称',
+      fieldName: 'productsmodel',
+      label: '产品型号',
       componentProps: {
-        placeholder: '请输入用户开户银行名称',
+        placeholder: '请输入产品型号',
         allowClear: true,
       },
-      rules: z.string().min(1, { message: '请输入用户开户银行名称' }),
+      rules: z.string().min(1, { message: '请输入产品型号' }),
     },
     {
       component: 'Input',
-      fieldName: 'usersbanknumber',
-      label: '用户开户银行账号',
+      fieldName: 'productssn',
+      label: '产品SN号',
       componentProps: {
-        placeholder: '请输入用户开户银行账号',
+        placeholder: '请输入产品SN号',
         allowClear: true,
       },
-      rules: z.string().min(1, { message: '请输入用户开户银行账号' }),
+      rules: z.string().min(1, { message: '请输入产品SN号' }),
     },
     {
       component: 'Input',
-      fieldName: 'usersphone',
-      label: '用户手机号',
+      fieldName: 'productspm',
+      label: '品目',
       componentProps: {
-        placeholder: '请输入用户手机号',
+        placeholder: '请输入品目',
         allowClear: true,
       },
-      rules: z.string().min(1, { message: '请输入用户手机号' }),
+      rules: z.string().min(1, { message: '请输入品目' }),
     },
     {
       component: 'Input',
-      fieldName: 'usersemail',
-      label: '用户邮箱',
+      fieldName: 'productsfl1',
+      label: '一级分类',
       componentProps: {
-        placeholder: '请输入用户邮箱',
+        placeholder: '请输入一级分类',
         allowClear: true,
       },
-      rules: z.string().min(1, { message: '请输入用户邮箱' }),
+      rules: z.string().min(1, { message: '请输入一级分类' }),
     },
     {
       component: 'Input',
-      fieldName: 'usersaddress',
-      label: '用户地址',
+      fieldName: 'productsfl2',
+      label: '二级分类',
       componentProps: {
-        placeholder: '请输入用户地址',
+        placeholder: '请输入二级分类',
         allowClear: true,
       },
-      rules: z.string().min(1, { message: '请输入用户地址' }),
+      rules: z.string().min(1, { message: '请输入二级分类' }),
     },
     {
       component: 'Input',
-      fieldName: 'userscontactphone',
-      label: '用户联系手机号',
+      fieldName: 'productsfdmc',
+      label: '分档名称',
       componentProps: {
-        placeholder: '请输入用户联系手机号',
+        placeholder: '请输入分档名称',
         allowClear: true,
       },
-      rules: z.string().min(1, { message: '请输入用户联系手机号' }),
+      rules: z.string().min(1, { message: '请输入分档名称' }),
     },
     {
       component: 'Input',
-      fieldName: 'userscontactemail',
-      label: '用户联系邮箱',
+      fieldName: 'productsfdbh',
+      label: '分档编号',
       componentProps: {
-        placeholder: '请输入用户联系邮箱',
+        placeholder: '请输入分档编号',
         allowClear: true,
       },
-      rules: z.string().min(1, { message: '请输入用户联系邮箱' }),
+      rules: z.string().min(1, { message: '请输入分档编号' }),
+    },
+    {
+      component: 'InputNumber',
+      fieldName: 'productszybt',
+      label: '中央补贴金额',
+      componentProps: {
+        placeholder: '请输入中央补贴金额',
+        min: 0,
+        precision: 2,
+      },
+      rules: z.number().min(0, { message: '请输入正确的中央补贴金额' }),
+    },
+    {
+      component: 'InputNumber',
+      fieldName: 'productstsxzybt',
+      label: '特殊县中央补贴金额',
+      componentProps: {
+        placeholder: '请输入特殊县中央补贴金额',
+        min: 0,
+        precision: 2,
+      },
+      rules: z.number().min(0, { message: '请输入正确的特殊县中央补贴金额' }),
     },
     {
       component: 'Input',
-      fieldName: 'userscontactaddress',
-      label: '用户联系地址',
+      fieldName: 'productsjjlx',
+      label: '机具类型',
       componentProps: {
-        placeholder: '请输入用户联系地址',
+        placeholder: '请输入机具类型',
         allowClear: true,
       },
-      rules: z.string().min(1, { message: '请输入用户联系地址' }),
+      rules: z.string().min(1, { message: '请输入机具类型' }),
     },
   ],
 });
 
 const [Modal, modalApi] = useVbenModal({
+  class: 'w-7/12',
   onCancel() {
     modalApi.close();
   },
@@ -156,23 +199,47 @@ const [Modal, modalApi] = useVbenModal({
       return;
     }
 
-    modalApi.close();
-    // const values = await baseFormApi.getValues();
+    try {
+      // 调用新增或编辑接口
+      const apiMap = {
+        create: () => addProductApi(validate.values as ProductEntity),
+        edit: () =>
+          editProductApi({
+            ...validate.values,
+            'productsid.value': data.value.row.productsid,
+          } 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 getProductDetailApi({
+          productsid: data.value.row.productsid,
         });
 
         baseFormApi.setValues(detailData);

+ 48 - 41
apps/web-ele/src/views/product-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 { getProductListApi } from '#/api/product-manage';
 import { $t } from '#/locales';
 
-import CustomerForm from './form.vue';
+import ProductForm 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: 'productsname',
+      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,37 @@ 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 getProductListApi({
+          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: 'productsname' },
+    { title: '产品类别', field: 'productscategory' },
+    { title: '产品原价', field: 'productsprice' },
+    { title: '产品型号', field: 'productsmodel' },
+    { title: '产品sn号', field: 'productssn' },
+    { title: '品目', field: 'productspm' },
+    { title: '一级分类', field: 'productsfl1' },
+    { title: '二级分类', field: 'productsfl2' },
+    { title: '分档名称', field: 'productsfdmc' },
+    { title: '分档编号', field: 'productsfdbh' },
+    { title: '中央补贴金额', field: 'productszybt', formatter: formatMoney },
+    {
+      title: '特殊县中央补贴金额',
+      field: 'productstsxzybt',
+      formatter: formatMoney,
+      width: 150,
+    },
+    { title: '机具类型', field: 'productsjjlx' },
+    { title: '创建时间', field: 'productsdate' },
     {
       title: '操作',
       field: 'action',
@@ -95,35 +95,42 @@ 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: ProductForm,
 });
 
 /* 创建 */
 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 formatMoney(row: any) {
+  return row.cellValue ? row.cellValue.toFixed(2) : '0.00';
+}
+
+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 +149,6 @@ function handleDetail(row: any) {
         />
       </template>
     </Grid>
-    <Modal />
+    <Modal @finish="handleFinish" />
   </Page>
 </template>

+ 0 - 0
apps/web-ele/src/views/merchant-manage/form.vue → apps/web-ele/src/views/scqy-manage/form.vue


+ 0 - 0
apps/web-ele/src/views/supplier-manage/index.vue → apps/web-ele/src/views/scqy-manage/index.vue


+ 0 - 0
apps/web-ele/src/views/supplier-manage/form.vue → apps/web-ele/src/views/subsidy-manage/form.vue


+ 0 - 0
apps/web-ele/src/views/merchant-manage/index.vue → apps/web-ele/src/views/subsidy-manage/index.vue


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

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

+ 62 - 0
packages/types/src/product.ts

@@ -0,0 +1,62 @@
+/** 产品信息*/
+// CREATE TABLE `products` (
+//   `productsid` varchar(50) NOT NULL COMMENT '产品id',
+//   `productsname` varchar(50) DEFAULT NULL COMMENT '产品名称',
+//   `productscategory` varchar(50) DEFAULT NULL COMMENT '产品类别(耕、种、管、收、运、烘等)',
+//   `productsprice` decimal(10,2) DEFAULT NULL COMMENT '产品原价',
+//   `productsmodel` varchar(50) DEFAULT NULL COMMENT '产品型号',
+//   `productssn` varchar(50) DEFAULT NULL COMMENT '产品sn号',
+//   `productsmerchantid` varchar(50) DEFAULT NULL COMMENT '关联渠道商ID',
+//   `productsdate` datetime DEFAULT NULL COMMENT '创建时间',
+//   `productsscqyid` varchar(50) DEFAULT NULL COMMENT '关联生产企业id',
+//   `productsfl1` varchar(50) DEFAULT NULL COMMENT '产品一级分类',
+//   `productsfl2` varchar(50) DEFAULT NULL COMMENT '产品二级分类',
+//   `productspm` varchar(50) DEFAULT NULL COMMENT '品目',
+//   `productsfdmc` varchar(50) DEFAULT NULL COMMENT '分档名称',
+//   `productsfdbh` varchar(50) DEFAULT NULL COMMENT '分档编号',
+//   `productszybt` decimal(10,2) DEFAULT NULL COMMENT '中央补贴金额',
+//   `productstsxzybt` decimal(10,2) DEFAULT NULL COMMENT '特殊县中央补贴金额',
+//   `productsjjlx` varchar(50) DEFAULT NULL COMMENT '机具类型',
+//   PRIMARY KEY (`productsid`),
+//   KEY `productsmerchantid` (`productsmerchantid`),
+//   CONSTRAINT `productsmerchantid` FOREIGN KEY (`productsmerchantid`) REFERENCES `users` (`usersid`) ON UPDATE NO ACTION
+// ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='产品信息';
+
+interface ProductEntity {
+  /** 产品id */
+  productsid: string;
+  /** 产品名称 */
+  productsname: string;
+  /** 产品类别 */
+  productscategory: string;
+  /** 产品原价 */
+  productsprice: number;
+  /** 产品型号 */
+  productsmodel: string;
+  /** 产品sn号 */
+  productssn: string;
+  /** 关联渠道商ID */
+  productsmerchantid: string;
+  /** 创建时间 */
+  productsdate: string;
+  /** 关联生产企业id */
+  productsscqyid: string;
+  /** 产品一级分类 */
+  productsfl1: string;
+  /** 产品二级分类 */
+  productsfl2: string;
+  /** 品目 */
+  productspm: string;
+  /** 分档名称 */
+  productsfdmc: string;
+  /** 分档编号 */
+  productsfdbh: string;
+  /** 中央补贴金额 */
+  productszybt: number;
+  /** 特殊县中央补贴金额 */
+  productstsxzybt: number;
+  /** 机具类型 */
+  productsjjlx: string;
+}
+
+export type { ProductEntity };

+ 17 - 2
packages/types/src/user.ts

@@ -27,28 +27,43 @@ interface UserInfo extends BasicUserInfo {
 //   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,userstype';
-
 /** 用户认证状态 */
 type UserAuthStatusType = 0 | 1;
 
 interface CustomerEntity {
+  /** 用户id */
   usersid: number;
+  /** 用户名称 */
   usersname: string;
+  /** 用户类型 */
   userstype: string;
+  /** 用户性质 */
   usersnature: number;
+  /** 用户关联上级id */
   userssuperiorid: string;
+  /** 用户证件号码 */
   usersidcardnumber: string;
+  /** 用户开户银行名称 */
   usersbankname: string;
+  /** 用户开户银行账号 */
   usersbanknumber: string;
+  /** 用户手机号 */
   usersphone: string;
+  /** 用户邮箱 */
   usersemail: string;
+  /** 用户地址 */
   usersaddress: string;
+  /** 用户联系手机号 */
   userscontactphone: string;
+  /** 用户联系邮箱 */
   userscontactemail: string;
+  /** 用户联系地址 */
   userscontactaddress: string;
+  /** 用户微信openid */
   usersopenid: string;
+  /** 用户是否实名 */
   usersauthstatus: UserAuthStatusType;
+  /** 用户创建时间 */
   usersdate: string;
 }