Browse Source

[feat] 采购订单

采购订单列表引入fileinput插件
新增 导入合同按钮和模态框和对应的js方法
dev
liuxiaoxu 3 months ago
parent
commit
a2c39699fa
  1. 118
      ruoyi-admin/src/main/resources/templates/purchase/purchaseOrder/purchaseOrder.html

118
ruoyi-admin/src/main/resources/templates/purchase/purchaseOrder/purchaseOrder.html

@ -4,6 +4,7 @@
<th:block th:include="include :: header('采购订单列表')" />
<th:block th:include="include :: datetimepicker-css"/>
<th:block th:include="include :: bootstrap-select-css"/>
<th:block th:include="include :: bootstrap-fileinput-css" />
<script type="text/javascript" th:src="@{/js/axios.min.js}"></script>
</head>
<body class="gray-bg">
@ -74,10 +75,13 @@
</form>
</div>
<div class="btn-group-sm" id="toolbar" role="group">
<a class="btn btn-success" onclick="importPurchaseOrder()" shiro:hasPermission="purchase:purchaseOrder:add">
<i class="fa fa-plus"></i> 导入合同
<!-- 导入合同按钮 -->
<a class="btn btn-warning" data-toggle="modal" data-target="#importContractModal">
<i class="fa fa-download"></i> 导入合同
</a>
<a class="btn btn-warning" onclick="exportContract()" shiro:hasPermission="purchase:purchaseOrder:exportContract">
<i class="fa fa-download"></i> 导出合同
</a>
@ -131,9 +135,37 @@
</div>
</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">&times;</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>
</div>
</div>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: datetimepicker-js"/>
<th:block th:include="include :: select2-js"/>
<th:block th:include="include :: bootstrap-fileinput-js" />
<th:block th:include="include:: zh-js" />
<script th:src="@{/js/activiti.js}"></script>
<script th:inline="javascript">
var editFlag = [[${@permission.hasPermi('purchase:purchaseOrder:edit')}]];
@ -290,7 +322,7 @@
});
};
//导出合同
function exportContract() {
// 获取选中的行
const selectedRows = $("#bootstrap-table").bootstrapTable('getSelections');
@ -340,12 +372,87 @@
});
}
// 显示警告消息的通用函数
function showWarning(message) {
$.modal.msgWarning(message);
}
$(document).ready(function() {
// 获取导入合同按钮
var importContractButton = $('#importContractButton');
// 添加点击事件处理器
importContractButton.on('click', function(event) {
// 阻止默认行为
event.preventDefault();
// 执行校验逻辑
if (checkConditions()) {
// 如果校验通过,则显示模态框
$('#importContractModal').modal('show');
} else {
// 如果校验失败,则显示提示信息
alert('您不具备导入合同的权限!');
}
});
// 定义校验逻辑函数
function checkConditions() {
// 这里可以根据需要添加校验逻辑
// 例如:检查用户权限、表单状态等
// 返回 true 表示校验通过,false 表示校验失败
// 获取选中的行
const selectedRows = $("#bootstrap-table").bootstrapTable('getSelections');
if (selectedRows.length !== 1) {
showWarning("请先选择一条采购订单");
return;
}
return true; // 示例:始终返回 true
}
});
//导入合同
$(document).ready(function () {
// 单图上传
$("#singleFile").fileinput({
uploadUrl: ctx + "common/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",
}
}).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("上传成功");
} else {
$.modal.alertError(response.msg);
}
});
});
// 订单结案
function reviewCloseCase(){
let data = $("#bootstrap-table").bootstrapTable("getSelections");
@ -381,8 +488,6 @@
});
}
function tableSet(data) {
var options = {
id: "closeCaseTable",
@ -405,6 +510,9 @@
],
}
}
</script>
</body>
</html>
Loading…
Cancel
Save