<style>
  .Sysuser_Date .el-range-editor .el-range-input {
    background-color: transparent;
  }

  .Sysuser_Date .el-range-editor.el-input__inner {
    background-color: transparent;
  }

  .syster_qDropdown .q-btn__wrapper {
    padding: 0 3px;
    min-height: 0 !important;
  }

</style>
<template>
  <div class="page-body">
    <div class="page-search row items-center">
      <div class="col row wrap q-mr-lg q-col-gutter-md">
        <div class="col-3">
          <q-input @input="resetSearch" clearable standout="bg-primary text-white" v-model="msg.EmployeeName"
            label="员工姓名/账号" maxlength="20" />
        </div>
        <div class="col-3">
          <q-select filled stack-label clearable @input="getDepartList(msg.School_Id),resetSearch()" option-value="SId"
            option-label="SName" v-model="msg.School_Id" ref="School_Id" :options="schoolList" label="所属校区"
            :dense="false" emit-value map-options />
        </div>
        <div class="col-3">
          <selectTree :treeData='DeptList' :defaultArray="returnString" nodeKey="DeptId" :multiple="false"
            labelKey="DeptName" childrenKey="ChildList" tipText="选择部门" @getChild="getChild"></selectTree>
        </div>
        <div class="col-3">
          <q-select filled stack-label @input="resetSearch" clearable option-value="PostId" option-label="PostName"
            v-model="msg.Post_Id" ref="Post_Id" :options="PostList" label="岗位" :dense="false" emit-value map-options />
        </div>
        <div class="col-3">
          <q-select filled @input="resetSearch" stack-label option-value="Id" option-label="Name" v-model="msg.IsLeave "
            :options="LeaveStatusList" label="在职状态" :dense="false" emit-value map-options />
        </div>
        <div class="col-3 Sysuser_Date">
          <q-field filled>
            <template v-slot:control>
              <el-date-picker v-model="dateListOne" @change="resetSearch()" value-format="yyyy-MM-dd" type="daterange" style="border:none;"
                 range-separator="至"  start-placeholder="入职开始日期"  end-placeholder="入职结束日期" />
            </template>
          </q-field>
        </div>
        <div class="col-3 Sysuser_Date">
          <q-field filled>
            <template v-slot:control>
              <el-date-picker v-model="dateListThree" @change="resetSearch()" value-format="yyyy-MM-dd" type="daterange" style="border:none;"
                  range-separator="至"  start-placeholder="离职开始日期"  end-placeholder="离职结束日期" />
            </template>
          </q-field>
        </div>
        <div class="col-3">
          <q-select filled stack-label option-value="Id" option-label="Name" v-model="msg.AccountUserType"
            @input="resetSearch()" :options="AccountUserTypeList" label="员工类型" :dense="false" emit-value map-options />
        </div>
        <!-- <div class="col-3 Sysuser_Date">
          <q-field filled class="col-6">
            <template v-slot:control>
              <el-date-picker v-model="dateListTwo" @change="resetSearch()" format="MM-dd"  value-format="yyyy-MM-dd"
                 type="daterange"  style="border:none;"   range-separator="至"  start-placeholder="生日开始时间"
                 end-placeholder="生日结束时间" />
            </template>
          </q-field>
        </div> -->
      </div>
    </div>
    <div class="page-content">
      <q-table :pagination="msg" :loading="loading" no-data-label="暂无相关数据" flat selection="multiple"
        :selected.sync="selected" class="sticky-right-column-table sticky-column-table" separator="none" :data="data"
        :columns="columns" row-key="Id">
        <template v-slot:top>
          <div class="col-2 q-table__title">员工管理</div>
          <q-space />
          <div class="page-option">
            <q-btn color="accent" size="sm" class="q-mr-md" label="同步到微信" @click="synchronization()"
              v-if="DeptEmpEnable==1" />
            <q-btn color="accent" size="sm" class="q-mr-md" icon="add" label="新增员工" @click="EditManager(null,0)" />
            <q-btn-dropdown outline size="sm" color="dark" label="更多">
              <q-list>
                <q-item clickable v-close-popup @click="getType(1)">
                  <q-item-section>
                    <q-item-label>离职</q-item-label>
                  </q-item-section>
                </q-item>
                <q-item clickable v-close-popup @click="resetPassWord()">
                  <q-item-section>
                    <q-item-label>重置密码</q-item-label>
                  </q-item-section>
                </q-item>
              </q-list>
            </q-btn-dropdown>
          </div>
        </template>
        <template v-slot:body-cell-EmployeeName="props">
          <q-td :props="props">
            <q-avatar rounded size="sm" v-if="props.row.UserIcon">
              <img :src="props.row.UserIcon" />
            </q-avatar>
            <q-avatar rounded size="sm" color="teal-10" text-color="white" v-if="!props.row.UserIcon">
              {{GetFirst(props.value[0])}}</q-avatar>
            <span class="q-ml-md text-blue cursor-pointer" style="color:#2961FE;margin-left:10px;cursor:pointer;"
              @click="EditManager(props.row,1)" title="点击查看详情">{{props.value}}</span>
          </q-td>
        </template>
        <template v-slot:body-cell-PropertyNumber="props">
          <q-td :props="props">
            <span class="q-ml-md text-blue cursor-pointer" style="color:#2961FE;margin-left:10px;cursor:pointer;"
              @click="goeduyhsl(props.row)" title="点击查看详情">{{props.value}}</span>
          </q-td>
        </template>

        <template v-slot:body-cell-StuSex="props">
          <q-td :props="props">
            <q-badge :color="props.value==1?'negative':'primary'" :label="props.value==1?'女':'男'" />
          </q-td>
        </template>
        <template v-slot:body-cell-LeaveStatus="props">
          <q-td :props="props">
            <span v-if="props.row.LeaveStatus=='在职'" style="color:#000">{{props.value}}</span>
            <span v-if="props.row.LeaveStatus=='兼职'" style="color:blue">{{props.value}}</span>
            <span v-if="props.row.LeaveStatus=='临时工'" style="color:orange">{{props.value}}</span>
            <span v-if="props.row.LeaveStatus=='离职'" style="color:red">{{props.value}}
            </span>
          </q-td>
        </template>
        <template v-slot:body-cell-BirthDate="props">
          <q-td :props="props">
            <span v-if="props.row.IsBirth==1" style="color:red">{{props.value}}</span>
            <span v-else>{{props.value}}</span>
          </q-td>
        </template>
        <template v-slot:body-cell-Status="props">
          <q-td :props="props">
            <q-toggle size="md" color="primary" :false-value="1" :true-value="0" v-model="props.row.Status"
              title="注意：关闭后，管理员将无法正常使用." @input="DeleteManager(props.row)" />
          </q-td>
        </template>
        <template v-slot:bottom>
          <q-pagination class="full-width justify-end" v-model="msg.pageIndex" color="primary" :max="pageCount"
            :input="true" @input="changePage" />
        </template>
        <template v-slot:body-cell-optioned="props">
          <q-td :props="props">
            <div class="syster_qDropdown">
              <q-btn flat size="xs" icon="edit" color="accent" style="font-weight:400" label="编辑"
                @click="EditManager(props.row,2)" />
              <q-btn-dropdown flat size="xs" color="dark" label="更多" style="margin-left:10px;">
                <q-list>
                  <q-item clickable v-close-popup @click="transFerJob(props.row,3)">
                    <q-item-section>
                      <q-item-label>调岗</q-item-label>
                    </q-item-section>
                  </q-item>
                  <q-item clickable v-close-popup @click="transFerJob(props.row,4)">
                    <q-item-section>
                      <q-item-label>调部门</q-item-label>
                    </q-item-section>
                  </q-item>
                  <q-item clickable v-close-popup @click="transFerJob(props.row,5)">
                    <q-item-section>
                      <q-item-label>调整职能</q-item-label>
                    </q-item-section>
                  </q-item>
                  <q-item clickable v-close-popup @click="goEAccountId(props.row.EmAccountId)"
                    v-if="props.row.EmAccountId>0">
                    <q-item-section>
                      <q-item-label>账户</q-item-label>
                    </q-item-section>
                  </q-item>
                  <q-item clickable v-close-popup @click="goWOrkTransfer(props.row.EmAccountId)">
                    <q-item-section>
                      <q-item-label>单据交接</q-item-label>
                    </q-item-section>
                  </q-item>
                  <q-item clickable v-close-popup @click="resetSinglePwd(props.row)">
                    <q-item-section>
                      <q-item-label>重置密码</q-item-label>
                    </q-item-section>
                  </q-item>
                  <q-item clickable v-close-popup @click="khHandover(props.row)" v-if='DeptEmpEnable==1'>
                    <q-item-section>
                      <q-item-label>客户交接</q-item-label>
                    </q-item-section>
                  </q-item>
                  <q-item clickable v-close-popup @click="orderHandover(props.row)" v-if='DeptEmpEnable==1'>
                    <q-item-section>
                      <q-item-label>订单交接</q-item-label>
                    </q-item-section>
                  </q-item>
                  <q-item clickable v-close-popup @click="teacherHandover(props.row)" v-if='DeptEmpEnable==1'>
                    <q-item-section>
                      <q-item-label>协助老师交接</q-item-label>
                    </q-item-section>
                  </q-item>
                </q-list>
              </q-btn-dropdown>
            </div>
          </q-td>
        </template>
      </q-table>
      <manager-form v-if="isShowManagerForm" :save-obj="managerOption" @close="closeStuForm" @success="refreshPage">
      </manager-form>
      <employee-set v-if="isShowEmployeeSet" :seting-obj="setObj" @close="closeStuForm" @success="refreshPage">
      </employee-set>
      <employee-info v-if="isShowEmpInfo" :save-obj="managerOption" @close="closeStuForm" @success="refreshPage">
      </employee-info>
      <!-- 企业微信客户交接 -->
      <q-dialog v-model="isDetails">
        <q-card style="width: 450px;">
          <q-card-section class="row items-center q-pb-none">
            <div class="text-h6">企业微信客户交接</div>
            <q-space />
            <q-btn icon="close" flat round dense v-close-popup />
          </q-card-section>
          <q-separator />
          <q-card-section>
            <div>
              <q-select style="width: 100%;" filled stack-label option-value="Id" option-label="EmployeeName" use-input
                v-model="joinMsg.ReceiveUserId" @filter="filterFn" ref="Id" :options="Employeelist" label="交接人员"
                :dense="false" emit-value map-options />
            </div>
            <div style="font-size: 12px;color:red;margin-top: 10px;">注：必须选择一项转移目标</div>
            <div style="display: flex;align-items: center;margin-top: 0px;">
              <div style="width: 110px;">企微客户转移</div>
              <q-radio v-model="joinMsg.CustomerTransfer" val="1" label="是" />
              <q-radio v-model="joinMsg.CustomerTransfer" val="2" label="否" />
            </div>
            <div style="display: flex;align-items: center;margin-top: 10px;">
              <div style="width: 110px;">渠道码人员转移</div>
              <q-radio v-model="joinMsg.ChannelTransfer" val="1" label="是" />
              <q-radio v-model="joinMsg.ChannelTransfer" val="2" label="否" />
            </div>
          </q-card-section>
          <q-separator />
          <q-card-actions align="right" class="bg-white">
            <q-btn class="q-mr-md" label="取消" @click="isDetails=false" />
            <q-btn color="accent" class="q-mr-md" label="确定" @click="saveOrderInfo()" :loading="jtloading" />
          </q-card-actions>

        </q-card>
      </q-dialog>
      <!-- 订单交接 -->
      <q-dialog v-model="orderIsDetails">
        <q-card style="width: 450px;">
          <q-card-section class="row items-center q-pb-none">
            <div class="text-h6">订单交接</div>
            <q-space />
            <q-btn icon="close" flat round dense v-close-popup />
          </q-card-section>
          <q-separator />
          <q-card-section>
            <div>
              <q-select style="width: 100%;" filled stack-label option-value="Id" option-label="EmployeeName" use-input
                v-model="orderHandoverMsg.ReceiveId" @filter="filterFn" ref="Id" :options="Employeelist" label="交接人员"
                :dense="false" emit-value map-options />
            </div>
            <div style="font-size: 12px;color:red;margin-top: 10px;">注：必须选择一项转移目标</div>
            <div style="display: flex;align-items: center;margin-top: 0px;">
              <div style="width: 110px;">订单转移</div>
              <q-radio v-model="orderHandoverMsg.CustomerTransfer" val="1" label="是" />
              <q-radio v-model="orderHandoverMsg.CustomerTransfer" val="2" label="否" />
            </div>
            <div style="display: flex;align-items: center;margin-top: 10px;">
              <div style="width: 110px;">渠道码人员转移</div>
              <q-radio v-model="orderHandoverMsg.ChannelTransfer" val="1" label="是" />
              <q-radio v-model="orderHandoverMsg.ChannelTransfer" val="2" label="否" />
            </div>
          </q-card-section>
          <q-separator />
          <q-card-actions align="right" class="bg-white">
            <q-btn class="q-mr-md" label="取消" @click="orderIsDetails=false" />
            <q-btn color="accent" class="q-mr-md" label="确定" @click="saveOrderHandoverInfo()" :loading="orderloading" />
          </q-card-actions>

        </q-card>
      </q-dialog>


      <!-- 协助老师交接 -->
      <q-dialog v-model="teacherIsDetails">
        <q-card style="width: 450px;">
          <q-card-section class="row items-center q-pb-none">
            <div class="text-h6">【{{teacherHandoverMsg.EmployeeName}}】协助人员交接</div>
            <q-space />
            <q-btn icon="close" flat round dense v-close-popup />
          </q-card-section>
          <q-separator />
          <q-card-section>
            <div>
              <q-select style="width: 100%;" filled stack-label option-value="Id" option-label="EmployeeName" use-input
                v-model="teacherHandoverMsg.ReceiveId" @filter="filterFn" ref="Id" :options="Employeelist" label="交接人员"
                :dense="false" emit-value map-options />
            </div>

          </q-card-section>
          <q-separator />
          <q-card-actions align="right" class="bg-white">
            <q-btn class="q-mr-md" label="取消" @click="teacherIsDetails=false" />
            <q-btn color="accent" class="q-mr-md" label="确定" @click="saveTeacherHandoverInfo()"
              :loading="teacherloading" />
          </q-card-actions>

        </q-card>
      </q-dialog>
    </div>
  </div>
</template>
<script>
  import {
    queryManagerPage,
    getSchoolDropdown,
    deleteManagerInfo,
    createManagerAccount,
    GetLeaveStatus,
    getEduEmployeeNumList
  } from '../../api/school/index'
  import {
    SetSynvEduEmployee,
    setUserCoustomerTransfer,
    getWeChatConfigInfo,
    SetUserLeaveOrderCareOf,
    SetUserLeaveTearchCareOf
  } from '../../api/system/wechat';
  import {
    BatchResetUserPassword
  } from '../../api/users/user.js'
  //岗位
  import {
    getPostList
  } from '../../api/system/post'
  import {
    getDeptTree
  } from '../../api/system/dept.js'
  import {
    queryEmployee
  } from '../../api/users/user'
  import managerForm from '../../components/school/manager/manager-form'
  import employeeSet from '../../components/school/manager/employee-set'
  import employeeInfo from '../../components/school/manager/employee-info'
  import selectTree from '../../components/common/select-tree'
  import {
    Loading,
    QSpinnerPie
  } from 'quasar'
  export default {
    meta: {
      title: "员工管理"
    },
    components: {
      managerForm,
      selectTree,
      employeeSet,
      employeeInfo
    },
    data() {
      return {
        currentUrl: "",
        isDetails: false,
        jtloading: false,
        columns: [{
            name: 'desc',
            required: true,
            label: '',
            align: 'left',
          },
          {
            name: 'EmployeeName',
            required: true,
            label: '姓名',
            align: 'left',
            field: row => row.EmployeeName
          },
          {
            name: 'SchoolName',
            label: '公司',
            field: 'SchoolName',
            align: 'left',
          },
          {
            name: 'DeptName',
            label: '部门',
            field: 'DeptName',
            align: 'left',
          },
          {
            name: 'PostName',
            label: '职位',
            field: 'PostName',
            align: 'left',
          },
          {
            name: 'Sex',
            label: '性别',
            field: 'Sex',
            align: 'left'
          },
          {
            name: 'Account',
            label: '账号',
            align: 'left',
            field: 'Account'
          },
          {
            name: 'EmployeeTel',
            label: '联系电话',
            field: 'EmployeeTel',
            align: 'left'
          },
          {
            name: 'BirthDate',
            label: '生日',
            field: 'BirthDate',
            align: 'left'
          },
          {
            name: 'Education',
            label: '学历',
            field: 'Education',
            align: 'left'
          },
          {
            name: 'LeaveStatus',
            label: '状态',
            field: 'LeaveStatus',
            align: 'left',
          },
          {
            name: 'DirectSupervisorName',
            label: '直属上级',
            field: 'DirectSupervisorName',
            align: 'left',
          },

          {
            name: 'AccountRemark',
            label: '行政备注',
            field: 'AccountRemark',
            align: 'left',
          },
          {
            name: 'PropertyNumber',
            required: true,
            label: '使用资产',
            align: 'left',
            field: row => row.PropertyNumber
          },
          {
            name: 'optioned',
            label: '操作',
            field: 'MId'
          }
        ],
        data: [],
        loading: true,
        msg: {
          pageIndex: 1,
          pageSize: 10,
          rowsPerPage: 10,
          School_Id: "", //校区
          Dept_Id: 0, //部门
          Post_Id: "", //岗位编号
          IsLeave: 1, //在职状态
          StartEntryTime: "", //入职开始时间
          EndEntryTime: "", //入职结束时间
          StartLeaveTime: "", //开始离职时间
          EndLeaveTime: "", //结束离职时间
          StartBirthDate: "", //开始生日
          EndBirthDate: "", //结束生日
          EmployeeName: "", //员工姓名电话
          AccountUserType: 1, //员工类型(1-甲鹤员工，2-旅游员工)
        },
        AccountUserTypeList: [{
            Id: 1,
            Name: "甲鹤员工"
          },
          {
            Id: 2,
            Name: "旅游员工"
          },
        ],
        pageCount: 0,
        managerOption: null,
        schoolList: [], //校区数组
        DeptList: [], // 部门下拉
        isShowManagerForm: false,
        resetLoading: false,
        returnString: [], //默认岗位
        PostList: [], //岗位
        LeaveStatusList: [{
            Id: 1,
            Name: "在职"
          },
          {
            Id: 2,
            Name: "离职"
          }
        ], //在职状态
        dateListOne: [], //入职-离职日期
        dateListTwo: [], //生日开始-结束日期
        dateListThree: [], //开始-结束离职日期
        selected: [],
        isShowEmployeeSet: false, //是否显示设置
        setObj: {
          type: 0,
          selected: []
        },
        isShowEmpInfo: false, //是否显示员工信息
        joinMsg: {
          TransferUserId: '',
          ReceiveUserId: '',
          CustomerTransfer: '1',
          ChannelTransfer: '1'
        },
        Employeelist: [],
        AllEmployeelist: [],
        DeptEmpEnable: 0, //是否显示企业微信信息 1 显示
        orderIsDetails: false, //离职人员订单交接
        orderHandoverMsg: {
          UserId: "", //原跟进成员的userid
          ReceiveId: "", //接替成员的userid
          TypeIds: 0, //类型 1 订单转交 2学员转交 
          CustomerTransfer: "1", //是否订单转移
          ChannelTransfer: "1", //是否渠道码人员转移
        }, //离职人员订单交接数据
        orderloading: false,
        teacherHandoverMsg: {
          UserId: "", //原跟进成员的userid
          ReceiveId: "", //接替成员的userid
          EmployeeName: "", //员工姓名
        }, //离职人员订单交接数据
        teacherloading: false,
        teacherIsDetails: false, //离职人员协助老师交接
      }
    },
    mounted() {
      this.currentUrl = this.$route.path
      this.getSchool()
      this.getManager();
      this.getDepartList(0);
      this.queryPostList(0);
      this.queryEmployee()
      this.getmicrodeploy() //获取企业微信的配置
    },
    methods: {
      // 订单交接
      orderHandover(row) {
        this.orderHandoverMsg.UserId = row.EmAccountId
        this.orderIsDetails = true
      },
      // 协助老师交接
      teacherHandover(row) {
        this.teacherHandoverMsg.UserId = row.EmAccountId;
        this.teacherHandoverMsg.EmployeeName = row.EmployeeName;
        this.teacherIsDetails = true
      },
      saveOrderHandoverInfo() { //保存
        if (this.orderHandoverMsg.ReceiveId == '') {
          this.$q.notify({
            type: 'negative',
            message: `请选择接替人员`,
            position: 'top'
          })
          return
        }
        if (this.orderHandoverMsg.ReceiveId == this.orderHandoverMsg.UserId) {
          this.$q.notify({
            type: 'negative',
            message: `接替人员不能是本人`,
            position: 'top'
          })
          return
        }
        if (this.orderHandoverMsg.CustomerTransfer == 2 && this.orderHandoverMsg.ChannelTransfer == 2) {
          this.$q.notify({
            type: 'negative',
            message: `转移目标必须选择一项`,
            position: 'top'
          })
          return
        }
        if (this.orderHandoverMsg.CustomerTransfer == 1 && this.orderHandoverMsg.ChannelTransfer != 1) {
          this.orderHandoverMsg.TypeIds = "1"
        } else if (this.orderHandoverMsg.CustomerTransfer != 1 && this.orderHandoverMsg.ChannelTransfer == 1) {
          this.orderHandoverMsg.TypeIds = "2"
        } else if (this.orderHandoverMsg.CustomerTransfer == 1 && this.orderHandoverMsg.ChannelTransfer == 1) {
          this.orderHandoverMsg.TypeIds = "1,2"
        }
        this.orderloading = true
        let msg = {
          UserId: this.orderHandoverMsg.UserId,
          ReceiveId: this.orderHandoverMsg.ReceiveId,
          TypeIds: this.orderHandoverMsg.TypeIds
        }
        SetUserLeaveOrderCareOf(msg).then(res => {
            if (res.Code == 1)
              this.$q.notify({
                icon: 'iconfont icon-chenggong',
                color: 'accent',
                timeout: 2000,
                message: res.Message,
                position: 'top'
              })
            this.orderIsDetails = false
            this.orderloading = false
            this.getManager()
          })
          .catch(err => {
            this.orderloading = false
          })
      },

      saveTeacherHandoverInfo() { //保存
        if (this.teacherHandoverMsg.ReceiveId == '') {
          this.$q.notify({
            type: 'negative',
            message: `请选择接替人员`,
            position: 'top'
          })
          return
        }
        if (this.teacherHandoverMsg.ReceiveId == this.teacherHandoverMsg.UserId) {
          this.$q.notify({
            type: 'negative',
            message: `接替人员不能是本人`,
            position: 'top'
          })
          return
        }

        this.teacherloading = true
        let msg = {
          UserId: this.teacherHandoverMsg.UserId,
          ReceiveId: this.teacherHandoverMsg.ReceiveId
        }
        SetUserLeaveTearchCareOf(msg).then(res => {
            if (res.Code == 1)
              this.$q.notify({
                icon: 'iconfont icon-chenggong',
                color: 'accent',
                timeout: 2000,
                message: res.Message,
                position: 'top'
              })
            this.teacherIsDetails = false
            this.teacherloading = false
            this.getManager()
          })
          .catch(err => {
            this.teacherloading = false
          })
      },
      resetSearch() {
        this.msg.pageIndex = 1;
        this.getManager()
      },
      //重置密码
      resetPassWord() {
        if (this.selected.length == 0) {
          this.$q.notify({
            type: 'negative',
            position: "top",
            message: `请选择修改人员`
          })
          return;
        }
        let that = this
        this.$q.dialog({
          title: "重置密码",
          message: "你正在进行重置密码行为，是否确认执行",
          persistent: true,
          cancel: {
            label: "取消",
            flat: true
          },
          ok: {
            label: "确认重置",
            flat: true,
            focus: true
          }
        }).onOk(() => {
          that.resetLoading = true;
          let Msg = [];
          this.selected.forEach(x => {
            let obj = {
              AccountType: x.AccountType,
              AccountId: x.AccountId
            }
            Msg.push(obj);
          })
          BatchResetUserPassword(Msg).then(res => {
            that.resetLoading = false
            that.$q.dialog({
              title: "密码重置成功",
              message: res.Message,
              persistent: true,
              ok: {
                label: "确认",
                flat: true,
                focus: true
              }
            })
            this.selected = [];
          }).catch(() => {
            that.resetLoading = false
          });
        })
      },
      //单个重置密码
      resetSinglePwd(item) {
        let that = this
        this.$q.dialog({
          title: "重置密码",
          message: "你正在进行重置密码行为，是否确认执行",
          persistent: true,
          cancel: {
            label: "取消",
            flat: true
          },
          ok: {
            label: "确认重置",
            flat: true,
            focus: true
          }
        }).onOk(() => {
          that.resetLoading = true;
          let Msg = [];
          let obj = {
            AccountType: item.AccountType,
            AccountId: item.AccountId
          }
          Msg.push(obj);
          BatchResetUserPassword(Msg).then(res => {
            that.resetLoading = false
            that.$q.dialog({
              title: "密码重置成功",
              message: res.Message,
              persistent: true,
              ok: {
                label: "确认",
                flat: true,
                focus: true
              }
            })
          }).catch(() => {
            that.resetLoading = false
          });
        })
      },
      DeleteManager(obj) {
        let that = this;
        var str = (obj.Status == 1 ? "【禁用】" : "【启用】");
        this.$q.dialog({
          title: str + "管理者",
          message: "你正在进行" + str + "管理者行为，一旦执行无法找回，是否确认执行？",
          persistent: true,
          cancel: {
            label: "取消",
            flat: true
          },
          ok: {
            label: "确认",
            flat: true,
            focus: true
          }
        }).onOk(() => {
          that.resetLoading = true
          deleteManagerInfo({
            MId: obj.MId,
            Status: obj.Status
          }).then(res => {
            this.$q.notify({
              icon: 'iconfont icon-chenggong',
              color: 'accent',
              timeout: 2000,
              message: '操作成功!',
              position: 'top'
            })
            this.getManager()
          })
        }).onCancel(() => {
          obj.Status = obj.Status == 1 ? 0 : 1;
        });
      },
      changePage(val) {
        this.msg.pageIndex = val;
        this.getManager();
      },
      getSchool() {
        getSchoolDropdown({}).then(res => {
          this.schoolList = res.Data;
        })
      },
      getManager() {
        this.loading = true;
        if (this.dateListOne && this.dateListOne.length > 0) {
          this.msg.StartEntryTime = this.dateListOne[0];
          this.msg.EndEntryTime = this.dateListOne[1];
        } else {
          this.msg.StartEntryTime = '';
          this.msg.EndEntryTime = '';
        }
        if (this.dateListTwo && this.dateListTwo.length > 0) {
          this.msg.StartBirthDate = this.dateListTwo[0];
          this.msg.EndBirthDate = this.dateListTwo[1];
        } else {
          this.msg.StartBirthDate = '';
          this.msg.EndBirthDate = '';
        }
        if (this.dateListThree && this.dateListThree.length > 0) {
          this.msg.StartLeaveTime = this.dateListThree[0];
          this.msg.EndLeaveTime = this.dateListThree[1];
        } else {
          this.msg.StartLeaveTime = '';
          this.msg.EndLeaveTime = '';
        }
        queryManagerPage(this.msg).then(res => {
          this.data = res.Data.PageData;
          this.pageCount = res.Data.PageCount;
          let UserIds = [];
          this.data.forEach(x => {
            UserIds.push(x.EmAccountId);
            x.PropertyNumber = 0
          })
          UserIds = UserIds.join(',')
          this.loading = false;
          this.geteduyhzclist(UserIds)
        }).catch(() => {
          this.loading = false;
        })
      },
      geteduyhzclist(UserIds) {
        getEduEmployeeNumList({
          UserIds: UserIds
        }).then(res => {
          this.loading = false;
          let data = res.data.data
          var mydata = JSON.parse(JSON.stringify(this.data));
          data.forEach(x => {
            mydata.forEach(j => {
              if (x.EmployeeId == j.EmAccountId) {
                j.PropertyNumber = x.PropertyNumber;
              }
            })
          });
          this.data = mydata;
        }).catch(() => {
          this.loading = false;
        })
      },
      refreshPage() {
        this.selected = [];
        this.getManager()
      },
      EditManager(obj, type) {
        if (obj) {
          this.managerOption = obj;
        } else {
          this.managerOption = null;
        }
        if (type == 1) {
          this.isShowEmpInfo = true;
        } else if (type == 2 || type == 0) {
          this.isShowManagerForm = true;
        }
      },
      //关闭表单
      closeStuForm() {
        this.isShowManagerForm = false;
        this.isShowEmployeeSet = false;
        this.isShowEmpInfo = false;
      },
      getChild(deptArray) {
        var tempStr = "";
        if (deptArray && deptArray != '') {
          tempStr = deptArray;
        }
        if (tempStr) {
          this.msg.Dept_Id = tempStr;
        } else {
          this.msg.Dept_Id = 0;
        }
        this.resetSearch();
        this.queryPostList(this.msg.Dept_Id);
      },
      //获取部门下拉数据
      getDepartList(id) {
        let msg = {
          School_Id: id
        }
        getDeptTree(msg).then(res => {
          if (res.Code == 1) {
            this.DeptList = res.Data;
          }
        })
      },
      //获取岗位
      queryPostList(deptId) {
        this.PostList = [];
        var postMsg = {
          RB_Dept_Id: deptId,
        };
        getPostList(postMsg).then(res => {
          if (res.Code == 1) {
            this.PostList = res.Data;
          }
        })
      },

      getType(num) {
        this.setObj.type = num;
        if (this.selected.length == 0) {
          this.$q.notify({
            type: 'negative',
            position: "top",
            message: `请选择员工`
          })
          return;
        } else {
          this.setObj.selected = this.selected
        }
        this.isShowEmployeeSet = true;
      },
      //单个调岗和调部门
      transFerJob(obj, type) {
        this.setObj.type = type;
        this.setObj.selected = [];
        this.setObj.selected.push(obj);
        this.isShowEmployeeSet = true;
      },
      goEAccountId(Id) {
        var tempStr = '/financial/empBankAccount?type=9' + '&id=' + Id;
        this.$router.push({
          path: tempStr
        });
      },
      goWOrkTransfer(Id) {
        var tempStr = '/financial/financalDocument/GetWOrkTransferPageLis?type=9' + '&id=' + Id;
        this.$router.push({
          path: tempStr
        });
      },
      GetFirst(val) {
        if (val) {
          return val.substr(0, 1);
        }
      },

      //点击使用资产跳转到资产列表查看
      goeduyhsl(row) {
        var tempStr = '/school/receiveNumList?id=' + row.EmAccountId;
        this.$router.push({
          path: tempStr
        });
      },
      synchronization() {
        this.$q.dialog({
          title: '提示信息',
          message: '是否同步员工数据到企业微信里？',
          cancel: true,
          persistent: true,
          ok: "确定",
          cancel: "取消",
        }).onOk(() => {
          Loading.show({
            message: '数据正在同步中，请稍后进入企业微信查看',
            spinner: QSpinnerPie
          })
          SetSynvEduEmployee({}).then(res => {
              if (res.Code == 1) {
                that.$q.notify({
                  icon: 'iconfont icon-chenggong',
                  color: 'accent',
                  timeout: 2000,
                  message: '操作成功',
                  position: 'top'
                })
                Loading.hide()
              }
            })
            .catch(err => {
              Loading.hide()

            })
        }).onCancel(() => {

        });


      },
      queryEmployee() { //下拉人员列表
        queryEmployee({
          IsLeave: 1
        }).then(res => {
          if (res.Code == 1) {
            this.AllEmployeelist = JSON.parse(JSON.stringify(res.Data));
            this.Employeelist = res.Data

          }
        }).catch(() => {

        })
      },
      filterFn(val, update) {
        update(() => {
          if (val === '') {
            this.Employeelist = JSON.parse(JSON.stringify(this.AllEmployeelist))
          } else {
            const needle = val.toLowerCase()
            this.Employeelist = this.AllEmployeelist.filter(v => v.EmployeeName.toLowerCase().indexOf(needle) > -1)
          }
        })
      },
      khHandover(row) { //客户交接
        this.joinMsg.TransferUserId = row.EmAccountId
        this.joinMsg.CustomerTransfer = '1'
        this.joinMsg.ChannelTransfer = '1'
        this.isDetails = true
      },
      saveOrderInfo() { //保存
        if (this.joinMsg.ReceiveUserId == '') {
          this.$q.notify({
            type: 'negative',
            message: `请选择接替人员`,
            position: 'top'
          })
          return
        }
        if (this.joinMsg.ReceiveUserId == this.joinMsg.TransferUserId) {
          this.$q.notify({
            type: 'negative',
            message: `接替人员不能是本人`,
            position: 'top'
          })
          return
        }
        if (this.joinMsg.CustomerTransfer == 2 && this.joinMsg.ChannelTransfer == 2) {
          this.$q.notify({
            type: 'negative',
            message: `转移目标必须选择一项`,
            position: 'top'
          })
          return
        }
        this.jtloading = true
        setUserCoustomerTransfer(this.joinMsg).then(res => {
            if (res.Code == 1)
              this.$q.notify({
                icon: 'iconfont icon-chenggong',
                color: 'accent',
                timeout: 2000,
                message: res.Message,
                position: 'top'
              })
            this.isDetails = false
            this.jtloading = false
            this.getManager()
          })
          .catch(err => {
            this.jtloading = false

          })
      },
      getmicrodeploy() {
        getWeChatConfigInfo({}).then(res => {
          if (res.Code == 1) {
            this.DeptEmpEnable = res.Data.DeptEmpEnable
          }
        })
      }
    },
  }

</script>
<style lang="sass">
  @import url('~assets/css/table.sass')

</style>
