<template>
  <div :style="{ width: record.options.width }">
    <a-button
      @click="fiveWhyFlag = true"
      type="primary"
    >打开5why</a-button>
    <ych-modal
      :fullscreen="false"
      :maskClosable="false"
      :visible="fiveWhyFlag"
      :footer="null"
      @cancel="fiveWhyFlag = false"
      :destroyOnClose="true">
      <k-five-why
        :ref="record.tableName"
        :columns="getColumns"
        :form-flag="true"
        v-bind="$attrs"
        :value="value"
        @change="changeValue"
        :recordConfig="record"
        v-decorator="[
            record.model, // input 的 name
            {
              initialValue: record.options.defaultValue
            }
          ]"
        :disabled="record.options.disabled"
      />
    </ych-modal>
  </div>
</template>
<script>

import {ajaxGetDictItems, ajaxGetHttpConfigItems, ajaxGetSqlConfigItems} from "../utils/api/api";
import KFiveWhy from "../KFiveWhy/KFiveWhy.vue";

export default {
  name: 'FiveWhyButton',
  data () {
    return {
      fiveWhyFlag: false,
      dataSource: [],
    }
  },
  components: {
    KFiveWhy
  },
  props: {
    record: {
      type: Object,
      required: true,
    },
    value: {
      type: String,
    },
    dictMap: {
      type: Object,
      default: () => {
      }
    },
  },
  computed: {
    //子表字段控制
    getColumns() {
      return []
      // const that = this;
      // return this.$ychCommon.getColumns(this.record, this.dictMap, ajaxGetDictItems, ajaxGetSqlConfigItems, ajaxGetHttpConfigItems, this.form, () => {
      //   that.reloadDataFlg = true
      // })
    },
  },
  methods: {
    changeValue(value){
      this.$emit('change', JSON.stringify(value))
      this.$emit('input', JSON.stringify(value))
    }
  }
}
</script>
