|
|
@ -78,7 +78,7 @@ |
|
|
|
|
|
|
|
<div class="btn-group-sm" id="toolbar" role="group"> |
|
|
|
<!-- 导入合同按钮 --> |
|
|
|
<a class="btn btn-warning" data-toggle="modal" data-target="#importContractModal"> |
|
|
|
<a class="btn btn-warning" onclick="importContract()" shiro:hasPermission="purchase:purchaseOrder:importContract"> |
|
|
|
<i class="fa fa-download"></i> 导入合同 |
|
|
|
</a> |
|
|
|
|
|
|
@ -136,30 +136,28 @@ |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
|
|
|
|
|
|
|
|
<!-- 导入合同模态框 --> |
|
|
|
<div class="modal inmodal fade" id="importContractModal" tabindex="-1" aria-labelledby="importContractModalLabel" role="dialog" aria-hidden="true"> |
|
|
|
<div class="modal-dialog"> |
|
|
|
<div class="modal-content"> |
|
|
|
<div class="modal-header"> |
|
|
|
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Close</span> |
|
|
|
</button> |
|
|
|
<h4 class="modal-title">导入合同</h4> |
|
|
|
</div> |
|
|
|
<div class="modal-body"> |
|
|
|
<div class="file-loading"> |
|
|
|
<input id="singleFile" name="file" type="file"> |
|
|
|
<!-- 添加隐藏的输入框 --> |
|
|
|
<input id="fileIdStr" name="fileIdStr" type="text" hidden> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<div class="modal-footer"> |
|
|
|
<button type="button" class="btn btn-white" data-dismiss="modal">关闭</button> |
|
|
|
<button type="button" class="btn btn-primary">保存</button> |
|
|
|
<!-- 导入合同模态框 --> |
|
|
|
<div class="modal inmodal fade" id="importContractModal" tabindex="-1" aria-labelledby="importContractModalLabel" role="dialog" aria-hidden="true"> |
|
|
|
<div class="modal-dialog"> |
|
|
|
<div class="modal-content"> |
|
|
|
<div class="modal-header"> |
|
|
|
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Close</span> |
|
|
|
</button> |
|
|
|
<h4 class="modal-title">导入合同</h4> |
|
|
|
</div> |
|
|
|
<div class="modal-body"> |
|
|
|
<div class="file-loading"> |
|
|
|
<input id="singleFile" name="file" type="file"> |
|
|
|
<!-- 添加隐藏的输入框 --> |
|
|
|
<input id="fileIdStr" name="fileIdStr" type="text" hidden> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<div class="modal-footer"> |
|
|
|
<button type="button" class="btn btn-white" data-dismiss="modal">关闭</button> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
|
|
|
|
<th:block th:include="include :: footer" /> |
|
|
|
<th:block th:include="include :: datetimepicker-js"/> |
|
|
@ -382,68 +380,87 @@ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$(document).ready(function() { |
|
|
|
// 获取导入合同按钮 |
|
|
|
var importContractButton = $('#importContractButton'); |
|
|
|
// 将选中的行数据存储到全局变量 |
|
|
|
var globalSelectedRow = null; |
|
|
|
|
|
|
|
// 添加点击事件处理器 |
|
|
|
importContractButton.on('click', function(event) { |
|
|
|
// 阻止默认行为 |
|
|
|
event.preventDefault(); |
|
|
|
|
|
|
|
// 执行校验逻辑 |
|
|
|
if (checkConditions()) { |
|
|
|
// 如果校验通过,则显示模态框 |
|
|
|
$('#importContractModal').modal('show'); |
|
|
|
} else { |
|
|
|
// 如果校验失败,则显示提示信息 |
|
|
|
alert('您不具备导入合同的权限!'); |
|
|
|
} |
|
|
|
}); |
|
|
|
// 导入合同 |
|
|
|
function importContract(){ |
|
|
|
// 获取选中的行 |
|
|
|
const selectedRows = $("#bootstrap-table").bootstrapTable('getSelections'); |
|
|
|
|
|
|
|
// 定义校验逻辑函数 |
|
|
|
function checkConditions() { |
|
|
|
// 这里可以根据需要添加校验逻辑 |
|
|
|
// 例如:检查用户权限、表单状态等 |
|
|
|
// 返回 true 表示校验通过,false 表示校验失败 |
|
|
|
// 获取选中的行 |
|
|
|
const selectedRows = $("#bootstrap-table").bootstrapTable('getSelections'); |
|
|
|
|
|
|
|
if (selectedRows.length !== 1) { |
|
|
|
showWarning("请先选择一条采购订单"); |
|
|
|
return; |
|
|
|
} |
|
|
|
if (selectedRows.length !== 1) { |
|
|
|
showWarning("请先选择一条采购订单"); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
const row = selectedRows[0]; |
|
|
|
|
|
|
|
// 定义状态码常量 |
|
|
|
const AUDIT_STATUS_APPROVED = "1"; // 审核通过 |
|
|
|
const USE_STATUS_DELETED = "2"; // 作废 |
|
|
|
|
|
|
|
// 检查是否作废 |
|
|
|
if (row.useStatus === USE_STATUS_DELETED) { |
|
|
|
showWarning("该采购订单已作废"); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
// 检查是否审核通过 |
|
|
|
if (row.auditStatus !== AUDIT_STATUS_APPROVED) { |
|
|
|
showWarning("该采购订单未审核通过"); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
return true; // 示例:始终返回 true |
|
|
|
if (selectedRows.length ===1) { |
|
|
|
// $("#purchaseOrderId").val(data[0].purchaseOrderId) |
|
|
|
$("#importContractModal").modal("show"); |
|
|
|
// 存储选中的行数据 |
|
|
|
globalSelectedRow = row; |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//导入合同 |
|
|
|
$(document).ready(function () { |
|
|
|
// 单图上传 |
|
|
|
$("#singleFile").fileinput({ |
|
|
|
uploadUrl: ctx + "common/uploadSingleFile", |
|
|
|
language: 'zh', //设置语言 |
|
|
|
dropZoneEnabled: true, //是否显示拖拽区域 |
|
|
|
maxFileSize: 20480, //上传文件最大值,单位kb |
|
|
|
allowedFileExtensions: ['jpg', 'png', 'gif', 'jpeg'], //指定上传文件类型 |
|
|
|
uploadUrl: prefix + "/uploadSingleFile", |
|
|
|
language: 'zh', // 设置语言 |
|
|
|
dropZoneEnabled: true, // 是否显示拖拽区域 |
|
|
|
maxFileSize: 20480, // 上传文件最大值,单位kb |
|
|
|
allowedFileExtensions: ['jpg', 'png', 'gif', 'jpeg'], // 指定上传文件类型 |
|
|
|
maxFileCount: 1, |
|
|
|
initialPreviewAsData: true, |
|
|
|
uploadExtraData: { |
|
|
|
img_key: "1000", |
|
|
|
img_keywords: "happy, nature", |
|
|
|
uploadExtraData: function() { |
|
|
|
// 返回额外的数据 |
|
|
|
return { |
|
|
|
img_key: "1000", |
|
|
|
img_keywords: "happy, nature", |
|
|
|
purchaseOrderCode: globalSelectedRow.purchaseOrderCode |
|
|
|
}; |
|
|
|
} |
|
|
|
}).on('fileuploaded', function (event, data, previewId, index) { |
|
|
|
var response = data.response; |
|
|
|
// var rsp = data.response; |
|
|
|
// document.getElementById('attachFileId').value = rsp.attachFileId; |
|
|
|
var attachFileId = response.data.id; |
|
|
|
if (response.code === web_status.SUCCESS) { |
|
|
|
$('#fileIdStr').val(attachFileId); |
|
|
|
$.modal.msgSuccess("上传成功"); |
|
|
|
|
|
|
|
// 在这里可以处理上传成功后的操作 |
|
|
|
var selectedRowData = globalSelectedRow; |
|
|
|
// 使用 selectedRowData 进行进一步的操作 |
|
|
|
console.log(selectedRowData); |
|
|
|
|
|
|
|
// 绑定保存按钮的点击事件 |
|
|
|
$('#saveImport').on('click', function() { |
|
|
|
// 这里可以添加保存逻辑 |
|
|
|
console.log("保存按钮被点击"); |
|
|
|
console.log("选中行的数据:", selectedRowData); |
|
|
|
console.log("附件ID:", attachFileId); |
|
|
|
}); |
|
|
|
} else { |
|
|
|
$.modal.alertError(response.msg); |
|
|
|
} |
|
|
|