<template>
  <div>
    <a-modal
      :title="title"
      :visible="visible"
      :width="width"
      :confirm-loading="confirmLoading"
      :footer="null"
      @cancel="handleCancel"
    >
      <a-row class="box" style="margin-bottom:30px" type="flex">
        <a-col v-for="(item, i) in data" :key="i" :span="colNum">
          <span class="contentsy">{{ item.label }}: <span>{{ item.value }}</span></span>
        </a-col>
      </a-row>
    </a-modal>
  </div>
</template>

<script>
export default {
  name: 'PDetailModel',
  components: {},
  model: {
    prop: 'visible',
    event: 'change'
  },
  props: {
    visible: {
      type: Boolean,
      default: false
    },
    title: {
      type: String,
      default: ''
    },
    colNum: {
      type: Number,
      default: 12
    },
    detailData: {
      type: Object,
      default() {
        return {}
      }
    },
    width: {
      type: Number,
      default: 800
    }
  },
  computed: {},
  watch: {
    detailData: {
      handler(val) {
        let arr = []
        for (const key in val) {
          if (Object.hasOwnProperty.call(val, key)) {
            let obj = {
              label: key,
              value: val[key]
            }
            arr.push(obj)
          }
        }
        this.data = arr 
        console.log(this.data)
      },
      deep: true,
      immediate: true,
    }
  },
  data() {
    return {
      confirmLoading: false,
      isShow: false,
      data: []
    }
  },
  created() {},
  mounted() {},
  methods: {
    handleCancel() {
      this.$emit('onCancel')
      this.$emit('change', false)
    }
  }
}
</script>

<style lang="less" scoped>
.extend-title {
  font-size: 14px;
  font-weight: bold;
  padding: 12px 0;
  border-bottom: 1px solid #e8e8e8;
  margin-bottom: 12px;
}
.contentsy {
  display: inline-block;
  font-size: 16px;
  margin: 10px 0;
}
.box {
  padding: 0 30px;
}
</style>
