edit.vue 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469
  1. <template>
  2. <ContainerComponent>
  3. <template>
  4. <v-card class="margin-bottom-20">
  5. <v-toolbar flat class="ot_light_grey" dark>
  6. <v-toolbar-title class="ot_dark_grey--text form_main_title">
  7. Description de l'organisation
  8. <v-btn @click="edit" v-if="readOnly" class="ot_green editBtn">
  9. Modifier
  10. </v-btn>
  11. </v-toolbar-title>
  12. </v-toolbar>
  13. <FormComponent :repository="repositories.organizationRepository" :id="id" :query="repositories.organizationRepository.query()">
  14. <template v-slot:form.input="{entry}">
  15. <v-tabs vertical>
  16. <v-tab><v-icon left>fa-info</v-icon>{{$t('description')}}</v-tab>
  17. <v-tab><v-icon left>fa-gavel</v-icon>{{$t('legalInformation')}}</v-tab>
  18. <v-tab><v-icon left>fa-certificate</v-icon>{{$t('agrements')}}</v-tab>
  19. <v-tab><v-icon left>fa-users</v-icon>{{$t('salary')}}</v-tab>
  20. <v-tab v-if="organizationProfile.isInsideNetwork()"><v-icon left>fa-share-alt</v-icon>{{$t('network')}}</v-tab>
  21. <v-tab><v-icon left>fa-rss</v-icon>{{$t('communication')}}</v-tab>
  22. <v-tab-item>
  23. <v-container fluid class="container">
  24. <v-row>
  25. <v-col cols="12" sm="6">
  26. <InputComponent field="name" :repository="repositories.organizationRepository" :entry="entry" :rules="rules.nameRules" />
  27. </v-col>
  28. <v-col cols="12" sm="6">
  29. <InputComponent field="acronym" :repository="repositories.organizationRepository" :entry="entry" />
  30. </v-col>
  31. <v-col cols="12" sm="6">
  32. <InputComponent
  33. field="siretNumber"
  34. :repository="repositories.organizationRepository"
  35. :entry="entry"
  36. v-on:update="checkSiret"
  37. :error="siretError"
  38. :errorMessage="siretErrorMessage"
  39. :rules="rules.siretRule"
  40. />
  41. </v-col>
  42. <v-col cols="12" sm="6">
  43. <InputComponent field="apeNumber" :repository="repositories.organizationRepository" :entry="entry" />
  44. </v-col>
  45. <v-col cols="12" sm="6" v-if="entry['legalStatus'] === 'ASSOCIATION_LAW_1901'" >
  46. <InputComponent field="waldecNumber" :repository="repositories.organizationRepository" :entry="entry" />
  47. </v-col>
  48. <v-col cols="12" sm="6" v-if="organizationProfile.isInsideNetwork()" >
  49. <InputComponent field="identifier" :repository="repositories.organizationRepository" :entry="entry"
  50. :label="organizationProfile.isCmf() ? 'identifierCmf' : 'identifierFfec'" />
  51. </v-col>
  52. <v-col cols="12" sm="6" v-if="organizationProfile.isFfec()" >
  53. <InputComponent field="ffecApproval" :repository="repositories.organizationRepository" :entry="entry" />
  54. </v-col>
  55. <v-col cols="12" sm="6">
  56. <InputComponent field="description" :repository="repositories.organizationRepository" :entry="entry" />
  57. </v-col>
  58. <v-col cols="12" sm="6">
  59. <InputComponent field="logo" :repository="repositories.organizationRepository" :entry="entry" />
  60. </v-col>
  61. <!-- @todo: ajouter les if et transformer en select-->
  62. <v-col cols="12" sm="6">
  63. <InputComponent field="typeOfPractices" :repository="repositories.organizationRepository" :entry="entry" />
  64. </v-col>
  65. <v-col cols="12" sm="6">
  66. <InputComponent field="otherPractice" :repository="repositories.organizationRepository" :entry="entry" />
  67. </v-col>
  68. </v-row>
  69. </v-container>
  70. </v-tab-item>
  71. <v-tab-item>
  72. <v-container fluid class="container">
  73. <v-row>
  74. <v-col cols="12" sm="6">
  75. <DatePickerComponent field="creationDate" :repository="repositories.organizationRepository" :entry="entry" />
  76. </v-col>
  77. <v-col cols="12" sm="6">
  78. <InputComponent field="prefectureName" :repository="repositories.organizationRepository" :entry="entry" />
  79. </v-col>
  80. <v-col cols="12" sm="6">
  81. <InputComponent field="prefectureNumber" :repository="repositories.organizationRepository" :entry="entry" />
  82. </v-col>
  83. <v-col cols="12" sm="6">
  84. <InputComponent field="tvaNumber" :repository="repositories.organizationRepository" :entry="entry" />
  85. </v-col>
  86. <v-col cols="12" sm="6">
  87. <SelectComponent field="legalStatus" :repository="repositories.organizationRepository" :entry="entry" enumType="organization_legal" />
  88. </v-col>
  89. <v-col cols="12" sm="6" v-if="!organizationProfile.isManagerProduct()" >
  90. <SelectComponent field="principalType" :repository="repositories.organizationRepository"
  91. :entry="entry" enumType="organization_principal_type"
  92. />
  93. </v-col>
  94. <v-col cols="12" sm="6" v-if="!organizationProfile.isFfec() && !organizationProfile.isManagerProduct() && !organizationProfile.isArtist()">
  95. <SelectComponent field="schoolCategory" :repository="repositories.organizationRepository" :entry="entry" enumType="organization_school_cat" />
  96. </v-col>
  97. <v-col cols="12" sm="6" v-if="organizationProfile.isFfec()" >
  98. <SelectComponent field="typeEstablishment" :repository="repositories.organizationRepository" :entry="entry" enumType="organization_type_establishment"/>
  99. </v-col>
  100. <v-col cols="12" sm="6" v-if="entry.typeEstablishment === 'MULTIPLE'" >
  101. <SelectComponent field="typeEstablishmentDetail" :repository="repositories.organizationRepository" :entry="entry" enumType="organization_type_establishment_detail"/>
  102. </v-col>
  103. </v-row>
  104. </v-container>
  105. </v-tab-item>
  106. <v-tab-item>
  107. <v-container fluid class="container">
  108. <v-row>
  109. <v-col cols="12" sm="6">
  110. <InputComponent field="youngApproval" :repository="repositories.organizationRepository" :entry="entry" />
  111. </v-col>
  112. <v-col cols="12" sm="6">
  113. <InputComponent field="trainingApproval" :repository="repositories.organizationRepository" :entry="entry" />
  114. </v-col>
  115. <v-col cols="12" sm="6">
  116. <InputComponent field="otherApproval" :repository="repositories.organizationRepository" :entry="entry" />
  117. </v-col>
  118. </v-row>
  119. </v-container>
  120. </v-tab-item>
  121. <v-tab-item>
  122. <v-container fluid class="container">
  123. <v-row>
  124. <v-col cols="12" sm="6">
  125. <InputComponent field="collectiveAgreement" :repository="repositories.organizationRepository" :entry="entry" />
  126. </v-col>
  127. <v-col cols="12" sm="6">
  128. <SelectComponent field="opca" :repository="repositories.organizationRepository" :entry="entry" enumType="organization_opca" />
  129. </v-col>
  130. <v-col cols="12" sm="6">
  131. <InputComponent field="icomNumber" :repository="repositories.organizationRepository" :entry="entry" />
  132. </v-col>
  133. <v-col cols="12" sm="6">
  134. <InputComponent field="urssafNumber" :repository="repositories.organizationRepository" :entry="entry" />
  135. </v-col>
  136. </v-row>
  137. </v-container>
  138. </v-tab-item>
  139. <v-tab-item v-if="organizationProfile.isInsideNetwork()">
  140. <v-container fluid class="container">
  141. <v-row>
  142. <v-col cols="12" sm="6" v-if="organizationProfile.isFfec()" >
  143. <InputComponent field="budget" :repository="repositories.organizationRepository" :entry="entry" type="number" />
  144. </v-col>
  145. <v-col cols="12" sm="6" v-if="organizationProfile.isFfec()" >
  146. <CheckboxComponent field="isPedagogicIsPrincipalActivity" :repository="repositories.organizationRepository" :entry="entry" />
  147. </v-col>
  148. <v-col cols="12" sm="6" v-if="organizationProfile.isFfec()" >
  149. <InputComponent field="pedagogicBudget" :repository="repositories.organizationRepository" :entry="entry" type="number"/>
  150. </v-col>
  151. </v-row>
  152. </v-container>
  153. </v-tab-item>
  154. <v-tab-item>
  155. <v-container fluid class="container">
  156. <v-row>
  157. <v-col cols="12" sm="6">
  158. <InputComponent field="twitter" :repository="repositories.organizationRepository" :entry="entry" />
  159. </v-col>
  160. <v-col cols="12" sm="6">
  161. <InputComponent field="facebook" :repository="repositories.organizationRepository" :entry="entry" />
  162. </v-col>
  163. <v-col cols="12" sm="6">
  164. <InputComponent field="instagram" :repository="repositories.organizationRepository" :entry="entry" />
  165. </v-col>
  166. <v-col cols="12" sm="6">
  167. <CheckboxComponent field="portailVisibility" :repository="repositories.organizationRepository" :entry="entry" />
  168. </v-col>
  169. <v-col cols="12" sm="6">
  170. <InputComponent field="image" :repository="repositories.organizationRepository" :entry="entry" />
  171. </v-col>
  172. </v-row>
  173. </v-container>
  174. </v-tab-item>
  175. </v-tabs>
  176. </template>
  177. </FormComponent>
  178. </v-card>
  179. </template>
  180. <v-expansion-panels v-model="panel" focusable>
  181. <!-- Adresses -->
  182. <ExpansionPanelComponent :title="$t('address_postal')" icon="fa-globe-europe">
  183. <v-container fluid class="container">
  184. <v-row>
  185. <v-col cols="12" sm="12">
  186. <DataTableComponent
  187. :query="repositories.addressRepository.with('addressPostal')"
  188. :rootModel="models.Organization"
  189. :rootId="id"
  190. :model="models.OrganizationAddressPostal"
  191. :headers="datatableHeaders.headersAddressPostal"
  192. >
  193. <template v-slot:item.type="{item}">
  194. {{$t(item.type)}}
  195. </template>
  196. <template v-slot:item.address="{item}">
  197. {{item['addressPostal.streetAddress']}}
  198. {{item['addressPostal.postalCode']}}
  199. {{item['addressPostal.addressCity']}}
  200. </template>
  201. <template v-slot:sheet.content="{itemId}">
  202. <v-container class="container sheetBottomContainer">
  203. <h2 class="sheet_bottom_title">Adresse postale</h2>
  204. <FormComponent :repository="repositories.addressRepository" :id="itemId" :query="queries.addressQuery()">
  205. <template v-slot:form.input="{entry: addressEntry }">
  206. <v-row>
  207. <v-col cols="12" sm="6">
  208. <SelectComponent field="type" label="address_postal_type" :repository="repositories.addressRepository" :entry="addressEntry" enumType="address_postal_organization" />
  209. </v-col>
  210. <v-col cols="12" sm="6">
  211. <InputComponent field="addressPostal.addressOwner" label="addressOwner" :repository="repositories.addressRepository" :entry="addressEntry" />
  212. </v-col>
  213. <v-col cols="12" sm="6">
  214. <InputComponent field="addressPostal.streetAddress" label="streetAddress" :repository="repositories.addressRepository" :entry="addressEntry" />
  215. </v-col>
  216. <v-col cols="12" sm="6">
  217. <InputComponent field="addressPostal.streetAddressSecond" label="streetAddressSecond" :repository="repositories.addressRepository" :entry="addressEntry" />
  218. </v-col>
  219. <v-col cols="12" sm="6">
  220. <InputComponent field="addressPostal.streetAddressThird" label="streetAddressThird" :repository="repositories.addressRepository" :entry="addressEntry" />
  221. </v-col>
  222. <v-col cols="12" sm="6">
  223. <InputComponent field="addressPostal.postalCode" label="postalCode" :repository="repositories.addressRepository" :entry="addressEntry" />
  224. </v-col>
  225. <v-col cols="12" sm="6">
  226. <InputComponent field="addressPostal.addressCity" label="addressCity" :repository="repositories.addressRepository" :entry="addressEntry" />
  227. </v-col>
  228. <v-col cols="12" sm="6">
  229. <InputComponent field="addressPostal.country" label="country" :repository="repositories.addressRepository" :entry="addressEntry" />
  230. </v-col>
  231. </v-row>
  232. </template>
  233. </FormComponent>
  234. </v-container>
  235. </template>
  236. </DataTableComponent>
  237. </v-col>
  238. </v-row>
  239. </v-container>
  240. </ExpansionPanelComponent>
  241. <!-- Point de Contact-->
  242. <ExpansionPanelComponent :title="$t('contact_point')" icon="fa-phone">
  243. <v-container class="container">
  244. <v-row>
  245. <v-col cols="12" sm="12">
  246. <DataTableComponent
  247. :query="repositories.contactPointRepository.query()"
  248. :rootModel="models.Organization"
  249. :rootId="id"
  250. :model="models.ContactPoint"
  251. :headers="datatableHeaders.headersContactPoint"
  252. >
  253. <template v-slot:sheet.content="{itemId }">
  254. <v-container class="container sheetBottomContainer">
  255. <h2 class="sheet_bottom_title">Point de contact</h2>
  256. <FormComponent :repository="repositories.contactPointRepository" :query="queries.contactPointQuery()" :id="itemId">
  257. <template v-slot:form.input="{entry: contactPointEntry }">
  258. <v-row>
  259. <v-col cols="12" sm="6">
  260. <InputComponent field="email" :repository="repositories.contactPointRepository" :entry="contactPointEntry" />
  261. </v-col>
  262. <v-col cols="12" sm="6">
  263. <InputComponent field="telphone" :repository="repositories.contactPointRepository" :entry="contactPointEntry" />
  264. </v-col>
  265. <v-col cols="12" sm="6">
  266. <InputComponent field="mobilPhone" :repository="repositories.contactPointRepository" :entry="contactPointEntry" />
  267. </v-col>
  268. <v-col cols="12" sm="6">
  269. <InputComponent field="faxNumber" :repository="repositories.contactPointRepository" :entry="contactPointEntry" />
  270. </v-col>
  271. </v-row>
  272. </template>
  273. </FormComponent>
  274. </v-container>
  275. </template>
  276. </DataTableComponent>
  277. </v-col>
  278. </v-row>
  279. </v-container>
  280. </ExpansionPanelComponent>
  281. <!-- IBAN -->
  282. <ExpansionPanelComponent :title="$t('bank_account')" icon="fa-euro-sign">
  283. <v-container class="container">
  284. <v-row>
  285. <v-col cols="12" sm="12">
  286. <DataTableComponent
  287. :query="repositories.bankAccountRepository.query()"
  288. :rootModel="models.Organization"
  289. :rootId="id"
  290. :model="models.BankAccount"
  291. :headers="datatableHeaders.headersBankAccount"
  292. >
  293. <template v-slot:sheet.content="{itemId}">
  294. <v-container class="container sheetBottomContainer">
  295. <h2 class="sheet_bottom_title">IBAN</h2>
  296. <FormComponent :repository="repositories.bankAccountRepository" :id="itemId" :query="queries.bankAccountQuery()">
  297. <template v-slot:form.input="{entry: bankAccountEntry }">
  298. <v-row>
  299. <v-col cols="12" sm="6">
  300. <InputComponent field="bankName" :repository="repositories.bankAccountRepository" :entry="bankAccountEntry" />
  301. </v-col>
  302. <v-col cols="12" sm="6">
  303. <InputComponent field="bic" :repository="repositories.bankAccountRepository" :entry="bankAccountEntry" />
  304. </v-col>
  305. <v-col cols="12" sm="6">
  306. <InputComponent field="iban" :repository="repositories.bankAccountRepository" :entry="bankAccountEntry" />
  307. </v-col>
  308. <v-col cols="12" sm="6">
  309. <InputComponent field="debitAddress" :repository="repositories.bankAccountRepository" :entry="bankAccountEntry" />
  310. </v-col>
  311. <v-col cols="12" sm="6">
  312. <InputComponent field="holder" :repository="repositories.bankAccountRepository" :entry="bankAccountEntry" />
  313. </v-col>
  314. <v-col cols="12" sm="6">
  315. <CheckboxComponent field="principal" :repository="repositories.bankAccountRepository" :entry="bankAccountEntry" />
  316. </v-col>
  317. </v-row>
  318. </template>
  319. </FormComponent>
  320. </v-container>
  321. </template>
  322. </DataTableComponent>
  323. </v-col>
  324. </v-row>
  325. </v-container>
  326. </ExpansionPanelComponent>
  327. </v-expansion-panels>
  328. </ContainerComponent>
  329. </template>
  330. <script lang="ts">
  331. import {defineComponent, useContext, onUnmounted, computed} from '@nuxtjs/composition-api'
  332. import {$dataProvider} from "~/services/dataProvider/dataProvider";
  333. import {$organizationProfile} from "~/services/profile/organizationProfile";
  334. import {Organization} from '@/models/Organization/Organization'
  335. import {OrganizationAddressPostal} from "~/models/Organization/OrganizationAddressPostal";
  336. import {ContactPoint} from "~/models/Core/ContactPoint";
  337. import {BankAccount} from "~/models/Core/BankAccount";
  338. import {useRepositoryHelper} from "~/use/store/useRepository";
  339. import {Utils} from "~/use/form/utils";
  340. export default defineComponent({
  341. name: 'organization_edit',
  342. setup() {
  343. const {store, app:{i18n}} = useContext()
  344. const organizationProfile = $organizationProfile(store)
  345. const id = store.state.profile.organization.id;
  346. const repositories = getRepositories()
  347. const {siretError, siretErrorMessage, checkSiret} = Utils.useHandleSiret()
  348. //onUnmounted( useRepositoryHelper.cleanRepository(repository) )
  349. const readOnly = computed(() => {
  350. return useRepositoryHelper.getReadOnly(repositories.organizationRepository)
  351. })
  352. return {
  353. repositories,
  354. queries: getQueries(),
  355. id,
  356. organizationProfile,
  357. models: {Organization, ContactPoint, BankAccount, OrganizationAddressPostal},
  358. edit: useRepositoryHelper.editRepository(repositories.organizationRepository),
  359. datatableHeaders: getDataTablesHeaders(i18n),
  360. rules: getRules(i18n),
  361. siretError,
  362. siretErrorMessage,
  363. checkSiret,
  364. panel:null,
  365. readOnly
  366. }
  367. },
  368. async asyncData({store, $rest}){
  369. await $dataProvider(store, $rest).getItem(Organization, store.state.profile.organization.id)
  370. }
  371. })
  372. function getRules(i18n: any){
  373. return {
  374. nameRules : [
  375. (nameValue:string) => !!nameValue || i18n.t('required'),
  376. (nameValue:string) => (nameValue || '').length <= 128 || i18n.t('name_length_rule')
  377. ],
  378. siretRule : [
  379. (siretValue:string) => /^([0-9]{9}|[0-9]{14})$/.test(siretValue) || i18n.t('siret_error')
  380. ]
  381. }
  382. }
  383. function getDataTablesHeaders(i18n: any) {
  384. return {
  385. headersContactPoint: [
  386. {text: i18n.t('email'), value: 'email'},
  387. {text: i18n.t('telphone'), value: 'telphone'},
  388. {text: i18n.t('mobilPhone'), value: 'mobilPhone'},
  389. {text: i18n.t('actions'), value: 'actions', sortable: false},
  390. ],
  391. headersBankAccount: [
  392. {text: i18n.t('bankName'), value: 'bankName'},
  393. {text: i18n.t('iban'), value: 'iban'},
  394. {text: i18n.t('bic'), value: 'bic'},
  395. {text: i18n.t('actions'), value: 'actions', sortable: false},
  396. ],
  397. headersAddressPostal: [
  398. {text: i18n.t('address_postal_type'), value: 'type'},
  399. {text: i18n.t('address'), value: 'address'},
  400. {text: i18n.t('actions'), value: 'actions', sortable: false},
  401. ]
  402. }
  403. }
  404. function getRepositories() {
  405. return {
  406. organizationRepository: useRepositoryHelper.initRepository(Organization),
  407. contactPointRepository: useRepositoryHelper.initRepository(ContactPoint, false),
  408. bankAccountRepository: useRepositoryHelper.initRepository(BankAccount, false),
  409. addressRepository: useRepositoryHelper.initRepository(OrganizationAddressPostal, false)
  410. }
  411. }
  412. function getQueries() {
  413. return {
  414. organizationQuery: () => getRepositories().organizationRepository.query(),
  415. contactPointQuery: () => getRepositories().contactPointRepository.query(),
  416. bankAccountQuery: () => getRepositories().bankAccountRepository.query(),
  417. addressQuery: () => getRepositories().addressRepository.with('addressPostal')
  418. }
  419. }
  420. </script>
  421. <style scoped>
  422. .v-tab{
  423. justify-content: left;
  424. font-size: 12px;
  425. }
  426. .v-icon.v-icon{
  427. font-size: 14px;
  428. }
  429. .sheet_bottom_title{
  430. text-align: left;
  431. border-bottom: 1px solid #1ead8d;
  432. margin-bottom: 35px;
  433. }
  434. .sheetBottomContainer{
  435. padding: 20px;
  436. padding-top: 30px;
  437. }
  438. </style>