import { ComoDialogOptions, ComoFormParams, ComoTableProps } from "como-admin-web";
// eslint-disable-next-line node/no-extraneous-import
import { ComoObjectType, ComoRules } from "como-ts-utils";
import { HasManyOptions, HasOneOptions } from "sequelize";
import { Model, Repository } from "sequelize-typescript";
/**
 * @description User-Service parameters
 */
export interface IUserOptions {
    uid?: string;
}
export interface IGetUserResponse {
    success: boolean;
    message: string;
    data: IUserOptions;
}
//全局对象
export interface GlobalOjectType extends ComoObjectType {
    [field:string]:any
}


//==========================数据验证定义========================
//redis设置的值
export interface ComoRedisValue<T extends string |number | null | Buffer | object | Array<any>> {
    data:T
}
//验证时机规则
export interface ComoValidatorTimingType {
    //验证时机
    validaTiming:number
    validaRule:ComoRules
}
//验证规则
export interface ComoValidatorRuleType {
    //验证规则
    [field:string]:ComoValidatorTimingType | ComoRules
}

//动态链表的类型参数
export interface AsyncHasOptions {
    joinName:'hasMany' | 'hasOne'
    joinOptions:HasManyOptions | HasOneOptions
    model:Repository<Model>
}


//上传文件的类型
export interface MidwayUploadFileType {
    filename:string
    data:string
    fieldName:string
    mimeType:string
    _ext:string
}
//查询列表基本参数类型
export interface SelectBaseParams extends ComoObjectType {
    page:number
    limit:number
}
//服务查询列表返回
export interface ListFindResult<M extends Model> extends ComoObjectType {
    rows:M[]
    count:number
}
//登录管理员TOken解析出来的信息
export interface AdminUserTokenInfo {
    username:string
    admin_id:number
    role_id:number
    role_flag:string | number
    login_time:number
}
//===================前端公共组件页面===========================
//表单获取数据类型
export interface CommonPageGetFormType {
    tablename:string
    pkId?:number | string
}
//自动生成表单数据类型
export interface CommonFormType {
    formOption:ComoFormParams
    dialogOption:ComoDialogOptions
}
//角色授权节点类型
export interface RoleAuthAccessType {
    role_id:number
    access_id:string[] | number[]
}
//按钮参数设置
export interface WebPageBtnParams{
    //文件下载地址 当类型为down时
    DownFileUrl?:string
    //批量操作参数
    //批量操作时 默认地址为【当前模型/allaction】 当类型为allaction
    AllActionParams?:ComoObjectType
    //当类型为loadform时参数
    loadFormDialog?:{
        //必须要遵守CommonFormType 响应的值
        FormUrl:string
        //表单需要的提交的地址
        SubmitUrl:string
        //提交类型
        SubmitType:'Post' | 'Get' | 'Put' | 'Delete'
    }
    //当类型为loadpage时
    LoadPageDialog?:{
        PageUrl:string
        PropsData:boolean
        DialogOptions:ComoDialogOptions
        OtherParams?:ComoObjectType
    }
    //页面跳转
    PageLink?:{
        RouterName:string
        OtherParams?:ComoObjectType
    }
    //弹出层功能
    //当类型为alert时
    AlertContent?:{
        title:string
        message:string
    }
}
//按钮类型
export interface WebPageBtnComponentItemOptions{
    type?:string
    style?:StyleObject
    size?:string
    color?:string
    lableName?:string
    clickEventName?:string
    disabled?:boolean
    powerName?:string
    params?:WebPageBtnParams
}
//组件数据
export interface WebPageHeaderLeftComponent {
    type:"button" | "search" | "tag"
    options:WebPageBtnComponentItemOptions | ComoFormParams
}
//vue列表数据配置
export interface WebPageTableConfig {
    //表格配置
    tableConfig:ComoTableProps
    //主键字段
    pkField:string
    //控制器名称
    apiUrl?:string
    //数据导出列自定义接口
    exportColumnAPI?:string
    //当前操作名称
    apiName?:string
    //名称字段
    nameField?:string
    //表格上部左侧数据
    headerLeft?:WebPageHeaderLeftComponent[]
    //表格顶部搜索数据
    search?:ComoFormParams
    //表格上部右侧数据
    headerRight?:WebPageHeaderLeftComponent[]
    //分页右侧数据
    pageRight?:WebPageHeaderLeftComponent[]
}
//样式类型
export interface StyleObject extends ComoObjectType {
    color?: string;
    fontSize?: string;
    backgroundColor?: string;
    fontWeight?: 'normal' | 'bold' | 'bolder' | 'lighter' | number;
    fontStyle?: 'normal' | 'italic' | 'oblique';
    textAlign?: 'left' | 'right' | 'center' | 'justify';
    lineHeight?: string;
    margin?:string
    cursor?:'default' | 'auto' | 'pointer' | 'text'
}

//卡片风格
export interface CardOptions extends ComoObjectType {
    header?:string
    bodyStyle?:StyleObject
    bodyClass?:string
    shadow?:'always' | 'never' | 'hover'
}

//文件上传
export interface UploadFileType {
    filename:string
    data:string
    fieldname:string
    mimeType:string
    _ext:string
}

//定义前端调用的函数数型
export interface WebFunction<T extends object> {
    (data:T,adminUser:AdminUserTokenInfo):any
}