|
|
@ -44,6 +44,7 @@ |
|
|
|
:apiUpdate="ItembasicApi.updateItembasic" |
|
|
|
:apiCreate="ItembasicApi.createItembasic" |
|
|
|
:isBusiness="false" |
|
|
|
@onChange="onChange" |
|
|
|
/> |
|
|
|
|
|
|
|
<!-- 详情 --> |
|
|
@ -190,28 +191,42 @@ const basicFormRef = ref() |
|
|
|
const openForm = (type: string, id?: number) => { |
|
|
|
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表单提交 |
|
|
|
const formsSuccess = async (formType,data) => { |
|
|
|
var isHave =Itembasic.allSchemas.formSchema.some(function (item) { |
|
|
|
return item.field === 'activeTime' || item.field === 'expireTime'; |
|
|
|
}); |
|
|
|
if(isHave){ |
|
|
|
if(data.activeTime && data.expireTime && data.activeTime >=data.expireTime){ |
|
|
|
message.error('失效时间要大于生效时间') |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
if(data.activeTime==0)data.activeTime = null; |
|
|
|
if(data.expireTime==0)data.expireTime = null; |
|
|
|
if (formType === 'create') { |
|
|
|
await ItembasicApi.createItembasic(data) |
|
|
|
message.success(t('common.createSuccess')) |
|
|
|
} else { |
|
|
|
await ItembasicApi.updateItembasic(data) |
|
|
|
message.success(t('common.updateSuccess')) |
|
|
|
} |
|
|
|
basicFormRef.value.dialogVisible = false |
|
|
|
getList() |
|
|
|
var isHave =Itembasic.allSchemas.formSchema.some(function (item) { |
|
|
|
return item.field === 'activeTime' || item.field === 'expireTime'; |
|
|
|
}) |
|
|
|
if(isHave){ |
|
|
|
if(data.activeTime && data.expireTime && data.activeTime >=data.expireTime){ |
|
|
|
message.error('失效时间要大于生效时间') |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
if(data.activeTime==0)data.activeTime = null; |
|
|
|
if(data.expireTime==0)data.expireTime = null; |
|
|
|
if (formType === 'create') { |
|
|
|
await ItembasicApi.createItembasic(data) |
|
|
|
message.success(t('common.createSuccess')) |
|
|
|
} else { |
|
|
|
await ItembasicApi.updateItembasic(data) |
|
|
|
message.success(t('common.updateSuccess')) |
|
|
|
} |
|
|
|
basicFormRef.value.dialogVisible = false |
|
|
|
getList() |
|
|
|
} |
|
|
|
|
|
|
|
const detailRef = ref() |
|
|
|