<template>
  <div class="auto">
    <modal :show.sync="show" title="使用公司" v-ref:modal large backdrop="false">
      <article slot="modal-body" class="modal-body">
        <form class="form-inline" style="text-align: center">
          <div  v-for="val in orgs">
            <strong>{{val}}</strong>
          </div>
        </form>
      </article>
      <footer slot="modal-footer" class="modal-footer" style="text-align: center;">
        <strong >共{{orgs.length}}家分公司使用</strong>
      </footer>
    </modal>
  </div>
</template>

<script>

  let getOrgName = async function (self) {

    // 将data的值转换成sql in的形式
    let condition = self.$login.convertToIn(self.data)

    if (condition) {
      let res = await self.$resetpost('rs/sql/getOrgName', {data:{condition: condition}}, {resolveMsg:null, rejectMsg: '获取组织名称失败'})
      res.data.forEach((org) => {
        self.orgs.push(org.name)
      })
    }

  }

  export default {
    title: '使用公司',
    data() {
      return {
        orgs: []
      }
    },
    props: ['show', 'data'],
    ready () {
      getOrgName(this)
    }
  }
</script>
