Commit 5b5e2000 authored by Samir Sadyhov's avatar Samir Sadyhov 🤔

канбан-доска - финальные статусы

parent e57e7d3b
......@@ -38,6 +38,8 @@ const KanbanBoard = {
isDelete: false,
selectedItems: [],
finishedCreateRecord: null,
getNextFieldNumber: function(url) {
let p = url.substring(url.indexOf('?') + 1).split('&');
p = p.map(x => {
......@@ -107,16 +109,19 @@ const KanbanBoard = {
},
getDictInfo: async function(){
const {code, title, value, color} = this.statusDict;
const {code, title, value, color, end, quality} = this.statusDict;
const {columns, items, name} = await appAPI.getDictionary(code);
this.columns = [];
for(let key in items) {
const item = items[key];
const parseItem = {
key: item[value]?.value,
countInPart: this.countInPart,
currentPage: 0
};
if(item.hasOwnProperty(title)) {
if(item[title].hasOwnProperty('translations')) {
parseItem.name = item[title]?.translations[AS.OPTIONS.locale];
......@@ -126,8 +131,12 @@ const KanbanBoard = {
}
if(color) parseItem.color = item[color]?.value;
if(end) parseItem.end = item[end]?.value;
if(quality) parseItem.quality = item[quality]?.value;
this.columns.push(parseItem);
}
this.columns.sort((a,b) => a.key - b.key);
},
......@@ -232,7 +241,7 @@ const KanbanBoard = {
removeRegistryRow: function(dataUUID, e) {
e.preventDefault();
e.target.blur();
UIkit.modal.confirm('Вы действительно хотите удалить запись?').then(() => {
UIkit.modal.confirm(i18n.tr('Вы действительно хотите удалить запись?'), {labels: {ok: i18n.tr('Да'), cancel: i18n.tr('Отмена')}}).then(() => {
Cons.showLoader();
try {
rest.synergyGet(`api/registry/delete_doc?dataUUID=${dataUUID}`, res => {
......@@ -347,6 +356,76 @@ const KanbanBoard = {
return cardContainer;
},
openFinishRecord: async function(dataUUID) {
Cons.showLoader();
const player = UTILS.getSynergyPlayer(dataUUID, true);
const meaning = await appAPI.getDocMeaningContent(dataUUID);
const dialog = await UTILS.getModalDialog(
meaning,
player.view.container,
i18n.tr('Зпустить'),
async () => {
if (!player.model.isValid()) {
showMessage(i18n.tr('Заполните обязательные поля'), 'error');
} else {
Cons.showLoader();
const activateResult = await appAPI.activateDoc(dataUUID);
Cons.hideLoader();
UIkit.modal(dialog).hide();
}
}
);
Cons.hideLoader();
UIkit.modal(dialog).show();
dialog.on('hidden', () => {
player.destroy();
dialog.remove();
});
},
createFinishRecord: async function(dataUUID) {
Cons.showLoader();
try {
const {registryCode, matching = [], currentLink} = this.finishedCreateRecord;
const documentID = await AS.FORMS.ApiUtils.getDocumentIdentifier(dataUUID);
const meaning = await appAPI.getDocMeaningContent(dataUUID);
const currentFormData = await appAPI.loadAsfData(dataUUID);
const asfData = [];
asfData.push({
id: currentLink,
type: 'reglink',
key: documentID,
valueID: documentID,
value: meaning
});
for(let i = 0; i < matching.length; i++) {
const {from, to} = matching[i];
const fromData = UTILS.getValue(currentFormData, from);
if (fromData) UTILS.setValue(asfData, to, fromData);
}
const resultCreate = await appAPI.createDocRCC(registryCode, asfData);
if(!resultCreate) throw new Error(i18n.tr('Ошибка создания записи'));
Cons.hideLoader();
this.openFinishRecord(resultCreate.dataID);
} catch (err) {
Cons.hideLoader();
showMessage(err.message, 'error');
}
},
renderColumn: async function(column, data){
const {name, key, color, recordsCount} = column;
const columnContainer = $('<div>', {class: 'column-container', id: `column-${key}`});
......@@ -417,44 +496,70 @@ const KanbanBoard = {
if(parentColumn.key == column.key) return;
Cons.showLoader();
const finishDrop = async () => {
Cons.showLoader();
const mergAsfData = [];
const mergeResult = await appAPI.mergeFormData({
uuid: dataUUID,
data: [{
mergAsfData.push({
id: this.fieldDict,
type: "listbox",
value: column.name,
key: column.key
}]
});
});
if(this.finishedCreateRecord && column.end == '1' && column.quality == '1') {
const currentDate = new Date();
mergAsfData.push({
id: this.finishedCreateRecord.currentDate,
type: "date",
value: dateUtils.formatDate(currentDate, dateUtils.CUSTOM_FORMAT_DATE),
key: dateUtils.formatDate(currentDate, dateUtils.DATE_FORMAT_FULL)
});
}
const mergeResult = await appAPI.mergeFormData({uuid: dataUUID, data: mergAsfData});
if(mergeResult) {
dataColumn.appendChild(document.getElementById(`card-${dataUUID}`));
parentColumn.recordsCount--;
column.recordsCount++;
columnTitle.text(`${column.name} (${column.recordsCount})`);
$(`#column-${parentColumnID} > .column-title`).text(`${parentColumn.name} (${parentColumn.recordsCount})`);
$(`#card-${dataUUID}`).attr('data-parentcolumnid', column.key);
if(mergeResult) {
dataColumn.appendChild(document.getElementById(`card-${dataUUID}`));
parentColumn.recordsCount--;
column.recordsCount++;
if(this.sum) {
const {cmp, prefix = ''} = this.sum;
const parentSumResult = await this.getSumRowInRegistry(cmp, parentColumnID);
const currentSumResult = await this.getSumRowInRegistry(cmp, key);
columnTitle.text(`${column.name} (${column.recordsCount})`);
$(`#column-${parentColumnID} > .column-title`).text(`${parentColumn.name} (${parentColumn.recordsCount})`);
$(`#card-${dataUUID}`).attr('data-parentcolumnid', column.key);
const parentSum = new Intl.NumberFormat('ru-RU').format(Number(parentSumResult[`${cmp}_0`]) || 0) + ` ${prefix}`;
const currentSum = new Intl.NumberFormat('ru-RU').format(Number(currentSumResult[`${cmp}_0`]) || 0) + ` ${prefix}`;
columnSum.text(currentSum);
$(`#column-${parentColumnID} > .column-sum`).text(parentSum);
}
if(this.sum) {
const {cmp, prefix = ''} = this.sum;
const parentSumResult = await this.getSumRowInRegistry(cmp, parentColumnID);
const currentSumResult = await this.getSumRowInRegistry(cmp, key);
if(!rowsButtonIsHidden) getRowsButton.detach().appendTo(columData);
const parentSum = new Intl.NumberFormat('ru-RU').format(Number(parentSumResult[`${cmp}_0`]) || 0) + ` ${prefix}`;
const currentSum = new Intl.NumberFormat('ru-RU').format(Number(currentSumResult[`${cmp}_0`]) || 0) + ` ${prefix}`;
columnSum.text(currentSum);
$(`#column-${parentColumnID} > .column-sum`).text(parentSum);
if(this.finishedCreateRecord && column.end == '1' && column.quality == '1') {
this.createFinishRecord(dataUUID);
}
} else {
showMessage("Произошла ошибка при смене статуса", 'error');
}
if(!rowsButtonIsHidden) getRowsButton.detach().appendTo(columData);
Cons.hideLoader();
}
if(parentColumn.end == '1') {
UIkit.modal.confirm(i18n.tr(`Вы уверены, что хотите перенести сделку из конечного статуса "${parentColumn.name}"?`), {labels: {ok: i18n.tr('Да'), cancel: i18n.tr('Отмена')}}).then(() => {
finishDrop();
}, () => null);
} else {
showMessage("Произошла ошибка при смене статуса", 'error');
finishDrop();
}
Cons.hideLoader();
}).on('dragover', this.allowDrop);
},
......@@ -508,7 +613,8 @@ const KanbanBoard = {
countInPart = 5,
sum,
searchString = null,
massActions
massActions,
finishedCreateRecord = null
} = params;
if(!registryCode) throw new Error(`Не передан параметр registryCode`);
......@@ -539,6 +645,8 @@ const KanbanBoard = {
this.sum = sum;
this.searchString = searchString;
this.finishedCreateRecord = finishedCreateRecord;
await this.getDictInfo();
const saveParam = sessionStorage.getItem(`filterParam_${Cons.getCurrentPage().code}_${AS.OPTIONS.currentUser.userid}`);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment