You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

624 lines
23 KiB
Plaintext

11 months ago
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title>单流程查询</title>
<meta name="renderer" content="webkit" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
<script src="../Scripts/jquery-1.11.0.min.js" type="text/javascript"></script>
<!--layui-->
<link href="../Scripts/layui/layui/css/layui.css" rel="stylesheet" />
<script src="../Scripts/layui/layui/layui.js" type="text/javascript"></script>
<link href="../Scripts/layui/layui/css/modules/layer/default/layer.css" rel="stylesheet" />
<script src="../Scripts/layui/layui/lay/modules/layer.js" type="text/javascript"></script>
<!--通用的JS-->
<script src="../Scripts/config.js" type="text/javascript"></script>
<script src="../Scripts/QueryString.js" type="text/javascript"></script>
<script src="../Scripts/QueryString.js" type="text/javascript"></script>
<script src="../Comm/Gener.js" type="text/javascript"></script>
<script src="../Comm/JS/Calendar/WdatePicker.js" type="text/javascript"></script>
<link href="../Comm/JS/Calendar/skin/WdatePicker.css" rel="stylesheet" type="text/css" />
<style type="text/css">
.layui-input, .layui-select, .layui-textarea {
height: 28px !important;
}
.layui-form-label {
padding: 3px 8px !important;
}
.layui-btn {
height: 28px !important;
line-height: 28px !important;
}
.layui-table-tool {
background-color: white !important;
}
</style>
<script type="text/javascript">
var searchFields = new Array(); //DDL的查询条件
var fields = []; //字符型字段查询的集合
var webUser = new WebUser();
//当前用户查询信息.
var ur;
var count;
var pageIdx = 1;
var pageSize = 10;
var pages = 1;//总页数;
var param = {
SearchType: GetQueryString("SearchType"),
FK_Flow: GetQueryString("FK_Flow"),
pageSize: pageSize,
pageIdx: pageIdx
};
var rptNo = "ND" + parseInt(param.FK_Flow) + "Rpt" + param.SearchType;
var firstLoadTable = true;
$(function () {
//工具栏
InitToolBar();
Search_MapAttr();
FlowSearch_Init();
});
/**
* 查询条件
*/
function InitToolBar() {
//创建处理器.
var handler = new HttpHandler("BP.WF.HttpHandler.WF_RptDfine");
handler.AddUrlData(); //增加参数.
//获取查询条件
var data = handler.DoMethodReturnString("FlowSearch_InitToolBar");
if (data.indexOf("err@") != -1) {
layer.alert(data);
console.log(data);
return;
}
data = JSON.parse(data);
//绑定外键枚举查询条件.
searchAttrs = data["Attrs"];
//格式为: @WFSta=0@FK_Dept=02
var mapBase = data.Sys_MapData[0];
//用户查询注册信息
ur = new Entity("BP.Sys.UserRegedit");
ur.MyPK = webUser.No + rptNo + "_SearchAttrs";
ur.RetrieveFromDBSources();
var _html = "";
//指定的文本字段查询
var StringSearchKeys = mapBase.StringSearchKeys;
if (StringSearchKeys == null || StringSearchKeys == undefined || StringSearchKeys == "") {
if (mapBase.IsSearchKey == "1") {
_html += '<div class="layui-inline">';
_html += '<label class="layui-form-label">关键字:</label>';
_html += '<div class="layui-input-inline">';
_html += '<input type="text" id="TB_Key" name="TB_Key" value="' + ur.SearchKey + '" autocomplete="off" class="layui-input" />';
_html += '</div>';
_html += '</div>';
}
} else {
//按照指定的string字段查询.
var strs = StringSearchKeys.split("*");
var fieldV = ""
$.each(strs, function (i, str) {
if (str != "") {
var item = str.split(",");
fieldV = ur.GetPara(item[0]);
if (fieldV == null || fieldV == undefined)
fieldV = "";
if (item.length == 2) {
fields.push(item[0]);
_html += '<div class="layui-inline">';
_html += '<label class="layui-form-label">' + item[1] + ':</label>';
_html += '<div class="layui-input-inline">';
_html += '<input type="text" id="TB_' + item[0] + '" name="TB_' + item[0] + '" value="' + fieldV + '" autocomplete="off" class="layui-input" />';
_html += '</div>';
_html += '</div>';
}
}
});
}
if (mapBase.DTSearchWay && mapBase.DTSearchWay != "0") {
_html += '<div class="layui-inline">';
_html += '<label class="layui-form-label">' + mapBase.DTSearchLabel + ':</label>';
var onfocus = "onfocus=\"WdatePicker({dateFmt:'yyyy-MM-dd'})\"";
// alert(mapBase.DTSearchWay);
if (mapBase.DTSearchWay != "1")
onfocus = " onfocus=\"WdatePicker({dateFmt:'yyyy-MM-dd HH:mm'})\"";
_html += '<div class="layui-input-inline" style="width:145px">';
_html += '<input type="text" id="TB_DTFrom" name="TB_DTFrom" value="' + ur.DTFrom + '"' + onfocus + ' class="layui-input Wdate" />';
_html += '</div>';
_html += '</div>';
_html += '<div class="layui-inline" ">';
_html += '<label class="layui-form-label" style="width:20px">到:</label>';
_html += '<div class="layui-input-inline" style="width:145px">';
_html += '<input type="text" id="TB_DTTo" name="TB_DTTo" value="' + ur.DTTo + '"' + onfocus + ' class="layui-input Wdate" />';
_html += '</div>';
_html += '</div>';
}
$("#toolBar").html(_html);
//外键、枚举、外部数据源
var json = AtParaToJson(ur.Vals);
for (var i = 0; i < searchAttrs.length; i++) {
var attr = searchAttrs[i];
if (attr.Field == "FK_NY") {
_html = "";
var fieldV = ur.GetPara(attr.Field);
if (fieldV == undefined)
fieldV = "";
var onfocus = " onfocus=\"WdatePicker({dateFmt:'yyyy-MM'})\"";
_html += '<div class="layui-inline">';
_html += '<label class="layui-form-label">' + attr.Name + ':</label>';
_html += '<div class="layui-input-inline" style="width:120px">';
_html += '<input type="text" id="TB_' + attr.Field + '" name="TB_' + attr.Field + '" value="' + fieldV + '"' + onfocus + ' class="layui-input Wdate" />';
_html += '</div>';
_html += '</div>';
$("#toolBar").append(_html);
fields.push(attr.Field);
continue;
}
_html = "";
_html += '<div class="layui-inline ">';
_html += '<label class="layui-form-label">' + attr.Name + ':</label>';
_html += '<div class="layui-input-inline" style="width:145px">';
_html += '<select name="CXDDL_' + attr.Field + '" ID="DDL_' + attr.Field + '">' + InitDDLOperation(data, attr, "all") + '</select>';
_html += '</div>';
_html += '</div>';
searchFields.push({ type: "select", id: "DDL_" + attr.Field });
$("#toolBar").append(_html);
var selectVal = json[attr.Field];
if (selectVal == undefined || selectVal == "")
selectVal = "all";
$("#DDL_" + attr.Field).val(selectVal);
}
//增加操作按钮
_html = "";
_html += '<div class="layui-inline">';
_html += '<div class="layui-input-inline">';
_html += '<input type="button" class="layui-btn" id="searchBtn" onclick="FlowSearch_Data()" style="margin-left: 15px" value="查询"/>';
//_html += '<input type="button" class="layui-btn layui-btn-primary" onclick="Exp()" value="导出全部"/>';
_html += '</div>';
$("#toolBar").append(_html);
}
/**
* 设置显示的列
* @return Cols的集合
*/
var columns = new Array();;
function Search_MapAttr() {
var handler = new HttpHandler("BP.WF.HttpHandler.WF_RptDfine");
handler.AddUrlData(); //增加参数.
//获取查询条件
var data = handler.DoMethodReturnString("FlowSearch_MapAttrs");
if (data.indexOf("err@") != -1) {
layer.alert(data);
console.log(data);
return;
}
data = JSON.parse(data);
//系统字段
var mapAttrOfSys = data["Sys_MapAttrOfSystem"];
//流程所有字段
var mapAttrOfAll = data["Sys_MapAttr"];
//系统字段字符串
//var sysFields = "," + data["Sys_Fields"][0].Field;
//表单字段
var mapAttrOfFrm = $.grep(mapAttrOfAll, function (item) {
if (item.UIVisible == 0)
return false;
//if (item.UIContralType != 0 && item.UIContralType != 1 && item.UIContralType != 2 && item.UIContralType != 3)
// return true;
if (item.KeyOfEn != "FK_NY")
return true;
return false;
});
//用户选择显示的字段
var selectFields = ur.GetPara("SelectFields");
selectFields = selectFields == null || selectFields == undefined ? "" : selectFields;
//生成表格的Cols数组
columns.push({
title: '序',
field: '',
align: 'center',
width: 40,
templet: function (d) {
return pageSize * (pageIdx - 1) + d.LAY_TABLE_INDEX + 1; // 返回每条的序号: 每页条数 *(当前页 - 1 + 序号
}
});
for (var i = 0; i < mapAttrOfSys.length; i++) {
if (mapAttrOfSys[i].KeyOfEn == "WFState")
continue;
columns.push(GenerColumn(mapAttrOfSys[i], false));
}
var keyOfEn = "";
for (var i = 0; i < mapAttrOfFrm.length; i++) {
keyOfEn = mapAttrOfFrm[i].KeyOfEn;
if (selectFields.indexOf("," + keyOfEn + ",") != -1 || selectFields.indexOf("," + keyOfEn + "T" + ",") != -1 || selectFields.indexOf("," + keyOfEn + "Text" + ",") != -1)
columns.push(GenerColumn(mapAttrOfFrm[i], false));
else
columns.push(GenerColumn(mapAttrOfFrm[i], true));
}
//流程状态
columns.push({
field: "WFSta",
title: "状态",
width: "100",
sort: true,
templet: function (data) {
return data["WFStaText"];
}
});
}
function FlowSearch_Data() {
var handler = new HttpHandler("BP.WF.HttpHandler.WF_RptDfine");
handler.AddPara("PageSize", pageSize);
handler.AddPara("PageIdx", pageIdx);
if (firstLoadTable == false) {
//增加字段查询
if ($("#TB_Key") != null && $("#TB_Key").val() != "" && fields.length == 0) {
ur.SearchKey = $("#TB_Key").val();
ur.SearchKey = $("#TB_Key").val();
}
else
ur.SearchKey = "";
for (var i = 0; i < fields.length; i++) {
var field = fields[i];
var strs = $("input[name='TB_" + field + "']");
if (strs.length == 1) {
ur.SetPara(field, $("#TB_" + field).val());
} else {
if ($("#TB_" + field + "_0").val() == "" && $("#TB_" + field + "_1").val() == "")
ur.SetPara(field, "");
else
ur.SetPara(field, $("#TB_" + field + "_0").val() + "," + $("#TB_" + field + "_1").val());
}
}
//增加时间条件的查询
if ($("#TB_DTFrom").length > 0) {
ur.DTFrom = $("#TB_DTFrom").val();
ur.DTTo = $("#TB_DTTo").val();
}
//增加下拉框的查询条件
var vals = "";
$.each(searchFields, function () {
vals += "@" + this.id + "=" + $("#" + this.id).val();
});
ur.Vals = vals;
ur.Update();
}
handler.AddUrlData(); //增加参数.
var data = handler.DoMethodReturnString("FlowSearch_Data");
if (data.indexOf("err@") != -1) {
layer.alert(data);
console.log(data);
return;
}
data = JSON.parse(data);
if (firstLoadTable == false) {
layui.table.reload('searchTable', { data: data });
return;
}
return data;
}
//禁用回车功能
$(window).keydown(function (e) {
var key = window.event ? e.keyCode : e.which;
if (!!key && key.toString() == "13") {
return false;
}
});
/**
* 查询数据
*/
function FlowSearch_Init() {
var data = FlowSearch_Data();
layui.use(['table', 'form'], function () {
var table = layui.table;
table.render({
elem: '#searchTable'
, data: data
, cellMinWidth: 80
, toolbar: 'true' //开启头部工具栏,并为其绑定左侧模板
, title: '用户数据表'
, cols: [columns]
, page: false
, cellMinWidth: 60
, height: $(document).height() - $("#toolBar").height() - 100
});
//监听排序信息
table.on('sort(searchTable)', function (obj) { //注tool是工具条事件名test是table原始容器的属性 lay-filter="对应的值"
ur.OrderBy = obj.field; //当前排序的字段名
ur.OrderWay = obj.type; //当前排序类型desc降序、asc升序、null空对象默认排序
FlowSearch_Data();
});
//头工具栏事件
table.on('toolbar(searchTable)', function (obj) {
switch (obj.event) {
case 'LAYTABLE_COLS': //筛选列
$(".layui-table-tool-panel").find("div").bind("click", function (event) {
var inputCheck = $(this).prev();
var name = inputCheck.attr("name");
var isCheck = $(this).hasClass("layui-form-checked");
var selectFields = ur.GetPara("SelectFields");
if (isCheck == false)
selectFields = selectFields.replace(name + ",", "");
else
selectFields = selectFields + name + ",";
ur.SetPara("SelectFields", selectFields);
ur.Update();
});
break;
};
});
//双击一行的事件
table.on('rowDouble(searchTable)', function (obj) {
var data = obj.data;
var url = '../MyView.htm?WorkID=' + data.OID + '&FK_Flow=' + GetQueryString("FK_Flow") + '&FK_Node=' + data.FlowEndNode + '&FID=' + (data.FID ? data.FID : 0) + '&t=' + Math.random();
layer.open({
type: 2,
title: "流程表单信息",
shade: false,
maxmin: true,
area: ['80%', '90%'],
content: url
});
});
});
ur.RetrieveFromDBSources();
layui.use('laypage', function () {
var laypage = layui.laypage;
//执行一个laypage实例
laypage.render({
elem: 'page' //注意,这里的 page 是 ID不用加 # 号
, count: ur.GetPara("Count") //数据总数,从服务端得到
, limits: [5, 10, 15, 20, 25]
, layout: ['count', 'prev', 'page', 'next', 'limit', 'refresh', 'skip']
, jump: function (obj) {
if (firstLoadTable == false) {
pageIdx = obj.curr;
pageSize = obj.limit;
//刷新数据
FlowSearch_Data();
}
if (firstLoadTable = true)
firstLoadTable = false;
}
});
$('#page').css('text-align', 'right'); // 分页右对齐
$('.layui-table-page').css('text-align', 'right'); //
});
}
/**
* 根据字段属性生成列属性
* @param attr
*/
function GenerColumn(attr, isHide) {
var field = attr.KeyOfEn;
var title = attr.Name;
var width = attr.Width;
if (field == "Title") {
width = 230;
}
if (attr.UIContralType == 1) {
if (width == null || width == "" || width == undefined)
width = 180;
return {
field: field, //字段名
title: title, //标题名称
minWidth: width, //宽度
hide: isHide, //是否隐藏
sort: true,
templet: function (data) {
var val = data[this.field + "Text"];
if (val == null && val == undefined)
val = data[this.field + "T"];
if (val == null && val == undefined)
val = data[this.field];
return val;
}
};
}
if (attr.UIContralType == 2) {
if (width == null || width == "" || width == undefined) {
width = 60;
}
return {
field: field,
title: title,
minWidth: width,
hide: isHide, //是否隐藏
sort: true,
template: function (data) {
if (data[this.field] == "0") return "否";
if (data[this.field] == "1") return "是";
}
};
}
if (width == null || width == "" || width == undefined)
width = 100;
if (field == "FlowStartRDT")
width = 160;
return {
field: field,
title: title,
minWidth: width,
hide: isHide, //是否隐藏
sort: true
};
}
//初始化下拉列表框的OPERATION
function InitDDLOperation(frmData, mapAttr, defVal) {
var operations = "";
operations += "<option value='all' >全部</option>";
var ens = frmData[mapAttr.Field];
if (ens == null) {
ens = [{ 'IntKey': 0, 'Lab': '否' }, { 'IntKey': 1, 'Lab': '是' }];
}
for (var i = 0; i < ens.length; i++) {
var en = ens[i];
if (en.No == undefined)
operations += "<option value='" + en.IntKey + "'>" + en.Lab + "</option>";
else
operations += "<option value='" + en.No + "'>" + en.Name + "</option>";
}
return operations;
}
function Reset() {
if (md.IsSearchKey) {
$("#tb_key").textbox("clear");
}
if (md.DTSearchWay != 0) {
$("#tb_dtFrom").datebox("clear");
$("#tb_dtTo").datebox("clear");
}
$.each(FilterCtrls, function () {
switch (this.type) {
case "date":
$("#" + this.id).datebox("clear");
break;
case "datetime":
$("#" + this.id).datetimebox("clear");
break;
case "text":
$("#" + this.id).textbox("clear");
break;
case "combo":
case "combotree":
$("#" + this.id).combobox("setValue", "all");
break;
case "checkbox":
$("#" + this.id)[0].checked = false;
break;
}
});
}
function ViewFlow(rowIndex, rowData) {
if (!rowData && typeof rowIndex != 'undefined') {
$('#dg').datagrid('selectRow', rowIndex);
rowData = $('#dg').datagrid('getSelected');
if (!rowData) return;
}
var url = '../MyView.htm?WorkID=' + rowData.OID + '&FK_Flow=' + fk_flow + '&FK_Node=' + rowData.FlowEndNode + '&FID=' + (rowData.FID ? rowData.FID : 0) + '&t=' + Math.random();
WinOpen(url);
}
function closeDlg() {
$("#eudlg").dialog("close");
}
</script>
</head>
<body style="background-color:white">
<div class="layui-card" style="margin:10px">
<form class="layui-form">
<div id="toolBar"></div>
</form>
<table class="layui-hide" id="searchTable" lay-filter="searchTable"></table>
<!--<script type="text/html" id="toolBar"></script>-->
<div id="page"></div>
</div>
<script type="text/javascript">
layui.use(['layedit', 'table', 'element'], function () {
});
</script>
</body>
</html>