<template>
  <div>
    <el-form-item v-if="false && optionModel.dsEnabled" :label="i18nt('请求访问')">
      <el-input
        class="search-input"
        max="200"
        v-model="optionModel.accessName"
        @clear="
          optionModel.accessCode = '';
          $forceUpdate();
        "
        v-el-readonly
        clearable
      >
        <i slot="suffix" class="el-input__icon el-icon-search" @click="showRequestaccessDialog = true"></i>
      </el-input>
    </el-form-item>
    <requestaccessDialog
      v-if="showRequestaccessDialog"
      :visiable.sync="showRequestaccessDialog"
      @confirm="confirmInsertRequestaccess"
      multi="false"
      :param="{ reportCode: reportTemplate.reportCode }"
    />
  </div>
</template>

<script>
import i18n from '../../../../../components/xform/utils/i18n';
import requestaccessDialog from '../../../../../views/user/form/report_requestaccess/dialog.vue';

export default {
  name: 'dsName-editor',
  mixins: [i18n],
  props: {
    designer: Object,
    selectedWidget: Object,
    optionModel: Object,
    dataSourceList: Array
  },
  components: {
    requestaccessDialog
  },
  inject: ['getReportTemplate'],
  computed: {
    reportTemplate: function() {
      return this.getReportTemplate();
    }
  },
  data() {
    return {
      showRequestaccessDialog: false
    };
  },
  methods: {
    confirmInsertRequestaccess(rows) {
      if (rows.length) {
        let row = rows[0];
        this.optionModel.accessName = row.accessName;
        this.optionModel.accessCode = row.accessCode;
      }
    }
  }
};
</script>

<style scoped></style>
