
<!--幼儿园详情-->
<template>
  <el-dialog
    v-dialog-drag
    :close-on-press-escape="false"
    :close-on-click-modal="false"
    title="幼儿园详情"
    :visible.sync="dialogVisible"
    width="900px"
    append-to-body
    @close="handleCancel"
  >
    <el-descriptions :column="2" :label-style="{ width: '90px', justifyContent: 'right'}">
      <el-descriptions-item label="幼儿园名称">{{ formState.kindergartenName }}</el-descriptions-item>
      <el-descriptions-item label="幼儿园类型">{{ formState.kindergartenType ? getDictLabel(options.kindergartenType, formState.kindergartenType) : '--' }}</el-descriptions-item>
      <template v-if="formState.kindergartenType === options.kindergartenTypeMap.kindergartenGroup">
        <el-descriptions-item label="所属集团">{{ formState.gardenName }}</el-descriptions-item>
        <el-descriptions-item label="是否集团总园">{{ formState.isGarden ? getDictLabel(options.yOrN, formState.isGarden) : '--' }}</el-descriptions-item>
      </template>
      <el-descriptions-item label="幼儿园简称">{{ formState.simpleName || '--' }}</el-descriptions-item>
      <el-descriptions-item label="英文名称">{{ formState.englishName || '--' }}</el-descriptions-item>
      <el-descriptions-item label="园长">{{ formState.principal || '--' }}</el-descriptions-item>
      <el-descriptions-item label="园长电话">{{ formState.principalPhone || '--' }}</el-descriptions-item>
      <el-descriptions-item label="法人">{{ formState.legalPerson || '--' }}</el-descriptions-item>
      <el-descriptions-item label="所属区域">{{ formState.belongRegion || '--' }}</el-descriptions-item>
      <el-descriptions-item label="详细地址" :span="2">{{ formState.detailAddress || '--' }}</el-descriptions-item>
      <el-descriptions-item label="幼儿园定位" :span="2">{{ formState.locationAddress || '--' }}</el-descriptions-item>
      <el-descriptions-item label="备注" :span="2">{{ formState.remark || '--' }}</el-descriptions-item>
      <el-descriptions-item label="幼儿园logo">
        <img v-if="formState.logoUrl" style="width: 100px; height: 100px" :src="formState.logoUrl" alt="照片">
        <span v-else>--</span>
      </el-descriptions-item>
    </el-descriptions>

    <div slot="footer" class="dialog-footer">
      <el-button @click="handleCancel">取 消</el-button>
    </div>
  </el-dialog>
</template>
<script>
import { getBranch } from '@/api/system/branch'
import { getDictLabel } from '@/utils/dict/config'
import options from '@/utils/dict/options'

const initForm = {
  id: null,
  kindergartenName: null,
  kindergartenType: null,
  gardenId: null,
  isGarden: null,
  simpleName: null,
  englishName: null,
  principal: null,
  principalPhone: null,
  legalPerson: null,
  fileId: null,
  provinceId: null, // 所属区域，
  cityId: null,
  belongRegion: null, // 省市区
  districtId: null,
  detailAddress: null,
  locationAddress: null, // 幼儿园定位
  latitudeLongitude: null, // 经纬度
  remark: null
}
export default {
  name: 'BranchInfoDialog',
  data() {
    return {
      options,
      dialogVisible: false,
      formState: Object.assign({}, initForm)
    }
  },
  methods: {
    getDictLabel,
    handleOpen(row) {
      this.dialogVisible = true
      getBranch(row.id).then(({ data }) => {
        this.formState = data
        this.formState.gardenName = row.gardenName
      })
    },
    handleCancel() {
      this.dialogVisible = false
    }
  }

}
</script>
<style scoped lang="scss">

</style>
