chore(config): 初始化项目配置文件
- 添加 .editorconfig 文件统一代码风格 - 配置 .env.development 环境变量文件 - 创建 .env.example 环境变量示例文件 - 设置 .eslintignore 忽略检查规则 - 配置 .eslintrc.js 代码检查规则 - 添加 .gitignore 文件忽略版本控制 - 设置 .prettierignore 忽略格式化规则 - 新增隐私政策HTML页面文件 - 创建API密钥编辑组件基础结构
This commit is contained in:
71
src/views/cms/cmsWebsite/components/search.vue
Normal file
71
src/views/cms/cmsWebsite/components/search.vue
Normal file
@@ -0,0 +1,71 @@
|
||||
<!-- 搜索表单 -->
|
||||
<template>
|
||||
<a-space style="flex-wrap: wrap">
|
||||
<a-button type="text" @click="openUrl(`/website/field`)"
|
||||
>字段扩展
|
||||
</a-button>
|
||||
<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/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';
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
// 选中的角色
|
||||
selection?: [];
|
||||
website?: CmsWebsite;
|
||||
count?: 0;
|
||||
}>(),
|
||||
{}
|
||||
);
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'add'): void;
|
||||
}>();
|
||||
|
||||
const add = () => {
|
||||
emit('add');
|
||||
};
|
||||
|
||||
// 清除缓存
|
||||
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,
|
||||
() => {}
|
||||
);
|
||||
</script>
|
||||
418
src/views/cms/cmsWebsite/components/websiteEdit.vue
Normal file
418
src/views/cms/cmsWebsite/components/websiteEdit.vue
Normal file
@@ -0,0 +1,418 @@
|
||||
<!-- 编辑弹窗 -->
|
||||
<template>
|
||||
<ele-modal
|
||||
:width="800"
|
||||
:visible="visible"
|
||||
:maskClosable="false"
|
||||
:maxable="maxable"
|
||||
:title="isUpdate ? '编辑小程序' : '创建小程序'"
|
||||
:body-style="{ paddingBottom: '28px' }"
|
||||
@update:visible="updateVisible"
|
||||
:confirm-loading="loading"
|
||||
@ok="save"
|
||||
>
|
||||
<a-form
|
||||
ref="formRef"
|
||||
:model="form"
|
||||
:rules="rules"
|
||||
:label-col="styleResponsive ? { md: 4, sm: 5, xs: 24 } : { flex: '90px' }"
|
||||
:wrapper-col="
|
||||
styleResponsive ? { md: 19, sm: 19, xs: 24 } : { flex: '1' }
|
||||
"
|
||||
>
|
||||
<a-form-item label="LOGO" name="avatar">
|
||||
<SelectFile
|
||||
:placeholder="`请选择图片`"
|
||||
:limit="1"
|
||||
:data="images"
|
||||
@done="chooseImage"
|
||||
@del="onDeleteItem"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="小程序名称" name="websiteName">
|
||||
<a-input
|
||||
allow-clear
|
||||
placeholder="请输入小程序名称"
|
||||
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"
|
||||
>
|
||||
<template #addonBefore>
|
||||
<a-select v-model:value="form.prefix" style="width: 90px">
|
||||
<a-select-option value="http://">http://</a-select-option>
|
||||
<a-select-option value="https://">https://</a-select-option>
|
||||
</a-select>
|
||||
</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="小程序描述" name="comments">
|
||||
<a-textarea
|
||||
:rows="4"
|
||||
:maxlength="200"
|
||||
placeholder="请输入小程序描述"
|
||||
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="小程序码" name="avatar">
|
||||
<SelectFile
|
||||
:placeholder="`请选择图片`"
|
||||
:limit="1"
|
||||
:data="websiteQrcode"
|
||||
@done="chooseQrcode"
|
||||
@del="onDeleteQrcode"
|
||||
/>
|
||||
</a-form-item>
|
||||
<!-- <a-form-item label="SEO关键词" name="keywords">-->
|
||||
<!-- <a-textarea-->
|
||||
<!-- :rows="4"-->
|
||||
<!-- :maxlength="200"-->
|
||||
<!-- placeholder="请输入SEO关键词"-->
|
||||
<!-- v-model:value="form.keywords"-->
|
||||
<!-- />-->
|
||||
<!-- </a-form-item>-->
|
||||
<!-- <a-form-item label="全局样式" name="style">-->
|
||||
<!-- <a-textarea-->
|
||||
<!-- :rows="4"-->
|
||||
<!-- :maxlength="200"-->
|
||||
<!-- placeholder="全局样式"-->
|
||||
<!-- v-model:value="form.style"-->
|
||||
<!-- />-->
|
||||
<!-- </a-form-item>-->
|
||||
<!-- <a-form-item label="小程序类型" name="websiteType">-->
|
||||
<!-- <a-select-->
|
||||
<!-- :options="websiteType"-->
|
||||
<!-- :value="form.websiteType"-->
|
||||
<!-- placeholder="请选择主体类型"-->
|
||||
<!-- @change="onCmsWebsiteType"-->
|
||||
<!-- />-->
|
||||
<!-- </a-form-item>-->
|
||||
<!-- <a-form-item label="当前版本" name="version">-->
|
||||
<!-- <a-tag color="red" v-if="form.version === 10">标准版</a-tag>-->
|
||||
<!-- <a-tag color="green" v-if="form.version === 20">专业版</a-tag>-->
|
||||
<!-- <a-tag color="cyan" v-if="form.version === 30">永久授权</a-tag>-->
|
||||
<!-- </a-form-item>-->
|
||||
<a-form-item label="状态" name="running">
|
||||
<a-radio-group
|
||||
v-model:value="form.running"
|
||||
:disabled="form.running == 4 || form.running == 5"
|
||||
>
|
||||
<a-radio :value="1">运行中</a-radio>
|
||||
<a-radio :value="2">维护中</a-radio>
|
||||
<a-radio :value="3">已关闭</a-radio>
|
||||
</a-radio-group>
|
||||
</a-form-item>
|
||||
<a-form-item v-if="form.running == 2" label="维护说明" name="statusText">
|
||||
<a-textarea
|
||||
:rows="4"
|
||||
:maxlength="200"
|
||||
placeholder="状态说明"
|
||||
v-model:value="form.statusText"
|
||||
/>
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
</ele-modal>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import {ref, reactive, watch} from 'vue';
|
||||
import {Form, message} from 'ant-design-vue';
|
||||
import {assignObject, uuid} from 'ele-admin-pro';
|
||||
import {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 props = defineProps<{
|
||||
// 弹窗是否打开
|
||||
visible: boolean;
|
||||
// 修改回显的数据
|
||||
data?: CmsWebsite | null;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'done'): void;
|
||||
(e: 'update:visible', visible: boolean): void;
|
||||
}>();
|
||||
|
||||
// 提交状态
|
||||
const loading = ref(false);
|
||||
// 是否显示最大化切换按钮
|
||||
const maxable = ref(true);
|
||||
// 表格选中数据
|
||||
const formRef = ref<FormInstance | null>(null);
|
||||
const images = ref<ItemType[]>([]);
|
||||
const 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'
|
||||
});
|
||||
form.websiteLogo = data.downloadUrl;
|
||||
};
|
||||
|
||||
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;
|
||||
}
|
||||
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>
|
||||
320
src/views/cms/cmsWebsite/index.vue
Normal file
320
src/views/cms/cmsWebsite/index.vue
Normal file
@@ -0,0 +1,320 @@
|
||||
<template>
|
||||
<a-page-header :title="getPageTitle()" @back="() => $router.go(-1)">
|
||||
<template #extra>
|
||||
<CmsWebsiteSearch/>
|
||||
</template>
|
||||
<a-spin :spinning="loading" class="page">
|
||||
<a-card :bordered="false" :body-style="{ padding: '16px' }">
|
||||
<ele-pro-table
|
||||
ref="tableRef"
|
||||
row-key="websiteId"
|
||||
:columns="columns"
|
||||
:datasource="datasource"
|
||||
:parse-data="parseData"
|
||||
:customRow="customRow"
|
||||
:need-page="false"
|
||||
:toolbar="false"
|
||||
tool-class="ele-toolbar-form"
|
||||
class="sys-org-table"
|
||||
>
|
||||
<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"/>
|
||||
</template>
|
||||
<template v-if="column.key === 'websiteName'">
|
||||
<div class="font-medium">{{ record.websiteName }}</div>
|
||||
</template>
|
||||
<template v-if="column.key === 'websiteCode'">
|
||||
<div class="text-gray-400">{{ record.tenantId }}</div>
|
||||
<div class="text-gray-400">
|
||||
{{ record.websiteCode }}
|
||||
</div>
|
||||
</template>
|
||||
<template v-if="column.key === 'domain'">
|
||||
<a-space direction="vertical">
|
||||
<a
|
||||
v-if="record.domain"
|
||||
:href="`${record.prefix}${record.domain}`"
|
||||
class="text-gray-500 hover:text-blue-500"
|
||||
target="_blank"
|
||||
>
|
||||
{{ record.domain }}
|
||||
</a>
|
||||
</a-space>
|
||||
</template>
|
||||
<template v-if="column.key === 'type'">
|
||||
<a-tag v-if="record.type === 1" color="green">是</a-tag>
|
||||
<a-tag
|
||||
v-if="record.type === 0"
|
||||
@click="updateType(record)"
|
||||
class="cursor-pointer"
|
||||
>否
|
||||
</a-tag
|
||||
>
|
||||
</template>
|
||||
<template v-if="column.key === 'version'">
|
||||
<span v-if="record.version === 10">基础版</span>
|
||||
<span v-if="record.version === 20">专业版</span>
|
||||
<span v-if="record.version === 30">永久授权</span>
|
||||
</template>
|
||||
<template v-if="column.key === 'status'">
|
||||
<a-tag v-if="record.running === 0" color="red">未开通</a-tag>
|
||||
<a-tag v-if="record.running === 1" color="green">运行中</a-tag>
|
||||
<a-tag v-if="record.running === 2" color="orange">维护中</a-tag>
|
||||
<a-tag v-if="record.running === 3" color="red">已关闭</a-tag>
|
||||
<a-tag v-if="record.running === 4" color="red">已欠费停机</a-tag>
|
||||
<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>
|
||||
</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>
|
||||
</template>
|
||||
<template v-if="column.key === 'action'">
|
||||
<!-- <a @click="onShare(record)" class="text-green-600">-->
|
||||
<!-- <QrcodeOutlined />-->
|
||||
<!-- 二维码-->
|
||||
<!-- </a>-->
|
||||
<!-- <a-divider type="vertical"/>-->
|
||||
<a @click="openEdit(record)">
|
||||
编辑
|
||||
</a>
|
||||
</template>
|
||||
</template>
|
||||
<template #emptyText>
|
||||
<a-empty
|
||||
:image-style="{
|
||||
height: '240px',
|
||||
}"
|
||||
>
|
||||
<template #description>
|
||||
<span>
|
||||
欢迎使用本产品,请先创建站点并完成初始化。
|
||||
</span>
|
||||
</template>
|
||||
<div class="pb-10">
|
||||
<a-button type="primary" @click="openEdit">立即创建</a-button>
|
||||
</div>
|
||||
</a-empty>
|
||||
</template>
|
||||
</ele-pro-table>
|
||||
</a-card>
|
||||
|
||||
<!-- 编辑弹窗 -->
|
||||
<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";
|
||||
|
||||
// 表格实例
|
||||
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 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);
|
||||
},
|
||||
// 行双击事件
|
||||
onDblclick: () => {
|
||||
openEdit(record);
|
||||
}
|
||||
};
|
||||
};
|
||||
query();
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
export default {
|
||||
name: 'CmsWebsite'
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped></style>
|
||||
Reference in New Issue
Block a user