|
| 1 | +<template> |
| 2 | + <q-table |
| 3 | + flat bordered |
| 4 | + title="Identités doubles" |
| 5 | + dense |
| 6 | + :rows="rows1" |
| 7 | + :columns="fieldsName" |
| 8 | + row-key="k" |
| 9 | + :rows-per-page-options="[20,50,0]" |
| 10 | + rows-per-page-label="Lignes par page" |
| 11 | + no-data-label="Aucune donnée" |
| 12 | + loading-label="Chargement..." |
| 13 | + no-results-label="Aucun résultat" |
| 14 | + > |
| 15 | + <template v-slot:body="props"> |
| 16 | + <q-tr :props="props"> |
| 17 | + <q-td |
| 18 | + v-for="col in props.cols" |
| 19 | + :key="col.name" |
| 20 | + :props="props" |
| 21 | + > |
| 22 | + <template v-if="col.name === 'id1'" > |
| 23 | + <q-btn round size="sm" color="green" icon="mdi-account-edit" @click="edit(col.value,'text-positive')"> |
| 24 | + <q-tooltip class="text-body2">Editer l'identité</q-tooltip> |
| 25 | + </q-btn> |
| 26 | + <q-btn round size="sm" color="green" icon="mdi-account-multiple"> |
| 27 | + <q-tooltip class="text-body2">fusionner les deux identités</q-tooltip> |
| 28 | + </q-btn> |
| 29 | + <q-btn round size="sm" color="green" icon="mdi-account-remove"> |
| 30 | + <q-tooltip class="text-body2">supprimer l'identité</q-tooltip> |
| 31 | + </q-btn> |
| 32 | + </template> |
| 33 | + <template v-else-if="col.name === 'id2'"> |
| 34 | + <q-btn round size="sm" color="red" icon="mdi-account-edit" @click="edit(col.value,'text-negative')"> |
| 35 | + <q-tooltip class="text-body2">Editer l'identité</q-tooltip> |
| 36 | + </q-btn> |
| 37 | + <q-btn round size="sm" color="red" icon="mdi-account-multiple"> |
| 38 | + <q-tooltip class="text-body2">fusionner les deux identités</q-tooltip> |
| 39 | + </q-btn> |
| 40 | + <q-btn round size="sm" color="red" icon="mdi-account-remove"> |
| 41 | + <q-tooltip class="text-body2">supprimer l'identité</q-tooltip> |
| 42 | + </q-btn> |
| 43 | + </template> |
| 44 | + <template v-else> |
| 45 | + {{ col.value }} |
| 46 | + </template> |
| 47 | + |
| 48 | + </q-td> |
| 49 | + </q-tr> |
| 50 | + </template> |
| 51 | + </q-table> |
| 52 | + <q-dialog v-model="editForm" full-width full-height persistent> |
| 53 | + <q-card> |
| 54 | + <q-card-section class="row items-center q-pb-none"> |
| 55 | + <h6 :class="cnColor">{{ cn }}</h6> |
| 56 | + <q-space></q-space> |
| 57 | + <q-btn class="q-mx-xs" icon="mdi-check" color="positive"> |
| 58 | + <q-tooltip>Enregistrer</q-tooltip> |
| 59 | + </q-btn> |
| 60 | + <q-btn class="q-mx-xs" icon="mdi-close" color="negative" v-close-popup > |
| 61 | + <q-tooltip>Quitter</q-tooltip> |
| 62 | + </q-btn> |
| 63 | + </q-card-section> |
| 64 | + <q-card-section> |
| 65 | + <sesame-identity-form :identity="identity"></sesame-identity-form> |
| 66 | + </q-card-section> |
| 67 | + </q-card> |
| 68 | + </q-dialog> |
| 69 | +</template> |
| 70 | +<script setup> |
| 71 | +import {ref} from "vue"; |
| 72 | +import {useQuasar} from "quasar"; |
| 73 | +import { useRouter } from 'vue-router' |
| 74 | +const router=useRouter() |
| 75 | +const $q=useQuasar() |
| 76 | +const editForm=ref(false) |
| 77 | +const identity=ref(null) |
| 78 | +const cn=ref("") |
| 79 | +const cnColor=ref("text-positive") |
| 80 | +const rows=[] |
| 81 | +const fieldsName=[ |
| 82 | + {name:'id1',label:'action',field:'id1', align: 'center',classes:"leftidlight"}, |
| 83 | + {name:'uid1',label:'identité 1',field:'uid1', align: 'left',classes:"leftid"}, |
| 84 | + {name:'cn1',label:'Nom Prenom 1',field:'cn1', align: 'left',classes:"leftidlight"}, |
| 85 | + {name:'employeeNumber1',label:'Numero',field:'employeeNumber1', align: 'left',classes:"leftidlight"}, |
| 86 | + {name:'departmentNumber1',label:'Departement',field:'departmentNumber1', align: 'left',classes:"leftidlight"}, |
| 87 | + {name:'id2',label:'action',field:'id2', align: 'center',classes:"rightidlight"}, |
| 88 | + {name:'uid2',label:'identité 2',field:'uid2', align: 'left',classes:"rightid"}, |
| 89 | + {name:'cn2',label:'Nom Prenom 2',field:'cn2', align: 'left',classes:"rightidlight"}, |
| 90 | + {name:'employeeNumber2',label:'Numero',field:'employeeNumber2', align: 'left',classes:"rightidlight"}, |
| 91 | + {name:'departmentNumber2',label:'Departement',field:'departmentNumber2', align: 'left',classes:"rightidlight"}, |
| 92 | +] |
| 93 | +const actions = { |
| 94 | + read: async (id) => { |
| 95 | + const data = await $http.get(`/management/identities/` + id , { |
| 96 | + method: 'get', |
| 97 | + }) |
| 98 | + return {...data._data?.data} |
| 99 | + } |
| 100 | +} |
| 101 | +
|
| 102 | +const { data: rows1, pending, error, refresh } = await useHttp('/management/identities/duplicates', { |
| 103 | + method: 'GET', |
| 104 | + transform: (result)=>{ |
| 105 | +
|
| 106 | + const allFields=result.data.map((enr)=>{ |
| 107 | + return { |
| 108 | + k:enr.k +'='+ enr.k1, |
| 109 | + id1:enr.data.at(0)._id, |
| 110 | + uid1:enr.data.at(0).uid, |
| 111 | + cn1:enr.data.at(0).cn, |
| 112 | + employeeNumber1:enr.data.at(0).employeeNumber, |
| 113 | + departmentNumber1:enr.data.at(0).departmentNumber.join(','), |
| 114 | + id2:enr.data.at(1)._id, |
| 115 | + uid2:enr.data.at(1).uid, |
| 116 | + cn2:enr.data.at(1).cn, |
| 117 | + employeeNumber2:enr.data.at(1).employeeNumber, |
| 118 | + departmentNumber2:enr.data.at(1).departmentNumber.join(','), |
| 119 | + } |
| 120 | + //return { k: enr.k, uid1: enr.data[Ø].uid, cn1:enr.data[0].cn, uid2: enr.data[1].uid, cn2:enr.data[1].cn,} |
| 121 | + }) |
| 122 | + console.log("RESULT " + allFields) |
| 123 | + return allFields |
| 124 | + } |
| 125 | +}); |
| 126 | +async function edit(id,colorClass){ |
| 127 | + identity.value=await actions.read(id) |
| 128 | + cnColor.value=colorClass |
| 129 | + cn.value=identity.value.inetOrgPerson.cn |
| 130 | + editForm.value=true |
| 131 | +} |
| 132 | +</script> |
| 133 | +<style> |
| 134 | +.leftid { |
| 135 | + color:white; |
| 136 | + background:green !important; |
| 137 | +} |
| 138 | +.leftidlight { |
| 139 | + color:black; |
| 140 | + background: #cfe4d4 !important; |
| 141 | +} |
| 142 | +.rightid { |
| 143 | + color:white; |
| 144 | + background:darkred !important; |
| 145 | +} |
| 146 | +.rightidlight { |
| 147 | + color:black; |
| 148 | + background: #ecd6d6 !important; |
| 149 | +} |
| 150 | +</style> |
0 commit comments