import http from '@/request/http.js'
import ossConfig from '@/assets/ossConfig.js'
import store from '@/store/index.js'
export default {
    // 获取请求用户信息
    getCurrentUserInfo: () => http.get('/api/SystemAdmin/BasicData/GetCurrentUserInfo'),

    // 获取年班级列表
    getGradeClass: () => http.get('/api/SystemAdmin/BSGradeClass/GetGradeClassListByCompanyId', {
        params: { company_id: store.state.tokenPayload.CompanyId },
        isShowLoading: false
    }),
    // 获取省市区
    getPCA: () => http.get('/Assets/Administrative-divisions-of-China/dist/pca-code.json', {
        baseURL: ossConfig.staticResourcesFileBucket.domain,
        isShowLoading: false
    }),
    // 获取省市
    getPC: () => http.get('/Assets/Administrative-divisions-of-China/dist/pc-code.json', {
        baseURL: ossConfig.staticResourcesFileBucket.domain,
        isShowLoading: false
    }),
    // 获取省
    getP: () => http.get('/Assets/Administrative-divisions-of-China/dist/provinces.json', {
        baseURL: ossConfig.staticResourcesFileBucket.domain,
        isShowLoading: false
    }),

    // ---- 表单控件 ----
    // 获取控件列表
    formControlsList: params => http.post('/api/Form/FormControls/List', params),
    // 获取控件详情
    formControlsGet: params => http.get('/api/Form/FormControls/Get', { params }),
    // 创建控件
    formControlsCreate: params => http.post('/api/Form/FormControls/Create', params),
    // 修改控件
    formControlsUpdate: params => http.post('/api/Form/FormControls/Update', params),
    // 启用禁用控件
    formControlsSetEnabled: params => http.get('/api/Form/FormControls/SetEnabled', { params }),
    // 删除控件
    formControlsDelete: params => http.get('/api/Form/FormControls/Delete', { params }),

    // ---- 表单详情 ----
    // 获取表单详情
    formInfoGet: params => http.get('/api/Form/FormInfo/Get', { params }),
    // 根据类别和数据源获取表单详情
    formInfoGetByCS: params => http.get('/api/Form/FormInfo/GetByCategoryAndSourceId', { params }),
    // 创建表单
    formInfoCreate: params => http.post('/api/Form/FormInfo/Create', params),
    // 修改表单
    formInfoUpdate: params => http.post('/api/Form/FormInfo/Update', params),
    // 删除表单
    formInfoDelete: params => http.get('/api/Form/FormInfo/Delete', { params }),

    // ---- 表单记录 ----
    // 获取记录列表
    formRecordList: params => http.get('/api/Form/FormRecord/List', { params }),
    // 获取记录详情
    formRecordGet: params => http.get('/api/Form/FormRecord/Get', { params }),
    // 创建记录
    formRecordCreate: params => http.post('/api/Form/FormRecord/Create', params),
    // 创建记录（不需要 token）
    formRecordCreateNoAuth: params => http.post('/api/Form/FormRecord/CreateNoAuthentication', params),
    // 修改记录
    formRecordUpdate: params => http.post('/api/Form/FormRecord/Update', params),
    // 删除记录
    formRecordDelete: params => http.get('/api/Form/FormRecord/Delete', { params }),

    // ---- 表单工具 ----
    // 日期区间排除休息时间
    formJudgeLeaveDay: params => http.get('/api/BsTeacherRestTime/JudgeLeaveDay', { params, isShowLoading: false }),
    // 表单控件数据唯一验证
    formRecordValidation: params => http.post('/api/Form/FormRecordValidation/UniqueValidation', params, { isShowLoading: false }),
    // 获取文件流进行下载
    formGetFile: url => http.get(url, { responseType: 'blob' })
}
