From d660d6fcf1e0bdbe34da310e159af4c0e8eeb7b5 Mon Sep 17 00:00:00 2001 From: HongxuanG <1359774872@qq.com> Date: Thu, 23 Jul 2026 18:32:02 +0800 Subject: [PATCH] =?UTF-8?q?feat(storegoods):=20=E6=96=B0=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E5=B7=A5=E8=BF=9B=E4=BB=93=E6=A8=A1=E5=9D=97=E5=B9=B6=E9=80=82?= =?UTF-8?q?=E9=85=8D=E6=99=BA=E7=9B=9BERP?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Cursor --- .env.devlocal | 5 + .env.zhisheng | 4 +- package.json | 2 + src/common/config.js | 15 +- src/common/http.api.js | 50 +- src/common/http.interceptor.js | 15 +- src/common/storeFabricBusinessOut.js | 33 +- src/common/storeGoodsProcessIn.js | 375 ++++++++++++ src/common/tts.js | 94 +++ .../card/storeFabricBusinessOutItem.vue | 2 +- .../card/storeGoodsProcessInItem.vue | 67 +++ .../storefabric/FabricOutScanDetail.vue | 7 +- src/components/storegoods/ProcessInBinBar.vue | 72 +++ .../storegoods/ProcessInDetailList.vue | 251 ++++++++ .../storegoods/ProcessInScanDetail.vue | 36 ++ src/manifest.json | 4 +- src/pages.json | 32 +- .../storefabric/storeFabricBusinessOutAdd.vue | 4 +- .../storeFabricBusinessOutEdit.vue | 2 +- .../storeFabricBusinessOutList.vue | 14 +- .../storeFabricBusinessOutMixin.js | 32 +- .../storeFabricBusinessOutView.vue | 2 +- .../storegoods/storeGoodsProcessInAdd.vue | 112 ++++ .../storegoods/storeGoodsProcessInEdit.vue | 98 ++++ .../storegoods/storeGoodsProcessInList.vue | 260 +++++++++ .../storegoods/storeGoodsProcessInMixin.js | 535 ++++++++++++++++++ .../storegoods/storeGoodsProcessInView.vue | 129 +++++ src/pages/sys/login/index.vue | 2 +- src/pages/sys/workbench/index.vue | 125 +--- src/store/index.js | 18 +- yarn.lock | 400 ++++++++----- 31 files changed, 2484 insertions(+), 313 deletions(-) create mode 100644 .env.devlocal create mode 100644 src/common/storeGoodsProcessIn.js create mode 100644 src/common/tts.js create mode 100644 src/components/card/storeGoodsProcessInItem.vue create mode 100644 src/components/storegoods/ProcessInBinBar.vue create mode 100644 src/components/storegoods/ProcessInDetailList.vue create mode 100644 src/components/storegoods/ProcessInScanDetail.vue create mode 100644 src/pages/storegoods/storeGoodsProcessInAdd.vue create mode 100644 src/pages/storegoods/storeGoodsProcessInEdit.vue create mode 100644 src/pages/storegoods/storeGoodsProcessInList.vue create mode 100644 src/pages/storegoods/storeGoodsProcessInMixin.js create mode 100644 src/pages/storegoods/storeGoodsProcessInView.vue diff --git a/.env.devlocal b/.env.devlocal new file mode 100644 index 0000000..be35b42 --- /dev/null +++ b/.env.devlocal @@ -0,0 +1,5 @@ +NODE_ENV = development +VUE_APP_ENV_NAME = 本地穿透环境 +VUE_APP_UPGRADE_NAME = erp_pda_dev +VUE_APP_PRODUCTION_API_URL = https://2yd52gx88533.vicp.fun/hcscm/pda/v1 +VUE_APP_DEV_API_URL = https://2yd52gx88533.vicp.fun/hcscm/pda/v1 diff --git a/.env.zhisheng b/.env.zhisheng index 7d11492..9bb0d8c 100644 --- a/.env.zhisheng +++ b/.env.zhisheng @@ -1,5 +1,5 @@ NODE_ENV = development VUE_APP_ENV_NAME = zhisheng环境 VUE_APP_UPGRADE_NAME = erp_pda_pre -VUE_APP_PRODUCTION_API_URL = https://hcscmpre.zzfzyc.com/hcscm_weave/pda/v1 -VUE_APP_DEV_API_URL = https://hcscmpre.zzfzyc.com/hcscm_weave/pda/v1 +VUE_APP_PRODUCTION_API_URL = https://hcscmpre.zzfzyc.com/hcscm/pda/v1 +VUE_APP_DEV_API_URL = https://hcscmpre.zzfzyc.com/hcscm/pda/v1 diff --git a/package.json b/package.json index d704e4d..f4d5106 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ "build:app-plus:zhisheng": "cross-env NODE_ENV=production UNI_PLATFORM=app-plus vue-cli-service uni-build --mode zhisheng", "build:app-plus:zhoushang": "cross-env NODE_ENV=production UNI_PLATFORM=app-plus vue-cli-service uni-build --mode zhoushang", "build:app-plus:mes": "cross-env NODE_ENV=production UNI_PLATFORM=app-plus vue-cli-service uni-build --mode mes", + "build:app-plus:devlocal": "cross-env NODE_ENV=production UNI_PLATFORM=app-plus vue-cli-service uni-build --mode devlocal", "build:custom": "cross-env NODE_ENV=production uniapp-cli custom", "build:h5": "cross-env NODE_ENV=production UNI_PLATFORM=h5 vue-cli-service uni-build", "build:mp-360": "cross-env NODE_ENV=production UNI_PLATFORM=mp-360 vue-cli-service uni-build", @@ -30,6 +31,7 @@ "dev:app-plus": "cross-env NODE_ENV=development UNI_PLATFORM=app-plus vue-cli-service uni-build --watch", "dev:app-plus:zhisheng": "cross-env NODE_ENV=development UNI_PLATFORM=app-plus vue-cli-service uni-build --watch --mode zhisheng", "dev:app-plus:mes": "cross-env NODE_ENV=development UNI_PLATFORM=app-plus vue-cli-service uni-build --watch --mode mes", + "dev:app-plus:devlocal": "cross-env NODE_ENV=development UNI_PLATFORM=app-plus vue-cli-service uni-build --watch --mode devlocal", "dev:custom": "cross-env NODE_ENV=development uniapp-cli custom", "dev:h5": "cross-env NODE_ENV=development UNI_PLATFORM=h5 vue-cli-service uni-serve", "dev:mp-360": "cross-env NODE_ENV=development UNI_PLATFORM=mp-360 vue-cli-service uni-build --watch", diff --git a/src/common/config.js b/src/common/config.js index 094da18..ca2af73 100644 --- a/src/common/config.js +++ b/src/common/config.js @@ -9,7 +9,7 @@ const config = { upgradeName: process.env.VUE_APP_UPGRADE_NAME || 'erp_pda', // 产品名称 - productName: '浩拓技术', + productName: '浩拓ERP', // 公司名称 companyName: '浩拓科技', @@ -20,14 +20,15 @@ const config = { // 环境判断 isDevelopment: isDevelopment, - // 生产环境API URL(服务名段 hcscm_weave) - productionApiUrl: process.env.VUE_APP_PRODUCTION_API_URL || 'https://www.haotopai.com/hcscm_weave/mes/server/pda/v1', + // 生产环境API URL(服务名段 hcscm) + productionApiUrl: process.env.VUE_APP_PRODUCTION_API_URL || 'https://www.haotopai.com/hcscm/pda/v1', - // 开发环境API URL选项(仅替换 //域名/ 后第一个路径段 hcscm → hcscm_weave,不改域名) + // 开发环境API URL选项(服务名段 hcscm) devApiUrlOptions: [ - { label: '测试环境', value: 'https://hcscmtest.zzfzyc.com/hcscm_weave/pda/v1' }, - { label: '本地环境', value: 'http://192.168.1.66:7010/hcscm_weave/pda/v1' }, - { label: '正式环境', value: process.env.VUE_APP_DEV_API_URL || 'https://www.haotopai.com/hcscm_weave/mes/server/pda/v1' }, + { label: '测试环境', value: 'https://hcscmtest.zzfzyc.com/hcscm/pda/v1' }, + { label: '本地环境', value: 'http://192.168.1.66:7010/hcscm/pda/v1' }, + { label: '本地穿透', value: 'https://2yd52gx88533.vicp.fun/hcscm/pda/v1' }, + { label: '正式环境', value: process.env.VUE_APP_DEV_API_URL || 'https://www.haotopai.com/hcscm/pda/v1' }, { label: '自定义', value: 'custom' } ] diff --git a/src/common/http.api.js b/src/common/http.api.js index 4c2ad0e..744ab7d 100644 --- a/src/common/http.api.js +++ b/src/common/http.api.js @@ -8,13 +8,23 @@ const install = (Vue, vm) => { const config = vm.vuex_config; console.log('install u',config) - // 坯布出仓单接口前缀(apiurl 已在 config.js 统一配置为 hcscm_weave 服务) - const GFM_OTHER_DELIVERY_PREFIX = '/grey_fabric_manage/gfmOtherDeliveryOrder/'; - const gfmOtherDeliveryUrl = (name) => (vm.$store.state.apiurl || '') + GFM_OTHER_DELIVERY_PREFIX + name; + // 接口前缀统一走 hcscm(apiurl 已在 config.js 配置为 hcscm 服务) + // 部分基础资料(往来单位、营销体系)仍在 hcscm_weave + const getApiUrl = () => String(vm.$store.state.apiurl || ''); + const getWeaveApiUrl = () => { + const url = getApiUrl(); + if (url.indexOf('hcscm_weave') !== -1) return url; + return url.replace('/hcscm/', '/hcscm_weave/'); + }; + + const GFM_OTHER_DELIVERY_PREFIX = '/grey_fabric_manage/gfmOtherDeliveryOrder/'; + const gfmOtherDeliveryUrl = (name) => getApiUrl() + GFM_OTHER_DELIVERY_PREFIX + name; - // 坯布库存接口前缀 const GFM_WAREHOUSE_PREFIX = '/grey_fabric_manage/gfmWarehouse/'; - const gfmWarehouseUrl = (name) => (vm.$store.state.apiurl || '') + GFM_WAREHOUSE_PREFIX + name; + const gfmWarehouseUrl = (name) => getApiUrl() + GFM_WAREHOUSE_PREFIX + name; + + const FPM_PROCESS_IN_PREFIX = '/product/fpmProcessInOrder/'; + const fpmProcessInUrl = (name) => getApiUrl() + FPM_PROCESS_IN_PREFIX + name; // 将各个定义的接口名称,统一放进对象挂载到vm.$u.api(因为vm就是this,也即this.$u.api)下 vm.$u.api = { @@ -46,12 +56,34 @@ const install = (Vue, vm) => { detailList: (params = {}) => vm.$u.get(gfmWarehouseUrl('getGfmWarehouseList'), params), }, - // 营销体系下拉(路径相对 apiurl:.../pda/v1/saleSystem/getSaleSystemDropdownList) - saleSystem: { - getDropdownList: (params = {}) => vm.$u.get('/saleSystem/getSaleSystemDropdownList', params), + // 加工进仓单 + fpmProcessInOrder: { + list: (params = {}) => vm.$u.get(fpmProcessInUrl('getFpmProcessInOrderList'), params), + detail: (params = {}) => vm.$u.get(fpmProcessInUrl('getFpmProcessInOrder'), params), + add: (params = {}) => vm.$u.postJson(fpmProcessInUrl('addFpmProcessInOrder'), params), + scanUpdate: (params = {}) => vm.$u.putJson(fpmProcessInUrl('updateFpmProcessInOrder'), params), + statusPass: (params = {}) => vm.$u.putJson(fpmProcessInUrl('updateFpmProcessInOrderStatusPass'), params), + statusWait: (params = {}) => vm.$u.putJson(fpmProcessInUrl('updateFpmProcessInOrderStatusWait'), params), + statusReject: (params = {}) => vm.$u.putJson(fpmProcessInUrl('updateFpmProcessInOrderStatusReject'), params), + statusCancel: (params = {}) => vm.$u.putJson(fpmProcessInUrl('updateFpmProcessInOrderStatusCancel'), params), }, - // 往来单位列表(路径相对 apiurl:.../pda/v1/business_unit/list) + // 物理仓库下拉 + physicalWarehouse: { + getDropdownList: (params = {}) => vm.$u.get('/warehouse/physicalWarehouse/getPhysicalWarehouseDropdownList', params), + }, + + // 仓位查询(Request: qr_code / warehouse_id / name;Response: GetPhysicalWarehouseBinData) + warehouseBin: { + getByQrCode: (params = {}) => vm.$u.get('/warehouse/warehouseBin/getWarehouseBin', params), + }, + + // 营销体系下拉(基础资料在 hcscm_weave) + saleSystem: { + getDropdownList: (params = {}) => vm.$u.get(getWeaveApiUrl() + '/saleSystem/getSaleSystemDropdownList', params), + }, + + // 往来单位列表 businessUnit: { list: (params = {}) => vm.$u.get('/business_unit/list', params), }, diff --git a/src/common/http.interceptor.js b/src/common/http.interceptor.js index 5b14d31..2a0b3d4 100644 --- a/src/common/http.interceptor.js +++ b/src/common/http.interceptor.js @@ -22,9 +22,11 @@ const install = (Vue, vm) => { // 请求拦截,配置Token等参数 Vue.prototype.$u.http.interceptor.request = (req) => { + const reqUrl = req && req.url ? String(req.url) : ''; + const isAbsolute = /^https?:\/\//i.test(reqUrl); console.log('request', req); console.log('baseUrl', vm.$store.state.apiurl); - console.log('完整URL', vm.$store.state.apiurl + req.url); + console.log('完整URL', isAbsolute ? reqUrl : (vm.$store.state.apiurl + reqUrl)); if (!req.header){ req.header = []; } @@ -68,11 +70,22 @@ const install = (Vue, vm) => { }); return false; } + // 非业务 JSON(如 404 page not found) + if (res.statusCode && res.statusCode !== 200) { + const msg = (res.data && res.data.msg) || `请求失败(${res.statusCode})`; + vm.$u.toast(msg); + return Promise.reject(new Error(msg)); + } console.log('res',res) if (!(res.data)){ vm.$u.toast('未连接到服务器') return Promise.reject(new Error('未连接到服务器')); } + if (typeof res.data !== 'object') { + const msg = '接口返回异常'; + vm.$u.toast(msg); + return Promise.reject(new Error(msg)); + } if(res.data.code !== 0) { vm.$u.toast(res.data.msg) diff --git a/src/common/storeFabricBusinessOut.js b/src/common/storeFabricBusinessOut.js index 96a88b4..e551b5d 100644 --- a/src/common/storeFabricBusinessOut.js +++ b/src/common/storeFabricBusinessOut.js @@ -69,8 +69,8 @@ export const BILL_TYPES = [ /** 列表分页拉取每页条数 */ export const LIST_PAGE_SIZE = 100; -/** 往来单位类型:织厂(接收单位下拉筛选) */ -export const BUSINESS_UNIT_TYPE_KNITTING_FACTORY = 11; +/** 往来单位类型:染厂(染厂下拉筛选) */ +export const BUSINESS_UNIT_TYPE_DYE_FACTORY = 12; export function getStatusOptions() { return Object.keys(AUDIT_STATUS_MAP).map((value) => ({ @@ -157,13 +157,12 @@ export const SCAN_DETAIL_TABLE_COLUMNS = [ { label: '重量', key: 'weight', width: 100 }, ]; -/** 扫码详情区汇总维度(勾选后参与表格分组;带 lock 的维度会随扫码请求传给后端) */ +/** 扫码详情区可勾选锁定维度(对应 PDAScanGfmOtherDeliveryOrderParam 的 *_lock;勾选后参与表格分组并随扫码请求传给后端) */ export const SCAN_GROUP_OPTIONS = [ { key: 'produce_order_no', label: '合同' }, { key: 'grey_fabric_code', label: '布编' }, { key: 'yarn_batch', label: '纱批' }, { key: 'machine_number', label: '机号' }, - { key: 'volume_number', label: '布号' }, { key: 'grey_fabric_level_name', label: '等级' }, ]; @@ -176,6 +175,32 @@ export const SCAN_MERGE_FIELD_MAP = { grey_fabric_level_name: 'grey_fabric_level_id_lock', }; +/** 扫码锁定维度不匹配时的语音文案(按匹配优先级排列) */ +const SCAN_MISMATCH_VOICE_RULES = [ + { patterns: ['机台', '机号', 'machine_number'], voice: '机台不同' }, + { patterns: ['纱批', 'yarn_batch'], voice: '纱批不同' }, + { patterns: ['合同号', '合同', '生产通知单', 'produce_order'], voice: '合同号不同' }, + { patterns: ['布编', 'grey_fabric_code'], voice: '布编不同' }, + { patterns: ['等级', 'grey_fabric_level', 'level'], voice: '等级不同' }, +]; + +/** + * 根据后端错误信息解析锁定维度不匹配的播报文案 + * @param {string} message + * @returns {string} 如「机台不同」;无法识别则返回空串 + */ +export function resolveScanMismatchVoice(message) { + const msg = String(message || ''); + if (!msg) return ''; + for (let i = 0; i < SCAN_MISMATCH_VOICE_RULES.length; i++) { + const rule = SCAN_MISMATCH_VOICE_RULES[i]; + if (rule.patterns.some((p) => msg.indexOf(p) !== -1)) { + return rule.voice; + } + } + return ''; +} + /** 构建扫码新增/删除请求参数(勾选锁定维度时附带当前详情区字段值) */ export function buildScanUpdateParams({ id, scanCode, scanType, groupKeys = [], detail = {} }) { const params = { diff --git a/src/common/storeGoodsProcessIn.js b/src/common/storeGoodsProcessIn.js new file mode 100644 index 0000000..972d572 --- /dev/null +++ b/src/common/storeGoodsProcessIn.js @@ -0,0 +1,375 @@ +/** + * 加工进仓单常量与数据工具 + * + * 真实接口请求统一注册在 src/common/http.api.js 的 vm.$u.api.fpmProcessInOrder 下。 + */ +import dayjs from 'dayjs'; + +export const AUDIT_STATUS = { + PENDING: 1, + APPROVED: 2, + REJECTED: 3, + VOIDED: 4, +}; + +export const DRAFT_AUDIT_STATUS = 0; +export const DRAFT_AUDIT_STATUS_NAME = '待保存'; + +export const AUDIT_STATUS_MAP = { + 1: '待审核', + 2: '已审核', + 3: '已驳回', + 4: '已作废', +}; + +/** 操作类型:1录入 3删除 */ +export const ARRANGE_TYPE = { + IN: 1, + DEL: 3, +}; + +/** 入仓类型:加工进仓单 */ +export const IN_ORDER_TYPE_PROCESS = 5; + +/** 往来单位类型:加工单位 */ +export const BUSINESS_UNIT_TYPE_PROCESS = 12; + +/** 成品物理仓类型 */ +export const WAREHOUSE_TYPE_FINISHED = 103; + +/** 默认仓库名称 */ +export const DEFAULT_WAREHOUSE_NAME = '成品仓'; + +export const LIST_PAGE_SIZE = 100; + +export const STATUS_ACTION_CONFIG = { + approve: { status: AUDIT_STATUS.APPROVED, msg: '确认审核该单据?', apiKey: 'statusPass' }, + void: { status: AUDIT_STATUS.VOIDED, msg: '确认作废该单据?', apiKey: 'statusCancel' }, + unapprove: { status: AUDIT_STATUS.PENDING, msg: '确认消审该单据?', apiKey: 'statusWait' }, +}; + +export function getStatusOptions() { + return Object.keys(AUDIT_STATUS_MAP).map((value) => ({ + value, + label: AUDIT_STATUS_MAP[value], + })); +} + +export function mapToSelectOptions(data) { + const list = Array.isArray(data) ? data : (data && (data.list || data.items || data.records)) || []; + return list.map((item) => ({ + value: item.id, + label: item.name || item.label || item.code || String(item.id), + })); +} + +/** 匹数:后端 ×100 存储 */ +export function formatRoll(value) { + const n = Number(value || 0) / 100; + return Number.isInteger(n) ? n : Number(n.toFixed(2)); +} + +/** 数量(公斤):后端 ×10000 存储 */ +export function formatWeightKg(value) { + const n = Number(value || 0) / 10000; + return Number(n.toFixed(2)); +} + +export function normalizeOrder(order) { + if (!order) return null; + return { + id: order.id, + order_no: order.order_no || '', + audit_status: order.audit_status, + audit_status_name: order.audit_status_name || AUDIT_STATUS_MAP[order.audit_status] || '', + process_unit_id: order.process_unit_id || '', + process_name: order.process_name || '', + warehouse_id: order.warehouse_id || '', + warehouse_name: order.warehouse_name || '', + sale_system_id: order.sale_system_id || '', + sale_system_name: order.sale_system_name || '', + in_order_type: order.in_order_type || IN_ORDER_TYPE_PROCESS, + in_order_type_name: order.in_order_type_name || '加工进仓单', + remark: order.remark || '', + warehouse_in_time: (order.warehouse_in_time || '').slice(0, 10), + creator_name: order.creator_name || '', + create_time: order.create_time || '', + auditor_name: order.auditor_name || '', + audit_time: order.audit_time || '', + total_roll: formatRoll(order.total_roll), + total_weight: formatWeightKg(order.total_weight), + total_length: formatRoll(order.total_length), + item_data: (order.item_data || []).map(normalizeItem), + _raw: order, + }; +} + +export function normalizeFineCode(fc) { + if (!fc) return null; + const weightRaw = fc.base_unit_weight != null + ? fc.base_unit_weight + : (fc.settle_weight != null ? fc.settle_weight : fc.weight); + return { + id: fc.id, + volume_number: fc.volume_number != null && fc.volume_number !== '' ? String(fc.volume_number) : '', + roll: formatRoll(fc.roll), + weight: formatWeightKg(weightRaw), + bar_code: fc.bar_code || '', + qr_code: fc.qr_code || '', + dye_factory_dyelot_number: fc.dye_factory_dyelot_number || fc.dyelot_number || '', + warehouse_bin_name: fc.warehouse_bin_name || '', + shelf_no: fc.shelf_no || '', + scan_code: fc.qr_code || fc.bar_code || '', + }; +} + +export function normalizeItem(item) { + return { + id: item.id, + quote_order_no: item.quote_order_no || '', + product_code: item.product_code || '', + product_name: item.product_name || '', + product_color_code: item.product_color_code || '', + product_color_name: item.product_color_name || '', + dye_factory_dyelot_number: item.dye_factory_dyelot_number || '', + dye_factory_color_code: item.dye_factory_color_code || '', + in_roll: formatRoll(item.in_roll), + in_weight: formatWeightKg(item.in_weight), + item_fc_data: (item.item_fc_data || []).map(normalizeFineCode).filter(Boolean), + }; +} + +/** + * 明细分组:成品编号 → 成品色号 → 细码 + */ +export function buildItemGroups(items) { + const productMap = new Map(); + (items || []).forEach((item) => { + const productKey = item.product_code || '-'; + if (!productMap.has(productKey)) { + productMap.set(productKey, { + group_key: `p:${productKey}`, + product_code: item.product_code || '', + product_name: item.product_name || '', + in_roll: 0, + in_weight: 0, + colors: new Map(), + }); + } + const productGroup = productMap.get(productKey); + if (!productGroup.product_name && item.product_name) { + productGroup.product_name = item.product_name; + } + + const colorKey = item.product_color_code || item.product_color_name || '-'; + if (!productGroup.colors.has(colorKey)) { + productGroup.colors.set(colorKey, { + group_key: `p:${productKey}|c:${colorKey}`, + product_color_code: item.product_color_code || '', + product_color_name: item.product_color_name || '', + quote_order_no: item.quote_order_no || '', + dye_factory_dyelot_number: item.dye_factory_dyelot_number || '', + in_roll: 0, + in_weight: 0, + fine_codes: [], + }); + } + const colorGroup = productGroup.colors.get(colorKey); + productGroup.in_roll = Number((productGroup.in_roll + Number(item.in_roll || 0)).toFixed(2)); + productGroup.in_weight = Number((productGroup.in_weight + Number(item.in_weight || 0)).toFixed(2)); + colorGroup.in_roll = Number((colorGroup.in_roll + Number(item.in_roll || 0)).toFixed(2)); + colorGroup.in_weight = Number((colorGroup.in_weight + Number(item.in_weight || 0)).toFixed(2)); + if (item.quote_order_no) colorGroup.quote_order_no = item.quote_order_no; + if (item.dye_factory_dyelot_number) { + colorGroup.dye_factory_dyelot_number = item.dye_factory_dyelot_number; + } + if (!colorGroup.product_color_name && item.product_color_name) { + colorGroup.product_color_name = item.product_color_name; + } + colorGroup.fine_codes.push(...(item.item_fc_data || [])); + }); + + return Array.from(productMap.values()).map((product) => ({ + group_key: product.group_key, + product_code: product.product_code, + product_name: product.product_name, + in_roll: product.in_roll, + in_weight: product.in_weight, + colors: Array.from(product.colors.values()), + })); +} + +export function getEmptyScanDetail() { + return { + quote_order_no: '', + dyelot_number: '', + volume_number: '', + product_code: '', + product_color_code: '', + order_roll: 0, + item_roll: 0, + order_weight: 0, + item_weight: 0, + }; +} + +/** 从扫码接口返回构建详情区(匹数÷100,数量÷10000) */ +export function buildScanDetailFromScanResponse(res) { + if (!res) return getEmptyScanDetail(); + return { + quote_order_no: res.quote_order_no || '', + dyelot_number: res.dyelot_number || '', + volume_number: res.volume_number != null && res.volume_number !== '' ? String(res.volume_number) : '', + product_code: res.product_code || '', + product_color_code: res.product_color_code || '', + order_roll: formatRoll(res.order_roll != null ? res.order_roll : res.total_roll), + item_roll: formatRoll(res.item_roll != null ? res.item_roll : res.roll), + order_weight: formatWeightKg(res.order_weight != null ? res.order_weight : res.total_weight), + item_weight: formatWeightKg(res.item_weight != null ? res.item_weight : res.weight), + }; +} + +/** 构建扫码请求参数 */ +export function buildScanUpdateParams({ id, scanCode, arrangeType, warehouseBinId }) { + const code = (scanCode || '').trim(); + const params = { + id: Number(id), + arrange_type: arrangeType, + }; + if (warehouseBinId) { + params.warehouse_bin_id = Number(warehouseBinId); + } + // 长码走二维码,短码走条码 + if (code.length > 20) { + params.qr_code = code; + } else { + params.bar_code = code; + } + return params; +} + +export function buildStatusParam(id) { + return { id: String(id) }; +} + +export function formatDisplayTime(value, format = 'YYYY-MM-DD') { + if (!value) return ''; + const parsed = dayjs(value); + return parsed.isValid() ? parsed.format(format) : String(value).slice(0, 10); +} + +export function canScanAtStatus(status) { + return [AUDIT_STATUS.PENDING, AUDIT_STATUS.REJECTED].includes(status); +} + +export function isLockedOrderStatus(status) { + return [AUDIT_STATUS.APPROVED, AUDIT_STATUS.VOIDED].includes(status); +} + +export function fetchAllOrderList(listFn, params = {}, pageSize = LIST_PAGE_SIZE) { + const pickBatch = (res) => { + if (Array.isArray(res)) return res; + if (!res || typeof res !== 'object') return []; + return res.list || res.records || res.items || []; + }; + const loadPage = (page, acc) => listFn({ ...params, page, size: pageSize }) + .then((res) => { + const batch = pickBatch(res); + if (!batch.length) return acc; + // 一次返回超过 pageSize:后端忽略分页,视为全量,避免死循环翻页 + if (batch.length > pageSize) return acc.concat(batch); + // 翻页后与首页首条相同:后端忽略 page,避免死循环 + if ( + page > 1 + && acc.length + && batch[0] + && acc[0] + && String(batch[0].id) === String(acc[0].id) + ) { + return acc; + } + const merged = acc.concat(batch); + const total = !Array.isArray(res) && res != null ? Number(res.total) : NaN; + if (!Number.isNaN(total) && merged.length >= total) return merged; + if (batch.length < pageSize) return merged; + return loadPage(page + 1, merged); + }); + return loadPage(1, []); +} + +export function getFormStatusActionButtons(headerSaved, orderId, status) { + if (!headerSaved || !orderId || !canScanAtStatus(status)) return []; + return [ + { label: '审核', action: 'approve' }, + { label: '作废', action: 'void' }, + ]; +} + +export function getViewStatusActionButtons(status) { + if (status === AUDIT_STATUS.PENDING || status === AUDIT_STATUS.REJECTED) { + return [ + { label: '编辑', action: 'edit' }, + { label: '审核', action: 'approve' }, + { label: '作废', action: 'void' }, + ]; + } + if (status === AUDIT_STATUS.APPROVED) { + return [{ label: '消审', action: 'unapprove' }]; + } + return []; +} + +export function orderToFormFields(order) { + return { + order_no: order.order_no, + process_unit_id: order.process_unit_id, + process_name: order.process_name, + warehouse_id: order.warehouse_id, + warehouse_name: order.warehouse_name, + remark: order.remark, + item_data: order.item_data, + }; +} + +/** 从仓库下拉中选出默认成品仓 */ +export function pickDefaultWarehouse(options, loginWarehouseId, loginWarehouseName) { + const list = options || []; + const byName = list.find((item) => item.label === DEFAULT_WAREHOUSE_NAME); + if (byName) return byName; + if (loginWarehouseId) { + const byId = list.find((item) => String(item.value) === String(loginWarehouseId)); + if (byId) return byId; + if (loginWarehouseName) { + return { value: loginWarehouseId, label: loginWarehouseName }; + } + } + return list[0] || null; +} + +/** + * 确认并执行审核状态变更 + */ +export function confirmOrderStatusAction(vm, { orderId, action, onSuccess }) { + const cfg = STATUS_ACTION_CONFIG[action]; + if (!cfg || !orderId) return; + const api = vm.$u.api.fpmProcessInOrder; + const requestFn = api[cfg.apiKey]; + if (typeof requestFn !== 'function') return; + uni.showModal({ + title: '提示', + content: cfg.msg, + success: (res) => { + if (!res.confirm) return; + uni.showLoading({ title: '处理中...' }); + requestFn(buildStatusParam(orderId)) + .then(() => { + if (typeof onSuccess === 'function') return onSuccess(); + uni.hideLoading(); + }) + .catch((e) => { + uni.hideLoading(); + if (vm.showError) vm.showError(e.message || '操作失败'); + }); + }, + }); +} diff --git a/src/common/tts.js b/src/common/tts.js new file mode 100644 index 0000000..6d0107e --- /dev/null +++ b/src/common/tts.js @@ -0,0 +1,94 @@ +/** + * Android PDA 语音播报(系统 TextToSpeech) + * App 端可用;非 App 环境静默跳过。 + */ +let ttsInstance = null; +let ttsReady = false; +let ttsInitStarted = false; +const pendingQueue = []; + +function flushPending() { + if (!ttsReady || !ttsInstance) return; + while (pendingQueue.length) { + const text = pendingQueue.shift(); + doSpeak(text); + } +} + +function doSpeak(text) { + if (!ttsInstance || !text) return; + try { + const TextToSpeech = plus.android.importClass('android.speech.tts.TextToSpeech'); + // QUEUE_FLUSH:打断当前播报,立即播新内容 + ttsInstance.speak(String(text), TextToSpeech.QUEUE_FLUSH, null); + } catch (e) { + console.warn('[tts] speak failed', e); + } +} + +export function initTts() { + // #ifdef APP-PLUS + if (ttsInitStarted || typeof plus === 'undefined') return; + if (plus.os.name !== 'Android') return; + ttsInitStarted = true; + try { + const main = plus.android.runtimeMainActivity(); + const TextToSpeech = plus.android.importClass('android.speech.tts.TextToSpeech'); + const Locale = plus.android.importClass('java.util.Locale'); + ttsInstance = new TextToSpeech( + main, + plus.android.implements('android.speech.tts.TextToSpeech$OnInitListener', { + onInit(status) { + if (status === TextToSpeech.SUCCESS) { + try { + ttsInstance.setLanguage(Locale.CHINA); + ttsInstance.setSpeechRate(1.0); + } catch (e) { + console.warn('[tts] setLanguage failed', e); + } + ttsReady = true; + flushPending(); + } else { + console.warn('[tts] init status not SUCCESS', status); + ttsReady = false; + } + }, + }) + ); + } catch (e) { + console.warn('[tts] init failed', e); + ttsInitStarted = false; + } + // #endif +} + +/** + * 播报中文文本;TTS 未就绪时先入队,初始化成功后补播。 + * @param {string} text + */ +export function speak(text) { + const content = (text || '').trim(); + if (!content) return; + // #ifdef APP-PLUS + if (typeof plus === 'undefined' || plus.os.name !== 'Android') return; + if (!ttsInitStarted) initTts(); + if (ttsReady && ttsInstance) { + doSpeak(content); + return; + } + pendingQueue.push(content); + // 避免异常堆积 + if (pendingQueue.length > 5) pendingQueue.splice(0, pendingQueue.length - 5); + // #endif +} + +export function stopSpeak() { + // #ifdef APP-PLUS + if (!ttsInstance) return; + try { + ttsInstance.stop(); + } catch (e) { + /* ignore */ + } + // #endif +} diff --git a/src/components/card/storeFabricBusinessOutItem.vue b/src/components/card/storeFabricBusinessOutItem.vue index 9ac4b18..1fb6576 100644 --- a/src/components/card/storeFabricBusinessOutItem.vue +++ b/src/components/card/storeFabricBusinessOutItem.vue @@ -13,7 +13,7 @@ {{ item.bill_type_name }} - 接收单位: + 染厂: {{ item.business_unit_name || '-' }} diff --git a/src/components/card/storeGoodsProcessInItem.vue b/src/components/card/storeGoodsProcessInItem.vue new file mode 100644 index 0000000..e4b7f55 --- /dev/null +++ b/src/components/card/storeGoodsProcessInItem.vue @@ -0,0 +1,67 @@ + + + + + diff --git a/src/components/storefabric/FabricOutScanDetail.vue b/src/components/storefabric/FabricOutScanDetail.vue index 2c5b166..7d97341 100644 --- a/src/components/storefabric/FabricOutScanDetail.vue +++ b/src/components/storefabric/FabricOutScanDetail.vue @@ -41,8 +41,7 @@ 机号: {{ detail.machine_number || '' }} - - + 布号: {{ detail.volume_number || '' }} @@ -90,10 +89,13 @@ + + diff --git a/src/components/storegoods/ProcessInDetailList.vue b/src/components/storegoods/ProcessInDetailList.vue new file mode 100644 index 0000000..b7f6af7 --- /dev/null +++ b/src/components/storegoods/ProcessInDetailList.vue @@ -0,0 +1,251 @@ + + + + + diff --git a/src/components/storegoods/ProcessInScanDetail.vue b/src/components/storegoods/ProcessInScanDetail.vue new file mode 100644 index 0000000..ee246c1 --- /dev/null +++ b/src/components/storegoods/ProcessInScanDetail.vue @@ -0,0 +1,36 @@ + + + + + diff --git a/src/manifest.json b/src/manifest.json index 68eb1ef..3da47d6 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -1,7 +1,7 @@ { - "name" : "浩拓技术", + "name" : "浩拓ERP", "appid" : "__UNI__F79F300", - "description" : "浩拓纺织平台", + "description" : "浩拓ERP", "versionName" : "1.1.5", "versionCode" : 105, "transformPx" : false, diff --git a/src/pages.json b/src/pages.json index 5d2fd41..4c76b83 100644 --- a/src/pages.json +++ b/src/pages.json @@ -421,14 +421,42 @@ "enablePullDownRefresh": false } + },{ + "path" : "pages/storegoods/storeGoodsProcessInList", + "style" : + { + "navigationBarTitleText": "加工进仓列表", + "enablePullDownRefresh": false + } + },{ + "path" : "pages/storegoods/storeGoodsProcessInAdd", + "style" : + { + "navigationBarTitleText": "新增加工进仓单", + "enablePullDownRefresh": false + } + },{ + "path" : "pages/storegoods/storeGoodsProcessInEdit", + "style" : + { + "navigationBarTitleText": "编辑加工进仓单", + "enablePullDownRefresh": false + } + },{ + "path" : "pages/storegoods/storeGoodsProcessInView", + "style" : + { + "navigationBarTitleText": "查看加工进仓单", + "enablePullDownRefresh": false + } },{ "path" : "pages/storegoods/storeGoodsBusinessIn", - "style" : + "style" : { "navigationBarTitleText": "成品进仓", "enablePullDownRefresh": false } - + },{ "path" : "pages/storegoods/storeGoodsBusinessInAdd", "style" : diff --git a/src/pages/storefabric/storeFabricBusinessOutAdd.vue b/src/pages/storefabric/storeFabricBusinessOutAdd.vue index 0130d83..16242cd 100644 --- a/src/pages/storefabric/storeFabricBusinessOutAdd.vue +++ b/src/pages/storefabric/storeFabricBusinessOutAdd.vue @@ -22,9 +22,9 @@ - + - 接收单位* + 染厂* diff --git a/src/pages/storefabric/storeFabricBusinessOutEdit.vue b/src/pages/storefabric/storeFabricBusinessOutEdit.vue index 17f405e..906a14a 100644 --- a/src/pages/storefabric/storeFabricBusinessOutEdit.vue +++ b/src/pages/storefabric/storeFabricBusinessOutEdit.vue @@ -11,7 +11,7 @@ {{ getBillTypeName() }} - 接收单位 + 染厂 {{ form.business_unit_name || '-' }} diff --git a/src/pages/storefabric/storeFabricBusinessOutList.vue b/src/pages/storefabric/storeFabricBusinessOutList.vue index ebc284c..8d2dc36 100644 --- a/src/pages/storefabric/storeFabricBusinessOutList.vue +++ b/src/pages/storefabric/storeFabricBusinessOutList.vue @@ -39,12 +39,12 @@ - - 出仓单位 - {{ deliveryUnitLabel || '全部' }} - + + + + - 接收单位 + 染厂 {{ businessUnitLabel || '全部' }} @@ -70,7 +70,7 @@ import { getStatusOptions, AUDIT_STATUS_MAP, BILL_TYPES, - BUSINESS_UNIT_TYPE_KNITTING_FACTORY, + BUSINESS_UNIT_TYPE_DYE_FACTORY, formatRoll, mapToSelectOptions, fetchAllOrderList, @@ -150,7 +150,7 @@ export default { }, loadBusinessUnitOptions() { if (this.businessUnitOptions.length) return Promise.resolve(this.businessUnitOptions); - return this.$u.api.businessUnit.list({ unit_type_id: BUSINESS_UNIT_TYPE_KNITTING_FACTORY }) + return this.$u.api.businessUnit.list({ unit_type_id: BUSINESS_UNIT_TYPE_DYE_FACTORY }) .then((res) => { this.businessUnitOptions = mapToSelectOptions(res); return this.businessUnitOptions; diff --git a/src/pages/storefabric/storeFabricBusinessOutMixin.js b/src/pages/storefabric/storeFabricBusinessOutMixin.js index 5a0ade6..8e14b02 100644 --- a/src/pages/storefabric/storeFabricBusinessOutMixin.js +++ b/src/pages/storefabric/storeFabricBusinessOutMixin.js @@ -3,17 +3,18 @@ * * 业务说明: * 1. 后端当前仅提供「坯布其他出货单」一种类型的接口,故出仓类型固定为 other, - * 表头保留接收单位(business_unit) / 出货日期 / 备注 等字段。 + * 表头保留染厂(business_unit) / 出货日期 / 备注 等字段。 * 2. 用户先填写表头并「提交保存」(addGfmOtherDeliveryOrder),拿到出仓单 id 后即可扫码; * 扫码新增/删除细码走 updateGfmOtherDeliveryOrder;勾选锁定维度时附带 *_lock 字段,操作后用返回的最新详情刷新。 * 3. 后端没有「修改表头」接口,保存成功或编辑进入后表头变为只读,仅可扫码维护细码。 */ import util from '@/common/util'; import scanMixin from '@/common/scanMixin.js'; +import { initTts, speak } from '@/common/tts.js'; import { AUDIT_STATUS_MAP, BILL_TYPES, - BUSINESS_UNIT_TYPE_KNITTING_FACTORY, + BUSINESS_UNIT_TYPE_DYE_FACTORY, normalizeOrder, mapToSelectOptions, getFineCodeScanCode, @@ -31,6 +32,7 @@ import { buildScanUpdateParams, getOrderDisplayWeight, getFineCodeDisplayWeight, + resolveScanMismatchVoice, } from '@/common/storeFabricBusinessOut'; export default { @@ -92,6 +94,7 @@ export default { }, onShow() { this.isPageActive = true; + initTts(); if (this.canScan && this.isEditable) { this.registerScanBroadcast((scanResult) => { this.QRBarCode = scanResult.trim().replace(/[\r\n]/g, ''); @@ -136,7 +139,7 @@ export default { }, ensureBusinessUnitOptions() { if (this.businessUnitOptions.length) return Promise.resolve(this.businessUnitOptions); - return this.$u.api.businessUnit.list({ unit_type_id: BUSINESS_UNIT_TYPE_KNITTING_FACTORY }) + return this.$u.api.businessUnit.list({ unit_type_id: BUSINESS_UNIT_TYPE_DYE_FACTORY }) .then((res) => { this.businessUnitOptions = mapToSelectOptions(res); return this.businessUnitOptions; @@ -191,7 +194,7 @@ export default { this.selectList = list; this.selectShow = true; }; - if (type === '接收单位') { + if (type === '染厂') { this.ensureBusinessUnitOptions() .then(openPicker) .catch((e) => this.showError(e.message || '加载单位列表失败')); @@ -199,7 +202,7 @@ export default { }, selectConfirmFun(e) { const item = e[0]; - if (this.selectType === '接收单位') { + if (this.selectType === '染厂') { this.form.business_unit_id = item.value; this.form.business_unit_name = item.label; } @@ -208,7 +211,7 @@ export default { this.form.delivery_time = e.detail.value; }, validateForm() { - if (!this.form.business_unit_id) return '请选择接收单位'; + if (!this.form.business_unit_id) return '请选择染厂'; if (!this.form.delivery_time) return '请选择出货日期'; return ''; }, @@ -334,12 +337,19 @@ export default { } this.BillDataMessage = scanType === 2 ? '删除成功' : '扫描成功'; this.QRBarCode = ''; - if (scanType === 2) this.showSuccess('删除成功'); - else util.playSuccessAudio(); + if (scanType === 2) { + speak('已删除出仓'); + uni.showToast({ title: '删除成功', icon: 'success' }); + } else { + speak('成功'); + } }) .catch((e) => { uni.hideLoading(); - this.showError(e.message || (scanType === 2 ? '删除失败' : '扫码失败')); + const message = e.message || (scanType === 2 ? '删除失败' : '扫码失败'); + const mismatchVoice = resolveScanMismatchVoice(message); + if (mismatchVoice) speak(mismatchVoice); + this.showError(message, { skipErrorAudio: !!mismatchVoice }); this.QRBarCode = ''; }); }, @@ -383,8 +393,8 @@ export default { }), }); }, - showError(message) { - util.playErrorAudio(); + showError(message, options = {}) { + if (!options.skipErrorAudio) util.playErrorAudio(); uni.showModal({ title: '提示', content: message, showCancel: false }); }, showSuccess(message) { diff --git a/src/pages/storefabric/storeFabricBusinessOutView.vue b/src/pages/storefabric/storeFabricBusinessOutView.vue index 8e913bd..85d3ce5 100644 --- a/src/pages/storefabric/storeFabricBusinessOutView.vue +++ b/src/pages/storefabric/storeFabricBusinessOutView.vue @@ -11,7 +11,7 @@ {{ billTypeName }} - 接收单位{{ order.business_unit_name }} + 染厂{{ order.business_unit_name }} 出货日期{{ formatTime(order.delivery_time) }} diff --git a/src/pages/storegoods/storeGoodsProcessInAdd.vue b/src/pages/storegoods/storeGoodsProcessInAdd.vue new file mode 100644 index 0000000..7461f8f --- /dev/null +++ b/src/pages/storegoods/storeGoodsProcessInAdd.vue @@ -0,0 +1,112 @@ + + + + + diff --git a/src/pages/storegoods/storeGoodsProcessInEdit.vue b/src/pages/storegoods/storeGoodsProcessInEdit.vue new file mode 100644 index 0000000..3e15513 --- /dev/null +++ b/src/pages/storegoods/storeGoodsProcessInEdit.vue @@ -0,0 +1,98 @@ + + + + + diff --git a/src/pages/storegoods/storeGoodsProcessInList.vue b/src/pages/storegoods/storeGoodsProcessInList.vue new file mode 100644 index 0000000..486cdb3 --- /dev/null +++ b/src/pages/storegoods/storeGoodsProcessInList.vue @@ -0,0 +1,260 @@ + + + + + diff --git a/src/pages/storegoods/storeGoodsProcessInMixin.js b/src/pages/storegoods/storeGoodsProcessInMixin.js new file mode 100644 index 0000000..f9d4a5b --- /dev/null +++ b/src/pages/storegoods/storeGoodsProcessInMixin.js @@ -0,0 +1,535 @@ +/** + * 加工进仓单表单 mixin(新增/编辑共用) + * + * 1. 先填表头(加工单位 / 仓库 / 备注)提交 add,拿到 id 后可扫码 + * 2. 先扫仓位(getWarehouseBin:传 qr_code + warehouse_id),校验后扫布匹二维码 + * 3. 扫码走 updateFpmProcessInOrder(arrange_type: 1 录入 / 3 删除,带 warehouse_bin_id) + * 4. 手机扫码成功展示详情后自动再次调起扫码,形成连续扫 + */ +import util from '@/common/util'; +import scanMixin from '@/common/scanMixin.js'; +import { initTts, speak } from '@/common/tts.js'; +import { + AUDIT_STATUS_MAP, + ARRANGE_TYPE, + BUSINESS_UNIT_TYPE_PROCESS, + WAREHOUSE_TYPE_FINISHED, + IN_ORDER_TYPE_PROCESS, + normalizeOrder, + mapToSelectOptions, + canScanAtStatus, + isLockedOrderStatus, + getFormStatusActionButtons, + orderToFormFields, + confirmOrderStatusAction, + DRAFT_AUDIT_STATUS, + DRAFT_AUDIT_STATUS_NAME, + getEmptyScanDetail, + buildScanDetailFromScanResponse, + buildScanUpdateParams, + pickDefaultWarehouse, +} from '@/common/storeGoodsProcessIn'; + +export default { + mixins: [scanMixin], + data() { + return { + pageMode: 'add', + orderId: 0, + form: this.getEmptyForm(), + headerSaved: false, + selectShow: false, + selectList: [], + selectType: '', + canScan: false, + QRBarCode: '', + BarCodeDelStatus: false, + BillDataMessage: '', + scanDetail: getEmptyScanDetail(), + auditStatus: 0, + processUnitOptions: [], + warehouseOptions: [], + dropdownLoading: false, + /** 仓位 */ + warehouseBinId: 0, + warehouseBinCode: '', + warehouseBinName: '', + /** 手机连续扫码开关:成功后自动再调起;取消/失败则关闭 */ + phoneContinuousScan: false, + /** 手机扫当前目标:bin | qr */ + phoneScanTarget: 'bin', + }; + }, + computed: { + isReadonly() { + return this.pageMode === 'view'; + }, + isEditable() { + return this.pageMode === 'add' || this.pageMode === 'edit'; + }, + headerEditable() { + return this.pageMode === 'add' && !this.headerSaved; + }, + statusActionButtons() { + return getFormStatusActionButtons(this.headerSaved, this.orderId, this.auditStatus); + }, + displayAuditStatus() { + if (this.pageMode === 'add' && !this.headerSaved) return DRAFT_AUDIT_STATUS; + return this.auditStatus; + }, + displayAuditStatusName() { + if (this.pageMode === 'add' && !this.headerSaved) return DRAFT_AUDIT_STATUS_NAME; + return AUDIT_STATUS_MAP[this.auditStatus] || ''; + }, + /** 录入需先选仓位;删除模式仅需单据可扫 */ + canScanQr() { + if (!this.canScan) return false; + if (this.BarCodeDelStatus) return true; + return !!this.warehouseBinId; + }, + /** 扫码栏在可扫状态下始终展示(含删除勾选) */ + showQrScanBar() { + return this.canScan; + }, + qrDisabledTip() { + if (!this.canScan) return '请先提交保存后再扫码'; + if (!this.warehouseBinId && !this.BarCodeDelStatus) return '请先扫描仓位后再扫布匹二维码'; + return '当前状态不可扫码'; + }, + }, + onShow() { + this.isPageActive = true; + initTts(); + if (this.canScan && this.isEditable) { + this.registerOrderScanBroadcast(); + } + }, + onHide() { + this.isPageActive = false; + this.phoneContinuousScan = false; + this.unregisterScanBroadcast(); + }, + onUnload() { + this.isPageActive = false; + this.phoneContinuousScan = false; + this.unregisterScanBroadcast(); + }, + methods: { + clearWarehouseBin() { + this.warehouseBinId = 0; + this.warehouseBinCode = ''; + this.warehouseBinName = ''; + this.phoneContinuousScan = false; + }, + handleBinPhoneScan() { + if (!this.canScan || !this.orderId) { + this.showError('请先提交保存后再扫码'); + return; + } + this.phoneContinuousScan = false; + this.phoneScanTarget = 'bin'; + this.openPhoneScan({ + callback: (scanResult) => { + this.warehouseBinCode = String(scanResult || '').trim().replace(/[\r\n]/g, ''); + this.$nextTick(() => this.resolveWarehouseBin()); + }, + fail: () => {}, + }); + }, + handlePhoneScan() { + if (!this.canScan || !this.orderId) { + this.showError('请先提交保存后再扫码'); + return; + } + // 删除模式可直接扫布匹码;录入模式无仓位时先扫仓位 + if (!this.BarCodeDelStatus && !this.warehouseBinId) { + this.handleBinPhoneScan(); + return; + } + this.phoneScanTarget = 'qr'; + this.phoneContinuousScan = true; + this.openContinuousPhoneScan(); + }, + openContinuousPhoneScan() { + if (!this.phoneContinuousScan || !this.canScanQr || !this.isPageActive) { + this.phoneContinuousScan = false; + return; + } + this.openPhoneScan({ + callback: (scanResult) => { + this.QRBarCode = String(scanResult || '').trim().replace(/[\r\n]/g, ''); + this.$nextTick(() => this.handleScan({ fromPhone: true })); + }, + fail: () => { + this.phoneContinuousScan = false; + }, + }); + }, + scheduleNextPhoneScan() { + if (!this.phoneContinuousScan || !this.canScanQr || !this.isPageActive) { + this.phoneContinuousScan = false; + return; + } + setTimeout(() => { + this.openContinuousPhoneScan(); + }, 400); + }, + registerOrderScanBroadcast() { + this.registerScanBroadcast((scanResult) => { + const code = String(scanResult || '').trim().replace(/[\r\n]/g, ''); + if (!code) return; + // 删除模式:直接按布匹码删除;未扫仓位时枪扫优先解析为仓位 + if (!this.BarCodeDelStatus && !this.warehouseBinId) { + this.warehouseBinCode = code; + this.$nextTick(() => this.resolveWarehouseBin()); + return; + } + this.QRBarCode = code; + this.$nextTick(() => this.handleScan()); + }); + }, + resolveWarehouseBin() { + const code = (this.warehouseBinCode || '').trim(); + if (!this.canScan || !this.orderId) { + this.showError('请先提交保存后再扫码'); + return; + } + if (!code) return; + if (!this.form.warehouse_id) { + this.showError('单据缺少仓库信息'); + return; + } + uni.showLoading({ title: '识别仓位...' }); + return this.$u.api.warehouseBin.getByQrCode({ + qr_code: code, + warehouse_id: Number(this.form.warehouse_id), + }) + .then((data) => { + uni.hideLoading(); + if (!data || !data.id) { + throw new Error('未识别到仓位'); + } + // 返回 physical_warehouse_id,与单据仓库校验 + if ( + data.physical_warehouse_id + && String(data.physical_warehouse_id) !== String(this.form.warehouse_id) + ) { + this.warehouseBinId = 0; + this.warehouseBinName = ''; + throw new Error('该仓位不属于当前仓库'); + } + this.warehouseBinId = data.id; + this.warehouseBinCode = data.code || data.qr_code || code; + this.warehouseBinName = data.name || ''; + this.BillDataMessage = `仓位已选择:${this.warehouseBinName || this.warehouseBinCode}`; + speak('仓位成功'); + uni.showToast({ title: '仓位识别成功', icon: 'success' }); + }) + .catch((e) => { + uni.hideLoading(); + this.warehouseBinId = 0; + this.warehouseBinName = ''; + this.showError(e.message || '仓位识别失败'); + }); + }, + syncCanScanFromStatus(status) { + const nextCanScan = this.isEditable && canScanAtStatus(status); + if (this.canScan && !nextCanScan) { + this.phoneContinuousScan = false; + this.unregisterScanBroadcast(); + } + this.canScan = nextCanScan; + }, + loadBaseDropdowns() { + if (this.dropdownLoading) return Promise.resolve(); + this.dropdownLoading = true; + return Promise.all([ + this.ensureProcessUnitOptions().catch((e) => { + console.error('加载加工单位失败', e); + return []; + }), + this.ensureWarehouseOptions().catch((e) => { + console.error('加载仓库失败', e); + return []; + }), + ]).finally(() => { + this.dropdownLoading = false; + }); + }, + ensureProcessUnitOptions() { + if (this.processUnitOptions.length) return Promise.resolve(this.processUnitOptions); + return this.$u.api.businessUnit.list({ unit_type_id: BUSINESS_UNIT_TYPE_PROCESS }) + .then((res) => { + this.processUnitOptions = mapToSelectOptions(res); + return this.processUnitOptions; + }); + }, + ensureWarehouseOptions() { + if (this.warehouseOptions.length) return Promise.resolve(this.warehouseOptions); + return this.$u.api.physicalWarehouse.getDropdownList({ warehouse_type_id: WAREHOUSE_TYPE_FINISHED }) + .then((res) => { + this.warehouseOptions = mapToSelectOptions(res); + if (this.headerEditable && !this.form.warehouse_id) { + this.applyDefaultWarehouse(); + } + return this.warehouseOptions; + }); + }, + applyDefaultWarehouse() { + const app = getApp(); + const picked = pickDefaultWarehouse( + this.warehouseOptions, + app && app.globalData ? app.globalData.StoreNameID : '', + app && app.globalData ? app.globalData.StoreName : '', + ); + if (!picked) return; + this.form.warehouse_id = picked.value; + this.form.warehouse_name = picked.label; + }, + getEmptyForm() { + return { + order_no: '', + process_unit_id: '', + process_name: '', + warehouse_id: '', + warehouse_name: '', + remark: '', + item_data: [], + }; + }, + loadOrder(id, options = {}) { + const { rejectIfLocked = false } = options; + return this.$u.api.fpmProcessInOrder.detail({ id }) + .then((res) => { + const order = normalizeOrder(res); + if (!order) { + this.showError('单据不存在'); + return null; + } + if (rejectIfLocked && isLockedOrderStatus(order.audit_status)) { + this.showError('当前状态不可编辑'); + setTimeout(() => uni.navigateBack(), 1500); + return null; + } + this.orderId = order.id; + this.auditStatus = order.audit_status; + this.headerSaved = true; + this.form = orderToFormFields(order); + this.clearWarehouseBin(); + this.syncCanScanFromStatus(order.audit_status); + if (this.canScan) this.registerOrderScanBroadcast(); + return order; + }) + .catch((e) => { + this.showError(e.message || '加载单据失败'); + return null; + }); + }, + pickerSelectFun(type) { + if (!this.headerEditable) return; + this.selectType = type; + const openPicker = (list) => { + if (!list.length) { + this.showError('暂无可选数据'); + return; + } + this.selectList = list; + this.selectShow = true; + }; + if (type === '加工单位') { + this.ensureProcessUnitOptions() + .then(openPicker) + .catch((e) => this.showError(e.message || '加载加工单位失败')); + } else if (type === '仓库名称') { + this.ensureWarehouseOptions() + .then(openPicker) + .catch((e) => this.showError(e.message || '加载仓库失败')); + } + }, + selectConfirmFun(e) { + const item = e[0]; + if (this.selectType === '加工单位') { + this.form.process_unit_id = item.value; + this.form.process_name = item.label; + } else if (this.selectType === '仓库名称') { + this.form.warehouse_id = item.value; + this.form.warehouse_name = item.label; + } + }, + validateForm() { + if (!this.form.process_unit_id) return '请选择加工单位'; + if (!this.form.warehouse_id) return '请选择仓库名称'; + const app = getApp(); + const saleSystemId = app && app.globalData ? app.globalData.PlanDepartmentID : ''; + if (!saleSystemId) return '缺少营销体系,请重新登录'; + return ''; + }, + buildAddParam() { + const app = getApp(); + return { + inOrderType: IN_ORDER_TYPE_PROCESS, + process_unit_id: Number(this.form.process_unit_id), + warehouse_id: Number(this.form.warehouse_id), + sale_system_id: Number(app.globalData.PlanDepartmentID), + remark: this.form.remark || '', + item_data: [], + }; + }, + submitSave() { + if (this.headerSaved) { + this.showError('表头已保存,请直接扫码'); + return; + } + const err = this.validateForm(); + if (err) { + this.showError(err); + return; + } + uni.showLoading({ title: '保存中...' }); + this.$u.api.fpmProcessInOrder.add(this.buildAddParam()) + .then((res) => { + this.orderId = (res && res.id) || 0; + if (!this.orderId) { + throw new Error('保存失败,未返回单据ID'); + } + return this.$u.api.fpmProcessInOrder.detail({ id: this.orderId }); + }) + .then((detail) => { + uni.hideLoading(); + const order = normalizeOrder(detail); + this.applyOrder(order); + this.headerSaved = true; + this.clearWarehouseBin(); + this.syncCanScanFromStatus(order.audit_status); + this.showSuccess('保存成功,请先扫描仓位'); + this.registerOrderScanBroadcast(); + }) + .catch((e) => { + uni.hideLoading(); + this.showError(e.message || '保存失败'); + }); + }, + applyOrder(order) { + if (!order) return; + this.auditStatus = order.audit_status; + Object.assign(this.form, orderToFormFields(order)); + }, + handleScan(options = {}) { + const fromPhone = !!options.fromPhone; + const code = (this.QRBarCode || '').trim(); + if (!this.canScan || !this.orderId) { + this.showError('请先提交保存后再扫码'); + this.QRBarCode = ''; + this.phoneContinuousScan = false; + return; + } + const isDelete = this.BarCodeDelStatus; + if (!isDelete && !this.warehouseBinId) { + this.showError('请先扫描仓位'); + this.QRBarCode = ''; + this.phoneContinuousScan = false; + return; + } + if (!code) { + this.QRBarCode = ''; + if (fromPhone) this.scheduleNextPhoneScan(); + return; + } + const arrangeType = isDelete ? ARRANGE_TYPE.DEL : ARRANGE_TYPE.IN; + this.doScanUpdate(code, arrangeType, { fromPhone }); + }, + BarCodeDelChange(e) { + this.BarCodeDelStatus = (e.detail.value || []).length > 0; + this.BillDataMessage = this.BarCodeDelStatus ? '删除模式:扫描细码即可删除' : ''; + }, + getFineCodeScanCode(fineCode) { + if (!fineCode) return ''; + return fineCode.qr_code || fineCode.scan_code || fineCode.bar_code || ''; + }, + onDeleteFineCode(fineCode) { + if (!this.canScan || !this.orderId) { + this.showError('当前状态不可删除'); + return; + } + const scanCode = this.getFineCodeScanCode(fineCode); + if (!scanCode) { + this.showError('该细码缺少条码,无法删除'); + return; + } + uni.showModal({ + title: '提示', + content: `确认删除细码 ${scanCode}?`, + success: (res) => { + if (!res.confirm) return; + this.doScanUpdate(scanCode, ARRANGE_TYPE.DEL); + }, + }); + }, + doScanUpdate(scanCode, arrangeType, options = {}) { + const { fromPhone = false } = options; + const isDelete = arrangeType === ARRANGE_TYPE.DEL; + uni.showLoading({ title: isDelete ? '删除中...' : '处理中...' }); + return this.$u.api.fpmProcessInOrder.scanUpdate(buildScanUpdateParams({ + id: this.orderId, + scanCode, + arrangeType, + // 删除不强制仓位;录入带当前仓位 + warehouseBinId: isDelete ? 0 : this.warehouseBinId, + })) + .then((scanRes) => { + this.scanDetail = buildScanDetailFromScanResponse(scanRes); + this.BillDataMessage = isDelete ? '删除成功' : '扫描成功'; + this.QRBarCode = ''; + if (isDelete) { + speak('已删除'); + uni.showToast({ title: '删除成功', icon: 'success' }); + } else { + speak('成功'); + } + return this.$u.api.fpmProcessInOrder.detail({ id: this.orderId }) + .then((detail) => { + const order = normalizeOrder(detail); + if (order) { + this.form.item_data = order.item_data; + this.auditStatus = order.audit_status; + } + }) + .catch(() => null); + }) + .then(() => { + uni.hideLoading(); + if (fromPhone) this.scheduleNextPhoneScan(); + }) + .catch((e) => { + uni.hideLoading(); + this.phoneContinuousScan = false; + const message = e.message || (isDelete ? '删除失败' : '扫码失败'); + this.showError(message); + this.QRBarCode = ''; + }); + }, + handleStatusAction(action) { + confirmOrderStatusAction(this, { + orderId: this.orderId, + action, + onSuccess: () => this.$u.api.fpmProcessInOrder.detail({ id: this.orderId }) + .then((detail) => { + uni.hideLoading(); + const order = normalizeOrder(detail); + if (!order) return; + this.applyOrder(order); + this.syncCanScanFromStatus(order.audit_status); + this.showSuccess('操作成功'); + }), + }); + }, + showError(message) { + util.playErrorAudio(); + uni.showModal({ title: '提示', content: message, showCancel: false }); + }, + showSuccess(message) { + util.playSuccessAudio(); + uni.showToast({ title: message, icon: 'success' }); + }, + }, +}; diff --git a/src/pages/storegoods/storeGoodsProcessInView.vue b/src/pages/storegoods/storeGoodsProcessInView.vue new file mode 100644 index 0000000..0835625 --- /dev/null +++ b/src/pages/storegoods/storeGoodsProcessInView.vue @@ -0,0 +1,129 @@ + + + + + diff --git a/src/pages/sys/login/index.vue b/src/pages/sys/login/index.vue index 6607bc2..3f7eb07 100644 --- a/src/pages/sys/login/index.vue +++ b/src/pages/sys/login/index.vue @@ -138,7 +138,7 @@ export default { showApiUrlPicker: false, // 根据环境设置默认URL和选项 selectedApiUrl: config.isDevelopment ? config.devApiUrlOptions[0].value : config.productionApiUrl, - customApiUrl: 'http://192.168.1.66:50002/hcscm_weave/pda/v1', + customApiUrl: 'http://192.168.1.66:50002/hcscm/pda/v1', apiUrlList: config.isDevelopment ? config.devApiUrlOptions : [], phoneNo: '', //username: '', diff --git a/src/pages/sys/workbench/index.vue b/src/pages/sys/workbench/index.vue index eba6a2e..e8e8bdb 100644 --- a/src/pages/sys/workbench/index.vue +++ b/src/pages/sys/workbench/index.vue @@ -7,111 +7,34 @@ - - - - - - - - - - - + 销售管理 + + + + + + + 成品配布 + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 坯布管理 - - - - - - - - - - - - - 坯布出库 - - - - - - 坯布库存 - - - - - - - - - - - - - - - + + + 成品管理 + + + + + + + 加工进仓 + + +