Merge branch 'master' of http://47.109.37.87:3000/by2025/admin-vben5
Some checks are pending
Gitea Actions Demo / Explore-Gitea-Actions (push) Waiting to run

This commit is contained in:
2025-07-16 21:59:03 +08:00
30 changed files with 3453 additions and 109 deletions

View File

@@ -26,6 +26,16 @@ export interface DeviceLocationVO {
*/
searchValue: string;
/**
* 位置类型
*/
locationObjName: string;
/**
* 搜索值
*/
remark: string;
}
export interface DeviceLocationForm extends BaseEntity {

View File

@@ -0,0 +1,61 @@
import type { MachineVO, MachineForm, MachineQuery } 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 machineList(params?: MachineQuery) {
return requestClient.get<PageResult<MachineVO>>('/property/machine/list', { params });
}
/**
* 导出设备列表列表
* @param params
* @returns 设备列表列表
*/
export function machineExport(params?: MachineQuery) {
return commonExport('/property/machine/export', params ?? {});
}
/**
* 查询设备列表详情
* @param id id
* @returns 设备列表详情
*/
export function machineInfo(id: ID) {
return requestClient.get<MachineVO>(`/property/machine/${id}`);
}
/**
* 新增设备列表
* @param data
* @returns void
*/
export function machineAdd(data: MachineForm) {
return requestClient.postWithMsg<void>('/property/machine', data);
}
/**
* 更新设备列表
* @param data
* @returns void
*/
export function machineUpdate(data: MachineForm) {
return requestClient.putWithMsg<void>('/property/machine', data);
}
/**
* 删除设备列表
* @param id id
* @returns void
*/
export function machineRemove(id: ID | IDS) {
return requestClient.deleteWithMsg<void>(`/property/machine/${id}`);
}

View File

@@ -0,0 +1,204 @@
import type { PageQuery, BaseEntity } from '#/api/common';
export interface MachineVO {
/**
* 主键
*/
id: string | number;
/**
* 设备名称
*/
machineName: string;
/**
* 设备编码
*/
machineCode: string;
/**
* 设备品牌
*/
machineBrand: string;
/**
* 设备类型
*/
machineTypeId: string | number;
/**
* 位置详情
*/
locationId: string | number;
/**
* 采购价格
*/
purchasePrice: number;
/**
* 启用时间
*/
activationTime: string;
/**
* 保修截至时间
*/
deadline: string;
/**
* 使用年限(年)
*/
serviceLife: number;
/**
* 保修周期
*/
maintenanceCycle: string;
/**
* 使用状态
*/
state: string;
/**
* 责任人
*/
personId: string | number;
}
export interface MachineForm extends BaseEntity {
/**
* 主键
*/
id?: string | number;
/**
* 设备名称
*/
machineName?: string;
/**
* 设备编码
*/
machineCode?: string;
/**
* 设备品牌
*/
machineBrand?: string;
/**
* 设备类型
*/
machineTypeId?: string | number;
/**
* 位置详情
*/
locationId?: string | number;
/**
* 采购价格
*/
purchasePrice?: number;
/**
* 启用时间
*/
activationTime?: string;
/**
* 保修截至时间
*/
deadline?: string;
/**
* 使用年限(年)
*/
serviceLife?: number;
/**
* 保修周期
*/
maintenanceCycle?: string;
/**
* 使用状态
*/
state?: string;
/**
* 责任人
*/
personId?: string | number;
}
export interface MachineQuery extends PageQuery {
/**
* 设备名称
*/
machineName?: string;
/**
* 设备编码
*/
machineCode?: string;
/**
* 设备品牌
*/
machineBrand?: string;
/**
* 设备类型
*/
machineTypeId?: string | number;
/**
* 位置详情
*/
locationId?: string | number;
/**
* 采购价格
*/
purchasePrice?: number;
/**
* 启用时间
*/
activationTime?: string;
/**
* 保修截至时间
*/
deadline?: string;
/**
* 使用年限(年)
*/
serviceLife?: number;
/**
* 保修周期
*/
maintenanceCycle?: string;
/**
* 使用状态
*/
state?: string;
/**
* 责任人
*/
personId?: string | number;
/**
* 日期范围参数
*/
params?: any;
}

View File

@@ -0,0 +1,61 @@
import type { MaintainPlanVO, MaintainPlanForm, MaintainPlanQuery } 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 maintainPlanList(params?: MaintainPlanQuery) {
return requestClient.get<PageResult<MaintainPlanVO>>('/property/maintainPlan/list', { params });
}
/**
* 导出保养计划列表
* @param params
* @returns 保养计划列表
*/
export function maintainPlanExport(params?: MaintainPlanQuery) {
return commonExport('/property/maintainPlan/export', params ?? {});
}
/**
* 查询保养计划详情
* @param id id
* @returns 保养计划详情
*/
export function maintainPlanInfo(id: ID) {
return requestClient.get<MaintainPlanVO>(`/property/maintainPlan/${id}`);
}
/**
* 新增保养计划
* @param data
* @returns void
*/
export function maintainPlanAdd(data: MaintainPlanForm) {
return requestClient.postWithMsg<void>('/property/maintainPlan', data);
}
/**
* 更新保养计划
* @param data
* @returns void
*/
export function maintainPlanUpdate(data: MaintainPlanForm) {
return requestClient.putWithMsg<void>('/property/maintainPlan', data);
}
/**
* 删除保养计划
* @param id id
* @returns void
*/
export function maintainPlanRemove(id: ID | IDS) {
return requestClient.deleteWithMsg<void>(`/property/maintainPlan/${id}`);
}

View File

@@ -0,0 +1,174 @@
import type { PageQuery, BaseEntity } from '#/api/common';
export interface MaintainPlanVO {
/**
* 主键
*/
id: string | number;
/**
* 计划名称
*/
planName: string;
/**
* 计划编号
*/
planNo: string;
/**
* 保养周期(1月/天2.固定天)
*/
planPeriod: string;
/**
* 保养设备类型id
*/
machineTypeId: string | number;
/**
* 保养天
*/
maintainDay: string;
/**
* 保养月
*/
maintainMonth: string;
/**
* 固定天
*/
maintainEveryday: string;
/**
* 开始时间
*/
startDate: string;
/**
* 结束时间
*/
endDate: string;
/**
* 状态(0启用,1停用)
*/
state: string;
}
export interface MaintainPlanForm extends BaseEntity {
/**
* 主键
*/
id?: string | number;
/**
* 计划名称
*/
planName?: string;
/**
* 计划编号
*/
planNo?: string;
/**
* 保养周期(1月/天2.固定天)
*/
planPeriod?: string;
/**
* 保养设备类型id
*/
machineTypeId?: string | number;
/**
* 保养天
*/
maintainDay?: string;
/**
* 保养月
*/
maintainMonth?: string;
/**
* 固定天
*/
maintainEveryday?: string;
/**
* 开始时间
*/
startDate?: string;
/**
* 结束时间
*/
endDate?: string;
/**
* 状态(0启用,1停用)
*/
state?: string;
}
export interface MaintainPlanQuery extends PageQuery {
/**
* 计划名称
*/
planName?: string;
/**
* 计划编号
*/
planNo?: string;
/**
* 保养周期(1月/天2.固定天)
*/
planPeriod?: string;
/**
* 保养设备类型id
*/
machineTypeId?: string | number;
/**
* 保养天
*/
maintainDay?: string;
/**
* 保养月
*/
maintainMonth?: string;
/**
* 固定天
*/
maintainEveryday?: string;
/**
* 开始时间
*/
startDate?: string;
/**
* 结束时间
*/
endDate?: string;
/**
* 状态(0启用,1停用)
*/
state?: string;
/**
* 日期范围参数
*/
params?: any;
}

View 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}`);
}

View 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[];
}

View 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}`);
}

View 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;
}

View File

@@ -0,0 +1,121 @@
<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');
}
defineExpose({
handleReload,
});
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>

View File

@@ -1,5 +1,7 @@
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 = () => [
@@ -8,23 +10,14 @@ export const querySchema: FormSchemaGetter = () => [
fieldName: 'locationName',
label: '位置名称',
},
{
component: 'Input',
fieldName: 'locationCode',
label: '位置编号',
},
{
component: 'Select',
componentProps: {
options: getDictOptions('pro_location_type'),
},
fieldName: 'locationType',
label: '位置类型',
},
{
component: 'Input',
fieldName: 'searchValue',
label: '搜索值',
},
];
// 需要使用i18n注意这里要改成getter形式 否则切换语言不会刷新
@@ -32,24 +25,30 @@ export const querySchema: FormSchemaGetter = () => [
export const columns: VxeGridProps['columns'] = [
{ type: 'checkbox', width: 60 },
{
title: '主键',
field: 'id',
title: '位置编码',
field: 'locationCode',
},
{
title: '位置名称',
field: 'locationName',
},
{
title: '位置编号',
field: 'locationCode',
},
{
title: '位置类型',
field: 'locationType',
slots: {
default: ({ row }) => {
return renderDict(row.locationType, 'pro_location_type');
},
},
},
{
title: '搜索值',
field: 'searchValue',
title: '位置对象',
field: 'locationObject',
},
{
title: '备注',
field: 'remark',
},
{
field: 'action',
@@ -60,37 +59,41 @@ export const columns: VxeGridProps['columns'] = [
},
];
export const modalSchema: FormSchemaGetter = () => [
{
label: '主键',
fieldName: 'id',
component: 'Input',
dependencies: {
show: () => false,
triggerFields: [''],
},
},
{
label: '位置名称',
fieldName: 'locationName',
component: 'Input',
rules: 'required',
},
{
label: '位置编号',
fieldName: 'locationCode',
component: 'Input',
},
{
label: '位置类型',
fieldName: 'locationType',
component: 'Select',
componentProps: {
},
},
{
label: '搜索值',
fieldName: 'searchValue',
component: 'Input',
},
];
// export const modalSchema: FormSchemaGetter = () => [
// {
// label: '主键',
// fieldName: 'id',
// component: 'Input',
// dependencies: {
// show: () => false,
// triggerFields: [''],
// },
// },
// {
// label: '位置名称',
// fieldName: 'locationName',
// component: 'Input',
// rules: 'required',
// },
// {
// label: '位置类型',
// fieldName: 'locationType',
// component: 'Select',
// componentProps: {
// options: getDictOptions('pro_location_type'),
// },
// rules: 'selectRequired',
// },
// {
// component: 'TreeSelect',
// fieldName: 'locationObject',
// defaultValue: undefined,
// label: '位置对象',
// rules: 'selectRequired',
// },
// {
// label: '备注',
// fieldName: 'remark',
// component: 'Textarea',
// },
// ];

View File

@@ -0,0 +1,52 @@
<script setup lang="ts">
import type {DeviceLocationVO} from '#/api/property/equipmentManagement/deviceLocation/model';
import {shallowRef} from 'vue';
import {useVbenModal} from '@vben/common-ui';
import {Descriptions, DescriptionsItem} from 'ant-design-vue';
import {deviceLocationInfo} from '#/api/property/equipmentManagement/deviceLocation';
import {renderDict} from "#/utils/render";
const [BasicModal, modalApi] = useVbenModal({
onOpenChange: handleOpenChange,
onClosed() {
deviceLocationDetail.value = null;
},
});
const deviceLocationDetail = shallowRef<null | DeviceLocationVO>(null);
async function handleOpenChange(open: boolean) {
if (!open) {
return null;
}
modalApi.modalLoading(true);
const {id} = modalApi.getData() as { id: number | string };
const response = await deviceLocationInfo(id);
deviceLocationDetail.value = response;
modalApi.modalLoading(false);
}
</script>
<template>
<BasicModal :footer="false" :fullscreen-button="false" title="查看收费" class="w-[70%]">
<Descriptions v-if="deviceLocationDetail" size="small" :column="2" bordered :labelStyle="{width:'100px'}">
<DescriptionsItem label="位置编码">
{{ deviceLocationDetail.locationCode }}
</DescriptionsItem>
<DescriptionsItem label="位置名称">
{{ deviceLocationDetail.locationName }}
</DescriptionsItem>
<DescriptionsItem label="位置类型" v-if="deviceLocationDetail.locationType!=null">
<component
:is="renderDict(deviceLocationDetail.locationType,'pro_location_type')"
/>
</DescriptionsItem>
<DescriptionsItem label="位置对象">
{{ deviceLocationDetail.locationObjName }}
</DescriptionsItem>
<DescriptionsItem label="备注">
{{ deviceLocationDetail.remark }}
</DescriptionsItem>
</Descriptions>
</BasicModal>
</template>

View File

@@ -1,23 +1,71 @@
<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 { deviceLocationAdd, deviceLocationInfo, deviceLocationUpdate } from '#/api/property/deviceLocation';
import {cloneDeep, handleNode} from '@vben/utils';
import {useVbenForm} from '#/adapter/form';
import { deviceLocationAdd, deviceLocationInfo, deviceLocationUpdate } from '#/api/property/equipmentManagement/deviceLocation';
import { defaultFormValueGetter, useBeforeCloseDiff } from '#/utils/popup';
import { modalSchema } from './data';
// import { modalSchema } from './data';
import {communityTree} from "#/api/property/community";
import {getDictOptions} from "#/utils/dict";
const emit = defineEmits<{ reload: [] }>();
const isUpdate = ref(false);
const title = computed(() => {
return isUpdate.value ? $t('pages.common.edit') : $t('pages.common.add');
});
const modalSchema = [
{
label: '主键',
fieldName: 'id',
component: 'Input',
dependencies: {
show: () => false,
triggerFields: [''],
},
},
{
label: '位置名称',
fieldName: 'locationName',
component: 'Input',
rules: 'required',
},
{
label: '位置类型',
fieldName: 'locationType',
component: 'Select',
componentProps: {
options: getDictOptions('pro_location_type'),
onChange: async (value: string) => {
if(value) {
await setupCommunitySelect(value)
await formApi.setFieldValue('locationObjId', null);
}
}
},
rules: 'selectRequired',
},
{
component: 'TreeSelect',
fieldName: 'locationObjId',
defaultValue: undefined,
label: '位置对象',
dependencies: {
show: (formValue) =>formValue.locationType!==undefined ,
triggerFields: ['locationType'],
},
rules: 'selectRequired',
},
{
label: '备注',
fieldName: 'remark',
component: 'Textarea',
},
];
const [BasicForm, formApi] = useVbenForm({
commonConfig: {
// 默认占满两列
@@ -29,7 +77,7 @@ const [BasicForm, formApi] = useVbenForm({
class: 'w-full',
}
},
schema: modalSchema(),
schema: modalSchema,
showDefaultActions: false,
wrapperClass: 'grid-cols-2',
});
@@ -53,16 +101,14 @@ const [BasicModal, modalApi] = useVbenModal({
return null;
}
modalApi.modalLoading(true);
const { id } = modalApi.getData() as { id?: number | string };
isUpdate.value = !!id;
if (isUpdate.value && id) {
const record = await deviceLocationInfo(id);
record.locationType = record.locationType?.toString();
await formApi.setValues(record);
}
await markInitialized();
modalApi.modalLoading(false);
},
});
@@ -74,7 +120,6 @@ async function handleConfirm() {
if (!valid) {
return;
}
// getValues获取为一个readonly的对象 需要修改必须先深拷贝一次
const data = cloneDeep(await formApi.getValues());
await (isUpdate.value ? deviceLocationUpdate(data) : deviceLocationAdd(data));
resetInitialized();
@@ -91,6 +136,39 @@ async function handleClosed() {
await formApi.resetForm();
resetInitialized();
}
async function setupCommunitySelect(value:any) {
const areaList = await communityTree(Number(value)+1);
const splitStr = '/';
handleNode(areaList, 'label', splitStr, function (node: any) {
if (node.level != Number(value)+1) {
node.disabled = true;
}
});
formApi.updateSchema([
{
componentProps: () => ({
class: 'w-full',
fieldNames: {
key: 'id',
label: 'label',
value: 'code',
children: 'children',
},
placeholder: '请选择',
showSearch: true,
treeData: areaList,
treeDefaultExpandAll: true,
treeLine: { showLeafIcon: false },
// 筛选的字段
treeNodeFilterProp: 'label',
// 选中后显示在输入框的值
treeNodeLabelProp: 'fullName',
}),
fieldName: 'locationObjId',
},
]);
}
</script>
<template>

View File

@@ -1,29 +1,19 @@
<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 {
import {
useVbenVxeGrid,
vxeCheckboxChecked,
type VxeGridProps
type VxeGridProps
} from '#/adapter/vxe-table';
import {
deviceLocationExport,
deviceLocationList,
deviceLocationRemove,
} from '#/api/property/deviceLocation';
import type { DeviceLocationForm } from '#/api/property/deviceLocation/model';
import { commonDownloadExcel } from '#/utils/file/download';
} from '#/api/property/equipmentManagement/deviceLocation';
import type { DeviceLocationForm } from '#/api/property/equipmentManagement/deviceLocation/model';
import deviceLocationModal from './deviceLocation-modal.vue';
import deviceLocationDetail from './deviceLocation-detail.vue';
import { columns, querySchema } from './data';
const formOptions: VbenFormProps = {
@@ -35,15 +25,6 @@ const formOptions: VbenFormProps = {
},
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 = {
@@ -55,8 +36,6 @@ const gridOptions: VxeGridProps = {
// 点击行选中
// trigger: 'row',
},
// 需要使用i18n注意这里要改成getter形式 否则切换语言不会刷新
// columns: columns(),
columns,
height: 'auto',
keepSource: true,
@@ -117,10 +96,13 @@ function handleMultiDelete() {
});
}
function handleDownloadExcel() {
commonDownloadExcel(deviceLocationExport, '设备位置数据', tableApi.formApi.form.values, {
fieldMappingTime: formOptions.fieldMappingTime,
});
const [deviceLocationDetailModal, deviceLocationDetailApi] = useVbenModal({
connectedComponent: deviceLocationDetail,
});
async function handleInfo(row: Required<DeviceLocationForm>) {
deviceLocationDetailApi.setData({ id: row.id });
deviceLocationDetailApi.open();
}
</script>
@@ -129,17 +111,11 @@ function handleDownloadExcel() {
<BasicTable table-title="设备位置列表">
<template #toolbar-tools>
<Space>
<a-button
v-access:code="['property:deviceLocation:export']"
@click="handleDownloadExcel"
>
{{ $t('pages.common.export') }}
</a-button>
<a-button
:disabled="!vxeCheckboxChecked(tableApi)"
danger
type="primary"
v-access:code="['property:deviceLocation:remove']"
type="primary"
v-access:code="['property:deviceLocation:remove']"
@click="handleMultiDelete">
{{ $t('pages.common.delete') }}
</a-button>
@@ -154,6 +130,11 @@ function handleDownloadExcel() {
</template>
<template #action="{ row }">
<Space>
<ghost-button
@click.stop="handleInfo(row)"
>
{{ $t('pages.common.info') }}
</ghost-button>
<ghost-button
v-access:code="['property:deviceLocation:edit']"
@click.stop="handleEdit(row)"
@@ -178,5 +159,6 @@ function handleDownloadExcel() {
</template>
</BasicTable>
<DeviceLocationModal @reload="tableApi.query()" />
<deviceLocationDetailModal/>
</Page>
</template>

View File

@@ -0,0 +1,217 @@
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: 'machineName',
label: '设备名称',
},
{
component: 'Input',
fieldName: 'machineCode',
label: '设备编码',
},
{
component: 'Select',
componentProps:{
options:getDictOptions('wy_sbsyzt')
},
fieldName: 'state',
label: '使用状态',
},
];
export const columns: VxeGridProps['columns'] = [
{ type: 'checkbox', width: 60 },
{
title: '设备名称',
field: 'machineName',
minWidth:180
},
{
title: '设备编码',
field: 'machineCode',
width:100
},
{
title: '设备品牌',
field: 'machineBrand',
width:100
},
{
title: '设备类型',
field: 'machineTypeId',
width:100
},
{
title: '位置详情',
field: 'locationId',
width:100
},
{
title: '采购价格',
field: 'purchasePrice',
width:100
},
{
title: '启用时间',
field: 'activationTime',
width:100
},
{
title: '保修截至时间',
field: 'deadline',
width:100
},
{
title: '使用年限',
field: 'serviceLife',
width:100
},
{
title: '保修周期',
field: 'maintenanceCycle',
width:100,
slots:{
default: ({row})=>{
return renderDict(row.maintenanceCycle,'wy_sbbxzq')
}
}
},
{
title: '使用状态',
field: 'state',
width:100,
slots:{
default: ({row})=>{
return renderDict(row.state,'wy_sbsyzt')
}
}
},
{
title: '责任人',
field: 'personId',
width:100
},
{
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: 'machineName',
component: 'Input',
rules: 'required',
formItemClass: 'col-span-2',
},
{
label: '设备编码',
fieldName: 'machineCode',
component: 'Input',
rules: 'required',
},
{
label: '设备品牌',
fieldName: 'machineBrand',
component: 'Input',
rules: 'required',
},
{
label: '设备类型',
fieldName: 'machineTypeId',
component: 'TreeSelect',
rules: 'selectRequired',
formItemClass: 'col-span-2',
},
{
label: '位置详情',
fieldName: 'locationId',
component: 'ApiSelect',
rules: 'selectRequired',
formItemClass: 'col-span-2',
},
{
label: '采购价格',
fieldName: 'purchasePrice',
component: 'InputNumber',
componentProps:{
min:0,
precision:2
},
rules: 'required',
},
{
label: '启用时间',
fieldName: 'activationTime',
component: 'DatePicker',
componentProps: {
format: 'YYYY-MM-DD',
valueFormat: 'YYYY-MM-DD',
},
rules: 'required',
},
{
label: '保修截至时间',
fieldName: 'deadline',
component: 'DatePicker',
componentProps: {
format: 'YYYY-MM-DD',
valueFormat: 'YYYY-MM-DD',
},
rules: 'required',
},
{
label: '使用年限',
fieldName: 'serviceLife',
component: 'InputNumber',
componentProps:{
min:1,
precision:0
},
rules: 'required',
},
{
label: '保修周期',
fieldName: 'maintenanceCycle',
component: 'Select',
componentProps: {
options:getDictOptions('wy_sbbxzq')
},
rules: 'selectRequired',
},
{
label: '使用状态',
fieldName: 'state',
component: 'Select',
componentProps:{
options:getDictOptions('wy_sbsyzt')
},
rules: 'selectRequired',
},
{
label: '责任人',
fieldName: 'personId',
component: 'ApiSelect',
rules: 'selectRequired',
formItemClass: 'col-span-2',
},
];

View File

@@ -0,0 +1,204 @@
<script setup lang="ts">
import {Page, useVbenModal, type VbenFormProps} from '@vben/common-ui';
import {getVxePopupContainer} from '@vben/utils';
import {Modal, Popconfirm, Space} from 'ant-design-vue';
import {
useVbenVxeGrid,
vxeCheckboxChecked,
type VxeGridProps
} from '#/adapter/vxe-table';
import {
machineExport,
machineList,
machineRemove,
} from '#/api/property/equipmentManagement/machine';
import type {MachineForm} from '#/api/property/equipmentManagement/machine/model';
import {commonDownloadExcel} from '#/utils/file/download';
import machineModal from './machine-modal.vue';
import {columns, querySchema} from './data';
import MachineTypeTree from '../components/machine-type-tree.vue'
import machineDetail from './machine-detail.vue'
import {ref} from "vue";
const selectTypeId = ref('')
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',
handleReset: async () => {
selectTypeId.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',
},
columns,
height: 'auto',
keepSource: true,
pagerConfig: {},
proxyConfig: {
ajax: {
query: async ({page}, formValues = {}) => {
formValues.machineTypeId = selectTypeId.value
return await machineList({
pageNum: page.currentPage,
pageSize: page.pageSize,
...formValues,
});
},
},
},
rowConfig: {
keyField: 'id',
},
// 表格全局唯一表示 保存列配置需要用到
id: 'property-machine-index'
};
const [BasicTable, tableApi] = useVbenVxeGrid({
formOptions,
gridOptions,
});
const [MachineModal, modalApi] = useVbenModal({
connectedComponent: machineModal,
});
const [MachineDetail, detailApi] = useVbenModal({
connectedComponent: machineDetail,
});
function handleAdd() {
modalApi.setData({});
modalApi.open();
}
async function handleEdit(row: Required<MachineForm>) {
modalApi.setData({id: row.id});
modalApi.open();
}
async function handleInfo(row: Required<MachineForm>) {
detailApi.setData({id: row.id});
detailApi.open();
}
async function handleDelete(row: Required<MachineForm>) {
await machineRemove(row.id);
await tableApi.query();
}
function handleMultiDelete() {
const rows = tableApi.grid.getCheckboxRecords();
const ids = rows.map((row: Required<MachineForm>) => row.id);
Modal.confirm({
title: '提示',
okType: 'danger',
content: `确认删除选中的${ids.length}条记录吗?`,
onOk: async () => {
await machineRemove(ids);
await tableApi.query();
},
});
}
function handleDownloadExcel() {
commonDownloadExcel(machineExport, '设备列表数据', 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="selectTypeId"
class="w-[260px]"
@reload="() => tableApi.reload()"
@select="() => tableApi.reload()"
/>
<BasicTable class="flex-1 overflow-hidden" table-title="设备列表列表">
<template #toolbar-tools>
<Space>
<a-button
v-access:code="['property:machine:export']"
@click="handleDownloadExcel"
>
{{ $t('pages.common.export') }}
</a-button>
<a-button
:disabled="!vxeCheckboxChecked(tableApi)"
danger
type="primary"
v-access:code="['property:machine:remove']"
@click="handleMultiDelete">
{{ $t('pages.common.delete') }}
</a-button>
<a-button
type="primary"
v-access:code="['property:machine:add']"
@click="handleAdd"
>
{{ $t('pages.common.add') }}
</a-button>
</Space>
</template>
<template #action="{ row }">
<Space>
<ghost-button
v-access:code="['property:machine:info']"
@click.stop="handleInfo(row)"
>
{{ $t('pages.common.info') }}
</ghost-button>
<ghost-button
v-access:code="['property:machine: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:machine:remove']"
@click.stop=""
>
{{ $t('pages.common.delete') }}
</ghost-button>
</Popconfirm>
</Space>
</template>
</BasicTable>
</div>
<MachineModal @reload="tableApi.query()"/>
<MachineDetail/>
</Page>
</template>

View File

@@ -0,0 +1,83 @@
<script setup lang="ts">
import {shallowRef} from 'vue';
import {useVbenModal} from '@vben/common-ui';
import {Descriptions, DescriptionsItem} from 'ant-design-vue';
import dayjs from 'dayjs';
import duration from 'dayjs/plugin/duration';
import relativeTime from 'dayjs/plugin/relativeTime';
import {renderDict} from "#/utils/render";
dayjs.extend(duration);
dayjs.extend(relativeTime);
import {CheckboxGroup} from 'ant-design-vue'
import {getDictOptions} from "#/utils/dict";
import {machineInfo} from "#/api/property/equipmentManagement/machine";
import type {MachineVO} from "#/api/property/equipmentManagement/machine/model";
const [BasicModal, modalApi] = useVbenModal({
onOpenChange: handleOpenChange,
onClosed() {
machineDetail.value = null;
},
});
const machineDetail = shallowRef<null | MachineVO>(null);
async function handleOpenChange(open: boolean) {
if (!open) {
return null;
}
modalApi.modalLoading(true);
const {id} = modalApi.getData() as { id: number | string };
machineDetail.value = await machineInfo(id);
modalApi.modalLoading(false);
}
</script>
<template>
<BasicModal :footer="false" :fullscreen-button="false" title="设备详情" class="w-[70%]">
<Descriptions v-if="machineDetail" size="small" :column="2" bordered
:labelStyle="{width:'120px'}">
<DescriptionsItem label="设备名称">
{{ machineDetail.machineName }}
</DescriptionsItem>
<DescriptionsItem label="设备编码">
{{ machineDetail.machineCode }}
</DescriptionsItem>
<DescriptionsItem label="设备品牌">
{{ machineDetail.machineBrand }}
</DescriptionsItem>
<DescriptionsItem label="设备类型">
{{ machineDetail.machineTypeId }}
</DescriptionsItem>
<DescriptionsItem label="位置详情">
{{ machineDetail.locationId }}
</DescriptionsItem>
<DescriptionsItem label="采购价格">
{{ machineDetail.purchasePrice }}
</DescriptionsItem>
<DescriptionsItem label="启用时间">
{{ machineDetail.activationTime }}
</DescriptionsItem>
<DescriptionsItem label="保修截至时间">
{{ machineDetail.deadline }}
</DescriptionsItem>
<DescriptionsItem label="使用年限(年)">
{{ machineDetail.serviceLife }}
</DescriptionsItem>
<DescriptionsItem label="保修周期" v-if="machineDetail.maintenanceCycle!=null">
<component
:is="renderDict(machineDetail.maintenanceCycle,'wy_sbbxzq')"
/>
</DescriptionsItem>
<DescriptionsItem label="使用状态" v-if="machineDetail.state!=null">
<component
:is="renderDict(machineDetail.state,'wy_sbsyzt')"
/>
</DescriptionsItem>
<DescriptionsItem label="责任人" >
{{ machineDetail.personId }}
</DescriptionsItem>
</Descriptions>
</BasicModal>
</template>

View File

@@ -0,0 +1,186 @@
<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 {machineAdd, machineInfo, machineUpdate} from '#/api/property/equipmentManagement/machine';
import {defaultFormValueGetter, useBeforeCloseDiff} from '#/utils/popup';
import {modalSchema} from './data';
import {personList} from "#/api/property/resident/person";
import {renderDictValue} from "#/utils/render";
import {getMachineTypeTree} from "#/api/property/machineType";
import {deviceLocationList} from "#/api/property/equipmentManagement/deviceLocation";
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-1',
// 默认label宽度 px
labelWidth: 110,
// 通用配置项 会影响到所有表单项
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-[70%]',
fullscreenButton: false,
onBeforeClose,
onClosed: handleClosed,
onConfirm: handleConfirm,
onOpenChange: async (isOpen) => {
if (!isOpen) {
return null;
}
modalApi.modalLoading(true);
await queryPersonData()
await setupTypeSelect()
await queryLocationData()
const {id} = modalApi.getData() as { id?: number | string };
isUpdate.value = !!id;
if (isUpdate.value && id) {
const record = await machineInfo(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 ? machineUpdate(data) : machineAdd(data));
resetInitialized();
emit('reload');
modalApi.close();
} catch (error) {
console.error(error);
} finally {
modalApi.lock(false);
}
}
async function handleClosed() {
await formApi.resetForm();
resetInitialized();
}
/**
* 查询负责人数据
*/
async function queryPersonData() {
let params = {
pageSize: 1000,
pageNum: 1,
}
const res = await personList(params);
const options = res.rows.map((user) => ({
label: user.userName + '-' + renderDictValue(user.gender, 'sys_user_sex')
+ '-' + user.phone + '-' + user.unitName,
value: user.id,
}));
formApi.updateSchema([{
componentProps: () => ({
options: options,
showSearch: true,
optionFilterProp: 'label',
optionLabelProp: 'label',
}),
fieldName: 'personId',
}])
}
/**
*初始化设别类型数据
*/
async function setupTypeSelect() {
const typeList = await getMachineTypeTree();
formApi.updateSchema([
{
componentProps: () => ({
class: 'w-full',
fieldNames: {
key: 'id',
label: 'machineTypeName',
value: 'id',
children: 'children',
},
placeholder: '请选择',
showSearch: true,
treeData: typeList,
treeDefaultExpandAll: true,
treeLine: {showLeafIcon: false},
// 筛选的字段
treeNodeFilterProp: 'label',
// 选中后显示在输入框的值
treeNodeLabelProp: 'machineTypeName',
}),
fieldName: 'machineTypeId',
},
]);
}
/**
* 查询设备位置数据
*/
async function queryLocationData() {
let params = {
pageSize: 1000,
pageNum: 1,
}
const res = await deviceLocationList(params);
const options = res.rows.map((item) => ({
label: item.locationName + '-' + renderDictValue(item.locationType, 'pro_location_type'),
value: item.id,
}));
formApi.updateSchema([{
componentProps: () => ({
options: options,
showSearch: true,
optionFilterProp: 'label',
optionLabelProp: 'label',
}),
fieldName: 'locationId',
}])
}
</script>
<template>
<BasicModal :title="title">
<BasicForm/>
</BasicModal>
</template>

View File

@@ -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',
},
];

View File

@@ -0,0 +1,225 @@
<script setup lang="ts">
import type { Recordable } from '@vben/types';
import { ref, onMounted, watch } 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,
machineTypeInfo,
getMachineTypeTree,
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 } from './data';
const selectDeptId = ref<string[]>([]);
// 新增:详情数据
const detailData = ref<any>(null);
interface MachineTypeTree {
id: number;
/**
* antd组件必须要这个属性 实际是没有这个属性的
*/
key: string;
parentId: number;
label: string;
weight: number;
children?: MachineTypeTree[];
}
interface MachineTypeTreeData {
id: number;
label: string;
children?: MachineTypeTreeData[];
}
async function loadDetail() {
// 这里假设 selectDeptId 选中后加载详情,否则加载第一个
let id:any = selectDeptId.value[0];
if (!id) {
// 可选:默认加载第一个类型详情
const res:MachineTypeTree[] = await getMachineTypeTree();
if (res.length > 0 && res[0]) {
id = res[0].id;
}
}
if (id) {
// 获取详情接口
const { machineTypeInfo } = await import('#/api/property/machineType');
detailData.value = await machineTypeInfo(id);
} else {
detailData.value = null;
}
}
onMounted(loadDetail);
watch(selectDeptId, loadDetail);
const treeRef = ref();
function reloadTree() {
treeRef.value?.handleReload?.();
}
const [MachineTypeModal, modalApi] = useVbenModal({
connectedComponent: machineTypeModal,
});
function handleAdd() {
modalApi.setData({});
modalApi.open();
}
async function handleEdit() {
if (detailData.value && detailData.value.id) {
modalApi.setData({ id: detailData.value.id });
modalApi.open();
}
}
async function handleDelete() {
if (detailData.value && detailData.value.id) {
await machineTypeRemove(detailData.value.id);
reloadTree();
await loadDetail();
}
}
// async function handleDelete() {
// if (detailData.value && detailData.value.id) {
// const currentId = detailData.value.id;
// // 1. 获取完整树
// const tree = await getMachineTypeTree();
// // 2. 递归查找当前节点的父节点和同级节点
// function findParentAndSiblings(list:any, targetId:any, parent:any = null) {
// for (const node of list) {
// if (node.id === targetId) {
// return { parent, siblings: list };
// }
// if (node.children && node.children.length) {
// const res:any = findParentAndSiblings(node.children, targetId, node);
// if (res) return res;
// }
// }
// return null;
// }
// const found = findParentAndSiblings(tree, currentId);
// // 3. 删除
// await machineTypeRemove(currentId);
// // 4. 选中逻辑
// let nextId = null;
// if (found) {
// // 同级第一个(排除自己)
// const sameLevel = found.siblings.filter((n:any) => n.id !== currentId);
// if (sameLevel.length > 0) {
// nextId = sameLevel[0].id;
// } else if (found.parent) {
// nextId = found.parent.id;
// }
// }
// // 5. 设置选中
// if (nextId) {
// selectDeptId.value = [nextId];
// } else {
// selectDeptId.value = [];
// }
// // 6. 刷新树和详情
// reloadTree();
// await loadDetail();
// }
// }
function handleDownloadExcel() {
commonDownloadExcel(machineTypeExport, '设备类型数据', {}, {
fieldMappingTime: [],
});
}
</script>
<template>
<Page :auto-content-height="true">
<div class="flex h-full gap-[8px]">
<MachineTypeTree
ref="treeRef"
v-model:select-dept-id="selectDeptId"
class="w-[260px]"
@reload="loadDetail"
@select="loadDetail"
/>
<div class="flex-1">
<!-- 顶部操作按钮 -->
<div class="mb-4 flex gap-2">
<a-button
danger
type="primary"
v-access:code="['property:machineType:remove']"
@click="handleDelete"
:disabled="!detailData || !detailData.id"
>
{{ $t('pages.common.delete') }}
</a-button>
<a-button
type="primary"
v-access:code="['property:machineType:add']"
@click="handleAdd"
>
{{ $t('pages.common.add') }}
</a-button>
<a-button
v-if="detailData && detailData.id"
type="default"
v-access:code="['property:machineType:edit']"
@click="handleEdit"
>
{{ $t('pages.common.edit') }}
</a-button>
</div>
<!-- 详情展示 -->
<a-card v-if="detailData" :title="detailData.machineTypeName">
<a-descriptions
bordered
:column="2"
size="middle"
title="设备类型详情"
class="mb-2"
>
<a-descriptions-item label="类型名称">
{{ detailData.machineTypeName }}
</a-descriptions-item>
<a-descriptions-item label="类型编号">
{{ detailData.machineTypeCode }}
</a-descriptions-item>
<a-descriptions-item label="是否启用">
<a-tag :color="detailData.isEnable == '1' ? 'green' : 'red'">
{{ detailData.isEnable == '1' ? '启用' : '禁用' }}
</a-tag>
</a-descriptions-item>
<a-descriptions-item label="备注">
{{ detailData.remark || '-' }}
</a-descriptions-item>
</a-descriptions>
</a-card>
<a-empty v-else description="暂无详情" />
<MachineTypeModal @reload="() => { reloadTree(); loadDetail(); }" />
</div>
</div>
</Page>
</template>

View File

@@ -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>

View File

@@ -0,0 +1,209 @@
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: 'planName',
label: '计划名称',
},
{
component: 'Select',
fieldName: 'state',
label: '状态',
componentProps: {
options: getDictOptions('wy_state')
},
},
];
export const columns: VxeGridProps['columns'] = [
{type: 'checkbox', width: 60},
{
title: '主键',
field: 'id',
},
{
title: '计划名称',
field: 'planName',
},
{
title: '计划编号',
field: 'planNo',
},
{
title: '设备类型',
field: 'machineTypeId',
},
{
title: '保养周期',
field: 'planPeriod',
slots: {
default: ({row}) => {
return renderDict(row.planPeriod,'wy_sbbyzq')
}
}
},
// {
// title: '保养天',
// field: 'maintainDay',
// },
// {
// title: '保养月',
// field: 'maintainMonth',
// },
// {
// title: '固定天',
// field: 'maintainEveryday',
// },
{
title: '开始时间',
field: 'startDate',
},
{
title: '结束时间',
field: 'endDate',
},
{
title: '状态',
field: 'state',
slots:{
default:'state'
}
},
{
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: 'planName',
component: 'Input',
rules: 'required',
},
{
label: '计划编号',
fieldName: 'planNo',
component: 'Input',
rules: 'required',
},
{
label: '保养周期',
fieldName: 'planPeriod',
component: 'Select',
componentProps: {
options: getDictOptions('wy_sbbyzq')
},
rules: 'selectRequired',
},
{
label: '设备类型',
fieldName: 'machineTypeId',
component: 'TreeSelect',
rules: 'selectRequired',
},
{
label: '月',
fieldName: 'maintainMonth',
component: 'CheckboxGroup',
dependencies: {
show: (formValue) => formValue.planPeriod=='1',
triggerFields: ['planPeriod'],
},
formItemClass: 'col-span-2',
componentProps: {
options: Array.from({ length: 12 }, (_, i) => ({
label: `${i + 1}`,
value: (i + 1).toString(),
})),
},
rules: 'selectRequired',
},
{
label: '日',
fieldName: 'maintainDay',
component: 'CheckboxGroup',
dependencies: {
show: (formValue) => formValue.planPeriod=='1',
triggerFields: ['planPeriod'],
},
formItemClass: 'col-span-2',
componentProps: {
options: Array.from({ length: 31 }, (_, i) => ({
label: `${i + 1}`,
value: (i + 1).toString(),
})),
},
rules: 'selectRequired',
},
{
label: '固定天数',
fieldName: 'maintainEveryday',
component: 'InputNumber',
dependencies: {
show: (formValue) => formValue.planPeriod=='2',
triggerFields: ['planPeriod'],
},
rules:'required',
componentProps:{
min:0,
precision:2,
placeholder:'请填写多少天后保养一次',
},
},
{
label: '计划日期',
fieldName: 'planDate',
component: 'RangePicker',
componentProps: {
format: 'YYYY-MM-DD',
valueFormat: 'YYYY-MM-DD',
},
rules:'required'
},
// {
// label: '开始时间',
// fieldName: 'startDate',
// component: 'DatePicker',
// componentProps: {
// showTime: true,
// format: 'YYYY-MM-DD HH:mm:ss',
// valueFormat: 'YYYY-MM-DD HH:mm:ss',
// },
// rules:'required'
// },
// {
// label: '结束时间',
// fieldName: 'endDate',
// component: 'DatePicker',
// componentProps: {
// showTime: true,
// format: 'YYYY-MM-DD HH:mm:ss',
// valueFormat: 'YYYY-MM-DD HH:mm:ss',
// },
// rules:'required'
// },
// {
// label: '状态(0启用,1停用)',
// fieldName: 'state',
// component: 'Input',
// },
];

View File

@@ -0,0 +1,197 @@
<script setup lang="ts">
import { Page, useVbenModal, type VbenFormProps } from '@vben/common-ui';
import { getVxePopupContainer } from '@vben/utils';
import { Modal, Popconfirm, Space } from 'ant-design-vue';
import {
useVbenVxeGrid,
vxeCheckboxChecked,
type VxeGridProps
} from '#/adapter/vxe-table';
import {
maintainPlanExport,
maintainPlanList,
maintainPlanRemove, maintainPlanUpdate,
} from '#/api/property/equipmentManagement/maintainPlan';
import type { MaintainPlanForm } from '#/api/property/equipmentManagement/maintainPlan/model';
import { commonDownloadExcel } from '#/utils/file/download';
import maintainPlanModal from './maintainPlan-modal.vue';
import { columns, querySchema } from './data';
import planDetail from './plan-detail.vue'
import {TableSwitch} from "#/components/table";
import {useAccess} from "@vben/access";
const { hasAccessByCodes } = useAccess();
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',
};
const gridOptions: VxeGridProps = {
checkboxConfig: {
// 高亮
highlight: true,
// 翻页时保留选中状态
reserve: true,
// 点击行选中
// trigger: 'row',
},
columns,
height: 'auto',
keepSource: true,
pagerConfig: {},
proxyConfig: {
ajax: {
query: async ({ page }, formValues = {}) => {
return await maintainPlanList({
pageNum: page.currentPage,
pageSize: page.pageSize,
...formValues,
});
},
},
},
rowConfig: {
keyField: 'id',
},
// 表格全局唯一表示 保存列配置需要用到
id: 'property-maintainPlan-index'
};
const [BasicTable, tableApi] = useVbenVxeGrid({
formOptions,
gridOptions,
});
const [MaintainPlanModal, modalApi] = useVbenModal({
connectedComponent: maintainPlanModal,
});
const [PlanDetail, detailApi] = useVbenModal({
connectedComponent: planDetail,
});
function handleAdd() {
modalApi.setData({});
modalApi.open();
}
async function handleEdit(row: Required<MaintainPlanForm>) {
modalApi.setData({ id: row.id });
modalApi.open();
}
async function handleInfo(row: Required<MaintainPlanForm>) {
detailApi.setData({ id: row.id });
detailApi.open();
}
async function handleDelete(row: Required<MaintainPlanForm>) {
await maintainPlanRemove(row.id);
await tableApi.query();
}
function handleMultiDelete() {
const rows = tableApi.grid.getCheckboxRecords();
const ids = rows.map((row: Required<MaintainPlanForm>) => row.id);
Modal.confirm({
title: '提示',
okType: 'danger',
content: `确认删除选中的${ids.length}条记录吗?`,
onOk: async () => {
await maintainPlanRemove(ids);
await tableApi.query();
},
});
}
function handleDownloadExcel() {
commonDownloadExcel(maintainPlanExport, '保养计划数据', 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:maintainPlan:export']"
@click="handleDownloadExcel"
>
{{ $t('pages.common.export') }}
</a-button>
<a-button
:disabled="!vxeCheckboxChecked(tableApi)"
danger
type="primary"
v-access:code="['property:maintainPlan:remove']"
@click="handleMultiDelete">
{{ $t('pages.common.delete') }}
</a-button>
<a-button
type="primary"
v-access:code="['property:maintainPlan:add']"
@click="handleAdd"
>
{{ $t('pages.common.add') }}
</a-button>
</Space>
</template>
<template #action="{ row }">
<Space>
<ghost-button
v-access:code="['property:maintainPlan:info']"
@click.stop="handleInfo(row)"
>
{{ $t('pages.common.info') }}
</ghost-button>
<ghost-button
v-access:code="['property:maintainPlan: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:maintainPlan:remove']"
@click.stop=""
>
{{ $t('pages.common.delete') }}
</ghost-button>
</Popconfirm>
</Space>
</template>
<template #state="{row}">
<TableSwitch
:checkedValue="1"
:unCheckedValue="0"
v-model:value="row.state"
:api="() => maintainPlanUpdate(row)"
:disabled="!hasAccessByCodes(['property:depot:edit'])"
@reload="() => tableApi.query()"
/>
</template>
</BasicTable>
<MaintainPlanModal @reload="tableApi.query()" />
<PlanDetail/>
</Page>
</template>

View File

@@ -0,0 +1,153 @@
<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 {
maintainPlanAdd,
maintainPlanInfo,
maintainPlanUpdate
} from '#/api/property/equipmentManagement/maintainPlan';
import {defaultFormValueGetter, useBeforeCloseDiff} from '#/utils/popup';
import {modalSchema} from './data';
import {getMachineTypeTree} from "#/api/property/machineType";
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-1',
// 默认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-[70%]',
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;
await setupTypeSelect();
if (isUpdate.value && id) {
const record = await maintainPlanInfo(id);
record.planDate = [record.startDate, record.endDate]
if (record.planPeriod == '1') {
record.maintainanceMonth = record.maintainanceMonth?.split(',')
record.maintainanceDay = record.maintainanceDay?.split(',')
}
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());
if (data.planDate && data.planDate.length) {
data.startDate = data.planDate[0]
data.endDate = data.planDate[1]
}
if (data.planPeriod == '1') {
data.maintainanceMonth = data.maintainanceMonth?.join(',')
data.maintainanceDay = data.maintainanceDay?.join(',')
data.maintainanceEveryday = undefined
} else {
data.maintainanceMonth = undefined
data.maintainanceDay = undefined
}
await (isUpdate.value ? maintainPlanUpdate(data) : maintainPlanAdd(data));
resetInitialized();
emit('reload');
modalApi.close();
} catch (error) {
console.error(error);
} finally {
modalApi.lock(false);
}
}
async function handleClosed() {
await formApi.resetForm();
resetInitialized();
}
/**
*初始化设别类型数据
*/
async function setupTypeSelect() {
const typeList = await getMachineTypeTree();
formApi.updateSchema([
{
componentProps: () => ({
class: 'w-full',
fieldNames: {
key: 'id',
label: 'machineTypeName',
value: 'id',
children: 'children',
},
placeholder: '请选择',
showSearch: true,
treeData: typeList,
treeDefaultExpandAll: true,
treeLine: {showLeafIcon: false},
// 筛选的字段
treeNodeFilterProp: 'label',
// 选中后显示在输入框的值
treeNodeLabelProp: 'machineTypeName',
}),
fieldName: 'machineTypeId',
},
]);
}
</script>
<template>
<BasicModal :title="title">
<BasicForm/>
</BasicModal>
</template>

View File

@@ -0,0 +1,88 @@
<script setup lang="ts">
import {shallowRef} from 'vue';
import {useVbenModal} from '@vben/common-ui';
import {Descriptions, DescriptionsItem} from 'ant-design-vue';
import dayjs from 'dayjs';
import duration from 'dayjs/plugin/duration';
import relativeTime from 'dayjs/plugin/relativeTime';
import {renderDict} from "#/utils/render";
dayjs.extend(duration);
dayjs.extend(relativeTime);
import {CheckboxGroup} from 'ant-design-vue'
import {getDictOptions} from "#/utils/dict";
import {maintainPlanInfo} from "#/api/property/equipmentManagement/maintainPlan";
import type {MaintainPlanVO} from "#/api/property/equipmentManagement/maintainPlan/model";
const [BasicModal, modalApi] = useVbenModal({
onOpenChange: handleOpenChange,
onClosed() {
maintainPlanDetail.value = null;
},
});
const maintainPlanDetail = shallowRef<null | MaintainPlanVO>(null);
async function handleOpenChange(open: boolean) {
if (!open) {
return null;
}
modalApi.modalLoading(true);
const {id} = modalApi.getData() as { id: number | string };
maintainPlanDetail.value = await maintainPlanInfo(id);
if (maintainPlanDetail.value.planPeriod == '1') {
maintainPlanDetail.value.maintainMonth = maintainPlanDetail.value.maintainMonth?.split(',');
maintainPlanDetail.value.maintainDay = maintainPlanDetail.value.maintainDay?.split(',');
}
modalApi.modalLoading(false);
}
const dayArr=Array.from({ length: 31 }, (_, i) => ({
label: `${i + 1}`,
value: (i + 1).toString(),
}));
const monthArr=Array.from({ length: 12 }, (_, i) => ({
label: `${i + 1}`,
value: (i + 1).toString(),
}))
</script>
<template>
<BasicModal :footer="false" :fullscreen-button="false" title="保养计划详情" class="w-[70%]">
<Descriptions v-if="maintainPlanDetail" size="small" :column="2" bordered
:labelStyle="{width:'100px'}">
<DescriptionsItem label="计划名称">
{{ maintainPlanDetail.planName }}
</DescriptionsItem>
<DescriptionsItem label="计划编号">
{{ maintainPlanDetail.planNo }}
</DescriptionsItem>
<DescriptionsItem label="保养周期" v-if="maintainPlanDetail.planPeriod!=null">
<component
:is="renderDict(maintainPlanDetail.planPeriod,'wy_sbbyzq')"
/>
</DescriptionsItem>
<DescriptionsItem label="设备类型">
{{ maintainPlanDetail.machineTypeId }}
</DescriptionsItem>
<DescriptionsItem label="月" :span="2" v-if="maintainPlanDetail.planPeriod=='1'">
<CheckboxGroup v-model:value="maintainPlanDetail.maintainMonth"
:options="monthArr"/>
</DescriptionsItem>
<DescriptionsItem label="日" :span="2" v-if="maintainPlanDetail.planPeriod=='1'">
<CheckboxGroup v-model:value="maintainPlanDetail.maintainDay"
:options="dayArr"/>
</DescriptionsItem>
<DescriptionsItem label="固定天数" v-if="maintainPlanDetail.planPeriod=='2'">
{{maintainPlanDetail.maintainEveryday}}
</DescriptionsItem>
<DescriptionsItem label="计划日期" :span="2">
{{ maintainPlanDetail.startDate + '\xa0至\xa0' + maintainPlanDetail.endDate }}
</DescriptionsItem>
<DescriptionsItem label="状态" v-if="maintainPlanDetail.state!=null">
<component
:is="renderDict(maintainPlanDetail.state,'wy_state')"
/>
</DescriptionsItem>
</Descriptions>
</BasicModal>
</template>

View File

@@ -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',
},
];

View File

@@ -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>

View File

@@ -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>

View File

@@ -15,10 +15,10 @@ export const querySchema: FormSchemaGetter = () => [
{
component: 'Select',
componentProps: {
options:getDictOptions('wy_xjqdfs')
options:getDictOptions('wy_xjzt')
},
fieldName: 'taskType',
label: '巡检方式',
fieldName: 'status',
label: '巡检状态',
},
];
@@ -73,7 +73,7 @@ export const columns: VxeGridProps['columns'] = [
width:100,
slots: {
default: ({ row }) => {
return renderDict(row.taskType, 'wy_xjqdfs');
return renderDict(row.taskType, 'wy_xjzt');
},
},
},

View File

@@ -3,7 +3,7 @@ import { computed, ref } from 'vue';
import { useVbenModal } from '@vben/common-ui';
import { $t } from '@vben/locales';
import {cloneDeep, getPopupContainer, handleNode} from '@vben/utils';
import {cloneDeep, handleNode} from '@vben/utils';
import { useVbenForm } from '#/adapter/form';
import { resident_unitAdd, resident_unitInfo, resident_unitUpdate } from '#/api/property/resident/unit';
@@ -108,7 +108,6 @@ async function initLocationOptions() {
value: 'code',
children: 'children',
},
getPopupContainer,
placeholder: '请选择入驻位置',
showSearch: true,
treeData: locationList,