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.

335 lines
14 KiB
Plaintext

11 months ago
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<!--标准mui.css-->
<link href="../../js/mui/css/mui.min.css" rel="stylesheet" type="text/css" />
<link href="../../js/mui/css/mui.picker.min.css" rel="stylesheet" type="text/css" />
<link href="../../js/mui/css/mui.dtpicker.css" rel="stylesheet" />
<link href="../../js/mui/css/mui.indexedlist.css" rel="stylesheet" type="text/css" />
<script src="../../js/jquery.js" type="text/javascript"></script>
<script src="../../js/mui/js/mui.min.js" type="text/javascript"></script>
<script src="../../js/mui/js/mui.view.js" type="text/javascript"></script>
<script src="../../js/mui/js/mui.picker.min.js" type="text/javascript"></script>
<script src="../../js/mui/js/mui.dtpicker.js"></script>
<!-- 引入通用基础JS -->
<script src="../../Scripts/config.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="../../Scripts/commonYangYH.js" type="text/javascript"></script>
<script src="../../Comm/JScript.js" type="text/javascript"></script>
<script src="../CCFlowEnum.js" type="text/javascript"></script>>
<script src="../../MapAttr.js" type="text/javascript"></script>
<script src="Dtl.js" type="text/javascript"></script>
<style type="text/css">
input[type=color], input[type=date], input[type=datetime-local], input[type=datetime], input[type=email], input[type=month], input[type=number], input[type=password], input[type=search], input[type=tel], input[type=text], input[type=time], input[type=url], input[type=week], select, textarea {
padding: 5px 10px !important;
}
.mui-input-row label {
padding: 5px 15px !important;
}
.mui-content > .mui-card:first-child {
margin-top: -15px !important;
}
</style>
<script type="text/javascript">
var mapData = null;//从表对应类的属性
var frmData = null;
var newRowIdx =0;//新增行数
$(function () {
InitPage("dtlBatch");
//初始工具栏.
InitToolbar();
$("#headTitle").html(mapData.Name);
});
function InitPage() {
newRowIdx =0;
//初始化标题和表单数据
var httpHandler = new HttpHandler("BP.WF.HttpHandler.WF_CommEntity");
httpHandler.AddUrlData(); //增加参数属性.
var data = httpHandler.DoMethodReturnString("Dtl_Init");
if (data.indexOf('err@') == 0) {
mui.alert(data);
return;
}
frmData = JSON.parse(data);
mapData = frmData["Sys_MapData"][0];
mapData = new Entity("BP.Sys.MapData", mapData); //把他转化成entity.
//绑定数据.
BindDtls();
}
function BindDtls() {
var mapAtrrs = frmData.Sys_MapAttr; //从表字段属性
var dtls = frmData.Dtls;//从表数据
var _Html = "";
//判断是否有数据
if (dtls.length == 0) {
_Html = "<div class='mui-indexed-list-inner empty'>";
_Html += " <div class='mui-indexed-list-empty-alert'>没有数据</div>";
_Html += "</div>";
$('#DtlContent').append(_Html);
return;
}
//加载表单元素\数据
var dtl_Idx = 1;
for (var j = 0; j < dtls.length; j++) {
_Html += "<ul class='mui-table-view'>";
_Html += " <li class='mui-table-view-divider'>序号:" + dtl_Idx;
if (mapData.GetPara("IsDelete") == "1") {
_Html += " <div style='float: right;margin-right: 20px;' class='dtl_deleterow' id='" + dtls[j].OID + "'>删除</div>";
}
_Html += " </li>";
_Html += InitDtlMapAttr(mapAtrrs, null, frmData, false, "dtls", dtls[j].OID);
_Html += "</ul>";
dtl_Idx++;
}
$('#DtlContent').html("").append(_Html);
//为元素赋值
LoadDtlsData();
ReRenderForm();
}
/**
* 删除
* @param pkval
*/
function Delete(pkval) {
if (window.confirm('您确定要删除吗?') == false)
return;
var ensName = GetQueryString("EnsName");
var enName = ensName.substring(0, ensName.length - 1);
//执行删除.
var en = new Entity(enName);
en.SetPKVal(pkval);
en.Delete();
var div = $("#" + pkval).parent().parent();
if (div.hasClass("mui-table-view") == true)
div.remove();
}
//新增
function NewEn() {
$(".empty").hide();
var _Html = "";
newRowIdx++;
var dtl_Idx = frmData.Dtls.length + newRowIdx;
_Html += "<ul class='mui-table-view'>";
_Html += " <li class='mui-table-view-divider'>序号:" + dtl_Idx;
_Html += " <div style='float: right;margin-right: 20px;' class='dtl_removerow' id='" + newRowIdx + "'>移除</div>";
_Html += " </li>";
_Html += InitDtlMapAttr(frmData.Sys_MapAttr, null, frmData, false, "dtls", newRowIdx);
_Html += "</ul>";
$('#DtlContent').append(_Html);
//删除事件
ReRenderForm();
}
//保存
function SaveEns() {
var handler = new HttpHandler("BP.WF.HttpHandler.WF_CommEntity");
handler.AddUrlData(); //增加参数属性.
handler.AddFormData();
handler.AddPara("NewRowCount", newRowIdx);
var data = handler.DoMethodReturnString("Dtl_Save");
if (data.indexOf("err@") == 0) {
mui.alert(data);
return;
}
mui.alert("保存成功");
InitPage();
}
function LoadDtlsData() {
//设置默认值
$.each(frmData.Dtls, function (i, dtl) {
for (var j = 0; j < frmData.Sys_MapAttr.length; j++) {
var mapAttr = frmData.Sys_MapAttr[j];
//添加 label
//如果是整行的需要添加 style='clear:both'.
var defValue = ConvertDefVal(dtl, mapAttr.DefVal, mapAttr.KeyOfEn);
//if (mapAttr.DefValType == 0 && mapAttr.DefVal == "10002" && (defValue == "10002" || defValue == "10002.0000"))
// defValue = "";
if ($('#TB_' + dtl.OID + "_" + mapAttr.KeyOfEn).length == 1) {
$('#TB_' + dtl.OID + "_" + mapAttr.KeyOfEn).val(defValue);
$('#TB_' + dtl.OID + "_" + mapAttr.KeyOfEn).html(defValue);//只读大文本放到div里
if (mapAttr.MyDataType == FormDataType.AppDate || mapAttr.MyDataType == FormDataType.AppDateTime)
$('#LAB_' + dtl.OID + "_" + mapAttr.KeyOfEn).html(defValue);
}
if ($('#DDL_' + dtl.OID + "_" + mapAttr.KeyOfEn).length == 1) {
// 判断下拉框是否有对应option, 若没有则追加
if ($("option[value='" + defValue + "']", '#DDL_' + dtl.OID + "_" + mapAttr.KeyOfEn).length == 0) {
var mainTable = frmData.MainTable[0];
var selectText = mainTable[mapAttr.KeyOfEn + "Text"];
//@浙商银行
if (selectText == undefined)
selectText = mainTable[mapAttr.FKText];
if (selectText == undefined)
selectText = "";
$('#DDL_' + dtl.OID + "_" + mapAttr.KeyOfEn).append("<option value='" + defValue + "'>" + selectText + "</option>");
}
//
$('#DDL_' + dtl.OID + "_" + mapAttr.KeyOfEn).val(defValue);
}
if ($('#CB_' + dtl.OID + "_" + mapAttr.KeyOfEn).length == 1) {
if (defValue == "1") {
$('#CB_' + dtl.OID + "_" + mapAttr.KeyOfEn).attr("checked", true);
$('#CB_' + dtl.OID + "_" + mapAttr.KeyOfEn).val(1);
//判断是否存在mui-active这个类
if ($("#SW_" + dtl.OID + "_" + mapAttr.KeyOfEn).hasClass("mui-active") == false)
$("#SW_" + dtl.OID + "_" + mapAttr.KeyOfEn).addClass("mui-active");
} else {
$('#CB_' + dtl.OID + "_" + mapAttr.KeyOfEn).attr("checked", false);
$('#CB_' + dtl.OID + "_" + mapAttr.KeyOfEn).val(0);
//判断是否存在mui-active这个类
if ($("#SW_" + dtl.OID + "_" + mapAttr.KeyOfEn).hasClass("mui-active") == true)
$("#SW_" + dtl.OID + "_" + mapAttr.KeyOfEn).removeClass("mui-active");
}
}
if (mapAttr.UIIsEnable == "0") {
$('#TB_' + dtl.OID + "_" + mapAttr.KeyOfEn).attr('disabled', true);
$('#DDL_' + dtl.OID + "_" + mapAttr.KeyOfEn).attr('disabled', true);
$('#CB_' + dtl.OID + "_" + mapAttr.KeyOfEn).attr('disabled', true);
}
}
});
}
//填充默认数据
function ConvertDefVal(MainTable, defVal, keyOfEn) {
var result = defVal;
//通过MAINTABLE返回的参数
for (var ele in MainTable) {
if (keyOfEn == ele) {
result = MainTable[ele];
break;
}
}
return result = unescape(result);
}
function ReRenderForm() {
mui(".mui-switch").switch();
//监听开关事件
var SW = $('.mui-switch');
$.each(SW, function (i, obj) {
var KeyOfEn = $(obj).attr("id");
document.getElementById(KeyOfEn).addEventListener("toggle", function (event) {
var id = this.id.substring(3)
if (event.detail.isActive) {
$("#CB_" + id).val("1");
} else {
$("#CB_" + id).val("0");
}
})
});
//初始化复选下拉框
var selectPicker = $('.selectpicker');
$.each(selectPicker, function (i, selectObj) {
var defVal = $(selectObj).attr('data-val');
var defValArr = defVal.split(',');
$(selectObj).selectpicker('val', defValArr);
});
//删除事件
$(".dtl_deleterow").on("click", function () {
var target = $(this);
var oid = target.attr("id");
Delete(oid);
newRowIdx--;
});
$(".dtl_removerow").on("click", function () {
var target = $(this);
var oid = target.attr("id");
var div = $("#" + oid).parent().parent();
if (div.hasClass("mui-table-view") == true) {
div.remove();
newRowIdx--;
}
});
var pickdates = $("#en_mainInfo .ccformdate");
pickdates.each(function (i, pickdate) {
var id = this.getAttribute('id');
if ($("#" + id).html() == '') {
$("#" + id).html("<p>请选择时间<p>");
}
pickdate.addEventListener('tap', function () {
var _self = this;
var optionsJson = this.getAttribute('data-options') || '{}';
var options = JSON.parse(optionsJson);
if (options.type == 0) {
options.type = "date";//yyyy-MM-dd
} else if (options.type == 1) {
options.type = "date-time";//yyyy-MM-dd HH:mm
} else if (options.type == 2) {
options.type = "datetime";//yyyy-MM-dd HH:mm:ss
} else if (options.type == 3) {
options.type = "month";//yyyy-MM
} else if (options.type == 4) {
options.type = "time-min";//HH:mm
} else if (options.type == 5) {
options.type = "time";//HH:mm:ss
} else if (options.type == 6) {
options.type = "month-day";//MM-dd
} else if (options.type == 7) {
options.type = "year";//yyyy
}
var id = this.getAttribute('id');
_self.picker = new mui.DtPicker(options);
_self.picker.show(function (rs) {
$("#" + id).html(rs.text);
$("#TB_" + id.substr(4)).val(rs.text);
_self.picker.dispose();
_self.picker = null;
});
}, false);
});
}
</script>
</head>
<body>
<form id="cc" class="mui-input-group">
<header class="mui-bar mui-bar-nav">
<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
<h1 class="mui-title" id="headTitle">基础信息</h1>
</header>
<div class="mui-content" id="DtlContent">
<div class="mui-card">
<ul class="mui-table-view" id="entree"></ul>
<ul class="mui-table-view mui-table-view-chevron" id="dtmtree"></ul>
</div>
</div>
<nav id="bottomToolBar" class="mui-bar mui-bar-tab"></nav>
</form>
</body>
</html>