import request from '@/utils/request';

export default {
  //列表
  list: async (params) => {
    const res = await request.get('/main/produceparam/page', { params });
    if (res.data.code == 0) {
      return res.data.data;
    }
  },
  //详情
  getById: async (id) => {
    const res = await request.get(`/main/produceparam/getById/${id}`);
    if (res.data.code == 0) {
      return res.data.data;
    }
  },
  //详情
  getCode: async () => {
    const res = await request.get(
      `/main/codemanage/getCode/process_parameters`
    );
    if (res.data.code == 0) {
      return res.data.data;
    }
  },
  //保存
  save: async (data) => {
    const res = await request.post('/main/produceparam/save', data);

    if (res.data.code == 0) {
      console.log('保存');
      return '保存' + res.data.message;
    }
  },
  //保存
  update: async (data) => {
    const res = await request.put('/main/produceparam/update', data);
    if (res.data.code == 0) {
      console.log('修改');
      return '修改' + res.data.message;
    }
  },
  //删除
  delete: async (data) => {
    const res = await request.delete('/main/produceparam/delete', { data });
    if (res.data.code == 0) {
      return res.data.message;
    }
  }
};
