From 1d95b134d85c3c60cf0e72739888c9741a0bb1ee Mon Sep 17 00:00:00 2001
From: zhou zhou <3272660260@qq.com>
Date: 星期五, 10 四月 2026 13:20:39 +0800
Subject: [PATCH] #页面优化
---
rsf-design/src/api/wh-mat.js | 147 ++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 145 insertions(+), 2 deletions(-)
diff --git a/rsf-design/src/api/wh-mat.js b/rsf-design/src/api/wh-mat.js
index ed04047..2bc5a50 100644
--- a/rsf-design/src/api/wh-mat.js
+++ b/rsf-design/src/api/wh-mat.js
@@ -4,13 +4,53 @@
return String(value ?? '').trim()
}
+function normalizeIds(ids) {
+ if (Array.isArray(ids)) {
+ return ids
+ .map((item) => Number(item))
+ .filter((item) => Number.isFinite(item))
+ .join(',')
+ }
+ return String(ids ?? '')
+ .split(',')
+ .map((item) => Number(item))
+ .filter((item) => Number.isFinite(item))
+ .join(',')
+}
+
+function normalizeIdList(ids) {
+ if (Array.isArray(ids)) {
+ return ids.map((item) => Number(item)).filter((item) => Number.isFinite(item))
+ }
+ return String(ids ?? '')
+ .split(',')
+ .map((item) => Number(item))
+ .filter((item) => Number.isFinite(item))
+}
+
function normalizeQueryParams(params = {}) {
+ const allowKeys = new Set([
+ 'condition',
+ 'code',
+ 'name',
+ 'spec',
+ 'model',
+ 'color',
+ 'size',
+ 'barcode',
+ 'groupId',
+ 'unit',
+ 'status',
+ 'flagCheck',
+ 'validWarn'
+ ])
const result = {
current: params.current || 1,
- pageSize: params.pageSize || params.size || 20
+ pageSize: params.pageSize || params.size || 20,
+ orderBy: normalizeText(params.orderBy) || 'create_time desc'
}
- ;['condition', 'code', 'name', 'spec', 'model', 'color', 'size', 'barcode', 'groupId'].forEach((key) => {
+ Array.from(allowKeys).forEach((key) => {
const value = params[key]
if (value === undefined || value === null || value === '') {
return
@@ -19,6 +59,29 @@
const trimmed = normalizeText(value)
if (trimmed) {
result[key] = trimmed
+ }
+ return
+ }
+ result[key] = value
+ })
+
+ Object.entries(params).forEach(([key, value]) => {
+ if (['current', 'pageSize', 'size', 'orderBy'].includes(key) || allowKeys.has(key)) {
+ return
+ }
+ if (value === undefined || value === null || value === '') {
+ return
+ }
+ if (typeof value === 'string') {
+ const trimmed = normalizeText(value)
+ if (trimmed) {
+ result[key] = trimmed
+ }
+ return
+ }
+ if (Array.isArray(value)) {
+ if (value.length) {
+ result[key] = value
}
return
}
@@ -45,6 +108,53 @@
return request.get({ url: `/matnr/${id}` })
}
+export function fetchGetMatnrMany(ids) {
+ return request.post({ url: `/matnr/many/${normalizeIds(ids)}` })
+}
+
+export function fetchEnabledFields() {
+ return request.get({ url: '/fields/enable/list' })
+}
+
+export function fetchSaveMatnr(params = {}) {
+ return request.post({ url: '/matnr/save', params })
+}
+
+export function fetchUpdateMatnr(params = {}) {
+ return request.post({ url: '/matnr/update', params })
+}
+
+export function fetchDeleteMatnr(ids) {
+ return request.post({ url: `/matnr/remove/${normalizeIds(ids)}` })
+}
+
+export function fetchBindMatnrGroup(payload = {}) {
+ return request.post({
+ url: '/matnr/group/bind',
+ params: {
+ ids: normalizeIdList(payload.ids),
+ ...(payload.groupId !== undefined && payload.groupId !== null && payload.groupId !== ''
+ ? { groupId: Number(payload.groupId) }
+ : {})
+ }
+ })
+}
+
+export function fetchBatchUpdateMatnr(payload = {}) {
+ const matnr = payload.matnr && typeof payload.matnr === 'object' ? payload.matnr : {}
+ return request.post({
+ url: '/matnr/batch/update',
+ params: {
+ ids: normalizeIdList(payload.ids),
+ matnr: Object.fromEntries(
+ Object.entries(matnr).filter(
+ ([, value]) => value !== undefined && value !== null && value !== ''
+ )
+ )
+ }
+ })
+}
+
export function fetchMatnrGroupTree(params = {}) {
return request.post({
url: '/matnrGroup/tree',
@@ -52,3 +162,36 @@
})
}
+export async function fetchExportMatnrReport(payload = {}, options = {}) {
+ return fetch(`${import.meta.env.VITE_API_URL}/matnr/export`, {
+ method: 'POST',
+ headers: {
+ 'Content-Type': 'application/json',
+ ...(options.headers || {})
+ },
+ body: JSON.stringify(payload)
+ })
+}
+
+export async function fetchDownloadMatnrTemplate(payload = {}, options = {}) {
+ return fetch(`${import.meta.env.VITE_API_URL}/matnr/template/download`, {
+ method: 'POST',
+ headers: {
+ 'Content-Type': 'application/json',
+ ...(options.headers || {})
+ },
+ body: JSON.stringify(payload)
+ })
+}
+
+export function fetchImportMatnr(file) {
+ const formData = new FormData()
+ formData.append('file', file)
+ return request.post({
+ url: '/matnr/import',
+ data: formData,
+ headers: {
+ 'Content-Type': 'multipart/form-data'
+ }
+ })
+}
--
Gitblit v1.9.1