<template>
  <a-input v-model="name" v-on="$listeners" v-bind="$attrs"></a-input>
</template>

<script>

  import { getAction } from '../../../utils/manage'
  import YchConstant from "../../../utils//YchConstant";

  export default {
    name: 'SysOrgName',
    props: {
      value: {
        type: String,
        default: null
      }
    },
    data () {
      return {
        name: null,
        url: {
          queryPathNameById: YchConstant.PREFIX_SYSTEM + '/sysOrg/queryPathNameById',
        }
      }
    },
    watch: {
      value: {
        handler () {
          this.loadData()
        },
        immediate: true
      }
    },
    methods: {
      loadData () {
        if (!this.value) {
          this.name = null
          return
        }
        getAction(this.url.queryPathNameById, { id: this.value }).then((res) => {
          if (res.success) {
            this.name = res.result
          } else {
            this.name = null
          }
        }).finally(() => {
        })
      }
    }
  }
</script>
