1
This commit is contained in:
parent
cdde7183e4
commit
064635a59d
BIN
dist.tar.gz
BIN
dist.tar.gz
Binary file not shown.
@ -29,5 +29,11 @@ export default {
|
||||
* @type {boolean} true | false
|
||||
* @description Whether expand the shortcut key area
|
||||
*/
|
||||
shortcutExpanded: false
|
||||
shortcutExpanded: false,
|
||||
|
||||
/**
|
||||
* @type {'tile' | 'collapse'}
|
||||
* @description Toolbar button display mode: tile (平铺) or collapse (折叠)
|
||||
*/
|
||||
toolbarMode: 'collapse'
|
||||
}
|
||||
|
||||
@ -3,7 +3,7 @@ import defaultSettings from '@/settings'
|
||||
import { ref, computed, watch } from 'vue'
|
||||
import { useUserStore } from './user'
|
||||
|
||||
const { showSettings, tagsView, fixedHeader, sidebarLogo, shortcutExpanded } = defaultSettings
|
||||
const { showSettings, tagsView, fixedHeader, sidebarLogo, shortcutExpanded, toolbarMode: defaultToolbarMode } = defaultSettings
|
||||
|
||||
export const useSettingsStore = defineStore('settings', () => {
|
||||
const userStore = useUserStore()
|
||||
@ -15,6 +15,7 @@ export const useSettingsStore = defineStore('settings', () => {
|
||||
const sidebarLogoRef = ref(sidebarLogo)
|
||||
const layoutMode = ref<'sidebar' | 'top-bottom'>('top-bottom')
|
||||
const shortcutExpandedRef = ref<boolean>(shortcutExpanded)
|
||||
const toolbarModeRef = ref<'tile' | 'collapse'>(defaultToolbarMode || 'collapse')
|
||||
|
||||
const storageKey = computed(() => {
|
||||
if (!userStore.user?.username && !userStore.user?.id) return null
|
||||
@ -34,6 +35,7 @@ export const useSettingsStore = defineStore('settings', () => {
|
||||
if (typeof parsed.sidebarLogo === 'boolean') sidebarLogoRef.value = parsed.sidebarLogo
|
||||
if (typeof parsed.layoutMode === 'string') layoutMode.value = parsed.layoutMode
|
||||
if (typeof parsed.shortcutExpanded === 'boolean') shortcutExpandedRef.value = parsed.shortcutExpanded
|
||||
if (parsed.toolbarMode === 'tile' || parsed.toolbarMode === 'collapse') toolbarModeRef.value = parsed.toolbarMode
|
||||
} catch (e) {
|
||||
console.error('Failed to parse settings from storage', e)
|
||||
}
|
||||
@ -48,7 +50,8 @@ export const useSettingsStore = defineStore('settings', () => {
|
||||
fixedHeader: fixedHeaderRef.value,
|
||||
sidebarLogo: sidebarLogoRef.value,
|
||||
layoutMode: layoutMode.value,
|
||||
shortcutExpanded: shortcutExpandedRef.value
|
||||
shortcutExpanded: shortcutExpandedRef.value,
|
||||
toolbarMode: toolbarModeRef.value
|
||||
}
|
||||
try {
|
||||
localStorage.setItem(storageKey.value, JSON.stringify(payload))
|
||||
@ -69,6 +72,7 @@ export const useSettingsStore = defineStore('settings', () => {
|
||||
sidebarLogoRef.value = sidebarLogo
|
||||
layoutMode.value = 'top-bottom'
|
||||
shortcutExpandedRef.value = shortcutExpanded
|
||||
toolbarModeRef.value = defaultToolbarMode || 'collapse'
|
||||
}
|
||||
}, { immediate: true })
|
||||
|
||||
@ -80,7 +84,8 @@ export const useSettingsStore = defineStore('settings', () => {
|
||||
fixedHeader: 1,
|
||||
sidebarLogo: 1,
|
||||
layoutMode: 1,
|
||||
shortcutExpanded: 1
|
||||
shortcutExpanded: 1,
|
||||
toolbarMode: 1
|
||||
}, key)) return
|
||||
|
||||
switch (key) {
|
||||
@ -105,6 +110,9 @@ export const useSettingsStore = defineStore('settings', () => {
|
||||
case 'shortcutExpanded':
|
||||
shortcutExpandedRef.value = value
|
||||
break
|
||||
case 'toolbarMode':
|
||||
toolbarModeRef.value = value
|
||||
break
|
||||
default:
|
||||
break
|
||||
}
|
||||
@ -121,6 +129,7 @@ export const useSettingsStore = defineStore('settings', () => {
|
||||
sidebarLogo: sidebarLogoRef,
|
||||
layoutMode,
|
||||
shortcutExpanded: shortcutExpandedRef,
|
||||
toolbarMode: toolbarModeRef,
|
||||
changeSetting
|
||||
}
|
||||
})
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<div ref="containerRef" class="order-toolbar-button-group">
|
||||
<div ref="containerRef" class="order-toolbar-button-group" :class="{ 'order-toolbar-button-group--tile': isTileMode }">
|
||||
<div ref="mainRef" class="order-toolbar-button-group__main">
|
||||
<template v-for="button in visibleButtons" :key="button.key">
|
||||
<template v-for="button in displayButtons" :key="button.key">
|
||||
<el-dropdown
|
||||
v-if="button.buttonType === 'dropdown' && button.dropdownOptions?.length"
|
||||
trigger="click"
|
||||
@ -42,7 +42,7 @@
|
||||
</template>
|
||||
|
||||
<el-popover
|
||||
v-if="overflowButtons.length"
|
||||
v-if="!isTileMode && overflowButtons.length"
|
||||
v-model:visible="expandVisible"
|
||||
placement="bottom-start"
|
||||
:width="172"
|
||||
@ -87,12 +87,20 @@
|
||||
</div>
|
||||
</el-popover>
|
||||
</div>
|
||||
|
||||
<div class="order-toolbar-button-group__mode-toggle" @click="toggleToolbarMode">
|
||||
<el-tooltip :content="isTileMode ? '切换到折叠模式' : '切换到平铺模式'" placement="bottom">
|
||||
<el-icon :size="14"><Grid v-if="isTileMode" /><Fold v-else /></el-icon>
|
||||
</el-tooltip>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { nextTick, onBeforeUnmount, onMounted, ref, watch } from 'vue'
|
||||
import { computed, nextTick, onBeforeUnmount, onMounted, ref, watch } from 'vue'
|
||||
import type { ToolbarButtonConfig } from '../config/order-common-config'
|
||||
import { useSettingsStore } from '@/stores/modules/settings'
|
||||
import { Grid, Fold } from '@element-plus/icons-vue'
|
||||
|
||||
const props = defineProps<{
|
||||
buttons: ToolbarButtonConfig[]
|
||||
@ -106,6 +114,17 @@ const emit = defineEmits<{
|
||||
(e: 'action', action: ToolbarButtonConfig['action']): void
|
||||
}>()
|
||||
|
||||
const settingsStore = useSettingsStore()
|
||||
const isTileMode = computed(() => settingsStore.toolbarMode !== 'collapse')
|
||||
const displayButtons = computed(() => isTileMode.value ? props.buttons : visibleButtons.value)
|
||||
|
||||
const toggleToolbarMode = () => {
|
||||
settingsStore.changeSetting({
|
||||
key: 'toolbarMode',
|
||||
value: isTileMode.value ? 'collapse' : 'tile'
|
||||
})
|
||||
}
|
||||
|
||||
const containerRef = ref<HTMLElement | null>(null)
|
||||
const mainRef = ref<HTMLElement | null>(null)
|
||||
const visibleButtons = ref<ToolbarButtonConfig[]>([])
|
||||
@ -169,6 +188,8 @@ async function trimVisibleUntilFits() {
|
||||
}
|
||||
|
||||
async function scheduleLayout() {
|
||||
// 平铺模式不需要溢出检测
|
||||
if (isTileMode.value) return
|
||||
const frame = ++layoutFrame
|
||||
await nextTick()
|
||||
if (frame !== layoutFrame) return
|
||||
@ -205,16 +226,31 @@ watch(
|
||||
},
|
||||
{ deep: true }
|
||||
)
|
||||
|
||||
// 模式切换时重新布局
|
||||
watch(isTileMode, () => {
|
||||
if (!isTileMode.value) {
|
||||
visibleButtons.value = [...props.buttons]
|
||||
void scheduleLayout()
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.order-toolbar-button-group {
|
||||
position: relative;
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
flex: 1;
|
||||
width: 100%;
|
||||
max-width: 100%;
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.order-toolbar-button-group--tile {
|
||||
overflow: visible;
|
||||
}
|
||||
|
||||
.order-toolbar-button-group__main {
|
||||
@ -228,6 +264,11 @@ watch(
|
||||
flex-wrap: nowrap;
|
||||
}
|
||||
|
||||
.order-toolbar-button-group--tile .order-toolbar-button-group__main {
|
||||
overflow: visible;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.order-toolbar-button-group__main :deep(.el-dropdown) {
|
||||
flex-shrink: 0;
|
||||
}
|
||||
@ -243,6 +284,27 @@ watch(
|
||||
margin: 0;
|
||||
justify-content: flex-start;
|
||||
}
|
||||
|
||||
.order-toolbar-button-group__mode-toggle {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 24px;
|
||||
min-width: 24px;
|
||||
height: 24px;
|
||||
border-radius: 4px;
|
||||
background: #e8e8e8;
|
||||
cursor: pointer;
|
||||
color: #909399;
|
||||
transition: all 0.3s;
|
||||
flex-shrink: 0;
|
||||
margin-left: auto;
|
||||
|
||||
&:hover {
|
||||
background: #d0d0d0;
|
||||
color: #409EFF;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
<style lang="scss">
|
||||
|
||||
@ -455,6 +455,8 @@
|
||||
>
|
||||
<printer-component-connection-panel />
|
||||
</el-dialog>
|
||||
|
||||
<printer-list-test-dialog v-model="printerListTestVisible" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@ -491,6 +493,7 @@ import { useWavePickComplete } from './composables/useWavePickComplete'
|
||||
import BatchReceivingPrintDialog from '@/components/BatchReceivingPrintDialog.vue'
|
||||
import WavePlatformPrintPreviewDialog from './component/WavePlatformPrintPreviewDialog.vue'
|
||||
import PrinterComponentConnectionPanel from './component/PrinterComponentConnectionPanel.vue'
|
||||
import PrinterListTestDialog from './component/PrinterListTestDialog.vue'
|
||||
import PendingOrderListPanel from './component/PendingOrderListPanel.vue'
|
||||
import WaveBatchDetailPanel from './component/WaveBatchDetailPanel.vue'
|
||||
import WaveFetchTaskProgressDialog from './component/WaveFetchTaskProgressDialog.vue'
|
||||
@ -572,6 +575,7 @@ const platformPrintPayload = ref<WavePlatformPrintDataPayload | null>(null)
|
||||
const platformPrintErrorMessage = ref('')
|
||||
const platformPrintRequestMeta = ref<{ warehouse_id: number; wave_ids: Array<number | string> } | null>(null)
|
||||
const printerComponentConnectionVisible = ref(false)
|
||||
const printerListTestVisible = ref(false)
|
||||
const batchAllocateExpressLoading = ref(false)
|
||||
const batchAllocateStorageLoading = ref(false)
|
||||
const batchRemoveExceptionOrdersLoading = ref(false)
|
||||
@ -785,6 +789,9 @@ const toolbarActionMap: Record<string, () => void> = {
|
||||
openGroupOrderDialog: () => openGroupOrderDialog(),
|
||||
openPrinterComponentConnectionDialog: () => {
|
||||
printerComponentConnectionVisible.value = true
|
||||
},
|
||||
openPrinterListTestDialog: () => {
|
||||
printerListTestVisible.value = true
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
392
src/views/order/waveOrder/component/PrinterListTestDialog.vue
Normal file
392
src/views/order/waveOrder/component/PrinterListTestDialog.vue
Normal file
@ -0,0 +1,392 @@
|
||||
<template>
|
||||
<el-dialog
|
||||
v-model="visibleProxy"
|
||||
title="打印机列表测试"
|
||||
width="800px"
|
||||
align-center
|
||||
destroy-on-close
|
||||
append-to-body
|
||||
class="printer-list-test-dialog"
|
||||
>
|
||||
<!-- 打印组件连接状态 -->
|
||||
<section class="test-section">
|
||||
<div class="test-section__header">
|
||||
<h4 class="test-section__title">打印组件连接状态</h4>
|
||||
<el-button size="small" text @click="refreshStatus">
|
||||
<el-icon><Refresh /></el-icon>
|
||||
刷新
|
||||
</el-button>
|
||||
</div>
|
||||
<div class="component-status-grid">
|
||||
<div
|
||||
v-for="item in componentStatusRows"
|
||||
:key="item.name"
|
||||
class="component-status-card"
|
||||
:class="{ 'is-connected': item.connected }"
|
||||
>
|
||||
<span class="component-status-card__dot" :class="item.connected ? 'dot--ok' : 'dot--err'" />
|
||||
<span class="component-status-card__name">{{ item.name }}</span>
|
||||
<span class="component-status-card__port">{{ item.port }}</span>
|
||||
<el-tag size="small" :type="item.connected ? 'success' : 'danger'">
|
||||
{{ item.connected ? '已连接' : '未连接' }}
|
||||
</el-tag>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- 选择平台 / 获取打印机 -->
|
||||
<section class="test-section">
|
||||
<div class="test-section__header">
|
||||
<h4 class="test-section__title">获取打印机列表</h4>
|
||||
</div>
|
||||
<div class="test-platform-bar">
|
||||
<el-select
|
||||
v-model="selectedComponent"
|
||||
placeholder="选择打印平台"
|
||||
size="default"
|
||||
style="width: 260px"
|
||||
clearable
|
||||
>
|
||||
<el-option
|
||||
v-for="item in componentSelectOptions"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value"
|
||||
/>
|
||||
</el-select>
|
||||
<el-button
|
||||
type="primary"
|
||||
:loading="fetchingPrinters"
|
||||
:disabled="!selectedComponent"
|
||||
@click="fetchPrinterList"
|
||||
>
|
||||
获取打印机
|
||||
</el-button>
|
||||
</div>
|
||||
|
||||
<!-- 打印机列表结果 -->
|
||||
<div v-if="printerResult" class="test-result">
|
||||
<div class="test-result__meta">
|
||||
<span>组件:<code>{{ printerResult.componentName }}</code></span>
|
||||
<span>默认打印机:<code>{{ printerResult.defaultPrinter || '—' }}</code></span>
|
||||
<span>共 <strong>{{ printerResult.printers.length }}</strong> 台</span>
|
||||
</div>
|
||||
<div v-if="printerResult.printers.length > 0" class="test-printer-grid">
|
||||
<div
|
||||
v-for="printer in printerResult.printers"
|
||||
:key="printer"
|
||||
class="test-printer-tile"
|
||||
:class="{ 'is-default': printerResult.defaultPrinter === printer }"
|
||||
>
|
||||
<span class="test-printer-tile__icon">
|
||||
<el-icon><Printer /></el-icon>
|
||||
</span>
|
||||
<span class="test-printer-tile__name">{{ printer }}</span>
|
||||
<el-tag v-if="printerResult.defaultPrinter === printer" size="small" type="success">默认</el-tag>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else class="test-result__empty">
|
||||
<span>未获取到打印机列表,请确认组件已连接后重试</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 错误信息 -->
|
||||
<div v-if="printerError" class="test-error">
|
||||
<el-alert type="error" :closable="false" :title="printerError" />
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<template #footer>
|
||||
<el-button @click="visibleProxy = false">关闭</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, ref } from 'vue'
|
||||
import { Printer, Refresh } from '@element-plus/icons-vue'
|
||||
import { usePrinterComponentStore } from '@/stores/modules/printerComponent'
|
||||
import { queryComponentPrinterList } from '../config/print'
|
||||
|
||||
const props = defineProps<{
|
||||
modelValue: boolean
|
||||
}>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
'update:modelValue': [boolean]
|
||||
}>()
|
||||
|
||||
const printerStore = usePrinterComponentStore()
|
||||
|
||||
const visibleProxy = computed({
|
||||
get: () => props.modelValue,
|
||||
set: (v: boolean) => emit('update:modelValue', v)
|
||||
})
|
||||
|
||||
/** 打印组件端口映射(与 printerComponentCore DEFAULT_PRINTER_COMPONENTS 一致) */
|
||||
const COMPONENT_PORT_MAP: Record<string, string> = {
|
||||
抖音: '13888',
|
||||
拼多多: '5000',
|
||||
快手: '16888/ks/printer',
|
||||
京东: '9113',
|
||||
菜鸟: '13528',
|
||||
视频号: '12705',
|
||||
小红书: '10818',
|
||||
LODOP: '8000/c_webskt'
|
||||
}
|
||||
|
||||
/** 所有打印组件名称列表 */
|
||||
const ALL_PRINT_COMPONENTS = ['抖音', '拼多多', '快手', '京东', '菜鸟', '视频号', '小红书', 'LODOP']
|
||||
|
||||
const componentStatusRows = computed(() => {
|
||||
return ALL_PRINT_COMPONENTS.map((name) => ({
|
||||
name,
|
||||
port: COMPONENT_PORT_MAP[name] || '',
|
||||
connected: printerStore.isConnected(name)
|
||||
}))
|
||||
})
|
||||
|
||||
const componentSelectOptions = computed(() => {
|
||||
return ALL_PRINT_COMPONENTS.map((name) => {
|
||||
const connected = printerStore.isConnected(name)
|
||||
const port = COMPONENT_PORT_MAP[name] || ''
|
||||
return {
|
||||
label: `${name}${connected ? ' ✓' : ''} [${port}]`,
|
||||
value: name
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
const selectedComponent = ref('')
|
||||
const fetchingPrinters = ref(false)
|
||||
|
||||
type PrinterResult = {
|
||||
componentName: string
|
||||
defaultPrinter: string
|
||||
printers: string[]
|
||||
}
|
||||
|
||||
const printerResult = ref<PrinterResult | null>(null)
|
||||
const printerError = ref('')
|
||||
|
||||
function refreshStatus() {
|
||||
printerStore.refreshFromRuntime()
|
||||
}
|
||||
|
||||
async function fetchPrinterList() {
|
||||
const componentName = selectedComponent.value
|
||||
if (!componentName) return
|
||||
|
||||
fetchingPrinters.value = true
|
||||
printerResult.value = null
|
||||
printerError.value = ''
|
||||
|
||||
try {
|
||||
printerStore.refreshFromRuntime()
|
||||
const connected = printerStore.isConnected(componentName)
|
||||
const port = COMPONENT_PORT_MAP[componentName] || '未知'
|
||||
|
||||
if (!connected) {
|
||||
printerError.value = `组件「${componentName}」未连接(目标端口 ws://127.0.0.1:${port}),请先在「打印组件连接」面板中确认连接状态,并确保 ${componentName} 打印控件已启动`
|
||||
return
|
||||
}
|
||||
|
||||
const result = await queryComponentPrinterList(componentName, undefined, 5000)
|
||||
if (!result) {
|
||||
printerError.value = `组件「${componentName}」(端口 ${port})无响应或超时。可能原因:① ${componentName} 打印控件未正常运行;② 控件版本不支持 getPrinters 协议;③ 网络环境限制(公网 HTTP 请改用 HTTPS 打开)`
|
||||
return
|
||||
}
|
||||
|
||||
printerResult.value = {
|
||||
componentName,
|
||||
defaultPrinter: result.defaultPrinter || '',
|
||||
printers: result.printers || []
|
||||
}
|
||||
} catch (err: any) {
|
||||
printerError.value = err?.message || '获取打印机列表失败'
|
||||
} finally {
|
||||
fetchingPrinters.value = false
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.printer-list-test-dialog :deep(.el-dialog) {
|
||||
max-height: 80vh;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.printer-list-test-dialog :deep(.el-dialog__body) {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
overflow-y: auto;
|
||||
padding: 12px 20px;
|
||||
}
|
||||
|
||||
.test-section {
|
||||
margin-bottom: 16px;
|
||||
|
||||
&__header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
&__title {
|
||||
margin: 0;
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
color: #303133;
|
||||
}
|
||||
}
|
||||
|
||||
/* 组件连接状态网格 */
|
||||
.component-status-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(4, 1fr);
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.component-status-card {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
padding: 8px 12px;
|
||||
border: 1px solid #e4e7ed;
|
||||
border-radius: 6px;
|
||||
background: #fafbfc;
|
||||
|
||||
&.is-connected {
|
||||
border-color: #b7eb8f;
|
||||
background: #f6ffed;
|
||||
}
|
||||
|
||||
&__dot {
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
border-radius: 50%;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
&__name {
|
||||
flex: 1;
|
||||
font-size: 13px;
|
||||
color: #303133;
|
||||
}
|
||||
|
||||
&__port {
|
||||
font-size: 11px;
|
||||
color: #909399;
|
||||
font-family: monospace;
|
||||
white-space: nowrap;
|
||||
}
|
||||
}
|
||||
|
||||
.dot--ok {
|
||||
background: #52c41a;
|
||||
box-shadow: 0 0 4px rgba(82, 196, 26, 0.4);
|
||||
}
|
||||
|
||||
.dot--err {
|
||||
background: #d9d9d9;
|
||||
}
|
||||
|
||||
/* 选择平台区 */
|
||||
.test-platform-bar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
/* 打印机列表结果 */
|
||||
.test-result {
|
||||
border: 1px solid #e4e7ed;
|
||||
border-radius: 8px;
|
||||
background: #fafbfc;
|
||||
overflow: hidden;
|
||||
|
||||
&__meta {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 16px;
|
||||
padding: 8px 12px;
|
||||
border-bottom: 1px solid #ebeef5;
|
||||
font-size: 12px;
|
||||
color: #606266;
|
||||
|
||||
code {
|
||||
background: #f4f4f5;
|
||||
padding: 2px 6px;
|
||||
border-radius: 4px;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
strong {
|
||||
color: #409eff;
|
||||
}
|
||||
}
|
||||
|
||||
&__empty {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 32px 12px;
|
||||
font-size: 13px;
|
||||
color: #909399;
|
||||
}
|
||||
}
|
||||
|
||||
.test-printer-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
|
||||
gap: 6px;
|
||||
padding: 10px 12px;
|
||||
}
|
||||
|
||||
.test-printer-tile {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
padding: 8px 12px;
|
||||
border: 1px solid #e4e7ed;
|
||||
border-radius: 6px;
|
||||
background: #fff;
|
||||
transition: all 0.2s;
|
||||
|
||||
&.is-default {
|
||||
border-color: #67c23a;
|
||||
background: #f0f9eb;
|
||||
}
|
||||
|
||||
&__icon {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 26px;
|
||||
height: 26px;
|
||||
border-radius: 6px;
|
||||
background: #f0f2f5;
|
||||
color: #606266;
|
||||
flex-shrink: 0;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
&__name {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
font-size: 12px;
|
||||
color: #303133;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
}
|
||||
|
||||
.test-error {
|
||||
margin-top: 10px;
|
||||
}
|
||||
</style>
|
||||
@ -14,20 +14,50 @@
|
||||
<div v-else-if="payload" ref="printRootRef" class="wave-print-body">
|
||||
<div class="wave-print-settings-bar">
|
||||
<template v-if="printMode === 'station'">
|
||||
<el-select
|
||||
v-model="printSettings.station"
|
||||
placeholder="请选择打印台"
|
||||
size="small"
|
||||
:loading="stationLoading"
|
||||
@change="handleStationChange"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in stationOptions"
|
||||
:key="item.stationId"
|
||||
:label="item.name"
|
||||
:value="item.stationId"
|
||||
/>
|
||||
</el-select>
|
||||
<div class="wave-print-printer-section">
|
||||
<div class="wave-print-printer-section__header">
|
||||
<span class="wave-print-printer-section__title">选择打印台</span>
|
||||
<el-button size="small" text :loading="stationLoading" @click="loadStationOptions(true)">
|
||||
<el-icon><Refresh /></el-icon>
|
||||
刷新
|
||||
</el-button>
|
||||
<el-input
|
||||
v-if="stationOptions.length > 8"
|
||||
v-model="stationSearchKeyword"
|
||||
size="small"
|
||||
placeholder="搜索打印台…"
|
||||
clearable
|
||||
class="wave-print-printer-search"
|
||||
/>
|
||||
</div>
|
||||
<div v-if="stationLoading" class="wave-print-printer-grid__loading">
|
||||
<el-icon class="is-loading"><Loading /></el-icon>
|
||||
<span>加载打印台列表…</span>
|
||||
</div>
|
||||
<el-scrollbar v-else-if="filteredStationOptions.length > 0" max-height="160px">
|
||||
<div class="wave-print-printer-grid">
|
||||
<div
|
||||
v-for="item in filteredStationOptions"
|
||||
:key="item.stationId"
|
||||
class="wave-print-printer-tile"
|
||||
:class="{ 'is-selected': printSettings.station === item.stationId }"
|
||||
@click="handleStationSelect(item.stationId)"
|
||||
>
|
||||
<span class="wave-print-printer-tile__icon">
|
||||
<el-icon><Printer /></el-icon>
|
||||
</span>
|
||||
<span class="wave-print-printer-tile__name">{{ item.name }}</span>
|
||||
<span v-if="item.default_printer_name" class="wave-print-printer-tile__sub">{{ item.default_printer_name }}</span>
|
||||
<span v-if="printSettings.station === item.stationId" class="wave-print-printer-tile__check">
|
||||
<el-icon><Check /></el-icon>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</el-scrollbar>
|
||||
<div v-else class="wave-print-printer-grid__empty">
|
||||
<span>暂无可用打印台</span>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<template v-else>
|
||||
<div class="wave-print-printer-section">
|
||||
@ -366,6 +396,7 @@ type StationOption = {
|
||||
|
||||
const stationOptions = ref<StationOption[]>([])
|
||||
const stationLoading = ref(false)
|
||||
const stationSearchKeyword = ref('')
|
||||
const stationPrinting = ref(false)
|
||||
const browserPrinting = ref(false)
|
||||
const printerLoading = ref(false)
|
||||
@ -564,6 +595,18 @@ const uniqueExpressList = computed<ExpressPrinterRow[]>(() => {
|
||||
return [...map.values()]
|
||||
})
|
||||
|
||||
/** 搜索过滤后的打印台列表 */
|
||||
const filteredStationOptions = computed(() => {
|
||||
const keyword = stationSearchKeyword.value.trim().toLowerCase()
|
||||
if (!keyword) return stationOptions.value
|
||||
return stationOptions.value.filter(
|
||||
(item) =>
|
||||
item.name.toLowerCase().includes(keyword) ||
|
||||
item.stationId.toLowerCase().includes(keyword) ||
|
||||
item.default_printer_name.toLowerCase().includes(keyword)
|
||||
)
|
||||
})
|
||||
|
||||
/** 搜索过滤后的打印机列表 */
|
||||
const filteredPrinterOptions = computed(() => {
|
||||
const keyword = printerSearchKeyword.value.trim().toLowerCase()
|
||||
@ -910,10 +953,14 @@ function mapStationRow(item: Record<string, any>): StationOption {
|
||||
}
|
||||
}
|
||||
|
||||
async function loadStationOptions() {
|
||||
async function loadStationOptions(forceRefresh = false) {
|
||||
stationSearchKeyword.value = ''
|
||||
stationLoading.value = true
|
||||
try {
|
||||
// 优先使用缓存,避免弹窗每次打开都请求
|
||||
// 优先使用缓存,避免弹窗每次打开都请求(forceRefresh 时清除缓存重新加载)
|
||||
if (forceRefresh) {
|
||||
_cachedStationOptions = null
|
||||
}
|
||||
if (_cachedStationOptions) {
|
||||
stationOptions.value = _cachedStationOptions
|
||||
const savedStation = getSavedStationId()
|
||||
@ -974,13 +1021,17 @@ async function loadStationOptions() {
|
||||
}
|
||||
}
|
||||
|
||||
async function handleStationChange(val: string | number) {
|
||||
const stationId = String(val || '').trim()
|
||||
if (!stationId) {
|
||||
function handleStationSelect(stationId: string) {
|
||||
const id = String(stationId || '').trim()
|
||||
if (!id) return
|
||||
// 点击已选中的打印台 → 取消选中
|
||||
if (id === printSettings.station) {
|
||||
printSettings.station = ''
|
||||
clearSavedStationId()
|
||||
return
|
||||
}
|
||||
saveStationId(stationId)
|
||||
printSettings.station = id
|
||||
saveStationId(id)
|
||||
}
|
||||
|
||||
function resetExpressPrinterOverrides() {
|
||||
@ -1567,6 +1618,16 @@ async function printReport() {
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
&__sub {
|
||||
font-size: 11px;
|
||||
color: #909399;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
max-width: 120px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
&__check {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
@ -1350,6 +1350,11 @@ function shouldAlignPrinterViaComponent(component: string): boolean {
|
||||
return component === '京东';
|
||||
}
|
||||
|
||||
/** 视频号(微信小店)打印组件(12705)使用 command=getPrinterList 协议,而非 cmd=getPrinters */
|
||||
function isShipinhaoComponent(component: string): boolean {
|
||||
return component === '视频号';
|
||||
}
|
||||
|
||||
function isJingdongCloudPrintPayload(payload: Record<string, unknown>): boolean {
|
||||
return String(payload.orderType ?? '').trim().length > 0;
|
||||
}
|
||||
@ -1689,10 +1694,25 @@ function pickBestPrinterName(preferred: string, candidates: string[], fallback =
|
||||
function parseComponentGetPrintersResponse(
|
||||
response: Record<string, unknown>,
|
||||
useJingdongProtocol: boolean,
|
||||
useShipinhaoProtocol = false,
|
||||
): ComponentPrinterListResult {
|
||||
const printerNames = useJingdongProtocol
|
||||
? parseJingdongPrinterNames(response)
|
||||
: (() => {
|
||||
: useShipinhaoProtocol
|
||||
? (() => {
|
||||
// 视频号协议返回 printerList(而非 printers)
|
||||
const listRaw = Array.isArray(response.printerList) ? response.printerList : [];
|
||||
return listRaw
|
||||
.map((item) => {
|
||||
if (typeof item === 'string') return item.trim();
|
||||
if (item && typeof item === 'object') {
|
||||
return String((item as Record<string, unknown>).name ?? '').trim();
|
||||
}
|
||||
return '';
|
||||
})
|
||||
.filter(Boolean);
|
||||
})()
|
||||
: (() => {
|
||||
const printersRaw = Array.isArray(response.printers) ? response.printers : [];
|
||||
return printersRaw
|
||||
.map((item) => {
|
||||
@ -1729,6 +1749,7 @@ export async function queryComponentPrinterList(
|
||||
if (!eventName) return null;
|
||||
|
||||
const jingdong = isJingdongComponent(componentName);
|
||||
const shipinhao = isShipinhaoComponent(componentName);
|
||||
|
||||
try {
|
||||
const { printerComponents } = await import('@/core/printerRuntime');
|
||||
@ -1762,6 +1783,13 @@ export async function queryComponentPrinterList(
|
||||
const isJdMatch = isJingdongGetPrintersResponse(parsed, reqId);
|
||||
console.log(`[queryComponentPrinterList] 组件 "${componentName}" JD 响应匹配`, { code: parsed.code, success: parsed.success, isJdMatch, keys: Object.keys(parsed) })
|
||||
if (!isJdMatch) return;
|
||||
} else if (shipinhao) {
|
||||
// 视频号协议:command=getPrinterList,响应字段 ret/command/printerList
|
||||
const rcmd = String(parsed.command ?? '');
|
||||
const rrid = String(parsed.requestID ?? '');
|
||||
const isMatch = rcmd === 'getPrinterList' && rrid === reqId;
|
||||
console.log(`[queryComponentPrinterList] 组件 "${componentName}" 视频号响应匹配`, { command: rcmd, requestID: rrid, expectedReqId: reqId, isMatch, keys: Object.keys(parsed) })
|
||||
if (!isMatch) return;
|
||||
} else {
|
||||
const cmd = String(parsed.cmd ?? '');
|
||||
const rid = String(parsed.requestID ?? parsed.requetID ?? parsed.requestId ?? '');
|
||||
@ -1781,6 +1809,15 @@ export async function queryComponentPrinterList(
|
||||
componentName,
|
||||
JSON.stringify(buildJingdongGetPrintersRequest(reqId)),
|
||||
);
|
||||
} else if (shipinhao) {
|
||||
// 视频号(微信小店)协议:command=getPrinterList,无需 version 字段
|
||||
printerComponents.sendMessage(
|
||||
componentName,
|
||||
JSON.stringify({
|
||||
requestID: reqId,
|
||||
command: 'getPrinterList',
|
||||
}),
|
||||
);
|
||||
} else {
|
||||
printerComponents.sendMessage(
|
||||
componentName,
|
||||
@ -1799,7 +1836,7 @@ export async function queryComponentPrinterList(
|
||||
console.log(`[queryComponentPrinterList] 组件 "${componentName}" 无响应,返回 null`)
|
||||
return null;
|
||||
}
|
||||
const parsed = parseComponentGetPrintersResponse(response, jingdong);
|
||||
const parsed = parseComponentGetPrintersResponse(response, jingdong, shipinhao);
|
||||
console.log(`[queryComponentPrinterList] 组件 "${componentName}" 解析结果:`, parsed)
|
||||
return parsed;
|
||||
} catch (err) {
|
||||
|
||||
@ -48,7 +48,16 @@ export function waveScanField<G extends WaveScanFieldGroupKey>(
|
||||
}
|
||||
|
||||
/** 波次列表 ScanBox:基础信息分组(对齐待处理订单「订单基础信息」排版) */
|
||||
export const WAVE_SCAN_BASIC_INFO_GROUP = '基础信息'
|
||||
export const WAVE_SCAN_BASIC_INFO_GROUP = '波次信息'
|
||||
|
||||
/** 波次列表 ScanBox:流程状态分组(对齐待处理订单「流程状态」,所有流程字段归入一组) */
|
||||
export const WAVE_SCAN_PROCESS_STATUS_GROUP = '流程状态'
|
||||
|
||||
/** 波次列表 ScanBox:订单统计分组 */
|
||||
export const WAVE_SCAN_STATS_GROUP = '订单统计'
|
||||
|
||||
/** 波次列表 ScanBox:其他信息分组 */
|
||||
export const WAVE_SCAN_OTHER_GROUP = '其他信息'
|
||||
|
||||
/** 拣货任务 ScanBox:基础信息分组 */
|
||||
export const PICK_TASK_SCAN_BASIC_INFO_GROUP = '基础信息'
|
||||
@ -88,9 +97,9 @@ export const waveUpperTableDefaults = {
|
||||
emptyText: '暂无波次数据'
|
||||
}
|
||||
|
||||
/** 左侧筛选可用字段(基础信息在前,流程状态在后;流程字段以 label 独立分组,对齐待处理订单 ScanBox) */
|
||||
/** 左侧筛选可用字段(对标待处理订单 ScanBox 分组排序) */
|
||||
export const waveAvailableFields = [
|
||||
// 波次基础信息
|
||||
// ===== 波次信息 =====
|
||||
waveScanBasicField({ label: '波次号', value: 'wave_no', type: 'text' }),
|
||||
waveScanBasicField({
|
||||
label: '波次类型',
|
||||
@ -110,34 +119,19 @@ export const waveAvailableFields = [
|
||||
{ label: '已就绪', value: 1 }
|
||||
]
|
||||
}),
|
||||
waveScanBasicField({
|
||||
label: '区分快递',
|
||||
value: 'distinguish_express',
|
||||
type: 'select',
|
||||
options: [
|
||||
{ label: '是', value: 1 },
|
||||
{ label: '否', value: 0 }
|
||||
]
|
||||
}),
|
||||
waveScanBasicField({ label: '快递', value: 'logistics_name', type: 'text' }),
|
||||
waveScanBasicField({ label: '创建人', value: 'creator', type: 'text' }),
|
||||
waveScanBasicField({ label: '最小订单数', value: 'total_orders_min', type: 'number' }),
|
||||
waveScanBasicField({ label: '最大订单数', value: 'total_orders_max', type: 'number' }),
|
||||
waveScanBasicField({ label: '最小已处理订单', value: 'processed_orders_min', type: 'number' }),
|
||||
waveScanBasicField({ label: '最大已处理订单', value: 'processed_orders_max', type: 'number' }),
|
||||
// 流程状态(按作业顺序,每项独立分组)
|
||||
scanWorkflowField({
|
||||
|
||||
// ===== 流程状态(合并为一组,对齐待处理订单 ScanBox) =====
|
||||
{ ...scanWorkflowField({
|
||||
label: '库位分配',
|
||||
value: 'storage_assignment_status',
|
||||
type: 'select',
|
||||
options: [
|
||||
{ label: '未分配', value: '未分配' },
|
||||
{ label: '已分配', value: '已分配' },
|
||||
// { label: '错误', value: '错误' },
|
||||
{ label:'部分分配', value: 'partial' },
|
||||
{ label: '部分分配', value: 'partial' },
|
||||
]
|
||||
}),
|
||||
scanWorkflowField({
|
||||
}), group: WAVE_SCAN_PROCESS_STATUS_GROUP },
|
||||
{ ...scanWorkflowField({
|
||||
label: '快递分配',
|
||||
value: 'express_assignment_status',
|
||||
type: 'select',
|
||||
@ -145,8 +139,8 @@ export const waveAvailableFields = [
|
||||
{ label: '未分配', value: 'unassigned' },
|
||||
{ label: '已分配', value: 'assigned' },
|
||||
]
|
||||
}),
|
||||
scanWorkflowField({
|
||||
}), group: WAVE_SCAN_PROCESS_STATUS_GROUP },
|
||||
{ ...scanWorkflowField({
|
||||
label: '打印状态',
|
||||
value: 'print_assignment_status',
|
||||
type: 'select',
|
||||
@ -154,8 +148,8 @@ export const waveAvailableFields = [
|
||||
{ label: '未打印', value: 'unprinted' },
|
||||
{ label: '已打印', value: 'printed' },
|
||||
]
|
||||
}),
|
||||
scanWorkflowField({
|
||||
}), group: WAVE_SCAN_PROCESS_STATUS_GROUP },
|
||||
{ ...scanWorkflowField({
|
||||
label: '拣货状态',
|
||||
value: 'pick_assignment_status',
|
||||
type: 'select',
|
||||
@ -164,8 +158,8 @@ export const waveAvailableFields = [
|
||||
{ label: '部分拣货', value: '部分拣货' },
|
||||
{ label: '已拣货', value: '已拣货' },
|
||||
]
|
||||
}),
|
||||
scanWorkflowField({
|
||||
}), group: WAVE_SCAN_PROCESS_STATUS_GROUP },
|
||||
{ ...scanWorkflowField({
|
||||
label: '复核状态',
|
||||
value: 'review_assignment_status',
|
||||
type: 'select',
|
||||
@ -173,7 +167,26 @@ export const waveAvailableFields = [
|
||||
{ label: '未复核', value: 'unreviewed' },
|
||||
{ label: '已复核', value: 'reviewed' },
|
||||
]
|
||||
}),
|
||||
}), group: WAVE_SCAN_PROCESS_STATUS_GROUP },
|
||||
|
||||
// ===== 订单统计 =====
|
||||
{ ...waveScanBasicField({ label: '最小订单数', value: 'total_orders_min', type: 'number' }), group: WAVE_SCAN_STATS_GROUP },
|
||||
{ ...waveScanBasicField({ label: '最大订单数', value: 'total_orders_max', type: 'number' }), group: WAVE_SCAN_STATS_GROUP },
|
||||
{ ...waveScanBasicField({ label: '最小已处理订单', value: 'processed_orders_min', type: 'number' }), group: WAVE_SCAN_STATS_GROUP },
|
||||
{ ...waveScanBasicField({ label: '最大已处理订单', value: 'processed_orders_max', type: 'number' }), group: WAVE_SCAN_STATS_GROUP },
|
||||
|
||||
// ===== 其他信息 =====
|
||||
{ ...waveScanBasicField({
|
||||
label: '区分快递',
|
||||
value: 'distinguish_express',
|
||||
type: 'select',
|
||||
options: [
|
||||
{ label: '是', value: 1 },
|
||||
{ label: '否', value: 0 }
|
||||
]
|
||||
}), group: WAVE_SCAN_OTHER_GROUP },
|
||||
{ ...waveScanBasicField({ label: '快递', value: 'logistics_name', type: 'text' }), group: WAVE_SCAN_OTHER_GROUP },
|
||||
{ ...waveScanBasicField({ label: '创建人', value: 'creator', type: 'text' }), group: WAVE_SCAN_OTHER_GROUP },
|
||||
]
|
||||
|
||||
/** 抓取散单候选:左侧筛选可用字段 */
|
||||
@ -510,6 +523,15 @@ export const waveToolbarButtons: WaveToolbarButtonConfig[] = [
|
||||
action: 'openPrinterComponentConnectionDialog',
|
||||
onlyForWaveType: 2
|
||||
},
|
||||
{
|
||||
key: 'printerListTest',
|
||||
label: '打印机列表',
|
||||
type: 'primary',
|
||||
plain: true,
|
||||
size: 'small',
|
||||
action: 'openPrinterListTestDialog',
|
||||
onlyForWaveType: 2
|
||||
},
|
||||
{
|
||||
key: 'batchPrintPickingList',
|
||||
label: '批量打印拣货单(0)',
|
||||
|
||||
@ -617,7 +617,7 @@ async function loadProhibitedOptions() {
|
||||
}
|
||||
return null
|
||||
})
|
||||
.filter((x): x is { value: number; label: string } => x != null)
|
||||
.filter((x:any): x is { value: number; label: string } => x != null)
|
||||
}
|
||||
// 同步到 ScanBox 字段选项
|
||||
const prohibitedField = availableFieldsRef.find((f: any) => f.value === 'prohibited_type_id')
|
||||
|
||||
@ -2,7 +2,6 @@ export type StoreExpressBindingPolicyRecord = {
|
||||
id?: number
|
||||
warehouse_id?: number
|
||||
custom_name?: string
|
||||
store_ids?: string | null
|
||||
express_code?: string
|
||||
express_name?: string
|
||||
prohibited_type_id?: number[] | null
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user