Parcourir la source

fix: 故障总览代码修改

Eureka il y a 8 mois
Parent
commit
45a8138985
1 fichiers modifiés avec 136 ajouts et 2 suppressions
  1. 136 2
      fms-ui/src/views/system/failureRecord/index.vue

+ 136 - 2
fms-ui/src/views/system/failureRecord/index.vue

@@ -23,6 +23,10 @@
                    v-hasPermi="['system:failure:import']">导入
         </el-button>
       </el-col>
+      <el-col :span="1.5">
+        <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleGenerateReport"
+                   v-hasPermi="['system:failure:export']">报告生成</el-button>
+      </el-col>
       <el-col :span="1.5">
         <el-button
           type="danger"
@@ -86,8 +90,7 @@
     <el-dialog :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body>
       <el-input v-model="upload.batchName" placeholder="请输入批次名称"></el-input>
       <el-upload ref="upload" :limit="1" accept=".xlsx, .xls" :headers="upload.headers"
-                 :data="{ batchName: upload.batchName }"
-                 :action="upload.url + '?updateSupport=' + upload.updateSupport" :disabled="upload.isUploading"
+                 :action="upload.url + '?batchName=' + upload.batchName + '&updateSupport=' + upload.updateSupport" :disabled="upload.isUploading"
                  :on-progress="handleFileUploadProgress" :on-success="handleFileSuccess" :auto-upload="false" drag>
         <i class="el-icon-upload"></i>
         <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
@@ -157,6 +160,47 @@
         <el-button @click="cancel">取 消</el-button>
       </div>
     </el-dialog>
+
+    <!-- 报告对话框 -->
+    <el-dialog :title="report.title" :visible.sync="report.open" width="400px" append-to-body>
+      <div style="margin: 5px">
+        <el-row>
+          <el-col>
+            <span style="">故障月份</span>
+          </el-col>
+          <el-col>
+            <el-date-picker v-model="report.reportDate" type="month" placeholder="选择故障月份" value-format="yyyy-MM">
+            </el-date-picker>
+          </el-col>
+        </el-row>
+      </div>
+      <div style="margin: 5px">
+        <el-row>
+          <el-col><span style="">专业</span></el-col>
+          <el-col>
+            <el-select v-model="report.major" placeholder="请选择专业">
+              <el-option v-for="item in report.majorOption" :key="item.major" :label="item.major" :value="item.major">
+              </el-option>
+            </el-select>
+          </el-col>
+        </el-row>
+      </div>
+      <div style="margin: 5px">
+        <el-row>
+          <el-col><span style="">机型系列</span></el-col>
+          <el-col>
+            <el-select v-model="selectedBrandIds" placeholder="请选择机型系列" multiple @change="handleBrandChange">
+              <el-option v-for="option in brandOptions" :key="option.brandId" :label="option.brandName"
+                         :value="option.brandId"></el-option>
+            </el-select>
+          </el-col>
+        </el-row>
+      </div>
+      <div slot="footer" class="dialog-footer">
+        <el-button type="primary" @click="submitGenerateReport">确 定</el-button>
+        <el-button @click="report.open = false">取 消</el-button>
+      </div>
+    </el-dialog>
   </div>
 </template>
 
@@ -170,10 +214,13 @@ import {
 } from "@/api/system/failureRecord";
 
 import {
+  generateReport,
+  getMajorOption,
   listFailure,
 } from "@/api/system/failure";
 
 import {getToken} from "@/utils/auth";
+import {getListBrand} from "@/api/system/brand";
 
 export default {
   name: "FailureRecord",
@@ -196,6 +243,21 @@ export default {
         // 上传的地址
         url: process.env.VUE_APP_BASE_API + "/system/failureRecord/importData",
       },
+      // 报告参数
+      report: {
+        // 是否显示弹出层
+        open: false,
+        // 弹出层标题
+        title: "生成报告",
+        // 报告日期
+        reportDate: null,
+        // 专业
+        major: null,
+        brandIds: null,
+        majorOption: [],
+      },
+      selectedBrandIds: [],
+      brandOptions: [],  // 机型系列选项列表
       // 遮罩层
       loading: true,
       // 选中数组
@@ -238,7 +300,79 @@ export default {
     this.getList();
   },
   methods: {
+    // 生成报告
+    submitGenerateReport() {
+      if (!this.report.reportDate && !this.report.major && !this.report.brandIds) {
+        this.$message({
+          showClose: true,
+          message: "需要选择故障月份和专业和机型系列",
+          type: "error",
+        });
+        return;
+      }
+      if (!this.report.reportDate) {
+        this.$message({
+          showClose: true,
+          message: "需要选择故障月份",
+          type: "error",
+        });
+        return;
+      }
+      if (!this.report.major) {
+        this.$message({
+          showClose: true,
+          message: "需要选择专业",
+          type: "error",
+        });
+        return;
+      }
+
+      if (!this.report.brandIds) {
+        this.$message({
+          showClose: true,
+          message: "需要选择机型系列",
+          type: "error",
+        });
+        return;
+      }
+
+      generateReport(this.report.reportDate, this.report.major, this.report.brandIds).then(
+        (response) => {
+          console.info("报告返回结果" + response);
+          this.$message({
+            showClose: true,
+            message: response.msg,
+            type: "success",
+          });
+        }
+      );
+      this.report.open = false;
+    },
+    handleBrandChange() {
+      this.report.brandIds = this.selectedBrandIds.join(',');
+    },
+    /** 生成报告按钮操作 */
+    handleGenerateReport() {
+      this.report.title = "生成报告";
 
+      this.report.open = true;
+      this.report.reportDate = null;
+      this.report.major = null;
+      this.report.brandIds = null;
+      this.selectedBrandIds = []; // 清空已选择的机型系列ID
+      this.getBrandOptions();  // 在打开弹框时获取机型系列选项
+      this.report.majorOption = getMajorOption();
+      getMajorOption().then((response) => {
+        this.report.majorOption = response.data;
+      });
+    },
+    /** 获取机型系列选项 */
+    getBrandOptions() {
+      // 假设接口名称是 `listBrandOptions`
+      getListBrand().then(response => {
+        this.brandOptions = response.data;  // 假设返回的数据结构为 {data: [{brandId: 1, brandName: '系列1'}, ...]}
+      });
+    },
     getFailureList() {
       /** 查询故障记录列表 */
       this.loading = true;