|
@@ -20,12 +20,6 @@
|
|
|
<el-input type="text" v-model="formData.serialNumber" disabled/>
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
- <!--
|
|
|
- <el-col :span="8">
|
|
|
- <el-form-item label="设备责任人" prop="devicePersons">
|
|
|
- <el-input type="text" v-model="formData.devicePersons" disabled/>
|
|
|
- </el-form-item>
|
|
|
- </el-col> -->
|
|
|
<el-col :span="24">
|
|
|
<el-form-item :label="t('iotMaintain.remark')" prop="remark">
|
|
|
<el-input v-model="formData.remark" type="textarea" :placeholder="t('iotMaintain.remarkHolder')" />
|
|
@@ -77,13 +71,6 @@
|
|
|
/>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
- <!--
|
|
|
- <el-table-column label="里程周期(H)" align="center" prop="nextRunningKilometers" :formatter="erpPriceTableColumnFormatter">
|
|
|
- <template #default="scope">
|
|
|
- <el-input v-model="scope.row.nextRunningKilometers" />
|
|
|
- </template>
|
|
|
- </el-table-column>
|
|
|
- -->
|
|
|
<el-table-column :label="t('main.runTime')" key="runningTimeRule" width="90">
|
|
|
<template #default="scope">
|
|
|
<el-switch
|
|
@@ -93,13 +80,6 @@
|
|
|
/>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
- <!--
|
|
|
- <el-table-column label="时间周期(H)" align="center" prop="nextRunningTime" :formatter="erpPriceTableColumnFormatter">
|
|
|
- <template #default="scope">
|
|
|
- <el-input v-model="scope.row.nextRunningTime" />
|
|
|
- </template>
|
|
|
- </el-table-column>
|
|
|
- -->
|
|
|
<el-table-column :label="t('main.date')" key="naturalDateRule" width="80">
|
|
|
<template #default="scope">
|
|
|
<el-switch
|
|
@@ -109,13 +89,6 @@
|
|
|
/>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
- <!--
|
|
|
- <el-table-column label="自然日期(D)" align="center" prop="nextNaturalDate" :formatter="erpPriceTableColumnFormatter">
|
|
|
- <template #default="scope">
|
|
|
- <el-input v-model="scope.row.nextNaturalDate" />
|
|
|
- </template>
|
|
|
- </el-table-column>
|
|
|
- -->
|
|
|
<el-table-column :label="t('operationFill.operation')" align="center" min-width="120px">
|
|
|
<template #default="scope">
|
|
|
<div style="display: flex; justify-content: center; align-items: center; width: 100%">
|
|
@@ -317,14 +290,6 @@
|
|
|
</template>
|
|
|
</el-dialog>
|
|
|
|
|
|
- <div class="temp-list card" v-if="false">
|
|
|
- <h3>{{ t('mainPlan.duty') }}</h3>
|
|
|
- <el-table :data="tempDevicePersons" style="width: 100%" >
|
|
|
- <el-table-column prop="tempDeviceIds" :label="t('mainPlan.deviceId')" width="200" />
|
|
|
- <el-table-column prop="tempPersonNames" :label="t('operationFill.duty')" />
|
|
|
- </el-table>
|
|
|
- </div>
|
|
|
-
|
|
|
</template>
|
|
|
<script setup lang="ts">
|
|
|
import { IotDeviceApi, IotDeviceVO } from '@/api/pms/device'
|
|
@@ -332,7 +297,6 @@ import * as UserApi from '@/api/system/user'
|
|
|
import { useUserStore } from '@/store/modules/user'
|
|
|
import { ref } from 'vue'
|
|
|
import { IotMaintenanceBomApi, IotMaintenanceBomVO } from '@/api/pms/iotmaintenancebom'
|
|
|
-import { IotDevicePersonApi, IotDevicePersonVO } from '@/api/pms/iotdeviceperson'
|
|
|
import { IotMaintenancePlanApi, IotMaintenancePlanVO } from '@/api/pms/maintenance'
|
|
|
import { useTagsViewStore } from '@/store/modules/tagsView'
|
|
|
import {CACHE_KEY, useCache} from "@/hooks/web/useCache";
|
|
@@ -356,20 +320,8 @@ const formLoading = ref(false) // 表单的加载中:1)修改时的数据加
|
|
|
const formType = ref('') // 表单的类型:create - 新增;update - 修改
|
|
|
const deviceLabel = ref('') // 表单的类型:create - 新增;update - 修改
|
|
|
const list = ref<IotMaintenanceBomVO[]>([]) // 设备bom关联列表的数据
|
|
|
-const devicePersonsMap = ref<Map<number, Set<string>>>(new Map()) // 存储设备-责任人映射
|
|
|
-const tempDevicePersons = ref<Array<{
|
|
|
- tempDeviceIds: number[]
|
|
|
- tempDeviceNames: string
|
|
|
- tempPersonIds: number[]
|
|
|
- tempPersonNames: string
|
|
|
-}>>([])
|
|
|
-const deviceIds = ref<number[]>([]) // 已经选择的设备id数组
|
|
|
-const totalDeviceIds = ref<number[]>([]) // 列表区域暂存的设备id数组 包括之前选择的+当前选择的
|
|
|
|
|
|
-/** 获取当前所有设备ID集合 */
|
|
|
-const getCurrentDeviceIds = (): number[] => {
|
|
|
- return [...new Set(list.value.map(item => item.deviceId))]
|
|
|
-}
|
|
|
+const deviceIds = ref<number[]>([]) // 已经选择的设备id数组
|
|
|
|
|
|
const { params, name } = useRoute() // 查询参数
|
|
|
const id = params.id
|
|
@@ -391,11 +343,6 @@ const formRules = reactive({
|
|
|
})
|
|
|
const formRef = ref() // 表单 Ref
|
|
|
|
|
|
-interface DevicePerson {
|
|
|
- deviceId: number
|
|
|
- personName: string
|
|
|
-}
|
|
|
-
|
|
|
// 新增配置相关状态
|
|
|
const configDialog = reactive({
|
|
|
visible: false,
|
|
@@ -511,48 +458,6 @@ const queryParams = reactive({
|
|
|
bomFlag: 'b'
|
|
|
})
|
|
|
|
|
|
-/**
|
|
|
- * 根据选择的设备查询所有设备关联的 责任人姓名 逗号分隔
|
|
|
- */
|
|
|
-async function getDevicePersons() {
|
|
|
- // 获取当前已经选择的设备ID集合
|
|
|
- const existDeviceIds = getCurrentDeviceIds()
|
|
|
- if (existDeviceIds.length === 0) {
|
|
|
- formData.value.devicePersons = ''
|
|
|
- return
|
|
|
- }
|
|
|
- try {
|
|
|
- // 调用接口获取数据
|
|
|
- const params = {
|
|
|
- deviceIds: existDeviceIds.join(',') // 明确传递数组参数
|
|
|
- }
|
|
|
- const res = await IotDevicePersonApi.getPersonsByDeviceIds(params)
|
|
|
- const personsData = res || []
|
|
|
- // 清空旧数据
|
|
|
- devicePersonsMap.value.clear()
|
|
|
- // 处理接口数据
|
|
|
- personsData.forEach((item: { deviceId: number; personName: string }) => {
|
|
|
- if (!devicePersonsMap.value.has(item.deviceId)) {
|
|
|
- devicePersonsMap.value.set(item.deviceId, new Set())
|
|
|
- }
|
|
|
- devicePersonsMap.value.get(item.deviceId)?.add(item.personName)
|
|
|
- })
|
|
|
- // 生成展示字符串
|
|
|
- updateDevicePersonsDisplay()
|
|
|
- } catch (error) {
|
|
|
- console.error('获取设备责任人失败:', error)
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-/** 更新责任人显示 */
|
|
|
-function updateDevicePersonsDisplay() {
|
|
|
- const allNames = new Set<string>()
|
|
|
- devicePersonsMap.value.forEach(names => {
|
|
|
- names.forEach(name => allNames.add(name))
|
|
|
- })
|
|
|
- formData.value.devicePersons = Array.from(allNames).join(', ')
|
|
|
-}
|
|
|
-
|
|
|
const deviceChoose = async(selectedDevices) => {
|
|
|
const newIds = selectedDevices.map(device => device.id)
|
|
|
deviceIds.value = [...new Set([...deviceIds.value, ...newIds])]
|
|
@@ -561,7 +466,7 @@ const deviceChoose = async(selectedDevices) => {
|
|
|
}
|
|
|
queryParams.deviceIds = JSON.parse(JSON.stringify(params.deviceIds))
|
|
|
queryParams.bomFlag = 'b'
|
|
|
- // 根据选择的设备筛选出设备关系的分类BOM中与保养相关的节点项
|
|
|
+ // 根据选择的设备筛选出设备BOM中与保养相关的节点项
|
|
|
const res = await IotDeviceApi.deviceAssociateBomList(queryParams)
|
|
|
const rawData = res || []
|
|
|
if(rawData.length === 0){
|
|
@@ -571,8 +476,20 @@ const deviceChoose = async(selectedDevices) => {
|
|
|
console.error('接口返回数据结构异常:', rawData)
|
|
|
return
|
|
|
}
|
|
|
+
|
|
|
+ // 创建当前列表的唯一键集合(关键修改)
|
|
|
+ const existingKeys = new Set(
|
|
|
+ list.value.map(item => `${item.deviceId}-${item.bomNodeId}`)
|
|
|
+ )
|
|
|
+
|
|
|
// 转换数据结构(根据你的接口定义调整)
|
|
|
- const newItems = rawData.map(device => ({
|
|
|
+ const newItems = rawData
|
|
|
+ .filter(device => {
|
|
|
+ // 排除已存在的项(设备ID+bom节点ID)
|
|
|
+ const key = `${device.id}-${device.bomNodeId}`
|
|
|
+ return !existingKeys.has(key)
|
|
|
+ })
|
|
|
+ .map(device => ({
|
|
|
assetClass: device.assetClass,
|
|
|
deviceCode: device.deviceCode,
|
|
|
deviceName: device.deviceName,
|
|
@@ -842,8 +759,6 @@ const handleDelete = async (str: string) => {
|
|
|
const hasOtherItems = list.value.some(item => item.deviceId === deviceId)
|
|
|
if (!hasOtherItems) {
|
|
|
deviceIds.value = deviceIds.value.filter(id => id !== deviceId)
|
|
|
- devicePersonsMap.value.delete(deviceId) // 移除对应设备的责任人
|
|
|
- updateDevicePersonsDisplay() // 立即更新显示
|
|
|
}
|
|
|
// message.success('移除成功')
|
|
|
} catch (error) {
|