将整套 web 源码纳入仓库,并为 web/node_modules、构建产物及本地环境文件配置 .gitignore,同时移除占位用的 assets/.gitkeep。 Co-authored-by: Cursor <cursoragent@cursor.com>
162 lines
3.8 KiB
JavaScript
162 lines
3.8 KiB
JavaScript
// <!-- 物量计量管理模块 -->
|
||
import request from '../../utils/request'
|
||
|
||
// 获取计量管理列表
|
||
export function getTablist(data) {
|
||
return request(
|
||
{
|
||
url: "/material_metering/list",
|
||
method: 'post',
|
||
data
|
||
})
|
||
}
|
||
|
||
// 创建计量管理
|
||
export function addTablist(data) {
|
||
return request(
|
||
{
|
||
url: "/material_metering/create",
|
||
method: 'post',
|
||
data
|
||
})
|
||
}
|
||
|
||
|
||
// 更新计量管理
|
||
export function updateTablist(data) {
|
||
return request(
|
||
{
|
||
url: "/material_metering/update" ,
|
||
method: 'put',
|
||
data
|
||
})
|
||
}
|
||
|
||
// 删除计量管理
|
||
export function delTablist(data) {
|
||
return request({
|
||
url: "/material_metering/delete",
|
||
method: 'delete',
|
||
data
|
||
});
|
||
}
|
||
|
||
// 下载物料计量导入模板(无参数,返回 blob)
|
||
export function getAssetTemplate() {
|
||
return request({
|
||
url: "/material_metering/template",
|
||
method: 'post',
|
||
responseType: 'blob'
|
||
})
|
||
}
|
||
|
||
// 导出物料计量数据,参数:{ search, filter, ids? },返回 blob(一次性)
|
||
export function exportAsset(data) {
|
||
return request({
|
||
url: "/material_metering/export",
|
||
method: 'post',
|
||
data,
|
||
responseType: 'blob'
|
||
})
|
||
}
|
||
|
||
/**
|
||
* 流式导出物料计量数据:返回原生 fetch Response,调用方用 response.body.getReader() 流式读取
|
||
* 参数:{ search, filter, ids? },ids 不传或为空时按 search+filter 导出全部
|
||
*/
|
||
export function exportAssetStream(data) {
|
||
const baseURL = (typeof getApiBaseUrl === 'function' ? getApiBaseUrl() : null) || '';
|
||
const url = `${baseURL.replace(/\/+$/, '')}/material_metering/export`;
|
||
const token = typeof localStorage !== 'undefined' ? localStorage.getItem('token') : '';
|
||
const uid = typeof localStorage !== 'undefined' ? localStorage.getItem('uid') : '';
|
||
const language = typeof localStorage !== 'undefined' ? localStorage.getItem('language') || 'zh-CN' : 'zh-CN';
|
||
const headers = {
|
||
'Content-Type': 'application/json',
|
||
'Accept-Language': language
|
||
};
|
||
if (token) {
|
||
headers.token = token;
|
||
headers.Authorization = `Bearer ${token}`;
|
||
}
|
||
if (uid) headers.uid = uid;
|
||
return fetch(url, {
|
||
method: 'post',
|
||
headers,
|
||
body: JSON.stringify(data)
|
||
});
|
||
}
|
||
|
||
|
||
/**
|
||
* 上传文件(解析模板):传入 FormData(包含 file 字段),成功返回 { filename, import_type }
|
||
*/
|
||
export function uploadAsset(formData) {
|
||
return request({
|
||
url: "/material_metering/upload",
|
||
method: 'post',
|
||
data: formData,
|
||
});
|
||
}
|
||
|
||
|
||
/**
|
||
* 导入文件 参数filename和import_type(add,update)
|
||
*/
|
||
export function importAsset(data) {
|
||
return request({
|
||
url: "/material_metering/import",
|
||
method: 'post',
|
||
data
|
||
});
|
||
}
|
||
|
||
|
||
/**
|
||
* 下载错误信息,参数 { filename },返回 blob 文件流
|
||
*/
|
||
export function downloadErrorAsset(data) {
|
||
return request({
|
||
url: "/import/error_file/download",
|
||
method: 'post',
|
||
data,
|
||
responseType: 'blob',
|
||
});
|
||
}
|
||
// 获取物料计量邮件初始化状态
|
||
export function remarkTablist(data) {
|
||
return request(
|
||
{
|
||
url: "/material_metering/email_alert/info" ,
|
||
method: 'post',
|
||
data
|
||
})
|
||
}
|
||
// 更新物料计量邮件提醒状态(true或者false)
|
||
export function emailupDate(data) {
|
||
return request(
|
||
{
|
||
url: "/material_metering/email_alert/update" ,
|
||
method: 'put',
|
||
data
|
||
})
|
||
}
|
||
|
||
// 物料计量当月计量:列表接口,传 filter.next_calibrate_time 或 filter.create_at 为 { start_time: "当月1号 00:00:00", end_time: "下月1号 00:00:00" }
|
||
export function monthMaterialUpDate(data) {
|
||
return request(
|
||
{
|
||
url: "/material_metering/list" ,
|
||
method: 'post',
|
||
data
|
||
})
|
||
}
|
||
// 物料计量批量更新 ids:[]和其他表单参数
|
||
export function allupMaterialDate(data) {
|
||
return request(
|
||
{
|
||
url: "/material_metering/batch/update" ,
|
||
method: 'put',
|
||
data
|
||
})
|
||
}
|