<template>
  <div class="approvalDialog">
    <el-dialog 
      title="服务申请审批" 
      :visible.sync="dialogFormVisible" 
      :before-close="cancelRegister"
      top="4%"
      width="600px">

      <el-form :inline="true">
        <el-form-item label="系统名称：">
          <el-input placeholder="系统名称" v-model="form.applyname" disabled></el-input>
        </el-form-item>
        <el-form-item  class="address" label="申请系统地址：">
          <el-input type="textarea" resize="none" placeholder="申请系统地址" disabled v-model="form.applySysUrl">
          </el-input>
        </el-form-item>
        <el-form-item  class="applypeoplename" label="申请人：">
          <el-input resize="none" placeholder="申请人" disabled v-model="form.applypeoplename">
          </el-input>
        </el-form-item>
        <el-form-item  class="applyreason" label="申请原因：">
          <el-input resize="none" placeholder="申请原因" disabled v-model="form.applyreason">
          </el-input>
        </el-form-item>
        <el-form-item  class="applytime" label="申请时间：">
          <el-input resize="none" placeholder="申请时间" disabled v-model="form.applytime">
          </el-input>
        </el-form-item>
        <el-form-item label="是否通过：">
          <el-radio class="radio" v-model="form.radio" label="1">是</el-radio>
          <el-radio class="radio" v-model="form.radio" label="-1">否</el-radio>
        </el-form-item>
        <el-form-item label="审批意见：">
          <el-input
            type="textarea"
            placeholder="请输入内容"
            v-model="form.opinion">
          </el-input>
        </el-form-item>
      </el-form>

      <div slot="footer" class="dialog-footer" v-show="detailShow">
        <el-button @click="cancelRegister">取 消</el-button>
        <el-button type="primary" @click="dialogSure">确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
  import Api from '@/api/index.js'

  export default { 
    props: { 
      checkId: {
        type: Array,
        default: () => []
      },
      detailShow: {
        type: Boolean,
        default: true
      }   
    },
    data () {
      return { 
        form: {
          userguid: '',
          id: '',
          applypeoplename: '', // 申请人
          applySysUrl: '', // 申请系统地址
          applyname: '', // 系统名称
          applyreason: '', // 申请原因
          applytime: '', // 申请时间
          radio: '1', // 是否通过
          opinion: '' // 审批意见
        },
        formData: {},
        dialogFormVisible: false
      }
    },
    mounted () {
      this.checkMoreInformation()
    },
    computed: { 
      gisopUserInfo () {
        return this.$store.state.gisopUserInfo
      }
    },
    methods: {
      // 查看详细信息
      checkMoreInformation () {
        Api.getMoreInformation(this.checkId[0], this.checkId[1])
        .then(data => {
          this.detailShow = true
          this.dialogFormVisible = true
          let datas = data.data
          this.formData = datas
          this.form.userguid = datas.userguid
          this.form.applyid = datas.applyid
          this.form.applyname = datas.applyname
          this.form.applySysUrl = datas.applySysUrl
          this.form.applyreason = datas.applyreason
          this.form.applytime = datas.applytime
          this.form.applypeoplename = datas.applypeoplename
        }).catch(res => {
          this.$message({
            type: 'error',
            message: '请求数据失败'
          })
        })
      },
      // 确定
      dialogSure () { 
        var formData = new FormData()
        formData.append('applyname', this.formData.applyname) 
        formData.append('applySysUrl', this.formData.applySysUrl) 
        formData.append('applyreason', this.formData.applyreason) 
        formData.append('applypeoplename', this.formData.applypeoplename) 
        formData.append('applyservices', this.formData.applyservices) 
        formData.append('applyid', this.formData.applyid)
        formData.append('id', this.formData.id)
        formData.append('auditpeople', this.gisopUserInfo.userguid)
        formData.append('applystatus', this.form.radio)
        formData.append('auditopinion', this.form.opinion)
        formData.append('concurrentlimit', '1000')

        this.$emit('dialog-sure', formData)
      },
      // 取消
      cancelRegister () { 
        this.$emit('dialog-cancel')
      }
    } 
  }
</script>

<style lang="scss">
  .approvalDialog{ 
    .el-form-item__label{ 
      width: 110px;
    }
    .dialog-content{ 
      height: 450px;
    }
    .el-form-item{
      width: 100%;
    } 
    .el-form-item__content{ 
      width: 400px;
    }
    .btn{ 
      text-align: center;
    }

    .el-input.is-disabled {
      .el-input__inner {
        color: #606266;
      }
    }
    .el-textarea.is-disabled {
      .el-textarea__inner {
        color: #606266;
      }
    }
  }
</style>
