<template>
  <div class="app-container">
    <el-dialog
      class="appAuditModal "
      title="应用审核"
      :close-on-click-modal="false"
      :visible.sync="visible"
      top="4%"
    >
      <el-form v-loading="loading" label-width="240px">
        <el-form-item :label="$t('ec.app.proposer')" label-width="180px">
          <el-input v-model="formItem.proposer" type="text" style="width:600px;max-width:100%;" />
        </el-form-item>
        <el-form-item :label="$t('ec.app.projectCode')" label-width="180px">
          <el-input v-model="formItem.projectCode" type="text" style="width:600px;max-width:100%;" />
        </el-form-item>
        <el-form-item :label="$t('ec.app.projectName')" label-width="180px">
          <el-input v-model="formItem.projectName" type="text" style="width:600px;max-width:100%;" />
        </el-form-item>
        <el-form-item :label="$t('ec.app.proposerPhone')" label-width="180px">
          <el-input v-model="formItem.proposerPhone" type="text" style="width:600px;max-width:100%;" />
        </el-form-item>
        <el-form-item :label="$t('ec.app.auditRemarks')" label-width="180px">
          <el-input v-model="formItem.auditRemarks" type="textarea" :autosize="{minRows: 3, maxRows: 5}" style="width:600px;max-width:100%;" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="visible = false">{{ $t('ec.table.cancel') }}</el-button>
        <el-button type="primary" :loading="auditLoading" @click="confirm">{{ $t('ec.table.confirm') }}</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import mixin from 'ecip-web/utils/common-mixin'
import { updateAuditStatus } from 'ecip-web/api/vue/app/sysrRegisterAppApi'

export default {
  name: 'AppAuditModal',
  mixins: [...mixin],
  data() {
    return {
      visible: false,
      loading: false,
      auditLoading: false,
      formItem: {
        auditStatus: '',
        proposer: '',
        projectCode: '',
        projectName: '',
        proposerPhone: '',
        auditRemarks: ''
      }
    }
  },
  methods: {
    init(row) {
      this.visible = true
      this.formItem = row
    },
    async confirm() {
      try {
        this.auditLoading = true
        let msg = ''
        this.formItem.auditStatus = 'agree'
        const { message } = await updateAuditStatus(this.formItem.appId, this.formItem)
        msg = message
        this.visible = false
        this.$notify.success(msg)
      } finally {
        this.auditLoading = false
        this.$parent.getData()
      }
    }
  }
}
</script>

<style scoped>

</style>
