<template>

  <!-- 主体部分 -->
  <div class="xl:w-screen-xl m-auto py-4 mt-12 px-4 sm:px-0 sm:mt-2">
    <el-page-header :icon="ArrowLeft" @back="goBack">
      <template #content>
        <span class="text-large font-600 line-clamp-1"> 商业授权查询 </span>
      </template>
      <div class="w-screen-sm m-auto">
        <el-input
          v-model="where.keywords"
          :placeholder="`搜索关键词`"
          :suffix-icon="Search"
          class="w-full my-5"
          size="large"
          @change="reload"
        />
        <el-card class="my-5 sm:my-10 sm:px-2" shadow="hover">
          <el-result
            :title="`websoft.top 该域名已授权`"
            icon="success"
          />
        </el-card>
      </div>

    </el-page-header>
  </div>

</template>
<script lang="ts" setup>
import {ArrowLeft, Search} from '@element-plus/icons-vue'
import type {CmsArticleParam} from "~/api/cms/cmsArticle/model";
import {pageCmsWebsiteAll} from "~/api/cms/cmsWebsite";
import type {CmsWebsite, CmsWebsiteParam} from "~/api/cms/cmsWebsite/model";

const route = useRoute();
const router = useRouter();
// 页面信息
const list = ref<CmsWebsite[]>([]);
const total = ref(0);
const id = ref<number>();
const inputWidth = ref<string>('180px');
const showSearch = ref<boolean>(false);

// 搜索表单
const where = reactive<CmsWebsiteParam>({
  keywords: '',
  page: 1,
  limit: 12,
  status: undefined,
  recommend: undefined,
  search: true,
  websiteType: undefined,
  categoryId: undefined,
  lang: undefined
});

const goBack = () => {
  router.back();
}
const handleFocus = () => {
  inputWidth.value = '400px'; // 聚焦时宽度
}
const handleBlur = () => {
  inputWidth.value = '180px'; // 聚焦时宽度
}

const showDomain = (item: CmsWebsite) => {
  id.value = Number(item.websiteId);
};

const hideDomain = () => {
  id.value = 0;
};

// 加载页面数据
const reload = async () => {
  await pageCmsWebsiteAll({
    ...where,
    plugin: false
  }).then(response => {
    if (response?.list) {
      list.value = response?.list;
      total.value = response.count;
    }
  }).catch(() => {
  }).finally(() => showSearch.value = false)
}

/**
 * 搜索
 * @param data
 */
const search = (data: CmsArticleParam) => {
  where.page = data.page;
  reload();
}

watch(
  () => route.params.id,
  () => {
    reload();
  },
  {immediate: true}
);
</script>
<style lang="scss">
.el-input {
  transition: width 0.3s ease;
}
</style>


