<template>
  <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
    @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-select v-model="formData.objType" class="all-width">
            <el-option value="FormTemplate" :label="$t1('表单模板')"></el-option>
            <el-option value="FormScript" :label="$t1('逻辑脚本')"></el-option>
            <el-option value="TableTemplate" :label="$t1('数据表')"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item :label="$t1('唯一标识')">
          <el-input v-model="formData.sid" clearable class="all-width"/>
        </el-form-item>
        <el-form-item :label="$t1('提取码')">
          <span>{{ extractedCode }}</span>
        </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>
        {{ $t2('取 消', 'system.button.cancel2') }}
      </el-button>
      <el-button type="primary" @click="dialogConfirm" class="button-sty">
        <i class="el-icon-check el-icon"></i>
        {{ $t1('生成提取码') }}
      </el-button>
    </span>
  </el-dialog>
</template>
<script>
export default {
  name: "createDialog",
  data() {
    return {
      showDialog: true,
      formData: {
        objType: "FormTemplate",
        sid: null
      },
      extractedCode: null
    }
  },
  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)
    },
  }
}
</script>


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