From 8cdb9fd172b6b2e822cb8610044f68ca434da0cd Mon Sep 17 00:00:00 2001 From: marina Date: Tue, 3 Jun 2025 10:39:57 +0300 Subject: [PATCH] ERP-417 --- erp24/web/js/validate/validateForm.js | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/erp24/web/js/validate/validateForm.js b/erp24/web/js/validate/validateForm.js index accf7176..3a994a9b 100755 --- a/erp24/web/js/validate/validateForm.js +++ b/erp24/web/js/validate/validateForm.js @@ -1,3 +1,21 @@ +function updateCommentReadonly() { + const currentUser = $('.admin-name').text().trim(); + const selectedStoreId = $('#writeoffserp-store_id').val(); + const specialStoreIds = ['1', '9', '28']; + const allowedCommentUsers = ['Емельянова Ольга', 'Яшенкова Алена', 'Цветкова Ольга']; + + const isReadonly = specialStoreIds.includes(selectedStoreId) && !allowedCommentUsers.includes(currentUser); + $('#writeoffserp-comment').prop('readonly', isReadonly); +} + +$(document).ready(function () { + updateCommentReadonly(); + + $('#writeoffserp-store_id').on('change', function () { + updateCommentReadonly(); + }); +}); + $(".form-validate button").click(function (e) { e.preventDefault(); var form = $(this).closest('form')[0]; @@ -51,16 +69,11 @@ $(".form-validate button").click(function (e) { if (!errors['__common']) errors['__common'] = []; errors['__common'].push('Пожалуйста, добавьте хотя бы одно фото к каждому списанию перед сохранением.'); } - - if (commentValue.length > 0 && !allowedCommentUsers.includes(currentUser)) { - errors['WriteOffsErp[comment]'] = [ - 'Комментарий могут заполнять только: ' + allowedCommentUsers.join(', ') + '.' - ]; - } } if (Object.keys(errors).length > 0) { renderErrors(errors); + let allErrors = []; for (const key in errors) { if (Array.isArray(errors[key])) { -- 2.39.5