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. 53
      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;}
.rm_profile {overflow:hidden;}
.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 %}
<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 id="blackbox">
<div class='bb-triangle'></div>
@ -33,17 +49,6 @@
</div>
{% 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 class='profile_label'>
Фамилия, Имя, Отчество
@ -543,8 +548,8 @@
<script>
var paramsType,
profileForm = $("#profile-form"),
profileSearch =$("#searchAPI", profileForm),
profileBossName = $("#id_boss_name", profileForm),
profileSearch = $("#searchAPI"),
profileBossName = ("#id_boss_name", profileForm),
profileBossSurname =$("#id_boss_surname", profileForm),
profileBossMiddleName =$("#id_boss_midname", profileForm),
profileInn = $("#id_inn", profileForm),
@ -552,9 +557,7 @@
profileOqrn = $("#id_ogrn", profileForm),
profileAddress = $("#id_address", profileForm),
profileLegalAddress = $("#id_jur_address", profileForm),
profilePostalAddress = $("#id_real_address", profileForm),
profileInputs = [];
profilePostalAddress = $("#id_real_address", profileForm);
function getType() {
var False = false,
@ -587,7 +590,9 @@
profileAddress.val(data.address.value);
profileLegalAddress.val(data.address.value);
}
if (data.management) {
var management = data.management;
if (management.post) {profileBossTitle.val(data.management.post)}
if (management.name) {
@ -606,38 +611,39 @@
profileBossName.val(getPartOfPersonName(profileFullName, 1));
profileBossMiddleName.val(getPartOfPersonName(profileFullName, 2));
}
if (data.address) {
var address = data.address.value;
profileAddress.val(address);
profileLegalAddress.val(address);
profilePostalAddress.val(address);
}
if (data.state && data.state.registration_date) {
profileRegDate.val((new Date(data.state.registration_date)).toLocaleDateString())
}
}
profileInn.val(data.inn);
profileKpp.val(data.kpp);
profileOqrn.val(data.ogrn);
profileSearch.val('');
}
paramsType = getType();
if (paramsType === "LEGAL") {
var profileOrgName = $('#id_name', profileForm),
profileOrgFullName = $('#id_full_name', profileForm),
profileBossTitle = $('#id_boss_title', profileForm);
profileInputs = [profileOrgName, profileOrgFullName, profileInn, profileKpp, profileOqrn]
} else {
var profileRegDate = $('#id_ip_reg_date', profileForm);
profileInputs = [profileSearch, profileInn, profileKpp, profileOqrn];
}
for (var index = profileInputs.length - 1; index >= 0; --index) {
profileInputs[index].suggestions({
profileSearch.suggestions({
token: "{{ dadata_api_key }}",
type: "PARTY",
params: {
@ -646,7 +652,6 @@
count: 5,
onSelect: showSuggestion
});
}
</script>

Loading…
Cancel
Save