优化文章、分类、标签

This commit is contained in:
zjl 2024-12-12 11:24:04 +08:00
parent bed4eb179d
commit a905f4fab5
7 changed files with 111 additions and 28 deletions

View File

@ -16,7 +16,7 @@ export const columns = [
{
title: '文章标题',
key: 'title',
width: 200,
width: 250,
render(record) {
return h(
'a',

View File

@ -121,6 +121,9 @@
import Editor from '@/components/Editor/tinymce.vue';
import { buildTree } from '@/utils/auth';
/**
* 定义常量
*/
const emit = defineEmits(['success', 'update:visible']);
const formRef = ref();
const editorRef = ref();
@ -133,17 +136,18 @@
const message = useMessage();
const formData = reactive({
id: '',
categoryId: undefined,
categoryId: '',
title: '',
author: '',
cover: '',
images: '',
intro: '',
content: '',
status: 0,
click: '',
sort: 0,
images: '',
imagesList: [],
fileList: [],
});
/**
@ -161,6 +165,10 @@
default: 0,
},
});
/**
* 定义模态
*/
const [modalRegister, { openModal, setSubLoading }] = useModal({
title: props.articleId ? '编辑文章' : '添加文章',
subBtuText: '确定',
@ -182,6 +190,7 @@
);
return;
};
/**
* 执行提交
*/
@ -251,7 +260,10 @@
setFormData();
}
});
//
/**
* 定义函数
*/
defineExpose({
openModal,
});

View File

@ -27,7 +27,6 @@
</template>
新建
</n-button>
<n-button
type="error"
@click="handleDelete"
@ -63,12 +62,13 @@
import { getArticleList, articleDelete, articleBatchDelete } from '@/api/content/article';
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();
@ -76,14 +76,19 @@
const editVisible = ref(false);
const articleId = ref(0);
const rowKeys = ref([]);
const exportLoading = ref(false);
const showModal = ref(false);
/**
* 定义查询参数
*/
const formParams = reactive({
title: '',
status: '',
});
/**
* 定义操作栏
*/
const actionColumn = reactive({
width: 200,
title: '操作',
@ -113,24 +118,36 @@
},
});
function addTable() {
showModal.value = true;
}
/**
* 加载数据列表
* @param res 参数
*/
const loadDataTable = async (res) => {
rowKeys.value = [];
const result = await getArticleList({ ...formParams, ...res });
return result;
};
/**
* 数据行选中事件
* @param keys 参数
*/
function onCheckedRow(keys) {
rowKeys.value = keys;
}
/**
* 刷新数据列表
* @param noRefresh 参数
*/
function reloadTable(noRefresh = '') {
basicTableRef.value.reload(noRefresh ? {} : { pageNo: 1 });
}
/**
* 执行提交表单
* @param values 参数
*/
function handleSubmit(values: Recordable) {
for (const key in formParams) {
formParams[key] = '';
@ -141,6 +158,9 @@
reloadTable();
}
/**
* 执行重置
*/
function handleReset(values: Recordable) {
for (const key in formParams) {
formParams[key] = '';
@ -151,6 +171,9 @@
reloadTable();
}
/**
* 执行注册
*/
const [register, {}] = useForm({
gridProps: { cols: '1 s:1 m:2 l:3 xl:4 2xl:4' },
labelWidth: 80,
@ -166,6 +189,7 @@
await nextTick();
createModalRef.value.openModal();
};
/**
* 执行编辑
*/
@ -175,6 +199,7 @@
await nextTick();
createModalRef.value.openModal();
}
/**
* 执行删除
* @param id 参数

View File

@ -103,13 +103,19 @@
name: '',
//
sort: 0,
//
note: '',
});
/**
* 定义模态
*/
const [modalRegister, { openModal, setSubLoading }] = useModal({
title: props.categoryId ? '编辑分类' : '添加分类',
subBtuText: '确定',
width: 600,
});
/**
* 关闭窗体
*/
@ -122,7 +128,7 @@
/**
* 获取分类数据
*/
const getcategory = async () => {
const getCategory = async () => {
const data: any = await getCategoryList();
data.map((item) => {
expandedKeys.value.push(item.id);
@ -171,14 +177,17 @@
* 钩子函数
*/
onMounted(() => {
getcategory();
getCategory();
if (props.categoryId) {
getDetail();
} else {
formData.parentId = props.pid;
}
});
//
/**
* 定义函数
*/
defineExpose({
openModal,
});

View File

@ -64,8 +64,11 @@
const categoryId = ref(0);
const pid = ref(0);
/**
* 定义操作栏
*/
const actionColumn = reactive({
width: 220,
width: 250,
title: '操作',
align: 'center',
key: 'action',
@ -101,7 +104,7 @@
});
/**
* 获取部门列表
* 获取分类列表
*/
const loadDataTable = async (res) => {
const data = await getCategoryList();

View File

@ -66,11 +66,16 @@
default: 0,
},
});
/**
* 定义模态
*/
const [modalRegister, { openModal, setSubLoading }] = useModal({
title: props.tagId ? '编辑标签' : '添加标签',
subBtuText: '确定',
width: 600,
});
/**
* 执行提交
*/
@ -117,7 +122,10 @@
setFormData();
}
});
//
/**
* 定义函数
*/
defineExpose({
openModal,
});

View File

@ -27,7 +27,6 @@
</template>
新建
</n-button>
<n-button
type="error"
@click="handleDelete"
@ -63,12 +62,13 @@
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();
@ -76,13 +76,18 @@
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: '操作',
@ -112,24 +117,36 @@
},
});
function addTable() {
showModal.value = true;
}
/**
* 加载数据列表
* @param res 参数
*/
const loadDataTable = async (res) => {
rowKeys.value = [];
const result = await getTagList({ ...formParams, ...res });
return result;
};
/**
* 数据行选中事件
* @param keys 参数
*/
function onCheckedRow(keys) {
rowKeys.value = keys;
}
/**
* 刷新数据列表
* @param noRefresh 参数
*/
function reloadTable(noRefresh = '') {
basicTableRef.value.reload(noRefresh ? {} : { pageNo: 1 });
}
/**
* 执行提交表单
* @param values 参数
*/
function handleSubmit(values: Recordable) {
for (const key in formParams) {
formParams[key] = '';
@ -140,6 +157,10 @@
reloadTable();
}
/**
* 执行重置
* @param values 参数
*/
function handleReset(values: Recordable) {
for (const key in formParams) {
formParams[key] = '';
@ -150,6 +171,9 @@
reloadTable();
}
/**
* 执行注册
*/
const [register, {}] = useForm({
gridProps: { cols: '1 s:1 m:2 l:3 xl:4 2xl:4' },
labelWidth: 80,
@ -165,6 +189,7 @@
await nextTick();
createModalRef.value.openModal();
};
/**
* 执行编辑
*/
@ -174,6 +199,7 @@
await nextTick();
createModalRef.value.openModal();
}
/**
* 执行删除
* @param id 参数