yanghao 2 일 전
부모
커밋
b1633b216a

+ 13 - 1
src/api/pms/bom/index.ts

@@ -5,6 +5,7 @@ export interface BomVO {
   name: string
   code: string
   parentId: number
+  deptId?: number
   deviceCategoryId: number
   status: number
   sort: number
@@ -12,9 +13,15 @@ export interface BomVO {
   createTime: Date
 }
 
+export interface BomListTreeReqVO extends PageParam {
+  deptId?: number
+  name?: string
+  status?: number
+}
+
 // 查询bom(精简)列表
 export const getSimpleBomList = async (params: PageParam): Promise<BomVO[]> => {
-  return await request.get({ url: '/rq/iot-bom/simple-list', params})
+  return await request.get({ url: '/rq/iot-bom/simple-list', params })
 }
 
 // 查询Bom树列表
@@ -22,6 +29,11 @@ export const getBomPage = async (params: PageParam) => {
   return await request.get({ url: '/rq/iot-bom/list', params })
 }
 
+// 查询Bom树形列表
+export const getBomListTree = async (params: BomListTreeReqVO) => {
+  return await request.get({ url: '/rq/iot-bom/listTree', params })
+}
+
 // 查询Bom树节点详情
 export const getBom = async (id: number) => {
   return await request.get({ url: '/rq/iot-bom/get?id=' + id })

+ 31 - 24
src/components/DailyTableColumn/index.vue

@@ -37,18 +37,13 @@
                   <div class="flex items-center gap-x-2">
                     <div class="flex items-center">
                       <div class="i-carbon-calendar mr-1 -translate-y-[0.5px]"></div>
-                      <div class="font-medium mr-2">{{
-                        dayjs(row.createTime).format('YYYY-MM-DD')
-                      }}</div>
-                      <div class="flex items-center">
-                        <span>{{ formatT(row.reportDetails[0].startTime) }}</span>
-                        <span class="mx-1">-</span>
-                        <span>{{ formatT(row.reportDetails[0].endTime) }}</span>
+                      <div class="font-medium mr-2">
+                        {{ getReportDetailsTimeRange(row) }}
                       </div>
                     </div>
 
                     <div class="ml-auto group-hover:text-blue-600 font-medium">
-                      {{ row.reportDetails[0].duration }} H
+                      {{ getReportDetailsDuration(row.reportDetails) }} H
                     </div>
                   </div>
                   <!--
@@ -120,18 +115,13 @@
                   <div class="flex items-center gap-x-2">
                     <div class="flex items-center">
                       <div class="i-carbon-calendar mr-1 -translate-y-[0.5px]"></div>
-                      <div class="font-medium mr-2">{{
-                        dayjs(row.reportDetails[0].reportDate).format('YYYY-MM-DD')
-                      }}</div>
-                      <div class="flex items-center">
-                        <span>{{ formatT(row.reportDetails[0].startTime) }}</span>
-                        <span class="mx-1">-</span>
-                        <span>{{ formatT(row.reportDetails[0].endTime) }}</span>
+                      <div class="font-medium mr-2">
+                        {{ getReportDetailsTimeRange(row) }}
                       </div>
                     </div>
 
                     <div class="ml-auto group-hover:text-blue-600 font-medium">
-                      {{ row.reportDetails[0].duration }} H
+                      {{ getReportDetailsDuration(row.reportDetails) }} H
                     </div>
                   </div>
 
@@ -240,18 +230,13 @@
                   <div class="flex items-center gap-x-2">
                     <div class="flex items-center">
                       <div class="i-carbon-calendar mr-1 -translate-y-[0.5px]"></div>
-                      <div class="font-medium mr-2">{{
-                        dayjs(row.reportDetails[0].reportDate).format('YYYY-MM-DD')
-                      }}</div>
-                      <div class="flex items-center">
-                        <span>{{ formatT(row.reportDetails[0].startTime) }}</span>
-                        <span class="mx-1">-</span>
-                        <span>{{ formatT(row.reportDetails[0].endTime) }}</span>
+                      <div class="font-medium mr-2">
+                        {{ getReportDetailsTimeRange(row) }}
                       </div>
                     </div>
 
                     <div class="ml-auto group-hover:text-blue-600 font-medium">
-                      {{ row.reportDetails[0].duration }} H
+                      {{ getReportDetailsDuration(row.reportDetails) }} H
                     </div>
                   </div>
 
@@ -374,6 +359,28 @@ const props = defineProps<{
 
 const { columns, company } = toRefs(props)
 
+const getReportDetailsDuration = (reportDetails: any[] = []) =>
+  Number(reportDetails.reduce((sum, item) => sum + Number(item.duration || 0), 0).toFixed(2))
+
+const formatReportDetailTime = (time?: number[] | string) =>
+  Array.isArray(time) ? formatT(time) : time || ''
+
+const getReportDetailsTimeRange = (row: any) => {
+  const reportDetails = row.reportDetails || []
+  const first = reportDetails[0]
+  const last = reportDetails.at(-1)
+  if (!first || !last) return ''
+
+  const startDate = first.reportDate ?? row.createTime
+  const endDate = last.endDateTime ?? last.reportDate ?? row.createTime
+  const startTime = formatReportDetailTime(first.startTime)
+  const endTime = formatReportDetailTime(last.endTime)
+
+  return `${dayjs(startDate).format('YYYY-MM-DD')} ${startTime} - ${dayjs(endDate).format(
+    'YYYY-MM-DD'
+  )} ${endTime}`
+}
+
 const tagType = (status: number) => {
   switch (status) {
     case 0:

+ 326 - 383
src/views/pms/bom/index.vue

@@ -1,299 +1,200 @@
-<template>
-  <doc-alert title="用户体系" url="https://doc.iocoder.cn/user-center/" />
-  <doc-alert title="三方登陆" url="https://doc.iocoder.cn/social-user/" />
-  <doc-alert title="Excel 导入导出" url="https://doc.iocoder.cn/excel-import-and-export/" />
-
-  <el-row :gutter="20">
-    <!-- 左侧 设备分类 树 -->
-    <el-col :span="4" :xs="24">
-      <ContentWrap class="h-1/1">
-        <DeviceCategoryTree @node-click="handleDeviceCategoryTreeNodeClick" />
-      </ContentWrap>
-    </el-col>
-    <el-col :span="20" :xs="24">
-      <!-- 搜索 -->
-      <ContentWrap>
-        <el-form
-          class="-mb-15px"
-          :model="queryParams"
-          ref="queryFormRef"
-          :inline="true"
-          label-width="110px"
-        >
-          <el-form-item label="BOM节点名称" prop="name">
-            <el-input
-              v-model="queryParams.name"
-              placeholder="请输入BOM节点名称"
-              clearable
-              @keyup.enter="handleQuery"
-              class="!w-240px"
-            />
-          </el-form-item>
-          <el-form-item label="BOM节点" prop="status">
-            <el-select
-              v-model="queryParams.status"
-              placeholder="请选择BOM节点"
-              clearable
-              class="!w-240px"
-            >
-              <el-option
-                v-for="dict in getIntDictOptions(DICT_TYPE.COMMON_STATUS)"
-                :key="dict.value"
-                :label="dict.label"
-                :value="dict.value"
-              />
-            </el-select>
-          </el-form-item>
-          <el-form-item>
-            <el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
-            <el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
-            <el-button
-              type="primary"
-              plain
-              @click="openForm('create', null)"
-              v-hasPermi="['rq:iot-bom:create']"
-            >
-              <Icon icon="ep:plus" class="mr-5px" /> 新增
-            </el-button>
-            <el-button type="danger" plain @click="toggleExpandAll">
-              <Icon icon="ep:sort" class="mr-5px" /> 展开/折叠
-            </el-button>
-            <!--
-            <el-button @click="handleAllQuery"><Icon icon="ep:search" class="mr-5px" /> 查询所有</el-button> -->
-          </el-form-item>
-        </el-form>
-      </ContentWrap>
-
-      <ContentWrap>
-        <el-table
-          v-loading="loading"
-          :data="list"
-          row-key="id"
-          :default-expand-all="isExpandAll"
-          v-if="refreshTable"
-          style="width: 100%"
-          @row-click="handleClick"
-        >
-          <el-table-column prop="name" label="BOM节点" >
-            <template #default="scope">
-              <!-- 使用 el-tooltip 包裹内容 -->
-              <el-tooltip
-                effect="dark"
-                :content="`设备分类:${scope.row.deviceCategoryName || '暂无'}`"
-                placement="top-start"
-                :disabled="!scope.row.deviceCategoryName"
-              >
-                <!-- 原有显示名称 -->
-                <span class="bom-node-name">
-                  {{ scope.row.name }}
-                </span>
-              </el-tooltip>
-            </template>
-          </el-table-column>
-          <el-table-column prop="deviceCategoryName" label="设备分类" />
-          <el-table-column label="维修" width="100">
-            <template #default="scope">
-              <el-switch
-                :model-value="scope.row.type?.includes(1)"
-                active-value
-                inactive-value
-                disabled
-              />
-            </template>
-          </el-table-column>
-          <el-table-column label="保养" width="100">
-            <template #default="scope">
-              <el-switch
-                :model-value="scope.row.type?.includes(2)"
-                active-value
-                inactive-value
-                disabled
-              />
-            </template>
-          </el-table-column>
-          <el-table-column prop="sort" label="排序" width="80"/>
-          <!-- <el-table-column prop="status" label="状态" width="80">
-            <template #default="scope">
-              <dict-tag :type="DICT_TYPE.COMMON_STATUS" :value="scope.row.status" />
-            </template>
-          </el-table-column> -->
-          <!--
-          <el-table-column
-            label="创建时间"
-            align="center"
-            prop="createTime"
-            :formatter="dateFormatter"
-          /> -->
-          <el-table-column prop="materials" label="物料数量" width="80"/>
-          <el-table-column label="操作" align="center" width="300">
-            <template #default="scope">
-              <el-button
-                link
-                type="primary"
-                @click="openForm('update', scope.row)"
-                v-hasPermi="['rq:iot-bom:update']"
-              >
-                修改
-              </el-button>
-              <el-button
-                link
-                type="primary"
-                @click="openSelectMaterialForm(scope.row)"
-                v-hasPermi="['rq:iot-bom:update']"
-              >
-                添加物料
-              </el-button>
-              <el-button
-                link
-                type="primary"
-                @click="handleView(scope.row)"
-                v-hasPermi="['rq:iot-bom:update']"
-              >
-                物料详情
-              </el-button>
-              <el-button
-                link
-                type="danger"
-                @click="handleDelete(scope.row.id)"
-                v-hasPermi="['rq:iot-bom:delete']"
-              >
-                删除
-              </el-button>
-            </template>
-          </el-table-column>
-        </el-table>
-      </ContentWrap>
-    </el-col>
-  </el-row>
-
-  <!-- 添加或修改 Bom树节点 对话框 -->
-  <BomForm ref="formRef" :category_id="selectedId" @success="getList" />
-  <!-- 添加物料列表 -->
-  <MaterialList ref="materialListRef" @choose="chooseMaterial" />
-  <!-- 抽屉组件 -->
-  <MaterialListDrawer
-    :model-value="drawerVisible"
-    @update:model-value="val => drawerVisible = val"
-    :node-id="currentBomNodeId"
-    ref="showDrawer"
-    :row-info="currentRowInfo"
-    @refresh="handleDrawerClosed"
-  />
-</template>
 <script lang="ts" setup>
+import { useTableComponents } from '@/components/ZmTable/useTableComponents'
 import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
 import * as BomApi from '@/api/pms/bom'
-import {CommonBomMaterialApi, CommonBomMaterialVO} from '@/api/pms/commonbommaterial'
+import { CommonBomMaterialApi, CommonBomMaterialVO } from '@/api/pms/commonbommaterial'
+import { useTreeStore } from '@/store/modules/treeStore'
+import { useUserStore } from '@/store/modules/user'
 import BomForm from './BomForm.vue'
-import DeviceCategoryTree from './DeviceCategoryTree.vue'
-import { useTreeStore } from '@/store/modules/treeStore';
-import { ref, computed } from 'vue';
-import { handleTree } from '@/utils/tree'
-import MaterialList from "@/views/pms/bom/MaterialList.vue";
-import MaterialListDrawer from "@/views/pms/bom/MaterialListDrawer.vue";
+import MaterialList from '@/views/pms/bom/MaterialList.vue'
+import MaterialListDrawer from '@/views/pms/bom/MaterialListDrawer.vue'
 
 defineOptions({ name: 'Bom' })
 
-const showDrawer = ref()
-const drawerVisible = ref<boolean>(false)
-const treeStore = useTreeStore();
-const message = useMessage() // 消息弹窗
-const { t } = useI18n() // 国际化
-const isExpandAll = ref(true) // 是否展开,默认全部展开
-const loading = ref(true) // 列表的加载中
-const currentBomNodeId = ref() // 当前选中的bom节点
-const refreshTable = ref(true) // 重新渲染表格状态
-const list = ref() // 列表的数据
-
-// 添加存储当前行信息的变量 抽屉页面使用
-const currentRowInfo = ref({
-  deviceCategoryName: '',
-  bomNodeName: ''
-})
+type BomRow = Omit<BomApi.BomVO, 'id'> & {
+  id: number
+  children?: BomRow[]
+  deviceCategoryName?: string
+  materials?: number
+}
 
-const queryParams = reactive({
+const { t } = useI18n()
+const message = useMessage()
+const treeStore = useTreeStore()
+const { ZmTable, ZmTableColumn } = useTableComponents<BomRow>()
+
+const rootDeptId = 156
+const deptId = useUserStore().getUser.deptId || rootDeptId
+
+const initQuery: BomApi.BomListTreeReqVO = {
   pageNo: 1,
   pageSize: 10,
+  deptId: undefined,
   name: undefined,
-  status: undefined,
-  deviceCategoryId: undefined,
-})
-const queryFormRef = ref() // 搜索的表单
+  status: undefined
+}
+
+const queryParams = reactive<BomApi.BomListTreeReqVO>({ ...initQuery })
+const queryFormRef = ref()
+const loading = ref(false)
+const isExpandAll = ref(true)
+const refreshTable = ref(true)
+const list = ref<BomRow[]>([])
+const total = ref(0)
+const selectedRow = ref<BomRow>()
+const parentId = ref<number>()
+const currentBomNodeId = ref<number>()
+const drawerVisible = ref(false)
+const showDrawer = ref()
+const materialListRef = ref()
+const formRef = ref()
 
-const selectedRow = ref<any>(null)
+const currentRowInfo = ref({
+  deviceCategoryName: '',
+  bomNodeName: ''
+})
 
-const CommonBomMaterialData = ref({
+const commonBomMaterialData = ref({
   id: undefined,
   deviceCategoryId: undefined,
   bomNodeId: undefined,
   name: undefined,
   code: undefined,
   materialId: undefined,
-  quantity: undefined,
+  quantity: undefined
 })
 
-// 从 Store 中获取左侧设备分类树选中的 节点ID
-let selectedId = computed(() => treeStore.selectedId);
+const selectedId = computed(() => treeStore.selectedId)
 
-/** 查询 BOM树 列表 */
+const normalizeListTreeResult = (data: BomRow[] | PageResult<BomRow[]>) => {
+  if (Array.isArray(data)) {
+    return {
+      list: data,
+      total: data.length
+    }
+  }
+
+  return {
+    list: data?.list || [],
+    total: data?.total || 0
+  }
+}
+
+const hasBomType = (row: BomRow, type: number) => {
+  return row.type?.some((item) => Number(item) === type) || false
+}
+
+/** 查询 BOM 树列表 */
 const getList = async () => {
   loading.value = true
   try {
-    const data = await BomApi.getBomPage(queryParams)
-    list.value = handleTree(data)
+    const data = await BomApi.getBomListTree(queryParams)
+    const result = normalizeListTreeResult(data)
+    list.value = result.list
+    total.value = result.total
   } finally {
     loading.value = false
   }
 }
 
-/** 选择物料操作 */
-const materialListRef = ref()
-const openSelectMaterialForm = (row: any) => {
+const handleQuery = () => {
+  queryParams.pageNo = 1
+  getList()
+}
+
+const resetQuery = () => {
+  Object.assign(queryParams, { ...initQuery })
+  queryFormRef.value?.resetFields()
+  clearRowSelection()
+  handleQuery()
+}
+
+const handleSizeChange = (val: number) => {
+  queryParams.pageSize = val
+  handleQuery()
+}
+
+const handleCurrentChange = (val: number) => {
+  queryParams.pageNo = val
+  getList()
+}
+
+const handleDeptNodeClick = async (row: Tree) => {
+  clearRowSelection()
+  queryParams.deptId = row.id
+  queryParams.pageNo = 1
+  await getList()
+}
+
+const handleClick = (row: BomRow) => {
+  parentId.value = row.id
+  selectedRow.value = row
+}
+
+const clearRowSelection = () => {
+  selectedRow.value = undefined
+  parentId.value = undefined
+}
+
+const openForm = (type: string, row?: BomRow | null) => {
+  if (type === 'create' && selectedRow.value) {
+    formRef.value.open(type, null, selectedRow.value.id, selectedRow.value.deviceCategoryId)
+    return
+  }
+
+  if (row) {
+    treeStore.setSelectedId(row.deviceCategoryId)
+    formRef.value.open(type, row.id, row.parentId, row.deviceCategoryId)
+    return
+  }
+
+  formRef.value.open(type, null, parentId.value, selectedId.value)
+}
+
+const toggleExpandAll = () => {
+  refreshTable.value = false
+  isExpandAll.value = !isExpandAll.value
+  nextTick(() => {
+    refreshTable.value = true
+  })
+}
+
+const openSelectMaterialForm = (row: BomRow) => {
   materialListRef.value.open(row)
   currentBomNodeId.value = row.id
-  // 保存当前BOM节点的deviceCategoryId
-  CommonBomMaterialData.value.deviceCategoryId = row.deviceCategoryId
+  commonBomMaterialData.value.deviceCategoryId = row.deviceCategoryId
 }
 
-/** 查看物料详情 */
-const handleView = async (row) => {
+const handleView = async (row: BomRow) => {
   currentBomNodeId.value = row.id
-  // 保存当前行的信息
   currentRowInfo.value = {
     deviceCategoryName: row.deviceCategoryName || '暂无',
     bomNodeName: row.name || '暂无'
   }
   drawerVisible.value = true
   showDrawer.value.openDrawer()
-  // 强制刷新物料数据
   await showDrawer.value.loadMaterials(row.id)
 }
 
-const chooseSingleMaterial = async(row) => {
-  // 将物料关联到bom节点
+const chooseSingleMaterial = async (row) => {
   try {
-    // CommonBomMaterialData.value.deviceCategoryId = row.deviceCategoryId
-    CommonBomMaterialData.value.bomNodeId = currentBomNodeId.value
-    CommonBomMaterialData.value.materialId = row.id
-    CommonBomMaterialData.value.name = row.name
-    CommonBomMaterialData.value.code = row.code
-    const data = CommonBomMaterialData.value as unknown as CommonBomMaterialVO
-    await CommonBomMaterialApi.createCommonBomMaterial(data);
+    commonBomMaterialData.value.bomNodeId = currentBomNodeId.value
+    commonBomMaterialData.value.materialId = row.id
+    commonBomMaterialData.value.name = row.name
+    commonBomMaterialData.value.code = row.code
+    const data = commonBomMaterialData.value as unknown as CommonBomMaterialVO
+    await CommonBomMaterialApi.createCommonBomMaterial(data)
     message.success(t('common.createSuccess'))
-    // 保存成功后立即刷新抽屉数据
     showDrawer.value.loadMaterials(currentBomNodeId.value)
     await getList()
   } finally {
-    // formLoading.value = false
   }
 }
 
-const chooseMaterial = async(selectedMaterials) => {
-  // 将物料关联到bom节点
+const chooseMaterial = async (selectedMaterials) => {
   try {
-    // 转换数据结构(根据接口定义调整)
-    const materialsData = selectedMaterials.map(material => ({
-      deviceCategoryId: CommonBomMaterialData.value.deviceCategoryId,
+    const materialsData = selectedMaterials.map((material) => ({
+      deviceCategoryId: commonBomMaterialData.value.deviceCategoryId,
       bomNodeId: currentBomNodeId.value,
       materialId: material.id,
       name: material.name,
@@ -301,12 +202,8 @@ const chooseMaterial = async(selectedMaterials) => {
       quantity: material.quantity
     }))
 
-    // 调用批量添加接口
     const resultCount = await CommonBomMaterialApi.addMaterials(materialsData)
-    message.success(`成功添加物料数量:` + resultCount)
-
-    // message.success(t('common.createSuccess'))
-    // 保存成功后立即刷新抽屉数据
+    message.success(`成功添加物料数量:${resultCount}`)
     showDrawer.value.loadMaterials(currentBomNodeId.value)
     await getList()
   } catch (error) {
@@ -314,168 +211,214 @@ const chooseMaterial = async(selectedMaterials) => {
   }
 }
 
-/** 搜索按钮操作 */
-const handleQuery = () => {
-  queryParams.pageNo = 1
-  queryParams.deviceCategoryId = selectedId.value
-  getList()
-}
-
-/** 查询所有数据 */
-const handleAllQuery = () => {
-  queryParams.pageNo = 1
-  queryParams.deviceCategoryId = ''
-  getList()
-}
-
-/** 重置按钮操作 */
-const resetQuery = () => {
-  queryFormRef.value?.resetFields()
-  handleQuery()
-}
-
-/** 处理 设备分类 被点击 */
-const handleDeviceCategoryTreeNodeClick = async (row) => {
-  clearRowSelection() //清除表格行选择
-  queryParams.deviceCategoryId = row.id
-  await getList()
-}
-
-// 添加处理抽屉关闭的方法
 const handleDrawerClosed = () => {
-  getList() // 刷新BOM树数据
-}
-
-const parentId = ref('')
-const handleClick = (row: any) => {
-   parentId.value = row.id
-   selectedRow.value = row // 存储整行数据
-  console.log('当前行被点击了:' + selectedRow.value.deviceCategoryId)
-}
-
-/** 添加/修改操作 */
-const formRef = ref()
-const openForm = (type: string, row) => {
-  // 优先使用设备分类树的选择(当selectedRow不存在时)
-  const useTreeSelection = !selectedRow.value && selectedId.value
-
-  // 新增操作时使用选中行的数据
-  if (type === 'create' && selectedRow.value) {
-    formRef.value.open(
-      type,
-      null,
-      selectedRow.value?.id || (useTreeSelection ? undefined : undefined), // 作为 parentId
-      selectedRow.value?.deviceCategoryId || selectedId.value // // 设备分类ID:表格行 > 设备分类树 > 无
-    )
-    return
-  }
-  // 如果是没有点击左侧设备树 直接在初始化的列表页面点击某个 BOM节点的修改 也要保存当前BOM关联的设备分类ID
-  if(row != null) {
-    treeStore.setSelectedId(row.deviceCategoryId)
-    formRef.value.open(type, row.id, parentId.value)
-    return
-  }
-  formRef.value.open(type, null, parentId.value)
-}
-
-/** 展开/折叠操作 */
-const toggleExpandAll = () => {
-  refreshTable.value = false
-  isExpandAll.value = !isExpandAll.value
-  nextTick(() => {
-    refreshTable.value = true
-  })
-}
-
-// 清除表格行选择
-const clearRowSelection = () => {
-  selectedRow.value = null
-  parentId.value = ''
+  getList()
 }
 
-/** 删除按钮操作 */
 const handleDelete = async (id: number) => {
   try {
-    // 查找目标节点及其在树中的位置
-    const targetNode = findNodeById(list.value, id);
+    const targetNode = findNodeById(list.value, id)
 
-    // 检查是否存在子节点(使用 children 属性)
-    if (targetNode && targetNode.children && targetNode.children.length > 0) {
-      message.error('当前BOM节点包含子节点,不可删除');
-      return;
+    if (targetNode?.children?.length) {
+      message.error('当前BOM节点包含子节点,不可删除')
+      return
     }
 
-    // 删除的二次确认
     await message.delConfirm()
-    // 发起删除
     await BomApi.deleteBomNode(id)
     message.success(t('common.delSuccess'))
-    // 刷新列表
     await getList()
   } catch {}
 }
 
-/** 初始化 */
-onMounted(() => {
-  getList()
-})
+const findNodeById = (nodes: BomRow[], id: number): BomRow | undefined => {
+  for (const node of nodes) {
+    if (node.id === id) return node
 
-// 自定义箭头展开位置
-const toggleRowExpansion = (row) => {
-  const $table = document.querySelector('.el-table__body-wrapper') as any
-  if ($table) {
-    $table.__vue__.toggleRowExpansion(row)
+    if (node.children?.length) {
+      const foundInChildren = findNodeById(node.children, id)
+      if (foundInChildren) return foundInChildren
+    }
   }
-}
 
-const isExpanded = (row) => {
-  const $table = document.querySelector('.el-table__body-wrapper') as any
-  return $table?.__vue__.store.states.expandRows.value.includes(row)
+  return undefined
 }
 
-/**
- * 递归查找树节点
- * 基于 handleTree 处理后的树结构(包含 children 属性)
- * @param nodes 树节点数组
- * @param id 要查找的节点ID
- * @returns 找到的节点或 undefined
- */
-const findNodeById = (nodes: any[], id: number): any | undefined => {
-  // 遍历当前层级节点
-  for (const node of nodes) {
-    // 1. 检查当前节点是否匹配
-    if (node.id === id) return node;
-
-    // 2. 检查当前节点是否有子节点
-    if (node.children && node.children.length > 0) {
-      // 递归搜索子节点
-      const foundInChildren = findNodeById(node.children, id);
-      if (foundInChildren) return foundInChildren;
-    }
-  }
+onMounted(() => {
+  getList()
+})
+</script>
 
-  return undefined; // 未找到
-};
+<template>
+  <div
+    class="grid grid-cols-[auto_1fr] grid-rows-[auto_1fr] gap-4 h-[calc(100vh-20px-var(--top-tool-height)-var(--tags-view-height)-var(--app-footer-height))]">
+    <DeptTreeSelect
+      :top-id="rootDeptId"
+      :deptId="deptId"
+      v-model="queryParams.deptId"
+      :show-title="false"
+      request-api="getSimpleDeptList"
+      class="row-span-2" />
+
+    <el-form
+      ref="queryFormRef"
+      :model="queryParams"
+      size="default"
+      label-width="110px"
+      class="bg-white dark:bg-[#1d1e1f] rounded-lg shadow px-8 py-3 gap-6 flex items-center justify-between flex-wrap min-w-0">
+      <div class="flex items-center gap-6 flex-wrap">
+        <el-form-item label="BOM节点名称" prop="name">
+          <el-input
+            v-model="queryParams.name"
+            placeholder="请输入BOM节点名称"
+            clearable
+            class="!w-220px"
+            @keyup.enter="handleQuery" />
+        </el-form-item>
+        <el-form-item label="BOM节点" prop="status">
+          <el-select
+            v-model="queryParams.status"
+            placeholder="请选择BOM节点"
+            clearable
+            class="!w-180px">
+            <el-option
+              v-for="dict in getIntDictOptions(DICT_TYPE.COMMON_STATUS)"
+              :key="dict.value"
+              :label="dict.label"
+              :value="dict.value" />
+          </el-select>
+        </el-form-item>
+      </div>
+
+      <el-form-item>
+        <el-button type="primary" @click="handleQuery">
+          <Icon icon="ep:search" class="mr-5px" />搜索
+        </el-button>
+        <el-button @click="resetQuery"> <Icon icon="ep:refresh" class="mr-5px" />重置 </el-button>
+        <el-button
+          type="primary"
+          plain
+          @click="openForm('create', null)"
+          v-hasPermi="['rq:iot-bom:create']">
+          <Icon icon="ep:plus" class="mr-5px" />新增
+        </el-button>
+        <el-button type="danger" plain @click="toggleExpandAll">
+          <Icon icon="ep:sort" class="mr-5px" />展开/折叠
+        </el-button>
+      </el-form-item>
+    </el-form>
+
+    <div class="bg-white dark:bg-[#1d1e1f] shadow rounded-lg flex flex-col p-4 min-w-0">
+      <div class="flex-1 relative min-h-0">
+        <el-auto-resizer class="absolute">
+          <template #default="{ width, height }">
+            <ZmTable
+              v-if="refreshTable"
+              :data="list"
+              :loading="loading"
+              :width="width"
+              :height="height"
+              :max-height="height"
+              :default-expand-all="isExpandAll"
+              row-key="id"
+              show-border
+              @row-click="handleClick">
+              <ZmTableColumn prop="name" label="BOM节点" min-width="180" align="left" fixed="left">
+                <template #default="{ row }">
+                  <el-tooltip
+                    effect="dark"
+                    :content="`设备分类:${row.deviceCategoryName || '暂无'}`"
+                    placement="top-start"
+                    :disabled="!row.deviceCategoryName">
+                    <span class="bom-node-name">{{ row.name }}</span>
+                  </el-tooltip>
+                </template>
+              </ZmTableColumn>
+              <ZmTableColumn prop="deviceCategoryName" label="设备分类" min-width="140" />
+              <ZmTableColumn label="维修" width="90">
+                <template #default="{ row }">
+                  <el-switch :model-value="hasBomType(row, 1)" disabled />
+                </template>
+              </ZmTableColumn>
+              <ZmTableColumn label="保养" width="90">
+                <template #default="{ row }">
+                  <el-switch :model-value="hasBomType(row, 2)" disabled />
+                </template>
+              </ZmTableColumn>
+              <ZmTableColumn prop="sort" label="排序" width="80" />
+              <ZmTableColumn prop="materials" label="物料数量" width="100" />
+              <ZmTableColumn label="操作" width="300" fixed="right" action>
+                <template #default="{ row }">
+                  <el-button
+                    link
+                    type="primary"
+                    @click="openForm('update', row)"
+                    v-hasPermi="['rq:iot-bom:update']">
+                    修改
+                  </el-button>
+                  <el-button
+                    link
+                    type="primary"
+                    @click="openSelectMaterialForm(row)"
+                    v-hasPermi="['rq:iot-bom:update']">
+                    添加物料
+                  </el-button>
+                  <el-button
+                    link
+                    type="primary"
+                    @click="handleView(row)"
+                    v-hasPermi="['rq:iot-bom:update']">
+                    物料详情
+                  </el-button>
+                  <el-button
+                    link
+                    type="danger"
+                    @click="handleDelete(row.id)"
+                    v-hasPermi="['rq:iot-bom:delete']">
+                    删除
+                  </el-button>
+                </template>
+              </ZmTableColumn>
+            </ZmTable>
+          </template>
+        </el-auto-resizer>
+      </div>
+
+      <div class="h-8 mt-2 flex items-center justify-end">
+        <el-pagination
+          v-show="total > 0"
+          size="default"
+          :current-page="queryParams.pageNo"
+          :page-size="queryParams.pageSize"
+          :background="true"
+          :page-sizes="[10, 20, 30, 50, 100]"
+          :total="total"
+          layout="total, sizes, prev, pager, next, jumper"
+          @size-change="handleSizeChange"
+          @current-change="handleCurrentChange" />
+      </div>
+    </div>
+  </div>
 
-</script>
+  <BomForm ref="formRef" :category_id="selectedId" @success="getList" />
+  <MaterialList ref="materialListRef" @choose="chooseMaterial" />
+  <MaterialListDrawer
+    ref="showDrawer"
+    :model-value="drawerVisible"
+    :node-id="currentBomNodeId"
+    :row-info="currentRowInfo"
+    @update:model-value="(val) => (drawerVisible = val)"
+    @refresh="handleDrawerClosed" />
+</template>
 
 <style scoped>
-/* 确保表格容器正确继承宽度 */
-:deep(.el-table) {
-  width: 100% !important;
-}
-
-/* 操作按钮换行优化 */
-.flex-wrap {
-  flex-wrap: wrap;
-}
-.gap-4px {
-  gap: 4px;
+:deep(.el-form-item) {
+  margin-bottom: 0;
 }
 
-/* BOM节点名称样式 */
 .bom-node-name {
-  flex: 1;
+  display: inline-block;
+  max-width: 100%;
   overflow: hidden;
   text-overflow: ellipsis;
   white-space: nowrap;

+ 173 - 128
src/views/pms/iotrddailyreport/FillDailyReportForm.vue

@@ -122,6 +122,8 @@ interface Data {
 }
 
 interface ReportDetail {
+  reportDate: number
+  endDateTime: number
   startTime: string
   endTime: string
   constructionDetail: string
@@ -261,10 +263,15 @@ const initDailyFuel = () => {
 }
 
 const loading = ref(false)
+let loadDetailVersion = 0
+
 async function loadDetail(id: number) {
+  const version = ++loadDetailVersion
   loading.value = true
   try {
     const res = await IotRdDailyReportApi.getIotRdDailyReport(id)
+    if (version !== loadDetailVersion) return
+
     data.value = res
 
     opinion.value = data.value.opinion || ''
@@ -277,12 +284,25 @@ async function loadDetail(id: number) {
     form.value.faultDowntime = data.value.faultDowntime || 0
     form.value.constructionBrief = data.value.constructionBrief || ''
 
-    form.value.reportDetails = (data.value.reportDetails || []).map((item) => ({
-      duration: item.duration || 0,
-      constructionDetail: item.constructionDetail || '',
-      startTime: formatT(item.startTime),
-      endTime: formatT(item.endTime)
-    }))
+    form.value.reportDetails = (data.value.reportDetails || []).map((item) => {
+      const startTime = formatT(item.startTime)
+      const endTime = formatT(item.endTime)
+      const reportDate = item.reportDate ?? data.value.createTime ?? dayjs().valueOf()
+      const endDateTime =
+        item.endDateTime ??
+        (startTime && endTime && dayjs(`1970-01-01 ${endTime}`).isBefore(dayjs(`1970-01-01 ${startTime}`))
+          ? dayjs(reportDate).add(1, 'day').valueOf()
+          : reportDate)
+
+      return {
+        reportDate,
+        endDateTime,
+        duration: item.duration || 0,
+        constructionDetail: item.constructionDetail || '',
+        startTime,
+        endTime
+      }
+    })
 
     if (!form.value.reportDetails.length) {
       addReportDetailRow()
@@ -304,7 +324,9 @@ async function loadDetail(id: number) {
 
     initDailyFuel()
   } finally {
-    loading.value = false
+    if (version === loadDetailVersion) {
+      loading.value = false
+    }
   }
 }
 
@@ -435,6 +457,8 @@ async function submitApprovalForm(auditStatus: number) {
 
 function handleOpenForm(id: number, type: 'edit' | 'approval' | 'detail' | 'time') {
   formType.value = type
+  data.value = {}
+  opinion.value = ''
   form.value = original()
   loadDetail(id).then(() => {
     nextTick(() => formRef.value?.clearValidate())
@@ -450,13 +474,18 @@ function handleCancel() {
   })
 }
 
-onMounted(() => {
-  if (Object.keys(route.query).length > 0) {
-    handleOpenForm(
-      Number(route.query.id),
-      route.query.mode as 'edit' | 'approval' | 'detail' | 'time'
-    )
-  }
+watch(
+  () => [route.query.id, route.query.mode],
+  ([id, mode]) => {
+    if (id && mode) {
+      handleOpenForm(Number(id), mode as 'edit' | 'approval' | 'detail' | 'time')
+    }
+  },
+  { immediate: true }
+)
+
+onUnmounted(() => {
+  loadDetailVersion++
 })
 
 const formDisabled = computed(() => (key?: string) => {
@@ -611,7 +640,10 @@ const addReportDetailRow = () => {
   if (!form.value.reportDetails) {
     form.value.reportDetails = []
   }
+  const reportDate = data.value.createTime ?? dayjs().valueOf()
   form.value.reportDetails.push({
+    reportDate,
+    endDateTime: reportDate,
     startTime: '',
     endTime: '',
     duration: 0,
@@ -636,6 +668,32 @@ const handleListChange = useDebounceFn(() => {
   form.value.dailyFuel = total
 }, 500)
 
+const calculateReportDetailDuration = (row: ReportDetail) => {
+  if (!row.reportDate || !row.endDateTime || !row.startTime || !row.endTime) {
+    calculateDuration(row)
+    return
+  }
+
+  const start = dayjs(row.reportDate)
+    .hour(Number(row.startTime.split(':')[0]))
+    .minute(Number(row.startTime.split(':')[1]))
+    .second(0)
+    .millisecond(0)
+  const end = dayjs(row.endDateTime)
+    .hour(Number(row.endTime.split(':')[0]))
+    .minute(Number(row.endTime.split(':')[1]))
+    .second(0)
+    .millisecond(0)
+
+  let diffMinutes = end.diff(start, 'minute')
+
+  if (diffMinutes < 0) {
+    diffMinutes += 1440
+  }
+
+  row.duration = Number((diffMinutes / 60).toFixed(2))
+}
+
 const platformWorkloadData = computed(() => {
   if (!data.value) return []
   // 需要调整
@@ -780,8 +838,7 @@ const inContent = async (attachment) => {
 <template>
   <div
     class="bg-white rounded-xl shadow size-full flex flex-col gap-4 p-4 mb-12"
-    v-loading="loading"
-  >
+    v-loading="loading">
     <div class="flex justify-between items-start">
       <div class="flex flex-col gap-1">
         <div class="flex items-center gap-3">
@@ -791,8 +848,7 @@ const inContent = async (attachment) => {
           <div
             v-if="header.title"
             class="px-2 py-0.5 rounded text-xs font-medium border"
-            :class="statusClass"
-          >
+            :class="statusClass">
             {{ header.suffix }}
           </div>
         </div>
@@ -810,16 +866,14 @@ const inContent = async (attachment) => {
       v-if="formType !== 'edit'"
       :title="modeNotice"
       type="info"
-      :closable="false"
-    />
+      :closable="false" />
 
     <el-alert
       class="min-h-12"
       v-if="formType !== 'approval' && data.opinion"
       :title="data.opinion"
       type="warning"
-      :closable="false"
-    />
+      :closable="false" />
     <el-divider class="m-0! border-2! border-[var(--el-color-primary)]!" />
 
     <div class="grid grid-cols-3 gap-y-8 gap-x-4">
@@ -910,32 +964,26 @@ const inContent = async (attachment) => {
         <div
           v-for="(item, index) in progressList"
           :key="index"
-          class="group relative flex flex-col items-center flex-1 min-w-[160px] cursor-default select-none"
-        >
+          class="group relative flex flex-col items-center flex-1 min-w-[160px] cursor-default select-none">
           <div
             v-if="index !== progressList.length - 1"
-            class="absolute top-[34px] left-1/2 w-full h-[2px] bg-gray-100 group-hover:bg-blue-50 transition-colors duration-300"
-          >
+            class="absolute top-[34px] left-1/2 w-full h-[2px] bg-gray-100 group-hover:bg-blue-50 transition-colors duration-300">
           </div>
 
           <span
-            class="text-xs font-medium text-gray-400 mb-3 font-mono transition-colors duration-300 group-hover:text-blue-500"
-          >
+            class="text-xs font-medium text-gray-400 mb-3 font-mono transition-colors duration-300 group-hover:text-blue-500">
             {{ item.createTime || '--' }}
           </span>
 
           <div
-            class="relative z-10 mb-3 transition-transform duration-300 group-hover:-translate-y-0.5"
-          >
+            class="relative z-10 mb-3 transition-transform duration-300 group-hover:-translate-y-0.5">
             <div
-              class="w-4 h-4 rounded-full border-[3px] border-white shadow-[0_0_0_2px_rgba(229,231,235,1)] bg-blue-600 group-hover:shadow-[0_0_0_4px_rgba(219,234,254,1)] group-hover:bg-blue-500 transition-all duration-300"
-            >
+              class="w-4 h-4 rounded-full border-[3px] border-white shadow-[0_0_0_2px_rgba(229,231,235,1)] bg-blue-600 group-hover:shadow-[0_0_0_4px_rgba(219,234,254,1)] group-hover:bg-blue-500 transition-all duration-300">
             </div>
           </div>
 
           <span
-            class="text-sm font-bold text-gray-700 px-2 text-center leading-relaxed transition-colors duration-300 group-hover:text-blue-600"
-          >
+            class="text-sm font-bold text-gray-700 px-2 text-center leading-relaxed transition-colors duration-300 group-hover:text-blue-600">
             {{ item.rdStatusLabel || '未知状态' }}
           </span>
         </div>
@@ -952,15 +1000,13 @@ const inContent = async (attachment) => {
       :model="form"
       require-asterisk-position="right"
       class="flex flex-col"
-      :disabled="formDisabled()"
-    >
+      :disabled="formDisabled()">
       <!-- <h3 class="text-lg font-bold text-gray-800 flex items-center gap-2">
         <div class="w-1 h-4 bg-blue-600 rounded-full"></div>
         基础信息
       </h3> -->
       <div
-        class="p-6 rounded-lg shadow border border-solid border-gray-100 grid grid-cols-2 gap-x-8"
-      >
+        class="p-6 rounded-lg shadow border border-solid border-gray-100 grid grid-cols-2 gap-x-8">
         <el-form-item label="时间节点" prop="timeRange">
           <el-time-picker
             v-model="form.timeRange"
@@ -971,8 +1017,7 @@ const inContent = async (attachment) => {
             placeholder="选择时间范围"
             clearable
             format="HH:mm"
-            value-format="HH:mm"
-          />
+            value-format="HH:mm" />
         </el-form-item>
         <el-form-item label="当日油耗(L)" prop="dailyFuel">
           <el-input-number
@@ -981,8 +1026,7 @@ const inContent = async (attachment) => {
             :controls="false"
             align="left"
             class="w-full!"
-            placeholder="请输入当日油耗"
-          >
+            placeholder="请输入当日油耗">
             <template #suffix>升(L)</template>
           </el-input-number>
         </el-form-item>
@@ -993,22 +1037,19 @@ const inContent = async (attachment) => {
             placeholder="请选择施工设备"
             clearable
             filterable
-            tag-type="primary"
-          >
+            tag-type="primary">
             <el-option
               v-for="item in deviceOptions"
               :key="item.id"
               :label="item.deviceName"
-              :value="item.id"
-            >
+              :value="item.id">
               <span class="font-medium">{{ item.deviceCode + ' - ' + item.deviceName }}</span>
             </el-option>
           </el-select>
         </el-form-item>
         <el-form-item class="col-span-2" label="闲置/未施工设备">
           <div
-            class="w-full min-h-[40px] p-3 rounded bg-gray-50 border border-gray-200 border-dashed transition-all"
-          >
+            class="w-full min-h-[40px] p-3 rounded bg-gray-50 border border-gray-200 border-dashed transition-all">
             <template v-if="noSelectedDevices.length > 0">
               <div class="flex flex-wrap gap-2">
                 <el-tag
@@ -1016,8 +1057,7 @@ const inContent = async (attachment) => {
                   :key="device.id"
                   type="info"
                   effect="plain"
-                  class="!border-gray-300"
-                >
+                  class="!border-gray-300">
                   {{ device.deviceName }}
                 </el-tag>
               </div>
@@ -1042,22 +1082,35 @@ const inContent = async (attachment) => {
 
         <el-form-item prop="reportDetails" class="col-span-2">
           <ZmTable :data="form.reportDetails" :loading="false" class="col-span-2">
-            <ZmTableColumn
-              :width="120"
-              label="日期"
-              cover-formatter
-              :real-value="
-                () => (data.createTime ? dayjs(data.createTime).format('YYYY-MM-DD') : '')
-              "
-            />
+            <ZmTableColumn :width="160" label="开始日期" prop="reportDate">
+              <template #default="{ row, $index }">
+                <el-form-item
+                  v-if="$index >= 0"
+                  class="mb-0!"
+                  :prop="`reportDetails.${$index}.reportDate`"
+                  :rules="{
+                    required: true,
+                    message: '请选择开始日期',
+                    trigger: ['change', 'blur'],
+                    type: 'number'
+                  }">
+                  <el-date-picker
+                    v-model="row.reportDate"
+                    placeholder="选择开始日期"
+                    clearable
+                    value-format="x"
+                    class="w-full!"
+                    @change="calculateReportDetailDuration(row)" />
+                </el-form-item>
+              </template>
+            </ZmTableColumn>
             <ZmTableColumn :width="160" label="开始时间" prop="startTime">
               <template #default="{ row, $index }">
                 <el-form-item
                   v-if="$index >= 0"
                   class="mb-0!"
                   :prop="`reportDetails.${$index}.startTime`"
-                  :rules="{ required: true, message: '请选择开始时间', trigger: 'change' }"
-                >
+                  :rules="{ required: true, message: '请选择开始时间', trigger: 'change' }">
                   <el-time-picker
                     v-model="row.startTime"
                     placeholder="选择开始时间"
@@ -1065,8 +1118,29 @@ const inContent = async (attachment) => {
                     format="HH:mm"
                     value-format="HH:mm"
                     class="w-full!"
-                    @change="calculateDuration(row)"
-                  />
+                    @change="calculateReportDetailDuration(row)" />
+                </el-form-item>
+              </template>
+            </ZmTableColumn>
+            <ZmTableColumn :width="160" label="结束日期" prop="endDateTime">
+              <template #default="{ row, $index }">
+                <el-form-item
+                  v-if="$index >= 0"
+                  class="mb-0!"
+                  :prop="`reportDetails.${$index}.endDateTime`"
+                  :rules="{
+                    required: true,
+                    message: '请选择结束日期',
+                    trigger: ['change', 'blur'],
+                    type: 'number'
+                  }">
+                  <el-date-picker
+                    v-model="row.endDateTime"
+                    placeholder="选择结束日期"
+                    clearable
+                    value-format="x"
+                    class="w-full!"
+                    @change="calculateReportDetailDuration(row)" />
                 </el-form-item>
               </template>
             </ZmTableColumn>
@@ -1076,8 +1150,7 @@ const inContent = async (attachment) => {
                   v-if="$index >= 0"
                   class="mb-0!"
                   :prop="`reportDetails.${$index}.endTime`"
-                  :rules="{ required: true, message: '请选择结束时间', trigger: 'change' }"
-                >
+                  :rules="{ required: true, message: '请选择结束时间', trigger: 'change' }">
                   <el-time-picker
                     v-model="row.endTime"
                     placeholder="选择结束时间"
@@ -1085,8 +1158,7 @@ const inContent = async (attachment) => {
                     format="HH:mm"
                     value-format="HH:mm"
                     class="w-full!"
-                    @change="calculateDuration(row)"
-                  />
+                    @change="calculateReportDetailDuration(row)" />
                 </el-form-item>
               </template>
             </ZmTableColumn>
@@ -1097,8 +1169,7 @@ const inContent = async (attachment) => {
                   v-if="$index >= 0"
                   class="mb-0!"
                   :prop="`reportDetails.${$index}.constructionDetail`"
-                  :rules="{ required: true, message: '请输入施工详情', trigger: 'change' }"
-                >
+                  :rules="{ required: true, message: '请输入施工详情', trigger: 'change' }">
                   <el-input
                     v-model="row.constructionDetail"
                     placeholder="输入施工详情"
@@ -1106,8 +1177,7 @@ const inContent = async (attachment) => {
                     :autosize="{ minRows: 1 }"
                     show-word-limit
                     :maxlength="2000"
-                    class="w-full!"
-                  />
+                    class="w-full!" />
                 </el-form-item>
               </template>
             </ZmTableColumn>
@@ -1129,8 +1199,7 @@ const inContent = async (attachment) => {
             resize="none"
             show-word-limit
             :maxlength="1000"
-            placeholder="请输入下步工作计划"
-          />
+            placeholder="请输入下步工作计划" />
         </el-form-item>
         <el-form-item class="col-span-2" label="外租设备" prop="externalRental">
           <el-input
@@ -1140,8 +1209,7 @@ const inContent = async (attachment) => {
             resize="none"
             show-word-limit
             :maxlength="1000"
-            placeholder="请输入外租设备"
-          />
+            placeholder="请输入外租设备" />
         </el-form-item>
         <el-form-item class="col-span-2" label="故障情况" prop="malfunction">
           <el-input
@@ -1151,8 +1219,7 @@ const inContent = async (attachment) => {
             show-word-limit
             resize="none"
             :maxlength="1000"
-            placeholder="请输入故障情况"
-          />
+            placeholder="请输入故障情况" />
         </el-form-item>
         <el-form-item label="故障误工(H)" prop="faultDowntime">
           <el-input-number
@@ -1160,8 +1227,7 @@ const inContent = async (attachment) => {
             :min="0"
             :controls="false"
             align="left"
-            class="w-full!"
-          >
+            class="w-full!">
             <template #suffix>小时(H)</template>
           </el-input-number>
         </el-form-item>
@@ -1172,16 +1238,14 @@ const inContent = async (attachment) => {
             ref="fileUploadRef"
             :device-id="undefined"
             :show-folder-button="false"
-            @upload-success="handleUploadSuccess"
-          />
+            @upload-success="handleUploadSuccess" />
 
           <div v-if="form.attachments && form.attachments.length > 0" class="attachment-container">
             <div class="attachment-list">
               <div
                 v-for="(attachment, index) in form.attachments"
                 :key="attachment.id || index"
-                class="attachment-item"
-              >
+                class="attachment-item">
                 <a class="attachment-name" @click="inContent(attachment)">
                   {{ attachment.filename }}
                 </a>
@@ -1190,8 +1254,7 @@ const inContent = async (attachment) => {
                   type="danger"
                   link
                   size="small"
-                  @click="removeAttachment(index)"
-                >
+                  @click="removeAttachment(index)">
                   删除
                 </el-button>
               </div>
@@ -1216,14 +1279,12 @@ const inContent = async (attachment) => {
           collapse-tags
           collapse-tags-tooltip
           :max-collapse-tags="5"
-          tag-type="primary"
-        />
+          tag-type="primary" />
       </el-form-item>
       <template v-for="(pid, pindex) in form.platformIds" :key="pid">
         <el-divider v-if="pindex !== 0" class="my-6 border-2! border-[var(--el-color-primary)]!" />
         <div
-          class="p-6 rounded-lg shadow border border-solid border-gray-100 grid grid-cols-4 gap-x-8"
-        >
+          class="p-6 rounded-lg shadow border border-solid border-gray-100 grid grid-cols-4 gap-x-8">
           <h3 class="text-lg font-bold text-gray-800 flex items-center gap-2 col-span-4 mb-6">
             <div class="w-1 h-4 bg-blue-600 rounded-full"></div>
             {{ wellOptions.find((item) => item.value === pid)?.label ?? data.wellName ?? '' }}
@@ -1232,15 +1293,13 @@ const inContent = async (attachment) => {
             label="施工状态"
             :prop="`${pid}.rdStatus`"
             :rules="{ required: true, message: '请选择施工状态', trigger: 'change' }"
-            class="col-span-2"
-          >
+            class="col-span-2">
             <el-select
               v-model="form[pid].rdStatus"
               :options="rdStatusOptions"
               placeholder="请选择"
               class="w-full"
-              clearable
-            />
+              clearable />
           </el-form-item>
 
           <el-form-item
@@ -1252,8 +1311,7 @@ const inContent = async (attachment) => {
               trigger: 'change',
               type: 'array'
             }"
-            class="col-span-2"
-          >
+            class="col-span-2">
             <el-select
               v-model="form[pid].techniqueIds"
               :options="techniqueOptions"
@@ -1263,8 +1321,7 @@ const inContent = async (attachment) => {
               placeholder="请选择"
               class="w-full"
               @change="(val) => handleTechniqueChange(val, pid)"
-              clearable
-            />
+              clearable />
           </el-form-item>
 
           <template v-if="form[pid] && form[pid].extProperty">
@@ -1277,16 +1334,14 @@ const inContent = async (attachment) => {
                 attr.required === 1
                   ? [{ required: true, message: `请输入${attr.name}`, trigger: 'blur' }]
                   : []
-              "
-            >
+              ">
               <el-input-number
                 v-if="attr.dataType === 'double'"
                 v-model="attr.actualValue"
                 :controls="false"
                 class="w-full!"
                 align="left"
-                placeholder="请输入"
-              />
+                placeholder="请输入" />
               <el-input type="textarea" v-else v-model="attr.actualValue" placeholder="请输入" />
             </el-form-item>
           </template>
@@ -1300,8 +1355,7 @@ const inContent = async (attachment) => {
             :key="field.key"
             :label="field.label"
             :prop="`${pid}.${field.key}`"
-            :rules="noProductionTimeRule(pid)"
-          >
+            :rules="noProductionTimeRule(pid)">
             <el-input-number
               v-model="form[pid][field.key]"
               :min="0"
@@ -1310,8 +1364,7 @@ const inContent = async (attachment) => {
               class="w-full!"
               align="left"
               @blur="handleRowValidate(pid, field.key)"
-              :disabled="formDisabled(field.key)"
-            >
+              :disabled="formDisabled(field.key)">
               <template #suffix>小时(H)</template>
             </el-input-number>
           </el-form-item>
@@ -1324,8 +1377,7 @@ const inContent = async (attachment) => {
               required: form[pid].otherNptTime > 0,
               message: '请填写原因',
               trigger: ['blur', 'change']
-            }"
-          >
+            }">
             <el-input
               v-model="form[pid].otherNptReason"
               type="textarea"
@@ -1334,8 +1386,7 @@ const inContent = async (attachment) => {
               show-word-limit
               :maxlength="1000"
               placeholder="当'其他非生产时间'大于0时必填"
-              :disabled="formDisabled('otherNptReason')"
-            />
+              :disabled="formDisabled('otherNptReason')" />
           </el-form-item>
         </div>
       </template>
@@ -1351,8 +1402,7 @@ const inContent = async (attachment) => {
             type: 'string',
             trigger: ['blur', 'change']
           }
-        ]"
-      >
+        ]">
         <el-input
           v-model="form.constructionBrief"
           type="textarea"
@@ -1361,8 +1411,7 @@ const inContent = async (attachment) => {
           resize="none"
           :maxlength="1000"
           placeholder="请输入当日施工简报"
-          :disabled="formDisabled('constructionBrief')"
-        />
+          :disabled="formDisabled('constructionBrief')" />
       </el-form-item>
 
       <el-divider class="my-6 border-2! border-[var(--el-color-primary)]!" />
@@ -1380,8 +1429,7 @@ const inContent = async (attachment) => {
           prop="queryDate"
           :width="110"
           cover-formatter
-          :real-value="(row) => (row.queryDate ? dayjs(row.queryDate).format('YYYY-MM-DD') : '')"
-        />
+          :real-value="(row) => (row.queryDate ? dayjs(row.queryDate).format('YYYY-MM-DD') : '')" />
         <ZmTableColumn label="中航北斗油耗(L)" :width="140" prop="zhbdFuel" />
         <ZmTableColumn label="实际油耗(L)" prop="customFuel">
           <template #default="{ row, $index }">
@@ -1392,8 +1440,7 @@ const inContent = async (attachment) => {
                 :controls="false"
                 class="w-full!"
                 align="left"
-                @input="handleListChange"
-              >
+                @input="handleListChange">
                 <template #suffix> L </template>
               </el-input-number>
             </el-form-item>
@@ -1418,8 +1465,7 @@ const inContent = async (attachment) => {
               :label="label"
               :prop="prop"
               cover-formatter
-              :real-value="(row) => getWorkloadValue(row, prop)"
-            />
+              :real-value="(row) => getWorkloadValue(row, prop)" />
           </template>
         </ZmTable>
       </template>
@@ -1436,24 +1482,21 @@ const inContent = async (attachment) => {
             show-word-limit
             :maxlength="1000"
             placeholder="请输入审批意见"
-            :disabled="formDisabled('opinion')"
-          />
+            :disabled="formDisabled('opinion')" />
         </el-form-item>
       </template>
     </el-form>
   </div>
 
   <div
-    class="h-16 z-10 flex items-center justify-end px-6 shadow bg-white absolute bottom-0 left-0 w-full border-solid border-0 border-t-1 border-gray-200"
-  >
+    class="h-16 z-10 flex items-center justify-end px-6 shadow bg-white absolute bottom-0 left-0 w-full border-solid border-0 border-t-1 border-gray-200">
     <div v-if="formType === 'edit' || formType === 'time'">
       <el-button
         size="default"
         type="primary"
         @click="submitForm"
         :disabled="formDisabled('button')"
-        :loading="formLoading"
-      >
+        :loading="formLoading">
         确 定
       </el-button>
       <el-button size="default" @click="handleCancel">取 消</el-button>
@@ -1465,8 +1508,7 @@ const inContent = async (attachment) => {
         type="primary"
         @click="submitApprovalForm(20)"
         :disabled="formDisabled('button')"
-        :loading="formLoading"
-      >
+        :loading="formLoading">
         审批通过
       </el-button>
       <el-button
@@ -1474,12 +1516,15 @@ const inContent = async (attachment) => {
         type="danger"
         @click="submitApprovalForm(30)"
         :disabled="formDisabled('button')"
-        :loading="formLoading"
-      >
+        :loading="formLoading">
         审批拒绝
       </el-button>
       <el-button size="default" @click="handleCancel">取 消</el-button>
     </div>
+
+    <div v-if="formType === 'detail'">
+      <el-button size="default" @click="handleCancel">返 回</el-button>
+    </div>
   </div>
 </template>
 

+ 25 - 8
src/views/pms/iotrddailyreport/index.vue

@@ -90,6 +90,28 @@ const total = ref(0)
 
 const loading = ref(false)
 
+const getReportDetailsDuration = (reportDetails: any[] = []) =>
+  Number(reportDetails.reduce((sum, item) => sum + Number(item.duration || 0), 0).toFixed(2))
+
+const formatReportDetailTime = (time?: number[] | string) =>
+  Array.isArray(time) ? formatT(time) : time || ''
+
+const getReportDetailsTimeRange = (row: any) => {
+  const reportDetails = row.reportDetails || []
+  const first = reportDetails[0]
+  const last = reportDetails.at(-1)
+  if (!first || !last) return ''
+
+  const startDate = first.reportDate ?? row.createTime
+  const endDate = last.endDateTime ?? last.reportDate ?? row.createTime
+  const startTime = formatReportDetailTime(first.startTime)
+  const endTime = formatReportDetailTime(last.endTime)
+
+  return `${dayjs(startDate).format('YYYY-MM-DD')} ${startTime} - ${dayjs(endDate).format(
+    'YYYY-MM-DD'
+  )} ${endTime}`
+}
+
 const loadList = useDebounceFn(async function () {
   loading.value = true
   try {
@@ -357,18 +379,13 @@ onMounted(() => {
                             <div class="flex items-center gap-x-2">
                               <div class="flex items-center">
                                 <div class="i-carbon-calendar mr-1 -translate-y-[0.5px]"></div>
-                                <div class="font-medium mr-2">{{
-                                  dayjs(row.createTime).format('YYYY-MM-DD')
-                                }}</div>
-                                <div class="flex items-center">
-                                  <span>{{ formatT(row.reportDetails[0].startTime) }}</span>
-                                  <span class="mx-1">-</span>
-                                  <span>{{ formatT(row.reportDetails[0].endTime) }}</span>
+                                <div class="font-medium mr-2">
+                                  {{ getReportDetailsTimeRange(row) }}
                                 </div>
                               </div>
 
                               <div class="ml-auto group-hover:text-blue-600 font-medium">
-                                {{ row.reportDetails[0].duration }} H
+                                {{ getReportDetailsDuration(row.reportDetails) }} H
                               </div>
                             </div>
                             <!--

+ 25 - 8
src/views/pms/iotrydailyreport/ry-table.vue

@@ -85,6 +85,28 @@ const { list, loading, total, pageNo, pageSize, showAction, isIndex } = toRefs(p
 
 const { ZmTable, ZmTableColumn } = useTableComponents<ListItem>()
 
+const getReportDetailsDuration = (reportDetails: any[] = []) =>
+  Number(reportDetails.reduce((sum, item) => sum + Number(item.duration || 0), 0).toFixed(2))
+
+const formatReportDetailTime = (time?: number[] | string) =>
+  Array.isArray(time) ? formatT(time) : time || ''
+
+const getReportDetailsTimeRange = (row: any) => {
+  const reportDetails = row.reportDetails || []
+  const first = reportDetails[0]
+  const last = reportDetails.at(-1)
+  if (!first || !last) return ''
+
+  const startDate = first.reportDate ?? row.createTime
+  const endDate = last.endDateTime ?? last.reportDate ?? row.createTime
+  const startTime = formatReportDetailTime(first.startTime)
+  const endTime = formatReportDetailTime(last.endTime)
+
+  return `${dayjs(startDate).format('YYYY-MM-DD')} ${startTime} - ${dayjs(endDate).format(
+    'YYYY-MM-DD'
+  )} ${endTime}`
+}
+
 const cellStyle = ({ row, column }: { row: ListItem; column: any }) => {
   // 1. 红色预警:当日油耗大于 9000 升
   if (column.property === 'dailyFuel') {
@@ -241,18 +263,13 @@ function handleCurrentChange(val: number) {
                           <div class="flex items-center gap-x-2">
                             <div class="flex items-center">
                               <div class="i-carbon-calendar mr-1 -translate-y-[0.5px]"></div>
-                              <div class="font-medium mr-2">{{
-                                dayjs(row.reportDetails[0].reportDate).format('YYYY-MM-DD')
-                              }}</div>
-                              <div class="flex items-center">
-                                <span>{{ formatT(row.reportDetails[0].startTime) }}</span>
-                                <span class="mx-1">-</span>
-                                <span>{{ formatT(row.reportDetails[0].endTime) }}</span>
+                              <div class="font-medium mr-2">
+                                {{ getReportDetailsTimeRange(row) }}
                               </div>
                             </div>
 
                             <div class="ml-auto group-hover:text-blue-600 font-medium">
-                              {{ row.reportDetails[0].duration }} H
+                              {{ getReportDetailsDuration(row.reportDetails) }} H
                             </div>
                           </div>
 

+ 25 - 8
src/views/pms/iotrydailyreport/ry-xj-table.vue

@@ -97,6 +97,28 @@ const { list, loading, total, pageNo, pageSize, showAction, isIndex } = toRefs(p
 
 const { ZmTable, ZmTableColumn } = useTableComponents<ListItem>()
 
+const getReportDetailsDuration = (reportDetails: any[] = []) =>
+  Number(reportDetails.reduce((sum, item) => sum + Number(item.duration || 0), 0).toFixed(2))
+
+const formatReportDetailTime = (time?: number[] | string) =>
+  Array.isArray(time) ? formatT(time) : time || ''
+
+const getReportDetailsTimeRange = (row: any) => {
+  const reportDetails = row.reportDetails || []
+  const first = reportDetails[0]
+  const last = reportDetails.at(-1)
+  if (!first || !last) return ''
+
+  const startDate = first.reportDate ?? row.createTime
+  const endDate = last.endDateTime ?? last.reportDate ?? row.createTime
+  const startTime = formatReportDetailTime(first.startTime)
+  const endTime = formatReportDetailTime(last.endTime)
+
+  return `${dayjs(startDate).format('YYYY-MM-DD')} ${startTime} - ${dayjs(endDate).format(
+    'YYYY-MM-DD'
+  )} ${endTime}`
+}
+
 const transitTime = (row: ListItem) => {
   const { ratedProductionTime = 0, productionTime = 0 } = row
 
@@ -272,18 +294,13 @@ function handleCurrentChange(val: number) {
                           <div class="flex items-center gap-x-2">
                             <div class="flex items-center">
                               <div class="i-carbon-calendar mr-1 -translate-y-[0.5px]"></div>
-                              <div class="font-medium mr-2">{{
-                                dayjs(row.reportDetails[0].reportDate).format('YYYY-MM-DD')
-                              }}</div>
-                              <div class="flex items-center">
-                                <span>{{ formatT(row.reportDetails[0].startTime) }}</span>
-                                <span class="mx-1">-</span>
-                                <span>{{ formatT(row.reportDetails[0].endTime) }}</span>
+                              <div class="font-medium mr-2">
+                                {{ getReportDetailsTimeRange(row) }}
                               </div>
                             </div>
 
                             <div class="ml-auto group-hover:text-blue-600 font-medium">
-                              {{ row.reportDetails[0].duration }} H
+                              {{ getReportDetailsDuration(row.reportDetails) }} H
                             </div>
                           </div>
 

+ 18 - 6
src/views/pms/operation-meeting/components/operation-meeting-content.vue

@@ -261,6 +261,14 @@ const currentSummaryMeeting = computed(() => {
   )
 })
 
+const currentWorkloadMeeting = computed(() =>
+  isSummaryMode.value ? currentSummaryMeeting.value : activeMeetings.value[0]
+)
+
+const workloadScopeName = computed(() =>
+  isSummaryMode.value ? currentSummaryScopeName.value : companyDisplayName.value || '公司整体'
+)
+
 const meetingSeriesModel = computed({
   get: () => props.meeting.meetingSeries,
   set: (meetingSeries) => emits('update:meeting', { ...props.meeting, meetingSeries })
@@ -470,7 +478,7 @@ const appendWorkloadProperty = (
 
 const currentSummaryWorkloadProperties = computed(() =>
   getSortedExtProperties(
-    (currentSummaryMeeting.value?.extProperty || []).filter(
+    (currentWorkloadMeeting.value?.extProperty || []).filter(
       (item) => !isNextExtProperty(item) && isVisibleWorkloadExtProperty(item)
     )
   )
@@ -551,9 +559,8 @@ const getSummaryWorkloadIcon = (item: ExtPropertyItem) => {
 
 const showSummaryWorkload = computed(
   () =>
-    isSummaryMode.value &&
     props.type === 'view' &&
-    Boolean(props.companyFilterValue) &&
+    (!isSummaryMode.value || Boolean(props.companyFilterValue)) &&
     currentSummaryWorkloadProperties.value.length > 0
 )
 
@@ -577,7 +584,7 @@ const formatWorkloadPropertyValue = (item: ExtPropertyItem) => {
   return `${formatSummaryNumber(numericValue)}${item.unit || ''}`
 }
 
-const workloadDetailColumns = computed(() => currentSummaryMeeting.value?.details || [])
+const workloadDetailColumns = computed(() => currentWorkloadMeeting.value?.details || [])
 const workloadDetailRows = computed(() => {
   const propertyMap = new Map<string, ExtPropertyItem>()
 
@@ -822,7 +829,7 @@ const getMeetingTableCellClassName = ({ column }: MeetingTableCellStyleProps) =>
 
     <section v-if="showSummaryWorkload" class="meeting-workload-strip">
       <div class="meeting-workload-strip__title">
-        <span>{{ currentSummaryScopeName }}</span>
+        <span>{{ workloadScopeName }}</span>
         <small>工作量完成情况</small>
         <el-button
           class="meeting-workload-strip__detail"
@@ -873,7 +880,7 @@ const getMeetingTableCellClassName = ({ column }: MeetingTableCellStyleProps) =>
 
     <el-dialog
       v-model="workloadDetailVisible"
-      :title="`${currentSummaryScopeName}工作量完成情况详情`"
+      :title="`${workloadScopeName}工作量完成情况详情`"
       class="meeting-workload-detail-dialog"
       width="60%">
       <div class="meeting-workload-detail">
@@ -1560,6 +1567,11 @@ const getMeetingTableCellClassName = ({ column }: MeetingTableCellStyleProps) =>
   padding-top: 12px;
   margin-top: 12px;
   border-top: 1px solid var(--el-border-color-lighter);
+
+  :deep(.el-textarea__inner) {
+    color: #000;
+    -webkit-text-fill-color: #000;
+  }
 }
 
 .meeting-detail-table-view {