| | |
| | | <el-form-item :prop="`dataList.${$index}.unitQuantity`" |
| | | :rules="[{ required: true, message: '请输入单位产出所需数量', trigger: ['blur','change'] }]" |
| | | style="margin: 0"> |
| | | <el-input-number v-model="row.unitQuantity" |
| | | <el-input-number v-if="dataValue.isEdit" |
| | | v-model="row.unitQuantity" |
| | | :min="0" |
| | | :precision="2" |
| | | :precision="3" |
| | | :step="1" |
| | | controls-position="right" |
| | | style="width: 100%" |
| | | :disabled="!dataValue.isEdit" /> |
| | | <span v-else>{{ formatDecimalValue(row.unitQuantity) }}</span> |
| | | </el-form-item> |
| | | </template> |
| | | </el-table-column> |
| | |
| | | dataValue.showProductDialog = true; |
| | | }; |
| | | |
| | | const formatDecimalValue = ( |
| | | value: number | string | null | undefined |
| | | ) => { |
| | | const numericValue = Number(value); |
| | | if (Number.isNaN(numericValue)) { |
| | | return value; |
| | | } |
| | | return Number(numericValue.toFixed(3)); |
| | | }; |
| | | |
| | | const normalizeProductStructureList = (list: any[] = []) => |
| | | list.map((item: any) => ({ |
| | | ...item, |
| | | unitQuantity: formatDecimalValue(item.unitQuantity ?? 0), |
| | | })); |
| | | |
| | | const fetchData = async () => { |
| | | const { data } = await queryList(props.record.id); |
| | | dataValue.dataList = data; |
| | | dataValue.dataList = normalizeProductStructureList(data) as typeof dataValue.dataList; |
| | | }; |
| | | |
| | | const fetchProcessOptions = async () => { |
| | |
| | | if (valid) { |
| | | add({ |
| | | parentId: props.record.id, |
| | | productStructureList: dataValue.dataList || [], |
| | | }).then(res => { |
| | | productStructureList: normalizeProductStructureList(dataValue.dataList as any[]), |
| | | }).then(() => { |
| | | ElMessage.success("保存成功"); |
| | | visible.value = false; |
| | | dataValue.loading = false; |
| | |
| | | fetchData(); |
| | | fetchProcessOptions(); |
| | | }); |
| | | </script> |
| | | </script> |