Parcourir la source

关联部门为电站锅炉部的 计划排期,默认无需前台约检

xuzhancheng il y a 15 heures
Parent
commit
c5fb8e58fb

+ 46 - 21
yudao-ui-admin-vue3/src/views/pressure2/equipboilerscheduling/components/BoilerPlanScheduleDialog.vue

@@ -437,6 +437,7 @@ import {useUserStoreWithOut} from '@/store/modules/user'
 import {processInspectorGroups} from './inspector'
 import type {ProcessedDeptData} from './inspector'
 import {InspectionNatureTypeApi} from "@/api/pressure2/inspectionnaturetype";
+import {getDept} from "@/api/system/dept";
 
 const message = useMessage()
 const {queryCheckItemList, querySchedulingCheckItemList} = BoilerTaskOrderApi
@@ -1133,18 +1134,6 @@ const updateTeamList = (type) => {
 
 // 查询项目列表
 const handleQueryCheckItemList = async () => {
-  let req = []
-  console.log(props.selectedRows)
-  // if (props.selectedRows?.length > 0) {
-  //   for (const item of props.selectedRows) {
-  //     req = [...req, ...(item.inEquipIds?.split(',') || []), ...(item.outEquipIds?.split(',') || []), ...(item.preEquipIds?.split(',') || [])]
-  //   }
-  // } else {
-  //   return
-  // }
-  // if (req.length != 0) {
-  //   equipList.value = await EquipBoilerApi.getNameByIds(req)
-  // }
   checkItemList.value = []
   const checkTypes = [
     PressureBoilerCheckType.IN,
@@ -1220,23 +1209,59 @@ const handleQueryCheckItemList = async () => {
 
 }
 
+// 判断当前用户部门是否为锅炉检验部
+const isBoilerInspectionDept = ref(false)
+
+/** 检查设备部门是否为锅炉检验部 */
+const checkEquipDept = async (selectedRows: any[]) => {
+  console.log(selectedRows)
+  if (!selectedRows || selectedRows.length === 0) {
+    isBoilerInspectionDept.value = false
+    return
+  }
+  
+  try {
+    // 获取第一个设备的部门ID(假设选中的设备都属于同一个部门)
+    const firstRow = selectedRows[0]
+    const deptId = firstRow.relatedDepartment
+    
+    if (!deptId) {
+      console.warn('设备数据中没有部门信息')
+      isBoilerInspectionDept.value = false
+      return
+    }
+    
+    const deptInfo = await getDept(deptId)
+    // 判断部门名称是否包含"锅炉检验部"
+    isBoilerInspectionDept.value = deptInfo?.name?.includes('锅炉检验部') || false
+  } catch (error) {
+    console.error('获取设备部门信息失败:', error)
+    isBoilerInspectionDept.value = false
+  }
+}
+
 /** 打开弹窗 */
 const open = async (selectedInList, selectedOutList, selectedPreList, type?: string) => {
   //console.log('open', props.selectedRows)
   dialogVisible.value = true
 
+  // 合并所有选中的设备列表
+  const allSelectedRows = [
+    ...(selectedInList.value || []),
+    ...(selectedOutList.value || []),
+    ...(selectedPreList.value || [])
+  ]
+  
+  // 检查设备部门
+  await checkEquipDept(allSelectedRows)
 
   // 重置所有检验员选择
   inSelectedCheckers.value = []
   outSelectedCheckers.value = []
   preSelectedCheckers.value = []
 
-  // 使用传入的数据计算各类型设备数量
-  const counts = {
-    in: selectedInList?.length,
-    out: selectedOutList?.length,
-    pre: selectedPreList?.length
-  }
+  // 根据设备部门设置默认的约检确认状态
+  const defaultOrderConfirm = !isBoilerInspectionDept.value
 
   // 重置表单数据
   formData.value = {
@@ -1244,7 +1269,7 @@ const open = async (selectedInList, selectedOutList, selectedPreList, type?: str
     inDate: '',
     inTeamList: [],
     inTaskList: [],
-    inIsOrderConfirm: true,
+    inIsOrderConfirm: defaultOrderConfirm,
     inChargeType: '1',
     inIsExempt: '0',
     inShouldAmount: 0,
@@ -1254,7 +1279,7 @@ const open = async (selectedInList, selectedOutList, selectedPreList, type?: str
     outTeamList: [],
     outTaskList: [],
     outChargeType: '1',
-    outIsOrderConfirm: true,
+    outIsOrderConfirm: defaultOrderConfirm,
     outIsExempt: '0',
     outShouldAmount: 0,
     outServiceAmount: 0,
@@ -1262,7 +1287,7 @@ const open = async (selectedInList, selectedOutList, selectedPreList, type?: str
     preDate: '',
     preTeamList: [],
     pressureTaskList: [],
-    pressureIsOrderConfirm: true,
+    pressureIsOrderConfirm: defaultOrderConfirm,
     preChargeType: '1',
     preIsExempt: '0',
     preShouldAmount: 0,