Files
Leantime/app/Domain/Bom/Templates/show.blade.php

130 lines
4.5 KiB
PHP

@extends($layout)
@section('content')
@php
$type = $type ?? 'bom';
$typeNames = [
'bom' => 'BOM',
'process' => '工艺文件',
'tooling' => '工具清单',
];
$typeName = $typeNames[$type] ?? 'BOM';
@endphp
<div class="pageheader">
<div class="pageicon"><span class="fa fa-fw fa-list-check"></span></div>
<div class="pagetitle">
<h1>{{ $typeName }}</h1>
<p>{{ __('text.bom_subtitle', '全局主数据管理,可被项目引用') }}</p>
</div>
</div>
<div class="maincontent">
<div class="maincontentinner">
<div class="row" style="margin-bottom:16px;">
<div class="col-md-12">
<button type="button" class="btn btn-primary" id="btnNewBom">
<i class="fa fa-plus"></i> 新建 {{ $typeName }}
</button>
</div>
</div>
@if (empty($boms))
<div class="alert alert-info">暂无 {{ $typeName }},点击「新建 {{ $typeName }}」开始。</div>
@else
<div class="table-responsive">
<table class="table table-striped table-bordered">
<thead>
<tr>
<th>编号</th>
<th>名称</th>
<th>规格型号</th>
<th>图号</th>
<th>版本</th>
<th>类型</th>
<th style="width:160px;">操作</th>
</tr>
</thead>
<tbody>
@foreach ($boms as $bom)
<tr>
<td>{{ $bom['bomNo'] }}</td>
<td><a href="{{ BASE_URL }}/bom/show/{{ $bom['id'] }}">{{ $bom['productName'] }}</a></td>
<td>{{ $bom['specification'] }}</td>
<td>{{ $bom['drawingNo'] }}</td>
<td>{{ $bom['version'] }}</td>
<td>
<span class="label {{ (int)($bom['projectId'] ?? 0) === 0 ? 'label-success' : 'label-default' }}">
{{ (int)($bom['projectId'] ?? 0) === 0 ? '全局' : '项目私有' }}
</span>
</td>
<td>
<a class="btn btn-xs btn-default" href="{{ BASE_URL }}/bom/show/{{ $bom['id'] }}">打开</a>
<button class="btn btn-xs btn-danger btnDeleteBom" data-id="{{ $bom['id'] }}">删除</button>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
@endif
</div>
</div>
@once
@push('scripts')
<script>
jQuery(document).ready(function () {
var csrf = function () {
return jQuery('meta[name="csrf-token"]').attr('content') || '';
};
jQuery('#btnNewBom').on('click', function () {
var bomNo = prompt("编号", "");
if (bomNo === null) { return; }
var productName = prompt("名称", "");
if (productName === null) { return; }
jQuery.ajax({
url: '{{ BASE_URL }}/bom/api',
method: 'POST',
contentType: 'application/json',
headers: { 'X-CSRF-TOKEN': csrf() },
data: JSON.stringify({ bomNo: bomNo, productName: productName, type: '{{ $type }}', projectId: 0 }),
success: function (res) {
if (res.status === 'success') {
location.href = '{{ BASE_URL }}/bom/show/' + res.id;
} else {
alert(res.message || '创建失败');
}
},
error: function (xhr) {
alert('创建失败: ' + (xhr.responseJSON && xhr.responseJSON.message ? xhr.responseJSON.message : xhr.status));
}
});
});
jQuery('.btnDeleteBom').on('click', function () {
var id = jQuery(this).data('id');
if (!confirm("{{ __('text.confirm_delete') }}")) { return; }
jQuery.ajax({
url: '{{ BASE_URL }}/bom/api/' + id,
method: 'DELETE',
headers: { 'X-CSRF-TOKEN': csrf() },
success: function (res) {
location.reload();
},
error: function (xhr) {
alert('删除失败');
}
});
});
});
</script>
@endpush
@endonce
@endsection