1
This commit is contained in:
@@ -8,6 +8,17 @@ export function executeInstruction(data) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function executeInstructionWithForce(data) {
|
||||||
|
return request({
|
||||||
|
url: '/jarvis/instruction/execute',
|
||||||
|
method: 'post',
|
||||||
|
data: {
|
||||||
|
...data,
|
||||||
|
forceGenerate: true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
export function getHistory(type, limit) {
|
export function getHistory(type, limit) {
|
||||||
return request({
|
return request({
|
||||||
url: '/jarvis/instruction/history',
|
url: '/jarvis/instruction/history',
|
||||||
|
|||||||
@@ -116,11 +116,43 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</el-card>
|
</el-card>
|
||||||
|
|
||||||
|
<!-- 地址重复验证码弹窗 -->
|
||||||
|
<el-dialog
|
||||||
|
title="地址重复验证"
|
||||||
|
:visible.sync="verifyDialogVisible"
|
||||||
|
width="400px"
|
||||||
|
:close-on-click-modal="false"
|
||||||
|
:close-on-press-escape="false"
|
||||||
|
>
|
||||||
|
<div style="text-align: center;">
|
||||||
|
<el-alert
|
||||||
|
:title="verifyMessage"
|
||||||
|
type="warning"
|
||||||
|
:closable="false"
|
||||||
|
style="margin-bottom: 20px;"
|
||||||
|
/>
|
||||||
|
<div style="font-size: 24px; font-weight: bold; color: #409EFF; margin: 20px 0;">
|
||||||
|
{{ verifyCode }}
|
||||||
|
</div>
|
||||||
|
<el-input
|
||||||
|
v-model="verifyInput"
|
||||||
|
placeholder="请输入上方四位数字验证码"
|
||||||
|
maxlength="4"
|
||||||
|
style="width: 200px;"
|
||||||
|
@keyup.enter.native="handleVerify"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div slot="footer" class="dialog-footer">
|
||||||
|
<el-button @click="verifyDialogVisible = false">取消</el-button>
|
||||||
|
<el-button type="primary" @click="handleVerify" :loading="verifyLoading">确认</el-button>
|
||||||
|
</div>
|
||||||
|
</el-dialog>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { executeInstruction, getHistory } from '@/api/system/instruction'
|
import { executeInstruction, getHistory, executeInstructionWithForce } from '@/api/system/instruction'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'JdInstruction',
|
name: 'JdInstruction',
|
||||||
@@ -132,7 +164,14 @@ export default {
|
|||||||
requestHistory: [],
|
requestHistory: [],
|
||||||
responseHistory: [],
|
responseHistory: [],
|
||||||
historyLoading: false,
|
historyLoading: false,
|
||||||
historyLimit: 50
|
historyLimit: 50,
|
||||||
|
// 验证码相关
|
||||||
|
verifyDialogVisible: false,
|
||||||
|
verifyCode: '',
|
||||||
|
verifyInput: '',
|
||||||
|
verifyMessage: '',
|
||||||
|
verifyLoading: false,
|
||||||
|
pendingCommand: '' // 待执行的命令(验证通过后执行)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
@@ -188,6 +227,13 @@ export default {
|
|||||||
else if (typeof data === 'string') this.resultList = data ? [data] : []
|
else if (typeof data === 'string') this.resultList = data ? [data] : []
|
||||||
else this.resultList = []
|
else this.resultList = []
|
||||||
|
|
||||||
|
// 检查是否是地址重复错误
|
||||||
|
if (this.checkAddressDuplicate(this.resultList)) {
|
||||||
|
// 显示验证码弹窗
|
||||||
|
this.showVerifyDialog(cmd)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// 检查是否有以[炸弹]开头的消息
|
// 检查是否有以[炸弹]开头的消息
|
||||||
this.checkBombAlert(this.resultList)
|
this.checkBombAlert(this.resultList)
|
||||||
|
|
||||||
@@ -201,6 +247,63 @@ export default {
|
|||||||
this.$modal.msgError('执行失败,请稍后重试')
|
this.$modal.msgError('执行失败,请稍后重试')
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
// 检查是否是地址重复错误
|
||||||
|
checkAddressDuplicate(resultList) {
|
||||||
|
if (!resultList || resultList.length === 0) return false
|
||||||
|
for (let i = 0; i < resultList.length; i++) {
|
||||||
|
const result = resultList[i]
|
||||||
|
if (typeof result === 'string' && result.startsWith('ERROR_CODE:ADDRESS_DUPLICATE')) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
},
|
||||||
|
// 显示验证码弹窗
|
||||||
|
showVerifyDialog(command) {
|
||||||
|
// 生成四位随机数字验证码
|
||||||
|
this.verifyCode = String(Math.floor(1000 + Math.random() * 9000))
|
||||||
|
this.verifyInput = ''
|
||||||
|
this.verifyMessage = '检测到地址重复,请输入验证码以强制生成表单'
|
||||||
|
this.pendingCommand = command
|
||||||
|
this.verifyDialogVisible = true
|
||||||
|
},
|
||||||
|
// 处理验证码验证
|
||||||
|
handleVerify() {
|
||||||
|
if (!this.verifyInput || this.verifyInput.length !== 4) {
|
||||||
|
this.$modal.msgError('请输入四位数字验证码')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (this.verifyInput !== this.verifyCode) {
|
||||||
|
this.$modal.msgError('验证码错误,请重新输入')
|
||||||
|
this.verifyInput = ''
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// 验证通过,使用forceGenerate参数重新执行
|
||||||
|
this.verifyLoading = true
|
||||||
|
executeInstructionWithForce({ command: this.pendingCommand }).then(res => {
|
||||||
|
this.verifyLoading = false
|
||||||
|
this.verifyDialogVisible = false
|
||||||
|
if (res && (res.code === 200 || res.msg === '操作成功')) {
|
||||||
|
const data = res.data
|
||||||
|
if (Array.isArray(data)) this.resultList = data
|
||||||
|
else if (typeof data === 'string') this.resultList = data ? [data] : []
|
||||||
|
else this.resultList = []
|
||||||
|
|
||||||
|
// 检查是否有以[炸弹]开头的消息
|
||||||
|
this.checkBombAlert(this.resultList)
|
||||||
|
|
||||||
|
// 执行成功后刷新历史记录
|
||||||
|
this.loadHistory()
|
||||||
|
this.$modal.msgSuccess('表单已强制生成')
|
||||||
|
} else {
|
||||||
|
this.$modal.msgError(res && res.msg ? res.msg : '执行失败')
|
||||||
|
}
|
||||||
|
}).catch(() => {
|
||||||
|
this.verifyLoading = false
|
||||||
|
this.$modal.msgError('执行失败,请稍后重试')
|
||||||
|
})
|
||||||
|
},
|
||||||
loadHistory() {
|
loadHistory() {
|
||||||
this.historyLoading = true
|
this.historyLoading = true
|
||||||
Promise.all([
|
Promise.all([
|
||||||
|
|||||||
Reference in New Issue
Block a user