| | |
| | | |
| | | function createDefaultModel(): Model { |
| | | return { |
| | | id: null, |
| | | materialname: '', |
| | | batchcode: '', |
| | | actualstarttime: null, |
| | | jobinput: null, |
| | | weightloss: null, |
| | | slkrate: null, |
| | | weight: null, |
| | | distimebegin: null, |
| | | distimeend: null, |
| | | siloid: '' |
| | | id: null, |
| | | materialname: '', |
| | | batchcode: '', |
| | | actualstarttime: null, |
| | | jobinput: null, |
| | | weightloss: null, |
| | | slkrate: null, |
| | | weight: null, |
| | | distimebegin: null, |
| | | distimeend: null, |
| | | siloid: '' |
| | | }; |
| | | } |
| | | |
| | | type RuleKey = Extract< |
| | | keyof Model, |
| | | | 'id' |
| | | | 'materialname' |
| | | | 'batchcode' |
| | | >; |
| | | type RuleKey = Extract<keyof Model, 'id' | 'materialname' | 'batchcode'>; |
| | | |
| | | const rules: Record<RuleKey, App.Global.FormRule> = { |
| | | id: createRequiredRule('id不能为空'), |
| | | materialname: createRequiredRule('牌号不能为空'), |
| | | batchcode: createRequiredRule('批次号不能为空'), |
| | | batchcode: createRequiredRule('批次号不能为空') |
| | | }; |
| | | |
| | | function handleUpdateModelWhenEdit() { |
| | |
| | | async function handleSubmit() { |
| | | await validate(); |
| | | |
| | | const { id, materialname, batchcode, actualstarttime, jobinput, weightloss, slkrate, weight, distimebegin, distimeend, siloid } = model.value; |
| | | const { |
| | | id, |
| | | materialname, |
| | | batchcode, |
| | | actualstarttime, |
| | | jobinput, |
| | | weightloss, |
| | | slkrate, |
| | | weight, |
| | | distimebegin, |
| | | distimeend, |
| | | siloid |
| | | } = model.value; |
| | | |
| | | // request |
| | | if (props.operateType === 'add') { |
| | | const { error } = await fetchCreateStoreSilk({ materialname, batchcode, actualstarttime, jobinput, weightloss, slkrate, weight, distimebegin, distimeend, siloid }); |
| | | const { error } = await fetchCreateStoreSilk({ |
| | | materialname, |
| | | batchcode, |
| | | actualstarttime, |
| | | jobinput, |
| | | weightloss, |
| | | slkrate, |
| | | weight, |
| | | distimebegin, |
| | | distimeend, |
| | | siloid |
| | | }); |
| | | if (error) return; |
| | | } |
| | | |
| | | if (props.operateType === 'edit') { |
| | | const { error } = await fetchUpdateStoreSilk({ id, materialname, batchcode, actualstarttime, jobinput, weightloss, slkrate, weight, distimebegin, distimeend, siloid }); |
| | | const { error } = await fetchUpdateStoreSilk({ |
| | | id, |
| | | materialname, |
| | | batchcode, |
| | | actualstarttime, |
| | | jobinput, |
| | | weightloss, |
| | | slkrate, |
| | | weight, |
| | | distimebegin, |
| | | distimeend, |
| | | siloid |
| | | }); |
| | | if (error) return; |
| | | } |
| | | |