import request from '@/utils/http'
|
|
function normalizeText(value) {
|
return typeof value === 'string' ? value.trim() : value
|
}
|
|
function normalizeIds(ids) {
|
if (Array.isArray(ids)) {
|
return ids
|
.map((id) => String(id).trim())
|
.filter(Boolean)
|
.join(',')
|
}
|
if (ids === null || ids === undefined) {
|
return ''
|
}
|
return String(ids).trim()
|
}
|
|
function filterParams(params = {}, ignoredKeys = []) {
|
return Object.fromEntries(
|
Object.entries(params)
|
.filter(([key, value]) => {
|
if (ignoredKeys.includes(key)) return false
|
if (value === undefined || value === null) return false
|
if (typeof value === 'string' && value.trim() === '') return false
|
return true
|
})
|
.map(([key, value]) => [key, normalizeText(value)])
|
)
|
}
|
|
export function buildSubsystemFlowTemplatePageParams(params = {}) {
|
return {
|
current: params.current || 1,
|
pageSize: params.pageSize || params.size || 20,
|
...filterParams(params, ['current', 'pageSize', 'size'])
|
}
|
}
|
|
export function fetchSubsystemFlowTemplatePage(params = {}) {
|
return request.post({
|
url: '/subsystemFlowTemplate/page',
|
params: buildSubsystemFlowTemplatePageParams(params)
|
})
|
}
|
|
export function fetchGetSubsystemFlowTemplateDetail(id) {
|
return request.get({
|
url: `/subsystemFlowTemplate/${id}`
|
})
|
}
|
|
export function fetchGetSubsystemFlowTemplateMany(ids) {
|
return request.post({
|
url: `/subsystemFlowTemplate/many/${normalizeIds(ids)}`
|
})
|
}
|
|
export async function fetchExportSubsystemFlowTemplateReport(payload = {}, options = {}) {
|
return fetch(`${import.meta.env.VITE_API_URL}/subsystemFlowTemplate/export`, {
|
method: 'POST',
|
headers: {
|
'Content-Type': 'application/json',
|
...(options.headers || {})
|
},
|
body: JSON.stringify(payload)
|
})
|
}
|