123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209 |
- import type { CreateCrudOptionsProps, CreateCrudOptionsRet } from '@fast-crud/fast-crud';
- import { dict } from '@fast-crud/fast-crud';
- import _ from 'lodash';
- import { isString } from '~/src/utils';
- import type { UserList } from './api';
- import { addRequest, delRequest, editRequest, pageRequest, queryAll } from './api';
- const userList: UserList = await queryAll();
- const dictOpt = {
- url: '/userinfo/queryAll',
- label: 'relname',
- value: 'id'
- };
- function curd({ context }: CreateCrudOptionsProps): CreateCrudOptionsRet {
- const openModel = context?.openModel;
- return {
- crudOptions: {
- request: {
- pageRequest: async ({ page, query }) => {
- const { total, data } = await pageRequest(page.offset + 1, page.limit, query);
- return { records: data, total, currentPage: page.offset, pageSize: page.limit };
- },
- addRequest: ({ form }) => {
- return addRequest(form);
- },
- editRequest: ({ form }) => {
- editRequest(form);
- },
- delRequest: ({ row }) => {
- return delRequest(row.id);
- }
- },
- toolbar: {
- show: true
- },
- actionbar: {
- show: true,
- buttons: {
- add: {
- text: '新增班级',
- title: '使用表单新增班级',
- circle: false,
- tooltip: {
- slots: {
- default() {
- return '使用表单新增班级';
- }
- }
- }
- }
- }
- },
- form: {
- beforeSubmit: localContext => {
- if (isString(localContext.form.createUid)) {
- localContext.form.createUid = null;
- }
- if (isString(localContext.form.manageId)) {
- localContext.form.manageId = null;
- }
- return true;
- }
- },
- columns: {
- id: {
- title: '班级ID',
- type: 'text',
- search: { show: true },
- form: {
- show: false
- },
- column: {
- resizable: true,
- width: 120,
- align: 'center',
- fixed: 'left'
- }
- },
- name: {
- title: '班级名称',
- type: 'text',
- search: {
- title: '名称',
- show: true
- },
- column: {
- resizable: true,
- width: 60,
- align: 'center',
- fixed: 'left'
- }
- },
- createUid: {
- title: '创建用户',
- type: 'text',
- valueBuilder(localContext) {
- if (userList[localContext.row.createUid]) {
- localContext.row.createUid = userList[localContext.row.createUid];
- }
- },
- form: {
- component: {
- name: 'fs-dict-select',
- dict: dict(dictOpt)
- }
- },
- search: { show: false },
- column: {
- resizable: true,
- width: 90,
- align: 'center',
- fixed: 'left'
- }
- },
- manageId: {
- title: '负责人',
- type: 'text',
- valueBuilder(localContext) {
- if (userList[localContext.row.manageId]) {
- localContext.row.manageId = userList[localContext.row.manageId];
- }
- },
- form: {
- component: {
- name: 'fs-dict-select',
- dict: dict(dictOpt)
- }
- },
- search: { show: false },
- column: {
- resizable: true,
- width: 90,
- align: 'center',
- fixed: 'left'
- }
- },
- modifyTime: {
- title: '更新时间',
- type: 'easDateTime',
- search: { show: false },
- form: { show: false },
- column: {
- resizable: true,
- width: 110,
- align: 'center',
- fixed: 'left'
- }
- },
- createTime: {
- title: '创建时间',
- type: 'easDateTime',
- search: { show: true },
- form: { show: false },
- column: {
- resizable: true,
- width: 110,
- align: 'center',
- fixed: 'left'
- }
- },
- disabled: {
- title: '状态',
- type: 'dict-select',
- dict: dict({
- data: [
- { value: 'N', label: '启用中' },
- { value: 'Y', label: '已禁用' }
- ]
- }),
- column: {
- resizable: true,
- width: 80
- }
- }
- },
- rowHandle: {
- buttons: {
- studentManager: {
- text: null,
- size: 'small',
- icon: 'raphael:people',
- tooltip: {
- slots: {
- default() {
- return '管理学员';
- }
- }
- },
- click: ({ row }) => {
- openModel(row.id);
- }
- },
- schedule: {
- text: null,
- size: 'small',
- icon: 'uil:schedule',
- tooltip: {
- slots: {
- default() {
- return '查看排课计划';
- }
- }
- }
- }
- }
- }
- }
- };
- }
- export default curd;
|