<template>
  <div>
    <el-dialog :visible.sync="dialogVisible" width="70%" append-to-body>
      <span>
        <el-form
          :model="setting"
          ref="form"
          label-width="120px"
          :inline="false"
          size="normal"
        >
          <el-descriptions
            class="margin-top"
            :column="1"
            border
            title="子表数据-按钮配置"
          >
            <el-descriptions-item label="允许导入">
              <el-checkbox
                v-model="setting.import"
                :indeterminate="false"
              ></el-checkbox>
            </el-descriptions-item>
            <el-descriptions-item label="允许导出">
              <el-checkbox
                v-model="setting.export"
                :indeterminate="false"
              ></el-checkbox>
            </el-descriptions-item>
          </el-descriptions>
        </el-form>
      </span>
      <span slot="footer">
        <el-button @click="dialogVisible = false">取消</el-button>
        <el-button type="primary" @click="confirm">确定</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
export default {
  data() {
    return {
      setting: {
        import: false,
        export: true
      },
      dialogVisible: false,
      editingObj: null,
      editingField: ''
    }
  },
  methods: {
    showDialog(obj, field) {
      this.editingObj = obj
      this.editingField = field
      if (obj[field]) {
        this.$set(this, 'setting', obj[field])
      }
      this.dialogVisible = true
    },
    confirm() {
      this.$emit('confirm', this.setting)
      this.$set(this.editingObj, this.editingField, this.setting)
      this.dialogVisible = false
    }
  }
}
</script>

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