refactor: 程序版本选择时即写入PLC,确认上线不再重复写入

This commit is contained in:
XingCheng3
2026-05-29 14:41:29 +08:00
parent ec0e9a96ab
commit 123034aeb4
2 changed files with 60 additions and 24 deletions

View File

@@ -981,7 +981,8 @@ export default {
}
},
/** 实际执行 PLC 写值上线流程;成功后写入手动上线记录 */
/** 实际执行 PLC 写值上线流程;成功后写入手动上线记录
* 注意:程序版本已在选择弹窗确认时写入 PLC此处不再重复写 */
async doPartLoad(opName) {
const result = opName === this.opNameList[0] ? this.ws1Result : this.ws2Result
const partLoadStatus = opName === this.opNameList[0] ? this.ws1PartLoadStatus : this.ws2PartLoadStatus
@@ -998,8 +999,6 @@ export default {
}
try {
const r1 = await this.writePLCValue(opName, PROGRAM_VERSION_TAG_ID, programVersion)
if (r1.data.code != 0) throw new Error(r1.data.msg || '程序版本写入失败')
const r2 = await this.writePLCValue(opName, '205015', 'true')
if (r2.data.code == 0) {
partLoadStatus.success = true
@@ -1061,20 +1060,29 @@ export default {
this.versionDialog.visible = true
},
/** 首次扫码:从数据库取该物料最近一次的程序版本,直接回填,不弹窗 */
/** 首次扫码:从数据库取该物料最近一次的程序版本,直接回填 + 写PLC,不弹窗 */
async autoFillFirstVersion(opName) {
const result = opName === this.opNameList[0] ? this.ws1Result : this.ws2Result
const partCode = result.扫码物料编码 || ''
if (!partCode) return
const historyList = await this.loadHistoryVersions(partCode)
if (historyList && historyList.length > 0) {
result.程序版本 = historyList[0]
this.setLastUsedVersion(opName, historyList[0])
if (!historyList || historyList.length === 0) return
const version = historyList[0]
try {
const r = await this.writePLCValue(opName, PROGRAM_VERSION_TAG_ID, version)
if (r.data.code != 0) {
this.$message.error('程序版本写入PLC失败' + (r.data.msg || ''))
return
}
result.程序版本 = version
this.setLastUsedVersion(opName, version)
} catch (error) {
this.$message.error('程序版本写入PLC失败' + error.message)
}
},
/** "选择程序版本"弹窗确定:把版本回填到对应工位,不自动上线 */
confirmVersionDialog() {
/** "选择程序版本"弹窗确定:把版本回填 + 立即写入 PLC,不自动上线 */
async confirmVersionDialog() {
const version = this.versionDialog.selectedVersion ? this.versionDialog.selectedVersion.toString() : ''
if (!version) {
this.$message.warning('请选择或输入程序版本!')
@@ -1082,9 +1090,19 @@ export default {
}
const opName = this.versionDialog.opName
const result = opName === this.opNameList[0] ? this.ws1Result : this.ws2Result
result.程序版本 = version
this.setLastUsedVersion(opName, version)
this.versionDialog.visible = false
try {
const r = await this.writePLCValue(opName, PROGRAM_VERSION_TAG_ID, version)
if (r.data.code != 0) {
this.$message.error('程序版本写入PLC失败' + (r.data.msg || ''))
return
}
result.程序版本 = version
this.setLastUsedVersion(opName, version)
this.versionDialog.visible = false
this.$message.success('程序版本已写入 PLC')
} catch (error) {
this.$message.error('程序版本写入PLC失败' + error.message)
}
},
/** 读取该工位上一次使用的程序版本localStorage */

View File

@@ -981,7 +981,8 @@ export default {
}
},
/** 实际执行 PLC 写值上线流程;成功后写入手动上线记录 */
/** 实际执行 PLC 写值上线流程;成功后写入手动上线记录
* 注意:程序版本已在选择弹窗确认时写入 PLC此处不再重复写 */
async doPartLoad(opName) {
const result = opName === this.opNameList[0] ? this.ws1Result : this.ws2Result
const partLoadStatus = opName === this.opNameList[0] ? this.ws1PartLoadStatus : this.ws2PartLoadStatus
@@ -998,8 +999,6 @@ export default {
}
try {
const r1 = await this.writePLCValue(opName, PROGRAM_VERSION_TAG_ID, programVersion)
if (r1.data.code != 0) throw new Error(r1.data.msg || '程序版本写入失败')
const r2 = await this.writePLCValue(opName, '205015', 'true')
if (r2.data.code == 0) {
partLoadStatus.success = true
@@ -1061,20 +1060,29 @@ export default {
this.versionDialog.visible = true
},
/** 首次扫码:从数据库取该物料最近一次的程序版本,直接回填,不弹窗 */
/** 首次扫码:从数据库取该物料最近一次的程序版本,直接回填 + 写PLC,不弹窗 */
async autoFillFirstVersion(opName) {
const result = opName === this.opNameList[0] ? this.ws1Result : this.ws2Result
const partCode = result.扫码物料编码 || ''
if (!partCode) return
const historyList = await this.loadHistoryVersions(partCode)
if (historyList && historyList.length > 0) {
result.程序版本 = historyList[0]
this.setLastUsedVersion(opName, historyList[0])
if (!historyList || historyList.length === 0) return
const version = historyList[0]
try {
const r = await this.writePLCValue(opName, PROGRAM_VERSION_TAG_ID, version)
if (r.data.code != 0) {
this.$message.error('程序版本写入PLC失败' + (r.data.msg || ''))
return
}
result.程序版本 = version
this.setLastUsedVersion(opName, version)
} catch (error) {
this.$message.error('程序版本写入PLC失败' + error.message)
}
},
/** "选择程序版本"弹窗确定:把版本回填到对应工位,不自动上线 */
confirmVersionDialog() {
/** "选择程序版本"弹窗确定:把版本回填 + 立即写入 PLC,不自动上线 */
async confirmVersionDialog() {
const version = this.versionDialog.selectedVersion ? this.versionDialog.selectedVersion.toString() : ''
if (!version) {
this.$message.warning('请选择或输入程序版本!')
@@ -1082,9 +1090,19 @@ export default {
}
const opName = this.versionDialog.opName
const result = opName === this.opNameList[0] ? this.ws1Result : this.ws2Result
result.程序版本 = version
this.setLastUsedVersion(opName, version)
this.versionDialog.visible = false
try {
const r = await this.writePLCValue(opName, PROGRAM_VERSION_TAG_ID, version)
if (r.data.code != 0) {
this.$message.error('程序版本写入PLC失败' + (r.data.msg || ''))
return
}
result.程序版本 = version
this.setLastUsedVersion(opName, version)
this.versionDialog.visible = false
this.$message.success('程序版本已写入 PLC')
} catch (error) {
this.$message.error('程序版本写入PLC失败' + error.message)
}
},
/** 读取该工位上一次使用的程序版本localStorage */