dbmsv2 init...1
This commit is contained in:
parent
c5b3e484ed
commit
86e1ebdd52
@ -58,7 +58,7 @@ class ServerPartHelper extends EquipmentHelper
|
|||||||
}
|
}
|
||||||
$extras['class'] = array_key_exists('class', $extras) ? $extras['class'] . ' select-field' : 'select-field';
|
$extras['class'] = array_key_exists('class', $extras) ? $extras['class'] . ' select-field' : 'select-field';
|
||||||
$extras['onChange'] = "document.querySelector('input[name=\'amount\']').value = this.options[this.selectedIndex].getAttribute('data-price')";
|
$extras['onChange'] = "document.querySelector('input[name=\'amount\']').value = this.options[this.selectedIndex].getAttribute('data-price')";
|
||||||
$attributes = ['data-price' => 'getPrice'];
|
$attributes = ['data-type' => 'getType', 'data-price' => 'getPrice'];
|
||||||
$form = $this->form_dropdown_common($field, $value, $viewDatas, $extras, $attributes);
|
$form = $this->form_dropdown_common($field, $value, $viewDatas, $extras, $attributes);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|||||||
25
app/Views/admin/serverpart/create_form.php
Normal file
25
app/Views/admin/serverpart/create_form.php
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
<?= $this->extend(LAYOUTS[$viewDatas['layout']]['path']) ?>
|
||||||
|
<?= $this->section('content') ?>
|
||||||
|
<script type="text/javascript" src="/js/admin/serverpart.js"></script>
|
||||||
|
<?php if ($error = session('error')): echo $viewDatas['service']->getHelper()->alert($error) ?><?php endif ?>
|
||||||
|
<div id="container" class="content">
|
||||||
|
<div class="form_top"><?= $this->include("templates/{$viewDatas['layout']}/form_content_top"); ?></div>
|
||||||
|
<?= form_open(current_url(), $viewDatas['forms']['attributes'], $viewDatas['forms']['hiddens']) ?>
|
||||||
|
<div class="action_form">
|
||||||
|
<table class="table table-bordered">
|
||||||
|
<?php foreach ($viewDatas['control']['actionFields'] as $field): ?>
|
||||||
|
<tr>
|
||||||
|
<th nowrap class="text-end"><?= $viewDatas['service']->getHelper()->getFieldLabel($field, lang("{$viewDatas['class_path']}.label.{$field}"), $viewDatas) ?></th>
|
||||||
|
<td nowrap class="text-start">
|
||||||
|
<?= $viewDatas['service']->getHelper()->getFieldForm($field, old($field) ?? ($viewDatas['control']['form_datas'][$field] ?? null), $viewDatas) ?>
|
||||||
|
<span><?= validation_show_error($field); ?></span>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</table>
|
||||||
|
<div class="text-center"><?= form_submit('', '입력', array("class" => "btn btn-outline btn-primary")); ?></div>
|
||||||
|
<?= form_close(); ?>
|
||||||
|
</div>
|
||||||
|
<div class="form_bottom"><?= $this->include("templates/{$viewDatas['layout']}/form_content_bottom"); ?></div>
|
||||||
|
</div>
|
||||||
|
<?= $this->endSection() ?>
|
||||||
24
app/Views/admin/serverpart/modify_form.php
Normal file
24
app/Views/admin/serverpart/modify_form.php
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
<?= $this->extend(LAYOUTS[$viewDatas['layout']]['path']) ?>
|
||||||
|
<?= $this->section('content') ?>
|
||||||
|
<?php if ($error = session('error')): echo $viewDatas['service']->getHelper()->alert($error) ?><?php endif ?>
|
||||||
|
<div id="container" class="content">
|
||||||
|
<div class="form_top"><?= $this->include("templates/{$viewDatas['layout']}/form_content_top"); ?></div>
|
||||||
|
<?= form_open(current_url(), ['id' => 'action_form', ...$viewDatas['forms']['attributes']], $viewDatas['forms']['hiddens']) ?>
|
||||||
|
<div class="action_form">
|
||||||
|
<table class="table table-bordered">
|
||||||
|
<?php foreach ($viewDatas['control']['actionFields'] as $field): ?>
|
||||||
|
<tr>
|
||||||
|
<th nowrap class="text-end"><?= $viewDatas['service']->getHelper()->getFieldLabel($field, lang("{$viewDatas['class_path']}.label.{$field}"), $viewDatas) ?></th>
|
||||||
|
<td nowrap class="text-start">
|
||||||
|
<?= $viewDatas['service']->getHelper()->getFieldForm($field, old($field) ?? $viewDatas['entity']->$field ?? null, $viewDatas) ?>
|
||||||
|
<div><?= validation_show_error($field); ?></div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</table>
|
||||||
|
<div class="text-center"><?= form_submit("", '수정', ["class" => "btn btn-outline btn-primary"]) ?></div>
|
||||||
|
<?= form_close(); ?>
|
||||||
|
</div>
|
||||||
|
<div class="form_bottom"><?= $this->include("templates/{$viewDatas['layout']}/form_content_bottom"); ?></div>
|
||||||
|
</div>
|
||||||
|
<?= $this->endSection() ?>
|
||||||
31
public/js/admin/serverpart.js
Normal file
31
public/js/admin/serverpart.js
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
const typeSelect = document.querySelector("select[name=type]");
|
||||||
|
const partSelect = document.querySelector("select[name=part_uid]");
|
||||||
|
const amountInput = document.querySelector("input[name=amount]");
|
||||||
|
|
||||||
|
// type 선택 시 part_uid 옵션 필터링
|
||||||
|
typeSelect.addEventListener("change", function () {
|
||||||
|
let selectedType = this.value;
|
||||||
|
|
||||||
|
for (let option of partSelect.options) {
|
||||||
|
if (option.value === "") {
|
||||||
|
option.style.display = ""; // "부품정보 선택"은 항상 표시
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (!selectedType || option.dataset.type === selectedType) {
|
||||||
|
option.style.display = "";
|
||||||
|
} else {
|
||||||
|
option.style.display = "none";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 선택 초기화
|
||||||
|
partSelect.value = "";
|
||||||
|
amountInput.value = "";
|
||||||
|
});
|
||||||
|
|
||||||
|
// part_uid 선택 시 amount 자동 반영
|
||||||
|
partSelect.addEventListener("change", function () {
|
||||||
|
let selectedOption = this.options[this.selectedIndex];
|
||||||
|
let price = selectedOption.getAttribute("data-price") || "";
|
||||||
|
amountInput.value = price;
|
||||||
|
});
|
||||||
Loading…
Reference in New Issue
Block a user