feat: 完成巡检任务

This commit is contained in:
fyy
2025-07-15 16:12:11 +08:00
parent 1ed923c969
commit bd762452f8
7 changed files with 93 additions and 127 deletions

View File

@@ -67,6 +67,7 @@ const [BasicForm, formApi] = useVbenForm({
class: 'w-full', class: 'w-full',
disabled: isReadonly.value, disabled: isReadonly.value,
})), })),
schema: modalSchema(isReadonly.value),
}, },
// 1. 使用正确的属性名 handleValuesChange // 1. 使用正确的属性名 handleValuesChange
handleValuesChange: async (values, fieldsChanged) => { handleValuesChange: async (values, fieldsChanged) => {
@@ -327,6 +328,8 @@ async function handleConfirm() {
return; return;
} }
const data = cloneDeep(await formApi.getValues()); const data = cloneDeep(await formApi.getValues());
console.log(data);
// 单位数据缓存 // 单位数据缓存
if (unitListData.length === 0) { if (unitListData.length === 0) {
const res = await resident_unitList(); const res = await resident_unitList();
@@ -340,10 +343,9 @@ async function handleConfirm() {
data.name = cleanObj ? cleanObj.name : data.name || ''; data.name = cleanObj ? cleanObj.name : data.name || '';
data.unitId = unitObj ? unitObj.id : isUpdate.value ? editUnitId.value : ''; data.unitId = unitObj ? unitObj.id : isUpdate.value ? editUnitId.value : '';
data.sumPeices = Number(totalSumPeices.value) data.sumPeices = Number(totalSumPeices.value)
// data.sumPeices = parseInt(totalSumPeices.value, 10);
// 组装 cleanIds
// data.cleanIds = detailTable.value.map((item: any) => item.id);
data.cleanList = detailTable.value; data.cleanList = detailTable.value;
if (data.starTime) data.starTime = dayjs(data.starTime).format('YYYY-MM-DD HH:mm:ss');
if (data.endTime) data.endTime = dayjs(data.endTime).format('YYYY-MM-DD HH:mm:ss');
isUpdate.value ? await clean_orderUpdate({...data,id:editCleanOrderId.value}) : await clean_orderAdd(data); isUpdate.value ? await clean_orderUpdate({...data,id:editCleanOrderId.value}) : await clean_orderAdd(data);
resetInitialized(); resetInitialized();
emit('reload'); emit('reload');

View File

@@ -131,7 +131,7 @@ export const columns: VxeGridProps['columns'] = [
]; ];
export const modalSchema: FormSchemaGetter = () => [ export const modalSchema: (isReadonly: boolean) => FormSchema[] = (isReadonly) => [
{ {
label: '主键id', label: '主键id',
fieldName: 'id', fieldName: 'id',
@@ -167,7 +167,7 @@ export const modalSchema: FormSchemaGetter = () => [
showTime: true, showTime: true,
format: 'YYYY-MM-DD HH:mm:ss', format: 'YYYY-MM-DD HH:mm:ss',
placeholder: !values.starTime?'请先选择开始时间':`请选择结束时间(结束时间不能早于开始时间)`, placeholder: !values.starTime?'请先选择开始时间':`请选择结束时间(结束时间不能早于开始时间)`,
disabled: !values.starTime, // 没选开始时间时禁用 disabled: isReadonly || !values.starTime, // 没选开始时间时禁用
disabledDate: (current:any) => { disabledDate: (current:any) => {
if (!values.starTime) return false; if (!values.starTime) return false;
// 只允许选择大于等于开始时间的日期 // 只允许选择大于等于开始时间的日期

View File

@@ -39,29 +39,7 @@ const detailSchema = [
api: async () => { api: async () => {
const res = await plantsProductList({state:1,inventory:0}); const res = await plantsProductList({state:1,inventory:0});
plantListData = res.rows || []; plantListData = res.rows || [];
return res;
// 获取当前模态框的数据,包含已添加的产品列表
const modalData = modalApi.getData();
const existingProducts = modalData?.existingProducts || [];
const currentProductId = modalData?.currentProductId;
// 过滤掉已经添加到产品列表中的产品
// 如果是编辑模式,需要排除当前正在编辑的产品
const filteredRows = res.rows.filter((item: any) => {
// 如果是编辑模式且是当前正在编辑的产品,则保留
if (currentProductId && item.id === currentProductId) {
return true;
}
// 过滤掉已添加的产品
return !existingProducts.some((existing: any) =>
existing.productId === item.id || existing.id === item.id
);
});
return {
...res,
rows: filteredRows
};
}, },
resultField: 'rows', resultField: 'rows',
labelField: 'plantName', labelField: 'plantName',

View File

@@ -29,10 +29,10 @@ const [BasicForm, formApi] = useVbenForm({
// 默认label宽度 px // 默认label宽度 px
labelWidth: 120, labelWidth: 120,
// 通用配置项 会影响到所有表单项 // 通用配置项 会影响到所有表单项
componentProps: { componentProps: computed(() => ({
class: 'w-full', class: 'w-full',
disabled: isReadonly, disabled: isReadonly.value,
}, })),
}, },
schema: modalSchema(), schema: modalSchema(),
showDefaultActions: false, showDefaultActions: false,
@@ -143,13 +143,10 @@ const detailColumns = [
title: '操作', title: '操作',
key: 'action', key: 'action',
fixed: 'right' as const, fixed: 'right' as const,
width: 200,
}, },
]; ];
function handleAddDetail() { function handleAddDetail() {
detailModalApi.setData({ detailModalApi.setData({});
existingProducts: detailTable.value
});
detailModalApi.open(); detailModalApi.open();
} }
//添加植物组合包产品 //添加植物组合包产品
@@ -172,13 +169,7 @@ function handleViewDetail(record: any) {
} }
// 编辑产品详情 // 编辑产品详情
function handleEditDetail(record: any, index: number) { function handleEditDetail(record: any, index: number) {
detailModalApi.setData({ detailModalApi.setData({ ...record, index, readonly: false });
...record,
index,
readonly: false,
existingProducts: detailTable.value.filter((item: any, i: number) => i !== index),
currentProductId: record.productId || record.id
});
detailModalApi.open(); detailModalApi.open();
} }
//分类字典 //分类字典

View File

@@ -1,41 +1,23 @@
import type { FormSchemaGetter } from '#/adapter/form'; import type { FormSchemaGetter } from '#/adapter/form';
import type { VxeGridProps } from '#/adapter/vxe-table'; import type { VxeGridProps } from '#/adapter/vxe-table';
import { getDictOptions } from '#/utils/dict';
import { renderDict } from '#/utils/render';
export const querySchema: FormSchemaGetter = () => [ export const querySchema: FormSchemaGetter = () => [
// {
{ // component: 'Input',
component: 'DatePicker', // fieldName: 'actUserId',
componentProps: { // label: '当前巡检人',
showTime: true, // labelWidth: 160,
format: 'YYYY-MM-DD HH:mm:ss', // },
valueFormat: 'YYYY-MM-DD HH:mm:ss',
},
fieldName: 'actInsTime',
label: '实际巡检时间',
labelWidth: 120,
},
{
component: 'Input',
fieldName: 'actUserId',
label: '当前巡检人',
},
{ {
component: 'Select', component: 'Select',
componentProps: { componentProps: {
}, options:getDictOptions('wy_xjzt')
fieldName: 'taskType',
label: '巡检方式',
},
{
component: 'RadioGroup',
componentProps: {
buttonStyle: 'solid',
optionType: 'button',
}, },
fieldName: 'status', fieldName: 'status',
label: '巡检状态', label: '巡检状态',
labelWidth: 160,
}, },
]; ];
@@ -56,50 +38,58 @@ export const columns: VxeGridProps['columns'] = [
{ {
title: '巡检计划', title: '巡检计划',
field: 'planName', field: 'planName',
width:'auto' minWidth: 120,
}, },
{ {
title: '巡检开始日期', title: '巡检开始结束日期',
field: 'startDate', field: 'planInsTime',
width:180 minWidth:280
},
{
title: '巡检结束日期',
field: 'endDate',
width:180
},
{
title: '实际巡检时间',
field: 'actInsTime',
width:180
},
{
title: '当前巡检人',
field: 'actUserId',
width:'auto'
}, },
// {
// title: '当前巡检人',
// field: 'actUserId',
// width:'auto'
// },
{ {
title: '巡检方式', title: '巡检方式',
field: 'taskType', field: 'taskType',
width:'auto' width:'auto',
slots: {
default: ({ row }) => {
return renderDict(row.taskType, 'wy_xjqdfs');
},
},
}, },
{ {
title: '转移描述', title: '转移描述',
field: 'transferDesc', field: 'transferDesc',
width:200 width:200,
slots: {
default: ({ row }) => {
return row.transferDesc?row.transferDesc:'--';
},
},
}, },
{ {
title: '巡检状态', title: '巡检状态',
field: 'status', field: 'status',
width:'auto',
slots: {
default: ({ row }) => {
return renderDict(row.status, 'wy_xjzt');
},
},
}, },
{ {
title: '备注', title: '备注',
field: 'remark', field: 'remark',
width:'auto',
slots: {
default: ({ row }) => {
return row.remark?row.remark:'--';
},
},
}, },
{ {
field: 'action', field: 'action',
@@ -126,54 +116,45 @@ export const modalSchema: FormSchemaGetter = () => [
component: 'Input', component: 'Input',
}, },
{ {
label: '巡检开始日期', label: '巡检开始结束日期',
fieldName: 'startDate', fieldName: 'planInsTime',
component: 'Input',
},
{
label: '巡检结束日期',
fieldName: 'endDate',
component: 'Input',
},
{
label: '实际巡检时间',
fieldName: 'actInsTime',
component: 'DatePicker',
componentProps: {
showTime: true,
format: 'YYYY-MM-DD HH:mm:ss',
valueFormat: 'YYYY-MM-DD HH:mm:ss',
},
},
{
label: '当前巡检人',
fieldName: 'actUserId',
component: 'Input', component: 'Input',
}, },
// {
// label: '当前巡检人',
// fieldName: 'actUserId',
// component: 'Input',
// },
{ {
label: '巡检方式', label: '巡检方式',
fieldName: 'taskType', fieldName: 'taskType',
component: 'Select', component: 'Select',
componentProps: { componentProps: {
options: getDictOptions('wy_xjqdfs'),
}, },
}, },
{ {
label: '转移描述', label: '转移描述',
fieldName: 'transferDesc', fieldName: 'transferDesc',
component: 'Textarea', component: 'Textarea',
componentProps:{
placeholder:''
}
}, },
{ {
label: '巡检状态', label: '巡检状态',
fieldName: 'status', fieldName: 'status',
component: 'RadioGroup', component: 'Select',
componentProps: { componentProps: {
buttonStyle: 'solid', options: getDictOptions('wy_xjzt'),
optionType: 'button',
}, },
}, },
{ {
label: '备注', label: '备注',
fieldName: 'remark', fieldName: 'remark',
component: 'Input', component: 'Input',
componentProps:{
placeholder:''
}
} }
]; ];

View File

@@ -155,17 +155,17 @@ function handleDownloadExcel() {
</template> </template>
<template #action="{ row }"> <template #action="{ row }">
<Space> <Space>
<!-- <ghost-button <ghost-button
v-access:code="['property:inspectionTask:edit']" v-access:code="['property:inspectionTask:edit']"
@click.stop="handleEdit(row)" @click.stop="handleEdit(row)"
> >详情
{{ $t('pages.common.edit') }} </ghost-button>
</ghost-button> -->
<Popconfirm <Popconfirm
:get-popup-container="getVxePopupContainer" :get-popup-container="getVxePopupContainer"
placement="left" placement="left"
title="确认删除?" title="确认删除?"
@confirm="handleDelete(row)" @confirm="handleDelete(row)"
v-if="row.status == 0 || row.status == 3"
> >
<ghost-button <ghost-button
danger danger

View File

@@ -15,7 +15,7 @@ const emit = defineEmits<{ reload: [] }>();
const isUpdate = ref(false); const isUpdate = ref(false);
const title = computed(() => { const title = computed(() => {
return isUpdate.value ? $t('pages.common.edit') : $t('pages.common.add'); return isUpdate.value ? '详情' : $t('pages.common.add');
}); });
const [BasicForm, formApi] = useVbenForm({ const [BasicForm, formApi] = useVbenForm({
@@ -27,6 +27,7 @@ const [BasicForm, formApi] = useVbenForm({
// 通用配置项 会影响到所有表单项 // 通用配置项 会影响到所有表单项
componentProps: { componentProps: {
class: 'w-full', class: 'w-full',
disabled:true
} }
}, },
schema: modalSchema(), schema: modalSchema(),
@@ -48,6 +49,7 @@ const [BasicModal, modalApi] = useVbenModal({
onBeforeClose, onBeforeClose,
onClosed: handleClosed, onClosed: handleClosed,
onConfirm: handleConfirm, onConfirm: handleConfirm,
onOpenChange: async (isOpen) => { onOpenChange: async (isOpen) => {
if (!isOpen) { if (!isOpen) {
return null; return null;
@@ -75,8 +77,8 @@ async function handleConfirm() {
return; return;
} }
// getValues获取为一个readonly的对象 需要修改必须先深拷贝一次 // getValues获取为一个readonly的对象 需要修改必须先深拷贝一次
const data = cloneDeep(await formApi.getValues()); // const data = cloneDeep(await formApi.getValues());
await (isUpdate.value ? inspectionTaskUpdate(data) : inspectionTaskAdd(data)); // await (isUpdate.value ? inspectionTaskUpdate(data) : inspectionTaskAdd(data));
resetInitialized(); resetInitialized();
emit('reload'); emit('reload');
modalApi.close(); modalApi.close();
@@ -98,4 +100,16 @@ async function handleClosed() {
<BasicForm /> <BasicForm />
</BasicModal> </BasicModal>
</template> </template>
<style scoped>
/* 使用 :deep() 穿透 scoped 样式,影响子组件 */
:deep(.ant-input[disabled]),
:deep(.ant-input-number-disabled .ant-input-number-input),
:deep(.ant-select-disabled .ant-select-selection-item),
:deep(.ant-picker-disabled .ant-picker-input > input) {
/* 设置一个更深的颜色 */
color: rgb(0 0 0 / 65%) !important;
/* 有些浏览器需要这个来覆盖默认颜色 */
-webkit-text-fill-color: rgb(0 0 0 / 65%) !important;
}
</style>