diff --git a/src/common/http.api.js b/src/common/http.api.js index 278df00..09bd412 100644 --- a/src/common/http.api.js +++ b/src/common/http.api.js @@ -29,6 +29,9 @@ const install = (Vue, vm) => { const FPM_PRC_IN_PREFIX = '/product/fpmPrcInOrder/'; const fpmPrcInUrl = (name) => getApiUrl() + FPM_PRC_IN_PREFIX + name; + const FPM_PRT_OUT_PREFIX = '/product/fpmPrtOutOrder/'; + const fpmPrtOutUrl = (name) => getApiUrl() + FPM_PRT_OUT_PREFIX + name; + // 将各个定义的接口名称,统一放进对象挂载到vm.$u.api(因为vm就是this,也即this.$u.api)下 vm.$u.api = { @@ -109,6 +112,18 @@ const install = (Vue, vm) => { statusCancel: (params = {}) => vm.$u.putJson(fpmPrcInUrl('updateFpmPrcInOrderStatusCancel'), params), }, + // 成品采购退货出仓单 + fpmPrtOutOrder: { + list: (params = {}) => vm.$u.get(fpmPrtOutUrl('getFpmPrtOutOrderList'), params), + detail: (params = {}) => vm.$u.get(fpmPrtOutUrl('getFpmPrtOutOrder'), params), + add: (params = {}) => vm.$u.postJson(fpmPrtOutUrl('addFpmPrtOutOrder'), params), + scanUpdate: (params = {}) => vm.$u.putJson(fpmPrtOutUrl('updateFpmPrtOutOrder'), params), + statusPass: (params = {}) => vm.$u.putJson(fpmPrtOutUrl('updateFpmPrtOutOrderStatusPass'), params), + statusWait: (params = {}) => vm.$u.putJson(fpmPrtOutUrl('updateFpmPrtOutOrderStatusWait'), params), + statusReject: (params = {}) => vm.$u.putJson(fpmPrtOutUrl('updateFpmPrtOutOrderStatusReject'), params), + statusCancel: (params = {}) => vm.$u.putJson(fpmPrtOutUrl('updateFpmPrtOutOrderStatusCancel'), params), + }, + // 物理仓库下拉 physicalWarehouse: { getDropdownList: (params = {}) => vm.$u.get('/warehouse/physicalWarehouse/getPhysicalWarehouseDropdownList', params), @@ -142,7 +157,7 @@ const install = (Vue, vm) => { // PDA登录接口 pdaLogin: (params = {}) => vm.$u.postJson('/login', params), pdaLogout: (params = {}) => vm.$u.postJson('/logout', params), - // 修改密码:PUT pda/v1/user/updatePassword + // 修改密码:PUT pda/v1/user/updatePassword(system.UpdateUserPasswordParam: password, user_id) updatePassword: (params = {}) => vm.$u.putJson('/user/updatePassword', params), // 登录后获取当前用户信息、菜单与按钮权限 pdaGetInformation: (params = {}) => vm.$u.get('/information', params), diff --git a/src/common/list-filter.scss b/src/common/list-filter.scss index f92c59d..5b0c4bb 100644 --- a/src/common/list-filter.scss +++ b/src/common/list-filter.scss @@ -1,14 +1,37 @@ @import '@/common/pda-typography.scss'; page { background-color: #F8F8F8; } -.filterBar { display: flex; align-items: center; padding: 16rpx 20rpx; background: #fff; gap: 16rpx; } +.filterBar { + display: flex; + align-items: center; + padding: 16rpx 20rpx; + background: #fff; + gap: 16rpx; +} +/* 列表顶栏搜索框统一放大(覆盖 u-search 默认 64rpx) */ +.filterBar ::v-deep .u-search { + flex: 1; +} +.filterBar ::v-deep .u-content { + height: $pda-row-min-height !important; +} +.filterBar ::v-deep .u-input { + font-size: $pda-font-body !important; +} +.filterBar ::v-deep .u-placeholder-class { + font-size: $pda-font-placeholder !important; +} +.filterBar ::v-deep .u-icon-wrap .u-icon, +.filterBar ::v-deep .u-clear-icon { + font-size: 40rpx !important; +} .filterBtn { display: flex; flex-direction: column; align-items: center; justify-content: center; - min-width: 88rpx; - min-height: 76rpx; + min-width: 96rpx; + min-height: $pda-row-min-height; padding: 8rpx 10rpx; border: 2rpx solid transparent; border-radius: 12rpx; @@ -62,10 +85,10 @@ page { background-color: #F8F8F8; } .filterInput { display: flex; align-items: center; - min-height: $pda-row-min-height; - padding: 0 18rpx; + min-height: 112rpx; + padding: 0 22rpx; background: #f5f6f8; - border-radius: 8rpx; + border-radius: 12rpx; box-sizing: border-box; } ::v-deep .filterInput .u-input__input { @@ -80,10 +103,10 @@ page { background-color: #F8F8F8; } display: flex; align-items: center; justify-content: space-between; - min-height: $pda-row-min-height; - padding: 0 18rpx; + min-height: 112rpx; + padding: 0 22rpx; background: #f5f6f8; - border-radius: 8rpx; + border-radius: 12rpx; box-sizing: border-box; font-size: $pda-font-body; color: #202328; diff --git a/src/common/storeGoodsPurchaseReturnOut.js b/src/common/storeGoodsPurchaseReturnOut.js new file mode 100644 index 0000000..c4a7163 --- /dev/null +++ b/src/common/storeGoodsPurchaseReturnOut.js @@ -0,0 +1,429 @@ +/** + * 成品采购退货出仓单常量与数据工具 + * + * 真实接口请求统一注册在 src/common/http.api.js 的 vm.$u.api.fpmPrtOutOrder 下。 + */ +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 function toAuditStatus(status) { + const n = Number(status); + return Number.isFinite(n) ? n : DRAFT_AUDIT_STATUS; +} + +export const AUDIT_STATUS_MAP = { + 1: '待审核', + 2: '已审核', + 3: '已驳回', + 4: '已作废', +}; + +/** 操作类型:1录入 3删除 */ +export const ARRANGE_TYPE = { + IN: 1, + DEL: 3, +}; + +/** 出仓类型:采购退货出仓单 WarehouseGoodOutTypePurchaseReturn = 4 */ +export const OUT_ORDER_TYPE_PURCHASE_RETURN = 4; +export const OUT_ORDER_TYPE_PURCHASE_RETURN_NAME = '采购退货出仓单'; + +/** 订单类型:1大货 2剪板 3客订大货 4客订剪板 */ +export const SALE_MODE = { + BULK: 1, + SHEAR: 2, + CUSTOMER_BULK: 3, + CUSTOMER_SHEAR: 4, +}; + +export const SALE_MODE_MAP = { + [SALE_MODE.BULK]: '大货', + [SALE_MODE.SHEAR]: '剪板', + [SALE_MODE.CUSTOMER_BULK]: '客订大货', + [SALE_MODE.CUSTOMER_SHEAR]: '客订剪板', +}; + +export const SALE_MODE_OPTIONS = [ + { value: SALE_MODE.BULK, label: SALE_MODE_MAP[SALE_MODE.BULK] }, + { value: SALE_MODE.SHEAR, label: SALE_MODE_MAP[SALE_MODE.SHEAR] }, + { value: SALE_MODE.CUSTOMER_BULK, label: SALE_MODE_MAP[SALE_MODE.CUSTOMER_BULK] }, + { value: SALE_MODE.CUSTOMER_SHEAR, label: SALE_MODE_MAP[SALE_MODE.CUSTOMER_SHEAR] }, +]; + +/** 往来单位类型:成品供应商 */ +export const BUSINESS_UNIT_TYPE_PRODUCT_SUPPLIER = 15; + +/** 成品物理仓类型 */ +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 { mapToSelectOptions } from '@/common/remoteSelect'; + +/** 匹数:后端 ×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; + const outType = order.out_order_type || OUT_ORDER_TYPE_PURCHASE_RETURN; + return { + id: order.id, + order_no: order.order_no || '', + audit_status: toAuditStatus(order.audit_status), + audit_status_name: order.audit_status_name || AUDIT_STATUS_MAP[toAuditStatus(order.audit_status)] || '', + biz_unit_id: order.biz_unit_id || '', + biz_unit_name: order.biz_unit_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 || '', + sale_mode: order.sale_mode || '', + sale_mode_name: order.sale_mode_name || SALE_MODE_MAP[order.sale_mode] || '', + out_order_type: outType, + out_order_type_name: order.out_order_type_name + || order.in_order_type_name + || OUT_ORDER_TYPE_PURCHASE_RETURN_NAME, + remark: order.remark || '', + warehouse_out_time: (order.warehouse_out_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); + const qrCode = fc.qr_code || fc.long_code || ''; + const barCode = fc.bar_code || fc.digital_code || fc.short_code || ''; + return { + id: fc.id, + volume_number: fc.volume_number != null && fc.volume_number !== '' ? String(fc.volume_number) : '', + extern_volume_number: fc.extern_volume_number != null && fc.extern_volume_number !== '' + ? String(fc.extern_volume_number) + : '', + roll: formatRoll(fc.roll), + weight: formatWeightKg(weightRaw), + bar_code: barCode, + qr_code: qrCode, + digital_code: fc.digital_code || '', + long_code: fc.long_code || '', + short_code: fc.short_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: qrCode || barCode || '', + }; +} + +export function normalizeItem(item) { + const weightRaw = item.total_weight != null + ? item.total_weight + : (item.settle_weight != null ? item.settle_weight : item.out_weight); + 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 || '', + out_roll: formatRoll(item.out_roll), + out_weight: formatWeightKg(weightRaw), + 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 || '', + out_roll: 0, + out_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 || '', + out_roll: 0, + out_weight: 0, + fine_codes: [], + }); + } + const colorGroup = productGroup.colors.get(colorKey); + productGroup.out_roll = Number((productGroup.out_roll + Number(item.out_roll || 0)).toFixed(2)); + productGroup.out_weight = Number((productGroup.out_weight + Number(item.out_weight || 0)).toFixed(2)); + colorGroup.out_roll = Number((colorGroup.out_roll + Number(item.out_roll || 0)).toFixed(2)); + colorGroup.out_weight = Number((colorGroup.out_weight + Number(item.out_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, + out_roll: product.out_roll, + out_weight: product.out_weight, + colors: Array.from(product.colors.values()), + })); +} + +export function getEmptyScanDetail() { + return { + quote_order_no: '', + dyelot_number: '', + volume_number: '', + extern_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) : '', + extern_volume_number: res.extern_volume_number != null && res.extern_volume_number !== '' + ? String(res.extern_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), + }; +} + +/** 构建扫码请求参数(OpenAPI: PDAUpdateFpmPrtOutOrderParam) */ +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 > 25) { + 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) { + const s = toAuditStatus(status); + return s === AUDIT_STATUS.PENDING || s === AUDIT_STATUS.REJECTED; +} + +export function isLockedOrderStatus(status) { + const s = toAuditStatus(status); + return s === AUDIT_STATUS.APPROVED || s === AUDIT_STATUS.VOIDED; +} + +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; + if (batch.length > pageSize) return acc.concat(batch); + 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) return []; + const s = toAuditStatus(status); + if (s === AUDIT_STATUS.APPROVED) { + return [{ label: '消审', action: 'unapprove' }]; + } + if (!canScanAtStatus(s)) return []; + return [ + { label: '审核', action: 'approve' }, + { label: '作废', action: 'void' }, + ]; +} + +export function getViewStatusActionButtons(status) { + const s = toAuditStatus(status); + if (s === AUDIT_STATUS.PENDING || s === AUDIT_STATUS.REJECTED) { + return [ + { label: '编辑', action: 'edit' }, + { label: '审核', action: 'approve' }, + { label: '作废', action: 'void' }, + ]; + } + if (s === AUDIT_STATUS.APPROVED) { + return [{ label: '消审', action: 'unapprove' }]; + } + return []; +} + +export function orderToFormFields(order) { + return { + order_no: order.order_no, + biz_unit_id: order.biz_unit_id, + biz_unit_name: order.biz_unit_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, + sale_mode: order.sale_mode || '', + sale_mode_name: order.sale_mode_name || SALE_MODE_MAP[order.sale_mode] || '', + out_order_type: order.out_order_type || OUT_ORDER_TYPE_PURCHASE_RETURN, + out_order_type_name: order.out_order_type_name || OUT_ORDER_TYPE_PURCHASE_RETURN_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.fpmPrtOutOrder; + 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/components/card/storeGoodsPurchaseReturnOutItem.vue b/src/components/card/storeGoodsPurchaseReturnOutItem.vue new file mode 100644 index 0000000..82d652a --- /dev/null +++ b/src/components/card/storeGoodsPurchaseReturnOutItem.vue @@ -0,0 +1,61 @@ + + + + + diff --git a/src/manifest.json b/src/manifest.json index a5b6c8f..c4538b8 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -2,8 +2,8 @@ "name" : "浩拓ERP", "appid" : "__UNI__F79F300", "description" : "浩拓ERP", - "versionName" : "1.1.21", - "versionCode" : 121, + "versionName" : "1.1.22", + "versionCode" : 122, "transformPx" : false, "app-plus" : { "optimization" : { diff --git a/src/pages.json b/src/pages.json index e141cfc..2738dd9 100644 --- a/src/pages.json +++ b/src/pages.json @@ -480,6 +480,34 @@ "navigationBarTitleText": "采购进仓单详情", "enablePullDownRefresh": false } + },{ + "path" : "pages/storegoods/storeGoodsPurchaseReturnOutList", + "style" : + { + "navigationBarTitleText": "成品采购退货出仓", + "enablePullDownRefresh": false + } + },{ + "path" : "pages/storegoods/storeGoodsPurchaseReturnOutAdd", + "style" : + { + "navigationBarTitleText": "新增采购退货出仓单", + "enablePullDownRefresh": false + } + },{ + "path" : "pages/storegoods/storeGoodsPurchaseReturnOutEdit", + "style" : + { + "navigationBarTitleText": "编辑采购退货出仓单", + "enablePullDownRefresh": false + } + },{ + "path" : "pages/storegoods/storeGoodsPurchaseReturnOutView", + "style" : + { + "navigationBarTitleText": "查看采购退货出仓单", + "enablePullDownRefresh": false + } },{ "path" : "pages/storegoods/storeGoodsProcessReturnInList", "style" : diff --git a/src/pages/storegoods/storeGoodsPurchaseReturnOutAdd.vue b/src/pages/storegoods/storeGoodsPurchaseReturnOutAdd.vue new file mode 100644 index 0000000..42d391f --- /dev/null +++ b/src/pages/storegoods/storeGoodsPurchaseReturnOutAdd.vue @@ -0,0 +1,117 @@ + + + + + diff --git a/src/pages/storegoods/storeGoodsPurchaseReturnOutEdit.vue b/src/pages/storegoods/storeGoodsPurchaseReturnOutEdit.vue new file mode 100644 index 0000000..11b1921 --- /dev/null +++ b/src/pages/storegoods/storeGoodsPurchaseReturnOutEdit.vue @@ -0,0 +1,102 @@ + + + + + diff --git a/src/pages/storegoods/storeGoodsPurchaseReturnOutList.vue b/src/pages/storegoods/storeGoodsPurchaseReturnOutList.vue new file mode 100644 index 0000000..66c9568 --- /dev/null +++ b/src/pages/storegoods/storeGoodsPurchaseReturnOutList.vue @@ -0,0 +1,274 @@ + + + + + diff --git a/src/pages/storegoods/storeGoodsPurchaseReturnOutMixin.js b/src/pages/storegoods/storeGoodsPurchaseReturnOutMixin.js new file mode 100644 index 0000000..fd30756 --- /dev/null +++ b/src/pages/storegoods/storeGoodsPurchaseReturnOutMixin.js @@ -0,0 +1,542 @@ +/** + * 成品采购退货出仓单表单 mixin(新增/编辑共用) + * + * 1. 先填表头(供应商 / 仓库 / 营销体系 / 订单类型 / 备注)提交 add,拿到 id 后可扫码 + * 2. 扫码走 updateFpmPrtOutOrder(arrange_type: 1 录入 / 3 删除),不强制扫仓位 + * 3. 手机扫码成功展示详情后自动再次调起扫码,形成连续扫 + */ +import util from '@/common/util'; +import scanMixin from '@/common/scanMixin.js'; +import PlusBarcodePanel from '@/components/common/PlusBarcodePanel.vue'; +import remoteSelectMixin from '@/common/remoteSelectMixin.js'; +import { withNameParam } from '@/common/remoteSelect'; +import { initTts, speak } from '@/common/tts.js'; +import { + AUDIT_STATUS_MAP, + ARRANGE_TYPE, + BUSINESS_UNIT_TYPE_PRODUCT_SUPPLIER, + WAREHOUSE_TYPE_FINISHED, + OUT_ORDER_TYPE_PURCHASE_RETURN, + OUT_ORDER_TYPE_PURCHASE_RETURN_NAME, + SALE_MODE, + SALE_MODE_MAP, + SALE_MODE_OPTIONS, + normalizeOrder, + mapToSelectOptions, + canScanAtStatus, + isLockedOrderStatus, + getFormStatusActionButtons, + orderToFormFields, + confirmOrderStatusAction, + DRAFT_AUDIT_STATUS, + DRAFT_AUDIT_STATUS_NAME, + getEmptyScanDetail, + buildScanDetailFromScanResponse, + buildScanUpdateParams, + pickDefaultWarehouse, + formatDisplayTime, +} from '@/common/storeGoodsPurchaseReturnOut'; + +export default { + components: { PlusBarcodePanel }, + mixins: [scanMixin, remoteSelectMixin], + data() { + return { + pageMode: 'add', + orderId: 0, + form: this.getEmptyForm(), + headerSaved: false, + headerCollapsed: false, + selectShow: false, + selectList: [], + selectType: '', + canScan: false, + QRBarCode: '', + BarCodeDelStatus: false, + BillDataMessage: '', + scanDetail: getEmptyScanDetail(), + auditStatus: 0, + supplierOptions: [], + warehouseOptions: [], + saleSystemOptions: [], + saleModeOptions: SALE_MODE_OPTIONS, + dropdownLoading: false, + /** 手机连续扫码开关:成功后自动再调起;取消/失败则关闭 */ + phoneContinuousScan: false, + }; + }, + 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() { + return this.canScan; + }, + showQrScanBar() { + return this.canScan; + }, + qrDisabledTip() { + if (!this.canScan) 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: { + handlePhoneScan() { + if (!this.canScan || !this.orderId) { + this.showError('请先提交保存后再扫码'); + return; + } + this.phoneContinuousScan = false; + this.togglePhoneScanPanel(); + }, + onPlusBarcodeSuccess(scanResult) { + this.QRBarCode = String(scanResult || '').trim().replace(/[\r\n]/g, ''); + this.$nextTick(() => this.handleScan()); + }, + openContinuousPhoneScan() { + if (this.phoneScanPanelOpen) return; + 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.phoneScanPanelOpen) return; + 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; + this.QRBarCode = code; + this.$nextTick(() => this.handleScan()); + }); + }, + syncCanScanFromStatus(status) { + const nextCanScan = this.isEditable && canScanAtStatus(status); + if (this.canScan && !nextCanScan) { + this.phoneContinuousScan = false; + this.closePhoneScanPanel(); + this.unregisterScanBroadcast(); + } + this.canScan = nextCanScan; + }, + loadBaseDropdowns() { + if (this.dropdownLoading) return Promise.resolve(); + this.dropdownLoading = true; + if (this.headerEditable) this.applyDefaultSaleSystem(); + return Promise.all([ + this.ensureSupplierOptions().catch((e) => { + console.error('加载供应商失败', e); + return []; + }), + this.ensureWarehouseOptions().catch((e) => { + console.error('加载仓库失败', e); + return []; + }), + this.ensureSaleSystemOptions().catch((e) => { + console.error('加载营销体系失败', e); + return []; + }), + ]).finally(() => { + this.dropdownLoading = false; + }); + }, + ensureSupplierOptions() { + if (this.supplierOptions.length) return Promise.resolve(this.supplierOptions); + return this.$u.api.businessUnit.list({ unit_type_id: BUSINESS_UNIT_TYPE_PRODUCT_SUPPLIER }) + .then((res) => { + this.supplierOptions = mapToSelectOptions(res); + return this.supplierOptions; + }); + }, + 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; + }); + }, + ensureSaleSystemOptions() { + if (this.saleSystemOptions.length) return Promise.resolve(this.saleSystemOptions); + return this.$u.api.saleSystem.getDropdownList() + .then((res) => { + this.saleSystemOptions = mapToSelectOptions(res); + if (this.headerEditable) this.applyDefaultSaleSystem(); + return this.saleSystemOptions; + }); + }, + fetchRemoteSelectOptions(type, keyword) { + const empty = !String(keyword || '').trim(); + if (type === '供应商') { + return this.$u.api.businessUnit.list(withNameParam({ unit_type_id: BUSINESS_UNIT_TYPE_PRODUCT_SUPPLIER }, keyword)) + .then((res) => { + const list = mapToSelectOptions(res); + if (empty) this.supplierOptions = list; + return list; + }); + } + if (type === '仓库名称') { + return this.$u.api.physicalWarehouse.getDropdownList(withNameParam({ warehouse_type_id: WAREHOUSE_TYPE_FINISHED }, keyword)) + .then((res) => { + const list = mapToSelectOptions(res); + if (empty) this.warehouseOptions = list; + return list; + }); + } + if (type === '营销体系') { + return this.$u.api.saleSystem.getDropdownList(withNameParam({}, keyword)) + .then((res) => { + const list = mapToSelectOptions(res); + if (empty) this.saleSystemOptions = list; + return list; + }); + } + return Promise.resolve([]); + }, + 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; + }, + applyDefaultSaleSystem() { + if (this.form.sale_system_id) { + if (!this.form.sale_system_name && this.saleSystemOptions.length) { + const found = this.saleSystemOptions.find( + (item) => String(item.value) === String(this.form.sale_system_id), + ); + if (found) this.form.sale_system_name = found.label; + } + return; + } + const app = getApp(); + const gd = app && app.globalData ? app.globalData : {}; + const id = gd.PlanDepartmentID; + if (!id) return; + this.form.sale_system_id = id; + this.form.sale_system_name = gd.PlanDepartmentName || ''; + if (!this.form.sale_system_name && this.saleSystemOptions.length) { + const found = this.saleSystemOptions.find((item) => String(item.value) === String(id)); + if (found) this.form.sale_system_name = found.label; + } + }, + getEmptyForm() { + const app = getApp(); + const gd = app && app.globalData ? app.globalData : {}; + return { + order_no: '', + biz_unit_id: '', + biz_unit_name: '', + warehouse_id: '', + warehouse_name: '', + sale_system_id: gd.PlanDepartmentID || '', + sale_system_name: gd.PlanDepartmentName || '', + sale_mode: SALE_MODE.BULK, + sale_mode_name: SALE_MODE_MAP[SALE_MODE.BULK], + out_order_type: OUT_ORDER_TYPE_PURCHASE_RETURN, + out_order_type_name: OUT_ORDER_TYPE_PURCHASE_RETURN_NAME, + remark: '', + item_data: [], + }; + }, + loadOrder(id, options = {}) { + const { rejectIfLocked = false } = options; + return this.$u.api.fpmPrtOutOrder.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.headerCollapsed = true; + this.form = orderToFormFields(order); + 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; + if (type === '订单类型') { + this.selectType = type; + if (!this.saleModeOptions.length) { + this.showError('暂无可选数据'); + return; + } + this.selectList = this.saleModeOptions; + this.selectShow = true; + return; + } + const cache = { + '供应商': this.supplierOptions, + '仓库名称': this.warehouseOptions, + '营销体系': this.saleSystemOptions, + }; + if (cache[type]) this.openSelectPicker(type, cache[type]); + }, + selectConfirmFun(e) { + const item = e[0]; + if (this.selectType === '供应商') { + this.form.biz_unit_id = item.value; + this.form.biz_unit_name = item.label; + } else if (this.selectType === '仓库名称') { + this.form.warehouse_id = item.value; + this.form.warehouse_name = item.label; + } else if (this.selectType === '营销体系') { + this.form.sale_system_id = item.value; + this.form.sale_system_name = item.label; + } else if (this.selectType === '订单类型') { + this.form.sale_mode = item.value; + this.form.sale_mode_name = item.label; + } + }, + validateForm() { + if (!this.form.biz_unit_id) return '请选择供应商'; + if (!this.form.warehouse_id) return '请选择仓库名称'; + if (!this.form.sale_system_id) return '请选择营销体系'; + if (!this.form.sale_mode) return '请选择订单类型'; + return ''; + }, + buildAddParam() { + return { + // OpenAPI: product.AddFpmOutOrderParam + outOrderType: OUT_ORDER_TYPE_PURCHASE_RETURN, + biz_unit_id: Number(this.form.biz_unit_id), + warehouse_id: Number(this.form.warehouse_id), + sale_system_id: Number(this.form.sale_system_id), + sale_mode: Number(this.form.sale_mode), + warehouse_out_time: formatDisplayTime(new Date(), 'YYYY-MM-DD'), + 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.fpmPrtOutOrder.add(this.buildAddParam()) + .then((res) => { + this.orderId = (res && res.id) || 0; + if (!this.orderId) { + throw new Error('保存失败,未返回单据ID'); + } + return this.$u.api.fpmPrtOutOrder.detail({ id: this.orderId }); + }) + .then((detail) => { + uni.hideLoading(); + const order = normalizeOrder(detail); + this.applyOrder(order); + this.headerSaved = true; + this.headerCollapsed = true; + this.syncCanScanFromStatus(order.audit_status); + this.showSuccess('保存成功,请开始扫码', '保存成功', { voiceOnly: true }); + 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; + } + if (!code) { + this.QRBarCode = ''; + if (fromPhone) this.scheduleNextPhoneScan(); + return; + } + const arrangeType = this.BarCodeDelStatus ? 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.digital_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.fpmPrtOutOrder.scanUpdate(buildScanUpdateParams({ + id: this.orderId, + scanCode, + arrangeType, + })) + .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.fpmPrtOutOrder.detail({ id: this.orderId }) + .then((detail) => { + const order = normalizeOrder(detail); + if (order) { + this.form.item_data = order.item_data; + this.auditStatus = order.audit_status; + this.scanDetail = { + ...this.scanDetail, + order_roll: order.total_roll, + order_weight: order.total_weight, + }; + } + }) + .catch(() => null); + }) + .then(() => { + uni.hideLoading(); + if (fromPhone) this.scheduleNextPhoneScan(); + }) + .catch((e) => { + uni.hideLoading(); + this.phoneContinuousScan = false; + const message = e.message || (isDelete ? '删除失败' : '扫码失败'); + speak(isDelete ? '删除失败' : '扫码失败'); + uni.showToast({ title: message, icon: 'none', duration: 2500 }); + this.QRBarCode = ''; + }); + }, + handleStatusAction(action) { + confirmOrderStatusAction(this, { + orderId: this.orderId, + action, + onSuccess: () => this.$u.api.fpmPrtOutOrder.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(util.statusSuccessVoice(action)); + }), + }); + }, + showError(message) { + util.playErrorAudio(message); + uni.showModal({ title: '提示', content: message, showCancel: false }); + }, + showSuccess(message, voiceText, options) { + util.playSuccessAudio(voiceText || message, options); + uni.showToast({ title: message, icon: 'success' }); + }, + }, +}; diff --git a/src/pages/storegoods/storeGoodsPurchaseReturnOutView.vue b/src/pages/storegoods/storeGoodsPurchaseReturnOutView.vue new file mode 100644 index 0000000..2076e54 --- /dev/null +++ b/src/pages/storegoods/storeGoodsPurchaseReturnOutView.vue @@ -0,0 +1,139 @@ + + + + + diff --git a/src/pages/sys/user/pwd.vue b/src/pages/sys/user/pwd.vue index eca9338..cb20668 100644 --- a/src/pages/sys/user/pwd.vue +++ b/src/pages/sys/user/pwd.vue @@ -3,19 +3,10 @@ 请设置登录密码
定期更新密码提高安全性
- - - - - - - - + + - - - 密码必须是8-16位的数字,字符组合(不能是纯数字) 提交 @@ -26,46 +17,19 @@ /** * Copyright (c) 2013-Now http://aidex.vip All rights reserved. */ -import base64 from '@/common/base64.js'; +import { getUserInformation, getLoginData } from '@/common/userSession.js'; + export default { data() { return { model: { - oldPassword: '', - newPassword: '', - confirmPassword: '' + password: '' }, rules: { - oldPassword: [ + password: [ { required: true, - message: '请输入旧密码', - trigger: ['change','blur'], - } - ], - newPassword: [ - { - required: true, - message: '请输入新密码', - trigger: ['change','blur'], - }, - { - pattern: /^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]+\S{5,12}$/, - message: '需同时含有字母和数字,长度在6-12之间', - trigger: ['change','blur'], - } - ], - confirmPassword: [ - { - required: true, - message: '请重新输入密码', - trigger: ['change','blur'], - }, - { - validator: (rule, value, callback) => { - return value === this.model.newPassword; - }, - message: '两次输入的密码不相等', + message: '请输入密码', trigger: ['change','blur'], } ], @@ -76,18 +40,33 @@ export default { this.$refs.uForm.setRules(this.rules); }, methods: { + getCurrentUserId() { + const info = getUserInformation(); + if (info && info.user_id != null) return Number(info.user_id); + const login = getLoginData(); + if (login && login.user_id != null) return Number(login.user_id); + const app = getApp(); + const loginId = app && app.globalData ? app.globalData.LoginID : 0; + return Number(loginId || 0); + }, submit() { this.$refs.uForm.validate(valid => { if (valid) { + const userId = this.getCurrentUserId(); + if (!userId) { + this.$u.toast('缺少用户信息,请重新登录'); + return; + } + // OpenAPI: system.UpdateUserPasswordParam this.$u.api.updatePassword({ - old_password: this.model.oldPassword, - new_password: this.model.newPassword + password: this.model.password, + user_id: userId, }).then(() => { const saved = uni.getStorageSync('UserInfo'); if (saved && typeof saved === 'object') { uni.setStorageSync('UserInfo', { ...saved, - password: this.model.newPassword + password: this.model.password }); } uni.showModal({ diff --git a/src/pages/sys/workbench/index.vue b/src/pages/sys/workbench/index.vue index 5823642..24dbdd1 100644 --- a/src/pages/sys/workbench/index.vue +++ b/src/pages/sys/workbench/index.vue @@ -117,6 +117,15 @@ export default { router: 'FinishPurchaseWarehouseEntry', icon: 'icon-hetongguanli', color: 'icon-color03' + }, + { + name: '采购退货出仓', + subtitle: 'PURCHASE RETURN OUT', + backgroundImage: '/static/workbench/processing-out.png', + url: '/pages/storegoods/storeGoodsPurchaseReturnOutList', + router: 'FpPurchaseReturnDeliverGodown', + icon: 'icon-hetongguanli', + color: 'icon-color05' } ] }