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