refs #5561 feat: permite modificar registros
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
parent
5eac9d20dc
commit
024cb1e3f4
|
@ -0,0 +1,3 @@
|
|||
INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalType, principalId)
|
||||
VALUES
|
||||
('SaleTracking', 'deleteSaleGroupDetail', 'WRITE', 'ALLOW', 'ROLE', 'employee');
|
|
@ -28,11 +28,15 @@ module.exports = Self => {
|
|||
Object.assign(myOptions, options);
|
||||
|
||||
const stmt = new ParameterizedSQL(`
|
||||
SELECT iss.created,
|
||||
SELECT
|
||||
iss.id,
|
||||
iss.created,
|
||||
iss.saleFk,
|
||||
iss.quantity,
|
||||
iss.userFk,
|
||||
ish.id itemShelvingFk,
|
||||
ish.shelvingFk,
|
||||
s.parkingFk,
|
||||
p.code,
|
||||
u.name
|
||||
FROM itemShelvingSale iss
|
||||
|
|
|
@ -35,11 +35,6 @@
|
|||
"type": "belongsTo",
|
||||
"model": "VnUser",
|
||||
"foreignKey": "userFk"
|
||||
},
|
||||
"shelving": {
|
||||
"type": "belongsTo",
|
||||
"model": "Shelving",
|
||||
"foreignKey": "shelvingFk"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
<vn-thead>
|
||||
<vn-tr>
|
||||
<vn-th shrink>
|
||||
<vn-multi-check
|
||||
<vn-multi-check
|
||||
model="model">
|
||||
</vn-multi-check>
|
||||
</vn-th>
|
||||
|
@ -46,7 +46,7 @@
|
|||
ui-sref="order.card.summary({id: {{::order.id}}})" target="_blank">
|
||||
<vn-tr>
|
||||
<vn-td>
|
||||
<vn-check
|
||||
<vn-check
|
||||
ng-model="order.checked"
|
||||
vn-click-stop>
|
||||
</vn-check>
|
||||
|
@ -98,7 +98,7 @@
|
|||
scroll-offset="100">
|
||||
</vn-pagination>
|
||||
</vn-card>
|
||||
<vn-worker-descriptor-popover
|
||||
<vn-worker-descriptor-popover
|
||||
vn-id="workerDescriptor">
|
||||
</vn-worker-descriptor-popover>
|
||||
<vn-client-descriptor-popover
|
||||
|
@ -112,22 +112,22 @@
|
|||
ng-click="contextmenu.filterBySelection()">
|
||||
Filter by selection
|
||||
</vn-item>
|
||||
<vn-item translate
|
||||
ng-if="contextmenu.isFilterAllowed()"
|
||||
<vn-item translate
|
||||
ng-if="contextmenu.isFilterAllowed()"
|
||||
ng-click="contextmenu.excludeSelection()">
|
||||
Exclude selection
|
||||
</vn-item>
|
||||
<vn-item translate
|
||||
ng-if="contextmenu.isFilterAllowed()"
|
||||
<vn-item translate
|
||||
ng-if="contextmenu.isFilterAllowed()"
|
||||
ng-click="contextmenu.removeFilter()">
|
||||
Remove filter
|
||||
</vn-item>
|
||||
<vn-item translate
|
||||
<vn-item translate
|
||||
ng-click="contextmenu.removeAllFilters()">
|
||||
Remove all filters
|
||||
</vn-item>
|
||||
<vn-item translate
|
||||
ng-if="contextmenu.isActionAllowed()"
|
||||
<vn-item translate
|
||||
ng-if="contextmenu.isActionAllowed()"
|
||||
ng-click="contextmenu.copyValue()">
|
||||
Copy value
|
||||
</vn-item>
|
||||
|
@ -138,4 +138,4 @@
|
|||
on-accept="$ctrl.onDelete()"
|
||||
question="All the selected elements will be deleted. Are you sure you want to continue?"
|
||||
message="Delete selected elements">
|
||||
</vn-confirm>
|
||||
</vn-confirm>
|
||||
|
|
|
@ -26,15 +26,29 @@ module.exports = Self => {
|
|||
|
||||
Self.delete = async(saleFk, stateCode, options) => {
|
||||
const myOptions = {};
|
||||
let tx;
|
||||
|
||||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
||||
query = `CALL vn.saleTracking_del(?, ?)`;
|
||||
return Self.rawSql(query,
|
||||
[
|
||||
saleFk,
|
||||
stateCode,
|
||||
], myOptions);
|
||||
if (!myOptions.transaction) {
|
||||
tx = await Self.beginTransaction({});
|
||||
myOptions.transaction = tx;
|
||||
}
|
||||
|
||||
try {
|
||||
const result = await Self.rawSql(`CALL vn.saleTracking_del(?, ?)`,
|
||||
[
|
||||
saleFk,
|
||||
stateCode,
|
||||
], myOptions);
|
||||
|
||||
if (tx) await tx.commit();
|
||||
|
||||
return result;
|
||||
} catch (e) {
|
||||
if (tx) await tx.rollback();
|
||||
throw e;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethod('deleteSaleGroupDetail', {
|
||||
description: 'Elimina los registros de saleGroupDetail',
|
||||
accessType: 'WRITE',
|
||||
accepts: [
|
||||
{
|
||||
arg: 'saleFk',
|
||||
type: 'number',
|
||||
description: 'The sale id'
|
||||
}
|
||||
],
|
||||
returns: {
|
||||
type: ['object'],
|
||||
root: true
|
||||
},
|
||||
http: {
|
||||
path: `/deleteSaleGroupDetail`,
|
||||
verb: 'POST'
|
||||
}
|
||||
});
|
||||
|
||||
Self.deleteSaleGroupDetail = async(saleFk, options) => {
|
||||
const models = Self.app.models;
|
||||
const myOptions = {};
|
||||
let tx;
|
||||
|
||||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
||||
if (!myOptions.transaction) {
|
||||
tx = await Self.beginTransaction({});
|
||||
myOptions.transaction = tx;
|
||||
}
|
||||
|
||||
try {
|
||||
const deletes = await models.SaleGroupDetail.destroyAll({
|
||||
saleFk: saleFk
|
||||
}, myOptions);
|
||||
|
||||
if (tx) await tx.commit();
|
||||
|
||||
return deletes;
|
||||
} catch (e) {
|
||||
if (tx) await tx.rollback();
|
||||
throw e;
|
||||
}
|
||||
};
|
||||
};
|
|
@ -33,21 +33,34 @@ module.exports = Self => {
|
|||
});
|
||||
|
||||
Self.new = async(ctx, saleFk, isChecked, quantity, stateCode, options) => {
|
||||
const myOptions = {};
|
||||
const userId = ctx.req.accessToken.userId;
|
||||
const myOptions = {};
|
||||
let tx;
|
||||
|
||||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
||||
query = `CALL vn.saleTracking_new(?, ?, ?, ?, ?, ?, ?)`;
|
||||
return Self.rawSql(query,
|
||||
[
|
||||
saleFk,
|
||||
isChecked,
|
||||
quantity,
|
||||
userId,
|
||||
stateCode,
|
||||
null
|
||||
], myOptions);
|
||||
if (!myOptions.transaction) {
|
||||
tx = await Self.beginTransaction({});
|
||||
myOptions.transaction = tx;
|
||||
}
|
||||
try {
|
||||
const result = await Self.rawSql(`CALL vn.saleTracking_new(?, ?, ?, ?, ?, ?)`,
|
||||
[
|
||||
saleFk,
|
||||
isChecked,
|
||||
quantity,
|
||||
userId,
|
||||
stateCode,
|
||||
null
|
||||
], myOptions);
|
||||
|
||||
if (tx) await tx.commit();
|
||||
|
||||
return result;
|
||||
} catch (e) {
|
||||
if (tx) await tx.rollback();
|
||||
throw e;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
|
|
@ -3,4 +3,5 @@ module.exports = Self => {
|
|||
require('../methods/sale-tracking/listSaleTracking')(Self);
|
||||
require('../methods/sale-tracking/new')(Self);
|
||||
require('../methods/sale-tracking/delete')(Self);
|
||||
require('../methods/sale-tracking/deleteSaleGroupDetail')(Self);
|
||||
};
|
||||
|
|
|
@ -6,6 +6,16 @@
|
|||
order="concept ASC, quantity DESC"
|
||||
auto-load="true">
|
||||
</vn-crud-model>
|
||||
<vn-crud-model
|
||||
url="Shelvings"
|
||||
data="shelvings"
|
||||
auto-load="true">
|
||||
</vn-crud-model>
|
||||
<vn-crud-model
|
||||
url="Parkings"
|
||||
data="parkings"
|
||||
auto-load="true">
|
||||
</vn-crud-model>
|
||||
<vn-data-viewer model="model">
|
||||
<vn-card class="vn-w-lg">
|
||||
<vn-table model="model">
|
||||
|
@ -29,7 +39,7 @@
|
|||
}"
|
||||
class="circleState"
|
||||
vn-tooltip="sale group detail"
|
||||
>
|
||||
vn-click-stop="$ctrl.clickSaleGroupDetail($index)">
|
||||
</vn-chip>
|
||||
<vn-chip
|
||||
ng-class="{
|
||||
|
@ -158,24 +168,23 @@
|
|||
</vn-worker-descriptor-popover>
|
||||
</vn-popup>
|
||||
|
||||
|
||||
<vn-popup vn-id="itemShelvingSale" message="Shelvings sale">
|
||||
<vn-popup vn-id="itemShelvingSale">
|
||||
<vn-crud-model
|
||||
vn-id="modelSaleTracking"
|
||||
vn-id="modelItemShelvingSale"
|
||||
url="ItemShelvingSales/filter"
|
||||
link="{saleFk: $ctrl.saleId}"
|
||||
limit="20"
|
||||
data="$ctrl.itemShelvingSales"
|
||||
auto-load="true">
|
||||
</vn-crud-model>
|
||||
<vn-data-viewer model="modelSaleTracking" class="vn-w-lg">
|
||||
<vn-data-viewer model="modelItemShelvingSale" class="vn-w-lg">
|
||||
<vn-table>
|
||||
<vn-thead>
|
||||
<vn-tr>
|
||||
<vn-th field="quantity" number>Quantity</vn-th>
|
||||
<vn-th field="workerFk">Worker</vn-th>
|
||||
<vn-th field="shelving" shrink>Shelving</vn-th>
|
||||
<vn-th field="parking" shrink>Parking</vn-th>
|
||||
<vn-th field="shelving" expand>Shelving</vn-th>
|
||||
<vn-th field="parking" expand>Parking</vn-th>
|
||||
<vn-th field="created" expand>Created</vn-th>
|
||||
</vn-tr>
|
||||
</vn-thead>
|
||||
|
@ -186,7 +195,7 @@
|
|||
<field>
|
||||
<vn-input-number class="dense" vn-focus
|
||||
ng-model="itemShelvingSale.quantity"
|
||||
on-change="$ctrl.updateItemShelvingSale(itemShelvingSale)">
|
||||
on-change="$ctrl.updateQuantity(itemShelvingSale)">
|
||||
</vn-input-number>
|
||||
</field>
|
||||
</vn-td-editable>
|
||||
|
@ -197,8 +206,24 @@
|
|||
{{::itemShelvingSale.name | dashIfEmpty}}
|
||||
</span>
|
||||
</vn-td>
|
||||
<vn-td shrink>{{::itemShelvingSale.shelvingFk}}</vn-td>
|
||||
<vn-td shrink>{{::itemShelvingSale.code}}</vn-td>
|
||||
<vn-td expand>
|
||||
<vn-autocomplete
|
||||
data="shelvings"
|
||||
show-field="code"
|
||||
value-field="code"
|
||||
ng-model="itemShelvingSale.shelvingFk"
|
||||
on-change="$ctrl.updateShelving(itemShelvingSale)">
|
||||
</vn-autocomplete>
|
||||
</vn-td>
|
||||
<vn-td expand>
|
||||
<vn-autocomplete
|
||||
data="parkings"
|
||||
show-field="code"
|
||||
value-field="id"
|
||||
ng-model="itemShelvingSale.parkingFk"
|
||||
on-change="$ctrl.updateParking(itemShelvingSale)">
|
||||
</vn-autocomplete>
|
||||
</vn-td>
|
||||
<vn-td expand>{{::itemShelvingSale.created | date: 'dd/MM/yyyy HH:mm'}}</vn-td>
|
||||
</vn-tr>
|
||||
</vn-tbody>
|
||||
|
@ -209,64 +234,3 @@
|
|||
vn-id="worker-descriptor">
|
||||
</vn-worker-descriptor-popover>
|
||||
</vn-popup>
|
||||
|
||||
|
||||
<!-- <vn-dialog
|
||||
vn-id="itemShelvingSale"
|
||||
message="Shelvings sale"
|
||||
on-accept="$ctrl.sendPdfInvoice($data)">
|
||||
<tpl-body>
|
||||
<vn-crud-model
|
||||
vn-id="modelSaleTracking"
|
||||
url="ItemShelvingSales/filter"
|
||||
link="{saleFk: $ctrl.saleId}"
|
||||
limit="20"
|
||||
data="$ctrl.itemShelvingSales"
|
||||
auto-load="true">
|
||||
</vn-crud-model>
|
||||
<vn-data-viewer model="modelSaleTracking" class="vn-w-lg">
|
||||
<vn-table class="scrollable">
|
||||
<vn-thead>
|
||||
<vn-tr>
|
||||
<vn-th field="quantity" number shrink>Quantity</vn-th>
|
||||
<vn-th field="workerFk">Worker</vn-th>
|
||||
<vn-th field="shelving" shrink>Shelving</vn-th>
|
||||
<vn-th field="parking" shrink>Parking</vn-th>
|
||||
<vn-th field="created" expand>Created</vn-th>
|
||||
</vn-tr>
|
||||
</vn-thead>
|
||||
<vn-tbody>
|
||||
<vn-tr ng-repeat="itemShelvingSale in $ctrl.itemShelvingSales">
|
||||
<vn-td-editable number shrink>
|
||||
<text>{{itemShelvingSale.quantity}}</text>
|
||||
<field>
|
||||
<vn-input-number class="dense" vn-focus
|
||||
ng-model="itemShelvingSale.quantity"
|
||||
on-change="$ctrl.updateItemShelvingSale(sale)">
|
||||
</vn-input-number>
|
||||
</field>
|
||||
</vn-td-editable>
|
||||
<vn-td expand>
|
||||
<span
|
||||
class="link"
|
||||
ng-click="workerDescriptor.show($event, itemShelvingSale.userFk)">
|
||||
{{::itemShelvingSale.name | dashIfEmpty}}
|
||||
</span>
|
||||
</vn-td>
|
||||
<vn-td shrink>{{::itemShelvingSale.shelvingFk}}</vn-td>
|
||||
<vn-td shrink>{{::itemShelvingSale.code}}</vn-td>
|
||||
<vn-td expand>{{::itemShelvingSale.created | date: 'dd/MM/yyyy HH:mm'}}</vn-td>
|
||||
</vn-tr>
|
||||
</vn-tbody>
|
||||
</vn-table>
|
||||
</vn-card>
|
||||
</vn-data-viewer>
|
||||
<vn-worker-descriptor-popover
|
||||
vn-id="worker-descriptor">
|
||||
</vn-worker-descriptor-popover>
|
||||
</tpl-body>
|
||||
<tpl-buttons>
|
||||
<input type="button" response="cancel" translate-attr="{value: 'Cancel'}"/>
|
||||
<button response="accept" translate>Confirm</button>
|
||||
</tpl-buttons>
|
||||
</vn-dialog> -->
|
||||
|
|
|
@ -28,49 +28,61 @@ class Controller extends Section {
|
|||
this.$.itemShelvingSale.show();
|
||||
}
|
||||
|
||||
clickSaleGroupDetail(index) {
|
||||
const sale = this.sales[index];
|
||||
const params = {
|
||||
saleFk: sale.saleFk
|
||||
};
|
||||
return this.$http.post('SaleTrackings/deleteSaleGroupDetail', params)
|
||||
.then(() => {
|
||||
sale.hasSaleGroupDetail = false;
|
||||
this.vnApp.showSuccess(this.$t('Data saved!'));
|
||||
});
|
||||
}
|
||||
|
||||
clickPreviousSelected(index) {
|
||||
const sale = this.sales[index];
|
||||
if (!sale.isPreviousSelected) {
|
||||
sale.isPreviousSelected = true;
|
||||
this.saleTrackingNew(sale, 'PREVIOUS_PREPARATION', false);
|
||||
sale.isPreviousSelected = true;
|
||||
} else {
|
||||
this.saleTrackingDel(sale, 'PREVIOUS_PREPARATION');
|
||||
sale.isPreviousSelected = false;
|
||||
sale.isPrevious = false;
|
||||
this.saleTrackingDel(sale, 'PREVIOUS_PREPARATION');
|
||||
}
|
||||
}
|
||||
|
||||
clickPrevious(index) {
|
||||
const sale = this.sales[index];
|
||||
if (!sale.isPrevious) {
|
||||
this.saleTrackingNew(sale, 'PREVIOUS_PREPARATION', true);
|
||||
sale.isPrevious = true;
|
||||
sale.isPreviousSelected = true;
|
||||
this.saleTrackingNew(sale, 'PREVIOUS_PREPARATION', true);
|
||||
} else {
|
||||
sale.isPrevious = false;
|
||||
this.saleTrackingNew(sale, 'PREVIOUS_PREPARATION', false);
|
||||
sale.isPrevious = false;
|
||||
}
|
||||
}
|
||||
|
||||
clickPrepared(index) {
|
||||
const sale = this.sales[index];
|
||||
if (!sale.isPrepared) {
|
||||
sale.isPrepared = true;
|
||||
this.saleTrackingNew(sale, 'PREPARED', true);
|
||||
sale.isPrepared = true;
|
||||
} else {
|
||||
sale.isPrepared = false;
|
||||
this.saleTrackingDel(sale, 'PREPARED');
|
||||
sale.isPrepared = false;
|
||||
}
|
||||
}
|
||||
|
||||
clickControled(index) {
|
||||
const sale = this.sales[index];
|
||||
if (!sale.isControled) {
|
||||
sale.isControled = true;
|
||||
this.saleTrackingNew(sale, 'CHECKED', true);
|
||||
sale.isControled = true;
|
||||
} else {
|
||||
sale.isControled = false;
|
||||
this.saleTrackingDel(sale, 'CHECKED');
|
||||
sale.isControled = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -81,7 +93,7 @@ class Controller extends Section {
|
|||
quantity: sale.quantity,
|
||||
stateCode: stateCode
|
||||
};
|
||||
this.$http.post(`SaleTrackings/replace`, params).then(() => {
|
||||
this.$http.post(`SaleTrackings/new`, params).then(() => {
|
||||
this.vnApp.showSuccess(this.$t('Data saved!'));
|
||||
});
|
||||
}
|
||||
|
@ -95,6 +107,56 @@ class Controller extends Section {
|
|||
this.vnApp.showSuccess(this.$t('Data saved!'));
|
||||
});
|
||||
}
|
||||
|
||||
updateQuantity(itemShelvingSale) {
|
||||
const params = {
|
||||
quantity: itemShelvingSale.quantity
|
||||
};
|
||||
this.$http.patch(`ItemShelvingSales/${itemShelvingSale.id}`, params)
|
||||
.then(() => {
|
||||
this.vnApp.showSuccess(this.$t('Data saved!'));
|
||||
});
|
||||
}
|
||||
|
||||
updateShelving(itemShelvingSale) {
|
||||
const params = {
|
||||
shelvingFk: itemShelvingSale.shelvingFk
|
||||
};
|
||||
this.$http.patch(`ItemShelvings/${itemShelvingSale.itemShelvingFk}`, params)
|
||||
.then(res => {
|
||||
const filter = {
|
||||
fields: ['parkingFk'],
|
||||
where: {
|
||||
code: res.data.shelvingFk
|
||||
}
|
||||
};
|
||||
this.$http.get(`Shelvings/findOne`, {filter})
|
||||
.then(res => {
|
||||
itemShelvingSale.parkingFk = res.data.parkingFk;
|
||||
});
|
||||
|
||||
this.vnApp.showSuccess(this.$t('Data saved!'));
|
||||
});
|
||||
}
|
||||
|
||||
updateParking(itemShelvingSale) {
|
||||
const filter = {
|
||||
fields: ['id'],
|
||||
where: {
|
||||
code: itemShelvingSale.shelvingFk
|
||||
}
|
||||
};
|
||||
this.$http.get(`Shelvings/findOne`, {filter})
|
||||
.then(res => {
|
||||
const params = {
|
||||
parkingFk: itemShelvingSale.parkingFk
|
||||
};
|
||||
this.$http.patch(`Shelvings/${res.data.id}`, params)
|
||||
.then(() => {
|
||||
this.vnApp.showSuccess(this.$t('Data saved!'));
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
ngModule.vnComponent('vnTicketSaleTracking', {
|
||||
|
|
|
@ -1,14 +1,5 @@
|
|||
@import "variables";
|
||||
|
||||
vn-sale-tracking {
|
||||
.chip {
|
||||
display: inline-block;
|
||||
min-width: 15px;
|
||||
min-height: 25px;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
.circleState {
|
||||
display: inline-block;
|
||||
justify-content: center;
|
||||
|
|
Loading…
Reference in New Issue