112 lines
4.2 KiB
PHP
112 lines
4.2 KiB
PHP
<?php $isEdit = $vehicle !== null; ?>
|
||||
|
|
<div class="page-header">
|
|||
|
|
<div>
|
|||
|
|
<h1><?= $isEdit ? '编辑车辆' : '新增车辆' ?></h1>
|
|||
|
|
<?php if ($isEdit): ?>
|
|||
|
|
<p class="muted">ID:<?= (int)$vehicle['id'] ?></p>
|
|||
|
|
<?php endif; ?>
|
|||
|
|
</div>
|
|||
|
|
<a href="<?= url('vehicles/index') ?>" class="btn">返回列表</a>
|
|||
|
|
</div>
|
|||
|
|
|
|||
|
|
<form method="post" action="<?= url($isEdit ? 'vehicles/update' : 'vehicles/store') ?>" class="form">
|
|||
|
|
<input type="hidden" name="_csrf" value="<?= e(csrf_token()) ?>">
|
|||
|
|
<?php if ($isEdit): ?>
|
|||
|
|
<input type="hidden" name="id" value="<?= (int)$vehicle['id'] ?>">
|
|||
|
|
<?php endif; ?>
|
|||
|
|
|
|||
|
|
<div class="form-row">
|
|||
|
|
<label>车牌号 *</label>
|
|||
|
|
<input type="text" name="plate_number" required maxlength="20"
|
|||
|
|
value="<?= e($vehicle['plate_number'] ?? '') ?>"
|
|||
|
|
placeholder="例如:京A·88888 或 沪C12345"
|
|||
|
|
style="text-transform:uppercase;">
|
|||
|
|
<p class="muted" style="font-size:12px; margin-top:6px;">同一家庭内车牌号不可重复</p>
|
|||
|
|
</div>
|
|||
|
|
|
|||
|
|
<div class="form-row">
|
|||
|
|
<label>车型名称 *</label>
|
|||
|
|
<input type="text" name="model_name" required maxlength="100"
|
|||
|
|
value="<?= e($vehicle['model_name'] ?? '') ?>"
|
|||
|
|
placeholder="例如:特斯拉 Model Y、大众 帕萨特">
|
|||
|
|
</div>
|
|||
|
|
|
|||
|
|
<div class="form-row">
|
|||
|
|
<label>车辆类型 *</label>
|
|||
|
|
<div class="radio-group">
|
|||
|
|
<?php foreach ($typeLabels as $key => $label): ?>
|
|||
|
|
<label class="radio-label">
|
|||
|
|
<input type="radio" name="vehicle_type" value="<?= e($key) ?>"
|
|||
|
|
<?= ($vehicle['vehicle_type'] ?? 'own') === $key ? 'checked' : '' ?>>
|
|||
|
|
<span><?= e($label) ?></span>
|
|||
|
|
</label>
|
|||
|
|
<?php endforeach; ?>
|
|||
|
|
</div>
|
|||
|
|
</div>
|
|||
|
|
|
|||
|
|
<!-- 租车信息(仅租车类型显示) -->
|
|||
|
|
<div class="rental-only">
|
|||
|
|
<div class="form-row">
|
|||
|
|
<label>租车公司</label>
|
|||
|
|
<input type="text" name="rental_company" maxlength="100"
|
|||
|
|
value="<?= e($vehicle['rental_company'] ?? '') ?>"
|
|||
|
|
placeholder="例如:神州租车、一嗨租车">
|
|||
|
|
</div>
|
|||
|
|
|
|||
|
|
<div class="form-row">
|
|||
|
|
<label>租车订单号</label>
|
|||
|
|
<input type="text" name="rental_order_no" maxlength="50"
|
|||
|
|
value="<?= e($vehicle['rental_order_no'] ?? '') ?>"
|
|||
|
|
placeholder="例如:RENT20260801001">
|
|||
|
|
</div>
|
|||
|
|
</div>
|
|||
|
|
|
|||
|
|
<!-- 默认自有车(仅自有车类型显示) -->
|
|||
|
|
<div class="own-only">
|
|||
|
|
<div class="form-row">
|
|||
|
|
<label class="checkbox-label">
|
|||
|
|
<input type="checkbox" name="is_default" value="1"
|
|||
|
|
<?= !empty($vehicle['is_default']) ? 'checked' : '' ?>>
|
|||
|
|
<span>设为默认自有车(同一家庭只能有一辆)</span>
|
|||
|
|
</label>
|
|||
|
|
<p class="muted" style="font-size:12px; margin-top:6px;">
|
|||
|
|
选择后,其他自有车的默认标记会被自动取消。
|
|||
|
|
</p>
|
|||
|
|
</div>
|
|||
|
|
</div>
|
|||
|
|
|
|||
|
|
<div class="form-row">
|
|||
|
|
<label>备注</label>
|
|||
|
|
<textarea name="notes" rows="3" placeholder="其他补充说明"><?= e($vehicle['notes'] ?? '') ?></textarea>
|
|||
|
|
</div>
|
|||
|
|
|
|||
|
|
<div class="form-actions">
|
|||
|
|
<a href="<?= url('vehicles/index') ?>" class="btn">取消</a>
|
|||
|
|
<button type="submit" class="btn-primary">保存</button>
|
|||
|
|
</div>
|
|||
|
|
</form>
|
|||
|
|
|
|||
|
|
<script>
|
|||
|
|
(function () {
|
|||
|
|
var radios = document.querySelectorAll('input[name="vehicle_type"]');
|
|||
|
|
if (!radios.length) return;
|
|||
|
|
|
|||
|
|
var rentalBlocks = document.querySelectorAll('.rental-only');
|
|||
|
|
var ownBlocks = document.querySelectorAll('.own-only');
|
|||
|
|
|
|||
|
|
function refresh() {
|
|||
|
|
var val = 'own';
|
|||
|
|
radios.forEach(function (r) { if (r.checked) val = r.value; });
|
|||
|
|
|
|||
|
|
rentalBlocks.forEach(function (el) {
|
|||
|
|
el.style.display = (val === 'rental') ? '' : 'none';
|
|||
|
|
});
|
|||
|
|
ownBlocks.forEach(function (el) {
|
|||
|
|
el.style.display = (val === 'own') ? '' : 'none';
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
radios.forEach(function (r) { r.addEventListener('change', refresh); });
|
|||
|
|
refresh();
|
|||
|
|
})();
|
|||
|
|
</script>
|