diff --git a/modules/worker/back/models/locker.json b/modules/worker/back/models/locker.json index 9601ca129..62ddd0a5b 100644 --- a/modules/worker/back/models/locker.json +++ b/modules/worker/back/models/locker.json @@ -2,11 +2,6 @@ "name": "Locker", "description": "Employee's locker", "base": "VnModel", - "options": { - "mysql": { - "table": "locker" - } - }, "properties": { "code": { "type": "string" @@ -14,12 +9,5 @@ "gender": { "type": "string" } - }, - "relations": { - "worker": { - "type": "belongsTo", - "model": "worker", - "foreignKey": "workerFk" - } } } diff --git a/modules/worker/back/models/worker.js b/modules/worker/back/models/worker.js index 985d83e9f..266a3e1ca 100644 --- a/modules/worker/back/models/worker.js +++ b/modules/worker/back/models/worker.js @@ -20,7 +20,7 @@ module.exports = Self => { require('../methods/worker/isAuthorized')(Self); require('../methods/worker/setPassword')(Self); - Self.validatesUniquenessOf('locker', { - message: 'This locker has already been assigned' - }); + // Self.validatesUniquenessOf('locker', { + // message: 'This locker has already been assigned' + // }); }; diff --git a/modules/worker/back/models/worker.json b/modules/worker/back/models/worker.json index 70c3881cf..4680a4daa 100644 --- a/modules/worker/back/models/worker.json +++ b/modules/worker/back/models/worker.json @@ -53,6 +53,9 @@ }, "isF11Allowed": { "type" : "boolean" + }, + "sex": { + "type" : "string" } }, "relations": { @@ -87,9 +90,9 @@ "foreignKey": "workerFk" }, "locker": { - "type": "belongsTo", + "type": "hasOne", "model": "Locker", - "foreignKey": "code" + "foreignKey": "workerFk" } } } diff --git a/modules/worker/front/basic-data/index.html b/modules/worker/front/basic-data/index.html index a3f122a49..a835483cc 100644 --- a/modules/worker/front/basic-data/index.html +++ b/modules/worker/front/basic-data/index.html @@ -5,6 +5,12 @@ form="form" save="patch"> + +
@@ -75,11 +81,15 @@ ng-model="$ctrl.worker.SSN" rule> - - + data="$ctrl.$.locker.data" + show-field="code" + value-field="id" + ng-model="$ctrl.worker.locker.id"> + --> + diff --git a/modules/worker/front/basic-data/index.js b/modules/worker/front/basic-data/index.js index aae9774ec..2d0b3f300 100644 --- a/modules/worker/front/basic-data/index.js +++ b/modules/worker/front/basic-data/index.js @@ -8,21 +8,27 @@ 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; + } + + 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); + // if(this.$.worker.locker.id != ) return this.$.watcher.submit() .then(() => this.card.reload()); } - // async chooseLocker() { - // const locker = - // `SELECT l.code - // FROM worker w - // JOIN locker l ON w.sex = l.gender - // WHERE w.id = ? AND l.workerFk IS NULL; - // `[this.id]; - - // return locker; - // } } ngModule.vnComponent('vnWorkerBasicData', { diff --git a/modules/worker/front/card/index.js b/modules/worker/front/card/index.js index 9a40e31c2..48cb80f1e 100644 --- a/modules/worker/front/card/index.js +++ b/modules/worker/front/card/index.js @@ -28,6 +28,11 @@ class Controller extends ModuleCard { relation: 'department' } } + }, { + relation: 'locker', + scope: { + fields: ['id', 'code', 'gender'] + } } ] }; diff --git a/modules/worker/front/summary/index.html b/modules/worker/front/summary/index.html index 5e743efa3..b7212815f 100644 --- a/modules/worker/front/summary/index.html +++ b/modules/worker/front/summary/index.html @@ -58,8 +58,9 @@ phone-number="worker.client.phone" > - diff --git a/modules/worker/front/summary/index.js b/modules/worker/front/summary/index.js index 647e47e64..1ee2de54e 100644 --- a/modules/worker/front/summary/index.js +++ b/modules/worker/front/summary/index.js @@ -55,14 +55,9 @@ class Controller extends Summary { { relation: 'locker', scope: { - fields: ['id', 'code', 'gender'], - include: { - relation: 'worker', - scope: {fields: ['id']} - } + fields: ['id', 'code', 'gender'] } } - ] };