fix: 更新路由为后台配置,修改admim文件名称为admin
This commit is contained in:
66
src/views/admin/system/params/config/add.ts
Normal file
66
src/views/admin/system/params/config/add.ts
Normal file
@@ -0,0 +1,66 @@
|
||||
import ParamsApi, { type addRequest } from "@/api/system/params";
|
||||
import type { IModalConfig } from "@/components/CURD/types";
|
||||
import { paramTypeOptions } from './config'
|
||||
const modalConfig: IModalConfig<addRequest> = {
|
||||
pageName: "sys:user",
|
||||
dialog: {
|
||||
title: "添加系统参数",
|
||||
width: 800,
|
||||
draggable: true,
|
||||
},
|
||||
form: {
|
||||
labelWidth: 140,
|
||||
},
|
||||
formAction: function (data) {
|
||||
return ParamsApi.add(data);
|
||||
},
|
||||
beforeSubmit(data) {
|
||||
console.log("提交之前处理", data);
|
||||
},
|
||||
formItems: [
|
||||
{
|
||||
label: "参数编码",
|
||||
prop: "paramCode",
|
||||
rules: [{ required: true, message: "请输入参数编码", trigger: "blur" }],
|
||||
type: "input",
|
||||
attrs: {
|
||||
placeholder: "请输入参数编码",
|
||||
},
|
||||
},
|
||||
{
|
||||
label: "参数值",
|
||||
prop: "paramValue",
|
||||
rules: [{ required: true, message: "请输入参数值", trigger: "blur" }],
|
||||
type: "input",
|
||||
attrs: {
|
||||
placeholder: "请输入参数值",
|
||||
},
|
||||
},
|
||||
{
|
||||
label: "参数类型",
|
||||
prop: "paramType",
|
||||
rules: [{ required: true, message: "请选择参数类型", trigger: "blur" }],
|
||||
type: "select",
|
||||
attrs: {
|
||||
placeholder: "请选择参数类型",
|
||||
},
|
||||
col: {
|
||||
xs: 24,
|
||||
sm: 12,
|
||||
},
|
||||
options: paramTypeOptions,
|
||||
},
|
||||
{
|
||||
type: "textarea",
|
||||
label: "备注",
|
||||
prop: "remark",
|
||||
rules: [{ required: true, message: "请输入备注", trigger: "blur" }],
|
||||
attrs: {
|
||||
placeholder: "请输入备注",
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
// 如果有异步数据会修改配置的,推荐用reactive包裹,而纯静态配置的可以直接导出
|
||||
export default reactive(modalConfig);
|
||||
28
src/views/admin/system/params/config/config.ts
Normal file
28
src/views/admin/system/params/config/config.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
|
||||
export const paramTypeOptions: options[] = [
|
||||
{ label: "系统参数", value: 0 },
|
||||
{ label: "非系统参数", value: 1 },
|
||||
];
|
||||
|
||||
export type optionsType = "paramType" | "";
|
||||
|
||||
export function returnOptions(type: optionsType) {
|
||||
if (type === "paramType") {
|
||||
return paramTypeOptions;
|
||||
}
|
||||
}
|
||||
|
||||
export function returnOptionsLabel(optionsType: optionsType, value: string | number) {
|
||||
const options = returnOptions(optionsType);
|
||||
if (!options) {
|
||||
return "";
|
||||
}
|
||||
const option = options.find((item) => item.value === value);
|
||||
return option ? option.label : "";
|
||||
}
|
||||
|
||||
export interface options {
|
||||
label: string;
|
||||
value: string | number;
|
||||
[property: string]: any;
|
||||
}
|
||||
61
src/views/admin/system/params/config/content.ts
Normal file
61
src/views/admin/system/params/config/content.ts
Normal file
@@ -0,0 +1,61 @@
|
||||
import ParamsApi from "@/api/system/params";
|
||||
import type { editRequest } from "@/api/system/params";
|
||||
import type { IContentConfig } from "@/components/CURD/types";
|
||||
|
||||
const contentConfig: IContentConfig<editRequest> = {
|
||||
pageName: "sys:user",
|
||||
table: {
|
||||
border: true,
|
||||
highlightCurrentRow: true,
|
||||
},
|
||||
pagination: {
|
||||
background: true,
|
||||
layout: "prev,pager,next,jumper,total,sizes",
|
||||
pageSize: 20,
|
||||
pageSizes: [10, 20, 30, 50],
|
||||
},
|
||||
indexAction: function (params) {
|
||||
return ParamsApi.getList(params);
|
||||
},
|
||||
// modifyAction: function (data) {
|
||||
// // return ParamsApi.edit(data);
|
||||
// },
|
||||
pk: "id",
|
||||
toolbar: ["add"],
|
||||
defaultToolbar: ["refresh", "filter", "search"],
|
||||
cols: [
|
||||
{ type: "selection", width: 50, align: "center" },
|
||||
{
|
||||
label: "参数编码",
|
||||
align: "center",
|
||||
prop: "paramCode",
|
||||
},
|
||||
{
|
||||
label: "参数值",
|
||||
align: "center",
|
||||
prop: "paramValue",
|
||||
},
|
||||
{
|
||||
label: "参数类型",
|
||||
align: "center",
|
||||
prop: "paramType",
|
||||
templet: "custom",
|
||||
slotName: "options",
|
||||
},
|
||||
{
|
||||
label: "备注",
|
||||
align: "center",
|
||||
prop: "remark",
|
||||
},
|
||||
|
||||
{
|
||||
label: "操作",
|
||||
align: "center",
|
||||
fixed: "right",
|
||||
templet: "tool",
|
||||
operat: ["edit"],
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
export default contentConfig;
|
||||
133
src/views/admin/system/params/config/content2.ts
Normal file
133
src/views/admin/system/params/config/content2.ts
Normal file
@@ -0,0 +1,133 @@
|
||||
import type { IContentConfig } from "@/components/CURD/types";
|
||||
|
||||
const contentConfig: IContentConfig = {
|
||||
pageName: "sys:user",
|
||||
table: {
|
||||
showOverflowTooltip: true,
|
||||
},
|
||||
toolbar: [],
|
||||
indexAction: function (params) {
|
||||
// 模拟发起网络请求获取列表数据
|
||||
console.log("indexAction:", params);
|
||||
return Promise.resolve({
|
||||
total: 2,
|
||||
list: [
|
||||
{
|
||||
id: 1,
|
||||
username: "tom",
|
||||
avatar: "https://foruda.gitee.com/images/1723603502796844527/03cdca2a_716974.gif",
|
||||
percent: 99,
|
||||
price: 10,
|
||||
url: "https://www.baidu.com",
|
||||
icon: "el-icon-setting",
|
||||
gender: 1,
|
||||
status: 1,
|
||||
status2: 1,
|
||||
sort: 99,
|
||||
createTime: 1715647982437,
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
username: "jerry",
|
||||
avatar: "https://foruda.gitee.com/images/1723603502796844527/03cdca2a_716974.gif",
|
||||
percent: 88,
|
||||
price: 999,
|
||||
url: "https://www.google.com",
|
||||
icon: "el-icon-user",
|
||||
gender: 0,
|
||||
status: 0,
|
||||
status2: 0,
|
||||
sort: 0,
|
||||
createTime: 1715648977426,
|
||||
},
|
||||
],
|
||||
});
|
||||
},
|
||||
modifyAction(data) {
|
||||
// 模拟发起网络请求修改字段
|
||||
// console.log("modifyAction:", data);
|
||||
ElMessage.success(JSON.stringify(data));
|
||||
return Promise.resolve(null);
|
||||
},
|
||||
cols: [
|
||||
{ type: "index", width: 50, align: "center" },
|
||||
{ label: "ID", align: "center", prop: "id", show: false },
|
||||
{ label: "文本", align: "center", prop: "username" },
|
||||
{ label: "图片", align: "center", prop: "avatar", templet: "image" },
|
||||
{
|
||||
label: "百分比",
|
||||
align: "center",
|
||||
prop: "percent",
|
||||
templet: "percent",
|
||||
},
|
||||
{
|
||||
label: "货币符",
|
||||
align: "center",
|
||||
prop: "price",
|
||||
templet: "price",
|
||||
priceFormat: "$",
|
||||
},
|
||||
{ label: "链接", align: "center", prop: "url", width: 180, templet: "url" },
|
||||
{ label: "图标", align: "center", prop: "icon", templet: "icon" },
|
||||
{
|
||||
label: "列表值",
|
||||
align: "center",
|
||||
prop: "gender",
|
||||
templet: "list",
|
||||
selectList: { "0": "女", "1": "男" },
|
||||
},
|
||||
{
|
||||
label: "自定义",
|
||||
align: "center",
|
||||
prop: "status",
|
||||
templet: "custom",
|
||||
slotName: "status",
|
||||
},
|
||||
{
|
||||
label: "Switch",
|
||||
align: "center",
|
||||
prop: "status2",
|
||||
templet: "switch",
|
||||
activeValue: 1,
|
||||
inactiveValue: 0,
|
||||
activeText: "启用",
|
||||
inactiveText: "禁用",
|
||||
},
|
||||
{
|
||||
label: "输入框",
|
||||
align: "center",
|
||||
prop: "sort",
|
||||
templet: "input",
|
||||
inputType: "number",
|
||||
},
|
||||
{
|
||||
label: "日期格式化",
|
||||
align: "center",
|
||||
prop: "createTime",
|
||||
minWidth: 120,
|
||||
templet: "date",
|
||||
dateFormat: "YYYY/MM/DD HH:mm:ss",
|
||||
},
|
||||
{
|
||||
label: "操作栏",
|
||||
align: "center",
|
||||
fixed: "right",
|
||||
width: 220,
|
||||
templet: "tool",
|
||||
operat: [
|
||||
{
|
||||
name: "reset_pwd",
|
||||
auth: "password:reset",
|
||||
icon: "refresh-left",
|
||||
text: "重置密码",
|
||||
type: "primary",
|
||||
render(row) {
|
||||
return row.id === 1;
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
export default contentConfig;
|
||||
67
src/views/admin/system/params/config/edit.ts
Normal file
67
src/views/admin/system/params/config/edit.ts
Normal file
@@ -0,0 +1,67 @@
|
||||
import ParamsApi, { type addRequest } from "@/api/system/params";
|
||||
import type { IModalConfig } from "@/components/CURD/types";
|
||||
import { paramTypeOptions } from './config'
|
||||
const modalConfig: IModalConfig<addRequest> = {
|
||||
pageName: "sys:user",
|
||||
dialog: {
|
||||
title: "编辑系统参数",
|
||||
width: 800,
|
||||
draggable: true,
|
||||
},
|
||||
form: {
|
||||
labelWidth: 140,
|
||||
},
|
||||
formAction: function (data) {
|
||||
return ParamsApi.edit(data);
|
||||
},
|
||||
beforeSubmit(data) {
|
||||
console.log("提交之前处理", data);
|
||||
},
|
||||
formItems: [
|
||||
{
|
||||
label: "参数编码",
|
||||
prop: "paramCode",
|
||||
rules: [{ required: true, message: "请输入参数编码", trigger: "blur" }],
|
||||
type: "input",
|
||||
disabled: true,
|
||||
attrs: {
|
||||
placeholder: "请输入参数编码",
|
||||
},
|
||||
},
|
||||
{
|
||||
label: "参数值",
|
||||
prop: "paramValue",
|
||||
rules: [{ required: true, message: "请输入参数值", trigger: "blur" }],
|
||||
type: "input",
|
||||
attrs: {
|
||||
placeholder: "请输入参数值",
|
||||
},
|
||||
},
|
||||
{
|
||||
label: "参数类型",
|
||||
prop: "paramType",
|
||||
rules: [{ required: true, message: "请选择参数类型", trigger: "blur" }],
|
||||
type: "select",
|
||||
attrs: {
|
||||
placeholder: "请选择参数类型",
|
||||
},
|
||||
col: {
|
||||
xs: 24,
|
||||
sm: 12,
|
||||
},
|
||||
options: paramTypeOptions,
|
||||
},
|
||||
{
|
||||
type: "textarea",
|
||||
label: "备注",
|
||||
prop: "remark",
|
||||
rules: [{ required: true, message: "请输入备注", trigger: "blur" }],
|
||||
attrs: {
|
||||
placeholder: "请输入备注",
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
// 如果有异步数据会修改配置的,推荐用reactive包裹,而纯静态配置的可以直接导出
|
||||
export default reactive(modalConfig);
|
||||
24
src/views/admin/system/params/config/search.ts
Normal file
24
src/views/admin/system/params/config/search.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import type { ISearchConfig } from "@/components/CURD/types";
|
||||
import { paramTypeOptions } from './config'
|
||||
|
||||
const searchConfig: ISearchConfig = {
|
||||
pageName: "sys:user",
|
||||
formItems: [
|
||||
{
|
||||
type: "radio-button",
|
||||
label: "参数类型",
|
||||
prop: "type",
|
||||
attrs: {
|
||||
placeholder: "请选择参数类型",
|
||||
clearable: true,
|
||||
style: {
|
||||
width: "200px",
|
||||
},
|
||||
},
|
||||
options: paramTypeOptions,
|
||||
initialValue: paramTypeOptions[0].value
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
export default searchConfig;
|
||||
Reference in New Issue
Block a user