ChapterList.cshtml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. @using Bowin.Web.Controls.Mvc;
  2. @using EMISOnline.Entities;
  3. @using EMISOnline.Web.Controls;
  4. @model EMISOnline.Entities.EM_CourseChapter
  5. @{
  6. ViewBag.Title = "List";
  7. }
  8. <div class="easyui-panel" data-options="border:false,fit:true" style="position: relative;">
  9. <div class="search_keyword">
  10. <div class="search_input">
  11. <ul>
  12. <li style="float: right;">
  13. @Html.Button(new ButtonOptions() { ID = "btnAdd", Text = "新增章节" })
  14. @Html.Button(new ButtonOptions() { ID = "btnSave", Text = "保 存" })
  15. @Html.Button(new ButtonOptions() { ID = "btnDelete", Text = "删除章节" })
  16. </li>
  17. </ul>
  18. </div>
  19. </div>
  20. <div style="float: left; width: 20%">
  21. 章节目录
  22. @Html.Tree(new TreeOptions() { ID = "ChaperTree", Name = "ChaperTree", IsCascadeCheck = false, ItemSourceUrl = "~/CourseBuild/GetChaperTree?CoursematerialID=" + Request["CoursematerialID"] })
  23. </div>
  24. <div style="float: left; width: 80%">
  25. @using (Ajax.BeginForm(new AjaxOptions
  26. {
  27. OnSuccess = "FormSuccess",
  28. OnBegin = "EMISFunction.FormSubmit",
  29. OnComplete = "EMISFunction.FormComplete",
  30. }))
  31. {
  32. @Html.Hidden("CourseChapterID")
  33. @Html.Hidden("CoursematerialID", Request["CoursematerialID"])
  34. @Html.Hidden("type")
  35. <div class="gobal-from">
  36. <table cellpadding="0" cellspacing="0">
  37. <tr>
  38. <th style="width: 100px;">
  39. 所属章节:
  40. </th>
  41. <td>
  42. <input id="ParentCourseChapterID" name="ParentCourseChapterID" class="easyui-combotree" data-options="url:'@Url.Content("~/CourseBuild/GetChaperTree?CoursematerialID=")@ViewBag.CoursematerialID'"/>
  43. @* @Html.DropdownList(new DropdownListOptions { CssClass = "easyui-combotree", ItemSourceUrl = "~/CourseBuild/GetChaperTree?CoursematerialID=F6FCCB89-0CF0-4F73-9B45-AD26733CA2B2", ID = "ParentCourseChapterID", Name = "ParentCourseChapterID" }, new Dictionary<string, string> { { "class", "easyui-combotree" } })*@
  44. </td>
  45. </tr>
  46. <tr>
  47. <th>
  48. 章节名称:
  49. </th>
  50. <td>
  51. @Html.TextBoxFor(model => model.Name, new TextBoxOptions { Required = true, IsRequired = true })
  52. </td>
  53. </tr>
  54. <tr>
  55. <th>
  56. 序号:
  57. </th>
  58. <td>
  59. @Html.TextBoxFor(model => model.OrderID, new TextBoxOptions { })
  60. </td>
  61. </tr>
  62. <tr id="tr_videotype" style="display: none;">
  63. <th>
  64. 视频分类:
  65. </th>
  66. <td>
  67. @Html.RadioButtonFor(model => model.VideoTypeID, (int)EMISOnline.ViewModel.EM_OnlineVideoType.Local, new { onclick = "switchVideo(" + ((int)EMISOnline.ViewModel.EM_OnlineVideoType.Local).ToString() + ")" })
  68. 本地视频
  69. @Html.RadioButtonFor(model => model.VideoTypeID, (int)EMISOnline.ViewModel.EM_OnlineVideoType.Outer, new { onclick = "switchVideo(" + ((int)EMISOnline.ViewModel.EM_OnlineVideoType.Outer).ToString() + ")" })
  70. 外部视频
  71. </td>
  72. </tr>
  73. <tr id="tr_video" style="display: none;">
  74. <th>
  75. 章节视频:
  76. </th>
  77. <td>
  78. @Html.Selector(new SelectorOptions()
  79. {
  80. DataUrl = Url.Content("~/CourseBuild/GetVideoList"),
  81. ID = "txtCourseVideoID",
  82. Name = "CourseVideoID",
  83. IsSingleSelect = true,
  84. QueryParams = "id:1",
  85. TextName = "Name",
  86. Title = "视频列表",
  87. Colums = "Key:CourseVideoID,视频标题:Name:250:query,播放地址:PlayUrl:466",
  88. DataValue = "CourseVideoID",
  89. DataText = "Name",
  90. Width = 400
  91. })
  92. </td>
  93. </tr>
  94. <tr id="tr_outervideo" style="display: none;">
  95. <th>
  96. 章节视频地址:
  97. </th>
  98. <td>
  99. @Html.TextBoxFor(x => x.OuterVideoUrl, new { style = "width: 400px;" })
  100. </td>
  101. </tr>
  102. </table>
  103. </div>
  104. }
  105. </div>
  106. </div>
  107. <script type="text/javascript" src="@Url.Content("~/Scripts/Bowin.Control.Core/Controls/Selector.js")"></script>
  108. <script type="text/javascript" src="@Url.Content("~/Scripts/NewEMIS.Comm.js")"></script>
  109. <script type="text/javascript">
  110. $(function () {
  111. $("#CourseChapterID").val("00000000-0000-0000-0000-000000000000");
  112. $("#ChaperTree").tree({
  113. onClick: function (node) {
  114. if (node.id != "") {
  115. $("#ParentCourseChapterID").combotree("setValue", node.attributes.parentId);
  116. $("#Name").val(node.text);
  117. $("#OrderID").val(node.attributes.orderId);
  118. $("#CourseChapterID").val(node.id);
  119. $("#txtCourseVideoID").triggerbox({ "data": [{ "text": "", "value": ""}] });
  120. if (node.attributes != null && node.attributes.parentId != "") {
  121. $('[name=VideoTypeID][value="' + node.attributes.videoTypeID.toString() + '"]').attr('checked', 'checked');
  122. $("input[type='text'][name='OuterVideoUrl']").val(node.attributes.outerVideoUrl);
  123. $("#tr_videotype").show();
  124. $.post("@Url.Content("~/CourseBuild/GetChaperVideo")?CourseChapterID=" + node.id, function (data) {
  125. if (data != null && data != "") {
  126. if (node.attributes.videoTypeID == 0) {
  127. $("#tr_video").show();
  128. $("#tr_outervideo").hide();
  129. $("#txtCourseVideoID").triggerbox({ "data": [{ "text": data.Name, "value": data.CourseVideoID}] });
  130. } else {
  131. $("#tr_video").hide();
  132. $("#tr_outervideo").show();
  133. }
  134. } else if (node.attributes.videoTypeID != 0) {
  135. $("#tr_video").hide();
  136. $("#tr_outervideo").show();
  137. }
  138. });
  139. }
  140. else {
  141. $("#txtCourseVideoID").triggerbox({ "data": [{ "text": "", "value": ""}] });
  142. $("input[type='text'][name='OuterVideoUrl']").val("");
  143. $("#tr_video").hide();
  144. $("#tr_outervideo").hide();
  145. $("#tr_videotype").hide();
  146. }
  147. }
  148. else {
  149. $("#ParentCourseChapterID").combotree("setValue", "");
  150. $("#Name").val("");
  151. $("#OrderID").val("");
  152. $("#CourseChapterID").val("00000000-0000-0000-0000-000000000000");
  153. $('[name=VideoTypeID][value="@ViewBag.DefaultVideoTypeID"]').attr('checked', 'checked');
  154. $("#txtCourseVideoID").triggerbox({ "data": [{ "text": "", "value": ""}] });
  155. $("input[type='text'][name='OuterVideoUrl']").val("");
  156. $("#tr_video").hide();
  157. $("#tr_outervideo").hide();
  158. $("#tr_videotype").hide();
  159. }
  160. }
  161. });
  162. $("#btnSave").click(function () {
  163. if ($("#Name").val() == "") {
  164. alertMsg("章节名称不能为空!");
  165. return;
  166. }
  167. $("#type").val(1);
  168. $(document.forms[0]).submit();
  169. });
  170. $("#btnAdd").click(function () {
  171. $("#ParentCourseChapterID").combotree("setValue", "");
  172. $("#Name").val("");
  173. $("#OrderID").val("");
  174. $("#CourseChapterID").val("00000000-0000-0000-0000-000000000000");
  175. $('[name=VideoTypeID][value="@ViewBag.DefaultVideoTypeID"]').attr('checked', 'checked');
  176. $("#txtCourseVideoID").triggerbox({ "data": [{ "text": "", "value": ""}] });
  177. $("input[type='text'][name='OuterVideoUrl']").val("");
  178. $("#tr_video").hide();
  179. $("#tr_outervideo").hide();
  180. $("#tr_videotype").hide();
  181. });
  182. $("#btnDelete").click(function () {
  183. if ($("#CourseChapterID").val() == "00000000-0000-0000-0000-000000000000") {
  184. alertMsg("请选择章节!");
  185. return;
  186. }
  187. $("#type").val(2);
  188. $(document.forms[0]).submit();
  189. });
  190. $("#ParentCourseChapterID").combotree({
  191. onSelect: function (node) {
  192. if (node.attributes != null) {
  193. $("#tr_videotype").show();
  194. if ($("#CourseChapterID").val() != "00000000-0000-0000-0000-000000000000") {
  195. $('[name=VideoTypeID][value="'+node.attributes.videoTypeID.toString()+'"]').attr('checked', 'checked');
  196. if (node.attributes.videoTypeID == @ViewBag.DefaultVideoTypeID) {
  197. $("#tr_video").show();
  198. $("#tr_outervideo").hide();
  199. } else {
  200. $("#tr_video").hide();
  201. $("#tr_outervideo").show();
  202. }
  203. } else {
  204. $("#tr_video").show();
  205. $("#tr_outervideo").hide();
  206. }
  207. }
  208. else {
  209. $('[name=VideoTypeID][value="@ViewBag.DefaultVideoTypeID"]').attr('checked', 'checked');
  210. $("#txtCourseVideoID").triggerbox({ "data": [{ "text": "", "value": ""}] });
  211. $("input[type='text'][name='OuterVideoUrl']").val("");
  212. $("#tr_video").hide();
  213. $("#tr_outervideo").hide();
  214. $("#tr_videotype").hide();
  215. }
  216. }
  217. });
  218. });
  219. function FormSuccess(data) {
  220. $('a').removeAttr('disabled', 'disabled');
  221. $('#loading').hide();
  222. $.messager.alert('系统信息', data.Message, null, function () {
  223. if (data.IsSuccess) {
  224. window.location.reload();
  225. }
  226. });
  227. }
  228. function switchVideo(videoType) {
  229. if (videoType == @ViewBag.DefaultVideoTypeID) {
  230. $("#tr_video").show();
  231. $("#tr_outervideo").hide();
  232. } else {
  233. $("#tr_video").hide();
  234. $("#tr_outervideo").show();
  235. }
  236. }
  237. </script>