feat: 仓储表单体验、轨迹 SPA 代理修复与打印预览增强
All checks were successful
Build and Deploy Front / deploy (push) Successful in 10m0s
All checks were successful
Build and Deploy Front / deploy (push) Successful in 10m0s
修复 /track/pull|push 被代理误伤 404;Warning/ProviderService/Dictionary 路径改写;SkuImage 入库归一化。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
becb942e5b
commit
68b85dadf9
@ -1,10 +1,10 @@
|
||||
# =============================================================================
|
||||
# 本地开发默认 → 测试环境(Vite 代理到 api.nanafa.com,无浏览器 CORS)
|
||||
# 切生产:pnpm dev:ideship
|
||||
# 本地开发默认 → 生产环境(Vite 代理到 api.ideship.com,无浏览器 CORS)
|
||||
# 切测试:pnpm 用 .env.nanafa 构建,或临时改回 api.nanafa.com
|
||||
# =============================================================================
|
||||
VITE_DEPLOY_TARGET=nanafa
|
||||
VITE_OMS_ADMIN_URL=http://api.nanafa.com/admin
|
||||
VITE_API_ORIGIN=http://api.nanafa.com
|
||||
VITE_DEPLOY_TARGET=ideship
|
||||
VITE_OMS_ADMIN_URL=https://api.ideship.com/admin
|
||||
VITE_API_ORIGIN=https://api.ideship.com
|
||||
|
||||
VITE_WECOM_KF_URL=https://work.weixin.qq.com/kfid/kfcae09c206f6c7045a
|
||||
|
||||
|
||||
@ -76,7 +76,9 @@
|
||||
"vue-codemirror6": "^1.4.3",
|
||||
"vue-echarts": "^6.2.3",
|
||||
"vue-hooks-plus": "^2.4.0",
|
||||
"pdfjs-dist": "^6.3.289",
|
||||
"vue-i18n": "^9.2.2",
|
||||
"vue-pdf-embed": "^2.1.6",
|
||||
"vue-router": "^4.0.14",
|
||||
"vxe-table": "4.6.18",
|
||||
"xe-utils": "3.7.5",
|
||||
|
||||
172
pnpm-lock.yaml
generated
172
pnpm-lock.yaml
generated
@ -93,6 +93,9 @@ importers:
|
||||
nprogress:
|
||||
specifier: ^0.2.0
|
||||
version: 0.2.0
|
||||
pdfjs-dist:
|
||||
specifier: ^6.3.289
|
||||
version: 6.3.289
|
||||
pinia:
|
||||
specifier: ^2.0.23
|
||||
version: 2.3.1(typescript@4.9.5)(vue@3.5.18(typescript@4.9.5))
|
||||
@ -126,6 +129,9 @@ importers:
|
||||
vue-i18n:
|
||||
specifier: ^9.2.2
|
||||
version: 9.14.5(vue@3.5.18(typescript@4.9.5))
|
||||
vue-pdf-embed:
|
||||
specifier: ^2.1.6
|
||||
version: 2.1.6(vue@3.5.18(typescript@4.9.5))
|
||||
vue-router:
|
||||
specifier: ^4.0.14
|
||||
version: 4.5.1(vue@3.5.18(typescript@4.9.5))
|
||||
@ -1031,6 +1037,76 @@ packages:
|
||||
resolution: {integrity: sha512-bPHp6Ji8b41szTOcaP63VlnbbO5Ny6dwAATtY6JTjh5N2OLrb5Qk/Th5cRkRQhkWCt+EJsYrNB0MiL+Gpn6e3g==}
|
||||
engines: {node: '>=4'}
|
||||
|
||||
'@napi-rs/canvas-android-arm64@1.0.9':
|
||||
resolution: {integrity: sha512-4LGXk2/0HVzE29K8SzML5WubgCp++B1FH3qgl35XmSZE+lLdr6P9VRQEnZ0MCLZMTSuJP41yyhtoiVNEuvrTIA==}
|
||||
engines: {node: '>= 10'}
|
||||
cpu: [arm64]
|
||||
os: [android]
|
||||
|
||||
'@napi-rs/canvas-darwin-arm64@1.0.9':
|
||||
resolution: {integrity: sha512-YNdfLBzY0W/Pep9fo2L6RmoNlNksnn05LRnX66W63R3ij58S25QOTcjdtEt2v8+PnCESzqZsYzUo+QPeIR44NA==}
|
||||
engines: {node: '>= 10'}
|
||||
cpu: [arm64]
|
||||
os: [darwin]
|
||||
|
||||
'@napi-rs/canvas-darwin-x64@1.0.9':
|
||||
resolution: {integrity: sha512-ceZQSknTEcy3dOXoekv59LTCkXjvnLsq+VW5PeNNDHEPQbRS5Ervkm1EaDa7WLAjiYWMLuSQTRTHao1dEX4prg==}
|
||||
engines: {node: '>= 10'}
|
||||
cpu: [x64]
|
||||
os: [darwin]
|
||||
|
||||
'@napi-rs/canvas-linux-arm-gnueabihf@1.0.9':
|
||||
resolution: {integrity: sha512-XhfI0Wwv4llhd6nnWDtY3kQKjq0r+y1i91PlJlJI24ag2U9WrnwbG1qS3+fDLEyouwEVFchiKkTEHozK+5iUNA==}
|
||||
engines: {node: '>= 10'}
|
||||
cpu: [arm]
|
||||
os: [linux]
|
||||
|
||||
'@napi-rs/canvas-linux-arm64-gnu@1.0.9':
|
||||
resolution: {integrity: sha512-012oiYtKaE7i9oxc8q7nraT7kDOpLcaCmFLzVe9Ty34RHDdoDzbWLrVh827CNxYh/EADX1eSikA3ymLjo/nNuw==}
|
||||
engines: {node: '>= 10'}
|
||||
cpu: [arm64]
|
||||
os: [linux]
|
||||
|
||||
'@napi-rs/canvas-linux-arm64-musl@1.0.9':
|
||||
resolution: {integrity: sha512-Ls5UWYFFn63casTZEczbeyEg3vRDRkv9lscuGwfchtY5yLLQhgOB8SN4YGxmfJ5vTaBwZ2YUxBS3NtmjJmFXdA==}
|
||||
engines: {node: '>= 10'}
|
||||
cpu: [arm64]
|
||||
os: [linux]
|
||||
|
||||
'@napi-rs/canvas-linux-riscv64-gnu@1.0.9':
|
||||
resolution: {integrity: sha512-hLKEGxV7ZiRHqndePTokgDMdBlo/rDfzg7P4p4QIv9pUhuYobnu3R2NIFLCRghG0nwfo+s2sw+c1xZFeCmEAsw==}
|
||||
engines: {node: '>= 10'}
|
||||
cpu: [riscv64]
|
||||
os: [linux]
|
||||
|
||||
'@napi-rs/canvas-linux-x64-gnu@1.0.9':
|
||||
resolution: {integrity: sha512-6kaz3w0QMy77PDWk6rJ1ksIihdad3qzEyX2o2oGT8GwCaypfT5mhjr8buOO5hstyLxcWXDScuz56RsINLtBPIQ==}
|
||||
engines: {node: '>= 10'}
|
||||
cpu: [x64]
|
||||
os: [linux]
|
||||
|
||||
'@napi-rs/canvas-linux-x64-musl@1.0.9':
|
||||
resolution: {integrity: sha512-xrGvmS3v55hmZ86ls/kBLVNMUTYio3f6Ik0DireemG994VfPAwiA3ZXA0Uf1bByctkB3NQ1Sfb+H5bkdUnnzfQ==}
|
||||
engines: {node: '>= 10'}
|
||||
cpu: [x64]
|
||||
os: [linux]
|
||||
|
||||
'@napi-rs/canvas-win32-arm64-msvc@1.0.9':
|
||||
resolution: {integrity: sha512-yjmVS3ArZeRVCP7jqbPq4rpZa/BhTeI7ELE2XqJg3snICQBDevLZyArxswHkiTnT34KRic33/4fLirrHI+SY8A==}
|
||||
engines: {node: '>= 10'}
|
||||
cpu: [arm64]
|
||||
os: [win32]
|
||||
|
||||
'@napi-rs/canvas-win32-x64-msvc@1.0.9':
|
||||
resolution: {integrity: sha512-QlSYQdMQslB81nlABo9wNfQ6npFhE7/O+saCZdqVGueGanyRk4jCogD5EwQenfP3kIq9e+mm6GreQBjX5MrA8g==}
|
||||
engines: {node: '>= 10'}
|
||||
cpu: [x64]
|
||||
os: [win32]
|
||||
|
||||
'@napi-rs/canvas@1.0.9':
|
||||
resolution: {integrity: sha512-QviPdJImDi/jMAvBfqaw+19BndMd/sizXVW3NnpMd3VJGz++QXkOHcP9kWR/smHG0hNjHeyuHFyrx/5lD0oNcQ==}
|
||||
engines: {node: '>= 10'}
|
||||
|
||||
'@napi-rs/wasm-runtime@0.2.12':
|
||||
resolution: {integrity: sha512-ZVWUcfwY4E/yPitQJl481FjFo3K22D6qF0DuFH6Y/nbnE11GY5uguDxZMGXPQ8WQ0128MXQD7TnfHyK4oWoIJQ==}
|
||||
|
||||
@ -5329,6 +5405,10 @@ packages:
|
||||
pathe@2.0.3:
|
||||
resolution: {integrity: sha512-WUjGcAqP1gQacoQe+OBJsFA7Ld4DyXuUIjZ5cc75cLHvJ7dtNsTugphxIADwspS+AraAUePCKrSVtPLFj/F88w==}
|
||||
|
||||
pdfjs-dist@6.3.289:
|
||||
resolution: {integrity: sha512-ZHjSVpDa3D6izMq8/04lvkhkATUmL9px6ChPaXc1k6nU2Mrhlg1/7F0bdUqCwUjw3NsPTfPZsMDUU6ZIcRaeQw==}
|
||||
engines: {node: '>=22.13.0 || >=24'}
|
||||
|
||||
pend@1.2.0:
|
||||
resolution: {integrity: sha512-F3asv42UuXchdzt+xXqfW1OGlVBe+mxa2mqI0pg5yAHZPvFmY3Y6drSf/GQ1A86WgWEN9Kzh/WrgKa6iGcHXLg==}
|
||||
|
||||
@ -7025,6 +7105,11 @@ packages:
|
||||
resolution: {integrity: sha512-aEQvaFzIH6A0u0in4ghsxiqMgXNxf2+mtgOW8BaiLM6f3gTfvJMjZBjSrycDgdde7P5VfXOqLFGk4+Tf0Mre6Q==}
|
||||
engines: {node: '>=6.11.5'}
|
||||
|
||||
vue-pdf-embed@2.1.6:
|
||||
resolution: {integrity: sha512-cNmclL9jGuRIqgm13fx/3ZZd1nW/Nn0zXfQUo/yd8AQU9GTFLLYRgFc5HM41v1+bMoj1wW59mZoB/cNQx8Y2Rw==}
|
||||
peerDependencies:
|
||||
vue: ^3.3.0
|
||||
|
||||
vue-plugin-hiprint@0.0.60:
|
||||
resolution: {integrity: sha512-a5uOMn6Nr4qlYYaVNbQKwRZJa8UcNMTflfi6J430/NDtySJB+5ArE8I8+NLjgVV56x3/qdUBs/GWuZCX5Umv1w==}
|
||||
engines: {node: '>=16'}
|
||||
@ -8001,6 +8086,54 @@ snapshots:
|
||||
call-me-maybe: 1.0.2
|
||||
glob-to-regexp: 0.3.0
|
||||
|
||||
'@napi-rs/canvas-android-arm64@1.0.9':
|
||||
optional: true
|
||||
|
||||
'@napi-rs/canvas-darwin-arm64@1.0.9':
|
||||
optional: true
|
||||
|
||||
'@napi-rs/canvas-darwin-x64@1.0.9':
|
||||
optional: true
|
||||
|
||||
'@napi-rs/canvas-linux-arm-gnueabihf@1.0.9':
|
||||
optional: true
|
||||
|
||||
'@napi-rs/canvas-linux-arm64-gnu@1.0.9':
|
||||
optional: true
|
||||
|
||||
'@napi-rs/canvas-linux-arm64-musl@1.0.9':
|
||||
optional: true
|
||||
|
||||
'@napi-rs/canvas-linux-riscv64-gnu@1.0.9':
|
||||
optional: true
|
||||
|
||||
'@napi-rs/canvas-linux-x64-gnu@1.0.9':
|
||||
optional: true
|
||||
|
||||
'@napi-rs/canvas-linux-x64-musl@1.0.9':
|
||||
optional: true
|
||||
|
||||
'@napi-rs/canvas-win32-arm64-msvc@1.0.9':
|
||||
optional: true
|
||||
|
||||
'@napi-rs/canvas-win32-x64-msvc@1.0.9':
|
||||
optional: true
|
||||
|
||||
'@napi-rs/canvas@1.0.9':
|
||||
optionalDependencies:
|
||||
'@napi-rs/canvas-android-arm64': 1.0.9
|
||||
'@napi-rs/canvas-darwin-arm64': 1.0.9
|
||||
'@napi-rs/canvas-darwin-x64': 1.0.9
|
||||
'@napi-rs/canvas-linux-arm-gnueabihf': 1.0.9
|
||||
'@napi-rs/canvas-linux-arm64-gnu': 1.0.9
|
||||
'@napi-rs/canvas-linux-arm64-musl': 1.0.9
|
||||
'@napi-rs/canvas-linux-riscv64-gnu': 1.0.9
|
||||
'@napi-rs/canvas-linux-x64-gnu': 1.0.9
|
||||
'@napi-rs/canvas-linux-x64-musl': 1.0.9
|
||||
'@napi-rs/canvas-win32-arm64-msvc': 1.0.9
|
||||
'@napi-rs/canvas-win32-x64-msvc': 1.0.9
|
||||
optional: true
|
||||
|
||||
'@napi-rs/wasm-runtime@0.2.12':
|
||||
dependencies:
|
||||
'@emnapi/core': 1.4.5
|
||||
@ -12751,6 +12884,10 @@ snapshots:
|
||||
|
||||
pathe@2.0.3: {}
|
||||
|
||||
pdfjs-dist@6.3.289:
|
||||
optionalDependencies:
|
||||
'@napi-rs/canvas': 1.0.9
|
||||
|
||||
pend@1.2.0: {}
|
||||
|
||||
perfect-debounce@1.0.0: {}
|
||||
@ -12820,11 +12957,11 @@ snapshots:
|
||||
|
||||
possible-typed-array-names@1.1.0: {}
|
||||
|
||||
postcss-html@0.36.0(postcss-syntax@0.36.2)(postcss@7.0.39):
|
||||
postcss-html@0.36.0(postcss-syntax@0.36.2(postcss-html@1.8.0)(postcss@8.5.6))(postcss@7.0.39):
|
||||
dependencies:
|
||||
htmlparser2: 3.10.1
|
||||
postcss: 7.0.39
|
||||
postcss-syntax: 0.36.2(postcss-html@1.8.0)(postcss@8.5.6)
|
||||
postcss-syntax: 0.36.2(postcss-html@0.36.0(postcss-syntax@0.36.2(postcss-html@1.8.0)(postcss@8.5.6))(postcss@7.0.39))(postcss-jsx@0.36.4(postcss-syntax@0.36.2(postcss-html@1.8.0)(postcss@8.5.6))(postcss@7.0.39))(postcss-less@3.1.4)(postcss-markdown@0.36.0(postcss-syntax@0.36.2(postcss-html@1.8.0)(postcss@8.5.6))(postcss@7.0.39))(postcss-scss@2.1.1)(postcss@7.0.39)
|
||||
|
||||
postcss-html@1.8.0:
|
||||
dependencies:
|
||||
@ -12833,11 +12970,11 @@ snapshots:
|
||||
postcss: 8.5.6
|
||||
postcss-safe-parser: 6.0.0(postcss@8.5.6)
|
||||
|
||||
postcss-jsx@0.36.4(postcss-syntax@0.36.2)(postcss@7.0.39):
|
||||
postcss-jsx@0.36.4(postcss-syntax@0.36.2(postcss-html@1.8.0)(postcss@8.5.6))(postcss@7.0.39):
|
||||
dependencies:
|
||||
'@babel/core': 7.28.0
|
||||
postcss: 7.0.39
|
||||
postcss-syntax: 0.36.2(postcss-html@1.8.0)(postcss@8.5.6)
|
||||
postcss-syntax: 0.36.2(postcss-html@0.36.0(postcss-syntax@0.36.2(postcss-html@1.8.0)(postcss@8.5.6))(postcss@7.0.39))(postcss-jsx@0.36.4(postcss-syntax@0.36.2(postcss-html@1.8.0)(postcss@8.5.6))(postcss@7.0.39))(postcss-less@3.1.4)(postcss-markdown@0.36.0(postcss-syntax@0.36.2(postcss-html@1.8.0)(postcss@8.5.6))(postcss@7.0.39))(postcss-scss@2.1.1)(postcss@7.0.39)
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
|
||||
@ -12849,10 +12986,10 @@ snapshots:
|
||||
dependencies:
|
||||
postcss: 8.5.6
|
||||
|
||||
postcss-markdown@0.36.0(postcss-syntax@0.36.2)(postcss@7.0.39):
|
||||
postcss-markdown@0.36.0(postcss-syntax@0.36.2(postcss-html@1.8.0)(postcss@8.5.6))(postcss@7.0.39):
|
||||
dependencies:
|
||||
postcss: 7.0.39
|
||||
postcss-syntax: 0.36.2(postcss-html@1.8.0)(postcss@8.5.6)
|
||||
postcss-syntax: 0.36.2(postcss-html@0.36.0(postcss-syntax@0.36.2(postcss-html@1.8.0)(postcss@8.5.6))(postcss@7.0.39))(postcss-jsx@0.36.4(postcss-syntax@0.36.2(postcss-html@1.8.0)(postcss@8.5.6))(postcss@7.0.39))(postcss-less@3.1.4)(postcss-markdown@0.36.0(postcss-syntax@0.36.2(postcss-html@1.8.0)(postcss@8.5.6))(postcss@7.0.39))(postcss-scss@2.1.1)(postcss@7.0.39)
|
||||
remark: 10.0.1
|
||||
unist-util-find-all-after: 1.0.5
|
||||
|
||||
@ -12904,11 +13041,15 @@ snapshots:
|
||||
dependencies:
|
||||
postcss: 8.5.6
|
||||
|
||||
postcss-syntax@0.36.2(postcss-html@1.8.0)(postcss@8.5.6):
|
||||
postcss-syntax@0.36.2(postcss-html@0.36.0(postcss-syntax@0.36.2(postcss-html@1.8.0)(postcss@8.5.6))(postcss@7.0.39))(postcss-jsx@0.36.4(postcss-syntax@0.36.2(postcss-html@1.8.0)(postcss@8.5.6))(postcss@7.0.39))(postcss-less@3.1.4)(postcss-markdown@0.36.0(postcss-syntax@0.36.2(postcss-html@1.8.0)(postcss@8.5.6))(postcss@7.0.39))(postcss-scss@2.1.1)(postcss@7.0.39):
|
||||
dependencies:
|
||||
postcss: 8.5.6
|
||||
postcss: 7.0.39
|
||||
optionalDependencies:
|
||||
postcss-html: 1.8.0
|
||||
postcss-html: 0.36.0(postcss-syntax@0.36.2(postcss-html@1.8.0)(postcss@8.5.6))(postcss@7.0.39)
|
||||
postcss-jsx: 0.36.4(postcss-syntax@0.36.2(postcss-html@1.8.0)(postcss@8.5.6))(postcss@7.0.39)
|
||||
postcss-less: 3.1.4
|
||||
postcss-markdown: 0.36.0(postcss-syntax@0.36.2(postcss-html@1.8.0)(postcss@8.5.6))(postcss@7.0.39)
|
||||
postcss-scss: 2.1.1
|
||||
|
||||
postcss-value-parser@3.3.1: {}
|
||||
|
||||
@ -13951,10 +14092,10 @@ snapshots:
|
||||
normalize-selector: 0.2.0
|
||||
pify: 4.0.1
|
||||
postcss: 7.0.39
|
||||
postcss-html: 0.36.0(postcss-syntax@0.36.2)(postcss@7.0.39)
|
||||
postcss-jsx: 0.36.4(postcss-syntax@0.36.2)(postcss@7.0.39)
|
||||
postcss-html: 0.36.0(postcss-syntax@0.36.2(postcss-html@1.8.0)(postcss@8.5.6))(postcss@7.0.39)
|
||||
postcss-jsx: 0.36.4(postcss-syntax@0.36.2(postcss-html@1.8.0)(postcss@8.5.6))(postcss@7.0.39)
|
||||
postcss-less: 3.1.4
|
||||
postcss-markdown: 0.36.0(postcss-syntax@0.36.2)(postcss@7.0.39)
|
||||
postcss-markdown: 0.36.0(postcss-syntax@0.36.2(postcss-html@1.8.0)(postcss@8.5.6))(postcss@7.0.39)
|
||||
postcss-media-query-parser: 0.2.3
|
||||
postcss-reporter: 6.0.1
|
||||
postcss-resolve-nested-selector: 0.1.6
|
||||
@ -13962,7 +14103,7 @@ snapshots:
|
||||
postcss-sass: 0.3.5
|
||||
postcss-scss: 2.1.1
|
||||
postcss-selector-parser: 3.1.2
|
||||
postcss-syntax: 0.36.2(postcss-html@1.8.0)(postcss@8.5.6)
|
||||
postcss-syntax: 0.36.2(postcss-html@0.36.0(postcss-syntax@0.36.2(postcss-html@1.8.0)(postcss@8.5.6))(postcss@7.0.39))(postcss-jsx@0.36.4(postcss-syntax@0.36.2(postcss-html@1.8.0)(postcss@8.5.6))(postcss@7.0.39))(postcss-less@3.1.4)(postcss-markdown@0.36.0(postcss-syntax@0.36.2(postcss-html@1.8.0)(postcss@8.5.6))(postcss@7.0.39))(postcss-scss@2.1.1)(postcss@7.0.39)
|
||||
postcss-value-parser: 3.3.1
|
||||
resolve-from: 4.0.0
|
||||
signal-exit: 3.0.7
|
||||
@ -14685,6 +14826,11 @@ snapshots:
|
||||
dependencies:
|
||||
opencollective-postinstall: 2.0.3
|
||||
|
||||
vue-pdf-embed@2.1.6(vue@3.5.18(typescript@4.9.5)):
|
||||
dependencies:
|
||||
pdfjs-dist: 6.3.289
|
||||
vue: 3.5.18(typescript@4.9.5)
|
||||
|
||||
vue-plugin-hiprint@0.0.60:
|
||||
dependencies:
|
||||
'@claviska/jquery-minicolors': 2.3.6(jquery@3.7.1)
|
||||
|
||||
BIN
public/login-assets/hero-logistics.jpg
Normal file
BIN
public/login-assets/hero-logistics.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 134 KiB |
BIN
public/login-assets/hero-logistics.png
Normal file
BIN
public/login-assets/hero-logistics.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 160 KiB |
@ -101,11 +101,23 @@ export async function getFileAccessUrl(key: string): Promise<AccessUrlResult> {
|
||||
export async function streamFileBlob(keyOrUrl: string): Promise<Blob> {
|
||||
const res = await axiosInstance.get(omsUrl('/file-storage/stream'), {
|
||||
params: { key: keyOrUrl },
|
||||
responseType: 'blob',
|
||||
responseType: 'arraybuffer',
|
||||
timeout: 120000,
|
||||
})
|
||||
if (res.data instanceof Blob) return res.data
|
||||
return new Blob([res.data])
|
||||
const type = String(res.headers['content-type'] || '')
|
||||
const bytes = new Uint8Array(res.data as ArrayBuffer)
|
||||
const sample = new TextDecoder('utf-8', { fatal: false }).decode(bytes.slice(0, 256)).trim()
|
||||
if (type.toLowerCase().includes('json') || sample.startsWith('{') || sample.startsWith('[')) {
|
||||
try {
|
||||
const body = JSON.parse(new TextDecoder().decode(bytes))
|
||||
const msg = body?.msg ?? body?.message ?? body?.Message
|
||||
throw new Error(msg ? String(msg) : '文件流读取失败')
|
||||
} catch (e) {
|
||||
if (e instanceof Error && e.message !== '文件流读取失败') throw e
|
||||
throw new Error(sample || '文件流读取失败')
|
||||
}
|
||||
}
|
||||
return new Blob([bytes], { type: type || 'application/octet-stream' })
|
||||
}
|
||||
|
||||
/** POST /file-storage/normalize-key */
|
||||
|
||||
@ -1198,7 +1198,7 @@ export async function postOrderExceptionEventProcess(body: { id: number | string
|
||||
export async function postOrderPrint(body: OrderIdRequest): Promise<OrderPrintResult> {
|
||||
const res = await axiosInstance.post(orderUrl('/order/print'), { id: body.id })
|
||||
assertBusinessOk(res.data)
|
||||
const d = res.data?.data ?? res.data?.Data ?? {}
|
||||
const d = res.data?.data ?? res.data?.Data ?? res.data ?? {}
|
||||
return {
|
||||
printUrl: d.printUrl ?? d.PrintUrl ?? '',
|
||||
}
|
||||
@ -1218,7 +1218,7 @@ export async function postOrderExport(params: OrderExportRequest): Promise<Order
|
||||
sortOrder: params.sortOrder,
|
||||
})
|
||||
assertBusinessOk(res.data)
|
||||
const d = res.data?.data ?? res.data?.Data ?? {}
|
||||
const d = res.data?.data ?? res.data?.Data ?? res.data ?? {}
|
||||
return {
|
||||
downloadUrl: d.downloadUrl ?? d.DownloadUrl ?? '',
|
||||
expireAt: d.expireAt ?? d.ExpireAt ?? '',
|
||||
|
||||
@ -121,6 +121,8 @@ export const getWarehouseInboundSummary = (params?: Record<string, unknown>) =>
|
||||
|
||||
// Parcel
|
||||
export const getWarehouseParcelList = (body: Record<string, unknown>) => postList('/warehouse/parcel/list', body)
|
||||
export const getWarehouseParcelSummary = (params?: Record<string, unknown>) =>
|
||||
getData('/warehouse/parcel/summary', params)
|
||||
export const saveWarehouseParcel = (body: Record<string, unknown>) => postOk('/warehouse/parcel/save', body)
|
||||
export const deleteWarehouseParcel = (id: number) => postOk('/warehouse/parcel/delete', { id })
|
||||
export const putawayWarehouseParcel = (body: Record<string, unknown>) => postOk('/warehouse/parcel/putaway', body)
|
||||
|
||||
3
src/components.d.ts
vendored
3
src/components.d.ts
vendored
@ -43,6 +43,9 @@ declare module 'vue' {
|
||||
NanaBatchJobsDrawer: typeof import('./components/NanaAssistant/NanaBatchJobsDrawer.vue')['default']
|
||||
OrderPrintModal: typeof import('./components/PrintTemplate/OrderPrintModal.vue')['default']
|
||||
PaginationPro: typeof import('./components/PaginationPro/index.vue')['default']
|
||||
PrintOptionsForm: typeof import('./components/PrintTemplate/PrintOptionsForm.vue')['default']
|
||||
PrintPdfPreview: typeof import('./components/PrintTemplate/PrintPdfPreview.vue')['default']
|
||||
PrintPreviewPane: typeof import('./components/PrintTemplate/PrintPreviewPane.vue')['default']
|
||||
QuantityInput: typeof import('./components/QuantityInput/index.vue')['default']
|
||||
RbacDetailShell: typeof import('./components/RbacSplit/RbacDetailShell.vue')['default']
|
||||
RightTopMessage: typeof import('./components/top-nav/RightTopMessage.vue')['default']
|
||||
|
||||
@ -219,6 +219,32 @@
|
||||
|
||||
/** 编辑写回源数据时跳过 data watch,避免打断输入 */
|
||||
let ignoreDataWatch = false;
|
||||
/** 表头初始化/销毁期间不向业务页 emit search,避免首屏重复拉接口 */
|
||||
let headerSearchEmitReady = false;
|
||||
let headerSearchReadyTimer: ReturnType<typeof setTimeout> | null = null;
|
||||
|
||||
function pauseHeaderSearchEmit() {
|
||||
headerSearchEmitReady = false;
|
||||
if (headerSearchReadyTimer) {
|
||||
clearTimeout(headerSearchReadyTimer);
|
||||
headerSearchReadyTimer = null;
|
||||
}
|
||||
}
|
||||
|
||||
function scheduleHeaderSearchEmitReady() {
|
||||
if (headerSearchReadyTimer) {
|
||||
clearTimeout(headerSearchReadyTimer);
|
||||
}
|
||||
headerSearchReadyTimer = setTimeout(() => {
|
||||
headerSearchEmitReady = true;
|
||||
headerSearchReadyTimer = null;
|
||||
}, 450);
|
||||
}
|
||||
|
||||
function emitSearch() {
|
||||
if (!headerSearchEmitReady) return;
|
||||
emit('search');
|
||||
}
|
||||
|
||||
const hotContainer = ref<HTMLElement | null>(null);
|
||||
const containerRef = ref<HTMLElement | null>(null);
|
||||
@ -700,7 +726,7 @@
|
||||
const serverFilter = col.serverFilter !== false;
|
||||
emit('filter-apply', { field, value, serverFilter });
|
||||
if (serverFilter) {
|
||||
emit('search');
|
||||
emitSearch();
|
||||
}
|
||||
// 仅当前页过滤列做本地匹配;serverFilter 列交给接口(含高级运算)
|
||||
if (hotInstance && col.serverFilter === false) {
|
||||
@ -720,7 +746,7 @@
|
||||
const serverFilter = col.serverFilter !== false;
|
||||
emit('filter-apply', { field, value: '', serverFilter });
|
||||
if (serverFilter) {
|
||||
emit('search');
|
||||
emitSearch();
|
||||
} else if (hotInstance) {
|
||||
hotInstance.loadData(syncDisplayRows());
|
||||
hotInstance.render();
|
||||
@ -744,7 +770,7 @@
|
||||
}
|
||||
(props.searchParams as any)[key] = '';
|
||||
emit('filter-apply', { field: key, value: '', serverFilter: true });
|
||||
emit('search');
|
||||
emitSearch();
|
||||
syncHybridHeaders();
|
||||
}
|
||||
|
||||
@ -758,7 +784,7 @@
|
||||
localSortOrder.value = null;
|
||||
}
|
||||
emit('clear-filters');
|
||||
emit('search');
|
||||
emitSearch();
|
||||
if (hotInstance) {
|
||||
hotInstance.loadData(syncDisplayRows());
|
||||
hotInstance.render();
|
||||
@ -842,7 +868,7 @@
|
||||
}
|
||||
|
||||
function notifySearch() {
|
||||
emit('search');
|
||||
emitSearch();
|
||||
// 无服务端接线的页面也能靠本地过滤立即生效
|
||||
if (hotInstance) {
|
||||
hotInstance.loadData(syncDisplayRows());
|
||||
@ -1209,6 +1235,8 @@
|
||||
return;
|
||||
}
|
||||
|
||||
pauseHeaderSearchEmit();
|
||||
|
||||
if (hotInstance) {
|
||||
hotInstance.destroy();
|
||||
hotInstance = null;
|
||||
@ -1852,8 +1880,10 @@
|
||||
hotInstance = new Handsontable(hotContainer.value, hotConfig as any);
|
||||
// 首次创建后立即校准横向滚动条,避免首屏样式竞争导致横条被隐藏
|
||||
ensureHorizontalScrollbarVisible();
|
||||
scheduleHeaderSearchEmitReady();
|
||||
} catch (error) {
|
||||
console.error('初始化 Handsontable 失败:', error);
|
||||
scheduleHeaderSearchEmitReady();
|
||||
}
|
||||
};
|
||||
|
||||
@ -2424,6 +2454,7 @@
|
||||
});
|
||||
|
||||
onUnmounted(() => {
|
||||
pauseHeaderSearchEmit();
|
||||
if (resizeObserver && containerRef.value) {
|
||||
try {
|
||||
resizeObserver.unobserve(containerRef.value);
|
||||
|
||||
@ -1,138 +1,108 @@
|
||||
<template>
|
||||
<a-modal
|
||||
:visible="visible"
|
||||
:title="mode === 'batch' ? '批量打印' : '单个打印'"
|
||||
:title="modalTitle"
|
||||
:width="1120"
|
||||
:footer="false"
|
||||
:mask-closable="false"
|
||||
unmount-on-close
|
||||
@cancel="emit('update:visible', false)"
|
||||
modal-class="order-print-modal"
|
||||
@cancel="closeModal"
|
||||
>
|
||||
<div v-if="mode === 'batch'" class="batch-shell">
|
||||
<div class="batch-hero">
|
||||
<div class="batch-hero-left">
|
||||
<span class="batch-hero-icon">🖨</span>
|
||||
<div>
|
||||
<div class="batch-hero-title">批量打印</div>
|
||||
<p class="batch-hero-desc">预览后一键发送至本机 hiprint</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="batch-hero-stats">
|
||||
<div class="batch-stat">
|
||||
<span class="batch-stat-value">{{ printableItems.length }}</span>
|
||||
<span class="batch-stat-label">可打</span>
|
||||
</div>
|
||||
<div class="batch-stat batch-stat-muted">
|
||||
<span class="batch-stat-value">{{ items.length }}</span>
|
||||
<span class="batch-stat-label">总计</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="print-modal-body">
|
||||
<div :class="['print-status-bar', `print-status-bar--${printerStatusTone}`]">
|
||||
<span class="print-status-dot" />
|
||||
<span class="print-status-text">{{ printerStatusText }}</span>
|
||||
</div>
|
||||
|
||||
<div class="batch-options-card">
|
||||
<div class="batch-options-title">纸张与打印参数</div>
|
||||
<div class="batch-options-grid">
|
||||
<label>纸张</label>
|
||||
<a-select v-model="hiprintForm.paperPreset" :options="paperOptions" size="small" />
|
||||
<template v-if="hiprintForm.paperPreset === 'custom'">
|
||||
<label>宽(mm)</label>
|
||||
<a-input-number v-model="hiprintForm.customWidthMm" size="small" :min="10" :max="500" />
|
||||
<label>高(mm)</label>
|
||||
<a-input-number v-model="hiprintForm.customHeightMm" size="small" :min="10" :max="500" />
|
||||
</template>
|
||||
<label>横向</label>
|
||||
<a-switch v-model="hiprintForm.landscape" size="small" />
|
||||
<label>份数</label>
|
||||
<a-input-number v-model="hiprintForm.copies" size="small" :min="1" :max="99" />
|
||||
<label>缩放%</label>
|
||||
<a-input-number v-model="hiprintForm.scaleFactor" size="small" :min="10" :max="200" />
|
||||
<div v-if="mode === 'batch'" class="batch-shell">
|
||||
<div class="batch-options-card">
|
||||
<PrintOptionsForm
|
||||
v-model="hiprintForm"
|
||||
v-model:advanced-open="advancedOpen"
|
||||
:paper-options="paperOptions"
|
||||
:columns="2"
|
||||
/>
|
||||
</div>
|
||||
<div class="batch-options-actions">
|
||||
<a-button size="small" @click="openActiveInNewTab">新标签打开</a-button>
|
||||
<a-button type="primary" :disabled="!activeItem" @click="printActive">打印当前</a-button>
|
||||
<a-button type="primary" status="success" :disabled="!printableItems.length" @click="printAll">静默打印</a-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="batch-bottom-card">
|
||||
<div class="batch-bottom-caption">面单列表 · 点击条目切换预览</div>
|
||||
<div class="batch-bottom-body">
|
||||
<div class="batch-list">
|
||||
<div class="batch-list-title">列表({{ printableItems.length }})</div>
|
||||
<div class="batch-list-body">
|
||||
<div
|
||||
v-for="item in printableItems"
|
||||
:key="item.id"
|
||||
:class="['batch-list-item', { active: item.id === activeItem?.id }]"
|
||||
@click="activeId = item.id"
|
||||
>
|
||||
{{ item.label || item.id }}
|
||||
<div class="batch-bottom-card">
|
||||
<div class="batch-bottom-caption">面单列表 · 点击条目切换预览</div>
|
||||
<div class="batch-bottom-body">
|
||||
<div class="batch-list">
|
||||
<div class="batch-list-title">列表({{ printableItems.length }})</div>
|
||||
<div class="batch-list-body">
|
||||
<div
|
||||
v-for="item in printableItems"
|
||||
:key="item.id"
|
||||
:class="['batch-list-item', { active: item.id === activeItem?.id }]"
|
||||
@click="activeId = item.id"
|
||||
>
|
||||
{{ item.label || item.id }}
|
||||
</div>
|
||||
<a-empty v-if="!printableItems.length" description="暂无可打印内容" />
|
||||
</div>
|
||||
<a-empty v-if="!printableItems.length" description="暂无可打印内容" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="batch-preview">
|
||||
<div v-if="previewLoading" class="print-preview-loading">面单加载中…</div>
|
||||
<iframe
|
||||
v-else-if="previewSrc"
|
||||
ref="previewFrameRef"
|
||||
class="print-preview-frame"
|
||||
:src="previewSrc"
|
||||
<PrintPreviewPane
|
||||
:preparing="preparing"
|
||||
:loading="previewLoading"
|
||||
:rendering="previewRendering"
|
||||
:switching="previewSwitching"
|
||||
:error="previewError"
|
||||
:pdf-source="previewPdfSource"
|
||||
:html-src="previewHtmlSrc"
|
||||
:subtitle="activeItem?.label"
|
||||
:index-label="activeIndexLabel"
|
||||
@retry="retryPreview"
|
||||
@loading-failed="onPreviewPdfFailed"
|
||||
@rendered="onPreviewRendered"
|
||||
/>
|
||||
<a-empty v-else description="暂无可预览打印内容" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-else class="single-shell">
|
||||
<PrintPreviewPane
|
||||
class="single-preview"
|
||||
:preparing="preparing"
|
||||
:loading="previewLoading"
|
||||
:rendering="previewRendering"
|
||||
:switching="previewSwitching"
|
||||
:error="previewError"
|
||||
:pdf-source="previewPdfSource"
|
||||
:html-src="previewHtmlSrc"
|
||||
:subtitle="activeItem?.label"
|
||||
@retry="retryPreview"
|
||||
@loading-failed="onPreviewPdfFailed"
|
||||
@rendered="onPreviewRendered"
|
||||
/>
|
||||
<aside class="single-side-panel">
|
||||
<PrintOptionsForm v-model="hiprintForm" v-model:advanced-open="advancedOpen" :paper-options="paperOptions" />
|
||||
</aside>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-else class="single-shell">
|
||||
<section class="print-preview-panel">
|
||||
<div class="print-preview-toolbar">
|
||||
<span class="print-preview-title">PDF/HTML 预览</span>
|
||||
<a-button size="small" @click="openActiveInNewTab">新标签打开</a-button>
|
||||
</div>
|
||||
<div v-if="previewLoading" class="print-preview-loading">面单加载中…</div>
|
||||
<iframe
|
||||
v-else-if="previewSrc"
|
||||
ref="previewFrameRef"
|
||||
class="print-preview-frame"
|
||||
:src="previewSrc"
|
||||
/>
|
||||
<a-empty v-else description="暂无可预览打印内容" />
|
||||
</section>
|
||||
<aside class="single-side-panel">
|
||||
<div class="single-hero">
|
||||
<span class="single-hero-icon">🖨</span>
|
||||
<div>
|
||||
<div class="single-hero-title">单个打印</div>
|
||||
<p class="single-hero-desc">已连接后可直接静默发送到本机 hiprint</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="single-options-card">
|
||||
<div class="single-options-title">打印参数</div>
|
||||
<div class="single-options-grid">
|
||||
<label>纸张</label>
|
||||
<a-select v-model="hiprintForm.paperPreset" :options="paperOptions" size="small" />
|
||||
<template v-if="hiprintForm.paperPreset === 'custom'">
|
||||
<label>宽(mm)</label>
|
||||
<a-input-number v-model="hiprintForm.customWidthMm" size="small" :min="10" :max="500" />
|
||||
<label>高(mm)</label>
|
||||
<a-input-number v-model="hiprintForm.customHeightMm" size="small" :min="10" :max="500" />
|
||||
</template>
|
||||
<label>横向</label>
|
||||
<a-switch v-model="hiprintForm.landscape" size="small" />
|
||||
<label>份数</label>
|
||||
<a-input-number v-model="hiprintForm.copies" size="small" :min="1" :max="99" />
|
||||
<label>缩放%</label>
|
||||
<a-input-number v-model="hiprintForm.scaleFactor" size="small" :min="10" :max="200" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="single-actions">
|
||||
<a-button size="small" @click="openActiveInNewTab">新标签打开</a-button>
|
||||
<a-button type="primary" :disabled="!activeItem" @click="printActive">打印当前</a-button>
|
||||
</div>
|
||||
</aside>
|
||||
</div>
|
||||
<template #footer>
|
||||
<a-button :disabled="footerBusy" @click="closeModal">关闭</a-button>
|
||||
<a-button :disabled="!canOpenPreview" @click="openActiveInNewTab">新标签打开</a-button>
|
||||
<a-button
|
||||
v-if="mode === 'batch'"
|
||||
type="primary"
|
||||
status="success"
|
||||
:disabled="!canPrint"
|
||||
:loading="printingAll"
|
||||
@click="printAll"
|
||||
>
|
||||
{{ printingAll ? '发送中…' : '全部打印' }}
|
||||
</a-button>
|
||||
<a-button
|
||||
type="primary"
|
||||
:status="printJustSucceeded ? 'success' : undefined"
|
||||
:disabled="!canPrint"
|
||||
:loading="printingActive"
|
||||
@click="printActive"
|
||||
>
|
||||
{{ printActiveLabel }}
|
||||
</a-button>
|
||||
</template>
|
||||
</a-modal>
|
||||
</template>
|
||||
|
||||
@ -147,7 +117,14 @@ import {
|
||||
} from '@/utils/hiprint/hiprintElectronSocket';
|
||||
import { useHiprintClientState } from '@/utils/hiprint/hiprintClientState';
|
||||
import { resolveOmsAssetUrl } from '@/api/oms/common';
|
||||
import { fetchPrintAssetBytes, resolvePrintPreviewSrc } from '@/utils/printPreview';
|
||||
import PrintOptionsForm from '@/components/PrintTemplate/PrintOptionsForm.vue';
|
||||
import PrintPreviewPane from '@/components/PrintTemplate/PrintPreviewPane.vue';
|
||||
import { fetchPrintAssetBytes } from '@/utils/printPreview';
|
||||
import {
|
||||
getOrPrefetchPrintPreview,
|
||||
peekPrintPreviewCache,
|
||||
prefetchPrintPreview,
|
||||
} from '@/utils/printSessionCache';
|
||||
import {
|
||||
buildHiprintBlobPrintExtras,
|
||||
HIPRINT_PAPER_PRESET_OPTIONS,
|
||||
@ -166,11 +143,14 @@ const props = withDefaults(
|
||||
visible: boolean;
|
||||
mode: 'single' | 'batch';
|
||||
items: PrintItem[];
|
||||
/** 父级正在请求 printUrl,弹窗内展示获取中骨架屏 */
|
||||
preparing?: boolean;
|
||||
}>(),
|
||||
{
|
||||
mode: 'single',
|
||||
items: () => [],
|
||||
}
|
||||
preparing: false,
|
||||
},
|
||||
);
|
||||
|
||||
const emit = defineEmits<{
|
||||
@ -179,13 +159,22 @@ const emit = defineEmits<{
|
||||
|
||||
const paperOptions = HIPRINT_PAPER_PRESET_OPTIONS;
|
||||
const hiprintClientState = useHiprintClientState();
|
||||
const previewFrameRef = ref<HTMLIFrameElement>();
|
||||
const activeId = ref<number | string | null>(null);
|
||||
const hiprintForm = ref(readHiprintPrintFormFromStorage());
|
||||
const previewSrc = ref('');
|
||||
const advancedOpen = ref(false);
|
||||
const previewPdfSource = ref<string | Uint8Array | null>(null);
|
||||
const previewHtmlSrc = ref('');
|
||||
const previewLoading = ref(false);
|
||||
const previewRendering = ref(false);
|
||||
const previewSwitching = ref(false);
|
||||
const previewError = ref('');
|
||||
const printingActive = ref(false);
|
||||
const printingAll = ref(false);
|
||||
const printJustSucceeded = ref(false);
|
||||
let previewBlobUrl: string | null = null;
|
||||
let printSuccessTimer: ReturnType<typeof setTimeout> | null = null;
|
||||
let previewLoadToken = 0;
|
||||
let previewLoadTimer: ReturnType<typeof setTimeout> | null = null;
|
||||
|
||||
const printableItems = computed(() => (props.items || []).filter((x) => !!String(x?.url || '').trim()));
|
||||
const activeItem = computed(() => {
|
||||
@ -194,37 +183,170 @@ const activeItem = computed(() => {
|
||||
return printableItems.value.find((x) => x.id === activeId.value) || printableItems.value[0];
|
||||
});
|
||||
|
||||
const modalTitle = computed(() => {
|
||||
if (props.mode === 'batch') {
|
||||
return `批量打印(${printableItems.value.length} 单)`;
|
||||
}
|
||||
const label = activeItem.value?.label;
|
||||
return label ? `打印面单 · ${label}` : '打印面单';
|
||||
});
|
||||
|
||||
const activeIndexLabel = computed(() => {
|
||||
if (props.mode !== 'batch' || !activeItem.value) return '';
|
||||
const index = printableItems.value.findIndex((x) => x.id === activeItem.value?.id);
|
||||
if (index < 0) return '';
|
||||
return `${index + 1} / ${printableItems.value.length}`;
|
||||
});
|
||||
|
||||
const printerStatusTone = computed(() => {
|
||||
if (printingActive.value || printingAll.value) return 'warning';
|
||||
if (props.preparing) return 'default';
|
||||
if (hiprintClientState.connected) return 'success';
|
||||
if (hiprintClientState.connecting || hiprintClientState.enabled) return 'warning';
|
||||
return 'default';
|
||||
});
|
||||
|
||||
const printerStatusText = computed(() => {
|
||||
if (printingActive.value || printingAll.value) return '正在发送打印任务…';
|
||||
if (props.preparing) return '正在获取面单文件…';
|
||||
if (hiprintClientState.connecting) return '正在连接本机打印程序…';
|
||||
if (hiprintClientState.connected) return '本机打印已就绪,可一键自动打印';
|
||||
if (hiprintClientState.enabled) return '打印程序连接中,请稍候…';
|
||||
return '未连接,请先打开页面顶部「打印」开关';
|
||||
});
|
||||
|
||||
const previewBusy = computed(
|
||||
() => props.preparing || previewLoading.value || previewRendering.value || previewSwitching.value,
|
||||
);
|
||||
|
||||
const footerBusy = computed(() => printingActive.value || printingAll.value);
|
||||
|
||||
const canOpenPreview = computed(() => !!activeItem.value?.url && !props.preparing && !previewLoading.value);
|
||||
|
||||
const canPrint = computed(
|
||||
() => !!activeItem.value?.url && !previewBusy.value && !footerBusy.value && printableItems.value.length > 0,
|
||||
);
|
||||
|
||||
const printActiveLabel = computed(() => {
|
||||
if (printJustSucceeded.value) return '已发送';
|
||||
if (printingActive.value) return '发送中…';
|
||||
return props.mode === 'batch' ? '打印当前' : '打印';
|
||||
});
|
||||
|
||||
function closeModal() {
|
||||
emit('update:visible', false);
|
||||
}
|
||||
|
||||
function revokePreviewBlob() {
|
||||
if (!previewBlobUrl) return;
|
||||
URL.revokeObjectURL(previewBlobUrl);
|
||||
previewBlobUrl = null;
|
||||
}
|
||||
|
||||
function applyPreviewEntry(
|
||||
entry: { pdfSource: string | Uint8Array | null; htmlBlob: Blob | null },
|
||||
token: number,
|
||||
) {
|
||||
if (token !== previewLoadToken) return;
|
||||
|
||||
let nextHtml = '';
|
||||
let nextBlobUrl: string | null = null;
|
||||
if (entry.htmlBlob) {
|
||||
nextBlobUrl = URL.createObjectURL(entry.htmlBlob);
|
||||
nextHtml = nextBlobUrl;
|
||||
}
|
||||
|
||||
revokePreviewBlob();
|
||||
previewBlobUrl = nextBlobUrl;
|
||||
previewHtmlSrc.value = nextHtml;
|
||||
previewPdfSource.value = entry.pdfSource;
|
||||
previewRendering.value = !!(entry.pdfSource || nextHtml);
|
||||
previewLoading.value = false;
|
||||
previewSwitching.value = false;
|
||||
}
|
||||
|
||||
async function loadPreviewForActive() {
|
||||
const token = ++previewLoadToken;
|
||||
revokePreviewBlob();
|
||||
previewSrc.value = '';
|
||||
previewError.value = '';
|
||||
|
||||
if (!props.visible || !activeItem.value?.url) {
|
||||
if (!props.visible) {
|
||||
revokePreviewBlob();
|
||||
previewPdfSource.value = null;
|
||||
previewHtmlSrc.value = '';
|
||||
}
|
||||
previewLoading.value = false;
|
||||
previewRendering.value = false;
|
||||
previewSwitching.value = false;
|
||||
return;
|
||||
}
|
||||
previewLoading.value = true;
|
||||
try {
|
||||
const src = await resolvePrintPreviewSrc(activeItem.value.url);
|
||||
if (token !== previewLoadToken) {
|
||||
if (src.startsWith('blob:')) URL.revokeObjectURL(src);
|
||||
return;
|
||||
}
|
||||
if (src.startsWith('blob:')) {
|
||||
previewBlobUrl = src;
|
||||
}
|
||||
previewSrc.value = src;
|
||||
} catch {
|
||||
if (token !== previewLoadToken) return;
|
||||
previewSrc.value = toAbsoluteUrl(activeItem.value.url);
|
||||
} finally {
|
||||
if (token === previewLoadToken) previewLoading.value = false;
|
||||
|
||||
if (props.preparing) {
|
||||
previewLoading.value = false;
|
||||
previewSwitching.value = false;
|
||||
return;
|
||||
}
|
||||
|
||||
const url = activeItem.value.url;
|
||||
const cached = peekPrintPreviewCache(url);
|
||||
const hadContent = !!(previewPdfSource.value || previewHtmlSrc.value);
|
||||
|
||||
if (cached) {
|
||||
applyPreviewEntry(cached, token);
|
||||
return;
|
||||
}
|
||||
|
||||
if (hadContent) {
|
||||
previewSwitching.value = true;
|
||||
} else {
|
||||
previewLoading.value = true;
|
||||
}
|
||||
|
||||
try {
|
||||
const entry = await getOrPrefetchPrintPreview(url);
|
||||
if (token !== previewLoadToken) return;
|
||||
applyPreviewEntry(entry, token);
|
||||
} catch (e: any) {
|
||||
if (token !== previewLoadToken) return;
|
||||
previewError.value = e?.message || '面单预览加载失败,请尝试新标签打开';
|
||||
previewRendering.value = false;
|
||||
} finally {
|
||||
if (token === previewLoadToken) {
|
||||
previewLoading.value = false;
|
||||
previewSwitching.value = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function retryPreview() {
|
||||
void loadPreviewForActive();
|
||||
}
|
||||
|
||||
function onPreviewPdfFailed() {
|
||||
previewError.value = 'PDF 解析失败,请尝试新标签打开';
|
||||
previewPdfSource.value = null;
|
||||
previewRendering.value = false;
|
||||
}
|
||||
|
||||
function onPreviewRendered() {
|
||||
previewRendering.value = false;
|
||||
}
|
||||
|
||||
function flashPrintSuccess() {
|
||||
printJustSucceeded.value = true;
|
||||
if (printSuccessTimer) clearTimeout(printSuccessTimer);
|
||||
printSuccessTimer = setTimeout(() => {
|
||||
printJustSucceeded.value = false;
|
||||
printSuccessTimer = null;
|
||||
}, 1600);
|
||||
}
|
||||
|
||||
function scheduleLoadPreview() {
|
||||
if (previewLoadTimer) clearTimeout(previewLoadTimer);
|
||||
previewLoadTimer = null;
|
||||
const url = activeItem.value?.url;
|
||||
if (url) void prefetchPrintPreview(url);
|
||||
void loadPreviewForActive();
|
||||
}
|
||||
|
||||
watch(
|
||||
@ -232,35 +354,49 @@ watch(
|
||||
(visible) => {
|
||||
if (!visible) {
|
||||
revokePreviewBlob();
|
||||
previewSrc.value = '';
|
||||
previewPdfSource.value = null;
|
||||
previewHtmlSrc.value = '';
|
||||
previewError.value = '';
|
||||
previewLoading.value = false;
|
||||
previewRendering.value = false;
|
||||
previewSwitching.value = false;
|
||||
advancedOpen.value = false;
|
||||
printJustSucceeded.value = false;
|
||||
if (previewLoadTimer) clearTimeout(previewLoadTimer);
|
||||
previewLoadTimer = null;
|
||||
if (printSuccessTimer) clearTimeout(printSuccessTimer);
|
||||
printSuccessTimer = null;
|
||||
return;
|
||||
}
|
||||
activeId.value = printableItems.value[0]?.id ?? null;
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
watch(
|
||||
[
|
||||
() => props.visible,
|
||||
() => props.preparing,
|
||||
() => props.items,
|
||||
() => activeItem.value?.id,
|
||||
() => activeItem.value?.url,
|
||||
],
|
||||
() => {
|
||||
void loadPreviewForActive();
|
||||
scheduleLoadPreview();
|
||||
},
|
||||
{ deep: true },
|
||||
);
|
||||
|
||||
watch(
|
||||
() => hiprintForm.value,
|
||||
(val) => writeHiprintPrintFormToStorage(val),
|
||||
{ deep: true }
|
||||
{ deep: true },
|
||||
);
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
previewLoadToken += 1;
|
||||
if (previewLoadTimer) clearTimeout(previewLoadTimer);
|
||||
previewLoadTimer = null;
|
||||
if (printSuccessTimer) clearTimeout(printSuccessTimer);
|
||||
printSuccessTimer = null;
|
||||
revokePreviewBlob();
|
||||
});
|
||||
|
||||
@ -315,23 +451,17 @@ async function printActive() {
|
||||
Message.warning('打印连接未就绪,请先在顶部打开并连接');
|
||||
return;
|
||||
}
|
||||
printingActive.value = true;
|
||||
try {
|
||||
await silentPrintByUrl(activeItem.value.url);
|
||||
Message.success('已发送到本机 hiprint');
|
||||
return;
|
||||
flashPrintSuccess();
|
||||
Message.success('已发送到本机打印');
|
||||
} catch (e: any) {
|
||||
Message.warning(e?.message || '静默打印失败,回退浏览器打印');
|
||||
Message.warning(e?.message || '自动打印失败,将尝试浏览器打印');
|
||||
window.open(toAbsoluteUrl(activeItem.value.url) || activeItem.value.url, '_blank', 'noopener,noreferrer');
|
||||
} finally {
|
||||
printingActive.value = false;
|
||||
}
|
||||
try {
|
||||
if (previewFrameRef.value?.contentWindow) {
|
||||
previewFrameRef.value.contentWindow.focus();
|
||||
previewFrameRef.value.contentWindow.print();
|
||||
return;
|
||||
}
|
||||
} catch {
|
||||
// ignore
|
||||
}
|
||||
window.open(toAbsoluteUrl(activeItem.value.url) || activeItem.value.url, '_blank', 'noopener,noreferrer');
|
||||
}
|
||||
|
||||
async function printAll() {
|
||||
@ -343,80 +473,200 @@ async function printAll() {
|
||||
Message.warning('打印连接未就绪,请先在顶部打开并连接');
|
||||
return;
|
||||
}
|
||||
const tasks = printableItems.value.map((item) =>
|
||||
silentPrintByUrl(item.url).catch(() => {
|
||||
window.open(toAbsoluteUrl(item.url) || item.url, '_blank', 'noopener,noreferrer');
|
||||
})
|
||||
);
|
||||
const results = await Promise.allSettled(tasks);
|
||||
const failed = results.filter((x) => x.status === 'rejected').length;
|
||||
if (failed === 0) Message.success(`批量打印完成(${results.length} 单)`);
|
||||
else Message.warning(`批量打印完成:成功 ${results.length - failed},失败 ${failed}`);
|
||||
printingAll.value = true;
|
||||
try {
|
||||
const tasks = printableItems.value.map((item) =>
|
||||
silentPrintByUrl(item.url).catch(() => {
|
||||
window.open(toAbsoluteUrl(item.url) || item.url, '_blank', 'noopener,noreferrer');
|
||||
}),
|
||||
);
|
||||
const results = await Promise.allSettled(tasks);
|
||||
const failed = results.filter((x) => x.status === 'rejected').length;
|
||||
if (failed === 0) {
|
||||
flashPrintSuccess();
|
||||
Message.success(`批量打印完成(${results.length} 单)`);
|
||||
} else {
|
||||
Message.warning(`批量打印完成:成功 ${results.length - failed},失败 ${failed}`);
|
||||
}
|
||||
} finally {
|
||||
printingAll.value = false;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="less">
|
||||
.batch-shell { display: flex; flex-direction: column; gap: 12px; min-height: 740px; background: var(--app-page-bg); }
|
||||
.batch-hero {
|
||||
display: flex; justify-content: space-between; align-items: center; gap: 16px;
|
||||
padding: 12px 16px; border-radius: 12px;
|
||||
background: linear-gradient(135deg, rgba(13, 148, 136, 0.09) 0%, rgba(148, 163, 184, 0.14) 100%);
|
||||
border: 1px solid rgba(15, 23, 42, 0.06);
|
||||
.print-modal-body {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
max-height: calc(100vh - 220px);
|
||||
overflow: hidden;
|
||||
}
|
||||
.batch-hero-left { display: flex; align-items: center; gap: 10px; }
|
||||
.batch-hero-icon { width: 42px; height: 42px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; background: linear-gradient(145deg, var(--app-primary-color), #0f766e); }
|
||||
.batch-hero-title { font-size: 16px; font-weight: 700; color: #0f172a; }
|
||||
.batch-hero-desc { margin: 2px 0 0; font-size: 12px; color: #64748b; }
|
||||
.batch-hero-stats { display: flex; gap: 20px; }
|
||||
.batch-stat { text-align: center; min-width: 56px; }
|
||||
.batch-stat-value { display: block; font-size: 22px; line-height: 1.1; font-weight: 800; color: var(--app-primary-color); }
|
||||
.batch-stat-label { font-size: 11px; color: #94a3b8; }
|
||||
.batch-stat-muted .batch-stat-value { color: #64748b; }
|
||||
|
||||
.batch-options-card { padding: 12px 14px; border-radius: 10px; background: var(--app-card-bg); border: 1px solid rgba(15, 23, 42, 0.06); box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04); }
|
||||
.batch-options-title { font-size: 12px; font-weight: 600; color: #475569; margin-bottom: 8px; }
|
||||
.batch-options-grid { display: grid; grid-template-columns: 56px minmax(0, 180px) 56px minmax(0, 140px); gap: 8px 10px; align-items: center; }
|
||||
.batch-options-grid > label { font-size: 12px; color: var(--color-text-2); }
|
||||
.batch-options-grid :deep(.arco-switch) { justify-self: start; width: 34px; min-width: 34px; }
|
||||
.batch-options-actions { margin-top: 10px; display: flex; justify-content: flex-end; gap: 8px; }
|
||||
|
||||
.batch-bottom-card { flex: 1; min-height: 0; border-radius: 10px; overflow: hidden; border: 1px solid rgba(15, 23, 42, 0.08); background: var(--app-card-bg); box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04); display: flex; flex-direction: column; }
|
||||
.batch-bottom-caption { padding: 10px 12px; font-size: 12px; font-weight: 600; color: var(--color-text-2); background: var(--color-fill-2); border-bottom: 1px solid var(--color-border-2); }
|
||||
.batch-bottom-body { flex: 1; min-height: 0; display: grid; grid-template-columns: 320px minmax(0, 1fr); }
|
||||
.batch-list { border-right: 1px solid var(--color-border-2); display: flex; flex-direction: column; min-height: 0; }
|
||||
.batch-list-title { padding: 10px 12px; font-size: 12px; color: var(--color-text-2); border-bottom: 1px solid var(--color-border-2); background: var(--color-fill-2); }
|
||||
.batch-list-body { flex: 1; min-height: 0; overflow: auto; }
|
||||
.batch-list-item {
|
||||
padding: 10px 12px; cursor: pointer; border-bottom: 1px solid var(--color-border-2); color: var(--color-text-1); word-break: break-all;
|
||||
&:hover { background: var(--color-fill-2); }
|
||||
&.active { background: #e8f3ff; color: var(--app-primary-color); font-weight: 600; }
|
||||
}
|
||||
.batch-preview { display: flex; flex-direction: column; min-height: 0; }
|
||||
|
||||
.single-shell { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 12px; min-height: 700px; background: var(--app-page-bg); }
|
||||
.print-preview-panel { min-height: 0; border: 1px solid var(--color-border-2); border-radius: 10px; overflow: hidden; background: var(--app-card-bg); display: flex; flex-direction: column; }
|
||||
.single-side-panel { border: 1px solid var(--color-border-2); border-radius: 10px; background: var(--app-card-bg); padding: 12px; display: flex; flex-direction: column; gap: 12px; overflow: hidden; }
|
||||
.single-hero { display: flex; align-items: center; gap: 10px; }
|
||||
.single-hero-icon { width: 42px; height: 42px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; background: linear-gradient(145deg, var(--app-primary-color), #0f766e); }
|
||||
.single-hero-title { font-size: 16px; font-weight: 700; color: #0f172a; }
|
||||
.single-hero-desc { margin: 2px 0 0; font-size: 12px; color: #64748b; }
|
||||
.single-options-card { padding: 10px; border-radius: 8px; border: 1px solid var(--color-border-2); background: var(--app-card-bg); }
|
||||
.single-options-title { font-size: 12px; color: var(--color-text-2); font-weight: 600; margin-bottom: 8px; }
|
||||
.single-options-grid { display: grid; grid-template-columns: 56px minmax(0, 1fr); gap: 6px 8px; align-items: center; }
|
||||
.single-options-grid > label { font-size: 12px; color: var(--color-text-2); }
|
||||
.single-options-grid :deep(.arco-switch) { justify-self: start; width: 34px; min-width: 34px; }
|
||||
.print-preview-toolbar { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--color-border-2); background: var(--color-fill-2); }
|
||||
.print-preview-title { font-size: 12px; font-weight: 600; color: var(--color-text-2); }
|
||||
.single-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: auto; }
|
||||
.print-preview-frame { width: 100%; height: 100%; min-height: 640px; border: none; }
|
||||
.print-preview-loading {
|
||||
flex: 1;
|
||||
min-height: 640px;
|
||||
.print-status-bar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: var(--color-text-3);
|
||||
gap: 8px;
|
||||
padding: 8px 12px;
|
||||
border-radius: 8px;
|
||||
font-size: 13px;
|
||||
background: var(--color-fill-1);
|
||||
border: 1px solid var(--color-border-2);
|
||||
background: var(--color-fill-2);
|
||||
}
|
||||
|
||||
.print-status-bar--success {
|
||||
background: rgba(0, 180, 42, 0.08);
|
||||
border-color: rgba(0, 180, 42, 0.25);
|
||||
color: rgb(0, 128, 0);
|
||||
}
|
||||
|
||||
.print-status-bar--warning {
|
||||
background: rgba(255, 125, 0, 0.08);
|
||||
border-color: rgba(255, 125, 0, 0.25);
|
||||
color: rgb(180, 90, 0);
|
||||
}
|
||||
|
||||
.print-status-dot {
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
border-radius: 50%;
|
||||
background: var(--color-text-3);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.print-status-bar--success .print-status-dot {
|
||||
background: rgb(0, 180, 42);
|
||||
}
|
||||
|
||||
.print-status-bar--warning .print-status-dot {
|
||||
background: rgb(255, 125, 0);
|
||||
}
|
||||
|
||||
.batch-shell {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
min-height: 0;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.batch-options-card {
|
||||
padding: 12px 14px;
|
||||
border-radius: 10px;
|
||||
background: var(--app-card-bg);
|
||||
border: 1px solid rgba(15, 23, 42, 0.06);
|
||||
}
|
||||
|
||||
.batch-bottom-card {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
border-radius: 10px;
|
||||
overflow: hidden;
|
||||
border: 1px solid rgba(15, 23, 42, 0.08);
|
||||
background: var(--app-card-bg);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.batch-bottom-caption {
|
||||
padding: 10px 12px;
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
color: var(--color-text-2);
|
||||
background: var(--color-fill-2);
|
||||
border-bottom: 1px solid var(--color-border-2);
|
||||
}
|
||||
|
||||
.batch-bottom-body {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
display: grid;
|
||||
grid-template-columns: 280px minmax(0, 1fr);
|
||||
max-height: calc(100vh - 380px);
|
||||
}
|
||||
|
||||
.batch-list {
|
||||
border-right: 1px solid var(--color-border-2);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
.batch-list-title {
|
||||
padding: 10px 12px;
|
||||
font-size: 12px;
|
||||
color: var(--color-text-2);
|
||||
border-bottom: 1px solid var(--color-border-2);
|
||||
background: var(--color-fill-2);
|
||||
}
|
||||
|
||||
.batch-list-body {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.batch-list-item {
|
||||
padding: 10px 12px;
|
||||
cursor: pointer;
|
||||
border-bottom: 1px solid var(--color-border-2);
|
||||
color: var(--color-text-1);
|
||||
word-break: break-all;
|
||||
|
||||
&:hover {
|
||||
background: var(--color-fill-2);
|
||||
}
|
||||
|
||||
&.active {
|
||||
background: #e8f3ff;
|
||||
color: var(--app-primary-color);
|
||||
font-weight: 600;
|
||||
}
|
||||
}
|
||||
|
||||
.single-shell {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr) 300px;
|
||||
gap: 12px;
|
||||
min-height: 0;
|
||||
max-height: calc(100vh - 280px);
|
||||
}
|
||||
|
||||
.single-preview {
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
.single-side-panel {
|
||||
border: 1px solid var(--color-border-2);
|
||||
border-radius: 10px;
|
||||
background: var(--app-card-bg);
|
||||
padding: 12px;
|
||||
overflow: auto;
|
||||
}
|
||||
</style>
|
||||
|
||||
<style lang="less">
|
||||
.order-print-modal {
|
||||
.arco-modal-body {
|
||||
max-height: calc(100vh - 160px);
|
||||
overflow: hidden;
|
||||
animation: print-modal-body-in 0.22s ease;
|
||||
}
|
||||
|
||||
.arco-modal-footer {
|
||||
transition: opacity 0.18s ease;
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes print-modal-body-in {
|
||||
from {
|
||||
opacity: 0;
|
||||
transform: translateY(8px);
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
transform: translateY(0);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
115
src/components/PrintTemplate/PrintOptionsForm.vue
Normal file
115
src/components/PrintTemplate/PrintOptionsForm.vue
Normal file
@ -0,0 +1,115 @@
|
||||
<template>
|
||||
<div class="print-options-form" :class="{ 'print-options-form--two-col': columns === 2 }">
|
||||
<div class="print-options-title">打印参数</div>
|
||||
<div class="print-options-grid">
|
||||
<div class="print-options-field">
|
||||
<label>纸张</label>
|
||||
<a-select v-model="form.paperPreset" :options="paperOptions" size="small" />
|
||||
</div>
|
||||
<div class="print-options-field">
|
||||
<label>份数</label>
|
||||
<a-input-number v-model="form.copies" size="small" :min="1" :max="99" />
|
||||
</div>
|
||||
</div>
|
||||
<button type="button" class="print-options-advanced-toggle" @click="advancedOpen = !advancedOpen">
|
||||
{{ advancedOpen ? '收起高级设置' : '高级设置' }}
|
||||
</button>
|
||||
<div v-show="advancedOpen" class="print-options-grid print-options-grid--advanced">
|
||||
<template v-if="form.paperPreset === 'custom'">
|
||||
<div class="print-options-field">
|
||||
<label>宽(mm)</label>
|
||||
<a-input-number v-model="form.customWidthMm" size="small" :min="10" :max="500" />
|
||||
</div>
|
||||
<div class="print-options-field">
|
||||
<label>高(mm)</label>
|
||||
<a-input-number v-model="form.customHeightMm" size="small" :min="10" :max="500" />
|
||||
</div>
|
||||
</template>
|
||||
<div class="print-options-field">
|
||||
<label>横向</label>
|
||||
<a-switch v-model="form.landscape" size="small" />
|
||||
</div>
|
||||
<div class="print-options-field">
|
||||
<label title="100 表示原尺寸">缩放</label>
|
||||
<a-input-number v-model="form.scaleFactor" size="small" :min="10" :max="200" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import type { HiprintPrintForm } from '@/utils/hiprint/hiprintPrintOptions';
|
||||
|
||||
withDefaults(
|
||||
defineProps<{
|
||||
paperOptions: { value: string; label: string }[];
|
||||
/** 1=侧栏单列;2=批量顶栏双列 */
|
||||
columns?: 1 | 2;
|
||||
}>(),
|
||||
{
|
||||
columns: 1,
|
||||
},
|
||||
);
|
||||
|
||||
const form = defineModel<HiprintPrintForm>({ required: true });
|
||||
const advancedOpen = defineModel<boolean>('advancedOpen', { default: false });
|
||||
</script>
|
||||
|
||||
<style scoped lang="less">
|
||||
.print-options-form {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.print-options-title {
|
||||
font-size: 12px;
|
||||
color: var(--color-text-2);
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.print-options-grid {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.print-options-form--two-col .print-options-grid {
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
column-gap: 24px;
|
||||
row-gap: 8px;
|
||||
}
|
||||
|
||||
.print-options-field {
|
||||
display: grid;
|
||||
grid-template-columns: 56px minmax(0, 1fr);
|
||||
gap: 8px;
|
||||
align-items: center;
|
||||
min-width: 0;
|
||||
|
||||
> label {
|
||||
font-size: 12px;
|
||||
color: var(--color-text-2);
|
||||
}
|
||||
|
||||
:deep(.arco-switch) {
|
||||
justify-self: start;
|
||||
width: 34px;
|
||||
min-width: 34px;
|
||||
}
|
||||
}
|
||||
|
||||
.print-options-advanced-toggle {
|
||||
align-self: flex-start;
|
||||
padding: 0;
|
||||
border: none;
|
||||
background: none;
|
||||
font-size: 12px;
|
||||
color: var(--app-primary-color);
|
||||
cursor: pointer;
|
||||
|
||||
&:hover {
|
||||
opacity: 0.85;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
163
src/components/PrintTemplate/PrintPdfPreview.vue
Normal file
163
src/components/PrintTemplate/PrintPdfPreview.vue
Normal file
@ -0,0 +1,163 @@
|
||||
<template>
|
||||
<div ref="rootRef" class="print-pdf-preview" :class="{ 'is-rendered': rendered }">
|
||||
<div v-if="!rendered" class="print-pdf-preview__placeholder" aria-hidden="true">
|
||||
<div class="print-pdf-preview__placeholder-sheet" />
|
||||
</div>
|
||||
<VuePdfEmbed
|
||||
v-if="ready && pdfSource"
|
||||
:key="renderKey"
|
||||
:source="pdfSource"
|
||||
:width="pageWidth"
|
||||
class="print-pdf-preview__embed"
|
||||
@loading-failed="onLoadingFailed"
|
||||
@rendered="onRendered"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { nextTick, onBeforeUnmount, onMounted, ref, watch } from 'vue';
|
||||
import { Message } from '@arco-design/web-vue';
|
||||
import VuePdfEmbed, { GlobalWorkerOptions } from 'vue-pdf-embed/dist/index.essential.mjs';
|
||||
import PdfWorker from 'pdfjs-dist/legacy/build/pdf.worker.min.mjs?url';
|
||||
|
||||
GlobalWorkerOptions.workerSrc = PdfWorker;
|
||||
|
||||
const props = defineProps<{
|
||||
source: string | Uint8Array | null;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'rendered'): void;
|
||||
(e: 'loading-failed', error: unknown): void;
|
||||
}>();
|
||||
|
||||
const DEFAULT_WIDTH = 480;
|
||||
const rootRef = ref<HTMLElement>();
|
||||
const pdfSource = ref<string | Uint8Array | null>(null);
|
||||
const pageWidth = ref(DEFAULT_WIDTH);
|
||||
const renderKey = ref(0);
|
||||
const ready = ref(false);
|
||||
const rendered = ref(false);
|
||||
let resizeObserver: ResizeObserver | null = null;
|
||||
|
||||
function syncPageWidth() {
|
||||
const containerWidth = rootRef.value?.clientWidth ?? 0;
|
||||
pageWidth.value = containerWidth > 0 ? Math.min(520, Math.floor(containerWidth - 24)) : DEFAULT_WIDTH;
|
||||
}
|
||||
|
||||
async function syncSource() {
|
||||
ready.value = false;
|
||||
rendered.value = false;
|
||||
const next = props.source;
|
||||
pdfSource.value =
|
||||
typeof next === 'string'
|
||||
? next.trim() || null
|
||||
: next && next.byteLength > 0
|
||||
? next
|
||||
: null;
|
||||
if (!pdfSource.value) {
|
||||
emit('rendered');
|
||||
return;
|
||||
}
|
||||
renderKey.value += 1;
|
||||
await nextTick();
|
||||
requestAnimationFrame(() => {
|
||||
syncPageWidth();
|
||||
ready.value = true;
|
||||
});
|
||||
}
|
||||
|
||||
function onRendered() {
|
||||
rendered.value = true;
|
||||
emit('rendered');
|
||||
}
|
||||
|
||||
function onLoadingFailed(error: unknown) {
|
||||
rendered.value = true;
|
||||
emit('loading-failed', error);
|
||||
Message.warning('PDF 解析失败,请尝试新标签打开');
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
syncPageWidth();
|
||||
if (rootRef.value && typeof ResizeObserver !== 'undefined') {
|
||||
resizeObserver = new ResizeObserver(() => {
|
||||
syncPageWidth();
|
||||
});
|
||||
resizeObserver.observe(rootRef.value);
|
||||
}
|
||||
void syncSource();
|
||||
});
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
resizeObserver?.disconnect();
|
||||
resizeObserver = null;
|
||||
});
|
||||
|
||||
watch(
|
||||
() => props.source,
|
||||
() => {
|
||||
void syncSource();
|
||||
},
|
||||
);
|
||||
</script>
|
||||
|
||||
<style scoped lang="less">
|
||||
.print-pdf-preview {
|
||||
position: relative;
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
overflow: auto;
|
||||
background: var(--color-fill-1);
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
padding: 12px;
|
||||
}
|
||||
|
||||
.print-pdf-preview__placeholder {
|
||||
position: absolute;
|
||||
inset: 12px;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.print-pdf-preview__placeholder-sheet {
|
||||
width: min(280px, 100%);
|
||||
height: 100%;
|
||||
max-height: 420px;
|
||||
border-radius: 10px;
|
||||
border: 1px solid var(--color-border-2);
|
||||
background: linear-gradient(90deg, var(--color-fill-3) 25%, var(--color-fill-2) 50%, var(--color-fill-3) 75%);
|
||||
background-size: 200% 100%;
|
||||
animation: print-pdf-shimmer 1.2s ease-in-out infinite;
|
||||
}
|
||||
|
||||
.print-pdf-preview__embed {
|
||||
width: 100%;
|
||||
max-width: 520px;
|
||||
opacity: 0;
|
||||
transform: translateY(4px);
|
||||
transition: opacity 0.24s ease, transform 0.24s ease;
|
||||
}
|
||||
|
||||
.print-pdf-preview.is-rendered .print-pdf-preview__embed {
|
||||
opacity: 1;
|
||||
transform: translateY(0);
|
||||
}
|
||||
|
||||
.print-pdf-preview.is-rendered .print-pdf-preview__placeholder {
|
||||
opacity: 0;
|
||||
transition: opacity 0.18s ease;
|
||||
}
|
||||
|
||||
@keyframes print-pdf-shimmer {
|
||||
0% {
|
||||
background-position: 200% 0;
|
||||
}
|
||||
100% {
|
||||
background-position: -200% 0;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
263
src/components/PrintTemplate/PrintPreviewPane.vue
Normal file
263
src/components/PrintTemplate/PrintPreviewPane.vue
Normal file
@ -0,0 +1,263 @@
|
||||
<template>
|
||||
<section class="print-preview-panel">
|
||||
<div class="print-preview-toolbar">
|
||||
<div class="print-preview-toolbar-left">
|
||||
<span class="print-preview-title">面单预览</span>
|
||||
<span v-if="subtitle" class="print-preview-subtitle">{{ subtitle }}</span>
|
||||
<span v-if="indexLabel" class="print-preview-index">{{ indexLabel }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="print-preview-stage">
|
||||
<Transition name="print-preview-fade" mode="out-in">
|
||||
<div v-if="showBlockingLoader" key="loading" class="print-preview-loading">
|
||||
<div class="print-preview-skeleton" aria-hidden="true">
|
||||
<div class="print-preview-skeleton-bar short" />
|
||||
<div class="print-preview-skeleton-sheet" />
|
||||
<div class="print-preview-skeleton-bar" />
|
||||
<div class="print-preview-skeleton-bar medium" />
|
||||
</div>
|
||||
<p class="print-preview-loading-tip">{{ loadingTip }}</p>
|
||||
</div>
|
||||
|
||||
<div v-else-if="error" key="error" class="print-preview-error">
|
||||
<a-empty :description="error">
|
||||
<a-button size="small" type="primary" @click="emit('retry')">重试</a-button>
|
||||
</a-empty>
|
||||
</div>
|
||||
|
||||
<div v-else-if="pdfSource || htmlSrc" key="content" class="print-preview-content">
|
||||
<PrintPdfPreview
|
||||
v-if="pdfSource"
|
||||
:source="pdfSource"
|
||||
@loading-failed="emit('loading-failed', $event)"
|
||||
@rendered="emit('rendered')"
|
||||
/>
|
||||
<iframe
|
||||
v-else
|
||||
class="print-preview-frame"
|
||||
title="面单预览"
|
||||
:src="htmlSrc"
|
||||
@load="emit('rendered')"
|
||||
/>
|
||||
<div v-if="switching" class="print-preview-switch-mask">
|
||||
<a-spin dot />
|
||||
<span>切换中…</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-else key="empty" class="print-preview-empty">
|
||||
<a-empty description="暂无可预览打印内容" />
|
||||
</div>
|
||||
</Transition>
|
||||
</div>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue';
|
||||
import PrintPdfPreview from '@/components/PrintTemplate/PrintPdfPreview.vue';
|
||||
|
||||
const props = defineProps<{
|
||||
preparing?: boolean;
|
||||
loading?: boolean;
|
||||
rendering?: boolean;
|
||||
switching?: boolean;
|
||||
error?: string;
|
||||
pdfSource?: string | Uint8Array | null;
|
||||
htmlSrc?: string;
|
||||
subtitle?: string;
|
||||
indexLabel?: string;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'retry'): void;
|
||||
(e: 'loading-failed', error: unknown): void;
|
||||
(e: 'rendered'): void;
|
||||
}>();
|
||||
|
||||
const showBlockingLoader = computed(() => {
|
||||
if (props.preparing) return true;
|
||||
if (props.loading) return true;
|
||||
if (props.rendering && !props.pdfSource && !props.htmlSrc) return true;
|
||||
return false;
|
||||
});
|
||||
|
||||
const loadingTip = computed(() => {
|
||||
if (props.preparing) return '正在获取面单…';
|
||||
if (props.rendering) return '正在渲染面单…';
|
||||
return '正在加载面单…';
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped lang="less">
|
||||
.print-preview-panel {
|
||||
min-height: 0;
|
||||
height: 100%;
|
||||
border: 1px solid var(--color-border-2);
|
||||
border-radius: 10px;
|
||||
overflow: hidden;
|
||||
background: var(--app-card-bg);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.print-preview-toolbar {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 10px 12px;
|
||||
border-bottom: 1px solid var(--color-border-2);
|
||||
background: var(--color-fill-2);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.print-preview-toolbar-left {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
min-width: 0;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.print-preview-title {
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
color: var(--color-text-2);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.print-preview-subtitle {
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
color: var(--color-text-1);
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.print-preview-index {
|
||||
font-size: 12px;
|
||||
color: var(--color-text-3);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.print-preview-stage {
|
||||
position: relative;
|
||||
flex: 1;
|
||||
min-height: 420px;
|
||||
overflow: hidden;
|
||||
background: var(--color-fill-1);
|
||||
}
|
||||
|
||||
.print-preview-loading,
|
||||
.print-preview-error,
|
||||
.print-preview-empty {
|
||||
height: 100%;
|
||||
min-height: 420px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 16px;
|
||||
padding: 24px;
|
||||
}
|
||||
|
||||
.print-preview-loading-tip {
|
||||
margin: 0;
|
||||
font-size: 13px;
|
||||
color: var(--color-text-3);
|
||||
}
|
||||
|
||||
.print-preview-skeleton {
|
||||
width: min(280px, 72%);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.print-preview-skeleton-bar {
|
||||
height: 10px;
|
||||
border-radius: 6px;
|
||||
background: linear-gradient(90deg, var(--color-fill-3) 25%, var(--color-fill-2) 50%, var(--color-fill-3) 75%);
|
||||
background-size: 200% 100%;
|
||||
animation: print-skeleton-shimmer 1.2s ease-in-out infinite;
|
||||
|
||||
&.short {
|
||||
width: 42%;
|
||||
}
|
||||
|
||||
&.medium {
|
||||
width: 68%;
|
||||
}
|
||||
}
|
||||
|
||||
.print-preview-skeleton-sheet {
|
||||
width: 100%;
|
||||
aspect-ratio: 2 / 3;
|
||||
border-radius: 10px;
|
||||
border: 1px solid var(--color-border-2);
|
||||
background: linear-gradient(90deg, var(--color-fill-3) 25%, var(--color-fill-2) 50%, var(--color-fill-3) 75%);
|
||||
background-size: 200% 100%;
|
||||
animation: print-skeleton-shimmer 1.2s ease-in-out infinite;
|
||||
}
|
||||
|
||||
@keyframes print-skeleton-shimmer {
|
||||
0% {
|
||||
background-position: 200% 0;
|
||||
}
|
||||
100% {
|
||||
background-position: -200% 0;
|
||||
}
|
||||
}
|
||||
|
||||
.print-preview-content {
|
||||
position: relative;
|
||||
height: 100%;
|
||||
min-height: 420px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.print-preview-frame {
|
||||
width: 100%;
|
||||
flex: 1;
|
||||
min-height: 420px;
|
||||
border: none;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.print-preview-switch-mask {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 10px;
|
||||
background: rgba(255, 255, 255, 0.72);
|
||||
backdrop-filter: blur(2px);
|
||||
color: var(--color-text-2);
|
||||
font-size: 13px;
|
||||
z-index: 2;
|
||||
animation: print-mask-in 0.18s ease;
|
||||
}
|
||||
|
||||
.print-preview-fade-enter-active,
|
||||
.print-preview-fade-leave-active {
|
||||
transition: opacity 0.22s ease, transform 0.22s ease;
|
||||
}
|
||||
|
||||
.print-preview-fade-enter-from,
|
||||
.print-preview-fade-leave-to {
|
||||
opacity: 0;
|
||||
transform: translateY(6px);
|
||||
}
|
||||
|
||||
@keyframes print-mask-in {
|
||||
from {
|
||||
opacity: 0;
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@ -194,63 +194,40 @@
|
||||
);
|
||||
};
|
||||
|
||||
async function reloadActiveTab(itemData: TagProps, index: number) {
|
||||
tabBarStore.deleteCache(itemData);
|
||||
|
||||
setTimeout(() => {
|
||||
pub('page:refresh', {
|
||||
routeName: itemData.name,
|
||||
fullPath: itemData.fullPath,
|
||||
});
|
||||
}, 100);
|
||||
|
||||
tabBarStore.bumpRouteRefresh(itemData.name);
|
||||
await nextTick();
|
||||
|
||||
const currentTags = tabBarStore.getTabList;
|
||||
const duplicateIndex = currentTags.findIndex(
|
||||
(tag, idx) => tag.name === itemData.name && idx !== index,
|
||||
);
|
||||
if (duplicateIndex !== -1) {
|
||||
tabBarStore.deleteTag(duplicateIndex, currentTags[duplicateIndex]);
|
||||
}
|
||||
|
||||
setTimeout(() => {
|
||||
if (!itemData.ignoreCache) {
|
||||
tabBarStore.addCache(itemData.name);
|
||||
}
|
||||
}, 50);
|
||||
}
|
||||
|
||||
// 刷新当前标签页
|
||||
const handleRefresh = async (e: Event) => {
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
if (!isActive.value) return;
|
||||
|
||||
tabBarStore.deleteCache(props.itemData);
|
||||
|
||||
setTimeout(() => {
|
||||
pub('page:refresh', {
|
||||
routeName: props.itemData.name,
|
||||
fullPath: props.itemData.fullPath,
|
||||
});
|
||||
}, 100);
|
||||
|
||||
requestAnimationFrame(async () => {
|
||||
await router.replace({
|
||||
name: props.itemData.name,
|
||||
query: {
|
||||
...props.itemData.query,
|
||||
_r: Date.now(),
|
||||
},
|
||||
});
|
||||
|
||||
requestAnimationFrame(async () => {
|
||||
const cleanQuery = { ...(props.itemData.query || {}) } as Record<
|
||||
string,
|
||||
unknown
|
||||
>;
|
||||
delete cleanQuery._r;
|
||||
delete cleanQuery._refresh;
|
||||
await router.replace({
|
||||
name: props.itemData.name,
|
||||
query:
|
||||
Object.keys(cleanQuery).length > 0
|
||||
? (cleanQuery as any)
|
||||
: undefined,
|
||||
});
|
||||
|
||||
await nextTick();
|
||||
|
||||
const currentTags = tabBarStore.getTabList;
|
||||
const duplicateIndex = currentTags.findIndex(
|
||||
(tag, idx) =>
|
||||
tag.name === props.itemData.name && idx !== props.index,
|
||||
);
|
||||
if (duplicateIndex !== -1) {
|
||||
tabBarStore.deleteTag(duplicateIndex, currentTags[duplicateIndex]);
|
||||
}
|
||||
|
||||
setTimeout(() => {
|
||||
if (!props.itemData.ignoreCache) {
|
||||
tabBarStore.addCache(props.itemData.name);
|
||||
}
|
||||
}, 50);
|
||||
});
|
||||
});
|
||||
await reloadActiveTab(props.itemData, props.index);
|
||||
};
|
||||
|
||||
const actionSelect = async (value: any) => {
|
||||
@ -281,64 +258,7 @@
|
||||
tabBarStore.freshTabList(filterList);
|
||||
router.push({ name: itemData.name });
|
||||
} else if (value === Eaction.reload) {
|
||||
// 1. 删除缓存,确保组件不会被 keep-alive 缓存
|
||||
tabBarStore.deleteCache(itemData);
|
||||
|
||||
// 2. 发送刷新事件,让页面组件重新加载数据
|
||||
// 延迟发送,确保组件重新挂载后能收到事件
|
||||
setTimeout(() => {
|
||||
pub('page:refresh', {
|
||||
routeName: itemData.name,
|
||||
fullPath: itemData.fullPath,
|
||||
});
|
||||
}, 100);
|
||||
|
||||
// 3. 使用 requestAnimationFrame 确保操作在同一帧内完成
|
||||
requestAnimationFrame(async () => {
|
||||
// 4. 通过临时添加 query 参数来改变路由 key,触发组件重新挂载
|
||||
const refreshRoute = {
|
||||
...itemData,
|
||||
query: {
|
||||
...itemData.query,
|
||||
_r: Date.now(), // 使用短参数名,减少 URL 变化
|
||||
},
|
||||
};
|
||||
|
||||
// 5. 添加临时参数触发重新挂载
|
||||
await router.replace(refreshRoute);
|
||||
|
||||
// 6. 立即移除参数(使用 requestAnimationFrame 确保在同一帧内完成)
|
||||
requestAnimationFrame(async () => {
|
||||
const originalRoute = { ...itemData };
|
||||
if (!originalRoute.query) {
|
||||
originalRoute.query = {};
|
||||
}
|
||||
const { _r, ...cleanQuery } = originalRoute.query as any;
|
||||
await router.replace({
|
||||
...originalRoute,
|
||||
query: Object.keys(cleanQuery).length > 0 ? cleanQuery : undefined,
|
||||
});
|
||||
|
||||
// 7. 等待组件重新挂载完成
|
||||
await nextTick();
|
||||
|
||||
// 8. 检查并移除可能重复的标签
|
||||
const currentTags = tabBarStore.getTabList;
|
||||
const duplicateIndex = currentTags.findIndex(
|
||||
(tag, idx) => tag.name === itemData.name && idx !== index
|
||||
);
|
||||
if (duplicateIndex !== -1) {
|
||||
tabBarStore.deleteTag(duplicateIndex, currentTags[duplicateIndex]);
|
||||
}
|
||||
|
||||
// 9. 延迟重新添加缓存,确保组件已完全加载
|
||||
setTimeout(() => {
|
||||
if (!itemData.ignoreCache) {
|
||||
tabBarStore.addCache(itemData.name);
|
||||
}
|
||||
}, 50);
|
||||
});
|
||||
});
|
||||
await reloadActiveTab(itemData, index);
|
||||
} else {
|
||||
tabBarStore.resetTabList();
|
||||
router.push({ name: DEFAULT_ROUTE_NAME });
|
||||
|
||||
@ -1,10 +1,11 @@
|
||||
import { ref } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { Message } from '@arco-design/web-vue'
|
||||
import { resolveOmsAssetUrl } from '@/api/oms/common'
|
||||
import { printLabelPrint, printLabelTemplateList } from '@/api/operation'
|
||||
import { dispatchPrintUrl } from '@/utils/hiprint/dispatchPrintUrl'
|
||||
import { prefetchPrintPreview } from '@/utils/printSessionCache'
|
||||
|
||||
/** 运营页内打印面单(不跳转打印标签页)。 */
|
||||
/** 运营页内打印面单(hiprint 静默,不跳转页面)。 */
|
||||
export function useOperationLabelPrint(pageKey = 'operationPrint') {
|
||||
const { t } = useI18n()
|
||||
const printing = ref(false)
|
||||
@ -28,24 +29,42 @@ export function useOperationLabelPrint(pageKey = 'operationPrint') {
|
||||
}
|
||||
}
|
||||
|
||||
async function printWaybill(serviceNo: string, silent = false) {
|
||||
const number = String(serviceNo || '').trim()
|
||||
if (!number) {
|
||||
if (!silent) Message.warning(t('operation.fulfillPack.message.printNoWaybill'))
|
||||
async function printByNumber(
|
||||
number: string,
|
||||
numberType = 'waybill',
|
||||
options?: { silent?: boolean; labelTemplateId?: number },
|
||||
) {
|
||||
const no = String(number || '').trim()
|
||||
if (!no) {
|
||||
if (!options?.silent) {
|
||||
Message.warning(t('operation.fulfillPack.message.printNoWaybill'))
|
||||
}
|
||||
return false
|
||||
}
|
||||
const result = await printLabelPrint({
|
||||
number,
|
||||
numberType: 'waybill',
|
||||
labelTemplateId: labelTemplateId.value,
|
||||
number: no,
|
||||
numberType,
|
||||
labelTemplateId: options?.labelTemplateId ?? labelTemplateId.value,
|
||||
})
|
||||
const printUrl = (result as any)?.printUrl ?? (result as any)?.PrintUrl
|
||||
if (printUrl) {
|
||||
window.open(resolveOmsAssetUrl(String(printUrl)), '_blank')
|
||||
if (!printUrl) {
|
||||
if (!options?.silent) Message.warning(t('operation.printLabel.message.noPrintFile'))
|
||||
return false
|
||||
}
|
||||
void prefetchPrintPreview(String(printUrl))
|
||||
await dispatchPrintUrl(String(printUrl))
|
||||
return true
|
||||
}
|
||||
|
||||
async function printWaybill(serviceNo: string, silent = false) {
|
||||
try {
|
||||
return await printByNumber(serviceNo, 'waybill', { silent })
|
||||
} catch (e: any) {
|
||||
if (!silent) Message.error(e?.message || t('operation.printLabel.message.printFailed'))
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
async function batchPrintWaybills(serviceNos: string[]) {
|
||||
const list = [...new Set(serviceNos.map((s) => String(s || '').trim()).filter(Boolean))]
|
||||
if (!list.length) {
|
||||
@ -84,6 +103,7 @@ export function useOperationLabelPrint(pageKey = 'operationPrint') {
|
||||
labelTemplateId,
|
||||
labelTemplateOptions,
|
||||
loadLabelTemplates,
|
||||
printByNumber,
|
||||
printWaybill,
|
||||
batchPrintWaybills,
|
||||
}
|
||||
|
||||
12
src/env.d.ts
vendored
12
src/env.d.ts
vendored
@ -28,6 +28,18 @@ declare module '*.vue' {
|
||||
export default component;
|
||||
}
|
||||
|
||||
declare module 'vue-pdf-embed/dist/index.essential.mjs' {
|
||||
import type { DefineComponent } from 'vue';
|
||||
export const GlobalWorkerOptions: { workerSrc: string };
|
||||
const VuePdfEmbed: DefineComponent<Record<string, unknown>, {}, any>;
|
||||
export default VuePdfEmbed;
|
||||
}
|
||||
|
||||
declare module 'pdfjs-dist/build/pdf.worker.min.mjs?url' {
|
||||
const url: string;
|
||||
export default url;
|
||||
}
|
||||
|
||||
interface ImportMetaEnv {
|
||||
readonly VITE_API_BASE_URL: string;
|
||||
readonly VITE_OMS_URL?: string;
|
||||
|
||||
@ -24,8 +24,15 @@
|
||||
const cacheList = computed(() => tabBarStore.getCacheList);
|
||||
const keepAliveMax = MAX_KEEP_ALIVE_TABS;
|
||||
|
||||
/** 与 keep-alive include(组件 name)对齐,避免 name 未就绪时退回 path 导致 key 抖动、页面重复挂载 */
|
||||
function resolveRouteCacheKey(routeLoc: RouteLocationNormalized) {
|
||||
const matchedName = routeLoc.matched.at(-1)?.name ?? routeLoc.name;
|
||||
if (matchedName) return String(matchedName);
|
||||
return (routeLoc.path || '/').split('?')[0];
|
||||
}
|
||||
|
||||
watch(
|
||||
() => String(route.name || route.path),
|
||||
() => resolveRouteCacheKey(route),
|
||||
(name) => {
|
||||
if (!name || route.meta?.ignoreCache) return;
|
||||
tabBarStore.touchCache(name);
|
||||
@ -34,12 +41,16 @@
|
||||
);
|
||||
|
||||
function getComponentKey(routeLoc: RouteLocationNormalized) {
|
||||
const name = String(routeLoc.name || routeLoc.path);
|
||||
const baseKey = resolveRouteCacheKey(routeLoc);
|
||||
const refreshToken = routeLoc.query._r ?? routeLoc.query._refresh;
|
||||
if (refreshToken != null && String(refreshToken) !== '') {
|
||||
return `${name}__${refreshToken}`;
|
||||
return `${baseKey}__${refreshToken}`;
|
||||
}
|
||||
return name;
|
||||
const refreshTick = tabBarStore.routeRefreshTicks[baseKey] || 0;
|
||||
if (refreshTick > 0) {
|
||||
return `${baseKey}__rt${refreshTick}`;
|
||||
}
|
||||
return baseKey;
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@ -158,18 +158,26 @@ export default {
|
||||
'warehouse.sku.table.remark': 'Remark',
|
||||
'warehouse.sku.search.keyword': 'Code / Name',
|
||||
'warehouse.sku.tip': 'Manage warehouse SKUs. Check available stock on My Inventory.',
|
||||
'warehouse.sku.form.skuCode': 'SKU Code',
|
||||
'warehouse.sku.form.skuName': 'SKU Name',
|
||||
'warehouse.sku.form.skuCode': 'Code',
|
||||
'warehouse.sku.form.skuCodePlaceholder': 'Letters/numbers only',
|
||||
'warehouse.sku.form.skuName': 'Name',
|
||||
'warehouse.sku.form.skuNamePlaceholder': 'Product name',
|
||||
'warehouse.sku.form.unitPrice': 'Unit Price',
|
||||
'warehouse.sku.form.skuNameEn': 'SKU Name (EN)',
|
||||
'warehouse.sku.form.exHsCode': 'Export HSCode',
|
||||
'warehouse.sku.form.imHsCode': 'Import HSCode',
|
||||
'warehouse.sku.form.unitPricePlaceholder': 'Optional',
|
||||
'warehouse.sku.form.skuNameEn': 'EN Name',
|
||||
'warehouse.sku.form.skuNameEnPlaceholder': 'English name (optional)',
|
||||
'warehouse.sku.form.exHsCode': 'Export HS',
|
||||
'warehouse.sku.form.exHsCodePlaceholder': 'Export HS code (optional)',
|
||||
'warehouse.sku.form.imHsCode': 'Import HS',
|
||||
'warehouse.sku.form.imHsCodePlaceholder': 'Import HS code (optional)',
|
||||
'warehouse.sku.form.showExtra': 'Show more fields',
|
||||
'warehouse.sku.form.hideExtra': 'Hide extra fields',
|
||||
'warehouse.modal.section.declarationExtra': 'Declaration extras',
|
||||
'warehouse.sku.form.weightG': 'Weight(g)',
|
||||
'warehouse.sku.form.weightG': 'Weight',
|
||||
'warehouse.sku.form.weightPlaceholder': 'Optional',
|
||||
'warehouse.sku.form.remark': 'Remark',
|
||||
'warehouse.sku.form.imageUrl': 'SKU image',
|
||||
'warehouse.sku.form.remarkPlaceholder': 'Optional',
|
||||
'warehouse.sku.form.imageUrl': 'Image',
|
||||
'warehouse.sku.form.uploadImage': 'Upload image',
|
||||
'warehouse.sku.form.reuploadImage': 'Replace image',
|
||||
'warehouse.sku.form.clearImage': 'Clear image',
|
||||
@ -296,18 +304,25 @@ export default {
|
||||
'warehouse.parcel.table.remark': 'Remark',
|
||||
'warehouse.parcel.search.trackingNo': 'Tracking No',
|
||||
'warehouse.parcel.form.trackingNo': 'Tracking No',
|
||||
'warehouse.parcel.form.trackingNoPlaceholder': 'Scan or enter tracking number',
|
||||
'warehouse.parcel.form.carrierName': 'Carrier',
|
||||
'warehouse.parcel.form.carrierNamePlaceholder': 'e.g. SF, UPS (optional)',
|
||||
'warehouse.parcel.form.productName': 'Product',
|
||||
'warehouse.parcel.form.productNamePlaceholder': 'Required; a new row is added after fill',
|
||||
'warehouse.parcel.form.image': 'Image',
|
||||
'warehouse.parcel.form.uploadImage': 'Upload',
|
||||
'warehouse.parcel.form.reuploadImage': 'Re-upload',
|
||||
'warehouse.parcel.form.clearImage': 'Clear',
|
||||
'warehouse.parcel.form.attribute': 'Attributes',
|
||||
'warehouse.parcel.form.attributePlaceholder': 'Color/size etc. (optional)',
|
||||
'warehouse.parcel.form.quantity': 'Qty',
|
||||
'warehouse.parcel.form.remark': 'Remark',
|
||||
'warehouse.parcel.form.remarkPlaceholder': 'Parcel remark (optional)',
|
||||
'warehouse.parcel.form.itemRemark': 'Item remark',
|
||||
'warehouse.parcel.form.itemRemarkPlaceholder': 'Optional',
|
||||
'warehouse.parcel.form.currentWarehouse': 'Current warehouse',
|
||||
'warehouse.parcel.form.autoAddRow': 'A new row is added after you fill product name',
|
||||
'warehouse.parcel.form.itemFilledCount': '{n} filled',
|
||||
'warehouse.parcel.modal.add': 'Add Parcel',
|
||||
'warehouse.parcel.actions.delete': 'Delete Parcel',
|
||||
'warehouse.parcel.message.loadFailed': 'Failed to load parcels',
|
||||
@ -363,21 +378,29 @@ export default {
|
||||
'warehouse.inbound.tip': 'Forecast inbound goods. Stock increases after receive & putaway. Status: Forecasted → Received → Completed.',
|
||||
'warehouse.inbound.form.markReference': 'Mark Ref',
|
||||
'warehouse.inbound.form.markBoxNo': 'Box No',
|
||||
'warehouse.inbound.form.markBoxNoPlaceholder': 'Box mark (optional)',
|
||||
'warehouse.inbound.form.sku': 'SKU',
|
||||
'warehouse.inbound.form.plannedQty': 'Planned Qty',
|
||||
'warehouse.inbound.form.markPlaceholder': 'Usually the tracking number',
|
||||
'warehouse.inbound.form.remarkPlaceholder': 'Optional',
|
||||
'warehouse.inbound.form.optional': 'Optional',
|
||||
'warehouse.inbound.form.boxSkuDetail': 'Boxes & SKU lines',
|
||||
'warehouse.inbound.form.boxCount': 'Boxes {n}',
|
||||
'warehouse.inbound.form.skuCount': 'SKU {n}',
|
||||
'warehouse.inbound.form.totalQty': 'Total qty {n}',
|
||||
'warehouse.inbound.form.boxWeight': 'Weight/g',
|
||||
'warehouse.inbound.form.summaryMeta': '{box} boxes · {sku} SKU · qty {qty}',
|
||||
'warehouse.inbound.form.boxTabWithSku': 'Box {n} · {sku}',
|
||||
'warehouse.inbound.form.boxWeight': 'Weight',
|
||||
'warehouse.inbound.form.boxSize': 'Size',
|
||||
'warehouse.inbound.form.boxLength': 'L/cm',
|
||||
'warehouse.inbound.form.boxWidth': 'W/cm',
|
||||
'warehouse.inbound.form.boxHeight': 'H/cm',
|
||||
'warehouse.inbound.form.selectSku': 'Select SKU',
|
||||
'warehouse.inbound.form.autoAddSkuRow': 'A new row is added after you select a SKU',
|
||||
'warehouse.inbound.actions.addBox': 'Add box',
|
||||
'warehouse.inbound.actions.addBox5': 'Add 5 boxes',
|
||||
'warehouse.inbound.actions.removeBox': 'Remove boxes',
|
||||
'warehouse.inbound.actions.removeCurrentBox': 'Remove current box',
|
||||
'warehouse.inbound.actions.addSku': 'Add SKU line',
|
||||
'warehouse.inbound.modal.add': 'Add Inbound',
|
||||
'warehouse.inbound.drawer.detail': 'Inbound Detail',
|
||||
@ -396,6 +419,7 @@ export default {
|
||||
'warehouse.inbound.message.deleteSuccess': 'Deleted',
|
||||
'warehouse.inbound.message.required': 'Select warehouse',
|
||||
'warehouse.inbound.message.boxRequired': 'Add SKU lines to at least one box',
|
||||
'warehouse.inbound.message.keepOneBox': 'Keep at least one box',
|
||||
'warehouse.inbound.message.detailFailed': 'Failed to load detail',
|
||||
'warehouse.inbound.message.receiveBinRequired': 'Bin is required when received qty > 0',
|
||||
'warehouse.inbound.message.receiveQtyInvalid': 'Received qty cannot be negative',
|
||||
@ -3358,7 +3382,7 @@ export default {
|
||||
// Operation Module - Print Label
|
||||
'operation.printLabel.pageTitle': 'Print Label',
|
||||
'operation.printLabel.broadcastSettings': 'Broadcast Settings',
|
||||
'operation.printLabel.tip': 'Scan any number to load the order and bound goods. Verify qty before printing to avoid wrong/missing shipments.',
|
||||
'operation.printLabel.tip': 'Scan to print automatically. Ensure the top-bar printer is connected.',
|
||||
'operation.printLabel.scan.title': 'Scan & print',
|
||||
'operation.fulfillPack.scan.title': 'Scan lookup',
|
||||
'operation.fulfillPack.scan.placeholder': 'Scan domestic tracking / waybill / SKU',
|
||||
@ -3424,8 +3448,11 @@ export default {
|
||||
'operation.printLabel.labelTemplate.inbound': 'Inbound Label',
|
||||
'operation.printLabel.labelTemplate.outbound': 'Outbound Label',
|
||||
'operation.printLabel.labelTemplate.sku': 'SKU Label',
|
||||
'operation.printLabel.preview.title': 'Verify before print',
|
||||
'operation.printLabel.preview.empty': 'Scan a number to show order and bound goods',
|
||||
'operation.printLabel.preview.title': 'Label preview',
|
||||
'operation.printLabel.preview.empty': 'Scan a number to show order info; open Preview when needed',
|
||||
'operation.printLabel.preview.product': 'Product',
|
||||
'operation.printLabel.preview.country': 'Destination',
|
||||
'operation.printLabel.preview.status': 'Status',
|
||||
'operation.printLabel.preview.order': 'Order',
|
||||
'operation.printLabel.preview.bindSummary': '{lines} line(s) · {qty} pcs',
|
||||
'operation.printLabel.preview.lines': 'Lines',
|
||||
@ -3453,6 +3480,15 @@ export default {
|
||||
'operation.printLabel.message.lookupSuccess': 'Order found — verify bound goods',
|
||||
'operation.printLabel.message.lookupFirst': 'Lookup and verify the order first',
|
||||
'operation.printLabel.message.printSuccess': 'Print successful',
|
||||
'operation.printLabel.message.printFailed': 'Print failed',
|
||||
'operation.printLabel.message.noPrintFile': 'No print file returned',
|
||||
'operation.printLabel.scan.autoHint': 'Scan to lookup and print automatically',
|
||||
'operation.printLabel.printerStatus.ready': 'Local printer ready',
|
||||
'operation.printLabel.printerStatus.off': 'Printer not connected — enable Print in the top bar',
|
||||
'operation.printLabel.actions.reprint': 'Print again',
|
||||
'operation.printLabel.actions.printBtn': 'Print',
|
||||
'operation.printLabel.actions.preview': 'Preview',
|
||||
'operation.printLabel.actions.previewHint': 'Tap to view label',
|
||||
'operation.printLabel.printSuccess.yes': 'Yes',
|
||||
'operation.printLabel.printSuccess.no': 'No',
|
||||
'operation.printLabel.pagination.invalidPage': 'Please enter a valid page number',
|
||||
|
||||
@ -159,18 +159,26 @@ export default {
|
||||
'warehouse.sku.table.remark': '备注',
|
||||
'warehouse.sku.search.keyword': '编码/名称',
|
||||
'warehouse.sku.tip': '维护库内 SKU 主数据;可用库存请在「我的库存」查看。',
|
||||
'warehouse.sku.form.skuCode': 'SKU 编码',
|
||||
'warehouse.sku.form.skuName': 'SKU 名称',
|
||||
'warehouse.sku.form.skuCode': '编码',
|
||||
'warehouse.sku.form.skuCodePlaceholder': '仅字母数字,不含中文',
|
||||
'warehouse.sku.form.skuName': '名称',
|
||||
'warehouse.sku.form.skuNamePlaceholder': '商品中文名称',
|
||||
'warehouse.sku.form.unitPrice': '单价',
|
||||
'warehouse.sku.form.skuNameEn': 'SKU 英文名称',
|
||||
'warehouse.sku.form.exHsCode': 'HSCode 出口',
|
||||
'warehouse.sku.form.imHsCode': 'HSCode 进口',
|
||||
'warehouse.sku.form.unitPricePlaceholder': '选填',
|
||||
'warehouse.sku.form.skuNameEn': '英文名称',
|
||||
'warehouse.sku.form.skuNameEnPlaceholder': '申报英文名(选填)',
|
||||
'warehouse.sku.form.exHsCode': '出口编码',
|
||||
'warehouse.sku.form.exHsCodePlaceholder': '出口海关编码(选填)',
|
||||
'warehouse.sku.form.imHsCode': '进口编码',
|
||||
'warehouse.sku.form.imHsCodePlaceholder': '进口海关编码(选填)',
|
||||
'warehouse.sku.form.showExtra': '显示更多字段',
|
||||
'warehouse.sku.form.hideExtra': '收起更多字段',
|
||||
'warehouse.modal.section.declarationExtra': '申报扩展信息',
|
||||
'warehouse.sku.form.weightG': '重量(g)',
|
||||
'warehouse.sku.form.weightG': '重量',
|
||||
'warehouse.sku.form.weightPlaceholder': '选填',
|
||||
'warehouse.sku.form.remark': '备注',
|
||||
'warehouse.sku.form.imageUrl': 'SKU 图片',
|
||||
'warehouse.sku.form.remarkPlaceholder': '选填',
|
||||
'warehouse.sku.form.imageUrl': '图片',
|
||||
'warehouse.sku.form.uploadImage': '上传图片',
|
||||
'warehouse.sku.form.reuploadImage': '重新上传',
|
||||
'warehouse.sku.form.clearImage': '清除图片',
|
||||
@ -297,18 +305,25 @@ export default {
|
||||
'warehouse.parcel.table.remark': '备注',
|
||||
'warehouse.parcel.search.trackingNo': '快递单号',
|
||||
'warehouse.parcel.form.trackingNo': '快递单号',
|
||||
'warehouse.parcel.form.trackingNoPlaceholder': '扫码或输入快递单号',
|
||||
'warehouse.parcel.form.carrierName': '快递公司',
|
||||
'warehouse.parcel.form.carrierNamePlaceholder': '如顺丰、UPS(选填)',
|
||||
'warehouse.parcel.form.productName': '商品名称',
|
||||
'warehouse.parcel.form.productNamePlaceholder': '必填,填写后自动新增下一行',
|
||||
'warehouse.parcel.form.image': '图片',
|
||||
'warehouse.parcel.form.uploadImage': '上传',
|
||||
'warehouse.parcel.form.reuploadImage': '重传',
|
||||
'warehouse.parcel.form.clearImage': '清除',
|
||||
'warehouse.parcel.form.attribute': '属性',
|
||||
'warehouse.parcel.form.attributePlaceholder': '颜色/尺码等(选填)',
|
||||
'warehouse.parcel.form.quantity': '数量',
|
||||
'warehouse.parcel.form.remark': '备注',
|
||||
'warehouse.parcel.form.remarkPlaceholder': '包裹备注(选填)',
|
||||
'warehouse.parcel.form.itemRemark': '商品备注',
|
||||
'warehouse.parcel.form.itemRemarkPlaceholder': '选填',
|
||||
'warehouse.parcel.form.currentWarehouse': '当前仓库',
|
||||
'warehouse.parcel.form.autoAddRow': '填写商品名称后会自动新增下一行',
|
||||
'warehouse.parcel.form.itemFilledCount': '已填 {n} 项',
|
||||
'warehouse.parcel.modal.add': '新增包裹',
|
||||
'warehouse.parcel.actions.delete': '删除包裹',
|
||||
'warehouse.parcel.message.loadFailed': '加载包裹失败',
|
||||
@ -364,21 +379,29 @@ export default {
|
||||
'warehouse.inbound.tip': '预报到仓货物;收货上架后库存会增加。关注状态:预报 → 待入库 → 已完成。',
|
||||
'warehouse.inbound.form.markReference': '唛头',
|
||||
'warehouse.inbound.form.markBoxNo': '箱号',
|
||||
'warehouse.inbound.form.markBoxNoPlaceholder': '箱唛/箱号(选填)',
|
||||
'warehouse.inbound.form.sku': 'SKU',
|
||||
'warehouse.inbound.form.plannedQty': '计划数量',
|
||||
'warehouse.inbound.form.markPlaceholder': '一般填写物流的快递单号',
|
||||
'warehouse.inbound.form.markPlaceholder': '一般填写物流快递单号',
|
||||
'warehouse.inbound.form.remarkPlaceholder': '选填',
|
||||
'warehouse.inbound.form.optional': '选填',
|
||||
'warehouse.inbound.form.boxSkuDetail': '箱子与 SKU 明细',
|
||||
'warehouse.inbound.form.boxCount': '箱子 {n}',
|
||||
'warehouse.inbound.form.skuCount': 'SKU {n}',
|
||||
'warehouse.inbound.form.totalQty': '总入库 {n}',
|
||||
'warehouse.inbound.form.boxWeight': '重量/g',
|
||||
'warehouse.inbound.form.summaryMeta': '{box} 箱 · {sku} SKU · 计划 {qty}',
|
||||
'warehouse.inbound.form.boxTabWithSku': '箱 {n} · {sku}',
|
||||
'warehouse.inbound.form.boxWeight': '重量',
|
||||
'warehouse.inbound.form.boxSize': '尺寸',
|
||||
'warehouse.inbound.form.boxLength': '长/cm',
|
||||
'warehouse.inbound.form.boxWidth': '宽/cm',
|
||||
'warehouse.inbound.form.boxHeight': '高/cm',
|
||||
'warehouse.inbound.form.selectSku': '请选择库内 SKU',
|
||||
'warehouse.inbound.actions.addBox': '增加箱子',
|
||||
'warehouse.inbound.actions.addBox5': '一次新增 5 箱',
|
||||
'warehouse.inbound.form.selectSku': '选择库内 SKU',
|
||||
'warehouse.inbound.form.autoAddSkuRow': '选择 SKU 后会自动新增下一行',
|
||||
'warehouse.inbound.actions.addBox': '加箱',
|
||||
'warehouse.inbound.actions.addBox5': '一次加 5 箱',
|
||||
'warehouse.inbound.actions.removeBox': '移除箱子',
|
||||
'warehouse.inbound.actions.removeCurrentBox': '删除当前箱',
|
||||
'warehouse.inbound.actions.addSku': '选择库内 SKU',
|
||||
'warehouse.inbound.modal.add': '新增入库预报',
|
||||
'warehouse.inbound.drawer.detail': '入库详情',
|
||||
@ -397,6 +420,7 @@ export default {
|
||||
'warehouse.inbound.message.deleteSuccess': '删除成功',
|
||||
'warehouse.inbound.message.required': '请选择仓库',
|
||||
'warehouse.inbound.message.boxRequired': '请至少为一个箱子选择 SKU',
|
||||
'warehouse.inbound.message.keepOneBox': '至少保留一箱',
|
||||
'warehouse.inbound.message.detailFailed': '加载详情失败',
|
||||
'warehouse.inbound.message.receiveBinRequired': '有实收数量时必须选择上架库位',
|
||||
'warehouse.inbound.message.receiveQtyInvalid': '实收数量不能为负',
|
||||
@ -3411,7 +3435,7 @@ export default {
|
||||
|
||||
'operation.printLabel.pageTitle': '打印标签',
|
||||
'operation.printLabel.broadcastSettings': '播报设置',
|
||||
'operation.printLabel.tip': '扫描任一号码拉出订单与绑定货品,核对数量无误后再打印面单,避免发错、发漏。',
|
||||
'operation.printLabel.tip': '扫描后将自动打印面单,请确认顶部打印程序已连接。',
|
||||
'operation.printLabel.scan.title': '扫码打印',
|
||||
'operation.fulfillPack.scan.title': '扫码反查',
|
||||
'operation.fulfillPack.scan.placeholder': '扫描或输入国内快递单号 / 运单号 / SKU',
|
||||
@ -3476,8 +3500,11 @@ export default {
|
||||
'operation.printLabel.labelTemplate.inbound': '入库标签',
|
||||
'operation.printLabel.labelTemplate.outbound': '出库标签',
|
||||
'operation.printLabel.labelTemplate.sku': 'sku标签',
|
||||
'operation.printLabel.preview.title': '核对信息',
|
||||
'operation.printLabel.preview.empty': '扫描号码后显示订单与绑定货品',
|
||||
'operation.printLabel.preview.title': '面单预览',
|
||||
'operation.printLabel.preview.empty': '扫描单号后显示订单信息,需要时可点预览查看面单',
|
||||
'operation.printLabel.preview.product': '销售产品',
|
||||
'operation.printLabel.preview.country': '目的国家',
|
||||
'operation.printLabel.preview.status': '订单状态',
|
||||
'operation.printLabel.preview.order': '订单',
|
||||
'operation.printLabel.preview.bindSummary': '{lines} 种货 · 共 {qty} 件',
|
||||
'operation.printLabel.preview.lines': '货品种类',
|
||||
@ -3505,6 +3532,15 @@ export default {
|
||||
'operation.printLabel.message.lookupSuccess': '已找到订单,请核对绑定货品',
|
||||
'operation.printLabel.message.lookupFirst': '请先查询并核对订单信息',
|
||||
'operation.printLabel.message.printSuccess': '打印成功',
|
||||
'operation.printLabel.message.printFailed': '打印失败',
|
||||
'operation.printLabel.message.noPrintFile': '未获取到打印文件',
|
||||
'operation.printLabel.scan.autoHint': '扫描单号后自动查询并打印,无需点击按钮',
|
||||
'operation.printLabel.printerStatus.ready': '本机打印已就绪',
|
||||
'operation.printLabel.printerStatus.off': '未连接打印,请打开页面顶部「打印」开关',
|
||||
'operation.printLabel.actions.reprint': '再次打印',
|
||||
'operation.printLabel.actions.printBtn': '打印',
|
||||
'operation.printLabel.actions.preview': '预览',
|
||||
'operation.printLabel.actions.previewHint': '点击查看面单内容',
|
||||
'operation.printLabel.printSuccess.yes': '是',
|
||||
'operation.printLabel.printSuccess.no': '否',
|
||||
'operation.printLabel.pagination.invalidPage': '请输入有效页码',
|
||||
|
||||
@ -64,6 +64,7 @@ const useTabBarStore = defineStore('tabBar', {
|
||||
tagList: [DEFAULT_ROUTE],
|
||||
previewingPath: '',
|
||||
previewingName: '',
|
||||
routeRefreshTicks: {},
|
||||
}),
|
||||
|
||||
getters: {
|
||||
@ -161,6 +162,13 @@ const useTabBarStore = defineStore('tabBar', {
|
||||
deleteCache(tag: TagProps) {
|
||||
this.cacheTabList.delete(tag.name);
|
||||
},
|
||||
/** 顶栏刷新:仅 bump 一次 key,避免 router.replace 加/去 _r 导致页面挂载两次 */
|
||||
bumpRouteRefresh(routeName: string) {
|
||||
const key = String(routeName || '').trim();
|
||||
if (!key) return;
|
||||
const prev = this.routeRefreshTicks[key] || 0;
|
||||
this.routeRefreshTicks[key] = prev + 1;
|
||||
},
|
||||
freshTabList(tags: TagProps[]) {
|
||||
this.tagList = tags;
|
||||
this.cacheTabList.clear();
|
||||
|
||||
@ -12,4 +12,6 @@ export interface TabBarState {
|
||||
/** 菜单点击后、路由完成前的预亮标签,避免顶栏等页面渲染完才动 */
|
||||
previewingPath: string;
|
||||
previewingName: string;
|
||||
/** 顶栏标签刷新计数:驱动 page-layout 单次 remount,避免 _r 双跳路由 */
|
||||
routeRefreshTicks: Record<string, number>;
|
||||
}
|
||||
|
||||
65
src/utils/hiprint/dispatchPrintUrl.ts
Normal file
65
src/utils/hiprint/dispatchPrintUrl.ts
Normal file
@ -0,0 +1,65 @@
|
||||
import { resolveOmsAssetUrl } from '@/api/oms/common';
|
||||
import { fetchPrintAssetBytes } from '@/utils/printPreview';
|
||||
import {
|
||||
fetchHtmlTextForHiprint,
|
||||
fetchPdfBytesForHiprint,
|
||||
hiprintSendBlobPdf,
|
||||
hiprintSendHtmlPrint,
|
||||
} from '@/utils/hiprint/hiprintElectronSocket';
|
||||
import { useHiprintClientState } from '@/utils/hiprint/hiprintClientState';
|
||||
import {
|
||||
buildHiprintBlobPrintExtras,
|
||||
readHiprintPrintFormFromStorage,
|
||||
} from '@/utils/hiprint/hiprintPrintOptions';
|
||||
|
||||
function toAbsoluteUrl(url: string) {
|
||||
const resolved = resolveOmsAssetUrl(url) || String(url || '').trim();
|
||||
if (!resolved) return '';
|
||||
if (/^https?:\/\//i.test(resolved) || resolved.startsWith('blob:') || resolved.startsWith('data:')) {
|
||||
return resolved;
|
||||
}
|
||||
if (resolved.startsWith('/')) return `${window.location.origin}${resolved}`;
|
||||
return `${window.location.origin}/${resolved}`;
|
||||
}
|
||||
|
||||
async function sendBytesToHiprint(rawUrl: string, bytes: Uint8Array) {
|
||||
const extras = buildHiprintBlobPrintExtras(readHiprintPrintFormFromStorage());
|
||||
const isPdf = /\.pdf(\?|#|$)/i.test(rawUrl);
|
||||
if (isPdf) {
|
||||
await hiprintSendBlobPdf({ pdf_blob: bytes, printExtras: extras });
|
||||
return;
|
||||
}
|
||||
const html = new TextDecoder('utf-8').decode(bytes);
|
||||
await hiprintSendHtmlPrint({ html, printExtras: extras });
|
||||
}
|
||||
|
||||
/** 本机 hiprint 静默打印,不打开新标签页 */
|
||||
export async function dispatchPrintUrl(rawUrl: string) {
|
||||
const hiprintState = useHiprintClientState();
|
||||
if (!hiprintState.enabled || !hiprintState.connected) {
|
||||
throw new Error('请先打开页面顶部「打印」开关并连接本机打印程序');
|
||||
}
|
||||
|
||||
const url = String(rawUrl || '').trim();
|
||||
if (!url) throw new Error('打印地址为空');
|
||||
|
||||
try {
|
||||
const bytes = await fetchPrintAssetBytes(url);
|
||||
await sendBytesToHiprint(url, bytes);
|
||||
return;
|
||||
} catch {
|
||||
// 回退旧逻辑
|
||||
}
|
||||
|
||||
const absolute = toAbsoluteUrl(url);
|
||||
if (/\.pdf(\?|#|$)/i.test(url)) {
|
||||
const pdf_blob = await fetchPdfBytesForHiprint(absolute);
|
||||
const extras = buildHiprintBlobPrintExtras(readHiprintPrintFormFromStorage());
|
||||
await hiprintSendBlobPdf({ pdf_blob, printExtras: extras });
|
||||
return;
|
||||
}
|
||||
|
||||
const html = await fetchHtmlTextForHiprint(absolute);
|
||||
const extras = buildHiprintBlobPrintExtras(readHiprintPrintFormFromStorage());
|
||||
await hiprintSendHtmlPrint({ html, printExtras: extras });
|
||||
}
|
||||
@ -9,8 +9,14 @@ export interface HiprintPrintForm {
|
||||
scaleFactor: number;
|
||||
}
|
||||
|
||||
/** 物流面单常用尺寸(mm),走 pageSize 而非系统纸张名 */
|
||||
export const HIPRINT_LABEL_PAPER_MM: Record<string, { widthMm: number; heightMm: number }> = {
|
||||
label_100x150: { widthMm: 100, heightMm: 150 },
|
||||
label_100x180: { widthMm: 100, heightMm: 180 },
|
||||
};
|
||||
|
||||
const DEFAULT_FORM: HiprintPrintForm = {
|
||||
paperPreset: 'A4',
|
||||
paperPreset: 'label_100x150',
|
||||
customWidthMm: 100,
|
||||
customHeightMm: 150,
|
||||
landscape: false,
|
||||
@ -50,10 +56,16 @@ export function buildHiprintBlobPrintExtras(form: Partial<HiprintPrintForm>) {
|
||||
pagesPerSheet: 1,
|
||||
collate: true,
|
||||
};
|
||||
const labelPaper = HIPRINT_LABEL_PAPER_MM[f.paperPreset];
|
||||
if (f.paperPreset === 'custom') {
|
||||
const w = Math.max(10, Math.min(500, Number(f.customWidthMm) || 100));
|
||||
const h = Math.max(10, Math.min(500, Number(f.customHeightMm) || 150));
|
||||
extras.pageSize = { width: w * 1000, height: h * 1000 };
|
||||
} else if (labelPaper) {
|
||||
extras.pageSize = {
|
||||
width: labelPaper.widthMm * 1000,
|
||||
height: labelPaper.heightMm * 1000,
|
||||
};
|
||||
} else {
|
||||
extras.paperName = f.paperPreset || 'A4';
|
||||
}
|
||||
@ -61,16 +73,12 @@ export function buildHiprintBlobPrintExtras(form: Partial<HiprintPrintForm>) {
|
||||
}
|
||||
|
||||
export const HIPRINT_PAPER_PRESET_OPTIONS = [
|
||||
{ value: 'A0', label: 'A0' },
|
||||
{ value: 'A1', label: 'A1' },
|
||||
{ value: 'A2', label: 'A2' },
|
||||
{ value: 'A3', label: 'A3' },
|
||||
{ value: 'label_100x150', label: '面单 100×150' },
|
||||
{ value: 'label_100x180', label: '面单 100×180' },
|
||||
{ value: 'A4', label: 'A4' },
|
||||
{ value: 'A5', label: 'A5' },
|
||||
{ value: 'A6', label: 'A6' },
|
||||
{ value: 'Letter', label: 'Letter' },
|
||||
{ value: 'Legal', label: 'Legal' },
|
||||
{ value: 'Tabloid', label: 'Tabloid' },
|
||||
{ value: 'custom', label: '自定义 (mm)' },
|
||||
];
|
||||
|
||||
|
||||
@ -1,6 +1,25 @@
|
||||
import { axiosInstance } from '@/api/rbac'
|
||||
import { normalizeFileStorageKey, streamFileBlob } from '@/api/fileStorage'
|
||||
import { omsUrl, resolveOmsAssetUrl } from '@/api/oms/common'
|
||||
import { normalizeFileStorageKey } from '@/api/fileStorage'
|
||||
|
||||
const COS_PROXY_PREFIX = '/__cos__'
|
||||
const PREVIEW_FETCH_TIMEOUT_MS = 25000
|
||||
|
||||
export function withPreviewTimeout<T>(promise: Promise<T>, message = '面单加载超时'): Promise<T> {
|
||||
return new Promise<T>((resolve, reject) => {
|
||||
const timer = window.setTimeout(() => reject(new Error(message)), PREVIEW_FETCH_TIMEOUT_MS)
|
||||
promise
|
||||
.then((value) => {
|
||||
window.clearTimeout(timer)
|
||||
resolve(value)
|
||||
})
|
||||
.catch((error) => {
|
||||
window.clearTimeout(timer)
|
||||
reject(error)
|
||||
})
|
||||
})
|
||||
}
|
||||
const PDF_MAGIC = '%PDF'
|
||||
|
||||
function guessMime(pathOrUrl: string): string {
|
||||
if (/\.pdf(\?|#|$)/i.test(pathOrUrl)) return 'application/pdf'
|
||||
@ -8,6 +27,32 @@ function guessMime(pathOrUrl: string): string {
|
||||
return 'application/octet-stream'
|
||||
}
|
||||
|
||||
function isCosHost(hostname: string): boolean {
|
||||
const host = String(hostname || '').toLowerCase()
|
||||
return host.includes('myqcloud.com') || host.startsWith('cos.')
|
||||
}
|
||||
|
||||
function isCosAbsoluteUrl(raw: string): boolean {
|
||||
try {
|
||||
const u = new URL(raw)
|
||||
return isCosHost(u.hostname)
|
||||
} catch {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
/** 开发环境把 COS 绝对地址改写成 Vite 同源代理,避免跨域且绕开 dev 后端桶不一致 */
|
||||
export function toDevCosProxyUrl(url: string): string | null {
|
||||
if (!import.meta.env.DEV) return null
|
||||
try {
|
||||
const u = new URL(url)
|
||||
if (!isCosHost(u.host)) return null
|
||||
return `${COS_PROXY_PREFIX}/${u.host}${u.pathname}${u.search}`
|
||||
} catch {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
/** 开发环境把生产 Admin 绝对地址改写成 Vite 同源代理路径 */
|
||||
function rewriteDevAdminAssetPath(url: string): string {
|
||||
if (!import.meta.env.DEV) return url
|
||||
@ -17,6 +62,28 @@ function rewriteDevAdminAssetPath(url: string): string {
|
||||
return proxied || trimmed
|
||||
}
|
||||
|
||||
function stripAdminPrefix(key: string): string {
|
||||
return key.replace(/^admin\//i, '')
|
||||
}
|
||||
|
||||
/** 从 COS / Admin 完整 URL 或相对路径推断库内 object key(不含签名参数) */
|
||||
export function guessStorageKeyFromPrintUrl(raw: string): string | null {
|
||||
const value = String(raw || '').trim()
|
||||
if (!value) return null
|
||||
try {
|
||||
if (/^https?:\/\//i.test(value)) {
|
||||
const path = decodeURIComponent(new URL(value).pathname).replace(/^\/+/, '')
|
||||
const stripped = stripAdminPrefix(path)
|
||||
return stripped || null
|
||||
}
|
||||
const rel = value.replace(/^\/+/, '')
|
||||
const stripped = stripAdminPrefix(rel)
|
||||
return stripped || null
|
||||
} catch {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
function toSameOriginPath(url: string): string {
|
||||
const resolved = rewriteDevAdminAssetPath(resolveOmsAssetUrl(url) || url)
|
||||
if (!resolved) return ''
|
||||
@ -24,17 +91,96 @@ function toSameOriginPath(url: string): string {
|
||||
return resolved.startsWith('/') ? resolved : `/${resolved}`
|
||||
}
|
||||
|
||||
async function fetchBlobViaStream(keyOrUrl: string): Promise<Blob> {
|
||||
const res = await axiosInstance.get(omsUrl('/file-storage/stream'), {
|
||||
params: { key: keyOrUrl },
|
||||
responseType: 'blob',
|
||||
timeout: 120000,
|
||||
})
|
||||
const type = String(res.headers['content-type'] || guessMime(keyOrUrl))
|
||||
if (res.data instanceof Blob) {
|
||||
return res.data.type ? res.data : new Blob([res.data], { type })
|
||||
function pushUniqueKey(keys: string[], key: string | null | undefined) {
|
||||
const value = String(key || '').trim()
|
||||
if (!value || keys.includes(value)) return
|
||||
keys.push(value)
|
||||
}
|
||||
|
||||
/** 构建 /file-storage/stream 候选 key(优先短 key,避免把带签名的 COS URL 塞进 query) */
|
||||
async function buildPrintStreamKeyCandidates(rawUrl: string): Promise<string[]> {
|
||||
const raw = String(rawUrl || '').trim()
|
||||
if (!raw) return []
|
||||
|
||||
const keys: string[] = []
|
||||
|
||||
try {
|
||||
pushUniqueKey(keys, await normalizeFileStorageKey(raw))
|
||||
} catch {
|
||||
// ignore
|
||||
}
|
||||
return new Blob([res.data], { type })
|
||||
|
||||
const guessed = guessStorageKeyFromPrintUrl(raw)
|
||||
pushUniqueKey(keys, guessed)
|
||||
if (guessed && !guessed.startsWith('admin/')) {
|
||||
pushUniqueKey(keys, `admin/${guessed}`)
|
||||
}
|
||||
|
||||
const asset = resolveOmsAssetUrl(raw)
|
||||
const guessedAsset = guessStorageKeyFromPrintUrl(asset)
|
||||
pushUniqueKey(keys, guessedAsset)
|
||||
if (guessedAsset && !guessedAsset.startsWith('admin/')) {
|
||||
pushUniqueKey(keys, `admin/${guessedAsset}`)
|
||||
}
|
||||
|
||||
pushUniqueKey(keys, guessStorageKeyFromPrintUrl(rewriteDevAdminAssetPath(raw)))
|
||||
if (asset) {
|
||||
pushUniqueKey(keys, guessStorageKeyFromPrintUrl(rewriteDevAdminAssetPath(asset)))
|
||||
}
|
||||
|
||||
const sameOriginPath = toSameOriginPath(raw)
|
||||
if (sameOriginPath.startsWith('/')) {
|
||||
pushUniqueKey(keys, guessStorageKeyFromPrintUrl(sameOriginPath))
|
||||
}
|
||||
|
||||
return keys
|
||||
}
|
||||
|
||||
function stripUtf8Bom(bytes: Uint8Array): Uint8Array {
|
||||
if (bytes.length >= 3 && bytes[0] === 0xef && bytes[1] === 0xbb && bytes[2] === 0xbf) {
|
||||
return bytes.slice(3)
|
||||
}
|
||||
return bytes
|
||||
}
|
||||
|
||||
function bytesStartWithPdfMagic(bytes: Uint8Array): boolean {
|
||||
const head = bytes.slice(0, 5)
|
||||
if (head.length < 5) return false
|
||||
return String.fromCharCode(...head) === PDF_MAGIC
|
||||
}
|
||||
|
||||
async function throwIfBytesLookLikeApiError(bytes: Uint8Array) {
|
||||
const sample = new TextDecoder('utf-8', { fatal: false }).decode(bytes.slice(0, 256)).trim()
|
||||
if (!sample) return
|
||||
if (sample.startsWith('{') || sample.startsWith('[')) {
|
||||
try {
|
||||
const body = JSON.parse(sample)
|
||||
const msg = body?.msg ?? body?.message ?? body?.Message
|
||||
throw new Error(msg ? String(msg) : '面单下载失败')
|
||||
} catch (e) {
|
||||
if (e instanceof Error && e.message !== '面单下载失败' && !e.message.startsWith('Unexpected')) {
|
||||
throw e
|
||||
}
|
||||
throw new Error('面单下载失败')
|
||||
}
|
||||
}
|
||||
if (sample.startsWith('<!DOCTYPE') || sample.startsWith('<html') || sample.startsWith('<')) {
|
||||
throw new Error('面单下载失败')
|
||||
}
|
||||
}
|
||||
|
||||
/** 校验并规范化 PDF 字节(拒绝 JSON/HTML 错误体) */
|
||||
export async function normalizePdfBytes(blob: Blob, rawUrl: string): Promise<Uint8Array> {
|
||||
if (!isPrintPreviewPdf(rawUrl, blob)) {
|
||||
return new Uint8Array(await blob.arrayBuffer())
|
||||
}
|
||||
|
||||
let bytes = stripUtf8Bom(new Uint8Array(await blob.arrayBuffer()))
|
||||
if (!bytesStartWithPdfMagic(bytes)) {
|
||||
await throwIfBytesLookLikeApiError(bytes)
|
||||
throw new Error('面单文件不是有效的 PDF')
|
||||
}
|
||||
return bytes
|
||||
}
|
||||
|
||||
async function fetchBlobViaSameOriginPath(path: string): Promise<Blob> {
|
||||
@ -49,82 +195,106 @@ async function fetchBlobViaSameOriginPath(path: string): Promise<Blob> {
|
||||
return new Blob([res.data], { type })
|
||||
}
|
||||
|
||||
/**
|
||||
* 将打印 URL 转为可在 iframe 中预览的 blob: 地址(同源,避免 COS / api 跨域空白)。
|
||||
* 失败时回退为可直链打开的绝对地址。
|
||||
*/
|
||||
export async function resolvePrintPreviewSrc(rawUrl: string): Promise<string> {
|
||||
const raw = String(rawUrl || '').trim()
|
||||
if (!raw) return ''
|
||||
|
||||
const candidates = new Set<string>()
|
||||
candidates.add(raw)
|
||||
const asset = resolveOmsAssetUrl(raw)
|
||||
if (asset) candidates.add(asset)
|
||||
candidates.add(rewriteDevAdminAssetPath(raw))
|
||||
if (asset) candidates.add(rewriteDevAdminAssetPath(asset))
|
||||
|
||||
try {
|
||||
const key = await normalizeFileStorageKey(raw)
|
||||
if (key) candidates.add(key)
|
||||
} catch {
|
||||
// ignore
|
||||
async function fetchBlobViaProxiedUrl(rawUrl: string): Promise<Blob> {
|
||||
const proxied = toDevCosProxyUrl(rawUrl)
|
||||
const requestUrl = proxied || rawUrl
|
||||
const res = await axiosInstance.get(requestUrl, {
|
||||
responseType: 'arraybuffer',
|
||||
timeout: 120000,
|
||||
})
|
||||
const mime = String(res.headers['content-type'] || guessMime(rawUrl))
|
||||
const bytes = stripUtf8Bom(new Uint8Array(res.data as ArrayBuffer))
|
||||
await throwIfBytesLookLikeApiError(bytes)
|
||||
if (!bytesStartWithPdfMagic(bytes)) {
|
||||
throw new Error('面单文件不是有效的 PDF')
|
||||
}
|
||||
return new Blob([bytes], { type: 'application/pdf' })
|
||||
}
|
||||
|
||||
for (const candidate of candidates) {
|
||||
const value = String(candidate || '').trim()
|
||||
if (!value) continue
|
||||
async function fetchPreviewBlob(rawUrl: string): Promise<Blob> {
|
||||
const raw = String(rawUrl || '').trim()
|
||||
if (!raw) throw new Error('打印地址为空')
|
||||
|
||||
const errors: string[] = []
|
||||
|
||||
// 1. COS 签名直链优先(新标签能打开时最可靠;开发走 /__cos__ 代理)
|
||||
if (/^https?:\/\//i.test(raw) && isCosAbsoluteUrl(raw)) {
|
||||
try {
|
||||
const blob = await fetchBlobViaStream(value)
|
||||
return URL.createObjectURL(blob)
|
||||
} catch {
|
||||
// try next
|
||||
const blob = await fetchBlobViaProxiedUrl(raw)
|
||||
const bytes = await normalizePdfBytes(blob, raw)
|
||||
return new Blob([bytes], { type: 'application/pdf' })
|
||||
} catch (e: any) {
|
||||
errors.push(e?.message || 'COS 直链下载失败')
|
||||
}
|
||||
}
|
||||
|
||||
// 2. /file-storage/stream
|
||||
const keys = await buildPrintStreamKeyCandidates(raw)
|
||||
for (const key of keys) {
|
||||
try {
|
||||
const blob = await streamFileBlob(key)
|
||||
const mime = guessMime(key)
|
||||
const typed = blob.type ? blob : new Blob([blob], { type: mime })
|
||||
const bytes = await normalizePdfBytes(typed, raw)
|
||||
return new Blob([bytes], { type: 'application/pdf' })
|
||||
} catch (e: any) {
|
||||
if (e?.message) errors.push(String(e.message))
|
||||
}
|
||||
}
|
||||
|
||||
// 3. 同源 /uploads 路径
|
||||
const sameOriginPath = toSameOriginPath(raw)
|
||||
if (sameOriginPath.startsWith('/')) {
|
||||
try {
|
||||
const blob = await fetchBlobViaSameOriginPath(sameOriginPath)
|
||||
return URL.createObjectURL(blob)
|
||||
} catch {
|
||||
// ignore
|
||||
const bytes = await normalizePdfBytes(blob, raw)
|
||||
return new Blob([bytes], { type: 'application/pdf' })
|
||||
} catch (e: any) {
|
||||
if (e?.message) errors.push(String(e.message))
|
||||
}
|
||||
return `${window.location.origin}${sameOriginPath}`
|
||||
}
|
||||
|
||||
return sameOriginPath
|
||||
const detail = errors.find(Boolean)
|
||||
throw new Error(detail || '无法通过服务端加载面单文件')
|
||||
}
|
||||
|
||||
/** 供 hiprint 静默打印:优先经 /file-storage/stream 拉取字节 */
|
||||
export async function fetchPrintAssetBytes(rawUrl: string): Promise<Uint8Array> {
|
||||
/** 经 COS 代理 / file-storage/stream 拉取面单 Blob(PDF / HTML) */
|
||||
export async function fetchPrintPreviewBlob(rawUrl: string): Promise<Blob> {
|
||||
return fetchPreviewBlob(rawUrl)
|
||||
}
|
||||
|
||||
/** 开发环境优先返回同源 COS 代理 URL,供 vue-pdf-embed 直接加载 */
|
||||
export function resolvePrintPreviewPdfSource(rawUrl: string): string | null {
|
||||
const raw = String(rawUrl || '').trim()
|
||||
if (!raw) throw new Error('打印地址为空')
|
||||
|
||||
const candidates = new Set<string>([raw])
|
||||
try {
|
||||
const key = await normalizeFileStorageKey(raw)
|
||||
if (key) candidates.add(key)
|
||||
} catch {
|
||||
// ignore
|
||||
}
|
||||
|
||||
for (const candidate of candidates) {
|
||||
const value = String(candidate || '').trim()
|
||||
if (!value) continue
|
||||
try {
|
||||
const blob = await fetchBlobViaStream(value)
|
||||
return new Uint8Array(await blob.arrayBuffer())
|
||||
} catch {
|
||||
// try next
|
||||
}
|
||||
}
|
||||
|
||||
const path = toSameOriginPath(raw)
|
||||
if (path.startsWith('/')) {
|
||||
const blob = await fetchBlobViaSameOriginPath(path)
|
||||
return new Uint8Array(await blob.arrayBuffer())
|
||||
}
|
||||
|
||||
throw new Error('无法下载面单文件')
|
||||
if (!raw || !isPrintPreviewPdf(raw)) return null
|
||||
return toDevCosProxyUrl(raw)
|
||||
}
|
||||
|
||||
/** 拉取并校验 PDF 字节,供 vue-pdf-embed 使用 */
|
||||
export async function fetchPrintPreviewPdfBytes(rawUrl: string): Promise<Uint8Array> {
|
||||
const blob = await withPreviewTimeout(fetchPreviewBlob(rawUrl))
|
||||
return normalizePdfBytes(blob, rawUrl)
|
||||
}
|
||||
|
||||
/**
|
||||
* 将打印 URL 转为同源 blob: 地址(HTML 回落预览等场景)。
|
||||
*/
|
||||
export async function resolvePrintPreviewSrc(rawUrl: string): Promise<string> {
|
||||
const blob = await fetchPreviewBlob(rawUrl)
|
||||
return URL.createObjectURL(blob)
|
||||
}
|
||||
|
||||
export function isPrintPreviewPdf(rawUrl: string, blob?: Blob | null): boolean {
|
||||
const mime = String(blob?.type || '').toLowerCase()
|
||||
if (mime.includes('pdf')) return true
|
||||
return /\.pdf(\?|#|$)/i.test(String(rawUrl || ''))
|
||||
}
|
||||
|
||||
/** 供 hiprint 静默打印:优先经 COS 代理 / file-storage/stream 拉取字节 */
|
||||
export async function fetchPrintAssetBytes(rawUrl: string): Promise<Uint8Array> {
|
||||
const blob = await fetchPreviewBlob(rawUrl)
|
||||
if (isPrintPreviewPdf(rawUrl, blob)) {
|
||||
return normalizePdfBytes(blob, rawUrl)
|
||||
}
|
||||
return new Uint8Array(await blob.arrayBuffer())
|
||||
}
|
||||
|
||||
150
src/utils/printSessionCache.ts
Normal file
150
src/utils/printSessionCache.ts
Normal file
@ -0,0 +1,150 @@
|
||||
import { postOrderPrint } from '@/api/order';
|
||||
import {
|
||||
fetchPrintPreviewBlob,
|
||||
fetchPrintPreviewPdfBytes,
|
||||
isPrintPreviewPdf,
|
||||
resolvePrintPreviewPdfSource,
|
||||
withPreviewTimeout,
|
||||
} from '@/utils/printPreview';
|
||||
|
||||
const PRINT_URL_TTL_MS = 10 * 60 * 1000;
|
||||
const PREVIEW_TTL_MS = 10 * 60 * 1000;
|
||||
|
||||
export interface PrintPreviewCacheEntry {
|
||||
pdfSource: string | Uint8Array | null;
|
||||
htmlBlob: Blob | null;
|
||||
createdAt: number;
|
||||
}
|
||||
|
||||
interface PrintUrlCacheEntry {
|
||||
url: string;
|
||||
createdAt: number;
|
||||
}
|
||||
|
||||
const printUrlCache = new Map<string, PrintUrlCacheEntry>();
|
||||
const printUrlInflight = new Map<string, Promise<string>>();
|
||||
const previewCache = new Map<string, PrintPreviewCacheEntry>();
|
||||
const previewInflight = new Map<string, Promise<PrintPreviewCacheEntry>>();
|
||||
|
||||
function normalizeUrlKey(rawUrl: string) {
|
||||
return String(rawUrl || '').trim();
|
||||
}
|
||||
|
||||
function isUsablePrintUrl(raw: unknown) {
|
||||
const value = String(raw ?? '').trim();
|
||||
if (!value) return false;
|
||||
if (value.includes('获取中')) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
function isFresh(createdAt: number, ttl: number) {
|
||||
return Date.now() - createdAt < ttl;
|
||||
}
|
||||
|
||||
export function getCachedPrintUrl(orderId: string | number): string | null {
|
||||
const hit = printUrlCache.get(String(orderId));
|
||||
if (!hit || !isFresh(hit.createdAt, PRINT_URL_TTL_MS)) {
|
||||
if (hit) printUrlCache.delete(String(orderId));
|
||||
return null;
|
||||
}
|
||||
return hit.url;
|
||||
}
|
||||
|
||||
export function setCachedPrintUrl(orderId: string | number, url: string) {
|
||||
const value = String(url || '').trim();
|
||||
if (!isUsablePrintUrl(value)) return;
|
||||
printUrlCache.set(String(orderId), { url: value, createdAt: Date.now() });
|
||||
}
|
||||
|
||||
export function peekPrintPreviewCache(rawUrl: string): PrintPreviewCacheEntry | null {
|
||||
const key = normalizeUrlKey(rawUrl);
|
||||
if (!key) return null;
|
||||
const hit = previewCache.get(key);
|
||||
if (!hit || !isFresh(hit.createdAt, PREVIEW_TTL_MS)) {
|
||||
if (hit) previewCache.delete(key);
|
||||
return null;
|
||||
}
|
||||
return hit;
|
||||
}
|
||||
|
||||
async function warmPdfNetwork(url: string) {
|
||||
if (!url.startsWith('/__cos__/')) return;
|
||||
try {
|
||||
await fetch(url, { method: 'GET', credentials: 'include' });
|
||||
} catch {
|
||||
// ignore warm-up failure
|
||||
}
|
||||
}
|
||||
|
||||
async function buildPreviewEntry(rawUrl: string): Promise<PrintPreviewCacheEntry> {
|
||||
const raw = normalizeUrlKey(rawUrl);
|
||||
if (!raw) throw new Error('打印地址为空');
|
||||
|
||||
if (isPrintPreviewPdf(raw)) {
|
||||
const proxied = resolvePrintPreviewPdfSource(raw);
|
||||
if (proxied) {
|
||||
void warmPdfNetwork(proxied);
|
||||
return { pdfSource: proxied, htmlBlob: null, createdAt: Date.now() };
|
||||
}
|
||||
const bytes = await withPreviewTimeout(fetchPrintPreviewPdfBytes(raw));
|
||||
return { pdfSource: bytes, htmlBlob: null, createdAt: Date.now() };
|
||||
}
|
||||
|
||||
const blob = await withPreviewTimeout(fetchPrintPreviewBlob(raw));
|
||||
return { pdfSource: null, htmlBlob: blob, createdAt: Date.now() };
|
||||
}
|
||||
|
||||
/** 点击后立即预取面单预览(与弹窗打开并行) */
|
||||
export function prefetchPrintPreview(rawUrl: string): Promise<PrintPreviewCacheEntry> {
|
||||
const key = normalizeUrlKey(rawUrl);
|
||||
if (!key) return Promise.reject(new Error('打印地址为空'));
|
||||
|
||||
const cached = peekPrintPreviewCache(key);
|
||||
if (cached) return Promise.resolve(cached);
|
||||
|
||||
const inflight = previewInflight.get(key);
|
||||
if (inflight) return inflight;
|
||||
|
||||
const task = buildPreviewEntry(key)
|
||||
.then((entry) => {
|
||||
previewCache.set(key, entry);
|
||||
previewInflight.delete(key);
|
||||
return entry;
|
||||
})
|
||||
.catch((error) => {
|
||||
previewInflight.delete(key);
|
||||
throw error;
|
||||
});
|
||||
|
||||
previewInflight.set(key, task);
|
||||
return task;
|
||||
}
|
||||
|
||||
export async function getOrPrefetchPrintPreview(rawUrl: string): Promise<PrintPreviewCacheEntry> {
|
||||
const cached = peekPrintPreviewCache(rawUrl);
|
||||
if (cached) return cached;
|
||||
return prefetchPrintPreview(rawUrl);
|
||||
}
|
||||
|
||||
/** 获取 printUrl(带会话缓存 + 请求去重) */
|
||||
export async function fetchPrintUrlForOrder(orderId: string | number): Promise<string> {
|
||||
const key = String(orderId);
|
||||
const cached = getCachedPrintUrl(key);
|
||||
if (cached) return cached;
|
||||
|
||||
const inflight = printUrlInflight.get(key);
|
||||
if (inflight) return inflight;
|
||||
|
||||
const task = postOrderPrint({ id: orderId })
|
||||
.then((res) => {
|
||||
const url = String(res?.printUrl ?? '').trim();
|
||||
if (isUsablePrintUrl(url)) setCachedPrintUrl(key, url);
|
||||
return url;
|
||||
})
|
||||
.finally(() => {
|
||||
printUrlInflight.delete(key);
|
||||
});
|
||||
|
||||
printUrlInflight.set(key, task);
|
||||
return task;
|
||||
}
|
||||
@ -17,6 +17,9 @@ const SPA_API_PREFIXES = [
|
||||
'trackApi',
|
||||
] as const
|
||||
|
||||
/** 挂在 /track 根下的服务(前端常误写成 Track/xxx) */
|
||||
const TRACK_ROOT_SERVICES = ['Warning', 'ProviderService', 'Dictionary'] as const
|
||||
|
||||
const DEFAULT_PROD_API = 'https://api.ideship.com'
|
||||
|
||||
function prodApiOrigin(): string | null {
|
||||
@ -34,6 +37,24 @@ function isItfxSpaPath(afterApi: string): boolean {
|
||||
)
|
||||
}
|
||||
|
||||
function useTrackSingleSegment(origin: string): boolean {
|
||||
return (
|
||||
String(import.meta.env.VITE_DEPLOY_TARGET || '').toLowerCase() === 'ideship' ||
|
||||
/ideship\.com/i.test(origin)
|
||||
)
|
||||
}
|
||||
|
||||
/** /Track/Warning|ProviderService|Dictionary → /track/Warning|... */
|
||||
function rewriteTrackRootServicePath(path: string, origin: string): string | null {
|
||||
for (const name of TRACK_ROOT_SERVICES) {
|
||||
const prefix = `/Track/${name}`
|
||||
if (path === prefix || path.startsWith(`${prefix}/`)) {
|
||||
return `${origin}/track${path.slice('/Track'.length)}`
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
/** 遗留路径 → {apiOrigin}/{itfx|track|admin}/... */
|
||||
export function rewriteBrowserApiPath(url: string): string {
|
||||
if (!url) return url
|
||||
@ -77,12 +98,11 @@ export function rewriteBrowserApiPath(url: string): string {
|
||||
}
|
||||
|
||||
if (path.startsWith('/Track')) {
|
||||
const root = rewriteTrackRootServicePath(path, origin)
|
||||
if (root) return root
|
||||
// ideship:/Track/Track/Order → /track/Track/Order
|
||||
// nanafa:保持 /track + /Track/Track/Order
|
||||
const useSingle =
|
||||
String(import.meta.env.VITE_DEPLOY_TARGET || '').toLowerCase() === 'ideship' ||
|
||||
/ideship\.com/i.test(origin)
|
||||
if (useSingle && path.startsWith('/Track/Track/')) {
|
||||
if (useTrackSingleSegment(origin) && path.startsWith('/Track/Track/')) {
|
||||
return `${origin}/track/Track/${path.slice('/Track/Track/'.length)}`
|
||||
}
|
||||
return `${origin}/track${path}`
|
||||
@ -90,14 +110,11 @@ export function rewriteBrowserApiPath(url: string): string {
|
||||
|
||||
if (path.startsWith('/trackApi/')) {
|
||||
const rest = path.slice('/trackApi/'.length)
|
||||
const useSingle =
|
||||
String(import.meta.env.VITE_DEPLOY_TARGET || '').toLowerCase() === 'ideship' ||
|
||||
/ideship\.com/i.test(origin)
|
||||
// trackApi/Track/Order → /track/Track/Order
|
||||
if (useSingle && rest.startsWith('Track/')) {
|
||||
// trackApi/Track/Order → /track/Track/Order(ideship)
|
||||
if (useTrackSingleSegment(origin) && rest.startsWith('Track/')) {
|
||||
return `${origin}/track/${rest}`
|
||||
}
|
||||
// nanafa 历史:trackApi/Track/Order → /track/Track/Track/Order(与双 Track 客户端一致时由调用方决定)
|
||||
// trackApi/Warning|ProviderService|Dictionary → /track/...
|
||||
return `${origin}/track/${rest}`
|
||||
}
|
||||
|
||||
|
||||
@ -157,6 +157,32 @@ function looksLikeChinese(text: string) {
|
||||
return /[\u4e00-\u9fff]/.test(text)
|
||||
}
|
||||
|
||||
/** 申报图入库:去掉签名参数,避免 SkuImage VARCHAR 超长 */
|
||||
export function normalizeSkuImageForStorage(value?: string | null): string {
|
||||
const raw = String(value ?? '').trim()
|
||||
if (!raw) return ''
|
||||
if (raw.startsWith('data:') || raw.startsWith('blob:')) return raw
|
||||
try {
|
||||
if (/^https?:\/\//i.test(raw)) {
|
||||
const url = new URL(raw)
|
||||
// 托管资源只保留路径 key;外链去掉 query/hash 再存
|
||||
const path = decodeURIComponent(url.pathname || '').replace(/^\/+/, '')
|
||||
if (path && /(?:uploads\/|sku\/|parcel\/)/i.test(path)) {
|
||||
return path
|
||||
}
|
||||
return `${url.origin}${url.pathname}`
|
||||
}
|
||||
} catch {
|
||||
// ignore
|
||||
}
|
||||
const q = raw.indexOf('?')
|
||||
const h = raw.indexOf('#')
|
||||
let end = raw.length
|
||||
if (q >= 0) end = Math.min(end, q)
|
||||
if (h >= 0) end = Math.min(end, h)
|
||||
return raw.slice(0, end)
|
||||
}
|
||||
|
||||
/** 仓库 SKU → 我要下单申报行字段 */
|
||||
export function mapWarehouseSkuToDeclarationFields(raw: Row) {
|
||||
const row = normalizeListRow(raw)
|
||||
@ -167,7 +193,9 @@ export function mapWarehouseSkuToDeclarationFields(raw: Row) {
|
||||
const unitPrice = pickField(row, 'unitPrice', 'UnitPrice')
|
||||
const exHsCode = String(pickField(row, 'exHsCode', 'ExHsCode') ?? '')
|
||||
const imHsCode = String(pickField(row, 'imHsCode', 'ImHsCode') ?? '')
|
||||
const image = String(pickField(row, 'skuImageUrl', 'SkuImageUrl') ?? '')
|
||||
const image = normalizeSkuImageForStorage(
|
||||
String(pickField(row, 'skuImageUrl', 'SkuImageUrl') ?? ''),
|
||||
)
|
||||
const remark = String(pickField(row, 'remark', 'Remark') ?? '')
|
||||
|
||||
const formatNum = (value: number) => {
|
||||
|
||||
@ -43,6 +43,8 @@
|
||||
const currentPage = ref(1);
|
||||
const pageSize = ref(50);
|
||||
const listLoading = ref(false);
|
||||
/** 首屏加载完成前忽略 Handsontable 表头初始化触发的 search,避免重复请求 GetList */
|
||||
const listBootstrapping = ref(true);
|
||||
|
||||
/** 表头搜索(与 HandsontablePro 双向绑定) */
|
||||
const searchParams = reactive({
|
||||
@ -248,35 +250,58 @@
|
||||
};
|
||||
}
|
||||
|
||||
let listRequestKey = '';
|
||||
let listRequestTask: Promise<void> | null = null;
|
||||
|
||||
async function loadTableData() {
|
||||
try {
|
||||
listLoading.value = true;
|
||||
const res: any = await getLogGetList(buildListParams());
|
||||
const data = res?.data || res;
|
||||
tableData.value = data?.items || data?.list || (Array.isArray(data) ? data : []) || [];
|
||||
totalCount.value = Number(
|
||||
data?.totalCount ?? data?.pagination?.total ?? tableData.value.length ?? 0
|
||||
);
|
||||
} catch (e) {
|
||||
$baseMessage(t('system.log.message.loadFailed'), 'error');
|
||||
tableData.value = [];
|
||||
totalCount.value = 0;
|
||||
} finally {
|
||||
listLoading.value = false;
|
||||
const params = buildListParams();
|
||||
const key = JSON.stringify(params);
|
||||
if (listRequestTask && listRequestKey === key) {
|
||||
return listRequestTask;
|
||||
}
|
||||
listRequestKey = key;
|
||||
listRequestTask = (async () => {
|
||||
try {
|
||||
listLoading.value = true;
|
||||
const res: any = await getLogGetList(params);
|
||||
const data = res?.data || res;
|
||||
tableData.value = data?.items || data?.list || (Array.isArray(data) ? data : []) || [];
|
||||
totalCount.value = Number(
|
||||
data?.totalCount ?? data?.pagination?.total ?? tableData.value.length ?? 0
|
||||
);
|
||||
} catch (e) {
|
||||
$baseMessage(t('system.log.message.loadFailed'), 'error');
|
||||
tableData.value = [];
|
||||
totalCount.value = 0;
|
||||
} finally {
|
||||
listLoading.value = false;
|
||||
if (listRequestKey === key) {
|
||||
listRequestTask = null;
|
||||
listRequestKey = '';
|
||||
}
|
||||
}
|
||||
})();
|
||||
return listRequestTask;
|
||||
}
|
||||
|
||||
function handleHeaderSearch() {
|
||||
if (listBootstrapping.value) return;
|
||||
currentPage.value = 1;
|
||||
loadTableData();
|
||||
}
|
||||
|
||||
function handlePageChange(page: number) {
|
||||
if (listBootstrapping.value || page === currentPage.value) return;
|
||||
currentPage.value = page;
|
||||
loadTableData();
|
||||
}
|
||||
|
||||
function handlePageSizeChange(size: number) {
|
||||
if (listBootstrapping.value) {
|
||||
if (pageSize.value !== size) pageSize.value = size;
|
||||
return;
|
||||
}
|
||||
if (size === pageSize.value) return;
|
||||
pageSize.value = size;
|
||||
currentPage.value = 1;
|
||||
loadTableData();
|
||||
@ -400,14 +425,24 @@
|
||||
return 'text';
|
||||
}
|
||||
|
||||
let bootstrapTask: Promise<void> | null = null;
|
||||
|
||||
onMounted(() => {
|
||||
applyInitialRequestId();
|
||||
void bootstrapList();
|
||||
});
|
||||
|
||||
watch(
|
||||
() => props.initialRequestId,
|
||||
(v, prev) => {
|
||||
if (v && v !== prev) applyInitialRequestId();
|
||||
async (v, prev) => {
|
||||
if (!v || v === prev) return;
|
||||
listBootstrapping.value = true;
|
||||
try {
|
||||
await applyInitialRequestId();
|
||||
await loadTableData();
|
||||
await nextTick();
|
||||
} finally {
|
||||
listBootstrapping.value = false;
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
@ -417,7 +452,22 @@
|
||||
searchParams.requestId = id;
|
||||
currentPage.value = 1;
|
||||
}
|
||||
await loadTableData();
|
||||
}
|
||||
|
||||
function bootstrapList() {
|
||||
if (bootstrapTask) return bootstrapTask;
|
||||
bootstrapTask = (async () => {
|
||||
listBootstrapping.value = true;
|
||||
try {
|
||||
await applyInitialRequestId();
|
||||
await loadTableData();
|
||||
await nextTick();
|
||||
} finally {
|
||||
listBootstrapping.value = false;
|
||||
bootstrapTask = null;
|
||||
}
|
||||
})();
|
||||
return bootstrapTask;
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@ -19,9 +19,9 @@
|
||||
style="width: 140px"
|
||||
>
|
||||
<a-option value="all">{{ t('user.recharge.record.search.statusAll') }}</a-option>
|
||||
<a-option value="0">{{ t('user.recharge.record.search.statusPending') }}</a-option>
|
||||
<a-option value="1">{{ t('user.recharge.record.search.statusSuccess') }}</a-option>
|
||||
<a-option value="2">{{ t('user.recharge.record.search.statusFailed') }}</a-option>
|
||||
<a-option value="1">{{ t('user.recharge.record.search.statusPending') }}</a-option>
|
||||
<a-option value="2">{{ t('user.recharge.record.search.statusSuccess') }}</a-option>
|
||||
<a-option value="3">{{ t('user.recharge.record.search.statusFailed') }}</a-option>
|
||||
</a-select>
|
||||
<a-input-number
|
||||
v-model="customerIdFilter"
|
||||
@ -185,7 +185,7 @@ const listLoading = ref(false)
|
||||
const exporting = ref(false)
|
||||
|
||||
const serialNumber = ref('')
|
||||
/** 充值状态:all 不传;0/1/2 对应接口 */
|
||||
/** 充值状态:all 不传;1=待审核 2=通过 3=驳回(与后端 RechargeStatus 一致) */
|
||||
const statusFilter = ref('all')
|
||||
const customerIdFilter = ref<number | undefined>(undefined)
|
||||
const dateRange = ref<any[]>([])
|
||||
@ -312,13 +312,13 @@ function customCellRenderer(row: number, col: number, value: any, rowData: any):
|
||||
}
|
||||
if (colKey === 'payStatus') {
|
||||
const status = rowData?.payStatus
|
||||
if (status === '0') {
|
||||
if (status === '1') {
|
||||
return buildStatusTagHtml(t('user.recharge.record.search.statusPending'), 'wait')
|
||||
}
|
||||
if (status === '1') {
|
||||
if (status === '2') {
|
||||
return buildStatusTagHtml(t('user.recharge.record.search.statusSuccess'), 'ok')
|
||||
}
|
||||
if (status === '2') {
|
||||
if (status === '3') {
|
||||
return buildStatusTagHtml(t('user.recharge.record.search.statusFailed'), 'alert')
|
||||
}
|
||||
return '--'
|
||||
@ -330,7 +330,7 @@ function customCellRenderer(row: number, col: number, value: any, rowData: any):
|
||||
}
|
||||
|
||||
function actionRenderer(row: any, _rowIndex: number): string {
|
||||
if (String(row?.payStatus) !== '0') return '<span style="color:#c9cdd4;font-size:12px">?</span>'
|
||||
if (String(row?.payStatus) !== '1') return ''
|
||||
return wrapWarehouseActions([
|
||||
renderWarehouseActionBtn('approve', t('user.recharge.record.actions.approve')),
|
||||
renderWarehouseActionBtn('reject', t('user.recharge.record.actions.reject')),
|
||||
|
||||
@ -99,19 +99,28 @@ defineExpose({
|
||||
<template>
|
||||
<div class="fbl-panel" :class="{ 'is-compact': compact }">
|
||||
<section class="ops-card ops-card--scan">
|
||||
<div class="ops-card__body ops-scan">
|
||||
<div class="ops-scan__row">
|
||||
<div class="ops-card__body fbl-scan">
|
||||
<div class="fbl-scan__main">
|
||||
<a-input
|
||||
ref="scanInputRef"
|
||||
v-model="formData.scanNumber"
|
||||
:placeholder="t('operation.fulfillPack.scan.placeholder')"
|
||||
class="ops-scan-input"
|
||||
class="fbl-scan-input"
|
||||
allow-clear
|
||||
:disabled="lookingUp"
|
||||
@press-enter="onLookupClick"
|
||||
/>
|
||||
<a-button
|
||||
type="primary"
|
||||
class="fbl-scan-lookup-btn"
|
||||
:loading="lookingUp"
|
||||
@click="onLookupClick"
|
||||
>
|
||||
{{ t('operation.fulfillPack.actions.lookup') }}
|
||||
</a-button>
|
||||
</div>
|
||||
<div class="ops-scan__row ops-scan__row--tools">
|
||||
<div class="ops-scan__opts">
|
||||
<div class="fbl-scan__sub">
|
||||
<div class="fbl-scan__sub-row">
|
||||
<a-select
|
||||
v-if="showNumberTypeSelect"
|
||||
v-model="formData.numberType"
|
||||
@ -122,20 +131,11 @@ defineExpose({
|
||||
{{ item.label }}
|
||||
</a-option>
|
||||
</a-select>
|
||||
<a-checkbox v-model="keepScanFocus" class="ops-opt">
|
||||
<a-checkbox v-model="keepScanFocus" class="fbl-keep-focus">
|
||||
{{ t('operation.common.keepScanFocus') }}
|
||||
</a-checkbox>
|
||||
</div>
|
||||
<div class="ops-scan__actions">
|
||||
<a-button class="ops-btn ops-btn--ghost" @click="handleReset">
|
||||
{{ t('operation.fulfillPack.actions.reset') }}
|
||||
</a-button>
|
||||
<a-button type="primary" class="ops-btn ops-btn--primary" :loading="lookingUp" @click="onLookupClick">
|
||||
{{ t('operation.fulfillPack.actions.lookup') }}
|
||||
</a-button>
|
||||
</div>
|
||||
</div>
|
||||
<p class="ops-scan-hint">{{ t('operation.fulfillPack.scan.hint') }}</p>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
@ -255,8 +255,99 @@ defineExpose({
|
||||
}
|
||||
}
|
||||
|
||||
.fbl-scan {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
padding: 10px 12px;
|
||||
}
|
||||
|
||||
.fbl-scan__main {
|
||||
--fbl-scan-main-height: 56px;
|
||||
display: flex;
|
||||
align-items: stretch;
|
||||
gap: 8px;
|
||||
min-width: 0;
|
||||
min-height: var(--fbl-scan-main-height);
|
||||
}
|
||||
|
||||
.fbl-scan__sub {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.fbl-scan__sub-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-wrap: nowrap;
|
||||
gap: 8px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.fbl-scan-input {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
display: flex;
|
||||
|
||||
:deep(.arco-input-wrapper) {
|
||||
flex: 1;
|
||||
width: 100%;
|
||||
min-height: var(--fbl-scan-main-height, 56px);
|
||||
border-radius: 6px;
|
||||
background: var(--app-card-bg);
|
||||
border-color: var(--color-border-2);
|
||||
|
||||
&:hover,
|
||||
&.arco-input-focus {
|
||||
border-color: var(--app-primary-color);
|
||||
}
|
||||
|
||||
&.arco-input-focus {
|
||||
box-shadow: 0 0 0 2px color-mix(in srgb, var(--app-primary-color) 15%, transparent);
|
||||
}
|
||||
}
|
||||
|
||||
:deep(.arco-input) {
|
||||
height: 100%;
|
||||
min-height: calc(var(--fbl-scan-main-height, 56px) - 2px);
|
||||
font-size: 22px;
|
||||
font-weight: 600;
|
||||
letter-spacing: 0.02em;
|
||||
|
||||
&::placeholder {
|
||||
font-size: 16px;
|
||||
font-weight: 400;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.fbl-scan-lookup-btn {
|
||||
min-width: 72px;
|
||||
height: 100%;
|
||||
min-height: var(--fbl-scan-main-height, 56px);
|
||||
padding: 0 16px;
|
||||
font-size: 16px;
|
||||
border-radius: 6px;
|
||||
}
|
||||
|
||||
.fbl-type-select {
|
||||
width: 160px;
|
||||
flex: 0 0 auto;
|
||||
width: 124px;
|
||||
|
||||
:deep(.arco-select-view-single) {
|
||||
width: 100%;
|
||||
min-height: 32px;
|
||||
font-size: 14px;
|
||||
}
|
||||
}
|
||||
|
||||
.fbl-keep-focus {
|
||||
flex: 0 0 auto;
|
||||
white-space: nowrap;
|
||||
color: var(--color-text-2);
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.fbl-panel__candidates {
|
||||
@ -267,7 +358,7 @@ defineExpose({
|
||||
|
||||
.fbl-domestic-summary {
|
||||
margin: 0 0 8px;
|
||||
font-size: 12px;
|
||||
font-size: 14px;
|
||||
color: var(--color-text-2);
|
||||
font-family: ui-monospace, Consolas, monospace;
|
||||
}
|
||||
@ -285,9 +376,13 @@ defineExpose({
|
||||
cursor: pointer;
|
||||
text-align: left;
|
||||
|
||||
strong {
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
p {
|
||||
margin: 4px 0 0;
|
||||
font-size: 12px;
|
||||
margin: 6px 0 0;
|
||||
font-size: 14px;
|
||||
color: var(--color-text-3);
|
||||
}
|
||||
|
||||
@ -305,18 +400,20 @@ defineExpose({
|
||||
}
|
||||
|
||||
.fbl-hero__waybill {
|
||||
font-size: 20px;
|
||||
font-size: 26px;
|
||||
font-weight: 700;
|
||||
font-family: ui-monospace, Consolas, monospace;
|
||||
line-height: 1.25;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.fbl-hero__meta {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 12px;
|
||||
margin-top: 6px;
|
||||
font-size: 12px;
|
||||
color: var(--color-text-3);
|
||||
margin-top: 8px;
|
||||
font-size: 14px;
|
||||
color: var(--color-text-2);
|
||||
}
|
||||
|
||||
.fbl-tags {
|
||||
@ -375,7 +472,7 @@ defineExpose({
|
||||
strong {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
font-size: 14px;
|
||||
font-size: 16px;
|
||||
line-height: 1.45;
|
||||
word-break: break-word;
|
||||
}
|
||||
@ -386,7 +483,7 @@ defineExpose({
|
||||
flex-wrap: wrap;
|
||||
gap: 8px 12px;
|
||||
margin-top: 8px;
|
||||
font-size: 12px;
|
||||
font-size: 13px;
|
||||
color: var(--color-text-2);
|
||||
line-height: 1.5;
|
||||
}
|
||||
@ -412,6 +509,7 @@ defineExpose({
|
||||
padding: 32px 16px;
|
||||
text-align: center;
|
||||
color: var(--color-text-3);
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.fbl-warn {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -594,7 +594,7 @@ onMounted(() => {
|
||||
</div>
|
||||
<div class="toolbar-right">
|
||||
<span class="selected-count">
|
||||
<i18n-t keypath="order.myOrders.selectedCount" tag="span">
|
||||
<i18n-t keypath="order.myOrders.selectedCount" tag="span" scope="global">
|
||||
<template #count>
|
||||
<span class="count-number">{{ selectedRowCount }}</span>
|
||||
</template>
|
||||
|
||||
@ -1989,7 +1989,7 @@
|
||||
|
||||
<div class="toolbar-right">
|
||||
<span class="selected-count">
|
||||
<i18n-t keypath="order.myOrders.selectedCount" tag="span">
|
||||
<i18n-t keypath="order.myOrders.selectedCount" tag="span" scope="global">
|
||||
<template #count>
|
||||
<span class="count-number">{{ selectedRowCount }}</span>
|
||||
</template>
|
||||
|
||||
@ -1292,7 +1292,7 @@ onMounted(async () => {
|
||||
</div>
|
||||
<div class="toolbar-right">
|
||||
<span class="selected-count">
|
||||
<i18n-t keypath="order.pickupOrder.selectedCount" tag="span">
|
||||
<i18n-t keypath="order.pickupOrder.selectedCount" tag="span" scope="global">
|
||||
<template #count>
|
||||
<span class="count-number">{{ selectedRowCount }}</span>
|
||||
</template>
|
||||
|
||||
@ -39,7 +39,7 @@ import SelectDeclarationSkuModal from './components/SelectDeclarationSkuModal.vu
|
||||
import { getDictListAll } from '@/api/system/dict';
|
||||
import { getCountryList } from '@/api/system/country';
|
||||
import { getWarehouseList } from '@/api/system/warehouse';
|
||||
import { mapWarehouseSkuToDeclarationFields, normalizeListRow, pickField } from '@/utils/warehouseListMapper';
|
||||
import { mapWarehouseSkuToDeclarationFields, normalizeListRow, normalizeSkuImageForStorage, pickField } from '@/utils/warehouseListMapper';
|
||||
import { normalizeCargoAttributeCode } from '@/utils/cargoAttribute';
|
||||
import { useRbacUserStore } from '@/store/modules/rbac-user';
|
||||
import { useWarehouseAdminCustomer } from '@/composables/useWarehouseAdminCustomer';
|
||||
@ -2552,6 +2552,7 @@ import SelectDeclarationSkuModal from './components/SelectDeclarationSkuModal.vu
|
||||
amount: parseNumberValue(item.amount) ?? 0,
|
||||
weight: parseNumberValue(item.weight) ?? 0,
|
||||
isMagnetic: Boolean(item.isMagnetic),
|
||||
skuImage: normalizeSkuImageForStorage(item.skuImage),
|
||||
})),
|
||||
};
|
||||
payload.exportCustomsMode = exportMode || resolveExportCustomsMode9610Simple();
|
||||
|
||||
@ -758,7 +758,7 @@ watch(
|
||||
</div>
|
||||
<div class="toolbar-right">
|
||||
<span class="selected-count">
|
||||
<i18n-t keypath="order.myOrders.selectedCount" tag="span">
|
||||
<i18n-t keypath="order.myOrders.selectedCount" tag="span" scope="global">
|
||||
<template #count>
|
||||
<span class="count-number">{{ selectedRowCount }}</span>
|
||||
</template>
|
||||
|
||||
@ -70,6 +70,11 @@
|
||||
getWaybillBaseCatalog,
|
||||
} from './columnConfig';
|
||||
import OrderPrintModal from '@/components/PrintTemplate/OrderPrintModal.vue';
|
||||
import {
|
||||
fetchPrintUrlForOrder,
|
||||
getCachedPrintUrl,
|
||||
prefetchPrintPreview,
|
||||
} from '@/utils/printSessionCache';
|
||||
import { useHiprintClientState } from '@/utils/hiprint/hiprintClientState';
|
||||
import {
|
||||
ORDER_STATUS_TABS,
|
||||
@ -673,6 +678,10 @@
|
||||
}
|
||||
const printConnectionState = useHiprintClientState();
|
||||
const singlePrintVisible = ref(false);
|
||||
const singlePrintPreparing = ref(false);
|
||||
watch(singlePrintVisible, (visible) => {
|
||||
if (!visible) singlePrintPreparing.value = false;
|
||||
});
|
||||
const batchPrintVisible = ref(false);
|
||||
const singlePrintItems = ref<Array<{ id: number | string; label: string; url: string }>>([]);
|
||||
const batchPrintItems = ref<Array<{ id: number | string; label: string; url: string }>>([]);
|
||||
@ -1212,30 +1221,38 @@
|
||||
}
|
||||
|
||||
const handleRowPrint = async (row: any) => {
|
||||
singlePrintVisible.value = false;
|
||||
singlePrintItems.value = [];
|
||||
if (!row || !getOrderRowId(row)) {
|
||||
Message.warning('请选择要打印的订单');
|
||||
return;
|
||||
}
|
||||
const orderId = getOrderRowId(row)!;
|
||||
const cachedUrl = getCachedPrintUrl(orderId);
|
||||
|
||||
if (isUsablePrintUrl(cachedUrl)) {
|
||||
singlePrintVisible.value = true;
|
||||
singlePrintPreparing.value = false;
|
||||
singlePrintItems.value = [buildPrintItem(row, cachedUrl!)];
|
||||
void prefetchPrintPreview(cachedUrl!);
|
||||
return;
|
||||
}
|
||||
|
||||
const printUrlTask = fetchPrintUrlForOrder(orderId);
|
||||
singlePrintVisible.value = true;
|
||||
singlePrintItems.value = [buildPrintItem(row, '')];
|
||||
singlePrintPreparing.value = true;
|
||||
try {
|
||||
await withOrderActionLoading('singlePrint', async () => {
|
||||
const { printUrl } = await postOrderPrint({ id: getOrderRowId(row)! });
|
||||
if (!isUsablePrintUrl(printUrl)) {
|
||||
Message.info('未获取到打印文件,已打开打印弹窗供预览布局');
|
||||
singlePrintVisible.value = true;
|
||||
return;
|
||||
}
|
||||
singlePrintItems.value = [buildPrintItem(row, printUrl)];
|
||||
singlePrintVisible.value = true;
|
||||
if (!printConnectionState.enabled || !printConnectionState.connected) {
|
||||
Message.info('已打开面单预览;静默打印需先在顶部连接打印开关');
|
||||
}
|
||||
});
|
||||
} catch (e: any) {
|
||||
if (e?.message !== 'busy') {
|
||||
Message.error(e?.message || '打印失败');
|
||||
const printUrl = await printUrlTask;
|
||||
singlePrintPreparing.value = false;
|
||||
if (!isUsablePrintUrl(printUrl)) {
|
||||
Message.info('未获取到打印文件');
|
||||
return;
|
||||
}
|
||||
void prefetchPrintPreview(printUrl);
|
||||
singlePrintItems.value = [buildPrintItem(row, printUrl)];
|
||||
} catch (e: any) {
|
||||
singlePrintPreparing.value = false;
|
||||
singlePrintVisible.value = false;
|
||||
Message.error(e?.message || '获取面单失败');
|
||||
}
|
||||
};
|
||||
|
||||
@ -1962,7 +1979,7 @@
|
||||
|
||||
<div class="toolbar-right">
|
||||
<span class="selected-count">
|
||||
<i18n-t keypath="order.myOrders.selectedCount" tag="span">
|
||||
<i18n-t keypath="order.myOrders.selectedCount" tag="span" scope="global">
|
||||
<template #count>
|
||||
<span class="count-number">{{ selectedRowCount }}</span>
|
||||
</template>
|
||||
@ -2038,7 +2055,12 @@
|
||||
:default-keys="WAYBILL_MANAGE_DEFAULT_KEYS"
|
||||
@apply="handleColumnConfigApply"
|
||||
/>
|
||||
<OrderPrintModal v-model:visible="singlePrintVisible" mode="single" :items="singlePrintItems" />
|
||||
<OrderPrintModal
|
||||
v-model:visible="singlePrintVisible"
|
||||
mode="single"
|
||||
:items="singlePrintItems"
|
||||
:preparing="singlePrintPreparing"
|
||||
/>
|
||||
<OrderPrintModal v-model:visible="batchPrintVisible" mode="batch" :items="batchPrintItems" />
|
||||
|
||||
<a-modal
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, reactive, ref } from 'vue'
|
||||
import { computed, onMounted, reactive, ref, watch } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { Modal } from '@arco-design/web-vue'
|
||||
import { IconDelete, IconPlus } from '@arco-design/web-vue/es/icon'
|
||||
import HandsontablePro from '@/components/HandsontablePro/index.vue'
|
||||
import PaginationPro from '@/components/PaginationPro/index.vue'
|
||||
import ModalPro from '@/components/ModalPro/index.vue'
|
||||
@ -105,9 +106,8 @@ const statusTabs = [
|
||||
const slidingStatusTabs = computed(() =>
|
||||
statusTabs.map((tab) => ({
|
||||
key: tab.value,
|
||||
label: tab.countKey
|
||||
? `${t(tab.labelKey)} (${summary.value[tab.countKey]})`
|
||||
: t(tab.labelKey),
|
||||
label: t(tab.labelKey),
|
||||
badge: tab.countKey ? summary.value[tab.countKey] ?? 0 : undefined,
|
||||
})),
|
||||
)
|
||||
|
||||
@ -131,12 +131,20 @@ const formModel = reactive({
|
||||
const boxRows = ref<InboundBoxForm[]>([])
|
||||
|
||||
const boxTabItems = computed(() =>
|
||||
boxRows.value.map((box) => ({
|
||||
key: box.key,
|
||||
label: `${t('warehouse.inbound.box')} ${box.boxSeqNo}`,
|
||||
})),
|
||||
boxRows.value.map((box) => {
|
||||
const filled = box.lines.filter((l) => l.skuId).length
|
||||
return {
|
||||
key: box.key,
|
||||
label:
|
||||
filled > 0
|
||||
? t('warehouse.inbound.form.boxTabWithSku', { n: box.boxSeqNo, sku: filled })
|
||||
: `${t('warehouse.inbound.box')} ${box.boxSeqNo}`,
|
||||
}
|
||||
}),
|
||||
)
|
||||
|
||||
const canRemoveBox = computed(() => boxRows.value.length > 1)
|
||||
|
||||
const modalWarehouseName = computed(() => {
|
||||
const wh = warehouseOptions.value.find((w) => w.value === formModel.warehouseId)
|
||||
return wh?.label || ''
|
||||
@ -225,7 +233,10 @@ function addBoxes(count: number) {
|
||||
}
|
||||
|
||||
function removeActiveBox() {
|
||||
if (boxRows.value.length <= 1) return
|
||||
if (boxRows.value.length <= 1) {
|
||||
$baseMessage(t('warehouse.inbound.message.keepOneBox'), 'warning')
|
||||
return
|
||||
}
|
||||
const key = activeBoxKey.value
|
||||
const remain = boxRows.value.filter((b) => b.key !== key)
|
||||
boxRows.value = remain
|
||||
@ -233,23 +244,11 @@ function removeActiveBox() {
|
||||
activeBoxKey.value = remain[remain.length - 1]?.key || ''
|
||||
}
|
||||
|
||||
function removeSelectedBoxes() {
|
||||
if (!selectedBoxKeys.value.length) {
|
||||
removeActiveBox()
|
||||
function removeLine(box: InboundBoxForm, index: number) {
|
||||
if (box.lines.length <= 1) {
|
||||
box.lines[0] = { skuId: undefined, skuCode: '', plannedQty: 1 }
|
||||
return
|
||||
}
|
||||
const remain = boxRows.value.filter((b) => !selectedBoxKeys.value.includes(b.key))
|
||||
boxRows.value = remain.length ? remain : [createBox(1)]
|
||||
selectedBoxKeys.value = []
|
||||
activeBoxKey.value = boxRows.value[boxRows.value.length - 1].key
|
||||
}
|
||||
|
||||
function addLine(box: InboundBoxForm) {
|
||||
box.lines.push({ skuId: undefined, skuCode: '', plannedQty: 1 })
|
||||
}
|
||||
|
||||
function removeLine(box: InboundBoxForm, index: number) {
|
||||
if (box.lines.length <= 1) return
|
||||
box.lines.splice(index, 1)
|
||||
}
|
||||
|
||||
@ -259,6 +258,19 @@ function onSkuChange(line: InboundLineForm, skuId?: number) {
|
||||
line.skuCode = sku?.code || ''
|
||||
}
|
||||
|
||||
watch(
|
||||
boxRows,
|
||||
(boxes) => {
|
||||
for (const box of boxes) {
|
||||
const last = box.lines[box.lines.length - 1]
|
||||
if (last?.skuId) {
|
||||
box.lines.push({ skuId: undefined, skuCode: '', plannedQty: 1 })
|
||||
}
|
||||
}
|
||||
},
|
||||
{ deep: true },
|
||||
)
|
||||
|
||||
function mapRow(raw: Record<string, unknown>) {
|
||||
const row = normalizeListRow(raw)
|
||||
const status = String(pickField(row, 'receiptStatus', 'ReceiptStatus') ?? '')
|
||||
@ -738,129 +750,195 @@ onMounted(async () => {
|
||||
|
||||
<ModalPro
|
||||
:title="t('warehouse.inbound.modal.add')"
|
||||
:width="800"
|
||||
:width="860"
|
||||
:mask-closable="false"
|
||||
:body-style="{ maxHeight: '70vh', overflow: 'auto' }"
|
||||
@register="registerFormModal"
|
||||
@cancel="closeModal"
|
||||
>
|
||||
<div class="wh-form-modal">
|
||||
<a-form
|
||||
:model="formModel"
|
||||
layout="horizontal"
|
||||
:label-col-props="{ span: 6 }"
|
||||
:wrapper-col-props="{ span: 16 }"
|
||||
>
|
||||
<a-form-item :label="t('warehouse.parcel.form.currentWarehouse')" required>
|
||||
<span class="wh-form-readonly">
|
||||
{{
|
||||
modalWarehouseName
|
||||
|| warehouseOptions.find((o) => o.value === formModel.warehouseId)?.label
|
||||
|| currentWarehouseStore.warehouseName
|
||||
|| formModel.warehouseId
|
||||
|| '-'
|
||||
}}
|
||||
</span>
|
||||
</a-form-item>
|
||||
<a-form-item :label="t('warehouse.inbound.form.markReference')">
|
||||
<a-input v-model="formModel.markReference" :placeholder="t('warehouse.inbound.form.markPlaceholder')" allow-clear />
|
||||
</a-form-item>
|
||||
<a-form-item :label="t('warehouse.inbound.table.inboundType')">
|
||||
<a-select v-model="formModel.inboundType">
|
||||
<a-option value="normal">{{ t('warehouse.inbound.type.normal') }}</a-option>
|
||||
<a-option value="return">{{ t('warehouse.inbound.type.return') }}</a-option>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
<div class="wh-form-info-bar">
|
||||
{{ t('warehouse.parcel.form.currentWarehouse') }}:{{
|
||||
modalWarehouseName
|
||||
|| warehouseOptions.find((o) => o.value === formModel.warehouseId)?.label
|
||||
|| currentWarehouseStore.warehouseName
|
||||
|| formModel.warehouseId
|
||||
|| '-'
|
||||
}}
|
||||
</div>
|
||||
|
||||
<div class="wh-form-section__title">{{ t('warehouse.modal.section.basic') }}</div>
|
||||
<a-form :model="formModel" layout="horizontal" class="inbound-form-basic">
|
||||
<a-row :gutter="16">
|
||||
<a-col :span="14">
|
||||
<a-form-item :label="t('warehouse.inbound.form.markReference')">
|
||||
<a-input
|
||||
v-model="formModel.markReference"
|
||||
:placeholder="t('warehouse.inbound.form.markPlaceholder')"
|
||||
allow-clear
|
||||
/>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="10">
|
||||
<a-form-item :label="t('warehouse.inbound.table.inboundType')">
|
||||
<a-select v-model="formModel.inboundType">
|
||||
<a-option value="normal">{{ t('warehouse.inbound.type.normal') }}</a-option>
|
||||
<a-option value="return">{{ t('warehouse.inbound.type.return') }}</a-option>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
<a-form-item :label="t('warehouse.parcel.form.remark')">
|
||||
<a-input v-model="formModel.remark" allow-clear />
|
||||
<a-input
|
||||
v-model="formModel.remark"
|
||||
allow-clear
|
||||
:placeholder="t('warehouse.inbound.form.remarkPlaceholder')"
|
||||
/>
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
|
||||
<a-divider class="wh-form-divider" />
|
||||
|
||||
<div class="wh-form-section__head">
|
||||
<div class="wh-form-section__title">{{ t('warehouse.inbound.form.boxSkuDetail') }}</div>
|
||||
<div class="wh-form-meta">
|
||||
<a-tag color="arcoblue">{{ t('warehouse.inbound.form.boxCount', { n: boxCount }) }}</a-tag>
|
||||
<a-tag color="green">{{ t('warehouse.inbound.form.skuCount', { n: totalSkuCount }) }}</a-tag>
|
||||
<a-tag color="purple">{{ t('warehouse.inbound.form.totalQty', { n: totalPlannedQty }) }}</a-tag>
|
||||
<div class="wh-form-section__title">
|
||||
{{ t('warehouse.inbound.form.boxSkuDetail') }}
|
||||
<span class="wh-form-section__count">
|
||||
{{ t('warehouse.inbound.form.summaryMeta', {
|
||||
box: boxCount,
|
||||
sku: totalSkuCount,
|
||||
qty: totalPlannedQty,
|
||||
}) }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="wh-form-toolbar">
|
||||
<a-button type="primary" size="small" @click="addBox">{{ t('warehouse.inbound.actions.addBox') }}</a-button>
|
||||
<a-button size="small" @click="addBoxes(5)">{{ t('warehouse.inbound.actions.addBox5') }}</a-button>
|
||||
<a-button size="small" status="danger" @click="removeSelectedBoxes">{{ t('warehouse.inbound.actions.removeBox') }}</a-button>
|
||||
<a-space :size="8">
|
||||
<a-button size="mini" @click="addBox">
|
||||
<template #icon><IconPlus :size="12" /></template>
|
||||
{{ t('warehouse.inbound.actions.addBox') }}
|
||||
</a-button>
|
||||
<a-button size="mini" @click="addBoxes(5)">
|
||||
{{ t('warehouse.inbound.actions.addBox5') }}
|
||||
</a-button>
|
||||
<a-button
|
||||
size="mini"
|
||||
status="danger"
|
||||
:disabled="!canRemoveBox"
|
||||
@click="removeActiveBox"
|
||||
>
|
||||
{{ t('warehouse.inbound.actions.removeCurrentBox') }}
|
||||
</a-button>
|
||||
</a-space>
|
||||
</div>
|
||||
|
||||
<div class="wh-form-box-tabs">
|
||||
<SlidingTabs v-model="activeBoxKey" size="mini" :items="boxTabItems" />
|
||||
</div>
|
||||
|
||||
<div
|
||||
v-for="box in boxRows"
|
||||
v-show="activeBoxKey === box.key"
|
||||
:key="box.key"
|
||||
class="wh-form-box-panel"
|
||||
class="wh-form-box-panel inbound-box-panel"
|
||||
>
|
||||
<a-row :gutter="12">
|
||||
<a-col :span="8">
|
||||
<a-form-item :label="t('warehouse.inbound.form.markBoxNo')" :label-col-props="{ span: 24 }">
|
||||
<a-input v-model="box.markBoxNo" allow-clear />
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="4">
|
||||
<a-form-item :label="t('warehouse.inbound.form.boxWeight')" :label-col-props="{ span: 24 }">
|
||||
<a-input-number v-model="box.weightG" :min="0" style="width: 100%" />
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="4">
|
||||
<a-form-item :label="t('warehouse.inbound.form.boxLength')" :label-col-props="{ span: 24 }">
|
||||
<a-input-number v-model="box.lengthCm" :min="0" style="width: 100%" />
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="4">
|
||||
<a-form-item :label="t('warehouse.inbound.form.boxWidth')" :label-col-props="{ span: 24 }">
|
||||
<a-input-number v-model="box.widthCm" :min="0" style="width: 100%" />
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="4">
|
||||
<a-form-item :label="t('warehouse.inbound.form.boxHeight')" :label-col-props="{ span: 24 }">
|
||||
<a-input-number v-model="box.heightCm" :min="0" style="width: 100%" />
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
|
||||
<div class="wh-form-toolbar">
|
||||
<a-button type="primary" size="small" @click="addLine(box)">{{ t('warehouse.inbound.actions.addSku') }}</a-button>
|
||||
<div class="inbound-box-meta">
|
||||
<div class="inbound-box-meta__field inbound-box-meta__field--mark">
|
||||
<span class="inbound-box-meta__label">{{ t('warehouse.inbound.form.markBoxNo') }}</span>
|
||||
<a-input
|
||||
v-model="box.markBoxNo"
|
||||
allow-clear
|
||||
:placeholder="t('warehouse.inbound.form.markBoxNoPlaceholder')"
|
||||
/>
|
||||
</div>
|
||||
<div class="inbound-box-meta__field inbound-box-meta__field--weight">
|
||||
<span class="inbound-box-meta__label">{{ t('warehouse.inbound.form.boxWeight') }}</span>
|
||||
<a-input-number
|
||||
v-model="box.weightG"
|
||||
:min="0"
|
||||
style="width: 100%"
|
||||
:placeholder="t('warehouse.inbound.form.optional')"
|
||||
>
|
||||
<template #suffix>g</template>
|
||||
</a-input-number>
|
||||
</div>
|
||||
<div class="inbound-box-meta__field inbound-box-meta__field--size">
|
||||
<span class="inbound-box-meta__label">{{ t('warehouse.inbound.form.boxSize') }}</span>
|
||||
<div class="inbound-box-size">
|
||||
<a-input-number
|
||||
v-model="box.lengthCm"
|
||||
:min="0"
|
||||
:placeholder="t('warehouse.sku.form.length')"
|
||||
>
|
||||
<template #suffix>cm</template>
|
||||
</a-input-number>
|
||||
<span>×</span>
|
||||
<a-input-number
|
||||
v-model="box.widthCm"
|
||||
:min="0"
|
||||
:placeholder="t('warehouse.sku.form.width')"
|
||||
>
|
||||
<template #suffix>cm</template>
|
||||
</a-input-number>
|
||||
<span>×</span>
|
||||
<a-input-number
|
||||
v-model="box.heightCm"
|
||||
:min="0"
|
||||
:placeholder="t('warehouse.sku.form.height')"
|
||||
>
|
||||
<template #suffix>cm</template>
|
||||
</a-input-number>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<a-table :data="box.lines" :pagination="false" size="small" :bordered="{ cell: true }">
|
||||
<template #columns>
|
||||
<a-table-column :title="t('warehouse.inbound.form.sku')">
|
||||
<template #cell="{ record }">
|
||||
<a-select
|
||||
v-model="record.skuId"
|
||||
:options="skuOptions"
|
||||
allow-search
|
||||
:placeholder="t('warehouse.inbound.form.selectSku')"
|
||||
@change="(v: number) => onSkuChange(record, v)"
|
||||
/>
|
||||
</template>
|
||||
</a-table-column>
|
||||
<a-table-column :title="t('warehouse.inbound.line.plannedQty')" :width="130">
|
||||
<template #cell="{ record }">
|
||||
<a-input-number v-model="record.plannedQty" :min="1" style="width: 100%" />
|
||||
</template>
|
||||
</a-table-column>
|
||||
<a-table-column :title="t('warehouse.common.delete')" :width="72" align="center">
|
||||
<template #cell="{ rowIndex }">
|
||||
<a-button type="text" status="danger" size="small" @click="removeLine(box, rowIndex)">
|
||||
{{ t('warehouse.common.delete') }}
|
||||
</a-button>
|
||||
</template>
|
||||
</a-table-column>
|
||||
<div class="inbound-sku-head">
|
||||
<span class="wh-form-hint">{{ t('warehouse.inbound.form.autoAddSkuRow') }}</span>
|
||||
</div>
|
||||
|
||||
<a-table
|
||||
class="inbound-sku-table"
|
||||
:data="box.lines"
|
||||
:pagination="false"
|
||||
size="small"
|
||||
:bordered="{ cell: true }"
|
||||
>
|
||||
<template #columns>
|
||||
<a-table-column :title="'#'" :width="44">
|
||||
<template #cell="{ rowIndex }">{{ rowIndex + 1 }}</template>
|
||||
</a-table-column>
|
||||
<a-table-column :title="t('warehouse.inbound.form.sku')" :min-width="220">
|
||||
<template #cell="{ record }">
|
||||
<a-select
|
||||
v-model="record.skuId"
|
||||
:options="skuOptions"
|
||||
allow-search
|
||||
allow-clear
|
||||
:placeholder="t('warehouse.inbound.form.selectSku')"
|
||||
@change="(v: number) => onSkuChange(record, v)"
|
||||
/>
|
||||
</template>
|
||||
</a-table>
|
||||
</a-table-column>
|
||||
<a-table-column :title="t('warehouse.inbound.line.plannedQty')" :width="120">
|
||||
<template #cell="{ record }">
|
||||
<a-input-number v-model="record.plannedQty" :min="1" style="width: 100%" />
|
||||
</template>
|
||||
</a-table-column>
|
||||
<a-table-column :title="t('common.actions')" :width="64" align="center">
|
||||
<template #cell="{ rowIndex, record }">
|
||||
<div class="inbound-action-cell">
|
||||
<a-button
|
||||
v-if="record.skuId || box.lines.length > 1"
|
||||
type="text"
|
||||
status="danger"
|
||||
size="mini"
|
||||
:aria-label="t('warehouse.common.delete')"
|
||||
@click="removeLine(box, rowIndex)"
|
||||
>
|
||||
<IconDelete :size="16" />
|
||||
</a-button>
|
||||
</div>
|
||||
</template>
|
||||
</a-table-column>
|
||||
</template>
|
||||
</a-table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -891,4 +969,108 @@ onMounted(async () => {
|
||||
.receive-box-block {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.wh-form-section__count {
|
||||
margin-left: 8px;
|
||||
font-size: 12px;
|
||||
font-weight: 400;
|
||||
color: var(--color-text-3);
|
||||
}
|
||||
|
||||
.inbound-form-basic {
|
||||
:deep(.arco-form-item) {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
:deep(.arco-form-item-label-col) {
|
||||
flex: 0 0 72px;
|
||||
width: 72px;
|
||||
max-width: 72px;
|
||||
}
|
||||
|
||||
:deep(.arco-form-item-wrapper-col) {
|
||||
flex: 1;
|
||||
width: auto;
|
||||
max-width: none;
|
||||
}
|
||||
|
||||
:deep(.arco-form-item-label) {
|
||||
justify-content: flex-end;
|
||||
}
|
||||
}
|
||||
|
||||
.inbound-box-panel {
|
||||
padding: 12px;
|
||||
}
|
||||
|
||||
.inbound-box-meta {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 12px 16px;
|
||||
margin-bottom: 12px;
|
||||
align-items: flex-end;
|
||||
}
|
||||
|
||||
.inbound-box-meta__field {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
min-width: 0;
|
||||
|
||||
&--mark {
|
||||
flex: 1 1 160px;
|
||||
}
|
||||
|
||||
&--weight {
|
||||
flex: 0 0 120px;
|
||||
}
|
||||
|
||||
&--size {
|
||||
flex: 1 1 320px;
|
||||
}
|
||||
}
|
||||
|
||||
.inbound-box-meta__label {
|
||||
font-size: 12px;
|
||||
color: var(--color-text-3);
|
||||
line-height: 1.2;
|
||||
}
|
||||
|
||||
.inbound-box-size {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
|
||||
:deep(.arco-input-number) {
|
||||
width: 96px;
|
||||
}
|
||||
|
||||
> span {
|
||||
color: var(--color-text-3);
|
||||
}
|
||||
}
|
||||
|
||||
.inbound-sku-head {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.inbound-sku-table {
|
||||
:deep(.arco-table-td) {
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
:deep(.arco-table-cell) {
|
||||
padding-top: 6px;
|
||||
padding-bottom: 6px;
|
||||
}
|
||||
}
|
||||
|
||||
.inbound-action-cell {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
min-height: 32px;
|
||||
}
|
||||
</style>
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
import { computed, onMounted, reactive, ref, watch } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { Modal } from '@arco-design/web-vue'
|
||||
import { IconImage } from '@arco-design/web-vue/es/icon'
|
||||
import { IconDelete, IconImage } from '@arco-design/web-vue/es/icon'
|
||||
import HandsontablePro from '@/components/HandsontablePro/index.vue'
|
||||
import PaginationPro from '@/components/PaginationPro/index.vue'
|
||||
import ModalPro from '@/components/ModalPro/index.vue'
|
||||
@ -11,6 +11,7 @@ import { useTableContainerHeight } from '@/composables/useTableContainerHeight'
|
||||
import {
|
||||
deleteWarehouseParcel,
|
||||
getWarehouseParcelList,
|
||||
getWarehouseParcelSummary,
|
||||
saveWarehouseParcel,
|
||||
uploadWarehouseParcelImage,
|
||||
} from '@/api/warehouse'
|
||||
@ -88,16 +89,19 @@ const pageSize = ref(50)
|
||||
const totalCount = ref(0)
|
||||
|
||||
const statusTabs = [
|
||||
{ value: STATUS_TAB_ALL, labelKey: 'warehouse.parcel.status.all' },
|
||||
{ value: 'inTransit', labelKey: 'warehouse.parcel.status.inTransit' },
|
||||
{ value: 'arrived', labelKey: 'warehouse.parcel.status.arrived' },
|
||||
{ value: 'stored', labelKey: 'warehouse.parcel.status.stored' },
|
||||
{ value: STATUS_TAB_ALL, labelKey: 'warehouse.parcel.status.all', countKey: null },
|
||||
{ value: 'inTransit', labelKey: 'warehouse.parcel.status.inTransit', countKey: 'inTransit' as const },
|
||||
{ value: 'arrived', labelKey: 'warehouse.parcel.status.arrived', countKey: 'arrived' as const },
|
||||
{ value: 'stored', labelKey: 'warehouse.parcel.status.stored', countKey: 'stored' as const },
|
||||
]
|
||||
|
||||
const statusSummary = ref({ inTransit: 0, arrived: 0, stored: 0 })
|
||||
|
||||
const slidingStatusTabs = computed(() =>
|
||||
statusTabs.map((tab) => ({
|
||||
key: tab.value,
|
||||
label: t(tab.labelKey),
|
||||
badge: tab.countKey ? statusSummary.value[tab.countKey] ?? 0 : undefined,
|
||||
})),
|
||||
)
|
||||
|
||||
@ -116,6 +120,14 @@ const itemRows = ref<ParcelItemRow[]>([
|
||||
])
|
||||
|
||||
const filledItemCount = computed(() => itemRows.value.filter((r) => r.productName.trim()).length)
|
||||
const itemsRequiredHintVisible = ref(false)
|
||||
const currentWarehouseLabel = computed(
|
||||
() =>
|
||||
warehouseOptions.value.find((o) => o.value === formModel.warehouseId)?.label
|
||||
|| currentWarehouseStore.warehouseName
|
||||
|| (formModel.warehouseId != null ? String(formModel.warehouseId) : '')
|
||||
|| '-',
|
||||
)
|
||||
|
||||
const DETAIL_COLUMN_KEYS = new Set(['itemsSummary', 'attributeSummary', 'quantitySummary'])
|
||||
const detailVisible = ref(false)
|
||||
@ -343,17 +355,6 @@ async function handleItemImageUpload(rowIndex: number, options: any) {
|
||||
}
|
||||
}
|
||||
|
||||
function clearItemImage(rowIndex: number) {
|
||||
const row = itemRows.value[rowIndex]
|
||||
if (row) {
|
||||
if (row.imagePreviewUrl?.startsWith('blob:')) {
|
||||
URL.revokeObjectURL(row.imagePreviewUrl)
|
||||
}
|
||||
row.imageUrl = ''
|
||||
row.imagePreviewUrl = undefined
|
||||
}
|
||||
}
|
||||
|
||||
function handleEditFromDetail() {
|
||||
const row = detailRow.value
|
||||
if (!row) return
|
||||
@ -361,6 +362,13 @@ function handleEditFromDetail() {
|
||||
handleEdit(row)
|
||||
}
|
||||
|
||||
watch(
|
||||
filledItemCount,
|
||||
(count) => {
|
||||
if (count > 0) itemsRequiredHintVisible.value = false
|
||||
},
|
||||
)
|
||||
|
||||
watch(
|
||||
itemRows,
|
||||
(rows) => {
|
||||
@ -447,6 +455,21 @@ watch(adminCustomerId, (id) => {
|
||||
setRapidPackageCustomerCookie({ id: num, name: opt?.label || String(num) })
|
||||
})
|
||||
|
||||
async function loadSummary() {
|
||||
try {
|
||||
const data = await getWarehouseParcelSummary(withCustomerId({
|
||||
warehouseId: warehouseId.value,
|
||||
}))
|
||||
statusSummary.value = {
|
||||
inTransit: Number(data?.inTransit ?? data?.InTransit ?? 0) || 0,
|
||||
arrived: Number(data?.arrived ?? data?.Arrived ?? 0) || 0,
|
||||
stored: Number(data?.stored ?? data?.Stored ?? 0) || 0,
|
||||
}
|
||||
} catch {
|
||||
statusSummary.value = { inTransit: 0, arrived: 0, stored: 0 }
|
||||
}
|
||||
}
|
||||
|
||||
function resolveLifecycleStatusFilter(): string | undefined {
|
||||
const status = lifecycleStatus.value
|
||||
if (!status || status === STATUS_TAB_ALL) return undefined
|
||||
@ -499,6 +522,7 @@ function handlePageSizeChange(size: number) {
|
||||
|
||||
function handleSearch() {
|
||||
currentPage.value = 1
|
||||
loadSummary()
|
||||
loadList()
|
||||
}
|
||||
|
||||
@ -511,6 +535,7 @@ function handleAdd() {
|
||||
formModel.carrierName = ''
|
||||
formModel.lifecycleStatus = 'inTransit'
|
||||
formModel.remark = ''
|
||||
itemsRequiredHintVisible.value = false
|
||||
resetItems()
|
||||
if (!formModel.warehouseId) {
|
||||
$baseMessage(t('warehouse.common.noCurrentWarehouse'), 'warning')
|
||||
@ -529,6 +554,7 @@ function handleEdit(row: any) {
|
||||
formModel.carrierName = String(pickField(raw, 'carrierName', 'CarrierName') ?? '')
|
||||
formModel.lifecycleStatus = String(pickField(raw, 'lifecycleStatus', 'LifecycleStatus') ?? 'inTransit')
|
||||
formModel.remark = String(pickField(raw, 'remark', 'Remark') ?? '')
|
||||
itemsRequiredHintVisible.value = false
|
||||
const items = pickField(raw, 'items', 'Items')
|
||||
if (Array.isArray(items) && items.length) {
|
||||
itemRows.value = items.map((item: any) => ({
|
||||
@ -570,15 +596,17 @@ async function handleSave() {
|
||||
remark: row.remark || undefined,
|
||||
}))
|
||||
if (!items.length) {
|
||||
itemsRequiredHintVisible.value = true
|
||||
$baseMessage(t('warehouse.parcel.message.itemsRequired'), 'warning')
|
||||
return
|
||||
}
|
||||
itemsRequiredHintVisible.value = false
|
||||
saving.value = true
|
||||
try {
|
||||
await saveWarehouseParcel(withCustomerId({ ...formModel, items }))
|
||||
$baseMessage(t('warehouse.parcel.message.saveSuccess'), 'success')
|
||||
closeModal()
|
||||
await loadList()
|
||||
await Promise.all([loadSummary(), loadList()])
|
||||
} catch (e: any) {
|
||||
$baseMessage(e?.message || t('warehouse.parcel.message.saveFailed'), 'error')
|
||||
} finally {
|
||||
@ -595,7 +623,7 @@ function handleDelete(row: any) {
|
||||
onOk: async () => {
|
||||
await deleteWarehouseParcel(row.id)
|
||||
$baseMessage(t('warehouse.parcel.message.deleteSuccess'), 'success')
|
||||
await loadList()
|
||||
await Promise.all([loadSummary(), loadList()])
|
||||
},
|
||||
})
|
||||
}
|
||||
@ -619,7 +647,7 @@ function handleActionClick(row: any, _i: number, action?: string) {
|
||||
onMounted(async () => {
|
||||
setRapidPackageHostCookie()
|
||||
await loadWarehouses()
|
||||
await loadList()
|
||||
await Promise.all([loadSummary(), loadList()])
|
||||
})
|
||||
</script>
|
||||
|
||||
@ -653,6 +681,7 @@ onMounted(async () => {
|
||||
:placeholder="t('warehouse.common.warehouse')"
|
||||
:options="warehouseOptions"
|
||||
style="width: 200px"
|
||||
@change="handleSearch"
|
||||
/>
|
||||
<a-input
|
||||
v-model="keyword"
|
||||
@ -809,37 +838,46 @@ onMounted(async () => {
|
||||
@cancel="closeModal"
|
||||
>
|
||||
<div class="wh-form-modal">
|
||||
<div v-if="!formModel.id" class="wh-form-info-bar">
|
||||
{{ t('warehouse.parcel.form.currentWarehouse') }}:{{ currentWarehouseLabel }}
|
||||
</div>
|
||||
|
||||
<div class="wh-form-section__title">{{ t('warehouse.modal.section.basic') }}</div>
|
||||
<a-form
|
||||
:model="formModel"
|
||||
layout="horizontal"
|
||||
:label-col-props="{ span: 6 }"
|
||||
:wrapper-col-props="{ span: 16 }"
|
||||
class="parcel-form-basic"
|
||||
>
|
||||
<a-form-item v-if="!formModel.id" :label="t('warehouse.parcel.form.currentWarehouse')" required>
|
||||
<span class="wh-form-readonly">
|
||||
{{
|
||||
warehouseOptions.find((o) => o.value === formModel.warehouseId)?.label
|
||||
|| currentWarehouseStore.warehouseName
|
||||
|| formModel.warehouseId
|
||||
|| '-'
|
||||
}}
|
||||
</span>
|
||||
</a-form-item>
|
||||
<a-form-item v-else :label="t('warehouse.common.warehouse')" required>
|
||||
<a-form-item v-if="formModel.id" :label="t('warehouse.common.warehouse')" required>
|
||||
<a-select v-model="formModel.warehouseId" :options="warehouseOptions" allow-search />
|
||||
</a-form-item>
|
||||
<a-form-item :label="t('warehouse.parcel.form.trackingNo')" required>
|
||||
<a-input v-model="formModel.trackingNo" allow-clear />
|
||||
</a-form-item>
|
||||
<a-form-item :label="t('warehouse.parcel.form.carrierName')">
|
||||
<a-input v-model="formModel.carrierName" allow-clear />
|
||||
</a-form-item>
|
||||
<a-row :gutter="16">
|
||||
<a-col :span="12">
|
||||
<a-form-item :label="t('warehouse.parcel.form.trackingNo')" required>
|
||||
<a-input
|
||||
v-model="formModel.trackingNo"
|
||||
allow-clear
|
||||
:placeholder="t('warehouse.parcel.form.trackingNoPlaceholder')"
|
||||
/>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="12">
|
||||
<a-form-item :label="t('warehouse.parcel.form.carrierName')">
|
||||
<a-input
|
||||
v-model="formModel.carrierName"
|
||||
allow-clear
|
||||
:placeholder="t('warehouse.parcel.form.carrierNamePlaceholder')"
|
||||
/>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
<a-form-item :label="t('warehouse.parcel.form.remark')">
|
||||
<a-textarea
|
||||
v-model="formModel.remark"
|
||||
:max-length="500"
|
||||
show-word-limit
|
||||
:auto-size="{ minRows: 2, maxRows: 4 }"
|
||||
:placeholder="t('warehouse.parcel.form.remarkPlaceholder')"
|
||||
:auto-size="{ minRows: 1, maxRows: 3 }"
|
||||
/>
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
@ -847,96 +885,120 @@ onMounted(async () => {
|
||||
<a-divider class="wh-form-divider" />
|
||||
|
||||
<div class="wh-form-section__head">
|
||||
<div class="wh-form-section__title">{{ t('warehouse.modal.section.products') }}</div>
|
||||
<div class="wh-form-section__title">
|
||||
{{ t('warehouse.modal.section.products') }}
|
||||
<span class="wh-form-section__count">
|
||||
{{ t('warehouse.parcel.form.itemFilledCount', { n: filledItemCount }) }}
|
||||
</span>
|
||||
</div>
|
||||
<span class="wh-form-hint">{{ t('warehouse.parcel.form.autoAddRow') }}</span>
|
||||
</div>
|
||||
|
||||
<a-table :data="itemRows" :pagination="false" size="small" :bordered="{ cell: true }">
|
||||
<a-table
|
||||
class="parcel-item-table"
|
||||
:data="itemRows"
|
||||
:pagination="false"
|
||||
size="small"
|
||||
:bordered="{ cell: true }"
|
||||
:scroll="{ x: '100%' }"
|
||||
>
|
||||
<template #columns>
|
||||
<a-table-column :title="'#'" :width="48">
|
||||
<a-table-column :title="'#'" :width="44">
|
||||
<template #cell="{ rowIndex }">{{ rowIndex + 1 }}</template>
|
||||
</a-table-column>
|
||||
<a-table-column :title="t('warehouse.parcel.form.image')" :width="120">
|
||||
<a-table-column :title="t('warehouse.parcel.form.image')" :width="72" align="center">
|
||||
<template #cell="{ record, rowIndex }">
|
||||
<div class="parcel-item-image-cell">
|
||||
<a-image
|
||||
v-if="record.imageUrl"
|
||||
:src="resolveItemImageSrc(record)"
|
||||
width="36"
|
||||
height="36"
|
||||
fit="cover"
|
||||
:preview="true"
|
||||
class="parcel-item-thumb"
|
||||
/>
|
||||
<span v-else class="parcel-item-thumb parcel-item-thumb--empty">
|
||||
<IconImage :size="18" />
|
||||
</span>
|
||||
<a-upload
|
||||
:show-file-list="false"
|
||||
accept="image/jpeg,image/png,image/webp,image/gif,image/bmp"
|
||||
:custom-request="(opt) => handleItemImageUpload(rowIndex, opt)"
|
||||
>
|
||||
<a-button
|
||||
type="text"
|
||||
size="mini"
|
||||
:loading="imageUploadingIndex === rowIndex"
|
||||
<a-upload
|
||||
class="parcel-item-image-cell"
|
||||
:show-file-list="false"
|
||||
accept="image/jpeg,image/png,image/webp,image/gif,image/bmp"
|
||||
:disabled="imageUploadingIndex === rowIndex"
|
||||
:custom-request="(opt) => handleItemImageUpload(rowIndex, opt)"
|
||||
>
|
||||
<template #upload-button>
|
||||
<div
|
||||
class="parcel-item-upload"
|
||||
:class="{
|
||||
'is-loading': imageUploadingIndex === rowIndex,
|
||||
'has-image': !!record.imageUrl,
|
||||
}"
|
||||
>
|
||||
{{
|
||||
record.imageUrl
|
||||
? t('warehouse.parcel.form.reuploadImage')
|
||||
: t('warehouse.parcel.form.uploadImage')
|
||||
}}
|
||||
</a-button>
|
||||
</a-upload>
|
||||
<a-button
|
||||
v-if="record.imageUrl"
|
||||
type="text"
|
||||
size="mini"
|
||||
status="danger"
|
||||
@click="clearItemImage(rowIndex)"
|
||||
>
|
||||
{{ t('warehouse.parcel.form.clearImage') }}
|
||||
</a-button>
|
||||
</div>
|
||||
<a-spin v-if="imageUploadingIndex === rowIndex" :size="16" />
|
||||
<template v-else-if="record.imageUrl">
|
||||
<img
|
||||
class="parcel-item-thumb"
|
||||
:src="resolveItemImageSrc(record)"
|
||||
alt=""
|
||||
/>
|
||||
<span class="parcel-item-upload__mask">
|
||||
<IconImage :size="14" />
|
||||
</span>
|
||||
</template>
|
||||
<span v-else class="parcel-item-thumb parcel-item-thumb--empty">
|
||||
<IconImage :size="18" />
|
||||
</span>
|
||||
</div>
|
||||
</template>
|
||||
</a-upload>
|
||||
</template>
|
||||
</a-table-column>
|
||||
<a-table-column :title="t('warehouse.parcel.form.productName')">
|
||||
<a-table-column :title="t('warehouse.parcel.form.productName')" :min-width="160">
|
||||
<template #cell="{ record }">
|
||||
<a-input v-model="record.productName" allow-clear />
|
||||
<a-input
|
||||
v-model="record.productName"
|
||||
allow-clear
|
||||
:placeholder="t('warehouse.parcel.form.productNamePlaceholder')"
|
||||
/>
|
||||
</template>
|
||||
</a-table-column>
|
||||
<a-table-column :title="t('warehouse.parcel.form.attribute')" :width="160">
|
||||
<a-table-column :title="t('warehouse.parcel.form.attribute')" :width="140">
|
||||
<template #cell="{ record }">
|
||||
<a-input v-model="record.attributeText" allow-clear />
|
||||
<a-input
|
||||
v-model="record.attributeText"
|
||||
allow-clear
|
||||
:placeholder="t('warehouse.parcel.form.attributePlaceholder')"
|
||||
/>
|
||||
</template>
|
||||
</a-table-column>
|
||||
<a-table-column :title="t('warehouse.parcel.form.quantity')" :width="110">
|
||||
<a-table-column :title="t('warehouse.parcel.form.quantity')" :width="100">
|
||||
<template #cell="{ record }">
|
||||
<a-input-number v-model="record.quantity" :min="1" style="width: 100%" />
|
||||
</template>
|
||||
</a-table-column>
|
||||
<a-table-column :title="t('warehouse.parcel.form.itemRemark')" :width="160">
|
||||
<a-table-column :title="t('warehouse.parcel.form.itemRemark')" :width="140">
|
||||
<template #cell="{ record }">
|
||||
<a-input v-model="record.remark" allow-clear />
|
||||
<a-input
|
||||
v-model="record.remark"
|
||||
allow-clear
|
||||
:placeholder="t('warehouse.parcel.form.itemRemarkPlaceholder')"
|
||||
/>
|
||||
</template>
|
||||
</a-table-column>
|
||||
<a-table-column :title="t('warehouse.common.delete')" :width="72" align="center">
|
||||
<a-table-column :title="t('common.actions')" :width="64" align="center">
|
||||
<template #cell="{ rowIndex, record }">
|
||||
<a-button
|
||||
v-if="record.productName.trim()"
|
||||
type="text"
|
||||
status="danger"
|
||||
size="small"
|
||||
@click="removeItemRow(rowIndex)"
|
||||
>
|
||||
{{ t('warehouse.common.delete') }}
|
||||
</a-button>
|
||||
<div class="parcel-item-action-cell">
|
||||
<a-button
|
||||
v-if="record.productName.trim()"
|
||||
type="text"
|
||||
status="danger"
|
||||
size="mini"
|
||||
:aria-label="t('warehouse.common.delete')"
|
||||
@click="removeItemRow(rowIndex)"
|
||||
>
|
||||
<IconDelete :size="16" />
|
||||
</a-button>
|
||||
</div>
|
||||
</template>
|
||||
</a-table-column>
|
||||
</template>
|
||||
</a-table>
|
||||
|
||||
<a-alert v-if="filledItemCount === 0" type="warning" :show-icon="true" class="wh-form-divider">
|
||||
<a-alert
|
||||
v-if="itemsRequiredHintVisible"
|
||||
type="warning"
|
||||
:show-icon="true"
|
||||
class="wh-form-divider"
|
||||
>
|
||||
{{ t('warehouse.parcel.message.itemsRequired') }}
|
||||
</a-alert>
|
||||
</div>
|
||||
@ -966,6 +1028,53 @@ onMounted(async () => {
|
||||
}
|
||||
}
|
||||
|
||||
.parcel-form-basic {
|
||||
:deep(.arco-form-item) {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
:deep(.arco-form-item-label-col) {
|
||||
flex: 0 0 88px;
|
||||
width: 88px;
|
||||
max-width: 88px;
|
||||
}
|
||||
|
||||
:deep(.arco-form-item-wrapper-col) {
|
||||
flex: 1;
|
||||
width: auto;
|
||||
max-width: none;
|
||||
}
|
||||
|
||||
:deep(.arco-form-item-label) {
|
||||
justify-content: flex-end;
|
||||
}
|
||||
}
|
||||
|
||||
.wh-form-section__count {
|
||||
margin-left: 8px;
|
||||
font-size: 12px;
|
||||
font-weight: 400;
|
||||
color: var(--color-text-3);
|
||||
}
|
||||
|
||||
.parcel-item-table {
|
||||
:deep(.arco-table-td) {
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
:deep(.arco-table-cell) {
|
||||
padding-top: 6px;
|
||||
padding-bottom: 6px;
|
||||
}
|
||||
}
|
||||
|
||||
.parcel-item-action-cell {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
min-height: 32px;
|
||||
}
|
||||
|
||||
.parcel-item-thumb {
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
@ -981,17 +1090,73 @@ onMounted(async () => {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: #c9cdd4;
|
||||
background: var(--color-fill-2);
|
||||
color: var(--color-text-4);
|
||||
background: var(--color-fill-1);
|
||||
border-style: dashed;
|
||||
border-color: var(--color-border-3);
|
||||
transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
|
||||
}
|
||||
}
|
||||
|
||||
.parcel-item-image-cell {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
gap: 2px;
|
||||
padding: 4px 0;
|
||||
display: inline-flex;
|
||||
justify-content: center;
|
||||
line-height: 0;
|
||||
vertical-align: middle;
|
||||
|
||||
:deep(.arco-upload-wrapper),
|
||||
:deep(.arco-upload) {
|
||||
display: inline-flex;
|
||||
line-height: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.parcel-item-upload {
|
||||
position: relative;
|
||||
width: 48px;
|
||||
height: 48px;
|
||||
cursor: pointer;
|
||||
line-height: 0;
|
||||
overflow: hidden;
|
||||
border-radius: 4px;
|
||||
|
||||
.parcel-item-thumb {
|
||||
width: 48px;
|
||||
height: 48px;
|
||||
}
|
||||
|
||||
&:hover .parcel-item-thumb--empty {
|
||||
color: var(--app-primary-color);
|
||||
border-color: var(--app-primary-color);
|
||||
background: var(--color-primary-light-1);
|
||||
}
|
||||
|
||||
&.is-loading {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border: 1px solid var(--color-border-2);
|
||||
background: var(--color-fill-2);
|
||||
box-sizing: border-box;
|
||||
cursor: wait;
|
||||
}
|
||||
|
||||
&.has-image:hover .parcel-item-upload__mask {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
&__mask {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: #fff;
|
||||
background: rgba(0, 0, 0, 0.45);
|
||||
opacity: 0;
|
||||
transition: opacity 0.15s ease;
|
||||
pointer-events: none;
|
||||
}
|
||||
}
|
||||
|
||||
.parcel-image-preview {
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
import { computed, onMounted, reactive, ref } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { Modal } from '@arco-design/web-vue'
|
||||
import { IconDelete, IconImage, IconPlus } from '@arco-design/web-vue/es/icon'
|
||||
import HandsontablePro from '@/components/HandsontablePro/index.vue'
|
||||
import PaginationPro from '@/components/PaginationPro/index.vue'
|
||||
import ModalPro from '@/components/ModalPro/index.vue'
|
||||
@ -90,11 +91,22 @@ const skuImageFileList = ref<any[]>([])
|
||||
const imageUploading = ref(false)
|
||||
/** 直传后的本地预览(blob);详情回填时用接口已签好的 URL */
|
||||
const skuImagePreviewOverride = ref('')
|
||||
const showExtraFields = ref(false)
|
||||
|
||||
const skuImagePreview = computed(
|
||||
() => skuImagePreviewOverride.value || resolveOmsAssetUrl(formModel.skuImageUrl),
|
||||
)
|
||||
|
||||
function hasExtraFieldValues() {
|
||||
return !!(
|
||||
formModel.skuNameEn.trim()
|
||||
|| formModel.unitPrice != null
|
||||
|| formModel.exHsCode.trim()
|
||||
|| formModel.imHsCode.trim()
|
||||
|| formModel.remark.trim()
|
||||
)
|
||||
}
|
||||
|
||||
const currentWarehouseLabel = computed(() => {
|
||||
const id = currentWarehouseStore.resolveDefaultWarehouseId(selectedWarehouseId.value)
|
||||
return (
|
||||
@ -145,6 +157,7 @@ function resetForm() {
|
||||
}
|
||||
skuImagePreviewOverride.value = ''
|
||||
skuImageFileList.value = []
|
||||
showExtraFields.value = false
|
||||
}
|
||||
|
||||
function changeSkuCode() {
|
||||
@ -327,6 +340,7 @@ function handleEdit(row: any) {
|
||||
? formModel.skuImageUrl
|
||||
: ''
|
||||
syncImageFileList()
|
||||
showExtraFields.value = hasExtraFieldValues()
|
||||
openModal(true)
|
||||
}
|
||||
|
||||
@ -456,133 +470,215 @@ onMounted(async () => {
|
||||
|
||||
<ModalPro
|
||||
:title="modalTitle"
|
||||
:width="640"
|
||||
:width="720"
|
||||
:mask-closable="false"
|
||||
:body-style="{ maxHeight: '70vh', overflow: 'auto' }"
|
||||
@register="registerFormModal"
|
||||
@cancel="closeModal"
|
||||
>
|
||||
<div class="wh-form-modal">
|
||||
<div class="wh-form-info-bar">
|
||||
{{ t('warehouse.sku.form.currentWarehouse') }}:{{ currentWarehouseLabel || '-' }}
|
||||
</div>
|
||||
|
||||
<div class="wh-form-section__title">{{ t('warehouse.modal.section.basic') }}</div>
|
||||
<a-form
|
||||
:model="formModel"
|
||||
layout="horizontal"
|
||||
:label-col-props="{ span: 6 }"
|
||||
:wrapper-col-props="{ span: 16 }"
|
||||
>
|
||||
<a-form-item :label="t('warehouse.sku.form.currentWarehouse')">
|
||||
<span class="wh-form-readonly">{{ currentWarehouseLabel || '-' }}</span>
|
||||
</a-form-item>
|
||||
<a-form-item :label="t('warehouse.sku.form.skuCode')" required>
|
||||
<a-input
|
||||
v-if="!formModel.id"
|
||||
v-model="formModel.skuCode"
|
||||
allow-clear
|
||||
@change="changeSkuCode"
|
||||
/>
|
||||
<span v-else class="wh-form-readonly">{{ formModel.skuCode }}</span>
|
||||
</a-form-item>
|
||||
<a-form-item :label="t('warehouse.sku.form.skuName')" required>
|
||||
<a-input v-model="formModel.skuName" allow-clear />
|
||||
</a-form-item>
|
||||
<a-form-item :label="t('warehouse.sku.form.skuNameEn')">
|
||||
<a-input v-model="formModel.skuNameEn" allow-clear />
|
||||
</a-form-item>
|
||||
<a-form-item :label="t('warehouse.sku.form.unitPrice')">
|
||||
<a-input-number v-model="formModel.unitPrice" :min="0" :precision="4" style="width: 160px" />
|
||||
</a-form-item>
|
||||
<a-form-item :label="t('warehouse.sku.form.exHsCode')">
|
||||
<a-input v-model="formModel.exHsCode" allow-clear />
|
||||
</a-form-item>
|
||||
<a-form-item :label="t('warehouse.sku.form.imHsCode')">
|
||||
<a-input v-model="formModel.imHsCode" allow-clear />
|
||||
</a-form-item>
|
||||
<a-form :model="formModel" layout="horizontal" class="sku-form">
|
||||
<a-row :gutter="16">
|
||||
<a-col :span="12">
|
||||
<a-form-item :label="t('warehouse.sku.form.skuCode')" required>
|
||||
<a-input
|
||||
v-if="!formModel.id"
|
||||
v-model="formModel.skuCode"
|
||||
allow-clear
|
||||
:placeholder="t('warehouse.sku.form.skuCodePlaceholder')"
|
||||
@change="changeSkuCode"
|
||||
/>
|
||||
<span v-else class="wh-form-readonly">{{ formModel.skuCode }}</span>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="12">
|
||||
<a-form-item :label="t('warehouse.sku.form.skuName')" required>
|
||||
<a-input
|
||||
v-model="formModel.skuName"
|
||||
allow-clear
|
||||
:placeholder="t('warehouse.sku.form.skuNamePlaceholder')"
|
||||
/>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
|
||||
<a-form-item :label="t('warehouse.sku.form.imageUrl')">
|
||||
<div class="wh-form-sku-preview">
|
||||
<div class="wh-form-sku-preview__image">
|
||||
<img v-if="skuImagePreview" :src="skuImagePreview" alt="sku" />
|
||||
<span v-else class="wh-form-hint">-</span>
|
||||
</div>
|
||||
<div class="wh-form-sku-preview__fields">
|
||||
<a-upload
|
||||
:file-list="skuImageFileList"
|
||||
:custom-request="handleSkuImageUpload"
|
||||
:show-file-list="false"
|
||||
accept="image/jpeg,image/png,image/webp,image/gif,image/bmp"
|
||||
:disabled="imageUploading"
|
||||
>
|
||||
<a-button type="outline" :loading="imageUploading">
|
||||
{{
|
||||
formModel.skuImageUrl
|
||||
? t('warehouse.sku.form.reuploadImage')
|
||||
: t('warehouse.sku.form.uploadImage')
|
||||
}}
|
||||
</a-button>
|
||||
</a-upload>
|
||||
<a-button
|
||||
v-if="formModel.skuImageUrl"
|
||||
type="text"
|
||||
status="danger"
|
||||
@click="clearSkuImage"
|
||||
>
|
||||
{{ t('warehouse.sku.form.clearImage') }}
|
||||
</a-button>
|
||||
</div>
|
||||
<div class="sku-image-field">
|
||||
<a-upload
|
||||
class="sku-image-upload"
|
||||
:file-list="skuImageFileList"
|
||||
:custom-request="handleSkuImageUpload"
|
||||
:show-file-list="false"
|
||||
accept="image/jpeg,image/png,image/webp,image/gif,image/bmp"
|
||||
:disabled="imageUploading"
|
||||
>
|
||||
<template #upload-button>
|
||||
<div
|
||||
class="sku-image-upload__trigger"
|
||||
:class="{
|
||||
'is-loading': imageUploading,
|
||||
'has-image': !!skuImagePreview,
|
||||
}"
|
||||
>
|
||||
<a-spin v-if="imageUploading" :size="18" />
|
||||
<template v-else-if="skuImagePreview">
|
||||
<img :src="skuImagePreview" alt="sku" />
|
||||
<span class="sku-image-upload__mask">
|
||||
<IconImage :size="16" />
|
||||
<em>{{ t('warehouse.sku.form.reuploadImage') }}</em>
|
||||
</span>
|
||||
</template>
|
||||
<span v-else class="sku-image-upload__empty">
|
||||
<IconPlus :size="18" />
|
||||
<em>{{ t('warehouse.sku.form.uploadImage') }}</em>
|
||||
</span>
|
||||
</div>
|
||||
</template>
|
||||
</a-upload>
|
||||
<a-button
|
||||
v-if="formModel.skuImageUrl"
|
||||
type="text"
|
||||
status="danger"
|
||||
size="mini"
|
||||
class="sku-image-clear"
|
||||
:aria-label="t('warehouse.sku.form.clearImage')"
|
||||
@click="clearSkuImage"
|
||||
>
|
||||
<IconDelete :size="14" />
|
||||
{{ t('warehouse.sku.form.clearImage') }}
|
||||
</a-button>
|
||||
</div>
|
||||
</a-form-item>
|
||||
<a-form-item :label="t('warehouse.sku.form.remark')">
|
||||
<a-textarea v-model="formModel.remark" :auto-size="{ minRows: 2, maxRows: 4 }" />
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
|
||||
<a-divider class="wh-form-divider" />
|
||||
|
||||
<div class="wh-form-section__title">{{ t('warehouse.modal.section.weightSize') }}</div>
|
||||
<a-form
|
||||
:model="formModel"
|
||||
layout="horizontal"
|
||||
:label-col-props="{ span: 6 }"
|
||||
:wrapper-col-props="{ span: 16 }"
|
||||
>
|
||||
<a-form-item :label="t('warehouse.sku.form.weightG')">
|
||||
<a-input-number v-model="formModel.weightG" :min="0" style="width: 160px">
|
||||
<template #suffix>g</template>
|
||||
</a-input-number>
|
||||
</a-form-item>
|
||||
<div class="wh-form-section__head">
|
||||
<div class="wh-form-section__title">{{ t('warehouse.modal.section.weightSize') }}</div>
|
||||
<a-button
|
||||
v-if="formModel.lengthCm || formModel.widthCm || formModel.heightCm"
|
||||
type="text"
|
||||
size="mini"
|
||||
@click="clearSkuSize"
|
||||
>
|
||||
{{ t('warehouse.sku.form.clearSize') }}
|
||||
</a-button>
|
||||
</div>
|
||||
<a-form :model="formModel" layout="horizontal" class="sku-form">
|
||||
<a-row :gutter="16">
|
||||
<a-col :span="12">
|
||||
<a-form-item :label="t('warehouse.sku.form.weightG')">
|
||||
<a-input-number
|
||||
v-model="formModel.weightG"
|
||||
:min="0"
|
||||
style="width: 100%"
|
||||
:placeholder="t('warehouse.sku.form.weightPlaceholder')"
|
||||
>
|
||||
<template #suffix>g</template>
|
||||
</a-input-number>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="12">
|
||||
<a-form-item :label="t('warehouse.sku.form.volumeEstimate')">
|
||||
<span class="sku-volume-text">{{ skuVolumeText }}</span>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
<a-form-item :label="t('warehouse.sku.form.dimensions')">
|
||||
<div>
|
||||
<div class="wh-form-inline-size">
|
||||
<a-input-number
|
||||
v-model="formModel.lengthCm"
|
||||
:min="0"
|
||||
style="width: 110px"
|
||||
:placeholder="t('warehouse.sku.form.length')"
|
||||
>
|
||||
<template #suffix>cm</template>
|
||||
</a-input-number>
|
||||
<a-input-number
|
||||
v-model="formModel.widthCm"
|
||||
:min="0"
|
||||
style="width: 110px"
|
||||
:placeholder="t('warehouse.sku.form.width')"
|
||||
>
|
||||
<template #suffix>cm</template>
|
||||
</a-input-number>
|
||||
<a-input-number
|
||||
v-model="formModel.heightCm"
|
||||
:min="0"
|
||||
style="width: 110px"
|
||||
:placeholder="t('warehouse.sku.form.height')"
|
||||
>
|
||||
<template #suffix>cm</template>
|
||||
</a-input-number>
|
||||
<a-button type="text" @click="clearSkuSize">{{ t('warehouse.sku.form.clearSize') }}</a-button>
|
||||
</div>
|
||||
<div class="wh-form-volume">
|
||||
{{ t('warehouse.sku.form.volumeEstimate') }}:{{ skuVolumeText }}
|
||||
</div>
|
||||
<div class="wh-form-inline-size">
|
||||
<a-input-number
|
||||
v-model="formModel.lengthCm"
|
||||
:min="0"
|
||||
style="width: 112px"
|
||||
:placeholder="t('warehouse.sku.form.length')"
|
||||
>
|
||||
<template #suffix>cm</template>
|
||||
</a-input-number>
|
||||
<span class="sku-size-x">×</span>
|
||||
<a-input-number
|
||||
v-model="formModel.widthCm"
|
||||
:min="0"
|
||||
style="width: 112px"
|
||||
:placeholder="t('warehouse.sku.form.width')"
|
||||
>
|
||||
<template #suffix>cm</template>
|
||||
</a-input-number>
|
||||
<span class="sku-size-x">×</span>
|
||||
<a-input-number
|
||||
v-model="formModel.heightCm"
|
||||
:min="0"
|
||||
style="width: 112px"
|
||||
:placeholder="t('warehouse.sku.form.height')"
|
||||
>
|
||||
<template #suffix>cm</template>
|
||||
</a-input-number>
|
||||
</div>
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
|
||||
<div class="sku-extra-toggle">
|
||||
<a-button type="text" size="small" @click="showExtraFields = !showExtraFields">
|
||||
{{
|
||||
showExtraFields
|
||||
? t('warehouse.sku.form.hideExtra')
|
||||
: t('warehouse.sku.form.showExtra')
|
||||
}}
|
||||
</a-button>
|
||||
</div>
|
||||
|
||||
<template v-if="showExtraFields">
|
||||
<div class="wh-form-section__title">{{ t('warehouse.modal.section.declarationExtra') }}</div>
|
||||
<a-form :model="formModel" layout="horizontal" class="sku-form">
|
||||
<a-form-item :label="t('warehouse.sku.form.skuNameEn')">
|
||||
<a-input
|
||||
v-model="formModel.skuNameEn"
|
||||
allow-clear
|
||||
:placeholder="t('warehouse.sku.form.skuNameEnPlaceholder')"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item :label="t('warehouse.sku.form.unitPrice')">
|
||||
<a-input-number
|
||||
v-model="formModel.unitPrice"
|
||||
:min="0"
|
||||
:precision="4"
|
||||
style="width: 200px"
|
||||
:placeholder="t('warehouse.sku.form.unitPricePlaceholder')"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-row :gutter="16">
|
||||
<a-col :span="12">
|
||||
<a-form-item :label="t('warehouse.sku.form.exHsCode')">
|
||||
<a-input
|
||||
v-model="formModel.exHsCode"
|
||||
allow-clear
|
||||
:placeholder="t('warehouse.sku.form.exHsCodePlaceholder')"
|
||||
/>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="12">
|
||||
<a-form-item :label="t('warehouse.sku.form.imHsCode')">
|
||||
<a-input
|
||||
v-model="formModel.imHsCode"
|
||||
allow-clear
|
||||
:placeholder="t('warehouse.sku.form.imHsCodePlaceholder')"
|
||||
/>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
<a-form-item :label="t('warehouse.sku.form.remark')">
|
||||
<a-textarea
|
||||
v-model="formModel.remark"
|
||||
:max-length="500"
|
||||
show-word-limit
|
||||
:placeholder="t('warehouse.sku.form.remarkPlaceholder')"
|
||||
:auto-size="{ minRows: 1, maxRows: 3 }"
|
||||
/>
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
</template>
|
||||
</div>
|
||||
|
||||
<template #footer>
|
||||
@ -598,4 +694,140 @@ onMounted(async () => {
|
||||
<style scoped lang="less">
|
||||
@import '@/styles/warehouse-list-page.less';
|
||||
@import '@/styles/warehouse-form-modal.less';
|
||||
|
||||
.sku-form {
|
||||
:deep(.arco-form-item) {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
:deep(.arco-form-item-label-col) {
|
||||
flex: 0 0 96px;
|
||||
width: 96px;
|
||||
max-width: 96px;
|
||||
}
|
||||
|
||||
:deep(.arco-form-item-wrapper-col) {
|
||||
flex: 1;
|
||||
width: auto;
|
||||
max-width: none;
|
||||
}
|
||||
|
||||
:deep(.arco-form-item-label) {
|
||||
justify-content: flex-end;
|
||||
white-space: nowrap;
|
||||
}
|
||||
}
|
||||
|
||||
.sku-image-field {
|
||||
display: flex;
|
||||
align-items: flex-end;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.sku-image-upload {
|
||||
line-height: 0;
|
||||
|
||||
:deep(.arco-upload),
|
||||
:deep(.arco-upload-wrapper) {
|
||||
display: inline-flex;
|
||||
line-height: 0;
|
||||
}
|
||||
|
||||
&__trigger {
|
||||
position: relative;
|
||||
width: 88px;
|
||||
height: 88px;
|
||||
border-radius: 4px;
|
||||
overflow: hidden;
|
||||
cursor: pointer;
|
||||
box-sizing: border-box;
|
||||
border: 1px dashed var(--color-border-3);
|
||||
background: var(--color-fill-1);
|
||||
|
||||
img {
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
}
|
||||
|
||||
&.has-image {
|
||||
border-style: solid;
|
||||
border-color: var(--color-border-2);
|
||||
}
|
||||
|
||||
&.is-loading {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
cursor: wait;
|
||||
}
|
||||
|
||||
&:hover:not(.is-loading) {
|
||||
border-color: var(--app-primary-color);
|
||||
}
|
||||
|
||||
&.has-image:hover .sku-image-upload__mask {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
&__empty {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 4px;
|
||||
color: var(--color-text-3);
|
||||
|
||||
em {
|
||||
font-style: normal;
|
||||
font-size: 12px;
|
||||
line-height: 1.2;
|
||||
}
|
||||
}
|
||||
|
||||
&__mask {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 2px;
|
||||
color: #fff;
|
||||
background: rgba(0, 0, 0, 0.45);
|
||||
opacity: 0;
|
||||
transition: opacity 0.15s ease;
|
||||
pointer-events: none;
|
||||
|
||||
em {
|
||||
font-style: normal;
|
||||
font-size: 12px;
|
||||
line-height: 1.2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.sku-image-clear {
|
||||
height: 28px;
|
||||
padding: 0 4px;
|
||||
}
|
||||
|
||||
.sku-volume-text {
|
||||
color: var(--color-text-2);
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
|
||||
.sku-size-x {
|
||||
color: var(--color-text-3);
|
||||
line-height: 32px;
|
||||
}
|
||||
|
||||
.sku-extra-toggle {
|
||||
margin: 4px 0 8px;
|
||||
padding-left: 96px;
|
||||
}
|
||||
</style>
|
||||
|
||||
@ -26,11 +26,54 @@ export default defineConfig(({ mode }) => {
|
||||
).replace(/\/$/, '');
|
||||
// ideship:PATHBASE=/track → /track/Track/Order/...
|
||||
// nanafa:网关仍吃 /track/Track/Track/Order/...(前端历史双 Track)
|
||||
// 下列服务挂在 /track 根下(不是 /Track/xxx 控制器),前端却写成 Track/xxx,需剥掉网关前缀
|
||||
const trackUseSingleSegment =
|
||||
String(env.VITE_DEPLOY_TARGET || '').toLowerCase() === 'ideship' ||
|
||||
/ideship\.com/i.test(apiOrigin);
|
||||
|
||||
const TRACK_SPA_SEGMENTS = [
|
||||
'guide',
|
||||
'order',
|
||||
'warningOrder',
|
||||
'state',
|
||||
'flag',
|
||||
'content',
|
||||
'pull',
|
||||
'push',
|
||||
'kpiRegion',
|
||||
'kpiEarlyWarningConfig',
|
||||
'query',
|
||||
];
|
||||
|
||||
/** 后端挂在 PATHBASE 根下的服务(非 /Track/Order 这类) */
|
||||
const TRACK_ROOT_SERVICES = ['Warning', 'ProviderService', 'Dictionary'];
|
||||
|
||||
const isTrackSpaPath = (path: string) => {
|
||||
if (/^\/track\/?$/i.test(path)) return true;
|
||||
return TRACK_SPA_SEGMENTS.some(
|
||||
(seg) =>
|
||||
new RegExp(`^/track/${seg}(/|$)`, 'i').test(path),
|
||||
);
|
||||
};
|
||||
|
||||
/** /Track/Warning|ProviderService|Dictionary → /track/Warning|... */
|
||||
const rewriteTrackRootServicePath = (path: string) => {
|
||||
for (const name of TRACK_ROOT_SERVICES) {
|
||||
const prefix = `/Track/${name}`;
|
||||
if (path === prefix || path.startsWith(`${prefix}/`)) {
|
||||
return `/track${path.slice('/Track'.length)}`;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
const rewriteTrackProxyPath = (path: string) => {
|
||||
// 小写 /track SPA 不应进代理;若误入则原样返回,避免变成 /track/track/...
|
||||
if (path === '/track' || path.startsWith('/track/')) {
|
||||
return path;
|
||||
}
|
||||
const rootService = rewriteTrackRootServicePath(path);
|
||||
if (rootService) return rootService;
|
||||
if (trackUseSingleSegment) {
|
||||
if (path.startsWith('/Track/Track/')) {
|
||||
return `/track/Track/${path.slice('/Track/Track/'.length)}`;
|
||||
@ -214,6 +257,20 @@ export default defineConfig(({ mode }) => {
|
||||
changeOrigin: true,
|
||||
secure: false,
|
||||
},
|
||||
// 开发环境面单 PDF 预览:同源代理 COS 签名链接(dev 后端桶可能与 printUrl 不一致)
|
||||
'/__cos__': {
|
||||
target: 'https://cos.ideship.com',
|
||||
changeOrigin: true,
|
||||
secure: false,
|
||||
timeout: 30000,
|
||||
proxyTimeout: 30000,
|
||||
router: (req) => {
|
||||
const path = req.url?.split('?')[0] ?? '';
|
||||
const host = path.replace(/^\/__cos__\//, '').split('/')[0];
|
||||
return host ? `https://${host}` : 'https://cos.ideship.com';
|
||||
},
|
||||
rewrite: (path) => path.replace(/^\/__cos__\/[^/]+/, '') || '/',
|
||||
},
|
||||
'/marketing': {
|
||||
target: omsAdminTarget,
|
||||
changeOrigin: true,
|
||||
@ -311,10 +368,19 @@ export default defineConfig(({ mode }) => {
|
||||
rewrite: (path) => path.replace(/^\/api/, ''),
|
||||
},
|
||||
// 轨迹(track):{apiOrigin}/track/...
|
||||
// 注意:Windows 下 /Track 可能误匹配小写 SPA `/track/pull`,必须 bypass 到 index.html
|
||||
'/Track': {
|
||||
target: apiOrigin,
|
||||
changeOrigin: true,
|
||||
secure: false,
|
||||
bypass(req) {
|
||||
const path = (req.url || '').split('?')[0] || '';
|
||||
// 大写 /Track/... 是轨迹 API
|
||||
if (path.startsWith('/Track')) return undefined;
|
||||
// 小写 /track/... 是前端页面 —— 必须回 index.html,返回原 path 会找实体文件 404
|
||||
if (isTrackSpaPath(path)) return '/index.html';
|
||||
return undefined;
|
||||
},
|
||||
rewrite: rewriteTrackProxyPath,
|
||||
configure: (proxy) => {
|
||||
proxy.on('error', (err, req, res) => {
|
||||
@ -322,6 +388,27 @@ export default defineConfig(({ mode }) => {
|
||||
});
|
||||
},
|
||||
},
|
||||
// trackApi/*(另一套生成客户端):开发环境同样代理到 /track/*
|
||||
'/trackApi': {
|
||||
target: apiOrigin,
|
||||
changeOrigin: true,
|
||||
secure: false,
|
||||
rewrite: (path) => {
|
||||
const rest = path.replace(/^\/trackApi\/?/, '');
|
||||
if (trackUseSingleSegment && rest.startsWith('Track/')) {
|
||||
return `/track/${rest}`;
|
||||
}
|
||||
// Warning / ProviderService / Dictionary 已是根服务
|
||||
if (
|
||||
rest.startsWith('Warning') ||
|
||||
rest.startsWith('ProviderService') ||
|
||||
rest.startsWith('Dictionary')
|
||||
) {
|
||||
return `/track/${rest}`;
|
||||
}
|
||||
return `/track/${rest}`;
|
||||
},
|
||||
},
|
||||
// API(itfx):{apiOrigin}/itfx
|
||||
// 使用正则表达式匹配,排除前端路由路径
|
||||
'^/api/(?!upstreamInterface|upstreamInterfaceConfig|upstreamInterfaceConfigEdit|downstreamInterface|downstreamInterface/newPort|appList|appList/createApplication|requestLog|callStatistics|apiDebugger|trackApi)': {
|
||||
@ -605,9 +692,10 @@ export default defineConfig(({ mode }) => {
|
||||
// 标记请求,让代理中间件知道不要代理
|
||||
(req as any).__skipProxy = true;
|
||||
(req as any).__isFrontendRoute = true;
|
||||
// 关键:将 URL 重写为 /index.html,否则以 /api 开头的路径在 Vite 中不会走 SPA 回退,会直接 404
|
||||
// /track/* 等非 /api 路径会正常走 SPA 回退,所以只有 /api/* 前端路由需要显式重写
|
||||
req.url = '/index.html';
|
||||
// /api/* 与后端同前缀的 SPA 必须显式回退;/track/* 也回退,防止被 /Track 代理误伤
|
||||
if (url.startsWith('/api/') || url.toLowerCase().startsWith('/track')) {
|
||||
req.url = '/index.html';
|
||||
}
|
||||
next();
|
||||
return;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user