2、保养计划
This commit is contained in:
@@ -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}`);
|
||||
}
|
204
apps/web-antd/src/api/property/equipmentManagement/machine/model.d.ts
vendored
Normal file
204
apps/web-antd/src/api/property/equipmentManagement/machine/model.d.ts
vendored
Normal 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;
|
||||
}
|
@@ -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}`);
|
||||
}
|
174
apps/web-antd/src/api/property/equipmentManagement/maintainPlan/model.d.ts
vendored
Normal file
174
apps/web-antd/src/api/property/equipmentManagement/maintainPlan/model.d.ts
vendored
Normal 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;
|
||||
}
|
@@ -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',
|
||||
},
|
||||
];
|
@@ -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>
|
@@ -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>
|
@@ -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>
|
||||
|
@@ -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',
|
||||
// },
|
||||
];
|
@@ -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>
|
@@ -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>
|
||||
|
@@ -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>
|
@@ -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');
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@@ -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,
|
||||
|
Reference in New Issue
Block a user