| <template> | 
|   <div> | 
|     <vol-box | 
|       v-model="showDetialBox" | 
|       :lazy="true" | 
|       :height="350" | 
|       :width="600" | 
|       :padding="15" | 
|       title="设备协议信息-导入" | 
|     > | 
|       <upload-excel | 
|         ref="upload_excel" | 
|         :url="url" | 
|         :template="template" | 
|       ></upload-excel> | 
|     </vol-box> | 
|   </div> | 
| </template> | 
|      | 
|     <script> | 
| import VolBox from "@/components/basic/VolBox.vue"; | 
| import UploadExcel from "@/components/basic/UploadExcel.vue"; | 
| export default { | 
|   components: { VolBox, UploadExcel }, | 
|   data() { | 
|     return { | 
|       showDetialBox: false, | 
|       url: "", | 
|       template: { | 
|         url: "", //模板下载路径,如果没有模板路径,则不显示下载模板功能 | 
|         fileName: "设备协议信息导入模板", //下载模板的文件名 | 
|       }, | 
|     }; | 
|   }, | 
|   methods: { | 
|     open() { | 
|       this.template.url = `${this.http.ipAddress}api/DeviceProtocol/DownLoadTemplate`; | 
|       this.url = `${this.http.ipAddress}api/DeviceProtocol/GetImportData`; | 
|       this.showDetialBox = true; | 
|       this.$nextTick(() => { | 
|         this.$refs.upload_excel.upload = this.upload; | 
|         console.log(this.$refs.upload_excel); | 
|       }); | 
|     }, | 
|     upload() { | 
|       console.log("upload"); | 
|       let _url = this.url; | 
|       if (!_url) { | 
|         return this.$Message.error("没有配置好Url"); | 
|       } | 
|   | 
|       if (!this.$refs.upload_excel.file) { | 
|         return this.$Message.error("请选择文件"); | 
|       } | 
|       var formData = new FormData(); | 
|       formData.append("fileInput", this.$refs.upload_excel.file); | 
|       if (!this.$refs.upload_excel.importExcelBefore(formData)) { | 
|         return; | 
|       } | 
|       this.$refs.upload_excel.loadingStatus = true; | 
|       this.http.post(_url, formData).then( | 
|         (x) => { | 
|           // this.$refs.uploadFile.clearFiles(); | 
|           this.$refs.upload_excel.loadingStatus = false; | 
|           this.$refs.upload_excel.file = null; | 
|           if (x.status) { | 
|             this.$emit("parentCall", ($vue) => { | 
|               $vue.$refs.detail.rowData.push(...x.data); | 
|             }); | 
|           } | 
|   | 
|           this.message = x.message; | 
|           this.resultClass = x.status ? "v-r-success" : "v-r-error"; | 
|         }, | 
|         (error) => { | 
|           this.$refs.upload_excel.loadingStatus = false; | 
|         } | 
|       ); | 
|     }, | 
|   }, | 
|   created() {}, | 
| }; | 
| </script> | 
|      | 
|     <style scoped> | 
| .el-col { | 
|   border-radius: 4px; | 
| } | 
| .grid-content { | 
|   border-radius: 4px; | 
|   min-height: 36px; | 
| } | 
| .content-text { | 
|   display: flex; | 
|   align-items: center; | 
|   justify-content: center; | 
| } | 
| .left-text { | 
|   display: flex; | 
|   align-items: center; | 
|   justify-content: flex-start; | 
| } | 
| </style> | 
|     <style> | 
| .el-table .warning-row { | 
|   background: #fcf1e2; | 
| } | 
|   | 
| .el-table .success-row { | 
|   background: #f0f9eb; | 
| } | 
|   | 
| .el-table .error-row { | 
|   background: #fde2e2; | 
| } | 
| </style> |