提交 328244ba 编写于 作者: Skyeye云's avatar Skyeye云

表格支持设置日期搜索条件

上级 48151bc9
......@@ -10,15 +10,6 @@ layui.config({
form = layui.form,
table = layui.table;
// 获取本月日期
function getOneYMFormatDate(){
var date = new Date;
var year = date.getFullYear();
var month = date.getMonth() + 1;
month = (month < 10 ? "0" + month : month);
return year.toString() + "-" + month.toString();
}
table.render({
id: 'messageTable',
elem: '#messageTable',
......@@ -31,17 +22,19 @@ layui.config({
limit: getLimit(),
cols: [[
{ title: systemLanguage["com.skyeye.serialNumber"][languageType], type: 'numbers' },
{ field: 'materialName', title: '产品名称', align: 'left', width: 250},
{ field: 'materialModel', title: '型号', align: 'left', width: 150},
{ field: 'unitName', title: '单位', align: 'left', width: 80},
{ field: 'currentTock', title: '进货数量', align: 'left', width: 100},
{ field: 'currentTockMoney', title: '进货金额', align: 'left', width: 120},
{ field: 'returnCurrentTock', title: '退货数量', align: 'left', width: 100},
{ field: 'materialName', title: '产品名称', align: 'left', width: 250 },
{ field: 'materialModel', title: '型号', align: 'left', width: 150 },
{ field: 'unitName', title: '单位', align: 'left', width: 80 },
{ field: 'currentTock', title: '进货数量', align: 'left', width: 100 },
{ field: 'currentTockMoney', title: '进货金额', align: 'left', width: 120 },
{ field: 'returnCurrentTock', title: '退货数量', align: 'left', width: 100 },
{ field: 'returnCurrentTockMoney', title: '退货金额', align: 'left', width: 120 }
]],
done: function(json) {
matchingLanguage();
initTableSearchUtil.initAdvancedSearch(this, json.searchFilter, form, "请选择日期", function () {
initTableSearchUtil.initAdvancedSearch(this, json.searchFilter, form,
{value: "请选择日期", type: 'month', defaultValue: getOneYMFormatDate(), required: 'required'},
function () {
table.reloadData("messageTable", {page: {curr: 1}, where: getTableParams()});
});
}
......@@ -58,7 +51,11 @@ layui.config({
}
function getTableParams() {
return $.extend(true, {}, initTableSearchUtil.getSearchValue("messageTable"));
var params = {};
if ($("#messageTableKeyWord").length == 0) {
params["keyword"] = getOneYMFormatDate();
}
return $.extend(true, params, initTableSearchUtil.getSearchValue("messageTable"));
}
exports('incomingstatistics', {});
......
var rowId = "";
//单据的时间
var operTime = "";
layui.config({
base: basePath,
version: skyeyeVersion
}).extend({
window: 'js/winui.window'
}).define(['window', 'table', 'jquery', 'winui', 'form', 'laydate'], function (exports) {
}).define(['window', 'table', 'jquery', 'winui', 'form'], function (exports) {
winui.renderColor();
var $ = layui.$,
form = layui.form,
laydate = layui.laydate,
table = layui.table;
//初始化统计时间
operTime = getOneYMFormatDate();
//获取本月日期
function getOneYMFormatDate(){
var date = new Date;
var year = date.getFullYear();
var month = date.getMonth() + 1;
month = (month < 10 ? "0" + month : month);
return year.toString() + "-" + month.toString();
}
laydate.render({elem: '#operTime', type: 'month', value: operTime});
initTable();
function initTable(){
table.render({
......@@ -37,62 +18,49 @@ layui.config({
elem: '#messageTable',
method: 'post',
url: flowableBasePath + 'statistics004',
where: {materialName: $("#materialName").val(), operTime: operTime},
where: getTableParams(),
even: true,
page: true,
limits: [8, 16, 24, 32, 40, 48, 56],
limit: 8,
limits: getLimits(),
limit: getLimit(),
cols: [[
{ title: systemLanguage["com.skyeye.serialNumber"][languageType], type: 'numbers' },
{ field: 'materialName', title: '产品名称', align: 'left', width: 250},
{ field: 'materialModel', title: '型号', align: 'left', width: 100},
{ field: 'unitName', title: '单位', align: 'left', width: 80},
{ field: 'currentTock', title: '销售数量', align: 'left', width: 100},
{ field: 'currentTockMoney', title: '销售金额', align: 'left', width: 120},
{ field: 'returnCurrentTock', title: '退货数量', align: 'left', width: 100},
{ field: 'materialName', title: '产品名称', align: 'left', width: 250 },
{ field: 'materialModel', title: '型号', align: 'left', width: 150 },
{ field: 'unitName', title: '单位', align: 'left', width: 80 },
{ field: 'currentTock', title: '销售数量', align: 'left', width: 100 },
{ field: 'currentTockMoney', title: '销售金额', align: 'left', width: 120 },
{ field: 'returnCurrentTock', title: '退货数量', align: 'left', width: 100 },
{ field: 'returnCurrentTockMoney', title: '退货金额', align: 'left', width: 120 }
]],
done: function(json) {
matchingLanguage();
initTableSearchUtil.initAdvancedSearch(this, json.searchFilter, form,
{value: "请选择日期", type: 'month', defaultValue: getOneYMFormatDate(), required: 'required'},
function () {
table.reloadData("messageTable", {page: {curr: 1}, where: getTableParams()});
});
}
});
form.render();
}
form.on('submit(formSearch)', function (data) {
if (winui.verifyForm(data.elem)) {
loadTable();
}
return false;
});
$("body").on("click", "#reloadTable", function() {
loadTable();
});
form.render();
$("body").on("click", "#reloadTable", function() {
loadTable();
});
$("body").on("click", "#formSearch", function () {
refreshTable();
})
//刷新
// 刷新
function loadTable() {
if(isNull($("#operTime").val())) {//一定要记得,当createTime为空时
winui.window.msg("请选择日期.", {icon: 2, time: 2000});
}else {
operTime = $("#operTime").val();
table.reloadData("messageTable", {where:{materialName: $("#materialName").val(), operTime: operTime}});
}
table.reloadData("messageTable", {where: getTableParams()});
}
//搜索
function refreshTable(){
if(isNull($("#operTime").val())) {//一定要记得,当createTime为空时
winui.window.msg("请选择日期.", {icon: 2, time: 2000});
}else {
operTime = $("#operTime").val();
table.reloadData("messageTable", {page: {curr: 1}, where:{materialName: $("#materialName").val(), operTime: operTime}})
}
}
function getTableParams() {
var params = {};
if ($("#messageTableKeyWord").length == 0) {
params["keyword"] = getOneYMFormatDate();
}
return $.extend(true, params, initTableSearchUtil.getSearchValue("messageTable"));
}
exports('incomingstatistics', {});
});
......@@ -7,30 +7,10 @@
<link href="../../assets/lib/winui/css/winui.css" rel="stylesheet" />
</head>
<body>
<div class="txtcenter" style="margin:0 auto;padding-top:10px;">
<form class="layui-form layui-form-pane" action="" autocomplete="off">
<div class="layui-form-item">
<div class="layui-inline">
<label class="layui-form-label">商品名称</label>
<div class="layui-input-inline">
<input type="text" id="materialName" name="materialName" placeholder="请输入名称" class="layui-input" />
</div>
<label class="layui-form-label">单据日期</label>
<div class="layui-input-inline">
<input type="text" id="operTime" name="operTime" placeholder="请选择单据日期" class="layui-input" />
</div>
<button type="reset" class="layui-btn layui-btn-primary list-form-search"><language showName="com.skyeye.reset"></language></button>
<button class="layui-btn list-form-search" lay-submit lay-filter="formSearch"><language showName="com.skyeye.search2"></language></button>
</div>
</div>
</form>
</div>
<div class="winui-tip alert-info" id="showInfo">注:此处包含零售+销售+其他出库。</div>
<div class="winui-toolbar">
<div class="winui-tool">
<button id="reloadTable" class="winui-toolbtn"><i class="fa fa-refresh" aria-hidden="true"></i><language showName="com.skyeye.refreshDataBtn"></language></button>
<div style="width: calc(100% - 120px); float: right; padding: 8px 10px;">
<div class="layui-form-mid layui-word-aux" style="color: red !important;">注:此处包含零售+销售+其他出库。</div>
</div>
<button id="reloadTable" class="winui-toolbtn search-table-btn-right"><i class="fa fa-refresh" aria-hidden="true"></i><language showName="com.skyeye.refreshDataBtn"></language></button>
</div>
</div>
<div style="margin:auto 10px;">
......
......@@ -89,11 +89,40 @@ var initTableSearchUtil = {
* @param keywordPlaceholder 关键字搜索的提示语
*/
initTableKeyWordSearch: function (tableId, keywordPlaceholder) {
var str = '<div class="keyword-box">' +
var str;
if (typeof keywordPlaceholder === 'object') {
str = '<div class="keyword-box">' +
'<input type="text" id="' + tableId + 'KeyWord" placeholder="' + keywordPlaceholder.value + '" class="layui-input search-input-keyword" />' +
'<i class="fa fas fa-search input-icon search-btn-keyword" id="' + tableId + 'SearchTable" title="' + systemLanguage["com.skyeye.search2"][languageType] + '"></i>' +
'</div>';
} else {
str = '<div class="keyword-box">' +
'<input type="text" id="' + tableId + 'KeyWord" placeholder="' + keywordPlaceholder + '" class="layui-input search-input-keyword" />' +
'<i class="fa fas fa-search input-icon search-btn-keyword" id="' + tableId + 'SearchTable" title="' + systemLanguage["com.skyeye.search2"][languageType] + '"></i>' +
'</div>';
'</div>';
}
$(".winui-tool").append(str);
// 当对输入框有要求时
if (typeof keywordPlaceholder === 'object') {
// 是否有默认值
if (!isNull(keywordPlaceholder.defaultValue)) {
$("#" + tableId + "KeyWord").val(keywordPlaceholder.defaultValue);
}
if (keywordPlaceholder.type == 'month') {
var jsCon;
// 是否必填
if (keywordPlaceholder.required == 'required') {
jsCon = '<script>layui.define(["laydate"], function(exports) {' +
'var laydate = layui.laydate;laydate.render({elem: "#' + tableId + 'KeyWord", type: "' + keywordPlaceholder.type + '", trigger: "click", btns: ["confirm"]});' +
'})</script>';
} else {
jsCon = '<script>layui.define(["laydate"], function(exports) {' +
'var laydate = layui.laydate;laydate.render({elem: "#' + tableId + 'KeyWord", type: "' + keywordPlaceholder.type + '", trigger: "click"});' +
'})</script>';
}
$(".winui-tool").append(jsCon);
}
}
},
/**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册