Procházet zdrojové kódy

优化批量导入功能,调整代码格式,简化组件结构,修复逻辑错误

chrislee před 1 měsícem
rodič
revize
2e1d01f5fc
1 změnil soubory, kde provedl 7 přidání a 11 odebrání
  1. 7 11
      src/views/modules/tech/project-product.vue

+ 7 - 11
src/views/modules/tech/project-product.vue

@@ -22,11 +22,7 @@
       </el-form>
       <el-table :data="dataList" border v-loading="dataListLoading" ref="multipleTable" style="width: 100%;"
         @selection-change="handleSelectionChange" @select="handleSelect">
-        <el-table-column
-          type="selection"
-          :selectable="checkSelectable"
-          width="55"
-        />
+        <el-table-column type="selection" :selectable="checkSelectable" width="55" />
         <el-table-column label="序号" type="index" width="100" align="center">
         </el-table-column>
         <el-table-column prop="projectName" header-align="center" align="center" min-width="140"
@@ -77,7 +73,7 @@
         <el-button size="small" type="success" @click="submitUpload">开始上传</el-button>
       </el-upload>
     </el-dialog>
-      <el-dialog title="批量导入" :visible.sync="importBatchVisible">
+    <el-dialog title="批量导入" :visible.sync="importBatchVisible">
       <el-upload class="upload-demo" ref="uploadBatch" :on-remove="handleRemoveBatch" action="#" accept="" :limit="1"
         :file-list="fileList" :auto-upload="false" :http-request="handleUploadBatch" v-loading="importBatchLoading">
         <el-button slot="trigger" size="small" type="primary">选取文件</el-button>
@@ -141,9 +137,9 @@ export default {
     templateDownload() {
       location.href = this.$http.adornUrl(`/biz-service/product/template/download?_token=${Vue.cookie.get('token')}`)
     },
-    //批量导入
-    batchImport(){
-      if(this.currentSelection.length == 0){
+    // 批量导入
+    batchImport() {
+      if (this.currentSelection.length === 0) {
         this.$message({
           type: 'error',
           message: '请勾选数据'
@@ -167,7 +163,7 @@ export default {
 
       const formData = new FormData();
       formData.append("importFile", file.file);
-      for(let i=0;i<this.currentSelection.length;i++){
+      for (let i = 0; i < this.currentSelection.length; i++) {
         formData.append(`productTechnologyDataList[${i}].productTechnologyId`, this.currentSelection[i].productTechnologyId);
         formData.append(`productTechnologyDataList[${i}].productName`, this.currentSelection[i].productName);
       }
@@ -204,7 +200,7 @@ export default {
       this.currentSelection = val
     },
     // 处理单选/多选操作(核心逻辑)
-    handleSelect(selection, row){
+    handleSelect(selection, row) {
       // selection: 当前所有选中行数组;row: 当前被操作的行
       const isSelected = selection.includes(row); // 当前行是被选中还是取消选中
       if (isSelected) {