Przeglądaj źródła

跳着bom清单

Zimo 21 godzin temu
rodzic
commit
77e72f979e
2 zmienionych plików z 339 dodań i 384 usunięć
  1. 13 1
      src/api/pms/bom/index.ts
  2. 326 383
      src/views/pms/bom/index.vue

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

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

+ 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>
 <script lang="ts" setup>
+import { useTableComponents } from '@/components/ZmTable/useTableComponents'
 import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
 import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
 import * as BomApi from '@/api/pms/bom'
 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 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' })
 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,
   pageNo: 1,
   pageSize: 10,
   pageSize: 10,
+  deptId: undefined,
   name: 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,
   id: undefined,
   deviceCategoryId: undefined,
   deviceCategoryId: undefined,
   bomNodeId: undefined,
   bomNodeId: undefined,
   name: undefined,
   name: undefined,
   code: undefined,
   code: undefined,
   materialId: 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 () => {
 const getList = async () => {
   loading.value = true
   loading.value = true
   try {
   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 {
   } finally {
     loading.value = false
     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)
   materialListRef.value.open(row)
   currentBomNodeId.value = row.id
   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
   currentBomNodeId.value = row.id
-  // 保存当前行的信息
   currentRowInfo.value = {
   currentRowInfo.value = {
     deviceCategoryName: row.deviceCategoryName || '暂无',
     deviceCategoryName: row.deviceCategoryName || '暂无',
     bomNodeName: row.name || '暂无'
     bomNodeName: row.name || '暂无'
   }
   }
   drawerVisible.value = true
   drawerVisible.value = true
   showDrawer.value.openDrawer()
   showDrawer.value.openDrawer()
-  // 强制刷新物料数据
   await showDrawer.value.loadMaterials(row.id)
   await showDrawer.value.loadMaterials(row.id)
 }
 }
 
 
-const chooseSingleMaterial = async(row) => {
-  // 将物料关联到bom节点
+const chooseSingleMaterial = async (row) => {
   try {
   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'))
     message.success(t('common.createSuccess'))
-    // 保存成功后立即刷新抽屉数据
     showDrawer.value.loadMaterials(currentBomNodeId.value)
     showDrawer.value.loadMaterials(currentBomNodeId.value)
     await getList()
     await getList()
   } finally {
   } finally {
-    // formLoading.value = false
   }
   }
 }
 }
 
 
-const chooseMaterial = async(selectedMaterials) => {
-  // 将物料关联到bom节点
+const chooseMaterial = async (selectedMaterials) => {
   try {
   try {
-    // 转换数据结构(根据接口定义调整)
-    const materialsData = selectedMaterials.map(material => ({
-      deviceCategoryId: CommonBomMaterialData.value.deviceCategoryId,
+    const materialsData = selectedMaterials.map((material) => ({
+      deviceCategoryId: commonBomMaterialData.value.deviceCategoryId,
       bomNodeId: currentBomNodeId.value,
       bomNodeId: currentBomNodeId.value,
       materialId: material.id,
       materialId: material.id,
       name: material.name,
       name: material.name,
@@ -301,12 +202,8 @@ const chooseMaterial = async(selectedMaterials) => {
       quantity: material.quantity
       quantity: material.quantity
     }))
     }))
 
 
-    // 调用批量添加接口
     const resultCount = await CommonBomMaterialApi.addMaterials(materialsData)
     const resultCount = await CommonBomMaterialApi.addMaterials(materialsData)
-    message.success(`成功添加物料数量:` + resultCount)
-
-    // message.success(t('common.createSuccess'))
-    // 保存成功后立即刷新抽屉数据
+    message.success(`成功添加物料数量:${resultCount}`)
     showDrawer.value.loadMaterials(currentBomNodeId.value)
     showDrawer.value.loadMaterials(currentBomNodeId.value)
     await getList()
     await getList()
   } catch (error) {
   } 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 = () => {
 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) => {
 const handleDelete = async (id: number) => {
   try {
   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 message.delConfirm()
-    // 发起删除
     await BomApi.deleteBomNode(id)
     await BomApi.deleteBomNode(id)
     message.success(t('common.delSuccess'))
     message.success(t('common.delSuccess'))
-    // 刷新列表
     await getList()
     await getList()
   } catch {}
   } 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>
 <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 {
 .bom-node-name {
-  flex: 1;
+  display: inline-block;
+  max-width: 100%;
   overflow: hidden;
   overflow: hidden;
   text-overflow: ellipsis;
   text-overflow: ellipsis;
   white-space: nowrap;
   white-space: nowrap;