| | |
| | | import request from '@/utils/http' |
| | | |
| | | export function buildUserListParams(params = {}) { |
| | | return { |
| | | current: params.current || 1, |
| | | pageSize: params.pageSize || params.size || 20, |
| | | ...(params.username !== undefined ? { username: params.username } : {}), |
| | | ...(params.nickname !== undefined ? { nickname: params.nickname } : {}), |
| | | ...(params.phone !== undefined ? { phone: params.phone } : {}), |
| | | ...(params.email !== undefined ? { email: params.email } : {}), |
| | | ...(params.status !== undefined ? { status: params.status } : {}), |
| | | ...(params.deptId !== undefined ? { deptId: params.deptId } : {}) |
| | | } |
| | | } |
| | | |
| | | export function buildRoleListParams(params = {}) { |
| | | return { |
| | | current: params.current || 1, |
| | | pageSize: params.pageSize || params.size || 20, |
| | | ...(params.name !== undefined ? { name: params.name } : {}), |
| | | ...(params.code !== undefined ? { code: params.code } : {}), |
| | | ...(params.memo !== undefined ? { memo: params.memo } : {}), |
| | | ...(params.status !== undefined ? { status: params.status } : {}) |
| | | } |
| | | } |
| | | |
| | | export function buildOperationRecordPageParams(params = {}) { |
| | | return { |
| | | current: params.current || 1, |
| | | pageSize: params.pageSize || params.size || 20, |
| | | ...(params.condition !== undefined ? { condition: params.condition } : {}), |
| | | ...(params.namespace !== undefined ? { namespace: params.namespace } : {}), |
| | | ...(params.url !== undefined ? { url: params.url } : {}), |
| | | ...(params.appkey !== undefined ? { appkey: params.appkey } : {}), |
| | | ...(params.clientIp !== undefined ? { clientIp: params.clientIp } : {}), |
| | | ...(params.request !== undefined ? { request: params.request } : {}), |
| | | ...(params.response !== undefined ? { response: params.response } : {}), |
| | | ...(params.spendTime !== undefined ? { spendTime: params.spendTime } : {}), |
| | | ...(params.result !== undefined ? { result: params.result } : {}), |
| | | ...(params.userId !== undefined ? { userId: params.userId } : {}), |
| | | ...(params.timeStart !== undefined ? { timeStart: params.timeStart } : {}), |
| | | ...(params.timeEnd !== undefined ? { timeEnd: params.timeEnd } : {}), |
| | | ...(params.memo !== undefined ? { memo: params.memo } : {}) |
| | | } |
| | | } |
| | | |
| | | export function buildConfigPageParams(params = {}) { |
| | | return { |
| | | current: params.current || 1, |
| | | pageSize: params.pageSize || params.size || 20, |
| | | ...(params.condition !== undefined ? { condition: params.condition } : {}), |
| | | ...(params.uuid !== undefined ? { uuid: params.uuid } : {}), |
| | | ...(params.name !== undefined ? { name: params.name } : {}), |
| | | ...(params.flag !== undefined ? { flag: params.flag } : {}), |
| | | ...(params.type !== undefined ? { type: params.type } : {}), |
| | | ...(params.val !== undefined ? { val: params.val } : {}), |
| | | ...(params.content !== undefined ? { content: params.content } : {}), |
| | | ...(params.status !== undefined ? { status: params.status } : {}), |
| | | ...(params.timeStart !== undefined ? { timeStart: params.timeStart } : {}), |
| | | ...(params.timeEnd !== undefined ? { timeEnd: params.timeEnd } : {}), |
| | | ...(params.memo !== undefined ? { memo: params.memo } : {}) |
| | | } |
| | | } |
| | | |
| | | export function buildSerialRulePageParams(params = {}) { |
| | | return { |
| | | current: params.current || 1, |
| | | pageSize: params.pageSize || params.size || 20, |
| | | ...(params.condition !== undefined ? { condition: params.condition } : {}), |
| | | ...(params.code !== undefined ? { code: params.code } : {}), |
| | | ...(params.name !== undefined ? { name: params.name } : {}), |
| | | ...(params.delimit !== undefined ? { delimit: params.delimit } : {}), |
| | | ...(params.reset !== undefined ? { reset: params.reset } : {}), |
| | | ...(params.resetDep !== undefined ? { resetDep: params.resetDep } : {}), |
| | | ...(params.currValue !== undefined ? { currValue: params.currValue } : {}), |
| | | ...(params.lastCode !== undefined ? { lastCode: params.lastCode } : {}), |
| | | ...(params.status !== undefined ? { status: params.status } : {}), |
| | | ...(params.timeStart !== undefined ? { timeStart: params.timeStart } : {}), |
| | | ...(params.timeEnd !== undefined ? { timeEnd: params.timeEnd } : {}), |
| | | ...(params.memo !== undefined ? { memo: params.memo } : {}) |
| | | } |
| | | } |
| | | |
| | | export function buildDictTypePageParams(params = {}) { |
| | | return { |
| | | current: params.current || 1, |
| | | pageSize: params.pageSize || params.size || 20, |
| | | ...(params.condition !== undefined ? { condition: params.condition } : {}), |
| | | ...(params.code !== undefined ? { code: params.code } : {}), |
| | | ...(params.name !== undefined ? { name: params.name } : {}), |
| | | ...(params.description !== undefined ? { description: params.description } : {}), |
| | | ...(params.status !== undefined ? { status: params.status } : {}), |
| | | ...(params.timeStart !== undefined ? { timeStart: params.timeStart } : {}), |
| | | ...(params.timeEnd !== undefined ? { timeEnd: params.timeEnd } : {}), |
| | | ...(params.memo !== undefined ? { memo: params.memo } : {}) |
| | | } |
| | | } |
| | | |
| | | export function buildDictDataPageParams(params = {}) { |
| | | return { |
| | | current: params.current || 1, |
| | | pageSize: params.pageSize || params.size || 20, |
| | | ...(params.condition !== undefined ? { condition: params.condition } : {}), |
| | | ...(params.dictTypeId !== undefined ? { dictTypeId: params.dictTypeId } : {}), |
| | | ...(params.dictTypeCode !== undefined ? { dictTypeCode: params.dictTypeCode } : {}), |
| | | ...(params.value !== undefined ? { value: params.value } : {}), |
| | | ...(params.label !== undefined ? { label: params.label } : {}), |
| | | ...(params.sort !== undefined ? { sort: params.sort } : {}), |
| | | ...(params.group !== undefined ? { group: params.group } : {}), |
| | | ...(params.status !== undefined ? { status: params.status } : {}), |
| | | ...(params.memo !== undefined ? { memo: params.memo } : {}) |
| | | } |
| | | } |
| | | |
| | | export function buildWaveRulePageParams(params = {}) { |
| | | return { |
| | | current: params.current || 1, |
| | | pageSize: params.pageSize || params.size || 20, |
| | | ...(params.condition !== undefined ? { condition: params.condition } : {}), |
| | | ...(params.code !== undefined ? { code: params.code } : {}), |
| | | ...(params.type !== undefined ? { type: params.type } : {}), |
| | | ...(params.name !== undefined ? { name: params.name } : {}), |
| | | ...(params.status !== undefined ? { status: params.status } : {}), |
| | | ...(params.timeStart !== undefined ? { timeStart: params.timeStart } : {}), |
| | | ...(params.timeEnd !== undefined ? { timeEnd: params.timeEnd } : {}), |
| | | ...(params.memo !== undefined ? { memo: params.memo } : {}) |
| | | } |
| | | } |
| | | |
| | | export function buildFieldsPageParams(params = {}) { |
| | | return { |
| | | current: params.current || 1, |
| | | pageSize: params.pageSize || params.size || 20, |
| | | ...(params.condition !== undefined ? { condition: params.condition } : {}), |
| | | ...(params.fields !== undefined ? { fields: params.fields } : {}), |
| | | ...(params.fieldsAlise !== undefined ? { fieldsAlise: params.fieldsAlise } : {}), |
| | | ...(params.unique !== undefined ? { unique: params.unique } : {}), |
| | | ...(params.flagEnable !== undefined ? { flagEnable: params.flagEnable } : {}), |
| | | ...(params.status !== undefined ? { status: params.status } : {}), |
| | | ...(params.memo !== undefined ? { memo: params.memo } : {}) |
| | | } |
| | | } |
| | | |
| | | export function buildFieldsItemPageParams(params = {}) { |
| | | return { |
| | | current: params.current || 1, |
| | | pageSize: params.pageSize || params.size || 20, |
| | | ...(params.condition !== undefined ? { condition: params.condition } : {}), |
| | | ...(params.uuid !== undefined ? { uuid: params.uuid } : {}), |
| | | ...(params.fieldsId !== undefined ? { fieldsId: params.fieldsId } : {}), |
| | | ...(params.value !== undefined ? { value: params.value } : {}), |
| | | ...(params.matnrId !== undefined ? { matnrId: params.matnrId } : {}), |
| | | ...(params.shiperId !== undefined ? { shiperId: params.shiperId } : {}), |
| | | ...(params.status !== undefined ? { status: params.status } : {}), |
| | | ...(params.memo !== undefined ? { memo: params.memo } : {}) |
| | | } |
| | | } |
| | | |
| | | export function buildTenantPageParams(params = {}) { |
| | | return { |
| | | current: params.current || 1, |
| | | pageSize: params.pageSize || params.size || 20, |
| | | ...(params.condition !== undefined ? { condition: params.condition } : {}), |
| | | ...(params.name !== undefined ? { name: params.name } : {}), |
| | | ...(params.flag !== undefined ? { flag: params.flag } : {}), |
| | | ...(params.status !== undefined ? { status: params.status } : {}), |
| | | ...(params.memo !== undefined ? { memo: params.memo } : {}) |
| | | } |
| | | } |
| | | |
| | | export function buildHostPageParams(params = {}) { |
| | | return { |
| | | current: params.current || 1, |
| | | pageSize: params.pageSize || params.size || 20, |
| | | ...(params.condition !== undefined ? { condition: params.condition } : {}), |
| | | ...(params.name !== undefined ? { name: params.name } : {}), |
| | | ...(params.status !== undefined ? { status: params.status } : {}), |
| | | ...(params.memo !== undefined ? { memo: params.memo } : {}) |
| | | } |
| | | } |
| | | |
| | | function fetchGetUserList(params) { |
| | | return request.get({ |
| | | url: '/api/user/list', |
| | | params |
| | | }) |
| | | return request.post({ url: '/user/page', params: buildUserListParams(params) }) |
| | | } |
| | | |
| | | function fetchSaveUser(params) { |
| | | return request.post({ url: '/user/save', params }) |
| | | } |
| | | |
| | | function fetchUpdateUser(params) { |
| | | return request.post({ url: '/user/update', params }) |
| | | } |
| | | |
| | | function fetchDeleteUser(id) { |
| | | return request.post({ url: `/user/remove/${id}` }) |
| | | } |
| | | |
| | | function fetchResetUserPassword(params) { |
| | | const normalizedParams = normalizeAdminPasswordUpdateParams(params) |
| | | return request.post({ url: '/user/update', params: normalizedParams }) |
| | | } |
| | | |
| | | function fetchUpdateUserStatus(params) { |
| | | return request.post({ url: '/user/update', params }) |
| | | } |
| | | |
| | | function fetchGetUserDetail(id) { |
| | | return request.get({ url: `/user/${id}` }) |
| | | } |
| | | |
| | | function fetchGetRoleList(params) { |
| | | return request.get({ |
| | | url: '/api/role/list', |
| | | return request.post({ url: '/role/page', params: buildRoleListParams(params) }) |
| | | } |
| | | |
| | | function fetchOperationRecordPage(params = {}) { |
| | | return request.post({ |
| | | url: '/operationRecord/page', |
| | | params: buildOperationRecordPageParams(params) |
| | | }) |
| | | } |
| | | |
| | | function fetchConfigPage(params = {}) { |
| | | return request.post({ url: '/config/page', params: buildConfigPageParams(params) }) |
| | | } |
| | | |
| | | function fetchSerialRulePage(params = {}) { |
| | | return request.post({ url: '/serialRule/page', params: buildSerialRulePageParams(params) }) |
| | | } |
| | | |
| | | function fetchDictTypePage(params = {}) { |
| | | return request.post({ url: '/dictType/page', params: buildDictTypePageParams(params) }) |
| | | } |
| | | |
| | | function fetchDictDataPage(params = {}) { |
| | | return request.post({ url: '/dictData/page', params: buildDictDataPageParams(params) }) |
| | | } |
| | | |
| | | function fetchGetDictTypeDetail(id) { |
| | | return request.get({ url: `/dictType/${id}` }) |
| | | } |
| | | |
| | | function fetchSaveDictType(params) { |
| | | return request.post({ url: '/dictType/save', params }) |
| | | } |
| | | |
| | | function fetchUpdateDictType(params) { |
| | | return request.post({ url: '/dictType/update', params }) |
| | | } |
| | | |
| | | function fetchDeleteDictType(id) { |
| | | return request.post({ url: `/dictType/remove/${id}` }) |
| | | } |
| | | |
| | | function fetchWaveRulePage(params = {}) { |
| | | return request.post({ url: '/waveRule/page', params: buildWaveRulePageParams(params) }) |
| | | } |
| | | |
| | | function fetchGetWaveRuleDetail(id) { |
| | | return request.get({ url: `/waveRule/${id}` }) |
| | | } |
| | | |
| | | function fetchSaveWaveRule(params) { |
| | | return request.post({ url: '/waveRule/save', params }) |
| | | } |
| | | |
| | | function fetchUpdateWaveRule(params) { |
| | | return request.post({ url: '/waveRule/update', params }) |
| | | } |
| | | |
| | | function fetchDeleteWaveRule(id) { |
| | | return request.post({ url: `/waveRule/remove/${id}` }) |
| | | } |
| | | |
| | | function fetchFieldsPage(params = {}) { |
| | | return request.post({ url: '/fields/page', params: buildFieldsPageParams(params) }) |
| | | } |
| | | |
| | | function fetchGetFieldsDetail(id) { |
| | | return request.get({ url: `/fields/${id}` }) |
| | | } |
| | | |
| | | function fetchSaveFields(params) { |
| | | return request.post({ url: '/fields/save', params }) |
| | | } |
| | | |
| | | function fetchUpdateFields(params) { |
| | | return request.post({ url: '/fields/update', params }) |
| | | } |
| | | |
| | | function fetchDeleteFields(id) { |
| | | return request.post({ url: `/fields/remove/${id}` }) |
| | | } |
| | | |
| | | function fetchFieldsItemPage(params = {}) { |
| | | return request.post({ url: '/fieldsItem/page', params: buildFieldsItemPageParams(params) }) |
| | | } |
| | | |
| | | function fetchGetFieldsItemDetail(id) { |
| | | return request.get({ url: `/fieldsItem/${id}` }) |
| | | } |
| | | |
| | | function fetchSaveFieldsItem(params) { |
| | | return request.post({ url: '/fieldsItem/save', params }) |
| | | } |
| | | |
| | | function fetchUpdateFieldsItem(params) { |
| | | return request.post({ url: '/fieldsItem/update', params }) |
| | | } |
| | | |
| | | function fetchDeleteFieldsItem(id) { |
| | | return request.post({ url: `/fieldsItem/remove/${id}` }) |
| | | } |
| | | |
| | | function fetchTenantPage(params = {}) { |
| | | return request.post({ url: '/tenant/page', params: buildTenantPageParams(params) }) |
| | | } |
| | | |
| | | function fetchGetTenantDetail(id) { |
| | | return request.get({ url: `/tenant/${id}` }) |
| | | } |
| | | |
| | | function fetchInitTenant(params) { |
| | | return request.post({ url: '/tenant/init', params }) |
| | | } |
| | | |
| | | function fetchUpdateTenant(params) { |
| | | return request.post({ url: '/tenant/update', params }) |
| | | } |
| | | |
| | | function fetchDeleteTenant(id) { |
| | | return request.post({ url: `/tenant/remove/${id}` }) |
| | | } |
| | | |
| | | function fetchHostPage(params = {}) { |
| | | return request.post({ url: '/host/page', params: buildHostPageParams(params) }) |
| | | } |
| | | |
| | | function fetchGetHostDetail(id) { |
| | | return request.get({ url: `/host/${id}` }) |
| | | } |
| | | |
| | | function fetchSaveHost(params) { |
| | | return request.post({ url: '/host/save', params }) |
| | | } |
| | | |
| | | function fetchUpdateHost(params) { |
| | | return request.post({ url: '/host/update', params }) |
| | | } |
| | | |
| | | function fetchDeleteHost(id) { |
| | | return request.post({ url: `/host/remove/${id}` }) |
| | | } |
| | | |
| | | function fetchGetSerialRuleDetail(id) { |
| | | return request.get({ url: `/serialRule/${id}` }) |
| | | } |
| | | |
| | | function fetchSaveSerialRule(params) { |
| | | return request.post({ url: '/serialRule/save', params }) |
| | | } |
| | | |
| | | function fetchUpdateSerialRule(params) { |
| | | return request.post({ url: '/serialRule/update', params }) |
| | | } |
| | | |
| | | function fetchDeleteSerialRule(id) { |
| | | return request.post({ url: `/serialRule/remove/${id}` }) |
| | | } |
| | | |
| | | function fetchGetConfigDetail(id) { |
| | | return request.get({ url: `/config/${id}` }) |
| | | } |
| | | |
| | | function fetchSaveConfig(params) { |
| | | return request.post({ url: '/config/save', params }) |
| | | } |
| | | |
| | | function fetchUpdateConfig(params) { |
| | | return request.post({ url: '/config/update', params }) |
| | | } |
| | | |
| | | function fetchDeleteConfig(id) { |
| | | return request.post({ url: `/config/remove/${id}` }) |
| | | } |
| | | |
| | | function fetchGetOperationRecordDetail(id) { |
| | | return request.get({ url: `/operationRecord/${id}` }) |
| | | } |
| | | |
| | | function fetchDeleteOperationRecord(id) { |
| | | return request.post({ url: `/operationRecord/remove/${id}` }) |
| | | } |
| | | |
| | | function normalizeOperationRecordManyIds(ids) { |
| | | if (Array.isArray(ids)) { |
| | | return ids |
| | | .map((id) => normalizeLegacyId(id)) |
| | | .filter((id) => id !== '') |
| | | .join(',') |
| | | } |
| | | return normalizeLegacyId(ids) |
| | | } |
| | | |
| | | function fetchGetOperationRecordMany(ids) { |
| | | const normalizedIds = normalizeOperationRecordManyIds(ids) |
| | | return request.post({ url: `/operationRecord/many/${normalizedIds}` }) |
| | | } |
| | | |
| | | async function fetchExportOperationRecordReport(payload = {}, options = {}) { |
| | | return fetch(`${import.meta.env.VITE_API_URL}/operationRecord/export`, { |
| | | method: 'POST', |
| | | headers: { |
| | | 'Content-Type': 'application/json', |
| | | ...(options.headers || {}) |
| | | }, |
| | | body: JSON.stringify(payload) |
| | | }) |
| | | } |
| | | |
| | | function fetchSaveRole(params) { |
| | | return request.post({ url: '/role/save', params }) |
| | | } |
| | | |
| | | function fetchUpdateRole(params) { |
| | | return request.post({ url: '/role/update', params }) |
| | | } |
| | | |
| | | function fetchDeleteRole(id) { |
| | | return request.post({ url: `/role/remove/${id}` }) |
| | | } |
| | | |
| | | function fetchGetRoleOptions(params) { |
| | | return request.post({ url: '/role/list', params }) |
| | | } |
| | | |
| | | function buildRolePageParams(params = {}) { |
| | | return { |
| | | current: params.current || 1, |
| | | pageSize: params.pageSize || params.size || 20, |
| | | ...(params.name !== undefined ? { name: params.name } : {}), |
| | | ...(params.code !== undefined ? { code: params.code } : {}), |
| | | ...(params.memo !== undefined ? { memo: params.memo } : {}), |
| | | ...(params.status !== undefined ? { status: params.status } : {}), |
| | | ...(params.condition !== undefined ? { condition: params.condition } : {}) |
| | | } |
| | | } |
| | | |
| | | function fetchRolePage(params = {}) { |
| | | return request.post({ url: '/role/page', params: buildRolePageParams(params) }) |
| | | } |
| | | |
| | | const fetchRolePrintPage = fetchRolePage |
| | | |
| | | function normalizeRoleManyIds(ids) { |
| | | if (Array.isArray(ids)) { |
| | | return ids |
| | | .map((id) => normalizeLegacyId(id)) |
| | | .filter((id) => id !== '') |
| | | .join(',') |
| | | } |
| | | return normalizeLegacyId(ids) |
| | | } |
| | | |
| | | function fetchGetRoleMany(ids) { |
| | | const normalizedIds = normalizeRoleManyIds(ids) |
| | | return request.post({ url: `/role/many/${normalizedIds}` }) |
| | | } |
| | | |
| | | async function fetchExportRoleReport(payload = {}, options = {}) { |
| | | return fetch(`${import.meta.env.VITE_API_URL}/role/export`, { |
| | | method: 'POST', |
| | | headers: { |
| | | 'Content-Type': 'application/json', |
| | | ...(options.headers || {}) |
| | | }, |
| | | body: JSON.stringify(payload) |
| | | }) |
| | | } |
| | | |
| | | function fetchGetDeptTree(params) { |
| | | return request.post({ url: '/dept/tree', params }) |
| | | } |
| | | |
| | | function fetchGetDeptDetail(id) { |
| | | return request.get({ url: `/dept/${id}` }) |
| | | } |
| | | |
| | | function fetchSaveDept(params) { |
| | | return request.post({ url: '/dept/save', params }) |
| | | } |
| | | |
| | | function fetchUpdateDept(params) { |
| | | return request.post({ url: '/dept/update', params }) |
| | | } |
| | | |
| | | function fetchDeleteDept(id) { |
| | | return request.post({ url: `/dept/remove/${id}` }) |
| | | } |
| | | |
| | | function fetchGetMenuTree(params = {}) { |
| | | return request.post({ url: '/menu/tree', params }) |
| | | } |
| | | |
| | | function fetchSaveMenu(params) { |
| | | return request.post({ url: '/menu/save', params }) |
| | | } |
| | | |
| | | function fetchUpdateMenu(params) { |
| | | return request.post({ url: '/menu/update', params }) |
| | | } |
| | | |
| | | function fetchDeleteMenu(id) { |
| | | return request.post({ url: `/menu/remove/${id}` }) |
| | | } |
| | | |
| | | function fetchGetMenuPdaTree(params = {}) { |
| | | return request.post({ url: '/menuPda/tree', params }) |
| | | } |
| | | |
| | | function fetchSaveMenuPda(params) { |
| | | return request.post({ url: '/menuPda/save', params }) |
| | | } |
| | | |
| | | function fetchUpdateMenuPda(params) { |
| | | return request.post({ url: '/menuPda/update', params }) |
| | | } |
| | | |
| | | function fetchDeleteMenuPda(id) { |
| | | return request.post({ url: `/menuPda/remove/${id}` }) |
| | | } |
| | | |
| | | function assertAdminPasswordUpdatePayload(params) { |
| | | if (!isPlainObject(params)) { |
| | | throw new Error('fetchResetUserPassword requires an object payload') |
| | | } |
| | | if (params.id === undefined || params.id === null || params.id === '') { |
| | | throw new Error('fetchResetUserPassword requires a user id') |
| | | } |
| | | } |
| | | |
| | | function normalizeAdminPasswordUpdateParams(params) { |
| | | assertAdminPasswordUpdatePayload(params) |
| | | if (params.password !== undefined) { |
| | | return params |
| | | } |
| | | if (params.newPassword !== undefined) { |
| | | return { |
| | | ...params, |
| | | password: params.newPassword |
| | | } |
| | | } |
| | | throw new Error('fetchResetUserPassword requires a password payload') |
| | | } |
| | | |
| | | function getScopeListUrl(scopeType) { |
| | | const urlMap = { |
| | | menu: '/role/scope/list', |
| | | pda: '/rolePda/scope/list', |
| | | matnr: '/roleMatnr/scope/list', |
| | | warehouse: '/roleWarehouse/scope/list' |
| | | } |
| | | const url = urlMap[scopeType] |
| | | if (!url) { |
| | | throw new Error(`Unsupported scope type: ${scopeType}`) |
| | | } |
| | | return url |
| | | } |
| | | |
| | | function getScopeUpdateUrl(scopeType) { |
| | | const urlMap = { |
| | | menu: '/role/scope/update', |
| | | pda: '/rolePda/scope/update', |
| | | matnr: '/roleMatnr/scope/update', |
| | | warehouse: '/roleWarehouse/scope/update' |
| | | } |
| | | const url = urlMap[scopeType] |
| | | if (!url) { |
| | | throw new Error(`Unsupported scope type: ${scopeType}`) |
| | | } |
| | | return url |
| | | } |
| | | |
| | | function getScopeTreeUrl(scopeType) { |
| | | const urlMap = { |
| | | menu: '/menu/tree', |
| | | pda: '/menuPda/tree', |
| | | matnr: '/menuMatnrGroup/tree', |
| | | warehouse: '/menuWarehouse/tree' |
| | | } |
| | | const url = urlMap[scopeType] |
| | | if (!url) { |
| | | throw new Error(`Unsupported scope type: ${scopeType}`) |
| | | } |
| | | return url |
| | | } |
| | | |
| | | function fetchGetRoleScopeList(scopeType, roleId) { |
| | | return request.get({ url: getScopeListUrl(scopeType), params: { roleId } }) |
| | | } |
| | | |
| | | function fetchUpdateRoleScope(scopeType, params) { |
| | | return request.post({ url: getScopeUpdateUrl(scopeType), params }) |
| | | } |
| | | |
| | | function fetchGetRoleScopeTree(scopeType, params = {}) { |
| | | return request.post({ url: getScopeTreeUrl(scopeType), params }) |
| | | } |
| | | |
| | | function fetchGetUserLoginList(params) { |
| | | return request.post({ |
| | | url: '/userLogin/page', |
| | | params |
| | | }) |
| | | } |
| | | function fetchGetMenuList() { |
| | | return request.get({ |
| | | url: '/api/v3/system/menus/simple' |
| | | }) |
| | | |
| | | function fetchGetMenuList(params = {}) { |
| | | return request |
| | | .post({ url: '/menu/list', params }) |
| | | .then((menuList) => adaptLegacyMenuTree(buildLegacyMenuTree(menuList))) |
| | | } |
| | | export { fetchGetMenuList, fetchGetRoleList, fetchGetUserList } |
| | | |
| | | function adaptLegacyMenuTree(menuTree) { |
| | | if (!Array.isArray(menuTree)) { |
| | | return [] |
| | | } |
| | | |
| | | return menuTree.map((node) => adaptLegacyMenuNode(node)).filter(Boolean) |
| | | } |
| | | |
| | | function buildLegacyMenuTree(menuList) { |
| | | if (!Array.isArray(menuList)) { |
| | | return [] |
| | | } |
| | | |
| | | const nodeMap = new Map() |
| | | const roots = [] |
| | | |
| | | menuList.forEach((node) => { |
| | | if (!node || typeof node !== 'object') { |
| | | return |
| | | } |
| | | nodeMap.set(normalizeLegacyId(node.id), { |
| | | ...node, |
| | | children: [] |
| | | }) |
| | | }) |
| | | |
| | | nodeMap.forEach((node) => { |
| | | const parentId = normalizeLegacyId(node.parentId ?? 0) |
| | | if (parentId && parentId !== '0' && nodeMap.has(parentId)) { |
| | | nodeMap.get(parentId).children.push(node) |
| | | return |
| | | } |
| | | roots.push(node) |
| | | }) |
| | | |
| | | return sortLegacyMenuTree(roots) |
| | | } |
| | | |
| | | function sortLegacyMenuTree(nodes) { |
| | | return nodes |
| | | .sort((left, right) => { |
| | | const leftSort = Number(left?.sort ?? 0) |
| | | const rightSort = Number(right?.sort ?? 0) |
| | | if (leftSort !== rightSort) { |
| | | return leftSort - rightSort |
| | | } |
| | | return normalizeLegacyId(left?.id).localeCompare(normalizeLegacyId(right?.id)) |
| | | }) |
| | | .map((node) => ({ |
| | | ...node, |
| | | children: Array.isArray(node.children) ? sortLegacyMenuTree(node.children) : [] |
| | | })) |
| | | } |
| | | |
| | | function adaptLegacyMenuNode(node) { |
| | | if (!node || typeof node !== 'object' || node.type === 1) { |
| | | return null |
| | | } |
| | | |
| | | const menuChildren = [] |
| | | const authList = [] |
| | | const rawChildren = Array.isArray(node.children) ? node.children : [] |
| | | |
| | | rawChildren.forEach((child) => { |
| | | if (!child || typeof child !== 'object') { |
| | | return |
| | | } |
| | | if (child.type === 1) { |
| | | authList.push(buildLegacyAuthItem(child)) |
| | | return |
| | | } |
| | | const adaptedChild = adaptLegacyMenuNode(child) |
| | | if (adaptedChild) { |
| | | menuChildren.push(adaptedChild) |
| | | } |
| | | }) |
| | | |
| | | const adapted = { |
| | | id: normalizeLegacyId(node.id), |
| | | parentId: normalizeLegacyId(node.parentId ?? 0), |
| | | parentName: node.parentName || '', |
| | | name: buildLegacyRouteName(node), |
| | | route: typeof node.route === 'string' ? node.route : '', |
| | | path: buildLegacyMenuPath(node), |
| | | component: buildLegacyMenuComponent(node), |
| | | authority: node.authority || '', |
| | | icon: node.icon || '', |
| | | sort: node.sort ?? 0, |
| | | status: node.status ?? 1, |
| | | memo: node.memo || '', |
| | | type: node.type ?? 0, |
| | | meta: buildLegacyMenuMeta(node), |
| | | children: menuChildren |
| | | } |
| | | if (authList.length > 0) { |
| | | adapted.meta.authList = authList |
| | | } |
| | | |
| | | return adapted |
| | | } |
| | | |
| | | function buildLegacyMenuMeta(node) { |
| | | const metaSource = node.meta && typeof node.meta === 'object' ? node.meta : node |
| | | const meta = { |
| | | title: normalizeLegacyTitle(node.name || metaSource.title || '') |
| | | } |
| | | |
| | | const supportedKeys = [ |
| | | 'icon', |
| | | 'sort', |
| | | 'keepAlive', |
| | | 'isHide', |
| | | 'isHideTab', |
| | | 'fixedTab', |
| | | 'link', |
| | | 'isIframe', |
| | | 'roles', |
| | | 'showBadge', |
| | | 'showTextBadge', |
| | | 'activePath', |
| | | 'isFullPage' |
| | | ] |
| | | |
| | | supportedKeys.forEach((key) => { |
| | | if (metaSource[key] !== undefined) { |
| | | meta[key] = metaSource[key] |
| | | } |
| | | }) |
| | | meta.isEnable = normalizeLegacyEnableState(metaSource) |
| | | |
| | | return meta |
| | | } |
| | | |
| | | function buildLegacyAuthItem(node) { |
| | | const metaSource = node.meta && typeof node.meta === 'object' ? node.meta : node |
| | | return { |
| | | id: normalizeLegacyId(node.id), |
| | | parentId: normalizeLegacyId(node.parentId ?? 0), |
| | | parentName: node.parentName || '', |
| | | name: node.name || metaSource.title || '', |
| | | title: normalizeLegacyTitle(node.name || metaSource.title || ''), |
| | | route: typeof node.route === 'string' ? node.route : '', |
| | | component: buildLegacyMenuComponent(node), |
| | | authMark: metaSource.authMark || metaSource.authority || metaSource.code || '', |
| | | authority: metaSource.authority || metaSource.authMark || metaSource.code || '', |
| | | icon: metaSource.icon || '', |
| | | sort: metaSource.sort ?? 0, |
| | | status: metaSource.status ?? 1, |
| | | memo: metaSource.memo || '', |
| | | type: node.type ?? 1 |
| | | } |
| | | } |
| | | |
| | | function buildLegacyMenuPath(node) { |
| | | const rawPath = |
| | | typeof node.route === 'string' && node.route.trim() |
| | | ? node.route |
| | | : typeof node.path === 'string' |
| | | ? node.path |
| | | : '' |
| | | return normalizeLegacyPath(rawPath) |
| | | } |
| | | |
| | | function buildLegacyMenuComponent(node) { |
| | | if (typeof node.component === 'string') { |
| | | return node.component |
| | | } |
| | | return '' |
| | | } |
| | | |
| | | function buildLegacyRouteName(node) { |
| | | if (typeof node.name === 'string' && node.name.trim()) { |
| | | return node.name.trim() |
| | | } |
| | | if (typeof node.component === 'string' && node.component.trim()) { |
| | | return node.component.trim() |
| | | } |
| | | const path = buildLegacyMenuPath(node) |
| | | if (path) { |
| | | return path |
| | | .split('/') |
| | | .filter(Boolean) |
| | | .map((segment) => segment.charAt(0).toUpperCase() + segment.slice(1)) |
| | | .join('') |
| | | } |
| | | return `Menu${normalizeLegacyId(node.id)}` |
| | | } |
| | | |
| | | function normalizeLegacyTitle(title) { |
| | | if (typeof title !== 'string') { |
| | | return '' |
| | | } |
| | | const trimmedTitle = title.trim() |
| | | if (trimmedTitle.startsWith('menu.')) { |
| | | return `menus.${trimmedTitle.slice('menu.'.length)}` |
| | | } |
| | | return trimmedTitle |
| | | } |
| | | |
| | | function normalizeLegacyPath(path) { |
| | | if (typeof path !== 'string') { |
| | | return '' |
| | | } |
| | | return path.replace(/^\/+/, '').replace(/\/+$/, '') |
| | | } |
| | | |
| | | function normalizeLegacyId(id) { |
| | | if (id === null || id === undefined || id === '') { |
| | | return '' |
| | | } |
| | | return String(id) |
| | | } |
| | | |
| | | function normalizeLegacyEnableState(metaSource) { |
| | | if (metaSource.isEnable !== undefined) { |
| | | return Boolean(metaSource.isEnable) |
| | | } |
| | | if (metaSource.enabled !== undefined) { |
| | | return Boolean(metaSource.enabled) |
| | | } |
| | | if (metaSource.statusBool !== undefined) { |
| | | return Boolean(metaSource.statusBool) |
| | | } |
| | | if (metaSource.status !== undefined) { |
| | | return Number(metaSource.status) === 1 |
| | | } |
| | | return true |
| | | } |
| | | |
| | | function isPlainObject(value) { |
| | | return Boolean(value) && typeof value === 'object' && !Array.isArray(value) |
| | | } |
| | | |
| | | export { |
| | | fetchGetUserList, |
| | | fetchSaveUser, |
| | | fetchUpdateUser, |
| | | fetchDeleteUser, |
| | | fetchResetUserPassword, |
| | | fetchUpdateUserStatus, |
| | | fetchGetUserDetail, |
| | | fetchGetRoleList, |
| | | fetchOperationRecordPage, |
| | | fetchGetOperationRecordDetail, |
| | | fetchDeleteOperationRecord, |
| | | fetchGetOperationRecordMany, |
| | | fetchExportOperationRecordReport, |
| | | fetchConfigPage, |
| | | fetchGetConfigDetail, |
| | | fetchSaveConfig, |
| | | fetchUpdateConfig, |
| | | fetchDeleteConfig, |
| | | fetchSerialRulePage, |
| | | fetchGetSerialRuleDetail, |
| | | fetchSaveSerialRule, |
| | | fetchUpdateSerialRule, |
| | | fetchDeleteSerialRule, |
| | | fetchDictTypePage, |
| | | fetchGetDictTypeDetail, |
| | | fetchSaveDictType, |
| | | fetchUpdateDictType, |
| | | fetchDeleteDictType, |
| | | fetchDictDataPage, |
| | | fetchWaveRulePage, |
| | | fetchGetWaveRuleDetail, |
| | | fetchSaveWaveRule, |
| | | fetchUpdateWaveRule, |
| | | fetchDeleteWaveRule, |
| | | fetchFieldsPage, |
| | | fetchGetFieldsDetail, |
| | | fetchSaveFields, |
| | | fetchUpdateFields, |
| | | fetchDeleteFields, |
| | | fetchFieldsItemPage, |
| | | fetchGetFieldsItemDetail, |
| | | fetchSaveFieldsItem, |
| | | fetchUpdateFieldsItem, |
| | | fetchDeleteFieldsItem, |
| | | fetchTenantPage, |
| | | fetchGetTenantDetail, |
| | | fetchInitTenant, |
| | | fetchUpdateTenant, |
| | | fetchDeleteTenant, |
| | | fetchHostPage, |
| | | fetchGetHostDetail, |
| | | fetchSaveHost, |
| | | fetchUpdateHost, |
| | | fetchDeleteHost, |
| | | fetchSaveRole, |
| | | fetchUpdateRole, |
| | | fetchDeleteRole, |
| | | fetchGetRoleOptions, |
| | | fetchRolePrintPage, |
| | | fetchRolePage, |
| | | fetchExportRoleReport, |
| | | fetchGetRoleMany, |
| | | fetchGetDeptTree, |
| | | fetchGetDeptDetail, |
| | | fetchSaveDept, |
| | | fetchUpdateDept, |
| | | fetchDeleteDept, |
| | | fetchGetMenuTree, |
| | | fetchGetMenuPdaTree, |
| | | fetchSaveMenu, |
| | | fetchSaveMenuPda, |
| | | fetchUpdateMenu, |
| | | fetchUpdateMenuPda, |
| | | fetchDeleteMenu, |
| | | fetchDeleteMenuPda, |
| | | fetchGetRoleScopeList, |
| | | fetchGetRoleScopeTree, |
| | | fetchUpdateRoleScope, |
| | | fetchGetUserLoginList, |
| | | fetchGetMenuList |
| | | } |