RegisterCpr.svelte 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. <script>
  2. export let formData = {};
  3. export let onFieldChange = () => {};
  4. export let requiredFields = new Set();
  5. const indicatorOptions = [
  6. { label: 'Selecione...', value: '' },
  7. { label: 'Sim', value: 'S' },
  8. { label: 'Não', value: 'N' }
  9. ];
  10. const sections = [
  11. {
  12. title: 'Informações Gerais',
  13. description: 'Dados básicos da CPR e status cadastral.',
  14. columns: 2,
  15. fields: [
  16. { key: 'cpr_type_code', label: 'Tipo da CPR' },
  17. // { key: 'cpr_internal_control_number', label: 'Controle Interno' },
  18. // { key: 'cpr_isin_code', label: 'Código ISIN' },
  19. // { key: 'cpr_reference_date', label: 'Data de Referência', type: 'date' },
  20. { key: 'cpr_electronic_emission_indicator', label: 'Emissão Eletrônica', type: 'select', options: indicatorOptions },
  21. { key: 'cpr_automatic_expiration_indicator', label: 'Expiração Automática', type: 'select', options: indicatorOptions }
  22. ]
  23. },
  24. {
  25. title: 'Contas OTC e Liquidação',
  26. description: 'Vinculação das contas na câmara de registro e liquidação.',
  27. columns: 2,
  28. fields: [
  29. { key: 'cpr_otc_register_account_code', label: 'Conta OTC de Registro' },
  30. { key: 'cpr_otc_payment_agent_account_code', label: 'Conta OTC Agente de Pagamento' },
  31. { key: 'cpr_otc_custodian_account_code', label: 'Conta OTC Custódia' },
  32. { key: 'cpr_otc_favored_account_code', label: 'Conta OTC Favorecido' },
  33. { key: 'cpr_settlement_modality_type_code', label: 'Modalidade de Liquidação' },
  34. { key: 'cpr_otc_settlement_bank_account_code', label: 'Conta Bancária de Liquidação' }
  35. ]
  36. },
  37. // {
  38. // title: 'Depósito e Garantias',
  39. // description: 'Detalhes complementares sobre garantias e depósitos.',
  40. // columns: 3,
  41. // fields: [
  42. // // { key: 'cpr_ballast_type_code', label: 'Tipo de lastro' },
  43. // // { key: 'cpr_lot_number', label: 'Número do lote' },
  44. // // { key: 'cpr_ballast_quantity', label: 'Quantidade do lastro' },
  45. // // { key: 'cpr_currency_code', label: 'Código da moeda' },
  46. // // { key: 'cpr_transaction_identification', label: 'Identificação da operação' },
  47. // // { key: 'cpr_guarantee_limit_type_code', label: 'Tipo limite garantia' },
  48. // // { key: 'cpr_mother_code', label: 'Código mãe' },
  49. // // { key: 'cpr_deposit_quantity', label: 'Quantidade depositada' },
  50. // // { key: 'cpr_deposit_unit_price_value', label: 'Valor unitário depósito' },
  51. // // { key: 'cpr_deposit_person_type_acronym', label: 'Tipo pessoa depósito' },
  52. // // { key: 'cpr_deposit_document_number', label: 'Documento do depositante' }
  53. // ]
  54. // },
  55. // {
  56. // title: 'Eventos e operação',
  57. // description: 'Campos relacionados aos eventos e códigos regulatórios.',
  58. // columns: 2,
  59. // fields: [
  60. // // { key: 'cpr_event_type_code', label: 'Tipo do evento' },
  61. // // { key: 'cpr_event_original_date', label: 'Data original do evento', type: 'date' },
  62. // // { key: 'cpr_operation_modality_type_code', label: 'Modalidade da operação' },
  63. // // { key: 'cpr_bacen_reference_code', label: 'Código Bacen' },
  64. // // { key: 'cpr_children_codes', label: 'Códigos filhos (separados por vírgula)', type: 'textarea' }
  65. // ]
  66. // },
  67. {
  68. title: 'SCR e finalidades',
  69. description: 'Dados necessários para reporte ao SCR.',
  70. columns: 2,
  71. fields: [
  72. { key: 'cpr_scr_type_code', label: 'Tipo SCR' },
  73. { key: 'cpr_finality_code', label: 'Finalidade' },
  74. // { key: 'cpr_scr_customer_detail', label: 'Detalhe do cliente' },
  75. // { key: 'cpr_scr_person_type_acronym', label: 'Tipo de pessoa SCR' },
  76. // { key: 'cpr_scr_document_number', label: 'Documento do SCR' },
  77. { key: 'cpr_contract_code', label: 'Código do contrato principal' }
  78. ]
  79. }
  80. ];
  81. function getValue(key) {
  82. return formData?.[key] ?? '';
  83. }
  84. function handleInput(key) {
  85. return (event) => {
  86. onFieldChange(key, event.currentTarget.value);
  87. };
  88. }
  89. </script>
  90. <div class="bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-sm">
  91. <form class="space-y-6 p-4">
  92. {#each sections as section}
  93. <div class="space-y-3">
  94. <div>
  95. <h3 class="text-base font-semibold text-gray-900 dark:text-gray-100">{section.title}</h3>
  96. <p class="text-sm text-gray-500 dark:text-gray-400">{section.description}</p>
  97. </div>
  98. <div class={`grid gap-4 ${section.columns === 3 ? 'md:grid-cols-3' : 'md:grid-cols-2'} grid-cols-1`}>
  99. {#each section.fields as field}
  100. <div class="space-y-1">
  101. <label class="block text-sm font-medium text-gray-700 dark:text-gray-300">
  102. {field.label}
  103. {#if requiredFields?.has(field.key)}
  104. <span class="text-red-500">*</span>
  105. {/if}
  106. </label>
  107. {#if field.type === 'date'}
  108. <input
  109. type="date"
  110. class="w-full rounded border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700/70 text-gray-900 dark:text-gray-100 px-3 py-2 focus:outline-none focus:ring-2 focus:ring-blue-500"
  111. value={getValue(field.key)}
  112. on:input={handleInput(field.key)}
  113. required={requiredFields?.has(field.key)}
  114. />
  115. {:else if field.type === 'textarea'}
  116. <textarea
  117. rows="3"
  118. class="w-full rounded border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700/70 text-gray-900 dark:text-gray-100 px-3 py-2 focus:outline-none focus:ring-2 focus:ring-blue-500"
  119. on:input={handleInput(field.key)}
  120. required={requiredFields?.has(field.key)}
  121. >{getValue(field.key)}</textarea>
  122. {:else if field.type === 'select'}
  123. <select
  124. class="w-full rounded border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700/70 text-gray-900 dark:text-gray-100 px-3 py-2 focus:outline-none focus:ring-2 focus:ring-blue-500"
  125. value={getValue(field.key)}
  126. on:change={handleInput(field.key)}
  127. required={requiredFields?.has(field.key)}
  128. >
  129. {#each field.options as option}
  130. <option value={option.value}>{option.label}</option>
  131. {/each}
  132. </select>
  133. {:else}
  134. <input
  135. type="text"
  136. class="w-full rounded border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700/70 text-gray-900 dark:text-gray-100 px-3 py-2 focus:outline-none focus:ring-2 focus:ring-blue-500"
  137. value={getValue(field.key)}
  138. on:input={handleInput(field.key)}
  139. required={requiredFields?.has(field.key)}
  140. />
  141. {/if}
  142. </div>
  143. {/each}
  144. </div>
  145. </div>
  146. {/each}
  147. </form>
  148. </div>