diff --git a/src/api/backend/api/index.ts b/src/api/backend/api/index.ts index 59951c8..eaf51e9 100644 --- a/src/api/backend/api/index.ts +++ b/src/api/backend/api/index.ts @@ -31,6 +31,8 @@ import * as project from './project'; import * as company from './company'; import * as product from './product'; import * as materialsInOut from './materialsInOut'; +import * as vehicleUsage from './vehicleUsage'; + export default { auth, account, @@ -61,4 +63,5 @@ export default { product, materialsInOut, project, + vehicleUsage, }; diff --git a/src/api/backend/api/typings.d.ts b/src/api/backend/api/typings.d.ts index 98789b5..d7e2b29 100644 --- a/src/api/backend/api/typings.d.ts +++ b/src/api/backend/api/typings.d.ts @@ -1656,6 +1656,119 @@ declare namespace API { id: number; }; + // VehicleUsage + type VehicleUsageEntity = { + /** 年度 */ + year: number; + /** 外出使用的车辆Id */ + vechicleId: number; + /** 外出使用的车辆名称(字典) */ + vechicle: DictItemEntity; + /** 申请人 */ + applicant: string; + /** 出行司机 */ + driver: string; + /** 当前车辆里程数(KM) */ + currentMileage: number; + /** 预计出行开始时间 */ + expectedStartDate: Date; + /** 预计出行结束时间 */ + expectedEndDate: Date; + /** 使用事由 */ + purpose: string; + /** 实际回司时间 */ + actualReturnTime: Date; + /** 回城车辆里程数(KM) */ + returnMileage: number; + /** 审核人 */ + reviewer: string; + /** 审核状态:0待审核,1同意,2.不同意(字典) */ + status: number; + /** 备注 */ + remark: string; + /** 附件 */ + files?: StorageInfo[]; + id: number; + createdAt: string; + updatedAt: string; + }; + type VehicleUsageDto = { + /** 年度 */ + year: number; + /** 外出使用的车辆名称(字典) */ + vechicleId: number; + /** 申请人 */ + applicant: string; + /** 出行司机 */ + driver: string; + /** 当前车辆里程数(KM) */ + currentMileage: number; + /** 预计出行开始时间 */ + expectedStartDate: Date; + /** 预计出行结束时间 */ + expectedEndDate: Date; + /** 使用事由 */ + purpose: string; + /** 实际回司时间 */ + actualReturnTime: Date; + /** 回城车辆里程数(KM) */ + returnMileage: number; + /** 审核人 */ + reviewer: string; + /** 审核状态:0待审核,1同意,2.不同意(字典) */ + status: number; + /** 备注 */ + remark: string; + fileIds?: number[]; + }; + type VehicleUsageUpdateParams = { + id: number; + + }; + type VehicleUsageParams = { + page?: number; + pageSize?: number; + field?: string; + order?: 'ASC' | 'DESC'; + _t?: number; + }; + type VehicleUsageInfoParams = { + id: number; + }; + type VehicleUsageUpdateDto = { + /** 年度 */ + year?: number; + /** 外出使用的车辆名称(字典) */ + vechicleId?: number; + /** 申请人 */ + applicant?: string; + /** 出行司机 */ + driver?: string; + /** 当前车辆里程数(KM) */ + currentMileage?: number; + /** 预计出行开始时间 */ + expectedStartDate?: Date; + /** 预计出行结束时间 */ + expectedEndDate?: Date; + /** 使用事由 */ + purpose?: string; + /** 实际回司时间 */ + actualReturnTime?: Date; + /** 回城车辆里程数(KM) */ + returnMileage?: number; + /** 审核人 */ + reviewer?: string; + /** 审核状态:0待审核,1同意,2.不同意(字典) */ + status?: number; + /** 备注 */ + remark?: string; + /** 附件 */ + fileIds?: number[]; + }; + type VehicleUsageDeleteParams = { + id: number; + }; + // Materials In out history type MaterialsInOutUpdateParams = { id: number; diff --git a/src/api/backend/api/vehicleUsage.ts b/src/api/backend/api/vehicleUsage.ts new file mode 100644 index 0000000..79d2294 --- /dev/null +++ b/src/api/backend/api/vehicleUsage.ts @@ -0,0 +1,106 @@ +import { request, type RequestOptions } from '@/utils/request'; + + + +/** 获取车辆使用记录列表 GET /api/vehicle-usage */ +export async function vehicleUsageList(params: API.VehicleUsageParams, options?: RequestOptions) { + return request<{ + items?: API.VehicleUsageEntity[]; + meta?: { + itemCount?: number; + totalItems?: number; + itemsPerPage?: number; + totalPages?: number; + currentPage?: number; + }; + }>('/api/vehicle-usage', { + method: 'GET', + params: { + // page has a default value: 1 + page: '1', + // pageSize has a default value: 10 + pageSize: '10', + + ...params, + }, + ...(options || {}), + }); +} + +/** 新增车辆使用记录 POST /api/vehicle-usage */ +export async function vehicleUsageCreate(body: API.VehicleUsageDto, options?: RequestOptions) { + return request('/api/vehicle-usage', { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + data: body, + ...(options || { successMsg: '创建成功' }), + }); +} + +/** 获取车辆使用记录信息 GET /api/vehicle-usage/${param0} */ +export async function vehicleUsageInfo( + // 叠加生成的Param类型 (非body参数swagger默认没有生成对象) + params: API.VehicleUsageInfoParams, + options?: RequestOptions, +) { + const { id: param0, ...queryParams } = params; + return request(`/api/vehicle-usage/${param0}`, { + method: 'GET', + params: { ...queryParams }, + ...(options || {}), + }); +} + +/** 解除车辆使用记录和附件关联 PUT /api/vehicle-usage/unlink-attachments/${param0} */ +export async function unlinkAttachments( + // 叠加生成的Param类型 (非body参数swagger默认没有生成对象) + params: API.VehicleUsageUpdateParams, + body: API.VehicleUsageUpdateDto, + options?: RequestOptions, +) { + const { id: param0, ...queryParams } = params; + return request(`/api/vehicle-usage/unlink-attachments/${param0}`, { + method: 'PUT', + headers: { + 'Content-Type': 'application/json', + }, + params: { ...queryParams }, + data: body, + ...options, + }); +} + +/** 更新车辆使用记录 PUT /api/vehicle-usage/${param0} */ +export async function vehicleUsageUpdate( + // 叠加生成的Param类型 (非body参数swagger默认没有生成对象) + params: API.VehicleUsageUpdateParams, + body: API.VehicleUsageUpdateDto, + options?: RequestOptions, +) { + const { id: param0, ...queryParams } = params; + return request(`/api/vehicle-usage/${param0}`, { + method: 'PUT', + headers: { + 'Content-Type': 'application/json', + }, + params: { ...queryParams }, + data: body, + ...(options || { successMsg: '更新成功' }), + }); +} + +/** 删除车辆使用记录 DELETE /api/vehicle-usage/${param0} */ +export async function vehicleUsageDelete( + // 叠加生成的Param类型 (非body参数swagger默认没有生成对象) + params: API.VehicleUsageDeleteParams, + options?: RequestOptions, +) { + const { id: param0, ...queryParams } = params; + return request(`/api/vehicle-usage/${param0}`, { + method: 'DELETE', + params: { ...queryParams }, + ...(options || { successMsg: '删除成功' }), + }); +} diff --git a/src/views/vehicle-usage/columns.tsx b/src/views/vehicle-usage/columns.tsx new file mode 100644 index 0000000..6119587 --- /dev/null +++ b/src/views/vehicle-usage/columns.tsx @@ -0,0 +1,62 @@ +import Api from '@/api'; +import type { TableColumn } from '@/components/core/dynamic-table'; + +export type TableListItem = API.VehicleUsageEntity; +export type TableColumnItem = TableColumn; +export const baseColumns: TableColumnItem[] = [ + { + title: '外出使用的车辆名称及车牌号', + dataIndex: 'vechicle', + customRender: ({ record }) => { + return record?.vechicle?.label || ''; + }, + }, + { + title: '申请人', + dataIndex: 'applicant', + }, + { + title: '出行司机', + dataIndex: 'driver', + }, + // /** 外出使用的车辆Id */ + // vechicleId: number; + // /** 外出使用的车辆名称(字典) */ + // vechicle: DictItemEntity; + // /** 申请人 */ + // applicant: string; + // /** 出行司机 */ + // driver: string; + // /** 当前车辆里程数(KM) */ + // currentMileage: number; + // /** 预计出行开始时间 */ + // expectedStartDate: Date; + // /** 预计出行结束时间 */ + // expectedEndDate: Date; + // /** 使用事由 */ + // purpose: string; + // /** 实际回司时间 */ + // actualReturnTime: Date; + // /** 回城车辆里程数(KM) */ + // returnMileage: number; + // /** 审核人 */ + // reviewer: string; + // /** 审核状态:0待审核,1同意,2.不同意(字典) */ + // status: number; + // /** 备注 */ + // remark: string; + // { + // title: '所属公司', + // dataIndex: 'company', + // customRender: ({ record }) => { + // return record?.company?.name || ''; + // }, + // }, + // { + // title: '单位', + // dataIndex: 'unit', + // customRender: ({ record }) => { + // return record?.unit?.label || ''; + // }, + // }, +]; diff --git a/src/views/vehicle-usage/formSchemas.ts b/src/views/vehicle-usage/formSchemas.ts new file mode 100644 index 0000000..0e8ec4a --- /dev/null +++ b/src/views/vehicle-usage/formSchemas.ts @@ -0,0 +1,99 @@ +import Api from '@/api'; +import type { FormSchema } from '@/components/core/schema-form/'; +import { DictEnum } from '@/enums/dictEnum'; +import { useDictStore } from '@/store/modules/dict'; +import { debounce } from 'lodash-es'; +const { getDictItemsByCode } = useDictStore(); +export const formSchemas: FormSchema[] = [ + // { + // field: 'name', + // component: 'Input', + // label: '车辆使用名称', + // rules: [{ required: true, type: 'string' }], + // colProps: { + // span: 12, + // }, + // }, + // { + // label: '单位', + // component: 'Select', + // field: 'unitId', + // colProps: { + // span: 12, + // }, + // componentProps: ({ formInstance, schema, formModel }) => ({ + // showSearch: true, + // filterOption: (input: string, option: any) => { + // return option.label.indexOf(input) >= 0; + // }, + // fieldNames: { + // label: 'label', + // value: 'value', + // }, + // options: getDictItemsByCode(DictEnum.Unit).map((item) => ({ + // value: item.id, + // label: item.label, + // })), + + // getPopupContainer: () => document.body, + // defaultActiveFirstOption: true, + // }), + // }, + // { + // field: 'companyId', + // component: 'Select', + // label: '所属公司', + // helpMessage: '如未找到对应公司,请先去公司管理添加公司。', + // componentProps: ({ formInstance, schema }) => ({ + // showSearch: true, + // filterOption: false, + // fieldNames: { + // label: 'label', + // value: 'value', + // }, + // options: [], + // getPopupContainer: () => document.body, + // defaultActiveFirstOption: true, + // onChange: async (value) => { + // if (!value) { + // formInstance?.setFieldsValue({ companyId: undefined }); + // const options = await getCompanyOptions(); + // const newSchema = { + // field: schema.field, + // componentProps: { + // options, + // }, + // }; + // formInstance?.updateSchema([newSchema]); + // } + // }, + + // request: () => { + // return getCompanyOptions(); + // }, + // onSearch: debounce(async (keyword) => { + // schema.loading = true; + // const newSchema = { + // field: schema.field, + // componentProps: { + // options: [] as LabelValueOptions, + // }, + // }; + // formInstance?.updateSchema([newSchema]); + // const options = await getCompanyOptions(keyword).finally(() => (schema.loading = false)); + // newSchema.componentProps.options = options; + // formInstance?.updateSchema([newSchema]); + // }, 500), + // }), + // }, +]; + +const getCompanyOptions = async (keyword?: string): Promise => { + const { items: result } = await Api.company.companyList({ pageSize: 100, name: keyword }); + return ( + result?.map((item) => ({ + label: item.name, + value: item.id, + })) || [] + ); +}; diff --git a/src/views/vehicle-usage/index.vue b/src/views/vehicle-usage/index.vue index b6347f7..e378d20 100644 --- a/src/views/vehicle-usage/index.vue +++ b/src/views/vehicle-usage/index.vue @@ -1,7 +1,220 @@ - - - + +