|
@@ -6,7 +6,10 @@
|
|
|
<div class="page-head-titles">
|
|
<div class="page-head-titles">
|
|
|
<div class="page-title">设备统计</div>
|
|
<div class="page-title">设备统计</div>
|
|
|
</div>
|
|
</div>
|
|
|
- <el-button type="primary" icon="Plus" class="btn-primary" @click="handleAdd">新增设备</el-button>
|
|
|
|
|
|
|
+ <div class="page-head-actions">
|
|
|
|
|
+ <el-button icon="Upload" @click="handleImport">导入设备</el-button>
|
|
|
|
|
+ <el-button type="primary" icon="Plus" class="btn-primary" @click="handleAdd">新增设备</el-button>
|
|
|
|
|
+ </div>
|
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
<!-- KPI -->
|
|
<!-- KPI -->
|
|
@@ -428,6 +431,49 @@
|
|
|
<el-button type="primary" @click="mapOpen = false">使用当前坐标</el-button>
|
|
<el-button type="primary" @click="mapOpen = false">使用当前坐标</el-button>
|
|
|
</template>
|
|
</template>
|
|
|
</el-dialog>
|
|
</el-dialog>
|
|
|
|
|
+
|
|
|
|
|
+ <!-- 设备导入弹窗 -->
|
|
|
|
|
+ <el-dialog v-model="importOpen" title="导入设备" width="640px" append-to-body @closed="resetImport">
|
|
|
|
|
+ <el-upload
|
|
|
|
|
+ ref="importUploadRef"
|
|
|
|
|
+ drag
|
|
|
|
|
+ :limit="1"
|
|
|
|
|
+ accept=".xlsx, .xls"
|
|
|
|
|
+ :action="importActionUrl"
|
|
|
|
|
+ :headers="importHeaders"
|
|
|
|
|
+ :auto-upload="false"
|
|
|
|
|
+ :disabled="importUploading"
|
|
|
|
|
+ :before-upload="beforeImportUpload"
|
|
|
|
|
+ :on-progress="onImportProgress"
|
|
|
|
|
+ :on-success="onImportSuccess"
|
|
|
|
|
+ :on-error="onImportError"
|
|
|
|
|
+ >
|
|
|
|
|
+ <el-icon class="el-icon--upload"><upload-filled /></el-icon>
|
|
|
|
|
+ <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
|
|
|
|
|
+ <template #tip>
|
|
|
|
|
+ <div class="el-upload__tip">
|
|
|
|
|
+ <el-link type="primary" :underline="false" @click="downloadImportTemplate">下载模板</el-link>
|
|
|
|
|
+ <div>仅支持 xls、xlsx;模板中带红色 * 的列为必填;已存在的设备编码不会做任何修改。</div>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </template>
|
|
|
|
|
+ </el-upload>
|
|
|
|
|
+
|
|
|
|
|
+ <div v-if="importResult" class="import-result">
|
|
|
|
|
+ <div class="import-result-summary">
|
|
|
|
|
+ 导入成功 <strong>{{ importResult.successCount }}</strong> 条,导入失败
|
|
|
|
|
+ <strong :class="{ 'is-failure': importResult.failureCount > 0 }">{{ importResult.failureCount }}</strong> 条
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <el-table v-if="importResult.failures?.length" :data="importResult.failures" height="240" border size="small">
|
|
|
|
|
+ <el-table-column prop="equipmentCode" label="设备编码" width="200" show-overflow-tooltip />
|
|
|
|
|
+ <el-table-column prop="reason" label="失败原因" show-overflow-tooltip />
|
|
|
|
|
+ </el-table>
|
|
|
|
|
+ </div>
|
|
|
|
|
+
|
|
|
|
|
+ <template #footer>
|
|
|
|
|
+ <el-button type="primary" :loading="importUploading" @click="submitImport">开始导入</el-button>
|
|
|
|
|
+ <el-button @click="importOpen = false">关 闭</el-button>
|
|
|
|
|
+ </template>
|
|
|
|
|
+ </el-dialog>
|
|
|
</div>
|
|
</div>
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
@@ -447,7 +493,8 @@ import {
|
|
|
updateEquipment,
|
|
updateEquipment,
|
|
|
updateEquipmentStatus
|
|
updateEquipmentStatus
|
|
|
} from "@/api/pipeNetwork/pdeviceInform";
|
|
} from "@/api/pipeNetwork/pdeviceInform";
|
|
|
-import request from "@/utils/request";
|
|
|
|
|
|
|
+import request, { download } from "@/utils/request";
|
|
|
|
|
+import { getToken } from "@/utils/auth";
|
|
|
import { buildMinioAttachmentUrl } from "@/utils/minioAttachment";
|
|
import { buildMinioAttachmentUrl } from "@/utils/minioAttachment";
|
|
|
|
|
|
|
|
const { proxy } = getCurrentInstance();
|
|
const { proxy } = getCurrentInstance();
|
|
@@ -913,6 +960,66 @@ function resetQuery() {
|
|
|
handleQuery();
|
|
handleQuery();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+// 设备导入
|
|
|
|
|
+const importOpen = ref(false);
|
|
|
|
|
+const importUploadRef = ref();
|
|
|
|
|
+const importUploading = ref(false);
|
|
|
|
|
+const importResult = ref(null);
|
|
|
|
|
+const importHeaders = { Authorization: "Bearer " + getToken() };
|
|
|
|
|
+const importActionUrl = `${import.meta.env.VITE_APP_BASE_API}/equipment-base/importData`;
|
|
|
|
|
+
|
|
|
|
|
+function handleImport() {
|
|
|
|
|
+ importResult.value = null;
|
|
|
|
|
+ importOpen.value = true;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+function beforeImportUpload(file) {
|
|
|
|
|
+ if (!/\.(xlsx|xls)$/iu.test(file?.name || "")) {
|
|
|
|
|
+ proxy.$modal.msgError("仅支持 xls、xlsx 文件");
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+ return true;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+function onImportProgress() {
|
|
|
|
|
+ importUploading.value = true;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+function onImportSuccess(response) {
|
|
|
|
|
+ importUploading.value = false;
|
|
|
|
|
+ if (response?.code !== 200) {
|
|
|
|
|
+ proxy.$modal.msgError(response?.msg || "导入失败,请检查文件格式");
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ importResult.value = response.data || { successCount: 0, failureCount: 0, failures: [] };
|
|
|
|
|
+ importUploadRef.value?.clearFiles();
|
|
|
|
|
+ proxy.$modal.msgSuccess(
|
|
|
|
|
+ importResult.value.message ||
|
|
|
|
|
+ `导入完成:成功 ${importResult.value.successCount} 条,失败 ${importResult.value.failureCount} 条`
|
|
|
|
|
+ );
|
|
|
|
|
+ Promise.all([getList(), loadAssistData(), loadStatistics()]);
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+function onImportError(error) {
|
|
|
|
|
+ importUploading.value = false;
|
|
|
|
|
+ proxy.$modal.msgError(error?.message || "导入失败,请检查文件格式");
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+function submitImport() {
|
|
|
|
|
+ importResult.value = null;
|
|
|
|
|
+ importUploadRef.value?.submit();
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+function downloadImportTemplate() {
|
|
|
|
|
+ download("/equipment-base/importTemplate", {}, "设备台账导入模板.xlsx");
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+function resetImport() {
|
|
|
|
|
+ importUploading.value = false;
|
|
|
|
|
+ importResult.value = null;
|
|
|
|
|
+ importUploadRef.value?.clearFiles();
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
function handleAdd() {
|
|
function handleAdd() {
|
|
|
reset();
|
|
reset();
|
|
|
open.value = true;
|
|
open.value = true;
|
|
@@ -1043,10 +1150,34 @@ onBeforeUnmount(() => {
|
|
|
line-height: 1.4;
|
|
line-height: 1.4;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+.page-head-actions {
|
|
|
|
|
+ display: flex;
|
|
|
|
|
+ gap: 8px;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
.btn-primary :deep(.el-icon) {
|
|
.btn-primary :deep(.el-icon) {
|
|
|
font-size: 14px;
|
|
font-size: 14px;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+.import-result {
|
|
|
|
|
+ margin-top: 16px;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+.import-result-summary {
|
|
|
|
|
+ margin-bottom: 10px;
|
|
|
|
|
+ font-size: 14px;
|
|
|
|
|
+ color: #303133;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+.import-result-summary strong {
|
|
|
|
|
+ color: #67c23a;
|
|
|
|
|
+ font-size: 16px;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+.import-result-summary strong.is-failure {
|
|
|
|
|
+ color: #f56c6c;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
/* KPI */
|
|
/* KPI */
|
|
|
.kpi-row {
|
|
.kpi-row {
|
|
|
display: flex;
|
|
display: flex;
|