| | |
| | | style="margin-left: 10px" |
| | | >新增产品大类</el-button |
| | | > |
| | | <el-button type="success" style="margin-left: 10px" @click="openExportDia"> |
| | | 导出 |
| | | </el-button> |
| | | </div> |
| | | <div ref="containerRef"> |
| | | <el-tree |
| | |
| | | </div> |
| | | </template> |
| | | </el-dialog> |
| | | <el-dialog |
| | | v-model="exportDia" |
| | | title="导出产品数据" |
| | | width="420px" |
| | | @keydown.enter.prevent |
| | | > |
| | | <el-form label-position="top"> |
| | | <el-form-item label="选择产品大类(可不选)"> |
| | | <el-select |
| | | v-model="exportProductId" |
| | | clearable |
| | | filterable |
| | | placeholder="不选则导出全部产品" |
| | | style="width: 100%" |
| | | > |
| | | <el-option |
| | | v-for="item in rootProductOptions" |
| | | :key="item.id" |
| | | :label="item.label" |
| | | :value="item.id" |
| | | /> |
| | | </el-select> |
| | | <div class="export-tip"> |
| | | 已选:导出该大类及其子类;未选:导出全部 |
| | | </div> |
| | | </el-form-item> |
| | | </el-form> |
| | | <template #footer> |
| | | <div class="dialog-footer"> |
| | | <el-button type="primary" :loading="exportLoading" :disabled="exportLoading" @click="handleExport"> |
| | | 确认导出 |
| | | </el-button> |
| | | <el-button @click="closeExportDia">取消</el-button> |
| | | </div> |
| | | </template> |
| | | </el-dialog> |
| | | </div> |
| | | </template> |
| | | |
| | |
| | | addOrEditProductModel, |
| | | delProduct, |
| | | delProductModel, |
| | | exportProductData, |
| | | modelListPage, |
| | | productTreeList, |
| | | } from "@/api/basicData/product.js"; |
| | |
| | | |
| | | const productDia = ref(false); |
| | | const modelDia = ref(false); |
| | | const exportDia = ref(false); |
| | | const exportLoading = ref(false); |
| | | const modelOperationType = ref(""); |
| | | const search = ref(""); |
| | | const currentId = ref(""); |
| | | const currentParentId = ref(""); |
| | | const exportProductId = ref(""); |
| | | const operationType = ref(""); |
| | | const treeLoad = ref(false); |
| | | const list = ref([]); |
| | | const expandedKeys = ref([]); |
| | | const rootProductOptions = ref([]); |
| | | const tableColumn = ref([ |
| | | { |
| | | label: "规格型号", |
| | |
| | | productTreeList() |
| | | .then((res) => { |
| | | list.value = res; |
| | | rootProductOptions.value = Array.isArray(res) ? res : []; |
| | | list.value.forEach((a) => { |
| | | expandedKeys.value.push(a.label); |
| | | }); |
| | |
| | | proxy.$modal.msg("已取消"); |
| | | }); |
| | | }; |
| | | const openExportDia = () => { |
| | | exportDia.value = true; |
| | | }; |
| | | const closeExportDia = () => { |
| | | exportDia.value = false; |
| | | }; |
| | | // 导出产品(可按大类,含子类) |
| | | const handleExport = () => { |
| | | if (exportLoading.value) return; |
| | | exportLoading.value = true; |
| | | const params = exportProductId.value ? { productId: exportProductId.value } : {}; |
| | | exportProductData(params) |
| | | .then((blobData) => { |
| | | const blob = |
| | | blobData instanceof Blob |
| | | ? blobData |
| | | : new Blob([blobData], { |
| | | type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", |
| | | }); |
| | | const url = window.URL.createObjectURL(blob); |
| | | const link = document.createElement("a"); |
| | | link.href = url; |
| | | link.download = "产品数据.xlsx"; |
| | | document.body.appendChild(link); |
| | | link.click(); |
| | | document.body.removeChild(link); |
| | | window.URL.revokeObjectURL(url); |
| | | closeExportDia(); |
| | | }) |
| | | .catch(() => { |
| | | proxy.$modal.msgError("导出失败,请稍后重试"); |
| | | }) |
| | | .finally(() => { |
| | | exportLoading.value = false; |
| | | }); |
| | | }; |
| | | // 调用tree过滤方法 中文英过滤 |
| | | const filterNode = (value, data, node) => { |
| | | if (!value) { |
| | |
| | | .product-tree-scroll::-webkit-scrollbar-thumb:hover { |
| | | background: #909399; |
| | | } |
| | | .export-tip { |
| | | margin-top: 8px; |
| | | font-size: 12px; |
| | | color: #909399; |
| | | } |
| | | </style> |