<style>
  .empInfo_Dialog .classFirst {
    color: #000000;
    font-weight: bold;
  }

  .empInfo_Dialog .className {
    margin-left: 10px;
  }

  .empInfo_Dialog .classStatus {
    padding: 3px 8px;
    background-color: #c8d7fc;
    color: #2961FE;
    font-size: 12px;
    border-radius: 2px;
    margin-left: 20px;
  }

  .empInfo_Dialog .normalName {
    color: #999999;
    font-size: 12px;
  }

  .empInfo_Dialog .normalInner {
    color: #111111;
    font-weight: bold;
    font-size: 13px;
    margin-top: 5px;
  }

  .Employee_Top {
    display: flex;
    margin: 20px;
    justify-content: space-between;
    align-items: center;
  }

  .Employee_Top .q-avatar__content {
    font-size: 30px !important;
  }

  .empInfo_Dialog .Employee_Name {
    margin: 5px 0 0 10px;
    color: #111111;
  }

  .empInfo_Dialog .Employee_Name div:first-child {
    font-size: 12px;
  }

  .empInfo_Dialog .Employee_Name div:last-child {
    font-weight: bold;
    margin-top: 5px;
    font-size: 15px;
  }

  .Emloyee_CompanyInfo {
    display: flex;
    justify-content: space-between;
    margin: 0 18px 25px;
    border-bottom: 1px solid #d1d1d1;
    padding-bottom: 20px;
  }

  .empInfo_Dialog .employee_MenuList {
    width: 96%;
    margin: 25px auto;
    height: 40px;
    border-radius: 3px !important;
    border: 1px solid #2961FE;
    color: #2961FE;
    align-items: center;
    font-size: 12px;
    white-space: nowrap;
  }

  .empInfo_Dialog .checkedRole {
    background-color: #2961FE;
    color: #fff;
  }

  .empInfo_Dialog .employee_MenuList span {
    padding: 0 20px;
    display: inline-block;
    text-align: center;
    height: 100%;
    line-height: 38px;
    cursor: pointer;
  }

</style>
<template>
  <q-dialog v-model="persistent" maximized full-height seamless position="right" @hide="closeShenheForm">
    <q-card style="margin-top:61px;width:800px" class="no-border-radius empInfo_Dialog">
      <div class="Employee_Top">
        <div style="display:flex;">
          <div>
            <q-avatar size="60px" v-if="saveObj.UserIcon">
              <img :src="saveObj.UserIcon" />
            </q-avatar>
            <q-avatar size="60px" color="teal-10" text-color="white" v-if="!saveObj.UserIcon">
              {{saveObj.EmployeeName.substring(0,1)}}</q-avatar>
          </div>
          <div class="Employee_Name">
            <div>姓名</div>
            <div>{{saveObj.EmployeeName}}</div>
          </div>
        </div>
        <div>
          <q-btn label="调岗" color="accent q-px-md" size="10px" @click="isShowJobPop=true"
            style="font-weight:400 !important;margin-right:10px;">
            <q-popup-proxy>
              <q-banner v-if="isShowJobPop">
                <div style="width:300px;padding-bottom:20px;">
                  <div style="margin:10px 0 15px 0;">调岗</div>
                  <q-select filled stack-label option-value="PostId" option-label="PostName" v-model="Post_Id"
                    ref="Post_Id" :options="PostList" label="岗位" :dense="false" class="col-6 q-pb-lg" emit-value
                    map-options />
                  <q-btn color="primary" label="确定" style="width:100%;" @click="savePost()" />
                </div>
              </q-banner>
            </q-popup-proxy>
          </q-btn>
          <q-btn label="调部门" color="accent q-px-md" size="10px" @click="isShowDepPop=true"
            style="font-weight:400 !important;">
            <q-popup-proxy>
              <q-banner v-if="isShowDepPop">
                <div style="width:300px;padding-bottom:20px;">
                  <div style="margin:10px 0 15px 0;">调部门</div>
                  <q-radio v-model="deptObj.schoolType" @input="getDepartList()" :val="0" label="本校区" />
                  <q-radio v-model="deptObj.schoolType" @input="getDepartList()" :val="1" label="其他校区" />
                  <br />
                  <template v-if="deptObj.schoolType==1">
                    <q-select filled stack-label @input="getDepartList()" option-value="SId" option-label="SName"
                      v-model="deptObj.School_Id" ref="School_Id" :options="schoolList" label="所属校区" :dense="false"
                      emit-value map-options />
                    <br />
                  </template>

                  <selectTree :treeData='DeptList' :defaultArray="returnString" nodeKey="DeptId" :multiple="false"
                    labelKey="DeptName" childrenKey="ChildList" tipText="选择部门" @getChild="getChild"
                    classStr="col-6 q-pb-lg"></selectTree>
                  <q-btn color="primary" label="确定" style="width:100%;" @click="saveDepart()" />
                </div>
              </q-banner>
            </q-popup-proxy>
          </q-btn>
        </div>
      </div>
      <div class="Emloyee_CompanyInfo">
        <div>
          <div class="normalName">公司</div>
          <div class="normalInner">{{saveObj.SchoolName}}</div>
        </div>
        <div>
          <div class="normalName">部门</div>
          <div class="normalInner">{{saveObj.DeptName}}</div>
        </div>
        <div>
          <div class="normalName">岗位</div>
          <div class="normalInner">{{saveObj.PostName}}</div>
        </div>
        <div>
          <div class="normalName">电话</div>
          <div class="normalInner">{{saveObj.EmployeeTel}}</div>
        </div>
      </div>
      <div class="employee_MenuList">
        <span @click="getItem(item,index)" :class="{'checkedRole':index==checkedIndex}" v-for="(item,index) in menuList"
          :key="index">{{item.name}}
        </span>
      </div>
      <div v-if="tabCheck==0" style="margin:0 15px;">
        <employeeRemark :saveObj="saveObj"></employeeRemark>
      </div>
      <div v-if="tabCheck==1">
        <employeeDetails :saveObj="saveObj"></employeeDetails>
      </div>
      <div v-if="tabCheck==2">
        <employeeLog :saveObj="saveObj"></employeeLog>
      </div>
      <div v-if="tabCheck==3">
        <employeeFile :saveObj="saveObj"></employeeFile>
      </div>
      <div v-if="tabCheck==4">
        <employeeFinace :saveObj="saveObj"></employeeFinace>
      </div>
    </q-card>
    <div class="dialog-out-close" @click="closeShenheForm"
      style="height:40px !important;border-top-left-radius: 4px !important;border-bottom-left-radius: 4px !important;">
      <q-icon name="iconfont icon-jujue1" size="26px" />
    </div>
  </q-dialog>
</template>

<script>
  import {
    UpdateEmployeeLeave,
    UpdateEmployeeDept,
    UpdateEmployeePost
  } from '../../../api/users/user'
  import {
    getDeptTree
  } from '../../../api/system/dept.js'
  import {
    queryDeptPostList
  } from '../../../api/system/post'
  import {
    getSchoolDropdown,
  } from '../../../api/school/index'
  import employeeDetails from '../manager/employee_details';
  import employeeRemark from '../manager/employee-remark';
  import employeeLog from '../manager/employee_log';
  import employeeFile from '../manager/employee_file';
  import employeeFinace from '../manager/employee_finace';
  import selectTree from '../../common/select-tree'
  export default {
    props: {
      saveObj: {
        type: Object,
        default: null
      }
    },
    components: {
      employeeDetails,
      employeeRemark,
      employeeLog,
      employeeFile,
      employeeFinace,
      selectTree
    },
    data() {
      return {
        persistent: true,
        tabCheck: 0, //默认选第一个
        loading: false,
        checkedIndex: 0,
        setObj: {
          type: 0,
          selected: []
        },
        menuList: [{
          name: '行政备注',
          id: 0
        }, {
          name: '详细资料',
          id: 1
        }, {
          name: '日志记录',
          id: 2
        }, {
          name: '附件',
          id: 3
        }, {
          name: '财务单据',
          id: 4
        }],
        isShowJobPop: false,
        PostList: [], //岗位下拉数据
        Post_Id: 0, //岗位
        isShowDepPop: false,
        DeptList: [], //部门数据
        returnString: [], //部门默认
        departId: -2, // 部门
        schoolList: [], //校区列表
        deptObj: {
          schoolType: 0, //校区类型
          School_Id: 0,
        }
      }
    },
    created() {
      this.getSchool();
    },
    mounted() {
      this.queryPostList();
      this.getDepartList();
    },
    methods: {
      getSchool() {
        getSchoolDropdown({}).then(res => {
          this.schoolList = res.Data;
          var obj = {
            SName: '总部',
            SId: 0
          }
          this.schoolList.unshift(obj);
        })
      },
      closeShenheForm() {
        this.persistent = false;
        this.$emit('close');
      },
      //点击切换
      getItem(item, index) {
        this.checkedIndex = index;
        this.tabCheck = item.id;
      },
      //获取岗位下拉
      queryPostList() {
        var postMsg = {
          QDeptIds: 0
        };
        if (this.saveObj && this.saveObj.Dept_Id) {
          postMsg.QDeptIds = this.saveObj.Dept_Id;
        }
        queryDeptPostList(postMsg).then(res => {
          if (res.Code == 1) {
            this.PostList = res.Data;
            let obj = {
              PostName: '不限',
              PostId: 0
            }
            this.PostList.unshift(obj);
          }
        })
      },
      //保存修改岗位
      savePost() {
        if (this.Post_Id == 0) {
          this.$q.notify({
            type: 'negative',
            position: "top",
            message: `请选择岗位`
          })
          return;
        }
        let obj = {};
        if (this.saveObj) {
          obj.Id = this.saveObj.Id;
          obj.AccountId = this.saveObj.AccountId;
          obj.AccountType = this.saveObj.AccountType;
          obj.Post_Id = this.Post_Id;
        }
        UpdateEmployeePost(obj).then(res => {
          if (res.Code == 1) {
            this.isShowJobPop = false;
            this.closeShenheForm = false;
            this.$emit('close');
            this.$emit('success');
          }
        })
      },
      //选择部门
      getChild(deptArray) {
        if (deptArray && deptArray != '') {
          this.departId = deptArray;
        }
      },
      //获取部门下拉数据
      getDepartList() {
        this.DeptList = [];
        let msg = {
          School_Id: 0
        }
        if (this.deptObj.schoolType == 0) {
          msg.School_Id = this.saveObj.School_Id;
        } else {
          msg.School_Id = this.deptObj.School_Id;
        }
        getDeptTree(msg).then(res => {
          if (res.Code == 1) {
            this.DeptList = res.Data;
          }
        })
      },
      //保存部门
      saveDepart() {
        if (this.departId == -2) {
          this.$q.notify({
            type: 'negative',
            position: "top",
            message: `请选择部门`
          })
          return;
        }
        let obj = {};
        if (this.saveObj) {
          obj.Id = this.saveObj.Id;
          obj.AccountId = this.saveObj.AccountId;
          obj.AccountType = this.saveObj.AccountType;
          obj.Dept_Id = this.departId;
          obj.School_Id = this.deptObj.School_Id;
        }
        UpdateEmployeeDept(obj).then(res => {
          if (res.Code == 1) {
            this.isShowDepPop = false;
            this.closeShenheForm = false;
            this.$emit('success');
            this.$emit('close')
          }
        })
      }
    },
  }

</script>
