Browse Source

固定资产代码

master
ljlong_2630 7 months ago
parent
commit
35ff383c08
  1. 16
      src/api/eam/basic/fixedAssets/index.ts
  2. 3
      src/utils/dict.ts
  3. 50
      src/views/eam/basic/fixedAssets/fixedAssets.data.ts
  4. 21
      src/views/eam/basic/fixedAssets/index.vue

16
src/api/eam/basic/fixedAssets/index.ts

@ -1,4 +1,6 @@
import request from '@/config/axios' import request from '@/config/axios'
import { getStrDictOptions } from '@/utils/dict'
import { useUserStore } from '@/store/modules/user'
export interface FixedAssetsVO { export interface FixedAssetsVO {
number: string number: string
@ -19,8 +21,20 @@ export interface FixedAssetsVO {
concurrencyStamp: number concurrencyStamp: number
} }
// 查询固定资产列表
export const getFixedAssetsPage = async (params) => { 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)
);
// 如果找到了匹配的角色,将它作为manageDept的值加入到params中
if (matchingRole) {
params.manageDept = matchingRole; // 这里只添加第一个匹配的角色
}
if (params.isSearch) { if (params.isSearch) {
delete params.isSearch delete params.isSearch
const data = {...params} const data = {...params}

3
src/utils/dict.ts

@ -305,6 +305,7 @@ export enum DICT_TYPE {
TURN_TYPE = 'turn_type', //转移类型 TURN_TYPE = 'turn_type', //转移类型
ORDER_COMPLETE_RESULT = 'order_complete_result', //维修工单完成结果 ORDER_COMPLETE_RESULT = 'order_complete_result', //维修工单完成结果
FACTORY_TYPE = 'factory_type',//厂区类别 FACTORY_TYPE = 'factory_type',//厂区类别
EQUIPMENT_INDEX_NAME = 'equipment_index_name'//设备年度目标指标名称分类字段 EQUIPMENT_INDEX_NAME = 'equipment_index_name',//设备年度目标指标名称分类字段
SPECIAL_DEPT_ROLE = 'special_dept_role'
} }

50
src/views/eam/basic/fixedAssets/fixedAssets.data.ts

@ -38,6 +38,7 @@ export const FixedAssetsRules = reactive({
{ validator:validateNumDot, message: '请输入数字格式', trigger: 'blur'} { validator:validateNumDot, message: '请输入数字格式', trigger: 'blur'}
], ],
manageDept: [ manageDept: [
required,
{ max: 20, message: '不得超过20个字符', trigger: 'blur' }, { max: 20, message: '不得超过20个字符', trigger: 'blur' },
], ],
unit: [ unit: [
@ -108,8 +109,8 @@ export const FixedAssets = useCrudSchemas(reactive<CrudSchema[]>([
} }
}, },
{ {
label: '购买时间', label: '投入使用时间',
field: 'purchaseDate', field: 'beginUseDate',
sort: 'custom', sort: 'custom',
table: { table: {
width: '150', width: '150',
@ -123,14 +124,6 @@ export const FixedAssets = useCrudSchemas(reactive<CrudSchema[]>([
} }
} }
}, },
{
label: '采购部门',
field: 'purchaseDept',
sort: 'custom',
table: {
width: '150',
},
},
{ {
label: '供应商', label: '供应商',
field: 'supplierNumber', field: 'supplierNumber',
@ -170,33 +163,54 @@ export const FixedAssets = useCrudSchemas(reactive<CrudSchema[]>([
} }
} }
}, },
// {
// label: '管理部门',
// field: 'manageDept',
// sort: 'custom',
// table: {
// width: '150',
// },
// form: {
// componentProps: {
// disabled: true
// }
// }
// },
{ {
label: '购买价格', label: '单位',
field: 'purchasePrice', field: 'unit',
sort: 'custom', sort: 'custom',
table: { table: {
width: '150', width: '150',
}, },
}, },
{ {
label: '管理部门', label: '数量',
field: 'manageDept', field: 'qty',
sort: 'custom', sort: 'custom',
table: { table: {
width: '150', width: '150',
}, },
}, },
{ {
label: '单位', label: '期间费用科目描述',
field: 'unit', field: 'costSubjectDesc',
sort: 'custom', sort: 'custom',
table: { table: {
width: '150', width: '150',
}, },
}, },
{ {
label: '数量', label: '使用人',
field: 'qty', field: 'user',
sort: 'custom',
table: {
width: '150',
},
},
{
label: '状态',
field: 'status',
sort: 'custom', sort: 'custom',
table: { table: {
width: '150', width: '150',

21
src/views/eam/basic/fixedAssets/index.vue

@ -58,14 +58,15 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { useUserStore } from '@/store/modules/user'
import { getStrDictOptions } from '@/utils/dict'
import download from '@/utils/download' import download from '@/utils/download'
import { FixedAssets,FixedAssetsRules } from './fixedAssets.data' import { FixedAssets,FixedAssetsRules } from './fixedAssets.data'
import * as FixedAssetsApi from '@/api/eam/basic/fixedAssets' import * as FixedAssetsApi from '@/api/eam/basic/fixedAssets'
import * as defaultButtons from '@/utils/disposition/defaultButtons' import * as defaultButtons from '@/utils/disposition/defaultButtons'
import TableHead from '@/components/TableHead/src/TableHead.vue' // import TableHead from '@/components/TableHead/src/TableHead.vue'
import ImportForm from '@/components/ImportForm/src/ImportForm.vue' // import ImportForm from '@/components/ImportForm/src/ImportForm.vue'
import Detail from '@/components/Detail/src/Detail.vue' // import Detail from '@/components/Detail/src/Detail.vue'
defineOptions({ name: 'FixedAssets' }) defineOptions({ name: 'FixedAssets' })
const message = useMessage() // const message = useMessage() //
@ -149,6 +150,9 @@ const buttonTableClick = async (val, row) => {
/** 添加/修改操作 */ /** 添加/修改操作 */
const basicFormRef = ref() const basicFormRef = ref()
const openForm = (type: string, row?: any) => { const openForm = (type: string, row?: any) => {
basicFormRef.value.open(type, row) basicFormRef.value.open(type, row)
} }
@ -165,10 +169,19 @@ const formsSuccess = async (formType,data) => {
} }
if(data.activeTime==0)data.activeTime = null; if(data.activeTime==0)data.activeTime = null;
if(data.expireTime==0)data.expireTime = null; if(data.expireTime==0)data.expireTime = null;
const userStore = useUserStore() //
const deviceMoldTypeList = getStrDictOptions(DICT_TYPE.SPECIAL_DEPT_ROLE)
// userStore.rolesdeviceMoldTypeList
const matchingRole = userStore.roles.find(role =>
deviceMoldTypeList.some(deviceMold => deviceMold.value === role)
);
if (formType === 'create') { if (formType === 'create') {
data.manageDept = matchingRole
await FixedAssetsApi.createFixedAssets(data) await FixedAssetsApi.createFixedAssets(data)
message.success(t('common.createSuccess')) message.success(t('common.createSuccess'))
} else { } else {
data.manageDept = matchingRole
await FixedAssetsApi.updateFixedAssets(data) await FixedAssetsApi.updateFixedAssets(data)
message.success(t('common.updateSuccess')) message.success(t('common.updateSuccess'))
} }

Loading…
Cancel
Save