From 2c6056c9d08adc722ea892bd461c677ae0296a8a Mon Sep 17 00:00:00 2001 From: kkfluous Date: Fri, 13 Mar 2026 13:43:38 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E5=B0=81=E8=A3=85=20useActionColum?= =?UTF-8?q?n=20=E5=B7=A5=E5=85=B7=E5=87=BD=E6=95=B0=EF=BC=8C=E7=BB=9F?= =?UTF-8?q?=E4=B8=80=E6=93=8D=E4=BD=9C=E5=88=97=E5=AE=BD=E5=BA=A6=E8=AE=A1?= =?UTF-8?q?=E7=AE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 将 11 个页面共 15 处硬编码的操作列配置替换为 useActionColumn() 调用, 根据内联按钮数量和是否有下拉菜单自动计算宽度,解决按钮文字被遮挡问题。 Co-Authored-By: Claude Opus 4.6 --- apps/web-antd/src/utils/table.ts | 23 + .../web-antd/src/views/asset/customer/data.ts | 368 ++++++++++++++++ .../src/views/asset/delivery-order/data.ts | 6 +- .../src/views/asset/delivery-task/data.ts | 169 +++++++ .../views/asset/inspection-template/data.ts | 3 +- apps/web-antd/src/views/asset/parking/data.ts | 280 ++++++++++++ .../web-antd/src/views/asset/supplier/data.ts | 392 +++++++++++++++++ .../src/views/asset/vehicle-model/data.ts | 413 ++++++++++++++++++ .../src/views/asset/vehicle-prepare/data.ts | 217 +++++++++ .../views/asset/vehicle-registration/data.ts | 315 +++++++++++++ .../views/asset/vehicle-replacement/data.ts | 53 ++- 11 files changed, 2216 insertions(+), 23 deletions(-) create mode 100644 apps/web-antd/src/utils/table.ts create mode 100644 apps/web-antd/src/views/asset/customer/data.ts create mode 100644 apps/web-antd/src/views/asset/delivery-task/data.ts create mode 100644 apps/web-antd/src/views/asset/parking/data.ts create mode 100644 apps/web-antd/src/views/asset/supplier/data.ts create mode 100644 apps/web-antd/src/views/asset/vehicle-model/data.ts create mode 100644 apps/web-antd/src/views/asset/vehicle-prepare/data.ts create mode 100644 apps/web-antd/src/views/asset/vehicle-registration/data.ts diff --git a/apps/web-antd/src/utils/table.ts b/apps/web-antd/src/utils/table.ts new file mode 100644 index 0000000..d73ec8a --- /dev/null +++ b/apps/web-antd/src/utils/table.ts @@ -0,0 +1,23 @@ +import type { VxeTableGridOptions } from '#/adapter/vxe-table'; + +type VxeColumn = NonNullable[number]; + +/** + * 生成操作列配置,根据内联按钮数量和是否有下拉菜单自动计算宽度 + * @param inlineCount 内联按钮数量(最多 3 个) + * @param hasDropdown 是否有"更多"下拉菜单 + * @param slotName 插槽名称,默认 'actions' + */ +export function useActionColumn( + inlineCount: number, + hasDropdown = false, + slotName = 'actions', +): VxeColumn { + const width = Math.max(80, inlineCount * 60 + (hasDropdown ? 60 : 0)); + return { + title: '操作', + width, + fixed: 'right', + slots: { default: slotName }, + }; +} diff --git a/apps/web-antd/src/views/asset/customer/data.ts b/apps/web-antd/src/views/asset/customer/data.ts new file mode 100644 index 0000000..79f2abc --- /dev/null +++ b/apps/web-antd/src/views/asset/customer/data.ts @@ -0,0 +1,368 @@ +import type { VbenFormSchema } from '#/adapter/form'; +import type { VxeTableGridOptions } from '#/adapter/vxe-table'; +import type { AssetCustomerApi } from '#/api/asset/customer'; + +import { z } from '#/adapter/form'; +import { useActionColumn } from '#/utils/table'; + +/** 新增/修改的表单 - 基本信息 */ +export function useBasicFormSchema(): VbenFormSchema[] { + return [ + { + component: 'Input', + fieldName: 'id', + dependencies: { + triggerFields: [''], + show: () => false, + }, + }, + { + fieldName: 'customerCode', + label: '客户编码', + component: 'Input', + componentProps: { + placeholder: '请输入客户编码', + }, + rules: z.string().min(1, { message: '请输入客户编码' }), + }, + { + fieldName: 'coopStatus', + label: '合作状态', + component: 'Select', + componentProps: { + placeholder: '请选择合作状态', + options: [ + { label: '已合作', value: '已合作' }, + { label: '终止合作', value: '终止合作' }, + { label: '洽谈中', value: '洽谈中' }, + { label: '合约过期', value: '合约过期' }, + ], + }, + rules: z.string().min(1, { message: '请选择合作状态' }), + }, + { + fieldName: 'customerName', + label: '客户名称', + component: 'Input', + componentProps: { + placeholder: '请输入客户名称', + }, + rules: z.string().min(1, { message: '请输入客户名称' }), + }, + { + fieldName: 'province', + label: '省份', + component: 'Input', + componentProps: { + placeholder: '请输入省份', + }, + rules: z.string().min(1, { message: '请输入省份' }), + }, + { + fieldName: 'city', + label: '城市', + component: 'Input', + componentProps: { + placeholder: '请输入城市', + }, + rules: z.string().min(1, { message: '请输入城市' }), + }, + { + fieldName: 'address', + label: '详细地址', + component: 'Input', + componentProps: { + placeholder: '请输入详细地址', + }, + rules: z.string().min(1, { message: '请输入详细地址' }), + }, + { + fieldName: 'region', + label: '区域', + component: 'Select', + componentProps: { + placeholder: '请选择区域', + options: [ + { label: '华北', value: '华北' }, + { label: '华东', value: '华东' }, + { label: '华南', value: '华南' }, + { label: '华中', value: '华中' }, + { label: '东北', value: '东北' }, + { label: '西南', value: '西南' }, + { label: '西北', value: '西北' }, + ], + }, + }, + { + fieldName: 'contact', + label: '联系人', + component: 'Input', + componentProps: { + placeholder: '请输入联系人', + }, + rules: z.string().min(1, { message: '请输入联系人' }), + }, + { + fieldName: 'contactMobile', + label: '联系手机', + component: 'Input', + componentProps: { + placeholder: '请输入联系手机', + }, + rules: z + .string() + .min(1, { message: '请输入联系手机' }) + .regex(/^1[3-9]\d{9}$/, { message: '请输入正确的手机号' }), + }, + { + fieldName: 'contactPhone', + label: '联系电话', + component: 'Input', + componentProps: { + placeholder: '请输入联系电话', + }, + }, + { + fieldName: 'email', + label: '邮箱', + component: 'Input', + componentProps: { + placeholder: '请输入邮箱', + }, + }, + { + fieldName: 'creditCodeOrId', + label: '统一社会信用代码/身份证', + component: 'Input', + componentProps: { + placeholder: '请输入统一社会信用代码或身份证号', + }, + rules: z.string().min(1, { message: '请输入统一社会信用代码或身份证号' }), + }, + { + fieldName: 'businessManagers', + label: '业务负责人', + component: 'Select', + componentProps: { + placeholder: '请输入业务负责人', + mode: 'tags', + }, + rules: z.array(z.string()).min(1, { message: '请输入业务负责人' }), + }, + { + fieldName: 'remark', + label: '备注', + component: 'Textarea', + componentProps: { + placeholder: '请输入备注', + rows: 3, + }, + }, + ]; +} + +/** 新增/修改的表单 - 开票信息 */ +export function useInvoiceFormSchema(): VbenFormSchema[] { + return [ + { + fieldName: 'taxId', + label: '税号', + component: 'Input', + componentProps: { + placeholder: '请输入税号', + }, + }, + { + fieldName: 'invoiceAddress', + label: '开票地址', + component: 'Input', + componentProps: { + placeholder: '请输入开票地址', + }, + }, + { + fieldName: 'invoicePhone', + label: '开票电话', + component: 'Input', + componentProps: { + placeholder: '请输入开票电话', + }, + }, + { + fieldName: 'account', + label: '银行账号', + component: 'Input', + componentProps: { + placeholder: '请输入银行账号', + }, + }, + { + fieldName: 'openingBank', + label: '开户行', + component: 'Input', + componentProps: { + placeholder: '请输入开户行', + }, + }, + { + fieldName: 'mailingAddress', + label: '邮寄地址', + component: 'Input', + componentProps: { + placeholder: '请输入邮寄地址', + }, + }, + ]; +} + +/** 搜索表单 */ +export function useGridFormSchema(): VbenFormSchema[] { + return [ + { + fieldName: 'customerCode', + label: '客户编码', + component: 'Input', + componentProps: { + placeholder: '请输入客户编码', + }, + }, + { + fieldName: 'customerName', + label: '客户名称', + component: 'Input', + componentProps: { + placeholder: '请输入客户名称', + }, + }, + { + fieldName: 'coopStatus', + label: '合作状态', + component: 'Select', + componentProps: { + placeholder: '请选择合作状态', + mode: 'multiple', + options: [ + { label: '已合作', value: '已合作' }, + { label: '终止合作', value: '终止合作' }, + { label: '洽谈中', value: '洽谈中' }, + { label: '合约过期', value: '合约过期' }, + ], + }, + }, + { + fieldName: 'region', + label: '区域', + component: 'Select', + componentProps: { + placeholder: '请选择区域', + mode: 'multiple', + options: [ + { label: '华北', value: '华北' }, + { label: '华东', value: '华东' }, + { label: '华南', value: '华南' }, + { label: '华中', value: '华中' }, + { label: '东北', value: '东北' }, + { label: '西南', value: '西南' }, + { label: '西北', value: '西北' }, + ], + }, + }, + { + fieldName: 'city', + label: '城市', + component: 'Input', + componentProps: { + placeholder: '请输入城市', + }, + }, + ]; +} + +/** 表格列配置 */ +export function useGridColumns(): VxeTableGridOptions['columns'] { + return [ + { type: 'checkbox', width: 60, fixed: 'left' }, + { + field: 'customerCode', + title: '客户编码', + minWidth: 120, + fixed: 'left', + }, + { + field: 'coopStatus', + title: '合作状态', + minWidth: 100, + align: 'center', + }, + { + field: 'customerName', + title: '客户名称', + minWidth: 200, + }, + { + field: 'region', + title: '区域', + minWidth: 80, + align: 'center', + }, + { + field: 'city', + title: '城市', + minWidth: 100, + }, + { + field: 'address', + title: '地址', + minWidth: 200, + }, + { + field: 'contact', + title: '联系人', + minWidth: 100, + }, + { + field: 'contactMobile', + title: '联系手机', + minWidth: 120, + }, + { + field: 'contactPhone', + title: '联系电话', + minWidth: 120, + }, + { + field: 'email', + title: '邮箱', + minWidth: 150, + }, + { + field: 'creditCodeOrId', + title: '统一社会信用代码/身份证', + minWidth: 180, + }, + { + field: 'businessManagers', + title: '业务负责人', + minWidth: 120, + formatter: ({ cellValue }: { cellValue: string[] }) => + Array.isArray(cellValue) ? cellValue.join(', ') : cellValue || '', + }, + { + field: 'remark', + title: '备注', + minWidth: 150, + }, + { + field: 'creator', + title: '创建人', + minWidth: 100, + }, + { + field: 'createTime', + title: '创建时间', + minWidth: 180, + formatter: 'formatDateTime', + }, + useActionColumn(3), + ]; +} diff --git a/apps/web-antd/src/views/asset/delivery-order/data.ts b/apps/web-antd/src/views/asset/delivery-order/data.ts index 41a2a94..22d58c7 100644 --- a/apps/web-antd/src/views/asset/delivery-order/data.ts +++ b/apps/web-antd/src/views/asset/delivery-order/data.ts @@ -3,6 +3,7 @@ import type { VxeTableGridOptions } from '#/adapter/vxe-table'; import { z } from '#/adapter/form'; import { getRangePickerDefaultProps } from '#/utils'; +import { useActionColumn } from '#/utils/table'; // ========== 新增/编辑表单 ========== export function useFormSchema(): VbenFormSchema[] { @@ -37,6 +38,7 @@ export function useFormSchema(): VbenFormSchema[] { componentProps: { placeholder: '请选择交车日期', showTime: true, + format: 'YYYY-MM-DD HH:mm:ss', valueFormat: 'YYYY-MM-DD HH:mm:ss', style: { width: '100%' }, }, @@ -138,7 +140,7 @@ export function usePendingColumns(): VxeTableGridOptions['columns'] { { field: 'vehicleCount', title: '交车数量', minWidth: 100, align: 'center' }, { field: 'deliveryRegion', title: '交车区域', minWidth: 120 }, { field: 'deliveryLocation', title: '交车地点', minWidth: 150 }, - { title: '操作', width: 160, fixed: 'right', slots: { default: 'actions' } }, + useActionColumn(3), ]; } @@ -164,7 +166,7 @@ export function useHistoryColumns(): VxeTableGridOptions['columns'] { { field: 'vehicleCount', title: '交车数量', minWidth: 100, align: 'center' }, { field: 'deliveryRegion', title: '交车区域', minWidth: 120 }, { field: 'deliveryLocation', title: '交车地点', minWidth: 150 }, - { title: '操作', width: 100, fixed: 'right', slots: { default: 'actions' } }, + useActionColumn(3, true), ]; } diff --git a/apps/web-antd/src/views/asset/delivery-task/data.ts b/apps/web-antd/src/views/asset/delivery-task/data.ts new file mode 100644 index 0000000..a47aaff --- /dev/null +++ b/apps/web-antd/src/views/asset/delivery-task/data.ts @@ -0,0 +1,169 @@ +import type { VbenFormSchema } from '#/adapter/form'; +import type { VxeTableGridOptions } from '#/adapter/vxe-table'; + +import { z } from '#/adapter/form'; +import { useActionColumn } from '#/utils/table'; + +// ========== 新增/编辑表单 ========== +export function useFormSchema(): VbenFormSchema[] { + return [ + { + component: 'Input', + fieldName: 'id', + dependencies: { triggerFields: [''], show: () => false }, + }, + { + fieldName: 'contractId', + label: '选择项目名称', + component: 'ApiSelect', + componentProps: { + placeholder: '请选择或输入项目名称', + api: () => + import('#/api/asset/contract').then((m) => + m.getSimpleContractList(), + ), + labelField: 'projectName', + valueField: 'id', + showSearch: true, + filterOption: (input: string, option: any) => + (option?.label ?? '').toLowerCase().includes(input.toLowerCase()), + }, + rules: z.number().min(1, { message: '请选择项目名称' }), + }, + { + fieldName: 'contractCode', + label: '合同编码', + component: 'Input', + componentProps: { placeholder: '选择项目后自动填充', disabled: true }, + }, + { + fieldName: 'customerName', + label: '客户名称', + component: 'Input', + componentProps: { placeholder: '选择项目后自动填充', disabled: true }, + }, + { + fieldName: 'deliveryRegion', + label: '交车区域', + component: 'Input', + componentProps: { placeholder: '选择项目后自动填充', disabled: true }, + }, + { + fieldName: 'deliveryLocation', + label: '交车地点', + component: 'Input', + componentProps: { placeholder: '选择项目后自动填充', disabled: true }, + }, + { + fieldName: 'expectedDeliveryDateStart', + label: '预计交车开始日期', + component: 'DatePicker', + componentProps: { + placeholder: '请选择日期', + format: 'YYYY-MM-DD', + valueFormat: 'YYYY-MM-DD', + }, + rules: 'required', + }, + { + fieldName: 'expectedDeliveryDateEnd', + label: '预计交车结束日期', + component: 'DatePicker', + componentProps: { + placeholder: '请选择日期(可选)', + format: 'YYYY-MM-DD', + valueFormat: 'YYYY-MM-DD', + }, + }, + { + fieldName: 'billingStartDate', + label: '开始计费日期', + component: 'DatePicker', + componentProps: { + placeholder: '请选择开始计费日期', + format: 'YYYY-MM-DD', + valueFormat: 'YYYY-MM-DD', + }, + rules: 'required', + }, + { + fieldName: 'needReturn', + label: '已交车辆是否需要还车', + component: 'Checkbox', + renderComponentContent: () => ({ default: () => '不需要还车' }), + }, + ]; +} + +// ========== 搜索表单 ========== +export function useGridFormSchema(): VbenFormSchema[] { + return [ + { + fieldName: 'taskCode', + label: '交车任务编码', + component: 'Input', + componentProps: { placeholder: '请输入交车任务编码' }, + }, + { + fieldName: 'contractCode', + label: '合同编码', + component: 'Input', + componentProps: { placeholder: '请输入合同编码' }, + }, + { + fieldName: 'customerName', + label: '客户名称', + component: 'Input', + componentProps: { placeholder: '请输入客户名称' }, + }, + ]; +} + +// ========== 主表列配置(按合同分组) ========== +export function useGridColumns(): VxeTableGridOptions['columns'] { + return [ + { type: 'expand', width: 60, fixed: 'left' }, + { field: 'contractCode', title: '合同编码', minWidth: 220, fixed: 'left' }, + { field: 'projectName', title: '项目名称', minWidth: 150 }, + { field: 'customerName', title: '客户名称', minWidth: 150 }, + { field: 'businessDeptName', title: '业务部门', minWidth: 120 }, + { field: 'businessManagerName', title: '业务负责人', minWidth: 100 }, + { field: 'startDate', title: '合同生效日期', minWidth: 120 }, + { field: 'endDate', title: '合同结束日期', minWidth: 120 }, + useActionColumn(1), + ]; +} + +// ========== 子表列配置(交车任务明细) ========== +export function useSubGridColumns(): VxeTableGridOptions['columns'] { + return [ + { field: 'taskCode', title: '交车任务编码', minWidth: 260 }, + { + field: 'taskStatus', + title: '任务状态', + minWidth: 100, + formatter: ({ cellValue }: { cellValue: number }) => cellValue === 1 ? '挂起' : '激活', + }, + { + field: 'deliveryStatus', + title: '交车状态', + minWidth: 100, + formatter: ({ cellValue }: { cellValue: number }) => cellValue === 1 ? '已交车' : '未交车', + }, + { + field: 'expectedDeliveryDateStart', + title: '预计交车日期', + minWidth: 200, + formatter: ({ row }: { row: any }) => { + const start = row.expectedDeliveryDateStart || ''; + const end = row.expectedDeliveryDateEnd || ''; + return end ? `${start} 至 ${end}` : start; + }, + }, + { field: 'vehicleCount', title: '交车数量', minWidth: 100, align: 'center' }, + { field: 'billingStartDate', title: '开始计费日期', minWidth: 120 }, + { field: 'creator', title: '创建人', minWidth: 100 }, + { field: 'createTime', title: '创建时间', minWidth: 120, formatter: 'formatDateTime' }, + useActionColumn(3, true, 'subActions'), + ]; +} diff --git a/apps/web-antd/src/views/asset/inspection-template/data.ts b/apps/web-antd/src/views/asset/inspection-template/data.ts index ddd02ec..a612e10 100644 --- a/apps/web-antd/src/views/asset/inspection-template/data.ts +++ b/apps/web-antd/src/views/asset/inspection-template/data.ts @@ -2,6 +2,7 @@ import type { VbenFormSchema } from '#/adapter/form'; import type { VxeTableGridOptions } from '#/adapter/vxe-table'; import { z } from '#/adapter/form'; +import { useActionColumn } from '#/utils/table'; export const BIZ_TYPE_OPTIONS = [ { label: '备车', value: 1 }, @@ -77,7 +78,7 @@ export function useGridColumns(): VxeTableGridOptions['columns'] { }, { field: 'remark', title: '备注', minWidth: 150 }, { field: 'createTime', title: '创建时间', minWidth: 180, formatter: 'formatDateTime' }, - { title: '操作', width: 160, fixed: 'right', slots: { default: 'actions' } }, + useActionColumn(3), ]; } diff --git a/apps/web-antd/src/views/asset/parking/data.ts b/apps/web-antd/src/views/asset/parking/data.ts new file mode 100644 index 0000000..0ad187d --- /dev/null +++ b/apps/web-antd/src/views/asset/parking/data.ts @@ -0,0 +1,280 @@ +import type { VbenFormSchema } from '#/adapter/form'; +import type { VxeTableGridOptions } from '#/adapter/vxe-table'; +import type { AssetParkingApi } from '#/api/asset/parking'; + +import { $t } from '@vben/locales'; +import { useActionColumn } from '#/utils/table'; + +import { z } from '#/adapter/form'; +import { getRangePickerDefaultProps } from '#/utils'; + +/** 新增/修改的表单 */ +export function useFormSchema(): VbenFormSchema[] { + return [ + { + component: 'Input', + fieldName: 'id', + dependencies: { + triggerFields: [''], + show: () => false, + }, + }, + { + fieldName: 'name', + label: '停车场名称', + component: 'Input', + componentProps: { + placeholder: '请输入停车场名称', + }, + rules: z.string().min(1, { message: '请输入停车场名称' }), + }, + { + fieldName: 'capacity', + label: '容量', + component: 'InputNumber', + componentProps: { + placeholder: '请输入容量', + min: 1, + style: { width: '100%' }, + }, + rules: z.number().min(1, { message: '容量必须大于等于1' }), + }, + { + fieldName: 'province', + label: '省份', + component: 'Input', + componentProps: { + placeholder: '请输入省份', + }, + rules: z.string().min(1, { message: '请输入省份' }), + }, + { + fieldName: 'city', + label: '城市', + component: 'Input', + componentProps: { + placeholder: '请输入城市', + }, + rules: z.string().min(1, { message: '请输入城市' }), + }, + { + fieldName: 'address', + label: '地址', + component: 'Input', + componentProps: { + placeholder: '请输入详细地址', + }, + rules: z.string().min(1, { message: '请输入详细地址' }), + }, + { + fieldName: 'managerName', + label: '负责人', + component: 'Input', + componentProps: { + placeholder: '请输入负责人姓名', + }, + rules: z.string().min(1, { message: '请输入负责人姓名' }), + }, + { + fieldName: 'managerPhone', + label: '负责人联系方式', + component: 'Input', + componentProps: { + placeholder: '请输入负责人联系方式', + }, + rules: z.string().min(1, { message: '请输入负责人联系方式' }), + }, + { + fieldName: 'contactName', + label: '停车场联系人', + component: 'Input', + componentProps: { + placeholder: '请输入停车场联系人', + }, + }, + { + fieldName: 'contactPhone', + label: '停车场联系方式', + component: 'Input', + componentProps: { + placeholder: '请输入停车场联系方式', + }, + }, + { + fieldName: 'leaseStartDate', + label: '租赁开始时间', + component: 'DatePicker', + componentProps: { + placeholder: '请选择租赁开始时间', + format: 'YYYY-MM-DD', + valueFormat: 'YYYY-MM-DD', + }, + }, + { + fieldName: 'leaseEndDate', + label: '租赁结束时间', + component: 'DatePicker', + componentProps: { + placeholder: '请选择租赁结束时间', + format: 'YYYY-MM-DD', + valueFormat: 'YYYY-MM-DD', + }, + }, + { + fieldName: 'rentFee', + label: '租金费用(元/月)', + component: 'InputNumber', + componentProps: { + placeholder: '请输入租金费用', + min: 0, + precision: 2, + style: { width: '100%' }, + }, + }, + { + fieldName: 'longitude', + label: '经度', + component: 'Input', + componentProps: { + placeholder: '请输入经度', + }, + }, + { + fieldName: 'latitude', + label: '纬度', + component: 'Input', + componentProps: { + placeholder: '请输入纬度', + }, + }, + ]; +} + +/** 搜索表单 */ +export function useGridFormSchema(): VbenFormSchema[] { + return [ + { + fieldName: 'name', + label: '停车场名称', + component: 'Input', + componentProps: { + placeholder: '请输入停车场名称', + }, + }, + { + fieldName: 'province', + label: '省份', + component: 'Input', + componentProps: { + placeholder: '请输入省份', + }, + }, + { + fieldName: 'city', + label: '城市', + component: 'Input', + componentProps: { + placeholder: '请输入城市', + }, + }, + { + fieldName: 'managerName', + label: '负责人', + component: 'Input', + componentProps: { + placeholder: '请输入负责人', + }, + }, + { + fieldName: 'createTime', + label: '创建时间', + component: 'RangePicker', + componentProps: getRangePickerDefaultProps(), + }, + ]; +} + +/** 表格列配置 */ +export function useGridColumns(): VxeTableGridOptions['columns'] { + return [ + { type: 'checkbox', width: 60, fixed: 'left' }, + { + field: 'name', + title: '停车场名称', + minWidth: 150, + fixed: 'left', + }, + { + field: 'capacity', + title: '容量', + minWidth: 80, + align: 'center', + }, + { + field: 'parkedAmount', + title: '已停车辆数', + minWidth: 100, + align: 'center', + }, + { + field: 'province', + title: '省份', + minWidth: 100, + }, + { + field: 'city', + title: '城市', + minWidth: 100, + }, + { + field: 'address', + title: '地址', + minWidth: 200, + }, + { + field: 'managerName', + title: '负责人', + minWidth: 100, + }, + { + field: 'managerPhone', + title: '负责人联系方式', + minWidth: 120, + }, + { + field: 'contactName', + title: '停车场联系人', + minWidth: 120, + }, + { + field: 'contactPhone', + title: '停车场联系方式', + minWidth: 120, + }, + { + field: 'leaseStartDate', + title: '租赁开始时间', + minWidth: 120, + formatter: 'formatDate', + }, + { + field: 'leaseEndDate', + title: '租赁结束时间', + minWidth: 120, + formatter: 'formatDate', + }, + { + field: 'rentFee', + title: '租金费用(元/月)', + minWidth: 120, + align: 'right', + }, + { + field: 'createTime', + title: '创建时间', + minWidth: 180, + formatter: 'formatDateTime', + }, + useActionColumn(3), + ]; +} diff --git a/apps/web-antd/src/views/asset/supplier/data.ts b/apps/web-antd/src/views/asset/supplier/data.ts new file mode 100644 index 0000000..843129e --- /dev/null +++ b/apps/web-antd/src/views/asset/supplier/data.ts @@ -0,0 +1,392 @@ +import type { VbenFormSchema } from '#/adapter/form'; +import type { VxeTableGridOptions } from '#/adapter/vxe-table'; +import type { AssetSupplierApi } from '#/api/asset/supplier'; + +import { $t } from '@vben/locales'; +import { useActionColumn } from '#/utils/table'; + +import { z } from '#/adapter/form'; +import { getRangePickerDefaultProps } from '#/utils'; + +/** 新增/修改的表单 - 基本信息 */ +export function useBasicFormSchema(): VbenFormSchema[] { + return [ + { + component: 'Input', + fieldName: 'id', + dependencies: { + triggerFields: [''], + show: () => false, + }, + }, + { + fieldName: 'supplierCode', + label: '供应商编码', + component: 'Input', + componentProps: { + placeholder: '请输入供应商编码', + }, + rules: z.string().min(1, { message: '请输入供应商编码' }), + }, + { + fieldName: 'coopStatus', + label: '合作状态', + component: 'Select', + componentProps: { + placeholder: '请选择合作状态', + options: [ + { label: '已合作', value: '已合作' }, + { label: '终止合作', value: '终止合作' }, + { label: '洽谈中', value: '洽谈中' }, + { label: '合约过期', value: '合约过期' }, + ], + }, + rules: z.string().min(1, { message: '请选择合作状态' }), + }, + { + fieldName: 'supplierName', + label: '供应商名称', + component: 'Input', + componentProps: { + placeholder: '请输入供应商名称', + }, + rules: z.string().min(1, { message: '请输入供应商名称' }), + }, + { + fieldName: 'type', + label: '供应商类型', + component: 'Select', + componentProps: { + placeholder: '请选择供应商类型', + options: [ + { label: '备件供应商', value: '备件供应商' }, + { label: '保险公司', value: '保险公司' }, + { label: '加氢站', value: '加氢站' }, + { label: '充电站', value: '充电站' }, + { label: '维修站', value: '维修站' }, + { label: '救援车队', value: '救援车队' }, + { label: '整车厂', value: '整车厂' }, + { label: '其他', value: '其他' }, + ], + }, + rules: z.string().min(1, { message: '请选择供应商类型' }), + }, + { + fieldName: 'province', + label: '省份', + component: 'Input', + componentProps: { + placeholder: '请输入省份', + }, + rules: z.string().min(1, { message: '请输入省份' }), + }, + { + fieldName: 'city', + label: '城市', + component: 'Input', + componentProps: { + placeholder: '请输入城市', + }, + rules: z.string().min(1, { message: '请输入城市' }), + }, + { + fieldName: 'address', + label: '详细地址', + component: 'Input', + componentProps: { + placeholder: '请输入详细地址', + }, + rules: z.string().min(1, { message: '请输入详细地址' }), + }, + { + fieldName: 'region', + label: '区域', + component: 'Select', + componentProps: { + placeholder: '请选择区域', + options: [ + { label: '华北', value: '华北' }, + { label: '华东', value: '华东' }, + { label: '华南', value: '华南' }, + { label: '华中', value: '华中' }, + { label: '东北', value: '东北' }, + { label: '西南', value: '西南' }, + { label: '西北', value: '西北' }, + ], + }, + }, + { + fieldName: 'contact', + label: '联系人', + component: 'Input', + componentProps: { + placeholder: '请输入联系人', + }, + }, + { + fieldName: 'contactMobile', + label: '联系手机', + component: 'Input', + componentProps: { + placeholder: '请输入联系手机', + }, + }, + { + fieldName: 'contactPhone', + label: '联系电话', + component: 'Input', + componentProps: { + placeholder: '请输入联系电话', + }, + }, + { + fieldName: 'email', + label: '邮箱', + component: 'Input', + componentProps: { + placeholder: '请输入邮箱', + }, + }, + { + fieldName: 'creditCodeOrId', + label: '统一社会信用代码/身份证', + component: 'Input', + componentProps: { + placeholder: '请输入统一社会信用代码或身份证号', + }, + }, + { + fieldName: 'remark', + label: '备注', + component: 'Textarea', + componentProps: { + placeholder: '请输入备注', + rows: 3, + }, + }, + ]; +} + +/** 新增/修改的表单 - 开票信息 */ +export function useInvoiceFormSchema(): VbenFormSchema[] { + return [ + { + fieldName: 'taxId', + label: '税号', + component: 'Input', + componentProps: { + placeholder: '请输入税号', + }, + }, + { + fieldName: 'invoiceAddress', + label: '开票地址', + component: 'Input', + componentProps: { + placeholder: '请输入开票地址', + }, + }, + { + fieldName: 'invoicePhone', + label: '开票电话', + component: 'Input', + componentProps: { + placeholder: '请输入开票电话', + }, + }, + { + fieldName: 'account', + label: '银行账号', + component: 'Input', + componentProps: { + placeholder: '请输入银行账号', + }, + }, + { + fieldName: 'openingBank', + label: '开户行', + component: 'Input', + componentProps: { + placeholder: '请输入开户行', + }, + }, + { + fieldName: 'mailingAddress', + label: '邮寄地址', + component: 'Input', + componentProps: { + placeholder: '请输入邮寄地址', + }, + }, + ]; +} + +/** 搜索表单 */ +export function useGridFormSchema(): VbenFormSchema[] { + return [ + { + fieldName: 'supplierCode', + label: '供应商编码', + component: 'Input', + componentProps: { + placeholder: '请输入供应商编码', + }, + }, + { + fieldName: 'supplierName', + label: '供应商名称', + component: 'Input', + componentProps: { + placeholder: '请输入供应商名称', + }, + }, + { + fieldName: 'type', + label: '供应商类型', + component: 'Select', + componentProps: { + placeholder: '请选择供应商类型', + mode: 'multiple', + options: [ + { label: '备件供应商', value: '备件供应商' }, + { label: '保险公司', value: '保险公司' }, + { label: '加氢站', value: '加氢站' }, + { label: '充电站', value: '充电站' }, + { label: '维修站', value: '维修站' }, + { label: '救援车队', value: '救援车队' }, + { label: '整车厂', value: '整车厂' }, + { label: '其他', value: '其他' }, + ], + }, + }, + { + fieldName: 'coopStatus', + label: '合作状态', + component: 'Select', + componentProps: { + placeholder: '请选择合作状态', + mode: 'multiple', + options: [ + { label: '已合作', value: '已合作' }, + { label: '终止合作', value: '终止合作' }, + { label: '洽谈中', value: '洽谈中' }, + { label: '合约过期', value: '合约过期' }, + ], + }, + }, + { + fieldName: 'region', + label: '区域', + component: 'Select', + componentProps: { + placeholder: '请选择区域', + mode: 'multiple', + options: [ + { label: '华北', value: '华北' }, + { label: '华东', value: '华东' }, + { label: '华南', value: '华南' }, + { label: '华中', value: '华中' }, + { label: '东北', value: '东北' }, + { label: '西南', value: '西南' }, + { label: '西北', value: '西北' }, + ], + }, + }, + { + fieldName: 'createTime', + label: '创建时间', + component: 'RangePicker', + componentProps: getRangePickerDefaultProps(), + }, + ]; +} + +/** 表格列配置 */ +export function useGridColumns(): VxeTableGridOptions['columns'] { + return [ + { type: 'checkbox', width: 60, fixed: 'left' }, + { + field: 'supplierCode', + title: '供应商编码', + minWidth: 120, + fixed: 'left', + }, + { + field: 'supplierName', + title: '供应商名称', + minWidth: 180, + }, + { + field: 'type', + title: '供应商类型', + minWidth: 120, + }, + { + field: 'coopStatus', + title: '合作状态', + minWidth: 100, + }, + { + field: 'region', + title: '区域', + minWidth: 80, + }, + { + field: 'province', + title: '省份', + minWidth: 100, + }, + { + field: 'city', + title: '城市', + minWidth: 100, + }, + { + field: 'address', + title: '地址', + minWidth: 200, + }, + { + field: 'contact', + title: '联系人', + minWidth: 100, + }, + { + field: 'contactMobile', + title: '联系手机', + minWidth: 120, + }, + { + field: 'contactPhone', + title: '联系电话', + minWidth: 120, + }, + { + field: 'email', + title: '邮箱', + minWidth: 150, + }, + { + field: 'creditCodeOrId', + title: '统一社会信用代码', + minWidth: 180, + }, + { + field: 'remark', + title: '备注', + minWidth: 150, + }, + { + field: 'creator', + title: '创建人', + minWidth: 100, + }, + { + field: 'createTime', + title: '创建时间', + minWidth: 180, + formatter: 'formatDateTime', + }, + useActionColumn(3), + ]; +} diff --git a/apps/web-antd/src/views/asset/vehicle-model/data.ts b/apps/web-antd/src/views/asset/vehicle-model/data.ts new file mode 100644 index 0000000..c751b62 --- /dev/null +++ b/apps/web-antd/src/views/asset/vehicle-model/data.ts @@ -0,0 +1,413 @@ +import type { VbenFormSchema } from '#/adapter/form'; +import type { VxeTableGridOptions } from '#/adapter/vxe-table'; +import { z } from '#/adapter/form'; +import { useActionColumn } from '#/utils/table'; + +/** 新增/修改的表单 - 基本信息 */ +export function useBasicFormSchema(): VbenFormSchema[] { + return [ + { + component: 'Input', + fieldName: 'id', + dependencies: { + triggerFields: [''], + show: () => false, + }, + }, + { + fieldName: 'brand', + label: '品牌', + component: 'Input', + componentProps: { + placeholder: '请输入品牌,如:帕力安牌', + }, + rules: z.string().min(1, { message: '请输入品牌' }), + }, + { + fieldName: 'model', + label: '型号', + component: 'Input', + componentProps: { + placeholder: '请输入型号,如:XDQ504LXCFCEV01', + }, + rules: z.string().min(1, { message: '请输入型号' }), + }, + { + fieldName: 'vehicleType', + label: '车辆类型', + component: 'Input', + componentProps: { + placeholder: '请输入车辆类型,如:轻型箱式货车', + }, + rules: z.string().min(1, { message: '请输入车辆类型' }), + }, + { + fieldName: 'modelLabel', + label: '型号标签', + component: 'Input', + componentProps: { + placeholder: '请输入型号标签,如:4.5T冷链车', + }, + rules: z.string().min(1, { message: '请输入型号标签' }), + }, + { + fieldName: 'fuelType', + label: '燃料种类', + component: 'Select', + componentProps: { + placeholder: '请选择燃料种类', + options: [ + { label: '氢', value: '氢' }, + { label: '电', value: '电' }, + { label: '柴油', value: '柴油' }, + { label: '氢电混合', value: '氢电混合' }, + ], + }, + rules: z.string().min(1, { message: '请选择燃料种类' }), + }, + { + fieldName: 'plateColor', + label: '车牌颜色', + component: 'Select', + componentProps: { + placeholder: '请选择车牌颜色', + options: [ + { label: '绿牌', value: '绿牌' }, + { label: '黄牌', value: '黄牌' }, + { label: '黄绿牌', value: '黄绿牌' }, + ], + }, + rules: z.string().min(1, { message: '请选择车牌颜色' }), + }, + ]; +} + +/** 新增/修改的表单 - 车辆尺寸 */ +export function useSizeFormSchema(): VbenFormSchema[] { + return [ + { + fieldName: 'truckSize_x', + label: '车辆长度(mm)', + component: 'Input', + componentProps: { + placeholder: '请输入车辆长度', + }, + }, + { + fieldName: 'truckSize_y', + label: '车辆宽度(mm)', + component: 'Input', + componentProps: { + placeholder: '请输入车辆宽度', + }, + }, + { + fieldName: 'truckSize_z', + label: '车辆高度(mm)', + component: 'Input', + componentProps: { + placeholder: '请输入车辆高度', + }, + }, + { + fieldName: 'tireSize', + label: '轮胎规格', + component: 'Input', + componentProps: { + placeholder: '请输入轮胎规格', + }, + }, + { + fieldName: 'tireNumber', + label: '轮胎数量', + component: 'InputNumber', + componentProps: { + placeholder: '请输入轮胎数量', + min: 1, + style: { width: '100%' }, + }, + }, + ]; +} + +/** 新增/修改的表单 - 电池信息 */ +export function useBatteryFormSchema(): VbenFormSchema[] { + return [ + { + fieldName: 'batteryType', + label: '电池类型', + component: 'Select', + componentProps: { + placeholder: '请选择电池类型', + options: [ + { label: '磷酸铁锂', value: '磷酸铁锂' }, + { label: '三元锂', value: '三元锂' }, + ], + }, + }, + { + fieldName: 'batteryFactory', + label: '电池厂家', + component: 'Input', + componentProps: { + placeholder: '请输入电池厂家', + }, + }, + { + fieldName: 'reserveElectricity', + label: '储电量(kwh)', + component: 'InputNumber', + componentProps: { + placeholder: '请输入储电量', + min: 0, + precision: 2, + style: { width: '100%' }, + }, + }, + { + fieldName: 'electricityMileage', + label: '电续航里程(KM)', + component: 'InputNumber', + componentProps: { + placeholder: '请输入电续航里程', + min: 0, + style: { width: '100%' }, + }, + }, + ]; +} + +/** 新增/修改的表单 - 氢能信息 */ +export function useHydrogenFormSchema(): VbenFormSchema[] { + return [ + { + fieldName: 'hydrogenCapacity', + label: '氢瓶容量(L)', + component: 'InputNumber', + componentProps: { + placeholder: '请输入氢瓶容量', + min: 0, + style: { width: '100%' }, + }, + }, + { + fieldName: 'hydrogenFactory', + label: '供氢系统厂家', + component: 'Input', + componentProps: { + placeholder: '请输入供氢系统厂家', + }, + }, + { + fieldName: 'hydrogenUnit', + label: '仪表盘氢气单位', + component: 'Select', + componentProps: { + placeholder: '请选择氢气单位', + options: [ + { label: '%', value: '%' }, + { label: 'MPa', value: 'MPa' }, + { label: 'Kg', value: 'Kg' }, + ], + }, + }, + { + fieldName: 'hydrogenMileage', + label: '氢续航里程(KM)', + component: 'InputNumber', + componentProps: { + placeholder: '请输入氢续航里程', + min: 0, + style: { width: '100%' }, + }, + }, + ]; +} + +/** 新增/修改的表单 - 其他信息 */ +export function useOtherFormSchema(): VbenFormSchema[] { + return [ + { + fieldName: 'refrigeratorFactory', + label: '冷机厂家', + component: 'Input', + componentProps: { + placeholder: '请输入冷机厂家', + }, + }, + { + fieldName: 'onlineSpreadEnterprise', + label: '电堆厂家', + component: 'Input', + componentProps: { + placeholder: '请输入电堆厂家', + }, + }, + ]; +} + +/** 搜索表单 */ +export function useGridFormSchema(): VbenFormSchema[] { + return [ + { + fieldName: 'brand', + label: '品牌', + component: 'Input', + componentProps: { + placeholder: '请输入品牌', + }, + }, + { + fieldName: 'model', + label: '型号', + component: 'Input', + componentProps: { + placeholder: '请输入型号', + }, + }, + { + fieldName: 'fuelType', + label: '燃料种类', + component: 'Select', + componentProps: { + placeholder: '请选择燃料种类', + allowClear: true, + options: [ + { label: '氢', value: '氢' }, + { label: '电', value: '电' }, + { label: '柴油', value: '柴油' }, + { label: '氢电混合', value: '氢电混合' }, + ], + }, + }, + ]; +} + +/** 表格列配置 */ +export function useGridColumns(): VxeTableGridOptions['columns'] { + return [ + { type: 'checkbox', width: 60, fixed: 'left' }, + { + field: 'brand', + title: '品牌', + minWidth: 120, + fixed: 'left', + }, + { + field: 'model', + title: '型号', + minWidth: 150, + }, + { + field: 'modelLabel', + title: '型号标签', + minWidth: 120, + }, + { + field: 'vehicleType', + title: '车辆类型', + minWidth: 120, + }, + { + field: 'fuelType', + title: '燃料种类', + minWidth: 100, + }, + { + field: 'plateColor', + title: '车牌颜色', + minWidth: 100, + }, + { + field: 'tireNumber', + title: '轮胎数量', + minWidth: 80, + align: 'center', + }, + { + field: 'tireSize', + title: '轮胎规格', + minWidth: 100, + }, + { + field: 'batteryType', + title: '电池类型', + minWidth: 100, + }, + { + field: 'reserveElectricity', + title: '储电量(kWh)', + minWidth: 110, + align: 'right', + }, + { + field: 'hydrogenCapacity', + title: '氢瓶容量(L)', + minWidth: 110, + align: 'right', + }, + { + field: 'electricityMileage', + title: '电续航(KM)', + minWidth: 100, + align: 'right', + }, + { + field: 'hydrogenMileage', + title: '氢续航(KM)', + minWidth: 100, + align: 'right', + }, + { + field: 'createTime', + title: '创建时间', + minWidth: 180, + formatter: 'formatDateTime', + }, + useActionColumn(3), + ]; +} + +/** 维保项目表格列配置 */ +export function useMaintainItemColumns(): VxeTableGridOptions['columns'] { + return [ + { type: 'seq', width: 60, title: '序号' }, + { + field: 'maintainItem', + title: '保养项目名称', + minWidth: 150, + editRender: { name: 'input' }, + }, + { + field: 'kilometerCycle', + title: '保养公里周期(KM)', + minWidth: 150, + editRender: { name: 'input', props: { type: 'number' } }, + }, + { + field: 'timeCycle', + title: '保养时间周期(月)', + minWidth: 150, + editRender: { name: 'input', props: { type: 'number' } }, + }, + { + field: 'hourFee', + title: '工时费(元)', + minWidth: 120, + editRender: { name: 'input', props: { type: 'number' } }, + }, + { + field: 'materialFee', + title: '材料费(元)', + minWidth: 120, + editRender: { name: 'input', props: { type: 'number' } }, + }, + { + field: 'totalFee', + title: '费用合计(元)', + minWidth: 120, + editRender: { name: 'input', props: { type: 'number' } }, + }, + useActionColumn(1, false, 'operate'), + ]; +} diff --git a/apps/web-antd/src/views/asset/vehicle-prepare/data.ts b/apps/web-antd/src/views/asset/vehicle-prepare/data.ts new file mode 100644 index 0000000..6e647b5 --- /dev/null +++ b/apps/web-antd/src/views/asset/vehicle-prepare/data.ts @@ -0,0 +1,217 @@ +import type { VbenFormSchema } from '#/adapter/form'; +import type { VxeTableGridOptions } from '#/adapter/vxe-table'; + +import { z } from '#/adapter/form'; +import { getRangePickerDefaultProps } from '#/utils'; +import { useActionColumn } from '#/utils/table'; + +// ========== 车辆类型选项 ========== +export const VEHICLE_TYPE_OPTIONS = [ + { label: '轻型厢式货车', value: '轻型厢式货车' }, + { label: '重型厢式货车', value: '重型厢式货车' }, + { label: '重型半挂牵引车', value: '重型半挂牵引车' }, + { label: '重型集装箱半挂车', value: '重型集装箱半挂车' }, + { label: '小型普通客车', value: '小型普通客车' }, + { label: '重型平板半挂车', value: '重型平板半挂车' }, + { label: '叉车', value: '叉车' }, + { label: '油车', value: '油车' }, + { label: '观光车', value: '观光车' }, +]; + +// ========== 氢量单位选项 ========== +export const HYDROGEN_UNIT_OPTIONS = [ + { label: '%', value: '%' }, + { label: 'MPa', value: 'MPa' }, + { label: 'kg', value: 'kg' }, +]; + +// ========== 整备类型选项 ========== +export const PREP_TYPE_OPTIONS = [ + { label: '新车整备', value: '新车整备' }, + { label: '日常整备', value: '日常整备' }, + { label: '还车整备', value: '还车整备' }, + { label: '替换车整备', value: '替换车整备' }, +]; + +// ========== 备车检查项 ========== +export const CHECK_CATEGORIES = [ + { + category: '车灯', + items: ['大灯', '转向灯', '小灯', '示廓灯', '刹车灯', '倒车灯', '牌照灯', '防雾灯', '室内灯'], + }, + { + category: '仪表盘', + items: ['氢系统指示', '电控系统指示', '数值清晰准确', '故障报警灯'], + }, + { + category: '驾驶室', + items: [ + '点烟器', '车窗升降', '按键开关', '雨刮器', '内后视镜', + '内/外门把手', '安全带', '空调冷暖风', '仪表盘', '门锁功能', + '手刹', '车钥匙功能', '喇叭', '音响功能', '遮阳板', + '主副驾座椅', '方向盘', '内饰干净整洁', + ], + }, + { + category: '轮胎', + items: ['左前轮', '右前轮', '左后轮', '右后轮'], + type: 'input' as const, + }, + { + category: '液位检查', + items: ['机油', '冷却液', '制动液', '转向助力液'], + }, + { + category: '外观检查', + items: ['车漆', '车身', '挡风玻璃', '后视镜'], + }, + { + category: '车辆外观', + items: ['前保险杠', '后保险杠', '车顶', '底盘'], + }, + { + category: '其他', + items: ['灭火器', '三角警示牌', '急救包'], + }, + { + category: '随车工具', + items: ['千斤顶', '轮胎扳手', '拖车钩'], + }, + { + category: '随车证件', + items: ['行驶证', '保险卡', '年检标志'], + }, + { + category: '整车', + items: ['整车清洁', '整车功能'], + }, + { + category: '燃料电池系统', + items: ['燃料电池状态', '氢气瓶', '氢气管路'], + }, + { + category: '冷机', + items: ['制冷系统', '温控系统'], + }, + { + category: '制动系统', + items: ['制动片', '制动盘', '手刹功能'], + }, +]; + +// ========== 搜索表单 ========== +export function useGridFormSchema(): VbenFormSchema[] { + return [ + { + fieldName: 'completeTime', + label: '备车日期', + component: 'RangePicker', + componentProps: getRangePickerDefaultProps(), + }, + { + fieldName: 'plateNo', + label: '车牌号', + component: 'Input', + componentProps: { placeholder: '请输入车牌号' }, + }, + { + fieldName: 'vehicleType', + label: '车辆类型', + component: 'Select', + componentProps: { + placeholder: '请选择车辆类型', + allowClear: true, + options: VEHICLE_TYPE_OPTIONS, + }, + }, + { + fieldName: 'brand', + label: '品牌', + component: 'Input', + componentProps: { placeholder: '请输入品牌' }, + }, + { + fieldName: 'parkingLot', + label: '停车场', + component: 'Input', + componentProps: { placeholder: '请输入停车场' }, + }, + { + fieldName: 'createTime', + label: '创建时间', + component: 'RangePicker', + componentProps: getRangePickerDefaultProps(), + }, + ]; +} + +// ========== 已完成列表列 ========== +export function useCompletedColumns(): VxeTableGridOptions['columns'] { + return [ + { field: 'completeTime', title: '备车时间', minWidth: 160, formatter: 'formatDateTime' }, + { field: 'creator', title: '备车人', minWidth: 100 }, + { field: 'vehicleType', title: '车辆类型', minWidth: 120 }, + { field: 'brand', title: '品牌', minWidth: 100 }, + { field: 'model', title: '型号', minWidth: 100 }, + { field: 'plateNo', title: '车牌号', minWidth: 120 }, + { field: 'vin', title: '车辆识别代码', minWidth: 180 }, + { field: 'parkingLot', title: '停车场', minWidth: 120 }, + { + field: 'hasBodyAd', + title: '车身广告及放大字', + minWidth: 130, + formatter: ({ cellValue }: { cellValue: boolean }) => cellValue ? '有' : '无', + }, + { + field: 'hasTailLift', + title: '尾板', + minWidth: 80, + formatter: ({ cellValue }: { cellValue: boolean }) => cellValue ? '有' : '无', + }, + { + field: 'spareTireDepth', + title: '备胎胎纹深度', + minWidth: 120, + formatter: ({ cellValue }: { cellValue: number }) => cellValue != null ? `${cellValue}mm` : '', + }, + useActionColumn(1), + ]; +} + +// ========== 待提交列表列 ========== +export function usePendingColumns(): VxeTableGridOptions['columns'] { + return [ + { field: 'createTime', title: '创建时间', minWidth: 160, formatter: 'formatDateTime' }, + { field: 'creator', title: '创建人', minWidth: 100 }, + { field: 'vehicleType', title: '车辆类型', minWidth: 120 }, + { field: 'brand', title: '品牌', minWidth: 100 }, + { field: 'model', title: '型号', minWidth: 100 }, + { field: 'plateNo', title: '车牌号', minWidth: 120 }, + { field: 'vin', title: '车辆识别代码', minWidth: 180 }, + { field: 'parkingLot', title: '停车场', minWidth: 120 }, + { + field: 'hasBodyAd', + title: '车身广告及放大字', + minWidth: 130, + formatter: ({ cellValue }: { cellValue: boolean }) => cellValue ? '有' : '无', + }, + { + field: 'hasTailLift', + title: '尾板', + minWidth: 80, + formatter: ({ cellValue }: { cellValue: boolean }) => cellValue ? '有' : '无', + }, + { + field: 'spareTireDepth', + title: '备胎胎纹深度', + minWidth: 120, + formatter: ({ cellValue }: { cellValue: number }) => cellValue != null ? `${cellValue}mm` : '', + }, + useActionColumn(3, true), + ]; +} + +// ========== 兼容旧引用 ========== +export function useGridColumns(): VxeTableGridOptions['columns'] { + return usePendingColumns(); +} diff --git a/apps/web-antd/src/views/asset/vehicle-registration/data.ts b/apps/web-antd/src/views/asset/vehicle-registration/data.ts new file mode 100644 index 0000000..76900a2 --- /dev/null +++ b/apps/web-antd/src/views/asset/vehicle-registration/data.ts @@ -0,0 +1,315 @@ +import type { VbenFormSchema } from '#/adapter/form'; +import type { VxeTableGridOptions } from '#/adapter/vxe-table'; +import type { AssetVehicleRegistrationApi } from '#/api/asset/vehicle-registration'; + +import { $t } from '@vben/locales'; +import { useActionColumn } from '#/utils/table'; + +import { z } from '#/adapter/form'; +import { getRangePickerDefaultProps } from '#/utils'; + +/** 新增/修改的表单 - 基本信息 */ +export function useBasicFormSchema(): VbenFormSchema[] { + return [ + { + component: 'Input', + fieldName: 'id', + dependencies: { + triggerFields: [''], + show: () => false, + }, + }, + { + fieldName: 'vin', + label: '车辆识别代号(VIN)', + component: 'Input', + componentProps: { + placeholder: '请输入VIN码', + }, + rules: z.string().min(1, { message: '请输入VIN码' }), + }, + { + fieldName: 'plateNo', + label: '车牌号', + component: 'Input', + componentProps: { + placeholder: '请输入车牌号', + }, + rules: z.string().min(1, { message: '请输入车牌号' }), + }, + { + fieldName: 'plateDate', + label: '上牌日期', + component: 'DatePicker', + componentProps: { + placeholder: '请选择上牌日期', + format: 'YYYY-MM-DD', + valueFormat: 'YYYY-MM-DD', + }, + rules: 'required', + }, + { + fieldName: 'operator', + label: '操作员', + component: 'Input', + componentProps: { + placeholder: '请输入操作员', + }, + }, + ]; +} + +/** 新增/修改的表单 - OCR识别信息 */ +export function useOcrFormSchema(): VbenFormSchema[] { + return [ + { + fieldName: 'recognizedBrand', + label: '品牌型号', + component: 'Input', + componentProps: { + placeholder: 'OCR自动识别', + }, + }, + { + fieldName: 'recognizedModel', + label: '车型', + component: 'Input', + componentProps: { + placeholder: 'OCR自动识别', + }, + }, + { + fieldName: 'vehicleType', + label: '车辆类型', + component: 'Input', + componentProps: { + placeholder: 'OCR自动识别', + }, + }, + { + fieldName: 'owner', + label: '所有人', + component: 'Input', + componentProps: { + placeholder: 'OCR自动识别', + }, + }, + { + fieldName: 'useCharacter', + label: '使用性质', + component: 'Input', + componentProps: { + placeholder: 'OCR自动识别', + }, + }, + { + fieldName: 'engineNo', + label: '发动机号码', + component: 'Input', + componentProps: { + placeholder: 'OCR自动识别', + }, + }, + { + fieldName: 'registerDate', + label: '注册日期', + component: 'DatePicker', + componentProps: { + placeholder: 'OCR自动识别', + format: 'YYYY-MM-DD', + valueFormat: 'YYYY-MM-DD', + }, + }, + { + fieldName: 'issueDate', + label: '发证日期', + component: 'DatePicker', + componentProps: { + placeholder: 'OCR自动识别', + format: 'YYYY-MM-DD', + valueFormat: 'YYYY-MM-DD', + }, + }, + { + fieldName: 'inspectionRecord', + label: '检验记录', + component: 'Input', + componentProps: { + placeholder: 'OCR自动识别', + }, + }, + { + fieldName: 'scrapDate', + label: '强制报废期止', + component: 'DatePicker', + componentProps: { + placeholder: 'OCR自动识别', + format: 'YYYY-MM-DD', + valueFormat: 'YYYY-MM-DD', + }, + }, + { + fieldName: 'curbWeight', + label: '整备质量(kg)', + component: 'Input', + componentProps: { + placeholder: 'OCR自动识别', + }, + }, + { + fieldName: 'totalMass', + label: '总质量(kg)', + component: 'Input', + componentProps: { + placeholder: 'OCR自动识别', + }, + }, + { + fieldName: 'approvedPassengerCapacity', + label: '核定载人数', + component: 'Input', + componentProps: { + placeholder: 'OCR自动识别', + }, + }, + ]; +} + +/** 新增/修改的表单 - 其他信息 */ +export function useOtherFormSchema(): VbenFormSchema[] { + return [ + { + fieldName: 'vehicleModelId', + label: '匹配车型', + component: 'ApiSelect', + componentProps: { + placeholder: '请选择车型', + api: () => + import('#/api/asset/vehicle-model').then((m) => + m.getSimpleVehicleModelList(), + ), + labelField: 'modelLabel', + valueField: 'id', + }, + }, + { + fieldName: 'remark', + label: '备注', + component: 'Textarea', + componentProps: { + placeholder: '请输入备注', + rows: 3, + }, + }, + ]; +} + +/** 搜索表单 */ +export function useGridFormSchema(): VbenFormSchema[] { + return [ + { + fieldName: 'vin', + label: 'VIN码', + component: 'Input', + componentProps: { + placeholder: '请输入VIN码', + }, + }, + { + fieldName: 'plateNo', + label: '车牌号', + component: 'Input', + componentProps: { + placeholder: '请输入车牌号', + }, + }, + { + fieldName: 'status', + label: '状态', + component: 'Select', + componentProps: { + placeholder: '请选择状态', + options: [ + { label: '待确认', value: 0 }, + { label: '已确认', value: 1 }, + { label: '已作废', value: 2 }, + ], + }, + }, + { + fieldName: 'plateDate', + label: '上牌日期', + component: 'RangePicker', + componentProps: { + format: 'YYYY-MM-DD', + valueFormat: 'YYYY-MM-DD', + placeholder: ['开始日期', '结束日期'], + }, + }, + { + fieldName: 'createTime', + label: '创建时间', + component: 'RangePicker', + componentProps: getRangePickerDefaultProps(), + }, + ]; +} + +/** 表格列配置 */ +export function useGridColumns(): VxeTableGridOptions['columns'] { + return [ + { type: 'checkbox', width: 50, fixed: 'left' }, + { + field: 'vin', + title: 'VIN码', + width: 180, + fixed: 'left', + }, + { + field: 'plateNo', + title: '车牌号', + width: 120, + }, + { + field: 'plateDate', + title: '上牌日期', + width: 120, + }, + { + field: 'recognizedBrand', + title: '品牌型号', + width: 150, + }, + { + field: 'vehicleType', + title: '车辆类型', + width: 120, + }, + { + field: 'owner', + title: '所有人', + width: 150, + }, + { + field: 'status', + title: '状态', + width: 100, + cellRender: { name: 'CellDict', props: { type: 'tag' } }, + params: { + dictType: 'asset_vehicle_registration_status', + }, + }, + { + field: 'operator', + title: '操作员', + width: 100, + }, + { + field: 'createTime', + title: '创建时间', + width: 160, + formatter: 'formatDateTime', + }, + useActionColumn(3), + ]; +} diff --git a/apps/web-antd/src/views/asset/vehicle-replacement/data.ts b/apps/web-antd/src/views/asset/vehicle-replacement/data.ts index 6159e9d..4a8b6ea 100644 --- a/apps/web-antd/src/views/asset/vehicle-replacement/data.ts +++ b/apps/web-antd/src/views/asset/vehicle-replacement/data.ts @@ -2,6 +2,7 @@ import type { VbenFormSchema } from '#/adapter/form'; import type { VxeTableGridOptions } from '#/adapter/vxe-table'; import { z } from '#/adapter/form'; +import { useActionColumn } from '#/utils/table'; export const REPLACEMENT_TYPE_OPTIONS = [ { label: '临时替换', value: 1 }, @@ -122,12 +123,7 @@ export function useGridColumns(): VxeTableGridOptions['columns'] { minWidth: 180, formatter: 'formatDateTime', }, - { - title: '操作', - width: 280, - fixed: 'right', - slots: { default: 'actions' }, - }, + useActionColumn(3, true), ]; } @@ -168,26 +164,43 @@ export function useFormSchema(): VbenFormSchema[] { filterOption: (input: string, option: any) => (option?.label ?? '').toLowerCase().includes(input.toLowerCase()), }, + rules: z.number({ message: '请选择关联合同' }), }, { fieldName: 'originalVehicleId', - label: '原车辆ID', - component: 'InputNumber', + label: '原车辆', + component: 'ApiSelect', componentProps: { - placeholder: '请输入原车辆ID', - class: 'w-full', + placeholder: '请选择原车辆', + api: () => + import('#/api/asset/vehicle').then((m) => + m.getVehicleSimpleList(), + ), + labelField: 'plateNo', + valueField: 'id', + showSearch: true, + filterOption: (input: string, option: any) => + (option?.label ?? '').toLowerCase().includes(input.toLowerCase()), }, - rules: z.number({ message: '请输入原车辆ID' }), + rules: z.number({ message: '请选择原车辆' }), }, { fieldName: 'newVehicleId', - label: '新车辆ID', - component: 'InputNumber', + label: '新车辆', + component: 'ApiSelect', componentProps: { - placeholder: '请输入新车辆ID', - class: 'w-full', + placeholder: '请选择新车辆', + api: () => + import('#/api/asset/vehicle').then((m) => + m.getVehicleSimpleList(), + ), + labelField: 'plateNo', + valueField: 'id', + showSearch: true, + filterOption: (input: string, option: any) => + (option?.label ?? '').toLowerCase().includes(input.toLowerCase()), }, - rules: z.number({ message: '请输入新车辆ID' }), + rules: z.number({ message: '请选择新车辆' }), }, { fieldName: 'deliveryOrderId', @@ -214,8 +227,8 @@ export function useFormSchema(): VbenFormSchema[] { component: 'DatePicker', componentProps: { placeholder: '请选择预计替换日期', - class: 'w-full', - valueFormat: 'YYYY-MM-DD HH:mm:ss', + format: 'YYYY-MM-DD', + valueFormat: 'YYYY-MM-DD', }, }, { @@ -224,8 +237,8 @@ export function useFormSchema(): VbenFormSchema[] { component: 'DatePicker', componentProps: { placeholder: '请选择预计归还日期', - class: 'w-full', - valueFormat: 'YYYY-MM-DD HH:mm:ss', + format: 'YYYY-MM-DD', + valueFormat: 'YYYY-MM-DD', }, dependencies: { triggerFields: ['replacementType'],