新增:批量删除菜单功能和复制菜单功能
This commit is contained in:
@@ -23,7 +23,6 @@
|
||||
<template v-if="column.key === 'domain'">
|
||||
<a
|
||||
v-if="record.status == 1"
|
||||
class="ele-text-success"
|
||||
@click="openUrl(`https://${record.domain}`)"
|
||||
>{{ record.domain }}</a
|
||||
>
|
||||
@@ -34,6 +33,10 @@
|
||||
</a-space>
|
||||
</span>
|
||||
</template>
|
||||
<template v-if="column.key === 'type'">
|
||||
<a-tag color="orange" v-if="record.type === 1">系统</a-tag>
|
||||
<a-tag v-if="record.type === 0">自定义</a-tag>
|
||||
</template>
|
||||
<template v-if="column.key === 'hostName'">
|
||||
<span class="ele-text-placeholder">{{ record.hostName }}</span>
|
||||
</template>
|
||||
@@ -54,10 +57,10 @@
|
||||
@click="openEdit(record)"
|
||||
>验证中</a-tag
|
||||
>
|
||||
<a-tag v-if="record.status === 1" color="green">绑定成功</a-tag>
|
||||
<a-tag v-if="record.status === 1" color="green">已生效</a-tag>
|
||||
</template>
|
||||
<template v-if="column.key === 'action'">
|
||||
<a-space>
|
||||
<a-space v-if="record.type === 0">
|
||||
<a-button @click="openEdit(record)" size="small">管理</a-button>
|
||||
<a-popconfirm
|
||||
title="确定要删除此域名吗?"
|
||||
@@ -137,6 +140,12 @@
|
||||
width: 240,
|
||||
key: 'domain'
|
||||
},
|
||||
{
|
||||
title: '类型',
|
||||
dataIndex: 'type',
|
||||
align: 'center',
|
||||
key: 'type'
|
||||
},
|
||||
{
|
||||
title: '主机记录',
|
||||
dataIndex: 'hostName',
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
<a-col
|
||||
v-bind="styleResponsive ? { md: 12, sm: 24, xs: 24 } : { span: 12 }"
|
||||
>
|
||||
{{ form.parentId }}
|
||||
<a-form-item label="上级分类" name="parentId">
|
||||
<a-tree-select
|
||||
allow-clear
|
||||
@@ -45,7 +44,7 @@
|
||||
<a-form-item
|
||||
:label="form.type == 9 ? '链接地址' : '路由地址'"
|
||||
name="path"
|
||||
v-if="isUpdate"
|
||||
v-if="isUpdate || form.model == 'links'"
|
||||
>
|
||||
<a-input
|
||||
allow-clear
|
||||
@@ -56,15 +55,18 @@
|
||||
@pressEnter="save"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="组件路径" name="component" v-if="isUpdate">
|
||||
<a-input
|
||||
allow-clear
|
||||
placeholder="/pages/product/detail.vue"
|
||||
v-model:value="form.component"
|
||||
disabled
|
||||
@pressEnter="save"
|
||||
/>
|
||||
</a-form-item>
|
||||
<!-- <a-form-item-->
|
||||
<!-- label="组件路径"-->
|
||||
<!-- name="component"-->
|
||||
<!-- v-if="isUpdate"-->
|
||||
<!-- >-->
|
||||
<!-- <a-input-->
|
||||
<!-- allow-clear-->
|
||||
<!-- placeholder="/pages/product/detail.vue"-->
|
||||
<!-- v-model:value="form.component"-->
|
||||
<!-- @pressEnter="save"-->
|
||||
<!-- />-->
|
||||
<!-- </a-form-item>-->
|
||||
<a-form-item label="css样式" name="style" v-if="isUpdate">
|
||||
<a-input
|
||||
allow-clear
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
v-model:value="form.websiteName"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="访问地址" name="domain">
|
||||
<a-form-item label="二级域名" name="websiteCode">
|
||||
<a-input
|
||||
v-model:value="form.websiteCode"
|
||||
placeholder="huawei"
|
||||
@@ -43,6 +43,13 @@
|
||||
addon-after=".wsdns.cn"
|
||||
/>
|
||||
</a-form-item>
|
||||
<!-- <a-form-item label="顶级域名" name="domain" v-if="form.websiteCode">-->
|
||||
<!-- <a-input-->
|
||||
<!-- v-model:value="form.domain"-->
|
||||
<!-- placeholder="huawei.com"-->
|
||||
<!-- addon-before="https://"-->
|
||||
<!-- />-->
|
||||
<!-- </a-form-item>-->
|
||||
<a-form-item label="网站描述" name="comments">
|
||||
<a-textarea
|
||||
:rows="4"
|
||||
@@ -139,6 +146,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 { addDomain } from '@/api/cms/domain';
|
||||
|
||||
// 是否是修改
|
||||
const isUpdate = ref(false);
|
||||
@@ -228,14 +236,14 @@
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
domain: [
|
||||
{
|
||||
required: true,
|
||||
type: 'string',
|
||||
message: '请填写网站域名',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
// domain: [
|
||||
// {
|
||||
// required: true,
|
||||
// type: 'string',
|
||||
// message: '请填写网站域名',
|
||||
// trigger: 'blur'
|
||||
// }
|
||||
// ],
|
||||
adminUrl: [
|
||||
{
|
||||
required: true,
|
||||
@@ -308,7 +316,7 @@
|
||||
loading.value = false;
|
||||
message.success(msg);
|
||||
updateVisible(false);
|
||||
localStorage.setItem('Domain', `${form.prefix}${form.domain}`);
|
||||
localStorage.setItem('Domain', `${form.websiteCode}.wsdns.cn`);
|
||||
emit('done');
|
||||
})
|
||||
.catch((e) => {
|
||||
|
||||
@@ -26,6 +26,19 @@
|
||||
<a-image :src="record.websiteLogo" :width="50" />
|
||||
</template>
|
||||
<template v-if="column.key === 'domain'">
|
||||
<!-- <a-button-->
|
||||
<!-- type="link"-->
|
||||
<!-- v-if="record.domain"-->
|
||||
<!-- @click="-->
|
||||
<!-- openSpmUrl(-->
|
||||
<!-- `https://${record.domain}`,-->
|
||||
<!-- record,-->
|
||||
<!-- record.websiteId-->
|
||||
<!-- )-->
|
||||
<!-- "-->
|
||||
<!-- >-->
|
||||
<!-- {{ record.domain }}-->
|
||||
<!-- </a-button>-->
|
||||
<a-button
|
||||
type="link"
|
||||
@click="
|
||||
@@ -36,7 +49,7 @@
|
||||
)
|
||||
"
|
||||
>
|
||||
{{ record.websiteCode }}.wsdns.cn
|
||||
{{ record.websiteCode ? `${record.websiteCode}.wsdns.cn` : '' }}
|
||||
</a-button>
|
||||
</template>
|
||||
<template v-if="column.key === 'type'">
|
||||
|
||||
52
src/views/oa/website/components/search.vue
Normal file
52
src/views/oa/website/components/search.vue
Normal file
@@ -0,0 +1,52 @@
|
||||
<!-- 搜索表单 -->
|
||||
<template>
|
||||
<a-space :size="10" style="flex-wrap: wrap">
|
||||
<a-input-search
|
||||
allow-clear
|
||||
v-model:value="where.keywords"
|
||||
placeholder="网站名称|租户ID"
|
||||
@search="search"
|
||||
@pressEnter="search"
|
||||
/>
|
||||
</a-space>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { watch } from 'vue';
|
||||
import useSearch from '@/utils/use-search';
|
||||
import { WebsiteParam } from '@/api/system/website/model';
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
// 选中的角色
|
||||
selection?: [];
|
||||
count?: 0;
|
||||
}>(),
|
||||
{}
|
||||
);
|
||||
|
||||
// 表单数据
|
||||
const { where } = useSearch<WebsiteParam>({
|
||||
keywords: ''
|
||||
});
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'search', where?: WebsiteParam): void;
|
||||
(e: 'add'): void;
|
||||
(e: 'remove'): void;
|
||||
}>();
|
||||
|
||||
const add = () => {
|
||||
emit('add');
|
||||
};
|
||||
|
||||
/* 搜索 */
|
||||
const search = () => {
|
||||
emit('search', where);
|
||||
};
|
||||
|
||||
watch(
|
||||
() => props.selection,
|
||||
() => {}
|
||||
);
|
||||
</script>
|
||||
346
src/views/oa/website/components/websiteEdit.vue
Normal file
346
src/views/oa/website/components/websiteEdit.vue
Normal file
@@ -0,0 +1,346 @@
|
||||
<!-- 编辑弹窗 -->
|
||||
<template>
|
||||
<ele-modal
|
||||
:width="800"
|
||||
:visible="visible"
|
||||
:maskClosable="false"
|
||||
:maxable="maxable"
|
||||
:title="isUpdate ? '编辑网站信息' : '添加网站信息'"
|
||||
:body-style="{ paddingBottom: '28px' }"
|
||||
@update:visible="updateVisible"
|
||||
@ok="save"
|
||||
>
|
||||
<a-form
|
||||
ref="formRef"
|
||||
:model="form"
|
||||
:rules="rules"
|
||||
:label-col="styleResponsive ? { md: 4, sm: 5, xs: 24 } : { flex: '90px' }"
|
||||
:wrapper-col="
|
||||
styleResponsive ? { md: 19, sm: 19, xs: 24 } : { flex: '1' }
|
||||
"
|
||||
>
|
||||
<a-form-item label="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">
|
||||
<a-input
|
||||
v-model:value="form.domain"
|
||||
placeholder="websoft.top"
|
||||
addon-before="https://"
|
||||
/>
|
||||
</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="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="全局样式(Tailwind CSS风格)"
|
||||
v-model:value="form.style"
|
||||
/>
|
||||
</a-form-item>
|
||||
<!-- <a-form-item label="访问域名" name="domain">-->
|
||||
<!-- <a-input-->
|
||||
<!-- v-model:value="form.domain"-->
|
||||
<!-- placeholder="websoft.top"-->
|
||||
<!-- addon-before="https://"-->
|
||||
<!-- addon-after="websoft.top"-->
|
||||
<!-- />-->
|
||||
<!-- </a-form-item>-->
|
||||
<!-- <a-form-item label="后台管理" name="adminUrl">-->
|
||||
<!-- <a-input v-model:value="form.adminUrl" placeholder="admin.domain.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="ICP备案号" name="icpNo">-->
|
||||
<!-- <a-input-->
|
||||
<!-- allow-clear-->
|
||||
<!-- placeholder="请输入网站备案"-->
|
||||
<!-- v-model:value="form.icpNo"-->
|
||||
<!-- />-->
|
||||
<!-- </a-form-item>-->
|
||||
<!-- <a-form-item label="网站类型" name="websiteType">-->
|
||||
<!-- <a-select-->
|
||||
<!-- :options="websiteType"-->
|
||||
<!-- :value="form.websiteType"-->
|
||||
<!-- placeholder="请选择主体类型"-->
|
||||
<!-- @change="onWebsiteType"-->
|
||||
<!-- />-->
|
||||
<!-- </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="status">
|
||||
<a-radio-group
|
||||
v-model:value="form.status"
|
||||
:disabled="form.status && form.status > 3"
|
||||
>
|
||||
<a-radio :value="1">运行中</a-radio>
|
||||
<a-radio :value="2">维护中</a-radio>
|
||||
<a-radio :value="3">已关闭</a-radio>
|
||||
</a-radio-group>
|
||||
</a-form-item>
|
||||
<a-form-item v-if="form.status == 2" label="维护说明" name="statusText">
|
||||
<a-textarea
|
||||
:rows="4"
|
||||
:maxlength="200"
|
||||
placeholder="状态说明"
|
||||
v-model:value="form.statusText"
|
||||
/>
|
||||
</a-form-item>
|
||||
<!-- <a-divider style="margin-bottom: 24px" />-->
|
||||
</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, SelectProps } from 'ele-admin-pro';
|
||||
import { addWebsite, updateWebsite } from '@/api/system/website';
|
||||
import { Website } from '@/api/system/website/model';
|
||||
import { useThemeStore } from '@/store/modules/theme';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { ItemType } from 'ele-admin-pro/es/ele-image-upload/types';
|
||||
import { FormInstance } from 'ant-design-vue/es/form';
|
||||
import { FileRecord } from '@/api/system/file/model';
|
||||
|
||||
// 是否是修改
|
||||
const isUpdate = ref(false);
|
||||
const useForm = Form.useForm;
|
||||
// 是否开启响应式布局
|
||||
const themeStore = useThemeStore();
|
||||
const { styleResponsive } = storeToRefs(themeStore);
|
||||
|
||||
const props = defineProps<{
|
||||
// 弹窗是否打开
|
||||
visible: boolean;
|
||||
// 修改回显的数据
|
||||
data?: Website | 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 form = reactive<Website>({
|
||||
websiteId: undefined,
|
||||
websiteLogo: undefined,
|
||||
websiteName: undefined,
|
||||
websiteCode: undefined,
|
||||
keywords: '',
|
||||
prefix: '',
|
||||
domain: '',
|
||||
adminUrl: '',
|
||||
style: '',
|
||||
icpNo: undefined,
|
||||
email: undefined,
|
||||
version: undefined,
|
||||
websiteType: '',
|
||||
expirationTime: undefined,
|
||||
sortNumber: undefined,
|
||||
comments: undefined,
|
||||
status: undefined,
|
||||
statusText: undefined
|
||||
});
|
||||
|
||||
const websiteType = ref<SelectProps['options']>([
|
||||
{
|
||||
value: '企业官网',
|
||||
label: '企业官网'
|
||||
},
|
||||
{
|
||||
value: '门户网站',
|
||||
label: '门户网站'
|
||||
},
|
||||
{
|
||||
value: '电子商城',
|
||||
label: '电子商城'
|
||||
}
|
||||
]);
|
||||
|
||||
/* 更新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'
|
||||
}
|
||||
],
|
||||
domain: [
|
||||
{
|
||||
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 onDeleteItem = (index: number) => {
|
||||
images.value.splice(index, 1);
|
||||
form.websiteLogo = '';
|
||||
};
|
||||
|
||||
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 formData = {
|
||||
...form
|
||||
};
|
||||
const saveOrUpdate = isUpdate.value ? updateWebsite : addWebsite;
|
||||
saveOrUpdate(formData)
|
||||
.then((msg) => {
|
||||
loading.value = false;
|
||||
message.success(msg);
|
||||
updateVisible(false);
|
||||
localStorage.setItem('Domain', `${form.prefix}${form.domain}`);
|
||||
emit('done');
|
||||
})
|
||||
.catch((e) => {
|
||||
loading.value = false;
|
||||
message.error(e.message);
|
||||
});
|
||||
})
|
||||
.catch(() => {});
|
||||
};
|
||||
|
||||
watch(
|
||||
() => props.visible,
|
||||
(visible) => {
|
||||
if (visible) {
|
||||
images.value = [];
|
||||
websiteQrcode.value = [];
|
||||
if (props.data) {
|
||||
assignObject(form, props.data);
|
||||
if (props.data.websiteLogo) {
|
||||
images.value.push({
|
||||
uid: uuid(),
|
||||
url: props.data.websiteLogo,
|
||||
status: 'done'
|
||||
});
|
||||
}
|
||||
isUpdate.value = true;
|
||||
} else {
|
||||
isUpdate.value = false;
|
||||
}
|
||||
} else {
|
||||
resetFields();
|
||||
}
|
||||
},
|
||||
{ immediate: true }
|
||||
);
|
||||
</script>
|
||||
291
src/views/oa/website/index.vue
Normal file
291
src/views/oa/website/index.vue
Normal file
@@ -0,0 +1,291 @@
|
||||
<template>
|
||||
<div class="page">
|
||||
<div class="ele-body">
|
||||
<a-card :bordered="false" :body-style="{ padding: '16px' }">
|
||||
<ele-pro-table
|
||||
ref="tableRef"
|
||||
row-key="websiteId"
|
||||
: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 === 'websiteLogo'">
|
||||
<a-image :src="record.websiteLogo" :width="50" />
|
||||
</template>
|
||||
<template v-if="column.key === 'domain'">
|
||||
<a-button
|
||||
type="link"
|
||||
v-if="record.domain"
|
||||
@click="
|
||||
openSpmUrl(
|
||||
`https://${record.domain}`,
|
||||
record,
|
||||
record.websiteId
|
||||
)
|
||||
"
|
||||
>
|
||||
{{ record.domain }}
|
||||
</a-button>
|
||||
</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'">
|
||||
<text v-if="record.version === 10">免费版</text>
|
||||
<text v-if="record.version === 20">授权版</text>
|
||||
<text v-if="record.version === 30">永久授权</text>
|
||||
</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>
|
||||
<a-tag v-if="record.status === 2" color="orange">维护中</a-tag>
|
||||
<a-tag v-if="record.status === 3" color="red">已关闭</a-tag>
|
||||
<a-tag v-if="record.status === 4" color="red">已欠费停机</a-tag>
|
||||
<a-tag v-if="record.status === 5" color="red">违规关停</a-tag>
|
||||
</template>
|
||||
<template v-if="column.key === 'action'">
|
||||
<a-space>
|
||||
<a @click="openEdit(record)">编辑</a>
|
||||
</a-space>
|
||||
</template>
|
||||
</template>
|
||||
</ele-pro-table>
|
||||
</a-card>
|
||||
|
||||
<!-- 编辑弹窗 -->
|
||||
<WebsiteEdit v-model:visible="showEdit" :data="current" @done="reload" />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { createVNode, ref } from 'vue';
|
||||
import { message, Modal } from 'ant-design-vue';
|
||||
import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
|
||||
import type { EleProTable } from 'ele-admin-pro';
|
||||
import { toDateString } from 'ele-admin-pro';
|
||||
import type {
|
||||
DatasourceFunction,
|
||||
ColumnItem
|
||||
} from 'ele-admin-pro/es/ele-pro-table/types';
|
||||
import Search from './components/search.vue';
|
||||
import WebsiteEdit from './components/websiteEdit.vue';
|
||||
import {
|
||||
pageWebsite,
|
||||
removeWebsite,
|
||||
removeBatchWebsite,
|
||||
updateWebsite
|
||||
} from '@/api/system/website';
|
||||
import type { Website, WebsiteParam } from '@/api/system/website/model';
|
||||
import { openPreview, openSpmUrl, openUrl } from '@/utils/common';
|
||||
import { getSiteDomain } from '@/utils/domain';
|
||||
|
||||
// 表格实例
|
||||
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
|
||||
|
||||
// 表格选中数据
|
||||
const selection = ref<Website[]>([]);
|
||||
// 当前编辑数据
|
||||
const current = ref<Website | null>(null);
|
||||
// 是否显示编辑弹窗
|
||||
const showEdit = ref(false);
|
||||
// 是否显示批量移动弹窗
|
||||
const showMove = ref(false);
|
||||
// 加载状态
|
||||
const loading = ref(true);
|
||||
const domain = getSiteDomain();
|
||||
|
||||
// 表格数据源
|
||||
const datasource: DatasourceFunction = ({
|
||||
page,
|
||||
limit,
|
||||
where,
|
||||
orders,
|
||||
filters
|
||||
}) => {
|
||||
if (filters) {
|
||||
where.status = filters.status;
|
||||
}
|
||||
return pageWebsite({
|
||||
...where,
|
||||
...orders,
|
||||
page,
|
||||
limit
|
||||
});
|
||||
};
|
||||
|
||||
// 表格列配置
|
||||
const columns = ref<ColumnItem[]>([
|
||||
{
|
||||
title: 'ID',
|
||||
dataIndex: 'tenantId',
|
||||
key: 'tenantId',
|
||||
width: 90
|
||||
},
|
||||
{
|
||||
title: '网站名称',
|
||||
dataIndex: 'websiteName',
|
||||
key: 'websiteName',
|
||||
align: 'center'
|
||||
},
|
||||
{
|
||||
title: 'Logo',
|
||||
dataIndex: 'websiteLogo',
|
||||
key: 'websiteLogo',
|
||||
align: 'center'
|
||||
},
|
||||
{
|
||||
title: '域名',
|
||||
dataIndex: 'domain',
|
||||
key: 'domain',
|
||||
align: 'center'
|
||||
},
|
||||
{
|
||||
title: '网站描述',
|
||||
dataIndex: 'comments',
|
||||
key: 'comments',
|
||||
align: 'center'
|
||||
},
|
||||
{
|
||||
title: '当前版本',
|
||||
dataIndex: 'version',
|
||||
key: 'version',
|
||||
align: 'center'
|
||||
},
|
||||
{
|
||||
title: '状态',
|
||||
dataIndex: 'status',
|
||||
key: 'status',
|
||||
align: 'center'
|
||||
},
|
||||
{
|
||||
title: '创建时间',
|
||||
dataIndex: 'createTime',
|
||||
key: 'createTime',
|
||||
align: 'center',
|
||||
sorter: true,
|
||||
ellipsis: true,
|
||||
customRender: ({ text }) => toDateString(text, 'yyyy-MM-dd')
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
key: 'action',
|
||||
width: 120,
|
||||
fixed: 'right',
|
||||
align: 'center',
|
||||
hideInSetting: true
|
||||
}
|
||||
]);
|
||||
|
||||
/* 搜索 */
|
||||
const reload = (where?: WebsiteParam) => {
|
||||
selection.value = [];
|
||||
tableRef?.value?.reload({ where: where });
|
||||
};
|
||||
|
||||
/* 打开编辑弹窗 */
|
||||
const openEdit = (row?: Website) => {
|
||||
current.value = row ?? null;
|
||||
showEdit.value = true;
|
||||
};
|
||||
|
||||
/* 打开批量移动弹窗 */
|
||||
const openMove = () => {
|
||||
showMove.value = true;
|
||||
};
|
||||
|
||||
const updateType = (row: Website) => {
|
||||
updateWebsite(row).then((msg) => {
|
||||
message.success(msg);
|
||||
reload();
|
||||
});
|
||||
};
|
||||
|
||||
/* 删除单个 */
|
||||
const remove = (row: Website) => {
|
||||
const hide = message.loading('请求中..', 0);
|
||||
removeWebsite(row.websiteId)
|
||||
.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);
|
||||
removeBatchWebsite(selection.value.map((d) => d.websiteId))
|
||||
.then((msg) => {
|
||||
hide();
|
||||
message.success(msg);
|
||||
reload();
|
||||
})
|
||||
.catch((e) => {
|
||||
hide();
|
||||
message.error(e.message);
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/* 查询 */
|
||||
const query = () => {
|
||||
loading.value = true;
|
||||
};
|
||||
|
||||
/* 自定义行属性 */
|
||||
const customRow = (record: Website) => {
|
||||
return {
|
||||
// 行点击事件
|
||||
onClick: () => {
|
||||
// console.log(record);
|
||||
},
|
||||
// 行双击事件
|
||||
onDblclick: () => {
|
||||
openEdit(record);
|
||||
}
|
||||
};
|
||||
};
|
||||
query();
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
export default {
|
||||
name: 'Website'
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped></style>
|
||||
@@ -26,7 +26,11 @@
|
||||
<template v-if="column.key === 'goodsName'">
|
||||
<a
|
||||
@click="
|
||||
openSpmUrl(`/product/${record.goodsId}.html`, record, record.goodsId)
|
||||
openSpmUrl(
|
||||
`/product/detail/${record.goodsId}`,
|
||||
record,
|
||||
record.goodsId
|
||||
)
|
||||
"
|
||||
>{{ record.goodsName }}</a
|
||||
>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<!-- 编辑弹窗 -->
|
||||
<template>
|
||||
<ele-modal
|
||||
:width="540"
|
||||
:width="550"
|
||||
:visible="visible"
|
||||
:confirm-loading="loading"
|
||||
:title="`菜单克隆`"
|
||||
@@ -15,11 +15,28 @@
|
||||
:rules="rules"
|
||||
:label-col="styleResponsive ? { md: 5, sm: 4, xs: 24 } : { flex: '90px' }"
|
||||
:wrapper-col="
|
||||
styleResponsive ? { md: 18, sm: 20, xs: 24 } : { flex: '1' }
|
||||
styleResponsive ? { md: 17, sm: 20, xs: 24 } : { flex: '1' }
|
||||
"
|
||||
>
|
||||
<a-form-item label="选择模板" name="tenantName">
|
||||
<SelectTenant v-model:value="tenantName" @done="onPromoter" />
|
||||
<a-form-item label="操作说明" name="readme">
|
||||
<a-alert
|
||||
description="本功能可以实现一键复制A系统的菜单到B系统的菜单,复制成功后会作为顶级目录出现在B系统的菜单功能上(注意:还需要手动给角色勾选权限才能使用)。菜单ID可以在A系统的菜单管理->修改菜单->是否展示的后面获取。"
|
||||
type="warning"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="菜单ID" name="menuId">
|
||||
<a-input
|
||||
allow-clear
|
||||
placeholder="请输入菜单ID"
|
||||
v-model:value="form.menuId"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="租户ID" name="tenantId">
|
||||
<a-input
|
||||
allow-clear
|
||||
placeholder="请输入租户ID"
|
||||
v-model:value="form.tenantId"
|
||||
/>
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
</ele-modal>
|
||||
@@ -79,10 +96,18 @@
|
||||
|
||||
// 表单验证规则
|
||||
const rules = reactive<Record<string, Rule[]>>({
|
||||
tenantName: [
|
||||
tenantId: [
|
||||
{
|
||||
required: true,
|
||||
message: '请选择要克隆的模版',
|
||||
message: '请选择要复制的租户ID',
|
||||
type: 'string',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
menuId: [
|
||||
{
|
||||
required: true,
|
||||
message: '请选择要复制的菜单ID',
|
||||
type: 'string',
|
||||
trigger: 'blur'
|
||||
}
|
||||
|
||||
175
src/views/system/menu/components/delete.vue
Normal file
175
src/views/system/menu/components/delete.vue
Normal file
@@ -0,0 +1,175 @@
|
||||
<!-- 编辑弹窗 -->
|
||||
<template>
|
||||
<ele-modal
|
||||
:width="550"
|
||||
:visible="visible"
|
||||
:confirm-loading="loading"
|
||||
:title="`批量删除菜单`"
|
||||
:body-style="{ paddingBottom: '8px' }"
|
||||
@update:visible="updateVisible"
|
||||
@ok="save"
|
||||
>
|
||||
<a-form
|
||||
ref="formRef"
|
||||
:model="form"
|
||||
:rules="rules"
|
||||
:label-col="styleResponsive ? { md: 5, sm: 4, xs: 24 } : { flex: '90px' }"
|
||||
:wrapper-col="
|
||||
styleResponsive ? { md: 17, sm: 20, xs: 24 } : { flex: '1' }
|
||||
"
|
||||
>
|
||||
<a-form-item label="操作说明" name="readme">
|
||||
<a-alert
|
||||
description="批量删除顶级菜单目录下的所有子菜单(菜单ID可以在菜单管理->修改菜单->是否展示的后面获取)"
|
||||
type="warning"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="菜单ID" name="menuId">
|
||||
<a-input
|
||||
allow-clear
|
||||
placeholder="请输入菜单ID"
|
||||
v-model:value="form.menuId"
|
||||
/>
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
</ele-modal>
|
||||
</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 { isExternalLink } from 'ele-admin-pro/es';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { useThemeStore } from '@/store/modules/theme';
|
||||
import useFormData from '@/utils/use-form-data';
|
||||
import { deleteParentMenu } from '@/api/system/menu';
|
||||
import type { Menu } from '@/api/system/menu/model';
|
||||
|
||||
// 是否开启响应式布局
|
||||
const themeStore = useThemeStore();
|
||||
const { styleResponsive } = storeToRefs(themeStore);
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'done'): void;
|
||||
(e: 'update:visible', visible: boolean): void;
|
||||
}>();
|
||||
|
||||
const props = defineProps<{
|
||||
// 弹窗是否打开
|
||||
visible: boolean;
|
||||
// 修改回显的数据
|
||||
data?: Menu | null;
|
||||
// 上级菜单id
|
||||
parentId?: number;
|
||||
// 全部菜单数据
|
||||
menuList: Menu[];
|
||||
}>();
|
||||
|
||||
//
|
||||
const formRef = ref<FormInstance | null>(null);
|
||||
|
||||
// 是否是修改
|
||||
const isUpdate = ref(false);
|
||||
|
||||
// 提交状态
|
||||
const loading = ref(false);
|
||||
|
||||
// 表单数据
|
||||
const { form, resetFields, assignFields } = useFormData<Menu>({
|
||||
title: '',
|
||||
icon: '',
|
||||
path: '',
|
||||
component: '',
|
||||
tenantId: undefined,
|
||||
tenantName: ''
|
||||
});
|
||||
|
||||
// 表单验证规则
|
||||
const rules = reactive<Record<string, Rule[]>>({
|
||||
menuId: [
|
||||
{
|
||||
required: true,
|
||||
message: '请顶级菜单ID,将删除栏目下的所有子菜单',
|
||||
type: 'string',
|
||||
trigger: 'blur'
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
/* 保存编辑 */
|
||||
const save = () => {
|
||||
if (!formRef.value) {
|
||||
return;
|
||||
}
|
||||
formRef.value
|
||||
.validate()
|
||||
.then(() => {
|
||||
loading.value = true;
|
||||
deleteParentMenu(form.menuId).then((msg) => {
|
||||
message.success(msg);
|
||||
emit('done');
|
||||
loading.value = false;
|
||||
updateVisible(false);
|
||||
});
|
||||
})
|
||||
.catch(() => {});
|
||||
};
|
||||
|
||||
/* 更新visible */
|
||||
const updateVisible = (value: boolean) => {
|
||||
emit('update:visible', value);
|
||||
};
|
||||
|
||||
/* 判断是否是目录 */
|
||||
const isDirectory = (d: Menu) => {
|
||||
return !!d.children?.length && !d.component;
|
||||
};
|
||||
|
||||
watch(
|
||||
() => props.visible,
|
||||
(visible) => {
|
||||
if (visible) {
|
||||
if (props.data) {
|
||||
const isExternal = isExternalLink(props.data.path);
|
||||
const isInner = isExternalLink(props.data.component);
|
||||
// menuType 对应的值与后端不一致在前端处理
|
||||
const menuType =
|
||||
props.data.menuType === 1 ? 2 : isDirectory(props.data) ? 0 : 1;
|
||||
assignFields({
|
||||
...props.data,
|
||||
menuType,
|
||||
openType: isExternal ? 2 : isInner ? 1 : 0,
|
||||
parentId:
|
||||
props.data.parentId === 0 ? undefined : props.data.parentId
|
||||
});
|
||||
isUpdate.value = true;
|
||||
} else {
|
||||
form.parentId = props.parentId;
|
||||
isUpdate.value = false;
|
||||
}
|
||||
} else {
|
||||
resetFields();
|
||||
formRef.value?.clearValidate();
|
||||
}
|
||||
}
|
||||
);
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
import * as icons from '@/layout/menu-icons';
|
||||
|
||||
export default {
|
||||
components: icons,
|
||||
data() {
|
||||
return {
|
||||
iconData: [
|
||||
{
|
||||
title: '已引入的图标',
|
||||
icons: Object.keys(icons)
|
||||
}
|
||||
]
|
||||
};
|
||||
}
|
||||
};
|
||||
</script>
|
||||
@@ -184,20 +184,25 @@
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="是否展示">
|
||||
<a-switch
|
||||
checked-children="是"
|
||||
un-checked-children="否"
|
||||
:checked="form.hide === 0"
|
||||
:disabled="form.menuType === 2"
|
||||
@update:checked="updateHideValue"
|
||||
/>
|
||||
<a-tooltip
|
||||
title="选择不展示只注册路由不展示在侧边栏, 比如添加页面应该选择不展示"
|
||||
>
|
||||
<question-circle-outlined
|
||||
style="vertical-align: -4px; margin-left: 16px"
|
||||
/>
|
||||
</a-tooltip>
|
||||
<div class="flex justify-between">
|
||||
<div class="left">
|
||||
<a-switch
|
||||
checked-children="是"
|
||||
un-checked-children="否"
|
||||
:checked="form.hide === 0"
|
||||
:disabled="form.menuType === 2"
|
||||
@update:checked="updateHideValue"
|
||||
/>
|
||||
<a-tooltip
|
||||
title="选择不展示只注册路由不展示在侧边栏, 比如添加页面应该选择不展示"
|
||||
>
|
||||
<question-circle-outlined
|
||||
style="vertical-align: -4px; margin-left: 16px"
|
||||
/>
|
||||
</a-tooltip>
|
||||
</div>
|
||||
<a-tag>菜单ID:{{ form.menuId }}</a-tag>
|
||||
</div>
|
||||
</a-form-item>
|
||||
<a-form-item
|
||||
label="选择节点"
|
||||
|
||||
@@ -33,6 +33,9 @@
|
||||
<a-button type="dashed" class="ele-btn-icon" @click="foldAll">
|
||||
折叠全部
|
||||
</a-button>
|
||||
<a-button type="dashed" class="ele-btn-icon" @click="removeBatch">
|
||||
批量删除
|
||||
</a-button>
|
||||
<a-button type="dashed" class="ele-btn-icon" @click="cloneMenu">
|
||||
一键克隆
|
||||
</a-button>
|
||||
@@ -127,7 +130,8 @@
|
||||
:menu-list="menuData"
|
||||
@done="reload"
|
||||
/>
|
||||
<clone v-model:visible="showClone" @done="reload" />
|
||||
<Delete v-model:visible="showRemoveBatch" @done="reload" />
|
||||
<Clone v-model:visible="showClone" @done="reload" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -151,6 +155,7 @@
|
||||
import type { EleProTable } from 'ele-admin-pro/es';
|
||||
import MenuEdit from './components/menu-edit.vue';
|
||||
import MenuPlug from './components/menu-plug.vue';
|
||||
import Delete from './components/delete.vue';
|
||||
import Clone from './components/clone.vue';
|
||||
import { listMenus, removeMenu } from '@/api/system/menu';
|
||||
import type { Menu, MenuParam } from '@/api/system/menu/model';
|
||||
@@ -248,6 +253,7 @@
|
||||
const showEdit = ref(false);
|
||||
const showPlug = ref(false);
|
||||
const showClone = ref(false);
|
||||
const showRemoveBatch = ref(false);
|
||||
const token = ref(localStorage.getItem(TOKEN_STORE_NAME));
|
||||
|
||||
// 上级菜单id
|
||||
@@ -297,6 +303,10 @@
|
||||
showPlug.value = true;
|
||||
};
|
||||
|
||||
const removeBatch = () => {
|
||||
showRemoveBatch.value = true;
|
||||
};
|
||||
|
||||
/* 一键克隆 */
|
||||
const cloneMenu = (row?: Menu | null, id?: number) => {
|
||||
current.value = row ?? null;
|
||||
|
||||
@@ -381,8 +381,8 @@ const chooseFile = (data: FileRecord) => {
|
||||
url: data.thumbnail,
|
||||
status: "done"
|
||||
});
|
||||
form.companyLogo = data.thumbnail;
|
||||
updateCompany(form).then(res => {
|
||||
form.companyLogo = data.path;
|
||||
updateCompany(form).then(() => {
|
||||
message.success("上传成功");
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user