feat(inventory): 添加盘点明细校验逻辑并新增公共请求工具函数
- 修复盘点明细中数量为0时的校验逻辑,添加continue跳过无效项 - 新增aqgqj_public.js公共工具模块,包含请求封装、文件下载、日期格式化等通用功能 - 更新public.js中的本地开发环境API地址配置
This commit is contained in:
parent
db7513b887
commit
61d2818495
|
|
@ -149,6 +149,9 @@ function submitApply(data) {
|
|||
}
|
||||
for (let i = 0; i < list.length; i++) {
|
||||
if (list[i].quantityOfThisInventory === 0 || list[i].quantityOfThisInventory === '0') {
|
||||
continue;
|
||||
}
|
||||
if (list[i].quantityOfThisInventory == null || list[i].quantityOfThisInventory === '') {
|
||||
return layer.msg('盘点明细,第' + (i + 1) + '行,未填写本次盘点量', { icon: 7 });
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,291 @@
|
|||
/* const dataUrl = 'http://192.168.2.159:21520/'; // 数据请求路径
|
||||
// const dataUrl = 'http://192.168.0.50:21995/'; // 数据请求路径-亮
|
||||
const fileUrl = 'http://127.0.0.1:21995/statics'; // 文件路径
|
||||
const signFileUrl = 'http://127.0.0.1:21995/statics'; // 签名文件路径
|
||||
const viewFileUrl = 'http://192.168.0.14:8012/onlinePreview?url=' //14服务器预览文件 */
|
||||
|
||||
// const dataUrl = 'http://192.168.0.14:21520/'; // 数据请求路径
|
||||
// const fileUrl = 'http://192.168.0.14:21520/statics'; // 文件路径
|
||||
// const signFileUrl = 'http://127.0.0.1:21995/statics'; // 签名文件路径
|
||||
// const viewFileUrl = 'http://192.168.0.14:8012/onlinePreview?url=' //14服务器预览文件
|
||||
|
||||
const dataUrl = 'http://10.1.0.142:1999/gz_aqgqj/'; // 数据请求路径
|
||||
const dataUrlDevice = 'http://10.1.0.142:1999/'; // 数据请求路径
|
||||
const dataUrlCar = 'http://10.1.0.142:1999/gz_car/'; // 数据请求路径
|
||||
|
||||
const fileUrl = 'http://10.1.0.142:1999/gz_aqgqj/statics'; // 文件路径
|
||||
const viewFileUrl = 'http://10.1.0.142:8012/onlinePreview?url=' //14服务器预览文件
|
||||
|
||||
/* 请求 */
|
||||
function ajaxRequest(url, type, data, async, beforeFn, successFn, errorFn, contentType) {
|
||||
$.ajax({
|
||||
url: url,
|
||||
type: type,
|
||||
headers: {
|
||||
"authorization": sessionStorage.getItem("gz-token"),
|
||||
},
|
||||
data: data,
|
||||
async: async,
|
||||
beforeSend: beforeFn,
|
||||
contentType: contentType || "application/x-www-form-urlencoded; charset=utf-8",
|
||||
success: function (data) {
|
||||
if (data.code === 401) {
|
||||
closeWindowOpen();
|
||||
}
|
||||
successFn(data);
|
||||
},
|
||||
error: function (error) {
|
||||
errorFn(error)
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/* 文件上传请求 */
|
||||
function ajaxRequestByUploadFile(url, data, beforeFn, successFn, errorFn) {
|
||||
$.ajax({
|
||||
url: url,
|
||||
headers: {
|
||||
"authorization": sessionStorage.getItem("gz-token"),
|
||||
},
|
||||
type: 'POST',
|
||||
dataType: 'json',
|
||||
contentType: 'multipart/form-data',
|
||||
processData: false,
|
||||
contentType: false,
|
||||
data: data,
|
||||
beforeSend: beforeFn,
|
||||
success: function (data) {
|
||||
if (data.code === 401) {
|
||||
closeWindowOpen();
|
||||
}
|
||||
successFn(data);
|
||||
},
|
||||
error: function (error) {
|
||||
errorFn(error)
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/* 请求错误 */
|
||||
function errorFn(xhr, status, error) {
|
||||
if (xhr.status === 0) {
|
||||
// 网络连接失败
|
||||
console.error("网络连接失败,请检查网络是否正常");
|
||||
} else {
|
||||
// 请求出现其他错误
|
||||
console.error("ajax请求错误:" + error);
|
||||
}
|
||||
}
|
||||
|
||||
// 公共导出excel
|
||||
function exportExcelUtil(url, fileName, params) {
|
||||
let loadingMsg = layer.msg("数据导出中,请稍候...", { icon: 16, scrollbar: false, time: 0, });
|
||||
let xhr = new XMLHttpRequest();
|
||||
xhr.open("POST", url, true);
|
||||
xhr.responseType = "blob"; // 转换流
|
||||
xhr.setRequestHeader('Content-Type', 'application/json;charset=UTF-8')
|
||||
xhr.setRequestHeader("authorization", sessionStorage.getItem("gz-token"));
|
||||
xhr.onload = function () {
|
||||
layer.close(loadingMsg);
|
||||
if (this.status === 200) {
|
||||
let blob = this.response;
|
||||
var a = document.createElement("a");
|
||||
var url = window.URL.createObjectURL(blob);
|
||||
a.href = url;
|
||||
a.download = fileName + ".xlsx"; // 文件名
|
||||
} else {
|
||||
layer.msg("数据发生异常,请稍后重试", { icon: 16, scrollbar: false, time: 2000 });
|
||||
}
|
||||
a.click();
|
||||
window.URL.revokeObjectURL(url);
|
||||
};
|
||||
xhr.send(params);
|
||||
}
|
||||
|
||||
|
||||
// 下载文件的公共方法
|
||||
function downLoadFileUtil(url, fileName, params) {
|
||||
let loadingMsg = layer.msg("文件导出中,请稍候...", { icon: 16, scrollbar: false, time: 0, });
|
||||
let xhr = new XMLHttpRequest();
|
||||
xhr.open("GET", url, true);
|
||||
xhr.responseType = "blob"; // 转换流
|
||||
xhr.setRequestHeader("authorization", sessionStorage.getItem("gz-token"));
|
||||
xhr.onload = function () {
|
||||
layer.close(loadingMsg);
|
||||
if (this.status === 200) {
|
||||
let blob = this.response;
|
||||
var a = document.createElement("a");
|
||||
var url = window.URL.createObjectURL(blob);
|
||||
a.href = url;
|
||||
a.download = fileName; // 文件名
|
||||
} else {
|
||||
layer.msg("文件导出异常,请稍后重试", { icon: 16, scrollbar: false, time: 2000 });
|
||||
}
|
||||
a.click();
|
||||
window.URL.revokeObjectURL(url);
|
||||
};
|
||||
xhr.send();
|
||||
}
|
||||
|
||||
// 格式化日对象
|
||||
const getNowDate = () => {
|
||||
var date = new Date();
|
||||
var sign2 = "-";
|
||||
var year = date.getFullYear() // 年
|
||||
var month = date.getMonth() + 1; // 月
|
||||
var day = date.getDate(); // 日
|
||||
var hour = date.getHours(); // 时
|
||||
var minutes = date.getMinutes(); // 分
|
||||
var seconds = date.getSeconds() //秒
|
||||
var weekArr = ['星期一', '星期二', '星期三', '星期四', '星期五', '星期六', '星期天'];
|
||||
var week = weekArr[date.getDay()];
|
||||
// 给一位数的数据前面加 “0”
|
||||
if (month >= 1 && month <= 9) {
|
||||
month = "0" + month;
|
||||
}
|
||||
if (day >= 0 && day <= 9) {
|
||||
day = "0" + day;
|
||||
}
|
||||
if (hour >= 0 && hour <= 9) {
|
||||
hour = "0" + hour;
|
||||
}
|
||||
if (minutes >= 0 && minutes <= 9) {
|
||||
minutes = "0" + minutes;
|
||||
}
|
||||
if (seconds >= 0 && seconds <= 9) {
|
||||
seconds = "0" + seconds;
|
||||
}
|
||||
return year + "-" + month + "-" + day + "-" + hour + sign2 + minutes + sign2 + seconds;
|
||||
}
|
||||
// 空值赋值
|
||||
function setNullValue(value) {
|
||||
if (value === 0) {
|
||||
return 0;
|
||||
} else if (!value || value === 'null') {
|
||||
return '';
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
// 数字空值赋值
|
||||
function setNullNumValue(value) {
|
||||
if (value === 0) {
|
||||
return 0;
|
||||
} else if (!value || value === 'null') {
|
||||
return 0;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
function getUrlParam(key) {
|
||||
var href = window.location.href;
|
||||
var url = href.split("?");
|
||||
if (url.length <= 1) {
|
||||
return "";
|
||||
}
|
||||
var params = url[1].split("&");
|
||||
|
||||
for (var i = 0; i < params.length; i++) {
|
||||
var param = params[i].split("=");
|
||||
if (key == param[0]) {
|
||||
return param[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 预览文件
|
||||
function commonViewFile(params) {
|
||||
let path = fileUrl + params + '?auth=' + sessionStorage.getItem("gz-token");
|
||||
// path = fileUrl + params
|
||||
console.log(path);
|
||||
let encodePath = encodeURIComponent(useBase64.encode64(path));
|
||||
window.open(viewFileUrl + encodePath + '&token=' + generateToken());
|
||||
}
|
||||
|
||||
let _keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
|
||||
const useBase64 = {
|
||||
encode64: (e) => {
|
||||
let t = "";
|
||||
let f = 0;
|
||||
e = useBase64.encodeUTF8(e);
|
||||
while (f < e.length) {
|
||||
const n = e.charCodeAt(f++);
|
||||
const r = e.charCodeAt(f++);
|
||||
const i = e.charCodeAt(f++);
|
||||
let s = n >> 2;
|
||||
let o = (n & 3) << 4 | r >> 4;
|
||||
let u = (r & 15) << 2 | i >> 6;
|
||||
let a = i & 63;
|
||||
if (isNaN(r)) {
|
||||
u = a = 64;
|
||||
} else if (isNaN(i)) {
|
||||
a = 64;
|
||||
}
|
||||
t += _keyStr[s] + _keyStr[o] + _keyStr[u] + _keyStr[a];
|
||||
}
|
||||
return t;
|
||||
},
|
||||
decode64: (e) => {
|
||||
let t = "";
|
||||
let f = 0;
|
||||
e = e.replace(/[^A-Za-z0-9+/=]/g, "");
|
||||
while (f < e.length) {
|
||||
const s = _keyStr.indexOf(e.charAt(f++));
|
||||
const o = _keyStr.indexOf(e.charAt(f++));
|
||||
const u = _keyStr.indexOf(e.charAt(f++));
|
||||
const a = _keyStr.indexOf(e.charAt(f++));
|
||||
let n = s << 2 | o >> 4;
|
||||
let r = (o & 15) << 4 | u >> 2;
|
||||
let i = (u & 3) << 6 | a;
|
||||
t += String.fromCharCode(n);
|
||||
if (u !== 64) {
|
||||
t += String.fromCharCode(r);
|
||||
}
|
||||
if (a !== 64) {
|
||||
t += String.fromCharCode(i);
|
||||
}
|
||||
}
|
||||
return useBase64.decodeUTF8(t);
|
||||
},
|
||||
|
||||
encodeUTF8: (input) => {
|
||||
return unescape(encodeURIComponent(input));
|
||||
},
|
||||
|
||||
decodeUTF8: (input) => {
|
||||
return decodeURIComponent(escape(input));
|
||||
},
|
||||
}
|
||||
|
||||
/* 校验查询关键字是否包含特殊字符 */
|
||||
function checkValue(value) {
|
||||
if (value) {
|
||||
let pattern = new RegExp("[%_<>]");
|
||||
if (pattern.test(value)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// 页面401关闭页面
|
||||
function closeWindowOpen() {
|
||||
let layerIndex = top.layer.confirm('登录已过期,请点击确定后重新登录!', {
|
||||
btn: ['确认', '取消'],
|
||||
'title': '操作提示',
|
||||
move:false,
|
||||
cancel: function (index, layero) {
|
||||
sessionStorage.removeItem('gz-token');
|
||||
window.close();
|
||||
}
|
||||
}, function () {
|
||||
sessionStorage.removeItem('gz-token');
|
||||
window.close();
|
||||
top.layer.close(layerIndex);
|
||||
}, function () {
|
||||
sessionStorage.removeItem('gz-token');
|
||||
window.close();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
19
js/public.js
19
js/public.js
|
|
@ -1,16 +1,17 @@
|
|||
// const dataUrl = 'http://localhost:21520/aqd_screen/'; // 数据请求路径--安全工器具
|
||||
// const dataUrlDevice = 'http://localhost:21521/'; // 数据请求路径-工器具
|
||||
// const dataUrlCar = 'http://localhost:21522/gz_car/'; // 数据请求路径-车辆
|
||||
const dataUrl = 'http://127.0.0.1:21520/'; // 数据请求路径--安全工器具
|
||||
const dataUrlDevice = 'http://localhost:21521/'; // 数据请求路径-工器具
|
||||
const dataUrlCar = 'http://localhost:21522/gz_car/'; // 数据请求路径-车辆
|
||||
// const dataUrl = 'http://192.168.0.50:21995/'; // 数据请求路径-亮
|
||||
// const fileUrl = 'http://127.0.0.1:21995/statics'; // 文件路径
|
||||
// const signFileUrl = 'http://127.0.0.1:21995/statics'; // 签名文件路径
|
||||
|
||||
// const viewFileUrl = 'http://192.168.0.14:8012/onlinePreview?url=' //14服务器预览文件
|
||||
|
||||
|
||||
const dataUrl = 'http://192.168.0.16:21520/gz-aqgqj/'; // 数据请求路径
|
||||
const fileUrl = 'http://192.168.0.16:21520/gz-aqgqj/statics'; // 文件路径
|
||||
const fileUrl = 'http://127.0.0.1:21995/statics'; // 文件路径
|
||||
const signFileUrl = 'http://127.0.0.1:21995/statics'; // 签名文件路径
|
||||
const viewFileUrl = 'http://192.168.0.14:8012/onlinePreview?url=' //14服务器预览文件
|
||||
|
||||
// const dataUrl = 'http://192.168.0.16:21520/gz-aqgqj/'; // 数据请求路径
|
||||
// const fileUrl = 'http://192.168.0.16:21520/gz-aqgqj/statics'; // 文件路径
|
||||
// const viewFileUrl = 'http://192.168.0.14:8012/onlinePreview?url=' //14服务器预览文件
|
||||
|
||||
|
||||
/* 请求 */
|
||||
function ajaxRequest(url, type, data, async, beforeFn, successFn, errorFn, contentType) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue