refactor: 程序版本写入PLC改用 Web_WritePLC 接口

This commit is contained in:
XingCheng3
2026-05-29 15:38:51 +08:00
parent 123034aeb4
commit 0d9b3f6d80
2 changed files with 26 additions and 8 deletions

View File

@@ -449,7 +449,7 @@
<script> <script>
import { mapGetters } from 'vuex' import { mapGetters } from 'vuex'
import axios from 'axios' import axios from 'axios'
import { mqttIp, mqttTopic, mqttInitRequestTopic, writePlcApi_BtnType, selectOpNameApi, multiReadPlcApi, partUnloadedApi } from '@/../static/config' import { mqttIp, mqttTopic, mqttInitRequestTopic, writePlcApi, writePlcApi_BtnType, selectOpNameApi, multiReadPlcApi, partUnloadedApi } from '@/../static/config'
// ==================== 常量定义 ==================== // ==================== 常量定义 ====================
@@ -491,7 +491,7 @@ const POLL_TOTAL_COUNT = 120
export default { export default {
data() { data() {
return { return {
opNameType: '底架上线', opNameType: '底架上线', // 底架上线 转台上线
opName: '', opName: '',
clickOpName: '', clickOpName: '',
opNameList: [], opNameList: [],
@@ -620,6 +620,15 @@ export default {
}, { timeout: 5000 }) }, { timeout: 5000 })
}, },
/** 写入程序版本到PLC使用 Web_WritePLC 接口) */
async writeProgramVersionToPLC(opName, version) {
return axios.post(writePlcApi, {
tagTypeCodeID: PROGRAM_VERSION_TAG_ID,
OPName: opName,
tagValue: version
}, { timeout: 5000 })
},
/** 根据工位名获取对应的状态对象和托盘对象 */ /** 根据工位名获取对应的状态对象和托盘对象 */
getWorkstationData(opName) { getWorkstationData(opName) {
const isWs1 = opName === this.opNameList[0] const isWs1 = opName === this.opNameList[0]
@@ -1069,7 +1078,7 @@ export default {
if (!historyList || historyList.length === 0) return if (!historyList || historyList.length === 0) return
const version = historyList[0] const version = historyList[0]
try { try {
const r = await this.writePLCValue(opName, PROGRAM_VERSION_TAG_ID, version) const r = await this.writeProgramVersionToPLC(opName, version)
if (r.data.code != 0) { if (r.data.code != 0) {
this.$message.error('程序版本写入PLC失败' + (r.data.msg || '')) this.$message.error('程序版本写入PLC失败' + (r.data.msg || ''))
return return
@@ -1091,7 +1100,7 @@ export default {
const opName = this.versionDialog.opName const opName = this.versionDialog.opName
const result = opName === this.opNameList[0] ? this.ws1Result : this.ws2Result const result = opName === this.opNameList[0] ? this.ws1Result : this.ws2Result
try { try {
const r = await this.writePLCValue(opName, PROGRAM_VERSION_TAG_ID, version) const r = await this.writeProgramVersionToPLC(opName, version)
if (r.data.code != 0) { if (r.data.code != 0) {
this.$message.error('程序版本写入PLC失败' + (r.data.msg || '')) this.$message.error('程序版本写入PLC失败' + (r.data.msg || ''))
return return

View File

@@ -449,7 +449,7 @@
<script> <script>
import { mapGetters } from 'vuex' import { mapGetters } from 'vuex'
import axios from 'axios' import axios from 'axios'
import { mqttIp, mqttTopic, mqttInitRequestTopic, writePlcApi_BtnType, selectOpNameApi, multiReadPlcApi, partUnloadedApi } from '@/../static/config' import { mqttIp, mqttTopic, mqttInitRequestTopic, writePlcApi, writePlcApi_BtnType, selectOpNameApi, multiReadPlcApi, partUnloadedApi } from '@/../static/config'
// ==================== 常量定义 ==================== // ==================== 常量定义 ====================
@@ -491,7 +491,7 @@ const POLL_TOTAL_COUNT = 120
export default { export default {
data() { data() {
return { return {
opNameType: '转台上线', opNameType: '转台上线', // 底架上线 转台上线
opName: '', opName: '',
clickOpName: '', clickOpName: '',
opNameList: [], opNameList: [],
@@ -620,6 +620,15 @@ export default {
}, { timeout: 5000 }) }, { timeout: 5000 })
}, },
/** 写入程序版本到PLC使用 Web_WritePLC 接口) */
async writeProgramVersionToPLC(opName, version) {
return axios.post(writePlcApi, {
tagTypeCodeID: PROGRAM_VERSION_TAG_ID,
OPName: opName,
tagValue: version
}, { timeout: 5000 })
},
/** 根据工位名获取对应的状态对象和托盘对象 */ /** 根据工位名获取对应的状态对象和托盘对象 */
getWorkstationData(opName) { getWorkstationData(opName) {
const isWs1 = opName === this.opNameList[0] const isWs1 = opName === this.opNameList[0]
@@ -1069,7 +1078,7 @@ export default {
if (!historyList || historyList.length === 0) return if (!historyList || historyList.length === 0) return
const version = historyList[0] const version = historyList[0]
try { try {
const r = await this.writePLCValue(opName, PROGRAM_VERSION_TAG_ID, version) const r = await this.writeProgramVersionToPLC(opName, version)
if (r.data.code != 0) { if (r.data.code != 0) {
this.$message.error('程序版本写入PLC失败' + (r.data.msg || '')) this.$message.error('程序版本写入PLC失败' + (r.data.msg || ''))
return return
@@ -1091,7 +1100,7 @@ export default {
const opName = this.versionDialog.opName const opName = this.versionDialog.opName
const result = opName === this.opNameList[0] ? this.ws1Result : this.ws2Result const result = opName === this.opNameList[0] ? this.ws1Result : this.ws2Result
try { try {
const r = await this.writePLCValue(opName, PROGRAM_VERSION_TAG_ID, version) const r = await this.writeProgramVersionToPLC(opName, version)
if (r.data.code != 0) { if (r.data.code != 0) {
this.$message.error('程序版本写入PLC失败' + (r.data.msg || '')) this.$message.error('程序版本写入PLC失败' + (r.data.msg || ''))
return return