index.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428
  1. <!--
  2. Contenu de la page pages/organization.vue
  3. Contient toutes les informations sur l'organization courante
  4. -->
  5. <template>
  6. <LayoutContainer>
  7. <UiForm :id="id" :model="models.Organization" :query="repositories.organizationRepository.query()">
  8. <template #form.input="{entry, updateRepository}">
  9. <v-expansion-panels :value="panel" focusable accordion>
  10. <!-- Description -->
  11. <UiExpansionPanel id="description" icon="fa-info">
  12. <v-container fluid class="container">
  13. <v-row>
  14. <v-col cols="12" sm="6">
  15. <UiInputText field="name" :data="entry['name']" @update="updateRepository" />
  16. </v-col>
  17. <v-col cols="12" sm="6">
  18. <UiInputText field="acronym" :data="entry['acronym']" @update="updateRepository" />
  19. </v-col>
  20. <v-col cols="12" sm="6">
  21. <UiInputText
  22. field="siretNumber"
  23. :data="entry['siretNumber']"
  24. :error="siretError"
  25. :error-message="siretErrorMessage"
  26. :rules="rules.siretRule"
  27. @update="checkSiretHook($event, 'siretNumber', updateRepository)"
  28. />
  29. </v-col>
  30. <v-col cols="12" sm="6">
  31. <UiInputText field="apeNumber" :data="entry['apeNumber']" @update="updateRepository" />
  32. </v-col>
  33. <v-col v-if="entry['legalStatus'] === 'ASSOCIATION_LAW_1901'" cols="12" sm="6">
  34. <UiInputText field="waldecNumber" :data="entry['waldecNumber']" @update="updateRepository" />
  35. </v-col>
  36. <v-col v-if="organizationProfile.isInsideNetwork()" cols="12" sm="6">
  37. <UiInputText :label="organizationProfile.isCmf() ? 'identifierCmf' : 'identifierFfec'" field="identifier" :data="entry['identifier']" @update="updateRepository" />
  38. </v-col>
  39. <v-col v-if="organizationProfile.isFfec()" cols="12" sm="6">
  40. <UiInputText field="ffecApproval" :data="entry['ffecApproval']" @update="updateRepository" />
  41. </v-col>
  42. <v-col cols="12" sm="6">
  43. <UiInputText field="description" :data="entry['description']" @update="updateRepository" />
  44. </v-col>
  45. <v-col cols="12" sm="6">
  46. <UiInputText field="logo" :data="entry['logo']" @update="updateRepository" />
  47. </v-col>
  48. <!-- @todo: ajouter les if et transformer en select-->
  49. <v-col cols="12" sm="6">
  50. <UiInputText field="typeOfPractices" :data="entry['typeOfPractices']" @update="updateRepository" />
  51. </v-col>
  52. <v-col cols="12" sm="6">
  53. <UiInputText field="otherPractice" :data="entry['otherPractice']" @update="updateRepository" />
  54. </v-col>
  55. </v-row>
  56. </v-container>
  57. </UiExpansionPanel>
  58. <!-- Adresses -->
  59. <UiExpansionPanel id="address_postal" icon="fa-globe-europe">
  60. <v-container fluid class="container">
  61. <v-row>
  62. <v-col cols="12" sm="12">
  63. <UiSubList
  64. :query="repositories.addressRepository.with('addressPostal')"
  65. :root-model="models.Organization"
  66. :root-id="id"
  67. :model="models.OrganizationAddressPostal"
  68. loaderType="image"
  69. newLink="/organization/address/new"
  70. >
  71. <template #list.item="{items}">
  72. <v-container fluid>
  73. <v-row dense>
  74. <v-col
  75. v-for="item in items"
  76. :key="item.id"
  77. cols="4"
  78. >
  79. <UiCard
  80. :id="item.id"
  81. :link="`/organization/address/${item.id}`"
  82. :model="models.OrganizationAddressPostal"
  83. >
  84. <template #card.title>
  85. {{ $t(item.type) }}
  86. </template>
  87. <template #card.text>
  88. {{ item.addressPostal.streetAddress }} <br>
  89. <span v-if="item.addressPostal.streetAddressSecond">{{ item.addressPostal.streetAddressSecond }} <br></span>
  90. <span v-if="item.addressPostal.streetAddressThird">{{ item.addressPostal.streetAddressThird }} <br></span>
  91. {{ item.addressPostal.postalCode }} {{ item.addressPostal.addressCity }}<br>
  92. <span v-if="item.addressPostal.addressCountry">
  93. <UiItemFromUri
  94. :model="models.Country"
  95. :query="repositories.countryRepository.query()"
  96. :uri="item.addressPostal.addressCountry"
  97. >
  98. <template #item.text="{item}">
  99. {{item.name}}
  100. </template>
  101. </UiItemFromUri>
  102. </span>
  103. </template>
  104. </UiCard>
  105. </v-col>
  106. </v-row>
  107. </v-container>
  108. </template>
  109. </UiSubList>
  110. </v-col>
  111. </v-row>
  112. </v-container>
  113. </UiExpansionPanel>
  114. <!-- Point de Contact-->
  115. <UiExpansionPanel id="contact_point" icon="fa-phone">
  116. <v-container class="container">
  117. <v-row>
  118. <v-col cols="12" sm="12">
  119. <UiSubList
  120. :query="repositories.contactPointRepository.query()"
  121. :root-model="models.Organization"
  122. :root-id="id"
  123. :model="models.ContactPoint"
  124. loaderType="image"
  125. newLink="/organization/contact_points/new"
  126. >
  127. <template #list.item="{items}">
  128. <v-container fluid>
  129. <v-row dense>
  130. <v-col
  131. v-for="item in items"
  132. :key="item.id"
  133. cols="4"
  134. >
  135. <UiCard
  136. :id="item.id"
  137. :link="`/organization/contact_points/${item.id}`"
  138. :model="models.ContactPoint"
  139. >
  140. <template #card.title>
  141. {{ $t(item.contactType) }}
  142. </template>
  143. <template #card.text>
  144. <span v-if="item.email"><strong>{{ $t('email') }}</strong> : {{ item.email }} <br></span>
  145. <span v-if="item.emailInvalid" class="ot_danger--text"><v-icon class="ot_danger--text">mdi-alert</v-icon> <strong>{{ $t('emailInvalid') }}</strong> : {{ item.emailInvalid }} <br></span>
  146. <span v-if="item.telphone"><strong>{{ $t('telphone') }}</strong> : {{ formatPhoneNumber(item.telphone) }} <br></span>
  147. <span v-if="item.telphoneInvalid" class="ot_danger--text"><v-icon class="ot_danger--text">mdi-alert</v-icon> <strong>{{ $t('telphoneInvalid') }}</strong> : {{ formatPhoneNumber(item.telphoneInvalid) }} <br></span>
  148. <span v-if="item.mobilPhone"><strong>{{ $t('mobilPhone') }}</strong> : {{ formatPhoneNumber(item.mobilPhone) }} <br></span>
  149. <span v-if="item.mobilPhoneInvalid" class="ot_danger--text"><v-icon class="ot_danger--text">mdi-alert</v-icon> <strong>{{ $t('mobilPhoneInvalid') }}</strong> : {{ formatPhoneNumber(item.mobilPhoneInvalid) }} </span>
  150. </template>
  151. </UiCard>
  152. </v-col>
  153. </v-row>
  154. </v-container>
  155. </template>
  156. </UiSubList>
  157. </v-col>
  158. </v-row>
  159. </v-container>
  160. </UiExpansionPanel>
  161. <!-- Informations légales -->
  162. <UiExpansionPanel id="legalInformation" icon="fa-gavel">
  163. <v-container fluid class="container">
  164. <v-row>
  165. <v-col cols="12" sm="6">
  166. <UiInputDatePicker field="creationDate" :data="entry['creationDate']" @update="updateRepository" />
  167. </v-col>
  168. <v-col cols="12" sm="6">
  169. <UiInputText field="prefectureName" :data="entry['prefectureName']" @update="updateRepository" />
  170. </v-col>
  171. <v-col cols="12" sm="6">
  172. <UiInputText field="prefectureNumber" :data="entry['prefectureNumber']" @update="updateRepository" />
  173. </v-col>
  174. <v-col cols="12" sm="6">
  175. <UiInputText field="tvaNumber" :data="entry['tvaNumber']" @update="updateRepository" />
  176. </v-col>
  177. <v-col cols="12" sm="6">
  178. <UiInputEnum field="legalStatus" :data="entry['legalStatus']" enum-type="organization_legal" @update="updateRepository" />
  179. </v-col>
  180. <v-col v-if="!organizationProfile.isManagerProduct()" cols="12" sm="6">
  181. <UiInputEnum field="principalType" :data="entry['principalType']" enum-type="organization_principal_type" @update="updateRepository" />
  182. </v-col>
  183. <v-col v-if="!organizationProfile.isFfec() && !organizationProfile.isManagerProduct() && !organizationProfile.isArtist()" cols="12" sm="6">
  184. <UiInputEnum field="schoolCategory" :data="entry['schoolCategory']" enum-type="organization_school_cat" @update="updateRepository" />
  185. </v-col>
  186. <v-col v-if="organizationProfile.isFfec()" cols="12" sm="6">
  187. <UiInputEnum field="typeEstablishment" :data="entry['typeEstablishment']" enum-type="organization_type_establishment" @update="updateRepository" />
  188. </v-col>
  189. <v-col v-if="entry.typeEstablishment === 'MULTIPLE'" cols="12" sm="6">
  190. <UiInputEnum field="typeEstablishmentDetail" :data="entry['typeEstablishmentDetail']" enum-type="organization_type_establishment_detail" @update="updateRepository" />
  191. </v-col>
  192. </v-row>
  193. </v-container>
  194. </UiExpansionPanel>
  195. <!-- Agréments -->
  196. <UiExpansionPanel id="agrements" icon="fa-certificate">
  197. <v-container class="container">
  198. <v-row>
  199. <v-col cols="12" sm="6">
  200. <UiInputText field="youngApproval" :data="entry['youngApproval']" @update="updateRepository" />
  201. </v-col>
  202. <v-col cols="12" sm="6">
  203. <UiInputText field="trainingApproval" :data="entry['trainingApproval']" @update="updateRepository" />
  204. </v-col>
  205. <v-col cols="12" sm="6">
  206. <UiInputText field="otherApproval" :data="entry['otherApproval']" @update="updateRepository" />
  207. </v-col>
  208. </v-row>
  209. </v-container>
  210. </UiExpansionPanel>
  211. <!-- Salariés -->
  212. <UiExpansionPanel id="salary" icon="fa-users">
  213. <v-container class="container">
  214. <v-row>
  215. <v-col cols="12" sm="6">
  216. <UiInputText field="collectiveAgreement" :data="entry['collectiveAgreement']" @update="updateRepository" />
  217. </v-col>
  218. <v-col cols="12" sm="6">
  219. <UiInputEnum field="opca" :data="entry['opca']" enum-type="organization_opca" @update="updateRepository" />
  220. </v-col>
  221. <v-col cols="12" sm="6">
  222. <UiInputText field="icomNumber" :data="entry['icomNumber']" @update="updateRepository" />
  223. </v-col>
  224. <v-col cols="12" sm="6">
  225. <UiInputText field="urssafNumber" :data="entry['urssafNumber']" @update="updateRepository" />
  226. </v-col>
  227. </v-row>
  228. </v-container>
  229. </UiExpansionPanel>
  230. <!-- Réseaux -->
  231. <UiExpansionPanel v-if="organizationProfile.isInsideNetwork()" id="network" icon="fa-share-alt">
  232. <v-container class="container">
  233. <v-row>
  234. <v-col v-if="organizationProfile.isFfec()" cols="12" sm="6">
  235. <UiInputText field="budget" :data="entry['budget']" type="number" @update="updateRepository" />
  236. </v-col>
  237. <v-col v-if="organizationProfile.isFfec()" cols="12" sm="6">
  238. <UiInputCheckbox field="isPedagogicIsPrincipalActivity" :data="entry['isPedagogicIsPrincipalActivity']" @update="updateRepository" />
  239. </v-col>
  240. <v-col v-if="organizationProfile.isFfec()" cols="12" sm="6">
  241. <UiInputText field="pedagogicBudget" :data="entry['pedagogicBudget']" type="number" @update="updateRepository" />
  242. </v-col>
  243. </v-row>
  244. </v-container>
  245. </UiExpansionPanel>
  246. <!-- Communication -->
  247. <UiExpansionPanel id="communication" icon="fa-rss">
  248. <v-container class="container">
  249. <v-row>
  250. <v-col cols="12" sm="6">
  251. <UiInputText field="twitter" :data="entry['twitter']" @update="updateRepository" />
  252. </v-col>
  253. <v-col cols="12" sm="6">
  254. <UiInputText field="facebook" :data="entry['facebook']" @update="updateRepository" />
  255. </v-col>
  256. <v-col cols="12" sm="6">
  257. <UiInputText field="instagram" :data="entry['instagram']" @update="updateRepository" />
  258. </v-col>
  259. <v-col cols="12" sm="6">
  260. <UiInputCheckbox field="portailVisibility" :data="entry['portailVisibility']" @update="updateRepository" />
  261. </v-col>
  262. <v-col cols="12" sm="6">
  263. <UiInputText field="image" :data="entry['image']" @update="updateRepository" />
  264. </v-col>
  265. </v-row>
  266. </v-container>
  267. </UiExpansionPanel>
  268. <!-- IBAN -->
  269. <UiExpansionPanel id="bank_account" icon="fa-euro-sign">
  270. <v-container class="container">
  271. <v-row>
  272. <v-col cols="12" sm="12">
  273. <UiDataTable
  274. :query="repositories.bankAccountRepository.query()"
  275. :root-model="models.Organization"
  276. :root-id="id"
  277. :model="models.BankAccount"
  278. :headers="datatableHeaders.headersBankAccount"
  279. />
  280. </v-col>
  281. </v-row>
  282. </v-container>
  283. </UiExpansionPanel>
  284. </v-expansion-panels>
  285. </template>
  286. </UiForm>
  287. </LayoutContainer>
  288. </template>
  289. <script lang="ts">
  290. import { defineComponent, useContext } from '@nuxtjs/composition-api'
  291. import { $organizationProfile } from '~/services/profile/organizationProfile'
  292. import { Organization } from '@/models/Organization/Organization'
  293. import { OrganizationAddressPostal } from '~/models/Organization/OrganizationAddressPostal'
  294. import { ContactPoint } from '~/models/Core/ContactPoint'
  295. import { BankAccount } from '~/models/Core/BankAccount'
  296. import { repositoryHelper } from '~/services/store/repository'
  297. import UseValidator from '~/use/form/useValidator'
  298. import { UseNavigationHelpers } from '~/use/form/useNavigationHelpers'
  299. import I18N from '~/services/utils/i18n'
  300. import {Country} from "~/models/Core/Country";
  301. export default defineComponent({
  302. name: 'OrganizationParent',
  303. setup () {
  304. const { store, app: { i18n }, $dataProvider } = useContext()
  305. const organizationProfile = $organizationProfile(store)
  306. const id: number = store.state.profile.organization.id
  307. const repositories = getRepositories()
  308. const { siretError, siretErrorMessage, checkSiret } = UseValidator.useHandleSiret(i18n, $dataProvider)
  309. const checkSiretHook = async (siret: string, field: string, updateRepository: any) => {
  310. await checkSiret(siret)
  311. if (!siretError.value) { updateRepository(siret, field) }
  312. }
  313. const { panel } = UseNavigationHelpers.expansionPanels()
  314. const formatPhoneNumber = (number: string): string => {
  315. return I18N.formatPhoneNumber(number)
  316. }
  317. return {
  318. repositories,
  319. id,
  320. organizationProfile,
  321. models: { Organization, ContactPoint, BankAccount, OrganizationAddressPostal, Country },
  322. datatableHeaders: getDataTablesHeaders(i18n),
  323. rules: getRules(i18n),
  324. siretError,
  325. siretErrorMessage,
  326. checkSiretHook,
  327. formatPhoneNumber,
  328. panel
  329. }
  330. }
  331. })
  332. function getRules (i18n: any) {
  333. return {
  334. nameRules: [
  335. (nameValue: string) => !!nameValue || i18n.t('required'),
  336. (nameValue: string) => (nameValue || '').length <= 128 || i18n.t('name_length_rule')
  337. ],
  338. siretRule: [
  339. (siretValue: string) => /^([0-9]{9}|[0-9]{14})$/.test(siretValue) || i18n.t('siret_error')
  340. ]
  341. }
  342. }
  343. function getDataTablesHeaders (i18n: any) {
  344. return {
  345. headersContactPoint: [
  346. { text: i18n.t('email'), value: 'email' },
  347. { text: i18n.t('telphone'), value: 'telphone' },
  348. { text: i18n.t('mobilPhone'), value: 'mobilPhone' },
  349. { text: i18n.t('actions'), value: 'actions', sortable: false }
  350. ],
  351. headersBankAccount: [
  352. { text: i18n.t('bankName'), value: 'bankName' },
  353. { text: i18n.t('iban'), value: 'iban' },
  354. { text: i18n.t('bic'), value: 'bic' },
  355. { text: i18n.t('actions'), value: 'actions', sortable: false }
  356. ],
  357. headersAddressPostal: [
  358. { text: i18n.t('address_postal_type'), value: 'type' },
  359. { text: i18n.t('address'), value: 'address' },
  360. { text: i18n.t('actions'), value: 'actions', sortable: false }
  361. ]
  362. }
  363. }
  364. function getRepositories () {
  365. return {
  366. organizationRepository: repositoryHelper.getRepository(Organization),
  367. contactPointRepository: repositoryHelper.getRepository(ContactPoint),
  368. bankAccountRepository: repositoryHelper.getRepository(BankAccount),
  369. addressRepository: repositoryHelper.getRepository(OrganizationAddressPostal),
  370. countryRepository: repositoryHelper.getRepository(Country)
  371. }
  372. }
  373. </script>
  374. <style scoped>
  375. .v-icon.v-icon {
  376. font-size: 14px;
  377. }
  378. </style>