From e30795348373e277fe3d27f55ec800c0833e8733 Mon Sep 17 00:00:00 2001
From: loulijun2021 <1694218219@qq.com>
Date: 星期一, 11 九月 2023 10:38:09 +0800
Subject: [PATCH] 1.人员管理导入实现

---
 src/components/UploadExcel/index.vue         |    1 
 src/styles/global.css                        |    5 +
 package.json                                 |    1 
 src/views/basicSettings/organizationList.vue |   30 +++---
 src/views/systemSetting/dataImport.vue       |  150 +++++++++++++++++++++++++++++++------
 src/views/basicSettings/personList.vue       |    3 
 6 files changed, 148 insertions(+), 42 deletions(-)

diff --git a/package.json b/package.json
index 7b65d0d..781bf4c 100644
--- a/package.json
+++ b/package.json
@@ -27,6 +27,7 @@
     "jsonwebtoken": "^9.0.1",
     "lib-flexible": "^0.3.2",
     "lib-flexible-computer": "^1.0.2",
+    "nanoid": "^4.0.2",
     "normalize.css": "7.0.0",
     "nprogress": "0.2.0",
     "path-to-regexp": "2.4.0",
diff --git a/src/components/UploadExcel/index.vue b/src/components/UploadExcel/index.vue
index 5f82c34..0804349 100644
--- a/src/components/UploadExcel/index.vue
+++ b/src/components/UploadExcel/index.vue
@@ -12,6 +12,7 @@
       style="margin-left:16px;"
       :disabled="disabled"
       type="primary"
+      icon="el-icon-upload2"
       @click="handleUpload"
     >
       鏂囦欢涓婁紶
diff --git a/src/styles/global.css b/src/styles/global.css
index 4a09c44..aab4c4a 100644
--- a/src/styles/global.css
+++ b/src/styles/global.css
@@ -63,6 +63,11 @@
   justify-content: flex-end;
 }
 
+.el-button--text{
+  font-size: 14px !important;
+  cursor: pointer !important;
+}
+
 
 /*澶撮儴鎸夐挳缁勬牱寮�*/
 .bodyTopButtonGroup {
diff --git a/src/views/basicSettings/organizationList.vue b/src/views/basicSettings/organizationList.vue
index 76e2b73..d821c74 100644
--- a/src/views/basicSettings/organizationList.vue
+++ b/src/views/basicSettings/organizationList.vue
@@ -131,15 +131,15 @@
         </el-table>
       </div>
       <!--鍒嗛〉-->
-      <pagination
-        :total="total"
-        :page.sync="form.page"
-        :limit.sync="form.rows"
-        align="right"
-        layout="total,prev, pager, next,sizes,jumper"
-        popper-class="select_bottom"
-        @pagination="getSTorgData"
-      />
+      <!--      <pagination-->
+      <!--        :total="total"-->
+      <!--        :page.sync="form.page"-->
+      <!--        :limit.sync="form.rows"-->
+      <!--        align="right"-->
+      <!--        layout="total,prev, pager, next,sizes,jumper"-->
+      <!--        popper-class="select_bottom"-->
+      <!--        @pagination="getSTorgData"-->
+      <!--      />-->
     </div>
 
     <el-dialog
@@ -219,11 +219,11 @@
       tableHeight: 0,
       form: {
         storg_code: '', // 缁勭粐鏋舵瀯缂栫爜
-        storg_name: '', // 缁勭粐鏋舵瀯鍚嶇О
-        prop: 'lm_date', // 鎺掑簭瀛楁
-        order: 'desc', // 鎺掑簭瀛楁
-        page: 1, // 绗嚑椤�
-        rows: 20 // 姣忛〉澶氬皯鏉�
+        storg_name: '' // 缁勭粐鏋舵瀯鍚嶇О
+        // prop: 'lm_date', // 鎺掑簭瀛楁
+        // order: 'desc', // 鎺掑簭瀛楁
+        // page: 1, // 绗嚑椤�
+        // rows: 20 // 姣忛〉澶氬皯鏉�
       },
       total: 10,
       tableData: [],
@@ -431,7 +431,7 @@
     getHeight() {
       this.$nextTick(() => {
         this.mainHeight = window.innerHeight - 85
-        this.tableHeight = this.mainHeight - 200
+        this.tableHeight = this.mainHeight - 137
         this.$refs.tableDataRef.doLayout()
       })
     }
diff --git a/src/views/basicSettings/personList.vue b/src/views/basicSettings/personList.vue
index f7602ea..8ac0cec 100644
--- a/src/views/basicSettings/personList.vue
+++ b/src/views/basicSettings/personList.vue
@@ -37,8 +37,9 @@
         </div>
 
         <div style="width: calc(100% - 300px)">
-          <div class="bodyTopButtonGroup">
+          <div class="bodyTopButtonGroup" style="justify-content: space-between">
             <el-button v-waves type="primary" icon="el-icon-circle-plus-outline" @click="add('add')">鏂板</el-button>
+            <el-button v-waves type="success" icon="el-icon-download" @click="$router.push('./../systemSetting/dataImport?fileCode=3')">瀵煎叆</el-button>
           </div>
 
           <div class="bodyTopFormGroup">
diff --git a/src/views/systemSetting/dataImport.vue b/src/views/systemSetting/dataImport.vue
index 6462bdf..3f6df8b 100644
--- a/src/views/systemSetting/dataImport.vue
+++ b/src/views/systemSetting/dataImport.vue
@@ -1,7 +1,7 @@
 <template>
   <div class="" :style="{height:mainHeight+'px'}">
 
-    <div style="display: flex;margin: 20px 10px;">
+    <div style="display: flex;margin: 20px 10px;align-items: center">
 
       <el-select
         v-model="excelCode"
@@ -22,6 +22,7 @@
         type="primary"
         style="margin-left: 20px"
         :disabled="excelCode===''"
+        icon="el-icon-download"
         @click="getExcel"
       >涓嬭浇妯℃澘
       </el-button>
@@ -36,17 +37,36 @@
         type="info"
         style="margin-left: 20px"
         :disabled="excelCode===''"
+        icon="el-icon-refresh"
         @click="reset"
       >閲嶇疆
       </el-button>
 
       <el-button
-        type="primary"
+        type="warning"
         style="margin-left: 20px"
-        :disabled="excelCode===''"
-        @click="submit"
-      >鎻愪氦
+        icon="el-icon-circle-plus-outline"
+        :disabled="excelCode===''||tableData.length===0"
+        @click="addRow"
+      >鏂板琛�
       </el-button>
+
+      <el-button
+        type="success"
+        style="margin-left: 20px"
+        :disabled="excelCode===''||tableData.length===0"
+        icon="el-icon-thumb"
+        @click="submit"
+      >鎻愪氦鏁版嵁
+      </el-button>
+
+      <!--      <el-button-->
+      <!--        type="danger"-->
+      <!--        style="margin-left: 20px"-->
+      <!--        :disabled="excelCode===''||tableData.length===0"-->
+      <!--        @click="batchDel"-->
+      <!--      >鎵归噺鍒犻櫎-->
+      <!--      </el-button>-->
 
     </div>
 
@@ -61,9 +81,9 @@
           :key="i+j"
           :label="i"
         >
-          <!--          height:(mainHeight-180)+'px',-->
           <el-table
-            ref="tableDataRef"
+            v-if="tableData[j].length>0"
+            :ref="'tableDataRef'+j"
             :data="tableData[j]"
             border
             :height="(mainHeight-180)+'px'"
@@ -73,17 +93,24 @@
             style="overflow-y: scroll;"
             highlight-current-row
           >
-            <!--          <el-table-column-->
-            <!--            type="selection"-->
-            <!--            width="55"-->
-            <!--          />-->
+            <!--            @selection-change="handleSelectionChange"-->
+
+            <!--            <el-table-column-->
+            <!--              type="selection"-->
+            <!--              width="55"-->
+            <!--              fixed-->
+            <!--            />-->
             <el-table-column
-              type="index"
               label="搴忓彿"
               width="55"
               fixed
               align="center"
-            />
+              :render-header="indexRender"
+            >
+              <template slot-scope="scope">
+                {{ scope.$index }}
+              </template>
+            </el-table-column>
 
             <el-table-column
               v-for="item of tableHeader[j]"
@@ -196,22 +223,37 @@
                 <div v-else> {{ row[item] }}</div>
               </template>
             </el-table-column>
+
             <el-table-column
               label="鎿嶄綔"
-              width="120"
+              width="55"
+              :render-header="operationRender"
               fixed="right"
-            />
+            >
+              <template slot-scope="{row}">
+                <div class="operationClass" style="padding-left: 10px">
+                  <el-tooltip v-del-tab-index class="item" effect="dark" content="鍒犻櫎" placement="top">
+                    <i
+                      class="el-icon-delete"
+                      :style="{color:$store.state.settings.theme}"
+                      @click="delRow(row)"
+                    />
+                  </el-tooltip>
+                </div>
+              </template>
+            </el-table-column>
           </el-table>
         </el-tab-pane>
       </el-tabs>
 
     </div>
 
-    <!--    <div v-for="(i,j) in tableHeader" :key="i">-->
-    <!--      <el-table :data="tableData[j]" border highlight-current-row style="width: 100%;margin-top:20px;">-->
-    <!--        <el-table-column v-for="item of tableHeader[j]" :key="item" :prop="item" :label="item" />-->
-    <!--      </el-table>-->
-    <!--    </div>-->
+    <el-empty v-if="tableData.length===0" :image-size="500">
+      <el-button type="text">1.璇烽�夋嫨妯℃澘涓嬭浇</el-button>
+      <el-button type="text" style="margin-left: 0;">2.璇峰~鍐欐ā鏉挎暟鎹�</el-button>
+      <el-button type="text" style="margin-left: 0;">3.璇蜂笂浼犳枃浠舵彁浜�</el-button>
+    </el-empty>
+
   </div>
 </template>
 
@@ -219,6 +261,7 @@
 import UploadExcelComponent from '@/components/UploadExcel/index.vue'
 import { DownLoadExcel, ExcelModelCheck, ExcelModelData } from '@/api/Excel'
 import { GroupsPermissions, PostPermissions, PrentOrganization, RolePermissions } from '@/api/GeneralBasicData'
+import { nanoid } from 'nanoid'
 
 export default {
   name: 'UploadExcel',
@@ -290,12 +333,17 @@
           j.鎵�灞炵彮缁勭紪鐮� = j.鎵�灞炵彮缁勭紪鐮�.split(',').filter(e => groupArr.includes(e))
           j['*鎵�灞炵粍缁囩紪鐮�'] = orgArr.includes(j['*鎵�灞炵粍缁囩紪鐮�']) ? j['*鎵�灞炵粍缁囩紪鐮�'] : ''
           j['*鍦ㄨ亴鐘舵��'] = this.statusArr.find(e => e.name === j['*鍦ㄨ亴鐘舵��']).code
+          j.uuid = nanoid()
         })
       }
     },
     async getExcelModelData() {
       const { data: res } = await ExcelModelData()
       this.excelArr = res
+
+      if (window.location.hash.indexOf('?') !== -1) {
+        this.excelCode = window.location.hash.split('?')[1].split('=')[1]
+      }
     },
     async getExcel() {
       const res = await DownLoadExcel({ FileCode: this.excelCode })
@@ -351,25 +399,62 @@
             j.鎵�灞炵彮缁勭紪鐮� = j.鎵�灞炵彮缁勭紪鐮�.join(',')
             j.鎵�灞炶鑹茬紪鐮� = j.鎵�灞炶鑹茬紪鐮�.join(',')
           })
+
+          this.tableData[0].map(item => {
+            delete (item.uuid)
+          })
         }
+
         const data = {
           fileCode: this.excelCode,
           tableData: this.tableData
         }
         // console.log(JSON.stringify(this.tableData))
         ExcelModelCheck(data).then(res => {
-          if (res.code === '200') {
-            this.$notify.success('鎻愪氦鎴愬姛!')
+          if (res.json1.code === '200' && res.json2.code === '200') {
+            this.$notify.success('鏁版嵁鎻愪氦鎴愬姛!')
             this.tableData = []
             this.tableHeader = []
             this.sheetName = []
             this.excelCode = ''
+          } else {
+
           }
         })
       }).catch(() => {
         this.$notify.info('宸插彇娑堟彁浜わ紒')
       })
     },
+
+    addRow() {
+      // 鐢ㄦ埛娓呭崟鏂板琛�
+      if (this.sheetName.indexOf('鐢ㄦ埛娓呭崟') !== -1) {
+        this.tableData[0].unshift({
+          uuid: nanoid(),
+          '*鐢ㄦ埛缂栧彿(鍞竴)': '',
+          '*鐢ㄦ埛濮撳悕': '',
+          '*瀵嗙爜': '',
+          '*鍦ㄨ亴鐘舵��': 'Y',
+          '鎵嬫満鍙�': '',
+          '閭': '',
+          '*鎵�灞炵粍缁囩紪鐮�': '',
+          '鎵�灞炲矖浣嶇紪鐮�': [],
+          '鎵�灞炶鑹茬紪鐮�': [],
+          '鎵�灞炵彮缁勭紪鐮�': []
+        })
+      }
+    },
+    delRow(row) {
+      // 鐢ㄦ埛娓呭崟鍒犻櫎琛�
+      if (this.sheetName.indexOf('鐢ㄦ埛娓呭崟') !== -1) {
+        if (this.tableData[0].length > 1) {
+          return this.tableData[0].splice(this.tableData[0].findIndex(i => i.uuid === row.uuid), 1)
+        } else {
+          return this.$message.info('蹇呴』瑕佹湁涓�鏉℃暟鎹紒')
+        }
+      }
+    },
+
     reset() {
       this.tableData = []
       this.tableHeader = []
@@ -414,6 +499,9 @@
       } else if (column.label.indexOf('*') === -1 && rowIndex === 0) {
         string = 'background:#00b0f0;'
       }
+      // else if (rowIndex === 0 && columnIndex === 0) {
+      //   string = 'background:red;color:#fff'
+      // }
       return string + 'padding: 5px 0; fontWeight: 500;'
     },
     cellStyle() {
@@ -421,6 +509,16 @@
         padding: '5px 0'
       }
       return option
+    },
+    indexRender(h, { column }) {
+      return [
+        h('span', { style: 'color:#FFF' }, column.label)
+      ]
+    },
+    operationRender(h, { column }) {
+      return [
+        h('span', { style: 'color:#FFF' }, column.label)
+      ]
     },
     addRedStar(h, { column }) {
       if (column.label.indexOf('*') !== -1) { // 蹇呭~瀛楁
@@ -442,10 +540,10 @@
 
 <style scoped lang="scss">
 //::v-deep .el-table__body-wrapper {
-  //overflow-y: auto;
-  //overflow-x: scroll !important;
-  //height: calc(100% - 34px);
-  //width: 100% !important;
+//overflow-y: auto;
+//overflow-x: scroll !important;
+//height: calc(100% - 34px);
+//width: 100% !important;
 //}
 
 </style>

--
Gitblit v1.9.3