|
|
@@ -0,0 +1,139 @@
|
|
|
+<script setup lang="ts">
|
|
|
+
|
|
|
+defineOptions({
|
|
|
+ name: 'tagList',
|
|
|
+})
|
|
|
+import { ElButton, ElOption, ElPagination, ElSelect, ElTable, ElTableColumn, ElTag } from 'element-plus'
|
|
|
+
|
|
|
+import { usePagination } from 'vue-request'
|
|
|
+import { fetchTagList, deleteTag } from '@/api/modules/model'
|
|
|
+import type { TTagListItem } from '@/api/modules/model'
|
|
|
+import { formatDateGeneral } from '@/utils'
|
|
|
+import EditForm from './components/EditForm.vue'
|
|
|
+import SearchForm from './components/SearchForm.vue'
|
|
|
+import { toast } from 'vue-sonner'
|
|
|
+
|
|
|
+
|
|
|
+const editFormVisible = ref(false)
|
|
|
+const currentData = ref<TTagListItem|null>(null)
|
|
|
+// 搜索参数
|
|
|
+const searchParams = ref({
|
|
|
+ cate1: '',
|
|
|
+})
|
|
|
+
|
|
|
+const { data, run, loading, current, total, pageSize, changePageSize } = usePagination(fetchTagList, {
|
|
|
+ defaultParams: [{ page: 1, size: 20, cate1: '' }],
|
|
|
+});
|
|
|
+
|
|
|
+async function fetchData(page?: number) {
|
|
|
+ run({
|
|
|
+ cate1: searchParams.value.cate1,
|
|
|
+ page: page ?? current.value,
|
|
|
+ size: pageSize.value,
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+function handleCreate () {
|
|
|
+ editFormVisible.value = true
|
|
|
+ currentData.value = null
|
|
|
+}
|
|
|
+
|
|
|
+function handleEdit(row: TTagListItem) {
|
|
|
+ currentData.value = row
|
|
|
+ editFormVisible.value = true
|
|
|
+}
|
|
|
+
|
|
|
+function handleRefresh () {
|
|
|
+ fetchData()
|
|
|
+}
|
|
|
+
|
|
|
+function handleSearch () {
|
|
|
+ fetchData()
|
|
|
+}
|
|
|
+
|
|
|
+function handleReset () {
|
|
|
+ searchParams.value = {
|
|
|
+ cate1: '',
|
|
|
+ }
|
|
|
+ fetchData(1)
|
|
|
+}
|
|
|
+
|
|
|
+async function handleDelete(row: TTagListItem) {
|
|
|
+ const {code} = await deleteTag({id: row.id})
|
|
|
+ if(code === 0){
|
|
|
+ toast.success('删除成功')
|
|
|
+ fetchData()
|
|
|
+ return
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+onMounted(() => {
|
|
|
+ fetchData()
|
|
|
+})
|
|
|
+
|
|
|
+
|
|
|
+</script>
|
|
|
+
|
|
|
+<template>
|
|
|
+ <div class="absolute-container">
|
|
|
+ <div class="p-4 pb-0 bg-white dark-bg-black/50">
|
|
|
+ <SearchForm v-model="searchParams" @search="handleSearch" @reset="handleReset"/>
|
|
|
+ </div>
|
|
|
+ <FaPageMain class="flex-1 overflow-auto" main-class="flex-1 flex flex-col overflow-auto">
|
|
|
+ <div class="pb-4">
|
|
|
+ <div class="flex items-center gap-4">
|
|
|
+ <ElButton type="primary" @click="handleCreate">新增标签</ElButton>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <ElTable
|
|
|
+ v-loading="loading"
|
|
|
+ ref="tableRef" :data="data?.data?.content" stripe highlight-current-row border height="100%"
|
|
|
+ >
|
|
|
+ <ElTableColumn label="ID" prop="id" min-width="240" show-overflow-tooltip />
|
|
|
+ <ElTableColumn label="标签分类" prop="cate1" min-width="120" show-overflow-tooltip />
|
|
|
+ <ElTableColumn label="标签名(英文)" prop="name" min-width="150" show-overflow-tooltip />
|
|
|
+ <ElTableColumn label="标签别名" prop="alias" min-width="200">
|
|
|
+ <template #default="scope">
|
|
|
+ <ElTag v-for="(item, index) in scope.row.alias" :key="index" class="mr-1 mb-1">
|
|
|
+ {{ item }}
|
|
|
+ </ElTag>
|
|
|
+ <span v-if="!scope.row.alias || scope.row.alias.length === 0" class="text-gray-400">暂无别名</span>
|
|
|
+ </template>
|
|
|
+ </ElTableColumn>
|
|
|
+ <ElTableColumn label="外部QA ID" prop="outQaId" min-width="180" show-overflow-tooltip />
|
|
|
+ <ElTableColumn label="创建时间" prop="ctime" width="180">
|
|
|
+ <template #default="scope">
|
|
|
+ {{ formatDateGeneral(scope.row.ctime) }}
|
|
|
+ </template>
|
|
|
+ </ElTableColumn>
|
|
|
+ <ElTableColumn fixed="right" label="操作" min-width="120">
|
|
|
+ <template #default="{row}">
|
|
|
+ <ElButton link type="primary" size="small" @click="()=> handleEdit(row)">编辑</ElButton>
|
|
|
+ <ElPopconfirm title="确认删除?" @confirm="()=> handleDelete(row)">
|
|
|
+ <template #reference>
|
|
|
+ <ElButton link type="danger" size="small">删除</ElButton>
|
|
|
+ </template>
|
|
|
+ </ElPopconfirm>
|
|
|
+ </template>
|
|
|
+ </ElTableColumn>
|
|
|
+ </ElTable>
|
|
|
+ <div class="p-4">
|
|
|
+ <ElPagination v-model:current-page="current" v-model:page-size="pageSize" :total="total"
|
|
|
+ :page-sizes="[10, 20, 50, 100]" layout="total, sizes, prev, pager, next, jumper"
|
|
|
+ @size-change="changePageSize" @current-change="fetchData" />
|
|
|
+ </div>
|
|
|
+ </FaPageMain>
|
|
|
+ <EditForm v-model:visible="editFormVisible" @refresh="handleRefresh" />
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+<style scoped>
|
|
|
+.absolute-container {
|
|
|
+ position: absolute;
|
|
|
+ display: flex;
|
|
|
+ flex-direction: column;
|
|
|
+ width: 100%;
|
|
|
+ height: 100%;
|
|
|
+}
|
|
|
+</style>
|