分类、友链、标签管理
This commit is contained in:
parent
adaebac926
commit
df27fda054
30
src/views/content/category/columns.ts
Normal file
30
src/views/content/category/columns.ts
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
import { h } from 'vue';
|
||||||
|
import { NTag } from 'naive-ui';
|
||||||
|
|
||||||
|
export const columns = [
|
||||||
|
{
|
||||||
|
title: '分类名称',
|
||||||
|
key: 'name',
|
||||||
|
width: 200,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '分类排序',
|
||||||
|
key: 'sort',
|
||||||
|
width: 100,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '分类备注',
|
||||||
|
key: 'note',
|
||||||
|
width: 100,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '创建人',
|
||||||
|
key: 'createUser',
|
||||||
|
width: 100,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '创建时间',
|
||||||
|
key: 'createTime',
|
||||||
|
width: 180,
|
||||||
|
},
|
||||||
|
];
|
185
src/views/content/category/edit.vue
Normal file
185
src/views/content/category/edit.vue
Normal file
@ -0,0 +1,185 @@
|
|||||||
|
<template>
|
||||||
|
<basicModal
|
||||||
|
@register="modalRegister"
|
||||||
|
ref="modalRef"
|
||||||
|
class="basicModal basicFormModal"
|
||||||
|
@on-ok="handleSubmit"
|
||||||
|
@on-close="handleClose"
|
||||||
|
>
|
||||||
|
<template #default>
|
||||||
|
<n-form ref="formRef" :model="formData" label-placement="left" label-width="80px">
|
||||||
|
<n-form-item
|
||||||
|
label="上级分类"
|
||||||
|
path="parentId"
|
||||||
|
:rule="{ required: true, message: '请选择上级分类', trigger: 'change' }"
|
||||||
|
>
|
||||||
|
<n-tree-select
|
||||||
|
class="flex-1"
|
||||||
|
v-model:value="formData.parentId"
|
||||||
|
:options="categoryOptions"
|
||||||
|
clearable
|
||||||
|
default-expand-all
|
||||||
|
label-field="name"
|
||||||
|
key-field="id"
|
||||||
|
placeholder="请选择上级分类"
|
||||||
|
/>
|
||||||
|
</n-form-item>
|
||||||
|
<n-form-item
|
||||||
|
label="分类名称"
|
||||||
|
path="name"
|
||||||
|
:rule="{ required: true, message: '请输入分类名称', trigger: 'blur' }"
|
||||||
|
>
|
||||||
|
<n-input v-model:value="formData.name" placeholder="请输入分类名称" clearable />
|
||||||
|
</n-form-item>
|
||||||
|
<n-form-item label="分类排序" path="sort" class="flex-1">
|
||||||
|
<div>
|
||||||
|
<n-input-number v-model:value="formData.sort" :max="9999" />
|
||||||
|
<div class="form-tips">数值越小越排前</div>
|
||||||
|
</div>
|
||||||
|
</n-form-item>
|
||||||
|
<n-form-item label="分类备注" path="note">
|
||||||
|
<n-input
|
||||||
|
type="textarea"
|
||||||
|
class="flex-1"
|
||||||
|
v-model:value="formData.note"
|
||||||
|
placeholder="请输入分类备注"
|
||||||
|
clearable
|
||||||
|
/>
|
||||||
|
</n-form-item>
|
||||||
|
</n-form>
|
||||||
|
</template>
|
||||||
|
</basicModal>
|
||||||
|
</template>
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import {
|
||||||
|
categoryAdd,
|
||||||
|
categoryUpdate,
|
||||||
|
getCategoryList,
|
||||||
|
getCategoryDetail,
|
||||||
|
} from '@/api/content/category';
|
||||||
|
import { onMounted, reactive, ref, shallowRef } from 'vue';
|
||||||
|
import { buildTree } from '@/utils/auth';
|
||||||
|
import { useMessage, useDialog } from 'naive-ui';
|
||||||
|
import { useModal } from '@/components/Modal';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 定义接收的参数
|
||||||
|
*/
|
||||||
|
const props = defineProps({
|
||||||
|
visible: {
|
||||||
|
type: Boolean,
|
||||||
|
required: true,
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
|
categoryId: {
|
||||||
|
type: Number,
|
||||||
|
required: true,
|
||||||
|
default: 0,
|
||||||
|
},
|
||||||
|
pid: {
|
||||||
|
type: Number,
|
||||||
|
default: 0,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 定义参数变量
|
||||||
|
*/
|
||||||
|
const message = useMessage();
|
||||||
|
const expandedKeys = ref([]);
|
||||||
|
const emit = defineEmits(['success', 'update:visible']);
|
||||||
|
const formRef = ref();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 定义表单参数
|
||||||
|
*/
|
||||||
|
const formData = reactive({
|
||||||
|
id: '',
|
||||||
|
//父级id
|
||||||
|
parentId: 0,
|
||||||
|
//类型
|
||||||
|
type: 1,
|
||||||
|
//名称
|
||||||
|
name: '',
|
||||||
|
//排序
|
||||||
|
sort: 0,
|
||||||
|
note: '',
|
||||||
|
});
|
||||||
|
const [modalRegister, { openModal, setSubLoading }] = useModal({
|
||||||
|
title: props.categoryId ? '编辑分类' : '添加分类',
|
||||||
|
subBtuText: '确定',
|
||||||
|
width: 600,
|
||||||
|
});
|
||||||
|
/**
|
||||||
|
* 关闭窗体
|
||||||
|
*/
|
||||||
|
const handleClose = () => {
|
||||||
|
emit('update:visible', false);
|
||||||
|
};
|
||||||
|
|
||||||
|
const categoryOptions = ref<any[]>([]);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取分类数据
|
||||||
|
*/
|
||||||
|
const getcategory = async () => {
|
||||||
|
const data: any = await getCategoryList();
|
||||||
|
data.map((item) => {
|
||||||
|
expandedKeys.value.push(item.id);
|
||||||
|
});
|
||||||
|
const menu: any = [{ id: 0, name: '顶级', children: [] }];
|
||||||
|
const lists = buildTree(data);
|
||||||
|
menu[0].children.push(...lists);
|
||||||
|
categoryOptions.value = menu;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 执行提交表单
|
||||||
|
*/
|
||||||
|
const handleSubmit = async () => {
|
||||||
|
formRef.value
|
||||||
|
.validate()
|
||||||
|
.then(async () => {
|
||||||
|
props.categoryId ? await categoryUpdate(formData) : await categoryAdd(formData);
|
||||||
|
message.success('操作成功');
|
||||||
|
setSubLoading(false);
|
||||||
|
emit('update:visible', false);
|
||||||
|
emit('success');
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
setSubLoading(false);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置表单数据
|
||||||
|
*/
|
||||||
|
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);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 钩子函数
|
||||||
|
*/
|
||||||
|
onMounted(() => {
|
||||||
|
getcategory();
|
||||||
|
if (props.categoryId) {
|
||||||
|
getDetail();
|
||||||
|
} else {
|
||||||
|
formData.parentId = props.pid;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
//导出方法
|
||||||
|
defineExpose({
|
||||||
|
openModal,
|
||||||
|
});
|
||||||
|
</script>
|
175
src/views/content/category/index.vue
Normal file
175
src/views/content/category/index.vue
Normal file
@ -0,0 +1,175 @@
|
|||||||
|
<template>
|
||||||
|
<div class="menu-index">
|
||||||
|
<n-card :bordered="false" class="pt-3 mb-3 proCard">
|
||||||
|
<n-spin :show="loading">
|
||||||
|
<BasicTable
|
||||||
|
ref="tableRef"
|
||||||
|
:columns="columns"
|
||||||
|
:paginate-single-page="false"
|
||||||
|
:request="loadDataTable"
|
||||||
|
:row-key="(row) => row.id"
|
||||||
|
:autoScrollX="true"
|
||||||
|
:actionColumn="actionColumn"
|
||||||
|
v-model:expanded-row-keys="expandKeys"
|
||||||
|
>
|
||||||
|
<template #tableTitle>
|
||||||
|
<n-space>
|
||||||
|
<n-button type="primary" @click="handleAdd()" v-perm="['sys:category:add']">
|
||||||
|
<template #icon>
|
||||||
|
<n-icon>
|
||||||
|
<PlusOutlined />
|
||||||
|
</n-icon>
|
||||||
|
</template>
|
||||||
|
新增
|
||||||
|
</n-button>
|
||||||
|
<n-button @click="handleExpand"> 展开/折叠 </n-button>
|
||||||
|
</n-space>
|
||||||
|
</template>
|
||||||
|
</BasicTable>
|
||||||
|
</n-spin>
|
||||||
|
</n-card>
|
||||||
|
<editDialog
|
||||||
|
ref="createModalRef"
|
||||||
|
v-if="editVisible"
|
||||||
|
:categoryId="categoryId"
|
||||||
|
:pid="pid"
|
||||||
|
v-model:visible="editVisible"
|
||||||
|
@success="loadDataTable"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup name="menus">
|
||||||
|
import { defineAsyncComponent, nextTick, onMounted, ref, reactive, h } from 'vue';
|
||||||
|
import { PlusOutlined, EditOutlined, DeleteOutlined, FormOutlined } from '@vicons/antd';
|
||||||
|
import { BasicTable, TableAction } from '@/components/Table';
|
||||||
|
import { renderIcon } from '@/utils';
|
||||||
|
import editDialog from './edit.vue';
|
||||||
|
import { getCategoryList, categoryDelete } from '@/api/content/category';
|
||||||
|
import { getTreeValues } from '@/utils/helper/treeHelper';
|
||||||
|
import { useMessage, useDialog } from 'naive-ui';
|
||||||
|
import { columns } from './columns';
|
||||||
|
import { buildTree } from '@/utils/auth';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 定义参数变量
|
||||||
|
*/
|
||||||
|
const message = useMessage();
|
||||||
|
const dialog = useDialog();
|
||||||
|
const tableRef = ref();
|
||||||
|
const loading = ref(false);
|
||||||
|
const editVisible = ref(false);
|
||||||
|
const expandKeys = ref([]);
|
||||||
|
const createModalRef = ref();
|
||||||
|
const categoryId = ref(0);
|
||||||
|
const pid = ref(0);
|
||||||
|
|
||||||
|
const actionColumn = reactive({
|
||||||
|
width: 220,
|
||||||
|
title: '操作',
|
||||||
|
align: 'center',
|
||||||
|
key: 'action',
|
||||||
|
fixed: 'right',
|
||||||
|
render(record) {
|
||||||
|
return h(TableAction as any, {
|
||||||
|
style: 'button',
|
||||||
|
actions: [
|
||||||
|
{
|
||||||
|
label: '新增',
|
||||||
|
type: 'info',
|
||||||
|
icon: renderIcon(PlusOutlined),
|
||||||
|
auth: ['sys:category:add'],
|
||||||
|
onclick: handleAdd.bind(null, record),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '编辑',
|
||||||
|
type: 'warning',
|
||||||
|
icon: renderIcon(FormOutlined),
|
||||||
|
auth: ['sys:category:update'],
|
||||||
|
onclick: handleEdit.bind(null, record),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '删除',
|
||||||
|
type: 'error',
|
||||||
|
icon: renderIcon(DeleteOutlined),
|
||||||
|
auth: ['sys:category:delete'],
|
||||||
|
onclick: handleDelete.bind(null, record),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取部门列表
|
||||||
|
*/
|
||||||
|
const loadDataTable = async (res) => {
|
||||||
|
const data = await getCategoryList();
|
||||||
|
data.map((item) => {
|
||||||
|
item.key = item.id;
|
||||||
|
});
|
||||||
|
const result = {
|
||||||
|
records: buildTree(data),
|
||||||
|
total: 1,
|
||||||
|
};
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 执行添加
|
||||||
|
*/
|
||||||
|
const handleAdd = async (record: any) => {
|
||||||
|
categoryId.value = 0;
|
||||||
|
pid.value = record ? record.parentId : 0;
|
||||||
|
editVisible.value = true;
|
||||||
|
await nextTick();
|
||||||
|
createModalRef.value.openModal();
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 执行编辑
|
||||||
|
* @param data 参数
|
||||||
|
*/
|
||||||
|
const handleEdit = async (data: any) => {
|
||||||
|
categoryId.value = data.id;
|
||||||
|
editVisible.value = true;
|
||||||
|
await nextTick();
|
||||||
|
createModalRef.value.openModal();
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 执行删除
|
||||||
|
* @param id 菜单ID
|
||||||
|
*/
|
||||||
|
const handleDelete = (row: number) => {
|
||||||
|
dialog.warning({
|
||||||
|
title: '提示',
|
||||||
|
content: '确定要删除?',
|
||||||
|
positiveText: '确定',
|
||||||
|
negativeText: '取消',
|
||||||
|
onPositiveClick: async () => {
|
||||||
|
loading.value = true;
|
||||||
|
await categoryDelete(row.id);
|
||||||
|
message.success('删除成功');
|
||||||
|
loadDataTable();
|
||||||
|
loading.value = false;
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 执行扩展、收缩
|
||||||
|
*/
|
||||||
|
const handleExpand = () => {
|
||||||
|
loading.value = true;
|
||||||
|
if (!expandKeys.value.length) {
|
||||||
|
expandKeys.value = getTreeValues(tableRef.value.getDataSource(), 'id');
|
||||||
|
loading.value = false;
|
||||||
|
} else {
|
||||||
|
expandKeys.value = [];
|
||||||
|
loading.value = false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped></style>
|
83
src/views/content/link/columns.ts
Normal file
83
src/views/content/link/columns.ts
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
import { h } from 'vue';
|
||||||
|
import { NTag } from 'naive-ui';
|
||||||
|
|
||||||
|
export const columns = [
|
||||||
|
{
|
||||||
|
type: 'selection',
|
||||||
|
width: 50,
|
||||||
|
fixed: 'left',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'ID',
|
||||||
|
key: 'id',
|
||||||
|
fixed: 'left',
|
||||||
|
width: 50,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '友链名称',
|
||||||
|
key: 'name',
|
||||||
|
width: 100,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '友链类型',
|
||||||
|
key: 'type',
|
||||||
|
width: 100,
|
||||||
|
render(record) {
|
||||||
|
return h('span', record.type === 1 ? '友情链接' : '合作伙伴');
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '友链形式',
|
||||||
|
key: 'form',
|
||||||
|
width: 100,
|
||||||
|
render(record) {
|
||||||
|
return h('span', record.form === 1 ? '文字链接' : '图片链接');
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '友链地址',
|
||||||
|
key: 'url',
|
||||||
|
width: 200,
|
||||||
|
render(record) {
|
||||||
|
return h(
|
||||||
|
'a',
|
||||||
|
{
|
||||||
|
href: record.url,
|
||||||
|
target: '_blank',
|
||||||
|
},
|
||||||
|
record.url,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '状态',
|
||||||
|
key: 'status',
|
||||||
|
width: 100,
|
||||||
|
render(record) {
|
||||||
|
return h(
|
||||||
|
NTag,
|
||||||
|
{
|
||||||
|
type: record.status == 1 ? 'success' : 'error',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
default: () => (record.status == 1 ? '正常' : '停用'),
|
||||||
|
},
|
||||||
|
);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '排序',
|
||||||
|
key: 'sort',
|
||||||
|
width: 100,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '创建人',
|
||||||
|
key: 'createUser',
|
||||||
|
width: 100,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '创建时间',
|
||||||
|
key: 'createTime',
|
||||||
|
width: 180,
|
||||||
|
},
|
||||||
|
];
|
191
src/views/content/link/edit.vue
Normal file
191
src/views/content/link/edit.vue
Normal file
@ -0,0 +1,191 @@
|
|||||||
|
<template>
|
||||||
|
<basicModal
|
||||||
|
@register="modalRegister"
|
||||||
|
ref="modalRef"
|
||||||
|
class="basicModal basicFormModal"
|
||||||
|
@on-ok="handleSubmit"
|
||||||
|
@on-close="handleClose"
|
||||||
|
>
|
||||||
|
<template #default>
|
||||||
|
<n-form
|
||||||
|
class="ls-form"
|
||||||
|
ref="formRef"
|
||||||
|
:model="formData"
|
||||||
|
label-placement="left"
|
||||||
|
label-width="85px"
|
||||||
|
>
|
||||||
|
<n-form-item
|
||||||
|
label="名称"
|
||||||
|
path="name"
|
||||||
|
:rule="{ required: true, message: '请输入名称', trigger: 'blur' }"
|
||||||
|
>
|
||||||
|
<n-input
|
||||||
|
class="ls-input"
|
||||||
|
v-model:value="formData.name"
|
||||||
|
placeholder="请输入名称"
|
||||||
|
clearable
|
||||||
|
/>
|
||||||
|
</n-form-item>
|
||||||
|
<n-form-item
|
||||||
|
label="类型"
|
||||||
|
path="type"
|
||||||
|
:rule="{ type: 'number', required: true, message: '请选择类型', trigger: 'change' }"
|
||||||
|
>
|
||||||
|
<n-select
|
||||||
|
v-model:value="formData.type"
|
||||||
|
placeholder="请选择类型"
|
||||||
|
:options="optionData.typeList"
|
||||||
|
/>
|
||||||
|
</n-form-item>
|
||||||
|
<n-form-item
|
||||||
|
label="地址"
|
||||||
|
path="url"
|
||||||
|
:rule="{ required: true, message: '请输入地址', trigger: 'blur' }"
|
||||||
|
>
|
||||||
|
<n-input v-model:value="formData.url" placeholder="请输入地址" />
|
||||||
|
</n-form-item>
|
||||||
|
<n-form-item
|
||||||
|
label="形式"
|
||||||
|
path="form"
|
||||||
|
:rule="{ type: 'number', required: true, message: '请选择形式', trigger: 'change' }"
|
||||||
|
>
|
||||||
|
<n-select
|
||||||
|
v-model:value="formData.form"
|
||||||
|
placeholder="请选择形式"
|
||||||
|
:options="optionData.formList"
|
||||||
|
/>
|
||||||
|
</n-form-item>
|
||||||
|
<n-form-item
|
||||||
|
label="图片"
|
||||||
|
path="image"
|
||||||
|
:rule="{ required: true, message: '请上传图片', trigger: 'change' }"
|
||||||
|
v-if="formData.form == 2"
|
||||||
|
>
|
||||||
|
<UploadImg
|
||||||
|
@change-file-name="(name) => (formData.coverImgName = name)"
|
||||||
|
:fileType="['image/jpeg', 'image/png', 'image/jpg', 'image/gif']"
|
||||||
|
name="article"
|
||||||
|
:fileSize="200"
|
||||||
|
v-model:image-url="formData.image"
|
||||||
|
>
|
||||||
|
<template #tip>支持扩展名: jpg png jpeg;文件大小不超过200M</template>
|
||||||
|
</UploadImg>
|
||||||
|
</n-form-item>
|
||||||
|
<n-form-item label="排序" path="sort">
|
||||||
|
<n-input-number v-model:value="formData.sort" />
|
||||||
|
</n-form-item>
|
||||||
|
<n-form-item label="状态">
|
||||||
|
<n-radio-group v-model:value="formData.status" path="status">
|
||||||
|
<n-radio :value="1">在用</n-radio>
|
||||||
|
<n-radio :value="2">停用</n-radio>
|
||||||
|
</n-radio-group>
|
||||||
|
</n-form-item>
|
||||||
|
</n-form>
|
||||||
|
</template>
|
||||||
|
</basicModal>
|
||||||
|
</template>
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { getLinkDetail, linkAdd, linkUpdate } from '@/api/content/link';
|
||||||
|
import { onMounted, reactive, ref } from 'vue';
|
||||||
|
import { useMessage } from 'naive-ui';
|
||||||
|
import { useModal } from '@/components/Modal';
|
||||||
|
import UploadImg from '@/components/Upload/Image.vue';
|
||||||
|
|
||||||
|
const emit = defineEmits(['success', 'update:visible']);
|
||||||
|
const formRef = ref();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 定义表单参数
|
||||||
|
*/
|
||||||
|
const message = useMessage();
|
||||||
|
const formData = reactive({
|
||||||
|
id: '',
|
||||||
|
name: '',
|
||||||
|
type: undefined,
|
||||||
|
url: '',
|
||||||
|
form: undefined,
|
||||||
|
image: '',
|
||||||
|
status: 1,
|
||||||
|
sort: 0,
|
||||||
|
});
|
||||||
|
const optionData = {
|
||||||
|
typeList: [
|
||||||
|
{ label: '友情链接', value: 1 },
|
||||||
|
{ label: '合作伙伴', value: 2 },
|
||||||
|
],
|
||||||
|
formList: [
|
||||||
|
{ label: '文字链接', value: 1 },
|
||||||
|
{ label: '图片链接', value: 2 },
|
||||||
|
],
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* 定义接收的参数
|
||||||
|
*/
|
||||||
|
const props = defineProps({
|
||||||
|
visible: {
|
||||||
|
type: Boolean,
|
||||||
|
required: true,
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
|
linkId: {
|
||||||
|
type: Number,
|
||||||
|
required: true,
|
||||||
|
default: 0,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
const [modalRegister, { openModal, setSubLoading }] = useModal({
|
||||||
|
title: props.linkId ? '编辑友链' : '添加友链',
|
||||||
|
subBtuText: '确定',
|
||||||
|
width: 600,
|
||||||
|
});
|
||||||
|
/**
|
||||||
|
* 执行提交
|
||||||
|
*/
|
||||||
|
const handleSubmit = async () => {
|
||||||
|
formRef.value
|
||||||
|
.validate()
|
||||||
|
.then(async () => {
|
||||||
|
props.linkId ? await linkUpdate(formData) : await linkAdd(formData);
|
||||||
|
message.success('操作成功');
|
||||||
|
setSubLoading(false);
|
||||||
|
emit('update:visible', false);
|
||||||
|
emit('success');
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
setSubLoading(false);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 关闭窗体
|
||||||
|
*/
|
||||||
|
const handleClose = () => {
|
||||||
|
emit('update:visible', false);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置表单数据
|
||||||
|
*/
|
||||||
|
const setFormData = async () => {
|
||||||
|
const data = await getLinkDetail(props.linkId);
|
||||||
|
for (const key in formData) {
|
||||||
|
if (data[key] != null && data[key] != undefined) {
|
||||||
|
//@ts-ignore
|
||||||
|
formData[key] = data[key];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 钩子函数
|
||||||
|
*/
|
||||||
|
onMounted(() => {
|
||||||
|
if (props.linkId) {
|
||||||
|
setFormData();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
//导出方法
|
||||||
|
defineExpose({
|
||||||
|
openModal,
|
||||||
|
});
|
||||||
|
</script>
|
196
src/views/content/link/index.vue
Normal file
196
src/views/content/link/index.vue
Normal file
@ -0,0 +1,196 @@
|
|||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<n-card :bordered="false" class="pt-3 mb-3 proCard">
|
||||||
|
<BasicForm @register="register" @submit="handleSubmit" @reset="handleReset">
|
||||||
|
<template #statusSlot="{ model, field }">
|
||||||
|
<n-input v-model:value="model[field]" />
|
||||||
|
</template>
|
||||||
|
</BasicForm>
|
||||||
|
</n-card>
|
||||||
|
<n-card :bordered="false" class="proCard">
|
||||||
|
<BasicTable
|
||||||
|
:columns="columns"
|
||||||
|
:request="loadDataTable"
|
||||||
|
:row-key="(row) => row.id"
|
||||||
|
ref="basicTableRef"
|
||||||
|
:actionColumn="actionColumn"
|
||||||
|
@update:checked-row-keys="onCheckedRow"
|
||||||
|
:autoScrollX="true"
|
||||||
|
>
|
||||||
|
<template #tableTitle>
|
||||||
|
<n-space>
|
||||||
|
<n-button type="primary" @click="handleAdd" v-perm="['sys:link:add']">
|
||||||
|
<template #icon>
|
||||||
|
<n-icon>
|
||||||
|
<PlusOutlined />
|
||||||
|
</n-icon>
|
||||||
|
</template>
|
||||||
|
新建
|
||||||
|
</n-button>
|
||||||
|
|
||||||
|
<n-button
|
||||||
|
type="error"
|
||||||
|
@click="handleDelete"
|
||||||
|
:disabled="!rowKeys.length"
|
||||||
|
v-perm="['sys:link:batchDelete']"
|
||||||
|
>
|
||||||
|
<template #icon>
|
||||||
|
<n-icon>
|
||||||
|
<DeleteOutlined />
|
||||||
|
</n-icon>
|
||||||
|
</template>
|
||||||
|
删除
|
||||||
|
</n-button>
|
||||||
|
</n-space>
|
||||||
|
</template>
|
||||||
|
</BasicTable>
|
||||||
|
</n-card>
|
||||||
|
<editDialog
|
||||||
|
ref="createModalRef"
|
||||||
|
:linkId="linkId"
|
||||||
|
v-if="editVisible"
|
||||||
|
v-model:visible="editVisible"
|
||||||
|
@success="reloadTable('noRefresh')"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { h, nextTick, reactive, ref, unref } from 'vue';
|
||||||
|
import { useMessage, useDialog } from 'naive-ui';
|
||||||
|
import { TableAction } from '@/components/Table';
|
||||||
|
import { BasicForm, useForm } from '@/components/Form/index';
|
||||||
|
import { getLinkList, linkDelete, linkBatchDelete } from '@/api/content/link';
|
||||||
|
import { columns } from './columns';
|
||||||
|
import { PlusOutlined, DeleteOutlined, FormOutlined } from '@vicons/antd';
|
||||||
|
import CreateModal from './CreateModal.vue';
|
||||||
|
import editDialog from './edit.vue';
|
||||||
|
import { basicModal, useModal } from '@/components/Modal';
|
||||||
|
import { schemas } from './querySchemas';
|
||||||
|
import { renderIcon } from '@/utils';
|
||||||
|
|
||||||
|
const message = useMessage();
|
||||||
|
const dialog = useDialog();
|
||||||
|
const basicTableRef = ref();
|
||||||
|
const createModalRef = ref();
|
||||||
|
const editVisible = ref(false);
|
||||||
|
const linkId = ref(0);
|
||||||
|
const rowKeys = ref([]);
|
||||||
|
const exportLoading = ref(false);
|
||||||
|
|
||||||
|
const showModal = ref(false);
|
||||||
|
const formParams = reactive({
|
||||||
|
name: '',
|
||||||
|
});
|
||||||
|
|
||||||
|
const actionColumn = reactive({
|
||||||
|
width: 400,
|
||||||
|
title: '操作',
|
||||||
|
align: 'center',
|
||||||
|
key: 'action',
|
||||||
|
fixed: 'right',
|
||||||
|
render(record) {
|
||||||
|
return h(TableAction as any, {
|
||||||
|
style: 'button',
|
||||||
|
actions: [
|
||||||
|
{
|
||||||
|
label: '编辑',
|
||||||
|
icon: renderIcon(FormOutlined),
|
||||||
|
type: 'info',
|
||||||
|
onClick: handleEdit.bind(null, record),
|
||||||
|
auth: ['sys:link:update'],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '删除',
|
||||||
|
icon: renderIcon(DeleteOutlined),
|
||||||
|
type: 'error',
|
||||||
|
onClick: handleDelete.bind(null, record),
|
||||||
|
auth: ['sys:link:delete'],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
function addTable() {
|
||||||
|
showModal.value = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
const loadDataTable = async (res) => {
|
||||||
|
rowKeys.value = [];
|
||||||
|
const result = await getLinkList({ ...formParams, ...res });
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
|
||||||
|
function onCheckedRow(keys) {
|
||||||
|
rowKeys.value = keys;
|
||||||
|
}
|
||||||
|
|
||||||
|
function reloadTable(noRefresh = '') {
|
||||||
|
basicTableRef.value.reload(noRefresh ? {} : { pageNo: 1 });
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleSubmit(values: Recordable) {
|
||||||
|
for (const key in formParams) {
|
||||||
|
formParams[key] = '';
|
||||||
|
}
|
||||||
|
for (const key in values) {
|
||||||
|
formParams[key] = values[key];
|
||||||
|
}
|
||||||
|
reloadTable();
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleReset(values: Recordable) {
|
||||||
|
for (const key in formParams) {
|
||||||
|
formParams[key] = '';
|
||||||
|
}
|
||||||
|
for (const key in values) {
|
||||||
|
formParams[key] = values[key];
|
||||||
|
}
|
||||||
|
reloadTable();
|
||||||
|
}
|
||||||
|
|
||||||
|
const [register, {}] = useForm({
|
||||||
|
gridProps: { cols: '1 s:1 m:2 l:3 xl:4 2xl:4' },
|
||||||
|
labelWidth: 80,
|
||||||
|
schemas,
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 执行添加
|
||||||
|
*/
|
||||||
|
const handleAdd = async () => {
|
||||||
|
linkId.value = 0;
|
||||||
|
editVisible.value = true;
|
||||||
|
await nextTick();
|
||||||
|
createModalRef.value.openModal();
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* 执行编辑
|
||||||
|
*/
|
||||||
|
async function handleEdit(record: Recordable) {
|
||||||
|
linkId.value = record.id;
|
||||||
|
editVisible.value = true;
|
||||||
|
await nextTick();
|
||||||
|
createModalRef.value.openModal();
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 执行删除
|
||||||
|
* @param id 参数
|
||||||
|
*/
|
||||||
|
async function handleDelete(record) {
|
||||||
|
dialog.warning({
|
||||||
|
title: '提示',
|
||||||
|
content: '确定要删除?',
|
||||||
|
positiveText: '确定',
|
||||||
|
negativeText: '取消',
|
||||||
|
onPositiveClick: async () => {
|
||||||
|
record.id ? await linkDelete(record.id) : await linkBatchDelete(rowKeys.value);
|
||||||
|
message.success('删除成功');
|
||||||
|
reloadTable();
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="less" scoped></style>
|
11
src/views/content/link/querySchemas.ts
Normal file
11
src/views/content/link/querySchemas.ts
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
import { FormSchema } from '@/components/Form/index';
|
||||||
|
export const schemas: FormSchema[] = [
|
||||||
|
{
|
||||||
|
field: 'name',
|
||||||
|
component: 'NInput',
|
||||||
|
label: '友链名称',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请输入友链名称',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
36
src/views/content/tag/columns.ts
Normal file
36
src/views/content/tag/columns.ts
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
import { h } from 'vue';
|
||||||
|
import { NTag } from 'naive-ui';
|
||||||
|
|
||||||
|
export const columns = [
|
||||||
|
{
|
||||||
|
type: 'selection',
|
||||||
|
width: 50,
|
||||||
|
fixed: 'left',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'ID',
|
||||||
|
key: 'id',
|
||||||
|
fixed: 'left',
|
||||||
|
width: 50,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '标签名称',
|
||||||
|
key: 'name',
|
||||||
|
width: 100,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '排序',
|
||||||
|
key: 'sort',
|
||||||
|
width: 100,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '创建人',
|
||||||
|
key: 'createUser',
|
||||||
|
width: 100,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '创建时间',
|
||||||
|
key: 'createTime',
|
||||||
|
width: 180,
|
||||||
|
},
|
||||||
|
];
|
124
src/views/content/tag/edit.vue
Normal file
124
src/views/content/tag/edit.vue
Normal file
@ -0,0 +1,124 @@
|
|||||||
|
<template>
|
||||||
|
<basicModal
|
||||||
|
@register="modalRegister"
|
||||||
|
ref="modalRef"
|
||||||
|
class="basicModal basicFormModal"
|
||||||
|
@on-ok="handleSubmit"
|
||||||
|
@on-close="handleClose"
|
||||||
|
>
|
||||||
|
<template #default>
|
||||||
|
<n-form
|
||||||
|
class="ls-form"
|
||||||
|
ref="formRef"
|
||||||
|
:model="formData"
|
||||||
|
label-placement="left"
|
||||||
|
label-width="85px"
|
||||||
|
>
|
||||||
|
<n-form-item
|
||||||
|
label="标签名"
|
||||||
|
path="name"
|
||||||
|
:rule="{ required: true, message: '请输入标签名称', trigger: 'blur' }"
|
||||||
|
>
|
||||||
|
<n-input v-model:value="formData.name" placeholder="请输入标签名称" clearable />
|
||||||
|
</n-form-item>
|
||||||
|
<n-form-item label="排序" path="sort">
|
||||||
|
<n-input-number v-model:value="formData.sort" />
|
||||||
|
</n-form-item>
|
||||||
|
<n-form-item label="备注" path="note">
|
||||||
|
<n-input type="textarea" v-model:value="formData.note" placeholder="请输入标签备注" />
|
||||||
|
</n-form-item>
|
||||||
|
</n-form>
|
||||||
|
</template>
|
||||||
|
</basicModal>
|
||||||
|
</template>
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { getTagDetail, tagAdd, tagUpdate } from '@/api/content/tag';
|
||||||
|
import { onMounted, reactive, ref } from 'vue';
|
||||||
|
import { useMessage } from 'naive-ui';
|
||||||
|
import { useModal } from '@/components/Modal';
|
||||||
|
|
||||||
|
const emit = defineEmits(['success', 'update:visible']);
|
||||||
|
const formRef = ref();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 定义表单参数
|
||||||
|
*/
|
||||||
|
const message = useMessage();
|
||||||
|
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 [modalRegister, { openModal, setSubLoading }] = useModal({
|
||||||
|
title: props.tagId ? '编辑标签' : '添加标签',
|
||||||
|
subBtuText: '确定',
|
||||||
|
width: 600,
|
||||||
|
});
|
||||||
|
/**
|
||||||
|
* 执行提交
|
||||||
|
*/
|
||||||
|
const handleSubmit = async () => {
|
||||||
|
formRef.value
|
||||||
|
.validate()
|
||||||
|
.then(async () => {
|
||||||
|
props.tagId ? await tagUpdate(formData) : await tagAdd(formData);
|
||||||
|
message.success('操作成功');
|
||||||
|
setSubLoading(false);
|
||||||
|
emit('update:visible', false);
|
||||||
|
emit('success');
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
setSubLoading(false);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 关闭窗体
|
||||||
|
*/
|
||||||
|
const handleClose = () => {
|
||||||
|
emit('update:visible', false);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置表单数据
|
||||||
|
*/
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
//导出方法
|
||||||
|
defineExpose({
|
||||||
|
openModal,
|
||||||
|
});
|
||||||
|
</script>
|
196
src/views/content/tag/index.vue
Normal file
196
src/views/content/tag/index.vue
Normal file
@ -0,0 +1,196 @@
|
|||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<n-card :bordered="false" class="pt-3 mb-3 proCard">
|
||||||
|
<BasicForm @register="register" @submit="handleSubmit" @reset="handleReset">
|
||||||
|
<template #statusSlot="{ model, field }">
|
||||||
|
<n-input v-model:value="model[field]" />
|
||||||
|
</template>
|
||||||
|
</BasicForm>
|
||||||
|
</n-card>
|
||||||
|
<n-card :bordered="false" class="proCard">
|
||||||
|
<BasicTable
|
||||||
|
:columns="columns"
|
||||||
|
:request="loadDataTable"
|
||||||
|
:row-key="(row) => row.id"
|
||||||
|
ref="basicTableRef"
|
||||||
|
:actionColumn="actionColumn"
|
||||||
|
@update:checked-row-keys="onCheckedRow"
|
||||||
|
:autoScrollX="true"
|
||||||
|
>
|
||||||
|
<template #tableTitle>
|
||||||
|
<n-space>
|
||||||
|
<n-button type="primary" @click="handleAdd" v-perm="['sys:tag:add']">
|
||||||
|
<template #icon>
|
||||||
|
<n-icon>
|
||||||
|
<PlusOutlined />
|
||||||
|
</n-icon>
|
||||||
|
</template>
|
||||||
|
新建
|
||||||
|
</n-button>
|
||||||
|
|
||||||
|
<n-button
|
||||||
|
type="error"
|
||||||
|
@click="handleDelete"
|
||||||
|
:disabled="!rowKeys.length"
|
||||||
|
v-perm="['sys:tag:batchDelete']"
|
||||||
|
>
|
||||||
|
<template #icon>
|
||||||
|
<n-icon>
|
||||||
|
<DeleteOutlined />
|
||||||
|
</n-icon>
|
||||||
|
</template>
|
||||||
|
删除
|
||||||
|
</n-button>
|
||||||
|
</n-space>
|
||||||
|
</template>
|
||||||
|
</BasicTable>
|
||||||
|
</n-card>
|
||||||
|
<editDialog
|
||||||
|
ref="createModalRef"
|
||||||
|
:tagId="tagId"
|
||||||
|
v-if="editVisible"
|
||||||
|
v-model:visible="editVisible"
|
||||||
|
@success="reloadTable('noRefresh')"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { h, nextTick, reactive, ref, unref } from 'vue';
|
||||||
|
import { useMessage, useDialog } from 'naive-ui';
|
||||||
|
import { TableAction } from '@/components/Table';
|
||||||
|
import { BasicForm, useForm } from '@/components/Form/index';
|
||||||
|
import { getTagList, tagDelete, tagBatchDelete } from '@/api/content/tag';
|
||||||
|
import { columns } from './columns';
|
||||||
|
import { PlusOutlined, DeleteOutlined, FormOutlined } from '@vicons/antd';
|
||||||
|
import CreateModal from './CreateModal.vue';
|
||||||
|
import editDialog from './edit.vue';
|
||||||
|
import { basicModal, useModal } from '@/components/Modal';
|
||||||
|
import { schemas } from './querySchemas';
|
||||||
|
import { renderIcon } from '@/utils';
|
||||||
|
|
||||||
|
const message = useMessage();
|
||||||
|
const dialog = useDialog();
|
||||||
|
const basicTableRef = ref();
|
||||||
|
const createModalRef = ref();
|
||||||
|
const editVisible = ref(false);
|
||||||
|
const tagId = ref(0);
|
||||||
|
const rowKeys = ref([]);
|
||||||
|
const exportLoading = ref(false);
|
||||||
|
|
||||||
|
const showModal = ref(false);
|
||||||
|
const formParams = reactive({
|
||||||
|
name: '',
|
||||||
|
});
|
||||||
|
|
||||||
|
const actionColumn = reactive({
|
||||||
|
width: 200,
|
||||||
|
title: '操作',
|
||||||
|
align: 'center',
|
||||||
|
key: 'action',
|
||||||
|
fixed: 'right',
|
||||||
|
render(record) {
|
||||||
|
return h(TableAction as any, {
|
||||||
|
style: 'button',
|
||||||
|
actions: [
|
||||||
|
{
|
||||||
|
label: '编辑',
|
||||||
|
icon: renderIcon(FormOutlined),
|
||||||
|
type: 'info',
|
||||||
|
onClick: handleEdit.bind(null, record),
|
||||||
|
auth: ['sys:tag:update'],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '删除',
|
||||||
|
icon: renderIcon(DeleteOutlined),
|
||||||
|
type: 'error',
|
||||||
|
onClick: handleDelete.bind(null, record),
|
||||||
|
auth: ['sys:tag:delete'],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
function addTable() {
|
||||||
|
showModal.value = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
const loadDataTable = async (res) => {
|
||||||
|
rowKeys.value = [];
|
||||||
|
const result = await getTagList({ ...formParams, ...res });
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
|
||||||
|
function onCheckedRow(keys) {
|
||||||
|
rowKeys.value = keys;
|
||||||
|
}
|
||||||
|
|
||||||
|
function reloadTable(noRefresh = '') {
|
||||||
|
basicTableRef.value.reload(noRefresh ? {} : { pageNo: 1 });
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleSubmit(values: Recordable) {
|
||||||
|
for (const key in formParams) {
|
||||||
|
formParams[key] = '';
|
||||||
|
}
|
||||||
|
for (const key in values) {
|
||||||
|
formParams[key] = values[key];
|
||||||
|
}
|
||||||
|
reloadTable();
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleReset(values: Recordable) {
|
||||||
|
for (const key in formParams) {
|
||||||
|
formParams[key] = '';
|
||||||
|
}
|
||||||
|
for (const key in values) {
|
||||||
|
formParams[key] = values[key];
|
||||||
|
}
|
||||||
|
reloadTable();
|
||||||
|
}
|
||||||
|
|
||||||
|
const [register, {}] = useForm({
|
||||||
|
gridProps: { cols: '1 s:1 m:2 l:3 xl:4 2xl:4' },
|
||||||
|
labelWidth: 80,
|
||||||
|
schemas,
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 执行添加
|
||||||
|
*/
|
||||||
|
const handleAdd = async () => {
|
||||||
|
tagId.value = 0;
|
||||||
|
editVisible.value = true;
|
||||||
|
await nextTick();
|
||||||
|
createModalRef.value.openModal();
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* 执行编辑
|
||||||
|
*/
|
||||||
|
async function handleEdit(record: Recordable) {
|
||||||
|
tagId.value = record.id;
|
||||||
|
editVisible.value = true;
|
||||||
|
await nextTick();
|
||||||
|
createModalRef.value.openModal();
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 执行删除
|
||||||
|
* @param id 参数
|
||||||
|
*/
|
||||||
|
async function handleDelete(record) {
|
||||||
|
dialog.warning({
|
||||||
|
title: '提示',
|
||||||
|
content: '确定要删除?',
|
||||||
|
positiveText: '确定',
|
||||||
|
negativeText: '取消',
|
||||||
|
onPositiveClick: async () => {
|
||||||
|
record.id ? await tagDelete(record.id) : await tagBatchDelete(rowKeys.value);
|
||||||
|
message.success('删除成功');
|
||||||
|
reloadTable();
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="less" 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: 'NInput',
|
||||||
|
label: '标签名称',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请输入标签名称',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
Loading…
Reference in New Issue
Block a user