|
@@ -26,11 +26,6 @@
|
|
/>
|
|
/>
|
|
</el-select>
|
|
</el-select>
|
|
</el-form-item>
|
|
</el-form-item>
|
|
- <!--
|
|
|
|
- <el-form-item label="工单编号" prop="orderNumber">
|
|
|
|
- <el-input type="text" v-model="formData.orderNumber" disabled/>
|
|
|
|
- </el-form-item>
|
|
|
|
- -->
|
|
|
|
</el-col>
|
|
</el-col>
|
|
<el-col :span="8">
|
|
<el-col :span="8">
|
|
<el-form-item :label="t('mainPlan.MaintenanceCost')" prop="cost">
|
|
<el-form-item :label="t('mainPlan.MaintenanceCost')" prop="cost">
|
|
@@ -82,24 +77,6 @@
|
|
</el-form>
|
|
</el-form>
|
|
</ContentWrap>
|
|
</ContentWrap>
|
|
<ContentWrap>
|
|
<ContentWrap>
|
|
- <ContentWrap>
|
|
|
|
- <!-- 搜索工作栏 -->
|
|
|
|
- <el-form
|
|
|
|
- class="-mb-15px"
|
|
|
|
- :model="queryParams"
|
|
|
|
- ref="queryFormRef"
|
|
|
|
- :inline="true"
|
|
|
|
- label-width="68px"
|
|
|
|
- >
|
|
|
|
- <!--
|
|
|
|
- <el-form-item>
|
|
|
|
- <el-button @click="openForm" type="warning">
|
|
|
|
- <Icon icon="ep:plus" class="mr-5px" /> 新增设备</el-button>
|
|
|
|
- </el-form-item>
|
|
|
|
- -->
|
|
|
|
- </el-form>
|
|
|
|
- </ContentWrap>
|
|
|
|
-
|
|
|
|
<!-- 列表 -->
|
|
<!-- 列表 -->
|
|
<ContentWrap>
|
|
<ContentWrap>
|
|
<el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
|
|
<el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
|
|
@@ -115,7 +92,13 @@
|
|
<el-table-column :label="t('iotDevice.name')" align="center" prop="deviceName" />
|
|
<el-table-column :label="t('iotDevice.name')" align="center" prop="deviceName" />
|
|
<el-table-column :label="t('operationFillForm.sumTime')" align="center" prop="totalRunTime" :formatter="erpPriceTableColumnFormatter"/>
|
|
<el-table-column :label="t('operationFillForm.sumTime')" align="center" prop="totalRunTime" :formatter="erpPriceTableColumnFormatter"/>
|
|
<el-table-column :label="t('operationFillForm.sumKil')" align="center" prop="totalMileage" :formatter="erpPriceTableColumnFormatter"/>
|
|
<el-table-column :label="t('operationFillForm.sumKil')" align="center" prop="totalMileage" :formatter="erpPriceTableColumnFormatter"/>
|
|
- <el-table-column :label="t('mainPlan.MaintItems')" align="center" prop="name" />
|
|
|
|
|
|
+ <el-table-column :label="t('mainPlan.MaintItems')" align="center" prop="name" :show-overflow-tooltip="false" :width="maintItemsWidth" >
|
|
|
|
+ <template #default="{ row }">
|
|
|
|
+ <div class="full-content-cell"> <!-- 自定义样式 -->
|
|
|
|
+ {{ row.name }}
|
|
|
|
+ </div>
|
|
|
|
+ </template>
|
|
|
|
+ </el-table-column>
|
|
<el-table-column :label="t('main.mileage')" key="mileageRule" width="80">
|
|
<el-table-column :label="t('main.mileage')" key="mileageRule" width="80">
|
|
<template #default="scope">
|
|
<template #default="scope">
|
|
<el-switch
|
|
<el-switch
|
|
@@ -146,48 +129,75 @@
|
|
/>
|
|
/>
|
|
</template>
|
|
</template>
|
|
</el-table-column>
|
|
</el-table-column>
|
|
|
|
+ <el-table-column
|
|
|
|
+ v-if="shouldShowRunningTimeColumn"
|
|
|
|
+ :label="t('mainPlan.RunTimeCycle')"
|
|
|
|
+ align="center"
|
|
|
|
+ width="120"
|
|
|
|
+ >
|
|
|
|
+ <template #default="scope">
|
|
|
|
+ <el-input-number
|
|
|
|
+ v-if="scope.row.runningTimeRule === 0"
|
|
|
|
+ v-model="scope.row.nextRunningTime"
|
|
|
|
+ :precision="1"
|
|
|
|
+ :min="1"
|
|
|
|
+ :controls="false"
|
|
|
|
+ style="width: 100%"
|
|
|
|
+ @change="validateRunningTime(scope.row)"
|
|
|
|
+ />
|
|
|
|
+ <span v-else>-</span>
|
|
|
|
+ <!-- 错误提示 -->
|
|
|
|
+ <div v-if="scope.row.timeError" class="error-text">
|
|
|
|
+ {{ scope.row.timeError }}
|
|
|
|
+ </div>
|
|
|
|
+ </template>
|
|
|
|
+ </el-table-column>
|
|
<el-table-column :label="t('common.status')" align="center" width="100">
|
|
<el-table-column :label="t('common.status')" align="center" width="100">
|
|
<template #default="scope">
|
|
<template #default="scope">
|
|
{{ getStatusText(scope.row) }}
|
|
{{ getStatusText(scope.row) }}
|
|
</template>
|
|
</template>
|
|
</el-table-column>
|
|
</el-table-column>
|
|
- <el-table-column :label="t('iotMaintain.numberOfMaterials')" align="center" width="180">
|
|
|
|
|
|
+ <el-table-column :label="t('iotMaintain.numberOfMaterials')" align="center" width="90">
|
|
<template #default="scope">
|
|
<template #default="scope">
|
|
{{ getMaterialCount(scope.row.bomNodeId) }}
|
|
{{ getMaterialCount(scope.row.bomNodeId) }}
|
|
</template>
|
|
</template>
|
|
</el-table-column>
|
|
</el-table-column>
|
|
<el-table-column :label="t('iotMaintain.operation')" align="center" min-width="120px">
|
|
<el-table-column :label="t('iotMaintain.operation')" align="center" min-width="120px">
|
|
<template #default="scope">
|
|
<template #default="scope">
|
|
- <div style="display: flex; justify-content: center; align-items: center; width: 100%">
|
|
|
|
- <!-- 新增配置按钮 -->
|
|
|
|
- <div style="margin-left: 12px" v-if="scope.row.status === 0">
|
|
|
|
- <el-button
|
|
|
|
- link
|
|
|
|
- type="primary"
|
|
|
|
- @click="openConfigDialog(scope.row)"
|
|
|
|
- >
|
|
|
|
- {{ t('stock.DelayMaintenance') }}
|
|
|
|
- </el-button>
|
|
|
|
- </div>
|
|
|
|
- <div style="margin-left: 12px" v-if="scope.row.status === 0">
|
|
|
|
- <el-button
|
|
|
|
- link
|
|
|
|
- type="primary"
|
|
|
|
- @click="openMaterialForm(scope.row)"
|
|
|
|
- >
|
|
|
|
- {{ t('stock.selectMaterial') }}
|
|
|
|
- </el-button>
|
|
|
|
- </div>
|
|
|
|
- <div style="margin-left: 12px">
|
|
|
|
- <el-button
|
|
|
|
- link
|
|
|
|
- type="primary"
|
|
|
|
- @click="handleView(scope.row)"
|
|
|
|
- >
|
|
|
|
- {{ t('bomList.materialDetail') }}
|
|
|
|
- </el-button>
|
|
|
|
- </div>
|
|
|
|
- </div>
|
|
|
|
|
|
+ <el-dropdown trigger="hover" @command="handleDropdownCommand">
|
|
|
|
+ <el-button type="primary" link>
|
|
|
|
+ {{ t('action.more') }}<el-icon><arrow-down /></el-icon>
|
|
|
|
+ </el-button>
|
|
|
|
+ <template #dropdown>
|
|
|
|
+ <el-dropdown-menu>
|
|
|
|
+ <!-- 延迟保养按钮 -->
|
|
|
|
+ <el-dropdown-item
|
|
|
|
+ v-if="scope.row.status === 0"
|
|
|
|
+ :command="{ action: 'delay', row: scope.row }"
|
|
|
|
+ :icon="Clock"
|
|
|
|
+ >
|
|
|
|
+ {{ t('stock.DelayMaintenance') }}
|
|
|
|
+ </el-dropdown-item>
|
|
|
|
+
|
|
|
|
+ <!-- 选择物料按钮 -->
|
|
|
|
+ <el-dropdown-item
|
|
|
|
+ v-if="scope.row.status === 0"
|
|
|
|
+ :command="{ action: 'material', row: scope.row }"
|
|
|
|
+ :icon="Box"
|
|
|
|
+ >
|
|
|
|
+ {{ t('stock.selectMaterial') }}
|
|
|
|
+ </el-dropdown-item>
|
|
|
|
+
|
|
|
|
+ <!-- 物料详情按钮 -->
|
|
|
|
+ <el-dropdown-item
|
|
|
|
+ :command="{ action: 'detail', row: scope.row }"
|
|
|
|
+ :icon="Document"
|
|
|
|
+ >
|
|
|
|
+ {{ t('bomList.materialDetail') }}
|
|
|
|
+ </el-dropdown-item>
|
|
|
|
+ </el-dropdown-menu>
|
|
|
|
+ </template>
|
|
|
|
+ </el-dropdown>
|
|
</template>
|
|
</template>
|
|
</el-table-column>
|
|
</el-table-column>
|
|
</el-table>
|
|
</el-table>
|
|
@@ -478,6 +488,8 @@ import MaterialListDrawer from "@/views/pms/iotmainworkorder/SelectedMaterialDra
|
|
import WorkOrderMaterial from "@/views/pms/iotmainworkorder/WorkOrderMaterial.vue";
|
|
import WorkOrderMaterial from "@/views/pms/iotmainworkorder/WorkOrderMaterial.vue";
|
|
import { IotDevicePersonApi, IotDevicePersonVO } from '@/api/pms/iotdeviceperson'
|
|
import { IotDevicePersonApi, IotDevicePersonVO } from '@/api/pms/iotdeviceperson'
|
|
import {DICT_TYPE, getIntDictOptions} from "@/utils/dict";
|
|
import {DICT_TYPE, getIntDictOptions} from "@/utils/dict";
|
|
|
|
+// 引入图标
|
|
|
|
+import { ArrowDown, Clock, Box, Document } from '@element-plus/icons-vue';
|
|
|
|
|
|
/** 保养计划 表单 */
|
|
/** 保养计划 表单 */
|
|
defineOptions({ name: 'IotMainWorkOrderBom' })
|
|
defineOptions({ name: 'IotMainWorkOrderBom' })
|
|
@@ -506,6 +518,9 @@ const devicePersonsMap = ref<Map<number, Set<string>>>(new Map()) // 存储设
|
|
// 控制抽屉额外列的显示
|
|
// 控制抽屉额外列的显示
|
|
const hideExtraColumnsInDrawer = ref(false)
|
|
const hideExtraColumnsInDrawer = ref(false)
|
|
|
|
|
|
|
|
+// 新增响应式变量
|
|
|
|
+const maintItemsWidth = ref('auto')
|
|
|
|
+
|
|
const formData = ref({
|
|
const formData = ref({
|
|
id: undefined,
|
|
id: undefined,
|
|
deptId: undefined,
|
|
deptId: undefined,
|
|
@@ -658,6 +673,30 @@ const openConfigDialog = (row: IotMainWorkOrderBomVO) => {
|
|
configDialog.visible = true
|
|
configDialog.visible = true
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+// 运行时间周期 单行校验方法
|
|
|
|
+const validateRunningTime = (row: IotMainWorkOrderBomVO) => {
|
|
|
|
+ if (row.runningTimeRule === 0 && (!row.nextRunningTime || row.nextRunningTime <= 0)) {
|
|
|
|
+ row.timeError = t('mainPlan.runningTimeCycleError');
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ row.timeError = '';
|
|
|
|
+ return true;
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+// 运行时间周期 全局校验方法(在submitForm中调用)
|
|
|
|
+const validateAllRunningTimes = (): boolean => {
|
|
|
|
+ let isValid = true;
|
|
|
|
+ list.value.forEach(row => {
|
|
|
|
+ if (row.runningTimeRule === 0 && (!row.nextRunningTime || row.nextRunningTime <= 0)) {
|
|
|
|
+ isValid = false;
|
|
|
|
+ // 高亮标记错误行
|
|
|
|
+ row.timeError = t('mainPlan.runningTimeCycleError');
|
|
|
|
+ message.error(`${t('mainPlan.runningTimeCycleError')}: ${row.deviceCode}-${row.name}`);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ return isValid;
|
|
|
|
+};
|
|
|
|
+
|
|
// const materialFormRef = ref()
|
|
// const materialFormRef = ref()
|
|
const openMaterialForm = (row: any) => {
|
|
const openMaterialForm = (row: any) => {
|
|
bomNodeId.value = row.bomNodeId;
|
|
bomNodeId.value = row.bomNodeId;
|
|
@@ -691,6 +730,11 @@ const selectChoose = (selectedMaterial) => {
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+// 计算属性:判断是否需要显示运行时间周期列
|
|
|
|
+const shouldShowRunningTimeColumn = computed(() => {
|
|
|
|
+ return list.value.some(item => item.runningTimeRule === 0);
|
|
|
|
+});
|
|
|
|
+
|
|
/** 查看已经选择的物料 并编辑 */
|
|
/** 查看已经选择的物料 并编辑 */
|
|
const handleView = (row: IotMainWorkOrderBomVO) => {
|
|
const handleView = (row: IotMainWorkOrderBomVO) => {
|
|
currentBomNodeId.value = row.bomNodeId
|
|
currentBomNodeId.value = row.bomNodeId
|
|
@@ -890,6 +934,12 @@ const emit = defineEmits(['success']) // 定义 success 事件,用于操作成
|
|
const submitForm = async () => {
|
|
const submitForm = async () => {
|
|
// 校验表单
|
|
// 校验表单
|
|
await formRef.value.validate()
|
|
await formRef.value.validate()
|
|
|
|
+
|
|
|
|
+ // 运行时间周期全局校验
|
|
|
|
+ if (!validateAllRunningTimes()) {
|
|
|
|
+ return; // 校验失败则终止提交
|
|
|
|
+ }
|
|
|
|
+
|
|
// 校验表格数据
|
|
// 校验表格数据
|
|
const isValid = validateTableData()
|
|
const isValid = validateTableData()
|
|
if (!isValid) return
|
|
if (!isValid) return
|
|
@@ -969,6 +1019,48 @@ const configFormRules = reactive({
|
|
]
|
|
]
|
|
})
|
|
})
|
|
|
|
|
|
|
|
+// 计算文本宽度的辅助函数
|
|
|
|
+const getTextWidth = (text: string): number => {
|
|
|
|
+ const span = document.createElement('span')
|
|
|
|
+ span.style.visibility = 'hidden'
|
|
|
|
+ span.style.position = 'absolute'
|
|
|
|
+ span.style.whiteSpace = 'nowrap'
|
|
|
|
+ span.style.fontSize = '14px' // 与表格实际字体一致
|
|
|
|
+ span.style.fontFamily = 'inherit'
|
|
|
|
+ span.innerText = text
|
|
|
|
+ document.body.appendChild(span)
|
|
|
|
+ const width = span.offsetWidth
|
|
|
|
+ document.body.removeChild(span)
|
|
|
|
+ return width
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// 计算列宽的主函数
|
|
|
|
+const calculateMaintItemsWidth = () => {
|
|
|
|
+ if (list.value.length === 0) {
|
|
|
|
+ maintItemsWidth.value = 'auto'
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 1. 计算表头文本宽度
|
|
|
|
+ const headerText = t('mainPlan.MaintItems')
|
|
|
|
+ const headerWidth = getTextWidth(headerText)
|
|
|
|
+
|
|
|
|
+ // 2. 计算内容最大宽度
|
|
|
|
+ let contentMaxWidth = 0
|
|
|
|
+ list.value.forEach(item => {
|
|
|
|
+ if (item.name) {
|
|
|
|
+ const width = getTextWidth(item.name.toString())
|
|
|
|
+ if (width > contentMaxWidth) {
|
|
|
|
+ contentMaxWidth = width
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+
|
|
|
|
+ // 3. 取最大值 + 内边距(20px)
|
|
|
|
+ const maxWidth = Math.max(headerWidth, contentMaxWidth) + 20
|
|
|
|
+ maintItemsWidth.value = `${maxWidth}px`
|
|
|
|
+}
|
|
|
|
+
|
|
const getStatusText = (row: any) => {
|
|
const getStatusText = (row: any) => {
|
|
// 状态为1直接返回"完成"
|
|
// 状态为1直接返回"完成"
|
|
if (row.status === 1) return t('mainPlan.completed');
|
|
if (row.status === 1) return t('mainPlan.completed');
|
|
@@ -987,6 +1079,26 @@ const getStatusText = (row: any) => {
|
|
return t('mainPlan.maintaining');
|
|
return t('mainPlan.maintaining');
|
|
};
|
|
};
|
|
|
|
|
|
|
|
+// 监听数据变化重新计算
|
|
|
|
+watch(() => list.value, () => {
|
|
|
|
+ calculateMaintItemsWidth()
|
|
|
|
+}, { deep: true })
|
|
|
|
+
|
|
|
|
+// 下拉菜单命令处理
|
|
|
|
+const handleDropdownCommand = (command: { action: string; row: IotMainWorkOrderBomVO }) => {
|
|
|
|
+ switch (command.action) {
|
|
|
|
+ case 'delay':
|
|
|
|
+ openConfigDialog(command.row);
|
|
|
|
+ break;
|
|
|
|
+ case 'material':
|
|
|
|
+ openMaterialForm(command.row);
|
|
|
|
+ break;
|
|
|
|
+ case 'detail':
|
|
|
|
+ handleView(command.row);
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+};
|
|
|
|
+
|
|
/** 校验表格数据 */
|
|
/** 校验表格数据 */
|
|
const validateTableData = (): boolean => {
|
|
const validateTableData = (): boolean => {
|
|
let isValid = true;
|
|
let isValid = true;
|
|
@@ -1082,6 +1194,22 @@ const resetForm = () => {
|
|
formRef.value?.resetFields()
|
|
formRef.value?.resetFields()
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+// 防抖函数实现
|
|
|
|
+function debounce(func: Function, wait: number) {
|
|
|
|
+ let timeout: ReturnType<typeof setTimeout> | null
|
|
|
|
+ return function executedFunction(...args: any[]) {
|
|
|
|
+ const later = () => {
|
|
|
|
+ clearTimeout(timeout!)
|
|
|
|
+ func(...args)
|
|
|
|
+ }
|
|
|
|
+ clearTimeout(timeout!)
|
|
|
|
+ timeout = setTimeout(later, wait)
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// 响应窗口大小变化
|
|
|
|
+const handleResize = debounce(calculateMaintItemsWidth, 300)
|
|
|
|
+
|
|
onMounted(async () => {
|
|
onMounted(async () => {
|
|
materialList.value = []
|
|
materialList.value = []
|
|
const deptId = useUserStore().getUser.deptId
|
|
const deptId = useUserStore().getUser.deptId
|
|
@@ -1119,6 +1247,8 @@ onMounted(async () => {
|
|
console.error('数据加载失败:', error)
|
|
console.error('数据加载失败:', error)
|
|
message.error('数据加载失败,请重试')
|
|
message.error('数据加载失败,请重试')
|
|
}
|
|
}
|
|
|
|
+ window.addEventListener('resize', handleResize)
|
|
|
|
+ nextTick(calculateMaintItemsWidth)
|
|
})
|
|
})
|
|
|
|
|
|
</script>
|
|
</script>
|
|
@@ -1154,4 +1284,24 @@ onMounted(async () => {
|
|
font-size: 12px;
|
|
font-size: 12px;
|
|
font-weight: 500;
|
|
font-weight: 500;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+.error-text {
|
|
|
|
+ color: #f56c6c;
|
|
|
|
+ font-size: 12px;
|
|
|
|
+ margin-top: 5px;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+:deep(.el-table__body) {
|
|
|
|
+ .el-table__cell {
|
|
|
|
+ .cell {
|
|
|
|
+ word-break: break-word;
|
|
|
|
+ max-width: 600px; /* 最大宽度限制 */
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+.full-content-cell {
|
|
|
|
+ white-space: nowrap; /* 禁止换行 */
|
|
|
|
+ overflow: visible; /* 允许内容溢出单元格 */
|
|
|
|
+}
|
|
</style>
|
|
</style>
|