massive refactoring, Svelte removing
This commit is contained in:
parent
aa6b5e4575
commit
ecf4feb870
22 changed files with 1121 additions and 561 deletions
145
src/addObjectForm.ts
Normal file
145
src/addObjectForm.ts
Normal file
|
|
@ -0,0 +1,145 @@
|
|||
import 'choices.js/public/assets/styles/choices.min.css'
|
||||
|
||||
// Инициализация состояний для формы "Прибор"
|
||||
const stateInstrument = {
|
||||
фиксация: 'НаМесте',
|
||||
типПрибора: 'Величина',
|
||||
величина: 'Напряжение',
|
||||
уточнение: null,
|
||||
функции: []
|
||||
};
|
||||
|
||||
// Инициализация состояний для формы "Исполнительный механизм"
|
||||
const stateMechanism = {
|
||||
ручной: false,
|
||||
направление: null as string | null
|
||||
};
|
||||
|
||||
// Настройки для выбора значений
|
||||
const функцииПоТипу = {
|
||||
ВыполняемаяФункция: [
|
||||
'Сигнализация'
|
||||
, 'АвтоматическоеРегулирование'
|
||||
, 'ВеличинаОтклоненияОтЗаданной'
|
||||
, 'Регистрация'
|
||||
],
|
||||
ФункциональныйПризнак: [
|
||||
'ЧувствительныйЭлемент'
|
||||
, 'Преобразование'
|
||||
, 'ПервичныйПоказывающийПрибор'
|
||||
, 'СтанцияУправления'
|
||||
, 'ВключениеОтключениеПереключение'
|
||||
]
|
||||
};
|
||||
|
||||
// Создание элементов формы
|
||||
export function createInstrumentForm(container: HTMLElement | null) {
|
||||
const form = document.createElement('form');
|
||||
|
||||
// Фиксация
|
||||
const fixationLabel = document.createElement('label');
|
||||
fixationLabel.innerText = 'Фиксация:';
|
||||
const fixationSelect = document.createElement('select');
|
||||
fixationSelect.innerHTML = '<option value="НаМесте">На месте</option><option value="НаЩите">На щите</option>';
|
||||
fixationSelect.value = stateInstrument.фиксация;
|
||||
fixationSelect.addEventListener('change', (e) => {
|
||||
const target = e.target as HTMLInputElement;
|
||||
stateInstrument.фиксация = target.value;
|
||||
});
|
||||
fixationLabel.appendChild(fixationSelect);
|
||||
form.appendChild(fixationLabel);
|
||||
|
||||
// Тип прибора
|
||||
const typeLabel = document.createElement('label');
|
||||
typeLabel.innerText = 'Тип прибора:';
|
||||
const typeSelect = document.createElement('select');
|
||||
typeSelect.innerHTML = '<option value="Величина">Величина</option><option value="Мультивеличина">Мультивеличина</option>';
|
||||
typeSelect.value = stateInstrument.типПрибора;
|
||||
typeSelect.addEventListener('change', (e) => {
|
||||
const target = e.target as HTMLInputElement;
|
||||
stateInstrument.типПрибора = target.value;
|
||||
});
|
||||
typeLabel.appendChild(typeSelect);
|
||||
form.appendChild(typeLabel);
|
||||
|
||||
// Величина
|
||||
const magnitudeLabel = document.createElement('label');
|
||||
magnitudeLabel.innerText = 'Величина:';
|
||||
const magnitudeSelect = document.createElement('select');
|
||||
const choices = [
|
||||
{ value: 'A', label: 'Анализ, качество' },
|
||||
{ value: 'B', label: 'Пламя, горение' },
|
||||
{ value: 'C', label: 'Дополнительная величина (C)' },
|
||||
{ value: 'D', label: 'Дополнительная величина (D)' },
|
||||
{ value: 'E', label: 'Напряжение' },
|
||||
{ value: 'F', label: 'Расход' },
|
||||
{ value: 'G', label: 'Дополнительная величина (G)' },
|
||||
{ value: 'H', label: 'Ручное воздействие' },
|
||||
{ value: 'I', label: 'Ток' },
|
||||
{ value: 'J', label: 'Мощность' },
|
||||
{ value: 'K', label: 'Время' },
|
||||
{ value: 'L', label: 'Уровень' },
|
||||
{ value: 'M', label: 'Дополнительная величина (N)' },
|
||||
{ value: 'N', label: 'Дополнительная величина (N))' },
|
||||
{ value: 'O', label: 'Дополнительная величина (O)' },
|
||||
{ value: 'P', label: 'Давление' },
|
||||
{ value: 'Q', label: 'Количество' },
|
||||
{ value: 'E', label: 'Радиоактивность' },
|
||||
{ value: 'S', label: 'Скорость, частота' },
|
||||
{ value: 'T', label: 'Температура' },
|
||||
{ value: 'U', label: 'Разнородные величины' }, // несколько величин ТОЛЬКО здесь
|
||||
{ value: 'V', label: 'Вибрация' },
|
||||
{ value: 'W', label: 'Вес' },
|
||||
{ value: 'X', label: 'Дополнительная величина (нерекомендованная буква X)' },
|
||||
{ value: 'Y', label: 'Событие' },
|
||||
{ value: 'Z', label: 'Размер' }
|
||||
];
|
||||
choices.forEach(element => {
|
||||
const opt = document.createElement<'option'>('option')
|
||||
opt.setAttribute('value', element.value)
|
||||
opt.appendChild(document.createTextNode(element.label))
|
||||
magnitudeSelect.appendChild(opt)
|
||||
});
|
||||
magnitudeSelect.addEventListener('change', (e) => {
|
||||
const target = e.target as HTMLInputElement;
|
||||
stateInstrument.величина = target.value;
|
||||
});
|
||||
magnitudeLabel.appendChild(magnitudeSelect);
|
||||
form.appendChild(magnitudeLabel);
|
||||
|
||||
// Добавить форму на страницу
|
||||
container?.appendChild(form);
|
||||
}
|
||||
|
||||
export function createMechanismForm(container: HTMLElement | null) {
|
||||
const form = document.createElement('form');
|
||||
|
||||
// Ручное управление
|
||||
const manualControlLabel = document.createElement('label');
|
||||
manualControlLabel.innerText = 'Имеет ручное управление:';
|
||||
const manualControlCheckbox = document.createElement('input');
|
||||
manualControlCheckbox.type = 'checkbox';
|
||||
manualControlCheckbox.checked = stateMechanism.ручной;
|
||||
manualControlCheckbox.addEventListener('change', (e) => {
|
||||
const target = e.target as HTMLInputElement;
|
||||
stateMechanism.ручной = target.checked;
|
||||
});
|
||||
manualControlLabel.appendChild(manualControlCheckbox);
|
||||
form.appendChild(manualControlLabel);
|
||||
|
||||
// Направление
|
||||
const directionLabel = document.createElement('label');
|
||||
directionLabel.innerText = 'Направление:';
|
||||
const directionSelect = document.createElement('select');
|
||||
directionSelect.innerHTML = '<option value="Открывается">Открывается</option><option value="Закрывается">Закрывается</option><option value="ОстаётсяНаМесте">Остаётся на месте</option>';
|
||||
directionSelect.value = stateMechanism.направление || '';
|
||||
directionSelect.addEventListener('change', (e) => {
|
||||
const target = e.target as HTMLInputElement;
|
||||
stateMechanism.направление = target.value;
|
||||
});
|
||||
directionLabel.appendChild(directionSelect);
|
||||
form.appendChild(directionLabel);
|
||||
|
||||
// Добавить форму на страницу
|
||||
container?.appendChild(form);
|
||||
}
|
||||
Loading…
Reference in a new issue