import { request, paramsSerializer } from '@/utils/request.js';

// 延期预警 ------------------->
// 延期预警列表
export const getDelayWarnList = (data) =>
  request({
    url: '/api/admin/tb/delay/warn/query',
    params: data,
    paramsSerializer,
  });

// 关闭单个延期预警
export const closeDelayWarn = (id) =>
  request({
    url: '/api/admin/tb/delay/warn/close?id=' + id,
    loading: true,
  });
// 重启延期预警
export const restartDelayWarn = (id) =>
  request({
    url: '/api/admin/tb/delay/warn/restart?id=' + id,
    loading: true,
  });
// 单个延期预警的详情
export const delayWarnDetail = (id) =>
  request({
    url: '/api/admin/tb/delay/warn/get?id=' + id,
    // method: 'get',
  });
// 延期预警明细表
export const delayWarnDetailList = (id) =>
  request({
    url: '/api/admin/tb/delay/warn/detail/list?id=' + id,
  });

// 延期预警跟进提交
export const flowDelayWarn = (data) =>
  request({
    url: '/api/admin/tb/delay/warn/detail/save',
    data,
    loading: true,
  });

// 违规登记 ------------------->
// 违规登记列表
export const getViolationList = (data) =>
  request({
    url: '/api/admin/tb/violation/query',
    params: data,
  });
export const saveViolation = (data) =>
  request({
    url: '/api/admin/tb/violation/save',
    data,
  });
// 关闭单个违规登记
export const closeViolation = (id) =>
  request({
    url: '/api/admin/tb/violation/close?id=' + id,
    loading: true,
  });
// 重启违规登记
export const restartViolation = (id) =>
  request({
    url: '/api/admin/tb/violation/restart?id=' + id,
    loading: true,
  });
// 违规登记明细表
export const violationDetailList = (id) =>
  request({
    url: '/api/admin/tb/violation/detail/query?id=' + id,
  });
// 违规登记跟进提交
export const flowViolation = (data) =>
  request({
    url: '/api/admin/tb/violation/detail/save',
    data,
    loading: true,
  });

// 设备出入库 ------------------->
// 设备出入库登记查询
export const deviceOutInSearch = (params) =>
  request({
    url: '/api/admin/device/in/out/sop_page',
    params,
  });
export const deviceCanOut = (params) =>
  request({
    url: '/api/admin/device/in/out/can_out_info',
    params,
  });

// 查询可入库的设备信息
export const deviceCanIn = (params) =>
  request({
    url: '/api/admin/device/in/out/can_in_info',
    params,
  });

// 设备出入库，提交
export const deviceOutInSave = (data) =>
  request({
    url: '/api/admin/device/in/out/submit',
    data,
  });

// 项目计划变更 ------------------->
// 项目计划变更列表
export const planChangeList = (params) =>
  request({
    url: '/api/admin/project/exchange/list',
    params,
  });
// 项目变更计划申请（第一步）
export const createPlanChange = (data) =>
  request({
    url: '/api/admin/project/exchange/save',
    data,
  });
export const planChangeDetail = (id) =>
  request({
    url: '/api/admin/project/exchange/view',
    params: { id },
  });
// 项目变更计划审批
export const approvePlanChange = (params) =>
  request({
    url: '/api/admin/project/exchange/flow/approve',
    params,
    loading: true,
  });

// 流程相关 ------------------->
// 获取流程部署信息接口
export const flowDeploymentListApi = () =>
  request({
    url: '/api/admin/flow/deployment/data',
  });
export const flowFormPropertiesApi = (params) =>
  // flowDeploymentId or taskId or flowId
  // crmNo
  request({
    url: '/api/admin/flow/form_properties/get',
    params,
  });

// 流程详细信息接口
export const getFlowDetail = (data) =>
  request({
    url: '/api/admin/flow/view',
    data,
  });

// sop管理 ------------------->
export const sopListApi = (data) =>
  request({
    url: '/api/admin/sop/list',
    data,
  });
// sop申请
export const sopApplyApi = (params) =>
  request({
    url: '/api/admin/sop/apply',
    data: params,
  });
// sop填报-详情
export const sopFlowViewApi = (params) =>
  request({
    url: '/api/admin/flow/view',
    params,
  });
// sop填报-提交
export const sopApproveApi = (params) =>
  request({
    url: '/api/admin/sop/approve',
    data: params,
  });
// sop作废
export const sopCancelApi = (flowId) =>
  request({
    url: '/api/admin/sop/cancel',
    params: { flowId },
  });
// sop批量作废
export const sopBatchCancelApi = (flowIds) =>
  request({
    url: '/api/admin/sop/batch/cancel',
    data: flowIds,
  });
// sop 编辑-详情
export const sopEditApi = (sopId) =>
  request({
    url: '/api/admin/sop/edit',
    params: { id: sopId },
  });
// sop 编辑-保存
export const sopSaveApi = (data) =>
  request({
    url: '/api/admin/sop/save',
    data,
  });
// 元数据
export const metadataListApi = (params) =>
  request({
    url: '/api/admin/sop/metadata/list',
    params,
  });
export const metadataSaveApi = (formWidgetMetadataList) =>
  request({
    url: '/api/admin/sop/metadata/save',
    data: { formWidgetMetadataList },
  });
