文章分类、标签
This commit is contained in:
parent
d87ce9a414
commit
cbc61b5b9e
60
src/api/content/article.ts
Normal file
60
src/api/content/article.ts
Normal file
@ -0,0 +1,60 @@
|
||||
import { http } from '@/utils/http/axios';
|
||||
|
||||
/**
|
||||
* @description: 列表
|
||||
*/
|
||||
export function getArticleList(params?) {
|
||||
return http.request({
|
||||
url: '/article/page',
|
||||
method: 'GET',
|
||||
params,
|
||||
});
|
||||
}
|
||||
/**
|
||||
* @description: 根据ID获取详情
|
||||
*/
|
||||
export function getArticleDetail(articleId) {
|
||||
return http.request({
|
||||
url: '/article/detail/'+articleId,
|
||||
method: 'get',
|
||||
});
|
||||
}
|
||||
/**
|
||||
* @description: 添加
|
||||
*/
|
||||
export function articleAdd(data:any) {
|
||||
return http.request({
|
||||
url: '/article/add',
|
||||
method: 'POST',
|
||||
data,
|
||||
});
|
||||
}
|
||||
/**
|
||||
* @description: 更新
|
||||
*/
|
||||
export function articleUpdate(data:any) {
|
||||
return http.request({
|
||||
url: '/article/update',
|
||||
method: 'PUT',
|
||||
data
|
||||
});
|
||||
}
|
||||
/**
|
||||
* @description: 删除
|
||||
*/
|
||||
export function articleDelete(articleId) {
|
||||
return http.request({
|
||||
url: '/article/delete/'+articleId,
|
||||
method: 'DELETE',
|
||||
});
|
||||
}
|
||||
/**
|
||||
* @description: 批量删除
|
||||
*/
|
||||
export function articleBatchDelete(data:any) {
|
||||
return http.request({
|
||||
url: '/article/batchDelete',
|
||||
method: 'DELETE',
|
||||
data
|
||||
});
|
||||
}
|
50
src/api/content/category.ts
Normal file
50
src/api/content/category.ts
Normal file
@ -0,0 +1,50 @@
|
||||
import { http } from '@/utils/http/axios';
|
||||
|
||||
/**
|
||||
* @description: 列表
|
||||
*/
|
||||
export function getCategoryList(params?) {
|
||||
return http.request({
|
||||
url: '/category/list',
|
||||
method: 'GET',
|
||||
params,
|
||||
});
|
||||
}
|
||||
/**
|
||||
* @description: 根据ID获取详情
|
||||
*/
|
||||
export function getCategoryDetail(categoryId) {
|
||||
return http.request({
|
||||
url: '/category/detail/'+categoryId,
|
||||
method: 'get',
|
||||
});
|
||||
}
|
||||
/**
|
||||
* @description: 添加
|
||||
*/
|
||||
export function categoryAdd(data:any) {
|
||||
return http.request({
|
||||
url: '/category/add',
|
||||
method: 'POST',
|
||||
data,
|
||||
});
|
||||
}
|
||||
/**
|
||||
* @description: 更新
|
||||
*/
|
||||
export function categoryUpdate(data:any) {
|
||||
return http.request({
|
||||
url: '/category/update',
|
||||
method: 'PUT',
|
||||
data
|
||||
});
|
||||
}
|
||||
/**
|
||||
* @description: 删除部门
|
||||
*/
|
||||
export function categoryDelete(categoryId) {
|
||||
return http.request({
|
||||
url: '/category/delete/'+categoryId,
|
||||
method: 'DELETE',
|
||||
});
|
||||
}
|
60
src/api/content/tag.ts
Normal file
60
src/api/content/tag.ts
Normal file
@ -0,0 +1,60 @@
|
||||
import { http } from '@/utils/http/axios';
|
||||
|
||||
/**
|
||||
* @description: 列表
|
||||
*/
|
||||
export function getTagList(params?) {
|
||||
return http.request({
|
||||
url: '/tag/page',
|
||||
method: 'GET',
|
||||
params,
|
||||
});
|
||||
}
|
||||
/**
|
||||
* @description: 根据ID获取详情
|
||||
*/
|
||||
export function getTagDetail(tagId) {
|
||||
return http.request({
|
||||
url: '/tag/detail/'+tagId,
|
||||
method: 'get',
|
||||
});
|
||||
}
|
||||
/**
|
||||
* @description: 添加
|
||||
*/
|
||||
export function tagAdd(data:any) {
|
||||
return http.request({
|
||||
url: '/tag/add',
|
||||
method: 'POST',
|
||||
data,
|
||||
});
|
||||
}
|
||||
/**
|
||||
* @description: 更新
|
||||
*/
|
||||
export function tagUpdate(data:any) {
|
||||
return http.request({
|
||||
url: '/tag/update',
|
||||
method: 'PUT',
|
||||
data
|
||||
});
|
||||
}
|
||||
/**
|
||||
* @description: 删除
|
||||
*/
|
||||
export function tagDelete(tagId) {
|
||||
return http.request({
|
||||
url: '/tag/delete/'+tagId,
|
||||
method: 'DELETE',
|
||||
});
|
||||
}
|
||||
/**
|
||||
* @description: 批量删除
|
||||
*/
|
||||
export function tagBatchDelete(data:any) {
|
||||
return http.request({
|
||||
url: '/tag/batchDelete',
|
||||
method: 'DELETE',
|
||||
data
|
||||
});
|
||||
}
|
171
src/views/content/category/edit.vue
Normal file
171
src/views/content/category/edit.vue
Normal file
@ -0,0 +1,171 @@
|
||||
<template>
|
||||
<el-dialog
|
||||
v-model="props.visible"
|
||||
:title="props.categoryId?'编辑':'新增'"
|
||||
width="600"
|
||||
:close-on-click-modal="false"
|
||||
:before-close="dialogClose"
|
||||
>
|
||||
<el-form
|
||||
ref="formRef"
|
||||
:model="formData"
|
||||
label-width="80px"
|
||||
>
|
||||
<el-form-item
|
||||
label="上级分类"
|
||||
prop="parentId"
|
||||
:rules="{ required: true, message: '请选择上级分类', trigger: 'change' }"
|
||||
>
|
||||
<el-tree-select
|
||||
class="flex-1"
|
||||
v-model="formData.parentId"
|
||||
:data="categoryOptions"
|
||||
clearable
|
||||
node-key="id"
|
||||
:props="{
|
||||
label: 'name',
|
||||
}"
|
||||
:default-expand-all="true"
|
||||
placeholder="请选择上级分类"
|
||||
check-strictly
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item
|
||||
label="分类名称"
|
||||
prop="name"
|
||||
:rules="{ required: true, message: '请输入分类名称', trigger: 'blur' }"
|
||||
>
|
||||
<el-input
|
||||
v-model="formData.name"
|
||||
placeholder="请输入分类名称"
|
||||
clearable
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="分类排序" prop="sort" class="flex-1">
|
||||
<div>
|
||||
<el-input-number v-model="formData.sort" :max="9999" placeholder="请输入分类排序"/>
|
||||
<div class="form-tips">数值越小越排前</div>
|
||||
</div>
|
||||
</el-form-item>
|
||||
<el-form-item label="分类备注" prop="note">
|
||||
<el-input
|
||||
class="flex-1"
|
||||
v-model="formData.note"
|
||||
type="textarea"
|
||||
placeholder="请输入分类备注"
|
||||
clearable
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<span class="dialog-footer">
|
||||
<el-button @click="dialogClose">取消</el-button>
|
||||
<el-button :loading="subLoading" type="primary" @click="submit">
|
||||
确定
|
||||
</el-button>
|
||||
</span>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
import type {FormInstance} from "element-plus";
|
||||
import { categoryAdd,categoryUpdate,getCategoryList,getCategoryDetail } from '@/api/content/category';
|
||||
import {onMounted, reactive, ref, shallowRef} from "vue";
|
||||
import {getModulesKey} from "@/router";
|
||||
import {message,buildTree} from "@/utils/auth";
|
||||
import {useLockFn} from "@/utils/useLockFn";
|
||||
const props = defineProps({
|
||||
visible: {
|
||||
type: Boolean,
|
||||
required: true,
|
||||
default: false
|
||||
},
|
||||
categoryId: {
|
||||
type: Number,
|
||||
required: true,
|
||||
default: 0
|
||||
},
|
||||
pid: {
|
||||
type: Number,
|
||||
default: 0
|
||||
}
|
||||
});
|
||||
const emit = defineEmits(["success","update:visible"]);
|
||||
const formRef = shallowRef<FormInstance>();
|
||||
|
||||
const componentsOptions = ref(getModulesKey());
|
||||
const querySearch = (queryString: string, cb: any) => {
|
||||
const results = queryString
|
||||
? componentsOptions.value.filter((item) =>
|
||||
item.toLowerCase().includes(queryString.toLowerCase())
|
||||
)
|
||||
: componentsOptions.value;
|
||||
cb(results.map((item) => ({value: item})));
|
||||
};
|
||||
|
||||
const formData = reactive({
|
||||
id: "",
|
||||
//父级id
|
||||
parentId: 0,
|
||||
//名称
|
||||
name: "",
|
||||
//排序
|
||||
sort: 0,
|
||||
note:''
|
||||
});
|
||||
|
||||
const dialogClose = () => {
|
||||
emit("update:visible", false);
|
||||
};
|
||||
|
||||
const categoryOptions = ref<any[]>([]);
|
||||
|
||||
const getMenu = async () => {
|
||||
const data: any = await getCategoryList();
|
||||
const menu: any = [{id: 0, name: "顶级", children: []}];
|
||||
const lists = buildTree(data)
|
||||
menu[0].children.push(...lists)
|
||||
categoryOptions.value = menu
|
||||
};
|
||||
|
||||
const handleSubmit = async () => {
|
||||
await formRef.value?.validate();
|
||||
props.categoryId ? await categoryUpdate(formData) : await categoryAdd(formData);
|
||||
message("操作成功");
|
||||
emit("update:visible", false);
|
||||
emit("success");
|
||||
};
|
||||
|
||||
const { isLock:subLoading,lockFn: submit } = useLockFn(handleSubmit);
|
||||
|
||||
|
||||
const setFormData = (data: Record<any, any>) => {
|
||||
for (const key in formData) {
|
||||
if (data[key] != null && data[key] != undefined) {
|
||||
formData[key] = data[key];
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const getDetail = async () => {
|
||||
const data = await getCategoryDetail(
|
||||
props.categoryId
|
||||
);
|
||||
setFormData(data);
|
||||
};
|
||||
|
||||
const handleClose = () => {
|
||||
emit("close");
|
||||
};
|
||||
|
||||
|
||||
|
||||
onMounted(() => {
|
||||
getMenu()
|
||||
if (props.categoryId) {
|
||||
getDetail()
|
||||
}else{
|
||||
formData.parentId=props.pid
|
||||
}
|
||||
});
|
||||
</script>
|
137
src/views/content/category/index.vue
Normal file
137
src/views/content/category/index.vue
Normal file
@ -0,0 +1,137 @@
|
||||
<template>
|
||||
<div class="menu-index">
|
||||
<el-card :bordered="false" class="pt-3 mb-3 proCard">
|
||||
<div>
|
||||
<el-button type="primary" @click="handleAdd()">
|
||||
<template #icon>
|
||||
<el-icon>
|
||||
<plus />
|
||||
</el-icon>
|
||||
</template>
|
||||
新增
|
||||
</el-button>
|
||||
<el-button @click="handleExpand"> 展开/折叠</el-button>
|
||||
</div>
|
||||
</el-card>
|
||||
<el-card :bordered="false" class="pt-3 mb-3 proCard">
|
||||
<el-table border v-loading="loading" ref="tableRef" :data="lists" row-key="id"
|
||||
:tree-props="{ children: 'children', hasChildren: 'hasChildren' }">
|
||||
<el-table-column label="分类名称" prop="name" min-width="150" show-overflow-tooltip/>
|
||||
<el-table-column align="center" label="分类排序" prop="sort" min-width="100"/>
|
||||
<el-table-column align="center" label="分类备注" prop="note" min-width="100"/>
|
||||
<el-table-column align="center" label="创建人" prop="createUser" min-width="180"></el-table-column>
|
||||
<el-table-column align="center" label="创建时间" prop="createTime" min-width="180"></el-table-column>
|
||||
<el-table-column align="center" label="操作" width="160" fixed="right">
|
||||
<template #default="{ row }">
|
||||
<el-button type="primary" link
|
||||
@click="handleAdd(row.id)">
|
||||
新增
|
||||
</el-button>
|
||||
<el-button type="primary" link @click="handleEdit(row)">
|
||||
编辑
|
||||
</el-button>
|
||||
<el-button type="danger" link @click="handleDelete(row.id)">
|
||||
删除
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</el-card>
|
||||
<editDialog
|
||||
ref="editRef"
|
||||
v-if="editVisible"
|
||||
:categoryId="categoryId"
|
||||
:pid="pid"
|
||||
v-model:visible="editVisible"
|
||||
@success="getLists"
|
||||
>
|
||||
</editDialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup name="menu">
|
||||
import {defineAsyncComponent, nextTick, onMounted, ref, shallowRef} from "vue";
|
||||
import {getCategoryList,categoryDelete} from "@/api/content/category";
|
||||
import type {ElTable} from "element-plus";
|
||||
const tableRef = shallowRef<InstanceType<typeof ElTable>>();
|
||||
import {confirm, message,buildTree} from "@/utils/auth";
|
||||
|
||||
const editDialog = defineAsyncComponent(() =>
|
||||
import('./edit.vue')
|
||||
)
|
||||
|
||||
const isExpand = ref(false);
|
||||
const loading = ref(false);
|
||||
const editVisible=ref(false);
|
||||
const categoryId=ref(0);
|
||||
const pid=ref(0)
|
||||
const lists = ref([]);
|
||||
|
||||
const getLists = async () => {
|
||||
loading.value = true;
|
||||
try {
|
||||
const data = await getCategoryList();
|
||||
lists.value = buildTree(data);
|
||||
loading.value = false;
|
||||
} catch (error) {
|
||||
loading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
const handleAdd = async (parentId:any) => {
|
||||
categoryId.value=0
|
||||
pid.value=parentId?parentId:0
|
||||
await nextTick();
|
||||
editVisible.value=true
|
||||
};
|
||||
|
||||
const handleEdit = async (data: any) => {
|
||||
categoryId.value=data.id
|
||||
await nextTick();
|
||||
editVisible.value=true
|
||||
};
|
||||
|
||||
const handleDelete = async (categoryId: number) => {
|
||||
await confirm("确定要删除?");
|
||||
try {
|
||||
loading.value = true;
|
||||
await categoryDelete(categoryId);
|
||||
message("删除成功");
|
||||
getLists();
|
||||
} catch (e) {
|
||||
loading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
const handleExpand = () => {
|
||||
isExpand.value = !isExpand.value;
|
||||
toggleExpand(lists.value, isExpand.value);
|
||||
};
|
||||
|
||||
const toggleExpand = (children: any[], unfold = true) => {
|
||||
for (const key in children) {
|
||||
tableRef.value?.toggleRowExpansion(children[key], unfold);
|
||||
if (children[key].children) {
|
||||
toggleExpand(children[key].children!, unfold);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const getAll=()=>{
|
||||
getLists();
|
||||
}
|
||||
|
||||
|
||||
onMounted(() => {
|
||||
getAll()
|
||||
});
|
||||
|
||||
// onActivated(() => {
|
||||
// getAll()
|
||||
// });
|
||||
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
24
src/views/content/tag/columns.ts
Normal file
24
src/views/content/tag/columns.ts
Normal file
@ -0,0 +1,24 @@
|
||||
import { h } from 'vue';
|
||||
import { ElTag } from 'element-plus';
|
||||
|
||||
export const columns = [
|
||||
{
|
||||
type: 'selection',
|
||||
},
|
||||
{
|
||||
label: '标签名称',
|
||||
prop: 'name',
|
||||
},
|
||||
{
|
||||
label: '排序',
|
||||
prop: 'sort',
|
||||
},
|
||||
{
|
||||
label: '创建人',
|
||||
prop: 'createUser',
|
||||
},
|
||||
{
|
||||
label: '创建时间',
|
||||
prop: 'createTime',
|
||||
},
|
||||
];
|
104
src/views/content/tag/edit.vue
Normal file
104
src/views/content/tag/edit.vue
Normal file
@ -0,0 +1,104 @@
|
||||
<template>
|
||||
<el-dialog
|
||||
v-model="props.visible"
|
||||
:title="props.tagId?'编辑':'新增'"
|
||||
width="500"
|
||||
:close-on-click-modal="false"
|
||||
:before-close="dialogClose"
|
||||
>
|
||||
<el-form
|
||||
class="ls-form"
|
||||
ref="formRef"
|
||||
:model="formData"
|
||||
label-width="80px"
|
||||
>
|
||||
<el-form-item
|
||||
label="标签名称"
|
||||
prop="name"
|
||||
:rules="{ required: true, message: '请输入标签名称', trigger: 'blur' }"
|
||||
>
|
||||
<el-input
|
||||
class="ls-input"
|
||||
v-model="formData.name"
|
||||
placeholder="请输入标签名称"
|
||||
clearable
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="排序" prop="sort">
|
||||
<el-input-number v-model="formData.sort"/>
|
||||
</el-form-item>
|
||||
<el-form-item label="备注" prop="note">
|
||||
<el-input v-model="formData.note" type="textarea" placeholder="请输入标签备注"/>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<span class="dialog-footer">
|
||||
<el-button @click="dialogClose">取消</el-button>
|
||||
<el-button :loading="subLoading" type="primary" @click="submit">
|
||||
确定
|
||||
</el-button>
|
||||
</span>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
import type {FormInstance} from "element-plus";
|
||||
import {getTagDetail,tagAdd,tagUpdate} from "@/api/content/tag";
|
||||
import {onMounted, reactive, shallowRef} from "vue";
|
||||
import {message} from "@/utils/auth";
|
||||
import {useLockFn} from "@/utils/useLockFn";
|
||||
|
||||
const emit = defineEmits(["success", "update:visible"]);
|
||||
const formRef = shallowRef<FormInstance>();
|
||||
const formData = reactive({
|
||||
id: "",
|
||||
name: "",
|
||||
note: "",
|
||||
sort: 0
|
||||
});
|
||||
|
||||
const props = defineProps({
|
||||
visible: {
|
||||
type: Boolean,
|
||||
required: true,
|
||||
default: false
|
||||
},
|
||||
tagId: {
|
||||
type: Number,
|
||||
required: true,
|
||||
default: 0
|
||||
}
|
||||
});
|
||||
|
||||
const handleSubmit = async () => {
|
||||
await formRef.value?.validate();
|
||||
props.tagId ? await tagUpdate(formData) : await tagAdd(formData);
|
||||
message("操作成功");
|
||||
emit("update:visible", false);
|
||||
emit("success");
|
||||
};
|
||||
|
||||
const dialogClose = () => {
|
||||
emit("update:visible", false);
|
||||
};
|
||||
|
||||
const { isLock:subLoading,lockFn: submit } = useLockFn(handleSubmit);
|
||||
|
||||
|
||||
const setFormData = async () => {
|
||||
const data = await getTagDetail(props.tagId);
|
||||
for (const key in formData) {
|
||||
if (data[key] != null && data[key] != undefined) {
|
||||
//@ts-ignore
|
||||
formData[key] = data[key];
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
if (props.tagId) {
|
||||
setFormData();
|
||||
}
|
||||
});
|
||||
|
||||
</script>
|
160
src/views/content/tag/index.vue
Normal file
160
src/views/content/tag/index.vue
Normal file
@ -0,0 +1,160 @@
|
||||
<template>
|
||||
<PageWrapper>
|
||||
<el-card :bordered="false" class="pt-3 mb-3 proCard">
|
||||
<BasicForm @register="register" @submit="handleSubmit" @reset="handleReset"></BasicForm>
|
||||
</el-card>
|
||||
<el-card :bordered="false" class="proCard">
|
||||
<BasicTable
|
||||
:columns="columns"
|
||||
:request="loadDataTable"
|
||||
:row-key="(row) => row.id"
|
||||
ref="tableRef"
|
||||
:actionColumn="actionColumn"
|
||||
@selection-change="onSelectionChange"
|
||||
>
|
||||
<template #tableTitle>
|
||||
<el-button type="primary" @click="handleAdd">
|
||||
<template #icon>
|
||||
<el-icon class="el-input__icon">
|
||||
<PlusOutlined />
|
||||
</el-icon>
|
||||
</template>
|
||||
添加标签
|
||||
</el-button>
|
||||
<el-button type="danger" @click="handleDelete()" :disabled="!selectionData.length">
|
||||
<template #icon>
|
||||
<el-icon class="el-input__icon">
|
||||
<Delete />
|
||||
</el-icon>
|
||||
</template>
|
||||
删除
|
||||
</el-button>
|
||||
</template>
|
||||
|
||||
<template #action>
|
||||
<TableAction />
|
||||
</template>
|
||||
</BasicTable>
|
||||
</el-card>
|
||||
|
||||
<editDialog
|
||||
v-if="editVisible"
|
||||
:tagId="tagId"
|
||||
v-model:visible="editVisible"
|
||||
@success="reloadTable"
|
||||
>
|
||||
</editDialog>
|
||||
</PageWrapper>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { reactive, ref, h,nextTick,defineAsyncComponent } from 'vue';
|
||||
import { ColProps } from 'element-plus';
|
||||
import { schemas } from './querySchemas';
|
||||
import { useForm } from '@/components/Form/index';
|
||||
import { TableAction } from '@/components/Table';
|
||||
import { getTagList,tagDelete,tagBatchDelete } from '@/api/content/tag';
|
||||
import { columns } from './columns';
|
||||
import { PlusOutlined } from '@vicons/antd';
|
||||
import {message,confirm} from "@/utils/auth";
|
||||
const editDialog = defineAsyncComponent(() =>
|
||||
import('./edit.vue')
|
||||
)
|
||||
const tagId =ref(0)
|
||||
const editVisible=ref(false)
|
||||
const selectionData = ref([])
|
||||
const tableRef = ref();
|
||||
const formParams = reactive({
|
||||
name:''
|
||||
});
|
||||
const actionColumn = reactive({
|
||||
width: 250,
|
||||
label: '操作',
|
||||
prop: 'action',
|
||||
fixed: 'right',
|
||||
render(record) {
|
||||
return h(TableAction, {
|
||||
style: 'button',
|
||||
actions: [
|
||||
{
|
||||
label: '编辑',
|
||||
type: 'warning',
|
||||
onClick: handleEdit.bind(null, record),
|
||||
ifShow: () => {
|
||||
return true;
|
||||
},
|
||||
// auth: ['basic_list'],
|
||||
},
|
||||
{
|
||||
label: '删除',
|
||||
type: 'danger',
|
||||
onClick: handleDelete.bind(null, record),
|
||||
// 根据业务控制是否显示 isShow 和 auth 是并且关系
|
||||
ifShow: () => {
|
||||
return true;
|
||||
},
|
||||
// 根据权限控制是否显示: 有权限,会显示,支持多个
|
||||
// auth: ['basic_list'],
|
||||
},
|
||||
],
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
const loadDataTable = async (res: any) => {
|
||||
const result = await getTagList({ ...formParams, ...res });
|
||||
return result;
|
||||
};
|
||||
|
||||
function reloadTable() {
|
||||
tableRef.value.reload({pageNo:1});
|
||||
}
|
||||
const [register, {}] = useForm({
|
||||
labelWidth: 80,
|
||||
layout: 'horizontal',
|
||||
colProps: { span: 6 } as ColProps,
|
||||
submitOnReset:true,
|
||||
schemas
|
||||
});
|
||||
function handleSubmit(values: Recordable) {
|
||||
for (const key in formParams) {
|
||||
if (values[key] != null && values[key] != undefined) {
|
||||
formParams[key] = values[key];
|
||||
}
|
||||
}
|
||||
reloadTable();
|
||||
}
|
||||
|
||||
function handleReset() {
|
||||
for (const key in formParams) {
|
||||
formParams[key] ='';
|
||||
}
|
||||
}
|
||||
const handleAdd = async () => {
|
||||
tagId.value=0
|
||||
await nextTick();
|
||||
editVisible.value=true
|
||||
};
|
||||
|
||||
const handleEdit = async (record: Recordable) => {
|
||||
tagId.value=record.row.id
|
||||
await nextTick();
|
||||
editVisible.value=true
|
||||
};
|
||||
|
||||
async function handleDelete(record: Recordable) {
|
||||
let ids = []
|
||||
if(!record){
|
||||
ids = selectionData.value.map(({id}) => id);
|
||||
}
|
||||
await confirm('确定要删除?');
|
||||
record? await tagDelete(record.row.id):await tagBatchDelete(ids);
|
||||
message("删除成功");
|
||||
reloadTable()
|
||||
}
|
||||
function onSelectionChange(value){
|
||||
selectionData.value = value
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped></style>
|
11
src/views/content/tag/querySchemas.ts
Normal file
11
src/views/content/tag/querySchemas.ts
Normal file
@ -0,0 +1,11 @@
|
||||
import { FormSchema } from '@/components/Form/index';
|
||||
export const schemas: FormSchema[] = [
|
||||
{
|
||||
field: 'name',
|
||||
component: 'Input',
|
||||
label: '标签名称',
|
||||
componentProps: {
|
||||
placeholder: '请输入标签名称',
|
||||
},
|
||||
}
|
||||
];
|
Loading…
Reference in New Issue
Block a user