feat: 完成设备类型
Some checks are pending
Gitea Actions Demo / Explore-Gitea-Actions (push) Waiting to run
Some checks are pending
Gitea Actions Demo / Explore-Gitea-Actions (push) Waiting to run
This commit is contained in:
68
apps/web-antd/src/api/property/machineType/index.ts
Normal file
68
apps/web-antd/src/api/property/machineType/index.ts
Normal file
@@ -0,0 +1,68 @@
|
||||
import type { MachineTypeVO, MachineTypeForm, MachineTypeQuery,MachineTypeTree } from './model';
|
||||
|
||||
import type { ID, IDS } from '#/api/common';
|
||||
import type { PageResult } from '#/api/common';
|
||||
|
||||
import { commonExport } from '#/api/helper';
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
/**
|
||||
* 查询设备类型列表
|
||||
* @param params
|
||||
* @returns 设备类型列表
|
||||
*/
|
||||
export function machineTypeList(params?: MachineTypeQuery) {
|
||||
return requestClient.get<PageResult<MachineTypeVO>>('/property/machineType/list', { params });
|
||||
}
|
||||
/**
|
||||
* 查询设备类型树
|
||||
* @param params
|
||||
* @returns 设备类型树
|
||||
*/
|
||||
export function getMachineTypeTree() {
|
||||
return requestClient.get<MachineTypeTree[]>('/property/machineType/typeTree');
|
||||
}
|
||||
/**
|
||||
* 导出设备类型列表
|
||||
* @param params
|
||||
* @returns 设备类型列表
|
||||
*/
|
||||
export function machineTypeExport(params?: MachineTypeQuery) {
|
||||
return commonExport('/property/machineType/export', params ?? {});
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询设备类型详情
|
||||
* @param id id
|
||||
* @returns 设备类型详情
|
||||
*/
|
||||
export function machineTypeInfo(id: ID) {
|
||||
return requestClient.get<MachineTypeVO>(`/property/machineType/${id}`);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增设备类型
|
||||
* @param data
|
||||
* @returns void
|
||||
*/
|
||||
export function machineTypeAdd(data: MachineTypeForm) {
|
||||
return requestClient.postWithMsg<void>('/property/machineType', data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新设备类型
|
||||
* @param data
|
||||
* @returns void
|
||||
*/
|
||||
export function machineTypeUpdate(data: MachineTypeForm) {
|
||||
return requestClient.putWithMsg<void>('/property/machineType', data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除设备类型
|
||||
* @param id id
|
||||
* @returns void
|
||||
*/
|
||||
export function machineTypeRemove(id: ID | IDS) {
|
||||
return requestClient.deleteWithMsg<void>(`/property/machineType/${id}`);
|
||||
}
|
130
apps/web-antd/src/api/property/machineType/model.d.ts
vendored
Normal file
130
apps/web-antd/src/api/property/machineType/model.d.ts
vendored
Normal file
@@ -0,0 +1,130 @@
|
||||
import type { PageQuery, BaseEntity } from '#/api/common';
|
||||
|
||||
export interface MachineTypeVO {
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
id: string | number;
|
||||
|
||||
/**
|
||||
* 类型名称
|
||||
*/
|
||||
machineTypeName: string;
|
||||
|
||||
/**
|
||||
* 类型编号
|
||||
*/
|
||||
machineTypeCode: string;
|
||||
|
||||
/**
|
||||
* 上级类型
|
||||
*/
|
||||
parentTypeId: string | number;
|
||||
|
||||
/**
|
||||
* 是否启用
|
||||
*/
|
||||
isEnable: string;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
remark: string;
|
||||
|
||||
/**
|
||||
* 搜索值
|
||||
*/
|
||||
searchValue: string;
|
||||
|
||||
}
|
||||
|
||||
export interface MachineTypeForm extends BaseEntity {
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
id?: string | number;
|
||||
|
||||
/**
|
||||
* 类型名称
|
||||
*/
|
||||
machineTypeName?: string;
|
||||
|
||||
/**
|
||||
* 类型编号
|
||||
*/
|
||||
machineTypeCode?: string;
|
||||
|
||||
/**
|
||||
* 上级类型
|
||||
*/
|
||||
parentTypeId?: string | number;
|
||||
|
||||
/**
|
||||
* 是否启用
|
||||
*/
|
||||
isEnable?: string;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
remark?: string;
|
||||
|
||||
/**
|
||||
* 搜索值
|
||||
*/
|
||||
searchValue?: string;
|
||||
|
||||
}
|
||||
|
||||
export interface MachineTypeQuery extends PageQuery {
|
||||
/**
|
||||
* 类型名称
|
||||
*/
|
||||
machineTypeName?: string;
|
||||
|
||||
/**
|
||||
* 类型编号
|
||||
*/
|
||||
machineTypeCode?: string;
|
||||
|
||||
/**
|
||||
* 上级类型
|
||||
*/
|
||||
parentTypeId?: string | number;
|
||||
|
||||
/**
|
||||
* 是否启用
|
||||
*/
|
||||
isEnable?: string;
|
||||
|
||||
/**
|
||||
* 搜索值
|
||||
*/
|
||||
searchValue?: string;
|
||||
|
||||
/**
|
||||
* 日期范围参数
|
||||
*/
|
||||
params?: any;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: 设备类型树
|
||||
*/
|
||||
export interface MachineTypeTree {
|
||||
id: number;
|
||||
/**
|
||||
* antd组件必须要这个属性 实际是没有这个属性的
|
||||
*/
|
||||
key: string;
|
||||
parentId: number;
|
||||
label: string;
|
||||
weight: number;
|
||||
children?: MachineTypeTree[];
|
||||
}
|
||||
|
||||
export interface MachineTypeTreeData {
|
||||
id: number;
|
||||
label: string;
|
||||
children?: MachineTypeTreeData[];
|
||||
}
|
61
apps/web-antd/src/api/property/maintainTaskDetail/index.ts
Normal file
61
apps/web-antd/src/api/property/maintainTaskDetail/index.ts
Normal file
@@ -0,0 +1,61 @@
|
||||
import type { MaintainTaskDetailVO, MaintainTaskDetailForm, MaintainTaskDetailQuery } from './model';
|
||||
|
||||
import type { ID, IDS } from '#/api/common';
|
||||
import type { PageResult } from '#/api/common';
|
||||
|
||||
import { commonExport } from '#/api/helper';
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
/**
|
||||
* 查询保养明细列表
|
||||
* @param params
|
||||
* @returns 保养明细列表
|
||||
*/
|
||||
export function maintainTaskDetailList(params?: MaintainTaskDetailQuery) {
|
||||
return requestClient.get<PageResult<MaintainTaskDetailVO>>('/property/maintainTaskDetail/list', { params });
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出保养明细列表
|
||||
* @param params
|
||||
* @returns 保养明细列表
|
||||
*/
|
||||
export function maintainTaskDetailExport(params?: MaintainTaskDetailQuery) {
|
||||
return commonExport('/property/maintainTaskDetail/export', params ?? {});
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询保养明细详情
|
||||
* @param id id
|
||||
* @returns 保养明细详情
|
||||
*/
|
||||
export function maintainTaskDetailInfo(id: ID) {
|
||||
return requestClient.get<MaintainTaskDetailVO>(`/property/maintainTaskDetail/${id}`);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增保养明细
|
||||
* @param data
|
||||
* @returns void
|
||||
*/
|
||||
export function maintainTaskDetailAdd(data: MaintainTaskDetailForm) {
|
||||
return requestClient.postWithMsg<void>('/property/maintainTaskDetail', data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新保养明细
|
||||
* @param data
|
||||
* @returns void
|
||||
*/
|
||||
export function maintainTaskDetailUpdate(data: MaintainTaskDetailForm) {
|
||||
return requestClient.putWithMsg<void>('/property/maintainTaskDetail', data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除保养明细
|
||||
* @param id id
|
||||
* @returns void
|
||||
*/
|
||||
export function maintainTaskDetailRemove(id: ID | IDS) {
|
||||
return requestClient.deleteWithMsg<void>(`/property/maintainTaskDetail/${id}`);
|
||||
}
|
114
apps/web-antd/src/api/property/maintainTaskDetail/model.d.ts
vendored
Normal file
114
apps/web-antd/src/api/property/maintainTaskDetail/model.d.ts
vendored
Normal file
@@ -0,0 +1,114 @@
|
||||
import type { PageQuery, BaseEntity } from '#/api/common';
|
||||
|
||||
export interface MaintainTaskDetailVO {
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
id: string | number;
|
||||
|
||||
/**
|
||||
* 任务id
|
||||
*/
|
||||
taskId: string | number;
|
||||
|
||||
/**
|
||||
* 位置编号
|
||||
*/
|
||||
machineId: string | number;
|
||||
|
||||
/**
|
||||
* 保养情况
|
||||
*/
|
||||
sendFlag: string;
|
||||
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
sortNumber: number;
|
||||
|
||||
/**
|
||||
* 状态(0未开始,1已完成)
|
||||
*/
|
||||
state: string;
|
||||
|
||||
/**
|
||||
* 搜索值
|
||||
*/
|
||||
searchValue: string;
|
||||
|
||||
}
|
||||
|
||||
export interface MaintainTaskDetailForm extends BaseEntity {
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
id?: string | number;
|
||||
|
||||
/**
|
||||
* 任务id
|
||||
*/
|
||||
taskId?: string | number;
|
||||
|
||||
/**
|
||||
* 位置编号
|
||||
*/
|
||||
machineId?: string | number;
|
||||
|
||||
/**
|
||||
* 保养情况
|
||||
*/
|
||||
sendFlag?: string;
|
||||
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
sortNumber?: number;
|
||||
|
||||
/**
|
||||
* 状态(0未开始,1已完成)
|
||||
*/
|
||||
state?: string;
|
||||
|
||||
/**
|
||||
* 搜索值
|
||||
*/
|
||||
searchValue?: string;
|
||||
|
||||
}
|
||||
|
||||
export interface MaintainTaskDetailQuery extends PageQuery {
|
||||
/**
|
||||
* 任务id
|
||||
*/
|
||||
taskId?: string | number;
|
||||
|
||||
/**
|
||||
* 位置编号
|
||||
*/
|
||||
machineId?: string | number;
|
||||
|
||||
/**
|
||||
* 保养情况
|
||||
*/
|
||||
sendFlag?: string;
|
||||
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
sortNumber?: number;
|
||||
|
||||
/**
|
||||
* 状态(0未开始,1已完成)
|
||||
*/
|
||||
state?: string;
|
||||
|
||||
/**
|
||||
* 搜索值
|
||||
*/
|
||||
searchValue?: string;
|
||||
|
||||
/**
|
||||
* 日期范围参数
|
||||
*/
|
||||
params?: any;
|
||||
}
|
@@ -0,0 +1,119 @@
|
||||
<script setup lang="ts">
|
||||
import type { PropType } from 'vue';
|
||||
import type { DeptTree } from '#/api/system/user/model';
|
||||
import { onMounted, ref } from 'vue';
|
||||
import { SyncOutlined } from '@ant-design/icons-vue';
|
||||
import { Empty, InputSearch, Skeleton, Tree } from 'ant-design-vue';
|
||||
import { getMachineTypeTree } from '#/api/property/machineType';
|
||||
defineOptions({ inheritAttrs: false });
|
||||
|
||||
withDefaults(defineProps<{ showSearch?: boolean }>(), { showSearch: true });
|
||||
|
||||
const emit = defineEmits<{
|
||||
/**
|
||||
* 点击刷新按钮的事件
|
||||
*/
|
||||
reload: [];
|
||||
/**
|
||||
* 点击节点的事件
|
||||
*/
|
||||
select: [];
|
||||
}>();
|
||||
|
||||
const selectDeptId = defineModel('selectDeptId', {
|
||||
required: true,
|
||||
type: Array as PropType<string[]>,
|
||||
});
|
||||
|
||||
const searchValue = defineModel('searchValue', {
|
||||
type: String,
|
||||
default: '',
|
||||
});
|
||||
|
||||
/** 数据源 */
|
||||
type DeptTreeArray = DeptTree[];
|
||||
const deptTreeArray = ref<DeptTreeArray>([]);
|
||||
/** 骨架屏加载 */
|
||||
const showTreeSkeleton = ref<boolean>(true);
|
||||
function convertTreeLabel(list:any) {
|
||||
return list.map((item:any) => ({
|
||||
...item,
|
||||
label: item.machineTypeName,
|
||||
children: item.children ? convertTreeLabel(item.children) : [],
|
||||
}));
|
||||
}
|
||||
async function loadTree() {
|
||||
showTreeSkeleton.value = true;
|
||||
searchValue.value = '';
|
||||
selectDeptId.value = [];
|
||||
const ret = await getMachineTypeTree();
|
||||
deptTreeArray.value = convertTreeLabel(ret);
|
||||
showTreeSkeleton.value = false;
|
||||
}
|
||||
|
||||
async function handleReload() {
|
||||
await loadTree();
|
||||
emit('reload');
|
||||
}
|
||||
|
||||
onMounted(loadTree);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div :class="$attrs.class">
|
||||
<Skeleton
|
||||
:loading="showTreeSkeleton"
|
||||
:paragraph="{ rows: 8 }"
|
||||
active
|
||||
class="p-[8px]"
|
||||
>
|
||||
<div
|
||||
class="bg-background flex h-full flex-col overflow-y-auto rounded-lg"
|
||||
>
|
||||
<!-- 固定在顶部 必须加上bg-background背景色 否则会产生'穿透'效果 -->
|
||||
<div
|
||||
v-if="showSearch"
|
||||
class="bg-background z-100 sticky left-0 top-0 p-[8px]"
|
||||
>
|
||||
<InputSearch
|
||||
v-model:value="searchValue"
|
||||
:placeholder="$t('pages.common.search')"
|
||||
size="small"
|
||||
>
|
||||
<template #enterButton>
|
||||
<a-button @click="handleReload">
|
||||
<SyncOutlined class="text-primary" />
|
||||
</a-button>
|
||||
</template>
|
||||
</InputSearch>
|
||||
</div>
|
||||
<div class="h-full overflow-x-hidden px-[8px]">
|
||||
<Tree
|
||||
v-bind="$attrs"
|
||||
v-model:selected-keys="selectDeptId"
|
||||
:class="$attrs.class"
|
||||
:field-names="{ title: 'label', key: 'id' }"
|
||||
:show-line="{ showLeafIcon: false }"
|
||||
:tree-data="deptTreeArray"
|
||||
:virtual="false"
|
||||
default-expand-all
|
||||
@select="$emit('select')"
|
||||
>
|
||||
<template #title="{ label }">
|
||||
<span v-if="label.indexOf(searchValue) > -1">
|
||||
{{ label.substring(0, label.indexOf(searchValue)) }}
|
||||
<span style="color: #f50">{{ searchValue }}</span>
|
||||
{{
|
||||
label.substring(
|
||||
label.indexOf(searchValue) + searchValue.length,
|
||||
)
|
||||
}}
|
||||
</span>
|
||||
<span v-else>{{ label }}</span>
|
||||
</template>
|
||||
</Tree>
|
||||
</div>
|
||||
</div>
|
||||
</Skeleton>
|
||||
</div>
|
||||
</template>
|
@@ -0,0 +1,125 @@
|
||||
import type { FormSchemaGetter } from '#/adapter/form';
|
||||
import type { VxeGridProps } from '#/adapter/vxe-table';
|
||||
|
||||
import { getDictOptions } from '#/utils/dict';
|
||||
import { renderDict } from '#/utils/render';
|
||||
|
||||
export const querySchema: FormSchemaGetter = () => [
|
||||
{
|
||||
component: 'Input',
|
||||
fieldName: 'machineTypeName',
|
||||
label: '类型名称',
|
||||
labelWidth: 100,
|
||||
},
|
||||
{
|
||||
component: 'Input',
|
||||
fieldName: 'machineTypeCode',
|
||||
label: '类型编号',
|
||||
labelWidth: 100,
|
||||
},
|
||||
{
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
// 可选从DictEnum中获取 DictEnum.WY_KG 便于维护
|
||||
options: getDictOptions('wy_kg'),
|
||||
},
|
||||
fieldName: 'isEnable',
|
||||
label: '是否启用',
|
||||
labelWidth: 100,
|
||||
},
|
||||
];
|
||||
|
||||
// 需要使用i18n注意这里要改成getter形式 否则切换语言不会刷新
|
||||
// export const columns: () => VxeGridProps['columns'] = () => [
|
||||
export const columns: VxeGridProps['columns'] = [
|
||||
{ type: 'checkbox', width: 60 },
|
||||
{
|
||||
title: '序号',
|
||||
field: 'id',
|
||||
width: 60,
|
||||
slots: {
|
||||
default: ({ rowIndex }) => {
|
||||
return (rowIndex + 1).toString();
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '类型名称',
|
||||
field: 'machineTypeName',
|
||||
minWidth: 180,
|
||||
},
|
||||
{
|
||||
title: '类型编号',
|
||||
field: 'machineTypeCode',
|
||||
minWidth: 180,
|
||||
},
|
||||
{
|
||||
title: '是否启用',
|
||||
field: 'isEnable',
|
||||
slots: {
|
||||
default: ({ row }) => {
|
||||
// 可选从DictEnum中获取 DictEnum.WY_KG 便于维护
|
||||
return renderDict(row.isEnable, 'wy_kg');
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '备注',
|
||||
field: 'remark',
|
||||
},
|
||||
{
|
||||
field: 'action',
|
||||
fixed: 'right',
|
||||
slots: { default: 'action' },
|
||||
title: '操作',
|
||||
width: 180,
|
||||
},
|
||||
];
|
||||
|
||||
export const modalSchema: FormSchemaGetter = () => [
|
||||
{
|
||||
label: '主键',
|
||||
fieldName: 'id',
|
||||
component: 'Input',
|
||||
dependencies: {
|
||||
show: () => false,
|
||||
triggerFields: [''],
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '类型名称',
|
||||
fieldName: 'machineTypeName',
|
||||
component: 'Input',
|
||||
rules: 'required',
|
||||
labelWidth: 100,
|
||||
},
|
||||
{
|
||||
label: '类型编号',
|
||||
fieldName: 'machineTypeCode',
|
||||
component: 'Input',
|
||||
rules: 'required',
|
||||
labelWidth: 100,
|
||||
},
|
||||
{
|
||||
label: '上级类型',
|
||||
fieldName: 'parentTypeId',
|
||||
component: 'TreeSelect',
|
||||
defaultValue: undefined,
|
||||
labelWidth: 100,
|
||||
},
|
||||
{
|
||||
label: '是否启用',
|
||||
fieldName: 'isEnable',
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
// 可选从DictEnum中获取 DictEnum.WY_KG 便于维护
|
||||
options: getDictOptions('wy_kg'),
|
||||
},
|
||||
rules: 'selectRequired',
|
||||
},
|
||||
{
|
||||
label: '备注',
|
||||
fieldName: 'remark',
|
||||
component: 'Input',
|
||||
},
|
||||
];
|
@@ -0,0 +1,205 @@
|
||||
<script setup lang="ts">
|
||||
import type { Recordable } from '@vben/types';
|
||||
|
||||
import { ref } from 'vue';
|
||||
|
||||
import { Page, useVbenModal, type VbenFormProps } from '@vben/common-ui';
|
||||
import { getVxePopupContainer } from '@vben/utils';
|
||||
|
||||
import { Modal, Popconfirm, Space } from 'ant-design-vue';
|
||||
import dayjs from 'dayjs';
|
||||
import MachineTypeTree from '../components/machine-type-tree.vue';
|
||||
import {
|
||||
useVbenVxeGrid,
|
||||
vxeCheckboxChecked,
|
||||
type VxeGridProps
|
||||
} from '#/adapter/vxe-table';
|
||||
|
||||
import {
|
||||
machineTypeExport,
|
||||
machineTypeList,
|
||||
machineTypeRemove,
|
||||
} from '#/api/property/machineType';
|
||||
import type { MachineTypeForm } from '#/api/property/machineType/model';
|
||||
import { commonDownloadExcel } from '#/utils/file/download';
|
||||
|
||||
import machineTypeModal from './machineType-modal.vue';
|
||||
import { columns, querySchema } from './data';
|
||||
const selectDeptId = ref<string[]>([]);
|
||||
|
||||
const formOptions: VbenFormProps = {
|
||||
commonConfig: {
|
||||
labelWidth: 80,
|
||||
componentProps: {
|
||||
allowClear: true,
|
||||
},
|
||||
},
|
||||
schema: querySchema(),
|
||||
wrapperClass: 'grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4',
|
||||
// 处理区间选择器RangePicker时间格式 将一个字段映射为两个字段 搜索/导出会用到
|
||||
// 不需要直接删除
|
||||
// fieldMappingTime: [
|
||||
// [
|
||||
// 'createTime',
|
||||
// ['params[beginTime]', 'params[endTime]'],
|
||||
// ['YYYY-MM-DD 00:00:00', 'YYYY-MM-DD 23:59:59'],
|
||||
// ],
|
||||
// ],
|
||||
handleReset: async () => {
|
||||
selectDeptId.value = [];
|
||||
|
||||
const { formApi, reload } = tableApi;
|
||||
await formApi.resetForm();
|
||||
const formValues = formApi.form.values;
|
||||
formApi.setLatestSubmissionValues(formValues);
|
||||
await reload(formValues);
|
||||
},
|
||||
};
|
||||
|
||||
const gridOptions: VxeGridProps = {
|
||||
checkboxConfig: {
|
||||
// 高亮
|
||||
highlight: true,
|
||||
// 翻页时保留选中状态
|
||||
reserve: true,
|
||||
// 点击行选中
|
||||
// trigger: 'row',
|
||||
},
|
||||
// 需要使用i18n注意这里要改成getter形式 否则切换语言不会刷新
|
||||
// columns: columns(),
|
||||
columns,
|
||||
height: 'auto',
|
||||
keepSource: true,
|
||||
pagerConfig: {},
|
||||
proxyConfig: {
|
||||
ajax: {
|
||||
query: async ({ page }, formValues = {}) => {
|
||||
if (selectDeptId.value.length === 1) {
|
||||
formValues.parentTypeId = selectDeptId.value[0];
|
||||
} else {
|
||||
Reflect.deleteProperty(formValues, 'parentTypeId');
|
||||
}
|
||||
return await machineTypeList({
|
||||
pageNum: page.currentPage,
|
||||
pageSize: page.pageSize,
|
||||
...formValues,
|
||||
});
|
||||
},
|
||||
},
|
||||
},
|
||||
rowConfig: {
|
||||
keyField: 'id',
|
||||
},
|
||||
// 表格全局唯一表示 保存列配置需要用到
|
||||
id: 'property-machineType-index'
|
||||
};
|
||||
|
||||
const [BasicTable, tableApi] = useVbenVxeGrid({
|
||||
formOptions,
|
||||
gridOptions,
|
||||
});
|
||||
|
||||
const [MachineTypeModal, modalApi] = useVbenModal({
|
||||
connectedComponent: machineTypeModal,
|
||||
});
|
||||
|
||||
function handleAdd() {
|
||||
modalApi.setData({});
|
||||
modalApi.open();
|
||||
}
|
||||
|
||||
async function handleEdit(row: Required<MachineTypeForm>) {
|
||||
modalApi.setData({ id: row.id });
|
||||
modalApi.open();
|
||||
}
|
||||
|
||||
async function handleDelete(row: Required<MachineTypeForm>) {
|
||||
await machineTypeRemove(row.id);
|
||||
await tableApi.query();
|
||||
}
|
||||
|
||||
function handleMultiDelete() {
|
||||
const rows = tableApi.grid.getCheckboxRecords();
|
||||
const ids = rows.map((row: Required<MachineTypeForm>) => row.id);
|
||||
Modal.confirm({
|
||||
title: '提示',
|
||||
okType: 'danger',
|
||||
content: `确认删除选中的${ids.length}条记录吗?`,
|
||||
onOk: async () => {
|
||||
await machineTypeRemove(ids);
|
||||
await tableApi.query();
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
function handleDownloadExcel() {
|
||||
commonDownloadExcel(machineTypeExport, '设备类型数据', tableApi.formApi.form.values, {
|
||||
fieldMappingTime: formOptions.fieldMappingTime,
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Page :auto-content-height="true">
|
||||
<div class="flex h-full gap-[8px]">
|
||||
<MachineTypeTree
|
||||
v-model:select-dept-id="selectDeptId"
|
||||
class="w-[260px]"
|
||||
@reload="() => tableApi.reload()"
|
||||
@select="() => tableApi.reload()"
|
||||
/>
|
||||
<BasicTable table-title="设备类型列表">
|
||||
<template #toolbar-tools>
|
||||
<Space>
|
||||
<a-button
|
||||
v-access:code="['property:machineType:export']"
|
||||
@click="handleDownloadExcel"
|
||||
>
|
||||
{{ $t('pages.common.export') }}
|
||||
</a-button>
|
||||
<a-button
|
||||
:disabled="!vxeCheckboxChecked(tableApi)"
|
||||
danger
|
||||
type="primary"
|
||||
v-access:code="['property:machineType:remove']"
|
||||
@click="handleMultiDelete">
|
||||
{{ $t('pages.common.delete') }}
|
||||
</a-button>
|
||||
<a-button
|
||||
type="primary"
|
||||
v-access:code="['property:machineType:add']"
|
||||
@click="handleAdd"
|
||||
>
|
||||
{{ $t('pages.common.add') }}
|
||||
</a-button>
|
||||
</Space>
|
||||
</template>
|
||||
<template #action="{ row }">
|
||||
<Space>
|
||||
<ghost-button
|
||||
v-access:code="['property:machineType:edit']"
|
||||
@click.stop="handleEdit(row)"
|
||||
>
|
||||
{{ $t('pages.common.edit') }}
|
||||
</ghost-button>
|
||||
<Popconfirm
|
||||
:get-popup-container="getVxePopupContainer"
|
||||
placement="left"
|
||||
title="确认删除?"
|
||||
@confirm="handleDelete(row)"
|
||||
>
|
||||
<ghost-button
|
||||
danger
|
||||
v-access:code="['property:machineType:remove']"
|
||||
@click.stop=""
|
||||
>
|
||||
{{ $t('pages.common.delete') }}
|
||||
</ghost-button>
|
||||
</Popconfirm>
|
||||
</Space>
|
||||
</template>
|
||||
</BasicTable>
|
||||
<MachineTypeModal @reload="tableApi.query()" />
|
||||
</div>
|
||||
</Page>
|
||||
</template>
|
@@ -0,0 +1,136 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, ref } from 'vue';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
import { $t } from '@vben/locales';
|
||||
import { cloneDeep,handleNode,getPopupContainer } from '@vben/utils';
|
||||
import { useVbenForm } from '#/adapter/form';
|
||||
import { machineTypeAdd, machineTypeInfo, machineTypeUpdate } from '#/api/property/machineType';
|
||||
import { defaultFormValueGetter, useBeforeCloseDiff } from '#/utils/popup';
|
||||
import { getMachineTypeTree } from '#/api/property/machineType';
|
||||
|
||||
import { modalSchema } from './data';
|
||||
|
||||
const emit = defineEmits<{ reload: [] }>();
|
||||
|
||||
const isUpdate = ref(false);
|
||||
const title = computed(() => {
|
||||
return isUpdate.value ? $t('pages.common.edit') : $t('pages.common.add');
|
||||
});
|
||||
|
||||
const [BasicForm, formApi] = useVbenForm({
|
||||
commonConfig: {
|
||||
// 默认占满两列
|
||||
formItemClass: 'col-span-2',
|
||||
// 默认label宽度 px
|
||||
labelWidth: 80,
|
||||
// 通用配置项 会影响到所有表单项
|
||||
componentProps: {
|
||||
class: 'w-full',
|
||||
}
|
||||
},
|
||||
schema: modalSchema(),
|
||||
showDefaultActions: false,
|
||||
wrapperClass: 'grid-cols-2',
|
||||
});
|
||||
|
||||
const { onBeforeClose, markInitialized, resetInitialized } = useBeforeCloseDiff(
|
||||
{
|
||||
initializedGetter: defaultFormValueGetter(formApi),
|
||||
currentGetter: defaultFormValueGetter(formApi),
|
||||
},
|
||||
);
|
||||
|
||||
const [BasicModal, modalApi] = useVbenModal({
|
||||
// 在这里更改宽度
|
||||
class: 'w-[550px]',
|
||||
fullscreenButton: false,
|
||||
onBeforeClose,
|
||||
onClosed: handleClosed,
|
||||
onConfirm: handleConfirm,
|
||||
onOpenChange: async (isOpen) => {
|
||||
if (!isOpen) {
|
||||
return null;
|
||||
}
|
||||
setupCommunitySelect()
|
||||
modalApi.modalLoading(true);
|
||||
|
||||
const { id } = modalApi.getData() as { id?: number | string };
|
||||
isUpdate.value = !!id;
|
||||
|
||||
if (isUpdate.value && id) {
|
||||
const record = await machineTypeInfo(id);
|
||||
await formApi.setValues(record);
|
||||
}
|
||||
await markInitialized();
|
||||
|
||||
modalApi.modalLoading(false);
|
||||
},
|
||||
});
|
||||
async function setupCommunitySelect() {
|
||||
const areaList = await getMachineTypeTree();
|
||||
// 选中后显示在输入框的值 即父节点 / 子节点
|
||||
// addFullName(areaList, 'areaName', ' / ');
|
||||
const splitStr = '/';
|
||||
handleNode(areaList, 'machineTypeName', splitStr, function (node: any) {
|
||||
// if (node.level != 5) {
|
||||
// node.disabled = true;
|
||||
// }
|
||||
});
|
||||
formApi.updateSchema([
|
||||
{
|
||||
componentProps: () => ({
|
||||
class: 'w-full',
|
||||
fieldNames: {
|
||||
key: 'id',
|
||||
label: 'machineTypeName',
|
||||
value: 'id',
|
||||
children: 'children',
|
||||
},
|
||||
getPopupContainer,
|
||||
placeholder: '请选择设备类型',
|
||||
showSearch: true,
|
||||
treeData: areaList,
|
||||
treeDefaultExpandAll: true,
|
||||
treeLine: { showLeafIcon: false },
|
||||
// 筛选的字段
|
||||
treeNodeFilterProp: 'machineTypeName',
|
||||
// 选中后显示在输入框的值
|
||||
treeNodeLabelProp: 'fullName',
|
||||
}),
|
||||
fieldName: 'parentTypeId',
|
||||
},
|
||||
]);
|
||||
}
|
||||
async function handleConfirm() {
|
||||
try {
|
||||
modalApi.lock(true);
|
||||
const { valid } = await formApi.validate();
|
||||
if (!valid) {
|
||||
return;
|
||||
}
|
||||
// getValues获取为一个readonly的对象 需要修改必须先深拷贝一次
|
||||
const data = cloneDeep(await formApi.getValues());
|
||||
await (isUpdate.value ? machineTypeUpdate(data) : machineTypeAdd(data));
|
||||
resetInitialized();
|
||||
emit('reload');
|
||||
modalApi.close();
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
} finally {
|
||||
modalApi.lock(false);
|
||||
}
|
||||
}
|
||||
|
||||
async function handleClosed() {
|
||||
await formApi.resetForm();
|
||||
resetInitialized();
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<BasicModal :title="title">
|
||||
<BasicForm />
|
||||
</BasicModal>
|
||||
</template>
|
||||
|
@@ -0,0 +1,120 @@
|
||||
import type { FormSchemaGetter } from '#/adapter/form';
|
||||
import type { VxeGridProps } from '#/adapter/vxe-table';
|
||||
|
||||
import { getDictOptions } from '#/utils/dict';
|
||||
import { renderDict } from '#/utils/render';
|
||||
|
||||
export const querySchema: FormSchemaGetter = () => [
|
||||
{
|
||||
component: 'Input',
|
||||
fieldName: 'machineId',
|
||||
label: '位置编号',
|
||||
},
|
||||
{
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
// 可选从DictEnum中获取 DictEnum.WY_BYMXZT 便于维护
|
||||
options: getDictOptions('wy_bymxzt'),
|
||||
},
|
||||
fieldName: 'state',
|
||||
label: '状态',
|
||||
},
|
||||
];
|
||||
|
||||
// 需要使用i18n注意这里要改成getter形式 否则切换语言不会刷新
|
||||
// export const columns: () => VxeGridProps['columns'] = () => [
|
||||
export const columns: VxeGridProps['columns'] = [
|
||||
{ type: 'checkbox', width: 60 },
|
||||
{
|
||||
title: '设备名称',
|
||||
field: 'machineId',
|
||||
},
|
||||
{
|
||||
title: '设备编号',
|
||||
field: 'machineId',
|
||||
},
|
||||
{
|
||||
title: '位置编号',
|
||||
field: 'machineId',
|
||||
},
|
||||
{
|
||||
title: '计划名称',
|
||||
field: 'machineId',
|
||||
},
|
||||
{
|
||||
title: '计划保养人',
|
||||
field: 'machineId',
|
||||
},
|
||||
{
|
||||
title: '计划保养时间',
|
||||
field: 'machineId',
|
||||
},
|
||||
{
|
||||
title: '实际保养时间',
|
||||
field: 'machineId',
|
||||
},
|
||||
|
||||
{
|
||||
title: '保养情况',
|
||||
field: 'sendFlag',
|
||||
},
|
||||
{
|
||||
title: '状态',
|
||||
field: 'state',
|
||||
slots: {
|
||||
default: ({ row }) => {
|
||||
// 可选从DictEnum中获取 DictEnum.WY_BYMXZT 便于维护
|
||||
return renderDict(row.state, 'wy_bymxzt');
|
||||
},
|
||||
},
|
||||
},
|
||||
// {
|
||||
// field: 'action',
|
||||
// fixed: 'right',
|
||||
// slots: { default: 'action' },
|
||||
// title: '操作',
|
||||
// width: 180,
|
||||
// },
|
||||
];
|
||||
|
||||
export const modalSchema: FormSchemaGetter = () => [
|
||||
{
|
||||
label: '主键',
|
||||
fieldName: 'id',
|
||||
component: 'Input',
|
||||
dependencies: {
|
||||
show: () => false,
|
||||
triggerFields: [''],
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '位置编号',
|
||||
fieldName: 'machineId',
|
||||
component: 'Input',
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
label: '保养情况',
|
||||
fieldName: 'sendFlag',
|
||||
component: 'Input',
|
||||
},
|
||||
{
|
||||
label: '排序',
|
||||
fieldName: 'sortNumber',
|
||||
component: 'Input',
|
||||
},
|
||||
{
|
||||
label: '状态(0未开始,1已完成)',
|
||||
fieldName: 'state',
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
// 可选从DictEnum中获取 DictEnum.WY_BYMXZT 便于维护
|
||||
options: getDictOptions('wy_bymxzt'),
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '搜索值',
|
||||
fieldName: 'searchValue',
|
||||
component: 'Input',
|
||||
},
|
||||
];
|
@@ -0,0 +1,182 @@
|
||||
<script setup lang="ts">
|
||||
import type { Recordable } from '@vben/types';
|
||||
|
||||
import { ref } from 'vue';
|
||||
|
||||
import { Page, useVbenModal, type VbenFormProps } from '@vben/common-ui';
|
||||
import { getVxePopupContainer } from '@vben/utils';
|
||||
|
||||
import { Modal, Popconfirm, Space } from 'ant-design-vue';
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
import {
|
||||
useVbenVxeGrid,
|
||||
vxeCheckboxChecked,
|
||||
type VxeGridProps
|
||||
} from '#/adapter/vxe-table';
|
||||
|
||||
import {
|
||||
maintainTaskDetailExport,
|
||||
maintainTaskDetailList,
|
||||
maintainTaskDetailRemove,
|
||||
} from '#/api/property/maintainTaskDetail';
|
||||
import type { MaintainTaskDetailForm } from '#/api/property/maintainTaskDetail/model';
|
||||
import { commonDownloadExcel } from '#/utils/file/download';
|
||||
|
||||
import maintainTaskDetailModal from './maintainTaskDetail-modal.vue';
|
||||
import { columns, querySchema } from './data';
|
||||
|
||||
const formOptions: VbenFormProps = {
|
||||
commonConfig: {
|
||||
labelWidth: 80,
|
||||
componentProps: {
|
||||
allowClear: true,
|
||||
},
|
||||
},
|
||||
schema: querySchema(),
|
||||
wrapperClass: 'grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4',
|
||||
// 处理区间选择器RangePicker时间格式 将一个字段映射为两个字段 搜索/导出会用到
|
||||
// 不需要直接删除
|
||||
// fieldMappingTime: [
|
||||
// [
|
||||
// 'createTime',
|
||||
// ['params[beginTime]', 'params[endTime]'],
|
||||
// ['YYYY-MM-DD 00:00:00', 'YYYY-MM-DD 23:59:59'],
|
||||
// ],
|
||||
// ],
|
||||
};
|
||||
|
||||
const gridOptions: VxeGridProps = {
|
||||
checkboxConfig: {
|
||||
// 高亮
|
||||
highlight: true,
|
||||
// 翻页时保留选中状态
|
||||
reserve: true,
|
||||
// 点击行选中
|
||||
// trigger: 'row',
|
||||
},
|
||||
// 需要使用i18n注意这里要改成getter形式 否则切换语言不会刷新
|
||||
// columns: columns(),
|
||||
columns,
|
||||
height: 'auto',
|
||||
keepSource: true,
|
||||
pagerConfig: {},
|
||||
proxyConfig: {
|
||||
ajax: {
|
||||
query: async ({ page }, formValues = {}) => {
|
||||
return await maintainTaskDetailList({
|
||||
pageNum: page.currentPage,
|
||||
pageSize: page.pageSize,
|
||||
...formValues,
|
||||
});
|
||||
},
|
||||
},
|
||||
},
|
||||
rowConfig: {
|
||||
keyField: 'id',
|
||||
},
|
||||
// 表格全局唯一表示 保存列配置需要用到
|
||||
id: 'property-maintainTaskDetail-index'
|
||||
};
|
||||
|
||||
const [BasicTable, tableApi] = useVbenVxeGrid({
|
||||
formOptions,
|
||||
gridOptions,
|
||||
});
|
||||
|
||||
const [MaintainTaskDetailModal, modalApi] = useVbenModal({
|
||||
connectedComponent: maintainTaskDetailModal,
|
||||
});
|
||||
|
||||
function handleAdd() {
|
||||
modalApi.setData({});
|
||||
modalApi.open();
|
||||
}
|
||||
|
||||
async function handleEdit(row: Required<MaintainTaskDetailForm>) {
|
||||
modalApi.setData({ id: row.id });
|
||||
modalApi.open();
|
||||
}
|
||||
|
||||
async function handleDelete(row: Required<MaintainTaskDetailForm>) {
|
||||
await maintainTaskDetailRemove(row.id);
|
||||
await tableApi.query();
|
||||
}
|
||||
|
||||
function handleMultiDelete() {
|
||||
const rows = tableApi.grid.getCheckboxRecords();
|
||||
const ids = rows.map((row: Required<MaintainTaskDetailForm>) => row.id);
|
||||
Modal.confirm({
|
||||
title: '提示',
|
||||
okType: 'danger',
|
||||
content: `确认删除选中的${ids.length}条记录吗?`,
|
||||
onOk: async () => {
|
||||
await maintainTaskDetailRemove(ids);
|
||||
await tableApi.query();
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
function handleDownloadExcel() {
|
||||
commonDownloadExcel(maintainTaskDetailExport, '保养明细数据', tableApi.formApi.form.values, {
|
||||
fieldMappingTime: formOptions.fieldMappingTime,
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Page :auto-content-height="true">
|
||||
<BasicTable table-title="保养明细列表">
|
||||
<template #toolbar-tools>
|
||||
<Space>
|
||||
<a-button
|
||||
v-access:code="['property:maintainTaskDetail:export']"
|
||||
@click="handleDownloadExcel"
|
||||
>
|
||||
{{ $t('pages.common.export') }}
|
||||
</a-button>
|
||||
<!-- <a-button
|
||||
:disabled="!vxeCheckboxChecked(tableApi)"
|
||||
danger
|
||||
type="primary"
|
||||
v-access:code="['property:maintainTaskDetail:remove']"
|
||||
@click="handleMultiDelete">
|
||||
{{ $t('pages.common.delete') }}
|
||||
</a-button>
|
||||
<a-button
|
||||
type="primary"
|
||||
v-access:code="['property:maintainTaskDetail:add']"
|
||||
@click="handleAdd"
|
||||
>
|
||||
{{ $t('pages.common.add') }}
|
||||
</a-button> -->
|
||||
</Space>
|
||||
</template>
|
||||
<!-- <template #action="{ row }">
|
||||
<Space>
|
||||
<ghost-button
|
||||
v-access:code="['property:maintainTaskDetail:edit']"
|
||||
@click.stop="handleEdit(row)"
|
||||
>
|
||||
{{ $t('pages.common.edit') }}
|
||||
</ghost-button>
|
||||
<Popconfirm
|
||||
:get-popup-container="getVxePopupContainer"
|
||||
placement="left"
|
||||
title="确认删除?"
|
||||
@confirm="handleDelete(row)"
|
||||
>
|
||||
<ghost-button
|
||||
danger
|
||||
v-access:code="['property:maintainTaskDetail:remove']"
|
||||
@click.stop=""
|
||||
>
|
||||
{{ $t('pages.common.delete') }}
|
||||
</ghost-button>
|
||||
</Popconfirm>
|
||||
</Space>
|
||||
</template> -->
|
||||
</BasicTable>
|
||||
<MaintainTaskDetailModal @reload="tableApi.query()" />
|
||||
</Page>
|
||||
</template>
|
@@ -0,0 +1,101 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, ref } from 'vue';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
import { $t } from '@vben/locales';
|
||||
import { cloneDeep } from '@vben/utils';
|
||||
|
||||
import { useVbenForm } from '#/adapter/form';
|
||||
import { maintainTaskDetailAdd, maintainTaskDetailInfo, maintainTaskDetailUpdate } from '#/api/property/maintainTaskDetail';
|
||||
import { defaultFormValueGetter, useBeforeCloseDiff } from '#/utils/popup';
|
||||
|
||||
import { modalSchema } from './data';
|
||||
|
||||
const emit = defineEmits<{ reload: [] }>();
|
||||
|
||||
const isUpdate = ref(false);
|
||||
const title = computed(() => {
|
||||
return isUpdate.value ? $t('pages.common.edit') : $t('pages.common.add');
|
||||
});
|
||||
|
||||
const [BasicForm, formApi] = useVbenForm({
|
||||
commonConfig: {
|
||||
// 默认占满两列
|
||||
formItemClass: 'col-span-2',
|
||||
// 默认label宽度 px
|
||||
labelWidth: 80,
|
||||
// 通用配置项 会影响到所有表单项
|
||||
componentProps: {
|
||||
class: 'w-full',
|
||||
}
|
||||
},
|
||||
schema: modalSchema(),
|
||||
showDefaultActions: false,
|
||||
wrapperClass: 'grid-cols-2',
|
||||
});
|
||||
|
||||
const { onBeforeClose, markInitialized, resetInitialized } = useBeforeCloseDiff(
|
||||
{
|
||||
initializedGetter: defaultFormValueGetter(formApi),
|
||||
currentGetter: defaultFormValueGetter(formApi),
|
||||
},
|
||||
);
|
||||
|
||||
const [BasicModal, modalApi] = useVbenModal({
|
||||
// 在这里更改宽度
|
||||
class: 'w-[550px]',
|
||||
fullscreenButton: false,
|
||||
onBeforeClose,
|
||||
onClosed: handleClosed,
|
||||
onConfirm: handleConfirm,
|
||||
onOpenChange: async (isOpen) => {
|
||||
if (!isOpen) {
|
||||
return null;
|
||||
}
|
||||
modalApi.modalLoading(true);
|
||||
|
||||
const { id } = modalApi.getData() as { id?: number | string };
|
||||
isUpdate.value = !!id;
|
||||
|
||||
if (isUpdate.value && id) {
|
||||
const record = await maintainTaskDetailInfo(id);
|
||||
await formApi.setValues(record);
|
||||
}
|
||||
await markInitialized();
|
||||
|
||||
modalApi.modalLoading(false);
|
||||
},
|
||||
});
|
||||
|
||||
async function handleConfirm() {
|
||||
try {
|
||||
modalApi.lock(true);
|
||||
const { valid } = await formApi.validate();
|
||||
if (!valid) {
|
||||
return;
|
||||
}
|
||||
// getValues获取为一个readonly的对象 需要修改必须先深拷贝一次
|
||||
const data = cloneDeep(await formApi.getValues());
|
||||
await (isUpdate.value ? maintainTaskDetailUpdate(data) : maintainTaskDetailAdd(data));
|
||||
resetInitialized();
|
||||
emit('reload');
|
||||
modalApi.close();
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
} finally {
|
||||
modalApi.lock(false);
|
||||
}
|
||||
}
|
||||
|
||||
async function handleClosed() {
|
||||
await formApi.resetForm();
|
||||
resetInitialized();
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<BasicModal :title="title">
|
||||
<BasicForm />
|
||||
</BasicModal>
|
||||
</template>
|
||||
|
Reference in New Issue
Block a user