浏览代码

数据建模新增聚合设置

yukai 2 年之前
父节点
当前提交
74de865f1c

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

@@ -48,7 +48,9 @@ export default {
       copy: (params: object) => post('/source/template/copy', params),
       relation_check: (id: number) => get('/source/template/relation_check', { id }),
       source_list: (id: number) => get('/source/template/source_list', { id }),
+      aggregate_from: (id: number) => get('/source/template/aggregate_from', { id }),
       relation: (data: object) => post('/source/template/relation', data),
+      aggregate: (data: object) => post('/source/template/aggregate', data),
       
    } ,
 

+ 174 - 0
src/views/system/datahub/modeling/component/juhe.vue

@@ -0,0 +1,174 @@
+<template>
+	<div class="system-edit-dic-container">
+		<el-dialog title="设置聚合" v-model="isShowDialog" width="769px">
+			<el-form :model="ruleForm" ref="formRef" :rules="rules" size="default" label-width="110px">
+		
+				<el-form-item label="分组节点" prop="GroupNodeKey">
+						<el-select v-model="ruleForm.GroupNodeKey" filterable placeholder="请选择分组节点"  class="w100">
+							<el-option v-for="item in sourceData" :key="item.id" :label="item.name" :value="item.key">
+								<span style="float: left">{{ item.name }}</span>
+								<span style="float: right; font-size: 13px">{{ item.key }}</span>
+							</el-option>
+						</el-select>
+					</el-form-item>
+
+
+				<el-form-item label="时间窗口节点" prop="TimeNodeKey">
+			
+					<el-select v-model="ruleForm.TimeNodeKey" filterable placeholder="请选择时间窗口节点"  class="w100">
+							<el-option v-for="item in sourceData" :key="item.id" :label="item.name" :value="item.key">
+								<span style="float: left">{{ item.name }}</span>
+								<span style="float: right; font-size: 13px">{{ item.key }}</span>
+							</el-option>
+						</el-select>
+				</el-form-item>
+
+				<el-form-item label="时间值" prop="Duration">
+					<el-input v-model="ruleForm.Duration" placeholder="请输入时间值" class="w-35" />
+					<el-select v-model="ruleForm.TimeUnit" placeholder="请选择单位">
+						<el-option v-for="item in unitData" :key="item.value" :label="item.label" :value="item.value" />
+					</el-select>
+				</el-form-item>
+				
+			</el-form>
+			<template #footer>
+				<span class="dialog-footer">
+					<el-button @click="onCancel" size="default">取 消</el-button>
+					<el-button type="primary" @click="onSubmit" size="default">设置</el-button>
+				</span>
+			</template>
+		</el-dialog>
+
+	</div>
+</template>
+
+<script lang="ts">
+import { reactive, toRefs, defineComponent, ref, unref } from 'vue';
+import api from '/@/api/datahub';
+import { ElMessage } from 'element-plus';
+
+interface RuleFormState {
+	id?: number;
+	GroupNodeKey: string;
+	TimeNodeKey: string;
+	Duration: string;
+	TimeUnit: string;
+}
+interface DicState {
+	isShowDialog: boolean;
+	ruleForm: RuleFormState;
+	rules: {};
+	unitData:[];
+}
+
+export default defineComponent({
+	name: 'Edit',
+
+	setup(prop, { emit }) {
+		const formRef = ref<HTMLElement | null>(null);
+
+		const state = reactive<DicState>({
+			isShowDialog: false,
+			sourceData:[],
+			unitData: [
+				{
+					label: '秒',
+					value: 1,
+				},
+				{
+					label: '分',
+					value: 2,
+				},
+				{
+					label: '时',
+					value: 3,
+				},
+				{
+					label: '天',
+					value: 4,
+				},
+			],
+			ruleForm: {
+				id: 0,
+				GroupNodeKey: '',
+				TimeNodeKey: '',
+				Duration: '',
+				TimeUnit: '',
+			},
+			rules: {
+				GroupNodeKey: [{ required: true, message: '分组节点key不能为空', trigger: 'blur' }],
+				TimeNodeKey: [{ required: true, message: '时间窗口节点key不能为空', trigger: 'blur' }],
+				Duration: [{ required: true, message: '时间值不能为空', trigger: 'blur' }],
+				TimeUnit: [{ required: true, message: '时间单位不能为空', trigger: 'blur' }],
+			},
+		});
+
+		// 打开弹窗
+		const openDialog = (row: RuleFormState | null) => {
+			resetForm();
+			
+			
+			if (row) {
+				state.ruleForm.id=row.id;
+				api.template.aggregate_from(row.id).then((res: any) => {
+					api.node.getList({sourceId:res.id}).then((res: any) => {
+						state.sourceData=res.list
+						state.ruleForm.GroupNodeKey=row.groupNodeKey;
+						state.ruleForm.TimeNodeKey=row.timeNodeKey;
+						state.ruleForm.Duration=row.duration;
+						state.ruleForm.TimeUnit=row.timeUnit;
+					})
+								
+				});
+			}
+			state.isShowDialog = true;
+		};
+		const resetForm = () => {
+			state.ruleForm = {
+				id: 0,
+				GroupNodeKey: '',
+				TimeNodeKey: '',
+				Duration: '',
+				TimeUnit: '',
+			};
+		};
+
+
+
+
+		// 关闭弹窗
+		const closeDialog = () => {
+			state.isShowDialog = false;
+		};
+		// 取消
+		const onCancel = () => {
+			closeDialog();
+		};
+		// 新增
+		const onSubmit = () => {
+			const formWrap = unref(formRef) as any;
+			if (!formWrap) return;
+			formWrap.validate((valid: boolean) => {
+				if (valid) {
+
+						api.template.aggregate(state.ruleForm).then(() => {
+							ElMessage.success('设置成功');
+							closeDialog(); // 关闭弹窗
+							emit('typeList');
+						});
+				}
+			});
+		};
+	
+		return {
+			openDialog,
+			closeDialog,
+			onCancel,
+			onSubmit,
+			formRef,
+			...toRefs(state),
+		};
+	},
+});
+</script>
+

+ 11 - 1
src/views/system/datahub/modeling/index.vue

@@ -64,6 +64,7 @@
               <span>字段管理</span>
             </router-link>
             <el-button size="small" text type="success" @click="onOpenRecord(scope.row)" v-if="scope.row.status==1" v-auth="'record'">数据记录</el-button>
+            <el-button size="small" text type="danger" @click="onOpenJuhe(scope.row)" v-auth="'record'">聚合设置</el-button>
             <el-button size="small" text type="warning" @click="onOpenEdit(scope.row)" v-if="scope.row.status==0" v-auth="'edit'">修改</el-button>
             <el-button size="small" text type="danger" @click="onRowDel(scope.row)" v-if="scope.row.status==0" v-auth="'del'">删除</el-button>
             <el-button size="small" text type="primary" @click="copy(scope.row)" v-auth="'copy'">复制</el-button>
@@ -75,6 +76,7 @@
     </el-card>
     <EditDic ref="editDicRef" @typeList="typeList" />
     <Detail ref="detailRef" />
+    <Juhe ref="juheRef" />
   </div>
 </template>
 
@@ -83,6 +85,7 @@ import { toRefs, reactive, onMounted, ref, defineComponent,getCurrentInstance }
 import { ElMessageBox, ElMessage, FormInstance } from 'element-plus';
 import EditDic from './component/edit.vue';
 import Detail from './component/detail.vue';
+import Juhe from './component/juhe.vue';
 import api from '/@/api/datahub';
 
 // 定义接口来定义对象的类型
@@ -111,10 +114,11 @@ interface TableDataState {
 
 export default defineComponent({
   name: 'sourcelist',
-  components: { EditDic, Detail },
+  components: { EditDic, Detail,Juhe },
   setup() {
     const addDicRef = ref();
     const editDicRef = ref();
+    const juheRef = ref();
     const detailRef = ref();
     const queryRef = ref();
     const { proxy } = getCurrentInstance() as any;
@@ -157,6 +161,10 @@ const { datahub_model_type } = proxy.useDict('datahub_model_type');
     const onOpenRecord = (row: TableDataRow) => {
       detailRef.value.openDialog(row);
     };
+    //聚合设置
+    const onOpenJuhe = (row: TableDataRow) => {
+      juheRef.value.openDialog(row);
+    };
     const onRowDel = (row?: TableDataRow) => {
       let msg = '你确定要删除所选数据?';
       let ids: number[] = [];
@@ -221,8 +229,10 @@ const { datahub_model_type } = proxy.useDict('datahub_model_type');
       addDicRef,
       editDicRef,
       detailRef,
+      juheRef,
       queryRef,
       onOpenRecord,
+      onOpenJuhe,
       datahub_model_type,
       onOpenAdd,
       onOpenEdit,