tijian_tieying/web/dccdc/Views/sq2/sqfile.cshtml

250 lines
9.6 KiB
Plaintext
Raw Normal View History

2025-02-20 12:14:39 +08:00

@{
ViewBag.Title = "sqfile";
}
@using Newtonsoft.Json;
<div style="display:@Request.QueryString["show"]">
<table class="t3" style="width:100%">
<tr style="padding-top:2px">
<td class="ltd" width="70px">选择日期</td>
<td class="rtd" width="150px">
@Html.TextBox("xzrq", "" , new { @class = "l-text" })*
</td>
<td class="ltd" width="70px">文件类型</td>
<td class="rtd" width="150px">
@Html.DropDownList("wjlx", ViewData["wjlxD"] as SelectList, "----请选择----", new { @class = "l-text" })*
</td>
</tr>
<tr>
<td class="ltd" width="70px">选择文件</td>
<td class="rtd" width="150px">
<form id="fileForm" enctype='multipart/form-data'>
<input type="file" name="file1" id="file1" />*
@Html.Hidden("filepath")
<span style="color:red">大小:10M以内格式:图片格式、word、excel、pdf等</span>
</form>
</td>
<td class="ltd" width="70px">文件名称</td>
<td class="rtd" width="150px">
@Html.TextBox("title", "", new { @class = "l-text" })*
</td>
</tr>
</table>
<div style="text-align:center;margin-top:10px"><input type="@Request.QueryString["type"]" readonly="readonly" value="上传" class="l-button" onclick="save()" /></div>
</div>
<div id="maingrid"></div>
<div style="text-align:right;margin:5px">
<input type="@Request.QueryString["type"]" readonly="readonly" value="图片相册预览" style="width:120px" class="l-button" onclick="imgsview()" />
<input type="@Request.QueryString["type"]" readonly="readonly" value="关闭" class="l-button" onclick="check()" />
</div>
<div id="dialogshow"></div>
@section scripts{
<script type="text/javascript" src="@Url.Content("~/Scripts/public.js")"></script>
<script type="text/javascript">
$(function () {
$("#xzrq").ligerDateEditor({ initValue: "@ViewBag.now" });
$("#maingrid").ligerGrid({
height: '100%',
columns: [
{ display: '编号', name: 'id', align: 'left', width: '6%' },
{ display: '添加时间', name: 'addtime', width: '15%', render: function (r, i, v) { if (v) return formatDate(v) } },
{
display: '文件', name: 'title', align: 'left', width: '50%',
render: function (r, i, v) {
return '<a onclick="savelog(' + r.id + ')" href="' + r.filepath + '" target="_blank">下载 ' + v + '</a>'
}
},
{
display: '浏览记录', name: 'title', align: 'left', width: '12%',
render: function (r, i, v) {
return '<a onclick="showlog(\'' + r.downlog + '\')" href="javascript:;">浏览记录</a>'
}
},
{
display: '删除', name: 'id', align: 'left', width: '12%',
render: function (r, i, v) {
return "<div onclick='del(" + v + ")' style='text-align:center;display:@Request.QueryString["show"]'><img style='cursor:hand' src='@Url.Content("~/Content/jingfei/b_jian.png")'><div>";
}
}
],
url: "@Url.Action("getSqfile")?type=@Server.UrlEncode(ViewBag.type)&sqid=@ViewBag.sqid",
pageSize: 10,
rownumbers: true,
usePager: false,
heightDiff: -10
});
//上传文件
$("#file1").on("change", function () {
var titles = $("#file1").val().split("\\");
//$("#title").val(titles[titles.length-1]);
$.ajax({
url: "@Url.Action("uploadFile")",
type: 'POST',
cache: false,
data: new FormData($('#fileForm')[0]),
processData: false,
contentType: false,
dataType: "json",
beforeSend: function () {
$.ligerDialog.waitting("正在进行请稍后……");
},
success: function (data) {
$.ligerDialog.closeWaitting();
if (data.state) {
$("#filepath").val(data.url)
}
else {
$.ligerDialog.error(data.msg);
}
}
});
});
});
function save() {
var filepath = $("#filepath").val();
if (!filepath) {
$.ligerDialog.error("请选择文件!");
return;
}
var xzrq = $("#xzrq").val();
var wjlx=$("#wjlx").val();
var title = $("#title").val();
if (!xzrq || !wjlx || !title) {
$.ligerDialog.error("日期、类型、文件名称必填!");
return;
}
$.ajax({
url: "@Url.Action("saveSqfile")", type: "post", dataType: "json",
data: { type: "@Server.UrlDecode(ViewBag.type)", sqid: "@ViewBag.sqid", title: xzrq + title + wjlx, filepath: filepath },
success: function (d) {
$.ligerDialog.closeWaitting();
if (d.State == 0) {
$.ligerDialog.error("操作失败!");
}
else {
$.ligerDialog.success("操作成功!");
liger.get("maingrid").reload();
$("#filepath").val("");
$("#title").val("");
}
},
beforeSend: function () {
$.ligerDialog.waitting("正在进行请稍后……");
}
});
}
function del(id) {
if (confirm("确定删除") == true) {
$.ajax({
url: "@Url.Action("deleteSqfile")", type: "post", dataType: "json", data: { id: id },
success: function (d) {
$.ligerDialog.closeWaitting();
$.ligerDialog.alert(d.Message, function () {
if (d.State == 1) {
liger.get("maingrid").reload();
return;
}
});
},
beforeSend: function () {
$.ligerDialog.waitting("正在保存请稍后……");
}
});
}
}
function savelog(id) {
$.ajax({
url: "@Url.Action("savelog")", type: "post", dataType: "json", data: { ids: id },
success: function (d) {
$.ligerDialog.closeWaitting();
if (d.State == 1) {
liger.get("maingrid").reload();
return;
}
},
beforeSend: function () {
$.ligerDialog.waitting("正在保存请稍后……");
}
});
}
function showlog(content) {
$("#dialogshow").html(content.replace(/\|/g, "<br/>"));
$.ligerDialog.open({
target: $("#dialogshow"),
title: '浏览记录',
height: 200,
width: 200,
isResize: true
});
}
function check() {
var rows = liger.get("maingrid").getData();
if (parent.filecount != undefined) {
parent.filecount = rows.length;
}
if (parent.nodownfilecount != undefined) {
var count = 0;
for (var i in rows) {
if (!rows[i].downlog || rows[i].downlog.indexOf("@ViewBag.truename") == -1) {
count++;
}
}
parent.nodownfilecount = count;
}
var dialog = frameElement.dialog; //调用页面的dialog对象(ligerui对象)
dialog.close();//关闭dialog
}
//相册预览
function imgsview() {
var rows = liger.get("maingrid").getData();
var ids = "-1";
var imgs = "";
for (var i in rows) {
if (rows[i].filepath.indexOf(".jpg") != -1 || rows[i].filepath.indexOf(".png") != -1) {
imgs += rows[i].filepath + ",";
ids += "," + rows[i].id;
}
}
if (!imgs) {
$.ligerDialog.error("无图片!");
return;
}
//预览记录
$.ajax({
url: "@Url.Action("savelog")", type: "post", dataType: "json", data: { ids: ids },
success: function (d) {
$.ligerDialog.closeWaitting();
if (d.State == 1) {
liger.get("maingrid").reload();
}
},
beforeSend: function () {
$.ligerDialog.waitting("正在保存请稍后……");
}
});
window.open("@Url.Action("viewfile")?paths=" + imgs);
}
</script>
}