{{ 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 }}"
        :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">
            <base-card
              class="padding-large bottom-margin-medium"
              v-for="(module, moduleIndex) in configurations.descontoprimeiracompra_module"
              :key="moduleIndex">

              <div class="row small-space-xs">
                <div class="col-xs-12 col-sm-6">
                  <validation-provider
                    tag="div"
                    :name=`descontoprimeiracompra_module[${moduleIndex}][title]`
                    rules="required|max:25"
                    v-slot="{ errors, valid }">
                    <base-input
                      label="{{ entry_title }}"
                      :name=`descontoprimeiracompra_module[${moduleIndex}][title]`
                      v-model="module.title"
                      :error="errors[0]"
                      :valid="valid"
                      :disabled="disableForm">
                    </base-input>
                  </validation-provider>
                </div>
                <div class="col-xs-6 col-sm-2">
                  <validation-provider
                    tag="div"
                    :name=`descontoprimeiracompra_module[${moduleIndex}][sort]`
                    rules=""
                    v-slot="{ errors, valid }">
                    <base-input
                      label="{{ entry_sort }}"
                      :name=`descontoprimeiracompra_module[${moduleIndex}][sort]`
                      v-model="module.sort"
                      mask="positiveInteger"
                      :error="errors[0]"
                      :valid="valid"
                      :disabled="disableForm">
                    </base-input>
                  </validation-provider>
                </div>
                <div class="col-xs-6 col-sm-4">
                  <validation-provider
                    tag="div"
                    :name=`descontoprimeiracompra_module[${moduleIndex}][status]`
                    rules="required"
                    v-slot="{ errors, valid }">
                    <base-select
                      label="{{ entry_status }}"
                      :name=`descontoprimeiracompra_module[${moduleIndex}][status]`
                      v-model="module.status"
                      :error="errors[0]"
                      :valid="valid"
                      :disabled="disableForm">
                      {% for  key, value in Type_Status %}
                        <option value="{{ key }}">{{ value }}</option>
                      {% endfor %}
                    </base-select>
                  </validation-provider>
                </div>

                <div class="col-xs-6 col-md-3">
                  <validation-provider
                    tag="div"
                    :name=`descontoprimeiracompra_module[${moduleIndex}][type_descont]`
                    rules="required"
                    v-slot="{ errors, valid }">
                    <base-select
                      label="{{ entry_type_descont }}"
                      :name=`descontoprimeiracompra_module[${moduleIndex}][type_descont]`
                      v-model="module.type_descont"
                      :error="errors[0]"
                      :valid="valid"
                      :disabled="disableForm">
                      {% for  key, value in Type_DescontoPrimeiraCompra %}
                        <option value="{{ key }}">{{ value }}</option>
                      {% endfor %}
                    </base-select>
                  </validation-provider>
                </div>
                <div class="col-xs-6 col-md-3">
                  <validation-provider
                    tag="div"
                    :name=`descontoprimeiracompra_module[${moduleIndex}][value_descont]`
                    rules="required"
                    v-slot="{ errors, valid }">
                    <base-input
                      label="{{ entry_descont_value }}"
                      :name=`descontoprimeiracompra_module[${moduleIndex}][value_descont]`
                      v-model="module.value_descont"
                      :mask="module.type_descont == 1 ? 'brazilCurrency' : 'percentage'"
                      :error="errors[0]"
                      :valid="valid"
                      :disabled="disableForm">
                    </base-input>
                  </validation-provider>
                </div>
                <div class="col-xs-6 col-md-3">
                  <validation-provider
                    tag="div"
                    :name=`descontoprimeiracompra_module[${moduleIndex}][value_minimo]`
                    rules="required"
                    v-slot="{ errors, valid }">
                    <base-input
                      label="{{ entry_value_minimo }}"
                      :name=`descontoprimeiracompra_module[${moduleIndex}][value_minimo]`
                      v-model="module.value_minimo"
                      mask="brazilCurrency"
                      :error="errors[0]"
                      :valid="valid"
                      :disabled="disableForm">
                    </base-input>
                  </validation-provider>
                </div>
                <div class="col-xs-6 col-md-3">
                  <validation-provider
                    tag="div"
                    :name=`descontoprimeiracompra_module[${moduleIndex}][type_person]`
                    rules="required"
                    v-slot="{ errors, valid }">
                    <base-select
                      label="{{ entry_type_person }}"
                      :name=`descontoprimeiracompra_module[${moduleIndex}][type_person]`
                      v-model="module.type_person"
                      :error="errors[0]"
                      :valid="valid"
                      :disabled="disableForm">
                      {% for  key, value in Type_CadastroPessoa %}
                        <option value="{{ key }}">{{ value }}</option>
                      {% endfor %}
                    </base-select>
                  </validation-provider>
                </div>

                <div class="col-xs-12">
                  <base-button
                    apperance="outline"
                    @click.native="() => onRemoveModule(moduleIndex)">
                    {{ button_remove }}
                  </base-button>
                </div>
              </div>

            </base-card>
          </div>
          <div class="col-xs-12 col-sm-4">
            <base-card class="padding-large bottom-margin-medium">
              <validation-provider
                tag="div"
                name="descontoprimeiracompra_status"
                rules="required"
                v-slot="{ errors, valid }">
                <base-select
                  label="{{ entry_status }}"
                  name="descontoprimeiracompra_status"
                  v-model="configurations.descontoprimeiracompra_status"
                  :error="errors[0]"
                  :valid="valid"
                  :disabled="disableForm">
                  {% for  key, value in Type_Status %}
                    <option value="{{ key }}">{{ value }}</option>
                  {% endfor %}
                </base-select>
              </validation-provider>

              <validation-provider
                tag="div"
                class="top-margin-large"
                name="descontoprimeiracompra_status_pedido"
                rules="required"
                v-slot="{ errors, valid }">
                <base-select
                  label="{{ entry_status_pedido }}"
                  description="{{ entry_status_pedido_obs }}"
                  name="descontoprimeiracompra_status_pedido"
                  v-model="configurations.descontoprimeiracompra_status_pedido"
                  :error="errors[0]"
                  :valid="valid"
                  :disabled="disableForm">
                  {% for  key, order_status in order_statuses %}
                    <option value="{{ order_status.order_status_id }}">{{ order_status.name }}</option>
                  {% endfor %}
                </base-select>
              </validation-provider>

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


            </base-card>

            <base-button @click.native="onAddModule" class="top-margin-large">
              {{ button_add_module }}
            </base-button>
          </div>
        </div>
      </div>

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

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

{{ footer }}
