改造文章管理系统

This commit is contained in:
2024-08-27 07:22:22 +08:00
parent 13832d9de0
commit 31ec8e057a
41 changed files with 4041 additions and 525 deletions

View File

@@ -87,7 +87,7 @@
/>
</template>
</a-form-item>
<a-form-item label="所在页面">
<a-form-item label="展示页面">
<SelectDesign
:placeholder="`请选择页面`"
v-model:value="form.pageName"

View File

@@ -0,0 +1,579 @@
<!-- 编辑弹窗 -->
<template>
<ele-modal
:width="900"
:visible="visible"
:maskClosable="false"
:maxable="maxable"
:title="isUpdate ? '编辑文章' : '添加文章'"
:body-style="{ paddingBottom: '28px' }"
@update:visible="updateVisible"
@ok="save"
>
<a-form
ref="formRef"
:model="form"
:rules="rules"
:label-col="styleResponsive ? { md: 3, sm: 5, xs: 24 } : { flex: '90px' }"
:wrapper-col="
styleResponsive ? { md: 24, sm: 24, xs: 24 } : { flex: '1' }
"
>
<a-tabs type="card" v-model:active-key="active" @change="onChange">
<a-tab-pane tab="基本信息" key="base">
<a-form-item label="选择栏目" name="categoryId">
<SelectNavigsation
:data="data"
placeholder="请选择栏目"
style="width: 558px"
v-model:value="form.categoryName"
@done="chooseCategory"
/>
</a-form-item>
<a-form-item label="文章标题" name="title">
<a-input
allow-clear
style="width: 558px"
placeholder="文章标题"
v-model:value="form.title"
/>
</a-form-item>
<!-- <a-form-item label="单位名称" name="unitName">-->
<!-- <a-input-->
<!-- allow-clear-->
<!-- style="width: 558px"-->
<!-- placeholder="单位名称,如(个)"-->
<!-- v-model:value="form.unitName"-->
<!-- />-->
<!-- </a-form-item>-->
<!-- <a-form-item label="文章价格" name="price">-->
<!-- <a-input-number-->
<!-- :placeholder="`文章价格`"-->
<!-- style="width: 240px"-->
<!-- v-model:value="form.price"-->
<!-- />-->
<!-- <div class="ele-text-placeholder">文章的实际购买金额最低0.01</div>-->
<!-- </a-form-item>-->
<!-- <a-form-item label="市场价" name="salePrice">-->
<!-- <a-input-number-->
<!-- :placeholder="`市场价`"-->
<!-- style="width: 240px"-->
<!-- v-model:value="form.salePrice"-->
<!-- />-->
<!-- <div class="ele-text-placeholder">划线价仅用于文章页展示</div>-->
<!-- </a-form-item>-->
<a-form-item label="文章图片" name="image">
<SelectFile
:placeholder="`请选择图片`"
:limit="1"
:data="images"
@done="chooseImage"
@del="onDeleteItem"
/>
<!-- <div class="ele-text-placeholder"-->
<!-- >支持上传视频mp4格式视频时长不超过60秒视频大小不超过200M</div-->
<!-- >-->
</a-form-item>
<a-form-item label="上传附件" name="files">
<SelectFile
:placeholder="`请选择视频文件`"
:limit="9"
:data="files"
@done="chooseFile"
@del="onDeleteFile"
/>
</a-form-item>
<a-form-item label="文章内容" name="content">
<!-- 编辑器 -->
<tinymce-editor
ref="editorRef"
class="content"
v-model:value="content"
:disabled="disabled"
:init="config"
placeholder="图片直接粘贴自动上传"
@paste="onPaste"
/>
</a-form-item>
<a-form-item label="摘要">
<a-textarea
:rows="4"
:maxlength="200"
show-count
placeholder="请输入文章摘要"
@focus="onComments"
v-model:value="form.comments"
/>
</a-form-item>
<a-form-item label="发布时间" name="createTime" v-if="isUpdate">
<a-date-picker
v-model:value="form.createTime"
show-time
placeholder="Select Time"
value-format="YYYY-MM-DD HH:mm:ss"
/>
</a-form-item>
<a-form-item label="状态" name="status">
<a-radio-group v-model:value="form.status">
<a-radio :value="0">已发布</a-radio>
<a-radio :value="1">待审核</a-radio>
</a-radio-group>
</a-form-item>
</a-tab-pane>
<a-tab-pane tab="其他选项" key="other">
<a-form-item label="文章来源" name="source">
<source-select
v-model:value="form.source"
style="width: 180px"
/>
</a-form-item>
<a-form-item label="虚拟阅读量" name="virtualViews" :extra="`用户看到的阅读量(${Number(form?.actualViews) + Number(form?.virtualViews)}) = 实际阅读量(${form.actualViews}) + 虚拟阅读量(${form.virtualViews})`">
<a-input-number
:min="0"
:max="999999999"
style="width: 180px"
placeholder="请输入虚拟阅读量"
v-model:value="form.virtualViews"
/>
</a-form-item>
</a-tab-pane>
</a-tabs>
</a-form>
</ele-modal>
</template>
<script lang="ts" setup>
import { ref, reactive, watch } from 'vue';
import { Form, message } from 'ant-design-vue';
import { assignObject, htmlToText, uuid } from 'ele-admin-pro';
import { addArticle, updateArticle } from "@/api/cms/article";
import { Article } from '@/api/cms/article/model';
import { useThemeStore } from '@/store/modules/theme';
import { storeToRefs } from 'pinia';
import { ItemType } from 'ele-admin-pro/es/ele-image-upload/types';
import { FormInstance, RuleObject } from 'ant-design-vue/es/form';
import { FileRecord } from '@/api/system/file/model';
import TinymceEditor from '@/components/TinymceEditor/index.vue';
import { uploadFile, uploadOss } from "@/api/system/file";
import { SpecValue } from "@/api/shop/specValue/model";
import { Spec } from "@/api/shop/spec/model";
import { ArticleCategory } from "@/api/cms/category/model";
import { listArticleCategory } from "@/api/cms/category";
import { Navigation } from "@/api/cms/navigation/model";
import SourceSelect from "@/views/cms/article/dictionary/source-select.vue";
// 是否是修改
const isUpdate = ref(false);
const useForm = Form.useForm;
// 是否开启响应式布局
const themeStore = useThemeStore();
const { styleResponsive } = storeToRefs(themeStore);
const props = defineProps<{
// 弹窗是否打开
visible: boolean;
// 修改回显的数据
data?: Article | null;
// 商户ID
merchantId?: number;
}>();
const emit = defineEmits<{
(e: 'done'): void;
(e: 'update:visible', visible: boolean): void;
}>();
// 提交状态
const loading = ref(false);
// 是否显示最大化切换按钮
const maxable = ref(true);
// 表格选中数据
const formRef = ref<FormInstance | null>(null);
const images = ref<ItemType[]>([]);
const content = ref('');
const disabled = ref(false);
// 当前选项卡
const active = ref('base');
const spec = ref<SpecValue[]>([]);
const showSpecForm = ref(false);
const name = ref();
const value = ref();
const files = ref<ItemType[]>([]);
const category = ref<string[]>([]);
const takeaway = ref<ArticleCategory[]>([]);
// 用户信息
const form = reactive<Article>({
articleId: undefined,
// 封面图
image: '',
// 文章标题
title: '',
type: 0,
// 展现方式
showType: 10,
// 文章来源
source: undefined,
// 文章类型
categoryId: undefined,
// 栏目名称
categoryName: undefined,
// 文章内容
content: '',
// 虚拟阅读量
virtualViews: 0,
// 实际阅读量
actualViews: 0,
// 用户ID
userId: undefined,
// 所属门店ID
shopId: undefined,
files: '',
// 排序
sortNumber: 100,
// 备注
comments: undefined,
// 状态
status: 0,
// 创建时间
createTime: '',
// 更新时间
updateTime: ''
});
/* 更新visible */
const updateVisible = (value: boolean) => {
emit('update:visible', value);
};
// 表单验证规则
const rules = reactive({
title: [
{
required: true,
message: '请选择文章标题',
type: 'string',
trigger: 'blur'
}
],
image: [
{
required: true,
message: '请上传图片',
type: 'string',
trigger: 'blur'
}
],
// files: [
// {
// required: true,
// message: '请上传轮播图',
// type: 'string',
// trigger: 'blur',
// validator: async (_rule: RuleObject, value: string) => {
// if (form.files == '') {
// return Promise.reject('选择上传轮播图');
// }
// return Promise.resolve();
// }
// }
// ],
categoryId: [
{
required: true,
type: 'number',
message: '请选择栏目',
trigger: 'blur',
validator: async (_rule: RuleObject, value: string) => {
if (!form.categoryId) {
return Promise.reject('请选择栏目');
}
return Promise.resolve();
}
}
],
content: [
{
required: true,
type: "string",
message: "请输入文章内容",
trigger: "blur",
validator: async (_rule: RuleObject, value: string) => {
if (content.value == "") {
return Promise.reject("请输入文字内容");
}
return Promise.resolve();
}
}
],
});
const onType = (index: number) => {
form.type = index;
};
// /* 搜索 */
// const chooseMerchantId = (item: Merchant) => {
// form.merchantName = item.merchantName;
// form.merchantId = item.merchantId;
// };
//
// const chooseArticleCategory = (item: ArticleCategory,value: any) => {
// form.categoryId = value[1].value;
// form.categoryParent = value[0].label;
// form.categoryChildren = value[1].label;
// }
// const chooseTakeawayCategory = (item: ArticleCategory, value: any) => {
// form.categoryParent = '店铺分类';
// form.categoryChildren = value[0].label;
// form.categoryId = item[0];
// }
const chooseImage = (data: FileRecord) => {
images.value.push({
uid: data.id,
url: data.path,
status: 'done'
});
form.image = data.path;
};
const chooseCategory = (data: Navigation) => {
form.categoryName = data.title
form.categoryId = data.navigationId
}
const onChange = (text: string) => {
// 加载文章多规格
};
const onDeleteItem = (index: number) => {
images.value.splice(index, 1);
form.image = '';
};
const onClose = (index) => {
spec.value.splice(index, 1);
};
const openSpecForm = () => {
showSpecForm.value = !showSpecForm.value;
};
const onComments = () => {
if (form.comments == undefined) {
form.comments = htmlToText(content.value)
form.comments = form.comments.slice(0, 120)
}
}
const onSpec = (row: Spec) => {
// form.specName = row.specName;
if(row.specValue){
spec.value = JSON.parse(row?.specValue);
}
}
// 新增规格
const addSpecValue = () => {
if (!name.value || !value.value) {
message.error(`请输入规格和规格值`);
return false;
}
const findIndex = spec.value.findIndex((d) => d.value == name.value);
if (findIndex == 0) {
message.error(`${name.value}已存在)`);
return false;
}
spec.value.push({
value: name.value,
detail: [value.value]
});
name.value = '';
value.value = '';
openSpecForm();
};
const chooseFile = (data: FileRecord) => {
files.value.push({
uid: data.id,
url: data.path,
status: 'done'
});
form.files = JSON.stringify(files.value.map(d => d.url))
};
const onDeleteFile = (index: number) => {
files.value.splice(index, 1);
};
const editorRef = ref<InstanceType<typeof TinymceEditor> | null>(null);
const config = ref({
height: 500,
images_upload_handler: (blobInfo, success, error) => {
const file = blobInfo.blob();
const formData = new FormData();
formData.append('file', file, file.name);
uploadOss(file).then(res => {
success(res.path)
}).catch((msg) => {
error(msg);
})
},
// 自定义文件上传(这里使用把选择的文件转成 blob 演示)
file_picker_callback: (callback: any, _value: any, meta: any) => {
const input = document.createElement('input');
input.setAttribute('type', 'file');
// 设定文件可选类型
if (meta.filetype === 'image') {
input.setAttribute('accept', 'image/*');
} else if (meta.filetype === 'media') {
input.setAttribute('accept', 'video/*,.pdf');
}
input.onchange = () => {
const file = input.files?.[0];
if (!file) {
return;
}
if (meta.filetype === 'media') {
if (file.size / 1024 / 1024 > 200) {
editorRef.value?.alert({ content: '大小不能超过 200MB' });
return;
}
if(file.type.startsWith('application/pdf')){
uploadOss(file).then(res => {
const addPath = `<a href="${res.downloadUrl}" target="_blank">${res.name}</a>`;
content.value = content.value + addPath
})
return;
}
if (!file.type.startsWith('video/')) {
editorRef.value?.alert({ content: '只能选择视频文件' });
return;
}
uploadOss(file).then(res => {
callback(res.path)
});
}
};
input.click();
}
});
/* 粘贴图片上传服务器并插入编辑器 */
const onPaste = (e) => {
const items = (e.clipboardData || e.originalEvent.clipboardData).items;
let hasFile = false;
for (let i = 0; i < items.length; i++) {
if (items[i].type.indexOf('image') !== -1) {
let file = items[i].getAsFile();
const item: ItemType = {
file,
uid: (file as any).lastModified,
name: file.name
};
uploadFile(<File>item.file)
.then((result) => {
const addPath = `<p><img class="content-img" src="${result.url}"></p>`;
content.value = content.value + addPath
})
.catch((e) => {
message.error(e.message);
});
hasFile = true;
}
}
if (hasFile) {
e.preventDefault();
}
}
const { resetFields } = useForm(form, rules);
/* 保存编辑 */
const save = () => {
if (!formRef.value) {
return;
}
formRef.value
.validate()
.then(() => {
loading.value = true;
const formData = {
...form,
content: content.value
};
const saveOrUpdate = isUpdate.value ? updateArticle : addArticle;
saveOrUpdate(formData)
.then((msg) => {
loading.value = false;
message.success(msg);
updateVisible(false);
emit('done');
})
.catch((e) => {
loading.value = false;
message.error(e.message);
});
})
.catch(() => {});
};
watch(
() => props.visible,
(visible) => {
if (visible) {
images.value = [];
category.value = [];
files.value = [];
if (props.data) {
assignObject(form, props.data);
if (props.data.image) {
images.value.push({
uid: uuid(),
url: props.data.image,
status: 'done'
});
}
if(props.data.files){
const arr = JSON.parse(props.data.files)
arr.map((url:string) => {
files.value.push({
uid: uuid(),
url: url,
status: 'done'
})
})
}
// 文章分类
// if(props.data.categoryParent){
// category.value.push(props.data.categoryParent);
// }
// if(props.data.categoryChildren){
// category.value.push(props.data.categoryChildren);
// }
if (props.data.content){
content.value = props.data.content;
}
// 外卖文章分类
listArticleCategory({merchantId: props.merchantId}).then(list => {
takeaway.value = list
})
isUpdate.value = true;
} else {
spec.value = [];
isUpdate.value = false;
}
} else {
resetFields();
}
},
{ immediate: true }
);
</script>

View File

@@ -0,0 +1,147 @@
<!-- 搜索表单 -->
<template>
<a-space :size="10" style="flex-wrap: wrap">
<a-button type="primary" class="ele-btn-icon" @click="add">
<template #icon>
<PlusOutlined />
</template>
<span>添加</span>
</a-button>
<a-radio-group v-model:value="type" @change="handleSearch">
<a-radio-button value="已发布"
>已发布({{ goodsCount?.totalNum }})</a-radio-button
>
<a-radio-button value="待审核"
>待审核({{ goodsCount?.totalNum2 }})</a-radio-button
>
<a-radio-button value="已驳回"
>已驳回({{ goodsCount?.totalNum3 }})</a-radio-button
>
</a-radio-group>
<!-- <SelectMerchant-->
<!-- :placeholder="`选择商户`"-->
<!-- class="input-item"-->
<!-- v-if="!merchantId"-->
<!-- v-model:value="where.merchantName"-->
<!-- @done="chooseMerchantId"-->
<!-- />-->
<SelectNavigsation
class="input-item"
:placeholder="`选择栏目`"
v-model:value="where.categoryName"
@done="chooseArticleCategory"
/>
<a-input-search
allow-clear
placeholder="请输入关键词"
v-model:value="where.keywords"
@pressEnter="reload"
@search="reload"
/>
<a-button @click="reset">重置</a-button>
</a-space>
</template>
<script lang="ts" setup>
import { PlusOutlined } from '@ant-design/icons-vue';
import { ref, watch } from 'vue';
import { getCount } from '@/api/shop/goods';
import type { ArticleCount, ArticleParam } from '@/api/cms/article/model';
import useSearch from '@/utils/use-search';
import { Merchant } from '@/api/shop/merchant/model';
import { Navigation } from '@/api/cms/navigation/model';
const props = withDefaults(
defineProps<{
// 选中的角色
selection?: [];
merchantId?: number;
}>(),
{}
);
const type = ref<string>();
// 统计数据
const goodsCount = ref<ArticleCount>();
// 表单数据
const { where, resetFields } = useSearch<ArticleParam>({
articleId: undefined,
navigationId: undefined,
categoryId: undefined,
merchantId: undefined,
keywords: ''
});
const emit = defineEmits<{
(e: 'search', where?: ArticleParam): void;
(e: 'add'): void;
(e: 'remove'): void;
(e: 'batchMove'): void;
}>();
// 新增
const add = () => {
emit('add');
};
const handleSearch = (e) => {
const text = e.target.value;
resetFields();
if (text === '已发布') {
where.status = 1;
}
if (text === '待审核') {
where.status = 0;
}
if (text === '已驳回') {
where.status = 2;
}
emit('search', where);
};
const reload = () => {
getCount(where).then((data: any) => {
goodsCount.value = data;
});
emit('search', where);
};
/* 搜索 */
const chooseMerchantId = (item: Merchant) => {
where.merchantName = item.merchantName;
where.merchantId = item.merchantId;
reload();
};
const chooseArticleCategory = (category: Navigation) => {
where.categoryName = category.title;
where.navigationId = category.navigationId;
reload();
};
/* 重置 */
const reset = () => {
resetFields();
type.value = '';
reload();
};
// watch(
// () => props.selection,
// () => {}
// );
watch(
() => props.merchantId,
(id) => {
if (Number(id) > 0) {
where.merchantId = id;
reload();
} else {
where.merchantId = undefined;
reload();
}
},
{ immediate: true }
);
</script>

View File

@@ -0,0 +1,324 @@
<template>
<div class="page">
<div class="ele-body">
<a-card :bordered="false" :body-style="{ padding: '16px' }">
<ele-pro-table
ref="tableRef"
row-key="articleId"
:columns="columns"
:datasource="datasource"
:customRow="customRow"
:scroll="{ x: 1200 }"
tool-class="ele-toolbar-form"
class="sys-org-table"
>
<template #toolbar>
<search
@search="reload"
:selection="selection"
:merchantId="merchantId"
@add="openEdit"
@remove="removeBatch"
@batchMove="openMove"
/>
</template>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'title'">
<a
@click="
openSpmUrl(
`/article/detail/${record.articleId}.html`,
record,
record.articleId
)
"
>{{ record.title }}</a
>
</template>
<template v-if="column.key === 'type'">
<a-tag v-if="record.type === 0">虚拟文章</a-tag>
<a-tag v-if="record.type === 1">实物文章</a-tag>
</template>
<template v-if="column.key === 'image'">
<a-image :src="record.image" :width="80" />
</template>
<template v-if="column.key === 'salePrice'">
{{ formatNumber(record.salePrice) }}
</template>
<template v-if="column.key === 'status'">
<a-tag
:color="record.status == 0 ? 'green' : 'red'"
class="cursor-pointer"
@click="onUpdate(record)"
>{{ record.statusText }}</a-tag
>
</template>
<template v-if="column.key === 'action'">
<a-space>
<a @click="openEdit(record)">修改</a>
<a-divider type="vertical" />
<a-popconfirm
title="确定要删除此记录吗?"
@confirm="remove(record)"
>
<a class="ele-text-danger">删除</a>
</a-popconfirm>
</a-space>
</template>
</template>
</ele-pro-table>
</a-card>
<!-- 编辑弹窗 -->
<ArticleEdit v-model:visible="showEdit" :data="current" @done="reload" />
</div>
</div>
</template>
<script lang="ts" setup>
import { createVNode, ref, watch } from 'vue';
import { message, Modal } from 'ant-design-vue';
import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
import type { EleProTable } from 'ele-admin-pro';
import { uuid } from 'ele-admin-pro';
import type {
DatasourceFunction,
ColumnItem
} from 'ele-admin-pro/es/ele-pro-table/types';
import Search from './components/search.vue';
import ArticleEdit from './components/articleEdit.vue';
import {
pageArticle,
removeArticle,
removeBatchArticle
} from '@/api/cms/article';
import type { Article, ArticleParam } from '@/api/cms/article/model';
import { formatNumber } from 'ele-admin-pro/es';
import router from '@/router';
import { openSpmUrl, openUrl, openUrlSpm } from '@/utils/common';
import { getSiteDomain } from '@/utils/domain';
// 表格实例
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
// 表格选中数据
const selection = ref<Article[]>([]);
// 当前编辑数据
const current = ref<Article | null>(null);
// 是否显示编辑弹窗
const showEdit = ref(false);
// 是否显示批量移动弹窗
const showMove = ref(false);
// 店铺ID
const merchantId = ref<number>();
// 网站域名
const domain = getSiteDomain();
// 随机数
const token = ref<any>('');
// 表格数据源
const datasource: DatasourceFunction = ({
page,
limit,
where,
orders,
filters
}) => {
if (filters) {
where.status = filters.status;
}
if (merchantId.value) {
where.merchantId = merchantId.value;
}
return pageArticle({
...where,
...orders,
page,
limit
});
};
// 表格列配置
const columns = ref<ColumnItem[]>([
{
title: 'ID',
dataIndex: 'articleId',
key: 'articleId',
align: 'center',
width: 90
},
{
title: '文章标题',
dataIndex: 'title',
key: 'title'
},
{
title: '封面图',
dataIndex: 'image',
key: 'image',
width: 120,
align: 'center'
},
{
title: '所属栏目',
dataIndex: 'categoryId',
key: 'categoryId',
align: 'center',
hideInTable: true
},
{
title: '实际阅读量',
dataIndex: 'actualViews',
key: 'actualViews',
sorter: true,
width: 120,
align: 'center'
},
{
title: '虚拟阅读量',
dataIndex: 'virtualViews',
key: 'virtualViews',
width: 120,
align: 'center'
},
{
title: '推荐',
dataIndex: 'recommend',
key: 'recommend',
sorter: true,
align: 'center',
hideInTable: true
},
{
title: '状态',
dataIndex: 'status',
key: 'status',
sorter: true,
width: 120,
align: 'center'
},
{
title: '排序号',
dataIndex: 'sortNumber',
key: 'sortNumber',
sorter: true,
align: 'center',
hideInTable: true
},
{
title: '创建时间',
dataIndex: 'createTime',
key: 'createTime',
align: 'center',
width: 180,
sorter: true
},
{
title: '操作',
key: 'action',
width: 180,
fixed: 'right',
align: 'center',
hideInSetting: true
}
]);
/* 搜索 */
const reload = (where?: ArticleParam) => {
selection.value = [];
tableRef?.value?.reload({ where: where });
};
/* 打开编辑弹窗 */
const openEdit = (row?: Article) => {
current.value = row ?? null;
showEdit.value = true;
};
/* 打开批量移动弹窗 */
const openMove = () => {
showMove.value = true;
};
const onUpdate = (row?: Article) => {
// const isShow = row?.isShow == 0 ? 1 : 0;
// updateArticle({ ...row, isShow }).then((msg) => {
// message.success(msg);
// reload();
// });
};
/* 删除单个 */
const remove = (row: Article) => {
const hide = message.loading('请求中..', 0);
removeArticle(row.articleId)
.then((msg) => {
hide();
message.success(msg);
reload();
})
.catch((e) => {
hide();
message.error(e.message);
});
};
/* 批量删除 */
const removeBatch = () => {
if (!selection.value.length) {
message.error('请至少选择一条数据');
return;
}
Modal.confirm({
title: '提示',
content: '确定要删除选中的记录吗?',
icon: createVNode(ExclamationCircleOutlined),
maskClosable: true,
onOk: () => {
const hide = message.loading('请求中..', 0);
removeBatchArticle(selection.value.map((d) => d.articleId))
.then((msg) => {
hide();
message.success(msg);
reload();
})
.catch((e) => {
hide();
message.error(e.message);
});
}
});
};
/* 自定义行属性 */
const customRow = (record: Article) => {
return {
// 行点击事件
onClick: () => {
// console.log(record);
},
// 行双击事件
onDblclick: () => {
openEdit(record);
}
};
};
watch(
() => router.currentRoute.value.params.id,
(id) => {
merchantId.value = Number(id);
token.value = uuid();
reload();
},
{ immediate: true }
);
</script>
<script lang="ts">
export default {
name: 'ArticleV2'
};
</script>
<style lang="less" scoped></style>

View File

@@ -66,9 +66,16 @@
style="margin-right: 10px"
v-if="record.image"
/>
<a @click="openPreview(`/article/` + record.categoryId)">{{
record.title
}}</a>
<a
@click="
openSpmUrl(
`/article/${record.categoryId}`,
record,
record.categoryId
)
"
>{{ record.title }}</a
>
</template>
<template v-if="column.key === 'showIndex'">
<a-space @click="onShowIndex(record)">
@@ -153,7 +160,7 @@
ArticleCategory,
ArticleCategoryParam
} from '@/api/cms/category/model';
import { openNew, openPreview } from '@/utils/common';
import { openNew, openPreview, openSpmUrl } from '@/utils/common';
import { getSiteInfo } from '@/api/layout';
// 表格实例

View File

@@ -0,0 +1,252 @@
<!-- 编辑弹窗 -->
<template>
<ele-modal
:width="800"
:visible="visible"
:maskClosable="false"
:maxable="maxable"
:title="isUpdate ? '编辑组件' : '添加组件'"
:body-style="{ paddingBottom: '28px' }"
@update:visible="updateVisible"
@ok="save"
>
<a-form
ref="formRef"
:model="form"
:rules="rules"
:label-col="styleResponsive ? { md: 4, sm: 5, xs: 24 } : { flex: '90px' }"
:wrapper-col="
styleResponsive ? { md: 19, sm: 19, xs: 24 } : { flex: '1' }
"
>
<a-form-item label="组件标题" name="title">
<a-input
allow-clear
placeholder="请输入组件标题"
v-model:value="form.title"
/>
</a-form-item>
<a-form-item label="关联导航ID" name="navigationId">
<a-input
allow-clear
placeholder="请输入关联导航ID"
v-model:value="form.navigationId"
/>
</a-form-item>
<a-form-item label="组件类型" name="type">
<a-input
allow-clear
placeholder="请输入组件类型"
v-model:value="form.type"
/>
</a-form-item>
<a-form-item label="页面关键词" name="keywords">
<a-input
allow-clear
placeholder="请输入页面关键词"
v-model:value="form.keywords"
/>
</a-form-item>
<a-form-item label="页面描述" name="description">
<a-input
allow-clear
placeholder="请输入页面描述"
v-model:value="form.description"
/>
</a-form-item>
<a-form-item label="组件路径" name="path">
<a-input
allow-clear
placeholder="请输入组件路径"
v-model:value="form.path"
/>
</a-form-item>
<a-form-item label="组件图标" name="icon">
<a-input
allow-clear
placeholder="请输入组件图标"
v-model:value="form.icon"
/>
</a-form-item>
<a-form-item label="用户ID" name="userId">
<a-input
allow-clear
placeholder="请输入用户ID"
v-model:value="form.userId"
/>
</a-form-item>
<a-form-item label="排序(数字越小越靠前)" name="sortNumber">
<a-input-number
:min="0"
:max="9999"
class="ele-fluid"
placeholder="请输入排序号"
v-model:value="form.sortNumber"
/>
</a-form-item>
<a-form-item label="备注" name="comments">
<a-textarea
:rows="4"
:maxlength="200"
placeholder="请输入描述"
v-model:value="form.comments"
/>
</a-form-item>
<a-form-item label="状态, 0正常, 1冻结" name="status">
<a-radio-group v-model:value="form.status">
<a-radio :value="0">显示</a-radio>
<a-radio :value="1">隐藏</a-radio>
</a-radio-group>
</a-form-item>
</a-form>
</ele-modal>
</template>
<script lang="ts" setup>
import { ref, reactive, watch } from 'vue';
import { Form, message } from 'ant-design-vue';
import { assignObject, uuid } from 'ele-admin-pro';
import { addComponents, updateComponents } from '@/api/cms/components';
import { Components } from '@/api/cms/components/model';
import { useThemeStore } from '@/store/modules/theme';
import { storeToRefs } from 'pinia';
import { ItemType } from 'ele-admin-pro/es/ele-image-upload/types';
import { FormInstance } from 'ant-design-vue/es/form';
import { FileRecord } from '@/api/system/file/model';
// 是否是修改
const isUpdate = ref(false);
const useForm = Form.useForm;
// 是否开启响应式布局
const themeStore = useThemeStore();
const { styleResponsive } = storeToRefs(themeStore);
const props = defineProps<{
// 弹窗是否打开
visible: boolean;
// 修改回显的数据
data?: Components | null;
}>();
const emit = defineEmits<{
(e: 'done'): void;
(e: 'update:visible', visible: boolean): void;
}>();
// 提交状态
const loading = ref(false);
// 是否显示最大化切换按钮
const maxable = ref(true);
// 表格选中数据
const formRef = ref<FormInstance | null>(null);
const images = ref<ItemType[]>([]);
// 用户信息
const form = reactive<Components>({
id: undefined,
title: undefined,
navigationId: undefined,
type: undefined,
keywords: undefined,
description: undefined,
path: undefined,
icon: undefined,
userId: undefined,
sortNumber: undefined,
comments: undefined,
status: undefined,
tenantId: undefined,
createTime: undefined,
componentsId: undefined,
componentsName: '',
status: 0,
comments: '',
sortNumber: 100
});
/* 更新visible */
const updateVisible = (value: boolean) => {
emit('update:visible', value);
};
// 表单验证规则
const rules = reactive({
componentsName: [
{
required: true,
type: 'string',
message: '请填写组件名称',
trigger: 'blur'
}
]
});
const chooseImage = (data: FileRecord) => {
images.value.push({
uid: data.id,
url: data.path,
status: 'done'
});
form.image = data.path;
};
const onDeleteItem = (index: number) => {
images.value.splice(index, 1);
form.image = '';
};
const { resetFields } = useForm(form, rules);
/* 保存编辑 */
const save = () => {
if (!formRef.value) {
return;
}
formRef.value
.validate()
.then(() => {
loading.value = true;
const formData = {
...form
};
const saveOrUpdate = isUpdate.value ? updateComponents : addComponents;
saveOrUpdate(formData)
.then((msg) => {
loading.value = false;
message.success(msg);
updateVisible(false);
emit('done');
})
.catch((e) => {
loading.value = false;
message.error(e.message);
});
})
.catch(() => {});
};
watch(
() => props.visible,
(visible) => {
if (visible) {
images.value = [];
if (props.data) {
assignObject(form, props.data);
if(props.data.image){
images.value.push({
uid: uuid(),
url: props.data.image,
status: 'done'
})
}
isUpdate.value = true;
} else {
isUpdate.value = false;
}
} else {
resetFields();
}
},
{ immediate: true }
);
</script>

View File

@@ -0,0 +1,42 @@
<!-- 搜索表单 -->
<template>
<a-space :size="10" style="flex-wrap: wrap">
<a-button type="primary" class="ele-btn-icon" @click="add">
<template #icon>
<PlusOutlined />
</template>
<span>添加</span>
</a-button>
</a-space>
</template>
<script lang="ts" setup>
import { PlusOutlined } from '@ant-design/icons-vue';
import type { GradeParam } from '@/api/user/grade/model';
import { watch } from 'vue';
const props = withDefaults(
defineProps<{
// 选中的角色
selection?: [];
}>(),
{}
);
const emit = defineEmits<{
(e: 'search', where?: GradeParam): void;
(e: 'add'): void;
(e: 'remove'): void;
(e: 'batchMove'): void;
}>();
// 新增
const add = () => {
emit('add');
};
watch(
() => props.selection,
() => {}
);
</script>

View File

@@ -0,0 +1,281 @@
<template>
<div class="page">
<div class="ele-body">
<a-card :bordered="false" :body-style="{ padding: '16px' }">
<ele-pro-table
ref="tableRef"
row-key="componentsId"
:columns="columns"
:datasource="datasource"
:customRow="customRow"
tool-class="ele-toolbar-form"
class="sys-org-table"
>
<template #toolbar>
<search
@search="reload"
:selection="selection"
@add="openEdit"
@remove="removeBatch"
@batchMove="openMove"
/>
</template>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'image'">
<a-image :src="record.image" :width="50" />
</template>
<template v-if="column.key === 'status'">
<a-tag v-if="record.status === 0" color="green">显示</a-tag>
<a-tag v-if="record.status === 1" color="red">隐藏</a-tag>
</template>
<template v-if="column.key === 'action'">
<a-space>
<a @click="openEdit(record)">修改</a>
<a-divider type="vertical" />
<a-popconfirm
title="确定要删除此记录吗?"
@confirm="remove(record)"
>
<a class="ele-text-danger">删除</a>
</a-popconfirm>
</a-space>
</template>
</template>
</ele-pro-table>
</a-card>
<!-- 编辑弹窗 -->
<ComponentsEdit v-model:visible="showEdit" :data="current" @done="reload" />
</div>
</div>
</template>
<script lang="ts" setup>
import { createVNode, ref } from 'vue';
import { message, Modal } from 'ant-design-vue';
import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
import type { EleProTable } from 'ele-admin-pro';
import { toDateString } from 'ele-admin-pro';
import type {
DatasourceFunction,
ColumnItem
} from 'ele-admin-pro/es/ele-pro-table/types';
import Search from './components/search.vue';
import ComponentsEdit from './components/componentsEdit.vue';
import { pageComponents, removeComponents, removeBatchComponents } from '@/api/cms/components';
import type { Components, ComponentsParam } from '@/api/cms/components/model';
// 表格实例
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
// 表格选中数据
const selection = ref<Components[]>([]);
// 当前编辑数据
const current = ref<Components | null>(null);
// 是否显示编辑弹窗
const showEdit = ref(false);
// 是否显示批量移动弹窗
const showMove = ref(false);
// 加载状态
const loading = ref(true);
// 表格数据源
const datasource: DatasourceFunction = ({
page,
limit,
where,
orders,
filters
}) => {
if (filters) {
where.status = filters.status;
}
return pageComponents({
...where,
...orders,
page,
limit
});
};
// 表格列配置
const columns = ref<ColumnItem[]>([
{
title: 'ID',
dataIndex: 'id',
key: 'id',
align: 'center',
width: 90,
},
{
title: '组件标题',
dataIndex: 'title',
key: 'title',
align: 'center',
},
{
title: '关联导航ID',
dataIndex: 'navigationId',
key: 'navigationId',
align: 'center',
},
{
title: '组件类型',
dataIndex: 'type',
key: 'type',
align: 'center',
},
{
title: '页面关键词',
dataIndex: 'keywords',
key: 'keywords',
align: 'center',
},
{
title: '页面描述',
dataIndex: 'description',
key: 'description',
align: 'center',
},
{
title: '组件路径',
dataIndex: 'path',
key: 'path',
align: 'center',
},
{
title: '组件图标',
dataIndex: 'icon',
key: 'icon',
align: 'center',
},
{
title: '用户ID',
dataIndex: 'userId',
key: 'userId',
align: 'center',
},
{
title: '排序(数字越小越靠前)',
dataIndex: 'sortNumber',
key: 'sortNumber',
align: 'center',
},
{
title: '备注',
dataIndex: 'comments',
key: 'comments',
align: 'center',
},
{
title: '状态, 0正常, 1冻结',
dataIndex: 'status',
key: 'status',
align: 'center',
},
{
title: '创建时间',
dataIndex: 'createTime',
key: 'createTime',
align: 'center',
sorter: true,
ellipsis: true,
customRender: ({ text }) => toDateString(text, 'yyyy-MM-dd')
},
{
title: '操作',
key: 'action',
width: 180,
fixed: 'right',
align: 'center',
hideInSetting: true
}
]);
/* 搜索 */
const reload = (where?: ComponentsParam) => {
selection.value = [];
tableRef?.value?.reload({ where: where });
};
/* 打开编辑弹窗 */
const openEdit = (row?: Components) => {
current.value = row ?? null;
showEdit.value = true;
};
/* 打开批量移动弹窗 */
const openMove = () => {
showMove.value = true;
};
/* 删除单个 */
const remove = (row: Components) => {
const hide = message.loading('请求中..', 0);
removeComponents(row.componentsId)
.then((msg) => {
hide();
message.success(msg);
reload();
})
.catch((e) => {
hide();
message.error(e.message);
});
};
/* 批量删除 */
const removeBatch = () => {
if (!selection.value.length) {
message.error('请至少选择一条数据');
return;
}
Modal.confirm({
title: '提示',
content: '确定要删除选中的记录吗?',
icon: createVNode(ExclamationCircleOutlined),
maskClosable: true,
onOk: () => {
const hide = message.loading('请求中..', 0);
removeBatchComponents(selection.value.map((d) => d.componentsId))
.then((msg) => {
hide();
message.success(msg);
reload();
})
.catch((e) => {
hide();
message.error(e.message);
});
}
});
};
/* 查询 */
const query = () => {
loading.value = true;
};
/* 自定义行属性 */
const customRow = (record: Components) => {
return {
// 行点击事件
onClick: () => {
// console.log(record);
},
// 行双击事件
onDblclick: () => {
openEdit(record);
}
};
};
query();
</script>
<script lang="ts">
export default {
name: 'Components'
};
</script>
<style lang="less" scoped></style>

View File

@@ -0,0 +1,260 @@
<!-- 编辑弹窗 -->
<template>
<ele-modal
:width="800"
:visible="visible"
:maskClosable="false"
:maxable="maxable"
:title="isUpdate ? '编辑页面组件表' : '添加页面组件表'"
:body-style="{ paddingBottom: '28px' }"
@update:visible="updateVisible"
@ok="save"
>
<a-form
ref="formRef"
:model="form"
:rules="rules"
:label-col="styleResponsive ? { md: 4, sm: 5, xs: 24 } : { flex: '90px' }"
:wrapper-col="
styleResponsive ? { md: 19, sm: 19, xs: 24 } : { flex: '1' }
"
>
<a-form-item label="关联导航ID" name="navigationId">
<a-input
allow-clear
placeholder="请输入关联导航ID"
v-model:value="form.navigationId"
/>
</a-form-item>
<a-form-item label="组件" name="title">
<a-input
allow-clear
placeholder="请输入组件"
v-model:value="form.title"
/>
</a-form-item>
<a-form-item label="组件标识" name="dictCode">
<a-input
allow-clear
placeholder="请输入组件标识"
v-model:value="form.dictCode"
/>
</a-form-item>
<a-form-item label="组件样式" name="styles">
<a-input
allow-clear
placeholder="请输入组件样式"
v-model:value="form.styles"
/>
</a-form-item>
<a-form-item label="页面关键词" name="keywords">
<a-input
allow-clear
placeholder="请输入页面关键词"
v-model:value="form.keywords"
/>
</a-form-item>
<a-form-item label="页面描述" name="description">
<a-input
allow-clear
placeholder="请输入页面描述"
v-model:value="form.description"
/>
</a-form-item>
<a-form-item label="页面路由地址" name="path">
<a-input
allow-clear
placeholder="请输入页面路由地址"
v-model:value="form.path"
/>
</a-form-item>
<a-form-item label="缩列图" name="photo">
<a-input
allow-clear
placeholder="请输入缩列图"
v-model:value="form.photo"
/>
</a-form-item>
<a-form-item label="用户ID" name="userId">
<a-input
allow-clear
placeholder="请输入用户ID"
v-model:value="form.userId"
/>
</a-form-item>
<a-form-item label="排序(数字越小越靠前)" name="sortNumber">
<a-input-number
:min="0"
:max="9999"
class="ele-fluid"
placeholder="请输入排序号"
v-model:value="form.sortNumber"
/>
</a-form-item>
<a-form-item label="备注" name="comments">
<a-textarea
:rows="4"
:maxlength="200"
placeholder="请输入描述"
v-model:value="form.comments"
/>
</a-form-item>
<a-form-item label="状态, 0正常, 1冻结" name="status">
<a-radio-group v-model:value="form.status">
<a-radio :value="0">显示</a-radio>
<a-radio :value="1">隐藏</a-radio>
</a-radio-group>
</a-form-item>
</a-form>
</ele-modal>
</template>
<script lang="ts" setup>
import { ref, reactive, watch } from 'vue';
import { Form, message } from 'ant-design-vue';
import { assignObject, uuid } from 'ele-admin-pro';
import { addDesignRecord, updateDesignRecord } from '@/api/cms/designRecord';
import { DesignRecord } from '@/api/cms/designRecord/model';
import { useThemeStore } from '@/store/modules/theme';
import { storeToRefs } from 'pinia';
import { ItemType } from 'ele-admin-pro/es/ele-image-upload/types';
import { FormInstance } from 'ant-design-vue/es/form';
import { FileRecord } from '@/api/system/file/model';
// 是否是修改
const isUpdate = ref(false);
const useForm = Form.useForm;
// 是否开启响应式布局
const themeStore = useThemeStore();
const { styleResponsive } = storeToRefs(themeStore);
const props = defineProps<{
// 弹窗是否打开
visible: boolean;
// 修改回显的数据
data?: DesignRecord | null;
}>();
const emit = defineEmits<{
(e: 'done'): void;
(e: 'update:visible', visible: boolean): void;
}>();
// 提交状态
const loading = ref(false);
// 是否显示最大化切换按钮
const maxable = ref(true);
// 表格选中数据
const formRef = ref<FormInstance | null>(null);
const images = ref<ItemType[]>([]);
// 用户信息
const form = reactive<DesignRecord>({
id: undefined,
navigationId: undefined,
title: undefined,
dictCode: undefined,
styles: undefined,
keywords: undefined,
description: undefined,
path: undefined,
photo: undefined,
userId: undefined,
sortNumber: undefined,
comments: undefined,
status: undefined,
tenantId: undefined,
createTime: undefined,
designRecordId: undefined,
designRecordName: '',
status: 0,
comments: '',
sortNumber: 100
});
/* 更新visible */
const updateVisible = (value: boolean) => {
emit('update:visible', value);
};
// 表单验证规则
const rules = reactive({
designRecordName: [
{
required: true,
type: 'string',
message: '请填写页面组件表名称',
trigger: 'blur'
}
]
});
const chooseImage = (data: FileRecord) => {
images.value.push({
uid: data.id,
url: data.path,
status: 'done'
});
form.image = data.path;
};
const onDeleteItem = (index: number) => {
images.value.splice(index, 1);
form.image = '';
};
const { resetFields } = useForm(form, rules);
/* 保存编辑 */
const save = () => {
if (!formRef.value) {
return;
}
formRef.value
.validate()
.then(() => {
loading.value = true;
const formData = {
...form
};
const saveOrUpdate = isUpdate.value ? updateDesignRecord : addDesignRecord;
saveOrUpdate(formData)
.then((msg) => {
loading.value = false;
message.success(msg);
updateVisible(false);
emit('done');
})
.catch((e) => {
loading.value = false;
message.error(e.message);
});
})
.catch(() => {});
};
watch(
() => props.visible,
(visible) => {
if (visible) {
images.value = [];
if (props.data) {
assignObject(form, props.data);
if(props.data.image){
images.value.push({
uid: uuid(),
url: props.data.image,
status: 'done'
})
}
isUpdate.value = true;
} else {
isUpdate.value = false;
}
} else {
resetFields();
}
},
{ immediate: true }
);
</script>

View File

@@ -0,0 +1,42 @@
<!-- 搜索表单 -->
<template>
<a-space :size="10" style="flex-wrap: wrap">
<a-button type="primary" class="ele-btn-icon" @click="add">
<template #icon>
<PlusOutlined />
</template>
<span>添加</span>
</a-button>
</a-space>
</template>
<script lang="ts" setup>
import { PlusOutlined } from '@ant-design/icons-vue';
import type { GradeParam } from '@/api/user/grade/model';
import { watch } from 'vue';
const props = withDefaults(
defineProps<{
// 选中的角色
selection?: [];
}>(),
{}
);
const emit = defineEmits<{
(e: 'search', where?: GradeParam): void;
(e: 'add'): void;
(e: 'remove'): void;
(e: 'batchMove'): void;
}>();
// 新增
const add = () => {
emit('add');
};
watch(
() => props.selection,
() => {}
);
</script>

View File

@@ -0,0 +1,287 @@
<template>
<div class="page">
<div class="ele-body">
<a-card :bordered="false" :body-style="{ padding: '16px' }">
<ele-pro-table
ref="tableRef"
row-key="designRecordId"
:columns="columns"
:datasource="datasource"
:customRow="customRow"
tool-class="ele-toolbar-form"
class="sys-org-table"
>
<template #toolbar>
<search
@search="reload"
:selection="selection"
@add="openEdit"
@remove="removeBatch"
@batchMove="openMove"
/>
</template>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'image'">
<a-image :src="record.image" :width="50" />
</template>
<template v-if="column.key === 'status'">
<a-tag v-if="record.status === 0" color="green">显示</a-tag>
<a-tag v-if="record.status === 1" color="red">隐藏</a-tag>
</template>
<template v-if="column.key === 'action'">
<a-space>
<a @click="openEdit(record)">修改</a>
<a-divider type="vertical" />
<a-popconfirm
title="确定要删除此记录吗?"
@confirm="remove(record)"
>
<a class="ele-text-danger">删除</a>
</a-popconfirm>
</a-space>
</template>
</template>
</ele-pro-table>
</a-card>
<!-- 编辑弹窗 -->
<DesignRecordEdit v-model:visible="showEdit" :data="current" @done="reload" />
</div>
</div>
</template>
<script lang="ts" setup>
import { createVNode, ref } from 'vue';
import { message, Modal } from 'ant-design-vue';
import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
import type { EleProTable } from 'ele-admin-pro';
import { toDateString } from 'ele-admin-pro';
import type {
DatasourceFunction,
ColumnItem
} from 'ele-admin-pro/es/ele-pro-table/types';
import Search from './components/search.vue';
import DesignRecordEdit from './components/designRecordEdit.vue';
import { pageDesignRecord, removeDesignRecord, removeBatchDesignRecord } from '@/api/cms/designRecord';
import type { DesignRecord, DesignRecordParam } from '@/api/cms/designRecord/model';
// 表格实例
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
// 表格选中数据
const selection = ref<DesignRecord[]>([]);
// 当前编辑数据
const current = ref<DesignRecord | null>(null);
// 是否显示编辑弹窗
const showEdit = ref(false);
// 是否显示批量移动弹窗
const showMove = ref(false);
// 加载状态
const loading = ref(true);
// 表格数据源
const datasource: DatasourceFunction = ({
page,
limit,
where,
orders,
filters
}) => {
if (filters) {
where.status = filters.status;
}
return pageDesignRecord({
...where,
...orders,
page,
limit
});
};
// 表格列配置
const columns = ref<ColumnItem[]>([
{
title: 'ID',
dataIndex: 'id',
key: 'id',
align: 'center',
width: 90,
},
{
title: '关联导航ID',
dataIndex: 'navigationId',
key: 'navigationId',
align: 'center',
},
{
title: '组件',
dataIndex: 'title',
key: 'title',
align: 'center',
},
{
title: '组件标识',
dataIndex: 'dictCode',
key: 'dictCode',
align: 'center',
},
{
title: '组件样式',
dataIndex: 'styles',
key: 'styles',
align: 'center',
},
{
title: '页面关键词',
dataIndex: 'keywords',
key: 'keywords',
align: 'center',
},
{
title: '页面描述',
dataIndex: 'description',
key: 'description',
align: 'center',
},
{
title: '页面路由地址',
dataIndex: 'path',
key: 'path',
align: 'center',
},
{
title: '缩列图',
dataIndex: 'photo',
key: 'photo',
align: 'center',
},
{
title: '用户ID',
dataIndex: 'userId',
key: 'userId',
align: 'center',
},
{
title: '排序(数字越小越靠前)',
dataIndex: 'sortNumber',
key: 'sortNumber',
align: 'center',
},
{
title: '备注',
dataIndex: 'comments',
key: 'comments',
align: 'center',
},
{
title: '状态, 0正常, 1冻结',
dataIndex: 'status',
key: 'status',
align: 'center',
},
{
title: '创建时间',
dataIndex: 'createTime',
key: 'createTime',
align: 'center',
sorter: true,
ellipsis: true,
customRender: ({ text }) => toDateString(text, 'yyyy-MM-dd')
},
{
title: '操作',
key: 'action',
width: 180,
fixed: 'right',
align: 'center',
hideInSetting: true
}
]);
/* 搜索 */
const reload = (where?: DesignRecordParam) => {
selection.value = [];
tableRef?.value?.reload({ where: where });
};
/* 打开编辑弹窗 */
const openEdit = (row?: DesignRecord) => {
current.value = row ?? null;
showEdit.value = true;
};
/* 打开批量移动弹窗 */
const openMove = () => {
showMove.value = true;
};
/* 删除单个 */
const remove = (row: DesignRecord) => {
const hide = message.loading('请求中..', 0);
removeDesignRecord(row.designRecordId)
.then((msg) => {
hide();
message.success(msg);
reload();
})
.catch((e) => {
hide();
message.error(e.message);
});
};
/* 批量删除 */
const removeBatch = () => {
if (!selection.value.length) {
message.error('请至少选择一条数据');
return;
}
Modal.confirm({
title: '提示',
content: '确定要删除选中的记录吗?',
icon: createVNode(ExclamationCircleOutlined),
maskClosable: true,
onOk: () => {
const hide = message.loading('请求中..', 0);
removeBatchDesignRecord(selection.value.map((d) => d.designRecordId))
.then((msg) => {
hide();
message.success(msg);
reload();
})
.catch((e) => {
hide();
message.error(e.message);
});
}
});
};
/* 查询 */
const query = () => {
loading.value = true;
};
/* 自定义行属性 */
const customRow = (record: DesignRecord) => {
return {
// 行点击事件
onClick: () => {
// console.log(record);
},
// 行双击事件
onDblclick: () => {
openEdit(record);
}
};
};
query();
</script>
<script lang="ts">
export default {
name: 'DesignRecord'
};
</script>
<style lang="less" scoped></style>

View File

@@ -24,7 +24,7 @@
<a
v-if="record.status == 1"
class="ele-text-success"
@click="openPreview(`http://${record.domain}`)"
@click="openUrl(`https://${record.domain}`)"
>{{ record.domain }}</a
>
<span v-else>
@@ -96,7 +96,7 @@
updateDomain
} from '@/api/cms/domain';
import type { Domain, DomainParam } from '@/api/cms/domain/model';
import { openPreview } from '@/utils/common';
import { openPreview, openUrl } from "@/utils/common";
// 表格实例
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);

View File

@@ -22,7 +22,7 @@
:src="record.icon"
style="margin-right: 5px"
/>
<a @click="openUrl(record.url)">{{ record.name }}</a>
<a @click="openSpmUrl(record.url)">{{ record.name }}</a>
</template>
<template v-if="column.key === 'action'">
<a-space>
@@ -59,7 +59,7 @@
import { pageLink, removeLink } from '@/api/cms/link';
import type { Link, LinkParam } from '@/api/cms/link/model';
import { Menu } from '@/api/system/menu/model';
import { openNew, openUrl } from '@/utils/common';
import { openNew, openSpmUrl, openUrl } from '@/utils/common';
import LinkSearch from './components/link-search.vue';
// 表格实例

View File

@@ -0,0 +1,276 @@
<template>
<a-drawer
width="70%"
:visible="visible"
:title="`${data?.title}`"
placement="left"
:body-style="{ paddingBottom: '28px' }"
@update:visible="updateVisible"
:confirm-loading="loading"
:footer="null"
>
<ele-pro-table
ref="tableRef"
row-key="navigationId"
:columns="columns"
:datasource="datasource"
:customRow="customRow"
tool-class="ele-toolbar-form"
class="sys-org-table"
>
<template #toolbar>
<search
@search="reload"
:selection="selection"
:categoryId="categoryId"
@add="openEdit"
@remove="removeBatch"
@batchMove="openMove"
/>
</template>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'isStatus'">
<a-tag v-if="record.isStatus === 1" color="green">开启</a-tag>
<a-tag v-if="record.isStatus === 2" color="red">关闭</a-tag>
</template>
<template v-if="column.key === 'isFree'">
<a-tag v-if="record.isFree === 1" color="green">免费</a-tag>
<a-tag v-if="record.isFree === 2" color="orange">收费</a-tag>
</template>
<template v-if="column.key === 'action'">
<a-space>
<a @click="moveUp(record)">上移<ArrowUpOutlined /></a>
<a-divider type="vertical" />
<a @click="openEdit(record)">编辑</a>
<a-divider type="vertical" />
<a-popconfirm
title="确定要删除此记录吗?"
@confirm="remove(record)"
>
<a class="ele-text-danger">删除</a>
</a-popconfirm>
</a-space>
</template>
</template>
</ele-pro-table>
<!-- 编辑弹窗 -->
<DesignRecordEdit
v-model:visible="showEdit"
:merchant="data"
:categoryId="categoryId"
:data="current"
@done="reload"
/>
</a-drawer>
</template>
<script lang="ts" setup>
import { createVNode, ref, watch } from 'vue';
import { message, Modal } from 'ant-design-vue';
import {
ArrowUpOutlined,
ExclamationCircleOutlined
} from '@ant-design/icons-vue';
import { EleProTable } from 'ele-admin-pro';
import type {
DatasourceFunction,
ColumnItem
} from 'ele-admin-pro/es/ele-pro-table/types';
import Search from './components/search.vue';
import DesignRecordEdit from './components/designRecordEdit.vue';
import {
removeDesignRecord,
removeBatchDesignRecord,
updateDesignRecord
} from '@/api/cms/designRecord';
import type { DesignRecord } from '@/api/cms/designRecord/model';
import { Navigation } from '@/api/cms/navigation/model';
import { pageDesignRecord } from '@/api/cms/designRecord';
import { DesignRecordParam } from '@/api/cms/designRecord/model';
const props = defineProps<{
// 弹窗是否打开
visible: boolean;
// 修改回显的数据
categoryId?: number | null;
// 导航信息
data?: Navigation;
}>();
const emit = defineEmits<{
(e: 'done'): void;
(e: 'update:visible', visible: boolean): void;
}>();
/* 更新visible */
const updateVisible = (value: boolean) => {
emit('update:visible', value);
};
// 表格实例
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
// 表格选中数据
const selection = ref<DesignRecord[]>([]);
// 当前编辑数据
const current = ref<DesignRecord | null>(null);
// 是否显示编辑弹窗
const showEdit = ref(false);
// 是否显示批量移动弹窗
const showMove = ref(false);
// 加载状态
const loading = ref(true);
// 表格数据源
const datasource: DatasourceFunction = ({
page,
limit,
where,
orders,
filters
}) => {
if (filters) {
where.status = filters.status;
}
where.navigationId = props.categoryId;
return pageDesignRecord({
...where,
...orders,
page,
limit
});
};
// 表格列配置
const columns = ref<ColumnItem[]>([
{
key: 'navigationId',
width: 48,
align: 'center',
fixed: 'left',
hideInSetting: true,
customRender: ({ index }) => index + (tableRef.value?.tableIndex ?? 0)
},
{
title: '组件',
dataIndex: 'title',
key: 'title'
},
{
title: '排序',
dataIndex: 'sortNumber',
key: 'sortNumber',
width: 120,
align: 'center'
},
{
title: '操作',
key: 'action',
width: 180,
fixed: 'right',
align: 'center',
hideInSetting: true
}
]);
/* 搜索 */
const reload = (where?: DesignRecordParam) => {
selection.value = [];
tableRef?.value?.reload({ where: where });
};
/* 打开编辑弹窗 */
const openEdit = (row?: DesignRecord) => {
current.value = row ?? null;
showEdit.value = true;
};
/* 打开批量移动弹窗 */
const openMove = () => {
showMove.value = true;
};
/* 删除单个 */
const remove = (row: DesignRecord) => {
const hide = message.loading('请求中..', 0);
removeDesignRecord(row.periodId)
.then((msg) => {
hide();
message.success(msg);
reload();
})
.catch((e) => {
hide();
message.error(e.message);
});
};
/* 批量删除 */
const removeBatch = () => {
if (!selection.value.length) {
message.error('请至少选择一条数据');
return;
}
Modal.confirm({
title: '提示',
content: '确定要删除选中的记录吗?',
icon: createVNode(ExclamationCircleOutlined),
maskClosable: true,
onOk: () => {
const hide = message.loading('请求中..', 0);
removeBatchDesignRecord(selection.value.map((d) => d.periodId))
.then((msg) => {
hide();
message.success(msg);
reload();
})
.catch((e) => {
hide();
message.error(e.message);
});
}
});
};
// 上移
const moveUp = (row?: DesignRecord) => {
updateDesignRecord({
periodId: row?.periodId,
sortNumber: Number(row?.sortNumber) - 1
}).then((msg) => {
message.success(msg);
reload();
});
};
/* 自定义行属性 */
const customRow = (record: DesignRecord) => {
return {
// 行点击事件
onClick: () => {
// console.log(record);
},
// 行双击事件
onDblclick: () => {
openEdit(record);
}
};
};
watch(
() => props.categoryId,
(categoryId) => {
if (categoryId) {
reload();
}
}
);
</script>
<script lang="ts">
export default {
name: 'DesignRecord'
};
</script>
<style lang="less" scoped></style>

View File

@@ -0,0 +1,250 @@
<!-- 编辑弹窗 -->
<template>
<ele-modal
:width="800"
:visible="visible"
:maskClosable="false"
:maxable="maxable"
:title="isUpdate ? '编辑组件' : '添加组件'"
:body-style="{ paddingBottom: '28px' }"
@update:visible="updateVisible"
@ok="save"
>
<a-form
ref="formRef"
:model="form"
:rules="rules"
:label-col="styleResponsive ? { md: 4, sm: 5, xs: 24 } : { flex: '90px' }"
:wrapper-col="
styleResponsive ? { md: 19, sm: 19, xs: 24 } : { flex: '1' }
"
>
<!-- <a-form-item label="上级" name="parentId">-->
<!-- <a-input-->
<!-- allow-clear-->
<!-- placeholder="请输入上级id, 0是顶级"-->
<!-- v-model:value="form.parentId"-->
<!-- />-->
<!-- </a-form-item>-->
<a-form-item label="选择组件" name="dictCode">
<SelectDictDictionary
dict-code="componentsType"
:placeholder="`选择组件`"
v-model:value="form.dictCode"
@done="chooseComponents"
/>
</a-form-item>
<!-- 公共字段 -->
<a-form-item label="标题" name="title">
<a-input allow-clear placeholder="标题" v-model:value="form.title" />
</a-form-item>
<a-form-item label="样式" name="styles">
<a-input allow-clear placeholder="样式" v-model:value="form.styles" />
</a-form-item>
<!-- 卡片 -->
<!-- <template v-if="form.dictCode == 'Card'">-->
<!-- <a-form-item label="标题" name="title">-->
<!-- <a-input allow-clear placeholder="标题" v-model:value="form.title" />-->
<!-- </a-form-item>-->
<!-- </template>-->
<!-- <a-form-item label="缩列图" name="photo">-->
<!-- <a-input-->
<!-- allow-clear-->
<!-- placeholder="请输入缩列图"-->
<!-- v-model:value="form.photo"-->
<!-- />-->
<!-- </a-form-item>-->
<!-- <a-form-item label="用户ID" name="userId">-->
<!-- <a-input-->
<!-- allow-clear-->
<!-- placeholder="请输入用户ID"-->
<!-- v-model:value="form.userId"-->
<!-- />-->
<!-- </a-form-item>-->
<!-- <a-form-item label="排序(数字越小越靠前)" name="sortNumber">-->
<!-- <a-input-number-->
<!-- :min="0"-->
<!-- :max="9999"-->
<!-- class="ele-fluid"-->
<!-- placeholder="请输入排序号"-->
<!-- v-model:value="form.sortNumber"-->
<!-- />-->
<!-- </a-form-item>-->
<!-- <a-form-item label="备注" name="comments">-->
<!-- <a-textarea-->
<!-- :rows="4"-->
<!-- :maxlength="200"-->
<!-- placeholder="请输入描述"-->
<!-- v-model:value="form.comments"-->
<!-- />-->
<!-- </a-form-item>-->
<a-form-item label="状态" name="status">
<a-radio-group v-model:value="form.status">
<a-radio :value="0">显示</a-radio>
<a-radio :value="1">隐藏</a-radio>
</a-radio-group>
</a-form-item>
</a-form>
</ele-modal>
</template>
<script lang="ts" setup>
import { ref, reactive, watch } from 'vue';
import { Form, message } from 'ant-design-vue';
import { assignObject, uuid } from 'ele-admin-pro';
import { addDesignRecord, updateDesignRecord } from '@/api/cms/designRecord';
import { DesignRecord } from '@/api/cms/designRecord/model';
import { useThemeStore } from '@/store/modules/theme';
import { storeToRefs } from 'pinia';
import { ItemType } from 'ele-admin-pro/es/ele-image-upload/types';
import { FormInstance } from 'ant-design-vue/es/form';
import { FileRecord } from '@/api/system/file/model';
import { DictionaryData } from '@/api/system/dictionary-data/model';
// 是否是修改
const isUpdate = ref(false);
const useForm = Form.useForm;
// 是否开启响应式布局
const themeStore = useThemeStore();
const { styleResponsive } = storeToRefs(themeStore);
const props = defineProps<{
// 弹窗是否打开
visible: boolean;
// 修改回显的数据
data?: DesignRecord | null;
// 导航ID
categoryId?: number;
}>();
const emit = defineEmits<{
(e: 'done'): void;
(e: 'update:visible', visible: boolean): void;
}>();
// 提交状态
const loading = ref(false);
// 是否显示最大化切换按钮
const maxable = ref(true);
// 表格选中数据
const formRef = ref<FormInstance | null>(null);
const images = ref<ItemType[]>([]);
// 用户信息
const form = reactive<DesignRecord>({
id: undefined,
pageId: undefined,
parentId: undefined,
title: undefined,
styles: '',
keywords: undefined,
description: undefined,
path: undefined,
photo: undefined,
userId: undefined,
sortNumber: undefined,
comments: undefined,
status: undefined,
tenantId: undefined,
createTime: undefined,
designRecordId: undefined,
designRecordName: '',
status: 0,
comments: '',
sortNumber: 100
});
/* 更新visible */
const updateVisible = (value: boolean) => {
emit('update:visible', value);
};
// 表单验证规则
const rules = reactive({
dictCode: [
{
required: true,
type: 'string',
message: '请选择组件',
trigger: 'blur'
}
]
});
const chooseImage = (data: FileRecord) => {
images.value.push({
uid: data.id,
url: data.path,
status: 'done'
});
form.image = data.path;
};
const onDeleteItem = (index: number) => {
images.value.splice(index, 1);
form.image = '';
};
const chooseComponents = (data: DictionaryData) => {
form.title = data.dictDataName;
form.dictCode = data.dictDataCode;
};
const { resetFields } = useForm(form, rules);
/* 保存编辑 */
const save = () => {
if (!formRef.value) {
return;
}
formRef.value
.validate()
.then(() => {
loading.value = true;
const formData = {
...form,
navigationId: props.categoryId
};
const saveOrUpdate = isUpdate.value
? updateDesignRecord
: addDesignRecord;
saveOrUpdate(formData)
.then((msg) => {
loading.value = false;
message.success(msg);
updateVisible(false);
emit('done');
})
.catch((e) => {
loading.value = false;
message.error(e.message);
});
})
.catch(() => {});
};
watch(
() => props.visible,
(visible) => {
if (visible) {
images.value = [];
if (props.data) {
assignObject(form, props.data);
if (props.data.image) {
images.value.push({
uid: uuid(),
url: props.data.image,
status: 'done'
});
}
isUpdate.value = true;
} else {
isUpdate.value = false;
}
} else {
resetFields();
}
},
{ immediate: true }
);
</script>

View File

@@ -0,0 +1,42 @@
<!-- 搜索表单 -->
<template>
<a-space :size="10" style="flex-wrap: wrap">
<a-button type="primary" class="ele-btn-icon" @click="add">
<template #icon>
<PlusOutlined />
</template>
<span>添加组件</span>
</a-button>
</a-space>
</template>
<script lang="ts" setup>
import { PlusOutlined } from '@ant-design/icons-vue';
import { watch } from 'vue';
import { DesignParam } from '@/api/cms/design/model';
const props = withDefaults(
defineProps<{
// 选中的角色
selection?: [];
}>(),
{}
);
const emit = defineEmits<{
(e: 'search', where?: DesignParam): void;
(e: 'add'): void;
(e: 'remove'): void;
(e: 'batchMove'): void;
}>();
// 新增
const add = () => {
emit('add');
};
watch(
() => props.selection,
() => {}
);
</script>

View File

@@ -1,382 +1,394 @@
<!-- 编辑弹窗 -->
<template>
<ele-modal
:width="1000"
:visible="visible"
:maskClosable="false"
:maxable="true"
:title="isUpdate ? '编辑内容' : '添加内容'"
:body-style="{ paddingBottom: '28px' }"
@update:visible="updateVisible"
@ok="save"
>
<a-form
ref="formRef"
:model="form"
:rules="rules"
:label-col="styleResponsive ? { md: 2, sm: 5, xs: 24 } : { flex: '90px' }"
:wrapper-col="
<ele-modal
:width="1000"
:visible="visible"
:maskClosable="false"
:maxable="true"
:title="isUpdate ? '页面设置' : '页面设置'"
:body-style="{ paddingBottom: '28px' }"
@update:visible="updateVisible"
@ok="save"
>
<a-form
ref="formRef"
:model="form"
:rules="rules"
:label-col="styleResponsive ? { md: 2, sm: 5, xs: 24 } : { flex: '90px' }"
:wrapper-col="
styleResponsive ? { md: 21, sm: 19, xs: 24 } : { flex: '1' }
"
>
<a-form-item label="页面名称" name="name">
<a-input
allow-clear
:maxlength="100"
placeholder="关于我们"
v-model:value="form.name"
/>
</a-form-item>
<a-form-item label="路由地址" name="path">
<a-input
allow-clear
:maxlength="100"
placeholder="/about"
v-model:value="form.path"
/>
</a-form-item>
<a-form-item label="组件路径" name="component">
<a-input
allow-clear
:maxlength="100"
placeholder="请输入组件路径"
v-model:value="form.component"
/>
</a-form-item>
<a-form-item label="Banner" name="photo">
<SelectFile
:placeholder="`请选择图片`"
:limit="1"
:data="images"
@done="chooseFile"
@del="onDeleteItem"
/>
<!-- <ele-image-upload-->
<!-- v-model:value="images"-->
<!-- :limit="1"-->
<!-- :drag="true"-->
<!-- :upload-handler="uploadHandler"-->
<!-- @upload="onUpload"-->
<!-- />-->
</a-form-item>
<a-form-item label="页面内容" name="content">
<!-- 编辑器 -->
<div class="content">
<tinymce-editor
v-model:value="content"
:disabled="disabled"
:init="config"
placeholder="图片直接粘贴自动上传"
@paste="onPaste"
>
<a-form-item label="Banner" name="photo">
<SelectFile
:placeholder="`请选择图片`"
:limit="1"
:data="images"
@done="chooseFile"
@del="onDeleteItem"
/>
</div>
</a-form-item>
<a-form-item label="排序号" name="sortNumber">
<a-input-number
:min="0"
:max="9999"
class="ele-fluid"
placeholder="请输入排序号"
v-model:value="form.sortNumber"
/>
</a-form-item>
<a-form-item label="状态" name="status">
<a-radio-group v-model:value="form.status">
<a-radio :value="0">开启</a-radio>
<a-radio :value="1">关闭</a-radio>
</a-radio-group>
</a-form-item>
</a-form>
</ele-modal>
</a-form-item>
<a-form-item label="网站SEO">
<a-space direction="vertical"
class="w-full">
<a-input
allow-clear
:maxlength="100"
placeholder="Title"
v-model:value="form.name"
/>
<a-textarea
:rows="4"
:maxlength="200"
placeholder="Description"
v-model:value="form.description"
/>
<a-input
allow-clear
:maxlength="100"
placeholder="Keywords"
v-model:value="form.keywords"
/>
</a-space>
</a-form-item>
<a-form-item label="购买链接">
<a-space direction="vertical"
class="w-full">
<a-input
allow-clear
:maxlength="100"
placeholder="购买链接 buyUrl"
v-model:value="form.buyUrl"
/>
</a-space>
</a-form-item>
<a-form-item label="页面样式">
<a-space direction="vertical"
class="w-full">
<a-textarea
:rows="4"
:maxlength="200"
placeholder="Tailwind CSS风格"
v-model:value="form.styles"
/>
</a-space>
</a-form-item>
<a-form-item label="页面内容" name="content">
<!-- 编辑器 -->
<div class="content">
<tinymce-editor
v-model:value="content"
:disabled="disabled"
:init="config"
placeholder="图片直接粘贴自动上传"
@paste="onPaste"
/>
</div>
</a-form-item>
<a-form-item label="状态" name="status">
<a-radio-group v-model:value="form.status">
<a-radio :value="0">开启</a-radio>
<a-radio :value="1">关闭</a-radio>
</a-radio-group>
</a-form-item>
</a-form>
</ele-modal>
</template>
<script lang="ts" setup>
import { ref, reactive, watch } from 'vue';
import { message } from 'ant-design-vue';
import { uuid} from 'ele-admin-pro';
import { addDesign, updateDesign } from '@/api/cms/design';
import { Design } from '@/api/cms/design/model';
import { useThemeStore } from '@/store/modules/theme';
import { storeToRefs } from 'pinia';
import { FormInstance, Rule } from 'ant-design-vue/es/form';
import { ItemType } from 'ele-admin-pro/es/ele-image-upload/types';
import {uploadFile, uploadOss} from '@/api/system/file';
import TinymceEditor from "@/components/TinymceEditor/index.vue";
import useFormData from "@/utils/use-form-data";
import {removeSiteInfoCache} from "@/api/cms/website";
import {FileRecord} from "@/api/system/file/model";
import { ref, reactive, watch } from 'vue';
import { message } from 'ant-design-vue';
import { uuid} from 'ele-admin-pro';
import { addDesign, updateDesign } from '@/api/cms/design';
import { Design } from '@/api/cms/design/model';
import { useThemeStore } from '@/store/modules/theme';
import { storeToRefs } from 'pinia';
import { FormInstance, Rule } from 'ant-design-vue/es/form';
import { ItemType } from 'ele-admin-pro/es/ele-image-upload/types';
import {uploadFile, uploadOss} from '@/api/system/file';
import TinymceEditor from "@/components/TinymceEditor/index.vue";
import useFormData from "@/utils/use-form-data";
import {removeSiteInfoCache} from "@/api/cms/website";
import {FileRecord} from "@/api/system/file/model";
// 是否是修改
const isUpdate = ref(false);
// 是否开启响应式布局
const themeStore = useThemeStore();
const { styleResponsive } = storeToRefs(themeStore);
const disabled = ref(false);
// 编辑器内容,双向绑定
const content = ref<any>('');
// 是否是修改
const isUpdate = ref(false);
// 是否开启响应式布局
const themeStore = useThemeStore();
const { styleResponsive } = storeToRefs(themeStore);
const disabled = ref(false);
// 编辑器内容,双向绑定
const content = ref<any>('');
const props = defineProps<{
// 弹窗是否打开
visible: boolean;
// 修改回显的数据
data?: Design | null;
}>();
const props = defineProps<{
// 弹窗是否打开
visible: boolean;
// 修改回显的数据
data?: Design | null;
//
categoryId?: number;
}>();
const emit = defineEmits<{
(e: 'done'): void;
(e: 'update:visible', visible: boolean): void;
}>();
const emit = defineEmits<{
(e: 'done'): void;
(e: 'update:visible', visible: boolean): void;
}>();
// 提交状态
const loading = ref(false);
// 已上传数据
const images = ref<ItemType[]>([]);
// 表格选中数据
const formRef = ref<FormInstance | null>(null);
// 提交状态
const loading = ref(false);
// 已上传数据
const images = ref<ItemType[]>([]);
// 表格选中数据
const formRef = ref<FormInstance | null>(null);
// 表单数据
const { form, resetFields, assignFields } = useFormData<Design>({
pageId: undefined,
name: '',
images: '',
path: '',
component: '/custom/index',
content: '',
type: '',
status: 0,
comments: '',
sortNumber: 100,
navigationId: undefined
});
// 表单数据
const { form, resetFields, assignFields } = useFormData<Design>({
pageId: undefined,
name: '',
images: '',
path: '',
component: '/custom/index',
description: '',
keywords: '',
content: '',
buyUrl: '',
type: '',
styles: '',
status: 0,
comments: '',
sortNumber: 100,
navigationId: undefined
});
const editorRef = ref<InstanceType<typeof TinymceEditor> | null>(null);
const config = ref({
height: 500,
images_upload_handler: (blobInfo, success, error) => {
const file = blobInfo.blob();
const formData = new FormData();
formData.append('file', file, file.name);
uploadOss(file).then(res => {
success(res.url)
}).catch((msg) => {
error(msg);
})
return false;
},
// 自定义文件上传(这里使用把选择的文件转成 blob 演示)
file_picker_callback: (callback: any, _value: any, meta: any) => {
const input = document.createElement('input');
input.setAttribute('type', 'file');
// 设定文件可选类型
if (meta.filetype === 'image') {
input.setAttribute('accept', 'image/*');
} else if (meta.filetype === 'media') {
input.setAttribute('accept', 'video/*,.pdf');
const editorRef = ref<InstanceType<typeof TinymceEditor> | null>(null);
const config = ref({
height: 500,
images_upload_handler: (blobInfo, success, error) => {
const file = blobInfo.blob();
const formData = new FormData();
formData.append('file', file, file.name);
uploadOss(file).then(res => {
success(res.url)
}).catch((msg) => {
error(msg);
})
return false;
},
// 自定义文件上传(这里使用把选择的文件转成 blob 演示)
file_picker_callback: (callback: any, _value: any, meta: any) => {
const input = document.createElement('input');
input.setAttribute('type', 'file');
// 设定文件可选类型
if (meta.filetype === 'image') {
input.setAttribute('accept', 'image/*');
} else if (meta.filetype === 'media') {
input.setAttribute('accept', 'video/*,.pdf');
}
input.onchange = () => {
const file = input.files?.[0];
if (!file) {
return;
}
input.onchange = () => {
const file = input.files?.[0];
if (!file) {
if (meta.filetype === 'media') {
if (file.size / 1024 / 1024 > 200) {
editorRef.value?.alert({ content: '大小不能超过 200MB' });
return;
}
if (meta.filetype === 'media') {
if (file.size / 1024 / 1024 > 200) {
editorRef.value?.alert({ content: '大小不能超过 200MB' });
return;
}
if (!file.type.startsWith('video/')) {
editorRef.value?.alert({ content: '只能选择视频文件' });
return;
}
uploadOss(file).then(res => {
callback(res.downloadUrl);
})
if (!file.type.startsWith('video/')) {
editorRef.value?.alert({ content: '只能选择视频文件' });
return;
}
};
input.click();
}
});
/* 粘贴图片上传服务器并插入编辑器 */
const onPaste = (e) => {
const items = (e.clipboardData || e.originalEvent.clipboardData).items;
let hasFile = false;
for (let i = 0; i < items.length; i++) {
if (items[i].type.indexOf('image') !== -1) {
let file = items[i].getAsFile();
const item: ItemType = {
file,
uid: (file as any).lastModified,
name: file.name
};
uploadFile(<File>item.file)
.then((result) => {
const addPath = `<p><img class="content-img" src="${result.url}"></p>`;
content.value = content.value + addPath
})
.catch((e) => {
message.error(e.message);
});
hasFile = true;
uploadOss(file).then(res => {
callback(res.downloadUrl);
})
}
}
if (hasFile) {
e.preventDefault();
}
}
/* 更新visible */
const updateVisible = (value: boolean) => {
emit('update:visible', value);
};
// 表单验证规则
const rules = reactive<Record<string, Rule[]>>({
name: [
{
required: true,
type: 'string',
message: '请填写页面名称',
trigger: 'blur'
}
],
path: [
{
required: true,
type: 'string',
message: '请填写路由地址',
trigger: 'blur'
}
],
component: [
{
required: true,
type: 'string',
message: '请填写组件路径',
trigger: 'blur'
}
]
});
/* 上传事件 */
const uploadHandler = (file: File) => {
const item: ItemType = {
file,
uid: (file as any).uid,
name: file.name
};
if (file.type.startsWith('video')) {
if (file.size / 1024 / 1024 > 200) {
message.error('大小不能超过 200MB');
return;
}
}
if (file.type.startsWith('image')) {
if (file.size / 1024 / 1024 > 5) {
message.error('大小不能超过 5MB');
return;
}
}
input.click();
}
});
onUpload(item);
};
// 上传文件
const onUpload = (item: any) => {
const { file } = item;
uploadFile(file)
.then((data) => {
form.photo = data.path;
images.value.push({
uid: data.id,
url:
file.type == 'video/mp4'
? 'https://oss.wsdns.cn/20240301/6e4e32cb808245d4be336b9486961145.png'
: data.path,
status: 'done'
/* 粘贴图片上传服务器并插入编辑器 */
const onPaste = (e) => {
const items = (e.clipboardData || e.originalEvent.clipboardData).items;
let hasFile = false;
for (let i = 0; i < items.length; i++) {
if (items[i].type.indexOf('image') !== -1) {
let file = items[i].getAsFile();
const item: ItemType = {
file,
uid: (file as any).lastModified,
name: file.name
};
uploadFile(<File>item.file)
.then((result) => {
const addPath = `<p><img class="content-img" src="${result.url}"></p>`;
content.value = content.value + addPath
})
.catch((e) => {
message.error(e.message);
});
})
.catch((e) => {
message.error(e.message);
});
hasFile = true;
}
}
if (hasFile) {
e.preventDefault();
}
}
/* 更新visible */
const updateVisible = (value: boolean) => {
emit('update:visible', value);
};
// 表单验证规则
const rules = reactive<Record<string, Rule[]>>({
name: [
{
required: true,
type: 'string',
message: '请填写页面名称',
trigger: 'blur'
}
],
path: [
{
required: true,
type: 'string',
message: '请填写路由地址',
trigger: 'blur'
}
],
component: [
{
required: true,
type: 'string',
message: '请填写组件路径',
trigger: 'blur'
}
]
});
/* 上传事件 */
const uploadHandler = (file: File) => {
const item: ItemType = {
file,
uid: (file as any).uid,
name: file.name
};
const chooseFile = (data: FileRecord) => {
images.value.push({
uid: data.id,
url: data.downloadUrl,
status: 'done'
});
form.photo = data.downloadUrl;
}
const onDeleteItem = (index: number) => {
images.value.splice(index,1)
form.photo = '';
}
/* 保存编辑 */
const save = () => {
if (!formRef.value) {
if (file.type.startsWith('video')) {
if (file.size / 1024 / 1024 > 200) {
message.error('大小不能超过 200MB');
return;
}
formRef.value
.validate()
.then(() => {
loading.value = true;
const formData = {
...form,
content: content.value
};
const saveOrUpdate = isUpdate.value ? updateDesign : addDesign;
saveOrUpdate(formData)
.then((msg) => {
loading.value = false;
message.success(msg);
updateVisible(false);
// 清除缓存
removeSiteInfoCache('SiteInfo:' + localStorage.getItem('TenantId'));
emit('done');
})
.catch((e) => {
loading.value = false;
message.error(e.message);
});
})
.catch(() => {});
};
}
if (file.type.startsWith('image')) {
if (file.size / 1024 / 1024 > 5) {
message.error('大小不能超过 5MB');
return;
}
}
watch(
() => props.visible,
(visible) => {
if (visible) {
content.value = ''
images.value = []
if (props.data) {
assignFields(props.data);
if(props.data.content){
content.value = props.data.content
}
if(props.data.photo){
images.value.push({
uid: uuid(),
url: props.data.photo,
status: 'done'
})
}
isUpdate.value = !!props.data.pageId;
} else {
isUpdate.value = false;
content.value = '';
resetFields();
onUpload(item);
};
// 上传文件
const onUpload = (item: any) => {
const { file } = item;
uploadFile(file)
.then((data) => {
form.photo = data.path;
images.value.push({
uid: data.id,
url:
file.type == 'video/mp4'
? 'https://oss.wsdns.cn/20240301/6e4e32cb808245d4be336b9486961145.png'
: data.path,
status: 'done'
});
})
.catch((e) => {
message.error(e.message);
});
};
const chooseFile = (data: FileRecord) => {
images.value.push({
uid: data.id,
url: data.downloadUrl,
status: 'done'
});
form.photo = data.downloadUrl;
}
const onDeleteItem = (index: number) => {
images.value.splice(index,1)
form.photo = '';
}
/* 保存编辑 */
const save = () => {
if (!formRef.value) {
return;
}
formRef.value
.validate()
.then(() => {
loading.value = true;
const formData = {
...form,
navigationId: props.categoryId,
content: content.value
};
const saveOrUpdate = isUpdate.value ? updateDesign : addDesign;
saveOrUpdate(formData)
.then((msg) => {
loading.value = false;
message.success(msg);
updateVisible(false);
// 清除缓存
removeSiteInfoCache('SiteInfo:' + localStorage.getItem('TenantId'));
emit('done');
})
.catch((e) => {
loading.value = false;
message.error(e.message);
});
})
.catch(() => {});
};
watch(
() => props.visible,
(visible) => {
if (visible) {
content.value = ''
images.value = []
if (props.data) {
assignFields(props.data);
if(props.data.content){
content.value = props.data.content
}
if(props.data.photo){
images.value.push({
uid: uuid(),
url: props.data.photo,
status: 'done'
})
}
isUpdate.value = !!props.data.pageId;
} else {
isUpdate.value = false;
content.value = '';
resetFields();
formRef.value?.clearValidate();
}
},
{ immediate: true }
);
} else {
resetFields();
formRef.value?.clearValidate();
}
},
{ immediate: true }
);
</script>
<style lang="less">
.sdf{

View File

@@ -113,84 +113,104 @@
<a-col
v-bind="styleResponsive ? { md: 12, sm: 24, xs: 24 } : { span: 12 }"
>
<a-form-item label="位置" name="position">
<a-select
ref="select"
v-model:value="form.position"
style="width: 253px"
>
<a-select-option :value="1">顶部</a-select-option>
<a-select-option :value="2">底部</a-select-option>
</a-select>
<!-- <a-form-item label="模型" name="type">-->
<!-- <a-select-->
<!-- ref="select"-->
<!-- v-model:value="form.type"-->
<!-- style="width: 253px"-->
<!-- @change="onType"-->
<!-- >-->
<!-- <a-select-option :value="0">通用模型</a-select-option>-->
<!-- <a-select-option :value="1">单页内容</a-select-option>-->
<!-- <a-select-option :value="2">新闻分类</a-select-option>-->
<!-- <a-select-option :value="3">新闻详情</a-select-option>-->
<!-- <a-select-option :value="4">表单设计</a-select-option>-->
<!-- <a-select-option :value="5">知识文档</a-select-option>-->
<!-- <a-select-option :value="6">商品分类</a-select-option>-->
<!-- <a-select-option :value="7">商品详情</a-select-option>-->
<!-- <a-select-option :value="9">外部链接</a-select-option>-->
<!-- </a-select>-->
<!-- </a-form-item>-->
<!-- <a-form-item label="位置" name="position">-->
<!-- <a-radio-group v-model:value="form.position">-->
<!-- <a-radio :value="0">全部</a-radio>-->
<!-- <a-radio :value="1">顶部</a-radio>-->
<!-- <a-radio :value="2">底部</a-radio>-->
<!-- </a-radio-group>-->
<!-- </a-form-item>-->
<a-form-item label="位置" name="top">
<a-radio-group v-model:value="form.position" @change="onPosition">
<a-radio-button :value="0">不限</a-radio-button>
<a-radio-button :value="1">顶部</a-radio-button>
<a-radio-button :value="2">底部</a-radio-button>
</a-radio-group>
<!-- <a-space>-->
<!-- <a-switch-->
<!-- checked-children="显示"-->
<!-- un-checked-children="隐藏"-->
<!-- :checked="form.top === 0"-->
<!-- @update:checked="updateTopValue"-->
<!-- />-->
<!-- <a-switch-->
<!-- checked-children="显示"-->
<!-- un-checked-children="隐藏"-->
<!-- :checked="form.bottom === 0"-->
<!-- @update:checked="updateBottomValue"-->
<!-- />-->
<!-- </a-space>-->
</a-form-item>
<a-form-item label="模型" name="type">
<a-select
ref="select"
v-model:value="form.type"
style="width: 253px"
@change="onType"
>
<a-select-option :value="0">通用模型</a-select-option>
<a-select-option :value="1">单页内容</a-select-option>
<a-select-option :value="2">新闻分类</a-select-option>
<a-select-option :value="3">新闻详情</a-select-option>
<a-select-option :value="4">表单设计</a-select-option>
<a-select-option :value="5">知识文档</a-select-option>
<a-select-option :value="6">商品分类</a-select-option>
<a-select-option :value="7">商品详情</a-select-option>
<a-select-option :value="9">外部链接</a-select-option>
</a-select>
<a-form-item label="状态" name="hide">
<a-space>
<a-switch
checked-children="显示"
un-checked-children="隐藏"
:checked="form.hide === 0"
@update:checked="updateHideValue"
/>
</a-space>
</a-form-item>
<a-form-item label="排序" name="sortNumber">
<a-form-item label="排序" name="sortNumber">
<a-input-number
:min="0"
:max="99999"
class="ele-fluid"
placeholder="请输入排序号"
v-model:value="form.sortNumber"
@pressEnter="save"
/>
</a-form-item>
<a-form-item label="是否展示" name="hide">
<a-switch
checked-children=""
un-checked-children=""
:checked="form.hide === 0"
@update:checked="updateHideValue"
/>
</a-form-item>
<a-form-item label="菜单图标" name="icon">
<a-form-item label="图标" name="icon">
<SelectFile
:placeholder="`请选择图片`"
:limit="1"
:data="images"
:width="40"
:width="50"
:height="50"
@done="chooseFile"
@del="onDeleteItem"
/>
</a-form-item>
</a-col>
</a-row>
<div style="margin-bottom: 22px">
<a-divider />
</div>
<a-form-item
label="备注"
name="comments"
:label-col="
styleResponsive ? { md: 3, sm: 4, xs: 24 } : { flex: '90px' }
"
:wrapper-col="
styleResponsive ? { md: 21, sm: 20, xs: 24 } : { flex: '1' }
"
>
<a-textarea
:rows="4"
:maxlength="200"
placeholder="请输入备注信息"
v-model:value="form.comments"
/>
</a-form-item>
<!-- <div style="margin-bottom: 22px">-->
<!-- <a-divider />-->
<!-- </div>-->
<!-- <a-form-item-->
<!-- label="备注"-->
<!-- name="comments"-->
<!-- :label-col="-->
<!-- styleResponsive ? { md: 3, sm: 4, xs: 24 } : { flex: '90px' }-->
<!-- "-->
<!-- :wrapper-col="-->
<!-- styleResponsive ? { md: 21, sm: 20, xs: 24 } : { flex: '1' }-->
<!-- "-->
<!-- >-->
<!-- <a-textarea-->
<!-- :rows="4"-->
<!-- :maxlength="200"-->
<!-- placeholder="请输入备注信息"-->
<!-- v-model:value="form.comments"-->
<!-- />-->
<!-- </a-form-item>-->
</a-form>
</ele-modal>
</template>
@@ -257,6 +277,8 @@
sortNumber: 100,
hide: 0,
position: 1,
top: 1,
bottom: 1,
status: 0,
pageId: 0,
articleCategoryId: 0,
@@ -432,6 +454,21 @@
form.icon = '';
};
const onPosition = (index: number) => {
if (form.position == 0) {
form.top = 0;
form.bottom = 0;
}
if (form.position == 1) {
form.top = 0;
form.bottom = 1;
}
if (form.position == 2) {
form.top = 1;
form.bottom = 0;
}
};
/* 保存编辑 */
const save = () => {
if (!formRef.value) {
@@ -443,10 +480,10 @@
const navigationForm = {
...form
};
if (form.path != '' && form.path?.charAt(0) != '/') {
message.error('路由必须以"/"开头');
return false;
}
// if (form.path != '' && form.path?.charAt(0) != '/') {
// message.error('路由必须以"/"开头');
// return false;
// }
const saveOrUpdate = isUpdate.value ? updateNavigation : addNavigation;
saveOrUpdate(navigationForm)
.then((msg) => {
@@ -472,6 +509,14 @@
form.hide = value ? 0 : 1;
};
const updateTopValue = (value: boolean) => {
form.top = value ? 0 : 1;
};
const updateBottomValue = (value: boolean) => {
form.bottom = value ? 0 : 1;
};
watch(
() => props.visible,
(visible) => {

View File

@@ -26,10 +26,10 @@
<span>新建</span>
</a-button>
<a-button type="dashed" class="ele-btn-icon" @click="expandAll">
展开全部
展开
</a-button>
<a-button type="dashed" class="ele-btn-icon" @click="foldAll">
折叠全部
折叠
</a-button>
<a-divider type="vertical" />
<a-radio-group v-model:value="position" @change="reload">
@@ -82,7 +82,7 @@
style="margin-right: 10px"
v-if="record.image"
/>
<a v-if="!isDirectory(record)" @click="openPreview(record.path)">{{
<a v-if="!isDirectory(record)" @click="openSpmUrl(record.path)">{{
record.title
}}</a>
<a v-else>{{ record.title }}</a>
@@ -92,13 +92,15 @@
<span v-else></span>
</template>
<template v-if="column.key === 'position'">
<span v-if="record.position === 1" class="ele-text-placeholder"
>顶部</span
>
<span v-if="record.position === 2" class="ele-text-placeholder"
>底部</span
>
<span v-if="record.position === 0"></span>
<a-space>
<span v-if="record.top === 0" class="ele-text-placeholder"
>顶部</span
>
<span v-if="record.bottom === 0" class="ele-text-placeholder"
>底部</span
>
<span v-if="record.top === 0 || record.bottom === 0"></span>
</a-space>
</template>
<template v-if="column.key === 'hide'">
<span v-if="record.hide === 0" class="ele-text-success">显示</span>
@@ -108,12 +110,14 @@
</template>
<template v-else-if="column.key === 'action'">
<a-space>
<a class="text-fuchsia-300" @click="openLayout(record)">布局</a>
<a-divider type="vertical" />
<a class="text-gray-400" @click="openDesign(record)">设置</a>
<a-divider type="vertical" />
<a @click="openEdit(null, record.navigationId)">添加</a>
<a-divider type="vertical" />
<a @click="openEdit(record)">修改</a>
<a-divider type="vertical" />
<a @click="openDesign(record)">内容</a>
<a-divider type="vertical" />
<a-popconfirm
placement="topRight"
:disabled="record.home == 1"
@@ -140,6 +144,14 @@
<DesignEdit
v-model:visible="showDesignEdit"
:data="design"
:category-id="categoryId"
@done="reload"
/>
<!-- 页面组件弹窗 -->
<Components
v-model:visible="showDesignRecordEdit"
:data="current"
:category-id="categoryId"
@done="reload"
/>
</div>
@@ -148,7 +160,7 @@
<script lang="ts" setup>
import { ref } from 'vue';
import { message } from 'ant-design-vue/es';
import { ArrowUpOutlined, PlusOutlined } from '@ant-design/icons-vue';
import { PlusOutlined } from '@ant-design/icons-vue';
import type {
DatasourceFunction,
ColumnItem,
@@ -164,16 +176,17 @@
import type { EleProTable } from 'ele-admin-pro/es';
import NavigationEdit from './components/navigation-edit.vue';
import DesignEdit from './components/design-edit.vue';
import Components from './components/components.vue';
import {
listNavigation,
removeNavigation,
updateNavigation
} from '@/api/cms/navigation';
import type { Navigation, NavigationParam } from '@/api/cms/navigation/model';
import { openPreview } from '@/utils/common';
import { openPreview, openSpmUrl, openUrl } from '@/utils/common';
import { getSiteInfo } from '@/api/layout';
import { getDesign } from '@/api/cms/design';
import { Design } from '@/api/cms/design/model';
import { listDesign } from '@/api/cms/design';
// 表格实例
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
@@ -186,7 +199,7 @@
width: 80
},
{
title: '菜单名称',
title: '栏目名称',
dataIndex: 'title',
key: 'title',
showSorterTooltip: false,
@@ -238,14 +251,16 @@
dataIndex: 'createTime',
showSorterTooltip: false,
ellipsis: true,
hideInTable: true,
width: 180,
customRender: ({ text }) => toDateString(text)
},
{
title: '操作',
key: 'action',
width: 200,
align: 'center'
width: 240,
align: 'center',
fixed: 'right'
}
]);
@@ -257,8 +272,11 @@
const showEdit = ref(false);
// 编辑内容
const showDesignEdit = ref(false);
// 页面组件
const showDesignRecordEdit = ref(false);
// 上级分类id
const parentId = ref<number>();
const categoryId = ref<number>();
// 分类数据
const navigationData = ref<Navigation[]>([]);
// 表格展开的行
@@ -277,7 +295,17 @@
const datasource: DatasourceFunction = ({ where }) => {
where = {};
where.title = searchText.value;
where.position = position.value;
// where.position = position.value;
where.top = 0;
where.bottom = undefined;
if (position.value == 1) {
where.top = 0;
where.bottom = undefined;
}
if (position.value == 2) {
where.top = undefined;
where.bottom = 0;
}
where.isMpWeixin = false;
return listNavigation({ ...where });
};
@@ -322,16 +350,12 @@
};
const openDesign = (row?: Navigation) => {
// 设置默认值
design.value = {
listDesign({
navigationId: row?.navigationId,
name: row?.title,
path: `/page-${row?.navigationId}.html`,
component: `/pages/custom/index`
};
getDesign(Number(row?.pageId))
limit: 1
})
.then((res) => {
design.value = res;
design.value = res[0];
})
.catch(() => {})
.finally(() => {
@@ -339,6 +363,12 @@
});
};
const openLayout = (row?: Navigation) => {
current.value = row ?? null;
categoryId.value = row?.navigationId;
showDesignRecordEdit.value = true;
};
/* 删除单个 */
const remove = (row: Navigation) => {
if (row.children?.length) {

View File

@@ -92,12 +92,23 @@
<span v-if="form.version === 30">永久授权</span>
</a-form-item>
<a-form-item label="状态" name="status">
<a-radio-group v-model:value="form.status">
<a-radio :value="0">运行中</a-radio>
<a-radio :value="1">维护中</a-radio>
<a-radio :value="2">已关闭</a-radio>
<a-radio-group
v-model:value="form.status"
:disabled="form.status && form.status > 3"
>
<a-radio :value="1">运行中</a-radio>
<a-radio :value="2">维护中</a-radio>
<a-radio :value="3">已关闭</a-radio>
</a-radio-group>
</a-form-item>
<a-form-item v-if="form.status == 2" label="维护说明" name="statusText">
<a-textarea
:rows="4"
:maxlength="200"
placeholder="状态说明"
v-model:value="form.statusText"
/>
</a-form-item>
</a-form>
</ele-modal>
</template>
@@ -158,7 +169,8 @@
expirationTime: undefined,
sortNumber: undefined,
comments: undefined,
status: undefined
status: undefined,
statusText: undefined
});
const websiteType = ref<SelectProps['options']>([
@@ -279,7 +291,7 @@
loading.value = false;
message.success(msg);
updateVisible(false);
localStorage.setItem('Domain',`${form.prefix}${form.domain}`);
localStorage.setItem('Domain', `${form.prefix}${form.domain}`);
emit('done');
})
.catch((e) => {

View File

@@ -47,14 +47,16 @@
<a-tag v-if="record.version === 30">永久授权</a-tag>
</template>
<template v-if="column.key === 'status'">
<a-tag v-if="record.status === 0" color="green">正常</a-tag>
<a-tag v-if="record.status === 1" color="red">已过期</a-tag>
<a-tag v-if="record.status === 0" color="red">未开通</a-tag>
<a-tag v-if="record.status === 1" color="green">运行中</a-tag>
<a-tag v-if="record.status === 2" color="orange">维护中</a-tag>
<a-tag v-if="record.status === 3" color="red">已关闭</a-tag>
<a-tag v-if="record.status === 4" color="red">已欠费停机</a-tag>
<a-tag v-if="record.status === 5" color="red">违规关停</a-tag>
</template>
<template v-if="column.key === 'action'">
<a-space>
<a @click="openUrl(`${record.prefix}${record.domain}`)">首页</a>
<a-divider type="vertical" />
<a @click="openUrl(record.adminUrl)">后台</a>
<a @click="openEdit(record)">编辑</a>
</a-space>
</template>
</template>
@@ -138,7 +140,7 @@
align: 'center'
},
{
title: '域名',
title: '域名',
dataIndex: 'domain',
key: 'domain',
align: 'center'