Commit cb343624 authored by “yiyousong”'s avatar “yiyousong”

feat:添加系统设置板块

parent 67a1a324
<template>
<div class="qrcode ff">
<div class="skins_bnt">
<!-- 新增按钮 -->
<a-button type="primary" @click="showModal" class="skins_btn_1">新增</a-button>
<!-- 弹窗 -->
<a-modal v-model="visible" title="新增" @ok="handleOk">
<a-form-item label="二维码组合名称">
<a-input placeholder="请输入二维码组合名称" />
</a-form-item>
</a-modal>
</div>
<!-- 表格 -->
<a-table :columns="columns" :data-source="data">
<a slot="name" slot-scope="text">{{ text }}</a>
<span slot="number" slot-scope="text, record, index">{{ index + 1 }}</span>
<span slot="action">
<a class="item">关联事项</a>
<a type="primary" @click="showModal" class="edit">编辑</a>
<a class="delet">删除</a>
</span>
</a-table>
<!-- <DelModal :message="message" ref="delModal"/> -->
</div>
</template>
<script>
// import DelModal from '@/components/delmodal/index'
const columns = [
{
title: "序号",
dataIndex: "number",
scopedSlots: {
customRender: "number"
},
},
{
title: "二维码组合名称",
dataIndex: 'name',
},
{
title: "操作",
scopedSlots: {
customRender: "action",
},
},
];
const data = [
{
key: 1,
name: "网络理政部办理事项展示二维码",
},
{
key: 2,
name: "网络理政部办理事项展示二维码",
},
{
key: 3,
name: "网络理政部办理事项展示二维码",
},
{
key: 4,
name: "网络理政部办理事项展示二维码",
},
{
key: 5,
name: "网络理政部办理事项展示二维码",
},
{
key: 6,
name: "网络理政部办理事项展示二维码",
},
{
key: 7,
name: "网络理政部办理事项展示二维码",
},
{
key: 8,
name: "网络理政部办理事项展示二维码",
},
];
export default {
components: {
// DelModal
},
data () {
return {
data,
columns,
visible: false,
value: 1,
};
},
methods: {
showModal () {
this.visible = true;
},
handleOk (e) {
console.log(e);
this.visible = false;
},
handleCancel () {
this.visible = false;
},
onText (e) {
console.log(e);
},
onChange (checkedValues) {
console.log('checked = ', checkedValues);
},
// delmodal() {
// this.message = '节日'
// this.$refs.delModal.show()
// },
onChanges (e) {
console.log('radio checked', e.target.value);
},
editAction (data) {
this.$router.push({
path: 'basis', query: {
list: data
}
})
},
},
};
</script>
<style lang="less" scoped>
.skins_btn_1 {
margin-bottom: 15px;
width: 115px;
height: 36px;
background-color: rgba(5, 149, 253, 1);
border-color: rgba(5, 149, 253, 1);
}
.edit {
color: rgb(41, 184, 41);
margin-right: 40px;
}
.delet {
color: red;
}
.item {
margin-right: 40px;
color: #0595fd;
}
</style>
\ No newline at end of file
<template>
<div class="system flex flexc">
<a-tabs :activeKey="activeKey" @change="changeRouter">
<a-tab-pane key="/system/parameter" tab="系统参数"> </a-tab-pane>
<a-tab-pane key="/system/task" tab="任务信息"> </a-tab-pane>
<a-tab-pane key="/system/systemlogs" tab="操作日志"> </a-tab-pane>
</a-tabs>
<div class="system-out-box flex1">
<router-view></router-view>
</div>
</div>
</template>
<script>
export default {
computed: {
activeKey() {
return this.$route.path;
},
},
methods: {
changeRouter(path) {
this.$router.push(path);
},
},
};
</script>
<style lang="less" scoped>
.system {
width: 100%;
height: 100%;
padding: 15px;
.system-out-box {
overflow-y: auto;
}
/deep/.ant-tabs-nav-container {
border-bottom: 1px solid #f0f0f0 !important;
}
}
</style>
\ No newline at end of file
<template>
<div class="parameter">
<div class="control flex aic jcb mb15">
<div>
<a-button type="primary" style="margin-right: 10px" @click="handleAdd"
>新增</a-button
>
<a-button type="danger" @click="handleDelAll">批量删除</a-button>
</div>
<div class="search-box">
<a-input-search
placeholder="请输入参数名搜索"
enter-button="搜索"
v-model="searchValue"
allowClear
@search="onSearch"
/>
</div>
</div>
<!-- 表格 -->
<div class="table-content">
<a-table
:row-selection="{
selectedRowKeys: selectedRowKeys,
onChange: onSelectChange,
}"
:loading="loading"
bordered
:scroll="{ y: 590 }"
:columns="columns"
:pagination="{
showTotal: (total) => `共 ${total} 条`,
current: current,
total: total,
pageSize: size,
showSizeChanger: true,
showQuickJumper: true,
pageSizeOptions: pageSizeOptions,
onChange: handleChange,
onShowSizeChange: showSizeChange,
}"
size="small"
:data-source="tableData"
:rowKey="(record) => record.id"
>
<!-- 序号 -->
<span slot="num" slot-scope="text, record, index">{{
(current - 1) * size + index + 1
}}</span>
<!-- 有效状态 -->
<template slot="validStatus" slot-scope="text">
<a-tag>{{ filterItems(text.validStatus, dict.validStatus) }} </a-tag>
</template>
<!-- 修改状态 -->
<template slot="modStatus" slot-scope="text">
<a-tag>{{ filterItems(text.modStatus, dict.modStatus) }} </a-tag>
</template>
<!-- 展现类型 -->
<template slot="displayType" slot-scope="text">
<a-tag>{{ filterItems(text.displayType, dict.displayType) }} </a-tag>
</template>
<!-- 操作 -->
<template slot="action" slot-scope="text">
<a-space size="middle">
<a href="javascript:;" class="edit" @click="handleEdit(text)"
>编辑</a
>
<a href="javascript:;" class="delete" @click="handleDel(text.id)"
>删除</a
>
</a-space>
</template>
</a-table>
</div>
<!-- 新增 -->
<AddParameter
ref="AddParameter"
:addVisible.sync="addVisible"
:title="title"
:dict="dict"
@addSuccess="getSystemParameterList"
></AddParameter>
</div>
</template>
<script>
import { getSystemParameterList, delSystemParameter } from "@/services/system";
import AddParameter from "./modal/AddParameter.vue";
export default {
components: {
AddParameter,
},
data() {
const columns = [
{
title: "序号",
dataIndex: "num",
width: "65px",
scopedSlots: {
customRender: "num",
},
},
{
title: "参数名称",
dataIndex: "name",
},
{
title: "一级组织",
// dataIndex: "firstOrganize",
customRender: (text) => {
return text.firstOrganize || "--";
},
},
{
title: "二级组织",
// dataIndex: "secondOrganize",
customRender: (text) => {
return text.secondOrganize || "--";
},
},
{
title: "参数键",
dataIndex: "paramKey",
},
{
title: "参数值",
dataIndex: "paramValue",
},
{
title: "有效状态",
// dataIndex: "validStatus",
scopedSlots: {
customRender: "validStatus",
},
// customRender: (text) => {
// return this.filterItems(text.validStatus, this.dict.validStatus);
// },
},
{
title: "修改状态",
scopedSlots: {
customRender: "modStatus",
},
},
{
title: "展现类型",
scopedSlots: {
customRender: "displayType",
},
},
{
title: "备注",
// dataIndex: "remark",
customRender: (text) => {
return text.remark || "--";
},
},
{
title: "操作",
width: "120px",
scopedSlots: { customRender: "action" },
},
];
return {
columns,
loading: false,
current: 1,
size: 10,
total: 0,
pageSizeOptions: ["10", "30", "50", "100"],
searchValue: "", // 搜索
tableData: [],
selectedRowKeys: [],
dict: {}, // 字典
addVisible: false,
title: "新增",
};
},
created() {
this.getSystemParameterList();
},
methods: {
// 获取参数列表
async getSystemParameterList() {
let res = await getSystemParameterList({
page: this.current,
size: this.size,
name: `%${this.searchValue}%`,
});
if (res.data.code == 1) {
let { total, data, dict } = res.data.data;
this.dict = dict;
if (!data.length && this.current > 1) {
this.current -= 1;
}
this.total = total;
this.tableData = data;
}
},
// 新增
handleAdd() {
this.title = "新增";
this.$refs.AddParameter.onAdd();
this.addVisible = true;
},
// 搜索
onSearch() {
this.current = 1;
this.getSystemParameterList();
},
// 分页
handleChange(num) {
this.current = num;
this.getSystemParameterList();
},
// 改变每页显示数量
showSizeChange(current, size) {
this.current = current;
this.size = size;
this.getSystemParameterList();
},
// 选择
onSelectChange(keys) {
this.selectedRowKeys = keys;
},
// 批量删除
handleDelAll() {
if (!this.selectedRowKeys.length) {
this.$message.warn("请先勾选数据");
return;
}
let ids = this.selectedRowKeys.join(",");
this.handleDel(ids);
},
// 编辑
handleEdit(row) {
this.title = "编辑";
this.$refs.AddParameter.onEdit(row);
this.addVisible = true;
},
// 删除
handleDel(id) {
let _this = this;
this.$confirm({
title: "系统提示",
content: "删除不可恢复,确定要删除吗?",
okText: "确定",
okType: "danger",
cancelText: "取消",
centered: true,
icon: "exclamation-circle",
maskClosable: true,
async onOk() {
let res = await delSystemParameter({ id });
let { code, msg } = res.data;
if (code == 1) {
_this.$message.success(msg);
_this.selectedRowKeys = [];
_this.getSystemParameterList();
}
},
onCancel() {
console.log("Cancel");
},
});
},
// 过滤表格数据
filterItems(key, dict = {}) {
let val = "";
Object.keys(dict).forEach((keys) => {
if (key == keys) {
val = dict[keys];
}
});
return val;
},
},
};
</script>
<style lang="less" scoped>
.parameter {
width: 100%;
height: 100%;
}
</style>
\ No newline at end of file
<template>
<div>
<a-modal
:title="title"
:visible="Visible"
@cancel="handleCancel"
:maskClosable="false"
>
<a-button slot="footer" @click="handleReset">重置</a-button>
<a-button slot="footer" type="primary" @click="handleOk">保存</a-button>
<a-form-model
:model="form"
ref="form"
:rules="rules"
:label-col="{ span: 5 }"
:wrapper-col="{ span: 19 }"
>
<a-form-model-item label="参数名称" prop="name">
<a-input v-model="form.name" placeholder="请输入参数名称" />
</a-form-model-item>
<a-form-model-item label="一级组织" prop="firstOrganize">
<a-input v-model="form.firstOrganize" placeholder="请输入一级组织" />
</a-form-model-item>
<a-form-model-item label="二级组织" prop="secondOrganize">
<a-input v-model="form.secondOrganize" placeholder="请输入二级组织" />
</a-form-model-item>
<a-form-model-item label="参数键" prop="paramKey">
<a-input v-model="form.paramKey" placeholder="请输入参数键" />
</a-form-model-item>
<a-form-model-item label="参数值" prop="paramValue">
<a-input v-model="form.paramValue" placeholder="请输入参数值" />
</a-form-model-item>
<a-form-model-item label="参数修改状态" prop="modStatus">
<a-select v-model="form.modStatus" placeholder="请选择参数修改状态">
<a-select-option
v-for="(v, key) in dict.modStatus"
:key="key"
:value="Number(key)"
>{{ v }}</a-select-option
>
</a-select>
</a-form-model-item>
<a-form-model-item label="展现类型" prop="displayType">
<a-select v-model="form.displayType" placeholder="请选择展现类型">
<a-select-option
v-for="(v, key) in dict.displayType"
:key="key"
:value="Number(key)"
>{{ v }}</a-select-option
>
</a-select>
</a-form-model-item>
<a-form-model-item label="参数有效状态" prop="validStatus">
<a-radio-group v-model="form.validStatus">
<a-radio
v-for="(v, key) in dict.validStatus"
:value="Number(key)"
:key="key"
>{{ v }}</a-radio
>
</a-radio-group>
</a-form-model-item>
<a-form-model-item label="备注" prop="remark">
<a-textarea
:autoSize="{ minRows: 4, maxRows: 4 }"
v-model="form.remark"
placeholder="请输入备注"
allow-clear
/>
</a-form-model-item>
</a-form-model>
</a-modal>
</div>
</template>
<script>
import { saveSystemParameter } from "@/services/system";
export default {
components: {},
props: {
addVisible: {
required: true,
type: Boolean,
default: false,
},
title: {
required: true,
type: String,
default: "",
},
dict: {
required: true,
type: Object,
default: () => {
return {};
},
},
},
data() {
return {
form: {
name: "", // 参数名称
firstOrganize: "", // 一级组织
secondOrganize: "", // 二级组织
paramKey: "", // 参数键
paramValue: "", // 参数值
modStatus: undefined, // 参数修改状态
displayType: undefined, // 展现类型
validStatus: "", // 参数有效状态
remark: "", // 备注
},
rules: {
name: [{ required: true, message: "请输入参数名称", trigger: "blur" }],
paramKey: [
{ required: true, message: "请输入参数键", trigger: "blur" },
],
paramValue: [
{ required: true, message: "请输入参数值", trigger: "blur" },
],
},
};
},
computed: {
Visible: {
get() {
return this.addVisible;
},
set(val) {
this.$emit("update:addVisible", val);
},
},
},
methods: {
// 关闭弹窗
handleCancel() {
this.$refs.form.resetFields();
this.Visible = false;
},
// 重置
handleReset() {
this.$refs.form.resetFields();
},
// 新增
onAdd() {
Object.assign(this.form, this.$options.data().form);
this.form.id && this.$delete(this.form, "id");
},
// 编辑
onEdit(row) {
this.form = { ...row };
},
// 保存
handleOk() {
this.$refs.form.validate(async (valid) => {
if (valid) {
let res = await saveSystemParameter(this.form);
let { code, msg } = res.data;
if (code == 1) {
this.$message.success(msg);
this.$emit("addSuccess");
this.handleCancel();
}
}
});
},
},
};
</script>
<style lang="less" scoped>
</style>
\ No newline at end of file
<template>
<!-- 系统日志 -->
<div class="system-logs">
<div class="control">
<div class="search-box">
<a-input-search
placeholder="请输入请求地址搜索"
enter-button="搜索"
v-model="searchValue"
allowClear
@search="onSearch"
/>
</div>
</div>
<!-- 表格 -->
<div class="table-content">
<a-table
:loading="loading"
bordered
:scroll="{ y: 590 }"
:columns="columns"
size="small"
:pagination="{
showTotal: (total) => `共 ${total} 条`,
current: current,
total: total,
pageSize: size,
showSizeChanger: true,
showQuickJumper: true,
pageSizeOptions: pageSizeOptions,
onChange: handleChange,
onShowSizeChange: showSizeChange,
}"
:data-source="tableData"
:rowKey="(record) => record.id"
>
<!-- 序号 -->
<span slot="num" slot-scope="text, record, index">{{
(current - 1) * size + index + 1
}}</span>
<!-- 操作时间 -->
<template slot="logDate" slot-scope="text">
{{ text.logDate | dateFormat }}
</template>
</a-table>
</div>
</div>
</template>
<script>
import { getSystemLogsList } from "@/services/system";
const columns = [
{
title: "序号",
dataIndex: "num",
width: "65px",
scopedSlots: {
customRender: "num",
},
},
{
title: "用户名称",
dataIndex: "userName",
},
{
title: "登录名称",
dataIndex: "loginName",
},
{
title: "请求地址",
dataIndex: "requestUrl",
},
{
title: "操作内容",
dataIndex: "content",
},
{
title: "操作IP地址",
dataIndex: "ip",
},
{
title: "操作时间",
scopedSlots: {
customRender: "logDate",
},
},
];
export default {
data() {
return {
columns,
loading: false,
current: 1,
size: 10,
total: 0,
pageSizeOptions: ["10", "30", "50", "100"],
searchValue: "", // 搜索
tableData: [],
};
},
created() {
this.getSystemLogsList();
},
methods: {
// 获取日志列表
async getSystemLogsList() {
this.loading = true;
let res = await getSystemLogsList({
page: this.current,
size: this.size,
requestUrl: this.searchValue,
});
this.loading = false;
if (res.data.code == 1) {
let { result, total } = res.data.data;
this.tableData = result;
this.total = total;
}
},
// 搜索
onSearch() {
this.current = 1;
this.getSystemLogsList();
},
// 分页
handleChange(num) {
this.current = num;
this.getSystemLogsList();
},
// 改变每页显示数量
showSizeChange(current, size) {
this.current = current;
this.size = size;
this.getSystemLogsList();
},
},
};
</script>
<style lang="less" scoped>
.system-logs {
width: 100%;
height: 100%;
.control {
display: flex;
justify-content: flex-end;
margin-bottom: 15px;
}
}
</style>
\ No newline at end of file
<template>
<div class="task-set">
<div class="control flex aic jcb mb15">
<div>
<a-button type="primary" style="margin-right: 10px" @click="handleAdd"
>新增</a-button
>
<a-button type="danger" @click="handleDelAll">批量删除</a-button>
</div>
<div class="search-box">
<a-input-search
placeholder="请输入任务名搜索"
enter-button="搜索"
v-model="searchValue"
allowClear
@search="onSearch"
/>
</div>
</div>
<!-- 表格 -->
<div class="table-content">
<a-table
:row-selection="{
selectedRowKeys: selectedRowKeys,
onChange: onSelectChange,
}"
:loading="loading"
bordered
:scroll="{ y: 590 }"
:columns="columns"
:pagination="{
showTotal: (total) => `共 ${total} 条`,
current: current,
total: total,
pageSize: size,
showSizeChanger: true,
showQuickJumper: true,
pageSizeOptions: pageSizeOptions,
onChange: handleChange,
onShowSizeChange: showSizeChange,
}"
size="small"
:data-source="tableData"
:rowKey="(record) => record.id"
>
<!-- 序号 -->
<span slot="num" slot-scope="text, record, index">{{
(current - 1) * size + index + 1
}}</span>
<!-- 执行策略 -->
<template slot="excuteStrategy" slot-scope="text">
<a-tag
>{{ filterItems(text.excuteStrategy, dict.excuteStrategy) }}
</a-tag>
</template>
<!-- 最后执行时间 -->
<template slot="lastExcuteTime" slot-scope="text">
{{ text.lastExcuteTime | dateFormat }}
</template>
<!-- 任务状态 -->
<template slot="status" slot-scope="text">
<a-tag>{{ filterItems(text.status, dict.status) }} </a-tag>
</template>
<!-- 操作 -->
<template slot="action" slot-scope="text">
<a-space size="middle">
<a href="javascript:;" class="edit" @click="handleEdit(text)"
>编辑</a
>
<a href="javascript:;" class="delete" @click="handleDel(text.id)"
>删除</a
>
</a-space>
</template>
</a-table>
</div>
<!-- 新增 -->
<AddTask
ref="AddTask"
:addVisible.sync="addVisible"
:title="title"
:dict="dict"
@addSuccess="getSystemTaskList"
></AddTask>
</div>
</template>
<script>
import { getSystemTaskList, delSystemTask } from "@/services/system";
import AddTask from "./modal/AddTask.vue";
export default {
components: {
AddTask,
},
data() {
const columns = [
{
title: "序号",
dataIndex: "num",
width: "65px",
scopedSlots: {
customRender: "num",
},
},
{
title: "任务名称",
dataIndex: "name",
},
{
title: "执行主机",
customRender: (text) => {
return text.excuteHost || "--";
},
},
{
title: "执行关键字",
customRender: (text) => {
return text.taskKey || "--";
},
},
{
title: "执行策略",
scopedSlots: {
customRender: "excuteStrategy",
},
},
{
title: "最后执行主机",
customRender: (text) => {
return text.lastExcuteHost || "--";
},
},
{
title: "最后执行时间",
scopedSlots: {
customRender: "lastExcuteTime",
},
},
{
title: "任务状态",
scopedSlots: {
customRender: "status",
},
},
{
title: "操作",
width: "120px",
scopedSlots: { customRender: "action" },
},
];
return {
columns,
loading: false,
current: 1,
size: 10,
total: 0,
pageSizeOptions: ["10", "30", "50", "100"],
searchValue: "", // 搜索
tableData: [],
selectedRowKeys: [],
dict: {}, // 字典
addVisible: false,
title: "新增",
};
},
created() {
this.getSystemTaskList();
},
methods: {
// 获取参数列表
async getSystemTaskList() {
let res = await getSystemTaskList({
page: this.current,
size: this.size,
name: `%${this.searchValue}%`,
});
if (res.data.code == 1) {
let { total, data, dict } = res.data.data;
this.dict = dict;
if (!data.length && this.current > 1) {
this.current -= 1;
}
this.total = total;
this.tableData = data;
}
},
// 新增
handleAdd() {
this.title = "新增";
this.$refs.AddTask.onAdd();
this.addVisible = true;
},
// 搜索
onSearch() {
this.current = 1;
this.getSystemTaskList();
},
// 分页
handleChange(num) {
this.current = num;
this.getSystemTaskList();
},
// 改变每页显示数量
showSizeChange(current, size) {
this.current = current;
this.size = size;
this.getSystemTaskList();
},
// 选择
onSelectChange(keys) {
this.selectedRowKeys = keys;
},
// 批量删除
handleDelAll() {
if (!this.selectedRowKeys.length) {
this.$message.warn("请先勾选数据");
return;
}
let ids = this.selectedRowKeys.join(",");
this.handleDel(ids);
},
// 编辑
handleEdit(row) {
console.log(row);
this.title = "编辑";
this.$refs.AddTask.onEdit(row);
this.addVisible = true;
},
// 删除
handleDel(id) {
let _this = this;
this.$confirm({
title: "系统提示",
content: "删除不可恢复,确定要删除吗?",
okText: "确定",
okType: "danger",
cancelText: "取消",
centered: true,
icon: "exclamation-circle",
maskClosable: true,
async onOk() {
let res = await delSystemTask({ id });
let { code, msg } = res.data;
if (code == 1) {
_this.$message.success(msg);
_this.selectedRowKeys = [];
_this.getSystemTaskList();
}
},
onCancel() {
console.log("Cancel");
},
});
},
// 过滤表格数据
filterItems(key, dict = {}) {
let val = "";
Object.keys(dict).forEach((keys) => {
if (key == keys) {
val = dict[keys];
}
});
return val;
},
},
};
</script>
<style lang="less" scoped>
.task-set {
width: 100%;
height: 100%;
}
</style>
\ No newline at end of file
<template>
<div>
<a-modal
:title="title"
:visible="Visible"
@cancel="handleCancel"
:maskClosable="false"
>
<a-button slot="footer" @click="handleReset">重置</a-button>
<a-button slot="footer" type="primary" @click="handleOk">保存</a-button>
<a-form-model
:model="form"
ref="form"
:rules="rules"
:label-col="{ span: 5 }"
:wrapper-col="{ span: 19 }"
>
<a-form-model-item label="任务名称" prop="name">
<a-input v-model="form.name" placeholder="请输入参数名称" />
</a-form-model-item>
<a-form-model-item label="关键字" prop="taskKey">
<a-input v-model="form.taskKey" placeholder="请输入关键字" />
</a-form-model-item>
<a-form-model-item label="执行服务" prop="excuteService">
<a-input v-model="form.excuteService" placeholder="请输入执行服务" />
</a-form-model-item>
<a-form-model-item label="执行策略" prop="excuteStrategy">
<a-select v-model="form.excuteStrategy" placeholder="请选择执行策略">
<a-select-option
v-for="(v, key) in dict.excuteStrategy"
:key="key"
:value="Number(key)"
>{{ v }}</a-select-option
>
</a-select>
</a-form-model-item>
<a-form-model-item label="执行日期">
<a-input disabled value="每天" placeholder="请输入执行服务" />
</a-form-model-item>
<a-form-model-item label="执行时间" prop="excuteTime">
<a-time-picker
valueFormat="HH:mm"
format="HH:mm"
v-model="form.excuteTime"
/>
</a-form-model-item>
<a-form-model-item label="执行主机" prop="excuteHost">
<a-input v-model="form.excuteHost" placeholder="请输入执行主机" />
</a-form-model-item>
<a-form-model-item label="执行参数" prop="excuteParam">
<a-input v-model="form.excuteParam" placeholder="请输入执行参数" />
</a-form-model-item>
<a-form-model-item label="备注" prop="remark">
<a-textarea
:autoSize="{ minRows: 4, maxRows: 4 }"
v-model="form.remark"
placeholder="请输入备注"
allow-clear
/>
</a-form-model-item>
</a-form-model>
</a-modal>
</div>
</template>
<script>
import { saveSystemTask } from "@/services/system";
export default {
components: {},
props: {
addVisible: {
required: true,
type: Boolean,
default: false,
},
title: {
required: true,
type: String,
default: "",
},
dict: {
required: true,
type: Object,
default: () => {
return {};
},
},
},
data() {
return {
form: {
name: "", // 任务名称
taskKey: "", // 关键字
excuteService: "", // 执行服务
excuteStrategy: undefined, // 执行策略
excuteDate: 0, // 执行日期
excuteTime: "", // 执行时间
excuteHost: "", // 执行主机
excuteParam: "", // 执行参数
remark: "", // 备注
},
rules: {
name: [{ required: true, message: "请输入任务名称", trigger: "blur" }],
taskKey: [{ required: true, message: "请输入关键字", trigger: "blur" }],
excuteService: [
{ required: true, message: "请输入执行服务", trigger: "blur" },
],
},
};
},
computed: {
Visible: {
get() {
return this.addVisible;
},
set(val) {
this.$emit("update:addVisible", val);
},
},
},
methods: {
// 关闭弹窗
handleCancel() {
this.$refs.form.resetFields();
this.Visible = false;
},
// 重置
handleReset() {
this.$refs.form.resetFields();
},
// 新增
onAdd() {
Object.assign(this.form, this.$options.data().form);
this.form.id && this.$delete(this.form, "id");
},
// 编辑
onEdit(row) {
this.form = { ...row };
},
// 保存
handleOk() {
this.$refs.form.validate(async (valid) => {
if (valid) {
let res = await saveSystemTask(this.form);
let { code, msg } = res.data;
if (code == 1) {
this.$message.success(msg);
this.$emit("addSuccess");
this.handleCancel();
}
}
});
},
},
};
</script>
<style lang="less" scoped>
</style>
\ No newline at end of file
...@@ -169,6 +169,37 @@ const options = { ...@@ -169,6 +169,37 @@ const options = {
}, },
], ],
}, },
{
path: "system",
name: "系统设置",
component: () => import("@/pages/basicset/system/System"),
meta: {
icon: "global",
},
redirect: "system/parameter",
children: [
{
path: "parameter",
name: "系统参数",
component: () =>
import("@/pages/basicset/system/parameter/Parameter"),
meta: { invisible: true },
},
{
path: "task",
name: "任务信息",
component: () => import("@/pages/basicset/system/task/TaskSet"),
meta: { invisible: true },
},
{
path: "systemlogs",
name: "操作日志",
component: () =>
import("@/pages/basicset/system/systemlogs/SystemLogs"),
meta: { invisible: true },
},
],
},
], ],
}, },
], ],
......
...@@ -316,4 +316,26 @@ module.exports = { ...@@ -316,4 +316,26 @@ module.exports = {
used: `${BASE_URL}/base/app/version/used`, used: `${BASE_URL}/base/app/version/used`,
preview: `${BASE_URL}/base/app/version/preview`, preview: `${BASE_URL}/base/app/version/preview`,
}, },
// 系统设置
system: {
// 系统日志
logs: {
list: `${BASE_URL}/base/oper/log/list`,
info: `${BASE_URL}/base/oper/log/info`,
},
// 系统参数
parameter: {
list: `${BASE_URL}/base/param/list`,
info: `${BASE_URL}/base/param/info`,
save: `${BASE_URL}/base/param/save`,
delete: `${BASE_URL}/base/param/delete`,
},
// 系统任务信息
task: {
list: `${BASE_URL}/base/task/list`,
info: `${BASE_URL}/base/task/info`,
save: `${BASE_URL}/base/task/save`,
delete: `${BASE_URL}/base/task/delete`,
},
},
}; };
import { system } from "@/services/basicsetApi";
import { request, METHOD } from "@/utils/request";
/**
* 系统设置
*/
// 查询系统日志列表
export async function getSystemLogsList(data) {
return request(system.logs.list, METHOD.POST, data);
}
// 查看系统日志信息
export async function getSystemLogsInfo(data) {
return request(system.logs.info, METHOD.GET, data);
}
// 获取系统参数信息列表
export async function getSystemParameterList(data) {
return request(system.parameter.list, METHOD.POST, data);
}
// 获取系统参数信息
export async function getSystemParameterInfo(data) {
return request(system.parameter.info, METHOD.GET, data);
}
// 保存系统参数信息
export async function saveSystemParameter(data) {
return request(system.parameter.save, METHOD.POST, data);
}
// 删除系统参数信息
export async function delSystemParameter(data) {
return request(system.parameter.delete, METHOD.GET, data);
}
// 获取系统任务信息列表
export async function getSystemTaskList(data) {
return request(system.task.list, METHOD.POST, data);
}
// 获取系统任务信息
export async function getSystemTaskInfo(data) {
return request(system.task.info, METHOD.GET, data);
}
// 保存系统任务信息
export async function saveSystemTask(data) {
return request(system.task.save, METHOD.POST, data);
}
// 删除系统任务信息
export async function delSystemTask(data) {
return request(system.task.delete, METHOD.GET, data);
}
import routerMap from '@/router/async/router.map' import routerMap from "@/router/async/router.map";
import { mergeI18nFromRoutes } from '@/utils/i18n' import { mergeI18nFromRoutes } from "@/utils/i18n";
import Router from 'vue-router' import Router from "vue-router";
import deepMerge from 'deepmerge' import deepMerge from "deepmerge";
import basicOptions from '@/router/async/config.async' import basicOptions from "@/router/async/config.async";
//应用配置 //应用配置
let appOptions = { let appOptions = {
router: undefined, router: undefined,
i18n: undefined, i18n: undefined,
store: undefined store: undefined,
} };
/** /**
* 设置应用配置 * 设置应用配置
* @param options * @param options
*/ */
function setAppOptions (options) { function setAppOptions(options) {
const { router, store, i18n } = options const { router, store, i18n } = options;
appOptions.router = router appOptions.router = router;
appOptions.store = store appOptions.store = store;
appOptions.i18n = i18n appOptions.i18n = i18n;
} }
/** /**
...@@ -27,21 +27,22 @@ function setAppOptions (options) { ...@@ -27,21 +27,22 @@ function setAppOptions (options) {
* @param routesConfig 路由配置 * @param routesConfig 路由配置
* @param routerMap 本地路由组件注册配置 * @param routerMap 本地路由组件注册配置
*/ */
function parseRoutes (routesConfig, routerMap) { function parseRoutes(routesConfig, routerMap) {
let routes = [] let routes = [];
routesConfig.forEach(item => { routesConfig.forEach((item) => {
// 获取注册在 routerMap 中的 router,初始化 routeCfg // 获取注册在 routerMap 中的 router,初始化 routeCfg
let router = undefined, routeCfg = {} let router = undefined,
if (typeof item === 'string') { routeCfg = {};
router = routerMap[item] if (typeof item === "string") {
routeCfg = { path: (router && router.path) || item, router: item } router = routerMap[item];
} else if (typeof item === 'object') { routeCfg = { path: (router && router.path) || item, router: item };
router = routerMap[item.router] } else if (typeof item === "object") {
routeCfg = item router = routerMap[item.router];
routeCfg = item;
} }
if (!router) { if (!router) {
console.warn(`can't find register for router ${routeCfg.router}, please register it in advance.`) // console.warn(`can't find register for router ${routeCfg.router}, please register it in advance.`)
router = typeof item === 'string' ? { path: item, name: item } : item router = typeof item === "string" ? { path: item, name: item } : item;
} }
// 从 router 和 routeCfg 解析路由 // 从 router 和 routeCfg 解析路由
const meta = { const meta = {
...@@ -51,8 +52,8 @@ function parseRoutes (routesConfig, routerMap) { ...@@ -51,8 +52,8 @@ function parseRoutes (routesConfig, routerMap) {
link: router.link, link: router.link,
params: router.params, params: router.params,
query: router.query, query: router.query,
...router.meta ...router.meta,
} };
const cfgMeta = { const cfgMeta = {
authority: routeCfg.authority, authority: routeCfg.authority,
icon: routeCfg.icon, icon: routeCfg.icon,
...@@ -60,77 +61,85 @@ function parseRoutes (routesConfig, routerMap) { ...@@ -60,77 +61,85 @@ function parseRoutes (routesConfig, routerMap) {
link: routeCfg.link, link: routeCfg.link,
params: routeCfg.params, params: routeCfg.params,
query: routeCfg.query, query: routeCfg.query,
...routeCfg.meta ...routeCfg.meta,
} };
Object.keys(cfgMeta).forEach(key => { Object.keys(cfgMeta).forEach((key) => {
if (cfgMeta[key] === undefined || cfgMeta[key] === null || cfgMeta[key] === '') { if (
delete cfgMeta[key] cfgMeta[key] === undefined ||
cfgMeta[key] === null ||
cfgMeta[key] === ""
) {
delete cfgMeta[key];
} }
}) });
Object.assign(meta, cfgMeta) Object.assign(meta, cfgMeta);
const route = { const route = {
path: routeCfg.path || router.path || routeCfg.router, path: routeCfg.path || router.path || routeCfg.router,
name: routeCfg.name || router.name, name: routeCfg.name || router.name,
component: router.component, component: router.component,
redirect: routeCfg.redirect || router.redirect, redirect: routeCfg.redirect || router.redirect,
meta: { ...meta, authority: meta.authority || '*' } meta: { ...meta, authority: meta.authority || "*" },
} };
if (routeCfg.invisible || router.invisible) { if (routeCfg.invisible || router.invisible) {
route.meta.invisible = true route.meta.invisible = true;
} }
if (routeCfg.children && routeCfg.children.length > 0) { if (routeCfg.children && routeCfg.children.length > 0) {
route.children = parseRoutes(routeCfg.children, routerMap) route.children = parseRoutes(routeCfg.children, routerMap);
} }
routes.push(route) routes.push(route);
}) });
return routes return routes;
} }
/** /**
* 加载路由 * 加载路由
* @param routesConfig {RouteConfig[]} 路由配置 * @param routesConfig {RouteConfig[]} 路由配置
*/ */
function loadRoutes (routesConfig) { function loadRoutes(routesConfig) {
//兼容 0.6.1 以下版本 //兼容 0.6.1 以下版本
/*************** 兼容 version < v0.6.1 *****************/ /*************** 兼容 version < v0.6.1 *****************/
if (arguments.length > 0) { if (arguments.length > 0) {
const arg0 = arguments[0] const arg0 = arguments[0];
if (arg0.router || arg0.i18n || arg0.store) { if (arg0.router || arg0.i18n || arg0.store) {
routesConfig = arguments[1] routesConfig = arguments[1];
console.error('the usage of signature loadRoutes({router, store, i18n}, routesConfig) is out of date, please use the new signature: loadRoutes(routesConfig).') console.error(
console.error('方法签名 loadRoutes({router, store, i18n}, routesConfig) 的用法已过时, 请使用新的方法签名 loadRoutes(routesConfig)。') "the usage of signature loadRoutes({router, store, i18n}, routesConfig) is out of date, please use the new signature: loadRoutes(routesConfig)."
);
console.error(
"方法签名 loadRoutes({router, store, i18n}, routesConfig) 的用法已过时, 请使用新的方法签名 loadRoutes(routesConfig)。"
);
} }
} }
/*************** 兼容 version < v0.6.1 *****************/ /*************** 兼容 version < v0.6.1 *****************/
// 应用配置 // 应用配置
const { router, store, i18n } = appOptions const { router, store, i18n } = appOptions;
// 如果 routesConfig 有值,则更新到本地,否则从本地获取 // 如果 routesConfig 有值,则更新到本地,否则从本地获取
if (routesConfig) { if (routesConfig) {
store.commit('account/setRoutesConfig', routesConfig) store.commit("account/setRoutesConfig", routesConfig);
} else { } else {
routesConfig = store.getters['account/routesConfig'] routesConfig = store.getters["account/routesConfig"];
} }
// 如果开启了异步路由,则加载异步路由配置 // 如果开启了异步路由,则加载异步路由配置
const asyncRoutes = store.state.setting.asyncRoutes const asyncRoutes = store.state.setting.asyncRoutes;
if (asyncRoutes) { if (asyncRoutes) {
if (routesConfig && routesConfig.length > 0) { if (routesConfig && routesConfig.length > 0) {
const routes = parseRoutes(routesConfig, routerMap) const routes = parseRoutes(routesConfig, routerMap);
const finalRoutes = mergeRoutes(basicOptions.routes, routes) const finalRoutes = mergeRoutes(basicOptions.routes, routes);
formatRoutes(finalRoutes) formatRoutes(finalRoutes);
router.options = { ...router.options, routes: finalRoutes } router.options = { ...router.options, routes: finalRoutes };
router.matcher = new Router({ ...router.options, routes: [] }).matcher router.matcher = new Router({ ...router.options, routes: [] }).matcher;
router.addRoutes(finalRoutes) router.addRoutes(finalRoutes);
} }
} }
// 提取路由国际化数据 // 提取路由国际化数据
mergeI18nFromRoutes(i18n, router.options.routes) mergeI18nFromRoutes(i18n, router.options.routes);
// 初始化Admin后台菜单数据 // 初始化Admin后台菜单数据
const rootRoute = router.options.routes.find(item => item.path === '/') const rootRoute = router.options.routes.find((item) => item.path === "/");
const menuRoutes = rootRoute && rootRoute.children const menuRoutes = rootRoute && rootRoute.children;
if (menuRoutes) { if (menuRoutes) {
store.commit('setting/setMenuData', menuRoutes) store.commit("setting/setMenuData", menuRoutes);
} }
} }
...@@ -140,11 +149,11 @@ function loadRoutes (routesConfig) { ...@@ -140,11 +149,11 @@ function loadRoutes (routesConfig) {
* @param source {Route[]} * @param source {Route[]}
* @returns {Route[]} * @returns {Route[]}
*/ */
function mergeRoutes (target, source) { function mergeRoutes(target, source) {
const routesMap = {} const routesMap = {};
target.forEach(item => routesMap[item.path] = item) target.forEach((item) => (routesMap[item.path] = item));
source.forEach(item => routesMap[item.path] = item) source.forEach((item) => (routesMap[item.path] = item));
return Object.values(routesMap) return Object.values(routesMap);
} }
/** /**
...@@ -153,51 +162,51 @@ function mergeRoutes (target, source) { ...@@ -153,51 +162,51 @@ function mergeRoutes (target, source) {
* @param source {Route[]} * @param source {Route[]}
* @returns {Route[]} * @returns {Route[]}
*/ */
function deepMergeRoutes (target, source) { function deepMergeRoutes(target, source) {
// 映射路由数组 // 映射路由数组
const mapRoutes = routes => { const mapRoutes = (routes) => {
const routesMap = {} const routesMap = {};
routes.forEach(item => { routes.forEach((item) => {
routesMap[item.path] = { routesMap[item.path] = {
...item, ...item,
children: item.children ? mapRoutes(item.children) : undefined children: item.children ? mapRoutes(item.children) : undefined,
} };
}) });
return routesMap return routesMap;
} };
const tarMap = mapRoutes(target) const tarMap = mapRoutes(target);
const srcMap = mapRoutes(source) const srcMap = mapRoutes(source);
// 合并路由 // 合并路由
const merge = deepMerge(tarMap, srcMap) const merge = deepMerge(tarMap, srcMap);
// 转换为 routes 数组 // 转换为 routes 数组
const parseRoutesMap = routesMap => { const parseRoutesMap = (routesMap) => {
return Object.values(routesMap).map(item => { return Object.values(routesMap).map((item) => {
if (item.children) { if (item.children) {
item.children = parseRoutesMap(item.children) item.children = parseRoutesMap(item.children);
} else { } else {
delete item.children delete item.children;
} }
return item return item;
}) });
} };
return parseRoutesMap(merge) return parseRoutesMap(merge);
} }
/** /**
* 格式化路由 * 格式化路由
* @param routes 路由配置 * @param routes 路由配置
*/ */
function formatRoutes (routes) { function formatRoutes(routes) {
routes.forEach(route => { routes.forEach((route) => {
const { path } = route const { path } = route;
if (!path.startsWith('/') && path !== '*') { if (!path.startsWith("/") && path !== "*") {
route.path = '/' + path route.path = "/" + path;
} }
}) });
formatAuthority(routes) formatAuthority(routes);
} }
/** /**
...@@ -205,36 +214,38 @@ function formatRoutes (routes) { ...@@ -205,36 +214,38 @@ function formatRoutes (routes) {
* @param routes 路由 * @param routes 路由
* @param pAuthorities 父级路由权限配置集合 * @param pAuthorities 父级路由权限配置集合
*/ */
function formatAuthority (routes, pAuthorities = []) { function formatAuthority(routes, pAuthorities = []) {
routes.forEach(route => { routes.forEach((route) => {
const meta = route.meta const meta = route.meta;
const defaultAuthority = pAuthorities[pAuthorities.length - 1] || { permission: '*' } const defaultAuthority = pAuthorities[pAuthorities.length - 1] || {
permission: "*",
};
if (meta) { if (meta) {
let authority = {} let authority = {};
if (!meta.authority) { if (!meta.authority) {
authority = defaultAuthority authority = defaultAuthority;
} else if (typeof meta.authority === 'string') { } else if (typeof meta.authority === "string") {
authority.permission = meta.authority authority.permission = meta.authority;
} else if (typeof meta.authority === 'object') { } else if (typeof meta.authority === "object") {
authority = meta.authority authority = meta.authority;
const { role } = authority const { role } = authority;
if (typeof role === 'string') { if (typeof role === "string") {
authority.role = [role] authority.role = [role];
} }
if (!authority.permission && !authority.role) { if (!authority.permission && !authority.role) {
authority = defaultAuthority authority = defaultAuthority;
} }
} }
meta.authority = authority meta.authority = authority;
} else { } else {
const authority = defaultAuthority const authority = defaultAuthority;
route.meta = { authority } route.meta = { authority };
} }
route.meta.pAuthorities = pAuthorities route.meta.pAuthorities = pAuthorities;
if (route.children) { if (route.children) {
formatAuthority(route.children, [...pAuthorities, route.meta.authority]) formatAuthority(route.children, [...pAuthorities, route.meta.authority]);
} }
}) });
} }
/** /**
...@@ -242,10 +253,12 @@ function formatAuthority (routes, pAuthorities = []) { ...@@ -242,10 +253,12 @@ function formatAuthority (routes, pAuthorities = []) {
* @param path * @param path
* @returns {*} * @returns {*}
*/ */
function getI18nKey (path) { function getI18nKey(path) {
const keys = path.split('/').filter(item => !item.startsWith(':') && item != '') const keys = path
keys.push('name') .split("/")
return keys.join('.') .filter((item) => !item.startsWith(":") && item != "");
keys.push("name");
return keys.join(".");
} }
/** /**
...@@ -253,19 +266,28 @@ function getI18nKey (path) { ...@@ -253,19 +266,28 @@ function getI18nKey (path) {
* @param guards * @param guards
* @param options * @param options
*/ */
function loadGuards (guards, options) { function loadGuards(guards, options) {
const { beforeEach, afterEach } = guards const { beforeEach, afterEach } = guards;
const { router } = options const { router } = options;
beforeEach.forEach(guard => { beforeEach.forEach((guard) => {
if (guard && typeof guard === 'function') { if (guard && typeof guard === "function") {
router.beforeEach((to, from, next) => guard(to, from, next, options)) router.beforeEach((to, from, next) => guard(to, from, next, options));
} }
}) });
afterEach.forEach(guard => { afterEach.forEach((guard) => {
if (guard && typeof guard === 'function') { if (guard && typeof guard === "function") {
router.afterEach((to, from) => guard(to, from, options)) router.afterEach((to, from) => guard(to, from, options));
} }
}) });
} }
export { parseRoutes, loadRoutes, formatAuthority, getI18nKey, loadGuards, deepMergeRoutes, formatRoutes, setAppOptions } export {
parseRoutes,
loadRoutes,
formatAuthority,
getI18nKey,
loadGuards,
deepMergeRoutes,
formatRoutes,
setAppOptions,
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment