xuzhancheng 2 هفته پیش
والد
کامیت
8268b34c48

+ 3 - 0
yudao-ui-admin-vue3/src/views/pressure2/boilerconnectrecordreport/BoilerConnectRecordReportForm.vue

@@ -296,6 +296,7 @@ const getRecordList = async () => {
       pageNo: 1,
       pageSize: 1000,
       reportType: 100, //记录
+      status: 200, // 只查询上架状态的模板
     }
     const data = await DynamicTbApi.getDynamicTbPage(params)
     recordList.value = data.list
@@ -310,6 +311,7 @@ const getReportList = async () => {
       pageNo: 1,
       pageSize: 1000,
       reportType: 200, //报告
+      status: 200, // 只查询上架状态的模板
     }
     const data = await DynamicTbApi.getDynamicTbPage(params)
     reportList.value = data.list
@@ -331,6 +333,7 @@ const getAcceptOrderTemplateList = async () => {
       pageNo: 1,
       pageSize: 1000,
       reportType: 300, // 受理单模板,根据实际情况调整
+      status: 200, // 只查询上架状态的模板
     }
     const data = await DynamicTbApi.getDynamicTbPage(params)
     acceptOrderTemplateList.value = data.list

+ 2 - 0
yudao-ui-admin-vue3/src/views/pressure2/dynamictb/DynamicTbForm.vue

@@ -147,6 +147,7 @@ const formData = ref({
   formUrl: undefined,
   formPath: undefined,
   filePaths: [],
+  status: 400, // 默认下架状态
 })
 const formRules = reactive({
   tbName: [{ required: true, message: '模板名字不能为空', trigger: 'blur' }],
@@ -550,6 +551,7 @@ const resetForm = () => {
     formUrl: undefined,
     formPath: undefined,
     filePaths: [],
+    status: 400, // 默认下架状态
   }
   formRef.value?.resetFields()
 }

+ 33 - 14
yudao-ui-admin-vue3/src/views/pressure2/dynamictb/index.vue

@@ -172,13 +172,14 @@
             link
             type="primary"
             @click="openForm('update', scope.row.id)"
-            v-hasPermi="['pressure2:dynamic-tb:update']"
-            :disabled="scope.row.status == 200"
-          >
+            >
+            <!-- :disabled="scope.row.status == 200"
+          > -->
             编辑
           </el-button>
           <router-link :to="'/cybggl/dynamic-tb-col/'+scope.row.id">
-            <el-button link type="primary"  :disabled="scope.row.status == 200">数据</el-button>
+            <el-button link type="primary" >数据</el-button>
+            <!-- <el-button link type="primary"  :disabled="scope.row.status == 200">数据</el-button> -->
           </router-link>
           <el-button
             link
@@ -209,7 +210,6 @@
             link
             type="danger"
             @click="handleDelete(scope.row.id)"
-            v-hasPermi="['pressure2:dynamic-tb:delete']"
           >
             删除
           </el-button>
@@ -258,6 +258,7 @@ import { dateFormatter } from '@/utils/formatTime'
 import download from '@/utils/download'
 import { DynamicTbApi, DynamicTbVO } from '@/api/pressure2/dynamictb'
 import DynamicTbForm from './DynamicTbForm.vue'
+import { BoilerConnectRecordReportApi } from '@/api/pressure2/boilerconnectrecordreport'
 
 
 /** 承压动态报表表单 列表 */
@@ -391,16 +392,34 @@ const handleShelvesSave = async () => {
 
 // 下架
 const handleUndercarriage = async (row) => {
-  ElMessageBox.confirm('确定下架该报告模板吗?', '下架提示', {
-    confirmButtonText: '确 认',
-    cancelButtonText: '取 消'
-  }).then(async () => {
-    const res = await DynamicTbApi.updateStatus({id: row.id, status: 400})
-    if(res) {
-      ElMessage.success('下架成功')
-      getList()
+  try {
+    const connectInfos = await BoilerConnectRecordReportApi.getByTemplateId({
+      templateId: row.id,
+      type: row.reportType === 100 ? 'record' : 'report'
+    })
+    
+    if (connectInfos && connectInfos.length > 0) {
+      ElMessage.warning('该模板存在关联的检验项目,请先删除关联项目后再进行下架操作')
+      return
     }
-  })
+    
+    ElMessageBox.confirm('确定下架该报告模板吗?', '下架提示', {
+      confirmButtonText: '确 认',
+      cancelButtonText: '取 消'
+    }).then(async () => {
+      try {
+        const res = await DynamicTbApi.updateStatus({id: row.id, status: 400})
+        if(res) {
+          ElMessage.success('下架成功')
+          getList()
+        }
+      } catch (error) {
+        ElMessage.error('下架失败:' + (error.message || '未知错误'))
+      }
+    })
+  } catch (error) {
+    ElMessage.error('查询关联项目失败:' + (error.message || '未知错误'))
+  }
 }
 
 /** 初始化 **/