<template>
  <div>
    <el-dialog
      :title="$t1('新建企业')"
      :append-to-body="true"
      :modal-append-to-body="true"
      :close-on-click-modal="false"
      :visible.sync="showDialog"
      :modal="false"
      custom-class="dialog-style list-dialog dialog-checkbox pd_8"
      width="350px"
      v-el-drag-dialog
      v-el-dialog-center
      :before-close="dialogClose"
    >
      <div class="cont">
        <el-form
          ref="editCategoryForm"
          :model="formData"
          label-width="102px"
          class="adSearchForm"
          style="min-height: 150px; width: auto"
        >
          <el-form-item :label="$t1('企业类型')">
            <el-radio-group v-model="formData.gender">
              <el-radio :label="1">{{ $t1("海外营销") }}</el-radio
              ><br />
              <el-radio :label="2">{{ $t1("国内营销") }}</el-radio
              ><br />
              <el-radio :label="3">{{ $t1("产品平台") }}</el-radio>
            </el-radio-group>
          </el-form-item>
          <el-form-item :label="$t1('编码')">
            <el-input v-model="formData.sid" clearable class="all-width" />
          </el-form-item>
        </el-form>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button type="primary" plain class="button-sty" @click="dialogClose">
          <i class="el-icon-close el-icon"></i>
          {{ $t1("取消") }}
        </el-button>
        <el-button type="primary" @click="openCreateCompanyJsonDialog" class="button-sty">
          <i class="el-icon-check el-icon"></i>
          {{ $t1("确定") }}
        </el-button>
      </span>
    </el-dialog>
    <el-dialog
      title="新建企业JSON维护"
      :append-to-body="true"
      :modal-append-to-body="true"
      :close-on-click-modal="false"
      :visible.sync="showCreateCompanyJsonDialog"
      :modal="false"
      custom-class="dialog-style tips-dialog tips-1 "
      width="800px"
      @close="dialogClose"
      v-el-drag-dialog
      v-el-dialog-center
    >
      <div class="cont" style="height: 700px">
        <code-editor
          mode="json"
          :readonly="!1"
          v-model="companyJson"
          height="414px;"
        ></code-editor>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button type="primary" plain class="button-sty" @click="dialogClose">
          <i class="el-icon-close el-icon"></i>
          {{ $t1("取 消") }}
        </el-button>
        <el-button
          type="primary"
          @click="confirmCreateCompanyJsonDialog"
          class="button-sty"
        >
          <i class="el-icon-check el-icon"></i>
          {{ $t1("确 定") }}
        </el-button>
      </span>
    </el-dialog>
  </div>
</template>
<script>
export default {
  components: {},
  data() {
    return {
      showDialog: true,
      formData: {
        objType: "FormTemplate",
        sid: null,
      },
      extractedCode: null,
      companyJson: null,
      showCreateCompanyJsonDialog: false,
    };
  },
  methods: {
    dialogConfirm() {
      this.extractedCode = null;
      if (!this.formData.sid) {
        this.$baseAlert("唯一标识不能为空");
        return;
      }
      this.$http({
        aes: true,
        url: USER_PREFIX + `/form_develop/getExtractedCodeData`,
        method: `post`,
        data: this.formData,
        isLoading: true,
        success: (res) => {
          let rows = res.objx || [];
          if (rows.length) {
            let row = rows[0];
            this.extractedCode = row.extractedCode;
          }
        },
      });
    },
    dialogClose() {
      this.showDialog = false;
      this.$emit("update:visiable", false);
    },
    openCreateCompanyJsonDialog() {
      this.showDialog = false;
      this.companyJson = "";
      this.showCreateCompanyJsonDialog = true;
    },
    confirmCreateCompanyJsonDialog(data) {
      /* this.$http({
        aes: true,
        url: USER_PREFIX + `/form_develop/getExtractedCodeData`,
        method: `post`,
        data: this.formData,
        isLoading: true,
        success: (res) => {
          this.$message({
            message: res.content,
            type: "success"
          });
          this.dialogClose();
        },
      }); */
    },
  },
};
</script>

<style scoped>
::v-deep .el-select.all-width .el-input {
  width: 100% !important;
}
</style>
