Files
FE_CPONE/test/vuex/one-sampling-pe/api/sampling.js
2026-04-27 10:13:31 +07:00

166 lines
3.8 KiB
JavaScript

// API :
// search bank
// paramater : query , page , rowPerPage
const URL =
"/one-api/mockup/sampling/sampling/";
export async function get_samples(order_id, station_id) {
try {
var resp = await axios.post(URL + 'sampling/get_samples', {
orderid: order_id,
stationid: station_id
});
if (resp.status != 200) {
return {
status: "ERR",
message: resp.statusText
};
}
let data = resp.data;
return data;
} catch(e) {
return {
status: "ERR",
message: e.message
};
}
}
export async function get_sample(order_id, sample_id, barcode) {
try {
var resp = await axios.post(URL + 'sampling/get_sample', {
orderid: order_id,
sampleid: sample_id,
barcode: barcode
});
if (resp.status != 200) {
return {
status: "ERR",
message: resp.statusText
};
}
let data = resp.data;
return data;
} catch(e) {
return {
status: "ERR",
message: e.message
};
}
}
export async function save(token, order_id, sample_id, barcode, json_data) {
try {
var resp = await axios.post(URL + 'sampling/save', {
token: token,
orderid: order_id,
sampleid: sample_id,
barcode: barcode,
json_data: json_data
});
if (resp.status != 200) {
return {
status: "ERR",
message: resp.statusText
};
}
let data = resp.data;
return data;
} catch(e) {
return {
status: "ERR",
message: e.message
};
}
}
export async function save_note_supervisor(order_id, message) {
try {
let token = one_token()
var resp = await axios.post(URL + 'sampling/save_note_supervisor', {
orderid: order_id,
message: message,
token: token
});
if (resp.status != 200) {
return {
status: "ERR",
message: resp.statusText
};
}
let data = resp.data;
return data;
} catch(e) {
return {
status: "ERR",
message: e.message
};
}
}
export async function barcode_add(token, order_id, sample_id) {
try {
var resp = await axios.post(URL + 'sampling/barcode_add', {
token: token,
order_id: order_id,
sample_id: sample_id
});
if (resp.status != 200) {
return {
status: "ERR",
message: resp.statusText
};
}
let data = resp.data;
return data;
} catch(e) {
return {
status: "ERR",
message: e.message
};
}
}
export async function get_requirement() {
try {
var resp = await axios.post(URL + 'sampling/get_requirement', {});
if (resp.status != 200) {
return {
status: "ERR",
message: resp.statusText
};
}
let data = resp.data;
return data;
} catch(e) {
return {
status: "ERR",
message: e.message
};
}
}
export async function save_requirement(token, order_id, station_id, status, reqs) {
try {
var resp = await axios.post(URL + 'sampling/save_requirement', {
token: token,
order_id: order_id,
station_id: station_id,
status: status,
reqs: reqs
});
if (resp.status != 200) {
return {
status: "ERR",
message: resp.statusText
};
}
let data = resp.data;
return data;
} catch(e) {
return {
status: "ERR",
message: e.message
};
}
}