init
This commit is contained in:
162
src/config/LodopFuncs.js
Executable file
162
src/config/LodopFuncs.js
Executable file
@@ -0,0 +1,162 @@
|
||||
/* eslint-disable */
|
||||
import store from '../vuex/store'
|
||||
var CreatedOKLodop7766=null;
|
||||
|
||||
/****************************************
|
||||
*
|
||||
* 系统加载初始化
|
||||
*
|
||||
*/
|
||||
var js=document.scripts;
|
||||
var jsRoot;
|
||||
var jsversion="";
|
||||
for(var i=0;i<js.length;i++){
|
||||
if(js[i].src.indexOf("wdk.js")>-1){
|
||||
jsRoot=js[i].src.substring(0,js[i].src.lastIndexOf("/")+1);
|
||||
if(js[i].src.lastIndexOf("?")>-1){
|
||||
jsversion=js[i].src.substr(js[i].src.lastIndexOf("?"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//====判断是否需要安装CLodop云打印服务器:====
|
||||
export function needCLodop(){
|
||||
try{
|
||||
var ua=navigator.userAgent;
|
||||
if (ua.match(/Windows\sPhone/i) !=null) return true;
|
||||
if (ua.match(/iPhone|iPod/i) != null) return true;
|
||||
if (ua.match(/Android/i) != null) return true;
|
||||
if (ua.match(/Edge\D?\d+/i) != null) return true;
|
||||
|
||||
var verTrident=ua.match(/Trident\D?\d+/i);
|
||||
var verIE=ua.match(/MSIE\D?\d+/i);
|
||||
var verOPR=ua.match(/OPR\D?\d+/i);
|
||||
var verFF=ua.match(/Firefox\D?\d+/i);
|
||||
var x64=ua.match(/x64/i);
|
||||
if ((verTrident==null)&&(verIE==null)&&(x64!==null))
|
||||
return true; else
|
||||
if ( verFF !== null) {
|
||||
verFF = verFF[0].match(/\d+/);
|
||||
if ((verFF[0]>= 41)||(x64!==null)) return true;
|
||||
} else
|
||||
if ( verOPR !== null) {
|
||||
verOPR = verOPR[0].match(/\d+/);
|
||||
if ( verOPR[0] >= 32 ) return true;
|
||||
} else
|
||||
if ((verTrident==null)&&(verIE==null)) {
|
||||
var verChrome=ua.match(/Chrome\D?\d+/i);
|
||||
if ( verChrome !== null ) {
|
||||
verChrome = verChrome[0].match(/\d+/);
|
||||
if (verChrome[0]>=41) return true;
|
||||
};
|
||||
};
|
||||
return false;
|
||||
} catch(err) {return true;};
|
||||
};
|
||||
|
||||
//====页面引用CLodop云打印必须的JS文件:====
|
||||
// if (needCLodop()) {
|
||||
// var head = document.head || document.getElementsByTagName("head")[0] || document.documentElement;
|
||||
// var oscript = document.createElement("script");
|
||||
// oscript.src =store.getters.printUrl + "/CLodopfuncs.js?name=LODOP1";
|
||||
// head.insertBefore( oscript,head.firstChild );
|
||||
|
||||
// //引用双端口(8000和18000)避免其中某个被占用:
|
||||
// oscript = document.createElement("script");
|
||||
// oscript.src =store.getters.billPrintUrl + "/CLodopfuncs.js?name=LODOP2";
|
||||
// head.insertBefore( oscript,head.firstChild );
|
||||
// };
|
||||
|
||||
export function addCLodop () {
|
||||
var head = document.head || document.getElementsByTagName("head")[0] || document.documentElement;
|
||||
var oscript = document.createElement("script");
|
||||
oscript.src =store.getters.printUrl + "/CLodopfuncs.js?name=LODOP1";
|
||||
head.insertBefore( oscript,head.firstChild );
|
||||
|
||||
//引用双端口(8000和18000)避免其中某个被占用:
|
||||
oscript = document.createElement("script");
|
||||
oscript.src =store.getters.billPrintUrl + "/CLodopfuncs.js?name=LODOP2";
|
||||
head.insertBefore( oscript,head.firstChild );
|
||||
}
|
||||
|
||||
//====获取LODOP对象的主过程:====
|
||||
export function getLodop(oOBJECT,oEMBED){
|
||||
var strHtmInstall="<br><font color='#FF00FF'>打印控件未安装!点击这里<a href='"+jsRoot+"lib/lodop/install_lodop32.exe' target='_self'>执行安装</a>,安装后请刷新页面或重新进入。</font>";
|
||||
var strHtmUpdate="<br><font color='#FF00FF'>打印控件需要升级!点击这里<a href='"+jsRoot+"lib/lodop/install_lodop32.exe' target='_self'>执行升级</a>,升级后请重新进入。</font>";
|
||||
var strHtm64_Install="<br><font color='#FF00FF'>打印控件未安装!点击这里<a href='"+jsRoot+"lib/lodop/install_lodop64.exe' target='_self'>执行安装</a>,安装后请刷新页面或重新进入。</font>";
|
||||
var strHtm64_Update="<br><font color='#FF00FF'>打印控件需要升级!点击这里<a href='"+jsRoot+"lib/lodop/install_lodop64.exe' target='_self'>执行升级</a>,升级后请重新进入。</font>";
|
||||
var strHtmFireFox="<br><br><font color='#FF00FF'>(注意:如曾安装过Lodop旧版附件npActiveXPLugin,请在【工具】->【附加组件】->【扩展】中先卸它)</font>";
|
||||
var strHtmChrome="<br><br><font color='#FF00FF'>(如果此前正常,仅因浏览器升级或重安装而出问题,需重新执行以上安装)</font>";
|
||||
var strCLodopInstall="<br><font color='#FF00FF'>CLodop云打印服务(localhost本地)未安装启动!点击这里<a href='"+jsRoot+"lib/lodop/CLodop_Setup_for_Win32NT.exe' target='_self'>执行安装</a>,安装后请刷新页面。</font>";
|
||||
var strCLodopUpdate="<br><font color='#FF00FF'>CLodop云打印服务需升级!点击这里<a href='"+jsRoot+"lib/lodop/CLodop_Setup_for_Win32NT.exe' target='_self'>执行升级</a>,升级后请刷新页面。</font>";
|
||||
var LODOP;
|
||||
try{
|
||||
var isIE = (navigator.userAgent.indexOf('MSIE')>=0) || (navigator.userAgent.indexOf('Trident')>=0);
|
||||
if (needCLodop()) {
|
||||
try{ LODOP=getCLodop();} catch(err) {};
|
||||
if (!LODOP && document.readyState!=="complete") {alert("C-Lodop没准备好,请稍后再试!"); return;};
|
||||
if (!LODOP) {
|
||||
if (isIE) document.write(strCLodopInstall); else
|
||||
alert(strCLodopInstall);
|
||||
return;
|
||||
} else {
|
||||
|
||||
if (CLODOP.CVERSION<"3.0.2.5") {
|
||||
if (isIE) document.write(strCLodopUpdate); else
|
||||
alert(strCLodopUpdate);
|
||||
};
|
||||
if (oEMBED && oEMBED.parentNode) oEMBED.parentNode.removeChild(oEMBED);
|
||||
if (oOBJECT && oOBJECT.parentNode) oOBJECT.parentNode.removeChild(oOBJECT);
|
||||
};
|
||||
} else {
|
||||
var is64IE = isIE && (navigator.userAgent.indexOf('x64')>=0);
|
||||
//=====如果页面有Lodop就直接使用,没有则新建:==========
|
||||
if (oOBJECT!=undefined || oEMBED!=undefined) {
|
||||
if (isIE) LODOP=oOBJECT; else LODOP=oEMBED;
|
||||
} else if (CreatedOKLodop7766==null){
|
||||
LODOP=document.createElement("object");
|
||||
LODOP.setAttribute("width",0);
|
||||
LODOP.setAttribute("height",0);
|
||||
LODOP.setAttribute("style","position:absolute;left:0px;top:-100px;width:0px;height:0px;");
|
||||
if (isIE) LODOP.setAttribute("classid","clsid:2105C259-1E0C-4534-8141-A753534CB4CA");
|
||||
else LODOP.setAttribute("type","application/x-print-lodop");
|
||||
document.documentElement.appendChild(LODOP);
|
||||
CreatedOKLodop7766=LODOP;
|
||||
} else LODOP=CreatedOKLodop7766;
|
||||
//=====Lodop插件未安装时提示下载地址:==========
|
||||
if ((LODOP==null)||(typeof(LODOP.VERSION)=="undefined")) {
|
||||
if (navigator.userAgent.indexOf('Chrome')>=0)
|
||||
alert(strHtmChrome);
|
||||
if (navigator.userAgent.indexOf('Firefox')>=0)
|
||||
alert(strHtmFireFox);
|
||||
if (is64IE) document.write(strHtm64_Install); else
|
||||
if (isIE) document.write(strHtmInstall); else
|
||||
alert(strHtmInstall);
|
||||
return LODOP;
|
||||
};
|
||||
};
|
||||
if (LODOP.VERSION<"6.2.2.0") {
|
||||
if (needCLodop())
|
||||
alert(strCLodopUpdate); else
|
||||
if (is64IE) document.write(strHtm64_Update); else
|
||||
if (isIE) document.write(strHtmUpdate); else
|
||||
alert(strHtmUpdate);
|
||||
return LODOP;
|
||||
};
|
||||
//===如下空白位置适合调用统一功能(如注册语句、语言选择等):===
|
||||
|
||||
//===========================================================
|
||||
return LODOP;
|
||||
} catch(err) {alert("getLodop出错:"+err);};
|
||||
};
|
||||
|
||||
export function urlEncode(){
|
||||
var url = store.getters.imgip + 'wdk?action=wdk.pub&method=attachment_upload&catacode=temp'
|
||||
var url_encode = escape(url)
|
||||
return url_encode
|
||||
};
|
||||
|
||||
// export function getSystemInfoCallback(result){
|
||||
// alert(result)
|
||||
// window.localStorage.setItem('hhtId', result)
|
||||
// }
|
||||
23
src/config/env.js
Normal file
23
src/config/env.js
Normal file
@@ -0,0 +1,23 @@
|
||||
/**
|
||||
* 配置编译环境和线上环境之间的切换
|
||||
*
|
||||
* baseUrl: 域名地址
|
||||
* imgBaseUrl: 图片所在域名地址
|
||||
*
|
||||
*/
|
||||
|
||||
let baseUrl = ''
|
||||
let imgBaseUrl = ''
|
||||
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
baseUrl = 'http://192.168.81.107:8080'
|
||||
imgBaseUrl = 'http://192.168.81.156:8081/hl_nlapp/'
|
||||
} else if (process.env.NODE_ENV === 'production') {
|
||||
baseUrl = 'http://192.168.81.138:8080'
|
||||
imgBaseUrl = 'http://192.168.81.156:8081/hl_nlapp/'
|
||||
}
|
||||
|
||||
export {
|
||||
baseUrl,
|
||||
imgBaseUrl
|
||||
}
|
||||
8
src/config/filter.js
Normal file
8
src/config/filter.js
Normal file
@@ -0,0 +1,8 @@
|
||||
const filter = {
|
||||
numeric (value, bit) {
|
||||
if (!value) return ''
|
||||
return Number(value).toFixed(bit)
|
||||
}
|
||||
}
|
||||
|
||||
export default filter
|
||||
68
src/config/getData1.js
Normal file
68
src/config/getData1.js
Normal file
@@ -0,0 +1,68 @@
|
||||
import {post, post2} from '@config/http.js'
|
||||
// import store from '../vuex/store'
|
||||
|
||||
// 指令管理
|
||||
// 1.1 查询未完成指令
|
||||
export const queryInstraction = (keyword, scode, ncode) => post2('api/ash/hand/insts', {
|
||||
keyword: keyword,
|
||||
start_devicecode: scode,
|
||||
next_devicecode: ncode
|
||||
})
|
||||
// 1.2 指令操作
|
||||
export const instOperation = (uuid, type) => post2('api/ash/hand/inst', {
|
||||
inst_uuid: uuid,
|
||||
type: type
|
||||
})
|
||||
|
||||
// 任务管理
|
||||
// 1.1 查询未完成指令
|
||||
export const queryTask = (keyword, scode, ncode) => post2('api/ash/hand/tasks', {
|
||||
keyword: keyword,
|
||||
start_devicecode: scode,
|
||||
next_devicecode: ncode
|
||||
})
|
||||
// 1.2 指令操作
|
||||
export const taskOperation = (uuid, type) => post2('api/ash/hand/taskoperation', {
|
||||
inst_uuid: uuid,
|
||||
type: type
|
||||
})
|
||||
|
||||
// 送料
|
||||
// 1.1查询工序设备点位
|
||||
export const sendMaterialqueryDevice = () => post('api/pda/sendMaterial/queryDevice', {})
|
||||
// 1.2压制叫料确定
|
||||
export const sendMaterialconfirm = (wid, did, pid, pcode, qty, vcode, isfull) => post('api/pda/sendMaterial/confirm', {
|
||||
workprocedure_id: wid,
|
||||
device_id: did,
|
||||
point_id: pid,
|
||||
point_code: pcode,
|
||||
qty: qty,
|
||||
vehicle_code: vcode,
|
||||
is_full: isfull
|
||||
})
|
||||
|
||||
// 压制叫料
|
||||
// 1.1查询点位
|
||||
export const callMaterialqueryPoint = () => post('api/pda/callMaterial/queryPoint', {})
|
||||
// 1.2压制叫料确定
|
||||
export const callMaterialconfirm = (pid, pcode, pname, isfull) => post('api/pda/callMaterial/confirm', {
|
||||
point_id: pid,
|
||||
point_code: pcode,
|
||||
point_name: pname,
|
||||
is_full: isfull
|
||||
})
|
||||
|
||||
// 送空托盘
|
||||
// 1.1查询区域
|
||||
export const sendEmptyqueryArea = () => post('api/pda/sendEmpty/queryArea', {})
|
||||
// 1.2根据区域查询点位
|
||||
export const sendEmptyqueryPointByArea = (acode) => post('api/pda/sendEmpty/queryPointByArea', {
|
||||
area_code: acode
|
||||
})
|
||||
// 1.3 送空托盘确定
|
||||
export const sendEmptyconfirm = (pid, pcode, pname, vcode) => post('api/pda/sendEmpty/confirm', {
|
||||
point_id: pid,
|
||||
point_code: pcode,
|
||||
point_name: pname,
|
||||
vehicle_code: vcode
|
||||
})
|
||||
70
src/config/getData2.js
Normal file
70
src/config/getData2.js
Normal file
@@ -0,0 +1,70 @@
|
||||
import {post} from '@config/http.js'
|
||||
|
||||
// 手持登录
|
||||
export const loginApi = (user, password) => post('api/pda/handlogin', {
|
||||
user: user,
|
||||
password: password
|
||||
})
|
||||
// 手持登陆查询菜单权限
|
||||
export const authority = (id) => post('api/pda/authority', {
|
||||
accountId: id
|
||||
})
|
||||
// 修改密码
|
||||
export const updatePass = (Rfold, Rfnew) => post('api/pda/updatePass', {
|
||||
RfoldPass: Rfold,
|
||||
RfnewPass: Rfnew
|
||||
})
|
||||
|
||||
/** 呼叫空托盘 */
|
||||
// 1.1查询区域
|
||||
export const queryArea = () => post('api/pda/callEmpty/queryArea', {})
|
||||
// 1.2根据区域查询点位
|
||||
export const queryPointByArea = (code) => post('api/pda/callEmpty/queryPointByArea', {
|
||||
area_code: code
|
||||
})
|
||||
// 1.3 呼叫空托盘确定
|
||||
export const callEmptyConfirm = (id, code, pname, acode) => post('api/pda/callEmpty/confirm', {
|
||||
point_id: id,
|
||||
point_code: code,
|
||||
point_name: pname,
|
||||
area_code: acode
|
||||
})
|
||||
|
||||
/** 托盘点位绑定 */
|
||||
// 1.1查询区域
|
||||
export const queryArea1 = () => post('api/pda/sendEmpty/queryArea', {})
|
||||
// 1.2根据区域查询点位
|
||||
export const queryPointByArea1 = (code) => post('api/pda/sendEmpty/queryPointByArea', {
|
||||
area_code: code
|
||||
})
|
||||
// 1.2托盘点位绑定确认
|
||||
export const bindingConfirm = (code, vcode, status, is) => post('api/pda/binding/confirm', {
|
||||
point_code: code,
|
||||
vehicle_code: vcode,
|
||||
point_status: status,
|
||||
is_lock: is
|
||||
})
|
||||
|
||||
/** 盘点管理 */
|
||||
// 1.1查询物料
|
||||
export const queryMaterial = (page, size) => post('api/pda/check/queryMaterial', {
|
||||
page: page,
|
||||
size: size
|
||||
})
|
||||
// 1.2查询盘点单据
|
||||
export const queryIvt = (suuid, tuuid, page, size) => post('api/pda/check/queryIvt', {
|
||||
sect_uuid: suuid,
|
||||
struct_uuid: tuuid,
|
||||
page: page,
|
||||
size: size
|
||||
})
|
||||
// 1.3盘点确定
|
||||
export const checkConfirm = (arr) => post('api/pda/check/confirm', {
|
||||
JSONarray: arr
|
||||
})
|
||||
// 1.4查询库区
|
||||
export const querySectCode = () => post('api/pda/check/querySectCode', {})
|
||||
// 1.5查询仓位
|
||||
export const queryStructCode = (uuid) => post('api/pda/check/queryStructCode', {
|
||||
sect_uuid: uuid
|
||||
})
|
||||
83
src/config/http.js
Normal file
83
src/config/http.js
Normal file
@@ -0,0 +1,83 @@
|
||||
import axios from 'axios'
|
||||
import { Dialog, toast } from './mUtils.js'
|
||||
import store from '../vuex/store'
|
||||
import router from '@/router'
|
||||
|
||||
axios.defaults.timeout = 50000
|
||||
axios.defaults.headers.post['Content-Type'] = 'application/json;charset=UTF-8'
|
||||
|
||||
axios.interceptors.request.use(
|
||||
config => {
|
||||
let token = ''
|
||||
if (store.getters.userInfo !== '') {
|
||||
token = JSON.parse(store.getters.userInfo).token
|
||||
}
|
||||
token && (config.headers.Authorization = token)
|
||||
if (config.method === 'post') {
|
||||
if (!config.data.flag) {
|
||||
config.data = config.data
|
||||
} else {
|
||||
config.data = config.data.formData
|
||||
}
|
||||
}
|
||||
return config
|
||||
},
|
||||
error => {
|
||||
Dialog('错误的传参')
|
||||
return Promise.reject(error)
|
||||
}
|
||||
)
|
||||
|
||||
axios.interceptors.response.use(
|
||||
response => {
|
||||
if (response.status === 200) {
|
||||
return Promise.resolve(response)
|
||||
} else {
|
||||
return Promise.reject(response)
|
||||
}
|
||||
},
|
||||
error => {
|
||||
if (error && error.response) {
|
||||
switch (error.response.status) {
|
||||
case 401:
|
||||
toast(error.response.data.message)
|
||||
store.dispatch('setSignOut')
|
||||
router.push('/login')
|
||||
break
|
||||
}
|
||||
return Promise.reject(error.response.data)
|
||||
} else {
|
||||
return Promise.reject(error)
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
export const post = (sevmethod, params) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
axios.post(`${store.getters.baseUrl}/` + sevmethod, params)
|
||||
.then(response => {
|
||||
resolve(response.data)
|
||||
}, error => {
|
||||
Dialog(error.message)
|
||||
reject(error.message)
|
||||
})
|
||||
.catch((error) => {
|
||||
reject(error)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export const post2 = (sevmethod, params) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
axios.post(`${store.getters.acsUrl}/` + sevmethod, params)
|
||||
.then(response => {
|
||||
resolve(response.data)
|
||||
}, error => {
|
||||
Dialog(error.message)
|
||||
reject(error.message)
|
||||
})
|
||||
.catch((error) => {
|
||||
reject(error)
|
||||
})
|
||||
})
|
||||
}
|
||||
46
src/config/http1.js
Normal file
46
src/config/http1.js
Normal file
@@ -0,0 +1,46 @@
|
||||
import axios from 'axios'
|
||||
import { Dialog } from './mUtils.js'
|
||||
import store from '../vuex/store'
|
||||
|
||||
axios.defaults.timeout = 50000
|
||||
axios.defaults.headers.post['Content-Type'] = 'application/json;charset=UTF-8'
|
||||
|
||||
axios.interceptors.request.use(
|
||||
config => {
|
||||
if (config.method === 'post') {
|
||||
if (!config.data.flag) {
|
||||
config.data = config.data
|
||||
} else {
|
||||
config.data = config.data.formData
|
||||
}
|
||||
}
|
||||
return config
|
||||
},
|
||||
error => {
|
||||
Dialog('错误的传参')
|
||||
return Promise.reject(error)
|
||||
}
|
||||
)
|
||||
|
||||
axios.interceptors.response.use(
|
||||
response => {
|
||||
return Promise.resolve(response)
|
||||
},
|
||||
error => {
|
||||
return Promise.reject(error)
|
||||
}
|
||||
)
|
||||
|
||||
export const post = (sevmethod, params) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
axios.post(`${store.getters.acsUrl}/` + sevmethod, params)
|
||||
.then(response => {
|
||||
resolve(response.data)
|
||||
}, error => {
|
||||
reject(error.message)
|
||||
})
|
||||
.catch((error) => {
|
||||
reject(error)
|
||||
})
|
||||
})
|
||||
}
|
||||
114
src/config/isOperate.js
Normal file
114
src/config/isOperate.js
Normal file
@@ -0,0 +1,114 @@
|
||||
// 用户长时间未操作 退出登录
|
||||
import store from '../vuex/store'
|
||||
import router from '@/router'
|
||||
var timer = null
|
||||
|
||||
clearInterval(timer)
|
||||
|
||||
export function isOperateFun () {
|
||||
var lastTime = new Date().getTime() // 最后一次点击时间
|
||||
var currentTime = new Date().getTime() // 当前时间
|
||||
var timeOut = 10 * 60 * 1000 // 允许最长未操作时间
|
||||
// var i = 1 // 辅助作用
|
||||
|
||||
function handleReset () { // 重新赋值最后一次点击时间,清除定时器,重新开始定时器
|
||||
// console.log('又点击了!!!!!!')
|
||||
// i = 1
|
||||
|
||||
lastTime = new Date().getTime()
|
||||
|
||||
if (timer) {
|
||||
clearInterval(timer)
|
||||
timer = null
|
||||
}
|
||||
|
||||
if (!timer) {
|
||||
// console.log('真好!重新开始')
|
||||
handleInterval()
|
||||
}
|
||||
}
|
||||
|
||||
// document.onclick = () => { // 单击事件
|
||||
// handleReset()
|
||||
// }
|
||||
|
||||
// document.ondblclick = () => { // 双击事件
|
||||
// handleReset()
|
||||
// }
|
||||
|
||||
// document.onmousedown = () => { // 按下鼠标键时触发
|
||||
// handleReset()
|
||||
// }
|
||||
|
||||
// document.onmouseup = () => { // 释放按下的鼠标键时触发
|
||||
// handleReset()
|
||||
// }
|
||||
|
||||
// document.onmousemove = () => { // 鼠标移动事件
|
||||
// handleReset()
|
||||
// }
|
||||
|
||||
// document.onmouseover = () => { // 移入事件
|
||||
// handleReset()
|
||||
// }
|
||||
|
||||
// document.onmouseout = () => { // 移出事件
|
||||
// handleReset()
|
||||
// }
|
||||
|
||||
// document.onmouseenter = () => { // 移入事件
|
||||
// handleReset()
|
||||
// }
|
||||
|
||||
// document.onmouseleave = () => { // 移出事件
|
||||
// handleReset()
|
||||
// }
|
||||
|
||||
// document.touchstart = () => {
|
||||
// alert('touchstart')
|
||||
// handleReset()
|
||||
// }
|
||||
|
||||
// document.touchend = () => {
|
||||
// alert('touchend')
|
||||
// handleReset()
|
||||
// }
|
||||
|
||||
// document.touchmove = () => {
|
||||
// alert('touchend')
|
||||
// handleReset()
|
||||
// }
|
||||
|
||||
window.onload = function startup () {
|
||||
document.addEventListener('touchstart', handleReset, false)
|
||||
document.addEventListener('touchend', handleReset, false)
|
||||
document.addEventListener('touchmove', handleReset, false)
|
||||
}
|
||||
|
||||
function handleInterval () { // 定时器
|
||||
timer = setInterval(() => {
|
||||
currentTime = new Date().getTime() // 当前时间
|
||||
|
||||
// console.log(`${i++}-currentTime`, currentTime)
|
||||
// console.log('最后一次点击时间', lastTime)
|
||||
|
||||
if (currentTime - lastTime > timeOut) {
|
||||
// console.log('长时间未操作')
|
||||
|
||||
clearInterval(timer) // 清除定时器
|
||||
|
||||
store.dispatch('setSignOut').then(() => { // 执行退出并跳转到首页
|
||||
const path = window.location.href.split('#')[1]
|
||||
|
||||
if (path !== '/login') { // 判断当前路由不是首页 则跳转至首页
|
||||
router.push('/login')
|
||||
}
|
||||
|
||||
// window.AndroidWebView.loginOut() // 执行安卓退出方法
|
||||
})
|
||||
}
|
||||
}, 1000)
|
||||
}
|
||||
|
||||
handleInterval() // 一开始程序 默认执行定制器
|
||||
}
|
||||
137
src/config/mUtils.js
Normal file
137
src/config/mUtils.js
Normal file
@@ -0,0 +1,137 @@
|
||||
import store from '../vuex/store'
|
||||
|
||||
/**
|
||||
* 弹出框
|
||||
*/
|
||||
export const Dialog = (str) => {
|
||||
store.dispatch('showAlert', true)
|
||||
store.dispatch('alertMsg', str)
|
||||
// setTimeout(() => {
|
||||
// store.dispatch('showAlert', false)
|
||||
// }, 30000)
|
||||
}
|
||||
|
||||
/**
|
||||
* 提示框
|
||||
*/
|
||||
export const toast = (str) => {
|
||||
store.dispatch('showToast', true)
|
||||
store.dispatch('toastMsg', str)
|
||||
setTimeout(() => {
|
||||
store.dispatch('showToast', false)
|
||||
}, 3000)
|
||||
}
|
||||
|
||||
/**
|
||||
* 存储localStorage
|
||||
*/
|
||||
export const setStore = (name, content) => {
|
||||
if (!name) return
|
||||
if (typeof content !== 'string') {
|
||||
content = JSON.stringify(content)
|
||||
}
|
||||
window.localStorage.setItem(name, content)
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取localStorage
|
||||
*/
|
||||
export const getStore = name => {
|
||||
if (!name) return
|
||||
return window.localStorage.getItem(name)
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取style样式
|
||||
*/
|
||||
export const getStyle = (element, attr, NumberMode = 'int') => {
|
||||
let target
|
||||
// scrollTop 获取方式不同,没有它不属于style,而且只有document.body才能用
|
||||
if (attr === 'scrollTop') {
|
||||
target = element.scrollTop
|
||||
} else if (element.currentStyle) {
|
||||
target = element.currentStyle[attr]
|
||||
} else {
|
||||
target = document.defaultView.getComputedStyle(element, null)[attr]
|
||||
}
|
||||
// 在获取 opactiy 时需要获取小数 parseFloat
|
||||
return NumberMode === 'float' ? parseFloat(target) : parseInt(target)
|
||||
}
|
||||
|
||||
/**
|
||||
* 小数加法
|
||||
*/
|
||||
export const accAdd = (arg1, arg2) => {
|
||||
var r1, r2, m, c
|
||||
try {
|
||||
r1 = arg1.toString().split('.')[1].length
|
||||
} catch (e) {
|
||||
r1 = 0
|
||||
}
|
||||
try {
|
||||
r2 = arg2.toString().split('.')[1].length
|
||||
} catch (e) {
|
||||
r2 = 0
|
||||
}
|
||||
c = Math.abs(r1 - r2)
|
||||
m = Math.pow(10, Math.max(r1, r2))
|
||||
if (c > 0) {
|
||||
var cm = Math.pow(10, c)
|
||||
if (r1 > r2) {
|
||||
arg1 = Number(arg1.toString().replace('.', ''))
|
||||
arg2 = Number(arg2.toString().replace('.', '')) * cm
|
||||
} else {
|
||||
arg1 = Number(arg1.toString().replace('.', '')) * cm
|
||||
arg2 = Number(arg2.toString().replace('.', ''))
|
||||
}
|
||||
} else {
|
||||
arg1 = Number(arg1.toString().replace('.', ''))
|
||||
arg2 = Number(arg2.toString().replace('.', ''))
|
||||
}
|
||||
return (arg1 + arg2) / m
|
||||
}
|
||||
|
||||
/**
|
||||
* 小数减法
|
||||
*/
|
||||
export const accSubtract = (arg1, arg2) => {
|
||||
var r1, r2, m, c
|
||||
try {
|
||||
r1 = arg1.toString().split('.')[1].length
|
||||
} catch (e) {
|
||||
r1 = 0
|
||||
}
|
||||
try {
|
||||
r2 = arg2.toString().split('.')[1].length
|
||||
} catch (e) {
|
||||
r2 = 0
|
||||
}
|
||||
c = Math.abs(r1 - r2)
|
||||
m = Math.pow(10, Math.max(r1, r2))
|
||||
if (c > 0) {
|
||||
var cm = Math.pow(10, c)
|
||||
if (r1 > r2) {
|
||||
arg1 = Number(arg1.toString().replace('.', ''))
|
||||
arg2 = Number(arg2.toString().replace('.', '')) * cm
|
||||
} else {
|
||||
arg1 = Number(arg1.toString().replace('.', '')) * cm
|
||||
arg2 = Number(arg2.toString().replace('.', ''))
|
||||
}
|
||||
} else {
|
||||
arg1 = Number(arg1.toString().replace('.', ''))
|
||||
arg2 = Number(arg2.toString().replace('.', ''))
|
||||
}
|
||||
return (arg1 - arg2) / m
|
||||
}
|
||||
|
||||
/**
|
||||
* 小数乘法
|
||||
*/
|
||||
export const accMul = (arg1, arg2) => {
|
||||
var m = 0
|
||||
var s1 = arg1.toString()
|
||||
var s2 = arg2.toString()
|
||||
try { m += s1.split('.')[1].length } catch (e) {}
|
||||
try { m += s2.split('.')[1].length } catch (e) {}
|
||||
return Number(s1.replace('.', '')) * Number(s2.replace('.', '')) / Math.pow(10, m)
|
||||
}
|
||||
88
src/config/print.js
Normal file
88
src/config/print.js
Normal file
@@ -0,0 +1,88 @@
|
||||
export const initPrint = jparam => {
|
||||
var LODOP = this.LODOP
|
||||
console.log(LODOP, 'LODOP')
|
||||
// var LODOP=getLodop()
|
||||
if (typeof (LODOP) === 'undefined') {
|
||||
return null
|
||||
}
|
||||
LODOP.PRINT_INITA(0, 0, jparam.width, jparam.height, jparam.name)
|
||||
// LODOP.PRINT_INIT(jparam.name)
|
||||
LODOP.SET_LICENSES('浙江省烟草专卖局(公司)', 'C0C4A46A3A0D1F526D426018D9F11921', '', '')
|
||||
// LODOP.SET_PRINT_PAGESIZE(1, jparam.width/*0.1mm为单位*/, jparam.height, 'A4')
|
||||
// LODOP.SET_PRINT_MODE('POS_BASEON_PAPER', true)
|
||||
if (jparam.background) {
|
||||
LODOP.ADD_PRINT_SETUP_BKIMG("<img border='0' src='" + jparam.background + "'>")
|
||||
LODOP.SET_SHOW_MODE('BKIMG_IN_PREVIEW', 1) // 注:"BKIMG_IN_PREVIEW"-预览包含背景图 "BKIMG_IN_FIRSTPAGE"- 仅首页包含背景图
|
||||
}
|
||||
LODOP.SET_SHOW_MODE('SETUP_ENABLESS', '10000000000000')
|
||||
LODOP.SET_SHOW_MODE('HIDE_DISBUTTIN_SETUP', 1)// 隐藏那些无效按钮
|
||||
return LODOP
|
||||
}
|
||||
|
||||
export const print = data => {
|
||||
var LODOP = this.LODOP
|
||||
// alert(1)
|
||||
// LODOP.PRINT_INIT("打印任务名"); // 首先一个初始化语句
|
||||
// LODOP.ADD_PRINT_TEXT(0,0,100,20,"文本内容一");// 然后多个ADD语句及SET语句
|
||||
// LODOP.PRINT(); // 最后一个打印(或预览、维护、设计)语句
|
||||
// debugger
|
||||
// var data = {
|
||||
// param1: 'BGH00015',
|
||||
// param2: '8月',
|
||||
// param3: '马达,TE3-132S-4 5.5KW B3',
|
||||
// param4: '03049',
|
||||
// param5: '10',
|
||||
// // param6:'01#BGH00015', // 二维码
|
||||
// param6: '这个是二维码的内容。。哈哈哈', // 二维码
|
||||
// param7: '1002:大立库',
|
||||
// param8: '2018-08-18'
|
||||
// }
|
||||
// var LODOP = this.init_Print({
|
||||
// name: '打印模板1',
|
||||
// width: '80mm',
|
||||
// height: '60mm'
|
||||
// })
|
||||
initPrint({
|
||||
name: '打印模板1',
|
||||
width: '80mm',
|
||||
height: '60mm'
|
||||
})
|
||||
console.log('LODOP1', LODOP)
|
||||
if (!LODOP) {
|
||||
this.toast('未连接到打印机')
|
||||
return
|
||||
}
|
||||
// LODOP.PRINT_INITA(0,0,'80mm','60mm','打印模板1')
|
||||
LODOP.ADD_PRINT_RECT(0, 0, '80mm', '60mm', 0, 1)
|
||||
// 第一行 第一个参数
|
||||
// LODOP.SET_PRINT_STYLEA(2, 'FontName', '隶书')
|
||||
LODOP.SET_PRINT_STYLE('FontSize', 25)
|
||||
LODOP.SET_PRINT_STYLE('Bold', 1)
|
||||
LODOP.ADD_PRINT_TEXT('5mm', '5mm', '50mm', '20mm', data.param1)
|
||||
// 第一行 第二个参数
|
||||
LODOP.ADD_PRINT_TEXT('5mm', '60mm', '50mm', '20mm', data.param2)
|
||||
// 第二行 第一个参数
|
||||
LODOP.SET_PRINT_STYLE('FontSize', 13)
|
||||
LODOP.SET_PRINT_STYLE('Bold', 0)
|
||||
LODOP.ADD_PRINT_TEXT('17mm', '5mm', '80mm', '20mm', data.param3)
|
||||
// 第二行 第二个参数
|
||||
LODOP.ADD_PRINT_TEXT('25mm', '15mm', '50mm', '20mm', data.param4)
|
||||
// 第三行 第一个参数
|
||||
LODOP.SET_PRINT_STYLE('FontSize', 20)
|
||||
LODOP.SET_PRINT_STYLE('Bold', 0)
|
||||
LODOP.ADD_PRINT_TEXT('33mm', '10mm', '50mm', '20mm', data.param5)
|
||||
// LODOP.ADD_PRINT_TEXT('33mm', '25mm', '20mm', '20mm', '台')
|
||||
// 第四行 第一个参数
|
||||
LODOP.SET_PRINT_STYLE('FontSize', 15)
|
||||
LODOP.SET_PRINT_STYLE('Bold', 0)
|
||||
LODOP.ADD_PRINT_TEXT('43mm', '5mm', '60mm', '20mm', data.param7)
|
||||
// 第五行 第一个参数
|
||||
LODOP.ADD_PRINT_TEXT('53mm', '5mm', '60mm', '20mm', data.param8)
|
||||
// 打印二维码
|
||||
LODOP.ADD_PRINT_BARCODE('25mm', '45mm', '35mm', '35mm', 'QRCode', data.param6)
|
||||
// LODOP.SET_PRINT_STYLEA(0, 'GroundColor', '#0080FF')
|
||||
console.log('LODOP2', LODOP)
|
||||
LODOP.PRINT()
|
||||
console.log('LODOP3', LODOP)
|
||||
this.toast('打印成功!')
|
||||
}
|
||||
12
src/config/rem.js
Normal file
12
src/config/rem.js
Normal file
@@ -0,0 +1,12 @@
|
||||
(function (doc, win) {
|
||||
var docEl = doc.documentElement
|
||||
var resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize'
|
||||
var recalc = function () {
|
||||
var clientWidth = docEl.clientWidth
|
||||
if (!clientWidth) return
|
||||
docEl.style.fontSize = 100 * (clientWidth / 750) + 'px'
|
||||
}
|
||||
if (!doc.addEventListener) return
|
||||
win.addEventListener(resizeEvt, recalc, false)
|
||||
doc.addEventListener('DOMContentLoaded', recalc, false)
|
||||
})(document, window)
|
||||
Reference in New Issue
Block a user