1
This commit is contained in:
@@ -200,8 +200,68 @@ export default {
|
||||
fillSheng() {
|
||||
this.form.command = '生'
|
||||
},
|
||||
fillMan() {
|
||||
async fillMan() {
|
||||
// 先尝试查询今天的数据
|
||||
this.form.command = '慢单'
|
||||
this.loading = true
|
||||
|
||||
try {
|
||||
const res = await executeInstruction({ command: '慢单' })
|
||||
this.loading = false
|
||||
|
||||
if (res && (res.code === 200 || res.msg === '操作成功')) {
|
||||
const data = res.data
|
||||
let resultData = []
|
||||
if (Array.isArray(data)) resultData = data
|
||||
else if (typeof data === 'string') resultData = data ? [data] : []
|
||||
else resultData = []
|
||||
|
||||
// 如果今天的数据为空,尝试查询昨天的数据
|
||||
if (resultData.length === 0 || (resultData.length === 1 && resultData[0].includes('无数据'))) {
|
||||
this.$message.info('今天暂无慢单数据,正在查询昨天的数据...')
|
||||
|
||||
// 获取昨天的日期
|
||||
const yesterday = new Date()
|
||||
yesterday.setDate(yesterday.getDate() - 1)
|
||||
const yesterdayStr = yesterday.toISOString().split('T')[0].replace(/-/g, '')
|
||||
|
||||
this.loading = true
|
||||
const yesterdayRes = await executeInstruction({ command: `慢单${yesterdayStr}` })
|
||||
this.loading = false
|
||||
|
||||
if (yesterdayRes && (yesterdayRes.code === 200 || yesterdayRes.msg === '操作成功')) {
|
||||
const yesterdayData = yesterdayRes.data
|
||||
if (Array.isArray(yesterdayData)) this.resultList = yesterdayData
|
||||
else if (typeof yesterdayData === 'string') this.resultList = yesterdayData ? [yesterdayData] : []
|
||||
else this.resultList = []
|
||||
|
||||
if (this.resultList.length > 0) {
|
||||
this.$message.success(`已查询到昨天(${yesterdayStr})的慢单数据`)
|
||||
} else {
|
||||
this.$message.warning('昨天也没有慢单数据')
|
||||
this.resultList = []
|
||||
}
|
||||
} else {
|
||||
this.$message.error('查询昨天数据失败')
|
||||
this.resultList = []
|
||||
}
|
||||
} else {
|
||||
// 今天有数据,直接显示
|
||||
this.resultList = resultData
|
||||
this.$message.success('已查询到今天的慢单数据')
|
||||
}
|
||||
|
||||
// 执行成功后刷新历史记录
|
||||
this.loadHistory()
|
||||
} else {
|
||||
this.$message.error(res && res.msg ? res.msg : '查询失败')
|
||||
this.resultList = []
|
||||
}
|
||||
} catch (error) {
|
||||
this.loading = false
|
||||
this.$message.error('查询失败,请稍后重试')
|
||||
this.resultList = []
|
||||
}
|
||||
},
|
||||
clearAll() {
|
||||
this.form.command = ''
|
||||
|
||||
Reference in New Issue
Block a user