|
@@ -63,10 +63,10 @@
|
|
<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">
|
|
<el-table-column label="设备编码" align="center" prop="deviceCode" />
|
|
<el-table-column label="设备编码" align="center" prop="deviceCode" />
|
|
<el-table-column label="设备名称" align="center" prop="deviceName" />
|
|
<el-table-column label="设备名称" align="center" prop="deviceName" />
|
|
- <el-table-column label="运行时间(H)" align="center" prop="runningTime" :formatter="erpPriceTableColumnFormatter"/>
|
|
|
|
- <el-table-column label="运行公里数(KM)" align="center" prop="runningKilometers" :formatter="erpPriceTableColumnFormatter"/>
|
|
|
|
|
|
+ <el-table-column label="累计运行时间(H)" align="center" prop="totalRunTime" :formatter="erpPriceTableColumnFormatter"/>
|
|
|
|
+ <el-table-column label="累计运行公里数(KM)" align="center" prop="totalMileage" :formatter="erpPriceTableColumnFormatter"/>
|
|
<el-table-column label="BOM节点" align="center" prop="name" />
|
|
<el-table-column label="BOM节点" align="center" prop="name" />
|
|
- <el-table-column label="里程" key="mileageRule">
|
|
|
|
|
|
+ <el-table-column label="运行里程" key="mileageRule" width="80">
|
|
<template #default="scope">
|
|
<template #default="scope">
|
|
<el-switch
|
|
<el-switch
|
|
v-model="scope.row.mileageRule"
|
|
v-model="scope.row.mileageRule"
|
|
@@ -75,12 +75,14 @@
|
|
/>
|
|
/>
|
|
</template>
|
|
</template>
|
|
</el-table-column>
|
|
</el-table-column>
|
|
|
|
+ <!--
|
|
<el-table-column label="里程周期(H)" align="center" prop="nextRunningKilometers" :formatter="erpPriceTableColumnFormatter">
|
|
<el-table-column label="里程周期(H)" align="center" prop="nextRunningKilometers" :formatter="erpPriceTableColumnFormatter">
|
|
<template #default="scope">
|
|
<template #default="scope">
|
|
<el-input v-model="scope.row.nextRunningKilometers" />
|
|
<el-input v-model="scope.row.nextRunningKilometers" />
|
|
</template>
|
|
</template>
|
|
</el-table-column>
|
|
</el-table-column>
|
|
- <el-table-column label="运行时间" key="runningTimeRule">
|
|
|
|
|
|
+ -->
|
|
|
|
+ <el-table-column label="运行时间" key="runningTimeRule" width="80">
|
|
<template #default="scope">
|
|
<template #default="scope">
|
|
<el-switch
|
|
<el-switch
|
|
v-model="scope.row.runningTimeRule"
|
|
v-model="scope.row.runningTimeRule"
|
|
@@ -89,12 +91,14 @@
|
|
/>
|
|
/>
|
|
</template>
|
|
</template>
|
|
</el-table-column>
|
|
</el-table-column>
|
|
|
|
+ <!--
|
|
<el-table-column label="时间周期(H)" align="center" prop="nextRunningTime" :formatter="erpPriceTableColumnFormatter">
|
|
<el-table-column label="时间周期(H)" align="center" prop="nextRunningTime" :formatter="erpPriceTableColumnFormatter">
|
|
<template #default="scope">
|
|
<template #default="scope">
|
|
<el-input v-model="scope.row.nextRunningTime" />
|
|
<el-input v-model="scope.row.nextRunningTime" />
|
|
</template>
|
|
</template>
|
|
</el-table-column>
|
|
</el-table-column>
|
|
- <el-table-column label="自然日期" key="naturalDateRule">
|
|
|
|
|
|
+ -->
|
|
|
|
+ <el-table-column label="自然日期" key="naturalDateRule" width="80">
|
|
<template #default="scope">
|
|
<template #default="scope">
|
|
<el-switch
|
|
<el-switch
|
|
v-model="scope.row.naturalDateRule"
|
|
v-model="scope.row.naturalDateRule"
|
|
@@ -103,11 +107,13 @@
|
|
/>
|
|
/>
|
|
</template>
|
|
</template>
|
|
</el-table-column>
|
|
</el-table-column>
|
|
|
|
+ <!--
|
|
<el-table-column label="自然日期(D)" align="center" prop="nextNaturalDate" :formatter="erpPriceTableColumnFormatter">
|
|
<el-table-column label="自然日期(D)" align="center" prop="nextNaturalDate" :formatter="erpPriceTableColumnFormatter">
|
|
<template #default="scope">
|
|
<template #default="scope">
|
|
<el-input v-model="scope.row.nextNaturalDate" />
|
|
<el-input v-model="scope.row.nextNaturalDate" />
|
|
</template>
|
|
</template>
|
|
</el-table-column>
|
|
</el-table-column>
|
|
|
|
+ -->
|
|
<el-table-column label="操作" align="center" min-width="120px">
|
|
<el-table-column label="操作" 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="display: flex; justify-content: center; align-items: center; width: 100%">
|
|
@@ -153,7 +159,7 @@
|
|
:title="`设备 ${configDialog.current?.deviceCode+'-'+configDialog.current?.name} 保养配置`"
|
|
:title="`设备 ${configDialog.current?.deviceCode+'-'+configDialog.current?.name} 保养配置`"
|
|
width="600px"
|
|
width="600px"
|
|
>
|
|
>
|
|
- <el-form :model="configDialog.form" label-width="160px">
|
|
|
|
|
|
+ <el-form :model="configDialog.form" label-width="180px" :rules="configFormRules" ref="configFormRef">
|
|
<!-- 里程配置 -->
|
|
<!-- 里程配置 -->
|
|
<el-form-item
|
|
<el-form-item
|
|
v-if="configDialog.current?.mileageRule === 0"
|
|
v-if="configDialog.current?.mileageRule === 0"
|
|
@@ -186,13 +192,85 @@
|
|
label="上次保养自然日期(D)"
|
|
label="上次保养自然日期(D)"
|
|
prop="lastNaturalDate"
|
|
prop="lastNaturalDate"
|
|
>
|
|
>
|
|
- <el-input-number
|
|
|
|
|
|
+ <el-date-picker
|
|
v-model="configDialog.form.lastNaturalDate"
|
|
v-model="configDialog.form.lastNaturalDate"
|
|
|
|
+ type="date"
|
|
|
|
+ placeholder="选择日期"
|
|
|
|
+ format="YYYY-MM-DD"
|
|
|
|
+ value-format="YYYY-MM-DD"
|
|
|
|
+ />
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <!-- 保养规则周期值 + 提前量 -->
|
|
|
|
+ <el-form-item
|
|
|
|
+ v-if="configDialog.current?.mileageRule === 0"
|
|
|
|
+ label="里程周期(KM)"
|
|
|
|
+ prop="nextRunningKilometers"
|
|
|
|
+ >
|
|
|
|
+ <el-input-number
|
|
|
|
+ v-model="configDialog.form.nextRunningKilometers"
|
|
|
|
+ :precision="2"
|
|
|
|
+ :min="0"
|
|
|
|
+ controls-position="right"
|
|
|
|
+ />
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-form-item
|
|
|
|
+ v-if="configDialog.current?.mileageRule === 0"
|
|
|
|
+ label="公里数周期-提前量(KM)"
|
|
|
|
+ prop="kiloCycleLead"
|
|
|
|
+ >
|
|
|
|
+ <el-input-number
|
|
|
|
+ v-model="configDialog.form.kiloCycleLead"
|
|
|
|
+ :precision="2"
|
|
|
|
+ :min="0"
|
|
|
|
+ controls-position="right"
|
|
|
|
+ />
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-form-item
|
|
|
|
+ v-if="configDialog.current?.runningTimeRule === 0"
|
|
|
|
+ label="时间周期(H)"
|
|
|
|
+ prop="nextRunningTime"
|
|
|
|
+ >
|
|
|
|
+ <el-input-number
|
|
|
|
+ v-model="configDialog.form.nextRunningTime"
|
|
|
|
+ :precision="1"
|
|
|
|
+ :min="0"
|
|
|
|
+ controls-position="right"
|
|
|
|
+ />
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-form-item
|
|
|
|
+ v-if="configDialog.current?.runningTimeRule === 0"
|
|
|
|
+ label="时间周期-提前量(H)"
|
|
|
|
+ prop="timePeriodLead"
|
|
|
|
+ >
|
|
|
|
+ <el-input-number
|
|
|
|
+ v-model="configDialog.form.timePeriodLead"
|
|
:precision="1"
|
|
:precision="1"
|
|
:min="0"
|
|
:min="0"
|
|
controls-position="right"
|
|
controls-position="right"
|
|
/>
|
|
/>
|
|
</el-form-item>
|
|
</el-form-item>
|
|
|
|
+ <el-form-item
|
|
|
|
+ v-if="configDialog.current?.naturalDateRule === 0"
|
|
|
|
+ label="自然日周期(D)"
|
|
|
|
+ prop="nextNaturalDate"
|
|
|
|
+ >
|
|
|
|
+ <el-input-number
|
|
|
|
+ v-model="configDialog.form.nextNaturalDate"
|
|
|
|
+ :min="0"
|
|
|
|
+ controls-position="right"
|
|
|
|
+ />
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-form-item
|
|
|
|
+ v-if="configDialog.current?.naturalDateRule === 0"
|
|
|
|
+ label="自然日周期-提前量(D)"
|
|
|
|
+ prop="naturalDatePeriodLead"
|
|
|
|
+ >
|
|
|
|
+ <el-input-number
|
|
|
|
+ v-model="configDialog.form.naturalDatePeriodLead"
|
|
|
|
+ :min="0"
|
|
|
|
+ controls-position="right"
|
|
|
|
+ />
|
|
|
|
+ </el-form-item>
|
|
</el-form>
|
|
</el-form>
|
|
<template #footer>
|
|
<template #footer>
|
|
<el-button @click="configDialog.visible = false">取消</el-button>
|
|
<el-button @click="configDialog.visible = false">取消</el-button>
|
|
@@ -214,6 +292,7 @@ import {CACHE_KEY, useCache} from "@/hooks/web/useCache";
|
|
import MainPlanDeviceList from "@/views/pms/maintenance/MainPlanDeviceList.vue";
|
|
import MainPlanDeviceList from "@/views/pms/maintenance/MainPlanDeviceList.vue";
|
|
import * as DeptApi from "@/api/system/dept";
|
|
import * as DeptApi from "@/api/system/dept";
|
|
import {erpPriceTableColumnFormatter} from "@/utils";
|
|
import {erpPriceTableColumnFormatter} from "@/utils";
|
|
|
|
+import dayjs from 'dayjs'
|
|
|
|
|
|
/** 保养计划 表单 */
|
|
/** 保养计划 表单 */
|
|
defineOptions({ name: 'IotAddMainPlan' })
|
|
defineOptions({ name: 'IotAddMainPlan' })
|
|
@@ -224,6 +303,7 @@ const { delView } = useTagsViewStore() // 视图操作
|
|
const { currentRoute, push } = useRouter()
|
|
const { currentRoute, push } = useRouter()
|
|
const deptUsers = ref<UserApi.UserVO[]>([]) // 用户列表
|
|
const deptUsers = ref<UserApi.UserVO[]>([]) // 用户列表
|
|
const dept = ref() // 当前登录人所属部门对象
|
|
const dept = ref() // 当前登录人所属部门对象
|
|
|
|
+const configFormRef = ref() // 配置弹出框对象
|
|
const dialogTitle = ref('') // 弹窗的标题
|
|
const dialogTitle = ref('') // 弹窗的标题
|
|
const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
|
|
const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
|
|
const formType = ref('') // 表单的类型:create - 新增;update - 修改
|
|
const formType = ref('') // 表单的类型:create - 新增;update - 修改
|
|
@@ -255,27 +335,102 @@ const configDialog = reactive({
|
|
form: {
|
|
form: {
|
|
lastRunningKilometers: 0,
|
|
lastRunningKilometers: 0,
|
|
lastRunningTime: 0,
|
|
lastRunningTime: 0,
|
|
- lastNaturalDate: 0
|
|
|
|
|
|
+ lastNaturalDate: '',
|
|
|
|
+ // 保养规则 周期
|
|
|
|
+ nextRunningKilometers: 0,
|
|
|
|
+ nextRunningTime: 0,
|
|
|
|
+ nextNaturalDate: 0,
|
|
|
|
+ // 提前量
|
|
|
|
+ kiloCycleLead: 0,
|
|
|
|
+ timePeriodLead: 0,
|
|
|
|
+ naturalDatePeriodLead: 0
|
|
}
|
|
}
|
|
})
|
|
})
|
|
|
|
|
|
// 打开配置对话框
|
|
// 打开配置对话框
|
|
const openConfigDialog = (row: IotMaintenanceBomVO) => {
|
|
const openConfigDialog = (row: IotMaintenanceBomVO) => {
|
|
configDialog.current = row
|
|
configDialog.current = row
|
|
|
|
+
|
|
|
|
+ // 处理日期初始化(核心修改)
|
|
|
|
+ let initialDate = ''
|
|
|
|
+ if (row.lastNaturalDate) {
|
|
|
|
+ // 如果已有值:时间戳 -> 日期字符串
|
|
|
|
+ initialDate = dayjs(row.lastNaturalDate).format('YYYY-MM-DD')
|
|
|
|
+ } else {
|
|
|
|
+ // 如果无值:设置默认值避免1970问题
|
|
|
|
+ initialDate = ''
|
|
|
|
+ }
|
|
|
|
+
|
|
configDialog.form = {
|
|
configDialog.form = {
|
|
lastRunningKilometers: row.lastRunningKilometers || 0,
|
|
lastRunningKilometers: row.lastRunningKilometers || 0,
|
|
lastRunningTime: row.lastRunningTime || 0,
|
|
lastRunningTime: row.lastRunningTime || 0,
|
|
- lastNaturalDate: row.lastNaturalDate || 0
|
|
|
|
|
|
+ lastNaturalDate: initialDate,
|
|
|
|
+ // 保养规则 周期值
|
|
|
|
+ nextRunningKilometers: row.nextRunningKilometers || 0,
|
|
|
|
+ nextRunningTime: row.nextRunningTime || 0,
|
|
|
|
+ nextNaturalDate: row.nextNaturalDate || 0,
|
|
|
|
+ // 提前量
|
|
|
|
+ kiloCycleLead: row.kiloCycleLead || 0,
|
|
|
|
+ timePeriodLead: row.timePeriodLead || 0,
|
|
|
|
+ naturalDatePeriodLead: row.naturalDatePeriodLead || 0
|
|
}
|
|
}
|
|
configDialog.visible = true
|
|
configDialog.visible = true
|
|
}
|
|
}
|
|
|
|
|
|
// 保存配置
|
|
// 保存配置
|
|
const saveConfig = () => {
|
|
const saveConfig = () => {
|
|
- if (!configDialog.current) return
|
|
|
|
- // 更新当前行的数据
|
|
|
|
- Object.assign(configDialog.current, configDialog.form)
|
|
|
|
- configDialog.visible = false
|
|
|
|
|
|
+ (configFormRef.value as any).validate((valid: boolean) => {
|
|
|
|
+ if (!valid) return
|
|
|
|
+ if (!configDialog.current) return
|
|
|
|
+
|
|
|
|
+ // 动态校验逻辑
|
|
|
|
+ const requiredFields = []
|
|
|
|
+ if (configDialog.current.mileageRule === 0) {
|
|
|
|
+ requiredFields.push('nextRunningKilometers', 'kiloCycleLead')
|
|
|
|
+ }
|
|
|
|
+ if (configDialog.current.runningTimeRule === 0) {
|
|
|
|
+ requiredFields.push('nextRunningTime', 'timePeriodLead')
|
|
|
|
+ }
|
|
|
|
+ if (configDialog.current.naturalDateRule === 0) {
|
|
|
|
+ requiredFields.push('nextNaturalDate', 'naturalDatePeriodLead')
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ const missingFields = requiredFields.filter(field =>
|
|
|
|
+ !configDialog.form[field as keyof typeof configDialog.form]
|
|
|
|
+ )
|
|
|
|
+
|
|
|
|
+ if (missingFields.length > 0) {
|
|
|
|
+ message.error('请填写所有必填项')
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 强制校验逻辑
|
|
|
|
+ if (configDialog.current.naturalDateRule === 0) {
|
|
|
|
+ if (!configDialog.form.lastNaturalDate) {
|
|
|
|
+ message.error('必须选择自然日期')
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 验证日期有效性
|
|
|
|
+ const dateValue = dayjs(configDialog.form.lastNaturalDate)
|
|
|
|
+ if (!dateValue.isValid()) {
|
|
|
|
+ message.error('日期格式不正确')
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 转换逻辑(关键修改)
|
|
|
|
+ const finalDate = configDialog.form.lastNaturalDate
|
|
|
|
+ ? dayjs(configDialog.form.lastNaturalDate).valueOf()
|
|
|
|
+ : null // 改为null而不是0
|
|
|
|
+
|
|
|
|
+ // 更新当前行的数据
|
|
|
|
+ Object.assign(configDialog.current, {
|
|
|
|
+ ...configDialog.form,
|
|
|
|
+ lastNaturalDate: finalDate
|
|
|
|
+ })
|
|
|
|
+ configDialog.visible = false
|
|
|
|
+ })
|
|
}
|
|
}
|
|
|
|
|
|
const queryParams = reactive({
|
|
const queryParams = reactive({
|
|
@@ -288,7 +443,6 @@ const deviceChoose = async(selectedDevices) => {
|
|
const params = {
|
|
const params = {
|
|
deviceIds: deviceIds.value.join(',') // 明确传递数组参数
|
|
deviceIds: deviceIds.value.join(',') // 明确传递数组参数
|
|
}
|
|
}
|
|
- // console.log('请求参数:', JSON.parse(JSON.stringify(params.deviceIds)))
|
|
|
|
queryParams.deviceIds = JSON.parse(JSON.stringify(params.deviceIds))
|
|
queryParams.deviceIds = JSON.parse(JSON.stringify(params.deviceIds))
|
|
// 根据选择的设备筛选出设备关系的分类BOM中与保养相关的节点项
|
|
// 根据选择的设备筛选出设备关系的分类BOM中与保养相关的节点项
|
|
const res = await IotDeviceApi.deviceAssociateBomList(queryParams)
|
|
const res = await IotDeviceApi.deviceAssociateBomList(queryParams)
|
|
@@ -313,11 +467,16 @@ const deviceChoose = async(selectedDevices) => {
|
|
remark: null, // 初始化备注
|
|
remark: null, // 初始化备注
|
|
deviceId: device.id, // 移除操作需要
|
|
deviceId: device.id, // 移除操作需要
|
|
bomNodeId: device.bomNodeId,
|
|
bomNodeId: device.bomNodeId,
|
|
- runningTime: 0,
|
|
|
|
- runningKilometers: 0,
|
|
|
|
|
|
+ totalRunTime: device.totalRunTime,
|
|
|
|
+ totalMileage: device.totalMileage,
|
|
nextRunningKilometers: 0,
|
|
nextRunningKilometers: 0,
|
|
nextRunningTime: 0,
|
|
nextRunningTime: 0,
|
|
nextNaturalDate: 0,
|
|
nextNaturalDate: 0,
|
|
|
|
+ lastNaturalDate: null, // 初始化为null而不是0
|
|
|
|
+ // 保养规则 提前量
|
|
|
|
+ kiloCycleLead: 0,
|
|
|
|
+ timePeriodLead: 0,
|
|
|
|
+ naturalDatePeriodLead: 0
|
|
}))
|
|
}))
|
|
// 获取选择的设备相关的id数组
|
|
// 获取选择的设备相关的id数组
|
|
newItems.forEach(item => {
|
|
newItems.forEach(item => {
|
|
@@ -344,25 +503,6 @@ const close = () => {
|
|
push({ name: 'IotMaintenancePlan', params:{}})
|
|
push({ name: 'IotMaintenancePlan', params:{}})
|
|
}
|
|
}
|
|
|
|
|
|
-const selectChoose = (formData) => {
|
|
|
|
- console.log('接收到的数据:', JSON.stringify(formData))
|
|
|
|
- list.value.push(formData)
|
|
|
|
-}
|
|
|
|
-const handleChildSubmit = (formData) => {
|
|
|
|
- const modified = removeOnesFromKeys(formData)
|
|
|
|
- list.value.push(modified)
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-const removeOnesFromKeys = (obj: Record<string, any>) => {
|
|
|
|
- return Object.keys(obj).reduce(
|
|
|
|
- (acc, key) => {
|
|
|
|
- const newKey = key.replace(/1/g, '') // 替换所有 1
|
|
|
|
- acc[newKey] = obj[key]
|
|
|
|
- return acc
|
|
|
|
- },
|
|
|
|
- {} as Record<string, any>
|
|
|
|
- )
|
|
|
|
-}
|
|
|
|
/** 提交表单 */
|
|
/** 提交表单 */
|
|
const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调
|
|
const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调
|
|
const submitForm = async () => {
|
|
const submitForm = async () => {
|
|
@@ -378,7 +518,6 @@ const submitForm = async () => {
|
|
mainPlan: formData.value,
|
|
mainPlan: formData.value,
|
|
mainPlanBom: list.value
|
|
mainPlanBom: list.value
|
|
}
|
|
}
|
|
- // console.log('列表数据:'+data.mainPlanBom[0].lastRunningKilometers)
|
|
|
|
if (formType.value === 'create') {
|
|
if (formType.value === 'create') {
|
|
await IotMaintenancePlanApi.createIotMaintenancePlan(data)
|
|
await IotMaintenancePlanApi.createIotMaintenancePlan(data)
|
|
message.success(t('common.createSuccess'))
|
|
message.success(t('common.createSuccess'))
|
|
@@ -395,6 +534,40 @@ const submitForm = async () => {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+// 新增表单校验规则
|
|
|
|
+const configFormRules = reactive({
|
|
|
|
+ nextRunningKilometers: [{
|
|
|
|
+ required: true,
|
|
|
|
+ message: '里程周期必须填写',
|
|
|
|
+ trigger: 'blur'
|
|
|
|
+ }],
|
|
|
|
+ kiloCycleLead: [{
|
|
|
|
+ required: true,
|
|
|
|
+ message: '提前量必须填写',
|
|
|
|
+ trigger: 'blur'
|
|
|
|
+ }],
|
|
|
|
+ nextRunningTime: [{
|
|
|
|
+ required: true,
|
|
|
|
+ message: '时间周期必须填写',
|
|
|
|
+ trigger: 'blur'
|
|
|
|
+ }],
|
|
|
|
+ timePeriodLead: [{
|
|
|
|
+ required: true,
|
|
|
|
+ message: '提前量必须填写',
|
|
|
|
+ trigger: 'blur'
|
|
|
|
+ }],
|
|
|
|
+ nextNaturalDate: [{
|
|
|
|
+ required: true,
|
|
|
|
+ message: '自然日周期必须填写',
|
|
|
|
+ trigger: 'blur'
|
|
|
|
+ }],
|
|
|
|
+ naturalDatePeriodLead: [{
|
|
|
|
+ required: true,
|
|
|
|
+ message: '提前量必须填写',
|
|
|
|
+ trigger: 'blur'
|
|
|
|
+ }]
|
|
|
|
+})
|
|
|
|
+
|
|
/** 校验表格数据 */
|
|
/** 校验表格数据 */
|
|
const validateTableData = (): boolean => {
|
|
const validateTableData = (): boolean => {
|
|
let isValid = true
|
|
let isValid = true
|
|
@@ -403,6 +576,15 @@ const validateTableData = (): boolean => {
|
|
const noRules: string[] = [] // 行记录中设置了保养规则的记录数量
|
|
const noRules: string[] = [] // 行记录中设置了保养规则的记录数量
|
|
const configErrors: string[] = [] // 保养规则配置弹出框
|
|
const configErrors: string[] = [] // 保养规则配置弹出框
|
|
let shouldBreak = false;
|
|
let shouldBreak = false;
|
|
|
|
+
|
|
|
|
+ if (list.value.length === 0) {
|
|
|
|
+ errorMessages.push('请至少添加一条设备保养明细')
|
|
|
|
+ isValid = false
|
|
|
|
+ // 直接返回无需后续校验
|
|
|
|
+ message.error('请至少添加一条设备保养明细')
|
|
|
|
+ return isValid
|
|
|
|
+ }
|
|
|
|
+
|
|
list.value.forEach((row, index) => {
|
|
list.value.forEach((row, index) => {
|
|
if (shouldBreak) return;
|
|
if (shouldBreak) return;
|
|
const rowNumber = index + 1 // 用户可见的行号从1开始
|
|
const rowNumber = index + 1 // 用户可见的行号从1开始
|
|
@@ -439,7 +621,7 @@ const validateTableData = (): boolean => {
|
|
}
|
|
}
|
|
// 自然日期校验逻辑
|
|
// 自然日期校验逻辑
|
|
if (row.naturalDateRule === 0) {
|
|
if (row.naturalDateRule === 0) {
|
|
- if (!row.nextNaturalDate || row.nextNaturalDate <= 0) {
|
|
|
|
|
|
+ if (!row.nextNaturalDate) {
|
|
errorMessages.push(`第 ${rowNumber} 行:开启自然日期规则必须填写有效的自然日期周期`)
|
|
errorMessages.push(`第 ${rowNumber} 行:开启自然日期规则必须填写有效的自然日期周期`)
|
|
isValid = false
|
|
isValid = false
|
|
}
|
|
}
|
|
@@ -494,7 +676,7 @@ onMounted(async () => {
|
|
// 查询当前登录人所属部门名称
|
|
// 查询当前登录人所属部门名称
|
|
dept.value = await DeptApi.getDept(deptId)
|
|
dept.value = await DeptApi.getDept(deptId)
|
|
// 根据当前登录人部门信息生成生成 保养计划 名称
|
|
// 根据当前登录人部门信息生成生成 保养计划 名称
|
|
- formData.value.name = dept.value.name + '-保养计划'
|
|
|
|
|
|
+ formData.value.name = dept.value.name + ' - 保养计划'
|
|
deptUsers.value = await UserApi.getDeptUsersByDeptId(deptId)
|
|
deptUsers.value = await UserApi.getDeptUsersByDeptId(deptId)
|
|
formData.value.deptId = deptId
|
|
formData.value.deptId = deptId
|
|
if (id){
|
|
if (id){
|