loulijun2021
2023-09-18 ac83abeeafb189a84e9f3ea52b57acee979a353c
src/views/systemSetting/dataImport.vue
@@ -23,6 +23,7 @@
        style="margin-left: 20px"
        :disabled="excelCode===''"
        icon="el-icon-download"
        waves
        @click="getExcel"
      >下载模板
      </el-button>
@@ -38,6 +39,7 @@
        style="margin-left: 20px"
        :disabled="excelCode===''"
        icon="el-icon-refresh"
        waves
        @click="reset"
      >重置
      </el-button>
@@ -47,6 +49,7 @@
        style="margin-left: 20px"
        icon="el-icon-circle-plus-outline"
        :disabled="excelCode===''||tableData.length===0"
        waves
        @click="addRow"
      >新增行
      </el-button>
@@ -56,18 +59,10 @@
        style="margin-left: 20px"
        :disabled="excelCode===''||tableData.length===0"
        icon="el-icon-thumb"
        waves
        @click="submit"
      >提交数据
      </el-button>
      <!--      <el-button-->
      <!--        type="danger"-->
      <!--        style="margin-left: 20px"-->
      <!--        :disabled="excelCode===''||tableData.length===0"-->
      <!--        @click="batchDel"-->
      <!--      >批量删除-->
      <!--      </el-button>-->
    </div>
    <div
@@ -75,7 +70,7 @@
      style="margin: 10px"
    >
      <el-tabs type="border-card">
      <el-tabs v-model="activeName" type="border-card" @tab-click="handleTabClick">
        <el-tab-pane
          v-for="(i,j) in sheetName"
          :key="i+j"
@@ -83,7 +78,7 @@
        >
          <el-table
            v-if="tableData[j].length>0"
            :ref="'tableDataRef'+j"
            :ref="'tableDataRef'+i"
            :data="tableData[j]"
            border
            :height="(mainHeight-180)+'px'"
@@ -124,31 +119,22 @@
                    item.indexOf('手机号')!==-1||
                    item.indexOf('邮箱')!==-1||
                    item.indexOf('名称')!==-1||
                    item.indexOf('描述')!==-1
                    item.indexOf('描述')!==-1||
                    item.indexOf('上级编码')!==-1||
                    item.indexOf('类型编码')!==-1||
                    item.indexOf('联系人')!==-1||
                    item.indexOf('联系方式')!==-1||
                    item.indexOf('地址')!==-1
                  "
                >
                  <el-input v-model="row[item]" placeholder="请输入" />
                </div>
                <div v-else-if="item.indexOf('数据范围')!==-1">
                  <el-select
                    v-model="row[item]"
                    placeholder="请选择"
                    filterable
                    clearable
                  >
                    <el-option
                      v-for="item in powerArr"
                      :key="item.code"
                      :label="item.name"
                      :value="item.code"
                    />
                  </el-select>
                </div>
                <div v-else-if="item.indexOf('状态')!==-1">
                  <el-select
                    v-model="row[item]"
                    placeholder="请选择"
                    filterable
                    style="width:100%"
                    clearable
                  >
                    <el-option
@@ -223,33 +209,6 @@
                    :props="defaultProps"
                    :show-all-levels="false"
                  />
                  <!--                  <el-select-->
                  <!--                    v-model="row[item]"-->
                  <!--                    style="width: 100%;"-->
                  <!--                    placeholder="请选择"-->
                  <!--                    filterable-->
                  <!--                    clearable-->
                  <!--                  >-->
                  <!--                    <el-option-->
                  <!--                      v-for="item in orgArr"-->
                  <!--                      :key="item.torg_code"-->
                  <!--                      :label="item.torg_name"-->
                  <!--                      :value="item.torg_code"-->
                  <!--                    />-->
                  <!--                  </el-select>-->
                </div>
                <div v-else-if="item.indexOf('数据权限')!==-1">
                  <el-cascader
                    ref="cascader"
                    v-model="row[item]"
                    :options="orgOptions"
                    filterable
                    collapse-tags
                    :disabled="row['数据范围']!=='CUSTOM'"
                    :props="orgDefaultProps"
                    :show-all-levels="false"
                  />
                </div>
                <div v-else> {{ row[item] }}</div>
              </template>
@@ -285,6 +244,56 @@
      <el-button type="text" style="margin-left: 0;">3.请上传文件提交</el-button>
    </el-empty>
    <el-dialog
      v-el-drag-dialog
      title="失败原因"
      :visible.sync="dialogVisible"
      width="1000px"
      :close-on-click-modal="false"
      top="15vh"
      @closed="handleClose"
      @close="handleClose"
    >
      <div class="">
        <el-table
          ref="tableDataRef"
          class="tableFixed"
          :data="dialogTableData"
          :height="400"
          border
          row-class-name="custom-row"
          :style="{width: 100+'%',height: '400px',}"
          highlight-current-row
          :header-cell-style="this.$headerCellStyle"
          :cell-style="this.$cellStyle"
        >
          <el-table-column
            type="index"
            width="50"
            fixed
            label="序号"
          />
          <el-table-column
            prop="errorField"
            label="错误字段"
            show-overflow-tooltip
          />
          <el-table-column
            prop="errorCont"
            show-overflow-tooltip
            label="错误原因"
          />
        </el-table>
      </div>
      <span slot="footer" class="dialog-footer">
        <div class="footerButton">
          <el-button v-waves @click="dialogVisible=false">返 回</el-button>
          <!--          <el-button v-waves type="primary" @click="dialogVisibleConfirm">确 定</el-button>-->
        </div>
      </span>
    </el-dialog>
  </div>
</template>
@@ -294,10 +303,13 @@
import { GroupsPermissions, PostPermissions, PrentOrganization, RolePermissions } from '@/api/GeneralBasicData'
import { nanoid } from 'nanoid'
import arrayToTree from 'array-to-tree'
import elDragDialog from '@/directive/el-drag-dialog'
import waves from '@/directive/waves'
export default {
  name: 'UploadExcel',
  name: 'DataImport',
  components: { UploadExcelComponent },
  directives: { elDragDialog, waves },
  data() {
    return {
      mainHeight: window.innerHeight - 85,
@@ -328,12 +340,10 @@
      roleArr: [], // 角色
      groupArr: [], // 班组
      powerArr: [
        { code: 'ALL', name: '全部' },
        { code: 'LEVEL', name: '本级' },
        { code: 'PERSON', name: '本人' },
        { code: 'CUSTOM', name: '自定义' }
      ]// 数据范围
      dialogVisible: false,
      dialogTableData: [],
      activeName: '0'// tab选中值
    }
  },
@@ -360,56 +370,378 @@
      }
      this.$message({
        message: 'Please do not upload files larger than 1m in size.',
        message: '请不要上传大于1兆的文件。',
        type: 'warning'
      })
      return false
    },
    // excel成功后的回调
    async handleSuccess({ results, header, sheetName }) {
      if (results[0].length === 0) {
        return this.$message.info('表格数据不能为空!')
      }
      this.tableData = results
      this.tableHeader = header
      this.sheetName = sheetName
      this.activeName = '0'
      // 人员管理导入判断
      if (this.sheetName.indexOf('人员管理') !== -1) {
        this.statusArr = [
          { code: 'Y', name: '在职' },
          { code: 'N', name: '离职' }
        ]
        const postArr = this.postArr.map(i => i.postcode)
        const roleArr = this.roleArr.map(i => i.rolecode)
        const groupArr = this.groupArr.map(i => i.usergroupcode)
        const orgArr = this.orgArr.map(i => i.torg_code)
        this.tableData[this.sheetName.indexOf('人员管理')].forEach(j => {
          // j.所属岗位编码 = typeof j.所属岗位编码 === 'undefined' ? new Set() : j.所属岗位编码.split(',').filter(e => postArr.includes(e))
          // j.所属角色编码 = typeof j.所属角色编码 === 'undefined' ? ''.split(',') : j.所属角色编码.split(',').filter(e => roleArr.includes(e))
          // j.所属班组编码 = typeof j.所属班组编码 === 'undefined' ? ''.split(',') : j.所属班组编码.split(',').filter(e => groupArr.includes(e))
          j.所属岗位编码 = j.所属岗位编码.split(',').filter(e => postArr.includes(e))
          j.所属角色编码 = j.所属角色编码.split(',').filter(e => roleArr.includes(e))
          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()
        })
        console.log(this.tableData[0])
        // console.log(JSON.stringify(this.tableData[0]))
        this.handlePersonListUploadTemplate(true)
      }
      if (this.sheetName.indexOf('角色管理') !== -1) {
      if (this.sheetName.indexOf('角色管理') !== -1 || this.sheetName.indexOf('班组管理') !== -1 ||
        this.sheetName.indexOf('岗位管理') !== -1
      ) {
        this.statusArr = [
          { code: 'Y', name: '停用' },
          { code: 'N', name: '启用' }
          { code: 'Y', name: '正常' },
          { code: 'N', name: '停用' }
        ]
        this.tableData[0].forEach(j => {
          // j.所属岗位编码 = j.所属岗位编码.split(',').filter(e => postArr.includes(e))
          console.log(j['数据权限'], 1) // 级联多选回显  待研究  下次写
          j['数据范围'] = this.powerArr.find(e => e.name === j['数据范围']).code
          j['*状态'] = this.statusArr.find(e => e.name === j['*状态']).code
          j['*状态'] = j['*状态'] ? this.statusArr.find(e => e.name === j['*状态']).code : ''
          j.uuid = nanoid()
        })
      }
      if (this.sheetName.indexOf('往来单位') !== -1) {
        this.statusArr = [
          { code: 'Y', name: '正常' },
          { code: 'N', name: '停用' }
        ]
        this.tableData[0].forEach(j => {
          j.uuid = nanoid()
        })
        this.tableData[1].forEach(j => {
          j['*状态'] = j['*状态'] ? this.statusArr.find(e => e.name === j['*状态']).code : ''
          j.uuid = nanoid()
        })
      }
      // console.log(this.sheetName)
      // console.log(this.tableData)
      // console.log(this.tableHeader)
    },
    // 提交
    submit() {
      this.$confirm('是否确认提交?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
        .then(() => {
          if (this.sheetName.indexOf('人员管理') !== -1) {
            const res = this.handlePersonListSubmitData()
            if (res.code !== '200') {
              return this.$message.info(res.message)
            }
          }
          if (this.sheetName.indexOf('角色管理') !== -1) {
            const res = this.handleRoleListSubmitData()
            if (res.code !== '200') {
              return this.$message.info(res.message)
            }
          }
          if (this.sheetName.indexOf('班组管理') !== -1) {
            const res = this.handleGroupListSubmitData()
            if (res.code !== '200') {
              return this.$message.info(res.message)
            }
          }
          if (this.sheetName.indexOf('岗位管理') !== -1) {
            const res = this.handlePostListSubmitData()
            if (res.code !== '200') {
              return this.$message.info(res.message)
            }
          }
          if (this.sheetName.indexOf('往来单位类型') !== -1 && this.sheetName.indexOf('往来单位') !== -1) {
            const res = this.handleContactUnitListSubmitData()
            if (res.code !== '200') {
              return this.$message.info(res.message)
            }
          }
          const data = {
            fileCode: this.excelCode,
            tableData: this.tableData
          }
          ExcelModelCheck(data).then(res => {
            // 返回的json1、json2、json3   json1为模板校验、json2为数据校验、json3为导入数据库校验(可能会有系统报错产生)
            if (res.json1.code !== '200' && res.json2 === null && res.json3 === null) {
              this.$message.error(res.json1.message)
            }
            if (res.json1.code === '200' && res.json2 !== '200' && res.json3 === null) {
              this.$message.error(res.json2.message)
            }
            if (res.json1.code === '200' && res.json2 === '200' && res.json3 !== '200') {
              this.$message.error(res.json3.message)
            }
            if (res.json1.code === '300' && res.json2.code === '200' && res.json3.code === '300') { // 系统报错
              return this.$message.error(res.json3.message)
            }
            if (res.json1.code === '200' && res.json2.code === '301' && res.json3 === null) {
              this.dialogVisible = true
              this.dialogTableData = res.json2.data
            }
            if (res.json1.code === '200' && res.json2.code === '200' && res.json3.code === '200') {
              this.$notify.success('数据提交成功!')
              this.tableData = []
              this.tableHeader = []
              this.sheetName = []
              this.excelCode = ''
              return
            }
            if (this.sheetName.indexOf('人员管理') !== -1) {
              this.handlePersonListUploadTemplate(false)
            }
          })
        })
        .catch(e => {
          console.log(e)
          this.$notify.info('已取消提交!')
        })
    },
    // 处理人员管理导入模板
    handlePersonListUploadTemplate(isFirstUpload) {
      this.statusArr = [
        { code: 'Y', name: '在职' },
        { code: 'N', name: '离职' }
      ]
      const postArr = this.postArr.map(i => i.postcode)
      const roleArr = this.roleArr.map(i => i.rolecode)
      const groupArr = this.groupArr.map(i => i.usergroupcode)
      const orgArr = this.orgArr.map(i => i.torg_code)
      // this.sheetName.indexOf('人员管理')
      // 第一次提交
      if (isFirstUpload) {
        this.tableData[0].forEach(j => {
          j['所属岗位编码'] = j['所属岗位编码'] ? j['所属岗位编码'].split(',').filter(e => postArr.includes(e)) : []
          j['所属角色编码'] = j['所属角色编码'] ? j['所属角色编码'].split(',').filter(e => roleArr.includes(e)) : []
          j['所属班组编码'] = j['所属班组编码'] ? j['所属班组编码'].split(',').filter(e => groupArr.includes(e)) : []
          j['*所属组织编码'] = j['*所属组织编码'] ? (orgArr.includes(j['*所属组织编码']) ? this.findParent([], j['*所属组织编码'], this.orgOptions).reverse() : '') : ''
          j['*在职状态'] = j['*在职状态'] ? this.statusArr.find(e => e.name === j['*在职状态']).code : 'Y'
          j.uuid = nanoid()
        })
      }
      // 非第一次提交
      if (!isFirstUpload) {
        this.tableData[0].forEach(j => {
          j.所属岗位编码 = typeof j.所属岗位编码 === 'string' ? j.所属岗位编码.split(',').filter(e => postArr.includes(e)) : []
          j.所属角色编码 = typeof j.所属角色编码 === 'string' ? j.所属角色编码.split(',').filter(e => roleArr.includes(e)) : []
          j.所属班组编码 = typeof j.所属班组编码 === 'string' ? j.所属班组编码.split(',').filter(e => groupArr.includes(e)) : []
          j['*所属组织编码'] = this.findParent([], j['*所属组织编码'], this.orgOptions).reverse()
          j.uuid = nanoid()
        })
      }
    },
    // 处理人员管理提交数据
    handlePersonListSubmitData() {
      let flag = true
      let msg = ''
      if ([...new Set(this.tableData[0].map(i => i['*用户编号(唯一)']))].length !== this.tableData[0].length) {
        return this.$message.info('编码不能重复!')
      }
      this.tableData[0].forEach(j => {
        if (!j['*用户编号(唯一)']) {
          flag = false
          msg = '*用户编号(唯一)'
        }
        if (!j['*用户姓名']) {
          flag = false
          msg = '*用户姓名'
        }
        if (!j['*密码']) {
          flag = false
          msg = '*密码'
        }
        if (!j['*在职状态']) {
          flag = false
          msg = '*在职状态'
        }
        if (!j['*所属组织编码']) {
          flag = false
          msg = '*所属组织编码'
        }
      })
      if (!flag) {
        return { code: '301', message: msg + '不能为空!' }
      }
      this.tableData[0].forEach(j => {
        j['所属岗位编码'] = j['所属岗位编码'].join(',')
        j['所属班组编码'] = j['所属班组编码'].join(',')
        j['所属角色编码'] = j['所属角色编码'].join(',')
        j['*所属组织编码'] = j['*所属组织编码'][j['*所属组织编码'].length - 1]
      })
      this.tableData[0].map(item => {
        delete (item.uuid)
      })
      return { code: '200', message: '成功!' }
    },
    // 处理角色管理提交数据
    handleRoleListSubmitData() {
      let flag = true
      let msg = ''
      if ([...new Set(this.tableData[0].map(i => i['*角色编号(唯一)']))].length !== this.tableData[0].length) {
        return this.$message.info('编码不能重复!')
      }
      this.tableData[0].forEach(j => {
        if (!j['*角色编号(唯一)']) {
          flag = false
          msg = '*角色编号(唯一)'
        }
        if (!j['*角色名称']) {
          flag = false
          msg = '*角色名称'
        }
        if (!j['*状态']) {
          flag = false
          msg = '*状态'
        }
      })
      if (!flag) {
        return { code: '301', message: msg + '不能为空!' }
      }
      this.tableData[0].map(item => {
        delete (item.uuid)
      })
      return { code: '200', message: '成功!' }
    },
    // 处理班组管理提交数据
    handleGroupListSubmitData() {
      let flag = true
      let msg = ''
      if ([...new Set(this.tableData[0].map(i => i['*角色编号(唯一)']))].length !== this.tableData[0].length) {
        return this.$message.info('编码不能重复!')
      }
      this.tableData[0].forEach(j => {
        if (!j['*班组编号(唯一)']) {
          flag = false
          msg = '*班组编号(唯一)'
        }
        if (!j['*班组名称']) {
          flag = false
          msg = '*班组名称'
        }
        if (!j['*状态']) {
          flag = false
          msg = '*状态'
        }
      })
      if (!flag) {
        return { code: '301', message: msg + '不能为空!' }
      }
      this.tableData[0].map(item => {
        delete (item.uuid)
      })
      return { code: '200', message: '成功!' }
    },
    // 处理岗位管理提交数据
    handlePostListSubmitData() {
      let flag = true
      let msg = ''
      if ([...new Set(this.tableData[0].map(i => i['*岗位编号(唯一)']))].length !== this.tableData[0].length) {
        return this.$message.info('编码不能重复!')
      }
      this.tableData[0].forEach(j => {
        if (!j['*岗位编号(唯一)']) {
          flag = false
          msg = '*岗位编号(唯一)'
        }
        if (!j['*岗位名称']) {
          flag = false
          msg = '*岗位名称'
        }
        if (!j['*状态']) {
          flag = false
          msg = '*状态'
        }
      })
      if (!flag) {
        return { code: '301', message: msg + '不能为空!' }
      }
      this.tableData[0].map(item => {
        delete (item.uuid)
      })
      return { code: '200', message: '成功!' }
    },
    // 处理往来单位提交数据
    handleContactUnitListSubmitData() {
      let flag = true
      let msg = ''
      if ([...new Set(this.tableData[0].map(i => i['*往来单位类型编号(唯一)']))].length !== this.tableData[0].length) {
        return this.$message.info('往来单位类型编号不能重复!')
      }
      if ([...new Set(this.tableData[1].map(i => i['*往来单位编号(唯一)']))].length !== this.tableData[1].length) {
        return this.$message.info('往来单位编号不能重复!')
      }
      this.tableData[0].forEach(j => {
        if (!j['*往来单位类型编号(唯一)']) {
          flag = false
          msg = '*往来单位类型编号(唯一)不能为空!'
        }
        if (!j['*往来单位类型名称']) {
          flag = false
          msg = '*往来单位类型名称不能为空!'
        }
        if (j['*往来单位类型编号(唯一)'] === j['上级编码']) {
          flag = false
          msg = '*往来单位类型编号(唯一)与上级编码不能相同!'
        }
      })
      this.tableData[1].forEach(j => {
        if (!j['*往来单位编号(唯一)']) {
          flag = false
          msg = '*往来单位编号(唯一)不能为空!'
        }
        if (!j['*往来单位名称']) {
          flag = false
          msg = '*往来单位名称'
        }
        if (!j['*状态']) {
          flag = false
          msg = '*状态不能为空!'
        }
        if (!j['*往来单位类型编码']) {
          flag = false
          msg = '*往来单位类型编码不能为空!'
        }
      })
      if (!flag) {
        return { code: '301', message: msg }
      }
      this.tableData[0].map(item => {
        delete (item.uuid)
      })
      this.tableData[1].map(item => {
        delete (item.uuid)
      })
      return { code: '200', message: '成功!' }
    },
    // 获取模板
    async getExcelModelData() {
@@ -425,105 +757,9 @@
      const res = await DownLoadExcel({ FileCode: this.excelCode })
      window.location.href = res.data
    },
    submit() {
      // console.log(this.excelCode)
      // console.log(JSON.stringify(this.sheetName))
      // console.log(JSON.stringify(this.tableHeader))
      // console.log(JSON.stringify(this.tableData))
      this.$confirm('是否确认提交?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
        .then(() => {
          let flag = true
          let msg = ''
          if (this.sheetName.indexOf('人员管理') !== -1) {
            if ([...new Set(this.tableData[0].map(i => i['*用户编号(唯一)']))].length !== this.tableData[0].length) {
              return this.$message.info('编码不能重复!')
            }
            this.tableData[0].forEach(j => {
              if (!j['*用户编号(唯一)']) {
                flag = false
                msg = '*用户编号(唯一)'
              }
              if (!j['*用户姓名']) {
                flag = false
                msg = '*用户姓名'
              }
              if (!j['*密码']) {
                flag = false
                msg = '*密码'
              }
              if (!j['*在职状态']) {
                flag = false
                msg = '*在职状态'
              }
              if (!j['*所属组织编码']) {
                flag = false
                msg = '*所属组织编码'
              }
            })
            if (!flag) {
              return this.$message.info(msg + '不能为空!')
            }
            this.tableData[0].forEach(j => {
              j.所属岗位编码 = j.所属岗位编码.join(',')
              j.所属班组编码 = j.所属班组编码.join(',')
              j.所属角色编码 = j.所属角色编码.join(',')
              j['*所属组织编码'] = j['*所属组织编码'][j['*所属组织编码'].length - 1]
            })
            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.json1.code === '301' || res.json1.code === '300') {
              if (this.sheetName.indexOf('人员管理') !== -1) {
                const postArr = this.postArr.map(i => i.postcode)
                const roleArr = this.roleArr.map(i => i.rolecode)
                const groupArr = this.groupArr.map(i => i.usergroupcode)
                const orgArr = this.orgArr.map(i => i.torg_code)
                this.tableData[0].forEach(j => {
                  j.所属岗位编码 = j.所属岗位编码.split(',').filter(e => postArr.includes(e))
                  j.所属角色编码 = j.所属角色编码.split(',').filter(e => roleArr.includes(e))
                  j.所属班组编码 = j.所属班组编码.split(',').filter(e => groupArr.includes(e))
                  // j['*在职状态'] = this.statusArr.find(e => e.name === j['*在职状态']).code
                  // j['*所属组织编码'] = j['*所属组织编码'][j['*所属组织编码'].length - 1]
                  j['*所属组织编码'] = this.findParent([], j['*所属组织编码'], this.orgOptions).reverse()
                  j.uuid = nanoid()
                })
              }
              return this.$message.error(res.json1.message)
            }
            if (res.json1.code === '200' && res.json2.code === '200') {
              this.$notify.success('数据提交成功!')
              this.tableData = []
              this.tableHeader = []
              this.sheetName = []
              this.excelCode = ''
            } else {
              this.$notify.success('数据提交失败!')
            }
          })
        })
        .catch(e => {
          console.log(e)
          this.$notify.info('已取消提交!')
        })
    handleClose() {
      this.dialogTableData = []
    },
    // parents:用于返回的数组,childNode:要查询的节点,treeData:json树形数据
    findParent(parents, childNode, treeData) {
@@ -563,18 +799,84 @@
          '所属班组编码': []
        })
      }
      //  角色管理新增行
      if (this.sheetName.indexOf('角色管理') !== -1) {
        this.tableData[0].unshift({
          uuid: nanoid(),
          '*角色编号(唯一)': '',
          '*角色名称': '',
          '*状态': 'Y',
          '描述': ''
        })
      }
      //  班组管理新增行
      if (this.sheetName.indexOf('班组管理') !== -1) {
        this.tableData[0].unshift({
          uuid: nanoid(),
          '*班组编号(唯一)': '',
          '*班组名称': '',
          '*状态': 'Y',
          '描述': ''
        })
      }
      //  岗位管理新增行
      if (this.sheetName.indexOf('岗位管理') !== -1) {
        this.tableData[0].unshift({
          uuid: nanoid(),
          '*岗位编号(唯一)': '',
          '*岗位名称': '',
          '*状态': 'Y',
          '描述': ''
        })
      }
      if (this.sheetName.indexOf('往来单位类型') !== -1 && this.activeName === '0') {
        this.tableData[0].unshift({
          uuid: nanoid(),
          '*往来单位类型编号(唯一)': '',
          '*往来单位类型名称': '',
          '上级编码': ''
        })
      }
      if (this.sheetName.indexOf('往来单位') !== -1 && this.activeName === '1') {
        this.tableData[1].unshift({
          uuid: nanoid(),
          '*往来单位编号(唯一)': '',
          '*往来单位名称': '',
          '*状态': 'Y',
          '*往来单位类型编码': '',
          '联系人': '',
          '联系方式': '',
          '地址': ''
        })
      }
    },
    delRow(row) {
      // 人员管理删除行
      if (this.sheetName.indexOf('人员管理') !== -1) {
      // 针对单sheet
      if (this.sheetName.length === 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('必须要有一条数据!')
        }
      }
      // 针对两个 sheet
      if (this.sheetName.length === 2) {
        if (this.activeName === '0') {
          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('必须要有一条数据!')
          }
        }
        if (this.activeName === '1') {
          if (this.tableData[1].length > 1) {
            return this.tableData[1].splice(this.tableData[1].findIndex(i => i.uuid === row.uuid), 1)
          } else {
            return this.$message.info('必须要有一条数据!')
          }
        }
      }
    },
    reset() {
      this.tableData = []
      this.tableHeader = []
@@ -658,3 +960,9 @@
}
</script>
<style lang="scss">
::v-deep .el-dialog__body {
  padding: 20px 20px !important;
}
</style>