{{ header }}
<div id="root">
  <div class="page-loader" v-show="isLoading"></div>
  <validation-observer ref="validationObserver" tag="div" v-slot="{ handleSubmit }">
    <form
      ref="form"
      @submit.prevent="handleSubmit(onSubmit)"
      action="{{ data.action }}"
      method="post">

      <the-header
        title="{{ heading_title }}"
        help="http://manual.futurasistemas.com.br/manual-do-sistema/como-configurar-o-modulo-jamef/"
        :breadcrumbs='{{ breadcrumbs|json_encode() }}'>

        <base-button
          href="{{ data.back }}"
          apperance="outline">
          {{ button_cancel }}
        </base-button>
        <base-button
          type="submit"
          :disabled="disableForm"
          :loading="btnSubmitLoading">
          {{ button_save }}
        </base-button>

        <template #notification>
          <base-alert
            v-show="alert.type"
            :apperance="alert.type"
            @close="alert = {}">
            <span v-text="alert.message"></span>
          </base-alert>
        </template>
      </the-header>

      <div class="container-fluid">
        <div class="row">
          <div class="col-xs-12 col-sm-8 col-md-6">
            <base-card class="padding-large">

              <validation-provider
                tag="div"
                name="jamef_nome"
                rules="required|min:1|max:32"
                v-slot="{ errors, valid }">
                <base-input
                  label="{{ entry_modulo }}"
                  name="jamef_nome"
                  v-model="configurations.jamef_nome"
                  :error="errors[0]"
                  :valid="valid"
                  :disabled="disableForm"
                  required>
                </base-input>
              </validation-provider>

              <validation-provider
                tag="div"
                class="top-margin-large"
                name="jamef_login"
                rules="required|email"
                v-slot="{ errors, valid }">
                <base-input
                  label="{{ entry_login }}"
                  name="jamef_login"
                  v-model="configurations.jamef_login"
                  :error="errors[0]"
                  :valid="valid"
                  :disabled="disableForm"
                  required>
                </base-input>
              </validation-provider>

              <validation-provider
                tag="div"
                class="top-margin-large"
                name="jamef_password"
                rules="required"
                v-slot="{ errors, valid }">
                <base-input
                  label="{{ entry_password }}"
                  name="jamef_password"
                  v-model="configurations.jamef_password"
                  :error="errors[0]"
                  :valid="valid"
                  :disabled="disableForm"
                  :secret=true
                  required>
                </base-input>
              </validation-provider>

              <validation-provider
                tag="div"
                name="jamef_cnpj"
                class="top-margin-large"
                rules="required|cnpj"
                v-slot="{ errors, valid }">
                <base-input
                  label="{{ entry_cnpj }}"
                  name="jamef_cnpj"
                  v-model="configurations.jamef_cnpj"
                  mask="cnpj"
                  :error="errors[0]"
                  :valid="valid"
                  :disabled="disableForm"
                  required>
                </base-input>
              </validation-provider>

              <validation-provider
              rules="required"
              v-slot="{ errors, valid }">
              <base-select v-if="showFiliais"
                class="top-margin-large"
                label="{{ entry_filial }}"
                name="jamef_filial"
                v-model="configurations.jamef_filial"
                :error="errors[0]"
                :valid="valid"
                :disabled="disableForm">
                  <option :value="key" :key="key" v-for="(value, key) in filiais" v-text="value"></option>
              </base-select>
              </validation-provider>

              <pre>{{ filiais }}</pre>

               <base-button v-if="!showFiliais"
                class="top-margin-large"
                @click.native="getBranchesList"
                apperance="outline"
                :disabled="disableForm || disableSubmitButton"
                :loading="btnSubmitLoading">
                {{ entry_carregar_filiais }}
              </base-button>

              <base-select
                class="top-margin-large"
                class="top-margin-large"
                label="{{ entry_tipo_transporte }}"
                name="jamef_tipoTransporte"
                v-model="configurations.jamef_tipoTransporte"
                :disabled="disableForm">
                {% for  key, value in Type_TranporteJameF %}
                  <option value="{{ key }}">{{ value }}</option>
                {% endfor %}
              </base-select>

              <base-select
                class="top-margin-large"
                label="{{ entry_previsao }}"
                name="jamef_exibeprevisao"
                v-model="configurations.jamef_exibeprevisao"
                :disabled="disableForm">
                <option value="1">{{ text_enabled }}</option>
                <option value="0">{{ text_disabled }}</option>
              </base-select>


              <validation-provider
                tag="div"
                class="top-margin-large"
                name="jamef_periodoadicional"
                rules=""
                v-slot="{ errors, valid }">
                <base-input
                  label="{{ entry_periodoadicional }}"
                  description="{{ text_periodoadicional }}"
                  name="jamef_periodoadicional"
                  v-model="configurations.jamef_periodoadicional"
                  mask="integer"
                  :error="errors[0]"
                  :valid="valid"
                  :disabled="disableForm">
                </base-input>
              </validation-provider>

              <base-select
                class="top-margin-large"
                label="{{ entry_geo_zone }}"
                name="jamef_geo_zone_id"
                v-model="configurations.jamef_geo_zone_id"
                :disabled="disableForm">
                <option value="0">{{ text_all_zones }}</option>
                {% for geo_zone in geo_zones %}
                  <option value="{{ geo_zone.geo_zone_id }}">{{ geo_zone.name }}</option>
                {% endfor %}
              </base-select>

            </base-card>
          </div>
          <div class="col-xs-12 col-sm-4">
            <base-card class="padding-large">

              <base-select
                label="{{ entry_status }}"
                name="jamef_status"
                v-model="configurations.jamef_status"
                :disabled="disableForm">
                <option value="1">{{ text_enabled }}</option>
                <option value="0">{{ text_disabled }}</option>
              </base-select>

              <validation-provider
                tag="div"
                name="jamef_sort_order"
                class="top-margin-large"
                rules="numeric"
                v-slot="{ errors, valid }">
                <base-input
                  label="{{ entry_sort_order }}"
                  name="jamef_sort_order"
                  v-model="configurations.jamef_sort_order"
                  mask="integer"
                  :error="errors[0]"
                  :valid="valid"
                  :disabled="disableForm">
                </base-input>
              </validation-provider>
            </base-card>
          </div>
        </div>
      </div>

    </form>
  <validation-observer>
</div>

<script>
  const DATA = {{ data|json_encode() }};
</script>

{{ footer }}
