Forráskód Böngészése

3.数据源、数据模型增加复制功能(包含节点)

yukai 3 éve
szülő
commit
0ab9952dc9

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

@@ -17,6 +17,7 @@ export default {
     getdevList: (params: object) => get('/product/device/list', params),
     getdata: (params: object) => get('/source/getdata', params),
     getLists: (params: object) => get('/source/list', params),
+    copy: (params: object) => post('/source/copy', params),
 
     },
    
@@ -36,6 +37,7 @@ export default {
       detail: (id: number) => get('/source/template/detail', { id }),
       allList: (params: object) => get('/source/template/list', params), // 获取所有已发布列表
       getdata: (params: object) => get('/source/template/getdata',  params ),
+      copy: (params: object) => post('/source/template/copy', params),
    } ,
 
    tnode:{

+ 22 - 0
src/views/datahub/modeling/index.vue

@@ -76,6 +76,8 @@
 						<el-button size="small" text type="success" @click="onOpenRecord(scope.row)"  v-if="scope.row.status==1">数据记录</el-button>
 						<el-button size="small" text type="warning" @click="onOpenEdit(scope.row)" v-if="scope.row.status==0">修改</el-button>
 						<el-button size="small" text type="danger" @click="onRowDel(scope.row)" v-if="scope.row.status==0">删除</el-button>
+						<el-button size="small" text type="primary" @click="copy(scope.row)" >复制</el-button>
+
 					</template>
 				</el-table-column>
 			</el-table>
@@ -192,6 +194,25 @@ export default defineComponent({
 				})
 				.catch(() => {});
 		};
+
+		//复制数据
+		const copy=(row:TableDataRow)=>{
+			ElMessageBox.confirm("确定要复制该数据吗?", '提示', {
+				confirmButtonText: '确认',
+				cancelButtonText: '取消',
+				type: 'warning',
+			})
+				.then(() => {
+
+					api.template.copy({id:row.id}).then(() => {
+						ElMessage.success('复制成功');
+						typeList();
+					});
+				})
+				.catch(() => {});
+		}
+
+
 		// 页面加载时
 		onMounted(() => {
 			initTableData();
@@ -216,6 +237,7 @@ export default defineComponent({
 			onOpenAdd,
 			onOpenEdit,
 			onRowDel,
+			copy,
 			typeList,
 			resetQuery,
 			handleSelectionChange,

+ 19 - 0
src/views/datahub/source/index.vue

@@ -92,6 +92,7 @@
 						<el-button size="small" text type="success" @click="onOpenList(scope.row)"  v-if="scope.row.status==1">数据记录</el-button>
 						<el-button size="small" text type="warning" @click="onOpenEdit(scope.row)" v-if="scope.row.status==0">修改</el-button>
 						<el-button size="small" text type="danger" @click="onRowDel(scope.row)" v-if="scope.row.status==0">删除</el-button>
+						<el-button size="small" text type="primary" @click="copy(scope.row)" >复制</el-button>
 					</template>
 				</el-table-column>
 			</el-table>
@@ -197,6 +198,23 @@ export default defineComponent({
 			}).finally(() => (state.tableData.loading = false));
 		};
 
+		//复制数据
+		const copy=(row:TableDataRow)=>{
+			ElMessageBox.confirm("确定要复制该数据吗?", '提示', {
+				confirmButtonText: '确认',
+				cancelButtonText: '取消',
+				type: 'warning',
+			})
+				.then(() => {
+
+					api.common.copy({sourceId:row.sourceId}).then(() => {
+						ElMessage.success('复制成功');
+						typeList();
+					});
+				})
+				.catch(() => {});
+		}
+
 		//打开数据记录
 		const onOpenList=(row: TableDataRow)=>{
 			listDicRef.value.openDialog(row);
@@ -255,6 +273,7 @@ export default defineComponent({
 			editDicRef,
 			listDicRef,
 			queryRef,
+			copy,
 			onOpenList,
 			onOpenAdd,
 			onOpenEdit,