f28b5dc50a
Co-authored-by: Cursor <cursoragent@cursor.com>
452 lines
12 KiB
Vue
452 lines
12 KiB
Vue
<template>
|
|
<div class="console-app">
|
|
<console-shell
|
|
:preview-mode="previewMode"
|
|
:demo-mode="isStaticView"
|
|
:user-name="displayName"
|
|
:task-num="taskNum"
|
|
:work-status="workStatus"
|
|
:has-run-cmd="hasRunCmd"
|
|
:is-connect="isConnect"
|
|
:service-status="serviceStatus"
|
|
:printer-info="printer_info"
|
|
:run-text="runText"
|
|
:tag-variant="tagVariant"
|
|
:tag-label="tagLabel"
|
|
:loading="pageLoading"
|
|
:run-list="runList"
|
|
:current-run-val="currentRunVal"
|
|
:sure-text="sureText"
|
|
:change-c-d="changeCD"
|
|
:cd-type-options="cdTypeOptions"
|
|
:cd-list="cd_list"
|
|
:CDStatus="CDStatus"
|
|
:CDName="CDName"
|
|
:CDTypes="CDTypes"
|
|
:diskTypes="diskTypes"
|
|
:task-list="task_list"
|
|
:log-list="displayLogs"
|
|
:show-all-logs="showAll"
|
|
:version-text="versionText"
|
|
@open-work="onOpenWork"
|
|
@go-settings="onGoSettings"
|
|
@activate="onActivate"
|
|
@user-command="onUserCommand"
|
|
@new-work="onNewWork"
|
|
@maintain="onMaintain"
|
|
@command-cd="onCommandCd"
|
|
@confirm-cd="onConfirmCd"
|
|
@cancel-cd="onCancelCd"
|
|
@refresh="onRefresh"
|
|
@retry="onRetry"
|
|
@cancel-task="onCancel"
|
|
@toggle-logs="onToggleLogs"
|
|
@help="onHelp"
|
|
@about="aboutVisible = true"
|
|
/>
|
|
<work-add-modal-v2
|
|
v-if="workShow"
|
|
ref="workAdd"
|
|
:preview-mode="isStaticView"
|
|
:is-new="isNew"
|
|
:save-work-list="saveWorkList"
|
|
@close="onWorkClose"
|
|
/>
|
|
<el-dialog title="关于 DiscWorker" :visible.sync="aboutVisible" width="400px">
|
|
<div class="about-box">
|
|
<div>国产光盘打印刻录系统 DiscWorker</div>
|
|
<div>{{ versionText }}</div>
|
|
<div>© 2023 cardsoon Co., Ltd.</div>
|
|
</div>
|
|
</el-dialog>
|
|
<div v-if="serviceLoading" class="console-service-loading">
|
|
<i class="el-icon-loading" /> {{ serviceText }}
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
import '@/styles/console/index.scss'
|
|
import { mapGetters } from 'vuex'
|
|
import platform from '@/platform'
|
|
import ConsoleShell from '@/components/console/layout/ConsoleShell.vue'
|
|
import WorkAddModalV2 from '@/components/console/work/WorkAddModalV2.vue'
|
|
import { getConsoleMock, MOCK_PRINTER_STATUS } from '@/mock/console.mock'
|
|
import { transformTaskList } from '@/utils/console/taskListTransform'
|
|
import { getRunText, getDeviceTagVariant, getDeviceTagLabel } from '@/utils/console/printerStatus'
|
|
import { applyPrinterInfoSideEffects } from '@/utils/console/printerWatch'
|
|
import {
|
|
serviceChange,
|
|
startService,
|
|
handleActive as activateDevice,
|
|
openWork,
|
|
showWork,
|
|
workRetry,
|
|
workCancel,
|
|
handleRun,
|
|
handleCommandCD,
|
|
sureCD,
|
|
cancleCD,
|
|
noticeChange,
|
|
goSet,
|
|
goOut,
|
|
help,
|
|
getChangeCDDefault
|
|
} from '@/utils/console/consoleActions'
|
|
import { loadAppVersionLine } from '@/utils/console/appVersion'
|
|
|
|
export default {
|
|
name: 'ConsolePage',
|
|
components: { ConsoleShell, WorkAddModalV2 },
|
|
props: {
|
|
previewMode: { type: Boolean, default: false },
|
|
designMode: { type: Boolean, default: false }
|
|
},
|
|
data() {
|
|
return {
|
|
aboutVisible: false,
|
|
versionText: '',
|
|
taskNum: [0, 0, 0],
|
|
task_list: [],
|
|
printer_info: {},
|
|
cd_list: [],
|
|
logList: [],
|
|
previewAllLogs: [],
|
|
showAll: false,
|
|
workShow: false,
|
|
isNew: true,
|
|
saveWorkList: {},
|
|
is_set_cddev: false,
|
|
runList: [],
|
|
runVal: '',
|
|
currentRunVal: 0,
|
|
sureText: '请设置左右光盘桶类型并按确定键',
|
|
default_cd: [],
|
|
changeCD: getChangeCDDefault(),
|
|
CDTypes: {},
|
|
CDStatus: {},
|
|
CDName: {},
|
|
diskTypes: {},
|
|
isConnect: false,
|
|
serviceStatus: false,
|
|
serviceLoading: false,
|
|
serviceText: '服务关闭中',
|
|
pageLoading: true,
|
|
mockUserName: 'Admin'
|
|
}
|
|
},
|
|
computed: {
|
|
...mapGetters(['name']),
|
|
isStaticView() {
|
|
return this.previewMode || this.designMode
|
|
},
|
|
displayName() {
|
|
return this.isStaticView ? this.mockUserName : this.name
|
|
},
|
|
workStatus() {
|
|
return this.isConnect && this.serviceStatus
|
|
},
|
|
hasRunCmd() {
|
|
return platform.hasRunCmd && platform.hasRunCmd()
|
|
},
|
|
runText() {
|
|
return getRunText({
|
|
printer_info: this.printer_info,
|
|
isConnect: this.isConnect,
|
|
serviceStatus: this.serviceStatus,
|
|
PrinterStatus: this.isStaticView ? MOCK_PRINTER_STATUS : this.$store.state.chat.PrinterStatus
|
|
})
|
|
},
|
|
tagVariant() {
|
|
return getDeviceTagVariant({
|
|
printer_info: this.printer_info,
|
|
isConnect: this.isConnect,
|
|
serviceStatus: this.serviceStatus
|
|
})
|
|
},
|
|
tagLabel() {
|
|
return getDeviceTagLabel({
|
|
printer_info: this.printer_info,
|
|
isConnect: this.isConnect,
|
|
serviceStatus: this.serviceStatus,
|
|
PrinterStatus: this.isStaticView ? MOCK_PRINTER_STATUS : this.$store.state.chat.PrinterStatus
|
|
})
|
|
},
|
|
cdTypeOptions() {
|
|
return Object.keys(this.CDTypes).map((key) => ({
|
|
value: parseInt(key, 10),
|
|
label: this.CDTypes[key]
|
|
}))
|
|
},
|
|
displayLogs() {
|
|
if (this.isStaticView) {
|
|
return this.showAll ? this.previewAllLogs : this.logList
|
|
}
|
|
return this.showAll ? this.$store.state.chat.allLogList : this.logList
|
|
}
|
|
},
|
|
watch: {
|
|
'$store.state.chat.firstConnect': {
|
|
handler(val) {
|
|
if (this.isStaticView) return
|
|
if (val && this.$store.state.user.oneLogin) {
|
|
this.$store.dispatch('setDatas', { name: 'oneLogin', data: false })
|
|
this.$store.dispatch('chat/setDatas', { name: 'firstConnect', data: false })
|
|
startService(this)
|
|
}
|
|
},
|
|
immediate: true
|
|
},
|
|
'$store.state.chat.task_list': {
|
|
handler(val) {
|
|
if (this.isStaticView) return
|
|
const { list, taskNum } = transformTaskList(val, this.$store.state.chat.CDTypes, this.$accAdd)
|
|
this.task_list = list
|
|
this.taskNum = taskNum
|
|
},
|
|
deep: true,
|
|
immediate: true
|
|
},
|
|
'$store.state.chat.printer_info': {
|
|
handler(val) {
|
|
if (this.isStaticView) return
|
|
this.printer_info = { ...val }
|
|
const fx = applyPrinterInfoSideEffects(val, {
|
|
currentRunVal: this.currentRunVal,
|
|
is_set_cddev_flag: this.is_set_cddev
|
|
})
|
|
this.runList = fx.runList
|
|
if (fx.changeCDStrongList) {
|
|
this.changeCD.req_info.strong_list = fx.changeCDStrongList
|
|
this.default_cd = JSON.parse(JSON.stringify(fx.changeCDStrongList))
|
|
}
|
|
if (fx.shouldRedirectCddev) {
|
|
this.is_set_cddev = true
|
|
goSet(this, '/manage?type=cddev')
|
|
}
|
|
this.pageLoading = false
|
|
},
|
|
deep: true,
|
|
immediate: true
|
|
},
|
|
'$store.state.chat.cd_list': {
|
|
handler(val) {
|
|
if (this.isStaticView) return
|
|
this.cd_list = [...val]
|
|
},
|
|
deep: true,
|
|
immediate: true
|
|
},
|
|
'$store.state.chat.logList': {
|
|
handler(val) {
|
|
if (this.isStaticView) return
|
|
this.logList = [...val]
|
|
},
|
|
deep: true,
|
|
immediate: true
|
|
},
|
|
'$store.state.chat.CDTypes': {
|
|
handler(val) {
|
|
if (this.isStaticView) return
|
|
this.CDTypes = { ...val }
|
|
},
|
|
deep: true,
|
|
immediate: true
|
|
},
|
|
'$store.state.chat.CDStatus': {
|
|
handler(val) {
|
|
if (this.isStaticView) return
|
|
this.CDStatus = { ...val }
|
|
},
|
|
deep: true,
|
|
immediate: true
|
|
},
|
|
'$store.state.chat.CDName': {
|
|
handler(val) {
|
|
if (this.isStaticView) return
|
|
this.CDName = { ...val }
|
|
},
|
|
deep: true,
|
|
immediate: true
|
|
},
|
|
'$store.state.chat.diskTypes': {
|
|
handler(val) {
|
|
if (this.isStaticView) return
|
|
this.diskTypes = { ...val }
|
|
},
|
|
deep: true,
|
|
immediate: true
|
|
},
|
|
'$store.state.chat.isConnect': {
|
|
handler(val) {
|
|
if (this.isStaticView) return
|
|
this.isConnect = val
|
|
if (val) this.pageLoading = false
|
|
},
|
|
immediate: true
|
|
},
|
|
'$store.state.chat.serviceStatus': {
|
|
handler(val) {
|
|
if (this.isStaticView) return
|
|
this.serviceStatus = val
|
|
},
|
|
immediate: true
|
|
}
|
|
},
|
|
created() {
|
|
loadAppVersionLine().then((text) => {
|
|
this.versionText = text
|
|
})
|
|
if (this.isStaticView) {
|
|
this.applyMock()
|
|
}
|
|
},
|
|
mounted() {
|
|
if (!this.isStaticView) {
|
|
setTimeout(() => {
|
|
this.pageLoading = false
|
|
}, 3000)
|
|
}
|
|
},
|
|
methods: {
|
|
applyMock() {
|
|
const mock = getConsoleMock()
|
|
this.taskNum = mock.taskNum
|
|
this.task_list = mock.task_list
|
|
this.printer_info = mock.printer_info
|
|
this.cd_list = mock.cd_list
|
|
this.logList = mock.logList
|
|
this.previewAllLogs = [...mock.logList, ...(mock.allLogList || [])]
|
|
this.isConnect = mock.isConnect
|
|
this.serviceStatus = mock.serviceStatus
|
|
this.CDTypes = { ...(mock.CDTypes || {}) }
|
|
this.CDStatus = { ...(mock.CDStatus || {}) }
|
|
this.CDName = { ...(mock.CDName || {}) }
|
|
this.diskTypes = { ...(mock.diskTypes || {}) }
|
|
this.changeCD = getChangeCDDefault()
|
|
this.default_cd = JSON.parse(JSON.stringify(this.changeCD.req_info.strong_list))
|
|
this.runList = [
|
|
{ value: 1, label: '重启设备' },
|
|
{ value: 2, label: '清除错误' },
|
|
{ value: 6, label: '设置光盘桶' },
|
|
{ value: 7, label: '刷新光盘桶' }
|
|
]
|
|
this.pageLoading = false
|
|
},
|
|
onGoSettings() {
|
|
goSet(this, '/manage')
|
|
},
|
|
onOpenWork() {
|
|
if (this.isStaticView) {
|
|
this.$message.info('设计模式:打开文件 UI 待接入')
|
|
return
|
|
}
|
|
openWork(this, platform)
|
|
},
|
|
onNewWork() {
|
|
if (this.isStaticView) {
|
|
this.workShow = true
|
|
this.$nextTick(() => this.$refs.workAdd.show())
|
|
return
|
|
}
|
|
showWork(this)
|
|
},
|
|
onActivate() {
|
|
if (this.isStaticView) return
|
|
activateDevice(this)
|
|
},
|
|
onUserCommand(cmd) {
|
|
if (cmd === 'toggle-service') {
|
|
if (this.isStaticView) {
|
|
this.$message.info('设计模式:暂不连接服务')
|
|
return
|
|
}
|
|
serviceChange(this, !this.workStatus)
|
|
} else if (cmd === 'legacy') {
|
|
this.$router.push('/')
|
|
} else if (cmd === 'logout') {
|
|
goOut(this)
|
|
}
|
|
},
|
|
onMaintain(runVal) {
|
|
if (this.isStaticView) {
|
|
if (parseInt(runVal, 10) === 6) {
|
|
this.currentRunVal = 6
|
|
} else {
|
|
this.$message.info('设计模式')
|
|
}
|
|
return
|
|
}
|
|
this.runVal = runVal
|
|
handleRun(this, runVal)
|
|
},
|
|
onCommandCd(e, type) {
|
|
handleCommandCD(this, e, type)
|
|
},
|
|
onConfirmCd() {
|
|
if (this.isStaticView) {
|
|
this.currentRunVal = 0
|
|
this.$message.info('设计模式')
|
|
return
|
|
}
|
|
sureCD(this)
|
|
},
|
|
onCancelCd() {
|
|
if (this.isStaticView) {
|
|
this.currentRunVal = 0
|
|
this.changeCD.req_info.strong_list = JSON.parse(JSON.stringify(this.default_cd))
|
|
return
|
|
}
|
|
cancleCD(this)
|
|
},
|
|
onRefresh() {
|
|
if (this.isStaticView) {
|
|
this.applyMock()
|
|
return
|
|
}
|
|
this.$store.dispatch('chat/initWebSocket')
|
|
},
|
|
onRetry(row) {
|
|
if (this.isStaticView) return
|
|
workRetry(this, row)
|
|
},
|
|
onCancel(row) {
|
|
if (this.isStaticView) return
|
|
workCancel(this, row)
|
|
},
|
|
onToggleLogs() {
|
|
if (this.isStaticView) {
|
|
this.showAll = !this.showAll
|
|
return
|
|
}
|
|
noticeChange(this)
|
|
},
|
|
onHelp() {
|
|
help()
|
|
},
|
|
onWorkClose() {
|
|
this.workShow = false
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
.about-box {
|
|
line-height: 1.8;
|
|
font-size: 14px;
|
|
}
|
|
|
|
.console-service-loading {
|
|
position: fixed;
|
|
bottom: 40px;
|
|
right: 20px;
|
|
background: rgba(17, 24, 39, 0.88);
|
|
color: #fff;
|
|
padding: 10px 16px;
|
|
border-radius: var(--dw-radius-sm);
|
|
font-size: 13px;
|
|
z-index: 2500;
|
|
}
|
|
</style>
|