fix: 字典管理-配置:无搜索框问题(https://gitee.com/huge-dream/django-vue3-admin/issues/I6ZGNK)
This commit is contained in:
@@ -1,135 +1,144 @@
|
|||||||
import * as api from './api';
|
import * as api from './api';
|
||||||
import { dict, UserPageQuery, AddReq, DelReq, EditReq, CrudOptions, CreateCrudOptionsProps, CreateCrudOptionsRet } from '@fast-crud/fast-crud';
|
import {
|
||||||
import { dictionary } from '/@/utils/dictionary';
|
dict,
|
||||||
|
UserPageQuery,
|
||||||
|
AddReq,
|
||||||
|
DelReq,
|
||||||
|
EditReq,
|
||||||
|
CrudOptions,
|
||||||
|
CreateCrudOptionsProps,
|
||||||
|
CreateCrudOptionsRet
|
||||||
|
} from '@fast-crud/fast-crud';
|
||||||
|
import {dictionary} from '/@/utils/dictionary';
|
||||||
|
|
||||||
export const createCrudOptions = function ({ crudExpose, context }: CreateCrudOptionsProps): CreateCrudOptionsRet {
|
export const createCrudOptions = function ({crudExpose, context}: CreateCrudOptionsProps): CreateCrudOptionsRet {
|
||||||
const pageRequest = async (query: UserPageQuery) => {
|
const pageRequest = async (query: UserPageQuery) => {
|
||||||
return await api.GetList(query);
|
return await api.GetList(query);
|
||||||
};
|
};
|
||||||
const editRequest = async ({ form, row }: EditReq) => {
|
const editRequest = async ({form, row}: EditReq) => {
|
||||||
form.id = row.id;
|
form.id = row.id;
|
||||||
return await api.UpdateObj(form);
|
return await api.UpdateObj(form);
|
||||||
};
|
};
|
||||||
const delRequest = async ({ row }: DelReq) => {
|
const delRequest = async ({row}: DelReq) => {
|
||||||
return await api.DelObj(row.id);
|
return await api.DelObj(row.id);
|
||||||
};
|
};
|
||||||
const addRequest = async ({ form }: AddReq) => {
|
const addRequest = async ({form}: AddReq) => {
|
||||||
const data = crudExpose.getSearchFormData()
|
const data = crudExpose.getSearchFormData()
|
||||||
const parent = data.parent
|
const parent = data.parent
|
||||||
form.parent = parent
|
form.parent = parent
|
||||||
if(parent){
|
if (parent) {
|
||||||
return await api.AddObj(form);
|
return await api.AddObj(form);
|
||||||
}else{
|
} else {
|
||||||
return undefined
|
return undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
crudOptions: {
|
crudOptions: {
|
||||||
request: {
|
request: {
|
||||||
pageRequest,
|
pageRequest,
|
||||||
addRequest,
|
addRequest,
|
||||||
editRequest,
|
editRequest,
|
||||||
delRequest,
|
delRequest,
|
||||||
},
|
},
|
||||||
rowHandle: {
|
rowHandle: {
|
||||||
//固定右侧
|
//固定右侧
|
||||||
fixed: 'right',
|
fixed: 'right',
|
||||||
width: 200,
|
width: 200,
|
||||||
buttons: {
|
buttons: {
|
||||||
view: {
|
view: {
|
||||||
show: false,
|
show: false,
|
||||||
},
|
},
|
||||||
edit: {
|
edit: {
|
||||||
iconRight: 'Edit',
|
iconRight: 'Edit',
|
||||||
type: 'text',
|
type: 'text',
|
||||||
},
|
},
|
||||||
remove: {
|
remove: {
|
||||||
iconRight: 'Delete',
|
iconRight: 'Delete',
|
||||||
type: 'text',
|
type: 'text',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
columns: {
|
columns: {
|
||||||
_index: {
|
_index: {
|
||||||
title: '序号',
|
title: '序号',
|
||||||
form: { show: false },
|
form: {show: false},
|
||||||
column: {
|
column: {
|
||||||
//type: 'index',
|
//type: 'index',
|
||||||
align: 'center',
|
align: 'center',
|
||||||
width: '70px',
|
width: '70px',
|
||||||
columnSetDisabled: true, //禁止在列设置中选择
|
columnSetDisabled: true, //禁止在列设置中选择
|
||||||
formatter: (context) => {
|
formatter: (context) => {
|
||||||
//计算序号,你可以自定义计算规则,此处为翻页累加
|
//计算序号,你可以自定义计算规则,此处为翻页累加
|
||||||
let index = context.index ?? 1;
|
let index = context.index ?? 1;
|
||||||
let pagination = crudExpose!.crudBinding.value.pagination;
|
let pagination = crudExpose!.crudBinding.value.pagination;
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
return ((pagination.currentPage ?? 1) - 1) * pagination.pageSize + index + 1;
|
return ((pagination.currentPage ?? 1) - 1) * pagination.pageSize + index + 1;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
label: {
|
label: {
|
||||||
title: '名称',
|
title: '名称',
|
||||||
search: {
|
search: {
|
||||||
disabled: false,
|
show: true,
|
||||||
component: {
|
component: {
|
||||||
props: {
|
props: {
|
||||||
clearable: true,
|
clearable: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
type: 'input',
|
type: 'input',
|
||||||
form: {
|
form: {
|
||||||
rules: [
|
rules: [
|
||||||
// 表单校验规则
|
// 表单校验规则
|
||||||
{ required: true, message: '名称必填项' },
|
{required: true, message: '名称必填项'},
|
||||||
],
|
],
|
||||||
component: {
|
component: {
|
||||||
props: {
|
props: {
|
||||||
clearable: true,
|
clearable: true,
|
||||||
},
|
},
|
||||||
placeholder: '请输入名称',
|
placeholder: '请输入名称',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
type: {
|
type: {
|
||||||
title: '数据值类型',
|
title: '数据值类型',
|
||||||
type: 'dict-select',
|
type: 'dict-select',
|
||||||
search: {
|
search: {
|
||||||
disabled: true,
|
disabled: true,
|
||||||
component: {
|
component: {
|
||||||
props: {
|
props: {
|
||||||
clearable: true,
|
clearable: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
show: false,
|
show: false,
|
||||||
dict: dict({
|
dict: dict({
|
||||||
data: [
|
data: [
|
||||||
{ label: 'text', value: 0 },
|
{label: 'text', value: 0},
|
||||||
{ label: 'number', value: 1 },
|
{label: 'number', value: 1},
|
||||||
{ label: 'date', value: 2 },
|
{label: 'date', value: 2},
|
||||||
{ label: 'datetime', value: 3 },
|
{label: 'datetime', value: 3},
|
||||||
{ label: 'time', value: 4 },
|
{label: 'time', value: 4},
|
||||||
{ label: 'file', value: 5 },
|
{label: 'file', value: 5},
|
||||||
{ label: 'boolean', value: 6 },
|
{label: 'boolean', value: 6},
|
||||||
{ label: 'images', value: 7 },
|
{label: 'images', value: 7},
|
||||||
],
|
],
|
||||||
}),
|
}),
|
||||||
form: {
|
form: {
|
||||||
rules: [
|
rules: [
|
||||||
// 表单校验规则
|
// 表单校验规则
|
||||||
{ required: true, message: '数据值类型必填项' },
|
{required: true, message: '数据值类型必填项'},
|
||||||
],
|
],
|
||||||
value: 0,
|
value: 0,
|
||||||
component: {
|
component: {
|
||||||
props: {
|
props: {
|
||||||
clearable: true,
|
clearable: true,
|
||||||
},
|
},
|
||||||
placeholder: '请选择数据值类型',
|
placeholder: '请选择数据值类型',
|
||||||
},
|
},
|
||||||
/* valueChange(key, value, form, { getColumn, mode, component, immediate, getComponent }) {
|
/* valueChange(key, value, form, { getColumn, mode, component, immediate, getComponent }) {
|
||||||
const template = vm.getEditFormTemplate('value')
|
const template = vm.getEditFormTemplate('value')
|
||||||
// 选择框重新选择后,情况value值
|
// 选择框重新选择后,情况value值
|
||||||
if (!immediate) {
|
if (!immediate) {
|
||||||
@@ -178,22 +187,22 @@ export const createCrudOptions = function ({ crudExpose, context }: CreateCrudOp
|
|||||||
template.component.props = { accept: '.png,.jpeg,.jpg,.ico,.bmp,.gif', cropper: { viewMode: 1 } }
|
template.component.props = { accept: '.png,.jpeg,.jpg,.ico,.bmp,.gif', cropper: { viewMode: 1 } }
|
||||||
}
|
}
|
||||||
}, */
|
}, */
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
value: {
|
value: {
|
||||||
title: '数据值',
|
title: '数据值',
|
||||||
search: {
|
search: {
|
||||||
disabled: true,
|
show: true,
|
||||||
component: {
|
component: {
|
||||||
props: {
|
props: {
|
||||||
clearable: true,
|
clearable: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
view: {
|
view: {
|
||||||
component: { props: { height: 100, width: 100 } },
|
component: {props: {height: 100, width: 100}},
|
||||||
},
|
},
|
||||||
/* // 提交时,处理数据
|
/* // 提交时,处理数据
|
||||||
valueResolve(row: any, col: any) {
|
valueResolve(row: any, col: any) {
|
||||||
const value = row[col.key]
|
const value = row[col.key]
|
||||||
const type = row.type
|
const type = row.type
|
||||||
@@ -225,76 +234,76 @@ export const createCrudOptions = function ({ crudExpose, context }: CreateCrudOp
|
|||||||
row[col.key] = value
|
row[col.key] = value
|
||||||
}
|
}
|
||||||
}, */
|
}, */
|
||||||
type: 'input',
|
type: 'input',
|
||||||
form: {
|
form: {
|
||||||
rules: [
|
rules: [
|
||||||
// 表单校验规则
|
// 表单校验规则
|
||||||
{ required: true, message: '数据值必填项' },
|
{required: true, message: '数据值必填项'},
|
||||||
],
|
],
|
||||||
component: {
|
component: {
|
||||||
props: {
|
props: {
|
||||||
clearable: true,
|
clearable: true,
|
||||||
},
|
},
|
||||||
placeholder: '请输入数据值',
|
placeholder: '请输入数据值',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
status: {
|
status: {
|
||||||
title: '状态',
|
title: '状态',
|
||||||
width: 80,
|
width: 80,
|
||||||
search: {
|
search: {
|
||||||
disabled: false,
|
show: true
|
||||||
},
|
},
|
||||||
type: 'dict-radio',
|
type: 'dict-radio',
|
||||||
dict: dict({
|
dict: dict({
|
||||||
data: dictionary('button_status_bool'),
|
data: dictionary('button_status_bool'),
|
||||||
}),
|
}),
|
||||||
form: {
|
form: {
|
||||||
value: true,
|
value: true,
|
||||||
rules: [
|
rules: [
|
||||||
// 表单校验规则
|
// 表单校验规则
|
||||||
{ required: true, message: '状态必填项' },
|
{required: true, message: '状态必填项'},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
sort: {
|
sort: {
|
||||||
title: '排序',
|
title: '排序',
|
||||||
width: 70,
|
width: 70,
|
||||||
type: 'number',
|
type: 'number',
|
||||||
form: {
|
form: {
|
||||||
value: 1,
|
value: 1,
|
||||||
component: {},
|
component: {},
|
||||||
rules: [
|
rules: [
|
||||||
// 表单校验规则
|
// 表单校验规则
|
||||||
{ required: true, message: '排序必填项' },
|
{required: true, message: '排序必填项'},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
color: {
|
color: {
|
||||||
title: '标签颜色',
|
title: '标签颜色',
|
||||||
width: 90,
|
width: 90,
|
||||||
search: {
|
search: {
|
||||||
disabled: true,
|
disabled: true,
|
||||||
},
|
},
|
||||||
type: 'dict-select',
|
type: 'dict-select',
|
||||||
dict: dict({
|
dict: dict({
|
||||||
data: [
|
data: [
|
||||||
{ label: 'success', value: 'success', color: 'success' },
|
{label: 'success', value: 'success', color: 'success'},
|
||||||
{ label: 'primary', value: 'primary', color: 'primary' },
|
{label: 'primary', value: 'primary', color: 'primary'},
|
||||||
{ label: 'info', value: 'info', color: 'info' },
|
{label: 'info', value: 'info', color: 'info'},
|
||||||
{ label: 'danger', value: 'danger', color: 'danger' },
|
{label: 'danger', value: 'danger', color: 'danger'},
|
||||||
{ label: 'warning', value: 'warning', color: 'warning' },
|
{label: 'warning', value: 'warning', color: 'warning'},
|
||||||
],
|
],
|
||||||
}),
|
}),
|
||||||
form: {
|
form: {
|
||||||
component: {
|
component: {
|
||||||
props: {
|
props: {
|
||||||
clearable: true,
|
clearable: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user