From 8a266df75e912cc4ff49bc504db5b6b26f152892 Mon Sep 17 00:00:00 2001
From: jiangping <jp@doumee.com>
Date: 星期五, 07 六月 2024 17:34:31 +0800
Subject: [PATCH] 提交一把

---
 company/src/components/enterprise/importEmployees.vue |  183 ++++++++++++++++++++++++++-------------------
 1 files changed, 104 insertions(+), 79 deletions(-)

diff --git a/company/src/components/enterprise/importEmployees.vue b/company/src/components/enterprise/importEmployees.vue
index 72e8cb1..c19bb3d 100644
--- a/company/src/components/enterprise/importEmployees.vue
+++ b/company/src/components/enterprise/importEmployees.vue
@@ -9,95 +9,120 @@
         <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>
 
 <script>
-    import BaseOpera from '@/components/base/BaseOpera'
-    import GlobalWindow from '@/components/common/GlobalWindow'
-    import { importExcel } from '@/api/business/member'
-    export default {
-        name: 'importEmployees',
-        extends: BaseOpera,
-        components: { GlobalWindow },
-        data () {
-            return {
-                list: [],
-                price: 0,
-                type: null,
-                solutionId: null,
-                addList: [],
-                fileName: ''
-            }
-        },
-        methods: {
-            open (title, obj) {
-                this.title = title
-                this.addList = []
-                this.fileName = ''
-                this.type = obj.type
-                this.visible = true
-                this.solutionId = obj.solutionId
-                this.list = obj.arr
-                this.price = obj.price
-            },
-            // 瀵煎嚭妯℃澘
-            exportTemplate () {
-                // 鎶曚繚鐢宠
-                if (this.type === 1) {
-                    window.open(process.env.VUE_APP_MEMBER1_URL)
-                } else {
-                    window.open(process.env.VUE_APP_MEMBER_URL)
-                }
-            },
-            clickRef () {
-                this.$refs.fileExcel.click()
-            },
-            result (e) {
-                const data = new FormData()
-                data.append('file', e.target.files[0])
-                data.append('solutionId', this.solutionId)
-                importExcel(data)
-                    .then(res => {
-                        res.forEach(item => {
-                            item.memberName = item.name
-                            item.fee = ''
-                        })
-                        this.addList = res
-                        this.fileName = e.target.files[0].name
-                    })
-                    .catch(err => {
-                        this.$message.error(err)
-                        this.fileName = ''
-                    })
-                    .finally(() => {
-                        this.$refs.fileExcel.value = null
-                    })
-            },
-            confirm () {
-                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) {
-                            this.$message.warning(`[${this.addList[i].name}]鍛樺伐閲嶅`)
-                            return
-                        }
-                    }
-                }
-                this.addList.forEach(item => {
-                    item.fee = this.price || ''
-                })
-                this.$emit('result', this.addList)
-                this.visible = false
-            }
-        }
+import BaseOpera from '@/components/base/BaseOpera'
+import GlobalWindow from '@/components/common/GlobalWindow'
+import { importExcel } from '@/api/business/member'
+export default {
+  name: 'importEmployees',
+  extends: BaseOpera,
+  components: { GlobalWindow },
+  data () {
+    return {
+      importing:false,
+      confirming:false,
+      list: [],
+      price: 0,
+      type: null,
+      solutionId: null,
+      addList: [],
+      fileName: ''
     }
+  },
+  methods: {
+    open (title, obj) {
+      this.title = title
+      this.addList = []
+      this.fileName = ''
+      this.type = obj.type
+      this.visible = true
+      this.solutionId = obj.solutionId
+      this.list = obj.arr
+      this.price = obj.price
+      this.importing=false
+      this.confirming=false
+    },
+    // 瀵煎嚭妯℃澘
+    exportTemplate () {
+      // 鎶曚繚鐢宠
+      if (this.type === 1) {
+        window.open(process.env.VUE_APP_MEMBER1_URL)
+      } else {
+        window.open(process.env.VUE_APP_MEMBER_URL)
+      }
+    },
+    clickRef () {
+      if(this.importing){
+        return
+      }
+      this.importing=true
+      this.$refs.fileExcel.click()
+    },
+    result (e) {
+      const data = new FormData()
+      data.append('file', e.target.files[0])
+      data.append('solutionId', this.solutionId)
+      importExcel(data)
+        .then(res => {
+          res.forEach(item => {
+            item.memberName = item.name
+            item.fee = ''
+          })
+          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) {
+            this.$message.warning(`[${this.addList[i].name}]鍛樺伐閲嶅`)
+            return
+          }
+        }
+      }
+      this.addList.forEach(item => {
+        item.fee = this.price
+      })
+
+      // this.confirming = false
+      this.visible = false
+      this.$emit('result', this.addList)
+    }
+  }
+}
 </script>
 
 <style lang="scss" scoped>

--
Gitblit v1.9.3