"); }); $("#div-informacao").html(divsArray.join("")); codImovelArray.push("
Anônimo\
"); response.map(function (n) { if (n.referencia == 1) { codImovelArray.push(""); } }); codImovelArray.push("
"); $("#div-anonimo").html(codImovelArray.join("")); } addHiddenInputToForm(cpf); }); } function loadDocs(field) { var referenciaValue = $(field).data('referencia'); if (referenciaValue == 1) { $("#cpfcnpj").prop('readOnly', true); $("#nome").prop("disabled", true); }else{ $("#cpfcnpj").prop('readOnly', false); $("#nome").prop("disabled", false); } for (var i = 0; i < $("#div-informacao").find("div").length; i++) { $($("#div-informacao").find("div")[i]).attr("hidden", "hidden") } for (var i = 0; i < $("#div-anonimo").find("div.col-lg-3").length - 1; i++) { $($("#div-anonimo").find("div.col-lg-3")[i]).attr("hidden", "hidden") } $("#notref").removeAttr("hidden"); $("#responsavel").attr("hidden", "hidden"); $("#relacionarprotocolo").attr("hidden", "hidden"); var obj = { Id: field.value } var campoid = "div#assunto-" + field.value; var ref = "div#referencia-" + field.value; var refInput = $("input[name=referencia]").attr("disabled", "disabled"); $(campoid).removeAttr("hidden"); if ($(ref).length > 0) { $(ref).removeAttr("hidden"); $(ref).find('input[name=referencia]').removeAttr('disabled'); $("#notref").attr("hidden", "hidden"); //$("#responsavel").removeAttr("hidden"); $("#relacionarprotocolo").removeAttr("hidden"); } else { $("#relacionarprotocolo").removeAttr("hidden"); } if (assuntos.find(x => x.id === parseInt(field.value)).relacionarProtocolo == 1) { $("input[name=protocolo][value='1']").prop('checked', true); $("input[name=protocolo][value='0']").prop('disabled', true); $("#hideprotocolo").attr("hidden", "hidden"); $("#showprotoloco").removeAttr("hidden"); } else { $("input[name=protocolo][value='0']").prop('checked', true); $("#hideprotocolo").removeAttr("hidden"); $("#showprotoloco").attr("hidden", "hidden"); $("input[name=protocolo][value='0']").prop('disabled', false); } Service.save(baseUrl + "/solicitacoes/documentos", obj, field, function (response) { var cpfElement = document.getElementById('cpfLoginPortal'); var cpf = cpfElement ? cpfElement.value : ''; if (response.length > 0) { $("#docs").empty(); var html = ""; for (var i = 0; i < response.length; i++) { html += "
"; if (response[i].obrigatorio) { html += ""; if(response[i].informacao){ html += "
"; } html += ""; html += ""; } else { html += ""; if(response[i].informacao){ html += "
"; } html += ""; html += ""; } html += ""; html += ""; html += ""; html += ""; html += "
"; } $("#docs").append(html); addHiddenInputToForm(cpf); } }); } function GetProprietarios(field) { var obj = { Id: $(field).parent().find("input").val() } Service.save(baseUrl + "/solicitacoes/proprietarios", obj, field, function (response) { if (response.length > 0) { $("#cpfcnpj").val(""); $("#nome").val(""); var replace = ''); } else if (response.length == 0) { $("#cpfcnpj").val(""); $("#nome") .replaceWith(''); } }); } function getCpfCnpj(field) { if ($(field).find("option:selected").attr("data-cpfcnpj")) { var cpfcnpj = $(field).find("option:selected").attr("data-cpfcnpj"); $("#cpfcnpj").val(cpfcnpj); $("#cpfcnpj").trigger("change"); } else { $("#cpfcnpj").val(""); } } function selectProtocolo(field) { var valor = $(field).attr("data-processo"); $("#numeroprotocolo").val(valor); } function GetProtocolos() { var obj = { Id: $("#nome").find("option:selected").attr("data-id") ? $("#nome").find("option:selected").attr("data-id") : 0, CpfCnpj: $("#cpfcnpj").val() } Service.query(baseUrl + "/solicitacoes/protocolos", obj, $("#showprotoloco"), function (response) { if (response.length > 0) { Dialog.open($("#showprotoloco"), 'dialog-dynamic', response); /*var replace = '');*/ } else if (response.length == 0) { $("#numeroprotocolo") .replaceWith(''); } }); } $.widget("custom.combobox", { _create: function () { this.wrapper = $("") .addClass("custom-combobox") .insertAfter(this.element); this.element.hide(); this._createAutocomplete(); this._createShowAllButton(); }, _createAutocomplete: function () { var selected = this.element.children(":selected"), value = selected.val() ? selected.text() : ""; this.input = $("") .appendTo(this.wrapper) .val(value) .attr("placeholder", "Digite um Assunto") .addClass("custom-combobox-input ui-widget ui-widget-content ui-state-default") .autocomplete({ delay: 0, minLength: 0, source: $.proxy(this, "_source") }) .tooltip({ classes: { "ui-tooltip": "ui-state-highlight" } }); this._on(this.input, { autocompleteselect: function (event, ui) { ui.item.option.selected = true; this._trigger("select", event, { item: ui.item.option }); loadDocs(ui.item.option); }, autocompletechange: "_removeIfInvalid" }); }, _createShowAllButton: function () { var input = this.input, wasOpen = false; $("") .attr("tabIndex", -1) .attr("title", "Mostrar opções") .tooltip() .appendTo(this.wrapper) .button({ label: "", text: false }) .removeClass("ui-corner-all") .addClass("custom-combobox-toggle") .on("mousedown", function () { wasOpen = input.autocomplete("widget").is(":visible"); }) .on("click", function () { input.trigger("focus"); if (wasOpen) { return; } input.autocomplete("search", ""); }) .css({ 'position': 'absolute', }) }, _source: function (request, response) { var matcher = new RegExp($.ui.autocomplete.escapeRegex(request.term), "i"); response(this.element.children("option").map(function () { var text = $(this).text(); if (this.value && (!request.term || matcher.test(text))) return { label: text, value: text, option: this }; })); }, _removeIfInvalid: function (event, ui) { // Selected an item, nothing to do if (ui.item) { return; } // Search for a match (case-insensitive) var value = this.input.val(), valueLowerCase = value.toLowerCase(), valid = false; this.element.children("option").each(function () { if ($(this).text().toLowerCase() === valueLowerCase) { this.selected = valid = true; return false; } }); // Found a match, nothing to do if (valid) { return; } // Remove invalid value this.input .val("") .attr("title", value + "Nenhuma opção encontrada.") .tooltip("open"); this.element.val(""); this._delay(function () { this.input.tooltip("close").attr("title", ""); }, 2500); this.input.autocomplete("instance").term = ""; }, _destroy: function () { this.wrapper.remove(); this.element.show(); } }); $("#idassunto").combobox(); $("#toggle").on("click", function () { $("#idassunto").toggle(); });
Carregando...