<template>
  <div class="app-container">
    <el-row>
      <el-col :span="6">
        <el-card>
          <el-button type="primary" icon="el-icon-circle-plus-outline" size="small" @click="handleAdd('department_Form')">新增</el-button>
          <el-button type="warning" icon="el-icon-edit" size="small" @click="handleEdit()">编辑</el-button>
          <el-button type="danger" icon="el-icon-delete" size="small" @click="deleteTable()">删除</el-button>
        </el-card>
      </el-col>
      <el-col :span="18">
        <el-card>
          <span>人员名称:</span>
          <el-input v-model="Name" placeholder="请输入人员名称" class="input-with-select" size="small" style="width: 200px; margin-right: 15px" clearable>
            <el-button slot="append" icon="el-icon-search" @click="fetchPeopleForName"/>
          </el-input>
          <el-button type="primary" icon="el-icon-circle-plus-outline" size="small" @click="addPeople()">新增</el-button>
          <el-button type="danger" icon="el-icon-circle-close-outline" size="small" @click="Quit()">离职</el-button>
          <el-button type="text" size="small" style="float: right" @click="searchLeavingList">离职名单</el-button>
          <el-button v-popover:popover4 :disabled="disabledMove" type="success" icon="el-icon-sort" size="small" @click="moveGroup">移动
          </el-button>
          <!--<el-button size="small" @click="postMaintain()">岗位维护</el-button>-->
          <el-popover
            ref="popover4"
            width="178"
            placement="right"
            trigger="click"
            @hide="hide()">
            <el-dropdown size="small" placement="bottom-start" style="margin-right: 0">
              <el-input
                v-model="nodeName1"
                :disabled="true"
                size="small"
                placeholder="请选择部门"/>
              <el-button type="text" size="small" style="margin-left: 60px; margin-top: 15px" @click="moveGroupConfim">
                确认
              </el-button>
              <el-dropdown-menu slot="dropdown">
                <el-tree
                  ref="treeForm"
                  :data="departmentData"
                  :props="defaultProps"
                  style="width: 150px"
                  node-key="id"
                  accordion
                  @node-click="NodeClick"/>
              </el-dropdown-menu>
            </el-dropdown>
          </el-popover>
        </el-card>
      </el-col>
    </el-row>

    <el-row>
      <el-col :span="6">
        <el-card class="box-card" style="min-height: 700px; max-height: 743px">
          <div slot="header" class="clearfix">
            <span>部门维护</span>
            <el-button style="float: right; padding: 3px 0" type="text" @click="expandALL()">展开</el-button>
          </div>
          <div style="height: 650px">
            <el-tree
              ref="treeForm"
              :data="departmentData"
              :props="defaultProps"
              show-checkbox
              node-key="id"
              check-strictly
              default-expand-all
              @check-change="handleClick"/>
          </div>
        </el-card>
      </el-col>
      <el-col :span="18">
        <el-card>
          <el-table
            ref="multipleTable"
            :data="List"
            stripe
            tooltip-effect="dark"
            style="width: 100%"
            height="659"
            highlight-current-row
            border
            size="mini"
            @selection-change="handleSelectionChange">
            <el-table-column
              type="selection"
              width="55"/>
            <el-table-column align="center" label="部门名称" width="100">
              <template slot-scope="scope">
                {{ scope.row.节点名称 }}
              </template>
            </el-table-column>
            <el-table-column align="center" label="考勤编号" width="100">
              <template slot-scope="scope">
                {{ scope.row.考勤编号 }}
              </template>
            </el-table-column>
            <el-table-column align="center" label="密码" width="100">
              <template slot-scope="scope">
                {{ scope.row.密码 }}
              </template>
            </el-table-column>
            <el-table-column align="center" label="姓名" width="100">
              <template slot-scope="scope">
                {{ scope.row.姓名 }}
              </template>
            </el-table-column>
            <el-table-column align="center" label="性别" width="100">
              <template slot-scope="scope">
                {{ scope.row.性别 }}
              </template>
            </el-table-column>
            <el-table-column align="center" label="身份证号" width="165">
              <template slot-scope="scope">
                {{ scope.row.身份证号 }}
              </template>
            </el-table-column>
            <el-table-column align="center" label="学历" width="100">
              <template slot-scope="scope">
                {{ scope.row.学历名称 }}
              </template>
            </el-table-column>
            <el-table-column align="center" label="入职时间" width="100">
              <template slot-scope="scope">
                {{ scope.row.入公司时间 !== '' && scope.row.入公司时间 !== null ? scope.row.入公司时间 = scope.row.入公司时间.split(' ')[0]: scope.row.入公司时间 }}
              </template>
            </el-table-column>
            <el-table-column align="center" label="出生日期" width="100">
              <template slot-scope="scope">
                {{ scope.row.出生日期 !== '' && scope.row.出生日期 !== null ? scope.row.出生日期 = scope.row.出生日期.split(' ')[0]: scope.row.出生日期 }}
              </template>
            </el-table-column>
            <el-table-column align="center" label="联系方式" width="110">
              <template slot-scope="scope">
                {{ scope.row.联系电话 }}
              </template>
            </el-table-column>
            <el-table-column align="center" label="岗位工种" width="100">
              <template slot-scope="scope">
                {{ scope.row.岗位名称 }}
              </template>
            </el-table-column>
            <el-table-column align="center" label="民族" width="100">
              <template slot-scope="scope">
                {{ scope.row.民族 }}
              </template>
            </el-table-column>
            <el-table-column align="center" label="家庭住址" width="200">
              <template slot-scope="scope">
                {{ scope.row.家庭住址 }}
              </template>
            </el-table-column>
            <el-table-column label="操作" fixed="right" align="center" width="300">
              <template slot-scope="scope">
                <el-button
                  size="mini"
                  type="primary"
                  icon="el-icon-picture"
                  @click="handlePicture(scope.row)">上传图片</el-button>
                <el-button
                  size="mini"
                  type="primary"
                  icon="el-icon-edit"
                  @click="handleEditPeople(scope.row)">编辑</el-button>
                <el-button
                  size="mini"
                  type="danger"
                  icon="el-icon-delete"
                  @click="deletePeopleTable(scope.row)">删除</el-button>
              </template>
            </el-table-column>
          </el-table>
          <div class="block" style="margin-top: 10px;">
            <el-pagination
              :current-page="PageCurrent"
              :page-sizes="[10, 20, 30, 40, 50]"
              :page-size="PageSize"
              :total="total"
              layout="total, sizes, prev, pager, next, jumper"
              @size-change="handleSizeChange"
              @current-change="handleCurrentChange"/>
          </div>
        </el-card>
      </el-col>
    </el-row>

    <!--新增和编辑部门-->
    <el-dialog :title="department_Title" :visible.sync="department_DFV" center style="min-height: 200px" width="400px">
      <el-form ref="department_Form" :model="department_Form" :rules="rules" label-position="left" label-width="110px" class="demo-ruleForm">
        <el-form-item label="部门名称" prop="DepartmentName">
          <el-input v-model="department_Form.DepartmentName" size="small" style="width:200px"/>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="cancel">取消</el-button>
        <el-button v-if="department_Title==='新增部门'" type="primary" @click="submitAdd('department_Form')">确定</el-button>
        <el-button v-else-if="department_Title==='编辑部门'" type="primary" @click="submitEdit('department_Form')">确定</el-button>
      </div>
    </el-dialog>

    <el-dialog :title="people_title" :visible.sync="people_DFV" center style="min-height: 200px" width="800px">
      <el-form ref="people_form" :rules="rules" :model="people_form" label-position="left" label-width="110px" class="demo-ruleForm">
        <el-row>
          <el-col :span="12">
            <el-form-item label="考勤编号" prop="AccountNumber">
              <el-input v-model="people_form.AccountNumber" size="small" style="width:200px"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="密码" prop="Password">
              <el-input v-model="people_form.Password" size="small" style="width:200px"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="姓名" prop="Name">
              <el-input v-model="people_form.Name" size="small" style="width:200px"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="性别" prop="Sex">
              <el-select v-model="people_form.Sex" clearable placeholder="请选择性别" style="width: 200px" size="small">
                <el-option
                  v-for="item in SexData"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"/>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="出生日期" prop="Birthday">
              <el-date-picker
                v-model="people_form.Birthday"
                style="width: 200px"
                value-format="yyyy-MM-dd"
                size="small"
                type="date"
                placeholder="请选择出生日期"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="身份证号" prop="IDcard">
              <el-input v-model="people_form.IDcard" size="small" style="width:200px"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="入职时间" prop="TimeOfEntry">
              <el-date-picker
                v-model="people_form.TimeOfEntry"
                style="width: 200px"
                value-format="yyyy-MM-dd"
                size="small"
                type="date"
                placeholder="请选择入职时间"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="联系方式" prop="ContactInformation">
              <el-input v-model="people_form.ContactInformation" size="small" style="width:200px"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="学历" prop="Education">
              <el-select v-model="people_form.Education" clearable placeholder="请选择学历" style="width: 200px" size="small">
                <el-option
                  v-for="item in EducationDate"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"/>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="家庭住址" prop="Address">
              <el-input v-model="people_form.Address" size="small" style="width:200px"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="民族" prop="Nation">
              <el-input v-model="people_form.Nation" size="small" style="width:200px"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="岗位" prop="Post">
              <el-select v-model="people_form.Post" clearable placeholder="请选择岗位" style="width: 200px" size="small">
                <el-option
                  v-for="item in PostData"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"/>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button :loading="btnLoading" @click="cancel">取消</el-button>
        <el-button v-if="people_title === '新增人员'" :loading="btnLoading" type="primary" @click="submitAddPeople">确定</el-button>
        <el-button v-else-if="people_title === '编辑人员'" :loading="btnLoading" type="primary" @click="submitEditPeople">确定</el-button>
      </div>
    </el-dialog>

    <!--离职名单-->
    <el-dialog :visible.sync="LeavingListVisiable" title="离职名单" center style="height: 800px" width="80%">
      <el-table
        :data="LeavingList"
        stripe
        tooltip-effect="dark"
        style="width: 100%"
        height="500"
        highlight-current-row
        border
        size="mini">
        <el-table-column align="center" label="部门名称" width="100">
          <template slot-scope="scope">
            {{ scope.row.节点名称 }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="考勤编号" width="100">
          <template slot-scope="scope">
            {{ scope.row.考勤编号 }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="密码" width="100">
          <template slot-scope="scope">
            {{ scope.row.密码 }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="姓名" width="100">
          <template slot-scope="scope">
            {{ scope.row.姓名 }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="性别" width="100">
          <template slot-scope="scope">
            {{ scope.row.性别 }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="身份证号" width="165">
          <template slot-scope="scope">
            {{ scope.row.身份证号 }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="学历" width="100">
          <template slot-scope="scope">
            {{ scope.row.学历名称 }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="入职时间" width="100">
          <template slot-scope="scope">
            {{ scope.row.入公司时间 !== '' && scope.row.入公司时间 !== null ? scope.row.入公司时间 = scope.row.入公司时间.split(' ')[0]: scope.row.入公司时间 }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="出生日期" width="100">
          <template slot-scope="scope">
            {{ scope.row.出生日期 !== '' && scope.row.出生日期 !== null ? scope.row.出生日期 = scope.row.出生日期.split(' ')[0]: scope.row.出生日期 }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="联系方式" width="110">
          <template slot-scope="scope">
            {{ scope.row.联系电话 }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="岗位工种" width="100">
          <template slot-scope="scope">
            {{ scope.row.岗位名称 }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="民族" width="100">
          <template slot-scope="scope">
            {{ scope.row.民族 }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="家庭住址">
          <template slot-scope="scope">
            {{ scope.row.家庭住址 }}
          </template>
        </el-table-column>
      </el-table>
      <div class="block" style="margin-top: 10px;">
        <el-pagination
          :current-page="PageCurrentN"
          :page-sizes="[10, 20, 30, 40]"
          :page-size="PageSizeN"
          :total="totalN"
          layout="total, sizes, prev, pager, next, jumper"
          @size-change="handleSizeChangeN"
          @current-change="handleCurrentChangeN"/>
      </div>
    </el-dialog>
    <el-dialog :visible.sync="dialogFormVisible" title="上传图片" center style="height: 800px" width="30%">
      <el-upload
        id="invoiceScan"
        ref="upload"
        :multiple="true"
        :auto-upload="false"
        :on-success="uploadSuccess"
        :before-upload="beforeUpload"
        :on-exceed="warningExceed"
        :limit="limit"
        :action="upload+'?num='+ PersonId"
        list-type="picture-card">
        <i class="el-icon-plus"/>
      </el-upload>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogFormVisible=false">取消</el-button>
        <el-button type="primary" style="width: 70px" @click="submitPerson()">确定</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { moveGroups, getTree, tree, getTablePeople, getTablePeopleForName, addDepartmentName, delList, editList, delPeopleList, fetchEducationData, fetchPostData, addPeople, editPeople, quit, searchLeavingList } from '@/api/BasicData/PersonnelManagement'
import { uploadPerson } from '@/utils/request'
export default {
  data() {
    return {
      disabledMove: true,
      PageCurrentN: 1,
      PageSizeN: 10,
      totalN: null,
      LeavingList: [],
      LeavingListVisiable: false,
      departmentData: [],
      expandAll: true,
      i: 1,
      id: '',
      PageCurrent: 1,
      PageSize: 50,
      List: [],
      total: null,
      nodeName: '',
      btnLoading: false,
      department_DFV: false,
      upload: uploadPerson,
      dialogFormVisible: false,
      PersonId: '',
      department_Form: {
        DepartmentName: ''
      },
      department_Title: '',
      Name: '',
      people_title: '',
      people_DFV: false,
      defaultProps: {
        children: 'children',
        label: 'label'
      },
      people_form: {
        Name: '',
        AccountNumber: '',
        Password: '',
        Sex: null,
        Birthday: '',
        IDcard: '',
        TimeOfEntry: '',
        ContactInformation: '',
        Address: null,
        Nation: '',
        ForeignLanguageLevel: null,
        Title: null,
        PositionStatus: null,
        Education: null,
        Post: null,
        PeopleID: null
      },
      rules: {
        Name: [{ required: true, message: '请输入', trigger: 'blur' }],
        AccountNumber: [{ required: true, message: '请输入', trigger: 'blur' }],
        Password: [{ required: true, message: '请输入', trigger: 'blur' }],
        Sex: [{ required: true, message: '请输入', trigger: 'change' }],
        Birthday: [{ required: true, message: '请输入', trigger: 'change' }],
        IDcard: [{ required: true, message: '请输入', trigger: 'blur' }],
        TimeOfEntry: [{ required: true, message: '请输入', trigger: 'change' }],
        ContactInformation: [{ required: true, message: '请输入', trigger: 'blur' }],
        Address: [{ required: true, message: '请输入', trigger: 'change' }],
        Nation: [{ required: true, message: '请输入', trigger: 'change' }],
        ForeignLanguageLevel: [{ required: true, message: '请输入', trigger: 'change' }],
        Title: [{ required: true, message: '请输入', trigger: 'change' }],
        PositionStatus: [{ required: true, message: '请输入', trigger: 'change' }],
        Education: [{ required: true, message: '请输入', trigger: 'change' }],
        Post: [{ required: true, message: '请输入', trigger: 'change' }],
        DepartmentName: [{ required: true, message: '请输入', trigger: 'blur' }]
      },
      SexData: [{
        value: 1,
        label: '男'
      }, {
        value: 2,
        label: '女'
      }],
      EducationDate: [],
      PostData: [],
      multipleSelection: [],
      nodeName1: '',
      count1: 0,
      count2: 0
    }
  },
  created() {
    this.getTreeData()
    this.fetchEducationData()
    this.fetchPostData()
  },
  methods: {
    fetchEducationData() {
      this.getSelect(fetchEducationData, ['学历名称', '学历编号'], 'EducationDate')
    },
    fetchPostData() {
      this.people_form.Post = ''
      this.PostData = []
      this.getSelect(fetchPostData, ['岗位名称', '岗位编号'], 'PostData')
    },
    getTreeData() {
      getTree().then(response => {
        const data = response.data
        this.departmentData = tree(data, 0)
      })
    },
    expandALL() {
      this.expandAll = !this.expandAll
      for (let i = 0; i < this.$refs.treeForm.store._getAllNodes().length; i++) {
        this.$refs.treeForm.store._getAllNodes()[i].expanded = this.expandAll
      }
    },
    handleNodeClick() {
      this.getTable(getTablePeople, [this.id, this.PageCurrent, this.PageSize], ['List', 'total'])
    },
    handleClick(data, checked) {
      if (this.$refs.treeForm.getCheckedKeys().length !== 0 && this.$refs.treeForm.getCheckedNodes().length !== 0) {
        const data = this.$refs.treeForm.getCheckedKeys()
        if (data.length === 1) {
          this.id = data[0]
          this.handleNodeClick()
        }
        this.nodeName = this.$refs.treeForm.getCheckedNodes()[0].label
      } else {
        this.id = ''
        this.handleNodeClick()
      }
      this.i++
      if (this.i % 2 === 1) {
        if (checked) {
          this.$refs.treeForm.setCheckedNodes([data])
        } else {
          this.$refs.treeForm.setCheckedNodes([])
        }
      }
    },
    uploadSuccess(res) { // 上传成功回调
      if (res[0].result === '1') {
        this.$message.success('增加成功')
        this.dialogFormVisible = false
        this.$refs.upload.clearFiles()
      } else {
        this.$message.error('增加失败')
      }
    },
    beforeUpload(file) { // 上传前检测
      const isJPG = /^image\/.*/.test(file.type)
      if (!isJPG) {
        this.$message.error('只能上传图片。。')
      }
      return isJPG
    },
    warningExceed() {
      this.$message.error('仅可上传五张照片')
    },
    handlePicture(row) {
      this.dialogFormVisible = true
      this.PersonId = row.人员编号
    },
    submitPerson() {
      this.$refs.upload.submit()
    },
    handleAdd(formName) {
      this.department_Title = '新增部门'
      this.department_DFV = true
      this.department_Form.DepartmentName = ''
      this.count1 = this.count1 + 1
      if (this.count1 !== 1) {
        this.$refs[formName].resetFields()
      }
    },
    handleEdit() {
      this.addForm('department_Form')
      if (this.id) {
        this.department_Title = '编辑部门'
        this.department_DFV = true
        this.department_Form.DepartmentName = this.nodeName
      } else {
        this.$message.warning(`请选择要修改的部门`)
      }
    },
    submitAdd(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          this.department_DFV = false
          if (this.id) {
            addDepartmentName(this.id, this.department_Form.DepartmentName, 0).then(response => {
              if (response.data[0].result === '1') {
                this.getTreeData()
                this.$message.success('添加成功')
                this.i = 0
              } else {
                this.$message.error('添加失败')
              }
            })
          } else {
            addDepartmentName(0, this.department_Form.DepartmentName, 0).then(response => {
              if (response.data[0].result === '1') {
                this.getTreeData()
                this.$message.success('添加成功')
                this.i = 1
              } else {
                this.$message.error('添加失败')
              }
            })
          }
        } else {
          return false
        }
      })
    },
    submitEdit(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          this.department_DFV = false
          editList(this.id, this.department_Form.DepartmentName).then(response => {
            if (response.data[0].result === '1') {
              this.getTreeData()
              this.$message.success('编辑成功')
            } else {
              this.$message.error('编辑失败')
            }
          })
        } else {
          return false
        }
      })
    },
    deleteTable() {
      if (this.id) {
        this.$confirm('此操作将永久删除该数据, 是否继续?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          delList(this.id).then(response => {
            if (response.data[0].result === '1') {
              this.getTreeData()
              this.i = 1
              this.id = ''
              this.$message({
                message: '已被成功删除',
                type: 'success'
              })
            }
          })
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消删除'
          })
        })
      } else {
        this.$message.warning(`请选择部门`)
      }
    },
    cancel() {
      this.department_DFV = false
      this.people_DFV = false
    },
    fetchPeopleForName() {
      if (this.Name) {
        getTablePeopleForName(this.Name).then(response => {
          for (let i = 0; i < response.data.length; i++) {
            // let Data = response.data
            if (response.data[i].入公司时间) {
              response.data[i].入公司时间 = response.data[i].入公司时间.split(' ')[0]
            }
            if (response.data[i].出生日期) {
              response.data[i].出生日期 = response.data[i].出生日期.split(' ')[0]
            }
          }
          this.List = response.data
        })
      } else {
        this.$message.warning(`请输入人员姓名`)
        this.List = []
      }
    },
    addPeople() {
      if (this.id) {
        this.people_title = '新增人员'
        this.people_DFV = true
        this.addForm('people_form')
      } else {
        this.$message.warning(`请选择部门名称`)
      }
    },
    submitAddPeople() {
      this.btnLoading = true
      addPeople(this.id, this.people_form.Sex, this.people_form.Education, this.people_form.Address, this.people_form.Nation, this.people_form.Post, this.people_form.AccountNumber, this.people_form.Password, this.people_form.Name, this.people_form.IDcard, this.people_form.TimeOfEntry, this.people_form.Birthday, this.people_form.ContactInformation).then(response => {
        this.btnLoading = false
        if (response.data[0].result === '1') {
          this.people_DFV = false
          this.i = 0
          this.handleNodeClick()
          this.$message.success('添加成功')
        } else {
          this.$message.error('添加失败')
        }
      })
    },
    handleEditPeople(row) {
      this.people_title = '编辑人员'
      this.people_DFV = true
      this.addForm('people_form')
      this.people_form.PeopleID = row.人员编号
      this.people_form.Sex = parseInt(row.性别编号)
      this.people_form.Education = parseInt(row.学历编号)
      this.people_form.Address = row.家庭住址
      this.people_form.Nation = row.民族
      this.people_form.Post = parseInt(row.岗位编号)
      this.people_form.AccountNumber = row.考勤编号
      this.people_form.Password = row.密码
      this.people_form.Name = row.姓名
      this.people_form.IDcard = row.身份证号
      this.people_form.TimeOfEntry = row.入公司时间
      this.people_form.Birthday = row.出生日期
      this.people_form.ContactInformation = row.联系电话
    },
    submitEditPeople() {
      this.btnLoading = true
      editPeople(this.people_form.PeopleID, this.people_form.Sex, this.people_form.Education, this.people_form.Address, this.people_form.Nation, this.people_form.Post, this.people_form.AccountNumber, this.people_form.Password, this.people_form.Name, this.people_form.IDcard, this.people_form.TimeOfEntry, this.people_form.Birthday, this.people_form.ContactInformation).then(response => {
        this.btnLoading = false
        if (response.data[0].result === '1') {
          if (this.id !== '' && this.Name === '') {
            this.handleNodeClick()
          } else {
            this.feathPeopleForName()
          }
          this.$message.success('编辑成功')
          this.people_DFV = false
        } else {
          this.$message.error('编辑失败')
        }
      })
    },
    deletePeopleTable(row) {
      this.deleteRow(delPeopleList, row.人员编号, function() { this.id ? this.handleNodeClick() : this.feathPeopleForName() })
      this.i = 0
    },
    postMaintain() {

    },
    handleSizeChange(val) {
      this.PageSize = val
      this.PageCurrent = 1
      getTablePeople(this.id, this.PageCurrent, this.PageSize).then(response => {
        this.List = response.data.rows
        this.total = response.data.total
      })
    },
    handleCurrentChange(val) {
      this.PageCurrent = val
      getTablePeople(this.id, this.PageCurrent, this.PageSize).then(response => {
        this.List = response.data.rows
        this.total = response.data.total
      })
    },
    handleSizeChangeN(val) {
      this.PageSizeN = val
      this.PageCurrentN = 1
      this.getTable(searchLeavingList, [this.PageCurrentN, this.PageSizeN], ['LeavingList', 'totalN'])
    },
    handleCurrentChangeN(val) {
      this.PageCurrentN = val
      this.getTable(searchLeavingList, [this.PageCurrentN, this.PageSizeN], ['LeavingList', 'totalN'])
    },
    handleSelectionChange(val) {
      this.multipleSelection = val
      this.multipleSelection.length === 0 ? this.disabledMove = true : this.disabledMove = false
    },
    Quit() {
      if (this.multipleSelection.length === 0) {
        this.$message.warning('请选择进行离职操作的员工')
      } else {
        this.$confirm('此操作将永久删除该行, 是否继续?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          for (let i = 0; i < this.multipleSelection.length; i++) {
            quit(this.multipleSelection[i].人员编号).then(response => {
              if (response.data[0].result === '1') {
                this.$message.success('离职成功')
                getTablePeople(this.id, this.PageCurrent, this.PageSize).then(response => {
                  this.List = response.data.rows
                  this.total = response.data.total
                })
              } else { this.$message.error('离职失败') }
            })
          }
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消离职操作'
          })
        })
      }
    },
    searchLeavingList() {
      this.LeavingListVisiable = true
      this.getTable(searchLeavingList, [this.PageCurrentN, this.PageSizeN], ['LeavingList', 'totalN'])
    },
    moveGroupConfim() {
      this.id = this.node
      for (let i = 0; i < this.multipleSelection.length; i++) {
        moveGroups(this.multipleSelection[i].人员编号, this.node).then(response => {
          if (response.data[0].result === '1') {
            this.handleNodeClick()
            if (i === this.multipleSelection.length - 1) {
              this.$message.success('移组成功')
            }
          } else {
            this.$message.error('更新失败')
          }
        })
      }
    },
    hide() {
      this.nodeName1 = ''
      this.node = ''
    },
    moveGroup() {
      if (this.multipleSelection.length === 0) {
        this.$message.warning('请至少选择一个人员')
      }
    },
    NodeClick(data) {
      this.node = data.id
      this.nodeName1 = data.label
    }
  }
}
</script>

<style scoped>

</style>
