diff --git a/apps/web-antd/src/api/ops/inspection-template/index.ts b/apps/web-antd/src/api/ops/inspection-template/index.ts new file mode 100644 index 000000000..0a90da910 --- /dev/null +++ b/apps/web-antd/src/api/ops/inspection-template/index.ts @@ -0,0 +1,79 @@ +import { requestClient } from '#/api/request'; + +import type { FunctionType } from '#/api/ops/area'; + +export namespace InspectionTemplateApi { + /** 巡检检查项模板 */ + export interface Template { + id?: number; + /** 功能类型 */ + functionType: FunctionType; + /** 检查项标题 */ + itemTitle: string; + /** 检查项描述 */ + itemDescription?: string; + /** 排序号 */ + sortOrder?: number; + /** 启用状态 */ + isActive?: boolean; + /** 创建时间 */ + createTime?: string; + /** 更新时间 */ + updateTime?: string; + } + + /** 分页查询参数 */ + export interface TemplatePageQuery { + functionType?: FunctionType; + itemTitle?: string; + enabled?: boolean; + pageNo?: number; + pageSize?: number; + } + + /** 分页结果 */ + export interface PageResult { + list: Template[]; + total: number; + } +} + +// ========== 巡检检查项模板 API ========== + +/** 获取模板分页 */ +export function getTemplatePage(params: InspectionTemplateApi.TemplatePageQuery) { + return requestClient.get( + '/ops/inspection/template/page', + { params }, + ); +} + +/** 获取模板详情 */ +export function getTemplate(id: number) { + return requestClient.get( + '/ops/inspection/template/get', + { params: { id } }, + ); +} + +/** 新增模板 */ +export function createTemplate(data: InspectionTemplateApi.Template) { + return requestClient.post('/ops/inspection/template/create', data); +} + +/** 更新模板 */ +export function updateTemplate(data: InspectionTemplateApi.Template) { + return requestClient.put('/ops/inspection/template/update', data); +} + +/** 删除模板 */ +export function deleteTemplate(id: number) { + return requestClient.delete('/ops/inspection/template/delete', { + params: { id }, + }); +} + +/** 批量更新排序 */ +export function updateTemplateSortBatch(ids: number[]) { + return requestClient.put('/ops/inspection/template/update-sort-batch', ids); +} diff --git a/apps/web-antd/src/views/ops/inspection-template/data.ts b/apps/web-antd/src/views/ops/inspection-template/data.ts new file mode 100644 index 000000000..642ce529b --- /dev/null +++ b/apps/web-antd/src/views/ops/inspection-template/data.ts @@ -0,0 +1,111 @@ +import type { VbenFormSchema } from '#/adapter/form'; +import type { VxeTableGridOptions } from '#/adapter/vxe-table'; +import type { InspectionTemplateApi } from '#/api/ops/inspection-template'; + +import { z } from '#/adapter/form'; + +import { + FUNCTION_TYPE_OPTIONS, + FUNCTION_TYPE_TAG_COLORS, +} from '../area/data'; + +export { FUNCTION_TYPE_OPTIONS, FUNCTION_TYPE_TAG_COLORS }; + +/** 检查项列表列 */ +export function useGridColumns(): VxeTableGridOptions['columns'] { + return [ + { + field: 'drag', + title: '', + width: 40, + slots: { default: 'drag' }, + }, + { + field: 'sortOrder', + title: '排序号', + width: 100, + }, + { + field: 'itemTitle', + title: '检查项标题', + minWidth: 200, + align: 'left', + }, + { + field: 'itemDescription', + title: '检查项描述', + minWidth: 200, + align: 'left', + }, + { + field: 'isActive', + title: '启用状态', + width: 100, + slots: { default: 'isActive' }, + }, + { + field: 'createTime', + title: '创建时间', + width: 180, + formatter: 'formatDateTime', + }, + { + title: '操作', + width: 150, + fixed: 'right', + slots: { default: 'actions' }, + }, + ]; +} + +/** 检查项表单 Schema */ +export function useTemplateFormSchema(): VbenFormSchema[] { + return [ + { + fieldName: 'id', + component: 'Input', + dependencies: { triggerFields: [''], show: () => false }, + }, + { + fieldName: 'itemTitle', + label: '检查项标题', + component: 'Input', + componentProps: { placeholder: '请输入检查项标题' }, + rules: 'required', + }, + { + fieldName: 'itemDescription', + label: '检查项描述', + component: 'Textarea', + componentProps: { + placeholder: '请输入检查项描述', + rows: 3, + }, + }, + { + fieldName: 'sortOrder', + label: '排序号', + component: 'InputNumber', + componentProps: { + min: 0, + placeholder: '请输入排序号', + class: 'w-full', + }, + rules: z.number().min(0).default(0), + }, + { + fieldName: 'isActive', + label: '启用状态', + component: 'RadioGroup', + componentProps: { + options: [ + { label: '启用', value: true }, + { label: '停用', value: false }, + ], + optionType: 'button', + buttonStyle: 'solid', + }, + rules: z.boolean().default(true), + }, + ]; +} diff --git a/apps/web-antd/src/views/ops/inspection-template/index.vue b/apps/web-antd/src/views/ops/inspection-template/index.vue new file mode 100644 index 000000000..abc3ac9a2 --- /dev/null +++ b/apps/web-antd/src/views/ops/inspection-template/index.vue @@ -0,0 +1,359 @@ + + + diff --git a/apps/web-antd/src/views/ops/inspection-template/modules/form.vue b/apps/web-antd/src/views/ops/inspection-template/modules/form.vue new file mode 100644 index 000000000..8a328d34e --- /dev/null +++ b/apps/web-antd/src/views/ops/inspection-template/modules/form.vue @@ -0,0 +1,91 @@ + + +