perf: cleancode
gitea/salix-front/pipeline/pr-dev There was a failure building this commit
Details
gitea/salix-front/pipeline/pr-dev There was a failure building this commit
Details
This commit is contained in:
parent
c25b04e075
commit
4a01f1d930
|
@ -246,9 +246,9 @@ const saleTrackingNew = async (sale, stateCode, isChecked) => {
|
|||
try {
|
||||
const params = {
|
||||
saleFk: sale.saleFk,
|
||||
isChecked: isChecked,
|
||||
isChecked,
|
||||
quantity: sale.quantity,
|
||||
stateCode: stateCode,
|
||||
stateCode,
|
||||
};
|
||||
await axios.post(`SaleTrackings/new`, params);
|
||||
notify(t('globals.dataSaved'), 'positive');
|
||||
|
@ -257,10 +257,10 @@ const saleTrackingNew = async (sale, stateCode, isChecked) => {
|
|||
}
|
||||
};
|
||||
|
||||
const saleTrackingDel = async (sale, stateCode) => {
|
||||
const saleTrackingDel = async ({ saleFk }, stateCode) => {
|
||||
try {
|
||||
const params = {
|
||||
saleFk: sale.saleFk,
|
||||
saleFk,
|
||||
stateCodes: [stateCode],
|
||||
};
|
||||
await axios.post(`SaleTrackings/delete`, params);
|
||||
|
@ -284,14 +284,8 @@ const clickSaleGroupDetail = async (sale) => {
|
|||
|
||||
const clickPreviousSelected = (sale) => {
|
||||
try {
|
||||
if (!sale.isPreviousSelected) {
|
||||
saleTrackingNew(sale, 'PREVIOUS_PREPARATION', false);
|
||||
sale.isPreviousSelected = true;
|
||||
} else {
|
||||
saleTrackingDel(sale, 'PREVIOUS_PREPARATION');
|
||||
sale.isPreviousSelected = false;
|
||||
sale.isPrevious = false;
|
||||
}
|
||||
qCheckBoxController(sale, 'isPreviousSelected');
|
||||
if (!sale.isPreviousSelected) sale.isPrevious = false;
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
|
@ -299,41 +293,28 @@ const clickPreviousSelected = (sale) => {
|
|||
|
||||
const clickPrevious = (sale) => {
|
||||
try {
|
||||
if (!sale.isPrevious) {
|
||||
saleTrackingNew(sale, 'PREVIOUS_PREPARATION', true);
|
||||
sale.isPrevious = true;
|
||||
sale.isPreviousSelected = true;
|
||||
} else {
|
||||
saleTrackingNew(sale, 'PREVIOUS_PREPARATION', false);
|
||||
sale.isPrevious = false;
|
||||
}
|
||||
qCheckBoxController(sale, 'isPrevious');
|
||||
if (sale.isPrevious) sale.isPreviousSelected = true;
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
};
|
||||
|
||||
const clickPrepared = (sale) => {
|
||||
const qCheckBoxController = (sale, action) => {
|
||||
const STATE_CODES = {
|
||||
isControled: 'CHECKED',
|
||||
isPrepared: 'PREPARED',
|
||||
isPrevious: 'PREVIOUS_PREPARATION',
|
||||
isPreviousSelected: 'PREVIOUS_PREPARATION',
|
||||
};
|
||||
const stateCode = STATE_CODES[action];
|
||||
try {
|
||||
if (!sale.isPrepared) {
|
||||
saleTrackingNew(sale, 'PREPARED', true);
|
||||
sale.isPrepared = true;
|
||||
if (!sale[action]) {
|
||||
saleTrackingNew(sale, stateCode, true);
|
||||
sale[action] = true;
|
||||
} else {
|
||||
saleTrackingDel(sale, 'PREPARED');
|
||||
sale.isPrepared = false;
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
};
|
||||
|
||||
const clickControled = (sale) => {
|
||||
try {
|
||||
if (!sale.isControled) {
|
||||
saleTrackingNew(sale, 'CHECKED', true);
|
||||
sale.isControled = true;
|
||||
} else {
|
||||
saleTrackingDel(sale, 'CHECKED');
|
||||
sale.isControled = false;
|
||||
saleTrackingDel(sale, stateCode);
|
||||
sale[action] = false;
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
|
@ -403,7 +384,7 @@ const clickControled = (sale) => {
|
|||
color="warning"
|
||||
class="warning"
|
||||
:toggle-indeterminate="false"
|
||||
@update:model-value="clickPrepared(row)"
|
||||
@update:model-value="qCheckBoxController(row, 'isPrepared')"
|
||||
>
|
||||
<QTooltip>
|
||||
{{ t('ticketSaleTracking.prepared') }}
|
||||
|
@ -413,9 +394,8 @@ const clickControled = (sale) => {
|
|||
:model-value="!!row.isControled"
|
||||
color="yellow"
|
||||
class="yellow"
|
||||
style="stroke: red"
|
||||
:toggle-indeterminate="false"
|
||||
@update:model-value="clickControled(row)"
|
||||
@update:model-value="qCheckBoxController(row, 'isControled')"
|
||||
>
|
||||
<QTooltip>
|
||||
{{ t('ticketSaleTracking.checked') }}
|
||||
|
|
Loading…
Reference in New Issue