Pārlūkot izejas kodu

增加导入功能

twzydn20000928 2 gadi atpakaļ
vecāks
revīzija
e797810575

+ 7 - 3
src/views/extract/info/buildFlow.vue

@@ -2,10 +2,11 @@
   <div :loading="loading">
     <el-form ref="form" :model="form" :rules="rules" label-width="80px">
       <el-form-item label="故障名称" prop="errorAppearance">
-        <el-input v-model="form.errorAppearance" placeholder="请输入故障名称"/>
+        <el-input v-model="form.errorAppearance" placeholder="请输入故障名称" :readonly="readonly"/>
       </el-form-item>
       <el-form-item label="排故流程" prop="flowEncode">
         <el-input
+          :readonly="readonly"
           v-model="form.flowEncode"
           type="textarea"
           placeholder="请输入排故流程"
@@ -52,7 +53,9 @@ export default {
     getResult(){
       this.loading = true
       getFlow(this.subTask.id).then(response => {
-        this.form = response.data
+        if(response.data){
+          this.form = response.data
+        }
         this.loading = false
       });
     },
@@ -66,14 +69,15 @@ export default {
             updateFlow(this.form).then((response) => {
               this.$modal.msgSuccess("修改成功");
               this.open = false;
+              this.$emit("closeInfo");
             });
           } else {
             addFlow(this.form).then((response) => {
               this.$modal.msgSuccess("新增成功");
               this.open = false;
+              this.$emit("closeInfo");
             });
           }
-          this.$emit("closeInfo");
         }
       });
     },

+ 3 - 22
src/views/showInfo/breakdown/index.vue

@@ -97,9 +97,8 @@
           icon="el-icon-upload2"
           size="mini"
           @click="handleImport"
-          v-hasPermi="['showInfo:vehicle:add']"
-          >导入</el-button
-        >
+          v-hasPermi="['showInfo:breakdown:add']"
+          >导入</el-button>
       </el-col>
       <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
     </el-row>
@@ -302,27 +301,9 @@
             placeholder="请选择修复日期">
           </el-date-picker>
         </el-form-item>
+        
           </el-col>
         </el-row>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
       </el-form>
       <div slot="footer" class="dialog-footer">
         <el-button type="primary" @click="submitForm">确 定</el-button>

+ 105 - 3
src/views/suport/flow/index.vue

@@ -58,12 +58,21 @@
           v-hasPermi="['suport:flow:export']"
         >导出</el-button>
       </el-col>
+      <el-col :span="1.5">
+        <el-button
+          type="primary"
+          plain
+          icon="el-icon-upload2"
+          size="mini"
+          @click="handleImport"
+          v-hasPermi="['suport:flow:add']"
+          >导入</el-button>
+      </el-col>
       <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
     </el-row>
 
     <el-table v-loading="loading" :data="flowList" @selection-change="handleSelectionChange">
       <el-table-column type="selection" width="55" align="center" />
-      <el-table-column label="序号" align="center" prop="id" />
       <el-table-column label="故障名称" align="center" prop="errorAppearance" />
       <el-table-column label="流程数据" align="center" prop="flowEncode" />
       <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
@@ -109,11 +118,54 @@
         <el-button @click="cancel">取 消</el-button>
       </div>
     </el-dialog>
+
+    <!-- 导入故障 -->
+    <el-dialog
+      :title="upload.title"
+      :visible.sync="upload.open"
+      width="400px"
+      append-to-body
+      :close-on-click-modal="false"
+    >
+      <el-upload
+        ref="upload"
+        :limit="1"
+        accept=".xlsx, .xls"
+        :headers="upload.headers"
+        :action="upload.url + '?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>
+        <div class="el-upload__tip text-center" slot="tip">
+          <div class="el-upload__tip" slot="tip">
+            <el-checkbox v-model="upload.updateSupport" /> 是否更新已经存在的数据
+          </div>
+          <span>仅允许导入xls、xlsx格式文件。</span>
+          <el-link
+            type="primary"
+            :underline="false"
+            style="font-size: 12px; vertical-align: baseline"
+            @click="importTemplate"
+            >下载模板</el-link
+          >
+        </div>
+      </el-upload>
+      <div slot="footer" class="dialog-footer">
+        <el-button type="primary" @click="submitFileForm">确 定</el-button>
+        <el-button @click="upload.open = false">取 消</el-button>
+      </div>
+    </el-dialog>
   </div>
 </template>
 
 <script>
 import { listFlow, getFlow, delFlow, addFlow, updateFlow } from "@/api/suport/flow";
+import { getToken } from "@/utils/auth";
 
 export default {
   name: "Flow",
@@ -149,7 +201,21 @@ export default {
       form: {},
       // 表单校验
       rules: {
-      }
+      },
+      upload: {
+        // 是否显示弹出层
+        open: false,
+        // 弹出层标题
+        title: "",
+        // 是否禁用上传
+        isUploading: false,
+        // 是否更新已经存在的用户数据
+        updateSupport: 0,
+        // 设置上传的请求头部
+        headers: { Authorization: "Bearer " + getToken() },
+        // 上传的地址
+        url: process.env.VUE_APP_BASE_API + "/suport/flow/importData",
+      },
     };
   },
   created() {
@@ -254,7 +320,43 @@ export default {
       this.download('suport/flow/export', {
         ...this.queryParams
       }, `flow_${new Date().getTime()}.xlsx`)
-    }
+    },
+
+    /** 导入按钮操作 */
+    handleImport() {
+      this.upload.title = "排故流程";
+      this.upload.open = true;
+    },
+    /** 下载模板操作 */
+    importTemplate() {
+      this.download(
+        "suport/flow/importTemplate",
+        {},
+        `排故流程导入模板.xlsx`
+      );
+    },
+    // 文件上传中处理
+    handleFileUploadProgress(event, file, fileList) {
+      this.upload.isUploading = true;
+    },
+    // 文件上传成功处理
+    handleFileSuccess(response, file, fileList) {
+      this.upload.open = false;
+      this.upload.isUploading = false;
+      this.$refs.upload.clearFiles();
+      this.$alert(
+        "<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" +
+          response.msg +
+          "</div>",
+        "导入结果",
+        { dangerouslyUseHTMLString: true }
+      );
+      this.getList();
+    },
+    // 提交上传文件
+    submitFileForm() {
+      this.$refs.upload.submit();
+    },
   }
 };
 </script>

+ 105 - 3
src/views/suport/piont/index.vue

@@ -58,12 +58,21 @@
           v-hasPermi="['suport:piont:export']"
         >导出</el-button>
       </el-col>
+      <el-col :span="1.5">
+        <el-button
+          type="primary"
+          plain
+          icon="el-icon-upload2"
+          size="mini"
+          @click="handleImport"
+          v-hasPermi="['suport:piont:add']"
+          >导入</el-button>
+      </el-col>
       <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
     </el-row>
 
     <el-table v-loading="loading" :data="piontList" @selection-change="handleSelectionChange">
       <el-table-column type="selection" width="55" align="center" />
-      <el-table-column label="序号" align="center" prop="id" />
       <el-table-column label="编码" align="center" prop="code" />
       <el-table-column label="检查点" align="center" prop="checkPiont" />
       <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
@@ -109,11 +118,54 @@
         <el-button @click="cancel">取 消</el-button>
       </div>
     </el-dialog>
+
+    <!-- 导入检查点 -->
+    <el-dialog
+      :title="upload.title"
+      :visible.sync="upload.open"
+      width="400px"
+      append-to-body
+      :close-on-click-modal="false"
+    >
+      <el-upload
+        ref="upload"
+        :limit="1"
+        accept=".xlsx, .xls"
+        :headers="upload.headers"
+        :action="upload.url + '?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>
+        <div class="el-upload__tip text-center" slot="tip">
+          <div class="el-upload__tip" slot="tip">
+            <el-checkbox v-model="upload.updateSupport" /> 是否更新已经存在的数据
+          </div>
+          <span>仅允许导入xls、xlsx格式文件。</span>
+          <el-link
+            type="primary"
+            :underline="false"
+            style="font-size: 12px; vertical-align: baseline"
+            @click="importTemplate"
+            >下载模板</el-link
+          >
+        </div>
+      </el-upload>
+      <div slot="footer" class="dialog-footer">
+        <el-button type="primary" @click="submitFileForm">确 定</el-button>
+        <el-button @click="upload.open = false">取 消</el-button>
+      </div>
+    </el-dialog>
   </div>
 </template>
 
 <script>
 import { listPiont, getPiont, delPiont, addPiont, updatePiont } from "@/api/suport/piont";
+import { getToken } from "@/utils/auth";
 
 export default {
   name: "Piont",
@@ -148,7 +200,21 @@ export default {
       form: {},
       // 表单校验
       rules: {
-      }
+      },
+      upload: {
+        // 是否显示弹出层
+        open: false,
+        // 弹出层标题
+        title: "",
+        // 是否禁用上传
+        isUploading: false,
+        // 是否更新已经存在的用户数据
+        updateSupport: 0,
+        // 设置上传的请求头部
+        headers: { Authorization: "Bearer " + getToken() },
+        // 上传的地址
+        url: process.env.VUE_APP_BASE_API + "/suport/piont/importData",
+      },
     };
   },
   created() {
@@ -249,7 +315,43 @@ export default {
       this.download('suport/piont/export', {
         ...this.queryParams
       }, `piont_${new Date().getTime()}.xlsx`)
-    }
+    },
+
+    /** 导入按钮操作 */
+    handleImport() {
+      this.upload.title = "检查点管理";
+      this.upload.open = true;
+    },
+    /** 下载模板操作 */
+    importTemplate() {
+      this.download(
+        "suport/piont/importTemplate",
+        {},
+        `检查点管理导入模板.xlsx`
+      );
+    },
+    // 文件上传中处理
+    handleFileUploadProgress(event, file, fileList) {
+      this.upload.isUploading = true;
+    },
+    // 文件上传成功处理
+    handleFileSuccess(response, file, fileList) {
+      this.upload.open = false;
+      this.upload.isUploading = false;
+      this.$refs.upload.clearFiles();
+      this.$alert(
+        "<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" +
+          response.msg +
+          "</div>",
+        "导入结果",
+        { dangerouslyUseHTMLString: true }
+      );
+      this.getList();
+    },
+    // 提交上传文件
+    submitFileForm() {
+      this.$refs.upload.submit();
+    },
   }
 };
 </script>