index.vue 18 KB

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