index.vue 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535
  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" :rules="rules().nameRules" />
  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 v-if="organizationProfile.isInsideNetwork()" cols="12" sm="6">
  21. <UiInputText :label="organizationProfile.isCmf() ? 'identifierCmf' : 'identifierFfec'" field="identifier" :data="entry['identifier']" @update="updateRepository" />
  22. </v-col>
  23. <v-col v-if="organizationProfile.isFfec()" cols="12" sm="6">
  24. <UiInputText field="ffecApproval" :data="entry['ffecApproval']" @update="updateRepository" />
  25. </v-col>
  26. <v-col cols="12" sm="6">
  27. <UiInputText field="description" :data="entry['description']" @update="updateRepository" />
  28. </v-col>
  29. <v-col cols="12" sm="6">
  30. <UiImage
  31. :id="getIdFromUri(entry['logo'])"
  32. :upload="true"
  33. :width="200"
  34. field="logo"
  35. :ownerId="id"
  36. @update="updateRepository"
  37. ></UiImage>
  38. </v-col>
  39. <v-col v-if="!organizationProfile.isManagerProduct()" cols="12" sm="6">
  40. <UiInputEnum field="principalType" :data="entry['principalType']" enum-type="organization_principal_type" @update="updateRepository" />
  41. </v-col>
  42. <v-col v-if="!organizationProfile.isFfec() && !organizationProfile.isManagerProduct() && !organizationProfile.isArtist()" cols="12" sm="6">
  43. <UiInputEnum field="schoolCategory" :data="entry['schoolCategory']" enum-type="organization_school_cat" @update="updateRepository" />
  44. </v-col>
  45. <v-col v-if="organizationProfile.isFfec()" cols="12" sm="6">
  46. <UiInputEnum field="typeEstablishment" :data="entry['typeEstablishment']" enum-type="organization_type_establishment" @update="updateRepository" />
  47. </v-col>
  48. <v-col v-if="entry.typeEstablishment === 'MULTIPLE'" cols="12" sm="6">
  49. <UiInputEnum field="typeEstablishmentDetail" :data="entry['typeEstablishmentDetail']" enum-type="organization_type_establishment_detail" @update="updateRepository" />
  50. </v-col>
  51. <v-col cols="12" sm="6" v-if="organizationProfile.isCmf()">
  52. <UiInputAutocomplete
  53. field="typeOfPractices"
  54. :items="typeOfPractices"
  55. :isLoading="typeOfPracticesFetchingState.pending"
  56. :item-text="['name']"
  57. :data="getIdsFromUris(entry['typeOfPractices'])"
  58. :translate="true"
  59. :multiple="true"
  60. group="category"
  61. :rules="rules().typeOfPractice"
  62. @update="updateRepository($event.map((id) => `/api/type_of_practices/${id}`), 'typeOfPractices')"
  63. />
  64. </v-col>
  65. <v-col cols="12" sm="6" v-if="getIdsFromUris(entry['typeOfPractices']).indexOf(37) >= 0">
  66. <UiInputTextArea field="otherPractice" :data="entry['otherPractice']" @update="updateRepository" />
  67. </v-col>
  68. </v-row>
  69. </v-container>
  70. </UiExpansionPanel>
  71. <!-- Adresses -->
  72. <UiExpansionPanel id="address_postal" icon="fa-globe-europe">
  73. <v-container fluid class="container">
  74. <v-row>
  75. <v-col cols="12" sm="12">
  76. <UiSubResource
  77. :query="repositories().addressRepository.with('addressPostal')"
  78. :root-model="models().Organization"
  79. :root-id="id"
  80. :model="models().OrganizationAddressPostal"
  81. loaderType="image"
  82. newLink="/organization/address/new"
  83. >
  84. <template #list.item="{items}">
  85. <v-container fluid>
  86. <v-row dense>
  87. <v-col
  88. v-for="item in items"
  89. :key="item.id"
  90. cols="4"
  91. >
  92. <UiCard
  93. :id="item.id"
  94. :link="`/organization/address/${item.id}`"
  95. :model="models().OrganizationAddressPostal"
  96. >
  97. <template #card.title>
  98. {{ $t(item.type) }}
  99. </template>
  100. <template #card.text>
  101. {{ item.addressPostal.streetAddress }} <br>
  102. <span v-if="item.addressPostal.streetAddressSecond">{{ item.addressPostal.streetAddressSecond }} <br></span>
  103. <span v-if="item.addressPostal.streetAddressThird">{{ item.addressPostal.streetAddressThird }} <br></span>
  104. {{ item.addressPostal.postalCode }} {{ item.addressPostal.addressCity }}<br>
  105. <span v-if="item.addressPostal.addressCountry">
  106. <UiItemFromUri
  107. :model="models().Country"
  108. :query="repositories().countryRepository.query()"
  109. :uri="item.addressPostal.addressCountry"
  110. >
  111. <template #item.text="{item}">
  112. {{item.name}}
  113. </template>
  114. </UiItemFromUri>
  115. </span>
  116. </template>
  117. </UiCard>
  118. </v-col>
  119. </v-row>
  120. </v-container>
  121. </template>
  122. </UiSubResource>
  123. </v-col>
  124. </v-row>
  125. </v-container>
  126. </UiExpansionPanel>
  127. <!-- Point de Contact-->
  128. <UiExpansionPanel id="contact_point" icon="fa-phone">
  129. <v-container class="container">
  130. <v-row>
  131. <v-col cols="12" sm="12">
  132. <UiSubResource
  133. :query="repositories().contactPointRepository.query()"
  134. :root-model="models().Organization"
  135. :root-id="id"
  136. :model="models().ContactPoint"
  137. loaderType="image"
  138. newLink="/organization/contact_points/new"
  139. >
  140. <template #list.item="{items}">
  141. <v-container fluid>
  142. <v-row dense>
  143. <v-col
  144. v-for="item in items"
  145. :key="item.id"
  146. cols="4"
  147. >
  148. <UiCard
  149. :id="item.id"
  150. :link="`/organization/contact_points/${item.id}`"
  151. :model="models().ContactPoint"
  152. >
  153. <template #card.title>
  154. {{ $t(item.contactType) }}
  155. </template>
  156. <template #card.text>
  157. <span v-if="item.email"><strong>{{ $t('email') }}</strong> : {{ item.email }} <br></span>
  158. <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>
  159. <span v-if="item.telphone"><strong>{{ $t('telphone') }}</strong> : {{ formatPhoneNumber(item.telphone) }} <br></span>
  160. <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>
  161. <span v-if="item.mobilPhone"><strong>{{ $t('mobilPhone') }}</strong> : {{ formatPhoneNumber(item.mobilPhone) }} <br></span>
  162. <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>
  163. </template>
  164. </UiCard>
  165. </v-col>
  166. </v-row>
  167. </v-container>
  168. </template>
  169. </UiSubResource>
  170. </v-col>
  171. </v-row>
  172. </v-container>
  173. </UiExpansionPanel>
  174. <!-- Informations légales -->
  175. <UiExpansionPanel id="legalInformation" icon="fa-gavel">
  176. <v-container fluid class="container">
  177. <v-row>
  178. <v-col cols="12" sm="6">
  179. <UiInputText
  180. field="siretNumber"
  181. :data="entry['siretNumber']"
  182. :error="siretError"
  183. :error-message="siretErrorMessage"
  184. :rules="rules().siretRule"
  185. @update="checkSiretHook($event, 'siretNumber', updateRepository)"
  186. />
  187. </v-col>
  188. <v-col cols="12" sm="6">
  189. <UiInputText field="apeNumber" :data="entry['apeNumber']" @update="updateRepository" />
  190. </v-col>
  191. <v-col v-if="entry['legalStatus'] === 'ASSOCIATION_LAW_1901'" cols="12" sm="6">
  192. <UiInputText field="waldecNumber" :data="entry['waldecNumber']" @update="updateRepository" />
  193. </v-col>
  194. <v-col cols="12" sm="6">
  195. <UiInputDatePicker field="creationDate" :data="entry['creationDate']" @update="updateRepository" />
  196. </v-col>
  197. <v-col cols="12" sm="6">
  198. <UiInputText field="prefectureName" :data="entry['prefectureName']" @update="updateRepository" />
  199. </v-col>
  200. <v-col cols="12" sm="6">
  201. <UiInputText field="prefectureNumber" :data="entry['prefectureNumber']" @update="updateRepository" />
  202. </v-col>
  203. <v-col cols="12" sm="6">
  204. <UiInputDatePicker field="declarationDate" :data="entry['declarationDate']" @update="updateRepository" />
  205. </v-col>
  206. <v-col cols="12" sm="6">
  207. <UiInputText field="tvaNumber" :data="entry['tvaNumber']" @update="updateRepository" />
  208. </v-col>
  209. <v-col cols="12" sm="6">
  210. <UiInputEnum field="legalStatus" :data="entry['legalStatus']" enum-type="organization_legal" @update="updateRepository" />
  211. </v-col>
  212. </v-row>
  213. </v-container>
  214. </UiExpansionPanel>
  215. <!-- Agréments -->
  216. <UiExpansionPanel id="agrements" icon="fa-certificate">
  217. <v-container class="container">
  218. <v-row>
  219. <v-col cols="12" sm="6">
  220. <UiInputText field="youngApproval" :data="entry['youngApproval']" @update="updateRepository" />
  221. </v-col>
  222. <v-col cols="12" sm="6">
  223. <UiInputText field="trainingApproval" :data="entry['trainingApproval']" @update="updateRepository" />
  224. </v-col>
  225. <v-col cols="12" sm="6">
  226. <UiInputText field="otherApproval" :data="entry['otherApproval']" @update="updateRepository" />
  227. </v-col>
  228. </v-row>
  229. </v-container>
  230. </UiExpansionPanel>
  231. <!-- Salariés -->
  232. <UiExpansionPanel id="salary" icon="fa-users">
  233. <v-container class="container">
  234. <v-row>
  235. <v-col cols="12" sm="6">
  236. <UiInputText field="collectiveAgreement" :data="entry['collectiveAgreement']" @update="updateRepository" />
  237. </v-col>
  238. <v-col cols="12" sm="6">
  239. <UiInputEnum field="opca" :data="entry['opca']" enum-type="organization_opca" @update="updateRepository" />
  240. </v-col>
  241. <v-col cols="12" sm="6">
  242. <UiInputText field="icomNumber" :data="entry['icomNumber']" @update="updateRepository" />
  243. </v-col>
  244. <v-col cols="12" sm="6">
  245. <UiInputText field="urssafNumber" :data="entry['urssafNumber']" @update="updateRepository" />
  246. </v-col>
  247. </v-row>
  248. </v-container>
  249. </UiExpansionPanel>
  250. <!-- Réseaux -->
  251. <UiExpansionPanel v-if="organizationProfile.isInsideNetwork()" id="network" icon="fa-share-alt">
  252. <v-container class="container">
  253. <v-row>
  254. <v-col cols="12" sm="12">
  255. <UiSubResource
  256. :query="repositories().netWorkOrganizationRepository.with('network')"
  257. :root-model="models().Organization"
  258. :root-id="id"
  259. :model="models().NetworkOrganization"
  260. loaderType="text"
  261. >
  262. <template #list.item="{items}">
  263. <div v-for="item in items" :key="item.id">
  264. <span>{{ item.network.name }}</span> - <span>{{$t('first_subscription')}} : <UiTemplateDate :data="item.startDate" /></span>
  265. </div>
  266. </template>
  267. </UiSubResource>
  268. </v-col>
  269. <v-col v-if="organizationProfile.isFfec()" cols="12" sm="6">
  270. <UiInputText field="budget" :data="entry['budget']" type="number" @update="updateRepository" />
  271. </v-col>
  272. <v-col v-if="organizationProfile.isFfec()" cols="12" sm="6">
  273. <UiInputCheckbox field="isPedagogicIsPrincipalActivity" :data="entry['isPedagogicIsPrincipalActivity']" @update="updateRepository" />
  274. </v-col>
  275. <v-col v-if="organizationProfile.isFfec()" cols="12" sm="6">
  276. <UiInputText field="pedagogicBudget" :data="entry['pedagogicBudget']" type="number" @update="updateRepository" />
  277. </v-col>
  278. </v-row>
  279. </v-container>
  280. </UiExpansionPanel>
  281. <!-- Communication -->
  282. <UiExpansionPanel id="communication" icon="fa-rss">
  283. <v-container class="container">
  284. <v-row>
  285. <v-col cols="12" sm="6">
  286. <UiInputText field="twitter" :data="entry['twitter']" @update="updateRepository" />
  287. </v-col>
  288. <v-col cols="12" sm="6">
  289. <UiInputText field="youtube" :data="entry['youtube']" @update="updateRepository" />
  290. </v-col>
  291. <v-col cols="12" sm="6">
  292. <UiInputText field="facebook" :data="entry['facebook']" @update="updateRepository" />
  293. </v-col>
  294. <v-col cols="12" sm="6">
  295. <UiInputText field="instagram" :data="entry['instagram']" @update="updateRepository" />
  296. </v-col>
  297. <v-col cols="12" sm="6">
  298. <UiInputCheckbox field="portailVisibility" :data="entry['portailVisibility']" @update="updateRepository" />
  299. </v-col>
  300. <v-col cols="12" sm="6">
  301. <UiImage
  302. :id="getIdFromUri(entry['image'])"
  303. :upload="true"
  304. :width="200"
  305. field="image"
  306. :ownerId="id"
  307. @update="updateRepository"
  308. ></UiImage>
  309. </v-col>
  310. <v-col cols="12" sm="12">
  311. <UiSubResource
  312. :query="repositories().organizationArticleRepository.query()"
  313. :root-model="models().Organization"
  314. :root-id="id"
  315. :model="models().OrganizationArticle"
  316. loaderType="text"
  317. >
  318. <template #list.item="{items}">
  319. <h4 class="ot_grey--text font-weight-regular">{{$t('organizationArticle')}}</h4>
  320. <UiTemplateDataTable
  321. :headers="[
  322. { text: $t('title'), value: 'title' },
  323. { text: $t('link'), value: 'link' },
  324. { text: $t('date'), value: 'date' },
  325. ]"
  326. :items="items"
  327. >
  328. <template #item.date="{item}"><UiTemplateDate :data="item.date" /></template>
  329. </UiTemplateDataTable>
  330. </template>
  331. </UiSubResource>
  332. </v-col>
  333. </v-row>
  334. </v-container>
  335. </UiExpansionPanel>
  336. <!-- IBAN -->
  337. <UiExpansionPanel id="bank_account" icon="fa-euro-sign">
  338. <v-container class="container">
  339. <v-row>
  340. <v-col cols="12" sm="12">
  341. <UiSubResource
  342. :query="repositories().bankAccountRepository.query()"
  343. :root-model="models().Organization"
  344. :root-id="id"
  345. :model="models().BankAccount"
  346. loaderType="image"
  347. newLink="/organization/bank_account/new"
  348. >
  349. <template #list.item="{items}">
  350. <v-container fluid>
  351. <v-row dense>
  352. <v-col
  353. v-for="item in items"
  354. :key="item.id"
  355. cols="4"
  356. >
  357. <UiCard
  358. :id="item.id"
  359. :link="`/organization/bank_account/${item.id}`"
  360. :model="models().BankAccount"
  361. >
  362. <template #card.text>
  363. <span v-if="item.bankName"><strong>{{ $t('bankName') }}</strong> : {{ item.bankName }} <br></span>
  364. <span v-if="item.bic"><strong>{{ $t('bic') }}</strong> : {{ item.bic }} <br></span>
  365. <span v-if="item.bicInvalid" class="ot_danger--text"><v-icon class="ot_danger--text">mdi-alert</v-icon> <strong>{{ $t('bicInvalid') }}</strong> : {{ item.bicInvalid }} <br></span>
  366. <span v-if="item.iban"><strong>{{ $t('iban') }}</strong> : {{ item.iban }} <br></span>
  367. <span v-if="item.ibanInvalid" class="ot_danger--text"><v-icon class="ot_danger--text">mdi-alert</v-icon> <strong>{{ $t('ibanInvalid') }}</strong> : {{ item.ibanInvalid }} <br></span>
  368. </template>
  369. </UiCard>
  370. </v-col>
  371. </v-row>
  372. </v-container>
  373. </template>
  374. </UiSubResource>
  375. </v-col>
  376. </v-row>
  377. </v-container>
  378. </UiExpansionPanel>
  379. </v-expansion-panels>
  380. </template>
  381. </UiForm>
  382. </LayoutContainer>
  383. </template>
  384. <script lang="ts">
  385. import {defineComponent, useContext, reactive} from '@nuxtjs/composition-api'
  386. import { $organizationProfile } from '~/services/profile/organizationProfile'
  387. import { Organization } from '@/models/Organization/Organization'
  388. import { OrganizationAddressPostal } from '~/models/Organization/OrganizationAddressPostal'
  389. import { ContactPoint } from '~/models/Core/ContactPoint'
  390. import { BankAccount } from '~/models/Core/BankAccount'
  391. import { repositoryHelper } from '~/services/store/repository'
  392. import UseValidator from '~/composables/form/useValidator'
  393. import { UseNavigationHelpers } from '~/composables/form/useNavigationHelpers'
  394. import I18N from '~/services/utils/i18n'
  395. import {Country} from "~/models/Core/Country";
  396. import {UseTypeOfPractice} from "~/composables/data/useTypeOfPractice";
  397. import ModelsUtils from "~/services/utils/modelsUtils";
  398. import {NetworkOrganization} from "~/models/Network/NetworkOrganization";
  399. import {OrganizationArticle} from "~/models/Organization/OrganizationArticle";
  400. export default defineComponent({
  401. name: 'OrganizationParent',
  402. setup () {
  403. const { store, app: { i18n }, $dataProvider } = useContext()
  404. const organizationProfile = reactive($organizationProfile(store))
  405. const id: number = store.state.profile.organization.id
  406. const { siretError, siretErrorMessage, checkSiret } = UseValidator.useHandleSiret(i18n, $dataProvider)
  407. const {typeOfPractices, fetchState:typeOfPracticesFetchingState} = new UseTypeOfPractice().getAll()
  408. const checkSiretHook = async (siret: string, field: string, updateRepository: any) => {
  409. await checkSiret(siret)
  410. if (!siretError.value) { updateRepository(siret, field) }
  411. }
  412. const { panel } = UseNavigationHelpers.expansionPanels()
  413. const formatPhoneNumber = (number: string): string => {
  414. return I18N.formatPhoneNumber(number)
  415. }
  416. const getIdsFromUris = (uris: Array<string>) => {
  417. const ids:Array<any> = []
  418. for(const uri of uris){
  419. ids.push(ModelsUtils.extractIdFromUri(uri))
  420. }
  421. return ids
  422. }
  423. const getIdFromUri = (uri: string) => ModelsUtils.extractIdFromUri(uri)
  424. return {
  425. repositories: () => getRepositories(),
  426. id,
  427. organizationProfile,
  428. models: () => { return { Organization, ContactPoint, BankAccount, OrganizationAddressPostal, Country, NetworkOrganization, OrganizationArticle } },
  429. rules: () => getRules(i18n, organizationProfile),
  430. siretError,
  431. siretErrorMessage,
  432. checkSiretHook,
  433. formatPhoneNumber,
  434. typeOfPractices,
  435. typeOfPracticesFetchingState,
  436. panel,
  437. getIdFromUri,
  438. getIdsFromUris
  439. }
  440. }
  441. })
  442. function getRules (i18n: any, $organizationProfile:any) {
  443. return {
  444. nameRules: [
  445. (nameValue: string) => !!nameValue || i18n.t('required'),
  446. (nameValue: string) => (nameValue || '').length <= 128 || i18n.t('name_length_rule')
  447. ],
  448. siretRule: [
  449. (siretValue: string) => /^([0-9]{9}|[0-9]{14})$/.test(siretValue) || i18n.t('siret_error')
  450. ],
  451. typeOfPractice: [
  452. (typeOfPracticeValue: Array<number>) => {
  453. if(!$organizationProfile.isManagerProduct())
  454. return typeOfPracticeValue.length > 0 || i18n.t('required')
  455. return true
  456. }
  457. ]
  458. }
  459. }
  460. function getRepositories () {
  461. return {
  462. organizationRepository: repositoryHelper.getRepository(Organization),
  463. contactPointRepository: repositoryHelper.getRepository(ContactPoint),
  464. bankAccountRepository: repositoryHelper.getRepository(BankAccount),
  465. addressRepository: repositoryHelper.getRepository(OrganizationAddressPostal),
  466. countryRepository: repositoryHelper.getRepository(Country),
  467. netWorkOrganizationRepository: repositoryHelper.getRepository(NetworkOrganization),
  468. organizationArticleRepository: repositoryHelper.getRepository(OrganizationArticle),
  469. }
  470. }
  471. </script>
  472. <style scoped>
  473. .v-icon.v-icon {
  474. font-size: 14px;
  475. }
  476. </style>