tijian_tieying/web/dccdc/Views/sq2/sqbxmx2.cshtml
2025-02-20 12:14:39 +08:00

241 lines
11 KiB
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

@{
ViewBag.Title = "sqyscx";
}
<div id="layout1">
<div>
<table class="t1" style="width:100%">
<tr>
<td class="ltd" style="width:80px">开始时间:</td>
<td class="rtd" style="width:150px"><input id="start" class="l-text" /></td>
<td class="ltd" style="width:70px">结束时间:</td>
<td class="rtd" style="width:150px"><input id="end" class="l-text" /></td>
<td class="ltd" style="width:70px">申请人:</td>
<td class="rtd" style="width:150px">@Html.TextBox("sqr", "", new { @class = "l-text" })</td>
</tr>
</table>
</div>
<div position="left">
<table class="t1" style="width:100%">
<tr>
<td class="ltd" width="70px">申请科室</td>
<td class="rtd">@Html.DropDownList("ksid", ViewBag.ksD as SelectList, "所有科室", new { @class = "l-text" })</td>
<td class="rtd" rowspan="2"><input type="button" id="search" value="查询" class="l-button" style="height:46px" /></td>
</tr>
<tr>
<td class="ltd" width="70px">预算年份</td>
<td class="rtd">@Html.TextBox("year", "", new { @class = "l-text" })</td>
</tr>
</table>
<div id="maingrid"></div>
</div>
<div position="center" title="明细(双击增删)">
<div id="maingrid2"></div>
</div>
</div>
@using Newtonsoft.Json;
@section scripts{
<script type="text/javascript" src="@Url.Content("~/Scripts/public.js")"></script>
<script type="text/javascript">
//js对象深度克隆
var deepCopy = function (source) {
var result = {};
for (var key in source) {
result[key] = typeof source[key] === 'object' ? deepCopy(source[key]) : source[key];
}
return result;
}
function fun_date(days) {
var date1 = new Date(),
time1 = date1.getFullYear() + "-" + (date1.getMonth() + 1) + "-" + date1.getDate();//time1表示当前时间
var date2 = new Date(date1);
date2.setDate(date1.getDate() + days);
var y = date2.getFullYear();
var m = date2.getMonth() + 1;
m = m < 10 ? '0' + m : m;
var d = date2.getDate();
d = d < 10 ? ('0' + d) : d;
var time2 = y + "-" + m + "-" + d;
return time2;
}
$(function () {
$("#layout1").ligerLayout({ leftWidth: 310, topHeight: 130 });
$("#start").ligerDateEditor();
$("#end").ligerDateEditor();
//$("#start").ligerGetDateEditorManager().setValue(fun_date(-10));
//$("#end").ligerGetDateEditorManager().setValue(fun_date(0));
$("#search").click(function () {
liger.get("maingrid").set("parms", { start: $("#start").val(), end: $("#end").val(), sqr: $("#sqr").val(), ksid: $("#ksid").val(), year: $("#year").val() });
liger.get("maingrid").changePage("first");
liger.get("maingrid").reload();
})
function save() {
liger.get("maingrid2").endEdit();
var rows = liger.get("maingrid2").getData();
var items = "";
var dic = {};
if (rows.length == 0) {
$.ligerDialog.error("没有明细!");
return;
}
for (var i in rows) {
if (!("xmmc" in rows[i])) {
$.ligerDialog.error("必须全部维护预算!");
return;
}
if (rows[i].je == 0 || !rows[i].content || !rows[i].kmmc) {
$.ligerDialog.error("内容、科目必填,金额>0");
return;
}
if (dic[rows[i].id])
dic[rows[i].id] += rows[i].je;
else
dic[rows[i].id] = rows[i].je;
items += rows[i].id+ "|" + rows[i].xmmc + "|" + rows[i].content + "|" + rows[i].kmmc + "|" + rows[i].je + ",";
}
//一个预算可以多次使用 计算总计不能超
var dic2 = liger.get("maingrid").getData();
for (var i in dic) {
for (var j in dic2) {
if (dic2[j].id == i) {
if (dic[i] > dic2[j].syje) {
$.ligerDialog.error("有预算超额!");
return;
}
break;
}
}
}
if (window.parent.selectedYSBX) {
window.parent.selectedYSBX(items);
}
}
$("#maingrid").ligerGrid({
height: '100%',
columns: [
{ display: "经费名称", name: "xmmc", align: "left", width: 100 },
{
display: "预算金额", name: "je", align: "right", width: 80, totalSummary: {
render: function (suminf, column) {
return "<span style='color:red'>合计:" + suminf.sum + "</span>";
}
}
},
{
display: "已用金额", name: "je2", align: "right", width: 80, totalSummary: {
render: function (suminf, column) {
return "<span style='color:red'>合计:" + suminf.sum + "</span>";
}
}
},
{
display: "剩余金额", name: "syje", align: "right", width: 80, totalSummary: {
render: function (suminf, column) {
return "<span style='color:red'>合计:" + suminf.sum + "</span>";
}
}
},
{ display: '预算年份', name: 'year', align: 'left', width: 80 },
{ display: "ID", name: "id", align: "left", width: 50 }
],
url: "@Url.Action("getSqysbxPage2")?have=true",
pageSize: 10,
rownumbers: true,
usePager: false,
enabledEdit: true,
heightDiff: -20,
onDblClickRow: function (rowdata, rowid, rowobj) {
if (!rowdata.xmmc)
rowdata.xmmc = '';
var rows = liger.get("maingrid2").getData();
var have = false;
for (var i in rows) {
if (!("xmmc" in rows[i])) {
have = true;
if (rowdata.syje < rows[i].je) {
//$.ligerDialog.error("预算金额不足!");
//return;
//补充金额
var bcje = rows[i].je - rowdata.syje;
var rd = deepCopy(rows[i]);
rd.je = bcje; //剩余金额赋值给je字段
liger.get("maingrid2").add(rd);
//金额变化
rows[i].je = rowdata.syje;
liger.get("maingrid2").updateCell("je", rowdata.syje, i);
}
rows[i].id = rowdata.id;
rows[i].xmmc = rowdata.xmmc;
liger.get("maingrid2").updateCell("id", rowdata.id, i);
liger.get("maingrid2").updateCell("xmmc", rowdata.xmmc, i);
break;
}
}
if (have == false) {
//null深度赋值会变成{ } 对象 提前赋空值
var rd = deepCopy(rowdata);
rd.je = rd.syje; //剩余金额赋值给je字段
liger.get("maingrid2").add(rd);
}
}
});
var kemuD = @Html.Raw(ViewBag.kemuD);
$("#maingrid2").ligerGrid({
height: '100%',
columns: [
{ display: "经费名称", name: "xmmc", align: "left", width: 100 },
{ display: "业务内容", name: "content", align: "left", width: 160, type: 'string', editor: { type: 'string' } },
{
display: "科目", name: "kmmc", align: "left", width: 100, type: 'string',
editor: { type: 'select', data: kemuD, valueField: 'title', textField: 'title' }
},
{
display: "使用金额", name: "je", align: "right", width: 80, type: 'float', editor: { type: 'float', initSelect: true }, totalSummary: {
render: function (suminf, column) {
return "<span style='color:red'>合计:" + suminf.sum + "</span>";
}
}
},
{ display: "ID", name: "id", align: "left", width: 50 }
],
url: "@Url.Action("getCwfjBxmx")?type=@Request.QueryString["type"]&id=@Request.QueryString["bxdid"]",
pageSize: 10,
rownumbers: true,
usePager: false,
enabledEdit: true,
heightDiff: -20,
toolbar: {
items: [
{ text: '保存', click: save, icon: 'save' }
]
},
onDblClickRow: function (rowdata, rowid, rowobj) {
liger.get("maingrid2").remove(rowdata);
}
});
});
</script>
}