feat: 所有菜单页面状态改为可编辑开关

This commit is contained in:
H0nGzA1
2023-03-30 18:12:38 +08:00
parent 6917786864
commit af7bfcd215
7 changed files with 114 additions and 65 deletions

View File

@@ -0,0 +1,9 @@
/*
*
* 后端API接口响应数据
*/
interface APIResponseData {
code?: number;
data: [];
msg?: string;
}

View File

@@ -1,7 +1,8 @@
import * as api from './api';
import { dict, PageQuery, AddReq, DelReq, EditReq, CrudExpose, CrudOptions } from '@fast-crud/fast-crud';
import { dict, PageQuery, AddReq, DelReq, EditReq, CrudExpose, CrudOptions, compute } from '@fast-crud/fast-crud';
import { request } from '/@/utils/service';
import { dictionary } from '/@/utils/dictionary';
import { successMessage } from '/@/utils/message';
interface CreateCrudOptionsTypes {
crudOptions: CrudOptions;
}
@@ -189,12 +190,24 @@ export const createCrudOptions = function ({ crudExpose }: { crudExpose: CrudExp
},
width: 90,
type: 'dict-radio',
column: {
component: {
name: 'fs-dict-switch',
activeText: '',
inactiveText: '',
style: '--el-switch-on-color: #409eff; --el-switch-off-color: #dcdfe6',
onChange: compute((context) => {
return () => {
api.UpdateObj(context.row).then((res: APIResponseData) => {
successMessage(res.msg as string);
});
};
}),
},
},
dict: dict({
data: dictionary('button_status_bool'),
}),
form: {
value: true,
},
},
},
},

View File

@@ -1,8 +1,9 @@
import * as api from './api';
import { dict, PageQuery, AddReq, DelReq, EditReq, CrudExpose, CrudOptions } from '@fast-crud/fast-crud';
import { dict, PageQuery, AddReq, DelReq, EditReq, CrudExpose, CrudOptions, compute } from '@fast-crud/fast-crud';
import { verifyPhone } from '/@/utils/toolsValidate';
import { request } from '/@/utils/service';
import { dictionary } from '/@/utils/dictionary';
import { successMessage } from '/@/utils/message';
interface CreateCrudOptionsTypes {
crudOptions: CrudOptions;
}
@@ -229,16 +230,24 @@ export const createCrudOptions = function ({ crudExpose }: { crudExpose: CrudExp
disabled: false,
},
type: 'dict-radio',
column: {
component: {
name: 'fs-dict-switch',
activeText: '',
inactiveText: '',
style: '--el-switch-on-color: #409eff; --el-switch-off-color: #dcdfe6',
onChange: compute((context) => {
return () => {
api.UpdateObj(context.row).then((res: APIResponseData) => {
successMessage(res.msg as string);
});
};
}),
},
},
dict: dict({
data: dictionary('button_status_bool'),
}),
form: {
value: true,
component: {
span: 12,
placeholder: '请选择状态',
},
},
},
},
},

View File

@@ -1,7 +1,8 @@
import * as api from './api';
import { dict, PageQuery, AddReq, DelReq, EditReq, CrudExpose, CrudOptions } from '@fast-crud/fast-crud';
import { dict, PageQuery, AddReq, DelReq, EditReq, CrudExpose, CrudOptions, compute } from '@fast-crud/fast-crud';
import { dictionary } from '/@/utils/dictionary';
import { nextTick, ref } from 'vue';
import { successMessage } from '/@/utils/message';
interface CreateCrudOptionsTypes {
crudOptions: CrudOptions;
@@ -163,24 +164,24 @@ export const createCrudOptions = function ({ crudExpose, subDictRef }: { crudExp
show: true,
},
type: 'dict-radio',
column: {
component: {
name: 'fs-dict-switch',
activeText: '',
inactiveText: '',
style: '--el-switch-on-color: #409eff; --el-switch-off-color: #dcdfe6',
onChange: compute((context) => {
return () => {
api.UpdateObj(context.row).then((res: APIResponseData) => {
successMessage(res.msg as string);
});
};
}),
},
},
dict: dict({
data: dictionary('button_status_bool'),
}),
component: {
props: {
options: [],
},
},
form: {
rules: [
// 表单校验规则
{ required: true, message: '状态必填项' },
],
value: true,
component: {
placeholder: '请选择状态',
},
},
},
sort: {
title: '排序',

View File

@@ -1,6 +1,8 @@
import { CrudOptions, AddReq, DelReq, EditReq, dict, CrudExpose } from '@fast-crud/fast-crud';
import { CrudOptions, AddReq, DelReq, EditReq, dict, CrudExpose, compute } from '@fast-crud/fast-crud';
import _ from 'lodash-es';
import * as api from './api';
import { dictionary } from '/@/utils/dictionary';
import { successMessage } from '../../../utils/message';
interface CreateCrudOptionsTypes {
crudOptions: CrudOptions;
}
@@ -167,28 +169,24 @@ export const createCrudOptions = function ({ crudExpose, rolePermission }: { cru
title: '状态',
search: { show: true },
type: 'dict-radio',
dict: dict({
data: [
{
label: '启用',
value: true,
color: 'success',
},
{
label: '禁用',
value: false,
color: 'danger',
},
],
}),
column: {
width: 90,
sortable: 'custom',
component: {
name: 'fs-dict-switch',
activeText: '',
inactiveText: '',
style: '--el-switch-on-color: #409eff; --el-switch-off-color: #dcdfe6',
onChange: compute((context) => {
return () => {
api.UpdateObj(context.row).then((res: APIResponseData) => {
successMessage(res.msg as string);
});
};
}),
},
form: {
rules: [{ required: true, message: '状态必填' }],
value: true,
},
dict: dict({
data: dictionary('button_status_bool'),
}),
},
update_datetime: {
title: '更新时间',

View File

@@ -1,7 +1,8 @@
import * as api from './api';
import { dict, PageQuery, AddReq, DelReq, EditReq, CrudExpose, CrudOptions } from '@fast-crud/fast-crud';
import { dict, PageQuery, AddReq, DelReq, EditReq, CrudExpose, CrudOptions, compute } from '@fast-crud/fast-crud';
import { request } from '/@/utils/service';
import { dictionary } from '/@/utils/dictionary';
import { successMessage } from '/@/utils/message';
interface CreateCrudOptionsTypes {
crudOptions: CrudOptions;
}
@@ -282,15 +283,24 @@ export const createCrudOptions = function ({ crudExpose }: { crudExpose: CrudExp
show: true,
},
type: 'dict-radio',
column: {
component: {
name: 'fs-dict-switch',
activeText: '',
inactiveText: '',
style: '--el-switch-on-color: #409eff; --el-switch-off-color: #dcdfe6',
onChange: compute((context) => {
return () => {
api.UpdateObj(context.row).then((res: APIResponseData) => {
successMessage(res.msg as string);
});
};
}),
},
},
dict: dict({
data: dictionary('button_status_bool'),
}),
form: {
value: true,
component: {
span: 12,
},
},
},
avatar: {
title: '头像',

View File

@@ -1,7 +1,8 @@
import * as api from './api';
import { dict, PageQuery, AddReq, DelReq, EditReq, CrudExpose, CrudOptions } from '@fast-crud/fast-crud';
import { dict, PageQuery, AddReq, DelReq, EditReq, CrudExpose, CrudOptions, compute } from '@fast-crud/fast-crud';
import { request } from '/@/utils/service';
import { dictionary } from '/@/utils/dictionary';
import { successMessage } from '/@/utils/message';
interface CreateCrudOptionsTypes {
crudOptions: CrudOptions;
}
@@ -63,6 +64,7 @@ export const createCrudOptions = function ({ crudExpose }: { crudExpose: CrudExp
align: 'center',
width: '70px',
columnSetDisabled: true, //禁止在列设置中选择
//@ts-ignore
formatter: (context) => {
//计算序号,你可以自定义计算规则,此处为翻页累加
let index = context.index ?? 1;
@@ -198,18 +200,25 @@ export const createCrudOptions = function ({ crudExpose }: { crudExpose: CrudExp
search: {
disabled: false,
},
width: 150,
type: 'dict-radio',
column: {
component: {
name: 'fs-dict-switch',
activeText: '',
inactiveText: '',
style: '--el-switch-on-color: #409eff; --el-switch-off-color: #dcdfe6',
onChange: compute((context) => {
return () => {
api.UpdateObj(context.row).then((res: APIResponseData) => {
successMessage(res.msg as string);
});
};
}),
},
},
dict: dict({
data: dictionary('button_status_bool'),
}),
form: {
value: true,
rules: [{ required: true, message: '必填项' }],
component: {
span: 12,
},
},
},
},
},