5331 lines
200 KiB
JavaScript
5331 lines
200 KiB
JavaScript
|
|
Vue.config.devtools = true;
|
|||
|
|
//$(document).ready(function() {
|
|||
|
|
Vue.component('v-select', VueSelect.VueSelect);
|
|||
|
|
|
|||
|
|
var role = new Vue({
|
|||
|
|
el: '#setting_roles',
|
|||
|
|
components: {
|
|||
|
|
Multiselect: window.VueMultiselect.default,
|
|||
|
|
//vuejsDatepicker: window.vuejsDatepicker
|
|||
|
|
},
|
|||
|
|
data: {
|
|||
|
|
setModal: false,
|
|||
|
|
setOtdel: false,
|
|||
|
|
name: '',
|
|||
|
|
rolesEmp: [],
|
|||
|
|
isInput: false,
|
|||
|
|
nameRole: '',
|
|||
|
|
typeRole: { 'name': 'Менеджер', 'type': 'manager' },
|
|||
|
|
roles: [{ 'name': 'Руководитель (агенство)', 'type': 'user_admin' }, { 'name': 'Руководитель (отдел)', 'type': 'admin_department' }, { 'name': 'Офис менеджер (админ)', 'type': 'manager_office' }, { 'name': 'Менеджер', 'type': 'manager' }, { 'name': 'Офис менеджер (менеджер)', 'type': 'manager_office_menager' }, { 'name': 'Агент', 'type': 'agent' }],
|
|||
|
|
errorOtdel: '',
|
|||
|
|
mes_error_otdel: false,
|
|||
|
|
empRoles: { 'agent': 'Агент', 'manager': 'Менеджер', 'user_admin': 'Руководитель (агенство)', 'admin_department': 'Руководитель (отдел)', 'manager_office': 'Офис менеджер(админ)', 'manager_office_menager': 'Офис менеджер(менеджер)' },
|
|||
|
|
otdelId: 0,
|
|||
|
|
otdels: [],
|
|||
|
|
agencyId: $('#agency_id_dep').val(),
|
|||
|
|
OpenIndicator: {
|
|||
|
|
render: createElement => createElement('span', { class: { 'vueToggleSpan': true } }),
|
|||
|
|
},
|
|||
|
|
},
|
|||
|
|
methods: {
|
|||
|
|
addOtdel: function() {
|
|||
|
|
role.otdelId = 0;
|
|||
|
|
role.rolesEmp = [];
|
|||
|
|
role.name = '';
|
|||
|
|
role.isInput = false;
|
|||
|
|
role.setOtdel = true;
|
|||
|
|
|
|||
|
|
},
|
|||
|
|
addRole: function() {
|
|||
|
|
if (role.isEmpty(role.nameRole)) {
|
|||
|
|
role.errorOtdel += "<p>Заполните название роли</p>";
|
|||
|
|
role.mes_error_otdel = true;
|
|||
|
|
setTimeout(function() {
|
|||
|
|
role.errorOtdel = "";
|
|||
|
|
role.mes_error_otdel = false;
|
|||
|
|
}, 3000);
|
|||
|
|
}
|
|||
|
|
console.log(role.typeRole);
|
|||
|
|
if (role.isEmpty(role.typeRole)) {
|
|||
|
|
role.errorOtdel += "<p>Заполните доступ для роли</p>";
|
|||
|
|
role.mes_error_otdel = true;
|
|||
|
|
setTimeout(function() {
|
|||
|
|
role.errorOtdel = "";
|
|||
|
|
role.mes_error_otdel = false;
|
|||
|
|
}, 3000);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (!role.mes_error_otdel) {
|
|||
|
|
var roleOne = { 'name': role.nameRole, 'type': role.typeRole.type, 'isDiv': true, 'isEdit': false };
|
|||
|
|
console.log(roleOne);
|
|||
|
|
role.rolesEmp.push(roleOne);
|
|||
|
|
role.nameRole = '';
|
|||
|
|
role.typeRole = { 'name': 'Менеджер', 'type': 'manager', };
|
|||
|
|
role.isInput = false;
|
|||
|
|
$('.ui-tooltip').remove();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
},
|
|||
|
|
editEmp: function(id) {
|
|||
|
|
console.log(role.rolesEmp);
|
|||
|
|
role.rolesEmp[id].isDiv = false;
|
|||
|
|
role.rolesEmp[id].isEdit = true;
|
|||
|
|
role.typeRole = { 'name': role.empRoles[role.rolesEmp[id].type], 'type': role.rolesEmp[id].type };
|
|||
|
|
$('.ui-tooltip').remove();
|
|||
|
|
},
|
|||
|
|
editEmpSave: function(id) {
|
|||
|
|
if (role.isEmpty(role.rolesEmp[id].name)) {
|
|||
|
|
role.errorOtdel = "Заполните название роли";
|
|||
|
|
role.mes_error_otdel = true;
|
|||
|
|
setTimeout(function() {
|
|||
|
|
role.errorOtdel = "";
|
|||
|
|
role.mes_error_otdel = false;
|
|||
|
|
}, 3000);
|
|||
|
|
}
|
|||
|
|
if (role.isEmpty(role.typeRole)) {
|
|||
|
|
role.errorOtdel = "<p>Заполните доступ для роли</p>";
|
|||
|
|
role.mes_error_otdel = true;
|
|||
|
|
setTimeout(function() {
|
|||
|
|
role.errorOtdel = "";
|
|||
|
|
role.mes_error_otdel = false;
|
|||
|
|
}, 3000);
|
|||
|
|
}
|
|||
|
|
if (!role.mes_error_otdel) {
|
|||
|
|
|
|||
|
|
role.rolesEmp[id].type = role.typeRole.type;
|
|||
|
|
role.nameRole = '';
|
|||
|
|
role.typeRole = { 'name': 'Менеджер', 'type': 'manager' };
|
|||
|
|
role.rolesEmp[id].isDiv = true;
|
|||
|
|
role.rolesEmp[id].isEdit = false;
|
|||
|
|
$('.ui-tooltip').remove();
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
deleteEmp: function(id) {
|
|||
|
|
|
|||
|
|
if (role.rolesEmp[id].id !== undefined) {
|
|||
|
|
axios.post('/ajax/ajax_vue_settings.php', {
|
|||
|
|
request: 'delete_role',
|
|||
|
|
role_id: role.rolesEmp[id].id
|
|||
|
|
})
|
|||
|
|
.then(function(response) {
|
|||
|
|
console.log(response.data);
|
|||
|
|
})
|
|||
|
|
.catch(function(error) {
|
|||
|
|
console.log(error);
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
role.rolesEmp.splice(id, 1);
|
|||
|
|
$('.ui-tooltip').remove();
|
|||
|
|
},
|
|||
|
|
saveOtdet: function() {
|
|||
|
|
if (role.isEmpty(role.name)) {
|
|||
|
|
role.errorOtdel = "Заполните название отдела";
|
|||
|
|
role.mes_error_otdel = true;
|
|||
|
|
setTimeout(function() {
|
|||
|
|
role.errorOtdel = "";
|
|||
|
|
role.mes_error_otdel = false;
|
|||
|
|
}, 3000);
|
|||
|
|
} else {
|
|||
|
|
axios.post('/ajax/ajax_vue_settings.php', {
|
|||
|
|
request: 'save_dep',
|
|||
|
|
dep_id: role.otdelId,
|
|||
|
|
roles: role.rolesEmp,
|
|||
|
|
name: role.name,
|
|||
|
|
agency_id: this.agencyId
|
|||
|
|
|
|||
|
|
})
|
|||
|
|
.then(function(response) {
|
|||
|
|
console.log(response.data);
|
|||
|
|
br.getOtdels();
|
|||
|
|
role.setOtdel = false;
|
|||
|
|
})
|
|||
|
|
.catch(function(error) {
|
|||
|
|
console.log(error);
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
onloadForm: function() {
|
|||
|
|
$('#setting_roles').removeClass('hidden');
|
|||
|
|
},
|
|||
|
|
isEmpty: function(data) {
|
|||
|
|
if (typeof(data) === 'object') {
|
|||
|
|
if (JSON.stringify(data) === '{}' || JSON.stringify(data) === '[]') {
|
|||
|
|
return true;
|
|||
|
|
} else if (!data) {
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
return false;
|
|||
|
|
} else if (typeof(data) === 'string') {
|
|||
|
|
if (!data.trim()) {
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
return false;
|
|||
|
|
} else if (typeof(data) === 'undefined') {
|
|||
|
|
return true;
|
|||
|
|
} else {
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
created: function() {
|
|||
|
|
this.onloadForm();
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
$('body').on('click', '#setting_add_otdel', function() {
|
|||
|
|
role.addOtdel();
|
|||
|
|
})
|
|||
|
|
|
|||
|
|
var br = new Vue({
|
|||
|
|
el: '#block_roles',
|
|||
|
|
components: {
|
|||
|
|
Multiselect: window.VueMultiselect.default,
|
|||
|
|
//vuejsDatepicker: window.vuejsDatepicker
|
|||
|
|
},
|
|||
|
|
data: {
|
|||
|
|
otdels: [],
|
|||
|
|
agencyId: $('#agency_id_dep').val()
|
|||
|
|
},
|
|||
|
|
methods: {
|
|||
|
|
getOtdels: function() {
|
|||
|
|
axios.post('/ajax/ajax_vue_settings.php', {
|
|||
|
|
request: 'get_dep',
|
|||
|
|
agency_id: this.agencyId
|
|||
|
|
})
|
|||
|
|
.then(function(response) {
|
|||
|
|
//console.log(response.data);
|
|||
|
|
br.otdels = response.data;
|
|||
|
|
})
|
|||
|
|
.catch(function(error) {
|
|||
|
|
console.log(error);
|
|||
|
|
});
|
|||
|
|
},
|
|||
|
|
editOtdel: function(id) {
|
|||
|
|
role.isInput = false;
|
|||
|
|
axios.post('/ajax/ajax_vue_settings.php', {
|
|||
|
|
request: 'get_dep_one',
|
|||
|
|
dep_id: id
|
|||
|
|
})
|
|||
|
|
.then(function(response) {
|
|||
|
|
role.rolesEmp = [];
|
|||
|
|
role.name = response.data.name;
|
|||
|
|
role.otdelId = response.data.id;
|
|||
|
|
var roles = response.data.roles;
|
|||
|
|
for (var id in roles) {
|
|||
|
|
roles[id].isDiv = true;
|
|||
|
|
roles[id].isEdit = false;
|
|||
|
|
roles[id].type = roles[id].role;
|
|||
|
|
role.rolesEmp.push(roles[id]);
|
|||
|
|
}
|
|||
|
|
console.log(response.data);
|
|||
|
|
role.setOtdel = true;
|
|||
|
|
|
|||
|
|
})
|
|||
|
|
.catch(function(error) {
|
|||
|
|
console.log(error);
|
|||
|
|
});
|
|||
|
|
},
|
|||
|
|
deleteOtdel: function(id) {
|
|||
|
|
axios.post('/ajax/ajax_vue_settings.php', {
|
|||
|
|
request: 'delete_dep',
|
|||
|
|
dep_id: id
|
|||
|
|
})
|
|||
|
|
.then(function(response) {
|
|||
|
|
br.getOtdels();
|
|||
|
|
|
|||
|
|
})
|
|||
|
|
.catch(function(error) {
|
|||
|
|
console.log(error);
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
},
|
|||
|
|
created: function() {
|
|||
|
|
this.getOtdels();
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
if ($('#objectFieldsBlocksForm').length > 0) {
|
|||
|
|
var object_field_block_form = new Vue({
|
|||
|
|
el: '#objectFieldsBlocksForm',
|
|||
|
|
components: {},
|
|||
|
|
data() {
|
|||
|
|
return {
|
|||
|
|
block_id: 0,
|
|||
|
|
block_title: '',
|
|||
|
|
block_order: 0,
|
|||
|
|
agency_id: $('#session_agency_id').val() || null,
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
methods: {
|
|||
|
|
showEditFieldBlocksForm: function(block_id) {
|
|||
|
|
let ref = this;
|
|||
|
|
if (block_id != 0) {
|
|||
|
|
axios.post('/ajax/ajax_vue_settings.php', {
|
|||
|
|
request: 'get_field_block',
|
|||
|
|
agency_id: ref.agency_id,
|
|||
|
|
block_id: block_id
|
|||
|
|
}).then(function(response) {
|
|||
|
|
console.debug(response.data);
|
|||
|
|
if (response.data.success) {
|
|||
|
|
ref.block_id = response.data.block.id;
|
|||
|
|
ref.block_title = response.data.block.title;
|
|||
|
|
ref.block_order = response.data.block.order;
|
|||
|
|
$('#objectFieldsBlocksFormBg').fadeIn(500);
|
|||
|
|
$('#objectFieldsBlocksForm').toggle(300);
|
|||
|
|
$("body").addClass("lock");
|
|||
|
|
}
|
|||
|
|
}).catch(function(error) {
|
|||
|
|
if (error)
|
|||
|
|
console.debug(error);
|
|||
|
|
});
|
|||
|
|
} else {
|
|||
|
|
$('#objectFieldsBlocksFormBg').fadeIn(500);
|
|||
|
|
$('#objectFieldsBlocksForm').toggle(300);
|
|||
|
|
$("body").addClass("lock");
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
clearData() {
|
|||
|
|
this.block_id = 0;
|
|||
|
|
this.block_title = '';
|
|||
|
|
this.block_order = 0;
|
|||
|
|
},
|
|||
|
|
closeEditFieldBlockForm: function() {
|
|||
|
|
$('#objectFieldsBlocksFormBg').fadeOut(300);
|
|||
|
|
$('#objectFieldsBlocksForm').toggle(100);
|
|||
|
|
$("body").removeClass("lock");
|
|||
|
|
this.clearData();
|
|||
|
|
},
|
|||
|
|
saveFieldBlock: function(block_id) {
|
|||
|
|
let ref = this;
|
|||
|
|
let orders = [];
|
|||
|
|
$(object_fields_blocks.$refs.fieldsBlocks).find('li').each(function() {
|
|||
|
|
orders.push(parseInt($(this).data('order')));
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
if (orders.length > 0)
|
|||
|
|
ref.block_order = Math.max(...orders.sort()) + 1;
|
|||
|
|
|
|||
|
|
axios.post('/ajax/ajax_vue_settings.php', {
|
|||
|
|
request: 'save_object_fields_block',
|
|||
|
|
agency_id: ref.agency_id,
|
|||
|
|
block_title: ref.block_title,
|
|||
|
|
block_order: ref.block_order,
|
|||
|
|
block_id: block_id
|
|||
|
|
}).then((response) => {
|
|||
|
|
if (response.data.success) {
|
|||
|
|
let new_block_id = response.data.block_id;
|
|||
|
|
ref.$emit('add_edit_object_fields_block', new_block_id);
|
|||
|
|
ref.closeEditFieldBlockForm();
|
|||
|
|
}
|
|||
|
|
}).catch(function(error) {
|
|||
|
|
if (error)
|
|||
|
|
console.debug(error);
|
|||
|
|
});
|
|||
|
|
},
|
|||
|
|
},
|
|||
|
|
created: function() {}
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if ($('#objectFieldsForm').length > 0) {
|
|||
|
|
var object_field_form = new Vue({
|
|||
|
|
el: '#objectFieldsForm',
|
|||
|
|
components: {},
|
|||
|
|
data() {
|
|||
|
|
return {
|
|||
|
|
field_id: 0,
|
|||
|
|
agency_id: $('#session_agency_id').val() || null,
|
|||
|
|
name: '',
|
|||
|
|
title: '',
|
|||
|
|
type: 0,
|
|||
|
|
params: [],
|
|||
|
|
order: 0,
|
|||
|
|
agencyId: $('#session_agency_id').val() || null,
|
|||
|
|
is_available: 1,
|
|||
|
|
is_presentation: 1,
|
|||
|
|
is_filtrable: 0,
|
|||
|
|
is_active: 1,
|
|||
|
|
is_required: 0,
|
|||
|
|
typesList: [],
|
|||
|
|
block_id: 0,
|
|||
|
|
block_title: '',
|
|||
|
|
block_order: 0,
|
|||
|
|
blocksList: {
|
|||
|
|
0: 'Общие поля'
|
|||
|
|
},
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
methods: {
|
|||
|
|
showEditFieldBlocksForm: function(block_id) {
|
|||
|
|
if (typeof object_field_block_form !== "undefined") {
|
|||
|
|
object_field_block_form.showEditFieldBlocksForm(block_id);
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
showEditObjectFieldForm: function(id) {
|
|||
|
|
let ref = this;
|
|||
|
|
if (id !== 0) {
|
|||
|
|
axios.post('/ajax/ajax_vue_settings.php', {
|
|||
|
|
request: 'get_object_field',
|
|||
|
|
agency_id: ref.agencyId,
|
|||
|
|
field_id: id
|
|||
|
|
}).then(function(response) {
|
|||
|
|
console.log(response.data);
|
|||
|
|
|
|||
|
|
if (response.data.success) {
|
|||
|
|
ref.field_id = response.data.field.id;
|
|||
|
|
ref.name = response.data.field.name;
|
|||
|
|
ref.title = response.data.field.title;
|
|||
|
|
ref.type = response.data.field.type;
|
|||
|
|
|
|||
|
|
if (ref.type == 2 || ref.type == 3) {
|
|||
|
|
ref.params = response.data.field.params;
|
|||
|
|
if (ref.params != null && typeof ref.params['items'] !== "undefined") {
|
|||
|
|
let items = ref.params['items'];
|
|||
|
|
for (const [key, value] of Object.entries(items)) {
|
|||
|
|
if (value !== null) {
|
|||
|
|
value['mode'] = '';
|
|||
|
|
} else {
|
|||
|
|
delete items[key];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
ref.params['items'] = items;
|
|||
|
|
} else {
|
|||
|
|
if (ref.params == null) {
|
|||
|
|
ref.params = [];
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
ref.order = response.data.field.order;
|
|||
|
|
ref.block_id = response.data.field.block_id;
|
|||
|
|
ref.is_available = response.data.field.is_available;
|
|||
|
|
ref.is_presentation = response.data.field.is_presentation;
|
|||
|
|
ref.is_filtrable = response.data.field.is_filtrable;
|
|||
|
|
ref.is_required = response.data.field.is_required;
|
|||
|
|
ref.is_active = response.data.field.is_active;
|
|||
|
|
|
|||
|
|
console.debug(ref.params);
|
|||
|
|
|
|||
|
|
ref.getFieldTypes(ref.type);
|
|||
|
|
ref.getFieldBlocksList(ref.block_id);
|
|||
|
|
$('#objectFieldsFormBg').fadeIn(500);
|
|||
|
|
$('#objectFieldsForm').toggle(300);
|
|||
|
|
$("body").addClass("lock");
|
|||
|
|
|
|||
|
|
object_field_block_form.$on('add_edit_object_fields_block', function(block_id) {
|
|||
|
|
ref.getFieldBlocksList(block_id);
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}).catch(function(error) {
|
|||
|
|
if (error)
|
|||
|
|
console.log(error);
|
|||
|
|
});
|
|||
|
|
} else {
|
|||
|
|
ref.getFieldTypes(ref.type);
|
|||
|
|
ref.getFieldBlocksList(ref.block_id);
|
|||
|
|
$('#objectFieldsFormBg').fadeIn(500);
|
|||
|
|
$('#objectFieldsForm').toggle(300);
|
|||
|
|
$("body").addClass("lock");
|
|||
|
|
|
|||
|
|
object_field_block_form.$on('add_edit_object_fields_block', function(block_id) {
|
|||
|
|
ref.getFieldBlocksList(block_id);
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
storeFieldProps(action, prop, event) {
|
|||
|
|
let ref = this;
|
|||
|
|
|
|||
|
|
let params = ref.params;
|
|||
|
|
if (params.length == 0 && (ref.type == 2 || ref.type == 3)) {
|
|||
|
|
params = [];
|
|||
|
|
params['items'] = [];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$('.ui-tooltip.ui-widget').remove();
|
|||
|
|
|
|||
|
|
if (prop == null)
|
|||
|
|
prop = {
|
|||
|
|
value: 0,
|
|||
|
|
name: '',
|
|||
|
|
mode: 'edit'
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
//console.log({action, prop});
|
|||
|
|
|
|||
|
|
if (typeof action !== "undefined" && typeof prop !== "undefined") {
|
|||
|
|
switch (action) {
|
|||
|
|
case 'save':
|
|||
|
|
prop.mode = null;
|
|||
|
|
prop.name = $(event.target).closest('.inputs').find('[name="item_name"]').val();
|
|||
|
|
break;
|
|||
|
|
case 'edit':
|
|||
|
|
prop.mode = 'edit';
|
|||
|
|
break;
|
|||
|
|
case 'delete':
|
|||
|
|
if (typeof params['items'] !== "undefined") {
|
|||
|
|
if (confirm('Вы действительно хотите удалить пункт `' + prop['name'] + '`? Это также приведёт к удалению данных в объектах.')) {
|
|||
|
|
let items = params['items'];
|
|||
|
|
for (let [key, value] of Object.entries(items)) {
|
|||
|
|
if (value['value'] == prop['value'])
|
|||
|
|
delete ref.params['items'][key];
|
|||
|
|
}
|
|||
|
|
delete prop;
|
|||
|
|
$('.inputs [data-key="' + prop.value + '"]').parent('li').remove();
|
|||
|
|
params['items'] = items;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
break;
|
|||
|
|
case 'close':
|
|||
|
|
if (typeof params['items'] !== "undefined") {
|
|||
|
|
if (prop.value == null || typeof prop.value == "undefined" || prop.name == '' || typeof prop.name == "undefined") {
|
|||
|
|
let items = params['items'];
|
|||
|
|
for (let [key, value] of Object.entries(items)) {
|
|||
|
|
if (value['value'] == prop['value'])
|
|||
|
|
delete ref.params['items'][key];
|
|||
|
|
}
|
|||
|
|
delete prop;
|
|||
|
|
$('.inputs [data-key="' + prop.value + '"]').parent('li').remove();
|
|||
|
|
params['items'] = items;
|
|||
|
|
} else {
|
|||
|
|
prop.mode = null;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
break;
|
|||
|
|
case 'add':
|
|||
|
|
if (typeof params['items'] !== "undefined") {
|
|||
|
|
|
|||
|
|
let next = 1,
|
|||
|
|
values = [],
|
|||
|
|
items = params['items'];
|
|||
|
|
|
|||
|
|
for (const [key, value] of Object.entries(items)) {
|
|||
|
|
values.push(parseInt(value['value']));
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (values.length > 0)
|
|||
|
|
next = Math.max(...values.sort()) + 1;
|
|||
|
|
|
|||
|
|
//console.debug(next);
|
|||
|
|
items.push({
|
|||
|
|
name: '',
|
|||
|
|
value: next,
|
|||
|
|
mode: "edit"
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
ref.params = {...params };
|
|||
|
|
//console.log(ref.params);
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
getFieldTypes(type) {
|
|||
|
|
let ref = this;
|
|||
|
|
if (typeof type !== "undefined")
|
|||
|
|
ref.type = type;
|
|||
|
|
|
|||
|
|
axios.post('/ajax/ajax_vue_settings.php', {
|
|||
|
|
request: 'get_field_types',
|
|||
|
|
user_id: $("#session_user_id").val(),
|
|||
|
|
type: ref.type
|
|||
|
|
}).then((response) => {
|
|||
|
|
ref.typesList = response.data.list;
|
|||
|
|
$("#object-fields-type").html(response.data.html);
|
|||
|
|
$("#object-fields-type-input").fastselect({
|
|||
|
|
placeholder: 'Выберите тип',
|
|||
|
|
onItemSelect: function(item, val) {
|
|||
|
|
ref.type = val.value;
|
|||
|
|
console.log(ref.type);
|
|||
|
|
},
|
|||
|
|
});
|
|||
|
|
}).catch(function(error) {
|
|||
|
|
|
|||
|
|
if (error)
|
|||
|
|
console.debug(error);
|
|||
|
|
|
|||
|
|
});
|
|||
|
|
},
|
|||
|
|
getFieldTranslit: function() {
|
|||
|
|
let ref = this;
|
|||
|
|
ref.fieldsList = [];
|
|||
|
|
axios.post('/ajax/ajax_vue_settings.php', {
|
|||
|
|
request: 'get_field_translit',
|
|||
|
|
title: ref.title
|
|||
|
|
}).then(function(response) {
|
|||
|
|
if (!ref.isEmpty(response.data.result)) {
|
|||
|
|
ref.name = response.data.result;
|
|||
|
|
}
|
|||
|
|
}).catch(function(error) {
|
|||
|
|
ref.fieldsList = false;
|
|||
|
|
if (error)
|
|||
|
|
console.debug(error);
|
|||
|
|
});
|
|||
|
|
},
|
|||
|
|
saveObjectField(id) {
|
|||
|
|
let ref = this;
|
|||
|
|
let orders = [];
|
|||
|
|
$(object_fields.$refs.fieldsListTable).find('tbody tr').each(function() {
|
|||
|
|
orders.push(parseInt($(this).data('order')));
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
if (orders.length > 0)
|
|||
|
|
ref.order = Math.max(...orders.sort()) + 1;
|
|||
|
|
|
|||
|
|
let param = {
|
|||
|
|
name: ref.name,
|
|||
|
|
title: ref.title,
|
|||
|
|
type: ref.type,
|
|||
|
|
order: ref.order,
|
|||
|
|
is_available: ref.is_available,
|
|||
|
|
is_presentation: ref.is_presentation,
|
|||
|
|
is_filtrable: ref.is_filtrable,
|
|||
|
|
is_required: ref.is_required,
|
|||
|
|
is_active: ref.is_active,
|
|||
|
|
params: ref.params,
|
|||
|
|
block_id: ref.block_id
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
//console.log(param);
|
|||
|
|
axios.post('/ajax/ajax_vue_settings.php', {
|
|||
|
|
request: 'save_object_field',
|
|||
|
|
agency_id: ref.agency_id,
|
|||
|
|
param: param,
|
|||
|
|
field_id: id
|
|||
|
|
}).then((response) => {
|
|||
|
|
if (response.data.success) {
|
|||
|
|
ref.$emit('add_edit_object_fields');
|
|||
|
|
ref.closeEditObjectFieldForm();
|
|||
|
|
}
|
|||
|
|
}).catch(function(error) {
|
|||
|
|
if (error)
|
|||
|
|
console.debug(error);
|
|||
|
|
});
|
|||
|
|
},
|
|||
|
|
|
|||
|
|
getFieldBlocksList(block_id) {
|
|||
|
|
let ref = this;
|
|||
|
|
if (typeof block_id !== "undefined")
|
|||
|
|
ref.block_id = block_id;
|
|||
|
|
|
|||
|
|
ref.blocksList = [];
|
|||
|
|
axios.post('/ajax/ajax_vue_settings.php', {
|
|||
|
|
request: 'get_field_blocks',
|
|||
|
|
agency_id: ref.agency_id,
|
|||
|
|
block_id: ref.block_id
|
|||
|
|
}).then(function(response) {
|
|||
|
|
ref.blocksList = response.data.list;
|
|||
|
|
|
|||
|
|
$("#object-fields-block").html(response.data.html);
|
|||
|
|
$("#object-fields-block-input").fastselect({
|
|||
|
|
placeholder: 'Выберите блок',
|
|||
|
|
onItemSelect: function(item, val) {
|
|||
|
|
ref.block_id = val.value;
|
|||
|
|
console.log(ref.block_id);
|
|||
|
|
},
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
console.debug(ref.blocksList);
|
|||
|
|
}).catch(function(error) {
|
|||
|
|
ref.blocksList = [];
|
|||
|
|
if (error)
|
|||
|
|
console.debug(error);
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
return ref.blocksList;
|
|||
|
|
},
|
|||
|
|
getBlockName: function(block_id) {
|
|||
|
|
let ref = this;
|
|||
|
|
if (typeof block_id !== "undefined") {
|
|||
|
|
if (!ref.isEmpty(block_id)) {
|
|||
|
|
for (const [key, value] of Object.entries(ref.blocksList)) {
|
|||
|
|
if (parseInt(key) == parseInt(block_id))
|
|||
|
|
return value;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return block_id;
|
|||
|
|
},
|
|||
|
|
|
|||
|
|
clearData() {
|
|||
|
|
this.field_id = 0;
|
|||
|
|
this.name = '';
|
|||
|
|
this.title = '';
|
|||
|
|
this.type = 0;
|
|||
|
|
this.params = [];
|
|||
|
|
this.order = 0;
|
|||
|
|
this.is_available = 1;
|
|||
|
|
this.is_presentation = 1;
|
|||
|
|
this.is_filtrable = 0;
|
|||
|
|
this.is_required = 1;
|
|||
|
|
this.is_active = 0;
|
|||
|
|
this.block_id = 0;
|
|||
|
|
this.block_title = '';
|
|||
|
|
this.block_order = 0;
|
|||
|
|
this.blocksList = {
|
|||
|
|
0: 'Общие поля'
|
|||
|
|
};
|
|||
|
|
},
|
|||
|
|
closeEditObjectFieldForm() {
|
|||
|
|
$('#objectFieldsFormBg').fadeOut(300);
|
|||
|
|
$('#objectFieldsForm').toggle(100);
|
|||
|
|
$("body").removeClass("lock");
|
|||
|
|
this.clearData();
|
|||
|
|
},
|
|||
|
|
isEmpty(data) {
|
|||
|
|
if (typeof(data) === 'object') {
|
|||
|
|
if (JSON.stringify(data) === '{}' || JSON.stringify(data) === '[]') {
|
|||
|
|
return true;
|
|||
|
|
} else if (!data) {
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
return false;
|
|||
|
|
} else if (typeof(data) === 'string') {
|
|||
|
|
if (!data.trim()) {
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
return false;
|
|||
|
|
} else if (typeof(data) === 'undefined') {
|
|||
|
|
return true;
|
|||
|
|
} else {
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
},
|
|||
|
|
created: function() {}
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if ($('#objectFieldsBlocks').length > 0) {
|
|||
|
|
var object_fields_blocks = new Vue({
|
|||
|
|
el: '#objectFieldsBlocks',
|
|||
|
|
components: {},
|
|||
|
|
data() {
|
|||
|
|
return {
|
|||
|
|
blocksList: [],
|
|||
|
|
agency_id: $('#session_agency_id').val() || null
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
methods: {
|
|||
|
|
getObjectFieldsBlocks: function() {
|
|||
|
|
let ref = this;
|
|||
|
|
ref.blocksList = [];
|
|||
|
|
axios.post('/ajax/ajax_vue_settings.php', {
|
|||
|
|
request: 'get_field_blocks',
|
|||
|
|
agency_id: ref.agency_id,
|
|||
|
|
block_id: 0
|
|||
|
|
}).then(function(response) {
|
|||
|
|
ref.blocksList = response.data.list;
|
|||
|
|
console.debug(ref.blocksList);
|
|||
|
|
}).catch(function(error) {
|
|||
|
|
if (error)
|
|||
|
|
console.debug(error);
|
|||
|
|
});
|
|||
|
|
},
|
|||
|
|
showEditFieldBlocksForm: function(block_id) {
|
|||
|
|
if (typeof object_field_form != "undefined") {
|
|||
|
|
object_field_form.showEditFieldBlocksForm(block_id);
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
closeEditFieldBlocksForm: function() {
|
|||
|
|
if (typeof object_field_form != "undefined") {
|
|||
|
|
object_field_form.closeEditFieldBlocksForm(block_id);
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
confirmDeleteFieldBlock: function(id) {
|
|||
|
|
let ref = this;
|
|||
|
|
if (confirm('Вы действительно хотите удалить этот блок? Поля данного блока будут назначены как общие.')) {
|
|||
|
|
if (typeof id !== "undefined") {
|
|||
|
|
axios.post('/ajax/ajax_vue_settings.php', {
|
|||
|
|
request: 'delete_object_field_block',
|
|||
|
|
agency_id: ref.agency_id,
|
|||
|
|
block_id: id
|
|||
|
|
}).then((response) => {
|
|||
|
|
if (response.data.success) {
|
|||
|
|
ref.blocksList = [];
|
|||
|
|
ref.getObjectFieldsBlocks();
|
|||
|
|
if (typeof object_fields != "undefined")
|
|||
|
|
object_fields.getObjectFields();
|
|||
|
|
}
|
|||
|
|
}).catch(function(error) {
|
|||
|
|
if (error)
|
|||
|
|
console.debug(error);
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
setBlockOrder: function(id, order, direction) {
|
|||
|
|
let ref = this;
|
|||
|
|
axios.post('/ajax/ajax_vue_settings.php', {
|
|||
|
|
request: 'set_block_order',
|
|||
|
|
agency_id: ref.agency_id,
|
|||
|
|
direct: direction,
|
|||
|
|
sort_order: order,
|
|||
|
|
block_id: id
|
|||
|
|
}).then((response) => {
|
|||
|
|
if (response.data.success) {
|
|||
|
|
ref.blocksList = [];
|
|||
|
|
ref.getObjectFieldsBlocks();
|
|||
|
|
}
|
|||
|
|
}).catch(function(error) {
|
|||
|
|
if (error)
|
|||
|
|
console.debug(error);
|
|||
|
|
});
|
|||
|
|
},
|
|||
|
|
isEmpty(data) {
|
|||
|
|
if (typeof(data) === 'object') {
|
|||
|
|
if (JSON.stringify(data) === '{}' || JSON.stringify(data) === '[]') {
|
|||
|
|
return true;
|
|||
|
|
} else if (!data) {
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
return false;
|
|||
|
|
} else if (typeof(data) === 'string') {
|
|||
|
|
if (!data.trim()) {
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
return false;
|
|||
|
|
} else if (typeof(data) === 'undefined') {
|
|||
|
|
return true;
|
|||
|
|
} else {
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
},
|
|||
|
|
computed: {},
|
|||
|
|
created: function() {
|
|||
|
|
this.getObjectFieldsBlocks();
|
|||
|
|
if (typeof object_field_block_form != "undefined") {
|
|||
|
|
let ref = this;
|
|||
|
|
object_field_block_form.$on('add_edit_object_fields_block', function() {
|
|||
|
|
ref.getObjectFieldsBlocks();
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if ($('#object_fields').length > 0) {
|
|||
|
|
var object_fields = new Vue({
|
|||
|
|
el: '#object_fields',
|
|||
|
|
components: {},
|
|||
|
|
data() {
|
|||
|
|
return {
|
|||
|
|
fieldsList: [],
|
|||
|
|
blocksList: [],
|
|||
|
|
agency_id: $('#session_agency_id').val() || null
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
methods: {
|
|||
|
|
getObjectFields: function() {
|
|||
|
|
let ref = this;
|
|||
|
|
ref.fieldsList = [];
|
|||
|
|
|
|||
|
|
axios.post('/ajax/ajax_vue_settings.php', {
|
|||
|
|
request: 'get_object_fields',
|
|||
|
|
agency_id: ref.agency_id
|
|||
|
|
}).then(function(response) {
|
|||
|
|
var new_array = response.data;
|
|||
|
|
ref.fieldsList = ref.fieldsList.concat(new_array);
|
|||
|
|
console.debug(ref.fieldsList);
|
|||
|
|
}).catch(function(error) {
|
|||
|
|
ref.fieldsList = false;
|
|||
|
|
if (error)
|
|||
|
|
console.debug(error);
|
|||
|
|
});
|
|||
|
|
},
|
|||
|
|
confirmDeleteObjectField: function(id) {
|
|||
|
|
let ref = this;
|
|||
|
|
if (confirm('Вы действительно хотите удалить данное поле?')) {
|
|||
|
|
if (typeof id !== "undefined") {
|
|||
|
|
axios.post('/ajax/ajax_vue_settings.php', {
|
|||
|
|
request: 'delete_object_field',
|
|||
|
|
agency_id: ref.agency_id,
|
|||
|
|
field_id: id
|
|||
|
|
}).then((response) => {
|
|||
|
|
if (response.data.success) {
|
|||
|
|
ref.fieldsList = [];
|
|||
|
|
ref.getObjectFields();
|
|||
|
|
}
|
|||
|
|
}).catch(function(error) {
|
|||
|
|
if (error)
|
|||
|
|
console.debug(error);
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
showEditObjectFieldForm: function(id) {
|
|||
|
|
if (typeof object_field_form != "undefined") {
|
|||
|
|
object_field_form.showEditObjectFieldForm(id);
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
showEditFieldBlocksForm: function(block_id) {
|
|||
|
|
if (typeof object_field_form != "undefined") {
|
|||
|
|
object_field_form.showEditFieldBlocksForm(block_id);
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
setFieldOrder: function(id, order, direction) {
|
|||
|
|
let ref = this;
|
|||
|
|
axios.post('/ajax/ajax_vue_settings.php', {
|
|||
|
|
request: 'set_field_order',
|
|||
|
|
agency_id: ref.agency_id,
|
|||
|
|
direct: direction,
|
|||
|
|
sort_order: order,
|
|||
|
|
field_id: id
|
|||
|
|
}).then((response) => {
|
|||
|
|
if (response.data.success) {
|
|||
|
|
ref.fieldsList = [];
|
|||
|
|
ref.getObjectFields();
|
|||
|
|
}
|
|||
|
|
}).catch(function(error) {
|
|||
|
|
if (error)
|
|||
|
|
console.debug(error);
|
|||
|
|
});
|
|||
|
|
},
|
|||
|
|
isEmpty(data) {
|
|||
|
|
if (typeof(data) === 'object') {
|
|||
|
|
if (JSON.stringify(data) === '{}' || JSON.stringify(data) === '[]') {
|
|||
|
|
return true;
|
|||
|
|
} else if (!data) {
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
return false;
|
|||
|
|
} else if (typeof(data) === 'string') {
|
|||
|
|
if (!data.trim()) {
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
return false;
|
|||
|
|
} else if (typeof(data) === 'undefined') {
|
|||
|
|
return true;
|
|||
|
|
} else {
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
},
|
|||
|
|
computed: {},
|
|||
|
|
created: function() {
|
|||
|
|
this.getObjectFields();
|
|||
|
|
if (typeof object_field_form != "undefined") {
|
|||
|
|
let ref = this;
|
|||
|
|
object_field_form.$on('add_edit_object_fields', function() {
|
|||
|
|
ref.getObjectFields();
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if ($('#client_req_fields').length > 0) {
|
|||
|
|
var client_req_fields = new Vue({
|
|||
|
|
el: '#client_req_fields',
|
|||
|
|
components: {},
|
|||
|
|
data() {
|
|||
|
|
return {
|
|||
|
|
fieldsList: [],
|
|||
|
|
agency_id: $('#session_agency_id').val() || null
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
methods: {
|
|||
|
|
getClientReqFields: function() {
|
|||
|
|
|
|||
|
|
//this.fieldsList = [];
|
|||
|
|
|
|||
|
|
axios.post('/ajax/ajax_vue_settings.php', {
|
|||
|
|
request: 'get_client_req_fields',
|
|||
|
|
agency_id: this.agency_id
|
|||
|
|
}).then((response) => {
|
|||
|
|
// console.log(response.data);
|
|||
|
|
this.fieldsList = response.data;
|
|||
|
|
|
|||
|
|
}).catch(function(error) {
|
|||
|
|
this.fieldsList = false;
|
|||
|
|
if (error)
|
|||
|
|
console.debug(error);
|
|||
|
|
});
|
|||
|
|
},
|
|||
|
|
confirmDeleteClientReqField: function(id) {
|
|||
|
|
if (confirm('Вы действительно хотите удалить данную группу?')) {
|
|||
|
|
if (typeof id !== "undefined") {
|
|||
|
|
axios.post('/ajax/ajax_vue_settings.php', {
|
|||
|
|
request: 'delete_client_req_field',
|
|||
|
|
agency_id: this.agency_id,
|
|||
|
|
field_id: id
|
|||
|
|
}).then((response) => {
|
|||
|
|
console.log(response.data);
|
|||
|
|
if (response.data.success) {
|
|||
|
|
|
|||
|
|
this.getClientReqFields();
|
|||
|
|
}
|
|||
|
|
}).catch(function(error) {
|
|||
|
|
if (error)
|
|||
|
|
console.debug(error);
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
showEditClientReqFieldForm: function(id) {
|
|||
|
|
if (typeof clientReqFieldsModal != "undefined") {
|
|||
|
|
clientReqFieldsModal.showEditClientReqFieldForm(id);
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
showEditFieldBlocksForm: function(block_id) {
|
|||
|
|
if (typeof object_field_form != "undefined") {
|
|||
|
|
object_field_form.showEditFieldBlocksForm(block_id);
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
setFieldOrder: function(id, order, direction) {
|
|||
|
|
let ref = this;
|
|||
|
|
axios.post('/ajax/ajax_vue_settings.php', {
|
|||
|
|
request: 'set_field_order',
|
|||
|
|
agency_id: ref.agency_id,
|
|||
|
|
direct: direction,
|
|||
|
|
sort_order: order,
|
|||
|
|
field_id: id
|
|||
|
|
}).then((response) => {
|
|||
|
|
if (response.data.success) {
|
|||
|
|
ref.fieldsList = [];
|
|||
|
|
ref.getObjectFields();
|
|||
|
|
}
|
|||
|
|
}).catch(function(error) {
|
|||
|
|
if (error)
|
|||
|
|
console.debug(error);
|
|||
|
|
});
|
|||
|
|
},
|
|||
|
|
isEmpty(data) {
|
|||
|
|
if (typeof(data) === 'object') {
|
|||
|
|
if (JSON.stringify(data) === '{}' || JSON.stringify(data) === '[]') {
|
|||
|
|
return true;
|
|||
|
|
} else if (!data) {
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
return false;
|
|||
|
|
} else if (typeof(data) === 'string') {
|
|||
|
|
if (!data.trim()) {
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
return false;
|
|||
|
|
} else if (typeof(data) === 'undefined') {
|
|||
|
|
return true;
|
|||
|
|
} else {
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
},
|
|||
|
|
computed: {},
|
|||
|
|
created: function() {
|
|||
|
|
this.getClientReqFields();
|
|||
|
|
/* if (typeof object_field_form != "undefined") {
|
|||
|
|
let ref = this;
|
|||
|
|
object_field_form.$on('add_edit_object_fields', function() {
|
|||
|
|
ref.getObjectFields();
|
|||
|
|
});
|
|||
|
|
}*/
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if ($('#clientReqFieldsModal').length > 0) {
|
|||
|
|
var clientReqFieldsModal = new Vue({
|
|||
|
|
el: '#clientReqFieldsModal',
|
|||
|
|
components: {},
|
|||
|
|
data() {
|
|||
|
|
return {
|
|||
|
|
isShowClientReqFieldsForm: false,
|
|||
|
|
field_id: 0,
|
|||
|
|
is_podgroup: 0,
|
|||
|
|
is_podgroup_multiselect: 0,
|
|||
|
|
is_client: 1,
|
|||
|
|
is_req: 1,
|
|||
|
|
type: 0,
|
|||
|
|
agency_id: $('#session_agency_id').val() || null,
|
|||
|
|
name: '',
|
|||
|
|
title: '',
|
|||
|
|
types_req: [{
|
|||
|
|
"code": 0,
|
|||
|
|
"name": "Все",
|
|||
|
|
"order": -1,
|
|||
|
|
"heir": 0,
|
|||
|
|
"archive": 0,
|
|||
|
|
"type": "label",
|
|||
|
|
}],
|
|||
|
|
selectedType: 0,
|
|||
|
|
params: [],
|
|||
|
|
order: 0,
|
|||
|
|
agencyId: $('#session_agency_id').val() || null,
|
|||
|
|
userId: $('#session_user_id').val(),
|
|||
|
|
is_active: 1,
|
|||
|
|
is_required: 0,
|
|||
|
|
typesList: [],
|
|||
|
|
listPodgroups: {},
|
|||
|
|
is_filtrable: 0,
|
|||
|
|
OpenIndicator: {
|
|||
|
|
render: createElement => createElement('span', { class: { 'vueToggleSpan': true } }),
|
|||
|
|
},
|
|||
|
|
is_no_see: 0,
|
|||
|
|
users_see: [{ 'code': '0', 'name': '', 'type':'agent' }],
|
|||
|
|
selected_users_see_no: null,
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
methods: {
|
|||
|
|
|
|||
|
|
showEditClientReqFieldForm: function(id) {
|
|||
|
|
console.log(id);
|
|||
|
|
this.isShowClientReqFieldsForm = true;
|
|||
|
|
this.clearField();
|
|||
|
|
if (id > 0) {
|
|||
|
|
this.getClientReqField(id);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$("body").addClass("lock");
|
|||
|
|
},
|
|||
|
|
hideEditClientReqFieldForm: function() {
|
|||
|
|
this.isShowClientReqFieldsForm = false;
|
|||
|
|
$("body").removeClass("lock");
|
|||
|
|
},
|
|||
|
|
clearField() {
|
|||
|
|
this.field_id = 0;
|
|||
|
|
this.is_podgroup = 0;
|
|||
|
|
this.is_podgroup_multiselect=0;
|
|||
|
|
this.is_client = 1;
|
|||
|
|
this.is_req = 1;
|
|||
|
|
this.type = 0;
|
|||
|
|
this.title = '';
|
|||
|
|
this.selectedType = 0;
|
|||
|
|
this.params = [];
|
|||
|
|
this.is_required = 0;
|
|||
|
|
this.listPodgroups = {};
|
|||
|
|
this.getFieldTypes();
|
|||
|
|
this.getTypes();
|
|||
|
|
this.is_filtrable = 0;
|
|||
|
|
this.is_no_see = 0;
|
|||
|
|
this.selected_users_see_no = null;
|
|||
|
|
},
|
|||
|
|
getClientReqField(id) {
|
|||
|
|
this.field_id = id;
|
|||
|
|
axios.post('/ajax/ajax_vue_settings.php', {
|
|||
|
|
request: 'get_client_req_field',
|
|||
|
|
agency_id: this.agency_id,
|
|||
|
|
field_id: this.field_id,
|
|||
|
|
}).then((response) => {
|
|||
|
|
console.log(response.data);
|
|||
|
|
var res = response.data;
|
|||
|
|
var field = res.field;
|
|||
|
|
this.is_podgroup = field.is_podgroup;
|
|||
|
|
this.is_podgroup_multiselect = field.is_podgroup_multiselect;
|
|||
|
|
this.is_client = field.is_client;
|
|||
|
|
this.is_req = field.is_req;
|
|||
|
|
this.type = field.type;
|
|||
|
|
this.title = field.title;
|
|||
|
|
this.selectedType = JSON.parse(field.req_type);
|
|||
|
|
var params = JSON.parse(field.params);
|
|||
|
|
this.is_required = field.is_required;
|
|||
|
|
this.is_filtrable = field.is_filtrable;
|
|||
|
|
this.listPodgroups = res.list_podgroup;
|
|||
|
|
this.is_no_see = field.is_no_see;
|
|||
|
|
|
|||
|
|
if(!this.isEmpty(field.users_no_see)){
|
|||
|
|
var tempUS = JSON.parse(field.users_no_see);
|
|||
|
|
var tempUS2 = [];
|
|||
|
|
if(!this.isEmpty(tempUS)){
|
|||
|
|
for(var i in tempUS){
|
|||
|
|
if(!this.isEmpty(tempUS[i]) && tempUS[i] != 'null'){
|
|||
|
|
tempUS2.push(tempUS[i]);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
this.selected_users_see_no = tempUS2;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
var temp_params = [];
|
|||
|
|
if(!this.isEmpty(params) && params.items){
|
|||
|
|
for(var idp in params.items) {
|
|||
|
|
//console.log(params.items[idp]);
|
|||
|
|
if(!this.isEmpty(params.items[idp]) && params.items[idp].mode !== 'edit'){
|
|||
|
|
temp_params.push(params.items[idp]);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
params.items = temp_params;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
this.params = params;
|
|||
|
|
console.log(this.params);
|
|||
|
|
|
|||
|
|
for (var id in this.listPodgroups) {
|
|||
|
|
if (this.listPodgroups[id].params &&
|
|||
|
|
!this.isEmpty(this.listPodgroups[id].params) &&
|
|||
|
|
typeof this.listPodgroups[id].params == 'string') {
|
|||
|
|
this.listPodgroups[id].params = JSON.parse(this.listPodgroups[id].params);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
this.getFieldTypes();
|
|||
|
|
|
|||
|
|
}).catch(function(error) {
|
|||
|
|
this.fieldsList = false;
|
|||
|
|
if (error)
|
|||
|
|
console.debug(error);
|
|||
|
|
});
|
|||
|
|
},
|
|||
|
|
//Получение типов заявок
|
|||
|
|
getTypes() {
|
|||
|
|
axios.post('/ajax/ajax_vue_requisitions.php', {
|
|||
|
|
request: 'get_type',
|
|||
|
|
agency_id: this.agency_id,
|
|||
|
|
},
|
|||
|
|
|
|||
|
|
)
|
|||
|
|
.then((response) => {
|
|||
|
|
//console.log(response.data);
|
|||
|
|
var types = response.data.type
|
|||
|
|
types[0].name = 'Все';
|
|||
|
|
this.types_req = types;
|
|||
|
|
})
|
|||
|
|
.catch(function(error) {
|
|||
|
|
console.log(error);
|
|||
|
|
});
|
|||
|
|
},
|
|||
|
|
getFieldTypes(type) {
|
|||
|
|
|
|||
|
|
if (typeof type !== "undefined")
|
|||
|
|
this.type = type;
|
|||
|
|
if ($("#clientReq-fields-type").length < 1) {
|
|||
|
|
axios.post('/ajax/ajax_vue_settings.php', {
|
|||
|
|
request: 'get_field_types',
|
|||
|
|
user_id: $("#session_user_id").val(),
|
|||
|
|
type: this.type,
|
|||
|
|
selector: "clientReq-fields-type",
|
|||
|
|
}).then((response) => {
|
|||
|
|
|
|||
|
|
this.typesList = response.data.list;
|
|||
|
|
|
|||
|
|
$("#clientReq-fields-type-input").html(response.data.html);
|
|||
|
|
$("#clientReq-fields-type").val(this.type);
|
|||
|
|
$("#clientReq-fields-type").fastselect({
|
|||
|
|
placeholder: 'Выберите тип',
|
|||
|
|
onItemSelect: function(item, val) {
|
|||
|
|
clientReqFieldsModal.type = parseInt(val.value);
|
|||
|
|
|
|||
|
|
},
|
|||
|
|
});
|
|||
|
|
}).catch(function(error) {
|
|||
|
|
|
|||
|
|
if (error)
|
|||
|
|
console.debug(error);
|
|||
|
|
|
|||
|
|
});
|
|||
|
|
} else {
|
|||
|
|
$('#clientReq-fields-type').fastselect().data('fastselect').destroy();
|
|||
|
|
$("#clientReq-fields-type").val(this.type);
|
|||
|
|
$('#clientReq-fields-type').fastselect({
|
|||
|
|
placeholder: 'Выберите тип',
|
|||
|
|
onItemSelect: function(item, val) {
|
|||
|
|
clientReqFieldsModal.type = val.value;
|
|||
|
|
|
|||
|
|
},
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
selectType(val) {
|
|||
|
|
if (val.length == 0) {
|
|||
|
|
this.selectedType = 0;
|
|||
|
|
} else {
|
|||
|
|
for (var i = 0; i < val.length; i++) {
|
|||
|
|
if (val[i] == 0) {
|
|||
|
|
val.splice(i, 1);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
if (val.length == 0) {
|
|||
|
|
this.selectedType = 0;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
},
|
|||
|
|
change_podgroup() {
|
|||
|
|
this.params = [];
|
|||
|
|
this.type = 0;
|
|||
|
|
this.getFieldTypes(0);
|
|||
|
|
},
|
|||
|
|
storeFieldProps(action, prop, event) {
|
|||
|
|
console.log(action);
|
|||
|
|
let ref = this;
|
|||
|
|
|
|||
|
|
let params = ref.params;
|
|||
|
|
if (params.length == 0 && (ref.type == 2 || ref.type == 3)) {
|
|||
|
|
params['items'] = [];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$('.ui-tooltip.ui-widget').remove();
|
|||
|
|
|
|||
|
|
if (prop == null)
|
|||
|
|
prop = {
|
|||
|
|
value: 0,
|
|||
|
|
name: '',
|
|||
|
|
mode: 'edit'
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
console.log({ action, prop });
|
|||
|
|
|
|||
|
|
if (typeof action !== "undefined" && typeof prop !== "undefined") {
|
|||
|
|
switch (action) {
|
|||
|
|
case 'save':
|
|||
|
|
prop.mode = null;
|
|||
|
|
prop.name = $(event.target).closest('.inputs').find('[name="item_name"]').val();
|
|||
|
|
break;
|
|||
|
|
case 'edit':
|
|||
|
|
prop.mode = 'edit';
|
|||
|
|
break;
|
|||
|
|
case 'delete':
|
|||
|
|
if (typeof params['items'] !== "undefined") {
|
|||
|
|
if (confirm('Вы действительно хотите удалить пункт `' + prop['name'] + '`? Это также приведёт к удалению данных в клиентах или заявках.')) {
|
|||
|
|
let items = params['items'];
|
|||
|
|
for (let [key, value] of Object.entries(items)) {
|
|||
|
|
if (value['value'] == prop['value']) {
|
|||
|
|
ref.params['items'].splice(key, 1);
|
|||
|
|
}
|
|||
|
|
// delete ref.params['items'][key];
|
|||
|
|
}
|
|||
|
|
//prop = null;
|
|||
|
|
// $('.inputs [data-key="' + prop.value + '"]').parent('li').remove();
|
|||
|
|
params['items'] = items;
|
|||
|
|
prop = null;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
break;
|
|||
|
|
case 'close':
|
|||
|
|
if (typeof params['items'] !== "undefined") {
|
|||
|
|
if (prop.value == null || typeof prop.value == "undefined" || prop.name == '' || typeof prop.name == "undefined") {
|
|||
|
|
let items = params['items'];
|
|||
|
|
let tempItems = [];
|
|||
|
|
|
|||
|
|
for (let [key, value] of Object.entries(items)) {
|
|||
|
|
if (value['value'] !== prop['value']){
|
|||
|
|
tempItems.push(value);
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
items = tempItems;
|
|||
|
|
|
|||
|
|
///$('.inputs [data-key="' + prop.value + '"]').parent('li').remove();
|
|||
|
|
params['items'] = items;
|
|||
|
|
delete prop;
|
|||
|
|
|
|||
|
|
} else {
|
|||
|
|
prop.mode = null;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
break;
|
|||
|
|
case 'add':
|
|||
|
|
if (typeof params['items'] !== "undefined") {
|
|||
|
|
|
|||
|
|
let next = 1,
|
|||
|
|
values = [],
|
|||
|
|
items = params['items'];
|
|||
|
|
|
|||
|
|
for (const [key, value] of Object.entries(items)) {
|
|||
|
|
values.push(parseInt(value['value']));
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (values.length > 0)
|
|||
|
|
next = Math.max(...values.sort()) + 1;
|
|||
|
|
|
|||
|
|
//console.debug(next);
|
|||
|
|
items.push({
|
|||
|
|
name: '',
|
|||
|
|
value: next,
|
|||
|
|
mode: "edit"
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
ref.params = {...params };
|
|||
|
|
console.debug(ref.params);
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
addEditPodgroup(idadd) {
|
|||
|
|
id = idadd;
|
|||
|
|
if (typeof clientReqPodgroupsModal != "undefined") {
|
|||
|
|
if(idadd == 'add'){
|
|||
|
|
id = clientReqPodgroupsModal.tempIndex;
|
|||
|
|
}
|
|||
|
|
clientReqPodgroupsModal.showEditClientReqPodgroupForm(id);
|
|||
|
|
if (idadd != 'add' ) {
|
|||
|
|
clientReqPodgroupsModal.setPodgroup(this.listPodgroups[id]);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
deletePodgroup(id) {
|
|||
|
|
let tempPodgroup = this.listPodgroups;
|
|||
|
|
this.listPodgroups = {}
|
|||
|
|
//console.log(id);
|
|||
|
|
for(let pg in tempPodgroup){
|
|||
|
|
if(pg !== id){
|
|||
|
|
this.$set(this.listPodgroups, pg, tempPodgroup[pg]);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
$('.ui-tooltip').remove();
|
|||
|
|
|
|||
|
|
},
|
|||
|
|
|
|||
|
|
get_user_see(){
|
|||
|
|
axios.post('/ajax/ajax_vue_funnel.php', {
|
|||
|
|
request: 'get_users_see',
|
|||
|
|
agency_id: this.agencyId,
|
|||
|
|
user_id: this.userId,
|
|||
|
|
})
|
|||
|
|
.then((response) => {
|
|||
|
|
this.users_see = response.data;
|
|||
|
|
})
|
|||
|
|
.catch(function(error) {
|
|||
|
|
console.error(error);
|
|||
|
|
});
|
|||
|
|
},
|
|||
|
|
saveClientReqField(id) {
|
|||
|
|
//console.log(this.listPodgroups);
|
|||
|
|
let param = {
|
|||
|
|
is_podgroup: this.is_podgroup,
|
|||
|
|
is_podgroup_multiselect: this.is_podgroup_multiselect,
|
|||
|
|
is_client: this.is_client,
|
|||
|
|
is_req: this.is_req,
|
|||
|
|
type: this.type,
|
|||
|
|
title: this.title,
|
|||
|
|
req_type: this.selectedType,
|
|||
|
|
params: this.params,
|
|||
|
|
is_required: this.is_required,
|
|||
|
|
listPodgroups: this.listPodgroups,
|
|||
|
|
is_filtrable: this.is_filtrable,
|
|||
|
|
users_no_see: this.selected_users_see_no,
|
|||
|
|
is_no_see: this.is_no_see,
|
|||
|
|
};
|
|||
|
|
axios.post('/ajax/ajax_vue_settings.php', {
|
|||
|
|
request: 'save_client_req_fields',
|
|||
|
|
field_id: id,
|
|||
|
|
param: param,
|
|||
|
|
agency_id: this.agency_id,
|
|||
|
|
}).then((response) => {
|
|||
|
|
console.log(response.data);
|
|||
|
|
if (response.data.success) {
|
|||
|
|
|
|||
|
|
//let new_block_id = response.data.block_id;
|
|||
|
|
// ref.$emit('add_edit_object_fields_block', new_block_id);
|
|||
|
|
this.hideEditClientReqFieldForm();
|
|||
|
|
if (typeof client_req_fields != "undefined") {
|
|||
|
|
client_req_fields.getClientReqFields();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}).catch(function(error) {
|
|||
|
|
if (error)
|
|||
|
|
console.debug(error);
|
|||
|
|
});
|
|||
|
|
},
|
|||
|
|
isEmpty(data) {
|
|||
|
|
if (typeof(data) === 'object') {
|
|||
|
|
if (JSON.stringify(data) === '{}' || JSON.stringify(data) === '[]') {
|
|||
|
|
return true;
|
|||
|
|
} else if (!data) {
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
return false;
|
|||
|
|
} else if (typeof(data) === 'string') {
|
|||
|
|
if (!data.trim()) {
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
return false;
|
|||
|
|
} else if (typeof(data) === 'undefined') {
|
|||
|
|
return true;
|
|||
|
|
} else {
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
},
|
|||
|
|
|
|||
|
|
created: function() {
|
|||
|
|
this.get_user_see();
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if ($('#clientReqPodgroupsModal').length > 0) {
|
|||
|
|
var clientReqPodgroupsModal = new Vue({
|
|||
|
|
el: '#clientReqPodgroupsModal',
|
|||
|
|
components: {},
|
|||
|
|
data() {
|
|||
|
|
return {
|
|||
|
|
isShowClientReqPodgroupsForm: false,
|
|||
|
|
podgroup_id: 0,
|
|||
|
|
type: 0,
|
|||
|
|
agency_id: $('#session_agency_id').val() || null,
|
|||
|
|
title: '',
|
|||
|
|
params: [],
|
|||
|
|
order: 0,
|
|||
|
|
agencyId: $('#session_agency_id').val() || null,
|
|||
|
|
is_active: 1,
|
|||
|
|
is_required: 0,
|
|||
|
|
typesList: [],
|
|||
|
|
OpenIndicator: {
|
|||
|
|
render: createElement => createElement('span', { class: { 'vueToggleSpan': true } }),
|
|||
|
|
},
|
|||
|
|
tempIndex: -1,
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
methods: {
|
|||
|
|
setPodgroup(podgroup) {
|
|||
|
|
this.podgroup_id = podgroup.id;
|
|||
|
|
this.type = podgroup.type;
|
|||
|
|
this.params = podgroup.params;
|
|||
|
|
|
|||
|
|
if (!this.isEmpty(podgroup.params) && (typeof podgroup.params == 'string')) {
|
|||
|
|
this.params = JSON.parse(podgroup.params);
|
|||
|
|
}
|
|||
|
|
this.title = podgroup.title;
|
|||
|
|
this.is_required = podgroup.is_required;
|
|||
|
|
|
|||
|
|
this.getFieldTypes();
|
|||
|
|
},
|
|||
|
|
clearPodgroup() {
|
|||
|
|
this.type = 0;
|
|||
|
|
this.params = [];
|
|||
|
|
this.title = '';
|
|||
|
|
this.is_required = 0;
|
|||
|
|
this.getFieldTypes(0);
|
|||
|
|
this.id = 0;
|
|||
|
|
},
|
|||
|
|
showEditClientReqPodgroupForm: function(id) {
|
|||
|
|
this.clearPodgroup();
|
|||
|
|
this.podgroup_id = id;
|
|||
|
|
this.isShowClientReqPodgroupsForm = true;
|
|||
|
|
|
|||
|
|
if (typeof clientReqFieldsModal != "undefined" && clientReqFieldsModal.isShowClientReqFieldsForm === false) {
|
|||
|
|
$("body").addClass("lock");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
},
|
|||
|
|
hideEditClientReqPodgroupsForm: function() {
|
|||
|
|
this.isShowClientReqPodgroupsForm = false;
|
|||
|
|
|
|||
|
|
if (typeof clientReqFieldsModal != "undefined" && clientReqFieldsModal.isShowClientReqFieldsForm === false) {
|
|||
|
|
$("body").removeClass("lock");
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
getFieldTypes(type) {
|
|||
|
|
|
|||
|
|
if (typeof type !== "undefined")
|
|||
|
|
this.type = type;
|
|||
|
|
if ($("#clientReq-podgroups-type").length < 1) {
|
|||
|
|
axios.post('/ajax/ajax_vue_settings.php', {
|
|||
|
|
request: 'get_field_types',
|
|||
|
|
user_id: $("#session_user_id").val(),
|
|||
|
|
type: this.type,
|
|||
|
|
selector: "clientReq-podgroups-type",
|
|||
|
|
}).then((response) => {
|
|||
|
|
|
|||
|
|
// console.log(response.data.list);
|
|||
|
|
this.typesList = response.data.list;
|
|||
|
|
|
|||
|
|
$("#clientReq-podgroups-type-input").html(response.data.html);
|
|||
|
|
$("#clientReq-podgroups-type").val(this.type);
|
|||
|
|
$("#clientReq-podgroups-type").fastselect({
|
|||
|
|
placeholder: 'Выберите тип',
|
|||
|
|
onItemSelect: function(item, val) {
|
|||
|
|
clientReqPodgroupsModal.type = parseInt(val.value);
|
|||
|
|
|
|||
|
|
},
|
|||
|
|
});
|
|||
|
|
}).catch(function(error) {
|
|||
|
|
|
|||
|
|
if (error)
|
|||
|
|
console.debug(error);
|
|||
|
|
|
|||
|
|
});
|
|||
|
|
} else {
|
|||
|
|
$('#clientReq-podgroups-type').fastselect().data('fastselect').destroy();
|
|||
|
|
$("#clientReq-podgroups-type").val(this.type);
|
|||
|
|
$('#clientReq-podgroups-type').fastselect({
|
|||
|
|
placeholder: 'Выберите тип',
|
|||
|
|
onItemSelect: function(item, val) {
|
|||
|
|
clientReqPodgroupsModal.type = val.value;
|
|||
|
|
|
|||
|
|
},
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
|
|||
|
|
selectType(val) {
|
|||
|
|
if (val.length == 0) {
|
|||
|
|
this.selectedType = 0;
|
|||
|
|
} else {
|
|||
|
|
for (var i = 0; i < val.length; i++) {
|
|||
|
|
if (val[i] == 0) {
|
|||
|
|
val.splice(i, 1);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
if (val.length == 0) {
|
|||
|
|
this.selectedType = 0;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
},
|
|||
|
|
|
|||
|
|
storeFieldProps(action, prop, event) {
|
|||
|
|
let ref = this;
|
|||
|
|
|
|||
|
|
let params = ref.params;
|
|||
|
|
if (params.length == 0 && (ref.type == 2 || ref.type == 3)) {
|
|||
|
|
params['items'] = [];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$('.ui-tooltip.ui-widget').remove();
|
|||
|
|
|
|||
|
|
if (prop == null)
|
|||
|
|
prop = {
|
|||
|
|
value: 0,
|
|||
|
|
name: '',
|
|||
|
|
mode: 'edit'
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
console.debug({ action, prop });
|
|||
|
|
|
|||
|
|
if (typeof action !== "undefined" && typeof prop !== "undefined") {
|
|||
|
|
switch (action) {
|
|||
|
|
case 'save':
|
|||
|
|
prop.mode = null;
|
|||
|
|
prop.name = $(event.target).closest('.inputs').find('[name="item_name"]').val();
|
|||
|
|
break;
|
|||
|
|
case 'edit':
|
|||
|
|
prop.mode = 'edit';
|
|||
|
|
break;
|
|||
|
|
case 'delete':
|
|||
|
|
if (typeof params['items'] !== "undefined") {
|
|||
|
|
if (confirm('Вы действительно хотите удалить пункт `' + prop['name'] + '`? Это также приведёт к удалению данных в клиентах или заявках.')) {
|
|||
|
|
let items = params['items'];
|
|||
|
|
for (let [key, value] of Object.entries(items)) {
|
|||
|
|
if (value['value'] == prop['value']) {
|
|||
|
|
ref.params['items'].splice(key, 1);
|
|||
|
|
}
|
|||
|
|
// delete ref.params['items'][key];
|
|||
|
|
}
|
|||
|
|
//prop = null;
|
|||
|
|
$('.inputs [data-key="' + prop.value + '"]').parent('li').remove();
|
|||
|
|
params['items'] = items;
|
|||
|
|
prop = null;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
break;
|
|||
|
|
case 'close':
|
|||
|
|
if (typeof params['items'] !== "undefined") {
|
|||
|
|
if (prop.value == null || typeof prop.value == "undefined" || prop.name == '' || typeof prop.name == "undefined") {
|
|||
|
|
let items = params['items'];
|
|||
|
|
for (let [key, value] of Object.entries(items)) {
|
|||
|
|
if (value['value'] == prop['value'])
|
|||
|
|
delete ref.params['items'][key];
|
|||
|
|
}
|
|||
|
|
delete prop;
|
|||
|
|
$('.inputs [data-key="' + prop.value + '"]').parent('li').remove();
|
|||
|
|
params['items'] = items;
|
|||
|
|
} else {
|
|||
|
|
prop.mode = null;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
break;
|
|||
|
|
case 'add':
|
|||
|
|
if (typeof params['items'] !== "undefined") {
|
|||
|
|
|
|||
|
|
let next = 1,
|
|||
|
|
values = [],
|
|||
|
|
items = params['items'];
|
|||
|
|
|
|||
|
|
for (const [key, value] of Object.entries(items)) {
|
|||
|
|
values.push(parseInt(value['value']));
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (values.length > 0)
|
|||
|
|
next = Math.max(...values.sort()) + 1;
|
|||
|
|
|
|||
|
|
//console.debug(next);
|
|||
|
|
items.push({
|
|||
|
|
name: '',
|
|||
|
|
value: next,
|
|||
|
|
mode: "edit"
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
ref.params = {...params };
|
|||
|
|
console.debug(ref.params);
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
saveClientReqPodgroup(id) {
|
|||
|
|
//console.log(id);
|
|||
|
|
|
|||
|
|
if (typeof clientReqFieldsModal != "undefined") {
|
|||
|
|
var podgroup = { 'title': this.title, 'params': this.params, 'type': this.type, 'is_required': this.is_required };
|
|||
|
|
if (this.podgroup_id > 0) {
|
|||
|
|
podgroup.id = this.podgroup_id;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (id < 0) {
|
|||
|
|
if(this.isEmpty(clientReqFieldsModal.listPodgroups)){
|
|||
|
|
clientReqFieldsModal.listPodgroups = {};
|
|||
|
|
}
|
|||
|
|
podgroup.id = id;
|
|||
|
|
// console.log(clientReqFieldsModal.listPodgroups[id]);
|
|||
|
|
//clientReqFieldsModal.listPodgroups.push(podgroup);
|
|||
|
|
if(clientReqFieldsModal.listPodgroups[id]) {
|
|||
|
|
clientReqFieldsModal.$set(clientReqFieldsModal.listPodgroups, id, podgroup);
|
|||
|
|
} else {
|
|||
|
|
clientReqFieldsModal.$set(clientReqFieldsModal.listPodgroups, this.tempIndex, podgroup);
|
|||
|
|
// console.log(clientReqFieldsModal.listPodgroups);
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
this.tempIndex--;
|
|||
|
|
} else if (id >= 0) {
|
|||
|
|
clientReqFieldsModal.$set(clientReqFieldsModal.listPodgroups, id, podgroup);
|
|||
|
|
//clientReqFieldsModal.listPodgroups[id] = podgroup;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//console.log(podgroup);
|
|||
|
|
this.hideEditClientReqPodgroupsForm();
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
isEmpty(data) {
|
|||
|
|
if (typeof(data) === 'object') {
|
|||
|
|
if (JSON.stringify(data) === '{}' || JSON.stringify(data) === '[]') {
|
|||
|
|
return true;
|
|||
|
|
} else if (!data) {
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
return false;
|
|||
|
|
} else if (typeof(data) === 'string') {
|
|||
|
|
if (!data.trim()) {
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
return false;
|
|||
|
|
} else if (typeof(data) === 'undefined') {
|
|||
|
|
return true;
|
|||
|
|
} else {
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
},
|
|||
|
|
|
|||
|
|
computed: {},
|
|||
|
|
created: function() {
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if ($('#advertApiForm').length > 0) {
|
|||
|
|
var advert_api_form = new Vue({
|
|||
|
|
el: '#advertApiForm',
|
|||
|
|
components: {},
|
|||
|
|
data() {
|
|||
|
|
return {
|
|||
|
|
api_id: 0,
|
|||
|
|
agency_id: $('#session_agency_id').val() || null,
|
|||
|
|
servicesList: [],
|
|||
|
|
service_id: 0,
|
|||
|
|
client_id: null,
|
|||
|
|
secret_key: null,
|
|||
|
|
ext_user_id: null,
|
|||
|
|
use_for_complexes: '0',
|
|||
|
|
status: 1,
|
|||
|
|
error_msg: '',
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
methods: {
|
|||
|
|
setData() {
|
|||
|
|
|
|||
|
|
},
|
|||
|
|
clearData() {
|
|||
|
|
this.api_id = 0;
|
|||
|
|
//this.servicesList = [];
|
|||
|
|
this.service_id = 0;
|
|||
|
|
this.client_id = null;
|
|||
|
|
this.secret_key = null;
|
|||
|
|
this.ext_user_id = null;
|
|||
|
|
this.use_for_complexes = '0';
|
|||
|
|
this.status = 1;
|
|||
|
|
this.error_msg = '';
|
|||
|
|
},
|
|||
|
|
saveAdvertApi(id) {
|
|||
|
|
let ref = this;
|
|||
|
|
ref.error_msg = '';
|
|||
|
|
axios.post('/ajax/ajax_vue_settings.php', {
|
|||
|
|
request: 'add_edit_api',
|
|||
|
|
agency_id: ref.agency_id,
|
|||
|
|
api_id: id,
|
|||
|
|
service_id: ref.service_id,
|
|||
|
|
client_id: ref.client_id,
|
|||
|
|
secret_key: ref.secret_key,
|
|||
|
|
ext_user_id: ref.ext_user_id,
|
|||
|
|
use_for_complexes: ref.use_for_complexes,
|
|||
|
|
status: ref.status
|
|||
|
|
}).then((response) => {
|
|||
|
|
if (response.data.success) {
|
|||
|
|
ref.$emit('add_edit_api');
|
|||
|
|
ref.closeAdvertApiForm();
|
|||
|
|
} else if (!ref.isEmpty(response.data.errors)) {
|
|||
|
|
for (const [key, value] of Object.entries(response.data.errors)) {
|
|||
|
|
ref.error_msg += '<p>' + value + '</p>';
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}).catch(function(error) {
|
|||
|
|
if (error)
|
|||
|
|
console.debug(error);
|
|||
|
|
});
|
|||
|
|
},
|
|||
|
|
showAdvertApiForm(api_id) {
|
|||
|
|
let ref = this;
|
|||
|
|
if (typeof api_id !== "undefined" && api_id !== 0) {
|
|||
|
|
axios.post('/ajax/ajax_vue_settings.php', {
|
|||
|
|
request: 'get_api',
|
|||
|
|
api_id: api_id,
|
|||
|
|
agency_id: ref.agency_id
|
|||
|
|
}).then(function(response) {
|
|||
|
|
ref.api_id = response.data.id;
|
|||
|
|
ref.service_id = response.data.service_id;
|
|||
|
|
ref.client_id = response.data.client_id;
|
|||
|
|
ref.secret_key = response.data.secret_key;
|
|||
|
|
ref.ext_user_id = response.data.ext_user_id;
|
|||
|
|
ref.status = response.data.status;
|
|||
|
|
ref.use_for_complexes = response.data.use_for_complexes;
|
|||
|
|
|
|||
|
|
ref.getApiServicesList(ref.service_id);
|
|||
|
|
|
|||
|
|
$('#advertApiFormBg').fadeIn(100);
|
|||
|
|
$('#advertApiForm').toggle(50);
|
|||
|
|
$("body").addClass("lock");
|
|||
|
|
}).catch(function(error) {
|
|||
|
|
if (error)
|
|||
|
|
console.debug(error);
|
|||
|
|
});
|
|||
|
|
} else {
|
|||
|
|
|
|||
|
|
ref.service_id = 0;
|
|||
|
|
if (typeof advertising_stats != "undefined") {
|
|||
|
|
let exploded = advertising_stats.explodeList;
|
|||
|
|
ref.getApiServicesList(ref.service_id, exploded);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$('#advertApiFormBg').fadeIn(100);
|
|||
|
|
$('#advertApiForm').toggle(50);
|
|||
|
|
$("body").addClass("lock");
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
closeAdvertApiForm() {
|
|||
|
|
$('#advertApiFormBg').fadeOut(300);
|
|||
|
|
$('#advertApiForm').toggle(100);
|
|||
|
|
$("body").removeClass("lock");
|
|||
|
|
this.clearData();
|
|||
|
|
},
|
|||
|
|
getApiServicesList(service_id, explode_id) {
|
|||
|
|
let ref = this;
|
|||
|
|
if (typeof service_id !== "undefined")
|
|||
|
|
ref.service_id = service_id;
|
|||
|
|
|
|||
|
|
axios.post('/ajax/ajax_vue_settings.php', {
|
|||
|
|
request: 'get_api_services',
|
|||
|
|
agency_id: ref.agency_id,
|
|||
|
|
service_id: ref.service_id,
|
|||
|
|
explode_id: explode_id,
|
|||
|
|
}).then(function(response) {
|
|||
|
|
var new_array = response.data.list;
|
|||
|
|
ref.servicesList = ref.servicesList.concat(new_array);
|
|||
|
|
|
|||
|
|
$("#api-service-list").html(response.data.html);
|
|||
|
|
$("#api-service-list-input").fastselect({
|
|||
|
|
placeholder: 'Выберите площадку',
|
|||
|
|
onItemSelect: function(item, val) {
|
|||
|
|
ref.service_id = val.value;
|
|||
|
|
console.log(ref.service_id);
|
|||
|
|
},
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
console.debug(ref.servicesList);
|
|||
|
|
}).catch(function(error) {
|
|||
|
|
ref.servicesList = [];
|
|||
|
|
if (error)
|
|||
|
|
console.debug(error);
|
|||
|
|
});
|
|||
|
|
return ref.servicesList;
|
|||
|
|
},
|
|||
|
|
getServiceName: function(service_id) {
|
|||
|
|
let ref = this;
|
|||
|
|
if (typeof service_id !== "undefined") {
|
|||
|
|
if (!ref.isEmpty(service_id)) {
|
|||
|
|
for (const [key, value] of Object.entries(ref.servicesList)) {
|
|||
|
|
if (parseInt(value['value']) == parseInt(service_id))
|
|||
|
|
return value['label'];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return service_id;
|
|||
|
|
},
|
|||
|
|
isEmpty(data) {
|
|||
|
|
if (typeof(data) === 'object') {
|
|||
|
|
if (JSON.stringify(data) === '{}' || JSON.stringify(data) === '[]') {
|
|||
|
|
return true;
|
|||
|
|
} else if (!data) {
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
return false;
|
|||
|
|
} else if (typeof(data) === 'string') {
|
|||
|
|
if (!data.trim()) {
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
return false;
|
|||
|
|
} else if (typeof(data) === 'undefined') {
|
|||
|
|
return true;
|
|||
|
|
} else {
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
},
|
|||
|
|
created: function() {
|
|||
|
|
this.getApiServicesList();
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
if ($('#advertising_stats').length > 0) {
|
|||
|
|
var advertising_stats = new Vue({
|
|||
|
|
el: '#advertising_stats',
|
|||
|
|
components: {},
|
|||
|
|
data() {
|
|||
|
|
return {
|
|||
|
|
apiList: [],
|
|||
|
|
agency_id: $('#session_agency_id').val() || null,
|
|||
|
|
servicesList: [],
|
|||
|
|
explodeList: [],
|
|||
|
|
hideAddButton: false,
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
methods: {
|
|||
|
|
getApiList() {
|
|||
|
|
let ref = this;
|
|||
|
|
ref.apiList = [];
|
|||
|
|
ref.servicesList = advert_api_form.getApiServicesList();
|
|||
|
|
axios.post('/ajax/ajax_vue_settings.php', {
|
|||
|
|
request: 'get_api_list',
|
|||
|
|
agency_id: ref.agency_id
|
|||
|
|
}).then(function(response) {
|
|||
|
|
console.log(response.data);
|
|||
|
|
var new_array = response.data;
|
|||
|
|
ref.apiList = ref.apiList.concat(new_array);
|
|||
|
|
ref.servicesList = advert_api_form.getApiServicesList(0, ref.explodeList);
|
|||
|
|
|
|||
|
|
|
|||
|
|
for (const [key, item] of Object.entries(ref.apiList)) {
|
|||
|
|
ref.explodeList.push(parseInt(item['service_id']));
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
let servicesList2 = ref.servicesList;
|
|||
|
|
for (const [key, item] of Object.entries(servicesList2)) {
|
|||
|
|
if (ref.explodeList.indexOf(parseInt(item['value'])) !== -1) {
|
|||
|
|
delete(servicesList2[key]);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (servicesList2.length == 0) {
|
|||
|
|
ref.hideAddButton = true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}).catch(function(error) {
|
|||
|
|
if (error)
|
|||
|
|
console.debug(error);
|
|||
|
|
});
|
|||
|
|
},
|
|||
|
|
addAdvertStatsApi() {
|
|||
|
|
advert_api_form.showAdvertApiForm(0);
|
|||
|
|
},
|
|||
|
|
showAdvertApiForm(api_id) {
|
|||
|
|
advert_api_form.showAdvertApiForm(api_id);
|
|||
|
|
},
|
|||
|
|
confirmDeleteAdvertApi(api_id) {
|
|||
|
|
let ref = this;
|
|||
|
|
if (confirm('Вы действительно хотите удалить доступ к этому API.')) {
|
|||
|
|
axios.post('/ajax/ajax_vue_settings.php', {
|
|||
|
|
request: 'del_api',
|
|||
|
|
agency_id: ref.agency_id,
|
|||
|
|
api_id: api_id,
|
|||
|
|
}).then(function(response) {
|
|||
|
|
if (response.data.success) {
|
|||
|
|
ref.getApiList();
|
|||
|
|
}
|
|||
|
|
}).catch(function(error) {
|
|||
|
|
if (error)
|
|||
|
|
console.debug(error);
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
testAdvertApi(api_id, event) {
|
|||
|
|
let ref = this;
|
|||
|
|
let note = null;
|
|||
|
|
let button = $(event.target).parent('a');
|
|||
|
|
if (typeof api_id !== "undefined" && api_id !== 0) {
|
|||
|
|
button.fadeOut();
|
|||
|
|
axios.post('/ajax/ajax_vue_settings.php', {
|
|||
|
|
request: 'test_api',
|
|||
|
|
api_id: api_id,
|
|||
|
|
agency_id: ref.agency_id
|
|||
|
|
}).then(function(response) {
|
|||
|
|
console.log(response.data);
|
|||
|
|
if (response.data.success) {
|
|||
|
|
note = $('<span style="color:darkgreen;">OK</span>');
|
|||
|
|
button.after(note);
|
|||
|
|
} else {
|
|||
|
|
console.debug(response.data.errors);
|
|||
|
|
let errors = response.data.errors;
|
|||
|
|
note = $('<span style="color:darkred;" title="' + errors + '">ERROR</span>');
|
|||
|
|
button.after(note);
|
|||
|
|
}
|
|||
|
|
}).catch(function(error) {
|
|||
|
|
if (error) {
|
|||
|
|
note = $('<span style="color:darkred;" title="' + error + '">ERROR</span>');
|
|||
|
|
button.after(note);
|
|||
|
|
console.debug(error);
|
|||
|
|
} else {
|
|||
|
|
note = $('<span style="color:darkred;">ERROR</span>');
|
|||
|
|
button.after(note);
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
setTimeout(function() {
|
|||
|
|
if (typeof note == "object") {
|
|||
|
|
note.remove();
|
|||
|
|
}
|
|||
|
|
button.fadeIn();
|
|||
|
|
}, 3000);
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
|
|||
|
|
onMessage(api_id, event){
|
|||
|
|
let note = null;
|
|||
|
|
let indexApi = null;
|
|||
|
|
for(let i=0; i<this.apiList.length; i++){
|
|||
|
|
if(this.apiList[i].id == api_id){
|
|||
|
|
indexApi = i;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (typeof api_id !== "undefined" && api_id !== 0) {
|
|||
|
|
//button.fadeOut();
|
|||
|
|
axios.post('/ajax/ajax_vue_settings.php', {
|
|||
|
|
request: 'on_meesage',
|
|||
|
|
api_id: api_id,
|
|||
|
|
agency_id: this.agency_id
|
|||
|
|
}).then((response) => {
|
|||
|
|
$('.ui-tooltip.ui-widget').remove();
|
|||
|
|
console.log(response.data)
|
|||
|
|
if (response.data.errors) {
|
|||
|
|
let errors = response.data.errors;
|
|||
|
|
note = $('<span style="color:darkred;" title="' + errors + '">ERROR</span>');
|
|||
|
|
|
|||
|
|
|
|||
|
|
} else {
|
|||
|
|
note = $('<span style="color:darkgreen;">OK</span>');
|
|||
|
|
this.apiList[indexApi].is_messages = 1;
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}).catch(function(error) {
|
|||
|
|
if (error) {
|
|||
|
|
note = $('<span style="color:darkred;" title="' + error + '">ERROR</span>');
|
|||
|
|
|
|||
|
|
console.debug(error);
|
|||
|
|
} else {
|
|||
|
|
note = $('<span style="color:darkred;">ERROR</span>');
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
setTimeout(function() {
|
|||
|
|
if (typeof note == "object") {
|
|||
|
|
note.remove();
|
|||
|
|
$('.ui-tooltip.ui-widget').remove();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}, 3000);
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
|
|||
|
|
offMessage(api_id, event){
|
|||
|
|
let note = null;
|
|||
|
|
let indexApi = null;
|
|||
|
|
for(let i=0; i<this.apiList.length; i++){
|
|||
|
|
if(this.apiList[i].id == api_id){
|
|||
|
|
indexApi = i;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
// let button = $(event.target).parent('a');
|
|||
|
|
if (typeof api_id !== "undefined" && api_id !== 0) {
|
|||
|
|
// button.fadeOut();
|
|||
|
|
axios.post('/ajax/ajax_vue_settings.php', {
|
|||
|
|
request: 'off_meesage',
|
|||
|
|
api_id: api_id,
|
|||
|
|
agency_id: this.agency_id
|
|||
|
|
}).then((response) => {
|
|||
|
|
console.log(response.data)
|
|||
|
|
$('.ui-tooltip.ui-widget').remove();
|
|||
|
|
if (response.data.errors) {
|
|||
|
|
let errors = response.data.errors;
|
|||
|
|
note = $('<span style="color:darkred;" title="' + errors + '">ERROR</span>');
|
|||
|
|
// button.after(note);
|
|||
|
|
|
|||
|
|
} else {
|
|||
|
|
note = $('<span style="color:darkgreen;">OK</span>');
|
|||
|
|
this.apiList[indexApi].is_messages = 0;
|
|||
|
|
// button.after(note);
|
|||
|
|
}
|
|||
|
|
}).catch(function(error) {
|
|||
|
|
if (error) {
|
|||
|
|
note = $('<span style="color:darkred;" title="' + error + '">ERROR</span>');
|
|||
|
|
// button.after(note);
|
|||
|
|
console.debug(error);
|
|||
|
|
} else {
|
|||
|
|
note = $('<span style="color:darkred;">ERROR</span>');
|
|||
|
|
// button.after(note);
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
setTimeout(function() {
|
|||
|
|
if (typeof note == "object") {
|
|||
|
|
note.remove();
|
|||
|
|
$('.ui-tooltip.ui-widget').remove();
|
|||
|
|
}
|
|||
|
|
// button.fadeIn();
|
|||
|
|
}, 3000);
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
|
|||
|
|
isEmpty(data) {
|
|||
|
|
if (typeof(data) === 'object') {
|
|||
|
|
if (JSON.stringify(data) === '{}' || JSON.stringify(data) === '[]') {
|
|||
|
|
return true;
|
|||
|
|
} else if (!data) {
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
return false;
|
|||
|
|
} else if (typeof(data) === 'string') {
|
|||
|
|
if (!data.trim()) {
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
return false;
|
|||
|
|
} else if (typeof(data) === 'undefined') {
|
|||
|
|
return true;
|
|||
|
|
} else {
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
getServiceName: function(service_id) {
|
|||
|
|
return advert_api_form.getServiceName(service_id);
|
|||
|
|
},
|
|||
|
|
getForComplexesStr: function(forComplexes) {
|
|||
|
|
if (forComplexes && forComplexes == "1") {
|
|||
|
|
return "Да"
|
|||
|
|
} else {
|
|||
|
|
return "Нет"
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
safetyString: function(string, start, end) {
|
|||
|
|
if (typeof string !== "undefined") {
|
|||
|
|
if (!this.isEmpty(string)) {
|
|||
|
|
return string.slice(0, start) + '*****' + string.slice(-end);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return string;
|
|||
|
|
},
|
|||
|
|
},
|
|||
|
|
computed: {},
|
|||
|
|
created: function() {
|
|||
|
|
|
|||
|
|
setTimeout(this.getApiList(), 1000);
|
|||
|
|
|
|||
|
|
if (typeof advert_api_form != "undefined") {
|
|||
|
|
let ref = this;
|
|||
|
|
ref.servicesList = advert_api_form.getApiServicesList(0, ref.explodeList);
|
|||
|
|
advert_api_form.$on('add_edit_api', function() {
|
|||
|
|
ref.getApiList();
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if ($('#contract_types').length > 0) {
|
|||
|
|
var contract_types = new Vue({
|
|||
|
|
el: '#contract_types',
|
|||
|
|
components: {},
|
|||
|
|
data() {
|
|||
|
|
return {
|
|||
|
|
agency_id: $('#session_agency_id').val() || null,
|
|||
|
|
user_id: $('#session_user_id').val() || null,
|
|||
|
|
typeList: [],
|
|||
|
|
isEditForm: false,
|
|||
|
|
type_id: 0,
|
|||
|
|
type_title: null,
|
|||
|
|
error_name: false,
|
|||
|
|
errorText: '',
|
|||
|
|
errorMes: false,
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
methods: {
|
|||
|
|
getTypes() {
|
|||
|
|
axios.post('/ajax/ajax_vue_contract.php', {
|
|||
|
|
request: 'get_types_contract',
|
|||
|
|
agency_id: this.agency_id,
|
|||
|
|
}, )
|
|||
|
|
.then((response) => {
|
|||
|
|
//console.log(response.data);
|
|||
|
|
this.typeList = response.data;
|
|||
|
|
})
|
|||
|
|
.catch(function(error) {
|
|||
|
|
console.log(error);
|
|||
|
|
});
|
|||
|
|
},
|
|||
|
|
|
|||
|
|
//Редактирование типа
|
|||
|
|
edit(index) {
|
|||
|
|
this.error_name = false;
|
|||
|
|
this.errorText = '';
|
|||
|
|
this.errorMes = false;
|
|||
|
|
|
|||
|
|
this.isEditForm = true;
|
|||
|
|
if (index == -1) {
|
|||
|
|
this.type_id = 0;
|
|||
|
|
this.type_title = '';
|
|||
|
|
} else if (this.typeList[index].code > 0) {
|
|||
|
|
this.type_id = this.typeList[index].code;
|
|||
|
|
this.type_title = this.typeList[index].type;
|
|||
|
|
} else {
|
|||
|
|
alert("Что-то пошло не так!!! Обратитесь в техподдержку.");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
},
|
|||
|
|
|
|||
|
|
//Сохраненние
|
|||
|
|
saveType() {
|
|||
|
|
this.error_name = false;
|
|||
|
|
this.errorText = '';
|
|||
|
|
this.errorMes = false;
|
|||
|
|
if (this.isEmpty(this.type_title)) {
|
|||
|
|
this.error_name = true;
|
|||
|
|
this.errorText = '<p>Введите ноименование типа</p>';
|
|||
|
|
this.errorMes = true;
|
|||
|
|
} else {
|
|||
|
|
|
|||
|
|
axios.post('/ajax/ajax_vue_contract.php', {
|
|||
|
|
request: 'edit_add_type',
|
|||
|
|
agency_id: this.agency_id,
|
|||
|
|
user_id: this.user_id,
|
|||
|
|
id: this.type_id,
|
|||
|
|
type: this.type_title,
|
|||
|
|
}).then((response) => {
|
|||
|
|
if (response.data) {
|
|||
|
|
//console.log(response.data);
|
|||
|
|
this.getTypes();
|
|||
|
|
}
|
|||
|
|
}).catch(function(error) {
|
|||
|
|
if (error)
|
|||
|
|
console.log(error);
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
this.isEditForm = false;
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
|
|||
|
|
//Удаленине типа
|
|||
|
|
deleted(index) {
|
|||
|
|
if (confirm('Вы действительно хотите удалить этот тип договора?')) {
|
|||
|
|
var id = this.typeList[index].code;
|
|||
|
|
|
|||
|
|
if (id > 0) {
|
|||
|
|
axios.post('/ajax/ajax_vue_contract.php', {
|
|||
|
|
request: 'del_type',
|
|||
|
|
agency_id: this.agency_id,
|
|||
|
|
user_id: this.user_id,
|
|||
|
|
id: id,
|
|||
|
|
}).then((response) => {
|
|||
|
|
if (response.data) {
|
|||
|
|
//console.log(response.data);
|
|||
|
|
this.getTypes();
|
|||
|
|
}
|
|||
|
|
}).catch(function(error) {
|
|||
|
|
if (error)
|
|||
|
|
console.log(error);
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
|
|||
|
|
isEmpty(data) {
|
|||
|
|
if (typeof(data) === 'object') {
|
|||
|
|
if (JSON.stringify(data) === '{}' || JSON.stringify(data) === '[]') {
|
|||
|
|
return true;
|
|||
|
|
} else if (!data) {
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
return false;
|
|||
|
|
} else if (typeof(data) === 'string') {
|
|||
|
|
if (!data.trim()) {
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
return false;
|
|||
|
|
} else if (typeof(data) === 'undefined') {
|
|||
|
|
return true;
|
|||
|
|
} else {
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
},
|
|||
|
|
computed: {
|
|||
|
|
|
|||
|
|
},
|
|||
|
|
created: function() {
|
|||
|
|
$('#contract_types .full_modal-bg').removeClass('hidden');
|
|||
|
|
$('#contract_types .full_modal').removeClass('hidden');
|
|||
|
|
this.getTypes();
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//Причины хакрытия
|
|||
|
|
|
|||
|
|
if ($('#denial_list').length > 0) {
|
|||
|
|
var denial_list = new Vue({
|
|||
|
|
el: '#denial_list',
|
|||
|
|
components: {},
|
|||
|
|
data() {
|
|||
|
|
return {
|
|||
|
|
agency_id: $('#session_agency_id').val() || null,
|
|||
|
|
user_id: $('#session_user_id').val() || null,
|
|||
|
|
denialList: [],
|
|||
|
|
isEditForm: false,
|
|||
|
|
denial_id: 0,
|
|||
|
|
denial_title: null,
|
|||
|
|
error_name: false,
|
|||
|
|
error_heir: false,
|
|||
|
|
errorText: '',
|
|||
|
|
errorMes: false,
|
|||
|
|
OpenIndicator: {
|
|||
|
|
render: createElement => createElement('span', { class: { 'vueToggleSpan': true } }),
|
|||
|
|
},
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
methods: {
|
|||
|
|
getDenials() {
|
|||
|
|
axios.post('/ajax/ajax_vue_requisitions.php', {
|
|||
|
|
request: 'get_denials',
|
|||
|
|
agency_id: this.agency_id
|
|||
|
|
|
|||
|
|
}, )
|
|||
|
|
.then((response) => {
|
|||
|
|
console.log(response.data);
|
|||
|
|
this.denialList = response.data;
|
|||
|
|
|
|||
|
|
})
|
|||
|
|
.catch(function(error) {
|
|||
|
|
console.log(error);
|
|||
|
|
});
|
|||
|
|
},
|
|||
|
|
|
|||
|
|
//Редактирование типа
|
|||
|
|
edit(index) {
|
|||
|
|
this.error_name = false;
|
|||
|
|
this.errorText = '';
|
|||
|
|
this.errorMes = false;
|
|||
|
|
this.error_heir = false;
|
|||
|
|
|
|||
|
|
// this.type_type = 'label';
|
|||
|
|
|
|||
|
|
this.isEditForm = true;
|
|||
|
|
if (index == -1) {
|
|||
|
|
this.denial_id = 0;
|
|||
|
|
this.denial_title = '';
|
|||
|
|
|
|||
|
|
|
|||
|
|
} else if (this.denialList[index].id > 0) {
|
|||
|
|
this.denial_id = this.denialList[index].id;
|
|||
|
|
this.denial_title = this.denialList[index].name;
|
|||
|
|
|
|||
|
|
} else {
|
|||
|
|
alert("Что-то пошло не так!!! Обратитесь в техподдержку.");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
},
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
//Сохраненние
|
|||
|
|
save() {
|
|||
|
|
this.error_name = false;
|
|||
|
|
this.errorText = '';
|
|||
|
|
this.errorMes = false;
|
|||
|
|
|
|||
|
|
|
|||
|
|
if (this.isEmpty(this.denial_title)) {
|
|||
|
|
this.error_name = true;
|
|||
|
|
this.errorText = '<p>Введите ноименование причины</p>';
|
|||
|
|
this.errorMes = true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
if (!this.errorMes) {
|
|||
|
|
|
|||
|
|
this.isEditForm = false;
|
|||
|
|
|
|||
|
|
axios.post('/ajax/ajax_vue_requisitions.php', {
|
|||
|
|
request: 'edit_denial',
|
|||
|
|
agency_id: this.agency_id,
|
|||
|
|
|
|||
|
|
id: this.denial_id,
|
|||
|
|
name: this.denial_title,
|
|||
|
|
|
|||
|
|
}).then((response) => {
|
|||
|
|
if (response.data) {
|
|||
|
|
//console.log(response.data);
|
|||
|
|
//this.getDenials();
|
|||
|
|
this.denialList = response.data;
|
|||
|
|
}
|
|||
|
|
}).catch(function(error) {
|
|||
|
|
if (error)
|
|||
|
|
console.log(error);
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
|
|||
|
|
|
|||
|
|
//Удаленине типа
|
|||
|
|
deleted(index) {
|
|||
|
|
if (confirm('Вы действительно хотите удалить эту причину?')) {
|
|||
|
|
var id = this.denialList[index].id;
|
|||
|
|
//console.log(id);
|
|||
|
|
if (id > 0) {
|
|||
|
|
|
|||
|
|
axios.post('/ajax/ajax_vue_requisitions.php', {
|
|||
|
|
request: 'del_denial',
|
|||
|
|
agency_id: this.agency_id,
|
|||
|
|
id: id,
|
|||
|
|
}).then((response) => {
|
|||
|
|
if (response.data) {
|
|||
|
|
this.denialList = response.data;
|
|||
|
|
}
|
|||
|
|
}).catch(function(error) {
|
|||
|
|
if (error)
|
|||
|
|
console.log(error);
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
isEmpty(data) {
|
|||
|
|
if (typeof(data) === 'object') {
|
|||
|
|
if (JSON.stringify(data) === '{}' || JSON.stringify(data) === '[]') {
|
|||
|
|
return true;
|
|||
|
|
} else if (!data) {
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
return false;
|
|||
|
|
} else if (typeof(data) === 'string') {
|
|||
|
|
if (!data.trim()) {
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
return false;
|
|||
|
|
} else if (typeof(data) === 'undefined') {
|
|||
|
|
return true;
|
|||
|
|
} else {
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
},
|
|||
|
|
computed: {
|
|||
|
|
|
|||
|
|
},
|
|||
|
|
created: function() {
|
|||
|
|
$('#denial_list .full_modal-bg').removeClass('hidden');
|
|||
|
|
$('#denial_list .full_modal').removeClass('hidden');
|
|||
|
|
this.getDenials();
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
//Типы заявок
|
|||
|
|
if ($('#requisitions_types').length > 0) {
|
|||
|
|
var requisitions_types = new Vue({
|
|||
|
|
el: '#requisitions_types',
|
|||
|
|
components: {},
|
|||
|
|
data() {
|
|||
|
|
return {
|
|||
|
|
agency_id: $('#session_agency_id').val() || null,
|
|||
|
|
user_id: $('#session_user_id').val() || null,
|
|||
|
|
typeList: [{
|
|||
|
|
"code": 0,
|
|||
|
|
"name": "",
|
|||
|
|
"order": -1,
|
|||
|
|
"heir": 0,
|
|||
|
|
"archive": 0,
|
|||
|
|
"type": "label",
|
|||
|
|
}],
|
|||
|
|
typeListArchive: [],
|
|||
|
|
isEditForm: false,
|
|||
|
|
type_id: 0,
|
|||
|
|
type_title: null,
|
|||
|
|
error_name: false,
|
|||
|
|
error_heir: false,
|
|||
|
|
errorText: '',
|
|||
|
|
errorMes: false,
|
|||
|
|
OpenIndicator: {
|
|||
|
|
render: createElement => createElement('span', { class: { 'vueToggleSpan': true } }),
|
|||
|
|
},
|
|||
|
|
heir_types_req: [],
|
|||
|
|
heir_type: 1,
|
|||
|
|
type_type: 'label',
|
|||
|
|
denial_list: [],
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
methods: {
|
|||
|
|
getTypes() {
|
|||
|
|
axios.post('/ajax/ajax_vue_requisitions.php', {
|
|||
|
|
request: 'get_type',
|
|||
|
|
agency_id: this.agency_id,
|
|||
|
|
setting: 1,
|
|||
|
|
}, )
|
|||
|
|
.then((response) => {
|
|||
|
|
console.log(response.data);
|
|||
|
|
this.typeList = response.data.type;
|
|||
|
|
this.heir_types_req = response.data.heir;
|
|||
|
|
this.typeListArchive = response.data.type_archive;
|
|||
|
|
})
|
|||
|
|
.catch(function(error) {
|
|||
|
|
console.log(error);
|
|||
|
|
});
|
|||
|
|
},
|
|||
|
|
|
|||
|
|
//Редактирование типа
|
|||
|
|
edit(index) {
|
|||
|
|
this.error_name = false;
|
|||
|
|
this.errorText = '';
|
|||
|
|
this.errorMes = false;
|
|||
|
|
this.error_heir = false;
|
|||
|
|
|
|||
|
|
// this.type_type = 'label';
|
|||
|
|
|
|||
|
|
this.isEditForm = true;
|
|||
|
|
if (index == -1) {
|
|||
|
|
this.type_id = 0;
|
|||
|
|
this.type_title = '';
|
|||
|
|
this.type_type = 'label';
|
|||
|
|
this.denial_list = [];
|
|||
|
|
|
|||
|
|
} else if (this.typeList[index].code > 0) {
|
|||
|
|
this.type_id = this.typeList[index].code;
|
|||
|
|
this.type_title = this.typeList[index].name;
|
|||
|
|
this.heir_type = this.typeList[index].heir;
|
|||
|
|
this.type_type = this.typeList[index].type;
|
|||
|
|
this.denial_list = this.typeList[index].denial;
|
|||
|
|
} else {
|
|||
|
|
alert("Что-то пошло не так!!! Обратитесь в техподдержку.");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
},
|
|||
|
|
|
|||
|
|
check_denial(denial_id) {
|
|||
|
|
var check = 0;
|
|||
|
|
if (this.denial_list[denial_id].check == 0) {
|
|||
|
|
check = 1;
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
this.denial_list[denial_id].check = check;
|
|||
|
|
if (this.type_id > 0) {
|
|||
|
|
axios.post('/ajax/ajax_vue_requisitions.php', {
|
|||
|
|
request: 'set_type_denial',
|
|||
|
|
agency_id: this.agency_id,
|
|||
|
|
type_id: this.type_id,
|
|||
|
|
denial_id: denial_id,
|
|||
|
|
check: check,
|
|||
|
|
}, )
|
|||
|
|
.then((response) => {
|
|||
|
|
console.log(response.data);
|
|||
|
|
/*this.typeList = response.data.type;
|
|||
|
|
this.heir_types_req = response.data.heir;
|
|||
|
|
this.typeListArchive = response.data.type_archive;*/
|
|||
|
|
})
|
|||
|
|
.catch(function(error) {
|
|||
|
|
console.log(error);
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
|
|||
|
|
//Сохраненние
|
|||
|
|
saveType() {
|
|||
|
|
this.error_name = false;
|
|||
|
|
this.errorText = '';
|
|||
|
|
this.errorMes = false;
|
|||
|
|
this.error_heir = false;
|
|||
|
|
if (this.isEmpty(this.heir_type) || this.heir_type == 0) {
|
|||
|
|
this.error_heir = true;
|
|||
|
|
this.errorText = '<p>Выберите наследуемый тип </p>';
|
|||
|
|
this.errorMes = true;
|
|||
|
|
}
|
|||
|
|
if (this.isEmpty(this.type_title)) {
|
|||
|
|
this.error_name = true;
|
|||
|
|
this.errorText = '<p>Введите ноименование типа</p>';
|
|||
|
|
this.errorMes = true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
var order = 1;
|
|||
|
|
if (this.typeList.length > 0) {
|
|||
|
|
order = this.typeList.length + 1;
|
|||
|
|
}
|
|||
|
|
if (!this.errorMes) {
|
|||
|
|
|
|||
|
|
axios.post('/ajax/ajax_vue_requisitions.php', {
|
|||
|
|
request: 'edit_add_type',
|
|||
|
|
agency_id: this.agency_id,
|
|||
|
|
user_id: this.user_id,
|
|||
|
|
id: this.type_id,
|
|||
|
|
type: this.type_title,
|
|||
|
|
heir: this.heir_type,
|
|||
|
|
type_type: this.type_type,
|
|||
|
|
order: order
|
|||
|
|
}).then((response) => {
|
|||
|
|
if (response.data) {
|
|||
|
|
//console.log(response.data);
|
|||
|
|
this.getTypes();
|
|||
|
|
}
|
|||
|
|
}).catch(function(error) {
|
|||
|
|
if (error)
|
|||
|
|
console.log(error);
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
this.isEditForm = false;
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
|
|||
|
|
//очередь
|
|||
|
|
setFieldOrder: function(id, order, direction) {
|
|||
|
|
|
|||
|
|
axios.post('/ajax/ajax_vue_requisitions.php', {
|
|||
|
|
request: 'set_type_order',
|
|||
|
|
agency_id: this.agency_id,
|
|||
|
|
direct: direction,
|
|||
|
|
sort_order: order,
|
|||
|
|
id: id
|
|||
|
|
}).then((response) => {
|
|||
|
|
//console.log(response.data);
|
|||
|
|
if (response.data) {
|
|||
|
|
this.typeList = response.data.type;
|
|||
|
|
this.typeListArchive = response.data.type_archive;
|
|||
|
|
this.heir_types_req = response.data.heir;
|
|||
|
|
//ref.fieldsList = [];
|
|||
|
|
// ref.getObjectFields();
|
|||
|
|
}
|
|||
|
|
}).catch(function(error) {
|
|||
|
|
if (error)
|
|||
|
|
console.debug(error);
|
|||
|
|
});
|
|||
|
|
},
|
|||
|
|
|
|||
|
|
|
|||
|
|
//Помещение в архив
|
|||
|
|
|
|||
|
|
archive(index) {
|
|||
|
|
if (confirm('Вы действительно хотите архивировать этот тип заявки?')) {
|
|||
|
|
var id = this.typeList[index].code;
|
|||
|
|
var order = 1;
|
|||
|
|
if (this.typeList.length > 0) {
|
|||
|
|
order = this.typeList.length + 1;
|
|||
|
|
}
|
|||
|
|
// console.log(id);
|
|||
|
|
if (id > 0) {
|
|||
|
|
|
|||
|
|
axios.post('/ajax/ajax_vue_requisitions.php', {
|
|||
|
|
request: 'archive_type_req',
|
|||
|
|
agency_id: this.agency_id,
|
|||
|
|
user_id: this.user_id,
|
|||
|
|
order: order,
|
|||
|
|
id: id,
|
|||
|
|
}).then((response) => {
|
|||
|
|
if (response.data) {
|
|||
|
|
this.getTypes();
|
|||
|
|
}
|
|||
|
|
}).catch(function(error) {
|
|||
|
|
if (error)
|
|||
|
|
console.log(error);
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
|
|||
|
|
|
|||
|
|
//Удаленине типа
|
|||
|
|
deleted(index) {
|
|||
|
|
if (confirm('Вы действительно хотите удалить этот тип заявки?')) {
|
|||
|
|
var id = this.typeListArchive[index].code;
|
|||
|
|
//console.log(id);
|
|||
|
|
if (id > 0) {
|
|||
|
|
|
|||
|
|
axios.post('/ajax/ajax_vue_requisitions.php', {
|
|||
|
|
request: 'del_type_req',
|
|||
|
|
agency_id: this.agency_id,
|
|||
|
|
user_id: this.user_id,
|
|||
|
|
id: id,
|
|||
|
|
}).then((response) => {
|
|||
|
|
if (response.data) {
|
|||
|
|
this.getTypes();
|
|||
|
|
}
|
|||
|
|
}).catch(function(error) {
|
|||
|
|
if (error)
|
|||
|
|
console.log(error);
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
|
|||
|
|
//Восстановление из архива
|
|||
|
|
recover(index) {
|
|||
|
|
var id = this.typeListArchive[index].code;
|
|||
|
|
var order = 1;
|
|||
|
|
if (this.typeList.length > 0) {
|
|||
|
|
order = this.typeList.length + this.typeListArchive.length + 1;
|
|||
|
|
}
|
|||
|
|
//console.log(id);
|
|||
|
|
if (id > 0) {
|
|||
|
|
|
|||
|
|
axios.post('/ajax/ajax_vue_requisitions.php', {
|
|||
|
|
request: 'recover_type_req',
|
|||
|
|
agency_id: this.agency_id,
|
|||
|
|
user_id: this.user_id,
|
|||
|
|
order: order,
|
|||
|
|
id: id,
|
|||
|
|
}).then((response) => {
|
|||
|
|
//console.log(response.data);
|
|||
|
|
if (response.data) {
|
|||
|
|
this.getTypes();
|
|||
|
|
}
|
|||
|
|
}).catch(function(error) {
|
|||
|
|
if (error)
|
|||
|
|
console.log(error);
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
|
|||
|
|
isEmpty(data) {
|
|||
|
|
if (typeof(data) === 'object') {
|
|||
|
|
if (JSON.stringify(data) === '{}' || JSON.stringify(data) === '[]') {
|
|||
|
|
return true;
|
|||
|
|
} else if (!data) {
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
return false;
|
|||
|
|
} else if (typeof(data) === 'string') {
|
|||
|
|
if (!data.trim()) {
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
return false;
|
|||
|
|
} else if (typeof(data) === 'undefined') {
|
|||
|
|
return true;
|
|||
|
|
} else {
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
},
|
|||
|
|
computed: {
|
|||
|
|
|
|||
|
|
},
|
|||
|
|
created: function() {
|
|||
|
|
$('#requisitions_types .full_modal-bg').removeClass('hidden');
|
|||
|
|
$('#requisitions_types .full_modal').removeClass('hidden');
|
|||
|
|
this.getTypes();
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if ($('#complex_status').length > 0) {
|
|||
|
|
var complex_status_types = new Vue({
|
|||
|
|
el: '#complex_status',
|
|||
|
|
components: {},
|
|||
|
|
data() {
|
|||
|
|
return {
|
|||
|
|
defaultComplexStatusList: [],
|
|||
|
|
complexStatusList: [{
|
|||
|
|
id: null,
|
|||
|
|
name: null,
|
|||
|
|
status: null,
|
|||
|
|
color: null
|
|||
|
|
}],
|
|||
|
|
complex_status_id: null,
|
|||
|
|
isEditForm: false,
|
|||
|
|
roomToArchiveInfo: {
|
|||
|
|
rooms_count: null,
|
|||
|
|
status_id: null,
|
|||
|
|
new_status_id: null
|
|||
|
|
},
|
|||
|
|
status: {
|
|||
|
|
booking_type: null,
|
|||
|
|
booking_hour: null,
|
|||
|
|
booking_day: null,
|
|||
|
|
reminder_hour: null,
|
|||
|
|
reminder_day: null,
|
|||
|
|
reservation_extension: false,
|
|||
|
|
can_change_booking_queue: [],
|
|||
|
|
specify_comment_confirm: false,
|
|||
|
|
specify_comment_unconfirm: false,
|
|||
|
|
managers_of_confirm_reservation_extension: [],
|
|||
|
|
employees_not_required_confirmation: [],
|
|||
|
|
managers_of_unconfirm_reservation_extension: [],
|
|||
|
|
employees_not_required_unconfirmation: [],
|
|||
|
|
color: null,
|
|||
|
|
},
|
|||
|
|
complexStatusListArchive: [],
|
|||
|
|
error_name: false,
|
|||
|
|
error_status: false,
|
|||
|
|
error_booking_type: false,
|
|||
|
|
error_booking_hour: false,
|
|||
|
|
error_booking_day: false,
|
|||
|
|
error_reminder_hour: false,
|
|||
|
|
error_reminder_day: false,
|
|||
|
|
error_can_change_booking_queue: false,
|
|||
|
|
error_managers_of_confirm_reservation_extension: false,
|
|||
|
|
error_employees_not_required_confirmation: false,
|
|||
|
|
error_managers_of_unconfirm_reservation_extension: false,
|
|||
|
|
error_employees_not_required_unconfirmation: false,
|
|||
|
|
errorText: '',
|
|||
|
|
colorPicker: null,
|
|||
|
|
lastStatusColor: null,
|
|||
|
|
errorMes: false,
|
|||
|
|
pickerChanged: false,
|
|||
|
|
status_colors: [
|
|||
|
|
"#b84e01",
|
|||
|
|
"#ffa906",
|
|||
|
|
"#f95835",
|
|||
|
|
"#e079ca",
|
|||
|
|
"#8e60e4",
|
|||
|
|
"#10b2f3",
|
|||
|
|
"#57b4a8",
|
|||
|
|
"#50b7aa",
|
|||
|
|
"#94bd01",
|
|||
|
|
"#ebc615",
|
|||
|
|
"#a6a6a6"
|
|||
|
|
],
|
|||
|
|
bookingTypes: [
|
|||
|
|
{
|
|||
|
|
name: 'Временная бронь',
|
|||
|
|
type: 'temporary'
|
|||
|
|
},
|
|||
|
|
{
|
|||
|
|
name: 'Постоянная',
|
|||
|
|
type: 'constant'
|
|||
|
|
}
|
|||
|
|
],
|
|||
|
|
booking_time_type: 'hour',
|
|||
|
|
reminder_time_type: 'hour',
|
|||
|
|
bookingTimes: [
|
|||
|
|
{
|
|||
|
|
name: 'Час',
|
|||
|
|
type: 'hour'
|
|||
|
|
},
|
|||
|
|
{
|
|||
|
|
name: 'День',
|
|||
|
|
type: 'day'
|
|||
|
|
}
|
|||
|
|
],
|
|||
|
|
users: [],
|
|||
|
|
OpenIndicator: {
|
|||
|
|
render: createElement => createElement('span', { class: { 'vueToggleSpan': true } }),
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
methods: {
|
|||
|
|
handleSvgClick(e) {
|
|||
|
|
this.$refs.colorPicker.click()
|
|||
|
|
},
|
|||
|
|
getEmployeesAndManagers()
|
|||
|
|
{
|
|||
|
|
axios.post('/ajax/ajax_vue_complex_status.php', {
|
|||
|
|
request: 'get_employees_and_managers',
|
|||
|
|
},)
|
|||
|
|
.then((response) => {
|
|||
|
|
this.users = response.data;
|
|||
|
|
})
|
|||
|
|
.catch(function(error) {
|
|||
|
|
console.log(error);
|
|||
|
|
});
|
|||
|
|
},
|
|||
|
|
getDefaultComplexStatus()
|
|||
|
|
{
|
|||
|
|
axios.post('/ajax/ajax_vue_complex_status.php', {
|
|||
|
|
request: 'get_default_complex_status',
|
|||
|
|
},)
|
|||
|
|
.then((response) => {
|
|||
|
|
this.defaultComplexStatusList = response.data;
|
|||
|
|
})
|
|||
|
|
.catch(function(error) {
|
|||
|
|
console.log(error);
|
|||
|
|
});
|
|||
|
|
},
|
|||
|
|
|
|||
|
|
getComplexStatus()
|
|||
|
|
{
|
|||
|
|
axios.post('/ajax/ajax_vue_complex_status.php', {
|
|||
|
|
request: 'get_complex_status',
|
|||
|
|
},)
|
|||
|
|
.then((response) => {
|
|||
|
|
this.complexStatusList = response.data;
|
|||
|
|
})
|
|||
|
|
.catch(function(error) {
|
|||
|
|
console.log(error);
|
|||
|
|
});
|
|||
|
|
},
|
|||
|
|
|
|||
|
|
getArchiveComplexStatus()
|
|||
|
|
{
|
|||
|
|
axios.post('/ajax/ajax_vue_complex_status.php', {
|
|||
|
|
request: 'get_archive__complex_status',
|
|||
|
|
},)
|
|||
|
|
.then((response) => {
|
|||
|
|
this.complexStatusListArchive = response.data;
|
|||
|
|
})
|
|||
|
|
.catch(function(error) {
|
|||
|
|
console.log(error);
|
|||
|
|
});
|
|||
|
|
},
|
|||
|
|
|
|||
|
|
//Редактирование статус
|
|||
|
|
edit(index)
|
|||
|
|
{
|
|||
|
|
this.error_name = false;
|
|||
|
|
this.error_status = false;
|
|||
|
|
this.error_booking_type = false;
|
|||
|
|
this.error_booking_hour = false;
|
|||
|
|
this.error_booking_day = false;
|
|||
|
|
this.error_reminder_hour = false;
|
|||
|
|
this.error_reminder_day = false;
|
|||
|
|
this.error_managers_of_confirm_reservation_extension = false;
|
|||
|
|
this.error_managers_of_unconfirm_reservation_extension = false;
|
|||
|
|
this.errorText = '';
|
|||
|
|
this.errorMes = false;
|
|||
|
|
|
|||
|
|
this.isEditForm = true;
|
|||
|
|
this.lastStatusColor = null;
|
|||
|
|
this.pickerChanged = false;
|
|||
|
|
|
|||
|
|
if (index == -1) {
|
|||
|
|
this.complex_status_id = 0;
|
|||
|
|
this.status = {
|
|||
|
|
booking_type: null,
|
|||
|
|
booking_hour: null,
|
|||
|
|
booking_day: null,
|
|||
|
|
reminder_hour: null,
|
|||
|
|
reminder_day: null,
|
|||
|
|
reservation_extension: false,
|
|||
|
|
can_change_booking_queue: [],
|
|||
|
|
specify_comment_confirm: false,
|
|||
|
|
specify_comment_unconfirm: false,
|
|||
|
|
managers_of_confirm_reservation_extension: [],
|
|||
|
|
employees_not_required_confirmation: [],
|
|||
|
|
managers_of_unconfirm_reservation_extension: [],
|
|||
|
|
employees_not_required_unconfirmation: [],
|
|||
|
|
color: this.status_colors[0]
|
|||
|
|
};
|
|||
|
|
} else if (this.complexStatusList[index]) {
|
|||
|
|
this.complex_status_id = this.complexStatusList[index].id;
|
|||
|
|
this.status = JSON.parse(JSON.stringify(this.complexStatusList[index]))
|
|||
|
|
|
|||
|
|
this.status.can_change_booking_queue = this.status.can_change_booking_queue;
|
|||
|
|
|
|||
|
|
this.status.managers_of_confirm_reservation_extension = this.status.managers_of_confirm_reservation_extension;
|
|||
|
|
this.status.employees_not_required_confirmation = this.status.employees_not_required_confirmation;
|
|||
|
|
|
|||
|
|
this.status.managers_of_unconfirm_reservation_extension = this.status.managers_of_unconfirm_reservation_extension;
|
|||
|
|
this.status.employees_not_required_unconfirmation = this.status.employees_not_required_unconfirmation;
|
|||
|
|
|
|||
|
|
this.booking_time_type = this.status.booking_day > 0 ? 'day' : 'hour';
|
|||
|
|
this.reminder_time_type = this.status.reminder_day > 0 ? 'day' : 'hour';
|
|||
|
|
} else {
|
|||
|
|
alert("Что-то пошло не так!!! Обратитесь в техподдержку.");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (!this.status_colors.includes(this.status.color) && !this.lastStatusColor) {
|
|||
|
|
this.lastStatusColor = this.status.color
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
|
|||
|
|
//Помещение в архив
|
|||
|
|
async archive(index)
|
|||
|
|
{
|
|||
|
|
if (confirm('Вы действительно хотите архивировать этот статус?'))
|
|||
|
|
{
|
|||
|
|
var id = this.complexStatusList[index].id;
|
|||
|
|
|
|||
|
|
if (id > 0)
|
|||
|
|
{
|
|||
|
|
try {
|
|||
|
|
await axios.post('/ajax/ajax_vue_complex_status.php', {
|
|||
|
|
request: 'to_archive__complex_status',
|
|||
|
|
status_id: id
|
|||
|
|
})
|
|||
|
|
|
|||
|
|
this.getComplexStatus();
|
|||
|
|
this.getArchiveComplexStatus()
|
|||
|
|
} catch (error) {
|
|||
|
|
if (error && error.response.status == 422) {
|
|||
|
|
const { error: { rooms_count } } = error.response.data
|
|||
|
|
|
|||
|
|
this.roomToArchiveInfo = {
|
|||
|
|
rooms_count: rooms_count,
|
|||
|
|
status_id: id,
|
|||
|
|
new_status_id: null
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
console.log(this.roomToArchiveInfo);
|
|||
|
|
};
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
},
|
|||
|
|
|
|||
|
|
|
|||
|
|
async updateRoomStatus()
|
|||
|
|
{
|
|||
|
|
try {
|
|||
|
|
axios.post('/ajax/ajax_vue_complex_status.php', {
|
|||
|
|
request: 'update_rooms_status',
|
|||
|
|
status_id: this.roomToArchiveInfo.status_id,
|
|||
|
|
new_status_id: this.roomToArchiveInfo.new_status_id
|
|||
|
|
})
|
|||
|
|
|
|||
|
|
this.roomToArchiveInfo = {}
|
|||
|
|
|
|||
|
|
this.getComplexStatus();
|
|||
|
|
this.getArchiveComplexStatus()
|
|||
|
|
} catch (error) {
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
|
|||
|
|
//Восстановление из архива
|
|||
|
|
recover(index)
|
|||
|
|
{
|
|||
|
|
var id = this.complexStatusListArchive[index].id;
|
|||
|
|
|
|||
|
|
if (id > 0) {
|
|||
|
|
|
|||
|
|
axios.post('/ajax/ajax_vue_complex_status.php', {
|
|||
|
|
request: 'recover_is_archive__complex_status',
|
|||
|
|
status_id: id,
|
|||
|
|
}).then(() => {
|
|||
|
|
this.getComplexStatus();
|
|||
|
|
this.getArchiveComplexStatus()
|
|||
|
|
}).catch(function(error) {
|
|||
|
|
if (error) console.log(error);
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
|
|||
|
|
//Удаленине типа
|
|||
|
|
deleted(index)
|
|||
|
|
{
|
|||
|
|
if (confirm('Вы точно хотите безвозвратно удалить это статус?')) {
|
|||
|
|
var id = this.complexStatusListArchive[index].id;
|
|||
|
|
|
|||
|
|
//console.log(id);
|
|||
|
|
if (id > 0) {
|
|||
|
|
axios.post('/ajax/ajax_vue_complex_status.php', {
|
|||
|
|
request: 'delete_complex_status',
|
|||
|
|
status_id: id,
|
|||
|
|
}).then(() => {
|
|||
|
|
this.getArchiveComplexStatus()
|
|||
|
|
}).catch(function(error) {
|
|||
|
|
if (error) console.log(error);
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
|
|||
|
|
saveType()
|
|||
|
|
{
|
|||
|
|
this.error_name = false;
|
|||
|
|
this.error_status = false;
|
|||
|
|
this.error_booking_type = false;
|
|||
|
|
this.error_booking_hour = false;
|
|||
|
|
this.error_booking_day = false;
|
|||
|
|
this.error_reminder_hour = false,
|
|||
|
|
this.error_reminder_day = false,
|
|||
|
|
this.error_managers_of_confirm_reservation_extension = false;
|
|||
|
|
this.error_managers_of_unconfirm_reservation_extension = false;
|
|||
|
|
this.errorText = '';
|
|||
|
|
this.errorMes = false;
|
|||
|
|
|
|||
|
|
if (this.isEmpty(this.status.name)) {
|
|||
|
|
this.error_name = true;
|
|||
|
|
this.errorText = '<p>Введите название статуса</p>';
|
|||
|
|
this.errorMes = true;
|
|||
|
|
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
else if(this.isEmpty(this.status.status)) {
|
|||
|
|
this.error_status = true;
|
|||
|
|
this.errorText = '<p>Выберите тип статуса для наследования поведения</p>';
|
|||
|
|
this.errorMes = true;
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
else if(this.status.status == 'reservation' && this.isEmpty(this.status.booking_type)) {
|
|||
|
|
this.error_booking_type = true;
|
|||
|
|
this.errorText = '<p>Выберите тип бронирования</p>';
|
|||
|
|
this.errorMes = true;
|
|||
|
|
return;
|
|||
|
|
} else if (this.status.booking_type == 'temporary') {
|
|||
|
|
if (this.booking_time_type == 'day' && this.isEmpty(this.status.booking_day)) {
|
|||
|
|
this.error_booking_day = true;
|
|||
|
|
this.errorText = '<p>Введите срок временной брони</p>';
|
|||
|
|
this.errorMes = true;
|
|||
|
|
return;
|
|||
|
|
} else if (this.isEmpty(this.status.booking_hour) && this.isEmpty(this.status.booking_day)) {
|
|||
|
|
this.error_booking_hour = true;
|
|||
|
|
this.errorText = '<p>Неправильный срок истечении брони</p>';
|
|||
|
|
this.errorMes = true;
|
|||
|
|
return;
|
|||
|
|
} else if (this.booking_time_type == 'day' && this.reminder_time_type == 'day' && this.isEmpty(this.status.reminder_day)) {
|
|||
|
|
this.error_reminder_day = true;
|
|||
|
|
this.errorText = '<p>Введите срок уведомления об истечении брони</p>';
|
|||
|
|
this.errorMes = true;
|
|||
|
|
return;
|
|||
|
|
} else if (this.status.reminder_day > this.status.booking_day) {
|
|||
|
|
this.error_reminder_day = true;
|
|||
|
|
this.errorText = '<p>Неправильный срок уведомления</p>';
|
|||
|
|
this.errorMes = true;
|
|||
|
|
return;
|
|||
|
|
} else if ((this.status.reminder_hour >= this.status.booking_hour) && this.status.reminder_day == this.status.booking_day) {
|
|||
|
|
this.error_reminder_hour = true;
|
|||
|
|
this.errorText = '<p>Неправильный срок уведомления</p>';
|
|||
|
|
this.errorMes = true;
|
|||
|
|
return;
|
|||
|
|
} else if (this.reminder_time_type == 'hour' && this.isEmpty(this.status.reminder_hour)) {
|
|||
|
|
this.error_reminder_hour = true;
|
|||
|
|
this.errorText = '<p>Неправильный срок уведомления</p>';
|
|||
|
|
this.errorMes = true;
|
|||
|
|
return;
|
|||
|
|
} else if (this.status.reservation_extension == true) {
|
|||
|
|
if (this.isEmpty(this.status.managers_of_confirm_reservation_extension)) {
|
|||
|
|
this.error_managers_of_confirm_reservation_extension = true;
|
|||
|
|
this.errorText = '<p>Введите кто может утвердить продление бронирования</p>';
|
|||
|
|
this.errorMes = true;
|
|||
|
|
return;
|
|||
|
|
} else if (this.isEmpty(this.status.managers_of_unconfirm_reservation_extension)) {
|
|||
|
|
this.error_managers_of_unconfirm_reservation_extension = true;
|
|||
|
|
this.errorText = '<p>Введите кто может подтверждает отмену продление бронирования</p>';
|
|||
|
|
this.errorMes = true;
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
axios.post('/ajax/ajax_vue_complex_status.php', {
|
|||
|
|
request: 'edit_add_status',
|
|||
|
|
status: this.status,
|
|||
|
|
booking_type: this.booking_type,
|
|||
|
|
}).then(() => {
|
|||
|
|
this.getComplexStatus();
|
|||
|
|
}).catch(function(error) {
|
|||
|
|
if (error) console.log(error);
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
this.isEditForm = false;
|
|||
|
|
},
|
|||
|
|
|
|||
|
|
isEmpty(data)
|
|||
|
|
{
|
|||
|
|
if (typeof(data) === 'object')
|
|||
|
|
{
|
|||
|
|
if (JSON.stringify(data) === '{}' || JSON.stringify(data) === '[]') {
|
|||
|
|
return true;
|
|||
|
|
} else if (!data) {
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
else if (typeof(data) === 'string')
|
|||
|
|
{
|
|||
|
|
if (!data.trim()) {
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
else if (typeof(data) === 'undefined')
|
|||
|
|
{
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
else if (typeof(data) === 'number' && data <= 0)
|
|||
|
|
{
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
|
|||
|
|
changeStatusColor(color)
|
|||
|
|
{
|
|||
|
|
this.status.color = color;
|
|||
|
|
this.pickerChanged = false;
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
watch: {
|
|||
|
|
'booking_time_type': function ()
|
|||
|
|
{
|
|||
|
|
if (this.booking_time_type == 'hour')
|
|||
|
|
{
|
|||
|
|
this.reminder_time_type = 'hour';
|
|||
|
|
this.status.booking_day = null;
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
'reminder_time_type': function ()
|
|||
|
|
{
|
|||
|
|
if (this.booking_time_type == 'hour')
|
|||
|
|
{
|
|||
|
|
this.reminder_time_type = 'hour';
|
|||
|
|
this.status.reminder_day = null;
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
'status.status': function (val) {
|
|||
|
|
if (val && val != 'reservation') {
|
|||
|
|
this.status.booking_type = null;
|
|||
|
|
this.status.booking_hour = null;
|
|||
|
|
this.status.booking_day = null;
|
|||
|
|
this.status.reminder_hour = null;
|
|||
|
|
this.status.reminder_day = null;
|
|||
|
|
|
|||
|
|
this.booking_time_type = 'hour';
|
|||
|
|
this.reminder_time_type = 'hour';
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
'status.booking_type': function (val) {
|
|||
|
|
if (val && val != 'temporary') {
|
|||
|
|
this.status.booking_hour = null;
|
|||
|
|
this.status.booking_day = null;
|
|||
|
|
this.status.reminder_hour = null;
|
|||
|
|
this.status.reminder_day = null;
|
|||
|
|
|
|||
|
|
this.booking_time_type = 'hour';
|
|||
|
|
this.reminder_time_type = 'hour';
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
'status.booking_hour': function(val) {
|
|||
|
|
if (this.error_booking_hour == true)
|
|||
|
|
{
|
|||
|
|
this.error_booking_hour = false;
|
|||
|
|
this.errorText = null;
|
|||
|
|
this.errorMes = null;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (val == 0) {
|
|||
|
|
this.status.booking_hour = null;
|
|||
|
|
}
|
|||
|
|
if (val < 0) {
|
|||
|
|
this.status.booking_hour = null;
|
|||
|
|
}
|
|||
|
|
if (val > 24) {
|
|||
|
|
this.status.booking_hour = 24
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
'status.booking_day': function(val) {
|
|||
|
|
if (this.error_booking_day == true)
|
|||
|
|
{
|
|||
|
|
this.error_booking_day = false;
|
|||
|
|
this.errorText = null;
|
|||
|
|
this.errorMes = null;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (val == 0) {
|
|||
|
|
this.status.booking_day = null
|
|||
|
|
}
|
|||
|
|
if (val < 0) {
|
|||
|
|
this.status.booking_day = null;
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
'status.reminder_hour': function(val) {
|
|||
|
|
if (this.error_reminder_hour == true)
|
|||
|
|
{
|
|||
|
|
this.error_reminder_hour = false;
|
|||
|
|
this.errorText = null;
|
|||
|
|
this.errorMes = null;
|
|||
|
|
}
|
|||
|
|
if (val == 0) {
|
|||
|
|
this.status.reminder_hour = null
|
|||
|
|
}
|
|||
|
|
if (val < 0) {
|
|||
|
|
this.status.reminder_hour = null
|
|||
|
|
}
|
|||
|
|
if (val > 24) {
|
|||
|
|
this.status.reminder_hour = 24
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
'status.reminder_day': function(val) {
|
|||
|
|
if (this.error_reminder_day == true)
|
|||
|
|
{
|
|||
|
|
this.error_reminder_day = false;
|
|||
|
|
this.errorText = null;
|
|||
|
|
this.errorMes = null;
|
|||
|
|
}
|
|||
|
|
if (val == 0) {
|
|||
|
|
this.status.reminder_day = null
|
|||
|
|
}
|
|||
|
|
if (val < 0) {
|
|||
|
|
this.status.reminder_day = null;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
created: function() {
|
|||
|
|
$('#complex_status .full_modal-bg').removeClass('hidden');
|
|||
|
|
$('#complex_status .full_modal').removeClass('hidden');
|
|||
|
|
this.getComplexStatus();
|
|||
|
|
this.getDefaultComplexStatus();
|
|||
|
|
this.getArchiveComplexStatus();
|
|||
|
|
this.getEmployeesAndManagers();
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if ($('#installments').length > 0) {
|
|||
|
|
var installments = new Vue({
|
|||
|
|
el: '#installments',
|
|||
|
|
components: {},
|
|||
|
|
data() {
|
|||
|
|
return {
|
|||
|
|
installmentsList: [{
|
|||
|
|
id: null,
|
|||
|
|
name: null,
|
|||
|
|
}],
|
|||
|
|
installment_id: null,
|
|||
|
|
isEditForm: false,
|
|||
|
|
roomToArchiveInfo: {
|
|||
|
|
rooms_count: null,
|
|||
|
|
installment_id: null,
|
|||
|
|
new_installment_id: null
|
|||
|
|
},
|
|||
|
|
installment: {
|
|||
|
|
name: null,
|
|||
|
|
description: null,
|
|||
|
|
initial_payment: null,
|
|||
|
|
payment_period: null,
|
|||
|
|
interest_rate: null,
|
|||
|
|
type: null,
|
|||
|
|
allow_change_on_close: false,
|
|||
|
|
comment: null,
|
|||
|
|
},
|
|||
|
|
installmentsListArchive: [],
|
|||
|
|
payment_period_list: [
|
|||
|
|
{ payment_period: 'monthly', name: 'Ежемесячно' },
|
|||
|
|
{ payment_period: 'quarterly', name: 'Ежеквартально' },
|
|||
|
|
{ payment_period: 'yearly', name: 'Годовой' }
|
|||
|
|
],
|
|||
|
|
installment_type_list: [
|
|||
|
|
{ type: 'interest-free', name: 'Беспроцентная' },
|
|||
|
|
{ type: 'with-interest', name: 'С процентами' }
|
|||
|
|
],
|
|||
|
|
// Переменные для ошибок
|
|||
|
|
error_name: false,
|
|||
|
|
error_description: false,
|
|||
|
|
error_initial_payment: false,
|
|||
|
|
error_payment_period: false,
|
|||
|
|
error_interest_rate: false,
|
|||
|
|
error_comment: false,
|
|||
|
|
error_type: false,
|
|||
|
|
errorText: '',
|
|||
|
|
errorMes: false,
|
|||
|
|
OpenIndicator: {
|
|||
|
|
render: createElement => createElement('span', { class: { 'vueToggleSpan': true } }),
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
methods: {
|
|||
|
|
isEmpty(data)
|
|||
|
|
{
|
|||
|
|
if (typeof(data) === 'object')
|
|||
|
|
{
|
|||
|
|
if (JSON.stringify(data) === '{}' || JSON.stringify(data) === '[]') {
|
|||
|
|
return true;
|
|||
|
|
} else if (!data) {
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
else if (typeof(data) === 'string')
|
|||
|
|
{
|
|||
|
|
if (!data.trim()) {
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
else if (typeof(data) === 'undefined')
|
|||
|
|
{
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
else if (typeof(data) === 'number' && data <= 0)
|
|||
|
|
{
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
|
|||
|
|
getInstallments() {
|
|||
|
|
axios.post('/ajax/ajax_vue_installments.php', { request: 'get_installments' })
|
|||
|
|
.then((response) => {
|
|||
|
|
this.installmentsList = response.data;
|
|||
|
|
})
|
|||
|
|
.catch(error => console.log(error));
|
|||
|
|
},
|
|||
|
|
|
|||
|
|
getArchiveInstallments() {
|
|||
|
|
axios.post('/ajax/ajax_vue_installments.php', { request: 'get_archive_installments' })
|
|||
|
|
.then((response) => {
|
|||
|
|
this.installmentsListArchive = response.data;
|
|||
|
|
})
|
|||
|
|
.catch(error => console.log(error));
|
|||
|
|
},
|
|||
|
|
|
|||
|
|
// Метод проверки перед сохранением
|
|||
|
|
validateForm() {
|
|||
|
|
this.error_name = !this.installment.name;
|
|||
|
|
this.error_type = !this.installment.type;
|
|||
|
|
this.error_initial_payment = !this.installment.initial_payment || this.installment.initial_payment < 0 || this.installment.initial_payment > 100;
|
|||
|
|
this.error_payment_period = !this.installment.payment_period;
|
|||
|
|
this.error_interest_rate = (this.installment.type === 'with-interest' && (!this.installment.interest_rate || this.installment.interest_rate < 0 || this.installment.interest_rate > 100));
|
|||
|
|
|
|||
|
|
this.errorText = '';
|
|||
|
|
|
|||
|
|
if (this.error_name) this.errorText += '<p>Введите название рассрочки.</p>';
|
|||
|
|
if (this.error_type) this.errorText += '<p>Выберите тип рассрочки.</p>';
|
|||
|
|
if (this.error_initial_payment) this.errorText += '<p>Первоначальный взнос должен быть от 0 до 100%.</p>';
|
|||
|
|
if (this.error_payment_period) this.errorText += '<p>Выберите периодичность платежей.</p>';
|
|||
|
|
if (this.error_interest_rate) this.errorText += '<p>Процентная ставка должна быть от 0 до 100%.</p>';
|
|||
|
|
|
|||
|
|
return !this.error_name && !this.error_description && !this.error_type &&
|
|||
|
|
!this.error_initial_payment && !this.error_payment_period && !this.error_interest_rate;
|
|||
|
|
},
|
|||
|
|
|
|||
|
|
saveType() {
|
|||
|
|
this.errorText = '';
|
|||
|
|
this.errorMes = false;
|
|||
|
|
|
|||
|
|
if (!this.validateForm()) {
|
|||
|
|
this.errorMes = true;
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
axios.post('/ajax/ajax_vue_installments.php', {
|
|||
|
|
request: 'add_edit_installment',
|
|||
|
|
installment: this.installment,
|
|||
|
|
}).then(() => {
|
|||
|
|
this.getInstallments();
|
|||
|
|
this.isEditForm = false;
|
|||
|
|
}).catch(error => console.log(error));
|
|||
|
|
},
|
|||
|
|
|
|||
|
|
edit(index) {
|
|||
|
|
this.error_name = false;
|
|||
|
|
this.errorText = '';
|
|||
|
|
this.errorMes = false;
|
|||
|
|
|
|||
|
|
this.isEditForm = true;
|
|||
|
|
|
|||
|
|
if (index == -1) {
|
|||
|
|
this.installment_id = 0;
|
|||
|
|
this.installment = {
|
|||
|
|
name: null,
|
|||
|
|
description: null,
|
|||
|
|
initial_payment: null,
|
|||
|
|
payment_period: null,
|
|||
|
|
interest_rate: null,
|
|||
|
|
type: null,
|
|||
|
|
allow_change_on_close: false,
|
|||
|
|
comment: null,
|
|||
|
|
};
|
|||
|
|
} else if (this.installmentsList[index]) {
|
|||
|
|
this.installment_id = this.installmentsList[index].id;
|
|||
|
|
this.installment = JSON.parse(JSON.stringify(this.installmentsList[index]))
|
|||
|
|
} else {
|
|||
|
|
alert("Что-то пошло не так!!! Обратитесь в техподдержку.");
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
|
|||
|
|
// Archive an installment
|
|||
|
|
async archive(index) {
|
|||
|
|
if (confirm('Вы действительно хотите архивировать эту рассрочку?')) {
|
|||
|
|
let id = this.installmentsList[index].id;
|
|||
|
|
|
|||
|
|
if (id > 0) {
|
|||
|
|
try {
|
|||
|
|
await axios.post('/ajax/ajax_vue_installments.php', {
|
|||
|
|
request: 'to_archive_installment',
|
|||
|
|
installment_id: id
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
this.getInstallments();
|
|||
|
|
this.getArchiveInstallments();
|
|||
|
|
} catch (error) {
|
|||
|
|
if (error && error.response && error.response.status == 422) {
|
|||
|
|
console.error('Ошибка архивирования рассрочки:', error.response);
|
|||
|
|
} else {
|
|||
|
|
console.error('Произошла ошибка:', error);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
|
|||
|
|
// Восстановление из архива
|
|||
|
|
recover(index)
|
|||
|
|
{
|
|||
|
|
let id = this.installmentsListArchive[index].id;
|
|||
|
|
|
|||
|
|
if (id > 0) {
|
|||
|
|
|
|||
|
|
axios.post('/ajax/ajax_vue_installments.php', {
|
|||
|
|
request: 'recover_is_archive_installment',
|
|||
|
|
installment_id: id
|
|||
|
|
}).then(() => {
|
|||
|
|
this.getInstallments();
|
|||
|
|
this.getArchiveInstallments();
|
|||
|
|
}).catch(function(error) {
|
|||
|
|
if (error) console.log(error);
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
|
|||
|
|
deleteInstallment(index) {
|
|||
|
|
console.log('index: ', index)
|
|||
|
|
if (confirm('Вы точно хотите безвозвратно удалить эту рассрочку?')) {
|
|||
|
|
let id = this.installmentsListArchive[index].id;
|
|||
|
|
|
|||
|
|
if (id > 0) {
|
|||
|
|
axios.post('/ajax/ajax_vue_installments.php', {
|
|||
|
|
request: 'delete_installment',
|
|||
|
|
installment_id: id
|
|||
|
|
})
|
|||
|
|
.then(() => {
|
|||
|
|
this.getArchiveInstallments();
|
|||
|
|
})
|
|||
|
|
.catch(error => {
|
|||
|
|
console.error('Ошибка при удалении рассрочки:', error);
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
|
|||
|
|
},
|
|||
|
|
created() {
|
|||
|
|
$('#installments .full_modal-bg').removeClass('hidden');
|
|||
|
|
$('#installments .full_modal').removeClass('hidden');
|
|||
|
|
this.getInstallments();
|
|||
|
|
this.getArchiveInstallments();
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if ($('#unisenderApiKey').length > 0) {
|
|||
|
|
|
|||
|
|
var unisenderApiKey = new Vue({
|
|||
|
|
el: '#unisenderApiKey',
|
|||
|
|
components: {},
|
|||
|
|
data() {
|
|||
|
|
return {
|
|||
|
|
agency_id: $('#session_agency_id').val() || null,
|
|||
|
|
apiKey: null,
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
methods: {
|
|||
|
|
getKey() {
|
|||
|
|
axios.post('/ajax/ajax_vue_unisender.php', {
|
|||
|
|
request: 'get_key',
|
|||
|
|
agency_id: this.agency_id,
|
|||
|
|
|
|||
|
|
}, )
|
|||
|
|
.then((response) => {
|
|||
|
|
console.log(response.data);
|
|||
|
|
this.apiKey = response.data;
|
|||
|
|
|
|||
|
|
})
|
|||
|
|
.catch(function(error) {
|
|||
|
|
console.log(error);
|
|||
|
|
});
|
|||
|
|
},
|
|||
|
|
|
|||
|
|
|
|||
|
|
//Сохраненние
|
|||
|
|
saveKey() {
|
|||
|
|
|
|||
|
|
axios.post('/ajax/ajax_vue_unisender.php', {
|
|||
|
|
request: 'save_key',
|
|||
|
|
agency_id: this.agency_id,
|
|||
|
|
api_key: this.apiKey,
|
|||
|
|
|
|||
|
|
|
|||
|
|
}).then((response) => {
|
|||
|
|
console.log(response.data);
|
|||
|
|
if (response.data === true) {
|
|||
|
|
alert("Успешно сохранено!");
|
|||
|
|
|
|||
|
|
} else {
|
|||
|
|
alert("Код сохранен, но подключение не удалось!!!");
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}).catch(function(error) {
|
|||
|
|
if (error)
|
|||
|
|
console.log(error);
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
// this.isEditForm = false;
|
|||
|
|
|
|||
|
|
},
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
isEmpty(data) {
|
|||
|
|
if (typeof(data) === 'object') {
|
|||
|
|
if (JSON.stringify(data) === '{}' || JSON.stringify(data) === '[]') {
|
|||
|
|
return true;
|
|||
|
|
} else if (!data) {
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
return false;
|
|||
|
|
} else if (typeof(data) === 'string') {
|
|||
|
|
if (!data.trim()) {
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
return false;
|
|||
|
|
} else if (typeof(data) === 'undefined') {
|
|||
|
|
return true;
|
|||
|
|
} else {
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
},
|
|||
|
|
computed: {
|
|||
|
|
|
|||
|
|
},
|
|||
|
|
created: function() {
|
|||
|
|
this.getKey();
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if ($('#wazzapApiKey').length > 0) {
|
|||
|
|
|
|||
|
|
var wazzapApiKey = new Vue({
|
|||
|
|
el: '#wazzapApiKey',
|
|||
|
|
components: {},
|
|||
|
|
data() {
|
|||
|
|
return {
|
|||
|
|
agency_id: $('#session_agency_id').val() || null,
|
|||
|
|
apiKeyWazzap: null,
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
methods: {
|
|||
|
|
getWazzapKey() {
|
|||
|
|
axios.post('/ajax/ajax_vue_wazzap.php', {
|
|||
|
|
request: 'get_key',
|
|||
|
|
agency_id: this.agency_id,
|
|||
|
|
|
|||
|
|
}, )
|
|||
|
|
.then((response) => {
|
|||
|
|
console.log(response.data);
|
|||
|
|
this.apiKeyWazzap = response.data;
|
|||
|
|
|
|||
|
|
})
|
|||
|
|
.catch(function(error) {
|
|||
|
|
console.log(error);
|
|||
|
|
});
|
|||
|
|
},
|
|||
|
|
|
|||
|
|
addDirectorToWazzap() {
|
|||
|
|
axios.post('/ajax/ajax_vue_wazzap.php', {
|
|||
|
|
request: 'add_director',
|
|||
|
|
agency_id: this.agency_id
|
|||
|
|
}).then((response) => {
|
|||
|
|
console.log(response.data);
|
|||
|
|
if (response.data === 'done') {
|
|||
|
|
$('#directorAddToWazzapButton').hide();
|
|||
|
|
$('#directorAddedToWazzapLabel').show();
|
|||
|
|
alert("Пользователь добавлен!");
|
|||
|
|
} else {
|
|||
|
|
alert(response.data);
|
|||
|
|
}
|
|||
|
|
}).catch(function(error) {
|
|||
|
|
if (error)
|
|||
|
|
console.log(error);
|
|||
|
|
});
|
|||
|
|
},
|
|||
|
|
|
|||
|
|
//Сохраненние
|
|||
|
|
saveWazzapKey() {
|
|||
|
|
axios.post('/ajax/ajax_vue_wazzap.php', {
|
|||
|
|
request: 'save_key',
|
|||
|
|
agency_id: this.agency_id,
|
|||
|
|
api_key: this.apiKeyWazzap,
|
|||
|
|
|
|||
|
|
|
|||
|
|
}).then((response) => {
|
|||
|
|
console.log(response.data);
|
|||
|
|
if (response.data === true) {
|
|||
|
|
alert("Успешно сохранено!");
|
|||
|
|
}
|
|||
|
|
}).catch(function(error) {
|
|||
|
|
if (error)
|
|||
|
|
console.log(error);
|
|||
|
|
});
|
|||
|
|
},
|
|||
|
|
|
|||
|
|
isEmpty(data) {
|
|||
|
|
if (typeof(data) === 'object') {
|
|||
|
|
if (JSON.stringify(data) === '{}' || JSON.stringify(data) === '[]') {
|
|||
|
|
return true;
|
|||
|
|
} else if (!data) {
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
return false;
|
|||
|
|
} else if (typeof(data) === 'string') {
|
|||
|
|
if (!data.trim()) {
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
return false;
|
|||
|
|
} else if (typeof(data) === 'undefined') {
|
|||
|
|
return true;
|
|||
|
|
} else {
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
},
|
|||
|
|
computed: {
|
|||
|
|
|
|||
|
|
},
|
|||
|
|
created: function() {
|
|||
|
|
this.getWazzapKey();
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
function confirmDeleteObjectField(field_id) {
|
|||
|
|
object_fields.confirmDeleteObjectField(field_id);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
function showEditObjectFieldForm(field_id) {
|
|||
|
|
object_field_form.showEditObjectFieldForm(field_id);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
function closeEditObjectFieldForm() {
|
|||
|
|
object_field_form.closeEditObjectFieldForm();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
function showAdvertApiForm(api_id) {
|
|||
|
|
advert_api_form.showAdvertApiForm(api_id);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
function closeAdvertApiForm() {
|
|||
|
|
advert_api_form.closeAdvertApiForm();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
function showEditFieldBlocksForm(block_id) {
|
|||
|
|
object_field_block_form.showEditFieldBlocksForm(block_id);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
function closeEditFieldBlockForm() {
|
|||
|
|
object_field_block_form.closeEditFieldBlockForm();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if ($('#advertPricesForm').length > 0) {
|
|||
|
|
var advert_prices_form = new Vue({
|
|||
|
|
el: '#advertPricesForm',
|
|||
|
|
components: {},
|
|||
|
|
data() {
|
|||
|
|
return {
|
|||
|
|
id: null,
|
|||
|
|
agency_id: $('#session_agency_id').val() || null,
|
|||
|
|
region_id: null,
|
|||
|
|
region_id_child: null,
|
|||
|
|
operation_type_id: null,
|
|||
|
|
type_id: null,
|
|||
|
|
rent_type_id: null,
|
|||
|
|
commerce_type_id: null,
|
|||
|
|
error_message: '',
|
|||
|
|
avito: 0,
|
|||
|
|
cian: 0,
|
|||
|
|
domclick: 0,
|
|||
|
|
jcat: 0,
|
|||
|
|
yandex: 0,
|
|||
|
|
childRegions: [],
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
methods: {
|
|||
|
|
getChildRegions: function() {
|
|||
|
|
let ref = this;
|
|||
|
|
if (this.region_id > 0) {
|
|||
|
|
axios.post('/ajax/ajax_vue_settings.php', {
|
|||
|
|
request: 'get_region_child',
|
|||
|
|
region_id: this.region_id
|
|||
|
|
})
|
|||
|
|
.then(function (response) {
|
|||
|
|
//console.log(response.data);
|
|||
|
|
$("#advert_budget_region_child_block").html(response.data.html);
|
|||
|
|
$("#advertBudgetRegionChild").val(ref.region_id_child);
|
|||
|
|
$("#advertBudgetRegionChild").fastselect({
|
|||
|
|
placeholder: 'Выберите город/область',
|
|||
|
|
onItemSelect: function (item, data) {
|
|||
|
|
ref.region_id_child = data.value;
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
})
|
|||
|
|
.catch(function (error) {
|
|||
|
|
console.log(error);
|
|||
|
|
});
|
|||
|
|
} else {
|
|||
|
|
$("#advert_budget_region_child_block").html('<select name="advert_budget_region_child" id="advertBudgetRegionChild"><option value="0">Не выбрано</option></select>');
|
|||
|
|
$("#advertBudgetRegionChild").fastselect({
|
|||
|
|
placeholder: 'Выберите город/область',
|
|||
|
|
onItemSelect: function (item, data) {
|
|||
|
|
ref.region_id_child = data.value;
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
isEmpty(data) {
|
|||
|
|
if (typeof(data) === 'object') {
|
|||
|
|
if (JSON.stringify(data) === '{}' || JSON.stringify(data) === '[]') {
|
|||
|
|
return true;
|
|||
|
|
} else if (!data) {
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
return false;
|
|||
|
|
} else if (typeof(data) === 'string') {
|
|||
|
|
if (!data.trim()) {
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
return false;
|
|||
|
|
} else if (typeof(data) === 'undefined') {
|
|||
|
|
return true;
|
|||
|
|
} else {
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
deleteAdvertPrice(item_id) {
|
|||
|
|
let ref = this;
|
|||
|
|
if (confirm('Вы действительно желаете удалить данные настройки затрат?')) {
|
|||
|
|
if (!ref.isEmpty(ref.agency_id) && typeof item_id !== "undefined") {
|
|||
|
|
axios.post('/ajax/ajax_vue_settings.php', {
|
|||
|
|
request: 'del_advert_limits',
|
|||
|
|
id: item_id,
|
|||
|
|
agency_id: ref.agency_id
|
|||
|
|
}).then((response) => {
|
|||
|
|
|
|||
|
|
if (response.data.success)
|
|||
|
|
advert_prices_list.getAdvertPricesList();
|
|||
|
|
|
|||
|
|
}).catch(function(error) {
|
|||
|
|
if (error)
|
|||
|
|
console.log(error);
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
initFastSelect() {
|
|||
|
|
|
|||
|
|
let ref = this;
|
|||
|
|
|
|||
|
|
$('#advertBudgetRegion').fastselect().data('fastselect').destroy();
|
|||
|
|
$("#advertBudgetRegion").val(ref.region_id);
|
|||
|
|
$("#advertBudgetRegion").fastselect({
|
|||
|
|
placeholder: 'Выберите регион',
|
|||
|
|
onItemSelect: function(item, data) {
|
|||
|
|
ref.region_id = data.value;
|
|||
|
|
ref.getChildRegions();
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
$('#advertBudgetRegionChild').fastselect().data('fastselect').destroy();
|
|||
|
|
$("#advertBudgetRegionChild").val(ref.region_id_child);
|
|||
|
|
$("#advertBudgetRegionChild").fastselect({
|
|||
|
|
placeholder: 'Выберите город/область',
|
|||
|
|
onItemSelect: function(item, data) {
|
|||
|
|
ref.region_id_child = data.value;
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
$('#advertBudgetDealType').fastselect().data('fastselect').destroy();
|
|||
|
|
$("#advertBudgetDealType").val(ref.operation_type_id);
|
|||
|
|
$("#advertBudgetDealType").fastselect({
|
|||
|
|
placeholder: 'Выберите тип сделки',
|
|||
|
|
onItemSelect: function(item, data) {
|
|||
|
|
ref.operation_type_id = data.value;
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
$('#advertBudgetRentType').fastselect().data('fastselect').destroy();
|
|||
|
|
$("#advertBudgetRentType").val(ref.rent_type_id);
|
|||
|
|
$("#advertBudgetRentType").fastselect({
|
|||
|
|
placeholder: 'Выберите тип сделки',
|
|||
|
|
onItemSelect: function(item, data) {
|
|||
|
|
ref.rent_type_id = data.value;
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
$('#advertBudgetObjectType').fastselect().data('fastselect').destroy();
|
|||
|
|
$("#advertBudgetObjectType").val(ref.type_id);
|
|||
|
|
$("#advertBudgetObjectType").fastselect({
|
|||
|
|
placeholder: 'Выберите тип объекта',
|
|||
|
|
onItemSelect: function(item, data) {
|
|||
|
|
ref.type_id = data.value;
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
$('#advertBudgetCommerceType').fastselect().data('fastselect').destroy();
|
|||
|
|
$("#advertBudgetCommerceType").val(ref.commerce_type_id);
|
|||
|
|
$("#advertBudgetCommerceType").fastselect({
|
|||
|
|
placeholder: 'Выберите тип коммерции',
|
|||
|
|
onItemSelect: function(item, data) {
|
|||
|
|
ref.commerce_type_id = data.value;
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
this.getChildRegions();
|
|||
|
|
},
|
|||
|
|
getAdvertPricesForm(item_id) {
|
|||
|
|
|
|||
|
|
let ref = this;
|
|||
|
|
if (!ref.isEmpty(ref.agency_id)) {
|
|||
|
|
axios.post('/ajax/ajax_vue_settings.php', {
|
|||
|
|
request: 'get_advert_prices',
|
|||
|
|
id: (typeof item_id !== "undefined") ? item_id : null,
|
|||
|
|
agency_id: ref.agency_id
|
|||
|
|
}).then(function(response) {
|
|||
|
|
ref.id = response.data.id;
|
|||
|
|
ref.region_id = response.data.region_id;
|
|||
|
|
ref.region_id_child = response.data.region_id_child;
|
|||
|
|
ref.operation_type_id = response.data.operation_type_id;
|
|||
|
|
ref.type_id = response.data.type_id;
|
|||
|
|
ref.rent_type_id = response.data.rent_type_id;
|
|||
|
|
ref.commerce_type_id = response.data.commerce_type_id;
|
|||
|
|
ref.error_message = response.data.error_message;
|
|||
|
|
ref.avito = response.data.avito;
|
|||
|
|
ref.cian = response.data.cian;
|
|||
|
|
ref.domclick = response.data.domclick;
|
|||
|
|
ref.jcat = response.data.jcat;
|
|||
|
|
ref.yandex = response.data.yandex;
|
|||
|
|
|
|||
|
|
ref.initFastSelect();
|
|||
|
|
console.info(response.data);
|
|||
|
|
|
|||
|
|
$('#advertPricesFormBg').fadeIn(100);
|
|||
|
|
$('#advertPricesForm').toggle(50);
|
|||
|
|
$("body").addClass("lock");
|
|||
|
|
|
|||
|
|
}).catch(function(error) {
|
|||
|
|
if (error)
|
|||
|
|
console.debug(error);
|
|||
|
|
});
|
|||
|
|
} else {
|
|||
|
|
$('#advertPricesFormBg').fadeIn(100);
|
|||
|
|
$('#advertPricesForm').toggle(50);
|
|||
|
|
$("body").addClass("lock");
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
getPriceStyle(number) {
|
|||
|
|
return number + 1 % 2 > 0 ? 'background-color: #f9f9f9;' : ''
|
|||
|
|
},
|
|||
|
|
hideAdvertPricesForm() {
|
|||
|
|
$('#advertPricesFormBg').fadeOut(300);
|
|||
|
|
$('#advertPricesForm').toggle(100);
|
|||
|
|
$("body").removeClass("lock");
|
|||
|
|
},
|
|||
|
|
validateForm() {
|
|||
|
|
|
|||
|
|
let errors = [];
|
|||
|
|
if (this.isEmpty(this.region_id))
|
|||
|
|
errors.push('Поле `Регион` обязательно к заполнению.');
|
|||
|
|
|
|||
|
|
if (this.isEmpty(this.operation_type_id))
|
|||
|
|
errors.push('Поле `Тип сделки` обязательно к заполнению.');
|
|||
|
|
|
|||
|
|
if (this.operation_type_id == 2 && this.isEmpty(this.rent_type_id))
|
|||
|
|
errors.push('Поле `Срок аренды` обязательно к заполнению.');
|
|||
|
|
|
|||
|
|
if (this.isEmpty(this.type_id))
|
|||
|
|
errors.push('Поле `Тип объекта` обязательно к заполнению.');
|
|||
|
|
|
|||
|
|
if (this.type_id == 4 && this.isEmpty(this.commerce_type_id))
|
|||
|
|
errors.push('Поле `Тип коммерции` обязательно к заполнению.');
|
|||
|
|
|
|||
|
|
if (!this.isEmpty(errors)) {
|
|||
|
|
this.error_message = errors.join('<br/>');
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return true;
|
|||
|
|
},
|
|||
|
|
saveAdvertPricesForm() {
|
|||
|
|
let ref = this;
|
|||
|
|
if (this.validateForm() && !ref.isEmpty(ref.agency_id)) {
|
|||
|
|
axios.post('/ajax/ajax_vue_settings.php', {
|
|||
|
|
request: 'set_advert_prices',
|
|||
|
|
id: ref.id,
|
|||
|
|
agency_id: ref.agency_id,
|
|||
|
|
region: ref.region_id,
|
|||
|
|
region_child: ref.region_id_child,
|
|||
|
|
deal_type: ref.operation_type_id,
|
|||
|
|
rent_type: ref.rent_type_id,
|
|||
|
|
object_type: ref.type_id,
|
|||
|
|
commerce_type: ref.commerce_type_id,
|
|||
|
|
avito: ref.avito,
|
|||
|
|
cian: ref.cian,
|
|||
|
|
domclick: ref.domclick,
|
|||
|
|
jcat: ref.jcat,
|
|||
|
|
yandex: ref.yandex,
|
|||
|
|
}).then(function(response) {
|
|||
|
|
|
|||
|
|
console.info(response);
|
|||
|
|
|
|||
|
|
if (response.data.success) {
|
|||
|
|
ref.hideAdvertPricesForm();
|
|||
|
|
advert_prices_list.getAdvertPricesList();
|
|||
|
|
} else if (!this.isEmpty(response.data.errors)) {
|
|||
|
|
ref.error_message = response.data.errors;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}).catch(function(error) {
|
|||
|
|
if (error)
|
|||
|
|
console.debug(error);
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
},
|
|||
|
|
created: function() {
|
|||
|
|
|
|||
|
|
},
|
|||
|
|
watch: {
|
|||
|
|
'region_id': function(val, oldVal) {
|
|||
|
|
console.info(val);
|
|||
|
|
},
|
|||
|
|
'region_id_child': function(val, oldVal) {
|
|||
|
|
console.info(val);
|
|||
|
|
},
|
|||
|
|
'operation_type_id': function(val, oldVal) {
|
|||
|
|
console.info(val);
|
|||
|
|
},
|
|||
|
|
'type_id': function(val, oldVal) {
|
|||
|
|
console.info(val);
|
|||
|
|
},
|
|||
|
|
'rent_type_id': function(val, oldVal) {
|
|||
|
|
console.info(val);
|
|||
|
|
},
|
|||
|
|
'commerce_type_id': function(val, oldVal) {
|
|||
|
|
console.info(val);
|
|||
|
|
},
|
|||
|
|
'avito': function(val, oldVal) {
|
|||
|
|
console.info(val);
|
|||
|
|
},
|
|||
|
|
'cian': function(val, oldVal) {
|
|||
|
|
console.info(val);
|
|||
|
|
},
|
|||
|
|
'domclick': function(val, oldVal) {
|
|||
|
|
console.info(val);
|
|||
|
|
},
|
|||
|
|
'jcat': function(val, oldVal) {
|
|||
|
|
console.info(val);
|
|||
|
|
},
|
|||
|
|
'yandex': function(val, oldVal) {
|
|||
|
|
console.info(val);
|
|||
|
|
},
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
if ($('#advertPricesList').length > 0) {
|
|||
|
|
var advert_prices_list = new Vue({
|
|||
|
|
el: '#advertPricesList',
|
|||
|
|
components: {},
|
|||
|
|
data() {
|
|||
|
|
return {
|
|||
|
|
prices: [],
|
|||
|
|
user_id: null
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
methods: {
|
|||
|
|
isEmpty(data) {
|
|||
|
|
if (typeof(data) === 'object') {
|
|||
|
|
if (JSON.stringify(data) === '{}' || JSON.stringify(data) === '[]') {
|
|||
|
|
return true;
|
|||
|
|
} else if (!data) {
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
return false;
|
|||
|
|
} else if (typeof(data) === 'string') {
|
|||
|
|
if (!data.trim()) {
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
return false;
|
|||
|
|
} else if (typeof(data) === 'undefined') {
|
|||
|
|
return true;
|
|||
|
|
} else {
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
getAdvertPricesForm(id) {
|
|||
|
|
return advert_prices_form.getAdvertPricesForm(id);
|
|||
|
|
},
|
|||
|
|
confirmDeleteAdvertPrice(id) {
|
|||
|
|
return advert_prices_form.deleteAdvertPrice(id);
|
|||
|
|
},
|
|||
|
|
getAdvertPricesList() {
|
|||
|
|
let ref = this;
|
|||
|
|
axios.post('/ajax/ajax_vue_settings.php', {
|
|||
|
|
request: 'get_advert_prices_list'
|
|||
|
|
}).then(function(response) {
|
|||
|
|
|
|||
|
|
console.info(response);
|
|||
|
|
if (response.data.success)
|
|||
|
|
ref.prices = response.data.list;
|
|||
|
|
|
|||
|
|
}).catch(function(error) {
|
|||
|
|
|
|||
|
|
if (error)
|
|||
|
|
console.debug(error);
|
|||
|
|
|
|||
|
|
});
|
|||
|
|
},
|
|||
|
|
getPriceStyle(number) {
|
|||
|
|
return number + 1 % 2 > 0 ? 'background-color: #f9f9f9;' : ''
|
|||
|
|
},
|
|||
|
|
},
|
|||
|
|
created: function() {
|
|||
|
|
|
|||
|
|
},
|
|||
|
|
watch: {
|
|||
|
|
'prices': function(val, oldVal) {
|
|||
|
|
console.info(val);
|
|||
|
|
},
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if ($('#advertising_sources_add_edit_modal').length > 0) {
|
|||
|
|
var advertising_sources_add_edit_modal = new Vue({
|
|||
|
|
el: '#advertising_sources_add_edit_modal',
|
|||
|
|
components: {},
|
|||
|
|
data() {
|
|||
|
|
return {
|
|||
|
|
OpenIndicator: {
|
|||
|
|
render: createElement => createElement('span', { class: { 'vueToggleSpan': true } }),
|
|||
|
|
},
|
|||
|
|
is_no_see: 0,
|
|||
|
|
users_see: [{ 'code': '0', 'name': '', 'type':'agent' }],
|
|||
|
|
selected_users_see_no: null,
|
|||
|
|
userId: $('#session_user_id').val(),
|
|||
|
|
agencyId: $('#session_agency_id').val(),
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
methods: {
|
|||
|
|
get_user_see(){
|
|||
|
|
axios.post('/ajax/ajax_vue_funnel.php', {
|
|||
|
|
request: 'get_users_see',
|
|||
|
|
agency_id: this.agencyId,
|
|||
|
|
user_id: this.userId,
|
|||
|
|
})
|
|||
|
|
.then((response) => {
|
|||
|
|
this.users_see = response.data;
|
|||
|
|
})
|
|||
|
|
.catch(function(error) {
|
|||
|
|
console.error(error);
|
|||
|
|
});
|
|||
|
|
},
|
|||
|
|
isEmpty(data) {
|
|||
|
|
if (typeof(data) === 'object') {
|
|||
|
|
if (JSON.stringify(data) === '{}' || JSON.stringify(data) === '[]') {
|
|||
|
|
return true;
|
|||
|
|
} else if (!data) {
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
return false;
|
|||
|
|
} else if (typeof(data) === 'string') {
|
|||
|
|
if (!data.trim()) {
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
return false;
|
|||
|
|
} else if (typeof(data) === 'undefined') {
|
|||
|
|
return true;
|
|||
|
|
} else {
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
|
|||
|
|
},
|
|||
|
|
created: function() {
|
|||
|
|
this.get_user_see();
|
|||
|
|
},
|
|||
|
|
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if ($('#advertising_sources_connection').length > 0) {
|
|||
|
|
var advertising_sources_connection = new Vue({
|
|||
|
|
el: '#advertising_sources_connection',
|
|||
|
|
components: {
|
|||
|
|
|
|||
|
|
vuejsDatepicker: window.vuejsDatepicker
|
|||
|
|
},
|
|||
|
|
data() {
|
|||
|
|
return {
|
|||
|
|
ru: vdp_translation_ru.js,
|
|||
|
|
is_show: false,
|
|||
|
|
isDetailsTooltip: false,
|
|||
|
|
switchTab: 'settings',
|
|||
|
|
showForm: false,
|
|||
|
|
isDialogDel: false,
|
|||
|
|
mode: 'add',
|
|||
|
|
arraySources: [],
|
|||
|
|
arrayLogs: [],
|
|||
|
|
page: 1,
|
|||
|
|
all_pages: 1,
|
|||
|
|
prevPage: 0,
|
|||
|
|
ot: 0,
|
|||
|
|
do: 0,
|
|||
|
|
pagePagin: [],
|
|||
|
|
isPreloader: true,
|
|||
|
|
sources: [],
|
|||
|
|
date_start: null,
|
|||
|
|
date_end: null,
|
|||
|
|
format: "dd.MM.yyyy",
|
|||
|
|
mondayfirst: true,
|
|||
|
|
textDetails: "",
|
|||
|
|
sourceDetails: "",
|
|||
|
|
errors: {
|
|||
|
|
source: null,
|
|||
|
|
type: null,
|
|||
|
|
name: null,
|
|||
|
|
},
|
|||
|
|
tags: [],
|
|||
|
|
users: [],
|
|||
|
|
funnels: [],
|
|||
|
|
type_integration: [
|
|||
|
|
{'code': 1, 'name': 'pixel'},
|
|||
|
|
{'code': 2, 'name': 'creatium'},
|
|||
|
|
{'code': 3, 'name': 'creatium2'},
|
|||
|
|
{'code': 4, 'name': 'leadback'},
|
|||
|
|
{'code': 5, 'name': 'marqviz'},
|
|||
|
|
],
|
|||
|
|
types_integration: [
|
|||
|
|
{'code': 1, 'name': 'pixel'},
|
|||
|
|
{'code': 2, 'name': 'creatium'},
|
|||
|
|
{'code': 3, 'name': 'creatium2'},
|
|||
|
|
{'code': 4, 'name': 'leadback'},
|
|||
|
|
{'code': 5, 'name': 'marqviz'},
|
|||
|
|
{'code': 0, 'name': 'GCK или KnowHow'}
|
|||
|
|
],
|
|||
|
|
events_integration: [
|
|||
|
|
{'code': 'add', 'name': 'Добавление'},
|
|||
|
|
{'code': 'update', 'name': 'Изменение'},
|
|||
|
|
{'code': 'delete', 'name': 'Удаление'},
|
|||
|
|
],
|
|||
|
|
item: {
|
|||
|
|
id: 0,
|
|||
|
|
source: null,
|
|||
|
|
type_source_conect: 'tag',
|
|||
|
|
type: null,
|
|||
|
|
tags: null,
|
|||
|
|
who_work: null,
|
|||
|
|
funnel_id: null,
|
|||
|
|
name: null,
|
|||
|
|
funnel_id_req: null
|
|||
|
|
},
|
|||
|
|
OpenIndicator: {
|
|||
|
|
render: createElement => createElement('span', { class: { 'vueToggleSpan': true } }),
|
|||
|
|
},
|
|||
|
|
|
|||
|
|
filter: {
|
|||
|
|
type: null,
|
|||
|
|
name: null,
|
|||
|
|
users: null,
|
|||
|
|
date_start: null,
|
|||
|
|
date_end: null,
|
|||
|
|
event: null,
|
|||
|
|
},
|
|||
|
|
|
|||
|
|
userId: $('#session_user_id').val(),
|
|||
|
|
agencyId: $('#session_agency_id').val(),
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
methods: {
|
|||
|
|
|
|||
|
|
openModal(){
|
|||
|
|
this.switchTab = 'settings',
|
|||
|
|
this.filter = {
|
|||
|
|
type: null,
|
|||
|
|
name: null,
|
|||
|
|
users: null,
|
|||
|
|
date_start: null,
|
|||
|
|
date_end: null,
|
|||
|
|
event: null,
|
|||
|
|
}
|
|||
|
|
this.is_show = true;
|
|||
|
|
this.page = 1;
|
|||
|
|
this.get_sources_connection();
|
|||
|
|
|
|||
|
|
$('body').addClass("lock");
|
|||
|
|
|
|||
|
|
},
|
|||
|
|
closeModal(){
|
|||
|
|
this.is_show = false;
|
|||
|
|
$('body').removeClass("lock");
|
|||
|
|
},
|
|||
|
|
switch_tab(tab){
|
|||
|
|
this.switchTab = tab;
|
|||
|
|
this.page = 1;
|
|||
|
|
if(tab == 'history'){
|
|||
|
|
|
|||
|
|
this.get_logs_connection();
|
|||
|
|
} else {
|
|||
|
|
this.get_sources_connection();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
},
|
|||
|
|
openForm(mode, index){
|
|||
|
|
this.clearItem();
|
|||
|
|
this.get_sources_list();
|
|||
|
|
this.get_activites_list();
|
|||
|
|
this.get_users_list();
|
|||
|
|
this.get_funnels_list();
|
|||
|
|
this.mode = mode;
|
|||
|
|
this.showForm = true;
|
|||
|
|
if(mode == 'edit'){
|
|||
|
|
let temp_item = this.arraySources[index];
|
|||
|
|
if(temp_item.id){
|
|||
|
|
this.item.id = temp_item.id;
|
|||
|
|
this.item.source = temp_item.adv_id;
|
|||
|
|
this.item.type_source_conect = (temp_item.type > 0) ? 'domain' : 'tag';
|
|||
|
|
this.item.type = temp_item.type;
|
|||
|
|
this.item.name = (temp_item.type > 0) ? temp_item.domain : temp_item.tag;
|
|||
|
|
this.item.who_work = (temp_item.who_work > 0) ? temp_item.who_work : null;
|
|||
|
|
this.item.funnel_id = temp_item.funnel_id;
|
|||
|
|
this.item.funnel_id_req = temp_item.funnel_id_req;
|
|||
|
|
|
|||
|
|
if(!this.isEmpty(temp_item.tags)){
|
|||
|
|
let temp_tags = [];
|
|||
|
|
for(let i in temp_item.tags){
|
|||
|
|
temp_tags.push(temp_item.tags[i].activities_id);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
this.item.tags = temp_tags;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
closeForm(){
|
|||
|
|
this.showForm = false;
|
|||
|
|
},
|
|||
|
|
clear(){
|
|||
|
|
this.arrayLogs = [];
|
|||
|
|
this.arraySources = [];
|
|||
|
|
this.isPreloader = true;
|
|||
|
|
this.all_pages = 1;
|
|||
|
|
this.prevPage = 0;
|
|||
|
|
this.ot = 0;
|
|||
|
|
this.do = 0;
|
|||
|
|
this.pagePagin = [];
|
|||
|
|
this.delete_id = null;
|
|||
|
|
this.textDetails = '';
|
|||
|
|
this.sourceDetails = '';
|
|||
|
|
this.item = {
|
|||
|
|
id: 0,
|
|||
|
|
source: null,
|
|||
|
|
type_source_conect: 'tag',
|
|||
|
|
type: null,
|
|||
|
|
tags: null,
|
|||
|
|
who_work: null,
|
|||
|
|
funnel_id: null,
|
|||
|
|
name: null,
|
|||
|
|
funnel_id_req: null
|
|||
|
|
};
|
|||
|
|
this.errors = {
|
|||
|
|
source: null,
|
|||
|
|
type: null,
|
|||
|
|
name: null,
|
|||
|
|
};
|
|||
|
|
},
|
|||
|
|
clearItem(){
|
|||
|
|
this.item = {
|
|||
|
|
id: 0,
|
|||
|
|
source: null,
|
|||
|
|
type_source_conect: 'tag',
|
|||
|
|
type: null,
|
|||
|
|
tags: null,
|
|||
|
|
who_work: null,
|
|||
|
|
funnel_id: null,
|
|||
|
|
name: null,
|
|||
|
|
funnel_id_req: null
|
|||
|
|
};
|
|||
|
|
this.errors = {
|
|||
|
|
source: null,
|
|||
|
|
type: null,
|
|||
|
|
name: null,
|
|||
|
|
};
|
|||
|
|
},
|
|||
|
|
search_source(){
|
|||
|
|
// console.log(this.filter);
|
|||
|
|
this.page = 1;
|
|||
|
|
this.get_sources_connection();
|
|||
|
|
},
|
|||
|
|
search_log(){
|
|||
|
|
// console.log(this.filter);
|
|||
|
|
this.page = 1;
|
|||
|
|
this.get_logs_connection();
|
|||
|
|
},
|
|||
|
|
get_sources_connection(){
|
|||
|
|
|
|||
|
|
this.clear();
|
|||
|
|
axios.post('/ajax/ajax_vue_settings.php', {
|
|||
|
|
request: 'get_sources_connection',
|
|||
|
|
agency_id: this.agencyId,
|
|||
|
|
user_id: this.userId,
|
|||
|
|
page: this.page,
|
|||
|
|
filter: this.filter
|
|||
|
|
})
|
|||
|
|
.then((response) => {
|
|||
|
|
this.isPreloader = false;
|
|||
|
|
//console.log(response.data);
|
|||
|
|
this.arraySources = response.data.list;
|
|||
|
|
|
|||
|
|
this.all_pages = parseInt(response.data.allPages);
|
|||
|
|
if (this.all_pages > 1) {
|
|||
|
|
if (this.page > 1)
|
|||
|
|
this.prevPage = this.page - 1;
|
|||
|
|
}
|
|||
|
|
if (this.all_pages > 8) {
|
|||
|
|
if (this.page > 4) {
|
|||
|
|
this.ot = this.page - 3;
|
|||
|
|
} else {
|
|||
|
|
this.ot = 2;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (this.page < this.all_pages - 4) {
|
|||
|
|
this.do = this.page + 3;
|
|||
|
|
} else {
|
|||
|
|
this.do = this.all_pages;
|
|||
|
|
}
|
|||
|
|
} else {
|
|||
|
|
this.ot = 2;
|
|||
|
|
this.do = this.all_pages;
|
|||
|
|
}
|
|||
|
|
for (var i = this.ot; i < this.do; i++) {
|
|||
|
|
this.pagePagin.push(i);
|
|||
|
|
}
|
|||
|
|
})
|
|||
|
|
.catch(function(error) {
|
|||
|
|
console.error(error);
|
|||
|
|
});
|
|||
|
|
},
|
|||
|
|
get_logs_connection(){
|
|||
|
|
this.get_users_list();
|
|||
|
|
this.clear();
|
|||
|
|
axios.post('/ajax/ajax_vue_settings.php', {
|
|||
|
|
request: 'get_logs_connection',
|
|||
|
|
agency_id: this.agencyId,
|
|||
|
|
user_id: this.userId,
|
|||
|
|
page: this.page,
|
|||
|
|
filter: this.filter
|
|||
|
|
})
|
|||
|
|
.then((response) => {
|
|||
|
|
this.isPreloader = false;
|
|||
|
|
// console.log(response.data);
|
|||
|
|
this.arrayLogs = response.data.list;
|
|||
|
|
|
|||
|
|
this.all_pages = parseInt(response.data.allPages);
|
|||
|
|
if (this.all_pages > 1) {
|
|||
|
|
if (this.page > 1)
|
|||
|
|
this.prevPage = this.page - 1;
|
|||
|
|
}
|
|||
|
|
if (this.all_pages > 8) {
|
|||
|
|
if (this.page > 4) {
|
|||
|
|
this.ot = this.page - 3;
|
|||
|
|
} else {
|
|||
|
|
this.ot = 2;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (this.page < this.all_pages - 4) {
|
|||
|
|
this.do = this.page + 3;
|
|||
|
|
} else {
|
|||
|
|
this.do = this.all_pages;
|
|||
|
|
}
|
|||
|
|
} else {
|
|||
|
|
this.ot = 2;
|
|||
|
|
this.do = this.all_pages;
|
|||
|
|
}
|
|||
|
|
for (var i = this.ot; i < this.do; i++) {
|
|||
|
|
this.pagePagin.push(i);
|
|||
|
|
}
|
|||
|
|
})
|
|||
|
|
.catch(function(error) {
|
|||
|
|
console.error(error);
|
|||
|
|
});
|
|||
|
|
},
|
|||
|
|
get_sources_list(){
|
|||
|
|
if(this.isEmpty(this.sources)){
|
|||
|
|
axios.post('/ajax/ajax_vue_settings.php', {
|
|||
|
|
request: 'get_all_sources',
|
|||
|
|
agency_id: this.agencyId
|
|||
|
|
|
|||
|
|
})
|
|||
|
|
.then((response) => {
|
|||
|
|
|
|||
|
|
//console.log(response.data);
|
|||
|
|
this.sources = response.data;
|
|||
|
|
})
|
|||
|
|
.catch(function(error) {
|
|||
|
|
console.error(error);
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
get_activites_list(){
|
|||
|
|
if(this.isEmpty(this.tags)){
|
|||
|
|
axios.post('/ajax/ajax_vue_settings.php', {
|
|||
|
|
request: 'get_activites_list',
|
|||
|
|
agency_id: this.agencyId
|
|||
|
|
|
|||
|
|
})
|
|||
|
|
.then((response) => {
|
|||
|
|
|
|||
|
|
//console.log(response.data);
|
|||
|
|
this.tags = response.data;
|
|||
|
|
})
|
|||
|
|
.catch(function(error) {
|
|||
|
|
console.error(error);
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
get_users_list(){
|
|||
|
|
if(this.isEmpty(this.users)){
|
|||
|
|
axios.post('/ajax/ajax_vue_settings.php', {
|
|||
|
|
request: 'get_users_list',
|
|||
|
|
agency_id: this.agencyId,
|
|||
|
|
user_id: this.userId
|
|||
|
|
})
|
|||
|
|
.then((response) => {
|
|||
|
|
|
|||
|
|
// console.log(response.data);
|
|||
|
|
this.users = response.data;
|
|||
|
|
})
|
|||
|
|
.catch(function(error) {
|
|||
|
|
console.error(error);
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
},
|
|||
|
|
get_funnels_list(){
|
|||
|
|
if(this.isEmpty(this.funnels)){
|
|||
|
|
axios.post('/ajax/ajax_vue_settings.php', {
|
|||
|
|
request: 'get_funnels_list',
|
|||
|
|
agency_id: this.agencyId,
|
|||
|
|
|
|||
|
|
})
|
|||
|
|
.then((response) => {
|
|||
|
|
|
|||
|
|
// console.log(response.data);
|
|||
|
|
this.funnels = response.data;
|
|||
|
|
})
|
|||
|
|
.catch(function(error) {
|
|||
|
|
console.error(error);
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
//Пагинация
|
|||
|
|
pagin(page) {
|
|||
|
|
this.page = page;
|
|||
|
|
if(this.switchTab == 'history'){
|
|||
|
|
this.get_logs_connection();
|
|||
|
|
} else {
|
|||
|
|
this.get_sources_connection();
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
|
|||
|
|
//Получение данных о связи
|
|||
|
|
get_data_source(source_id){
|
|||
|
|
// console.log(source_id);
|
|||
|
|
this.item.tags = null;
|
|||
|
|
this.item.who_work = null;
|
|||
|
|
this.item.funnel_id = null;
|
|||
|
|
this.item.funnel_id_req = null;
|
|||
|
|
if(source_id > 0){
|
|||
|
|
axios.post('/ajax/ajax_vue_settings.php', {
|
|||
|
|
request: 'get_data_source',
|
|||
|
|
agency_id: this.agencyId,
|
|||
|
|
user_id: this.userId,
|
|||
|
|
source_id: this.item.source,
|
|||
|
|
|
|||
|
|
})
|
|||
|
|
.then((response) => {
|
|||
|
|
|
|||
|
|
// console.log(response.data);
|
|||
|
|
let res = response.data;
|
|||
|
|
if(!this.isEmpty(res.activites)){
|
|||
|
|
this.item.tags = res.activites;
|
|||
|
|
}
|
|||
|
|
if(!this.isEmpty(res.who_work)){
|
|||
|
|
this.item.who_work = res.who_work;
|
|||
|
|
}
|
|||
|
|
if(!this.isEmpty(res.funnel_id)){
|
|||
|
|
this.item.funnel_id = res.funnel_id;
|
|||
|
|
}
|
|||
|
|
if(!this.isEmpty(res.funnel_id_req)){
|
|||
|
|
this.item.funnel_id_req = res.funnel_id_req;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
})
|
|||
|
|
.catch(function(error) {
|
|||
|
|
console.error(error);
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
},
|
|||
|
|
|
|||
|
|
//save
|
|||
|
|
save(){
|
|||
|
|
this.errors = {
|
|||
|
|
source: null,
|
|||
|
|
type: null,
|
|||
|
|
name: null,
|
|||
|
|
};
|
|||
|
|
let _error = false;
|
|||
|
|
|
|||
|
|
|
|||
|
|
if(this.isEmpty(this.item.source)){
|
|||
|
|
this.errors.source = "Выберите источник";
|
|||
|
|
_error = true;
|
|||
|
|
}
|
|||
|
|
if(this.isEmpty(this.item.name)){
|
|||
|
|
this.errors.name = "Введите наименование";
|
|||
|
|
_error = true;
|
|||
|
|
}
|
|||
|
|
if(this.item.type_source_conect == 'domain' && this.isEmpty(this.item.type)){
|
|||
|
|
this.errors.type = "Выберите тип интеграции";
|
|||
|
|
_error = true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if(!_error){
|
|||
|
|
axios.post('/ajax/ajax_vue_settings.php', {
|
|||
|
|
request: 'save_source_connect',
|
|||
|
|
agency_id: this.agencyId,
|
|||
|
|
user_id: this.userId,
|
|||
|
|
item: this.item,
|
|||
|
|
|
|||
|
|
})
|
|||
|
|
.then((response) => {
|
|||
|
|
|
|||
|
|
//console.log(response.data);
|
|||
|
|
let res = response.data;
|
|||
|
|
if(res.result == 'error'){
|
|||
|
|
this.errors = res.errors;
|
|||
|
|
} else {
|
|||
|
|
this.closeForm();
|
|||
|
|
this.get_sources_connection();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
})
|
|||
|
|
.catch(function(error) {
|
|||
|
|
console.error(error);
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
openDeleteDialog(index){
|
|||
|
|
|
|||
|
|
this.delete_id = this.arraySources[index].id;
|
|||
|
|
this.isDialogDel = true;
|
|||
|
|
},
|
|||
|
|
confirmDelete(){
|
|||
|
|
console.log(this.delete_id);
|
|||
|
|
axios.post('/ajax/ajax_vue_settings.php', {
|
|||
|
|
request: 'del_source_connect',
|
|||
|
|
agency_id: this.agencyId,
|
|||
|
|
user_id: this.userId,
|
|||
|
|
delete_id: this.delete_id,
|
|||
|
|
|
|||
|
|
})
|
|||
|
|
.then((response) => {
|
|||
|
|
|
|||
|
|
console.log(response.data);
|
|||
|
|
let res = response.data;
|
|||
|
|
if(res.result == 'error'){
|
|||
|
|
this.errors = res.errors;
|
|||
|
|
} else {
|
|||
|
|
this.isDialogDel = false;
|
|||
|
|
this.get_sources_connection();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
})
|
|||
|
|
.catch(function(error) {
|
|||
|
|
console.error(error);
|
|||
|
|
});
|
|||
|
|
},
|
|||
|
|
|
|||
|
|
showTooltip(index, event){
|
|||
|
|
let temp_log = this.arrayLogs[index];
|
|||
|
|
this.textDetails = this.arrayLogs[index].description;
|
|||
|
|
this.sourceDetails = this.arrayLogs[index].source;
|
|||
|
|
|
|||
|
|
let pos = $(event.target).offset();
|
|||
|
|
let left = pos.left;
|
|||
|
|
var top = $(event.target).offset().top + 30;
|
|||
|
|
|
|||
|
|
this.isDetailsTooltip = true;
|
|||
|
|
|
|||
|
|
$("#as_details-tooltip").offset({ top: top, left: left })
|
|||
|
|
|
|||
|
|
setTimeout(function(){
|
|||
|
|
$("#as_details-tooltip").offset({ top: top, left: left })
|
|||
|
|
}, 300);
|
|||
|
|
},
|
|||
|
|
isEmpty(data) {
|
|||
|
|
if (typeof(data) === 'object') {
|
|||
|
|
if (JSON.stringify(data) === '{}' || JSON.stringify(data) === '[]') {
|
|||
|
|
return true;
|
|||
|
|
} else if (!data) {
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
return false;
|
|||
|
|
} else if (typeof(data) === 'string') {
|
|||
|
|
if (!data.trim()) {
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
return false;
|
|||
|
|
} else if (typeof(data) === 'undefined') {
|
|||
|
|
return true;
|
|||
|
|
} else {
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
|
|||
|
|
},
|
|||
|
|
created: function() {
|
|||
|
|
$(".as_modal-overlay").addClass('active');
|
|||
|
|
|
|||
|
|
},
|
|||
|
|
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if ($('#web_hooks_setting').length > 0) {
|
|||
|
|
|
|||
|
|
var web_hooks_setting = new Vue({
|
|||
|
|
el: '#web_hooks_setting',
|
|||
|
|
components: {
|
|||
|
|
|
|||
|
|
vuejsDatepicker: window.vuejsDatepicker
|
|||
|
|
},
|
|||
|
|
data() {
|
|||
|
|
return {
|
|||
|
|
ru: vdp_translation_ru.js,
|
|||
|
|
is_active: 0,
|
|||
|
|
is_show: false,
|
|||
|
|
isDetailsTooltip: false,
|
|||
|
|
showForm: false,
|
|||
|
|
isDialogDel: false,
|
|||
|
|
mode: 'add',
|
|||
|
|
page: 1,
|
|||
|
|
all_pages: 1,
|
|||
|
|
prevPage: 0,
|
|||
|
|
ot: 0,
|
|||
|
|
do: 0,
|
|||
|
|
arrayWebhooks: [],
|
|||
|
|
pagePagin: [],
|
|||
|
|
isPreloader: true,
|
|||
|
|
date_start: null,
|
|||
|
|
date_end: null,
|
|||
|
|
format: "dd.MM.yyyy",
|
|||
|
|
mondayfirst: true,
|
|||
|
|
errors: {
|
|||
|
|
url: null,
|
|||
|
|
section: null,
|
|||
|
|
name: null,
|
|||
|
|
action: null,
|
|||
|
|
steps: null,
|
|||
|
|
funnel: null,
|
|||
|
|
},
|
|||
|
|
funnels: [],
|
|||
|
|
steps: [],
|
|||
|
|
sections: [
|
|||
|
|
{'code': 'req', 'name': 'Заявки'},
|
|||
|
|
{'code': 'object', 'name': 'Объекты'},
|
|||
|
|
{'code': 'employee', 'name': 'Сорудники'}
|
|||
|
|
|
|||
|
|
],
|
|||
|
|
actions: [
|
|||
|
|
{'code': 'close_step', 'name': 'Закрытие этапа'},
|
|||
|
|
{'code': 'transition_step', 'name': 'Переход на этап'},
|
|||
|
|
|
|||
|
|
],
|
|||
|
|
item: {
|
|||
|
|
id: 0,
|
|||
|
|
url: null,
|
|||
|
|
name: null,
|
|||
|
|
section: null,
|
|||
|
|
action: null,
|
|||
|
|
steps: null,
|
|||
|
|
funnel_id: null,
|
|||
|
|
is_active: 1,
|
|||
|
|
|
|||
|
|
},
|
|||
|
|
OpenIndicator: {
|
|||
|
|
render: createElement => createElement('span', { class: { 'vueToggleSpan': true } }),
|
|||
|
|
},
|
|||
|
|
|
|||
|
|
filter: {
|
|||
|
|
type: null,
|
|||
|
|
name: null,
|
|||
|
|
users: null,
|
|||
|
|
date_start: null,
|
|||
|
|
date_end: null,
|
|||
|
|
event: null,
|
|||
|
|
},
|
|||
|
|
|
|||
|
|
userId: $('#session_user_id').val(),
|
|||
|
|
agencyId: $('#session_agency_id').val(),
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
methods: {
|
|||
|
|
|
|||
|
|
openModal(){
|
|||
|
|
this.switchTab = 'settings',
|
|||
|
|
this.filter = {
|
|||
|
|
type: null,
|
|||
|
|
name: null,
|
|||
|
|
users: null,
|
|||
|
|
date_start: null,
|
|||
|
|
date_end: null,
|
|||
|
|
event: null,
|
|||
|
|
}
|
|||
|
|
this.is_show = true;
|
|||
|
|
this.page = 1;
|
|||
|
|
this.get_enable_webhook();
|
|||
|
|
|
|||
|
|
$('body').addClass("lock");
|
|||
|
|
|
|||
|
|
},
|
|||
|
|
closeModal(){
|
|||
|
|
this.is_show = false;
|
|||
|
|
$('body').removeClass("lock");
|
|||
|
|
},
|
|||
|
|
switch_tab(tab){
|
|||
|
|
this.switchTab = tab;
|
|||
|
|
this.page = 1;
|
|||
|
|
if(tab == 'history'){
|
|||
|
|
|
|||
|
|
this.get_logs_connection();
|
|||
|
|
} else {
|
|||
|
|
this.get_sources_connection();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
},
|
|||
|
|
openForm(mode, index){
|
|||
|
|
this.clearItem();
|
|||
|
|
//this.get_sources_list();
|
|||
|
|
//this.get_activites_list();
|
|||
|
|
//this.get_users_list();
|
|||
|
|
//this.get_funnels_list();
|
|||
|
|
|
|||
|
|
this.mode = mode;
|
|||
|
|
this.showForm = true;
|
|||
|
|
if(mode == 'edit'){
|
|||
|
|
let temp_item = this.arrayWebhooks[index];
|
|||
|
|
if(temp_item.id){
|
|||
|
|
this.item.id = temp_item.id;
|
|||
|
|
this.item.name = temp_item.name;
|
|||
|
|
this.item.url = temp_item.url;
|
|||
|
|
this.item.funnel_id = temp_item.funnel_id;
|
|||
|
|
this.item.steps = JSON.parse(temp_item.steps);
|
|||
|
|
this.item.is_active = temp_item.is_active;
|
|||
|
|
this.item.section = temp_item.section;
|
|||
|
|
this.item.action = temp_item.action;
|
|||
|
|
}
|
|||
|
|
this.get_funnels_list();
|
|||
|
|
this.get_steps_funnel();
|
|||
|
|
this.change_section(1);
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
closeForm(){
|
|||
|
|
this.showForm = false;
|
|||
|
|
},
|
|||
|
|
clear(){
|
|||
|
|
|
|||
|
|
this.arrayWebhooks = [];
|
|||
|
|
this.isPreloader = true;
|
|||
|
|
this.all_pages = 1;
|
|||
|
|
this.prevPage = 0;
|
|||
|
|
this.ot = 0;
|
|||
|
|
this.do = 0;
|
|||
|
|
this.pagePagin = [];
|
|||
|
|
this.delete_id = null;
|
|||
|
|
this.textDetails = '';
|
|||
|
|
this.sourceDetails = '';
|
|||
|
|
this.item = {
|
|||
|
|
id: 0,
|
|||
|
|
url: null,
|
|||
|
|
name: null,
|
|||
|
|
section: null,
|
|||
|
|
action: null,
|
|||
|
|
steps: null,
|
|||
|
|
funnel_id: null,
|
|||
|
|
is_active: 1
|
|||
|
|
};
|
|||
|
|
this.errors = {
|
|||
|
|
url: null,
|
|||
|
|
section: null,
|
|||
|
|
name: null,
|
|||
|
|
action: null,
|
|||
|
|
steps: null,
|
|||
|
|
funnel: null,
|
|||
|
|
};
|
|||
|
|
},
|
|||
|
|
clearItem(){
|
|||
|
|
this.item = {
|
|||
|
|
id: 0,
|
|||
|
|
url: null,
|
|||
|
|
name: null,
|
|||
|
|
section: null,
|
|||
|
|
action: null,
|
|||
|
|
steps: null,
|
|||
|
|
funnel_id: null,
|
|||
|
|
is_active: 1
|
|||
|
|
};
|
|||
|
|
this.errors = {
|
|||
|
|
url: null,
|
|||
|
|
section: null,
|
|||
|
|
name: null,
|
|||
|
|
action: null,
|
|||
|
|
steps: null,
|
|||
|
|
funnel: null,
|
|||
|
|
};
|
|||
|
|
},
|
|||
|
|
|
|||
|
|
get_enable_webhook(){
|
|||
|
|
axios.post('/ajax/ajax_vue_settings.php', {
|
|||
|
|
request: 'get_enable_webhooks',
|
|||
|
|
agency_id: this.agencyId,
|
|||
|
|
|
|||
|
|
})
|
|||
|
|
.then((response) => {
|
|||
|
|
|
|||
|
|
console.log(response.data);
|
|||
|
|
this.is_active = response.data;
|
|||
|
|
if(this.is_active > 0){
|
|||
|
|
this.get_webhooks();
|
|||
|
|
}
|
|||
|
|
})
|
|||
|
|
.catch(function(error) {
|
|||
|
|
console.error(error);
|
|||
|
|
});
|
|||
|
|
},
|
|||
|
|
|
|||
|
|
enable_webhooks(){
|
|||
|
|
|
|||
|
|
axios.post('/ajax/ajax_vue_settings.php', {
|
|||
|
|
request: 'set_enable_webhooks',
|
|||
|
|
agency_id: this.agencyId,
|
|||
|
|
user_id: this.userId,
|
|||
|
|
enable_webhooks: this.is_active
|
|||
|
|
})
|
|||
|
|
.then((response) => {
|
|||
|
|
|
|||
|
|
console.log(response.data);
|
|||
|
|
if(this.is_active > 0){
|
|||
|
|
this.get_webhooks();
|
|||
|
|
}
|
|||
|
|
})
|
|||
|
|
.catch(function(error) {
|
|||
|
|
console.error(error);
|
|||
|
|
});
|
|||
|
|
},
|
|||
|
|
|
|||
|
|
change_section(no_change = 0){
|
|||
|
|
this.actions = [];
|
|||
|
|
console.log(no_change);
|
|||
|
|
if(no_change == 0){
|
|||
|
|
this.item.action = null;
|
|||
|
|
}
|
|||
|
|
console.log(this.item.section);
|
|||
|
|
switch(this.item.section){
|
|||
|
|
case 'req' : {
|
|||
|
|
this.actions = [
|
|||
|
|
{'code': 'close_step', 'name': 'Закрытие этапа'},
|
|||
|
|
{'code': 'transition_step', 'name': 'Переход на этап'}
|
|||
|
|
]
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
case 'object' : {
|
|||
|
|
this.actions = [
|
|||
|
|
{'code': 'object_create', 'name': 'Добавление нового объекта'},
|
|||
|
|
{'code': 'object_update', 'name': 'Редактирование объекта'},
|
|||
|
|
{'code': 'object_advertise', 'name': 'Выставление объекта в рекламу'},
|
|||
|
|
{'code': 'object_unadvertise', 'name': 'Снятие с рекламы'},
|
|||
|
|
{'code': 'object_archive', 'name': 'Отправка в архив'},
|
|||
|
|
{'code': 'object_restore', 'name': 'Возврат из архива'},
|
|||
|
|
]
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
case 'employee' : {
|
|||
|
|
this.actions = [
|
|||
|
|
{'code': 'employee_create', 'name': 'Добавление нового сотрудника'},
|
|||
|
|
{'code': 'employee_update', 'name': 'Изменение сотрудника'},
|
|||
|
|
{'code': 'employee_block', 'name': 'Блокировка сотрудника'},
|
|||
|
|
{'code': 'employee_unblock', 'name': 'Снятие блокировки с сотрудника'},
|
|||
|
|
{'code': 'employee_delete', 'name': 'Удаление сотрудника'},
|
|||
|
|
]
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
default : {
|
|||
|
|
this.actions = [
|
|||
|
|
{'code': 'close_step', 'name': 'Закрытие этапа'},
|
|||
|
|
{'code': 'transition_step', 'name': 'Переход на этап'}
|
|||
|
|
]
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
},
|
|||
|
|
|
|||
|
|
change_action(){
|
|||
|
|
if(this.item.action == 'close_step' || this.item.action == 'transition_step'){
|
|||
|
|
this.get_funnels_list();
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
|
|||
|
|
change_funnel(){
|
|||
|
|
if(this.item.action == 'close_step' || this.item.action == 'transition_step'){
|
|||
|
|
if(!this.isEmpty(this.item.steps)){
|
|||
|
|
this.item.steps = [];
|
|||
|
|
}
|
|||
|
|
this.get_steps_funnel();
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
search_source(){
|
|||
|
|
// console.log(this.filter);
|
|||
|
|
this.page = 1;
|
|||
|
|
this.get_sources_connection();
|
|||
|
|
},
|
|||
|
|
search_log(){
|
|||
|
|
// console.log(this.filter);
|
|||
|
|
this.page = 1;
|
|||
|
|
this.get_logs_connection();
|
|||
|
|
},
|
|||
|
|
|
|||
|
|
get_webhooks(){
|
|||
|
|
|
|||
|
|
this.clear();
|
|||
|
|
axios.post('/ajax/ajax_vue_settings.php', {
|
|||
|
|
request: 'get_webhooks',
|
|||
|
|
agency_id: this.agencyId,
|
|||
|
|
user_id: this.userId,
|
|||
|
|
page: this.page,
|
|||
|
|
//filter: this.filter
|
|||
|
|
})
|
|||
|
|
.then((response) => {
|
|||
|
|
this.isPreloader = false;
|
|||
|
|
//console.log(response.data);
|
|||
|
|
this.arrayWebhooks = response.data.list;
|
|||
|
|
|
|||
|
|
this.all_pages = parseInt(response.data.allPages);
|
|||
|
|
if (this.all_pages > 1) {
|
|||
|
|
if (this.page > 1)
|
|||
|
|
this.prevPage = this.page - 1;
|
|||
|
|
}
|
|||
|
|
if (this.all_pages > 8) {
|
|||
|
|
if (this.page > 4) {
|
|||
|
|
this.ot = this.page - 3;
|
|||
|
|
} else {
|
|||
|
|
this.ot = 2;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (this.page < this.all_pages - 4) {
|
|||
|
|
this.do = this.page + 3;
|
|||
|
|
} else {
|
|||
|
|
this.do = this.all_pages;
|
|||
|
|
}
|
|||
|
|
} else {
|
|||
|
|
this.ot = 2;
|
|||
|
|
this.do = this.all_pages;
|
|||
|
|
}
|
|||
|
|
for (var i = this.ot; i < this.do; i++) {
|
|||
|
|
this.pagePagin.push(i);
|
|||
|
|
}
|
|||
|
|
})
|
|||
|
|
.catch(function(error) {
|
|||
|
|
console.error(error);
|
|||
|
|
});
|
|||
|
|
},
|
|||
|
|
|
|||
|
|
get_funnels_list(){
|
|||
|
|
let section = null;
|
|||
|
|
if(this.item.section == 'req'){
|
|||
|
|
section = 'requisitions'
|
|||
|
|
}
|
|||
|
|
//if(this.isEmpty(this.funnels)){
|
|||
|
|
axios.post('/ajax/ajax_vue_settings.php', {
|
|||
|
|
request: 'get_funnels_list',
|
|||
|
|
agency_id: this.agencyId,
|
|||
|
|
section: section,
|
|||
|
|
|
|||
|
|
})
|
|||
|
|
.then((response) => {
|
|||
|
|
|
|||
|
|
console.log(response.data);
|
|||
|
|
//this.funnels = response.data;
|
|||
|
|
this.funnels = response.data;
|
|||
|
|
})
|
|||
|
|
.catch(function(error) {
|
|||
|
|
console.error(error);
|
|||
|
|
});
|
|||
|
|
//}
|
|||
|
|
},
|
|||
|
|
|
|||
|
|
get_steps_funnel(){
|
|||
|
|
this.steps = [];
|
|||
|
|
|
|||
|
|
if(this.item.funnel_id > 0){
|
|||
|
|
axios.post('/ajax/ajax_vue_settings.php', {
|
|||
|
|
request: 'get_steps_list',
|
|||
|
|
agency_id: this.agencyId,
|
|||
|
|
funnel_id: this.item.funnel_id,
|
|||
|
|
action: this.item.action
|
|||
|
|
})
|
|||
|
|
.then((response) => {
|
|||
|
|
|
|||
|
|
this.steps = response.data;
|
|||
|
|
})
|
|||
|
|
.catch(function(error) {
|
|||
|
|
console.error(error);
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
},
|
|||
|
|
//Пагинация
|
|||
|
|
pagin(page) {
|
|||
|
|
this.page = page;
|
|||
|
|
if(this.switchTab == 'history'){
|
|||
|
|
this.get_logs_connection();
|
|||
|
|
} else {
|
|||
|
|
this.get_sources_connection();
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
//save
|
|||
|
|
save(){
|
|||
|
|
console.log(this.item);
|
|||
|
|
this.errors = {
|
|||
|
|
url: null,
|
|||
|
|
section: null,
|
|||
|
|
name: null,
|
|||
|
|
action: null,
|
|||
|
|
steps: null,
|
|||
|
|
funnel: null
|
|||
|
|
};
|
|||
|
|
let _error = false;
|
|||
|
|
|
|||
|
|
|
|||
|
|
if(this.isEmpty(this.item.url)){
|
|||
|
|
this.errors.url = "Введите URL";
|
|||
|
|
_error = true;
|
|||
|
|
}
|
|||
|
|
if(this.isEmpty(this.item.name)){
|
|||
|
|
this.errors.name = "Введите наименование";
|
|||
|
|
_error = true;
|
|||
|
|
}
|
|||
|
|
if(this.isEmpty(this.item.section)){
|
|||
|
|
this.errors.section = "Выберите раздел";
|
|||
|
|
_error = true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if(this.isEmpty(this.item.action)){
|
|||
|
|
this.errors.action = "Выберите действие";
|
|||
|
|
_error = true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if(this.item.action == 'close_step' || this.item.action == 'transition_step'){
|
|||
|
|
if(this.isEmpty(this.item.funnel_id)){
|
|||
|
|
this.errors.funnel = "Выберите воронку";
|
|||
|
|
_error = true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if(this.isEmpty(this.item.steps)){
|
|||
|
|
this.errors.steps = "Выберите этапы";
|
|||
|
|
_error = true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if(!_error){
|
|||
|
|
axios.post('/ajax/ajax_vue_settings.php', {
|
|||
|
|
request: 'save_webhook',
|
|||
|
|
agency_id: this.agencyId,
|
|||
|
|
user_id: this.userId,
|
|||
|
|
item: this.item,
|
|||
|
|
|
|||
|
|
})
|
|||
|
|
.then((response) => {
|
|||
|
|
//console.log(response.data);
|
|||
|
|
let res = response.data;
|
|||
|
|
if(res.result == 'error'){
|
|||
|
|
this.errors = res.errors;
|
|||
|
|
} else {
|
|||
|
|
this.closeForm();
|
|||
|
|
this.get_webhooks();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
})
|
|||
|
|
.catch(function(error) {
|
|||
|
|
console.error(error);
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
openDeleteDialog(index){
|
|||
|
|
|
|||
|
|
this.delete_id = this.arrayWebhooks[index].id;
|
|||
|
|
this.isDialogDel = true;
|
|||
|
|
},
|
|||
|
|
confirmDelete(){
|
|||
|
|
|
|||
|
|
axios.post('/ajax/ajax_vue_settings.php', {
|
|||
|
|
request: 'del_webhook',
|
|||
|
|
agency_id: this.agencyId,
|
|||
|
|
user_id: this.userId,
|
|||
|
|
delete_id: this.delete_id,
|
|||
|
|
|
|||
|
|
})
|
|||
|
|
.then((response) => {
|
|||
|
|
|
|||
|
|
let res = response.data;
|
|||
|
|
if(res.result == 'error'){
|
|||
|
|
this.errors = res.errors;
|
|||
|
|
} else {
|
|||
|
|
this.isDialogDel = false;
|
|||
|
|
this.get_webhooks();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
})
|
|||
|
|
.catch(function(error) {
|
|||
|
|
console.error(error);
|
|||
|
|
});
|
|||
|
|
},
|
|||
|
|
|
|||
|
|
showTooltip(index, event){
|
|||
|
|
let temp_log = this.arrayLogs[index];
|
|||
|
|
this.textDetails = this.arrayLogs[index].description;
|
|||
|
|
this.sourceDetails = this.arrayLogs[index].source;
|
|||
|
|
|
|||
|
|
let pos = $(event.target).offset();
|
|||
|
|
let left = pos.left;
|
|||
|
|
var top = $(event.target).offset().top + 30;
|
|||
|
|
|
|||
|
|
this.isDetailsTooltip = true;
|
|||
|
|
|
|||
|
|
$("#as_details-tooltip").offset({ top: top, left: left })
|
|||
|
|
|
|||
|
|
setTimeout(function(){
|
|||
|
|
$("#as_details-tooltip").offset({ top: top, left: left })
|
|||
|
|
}, 300);
|
|||
|
|
},
|
|||
|
|
isEmpty(data) {
|
|||
|
|
if (typeof(data) === 'object') {
|
|||
|
|
if (JSON.stringify(data) === '{}' || JSON.stringify(data) === '[]') {
|
|||
|
|
return true;
|
|||
|
|
} else if (!data) {
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
return false;
|
|||
|
|
} else if (typeof(data) === 'string') {
|
|||
|
|
if (!data.trim()) {
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
return false;
|
|||
|
|
} else if (typeof(data) === 'undefined') {
|
|||
|
|
return true;
|
|||
|
|
} else {
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
|
|||
|
|
},
|
|||
|
|
created: function() {
|
|||
|
|
$(".as_modal-overlay").addClass('active');
|
|||
|
|
|
|||
|
|
},
|
|||
|
|
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
function hideAdvertPricesForm() {
|
|||
|
|
advert_prices_form.hideAdvertPricesForm();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
function getAdvertPricesForm(item_id, close) {
|
|||
|
|
|
|||
|
|
if (close)
|
|||
|
|
hideAdvertPricesForm();
|
|||
|
|
|
|||
|
|
advert_prices_form.getAdvertPricesForm(item_id);
|
|||
|
|
advert_prices_form.initFastSelect();
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
function confirmDeleteAdvertPrice(item_id) {
|
|||
|
|
advert_prices_form.deleteAdvertPrice(item_id);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
function saveAdvertPricesForm() {
|
|||
|
|
advert_prices_form.saveAdvertPricesForm();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
function getAdvertPricesList() {
|
|||
|
|
advert_prices_list.getAdvertPricesList();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$(document).ready(
|
|||
|
|
function() {
|
|||
|
|
$('body').on('click', '#href_setting_video1', function(){
|
|||
|
|
$('#setting_video1').html('<iframe src="https://vk.ru/video_ext.php?oid=-140502045&id=456239130&autoplay=1" width="306" height="181" allow="autoplay; encrypted-media; fullscreen; picture-in-picture; screen-wake-lock;" frameborder="0" allowfullscreen></iframe>');
|
|||
|
|
}
|
|||
|
|
);
|
|||
|
|
|
|||
|
|
$('body').on('click', '#href_setting_video2', function(){
|
|||
|
|
$('#setting_video2').html('<iframe src="https://vk.ru/video_ext.php?oid=-140502045&id=456239122&autoplay=1" width="306" height="181" allow="autoplay; encrypted-media; fullscreen; picture-in-picture; screen-wake-lock;" frameborder="0" allowfullscreen></iframe>');
|
|||
|
|
}
|
|||
|
|
);
|
|||
|
|
|
|||
|
|
$('body').on('click', '#href_setting_video3', function(){
|
|||
|
|
$('#setting_video3').html('<iframe src="https://vk.ru//video_ext.php?oid=-140502045&id=456239149&hd=2&autoplay=1" width="306" height="181" allow="autoplay; encrypted-media; fullscreen; picture-in-picture; screen-wake-lock;" frameborder="0" allowfullscreen></iframe>');
|
|||
|
|
}
|
|||
|
|
);
|
|||
|
|
}
|
|||
|
|
)
|