You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
87 lines
2.5 KiB
87 lines
2.5 KiB
import request from '@/config/axios'
|
|
import { getStrDictOptions } from '@/utils/dict'
|
|
import { useUserStore } from '@/store/modules/user'
|
|
|
|
export interface FixedAssetsVO {
|
|
number: string
|
|
name: string
|
|
accountingUnit: string
|
|
specifications: string
|
|
locationNumber: string
|
|
purchaseDate: Date
|
|
purchaseDept: string
|
|
supplierNumber: string
|
|
productionDate: Date
|
|
purchasePrice: number
|
|
manageDept: string
|
|
unit: string
|
|
qty: number
|
|
siteId: string
|
|
available: string
|
|
concurrencyStamp: number
|
|
}
|
|
|
|
export const getFixedAssetsPage = async (params) => {
|
|
const userStore = useUserStore() // 用户信息
|
|
const deviceMoldTypeList = getStrDictOptions(DICT_TYPE.SPECIAL_DEPT_ROLE)
|
|
|
|
// 查找第一个同时存在于userStore.roles和deviceMoldTypeList中的值
|
|
const matchingRole = userStore.roles.find(role =>
|
|
deviceMoldTypeList.some(deviceMold => deviceMold.value === role)
|
|
);
|
|
|
|
const admin = userStore.roles.find(role => {
|
|
if (role == 'gdzc_admin') {
|
|
return true;
|
|
} else {
|
|
return false;
|
|
}
|
|
});
|
|
|
|
// 如果找到了匹配的角色,将它作为manageDept的值加入到params中
|
|
if (matchingRole) {
|
|
params.manageDept = matchingRole; // 这里只添加第一个匹配的角色
|
|
} else if(admin){
|
|
params.manageDept = null;
|
|
} else {
|
|
params.manageDept = 'bukenengpipeidedao@3&*#@';
|
|
}
|
|
|
|
if (params.isSearch) {
|
|
delete params.isSearch
|
|
const data = {...params}
|
|
return await request.post({ url: '/eam/fixed-assets/senior', data })
|
|
} else {
|
|
return await request.get({ url: `/eam/fixed-assets/page`, params })
|
|
}
|
|
}
|
|
|
|
// 查询固定资产详情
|
|
export const getFixedAssets = async (id: number) => {
|
|
return await request.get({ url: `/eam/fixed-assets/get?id=` + id })
|
|
}
|
|
|
|
// 新增固定资产
|
|
export const createFixedAssets = async (data: FixedAssetsVO) => {
|
|
return await request.post({ url: `/eam/fixed-assets/create`, data })
|
|
}
|
|
|
|
// 修改固定资产
|
|
export const updateFixedAssets = async (data: FixedAssetsVO) => {
|
|
return await request.put({ url: `/eam/fixed-assets/update`, data })
|
|
}
|
|
|
|
// 删除固定资产
|
|
export const deleteFixedAssets = async (id: number) => {
|
|
return await request.delete({ url: `/eam/fixed-assets/delete?id=` + id })
|
|
}
|
|
|
|
// 导出固定资产 Excel
|
|
export const exportFixedAssets = async (params) => {
|
|
return await request.download({ url: `/eam/fixed-assets/export-excel`, params })
|
|
}
|
|
|
|
// 下载用户导入模板
|
|
export const importTemplate = () => {
|
|
return request.download({ url: '/eam/fixed-assets/get-import-template' })
|
|
}
|