|
@@ -59,8 +59,18 @@
|
|
|
<el-table-column label="设备id" align="center" prop="deviceId" v-if="false"/>
|
|
|
<el-table-column :label="t('iotMaintain.deviceCode')" align="center" prop="deviceCode" />
|
|
|
<el-table-column :label="t('iotMaintain.deviceName')" align="center" prop="deviceName" />
|
|
|
- <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.sumTime')" align="center" prop="totalRunTime" :formatter="erpPriceTableColumnFormatter">
|
|
|
+ <template #default="{ row }">
|
|
|
+ {{ row.totalRunTime ?? row.tempTotalRunTime }}
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column :label="t('operationFillForm.sumKil')" align="center" prop="totalMileage" :formatter="erpPriceTableColumnFormatter">
|
|
|
+ <template #default="{ row }">
|
|
|
+ {{ row.totalMileage ?? row.tempTotalMileage }}
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="tempTotalRunTime" align="center" prop="tempTotalRunTime" :formatter="erpPriceTableColumnFormatter" v-if="false"/>
|
|
|
+ <el-table-column label="tempTotalMileage" align="center" prop="tempTotalMileage" :formatter="erpPriceTableColumnFormatter" v-if="false"/>
|
|
|
<el-table-column :label="t('bomList.bomNode')" align="center" prop="name" />
|
|
|
<el-table-column :label="t('main.mileage')" key="mileageRule" width="80">
|
|
|
<template #default="scope">
|
|
@@ -68,6 +78,7 @@
|
|
|
v-model="scope.row.mileageRule"
|
|
|
:active-value="0"
|
|
|
:inactive-value="1"
|
|
|
+ @change="handleRuleChange(scope.row, 'mileage')"
|
|
|
/>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
@@ -77,6 +88,7 @@
|
|
|
v-model="scope.row.runningTimeRule"
|
|
|
:active-value="0"
|
|
|
:inactive-value="1"
|
|
|
+ @change="handleRuleChange(scope.row, 'runningTime')"
|
|
|
/>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
@@ -295,6 +307,69 @@
|
|
|
/>
|
|
|
</el-form-item>
|
|
|
</div>
|
|
|
+
|
|
|
+ <!-- 运行记录模板中 多个 累计运行时长 累计运行里程 属性匹配-->
|
|
|
+ <div class="form-group"
|
|
|
+ v-if="(configDialog.current?.runningTimeRule === 0 || configDialog.current?.mileageRule === 0)
|
|
|
+ && (configDialog.current?.timeAccumulatedAttrs?.length || configDialog.current?.mileageAccumulatedAttrs?.length)
|
|
|
+ && !configDialog.current.totalRunTime && !configDialog.current.totalMileage" >
|
|
|
+ <div class="group-title">{{ t('mainPlan.accumulatedParams') }}</div>
|
|
|
+ <!-- 累计运行时长 -->
|
|
|
+ <el-form-item
|
|
|
+ v-if="configDialog.current?.runningTimeRule === 0
|
|
|
+ && configDialog.current?.timeAccumulatedAttrs?.length && !configDialog.current.totalRunTime"
|
|
|
+ :label="t('mainPlan.accumulatedRunTime')"
|
|
|
+ prop="accumulatedTimeOption"
|
|
|
+ :rules="[{
|
|
|
+ required: configDialog.current?.runningTimeRule === 0 && configDialog.current?.timeAccumulatedAttrs?.length,
|
|
|
+ message: '请选择累计运行时长',
|
|
|
+ trigger: 'change'
|
|
|
+ }]"
|
|
|
+ >
|
|
|
+ <el-select
|
|
|
+ v-model="configDialog.form.accumulatedTimeOption"
|
|
|
+ placeholder="请选择累计运行时长"
|
|
|
+ style="width: 80%"
|
|
|
+ clearable
|
|
|
+ @change="handleAccumulatedTimeChange"
|
|
|
+ >
|
|
|
+ <el-option
|
|
|
+ v-for="(item, index) in configDialog.current.timeAccumulatedAttrs"
|
|
|
+ :key="`time-${item.pointName}-${index}`"
|
|
|
+ :label="item.pointName"
|
|
|
+ :value="item.pointName"
|
|
|
+ />
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ <!-- 累计运行公里数 -->
|
|
|
+ <el-form-item
|
|
|
+ v-if="configDialog.current?.mileageRule === 0
|
|
|
+ && configDialog.current?.mileageAccumulatedAttrs?.length && !configDialog.current.totalMileage"
|
|
|
+ :label="t('mainPlan.accumulatedMileage')"
|
|
|
+ prop="accumulatedMileageOption"
|
|
|
+ :rules="[{
|
|
|
+ required: configDialog.current?.mileageRule === 0 && configDialog.current?.mileageAccumulatedAttrs?.length,
|
|
|
+ message: '请选择累计运行公里数',
|
|
|
+ trigger: 'change'
|
|
|
+ }]"
|
|
|
+ >
|
|
|
+ <el-select
|
|
|
+ v-model="configDialog.form.accumulatedMileageOption"
|
|
|
+ placeholder="请选择累计运行公里数"
|
|
|
+ style="width: 80%"
|
|
|
+ clearable
|
|
|
+ @change="handleAccumulatedMileageChange"
|
|
|
+ >
|
|
|
+ <el-option
|
|
|
+ v-for="(item, index) in configDialog.current.mileageAccumulatedAttrs"
|
|
|
+ :key="`mileage-${item.pointName}-${index}`"
|
|
|
+ :label="item.pointName"
|
|
|
+ :value="item.pointName"
|
|
|
+ />
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ </div>
|
|
|
+
|
|
|
</el-form>
|
|
|
<template #footer>
|
|
|
<el-button @click="configDialog.visible = false">{{ t('common.cancel') }}</el-button>
|
|
@@ -392,7 +467,10 @@ const configDialog = reactive({
|
|
|
// 提前量
|
|
|
kiloCycleLead: 0,
|
|
|
timePeriodLead: 0,
|
|
|
- naturalDatePeriodLead: 0
|
|
|
+ naturalDatePeriodLead: 0,
|
|
|
+ // 多个累计时长 累计里程 匹配
|
|
|
+ accumulatedTimeOption: null, // 累计运行时长选项
|
|
|
+ accumulatedMileageOption: null, // 累计运行公里数选项
|
|
|
}
|
|
|
})
|
|
|
|
|
@@ -424,8 +502,24 @@ const openConfigDialog = (row: IotMaintenanceBomVO) => {
|
|
|
// 提前量
|
|
|
kiloCycleLead: row.kiloCycleLead || 0,
|
|
|
timePeriodLead: row.timePeriodLead || 0,
|
|
|
- naturalDatePeriodLead: row.naturalDatePeriodLead || 0
|
|
|
+ naturalDatePeriodLead: row.naturalDatePeriodLead || 0,
|
|
|
+ // 多个累计时长 累计里程 匹配
|
|
|
+ accumulatedTimeOption: null, // 累计运行时长选项
|
|
|
+ accumulatedMileageOption: null, // 累计运行公里数选项
|
|
|
}
|
|
|
+
|
|
|
+ // 初始化累计参数选择
|
|
|
+ /* configDialog.form.accumulatedTimeOption = row.isRuntimeFromTemp
|
|
|
+ ? row.code
|
|
|
+ : null;
|
|
|
+
|
|
|
+ configDialog.form.accumulatedMileageOption = row.isMileageFromTemp
|
|
|
+ ? row.type
|
|
|
+ : null; */
|
|
|
+
|
|
|
+ configDialog.form.accumulatedTimeOption = row.code || null;
|
|
|
+ configDialog.form.accumulatedMileageOption = row.type || null;
|
|
|
+
|
|
|
configDialog.visible = true
|
|
|
}
|
|
|
|
|
@@ -435,6 +529,21 @@ const saveConfig = () => {
|
|
|
if (!valid) return
|
|
|
if (!configDialog.current) return
|
|
|
|
|
|
+ // 累计运行时长配置 校验逻辑
|
|
|
+ if (configDialog.current.runningTimeRule === 0 &&
|
|
|
+ configDialog.current.timeAccumulatedAttrs?.length &&
|
|
|
+ !configDialog.form.accumulatedTimeOption) {
|
|
|
+ message.error('请选择累计运行时长');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // 累计运行公里数配置 校验逻辑
|
|
|
+ if (configDialog.current.mileageRule === 0 &&
|
|
|
+ configDialog.current.mileageAccumulatedAttrs?.length &&
|
|
|
+ !configDialog.form.accumulatedMileageOption) {
|
|
|
+ message.error('请选择累计运行公里数');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
// 动态校验逻辑
|
|
|
const requiredFields = []
|
|
|
if (configDialog.current.mileageRule === 0) {
|
|
@@ -476,12 +585,53 @@ const saveConfig = () => {
|
|
|
? dayjs(configDialog.form.lastNaturalDate).valueOf()
|
|
|
: null // 改为null而不是0
|
|
|
|
|
|
- // 更新当前行的数据
|
|
|
- Object.assign(configDialog.current, {
|
|
|
+ const updateData = {
|
|
|
...configDialog.form,
|
|
|
- // Date对象 -> 时间戳
|
|
|
lastNaturalDate: finalDate,
|
|
|
- })
|
|
|
+ };
|
|
|
+
|
|
|
+ // 关闭保养规则,无论是否有选择值,都清除相关数据
|
|
|
+ // 处理累计运行时长
|
|
|
+ if (configDialog.current.runningTimeRule !== 0) {
|
|
|
+ configDialog.current.code = null;
|
|
|
+ configDialog.current.totalRunTime = null;
|
|
|
+ configDialog.form.accumulatedTimeOption = null; // 清除选择值
|
|
|
+ } else if (configDialog.form.accumulatedTimeOption) {
|
|
|
+ // 查找选中的累计运行时长项
|
|
|
+ const selectedTimeOption = configDialog.current.timeAccumulatedAttrs?.find(
|
|
|
+ item => item.pointName === configDialog.form.accumulatedTimeOption
|
|
|
+ );
|
|
|
+ if (selectedTimeOption) {
|
|
|
+ configDialog.current.code = selectedTimeOption.pointName;
|
|
|
+ // 优先使用接口值,没有则使用临时值
|
|
|
+ configDialog.current.tempTotalRunTime = selectedTimeOption.totalRunTime;
|
|
|
+ configDialog.current.isRuntimeFromTemp = true;
|
|
|
+ // 只有接口未提供值时才使用临时值
|
|
|
+ if (!configDialog.current.totalRunTime) {
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 处理累计运行公里数
|
|
|
+ if (configDialog.current.mileageRule !== 0) {
|
|
|
+ configDialog.current.type = null;
|
|
|
+ configDialog.current.totalMileage = null;
|
|
|
+ configDialog.form.accumulatedMileageOption = null; // 清除选择值
|
|
|
+ } else if (configDialog.form.accumulatedMileageOption) {
|
|
|
+ // 查找选中的累计运行公里数项
|
|
|
+ const selectedMileageOption = configDialog.current.mileageAccumulatedAttrs?.find(
|
|
|
+ item => item.pointName === configDialog.form.accumulatedMileageOption
|
|
|
+ );
|
|
|
+ if (selectedMileageOption) {
|
|
|
+ configDialog.current.type = selectedMileageOption.pointName;
|
|
|
+ configDialog.current.tempTotalMileage = selectedMileageOption.totalRunTime;
|
|
|
+ configDialog.current.isMileageFromTemp = true;
|
|
|
+ if (!configDialog.current.totalMileage) {
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 更新当前行的数据
|
|
|
+ Object.assign(configDialog.current, updateData);
|
|
|
configDialog.visible = false
|
|
|
})
|
|
|
}
|
|
@@ -492,6 +642,53 @@ const queryParams = reactive({
|
|
|
bomFlag: 'b'
|
|
|
})
|
|
|
|
|
|
+// 处理保养规则变化 取消保养规则 时 清空已经设置的相应保养规则数据
|
|
|
+const handleRuleChange = (row: IotMaintenanceBomVO, ruleType: 'mileage' | 'runningTime') => {
|
|
|
+ // 当规则关闭时(inactive-value=1)
|
|
|
+ console.log('执行了保养规则变化事件' + row.totalRunTime + ' - ' + row.totalMileage)
|
|
|
+ // 当前保养项行已经返回了 totalRunTime totalMileage 数据 不需要再清空 累计运行时长 累计公里数
|
|
|
+
|
|
|
+ // 选择完设备匹配了保养项后 不能直接置空 因为可能是正常的累计时长 累计公里数
|
|
|
+ if (ruleType === 'runningTime' && row.runningTimeRule === 1) {
|
|
|
+ // 清除临时来源的值
|
|
|
+ if (row.isRuntimeFromTemp) {
|
|
|
+ row.totalRunTime = null;
|
|
|
+ row.tempTotalRunTime = null;
|
|
|
+ row.code = null;
|
|
|
+ // row.isRuntimeFromTemp = false;
|
|
|
+ }
|
|
|
+ // 强制清除配置对话框中的值(如果打开的是当前行)
|
|
|
+ if (configDialog.current?.deviceId === row.deviceId
|
|
|
+ && configDialog.current?.bomNodeId === row.bomNodeId) {
|
|
|
+ configDialog.form.accumulatedTimeOption = null;
|
|
|
+ }
|
|
|
+ } else if (ruleType === 'mileage' && row.mileageRule === 1) {
|
|
|
+ if (row.isMileageFromTemp) {
|
|
|
+ row.totalMileage = null;
|
|
|
+ row.tempTotalMileage = null;
|
|
|
+ row.type = null;
|
|
|
+ // row.isMileageFromTemp = false;
|
|
|
+ }
|
|
|
+ // 强制清除配置对话框中的值(如果打开的是当前行)
|
|
|
+ if (configDialog.current?.deviceId === row.deviceId &&
|
|
|
+ configDialog.current?.bomNodeId === row.bomNodeId) {
|
|
|
+ configDialog.form.accumulatedMileageOption = null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 如果配置对话框打开的是当前行,同步清除对话框中的选择值
|
|
|
+ if (configDialog.visible && configDialog.current &&
|
|
|
+ configDialog.current.deviceId === row.deviceId &&
|
|
|
+ configDialog.current.bomNodeId === row.bomNodeId) {
|
|
|
+
|
|
|
+ if (ruleType === 'runningTime') {
|
|
|
+ configDialog.form.accumulatedTimeOption = null;
|
|
|
+ } else if (ruleType === 'mileage') {
|
|
|
+ configDialog.form.accumulatedMileageOption = null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
const deviceChoose = async(selectedDevices) => {
|
|
|
const newIds = selectedDevices.map(device => device.id)
|
|
|
deviceIds.value = [...new Set([...deviceIds.value, ...newIds])]
|
|
@@ -767,6 +964,14 @@ const sortDeviceList = (devices: IotMaintenanceBomVO[]) => {
|
|
|
})
|
|
|
};
|
|
|
|
|
|
+// 累计运行时长变更
|
|
|
+const handleAccumulatedTimeChange = (option) => {
|
|
|
+}
|
|
|
+
|
|
|
+// 累计运行公里数变更
|
|
|
+const handleAccumulatedMileageChange = (option) => {
|
|
|
+}
|
|
|
+
|
|
|
/** 重置表单 */
|
|
|
const resetForm = () => {
|
|
|
formData.value = {
|