From b105e7f72bd68a6c84340cd413d83f843431642e Mon Sep 17 00:00:00 2001 From: yin <3313488199@qq.com> Date: Wed, 25 Mar 2026 18:17:54 +0800 Subject: [PATCH] =?UTF-8?q?3=E6=9C=8825=E5=8F=B7=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/profile.ts | 3 +- src/api/stock.ts | 46 +- src/api/storage/receiving.ts | 149 +- src/components/ScanBox/index.vue | 39 +- src/components/UpperTable/index.vue | 27 +- src/layout/component/TaskView/index.vue | 15 +- src/layout/index.vue | 5 +- src/router/map.ts | 2 +- src/styles/sidebar.scss | 6 +- src/utils/stockQueryBuilder.ts | 88 + src/views/profile/components/Bind.vue | 41 +- src/views/stock/{ => stock}/component/add.vue | 0 .../stock/{ => stock}/component/barcode.vue | 0 .../stock/{ => stock}/component/erpStock.vue | 15 +- .../stock/{ => stock}/component/info.vue | 0 src/views/stock/{ => stock}/component/log.vue | 17 +- .../stock/{ => stock}/component/recycle.vue | 0 .../stock/{ => stock}/component/storage.vue | 15 +- .../{ => stock}/component/store_stock.vue | 0 src/views/stock/{ => stock}/index.vue | 66 +- .../storage/entry/component/entrydetail.vue | 2 +- src/views/storage/entry/index.vue | 52 +- src/views/storage/inventory/index.vue | 43 +- .../storage/receiving/component/Product.vue | 48 +- src/views/storage/receiving/index.vue | 219 +- .../storage/receiving/receiving-config.ts | 70 +- src/wms_permission.sql | 131 - src/wms_stock_warehouse.sql | 26325 ---------------- temp/wechat-bind/TODO.md | 77 - 日志.md | 21 +- 30 files changed, 733 insertions(+), 26789 deletions(-) create mode 100644 src/utils/stockQueryBuilder.ts rename src/views/stock/{ => stock}/component/add.vue (100%) rename src/views/stock/{ => stock}/component/barcode.vue (100%) rename src/views/stock/{ => stock}/component/erpStock.vue (91%) rename src/views/stock/{ => stock}/component/info.vue (100%) rename src/views/stock/{ => stock}/component/log.vue (94%) rename src/views/stock/{ => stock}/component/recycle.vue (100%) rename src/views/stock/{ => stock}/component/storage.vue (90%) rename src/views/stock/{ => stock}/component/store_stock.vue (100%) rename src/views/stock/{ => stock}/index.vue (96%) delete mode 100644 src/wms_permission.sql delete mode 100644 src/wms_stock_warehouse.sql delete mode 100644 temp/wechat-bind/TODO.md diff --git a/src/api/profile.ts b/src/api/profile.ts index e2dbb2ff..a850e677 100644 --- a/src/api/profile.ts +++ b/src/api/profile.ts @@ -31,7 +31,8 @@ export const getBindWechatCode = () => { timestamp: new Date().getTime() }, data: {}, - isSystemApi: true + isSystemApi: true, + timeout: 120000 // 轮询接口,适当延长超时时间 } as any) } diff --git a/src/api/stock.ts b/src/api/stock.ts index 7bcd5123..9f61752d 100644 --- a/src/api/stock.ts +++ b/src/api/stock.ts @@ -7,7 +7,7 @@ export function stockWarehouse(pagination: any, data: any) { url: '/system', method: 'post', params: { - method: 'stock.stockWarehouse', + method: 'stock.warehouse.list', v, timestamp: new Date().getTime() }, @@ -21,7 +21,7 @@ export function getProhibitedType() { url: '/system', method: 'post', params: { - method: 'stock.getProhibitedType', + method: 'stock.warehouse.getProhibitedType', v, timestamp: new Date().getTime() }, @@ -35,7 +35,7 @@ export function getProhibitedList() { url: '/system', method: 'post', params: { - method: 'stock.getProhibitedList', + method: 'stock.warehouse.getProhibitedList', v, timestamp: new Date().getTime() }, @@ -49,7 +49,7 @@ export function getInfo(id: any) { url: '/system', method: 'post', params: { - method: 'stock.getInfo', + method: 'stock.warehouse.getInfo', v, timestamp: new Date().getTime() }, @@ -63,7 +63,7 @@ export function saveWarehouseStock(data: any) { url: '/system', method: 'post', params: { - method: 'stock.saveWarehouseStock', + method: 'stock.warehouse.saveWarehouseStock', v, timestamp: new Date().getTime() }, @@ -77,7 +77,7 @@ export function getBarcodes(id: any) { url: '/system', method: 'post', params: { - method: 'stock.getBarcodes', + method: 'stock.warehouse.getBarcodes', v, timestamp: new Date().getTime() }, @@ -91,7 +91,7 @@ export function saveWarehouseStockBarcode(data: any) { url: '/system', method: 'post', params: { - method: 'stock.saveWarehouseStockBarcode', + method: 'stock.warehouse.saveWarehouseStockBarcode', v, timestamp: new Date().getTime() }, @@ -105,7 +105,7 @@ export function getStoreStocks(data: any) { url: '/system', method: 'post', params: { - method: 'stock.getStoreStocks', + method: 'stock.warehouse.getStoreStocks', v, timestamp: new Date().getTime() }, @@ -119,7 +119,7 @@ export function bindItem(data: any) { url: '/system', method: 'post', params: { - method: 'stock.bindItem', + method: 'stock.warehouse.bindItem', v, timestamp: new Date().getTime() }, @@ -133,7 +133,7 @@ export function unbindItem(data: any) { url: '/system', method: 'post', params: { - method: 'stock.unbindItem', + method: 'stock.warehouse.unbindItem', v, timestamp: new Date().getTime() }, @@ -147,7 +147,7 @@ export function queryStockLogs(data: any) { url: '/system', method: 'post', params: { - method: 'stock.queryStockLogs', + method: 'stock.warehouse.queryStockLogs', v, timestamp: new Date().getTime() }, @@ -161,7 +161,7 @@ export function getStockUnits() { url: '/system', method: 'post', params: { - method: 'stock.getStockUnits', + method: 'stock.warehouse.getStockUnits', v, timestamp: new Date().getTime() }, @@ -175,7 +175,7 @@ export function getUnitList() { url: '/system', method: 'post', params: { - method: 'stock.getUnitList', + method: 'stock.warehouse.getUnitList', v, timestamp: new Date().getTime() }, @@ -189,7 +189,7 @@ export function createUnit(data: any) { url: '/system', method: 'post', params: { - method: 'stock.createUnit', + method: 'stock.warehouse.createUnit', v, timestamp: new Date().getTime() }, @@ -203,7 +203,7 @@ export function getBoxUnits() { url: '/system', method: 'post', params: { - method: 'stock.getBoxUnits', + method: 'stock.warehouse.getBoxUnits', v, timestamp: new Date().getTime() }, @@ -217,7 +217,7 @@ export function checkItemCodeUnique(data: any) { url: '/system', method: 'post', params: { - method: 'stock.checkItemCodeUnique', + method: 'stock.warehouse.checkItemCodeUnique', v, timestamp: new Date().getTime() }, @@ -231,7 +231,7 @@ export function createWarehouseStock(data: any) { url: '/system', method: 'post', params: { - method: 'stock.createWarehouseStock', + method: 'stock.warehouse.createWarehouseStock', v, timestamp: new Date().getTime() }, @@ -245,7 +245,7 @@ export function handleBatchDelete(data: any) { url: '/system', method: 'post', params: { - method: 'stock.handleBatchDelete', + method: 'stock.warehouse.handleBatchDelete', v, timestamp: new Date().getTime() }, @@ -259,7 +259,7 @@ export function handleBatchChange(data: any) { url: '/system', method: 'post', params: { - method: 'stock.handleBatchChange', + method: 'stock.warehouse.handleBatchChange', v, timestamp: new Date().getTime() }, @@ -273,7 +273,7 @@ export function deleteUnit(data: any) { url: '/system', method: 'post', params: { - method: 'stock.deleteUnit', + method: 'stock.warehouse.deleteUnit', v, timestamp: new Date().getTime() }, @@ -287,7 +287,7 @@ export function createProhibited(data: any) { url: '/system', method: 'post', params: { - method: 'stock.createProhibited', + method: 'stock.warehouse.createProhibited', v, timestamp: new Date().getTime() }, @@ -301,7 +301,7 @@ export function deleteProhibited(data: any) { url: '/system', method: 'post', params: { - method: 'stock.deleteProhibited', + method: 'stock.warehouse.deleteProhibited', v, timestamp: new Date().getTime() }, @@ -315,7 +315,7 @@ export function backData(data: any) { url: '/system', method: 'post', params: { - method: 'stock.backData', + method: 'stock.warehouse.backData', v, timestamp: new Date().getTime() }, diff --git a/src/api/storage/receiving.ts b/src/api/storage/receiving.ts index e804280b..5d41be84 100644 --- a/src/api/storage/receiving.ts +++ b/src/api/storage/receiving.ts @@ -28,7 +28,7 @@ export function getReceivingDetail(data: any): Promise { }) } -// 未使用,保留 +// 未使用 export function getReceivingProduct(data: any): Promise { return request({ url: '/system', @@ -81,4 +81,151 @@ export function sendPrint(data: any) { }, data: data }) +} + + + +export function createReceiving(data: any): Promise { + return request({ + url: '/system', + method: 'post', + params: { + method: 'storage.receiving.create', + v, + timestamp: new Date().getTime() + }, + data: data + }) +} + +// 不可用 +export function cancelReceiving(data: any): Promise { + return request({ + url: '/system', + method: 'post', + params: { + method: 'storage.receiving.batchCancelReceiving', + v, + timestamp: new Date().getTime() + }, + data: data + }) +} + + +export function addItem(data: any): Promise { + return request({ + url: '/system', + method: 'post', + params: { + method: 'storage.receiving.addItem', + v, + timestamp: new Date().getTime() + }, + data: data + }) +} + +export function removeItem(data: any): Promise { + return request({ + url: '/system', + method: 'post', + params: { + method: 'storage.receiving.removeItem', + v, + timestamp: new Date().getTime() + }, + data: data + }) +} + +export function saveReceiving(data: any): Promise { + return request({ + url: '/system', + method: 'post', + params: { + method: 'storage.receiving.saveReceiving', + v, + timestamp: new Date().getTime() + }, + data: data + }) +} + +export function getReceiving(data: any): Promise { + return request({ + url: '/system', + method: 'post', + params: { + method: 'storage.receiving.get', + v, + timestamp: new Date().getTime() + }, + data: data + }) +} + +export function addDetail(data: any): Promise { + return request({ + url: '/system', + method: 'post', + params: { + method: 'storage.receiving.addDetail', + v, + timestamp: new Date().getTime() + }, + data: data + }) +} + +export function deleteDetail(data: any): Promise { + return request({ + url: '/system', + method: 'post', + params: { + method: 'storage.receiving.deleteDetail', + v, + timestamp: new Date().getTime() + }, + data: data + }) +} + +export function detailChange(data: any): Promise { + return request({ + url: '/system', + method: 'post', + params: { + method: 'storage.receiving.detailChange', + v, + timestamp: new Date().getTime() + }, + data: data + }) +} + +export function cancelReceivingDetail(data: any): Promise { + return request({ + url: '/system', + method: 'post', + params: { + method: 'storage.receiving.cancel', + v, + timestamp: new Date().getTime() + }, + data: data + }) +} + +export function completeReceiving(data: any): Promise { + return request({ + url: '/system', + method: 'post', + params: { + method: 'storage.receiving.completeReceiving', + v, + timestamp: new Date().getTime() + }, + data: data + }) } \ No newline at end of file diff --git a/src/components/ScanBox/index.vue b/src/components/ScanBox/index.vue index 72847170..cafc291f 100644 --- a/src/components/ScanBox/index.vue +++ b/src/components/ScanBox/index.vue @@ -1,5 +1,5 @@ {{ scope.row[column.prop] }} @@ -589,29 +590,34 @@ defineExpose({ box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1); overflow: hidden; position: relative; - flex-shrink: 0; /* Prevent vertical shrinking which might clip pagination */ + /* 支持弹性高度:允许在 flex 父容器中自动伸缩 */ + flex: 1 1 auto; + min-height: 0; + height: 100%; } .table-container { - height: 395px; + /* 移除固定高度,弹性填满 upper-table-container 剩余空间 */ + flex: 1 1 auto; + min-height: 0; overflow: auto; z-index: 9; } .pagination-container { - padding: 16px 20px; + padding: 5px 10px; border-top: 1px solid #e8e8e8; background: #fff; display: flex; flex-direction: row; justify-content: space-between; align-items: center; - flex-wrap: wrap; /* Allow wrapping if needed */ + flex-wrap: wrap; flex-shrink: 0; } .pagination-info { - font-size: 14px; + font-size: 12px; color: #606266; white-space: nowrap; } @@ -621,11 +627,22 @@ defineExpose({ .pagination-container :deep(.el-pagination__jump), .pagination-container :deep(.el-pagination__total) { display: inline-flex !important; + margin-right: 8px; } .pagination-container :deep(.el-pagination) { flex-wrap: wrap; justify-content: flex-end; + --el-pagination-button-width: 28px; + --el-pagination-button-height: 28px; +} + +.pagination-container :deep(.el-select--small) { + width: 80px; +} + +.pagination-container :deep(.el-input__wrapper) { + padding: 0 4px; } .empty-table { diff --git a/src/layout/component/TaskView/index.vue b/src/layout/component/TaskView/index.vue index 7ad9cdbc..4d52cc1a 100644 --- a/src/layout/component/TaskView/index.vue +++ b/src/layout/component/TaskView/index.vue @@ -286,22 +286,22 @@ onMounted(() => { } .tags-view-wrapper { - height: 40px; + height: 32px; // border-bottom: 1px solid #d8dce5; // background-color: #e0dbdb; .tags-view-item { display: inline-block; position: relative; cursor: pointer; - height: 32px; - line-height: 32px; + height: 26px; + line-height: 26px; // border: 1px solid #d8dce5; color: #495060; background: #b8b5b5; - padding: 0 15px; - font-size: 14px; + padding: 0 10px; + font-size: 12px; margin-left: 5px; - margin-top: 4px; + margin-top: 3px; text-decoration: none; &:first-of-type { margin-left: 15px; @@ -347,7 +347,8 @@ onMounted(() => { } .navbar-wrapper { - height: 45px; + min-height: 45px; + height: auto; } diff --git a/src/layout/index.vue b/src/layout/index.vue index 87c05778..d744d49f 100644 --- a/src/layout/index.vue +++ b/src/layout/index.vue @@ -6,10 +6,10 @@
-
+
-
+
@@ -112,7 +112,6 @@ const handleClickOutside = () => { width: calc(100% - #{$sideBarWidth}); transition: width 0.28s; min-height: 97px; - max-height: 134px; &.fixed-header-top { width: 100% !important; diff --git a/src/router/map.ts b/src/router/map.ts index 60a05d9c..e4e3f45f 100644 --- a/src/router/map.ts +++ b/src/router/map.ts @@ -7,7 +7,7 @@ export const componentMap: Record = { 'auth/approve': () => import('@/views/auth/approve.vue'), 'account/index': () => import('@/views/account/index.vue'), 'warehouse/index': () => import('@/views/warehouse/index.vue'), - 'stock/index': () => import('@/views/stock/index.vue'), + 'stock/index': () => import('@/views/stock/stock/index.vue'), 'stock/storestock/index': () => import('@/views/stock/storestock/index.vue'), 'stock/combo_stock/index': () => import('@/views/stock/combo_stock/index.vue'), 'storage/receiving': () => import('@/views/storage/receiving/index.vue'), diff --git a/src/styles/sidebar.scss b/src/styles/sidebar.scss index c61bf54f..2ff78bfe 100644 --- a/src/styles/sidebar.scss +++ b/src/styles/sidebar.scss @@ -72,9 +72,9 @@ // Increase menu item size .el-menu-item, .el-sub-menu__title { - height: 60px !important; - line-height: 60px !important; - font-size: 16px !important; + height: 40px !important; + line-height: 40px !important; + font-size: 14px !important; } // menu hover diff --git a/src/utils/stockQueryBuilder.ts b/src/utils/stockQueryBuilder.ts new file mode 100644 index 00000000..dcdf4743 --- /dev/null +++ b/src/utils/stockQueryBuilder.ts @@ -0,0 +1,88 @@ + +/** + * stock.stockWarehouse 前端查询规则封装 + * 对应文档:stock-stockWarehouse-query-rules.md + */ + +/** + * 构建符合后端规范的 where 查询对象 + * @param params 前端原始查询参数(通常来自 ScanBox) + * @returns 后端需要的 where 对象 + */ +export function buildStockQuery(params: Record) { + const where: Record = {}; + + if (!params) return where; + + for (const [key, val] of Object.entries(params)) { + // 1. 基础空值检查 + if (val === null || val === undefined || val === '') continue; + if (Array.isArray(val) && val.length === 0) continue; + + let condition = val; + + // 2. 如果值不是对象结构(简单键值对),或数组(in 查询简写),则转换 + if (typeof val !== 'object' || Array.isArray(val)) { + condition = { value: val }; + } else { + // 如果是对象,检查内部 value 是否有效 + if ( + condition.value === null || + condition.value === undefined || + condition.value === '' || + (Array.isArray(condition.value) && condition.value.length === 0) + ) { + continue; + } + // 浅拷贝避免修改源数据 + condition = { ...val }; + } + + // 3. 默认操作符处理 + if (!condition.operator) { + if (key === 'barcode') { + condition.operator = 'like'; // 推荐 operator=eq|like + } else if (key === 'item_code') { + condition.operator = 'like'; + } else { + condition.operator = 'eq'; + } + } + + // 4. 类型转换与值处理 + // 处理 boolean -> Y/N + if (condition.type === 'boolean') { + if (condition.value === true || condition.value === 'true') { + condition.value = 'Y'; + } else if (condition.value === false || condition.value === 'false') { + condition.value = 'N'; + } + } + + // 处理 text (逗号分隔字符串拆分数组) - ScanBox 可能已经处理,这里做防守 + if (condition.type === 'text' && typeof condition.value === 'string' && condition.value.includes(',')) { + // 如果 ScanBox 传来了 string 且 type=text,后端规则提到 "逗号分隔字符串拆分数组" + // 取決于 ScanBox 是否处理了。如果 ScanBox 里的 operator 是 in 或者 contains 可能会有逗号 + // 文档说: type=text: 逗号分隔字符串拆分数组。 + // 如果我们传数组给后端,JSON序列化后是数组。 + if (!Array.isArray(condition.value)) { + condition.value = condition.value.split(',').filter((s: string) => s.trim() !== ''); + } + } + + // 5. 构造最终对象 (过滤掉多余字段如 isMultiple, placeholders 等) + const finalObj: Record = { + operator: condition.operator, + value: condition.value + }; + + if (condition.type) finalObj.type = condition.type; + + // 允许显式传递 field 映射 + if (condition.field) finalObj.field = condition.field; + + where[key] = finalObj; + } + + return where; +} diff --git a/src/views/profile/components/Bind.vue b/src/views/profile/components/Bind.vue index 06948ab2..7b4868e1 100644 --- a/src/views/profile/components/Bind.vue +++ b/src/views/profile/components/Bind.vue @@ -62,7 +62,7 @@ import { ElMessage, ElMessageBox } from 'element-plus' import { CircleCheckFilled, Loading, RefreshRight } from '@element-plus/icons-vue' import { getBindWechatCode, unbindWechat, getBindInfo } from '@/api/profile' -type QrStatus = 'waiting' | 'scanned' | 'bound' | 'expired' +type QrStatus = 'waiting' | 'pending' | 'scanned' | 'bound' | 'expired' const isBound = ref(false) const unbinding = ref(false) @@ -75,7 +75,7 @@ const qrBaseUrl = "https://ye4s.wms.gztbyc.com/qrcode/build?text=" const qrStatus = ref('waiting') let pollTimer: ReturnType | null = null -const POLL_INTERVAL = 3000 // 3 秒轮询一次 +const POLL_INTERVAL = 120000 // 120 秒轮询一次 /** 初始化:获取当前绑定状态 */ const fetchBindInfo = async () => { @@ -98,11 +98,11 @@ const fetchBindInfo = async () => { const handleBind = async () => { dialogVisible.value = true await refreshQrCode() - startPolling() } -/** 获取/刷新二维码 */ +/** 获取/刷新二维码,刷新完成后自动重启轮询 */ const refreshQrCode = async () => { + stopPolling() // 先停止旧的轮询,避免并发干扰 loading.value = true qrStatus.value = 'waiting' qrCodeUrl.value = '' @@ -111,7 +111,8 @@ const refreshQrCode = async () => { const data = res?.data if (!data) throw new Error('无返回数据') - if (data.status === 'bound') { + const isBoundNow = data.status === 'bound' || data.is_bound === true + if (isBoundNow) { // 已绑定,直接刷新状态关闭弹窗 isBound.value = true binderInfo.nickname = data.nickname || '' @@ -121,8 +122,18 @@ const refreshQrCode = async () => { return } - qrStatus.value = data.status as QrStatus - qrCodeUrl.value = data.code ? (qrBaseUrl + data.code) : '' + // 将后端 'pending' 归为 'waiting' 处理 + const mappedStatus = data.status === 'pending' ? 'waiting' : data.status as QrStatus + qrStatus.value = mappedStatus + // 有新 code 时更新二维码 URL + if (data.code) { + qrCodeUrl.value = qrBaseUrl + data.code + } + + // 刷新成功后重新启动轮询(过期状态不轮询,等待用户手动刷新) + if (mappedStatus !== 'expired') { + startPolling() + } } catch { ElMessage.error('获取二维码失败,请重试') dialogVisible.value = false @@ -140,22 +151,30 @@ const startPolling = () => { const data = res?.data if (!data) return - qrStatus.value = data.status as QrStatus + // 将后端 'pending' 归为 'waiting' 处理 + const mappedStatus = data.status === 'pending' ? 'waiting' : data.status as QrStatus + qrStatus.value = mappedStatus // 更新二维码 if (data.code) { qrCodeUrl.value = qrBaseUrl + data.code + console.log('二维码已更新') } - if (data.status === 'bound') { + const isBoundNow = data.status === 'bound' || data.is_bound === true + if (isBoundNow) { stopPolling() isBound.value = true binderInfo.nickname = data.nickname || '' binderInfo.openid = data.openid || '' dialogVisible.value = false ElMessage.success(`微信绑定成功:${data.nickname || '微信用户'}`) - } else if (data.status === 'expired') { - stopPolling() + } + + // expired 状态不再停止轮询,等待后端更新 code 或 status + if (data.status === 'expired') { + // 可选:如果需要清除旧二维码,可以在这里处理 + // 但为了体验平滑,保持 overlay 覆盖在旧图上即可 } } catch { // 轮询失败静默处理,不弹错误 diff --git a/src/views/stock/component/add.vue b/src/views/stock/stock/component/add.vue similarity index 100% rename from src/views/stock/component/add.vue rename to src/views/stock/stock/component/add.vue diff --git a/src/views/stock/component/barcode.vue b/src/views/stock/stock/component/barcode.vue similarity index 100% rename from src/views/stock/component/barcode.vue rename to src/views/stock/stock/component/barcode.vue diff --git a/src/views/stock/component/erpStock.vue b/src/views/stock/stock/component/erpStock.vue similarity index 91% rename from src/views/stock/component/erpStock.vue rename to src/views/stock/stock/component/erpStock.vue index 516044a4..ca6b31ab 100644 --- a/src/views/stock/component/erpStock.vue +++ b/src/views/stock/stock/component/erpStock.vue @@ -20,11 +20,11 @@ title="建议外部ERP修改商品编码重新推送,可以自动绑定" class="toolbar-btn" > - 添加绑定(建议外部ERP修改商品编码重新推送,可以自动绑定) + 添加绑定 - + @@ -54,7 +54,7 @@