diff --git a/modules/worker/back/models/locker.json b/modules/worker/back/models/locker.json index 62ddd0a5b..b329648c1 100644 --- a/modules/worker/back/models/locker.json +++ b/modules/worker/back/models/locker.json @@ -1,7 +1,12 @@ { "name": "Locker", - "description": "Employee's locker", "base": "VnModel", + "description": "Employee's locker", + "options": { + "mysql": { + "table": "locker" + } + }, "properties": { "code": { "type": "string" diff --git a/modules/worker/front/basic-data/index.html b/modules/worker/front/basic-data/index.html index a835483cc..af320f616 100644 --- a/modules/worker/front/basic-data/index.html +++ b/modules/worker/front/basic-data/index.html @@ -7,7 +7,7 @@ diff --git a/modules/worker/front/basic-data/index.js b/modules/worker/front/basic-data/index.js index 2d0b3f300..24d7091a6 100644 --- a/modules/worker/front/basic-data/index.js +++ b/modules/worker/front/basic-data/index.js @@ -8,20 +8,19 @@ class Controller extends Section { {code: 'M', name: this.$t('Married')}, {code: 'S', name: this.$t('Single')} ]; - this.$.lockerFilter = {workerFk: null}; - } - get worker() { - return this._worker; + // this.$.lockerFilter = {workerFk: null}; } + // get worker() { + // return this._worker; + // } - set worker(value) { - this._worker = value; - console.log('VALUE', value); - if (value) { - this.$.lockerFilter = {where: {AND: [{workerFk: null}, {gender: value.sex}]}}; - this.$.locker.refresh(); - } - } + // set worker(value) { + // this._worker = value; + // console.log('VALUE', value); + // if (value) + // this.$.lockerFilter = {where: {AND: [{workerFk: null}, {gender: value.sex}]}}; + // // this.$.locker.refresh(); + // } onSubmit() { console.log(this.worker); console.log(this.$.watcher.orgData); diff --git a/modules/worker/front/locker/index.html b/modules/worker/front/locker/index.html new file mode 100644 index 000000000..c6d31dc85 --- /dev/null +++ b/modules/worker/front/locker/index.html @@ -0,0 +1,50 @@ +
+ + + + + + + + + + +
+
+ + + + +
+ ID: {{id}} +
+
+ {{modelFk}}, {{serialNumber}} +
+
+
+
+
+ + + + +
diff --git a/modules/worker/front/locker/index.js b/modules/worker/front/locker/index.js new file mode 100644 index 000000000..885261e5c --- /dev/null +++ b/modules/worker/front/locker/index.js @@ -0,0 +1,53 @@ +import ngModule from '../module'; +import Section from 'salix/components/section'; +import './style.scss'; + +class Controller extends Section { + constructor($element, $) { + super($element, $); + const filter = { + where: {userFk: this.$params.id}, + include: {relation: 'deviceProduction'} + }; + this.$http.get('DeviceProductionUsers', {filter}). + then(res => { + if (res.data && res.data.length > 0) + this.setCurrentPDA(res.data[0]); + }); + } + + deallocatePDA() { + this.$http.post(`Workers/${this.$params.id}/deallocatePDA`, {pda: this.currentPDA.deviceProductionFk}) + .then(() => { + this.vnApp.showSuccess(this.$t('PDA deallocated')); + delete this.currentPDA; + }); + } + + allocatePDA() { + this.$http.post(`Workers/${this.$params.id}/allocatePDA`, {pda: this.newPDA}) + .then(res => { + if (res.data) + this.setCurrentPDA(res.data); + + this.vnApp.showSuccess(this.$t('PDA allocated')); + delete this.newPDA; + }); + } + + setCurrentPDA(data) { + this.currentPDA = data; + this.currentPDA.description = []; + this.currentPDA.description.push(`ID: ${this.currentPDA.deviceProductionFk}`); + this.currentPDA.description.push(`${this.$t('Model')}: ${this.currentPDA.deviceProduction.modelFk}`); + this.currentPDA.description.push(`${this.$t('Serial Number')}: ${this.currentPDA.deviceProduction.serialNumber}`); + this.currentPDA.description = this.currentPDA.description.join(' '); + } +} + +Controller.$inject = ['$element', '$scope']; + +ngModule.vnComponent('vnWorkerPda', { + template: require('./index.html'), + controller: Controller, +}); diff --git a/modules/worker/front/locker/style.scss b/modules/worker/front/locker/style.scss new file mode 100644 index 000000000..c55c9d218 --- /dev/null +++ b/modules/worker/front/locker/style.scss @@ -0,0 +1,6 @@ +@import "./variables"; + +.text-grey { + color: $color-font-light; +} +