/**
 * 标准装置台账管理接口
 */
import request from '../../index'
import type { IListQuery } from '@/views/equipement/standard/book/book-interface'
const prefix = 'standard'

// 列表查询
export function getStandardList(data: IListQuery) {
  return request({
    url: `${prefix}/approval/listPage?offset=${data.offset}&limit=${data.limit}`,
    method: 'post',
    data,
  })
}

// 新建(保存至草稿箱)
export function addStandard(data: object) {
  return request({
    url: `${prefix}/save`,
    method: 'post',
    data,
  })
}

// 编辑--草稿箱
export function updateStandard(data: object) {
  return request({
    url: `${prefix}/draftUpdate`,
    method: 'post',
    data,
  })
}
// 编辑--驳回编辑
export function failUpdateStandard(data: object) {
  return request({
    url: `${prefix}/failUpdate`,
    method: 'post',
    data,
  })
}

// 获取详情信息
export function getInfo(data: { id: string; type: string }) {
  return request({
    url: `${prefix}/detail`,
    method: 'post',
    data,
  })
}

// 提交
export function submit(data: { id: string; approvalType?: string; formId: string; processId?: string; changeFlag?: string }) {
  return request({
    url: `${prefix}/submit`,
    method: 'post',
    data,
  })
}

// 草稿箱删除
export function draftDelete(data: { id: string }) {
  return request({
    url: `${prefix}/draftDelete`,
    method: 'post',
    data,
  })
}

// 标准装置审批删除
export function approvalDelete(data: { id: string; taskId: string }) {
  return request({
    url: `${prefix}/approval/delete`,
    method: 'post',
    data,
  })
}

// 取消
export function cancelApproval(data: { processInstanceId?: string; comments: string; id: string }) {
  return request({
    url: `${prefix}/approval/revoke`,
    method: 'post',
    data,
  })
}

// 拒绝
export function refuseApproval(data: { id: string; taskId: string; comments: string }) {
  return request({
    url: `${prefix}/approval/refuse`,
    method: 'post',
    data,
  })
}

// -----------------------------------------计量人员--------------------------------------------
// 删除
export function deletePerson(data: { ids: string[] }) {
  return request({
    url: `${prefix}/staff/batchDelete`,
    method: 'post',
    data,
  })
}

// 新增
export function addPerson(data: any) {
  return request({
    url: `${prefix}/staff/batchAdd`,
    method: 'post',
    data,
  })
}

// 列表
export function getPersonList(data: { standardId: string; offset: number; limit: number }) {
  return request({
    url: `${prefix}/staff/listPage?offset=${data.offset}&limit=${data.limit}`,
    method: 'post',
    data,
  })
}

// ----------------------------------------标准配套设备----------------------------------------------
// 删除
export function deleteEquipment(data: any) {
  return request({
    url: `${prefix}/equipment/batchDelete`,
    method: 'post',
    data,
  })
}

// 新增
export function addEquipment(data: any) {
  return request({
    url: `${prefix}/equipment/batchAdd`,
    method: 'post',
    data,
  })
}

// 列表
export function getEquipmentList(data: { standardId?: string; offset: number; limit: number }) {
  return request({
    url: `${prefix}/equipment/listPage?offset=${data.offset}&limit=${data.limit}`,
    method: 'post',
    data,
  })
}
// --------------------------------------技术指标修改记录----------------------------------------------
// 列表
export function getTechChangeList(data: { standardId: string; offset: number; limit: number }) {
  return request({
    url: `${prefix}/technical/target/listPage?offset=${data.offset}&limit=${data.limit}`,
    method: 'post',
    data,
  })
}

