<template>
  <div class="secret-container">
    <d-breadcrumb class="secret-breadcrumb">
      <gc-breadcrumb-item :to="{ name: 'home' }"
      ><span class="title">首页</span></gc-breadcrumb-item>
      <gc-breadcrumb-item><span class="cur-title">开源软件列表</span></gc-breadcrumb-item>
    </d-breadcrumb>
    <d-tabs class="jyh-tabs" type="wrapped" v-model="selectTab">
      <d-tab id="OssQuery" title="开源软件查询">
        <OssQuery/>
      </d-tab>
      <d-tab id="BatchVerify" title="批量校验">
        <BatchVerify/>
      </d-tab>
    </d-tabs>
  </div>
</template>

<script setup lang="ts">
import SettingTitle from '@/components/Setting/SettingTitle/index.vue';
import SettingText from '@/components/Setting/SettingText/index.vue';
import { ref,reactive,watch } from 'vue';
import { getGroupClaList, setGroupClaStatus, deleteGroupCla } from '@/api/cla';
import { useRouter, useRoute } from 'vue-router';
import { GModal } from '@/components/Setting/index';
import { reqCatch } from '@/utils/catch';
import { getOrgInfo } from '@/views/Org/hooks/orgInfo';
import { Message } from 'vue-devui';
import OssQuery from './Components/OssQuery.vue';
import BatchVerify from './Components/BatchVerify.vue';
const { namespace } = getOrgInfo();


// 获取当前路由
const route = useRoute();

const selectTab = ref(route.query.tab || 'OssQuery');


// 监听路由变化，更新 Tab
watch(
  () => route.query.tab,
  (newTab) => {
    if (newTab) {
      selectTab.value = newTab;
    }
  }
);

// 删除弹窗
const item = ref('');
const deleteModal = ref();
const deletevModels = ref(false);
const openDelete = (row: any) => {
  item.value = row;
  deleteModal.value.showFlag = true;
  deletevModels.value = true;
};

const router = useRouter();

// 分页
const changeIndex = () => {
  // getGroupClaListData();
};

const changeSize = () => {
  pager.value.pageIndex = 1;
  // getGroupClaListData();
};

const repoFun = (arr: any) => {
  return arr ? (arr.length > 3 ? arr.slice(0, 3) : arr) : [];
};

// 编辑
const editRow = (row: any) => {
  // 后续请换成params，暂时params传参没传过去
  router.push({
    path: 'cla/edit/' + row.object_id,
    query: { cla: row.cla, pageType: 'edit' }
  });
};

// 确认删除
const confirmDelete = async (e: any) => {
  // const res = await reqCatch(deleteGroupCla, { group_id: namespace.value, cla_id: item.value.object_id });
  // if (!res.error) {
  //   getGroupClaListData();
  // }
};

// 去成员页
const goMember = (row: any) => {
  // 后续请换成params，暂时params传参没传过去,注意路由有个:claID
  router.push({
    path: 'cla/claId/member',
    query: { claId: row.object_id, claName: row.cla_name, group_path: namespace.value, pageType: 'edit' }
  });
};
const getGroupClaListData = async () => {
  // const params = {
  //   group_id: namespace.value,
  //   page: pager.value.pageIndex,
  //   per_page: pager.value.pageSize
  // };
  // const res = await reqCatch(getGroupClaList, params);
  // if (!res.error) {
  //   tableData.value = res?.data?.data?.content;
  //   pager.value.total = res.data.data.total;
  // }
};
getGroupClaListData();

const setClaStatus = async (row: any) => {
  // const params = {
  //   group_id: namespace.value,
  //   cla_id: row.object_id,
  //   status: row.status
  // };
  // const res = await reqCatch(setGroupClaStatus, params);
  // if (!res.error) {
  //   Message.success('操作成功!');
  //   getGroupClaListData();
  // }
};

const signCla = (row: any) => {
  router.push('/cla/' + row.object_id);
};
</script>

<style scoped lang="scss">
@import 'devui-theme/styles-var/devui-var.scss';

.secret-container {
  position: relative;

  .secret-op {
    position: absolute;
    right: 0;
    top: 0;
  }

}

.error {
  color: $devui-contrast;
}

:deep(.devui-table__row td) {
  padding-top: 16px;
  padding-bottom: 16px;
}

:deep(.devui-tag .devui-tag--default) {
  background-color: #fff;
  border-radius: 12px;
  padding: 4px 8px;
  font-size: 12px;
  line-height: 16px;
  margin-right: 8px;
  border: 1px solid #E3E3EE;
}

.one-line {
  word-break: break-all;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

.title {
  font-size: 14px;
  font-weight: 400;
  color: #9a9b9c;
  line-height: 20px;
}

.cur-title {
  font-size: 14px;
  font-weight: 500;
  color: #2d2d2e;
  line-height: 20px;
}

.search-form {
  position: relative;
  padding: 12px 20px 12px 0;
  border-radius: 8px 0px 8px 8px;
  background: #F2F5FC;

  .output-btn {
    position: absolute;
    right: 28px;
    bottom: 4px;
    color: #191919;
    font-family: HarmonyOS Sans SC;
    font-weight: regular;
    font-size: 14px;
    line-height: 22px;
    letter-spacing: 0px;
    text-align: left;

  }
}

.secret-breadcrumb {
  padding: 7px 20px 12px;
  background: #ffffff;
}
</style>
