|
@@ -0,0 +1,233 @@
|
|
|
+import { AddReq, CreateCrudOptionsProps, CreateCrudOptionsRet, dict, 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 getDetail = async ({ row }: InfoReq) => {
|
|
|
+ return await api.GetObj(row.id);
|
|
|
+ };
|
|
|
+
|
|
|
+ // 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,
|
|
|
+ getDetail,
|
|
|
+ },
|
|
|
+ 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, //禁止在列设置中选择
|
|
|
+ },
|
|
|
+ },
|
|
|
+ user_code:{
|
|
|
+ title:'学号',
|
|
|
+ type:'input',
|
|
|
+ column: {
|
|
|
+ minWidth: 120,
|
|
|
+ },
|
|
|
+ form: {
|
|
|
+ component: { placeholder: '请填写学号' },
|
|
|
+ rules: [{ required: true, message: '请填写学号' }],
|
|
|
+ },
|
|
|
+ },
|
|
|
+ username:{
|
|
|
+ title:'昵称',
|
|
|
+ type:'input',
|
|
|
+ column: {
|
|
|
+ show: false,
|
|
|
+ minWidth: 120,
|
|
|
+ },
|
|
|
+ form: {
|
|
|
+ component: { placeholder: '请填写昵称' },
|
|
|
+ rules: [{ required: true, message: '请填写昵称' }],
|
|
|
+ },
|
|
|
+ },
|
|
|
+ name: {
|
|
|
+ title: '名称',
|
|
|
+ search: {
|
|
|
+ show: true,
|
|
|
+ },
|
|
|
+ treeNode: true,
|
|
|
+ type: 'input',
|
|
|
+ column: {
|
|
|
+ minWidth: 120,
|
|
|
+ },
|
|
|
+ form: {
|
|
|
+ rules: [
|
|
|
+ // 表单校验规则
|
|
|
+ { required: true, message: '名称必填项' },
|
|
|
+ ],
|
|
|
+ component: {
|
|
|
+ placeholder: '请输入名称',
|
|
|
+ },
|
|
|
+ },
|
|
|
+ },
|
|
|
+ password:{
|
|
|
+ title: '密码',
|
|
|
+ type: 'input',
|
|
|
+ column: {
|
|
|
+ minWidth: 120,
|
|
|
+ show: false,
|
|
|
+ },
|
|
|
+ form: {
|
|
|
+ component: { placeholder: '请填写密码' },
|
|
|
+ rules: [{ required: true, message: '请填写密码' }],
|
|
|
+ },
|
|
|
+ },
|
|
|
+ email:{
|
|
|
+ title: '邮箱',
|
|
|
+ type: 'input',
|
|
|
+ column: {
|
|
|
+ show: false,
|
|
|
+ minWidth: 120,
|
|
|
+ },
|
|
|
+ form: {
|
|
|
+ component: { placeholder: '请填写邮箱' },
|
|
|
+ rules: [{ required: false, message: '请填写邮箱' }],
|
|
|
+ },
|
|
|
+ },
|
|
|
+ mobile:{
|
|
|
+ title: '手机号',
|
|
|
+ type: 'input',
|
|
|
+ column: {
|
|
|
+ show: false,
|
|
|
+ minWidth: 120,
|
|
|
+ },
|
|
|
+ form: {
|
|
|
+ component: { placeholder: '请填写手机号' },
|
|
|
+ rules: [{ required: true, message: '请填写手机号' }],
|
|
|
+ },
|
|
|
+ },
|
|
|
+ gender:{
|
|
|
+ title: '性别',
|
|
|
+ type: 'dict-select',
|
|
|
+ column: {
|
|
|
+ show: false,
|
|
|
+ minWidth: 120,
|
|
|
+ },
|
|
|
+ dict: dict({
|
|
|
+ data: [
|
|
|
+ { label: '男', value: 1 },
|
|
|
+ { label: '女', value: 2 },
|
|
|
+ ],
|
|
|
+ }),
|
|
|
+ form: {
|
|
|
+ component: { placeholder: '请选择性别' },
|
|
|
+ rules: [{ required: true, message: '请选择性别' }],
|
|
|
+ },
|
|
|
+ },
|
|
|
+ user_type:{
|
|
|
+ title: '用户类型',
|
|
|
+ type: 'dict-select',
|
|
|
+ column: {
|
|
|
+ minWidth: 120,
|
|
|
+ },
|
|
|
+ dict: dict({
|
|
|
+ data: [
|
|
|
+ { label: '学生', value: 0 },
|
|
|
+ { label: '教师', value: 1 },
|
|
|
+ { label: '校外团体', value: 2 },
|
|
|
+ ],
|
|
|
+ }),
|
|
|
+ form: {
|
|
|
+ component: { placeholder: '请填写租户' },
|
|
|
+ rules: [{ required: false, message: '请填写租户' }],
|
|
|
+ },
|
|
|
+ },
|
|
|
+ organization:{
|
|
|
+ title: '学院',
|
|
|
+ type: 'input',
|
|
|
+ column: {
|
|
|
+ show: true,
|
|
|
+ minWidth: 120,
|
|
|
+ },
|
|
|
+ form: {
|
|
|
+ component: { placeholder: '请填写学院' },
|
|
|
+ rules: [{ required: false, message: '请填写学院' }],
|
|
|
+ },
|
|
|
+ },
|
|
|
+ sub_organization:{
|
|
|
+ title: '专业',
|
|
|
+ type: 'input',
|
|
|
+ column: {
|
|
|
+ show: true,
|
|
|
+ minWidth: 120,
|
|
|
+ },
|
|
|
+ form: {
|
|
|
+ component: { placeholder: '请填写专业' },
|
|
|
+ rules: [{ required: false, message: '请填写专业' }],
|
|
|
+ },
|
|
|
+ },
|
|
|
+ grade_or_level:{
|
|
|
+ title: '年级',
|
|
|
+ type: 'input',
|
|
|
+ column: {
|
|
|
+ show: true,
|
|
|
+ minWidth: 120,
|
|
|
+ },
|
|
|
+ form: {
|
|
|
+ component: { placeholder: '请填写年级' },
|
|
|
+ rules: [{ required: false, message: '请填写年级' }],
|
|
|
+ },
|
|
|
+ },
|
|
|
+ class_or_group:{
|
|
|
+ title: '班级',
|
|
|
+ type: 'input',
|
|
|
+ column: {
|
|
|
+ show: true,
|
|
|
+ minWidth: 120,
|
|
|
+ },
|
|
|
+ form: {
|
|
|
+ component: { placeholder: '请填写班级' },
|
|
|
+ rules: [{ required: false, message: '请填写班级' }],
|
|
|
+ },
|
|
|
+ },
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ },
|
|
|
+ },
|
|
|
+ };
|
|
|
+};
|