<template>
  <div class="about">
    <content-header>
      <template v-slot:header>修改机构信息</template>
    </content-header >
  <content-form interval-width="40px" ref="child" />
    <!-- <div class="button-submit" disabled="true" @click="submitForm" ><span  >提 交</span></div> -->
      <el-button  class="button-submit" :disabled="submitDisabled" @click='submitForm()' type="primary">提 交</el-button>

    <template>
      <dialog-box :dialogVisible.sync="dialogVisible" >
        <template v-slot:show-errtitle>{{dialogErrTltle}}</template>
        <template v-slot:show-text>{{dialogVisibleIf}}</template>
        <el-button @click="dialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="dialogVisible = false">确 定</el-button>
      </dialog-box>
    </template>
  </div>
</template>
<script>
//  interval-width="40px"  控制表单列间隔
import ContentHeader from '@/common/components/ContentHeader.vue'
import ContentForm from '@/components/modifyOrgan/ContentForm.vue'
import DialogBox from '@/common/components/DialogBox.vue'
import {startFun} from  './test.js'

export default {
  name: 'ModifyOrgan',
  data(){
    return{
      mechanismData:{},
      resGetUserInfo : {}, //登录账号信息
      dialogVisible: false, //是否显示弹框
      dialogErrTltle: '',  //错误表头titlt
      dialogVisibleIf: '表单数据错误',
      submitDisabled: false
    }
  },
  created(){
    setTimeout(() => {
      this.getAxiosData() 
    }, 1000);
      
   
  },
  methods:{
    submitForm(){ 
      if(this.$refs.child.submitForm()){
       this.submitDisabled = true
        setTimeout(() => {
          this.submitDisabled = false
        }, 3000);
        let arr = []
        arr.push(this.$refs.child.userForm)
      
        let INST_RELATION_LISTGet = JSON.stringify(arr)
        let resGetUserInfo = this.resGetUserInfo
        let userFormObj={
          USER_CODE: resGetUserInfo.USERCODE,
          INST_USER_CODE: resGetUserInfo.USERCODE,
          USER_TYPE: this.mechanismData.USER_TYPE,
          BUSIN_TYPE: this.mechanismData.BUSIN_TYPE,
          BUSIN_DEPT: this.mechanismData.BUSIN_DEPT,
          GTJA_RELATION_LIST: JSON.stringify(this.mechanismData.GTJA_RELATION_LIST),
          INST_RELATION_LIST: INST_RELATION_LISTGet,
          SYSTEM_ID:'79',
          ACTION_TYPE:'1',
          OPERATOR:this.resGetUserInfo.USER_CUSTID,
        }
        fql.WFW_USER_MANAGE_SERVICE['设置机构信息'](userFormObj)
        .then(res =>{
          if(res.list == undefined){throw new Error(res);}
          if(res.RNUM ==0){
            this.dialogErrTltle = ''  //提示信息
            this.dialogVisibleIf =  '修改成功'
            this.dialogVisible = true
            this.$refs.child.resetForm()
            this.getAxiosData()
          }else{
            throw new Error(res.msg)
          }
        })    
        .catch( err =>{
          this.dialogErrTltle = '修改失败！'
          this.dialogVisibleIf =  'W12001020  错误信息'+ err
          this.dialogVisible = true
        })
      }
    },
    //获取业务类型和部门
    getAxiosData(){
      const _this = this;
      this.$GetUserInfo.then(res=>{
        _this.resGetUserInfo = res
        startFun(res,1)
        const mechanismQueryData={
        USER_CODE: _this.resGetUserInfo.USERCODE,
        INST_USER_CODE: _this.resGetUserInfo.USERCODE,
        SYSTEM_ID : '79', //子系统编号
        ACTION_TYPE : '1', //操作类型
        OPERATOR : _this.resGetUserInfo.USER_CUSTID //操作员
      }
      fql.WFW_USER_MANAGE_SERVICE['查询机构信息'](mechanismQueryData).then(function(res){
        if(res.list == undefined){throw new Error(res);}
        if(res.RNUM != "1"){throw new Error(res.msg)}
        // _this.userInformation = res.list[0].RIGHT_LIST
        _this.mechanismData = res.list[0]

      })
      .catch( err =>{
        _this.dialogErrTltle = '查询失败！'
        _this.dialogVisibleIf =  'W12001019  错误信息'+err
        _this.dialogVisible = true
      })
      })
  
    }
  },
   watch:{
    mechanismData(val,obval){
      console.log( this.$refs.child.dataLeft[1].value = val.BUSIN_TYPE);
      console.log( this.$refs.child.dataLeft[2].value = val.BUSIN_DEPT);
      // this.getAxiosData()
    }
  },
  computed:{
    getaaa(){
      return this.$store.state.userInfo
    }
  },
  components: {
    ContentHeader,//公共
    ContentForm,
    DialogBox //弹框
  },
}
</script>
<style scoped>
/* 提交按钮Style */
.button-submit{
 display: block;
  width: 102px;
  height: 30px;
  border-radius: 2px;
  padding: 0;
  text-align: center;
  margin-left: 154px;
  margin-top: 24px;
  margin-bottom: 24px;
  background: #2E5DED !important;
}


</style>