123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 |
- import { AddReq, CreateCrudOptionsProps, CreateCrudOptionsRet, UserPageQuery } from '@fast-crud/fast-crud';
- import * as api from './api';
- import { auth } from '/@/utils/authFunction';
- export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProps): CreateCrudOptionsRet {
- const pageRequest = async (query: UserPageQuery) => {
- return await api.GetList(query);
- };
- // const editRequest = async ({ form, row }: EditReq) => {
- // form.id = row.id;
- // return await api.UpdateObj(form);
- // };
- // const delRequest = async ({ row }: DelReq) => {
- // return await api.DelObj(row.id);
- // };
- const addRequest = async ({ form }: AddReq) => {
- return await api.AddObj(form);
- };
- /**
- * 懒加载
- * @param row
- * @returns {Promise<unknown>}
- */
- // const loadContentMethod = (tree: any, treeNode: any, resolve: Function) => {
- // pageRequest({ pcode: tree.code }).then((res: APIResponseData) => {
- // resolve(res.data);
- // });
- // };
- return {
- crudOptions: {
- request: {
- pageRequest,
- addRequest,
- },
- actionbar: {
- buttons: {
- add: {
- show: auth('area:Create'),
- },
- },
- },
- pagination: {
- show: false,
- },
- columns: {
- _index: {
- title: '序号',
- form: { show: false },
- column: {
- type: 'index',
- align: 'center',
- width: '70px',
- columnSetDisabled: true, //禁止在列设置中选择
- },
- },
- name: {
- title: '名称',
- search: {
- show: true,
- },
- treeNode: true,
- type: 'input',
- column: {
- minWidth: 120,
- },
- form: {
- rules: [
- // 表单校验规则
- { required: true, message: '名称必填项' },
- ],
- component: {
- placeholder: '请输入名称',
- },
- },
- },
- color:{
- title: '颜色',
- type: 'input',
- column: {
- minWidth: 120,
- },
- form: {
- component: { placeholder: '请填写标签颜色' },
- rules: [{ required: true, message: '请填写标签颜色' }],
- },
- },
- description:{
- title: '标签描述',
- type: 'input',
- column: {
- minWidth: 120,
- },
- form: {
- component: { placeholder: '请填写标签描述' },
- rules: [{ required: true, message: '请填写标签描述' }],
- },
- },
- sort:{
- title: '排序',
- type: 'input',
- column: {
- minWidth: 120,
- },
- form: {
- component: { placeholder: '请填写排序' },
- rules: [{ required: true, message: '请填写排序' }],
- },
- },
- },
- },
- };
- };
|