2018-09-05 11:47:15 +00:00
|
|
|
import ngModule from '../module';
|
2020-11-23 12:41:51 +00:00
|
|
|
import Summary from 'salix/components/summary';
|
2019-09-26 09:41:56 +00:00
|
|
|
import './style.scss';
|
2018-09-05 11:47:15 +00:00
|
|
|
|
2020-11-23 12:41:51 +00:00
|
|
|
class Controller extends Summary {
|
2020-06-12 12:28:29 +00:00
|
|
|
constructor($element, $, vnFile) {
|
|
|
|
super($element, $);
|
|
|
|
this.vnFile = vnFile;
|
|
|
|
}
|
|
|
|
|
2020-03-18 14:47:38 +00:00
|
|
|
$onChanges() {
|
|
|
|
if (this.claim && this.claim.id)
|
2022-02-28 11:40:44 +00:00
|
|
|
this.loadData();
|
2020-03-18 14:47:38 +00:00
|
|
|
}
|
|
|
|
|
2022-02-28 06:57:46 +00:00
|
|
|
loadData() {
|
2022-02-28 11:40:44 +00:00
|
|
|
return this.$http.get(`Claims/${this.claim.id}/getSummary`).then(res => {
|
|
|
|
if (res && res.data)
|
|
|
|
this.summary = res.data;
|
|
|
|
});
|
2022-02-28 06:57:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
reload() {
|
2022-02-28 11:40:44 +00:00
|
|
|
this.loadData()
|
|
|
|
.then(() => {
|
|
|
|
if (this.card)
|
|
|
|
this.card.reload();
|
2022-03-02 10:07:35 +00:00
|
|
|
|
2022-02-28 11:40:44 +00:00
|
|
|
if (this.parentReload)
|
|
|
|
this.parentReload();
|
|
|
|
});
|
2022-02-28 06:57:46 +00:00
|
|
|
}
|
2022-02-28 11:40:44 +00:00
|
|
|
|
2021-01-12 06:39:12 +00:00
|
|
|
get isSalesPerson() {
|
|
|
|
return this.aclService.hasAny(['salesPerson']);
|
|
|
|
}
|
|
|
|
|
|
|
|
get isClaimManager() {
|
|
|
|
return this.aclService.hasAny(['claimManager']);
|
|
|
|
}
|
|
|
|
|
2020-03-18 14:47:38 +00:00
|
|
|
get claim() {
|
|
|
|
return this._claim;
|
|
|
|
}
|
|
|
|
|
|
|
|
set claim(value) {
|
|
|
|
this._claim = value;
|
|
|
|
|
|
|
|
// Get DMS on summary load
|
2022-02-28 06:57:46 +00:00
|
|
|
if (value) {
|
2020-03-18 14:47:38 +00:00
|
|
|
this.$.$applyAsync(() => this.loadDms());
|
2022-02-28 06:57:46 +00:00
|
|
|
this.loadData();
|
|
|
|
}
|
2020-03-18 14:47:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
loadDms() {
|
|
|
|
this.$.model.where = {
|
|
|
|
claimFk: this.claim.id
|
|
|
|
};
|
|
|
|
this.$.model.refresh();
|
|
|
|
}
|
|
|
|
|
2020-06-12 12:28:29 +00:00
|
|
|
getImagePath(dmsId) {
|
|
|
|
return this.vnFile.getPath(`/api/dms/${dmsId}/downloadFile`);
|
|
|
|
}
|
2022-02-28 06:57:46 +00:00
|
|
|
|
|
|
|
changeState(value) {
|
|
|
|
const params = {
|
|
|
|
id: this.claim.id,
|
|
|
|
claimStateFk: value
|
|
|
|
};
|
|
|
|
|
|
|
|
this.$http.patch(`Claims/updateClaim/${this.claim.id}`, params)
|
|
|
|
.then(() => {
|
|
|
|
this.reload();
|
|
|
|
})
|
|
|
|
.then(() => {
|
|
|
|
this.vnApp.showSuccess(this.$t('Data saved!'));
|
|
|
|
});
|
|
|
|
}
|
2018-09-05 11:47:15 +00:00
|
|
|
}
|
|
|
|
|
2020-06-12 12:28:29 +00:00
|
|
|
Controller.$inject = ['$element', '$scope', 'vnFile'];
|
|
|
|
|
2020-07-24 12:22:30 +00:00
|
|
|
ngModule.vnComponent('vnClaimSummary', {
|
2018-09-05 11:47:15 +00:00
|
|
|
template: require('./index.html'),
|
|
|
|
controller: Controller,
|
|
|
|
bindings: {
|
2022-02-28 06:57:46 +00:00
|
|
|
claim: '<',
|
|
|
|
model: '<?',
|
|
|
|
parentReload: '&'
|
|
|
|
},
|
|
|
|
require: {
|
|
|
|
card: '?^vnClaimCard'
|
2018-09-05 11:47:15 +00:00
|
|
|
}
|
|
|
|
});
|