<template>
  <div>
    <el-dialog class="dlg-linkpicker" :title="dialogTitle" @open="init" :visible.sync="isShow" width="850px">
      <link-picker-tab ref='linkPickerTab'></link-picker-tab>
      <span slot="footer" class="dialog-footer">
        <el-button @click="isShow = false">取 消</el-button>
        <el-button type="primary" :loading="confirmLoading" @click="confirm">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>
<script>
import linkPickerTab from './components/LinkPickerTab.vue'
export default {
  components: {
    linkPickerTab
  },
  props: {
    show: {
      type: Boolean,
      default: false
    }
  },
  computed: {
    isShow: {
      get() {
        return this.show
      },
      set(val) {
        this.$emit('update:show', val)
      }
    }
  },
  data() {
    return {
      dialogTitle: '选择站内链接',
      confirmLoading: false
    }
  },
  methods: {
    init() { },
    confirm() {
      var linkObj = this.$refs.linkPickerTab.getValue()
      if (linkObj !== null) {
        if (window.dialogSavedCallback) {
          window.dialogSavedCallback(linkObj)
        }
        this.confirmLoading = false
        this.isShow = false
      } else {
        this.confirmLoading = false
      }
    },
    confirmInvalid() {
      this.confirmLoading = false
    },
    picked(link) { }
  }
}
</script>
<style></style>
