|
|
@ -48,24 +48,27 @@ |
|
|
|
</el-carousel> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<div class="footer-info"> |
|
|
|
<!-- <div class="footer-info"> |
|
|
|
<div>扫描产品信息</div> |
|
|
|
<div class="bg-color"> |
|
|
|
<el-input v-model="code" autofocus placeholder="请扫码" @keyup.enter.native="enterPress"></el-input> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> --> |
|
|
|
</div> |
|
|
|
</template> |
|
|
|
<script> |
|
|
|
import { codeparser } from '@/api/quality/pkg.js' |
|
|
|
// import { codeparser } from '@/api/quality/pkg.js' |
|
|
|
import * as api from '@/api/quality/ods' |
|
|
|
import { getOneOdshead } from '@/api/productexe/base' |
|
|
|
import permissLogin from './component/login' |
|
|
|
import { getToken } from '@/utils/auth' |
|
|
|
const neffos = require('neffos.js') |
|
|
|
export default { |
|
|
|
components: {permissLogin}, |
|
|
|
data() { |
|
|
|
return { |
|
|
|
baseUrl: process.env.VUE_APP_BASE_API, |
|
|
|
baseWsUrl: (process.env.VUE_APP_BASE_API).substring(7), |
|
|
|
supplierList: [], |
|
|
|
actPos: 0, |
|
|
|
code: '', |
|
|
@ -77,11 +80,10 @@ export default { |
|
|
|
cutTime: 5000, //轮播时间,单位毫秒 |
|
|
|
nowIndex: 0, |
|
|
|
isLoginVisible: false, // 是否登录 |
|
|
|
// torquePicture: '', // 图片 |
|
|
|
partNumber: '', // 零件号 |
|
|
|
barCodeData: '', // 条形码 |
|
|
|
tableData: [], // 列表数据 |
|
|
|
timer: '', //定时器 |
|
|
|
// timer: '', //定时器 |
|
|
|
} |
|
|
|
}, |
|
|
|
computed: { |
|
|
@ -89,38 +91,87 @@ export default { |
|
|
|
return this.$refs.videoPlayer.player |
|
|
|
}, |
|
|
|
}, |
|
|
|
mounted() { |
|
|
|
// this.runExample() |
|
|
|
}, |
|
|
|
created() { |
|
|
|
this.codeparser() |
|
|
|
// this.codeparser() |
|
|
|
}, |
|
|
|
methods: { |
|
|
|
// 定时获取接口参数 |
|
|
|
timedInterface() { |
|
|
|
if (this.isLoginVisible === true) { |
|
|
|
this.timer = setInterval(() => { |
|
|
|
this.getScrewList() |
|
|
|
}, 1000) |
|
|
|
} |
|
|
|
}, |
|
|
|
// 获取当前零件最新数据 |
|
|
|
getScrewList() { |
|
|
|
let params = { |
|
|
|
stn: this.workPlaceNr |
|
|
|
} |
|
|
|
api.getScrewList(params).then((res) => { |
|
|
|
if (res.code == 200) { |
|
|
|
this.partNumber = res.data['PARTNO'] |
|
|
|
this.barCodeData = res.data['UNITSN'] |
|
|
|
} else { |
|
|
|
this.$message.error(res.msg) |
|
|
|
async runExample() { |
|
|
|
const _this = this |
|
|
|
const ws = (function (getToken){ |
|
|
|
const self = {} |
|
|
|
const nameSpaces = {} |
|
|
|
function register(nameSpaceName, events) { |
|
|
|
events._OnNamespaceConnected = function (nsConn, msg) { |
|
|
|
if (nsConn.conn.wasReconnected()) { |
|
|
|
console.log(`re-onnected to namespace: ${msg.Namespace}${nsConn.conn.reconnectTries} after trie(s)`); |
|
|
|
} else { |
|
|
|
console.log(`onnected to namespace: ${msg.Namespace}`); |
|
|
|
} |
|
|
|
nsConn.emit("login",JSON.stringify({ |
|
|
|
'token': getToken(), |
|
|
|
'STN': String(_this.workPlaceNr) |
|
|
|
})); |
|
|
|
}; |
|
|
|
events.onLogin = function (nsConn, msg) { |
|
|
|
console.log(msg) |
|
|
|
}; |
|
|
|
nameSpaces[nameSpaceName] = events |
|
|
|
} |
|
|
|
async function dial(host) { |
|
|
|
return await neffos.dial(`ws://${host}/admin/ws`, nameSpaces, { |
|
|
|
reconnect: 1000 * 5 |
|
|
|
}); |
|
|
|
} |
|
|
|
self.register = register; |
|
|
|
self.dial = dial; |
|
|
|
return self; |
|
|
|
})(getToken) |
|
|
|
|
|
|
|
ws.register("EODS", { |
|
|
|
STN_DATA: function (nsConn, msg) { |
|
|
|
let msgData = JSON.parse(msg.Body) |
|
|
|
_this.code = msgData.UNITSN |
|
|
|
_this.partNumber = msgData['PARTNO'] |
|
|
|
_this.barCodeData = msgData['UNITSN'] |
|
|
|
_this.getArtrouteodsLst() |
|
|
|
// console.log(JSON.parse(msg.Body)) |
|
|
|
} |
|
|
|
}) |
|
|
|
const connection = await ws.dial(_this.baseWsUrl) |
|
|
|
connection.connect("EODS"); |
|
|
|
}, |
|
|
|
// 定时获取接口参数 |
|
|
|
// timedInterface() { |
|
|
|
// if (this.isLoginVisible === true) { |
|
|
|
// this.timer = setInterval(() => { |
|
|
|
// this.getScrewList() |
|
|
|
// }, 1000) |
|
|
|
// } |
|
|
|
// }, |
|
|
|
// 获取当前零件最新数据 |
|
|
|
// getScrewList() { |
|
|
|
// let params = { |
|
|
|
// stn: this.workPlaceNr |
|
|
|
// } |
|
|
|
// api.getScrewList(params).then((res) => { |
|
|
|
// if (res.code == 200) { |
|
|
|
// this.partNumber = res.data['PARTNO'] |
|
|
|
// this.barCodeData = res.data['UNITSN'] |
|
|
|
// } else { |
|
|
|
// this.$message.error(res.msg) |
|
|
|
// } |
|
|
|
// }) |
|
|
|
// }, |
|
|
|
getLoginMessage(data) { |
|
|
|
if (data.isLoginSuccess === true) { |
|
|
|
this.workPlaceNr = data.actPosItem |
|
|
|
this.isLoginVisible = data.isLoginSuccess |
|
|
|
this.getScrewList() |
|
|
|
this.timedInterface() |
|
|
|
this.runExample() |
|
|
|
// this.getScrewList() |
|
|
|
// this.timedInterface() |
|
|
|
} |
|
|
|
}, |
|
|
|
// andon按钮触发事件 |
|
|
@ -137,33 +188,33 @@ export default { |
|
|
|
}) |
|
|
|
}, |
|
|
|
// 扫码回车提交 |
|
|
|
enterPress(e) { |
|
|
|
if (!this.isLoginVisible) { |
|
|
|
this.$message({ |
|
|
|
type: 'warning', |
|
|
|
message: '请先登录', |
|
|
|
}) |
|
|
|
return |
|
|
|
} |
|
|
|
let code = e.target.value.trim() |
|
|
|
let ruleCode = this.codeRules.filter( |
|
|
|
(code) => code['CodeParser-ParserId'] == 'EODS' |
|
|
|
)[0] |
|
|
|
if (ruleCode['CodeParser-Length'] != 0) { |
|
|
|
code = code.substr( |
|
|
|
ruleCode['CodeParser-StartPos'], |
|
|
|
ruleCode['CodeParser-Length'] |
|
|
|
) |
|
|
|
} |
|
|
|
this.code = code |
|
|
|
this.getArtrouteodsLst() |
|
|
|
}, |
|
|
|
// enterPress(e) { |
|
|
|
// if (!this.isLoginVisible) { |
|
|
|
// this.$message({ |
|
|
|
// type: 'warning', |
|
|
|
// message: '请先登录', |
|
|
|
// }) |
|
|
|
// return |
|
|
|
// } |
|
|
|
// let code = e.target.value.trim() |
|
|
|
// let ruleCode = this.codeRules.filter( |
|
|
|
// (code) => code['CodeParser-ParserId'] == 'EODS' |
|
|
|
// )[0] |
|
|
|
// if (ruleCode['CodeParser-Length'] != 0) { |
|
|
|
// code = code.substr( |
|
|
|
// ruleCode['CodeParser-StartPos'], |
|
|
|
// ruleCode['CodeParser-Length'] |
|
|
|
// </span><span class="err"> pan> ) |
|
|
|
// } |
|
|
|
// this.code = code |
|
|
|
// this.getArtrouteodsLst() |
|
|
|
// }, |
|
|
|
//获取扫码规则 |
|
|
|
codeparser() { |
|
|
|
codeparser().then((res) => { |
|
|
|
this.codeRules = res.data |
|
|
|
}) |
|
|
|
}, |
|
|
|
// codeparser() { |
|
|
|
// codeparser().then((res) => { |
|
|
|
// this.codeRules = res.data |
|
|
|
// }) |
|
|
|
// }, |
|
|
|
// 根据条码获取信息 |
|
|
|
getArtrouteodsLst() { |
|
|
|
api.getArtrouteodsLst(this.code, this.workPlaceNr).then(async (res) => { |
|
|
@ -234,11 +285,11 @@ export default { |
|
|
|
}) |
|
|
|
}, |
|
|
|
}, |
|
|
|
beforeDestroy() { |
|
|
|
if (this.timer) { |
|
|
|
clearInterval(this.timer) |
|
|
|
} |
|
|
|
}, |
|
|
|
// beforeDestroy() { |
|
|
|
// if (this.timer) { |
|
|
|
// clearInterval(this.timer) |
|
|
|
// } |
|
|
|
// }, |
|
|
|
} |
|
|
|
</script> |
|
|
|
<style lang="scss" scoped> |
|
|
|