wu
2024-08-02 928fa3682fcd0bcb59e3ca3da8770ecbb06cf315
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
// src/services/api.js
import request from '../utils/request';
import { ElMessage } from 'element-plus';
 
 // Replace with your actual backend base URL
 
// Function to find list of raw usages
const BASE_URL = 'glassStorage/api/rawUsage';
const taskBASE_URL = 'glassStorage/api/storageTask';
 
export const findTasks = () => {
  const url = `glassStorage/api/storageTask/findTasks`;
  const options = {
    method: 'get',
    url,
    json: true,
    
  };
 
  return new Promise((resolve, reject) => {
    request(options, (error, response, body) => {
      if (error) {
        reject(new Error(error.message));
      } else {
        resolve(body);
      }
    });
  });
};
 
 
 
export const findList = (params) => {
  const url = `${BASE_URL}/findList`;
  const options = {
    method: 'post',
    url,
    json: true,
    body: params
  };
 
  return new Promise((resolve, reject) => {
    request(options, (error, response, body) => {
      if (error) {
        reject(new Error(error.message));
      } else {
        resolve(body);
      }
    });
  });
};
 
// Function to find raw usage by ID
export const findById = (id) => {
  const url = `${BASE_URL}/${id}`;
  const options = {
    method: 'get',
    url,
    json: true
  };
 
  return new Promise((resolve, reject) => {
    request(options, (error, response, body) => {
      if (error) {
        reject(new Error(error.message));
      } else {
        resolve(body);
      }
    });
  });
};
 
// Function to insert a new raw usage
export const insertRawUsage = (rawUsage) => {
  const url = `${BASE_URL}`;
  const options = {
    method: 'post',
    url,
    json: true,
    body: rawUsage
  };
 
  return new Promise((resolve, reject) => {
    request(options, (error, response, body) => {
      if (error) {
        reject(new Error(error.message));
      } else {
        resolve(body);
      }
    });
  });
};
 
 
export const updateRawUsage = async (rawUsage) => {
  try {
    const response = await request.post(`${BASE_URL}/updaterawUsage`, rawUsage);
    ElMessage.success('修改成功');
    return response.data;
  } catch (error) {
    ElMessage.error('修改失败');
    throw error;
  }
};
 
export const deleteRawUsage = async (id) => {
  try {
    const response = await request.post(`${BASE_URL}/id`, id);
    ElMessage.success('删除原始使用数据成功');
    return response.data;
  } catch (error) {
    ElMessage.error('删除原始使用数据失败');
    throw error;
  }
};
 
export const inStorage = async (RawUsageAndShelfRack) => {
  try {
    const response = await request.post(`${BASE_URL}/inStorage`, RawUsageAndShelfRack);
    ElMessage.success('入库操作成功');
    return response.data;
  } catch (error) {
    ElMessage.error('入库操作失败');
    throw error;
  }
};
 
export const outStorage = async (RawUsageAndShelfRack) => {
  try {
    const response = await request.post(`${BASE_URL}/outStorage`, RawUsageAndShelfRack);
    ElMessage.success('出库操作成功');
    return response.data;
  } catch (error) {
    ElMessage.error('出库操作失败');
    throw error;
  }
};
 
 
 
export const taskUpdate = async (task) => {
  try {
    const response = await request.post(`${taskBASE_URL}/taskUpdate`, task);
 
    return response.data;
  } catch (error) {
 
    throw error;
  }
};
 
 
 
 
 
 
const API_URL = 'glassStorage/api/shelfRack';  // Adjust this based on your actual API URL
 
export const shelfRackfindList = (params) => {
  return request.post(`${API_URL}/findList`, params)
    .then(response => response.data)
    .catch(error => {
      throw error;  // Handle errors appropriately in your frontend
    });
};
 
export const shelfRackfindById = (id) => {
  return request.get(`${API_URL}/${id}`)
    .then(response => response.data)
    .catch(error => {
      throw error;
    });
};
 
export const insertShelfRack = (shelfRack) => {
  return request.post(`${API_URL}`, shelfRack)
    .then(response => response.data)
    .catch(error => {
      throw error;
    });
};
 
export const updateShelfRack = (shelfRack) => {
  return request.put(`${API_URL}`, shelfRack)
    .then(response => response.data)
    .catch(error => {
      throw error;
    });
};
 
export const shelfRackdeleteById = (id) => {
  return request.delete(`${API_URL}/${id}`)
    .then(response => response.data)
    .catch(error => {
      throw error;
    });
};
 
export const findShelfRack = () => {
  return request.get(`${API_URL}/findshelfrack`)
    .then(response => response.data)
    .catch(error => {
      throw error;
    });
};