Compare commits
8 Commits
c858ace541
...
dev
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
630a98af65 | ||
|
|
31178da436 | ||
|
|
323a641fa3 | ||
| f35d64bd91 | |||
| 15ce1cfa13 | |||
| 7058245cdf | |||
| 7f5ab90f22 | |||
| 124de2926e |
24
package-lock.json
generated
24
package-lock.json
generated
@@ -28,6 +28,7 @@
|
||||
"crypto-js": "^4.2.0",
|
||||
"dayjs": "^1.11.4",
|
||||
"echarts": "^5.4.2",
|
||||
"flv.js": "^1.6.2",
|
||||
"jsencrypt": "^3.3.2",
|
||||
"lint-staged": "^15.2.10",
|
||||
"lodash-es": "^4.17.21",
|
||||
@@ -765,7 +766,6 @@
|
||||
},
|
||||
"node_modules/@clack/prompts/node_modules/is-unicode-supported": {
|
||||
"version": "1.3.0",
|
||||
"extraneous": true,
|
||||
"inBundle": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
@@ -6560,6 +6560,12 @@
|
||||
"es6-symbol": "^3.1.1"
|
||||
}
|
||||
},
|
||||
"node_modules/es6-promise": {
|
||||
"version": "4.2.8",
|
||||
"resolved": "https://registry.npmmirror.com/es6-promise/-/es6-promise-4.2.8.tgz",
|
||||
"integrity": "sha512-HJDGx5daxeIvxdBxvG2cb9g4tEvwIk3i8+nhX0yGrYmZUzbkdg8QbDevheDB8gd0//uPj4c1EQua8Q+MViT0/w==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/es6-symbol": {
|
||||
"version": "3.1.4",
|
||||
"resolved": "https://registry.npmmirror.com/es6-symbol/-/es6-symbol-3.1.4.tgz",
|
||||
@@ -8254,6 +8260,16 @@
|
||||
"dev": true,
|
||||
"license": "ISC"
|
||||
},
|
||||
"node_modules/flv.js": {
|
||||
"version": "1.6.2",
|
||||
"resolved": "https://registry.npmmirror.com/flv.js/-/flv.js-1.6.2.tgz",
|
||||
"integrity": "sha512-xre4gUbX1MPtgQRKj2pxJENp/RnaHaxYvy3YToVVCrSmAWUu85b9mug6pTXF6zakUjNP2lFWZ1rkSX7gxhB/2A==",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"es6-promise": "^4.2.8",
|
||||
"webworkify-webpack": "^2.1.5"
|
||||
}
|
||||
},
|
||||
"node_modules/follow-redirects": {
|
||||
"version": "1.15.9",
|
||||
"resolved": "https://registry.npmmirror.com/follow-redirects/-/follow-redirects-1.15.9.tgz",
|
||||
@@ -16043,6 +16059,12 @@
|
||||
"node": ">=4.0"
|
||||
}
|
||||
},
|
||||
"node_modules/webworkify-webpack": {
|
||||
"version": "2.1.5",
|
||||
"resolved": "https://registry.npmmirror.com/webworkify-webpack/-/webworkify-webpack-2.1.5.tgz",
|
||||
"integrity": "sha512-2akF8FIyUvbiBBdD+RoHpoTbHMQF2HwjcxfDvgztAX5YwbZNyrtfUMgvfgFVsgDhDPVTlkbb5vyasqDHfIDPQw==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/which": {
|
||||
"version": "2.0.2",
|
||||
"resolved": "https://registry.npmmirror.com/which/-/which-2.0.2.tgz",
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
"crypto-js": "^4.2.0",
|
||||
"dayjs": "^1.11.4",
|
||||
"echarts": "^5.4.2",
|
||||
"flv.js": "^1.6.2",
|
||||
"jsencrypt": "^3.3.2",
|
||||
"lint-staged": "^15.2.10",
|
||||
"lodash-es": "^4.17.21",
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import http from '@/utils/http'
|
||||
|
||||
const BASE_URL = '/admin/meterialInfo'
|
||||
const BASE_URL = '/admin/materialInfo'
|
||||
|
||||
export interface MeterialInfoResp {
|
||||
export interface MaterialInfoResp {
|
||||
materialName: string
|
||||
encoding: string
|
||||
unitWeight: string
|
||||
maxWeight: string
|
||||
materialSpec: string
|
||||
photoUrl: string
|
||||
createUser: string
|
||||
createTime: string
|
||||
@@ -19,16 +19,33 @@ export interface MaterialInfoQuery {
|
||||
encoding: string | undefined
|
||||
sort: Array<string>
|
||||
}
|
||||
|
||||
/* 物料信息导入结果类型 */
|
||||
export interface MaterialImportResp {
|
||||
importKey: string
|
||||
totalRows: number
|
||||
validRows: number
|
||||
duplicateNameRows: number
|
||||
duplicateCodeRows: number
|
||||
}
|
||||
export interface MaterialInfoPageQuery extends MaterialInfoQuery, PageQuery {}
|
||||
|
||||
/** @desc 查询物料信息列表 */
|
||||
export function listMaterialInfo(query: MaterialInfoPageQuery) {
|
||||
return http.get<PageRes<MeterialInfoResp[]>>(`${BASE_URL}`, query)
|
||||
return http.get<PageRes<MaterialInfoResp[]>>(`${BASE_URL}`, query)
|
||||
}
|
||||
|
||||
interface MaterialInfoDetailResp {
|
||||
}
|
||||
|
||||
/** @desc 下载物料信息导入模板 */
|
||||
export function downloadMaterialInfoImportTemplate() {
|
||||
return http.download(`${BASE_URL}/import/template`)
|
||||
}
|
||||
|
||||
/** @desc 查询物料信息详情 */
|
||||
export function getMaterialInfo(id: string) {
|
||||
return http.get<MeterialInfoDetailResp>(`${BASE_URL}/${id}`)
|
||||
return http.get<MaterialInfoDetailResp>(`${BASE_URL}/${id}`)
|
||||
}
|
||||
|
||||
/** @desc 新增物料信息 */
|
||||
@@ -47,6 +64,26 @@ export function deleteMaterialInfo(id: string) {
|
||||
}
|
||||
|
||||
/** @desc 导出物料信息 */
|
||||
export function exportMaterialInfo(query: MeterialInfoQuery) {
|
||||
export function exportMaterialInfo(query: MaterialInfoQuery) {
|
||||
return http.download(`${BASE_URL}/export`, query)
|
||||
}
|
||||
|
||||
/** @desc 解析物料信息导入数据 */
|
||||
export function parseImportMaterial(data: FormData) {
|
||||
return http.post(`${BASE_URL}/import/parse`, data)
|
||||
}
|
||||
|
||||
/** @desc 导入物料信息 */
|
||||
export function importMaterial(data: any) {
|
||||
return http.post(`${BASE_URL}/import`, data)
|
||||
}
|
||||
|
||||
/** @desc 物料照片批量导入数据 */
|
||||
export function uploadMaterialPhotos(data: FormData) {
|
||||
return http.post(`${BASE_URL}/import/uploadMaterialPhotos`, data)
|
||||
}
|
||||
|
||||
/** @desc 物料照片抓取数据 */
|
||||
export function catchPhoto(data: FormData) {
|
||||
return http.post(`${BASE_URL}/import/catch`, data)
|
||||
}
|
||||
|
||||
18
src/types/components.d.ts
vendored
18
src/types/components.d.ts
vendored
@@ -13,9 +13,7 @@ declare module 'vue' {
|
||||
ABreadcrumb: typeof import('@arco-design/web-vue')['Breadcrumb']
|
||||
ABreadcrumbItem: typeof import('@arco-design/web-vue')['BreadcrumbItem']
|
||||
AButton: typeof import('@arco-design/web-vue')['Button']
|
||||
ACard: typeof import('@arco-design/web-vue')['Card']
|
||||
ACheckbox: typeof import('@arco-design/web-vue')['Checkbox']
|
||||
ACheckboxGroup: typeof import('@arco-design/web-vue')['CheckboxGroup']
|
||||
ACol: typeof import('@arco-design/web-vue')['Col']
|
||||
AConfigProvider: typeof import('@arco-design/web-vue')['ConfigProvider']
|
||||
ADatePicker: typeof import('@arco-design/web-vue')['DatePicker']
|
||||
@@ -28,8 +26,6 @@ declare module 'vue' {
|
||||
AEmpty: typeof import('@arco-design/web-vue')['Empty']
|
||||
AForm: typeof import('@arco-design/web-vue')['Form']
|
||||
AFormItem: typeof import('@arco-design/web-vue')['FormItem']
|
||||
AGrid: typeof import('@arco-design/web-vue')['Grid']
|
||||
AGridItem: typeof import('@arco-design/web-vue')['GridItem']
|
||||
AIcon: typeof import('@arco-design/web-vue')['Icon']
|
||||
AImage: typeof import('@arco-design/web-vue')['Image']
|
||||
AInput: typeof import('@arco-design/web-vue')['Input']
|
||||
@@ -37,41 +33,29 @@ declare module 'vue' {
|
||||
AInputPassword: typeof import('@arco-design/web-vue')['InputPassword']
|
||||
AInputSearch: typeof import('@arco-design/web-vue')['InputSearch']
|
||||
ALayout: typeof import('@arco-design/web-vue')['Layout']
|
||||
ALayoutContent: typeof import('@arco-design/web-vue')['LayoutContent']
|
||||
ALayoutHeader: typeof import('@arco-design/web-vue')['LayoutHeader']
|
||||
ALayoutSider: typeof import('@arco-design/web-vue')['LayoutSider']
|
||||
ALink: typeof import('@arco-design/web-vue')['Link']
|
||||
AMenu: typeof import('@arco-design/web-vue')['Menu']
|
||||
AMenuItem: typeof import('@arco-design/web-vue')['MenuItem']
|
||||
AModal: typeof import('@arco-design/web-vue')['Modal']
|
||||
AOption: typeof import('@arco-design/web-vue')['Option']
|
||||
AOverflowList: typeof import('@arco-design/web-vue')['OverflowList']
|
||||
APagination: typeof import('@arco-design/web-vue')['Pagination']
|
||||
APopconfirm: typeof import('@arco-design/web-vue')['Popconfirm']
|
||||
APopover: typeof import('@arco-design/web-vue')['Popover']
|
||||
AProgress: typeof import('@arco-design/web-vue')['Progress']
|
||||
ARadio: typeof import('@arco-design/web-vue')['Radio']
|
||||
ARadioGroup: typeof import('@arco-design/web-vue')['RadioGroup']
|
||||
ARangePicker: typeof import('@arco-design/web-vue')['RangePicker']
|
||||
ARow: typeof import('@arco-design/web-vue')['Row']
|
||||
AScrollbar: typeof import('@arco-design/web-vue')['Scrollbar']
|
||||
ASelect: typeof import('@arco-design/web-vue')['Select']
|
||||
ASpace: typeof import('@arco-design/web-vue')['Space']
|
||||
AStatistic: typeof import('@arco-design/web-vue')['Statistic']
|
||||
ASpin: typeof import('@arco-design/web-vue')['Spin']
|
||||
ASubMenu: typeof import('@arco-design/web-vue')['SubMenu']
|
||||
ASwitch: typeof import('@arco-design/web-vue')['Switch']
|
||||
ATable: typeof import('@arco-design/web-vue')['Table']
|
||||
ATabPane: typeof import('@arco-design/web-vue')['TabPane']
|
||||
ATabs: typeof import('@arco-design/web-vue')['Tabs']
|
||||
ATag: typeof import('@arco-design/web-vue')['Tag']
|
||||
ATextarea: typeof import('@arco-design/web-vue')['Textarea']
|
||||
ATooltip: typeof import('@arco-design/web-vue')['Tooltip']
|
||||
ATree: typeof import('@arco-design/web-vue')['Tree']
|
||||
ATreeSelect: typeof import('@arco-design/web-vue')['TreeSelect']
|
||||
ATrigger: typeof import('@arco-design/web-vue')['Trigger']
|
||||
ATypographyParagraph: typeof import('@arco-design/web-vue')['TypographyParagraph']
|
||||
ATypographyTitle: typeof import('@arco-design/web-vue')['TypographyTitle']
|
||||
AUpload: typeof import('@arco-design/web-vue')['Upload']
|
||||
Avatar: typeof import('./../components/Avatar/index.vue')['default']
|
||||
AWatermark: typeof import('@arco-design/web-vue')['Watermark']
|
||||
Breadcrumb: typeof import('./../components/Breadcrumb/index.vue')['default']
|
||||
|
||||
@@ -5,9 +5,10 @@
|
||||
<div class="guide-section full-background">
|
||||
<div class="guide-content full-height">
|
||||
<!-- 标题 -->
|
||||
<!-- 注意:标题现在不再强制占满全宽,而是适应内容 -->
|
||||
<h1 class="page-title">物料领取流程</h1>
|
||||
|
||||
<!-- 图片和按钮卡片 - 确保在任何比例下完全显示 -->
|
||||
<!-- 图片和按钮卡片 -->
|
||||
<div class="guide-card centered">
|
||||
<!-- 图片展示区 -->
|
||||
<div class="image-wrapper">
|
||||
@@ -36,7 +37,7 @@ defineOptions({ name: 'Analysis' })
|
||||
const router = useRouter()
|
||||
|
||||
const handleStart = () => {
|
||||
router.push('')
|
||||
router.push('/weightManage')
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -66,10 +67,10 @@ const handleStart = () => {
|
||||
height: 100%;
|
||||
min-height: 100vh;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
justify-content: flex-start; // 整体靠左,由子元素 margin 控制位置
|
||||
align-items: center;
|
||||
background: #f5f7fa;
|
||||
padding: 10px; // 减小内边距
|
||||
padding: 10px;
|
||||
box-sizing: border-box;
|
||||
|
||||
.guide-content.full-height {
|
||||
@@ -79,10 +80,13 @@ const handleStart = () => {
|
||||
margin: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-start; // 【关键】让子元素(标题和卡片)从左侧开始排列,而不是拉伸
|
||||
|
||||
.page-title {
|
||||
text-align: center;
|
||||
font-size: 42px; // 稍微减小字体
|
||||
// 【修改】让标题宽度适应内容,以便通过 margin 控制其整体位置
|
||||
width: fit-content;
|
||||
text-align: center; // 文字本身在标题块内居中
|
||||
font-size: 42px;
|
||||
font-weight: 800;
|
||||
color: #1e293b;
|
||||
margin-bottom: 15px;
|
||||
@@ -92,13 +96,17 @@ const handleStart = () => {
|
||||
flex-shrink: 0;
|
||||
padding: 0 10px;
|
||||
|
||||
// 【关键修改】应用与卡片相同的左侧偏移,确保标题在卡片正上方
|
||||
margin-left: 30%; // 必须与 .guide-card 的 margin-left 一致
|
||||
margin-right: auto;
|
||||
|
||||
&::after {
|
||||
content: '';
|
||||
display: block;
|
||||
width: 80px; // 减小下划线宽度
|
||||
width: 80px;
|
||||
height: 4px;
|
||||
background: linear-gradient(90deg, #165dff, #6aa1ff);
|
||||
margin: 10px auto 0;
|
||||
margin: 10px auto 0; // 下划线在标题块内居中
|
||||
border-radius: 2px;
|
||||
}
|
||||
}
|
||||
@@ -108,22 +116,23 @@ const handleStart = () => {
|
||||
.guide-card {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 40px; // 减小间距
|
||||
gap: 40px;
|
||||
background: white;
|
||||
border-radius: 30px; // 减小圆角
|
||||
border-radius: 30px;
|
||||
box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
|
||||
padding: 20px 30px; // 减小内边距
|
||||
padding: 20px 30px;
|
||||
flex-wrap: wrap;
|
||||
border: 1px solid rgba(0, 0, 0, 0.05);
|
||||
min-height: 400px; // 减小最小高度
|
||||
min-height: 400px;
|
||||
width: auto;
|
||||
max-width: 90vw; // 使用视口宽度的90%,确保有边距
|
||||
margin: 0 auto;
|
||||
max-width: 90vw;
|
||||
|
||||
// 【核心修改】设置左边距实现左偏移
|
||||
margin-left: 10%; // 与标题保持一致
|
||||
margin-right: auto;
|
||||
|
||||
&.centered {
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
// 移除原本的居中逻辑
|
||||
}
|
||||
|
||||
.image-wrapper {
|
||||
@@ -131,16 +140,16 @@ const handleStart = () => {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
min-width: 300px; // 减小最小宽度
|
||||
max-width: 600px; // 减小最大宽度
|
||||
min-width: 300px;
|
||||
max-width: 600px;
|
||||
height: 100%;
|
||||
|
||||
.guide-image.enlarged {
|
||||
max-width: 100%;
|
||||
width: auto;
|
||||
height: auto;
|
||||
max-height: 50vh; // 减小最大高度
|
||||
min-height: 250px; // 减小最小高度
|
||||
max-height: 50vh;
|
||||
min-height: 250px;
|
||||
object-fit: contain;
|
||||
border-radius: 16px;
|
||||
filter: drop-shadow(0 10px 20px rgba(0, 0, 0, 0.08));
|
||||
@@ -159,13 +168,13 @@ const handleStart = () => {
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 12px;
|
||||
min-width: 180px; // 减小最小宽度
|
||||
min-width: 180px;
|
||||
|
||||
.button-hint {
|
||||
font-size: 14px; // 减小字体
|
||||
font-size: 14px;
|
||||
color: #475569;
|
||||
background: #f1f5f9;
|
||||
padding: 6px 18px; // 减小内边距
|
||||
padding: 6px 18px;
|
||||
border-radius: 24px;
|
||||
white-space: nowrap;
|
||||
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.02);
|
||||
@@ -180,9 +189,9 @@ const handleStart = () => {
|
||||
}
|
||||
|
||||
.start-button.enlarged {
|
||||
min-width: 160px; // 减小按钮宽度
|
||||
height: 56px; // 减小按钮高度
|
||||
font-size: 22px; // 减小字体
|
||||
min-width: 160px;
|
||||
height: 56px;
|
||||
font-size: 22px;
|
||||
border-radius: 40px;
|
||||
box-shadow: 0 10px 20px rgba(22, 93, 255, 0.2);
|
||||
transition: all 0.3s ease;
|
||||
@@ -209,12 +218,11 @@ const handleStart = () => {
|
||||
// 针对不同屏幕尺寸的精细调整
|
||||
@media (min-width: 1920px) {
|
||||
.guide-card {
|
||||
max-width: 1600px; // 超大屏幕限制最大宽度
|
||||
max-width: 1600px;
|
||||
padding: 30px 50px;
|
||||
|
||||
.image-wrapper {
|
||||
max-width: 800px;
|
||||
}
|
||||
.guide-content.full-height .page-title {
|
||||
// 大屏幕保持同步
|
||||
}
|
||||
}
|
||||
|
||||
@@ -222,15 +230,7 @@ const handleStart = () => {
|
||||
.guide-card {
|
||||
gap: 30px;
|
||||
padding: 20px 25px;
|
||||
|
||||
.image-wrapper {
|
||||
min-width: 280px;
|
||||
max-width: 500px;
|
||||
|
||||
.guide-image.enlarged {
|
||||
max-height: 45vh;
|
||||
}
|
||||
}
|
||||
// 如果需要,可以在这里微调 margin-left,记得同时微调 title
|
||||
}
|
||||
}
|
||||
|
||||
@@ -242,43 +242,26 @@ const handleStart = () => {
|
||||
.guide-card {
|
||||
gap: 25px;
|
||||
padding: 15px 20px;
|
||||
max-width: 95vw; // 在小屏幕上使用更宽的百分比
|
||||
|
||||
.image-wrapper {
|
||||
min-width: 250px;
|
||||
max-width: 450px;
|
||||
|
||||
.guide-image.enlarged {
|
||||
max-height: 40vh;
|
||||
min-height: 200px;
|
||||
}
|
||||
}
|
||||
|
||||
.button-wrapper {
|
||||
min-width: 160px;
|
||||
|
||||
.button-hint {
|
||||
font-size: 13px;
|
||||
padding: 5px 15px;
|
||||
}
|
||||
|
||||
.start-button.enlarged {
|
||||
min-width: 150px;
|
||||
height: 50px;
|
||||
font-size: 20px;
|
||||
}
|
||||
}
|
||||
max-width: 95vw;
|
||||
// 平板端如果需要调整偏移,请同时调整下方 title 的 margin
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.guide-section.full-background {
|
||||
padding: 5px;
|
||||
justify-content: center; // 移动端恢复整体居中
|
||||
|
||||
.guide-content.full-height {
|
||||
align-items: center; // 移动端子元素也居中
|
||||
|
||||
.page-title {
|
||||
font-size: 28px;
|
||||
margin-bottom: 10px;
|
||||
// 【重要】移动端重置 margin,恢复自动居中
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
width: fit-content; // 保持适应内容
|
||||
|
||||
&::after {
|
||||
width: 60px;
|
||||
@@ -294,7 +277,11 @@ const handleStart = () => {
|
||||
padding: 20px 15px;
|
||||
gap: 20px;
|
||||
min-height: auto;
|
||||
max-width: 98vw; // 移动端几乎占满宽度
|
||||
max-width: 98vw;
|
||||
|
||||
// 【重要】移动端强制居中
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
|
||||
.image-wrapper {
|
||||
min-width: auto;
|
||||
@@ -334,14 +321,12 @@ const handleStart = () => {
|
||||
.guide-section.full-background {
|
||||
.guide-card {
|
||||
@media (min-width: 1025px) {
|
||||
margin-left: 5%; // 在有侧边栏时左移
|
||||
margin-right: auto;
|
||||
// 如果有侧边栏,确保标题和卡片偏移量依然一致
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 确保父容器占满且无滚动问题
|
||||
html, body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
@@ -359,22 +344,22 @@ html, body {
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
// 针对100%缩放比例的特殊处理
|
||||
// 针对特定分辨率的微调(可选)
|
||||
@media screen and (min-width: 1280px) and (max-width: 1366px) {
|
||||
.guide-card {
|
||||
max-width: 85vw; // 在常见笔记本屏幕上使用85%宽度
|
||||
max-width: 85vw;
|
||||
}
|
||||
}
|
||||
|
||||
@media screen and (min-width: 1367px) and (max-width: 1440px) {
|
||||
.guide-card {
|
||||
max-width: 80vw; // 在1440p屏幕上使用80%宽度
|
||||
max-width: 80vw;
|
||||
}
|
||||
}
|
||||
|
||||
@media screen and (min-width: 1441px) and (max-width: 1680px) {
|
||||
.guide-card {
|
||||
max-width: 75vw; // 在更大屏幕上使用75%宽度
|
||||
max-width: 75vw;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -58,9 +58,9 @@ const columns: ColumnItem[] = reactive([
|
||||
span: 24,
|
||||
},
|
||||
{
|
||||
label: '物料单次可称量最大重量(kg)',
|
||||
field: 'maxWeight',
|
||||
type: 'input-number',
|
||||
label: '物料规格',
|
||||
field: 'materialSpec',
|
||||
type: 'input',
|
||||
span: 24,
|
||||
},
|
||||
{
|
||||
|
||||
201
src/views/material/MaterialInfoImportDrawer.vue
Normal file
201
src/views/material/MaterialInfoImportDrawer.vue
Normal file
@@ -0,0 +1,201 @@
|
||||
<template>
|
||||
<a-drawer
|
||||
v-model:visible="visible"
|
||||
title="导入物料信息"
|
||||
:mask-closable="false"
|
||||
:esc-to-close="false"
|
||||
:width="width >= 600 ? 600 : '100%'"
|
||||
ok-text="确认导入"
|
||||
cancel-text="取消导入"
|
||||
@before-ok="save"
|
||||
@close="reset"
|
||||
>
|
||||
<a-form ref="formRef" :model="form" size="large" auto-label-width>
|
||||
<a-alert v-if="!form.disabled" style="margin-bottom: 15px">
|
||||
请按照模板要求填写数据,填写完毕后,请先上传并进行解析。
|
||||
<template #action>
|
||||
<a-link @click="downloadTemplate">
|
||||
<template #icon><GiSvgIcon name="file-excel" :size="16" /></template>
|
||||
<template #default>下载模板</template>
|
||||
</a-link>
|
||||
</template>
|
||||
</a-alert>
|
||||
<fieldset>
|
||||
<legend>1.解析数据</legend>
|
||||
<div class="file-box">
|
||||
<a-upload
|
||||
draggable
|
||||
:custom-request="handleUpload"
|
||||
:limit="1"
|
||||
:show-retry-butto="false"
|
||||
:show-cancel-button="false" tip="仅支持xls、xlsx格式"
|
||||
:file-list="uploadFile"
|
||||
accept=".xls, .xlsx, application/vnd.ms-excel, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
|
||||
/>
|
||||
</div>
|
||||
<div v-if="dataResult.importKey">
|
||||
<div class="file-box">
|
||||
<a-space size="large">
|
||||
<a-statistic title="总计行数" :value="dataResult.totalRows" />
|
||||
<a-statistic title="正常行数" :value="dataResult.validRows" />
|
||||
</a-space>
|
||||
</div>
|
||||
<div class="file-box">
|
||||
<a-space size="large">
|
||||
<a-statistic title="已存在物料名" :value="dataResult.duplicateNameRows" />
|
||||
<a-statistic title="已存在编码" :value="dataResult.duplicateCodeRows" />
|
||||
</a-space>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<legend>2.导入策略</legend>
|
||||
<a-form-item label="物料名已存在" field="duplicateName">
|
||||
<a-radio-group v-model="form.duplicateName" type="button">
|
||||
<a-radio :value="1">跳过该行</a-radio>
|
||||
<a-radio :value="2">修改数据</a-radio>
|
||||
<a-radio :value="3">停止导入</a-radio>
|
||||
</a-radio-group>
|
||||
</a-form-item>
|
||||
<a-form-item label="编码已存在" field="duplicateCode">
|
||||
<a-radio-group v-model="form.duplicateCode" type="button">
|
||||
<a-radio :value="1">跳过该行</a-radio>
|
||||
<a-radio :value="2">修改数据</a-radio>
|
||||
<a-radio :value="3">停止导入</a-radio>
|
||||
</a-radio-group>
|
||||
</a-form-item>
|
||||
<a-form-item label="默认状态" field="defaultStatus">
|
||||
<a-switch
|
||||
v-model="form.defaultStatus"
|
||||
:checked-value="1"
|
||||
:unchecked-value="2"
|
||||
checked-text="启用"
|
||||
unchecked-text="禁用"
|
||||
type="round"
|
||||
/>
|
||||
</a-form-item>
|
||||
</fieldset>
|
||||
</a-form>
|
||||
</a-drawer>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { type FormInstance, Message, type RequestOption } from '@arco-design/web-vue'
|
||||
import { useWindowSize } from '@vueuse/core'
|
||||
import {
|
||||
type MaterialImportResp,
|
||||
downloadMaterialInfoImportTemplate,
|
||||
importMaterial,
|
||||
parseImportMaterial,
|
||||
} from '@/apis/material/materialInfo'
|
||||
import { useDownload, useResetReactive } from '@/hooks'
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'save-success'): void
|
||||
}>()
|
||||
|
||||
const { width } = useWindowSize()
|
||||
|
||||
const visible = ref(false)
|
||||
const formRef = ref<FormInstance>()
|
||||
const uploadFile = ref([])
|
||||
|
||||
const [form, resetForm] = useResetReactive({
|
||||
importKey: '',
|
||||
errorPolicy: 1,
|
||||
duplicateName: 1,
|
||||
duplicateCode: 1,
|
||||
defaultStatus: 1,
|
||||
})
|
||||
|
||||
const dataResult = ref<MaterialImportResp>({
|
||||
importKey: '',
|
||||
totalRows: 0,
|
||||
validRows: 0,
|
||||
duplicateNameRows: 0,
|
||||
duplicateCodeRows: 0,
|
||||
})
|
||||
|
||||
// 重置
|
||||
const reset = () => {
|
||||
formRef.value?.resetFields()
|
||||
dataResult.value.importKey = ''
|
||||
uploadFile.value = []
|
||||
resetForm()
|
||||
}
|
||||
|
||||
// 下载模板
|
||||
const downloadTemplate = () => {
|
||||
useDownload(() => downloadMaterialInfoImportTemplate())
|
||||
}
|
||||
|
||||
// 上传解析导入数据
|
||||
const handleUpload = (options: RequestOption) => {
|
||||
const controller = new AbortController();
|
||||
(async function requestWrap() {
|
||||
const { onProgress, onError, onSuccess, fileItem, name = 'file' } = options
|
||||
onProgress(20)
|
||||
const formData = new FormData()
|
||||
formData.append(name as string, fileItem.file as Blob)
|
||||
try {
|
||||
const res = await parseImportMaterial(formData)
|
||||
dataResult.value = res.data
|
||||
Message.success('上传解析成功')
|
||||
onSuccess(res)
|
||||
} catch (error) {
|
||||
onError(error)
|
||||
}
|
||||
})()
|
||||
return {
|
||||
abort() {
|
||||
controller.abort()
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// 执行导入
|
||||
const save = async () => {
|
||||
try {
|
||||
if (!dataResult.value.importKey) {
|
||||
Message.warning('请先上传文件,解析导入数据')
|
||||
return false
|
||||
}
|
||||
form.importKey = dataResult.value.importKey
|
||||
const res = await importMaterial(form)
|
||||
Message.success(`导入成功! 新增${res.data.insertRows}, 修改${res.data.updateRows},总计处理${res.data.totalRows}`)
|
||||
emit('save-success')
|
||||
return true
|
||||
} catch (error) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// 打开
|
||||
const onOpen = () => {
|
||||
reset()
|
||||
visible.value = true
|
||||
}
|
||||
|
||||
defineExpose({ onOpen })
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
fieldset {
|
||||
padding: 15px 15px 0 15px;
|
||||
margin-bottom: 15px;
|
||||
border: 1px solid var(--color-neutral-3);
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
fieldset legend {
|
||||
color: rgb(var(--gray-10));
|
||||
padding: 2px 5px 2px 5px;
|
||||
border: 1px solid var(--color-neutral-3);
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
.file-box {
|
||||
margin-bottom: 20px;
|
||||
margin-left: 10px;
|
||||
}
|
||||
</style>
|
||||
134
src/views/material/PhotosImport.vue
Normal file
134
src/views/material/PhotosImport.vue
Normal file
@@ -0,0 +1,134 @@
|
||||
<template>
|
||||
<a-drawer
|
||||
v-model:visible="visible"
|
||||
title="批量导入物料照片"
|
||||
:mask-closable="false"
|
||||
:esc-to-close="false"
|
||||
:width="width >= 600 ? 600 : '100%'"
|
||||
ok-text="确认导入"
|
||||
cancel-text="取消导入"
|
||||
@before-ok="save"
|
||||
@close="reset"
|
||||
>
|
||||
<a-form ref="formRef" :model="form" size="large" auto-label-width>
|
||||
<fieldset>
|
||||
<legend>zip文件上传</legend>
|
||||
<div class="file-box">
|
||||
<a-upload
|
||||
draggable
|
||||
:custom-request="handleUpload"
|
||||
:limit="1"
|
||||
:show-retry-button="false"
|
||||
:show-cancel-button="false"
|
||||
tip="仅支持zip格式"
|
||||
:file-list="uploadFile"
|
||||
accept=".zip"
|
||||
/>
|
||||
</div>
|
||||
</fieldset>
|
||||
</a-form>
|
||||
</a-drawer>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { type FormInstance, Message, type RequestOption } from '@arco-design/web-vue'
|
||||
import { useWindowSize } from '@vueuse/core'
|
||||
import { uploadMaterialPhotos } from '@/apis/material/materialInfo'
|
||||
import { useResetReactive } from '@/hooks'
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'save-success'): void
|
||||
}>()
|
||||
|
||||
const { width } = useWindowSize()
|
||||
|
||||
const visible = ref(false)
|
||||
const formRef = ref<FormInstance>()
|
||||
const uploadFile = ref([])
|
||||
// 新增:保存上传的文件对象
|
||||
const uploadFileObj = ref<File | null>(null)
|
||||
|
||||
// 移除不必要的表单字段,只保留空对象即可
|
||||
const [form, resetForm] = useResetReactive({})
|
||||
|
||||
// 重置
|
||||
const reset = () => {
|
||||
formRef.value?.resetFields()
|
||||
uploadFile.value = []
|
||||
uploadFileObj.value = null // 重置文件对象
|
||||
resetForm()
|
||||
}
|
||||
|
||||
// 修改上传逻辑:仅保存文件对象,不做解析
|
||||
const handleUpload = (options: RequestOption) => {
|
||||
const { onProgress, onError, onSuccess, fileItem } = options
|
||||
onProgress(100) // 直接标记上传完成(仅前端显示)
|
||||
|
||||
// 保存文件对象供后续提交使用
|
||||
uploadFileObj.value = fileItem.file as File
|
||||
uploadFile.value = [fileItem] // 更新文件列表显示
|
||||
|
||||
Message.success('文件已选择,点击确认导入即可上传')
|
||||
onSuccess({}) // 通知上传组件完成
|
||||
return {
|
||||
abort() {
|
||||
// 空实现,取消时会走reset逻辑
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// 执行导入:直接上传文件到后端
|
||||
const save = async () => {
|
||||
try {
|
||||
// 校验是否选择了文件
|
||||
if (!uploadFileObj.value) {
|
||||
Message.warning('请先选择要上传的ZIP文件')
|
||||
return false
|
||||
}
|
||||
|
||||
// 构建FormData
|
||||
const formData = new FormData()
|
||||
formData.append('zipFile', uploadFileObj.value) // 后端接收参数名保持为zipFile
|
||||
|
||||
// 调用后端照片批量导入接口
|
||||
await uploadMaterialPhotos(formData)
|
||||
|
||||
Message.success('物料照片批量导入成功!')
|
||||
emit('save-success') // 通知父组件刷新列表
|
||||
visible.value = false // 关闭抽屉
|
||||
return true
|
||||
} catch (error) {
|
||||
Message.error('物料照片导入失败,请重试!')
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// 打开抽屉
|
||||
const onOpen = () => {
|
||||
reset()
|
||||
visible.value = true
|
||||
}
|
||||
|
||||
defineExpose({ onOpen })
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
fieldset {
|
||||
padding: 15px 15px 0 15px;
|
||||
margin-bottom: 15px;
|
||||
border: 1px solid var(--color-neutral-3);
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
fieldset legend {
|
||||
color: rgb(var(--gray-10));
|
||||
padding: 2px 5px 2px 5px;
|
||||
border: 1px solid var(--color-neutral-3);
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
.file-box {
|
||||
margin-bottom: 20px;
|
||||
margin-left: 10px;
|
||||
}
|
||||
</style>
|
||||
@@ -12,6 +12,7 @@
|
||||
:disabled-column-keys="['name']"
|
||||
@refresh="search"
|
||||
>
|
||||
<!-- toolbar 部分保持不变 -->
|
||||
<template #toolbar-left>
|
||||
<a-input-search v-model="queryForm.materialName" placeholder="请输入物料名称" allow-clear @search="search" />
|
||||
<a-input-search v-model="queryForm.encoding" placeholder="请输入物料编码" allow-clear @search="search" />
|
||||
@@ -25,24 +26,44 @@
|
||||
<template #icon><icon-plus /></template>
|
||||
<template #default>新增</template>
|
||||
</a-button>
|
||||
<a-button v-permission="['admin:materialInfo:import']" @click="onImport">
|
||||
<template #icon><icon-upload /></template>
|
||||
<template #default>导入</template>
|
||||
</a-button>
|
||||
<a-button v-permission="['admin:materialInfo:export']" @click="onExport">
|
||||
<template #icon><icon-download /></template>
|
||||
<template #default>导出</template>
|
||||
</a-button>
|
||||
<a-button v-permission="['admin:materialInfo:import']" @click="onPhotosImport">
|
||||
<template #icon><icon-upload /></template>
|
||||
<template #default>照片批量导入</template>
|
||||
</a-button>
|
||||
</template>
|
||||
<!-- 物料照片插槽:核心新增部分 -->
|
||||
|
||||
<!-- 【修改点】照片列插槽 -->
|
||||
<template #photoUrl="{ record }">
|
||||
<div class="photo-container">
|
||||
<!-- 1. 正常显示图片:有地址 且 未标记为错误 -->
|
||||
<img
|
||||
v-if="record.photoUrl"
|
||||
v-if="record.photoUrl && !record.photoLoadError"
|
||||
:src="record.photoUrl"
|
||||
alt="物料照片"
|
||||
class="material-photo"
|
||||
@error="handleImgError($event)"
|
||||
@load="handleImgLoad(record)"
|
||||
@error="handleImgError(record, $event)"
|
||||
/>
|
||||
<span v-else class="no-photo">暂无照片</span>
|
||||
|
||||
<!-- 2. 无地址 -->
|
||||
<span v-else-if="!record.photoUrl" class="no-photo">暂无照片</span>
|
||||
|
||||
<!-- 3. 地址存在但加载失败 -->
|
||||
<span v-else class="photo-error">
|
||||
<icon-exclamation-circle-fill class="error-icon" />
|
||||
照片异常
|
||||
</span>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<template #action="{ record }">
|
||||
<a-space>
|
||||
<a-link v-permission="['admin:materialInfo:update']" title="修改" @click="onUpdate(record)">修改</a-link>
|
||||
@@ -60,11 +81,16 @@
|
||||
</GiTable>
|
||||
|
||||
<MaterialInfoAddModal ref="MaterialInfoAddModalRef" @save-success="search" />
|
||||
<MaterialInfoImportDrawer ref="MaterialInfoImportDrawerRef" @save-success="search" />
|
||||
<PhotosImport ref="PhotosImportRef" @save-success="search"/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
// ... 保持原有的 import 不变
|
||||
import MaterialInfoAddModal from './MaterialInfoAddModal.vue'
|
||||
import MaterialInfoImportDrawer from './MaterialInfoImportDrawer.vue'
|
||||
import PhotosImport from '@/views/material/PhotosImport.vue';
|
||||
import { type MaterialInfoQuery, type MaterialInfoResp, deleteMaterialInfo, exportMaterialInfo, listMaterialInfo } from '@/apis/material/materialInfo'
|
||||
import type { TableInstanceColumns } from '@/components/GiTable/type'
|
||||
import { useDownload, useTable } from '@/hooks'
|
||||
@@ -73,6 +99,12 @@ import has from '@/utils/has'
|
||||
|
||||
defineOptions({ name: 'MaterialInfo' })
|
||||
|
||||
// 扩展类型定义,允许动态添加 photoLoadError 属性
|
||||
// 如果 TS 报错,可以在 MaterialInfoResp 接口定义中添加 photoLoadError?: boolean;
|
||||
interface MaterialInfoRespWithStatus extends MaterialInfoResp {
|
||||
photoLoadError?: boolean;
|
||||
}
|
||||
|
||||
const queryForm = reactive<MaterialInfoQuery>({
|
||||
materialName: undefined,
|
||||
encoding: undefined,
|
||||
@@ -86,12 +118,12 @@ const {
|
||||
search,
|
||||
handleDelete,
|
||||
} = useTable((page) => listMaterialInfo({ ...queryForm, ...page }), { immediate: true })
|
||||
|
||||
const columns = ref<TableInstanceColumns[]>([
|
||||
{ title: '物料名称', dataIndex: 'materialName', slotName: 'materialName' },
|
||||
{ title: '物料编码', dataIndex: 'encoding', slotName: 'encoding' },
|
||||
{ title: '物料单位重量(g)', dataIndex: 'unitWeight', slotName: 'unitWeight' },
|
||||
{ title: '物料单次可称量最大重量(kg)', dataIndex: 'maxWeight', slotName: 'maxWeight' },
|
||||
// 可给photoUrl列添加宽度,优化显示
|
||||
{ title: '物料规格', dataIndex: 'materialSpec', slotName: 'materialSpec' },
|
||||
{ title: '物料照片', dataIndex: 'photoUrl', slotName: 'photoUrl', width: 120, align: 'center' },
|
||||
{ title: '创建人', dataIndex: 'createUserString', slotName: 'createUser' },
|
||||
{ title: '创建时间', dataIndex: 'createTime', slotName: 'createTime' },
|
||||
@@ -106,14 +138,12 @@ const columns = ref<TableInstanceColumns[]>([
|
||||
},
|
||||
])
|
||||
|
||||
// 重置
|
||||
const reset = () => {
|
||||
queryForm.materialName = undefined
|
||||
queryForm.encoding = undefined
|
||||
search()
|
||||
}
|
||||
|
||||
// 删除
|
||||
const onDelete = (record: MaterialInfoResp) => {
|
||||
return handleDelete(() => deleteMaterialInfo(record.id), {
|
||||
content: `是否确定删除该条数据?`,
|
||||
@@ -121,54 +151,79 @@ const onDelete = (record: MaterialInfoResp) => {
|
||||
})
|
||||
}
|
||||
|
||||
// 导出
|
||||
const onExport = () => {
|
||||
useDownload(() => exportMaterialInfo(queryForm))
|
||||
}
|
||||
|
||||
// 图片加载失败处理函数(新增)
|
||||
const handleImgError = (e: Event) => {
|
||||
// 替换为你的默认图片地址(建议放在/static目录下)
|
||||
const target = e.target as HTMLImageElement
|
||||
target.src = '/static/images/default-material.png'
|
||||
// 【修改点】图片加载处理逻辑
|
||||
const handleImgLoad = (record: MaterialInfoRespWithStatus) => {
|
||||
record.photoLoadError = false
|
||||
}
|
||||
|
||||
const handleImgError = (record: MaterialInfoRespWithStatus, e: Event) => {
|
||||
// 标记为加载错误,触发模板渲染 "照片异常"
|
||||
record.photoLoadError = true
|
||||
console.warn(`物料照片加载失败: ${record.photoUrl}`)
|
||||
}
|
||||
|
||||
const MaterialInfoAddModalRef = ref<InstanceType<typeof MaterialInfoAddModal>>()
|
||||
// 新增
|
||||
const onAdd = () => {
|
||||
MaterialInfoAddModalRef.value?.onAdd()
|
||||
}
|
||||
|
||||
// 修改
|
||||
const onUpdate = (record: MaterialInfoResp) => {
|
||||
MaterialInfoAddModalRef.value?.onUpdate(record.id)
|
||||
}
|
||||
|
||||
// 详情(补充定义,避免报错)
|
||||
const onDetail = (record: MaterialInfoResp) => {
|
||||
// 可补充详情逻辑,如打开详情弹窗
|
||||
console.log('物料详情', record)
|
||||
const MaterialInfoImportDrawerRef = ref<InstanceType<typeof MaterialInfoImportDrawer>>()
|
||||
const onImport = () => {
|
||||
MaterialInfoImportDrawerRef.value?.onOpen()
|
||||
}
|
||||
|
||||
const PhotosImportRef = ref<InstanceType<typeof PhotosImport>>()
|
||||
const onPhotosImport = () => {
|
||||
PhotosImportRef.value?.onOpen()
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
// 物料照片样式(新增)
|
||||
.photo-container {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
height: 80px;
|
||||
width: 100%;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.material-photo {
|
||||
width: 80px;
|
||||
height: 80px;
|
||||
object-fit: cover; // 保持图片比例,避免拉伸
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
border-radius: 4px;
|
||||
transition: opacity 0.3s;
|
||||
}
|
||||
|
||||
.no-photo {
|
||||
color: #999;
|
||||
font-size: 12px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
// 新增样式
|
||||
.photo-error {
|
||||
color: #ff4d4f; // 阿里红/危险色
|
||||
font-size: 12px;
|
||||
text-align: center;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
line-height: 1.4;
|
||||
|
||||
.error-icon {
|
||||
font-size: 18px;
|
||||
margin-bottom: 2px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { Message, type TreeNodeData } from '@arco-design/web-vue'
|
||||
import { Message } from '@arco-design/web-vue'
|
||||
import { useWindowSize } from '@vueuse/core'
|
||||
import { addUser, getUser, updateUser } from '@/apis/system/user'
|
||||
import { type ColumnItem, GiForm } from '@/components/GiForm'
|
||||
|
||||
@@ -123,7 +123,7 @@ const queryFormColumns: ColumnItem[] = reactive([
|
||||
hideLabel: true,
|
||||
},
|
||||
props: {
|
||||
placeholder: '搜索用户名/昵称/描述',
|
||||
placeholder: '搜索用户名',
|
||||
showWordLimit: false,
|
||||
},
|
||||
},
|
||||
@@ -227,11 +227,6 @@ const onUpdate = (record: UserResp) => {
|
||||
UserAddDrawerRef.value?.onUpdate(record.id)
|
||||
}
|
||||
|
||||
const UserDetailDrawerRef = ref<InstanceType<typeof UserDetailDrawer>>()
|
||||
const onDetail = (record: UserResp) => {
|
||||
UserDetailDrawerRef.value?.onOpen(record.id)
|
||||
}
|
||||
|
||||
const UserResetPwdModalRef = ref<InstanceType<typeof UserResetPwdModal>>()
|
||||
const onResetPwd = (record: UserResp) => {
|
||||
UserResetPwdModalRef.value?.onOpen(record.id)
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
<div class="main-content">
|
||||
<!-- 左侧表单 -->
|
||||
<div class="left-section">
|
||||
<a-image v-if="!formData.photoUrl" :src="formData.photoUrl"/>
|
||||
<a-image v-if="!formData.photoUrl" :src="formData.photoUrl" />
|
||||
<img v-else :src="formData.photoUrl" class="sample-image square-image" alt="样图">
|
||||
|
||||
<a-form :model="formData" layout="vertical">
|
||||
@@ -88,7 +88,6 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="info-card">
|
||||
<h4>比对结果</h4>
|
||||
<div class="info-item">
|
||||
@@ -110,7 +109,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 称重登记页面 -->
|
||||
<!-- 称重登记页面 - 这里放FLV播放器 -->
|
||||
<div v-else-if="activeStep === 2" class="step-content">
|
||||
<div class="weighing-content">
|
||||
<!-- 左侧输入区域 -->
|
||||
@@ -139,7 +138,43 @@
|
||||
<a-input v-model="ahDeviceWeight" placeholder="-" disabled/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="image-placeholder large-image">实时画面</div>
|
||||
|
||||
<!-- 这里是摄像头画面 - 替换成FLV播放器 -->
|
||||
<div class="video-container large-image">
|
||||
<video
|
||||
ref="cameraVideo"
|
||||
autoplay
|
||||
muted
|
||||
playsinline
|
||||
style="width: 100%; height: 100%; object-fit: cover;"
|
||||
></video>
|
||||
|
||||
<!-- 加载状态 -->
|
||||
<div v-if="cameraStatus === 'connecting'" class="video-overlay">
|
||||
<a-spin />
|
||||
<span style="margin-left: 8px;">加载中...</span>
|
||||
</div>
|
||||
|
||||
<!-- 错误状态 -->
|
||||
<div v-if="cameraStatus === 'error'" class="video-overlay error">
|
||||
<icon-close-circle-fill style="color: #ff4d4f; font-size: 24px;" />
|
||||
<span>连接失败</span>
|
||||
<a-button size="small" type="primary" @click="reconnectCamera">重试</a-button>
|
||||
</div>
|
||||
|
||||
<!-- 未连接状态 -->
|
||||
<div v-if="cameraStatus === 'disconnected'" class="video-overlay">
|
||||
<icon-pause-circle-fill style="color: #999; font-size: 24px;" />
|
||||
<span>未连接</span>
|
||||
<a-button size="small" type="primary" @click="initCamera">连接</a-button>
|
||||
</div>
|
||||
|
||||
<!-- 摄像头状态标识 -->
|
||||
<div v-if="cameraStatus === 'connected'" class="camera-badge">
|
||||
<span class="live-badge">LIVE</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="weighing-actions">
|
||||
<a-button type="primary" @click="handleConfirm">确定</a-button>
|
||||
<a-button style="margin-left: 12px;" @click="handleReset">重置</a-button>
|
||||
@@ -231,11 +266,20 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive, onUnmounted } from 'vue'
|
||||
import { nextTick, onBeforeUnmount, onMounted, ref, reactive, onUnmounted } from 'vue'
|
||||
import { Modal, Message } from '@arco-design/web-vue'
|
||||
import { getMaterialDetail } from "@/apis/weightManage/weightManage";
|
||||
import {addWorkOrder, type WorkOrderResp} from "@/apis/workOrder/workOrder";
|
||||
import { Notification } from "@arco-design/web-vue"
|
||||
import { catchPhoto } from '@/apis/material/materialInfo'
|
||||
|
||||
|
||||
|
||||
|
||||
defineOptions({ name: 'WeightManage' })
|
||||
|
||||
// 动态导入flv.js
|
||||
const flvjs = ref<any>(null)
|
||||
|
||||
// 当前步骤
|
||||
const activeStep = ref(1)
|
||||
@@ -249,7 +293,252 @@ const formData = reactive({
|
||||
materialSpec: '', // 物料规格
|
||||
unitWeight: 0, // 重量
|
||||
photoUrl: '', // 样图URL
|
||||
matchResult: '' // 比对结果
|
||||
matchResult: '', // 比对结果
|
||||
})
|
||||
|
||||
// 摄像头状态
|
||||
const cameraStatus = ref<'connected' | 'connecting' | 'disconnected' | 'error'>('disconnected')
|
||||
|
||||
// 视频元素引用
|
||||
const cameraVideo = ref<HTMLVideoElement | null>(null)
|
||||
|
||||
// FLV播放器实例
|
||||
let player: any = null
|
||||
|
||||
const reconnectCount = ref(0)
|
||||
const maxReconnectAttempts = 5
|
||||
const reconnectTimer = ref<any>(null)
|
||||
|
||||
// 直接写死FLV流地址(根据你的实际地址修改)
|
||||
const FLV_URL = 'http://192.168.2.87:8866/live?url=rtsp://admin:admin%40123@192.168.2.59:554/media/video1' // 摄像头的FLV地址
|
||||
|
||||
// 加载flv.js
|
||||
const loadFlvJs = async () => {
|
||||
if (typeof window !== 'undefined') {
|
||||
const module = await import('flv.js')
|
||||
flvjs.value = module.default
|
||||
}
|
||||
}
|
||||
|
||||
// 初始化摄像头
|
||||
const initCamera = () => {
|
||||
if (!cameraVideo.value || !flvjs.value) {
|
||||
return
|
||||
}
|
||||
|
||||
// 检查浏览器支持
|
||||
if (!flvjs.value.isSupported()) {
|
||||
Message.error('当前浏览器不支持FLV播放')
|
||||
cameraStatus.value = 'error'
|
||||
return
|
||||
}
|
||||
|
||||
cameraStatus.value = 'connecting'
|
||||
|
||||
// 清除之前的重连定时器
|
||||
if (reconnectTimer.value) {
|
||||
clearTimeout(reconnectTimer.value)
|
||||
reconnectTimer.value = null
|
||||
}
|
||||
|
||||
try {
|
||||
// 销毁旧的播放器
|
||||
if (player) {
|
||||
player.destroy()
|
||||
player = null
|
||||
}
|
||||
|
||||
// 创建新的播放器
|
||||
player = flvjs.value.createPlayer({
|
||||
type: 'flv',
|
||||
url: FLV_URL,
|
||||
isLive: true,
|
||||
hasAudio: false,
|
||||
hasVideo: true,
|
||||
enableStashBuffer: false,
|
||||
stashInitialSize: 128,
|
||||
enableWorker: true,
|
||||
autoCleanupSourceBuffer: true,
|
||||
})
|
||||
|
||||
// 绑定视频元素
|
||||
player.attachMediaElement(cameraVideo.value)
|
||||
|
||||
// 加载并播放
|
||||
player.load()
|
||||
player.play().then(() => {
|
||||
cameraStatus.value = 'connected'
|
||||
reconnectCount.value = 0 // 连接成功,重置重连计数
|
||||
}).catch((error: any) => {
|
||||
cameraStatus.value = 'error'
|
||||
Message.error('摄像头播放失败,正在重连')
|
||||
// 触发自动重连
|
||||
handleReconnect()
|
||||
})
|
||||
|
||||
// 监听各种事件
|
||||
player.on(flvjs.value.Events.ERROR, (err: any) => {
|
||||
cameraStatus.value = 'error'
|
||||
// 触发自动重连
|
||||
handleReconnect()
|
||||
})
|
||||
|
||||
player.on(flvjs.value.Events.STALLED, () => {
|
||||
// 可以在这里处理卡顿,但不立即重连
|
||||
})
|
||||
|
||||
player.on(flvjs.value.Events.RECOVERED_EARLY, () => {
|
||||
if (cameraStatus.value !== 'connected') {
|
||||
cameraStatus.value = 'connected'
|
||||
}
|
||||
})
|
||||
} catch (error) {
|
||||
cameraStatus.value = 'error'
|
||||
handleReconnect()
|
||||
}
|
||||
}
|
||||
|
||||
// 处理自动重连
|
||||
const handleReconnect = () => {
|
||||
// 只有当前在称重页面才重连
|
||||
if (activeStep.value !== 2) return
|
||||
|
||||
// 检查重连次数
|
||||
if (reconnectCount.value >= maxReconnectAttempts) {
|
||||
Message.error('摄像头连接失败,请手动重试')
|
||||
return
|
||||
}
|
||||
|
||||
// 增加重连计数
|
||||
reconnectCount.value++
|
||||
|
||||
// 计算重连延迟(指数退避)
|
||||
const delay = Math.min(1000 * 2 ** (reconnectCount.value - 1), 30000)
|
||||
|
||||
// 清除旧的定时器
|
||||
if (reconnectTimer.value) {
|
||||
clearTimeout(reconnectTimer.value)
|
||||
}
|
||||
|
||||
// 设置新的重连定时器
|
||||
reconnectTimer.value = setTimeout(() => {
|
||||
initCamera()
|
||||
}, delay)
|
||||
}
|
||||
|
||||
// 重新连接摄像头(手动)
|
||||
const reconnectCamera = () => {
|
||||
reconnectCount.value = 0 // 手动重连时重置计数
|
||||
initCamera()
|
||||
}
|
||||
|
||||
// 添加一个定时检查状态的函数
|
||||
const checkCameraStatus = () => {
|
||||
if (!player || !cameraVideo.value) return
|
||||
|
||||
try {
|
||||
// 检查播放器状态
|
||||
if (player.isPlaying && !player.isPlaying()) {
|
||||
if (cameraStatus.value === 'connected') {
|
||||
cameraStatus.value = 'error'
|
||||
handleReconnect()
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
}
|
||||
}
|
||||
|
||||
// 启动状态检查定时器
|
||||
let statusCheckTimer: any = null
|
||||
|
||||
// 监听步骤变化
|
||||
watch(activeStep, (newVal) => {
|
||||
if (newVal === 2) {
|
||||
// 进入称重登记页面,启动摄像头
|
||||
reconnectCount.value = 0 // 重置重连计数
|
||||
nextTick(() => {
|
||||
initCamera()
|
||||
})
|
||||
|
||||
// 启动状态检查(每30秒检查一次)
|
||||
statusCheckTimer = setInterval(checkCameraStatus, 30000)
|
||||
} else {
|
||||
// 离开称重登记页面,停止摄像头和定时器
|
||||
stopCamera()
|
||||
if (statusCheckTimer) {
|
||||
clearInterval(statusCheckTimer)
|
||||
statusCheckTimer = null
|
||||
}
|
||||
if (reconnectTimer.value) {
|
||||
clearTimeout(reconnectTimer.value)
|
||||
reconnectTimer.value = null
|
||||
}
|
||||
reconnectCount.value = 0
|
||||
}
|
||||
})
|
||||
|
||||
// 组件卸载时清理所有定时器
|
||||
onBeforeUnmount(() => {
|
||||
stopCamera()
|
||||
if (statusCheckTimer) {
|
||||
clearInterval(statusCheckTimer)
|
||||
statusCheckTimer = null
|
||||
}
|
||||
if (reconnectTimer.value) {
|
||||
clearTimeout(reconnectTimer.value)
|
||||
reconnectTimer.value = null
|
||||
}
|
||||
})
|
||||
|
||||
// 重新连接摄像头
|
||||
// const reconnectCamera = () => {
|
||||
// if (player) {
|
||||
// player.unload()
|
||||
// player.detachMediaElement()
|
||||
// player.destroy()
|
||||
// player = null
|
||||
// }
|
||||
// setTimeout(() => initCamera(), 1000)
|
||||
// }
|
||||
|
||||
// 停止摄像头
|
||||
const stopCamera = () => {
|
||||
if (player) {
|
||||
player.pause()
|
||||
player.unload()
|
||||
player.detachMediaElement()
|
||||
player.destroy()
|
||||
player = null
|
||||
cameraStatus.value = 'disconnected'
|
||||
}
|
||||
if (reconnectTimer.value) {
|
||||
clearTimeout(reconnectTimer.value)
|
||||
reconnectTimer.value = null
|
||||
}
|
||||
reconnectCount.value = 0
|
||||
}
|
||||
|
||||
// 监听步骤变化
|
||||
watch(activeStep, (newVal) => {
|
||||
if (newVal === 2) {
|
||||
// 进入称重登记页面,启动摄像头
|
||||
nextTick(() => {
|
||||
initCamera()
|
||||
})
|
||||
} else {
|
||||
// 离开称重登记页面,停止摄像头
|
||||
stopCamera()
|
||||
}
|
||||
})
|
||||
|
||||
// 组件挂载时
|
||||
onMounted(async () => {
|
||||
await loadFlvJs()
|
||||
})
|
||||
|
||||
// 组件卸载时
|
||||
onBeforeUnmount(() => {
|
||||
stopCamera()
|
||||
})
|
||||
|
||||
const workOrderResp = ref<WorkOrderResp>({
|
||||
@@ -311,9 +600,23 @@ const columns = [
|
||||
},
|
||||
{
|
||||
title: '抓拍图片',
|
||||
dataIndex: 'imgUrl',
|
||||
key: 'imgUrl',
|
||||
className: 'green-bg'
|
||||
dataIndex: 'image',
|
||||
key: 'image',
|
||||
className: 'green-bg',
|
||||
// 使用自定义渲染
|
||||
render: ({ record }) => {
|
||||
if (record.image && record.image !== '未抓拍') {
|
||||
return h('div', { class: 'image-preview' }, [
|
||||
h('img', {
|
||||
src: record.image,
|
||||
alt: '抓拍图片',
|
||||
style: 'width: 60px; height: 45px; object-fit: cover; border-radius: 4px; cursor: pointer;',
|
||||
onClick: () => previewImage(record.image),
|
||||
}),
|
||||
])
|
||||
}
|
||||
return h('span', record.image || '-')
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
@@ -323,8 +626,6 @@ const columns = [
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
|
||||
// 防抖函数
|
||||
const debounce = <T extends (...args: any[]) => any>(func: T, delay: number): ((...args: Parameters<T>) => void) => {
|
||||
let timer: ReturnType<typeof setTimeout> | null = null;
|
||||
@@ -510,7 +811,7 @@ const handleConfirm = () => {
|
||||
quantity: inputQuantity.value,
|
||||
weight: ahDeviceWeight.value,
|
||||
calculatedWeight: calculatedWeight.value,
|
||||
imgUrl: '图片'
|
||||
image: captureUrl || '未抓拍',
|
||||
}
|
||||
// 添加到列表
|
||||
weighingList.value.push(newItem)
|
||||
@@ -520,6 +821,65 @@ const handleConfirm = () => {
|
||||
calculatedWeight.value = ''
|
||||
// 称重次数累加
|
||||
weighingCount.value = weighingList.value.length + 1
|
||||
Message.success('添加成功')
|
||||
}
|
||||
|
||||
// 抓拍功能 - 内部方法,不暴露按钮
|
||||
const capturePhoto = async (): Promise<string> => {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
try {
|
||||
const video = cameraVideo.value
|
||||
if (!video) {
|
||||
reject(new Error('视频未初始化'))
|
||||
return
|
||||
}
|
||||
|
||||
// 创建canvas抓取当前帧
|
||||
const canvas = document.createElement('canvas')
|
||||
canvas.width = video.videoWidth || 640
|
||||
canvas.height = video.videoHeight || 480
|
||||
const ctx = canvas.getContext('2d')
|
||||
ctx.drawImage(video, 0, 0, canvas.width, canvas.height)
|
||||
|
||||
// 转换为Blob
|
||||
const blob = await new Promise<Blob>((resolve) => {
|
||||
canvas.toBlob((b) => resolve(b), 'image/jpeg', 0.9)
|
||||
})
|
||||
|
||||
// 创建FormData
|
||||
const formData = new FormData()
|
||||
formData.append('file', blob, `capture_${Date.now()}.jpg`)
|
||||
|
||||
// 调用后端接口
|
||||
const response = await catchPhoto(formData)
|
||||
if (!response.code === '200') {
|
||||
reject(new Error('上传失败'))
|
||||
return
|
||||
}
|
||||
|
||||
const imageUrl = await response.data
|
||||
resolve(imageUrl)
|
||||
} catch (error) {
|
||||
reject(error)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 图片预览函数
|
||||
const previewImage = (url: string) => {
|
||||
// 使用Arco Design的图片预览组件
|
||||
Modal.info({
|
||||
title: '图片预览',
|
||||
content: () => h('div', { style: 'text-align: center;' }, [
|
||||
h('img', {
|
||||
src: url,
|
||||
style: 'max-width: 100%; max-height: 500px; object-fit: contain;',
|
||||
}),
|
||||
]),
|
||||
okText: '关闭',
|
||||
hideCancel: true,
|
||||
width: 'auto',
|
||||
})
|
||||
}
|
||||
|
||||
// 处理重置
|
||||
@@ -590,8 +950,6 @@ const closeWebSocket = () => {
|
||||
onUnmounted(() => {
|
||||
closeWebSocket()
|
||||
})
|
||||
|
||||
defineOptions({ name: 'WeightManage' })
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
@@ -719,10 +1077,68 @@ defineOptions({ name: 'WeightManage' })
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
/* 视频容器 - 替换原来的image-placeholder */
|
||||
.video-container {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
height: 240px;
|
||||
background: #000;
|
||||
border-radius: 4px;
|
||||
overflow: hidden;
|
||||
margin: 20px 0;
|
||||
}
|
||||
|
||||
.video-container video {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
}
|
||||
|
||||
.video-overlay {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background: rgba(0, 0, 0, 0.7);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: #fff;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.video-overlay.error {
|
||||
background: rgba(255, 77, 79, 0.2);
|
||||
}
|
||||
|
||||
.camera-badge {
|
||||
position: absolute;
|
||||
top: 10px;
|
||||
right: 10px;
|
||||
z-index: 10;
|
||||
}
|
||||
|
||||
.live-badge {
|
||||
background: #ff4d4f;
|
||||
color: white;
|
||||
padding: 2px 8px;
|
||||
border-radius: 4px;
|
||||
font-size: 12px;
|
||||
font-weight: bold;
|
||||
animation: pulse 1.5s infinite;
|
||||
}
|
||||
|
||||
@keyframes pulse {
|
||||
0% { opacity: 1; }
|
||||
50% { opacity: 0.7; }
|
||||
100% { opacity: 1; }
|
||||
}
|
||||
|
||||
.large-image {
|
||||
width: 100%;
|
||||
height: 200px;
|
||||
margin: 20px 0;
|
||||
height: 240px;
|
||||
}
|
||||
|
||||
.input-placeholder {
|
||||
|
||||
Reference in New Issue
Block a user