5050 </el-form-item >
5151 </el-col >
5252 <el-col :xs =" 24" :sm =" 24" :md =" 12" :lg =" 12" :xl =" 12" >
53- <el-form-item prop =" des " class =" mt-[12px]" >
53+ <el-form-item prop =" owner " class =" mt-[12px]" >
5454 <template #label >
5555 <p class =" text-gray-500 text-xs" >
56- {{ t("dataPipelines.taskDescription ") }}
56+ {{ t("dataPipelines.dataOwner ") }}
5757 </p >
5858 </template >
59- <el-input
60- v-model =" form.des "
61- :placeholder =" `${t('dataPipelines.toInput ')}${t(
62- 'dataPipelines.taskDescription '
59+ <el-select
60+ v-model =" form.owner "
61+ :placeholder =" `${t('dataPipelines.toSel ')}${t(
62+ 'dataPipelines.dataOwner '
6363 )}`"
64- clearable
64+ @change = " getSelListData(true) "
6565 >
66- </el-input >
66+ <el-option
67+ v-for =" item in ownerPathOptions"
68+ :key =" item"
69+ :label =" item"
70+ :value =" item"
71+ />
72+ </el-select >
6773 </el-form-item >
6874 </el-col >
6975
110116 </el-select >
111117 </el-form-item >
112118 </el-col >
119+
120+ <el-col :xs =" 24" :sm =" 24" :md =" 12" :lg =" 12" :xl =" 12" >
121+ <el-form-item prop =" des" class =" mt-[12px]" >
122+ <template #label >
123+ <p class =" text-gray-500 text-xs" >
124+ {{ t("dataPipelines.taskDescription") }}
125+ </p >
126+ </template >
127+ <el-input
128+ v-model =" form.des"
129+ :placeholder =" `${t('dataPipelines.toInput')}${t(
130+ 'dataPipelines.taskDescription'
131+ )}`"
132+ clearable
133+ >
134+ </el-input >
135+ </el-form-item >
136+ </el-col >
113137 </el-row >
114138
115139 <p class =" text-gray-900 text-2xl font-medium my-4" >
219243 @change =" selListDataChange"
220244 >
221245 <el-option
222- v-for =" item in selListData "
246+ v-for =" item in dataFlowList "
223247 :label =" item.name"
224248 :value =" item.path"
225249 />
@@ -326,13 +350,22 @@ const userStore = useUserStore();
326350const spaceResourceFieldsRef = ref (null );
327351const taskNamespaceFieldsRef = ref (null );
328352
353+ // 数据所有者可选项(个人 + 所属组织),借鉴数据处理任务创建
354+ const ownerPathOptions = ref ([]);
355+
329356const onNamespacesLoaded = (payload ) => {
330357 applyNamespaceFromLoaded (form, payload);
358+ ownerPathOptions .value = payload? .ownerPathOptions || [];
359+ if (! form .value .owner && ownerPathOptions .value .length ) {
360+ form .value .owner = ownerPathOptions .value [0 ];
361+ getSelListData (true );
362+ }
331363};
332364
333365// 表单
334366const form = ref ({
335367 skip_meta: false ,
368+ owner: " " ,
336369 namespace_type: " personal" ,
337370 namespace_uuid: " " ,
338371 cluster_id: " " ,
@@ -360,6 +393,13 @@ const rules = ref({
360393 trigger: " blur" ,
361394 },
362395 ],
396+ owner: [
397+ {
398+ required: true ,
399+ message: ` ${ t (" dataPipelines.toSel" )}${ t (" dataPipelines.dataOwner" )} ` ,
400+ trigger: " change" ,
401+ },
402+ ],
363403 from_csg_hub_repo_id: [
364404 {
365405 required: true ,
@@ -408,8 +448,10 @@ const rules = ref({
408448 ],
409449});
410450
411- // 数据源下拉框列表
451+ // 数据源下拉框列表(数据来源,按 owner 加载,可含组织)
412452const selListData = ref ([]);
453+ // 数据流向下拉框列表(固定为当前用户的个人数据集,不含组织)
454+ const dataFlowList = ref ([]);
413455const csg_hub_dataset_info = ref ({});
414456// 格式转换
415457const dataObj = ref ([]);
@@ -464,17 +506,22 @@ const handleSourceChange = (groupKey) => {
464506};
465507
466508onMounted (() => {
467- getSelListData ();
509+ updateOwner ();
510+ loadDataFlowList ();
468511 getFormatTypeList ();
469512 fetchUserToken ();
470513});
471514
515+ watch ([() => userStore .username , () => route .query .datasetPath ], () => {
516+ updateOwner ();
517+ loadDataFlowList ();
518+ });
519+
472520const fetchUserToken = async () => {
473- // if (!userStore.username) return
521+ if (! userStore .username ) return ;
474522
475523 const { data } = await useFetchApi (
476- // ${userStore.username}
477- ` /user/${ userStore .username } /tokens?app=git`
524+ ` /user/${ userStore .username } /tokens?app=git`
478525 ).json ();
479526 if (data .value ) {
480527 const body = data .value ;
@@ -517,18 +564,27 @@ const fetchBranchList = async (val) => {
517564 * 查询数据流向分支
518565 * @param val
519566 */
520- const selListDataChange = async (val ) => {
567+ const selListDataChange = (val ) => {
521568 if (val) {
522- let params = selListData .value .find ((item ) => item .path === val);
523- form .value .to_csg_hub_dataset_name = params .name ;
524- form .value .to_csg_hub_dataset_id = params .id ;
569+ let params = dataFlowList .value .find ((item ) => item .path === val);
570+ form .value .to_csg_hub_dataset_name = params ? params .name : " " ;
571+ form .value .to_csg_hub_dataset_id = params ? params .id : " " ;
572+ // 数据流向分支取所选数据集默认分支(后端上传时自动版本化 v1/v2)
573+ form .value .to_csg_hub_dataset_default_branch = params
574+ ? params .default_branch || " main"
575+ : " " ;
525576 } else {
526577 form .value .to_csg_hub_dataset_name = " " ;
527578 form .value .to_csg_hub_dataset_id = " " ;
579+ form .value .to_csg_hub_dataset_default_branch = " " ;
528580 }
529- form . value . to_csg_hub_dataset_default_branch = " " ;
581+ } ;
530582
531- const url = ` /datasets/${ form .value .to_csg_hub_repo_id } /branches` ;
583+ /**
584+ * 加载当前用户个人数据集,作为数据流向候选(不含组织,与来源 owner 解耦)
585+ */
586+ const loadDataFlowList = async () => {
587+ if (! userStore .username ) return ;
532588 let options = {
533589 headers: {
534590 Authorization: ` Bearer ${ cookies .get (" user_token" )} ` ,
@@ -537,17 +593,20 @@ const selListDataChange = async (val) => {
537593 )} ;user_token=${ cookies .get (" user_token" )} ;` ,
538594 },
539595 };
596+ const url = ` /user/${ userStore .username } /datasets?per=50&page=1` ;
540597 const { data } = await useFetchApi (url, options).get ().json ();
541- if (data .value && data .value .data ) {
542- to_branchList .value = data .value .data ;
543- }
598+ dataFlowList .value = data .value && data .value .data ? data .value .data : [];
544599};
545600
546601/**
547- * 获取数据流向
548- * @param type
602+ * 根据数据所有者获取数据集列表(数据来源 / 数据流向共用),借鉴数据处理任务创建
603+ * @param type 为真时表示所有者切换,需清空已选数据来源
549604 */
550605const getSelListData = async (type ) => {
606+ if (! form .value .owner ) {
607+ selListData .value = [];
608+ return ;
609+ }
551610 let options = {
552611 headers: {
553612 Authorization: ` Bearer ${ cookies .get (" user_token" )} ` ,
@@ -556,14 +615,33 @@ const getSelListData = async (type) => {
556615 )} ;user_token=${ cookies .get (" user_token" )} ;` ,
557616 },
558617 };
559- const { data } = await useFetchApi (
560- ` /user/${ userStore .username } /datasets?per=50&page=1` ,
561- options
562- )
563- .get ()
564- .json ();
565- console .log (data, " datadatadatadatadatadata" );
566- selListData .value = data .value .data ;
618+ let url = ` /user/${ form .value .owner } /datasets?per=50&page=1` ;
619+ if (form .value .owner !== userStore .username ) {
620+ url = ` /organization/${ form .value .owner } /datasets?current_user=${ userStore .username } &per=50&page=1` ;
621+ }
622+ const { data } = await useFetchApi (url, options).get ().json ();
623+ if (data .value && data .value .data ) {
624+ selListData .value = data .value .data ;
625+ } else {
626+ selListData .value = [];
627+ }
628+ if (type) {
629+ form .value .from_csg_hub_repo_id = " " ;
630+ form .value .from_csg_hub_dataset_branch = " " ;
631+ branchList .value = [];
632+ }
633+ };
634+
635+ /**
636+ * 初始化数据所有者(默认当前用户 / 路由携带的数据集归属)
637+ */
638+ const updateOwner = () => {
639+ form .value .owner = route .query .datasetPath
640+ ? route .query .datasetPath .split (" /" )[0 ]
641+ : userStore .username ;
642+ if (form .value .owner ) {
643+ getSelListData ();
644+ }
567645};
568646
569647/**
0 commit comments