<template>
  <div style="height:100%;padding:3px 8px;overflow: auto;" class="userD-mag">
    <!--通讯,68-->
    <div id="showUserDetail">
    </div>
    <!--通讯,68-->
    <!--通讯,69-->
    <div id="saveUserDetail">
    </div>
    <!--通讯,69-->
    <!--通讯,70-->
    <div id="getNation">
    </div>
    <!--通讯,70-->
    <!--通讯,71-->
    <div id="getProvince">
    </div>
    <!--通讯,71-->
    <!--通讯,72-->
    <div id="getCitpaginationys">
    </div>
    <!--通讯,72-->
    <!--标签页,3-->
    <el-tabs ref="tab1" type="border-card" @tab-click="handleClick" style="height:auto;">
      <!--tabPane,13-->
      <el-tab-pane :label="userTitle">
        <!--表单,3-->
        <el-form ref="addUser" :model="user" tokenKey="addUser" label-width="120px"
                 :rules="rolesPass" :disabled="isDisabled">
          <!--输入框,37-->
          <el-input event-render="loadText" v-model="user.id"
                    type="text" :disabled="false" v-if="false">
          </el-input>
          <!--输入框,37-->
          <!--布局,27-->
          <el-row ref="thirdLine" :gutter="30">
            <!--col,49-->
            <el-col :span="11">
              <!--表单行,47-->
              <el-form-item :label="$t('statics.登录名:')" prop="logName" >
                <!--输入框,38-->
                <el-input event-render="loadText" v-model="user.logName"
                          type="text" :disabled="logNameDisabled" maxlength="8">
                </el-input>
                <!--输入框,38-->
              </el-form-item>
              <!--表单行,47-->
            </el-col>
            <!--col,49-->
            <!--col,50-->
            <el-col :span="11">
              <!--表单行,48-->
              <el-form-item :label="$t('statics.姓名:')" class="requireds" prop="name">
                <!--输入框,39-->
                <el-input event-render="loadText" v-model="user.name"
                          type="text" :disabled="false">
                </el-input>
                <!--输入框,39-->
              </el-form-item>
              <!--表单行,48-->
            </el-col>
            <!--col,50-->
          </el-row>
          <!--布局,27-->
          <!--布局,28-->
          <el-row ref="thirdLine" :gutter="30" v-if="setPassWord">
            <!--col,51-->
            <el-col :span="11">
              <!--表单行,49-->
              <el-form-item :label="$t('statics.密码:')" prop="logPass" class="requireds">
                <!--输入框,40-->
                <el-input event-render="loadText" v-model="user.logPass"
                          type="password" :disabled="false" >
                </el-input>
                <!--输入框,40-->
              </el-form-item>
              <!--表单行,49-->
            </el-col>
            <!--col,51-->
            <!--col,52-->
            <el-col :span="11">
              <!--表单行,50-->
              <el-form-item :label="$t('statics.确认密码:')" prop="confirmPass" class="requireds">
                <!--输入框,41-->
                <el-input event-render="loadText" v-model="user.confirmPass"
                          type="password" :disabled="false">
                </el-input>
                <!--输入框,41-->
              </el-form-item>
              <!--表单行,50-->
            </el-col>
            <!--col,52-->
          </el-row>
          <!--布局,28-->
          <!--布局,29-->
          <el-row ref="thirdLine" :gutter="30">
            <!--col,53-->
            <el-col :span="11">

              <el-form-item :label="$t('statics.归属行:')"  prop="workorg">
                <el-select v-model="user.workorg">
                  <el-option
                      v-for="item in branchlist"
                      :key="item.branch"
                      :label="$i18n.locale == 'zh' ? item.branch +' - '+ item.bchname : item.branch +' - '+ item.namen"
                      :value="item.branch"
                  >
					<span style="float: left" v-if="$i18n.locale === 'zh'">{{ item.branch }} - {{ item.bchname }}</span>
                	<span style="float: left" v-if="$i18n.locale === 'en'">{{ item.branch }} - {{ item.namen }}</span>
                  </el-option>
                </el-select>
              </el-form-item>

              <!--表单行,51-->
            </el-col>

            <el-col :span="11">
              <!--表单行,54-->
              <el-form-item :label="$t('statics.是否冻结:')"  prop="state">
                <!--单选框,18-->
                <el-radio v-model="user.state" label="3">
                  {{ $t('statics.是') }}
                </el-radio>
                <!--单选框,18-->
                <!--单选框,19-->
                <el-radio v-model="user.state" label="Y">
                  {{ $t('statics.否') }}
                </el-radio>
                <!--单选框,19-->
                <!--单选框,20-->
                <el-radio v-model="user.state" label="A">
                  {{ $t('statics.临时冻结') }}(10min)
                </el-radio>
                <!--单选框,20-->
              </el-form-item>
              <!--表单行,54-->
            </el-col>
          </el-row>

          <el-row ref="thirdLine" :gutter="30">
            <!--col,62-->
            <!--col,62-->
            <!--col,63-->
            <el-col :span="11">
              <!--表单行,61-->
              <el-form-item :label="$t('statics.电话:')"  prop="mobilePhone">
                <!--输入框,46-->
                <el-input event-render="loadText" v-model="user.mobilePhone"
                          type="text" :disabled="false">
                </el-input>
                <!--输入框,46-->
              </el-form-item>
              <!--表单行,61-->
            </el-col>

            <el-col :span="11">
              <!--表单行,62-->
              <el-form-item :label="$t('statics.传真:')"  prop="faxaPhone">
                <!--输入框,47-->
                <el-input event-render="loadText" v-model="user.faxaPhone"
                          type="text" :disabled="false">
                </el-input>
                <!--输入框,47-->
              </el-form-item>
              <!--表单行,62-->
            </el-col>
            <!--col,63-->
          </el-row>
          <!--布局,33-->
          <!--布局,34-->
          <el-row ref="thirdLine" :gutter="30">
            <!--col,64-->
            <el-col :span="11">
              <!--表单行,63-->
              <el-form-item :label="$t('statics.邮编:')" prop="postalcode">
                <!--输入框,48-->
                <el-input event-render="loadText" v-model="user.postalcode"
                          type="text" :disabled="false">
                </el-input>
                <!--输入框,48-->
              </el-form-item>
              <!--表单行,63-->
            </el-col>

            <el-col :span="11">
              <!--表单行,64-->
              <el-form-item :label="$t('statics.电子邮箱:')" prop="email">
                <!--输入框,49-->
                <el-input event-render="loadText" v-model="user.email"
                          type="text" :disabled="false">
                </el-input>
                <!--输入框,49-->
              </el-form-item>
              <!--表单行,64-->
            </el-col>
            <!--col,65-->
          </el-row>
          <!--布局,34-->
          <!--布局,35-->
          <el-row ref="thirdLine" :gutter="30">
            <!--col,66-->
            <el-col :span="11">
              <!--表单行,68-->
              <el-form-item :label="$t('statics.授权档次:')"  prop="authlevel">
                <c-select v-model="user.authlevel" dbCode="ATHLVL" :disabled="isFieldDisabled"></c-select>
              </el-form-item>
              <!--表单行,68-->
            </el-col>

            <el-col :span="11">
              <!--表单行,69-->
              <el-form-item :label="$t('statics.授权权限:')"  prop="relgrp">
                <c-select v-model="user.relgrp" dbCode="GRPCDE"></c-select>
              </el-form-item>
              <!--表单行,69-->
            </el-col>
          </el-row>

          <el-row :gutter="30">
            <!--col,71-->
            <el-col :span="11">
              <!--表单行,69-->
              <el-form-item :label="$t('statics.授权币种:')"  prop="relcur">
                <c-select v-model="user.relcur" dbCode="CURTXT"></c-select>
              </el-form-item>
              <!--表单行,69-->
            </el-col>
            <!--col,71-->
            <el-col :span="11">
              <!--表单行,68-->
              <el-form-item :label="$t('statics.授权金额:')"  prop="relamt">
                <!--输入框,53-->
                <el-input event-render="loadText" v-model="user.relamt"
                          type="text" :disabled="false">
                </el-input>
                <!--输入框,53-->
              </el-form-item>
              <!--表单行,68-->
            </el-col>
          </el-row>
          <el-row :gutter="30">
            <!--col,71-->
            <el-col :span="11">
              <!--表单行,69-->
              <el-form-item :label="$t('statics.关联机构:')"  prop="branchcode">
                <el-select v-model="user.branchcode" multiple>
                  <el-option
                      v-for="item in branchlist"
                      :key="item.branch"
                      :label="$i18n.locale == 'zh' ? item.branch +' - '+ item.bchname : item.branch +' - '+ item.namen"
                      :value="item.branch"
                  >
					<span style="float: left" v-if="$i18n.locale === 'zh'">{{ item.branch }} - {{ item.bchname }}</span>
                	<span style="float: left" v-if="$i18n.locale === 'en'">{{ item.branch }} - {{ item.namen }}</span>

                  </el-option>
                </el-select>
              </el-form-item>
              <!--表单行,69-->
            </el-col>
            <!--col,71-->
            <el-col :span="11">
              <!--表单行,68-->
              <el-form-item :label="$t('statics.关联角色:')"  prop="rolecode">
                <!--输入框,53-->
                <el-select v-model="user.rolecode"  multiple>
                  <el-option
                      v-for="item in rolelist"
                      :key="item.id"
                      :label="$i18n.locale == 'zh' ? item.id +' - '+ item.name : item.id +' - '+ item.extfield1"
                      :value="item.id"
                  >
				  <span style="float: left" v-if="$i18n.locale === 'zh'">{{ item.id }} - {{ item.name }}</span>
				  <span style="float: left" v-if="$i18n.locale === 'en'">{{ item.id }} - {{ item.extfield1 }}</span>
                  </el-option>
                </el-select>
                <!--输入框,53-->
              </el-form-item>
              <!--表单行,68-->
            </el-col>
          </el-row>
          <!--布局,36-->
          <el-row ref="thirdLine" :gutter="30">
            <!--col,67-->
            <el-col :span="11">
              <!--表单行,65-->
              <el-form-item :label="$t('statics.附加信息1:')" prop="extfield1">
                <!--输入框,50-->
                <el-input event-render="loadText" v-model="user.extfield1"
                          type="text" :disabled="false">
                </el-input>
                <!--输入框,50-->
              </el-form-item>
              <!--表单行,65-->
            </el-col>
            <!--col,67-->
            <el-col :span="11">
              <!--表单行,66-->
              <el-form-item :label="$t('statics.附加信息2:')"  prop="extfield2">
                <!--输入框,51-->
                <el-input event-render="loadText" v-model="user.extfield2"
                          type="text" :disabled="false">
                </el-input>
                <!--输入框,51-->
              </el-form-item>
              <!--表单行,66-->
            </el-col>
          </el-row>
          <!--布局,36-->
          <!--布局,37-->
          <el-row ref="thirdLine" :gutter="30">
            <!--col,69-->
            <el-col :span="11">
              <!--表单行,67-->
              <el-form-item :label="$t('statics.附加信息3:')"  prop="extfield3">
                <!--输入框,52-->
                <el-input event-render="loadText" v-model="user.extfield3"
                          type="text" :disabled="false">
                </el-input>
                <!--输入框,52-->
              </el-form-item>
              <!--表单行,67-->
            </el-col>
            <!--col,69-->
            <el-col :span="11">
              <!--表单行,68-->
              <el-form-item :label="$t('statics.附加信息4:')"  prop="extfield4">
                <!--输入框,53-->
                <el-input event-render="loadText" v-model="user.extfield4"
                          type="text" :disabled="false">
                </el-input>
                <!--输入框,53-->
              </el-form-item>
              <!--表单行,68-->
            </el-col>
          </el-row>
          <!--布局,37-->
          <!--布局,38-->
          <el-row :gutter="30">
            <!--col,71-->
            <el-col :span="11">
              <!--表单行,69-->
              <el-form-item :label="$t('statics.附加信息5:')"  prop="extfield5">
                <!--输入框,54-->
                <el-input event-render="loadText" v-model="user.extfield5"
                          type="text" :disabled="false">
                </el-input>
                <!--输入框,54-->
              </el-form-item>
              <!--表单行,69-->
            </el-col>
            <!--col,71-->
          </el-row>
          <!--布局,38-->
          <!--布局,39-->
          <!--布局,39-->
        </el-form>
        <el-row>
          <el-col :span="24" class="text-center subBtn">
            <el-button type="primary" ref="userSubmitBtn" v-if="isShowSubmit" :loading="false" icon="el-icon-circle-check" @click="saveUser('addUser')">
              {{ $t('statics.提交') }}
            </el-button>
            <el-button type="primary" :loading="false" icon="el-icon-refresh-left" native-type="reset" :disabled="false" @click="goBack()">
              {{ $t('statics.返回') }}
            </el-button>
            <el-button type="primary" v-if="passWordBtn && !setPassWord" :loading="false" icon="el-icon-refresh" @click="changePassW">
              {{ $t('statics.重设密码') }}
            </el-button>
          </el-col>
        </el-row>
      </el-tab-pane>
    </el-tabs>
  </div>
</template>
<script type="text/javascript">
import * as iscMessage from '@/util/isc-common/messageManage.js'
import dateFormat from '@/util/date/dateFormat.js'

import { Col,TabPane,RadioGroup,Form,FormItem,Radio,RadioButton,TableColumn,Card,Input,Button,Dialog,Select,Tree,Tabs,Option,DatePicker,Row,Popover} from 'element-ui'

import { IscPagingTable} from '@/components/isc'
import RelatedOrgChild from '@/page/Statics/Usr/RelatedOrg.vue';
import Api from "@/service/Api";
export default {
  name: "userAdd",
  data () {
    return {
      branchlist:[],
      rolelist:[],
      editPriority: '5',
      selectDataList: [],
      limit: 100,
      offset: 0,
      userID:0,
      btnType:"",
      isDisabled:false,
      isShowSubmit:true,
      setPassWord:false,
      passWordBtn:false,
      cityList:[],
      nationList:[],
      provinceList:[],
      relationTableRef:'',
      openOrgDialog:false,
      orgTreeDialogbtn:true,
      orgTreeblongbtn:false,
      userTitle:this.$t('statics.新增用户'),
      Dialogtitle:this.$t('statics.机构数据'),
      nodeProp:{children:'children',label: 'text',isLeaf: 'leaf'},
      GroupGridList:null,
      OrgGridList:null,
      PostGridList:null,
      DepartGridList:null,
      RoleGridList:null,
      openDeptDialog:false,
      openDepartDialog:false,
      deptNode:null,
      deptResolve:null,
      orgNode:null,
      orgResolve:null,
      deptTreeData:[{label: this.$t('statics.一级 1'),children: [{label: this.$t('statics.二级 1-1'),children: [{label: this.$t('statics.三级 1-1-1') }]}]}],
      orgTreeData:[{label: this.$t('statics.一级 1'),children: [{label: this.$t('statics.二级 1-1'),children: [{label: this.$t('statics.三级 1-1-1') }]}]}],
      openGroupDialog:false,
      openPostDialog:false,
      openRoleDialog:false,
      groupTreeData:[],
      postTreeData:[],
      RoleTreeData:[],
      orgRadio:'',
      orgRow:null,
      departRadio:'',
      departRow:null,
      postRadio:'',
      postRow:null,
      groupRadio:'',
      groupRow:null,
      roleRadio:'',
      roleRow:null,
      clickListRow:null,
      ddddd:[{'label':this.$t('statics.选项'),'value':'11','disabled':true},{'label':this.$t('statics.选项一')}],
      orgData:'',
      orgDataList:[],
      departmentDataList:[],
      delGroup:{"fileName":"users.json","basePath":"{{basePath}}","method":"post","scheme":"{{schemes}}","host":"{{host}}","consume":"0","produce":"0","uri":"/users/User/group/relation/{userid}/{groupid}"},
      delRole:{"fileName":"users.json","basePath":"{{basePath}}","method":"post","scheme":"{{schemes}}","host":"{{host}}","consume":"0","produce":"0","uri":"/qukacc/User/role/relation/{userid}/{roleid}/{departmentid}"},
      searchDepart:{"fileName":"users.json","basePath":"{{basePath}}","method":"get","scheme":"{{schemes}}","host":"{{host}}","consume":"0","produce":"0","uri":"/users/User/depart/relation/{userid}"},
      saveDepart:{"fileName":"users.json","basePath":"{{basePath}}","method":"post","scheme":"{{schemes}}","host":"{{host}}","consume":"0","produce":"0","uri":"/users/User/depart/relation/put"},
      savePost:{"fileName":"users.json","basePath":"{{basePath}}","method":"post","scheme":"{{schemes}}","host":"{{host}}","consume":"0","produce":"0","uri":"/users/User/post/relation/put"},
      delOrgd:{"fileName":"users.json","basePath":"{{basePath}}","method":"post","scheme":"{{schemes}}","host":"{{host}}","consume":"0","produce":"0","uri":"/usr/User/org/relation/{userid}/{orgid}"},
      getDepartFlag:{"fileName":"users.json","basePath":"{{basePath}}","method":"get","scheme":"{{schemes}}","host":"{{host}}","consume":"0","produce":"0","uri":"/users/User/depart/flag/{departnum}"},
      searchPost:{"fileName":"users.json","basePath":"{{basePath}}","method":"get","scheme":"{{schemes}}","host":"{{host}}","consume":"0","produce":"0","uri":"/users/User/post/relation/{userid}"},
      // searchRoleOrg:{"fileName":"users.json","basePath":"{{basePath}}","method":"get","scheme":"{{schemes}}","host":"{{host}}","consume":"0","produce":"0","uri":"/users/User/org/relation/{userid}"},
      selectGroupTree:{"fileName":"users.json","basePath":"{{basePath}}","method":"get","scheme":"{{schemes}}","host":"{{host}}","consume":"0","produce":"0","uri":"/users/User/group/relation/grouptree/{userid}"},
      searchRole:{"fileName":"users.json","basePath":"{{basePath}}","method":"get","scheme":"{{schemes}}","host":"{{host}}","consume":"0","produce":"0","uri":"/users/User/role/relation/{userid}"},
      getProvince:{"fileName":"users.json","basePath":"{{basePath}}","method":"get","scheme":"{{schemes}}","host":"{{host}}","consume":"0","produce":"0","uri":"/users/User/province"},
      selectPostTree:{"fileName":"users.json","basePath":"{{basePath}}","method":"get","scheme":"{{schemes}}","host":"{{host}}","consume":"0","produce":"0","uri":"/users/User/post/relation/posttree/{userid}"},
      submitGroup:{"fileName":"users.json","basePath":"{{basePath}}","method":"post","scheme":"{{schemes}}","host":"{{host}}","consume":"0","produce":"0","uri":"/users/User/group/relation"},
      submitRole:{"fileName":"users.json","basePath":"{{basePath}}","method":"post","scheme":"{{schemes}}","host":"{{host}}","consume":"0","produce":"0","uri":"/usr/User/role/relation"},
      selectRoletree:{"fileName":"users.json","basePath":"{{basePath}}","method":"get","scheme":"{{schemes}}","host":"{{host}}","consume":"0","produce":"0","uri":"/admin/usr/allroletree"},
      selectSubRoletree:{"fileName":"users.json","basePath":"{{basePath}}","method":"get","scheme":"{{schemes}}","host":"{{host}}","consume":"0","produce":"0","uri":"/usr/User/conn/subroletree/{currentLoginUserRoleId}"},
      delDepart:{"fileName":"users.json","basePath":"{{basePath}}","method":"post","scheme":"{{schemes}}","host":"{{host}}","consume":"0","produce":"0","uri":"/users/User/depart/relation/{userid}/{departId}"},
      searchOrg:{"fileName":"users.json","basePath":"{{basePath}}","method":"get","scheme":"{{schemes}}","host":"{{host}}","consume":"0","produce":"0","uri":"/users/User/org/relation/{userid}"},
      saveGroup:{"fileName":"users.json","basePath":"{{basePath}}","method":"post","scheme":"{{schemes}}","host":"{{host}}","consume":"0","produce":"0","uri":"/users/User/group/relation/put"},
      getNation:{"fileName":"users.json","basePath":"{{basePath}}","method":"get","scheme":"{{schemes}}","host":"{{host}}","consume":"0","produce":"0","uri":"/users/User/nation"},
      saveRole:{"fileName":"users.json","basePath":"{{basePath}}","method":"post","scheme":"{{schemes}}","host":"{{host}}","consume":"0","produce":"0","uri":"/usr/User/role/relation/put"},
      showUserDetail:{"fileName":"users.json","basePath":"{{basePath}}","method":"get","scheme":"{{schemes}}","host":"{{host}}","consume":"0","produce":"0","uri":"/admin/usr/userdetail/userid/{id}"},
      getDeptTreeChild:{"fileName":"department.json","basePath":"{{basePath}}","method":"get","scheme":"{{schemes}}","host":"{{host}}","consume":"0","produce":"0","uri":"/department/find/treeNode/{departmentNumber}"},
      saveOrgd:{"fileName":"users.json","basePath":"{{basePath}}","method":"post","scheme":"{{schemes}}","host":"{{host}}","consume":"0","produce":"0","uri":"/usr/User/org/relation/put"},
      saveUserDetail:{"fileName":"users.json","basePath":"{{basePath}}","method":"post","scheme":"{{schemes}}","host":"{{host}}","consume":"0","produce":"0","uri":"/usr/saveUsr"},
      delPost:{"fileName":"users.json","basePath":"{{basePath}}","method":"post","scheme":"{{schemes}}","host":"{{host}}","consume":"0","produce":"0","uri":"/users/User/post/relation/{userid}/{postid}"},
      getDepartTreeA:{"fileName":"users.json","basePath":"{{basePath}}","method":"get","scheme":"{{schemes}}","host":"{{host}}","consume":"0","produce":"0","uri":"/users/userrest/depart/relation/departtree/all"},
      submitPost:{"fileName":"users.json","basePath":"{{basePath}}","method":"post","scheme":"{{schemes}}","host":"{{host}}","consume":"0","produce":"0","uri":"/users/User/post/relation"},
      getOrgChildTree:{"fileName":"orgs.json","basePath":"{{basePath}}","method":"get","scheme":"{{schemes}}","host":"{{host}}","consume":"0","produce":"0","uri":"/orgs/org/parentorg/{parentid}"},
      getCitys:{"fileName":"users.json","basePath":"{{basePath}}","method":"get","scheme":"{{schemes}}","host":"{{host}}","consume":"0","produce":"0","uri":"/users/User/province/city/{provinceid}"},
      saveOrgUserRel:{"fileName":"users.json","basePath":"{{basePath}}","method":"post","scheme":"{{schemes}}","host":"{{host}}","consume":"0","produce":"0","uri":"/usr/User/org/relation"},
      getDeptTree:{"fileName":"users.json","basePath":"{{basePath}}","method":"get","scheme":"{{schemes}}","host":"{{host}}","consume":"0","produce":"0","uri":"/users/User/departtree/all/{workorg}"},
      saveDepartRe:{"fileName":"users.json","basePath":"{{basePath}}","method":"post","scheme":"{{schemes}}","host":"{{host}}","consume":"0","produce":"0","uri":"/users/User/depart/relation"},
      getOrgParentTree:{"fileName":"orgs.json","basePath":"{{basePath}}","method":"get","scheme":"{{schemes}}","host":"{{host}}","consume":"0","produce":"0","uri":"/orgs/org/getDepartParent"},
      searchGroup:{"fileName":"users.json","basePath":"{{basePath}}","method":"get","scheme":"{{schemes}}","host":"{{host}}","consume":"0","produce":"0","uri":"/users/User/group/relation/{userid}"},
      saveInfo:{"fileName":"users.json","basePath":"{{basePath}}","method":"post","scheme":"{{schemes}}","host":"{{host}}","consume":"0","produce":"0","uri":"/uro/saveInfo"},
      deleteInfo:{"fileName":"users.json","basePath":"{{basePath}}","method":"post","scheme":"{{schemes}}","host":"{{host}}","consume":"0","produce":"0","uri":"/uro/deleteInfo"},
      // checkUser:{"fileName":"users.json","basePath":"{{basePath}}","method":"post","scheme":"{{schemes}}","host":"{{host}}","consume":"0","produce":"0","uri":"/usr/isHeadBankUser/{id}"},
      rolesPass:{
        logName: [{ required: true, message: this.$t('statics.请输入柜员号')}],
        name: [{ required: true, message: this.$t('statics.请输入姓名')}],
        workorg: [{ required: true, message: this.$t('statics.请选择归属行')}],
        logPass: [{ required: true, message: this.$t('statics.请输入密码'), trigger: 'blur' }, { max: 15, message: this.$t('statics.密码长度不能超过15位'), trigger: 'blur' }],
        confirmPass: [{validator: this.validatePass2, trigger: 'blur'}],
        relgrp:[{ required: true, message: this.$t('statics.请选择授权权限'),trigger: 'blur'},],
        branchcode:[{ required: true, message: this.$t('statics.请选择关联机构'),trigger: 'blur'},],
        rolecode:[{ required: true, message: this.$t('statics.请选择关联角色'),trigger: 'blur'},],
      },
    user:{
      rolecode:{
        id:"",
        name:"",
      },
      branchcode:{
        branch:"",
        bchname:"",
      },
      extfield1:'',
      extfield2:'',
      extfield3:'',
      extfield4:'',
      extfield5:'',
      mobilePhone:'',
      postalcode:'',
      email:'',
      state:'Y',
      workDept:'',
      workDeptName:'',
      workorg:'',
      workorgName:'',
      faxaPhone:'',
      confirmPass:'',
      logPass:'',
      logName:'',
      name:'',
      id:'',
      relgrp:'', // 授权权限
      relcur:'', // 授权币种
      relamt:'', // 授权金额
      authlevel:'', // 授权档次
      role:'',//用户关联角色
    },
      scope:{
          row:''
    },
    logNameDisabled:false,
    isFieldDisabled: true
    }
  },
  components: {
      'isc-paging-table':IscPagingTable,
      'el-radio-group':RadioGroup,
      'el-form':Form,
      'el-radio':Radio,
      'el-col':Col,
      'el-radio-button':RadioButton,
      'el-input':Input,
      'el-option':Option,
      'el-row':Row,
      'el-tabs':Tabs,
      'el-button':Button,
      'el-select':Select,
      'el-form-item':FormItem,
      'el-date-picker':DatePicker,
      'el-dialog':Dialog,
      'el-table-column':TableColumn,
      'el-card':Card,
      'el-popover':Popover,
      'el-tree':Tree,
    'el-tab-pane':TabPane,
    'el-related-org-child':RelatedOrgChild
  },
  mounted (){
    this.$parent.hideChild = false;
    this.userID = this.$route.query.id;
    this.isDisabled = false;
    this.isShowSubmit = true;
    this.logNameDisabled = false;
    this.btnType = this.$route.query.btnType;
    this.bch_init();
    this.role_init();
    let $this = this;
    this.$el.querySelectorAll('*[isToken]').forEach(function(el,index){
      var key =el.getAttribute('tokenKey');
      iscMessage.getTokenID($this,key);
    });
    this.$el.querySelectorAll('*[data-init]').forEach(function(el,index){
      var init =el.getAttribute('data-init');
      var message = iscMessage.initMessageKey(init);
      $this.poin_initManage(message[0],message[1],message[2]);
    });
    if(this.userID == null){
      //增加,显示密码框
      this.setPassWord = true;
      this.logNameDisabled = false;
      this.isFieldDisabled=false;
    }
    else{
      //修改 ,显示重置密码按钮,反显数据
      this.logNameDisabled = true;
      if(this.btnType == "info"){
        this.passWordBtn=false;
        this.userTitle=this.$t('statics.查看用户');
        this.isDisabled = true;
        this.isShowSubmit = false;
      }else{
        this.passWordBtn=true;
        this.userTitle=this.$t('statics.修改用户');
        this.isFieldDisabled=false;
        // this.checkUserInfo();
      }
      this.user.id = this.userID;
      this.poin_initManage({"id":"showUserDetail"},function afterLoad(response,responseData){
        if(response.ok){
          let bchList=responseData.data.branchList;
          let tmpList=[]
          bchList.forEach((item) => {
            tmpList.push(item.BRANCH);
          });
          let roleList=responseData.data.roleList;
          let tmpList2=[]
          roleList.forEach((item2) => {
            tmpList2.push(item2.ROLEID);
          });
          $this.user.rolecode=tmpList2;
          $this.user.branchcode=tmpList;
          $this.user.id= responseData.data.id;
          $this.user.logName=responseData.data.extkey;
          $this.user.name= responseData.data.nam;
          $this.user.workorg= responseData.data.workorg;
          $this.user.mobilePhone=responseData.data.tel;
          $this.user.faxaPhone= responseData.data.fax;
          $this.user.postalcode= responseData.data.postalcode;
          $this.user.relgrp = responseData.data.relgrp;
          $this.user.authlevel = responseData.data.authlevel;
          $this.user.relcur = responseData.data.relcur;
          $this.user.relamt = responseData.data.relamt;
          $this.user.logPass=responseData.data.password;
          $this.user.email=responseData.data.eml;
          $this.user.workDept= responseData.data.workDept;
          $this.user.workDeptName=responseData.data.workDeptName;
          $this.user.confirmPass=responseData.data.confirmPass;
          $this.user.extfield1= responseData.data.extfield1;
          $this.user.extfield2= responseData.data.extfield2;
          $this.user.extfield3= responseData.data.extfield3;
          $this.user.extfield4= responseData.data.extfield4;
          $this.user.extfield5= responseData.data.extfield5;
          $this.user.state = responseData.data.secsta;
        }
      },function beforLoad(messageObj){
        messageObj.loading =true;
        messageObj.setUriParam({"id":$this.userID});	 
      });
    };
    this.poin_initManage({
    "id":"searchRoleOrg",
    'responseFields':{'total':'%OrgRelationGrid.total'},
    'requestFields':{'offset':'#offset','limit':'#limit'}},
    'afterGetUserRelations',
    'beforGetUserRelations');
  },
  methods : {
    bch_init(){
      Api.post('/admin/bch/getBchListForUsr',{}).then(res=>{
            this.branchlist = res.data;
          }
      )
    },
    role_init(){
      Api.post('/admin/role/getRoleList',{}).then(res=>{
            this.rolelist = res.data;
          }
      )
    },
    poin_initManage(messageKey,callback,execBefore){
      messageKey.vue = this;
      iscMessage.messageManage(messageKey,callback,execBefore);
    },
    async saveUser(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          if(this.userID == null){
            this.$confirm(this.$t('statics.是否确定添加用户?'), this.$t('statics.提示'), {
              confirmButtonText: this.$t('statics.确认'),
              cancelButtonText: this.$t('statics.取消'),
              type: "warning",
            }).then(async (res) => {
              let params = {
                extkey:this.user.logName,
                nam:this.user.name,
                passwd:this.user.logPass,
                secsta:this.user.state,
                tel:this.user.mobilePhone,
                fax:this.user.faxaPhone,
                eml:this.user.email,
                authlevel:this.user.authlevel,
                relgrp:this.user.relgrp,
                relcur:this.user.relcur,
                relamt:this.user.relamt,
                branch:this.user.branchcode,
                role:this.user.rolecode,
                workorg:this.user.workorg,
              };
              await Api.post('/admin/usr/addusr', params)
              .then((res) => {
                if (res.respCode == "AAAAAA" || res.respCode == "AAAAAA") {
                  this.$notify({
                    title: this.$t('components.成功'),
                    message: this.$t('components.校验成功'),
                    type: "success",
               });
                } else {
                  this.$notify({
                    title: this.$t('components.失败'),
                    message: this.$t('components.校验失败'),
                    type: 'error',
                  });
                }

              });
              //this.$router.push({name:'userSearch'});
              this.routerPush({
                path: '/iscOrganization/userManage'
              })
              this.$parent.$refs.userTable.refresh();
            });
          }else{
            this.$confirm(this.$t('statics.是否确定修改该用户?'), this.$t('statics.提示'), {
              confirmButtonText: this.$t('statics.确认'),
              cancelButtonText: this.$t('statics.取消'),
              type: "warning",
            }).then(async (res) => {
              let params = {
                extkey:this.user.logName,
                nam:this.user.name,
                secsta:this.user.state,
                tel:this.user.mobilePhone,
                fax:this.user.faxaPhone,
                eml:this.user.email,
                authlevel:this.user.authlevel,
                relgrp:this.user.relgrp,
                relcur:this.user.relcur,
                relamt:this.user.relamt,
                branch:this.user.branchcode,
                role:this.user.rolecode,
                workorg:this.user.workorg,
              };
              await Api.post('/admin/usr/updateusr', params).then((res) => {
                if (res.respCode == "AAAAAA" || res.respCode == "AAAAAA") {
                  this.$notify({
                    title: this.$t('components.成功'),
                    message: this.$t('components.校验成功'),
                    type: "success",
               });
                } else {
                  this.$notify({
                    title: this.$t('components.失败'),
                    message: this.$t('components.校验失败'),
                    type: 'error',
                  });
                }

              });;
              this.routerPush({
                path: '/iscOrganization/userManage'
              })
              this.$parent.$refs.userTable.refresh();
            });
          }
        } 
        
        // else {
        //   this.$notify({
        //     title: this.$t('components.失败'),
        //     message: this.$t('components.校验失败'),
        //     type: 'error',
        //   });
        // }
      });
    },
    beforGetUserRelations(messageObj){
      //根据用户查询所属机构,部门,工作组,岗位,角色表
      if(this.userID == null){
      //增加用户,不用查询关联表信息
        messageObj.closeFlag = true;
      }else{
        messageObj.closeFlag = false;
      }
      messageObj.setUriParam({"userid":this.userID});
    },
    beforGetRoleOrg(messageObj){
      //根据用户查询所属机构,部门,工作组,岗位,角色表
      if(this.userID == null){
      //增加用户,不用查询关联表信息
        messageObj.closeFlag = true;
      }else{
        messageObj.closeFlag = false;
      }
      messageObj.setUriParam({"userid":this.userID});
      messageObj.addRequestParam({
        "offset": 0,
      })
    },
    afterGetRole(res,data){
      if(res && res.ok && data){
        this.RoleGridList = data.rows
        }
    },
    afterGetUserRelations(res,data) {
      if(res && res.ok && data){
        var selectList = data.rows;
        this.orgDataList = [];
        for(var i =0; i < selectList.length; i++){
          var option = {};
          option.label = selectList[i].name;
          option.value = +selectList[i].nodeId;
          this.orgDataList.push(option);
        }   
          this.orgDataList.unshift({label:this.$t('statics.所有机构'),value: 0})
          this.selectDataList =  this.orgDataList.concat(this.departmentDataList)
        }
    },
    afterGetUserDepartment(res,data) {
      if(res && res.ok && data){
        var selectList = data.rows;
        this.departmentDataList = [];
        for(var i =0; i < selectList.length; i++){
          var option = {};
          option.label = selectList[i].name;
          option.value = +selectList[i].departmentNumber;
          this.departmentDataList.push(option);
        }
        this.selectDataList =  this.orgDataList.concat(this.departmentDataList)
        }
    },
    checkOrgBlong(){
      //选择归属行弹出框
      if(this.orgNode != null){
        //重新渲染机构树
        this.orgTreeData =[];
        this.searchChild(this.orgNode, this.orgResolve);
      }
      this.Dialogtitle = this.$t('statics.归属行');
      this.orgTreeDialogbtn =false;
      this.orgTreeblongbtn =true;
      this.openOrgDialog = true;
    
    },
    checkDeptBtn(){
      //选择归属部门->弹出框
      if(this.user.workorgName){
        this.openDeptDialog = true;
        if(this.deptNode != null){
          //需要重新渲染部门树
          this.deptTreeData =[];
          this.searchDeptChild(this.deptNode, this.deptResolve);
        }
      }else{
        this.$message({message: this.$t('statics.请先选择归属行!'),center: true,type: 'warning'});
      }
    },
    addOrglistBtn(){
      //增加机构->弹出框
      if(this.orgRow){
        this.orgRow = null;
        this.orgRadio = null;
      }
      if(this.userID == null){
        this.$message({message: this.$t('statics.请先保存用户信息!'),center: true,type: 'warning'});
      }else{
        if(this.orgNode != null){
          //需要重新渲染机构树
          this.orgTreeData =[];
          this.searchChild(this.orgNode, this.orgResolve);
        }
        this.Dialogtitle = this.$t('statics.机构数据');
        this.orgTreeDialogbtn =true;
        this.orgTreeblongbtn =false;
        this.openOrgDialog = true;
      }
    },
    addDeptlistBtn(){
    //增加部门列表->弹出框
    if(this.departRow){
        this.departRow = null;
        this.departRadio = null;
      }
      if(this.userID == null){
        this.$message({message: this.$t('statics.请先保存用户信息!'),center: true,type: 'warning'});
      }else{
      this.openDepartDialog =true;
      this.$nextTick(()=>{
        var node = this.$refs.departTree.getCurrentNode();
          if(node != null){
          this.$refs.departTree.setCurrentKey(null);
          }
      })
      }
    },
    saveOrgBtn(){
      //修改机构保存
      var $this = this;
      this.relationTableRef = "OrgRelationGrid";
      var selectData = this.orgRow;
      if(selectData != null && selectData.ifDefault == 1 && selectData.state == 0){
        $this.$message({message: this.$t('statics.默认机构不能为锁定状态!'),center: true,type: 'warning'});
        // 清空选中状态
        this.orgRow =null;
        this.orgRadio ='';
        // 刷新当前表格
        this.$refs[this.relationTableRef].refresh();
        return;
      }
      this.poin_initManage({'id':'saveOrgd'},'saveUserRelation',function beforSaveOrgD(messageObj){
        //后台返回的字符串,默认是json,所以这里指定一下类型
        //messageObj.responseType="text/html";
        if(selectData != null){
          messageObj.closeFlag = false;
          messageObj.setData(JSON.stringify([{"departId":selectData.id,"state":selectData.state,"ifDefault":selectData.ifDefault,"personId":$this.userID}]));
          //记录当前点击的行 和 按钮
          $this.clickListRow = "orgRow";
          $this.clickRowRadio = "orgRadio";
        }else{
          $this.$message({message: this.$t('statics.请选择一条数据修改!'),center: true,type: 'warning'});
          messageObj.closeFlag = true;
        }
      })
    },
    saveDeptBtn(){
      //修改部门保存
      var $this = this;
      this.relationTableRef = "DepartRelationGrid";
      var selectData = this.departRow;
      this.poin_initManage({'id':'saveDepart'},'saveUserRelation',function beforSaveOrgD(messageObj){
        if(selectData != null){
          messageObj.closeFlag = false;
          messageObj.setData(JSON.stringify({"departId":selectData.departmentNumber,"state":selectData.state,"personId":$this.userID}));
          //记录当前点击的行 和 按钮
          $this.clickListRow = "departRow";
          $this.clickRowRadio = "departRadio";
        }else{
          $this.$message({message: this.$t('statics.请选择一条数据修改!'),center: true,type: 'warning'});
          messageObj.closeFlag = true;
        }
      })
    },
    saveGroupBtn(){
      //修改工作组保存
      var $this = this;
      this.relationTableRef = "GroupRelationGrid";
      var selectData = this.groupRow;
      this.poin_initManage({'id':'saveGroup'},'saveUserRelation',function beforSaveOrgD(messageObj){
        if(selectData != null){
          messageObj.closeFlag = false;
          messageObj.setData(JSON.stringify({"groupId":selectData.id,"state":selectData.state,"personId":$this.userID}));
          //记录当前点击的行 和 按钮
          $this.clickListRow = "groupRow";
          $this.clickRowRadio = "groupRadio";
        }else{
          $this.$message({message: this.$t('statics.请选择一条数据修改!'),center: true,type: 'warning'});
          messageObj.closeFlag = true;
        }
      })
    },
    savePostBtn(){
      //修改岗位保存
      var $this = this;
      this.relationTableRef = "PostRelationGrid";
      var selectData = this.postRow;
      this.poin_initManage({'id':'savePost'},'saveUserRelation',function beforSaveOrgD(messageObj){
        if(selectData != null){
          messageObj.closeFlag = false;
          messageObj.setData(JSON.stringify({"postId":selectData.id,"state":selectData.state,"personId":$this.userID}));
          //记录当前点击的行 和 按钮
          $this.clickListRow = "postRow";
          $this.clickRowRadio = "postRadio";
        }else{
          $this.$message({message: this.$t('statics.请选择一条数据修改!'),center: true,type: 'warning'});
          messageObj.closeFlag = true;
        }
      })
    },
    saveRoleBtn(){
      //修改角色保存
      var $this = this;
      this.relationTableRef = "RoleRelationGrid";
      var selectData = this.roleRow;
      if(selectData != null && selectData.ifDefault == 1 && selectData.state == 0){
        $this.$message({message: this.$t('statics.默认角色不能为锁定状态!'),center: true,type: 'warning'});
        // 清空选中状态
        this.roleRow =null;
        this.roleRadio ='';
        // 刷新当前表格
        this.$refs[this.relationTableRef].refresh();
        return;
      }
      this.poin_initManage({'id':'saveRole'},'saveUserRelation',function beforSaveOrgD(messageObj){
        if(selectData != null){
          messageObj.closeFlag = false;
          messageObj.setData(JSON.stringify({"roleId":selectData.id,"state":selectData.state,"ifDefault":selectData.ifDefault,"personId":$this.userID,"departmentId":selectData.departmentId,"oldDepartmentId":selectData.oldDepartmentId,"priority":selectData.priority}));
          //记录当前点击的行 和 按钮
          $this.clickListRow = "roleRow";
          $this.clickRowRadio = "roleRadio";
        }else{
          $this.$message({message: this.$t('statics.请选择一条数据修改!'),center: true,type: 'warning'});
          messageObj.closeFlag = true;
        }
      })
    },
    delOrgBtn(){
      //删除机构
      var $this = this;
      this.relationTableRef = "OrgRelationGrid";
      var selectData = this.orgRow;
      if(selectData != null){
        if(selectData.ifDefault == 1){
          $this.$message({message: this.$t('statics.不能删除默认机构!'),center: true,type: 'warning'});
          return;
        }
        $this.$confirm('确定要删除该机构吗?', '提示', {
                confirmButtonText: this.$t('statics.确定'),
                cancelButtonText: this.$t('statics.取消'),
                type: 'warning'
              }).then(() => {
              this.poin_initManage({'id':'delOrgd'},'afterDelUserRelation',function beforeDelOrgD(messageObj){
              messageObj.setUriParam({
                "userid":$this.userID,
                "orgid":selectData.id
              });
              $this.clickListRow = "orgRow";
              $this.clickRowRadio = "orgRadio";
            });
            this.deleteRelatedOrg(selectData.id,$this.userID);
              }).catch(() => {
                $this.$message({
                  type: 'info',
                  message: this.$t('statics.已取消删除')
                });          
              });	
        }else{
          $this.$message({message: this.$t('statics.请选择一条数据进行删除!'),center: true,type: 'warning'});
        }
    },
    delDeptBtn(){
      //删除部门
      var $this = this;
      this.relationTableRef = "DepartRelationGrid";
      var selectData = this.departRow;
      if(selectData != null){
        $this.$confirm(this.$t('statics.删除该部门将会连同该部门对应角色一同删除,确认删除吗?'), this.$t('statics.提示'), {
                confirmButtonText: this.$t('statics.确定'),
                cancelButtonText: this.$t('statics.取消'),
                type: 'warning'
              }).then(() => {
                this.poin_initManage({'id':'delDepart'},'afterDelUserRelation',function beforeDelOrgD(messageObj){
              messageObj.setUriParam({
                "userid":$this.userID,
                "departId":selectData.departmentNumber
              });
              $this.clickListRow="departRow";
              $this.clickRowRadio = "departRadio";
                });
              }).catch(() => {
                $this.$message({
                  type: 'info',
                  message: this.$t('statics.已取消删除')
                });          
              });	
      }else{
        $this.$message({message: this.$t('statics.请选择一条数据进行删除!'),center: true,type: 'warning'});
        }
    },
    delGroupBtn(){
      //删除工作组
      var $this = this;
      this.relationTableRef = "GroupRelationGrid";
      var selectData = this.groupRow;
      this.poin_initManage({'id':'delGroup'},'afterDelUserRelation',function beforeDelOrgD(messageObj){
        if(selectData != null){
          messageObj.closeFlag = false;
          messageObj.setUriParam({
            "userid":$this.userID,
            "groupid":selectData.id
          });
          $this.clickListRow ="groupRow";
          $this.clickRowRadio = "groupRadio";
        }else{
          $this.$message({message: this.$t('statics.请选择一条数据进行删除!'),center: true,type: 'warning'});
          messageObj.closeFlag = true;
        }
      });
    },
    delPostBtn(){
      //删除岗位
      var $this = this;
      this.relationTableRef = "PostRelationGrid";
      var selectData = this.postRow;
      this.poin_initManage({'id':'delPost'},'afterDelUserRelation',function beforeDelOrgD(messageObj){
        if(selectData != null){
          messageObj.closeFlag = false;
          messageObj.setUriParam({
            "userid":$this.userID,
            "postid":selectData.id
          });
          $this.clickListRow ="postRow";
          $this.clickRowRadio = "postRadio";
        }else{
          $this.$message({message: this.$t('statics.请选择一条数据进行删除!'),center: true,type: 'warning'});
          messageObj.closeFlag = true;
        }
      });
    },
    delRoleBtn(){
      //删除角色
      var $this = this;
      this.relationTableRef = "RoleRelationGrid";
      var selectData = this.roleRow;
      if(selectData != null && selectData.ifDefault == 1){
        $this.$message({message: this.$t('statics.不能删除默认角色!'),center: true,type: 'warning'});
        return;
      }
      if(selectData != null){
        $this.$confirm(this.$t('statics.确定要删除该角色吗?'), this.$t('statics.提示'), {confirmButtonText: this.$t('statics.确定'),cancelButtonText: this.$t('statics.取消'),type: 'warning'})
        .then(() => {
          this.poin_initManage({'id':'delRole'},'afterDelUserRelation',function beforeDelOrgD(messageObj){
            messageObj.closeFlag = false;
            messageObj.setUriParam({
              "userid":$this.userID,
              "roleid":selectData.id,
              "departmentid":selectData.departmentId
            });
            $this.clickListRow ="roleRow";
            $this.clickRowRadio = "roleRadio";
          });
        })
        .catch(() => {$this.$message({type: 'info', message: this.$t('statics.已取消删除')})});
      } else {
        $this.$message({message: this.$t('statics.请选择一条数据进行删除!'),center: true,type: 'warning'});
      }
    },
    saveUserRelation(response,responseData){
      //执行机构,部门,岗位,角色,工作组【修改保存】
      if(response.ok){
        if(this.clickListRow == "orgRow" && responseData.canModify == "false"){
          this[this.clickListRow].ifDefault = 1;
          this[this.clickListRow] =null;
          this[this.clickRowRadio] ='';
          this.$message({message: this.$t('statics.必须要有一条默认机构!'),center: true,type: 'error'});
          return;
        }
        if(this.clickListRow == "roleRow" && responseData.canModify == "false"){
          this[this.clickListRow].ifDefault = 1;
          this[this.clickListRow] =null;
          this[this.clickRowRadio] ='';
          this.$message({message: this.$t('statics.必须要有一条默认角色!'),center: true,type: 'error'});
          return;
        }
        //成功后把当前操作行状态清空
        this[this.clickListRow] =null;
        this[this.clickRowRadio] ='';
        this.$message({message: this.$t('statics.保存成功!'),center: true,type: 'success'});
        //刷新当前表格
        this.$refs[this.relationTableRef].refresh();
      }else{
      //提示错误
        //把当前操作行状态清空
        this[this.clickListRow] =null;
        this[this.clickRowRadio] ='';
        //刷新当前表格
        this.$refs[this.relationTableRef].refresh();
        this.$message({message:responseData.errorMsg,center: true,type: 'warning'});
      }
    },
    afterDelUserRelation(response,responseData){
      //执行机构,部门,岗位,角色,工作组【删除】
      if(response.ok){
        //当前点击行删除后,清除行数据对象
        this[this.clickListRow] = null;
        this[this.clickRowRadio] ='';
        if(responseData){
          this.$message({message: this.$t('statics.删除成功!'),center: true,type: 'success'});
          this.poin_initManage({"id":"searchRoleOrg",'responseFields':{},'requestFields':{'limit':'#limit'}},'afterGetUserRelations','beforGetRoleOrg')

        }else{
          this.$message({message: this.$t('statics.数据不存在/已删除!'),center: true,type: 'warning'});
        }
      //刷新当前表格
      this.$refs[this.relationTableRef].refresh();
      //刷新角色表格
      this.$refs.RoleRelationGrid.refresh();
      }else{
      //提示错误
      this.$message({message:responseData.errorMsg,center: true,type: 'warning'});
      }
    },
    searchChild(node, resolve){
      //渲染机构树方法
      var $this= this;
      if(node.level == 0){
        //保存顶级对象,用于再次刷新树渲染
        this.orgNode = node;
        this.orgResolve = resolve;
        //加载树的根节点
        this.poin_initManage({"id":"getOrgParentTree"},function aftert(response,responseData,messageObj){
        var treeDatas=[];
        if(response.ok){
            treeDatas = iscMessage.arrayToTree(responseData,'0','id','pid');
        }else{
            $this.$message({message: responseData.errorMsg,center: true,type: 'error'});
        }
          resolve(treeDatas);
        });
      }else{
        var nodeid = node.data.id;
        //根据id加载子节点
        this.poin_initManage({"id":"getOrgChildTree"},function aftert(response,responseData,messageObj){
          var treeDatas=[];
          if(response.ok){
            //子节点的数据处理
              treeDatas = iscMessage.arrayToTree(responseData,nodeid,'id','pid');
          }else{
              $this.$message({message: responseData.errorMsg,center: true,type: 'error'});
          }
            resolve(treeDatas);
        },function beforeGet(messageObj){
          messageObj.setUriParam({'parentid':nodeid});
        });
      }
    },
    searchDeptChild(node, resolve){
      //渲染归属部门树方法
      var $this= this;
      if(node.level == 0){
        //保存顶级对象,用于再次刷新树渲染
        this.deptNode = node;
        this.deptResolve = resolve;
        //查询顶级树节点
        this.poin_initManage({"id":"getDeptTree"},function aftert(response,responseData,messageObj){
        var treeDatas=[];
        if(response.ok){
            treeDatas = iscMessage.arrayToTree(responseData,responseData[0].pid,'id','pid');
        }else{
            $this.$message({message: responseData.errorMsg,center: true,type: 'error'});
        }
          resolve(treeDatas);
        },function beforeGet(messageObj){
          messageObj.setUriParam({'workorg':$this.user.workorg});
        });
      }else{
        var nodeid = node.data.id;
        this.poin_initManage({"id":"getDeptTreeChild"},function aftert(response,responseData,messageObj){
          var treeDatas=[];
          if(response.ok){
            //子节点的数据处理
              treeDatas = iscMessage.arrayToTree(responseData,nodeid,'id','pid');
          }else{
              $this.$message({message: responseData.errorMsg,center: true,type: 'error'});
          }
            resolve(treeDatas);
        },function beforeGet(messageObj){
          messageObj.setUriParam({'departmentNumber':nodeid});
        });
      }
    },
    searchDepartTree(node, resolve){
      //渲染部门数据树方法
      var $this= this;
      if(node.level == 0){
        this.poin_initManage({"id":"getDepartTreeA"},function aftert(response,responseData,messageObj){
        var treeDatas=[];
        if(response.ok){
            treeDatas = iscMessage.arrayToTree(responseData,responseData[0].pid,'id','pid');
        }else{
            $this.$message({message: responseData.errorMsg,center: true,type: 'error'});
        }
          resolve(treeDatas);
        });
      }else{
        var nodeid = node.data.id;
        this.poin_initManage({"id":"getDeptTreeChild"},function aftert(response,responseData,messageObj){
          var treeDatas=[];
          if(response.ok){
            //子节点的数据处理
              treeDatas = iscMessage.arrayToTree(responseData,nodeid,'id','pid');
          }else{
              $this.$message({message: responseData.errorMsg,center: true,type: 'error'});
          }
            resolve(treeDatas);
        },function beforeGet(messageObj){
          messageObj.setUriParam({'departmentNumber':nodeid});
        });
      }
    },
    addOrgBtn(tree,tables){
      //添加机构, 提交操作
      var node = this.$refs[tree].getCurrentNode();
      var $this = this;
      if(!node){
        this.$message({message: this.$t('statics.请选择完再提交!'),center: true,type: 'warning'});
      }else{
        this.poin_initManage({'id':'saveOrgUserRel'},function afterSave(response,data){
        if(response.ok){
          if(parseInt(data.orgSize) > 1){
            $this.$message({message: this.$t('statics.保存用户所属机构成功,请配置默认机构!'),center: true,type: 'warning'});
          } else {
            $this.$message({message: this.$t('statics.保存用户所属机构成功!'),center: true,type: 'success'});
          }
          $this.$refs[tables].refresh();
          $this.openOrgDialog = false;
          //add by fanyuzhe @2019-12-12 重新获取角色页签中的下拉框数据
          $this.poin_initManage({"id":"searchRoleOrg",'responseFields':{},'requestFields':{'limit':'#limit'}},'afterGetUserRelations','beforGetRoleOrg')
          //add by lujing@date2019-10-17 重置树选中
          $this.$refs[tree].store.setCurrentNodeKey(null);
          // 新增用户关联机构信息
          $this.saveRelatedOrg(node.cls,$this.userID);
        }else{
          if(data.errorMsg){
            $this.$message({message: data.errorMsg,center: true,type: 'error'});
          }
        }
        },function beforSaveOrgD(messageObj){
          messageObj.setData({"departId":node.cls,"personId":$this.userID});
        })
      }
    },
    // 新增用户关联机构信息
    saveRelatedOrg(departId,personId){
      this.poin_initManage({'id':'saveInfo'},function afterSave(response,data){

      },function beforSaveOrgD(messageObj){
        messageObj.setData([{"departId":departId,"userdetailsid":personId}]);
      })
    },
    // 删除用户关联机构信息
    deleteRelatedOrg(departId,personId){
      this.poin_initManage({'id':'deleteInfo'},function afterSave(response,data){

      },function beforSaveOrgD(messageObj){
        messageObj.setData({"departId":departId,"userdetailsid":personId});
      })
    },
    handleClick(tab, event) {
      if("usrRelOrg" == tab.name){
        this.$refs.usrRelOrgChild.searchTable(this.userID);
      }
      // 这里不用tab.name 是因为一旦加上tab.name,会导致页面不显示,原因未知
      if("0" == tab.paneName){
        this.checkUserInfo();
      }
    },
    // 校验用户是否为总行用户
    // checkUserInfo(){
    //   var $this = this;
    //   if($this.userID == undefined || $this.userID == ""){
    //
    //   } else {
    //     this.poin_initManage({'id':'checkUser'},function afterSave(response,data){
    //       if(response.ok){
    //         if(data){
    //           $this.isFieldDisabled = false;
    //         } else {
    //           $this.isFieldDisabled = true;
    //           $this.user.authlevel = "";
    //           $this.user.authority = "0"; // 否
    //         }
    //       }
    //     },function beforSaveOrgD(messageObj){
    //       messageObj.setUriParam({"id":$this.userID});
    //     })
    //   }
    // },
    addOrgblongBtn(tree){
      //选择归属行提交
      var node = this.$refs[tree].getCurrentNode();
      if(node){
        this.user.workorg = node.id;
        this.user.workorgName = node.text;
        //归属部门清空
        if(this.user.workDept){
          this.user.workDept = "";
          this.user.workDeptName = "";
        }
        this.openOrgDialog = false;
        //add by lujing@date2019-10-17 重置树选中
        this.$refs[tree].store.setCurrentNodeKey(null);
      }else{
        this.$message({message: this.$t('statics.请选择完再提交!'),center: true,type: 'warning'});
      }
    },
    addDeptBtn(tree){
      //归属部门提交
      var $this = this;
      var node = this.$refs[tree].getCurrentNode();
      if(node){
        $this.poin_initManage({'id':'getDepartFlag'},function afterSave(response,data){
        if(response.ok){
          if (data.flag == 0 || data.flag == 1) {
              $this.$message({message: this.$t('statics.请选择部门的节点提交!'),center: true,type: 'warning'});
              return;
            } else {
              //传递值,并关闭弹框
              $this.user.workDept = node.id;
              $this.user.workDeptName = node.text;
              $this.openDeptDialog = false;
              //add by lujing@date2019-10-17 重置树选中
              $this.$refs[tree].store.setCurrentNodeKey(null);
            }
        }else{
            $this.$message({message: data.errorMsg,center: true,type: 'error'});
        }
        },function beforS(messageObj){
            messageObj.setUriParam({"departnum" : node.id});
        });
      }else{
        this.$message({message: this.$t('statics.请选择完再提交!'),center: true,type: 'warning'});
      }
    },
    addDepartBtns(tree,tables){
      //添加部门 提交操作
      var node = this.$refs[tree].getCurrentNode();
      var $this = this;
      if(!node){
        this.$message({message: this.$t('statics.请选择完再提交!'),center: true,type: 'warning'});
      }else{
        this.poin_initManage({'id':'saveDepartRe'},function afterSave(response,responseData){
          if(response.ok){
            if (responseData.flag == 0 || responseData.flag == 1) {
              $this.$message({message: this.$t('statics.请选择一个部门!'),center: true,type: 'warning'});
              return;
            }
            $this.$message({message: this.$t('statics.保存用户部门成功!'),center: true,type: 'success'});
            $this.openDepartDialog = false;
            //add by lujing@date2019-10-17 重置树选中
            $this.$refs[tree].store.setCurrentNodeKey(null);
            $this.$refs[tables].refresh();
          }else{
            $this.$message({message:responseData.errorMsg,center: true,type: 'error'});
          }
        },function beforSaveOrgD(messageObj){
          messageObj.setData({"departId":node.id,"personId":$this.userID});
        })
      }
    },
    selectCityByPro(bol,citypam){
      //根据省份查城市
      var $this = this;
      var provinceid = this.user.province;
      if(provinceid){
        this.user.city="";
        this.poin_initManage({"id":"getCitys","responseFields":{"$cityList":{"text":"label","value":"value"}}},function after(response){
          if(response.ok && !bol &&citypam){
            $this.user.city = citypam.toString();
          }
        },function beforeGet(messageObj){
          messageObj.setUriParam({'provinceid':provinceid});
        });
      }
    },
    addGroupBtn(){
    //增加所属工作组按钮
    if(this.groupRow){
        this.groupRow = null;
        this.groupRadio = null;
      }
    var $this = this;
    $this.groupTreeData = [];
    if(this.userID == null){ 
        this.$message({message: this.$t('statics.请先保存用户信息!'),center: true,type: 'warning'});
      }else{
        this.poin_initManage({"id":"selectGroupTree"},function afterG(response,responseData){
          if(response.ok){
          $this.groupTreeData = iscMessage.arrayToTree(responseData,'0');
          }else{
            if(responseData.errorMsg){
              $this.$message({message: responseData.errorMsg,center: true,type: 'error'});
            }
          }
        },function beforeGet(messageObj){
            messageObj.setUriParam({'userid':$this.userID});
        });
      this.openGroupDialog = true;
    }
    },
    addGroupBtns(tree,tables){
    //添加工作组提交操作
      var node = this.$refs[tree].getCurrentNode();
      var $this = this;
      if(!node){
        this.$message({message: this.$t('statics.请选择完再提交!'),center: true,type: 'warning'});
      }else{
        this.poin_initManage({'id':'submitGroup'},function afterSave(response,responseData){
          if(response.ok){
            $this.$message({message: this.$t('statics.保存工作组成功!'),center: true,type: 'success'});
            $this.$refs[tables].refresh();
            $this.openGroupDialog = false;
            //add by lujing@date2019-10-17 重置树选中
            $this.$refs[tree].store.setCurrentNodeKey(null);
          }else{
            if(responseData.errorMsg){
              $this.$message({message: responseData.errorMsg,center: true,type: 'error'});
            }
          }
        },function beforSaveOrgD(messageObj){
          messageObj.setData({"groupId":node.id,"personId":$this.userID});
        })
      }
    },
    addPostBtn(){
    //增加岗位 按钮
    if(this.postRow){
        this.postRow = null;
        this.postRadio = null;
      }
    var $this = this;
    $this.postTreeData = [];
    if(this.userID == null){
        this.$message({message: this.$t('statics.请先保存用户信息!'),center: true,type: 'warning'});
      }else{
        this.poin_initManage({"id":"selectPostTree"},function afterG(response,responseData){
          if(response.ok){
            $this.postTreeData = iscMessage.arrayToTree(responseData,'0');
          }else{
            $this.$message({message: responseData.errorMsg,center: true,type: 'error'});
          }
        },function beforeGet(messageObj){
          messageObj.setUriParam({'userid':$this.userID});
        });
      this.openPostDialog = true;
    }
    },
    addPostBtns(tree,tables){
      //添加岗位 提交操作
      var node = this.$refs[tree].getCurrentNode();
      var $this = this;
      if(!node){
        this.$message({message: this.$t('statics.请选择完再提交!'),center: true,type: 'warning'});
      }else{
        this.poin_initManage({'id':'submitPost'},function afterSave(response,responseData){
          if(response.ok){
            $this.$message({message: this.$t('statics.保存用户岗位成功!'),center: true,type: 'success'});
            $this.openPostDialog = false;
            //add by lujing@date2019-10-17 重置树选中
            $this.$refs[tree].store.setCurrentNodeKey(null);
            $this.$refs[tables].refresh();
          }else{
            if(responseData.errorMsg){
              $this.$message({message: responseData.errorMsg,center: true,type: 'error'});
            }
          }
        },function beforSaveOrgD(messageObj){
          messageObj.setData({"postId":node.id,"personId":$this.userID});
        })
      }
    },
    addRoleBtn(){
    if(this.roleRow){
        this.roleRow = null;
        this.roleRadio = null;
      }
    //增加角色按钮
      var $this = this;
      if(this.userID == null){
        this.$message({message: this.$t('statics.请先保存用户信息!'),center: true,type: 'warning'});
      }else{
        if('10230' == JSON.parse(window.sessionStorage.curRole).id){
          this.poin_initManage({"id":"selectRoletree"},function afterG(response,responseData){
            if(response.ok){
              $this.RoleTreeData = iscMessage.arrayToTree(responseData,'0');
            }else{
              if(responseData.errorMsg){
                $this.$message({message: responseData.errorMsg,center: true,type: 'error'});
              }
            }
          });
        } else {
          this.poin_initManage({"id":"selectSubRoletree"},function afterG(response,responseData){
            if(response.ok){
              $this.RoleTreeData = iscMessage.arrayToTree(responseData, JSON.parse(window.sessionStorage.curRole).parentRoleId);
            }else{
              if(responseData.errorMsg){
                $this.$message({message: responseData.errorMsg,center: true,type: 'error'});
              }
            }
          },function beforeGet(messageObj){
              messageObj.setUriParam({'currentLoginUserRoleId':JSON.parse(window.sessionStorage.curRole).id});
          });
        }
        this.openRoleDialog = true;
      }
    },
    addRoleBtns(tree,tables){
      //添加角色 提交操作
      var node = this.$refs[tree].getCurrentNode();
      var $this = this;
      if(!node){
        this.$message({message: this.$t('statics.请选择完再提交!'),center: true,type: 'warning'});
      }else{
        this.poin_initManage({'id':'submitRole'},function afterSave(response,responseData){
          if(response.ok){
            if(parseInt(responseData.roleSize) > 1){
              $this.$message({message: this.$t('statics.保存用户角色成功,请配置默认角色!'),center: true,type: 'warning'});
            } else {
              $this.$message({message: this.$t('statics.保存用户角色成功!'),center: true,type: 'success'});
            }
            $this.openRoleDialog = false;
            //add by lujing@date2019-10-17 重置树选中
            $this.$refs[tree].store.setCurrentNodeKey(null);
            $this.$refs[tables].refresh();
          }else{
            if(responseData.errorMsg){
              $this.$message({message: responseData.errorMsg,center: true,type: 'error'});
            }
          }
        },function beforSaveOrgD(messageObj){
          messageObj.setData(JSON.stringify({"roleId":node.id,"personId":$this.userID}));
        })
      }
    },
    clickOrgRow(row){
      //点击机构列表行
      this.orgRadio = this.OrgGridList.indexOf(row);
      this.orgRow = row;
    },
    clickDepartRow(row){
      //点击部门列表行
      this.departRadio = this.DepartGridList.indexOf(row);
      this.departRow = row;
    },
    clickGroupRow(row){
      //点击工作组列表行
      this.groupRadio = this.GroupGridList.indexOf(row);
      this.groupRow = row;
    },
    clickPostRow(row){
      //点击岗位列表行
      this.postRadio = this.PostGridList.indexOf(row);
      this.postRow = row;
    },
    clickRoleRow(row){
      //点击角色列表行
      this.roleRadio = this.RoleGridList.indexOf(row);
      this.roleRow = row;
    },
    validatePass2(rule, value, callback){
      if (value === '') {
            callback(new Error(this.$t('statics.请再次输入密码')));
          } else if (value !== this.user.logPass) {
            callback(new Error(this.$t('statics.两次输入密码不一致')));
          } else {
            callback();
          }
    },
    changePassW(){
      this.user.logPass="";
      this.setPassWord = true;
      this.$notify.warning({
        title: this.$t('statics.提示'),
        message: this.$t('statics.请重新输入密码之后点击‘提交’!')
      });
    },
    goBack(){
      //this.$router.push({name:'userSearch'});
      this.routerPush({
            path: '/iscOrganization/userManage'
          })
      this.$parent.$refs.userTable.refresh();
    },
    //add by lujing 关闭弹出框和取消按钮,重置树选中节点
    closeAndResetTree(close,tree){
      //add by lujing@date2019-10-17 重置树选中
      this[close]= false;
      var node = this.$refs[tree].getCurrentNode();
      if(node){
        this.$refs[tree].store.setCurrentNodeKey(null);
      }
    },
    confirmEdit(index, row, ref) {
      this.RoleGridList[index].priority = this.editPriority;
      this.$refs[ref].doClose();
    },
    cancelEdit(ref) {
      this.$refs[ref].doClose();
    },
    editColumn(index, row) {
      this.editPriority = row.priority;
    }
  },
  beforeDestroy() {
    this.$parent.hideChild = true;
  }
}
</script>
<style type="text/css" lang="less">
.userD-mag{
 .requireds .el-form-item__label:before{
    content: '*';
    color: #f56c6c;
    margin-right: 4px;
   }
	.el-form .subBtn>.el-button{
	margin-right:50px
}
	.dialog-tree{
	height:410px;
	overflow: auto;
 }
 .el-table__row{
	 a{
		color: #000;
		text-decoration: none;
		border-bottom: dashed 1px #0088cc;
	}
 }
 .fontdashed {
	 cursor:pointer;
	 border-bottom: dashed 1px #0088cc;
 }
}
</style>