This commit is contained in:
parent
69739fca9c
commit
c0c3d913b7
|
@ -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"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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'
|
||||
// });
|
||||
};
|
||||
|
|
|
@ -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"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,12 @@
|
|||
form="form"
|
||||
save="patch">
|
||||
</vn-watcher>
|
||||
<vn-crud-model
|
||||
vn-id="locker"
|
||||
url="Lockers"
|
||||
filter="$ctrl.$.lockerFilter"
|
||||
auto-load="false">
|
||||
</vn-crud-model>
|
||||
<form name="form" ng-submit="$ctrl.onSubmit()" class="vn-w-md">
|
||||
<vn-card class="vn-pa-lg">
|
||||
<vn-vertical>
|
||||
|
@ -75,11 +81,15 @@
|
|||
ng-model="$ctrl.worker.SSN"
|
||||
rule>
|
||||
</vn-textfield>
|
||||
<vn-autocomplete
|
||||
<!-- <vn-autocomplete
|
||||
ng-if="$ctrl.$.locker"
|
||||
label="Locker"
|
||||
url="Lockers"
|
||||
ng-model="$ctrl.locker.code">
|
||||
</vn-autocomplete>
|
||||
data="$ctrl.$.locker.data"
|
||||
show-field="code"
|
||||
value-field="id"
|
||||
ng-model="$ctrl.worker.locker.id">
|
||||
</vn-autocomplete> -->
|
||||
<!-- {{$ctrl.$.locker}} -->
|
||||
</vn-horizontal>
|
||||
</vn-vertical>
|
||||
</vn-card>
|
||||
|
|
|
@ -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', {
|
||||
|
|
|
@ -28,6 +28,11 @@ class Controller extends ModuleCard {
|
|||
relation: 'department'
|
||||
}
|
||||
}
|
||||
}, {
|
||||
relation: 'locker',
|
||||
scope: {
|
||||
fields: ['id', 'code', 'gender']
|
||||
}
|
||||
}
|
||||
]
|
||||
};
|
||||
|
|
|
@ -58,8 +58,9 @@
|
|||
phone-number="worker.client.phone"
|
||||
></vn-link-phone>
|
||||
</vn-label-value>
|
||||
<vn-label-value label="Locker"
|
||||
value="{{worker.locker.code}}"
|
||||
<vn-label-value
|
||||
label="Locker"
|
||||
value="{{worker.locker.code}}"
|
||||
>
|
||||
</vn-label-value>
|
||||
</vn-one>
|
||||
|
|
|
@ -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']
|
||||
}
|
||||
}
|
||||
|
||||
]
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue