|
@@ -72,6 +72,7 @@
|
|
|
:default-expand-all="isExpandAll"
|
|
|
v-if="refreshTable"
|
|
|
style="width: 100%"
|
|
|
+ @row-click="handleClick"
|
|
|
>
|
|
|
<el-table-column prop="name" label="BOM节点" >
|
|
|
<template #default="scope">
|
|
@@ -90,12 +91,32 @@
|
|
|
</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">
|
|
|
+ <!-- <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> -->
|
|
|
<!--
|
|
|
<el-table-column
|
|
|
label="创建时间"
|
|
@@ -155,6 +176,7 @@
|
|
|
@update:model-value="val => drawerVisible = val"
|
|
|
:node-id="currentBomNodeId"
|
|
|
ref="showDrawer"
|
|
|
+ @refresh="handleDrawerClosed"
|
|
|
/>
|
|
|
</template>
|
|
|
<script lang="ts" setup>
|
|
@@ -190,6 +212,8 @@ const queryParams = reactive({
|
|
|
})
|
|
|
const queryFormRef = ref() // 搜索的表单
|
|
|
|
|
|
+const selectedRow = ref<any>(null)
|
|
|
+
|
|
|
const CommonBomMaterialData = ref({
|
|
|
id: undefined,
|
|
|
deviceCategoryId: undefined,
|
|
@@ -273,20 +297,46 @@ const resetQuery = () => {
|
|
|
|
|
|
/** 处理 设备分类 被点击 */
|
|
|
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)
|
|
|
+ formRef.value.open(type, row.id, parentId.value)
|
|
|
return
|
|
|
}
|
|
|
- formRef.value.open(type, null)
|
|
|
+ formRef.value.open(type, null, parentId.value)
|
|
|
}
|
|
|
|
|
|
/** 展开/折叠操作 */
|
|
@@ -298,6 +348,12 @@ const toggleExpandAll = () => {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
+// 清除表格行选择
|
|
|
+const clearRowSelection = () => {
|
|
|
+ selectedRow.value = null
|
|
|
+ parentId.value = ''
|
|
|
+}
|
|
|
+
|
|
|
/** 删除按钮操作 */
|
|
|
const handleDelete = async (id: number) => {
|
|
|
try {
|