2019-06-06 11:59:11 +00:00
|
|
|
import ngModule from '../../module';
|
2020-03-18 07:35:59 +00:00
|
|
|
import Section from 'salix/components/section';
|
2019-05-28 09:26:54 +00:00
|
|
|
import './style.scss';
|
|
|
|
|
2020-03-18 07:35:59 +00:00
|
|
|
class Controller extends Section {
|
2020-06-12 12:28:29 +00:00
|
|
|
constructor($element, $, vnFile) {
|
2020-03-18 07:35:59 +00:00
|
|
|
super($element, $);
|
2020-06-12 12:28:29 +00:00
|
|
|
this.vnFile = vnFile;
|
2019-05-28 09:26:54 +00:00
|
|
|
this.filter = {
|
|
|
|
include: {
|
|
|
|
relation: 'dms',
|
|
|
|
scope: {
|
2019-06-06 11:59:11 +00:00
|
|
|
fields: [
|
|
|
|
'dmsTypeFk',
|
|
|
|
'workerFk',
|
2019-07-19 06:13:52 +00:00
|
|
|
'hardCopyNumber',
|
2019-06-06 11:59:11 +00:00
|
|
|
'reference',
|
|
|
|
'description',
|
|
|
|
'hasFile',
|
|
|
|
'file',
|
|
|
|
'created',
|
|
|
|
],
|
2019-05-28 09:26:54 +00:00
|
|
|
include: [{
|
|
|
|
relation: 'dmsType',
|
|
|
|
scope: {
|
|
|
|
fields: ['name']
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
relation: 'worker',
|
|
|
|
scope: {
|
2023-08-30 10:48:57 +00:00
|
|
|
fields: ['id'],
|
2019-05-28 09:26:54 +00:00
|
|
|
include: {
|
|
|
|
relation: 'user',
|
|
|
|
scope: {
|
2020-09-03 13:11:16 +00:00
|
|
|
fields: ['name']
|
2019-05-28 09:26:54 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}]
|
|
|
|
},
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2020-04-28 12:26:02 +00:00
|
|
|
deleteDms(index) {
|
|
|
|
const dmsFk = this.ticketDms[index].dmsFk;
|
|
|
|
this.$http.post(`ticketDms/${dmsFk}/removeFile`)
|
|
|
|
.then(() => {
|
|
|
|
this.$.model.remove(index);
|
|
|
|
this.vnApp.showSuccess(this.$t('Data saved!'));
|
2019-05-28 09:26:54 +00:00
|
|
|
});
|
|
|
|
}
|
2020-06-12 12:28:29 +00:00
|
|
|
|
|
|
|
downloadFile(dmsId) {
|
|
|
|
this.vnFile.download(`api/dms/${dmsId}/downloadFile`);
|
|
|
|
}
|
2021-06-25 08:12:41 +00:00
|
|
|
|
|
|
|
importDms() {
|
2021-06-29 09:59:21 +00:00
|
|
|
try {
|
|
|
|
if (!this.dmsId)
|
|
|
|
throw new Error(`The document indentifier can't be empty`);
|
|
|
|
|
|
|
|
const data = {
|
|
|
|
ticketFk: this.$params.id,
|
|
|
|
dmsFk: this.dmsId
|
|
|
|
};
|
2021-06-25 08:12:41 +00:00
|
|
|
|
2021-06-29 09:59:21 +00:00
|
|
|
this.$http.post('ticketDms', data).then(() => {
|
|
|
|
this.vnApp.showSuccess(this.$t('Data saved!'));
|
|
|
|
this.dmsId = null;
|
|
|
|
this.$.model.refresh();
|
|
|
|
});
|
|
|
|
} catch (e) {
|
|
|
|
this.vnApp.showError(this.$t(e.message));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
2021-06-25 08:12:41 +00:00
|
|
|
}
|
2019-05-28 09:26:54 +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('vnTicketDmsIndex', {
|
2019-05-28 09:26:54 +00:00
|
|
|
template: require('./index.html'),
|
|
|
|
controller: Controller,
|
|
|
|
});
|