| | |
| | | name: "产品维护导入", |
| | | }); |
| | | |
| | | const props = defineProps({ |
| | | productId: { type: [String, Number], default: "" }, |
| | | }); |
| | | const emits = defineEmits(["uploadSuccess"]); |
| | | const fileUploadRef = ref(); |
| | | const upload = reactive({ |
| | | // 是否显示弹出层(供应商导入) |
| | | open: false, |
| | | // 弹出层标题(供应商导入) |
| | | title: "", |
| | | title: "产品导入", |
| | | // 是否禁用上传 |
| | | isUploading: false, |
| | | // 设置上传的请求头部 |
| | | headers: { Authorization: "Bearer " + getToken() }, |
| | | }); |
| | | // 上传的地址(携带 productId 参数,传给后端的 importProduct 接口) |
| | | const uploadUrl = computed( |
| | | () => |
| | | import.meta.env.VITE_APP_BASE_API + |
| | | "/basic/product/import" + |
| | | (props.productId ? `?productId=${props.productId}` : "") |
| | | ); |
| | | // 上传的地址 |
| | | const uploadUrl = computed(() => import.meta.env.VITE_APP_BASE_API + "/basic/product/import"); |
| | | // 点击导入 |
| | | const handleImport = () => { |
| | | if (!props.productId) { |
| | | ElMessage({ message: "请先选择产品", type: "warning" }); |
| | | return; |
| | | } |
| | | upload.open = true; |
| | | upload.title = "产品导入"; |
| | | }; |
| | | |
| | | const submitFileForm = () => { |
| | |
| | | @clear="searchFilter" |
| | | clearable |
| | | prefix-icon="Search" /> |
| | | <span style="margin-left: 12px"> |
| | | <ImportExcel @uploadSuccess="handleImportSuccess" /> |
| | | </span> |
| | | <el-button v-if="false" |
| | | type="primary" |
| | | @click="openProDia('addOne')" |
| | |
| | | @click="openModelDia('add')"> |
| | | 新增规格型号 |
| | | </el-button> |
| | | <ImportExcel :product-id="currentId" |
| | | @uploadSuccess="getModelList" /> |
| | | <el-button type="danger" |
| | | @click="handleDelete" |
| | | style="margin-left: 10px" |
| | |
| | | tableLoading.value = false; |
| | | }); |
| | | }; |
| | | // 导入完成后刷新产品树与右侧规格列表 |
| | | const handleImportSuccess = () => { |
| | | getProductTreeList(); |
| | | if (currentId.value) { |
| | | getModelList(); |
| | | } |
| | | }; |
| | | // 删除规格型号 |
| | | const handleDelete = () => { |
| | | let ids = []; |
| | |
| | | style="margin: 0"> |
| | | <el-input-number v-model="row.unitQuantity" |
| | | :min="0" |
| | | :precision="2" |
| | | :precision="8" |
| | | :step="1" |
| | | controls-position="right" |
| | | style="width: 100%" |
| | |
| | | }); |
| | | }; |
| | | |
| | | const toQuantityNumber = value => { |
| | | const toQuantityNumber = (value, scale = 2) => { |
| | | const numberValue = Number(value); |
| | | if (!Number.isFinite(numberValue)) { |
| | | return 0; |
| | | } |
| | | return Number(numberValue.toFixed(2)); |
| | | return Number(numberValue.toFixed(scale)); |
| | | }; |
| | | |
| | | const syncDemandedQuantityTree = (items, parentDemandedQuantity = null) => { |
| | | items.forEach(item => { |
| | | if (parentDemandedQuantity !== null) { |
| | | item.demandedQuantity = toQuantityNumber( |
| | | parentDemandedQuantity * toQuantityNumber(item.unitQuantity) |
| | | parentDemandedQuantity * toQuantityNumber(item.unitQuantity, 8) |
| | | ); |
| | | } |
| | | |
| | |
| | | style="margin: 0"> |
| | | <el-input-number v-model="row.unitQuantity" |
| | | :min="0" |
| | | :precision="2" |
| | | :precision="8" |
| | | :step="1" |
| | | controls-position="right" |
| | | style="width: 100%" |
| | |
| | | }); |
| | | }; |
| | | |
| | | const toQuantityNumber = (value: any) => { |
| | | const toQuantityNumber = (value: any, scale: number = 2) => { |
| | | const numberValue = Number(value); |
| | | if (!Number.isFinite(numberValue)) { |
| | | return 0; |
| | | } |
| | | return Number(numberValue.toFixed(2)); |
| | | return Number(numberValue.toFixed(scale)); |
| | | }; |
| | | |
| | | const syncDemandedQuantityTree = ( |
| | |
| | | items.forEach((item: any) => { |
| | | if (parentDemandedQuantity !== null) { |
| | | item.demandedQuantity = toQuantityNumber( |
| | | parentDemandedQuantity * toQuantityNumber(item.unitQuantity) |
| | | parentDemandedQuantity * toQuantityNumber(item.unitQuantity, 8) |
| | | ); |
| | | } |
| | | |
| | |
| | | }; |
| | | |
| | | const fetchProcessOptions = async () => { |
| | | const { data } = await list({}); |
| | | const { data } = await list({size: -1}); |
| | | console.log(data, "dataValue.dataList"); |
| | | dataValue.processOptions = normalizeListData(data); |
| | | }; |
| | |
| | | <el-form-item label="数量" :rules="[{ required: true, message: '请填写数量' }]" style="margin:0"> |
| | | <el-input-number v-model="row.unitQuantity" |
| | | :min="0" |
| | | :precision="2" |
| | | :precision="8" |
| | | :step="1" |
| | | controls-position="right" |
| | | style="width:100%" |
| | |
| | | }); |
| | | }; |
| | | |
| | | const toQuantityNumber = (value: any) => { |
| | | const toQuantityNumber = (value: any, scale: number = 2) => { |
| | | const numberValue = Number(value); |
| | | if (!Number.isFinite(numberValue)) { |
| | | return 0; |
| | | } |
| | | return Number(numberValue.toFixed(2)); |
| | | return Number(numberValue.toFixed(scale)); |
| | | }; |
| | | |
| | | const syncDemandedQuantityTree = ( |
| | |
| | | items.forEach((item: any) => { |
| | | if (parentDemandedQuantity !== null) { |
| | | item.demandedQuantity = toQuantityNumber( |
| | | parentDemandedQuantity * toQuantityNumber(item.unitQuantity) |
| | | parentDemandedQuantity * toQuantityNumber(item.unitQuantity, 8) |
| | | ); |
| | | } |
| | | |
| | |
| | | }; |
| | | |
| | | const fetchProcessOptions = async () => { |
| | | const { data } = await list({}); |
| | | const { data } = await list({size: -1}); |
| | | console.log(data, "dataValue.dataList"); |
| | | dataValue.processOptions = normalizeListData(data); |
| | | }; |
| | |
| | | style="margin: 0"> |
| | | <el-input-number v-model="row.unitQuantity" |
| | | :min="0" |
| | | :precision="2" |
| | | :precision="8" |
| | | :step="1" |
| | | controls-position="right" |
| | | style="width: 100%" |
| | |
| | | <template #default="{ row }"> |
| | | <el-input-number v-model="row.pickQty" |
| | | :min="0" |
| | | :precision="3" |
| | | :precision="8" |
| | | :step="1" |
| | | controls-position="right" |
| | | style="width: 100%;" /> |