jiangping
2024-06-07 8a266df75e912cc4ff49bc504db5b6b26f152892
company/src/components/enterprise/importEmployees.vue
@@ -9,13 +9,17 @@
        <el-form class="demo-form-inline">
            <el-form-item label="上传名单" required>
                <div style="width: 100%;display: flex;align-items: center;">
                    <el-button type="primary" @click="clickRef">点击上传</el-button>
                    <el-button type="primary" @click="clickRef" :loading="importing">点击上传</el-button>
                    <el-button type="text" @click="exportTemplate">名单模板.EXCEL</el-button>
                </div>
                <div style="font-size: 14px; color: black;" v-if="fileName">{{fileName}}</div>
            </el-form-item>
        </el-form>
        <input type="file" style="position: fixed; left: 0; top: -50px;" accept=".xlsx" ref="fileExcel" @change="result" />
        <input type="file"   @cancel="importing=false"  style="position: fixed; left: 0; top: -50px;" accept=".xlsx" ref="fileExcel" @change="result" />
      <template  v-slot:footer>
        <el-button type="primary"   :loading="confirming" @click="confirm">确定</el-button>
        <el-button @click="visible=false">返回</el-button>
      </template>
    </GlobalWindow>
</template>
@@ -29,6 +33,8 @@
        components: { GlobalWindow },
        data () {
            return {
      importing:false,
      confirming:false,
                list: [],
                price: 0,
                type: null,
@@ -47,6 +53,8 @@
                this.solutionId = obj.solutionId
                this.list = obj.arr
                this.price = obj.price
      this.importing=false
      this.confirming=false
            },
            // 导出模板
            exportTemplate () {
@@ -58,6 +66,10 @@
                }
            },
            clickRef () {
      if(this.importing){
        return
      }
      this.importing=true
                this.$refs.fileExcel.click()
            },
            result (e) {
@@ -72,16 +84,27 @@
                        })
                        this.addList = res
                        this.fileName = e.target.files[0].name
          this.importing =false
                    })
                    .catch(err => {
          this.importing =false
                        this.$message.error(err)
                        this.fileName = ''
                    })
                    .finally(() => {
          this.importing =false
                        this.$refs.fileExcel.value = null
                    })
            },
            confirm () {
      if(this.addList==null || this.addList.length ==0){
        this.$message.error('导入人员名单为空,请先上传人员名单')
        return;
      }
      if(this.confirming){
        return
      }
      this.confirming = true
                for (let i = 0; i < this.addList.length; i++) {
                    for (let a = 0; a < this.list.length; a++) {
                        if (this.addList[i].idCard === this.list[a].idcardNo) {
@@ -91,10 +114,12 @@
                    }
                }
                this.addList.forEach(item => {
                    item.fee = this.price || ''
        item.fee = this.price
                })
                this.$emit('result', this.addList)
      // this.confirming = false
                this.visible = false
      this.$emit('result', this.addList)
            }
        }
    }