import { AddReq, CreateCrudOptionsProps, CreateCrudOptionsRet, UserPageQuery } from '@fast-crud/fast-crud';
import * as api from './api';

export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProps): CreateCrudOptionsRet {
	const pageRequest = async (query: UserPageQuery) => {
		return await api.GetList(query);
	};

		const getDetail = async ({ row }: InfoReq) => {
		return await api.GetObj(row.id);
	};


	const addRequest = async ({ form }: AddReq) => {
		return await api.AddObj(form);
	};

	let a="test";

	return {
		crudOptions: {
			layout: 'custom',
			request: {
				pageRequest,
				addRequest,
				getDetail,
			},
			search:{
				show: false,
			},
			toolbar:{
				show: false,
			},
			rowHandle:{
				show: false,
			},
			table:{
				show:false,
			},
			actionbar: {
				show:false,
				buttons: {
					add: {
						show:false,
						// show: auth('area:Create'),
					},
				},
			},
			pagination: {
				show: true,
			},		
			columns: {
				search:{
					title: '关键字搜索',
					search: { show: true,type: 'input', },
					type: 'input',
					form: {
						component: { placeholder: '请输入' },
						show:false},
					column: {show:false}
				},
				classroom:{
					title:'教室',
					type:'input',
					column: {
						minWidth: 120,
					},
					form: {
						component: { placeholder: '请填写教室' },
						rules: [{ required: true, message: '请填写教室' }],
					},
				},
				teacher_name:{
					title:'教师名字'+a,
					type:'input',
					column: {
						show: true,
						minWidth: 120,
					},
					form: {
						component: { placeholder: '请填写教师名字' },
						rules: [{ required: true, message: '请填写教师名字' }],
					},
				},
				datetime_label: {
					title: '星期',
					search: {
						show: true,
					},
					treeNode: true,
					type: 'input',
					column: {
						minWidth: 120,
					},
					form: {
						rules: [
							// 表单校验规则
							{ required: true, message: '名称必填项' },
						],
						component: {
							placeholder: '请输入名称',
						},
					},
				},
				time_label:{
					title: '上下午',
					type: 'input',
					column: {
						minWidth: 120,
						show: true,
					},
					form: {
						component: { placeholder: '请填写密码' },
						rules: [{ required: true, message: '请填写密码' }],
					},
				},
				semester_label:{
					title: '学期',
					type: 'input',
					column: {
						show: true,
						minWidth: 120,
					},
					form: {
						component: { placeholder: '请填写邮箱' },
						rules: [{ required: false, message: '请填写邮箱' }],
					},
				},
				classdetail:{
					title: '课程名称',
					type: 'input',
					column: {
						show: true,
						minWidth: 120,
					},
					form: {
						component: { placeholder: '请填写手机号' },
						rules: [{ required: true, message: '请填写手机号' }],
					},
				},
				
				



			},
		},
	};
};
