Feat: use store/config to display attributs of months

This commit is contained in:
Bertrand Benjamin 2021-08-12 12:22:03 +02:00
parent 4e8189da38
commit db21bc1275
3 changed files with 31 additions and 40 deletions

View File

@ -14,44 +14,25 @@
</div> </div>
</div> </div>
<div id="display"> <div id="display">
<ul> <ul v-show="!editing">
<li> <li v-for="cara in monthDesc" :key='cara.name'>
<label for="ca-theo">CA "Séances effectuées"</label> <label :for='cara.name'>{{ cara.desc }}</label>
<span class="value" v-show="!editing">{{ TheMonth.caTheo ?? ""}}</span> <span class="value" >{{ TheMonth.[cara.name] ?? "∅"}}</span>
<input type="number" v-model.number="monthCopy.caTheo" id="ca-theo" class="value" v-show="editing">
</li>
<li>
<label for="ca-retro">CA "Séances facturées"</label>
<span class="value" v-show="!editing">{{ TheMonth.caRetro ?? ""}}</span>
<input type="number" v-model.number="monthCopy.caRetro" id="ca-retro" class="value" v-show="editing">
</li>
<li>
<label for="ca-react">CA "Séances facturées" réactualisé</label>
<span class="value" v-show="!editing">{{ TheMonth.caReact ?? ""}}</span>
<input type="number" v-model.number="monthCopy.caReact" id="ca-react" class="value" v-show="editing">
</li>
<li>
<label for="nbr-seances">Nombre de séances effectuées</label>
<span class="value" v-show="!editing">{{ TheMonth.sessionQty ?? ""}}</span>
<input type="number" v-model.number="monthCopy.sessionQty" id="nbr-seances" class="value" v-show="editing">
</li>
<li>
<label for="retro">Montant de la rétrocession</label>
<span class="value" v-show="!editing">{{ TheMonth.retro ?? ""}}</span>
<input type="number" v-model.number="monthCopy.retro" id="retro" class="value" v-show="editing">
</li>
<li>
<label for="remuneration">Rémunération </label>
<span class="value" v-show="!editing">{{ TheMonth.remuneration ?? ""}}</span>
<input type="number" v-model.number="monthCopy.remuneration" id="remuneration" class="value" v-show="editing">
</li> </li>
</ul> </ul>
<ul v-show="editing">
<li v-for="cara in monthDesc" :key='cara.name'>
<label :for='cara.name'>{{ cara.desc }}</label>
<input type="number" v-model.number="monthCopy[cara.name]" id="cara.name" class="value">
</li>
</ul>
</div> </div>
</div> </div>
</template> </template>
<script> <script>
import { mapActions } from 'vuex' import { mapActions, mapGetters } from 'vuex'
import { parseISO, format } from 'date-fns' import { parseISO, format } from 'date-fns'
export default { export default {
name: 'MonthPresentation', name: 'MonthPresentation',
@ -71,6 +52,9 @@ export default {
this.monthCopy = {...this.TheMonth} this.monthCopy = {...this.TheMonth}
}, },
computed: { computed: {
...mapGetters('config', {
'monthDesc': 'monthDesc',
}),
rawDate: function () { rawDate: function () {
return parseISO(this.TheDate, "yyyy-MM", new Date()) return parseISO(this.TheDate, "yyyy-MM", new Date())
}, },

View File

@ -10,43 +10,50 @@ const config = {
userDir: './userDir/', userDir: './userDir/',
dataFile: 'datas.csv', dataFile: 'datas.csv',
caProPercentage: 0.5, caProPercentage: 0.5,
monthDesc : { monthDesc : [
caTheo: { {
color: '', color: '',
desc: 'CA "scéances effectuées"', desc: 'CA "scéances effectuées"',
type: 'base', type: 'base',
name: 'caTheo',
}, },
caRetro: { {
color: '', color: '',
desc: 'CA "Séances facturées"', desc: 'CA "Séances facturées"',
type: 'base', type: 'base',
name: 'caRetro',
}, },
caReact: { {
color: '', color: '',
desc: 'CA "Séances facturées" réactualisé', desc: 'CA "Séances facturées" réactualisé',
type: 'base', type: 'base',
name: 'caReact',
}, },
sessionQty: { {
color: '', color: '',
desc: 'Nombre de séances effectuées', desc: 'Nombre de séances effectuées',
type: 'base', type: 'base',
name: 'sessionQty',
}, },
retro: { {
color: '', color: '',
desc: 'Montant de la rétrocession', desc: 'Montant de la rétrocession',
type: 'base', type: 'base',
name: 'retro',
}, },
remu: { {
color: '', color: '',
desc: 'Rémuneration', desc: 'Rémuneration',
type: 'base', type: 'base',
name: 'remu',
}, },
}, ],
} }
}, },
getters: { getters: {
userDir (state) { return state.userDir }, userDir (state) { return state.userDir },
dataFilePath (state) { return path.join(state.userDir, state.dataFile) }, dataFilePath (state) { return path.join(state.userDir, state.dataFile) },
monthDesc (state) { return state.monthDesc },
caProPercentage (state) { return state.caProPercentage }, caProPercentage (state) { return state.caProPercentage },
}, },
mutations: { mutations: {

View File

@ -5,4 +5,4 @@ caTheo,sessionQty,caRetro,caReact,retro,remuneration,date
5700,,4194,5630,627,2000,2021-04 5700,,4194,5630,627,2000,2021-04
6500,,5564,6335,699,2800,2021-05 6500,,5564,6335,699,2800,2021-05
6725,235,5442,6376,638,2800,2021-06 6725,235,5442,6376,638,2800,2021-06
2176,81,1274,,172,2000,2021-07 2176,81,1274,,172,2000,2021-07
1 caTheo sessionQty caRetro caReact retro remuneration date
5 5700 4194 5630 627 2000 2021-04
6 6500 5564 6335 699 2800 2021-05
7 6725 235 5442 6376 638 2800 2021-06
8 2176 81 1274 172 2000 2021-07