| | |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="发货日期" prop="shippingDate" width="120" show-overflow-tooltip /> |
| | | <el-table-column label="录入日期" prop="entryDate" width="120" show-overflow-tooltip /> |
| | | <el-table-column label="签订日期" prop="executionDate" width="120" show-overflow-tooltip /> |
| | | <el-table-column label="录入日期" prop="entryDate" width="120" show-overflow-tooltip /> |
| | | <el-table-column fixed="right" label="操作" min-width="200" align="center"> |
| | | <template #default="scope"> |
| | | <el-button link type="primary" size="small" @click="openForm('edit', scope.row)">编辑</el-button> |
| | |
| | | const getProductOptions = () => { |
| | | // 返回 Promise,便于在编辑产品时等待加载完成 |
| | | return productTreeList().then((res) => { |
| | | productOptions.value = convertIdToValue(res); |
| | | // 兼容接口返回 { data: [] } 或直接返回数组 |
| | | const list = Array.isArray(res) ? res : (res?.data ?? []); |
| | | productOptions.value = convertIdToValue(list); |
| | | return productOptions.value; |
| | | }); |
| | | }; |
| | |
| | | return null; // 没有找到节点,返回null |
| | | }; |
| | | function convertIdToValue(data) { |
| | | if (!data || !Array.isArray(data)) return []; |
| | | return data.map((item) => { |
| | | const { id, children, ...rest } = item; |
| | | const newItem = { |
| | |
| | | productOperationType.value = type; |
| | | productForm.value = {}; |
| | | proxy.resetForm("productFormRef"); |
| | | // 新增、编辑都需先加载产品树,否则 el-tree-select 无数据 |
| | | try { |
| | | await getProductOptions(); |
| | | } catch (e) { |
| | | console.error("加载产品树失败", e); |
| | | } |
| | | if (type === "edit") { |
| | | productForm.value = { ...row }; |
| | | productIndex.value = index; |