refactor serch in DaData individual businessman

remotes/origin/mitri4
Dmitriy Shesterkin 9 years ago
parent d525877c91
commit 0368c45a96
  1. 7
      project/static/css/style.css
  2. 69
      project/templates/customer/profile/edit.html

@ -684,3 +684,10 @@ a.popup-unreg {background:url(../img/popup-trash.png) no-repeat 3px center;}
.italic {font-style: italic;} .italic {font-style: italic;}
.rm_profile {overflow:hidden;} .rm_profile {overflow:hidden;}
.rm_profile .list-col2 {border-left:none;} .rm_profile .list-col2 {border-left:none;}
/* profile */
.search-property {
padding: 15px;
background: rgba(128, 128, 128, 0.1);
}

@ -5,6 +5,22 @@
{% block content %} {% block content %}
<h2>Редактирование реквизитов{% if profile.is_ip %} ИП{% elif profile.is_org %} организации{% endif %}</h2> <h2>Редактирование реквизитов{% if profile.is_ip %} ИП{% elif profile.is_org %} организации{% endif %}</h2>
<div class="search-property">
<div id="searchProperty" class="field">
<div class='profile_label'>
Поиск реквизитов:
</div>
<div class='long-input profile_field'>
<input id="searchAPI"
maxlength="256"
name="searchAPI"
type="text"
placeholder="Введите название в свободной форме, адрес, ИНН или ОГРН">
</div>
<div class="clear"></div>
</div>
</div>
<div class="profile-form content-white rel"> <div class="profile-form content-white rel">
<div id="blackbox"> <div id="blackbox">
<div class='bb-triangle'></div> <div class='bb-triangle'></div>
@ -33,17 +49,6 @@
</div> </div>
{% if profile.is_ip %} {% if profile.is_ip %}
<div id="boss_fio" class="field">
<div class='profile_label'>
Индивидуальный предприниматель
</div>
<div class='long-input profile_field'>
<input id="searchAPI" maxlength="256" name="searchAPI" type="text">
<span class="help-text">Остальные необходимые поля заполнятся по найденным данным</span>
</div>
<div class="clear"></div>
</div>
<div id="boss_fio" class="field"> <div id="boss_fio" class="field">
<div class='profile_label'> <div class='profile_label'>
Фамилия, Имя, Отчество Фамилия, Имя, Отчество
@ -543,8 +548,8 @@
<script> <script>
var paramsType, var paramsType,
profileForm = $("#profile-form"), profileForm = $("#profile-form"),
profileSearch =$("#searchAPI", profileForm), profileSearch = $("#searchAPI"),
profileBossName = $("#id_boss_name", profileForm), profileBossName = ("#id_boss_name", profileForm),
profileBossSurname =$("#id_boss_surname", profileForm), profileBossSurname =$("#id_boss_surname", profileForm),
profileBossMiddleName =$("#id_boss_midname", profileForm), profileBossMiddleName =$("#id_boss_midname", profileForm),
profileInn = $("#id_inn", profileForm), profileInn = $("#id_inn", profileForm),
@ -552,9 +557,7 @@
profileOqrn = $("#id_ogrn", profileForm), profileOqrn = $("#id_ogrn", profileForm),
profileAddress = $("#id_address", profileForm), profileAddress = $("#id_address", profileForm),
profileLegalAddress = $("#id_jur_address", profileForm), profileLegalAddress = $("#id_jur_address", profileForm),
profilePostalAddress = $("#id_real_address", profileForm), profilePostalAddress = $("#id_real_address", profileForm);
profileInputs = [];
function getType() { function getType() {
var False = false, var False = false,
@ -587,7 +590,9 @@
profileAddress.val(data.address.value); profileAddress.val(data.address.value);
profileLegalAddress.val(data.address.value); profileLegalAddress.val(data.address.value);
} }
if (data.management) { if (data.management) {
var management = data.management; var management = data.management;
if (management.post) {profileBossTitle.val(data.management.post)} if (management.post) {profileBossTitle.val(data.management.post)}
if (management.name) { if (management.name) {
@ -606,47 +611,47 @@
profileBossName.val(getPartOfPersonName(profileFullName, 1)); profileBossName.val(getPartOfPersonName(profileFullName, 1));
profileBossMiddleName.val(getPartOfPersonName(profileFullName, 2)); profileBossMiddleName.val(getPartOfPersonName(profileFullName, 2));
} }
if (data.address) { if (data.address) {
var address = data.address.value; var address = data.address.value;
profileAddress.val(address); profileAddress.val(address);
profileLegalAddress.val(address); profileLegalAddress.val(address);
profilePostalAddress.val(address); profilePostalAddress.val(address);
} }
if (data.state && data.state.registration_date) { if (data.state && data.state.registration_date) {
profileRegDate.val((new Date(data.state.registration_date)).toLocaleDateString()) profileRegDate.val((new Date(data.state.registration_date)).toLocaleDateString())
} }
} }
profileInn.val(data.inn); profileInn.val(data.inn);
profileKpp.val(data.kpp); profileKpp.val(data.kpp);
profileOqrn.val(data.ogrn); profileOqrn.val(data.ogrn);
profileSearch.val('');
} }
paramsType = getType(); paramsType = getType();
if (paramsType === "LEGAL") { if (paramsType === "LEGAL") {
var profileOrgName = $('#id_name', profileForm), var profileOrgName = $('#id_name', profileForm),
profileOrgFullName = $('#id_full_name', profileForm), profileOrgFullName = $('#id_full_name', profileForm),
profileBossTitle = $('#id_boss_title', profileForm); profileBossTitle = $('#id_boss_title', profileForm);
profileInputs = [profileOrgName, profileOrgFullName, profileInn, profileKpp, profileOqrn]
} else { } else {
var profileRegDate = $('#id_ip_reg_date', profileForm); var profileRegDate = $('#id_ip_reg_date', profileForm);
profileInputs = [profileSearch, profileInn, profileKpp, profileOqrn];
} }
for (var index = profileInputs.length - 1; index >= 0; --index) { profileSearch.suggestions({
token: "{{ dadata_api_key }}",
profileInputs[index].suggestions({ type: "PARTY",
token: "{{ dadata_api_key }}", params: {
type: "PARTY", type: paramsType
params: { },
type: paramsType count: 5,
}, onSelect: showSuggestion
count: 5, });
onSelect: showSuggestion
});
}
</script> </script>

Loading…
Cancel
Save