<!-- 组织架构模块 添加船舶页面 -->
<template>
  <div class="box-body" v-loading="loading">
    <div class="label-box">
      <span class="label-title">查看成员</span>
      <div class="button-float">
        <el-button @click="cancel">返回</el-button>
      </div>
    </div>
    <div class="main-list">
      <el-form ref="ruleForm" :model="ruleForm" class="demo-ruleForm">
        <el-form-item label="中文名：">
          {{ruleForm.staffName | empty}}
        </el-form-item>
        <el-form-item label="账号：" class="serviceType">
          <span class="tips"><svg-icon icon-class="tips" />
          <p>成员唯一标识，可以使用工号、邮箱等<br>公司系统内统一的ID</p>
          </span>
          {{ruleForm.staffAccount}}
        </el-form-item>
        <el-form-item label="手机号：">
          {{ruleForm.staffMobilePhone}}
        </el-form-item>
        <el-form-item label="公司/部门：" prop="underCompId" class="dept-comp">
          {{ruleForm.underCompName}} /
          {{ruleForm.deptName}}
        </el-form-item>
      </el-form>
      <div class="department">
        <div>
          <span class="star font">职务</span>
          <span class="ontent" v-if="zhiwu1.roleName">{{ zhiwu1.roleName}}</span>
        </div>
        <div class="lastspan">
          <span class="star font">关联船舶</span>
          <div class="ontent" style="width: 800px;">
            <span v-for="(item,key) in seleteShipList" :key="key" v-show="item.vesselId" class="ontent shipName">{{ item.vesselName }}</span>
          </div>
        </div>
        <div style="display:flex">
          <span class=" font">兼职职务</span>
          <div class="boxClass">
            <div v-for="(item,index) in jobList" :key="index" v-show="item.roleId" style="margin-bottom: 10px">
              <span class=" aaa">兼职{{index+1}}:{{ item.roleName}}</span>
              <div class="lastspan">
                <span class="star bbb">关联船舶</span>
                <div class="ontent" style="width: 800px;">
                  <span v-for="(item,index) in item.asd" :key="item.vesselId+index" v-show="item.vesselId" class="ontent shipName">{{ item.vesselName }}</span>
                </div>
              </div>
            </div>

          </div>
        </div>
      </div>
      <div class="uphead">
        <span class="imghead font">上传签名：</span>
        <img :src="ruleForm.electronicSignature === '' ? url:ruleForm.electronicSignature" class="img" >
      </div>
    </div>
  </div>
</template>
<script>
  import {
    addadmin,
    shipList,
    findRoles
  } from '../../api/organization/orgAddMan';
  import {
    getTreeList
  } from '../../api/organization/tree';
  import {
    getOssInterimCredentials,
    GotOssAccessConfig
  } from '../../api/upload';
  import {
    client
  } from '../../utils/alioss';

  import apiBasicData from '../../api/basicData01';
  import shoreApi from '../../api/organization/shore';
  import { staffInfo , changeInfo , companyRoleList , companyVessels , getDeptListByCompId } from '../../api/shoreBasedMembers';


  export default {
    name: 'shoreMemberAdd',
    data() {
      return {
        compId: localStorage.getItem('enterprise-front-companyId'),
        datamsg: '',
        /* 页面传递来的数据 */
        checklist: [{
          value: ''
        }],
        Department: '',
        Departmentname: '',
        /* 设置部门 */
        checklist1: [{
          key: '',
          value: ''
        }],
        Department1: '',
        Departmentname1: '',
        zwmsg: '',
        // 船舶
        checklist2: [],
        Department2: '',
        Departmentname2: '',
        /* 设置关联船舶 */
        url: 'http://winsea-saas-test.oss-cn-shanghai.aliyuncs.com/default-logo.png',
        setUpTheDepartment: false,
        setDuty: false,
        chargeShip: false,
        loading: false,
        ruleForm: {
          deptId: '',
          staffName: '',
          staffAccount: '',
          loginPassword: '',
          staffMobilePhone: '',
          electronicSignature: '',
          majorRoleId: '',
          roles: [{
            roleId: '',
            major: '1'
          }],
          vessels: []
        },
        data: [],
        data5:[],
        data6:[],
        data1: [{
          id: '',
          label: '',
          disabled: true,
          children: []
        }],
        checkboxmsg: [],
        primaryzw: '1',
        zhiwuCheckList: [],
        zhiwu1: {},
        zhiwu2: [],
        zhiwu11: {},
        shipCheckList: [],
        seleteShipList: [],
        companyList: [],
        deptList: [],
        inputType: 'text',
        isChrome:true,
        roleLoading:false,
        id:this.$route.query.id,
        aaa:[],
        jobList: []
      };
    },
    created() {
      if(this.id){
        this.getInfo();
      }
    },
    methods: {
      getInfo() {
        this.loading = true;
        staffInfo({staffId:this.id}).then((response) => {
          this.ruleForm = response;

          if(!this.ruleForm.electronicSignature){
            this.ruleForm.electronicSignature = this.url;
          }
          // this.checklist2 = response.vessels;
           this.zhiwu1.roleName = response.majorRole.roleName
        response.majorRole.vessels.forEach( item=>{
          this.seleteShipList.push(item)
        })
        response.roles.forEach(item=>{
          this.jobList.push(item)
        })
        this.jobList.forEach(v =>{
          v.asd = []
        })

        response.roles.forEach(item=>{
          console.log()
          // if(item.vessels){
          //   item.vessels.forEach(itemA =>{
          //     this.jobList.forEach(ite =>{
          //       if(ite.roleId === item.roleId){
          //         ite.asd.push(itemA)
          //       }
                
          //     })
              
          //   })
          // }
          
        })
          // response.roles.find(item=>{
          //   if(item.major === '1'){
          //     this.zhiwu1 = {
          //       roleId: item.roleId,
          //       roleName: item.roleName,
          //       major: '1',
          //     }
          //   }
          //   this.zhiwuCheckList.push(item.roleId)
          // })

          this.loading = false;
        })
      },
      cancel() {
        this.$router.go(-1);
      },
    }
  };

</script>
<style scoped lang="scss">

  .dept-comp {
    /deep/ .el-select:nth-child(1){
    margin-right: 10px;
    }
    /deep/ .el-input__inner, .el-select{
    width: 203px !important;
    }
  }

  .serviceType {
    /deep/ .el-form-item__label {
      padding-right: 25px;
    }
    .el-form-item__content {
      position: relative;
    }
  .tips {
    font-size: 20px;
    color: #999;
    position: absolute;
    left: -25px;
    cursor: pointer;
    z-index: 99;
      &:hover{
        p {
          display: block;
        }
      }
      p{
        display: none;
        box-shadow: 0 1px 8px rgba(137,142,146,0.34);
        font-size: 12px;
        line-height: 16px;
        background: #fff;
        color: #333;
        padding: 3px;
        margin: 0;
        margin-top: -4px;
        border-radius: 5px;
        height: 40px;
      }
    }
  }

  .border {
    width: 960px;
    height: 100%;
    border-left: 1px solid #cccccc;
  }
  .organization-box {
    height: calc(86vh - 10px);
    overflow-y: auto;
    border: none;
  }
  .uphead {
    margin: 20px 0;
    height: 60px;
    line-height: 60px;
  }
  .img {
    display: inline-block;
    height: 60px;
    width: 60px;
    border-radius: 10px;
    vertical-align: sub;
  }
  .kyc-passin {
    margin-left: 20px;
    width: 170px;
  }
  .talk {
    font-size: 12px;
    color: #999999;
  }
  /deep/.el-dialog__body {
    padding: 0;
  }
  /deep/ .el-dialog--center .el-dialog__body {
    padding: 0;
  }
  .adddepartment {
    height: 400px;
    display: flex;
    justify-content: space-between;
  }
  .adddepartment1 {
    padding: 20px;
    width: 50%;
    overflow-y: auto;
  }
  .adddepartment2 {
    padding: 20px;
    width: 50%;
    background-color: #eeeeee;
  }
  /deep/.el-tree-node__content {
    height: 40px;
  }
  .adddepartment3 {
    height: 36px;
    line-height: 36px;
    background-color: #ffffff;
    position: relative;
    margin-bottom: 5px;
  }
  .adddepartment4 {
    display: inline-block;
    margin-bottom: 20px;
  }
  .adddepartmentLeft {
    width: 195px;
    display: inline-block;
    position: absolute;
    left: 10px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .shipName {
    padding: 4px 8px;
    background-color: #dde9fc;
    margin-right: 10px;
    margin-bottom: 10px;
  }
  .ddv1 {
    //width: 730px;
    vertical-align: top;
    margin-top: 2px;
  }
  .ddv1 > span {
    float: left;
  }
  .adddepartmentDel {
    display: inline-block;
    position: absolute;
    right: 20px;
    color: #1d6ced;
    cursor: pointer;
  }
  /deep/.el-form-item .el-input__inner {
    width: 420px;
  }
  .main-list {
    height: calc(42vh);
  }
  .primaryzw{
    width: 100%;
    margin-bottom: 30px;
  }
  .zhiwu{
    margin-left: 40px;
    width: 180px;
  }
  .zhiwuCheck{
    display: block;
    margin-top: 10px;
  }
  .zhuyaozhiwu{
    margin-top: 10px;
    background-color: #ffffff;
    padding: 3px 8px;
    // display: inline-block;
  }
  .ciyaozhiwu{
    background-color: #ffffff;
    padding: 5px 10px;
    // display: inline-block;
    margin-top: 10px;
  }
  .zhiwuradio{
    margin-top: 5px;
    margin-right: 10px;
  }
  .zhiwuDel{
    margin-inline-start: 10px;
    color: #1d6ced;
    cursor: pointer;
    float:right;
  }
  .lastspan{
    display: flex;
  }
  .ddv1{
    flex: 1;
  }
  .operactionShip {
    width: calc(100% - 140px);
    display: block;
  }

  .inputPsd{
    -webkit-text-security:disc;
  }
  .aaa {
  display: inline-block;
  padding-right: 12px;
  font-size: 14px;
  color: #666666;
  margin-bottom: 15px;
}
.bbb {
  display: inline-block;
  padding-right: 12px;
  font-size: 14px;
  color: #666666;
}
</style>
