Przeglądaj źródła

feat: 计算指标增加是否发布状态检查

vera_min 5 miesięcy temu
rodzic
commit
c78abd6a5d

+ 2 - 1
src/api/datahub/index.ts

@@ -2,7 +2,7 @@
  * @Author: vera_min vera_min@163.com
  * @Date: 2025-04-14 16:36:08
  * @LastEditors: vera_min vera_min@163.com
- * @LastEditTime: 2025-05-07 20:56:56
+ * @LastEditTime: 2025-05-08 20:13:03
  * @FilePath: /sagoo-admin-ui/src/api/datahub/index.ts
  * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
  */
@@ -110,5 +110,6 @@ export default {
       delete: (id: number) => del('/compute/del', { id }),
       edit: (data: object) => put('/compute/edit', data),
       deploy: (data: object) => put('/compute/publish', data),
+      checkDeploy: (params: object) => get('/compute/checkComputeIndexDeploy', params)
    },
 }

+ 38 - 23
src/views/system/datahub/modeling/calculationIndicator.vue

@@ -31,34 +31,33 @@
                 </el-icon>
                 重置
               </el-button>
-              <el-button type="primary" class="ml10" @click="onOpenAdd" v-auth="'add'" v-if="developer_status == 0">
+              <el-button type="primary" class="ml10" @click="onOpenAdd">
                 <el-icon>
                   <ele-FolderAdd />
                 </el-icon>
                 新增计算指标模型
               </el-button>
-              <el-button type="success" class="ml10" @click="onPublish()">
-              <el-icon>
-                <ele-Upload />
-              </el-icon>
-              发布
-            </el-button>
+              <el-button :loading="publishLoading" type="success" class="ml10" @click="onPublish()">
+                <el-icon>
+                  <ele-Upload />
+                </el-icon>
+                {{ publishStatus }}
+              </el-button>
             </el-form-item>
           </el-form>
         </div>
-
         <el-table :data="tableData.data" style="width: 100%" v-loading="tableData.loading">
-          <el-table-column label="ID" align="center" prop="id" width="100" v-col="'id'" />
-          <el-table-column label="指标名称" prop="name" width="140" show-overflow-tooltip v-col="'key'" />
-          <el-table-column label="指标标识" prop="key" width="140" show-overflow-tooltip v-col="'key'" />
-          <el-table-column label="计算公式" prop="formula" show-overflow-tooltip v-col="'dataType'" />
-          <el-table-column label="数据类型" prop="types" width="85" show-overflow-tooltip v-col="'dataType'" />
-          <el-table-column label="指标说明" prop="description" show-overflow-tooltip v-col="'name'" />
-          <el-table-column prop="createdAt" label="创建时间" align="center" width="160" v-col="'createdAt'"></el-table-column>
+          <el-table-column label="ID" align="center" prop="id" width="100" />
+          <el-table-column label="指标名称" prop="name" width="140" show-overflow-tooltip />
+          <el-table-column label="指标标识" prop="key" width="140" show-overflow-tooltip />
+          <el-table-column label="计算公式" prop="formula" show-overflow-tooltip />
+          <el-table-column label="数据类型" prop="types" width="85" show-overflow-tooltip />
+          <el-table-column label="指标说明" prop="description" show-overflow-tooltip />
+          <el-table-column prop="createdAt" label="创建时间" align="center" width="160" />
           <el-table-column label="操作" width="100" align="center" fixed="right">
             <template #default="scope">
-              <el-button size="small" text type="warning" @click="onOpenEdit(scope.row)" v-if="developer_status == 0" v-auth="'edit'">修改</el-button>
-              <el-button size="small" text type="danger" @click="onRowDel(scope.row)" v-if="developer_status == 0" v-auth="'del'">删除</el-button>
+              <el-button size="small" text type="warning" @click="onOpenEdit(scope.row)">修改</el-button>
+              <el-button size="small" text type="danger" @click="onRowDel(scope.row)">删除</el-button>
             </template>
           </el-table-column>
         </el-table>
@@ -85,6 +84,8 @@ const editDicRef = ref();
 const route = useRoute();
 const detail = ref<any>({});
 const developer_status = ref(0);
+const publishLoading = ref(false);
+const publishStatus = ref('');
 const tableData = ref(
   {
     data: [],
@@ -140,20 +141,34 @@ const onRowDel = (row: any) => {
 };
 
 const onPublish = () => {
-  ElMessageBox.confirm('是否发布?', '提示', {
+  ElMessageBox.confirm(`是否${publishStatus.value}?`, '提示', {
     confirmButtonText: '确认',
     cancelButtonText: '取消',
     type: 'warning',
   }).then(() => {
-    api.calculationIndicator.deploy({ dataTemplateKey: detail.value.key }).then((res: any) => {
+    publishLoading.value = true;
+    api.calculationIndicator.deploy({ dataTemplateKey: detail.value.key }).then(() => {
       ElMessage.success('操作成功');
+      checkDeploy();
       typeList();
-    });
+    }).finally(() => (publishLoading.value = false));
   })
-  .catch(() => { });
+  .catch(() => { })
+  
 
 };
 
+const checkDeploy = () => {
+  const ids = route.params?.modelId as string;
+  api.calculationIndicator.checkDeploy({ dataTemplateKey: ids }).then((res: any) => {
+    if (res === true) {
+      publishStatus.value = '取消发布';
+    }else if (res === false) {
+      publishStatus.value = '发布';
+    }
+  })
+};
+
 // 打开修改数据源弹窗
 const onOpenEdit = (row: any) => {
   editDicRef.value.openDialog(row);
@@ -197,9 +212,9 @@ onMounted(() => {
   const ids = route.params?.modelId as string;
   api.template.detail(ids).then((res: any) => {
     detail.value = res.data;
-    developer_status.value = res.data.status
+    developer_status.value = res.data.status;
   });
-
+  checkDeploy()
   typeList();
 });
 </script>

+ 0 - 2
src/views/system/datahub/modeling/component/addOrEditIndictor.vue

@@ -191,9 +191,7 @@ const openDialog = (row: any, dataTemplateKey:string) => {
     ruleForm.value.dataTemplateKey = dataTemplateKey;
   }
   getNodeList();
-
   isShowDialog.value = true;
-
 };