From d5ac872976e858d750d545f951c460abb1f163ac Mon Sep 17 00:00:00 2001 From: zhongwenkai <3478244299@qq.com> Date: Thu, 18 Jun 2026 11:37:50 +0800 Subject: [PATCH] =?UTF-8?q?feat=EF=BC=9A=E4=BB=93=E5=82=A8=E7=AE=A1?= =?UTF-8?q?=E7=90=86-=E5=A4=87=E4=BB=B6=E5=BA=93=E5=AD=98=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/mes/sparepart.js | 17 + src/locales/zh-CN.js | 18 + src/pages.json | 7 + .../pages/moldRepair/userSelect.vue | 8 +- .../pages/sparepartInbound/create.vue | 85 +-- .../pages/sparepartInventory/index.vue | 582 ++++++++++++++++++ .../pages/sparepartOutbound/create.vue | 38 +- src/utils/permissionMenu.js | 2 + 8 files changed, 669 insertions(+), 88 deletions(-) create mode 100644 src/pages_function/pages/sparepartInventory/index.vue diff --git a/src/api/mes/sparepart.js b/src/api/mes/sparepart.js index 161bb98..896e9ee 100644 --- a/src/api/mes/sparepart.js +++ b/src/api/mes/sparepart.js @@ -29,3 +29,20 @@ export function getSparepartStockCount(productId) { params: { productId } }) } + +// 备件库存查询(分页) +export function getSparepartInventoryPage(params) { + return request({ + url: '/admin-api/erp/stock/page', + method: 'get', + params + }) +} + +// 仓库简单列表 +export function getWarehouseSimpleList() { + return request({ + url: '/admin-api/erp/warehouse/simple-list', + method: 'get' + }) +} diff --git a/src/locales/zh-CN.js b/src/locales/zh-CN.js index 58581db..ef09024 100644 --- a/src/locales/zh-CN.js +++ b/src/locales/zh-CN.js @@ -1454,5 +1454,23 @@ export default { deleteSuccess: '删除成功', empty: '暂无出库单据', createTitle: '新增备件出库' + }, + sparepartInventory: { + moduleName: '备件库存查询', + searchPlaceholder: '请输入备件编码或名称', + allWarehouse: '全部仓库', + warehousePlaceholder: '仓库筛选', + productName: '物料名称', + barCode: '物料编码', + warehouse: '仓库', + area: '库区', + count: '基本数量', + stockDisplay: '库存展示', + unit: '单位', + category: '物料分类', + packagingRule: '包装/换算规则', + recentInTime: '最近入库', + recentOutTime: '最近出库', + empty: '暂无备件库存数据' } } diff --git a/src/pages.json b/src/pages.json index a9be7da..af11d13 100644 --- a/src/pages.json +++ b/src/pages.json @@ -416,6 +416,13 @@ "navigationStyle": "custom" } }, + { + "path": "sparepartInventory/index", + "style": { + "navigationBarTitleText": "备件库存查询", + "navigationStyle": "custom" + } + }, { "path": "keypart/index", diff --git a/src/pages_function/pages/moldRepair/userSelect.vue b/src/pages_function/pages/moldRepair/userSelect.vue index 17ea710..8909271 100644 --- a/src/pages_function/pages/moldRepair/userSelect.vue +++ b/src/pages_function/pages/moldRepair/userSelect.vue @@ -63,15 +63,18 @@ const selectedId = ref('') const searchText = ref('') const userList = ref([]) const loading = ref(false) +const fromSource = ref('moldRepair') // moldRepair | sparepartInbound | sparepartOutbound let searchTimer = null const pageTitle = computed(() => { + if (field.value === 'operator') return '选择经办人' return field.value === 'confirmBy' ? t('moldRepair.confirmBy') : t('moldRepair.acceptedBy') }) onLoad(async (options) => { field.value = String(options?.field || 'acceptedBy') selectedId.value = String(options?.selectedId || '') + fromSource.value = String(options?.from || 'moldRepair') await loadUsers() }) @@ -120,7 +123,10 @@ function handleConfirm() { uni.showToast({ title: t('moldRepair.validatorUserRequired'), icon: 'none' }) return } - getApp().globalData._moldRepairUserSelectResult = { + // 根据来源使用不同的 globalData key + const keyMap = { sparepartInbound: '_sparepartInboundUserSelectResult', sparepartOutbound: '_sparepartOutboundUserSelectResult' } + const key = keyMap[fromSource.value] || '_moldRepairUserSelectResult' + getApp().globalData[key] = { field: field.value === 'confirmBy' ? 'confirmBy' : 'acceptedBy', user } diff --git a/src/pages_function/pages/sparepartInbound/create.vue b/src/pages_function/pages/sparepartInbound/create.vue index da20b4d..b3d3b64 100644 --- a/src/pages_function/pages/sparepartInbound/create.vue +++ b/src/pages_function/pages/sparepartInbound/create.vue @@ -38,26 +38,11 @@ *经办人 - - - {{ selectedOperator ? selectedOperator.label : '请选择经办人' }} + + + {{ selectedOperatorName || '请选择经办人' }} - - - - - {{ item.label }} - - - 暂无数据 - - + @@ -158,7 +143,6 @@ import { useI18n } from 'vue-i18n' import NavBar from '@/components/common/NavBar.vue' import { createSparepartInbound } from '@/api/mes/sparepartInbound' import { getSparepartDetail } from '@/api/mes/sparepart' -import { getSimpleUserList } from '@/api/mes/moldget' const { t } = useI18n() @@ -217,10 +201,9 @@ async function handleScanCode(code) { // 入库时间 const inboundDate = ref(formatDate(new Date())) -// 经办人 -const operatorOptions = ref([]) -const selectedOperator = ref(null) -const showOperatorDropdown = ref(false) +// 经办人(页面选择模式) +const selectedOperatorId = ref(null) +const selectedOperatorName = ref('') // 备注 const remark = ref('') @@ -280,24 +263,11 @@ function removeItem(idx) { } // 经办人 -function toggleOperatorDropdown() { - showOperatorDropdown.value = !showOperatorDropdown.value -} -function handleSelectOperator(item) { - selectedOperator.value = item - showOperatorDropdown.value = false -} -async function loadOperators() { - try { - const res = await getSimpleUserList() - const data = Array.isArray(res) ? res : (Array.isArray(res?.data) ? res.data : []) - operatorOptions.value = data.map((u) => ({ - value: u.id || u.userId, - label: u.nickname || u.userName || u.name || String(u.id || '') - })) - } catch (e) { - console.error('loadOperators error', e) - } +function goSelectOperator() { + getApp().globalData._sparepartInboundUserFrom = 'inbound' + uni.navigateTo({ + url: '/pages_function/pages/moldRepair/userSelect?field=operator&from=sparepartInbound' + }) } // 附件 @@ -365,7 +335,7 @@ async function handleSubmit() { uni.showToast({ title: '请选择入库时间', icon: 'none' }) return } - if (!selectedOperator.value) { + if (!selectedOperatorId.value) { uni.showToast({ title: '请选择经办人', icon: 'none' }) return } @@ -390,7 +360,7 @@ async function handleSubmit() { const submitData = { isCode: true, inTime: inboundDate.value ? new Date(inboundDate.value.replace(/-/g, '/')).getTime() : Date.now(), - stockUserId: String(selectedOperator.value.value), + stockUserId: String(selectedOperatorId.value), supplierId: itemList.value[0]?.supplierId, status: 0, totalCount: totalCount, @@ -432,12 +402,16 @@ onShow(() => { if (Array.isArray(items)) { itemList.value = [...items] } - loadOperators() + // 读取用户选择页返回的经办人 + const userResult = getApp().globalData?._sparepartInboundUserSelectResult + if (userResult) { + selectedOperatorId.value = userResult.user.id + selectedOperatorName.value = userResult.user.nickname || userResult.user.userName || userResult.user.name || '' + getApp().globalData._sparepartInboundUserSelectResult = null + } }) -onHide(() => { - showOperatorDropdown.value = false -}) +onHide(() => {}) diff --git a/src/pages_function/pages/sparepartOutbound/create.vue b/src/pages_function/pages/sparepartOutbound/create.vue index c443489..d4c7bd0 100644 --- a/src/pages_function/pages/sparepartOutbound/create.vue +++ b/src/pages_function/pages/sparepartOutbound/create.vue @@ -38,18 +38,9 @@ *经办人 - - {{ selectedOperator ? selectedOperator.label : '请选择经办人' }} - - - - - {{ item.label }} - - - 暂无数据 - - + + {{ selectedOperatorName || '请选择经办人' }} + @@ -130,15 +121,13 @@ import { useI18n } from 'vue-i18n' import NavBar from '@/components/common/NavBar.vue' import { createSparepartOutbound } from '@/api/mes/sparepartOutbound' import { getSparepartDetail } from '@/api/mes/sparepart' -import { getSimpleUserList } from '@/api/mes/moldget' const { t } = useI18n() const itemList = ref([]) const outboundDate = ref(formatDate(new Date())) -const selectedOperator = ref(null) -const operatorOptions = ref([]) -const showOperatorDropdown = ref(false) +const selectedOperatorId = ref(null) +const selectedOperatorName = ref('') const remark = ref('') const attachmentList = ref([]) @@ -205,10 +194,11 @@ function handleScan() { function removeItem(idx) { itemList.value.splice(idx, 1); getApp().globalData._sparepartOutboundItems = [...itemList.value] } // 经办人 -function toggleOperatorDropdown() { showOperatorDropdown.value = !showOperatorDropdown.value } -function handleSelectOperator(item) { selectedOperator.value = item; showOperatorDropdown.value = false } -async function loadOperators() { - try { const res = await getSimpleUserList(); const data = Array.isArray(res) ? res : (Array.isArray(res?.data) ? res.data : []); operatorOptions.value = data.map((u) => ({ value: u.id || u.userId, label: u.nickname || u.userName || u.name || String(u.id || '') })) } catch (e) { } +function goSelectOperator() { + getApp().globalData._sparepartOutboundUserFrom = 'outbound' + uni.navigateTo({ + url: '/pages_function/pages/moldRepair/userSelect?field=operator&from=sparepartOutbound' + }) } // 附件 @@ -227,7 +217,7 @@ function removeAttachment(idx) { attachmentList.value.splice(idx, 1) } async function handleSubmit() { if (!itemList.value.length) { uni.showToast({ title: '请先添加备件', icon: 'none' }); return } if (!outboundDate.value) { uni.showToast({ title: '请选择出库时间', icon: 'none' }); return } - if (!selectedOperator.value) { uni.showToast({ title: '请选择经办人', icon: 'none' }); return } + if (!selectedOperatorId.value) { uni.showToast({ title: '请选择经办人', icon: 'none' }); return } // 完全对齐 Web 端格式:13位毫秒时间戳 + stockUserId const outTime = outboundDate.value ? new Date(outboundDate.value.replace(/-/g, '/')).getTime() : Date.now() @@ -251,7 +241,7 @@ async function handleSubmit() { const submitData = { isCode: true, outTime: outTime, - responserId: Number(selectedOperator.value.value), + responserId: Number(selectedOperatorId.value), status: 0, totalCount: totalCount, totalPrice: 0, @@ -279,8 +269,8 @@ async function handleSubmit() { onReady(() => { focusKeywordNoKeyboard() }) -onShow(() => { const items = getApp().globalData?._sparepartOutboundItems; if (Array.isArray(items)) itemList.value = [...items]; loadOperators() }) -onHide(() => { showOperatorDropdown.value = false }) +onShow(() => { const items = getApp().globalData?._sparepartOutboundItems; if (Array.isArray(items)) itemList.value = [...items]; const userResult = getApp().globalData?._sparepartOutboundUserSelectResult; if (userResult) { selectedOperatorId.value = userResult.user.id; selectedOperatorName.value = userResult.user.nickname || userResult.user.userName || userResult.user.name || ''; getApp().globalData._sparepartOutboundUserSelectResult = null } }) +onHide(() => {})