初始化

This commit is contained in:
2026-08-08 18:28:49 +08:00
parent 9bef4420e0
commit f082037a6e
854 changed files with 217171 additions and 11 deletions
+128
View File
@@ -0,0 +1,128 @@
<?php
include APP_PATH . 'app/views/layouts/admin_header.php';
?>
<div class="row">
<div class="col-md-10 col-md-offset-1">
<div class="box box-primary">
<div class="box-header with-border">
<h3 class="box-title"><i class="fa fa-edit"></i> 编辑采购订单</h3>
</div>
<form method="post">
<input type="hidden" name="csrf_token" value="<?php echo htmlspecialchars($csrfToken); ?>">
<div class="box-body">
<div class="row">
<div class="col-md-4">
<div class="form-group">
<label>采购单号 <span class="text-red">*</span></label>
<input type="text" name="order_no" class="form-control" value="<?php echo htmlspecialchars($order['order_no']); ?>" required>
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label>供应商</label>
<select name="supplier_id" class="form-control">
<?php foreach ($suppliers as $s): ?>
<option value="<?php echo $s['id']; ?>" <?php echo $s['id'] == $order['supplier_id'] ? 'selected' : ''; ?>><?php echo htmlspecialchars($s['name']); ?></option>
<?php endforeach; ?>
</select>
</div>
</div>
<div class="col-md-2">
<div class="form-group">
<label>采购日期</label>
<input type="date" name="order_date" class="form-control" value="<?php echo htmlspecialchars($order['order_date']); ?>">
</div>
</div>
<div class="col-md-2">
<div class="form-group">
<label>状态</label>
<select name="status" class="form-control">
<option value="pending" <?php echo ($order['status'] ?? '') === 'pending' ? 'selected' : ''; ?>>待确认</option>
<option value="confirmed" <?php echo ($order['status'] ?? '') === 'confirmed' ? 'selected' : ''; ?>>已确认</option>
<option value="received" <?php echo ($order['status'] ?? '') === 'received' ? 'selected' : ''; ?>>已收货</option>
<option value="cancelled" <?php echo ($order['status'] ?? '') === 'cancelled' ? 'selected' : ''; ?>>已取消</option>
</select>
</div>
</div>
</div>
<h4>采购明细</h4>
<table class="table table-bordered" id="itemsTable">
<thead>
<tr>
<th>产品名称</th>
<th style="width:120px">规格型号</th>
<th style="width:80px">数量</th>
<th style="width:80px">单位</th>
<th style="width:100px">单价</th>
<th style="width:100px">金额</th>
<th style="width:60px">操作</th>
</tr>
</thead>
<tbody id="itemsBody">
<?php if (!empty($items)): ?>
<?php foreach ($items as $item): ?>
<tr>
<td><input type="text" name="product_name[]" class="form-control" value="<?php echo htmlspecialchars($item['product_name']); ?>"></td>
<td><input type="text" name="product_model[]" class="form-control" value="<?php echo htmlspecialchars($item['product_model']); ?>"></td>
<td><input type="number" name="quantity[]" class="form-control qty" value="<?php echo $item['quantity']; ?>" min="1" onchange="calcRow(this)"></td>
<td><input type="text" name="unit[]" class="form-control" value="<?php echo htmlspecialchars($item['unit']); ?>"></td>
<td><input type="number" name="unit_price[]" class="form-control price" value="<?php echo $item['unit_price']; ?>" step="0.01" onchange="calcRow(this)"></td>
<td><input type="text" class="form-control amount" readonly value="<?php echo number_format($item['amount'], 2); ?>"></td>
<td><button type="button" class="btn btn-xs btn-danger" onclick="removeRow(this)"><i class="fa fa-times"></i></button></td>
</tr>
<?php endforeach; ?>
<?php endif; ?>
</tbody>
<tfoot>
<tr>
<td colspan="7">
<button type="button" class="btn btn-sm btn-success" onclick="addRow()"><i class="fa fa-plus"></i> 添加行</button>
</td>
</tr>
</tfoot>
</table>
<div class="form-group">
<label>备注</label>
<textarea name="remark" class="form-control" rows="2"><?php echo htmlspecialchars($order['remark']); ?></textarea>
</div>
</div>
<div class="box-footer">
<button type="submit" class="btn btn-primary"><i class="fa fa-save"></i> 保存</button>
<a href="<?php echo BASE_URL; ?>/Inventory/purchase" class="btn btn-default">返回</a>
</div>
</form>
</div>
</div>
</div>
<script>
function addRow() {
var tbody = document.getElementById('itemsBody');
var row = document.createElement('tr');
row.innerHTML = '<td><input type="text" name="product_name[]" class="form-control"></td>' +
'<td><input type="text" name="product_model[]" class="form-control"></td>' +
'<td><input type="number" name="quantity[]" class="form-control qty" value="1" min="1" onchange="calcRow(this)"></td>' +
'<td><input type="text" name="unit[]" class="form-control" value="个"></td>' +
'<td><input type="number" name="unit_price[]" class="form-control price" value="0" step="0.01" onchange="calcRow(this)"></td>' +
'<td><input type="text" class="form-control amount" readonly value="0.00"></td>' +
'<td><button type="button" class="btn btn-xs btn-danger" onclick="removeRow(this)"><i class="fa fa-times"></i></button></td>';
tbody.appendChild(row);
}
function removeRow(btn) {
var tbody = document.getElementById('itemsBody');
if (tbody.rows.length > 1) {
btn.closest('tr').remove();
}
}
function calcRow(el) {
var row = el.closest('tr');
var qty = parseFloat(row.querySelector('.qty').value) || 0;
var price = parseFloat(row.querySelector('.price').value) || 0;
row.querySelector('.amount').value = (qty * price).toFixed(2);
}
</script>
<?php include APP_PATH . 'app/views/layouts/admin_footer.php'; ?>