7489-testToMaster #2515
|
@ -2,11 +2,6 @@
|
||||||
"name": "Locker",
|
"name": "Locker",
|
||||||
"description": "Employee's locker",
|
"description": "Employee's locker",
|
||||||
"base": "VnModel",
|
"base": "VnModel",
|
||||||
"options": {
|
|
||||||
"mysql": {
|
|
||||||
"table": "locker"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"properties": {
|
"properties": {
|
||||||
"code": {
|
"code": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
|
@ -14,12 +9,5 @@
|
||||||
"gender": {
|
"gender": {
|
||||||
"type": "string"
|
"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/isAuthorized')(Self);
|
||||||
require('../methods/worker/setPassword')(Self);
|
require('../methods/worker/setPassword')(Self);
|
||||||
|
|
||||||
Self.validatesUniquenessOf('locker', {
|
// Self.validatesUniquenessOf('locker', {
|
||||||
message: 'This locker has already been assigned'
|
// message: 'This locker has already been assigned'
|
||||||
});
|
// });
|
||||||
};
|
};
|
||||||
|
|
|
@ -53,6 +53,9 @@
|
||||||
},
|
},
|
||||||
"isF11Allowed": {
|
"isF11Allowed": {
|
||||||
"type" : "boolean"
|
"type" : "boolean"
|
||||||
|
},
|
||||||
|
"sex": {
|
||||||
|
"type" : "string"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"relations": {
|
"relations": {
|
||||||
|
@ -87,9 +90,9 @@
|
||||||
"foreignKey": "workerFk"
|
"foreignKey": "workerFk"
|
||||||
},
|
},
|
||||||
"locker": {
|
"locker": {
|
||||||
"type": "belongsTo",
|
"type": "hasOne",
|
||||||
"model": "Locker",
|
"model": "Locker",
|
||||||
"foreignKey": "code"
|
"foreignKey": "workerFk"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,12 @@
|
||||||
form="form"
|
form="form"
|
||||||
save="patch">
|
save="patch">
|
||||||
</vn-watcher>
|
</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">
|
<form name="form" ng-submit="$ctrl.onSubmit()" class="vn-w-md">
|
||||||
<vn-card class="vn-pa-lg">
|
<vn-card class="vn-pa-lg">
|
||||||
<vn-vertical>
|
<vn-vertical>
|
||||||
|
@ -75,11 +81,15 @@
|
||||||
ng-model="$ctrl.worker.SSN"
|
ng-model="$ctrl.worker.SSN"
|
||||||
rule>
|
rule>
|
||||||
</vn-textfield>
|
</vn-textfield>
|
||||||
<vn-autocomplete
|
<!-- <vn-autocomplete
|
||||||
|
ng-if="$ctrl.$.locker"
|
||||||
label="Locker"
|
label="Locker"
|
||||||
url="Lockers"
|
data="$ctrl.$.locker.data"
|
||||||
ng-model="$ctrl.locker.code">
|
show-field="code"
|
||||||
</vn-autocomplete>
|
value-field="id"
|
||||||
|
ng-model="$ctrl.worker.locker.id">
|
||||||
|
</vn-autocomplete> -->
|
||||||
|
<!-- {{$ctrl.$.locker}} -->
|
||||||
</vn-horizontal>
|
</vn-horizontal>
|
||||||
</vn-vertical>
|
</vn-vertical>
|
||||||
</vn-card>
|
</vn-card>
|
||||||
|
|
|
@ -8,21 +8,27 @@ class Controller extends Section {
|
||||||
{code: 'M', name: this.$t('Married')},
|
{code: 'M', name: this.$t('Married')},
|
||||||
{code: 'S', name: this.$t('Single')}
|
{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() {
|
onSubmit() {
|
||||||
|
console.log(this.worker);
|
||||||
|
console.log(this.$.watcher.orgData);
|
||||||
|
// if(this.$.worker.locker.id != )
|
||||||
return this.$.watcher.submit()
|
return this.$.watcher.submit()
|
||||||
.then(() => this.card.reload());
|
.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', {
|
ngModule.vnComponent('vnWorkerBasicData', {
|
||||||
|
|
|
@ -28,6 +28,11 @@ class Controller extends ModuleCard {
|
||||||
relation: 'department'
|
relation: 'department'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}, {
|
||||||
|
relation: 'locker',
|
||||||
|
scope: {
|
||||||
|
fields: ['id', 'code', 'gender']
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
|
@ -58,8 +58,9 @@
|
||||||
phone-number="worker.client.phone"
|
phone-number="worker.client.phone"
|
||||||
></vn-link-phone>
|
></vn-link-phone>
|
||||||
</vn-label-value>
|
</vn-label-value>
|
||||||
<vn-label-value label="Locker"
|
<vn-label-value
|
||||||
value="{{worker.locker.code}}"
|
label="Locker"
|
||||||
|
value="{{worker.locker.code}}"
|
||||||
>
|
>
|
||||||
</vn-label-value>
|
</vn-label-value>
|
||||||
</vn-one>
|
</vn-one>
|
||||||
|
|
|
@ -55,14 +55,9 @@ class Controller extends Summary {
|
||||||
{
|
{
|
||||||
relation: 'locker',
|
relation: 'locker',
|
||||||
scope: {
|
scope: {
|
||||||
fields: ['id', 'code', 'gender'],
|
fields: ['id', 'code', 'gender']
|
||||||
include: {
|
|
||||||
relation: 'worker',
|
|
||||||
scope: {fields: ['id']}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue