117 lines
4.4 KiB
Plaintext
117 lines
4.4 KiB
Plaintext
|
|
@{
|
|
ViewBag.Title = "RepositoryAdd";
|
|
}
|
|
|
|
|
|
<div id="checkQuestionnaireAdd">
|
|
<table class="t1" style="width:100%">
|
|
<tr>
|
|
<td class="ltd" width="100px"><input id="code" class="l-text" name="code" type="hidden" />标题:</td>
|
|
<td class="rtd"><input id="title" class="l-text" name="title" style="width:340px" type="text" /></td>
|
|
</tr>
|
|
<tr>
|
|
<td class="ltd" width="100px"><input id="code" class="l-text" name="code" type="hidden" />内容:</td>
|
|
<td class="rtd"><script type="text/plain" id="myEditor">
|
|
|
|
</script></td>
|
|
</tr>
|
|
<tr>
|
|
<td class="ltd" width="100px">图片上传:</td>
|
|
<td>
|
|
<input type="file" name="file" id="file" onchange="filechange(event)" />
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="ltd" style="width:100px"></td>
|
|
<td class="rtd" style="width:400px"><img src="" style="height:50px" id="img-change"></td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="2">
|
|
<div align="center">
|
|
<input type="submit" id="submitid" value="提交" class="l-button" />
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
|
|
@section scripts{
|
|
<script src="@Url.Content("~/Scripts/ajaxfileupload.js?v1.0.4")"></script>
|
|
<script type="text/javascript" src="@Url.Content("~/ueditor/ueditor.config.js")"></script>
|
|
<script type="text/javascript" src="@Url.Content("~/ueditor/ueditor.all.js")"></script>
|
|
<script type="text/javascript">
|
|
var editor;
|
|
|
|
editor = UE.getEditor("myEditor", { autoHeightEnabled: false, initialFrameHeight: 300, initialFrameWidth: 600});
|
|
$(function () {
|
|
@*
|
|
$("#save").bind("click", function () {
|
|
$.ajax("@Url.Action("SaveWeiXinNR")", {
|
|
type: "post", dataType: "json", data: {
|
|
id: $("#id").val(),
|
|
parm_name: $("#parm_name").val(), Parm_value: editor.getContent()
|
|
}, success: function (data) {
|
|
$.ligerDialog.alert(data.Message);
|
|
}
|
|
});
|
|
});
|
|
});
|
|
*@
|
|
|
|
var filechange = function (event) {
|
|
var files = event.target.files, file;
|
|
if (files && files.length > 0) {
|
|
// 获取目前上传的文件
|
|
file = files[0];// 文件大小校验的动作
|
|
//if (file.size > 1024 * 1024 * 2) {
|
|
// alert('图片大小不能超过 2MB!');
|
|
// return false;
|
|
//}
|
|
// 获取 window 的 URL 工具
|
|
var URL = window.URL || window.webkitURL;
|
|
// 通过 file 生成目标 url
|
|
var imgURL = URL.createObjectURL(file);
|
|
//用attr将img的src属性改成获得的url
|
|
$("#img-change").attr("src", imgURL);
|
|
// 使用下面这句可以在内存中释放对此 url 的伺服,跑了之后那个 URL 就无效了
|
|
// URL.revokeObjectURL(imgURL);
|
|
}
|
|
};
|
|
$("#submitid").click(function () {
|
|
if ($("#title").val().trim() == "") {
|
|
$.ligerDialog.alert("请输入标题!");
|
|
return;
|
|
}
|
|
if (editor.getContent().trim() == "") {
|
|
$.ligerDialog.alert("请输入内容!");
|
|
return;
|
|
}
|
|
|
|
//if ($("#file").val() == "") {
|
|
// $.ligerDialog.alert("请先选择上传文件");
|
|
// return;
|
|
//}
|
|
|
|
$.ajaxFileUpload({
|
|
url: "@Url.Action("repositorySaveData")",
|
|
type: "post",
|
|
dataType: "json",
|
|
data: {
|
|
title: $("#title").val(),
|
|
content: editor.getContent()
|
|
},
|
|
fileElementId: "file", // 上传文件的id、name属性名
|
|
success: function (data) {
|
|
$.ligerDialog.alert(data.Message, function () { window.parent.init(); });
|
|
},
|
|
error: function (e) {
|
|
$.ligerDialog.warn(e.responseText);
|
|
}
|
|
});
|
|
});
|
|
});
|
|
</script>
|
|
}
|
|
|