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

189 lines
7.6 KiB
Plaintext

@{
ViewBag.Title = "sqcgMessage";
}
@model dccdc.Models.sqcgModel
@section scripts{
<script type="text/javascript" src="@Url.Content("~/Scripts/public.js")"></script>
<script type="text/javascript">
$(function () {
$("#layout1").ligerLayout({ leftWidth: 300, topHeight: 150 });
$("#sqsj").ligerDateEditor();
$("#sqsj").ligerGetDateEditorManager().setValue(fun_date(0));
$("#fyly").change(function () {
var select = $("#fyly").val();
$("#fydh").val("");
var url = "";
switch (select) {
case "2": url = "@Url.Action("choosexmjfView", "jingfei")"; break;
case "3": url = "@Url.Action("chooseszydView", "jingfei")"; break;
}
if (url == "")
return;
openf2 = $.ligerDialog.open({
title: "选择申请单",
url: url,
width: 500,
height: 400
});
})
$("#grid2").ligerGrid({
height: "100%",
columns: [
{ display: "名称", name: "title", align: "left", width: 200, type: 'string', editor: { type: 'string' } },
{ display: "内容", name: "content", align: "left", width: 400, type: 'string', editor: { type: 'string' } },
{ display: "数量", name: "sl", align: "right", width: 60, type: 'float', editor: { type: 'float' } },
{ display: "金额", name: "je", align: "right", width: 60, type: 'float', editor: { type: 'float' } }
],
url: "@Url.Action("getxm4")?key=0000000&id=@Request.QueryString["id"]",
rownumber: true,
usePager: false,
enabledEdit: true,
toolbar: {
items: [
{ text: '增加', click: edit, icon: 'add' }
]
},
onDblClickRow: function (rowdata, rowid, rowobj) {
liger.get("grid2").remove(rowdata);
//计算
sum();
},
onAfterEdit: function (e) {
//计算
sum();
}
});
})
function edit(item) {
var id;
if (item.text === "增加") {
rowdata = {};
rowdata.title = "";
rowdata.content = "";
rowdata.sl = 1;
rowdata.je = 0;
liger.get("grid2").add(rowdata);
}
}
function sum() {
var rows = liger.get("grid2").getData();
var result = 0;
for (var i in rows) {
result += rows[i].sl * rows[i].je;
}
$("#je").val(result.toFixed(2));
}
function save() {
liger.get("grid2").endEdit();
var rows = liger.get("grid2").getData();
if (rows.length == 0) {
$.ligerDialog.error("请添加明细!")
return;
}
for (var i in rows) {
if (rows[i].title == "") {
$.ligerDialog.error("名称必填!")
return;
}
}
var id = $("#id").val();
var je = $("#je").val();
var bz = $("#bz").val();
var fyly = $("#fyly").val();
var fydh = $("#fydh").val();
if (!je || !fyly) {
$.ligerDialog.error("请填写详细信息!")
return;
}
var items = "";
for (var i in rows) {
items += rows[i].title + "|" + rows[i].content + "|" + rows[i].sl + "|" + rows[i].je + ",";
}
$.ajax({
url: "@Url.Action("savesqcg")", type: "post", dataType: "json", data: { id: id, je: je, fyly: fyly, fydh: fydh, bz: bz, items: items },
success: function (d) {
$.ligerDialog.closeWaitting();
if (d.State == "0") {
$.ligerDialog.error("操作失败!");
}
else {
$.ligerDialog.success("操作成功!");
parent.init();
}
},
beforeSend: function () {
$.ligerDialog.waitting("正在进行请稍后……");
}
});
}
//弹出框选中
function selectedJFSQD(rowdata) {
$("#fydh").val(rowdata.sqdh);
openf2.close();
}
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;
}
</script>
}
<div class="l-clear"></div>
<div id="layout1">
<div position="center" title="明细(双击增删)">
<div id="grid2"></div>
</div>
<div position="top">
@Html.HiddenFor(m => m.id)
<table class="t1" style="width:100%">
<tr>
<td class="ltd" width="70px">科室</td>
<td class="rtd" width="150px">@Html.TextBoxFor(m => m.ksmc, new { @class = "l-text", @readonly = "readonly" })</td>
<td class="ltd" width="70px">单号</td>
<td class="rtd" width="150px">@Html.TextBoxFor(m => m.sqdh, new { @class = "l-text", @readonly = "readonly" })</td>
<td class="ltd" width="70px">申请日期</td>
<td class="rtd" width="150px">@Html.TextBoxFor(m => m.sqsj, new { @class = "l-text", @readonly = "readonly" })</td>
</tr>
<tr>
<td class="ltd" width="70px">申请人</td>
<td class="rtd" width="150px">@Html.TextBoxFor(m => m.sqr, new { @class = "l-text", @readonly = "readonly" })</td>
<td class="ltd" width="70px">状态</td>
<td class="rtd" width="150px">@Html.DropDownListFor(m => m.zt, ViewBag.ztD as SelectList, "----请选择----", new { @class = "l-text", @disabled = "disabled" })</td>
<td class="ltd" width="70px">金额</td>
<td class="rtd" width="150px">@Html.TextBoxFor(m => m.je, new { @class = "l-text l-text-field-number", @type = "number", @readonly = "readonly" })</td>
</tr>
<tr>
<td class="ltd" width="70px">费用来源</td>
<td class="rtd" width="150px">@Html.DropDownListFor(m => m.fyly, ViewBag.fylyD as SelectList, "----请选择----", new { @class = "l-text" })<br />@Html.TextBoxFor(m => m.fydh, new { @class = "l-text", @readonly = "readonly" })</td>
<td class="ltd" width="70px">备注</td>
<td class="rtd" width="150px">@Html.TextAreaFor(m => m.bz, new { cols = "18", rows = "3" })</td>
<td class="ltd" width="70px"></td>
<td class="rtd" width="150px"><input type="@Request.QueryString["type"]" value="申请" style="height:50px" class="l-button" onclick="save()" /></td>
</tr>
</table>
</div>
</div>