<template>
  <span class="button-sty" style="cursor: unset">
    <el-button
      type="primary"
      plain
      class="button-sty"
      icon="el-icon-set-up"
      @click="openPreformDialog"
    >
      {{ $t1("回退当前版本") }}
    </el-button>
    <preformDialog
      v-if="showPreformDialog"
      :visiable.sync="showPreformDialog"
      @confirm="confirmPreformDialog"
    ></preformDialog>
  </span>
</template>
<script>
export default {
  name: "reverButton",
  props: {
    hData: Object,
    objType: {
      type: String,
      default: "",
    },
    objCode: {
      type: String,
      default: "",
    },
  },
  components: {
    preformDialog: () => import("./preformDialog.vue"),
  },
  data() {
    return {
      historyDialogVisible: false,
      showPreformDialog: false,
      formData: {
        logContent: "",
      },
    };
  },
  methods: {
    saveDataHandle(preformData) {
      let url = null;
      if (this.objType === "FormTemplate") {
        url = USER_PREFIX + "/formTemplate/update";
      } else if (this.objType === "FormScript") {
        url = USER_PREFIX + "/formScript/update";
      } else if (this.objType === "SzTaMb") {
        url = USER_PREFIX + "/szTaMb/update";
      }
      this.$http({
        // aes: true,
        url: url,
        method: `post`,
        data: {
          ...this.hData,
          rb: 1,
          logContent: preformData.logContent,
        },
        isLoading: true,
        success: (res) => {
          this.$message({
            message: res.content,
            type: "success",
          });
          this.$emit("reverCallback");
        },
      });
    },
    openPreformDialog() {
      this.showPreformDialog = true;
    },
    confirmPreformDialog(preformData) {
      this.saveDataHandle(preformData);
    },
  },
};
</script>
