You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
665 lines
28 KiB
665 lines
28 KiB
2 years ago
|
<!DOCTYPE html>
|
||
|
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
|
||
|
<head>
|
||
|
<th:block th:include="include :: header('BOM列表')"/>
|
||
|
<script type="text/javascript" th:src="@{/js/axios.min.js}"></script>
|
||
|
</head>
|
||
|
<body class="gray-bg">
|
||
|
<div class="container-div">
|
||
|
<div class="row">
|
||
|
<div class="col-sm-12 search-collapse">
|
||
|
<form id="formId">
|
||
|
<div class="select-list">
|
||
|
<ul>
|
||
|
<li>
|
||
|
<label>清单编号:</label>
|
||
|
<input type="text" name="bomCode"/>
|
||
|
</li>
|
||
|
<li>
|
||
|
<label>清单名称:</label>
|
||
|
<input type="text" name="bomName"/>
|
||
|
</li>
|
||
|
<li>
|
||
|
<label>客户代码:</label>
|
||
|
<input type="text" name="enterpriseCode"/>
|
||
|
</li>
|
||
|
<li>
|
||
|
<label>客户料号:</label>
|
||
|
<input type="text" name="customerNumber"/>
|
||
|
</li>
|
||
|
<li>
|
||
|
<label>成品代码:</label>
|
||
|
<!-- <select name="finishProductCode">-->
|
||
|
<!-- <option value="">所有</option>-->
|
||
|
<!-- <option value="-1">代码生成请选择字典属性</option>-->
|
||
|
<!-- </select>-->
|
||
|
<input type="text" name="finishProductCode"/>
|
||
|
|
||
|
</li>
|
||
|
<li>
|
||
|
<label>确认否:</label>
|
||
|
<select name="confirmNo" th:with="type=${@dict.getType('sys_whether')}">
|
||
|
<option value="">所有</option>
|
||
|
<option th:each="dict : ${type}" th:text="${dict.dictLabel}"
|
||
|
th:value="${dict.dictValue}"></option>
|
||
|
</select>
|
||
|
</li>
|
||
|
<li>
|
||
|
<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
|
||
|
class="fa fa-search"></i> 搜索</a>
|
||
|
<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
|
||
|
class="fa fa-refresh"></i> 重置</a>
|
||
|
</li>
|
||
|
</ul>
|
||
|
</div>
|
||
|
</form>
|
||
|
</div>
|
||
|
|
||
|
<div class="btn-group-sm" id="toolbar" role="group">
|
||
|
<a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="system:bom:add">
|
||
|
<i class="fa fa-plus"></i> 添加
|
||
|
</a>
|
||
|
<a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="system:bom:edit">
|
||
|
<i class="fa fa-edit"></i> 修改
|
||
|
</a>
|
||
|
<a class="btn btn-danger multiple disabled" onclick="removeBom()"
|
||
|
shiro:hasPermission="system:bom:remove">
|
||
|
<i class="fa fa-remove"></i> 删除
|
||
|
</a>
|
||
|
<a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:bom:export">
|
||
|
<i class="fa fa-download"></i> 导出
|
||
|
</a>
|
||
|
<a class="btn btn-warning" onclick="exportBomDetail()" shiro:hasPermission="system:bom:export">
|
||
|
<i class="fa fa-download"></i> 单个导出
|
||
|
</a>
|
||
|
<a class="btn btn-success" onclick="bomConfirm()">
|
||
|
|
||
|
<i class="fa fa-hand-grab-o"></i> 确认
|
||
|
</a>
|
||
|
</div>
|
||
|
<div class="col-sm-12 select-table table-striped">
|
||
|
<table id="bootstrap-table" style="white-space: nowrap"></table>
|
||
|
</div>
|
||
|
</div>
|
||
|
</div>
|
||
|
|
||
|
<!--确认-->
|
||
|
<div class="modal fade" id="confirmModel">
|
||
|
<div class="modal-dialog">
|
||
|
<div class="modal-content message_align">
|
||
|
<div class="modal-header">
|
||
|
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
|
||
|
aria-hidden="true">×</span></button>
|
||
|
<h4 class="modal-title">确认信息</h4>
|
||
|
</div>
|
||
|
<div class="modal-body" style="height: 180px">
|
||
|
<form id="form-confirm-edit">
|
||
|
<div class="form-group" style="display: none">
|
||
|
<label class="col-sm-3 control-label is-required">Bomid:</label>
|
||
|
<div class="col-sm-8">
|
||
|
<input id="bomId" name="bomId" class="form-control" type="text" required
|
||
|
readonly>
|
||
|
</div>
|
||
|
</div>
|
||
|
<div class="form-group">
|
||
|
<label class="col-sm-3 control-label">确认否:</label>
|
||
|
<div class="col-sm-8">
|
||
|
<select id="confirmNo" name="confirmNo" class="form-control" th:with="type=${@dict.getType('sys_whether')}">
|
||
|
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
|
||
|
</select>
|
||
|
</div>
|
||
|
</div>
|
||
|
<div class="form-group">
|
||
|
<label class="col-sm-3 control-label">确认日期:</label>
|
||
|
<div class="col-sm-8">
|
||
|
<div class="input-group date">
|
||
|
<input id="confirmTime" name="confirmTime" class="form-control" placeholder="yyyy-mm-dd hh:ii:ss" type="text">
|
||
|
<span class="input-group-addon"><i class="fa fa-calendar"></i></span>
|
||
|
</div>
|
||
|
</div>
|
||
|
</div>
|
||
|
<div class="form-group">
|
||
|
<label class="col-sm-3 control-label">确认人:</label>
|
||
|
<div class="col-sm-8">
|
||
|
<input id="confirmName" name="confirmName" class="form-control" type="text">
|
||
|
</div>
|
||
|
</div>
|
||
|
</form>
|
||
|
</div>
|
||
|
<div class="modal-footer">
|
||
|
<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
|
||
|
<button type="button" onclick="ConfirmSubmit()" class="btn btn-success" data-dismiss="modal">确定</button>
|
||
|
</div>
|
||
|
</div>
|
||
|
</div>
|
||
|
</div>
|
||
|
<div class="alert alert-success hide">bom清单已确认</div>
|
||
|
|
||
|
<th:block th:include="include :: footer"/>
|
||
|
<th:block th:include="include :: datetimepicker-js"/>
|
||
|
|
||
|
<script th:inline="javascript">
|
||
|
var editFlag = [[${@permission.hasPermi('system:bom:edit')}]];
|
||
|
var removeFlag = [[${@permission.hasPermi('system:bom:remove')}]];
|
||
|
var currentVersionDatas = [[${@dict.getType('sys_whether')}]];
|
||
|
var confirmNoDatas = [[${@dict.getType('sys_whether')}]];
|
||
|
var prefix = ctx + "system/bom";
|
||
|
|
||
|
$(function () {
|
||
|
var options = {
|
||
|
url: prefix + "/list",
|
||
|
createUrl: prefix + "/add",
|
||
|
updateUrl: prefix + "/edit/{id}",
|
||
|
removeUrl: prefix + "/remove",
|
||
|
exportUrl: prefix + "/export",
|
||
|
clickToSelect: true,
|
||
|
detailView: true,
|
||
|
modalName: "BOM",
|
||
|
columns: [{
|
||
|
checkbox: true
|
||
|
},
|
||
|
{
|
||
|
field: 'bomId',
|
||
|
title: 'BOMid',
|
||
|
visible: false
|
||
|
},
|
||
|
{
|
||
|
field: 'confirmNo',
|
||
|
title: '确认否',
|
||
|
formatter: function (value, row, index) {
|
||
|
// return $.table.selectDictLabel(confirmNoDatas, value);
|
||
|
|
||
|
var actions = [];
|
||
|
if ($.table.selectDictLabel(confirmNoDatas, value) == "<span class=''>是</span>") {
|
||
|
actions.push('<a class="btn btn-primary btn-xs disabled">已确认</a> ');
|
||
|
} else {
|
||
|
actions.push('<a class="btn btn-danger btn-xs disabled">未确认</a> ');
|
||
|
}
|
||
|
return actions.join('');
|
||
|
}
|
||
|
},
|
||
|
{
|
||
|
field: 'bomCode',
|
||
|
title: '清单编号'
|
||
|
},
|
||
|
{
|
||
|
field: 'bomName',
|
||
|
title: '清单名称'
|
||
|
},
|
||
|
{
|
||
|
field: 'bomProductionCost',
|
||
|
title: '生产费用'
|
||
|
},
|
||
|
{
|
||
|
field: 'versionNumber',
|
||
|
title: '版本号'
|
||
|
},
|
||
|
{
|
||
|
field: 'bomRemarks',
|
||
|
title: '备注'
|
||
|
},
|
||
|
{
|
||
|
field: 'bomCreator',
|
||
|
title: '创建人'
|
||
|
},
|
||
|
{
|
||
|
field: 'enterpriseName',
|
||
|
title: '客户名称'
|
||
|
},
|
||
|
{
|
||
|
field: 'bomTime',
|
||
|
title: '创建时间'
|
||
|
},
|
||
|
{
|
||
|
field: 'enterpriseCode',
|
||
|
title: '客户代码'
|
||
|
},
|
||
|
{
|
||
|
field: 'customerNumber',
|
||
|
title: '客户料号'
|
||
|
},
|
||
|
{
|
||
|
field: 'finishProductCode',
|
||
|
title: '成品代码'
|
||
|
},
|
||
|
{
|
||
|
field: 'finishProductName',
|
||
|
title: '成品名称'
|
||
|
},
|
||
|
{
|
||
|
field: 'specificationModel',
|
||
|
title: '规格型号'
|
||
|
},
|
||
|
{
|
||
|
field: 'inventoryUnit',
|
||
|
title: '单位'
|
||
|
},
|
||
|
{
|
||
|
field: 'currentVersion',
|
||
|
title: '当前版本',
|
||
|
formatter: function (value, row, index) {
|
||
|
return $.table.selectDictLabel(currentVersionDatas, value);
|
||
|
}
|
||
|
},
|
||
|
{
|
||
|
field: 'confirmName',
|
||
|
title: '确认人'
|
||
|
},
|
||
|
{
|
||
|
field: 'confirmTime',
|
||
|
title: '确认时间'
|
||
|
},
|
||
|
|
||
|
{
|
||
|
field: 'firstAddTime',
|
||
|
title: '录入时间',
|
||
|
formatter: function (value, row, index) {
|
||
|
if (value == null) {
|
||
|
return " ";
|
||
|
} else {
|
||
|
return value;
|
||
|
}
|
||
|
}
|
||
|
},
|
||
|
{
|
||
|
field: 'updateInfoTime',
|
||
|
title: '上次修改时间',
|
||
|
formatter: function (value, row, index) {
|
||
|
if (value == null) {
|
||
|
return " ";
|
||
|
} else {
|
||
|
var vArr = value.split(',')
|
||
|
return vArr[0];
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// {
|
||
|
// title: '操作',
|
||
|
// align: 'center',
|
||
|
// formatter: function (value, row, index) {
|
||
|
// var actions = [];
|
||
|
// actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.bomId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
|
||
|
// actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.bomId + '\')"><i class="fa fa-remove"></i>删除</a>');
|
||
|
// return actions.join('');
|
||
|
// }
|
||
|
// }
|
||
|
],
|
||
|
onExpandRow:function (index,row,$detail) {
|
||
|
// console.log(index)
|
||
|
// console.log(row.finishProductCode)
|
||
|
// console.log($detail)
|
||
|
$detail.html('<div class="box-body" style="overflow: auto;" id="out_raw_table"><table class="select-table table-container table-striped" id="raw-table"></table></div>' +
|
||
|
'<div class="box-body" style="overflow: auto;" id="out_subsidiary_table"><table class="select-table table-container table-striped" id="subsidiary-table" style="height: fit-content"></table></div>').find('table');
|
||
|
initRawDetail(index,row,$detail);
|
||
|
initSubsidiaryDetail(index,row,$detail);
|
||
|
}
|
||
|
};
|
||
|
$.table.init(options);
|
||
|
});
|
||
|
|
||
|
//初始化子表格(循环)
|
||
|
initRawDetail = function (index, row, $detail) {
|
||
|
var finishProductCode = row.finishProductCode;
|
||
|
// console.log(finishProductCode)
|
||
|
$("#raw-table").bootstrapTable({
|
||
|
url: ctx + 'system/bomrawmaterial/list',
|
||
|
contentType: "application/x-www-form-urlencoded",
|
||
|
method: 'post',
|
||
|
queryParams: function (params) {
|
||
|
var curParams = {
|
||
|
// 传递参数查询参数
|
||
|
pageSize: params.limit,
|
||
|
pageNum: params.offset / params.limit + 1,
|
||
|
finishProductCode: finishProductCode
|
||
|
};
|
||
|
// console.log(data[0].enterpriseCode)
|
||
|
return curParams
|
||
|
},
|
||
|
toolbar: false, //工具按钮用哪个容器
|
||
|
striped: true, //是否显示行间隔色
|
||
|
cache: false, //是否使用缓存,默认为true,所以一般情况下需要设置一下这个属性(*)
|
||
|
pagination: false, //是否显示分页(*)
|
||
|
sortable: false, //是否启用排序
|
||
|
pageNumber: 1, //初始化加载第一页,默认第一页
|
||
|
pageSize: 10, //每页的记录行数(*)
|
||
|
pageList: [10, 25, 50, 100], //可供选择的每页的行数(*)
|
||
|
search: false, //是否显示表格搜索,此搜索是客户端搜索,不会进服务端,所以,个人感觉意义不大
|
||
|
strictSearch: true,
|
||
|
showColumns: false, //是否显示所有的列
|
||
|
showRefresh: false, //是否显示刷新按钮
|
||
|
clickToSelect: true, //是否启用点击选中行
|
||
|
uniqueId: 'finishProductCode',
|
||
|
showToggle: false, //是否显示详细视图和列表视图的切换按钮
|
||
|
cardView: false, //是否显示详细视图
|
||
|
columns: [
|
||
|
{
|
||
|
field: 'rawMaterialId',
|
||
|
title: '原料id',
|
||
|
visible: false
|
||
|
},
|
||
|
{
|
||
|
field: 'finishProductCode',
|
||
|
title: '成品代码',
|
||
|
visible: false
|
||
|
},
|
||
|
{
|
||
|
field: 'rawMaterialCode',
|
||
|
title: '原料代码'
|
||
|
},
|
||
|
{
|
||
|
field: 'rawMaterialName',
|
||
|
title: '原料名称'
|
||
|
},
|
||
|
{
|
||
|
field: 'specificationModel',
|
||
|
title: '规格型号'
|
||
|
},
|
||
|
{
|
||
|
field: 'inventoryUnit',
|
||
|
title: '单位'
|
||
|
},
|
||
|
{
|
||
|
field: 'rawMaterialConsumption',
|
||
|
title: '用量'
|
||
|
},
|
||
|
{
|
||
|
field: 'rawMaterialLoss',
|
||
|
title: '损耗%'
|
||
|
},
|
||
|
{
|
||
|
field: 'supplierNumber',
|
||
|
title: '厂商料号'
|
||
|
},
|
||
|
{
|
||
|
field: 'finishedProductQuantity',
|
||
|
title: '成品数量'
|
||
|
},
|
||
|
{
|
||
|
field: 'remarks',
|
||
|
title: '备注说明'
|
||
|
},
|
||
|
{
|
||
|
field: 'processingCategory',
|
||
|
title: '加工类别'
|
||
|
}],
|
||
|
//无线循环取子表,直到子表里面没有记录
|
||
|
onExpandRow: function (index, row, $Subdetail) {
|
||
|
initRawDetail(index, row, $Subdetail);
|
||
|
}
|
||
|
|
||
|
})
|
||
|
}
|
||
|
//初始化子表格(循环)
|
||
|
initSubsidiaryDetail = function (index, row, $detail) {
|
||
|
var finishProductCode = row.finishProductCode;
|
||
|
// console.log(finishProductCode)
|
||
|
$("#subsidiary-table").bootstrapTable({
|
||
|
url: ctx + 'system/bomsubsidiarymaterial/list',
|
||
|
contentType: "application/x-www-form-urlencoded",
|
||
|
method: 'post',
|
||
|
queryParams: function (params) {
|
||
|
var curParams = {
|
||
|
// 传递参数查询参数
|
||
|
pageSize: params.limit,
|
||
|
pageNum: params.offset / params.limit + 1,
|
||
|
finishProductCode: finishProductCode
|
||
|
};
|
||
|
// console.log(data[0].enterpriseCode)
|
||
|
return curParams
|
||
|
},
|
||
|
toolbar: false, //工具按钮用哪个容器
|
||
|
striped: true, //是否显示行间隔色
|
||
|
cache: false, //是否使用缓存,默认为true,所以一般情况下需要设置一下这个属性(*)
|
||
|
pagination: false, //是否显示分页(*)
|
||
|
sortable: false, //是否启用排序
|
||
|
pageNumber: 1, //初始化加载第一页,默认第一页
|
||
|
pageSize: 10, //每页的记录行数(*)
|
||
|
pageList: [10, 25, 50, 100], //可供选择的每页的行数(*)
|
||
|
search: false, //是否显示表格搜索,此搜索是客户端搜索,不会进服务端,所以,个人感觉意义不大
|
||
|
strictSearch: true,
|
||
|
showColumns: false, //是否显示所有的列
|
||
|
showRefresh: false, //是否显示刷新按钮
|
||
|
clickToSelect: true, //是否启用点击选中行
|
||
|
uniqueId: 'finishProductCode',
|
||
|
showToggle: false, //是否显示详细视图和列表视图的切换按钮
|
||
|
cardView: false, //是否显示详细视图
|
||
|
columns: [
|
||
|
{
|
||
|
field: 'subsidiaryMaterialId',
|
||
|
title: 'bom辅料id',
|
||
|
visible: false
|
||
|
},
|
||
|
{
|
||
|
field: 'finishProductCode',
|
||
|
title: '成品代码',
|
||
|
visible: false
|
||
|
},
|
||
|
{
|
||
|
field: 'subsidiaryMaterialCode',
|
||
|
title: '辅料代码'
|
||
|
},
|
||
|
{
|
||
|
field: 'subsidiaryMaterialName',
|
||
|
title: '辅料名称'
|
||
|
},
|
||
|
{
|
||
|
field: 'specificationModel',
|
||
|
title: '规格型号'
|
||
|
},
|
||
|
{
|
||
|
field: 'inventoryUnit',
|
||
|
title: '单位'
|
||
|
},
|
||
|
{
|
||
|
field: 'subsidiaryMaterialConsumption',
|
||
|
title: '用量'
|
||
|
},
|
||
|
{
|
||
|
field: 'subsidiaryMaterialLoss',
|
||
|
title: '损耗%'
|
||
|
},
|
||
|
{
|
||
|
field: 'supplierNumber',
|
||
|
title: '厂商料号'
|
||
|
},
|
||
|
{
|
||
|
field: 'finishedProductQuantity',
|
||
|
title: '成品数量'
|
||
|
},
|
||
|
{
|
||
|
field: 'remarks',
|
||
|
title: '备注说明'
|
||
|
},
|
||
|
{
|
||
|
field: 'processingCategory',
|
||
|
title: '加工类别'
|
||
|
}],
|
||
|
//无线循环取子表,直到子表里面没有记录
|
||
|
onExpandRow: function (index, row, $Subdetail) {
|
||
|
initSubsidiaryDetail(index, row, $Subdetail);
|
||
|
}
|
||
|
|
||
|
})
|
||
|
}
|
||
|
|
||
|
//删除bom
|
||
|
function removeBom() {
|
||
|
var data = $("#bootstrap-table").bootstrapTable("getSelections");
|
||
|
var rawNum = 0;
|
||
|
var subsidiaryNum = 0;
|
||
|
if (data.length === 1) {
|
||
|
// console.log(data[0])
|
||
|
$.ajax({
|
||
|
url: ctx + 'system/bomrawmaterial/list',
|
||
|
type: 'post',
|
||
|
data: {
|
||
|
finishProductCode: data[0].finishProductCode
|
||
|
},
|
||
|
async: false,
|
||
|
success: function (res) {
|
||
|
rawNum = res.rows.length;
|
||
|
}
|
||
|
})
|
||
|
$.ajax({
|
||
|
url: ctx + 'system/bomsubsidiarymaterial/list',
|
||
|
type: 'post',
|
||
|
data: {
|
||
|
finishProductCode: data[0].finishProductCode
|
||
|
},
|
||
|
async: false,
|
||
|
success: function (res) {
|
||
|
subsidiaryNum = res.rows.length;
|
||
|
}
|
||
|
})
|
||
|
// console.log(rawNum)
|
||
|
// console.log(subsidiaryNum)
|
||
|
if (rawNum>0 || subsidiaryNum>0) {
|
||
|
$.modal.confirm("该bom含有"+rawNum+"条原料数据和"+subsidiaryNum+"条辅料数据,是否确认删除?",function() {
|
||
|
$.ajax({
|
||
|
url: ctx + 'system/bom/removeBom',
|
||
|
type: 'post',
|
||
|
data: {
|
||
|
bomData: JSON.stringify(data)
|
||
|
},
|
||
|
success: function (res) {
|
||
|
console.log(res)
|
||
|
$("#bootstrap-table").bootstrapTable("refresh");
|
||
|
$.modal.msgSuccess("删除成功!")
|
||
|
}
|
||
|
})
|
||
|
})
|
||
|
} else if (rawNum === 0 && subsidiaryNum === 0) {
|
||
|
$.modal.confirm("确认删除本条BOM信息吗?",function () {
|
||
|
$.ajax({
|
||
|
url: ctx + 'system/bom/remove',
|
||
|
type: 'post',
|
||
|
data: {
|
||
|
ids: data[0].bomId.toString()
|
||
|
},
|
||
|
success: function (res) {
|
||
|
console.log(res)
|
||
|
$("#bootstrap-table").bootstrapTable("refresh");
|
||
|
$.modal.msgSuccess("删除成功!")
|
||
|
}
|
||
|
|
||
|
})
|
||
|
})
|
||
|
} else {
|
||
|
$.modal.msgError("服务器出错,请联系管理员");
|
||
|
}
|
||
|
} else {
|
||
|
$.modal.msgWarning("请选择一条数据");
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// 确认
|
||
|
function bomConfirm() {
|
||
|
let data = $("#bootstrap-table").bootstrapTable("getSelections");
|
||
|
let userName = [[${@permission.getPrincipalProperty('userName')}]];
|
||
|
if (data.length === 1) {
|
||
|
$("#bomId").val(data[0].bomId)
|
||
|
$("#confirmNo").val(1).trigger("change")
|
||
|
$("#confirmName").val(userName)
|
||
|
$("#confirmTime").datetimepicker("setDate", new Date());
|
||
|
$("#confirmModel").modal("show");
|
||
|
} else {
|
||
|
$.modal.alert("请选择一条数据");
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// 确认
|
||
|
function ConfirmSubmit() {
|
||
|
var data = $("#bootstrap-table").bootstrapTable("getSelections");
|
||
|
$.ajax({
|
||
|
url: prefix + "/edit",
|
||
|
type: "post",
|
||
|
resultType: "json",
|
||
|
data: $('#form-confirm-edit').serialize(),
|
||
|
success: function (resp) {
|
||
|
$("#bootstrap-table").bootstrapTable('refresh');
|
||
|
// $(".alert-success").addClass("show");
|
||
|
// window.setTimeout(function () {
|
||
|
// $(".alert-success").removeClass("show");
|
||
|
// }, 1000);//显示的时间
|
||
|
$.modal.msgSuccess("操作成功!")
|
||
|
|
||
|
},
|
||
|
error: function () {
|
||
|
$.modal.msgError("出错了!");
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
|
||
|
//单个导出
|
||
|
function exportBomDetail() {
|
||
|
var bomData = $("#bootstrap-table").bootstrapTable("getSelections");
|
||
|
var rawData;
|
||
|
var subsidiaryData;
|
||
|
console.log(bomData)
|
||
|
if (bomData.length === 1) {
|
||
|
// console.log(data[0])
|
||
|
$.ajax({
|
||
|
url: ctx + 'system/bomrawmaterial/list',
|
||
|
type: 'post',
|
||
|
data: {
|
||
|
finishProductCode: bomData[0].finishProductCode
|
||
|
},
|
||
|
async: false,
|
||
|
success: function (res) {
|
||
|
rawData = res.rows;
|
||
|
}
|
||
|
})
|
||
|
$.ajax({
|
||
|
url: ctx + 'system/bomsubsidiarymaterial/list',
|
||
|
type: 'post',
|
||
|
data: {
|
||
|
finishProductCode: bomData[0].finishProductCode
|
||
|
},
|
||
|
async: false,
|
||
|
success: function (res) {
|
||
|
subsidiaryData = res.rows;
|
||
|
}
|
||
|
})
|
||
|
console.log(rawData)
|
||
|
console.log(subsidiaryData)
|
||
|
$.modal.confirm("确认导出该条bom数据吗?", function() {
|
||
|
axios({
|
||
|
url: prefix + '/exportBomDetail',
|
||
|
method: 'POST',
|
||
|
data: {
|
||
|
exData: {
|
||
|
// "selectData": JSON.stringify(selectData),
|
||
|
"bomData": JSON.stringify(bomData),
|
||
|
"rawData": JSON.stringify(rawData),
|
||
|
"subsidiaryData": JSON.stringify(subsidiaryData)
|
||
|
}
|
||
|
},
|
||
|
responseType: 'blob'
|
||
|
}).then(response => {
|
||
|
// console.log(response)
|
||
|
// console.log(response.data)
|
||
|
const URL = window.URL.createObjectURL(response.data)
|
||
|
// 创建隐藏<a>标签进行下载
|
||
|
const tempLink = document.createElement('a')
|
||
|
tempLink.style.display = 'none'
|
||
|
tempLink.href = URL
|
||
|
let time = new Date().toLocaleString()
|
||
|
tempLink.setAttribute('download', time + '_' + bomData[0].finishProductName + "_bom.xlsx")
|
||
|
if (typeof tempLink.download === 'undefined') {
|
||
|
tempLink.setAttribute('target', '_blank')
|
||
|
}
|
||
|
document.body.appendChild(tempLink)
|
||
|
tempLink.click()
|
||
|
document.body.removeChild(tempLink)// 移除dom元素
|
||
|
window.URL.revokeObjectURL(URL)//释放内存
|
||
|
})
|
||
|
})
|
||
|
} else {
|
||
|
$.modal.msgWarning("请选择一条数据")
|
||
|
}
|
||
|
|
||
|
}
|
||
|
</script>
|
||
|
</body>
|
||
|
</html>
|