<template>
  <div>
    <el-form-item label-width="0">
      <el-divider class="custom-divider">后端导入设置</el-divider>
    </el-form-item>
    <el-form-item label="导入数据表名">
      <el-input v-model="optionModel.importEntity"></el-input>
    </el-form-item>
    <el-form-item label="文件大小限制（M）">
      <base-input-number
        v-model="optionModel.importFileLimitSize"
        :max="200"
      ></base-input-number>
    </el-form-item>
    <el-form-item label="导入模板文件编码">
      <el-input
        class="search-input"
        max="200"
        :value="optionModel.importAttachCode"
        clearable
        @clear="
          optionModel.importAttachCode = null;
          optionModel.importAttachName = null;
        "
      >
        <i
          slot="suffix"
          class="el-input__icon el-icon-search"
          @click="showBdAttachSettingDialog = true"
        ></i>
      </el-input>
    </el-form-item>
    <el-form-item label="导入模板文件名称">
      <span>{{ optionModel.importAttachName }}</span>
    </el-form-item>
    <el-form-item label="关联表格唯一名称">
      <el-input v-model="optionModel.tableRef"></el-input>
    </el-form-item>
    <el-form-item label="执行后台脚本编码">
      <el-input v-model="optionModel.importScriptCode"></el-input>
    </el-form-item>
    <el-form-item label="多sheet导入">
      <el-switch v-model="optionModel.multipleSheet"></el-switch>
    </el-form-item>
    <el-form-item label="批量导入">
      <el-switch v-model="optionModel.importMultiple"></el-switch>
    </el-form-item>
    <el-form-item label="批量导入大小">
      <base-input-number
        v-model="optionModel.importMultiSize"
        :max="200"
      ></base-input-number>
    </el-form-item>
    <el-form-item label="点击前置事件" label-width="150px">
      <a href="javascript:void(0);" class="a-link link-oneLind"
         @click="editEventHandler('onBeforeClickButton', eventParams)">
        <span>{{ optionModel.onBeforeClickButton }}</span>
        <i class="el-icon-edit"></i>
      </a>
    </el-form-item>
    <el-form-item label="启用图片处理">
      <el-switch v-model="optionModel.enabledImportPreHandle"></el-switch>
    </el-form-item>
    <el-form-item label="导入前数据处理" label-width="150px">
      <a
        href="javascript:void(0);"
        class="a-link link-oneLind"
        @click="editEventHandler('onBeforeImport', onBeforeImportParams)"
      >
        <span>{{ optionModel.onBeforeImport }}</span>
        <i class="el-icon-edit"></i>
      </a>
    </el-form-item>

    <el-form-item label="导入完成回调" label-width="150px">
      <a
        href="javascript:void(0);"
        class="a-link link-oneLind"
        @click="editEventHandler('onSuccessImport', onSuccessImportParams)"
      >
        <span>{{ optionModel.onSuccessImport }}</span>
        <i class="el-icon-edit"></i>
      </a>
    </el-form-item>
    <el-form-item label="隐藏取消按钮" label-width="150px">
      <el-switch v-model="optionModel.hideCancelButton"></el-switch>
    </el-form-item>

    <bdAttachSettingDialog
      v-if="showBdAttachSettingDialog"
      :visiable.sync="showBdAttachSettingDialog"
      :multi="false"
      @confirm="confirmBdAttachSettingDialog"
    ></bdAttachSettingDialog>
  </div>
</template>

<script>
import i18n from "../../../../../../components/xform/utils/i18n";
import eventMixin from "../../../../../../components/xform/form-designer/setting-panel/property-editor/event-handler/eventMixin";
import bdAttachSettingDialog from "../../../../../../views/bd/setting/bd_attach_setting/dialog.vue";

export default {
  name: "import-button-editor",
  components: { bdAttachSettingDialog },
  mixins: [i18n, eventMixin],
  props: {
    designer: Object,
    selectedWidget: Object,
    optionModel: Object,
  },
  data() {
    return {
      eventParams: ["dataId", "formCode", "done"],
      showBdAttachSettingDialog: false,
      onBeforeImportParams: ["dataId", "formCode", "file", "resultData", "done"],
      onConfirmImportParams: ["dataId", "formCode", "resultData", "file", "done", "close"],
      onSuccessImportParams: ["dataId", "formCode", "resultData", "file"],
    };
  },
  methods: {
    confirmBdAttachSettingDialog(rows) {
      if (rows.length) {
        let row = rows[0];
        this.optionModel.importAttachName = row.name;
        this.optionModel.importAttachCode = row.code;
      }
    },
  },
};
</script>

<style scoped></style>
