Browse Source

物品基础信息 根据生效时间和有效天数 自动计算失效时间

master
陈薪名 11 months ago
parent
commit
4489c23fe4
  1. 55
      src/views/wms/basicDataManage/itemManage/itembasic/index.vue
  2. 4
      src/views/wms/basicDataManage/itemManage/itembasic/itembasic.data.ts

55
src/views/wms/basicDataManage/itemManage/itembasic/index.vue

@ -44,6 +44,7 @@
:apiUpdate="ItembasicApi.updateItembasic" :apiUpdate="ItembasicApi.updateItembasic"
:apiCreate="ItembasicApi.createItembasic" :apiCreate="ItembasicApi.createItembasic"
:isBusiness="false" :isBusiness="false"
@onChange="onChange"
/> />
<!-- 详情 --> <!-- 详情 -->
@ -190,28 +191,42 @@ const basicFormRef = ref()
const openForm = (type: string, id?: number) => { const openForm = (type: string, id?: number) => {
basicFormRef.value.open(type, id) basicFormRef.value.open(type, id)
} }
/**
* 监听改变事件
* @param field 当前操作字段
* @param cur 改变后值
*/
const onChange = (field, cur) => {
//
if (field == 'validityDays' || field == 'activeTime') {
//
basicFormRef.value.formRef.formModel.expireTime = basicFormRef.value.formRef.formModel.activeTime + basicFormRef.value.formRef.formModel.validityDays * 24 * 60 * 60 * 1000
}
}
// form // form
const formsSuccess = async (formType,data) => { const formsSuccess = async (formType,data) => {
var isHave =Itembasic.allSchemas.formSchema.some(function (item) { var isHave =Itembasic.allSchemas.formSchema.some(function (item) {
return item.field === 'activeTime' || item.field === 'expireTime'; return item.field === 'activeTime' || item.field === 'expireTime';
}); })
if(isHave){ if(isHave){
if(data.activeTime && data.expireTime && data.activeTime >=data.expireTime){ if(data.activeTime && data.expireTime && data.activeTime >=data.expireTime){
message.error('失效时间要大于生效时间') message.error('失效时间要大于生效时间')
return; return
} }
} }
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;
if (formType === 'create') { if (formType === 'create') {
await ItembasicApi.createItembasic(data) await ItembasicApi.createItembasic(data)
message.success(t('common.createSuccess')) message.success(t('common.createSuccess'))
} else { } else {
await ItembasicApi.updateItembasic(data) await ItembasicApi.updateItembasic(data)
message.success(t('common.updateSuccess')) message.success(t('common.updateSuccess'))
} }
basicFormRef.value.dialogVisible = false basicFormRef.value.dialogVisible = false
getList() getList()
} }
const detailRef = ref() const detailRef = ref()

4
src/views/wms/basicDataManage/itemManage/itembasic/itembasic.data.ts

@ -317,7 +317,8 @@ export const Itembasic = useCrudSchemas(reactive<CrudSchema[]>([
form: { form: {
component: 'InputNumber', component: 'InputNumber',
componentProps: { componentProps: {
min: 0 min: 0,
precision: 0
} }
}, },
}, },
@ -386,6 +387,7 @@ export const Itembasic = useCrudSchemas(reactive<CrudSchema[]>([
type: 'datetime', type: 'datetime',
dateFormat: 'YYYY-MM-DD HH:mm:ss', dateFormat: 'YYYY-MM-DD HH:mm:ss',
valueFormat: 'x', valueFormat: 'x',
disabled: true
} }
}, },
}, },

Loading…
Cancel
Save