OneBot: Leantime 改造版源码(BOM/Univer 表格/AI 接管/品牌替换等)
This commit is contained in:
164
app/Domain/Bom/Templates/refDetail.blade.php
Normal file
164
app/Domain/Bom/Templates/refDetail.blade.php
Normal file
@@ -0,0 +1,164 @@
|
||||
@extends($layout)
|
||||
@section('content')
|
||||
|
||||
@php
|
||||
$m = $master ?? [];
|
||||
$masterBom = $m['bom'] ?? [];
|
||||
$masterColumns = $m['columns'] ?? [];
|
||||
$masterItems = $m['items'] ?? [];
|
||||
$imageColumns = $m['imageColumns'] ?? [];
|
||||
$fileColumns = $m['fileColumns'] ?? [];
|
||||
$refId = (int)($ref['id'] ?? 0);
|
||||
$typeNames = ['bom'=>'BOM','process'=>'工艺文件','tooling'=>'工具清单'];
|
||||
$typeName = $typeNames[$masterBom['type'] ?? 'bom'] ?? 'BOM';
|
||||
@endphp
|
||||
|
||||
<div class="pageheader">
|
||||
<div class="pageicon"><span class="fa fa-fw fa-link"></span></div>
|
||||
<div class="pagetitle">
|
||||
<h1>{{ $masterBom['productName'] ?? $masterBom['bomNo'] ?? $typeName }}</h1>
|
||||
<p>引用视图 — {{ $typeName }}(全局数据只读,可追加项目级列)</p>
|
||||
</div>
|
||||
<div class="maincontent" style="margin-top:16px;">
|
||||
<a href="{{ BASE_URL }}/bom/refs" class="btn btn-default"><i class="fa fa-arrow-left"></i> 返回引用列表</a>
|
||||
<button type="button" class="btn btn-primary" id="btnAddRefColumn"><i class="fa fa-columns"></i> 增加项目列</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="maincontent">
|
||||
<div class="maincontentinner">
|
||||
<div id="refAlert" class="alert" style="display:none;"></div>
|
||||
|
||||
<div style="overflow-x:auto;max-width:100%;border:1px solid #e5e5e5;border-radius:4px;">
|
||||
<table class="table table-bordered table-striped" id="refTable" style="margin-bottom:0;white-space:nowrap;">
|
||||
<thead>
|
||||
<tr>
|
||||
@foreach ($fixedColumns as $key => $label)
|
||||
<th data-key="{{ $key }}">{{ $label }}</th>
|
||||
@endforeach
|
||||
@foreach ($masterColumns as $col)
|
||||
<th data-key="{{ $col['key'] }}">{{ $col['label'] ?: $col['key'] }}</th>
|
||||
@endforeach
|
||||
@foreach ($refColumns as $col)
|
||||
<th data-ref-column-id="{{ $col['id'] }}" data-key="{{ $col['key'] }}">
|
||||
{{ $col['label'] ?: $col['key'] }}
|
||||
<a href="javascript:void(0)" class="btnDelRefColumn" data-id="{{ $col['id'] }}" title="删除列">×</a>
|
||||
</th>
|
||||
@endforeach
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@forelse ($masterItems as $item)
|
||||
<tr data-item-id="{{ $item['id'] }}">
|
||||
@foreach ($fixedColumns as $key => $label)
|
||||
<td>{{ $item[$key] ?? '' }}</td>
|
||||
@endforeach
|
||||
@foreach ($masterColumns as $col)
|
||||
<td>
|
||||
@if (in_array($col['key'], $imageColumns, true))
|
||||
@php $attach = json_decode((string)($item[$col['key']] ?? ''), true); @endphp
|
||||
@if (is_array($attach))
|
||||
@foreach ($attach as $a)
|
||||
<a href="{{ $a['url'] ?? '#' }}" target="_blank"><img src="{{ $a['url'] ?? '' }}" style="height:42px;width:auto;margin:2px;border-radius:2px;"></a>
|
||||
@endforeach
|
||||
@endif
|
||||
@elseif (in_array($col['key'], $fileColumns, true))
|
||||
@php $attach = json_decode((string)($item[$col['key']] ?? ''), true); @endphp
|
||||
@if (is_array($attach))
|
||||
@foreach ($attach as $a)
|
||||
<a href="{{ $a['url'] ?? '#' }}" target="_blank">{{ $a['name'] ?? '下载' }}</a><br>
|
||||
@endforeach
|
||||
@endif
|
||||
@else
|
||||
{{ $item[$col['key']] ?? '' }}
|
||||
@endif
|
||||
</td>
|
||||
@endforeach
|
||||
@foreach ($refColumns as $col)
|
||||
@php
|
||||
$cid = (int)$col['id'];
|
||||
$val = $refValues[(int)$item['id']][$cid] ?? '';
|
||||
@endphp
|
||||
<td><input type="text" class="form-control refVal" data-column-id="{{ $cid }}" value="{{ $val }}"></td>
|
||||
@endforeach
|
||||
</tr>
|
||||
@empty
|
||||
<tr><td colspan="99" class="text-center text-muted">暂无明细</td></tr>
|
||||
@endforelse
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@once
|
||||
@push('scripts')
|
||||
<script>
|
||||
jQuery(document).ready(function () {
|
||||
var REF_ID = {{ $refId }};
|
||||
var BASE = '{{ BASE_URL }}';
|
||||
var csrf = function () { return jQuery('meta[name="csrf-token"]').attr('content') || ''; };
|
||||
|
||||
function showAlert(msg, type) {
|
||||
var el = jQuery('#refAlert');
|
||||
el.attr('class', 'alert alert-' + (type || 'info')).text(msg).show();
|
||||
}
|
||||
|
||||
// 保存项目级追加值(blur 触发)
|
||||
jQuery('#refTable').on('blur change', '.refVal', function () {
|
||||
var tr = jQuery(this).closest('tr');
|
||||
var itemId = tr.data('item-id');
|
||||
var columnId = jQuery(this).data('column-id');
|
||||
var value = jQuery(this).val();
|
||||
jQuery.ajax({
|
||||
url: BASE + '/bom/api/ref/' + REF_ID + '/value',
|
||||
method: 'POST',
|
||||
contentType: 'application/json',
|
||||
headers: { 'X-CSRF-TOKEN': csrf() },
|
||||
data: JSON.stringify({ columnId: columnId, itemId: itemId, value: value }),
|
||||
dataType: 'json'
|
||||
}).fail(function (xhr) {
|
||||
var m = xhr.responseJSON && xhr.responseJSON.message ? xhr.responseJSON.message : ('HTTP ' + xhr.status);
|
||||
showAlert(m, 'danger');
|
||||
});
|
||||
});
|
||||
|
||||
// 增加项目级列
|
||||
jQuery('#btnAddRefColumn').on('click', function () {
|
||||
var key = prompt('项目列标识(如:日期、库存、采购数量)', '');
|
||||
if (!key) { return; }
|
||||
var label = prompt('列显示名', key);
|
||||
if (label === null) { return; }
|
||||
jQuery.ajax({
|
||||
url: BASE + '/bom/api/ref/' + REF_ID + '/column',
|
||||
method: 'POST',
|
||||
contentType: 'application/json',
|
||||
headers: { 'X-CSRF-TOKEN': csrf() },
|
||||
data: JSON.stringify({ key: key, label: label }),
|
||||
dataType: 'json',
|
||||
success: function () { location.reload(); },
|
||||
error: function (xhr) {
|
||||
alert(xhr.responseJSON && xhr.responseJSON.message ? xhr.responseJSON.message : '失败');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// 删除项目级列
|
||||
jQuery('#refTable').on('click', '.btnDelRefColumn', function () {
|
||||
if (!confirm('确定删除该项目级列?相关数据将删除,不影响全局主数据。')) { return; }
|
||||
var id = jQuery(this).data('id');
|
||||
jQuery.ajax({
|
||||
url: BASE + '/bom/api/ref-column/' + id,
|
||||
method: 'DELETE',
|
||||
headers: { 'X-CSRF-TOKEN': csrf() },
|
||||
success: function () { location.reload(); },
|
||||
error: function () { alert('删除失败'); }
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@endpush
|
||||
@endonce
|
||||
|
||||
@endsection
|
||||
Reference in New Issue
Block a user