Browse Source

bug修复和优化

master
ljlong_2630 2 months ago
parent
commit
6971ab00ab
  1. 6
      src/api/eam/basic/location/index.ts
  2. 8
      src/views/eam/item/itemAccounts/itemAccounts.data.ts
  3. 28
      src/views/eam/item/itemLocationReplace/index.vue
  4. 103
      src/views/eam/item/itemLocationReplace/itemLocationReplace.data.ts

6
src/api/eam/basic/location/index.ts

@ -53,3 +53,9 @@ export const exportLocation = async (params) => {
export const getLocationNoPage = async (params) => {
return await request.get({ url: `/eam/location/noPage`, params })
}
// 查询库位列表
export const selectPageByConditions = async (params) => {
return await request.get({ url: `/eam/location/selectPageByConditions`, params })
}

8
src/views/eam/item/itemAccounts/itemAccounts.data.ts

@ -305,7 +305,15 @@ export const ItemAccounts = useCrudSchemas(reactive<CrudSchema[]>([
field: 'areaAge',
sort: 'custom',
formatter: (row: Recordable, column: TableColumn, cellValue: any) => {
if (!row.purchaseTime) {
return '未知'; // 如果 purchaseTime 为 null 或 undefined,返回 '未知'
}
const purchaseTime = new Date(row.purchaseTime); // 获取采购时间
if (isNaN(purchaseTime.getTime())) {
return '未知'; // 如果 purchaseTime 不是有效日期,返回 '未知'
}
const currentTime = new Date(); // 当前时间
const ageInMilliseconds = currentTime.getTime() - purchaseTime.getTime(); // 时间差(毫秒)
const ageInDays = Math.floor(ageInMilliseconds / (1000 * 60 * 60 * 24)); // 转换为天数

28
src/views/eam/item/itemLocationReplace/index.vue

@ -65,6 +65,7 @@ import * as defaultButtons from '@/utils/disposition/defaultButtons'
import TableHead from '@/components/TableHead/src/TableHead.vue'
import ImportForm from '@/components/ImportForm/src/ImportForm.vue'
import Detail from '@/components/Detail/src/Detail.vue'
import * as ItemAccountsApi from '@/api/eam/item/itemAccounts'
defineOptions({ name: 'ItemLocationReplace' })
@ -77,13 +78,28 @@ routeName.value = route.name
const tableColumns = ref(ItemLocationReplace.allSchemas.tableColumns)
//
const searchTableSuccess = (formField, searchField, val, formRef) => {
const searchTableSuccess = async (formField, searchField, val, formRef) => {
nextTick(() => {
const setV = {}
setV[formField] = val[0][searchField]
formRef.setValues(setV)
})
}
const setV = {};
if (formField === 'locationNumber') {
setV['isInAccount'] = val[0].isInAccount;
let params = {
isInAccount: val[0].isInAccount,
locationNumber: val[0].number
};
ItemAccountsApi.getItemAccountsPage(params).then(res => {
setV['oldItemNumber'] = res.list[0]?.itemNumber;
//
setV[formField] = val[0][searchField];
formRef.setValues(setV);
});
} else if(formField === 'itemNumber'){
setV['oldLocationNumber'] = val[0].locationNumber;
setV[formField] = val[0][searchField];
formRef.setValues(setV);
}
});
};
//
const updataTableColumns = (val) => {

103
src/views/eam/item/itemLocationReplace/itemLocationReplace.data.ts

@ -1,32 +1,117 @@
import type { CrudSchema } from '@/hooks/web/useCrudSchemas'
import { dateFormatter } from '@/utils/formatTime'
import * as UserApi from '@/api/system/user'
import { Location } from '../../basic/location/location.data'
import * as LocationApi from '@/api/eam/basic/location'
import { ItemAccounts } from '../itemAccounts/itemAccounts.data'
import * as ItemAccountsApi from '@/api/eam/item/itemAccounts'
const userListAll = await UserApi.getSimpleUserList()
// 表单校验
export const ItemLocationReplaceRules = reactive({
locationNumber: [required],
oldItemNumber: [required],
itemNumber: [required],
oldLocationNumber: [required],
})
export const ItemLocationReplace = useCrudSchemas(reactive<CrudSchema[]>([
{
label: '库位编号',
label: '变更后库位编号',
field: 'locationNumber',
sort: 'custom',
isSearch: true,
form: {
componentProps: {
enterSearch: true,
isSearchList: true, // 开启查询弹窗
searchListPlaceholder: '请选择变更后库位编号', // 输入框占位文本
searchField: 'number', // 查询弹窗赋值字段
searchTitle: '库位信息', // 查询弹窗标题
isConcatDetailSchemas:false,//是否是主子表合并 默认false
searchAllSchemas: Location.allSchemas, // 查询弹窗所需类
searchPage: LocationApi.selectPageByConditions, // 查询弹窗所需分页方法
isEnter:true,
searchCondition: [{
key:'available',
value:'TRUE',
message: '是否可用',
isMainValue: false
},{
key:'qty',
value:'0',
message: '库存数量',
isMainValue: false
},]
}
},
},
{
label: '变更前备件编号',
field: 'oldItemNumber',
sort: 'custom',
isSearch: true,
form: {
component: 'Input',
componentProps: {
disabled: true,
}
}
},
{
label: '变更后备件编号',
field: 'itemNumber',
sort: 'custom',
isSearch: true,
form: {
componentProps: {
enterSearch: true,
isSearchList: true, // 开启查询弹窗
searchListPlaceholder: '请选择变更后备件编号', // 输入框占位文本
searchField: 'itemNumber', // 查询弹窗赋值字段
searchTitle: '备件信息', // 查询弹窗标题
isConcatDetailSchemas:false,//是否是主子表合并 默认false
searchAllSchemas: ItemAccounts.allSchemas, // 查询弹窗所需类
searchPage: ItemAccountsApi.getItemAccountsPage, // 查询弹窗所需分页方法
isEnter:true,
searchCondition: [{
key:'available',
value:'TRUE',
message: '是否可用',
isMainValue: false
}, {
key:'isInAccount',
value:'isInAccount',
message: '请选择变更后库位!',
isMainValue: true
}]
}
},
},
{
label: '变更前库位编号',
field: 'oldLocationNumber',
sort: 'custom',
isSearch: true,
form: {
component: 'Input',
componentProps: {
disabled: true,
}
}
},
{
label: '是否账内',
field: 'isInAccount',
sort: 'custom',
isSearch: true,
dictType: DICT_TYPE.TRUE_FALSE,
dictClass: 'string',
form: {
component: 'Select',
componentProps: {
disabled: true
}
}
},
{
label: '变更时间',
@ -44,6 +129,18 @@ export const ItemLocationReplace = useCrudSchemas(reactive<CrudSchema[]>([
},
isForm: false,
},
{
label: '变更人',
field: 'creator',
sort: 'custom',
isForm: false,
formatter: (_: Recordable, __: TableColumn, cellValue: number) => {
return userListAll.find((account) => account.id == cellValue)?.nickname
},
table: {
width: 170
},
},
{
label: '操作',
field: 'action',

Loading…
Cancel
Save