diff --git a/apps/web-antd/src/api/license/customer/index.ts b/apps/web-antd/src/api/license/customer/index.ts new file mode 100644 index 0000000..fe8a042 --- /dev/null +++ b/apps/web-antd/src/api/license/customer/index.ts @@ -0,0 +1,54 @@ +import type { PageParam, PageResult } from '@vben/request'; + +import { requestClient } from '#/api/request'; + +export namespace CustomerApi { + /** 客户信息 */ + export interface Customer { + id: number; // 主键 + name?: string; // 客户名称 + code?: string; // 客户编号 + type?: number; // 客户类型 + areaId?: number; // 地区 + contacts?: string; // 联系人 + role: string; // 角色 + phone: string; // 联系电话 + email: string; // 邮箱 + remark: string; // 备注 + } +} + +/** 查询客户分页 */ +export function getCustomerPage(params: PageParam) { + return requestClient.get>( + '/license/customer/page', + { params }, + ); +} + +/** 查询客户详情 */ +export function getCustomer(id: number) { + return requestClient.get( + `/license/customer/get?id=${id}`, + ); +} + +/** 新增客户 */ +export function createCustomer(data: CustomerApi.Customer) { + return requestClient.post('/license/customer/create', data); +} + +/** 修改客户 */ +export function updateCustomer(data: CustomerApi.Customer) { + return requestClient.put('/license/customer/update', data); +} + +/** 删除客户 */ +export function deleteCustomer(id: number) { + return requestClient.delete(`/license/customer/delete?id=${id}`); +} + +/** 导出客户 */ +export function exportCustomer(params: any) { + return requestClient.download('/license/customer/export-excel', params); +} diff --git a/apps/web-antd/src/locales/langs/en-US/menu.json b/apps/web-antd/src/locales/langs/en-US/menu.json index 85a062a..8f4ee17 100644 --- a/apps/web-antd/src/locales/langs/en-US/menu.json +++ b/apps/web-antd/src/locales/langs/en-US/menu.json @@ -81,5 +81,6 @@ "java": "Java Monitoring", "track": "Link Tracking" } - } + }, + "customer": "Customer Management" } diff --git a/apps/web-antd/src/locales/langs/zh-CN/menu.json b/apps/web-antd/src/locales/langs/zh-CN/menu.json index 99ac0b8..b869be7 100644 --- a/apps/web-antd/src/locales/langs/zh-CN/menu.json +++ b/apps/web-antd/src/locales/langs/zh-CN/menu.json @@ -81,5 +81,6 @@ "java": "Java 监控", "track": "链路追踪" } - } + }, + "customer": "客户管理" } diff --git a/apps/web-antd/src/utils/dict.ts b/apps/web-antd/src/utils/dict.ts index ded8ea4..7480127 100644 --- a/apps/web-antd/src/utils/dict.ts +++ b/apps/web-antd/src/utils/dict.ts @@ -219,6 +219,8 @@ enum DICT_TYPE { IOT_RW_TYPE = 'iot_rw_type', // IOT 读写类型 IOT_UNIT_TYPE = 'iot_unit_type', // IOT 单位类型 IOT_VALIDATE_TYPE = 'iot_validate_type', // IOT 数据校验级别 + // ========== LICENSE 模块 ========== + LIC_CUSTOMER_TYPE = 'lic_customer_type', // 客户类型 MEMBER_EXPERIENCE_BIZ_TYPE = 'member_experience_biz_type', // 会员经验业务类型 // ========== Member 会员模块 ========== MEMBER_POINT_BIZ_TYPE = 'member_point_biz_type', // 积分的业务类型 diff --git a/apps/web-antd/src/views/license/customer/data.ts b/apps/web-antd/src/views/license/customer/data.ts new file mode 100644 index 0000000..7cf7255 --- /dev/null +++ b/apps/web-antd/src/views/license/customer/data.ts @@ -0,0 +1,252 @@ +import type { VbenFormSchema } from '#/adapter/form'; +import type { OnActionClickFn, VxeTableGridOptions } from '#/adapter/vxe-table'; +import type { CustomerApi } from '#/api/license/customer'; + +import { useAccess } from '@vben/access'; + +import { DICT_TYPE, getDictOptions, getRangePickerDefaultProps } from '#/utils'; + +const { hasAccessByCodes } = useAccess(); + +/** 新增/修改的表单 */ +export function useFormSchema(): VbenFormSchema[] { + return [ + { + fieldName: 'id', + component: 'Input', + dependencies: { + triggerFields: [''], + show: () => false, + }, + }, + { + fieldName: 'name', + label: '客户名称', + rules: 'required', + component: 'Input', + componentProps: { + placeholder: '请输入客户名称', + }, + }, + { + fieldName: 'code', + label: '客户编号', + rules: 'required', + component: 'Input', + componentProps: { + placeholder: '请输入客户编号', + }, + }, + { + fieldName: 'type', + label: '客户类型', + rules: 'required', + component: 'Select', + componentProps: { + options: getDictOptions(DICT_TYPE.LIC_CUSTOMER_TYPE, 'number'), + placeholder: '请选择客户类型', + }, + }, + { + fieldName: 'areaId', + label: '地区', + rules: 'required', + component: 'Input', + componentProps: { + placeholder: '请输入地区', + }, + }, + { + fieldName: 'contacts', + label: '联系人', + rules: 'required', + component: 'Input', + componentProps: { + placeholder: '请输入联系人', + }, + }, + { + fieldName: 'role', + label: '角色', + component: 'Input', + componentProps: { + placeholder: '请输入角色', + }, + }, + { + fieldName: 'phone', + label: '联系电话', + component: 'Input', + componentProps: { + placeholder: '请输入联系电话', + }, + }, + { + fieldName: 'email', + label: '邮箱', + component: 'Input', + componentProps: { + placeholder: '请输入邮箱', + }, + }, + { + fieldName: 'remark', + label: '备注', + component: 'Textarea', + componentProps: { + placeholder: '请输入备注', + }, + }, + ]; +} + +/** 列表的搜索表单 */ +export function useGridFormSchema(): VbenFormSchema[] { + return [ + { + fieldName: 'name', + label: '客户名称', + component: 'Input', + componentProps: { + allowClear: true, + placeholder: '请输入客户名称', + }, + }, + { + fieldName: 'code', + label: '客户编号', + component: 'Input', + componentProps: { + allowClear: true, + placeholder: '请输入客户编号', + }, + }, + { + fieldName: 'type', + label: '客户类型', + component: 'Select', + componentProps: { + allowClear: true, + options: getDictOptions(DICT_TYPE.LIC_CUSTOMER_TYPE, 'number'), + placeholder: '请选择客户类型', + }, + }, + { + fieldName: 'areaId', + label: '地区', + component: 'Input', + componentProps: { + allowClear: true, + placeholder: '请输入地区', + }, + }, + { + fieldName: 'contacts', + label: '联系人', + component: 'Input', + componentProps: { + allowClear: true, + placeholder: '请输入联系人', + }, + }, + { + fieldName: 'createTime', + label: '创建时间', + component: 'RangePicker', + componentProps: { + ...getRangePickerDefaultProps(), + allowClear: true, + }, + }, + ]; +} + +/** 列表的字段 */ +export function useGridColumns( + onActionClick?: OnActionClickFn, +): VxeTableGridOptions['columns'] { + return [ + { + field: 'name', + title: '客户名称', + minWidth: 120, + }, + { + field: 'code', + title: '客户编号', + minWidth: 120, + }, + { + field: 'type', + title: '客户类型', + minWidth: 120, + cellRender: { + name: 'CellDict', + props: { type: DICT_TYPE.LIC_CUSTOMER_TYPE }, + }, + }, + { + field: 'areaId', + title: '地区', + minWidth: 120, + }, + { + field: 'contacts', + title: '联系人', + minWidth: 120, + }, + { + field: 'role', + title: '角色', + minWidth: 120, + }, + { + field: 'phone', + title: '联系电话', + minWidth: 120, + }, + { + field: 'email', + title: '邮箱', + minWidth: 120, + }, + { + field: 'remark', + title: '备注', + minWidth: 120, + }, + { + field: 'createTime', + title: '创建时间', + minWidth: 120, + formatter: 'formatDateTime', + }, + { + field: 'operation', + title: '操作', + minWidth: 200, + align: 'center', + fixed: 'right', + headerAlign: 'center', + showOverflow: false, + cellRender: { + attrs: { + nameField: 'id', + nameTitle: '客户', + onClick: onActionClick, + }, + name: 'CellOperation', + options: [ + { + code: 'edit', + show: hasAccessByCodes(['license:customer:update']), + }, + { + code: 'delete', + show: hasAccessByCodes(['license:customer:delete']), + }, + ], + }, + }, + ]; +} diff --git a/apps/web-antd/src/views/license/customer/index.vue b/apps/web-antd/src/views/license/customer/index.vue new file mode 100644 index 0000000..265b19c --- /dev/null +++ b/apps/web-antd/src/views/license/customer/index.vue @@ -0,0 +1,145 @@ + + + diff --git a/apps/web-antd/src/views/license/customer/modules/form.vue b/apps/web-antd/src/views/license/customer/modules/form.vue new file mode 100644 index 0000000..a0fedd2 --- /dev/null +++ b/apps/web-antd/src/views/license/customer/modules/form.vue @@ -0,0 +1,89 @@ + + +