mirror of
https://github.com/bufanyun/hotgo.git
synced 2025-11-15 05:33:47 +08:00
更新2.1.2版本,优化部门、角色权限,增加上下级关系;增加登录、系统、短信日志;优化省市区编码
This commit is contained in:
@@ -30,7 +30,7 @@
|
||||
<PlusOutlined />
|
||||
</n-icon>
|
||||
</template>
|
||||
新建
|
||||
添加策略
|
||||
</n-button>
|
||||
|
||||
<n-button type="error" @click="batchDelete" :disabled="batchDeleteDisabled">
|
||||
@@ -48,7 +48,7 @@
|
||||
v-model:show="showModal"
|
||||
:show-icon="false"
|
||||
preset="dialog"
|
||||
title="新建"
|
||||
:title="formParams?.id > 0 ? '编辑策略 #' + formParams.id : '添加策略'"
|
||||
style="width: 720px"
|
||||
>
|
||||
<n-form
|
||||
@@ -59,8 +59,8 @@
|
||||
:label-width="80"
|
||||
class="py-4"
|
||||
>
|
||||
<n-form-item label="IP地址" path="ip">
|
||||
<n-input type="textarea" placeholder="请输入IP地址" v-model:value="formParams.ip" />
|
||||
<n-form-item label="IP策略" path="ip">
|
||||
<n-input type="textarea" placeholder="请输入IP策略" v-model:value="formParams.ip" />
|
||||
<template #feedback>
|
||||
<p>支持添加IP:如果添加多个IP请用","隔开</p>
|
||||
<p>支持添加IP段,如:192.168.0.0/24</p>
|
||||
@@ -72,7 +72,7 @@
|
||||
<n-form-item label="状态" path="status">
|
||||
<n-radio-group v-model:value="formParams.status" name="status">
|
||||
<n-radio-button
|
||||
v-for="status in statusOptions"
|
||||
v-for="status in blacklistOptions"
|
||||
:key="status.value"
|
||||
:value="status.value"
|
||||
:label="status.label"
|
||||
@@ -107,8 +107,23 @@
|
||||
import { Dict } from '@/api/dict/dict';
|
||||
import { getOptionLabel, getOptionTag } from '@/utils/hotgo';
|
||||
|
||||
const blacklistOptions = [
|
||||
{
|
||||
value: 1,
|
||||
label: '封禁中',
|
||||
listClass: 'warning',
|
||||
},
|
||||
{
|
||||
value: 2,
|
||||
label: '已解封',
|
||||
listClass: 'success',
|
||||
},
|
||||
].map((s) => {
|
||||
return s;
|
||||
});
|
||||
|
||||
const options = ref({
|
||||
status: [],
|
||||
status: blacklistOptions,
|
||||
});
|
||||
|
||||
const columns = [
|
||||
@@ -185,7 +200,7 @@
|
||||
defaultValue: null,
|
||||
componentProps: {
|
||||
placeholder: '请选择类型',
|
||||
options: [],
|
||||
options: blacklistOptions,
|
||||
onUpdateValue: (e: any) => {
|
||||
console.log(e);
|
||||
},
|
||||
@@ -350,19 +365,6 @@
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
async function loadOptions() {
|
||||
options.value.status = await Dict('sys_normal_disable');
|
||||
for (const item of schemas.value) {
|
||||
if (item.field === 'status') {
|
||||
item.componentProps.options = options.value.status;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
await loadOptions();
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped></style>
|
||||
|
||||
@@ -35,13 +35,10 @@
|
||||
<n-input v-model:value="formValue.smtpAdminMailbox" placeholder="" />
|
||||
</n-form-item>
|
||||
|
||||
<n-form-item>
|
||||
<n-button size="small" type="default" @click="sendTest">发送测试邮件</n-button>
|
||||
</n-form-item>
|
||||
|
||||
<div>
|
||||
<n-space>
|
||||
<n-button type="primary" @click="formSubmit">保存更新</n-button>
|
||||
<n-button type="default" @click="sendTest">发送测试邮件</n-button>
|
||||
</n-space>
|
||||
</div>
|
||||
</n-form>
|
||||
@@ -118,11 +115,9 @@
|
||||
formBtnLoading.value = true;
|
||||
formRef.value.validate((errors) => {
|
||||
if (!errors) {
|
||||
console.log('formParams:' + JSON.stringify(formParams.value));
|
||||
|
||||
showModal.value = false;
|
||||
sendTestEmail(formParams.value).then((_res) => {
|
||||
message.success('发送成功');
|
||||
showModal.value = false;
|
||||
});
|
||||
} else {
|
||||
message.error('请填写完整信息');
|
||||
@@ -139,8 +134,6 @@
|
||||
function formSubmit() {
|
||||
formRef.value.validate((errors) => {
|
||||
if (!errors) {
|
||||
console.log('formValue.value:' + JSON.stringify(formValue.value));
|
||||
|
||||
updateConfig({ group: group.value, list: formValue.value })
|
||||
.then((res) => {
|
||||
console.log('res:' + JSON.stringify(res));
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
<n-form-item label="默认驱动" path="smsDrive">
|
||||
<n-select
|
||||
placeholder="默认发送驱动"
|
||||
:options="driveList"
|
||||
:options="options.config_sms_drive"
|
||||
v-model:value="formValue.smsDrive"
|
||||
/>
|
||||
</n-form-item>
|
||||
@@ -39,11 +39,7 @@
|
||||
|
||||
<n-divider title-placement="left">阿里云</n-divider>
|
||||
<n-form-item label="AccessKeyID" path="smsAliyunAccessKeyID">
|
||||
<n-input
|
||||
v-model:value="formValue.smsAliyunAccessKeyID"
|
||||
placeholder=""
|
||||
type="password"
|
||||
/>
|
||||
<n-input v-model:value="formValue.smsAliyunAccessKeyID" placeholder="" />
|
||||
<template #feedback
|
||||
>应用key和密钥你可以通过 https://ram.console.aliyun.com/manage/ak 获取</template
|
||||
>
|
||||
@@ -53,8 +49,15 @@
|
||||
<n-input
|
||||
type="password"
|
||||
v-model:value="formValue.smsAliyunAccessKeySecret"
|
||||
placeholder=""
|
||||
/>
|
||||
show-password-on="click"
|
||||
>
|
||||
<template #password-visible-icon>
|
||||
<n-icon :size="16" :component="GlassesOutline" />
|
||||
</template>
|
||||
<template #password-invisible-icon>
|
||||
<n-icon :size="16" :component="Glasses" />
|
||||
</template>
|
||||
</n-input>
|
||||
</n-form-item>
|
||||
|
||||
<n-form-item label="签名" path="smsAliyunSign">
|
||||
@@ -68,7 +71,7 @@
|
||||
<n-dynamic-input
|
||||
v-model:value="formValue.smsAliyunTemplate"
|
||||
preset="pair"
|
||||
key-placeholder="key"
|
||||
key-placeholder="事件KEY"
|
||||
value-placeholder="模板CODE"
|
||||
/>
|
||||
</n-form-item>
|
||||
@@ -76,22 +79,74 @@
|
||||
<div>
|
||||
<n-space>
|
||||
<n-button type="primary" @click="formSubmit">保存更新</n-button>
|
||||
<n-button type="default" @click="sendTest">发送测试短信</n-button>
|
||||
</n-space>
|
||||
</div>
|
||||
</n-form>
|
||||
</n-grid-item>
|
||||
</n-grid>
|
||||
</n-spin>
|
||||
|
||||
<n-modal
|
||||
:block-scroll="false"
|
||||
:mask-closable="false"
|
||||
v-model:show="showModal"
|
||||
:show-icon="false"
|
||||
preset="dialog"
|
||||
title="发送测试短信"
|
||||
>
|
||||
<n-form
|
||||
:model="formParams"
|
||||
:rules="rules"
|
||||
ref="formTestRef"
|
||||
label-placement="left"
|
||||
:label-width="80"
|
||||
class="py-4"
|
||||
>
|
||||
<n-form-item label="事件模板" path="event">
|
||||
<n-select :options="options.config_sms_template" v-model:value="formParams.event" />
|
||||
</n-form-item>
|
||||
|
||||
<n-form-item label="手机号" path="mobile">
|
||||
<n-input
|
||||
placeholder="请输入接收手机号"
|
||||
v-model:value="formParams.mobile"
|
||||
:required="true"
|
||||
/>
|
||||
</n-form-item>
|
||||
|
||||
<n-form-item label="验证码" path="code">
|
||||
<n-input
|
||||
placeholder="请输入要接收的验证码"
|
||||
v-model:value="formParams.code"
|
||||
:required="true"
|
||||
/>
|
||||
</n-form-item>
|
||||
</n-form>
|
||||
|
||||
<template #action>
|
||||
<n-space>
|
||||
<n-button @click="() => (showModal = false)">关闭</n-button>
|
||||
<n-button type="info" :loading="formBtnLoading" @click="confirmForm">发送</n-button>
|
||||
</n-space>
|
||||
</template>
|
||||
</n-modal>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, onMounted } from 'vue';
|
||||
import { useMessage } from 'naive-ui';
|
||||
import { getConfig, updateConfig } from '@/api/sys/config';
|
||||
import { getConfig, sendTestSms, updateConfig } from '@/api/sys/config';
|
||||
import { Dicts } from '@/api/dict/dict';
|
||||
import { Options } from '@/utils/hotgo';
|
||||
import { GlassesOutline, Glasses } from '@vicons/ionicons5';
|
||||
|
||||
const group = ref('sms');
|
||||
const show = ref(false);
|
||||
const showModal = ref(false);
|
||||
const formBtnLoading = ref(false);
|
||||
const formParams = ref({ mobile: '', event: '', code: '1234' });
|
||||
|
||||
const rules = {
|
||||
smsDrive: {
|
||||
@@ -101,19 +156,15 @@
|
||||
},
|
||||
};
|
||||
|
||||
const driveList = [
|
||||
{
|
||||
label: '阿里云',
|
||||
value: 'aliyun',
|
||||
},
|
||||
{
|
||||
label: '腾讯云',
|
||||
value: 'tencent',
|
||||
},
|
||||
];
|
||||
const formTestRef = ref<any>();
|
||||
const formRef: any = ref(null);
|
||||
const message = useMessage();
|
||||
|
||||
const options = ref<Options>({
|
||||
config_sms_template: [],
|
||||
config_sms_drive: [],
|
||||
});
|
||||
|
||||
const formValue = ref({
|
||||
smsDrive: 'aliyun',
|
||||
smsAliyunAccessKeyID: '',
|
||||
@@ -125,6 +176,11 @@
|
||||
smsCodeExpire: 600,
|
||||
});
|
||||
|
||||
function sendTest() {
|
||||
showModal.value = true;
|
||||
formBtnLoading.value = false;
|
||||
}
|
||||
|
||||
function formSubmit() {
|
||||
formRef.value.validate((errors) => {
|
||||
if (!errors) {
|
||||
@@ -149,8 +205,9 @@
|
||||
load();
|
||||
});
|
||||
|
||||
function load() {
|
||||
async function load() {
|
||||
show.value = true;
|
||||
await loadOptions();
|
||||
new Promise((_resolve, _reject) => {
|
||||
getConfig({ group: group.value })
|
||||
.then((res) => {
|
||||
@@ -164,4 +221,26 @@
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
async function loadOptions() {
|
||||
options.value = await Dicts({
|
||||
types: ['config_sms_template', 'config_sms_drive'],
|
||||
});
|
||||
}
|
||||
|
||||
function confirmForm(e) {
|
||||
e.preventDefault();
|
||||
formBtnLoading.value = true;
|
||||
formTestRef.value.validate((errors) => {
|
||||
if (!errors) {
|
||||
sendTestSms(formParams.value).then((_res) => {
|
||||
message.success('发送成功');
|
||||
showModal.value = false;
|
||||
});
|
||||
} else {
|
||||
message.error('请填写完整信息');
|
||||
}
|
||||
formBtnLoading.value = false;
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
<PlusOutlined />
|
||||
</n-icon>
|
||||
</template>
|
||||
新建
|
||||
添加任务
|
||||
</n-button>
|
||||
|
||||
<n-button type="error" @click="batchDelete" :disabled="batchDeleteDisabled">
|
||||
@@ -57,7 +57,7 @@
|
||||
v-model:show="showModal"
|
||||
:show-icon="false"
|
||||
preset="dialog"
|
||||
title="新建"
|
||||
:title="formParams?.id > 0 ? '编辑任务 #' + formParams.id : '添加任务'"
|
||||
style="width: 720px"
|
||||
>
|
||||
<n-form
|
||||
@@ -100,9 +100,8 @@
|
||||
</n-radio-group>
|
||||
</n-form-item>
|
||||
|
||||
<n-form-item label="执行次数" path="count">
|
||||
<n-form-item label="执行次数" path="count" v-if="formParams.policy === 4">
|
||||
<n-input placeholder="请输入执行次数" v-model:value="formParams.count" />
|
||||
<template #feedback> 仅在单次、多次策略时生效</template>
|
||||
</n-form-item>
|
||||
|
||||
<n-form-item label="定时表达式" path="pattern">
|
||||
@@ -154,7 +153,7 @@
|
||||
import { TreeSelectOption, useDialog, useMessage } from 'naive-ui';
|
||||
import { BasicTable, TableAction } from '@/components/Table';
|
||||
import { BasicForm, FormSchema, useForm } from '@/components/Form/index';
|
||||
import { Delete, Edit, getSelect, List, Status } from '@/api/sys/cron';
|
||||
import { Delete, Edit, getSelect, List, Status, OnlineExec } from '@/api/sys/cron';
|
||||
import { columns } from './columns';
|
||||
import { DeleteOutlined, GroupOutlined, PlusOutlined } from '@vicons/antd';
|
||||
import { statusActions } from '@/enums/optionsiEnum';
|
||||
@@ -369,8 +368,21 @@
|
||||
}
|
||||
|
||||
function handleExecute(record: Recordable) {
|
||||
console.log('点击了handleExecute', record);
|
||||
message.error('暂未配置');
|
||||
dialog.warning({
|
||||
title: '警告',
|
||||
content: '提交成功后将立即执行一次,你确定要执行吗?',
|
||||
positiveText: '确定',
|
||||
negativeText: '取消',
|
||||
onPositiveClick: () => {
|
||||
OnlineExec(record).then((_res) => {
|
||||
message.success('提交成功,执行结果请登录控制台查看日志!');
|
||||
reloadTable();
|
||||
});
|
||||
},
|
||||
onNegativeClick: () => {
|
||||
// message.error('取消');
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
function handleDelete(record: Recordable) {
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
<PlusOutlined />
|
||||
</n-icon>
|
||||
</template>
|
||||
新建分组
|
||||
添加分组
|
||||
</n-button>
|
||||
</template>
|
||||
</BasicTable>
|
||||
@@ -82,7 +82,7 @@
|
||||
import { BasicTable, TableAction } from '@/components/Table';
|
||||
import { columns } from './columns';
|
||||
import { PlusOutlined } from '@vicons/antd';
|
||||
import { GroupDelete, GroupEdit, GroupList, getSelect } from '@/api/sys/cron';
|
||||
import { GroupDelete, GroupEdit, GroupList, getSelect } from '@/api/sys/cron';
|
||||
import { statusOptions } from '@/enums/optionsiEnum';
|
||||
|
||||
const optionTreeData = ref([]);
|
||||
@@ -96,7 +96,7 @@
|
||||
remark: '',
|
||||
status: statusValue.value,
|
||||
});
|
||||
const modalTitle = ref('新建分组');
|
||||
const modalTitle = ref('添加分组');
|
||||
const showModal = ref(false);
|
||||
const formBtnLoading = ref(false);
|
||||
const rules = {
|
||||
@@ -109,7 +109,7 @@
|
||||
|
||||
function addTable() {
|
||||
showModal.value = true;
|
||||
modalTitle.value = '新建分组';
|
||||
modalTitle.value = '添加分组';
|
||||
formParams.value = defaultValueRef();
|
||||
}
|
||||
|
||||
@@ -179,11 +179,10 @@
|
||||
positiveText: '确定',
|
||||
negativeText: '取消',
|
||||
onPositiveClick: () => {
|
||||
GroupDelete(record)
|
||||
.then((_res) => {
|
||||
message.success('操作成功');
|
||||
reloadTable();
|
||||
});
|
||||
GroupDelete(record).then((_res) => {
|
||||
message.success('操作成功');
|
||||
reloadTable();
|
||||
});
|
||||
},
|
||||
onNegativeClick: () => {
|
||||
// message.error('取消');
|
||||
|
||||
@@ -58,7 +58,7 @@
|
||||
</n-space>
|
||||
</template>
|
||||
<div class="w-full menu">
|
||||
<n-input type="input" v-model:value="pattern" placeholder="输入菜单名称搜索">
|
||||
<n-input type="input" v-model:value="pattern" placeholder="输入字典名称搜索">
|
||||
<template #suffix>
|
||||
<n-icon size="18" class="cursor-pointer">
|
||||
<SearchOutlined />
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
<PlusOutlined />
|
||||
</n-icon>
|
||||
</template>
|
||||
新建
|
||||
添加数据
|
||||
</n-button>
|
||||
</template>
|
||||
</BasicTable>
|
||||
@@ -32,7 +32,7 @@
|
||||
v-model:show="showModal"
|
||||
:show-icon="false"
|
||||
preset="dialog"
|
||||
:title="formParams?.id > 0 ? '编辑' : '新建'"
|
||||
:title="formParams?.id > 0 ? '编辑数据' : '添加数据'"
|
||||
>
|
||||
<n-form
|
||||
:model="formParams"
|
||||
@@ -53,15 +53,19 @@
|
||||
<n-form-item label="标签" path="label">
|
||||
<n-input placeholder="请输入标签名称" v-model:value="formParams.label" />
|
||||
</n-form-item>
|
||||
<n-form-item label="标签样式" path="listClass">
|
||||
<n-select
|
||||
:render-tag="renderTag"
|
||||
v-model:value="formParams.listClass"
|
||||
:options="labelOptions"
|
||||
/>
|
||||
</n-form-item>
|
||||
<n-form-item label="字典键值" path="value">
|
||||
<n-input placeholder="请输入键值" v-model:value="formParams.value" />
|
||||
</n-form-item>
|
||||
<n-form-item label="键值类型" path="valueType">
|
||||
<n-select v-model:value="formParams.valueType" :options="options" />
|
||||
</n-form-item>
|
||||
<n-form-item label="标签样式" path="listClass">
|
||||
<n-select v-model:value="formParams.listClass" :options="tagOptions" />
|
||||
</n-form-item>
|
||||
<n-form-item label="排序" path="sort">
|
||||
<n-input-number placeholder="请输入" v-model:value="formParams.sort" />
|
||||
</n-form-item>
|
||||
@@ -93,13 +97,13 @@
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { h, reactive, ref, watch, onMounted } from 'vue';
|
||||
import { TreeSelectOption, useMessage, useDialog } from 'naive-ui';
|
||||
import { TreeSelectOption, useMessage, useDialog, NTag, SelectRenderTag } from 'naive-ui';
|
||||
import { BasicTable, TableAction } from '@/components/Table';
|
||||
import { BasicForm, FormSchema, useForm } from '@/components/Form/index';
|
||||
import { getDataList, getDictSelect, EditData, DeleteData } from '@/api/dict/dict';
|
||||
import { columns } from './columns';
|
||||
import { PlusOutlined } from '@vicons/antd';
|
||||
import { statusOptions, tagOptions } from '@/enums/optionsiEnum';
|
||||
import { statusOptions } from '@/enums/optionsiEnum';
|
||||
import { TypeSelect } from '@/api/sys/config';
|
||||
import { Option } from '@/utils/hotgo';
|
||||
const options = ref<Option>();
|
||||
@@ -138,6 +142,49 @@
|
||||
},
|
||||
];
|
||||
|
||||
const renderTag: SelectRenderTag = ({ option }) => {
|
||||
return h(
|
||||
NTag,
|
||||
{
|
||||
type: option.type as 'success' | 'warning' | 'error' | 'info' | 'primary' | 'default',
|
||||
},
|
||||
{ default: () => option.label }
|
||||
);
|
||||
};
|
||||
|
||||
const labelOptions = ref([
|
||||
{
|
||||
label: '绿色',
|
||||
value: 'success',
|
||||
type: 'success',
|
||||
},
|
||||
{
|
||||
label: '橙色',
|
||||
value: 'warning',
|
||||
type: 'warning',
|
||||
},
|
||||
{
|
||||
label: '红色',
|
||||
value: 'error',
|
||||
type: 'error',
|
||||
},
|
||||
{
|
||||
label: '蓝色',
|
||||
value: 'info',
|
||||
type: 'info',
|
||||
},
|
||||
{
|
||||
label: '灰色',
|
||||
value: 'default',
|
||||
type: 'default',
|
||||
},
|
||||
{
|
||||
label: '主题色',
|
||||
value: 'primary',
|
||||
type: 'primary',
|
||||
},
|
||||
]);
|
||||
|
||||
const formRef: any = ref(null);
|
||||
const message = useMessage();
|
||||
const dialog = useDialog();
|
||||
|
||||
Reference in New Issue
Block a user