布局、布局推荐

This commit is contained in:
陈红丽 2024-12-02 10:37:21 +08:00
parent df27fda054
commit 50f0b12127
14 changed files with 1288 additions and 2 deletions

View File

@ -5,7 +5,7 @@ import { ACCESS_TOKEN, CURRENT_USER, IS_LOCKSCREEN } from '@/store/mutation-type
import { ResultEnum } from '@/enums/httpEnum'; import { ResultEnum } from '@/enums/httpEnum';
const Storage = createStorage({ storage: localStorage }); const Storage = createStorage({ storage: localStorage });
import { getUserInfo, login } from '@/api/system/user'; import { getUserInfo, login, login2 } from '@/api/system/user';
import { storage } from '@/utils/Storage'; import { storage } from '@/utils/Storage';
export interface IUserState { export interface IUserState {
@ -61,6 +61,7 @@ export const useUserStore = defineStore({
async login(userInfo) { async login(userInfo) {
try { try {
const response = await login(userInfo); const response = await login(userInfo);
// const response = await login2(userInfo);
const { code, data } = response; const { code, data } = response;
if (code === ResultEnum.SUCCESS) { if (code === ResultEnum.SUCCESS) {
const ex = 7 * 24 * 60 * 60 * 1000; const ex = 7 * 24 * 60 * 60 * 1000;

View File

@ -0,0 +1,41 @@
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: 'location',
width: 100,
},
{
title: '位置描述',
key: 'description',
width: 200,
},
{
title: '排序',
key: 'sort',
width: 100,
},
{
title: '创建人',
key: 'createUser',
width: 100,
},
{
title: '创建时间',
key: 'createTime',
width: 180,
},
];

View File

@ -0,0 +1,125 @@
<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="location"
:rule="{ required: true, message: '请输入位置编号', trigger: 'blur' }"
>
<number-input v-model="formData.location" placeholder="请输入位置编号" clearable />
</n-form-item>
<n-form-item label="描述" path="description">
<n-input type="textarea" v-model:value="formData.description" placeholder="请输入描述" />
</n-form-item>
<n-form-item label="排序" path="sort">
<n-input-number v-model:value="formData.sort" />
</n-form-item>
</n-form>
</template>
</basicModal>
</template>
<script lang="ts" setup>
import { getLayoutDetail, layoutAdd, layoutUpdate } from '@/api/content/layout';
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: '',
description: '',
location: '',
sort: 0,
});
/**
* 定义接收的参数
*/
const props = defineProps({
visible: {
type: Boolean,
required: true,
default: false,
},
layoutId: {
type: Number,
required: true,
default: 0,
},
});
const [modalRegister, { openModal, setSubLoading }] = useModal({
title: props.layoutId ? '编辑布局' : '添加布局',
subBtuText: '确定',
width: 600,
});
/**
* 执行提交
*/
const handleSubmit = async () => {
formRef.value
.validate()
.then(async () => {
props.layoutId ? await layoutUpdate(formData) : await layoutAdd(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 getLayoutDetail(props.layoutId);
for (const key in formData) {
if (data[key] != null && data[key] != undefined) {
//@ts-ignore
formData[key] = data[key];
}
}
formData.location = formData.location + '';
};
/**
* 钩子函数
*/
onMounted(() => {
if (props.layoutId) {
setFormData();
}
});
//
defineExpose({
openModal,
});
</script>

View 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:layout:add']">
<template #icon>
<n-icon>
<PlusOutlined />
</n-icon>
</template>
新建
</n-button>
<n-button
type="error"
@click="handleDelete"
:disabled="!rowKeys.length"
v-perm="['sys:layout:batchDelete']"
>
<template #icon>
<n-icon>
<DeleteOutlined />
</n-icon>
</template>
删除
</n-button>
</n-space>
</template>
</BasicTable>
</n-card>
<editDialog
ref="createModalRef"
:layoutId="layoutId"
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 { getLayoutList, layoutDelete, layoutBatchDelete } from '@/api/content/layout';
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 layoutId = ref(0);
const rowKeys = ref([]);
const exportLoading = ref(false);
const showModal = ref(false);
const formParams = reactive({
description: '',
});
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:layout:update'],
},
{
label: '删除',
icon: renderIcon(DeleteOutlined),
type: 'error',
onClick: handleDelete.bind(null, record),
auth: ['sys:layout:delete'],
},
],
});
},
});
function addTable() {
showModal.value = true;
}
const loadDataTable = async (res) => {
rowKeys.value = [];
const result = await getLayoutList({ ...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 () => {
layoutId.value = 0;
editVisible.value = true;
await nextTick();
createModalRef.value.openModal();
};
/**
* 执行编辑
*/
async function handleEdit(record: Recordable) {
layoutId.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 layoutDelete(record.id) : await layoutBatchDelete(rowKeys.value);
message.success('删除成功');
reloadTable();
},
});
}
</script>
<style lang="less" scoped></style>

View File

@ -0,0 +1,11 @@
import { FormSchema } from '@/components/Form/index';
export const schemas: FormSchema[] = [
{
field: 'description',
component: 'NInput',
label: '页面描述',
componentProps: {
placeholder: '请输入页面位置描述',
},
},
];

View File

@ -0,0 +1,54 @@
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: 'description',
width: 250,
render(record) {
return record.layoutDescription + '>>' + record.layoutLocation;
},
},
{
title: '推荐类型',
key: 'typeText',
width: 100,
},
{
title: '推荐ID',
key: 'typeId',
width: 100,
},
{
title: '推荐标题',
key: 'typeTitle',
width: 200,
},
{
title: '排序',
key: 'sort',
width: 100,
},
{
title: '创建人',
key: 'createUser',
width: 100,
},
{
title: '创建时间',
key: 'createTime',
width: 180,
},
];

View File

@ -0,0 +1,225 @@
<template>
<n-drawer v-model:show="props.visible" @after-leave="handleClose" :width="800">
<n-drawer-content :title="props.layoutId ? '编辑' : '新增'">
<template #default>
<n-form
class="ls-form"
ref="formRef"
:model="formData"
label-placement="left"
label-width="85px"
>
<n-form-item
label="页面布局"
path="layoutId"
class="flex-1"
:rule="{ type: 'number', required: true, message: '请选择页面布局', trigger: 'change' }"
>
<n-select
v-model:value="formData.layoutId"
class="flex-1"
clearable
placeholder="请选择页面布局"
:options="layoutList"
label-field="description"
value-field="id"
/>
</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="请选择页面类型"
@update:value="handleType"
:options="typeList"
/>
</n-form-item>
<n-form-item
label="推荐文章"
path="typeId"
:rule="{
key: 'typeId',
type: 'number',
required: true,
message: '请选择推荐文章',
trigger: 'blur',
}"
>
<n-input
v-model:value="formData.typeText"
placeholder="请选择推荐文章"
@click="getLayoutItem"
/>
</n-form-item>
<n-form-item label="图片路径" path="image">
<UploadImg
: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>
</template>
<template #footer>
<span class="dialog-footer">
<n-button @click="handleClose">取消</n-button>
<n-button :loading="subLoading" type="primary" @click="submit"> 确定 </n-button>
</span>
</template>
</n-drawer-content>
<chooseArticle
v-if="chooseVisible"
v-model:visible="chooseVisible"
:type="formData.type"
ref="articleRef"
@success="selectedCallback"
/>
</n-drawer>
</template>
<script lang="ts" setup>
import { getLayoutDetail, layoutAdd, layoutUpdate } from '@/api/content/layoutItem';
import { getLayoutAllList } from '@/api/content/layout';
import { onMounted, reactive, ref, nextTick } from 'vue';
import { useMessage } from 'naive-ui';
import UploadImg from '@/components/Upload/Image.vue';
import chooseArticle from './layout/index.vue';
import { useLockFn } from '@/utils/useLockFn';
const emit = defineEmits(['success', 'update:visible']);
const formRef = ref();
const articleRef = ref();
/**
* 定义表单参数
*/
const message = useMessage();
const chooseVisible = ref(false);
const layoutList = ref([]);
const formData = reactive({
id: '',
layoutId: undefined,
type: undefined,
typeText: '',
typeId: '',
image: '',
sort: 0,
});
/**
* 定义接收的参数
*/
const props = defineProps({
visible: {
type: Boolean,
required: true,
default: false,
},
layoutId: {
type: Number,
required: true,
default: 0,
},
});
const typeList = [
{ label: 'CMS文章', value: 1 },
{ label: '通知公告', value: 2 },
];
/**
* 获取推荐类型
*/
const getLayoutItem = async () => {
if (!formData.type) {
message.warning('请选择页面类型');
return;
}
chooseVisible.value = true;
await nextTick();
articleRef.value.openModal();
};
/**
* 执行选择类型
*/
const handleType = () => {
formData.typeId = '';
formData.typeText = '';
};
/**
* 执行提交
*/
const handleSubmit = async () => {
formRef.value
.validate()
.then(async () => {
props.layoutId ? await layoutUpdate(formData) : await layoutAdd(formData);
message.success('操作成功');
emit('update:visible', false);
emit('success');
})
.catch((error) => {});
};
const { isLock: subLoading, lockFn: submit } = useLockFn(handleSubmit);
/**
* 关闭窗体
*/
const handleClose = () => {
emit('update:visible', false);
};
/**
* 设置表单数据
*/
const setFormData = async () => {
const data = await getLayoutDetail(props.layoutId);
for (const key in formData) {
if (data[key] != null && data[key] != undefined) {
//@ts-ignore
formData[key] = data[key];
}
}
};
/**
* 选择推荐内容成功回调事件
*/
const selectedCallback = (row) => {
console.log(row);
formData.typeText = row.title;
formData.typeId = row.id;
formRef.value?.validate(
(errors) => {},
(rule) => {
return rule?.key === 'typeId';
},
);
return;
};
/**
* 获取全部字典数据
*/
const getAllDict = async () => {
let list = await getLayoutAllList();
layoutList.value = list ? list : [];
};
/**
* 钩子函数
*/
onMounted(() => {
getAllDict();
if (props.layoutId) {
setFormData();
}
});
</script>

View File

@ -0,0 +1,195 @@
<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:layoutItem:add']">
<template #icon>
<n-icon>
<PlusOutlined />
</n-icon>
</template>
新建
</n-button>
<n-button
type="error"
@click="handleDelete"
:disabled="!rowKeys.length"
v-perm="['sys:layoutItem:batchDelete']"
>
<template #icon>
<n-icon>
<DeleteOutlined />
</n-icon>
</template>
删除
</n-button>
</n-space>
</template>
</BasicTable>
</n-card>
<editDialog
ref="createModalRef"
:layoutId="layoutId"
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 { getLayoutList, layoutDelete, layoutBatchDelete } from '@/api/content/layoutItem';
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 layoutId = ref(0);
const rowKeys = ref([]);
const exportLoading = ref(false);
const showModal = ref(false);
const formParams = reactive({
name: '',
status: '',
});
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:layoutItem:update'],
},
{
label: '删除',
icon: renderIcon(DeleteOutlined),
type: 'error',
onClick: handleDelete.bind(null, record),
auth: ['sys:layoutItem:delete'],
},
],
});
},
});
function addTable() {
showModal.value = true;
}
const loadDataTable = async (res) => {
rowKeys.value = [];
const result = await getLayoutList({ ...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 () => {
layoutId.value = 0;
await nextTick();
editVisible.value = true;
};
/**
* 执行编辑
*/
async function handleEdit(record: Recordable) {
layoutId.value = record.id;
await nextTick();
editVisible.value = true;
}
/**
* 执行删除
* @param id 参数
*/
async function handleDelete(record) {
dialog.warning({
title: '提示',
content: '确定要删除?',
positiveText: '确定',
negativeText: '取消',
onPositiveClick: async () => {
record.id ? await layoutDelete(record.id) : await layoutBatchDelete(rowKeys.value);
message.success('删除成功');
reloadTable();
},
});
}
</script>
<style lang="less" scoped></style>

View File

@ -0,0 +1,54 @@
import { h } from 'vue';
export const columns = [
{
type: 'selection',
width: 50,
fixed: 'left',
multiple: false,
},
{
title: 'ID',
key: 'id',
width: 60,
fixed: 'left',
},
{
title: '文章标题',
key: 'title',
ren(record) {
return h(
'a',
{
href: 'http://www.baidu.com',
target: '_blank',
},
record.title,
);
},
width: 300,
},
{
title: '文章分类',
key: 'categoryName',
width: 100,
},
{
title: '文章状态',
key: 'status',
render(record) {
return h('span', record.status === 1 ? '下架' : '正常');
},
width: 100,
},
{
title: '创建人',
key: 'createUser',
width: 100,
},
{
title: '创建时间',
key: 'createTime',
width: 180,
},
];

View File

@ -0,0 +1,30 @@
import { FormSchema } from '@/components/Form/index';
export const schemas: FormSchema[] = [
{
field: 'title',
component: 'NInput',
label: '文章标题',
componentProps: {
placeholder: '请输入文章标题',
},
},
{
field: 'status',
component: 'NSelect',
label: '文章状态',
componentProps: {
placeholder: '请选择文章状态',
clearable: true,
options: [
{
label: '下架',
value: '1',
},
{
label: '正常',
value: '0',
},
],
},
},
];

View File

@ -0,0 +1,191 @@
<template>
<basicModal
@register="modalRegister"
ref="modalRef"
class="basicModal basicFormModal"
@on-ok="handleSubmits"
@on-close="handleClose"
>
<template #default>
<BasicForm @register="register" @submit="handleSubmit" @reset="handleReset">
<template #statusSlot="{ model, field }">
<n-input v-model:value="model[field]" />
</template>
</BasicForm>
<BasicTable
:columns="columnsType()"
:request="loadDataTable"
ref="tableRef"
:autoScrollX="true"
:row-key="(row) => row.id"
@update:checked-row-keys="rowClick"
:row-props="rowProps"
v-model:checked-row-keys="checkedKeys"
:showTableSetting="false"
/>
</template>
</basicModal>
</template>
<script lang="ts" setup>
import { getArticleList } from '@/api/content/article';
import { BasicForm, useForm } from '@/components/Form/index';
import { getNoticeList } from '@/api/data/notice';
import { onMounted, reactive, ref } from 'vue';
import { useModal } from '@/components/Modal';
import { useMessage } from 'naive-ui';
import { columns } from './article/columns';
import { schemas } from './article/querySchemas';
import { columns2 } from './notice/columns';
import { schemas2 } from './notice/querySchemas';
const emit = defineEmits(['success', 'update:visible', 'update:checked-row-keys']);
const message = useMessage();
/**
* 定义接收的参数
*/
const props = defineProps({
visible: {
type: Boolean,
required: true,
default: false,
},
type: {
type: Number,
required: true,
default: 1,
},
});
const selectRow = ref({});
const tableRef = ref();
const checkedKeys = ref([]);
const [modalRegister, { openModal, setSubLoading }] = useModal({
title: '选择文章',
width: 1000,
});
/**
* 定义查询参数
*/
const formParams = reactive({
title: '',
status: '',
});
/**
* 定义列类型
*/
const columnsType = () => {
if (props.type == 1) {
//
return columns;
} else if (props.type == 2) {
//
return columns2;
}
};
/**
* 执行提交表单
*/
const handleSubmits = async () => {
if (!selectRow.value.id) {
setSubLoading(false);
return message.error('请选择文章');
}
setSubLoading(false);
emit('update:visible', false);
emit('success', selectRow.value);
};
/**
* 关闭窗体
*/
const handleClose = () => {
emit('update:visible', false);
};
/**
* 加载数据列表
* @param res 参数
*/
const loadDataTable = async (res: any) => {
let result = [];
if (props.type == 1) {
result = await getArticleList({ ...formParams, ...res });
} else {
result = await getNoticeList({ ...formParams, ...res });
}
return result;
};
/**
* 刷新数据列表
* @param noRefresh 参数
*/
function reloadTable(noRefresh = '') {
tableRef.value.reload(noRefresh ? {} : { pageNo: 1 });
}
/**
* 注册
*/
const [register, {}] = useForm({
gridProps: { cols: '1 s:1 m:2 l:3 xl:4 2xl:4' },
labelWidth: 80,
schemas: props.type == 1 ? schemas : schemas2,
});
/**
* 执行提交表单
* @param values 参数
*/
function handleSubmit(values) {
for (const key in formParams) {
formParams[key] = '';
}
for (const key in values) {
formParams[key] = values[key];
}
reloadTable();
}
/**
* 执行重置
*/
function handleReset() {
for (const key in formParams) {
formParams[key] = '';
}
reloadTable();
}
/**
* 数据行点击事件
* @param record 参数
*/
const rowProps = (row) => {
console.log(row);
return {
style: 'cursor: pointer;',
onClick: () => {
checkedKeys.value = [row.id];
selectRow.value = row;
},
};
};
const rowClick = (record, row) => {
console.log(record);
checkedKeys.value = record;
selectRow.value = row[0];
};
/**
* 钩子函数
*/
onMounted(() => {});
//
defineExpose({
openModal,
});
</script>

View File

@ -0,0 +1,69 @@
import { h } from 'vue';
import { NTag } from 'naive-ui';
export const columns2 = [
{
type: 'selection',
width: 50,
fixed: 'left',
multiple: false,
},
{
title: 'ID',
key: 'id',
width: 60,
fixed: 'left',
},
{
title: '标题',
key: 'title',
width: 200,
},
{
title: '类型',
key: 'type',
width: 100,
render(record) {
return h(
NTag,
{
type: record.type == 1 ? 'info' : 'success',
},
{
default: () => (record.type == 1 ? '通知' : '公告'),
},
);
},
},
{
title: '状态',
key: 'status',
render(record) {
return h(
NTag,
{
type: record.status == 1 ? 'success' : 'error',
},
{
default: () => (record.status == 1 ? '正常' : '禁用'),
},
);
},
width: 100,
},
{
title: '点击率',
key: 'clickNum',
width: 100,
},
{
title: '创建人',
key: 'createUser',
width: 100,
},
{
title: '创建时间',
key: 'createTime',
width: 180,
},
];

View File

@ -0,0 +1,49 @@
import { FormSchema } from '@/components/Form/index';
export const schemas2: FormSchema[] = [
{
field: 'title',
component: 'NInput',
label: '标题',
componentProps: {
placeholder: '请输入标题',
},
},
{
field: 'type',
component: 'NSelect',
label: '类型',
componentProps: {
placeholder: '请选择类型',
clearable: true,
options: [
{
label: '通知',
value: '1',
},
{
label: '公告',
value: '2',
},
],
},
},
{
field: 'status',
component: 'NSelect',
label: '状态',
componentProps: {
placeholder: '请选择状态',
clearable: true,
options: [
{
label: '正常',
value: '1',
},
{
label: '关闭',
value: '2',
},
],
},
},
];

View File

@ -0,0 +1,45 @@
import { FormSchema } from '@/components/Form/index';
import { getLayoutAllList } from '@/api/content/layout';
export const loadSelectData = async (res) => {
//这里可以进行数据转换处理
return (await getLayoutAllList({ ...res })).map((item, index) => {
return {
...item,
label: item.description,
value: item.id,
index,
};
});
};
export const schemas: FormSchema[] = [
{
field: 'layoutId',
component: 'BasicSelect',
label: '页面布局',
componentProps: {
placeholder: '请选择页面布局',
clearable: true,
block: true,
request: loadSelectData,
},
},
{
field: 'type',
component: 'NSelect',
label: '页面类型',
componentProps: {
placeholder: '请选择页面类型',
clearable: true,
options: [
{
label: 'CMS文章',
value: '1',
},
{
label: '通知公告',
value: '2',
},
],
},
},
];