style(api): 统一代码格式化规范

- 调整 import 语句格式,统一空格和引号风格
- 修复函数参数跨行时的格式对齐问题
- 清理多余空行和注释中的空白字符
- 统一对象属性结尾逗号的使用规范
- 规范化字符串拼接和模板语法的格式
- 优化长参数列表的换行和缩进格式
This commit is contained in:
2026-01-17 17:04:46 +08:00
parent 836fd4d8d0
commit 4af50e6449
416 changed files with 24611 additions and 22733 deletions

View File

@@ -61,10 +61,14 @@
/>
</div>
<div class="flex flex-col gap-2 mt-2">
<div class="w-[500px] space-y-2" v-for="(_, index) in images" :key="index">
<div
class="w-[500px] space-y-2"
v-for="(_, index) in images"
:key="index"
>
<a-input
v-model:value="images[index].title"
:placeholder="`请输入图片标题${index+1}`"
:placeholder="`请输入图片标题${index + 1}`"
/>
<a-input
v-model:value="images[index].path"
@@ -132,10 +136,7 @@
</a-form-item>
</template>
<template v-if="form.type == 4">
<a-form-item
label="文本"
name="comments"
>
<a-form-item label="文本" name="comments">
<a-textarea
:rows="4"
:maxlength="200"
@@ -145,10 +146,7 @@
</a-form-item>
</template>
<a-form-item label="链接" name="path" v-if="form.type == 4">
<a-input
v-model:value="form.path"
placeholder="https://"
/>
<a-input v-model:value="form.path" placeholder="https://" />
</a-form-item>
<a-form-item label="尺寸">
<a-space>
@@ -167,7 +165,9 @@
/>
</a-space>
<div class="pt-2">
<span class="text-gray-400">广告位尺寸大小(默认值100% * 500px)</span>
<span class="text-gray-400"
>广告位尺寸大小(默认值100% * 500px)</span
>
</div>
</a-form-item>
<a-form-item label="位置">
@@ -175,7 +175,7 @@
allow-clear
:tree-data="navigationList"
tree-default-expand-all
style="width: 500px;"
style="width: 500px"
placeholder="请选择所属栏目"
:value="form.categoryId || undefined"
:listHeight="700"
@@ -191,7 +191,12 @@
v-model:value="form.style"
/>
<div class="pt-2 none">
<a class="text-sm text-gray-400" href="https://tailwindcss.com/docs/padding" target="_blank">Tailwind 使用说明</a>
<a
class="text-sm text-gray-400"
href="https://tailwindcss.com/docs/padding"
target="_blank"
>Tailwind 使用说明</a
>
</div>
</a-form-item>
<a-form-item label="描述" name="comments" v-if="form.type != 4">
@@ -221,182 +226,185 @@
</template>
<script lang="ts" setup>
import {ref, reactive, watch} from 'vue';
import {Form, message} from 'ant-design-vue';
import {assignObject} from 'ele-admin-pro';
import {addCmsAd, updateCmsAd} from '@/api/cms/cmsAd';
import {CmsAd} from '@/api/cms/cmsAd/model';
import {useThemeStore} from '@/store/modules/theme';
import {storeToRefs} from 'pinia';
import {FormInstance} from 'ant-design-vue/es/form';
import {useI18n} from 'vue-i18n';
import {FileRecord} from '@/api/system/file/model';
import {CmsNavigation} from "@/api/cms/cmsNavigation/model";
import { ref, reactive, watch } from 'vue';
import { Form, message } from 'ant-design-vue';
import { assignObject } from 'ele-admin-pro';
import { addCmsAd, updateCmsAd } from '@/api/cms/cmsAd';
import { CmsAd } from '@/api/cms/cmsAd/model';
import { useThemeStore } from '@/store/modules/theme';
import { storeToRefs } from 'pinia';
import { FormInstance } from 'ant-design-vue/es/form';
import { useI18n } from 'vue-i18n';
import { FileRecord } from '@/api/system/file/model';
import { CmsNavigation } from '@/api/cms/cmsNavigation/model';
// 是否是修改
const isUpdate = ref(false);
const disabled = ref(true);
const useForm = Form.useForm;
// 是否开启响应式布局
const themeStore = useThemeStore();
const {styleResponsive} = storeToRefs(themeStore);
// 是否是修改
const isUpdate = ref(false);
const disabled = ref(true);
const useForm = Form.useForm;
// 是否开启响应式布局
const themeStore = useThemeStore();
const { styleResponsive } = storeToRefs(themeStore);
const props = defineProps<{
// 弹窗是否打开
visible: boolean;
// 修改回显的数据
data?: CmsAd | null;
// 栏目导航
navigationList?: CmsNavigation[];
}>();
const props = defineProps<{
// 弹窗是否打开
visible: boolean;
// 修改回显的数据
data?: CmsAd | null;
// 栏目导航
navigationList?: CmsNavigation[];
}>();
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<any[]>([]);
const {locale} = useI18n();
// 是否显示最大化切换按钮
const maxable = ref(true);
// 表格选中数据
const formRef = ref<FormInstance | null>(null);
// 提交状态
const loading = ref(false);
// 已上传数据
const images = ref<any[]>([]);
const { locale } = useI18n();
// 是否显示最大化切换按钮
const maxable = ref(true);
// 表格选中数据
const formRef = ref<FormInstance | null>(null);
// 用户信息
const form = reactive<CmsAd>({
adId: undefined,
type: undefined,
code: undefined,
categoryId: undefined,
name: '',
style: '',
images: '',
imageList: undefined,
width: '',
height: '',
path: '',
status: 0,
comments: '',
lang: locale.value || undefined,
sortNumber: 100,
merchantId: undefined
});
/* 更新visible */
const updateVisible = (value: boolean) => {
emit('update:visible', value);
};
// 表单验证规则
const rules = {
name: [
{
required: true,
message: '请输入标题',
trigger: 'blur'
}
],
type: [
{
required: true,
message: '请选择类型',
trigger: 'blur'
}
],
images: [
{
required: true,
message: '请上传图片或视频',
trigger: 'blur',
validator: (_rule: any, _: string) => {
return new Promise<void>((resolve, reject) => {
if (images.value.length == 0) {
return reject('请上传图片或视频文件');
}
return resolve();
});
}
}
]
};
const {resetFields} = useForm(form, rules);
const chooseFile = (data: FileRecord) => {
images.value.push({
uid: data.id,
url: data.downloadUrl + '?x-oss-process=image/resize,m_fixed,w_2000/quality,Q_90',
status: 'done',
title: '', // 初始化标题为空
path: '' // 初始化链接为空
// 用户信息
const form = reactive<CmsAd>({
adId: undefined,
type: undefined,
code: undefined,
categoryId: undefined,
name: '',
style: '',
images: '',
imageList: undefined,
width: '',
height: '',
path: '',
status: 0,
comments: '',
lang: locale.value || undefined,
sortNumber: 100,
merchantId: undefined
});
form.images = data.downloadUrl + '?x-oss-process=image/resize,m_fixed,w_2000/quality,Q_90';
};
const onDeleteItem = (index: number) => {
images.value.splice(index, 1);
form.images = '';
};
/* 更新visible */
const updateVisible = (value: boolean) => {
emit('update:visible', value);
};
// 选择栏目
const onCategoryId = (id: number) => {
form.categoryId = id;
};
const onTypeChange = () => {
disabled.value = !disabled.value;
}
/* 保存编辑 */
const save = () => {
if (!formRef.value) {
return;
}
formRef.value
.validate()
.then(() => {
loading.value = true;
const formData = {
...form,
images: JSON.stringify(images.value)
};
const saveOrUpdate = isUpdate.value ? updateCmsAd : addCmsAd;
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) {
if (props.data) {
assignObject(form, props.data);
images.value = props.data.imageList;
isUpdate.value = true;
} else {
images.value = [];
disabled.value = true;
isUpdate.value = false;
// 表单验证规则
const rules = {
name: [
{
required: true,
message: '请输入标题',
trigger: 'blur'
}
} else {
resetFields();
],
type: [
{
required: true,
message: '请选择类型',
trigger: 'blur'
}
],
images: [
{
required: true,
message: '请上传图片或视频',
trigger: 'blur',
validator: (_rule: any, _: string) => {
return new Promise<void>((resolve, reject) => {
if (images.value.length == 0) {
return reject('请上传图片或视频文件');
}
return resolve();
});
}
}
]
};
const { resetFields } = useForm(form, rules);
const chooseFile = (data: FileRecord) => {
images.value.push({
uid: data.id,
url:
data.downloadUrl +
'?x-oss-process=image/resize,m_fixed,w_2000/quality,Q_90',
status: 'done',
title: '', // 初始化标题为空
path: '' // 初始化链接为空
});
form.images =
data.downloadUrl +
'?x-oss-process=image/resize,m_fixed,w_2000/quality,Q_90';
};
const onDeleteItem = (index: number) => {
images.value.splice(index, 1);
form.images = '';
};
// 选择栏目
const onCategoryId = (id: number) => {
form.categoryId = id;
};
const onTypeChange = () => {
disabled.value = !disabled.value;
};
/* 保存编辑 */
const save = () => {
if (!formRef.value) {
return;
}
},
{immediate: true}
);
formRef.value
.validate()
.then(() => {
loading.value = true;
const formData = {
...form,
images: JSON.stringify(images.value)
};
const saveOrUpdate = isUpdate.value ? updateCmsAd : addCmsAd;
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) {
if (props.data) {
assignObject(form, props.data);
images.value = props.data.imageList;
isUpdate.value = true;
} else {
images.value = [];
disabled.value = true;
isUpdate.value = false;
}
} else {
resetFields();
}
},
{ immediate: true }
);
</script>

View File

@@ -1,7 +1,7 @@
<!-- 搜索表单 -->
<template>
<a-space :size="10" style="flex-wrap: wrap">
<a-button type="primary" class="ele-btn-icon" @click="add">
<a-button type="primary" class="ele-btn-icon" @click="add">
<template #icon>
<PlusOutlined />
</template>
@@ -32,9 +32,9 @@
<script lang="ts" setup>
import { PlusOutlined } from '@ant-design/icons-vue';
import { watch } from 'vue';
import {CmsNavigation} from "@/api/cms/cmsNavigation/model";
import {CmsAdParam} from "@/api/cms/cmsAd/model";
import useSearch from "@/utils/use-search";
import { CmsNavigation } from '@/api/cms/cmsNavigation/model';
import { CmsAdParam } from '@/api/cms/cmsAd/model';
import useSearch from '@/utils/use-search';
const props = withDefaults(
defineProps<{

View File

@@ -28,8 +28,8 @@
<a-tag v-if="record.type == 4">文本</a-tag>
</template>
<template v-if="column.key === 'name'">
<div>{{ record.name }}</div>
<div class="text-gray-400">{{ record.code }}</div>
<div>{{ record.name }}</div>
<div class="text-gray-400">{{ record.code }}</div>
</template>
<template v-if="column.key === 'categoryId'">
<span class="text-gray-400">{{ record.categoryName }}</span>
@@ -44,7 +44,7 @@
v-for="item in record.imageList"
:key="index"
>
<a-image :src="item.url" :width="80"/>
<a-image :src="item.url" :width="80" />
</template>
<template v-if="record.type == 4">
{{ record.comments }}
@@ -58,7 +58,7 @@
<template v-if="column.key === 'action'">
<a-space>
<a @click="openEdit(record)">修改</a>
<a-divider type="vertical"/>
<a-divider type="vertical" />
<a-popconfirm
title="确定要删除此记录吗?"
@confirm="remove(record)"
@@ -72,217 +72,222 @@
</a-card>
<!-- 编辑弹窗 -->
<CmsAdEdit v-model:visible="showEdit" :data="current" :navigationList="navigationList" @done="reload"/>
<CmsAdEdit
v-model:visible="showEdit"
:data="current"
:navigationList="navigationList"
@done="reload"
/>
</a-page-header>
</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 {toTreeData} from 'ele-admin-pro';
import {useI18n} from 'vue-i18n';
import type {
DatasourceFunction,
ColumnItem
} from 'ele-admin-pro/es/ele-pro-table/types';
import Search from './components/search.vue';
import CmsAdEdit from './components/cmsAdEdit.vue';
import {pageCmsAd, removeCmsAd, removeBatchCmsAd} from '@/api/cms/cmsAd';
import type {CmsAd, CmsAdParam} from '@/api/cms/cmsAd/model';
import {CmsNavigation} from "@/api/cms/cmsNavigation/model";
import {listCmsNavigation} from "@/api/cms/cmsNavigation";
import {getPageTitle} from "@/utils/common";
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 { toTreeData } from 'ele-admin-pro';
import { useI18n } from 'vue-i18n';
import type {
DatasourceFunction,
ColumnItem
} from 'ele-admin-pro/es/ele-pro-table/types';
import Search from './components/search.vue';
import CmsAdEdit from './components/cmsAdEdit.vue';
import { pageCmsAd, removeCmsAd, removeBatchCmsAd } from '@/api/cms/cmsAd';
import type { CmsAd, CmsAdParam } from '@/api/cms/cmsAd/model';
import { CmsNavigation } from '@/api/cms/cmsNavigation/model';
import { listCmsNavigation } from '@/api/cms/cmsNavigation';
import { getPageTitle } from '@/utils/common';
// 表格实例
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
// 国际化
const {locale} = useI18n();
// 表格选中数据
const selection = ref<CmsAd[]>([]);
// 当前编辑数据
const current = ref<CmsAd | null>(null);
// 是否显示编辑弹窗
const showEdit = ref(false);
// 是否显示批量移动弹窗
const showMove = ref(false);
// 栏目数据
const navigationList = ref<CmsNavigation[]>();
// 加载状态
const loading = ref(true);
// 表格实例
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
// 国际化
const { locale } = useI18n();
// 表格选中数据
const selection = ref<CmsAd[]>([]);
// 当前编辑数据
const current = ref<CmsAd | null>(null);
// 是否显示编辑弹窗
const showEdit = ref(false);
// 是否显示批量移动弹窗
const showMove = ref(false);
// 栏目数据
const navigationList = ref<CmsNavigation[]>();
// 加载状态
const loading = ref(true);
// 表格数据源
const datasource: DatasourceFunction = ({
page,
limit,
where,
orders,
filters
}) => {
if (filters) {
where.status = filters.status;
}
where.lang = locale.value || undefined;
return pageCmsAd({
...where,
...orders,
// 表格数据源
const datasource: DatasourceFunction = ({
page,
limit
});
};
// 表格列配置
const columns = ref<ColumnItem[]>([
{
title: 'ID',
width: 90,
dataIndex: 'adId'
},
{
title: '名称',
dataIndex: 'name',
key: 'name',
ellipsis: true,
width: 180
},
{
title: '类型',
dataIndex: 'type',
key: 'type',
align: 'center',
width: 120
},
{
title: '广告图片',
dataIndex: 'images',
key: 'images'
},
{
title: '栏目名称',
dataIndex: 'categoryId',
key: 'categoryId',
align: 'center',
width: 180
},
{
title: '状态',
dataIndex: 'status',
key: 'status',
align: 'center',
width: 120
},
{
title: '操作',
key: 'action',
width: 120,
fixed: 'right',
align: 'center',
hideInSetting: true
}
]);
/* 搜索 */
const reload = (where?: CmsAdParam) => {
selection.value = [];
tableRef?.value?.reload({where: where});
};
/* 打开编辑弹窗 */
const openEdit = (row?: CmsAd) => {
current.value = row ?? null;
showEdit.value = true;
};
/* 打开批量移动弹窗 */
const openMove = () => {
showMove.value = true;
};
/* 删除单个 */
const remove = (row: CmsAd) => {
const hide = message.loading('请求中..', 0);
removeCmsAd(row.adId)
.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);
removeBatchCmsAd(selection.value.map((d) => d.adId))
.then((msg) => {
hide();
message.success(msg);
reload();
})
.catch((e) => {
hide();
message.error(e.message);
});
limit,
where,
orders,
filters
}) => {
if (filters) {
where.status = filters.status;
}
});
};
/* 查询 */
const query = () => {
loading.value = true;
// 加载栏目数据
if (!navigationList.value) {
listCmsNavigation({}).then((res) => {
navigationList.value = toTreeData({
data: res?.map((d) => {
d.value = d.navigationId;
d.label = d.title;
if (!d.component) {
d.disabled = true;
}
return d;
}),
idField: 'navigationId',
parentIdField: 'parentId'
});
where.lang = locale.value || undefined;
return pageCmsAd({
...where,
...orders,
page,
limit
});
}
};
};
/* 自定义行属性 */
const customRow = (record: CmsAd) => {
return {
// 行点击事件
onClick: () => {
// console.log(record);
// 表格列配置
const columns = ref<ColumnItem[]>([
{
title: 'ID',
width: 90,
dataIndex: 'adId'
},
// 行双击事件
onDblclick: () => {
openEdit(record);
{
title: '名称',
dataIndex: 'name',
key: 'name',
ellipsis: true,
width: 180
},
{
title: '类型',
dataIndex: 'type',
key: 'type',
align: 'center',
width: 120
},
{
title: '广告图片',
dataIndex: 'images',
key: 'images'
},
{
title: '栏目名称',
dataIndex: 'categoryId',
key: 'categoryId',
align: 'center',
width: 180
},
{
title: '状态',
dataIndex: 'status',
key: 'status',
align: 'center',
width: 120
},
{
title: '操作',
key: 'action',
width: 120,
fixed: 'right',
align: 'center',
hideInSetting: true
}
]);
/* 搜索 */
const reload = (where?: CmsAdParam) => {
selection.value = [];
tableRef?.value?.reload({ where: where });
};
/* 打开编辑弹窗 */
const openEdit = (row?: CmsAd) => {
current.value = row ?? null;
showEdit.value = true;
};
/* 打开批量移动弹窗 */
const openMove = () => {
showMove.value = true;
};
/* 删除单个 */
const remove = (row: CmsAd) => {
const hide = message.loading('请求中..', 0);
removeCmsAd(row.adId)
.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);
removeBatchCmsAd(selection.value.map((d) => d.adId))
.then((msg) => {
hide();
message.success(msg);
reload();
})
.catch((e) => {
hide();
message.error(e.message);
});
}
});
};
/* 查询 */
const query = () => {
loading.value = true;
// 加载栏目数据
if (!navigationList.value) {
listCmsNavigation({}).then((res) => {
navigationList.value = toTreeData({
data: res?.map((d) => {
d.value = d.navigationId;
d.label = d.title;
if (!d.component) {
d.disabled = true;
}
return d;
}),
idField: 'navigationId',
parentIdField: 'parentId'
});
});
}
};
};
query();
/* 自定义行属性 */
const customRow = (record: CmsAd) => {
return {
// 行点击事件
onClick: () => {
// console.log(record);
},
// 行双击事件
onDblclick: () => {
openEdit(record);
}
};
};
query();
</script>
<script lang="ts">
export default {
name: 'CmsAd'
};
export default {
name: 'CmsAd'
};
</script>
<style lang="less" scoped></style>

View File

@@ -172,7 +172,9 @@
const formData = {
...form
};
const saveOrUpdate = isUpdate.value ? updateCmsAdRecord : addCmsAdRecord;
const saveOrUpdate = isUpdate.value
? updateCmsAdRecord
: addCmsAdRecord;
saveOrUpdate(formData)
.then((msg) => {
loading.value = false;
@@ -195,12 +197,12 @@
images.value = [];
if (props.data) {
assignObject(form, props.data);
if(props.data.image){
if (props.data.image) {
images.value.push({
uid: uuid(),
url: props.data.image,
status: 'done'
})
});
}
isUpdate.value = true;
} else {

View File

@@ -45,7 +45,11 @@
</a-card>
<!-- 编辑弹窗 -->
<CmsAdRecordEdit v-model:visible="showEdit" :data="current" @done="reload" />
<CmsAdRecordEdit
v-model:visible="showEdit"
:data="current"
@done="reload"
/>
</div>
</div>
</template>
@@ -62,8 +66,15 @@
} from 'ele-admin-pro/es/ele-pro-table/types';
import Search from './components/search.vue';
import CmsAdRecordEdit from './components/cmsAdRecordEdit.vue';
import { pageCmsAdRecord, removeCmsAdRecord, removeBatchCmsAdRecord } from '@/api/cms/cmsAdRecord';
import type { CmsAdRecord, CmsAdRecordParam } from '@/api/cms/cmsAdRecord/model';
import {
pageCmsAdRecord,
removeCmsAdRecord,
removeBatchCmsAdRecord
} from '@/api/cms/cmsAdRecord';
import type {
CmsAdRecord,
CmsAdRecordParam
} from '@/api/cms/cmsAdRecord/model';
// 表格实例
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
@@ -105,49 +116,49 @@
dataIndex: 'adRecordId',
key: 'adRecordId',
align: 'center',
width: 90,
width: 90
},
{
title: '广告标题',
dataIndex: 'title',
key: 'title',
align: 'center',
align: 'center'
},
{
title: '图片地址',
dataIndex: 'path',
key: 'path',
align: 'center',
align: 'center'
},
{
title: '链接地址',
dataIndex: 'url',
key: 'url',
align: 'center',
align: 'center'
},
{
title: '广告位ID',
dataIndex: 'adId',
key: 'adId',
align: 'center',
align: 'center'
},
{
title: '排序(数字越小越靠前)',
dataIndex: 'sortNumber',
key: 'sortNumber',
align: 'center',
align: 'center'
},
{
title: '备注',
dataIndex: 'comments',
key: 'comments',
align: 'center',
align: 'center'
},
{
title: '状态, 0正常, 1冻结',
dataIndex: 'status',
key: 'status',
align: 'center',
align: 'center'
},
{
title: '创建时间',

View File

@@ -42,12 +42,12 @@
<script lang="ts" setup>
import { ref, reactive, watch } from 'vue';
import { Form, message } from 'ant-design-vue';
import { updateBatchCmsArticle } from "@/api/cms/cmsArticle";
import { updateBatchCmsArticle } from '@/api/cms/cmsArticle';
import { CmsArticle } from '@/api/cms/cmsArticle/model';
import { useThemeStore } from '@/store/modules/theme';
import { storeToRefs } from 'pinia';
import { FormInstance, RuleObject } from 'ant-design-vue/es/form';
import { CmsNavigation } from "@/api/cms/cmsNavigation/model";
import { CmsNavigation } from '@/api/cms/cmsNavigation/model';
// 是否是修改
const useForm = Form.useForm;
@@ -145,17 +145,17 @@
content: [
{
required: true,
type: "string",
message: "请输入文章内容",
trigger: "blur",
type: 'string',
message: '请输入文章内容',
trigger: 'blur',
validator: async (_rule: RuleObject, value: string) => {
if (content.value == "") {
return Promise.reject("请输入文字内容");
if (content.value == '') {
return Promise.reject('请输入文字内容');
}
return Promise.resolve();
}
}
],
]
});
// 选择栏目
@@ -175,18 +175,19 @@
.validate()
.then(() => {
loading.value = true;
props.selection?.map(d => d.articleId)
props.selection?.map((d) => d.articleId);
updateBatchCmsArticle({
ids: props.selection?.map(d => d.articleId),
ids: props.selection?.map((d) => d.articleId),
data: {
categoryId: form.categoryId
}
}).then((msg) => {
message.success(msg);
loading.value = false;
updateVisible(false);
emit('done');
})
.then((msg) => {
message.success(msg);
loading.value = false;
updateVisible(false);
emit('done');
})
.catch((e) => {
message.error(e.message);
});

View File

@@ -1,9 +1,9 @@
<!-- 搜索表单 -->
<template>
<a-space :size="10" style="flex-wrap: wrap">
<a-button type="primary" class="ele-btn-icon" @click="add">
<a-button type="primary" class="ele-btn-icon" @click="add">
<template #icon>
<PlusOutlined/>
<PlusOutlined />
</template>
<span>添加</span>
</a-button>
@@ -15,7 +15,7 @@
@click="removeBatch"
>
<template #icon>
<DeleteOutlined/>
<DeleteOutlined />
</template>
<span>批量删除</span>
</a-button>
@@ -26,19 +26,20 @@
>
移动
</a-button>
<a-radio-group v-model:value="type" @change="handleSearch" v-if="setting.setting?.articleReview">
<a-radio-group
v-model:value="type"
@change="handleSearch"
v-if="setting.setting?.articleReview"
>
<a-radio-button type="text" value="已发布"
>已发布({{ articleCount?.totalNum }})
</a-radio-button
>
>已发布({{ articleCount?.totalNum }})
</a-radio-button>
<a-radio-button value="待审核"
>待审核({{ articleCount?.totalNum2 }})
</a-radio-button
>
>待审核({{ articleCount?.totalNum2 }})
</a-radio-button>
<a-radio-button value="已驳回"
>已驳回({{ articleCount?.totalNum3 }})
</a-radio-button
>
>已驳回({{ articleCount?.totalNum3 }})
</a-radio-button>
</a-radio-group>
<a-tree-select
allow-clear
@@ -68,259 +69,261 @@
@search="reload"
/>
<a-button type="text" @click="reset">重置</a-button>
<a-button type="text" @click="handleExport">导出xls</a-button>
<a-button type="text" @click="openImport">导入xls</a-button>
<a-button type="text" @click="handleExport">导出xls</a-button>
<a-button type="text" @click="openImport">导入xls</a-button>
</a-space>
<!-- 导入弹窗 -->
<import v-model:visible="showImport" @done="reload"/>
<import v-model:visible="showImport" @done="reload" />
</template>
<script lang="ts" setup>
import {DeleteOutlined, PlusOutlined} from '@ant-design/icons-vue';
import {ref, watch} from 'vue';
import {message} from 'ant-design-vue';
import {utils, writeFile} from 'xlsx';
import {getCount, listCmsArticle} from '@/api/cms/cmsArticle';
import type {CmsArticle, CmsArticleCount, CmsArticleParam} from '@/api/cms/cmsArticle/model';
import useSearch from '@/utils/use-search';
import {CmsNavigation} from '@/api/cms/cmsNavigation/model';
import dayjs from 'dayjs';
import Import from "./Import.vue";
import {useWebsiteSettingStore} from "@/store/modules/setting";
import {openUrl} from "@/utils/common";
import { DeleteOutlined, PlusOutlined } from '@ant-design/icons-vue';
import { ref, watch } from 'vue';
import { message } from 'ant-design-vue';
import { utils, writeFile } from 'xlsx';
import { getCount, listCmsArticle } from '@/api/cms/cmsArticle';
import type {
CmsArticle,
CmsArticleCount,
CmsArticleParam
} from '@/api/cms/cmsArticle/model';
import useSearch from '@/utils/use-search';
import { CmsNavigation } from '@/api/cms/cmsNavigation/model';
import dayjs from 'dayjs';
import Import from './Import.vue';
import { useWebsiteSettingStore } from '@/store/modules/setting';
import { openUrl } from '@/utils/common';
const props = withDefaults(
defineProps<{
// 选中的角色
selection?: CmsArticle[];
merchantId?: number;
navigationList?: CmsNavigation[];
categoryId?: number;
}>(),
{}
);
const props = withDefaults(
defineProps<{
// 选中的角色
selection?: CmsArticle[];
merchantId?: number;
navigationList?: CmsNavigation[];
categoryId?: number;
}>(),
{}
);
const type = ref<string>();
const setting = useWebsiteSettingStore();
// 统计数据
const articleCount = ref<CmsArticleCount>();
const showChooseDict = ref<boolean>(false);
// 请求状态
const loading = ref(false);
const xlsFileName = ref<string>();
const articleList = ref<CmsArticle[]>([]);
// 是否显示用户导入弹窗
const showImport = ref(false);
const type = ref<string>();
const setting = useWebsiteSettingStore();
// 统计数据
const articleCount = ref<CmsArticleCount>();
const showChooseDict = ref<boolean>(false);
// 请求状态
const loading = ref(false);
const xlsFileName = ref<string>();
const articleList = ref<CmsArticle[]>([]);
// 是否显示用户导入弹窗
const showImport = ref(false);
// 表单数据
const {where, resetFields} = useSearch<CmsArticleParam>({
articleId: undefined,
model: undefined,
categoryId: undefined,
merchantId: undefined,
keywords: '',
sceneType: undefined,
userId: undefined
});
const emit = defineEmits<{
(e: 'search', where?: CmsArticleParam): void;
(e: 'add'): void;
(e: 'remove'): void;
(e: 'batchMove'): void;
}>();
// 新增
const add = () => {
emit('add');
};
// 批量删除
const removeBatch = () => {
emit('remove');
};
// 批量更新
const updateBatch = () => {
emit('batchMove');
}
/* 打开编辑弹窗 */
const openImport = () => {
showImport.value = true;
};
const handleSearch = (e) => {
const text = e.target.value;
if (text === '已发布') {
where.status = 0;
}
if (text === '待审核') {
where.status = 1;
}
if (text === '已驳回') {
where.status = 2;
}
emit('search', where);
};
const reload = () => {
getCount(where).then((data: any) => {
articleCount.value = data;
// 表单数据
const { where, resetFields } = useSearch<CmsArticleParam>({
articleId: undefined,
model: undefined,
categoryId: undefined,
merchantId: undefined,
keywords: '',
sceneType: undefined,
userId: undefined
});
emit('search', where);
};
// 按模型查找
const chooseModel = () => {
emit('search', where);
};
const emit = defineEmits<{
(e: 'search', where?: CmsArticleParam): void;
(e: 'add'): void;
(e: 'remove'): void;
(e: 'batchMove'): void;
}>();
// 按分类查询
const onCategoryId = (id: number) => {
where.categoryId = id;
emit('search', where);
};
// 新增
const add = () => {
emit('add');
};
// 导出
const handleExport = async () => {
loading.value = true;
const array: (string | number)[][] = [
[
'文章ID',
'文章标题',
'封面图片',
'所属栏目',
'栏目ID',
'父级栏目名称',
'父级栏目ID',
'文章内容',
'摘要',
'来源',
'实际阅读量',
'作者',
'发布时间',
'类型',
'模型',
'详情页模板',
'话题',
'关键词',
'产品概述',
'显示方式',
'客户端',
'文件列表',
'视频地址',
'点赞数',
'评论数',
'推荐',
'用户ID',
'商户ID',
'语言',
'排序',
`状态`,
'租户ID'
]
];
// 批量删除
const removeBatch = () => {
emit('remove');
};
// 按搜索结果导出
where.sceneType = 'Content';
await listCmsArticle(where)
.then((list) => {
articleList.value = list;
list?.forEach((d: CmsArticle) => {
array.push([
`${d.articleId}`,
`${d.title}`,
`${d.image}`,
`${d.categoryName}`,
`${d.categoryId}`,
`${d.parentName}`,
`${d.parentId}`,
`${d.content}`,
`${d.comments}`,
`${d.source}`,
`${d.actualViews}`,
`${d.author}`,
`${d.createTime}`,
`${d.type}`,
`${d.model}`,
`${d.detail}`,
`${d.topic}`,
`${d.tags}`,
`${d.overview}`,
`${d.showType}`,
`${d.platform}`,
`${d.files}`,
`${d.video}`,
`${d.likes}`,
`${d.commentNumbers}`,
`${d.recommend}`,
`${d.userId}`,
`${d.merchantId}`,
`${d.lang}`,
`${d.sortNumber}`,
`${d.status}`,
`${d.tenantId}`
]);
});
const sheetName = `导出文章列表${dayjs(new Date()).format('YYYYMMDD')}`;
const workbook = {
SheetNames: [sheetName],
Sheets: {}
};
const sheet = utils.aoa_to_sheet(array);
workbook.Sheets[sheetName] = sheet;
// 设置列宽
sheet['!cols'] = [
{wch: 10},
{wch: 40},
{wch: 20},
{wch: 20},
{wch: 60},
{wch: 15},
{wch: 10},
{wch: 10},
{wch: 20},
{wch: 10},
{wch: 20}
];
message.loading('正在导出...');
setTimeout(() => {
writeFile(
workbook,
`${
where.createTimeEnd ? xlsFileName.value + '_' : ''
}${sheetName}.xlsx`
);
loading.value = false;
}, 1000);
})
.catch((msg) => {
message.error(msg);
loading.value = false;
})
.finally(() => {
});
// 批量更新
const updateBatch = () => {
emit('batchMove');
};
};
/* 打开编辑弹窗 */
const openImport = () => {
showImport.value = true;
};
/* 重置 */
const reset = () => {
resetFields();
type.value = undefined;
reload();
openUrl(`/website/article`)
};
watch(
() => props.merchantId,
() => {
if (props.categoryId) {
where.categoryId = props.categoryId;
const handleSearch = (e) => {
const text = e.target.value;
if (text === '已发布') {
where.status = 0;
}
if (text === '待审核') {
where.status = 1;
}
if (text === '已驳回') {
where.status = 2;
}
emit('search', where);
};
const reload = () => {
getCount(where).then((data: any) => {
articleCount.value = data;
});
emit('search', where);
};
// 按模型查找
const chooseModel = () => {
emit('search', where);
};
// 按分类查询
const onCategoryId = (id: number) => {
where.categoryId = id;
emit('search', where);
};
// 导出
const handleExport = async () => {
loading.value = true;
const array: (string | number)[][] = [
[
'文章ID',
'文章标题',
'封面图片',
'所属栏目',
'栏目ID',
'父级栏目名称',
'父级栏目ID',
'文章内容',
'摘要',
'来源',
'实际阅读量',
'作者',
'发布时间',
'类型',
'模型',
'详情页模板',
'话题',
'关键词',
'产品概述',
'显示方式',
'客户端',
'文件列表',
'视频地址',
'点赞数',
'评论数',
'推荐',
'用户ID',
'商户ID',
'语言',
'排序',
`状态`,
'租户ID'
]
];
// 按搜索结果导出
where.sceneType = 'Content';
await listCmsArticle(where)
.then((list) => {
articleList.value = list;
list?.forEach((d: CmsArticle) => {
array.push([
`${d.articleId}`,
`${d.title}`,
`${d.image}`,
`${d.categoryName}`,
`${d.categoryId}`,
`${d.parentName}`,
`${d.parentId}`,
`${d.content}`,
`${d.comments}`,
`${d.source}`,
`${d.actualViews}`,
`${d.author}`,
`${d.createTime}`,
`${d.type}`,
`${d.model}`,
`${d.detail}`,
`${d.topic}`,
`${d.tags}`,
`${d.overview}`,
`${d.showType}`,
`${d.platform}`,
`${d.files}`,
`${d.video}`,
`${d.likes}`,
`${d.commentNumbers}`,
`${d.recommend}`,
`${d.userId}`,
`${d.merchantId}`,
`${d.lang}`,
`${d.sortNumber}`,
`${d.status}`,
`${d.tenantId}`
]);
});
const sheetName = `导出文章列表${dayjs(new Date()).format('YYYYMMDD')}`;
const workbook = {
SheetNames: [sheetName],
Sheets: {}
};
const sheet = utils.aoa_to_sheet(array);
workbook.Sheets[sheetName] = sheet;
// 设置列宽
sheet['!cols'] = [
{ wch: 10 },
{ wch: 40 },
{ wch: 20 },
{ wch: 20 },
{ wch: 60 },
{ wch: 15 },
{ wch: 10 },
{ wch: 10 },
{ wch: 20 },
{ wch: 10 },
{ wch: 20 }
];
message.loading('正在导出...');
setTimeout(() => {
writeFile(
workbook,
`${
where.createTimeEnd ? xlsFileName.value + '_' : ''
}${sheetName}.xlsx`
);
loading.value = false;
}, 1000);
})
.catch((msg) => {
message.error(msg);
loading.value = false;
})
.finally(() => {});
};
/* 重置 */
const reset = () => {
resetFields();
type.value = undefined;
reload();
},
{immediate: true}
);
openUrl(`/website/article`);
};
watch(
() => props.merchantId,
() => {
if (props.categoryId) {
where.categoryId = props.categoryId;
}
reload();
},
{ immediate: true }
);
</script>

View File

@@ -58,22 +58,22 @@
:color="record.status == 0 ? 'green' : 'red'"
class="cursor-pointer"
@click="onUpdate(record)"
>{{ record.statusText }}
>{{ record.statusText }}
</a-tag>
</template>
<template v-if="column.key === 'recommend'">
<a-space @click="onRecommend(record)">
<span v-if="record.recommend === 1" class="ele-text-success"
><CheckOutlined
><CheckOutlined
/></span>
<span v-else class="ele-text-placeholder"><CloseOutlined/></span>
<span v-else class="ele-text-placeholder"><CloseOutlined /></span>
</a-space>
</template>
<template v-if="column.key === 'action'">
<a @click="onShare(record)">预览</a>
<a-divider type="vertical"/>
<a-divider type="vertical" />
<a @click="openEdit(record)">修改</a>
<a-divider type="vertical"/>
<a-divider type="vertical" />
<a-popconfirm
title="确定要删除此记录吗?"
@confirm="remove(record)"
@@ -113,336 +113,330 @@
</template>
<script lang="ts" setup>
import {createVNode, ref, watch} from 'vue';
import {message, Modal} from 'ant-design-vue';
import {useI18n} from 'vue-i18n';
import {
CheckOutlined,
CloseOutlined,
ExclamationCircleOutlined
} from '@ant-design/icons-vue';
import type {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 ArticleEdit from './components/articleEdit.vue';
import ArticleUpdate from './components/articleUpdate.vue';
import {
pageCmsArticle,
removeCmsArticle,
removeBatchCmsArticle,
updateCmsArticle, getCmsArticle
} from '@/api/cms/cmsArticle';
import type {CmsArticle, CmsArticleParam} from '@/api/cms/cmsArticle/model';
import {formatNumber} from 'ele-admin-pro/es';
import router from '@/router';
import {toTreeData} from 'ele-admin-pro';
import {
detail,
getPageTitle
} from '@/utils/common';
import {listCmsNavigation} from '@/api/cms/cmsNavigation';
import {CmsNavigation} from '@/api/cms/cmsNavigation/model';
import {CmsArticleCategory} from '@/api/cms/cmsArticleCategory/model';
import {listCmsArticleCategory} from '@/api/cms/cmsArticleCategory';
import Qrcode from '@/components/QrCode/index.vue';
import { createVNode, ref, watch } from 'vue';
import { message, Modal } from 'ant-design-vue';
import { useI18n } from 'vue-i18n';
import {
CheckOutlined,
CloseOutlined,
ExclamationCircleOutlined
} from '@ant-design/icons-vue';
import type { 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 ArticleEdit from './components/articleEdit.vue';
import ArticleUpdate from './components/articleUpdate.vue';
import {
pageCmsArticle,
removeCmsArticle,
removeBatchCmsArticle,
updateCmsArticle,
getCmsArticle
} from '@/api/cms/cmsArticle';
import type { CmsArticle, CmsArticleParam } from '@/api/cms/cmsArticle/model';
import { formatNumber } from 'ele-admin-pro/es';
import router from '@/router';
import { toTreeData } from 'ele-admin-pro';
import { detail, getPageTitle } from '@/utils/common';
import { listCmsNavigation } from '@/api/cms/cmsNavigation';
import { CmsNavigation } from '@/api/cms/cmsNavigation/model';
import { CmsArticleCategory } from '@/api/cms/cmsArticleCategory/model';
import { listCmsArticleCategory } from '@/api/cms/cmsArticleCategory';
import Qrcode from '@/components/QrCode/index.vue';
// 表格实例
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
// 国际化
const {locale} = useI18n();
// 表格选中数据
const selection = ref<CmsArticle[]>([]);
// 当前编辑数据
const current = ref<CmsArticle | null>(null);
// 是否显示编辑弹窗
const showEdit = ref(false);
// 是否显示批量移动弹窗
const showMove = ref(false);
// 店铺ID
const merchantId = ref<number>();
// 栏目ID
const categoryId = ref<number>();
// 栏目数据
const navigationList = ref<CmsNavigation[]>();
// 文章分类
const categoryList = ref<CmsArticleCategory[]>();
// 是否显示二维码
const showQrcode = ref(false);
// 表格实例
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
// 国际化
const { locale } = useI18n();
// 表格选中数据
const selection = ref<CmsArticle[]>([]);
// 当前编辑数据
const current = ref<CmsArticle | null>(null);
// 是否显示编辑弹窗
const showEdit = ref(false);
// 是否显示批量移动弹窗
const showMove = ref(false);
// 店铺ID
const merchantId = ref<number>();
// 栏目ID
const categoryId = ref<number>();
// 栏目数据
const navigationList = ref<CmsNavigation[]>();
// 文章分类
const categoryList = ref<CmsArticleCategory[]>();
// 是否显示二维码
const showQrcode = ref(false);
// 表格数据源
const datasource: DatasourceFunction = ({page, limit, where, orders}) => {
if (categoryId.value) {
where.categoryId = categoryId.value;
}
where.lang = locale.value || undefined;
return pageCmsArticle({
...where,
...orders,
page,
limit
});
};
// 表格列配置
const columns = ref<ColumnItem[]>([
{
title: 'ID',
dataIndex: 'articleId',
key: 'articleId',
align: 'center',
width: 90
},
{
title: '封面图',
dataIndex: 'image',
key: 'image',
width: 120,
align: 'center'
},
{
title: '文章标题',
dataIndex: 'title',
key: 'title'
},
{
title: '栏目名称',
dataIndex: 'categoryName',
key: 'categoryName',
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',
hideInTable: true
},
{
title: '推荐',
dataIndex: 'recommend',
key: 'recommend',
sorter: true,
width: 120,
align: 'center'
},
{
title: '状态',
dataIndex: 'status',
key: 'status',
sorter: true,
width: 120,
align: 'center'
},
{
title: '排序号',
dataIndex: 'sortNumber',
key: 'sortNumber',
sorter: true,
width: 120,
align: 'center'
},
{
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?: CmsArticleParam) => {
selection.value = [];
tableRef?.value?.reload({where: where});
};
/* 打开编辑弹窗 */
const openEdit = async (row?: CmsArticle) => {
current.value = row ?? null;
if(row?.articleId){
current.value = await getCmsArticle(row?.articleId);
}
showEdit.value = true;
};
/* 打开批量移动弹窗 */
const openMove = () => {
showMove.value = true;
};
// 分享二维码
const onShare = (row?: CmsArticle) => {
const data = {
isMobile: true,
...row
// 表格数据源
const datasource: DatasourceFunction = ({ page, limit, where, orders }) => {
if (categoryId.value) {
where.categoryId = categoryId.value;
}
where.lang = locale.value || undefined;
return pageCmsArticle({
...where,
...orders,
page,
limit
});
};
data.qrcode = `${detail(data)}`;
data.url = `${detail(row)}`;
current.value = data ?? null;
showQrcode.value = true;
};
const hideShare = () => {
showQrcode.value = false;
};
// 表格列配置
const columns = ref<ColumnItem[]>([
{
title: 'ID',
dataIndex: 'articleId',
key: 'articleId',
align: 'center',
width: 90
},
{
title: '封面图',
dataIndex: 'image',
key: 'image',
width: 120,
align: 'center'
},
{
title: '文章标题',
dataIndex: 'title',
key: 'title'
},
{
title: '栏目名称',
dataIndex: 'categoryName',
key: 'categoryName',
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',
hideInTable: true
},
{
title: '推荐',
dataIndex: 'recommend',
key: 'recommend',
sorter: true,
width: 120,
align: 'center'
},
{
title: '状态',
dataIndex: 'status',
key: 'status',
sorter: true,
width: 120,
align: 'center'
},
{
title: '排序号',
dataIndex: 'sortNumber',
key: 'sortNumber',
sorter: true,
width: 120,
align: 'center'
},
{
title: '创建时间',
dataIndex: 'createTime',
key: 'createTime',
align: 'center',
width: 180,
sorter: true
},
{
title: '操作',
key: 'action',
width: 180,
fixed: 'right',
align: 'center',
hideInSetting: true
}
]);
const onUpdate = (row?: CmsArticle) => {
const status = row?.status == 0 ? 1 : 0;
updateCmsArticle({...row, status}).then((msg) => {
message.success(msg);
reload();
});
};
/* 搜索 */
const reload = (where?: CmsArticleParam) => {
selection.value = [];
tableRef?.value?.reload({ where: where });
};
const onRecommend = (row: CmsArticle) => {
updateCmsArticle({
...row,
recommend: row.recommend == 1 ? 0 : 1
}).then((msg) => {
message.success(msg);
reload();
});
};
/* 打开编辑弹窗 */
const openEdit = async (row?: CmsArticle) => {
current.value = row ?? null;
if (row?.articleId) {
current.value = await getCmsArticle(row?.articleId);
}
showEdit.value = true;
};
/* 删除单个 */
const remove = (row: CmsArticle) => {
const hide = message.loading('请求中..', 0);
removeCmsArticle(row.articleId)
.then((msg) => {
hide();
/* 打开批量移动弹窗 */
const openMove = () => {
showMove.value = true;
};
// 分享二维码
const onShare = (row?: CmsArticle) => {
const data = {
isMobile: true,
...row
};
data.qrcode = `${detail(data)}`;
data.url = `${detail(row)}`;
current.value = data ?? null;
showQrcode.value = true;
};
const hideShare = () => {
showQrcode.value = false;
};
const onUpdate = (row?: CmsArticle) => {
const status = row?.status == 0 ? 1 : 0;
updateCmsArticle({ ...row, status }).then((msg) => {
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);
removeBatchCmsArticle(selection.value.map((d) => d.articleId))
.then((msg) => {
hide();
message.success(msg);
reload();
})
.catch((e) => {
hide();
message.error(e.message);
});
}
});
};
/* 自定义行属性 */
const customRow = (record: CmsArticle) => {
return {
// 行点击事件
onClick: () => {
// console.log(record);
},
// 行双击事件
onDblclick: () => {
openEdit(record);
}
};
};
// 加载栏目数据
if (!navigationList.value) {
listCmsNavigation({}).then((res) => {
navigationList.value = toTreeData({
data: res?.map((d) => {
d.value = d.navigationId;
d.label = d.title;
if (!d.component) {
d.disabled = true;
}
if (
d.model == 'index' ||
d.model == 'page' ||
d.model == 'order'
) {
d.disabled = true;
}
return d;
}),
idField: 'navigationId',
parentIdField: 'parentId'
});
});
}
// 加载文章分类
if (!categoryList.value) {
listCmsArticleCategory({}).then((res) => {
categoryList.value = toTreeData({
data: res?.map((d) => {
d.value = d.categoryId;
d.label = d.title;
return d;
}),
idField: 'categoryId',
parentIdField: 'parentId'
});
});
}
watch(
() => router.currentRoute.value.query,
(query) => {
if (query) {
categoryId.value = Number(query.id);
const onRecommend = (row: CmsArticle) => {
updateCmsArticle({
...row,
recommend: row.recommend == 1 ? 0 : 1
}).then((msg) => {
message.success(msg);
reload();
});
};
/* 删除单个 */
const remove = (row: CmsArticle) => {
const hide = message.loading('请求中..', 0);
removeCmsArticle(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;
}
},
{immediate: true}
);
Modal.confirm({
title: '提示',
content: '确定要删除选中的记录吗?',
icon: createVNode(ExclamationCircleOutlined),
maskClosable: true,
onOk: () => {
const hide = message.loading('请求中..', 0);
removeBatchCmsArticle(selection.value.map((d) => d.articleId))
.then((msg) => {
hide();
message.success(msg);
reload();
})
.catch((e) => {
hide();
message.error(e.message);
});
}
});
};
/* 自定义行属性 */
const customRow = (record: CmsArticle) => {
return {
// 行点击事件
onClick: () => {
// console.log(record);
},
// 行双击事件
onDblclick: () => {
openEdit(record);
}
};
};
// 加载栏目数据
if (!navigationList.value) {
listCmsNavigation({}).then((res) => {
navigationList.value = toTreeData({
data: res?.map((d) => {
d.value = d.navigationId;
d.label = d.title;
if (!d.component) {
d.disabled = true;
}
if (d.model == 'index' || d.model == 'page' || d.model == 'order') {
d.disabled = true;
}
return d;
}),
idField: 'navigationId',
parentIdField: 'parentId'
});
});
}
// 加载文章分类
if (!categoryList.value) {
listCmsArticleCategory({}).then((res) => {
categoryList.value = toTreeData({
data: res?.map((d) => {
d.value = d.categoryId;
d.label = d.title;
return d;
}),
idField: 'categoryId',
parentIdField: 'parentId'
});
});
}
watch(
() => router.currentRoute.value.query,
(query) => {
if (query) {
categoryId.value = Number(query.id);
reload();
}
},
{ immediate: true }
);
</script>
<script lang="ts">
export default {
name: 'CmsArticleV2'
};
export default {
name: 'CmsArticleV2'
};
</script>

View File

@@ -40,17 +40,15 @@
v-model:value="form.type"
/>
</a-form-item>
<a-form-item
label="分类图片"
name="image">
<SelectFile
:placeholder="`请选择图片`"
:limit="1"
:data="images"
@done="chooseImage"
@del="onDeleteItem"
/>
</a-form-item>
<a-form-item label="分类图片" name="image">
<SelectFile
:placeholder="`请选择图片`"
:limit="1"
:data="images"
@done="chooseImage"
@del="onDeleteItem"
/>
</a-form-item>
<a-form-item label="上级分类ID" name="parentId">
<a-input
allow-clear
@@ -110,7 +108,10 @@
v-model:value="form.comments"
/>
</a-form-item>
<a-form-item label="是否隐藏, 0否, 1是(仅注册路由不显示在左侧菜单)" name="hide">
<a-form-item
label="是否隐藏, 0否, 1是(仅注册路由不显示在左侧菜单)"
name="hide"
>
<a-input
allow-clear
placeholder="请输入是否隐藏, 0否, 1是(仅注册路由不显示在左侧菜单)"
@@ -159,7 +160,10 @@
import { ref, reactive, watch } from 'vue';
import { Form, message } from 'ant-design-vue';
import { assignObject, uuid } from 'ele-admin-pro';
import { addCmsArticleCategory, updateCmsArticleCategory } from '@/api/cms/cmsArticleCategory';
import {
addCmsArticleCategory,
updateCmsArticleCategory
} from '@/api/cms/cmsArticleCategory';
import { CmsArticleCategory } from '@/api/cms/cmsArticleCategory/model';
import { useThemeStore } from '@/store/modules/theme';
import { storeToRefs } from 'pinia';
@@ -263,7 +267,9 @@
const formData = {
...form
};
const saveOrUpdate = isUpdate.value ? updateCmsArticleCategory : addCmsArticleCategory;
const saveOrUpdate = isUpdate.value
? updateCmsArticleCategory
: addCmsArticleCategory;
saveOrUpdate(formData)
.then((msg) => {
loading.value = false;
@@ -286,12 +292,12 @@
images.value = [];
if (props.data) {
assignObject(form, props.data);
if(props.data.image){
if (props.data.image) {
images.value.push({
uid: uuid(),
url: props.data.image,
status: 'done'
})
});
}
isUpdate.value = true;
} else {

View File

@@ -45,7 +45,11 @@
</a-card>
<!-- 编辑弹窗 -->
<CmsArticleCategoryEdit v-model:visible="showEdit" :data="current" @done="reload" />
<CmsArticleCategoryEdit
v-model:visible="showEdit"
:data="current"
@done="reload"
/>
</div>
</div>
</template>
@@ -62,8 +66,15 @@
} from 'ele-admin-pro/es/ele-pro-table/types';
import Search from './components/search.vue';
import CmsArticleCategoryEdit from './components/cmsArticleCategoryEdit.vue';
import { pageCmsArticleCategory, removeCmsArticleCategory, removeBatchCmsArticleCategory } from '@/api/cms/cmsArticleCategory';
import type { CmsArticleCategory, CmsArticleCategoryParam } from '@/api/cms/cmsArticleCategory/model';
import {
pageCmsArticleCategory,
removeCmsArticleCategory,
removeBatchCmsArticleCategory
} from '@/api/cms/cmsArticleCategory';
import type {
CmsArticleCategory,
CmsArticleCategoryParam
} from '@/api/cms/cmsArticleCategory/model';
// 表格实例
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
@@ -105,109 +116,109 @@
dataIndex: 'categoryId',
key: 'categoryId',
align: 'center',
width: 90,
width: 90
},
{
title: '分类标识',
dataIndex: 'categoryCode',
key: 'categoryCode',
align: 'center',
align: 'center'
},
{
title: '分类名称',
dataIndex: 'title',
key: 'title',
align: 'center',
align: 'center'
},
{
title: '类型 0列表 1单页 2外链',
dataIndex: 'type',
key: 'type',
align: 'center',
align: 'center'
},
{
title: '分类图片',
dataIndex: 'image',
key: 'image',
align: 'center',
align: 'center'
},
{
title: '上级分类ID',
dataIndex: 'parentId',
key: 'parentId',
align: 'center',
align: 'center'
},
{
title: '路由/链接地址',
dataIndex: 'path',
key: 'path',
align: 'center',
align: 'center'
},
{
title: '组件路径',
dataIndex: 'component',
key: 'component',
align: 'center',
align: 'center'
},
{
title: '绑定的页面',
dataIndex: 'pageId',
key: 'pageId',
align: 'center',
align: 'center'
},
{
title: '用户ID',
dataIndex: 'userId',
key: 'userId',
align: 'center',
align: 'center'
},
{
title: '文章数量',
dataIndex: 'count',
key: 'count',
align: 'center',
align: 'center'
},
{
title: '排序(数字越小越靠前)',
dataIndex: 'sortNumber',
key: 'sortNumber',
align: 'center',
align: 'center'
},
{
title: '备注',
dataIndex: 'comments',
key: 'comments',
align: 'center',
align: 'center'
},
{
title: '是否隐藏, 0否, 1是(仅注册路由不显示在左侧菜单)',
dataIndex: 'hide',
key: 'hide',
align: 'center',
align: 'center'
},
{
title: '是否推荐',
dataIndex: 'recommend',
key: 'recommend',
align: 'center',
align: 'center'
},
{
title: '是否显示在首页',
dataIndex: 'showIndex',
key: 'showIndex',
align: 'center',
align: 'center'
},
{
title: '状态, 0正常, 1禁用',
dataIndex: 'status',
key: 'status',
align: 'center',
align: 'center'
},
{
title: '是否删除, 0否, 1是',
dataIndex: 'deleted',
key: 'deleted',
align: 'center',
align: 'center'
},
{
title: '创建时间',
@@ -222,7 +233,7 @@
title: '修改时间',
dataIndex: 'updateTime',
key: 'updateTime',
align: 'center',
align: 'center'
},
{
title: '操作',
@@ -279,7 +290,9 @@
maskClosable: true,
onOk: () => {
const hide = message.loading('请求中..', 0);
removeBatchCmsArticleCategory(selection.value.map((d) => d.cmsArticleCategoryId))
removeBatchCmsArticleCategory(
selection.value.map((d) => d.cmsArticleCategoryId)
)
.then((msg) => {
hide();
message.success(msg);

View File

@@ -120,7 +120,10 @@
import { ref, reactive, watch } from 'vue';
import { Form, message } from 'ant-design-vue';
import { assignObject, uuid } from 'ele-admin-pro';
import { addCmsArticleComment, updateCmsArticleComment } from '@/api/cms/cmsArticleComment';
import {
addCmsArticleComment,
updateCmsArticleComment
} from '@/api/cms/cmsArticleComment';
import { CmsArticleComment } from '@/api/cms/cmsArticleComment/model';
import { useThemeStore } from '@/store/modules/theme';
import { storeToRefs } from 'pinia';
@@ -220,7 +223,9 @@
const formData = {
...form
};
const saveOrUpdate = isUpdate.value ? updateCmsArticleComment : addCmsArticleComment;
const saveOrUpdate = isUpdate.value
? updateCmsArticleComment
: addCmsArticleComment;
saveOrUpdate(formData)
.then((msg) => {
loading.value = false;
@@ -243,12 +248,12 @@
images.value = [];
if (props.data) {
assignObject(form, props.data);
if(props.data.image){
if (props.data.image) {
images.value.push({
uid: uuid(),
url: props.data.image,
status: 'done'
})
});
}
isUpdate.value = true;
} else {

View File

@@ -45,7 +45,11 @@
</a-card>
<!-- 编辑弹窗 -->
<CmsArticleCommentEdit v-model:visible="showEdit" :data="current" @done="reload" />
<CmsArticleCommentEdit
v-model:visible="showEdit"
:data="current"
@done="reload"
/>
</div>
</div>
</template>
@@ -62,8 +66,15 @@
} from 'ele-admin-pro/es/ele-pro-table/types';
import Search from './components/search.vue';
import CmsArticleCommentEdit from './components/cmsArticleCommentEdit.vue';
import { pageCmsArticleComment, removeCmsArticleComment, removeBatchCmsArticleComment } from '@/api/cms/cmsArticleComment';
import type { CmsArticleComment, CmsArticleCommentParam } from '@/api/cms/cmsArticleComment/model';
import {
pageCmsArticleComment,
removeCmsArticleComment,
removeBatchCmsArticleComment
} from '@/api/cms/cmsArticleComment';
import type {
CmsArticleComment,
CmsArticleCommentParam
} from '@/api/cms/cmsArticleComment/model';
// 表格实例
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
@@ -105,79 +116,79 @@
dataIndex: 'commentId',
key: 'commentId',
align: 'center',
width: 90,
width: 90
},
{
title: '文章ID',
dataIndex: 'articleId',
key: 'articleId',
align: 'center',
align: 'center'
},
{
title: '评分 (10好评 20中评 30差评)',
dataIndex: 'score',
key: 'score',
align: 'center',
align: 'center'
},
{
title: '评价内容',
dataIndex: 'content',
key: 'content',
align: 'center',
align: 'center'
},
{
title: '是否为图片评价',
dataIndex: 'isPicture',
key: 'isPicture',
align: 'center',
align: 'center'
},
{
title: '评论者ID',
dataIndex: 'userId',
key: 'userId',
align: 'center',
align: 'center'
},
{
title: '被评价者ID',
dataIndex: 'toUserId',
key: 'toUserId',
align: 'center',
align: 'center'
},
{
title: '回复的评论ID',
dataIndex: 'replyCommentId',
key: 'replyCommentId',
align: 'center',
align: 'center'
},
{
title: '回复者ID',
dataIndex: 'replyUserId',
key: 'replyUserId',
align: 'center',
align: 'center'
},
{
title: '排序(数字越小越靠前)',
dataIndex: 'sortNumber',
key: 'sortNumber',
align: 'center',
align: 'center'
},
{
title: '备注',
dataIndex: 'comments',
key: 'comments',
align: 'center',
align: 'center'
},
{
title: '状态, 0未读, 1已读',
dataIndex: 'status',
key: 'status',
align: 'center',
align: 'center'
},
{
title: '是否删除, 0否, 1是',
dataIndex: 'deleted',
key: 'deleted',
align: 'center',
align: 'center'
},
{
title: '创建时间',
@@ -192,7 +203,7 @@
title: '修改时间',
dataIndex: 'updateTime',
key: 'updateTime',
align: 'center',
align: 'center'
},
{
title: '操作',
@@ -249,7 +260,9 @@
maskClosable: true,
onOk: () => {
const hide = message.loading('请求中..', 0);
removeBatchCmsArticleComment(selection.value.map((d) => d.cmsArticleCommentId))
removeBatchCmsArticleComment(
selection.value.map((d) => d.cmsArticleCommentId)
)
.then((msg) => {
hide();
message.success(msg);

View File

@@ -41,7 +41,10 @@
import { ref, reactive, watch } from 'vue';
import { Form, message } from 'ant-design-vue';
import { assignObject, uuid } from 'ele-admin-pro';
import { addCmsArticleContent, updateCmsArticleContent } from '@/api/cms/cmsArticleContent';
import {
addCmsArticleContent,
updateCmsArticleContent
} from '@/api/cms/cmsArticleContent';
import { CmsArticleContent } from '@/api/cms/cmsArticleContent/model';
import { useThemeStore } from '@/store/modules/theme';
import { storeToRefs } from 'pinia';
@@ -135,7 +138,9 @@
const formData = {
...form
};
const saveOrUpdate = isUpdate.value ? updateCmsArticleContent : addCmsArticleContent;
const saveOrUpdate = isUpdate.value
? updateCmsArticleContent
: addCmsArticleContent;
saveOrUpdate(formData)
.then((msg) => {
loading.value = false;
@@ -158,12 +163,12 @@
images.value = [];
if (props.data) {
assignObject(form, props.data);
if(props.data.image){
if (props.data.image) {
images.value.push({
uid: uuid(),
url: props.data.image,
status: 'done'
})
});
}
isUpdate.value = true;
} else {

View File

@@ -45,7 +45,11 @@
</a-card>
<!-- 编辑弹窗 -->
<CmsArticleContentEdit v-model:visible="showEdit" :data="current" @done="reload" />
<CmsArticleContentEdit
v-model:visible="showEdit"
:data="current"
@done="reload"
/>
</div>
</div>
</template>
@@ -62,8 +66,15 @@
} from 'ele-admin-pro/es/ele-pro-table/types';
import Search from './components/search.vue';
import CmsArticleContentEdit from './components/cmsArticleContentEdit.vue';
import { pageCmsArticleContent, removeCmsArticleContent, removeBatchCmsArticleContent } from '@/api/cms/cmsArticleContent';
import type { CmsArticleContent, CmsArticleContentParam } from '@/api/cms/cmsArticleContent/model';
import {
pageCmsArticleContent,
removeCmsArticleContent,
removeBatchCmsArticleContent
} from '@/api/cms/cmsArticleContent';
import type {
CmsArticleContent,
CmsArticleContentParam
} from '@/api/cms/cmsArticleContent/model';
// 表格实例
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
@@ -105,19 +116,19 @@
dataIndex: 'id',
key: 'id',
align: 'center',
width: 90,
width: 90
},
{
title: '文章ID',
dataIndex: 'articleId',
key: 'articleId',
align: 'center',
align: 'center'
},
{
title: '文章内容',
dataIndex: 'content',
key: 'content',
align: 'center',
align: 'center'
},
{
title: '创建时间',
@@ -183,7 +194,9 @@
maskClosable: true,
onOk: () => {
const hide = message.loading('请求中..', 0);
removeBatchCmsArticleContent(selection.value.map((d) => d.cmsArticleContentId))
removeBatchCmsArticleContent(
selection.value.map((d) => d.cmsArticleContentId)
)
.then((msg) => {
hide();
message.success(msg);

View File

@@ -41,7 +41,10 @@
import { ref, reactive, watch } from 'vue';
import { Form, message } from 'ant-design-vue';
import { assignObject, uuid } from 'ele-admin-pro';
import { addCmsArticleCount, updateCmsArticleCount } from '@/api/cms/cmsArticleCount';
import {
addCmsArticleCount,
updateCmsArticleCount
} from '@/api/cms/cmsArticleCount';
import { CmsArticleCount } from '@/api/cms/cmsArticleCount/model';
import { useThemeStore } from '@/store/modules/theme';
import { storeToRefs } from 'pinia';
@@ -135,7 +138,9 @@
const formData = {
...form
};
const saveOrUpdate = isUpdate.value ? updateCmsArticleCount : addCmsArticleCount;
const saveOrUpdate = isUpdate.value
? updateCmsArticleCount
: addCmsArticleCount;
saveOrUpdate(formData)
.then((msg) => {
loading.value = false;
@@ -158,12 +163,12 @@
images.value = [];
if (props.data) {
assignObject(form, props.data);
if(props.data.image){
if (props.data.image) {
images.value.push({
uid: uuid(),
url: props.data.image,
status: 'done'
})
});
}
isUpdate.value = true;
} else {

View File

@@ -45,7 +45,11 @@
</a-card>
<!-- 编辑弹窗 -->
<CmsArticleCountEdit v-model:visible="showEdit" :data="current" @done="reload" />
<CmsArticleCountEdit
v-model:visible="showEdit"
:data="current"
@done="reload"
/>
</div>
</div>
</template>
@@ -62,8 +66,15 @@
} from 'ele-admin-pro/es/ele-pro-table/types';
import Search from './components/search.vue';
import CmsArticleCountEdit from './components/cmsArticleCountEdit.vue';
import { pageCmsArticleCount, removeCmsArticleCount, removeBatchCmsArticleCount } from '@/api/cms/cmsArticleCount';
import type { CmsArticleCount, CmsArticleCountParam } from '@/api/cms/cmsArticleCount/model';
import {
pageCmsArticleCount,
removeCmsArticleCount,
removeBatchCmsArticleCount
} from '@/api/cms/cmsArticleCount';
import type {
CmsArticleCount,
CmsArticleCountParam
} from '@/api/cms/cmsArticleCount/model';
// 表格实例
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
@@ -105,19 +116,19 @@
dataIndex: 'id',
key: 'id',
align: 'center',
width: 90,
width: 90
},
{
title: '文章ID',
dataIndex: 'articleId',
key: 'articleId',
align: 'center',
align: 'center'
},
{
title: '用户ID',
dataIndex: 'userId',
key: 'userId',
align: 'center',
align: 'center'
},
{
title: '创建时间',
@@ -183,7 +194,9 @@
maskClosable: true,
onOk: () => {
const hide = message.loading('请求中..', 0);
removeBatchCmsArticleCount(selection.value.map((d) => d.cmsArticleCountId))
removeBatchCmsArticleCount(
selection.value.map((d) => d.cmsArticleCountId)
)
.then((msg) => {
hide();
message.success(msg);

View File

@@ -41,7 +41,10 @@
import { ref, reactive, watch } from 'vue';
import { Form, message } from 'ant-design-vue';
import { assignObject, uuid } from 'ele-admin-pro';
import { addCmsArticleLike, updateCmsArticleLike } from '@/api/cms/cmsArticleLike';
import {
addCmsArticleLike,
updateCmsArticleLike
} from '@/api/cms/cmsArticleLike';
import { CmsArticleLike } from '@/api/cms/cmsArticleLike/model';
import { useThemeStore } from '@/store/modules/theme';
import { storeToRefs } from 'pinia';
@@ -135,7 +138,9 @@
const formData = {
...form
};
const saveOrUpdate = isUpdate.value ? updateCmsArticleLike : addCmsArticleLike;
const saveOrUpdate = isUpdate.value
? updateCmsArticleLike
: addCmsArticleLike;
saveOrUpdate(formData)
.then((msg) => {
loading.value = false;
@@ -158,12 +163,12 @@
images.value = [];
if (props.data) {
assignObject(form, props.data);
if(props.data.image){
if (props.data.image) {
images.value.push({
uid: uuid(),
url: props.data.image,
status: 'done'
})
});
}
isUpdate.value = true;
} else {

View File

@@ -45,7 +45,11 @@
</a-card>
<!-- 编辑弹窗 -->
<CmsArticleLikeEdit v-model:visible="showEdit" :data="current" @done="reload" />
<CmsArticleLikeEdit
v-model:visible="showEdit"
:data="current"
@done="reload"
/>
</div>
</div>
</template>
@@ -62,8 +66,15 @@
} from 'ele-admin-pro/es/ele-pro-table/types';
import Search from './components/search.vue';
import CmsArticleLikeEdit from './components/cmsArticleLikeEdit.vue';
import { pageCmsArticleLike, removeCmsArticleLike, removeBatchCmsArticleLike } from '@/api/cms/cmsArticleLike';
import type { CmsArticleLike, CmsArticleLikeParam } from '@/api/cms/cmsArticleLike/model';
import {
pageCmsArticleLike,
removeCmsArticleLike,
removeBatchCmsArticleLike
} from '@/api/cms/cmsArticleLike';
import type {
CmsArticleLike,
CmsArticleLikeParam
} from '@/api/cms/cmsArticleLike/model';
// 表格实例
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
@@ -105,19 +116,19 @@
dataIndex: 'id',
key: 'id',
align: 'center',
width: 90,
width: 90
},
{
title: '文章ID',
dataIndex: 'articleId',
key: 'articleId',
align: 'center',
align: 'center'
},
{
title: '用户ID',
dataIndex: 'userId',
key: 'userId',
align: 'center',
align: 'center'
},
{
title: '创建时间',
@@ -183,7 +194,9 @@
maskClosable: true,
onOk: () => {
const hide = message.loading('请求中..', 0);
removeBatchCmsArticleLike(selection.value.map((d) => d.cmsArticleLikeId))
removeBatchCmsArticleLike(
selection.value.map((d) => d.cmsArticleLikeId)
)
.then((msg) => {
hide();
message.success(msg);

View File

@@ -134,7 +134,7 @@
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 {CmsNavigation} from "@/api/cms/cmsNavigation/model";
import { CmsNavigation } from '@/api/cms/cmsNavigation/model';
// 是否是修改
const isUpdate = ref(false);
@@ -255,12 +255,12 @@
images.value = [];
if (props.data) {
assignObject(form, props.data);
if(props.data.image){
if (props.data.image) {
images.value.push({
uid: uuid(),
url: props.data.image,
status: 'done'
})
});
}
isUpdate.value = true;
} else {

View File

@@ -60,7 +60,7 @@
// 表单数据
const { where, resetFields } = useSearch<CmsDesignParam>({
keywords: '',
categoryId: undefined,
categoryId: undefined
});
// 新增
@@ -89,11 +89,7 @@
if (!d.component) {
d.disabled = true;
}
if (
d.model == 'index' ||
d.model == 'page' ||
d.model == 'order'
) {
if (d.model == 'index' || d.model == 'page' || d.model == 'order') {
d.disabled = true;
}
return d;

View File

@@ -1,50 +1,50 @@
<template>
<a-page-header :title="getPageTitle()" @back="() => $router.go(-1)">
<a-card :bordered="false" :body-style="{ padding: '16px' }">
<ele-pro-table
ref="tableRef"
row-key="cmsDesignId"
: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"
/>
<a-card :bordered="false" :body-style="{ padding: '16px' }">
<ele-pro-table
ref="tableRef"
row-key="cmsDesignId"
: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 #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 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>
</ele-pro-table>
</a-card>
<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>
<!-- 编辑弹窗 -->
<CmsDesignEdit v-model:visible="showEdit" :data="current" @done="reload" />
<!-- 编辑弹窗 -->
<CmsDesignEdit v-model:visible="showEdit" :data="current" @done="reload" />
</a-page-header>
</template>
@@ -61,9 +61,13 @@
} from 'ele-admin-pro/es/ele-pro-table/types';
import Search from './components/search.vue';
import CmsDesignEdit from './components/cmsDesignEdit.vue';
import { pageCmsDesign, removeCmsDesign, removeBatchCmsDesign } from '@/api/cms/cmsDesign';
import {
pageCmsDesign,
removeCmsDesign,
removeBatchCmsDesign
} from '@/api/cms/cmsDesign';
import type { CmsDesign, CmsDesignParam } from '@/api/cms/cmsDesign/model';
import {getPageTitle} from "@/utils/common";
import { getPageTitle } from '@/utils/common';
// 表格实例
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
@@ -108,7 +112,7 @@
dataIndex: 'pageId',
key: 'pageId',
align: 'center',
width: 90,
width: 90
},
{
title: '页面',

View File

@@ -42,12 +42,12 @@
v-model:value="form.hostValue"
/>
</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-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-item label="排序号" v-if="isUpdate" name="sortNumber">
<a-input-number
:min="0"

View File

@@ -3,52 +3,51 @@
<template #extra>
<CmsWebsiteSearch />
</template>
<a-card :bordered="false" :body-style="{ padding: '16px' }">
<ele-pro-table
ref="tableRef"
row-key="cmsDomainId"
: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"
/>
<a-card :bordered="false" :body-style="{ padding: '16px' }">
<ele-pro-table
ref="tableRef"
row-key="cmsDomainId"
: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 #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="red">待绑定</a-tag>
<a-tag v-if="record.status === 1" color="green">已绑定</a-tag>
</template>
<template v-if="column.key === 'action'">
<a-space v-if="record.status === 0">
<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 v-if="column.key === 'status'">
<a-tag v-if="record.status === 0" color="red">待绑定</a-tag>
<a-tag v-if="record.status === 1" color="green">已绑定</a-tag>
</template>
</ele-pro-table>
</a-card>
<!-- 编辑弹窗 -->
<CmsDomainEdit v-model:visible="showEdit" :data="current" @done="reload" />
<template v-if="column.key === 'action'">
<a-space v-if="record.status === 0">
<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>
<!-- 编辑弹窗 -->
<CmsDomainEdit v-model:visible="showEdit" :data="current" @done="reload" />
</a-page-header>
</template>
@@ -64,10 +63,14 @@
} from 'ele-admin-pro/es/ele-pro-table/types';
import Search from './components/search.vue';
import CmsDomainEdit from './components/cmsDomainEdit.vue';
import { pageCmsDomain, removeCmsDomain, removeBatchCmsDomain } from '@/api/cms/cmsDomain';
import {
pageCmsDomain,
removeCmsDomain,
removeBatchCmsDomain
} from '@/api/cms/cmsDomain';
import type { CmsDomain, CmsDomainParam } from '@/api/cms/cmsDomain/model';
import {getPageTitle} from "@/utils/common";
import CmsWebsiteSearch from "@/views/cms/cmsWebsite/components/search.vue";
import { getPageTitle } from '@/utils/common';
import CmsWebsiteSearch from '@/views/cms/cmsWebsite/components/search.vue';
// 表格实例
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
@@ -94,9 +97,9 @@
if (filters) {
where.status = filters.status;
}
if(localStorage.getItem('WebsiteId')){
if (localStorage.getItem('WebsiteId')) {
where.websiteId = localStorage.getItem('WebsiteId');
}else {
} else {
where.userId = localStorage.getItem('UserId');
}
return pageCmsDomain({
@@ -121,7 +124,7 @@
title: '域名',
dataIndex: 'domain',
key: 'domain',
align: 'center',
align: 'center'
},
// {
// title: '主机记录',
@@ -139,7 +142,7 @@
title: '状态',
dataIndex: 'status',
key: 'status',
align: 'center',
align: 'center'
},
{
title: '创建时间',

View File

@@ -15,12 +15,10 @@
:model="form"
:rules="rules"
labelAlign="left"
:label-col="
styleResponsive ? { md: 4, sm: 5, xs: 24 } : { flex: '90px' }
"
:label-col="styleResponsive ? { md: 4, sm: 5, xs: 24 } : { flex: '90px' }"
:wrapper-col="
styleResponsive ? { md: 18, sm: 19, xs: 24 } : { flex: '1' }
"
styleResponsive ? { md: 18, sm: 19, xs: 24 } : { flex: '1' }
"
>
<a-form-item label="表单名称" name="name">
<a-input
@@ -64,7 +62,7 @@
@del="onDeleteItem"
/>
<div class="ele-text-placeholder"
>请上传jpgpng格式的图片图片尺寸750px*460px</div
>请上传jpgpng格式的图片图片尺寸750px*460px</div
>
</template>
</a-space>
@@ -85,7 +83,7 @@
@del="onDeleteVideoItem"
/>
<div class="ele-text-placeholder"
>请上传mp4格式的视频文件大小200M以内</div
>请上传mp4格式的视频文件大小200M以内</div
>
</template>
</a-space>
@@ -108,7 +106,7 @@
@del="onDeleteItem2"
/>
<div class="ele-text-placeholder"
>请上传jpgpng格式的图片图片尺寸750px*1624px</div
>请上传jpgpng格式的图片图片尺寸750px*1624px</div
>
</template>
</a-space>
@@ -152,53 +150,49 @@
@change="onSelect(element, index)"
>
<a-select-option value="text"
>单行文本</a-select-option
>单行文本</a-select-option
>
<a-select-option value="textarea"
>多行文本</a-select-option
>多行文本</a-select-option
>
<a-select-option value="radio"
>单选</a-select-option
>单选</a-select-option
>
<a-select-option value="checkbox"
>多选</a-select-option
>多选</a-select-option
>
<a-select-option value="phone"
>手机号码</a-select-option
>手机号码</a-select-option
>
<a-select-option value="email"
>邮箱</a-select-option
>
<a-select-option value="time"
>时间</a-select-option
>
<a-select-option value="date"
>日期</a-select-option
>邮箱</a-select-option
>
<a-select-option value="time">时间</a-select-option>
<a-select-option value="date">日期</a-select-option>
<a-select-option value="image"
>图片上传</a-select-option
>图片上传</a-select-option
>
</a-select>
</template>
</a-input>
<a-checkbox v-model:checked="element.checked"
>必填</a-checkbox
>必填</a-checkbox
>
<a
v-if="element.type == 'radio'"
@click="openRadioForm(element)"
>设置</a
>设置</a
>
<a
v-if="element.type == 'checkbox'"
@click="openCheckboxForm(element)"
>设置</a
>设置</a
>
<a-button
@click="removeItem(index)"
danger
style="margin-left: 10px"
>删除</a-button
>删除</a-button
>
</a-space>
</div>
@@ -207,7 +201,7 @@
</template>
</vue-draggable>
<a @click="addItem"
><PlusCircleOutlined style="margin-right: 4px" />新增</a
><PlusCircleOutlined style="margin-right: 4px" />新增</a
>
</div>
</a-form-item>
@@ -232,7 +226,7 @@
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 {Website} from "@/api/system/website/model";
import { Website } from '@/api/system/website/model';
// 是否是修改
const useForm = Form.useForm;

View File

@@ -3,51 +3,51 @@
<template #extra>
<CmsWebsiteSearch />
</template>
<a-card :bordered="false" :body-style="{ padding: '16px' }">
<ele-pro-table
ref="tableRef"
row-key="cmsFormId"
: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"
/>
<a-card :bordered="false" :body-style="{ padding: '16px' }">
<ele-pro-table
ref="tableRef"
row-key="cmsFormId"
: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 #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 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>
</ele-pro-table>
</a-card>
<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>
<!-- 编辑弹窗 -->
<CmsFormEdit v-model:visible="showEdit" :data="current" @done="reload" />
<!-- 编辑弹窗 -->
<CmsFormEdit v-model:visible="showEdit" :data="current" @done="reload" />
</a-page-header>
</template>
@@ -63,10 +63,14 @@
} from 'ele-admin-pro/es/ele-pro-table/types';
import Search from './components/search.vue';
import CmsFormEdit from './components/cmsFormEdit.vue';
import { pageCmsForm, removeCmsForm, removeBatchCmsForm } from '@/api/cms/cmsForm';
import {
pageCmsForm,
removeCmsForm,
removeBatchCmsForm
} from '@/api/cms/cmsForm';
import type { CmsForm, CmsFormParam } from '@/api/cms/cmsForm/model';
import {getPageTitle} from "@/utils/common";
import CmsWebsiteSearch from "@/views/cms/cmsWebsite/components/search.vue";
import { getPageTitle } from '@/utils/common';
import CmsWebsiteSearch from '@/views/cms/cmsWebsite/components/search.vue';
// 表格实例
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
@@ -108,7 +112,7 @@
dataIndex: 'formId',
key: 'formId',
align: 'center',
width: 90,
width: 90
},
{
title: '表单标题',
@@ -120,14 +124,14 @@
dataIndex: 'status',
key: 'status',
width: 120,
align: 'center',
align: 'center'
},
{
title: '排序',
dataIndex: 'sortNumber',
key: 'sortNumber',
width: 120,
align: 'center',
align: 'center'
},
{
title: '创建时间',

View File

@@ -99,7 +99,10 @@
import { ref, reactive, watch } from 'vue';
import { Form, message } from 'ant-design-vue';
import { assignObject, uuid } from 'ele-admin-pro';
import { addCmsFormRecord, updateCmsFormRecord } from '@/api/cms/cmsFormRecord';
import {
addCmsFormRecord,
updateCmsFormRecord
} from '@/api/cms/cmsFormRecord';
import { CmsFormRecord } from '@/api/cms/cmsFormRecord/model';
import { useThemeStore } from '@/store/modules/theme';
import { storeToRefs } from 'pinia';
@@ -196,7 +199,9 @@
const formData = {
...form
};
const saveOrUpdate = isUpdate.value ? updateCmsFormRecord : addCmsFormRecord;
const saveOrUpdate = isUpdate.value
? updateCmsFormRecord
: addCmsFormRecord;
saveOrUpdate(formData)
.then((msg) => {
loading.value = false;
@@ -219,12 +224,12 @@
images.value = [];
if (props.data) {
assignObject(form, props.data);
if(props.data.image){
if (props.data.image) {
images.value.push({
uid: uuid(),
url: props.data.image,
status: 'done'
})
});
}
isUpdate.value = true;
} else {

View File

@@ -45,7 +45,11 @@
</a-card>
<!-- 编辑弹窗 -->
<CmsFormRecordEdit v-model:visible="showEdit" :data="current" @done="reload" />
<CmsFormRecordEdit
v-model:visible="showEdit"
:data="current"
@done="reload"
/>
</div>
</div>
</template>
@@ -62,8 +66,15 @@
} from 'ele-admin-pro/es/ele-pro-table/types';
import Search from './components/search.vue';
import CmsFormRecordEdit from './components/cmsFormRecordEdit.vue';
import { pageCmsFormRecord, removeCmsFormRecord, removeBatchCmsFormRecord } from '@/api/cms/cmsFormRecord';
import type { CmsFormRecord, CmsFormRecordParam } from '@/api/cms/cmsFormRecord/model';
import {
pageCmsFormRecord,
removeCmsFormRecord,
removeBatchCmsFormRecord
} from '@/api/cms/cmsFormRecord';
import type {
CmsFormRecord,
CmsFormRecordParam
} from '@/api/cms/cmsFormRecord/model';
// 表格实例
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
@@ -105,67 +116,67 @@
dataIndex: 'formRecordId',
key: 'formRecordId',
align: 'center',
width: 90,
width: 90
},
{
title: '手机号',
dataIndex: 'phone',
key: 'phone',
align: 'center',
align: 'center'
},
{
title: '表单数据',
dataIndex: 'formData',
key: 'formData',
align: 'center',
align: 'center'
},
{
title: '表单ID',
dataIndex: 'formId',
key: 'formId',
align: 'center',
align: 'center'
},
{
title: '用户ID',
dataIndex: 'userId',
key: 'userId',
align: 'center',
align: 'center'
},
{
title: '商户ID',
dataIndex: 'merchantId',
key: 'merchantId',
align: 'center',
align: 'center'
},
{
title: '姓名',
dataIndex: 'name',
key: 'name',
align: 'center',
align: 'center'
},
{
title: '排序(数字越小越靠前)',
dataIndex: 'sortNumber',
key: 'sortNumber',
align: 'center',
align: 'center'
},
{
title: '备注',
dataIndex: 'comments',
key: 'comments',
align: 'center',
align: 'center'
},
{
title: '状态, 0正常, 1冻结',
dataIndex: 'status',
key: 'status',
align: 'center',
align: 'center'
},
{
title: '是否删除, 0否, 1是',
dataIndex: 'deleted',
key: 'deleted',
align: 'center',
align: 'center'
},
{
title: '创建时间',

View File

@@ -58,7 +58,10 @@
v-model:value="form.comments"
/>
</a-form-item>
<a-form-item label="状态, 0已发布, 1待审核 2已驳回 3违规内容" name="status">
<a-form-item
label="状态, 0已发布, 1待审核 2已驳回 3违规内容"
name="status"
>
<a-radio-group v-model:value="form.status">
<a-radio :value="0">显示</a-radio>
<a-radio :value="1">隐藏</a-radio>

View File

@@ -1,13 +1,16 @@
<!-- 搜索表单 -->
<template>
<a-space :size="10" style="flex-wrap: wrap">
<a-alert type="warning" message="默认为简体中文,请根据需要配置国际化支持。" />
<!-- <a-button type="primary" class="ele-btn-icon" disabled @click="add">-->
<!-- <template #icon>-->
<!-- <PlusOutlined />-->
<!-- </template>-->
<!-- <span>添加</span>-->
<!-- </a-button>-->
<a-alert
type="warning"
message="默认为简体中文,请根据需要配置国际化支持。"
/>
<!-- <a-button type="primary" class="ele-btn-icon" disabled @click="add">-->
<!-- <template #icon>-->
<!-- <PlusOutlined />-->
<!-- </template>-->
<!-- <span>添加</span>-->
<!-- </a-button>-->
</a-space>
</template>

View File

@@ -3,36 +3,39 @@
<template #extra>
<CmsWebsiteSearch />
</template>
<a-card :bordered="false" :body-style="{ padding: '16px' }">
<ele-pro-table
ref="tableRef"
row-key="cmsLangId"
: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"
<a-card :bordered="false" :body-style="{ padding: '16px' }">
<ele-pro-table
ref="tableRef"
row-key="cmsLangId"
: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 === 'action'">
<a-switch
v-model:checked="record.enable"
:disabled="record.status"
@change="onChange(record)"
/>
</template>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'action'">
<a-switch v-model:checked="record.enable" :disabled="record.status" @change="onChange(record)"/>
</template>
</template>
</ele-pro-table>
</a-card>
<!-- 编辑弹窗 -->
<CmsLangEdit v-model:visible="showEdit" :data="current" @done="reload" />
</template>
</ele-pro-table>
</a-card>
<!-- 编辑弹窗 -->
<CmsLangEdit v-model:visible="showEdit" :data="current" @done="reload" />
</a-page-header>
</template>
@@ -47,11 +50,11 @@
} from 'ele-admin-pro/es/ele-pro-table/types';
import Search from './components/search.vue';
import CmsLangEdit from './components/cmsLangEdit.vue';
import {pageCmsLang, removeBatchCmsLang} from '@/api/cms/cmsLang';
import { pageCmsLang, removeBatchCmsLang } from '@/api/cms/cmsLang';
import type { CmsLang, CmsLangParam } from '@/api/cms/cmsLang/model';
import {addCmsLangLog, removeCmsLangLog} from "@/api/cms/cmsLangLog";
import {getPageTitle} from "@/utils/common";
import CmsWebsiteSearch from "@/views/cms/cmsWebsite/components/search.vue";
import { addCmsLangLog, removeCmsLangLog } from '@/api/cms/cmsLangLog';
import { getPageTitle } from '@/utils/common';
import CmsWebsiteSearch from '@/views/cms/cmsWebsite/components/search.vue';
// 表格实例
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
@@ -68,12 +71,7 @@
const loading = ref(true);
// 表格数据源
const datasource: DatasourceFunction = ({
page,
limit,
where,
orders
}) => {
const datasource: DatasourceFunction = ({ page, limit, where, orders }) => {
return pageCmsLang({
...where,
...orders,
@@ -96,13 +94,13 @@
title: '名称',
dataIndex: 'name',
key: 'name',
align: 'center',
align: 'center'
},
{
title: '编码',
dataIndex: 'code',
key: 'code',
align: 'center',
align: 'center'
},
// {
// title: '排序',
@@ -138,17 +136,17 @@
};
// 启用禁用开关
const onChange = (item:any) => {
const onChange = (item: any) => {
if (item.enable == true) {
addCmsLangLog({
code: item.code,
langId: item.id,
lang: item.name
})
}else {
});
} else {
removeCmsLangLog(item.id);
}
}
};
/* 批量删除 */
const removeBatch = () => {

View File

@@ -158,12 +158,12 @@
images.value = [];
if (props.data) {
assignObject(form, props.data);
if(props.data.image){
if (props.data.image) {
images.value.push({
uid: uuid(),
url: props.data.image,
status: 'done'
})
});
}
isUpdate.value = true;
} else {

View File

@@ -45,7 +45,11 @@
</a-card>
<!-- 编辑弹窗 -->
<CmsLangLogEdit v-model:visible="showEdit" :data="current" @done="reload" />
<CmsLangLogEdit
v-model:visible="showEdit"
:data="current"
@done="reload"
/>
</div>
</div>
</template>
@@ -62,7 +66,11 @@
} from 'ele-admin-pro/es/ele-pro-table/types';
import Search from './components/search.vue';
import CmsLangLogEdit from './components/cmsLangLogEdit.vue';
import { pageCmsLangLog, removeCmsLangLog, removeBatchCmsLangLog } from '@/api/cms/cmsLangLog';
import {
pageCmsLangLog,
removeCmsLangLog,
removeBatchCmsLangLog
} from '@/api/cms/cmsLangLog';
import type { CmsLangLog, CmsLangLogParam } from '@/api/cms/cmsLangLog/model';
// 表格实例
@@ -105,19 +113,19 @@
dataIndex: 'id',
key: 'id',
align: 'center',
width: 90,
width: 90
},
{
title: '关联ID',
dataIndex: 'langId',
key: 'langId',
align: 'center',
align: 'center'
},
{
title: '编码',
dataIndex: 'code',
key: 'code',
align: 'center',
align: 'center'
},
{
title: '创建时间',

View File

@@ -27,10 +27,7 @@
/>
</a-form-item>
<a-form-item label="网址" name="url">
<a-input
v-model:value="form.url"
placeholder="websoft.top"
>
<a-input v-model:value="form.url" placeholder="websoft.top">
<template #addonBefore>
<a-select v-model:value="before" style="width: 90px">
<a-select-option value="https://">https://</a-select-option>
@@ -39,18 +36,18 @@
</template>
</a-input>
</a-form-item>
<!-- <a-form-item label="选择栏目" name="categoryId">-->
<!-- <a-tree-select-->
<!-- allow-clear-->
<!-- :tree-data="navigationList"-->
<!-- tree-default-expand-all-->
<!-- placeholder="请选择栏目"-->
<!-- :value="form.categoryId || undefined"-->
<!-- :dropdown-style="{ maxHeight: '360px', overflow: 'auto' }"-->
<!-- @update:value="(value?: number) => (form.categoryId = value)"-->
<!-- @change="onCategoryId"-->
<!-- />-->
<!-- </a-form-item>-->
<!-- <a-form-item label="选择栏目" name="categoryId">-->
<!-- <a-tree-select-->
<!-- allow-clear-->
<!-- :tree-data="navigationList"-->
<!-- tree-default-expand-all-->
<!-- placeholder="请选择栏目"-->
<!-- :value="form.categoryId || undefined"-->
<!-- :dropdown-style="{ maxHeight: '360px', overflow: 'auto' }"-->
<!-- @update:value="(value?: number) => (form.categoryId = value)"-->
<!-- @change="onCategoryId"-->
<!-- />-->
<!-- </a-form-item>-->
<a-form-item label="图标" name="icon">
<SelectFile
:placeholder="`请选择图标`"
@@ -84,190 +81,190 @@
</template>
<script lang="ts" setup>
import { ref, reactive, watch } from 'vue';
import { message } from 'ant-design-vue/es';
import type { FormInstance, Rule } from 'ant-design-vue/es/form';
import { storeToRefs } from 'pinia';
import { useThemeStore } from '@/store/modules/theme';
import useFormData from '@/utils/use-form-data';
import { addCmsLink, updateCmsLink } from '@/api/cms/cmsLink';
import type { CmsLink } from '@/api/cms/cmsLink/model';
import { ItemType } from 'ele-admin-pro/es/ele-image-upload/types';
import { uploadFile } from '@/api/system/file';
import { FileRecord } from '@/api/system/file/model';
import { CmsNavigation } from '@/api/cms/cmsNavigation/model';
import {getLang} from "@/utils/common";
import { ref, reactive, watch } from 'vue';
import { message } from 'ant-design-vue/es';
import type { FormInstance, Rule } from 'ant-design-vue/es/form';
import { storeToRefs } from 'pinia';
import { useThemeStore } from '@/store/modules/theme';
import useFormData from '@/utils/use-form-data';
import { addCmsLink, updateCmsLink } from '@/api/cms/cmsLink';
import type { CmsLink } from '@/api/cms/cmsLink/model';
import { ItemType } from 'ele-admin-pro/es/ele-image-upload/types';
import { uploadFile } from '@/api/system/file';
import { FileRecord } from '@/api/system/file/model';
import { CmsNavigation } from '@/api/cms/cmsNavigation/model';
import { getLang } from '@/utils/common';
// 是否开启响应式布局
const themeStore = useThemeStore();
const { styleResponsive } = storeToRefs(themeStore);
// 是否开启响应式布局
const themeStore = useThemeStore();
const { styleResponsive } = storeToRefs(themeStore);
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 props = defineProps<{
// 弹窗是否打开
visible: boolean;
// 修改回显的数据
data?: CmsLink | null;
navigationList?: CmsNavigation[];
}>();
const props = defineProps<{
// 弹窗是否打开
visible: boolean;
// 修改回显的数据
data?: CmsLink | null;
navigationList?: CmsNavigation[];
}>();
//
const formRef = ref<FormInstance | null>(null);
// 是否是修改
const isUpdate = ref(false);
// 已上传数据
const images = ref<ItemType[]>([]);
// 提交状态
const loading = ref(false);
const before = ref<string>('https://');
//
const formRef = ref<FormInstance | null>(null);
// 是否是修改
const isUpdate = ref(false);
// 已上传数据
const images = ref<ItemType[]>([]);
// 提交状态
const loading = ref(false);
const before = ref<string>('https://');
// 表单数据
const { form, resetFields, assignFields } = useFormData<CmsLink>({
id: undefined,
name: '',
url: '',
sortNumber: 100,
categoryId: undefined,
comments: undefined
});
// 表单验证规则
const rules = reactive<Record<string, Rule[]>>({
name: [
{
required: true,
type: 'string',
trigger: 'blur'
}
],
url: [
{
required: true,
message: '请输入正确的URL',
type: 'string',
trigger: 'blur'
}
]
});
// 上传文件
const onUpload = (item: any) => {
const { file } = item;
uploadFile(file)
.then((data) => {
images.value.push({
uid: data.id,
url: data.url,
status: 'done'
});
form.icon = data.url;
message.success('上传成功');
})
.catch((e) => {
message.error(e.message);
});
};
/* 上传事件 */
const uploadHandler = (file: File) => {
const item: ItemType = {
file,
uid: (file as any).uid,
name: file.name
};
if (file.size / 1024 / 1024 > 1) {
message.error('大小不能超过 1MB');
return;
}
onUpload(item);
};
const chooseFile = (data: FileRecord) => {
images.value.push({
uid: data.id,
url: data.path,
status: 'done'
// 表单数据
const { form, resetFields, assignFields } = useFormData<CmsLink>({
id: undefined,
name: '',
url: '',
sortNumber: 100,
categoryId: undefined,
comments: undefined
});
form.icon = data.path;
};
const onDeleteItem = (index: number) => {
images.value.splice(index, 1);
form.icon = '';
};
// 选择栏目
const onCategoryId = (id: number) => {
form.categoryId = id;
};
/* 保存编辑 */
const save = () => {
if (!formRef.value) {
return;
}
console.log(form,'fff>');
formRef.value
.validate()
.then(() => {
loading.value = true;
const saveOrUpdate = isUpdate.value ? updateCmsLink : addCmsLink;
form.url = `${before.value}${form.url}`;
saveOrUpdate(form)
.then((msg) => {
loading.value = false;
message.success(msg);
updateVisible(false);
emit('done');
})
.catch((e) => {
loading.value = false;
message.error(e.message);
});
})
.catch(() => {});
};
/* 更新visible */
const updateVisible = (value: boolean) => {
emit('update:visible', value);
};
watch(
() => props.visible,
(visible) => {
if (visible) {
if (props.data) {
assignFields(props.data);
images.value = [];
if (props.data.icon) {
images.value.push({
uid: 1,
url: props.data.icon,
status: 'done'
});
}
if(props.data.url?.startsWith('https://')){
before.value = 'https://';
form.url = props.data.url.replace('https://', '');
}
if(props.data.url?.startsWith('http://')){
before.value = 'http://';
form.url = props.data.url.replace('http://', '');
}
isUpdate.value = true;
} else {
images.value = [];
isUpdate.value = false;
// 表单验证规则
const rules = reactive<Record<string, Rule[]>>({
name: [
{
required: true,
type: 'string',
trigger: 'blur'
}
} else {
resetFields();
formRef.value?.clearValidate();
],
url: [
{
required: true,
message: '请输入正确的URL',
type: 'string',
trigger: 'blur'
}
]
});
// 上传文件
const onUpload = (item: any) => {
const { file } = item;
uploadFile(file)
.then((data) => {
images.value.push({
uid: data.id,
url: data.url,
status: 'done'
});
form.icon = data.url;
message.success('上传成功');
})
.catch((e) => {
message.error(e.message);
});
};
/* 上传事件 */
const uploadHandler = (file: File) => {
const item: ItemType = {
file,
uid: (file as any).uid,
name: file.name
};
if (file.size / 1024 / 1024 > 1) {
message.error('大小不能超过 1MB');
return;
}
}
);
onUpload(item);
};
const chooseFile = (data: FileRecord) => {
images.value.push({
uid: data.id,
url: data.path,
status: 'done'
});
form.icon = data.path;
};
const onDeleteItem = (index: number) => {
images.value.splice(index, 1);
form.icon = '';
};
// 选择栏目
const onCategoryId = (id: number) => {
form.categoryId = id;
};
/* 保存编辑 */
const save = () => {
if (!formRef.value) {
return;
}
console.log(form, 'fff>');
formRef.value
.validate()
.then(() => {
loading.value = true;
const saveOrUpdate = isUpdate.value ? updateCmsLink : addCmsLink;
form.url = `${before.value}${form.url}`;
saveOrUpdate(form)
.then((msg) => {
loading.value = false;
message.success(msg);
updateVisible(false);
emit('done');
})
.catch((e) => {
loading.value = false;
message.error(e.message);
});
})
.catch(() => {});
};
/* 更新visible */
const updateVisible = (value: boolean) => {
emit('update:visible', value);
};
watch(
() => props.visible,
(visible) => {
if (visible) {
if (props.data) {
assignFields(props.data);
images.value = [];
if (props.data.icon) {
images.value.push({
uid: 1,
url: props.data.icon,
status: 'done'
});
}
if (props.data.url?.startsWith('https://')) {
before.value = 'https://';
form.url = props.data.url.replace('https://', '');
}
if (props.data.url?.startsWith('http://')) {
before.value = 'http://';
form.url = props.data.url.replace('http://', '');
}
isUpdate.value = true;
} else {
images.value = [];
isUpdate.value = false;
}
} else {
resetFields();
formRef.value?.clearValidate();
}
}
);
</script>

View File

@@ -45,9 +45,9 @@
import { useThemeStore } from '@/store/modules/theme';
import { storeToRefs } from 'pinia';
import { FormInstance, RuleObject } from 'ant-design-vue/es/form';
import { CmsNavigation } from "@/api/cms/cmsNavigation/model";
import {updateBatchCmsLink} from "@/api/cms/cmsLink";
import {CmsLink} from "@/api/cms/cmsLink/model";
import { CmsNavigation } from '@/api/cms/cmsNavigation/model';
import { updateBatchCmsLink } from '@/api/cms/cmsLink';
import { CmsLink } from '@/api/cms/cmsLink/model';
// 是否是修改
const useForm = Form.useForm;
@@ -108,7 +108,7 @@
// 租户id
tenantId: undefined,
// 创建时间
createTime: undefined,
createTime: undefined
});
/* 更新visible */
@@ -137,17 +137,17 @@
content: [
{
required: true,
type: "string",
message: "请输入文章内容",
trigger: "blur",
type: 'string',
message: '请输入文章内容',
trigger: 'blur',
validator: async (_rule: RuleObject, value: string) => {
if (content.value == "") {
return Promise.reject("请输入文字内容");
if (content.value == '') {
return Promise.reject('请输入文字内容');
}
return Promise.resolve();
}
}
],
]
});
// 选择栏目
@@ -167,18 +167,19 @@
.validate()
.then(() => {
loading.value = true;
props.selection?.map(d => d.id)
props.selection?.map((d) => d.id);
updateBatchCmsLink({
ids: props.selection?.map(d => d.id),
ids: props.selection?.map((d) => d.id),
data: {
categoryId: form.categoryId
}
}).then((msg) => {
message.success(msg);
loading.value = false;
updateVisible(false);
emit('done');
})
.then((msg) => {
message.success(msg);
loading.value = false;
updateVisible(false);
emit('done');
})
.catch((e) => {
message.error(e.message);
});

View File

@@ -1,30 +1,27 @@
<!-- 搜索表单 -->
<template>
<a-space :size="10" style="flex-wrap: wrap">
<a-button type="primary" class="ele-btn-icon" @click="add">
<a-button type="primary" class="ele-btn-icon" @click="add">
<template #icon>
<PlusOutlined />
</template>
<span>添加</span>
</a-button>
<a-button
:disabled="selection?.length === 0"
@click="updateBatch"
>
<a-button :disabled="selection?.length === 0" @click="updateBatch">
移动
</a-button>
<!-- <a-tree-select-->
<!-- allow-clear-->
<!-- :tree-data="navigationList"-->
<!-- tree-default-expand-all-->
<!-- style="width: 280px"-->
<!-- :listHeight="700"-->
<!-- placeholder="请选择栏目"-->
<!-- :value="where.categoryId || undefined"-->
<!-- :dropdown-style="{ overflow: 'auto' }"-->
<!-- @update:value="(value?: number) => (where.categoryId = value)"-->
<!-- @change="onCategoryId"-->
<!-- />-->
<!-- <a-tree-select-->
<!-- allow-clear-->
<!-- :tree-data="navigationList"-->
<!-- tree-default-expand-all-->
<!-- style="width: 280px"-->
<!-- :listHeight="700"-->
<!-- placeholder="请选择栏目"-->
<!-- :value="where.categoryId || undefined"-->
<!-- :dropdown-style="{ overflow: 'auto' }"-->
<!-- @update:value="(value?: number) => (where.categoryId = value)"-->
<!-- @change="onCategoryId"-->
<!-- />-->
<a-input-search
allow-clear
placeholder="请输入关键词"
@@ -39,9 +36,9 @@
import { PlusOutlined } from '@ant-design/icons-vue';
import type { GradeParam } from '@/api/user/grade/model';
import { watch } from 'vue';
import {CmsNavigation} from "@/api/cms/cmsNavigation/model";
import useSearch from "@/utils/use-search";
import {CmsLinkParam} from "@/api/cms/cmsLink/model";
import { CmsNavigation } from '@/api/cms/cmsNavigation/model';
import useSearch from '@/utils/use-search';
import { CmsLinkParam } from '@/api/cms/cmsLink/model';
const props = withDefaults(
defineProps<{
@@ -75,7 +72,7 @@
// 批量更新
const updateBatch = () => {
emit('batchMove');
}
};
// 按分类查询
const onCategoryId = (id: number) => {

View File

@@ -23,8 +23,11 @@
</template>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'icon'">
<a-image :src="record.icon" :width="50"
fallback="https://file.wsdns.cn/20230218/550e610d43334dd2a7f66d5b20bd58eb.svg"/>
<a-image
:src="record.icon"
:width="50"
fallback="https://file.wsdns.cn/20230218/550e610d43334dd2a7f66d5b20bd58eb.svg"
/>
</template>
<template v-if="column.key === 'status'">
<a-tag v-if="record.status === 0" color="green">显示</a-tag>
@@ -33,7 +36,7 @@
<template v-if="column.key === 'action'">
<a-space>
<a @click="openEdit(record)">修改</a>
<a-divider type="vertical"/>
<a-divider type="vertical" />
<a-popconfirm
title="确定要删除此记录吗?"
@confirm="remove(record)"
@@ -47,7 +50,12 @@
</a-card>
<!-- 编辑弹窗 -->
<CmsLinkEdit v-model:visible="showEdit" :navigationList="navigationList" :data="current" @done="reload"/>
<CmsLinkEdit
v-model:visible="showEdit"
:navigationList="navigationList"
:data="current"
@done="reload"
/>
<!-- 批量更新 -->
<LinkUpdate
@@ -60,214 +68,218 @@
</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 type {
DatasourceFunction,
ColumnItem
} from 'ele-admin-pro/es/ele-pro-table/types';
import Search from './components/search.vue';
import {toTreeData} from 'ele-admin-pro';
import CmsLinkEdit from './components/cmsLinkEdit.vue';
import {pageCmsLink, removeCmsLink, removeBatchCmsLink} from '@/api/cms/cmsLink';
import type {CmsLink, CmsLinkParam} from '@/api/cms/cmsLink/model';
import {CmsNavigation} from "@/api/cms/cmsNavigation/model";
import {listCmsNavigation} from "@/api/cms/cmsNavigation";
import {getLang, getPageTitle} from "@/utils/common";
import LinkUpdate from './components/linkUpdate.vue';
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 type {
DatasourceFunction,
ColumnItem
} from 'ele-admin-pro/es/ele-pro-table/types';
import Search from './components/search.vue';
import { toTreeData } from 'ele-admin-pro';
import CmsLinkEdit from './components/cmsLinkEdit.vue';
import {
pageCmsLink,
removeCmsLink,
removeBatchCmsLink
} from '@/api/cms/cmsLink';
import type { CmsLink, CmsLinkParam } from '@/api/cms/cmsLink/model';
import { CmsNavigation } from '@/api/cms/cmsNavigation/model';
import { listCmsNavigation } from '@/api/cms/cmsNavigation';
import { getLang, getPageTitle } from '@/utils/common';
import LinkUpdate from './components/linkUpdate.vue';
// 表格实例
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
// 表格实例
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
// 表格选中数据
const selection = ref<CmsLink[]>([]);
// // 多语言
// const { locale } = useI18n();
// 当前编辑数据
const current = ref<CmsLink | null>(null);
// 是否显示编辑弹窗
const showEdit = ref(false);
// 是否显示批量移动弹窗
const showMove = ref(false);
// 加载状态
const loading = ref(true);
// 栏目数据
const navigationList = ref<CmsNavigation[]>();
// 表格选中数据
const selection = ref<CmsLink[]>([]);
// // 多语言
// const { locale } = useI18n();
// 当前编辑数据
const current = ref<CmsLink | null>(null);
// 是否显示编辑弹窗
const showEdit = ref(false);
// 是否显示批量移动弹窗
const showMove = ref(false);
// 加载状态
const loading = ref(true);
// 栏目数据
const navigationList = ref<CmsNavigation[]>();
// 表格数据源
const datasource: DatasourceFunction = ({
page,
limit,
where,
orders,
filters
}) => {
if (filters) {
where.status = filters.status;
}
return pageCmsLink({
...where,
...orders,
// 表格数据源
const datasource: DatasourceFunction = ({
page,
limit
});
};
// 表格列配置
const columns = ref<ColumnItem[]>([
// {
// key: 'index',
// width: 48,
// align: 'center',
// fixed: 'left',
// hideInSetting: true,
// customRender: ({ index }) => index + (tableRef.value?.tableIndex ?? 0)
// },
{
title: '图标',
dataIndex: 'icon',
key: 'icon',
align: 'center',
width: 120,
},
{
title: '链接名称',
dataIndex: 'name',
key: 'name'
},
{
title: '链接地址',
dataIndex: 'url',
key: 'url'
},
{
title: '备注',
dataIndex: 'comments'
},
{
title: '所属栏目',
dataIndex: 'categoryName',
align: 'center',
width: 180,
hideInTable: true
},
{
title: '状态',
dataIndex: 'status',
key: 'status',
align: 'center',
width: 120,
showSorterTooltip: false,
customRender: ({text}) => ['显示', '隐藏'][text]
},
{
title: '操作',
key: 'action',
width: 200,
align: 'center'
}
]);
/* 搜索 */
const reload = (where?: CmsLinkParam) => {
selection.value = [];
tableRef?.value?.reload({where: where});
};
/* 打开编辑弹窗 */
const openEdit = (row?: CmsLink) => {
current.value = row ?? null;
showEdit.value = true;
};
/* 打开批量移动弹窗 */
const openMove = () => {
showMove.value = true;
};
/* 删除单个 */
const remove = (row: CmsLink) => {
const hide = message.loading('请求中..', 0);
removeCmsLink(row.id)
.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);
removeBatchCmsLink(selection.value.map((d) => d.id))
.then((msg) => {
hide();
message.success(msg);
reload();
})
.catch((e) => {
hide();
message.error(e.message);
});
limit,
where,
orders,
filters
}) => {
if (filters) {
where.status = filters.status;
}
});
};
/* 查询 */
const query = () => {
loading.value = true;
// 加载栏目数据
if (!navigationList.value) {
listCmsNavigation({}).then((res) => {
navigationList.value = toTreeData({
data: res?.map((d) => {
d.value = d.navigationId;
d.label = d.title;
return d;
}),
idField: 'navigationId',
parentIdField: 'parentId'
});
return pageCmsLink({
...where,
...orders,
page,
limit
});
}
};
};
/* 自定义行属性 */
const customRow = (record: CmsLink) => {
return {
// 行点击事件
onClick: () => {
// console.log(record);
// 表格列配置
const columns = ref<ColumnItem[]>([
// {
// key: 'index',
// width: 48,
// align: 'center',
// fixed: 'left',
// hideInSetting: true,
// customRender: ({ index }) => index + (tableRef.value?.tableIndex ?? 0)
// },
{
title: '图标',
dataIndex: 'icon',
key: 'icon',
align: 'center',
width: 120
},
// 行双击事件
onDblclick: () => {
openEdit(record);
{
title: '链接名称',
dataIndex: 'name',
key: 'name'
},
{
title: '链接地址',
dataIndex: 'url',
key: 'url'
},
{
title: '备注',
dataIndex: 'comments'
},
{
title: '所属栏目',
dataIndex: 'categoryName',
align: 'center',
width: 180,
hideInTable: true
},
{
title: '状态',
dataIndex: 'status',
key: 'status',
align: 'center',
width: 120,
showSorterTooltip: false,
customRender: ({ text }) => ['显示', '隐藏'][text]
},
{
title: '操作',
key: 'action',
width: 200,
align: 'center'
}
]);
/* 搜索 */
const reload = (where?: CmsLinkParam) => {
selection.value = [];
tableRef?.value?.reload({ where: where });
};
/* 打开编辑弹窗 */
const openEdit = (row?: CmsLink) => {
current.value = row ?? null;
showEdit.value = true;
};
/* 打开批量移动弹窗 */
const openMove = () => {
showMove.value = true;
};
/* 删除单个 */
const remove = (row: CmsLink) => {
const hide = message.loading('请求中..', 0);
removeCmsLink(row.id)
.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);
removeBatchCmsLink(selection.value.map((d) => d.id))
.then((msg) => {
hide();
message.success(msg);
reload();
})
.catch((e) => {
hide();
message.error(e.message);
});
}
});
};
/* 查询 */
const query = () => {
loading.value = true;
// 加载栏目数据
if (!navigationList.value) {
listCmsNavigation({}).then((res) => {
navigationList.value = toTreeData({
data: res?.map((d) => {
d.value = d.navigationId;
d.label = d.title;
return d;
}),
idField: 'navigationId',
parentIdField: 'parentId'
});
});
}
};
};
query();
/* 自定义行属性 */
const customRow = (record: CmsLink) => {
return {
// 行点击事件
onClick: () => {
// console.log(record);
},
// 行双击事件
onDblclick: () => {
openEdit(record);
}
};
};
query();
</script>
<script lang="ts">
export default {
name: 'CmsLink'
};
export default {
name: 'CmsLink'
};
</script>
<style lang="less" scoped></style>

View File

@@ -20,11 +20,7 @@
"
>
<a-form-item label="模型名称" name="name">
<a-input
allow-clear
placeholder="文章"
v-model:value="form.name"
/>
<a-input allow-clear placeholder="文章" v-model:value="form.name" />
</a-form-item>
<a-form-item label="模型标识" name="model">
<a-input
@@ -85,36 +81,37 @@
</a-space>
</a-form-item>
<a-form-item label="style" name="style">
<a-input
allow-clear
placeholder="style"
v-model:value="form.style"
/>
<a-input allow-clear placeholder="style" v-model:value="form.style" />
<div class="pt-2">
<a class="text-sm text-gray-500" href="https://www.tailwindcss.cn/docs/installation" target="_blank">Tailwind Css使用教程</a>
<a
class="text-sm text-gray-500"
href="https://www.tailwindcss.cn/docs/installation"
target="_blank"
>Tailwind Css使用教程</a
>
</div>
</a-form-item>
<!-- <a-form-item label="Banner标题" name="title">-->
<!-- <a-input-->
<!-- allow-clear-->
<!-- placeholder="请输入Banner上的标题"-->
<!-- v-model:value="form.title"-->
<!-- />-->
<!-- </a-form-item>-->
<!-- <a-form-item label="Banner描述" name="describe">-->
<!-- <a-input-->
<!-- allow-clear-->
<!-- placeholder="请输入Banner上的描述"-->
<!-- v-model:value="form.describe"-->
<!-- />-->
<!-- </a-form-item>-->
<!-- <a-form-item label="显示方式" name="showType">-->
<!-- <a-radio-group v-model:value="form.showType">-->
<!-- <a-radio :value="0">文字列表</a-radio>-->
<!-- <a-radio :value="10">小图展示</a-radio>-->
<!-- <a-radio :value="20">大图展示</a-radio>-->
<!-- </a-radio-group>-->
<!-- </a-form-item>-->
<!-- <a-form-item label="Banner标题" name="title">-->
<!-- <a-input-->
<!-- allow-clear-->
<!-- placeholder="请输入Banner上的标题"-->
<!-- v-model:value="form.title"-->
<!-- />-->
<!-- </a-form-item>-->
<!-- <a-form-item label="Banner描述" name="describe">-->
<!-- <a-input-->
<!-- allow-clear-->
<!-- placeholder="请输入Banner上的描述"-->
<!-- v-model:value="form.describe"-->
<!-- />-->
<!-- </a-form-item>-->
<!-- <a-form-item label="显示方式" name="showType">-->
<!-- <a-radio-group v-model:value="form.showType">-->
<!-- <a-radio :value="0">文字列表</a-radio>-->
<!-- <a-radio :value="10">小图展示</a-radio>-->
<!-- <a-radio :value="20">大图展示</a-radio>-->
<!-- </a-radio-group>-->
<!-- </a-form-item>-->
<a-form-item label="排序" name="sortNumber">
<a-input-number
:min="0"
@@ -227,7 +224,7 @@
message: '请填写菜单路由地址',
trigger: 'blur'
}
],
]
// component: [
// {
// required: true,
@@ -244,7 +241,9 @@
url: data.path,
status: 'done'
});
form.banner = data.downloadUrl + '?x-oss-process=image/resize,m_fixed,w_2000/quality,Q_90';
form.banner =
data.downloadUrl +
'?x-oss-process=image/resize,m_fixed,w_2000/quality,Q_90';
form.thumb = data.path;
};
@@ -257,7 +256,7 @@
const onInput = () => {
form.component = `/pages/${form.model}/[id].vue`;
form.componentDetail = `/pages/${form.model}/detail/[id].vue`;
}
};
const { resetFields } = useForm(form, rules);
@@ -296,12 +295,12 @@
images.value = [];
if (props.data) {
assignObject(form, props.data);
if(props.data.banner){
if (props.data.banner) {
images.value.push({
uid: uuid(),
url: props.data.banner,
status: 'done'
})
});
}
isUpdate.value = true;
} else {

View File

@@ -1,7 +1,7 @@
<!-- 搜索表单 -->
<template>
<a-space :size="10" style="flex-wrap: wrap;">
<a-button type="primary" class="ele-btn-icon" @click="add">
<a-space :size="10" style="flex-wrap: wrap">
<a-button type="primary" class="ele-btn-icon" @click="add">
<template #icon>
<PlusOutlined />
</template>
@@ -13,7 +13,7 @@
<script lang="ts" setup>
import { PlusOutlined } from '@ant-design/icons-vue';
import { watch } from 'vue';
import {CmsModelParam} from "@/api/cms/cmsModel/model";
import { CmsModelParam } from '@/api/cms/cmsModel/model';
const props = withDefaults(
defineProps<{

View File

@@ -3,58 +3,57 @@
<template #extra>
<CmsWebsiteSearch />
</template>
<a-card :bordered="false" :body-style="{ padding: '16px' }">
<ele-pro-table
ref="tableRef"
row-key="modelId"
: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"
/>
<a-card :bordered="false" :body-style="{ padding: '16px' }">
<ele-pro-table
ref="tableRef"
row-key="modelId"
: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 === 'banner'">
<a-image v-if="record.banner" :src="record.banner" :width="100" />
</template>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'banner'">
<a-image v-if="record.banner" :src="record.banner" :width="100" />
</template>
<template v-if="column.key === 'component'">
<div class="text-gray-300">{{ record.component }}</div>
</template>
<template v-if="column.key === 'componentDetail'">
<div class="text-gray-300">{{ record.componentDetail }}</div>
</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 v-if="column.key === 'component'">
<div class="text-gray-300">{{ record.component }}</div>
</template>
</ele-pro-table>
</a-card>
<!-- 编辑弹窗 -->
<CmsModelEdit v-model:visible="showEdit" :data="current" @done="reload" />
<template v-if="column.key === 'componentDetail'">
<div class="text-gray-300">{{ record.componentDetail }}</div>
</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>
<!-- 编辑弹窗 -->
<CmsModelEdit v-model:visible="showEdit" :data="current" @done="reload" />
</a-page-header>
</template>
@@ -70,10 +69,14 @@
} from 'ele-admin-pro/es/ele-pro-table/types';
import Search from './components/search.vue';
import CmsModelEdit from './components/cmsModelEdit.vue';
import { pageCmsModel, removeCmsModel, removeBatchCmsModel } from '@/api/cms/cmsModel';
import {
pageCmsModel,
removeCmsModel,
removeBatchCmsModel
} from '@/api/cms/cmsModel';
import type { CmsModel, CmsModelParam } from '@/api/cms/cmsModel/model';
import {getPageTitle} from "@/utils/common";
import CmsWebsiteSearch from "@/views/cms/cmsWebsite/components/search.vue";
import { getPageTitle } from '@/utils/common';
import CmsWebsiteSearch from '@/views/cms/cmsWebsite/components/search.vue';
// 表格实例
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
@@ -114,7 +117,7 @@
title: '模型名称',
dataIndex: 'name',
key: 'name',
width: 180,
width: 180
},
{
title: '模型标识',
@@ -149,7 +152,7 @@
dataIndex: 'sortNumber',
key: 'sortNumber',
width: 120,
align: 'center',
align: 'center'
},
{
title: '创建时间',

View File

@@ -77,4 +77,3 @@
emit('update:visible', value);
};
</script>

View File

@@ -92,7 +92,10 @@
import { ref, reactive, watch } from 'vue';
import { Form, message } from 'ant-design-vue';
import { assignObject, uuid } from 'ele-admin-pro';
import { addCmsDesignRecord, updateCmsDesignRecord } from '@/api/cms/cmsDesignRecord';
import {
addCmsDesignRecord,
updateCmsDesignRecord
} from '@/api/cms/cmsDesignRecord';
import { CmsDesignRecord } from '@/api/cms/cmsDesignRecord/model';
import { useThemeStore } from '@/store/modules/theme';
import { storeToRefs } from 'pinia';

View File

@@ -1,60 +1,62 @@
<!-- 搜索表单 -->
<template>
<a-space style="flex-wrap: wrap" v-if="hasRole('superAdmin') || hasRole('admin') || hasRole('foundation')">
<!-- <a-button-->
<!-- type="text"-->
<!-- @click="openUrl('/mp-pages')"-->
<!-- >小程序端-->
<!-- </a-button>-->
<a-space
style="flex-wrap: wrap"
v-if="hasRole('superAdmin') || hasRole('admin') || hasRole('foundation')"
>
<!-- <a-button-->
<!-- type="text"-->
<!-- @click="openUrl('/mp-pages')"-->
<!-- >小程序端-->
<!-- </a-button>-->
</a-space>
</template>
<script lang="ts" setup>
import {watch,nextTick} from 'vue';
import {CmsWebsite} from '@/api/cms/cmsWebsite/model';
import {openUrl} from "@/utils/common";
import {message} from 'ant-design-vue';
import {removeSiteInfoCache} from "@/api/cms/cmsWebsite";
import {hasRole} from "@/utils/permission";
import { watch, nextTick } from 'vue';
import { CmsWebsite } from '@/api/cms/cmsWebsite/model';
import { openUrl } from '@/utils/common';
import { message } from 'ant-design-vue';
import { removeSiteInfoCache } from '@/api/cms/cmsWebsite';
import { hasRole } from '@/utils/permission';
const props = withDefaults(
defineProps<{
// 选中的角色
selection?: [];
website?: CmsWebsite;
count?: 0;
}>(),
{}
);
const props = withDefaults(
defineProps<{
// 选中的角色
selection?: [];
website?: CmsWebsite;
count?: 0;
}>(),
{}
);
const emit = defineEmits<{
(e: 'add'): void;
}>();
const emit = defineEmits<{
(e: 'add'): void;
}>();
const add = () => {
emit('add');
};
const add = () => {
emit('add');
};
// 清除缓存
const clearSiteInfoCache = () => {
removeSiteInfoCache('SiteInfo:' + localStorage.getItem('TenantId') + "*").then(
(msg) => {
// 清除缓存
const clearSiteInfoCache = () => {
removeSiteInfoCache(
'SiteInfo:' + localStorage.getItem('TenantId') + '*'
).then((msg) => {
if (msg) {
message.success(msg);
}
});
};
nextTick(() => {
if (localStorage.getItem('NotActive')) {
// IsActive.value = false
}
});
watch(
() => props.selection,
() => {}
);
};
nextTick(() => {
if(localStorage.getItem('NotActive')){
// IsActive.value = false
}
})
watch(
() => props.selection,
() => {
}
);
</script>

View File

@@ -61,7 +61,7 @@
allow-clear
:placeholder="`请输入详情页ID`"
v-model:value="form.itemId"
style="width: 276px;"
style="width: 276px"
@pressEnter="save"
/>
</a-form-item>
@@ -74,10 +74,7 @@
<!-- @pressEnter="save"-->
<!-- />-->
<!-- </a-form-item>-->
<a-form-item
:label="'path'"
name="path"
>
<a-form-item :label="'path'" name="path">
<a-input
allow-clear
:placeholder="pathPlaceholder"
@@ -156,7 +153,7 @@
@del="onDeleteItem"
/>
</a-form-item>
<a-divider style="margin-bottom: 16px"/>
<a-divider style="margin-bottom: 16px" />
<a-form-item label="状态" name="hide">
<a-space>
<a-switch
@@ -185,8 +182,12 @@
v-model:value="password"
/>
</a-form-item>
<a-form-item label="关联栏目" name="style" v-if="lang && lang != 'zh_CN'"
extra="选择对应中文栏目,用于同步保存翻译内容">
<a-form-item
label="关联栏目"
name="style"
v-if="lang && lang != 'zh_CN'"
extra="选择对应中文栏目,用于同步保存翻译内容"
>
<a-tree-select
allow-clear
:tree-data="zhCmsNavigationList"
@@ -204,392 +205,389 @@
</template>
<script lang="ts" setup>
import {ref, reactive, watch} from 'vue';
import {message} from 'ant-design-vue/es';
import type {FormInstance, Rule} from 'ant-design-vue/es/form';
import {storeToRefs} from 'pinia';
import {useI18n} from 'vue-i18n';
import {toTreeData} from 'ele-admin-pro/es';
import {useThemeStore} from '@/store/modules/theme';
import useFormData from '@/utils/use-form-data';
import {CmsNavigation} from '@/api/cms/cmsNavigation/model';
import {
addCmsNavigation, listCmsNavigation,
updateCmsNavigation
} from '@/api/cms/cmsNavigation';
import {ItemType} from 'ele-admin-pro/es/ele-image-upload/types';
import {FileRecord} from '@/api/system/file/model';
import {uuid} from "ele-admin-pro";
import {CmsModel} from "@/api/cms/cmsModel/model";
import {listCmsModel} from "@/api/cms/cmsModel";
import { ref, reactive, watch } from 'vue';
import { message } from 'ant-design-vue/es';
import type { FormInstance, Rule } from 'ant-design-vue/es/form';
import { storeToRefs } from 'pinia';
import { useI18n } from 'vue-i18n';
import { toTreeData } from 'ele-admin-pro/es';
import { useThemeStore } from '@/store/modules/theme';
import useFormData from '@/utils/use-form-data';
import { CmsNavigation } from '@/api/cms/cmsNavigation/model';
import {
addCmsNavigation,
listCmsNavigation,
updateCmsNavigation
} from '@/api/cms/cmsNavigation';
import { ItemType } from 'ele-admin-pro/es/ele-image-upload/types';
import { FileRecord } from '@/api/system/file/model';
import { uuid } from 'ele-admin-pro';
import { CmsModel } from '@/api/cms/cmsModel/model';
import { listCmsModel } from '@/api/cms/cmsModel';
// 是否开启响应式布局
const themeStore = useThemeStore();
const {styleResponsive} = storeToRefs(themeStore);
const {locale} = useI18n();
// 是否开启响应式布局
const themeStore = useThemeStore();
const { styleResponsive } = storeToRefs(themeStore);
const { locale } = useI18n();
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 props = defineProps<{
// 弹窗是否打开
visible: boolean;
// 修改回显的数据
data?: CmsNavigation | null;
// 上级分类id
parentId?: number;
// 位置
position?: number;
// 全部导航数据
navigationList: CmsNavigation[];
// 模型
model?: string;
}>();
const props = defineProps<{
// 弹窗是否打开
visible: boolean;
// 修改回显的数据
data?: CmsNavigation | null;
// 上级分类id
parentId?: number;
// 位置
position?: number;
// 全部导航数据
navigationList: CmsNavigation[];
// 模型
model?: string;
}>();
const models = ref<CmsModel[]>([]);
//
const formRef = ref<FormInstance | null>(null);
// 是否是修改
const isUpdate = ref(false);
// 提交状态
const loading = ref(false);
// 已上传数据
const images = ref<ItemType[]>([]);
const password = ref();
const pathPlaceholder = ref<string>('/pages/index/index');
const lang = ref(localStorage.getItem('i18n-lang'));
const zhCmsNavigationList = ref<CmsNavigation[]>([]);
const models = ref<CmsModel[]>([]);
//
const formRef = ref<FormInstance | null>(null);
// 是否是修改
const isUpdate = ref(false);
// 提交状态
const loading = ref(false);
// 已上传数据
const images = ref<ItemType[]>([]);
const password = ref();
const pathPlaceholder = ref<string>('/pages/index/index');
const lang = ref(localStorage.getItem('i18n-lang'));
const zhCmsNavigationList = ref<CmsNavigation[]>([]);
// 表单数据
const {form, resetFields, assignFields} = useFormData<CmsNavigation>({
navigationId: undefined,
model: 'page',
code: undefined,
modelName: undefined,
type: 0,
title: '',
parentId: 0,
parentName: undefined,
parentPath: undefined,
parentPosition: undefined,
path: undefined,
component: undefined,
componentPath: '/pages/[page].vue',
sortNumber: 100,
comments: '',
hide: 0,
permission: 0,
password: undefined,
position: 1,
top: 0,
bottom: 1,
gutter: undefined,
span: 0,
isMpWeixin: undefined,
status: 0,
pageId: 0,
itemId: 0,
lang: locale.value,
langCategoryId: undefined,
tenantId: undefined
});
// 表单验证规则
const rules = reactive<Record<string, Rule[]>>({
title: [
{
required: true,
message: '请输入菜单名称',
type: 'string',
trigger: 'blur'
}
],
itemId: [
{
required: true,
message: '请选择详情页ID',
type: 'number',
trigger: 'blur'
}
],
path: [
{
required: true,
message: '请输入路由地址',
type: 'string',
trigger: 'blur'
}
],
model: [
{
required: true,
message: '请选择模型',
type: 'string',
trigger: 'blur'
}
],
// component: [
// {
// required: true,
// type: 'string',
// trigger: 'blur',
// validator: (_rule: Rule, value: string) => {
// return new Promise<void>((resolve, reject) => {
// if (!value) {
// return reject('请填写组件路径');
// }
// if (value.charAt(0) != '/') {
// return reject('请填写路由地址,必须是以"/"开头的英文字母+数字');
// }
// if (isChinese(value)) {
// return reject('不支持中文');
// }
// resolve();
// });
// }
// }
// ],
// path: [
// {
// required: true,
// type: 'string',
// trigger: 'blur',
// validator: (_rule: Rule, value: string) => {
// return new Promise<void>((resolve, reject) => {
// if (!value) {
// return reject('请填写路由地址');
// }
// if (form.type == 9) {
// if (!isUrl(value)) {
// return reject('请输入正确的网址');
// }
// resolve();
// }
// if (form.type == 1) {
// if (form.pageId == 0) {
// return reject('请选择页面');
// }
// }
// if (value.charAt(0) != '/') {
// return reject('请填写路由地址,必须是以"/"开头的英文字母+数字');
// }
// if (isChinese(value)) {
// return reject('不支持中文');
// }
// resolve();
// // checkExistence('path', value, form.navigationId)
// // .then((msg) => {
// // return reject(msg);
// // })
// // .catch(() => {
// // resolve();
// // });
// });
// }
// }
// ],
status: [
{
required: true,
message: '请设置是否展示',
type: 'number',
trigger: 'blur'
}
]
});
const chooseModel = (item: CmsModel) => {
form.model = `${item.model}`;
form.path = `${item.path}`;
form.component = `${item.component}`;
form.itemId = undefined;
if (item.model == 'links') {
pathPlaceholder.value = 'https://';
}
if (item.model == 'product') {
pathPlaceholder.value = '/iphone-15-pro';
}
};
const chooseFile = (data: FileRecord) => {
images.value.push({
uid: data.id,
url: data.path,
status: 'done'
// 表单数据
const { form, resetFields, assignFields } = useFormData<CmsNavigation>({
navigationId: undefined,
model: 'page',
code: undefined,
modelName: undefined,
type: 0,
title: '',
parentId: 0,
parentName: undefined,
parentPath: undefined,
parentPosition: undefined,
path: undefined,
component: undefined,
componentPath: '/pages/[page].vue',
sortNumber: 100,
comments: '',
hide: 0,
permission: 0,
password: undefined,
position: 1,
top: 0,
bottom: 1,
gutter: undefined,
span: 0,
isMpWeixin: undefined,
status: 0,
pageId: 0,
itemId: 0,
lang: locale.value,
langCategoryId: undefined,
tenantId: undefined
});
form.icon = data.path;
};
const onDeleteItem = (index: number) => {
images.value.splice(index, 1);
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) {
return;
}
formRef.value
.validate()
.then(() => {
if (password.value) {
form.password = password.value;
// 表单验证规则
const rules = reactive<Record<string, Rule[]>>({
title: [
{
required: true,
message: '请输入菜单名称',
type: 'string',
trigger: 'blur'
}
if (form.model == 'detail' && form.itemId == 0) {
message.error('请输入文章ID');
return false;
],
itemId: [
{
required: true,
message: '请选择详情页ID',
type: 'number',
trigger: 'blur'
}
if (form.model == 'item' && form.itemId == 0) {
message.error('请输入产品ID');
return false;
],
path: [
{
required: true,
message: '请输入路由地址',
type: 'string',
trigger: 'blur'
}
if (form.path == '/') {
form.model = 'index';
form.sortNumber = 0;
],
model: [
{
required: true,
message: '请选择模型',
type: 'string',
trigger: 'blur'
}
const navigationForm = {
...form,
parentId: form.parentId || 0
};
const saveOrUpdate = isUpdate.value
? updateCmsNavigation
: addCmsNavigation;
saveOrUpdate(navigationForm)
.then((msg) => {
message.success(msg);
updateVisible(false);
emit('done');
})
.catch((e) => {
message.error(e.message);
});
})
.catch(() => {
});
};
/* 更新visible */
const updateVisible = (value: boolean) => {
emit('update:visible', value);
};
const updateHideValue = (value: boolean) => {
form.hide = value ? 0 : 1;
};
// 获取模型列表
const getModels = () => {
listCmsModel({}).then(res => {
models.value = res.map(d => {
d.label = d.name;
d.value = d.model;
return d;
});
})
}
// 简体中文栏目
if (lang.value != 'zh_CN') {
listCmsNavigation({
lang: 'zh_CN'
}).then(list => {
zhCmsNavigationList.value = toTreeData({
data: list.map((d) => {
return {...d, key: d.navigationId, value: d.navigationId};
}),
idField: 'navigationId',
parentIdField: 'parentId'
});
})
}
watch(
() => props.visible,
(visible) => {
getModels();
if (visible) {
form.position = props.position;
images.value = [];
if (props.parentId) {
form.parentId = props.parentId;
],
// component: [
// {
// required: true,
// type: 'string',
// trigger: 'blur',
// validator: (_rule: Rule, value: string) => {
// return new Promise<void>((resolve, reject) => {
// if (!value) {
// return reject('请填写组件路径');
// }
// if (value.charAt(0) != '/') {
// return reject('请填写路由地址,必须是以"/"开头的英文字母+数字');
// }
// if (isChinese(value)) {
// return reject('不支持中文');
// }
// resolve();
// });
// }
// }
// ],
// path: [
// {
// required: true,
// type: 'string',
// trigger: 'blur',
// validator: (_rule: Rule, value: string) => {
// return new Promise<void>((resolve, reject) => {
// if (!value) {
// return reject('请填写路由地址');
// }
// if (form.type == 9) {
// if (!isUrl(value)) {
// return reject('请输入正确的网址');
// }
// resolve();
// }
// if (form.type == 1) {
// if (form.pageId == 0) {
// return reject('请选择页面');
// }
// }
// if (value.charAt(0) != '/') {
// return reject('请填写路由地址,必须是以"/"开头的英文字母+数字');
// }
// if (isChinese(value)) {
// return reject('不支持中文');
// }
// resolve();
// // checkExistence('path', value, form.navigationId)
// // .then((msg) => {
// // return reject(msg);
// // })
// // .catch(() => {
// // resolve();
// // });
// });
// }
// }
// ],
status: [
{
required: true,
message: '请设置是否展示',
type: 'number',
trigger: 'blur'
}
if (props.model) {
form.model = props.model;
form.path = `/${props.model}`;
form.component = `/pages/${props.model}/index.vue`;
if (props.model == 'page') {
form.component = `/pages/[${props.model}]/index.vue`;
}
}
if (props.data) {
assignFields({
...props.data,
tempPath: props.data.path
});
if (props.data.icon) {
images.value.push({
uid: uuid(),
url: props.data.icon,
status: 'done'
});
}
if (form.lang == '') {
form.lang = locale.value;
}
if (props.data.parentPosition) {
form.position = props.data.parentPosition;
}
// if (props.data.type == 2) {
// form.pageName = props.data.title;
// }
isUpdate.value = true;
} else {
isUpdate.value = false;
}
} else {
resetFields();
formRef.value?.clearValidate();
]
});
const chooseModel = (item: CmsModel) => {
form.model = `${item.model}`;
form.path = `${item.path}`;
form.component = `${item.component}`;
form.itemId = undefined;
if (item.model == 'links') {
pathPlaceholder.value = 'https://';
}
if (item.model == 'product') {
pathPlaceholder.value = '/iphone-15-pro';
}
};
const chooseFile = (data: FileRecord) => {
images.value.push({
uid: data.id,
url: data.path,
status: 'done'
});
form.icon = data.path;
};
const onDeleteItem = (index: number) => {
images.value.splice(index, 1);
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) {
return;
}
formRef.value
.validate()
.then(() => {
if (password.value) {
form.password = password.value;
}
if (form.model == 'detail' && form.itemId == 0) {
message.error('请输入文章ID');
return false;
}
if (form.model == 'item' && form.itemId == 0) {
message.error('请输入产品ID');
return false;
}
if (form.path == '/') {
form.model = 'index';
form.sortNumber = 0;
}
const navigationForm = {
...form,
parentId: form.parentId || 0
};
const saveOrUpdate = isUpdate.value
? updateCmsNavigation
: addCmsNavigation;
saveOrUpdate(navigationForm)
.then((msg) => {
message.success(msg);
updateVisible(false);
emit('done');
})
.catch((e) => {
message.error(e.message);
});
})
.catch(() => {});
};
/* 更新visible */
const updateVisible = (value: boolean) => {
emit('update:visible', value);
};
const updateHideValue = (value: boolean) => {
form.hide = value ? 0 : 1;
};
// 获取模型列表
const getModels = () => {
listCmsModel({}).then((res) => {
models.value = res.map((d) => {
d.label = d.name;
d.value = d.model;
return d;
});
});
};
// 简体中文栏目
if (lang.value != 'zh_CN') {
listCmsNavigation({
lang: 'zh_CN'
}).then((list) => {
zhCmsNavigationList.value = toTreeData({
data: list.map((d) => {
return { ...d, key: d.navigationId, value: d.navigationId };
}),
idField: 'navigationId',
parentIdField: 'parentId'
});
});
}
);
watch(
() => props.visible,
(visible) => {
getModels();
if (visible) {
form.position = props.position;
images.value = [];
if (props.parentId) {
form.parentId = props.parentId;
}
if (props.model) {
form.model = props.model;
form.path = `/${props.model}`;
form.component = `/pages/${props.model}/index.vue`;
if (props.model == 'page') {
form.component = `/pages/[${props.model}]/index.vue`;
}
}
if (props.data) {
assignFields({
...props.data,
tempPath: props.data.path
});
if (props.data.icon) {
images.value.push({
uid: uuid(),
url: props.data.icon,
status: 'done'
});
}
if (form.lang == '') {
form.lang = locale.value;
}
if (props.data.parentPosition) {
form.position = props.data.parentPosition;
}
// if (props.data.type == 2) {
// form.pageName = props.data.title;
// }
isUpdate.value = true;
} else {
isUpdate.value = false;
}
} else {
resetFields();
formRef.value?.clearValidate();
}
}
);
</script>
<script lang="ts">
import * as icons from '@/layout/menu-icons';
import * as icons from '@/layout/menu-icons';
export default {
components: icons,
data() {
return {
iconData: [
{
title: '已引入的图标',
icons: Object.keys(icons)
}
]
};
}
};
export default {
components: icons,
data() {
return {
iconData: [
{
title: '已引入的图标',
icons: Object.keys(icons)
}
]
};
}
};
</script>

View File

@@ -1,7 +1,7 @@
<template>
<a-page-header :title="getPageTitle()" @back="() => $router.go(-1)">
<template #extra>
<Extra/>
<Extra />
</template>
<a-card :bordered="false">
<!-- 表格 -->
@@ -24,7 +24,7 @@
<a-space>
<a-button type="primary" class="ele-btn-icon" @click="openEdit()">
<template #icon>
<PlusOutlined/>
<PlusOutlined />
</template>
<span>新建</span>
</a-button>
@@ -44,19 +44,30 @@
折叠
</a-button>
</template>
<a-divider type="vertical"/>
<a-button type="dashed" :disabled="!hasRole('superAdmin')" @click="handleExport">备份</a-button>
<a-button type="dashed" :disabled="!hasRole('superAdmin')" @click="openImport">恢复</a-button>
<a-divider type="vertical" />
<a-button
type="dashed"
@click="push('/website/model')"
>模型管理
</a-button
:disabled="!hasRole('superAdmin')"
@click="handleExport"
>备份</a-button
>
<a-button
type="dashed"
:disabled="!hasRole('superAdmin')"
@click="openImport"
>恢复</a-button
>
<a-button type="dashed" @click="push('/website/model')"
>模型管理
</a-button>
<a-button
type="dashed"
class="ele-btn-icon"
@click="clearSiteInfoCache"
>
<a-button type="dashed" class="ele-btn-icon" @click="clearSiteInfoCache">
清除缓存
</a-button>
<a-divider type="vertical"/>
<a-divider type="vertical" />
<a-radio-group v-model:value="position" @change="reload">
<a-radio-button :value="1">顶部</a-radio-button>
<a-radio-button :value="2">底部</a-radio-button>
@@ -69,8 +80,10 @@
@change="reload"
>
<a-select-option :value="undefined">不限</a-select-option>
<template v-for="(item,index) in modelList" :key="index">
<a-select-option :value="item.model" :index="index">{{ item.name }}</a-select-option>
<template v-for="(item, index) in modelList" :key="index">
<a-select-option :value="item.model" :index="index">{{
item.name
}}</a-select-option>
</template>
</a-select>
<!-- 搜索表单 -->
@@ -86,30 +99,45 @@
<template #bodyCell="{ column, record, index }">
<template v-if="column.key === 'title'">
<a-space>
<a-avatar v-if="record.icon" :size="22" :src="record.icon"/>
<a @click="push({
path: `/article`,
query: {
id: record.navigationId,
name: record.title,
model: record.model
}
})">{{ record.title }}</a>
<a-avatar v-if="record.icon" :size="22" :src="record.icon" />
<a
@click="
push({
path: `/article`,
query: {
id: record.navigationId,
name: record.title,
model: record.model
}
})
"
>{{ record.title }}</a
>
</a-space>
<template v-if="record.model == 'page'">
<a-divider type="vertical"/>
<a-tooltip v-if="record.model == 'page'" :title="`编辑页面内容及SEO信息`">
<a-divider type="vertical" />
<a-tooltip
v-if="record.model == 'page'"
:title="`编辑页面内容及SEO信息`"
>
<a @click="openDesign(record)">
<FileWordOutlined/>
<FileWordOutlined />
</a>
</a-tooltip>
</template>
</template>
<template v-if="column.key === 'path'">
<div @mouseover="saveNavigationIcon(record.navigationId)" @mouseleave="removeNavigationIcon">
<div
@mouseover="saveNavigationIcon(record.navigationId)"
@mouseleave="removeNavigationIcon"
>
<span class="text-gray-400">{{ record.path }}</span>
<span class="text-gray-400" v-if="currentId == record.navigationId" @click="copyText(record.path)"><CopyOutlined
class="px-2"/></span>
<span
class="text-gray-400"
v-if="currentId == record.navigationId"
@click="copyText(record.path)"
><CopyOutlined class="px-2"
/></span>
</div>
</template>
<template v-if="column.key === 'component'">
@@ -125,9 +153,8 @@
</template>
<template v-if="column.key === 'type'">
<a-tag v-if="isExternalLink(record.path)" color="purple"
>外部链接
</a-tag
>
>外部链接
</a-tag>
<a-tag v-else-if="index === 0" color="orange">首页</a-tag>
<a-tag v-else-if="isExternalLink(record.component)" color="orange">
内链
@@ -136,7 +163,7 @@
<a-tag v-else>{{ record.modelName }}</a-tag>
</template>
<template v-if="column.key === 'banner'">
<a-image v-if="record.banner" :src="record.banner" :width="100"/>
<a-image v-if="record.banner" :src="record.banner" :width="100" />
</template>
<template v-if="column.key === 'showIndex'">
<a-tag v-if="record.showIndex === 1" color="green">显示</a-tag>
@@ -145,10 +172,10 @@
<template v-if="column.key === 'position'">
<a-space>
<span v-if="record.top === 0" class="ele-text-placeholder"
>顶部</span
>顶部</span
>
<span v-if="record.bottom === 0" class="ele-text-placeholder"
>底部</span
>底部</span
>
<span v-if="record.top === 0 || record.bottom === 0"></span>
</a-space>
@@ -156,7 +183,7 @@
<template v-if="column.key === 'hide'">
<span v-if="record.hide === 0" class="ele-text-success">显示</span>
<span v-if="record.hide === 1" class="ele-text-placeholder"
>隐藏</span
>隐藏</span
>
</template>
<template v-else-if="column.key === 'action'">
@@ -166,15 +193,17 @@
<!-- <a-divider type="vertical"/>-->
<!-- </a-tooltip>-->
<a-tooltip :title="`添加子分类`">
<a @click="openEdit(null, record.navigationId,record.model)">添加</a>
<a @click="openEdit(null, record.navigationId, record.model)"
>添加</a
>
</a-tooltip>
<!-- <a-divider type="vertical" />-->
<!-- <a-tooltip :title="`自定义组件`">-->
<!-- <a @click="openDesign(record)">组件</a>-->
<!-- </a-tooltip>-->
<a-divider type="vertical"/>
<a-divider type="vertical" />
<a @click="openEdit(record)">修改</a>
<a-divider type="vertical"/>
<a-divider type="vertical" />
<a-popconfirm
placement="topRight"
title="确定要删除此菜单吗?"
@@ -194,7 +223,7 @@
<!-- <a @click="openDesign(record)">组件</a>-->
<!-- </a-tooltip>-->
<a @click="openEdit(record)">修改</a>
<a-divider type="vertical"/>
<a-divider type="vertical" />
<a-popconfirm
placement="topRight"
title="确定要删除此菜单吗?"
@@ -228,363 +257,370 @@
</template>
<script lang="ts" setup>
import {ref} from 'vue';
import {message} from 'ant-design-vue/es';
import {PlusOutlined, CopyOutlined, FileWordOutlined, MinusOutlined, MinusSquareOutlined, PlusSquareOutlined} from '@ant-design/icons-vue';
import type {
DatasourceFunction,
ColumnItem,
EleProTableDone
} from 'ele-admin-pro/es/ele-pro-table/types';
import {
messageLoading,
toDateString,
isExternalLink,
toTreeData,
eachTreeData
} from 'ele-admin-pro/es';
import type {EleProTable} from 'ele-admin-pro/es';
import {useI18n} from 'vue-i18n';
import CmsNavigationEdit from './components/navigation-edit.vue';
import DesignEdit from './components/design-edit.vue';
import {
listCmsNavigation,
removeCmsNavigation
} from '@/api/cms/cmsNavigation';
import type {
CmsNavigation,
CmsNavigationParam
} from '@/api/cms/cmsNavigation/model';
import {copyText, getPageTitle} from '@/utils/common';
import {CmsDesign} from '@/api/cms/cmsDesign/model';
import {removeSiteInfoCache} from '@/api/cms/cmsWebsite';
import Extra from "./components/extra.vue";
import {useRouter} from 'vue-router';
import {listCmsModel} from "@/api/cms/cmsModel";
import {CmsModel} from "@/api/cms/cmsModel/model";
import {hasRole} from "@/utils/permission";
import { ref } from 'vue';
import { message } from 'ant-design-vue/es';
import {
PlusOutlined,
CopyOutlined,
FileWordOutlined,
MinusOutlined,
MinusSquareOutlined,
PlusSquareOutlined
} from '@ant-design/icons-vue';
import type {
DatasourceFunction,
ColumnItem,
EleProTableDone
} from 'ele-admin-pro/es/ele-pro-table/types';
import {
messageLoading,
toDateString,
isExternalLink,
toTreeData,
eachTreeData
} from 'ele-admin-pro/es';
import type { EleProTable } from 'ele-admin-pro/es';
import { useI18n } from 'vue-i18n';
import CmsNavigationEdit from './components/navigation-edit.vue';
import DesignEdit from './components/design-edit.vue';
import {
listCmsNavigation,
removeCmsNavigation
} from '@/api/cms/cmsNavigation';
import type {
CmsNavigation,
CmsNavigationParam
} from '@/api/cms/cmsNavigation/model';
import { copyText, getPageTitle } from '@/utils/common';
import { CmsDesign } from '@/api/cms/cmsDesign/model';
import { removeSiteInfoCache } from '@/api/cms/cmsWebsite';
import Extra from './components/extra.vue';
import { useRouter } from 'vue-router';
import { listCmsModel } from '@/api/cms/cmsModel';
import { CmsModel } from '@/api/cms/cmsModel/model';
import { hasRole } from '@/utils/permission';
const {push} = useRouter();
// 表格实例
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
const modelList = ref<CmsModel[]>([])
const currentId = ref<number>();
const modelName = ref<string>();
// 国际化
const {locale} = useI18n();
const { push } = useRouter();
// 表格实例
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
const modelList = ref<CmsModel[]>([]);
const currentId = ref<number>();
const modelName = ref<string>();
// 国际化
const { locale } = useI18n();
// 表格列配置
const columns = ref<ColumnItem[]>([
// {
// key: 'index',
// width: 48,
// align: 'center',
// fixed: 'left',
// hideInSetting: true,
// customRender: ({ index }) => index + (tableRef.value?.tableIndex ?? 0)
// },
{
title: 'ID',
dataIndex: 'navigationId',
key: 'navigationId',
width: 90
},
{
title: '栏目名称',
dataIndex: 'title',
key: 'title',
showSorterTooltip: false,
ellipsis: true
},
{
title: '路径',
dataIndex: 'path',
key: 'path'
},
{
title: '组件路径',
dataIndex: 'component',
hideInTable: true,
key: 'component'
},
{
title: '模型',
dataIndex: 'model',
key: 'model',
width: 120,
align: 'center'
},
{
title: 'banner',
dataIndex: 'banner',
align: 'center',
key: 'banner',
width: 120,
hideInTable: true
},
{
title: '位置',
dataIndex: 'position',
key: 'position',
align: 'center',
width: 120
},
{
title: '状态',
dataIndex: 'hide',
key: 'hide',
align: 'center',
width: 120,
showSorterTooltip: false,
customRender: ({text}) => ['显示', '隐藏'][text]
},
{
title: '排序',
dataIndex: 'sortNumber',
align: 'center',
width: 120,
showSorterTooltip: false
},
{
title: '创建时间',
dataIndex: 'createTime',
showSorterTooltip: false,
ellipsis: true,
hideInTable: true,
width: 180,
customRender: ({text}) => toDateString(text)
},
{
title: '操作',
key: 'action',
align: 'center',
width: 220,
fixed: 'right'
}
]);
// 当前编辑数据
const current = ref<CmsNavigation | null>(null);
// 当前选中页面
const design = ref<CmsDesign>();
// 是否显示编辑弹窗
const showEdit = ref(false);
// 编辑内容
const showDesignEdit = ref(false);
// 上级分类id
const parentId = ref<number>();
const categoryId = ref<number>();
// 分类数据
const navigationData = ref<CmsNavigation[]>([]);
// 表格展开的行
const expandedRowKeys = ref<number[]>([]);
const searchText = ref('');
const position = ref(undefined);
const model = ref<any>('page')
// 清除缓存
const clearSiteInfoCache = () => {
removeSiteInfoCache('SiteInfo:' + localStorage.getItem('TenantId')).then(
(msg) => {
if (msg) {
message.success(msg);
}
}
);
};
// 表格数据源
const datasource: DatasourceFunction = ({where}) => {
where = {};
where.keywords = searchText.value;
where.top = undefined;
where.bottom = undefined;
if (position.value == 1) {
where.top = 0;
where.bottom = undefined;
}
if (position.value == 2) {
where.top = undefined;
where.bottom = 0;
}
if (position.value == 0) {
where.top = undefined;
where.bottom = undefined;
}
where.isMpWeixin = false;
if (locale.value) {
where.lang = locale.value || undefined;
}
where.model = modelName.value;
return listCmsNavigation({...where});
};
/* 数据转为树形结构 */
const parseData = (data: CmsNavigation[]) => {
return toTreeData({
data: data.map((d) => {
return {...d, key: d.navigationId, value: d.navigationId};
}),
idField: 'navigationId',
parentIdField: 'parentId'
});
};
/* 表格渲染完成回调 */
const onDone: EleProTableDone<CmsNavigation> = ({data}) => {
navigationData.value = data;
expandAll()
};
/* 刷新表格 */
const reload = (where?: CmsNavigationParam) => {
console.log(where, 'w')
tableRef?.value?.reload({where});
};
/* 打开编辑弹窗 */
const openEdit = (row?: CmsNavigation | null, id?: number, mod?: string) => {
current.value = row ?? null;
model.value = mod ?? null;
parentId.value = id;
showEdit.value = true;
};
// 跳转模型内容列表
const openDesign = (row?: CmsNavigation) => {
categoryId.value = row?.navigationId;
showDesignEdit.value = true;
return;
// if (row && isDirectory(row)) {
// categoryId.value = row?.navigationId;
// showDesignEdit.value = true;
// return;
// }
// TODO 单页模型
// if (row?.model == 'custom') {
// router.push({
// path: `/cms/design`,
// query: {
// id: row.navigationId,
// type: row.model
// }
// });
// return;
// }
// TODO 文章列表
// if (row?.model === 'article') {
// router.push({
// path: `/cms/article`,
// query: {
// id: row.navigationId,
// type: row.model
// }
// });
// return;
// }
// TODO 产品列表
// if (row?.model === 'product') {
// router.push({
// path: '/goods/index',
// query: { categoryId: row.navigationId, type: row.type }
// });
// return;
// }
};
const onModel = () => {
reload()
}
const saveNavigationIcon = (index: number) => {
currentId.value = index;
}
const removeNavigationIcon = () => {
currentId.value = undefined;
}
/* 删除单个 */
const remove = (row: CmsNavigation) => {
console.log(row);
if (row.children?.length) {
message.error('请先删除子节点');
return;
}
const hide = messageLoading('请求中..', 0);
removeCmsNavigation(row.navigationId)
.then((msg) => {
hide();
message.success(msg);
reload();
})
.catch((e) => {
hide();
message.error(e.message);
});
};
/* 展开全部 */
const expandAll = () => {
let keys: number[] = [];
eachTreeData(navigationData.value, (d) => {
if (d.children && d.children.length && d.navigationId) {
keys.push(d.navigationId);
}
});
expandedRowKeys.value = keys;
};
/* 折叠全部 */
const foldAll = () => {
expandedRowKeys.value = [];
};
/* 点击展开图标时触发 */
const onExpand = (expanded: boolean, record: CmsNavigation) => {
if (expanded) {
expandedRowKeys.value = [
...expandedRowKeys.value,
record.navigationId as number
];
} else {
expandedRowKeys.value = expandedRowKeys.value.filter(
(d) => d !== record.navigationId
);
}
};
/* 判断是否是目录 */
const isDirectory = (d: CmsNavigation) => {
return !!d.children?.length;
};
listCmsModel().then((data) => {
modelList.value = data;
});
/* 自定义行属性 */
const customRow = (record: CmsNavigation) => {
return {
// 行点击事件
onClick: () => {
// console.log(record);
// 表格列配置
const columns = ref<ColumnItem[]>([
// {
// key: 'index',
// width: 48,
// align: 'center',
// fixed: 'left',
// hideInSetting: true,
// customRender: ({ index }) => index + (tableRef.value?.tableIndex ?? 0)
// },
{
title: 'ID',
dataIndex: 'navigationId',
key: 'navigationId',
width: 90
},
// 行双击事件
onDblclick: () => {
if (record.model !== 'index') {
openEdit(record);
{
title: '栏目名称',
dataIndex: 'title',
key: 'title',
showSorterTooltip: false,
ellipsis: true
},
{
title: '路径',
dataIndex: 'path',
key: 'path'
},
{
title: '组件路径',
dataIndex: 'component',
hideInTable: true,
key: 'component'
},
{
title: '模型',
dataIndex: 'model',
key: 'model',
width: 120,
align: 'center'
},
{
title: 'banner',
dataIndex: 'banner',
align: 'center',
key: 'banner',
width: 120,
hideInTable: true
},
{
title: '位置',
dataIndex: 'position',
key: 'position',
align: 'center',
width: 120
},
{
title: '状态',
dataIndex: 'hide',
key: 'hide',
align: 'center',
width: 120,
showSorterTooltip: false,
customRender: ({ text }) => ['显示', '隐藏'][text]
},
{
title: '排序',
dataIndex: 'sortNumber',
align: 'center',
width: 120,
showSorterTooltip: false
},
{
title: '创建时间',
dataIndex: 'createTime',
showSorterTooltip: false,
ellipsis: true,
hideInTable: true,
width: 180,
customRender: ({ text }) => toDateString(text)
},
{
title: '操作',
key: 'action',
align: 'center',
width: 220,
fixed: 'right'
}
]);
// 当前编辑数据
const current = ref<CmsNavigation | null>(null);
// 当前选中页面
const design = ref<CmsDesign>();
// 是否显示编辑弹窗
const showEdit = ref(false);
// 编辑内容
const showDesignEdit = ref(false);
// 上级分类id
const parentId = ref<number>();
const categoryId = ref<number>();
// 分类数据
const navigationData = ref<CmsNavigation[]>([]);
// 表格展开的行
const expandedRowKeys = ref<number[]>([]);
const searchText = ref('');
const position = ref(undefined);
const model = ref<any>('page');
// 清除缓存
const clearSiteInfoCache = () => {
removeSiteInfoCache('SiteInfo:' + localStorage.getItem('TenantId')).then(
(msg) => {
if (msg) {
message.success(msg);
}
}
);
};
// 表格数据源
const datasource: DatasourceFunction = ({ where }) => {
where = {};
where.keywords = searchText.value;
where.top = undefined;
where.bottom = undefined;
if (position.value == 1) {
where.top = 0;
where.bottom = undefined;
}
if (position.value == 2) {
where.top = undefined;
where.bottom = 0;
}
if (position.value == 0) {
where.top = undefined;
where.bottom = undefined;
}
where.isMpWeixin = false;
if (locale.value) {
where.lang = locale.value || undefined;
}
where.model = modelName.value;
return listCmsNavigation({ ...where });
};
/* 数据转为树形结构 */
const parseData = (data: CmsNavigation[]) => {
return toTreeData({
data: data.map((d) => {
return { ...d, key: d.navigationId, value: d.navigationId };
}),
idField: 'navigationId',
parentIdField: 'parentId'
});
};
/* 表格渲染完成回调 */
const onDone: EleProTableDone<CmsNavigation> = ({ data }) => {
navigationData.value = data;
expandAll();
};
/* 刷新表格 */
const reload = (where?: CmsNavigationParam) => {
console.log(where, 'w');
tableRef?.value?.reload({ where });
};
/* 打开编辑弹窗 */
const openEdit = (row?: CmsNavigation | null, id?: number, mod?: string) => {
current.value = row ?? null;
model.value = mod ?? null;
parentId.value = id;
showEdit.value = true;
};
// 跳转模型内容列表
const openDesign = (row?: CmsNavigation) => {
categoryId.value = row?.navigationId;
showDesignEdit.value = true;
return;
// if (row && isDirectory(row)) {
// categoryId.value = row?.navigationId;
// showDesignEdit.value = true;
// return;
// }
// TODO 单页模型
// if (row?.model == 'custom') {
// router.push({
// path: `/cms/design`,
// query: {
// id: row.navigationId,
// type: row.model
// }
// });
// return;
// }
// TODO 文章列表
// if (row?.model === 'article') {
// router.push({
// path: `/cms/article`,
// query: {
// id: row.navigationId,
// type: row.model
// }
// });
// return;
// }
// TODO 产品列表
// if (row?.model === 'product') {
// router.push({
// path: '/goods/index',
// query: { categoryId: row.navigationId, type: row.type }
// });
// return;
// }
};
const onModel = () => {
reload();
};
const saveNavigationIcon = (index: number) => {
currentId.value = index;
};
const removeNavigationIcon = () => {
currentId.value = undefined;
};
/* 删除单个 */
const remove = (row: CmsNavigation) => {
console.log(row);
if (row.children?.length) {
message.error('请先删除子节点');
return;
}
const hide = messageLoading('请求中..', 0);
removeCmsNavigation(row.navigationId)
.then((msg) => {
hide();
message.success(msg);
reload();
})
.catch((e) => {
hide();
message.error(e.message);
});
};
/* 展开全部 */
const expandAll = () => {
let keys: number[] = [];
eachTreeData(navigationData.value, (d) => {
if (d.children && d.children.length && d.navigationId) {
keys.push(d.navigationId);
}
});
expandedRowKeys.value = keys;
};
/* 折叠全部 */
const foldAll = () => {
expandedRowKeys.value = [];
};
/* 点击展开图标时触发 */
const onExpand = (expanded: boolean, record: CmsNavigation) => {
if (expanded) {
expandedRowKeys.value = [
...expandedRowKeys.value,
record.navigationId as number
];
} else {
expandedRowKeys.value = expandedRowKeys.value.filter(
(d) => d !== record.navigationId
);
}
};
};
/* 判断是否是目录 */
const isDirectory = (d: CmsNavigation) => {
return !!d.children?.length;
};
listCmsModel().then((data) => {
modelList.value = data;
});
/* 自定义行属性 */
const customRow = (record: CmsNavigation) => {
return {
// 行点击事件
onClick: () => {
// console.log(record);
},
// 行双击事件
onDblclick: () => {
if (record.model !== 'index') {
openEdit(record);
}
}
};
};
</script>
<script lang="ts">
export default {
name: 'CmsNavigation'
};
export default {
name: 'CmsNavigation'
};
</script>

View File

@@ -28,7 +28,7 @@
:labelStyle="{ width: '90px', color: '#808080' }"
>
<a-space class="flex items-center">
<a-avatar :src="form.avatar" size="small"/>
<a-avatar :src="form.avatar" size="small" />
{{ form.realName }}
</a-space>
</a-descriptions-item>
@@ -49,7 +49,9 @@
<a-tag v-if="form.orderStatus === 4" color="red">退款申请中</a-tag>
<a-tag v-if="form.orderStatus === 5" color="red">退款被拒绝</a-tag>
<a-tag v-if="form.orderStatus === 6" color="orange">退款成功</a-tag>
<a-tag v-if="form.orderStatus === 7" color="pink">客户端申请退款</a-tag>
<a-tag v-if="form.orderStatus === 7" color="pink"
>客户端申请退款</a-tag
>
</a-descriptions-item>
<!-- 第三排-->
<a-descriptions-item
@@ -108,68 +110,68 @@
<template v-if="form.payStatus == 1">
<a-tag v-if="form.payType == 0">余额支付</a-tag>
<a-tag v-if="form.payType == 1">
<WechatOutlined class="tag-icon"/>
<WechatOutlined class="tag-icon" />
微信支付
</a-tag>
<a-tag v-if="form.payType == 2">积分</a-tag>
<a-tag v-if="form.payType == 3">
<AlipayCircleOutlined class="tag-icon"/>
<AlipayCircleOutlined class="tag-icon" />
支付宝
</a-tag>
<a-tag v-if="form.payType == 4">
<IdcardOutlined class="tag-icon"/>
<IdcardOutlined class="tag-icon" />
现金
</a-tag>
<a-tag v-if="form.payType == 5">
<IdcardOutlined class="tag-icon"/>
<IdcardOutlined class="tag-icon" />
POS机
</a-tag>
<a-tag v-if="form.payType == 6">
<IdcardOutlined class="tag-icon"/>
<IdcardOutlined class="tag-icon" />
VIP月卡
</a-tag>
<a-tag v-if="form.payType == 7">
<IdcardOutlined class="tag-icon"/>
<IdcardOutlined class="tag-icon" />
VIP年卡
</a-tag>
<a-tag v-if="form.payType == 8">
<IdcardOutlined class="tag-icon"/>
<IdcardOutlined class="tag-icon" />
VIP次卡
</a-tag>
<a-tag v-if="form.payType == 9">
<IdcardOutlined class="tag-icon"/>
<IdcardOutlined class="tag-icon" />
IC月卡
</a-tag>
<a-tag v-if="form.payType == 10">
<IdcardOutlined class="tag-icon"/>
<IdcardOutlined class="tag-icon" />
IC年卡
</a-tag>
<a-tag v-if="form.payType == 11">
<IdcardOutlined class="tag-icon"/>
<IdcardOutlined class="tag-icon" />
IC次卡
</a-tag>
<a-tag v-if="form.payType == 12">
<IdcardOutlined class="tag-icon"/>
<IdcardOutlined class="tag-icon" />
免费
</a-tag>
<a-tag v-if="form.payType == 13">
<IdcardOutlined class="tag-icon"/>
<IdcardOutlined class="tag-icon" />
VIP充值卡
</a-tag>
<a-tag v-if="form.payType == 14">
<IdcardOutlined class="tag-icon"/>
<IdcardOutlined class="tag-icon" />
IC充值卡
</a-tag>
<a-tag v-if="form.payType == 15">
<IdcardOutlined class="tag-icon"/>
<IdcardOutlined class="tag-icon" />
积分支付
</a-tag>
<a-tag v-if="form.payType == 16">
<IdcardOutlined class="tag-icon"/>
<IdcardOutlined class="tag-icon" />
VIP季卡
</a-tag>
<a-tag v-if="form.payType == 17">
<IdcardOutlined class="tag-icon"/>
<IdcardOutlined class="tag-icon" />
IC季卡
</a-tag>
</template>
@@ -204,10 +206,9 @@
<a-tag v-if="form.isSettled == 1" color="green">已结算</a-tag>
</a-descriptions-item>
<!-- <a-descriptions-item span="3">-->
<!-- <a-divider/>-->
<!-- </a-descriptions-item>-->
<!-- <a-descriptions-item span="3">-->
<!-- <a-divider/>-->
<!-- </a-descriptions-item>-->
</a-descriptions>
</a-card>
<a-card class="order-card" :bordered="false">
@@ -223,364 +224,363 @@
</template>
<script lang="ts" setup>
import {ref, reactive, watch} from 'vue';
import {Form} from 'ant-design-vue';
import {assignObject} from 'ele-admin-pro';
import {ColumnItem} from 'ele-admin-pro/es/ele-pro-table/types';
import {
CheckOutlined,
CloseOutlined,
CoffeeOutlined
} from '@ant-design/icons-vue';
import {ShopOrder} from '@/api/shop/shopOrder/model';
import {BszxPay} from '@/api/bszx/bszxPay/model';
import {pageBszxPay} from '@/api/bszx/bszxPay';
import {toDateString} from 'ele-admin-pro';
import {copyText} from "@/utils/common";
import { ref, reactive, watch } from 'vue';
import { Form } from 'ant-design-vue';
import { assignObject } from 'ele-admin-pro';
import { ColumnItem } from 'ele-admin-pro/es/ele-pro-table/types';
import {
CheckOutlined,
CloseOutlined,
CoffeeOutlined
} from '@ant-design/icons-vue';
import { ShopOrder } from '@/api/shop/shopOrder/model';
import { BszxPay } from '@/api/bszx/bszxPay/model';
import { pageBszxPay } from '@/api/bszx/bszxPay';
import { toDateString } from 'ele-admin-pro';
import { copyText } from '@/utils/common';
const useForm = Form.useForm;
const useForm = Form.useForm;
const props = defineProps<{
// 弹窗是否打开
visible: boolean;
// 修改回显的数据
data?: ShopOrder | null;
}>();
const props = defineProps<{
// 弹窗是否打开
visible: boolean;
// 修改回显的数据
data?: ShopOrder | null;
}>();
export interface step {
title?: String | undefined;
subTitle?: String | undefined;
description?: String | undefined;
}
// 是否是修改
const isUpdate = ref(false);
// 是否显示最大化切换按钮
const maxAble = ref(true);
// 订单信息
const orderInfo = ref<BszxPay[]>([]);
// 步骤条
const steps = ref<step[]>([
{
title: '报餐',
description: undefined
},
{
title: '付款',
description: undefined
},
{
title: '发餐',
description: undefined
},
{
title: '取餐',
description: undefined
},
{
title: '完成',
description: undefined
export interface step {
title?: String | undefined;
subTitle?: String | undefined;
description?: String | undefined;
}
]);
const active = ref(2);
const emit = defineEmits<{
(e: 'done'): void;
(e: 'update:visible', visible: boolean): void;
}>();
// 是否是修改
const isUpdate = ref(false);
// 是否显示最大化切换按钮
const maxAble = ref(true);
// 订单信息
const orderInfo = ref<BszxPay[]>([]);
// 订单信息
const form = reactive<ShopOrder>({
// 订单号
orderId: undefined,
// 订单编号
orderNo: undefined,
// 订单类型0商城订单 1预定订单/外卖 2会员卡
type: undefined,
// 快递/自提
deliveryType: undefined,
// 下单渠道0小程序预定 1俱乐部训练场 3活动订场
channel: undefined,
// 微信支付订单号
transactionId: undefined,
// 微信退款订单号
refundOrder: undefined,
// 商户ID
merchantId: undefined,
// 商户名称
merchantName: undefined,
// 商户编号
merchantCode: undefined,
// 使用的优惠券id
couponId: undefined,
// 使用的会员卡id
cardId: undefined,
// 关联管理员id
adminId: undefined,
// 核销管理员id
confirmId: undefined,
// IC卡号
icCard: undefined,
// 头像
avatar: undefined,
// 真实姓名
realName: undefined,
// 手机号码
phone: undefined,
// 收货地址
address: undefined,
//
addressLat: undefined,
//
addressLng: undefined,
// 自提店铺id
selfTakeMerchantId: undefined,
// 自提店铺
selfTakeMerchantName: undefined,
// 配送开始时间
sendStartTime: undefined,
// 配送结束时间
sendEndTime: undefined,
// 发货店铺id
expressMerchantId: undefined,
// 发货店铺
expressMerchantName: undefined,
// 订单总额
totalPrice: undefined,
// 减少的金额使用VIP会员折扣、优惠券抵扣、优惠券折扣后减去的价格
reducePrice: undefined,
// 实际付款
payPrice: undefined,
// 用于统计
price: undefined,
// 价钱,用于积分赠送
money: undefined,
// 退款金额
refundMoney: undefined,
// 教练价格
coachPrice: undefined,
// 购买数量
totalNum: undefined,
// 教练id
coachId: undefined,
// 支付的用户id
payUserId: undefined,
// 0余额支付, 1微信支付102微信Native2会员卡支付3支付宝4现金5POS机6VIP月卡7VIP年卡8VIP次卡9IC月卡10IC年卡11IC次卡12免费13VIP充值卡14IC充值卡15积分支付16VIP季卡17IC季卡18代付
payType: undefined,
// 代付支付方式,0余额支付, 1微信支付102微信Native2会员卡支付3支付宝4现金5POS机6VIP月卡7VIP年卡8VIP次卡9IC月卡10IC年卡11IC次卡12免费13VIP充值卡14IC充值卡15积分支付16VIP季卡17IC季卡18代付
friendPayType: undefined,
// 0未付款1已付款
payStatus: undefined,
// 0未使用1已完成2已取消3取消中4退款申请中5退款被拒绝6退款成功7客户端申请退款
orderStatus: undefined,
// 发货状态(10未发货 20已发货 30部分发货)
deliveryStatus: undefined,
// 发货时间
deliveryTime: undefined,
// 优惠类型0无、1抵扣优惠券、2折扣优惠券、3、VIP月卡、4VIP年卡5VIP次卡、6VIP会员卡、7IC月卡、8IC年卡、9IC次卡、10IC会员卡、11免费订单、12VIP充值卡、13IC充值卡、14VIP季卡、15IC季卡
couponType: undefined,
// 优惠说明
couponDesc: undefined,
// 二维码地址,保存订单号,支付成功后才生成
qrcode: undefined,
// vip月卡年卡、ic月卡年卡回退次数
returnNum: undefined,
// vip充值回退金额
returnMoney: undefined,
// 预约详情开始时间数组
startTime: undefined,
// 是否已开具发票0未开发票1已开发票2不能开具发票
isInvoice: undefined,
// 发票流水号
invoiceNo: undefined,
// 支付时间
payTime: undefined,
// 退款时间
refundTime: undefined,
// 申请退款时间
refundApplyTime: undefined,
// 过期时间
expirationTime: undefined,
// 对账情况0=未对账1=已对账3=已对账金额对不上4=未查询到该订单
checkBill: undefined,
// 订单是否已结算(0未结算 1已结算)
isSettled: undefined,
// 系统版本号 0当前版本 value=其他版本
version: undefined,
// 用户id
userId: undefined,
// 备注
comments: undefined,
// 排序号
sortNumber: undefined,
// 是否删除, 0否, 1是
deleted: undefined,
// 租户id
tenantId: undefined,
// 修改时间
updateTime: undefined,
// 创建时间
createTime: undefined,
// 自提码
selfTakeCode: undefined,
// 是否已收到赠品
hasTakeGift: undefined,
});
// 请求状态
const loading = ref(true);
const {resetFields} = useForm(form);
/* 更新visible */
const updateVisible = (value: boolean) => {
emit('update:visible', value);
};
const columns = ref<ColumnItem[]>([
{
title: '场馆名称',
dataIndex: 'siteName',
key: 'siteName',
align: 'center'
},
{
title: '场地',
dataIndex: 'fieldName',
align: 'center'
},
{
title: '价格',
dataIndex: 'price',
align: 'center'
},
{
title: '儿童价',
dataIndex: 'childrenPrice',
align: 'center'
},
{
title: '成人数',
dataIndex: 'adultNum',
align: 'center'
},
{
title: '儿童数',
dataIndex: 'childrenNum',
align: 'center'
},
{
title: '预定信息',
dataIndex: 'dateTime',
key: 'dateTime',
align: 'center'
},
{
title: '是否免费',
dataIndex: 'isFree',
align: 'center',
customRender: ({text}) => ['', '免费', '付费'][text]
}
]);
/* 制作步骤条 */
const loadSteps = (order) => {
steps.value = [];
steps.value.push({
title: '下单'
});
steps.value.push({
title: '付款'
});
steps.value.push({
title: '发货'
});
steps.value.push({
title: '收货'
});
steps.value.push({
title: '完成'
});
// 下单
if (order.payStatus == 10) {
active.value = 0;
steps.value[0].description = order.createTime;
}
// 付款
if (order.payStatus == 20) {
active.value = 1;
steps.value[0].description = order.createTime;
steps.value[1].description = order.payTime;
}
// 发货
if (order.payStatus == 20 && order.deliveryStatus == 20) {
active.value = 2;
steps.value[0].description = order.createTime;
steps.value[1].description = order.payTime;
steps.value[2].description = order.deliveryTime;
}
// 收货
if (order.payStatus == 20 && order.receiptStatus == 20) {
active.value = 3;
steps.value[0].description = order.createTime;
steps.value[1].description = order.payTime;
steps.value[2].description = order.deliveryTime;
steps.value[3].description = order.receiptTime;
}
// 完成
if (order.payStatus == 20 && order.orderStatus == 30) {
active.value = 4;
steps.value[0].description = order.createTime;
steps.value[1].description = order.payTime;
steps.value[2].description = order.deliveryTime;
steps.value[3].description = order.receiptTime;
}
// 已取消
if (order.orderStatus == 20) {
active.value = 4;
}
};
// const getOrderInfo = () => {
// const orderId = props.data?.orderId;
// listOrderInfo({ orderId }).then((data) => {
// orderInfo.value = data.filter((d) => d.totalNum > 0);
// });
// };
/* 保存编辑 */
const save = () => {
};
watch(
() => props.visible,
(visible) => {
if (visible) {
if (props.data) {
loading.value = true;
assignObject(form, props.data);
pageBszxPay({orderId: form.orderId}).then((res) => {
if (res?.list) {
orderInfo.value = res?.list;
}
loading.value = false;
});
loadSteps(props.data);
}
} else {
resetFields();
// 步骤条
const steps = ref<step[]>([
{
title: '报餐',
description: undefined
},
{
title: '付款',
description: undefined
},
{
title: '发餐',
description: undefined
},
{
title: '取餐',
description: undefined
},
{
title: '完成',
description: undefined
}
}
);
]);
const active = ref(2);
const emit = defineEmits<{
(e: 'done'): void;
(e: 'update:visible', visible: boolean): void;
}>();
// 订单信息
const form = reactive<ShopOrder>({
// 订单号
orderId: undefined,
// 订单编号
orderNo: undefined,
// 订单类型0商城订单 1预定订单/外卖 2会员卡
type: undefined,
// 快递/自提
deliveryType: undefined,
// 下单渠道0小程序预定 1俱乐部训练场 3活动订场
channel: undefined,
// 微信支付订单号
transactionId: undefined,
// 微信退款订单号
refundOrder: undefined,
// 商户ID
merchantId: undefined,
// 商户名称
merchantName: undefined,
// 商户编号
merchantCode: undefined,
// 使用的优惠券id
couponId: undefined,
// 使用的会员卡id
cardId: undefined,
// 关联管理员id
adminId: undefined,
// 核销管理员id
confirmId: undefined,
// IC卡号
icCard: undefined,
// 头像
avatar: undefined,
// 真实姓名
realName: undefined,
// 手机号码
phone: undefined,
// 收货地址
address: undefined,
//
addressLat: undefined,
//
addressLng: undefined,
// 自提店铺id
selfTakeMerchantId: undefined,
// 自提店铺
selfTakeMerchantName: undefined,
// 配送开始时间
sendStartTime: undefined,
// 配送结束时间
sendEndTime: undefined,
// 发货店铺id
expressMerchantId: undefined,
// 发货店铺
expressMerchantName: undefined,
// 订单总额
totalPrice: undefined,
// 减少的金额使用VIP会员折扣、优惠券抵扣、优惠券折扣后减去的价格
reducePrice: undefined,
// 实际付款
payPrice: undefined,
// 用于统计
price: undefined,
// 价钱,用于积分赠送
money: undefined,
// 退款金额
refundMoney: undefined,
// 教练价格
coachPrice: undefined,
// 购买数量
totalNum: undefined,
// 教练id
coachId: undefined,
// 支付的用户id
payUserId: undefined,
// 0余额支付, 1微信支付102微信Native2会员卡支付3支付宝4现金5POS机6VIP月卡7VIP年卡8VIP次卡9IC月卡10IC年卡11IC次卡12免费13VIP充值卡14IC充值卡15积分支付16VIP季卡17IC季卡18代付
payType: undefined,
// 代付支付方式,0余额支付, 1微信支付102微信Native2会员卡支付3支付宝4现金5POS机6VIP月卡7VIP年卡8VIP次卡9IC月卡10IC年卡11IC次卡12免费13VIP充值卡14IC充值卡15积分支付16VIP季卡17IC季卡18代付
friendPayType: undefined,
// 0未付款1已付款
payStatus: undefined,
// 0未使用1已完成2已取消3取消中4退款申请中5退款被拒绝6退款成功7客户端申请退款
orderStatus: undefined,
// 发货状态(10未发货 20已发货 30部分发货)
deliveryStatus: undefined,
// 发货时间
deliveryTime: undefined,
// 优惠类型0无、1抵扣优惠券、2折扣优惠券、3、VIP月卡、4VIP年卡5VIP次卡、6VIP会员卡、7IC月卡、8IC年卡、9IC次卡、10IC会员卡、11免费订单、12VIP充值卡、13IC充值卡、14VIP季卡、15IC季卡
couponType: undefined,
// 优惠说明
couponDesc: undefined,
// 二维码地址,保存订单号,支付成功后才生成
qrcode: undefined,
// vip月卡年卡、ic月卡年卡回退次数
returnNum: undefined,
// vip充值回退金额
returnMoney: undefined,
// 预约详情开始时间数组
startTime: undefined,
// 是否已开具发票0未开发票1已开发票2不能开具发票
isInvoice: undefined,
// 发票流水号
invoiceNo: undefined,
// 支付时间
payTime: undefined,
// 退款时间
refundTime: undefined,
// 申请退款时间
refundApplyTime: undefined,
// 过期时间
expirationTime: undefined,
// 对账情况0=未对账1=已对账3=已对账金额对不上4=未查询到该订单
checkBill: undefined,
// 订单是否已结算(0未结算 1已结算)
isSettled: undefined,
// 系统版本号 0当前版本 value=其他版本
version: undefined,
// 用户id
userId: undefined,
// 备注
comments: undefined,
// 排序号
sortNumber: undefined,
// 是否删除, 0否, 1是
deleted: undefined,
// 租户id
tenantId: undefined,
// 修改时间
updateTime: undefined,
// 创建时间
createTime: undefined,
// 自提码
selfTakeCode: undefined,
// 是否已收到赠品
hasTakeGift: undefined
});
// 请求状态
const loading = ref(true);
const { resetFields } = useForm(form);
/* 更新visible */
const updateVisible = (value: boolean) => {
emit('update:visible', value);
};
const columns = ref<ColumnItem[]>([
{
title: '场馆名称',
dataIndex: 'siteName',
key: 'siteName',
align: 'center'
},
{
title: '场地',
dataIndex: 'fieldName',
align: 'center'
},
{
title: '价格',
dataIndex: 'price',
align: 'center'
},
{
title: '儿童价',
dataIndex: 'childrenPrice',
align: 'center'
},
{
title: '成人数',
dataIndex: 'adultNum',
align: 'center'
},
{
title: '儿童数',
dataIndex: 'childrenNum',
align: 'center'
},
{
title: '预定信息',
dataIndex: 'dateTime',
key: 'dateTime',
align: 'center'
},
{
title: '是否免费',
dataIndex: 'isFree',
align: 'center',
customRender: ({ text }) => ['', '免费', '付费'][text]
}
]);
/* 制作步骤条 */
const loadSteps = (order) => {
steps.value = [];
steps.value.push({
title: '下单'
});
steps.value.push({
title: '付款'
});
steps.value.push({
title: '发货'
});
steps.value.push({
title: '收货'
});
steps.value.push({
title: '完成'
});
// 下单
if (order.payStatus == 10) {
active.value = 0;
steps.value[0].description = order.createTime;
}
// 付款
if (order.payStatus == 20) {
active.value = 1;
steps.value[0].description = order.createTime;
steps.value[1].description = order.payTime;
}
// 发货
if (order.payStatus == 20 && order.deliveryStatus == 20) {
active.value = 2;
steps.value[0].description = order.createTime;
steps.value[1].description = order.payTime;
steps.value[2].description = order.deliveryTime;
}
// 收货
if (order.payStatus == 20 && order.receiptStatus == 20) {
active.value = 3;
steps.value[0].description = order.createTime;
steps.value[1].description = order.payTime;
steps.value[2].description = order.deliveryTime;
steps.value[3].description = order.receiptTime;
}
// 完成
if (order.payStatus == 20 && order.orderStatus == 30) {
active.value = 4;
steps.value[0].description = order.createTime;
steps.value[1].description = order.payTime;
steps.value[2].description = order.deliveryTime;
steps.value[3].description = order.receiptTime;
}
// 已取消
if (order.orderStatus == 20) {
active.value = 4;
}
};
// const getOrderInfo = () => {
// const orderId = props.data?.orderId;
// listOrderInfo({ orderId }).then((data) => {
// orderInfo.value = data.filter((d) => d.totalNum > 0);
// });
// };
/* 保存编辑 */
const save = () => {};
watch(
() => props.visible,
(visible) => {
if (visible) {
if (props.data) {
loading.value = true;
assignObject(form, props.data);
pageBszxPay({ orderId: form.orderId }).then((res) => {
if (res?.list) {
orderInfo.value = res?.list;
}
loading.value = false;
});
loadSteps(props.data);
}
} else {
resetFields();
}
}
);
</script>
<script lang="ts">
import * as MenuIcons from '@/layout/menu-icons';
import * as MenuIcons from '@/layout/menu-icons';
export default {
name: 'BszxOrderInfo',
components: MenuIcons
};
export default {
name: 'BszxOrderInfo',
components: MenuIcons
};
</script>

View File

@@ -37,18 +37,18 @@
<a-select-option :value="3">支付宝</a-select-option>
<a-select-option :value="4">现金</a-select-option>
<a-select-option :value="5">POS机</a-select-option>
<!-- <a-select-option :value="6">VIP月卡</a-select-option>-->
<!-- <a-select-option :value="7">VIP年卡</a-select-option>-->
<!-- <a-select-option :value="8">VIP次卡</a-select-option>-->
<!-- <a-select-option :value="9">IC月卡</a-select-option>-->
<!-- <a-select-option :value="10">IC年卡</a-select-option>-->
<!-- <a-select-option :value="11">IC次卡</a-select-option>-->
<!-- <a-select-option :value="6">VIP月卡</a-select-option>-->
<!-- <a-select-option :value="7">VIP年卡</a-select-option>-->
<!-- <a-select-option :value="8">VIP次卡</a-select-option>-->
<!-- <a-select-option :value="9">IC月卡</a-select-option>-->
<!-- <a-select-option :value="10">IC年卡</a-select-option>-->
<!-- <a-select-option :value="11">IC次卡</a-select-option>-->
<a-select-option :value="12">免费</a-select-option>
<!-- <a-select-option :value="13">VIP充值卡</a-select-option>-->
<!-- <a-select-option :value="14">IC充值卡</a-select-option>-->
<!-- <a-select-option :value="15">积分支付</a-select-option>-->
<!-- <a-select-option :value="16">VIP季卡</a-select-option>-->
<!-- <a-select-option :value="17">IC季卡</a-select-option>-->
<!-- <a-select-option :value="13">VIP充值卡</a-select-option>-->
<!-- <a-select-option :value="14">IC充值卡</a-select-option>-->
<!-- <a-select-option :value="15">积分支付</a-select-option>-->
<!-- <a-select-option :value="16">VIP季卡</a-select-option>-->
<!-- <a-select-option :value="17">IC季卡</a-select-option>-->
</a-select>
<a-select
v-model:value="where.isInvoice"
@@ -82,9 +82,9 @@
import { utils, writeFile } from 'xlsx';
import dayjs from 'dayjs';
import { message } from 'ant-design-vue';
import useSearch from "@/utils/use-search";
import {listBszxPay} from "@/api/bszx/bszxPay";
import {ShopOrder, ShopOrderParam} from "@/api/shop/shopOrder/model";
import useSearch from '@/utils/use-search';
import { listBszxPay } from '@/api/bszx/bszxPay';
import { ShopOrder, ShopOrderParam } from '@/api/shop/shopOrder/model';
const props = withDefaults(
defineProps<{
@@ -113,7 +113,7 @@
payStatus: undefined,
orderStatus: undefined,
payType: undefined,
isInvoice: undefined,
isInvoice: undefined
});
const reload = () => {
@@ -139,7 +139,7 @@
const dateRange = ref<[string, string]>(['', '']);
// 变量
const loading = ref(false);
const orders = ref<ShopOrder[]>([])
const orders = ref<ShopOrder[]>([]);
const xlsFileName = ref<string>();
// 导出
@@ -212,7 +212,6 @@
loading.value = false;
})
.finally(() => {});
};
watch(

View File

@@ -21,10 +21,14 @@
</template>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'name'">
<div @click="onSearch(record)" class="cursor-pointer">{{ record.name || '匿名' }}</div>
<div @click="onSearch(record)" class="cursor-pointer">{{
record.name || '匿名'
}}</div>
</template>
<template v-if="column.key === 'phone'">
<div v-if="record.mobile" class="text-gray-400">{{ record.mobile }}</div>
<div v-if="record.mobile" class="text-gray-400">{{
record.mobile
}}</div>
<div v-else class="text-gray-600">{{ record.phone }}</div>
</template>
<template v-if="column.key === 'payType'">
@@ -101,12 +105,19 @@
</template>
</template>
<template v-if="column.key === 'payStatus'">
<a-tag v-if="record.payStatus == 1" color="green" @click="updatePayStatus(record)">已付款</a-tag>
<a-tag v-if="record.payStatus == 0" @click="updatePayStatus(record)">未付款</a-tag>
<a-tag
v-if="record.payStatus == 1"
color="green"
@click="updatePayStatus(record)"
>已付款</a-tag
>
<a-tag v-if="record.payStatus == 0" @click="updatePayStatus(record)"
>未付款</a-tag
>
<a-tag v-if="record.payStatus == 3">未付款,占场中</a-tag>
</template>
<template v-if="column.key === 'image'">
<a-image :src="record.image" :width="50"/>
<a-image :src="record.image" :width="50" />
</template>
<template v-if="column.key === 'sex'">
<a-tag v-if="record.sex === 1"></a-tag>
@@ -114,18 +125,30 @@
</template>
<template v-if="column.key === 'deliveryStatus'">
<a-tag v-if="record.deliveryStatus == 10">未核销</a-tag>
<a-tag v-if="record.deliveryStatus == 20" color="green">已核销</a-tag>
<a-tag v-if="record.deliveryStatus == 30" color="bule">部分核销</a-tag>
<a-tag v-if="record.deliveryStatus == 20" color="green"
>核销</a-tag
>
<a-tag v-if="record.deliveryStatus == 30" color="bule"
>部分核销</a-tag
>
</template>
<template v-if="column.key === 'orderStatus'">
<a-tag v-if="record.orderStatus === 0">未完成</a-tag>
<a-tag v-if="record.orderStatus === 1" color="green">已完成</a-tag>
<a-tag v-if="record.orderStatus === 2" color="red">已取消</a-tag>
<a-tag v-if="record.orderStatus === 3" color="red">取消中</a-tag>
<a-tag v-if="record.orderStatus === 4" color="red">退款申请中</a-tag>
<a-tag v-if="record.orderStatus === 5" color="red">退款被拒绝</a-tag>
<a-tag v-if="record.orderStatus === 6" color="orange">退款成功</a-tag>
<a-tag v-if="record.orderStatus === 7" color="pink">客户端申请退款</a-tag>
<a-tag v-if="record.orderStatus === 4" color="red"
>退款申请中</a-tag
>
<a-tag v-if="record.orderStatus === 5" color="red"
>退款被拒绝</a-tag
>
<a-tag v-if="record.orderStatus === 6" color="orange"
>退款成功</a-tag
>
<a-tag v-if="record.orderStatus === 7" color="pink"
>客户端申请退款</a-tag
>
</template>
<template v-if="column.key === 'isInvoice'">
<a-tag v-if="record.isInvoice == 0">未开具</a-tag>
@@ -139,7 +162,7 @@
<template v-if="column.key === 'action'">
<a-space>
<a @click="openEdit(record)">修改</a>
<a-divider type="vertical"/>
<a-divider type="vertical" />
<a-popconfirm
title="确定要删除此记录吗?"
@confirm="remove(record)"
@@ -158,212 +181,212 @@
</template>
<script lang="ts" setup>
import {ref} from 'vue';
import type {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 {getPageTitle} from "@/utils/common";
import OrderInfo from './components/orderInfo.vue';
import {ShopOrder, ShopOrderParam} from "@/api/shop/shopOrder/model";
import {pageShopOrder, updateShopOrder} from "@/api/shop/shopOrder";
import {message} from "ant-design-vue";
import {updateUser} from "@/api/system/user";
import { ref } from 'vue';
import type { 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 { getPageTitle } from '@/utils/common';
import OrderInfo from './components/orderInfo.vue';
import { ShopOrder, ShopOrderParam } from '@/api/shop/shopOrder/model';
import { pageShopOrder, updateShopOrder } from '@/api/shop/shopOrder';
import { message } from 'ant-design-vue';
import { updateUser } from '@/api/system/user';
// 表格实例
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
// 表格实例
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
// 表格选中数据
const selection = ref<ShopOrder[]>([]);
// 当前编辑数据
const current = ref<ShopOrder | null>(null);
// 是否显示编辑弹窗
const showEdit = ref(false);
// 是否显示批量移动弹窗
const showMove = ref(false);
// 加载状态
const loading = ref(true);
// 表格选中数据
const selection = ref<ShopOrder[]>([]);
// 当前编辑数据
const current = ref<ShopOrder | 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 pageShopOrder({
...where,
...orders,
// 表格数据源
const datasource: DatasourceFunction = ({
page,
limit
});
};
// 表格列配置
const columns = ref<ColumnItem[]>([
{
title: '订单号',
dataIndex: 'orderNo',
key: 'orderNo',
align: 'center',
width: 200,
},
{
title: '姓名',
dataIndex: 'realName',
key: 'realName',
align: 'center'
},
{
title: '手机号码',
dataIndex: 'phone',
key: 'phone',
align: 'center'
},
{
title: '实付金额',
dataIndex: 'payPrice',
key: 'payPrice',
align: 'center',
customRender: ({text}) => '¥' + text
},
{
title: '支付方式',
dataIndex: 'payType',
key: 'payType',
align: 'center'
},
{
title: '支付状态',
dataIndex: 'payStatus',
key: 'payStatus',
align: 'center'
},
{
title: '核销状态',
dataIndex: 'deliveryStatus',
key: 'deliveryStatus',
align: 'center',
},
{
title: '开票状态',
dataIndex: 'isInvoice',
key: 'isInvoice',
align: 'center',
},
{
title: '订单状态',
dataIndex: 'orderStatus',
key: 'orderStatus',
align: 'center',
},
// {
// title: '支付时间',
// dataIndex: 'payTime',
// key: 'payTime',
// align: 'center',
// width: 180,
// sorter: true,
// ellipsis: true
// },
{
title: '下单时间',
dataIndex: 'createTime',
key: 'createTime',
align: 'center',
width: 180,
sorter: true,
ellipsis: true
},
// {
// title: '操作',
// key: 'action',
// width: 180,
// fixed: 'right',
// align: 'center',
// hideInSetting: true
// }
]);
/* 搜索 */
const reload = (where?: ShopOrderParam) => {
selection.value = [];
tableRef?.value?.reload({where: where});
};
const onSearch = (item: ShopOrder) => {
reload({userId: item.userId})
}
/* 打开编辑弹窗 */
const openEdit = (row?: ShopOrder) => {
current.value = row ?? null;
showEdit.value = true;
};
/* 打开批量移动弹窗 */
const openMove = () => {
showMove.value = true;
};
/**
* 修复订单支付状态
*/
const updatePayStatus = (record: ShopOrder) => {
if (record.deliveryStatus == 20) {
// 修复订单数据
updateShopOrder({
...record,
payStatus: 20,
deliveryStatus: 20,
orderStatus: 1
}).then(() => {
message.success('修复成功');
})
}
// 更新用户真实姓名
updateUser({
userId: record.userId,
realName: record.realName
}).then(() => {
reload();
})
}
/* 查询 */
const query = () => {
loading.value = true;
};
/* 自定义行属性 */
const customRow = (record: ShopOrder) => {
return {
// 行点击事件
onClick: () => {
// console.log(record);
},
// 行双击事件
onDblclick: () => {
openEdit(record);
limit,
where,
orders,
filters
}) => {
if (filters) {
where.status = filters.status;
}
return pageShopOrder({
...where,
...orders,
page,
limit
});
};
};
query();
// 表格列配置
const columns = ref<ColumnItem[]>([
{
title: '订单号',
dataIndex: 'orderNo',
key: 'orderNo',
align: 'center',
width: 200
},
{
title: '姓名',
dataIndex: 'realName',
key: 'realName',
align: 'center'
},
{
title: '手机号码',
dataIndex: 'phone',
key: 'phone',
align: 'center'
},
{
title: '实付金额',
dataIndex: 'payPrice',
key: 'payPrice',
align: 'center',
customRender: ({ text }) => '¥' + text
},
{
title: '支付方式',
dataIndex: 'payType',
key: 'payType',
align: 'center'
},
{
title: '支付状态',
dataIndex: 'payStatus',
key: 'payStatus',
align: 'center'
},
{
title: '核销状态',
dataIndex: 'deliveryStatus',
key: 'deliveryStatus',
align: 'center'
},
{
title: '开票状态',
dataIndex: 'isInvoice',
key: 'isInvoice',
align: 'center'
},
{
title: '订单状态',
dataIndex: 'orderStatus',
key: 'orderStatus',
align: 'center'
},
// {
// title: '支付时间',
// dataIndex: 'payTime',
// key: 'payTime',
// align: 'center',
// width: 180,
// sorter: true,
// ellipsis: true
// },
{
title: '下单时间',
dataIndex: 'createTime',
key: 'createTime',
align: 'center',
width: 180,
sorter: true,
ellipsis: true
}
// {
// title: '操作',
// key: 'action',
// width: 180,
// fixed: 'right',
// align: 'center',
// hideInSetting: true
// }
]);
/* 搜索 */
const reload = (where?: ShopOrderParam) => {
selection.value = [];
tableRef?.value?.reload({ where: where });
};
const onSearch = (item: ShopOrder) => {
reload({ userId: item.userId });
};
/* 打开编辑弹窗 */
const openEdit = (row?: ShopOrder) => {
current.value = row ?? null;
showEdit.value = true;
};
/* 打开批量移动弹窗 */
const openMove = () => {
showMove.value = true;
};
/**
* 修复订单支付状态
*/
const updatePayStatus = (record: ShopOrder) => {
if (record.deliveryStatus == 20) {
// 修复订单数据
updateShopOrder({
...record,
payStatus: 20,
deliveryStatus: 20,
orderStatus: 1
}).then(() => {
message.success('修复成功');
});
}
// 更新用户真实姓名
updateUser({
userId: record.userId,
realName: record.realName
}).then(() => {
reload();
});
};
/* 查询 */
const query = () => {
loading.value = true;
};
/* 自定义行属性 */
const customRow = (record: ShopOrder) => {
return {
// 行点击事件
onClick: () => {
// console.log(record);
},
// 行双击事件
onDblclick: () => {
openEdit(record);
}
};
};
query();
</script>
<script lang="ts">
import * as MenuIcons from '@/layout/menu-icons';
import * as MenuIcons from '@/layout/menu-icons';
export default {
name: 'BszxOrder',
components: MenuIcons
};
export default {
name: 'BszxOrder',
components: MenuIcons
};
</script>
<style lang="less" scoped></style>

View File

@@ -3,49 +3,115 @@
<template #extra>
<CmsWebsiteSearch />
</template>
<a-card class="ele-body" :bordered="false" :body-style="{ padding: '16px' }">
<a-card
class="ele-body"
:bordered="false"
:body-style="{ padding: '16px' }"
>
<a-form
ref="formRef"
:model="form"
:rules="rules"
:label-col="styleResponsive ? { md: 2, sm: 5, xs: 24 } : { flex: '120px' }"
:label-col="
styleResponsive ? { md: 2, sm: 5, xs: 24 } : { flex: '120px' }
"
:wrapper-col="
styleResponsive ? { md: 14, sm: 19, xs: 24 } : { flex: '1' }
"
styleResponsive ? { md: 14, sm: 19, xs: 24 } : { flex: '1' }
"
>
<a-tabs v-model:activeKey="activeKey" type="card">
<a-tab-pane key="setting" tab="网站设置" class="mt-5">
<a-form-item label="悬浮工具栏" name="floatTool" extra="显示网站悬浮客服工具栏">
<a-switch v-model:checked="form.floatTool" checked-children="显示" un-checked-children="隐藏" @change="save" />
</a-form-item>
<a-form-item label="显示站内搜索" name="searchBtn">
<a-switch v-model:checked="form.searchBtn" checked-children="显示" un-checked-children="隐藏" @change="save" />
</a-form-item>
<a-form-item label="显示版权" name="showCopyright">
<a-switch v-model:checked="form.showCopyright" checked-children="显示" un-checked-children="隐藏" @change="save" />
</a-form-item>
<a-form-item label="启用登录注册" name="loginBtn">
<a-switch v-model:checked="form.loginBtn" checked-children="启用" un-checked-children="不启用" @change="save" />
</a-form-item>
<a-form-item label="默认编辑器" name="editor" extra="设置默认编辑器">
<a-select v-model:value="form.editor" placeholder="请选择编辑器" class="max-w-xs" @change="save">
<a-select-option :value="1">富文本编辑器</a-select-option>
<a-select-option :value="2">Markdown编辑器</a-select-option>
</a-select>
</a-form-item>
</a-tab-pane>
<a-tab-pane key="privacy" tab="隐私与安全" class="mt-5">
<a-form-item label="允许被搜索" name="name" extra="关闭后,用户无法通过名称搜索到此网站">
<a-switch v-model:checked="form.market" checked-children="允许" un-checked-children="不允许" @change="save" />
</a-form-item>
<a-form-item label="文章发布审核" name="articleReview" extra="开启需要审核后发布,关闭则直接发布">
<a-switch v-model:checked="form.articleReview" checked-children="需要" un-checked-children="不需要" @change="save" />
</a-form-item>
<a-form-item label="开发者模式" name="plugin" extra="开启开发者模式">
<a-switch v-model:checked="form.plugin" checked-children="启用" un-checked-children="禁用" @change="save" />
</a-form-item>
</a-tab-pane>
</a-tabs>
<a-tabs v-model:activeKey="activeKey" type="card">
<a-tab-pane key="setting" tab="网站设置" class="mt-5">
<a-form-item
label="悬浮工具栏"
name="floatTool"
extra="显示网站悬浮客服工具栏"
>
<a-switch
v-model:checked="form.floatTool"
checked-children="显示"
un-checked-children="隐藏"
@change="save"
/>
</a-form-item>
<a-form-item label="显示站内搜索" name="searchBtn">
<a-switch
v-model:checked="form.searchBtn"
checked-children="显示"
un-checked-children="隐藏"
@change="save"
/>
</a-form-item>
<a-form-item label="显示版权" name="showCopyright">
<a-switch
v-model:checked="form.showCopyright"
checked-children="显示"
un-checked-children="隐藏"
@change="save"
/>
</a-form-item>
<a-form-item label="启用登录注册" name="loginBtn">
<a-switch
v-model:checked="form.loginBtn"
checked-children="启用"
un-checked-children="不启用"
@change="save"
/>
</a-form-item>
<a-form-item
label="默认编辑器"
name="editor"
extra="设置默认编辑器"
>
<a-select
v-model:value="form.editor"
placeholder="请选择编辑器"
class="max-w-xs"
@change="save"
>
<a-select-option :value="1">富文本编辑器</a-select-option>
<a-select-option :value="2">Markdown编辑器</a-select-option>
</a-select>
</a-form-item>
</a-tab-pane>
<a-tab-pane key="privacy" tab="隐私与安全" class="mt-5">
<a-form-item
label="允许被搜索"
name="name"
extra="关闭后,用户无法通过名称搜索到此网站"
>
<a-switch
v-model:checked="form.market"
checked-children="允许"
un-checked-children="不允许"
@change="save"
/>
</a-form-item>
<a-form-item
label="文章发布审核"
name="articleReview"
extra="开启需要审核后发布,关闭则直接发布"
>
<a-switch
v-model:checked="form.articleReview"
checked-children="需要"
un-checked-children="不需要"
@change="save"
/>
</a-form-item>
<a-form-item
label="开发者模式"
name="plugin"
extra="开启开发者模式"
>
<a-switch
v-model:checked="form.plugin"
checked-children="启用"
un-checked-children="禁用"
@change="save"
/>
</a-form-item>
</a-tab-pane>
</a-tabs>
</a-form>
</a-card>
</a-page-header>
@@ -55,16 +121,19 @@
import { ref, reactive, watch } from 'vue';
import { Form, message } from 'ant-design-vue';
import { FormInstance } from 'ant-design-vue/es/form';
import {getPageTitle} from "@/utils/common";
import { getPageTitle } from '@/utils/common';
import { storeToRefs } from 'pinia';
import { assignObject } from 'ele-admin-pro';
import { ItemType } from 'ele-admin-pro/es/ele-image-upload/types';
import CmsWebsiteSearch from "@/views/cms/cmsWebsite/components/search.vue";
import {useThemeStore} from "@/store/modules/theme";
import router from "@/router";
import {CmsWebsiteSetting} from "@/api/cms/cmsWebsiteSetting/model";
import {getCmsWebsiteSetting, updateCmsWebsiteSetting} from "@/api/cms/cmsWebsiteSetting";
import {useWebsiteSettingStore} from "@/store/modules/setting";
import CmsWebsiteSearch from '@/views/cms/cmsWebsite/components/search.vue';
import { useThemeStore } from '@/store/modules/theme';
import router from '@/router';
import { CmsWebsiteSetting } from '@/api/cms/cmsWebsiteSetting/model';
import {
getCmsWebsiteSetting,
updateCmsWebsiteSetting
} from '@/api/cms/cmsWebsiteSetting';
import { useWebsiteSettingStore } from '@/store/modules/setting';
// 网站设置信息
const setting = useWebsiteSettingStore();
@@ -118,16 +187,18 @@
/* 查询 */
const query = () => {
loading.value = true;
getCmsWebsiteSetting(Number(localStorage.getItem('WebsiteId'))).then(data => {
assignObject(form, data);
if(data){
assignObject(form,data)
}else {
resetFields()
}
}).catch((msg) => {
console.log(msg)
})
getCmsWebsiteSetting(Number(localStorage.getItem('WebsiteId')))
.then((data) => {
assignObject(form, data);
if (data) {
assignObject(form, data);
} else {
resetFields();
}
})
.catch((msg) => {
console.log(msg);
});
};
const { resetFields } = useForm(form, rules);
@@ -161,7 +232,7 @@
watch(
() => router,
() => {
query()
query();
},
{ immediate: true }
);

View File

@@ -166,7 +166,10 @@
v-model:value="form.statisticsDate"
/>
</a-form-item>
<a-form-item label="统计类型: 1日统计, 2月统计, 3年统计" name="statisticsType">
<a-form-item
label="统计类型: 1日统计, 2月统计, 3年统计"
name="statisticsType"
>
<a-input
allow-clear
placeholder="请输入统计类型: 1日统计, 2月统计, 3年统计"
@@ -224,7 +227,10 @@
import { ref, reactive, watch } from 'vue';
import { Form, message } from 'ant-design-vue';
import { assignObject, uuid } from 'ele-admin-pro';
import { addCmsStatistics, updateCmsStatistics } from '@/api/cms/cmsStatistics';
import {
addCmsStatistics,
updateCmsStatistics
} from '@/api/cms/cmsStatistics';
import { CmsStatistics } from '@/api/cms/cmsStatistics/model';
import { useThemeStore } from '@/store/modules/theme';
import { storeToRefs } from 'pinia';
@@ -344,7 +350,9 @@
const formData = {
...form
};
const saveOrUpdate = isUpdate.value ? updateCmsStatistics : addCmsStatistics;
const saveOrUpdate = isUpdate.value
? updateCmsStatistics
: addCmsStatistics;
saveOrUpdate(formData)
.then((msg) => {
loading.value = false;
@@ -367,12 +375,12 @@
images.value = [];
if (props.data) {
assignObject(form, props.data);
if(props.data.image){
if (props.data.image) {
images.value.push({
uid: uuid(),
url: props.data.image,
status: 'done'
})
});
}
isUpdate.value = true;
} else {

View File

@@ -10,7 +10,7 @@
:value-style="{ color: '#3f8600' }"
>
<template #prefix>
<UserOutlined/>
<UserOutlined />
</template>
</a-statistic>
</a-card>
@@ -24,7 +24,7 @@
:value-style="{ color: '#1890ff' }"
>
<template #prefix>
<AccountBookOutlined/>
<AccountBookOutlined />
</template>
</a-statistic>
</a-card>
@@ -38,7 +38,7 @@
:value-style="{ color: '#cf1322' }"
>
<template #prefix>
<MoneyCollectOutlined/>
<MoneyCollectOutlined />
</template>
</a-statistic>
</a-card>
@@ -53,7 +53,7 @@
:value-style="{ color: '#722ed1' }"
>
<template #prefix>
<ClockCircleOutlined/>
<ClockCircleOutlined />
</template>
</a-statistic>
</a-card>
@@ -63,101 +63,105 @@
</template>
<script lang="ts" setup>
import {ref, onMounted} from 'vue';
import {
UserOutlined,
CalendarOutlined,
QrcodeOutlined,
ShopOutlined,
ClockCircleOutlined,
SettingOutlined,
AccountBookOutlined,
FileTextOutlined,
MoneyCollectOutlined
} from '@ant-design/icons-vue';
import {getSiteInfo} from "@/api/layout";
import {CmsWebsite} from "@/api/cms/cmsWebsite/model";
import {pageUsers} from "@/api/system/user";
import {pageShopOrder} from "@/api/shop/shopOrder";
import {getPageTitle, openNew} from "@/utils/common";
import {listCmsStatistics} from "@/api/cms/cmsStatistics";
import { ref, onMounted } from 'vue';
import {
UserOutlined,
CalendarOutlined,
QrcodeOutlined,
ShopOutlined,
ClockCircleOutlined,
SettingOutlined,
AccountBookOutlined,
FileTextOutlined,
MoneyCollectOutlined
} from '@ant-design/icons-vue';
import { getSiteInfo } from '@/api/layout';
import { CmsWebsite } from '@/api/cms/cmsWebsite/model';
import { pageUsers } from '@/api/system/user';
import { pageShopOrder } from '@/api/shop/shopOrder';
import { getPageTitle, openNew } from '@/utils/common';
import { listCmsStatistics } from '@/api/cms/cmsStatistics';
// 当前小程序项目
const siteInfo = ref<CmsWebsite>({});
// 当前小程序项目
const siteInfo = ref<CmsWebsite>({});
// 系统信息
const systemInfo = ref({
name: '小程序开发',
description: '基于Spring、SpringBoot、SpringMVC等技术栈构建的前后端分离开发平台',
version: '2.0.0',
status: '运行中',
logo: '/logo.png',
environment: '生产环境',
database: 'MySQL 8.0',
server: 'Linux CentOS 7.9',
expirationTime: '2024-01-01 09:00:00'
});
// 系统信息
const systemInfo = ref({
name: '小程序开发',
description:
'基于Spring、SpringBoot、SpringMVC等技术栈构建的前后端分离开发平台',
version: '2.0.0',
status: '运行中',
logo: '/logo.png',
environment: '生产环境',
database: 'MySQL 8.0',
server: 'Linux CentOS 7.9',
expirationTime: '2024-01-01 09:00:00'
});
// 统计数据
const statistics = ref({
userCount: 0,
orderCount: 0,
todayVisit: 0,
runDays: 365
});
// 统计数据
const statistics = ref({
userCount: 0,
orderCount: 0,
todayVisit: 0,
runDays: 365
});
onMounted(() => {
// 加载系统信息和统计数据
loadSystemInfo();
loadStatistics();
});
onMounted(() => {
// 加载系统信息和统计数据
loadSystemInfo();
loadStatistics();
});
const loadSystemInfo = async () => {
// TODO: 调用API获取系统信息
siteInfo.value = await getSiteInfo();
if (siteInfo.value.createTime) {
// 根据创建时间计算运行天数
statistics.value.runDays = Math.floor((new Date().getTime() - new Date(siteInfo.value.createTime).getTime()) / (24 * 60 * 60 * 1000))
}
};
const loadSystemInfo = async () => {
// TODO: 调用API获取系统信息
siteInfo.value = await getSiteInfo();
if (siteInfo.value.createTime) {
// 根据创建时间计算运行天数
statistics.value.runDays = Math.floor(
(new Date().getTime() - new Date(siteInfo.value.createTime).getTime()) /
(24 * 60 * 60 * 1000)
);
}
};
const loadStatistics = async () => {
// TODO: 调用API获取统计数据
const users = await pageUsers({})
const orders = await pageShopOrder({})
if (users) {
console.log(users.count)
statistics.value.userCount = users.count
}
if (orders) {
statistics.value.orderCount = orders.count
}
// 获取统计表数据
const data = await listCmsStatistics({});
if (data) {
// 统计数据
statistics.value.totalSales = data[0].totalSales;
}
};
const loadStatistics = async () => {
// TODO: 调用API获取统计数据
const users = await pageUsers({});
const orders = await pageShopOrder({});
if (users) {
console.log(users.count);
statistics.value.userCount = users.count;
}
if (orders) {
statistics.value.orderCount = orders.count;
}
// 获取统计表数据
const data = await listCmsStatistics({});
if (data) {
// 统计数据
statistics.value.totalSales = data[0].totalSales;
}
};
</script>
<style scoped>
.system-info h2 {
margin-bottom: 8px;
}
.system-info h2 {
margin-bottom: 8px;
}
.stat-card {
text-align: center;
margin-bottom: 16px;
}
.stat-card {
text-align: center;
margin-bottom: 16px;
}
.stat-card :deep(.ant-statistic-title) {
font-size: 14px;
color: #666;
}
.stat-card :deep(.ant-statistic-title) {
font-size: 14px;
color: #666;
}
.stat-card :deep(.ant-statistic-content) {
font-size: 24px;
font-weight: 600;
}
.stat-card :deep(.ant-statistic-content) {
font-size: 24px;
font-weight: 600;
}
</style>

View File

@@ -33,38 +33,36 @@
v-model:value="form.code"
/>
</a-form-item>
<a-form-item
label="缩列图"
name="image">
<SelectFile
:placeholder="`请选择图片`"
:limit="1"
:data="images"
@done="chooseImage"
@del="onDeleteItem"
/>
</a-form-item>
<!-- <a-form-item label="类型 1企业官网 2其他" name="type">-->
<!-- <a-input-->
<!-- allow-clear-->
<!-- placeholder="请输入类型 1企业官网 2其他"-->
<!-- 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="prefix">-->
<!-- <a-input-->
<!-- allow-clear-->
<!-- placeholder="请输入域名前缀"-->
<!-- v-model:value="form.prefix"-->
<!-- />-->
<!-- </a-form-item>-->
<a-form-item label="缩列图" name="image">
<SelectFile
:placeholder="`请选择图片`"
:limit="1"
:data="images"
@done="chooseImage"
@del="onDeleteItem"
/>
</a-form-item>
<!-- <a-form-item label="类型 1企业官网 2其他" name="type">-->
<!-- <a-input-->
<!-- allow-clear-->
<!-- placeholder="请输入类型 1企业官网 2其他"-->
<!-- 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="prefix">-->
<!-- <a-input-->
<!-- allow-clear-->
<!-- placeholder="请输入域名前缀"-->
<!-- v-model:value="form.prefix"-->
<!-- />-->
<!-- </a-form-item>-->
<a-form-item label="预览地址" name="domain">
<a-input
allow-clear
@@ -79,34 +77,34 @@
v-model:value="form.downUrl"
/>
</a-form-item>
<!-- <a-form-item label="色系" name="color">-->
<!-- <a-input-->
<!-- allow-clear-->
<!-- placeholder="请输入色系"-->
<!-- v-model:value="form.color"-->
<!-- />-->
<!-- </a-form-item>-->
<!-- <a-form-item label="应用版本 10免费版 20授权版 30永久授权" name="version">-->
<!-- <a-input-->
<!-- allow-clear-->
<!-- placeholder="请输入应用版本 10免费版 20授权版 30永久授权"-->
<!-- v-model:value="form.version"-->
<!-- />-->
<!-- </a-form-item>-->
<!-- <a-form-item label="行业类型(父级)" name="industryParent">-->
<!-- <a-input-->
<!-- allow-clear-->
<!-- placeholder="请输入行业类型(父级)"-->
<!-- v-model:value="form.industryParent"-->
<!-- />-->
<!-- </a-form-item>-->
<!-- <a-form-item label="行业类型(子级)" name="industryChild">-->
<!-- <a-input-->
<!-- allow-clear-->
<!-- placeholder="请输入行业类型(子级)"-->
<!-- v-model:value="form.industryChild"-->
<!-- />-->
<!-- </a-form-item>-->
<!-- <a-form-item label="色系" name="color">-->
<!-- <a-input-->
<!-- allow-clear-->
<!-- placeholder="请输入色系"-->
<!-- v-model:value="form.color"-->
<!-- />-->
<!-- </a-form-item>-->
<!-- <a-form-item label="应用版本 10免费版 20授权版 30永久授权" name="version">-->
<!-- <a-input-->
<!-- allow-clear-->
<!-- placeholder="请输入应用版本 10免费版 20授权版 30永久授权"-->
<!-- v-model:value="form.version"-->
<!-- />-->
<!-- </a-form-item>-->
<!-- <a-form-item label="行业类型(父级)" name="industryParent">-->
<!-- <a-input-->
<!-- allow-clear-->
<!-- placeholder="请输入行业类型(父级)"-->
<!-- v-model:value="form.industryParent"-->
<!-- />-->
<!-- </a-form-item>-->
<!-- <a-form-item label="行业类型(子级)" name="industryChild">-->
<!-- <a-input-->
<!-- allow-clear-->
<!-- placeholder="请输入行业类型(子级)"-->
<!-- v-model:value="form.industryChild"-->
<!-- />-->
<!-- </a-form-item>-->
<a-form-item label="备注" name="comments">
<a-textarea
:rows="4"
@@ -115,23 +113,23 @@
v-model:value="form.comments"
/>
</a-form-item>
<!-- <a-form-item label="是否共享模板" name="share">-->
<!-- <a-radio-group-->
<!-- v-model:value="form.share"-->
<!-- >-->
<!-- <a-radio :value="1">共享</a-radio>-->
<!-- <a-radio :value="0">私有</a-radio>-->
<!-- </a-radio-group>-->
<!-- </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="share">-->
<!-- <a-radio-group-->
<!-- v-model:value="form.share"-->
<!-- >-->
<!-- <a-radio :value="1">共享</a-radio>-->
<!-- <a-radio :value="0">私有</a-radio>-->
<!-- </a-radio-group>-->
<!-- </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>
</ele-modal>
</template>
@@ -246,7 +244,9 @@
const formData = {
...form
};
const saveOrUpdate = isUpdate.value ? updateCmsTemplate : addCmsTemplate;
const saveOrUpdate = isUpdate.value
? updateCmsTemplate
: addCmsTemplate;
saveOrUpdate(formData)
.then((msg) => {
loading.value = false;
@@ -269,12 +269,12 @@
images.value = [];
if (props.data) {
assignObject(form, props.data);
if(props.data.image){
if (props.data.image) {
images.value.push({
uid: uuid(),
url: props.data.image,
status: 'done'
})
});
}
isUpdate.value = true;
} else {

View File

@@ -52,7 +52,11 @@
</a-card>
<!-- 编辑弹窗 -->
<CmsTemplateEdit v-model:visible="showEdit" :data="current" @done="reload" />
<CmsTemplateEdit
v-model:visible="showEdit"
:data="current"
@done="reload"
/>
</div>
</div>
</template>
@@ -68,8 +72,15 @@
} from 'ele-admin-pro/es/ele-pro-table/types';
import Search from './components/search.vue';
import CmsTemplateEdit from './components/cmsTemplateEdit.vue';
import { pageCmsTemplate, removeCmsTemplate, removeBatchCmsTemplate } from '@/api/cms/cmsTemplate';
import type { CmsTemplate, CmsTemplateParam } from '@/api/cms/cmsTemplate/model';
import {
pageCmsTemplate,
removeCmsTemplate,
removeBatchCmsTemplate
} from '@/api/cms/cmsTemplate';
import type {
CmsTemplate,
CmsTemplateParam
} from '@/api/cms/cmsTemplate/model';
// 表格实例
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);

View File

@@ -36,11 +36,8 @@
v-model:value="form.websiteName"
/>
</a-form-item>
<a-form-item label="网站域名" name="domain" v-if="form.type == 10">
<a-input
v-model:value="form.domain"
placeholder="huawei.com"
>
<a-form-item label="网站域名" name="domain" v-if="form.type == 10">
<a-input v-model:value="form.domain" placeholder="huawei.com">
<template #addonBefore>
<a-select v-model:value="form.prefix" style="width: 90px">
<a-select-option value="http://">http://</a-select-option>
@@ -49,13 +46,13 @@
</template>
</a-input>
</a-form-item>
<!-- <a-form-item label="AppSecret" name="websiteSecret" v-if="form.type == 20">-->
<!-- <a-input-password-->
<!-- allow-clear-->
<!-- placeholder="请输入AppSecret"-->
<!-- v-model:value="form.websiteSecret"-->
<!-- />-->
<!-- </a-form-item>-->
<!-- <a-form-item label="AppSecret" name="websiteSecret" v-if="form.type == 20">-->
<!-- <a-input-password-->
<!-- allow-clear-->
<!-- placeholder="请输入AppSecret"-->
<!-- v-model:value="form.websiteSecret"-->
<!-- />-->
<!-- </a-form-item>-->
<a-form-item label="小程序描述" name="comments">
<a-textarea
:rows="4"
@@ -64,13 +61,13 @@
v-model:value="form.comments"
/>
</a-form-item>
<!-- <a-form-item label="小程序AppID" name="websiteCode" v-if="form.type == 20">-->
<!-- <a-input-->
<!-- allow-clear-->
<!-- placeholder="请输入AppId"-->
<!-- v-model:value="form.websiteCode"-->
<!-- />-->
<!-- </a-form-item>-->
<!-- <a-form-item label="小程序AppID" name="websiteCode" v-if="form.type == 20">-->
<!-- <a-input-->
<!-- allow-clear-->
<!-- placeholder="请输入AppId"-->
<!-- v-model:value="form.websiteCode"-->
<!-- />-->
<!-- </a-form-item>-->
<a-form-item label="小程序码" name="avatar">
<SelectFile
:placeholder="`请选择图片`"
@@ -132,287 +129,286 @@
</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 {addCmsWebsite, updateCmsWebsite} from '@/api/cms/cmsWebsite';
import {CmsWebsite} from '@/api/cms/cmsWebsite/model';
import {useThemeStore} from '@/store/modules/theme';
import {storeToRefs} from 'pinia';
import {FormInstance} from 'ant-design-vue/es/form';
import {ItemType} from 'ele-admin-pro/es/ele-image-upload/types';
import {FileRecord} from '@/api/system/file/model';
import {updateCmsDomain} from '@/api/cms/cmsDomain';
import {updateTenant} from "@/api/system/tenant";
import {decrypt, encrypt} from "@/utils/common";
import { ref, reactive, watch } from 'vue';
import { Form, message } from 'ant-design-vue';
import { assignObject, uuid } from 'ele-admin-pro';
import { addCmsWebsite, updateCmsWebsite } from '@/api/cms/cmsWebsite';
import { CmsWebsite } from '@/api/cms/cmsWebsite/model';
import { useThemeStore } from '@/store/modules/theme';
import { storeToRefs } from 'pinia';
import { FormInstance } from 'ant-design-vue/es/form';
import { ItemType } from 'ele-admin-pro/es/ele-image-upload/types';
import { FileRecord } from '@/api/system/file/model';
import { updateCmsDomain } from '@/api/cms/cmsDomain';
import { updateTenant } from '@/api/system/tenant';
import { decrypt, encrypt } from '@/utils/common';
// 是否是修改
const isUpdate = ref(false);
const useForm = Form.useForm;
// 是否开启响应式布局
const themeStore = useThemeStore();
const {styleResponsive} = storeToRefs(themeStore);
// 是否是修改
const isUpdate = ref(false);
const useForm = Form.useForm;
// 是否开启响应式布局
const themeStore = useThemeStore();
const { styleResponsive } = storeToRefs(themeStore);
const props = defineProps<{
// 弹窗是否打开
visible: boolean;
// 修改回显的数据
data?: CmsWebsite | null;
}>();
const props = defineProps<{
// 弹窗是否打开
visible: boolean;
// 修改回显的数据
data?: CmsWebsite | null;
}>();
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 maxable = ref(true);
// 表格选中数据
const formRef = ref<FormInstance | null>(null);
const images = ref<ItemType[]>([]);
const websiteQrcode = ref<ItemType[]>([]);
const oldDomain = ref();
const files = ref<ItemType[]>([]);
// 提交状态
const loading = ref(false);
// 是否显示最大化切换按钮
const maxable = ref(true);
// 表格选中数据
const formRef = ref<FormInstance | null>(null);
const images = ref<ItemType[]>([]);
const websiteQrcode = ref<ItemType[]>([]);
const oldDomain = ref();
const files = ref<ItemType[]>([]);
// 用户信息
const form = reactive<CmsWebsite>({
websiteId: undefined,
websiteLogo: undefined,
websiteName: undefined,
websiteCode: undefined,
websiteSecret: undefined,
type: 20,
files: undefined,
keywords: '',
prefix: '',
domain: '',
adminUrl: '',
style: '',
icpNo: undefined,
email: undefined,
version: undefined,
websiteType: '',
running: 1,
expirationTime: undefined,
sortNumber: undefined,
comments: undefined,
status: undefined,
statusText: undefined
});
/* 更新visible */
const updateVisible = (value: boolean) => {
emit('update:visible', value);
};
// 表单验证规则
const rules = reactive({
comments: [
{
required: true,
type: 'string',
message: '请填写小程序描述',
trigger: 'blur'
}
],
keywords: [
{
required: true,
type: 'string',
message: '请填写SEO关键词',
trigger: 'blur'
}
],
running: [
{
required: true,
type: 'number',
message: '请选择小程序状态',
trigger: 'change'
}
],
domain: [
{
required: true,
type: 'string',
message: '请填写小程序域名',
trigger: 'blur'
}
],
websiteCode: [
{
required: true,
type: 'string',
message: '请填写小程序码',
trigger: 'blur'
}
],
websiteSecret: [
{
required: true,
type: 'string',
message: '请填写小程序密钥',
trigger: 'blur'
}
],
adminUrl: [
{
required: true,
type: 'string',
message: '请填写小程序后台管理地址',
trigger: 'blur'
}
],
icpNo: [
{
required: true,
type: 'string',
message: '请填写ICP备案号',
trigger: 'blur'
}
],
appSecret: [
{
required: true,
type: 'string',
message: '请填写小程序秘钥',
trigger: 'blur'
}
],
websiteName: [
{
required: true,
type: 'string',
message: '请填写小程序信息名称',
trigger: 'blur'
}
]
});
const chooseImage = (data: FileRecord) => {
images.value.push({
uid: data.id,
url: data.path,
status: 'done'
// 用户信息
const form = reactive<CmsWebsite>({
websiteId: undefined,
websiteLogo: undefined,
websiteName: undefined,
websiteCode: undefined,
websiteSecret: undefined,
type: 20,
files: undefined,
keywords: '',
prefix: '',
domain: '',
adminUrl: '',
style: '',
icpNo: undefined,
email: undefined,
version: undefined,
websiteType: '',
running: 1,
expirationTime: undefined,
sortNumber: undefined,
comments: undefined,
status: undefined,
statusText: undefined
});
form.websiteLogo = data.downloadUrl;
};
const chooseQrcode = (data: FileRecord) => {
websiteQrcode.value.push({
uid: data.id,
url: data.path,
status: 'done'
});
form.websiteDarkLogo = data.downloadUrl;
}
/* 更新visible */
const updateVisible = (value: boolean) => {
emit('update:visible', value);
};
const onDeleteItem = (index: number) => {
images.value.splice(index, 1);
form.websiteLogo = '';
};
const onDeleteQrcode = (index: number) => {
websiteQrcode.value.splice(index, 1);
form.websiteDarkLogo = '';
};
const {resetFields} = useForm(form, rules);
/* 保存编辑 */
const save = () => {
if (!formRef.value) {
return;
}
formRef.value
.validate()
.then(() => {
loading.value = true;
const saveOrUpdate = isUpdate.value ? updateCmsWebsite : addCmsWebsite;
if (!isUpdate.value) {
updateVisible(false);
message.loading('创建过程中请勿刷新页面!', 0)
// 表单验证规则
const rules = reactive({
comments: [
{
required: true,
type: 'string',
message: '请填写小程序描述',
trigger: 'blur'
}
const formData = {
...form,
type: 20,
adminUrl: `mp.websoft.top`,
websiteSecret: form.websiteSecret ? encrypt(form.websiteSecret) : undefined,
files: JSON.stringify(files.value),
};
saveOrUpdate(formData)
.then((msg) => {
loading.value = false;
updateVisible(false);
updateCmsDomain({
websiteId: form.websiteId,
domain: `${localStorage.getItem('TenantId')}.shoplnk.cn`
});
updateTenant({
tenantName: `${form.websiteName}`
}).then(() => {
})
localStorage.setItem('Domain', `${form.websiteCode}.shoplnk.cn`);
localStorage.setItem('WebsiteId', `${form.websiteId}`);
localStorage.setItem('WebsiteName', `${form.websiteName}`);
message.destroy();
message.success(msg);
// window.location.reload();
emit('done');
})
.catch((e) => {
loading.value = false;
message.destroy();
message.error(e.message);
});
})
.catch(() => {
],
keywords: [
{
required: true,
type: 'string',
message: '请填写SEO关键词',
trigger: 'blur'
}
],
running: [
{
required: true,
type: 'number',
message: '请选择小程序状态',
trigger: 'change'
}
],
domain: [
{
required: true,
type: 'string',
message: '请填写小程序域名',
trigger: 'blur'
}
],
websiteCode: [
{
required: true,
type: 'string',
message: '请填写小程序码',
trigger: 'blur'
}
],
websiteSecret: [
{
required: true,
type: 'string',
message: '请填写小程序密钥',
trigger: 'blur'
}
],
adminUrl: [
{
required: true,
type: 'string',
message: '请填写小程序后台管理地址',
trigger: 'blur'
}
],
icpNo: [
{
required: true,
type: 'string',
message: '请填写ICP备案号',
trigger: 'blur'
}
],
appSecret: [
{
required: true,
type: 'string',
message: '请填写小程序秘钥',
trigger: 'blur'
}
],
websiteName: [
{
required: true,
type: 'string',
message: '请填写小程序信息名称',
trigger: 'blur'
}
]
});
const chooseImage = (data: FileRecord) => {
images.value.push({
uid: data.id,
url: data.path,
status: 'done'
});
};
form.websiteLogo = data.downloadUrl;
};
watch(
() => props.visible,
(visible) => {
if (visible) {
images.value = [];
files.value = [];
websiteQrcode.value = [];
if (props.data?.websiteId) {
assignObject(form, props.data);
if (props.data.websiteLogo) {
images.value.push({
uid: uuid(),
url: props.data.websiteLogo,
status: 'done'
});
}
if (props.data.websiteDarkLogo) {
websiteQrcode.value.push({
uid: uuid(),
url: props.data.websiteDarkLogo,
status: 'done'
});
}
if (props.data.files) {
files.value = JSON.parse(props.data.files);
}
if (props.data.websiteCode) {
oldDomain.value = props.data.websiteCode;
}
if(props.data.websiteSecret){
form.websiteSecret = decrypt(props.data.websiteSecret);
}
isUpdate.value = true;
} else {
isUpdate.value = false;
}
} else {
resetFields();
const chooseQrcode = (data: FileRecord) => {
websiteQrcode.value.push({
uid: data.id,
url: data.path,
status: 'done'
});
form.websiteDarkLogo = data.downloadUrl;
};
const onDeleteItem = (index: number) => {
images.value.splice(index, 1);
form.websiteLogo = '';
};
const onDeleteQrcode = (index: number) => {
websiteQrcode.value.splice(index, 1);
form.websiteDarkLogo = '';
};
const { resetFields } = useForm(form, rules);
/* 保存编辑 */
const save = () => {
if (!formRef.value) {
return;
}
},
{immediate: true}
);
formRef.value
.validate()
.then(() => {
loading.value = true;
const saveOrUpdate = isUpdate.value ? updateCmsWebsite : addCmsWebsite;
if (!isUpdate.value) {
updateVisible(false);
message.loading('创建过程中请勿刷新页面!', 0);
}
const formData = {
...form,
type: 20,
adminUrl: `mp.websoft.top`,
websiteSecret: form.websiteSecret
? encrypt(form.websiteSecret)
: undefined,
files: JSON.stringify(files.value)
};
saveOrUpdate(formData)
.then((msg) => {
loading.value = false;
updateVisible(false);
updateCmsDomain({
websiteId: form.websiteId,
domain: `${localStorage.getItem('TenantId')}.shoplnk.cn`
});
updateTenant({
tenantName: `${form.websiteName}`
}).then(() => {});
localStorage.setItem('Domain', `${form.websiteCode}.shoplnk.cn`);
localStorage.setItem('WebsiteId', `${form.websiteId}`);
localStorage.setItem('WebsiteName', `${form.websiteName}`);
message.destroy();
message.success(msg);
// window.location.reload();
emit('done');
})
.catch((e) => {
loading.value = false;
message.destroy();
message.error(e.message);
});
})
.catch(() => {});
};
watch(
() => props.visible,
(visible) => {
if (visible) {
images.value = [];
files.value = [];
websiteQrcode.value = [];
if (props.data?.websiteId) {
assignObject(form, props.data);
if (props.data.websiteLogo) {
images.value.push({
uid: uuid(),
url: props.data.websiteLogo,
status: 'done'
});
}
if (props.data.websiteDarkLogo) {
websiteQrcode.value.push({
uid: uuid(),
url: props.data.websiteDarkLogo,
status: 'done'
});
}
if (props.data.files) {
files.value = JSON.parse(props.data.files);
}
if (props.data.websiteCode) {
oldDomain.value = props.data.websiteCode;
}
if (props.data.websiteSecret) {
form.websiteSecret = decrypt(props.data.websiteSecret);
}
isUpdate.value = true;
} else {
isUpdate.value = false;
}
} else {
resetFields();
}
},
{ immediate: true }
);
</script>

View File

@@ -1,7 +1,7 @@
<template>
<a-page-header :title="getPageTitle()" @back="() => $router.go(-1)">
<template #extra>
<CmsWebsiteSearch/>
<CmsWebsiteSearch />
</template>
<a-spin :spinning="loading" class="page">
<a-card :bordered="false" :body-style="{ padding: '16px' }">
@@ -19,7 +19,11 @@
>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'websiteLogo'">
<a-image :src="record.websiteLogo" :width="50" fallback="https://file.wsdns.cn/20230218/550e610d43334dd2a7f66d5b20bd58eb.svg"/>
<a-image
:src="record.websiteLogo"
:width="50"
fallback="https://file.wsdns.cn/20230218/550e610d43334dd2a7f66d5b20bd58eb.svg"
/>
</template>
<template v-if="column.key === 'websiteName'">
<div class="font-medium">{{ record.websiteName }}</div>
@@ -48,9 +52,8 @@
v-if="record.type === 0"
@click="updateType(record)"
class="cursor-pointer"
>
</a-tag
>
>
</a-tag>
</template>
<template v-if="column.key === 'version'">
<span v-if="record.version === 10">基础版</span>
@@ -66,13 +69,23 @@
<a-tag v-if="record.running === 5" color="red">违规关停</a-tag>
</template>
<template v-if="column.key === 'comments'">
<div class="text-gray-400 line-clamp-3">{{ record.comments }}</div>
<div class="text-gray-400 line-clamp-3">{{
record.comments
}}</div>
</template>
<template v-if="column.key === 'expirationTime'">
<div class="text-gray-400">{{ toDateString(record.createTime, 'YYYY-MM-dd') }}</div>
<div class="text-gray-400">{{ toDateString(record.expirationTime, 'YYYY-MM-dd') }}</div>
<a-tag v-if="record.status < 0 && record.soon < 0" color="red">已过期</a-tag>
<a-tag v-if="record.status > 0 && record.soon < 0" color="orange">即将过期</a-tag>
<div class="text-gray-400">{{
toDateString(record.createTime, 'YYYY-MM-dd')
}}</div>
<div class="text-gray-400">{{
toDateString(record.expirationTime, 'YYYY-MM-dd')
}}</div>
<a-tag v-if="record.status < 0 && record.soon < 0" color="red"
>已过期</a-tag
>
<a-tag v-if="record.status > 0 && record.soon < 0" color="orange"
>即将过期</a-tag
>
</template>
<template v-if="column.key === 'action'">
<!-- <a @click="onShare(record)" class="text-green-600">-->
@@ -80,21 +93,17 @@
<!-- 二维码-->
<!-- </a>-->
<!-- <a-divider type="vertical"/>-->
<a @click="openEdit(record)">
编辑
</a>
<a @click="openEdit(record)"> 编辑 </a>
</template>
</template>
<template #emptyText>
<a-empty
:image-style="{
height: '240px',
height: '240px'
}"
>
<template #description>
<span>
欢迎使用本产品请先创建站点并完成初始化
</span>
<span> 欢迎使用本产品请先创建站点并完成初始化 </span>
</template>
<div class="pb-10">
<a-button type="primary" @click="openEdit">立即创建</a-button>
@@ -105,216 +114,209 @@
</a-card>
<!-- 编辑弹窗 -->
<WebsiteEdit v-model:visible="showEdit" :data="current" @done="reload"/>
<WebsiteEdit v-model:visible="showEdit" :data="current" @done="reload" />
<!-- 二维码 -->
<!-- <Qrcode v-model:visible="showQrcode" :data="`${qrcode}`" @done="hideShare" title="二维码"/>-->
</a-spin>
</a-page-header>
</template>
<script lang="ts" setup>
import {ref} from 'vue';
import {message} from 'ant-design-vue';
// import {QrcodeOutlined} 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 WebsiteEdit from './components/websiteEdit.vue';
// import Qrcode from '@/components/QrCode/index.vue';
import {
pageCmsWebsite,
updateCmsWebsite
} from '@/api/cms/cmsWebsite';
import type {CmsWebsite, CmsWebsiteParam} from '@/api/cms/cmsWebsite/model';
import {getPageTitle} from '@/utils/common';
import {PageResult} from '@/api';
import {pageOrderGoods} from "@/api/system/orderGoods";
import {OrderGoods} from "@/api/system/orderGoods/model";
import CmsWebsiteSearch from "@/views/cms/cmsWebsite/components/search.vue";
import {getAuthorizedDomain} from "@/api/cms/cmsDomain";
import { ref } from 'vue';
import { message } from 'ant-design-vue';
// import {QrcodeOutlined} 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 WebsiteEdit from './components/websiteEdit.vue';
// import Qrcode from '@/components/QrCode/index.vue';
import { pageCmsWebsite, updateCmsWebsite } from '@/api/cms/cmsWebsite';
import type { CmsWebsite, CmsWebsiteParam } from '@/api/cms/cmsWebsite/model';
import { getPageTitle } from '@/utils/common';
import { PageResult } from '@/api';
import { pageOrderGoods } from '@/api/system/orderGoods';
import { OrderGoods } from '@/api/system/orderGoods/model';
import CmsWebsiteSearch from '@/views/cms/cmsWebsite/components/search.vue';
import { getAuthorizedDomain } from '@/api/cms/cmsDomain';
// 表格实例
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
// 表格实例
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
// 表格选中数据
const selection = ref<CmsWebsite[]>([]);
// 当前编辑数据
const current = ref<CmsWebsite | null>(null);
// 是否显示编辑弹窗
const showEdit = ref(false);
// 是否显示二维码
const showQrcode = ref(false);
// 二维码内容
const qrcode = ref();
// 加载状态
const loading = ref(true);
// 当前小程序项目
const website = ref<CmsWebsite>();
// 已购买且未安装的小程序
const orderGoods = ref<OrderGoods>();
// 默认域名
const domain = ref<string>();
// 表格选中数据
const selection = ref<CmsWebsite[]>([]);
// 当前编辑数据
const current = ref<CmsWebsite | null>(null);
// 是否显示编辑弹窗
const showEdit = ref(false);
// 是否显示二维码
const showQrcode = ref(false);
// 二维码内容
const qrcode = ref();
// 加载状态
const loading = ref(true);
// 当前小程序项目
const website = ref<CmsWebsite>();
// 已购买且未安装的小程序
const orderGoods = ref<OrderGoods>();
// 默认域名
const domain = ref<string>();
// 表格数据源
const datasource: DatasourceFunction = ({
page,
limit,
where,
orders
}) => {
return pageCmsWebsite({
...where,
...orders,
page,
limit
});
};
// 表格数据源
const datasource: DatasourceFunction = ({ page, limit, where, orders }) => {
return pageCmsWebsite({
...where,
...orders,
page,
limit
});
};
// 表格列配置
const columns = ref<ColumnItem[]>([
// {
// title: 'AppID',
// dataIndex: 'tenantId',
// key: 'tenantId',
// width: 90
// },
{
title: '头像',
dataIndex: 'websiteLogo',
key: 'websiteLogo',
align: 'center',
width: 120
},
{
title: '小程序名称',
dataIndex: 'websiteName',
key: 'websiteName',
align: 'center'
},
// {
// title: '小程序信息',
// dataIndex: 'websiteCode',
// key: 'websiteCode'
// },
{
title: '小程序描述',
dataIndex: 'comments',
key: 'comments'
},
// {
// title: '当前版本',
// dataIndex: 'version',
// key: 'version',
// align: 'center'
// },
{
title: '状态',
dataIndex: 'status',
key: 'status',
align: 'center',
width: 170
},
{
title: '创建时间',
dataIndex: 'expirationTime',
key: 'expirationTime',
align: 'center',
width: 170,
sorter: true,
ellipsis: true,
customRender: ({text}) => toDateString(text, 'yyyy-MM-dd')
},
{
title: '操作',
key: 'action',
width: 170,
fixed: 'right',
align: 'center',
hideInSetting: true
}
]);
// 整理数据
const parseData = (data: PageResult<CmsWebsite>) => {
if (data?.count > 0) {
website.value = data.list[0];
localStorage.setItem('WebsiteId', `${website.value?.websiteId}`);
}
return data;
};
/* 搜索 */
const reload = (where?: CmsWebsiteParam) => {
selection.value = [];
tableRef?.value?.reload({where: where});
};
/* 打开编辑弹窗 */
const openEdit = (row?: CmsWebsite) => {
current.value = row ?? null;
showEdit.value = true;
};
const updateType = (row: CmsWebsite) => {
updateCmsWebsite(row).then((msg) => {
message.success(msg);
reload();
});
};
const onShare = (row?: CmsWebsite) => {
qrcode.value = `${row?.prefix}${row?.domain}`
showQrcode.value = true;
}
const hideShare = () => {
showQrcode.value = false;
}
/* 查询 */
const query = () => {
// 查询订单
pageOrderGoods({itemId: 10297, payStatus: true, orderStatus: 0}).then(res => {
loading.value = false;
if (res?.count && res?.count > 0) {
orderGoods.value = res?.list[0];
}
})
// 查询授权域名
if (localStorage.getItem('Domain')) {
getAuthorizedDomain().then((data) => {
if (data) {
domain.value = data.domain;
}
})
}
};
/* 自定义行属性 */
const customRow = (record: CmsWebsite) => {
return {
// 行点击事件
onClick: () => {
// console.log(record);
// 表格列配置
const columns = ref<ColumnItem[]>([
// {
// title: 'AppID',
// dataIndex: 'tenantId',
// key: 'tenantId',
// width: 90
// },
{
title: '头像',
dataIndex: 'websiteLogo',
key: 'websiteLogo',
align: 'center',
width: 120
},
// 行双击事件
onDblclick: () => {
openEdit(record);
{
title: '小程序名称',
dataIndex: 'websiteName',
key: 'websiteName',
align: 'center'
},
// {
// title: '小程序信息',
// dataIndex: 'websiteCode',
// key: 'websiteCode'
// },
{
title: '小程序描述',
dataIndex: 'comments',
key: 'comments'
},
// {
// title: '当前版本',
// dataIndex: 'version',
// key: 'version',
// align: 'center'
// },
{
title: '状态',
dataIndex: 'status',
key: 'status',
align: 'center',
width: 170
},
{
title: '创建时间',
dataIndex: 'expirationTime',
key: 'expirationTime',
align: 'center',
width: 170,
sorter: true,
ellipsis: true,
customRender: ({ text }) => toDateString(text, 'yyyy-MM-dd')
},
{
title: '操作',
key: 'action',
width: 170,
fixed: 'right',
align: 'center',
hideInSetting: true
}
]);
// 整理数据
const parseData = (data: PageResult<CmsWebsite>) => {
if (data?.count > 0) {
website.value = data.list[0];
localStorage.setItem('WebsiteId', `${website.value?.websiteId}`);
}
return data;
};
/* 搜索 */
const reload = (where?: CmsWebsiteParam) => {
selection.value = [];
tableRef?.value?.reload({ where: where });
};
/* 打开编辑弹窗 */
const openEdit = (row?: CmsWebsite) => {
current.value = row ?? null;
showEdit.value = true;
};
const updateType = (row: CmsWebsite) => {
updateCmsWebsite(row).then((msg) => {
message.success(msg);
reload();
});
};
const onShare = (row?: CmsWebsite) => {
qrcode.value = `${row?.prefix}${row?.domain}`;
showQrcode.value = true;
};
const hideShare = () => {
showQrcode.value = false;
};
/* 查询 */
const query = () => {
// 查询订单
pageOrderGoods({ itemId: 10297, payStatus: true, orderStatus: 0 }).then(
(res) => {
loading.value = false;
if (res?.count && res?.count > 0) {
orderGoods.value = res?.list[0];
}
}
);
// 查询授权域名
if (localStorage.getItem('Domain')) {
getAuthorizedDomain().then((data) => {
if (data) {
domain.value = data.domain;
}
});
}
};
};
query();
/* 自定义行属性 */
const customRow = (record: CmsWebsite) => {
return {
// 行点击事件
onClick: () => {
// console.log(record);
},
// 行双击事件
onDblclick: () => {
openEdit(record);
}
};
};
query();
</script>
<script lang="ts">
export default {
name: 'CmsWebsite'
};
export default {
name: 'CmsWebsite'
};
</script>
<style lang="less" scoped></style>

View File

@@ -20,9 +20,9 @@
<p class="ant-upload-hint">将文件拖到此处或点击上传</p>
</a-upload-dragger>
</a-spin>
<!-- <div class="ele-text-center">-->
<!-- <span>导入备份文件</span>-->
<!-- </div>-->
<!-- <div class="ele-text-center">-->
<!-- <span>导入备份文件</span>-->
<!-- </div>-->
</ele-modal>
</template>
@@ -30,7 +30,7 @@
import { ref } from 'vue';
import { message } from 'ant-design-vue/es';
import { CloudUploadOutlined } from '@ant-design/icons-vue';
import {importWebsiteField} from "@/api/cms/cmsWebsiteField";
import { importWebsiteField } from '@/api/cms/cmsWebsiteField';
const emit = defineEmits<{
(e: 'done'): void;

View File

@@ -63,11 +63,7 @@
/>
</a-form-item>
<a-form-item label="style" name="style">
<a-input
allow-clear
placeholder="style"
v-model:value="form.style"
/>
<a-input allow-clear placeholder="style" v-model:value="form.style" />
</a-form-item>
<a-form-item label="名称" name="value">
<a-input
@@ -114,7 +110,10 @@
import { ref, reactive, watch } from 'vue';
import { Form, message } from 'ant-design-vue';
import { assignObject, uuid } from 'ele-admin-pro';
import { addCmsWebsiteField, updateCmsWebsiteField } from '@/api/cms/cmsWebsiteField';
import {
addCmsWebsiteField,
updateCmsWebsiteField
} from '@/api/cms/cmsWebsiteField';
import { CmsWebsiteField } from '@/api/cms/cmsWebsiteField/model';
import { useThemeStore } from '@/store/modules/theme';
import { storeToRefs } from 'pinia';
@@ -218,7 +217,9 @@
const formData = {
...form
};
const saveOrUpdate = isUpdate.value ? updateCmsWebsiteField : addCmsWebsiteField;
const saveOrUpdate = isUpdate.value
? updateCmsWebsiteField
: addCmsWebsiteField;
saveOrUpdate(formData)
.then((msg) => {
loading.value = false;
@@ -241,12 +242,12 @@
images.value = [];
if (props.data) {
assignObject(form, props.data);
if(props.data.image){
if (props.data.image) {
images.value.push({
uid: uuid(),
url: props.data.image,
status: 'done'
})
});
}
isUpdate.value = true;
} else {

View File

@@ -25,12 +25,12 @@
:disabled="isUpdate"
v-model:value="form.name"
/>
<!-- <SelectWebsiteField-->
<!-- :placeholder="`从模板选择`"-->
<!-- class="input-item"-->
<!-- v-model:value="form.name"-->
<!-- @done="chooseData"-->
<!-- />-->
<!-- <SelectWebsiteField-->
<!-- :placeholder="`从模板选择`"-->
<!-- class="input-item"-->
<!-- v-model:value="form.name"-->
<!-- @done="chooseData"-->
<!-- />-->
</div>
</a-form-item>
<a-form-item label="内容" name="type">
@@ -52,9 +52,7 @@
@done="chooseImage"
@del="onDeleteItem"
/>
<div class="pt-2 text-gray-400">
请选择或上传图片
</div>
<div class="pt-2 text-gray-400"> 请选择或上传图片 </div>
</template>
<template v-else-if="form.type == 2">
<SelectFile
@@ -65,12 +63,10 @@
@done="chooseImage"
@del="onDeleteItem"
/>
<div class="pt-2 text-gray-400">
请选择或上传视频
</div>
<div class="pt-2 text-gray-400"> 请选择或上传视频 </div>
</template>
<template v-else-if="form.type === 3">
<a-switch v-model:checked="form.value"/>
<a-switch v-model:checked="form.value" />
</template>
<template v-else>
<a-input placeholder="字段内容" v-model:value="form.value" />
@@ -85,17 +81,22 @@
v-model:value="form.comments"
/>
</a-form-item>
<a-form-item label="加密" name="encrypted" extra="私密信息需要加密保存" v-if="form.type === 0">
<a-switch v-model:checked="form.encrypted"></a-switch>
<a-form-item
label="加密"
name="encrypted"
extra="私密信息需要加密保存"
v-if="form.type === 0"
>
<a-switch v-model:checked="form.encrypted" />
</a-form-item>
<!-- <a-form-item label="预留" name="style">-->
<!-- <a-input-->
<!-- allow-clear-->
<!-- placeholder="预留字段"-->
<!-- style="width: 325px"-->
<!-- v-model:value="form.style"-->
<!-- />-->
<!-- </a-form-item>-->
<!-- <a-form-item label="预留" name="style">-->
<!-- <a-input-->
<!-- allow-clear-->
<!-- placeholder="预留字段"-->
<!-- style="width: 325px"-->
<!-- v-model:value="form.style"-->
<!-- />-->
<!-- </a-form-item>-->
<a-form-item label="排序" name="sortNumber">
<a-input-number
:min="0"
@@ -109,207 +110,206 @@
</template>
<script lang="ts" setup>
import {ref, reactive, watch} from 'vue';
import {FormInstance} from 'ant-design-vue/es/form';
import useFormData from '@/utils/use-form-data';
import {
addCmsWebsiteField,
updateCmsWebsiteField
} from '@/api/cms/cmsWebsiteField';
import {message} from 'ant-design-vue/es';
import {removeSiteInfoCache} from '@/api/cms/cmsWebsite';
import {ItemType} from 'ele-admin-pro/es/ele-image-upload/types';
import {FileRecord} from '@/api/system/file/model';
import {uuid} from 'ele-admin-pro';
import {useI18n} from 'vue-i18n';
import {CmsWebsiteField} from '@/api/cms/cmsWebsiteField/model';
import {decrypt, encrypt} from "@/utils/common";
import { ref, reactive, watch } from 'vue';
import { FormInstance } from 'ant-design-vue/es/form';
import useFormData from '@/utils/use-form-data';
import {
addCmsWebsiteField,
updateCmsWebsiteField
} from '@/api/cms/cmsWebsiteField';
import { message } from 'ant-design-vue/es';
import { removeSiteInfoCache } from '@/api/cms/cmsWebsite';
import { ItemType } from 'ele-admin-pro/es/ele-image-upload/types';
import { FileRecord } from '@/api/system/file/model';
import { uuid } from 'ele-admin-pro';
import { useI18n } from 'vue-i18n';
import { CmsWebsiteField } from '@/api/cms/cmsWebsiteField/model';
import { decrypt, encrypt } from '@/utils/common';
// 是否是修改
const isUpdate = ref(false);
// 是否是修改
const isUpdate = ref(false);
const props = defineProps<{
// 弹窗是否打开
visible: boolean;
websiteId: number | null | undefined;
// 修改回显的数据
data?: CmsWebsiteField | null;
}>();
const props = defineProps<{
// 弹窗是否打开
visible: boolean;
websiteId: number | null | undefined;
// 修改回显的数据
data?: CmsWebsiteField | null;
}>();
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 {locale} = useI18n();
// 提交状态
const loading = ref(false);
const images = ref<ItemType[]>([]);
const formRef = ref<FormInstance | null>(null); // 国际化
const { locale } = useI18n();
const {form, resetFields, assignFields} = useFormData<CmsWebsiteField>({
id: undefined,
type: 0,
template: undefined,
name: undefined,
value: undefined,
modifyRange: undefined,
defaultValue: undefined,
comments: '',
style: '',
lang: '',
encrypted: false,
sortNumber: 100
});
// 表单验证规则
const rules = reactive({
name: [
{
required: true,
type: 'string',
message: '请输入名称'
}
],
comments: [
{
required: true,
type: 'string',
message: '请输入字段备注'
}
],
type: [
{
required: true,
type: 'number',
message: '请选择字段类型'
}
],
value: [
{
required: true,
type: 'string',
message: '请填写字段值'
}
]
// comments: [
// {
// required: true,
// type: 'string',
// message: '请输入字段'
// }
// ],
});
/* 更新visible */
const updateVisible = (value: boolean) => {
emit('update:visible', value);
};
const chooseImage = (data: FileRecord) => {
images.value.push({
uid: data.id,
url: data.path,
status: 'done'
const { form, resetFields, assignFields } = useFormData<CmsWebsiteField>({
id: undefined,
type: 0,
template: undefined,
name: undefined,
value: undefined,
modifyRange: undefined,
defaultValue: undefined,
comments: '',
style: '',
lang: '',
encrypted: false,
sortNumber: 100
});
form.value = data.downloadUrl;
form.type = 1;
};
const onDeleteItem = (index: number) => {
images.value.splice(index, 1);
form.type = 0;
};
// const chooseData = (data: CmsWebsiteField) => {
// form.name = data.name;
// form.value = data.defaultValue;
// form.comments = data.comments;
// if (data.type == 1) {
// images.value.push({
// uid: `${data.id}`,
// url: data.defaultValue,
// status: 'done'
// });
// }
// };
/* 保存编辑 */
const save = () => {
if (!formRef.value) {
return;
}
formRef.value
.validate()
.then(() => {
loading.value = true;
// 3 开关
if (form.type == 3) {
form.value = form.value ? '1' : '0';
// 表单验证规则
const rules = reactive({
name: [
{
required: true,
type: 'string',
message: '请输入名称'
}
const data = {
...form,
// name: form.name?.toUpperCase(),
websiteId: props.websiteId,
lang: locale.value
};
// 加密处理
if (data.encrypted) {
data.value = encrypt(data.value);
],
comments: [
{
required: true,
type: 'string',
message: '请输入字段备注'
}
const saveOrUpdate = isUpdate.value
? updateCmsWebsiteField
: addCmsWebsiteField;
saveOrUpdate(data)
.then((msg) => {
loading.value = false;
message.success(msg);
updateVisible(false);
// 清除缓存
removeSiteInfoCache('SiteInfo:' + localStorage.getItem('TenantId'));
if (form.name == 'i18n') {
localStorage.setItem('i18n', '1');
window.location.reload();
}
emit('done');
})
.catch((e) => {
loading.value = false;
message.error(e.message);
});
})
.catch(() => {
],
type: [
{
required: true,
type: 'number',
message: '请选择字段类型'
}
],
value: [
{
required: true,
type: 'string',
message: '请填写字段值'
}
]
// comments: [
// {
// required: true,
// type: 'string',
// message: '请输入字段'
// }
// ],
});
/* 更新visible */
const updateVisible = (value: boolean) => {
emit('update:visible', value);
};
const chooseImage = (data: FileRecord) => {
images.value.push({
uid: data.id,
url: data.path,
status: 'done'
});
};
form.value = data.downloadUrl;
form.type = 1;
};
watch(
() => props.visible,
(visible) => {
if (visible) {
images.value = [];
if (props.data) {
assignFields(props.data);
form.comments = props.data.comments;
if (form.type == 1) {
images.value.push({
uid: uuid(),
url: props.data.value,
status: 'done'
});
}
if (form.type == 3) {
form.value = props.data.value == '1';
}
if (form.encrypted) {
form.value = decrypt(props.data.value);
}
isUpdate.value = true;
} else {
isUpdate.value = false;
}
} else {
resetFields();
const onDeleteItem = (index: number) => {
images.value.splice(index, 1);
form.type = 0;
};
// const chooseData = (data: CmsWebsiteField) => {
// form.name = data.name;
// form.value = data.defaultValue;
// form.comments = data.comments;
// if (data.type == 1) {
// images.value.push({
// uid: `${data.id}`,
// url: data.defaultValue,
// status: 'done'
// });
// }
// };
/* 保存编辑 */
const save = () => {
if (!formRef.value) {
return;
}
}
);
formRef.value
.validate()
.then(() => {
loading.value = true;
// 3 开关
if (form.type == 3) {
form.value = form.value ? '1' : '0';
}
const data = {
...form,
// name: form.name?.toUpperCase(),
websiteId: props.websiteId,
lang: locale.value
};
// 加密处理
if (data.encrypted) {
data.value = encrypt(data.value);
}
const saveOrUpdate = isUpdate.value
? updateCmsWebsiteField
: addCmsWebsiteField;
saveOrUpdate(data)
.then((msg) => {
loading.value = false;
message.success(msg);
updateVisible(false);
// 清除缓存
removeSiteInfoCache('SiteInfo:' + localStorage.getItem('TenantId'));
if (form.name == 'i18n') {
localStorage.setItem('i18n', '1');
window.location.reload();
}
emit('done');
})
.catch((e) => {
loading.value = false;
message.error(e.message);
});
})
.catch(() => {});
};
watch(
() => props.visible,
(visible) => {
if (visible) {
images.value = [];
if (props.data) {
assignFields(props.data);
form.comments = props.data.comments;
if (form.type == 1) {
images.value.push({
uid: uuid(),
url: props.data.value,
status: 'done'
});
}
if (form.type == 3) {
form.value = props.data.value == '1';
}
if (form.encrypted) {
form.value = decrypt(props.data.value);
}
isUpdate.value = true;
} else {
isUpdate.value = false;
}
} else {
resetFields();
}
}
);
</script>

View File

@@ -1,8 +1,18 @@
<template>
<a-space>
<a-button @click="add" type="primary">添加字段</a-button>
<a-button type="dashed" :disabled="!hasRole('superAdmin')" @click="handleExport">备份</a-button>
<a-button type="dashed" :disabled="!hasRole('superAdmin')" @click="openImport">恢复</a-button>
<a-button
type="dashed"
:disabled="!hasRole('superAdmin')"
@click="handleExport"
>备份</a-button
>
<a-button
type="dashed"
:disabled="!hasRole('superAdmin')"
@click="openImport"
>恢复</a-button
>
<a-input-search
allow-clear
placeholder="请输入关键词"
@@ -12,103 +22,96 @@
/>
</a-space>
<!-- 导入弹窗 -->
<import v-model:visible="showImport" @done="reload"/>
<import v-model:visible="showImport" @done="reload" />
</template>
<script lang="ts" setup>
import {ref} from 'vue';
import {CmsWebsiteField, CmsWebsiteFieldParam} from "@/api/cms/cmsWebsiteField/model";
import useSearch from "@/utils/use-search";
import {hasRole} from "@/utils/permission";
import {utils, writeFile} from 'xlsx';
import {message} from 'ant-design-vue';
import Import from "./Import.vue";
import {listCmsWebsiteField} from "@/api/cms/cmsWebsiteField";
import {getTenantId} from "@/utils/domain";
import { ref } from 'vue';
import {
CmsWebsiteField,
CmsWebsiteFieldParam
} from '@/api/cms/cmsWebsiteField/model';
import useSearch from '@/utils/use-search';
import { hasRole } from '@/utils/permission';
import { utils, writeFile } from 'xlsx';
import { message } from 'ant-design-vue';
import Import from './Import.vue';
import { listCmsWebsiteField } from '@/api/cms/cmsWebsiteField';
import { getTenantId } from '@/utils/domain';
// 是否显示导入弹窗
const showImport = ref(false);
const loading = ref(false);
const xlsFileName = ref<string>();
const fields = ref<CmsWebsiteField[]>([]);
// 是否显示导入弹窗
const showImport = ref(false);
const loading = ref(false);
const xlsFileName = ref<string>();
const fields = ref<CmsWebsiteField[]>([]);
const emit = defineEmits<{
(e: 'search', where?: CmsWebsiteFieldParam): void;
(e: 'add'): void;
}>();
const emit = defineEmits<{
(e: 'search', where?: CmsWebsiteFieldParam): void;
(e: 'add'): void;
}>();
const add = () => {
emit('add');
};
const add = () => {
emit('add');
};
// 表单数据
const { where } = useSearch<CmsWebsiteFieldParam>({
keywords: ''
});
// 表单数据
const {where} = useSearch<CmsWebsiteFieldParam>({
keywords: ''
});
const reload = () => {
emit('search', where);
};
const reload = () => {
emit('search', where);
};
/* 打开编辑弹窗 */
const openImport = () => {
showImport.value = true;
};
/* 打开编辑弹窗 */
const openImport = () => {
showImport.value = true;
};
// 导出
const handleExport = async () => {
loading.value = true;
const array: (string | number)[][] = [
['类型', '名称', '值', '加密', '备注']
];
// 导出
const handleExport = async () => {
loading.value = true;
const array: (string | number)[][] = [
[
'类型',
'名称',
'值',
'加密',
'备注'
]
];
// 按搜索结果导出
await listCmsWebsiteField(where)
.then((list) => {
fields.value = list;
list?.forEach((d: CmsWebsiteField) => {
array.push([
`${d.type}`,
`${d.name}`,
`${d.value}`,
`${d.encrypted ? '1' : '0'}`,
`${d.comments}`
]);
});
const sheetName = `bak_config_${getTenantId()}`;
const workbook = {
SheetNames: [sheetName],
Sheets: {}
};
const sheet = utils.aoa_to_sheet(array);
workbook.Sheets[sheetName] = sheet;
// 设置列宽
sheet['!cols'] = [];
message.loading('正在导出...');
setTimeout(() => {
writeFile(
workbook,
`${
where.createTimeEnd ? xlsFileName.value + '_' : ''
}${sheetName}.xlsx`
);
// 按搜索结果导出
await listCmsWebsiteField(where)
.then((list) => {
fields.value = list;
list?.forEach((d: CmsWebsiteField) => {
array.push([
`${d.type}`,
`${d.name}`,
`${d.value}`,
`${d.encrypted ? '1' : '0'}`,
`${d.comments}`
]);
});
const sheetName = `bak_config_${getTenantId()}`;
const workbook = {
SheetNames: [sheetName],
Sheets: {}
};
const sheet = utils.aoa_to_sheet(array);
workbook.Sheets[sheetName] = sheet;
// 设置列宽
sheet['!cols'] = [];
message.loading('正在导出...');
setTimeout(() => {
writeFile(
workbook,
`${
where.createTimeEnd ? xlsFileName.value + '_' : ''
}${sheetName}.xlsx`
);
loading.value = false;
}, 1000);
})
.catch((msg) => {
message.error(msg);
loading.value = false;
}, 1000);
})
.catch((msg) => {
message.error(msg);
loading.value = false;
})
.finally(() => {
});
};
})
.finally(() => {});
};
</script>

View File

@@ -1,7 +1,7 @@
<template>
<a-page-header :title="getPageTitle()" @back="() => $router.go(-1)">
<template #extra>
<CmsWebsiteSearch/>
<CmsWebsiteSearch />
</template>
<a-card :bordered="false">
<div class="website-field">
@@ -17,17 +17,33 @@
class="sys-org-table"
>
<template #toolbar>
<Search @add="openEdit" @search="reload"/>
<Search @add="openEdit" @search="reload" />
</template>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'name'">
<div class="ele-text-heading" @mouseover="onCopyIcon(record.name)" @mouseleave="hideCopyIcon">
<div
class="ele-text-heading"
@mouseover="onCopyIcon(record.name)"
@mouseleave="hideCopyIcon"
>
<span>{{ record.name }}</span>
<CopyOutlined class="px-2" style="color: #cccccc" @click="copyText(`${record.name} ${record.encrypted ? decrypt(record.value) : record.value}`)"/>
<CopyOutlined
class="px-2"
style="color: #cccccc"
@click="
copyText(
`${record.name} ${
record.encrypted ? decrypt(record.value) : record.value
}`
)
"
/>
</div>
<template v-if="record.value">
<a-space>
<div class="text-gray-400" v-if="record.encrypted">{{ decrypt(record.value) }}</div>
<div class="text-gray-400" v-if="record.encrypted">{{
decrypt(record.value)
}}</div>
<div class="text-gray-400" v-else>{{ record.value }}</div>
</a-space>
</template>
@@ -45,11 +61,15 @@
style="background-color: #000000"
:width="120"
:height="120"
></video>
<a-switch
v-else-if="record.type == 3"
:checked="record.value == '1'"
@change="updateValue(record)"
/>
<a-switch v-else-if="record.type == 3" :checked="record.value == '1'" @change="updateValue(record)"/>
<span v-else-if="record.name === 'AppSecret'">
{{ decrypt(record.value) }}
</span>
{{ decrypt(record.value) }}
</span>
<div v-else v-html="record.value"></div>
</a-space>
</template>
@@ -62,7 +82,7 @@
<template v-if="column.key === 'action'">
<a @click="openEdit(record)">编辑</a>
<template v-if="record.deleted == 0">
<a-divider type="vertical"/>
<a-divider type="vertical" />
<a-popconfirm
title="确定要删除此记录吗?"
@confirm="remove(record)"
@@ -71,7 +91,7 @@
</a-popconfirm>
</template>
<template v-if="record.deleted == 1">
<a-divider type="vertical"/>
<a-divider type="vertical" />
<a-popconfirm
title="确定要放回原处吗?"
@confirm="recovery(record)"
@@ -83,202 +103,203 @@
</template>
</ele-pro-table>
<!-- 编辑弹窗 -->
<Edit v-model:visible="showEdit" :data="current" @done="reload"/>
<Edit v-model:visible="showEdit" :data="current" @done="reload" />
</div>
</a-card>
</a-page-header>
</template>
<script lang="ts" setup>
import {ref, watch} from 'vue';
import {message} from 'ant-design-vue';
import type {EleProTable} from 'ele-admin-pro';
import {CopyOutlined} from '@ant-design/icons-vue';
import type {DatasourceFunction} from 'ele-admin-pro/es/ele-pro-table/types';
import CmsWebsiteSearch from "@/views/cms/cmsWebsite/components/search.vue";
import Search from './components/search.vue';
import Edit from './components/edit.vue';
import {
CmsWebsiteField,
CmsWebsiteFieldParam
} from '@/api/cms/cmsWebsiteField/model';
import {
listCmsWebsiteField,
removeCmsWebsiteField,
undeleteWebsiteField, updateCmsWebsiteField
} from '@/api/cms/cmsWebsiteField';
import {copyText, decrypt, getPageTitle} from '@/utils/common';
import { ref, watch } from 'vue';
import { message } from 'ant-design-vue';
import type { EleProTable } from 'ele-admin-pro';
import { CopyOutlined } from '@ant-design/icons-vue';
import type { DatasourceFunction } from 'ele-admin-pro/es/ele-pro-table/types';
import CmsWebsiteSearch from '@/views/cms/cmsWebsite/components/search.vue';
import Search from './components/search.vue';
import Edit from './components/edit.vue';
import {
CmsWebsiteField,
CmsWebsiteFieldParam
} from '@/api/cms/cmsWebsiteField/model';
import {
listCmsWebsiteField,
removeCmsWebsiteField,
undeleteWebsiteField,
updateCmsWebsiteField
} from '@/api/cms/cmsWebsiteField';
import { copyText, decrypt, getPageTitle } from '@/utils/common';
const props = defineProps<{
websiteId: any;
data: CmsWebsiteField;
}>();
const props = defineProps<{
websiteId: any;
data: CmsWebsiteField;
}>();
// 表格实例
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
const selection = ref<any[]>();
// 当前编辑数据
const current = ref<CmsWebsiteField | null>(null);
// 是否显示编辑弹窗
const showEdit = ref(false);
const currentName = ref<string>();
// 表格实例
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
const selection = ref<any[]>();
// 当前编辑数据
const current = ref<CmsWebsiteField | null>(null);
// 是否显示编辑弹窗
const showEdit = ref(false);
const currentName = ref<string>();
// 表格数据源
const datasource: DatasourceFunction = ({page, limit, where, orders}) => {
// 搜索条件
return listCmsWebsiteField({
...where,
...orders,
page,
limit
});
};
// 表格列配置
const columns = ref<any[]>([
// {
// title: 'ID',
// dataIndex: 'id',
// width: 120
// },
{
title: '字段',
dataIndex: 'name',
key: 'name',
ellipsis: true
},
// {
// title: '值',
// dataIndex: 'value',
// key: 'value',
// ellipsis: true
// },
{
title: '描述',
dataIndex: 'comments',
key: 'comments',
ellipsis: true
},
{
title: '加密',
dataIndex: 'encrypted',
key: 'encrypted',
align: 'center',
width: 120
},
{
title: '排序',
dataIndex: 'sortNumber',
width: 120,
align: 'center'
},
{
title: '操作',
key: 'action',
width: 180,
align: 'center',
hideInSetting: true
}
]);
const onCopyIcon = (text: string) => {
currentName.value = text;
}
const hideCopyIcon = () => {
currentName.value = undefined;
}
/* 打开编辑弹窗 */
const openEdit = (row?: CmsWebsiteField) => {
current.value = row ?? null;
showEdit.value = true;
};
/* 搜索 */
const reload = (where?: CmsWebsiteFieldParam) => {
selection.value = [];
tableRef?.value?.reload({where: where});
};
const updateValue = (row: CmsWebsiteField) => {
const hide = message.loading('请求中..', 0);
updateCmsWebsiteField({
...row,
value: row.value == '1' ? '0' : '1'
})
.then((msg) => {
hide();
message.success(msg);
reload();
})
.catch((e) => {
hide();
message.error(e.message);
// 表格数据源
const datasource: DatasourceFunction = ({ page, limit, where, orders }) => {
// 搜索条件
return listCmsWebsiteField({
...where,
...orders,
page,
limit
});
};
/* 删除单个 */
const remove = (row: CmsWebsiteField) => {
const hide = message.loading('请求中..', 0);
removeCmsWebsiteField(row.id)
.then((msg) => {
hide();
message.success(msg);
if (row.name == 'i18n') {
localStorage.removeItem('i18n');
window.location.reload();
}
reload();
})
.catch((e) => {
hide();
message.error(e.message);
});
};
// 从回收站放回原处
const recovery = (row: CmsWebsiteField) => {
const hide = message.loading('请求中..', 0);
undeleteWebsiteField(row.id)
.then((msg) => {
hide();
message.success(msg);
reload();
})
.catch((e) => {
hide();
message.error(e.message);
});
};
/* 自定义行属性 */
const customRow = (record: CmsWebsiteField) => {
return {
// 行点击事件
onClick: () => {
// console.log(record);
},
// 行双击事件
onDblclick: () => {
openEdit(record);
}
};
};
watch(
() => props.websiteId,
(websiteId) => {
if (websiteId) {
reload();
// 表格列配置
const columns = ref<any[]>([
// {
// title: 'ID',
// dataIndex: 'id',
// width: 120
// },
{
title: '字段',
dataIndex: 'name',
key: 'name',
ellipsis: true
},
// {
// title: '值',
// dataIndex: 'value',
// key: 'value',
// ellipsis: true
// },
{
title: '描述',
dataIndex: 'comments',
key: 'comments',
ellipsis: true
},
{
title: '加密',
dataIndex: 'encrypted',
key: 'encrypted',
align: 'center',
width: 120
},
{
title: '排序',
dataIndex: 'sortNumber',
width: 120,
align: 'center'
},
{
title: '操作',
key: 'action',
width: 180,
align: 'center',
hideInSetting: true
}
},
{immediate: true}
);
]);
const onCopyIcon = (text: string) => {
currentName.value = text;
};
const hideCopyIcon = () => {
currentName.value = undefined;
};
/* 打开编辑弹窗 */
const openEdit = (row?: CmsWebsiteField) => {
current.value = row ?? null;
showEdit.value = true;
};
/* 搜索 */
const reload = (where?: CmsWebsiteFieldParam) => {
selection.value = [];
tableRef?.value?.reload({ where: where });
};
const updateValue = (row: CmsWebsiteField) => {
const hide = message.loading('请求中..', 0);
updateCmsWebsiteField({
...row,
value: row.value == '1' ? '0' : '1'
})
.then((msg) => {
hide();
message.success(msg);
reload();
})
.catch((e) => {
hide();
message.error(e.message);
});
};
/* 删除单个 */
const remove = (row: CmsWebsiteField) => {
const hide = message.loading('请求中..', 0);
removeCmsWebsiteField(row.id)
.then((msg) => {
hide();
message.success(msg);
if (row.name == 'i18n') {
localStorage.removeItem('i18n');
window.location.reload();
}
reload();
})
.catch((e) => {
hide();
message.error(e.message);
});
};
// 从回收站放回原处
const recovery = (row: CmsWebsiteField) => {
const hide = message.loading('请求中..', 0);
undeleteWebsiteField(row.id)
.then((msg) => {
hide();
message.success(msg);
reload();
})
.catch((e) => {
hide();
message.error(e.message);
});
};
/* 自定义行属性 */
const customRow = (record: CmsWebsiteField) => {
return {
// 行点击事件
onClick: () => {
// console.log(record);
},
// 行双击事件
onDblclick: () => {
openEdit(record);
}
};
};
watch(
() => props.websiteId,
(websiteId) => {
if (websiteId) {
reload();
}
},
{ immediate: true }
);
</script>
<script lang="ts">
export default {
name: 'CmsWebsiteFieldIndex'
};
export default {
name: 'CmsWebsiteFieldIndex'
};
</script>

View File

@@ -61,7 +61,10 @@
v-model:value="form.plugin"
/>
</a-form-item>
<a-form-item label="编辑器类型 1 md-editor-v3, 2 tinymce-editor" name="editor">
<a-form-item
label="编辑器类型 1 md-editor-v3, 2 tinymce-editor"
name="editor"
>
<a-input
allow-clear
placeholder="请输入编辑器类型 1 md-editor-v3, 2 tinymce-editor"
@@ -134,7 +137,10 @@
import { ref, reactive, watch } from 'vue';
import { Form, message } from 'ant-design-vue';
import { assignObject } from 'ele-admin-pro';
import { addCmsWebsiteSetting, updateCmsWebsiteSetting } from '@/api/cms/cmsWebsiteSetting';
import {
addCmsWebsiteSetting,
updateCmsWebsiteSetting
} from '@/api/cms/cmsWebsiteSetting';
import { CmsWebsiteSetting } from '@/api/cms/cmsWebsiteSetting/model';
import { useThemeStore } from '@/store/modules/theme';
import { storeToRefs } from 'pinia';
@@ -221,7 +227,9 @@
const formData = {
...form
};
const saveOrUpdate = isUpdate.value ? updateCmsWebsiteSetting : addCmsWebsiteSetting;
const saveOrUpdate = isUpdate.value
? updateCmsWebsiteSetting
: addCmsWebsiteSetting;
saveOrUpdate(formData)
.then((msg) => {
loading.value = false;

View File

@@ -45,7 +45,11 @@
</a-card>
<!-- 编辑弹窗 -->
<CmsWebsiteSettingEdit v-model:visible="showEdit" :data="current" @done="reload" />
<CmsWebsiteSettingEdit
v-model:visible="showEdit"
:data="current"
@done="reload"
/>
</div>
</div>
</template>
@@ -62,8 +66,15 @@
} from 'ele-admin-pro/es/ele-pro-table/types';
import Search from './components/search.vue';
import CmsWebsiteSettingEdit from './components/cmsWebsiteSettingEdit.vue';
import { pageCmsWebsiteSetting, removeCmsWebsiteSetting, removeBatchCmsWebsiteSetting } from '@/api/cms/cmsWebsiteSetting';
import type { CmsWebsiteSetting, CmsWebsiteSettingParam } from '@/api/cms/cmsWebsiteSetting/model';
import {
pageCmsWebsiteSetting,
removeCmsWebsiteSetting,
removeBatchCmsWebsiteSetting
} from '@/api/cms/cmsWebsiteSetting';
import type {
CmsWebsiteSetting,
CmsWebsiteSettingParam
} from '@/api/cms/cmsWebsiteSetting/model';
// 表格实例
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
@@ -105,91 +116,91 @@
dataIndex: 'id',
key: 'id',
align: 'center',
width: 90,
width: 90
},
{
title: '关联网站ID',
dataIndex: 'websiteId',
key: 'websiteId',
align: 'center',
align: 'center'
},
{
title: '是否官方插件',
dataIndex: 'official',
key: 'official',
align: 'center',
align: 'center'
},
{
title: '是否展示在插件市场',
dataIndex: 'market',
key: 'market',
align: 'center',
align: 'center'
},
{
title: '是否允许被搜索',
dataIndex: 'search',
key: 'search',
align: 'center',
align: 'center'
},
{
title: '是否共享',
dataIndex: 'share',
key: 'share',
align: 'center',
align: 'center'
},
{
title: '是否插件 0应用1 插件 ',
dataIndex: 'plugin',
key: 'plugin',
align: 'center',
align: 'center'
},
{
title: '编辑器类型 1 md-editor-v3, 2 tinymce-editor',
dataIndex: 'editor',
key: 'editor',
align: 'center',
align: 'center'
},
{
title: '显示站内搜索',
dataIndex: 'searchBtn',
key: 'searchBtn',
align: 'center',
align: 'center'
},
{
title: '显示登录注册功能',
dataIndex: 'loginBtn',
key: 'loginBtn',
align: 'center',
align: 'center'
},
{
title: '显示悬浮客服工具',
dataIndex: 'kefuTool',
key: 'kefuTool',
align: 'center',
align: 'center'
},
{
title: '显示版权链接',
dataIndex: 'copyrightLink',
key: 'copyrightLink',
align: 'center',
align: 'center'
},
{
title: '导航栏最多显示数量',
dataIndex: 'maxMenuNum',
key: 'maxMenuNum',
align: 'center',
align: 'center'
},
{
title: '排序号',
dataIndex: 'sortNumber',
key: 'sortNumber',
align: 'center',
align: 'center'
},
{
title: '是否删除, 0否, 1是',
dataIndex: 'deleted',
key: 'deleted',
align: 'center',
align: 'center'
},
{
title: '创建时间',
@@ -204,7 +215,7 @@
title: '修改时间',
dataIndex: 'updateTime',
key: 'updateTime',
align: 'center',
align: 'center'
},
{
title: '操作',
@@ -261,7 +272,9 @@
maskClosable: true,
onOk: () => {
const hide = message.loading('请求中..', 0);
removeBatchCmsWebsiteSetting(selection.value.map((d) => d.cmsWebsiteSettingId))
removeBatchCmsWebsiteSetting(
selection.value.map((d) => d.cmsWebsiteSettingId)
)
.then((msg) => {
hide();
message.success(msg);

View File

@@ -1,100 +1,71 @@
<!-- 搜索表单 -->
<template>
<a-space style="flex-wrap: wrap">
<a-button
type="text"
@click="openUrl(`/website/field`)"
>字段扩展
<a-button type="text" @click="openUrl(`/website/field`)"
>字段扩展
</a-button>
<a-button
type="text"
@click="openUrl('/website/dict')"
>字典管理
<a-button type="text" @click="openUrl('/website/dict')">字典管理 </a-button>
<a-button type="text" @click="openUrl('/website/domain')"
>域名管理
</a-button>
<a-button
type="text"
@click="openUrl('/website/domain')"
>域名管理
</a-button
>
<a-button
type="text"
@click="openUrl('/website/model')"
>模型管理
</a-button
>
<a-button
type="text"
@click="openUrl('/website/form')"
>表单管理
</a-button
>
<a-button
type="text"
@click="openUrl('/website/lang')"
>国际化
</a-button
>
<a-button
type="text"
@click="openUrl('/website/setting')"
>网站设置
</a-button
>
<a-button
type="text"
class="ele-btn-icon"
@click="clearSiteInfoCache">
<a-button type="text" @click="openUrl('/website/model')"
>模型管理
</a-button>
<a-button type="text" @click="openUrl('/website/form')">表单管理 </a-button>
<a-button type="text" @click="openUrl('/website/lang')">国际化 </a-button>
<a-button type="text" @click="openUrl('/website/setting')"
>网站设置
</a-button>
<a-button type="text" class="ele-btn-icon" @click="clearSiteInfoCache">
清除缓存
</a-button>
</a-space>
</template>
<script lang="ts" setup>
import {watch,nextTick} from 'vue';
import {CmsWebsite} from '@/api/cms/cmsWebsite/model';
import {openUrl} from "@/utils/common";
import {message} from 'ant-design-vue';
import {removeSiteInfoCache} from "@/api/cms/cmsWebsite";
import { watch, nextTick } from 'vue';
import { CmsWebsite } from '@/api/cms/cmsWebsite/model';
import { openUrl } from '@/utils/common';
import { message } from 'ant-design-vue';
import { removeSiteInfoCache } from '@/api/cms/cmsWebsite';
const props = withDefaults(
defineProps<{
// 选中的角色
selection?: [];
website?: CmsWebsite;
count?: 0;
}>(),
{}
);
const props = withDefaults(
defineProps<{
// 选中的角色
selection?: [];
website?: CmsWebsite;
count?: 0;
}>(),
{}
);
const emit = defineEmits<{
(e: 'add'): void;
}>();
const emit = defineEmits<{
(e: 'add'): void;
}>();
const add = () => {
emit('add');
};
const add = () => {
emit('add');
};
// 清除缓存
const clearSiteInfoCache = () => {
removeSiteInfoCache('SiteInfo:' + localStorage.getItem('TenantId') + "*").then(
(msg) => {
// 清除缓存
const clearSiteInfoCache = () => {
removeSiteInfoCache(
'SiteInfo:' + localStorage.getItem('TenantId') + '*'
).then((msg) => {
if (msg) {
message.success(msg);
}
});
};
nextTick(() => {
if (localStorage.getItem('NotActive')) {
// IsActive.value = false
}
});
watch(
() => props.selection,
() => {}
);
};
nextTick(() => {
if(localStorage.getItem('NotActive')){
// IsActive.value = false
}
})
watch(
() => props.selection,
() => {
}
);
</script>

View File

@@ -39,11 +39,8 @@
v-model:value="form.websiteName"
/>
</a-form-item>
<a-form-item label="网站域名" name="domain" v-if="form.type == 10">
<a-input
v-model:value="form.domain"
placeholder="huawei.com"
>
<a-form-item label="网站域名" name="domain" v-if="form.type == 10">
<a-input v-model:value="form.domain" placeholder="huawei.com">
<template #addonBefore>
<a-select v-model:value="form.prefix" style="width: 90px">
<a-select-option value="http://">http://</a-select-option>
@@ -52,7 +49,7 @@
</template>
</a-input>
</a-form-item>
<a-form-item label="AppId" name="websiteCode" v-if="form.type == 20">
<a-form-item label="AppId" name="websiteCode" v-if="form.type == 20">
<a-input
allow-clear
placeholder="请输入AppId"
@@ -120,294 +117,292 @@
</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 {addCmsWebsite, updateCmsWebsite} from '@/api/cms/cmsWebsite';
import {CmsWebsite} from '@/api/cms/cmsWebsite/model';
import {useThemeStore} from '@/store/modules/theme';
import {storeToRefs} from 'pinia';
import {FormInstance, type Rule} from 'ant-design-vue/es/form';
import {ItemType} from 'ele-admin-pro/es/ele-image-upload/types';
import {FileRecord} from '@/api/system/file/model';
import {checkExistence} from '@/api/cms/cmsDomain';
import {updateCmsDomain} from '@/api/cms/cmsDomain';
import {updateTenant} from "@/api/system/tenant";
import { ref, reactive, watch } from 'vue';
import { Form, message } from 'ant-design-vue';
import { assignObject, uuid } from 'ele-admin-pro';
import { addCmsWebsite, updateCmsWebsite } from '@/api/cms/cmsWebsite';
import { CmsWebsite } from '@/api/cms/cmsWebsite/model';
import { useThemeStore } from '@/store/modules/theme';
import { storeToRefs } from 'pinia';
import { FormInstance, type Rule } from 'ant-design-vue/es/form';
import { ItemType } from 'ele-admin-pro/es/ele-image-upload/types';
import { FileRecord } from '@/api/system/file/model';
import { checkExistence } from '@/api/cms/cmsDomain';
import { updateCmsDomain } from '@/api/cms/cmsDomain';
import { updateTenant } from '@/api/system/tenant';
// 是否是修改
const isUpdate = ref(false);
const useForm = Form.useForm;
// 是否开启响应式布局
const themeStore = useThemeStore();
const {styleResponsive} = storeToRefs(themeStore);
// 是否是修改
const isUpdate = ref(false);
const useForm = Form.useForm;
// 是否开启响应式布局
const themeStore = useThemeStore();
const { styleResponsive } = storeToRefs(themeStore);
const props = defineProps<{
// 弹窗是否打开
visible: boolean;
// 修改回显的数据
data?: CmsWebsite | null;
}>();
const props = defineProps<{
// 弹窗是否打开
visible: boolean;
// 修改回显的数据
data?: CmsWebsite | null;
}>();
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 maxable = ref(true);
// 表格选中数据
const formRef = ref<FormInstance | null>(null);
const images = ref<ItemType[]>([]);
const websiteQrcode = ref<ItemType[]>([]);
const oldDomain = ref();
const files = ref<ItemType[]>([]);
// 提交状态
const loading = ref(false);
// 是否显示最大化切换按钮
const maxable = ref(true);
// 表格选中数据
const formRef = ref<FormInstance | null>(null);
const images = ref<ItemType[]>([]);
const websiteQrcode = ref<ItemType[]>([]);
const oldDomain = ref();
const files = ref<ItemType[]>([]);
// 用户信息
const form = reactive<CmsWebsite>({
websiteId: undefined,
websiteLogo: undefined,
websiteName: undefined,
websiteCode: undefined,
type: 20,
files: undefined,
keywords: '',
prefix: '',
domain: '',
adminUrl: '',
style: '',
icpNo: undefined,
email: undefined,
version: undefined,
websiteType: '',
running: 1,
expirationTime: undefined,
sortNumber: undefined,
comments: undefined,
status: undefined,
statusText: undefined
});
/* 更新visible */
const updateVisible = (value: boolean) => {
emit('update:visible', value);
};
// 表单验证规则
const rules = reactive({
// comments: [
// {
// required: true,
// type: 'string',
// message: '请填写小程序描述',
// trigger: 'blur'
// }
// ],
keywords: [
{
required: true,
type: 'string',
message: '请填写SEO关键词',
trigger: 'blur'
}
],
running: [
{
required: true,
type: 'number',
message: '请选择小程序状态',
trigger: 'change'
}
],
domain: [
{
required: true,
type: 'string',
message: '请填写小程序域名',
trigger: 'blur'
}
],
websiteCode: [
{
required: true,
type: 'string',
message: '请填写小程序码',
trigger: 'blur'
}
],
// websiteCode: [
// {
// required: true,
// type: 'string',
// message: '该域名已被使用',
// validator: (_rule: Rule, value: string) => {
// return new Promise<void>((resolve, reject) => {
// if (!value) {
// return reject('请输入二级域名');
// }
// checkExistence('domain', `${value}.wsdns.cn`)
// .then(() => {
// if (value === oldDomain.value) {
// return resolve();
// }
// reject('已存在');
// })
// .catch(() => {
// resolve();
// });
// });
// },
// trigger: 'blur'
// }
// ],
adminUrl: [
{
required: true,
type: 'string',
message: '请填写小程序后台管理地址',
trigger: 'blur'
}
],
icpNo: [
{
required: true,
type: 'string',
message: '请填写ICP备案号',
trigger: 'blur'
}
],
appSecret: [
{
required: true,
type: 'string',
message: '请填写小程序秘钥',
trigger: 'blur'
}
],
websiteName: [
{
required: true,
type: 'string',
message: '请填写小程序信息名称',
trigger: 'blur'
}
]
});
const chooseImage = (data: FileRecord) => {
images.value.push({
uid: data.id,
url: data.path,
status: 'done'
// 用户信息
const form = reactive<CmsWebsite>({
websiteId: undefined,
websiteLogo: undefined,
websiteName: undefined,
websiteCode: undefined,
type: 20,
files: undefined,
keywords: '',
prefix: '',
domain: '',
adminUrl: '',
style: '',
icpNo: undefined,
email: undefined,
version: undefined,
websiteType: '',
running: 1,
expirationTime: undefined,
sortNumber: undefined,
comments: undefined,
status: undefined,
statusText: undefined
});
form.websiteLogo = data.downloadUrl;
};
const onDeleteItem = (index: number) => {
images.value.splice(index, 1);
form.websiteLogo = '';
};
/* 更新visible */
const updateVisible = (value: boolean) => {
emit('update:visible', value);
};
const chooseFile = (data: FileRecord) => {
form.websiteCode = data.url;
files.value.push({
uid: data.id,
url: data.url,
status: 'done'
});
};
const onDeleteFile = (index: number) => {
files.value.splice(index, 1);
};
// const onWebsiteType = (text: string) => {
// form.websiteType = text;
// };
const {resetFields} = useForm(form, rules);
/* 保存编辑 */
const save = () => {
if (!formRef.value) {
return;
}
formRef.value
.validate()
.then(() => {
loading.value = true;
const saveOrUpdate = isUpdate.value ? updateCmsWebsite : addCmsWebsite;
if (!isUpdate.value) {
updateVisible(false);
message.loading('创建过程中请勿刷新页面!', 0)
// 表单验证规则
const rules = reactive({
// comments: [
// {
// required: true,
// type: 'string',
// message: '请填写小程序描述',
// trigger: 'blur'
// }
// ],
keywords: [
{
required: true,
type: 'string',
message: '请填写SEO关键词',
trigger: 'blur'
}
const formData = {
...form,
type: 20,
adminUrl: `mp.websoft.top`,
files: JSON.stringify(files.value),
};
saveOrUpdate(formData)
.then((msg) => {
loading.value = false;
updateVisible(false);
updateCmsDomain({
websiteId: form.websiteId,
domain: `${localStorage.getItem('TenantId')}.shoplnk.cn`
});
updateTenant({
tenantName: `${form.websiteName}`
}).then(() => {
})
localStorage.setItem('Domain', `${form.websiteCode}.shoplnk.cn`);
localStorage.setItem('WebsiteId', `${form.websiteId}`);
localStorage.setItem('WebsiteName', `${form.websiteName}`);
message.destroy();
message.success(msg);
// window.location.reload();
emit('done');
})
.catch((e) => {
loading.value = false;
message.destroy();
message.error(e.message);
});
})
.catch(() => {
],
running: [
{
required: true,
type: 'number',
message: '请选择小程序状态',
trigger: 'change'
}
],
domain: [
{
required: true,
type: 'string',
message: '请填写小程序域名',
trigger: 'blur'
}
],
websiteCode: [
{
required: true,
type: 'string',
message: '请填写小程序码',
trigger: 'blur'
}
],
// websiteCode: [
// {
// required: true,
// type: 'string',
// message: '该域名已被使用',
// validator: (_rule: Rule, value: string) => {
// return new Promise<void>((resolve, reject) => {
// if (!value) {
// return reject('请输入二级域名');
// }
// checkExistence('domain', `${value}.wsdns.cn`)
// .then(() => {
// if (value === oldDomain.value) {
// return resolve();
// }
// reject('已存在');
// })
// .catch(() => {
// resolve();
// });
// });
// },
// trigger: 'blur'
// }
// ],
adminUrl: [
{
required: true,
type: 'string',
message: '请填写小程序后台管理地址',
trigger: 'blur'
}
],
icpNo: [
{
required: true,
type: 'string',
message: '请填写ICP备案号',
trigger: 'blur'
}
],
appSecret: [
{
required: true,
type: 'string',
message: '请填写小程序秘钥',
trigger: 'blur'
}
],
websiteName: [
{
required: true,
type: 'string',
message: '请填写小程序信息名称',
trigger: 'blur'
}
]
});
const chooseImage = (data: FileRecord) => {
images.value.push({
uid: data.id,
url: data.path,
status: 'done'
});
};
form.websiteLogo = data.downloadUrl;
};
watch(
() => props.visible,
(visible) => {
if (visible) {
images.value = [];
files.value = [];
websiteQrcode.value = [];
if (props.data?.websiteId) {
assignObject(form, props.data);
if (props.data.websiteLogo) {
images.value.push({
uid: uuid(),
url: props.data.websiteLogo,
status: 'done'
});
}
if (props.data.files) {
files.value = JSON.parse(props.data.files);
}
if (props.data.websiteCode) {
oldDomain.value = props.data.websiteCode;
}
isUpdate.value = true;
} else {
isUpdate.value = false;
}
} else {
resetFields();
const onDeleteItem = (index: number) => {
images.value.splice(index, 1);
form.websiteLogo = '';
};
const chooseFile = (data: FileRecord) => {
form.websiteCode = data.url;
files.value.push({
uid: data.id,
url: data.url,
status: 'done'
});
};
const onDeleteFile = (index: number) => {
files.value.splice(index, 1);
};
// const onWebsiteType = (text: string) => {
// form.websiteType = text;
// };
const { resetFields } = useForm(form, rules);
/* 保存编辑 */
const save = () => {
if (!formRef.value) {
return;
}
},
{immediate: true}
);
formRef.value
.validate()
.then(() => {
loading.value = true;
const saveOrUpdate = isUpdate.value ? updateCmsWebsite : addCmsWebsite;
if (!isUpdate.value) {
updateVisible(false);
message.loading('创建过程中请勿刷新页面!', 0);
}
const formData = {
...form,
type: 20,
adminUrl: `mp.websoft.top`,
files: JSON.stringify(files.value)
};
saveOrUpdate(formData)
.then((msg) => {
loading.value = false;
updateVisible(false);
updateCmsDomain({
websiteId: form.websiteId,
domain: `${localStorage.getItem('TenantId')}.shoplnk.cn`
});
updateTenant({
tenantName: `${form.websiteName}`
}).then(() => {});
localStorage.setItem('Domain', `${form.websiteCode}.shoplnk.cn`);
localStorage.setItem('WebsiteId', `${form.websiteId}`);
localStorage.setItem('WebsiteName', `${form.websiteName}`);
message.destroy();
message.success(msg);
// window.location.reload();
emit('done');
})
.catch((e) => {
loading.value = false;
message.destroy();
message.error(e.message);
});
})
.catch(() => {});
};
watch(
() => props.visible,
(visible) => {
if (visible) {
images.value = [];
files.value = [];
websiteQrcode.value = [];
if (props.data?.websiteId) {
assignObject(form, props.data);
if (props.data.websiteLogo) {
images.value.push({
uid: uuid(),
url: props.data.websiteLogo,
status: 'done'
});
}
if (props.data.files) {
files.value = JSON.parse(props.data.files);
}
if (props.data.websiteCode) {
oldDomain.value = props.data.websiteCode;
}
isUpdate.value = true;
} else {
isUpdate.value = false;
}
} else {
resetFields();
}
},
{ immediate: true }
);
</script>

View File

@@ -18,16 +18,24 @@
<a-col :span="14">
<div class="system-info">
<h2 class="ele-text-heading">{{ siteStore.websiteName }}</h2>
<p class="ele-text-secondary">{{ siteStore.websiteComments }}</p>
<p class="ele-text-secondary">{{
siteStore.websiteComments
}}</p>
<a-space>
<a-tag color="blue">版本 {{ systemInfo.version }}</a-tag>
<a-tag color="green">{{ systemInfo.status }}</a-tag>
<a-popover title="小程序码">
<template #content>
<p><img :src="siteStore.websiteDarkLogo" alt="小程序码" width="300" height="300"></p>
<p
><img
:src="siteStore.websiteDarkLogo"
alt="小程序码"
width="300"
height="300"
/></p>
</template>
<a-tag>
<QrcodeOutlined/>
<QrcodeOutlined />
</a-tag>
</a-popover>
</a-space>
@@ -35,7 +43,6 @@
</a-col>
<a-col :span="3">
<div class="flex justify-center items-center h-full w-full">
</div>
</a-col>
</a-row>
@@ -52,7 +59,7 @@
:loading="loading"
>
<template #prefix>
<UserOutlined/>
<UserOutlined />
</template>
</a-statistic>
</a-card>
@@ -67,7 +74,7 @@
:loading="loading"
>
<template #prefix>
<AccountBookOutlined/>
<AccountBookOutlined />
</template>
</a-statistic>
</a-card>
@@ -82,7 +89,7 @@
:loading="loading"
>
<template #prefix>
<MoneyCollectOutlined/>
<MoneyCollectOutlined />
</template>
</a-statistic>
</a-card>
@@ -98,7 +105,7 @@
:loading="loading"
>
<template #prefix>
<ClockCircleOutlined/>
<ClockCircleOutlined />
</template>
</a-statistic>
</a-card>
@@ -130,7 +137,11 @@
{{ siteInfo?.expirationTime }}
</a-descriptions-item>
<a-descriptions-item label="技术支持">
<span class="cursor-pointer" @click="openNew(`https://websoft.top/order/3429.html`)">网宿软件</span>
<span
class="cursor-pointer"
@click="openNew(`https://websoft.top/order/3429.html`)"
>网宿软件</span
>
</a-descriptions-item>
</a-descriptions>
</a-card>
@@ -140,24 +151,28 @@
<a-col :span="12">
<a-card title="快捷操作" :bordered="false">
<a-space direction="vertical" style="width: 100%">
<a-button type="primary" block @click="$router.push('/website/index')">
<ShopOutlined/>
<a-button
type="primary"
block
@click="$router.push('/website/index')"
>
<ShopOutlined />
站点管理
</a-button>
<a-button block @click="$router.push('/website/order')">
<CalendarOutlined/>
<CalendarOutlined />
订单管理
</a-button>
<a-button block @click="$router.push('/system/user')">
<UserOutlined/>
<UserOutlined />
用户管理
</a-button>
<a-button block @click="$router.push('/system/login-record')">
<FileTextOutlined/>
<FileTextOutlined />
系统日志
</a-button>
<a-button block @click="$router.push('/system/setting')">
<SettingOutlined/>
<SettingOutlined />
系统设置
</a-button>
</a-space>
@@ -168,91 +183,92 @@
</template>
<script lang="ts" setup>
import {ref, onMounted, onUnmounted, computed} from 'vue';
import {
UserOutlined,
CalendarOutlined,
QrcodeOutlined,
ShopOutlined,
ClockCircleOutlined,
SettingOutlined,
AccountBookOutlined,
FileTextOutlined,
MoneyCollectOutlined
} from '@ant-design/icons-vue';
import {openNew} from "@/utils/common";
import { useSiteStore } from '@/store/modules/site';
import { useStatisticsStore } from '@/store/modules/statistics';
import { storeToRefs } from 'pinia';
import { ref, onMounted, onUnmounted, computed } from 'vue';
import {
UserOutlined,
CalendarOutlined,
QrcodeOutlined,
ShopOutlined,
ClockCircleOutlined,
SettingOutlined,
AccountBookOutlined,
FileTextOutlined,
MoneyCollectOutlined
} from '@ant-design/icons-vue';
import { openNew } from '@/utils/common';
import { useSiteStore } from '@/store/modules/site';
import { useStatisticsStore } from '@/store/modules/statistics';
import { storeToRefs } from 'pinia';
// 使用状态管理
const siteStore = useSiteStore();
const statisticsStore = useStatisticsStore();
// 使用状态管理
const siteStore = useSiteStore();
const statisticsStore = useStatisticsStore();
// 从 store 中获取响应式数据
const { siteInfo, loading: siteLoading } = storeToRefs(siteStore);
const { loading: statisticsLoading } = storeToRefs(statisticsStore);
// 从 store 中获取响应式数据
const { siteInfo, loading: siteLoading } = storeToRefs(siteStore);
const { loading: statisticsLoading } = storeToRefs(statisticsStore);
// 系统信息
const systemInfo = ref({
name: '小程序开发',
description: '基于Spring、SpringBoot、SpringMVC等技术栈构建的前后端分离开发平台',
version: '2.0.0',
status: '运行中',
logo: '/logo.png',
environment: '生产环境',
database: 'MySQL 8.0',
server: 'Linux CentOS 7.9',
expirationTime: '2024-01-01 09:00:00'
});
// 系统信息
const systemInfo = ref({
name: '小程序开发',
description:
'基于Spring、SpringBoot、SpringMVC等技术栈构建的前后端分离开发平台',
version: '2.0.0',
status: '运行中',
logo: '/logo.png',
environment: '生产环境',
database: 'MySQL 8.0',
server: 'Linux CentOS 7.9',
expirationTime: '2024-01-01 09:00:00'
});
// 计算属性
const runDays = computed(() => siteStore.runDays);
const userCount = computed(() => statisticsStore.userCount);
const orderCount = computed(() => statisticsStore.orderCount);
const totalSales = computed(() => statisticsStore.totalSales);
// 计算属性
const runDays = computed(() => siteStore.runDays);
const userCount = computed(() => statisticsStore.userCount);
const orderCount = computed(() => statisticsStore.orderCount);
const totalSales = computed(() => statisticsStore.totalSales);
// 加载状态
const loading = computed(() => siteLoading.value || statisticsLoading.value);
// 加载状态
const loading = computed(() => siteLoading.value || statisticsLoading.value);
onMounted(async () => {
// 加载网站信息和统计数据
try {
await Promise.all([
siteStore.fetchSiteInfo(),
statisticsStore.fetchStatistics()
]);
onMounted(async () => {
// 加载网站信息和统计数据
try {
await Promise.all([
siteStore.fetchSiteInfo(),
statisticsStore.fetchStatistics()
]);
// 开始自动刷新统计数据每5分钟
statisticsStore.startAutoRefresh();
} catch (error) {
console.error('加载数据失败:', error);
}
});
// 开始自动刷新统计数据每5分钟
statisticsStore.startAutoRefresh();
} catch (error) {
console.error('加载数据失败:', error);
}
});
onUnmounted(() => {
// 组件卸载时停止自动刷新
statisticsStore.stopAutoRefresh();
});
onUnmounted(() => {
// 组件卸载时停止自动刷新
statisticsStore.stopAutoRefresh();
});
</script>
<style scoped>
.system-info h2 {
margin-bottom: 8px;
}
.system-info h2 {
margin-bottom: 8px;
}
.stat-card {
text-align: center;
margin-bottom: 16px;
}
.stat-card {
text-align: center;
margin-bottom: 16px;
}
.stat-card :deep(.ant-statistic-title) {
font-size: 14px;
color: #666;
}
.stat-card :deep(.ant-statistic-title) {
font-size: 14px;
color: #666;
}
.stat-card :deep(.ant-statistic-content) {
font-size: 24px;
font-weight: 600;
}
.stat-card :deep(.ant-statistic-content) {
font-size: 24px;
font-weight: 600;
}
</style>

View File

@@ -13,7 +13,7 @@
>
<template #toolbar>
<a-space>
<a-button type="primary" class="ele-btn-icon" @click="openEdit()">
<a-button type="primary" class="ele-btn-icon" @click="openEdit()">
<template #icon>
<plus-outlined />
</template>

View File

@@ -1,7 +1,7 @@
<template>
<a-page-header :title="getPageTitle()" @back="() => $router.go(-1)">
<template #extra>
<Extra/>
<Extra />
</template>
<a-card :bordered="false">
<!-- 表格 -->
@@ -23,7 +23,7 @@
>
<a-button type="primary" class="ele-btn-icon">
<template #icon>
<UploadOutlined/>
<UploadOutlined />
</template>
<span>上传文件</span>
</a-button>
@@ -36,7 +36,7 @@
@click="removeBatch"
>
<template #icon>
<delete-outlined/>
<delete-outlined />
</template>
<span>删除</span>
</a-button>
@@ -63,10 +63,11 @@
</template>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'path'">
<span class="text-gray-400">[文件]</span>
<span class="text-gray-400">[文件]</span>
</template>
<template v-if="column.key === 'name'">
<div>{{ record.name }}
<div
>{{ record.name }}
<copy-outlined
style="padding-left: 4px"
@click="copyText(record.downloadUrl)"
@@ -76,9 +77,9 @@
<template v-if="column.key === 'action'">
<div>
<a :href="record.downloadUrl" target="_blank">下载</a>
<a-divider type="vertical"/>
<a-divider type="vertical" />
<a @click="openEdit(record)">修改</a>
<a-divider type="vertical"/>
<a-divider type="vertical" />
<a-popconfirm
placement="topRight"
title="确定要删除此评价吗?"
@@ -92,216 +93,213 @@
</ele-pro-table>
</a-card>
<!-- 编辑弹窗 -->
<video-edit v-model:visible="showEdit" :data="current" @done="reload"/>
<video-edit v-model:visible="showEdit" :data="current" @done="reload" />
</a-page-header>
</template>
<script lang="ts" setup>
import {createVNode, ref} from 'vue';
import {message, Modal} from 'ant-design-vue/es';
import {
UploadOutlined,
DeleteOutlined,
ExclamationCircleOutlined, CopyOutlined
} from '@ant-design/icons-vue';
import type {EleProTable} from 'ele-admin-pro/es';
import type {
DatasourceFunction,
ColumnItem
} from 'ele-admin-pro/es/ele-pro-table/types';
import {messageLoading, toDateString} from 'ele-admin-pro/es';
import VideoEdit from './components/video-edit.vue';
import {
pageFiles,
removeFile,
removeFiles,
uploadOss
} from '@/api/system/file';
import type {
FileRecord,
FileRecordParam
} from '@/api/system/file/model';
import {copyText, getPageTitle} from "@/utils/common";
import Extra from "@/views/cms/photo/components/Extra.vue";
import { createVNode, ref } from 'vue';
import { message, Modal } from 'ant-design-vue/es';
import {
UploadOutlined,
DeleteOutlined,
ExclamationCircleOutlined,
CopyOutlined
} from '@ant-design/icons-vue';
import type { EleProTable } from 'ele-admin-pro/es';
import type {
DatasourceFunction,
ColumnItem
} from 'ele-admin-pro/es/ele-pro-table/types';
import { messageLoading, toDateString } from 'ele-admin-pro/es';
import VideoEdit from './components/video-edit.vue';
import {
pageFiles,
removeFile,
removeFiles,
uploadOss
} from '@/api/system/file';
import type { FileRecord, FileRecordParam } from '@/api/system/file/model';
import { copyText, getPageTitle } from '@/utils/common';
import Extra from '@/views/cms/photo/components/Extra.vue';
// 表格实例
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
// 表格选中数据
const selection = ref<FileRecord[]>([]);
// 当前编辑数据
const current = ref<FileRecord | null>(null);
// 是否显示编辑弹窗
const showEdit = ref(false);
const type = ref('name');
const searchText = ref('');
// 表格列配置
const columns = ref<ColumnItem[]>([
{
key: 'index',
width: 48,
align: 'center',
fixed: 'left',
hideInSetting: true,
customRender: ({index}) => index + (tableRef.value?.tableIndex ?? 0)
},
{
title: '类型',
dataIndex: 'path',
align: 'center',
width: 90,
key: 'path'
},
{
title: '文件名称',
dataIndex: 'name',
key: 'name'
},
{
title: '描述',
dataIndex: 'comments',
ellipsis: true
},
{
title: '文件大小',
dataIndex: 'length',
sorter: true,
align: 'center',
showSorterTooltip: false,
ellipsis: true,
customRender: ({text}) => {
if (text < 1024) {
return text + 'B';
} else if (text < 1024 * 1024) {
return (text / 1024).toFixed(1) + 'KB';
} else if (text < 1024 * 1024 * 1024) {
return (text / 1024 / 1024).toFixed(1) + 'M';
} else {
return (text / 1024 / 1024 / 1024).toFixed(1) + 'G';
}
// 表格实例
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
// 表格选中数据
const selection = ref<FileRecord[]>([]);
// 当前编辑数据
const current = ref<FileRecord | null>(null);
// 是否显示编辑弹窗
const showEdit = ref(false);
const type = ref('name');
const searchText = ref('');
// 表格列配置
const columns = ref<ColumnItem[]>([
{
key: 'index',
width: 48,
align: 'center',
fixed: 'left',
hideInSetting: true,
customRender: ({ index }) => index + (tableRef.value?.tableIndex ?? 0)
},
width: 120
},
{
title: '发布者',
width: 120,
dataIndex: 'createNickname'
},
{
title: '发布时间',
dataIndex: 'createTime',
sorter: true,
width: 180,
showSorterTooltip: false,
ellipsis: true,
customRender: ({text}) => toDateString(text)
},
{
title: '操作',
key: 'action',
width: 200,
align: 'center'
}
]);
// 表格数据源
const datasource: DatasourceFunction = ({page, limit, where, orders}) => {
where = {};
if (type.value == 'name') {
where.name = searchText.value;
}
if (type.value == 'createNickname') {
where.createNickname = searchText.value;
}
where.contentType = 'application';
return pageFiles({...where, ...orders, page, limit});
};
/* 搜索 */
const reload = (where?: FileRecordParam) => {
selection.value = [];
tableRef?.value?.reload({page: 1, where});
};
/* 打开编辑弹窗 */
const openEdit = (row?: FileRecord) => {
current.value = row ?? null;
showEdit.value = true;
};
/* 删除单个 */
const remove = (row: FileRecord) => {
const hide = messageLoading('请求中..', 0);
removeFile(row.id)
.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 = messageLoading('请求中..', 0);
removeFiles(selection.value.map((d) => d.id))
.then((msg) => {
hide();
message.success(msg);
reload();
})
.catch((e) => {
hide();
message.error(e.message);
});
{
title: '类型',
dataIndex: 'path',
align: 'center',
width: 90,
key: 'path'
},
{
title: '文件名称',
dataIndex: 'name',
key: 'name'
},
{
title: '描述',
dataIndex: 'comments',
ellipsis: true
},
{
title: '文件大小',
dataIndex: 'length',
sorter: true,
align: 'center',
showSorterTooltip: false,
ellipsis: true,
customRender: ({ text }) => {
if (text < 1024) {
return text + 'B';
} else if (text < 1024 * 1024) {
return (text / 1024).toFixed(1) + 'KB';
} else if (text < 1024 * 1024 * 1024) {
return (text / 1024 / 1024).toFixed(1) + 'M';
} else {
return (text / 1024 / 1024 / 1024).toFixed(1) + 'G';
}
},
width: 120
},
{
title: '发布者',
width: 120,
dataIndex: 'createNickname'
},
{
title: '发布时间',
dataIndex: 'createTime',
sorter: true,
width: 180,
showSorterTooltip: false,
ellipsis: true,
customRender: ({ text }) => toDateString(text)
},
{
title: '操作',
key: 'action',
width: 200,
align: 'center'
}
});
};
]);
// 上传文件
const onUpload = (item) => {
const {file} = item;
if (!file.type.startsWith('application')) {
message.error('只能选择视频文件');
return;
}
if (file.size / 1024 / 1024 > 100) {
message.error('大小不能超过 100MB');
return;
}
const hide = messageLoading({
content: '上传中..',
duration: 0,
mask: true
});
uploadOss(file)
.then((data) => {
hide();
message.success('上传成功');
reload();
})
.catch((e) => {
message.error(e.message);
hide();
// 表格数据源
const datasource: DatasourceFunction = ({ page, limit, where, orders }) => {
where = {};
if (type.value == 'name') {
where.name = searchText.value;
}
if (type.value == 'createNickname') {
where.createNickname = searchText.value;
}
where.contentType = 'application';
return pageFiles({ ...where, ...orders, page, limit });
};
/* 搜索 */
const reload = (where?: FileRecordParam) => {
selection.value = [];
tableRef?.value?.reload({ page: 1, where });
};
/* 打开编辑弹窗 */
const openEdit = (row?: FileRecord) => {
current.value = row ?? null;
showEdit.value = true;
};
/* 删除单个 */
const remove = (row: FileRecord) => {
const hide = messageLoading('请求中..', 0);
removeFile(row.id)
.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 = messageLoading('请求中..', 0);
removeFiles(selection.value.map((d) => d.id))
.then((msg) => {
hide();
message.success(msg);
reload();
})
.catch((e) => {
hide();
message.error(e.message);
});
}
});
};
};
// 上传文件
const onUpload = (item) => {
const { file } = item;
if (!file.type.startsWith('application')) {
message.error('只能选择视频文件');
return;
}
if (file.size / 1024 / 1024 > 100) {
message.error('大小不能超过 100MB');
return;
}
const hide = messageLoading({
content: '上传中..',
duration: 0,
mask: true
});
uploadOss(file)
.then((data) => {
hide();
message.success('上传成功');
reload();
})
.catch((e) => {
message.error(e.message);
hide();
});
};
</script>
<script lang="ts">
export default {
name: 'FileIndex'
};
export default {
name: 'FileIndex'
};
</script>

View File

@@ -21,111 +21,105 @@
/>
</div>
<a-space direction="vertical" class="mt-5">
<div class="ele-text-secondary">
文件名称{{ form.name }}
</div>
<div class="ele-text-secondary">
文件路径{{ form.path }}
</div>
<div class="ele-text-secondary">
视频描述{{ form.comments }}
</div>
<div class="ele-text-secondary"> 文件名称{{ form.name }} </div>
<div class="ele-text-secondary"> 文件路径{{ form.path }} </div>
<div class="ele-text-secondary"> 视频描述{{ form.comments }} </div>
</a-space>
</a-card>
</a-page-header>
</template>
<script lang="ts" setup>
import {ref, reactive, watch, unref} from 'vue';
import Player from 'xgplayer';
import {useRouter} from 'vue-router';
import {toDateString} from 'ele-admin-pro';
import {setPageTabTitle} from '@/utils/page-tab-util';
import {message} from 'ant-design-vue/es';
import useFormData from '@/utils/use-form-data';
import {FileRecord} from '@/api/system/file/model';
import {getFile} from '@/api/system/file';
import { ref, reactive, watch, unref } from 'vue';
import Player from 'xgplayer';
import { useRouter } from 'vue-router';
import { toDateString } from 'ele-admin-pro';
import { setPageTabTitle } from '@/utils/page-tab-util';
import { message } from 'ant-design-vue/es';
import useFormData from '@/utils/use-form-data';
import { FileRecord } from '@/api/system/file/model';
import { getFile } from '@/api/system/file';
const {currentRoute} = useRouter();
import {getPageTitle} from "@/utils/common";
const { currentRoute } = useRouter();
import { getPageTitle } from '@/utils/common';
const ROUTE_PATH = '/cms/video/player';
const ROUTE_PATH = '/cms/video/player';
// 视频播放器一实例
let player1: Player;
// 视频播放器一是否实例化完成
const ready1 = ref(false);
// 视频播放器一实例
let player1: Player;
// 视频播放器一是否实例化完成
const ready1 = ref(false);
// 视频播放器一配置
const config1 = reactive({
id: 'demoPlayer1',
lang: 'zh-cn',
fluid: true,
// 视频地址
url: 'https://file.wsdns.cn/20221126/cf17ef352db54bf28efeda268107714f.mp4',
// 封面
poster:
'https://file.wsdns.cn/20221125/49f0c461d61e48f28b324366a0a63a2e.jpg',
// 开启倍速播放
playbackRate: [0.5, 1, 1.5, 2],
// 开启画中画
pip: true
});
/* 播放器一渲染完成 */
const onPlayer1 = (player: Player) => {
player1 = player;
player1.on('play', () => {
ready1.value = true;
// 视频播放器一配置
const config1 = reactive({
id: 'demoPlayer1',
lang: 'zh-cn',
fluid: true,
// 视频地址
url: 'https://file.wsdns.cn/20221126/cf17ef352db54bf28efeda268107714f.mp4',
// 封面
poster:
'https://file.wsdns.cn/20221125/49f0c461d61e48f28b324366a0a63a2e.jpg',
// 开启倍速播放
playbackRate: [0.5, 1, 1.5, 2],
// 开启画中画
pip: true
});
};
// 视频信息
const {form, assignFields} = useFormData<FileRecord>({
id: 0,
name: '',
url: '',
path: '',
comments: '',
createNickname: '',
createTime: ''
});
// 请求状态
const loading = ref(true);
/* */
const query = () => {
const {query} = unref(currentRoute);
const id = query.id;
if (!id || form.id === Number(id)) {
return;
}
loading.value = true;
getFile(Number(id))
.then((data) => {
loading.value = false;
assignFields({
...data,
createTime: toDateString(data.createTime)
});
// 修改页签标题
if (unref(currentRoute).path === ROUTE_PATH) {
setPageTabTitle(String(data.comments));
}
})
.catch((e) => {
loading.value = false;
message.error(e.message);
});
};
watch(
currentRoute,
(route) => {
const {path} = unref(route);
if (path !== ROUTE_PATH) {
/* 播放器一渲染完成 */
const onPlayer1 = (player: Player) => {
player1 = player;
player1.on('play', () => {
ready1.value = true;
});
};
// 视频信息
const { form, assignFields } = useFormData<FileRecord>({
id: 0,
name: '',
url: '',
path: '',
comments: '',
createNickname: '',
createTime: ''
});
// 请求状态
const loading = ref(true);
/* */
const query = () => {
const { query } = unref(currentRoute);
const id = query.id;
if (!id || form.id === Number(id)) {
return;
}
query();
},
{immediate: true}
);
loading.value = true;
getFile(Number(id))
.then((data) => {
loading.value = false;
assignFields({
...data,
createTime: toDateString(data.createTime)
});
// 修改页签标题
if (unref(currentRoute).path === ROUTE_PATH) {
setPageTabTitle(String(data.comments));
}
})
.catch((e) => {
loading.value = false;
message.error(e.message);
});
};
watch(
currentRoute,
(route) => {
const { path } = unref(route);
if (path !== ROUTE_PATH) {
return;
}
query();
},
{ immediate: true }
);
</script>

View File

@@ -12,58 +12,58 @@
</template>
<script lang="ts" setup>
import {watch} from 'vue';
import { PlusOutlined } from '@ant-design/icons-vue';
import type {CmsArticle, CmsArticleParam} from '@/api/cms/cmsArticle/model';
import useSearch from '@/utils/use-search';
import {CmsNavigation} from '@/api/cms/cmsNavigation/model';
import { watch } from 'vue';
import { PlusOutlined } from '@ant-design/icons-vue';
import type { CmsArticle, CmsArticleParam } from '@/api/cms/cmsArticle/model';
import useSearch from '@/utils/use-search';
import { CmsNavigation } from '@/api/cms/cmsNavigation/model';
const props = withDefaults(
defineProps<{
// 选中的角色
selection?: CmsArticle[];
merchantId?: number;
navigationList?: CmsNavigation[];
categoryId?: number;
}>(),
{}
);
const props = withDefaults(
defineProps<{
// 选中的角色
selection?: CmsArticle[];
merchantId?: number;
navigationList?: CmsNavigation[];
categoryId?: number;
}>(),
{}
);
// 表单数据
const {where} = useSearch<CmsArticleParam>({
articleId: undefined,
model: undefined,
categoryId: undefined,
merchantId: undefined,
keywords: '',
sceneType: undefined,
userId: undefined
});
// 表单数据
const { where } = useSearch<CmsArticleParam>({
articleId: undefined,
model: undefined,
categoryId: undefined,
merchantId: undefined,
keywords: '',
sceneType: undefined,
userId: undefined
});
const emit = defineEmits<{
(e: 'search', where?: CmsArticleParam): void;
(e: 'add'): void;
(e: 'remove'): void;
(e: 'batchMove'): void;
}>();
const emit = defineEmits<{
(e: 'search', where?: CmsArticleParam): void;
(e: 'add'): void;
(e: 'remove'): void;
(e: 'batchMove'): void;
}>();
const reload = () => {
emit('search', where);
};
const reload = () => {
emit('search', where);
};
// 新增
const add = () => {
emit('add');
};
// 新增
const add = () => {
emit('add');
};
watch(
() => props.merchantId,
() => {
if (props.categoryId) {
where.categoryId = props.categoryId;
}
reload();
},
{immediate: true}
);
watch(
() => props.merchantId,
() => {
if (props.categoryId) {
where.categoryId = props.categoryId;
}
reload();
},
{ immediate: true }
);
</script>

View File

@@ -51,331 +51,328 @@
</template>
<script lang="ts" setup>
import {createVNode, ref, watch} from 'vue';
import {message, Modal} from 'ant-design-vue';
import {
CheckOutlined,
CloseOutlined,
ExclamationCircleOutlined
} from '@ant-design/icons-vue';
import type {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 ArticleEdit from './components/articleEdit.vue';
import {
pageCmsArticle,
removeCmsArticle,
removeBatchCmsArticle,
updateCmsArticle
} from '@/api/cms/cmsArticle';
import type {CmsArticle, CmsArticleParam} from '@/api/cms/cmsArticle/model';
import {formatNumber} from 'ele-admin-pro/es';
import router from '@/router';
import {toTreeData} from 'ele-admin-pro';
import {toDateString} from 'ele-admin-pro';
import {
detail,
getPageTitle
} from '@/utils/common';
import {listCmsNavigation} from '@/api/cms/cmsNavigation';
import {CmsNavigation} from '@/api/cms/cmsNavigation/model';
import {CmsArticleCategory} from '@/api/cms/cmsArticleCategory/model';
import {listCmsArticleCategory} from '@/api/cms/cmsArticleCategory';
import {getCmsWebsiteSetting} from '@/api/cms/cmsWebsiteSetting';
import {useWebsiteSettingStore} from '@/store/modules/setting';
import { createVNode, ref, watch } from 'vue';
import { message, Modal } from 'ant-design-vue';
import {
CheckOutlined,
CloseOutlined,
ExclamationCircleOutlined
} from '@ant-design/icons-vue';
import type { 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 ArticleEdit from './components/articleEdit.vue';
import {
pageCmsArticle,
removeCmsArticle,
removeBatchCmsArticle,
updateCmsArticle
} from '@/api/cms/cmsArticle';
import type { CmsArticle, CmsArticleParam } from '@/api/cms/cmsArticle/model';
import { formatNumber } from 'ele-admin-pro/es';
import router from '@/router';
import { toTreeData } from 'ele-admin-pro';
import { toDateString } from 'ele-admin-pro';
import { detail, getPageTitle } from '@/utils/common';
import { listCmsNavigation } from '@/api/cms/cmsNavigation';
import { CmsNavigation } from '@/api/cms/cmsNavigation/model';
import { CmsArticleCategory } from '@/api/cms/cmsArticleCategory/model';
import { listCmsArticleCategory } from '@/api/cms/cmsArticleCategory';
import { getCmsWebsiteSetting } from '@/api/cms/cmsWebsiteSetting';
import { useWebsiteSettingStore } from '@/store/modules/setting';
// 表格实例
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
// 表格选中数据
const selection = ref<CmsArticle[]>([]);
// 当前编辑数据
const current = ref<CmsArticle | null>(null);
// 是否显示编辑弹窗
const showEdit = ref(false);
// 是否显示批量移动弹窗
const showMove = ref(false);
// 店铺ID
const merchantId = ref<number>();
// 栏目ID
const categoryId = ref<number>();
// 栏目数据
const navigationList = ref<CmsNavigation[]>();
// 文章分类
const categoryList = ref<CmsArticleCategory[]>();
// 是否显示二维码
const showQrcode = ref(false);
// 网站设置信息
const setting = useWebsiteSettingStore();
// 表格实例
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
// 表格选中数据
const selection = ref<CmsArticle[]>([]);
// 当前编辑数据
const current = ref<CmsArticle | null>(null);
// 是否显示编辑弹窗
const showEdit = ref(false);
// 是否显示批量移动弹窗
const showMove = ref(false);
// 店铺ID
const merchantId = ref<number>();
// 栏目ID
const categoryId = ref<number>();
// 栏目数据
const navigationList = ref<CmsNavigation[]>();
// 文章分类
const categoryList = ref<CmsArticleCategory[]>();
// 是否显示二维码
const showQrcode = ref(false);
// 网站设置信息
const setting = useWebsiteSettingStore();
// 表格数据源
const datasource: DatasourceFunction = ({page, limit, where, orders}) => {
if (categoryId.value) {
where.categoryId = categoryId.value;
}
where.model = 'help';
return pageCmsArticle({
...where,
...orders,
page,
limit
});
};
// 表格列配置
const columns = ref<ColumnItem[]>([
// {
// title: 'ID',
// dataIndex: 'articleId',
// key: 'articleId',
// align: 'center',
// width: 90
// },
// {
// title: '封面图',
// dataIndex: 'image',
// key: 'image',
// width: 120,
// align: 'center'
// },
{
title: '文章标题',
dataIndex: 'title',
key: 'title'
},
// {
// title: '栏目名称',
// dataIndex: 'categoryName',
// key: 'categoryName',
// 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',
// hideInTable: true
// },
// {
// title: '推荐',
// dataIndex: 'recommend',
// key: 'recommend',
// sorter: true,
// width: 120,
// align: 'center'
// },
// {
// title: '状态',
// dataIndex: 'status',
// key: 'status',
// sorter: true,
// width: 120,
// align: 'center'
// },
// {
// title: '排序号',
// dataIndex: 'sortNumber',
// key: 'sortNumber',
// sorter: true,
// width: 120,
// align: 'center'
// },
{
title: '创建时间',
dataIndex: 'createTime',
key: 'createTime',
align: 'center',
width: 180,
customRender: ({text}) => toDateString(text, 'yyyy-MM-dd'),
sorter: true
},
// {
// title: '操作',
// key: 'action',
// width: 180,
// fixed: 'right',
// align: 'center',
// hideInSetting: true
// }
]);
/* 搜索 */
const reload = (where?: CmsArticleParam) => {
selection.value = [];
tableRef?.value?.reload({where: where});
};
/* 打开编辑弹窗 */
const openEdit = (row?: CmsArticle) => {
current.value = row ?? null;
showEdit.value = true;
};
/* 打开批量移动弹窗 */
const openMove = () => {
showMove.value = true;
};
// 分享二维码
const onShare = (row?: CmsArticle) => {
const data = {
isMobile: true,
...row
// 表格数据源
const datasource: DatasourceFunction = ({ page, limit, where, orders }) => {
if (categoryId.value) {
where.categoryId = categoryId.value;
}
where.model = 'help';
return pageCmsArticle({
...where,
...orders,
page,
limit
});
};
data.qrcode = `${detail(data)}`;
data.url = `${detail(row)}`;
current.value = data ?? null;
showQrcode.value = true;
};
const onUpdate = (row?: CmsArticle) => {
const status = row?.status == 0 ? 1 : 0;
updateCmsArticle({...row, status}).then((msg) => {
message.success(msg);
reload();
});
};
// 表格列配置
const columns = ref<ColumnItem[]>([
// {
// title: 'ID',
// dataIndex: 'articleId',
// key: 'articleId',
// align: 'center',
// width: 90
// },
// {
// title: '封面图',
// dataIndex: 'image',
// key: 'image',
// width: 120,
// align: 'center'
// },
{
title: '文章标题',
dataIndex: 'title',
key: 'title'
},
// {
// title: '栏目名称',
// dataIndex: 'categoryName',
// key: 'categoryName',
// 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',
// hideInTable: true
// },
// {
// title: '推荐',
// dataIndex: 'recommend',
// key: 'recommend',
// sorter: true,
// width: 120,
// align: 'center'
// },
// {
// title: '状态',
// dataIndex: 'status',
// key: 'status',
// sorter: true,
// width: 120,
// align: 'center'
// },
// {
// title: '排序号',
// dataIndex: 'sortNumber',
// key: 'sortNumber',
// sorter: true,
// width: 120,
// align: 'center'
// },
{
title: '创建时间',
dataIndex: 'createTime',
key: 'createTime',
align: 'center',
width: 180,
customRender: ({ text }) => toDateString(text, 'yyyy-MM-dd'),
sorter: true
}
// {
// title: '操作',
// key: 'action',
// width: 180,
// fixed: 'right',
// align: 'center',
// hideInSetting: true
// }
]);
const onRecommend = (row: CmsArticle) => {
updateCmsArticle({
...row,
recommend: row.recommend == 1 ? 0 : 1
}).then((msg) => {
message.success(msg);
reload();
});
};
/* 搜索 */
const reload = (where?: CmsArticleParam) => {
selection.value = [];
tableRef?.value?.reload({ where: where });
};
/* 删除单个 */
const remove = (row: CmsArticle) => {
const hide = message.loading('请求中..', 0);
removeCmsArticle(row.articleId)
.then((msg) => {
hide();
/* 打开编辑弹窗 */
const openEdit = (row?: CmsArticle) => {
current.value = row ?? null;
showEdit.value = true;
};
/* 打开批量移动弹窗 */
const openMove = () => {
showMove.value = true;
};
// 分享二维码
const onShare = (row?: CmsArticle) => {
const data = {
isMobile: true,
...row
};
data.qrcode = `${detail(data)}`;
data.url = `${detail(row)}`;
current.value = data ?? null;
showQrcode.value = true;
};
const onUpdate = (row?: CmsArticle) => {
const status = row?.status == 0 ? 1 : 0;
updateCmsArticle({ ...row, status }).then((msg) => {
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);
removeBatchCmsArticle(selection.value.map((d) => d.articleId))
.then((msg) => {
hide();
message.success(msg);
reload();
})
.catch((e) => {
hide();
message.error(e.message);
});
}
});
};
/* 自定义行属性 */
const customRow = (record: CmsArticle) => {
return {
// 行点击事件
onClick: () => {
openEdit(record);
},
// 行双击事件
onDblclick: () => {
openEdit(record);
}
};
};
// 加载栏目数据
if (!navigationList.value) {
listCmsNavigation({}).then((res) => {
navigationList.value = toTreeData({
data: res?.map((d) => {
d.value = d.navigationId;
d.label = d.title;
if (!d.component) {
d.disabled = true;
}
if (
d.model == 'index' ||
d.model == 'page' ||
d.model == 'order' ||
d.model == 'links'
) {
d.disabled = true;
}
return d;
}),
idField: 'navigationId',
parentIdField: 'parentId'
});
});
}
// 加载文章分类
if (!categoryList.value) {
listCmsArticleCategory({}).then((res) => {
categoryList.value = toTreeData({
data: res?.map((d) => {
d.value = d.categoryId;
d.label = d.title;
return d;
}),
idField: 'categoryId',
parentIdField: 'parentId'
});
});
}
watch(
() => router.currentRoute.value.query,
(query) => {
if (query) {
categoryId.value = Number(query.id);
const onRecommend = (row: CmsArticle) => {
updateCmsArticle({
...row,
recommend: row.recommend == 1 ? 0 : 1
}).then((msg) => {
message.success(msg);
reload();
});
};
/* 删除单个 */
const remove = (row: CmsArticle) => {
const hide = message.loading('请求中..', 0);
removeCmsArticle(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;
}
},
{immediate: true}
);
Modal.confirm({
title: '提示',
content: '确定要删除选中的记录吗?',
icon: createVNode(ExclamationCircleOutlined),
maskClosable: true,
onOk: () => {
const hide = message.loading('请求中..', 0);
removeBatchCmsArticle(selection.value.map((d) => d.articleId))
.then((msg) => {
hide();
message.success(msg);
reload();
})
.catch((e) => {
hide();
message.error(e.message);
});
}
});
};
/* 自定义行属性 */
const customRow = (record: CmsArticle) => {
return {
// 行点击事件
onClick: () => {
openEdit(record);
},
// 行双击事件
onDblclick: () => {
openEdit(record);
}
};
};
// 加载栏目数据
if (!navigationList.value) {
listCmsNavigation({}).then((res) => {
navigationList.value = toTreeData({
data: res?.map((d) => {
d.value = d.navigationId;
d.label = d.title;
if (!d.component) {
d.disabled = true;
}
if (
d.model == 'index' ||
d.model == 'page' ||
d.model == 'order' ||
d.model == 'links'
) {
d.disabled = true;
}
return d;
}),
idField: 'navigationId',
parentIdField: 'parentId'
});
});
}
// 加载文章分类
if (!categoryList.value) {
listCmsArticleCategory({}).then((res) => {
categoryList.value = toTreeData({
data: res?.map((d) => {
d.value = d.categoryId;
d.label = d.title;
return d;
}),
idField: 'categoryId',
parentIdField: 'parentId'
});
});
}
watch(
() => router.currentRoute.value.query,
(query) => {
if (query) {
categoryId.value = Number(query.id);
reload();
}
},
{ immediate: true }
);
</script>
<script lang="ts">
export default {
name: 'CmsArticleV2'
};
export default {
name: 'CmsArticleV2'
};
</script>

View File

@@ -1,70 +1,60 @@
<!-- 搜索表单 -->
<template>
<a-space style="flex-wrap: wrap" v-if="hasRole('superAdmin') || hasRole('admin') || hasRole('foundation')">
<a-button
type="text"
@click="openUrl('/website/photo')"
>图片
</a-button>
<a-button
type="text"
@click="openUrl('/website/video')"
>视频
</a-button>
<a-button
type="text"
@click="openUrl('/website/file')"
>文件
</a-button>
<a-space
style="flex-wrap: wrap"
v-if="hasRole('superAdmin') || hasRole('admin') || hasRole('foundation')"
>
<a-button type="text" @click="openUrl('/website/photo')">图片 </a-button>
<a-button type="text" @click="openUrl('/website/video')">视频 </a-button>
<a-button type="text" @click="openUrl('/website/file')">文件 </a-button>
</a-space>
</template>
<script lang="ts" setup>
import {watch,nextTick} from 'vue';
import {CmsWebsite} from '@/api/cms/cmsWebsite/model';
import {openUrl} from "@/utils/common";
import {message} from 'ant-design-vue';
import {removeSiteInfoCache} from "@/api/cms/cmsWebsite";
import {hasRole} from "@/utils/permission";
import { watch, nextTick } from 'vue';
import { CmsWebsite } from '@/api/cms/cmsWebsite/model';
import { openUrl } from '@/utils/common';
import { message } from 'ant-design-vue';
import { removeSiteInfoCache } from '@/api/cms/cmsWebsite';
import { hasRole } from '@/utils/permission';
const props = withDefaults(
defineProps<{
// 选中的角色
selection?: [];
website?: CmsWebsite;
count?: 0;
}>(),
{}
);
const props = withDefaults(
defineProps<{
// 选中的角色
selection?: [];
website?: CmsWebsite;
count?: 0;
}>(),
{}
);
const emit = defineEmits<{
(e: 'add'): void;
}>();
const emit = defineEmits<{
(e: 'add'): void;
}>();
const add = () => {
emit('add');
};
const add = () => {
emit('add');
};
// 清除缓存
const clearSiteInfoCache = () => {
removeSiteInfoCache('SiteInfo:' + localStorage.getItem('TenantId') + "*").then(
(msg) => {
// 清除缓存
const clearSiteInfoCache = () => {
removeSiteInfoCache(
'SiteInfo:' + localStorage.getItem('TenantId') + '*'
).then((msg) => {
if (msg) {
message.success(msg);
}
});
};
nextTick(() => {
if (localStorage.getItem('NotActive')) {
// IsActive.value = false
}
});
watch(
() => props.selection,
() => {}
);
};
nextTick(() => {
if(localStorage.getItem('NotActive')){
// IsActive.value = false
}
})
watch(
() => props.selection,
() => {
}
);
</script>

View File

@@ -115,7 +115,7 @@
import { RuleObject } from 'ant-design-vue/es/form';
import { copyText } from '@/utils/common';
import { DictData } from '@/api/system/dict-data/model';
import DictSelect from "@/components/DictSelect/index.vue";
import DictSelect from '@/components/DictSelect/index.vue';
// 是否开启响应式布局
const themeStore = useThemeStore();
@@ -219,7 +219,7 @@
const chooseGroupId = (item: DictData) => {
form.groupId = item.dictDataId;
form.groupName = item.dictDataName;
console.log(form,'>>>>>>>last')
console.log(form, '>>>>>>>last');
};
/* 保存编辑 */

View File

@@ -65,7 +65,7 @@
import useFormData from '@/utils/use-form-data';
import { addDictData, updateDictData } from '@/api/system/dict-data';
import { DictData } from '@/api/system/dict-data/model';
import { removeSiteInfoCache } from "@/api/cms/cmsWebsite";
import { removeSiteInfoCache } from '@/api/cms/cmsWebsite';
// 是否开启响应式布局
const themeStore = useThemeStore();

View File

@@ -13,7 +13,7 @@
>
<template #toolbar>
<a-space>
<a-button type="primary" class="ele-btn-icon" @click="openEdit()">
<a-button type="primary" class="ele-btn-icon" @click="openEdit()">
<template #icon>
<plus-outlined />
</template>

View File

@@ -11,7 +11,7 @@
>
<a-button key="1" type="primary" class="ele-btn-icon">
<template #icon>
<UploadOutlined/>
<UploadOutlined />
</template>
<span>上传图片</span>
</a-button>
@@ -31,9 +31,7 @@
style="width: 100px; margin: -5px -12px"
>
<a-select-option value="name">文件名称</a-select-option>
<a-select-option value="createNickname">
上传人
</a-select-option>
<a-select-option value="createNickname"> 上传人 </a-select-option>
</a-select>
</template>
</a-input-search>
@@ -46,7 +44,7 @@
/>
</a-space>
<template v-if="activeKey === '2'">
<Image :data="data" :where="where" @done="query"/>
<Image :data="data" :where="where" @done="query" />
<div class="ele-text-center" style="margin-top: 38px">
<a-pagination
:total="count"
@@ -59,118 +57,118 @@
</div>
</template>
<template v-if="activeKey === '1'">
<List :data="data" :where="where"/>
<List :data="data" :where="where" />
</template>
</a-page-header>
</template>
<script lang="ts" setup>
import {reactive, ref} from 'vue';
import {UploadOutlined} from '@ant-design/icons-vue';
import {FileRecord, FileRecordParam} from '@/api/system/file/model';
import Image from './image.vue';
import List from './list.vue';
import {messageLoading} from 'ele-admin-pro';
import {pageFiles, uploadFile} from '@/api/system/file';
import {message} from 'ant-design-vue/es';
import {DictData} from '@/api/system/dict-data/model';
import {getMerchantId} from "@/utils/merchant";
import {getPageTitle} from "@/utils/common";
import Extra from "./components/Extra.vue";
import { reactive, ref } from 'vue';
import { UploadOutlined } from '@ant-design/icons-vue';
import { FileRecord, FileRecordParam } from '@/api/system/file/model';
import Image from './image.vue';
import List from './list.vue';
import { messageLoading } from 'ele-admin-pro';
import { pageFiles, uploadFile } from '@/api/system/file';
import { message } from 'ant-design-vue/es';
import { DictData } from '@/api/system/dict-data/model';
import { getMerchantId } from '@/utils/merchant';
import { getPageTitle } from '@/utils/common';
import Extra from './components/Extra.vue';
const type = ref('name');
const searchText = ref('');
const data = ref<FileRecord[] | any>([]);
// 当前选项卡
const activeKey = ref('1');
// 第几页
const page = ref(1);
// 每页多少条
const limit = ref(12);
// 总数量
const count = ref(0);
// 搜索表单
const where = reactive<FileRecordParam>({
name: '',
createNickname: '',
groupId: undefined,
groupName: undefined
});
/* 搜索 */
const chooseGroupId = (item: DictData) => {
console.log(item);
where.groupId = item.dictDataId;
where.groupName = item.dictDataName;
query();
};
/* 查询数据 */
const query = () => {
console.log('query()');
if (type.value == 'name') {
where.name = searchText.value;
}
if (type.value == 'createNickname') {
where.createNickname = searchText.value;
}
where.page = page.value;
where.limit = limit.value;
where.merchantId = getMerchantId();
// where.contentType = 'image';
const hide = messageLoading('请求中..', 0);
pageFiles(where).then((res) => {
count.value = Number(res?.count);
data.value = res?.list;
hide();
const type = ref('name');
const searchText = ref('');
const data = ref<FileRecord[] | any>([]);
// 当前选项卡
const activeKey = ref('1');
// 第几页
const page = ref(1);
// 每页多少条
const limit = ref(12);
// 总数量
const count = ref(0);
// 搜索表单
const where = reactive<FileRecordParam>({
name: '',
createNickname: '',
groupId: undefined,
groupName: undefined
});
};
query();
/* 搜索 */
const chooseGroupId = (item: DictData) => {
console.log(item);
where.groupId = item.dictDataId;
where.groupName = item.dictDataName;
query();
};
// 上传文件
const onUpload = (item) => {
const {file} = item;
if (!file.type.startsWith('image')) {
message.error('只能选择图片');
return;
}
if (file.size / 1024 / 1024 > 10) {
message.error('大小不能超过 10MB');
return;
}
const hide = messageLoading({
content: '上传中..',
duration: 0,
mask: true
});
uploadFile(file)
.then((data) => {
hide();
message.success('上传成功');
query();
})
.catch((e) => {
message.error(e.message);
/* 查询数据 */
const query = () => {
console.log('query()');
if (type.value == 'name') {
where.name = searchText.value;
}
if (type.value == 'createNickname') {
where.createNickname = searchText.value;
}
where.page = page.value;
where.limit = limit.value;
where.merchantId = getMerchantId();
// where.contentType = 'image';
const hide = messageLoading('请求中..', 0);
pageFiles(where).then((res) => {
count.value = Number(res?.count);
data.value = res?.list;
hide();
});
};
};
query();
// 上传文件
const onUpload = (item) => {
const { file } = item;
if (!file.type.startsWith('image')) {
message.error('只能选择图片');
return;
}
if (file.size / 1024 / 1024 > 10) {
message.error('大小不能超过 10MB');
return;
}
const hide = messageLoading({
content: '上传中..',
duration: 0,
mask: true
});
uploadFile(file)
.then((data) => {
hide();
message.success('上传成功');
query();
})
.catch((e) => {
message.error(e.message);
hide();
});
};
</script>
<script lang="ts">
export default {
name: 'PhotoIndex'
};
export default {
name: 'PhotoIndex'
};
</script>
<style lang="less" scoped>
.project-list-desc {
height: 44px;
line-height: 22px;
margin-bottom: 20px;
overflow: hidden;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
}
.project-list-desc {
height: 44px;
line-height: 22px;
margin-bottom: 20px;
overflow: hidden;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
}
</style>

View File

@@ -20,7 +20,7 @@
:accept="'image/*,application/*'"
:customRequest="onUpload"
>
<a-button type="primary" class="ele-btn-icon">
<a-button type="primary" class="ele-btn-icon">
<template #icon>
<UploadOutlined />
</template>
@@ -56,10 +56,8 @@
@search="reload"
/>
<a-button type="text" @click="reset">重置</a-button>
<a-button
type="text"
@click="openUrl('/cms/photo/dict')"
>管理分组</a-button
<a-button type="text" @click="openUrl('/cms/photo/dict')"
>管理分组</a-button
>
</a-space>
</div>
@@ -92,12 +90,13 @@
</template>
</template>
<template v-if="column.dataIndex === 'name'">
<div>{{ record.name }}<copy-outlined
style="padding-left: 4px"
@click="copyText(record.downloadUrl)"
<div
>{{ record.name
}}<copy-outlined
style="padding-left: 4px"
@click="copyText(record.downloadUrl)"
/></div>
<div class="text-gray-400">{{ record.comments }}</div>
</template>
<template v-if="column.dataIndex === 'comments'">
<span @click="openEdit(record)">{{ record.comments }}</span>
@@ -145,14 +144,11 @@
removeFiles,
uploadOss
} from '@/api/system/file';
import type {
FileRecord,
FileRecordParam
} from '@/api/system/file/model';
import {copyText, isImage, openUrl} from '@/utils/common';
import type { FileRecord, FileRecordParam } from '@/api/system/file/model';
import { copyText, isImage, openUrl } from '@/utils/common';
import DictSelect from '@/components/DictSelect/index.vue';
import { getMerchantId } from '@/utils/merchant';
import useSearch from "@/utils/use-search";
import useSearch from '@/utils/use-search';
// 表格实例
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);

View File

@@ -48,7 +48,10 @@
import { FormInstance } from 'ant-design-vue/es/form';
import { CmsWebsiteField } from '@/api/cms/cmsWebsiteField/model';
import useFormData from '@/utils/use-form-data';
import { addCmsWebsiteField, updateCmsWebsiteField } from '@/api/cms/cmsWebsiteField';
import {
addCmsWebsiteField,
updateCmsWebsiteField
} from '@/api/cms/cmsWebsiteField';
import { message } from 'ant-design-vue/es';
import { removeSiteInfoCache } from '@/api/cms/CmsWebsite';
import { ItemType } from 'ele-admin-pro/es/ele-image-upload/types';

View File

@@ -23,7 +23,7 @@
>
<a-button type="primary" class="ele-btn-icon">
<template #icon>
<UploadOutlined/>
<UploadOutlined />
</template>
<span>上传视频</span>
</a-button>
@@ -36,7 +36,7 @@
@click="removeBatch"
>
<template #icon>
<delete-outlined/>
<delete-outlined />
</template>
<span>删除</span>
</a-button>
@@ -67,12 +67,12 @@
<div
class="video"
style="
background-color: #000000;
display: flex;
width: 160px;
height: 100px;
justify-content: center;
"
background-color: #000000;
display: flex;
width: 160px;
height: 100px;
justify-content: center;
"
>
<video
:src="`${record.path}`"
@@ -83,17 +83,19 @@
</a>
</template>
<template v-if="column.key === 'name'">
<div>{{ record.name }}<copy-outlined
style="padding-left: 4px"
@click="copyText(record.downloadUrl)"
<div
>{{ record.name
}}<copy-outlined
style="padding-left: 4px"
@click="copyText(record.downloadUrl)"
/></div>
</template>
<template v-if="column.key === 'action'">
<div>
<a :href="record.downloadUrl" target="_blank">下载</a>
<a-divider type="vertical"/>
<a-divider type="vertical" />
<a @click="openEdit(record)">修改</a>
<a-divider type="vertical"/>
<a-divider type="vertical" />
<a-popconfirm
placement="topRight"
title="确定要删除此评价吗?"
@@ -107,215 +109,216 @@
</ele-pro-table>
</a-card>
<!-- 编辑弹窗 -->
<video-edit v-model:visible="showEdit" :data="current" @done="reload"/>
<video-edit v-model:visible="showEdit" :data="current" @done="reload" />
</a-page-header>
</template>
<script lang="ts" setup>
import {createVNode, ref} from 'vue';
import {message, Modal} from 'ant-design-vue/es';
import {
UploadOutlined,
DeleteOutlined,
ExclamationCircleOutlined, CopyOutlined
} from '@ant-design/icons-vue';
import type {EleProTable} from 'ele-admin-pro/es';
import type {
DatasourceFunction,
ColumnItem
} from 'ele-admin-pro/es/ele-pro-table/types';
import {messageLoading, toDateString} from 'ele-admin-pro/es';
import VideoEdit from './components/video-edit.vue';
import {
pageFiles,
removeFile,
removeFiles,
uploadFile, uploadOss
} from '@/api/system/file/index';
import type {
FileRecord,
FileRecordParam
} from '@/api/system/file/model/index';
import {FILE_SERVER} from '@/config/setting';
import {copyText, getPageTitle} from "@/utils/common";
import Extra from "@/views/cms/photo/components/Extra.vue";
import { createVNode, ref } from 'vue';
import { message, Modal } from 'ant-design-vue/es';
import {
UploadOutlined,
DeleteOutlined,
ExclamationCircleOutlined,
CopyOutlined
} from '@ant-design/icons-vue';
import type { EleProTable } from 'ele-admin-pro/es';
import type {
DatasourceFunction,
ColumnItem
} from 'ele-admin-pro/es/ele-pro-table/types';
import { messageLoading, toDateString } from 'ele-admin-pro/es';
import VideoEdit from './components/video-edit.vue';
import {
pageFiles,
removeFile,
removeFiles,
uploadFile,
uploadOss
} from '@/api/system/file/index';
import type {
FileRecord,
FileRecordParam
} from '@/api/system/file/model/index';
import { FILE_SERVER } from '@/config/setting';
import { copyText, getPageTitle } from '@/utils/common';
import Extra from '@/views/cms/photo/components/Extra.vue';
// 表格实例
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
// 表格选中数据
const selection = ref<FileRecord[]>([]);
// 当前编辑数据
const current = ref<FileRecord | null>(null);
// 是否显示编辑弹窗
const showEdit = ref(false);
const type = ref('name');
const searchText = ref('');
// 表格列配置
const columns = ref<ColumnItem[]>([
{
key: 'index',
width: 48,
align: 'center',
fixed: 'left',
hideInSetting: true,
customRender: ({index}) => index + (tableRef.value?.tableIndex ?? 0)
},
{
title: '封面图',
dataIndex: 'path',
width: 180,
key: 'path'
},
{
title: '文件名称',
dataIndex: 'name',
key: 'name'
},
{
title: '描述',
dataIndex: 'comments',
ellipsis: true
},
{
title: '文件大小',
dataIndex: 'length',
sorter: true,
showSorterTooltip: false,
ellipsis: true,
customRender: ({text}) => {
if (text < 1024) {
return text + 'B';
} else if (text < 1024 * 1024) {
return (text / 1024).toFixed(1) + 'KB';
} else if (text < 1024 * 1024 * 1024) {
return (text / 1024 / 1024).toFixed(1) + 'M';
} else {
return (text / 1024 / 1024 / 1024).toFixed(1) + 'G';
}
// 表格实例
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
// 表格选中数据
const selection = ref<FileRecord[]>([]);
// 当前编辑数据
const current = ref<FileRecord | null>(null);
// 是否显示编辑弹窗
const showEdit = ref(false);
const type = ref('name');
const searchText = ref('');
// 表格列配置
const columns = ref<ColumnItem[]>([
{
key: 'index',
width: 48,
align: 'center',
fixed: 'left',
hideInSetting: true,
customRender: ({ index }) => index + (tableRef.value?.tableIndex ?? 0)
},
width: 120
},
{
title: '发布者',
width: 120,
dataIndex: 'createNickname'
},
{
title: '发布时间',
dataIndex: 'createTime',
sorter: true,
width: 180,
showSorterTooltip: false,
ellipsis: true,
customRender: ({text}) => toDateString(text)
},
{
title: '操作',
key: 'action',
width: 200,
align: 'center'
}
]);
// 表格数据源
const datasource: DatasourceFunction = ({page, limit, where, orders}) => {
where = {};
if (type.value == 'name') {
where.name = searchText.value;
}
if (type.value == 'createNickname') {
where.createNickname = searchText.value;
}
where.contentType = 'video';
return pageFiles({...where, ...orders, page, limit});
};
/* 搜索 */
const reload = (where?: FileRecordParam) => {
selection.value = [];
tableRef?.value?.reload({page: 1, where});
};
/* 打开编辑弹窗 */
const openEdit = (row?: FileRecord) => {
current.value = row ?? null;
showEdit.value = true;
};
/* 删除单个 */
const remove = (row: FileRecord) => {
const hide = messageLoading('请求中..', 0);
removeFile(row.id)
.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 = messageLoading('请求中..', 0);
removeFiles(selection.value.map((d) => d.id))
.then((msg) => {
hide();
message.success(msg);
reload();
})
.catch((e) => {
hide();
message.error(e.message);
});
{
title: '封面图',
dataIndex: 'path',
width: 180,
key: 'path'
},
{
title: '文件名称',
dataIndex: 'name',
key: 'name'
},
{
title: '描述',
dataIndex: 'comments',
ellipsis: true
},
{
title: '文件大小',
dataIndex: 'length',
sorter: true,
showSorterTooltip: false,
ellipsis: true,
customRender: ({ text }) => {
if (text < 1024) {
return text + 'B';
} else if (text < 1024 * 1024) {
return (text / 1024).toFixed(1) + 'KB';
} else if (text < 1024 * 1024 * 1024) {
return (text / 1024 / 1024).toFixed(1) + 'M';
} else {
return (text / 1024 / 1024 / 1024).toFixed(1) + 'G';
}
},
width: 120
},
{
title: '发布者',
width: 120,
dataIndex: 'createNickname'
},
{
title: '发布时间',
dataIndex: 'createTime',
sorter: true,
width: 180,
showSorterTooltip: false,
ellipsis: true,
customRender: ({ text }) => toDateString(text)
},
{
title: '操作',
key: 'action',
width: 200,
align: 'center'
}
});
};
]);
// 上传文件
const onUpload = (item) => {
const {file} = item;
if (!file.type.startsWith('video')) {
message.error('只能选择视频文件');
return;
}
if (file.size / 1024 / 1024 > 100) {
message.error('大小不能超过 100MB');
return;
}
const hide = messageLoading({
content: '上传中..',
duration: 0,
mask: true
});
uploadOss(file)
.then((data) => {
hide();
message.success('上传成功');
reload();
})
.catch((e) => {
message.error(e.message);
hide();
// 表格数据源
const datasource: DatasourceFunction = ({ page, limit, where, orders }) => {
where = {};
if (type.value == 'name') {
where.name = searchText.value;
}
if (type.value == 'createNickname') {
where.createNickname = searchText.value;
}
where.contentType = 'video';
return pageFiles({ ...where, ...orders, page, limit });
};
/* 搜索 */
const reload = (where?: FileRecordParam) => {
selection.value = [];
tableRef?.value?.reload({ page: 1, where });
};
/* 打开编辑弹窗 */
const openEdit = (row?: FileRecord) => {
current.value = row ?? null;
showEdit.value = true;
};
/* 删除单个 */
const remove = (row: FileRecord) => {
const hide = messageLoading('请求中..', 0);
removeFile(row.id)
.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 = messageLoading('请求中..', 0);
removeFiles(selection.value.map((d) => d.id))
.then((msg) => {
hide();
message.success(msg);
reload();
})
.catch((e) => {
hide();
message.error(e.message);
});
}
});
};
};
// 上传文件
const onUpload = (item) => {
const { file } = item;
if (!file.type.startsWith('video')) {
message.error('只能选择视频文件');
return;
}
if (file.size / 1024 / 1024 > 100) {
message.error('大小不能超过 100MB');
return;
}
const hide = messageLoading({
content: '上传中..',
duration: 0,
mask: true
});
uploadOss(file)
.then((data) => {
hide();
message.success('上传成功');
reload();
})
.catch((e) => {
message.error(e.message);
hide();
});
};
</script>
<script lang="ts">
export default {
name: 'VideoIndex'
};
export default {
name: 'VideoIndex'
};
</script>

View File

@@ -21,111 +21,105 @@
/>
</div>
<a-space direction="vertical" class="mt-5">
<div class="ele-text-secondary">
文件名称{{ form.name }}
</div>
<div class="ele-text-secondary">
文件路径{{ form.path }}
</div>
<div class="ele-text-secondary">
视频描述{{ form.comments }}
</div>
<div class="ele-text-secondary"> 文件名称{{ form.name }} </div>
<div class="ele-text-secondary"> 文件路径{{ form.path }} </div>
<div class="ele-text-secondary"> 视频描述{{ form.comments }} </div>
</a-space>
</a-card>
</a-page-header>
</template>
<script lang="ts" setup>
import {ref, reactive, watch, unref} from 'vue';
import Player from 'xgplayer';
import {useRouter} from 'vue-router';
import {toDateString} from 'ele-admin-pro';
import {setPageTabTitle} from '@/utils/page-tab-util';
import {message} from 'ant-design-vue/es';
import useFormData from '@/utils/use-form-data';
import {FileRecord} from '@/api/system/file/model';
import {getFile} from '@/api/system/file';
import { ref, reactive, watch, unref } from 'vue';
import Player from 'xgplayer';
import { useRouter } from 'vue-router';
import { toDateString } from 'ele-admin-pro';
import { setPageTabTitle } from '@/utils/page-tab-util';
import { message } from 'ant-design-vue/es';
import useFormData from '@/utils/use-form-data';
import { FileRecord } from '@/api/system/file/model';
import { getFile } from '@/api/system/file';
const {currentRoute} = useRouter();
import {getPageTitle} from "@/utils/common";
const { currentRoute } = useRouter();
import { getPageTitle } from '@/utils/common';
const ROUTE_PATH = '/cms/video/player';
const ROUTE_PATH = '/cms/video/player';
// 视频播放器一实例
let player1: Player;
// 视频播放器一是否实例化完成
const ready1 = ref(false);
// 视频播放器一实例
let player1: Player;
// 视频播放器一是否实例化完成
const ready1 = ref(false);
// 视频播放器一配置
const config1 = reactive({
id: 'demoPlayer1',
lang: 'zh-cn',
fluid: true,
// 视频地址
url: 'https://file.wsdns.cn/20221126/cf17ef352db54bf28efeda268107714f.mp4',
// 封面
poster:
'https://file.wsdns.cn/20221125/49f0c461d61e48f28b324366a0a63a2e.jpg',
// 开启倍速播放
playbackRate: [0.5, 1, 1.5, 2],
// 开启画中画
pip: true
});
/* 播放器一渲染完成 */
const onPlayer1 = (player: Player) => {
player1 = player;
player1.on('play', () => {
ready1.value = true;
// 视频播放器一配置
const config1 = reactive({
id: 'demoPlayer1',
lang: 'zh-cn',
fluid: true,
// 视频地址
url: 'https://file.wsdns.cn/20221126/cf17ef352db54bf28efeda268107714f.mp4',
// 封面
poster:
'https://file.wsdns.cn/20221125/49f0c461d61e48f28b324366a0a63a2e.jpg',
// 开启倍速播放
playbackRate: [0.5, 1, 1.5, 2],
// 开启画中画
pip: true
});
};
// 视频信息
const {form, assignFields} = useFormData<FileRecord>({
id: 0,
name: '',
url: '',
path: '',
comments: '',
createNickname: '',
createTime: ''
});
// 请求状态
const loading = ref(true);
/* */
const query = () => {
const {query} = unref(currentRoute);
const id = query.id;
if (!id || form.id === Number(id)) {
return;
}
loading.value = true;
getFile(Number(id))
.then((data) => {
loading.value = false;
assignFields({
...data,
createTime: toDateString(data.createTime)
});
// 修改页签标题
if (unref(currentRoute).path === ROUTE_PATH) {
setPageTabTitle(String(data.comments));
}
})
.catch((e) => {
loading.value = false;
message.error(e.message);
});
};
watch(
currentRoute,
(route) => {
const {path} = unref(route);
if (path !== ROUTE_PATH) {
/* 播放器一渲染完成 */
const onPlayer1 = (player: Player) => {
player1 = player;
player1.on('play', () => {
ready1.value = true;
});
};
// 视频信息
const { form, assignFields } = useFormData<FileRecord>({
id: 0,
name: '',
url: '',
path: '',
comments: '',
createNickname: '',
createTime: ''
});
// 请求状态
const loading = ref(true);
/* */
const query = () => {
const { query } = unref(currentRoute);
const id = query.id;
if (!id || form.id === Number(id)) {
return;
}
query();
},
{immediate: true}
);
loading.value = true;
getFile(Number(id))
.then((data) => {
loading.value = false;
assignFields({
...data,
createTime: toDateString(data.createTime)
});
// 修改页签标题
if (unref(currentRoute).path === ROUTE_PATH) {
setPageTabTitle(String(data.comments));
}
})
.catch((e) => {
loading.value = false;
message.error(e.message);
});
};
watch(
currentRoute,
(route) => {
const { path } = unref(route);
if (path !== ROUTE_PATH) {
return;
}
query();
},
{ immediate: true }
);
</script>