| | |
| | | |
| | | 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; |
| | | } |
| | | |
| | |
| | | /> |
| | | </NFormItem> |
| | | <NFormItem label="投料重量" path="jobinput"> |
| | | <NInput v-model:value="model.jobinput" placeholder="请输入投料重量" /> |
| | | <NInputNumber v-model:value="model.jobinput" placeholder="请输入投料重量" class="w-full" /> |
| | | </NFormItem> |
| | | <NFormItem label="损耗重量" path="weightloss"> |
| | | <NInput v-model:value="model.weightloss" placeholder="请输入损耗重量" /> |
| | | <NInputNumber v-model:value="model.weightloss" placeholder="请输入损耗重量" class="w-full" /> |
| | | </NFormItem> |
| | | <NFormItem label="出叶丝率" path="slkrate"> |
| | | <NInput v-model:value="model.slkrate" placeholder="请输入出叶丝率" /> |
| | | <NInputNumber v-model:value="model.slkrate" placeholder="请输入出叶丝率" class="w-full" /> |
| | | </NFormItem> |
| | | <NFormItem label="储丝柜重量" path="weight"> |
| | | <NInput v-model:value="model.weight" placeholder="请输入储丝柜重量" /> |
| | | <NInputNumber v-model:value="model.weight" placeholder="请输入储丝柜重量" class="w-full" /> |
| | | </NFormItem> |
| | | <NFormItem label="储丝柜出料开始时间" path="distimebegin"> |
| | | <NDatePicker |