import request from '@/utils/request'
import state from '@/store'
import router from '@/router'

export function getPartsCategories() {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: '车间生产管理工艺_基础表_典型工艺名称_分类_查询数据 '
    }
  })
}

export function getPartsName(num) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: '车间生产管理工艺_基础表_典型工艺名称_查询数据_查典型工艺名称',
      param: `典型工艺名称分类流水号=${num}`
    }
  })
}

export function getTableData(pageCurrent, pageSize, partsCategoriesCheck, partsCategories, partsNameCheck, partsName) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: '车间生产管理工艺_基础表_典型工艺名称_查询数据_综合查询',
      param: `典型工艺名称分类流水号_check=${partsCategoriesCheck}&典型工艺名称分类流水号=${partsCategories}&典型工艺流水号_check=${partsNameCheck}&典型工艺流水号=${partsName}&典型工艺流水号1_check=0`,
      Pagination: pageCurrent + '&' + pageSize
    }
  })
}

export function upMove(typicalProcessNum, typicalSerialNum) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '2',
      name: '车间生产管理工艺_基础表_典型工艺工序_上移工序',
      param: `典型工艺流水号=${typicalProcessNum}&典型工艺工序流水号=${typicalSerialNum}`
    }
  })
}

export function downMove(typicalProcessNum, typicalSerialNum) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '2',
      name: '车间生产管理工艺_基础表_典型工艺工序_下移工序',
      param: `典型工艺流水号=${typicalProcessNum}&典型工艺工序流水号=${typicalSerialNum}`
    }
  })
}

export function insertRow(typicalProcessNum, typicalSerialNum) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '2',
      name: '车间生产管理工艺_基础表_典型工艺工序_添加工序',
      param: `典型工艺流水号=${typicalProcessNum}&典型工艺工序流水号=${typicalSerialNum}`
    }
  })
}

export function deleRow(typicalProcessNum, typicalSerialNum) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '2',
      name: '车间生产管理工艺_基础表_典型工艺名称_删除数据',
      param: `典型工艺流水号=${typicalProcessNum}&典型工艺工序流水号=${typicalSerialNum}`
    }
  })
}

export function editConfirm(typicalProcessNum, typicalSerialNum, processNum, processNo, processClaim, pieceQuota, quasiQuota, remarks) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '2',
      name: '车间生产管理工艺_基础表_典型工艺工序_修改数据',
      param: `典型工艺流水号=${typicalProcessNum}&典型工艺工序流水号=${typicalSerialNum}&工艺序号=${processNum}&工艺编号=${processNo}&工艺要求=${processClaim}&单件定额工时=${pieceQuota}&准结定额工时=${quasiQuota}&备注=${remarks}`
    }
  })
}

export function processNameClick() {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: '车间生产管理工艺_基础表_工艺分类名称_查询数据'
    }
  })
}

export function processNameSelect(val) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: '车间生产管理工艺_基础表_工艺名称_查询数据',
      param: `工艺分类流水号_check=1=bit&工艺分类流水号=${val}=int`
    }
  })
}

export function processRequestSelect(val) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: '车间生产管理_基础表_工艺要求_查询数据',
      param: `工艺编号=${val}=int`
    }
  })
}

export function difficultyLevel(level, typicalSerialNum) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '2',
      name: '车间生产管理工艺_零件工序_修改数据_典型工艺难度等级',
      param: `工艺难度等级=${level}&典型工艺工序流水号=${typicalSerialNum}`
    }
  })
}

export function isAddOrEdit(typicalSerialNum) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: '车间生产管理工艺_基础表_典型工艺工序_查询数据_根据典型工艺流水号',
      param: `典型工艺流水号=${typicalSerialNum}`
    }
  })
}

export function addProcess(typicalSerialNum, processNum, processNo) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: '车间生产管理工艺_基础表_典型工艺工序_增加数据_NEW',
      param: `典型工艺流水号=${typicalSerialNum}&工艺序号=${processNum}&工艺编号=${processNo}`
    }
  })
}
