<template>
  <el-form-item label="onClick" label-width="150px">
    <a
      href="javascript:void(0);"
      class="a-link link-oneLind"
      @click="openEventHandlerDialog"
    >
      <span>{{ optionModel.onClick }}</span>
      <i class="el-icon-edit"></i>
    </a>
  </el-form-item>
</template>

<script>
import i18n from "../../../../../../components/xform/utils/i18n";
import eventMixin from "../../../../../../components/xform/form-designer/setting-panel/property-editor/event-handler/eventMixin";

export default {
  name: "onClick-editor",
  mixins: [i18n, eventMixin],
  props: {
    designer: Object,
    selectedWidget: Object,
    optionModel: Object,
    tableColumns: Array,
  },
  data() {
    return {
      // eventParams: ["id", "formCode"],
    };
  },

  methods: {
    getEventParams() {
      let eventParams = ["dataId", "formCode"];
      if (this.tableColumns && this.tableColumns.length > 0) {
        eventParams.push("row", "rowIndex", "event");
      } else {
        eventParams.push("event");
      }
      if (this.selectedWidget.type == "census") {
        eventParams.push("param");
      }
      return eventParams;
    },
    openEventHandlerDialog() {
      let eventParams = this.getEventParams();
      this.editEventHandler("onClick", eventParams);
    },
  },
};
</script>

<style scoped></style>
