<template>
  <div :id="docid" v-if="record">
    <div :id="docid1">
      <div class="columns is-multiline mx-0">
        <div class="column is-3 pb-1 px-0">
          <div class="field">
            <label class="label">{{ this.data && findFieldName("id")[this.lang] }}</label>
            <div class="control">
              <span class="hyperlink" @click="$copyToClipboard(record.id)">{{ record.id }}</span>
            </div>
          </div>
        </div>
        <div class="column is-3 pb-1 px-0">
          <div class="field">
            <label class="label">{{ this.data && findFieldName("code")[this.lang] }}</label>
            <div class="control">
              <span class="hyperlink" @click="$copyToClipboard(record.code)">{{ record.code }}</span>
            </div>
          </div>
        </div>
        <div class="column is-3 pb-1 px-0">
          <div class="field">
            <label class="label">{{ this.lang === 'vi' ? 'Tên' : 'Name' }}</label>
            <div class="control">
              {{ record.name }}
            </div>
          </div>
        </div>
        <div class="column is-3 pb-1 px-0">
          <div class="field">
            <label class="label">{{ this.lang === 'vi' ? 'Chi tiết' : 'Detail' }}</label>
            <div class="control">
              <span>{{ record.detail }}</span>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
import { useStore } from "@/stores/index";
export default {
  setup() {
    const store = useStore();
    return { store };
  },
  props: ["row", "pagename"],
  data() {
    return {
      record: undefined,
      errors: {},
      showmodal: undefined,
      docid: this.$id(),
      docid1: this.$id(),
      data: this.store.common,
      isEditMode: this.isEditMode,
    };
  },
  computed: {
    lang() {
      return this.store.lang;
    },
    isVietnamese() {
      return this.store.lang === "vi";
    },
  },
  async created() {
    this.record = await this.$getdata("transactiontype", { id: this.row.id }, undefined, true);
  },
  methods: {
    findFieldName(code) {
      let field = this.data.find((v) => v.code === code);
      return field;
    },
    copy(value) {
      this.$copyToClipboard(value);
      this.$snackbar("Đã copy vào clipboard.", "Copy", "Success");
    },
  },
};
</script>
