CampAttach.cshtml 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. @using WeOnlineApp.Configuration
  2. @using WeOnlineApp.Authorization
  3. @using WeOnlineApp.Views.Shared.Modals
  4. @using WeOnlineApp.Views.Shared.SearchForm
  5. @using WeOnlineApp.Views.Shared.Table
  6. @{
  7. ViewBag.Title = "培训营情景附件配置";
  8. string activeMenu = PermissionNames.PagesTrainMgCampMg; //The menu item will be active for this page.
  9. ViewBag.ActiveMenu = activeMenu;
  10. string fileType = "<option value=\"\" selected>请选择文件类型</option><option value=\"image\" >图片</option><option value=\"video\" >视频</option>";
  11. var campNo = ViewBag.CampNo;
  12. var searchForm = new SearchFormViewModel(new List<SearchItem>()
  13. {
  14. new SearchItem("sceneNo", "情景编号"),
  15. new SearchItem("sceneName", "情景简称"),
  16. });
  17. var searchForm2 = new SearchFormViewModel(new List<SearchItem>()
  18. {
  19. new SearchItem("fileName", "附件名称"),
  20. },"search-attach-form");
  21. var table = new TableViewModel(IwbConsts.ApiAppUrl + "Camp/GetSceneAttaches?no="+campNo,null, searchForm, tableId: "table")
  22. .SetFields(new List<FieldItem>()
  23. {
  24. new FieldItem("campName", "培训营"),
  25. new FieldItem("sceneNo", "情景编号"),
  26. new FieldItem("sceneName", "情景简称"),
  27. new FieldItem("", "附件信息","ActionFormatter").SetWidth(200),
  28. });
  29. var attachTable = new TableViewModel(IwbConsts.ApiAppUrl + "Camp/GetAttachFiles?no=" + campNo,null, searchForm2, tableId:"table-attach")
  30. .SetFields(new List<FieldItem>()
  31. {
  32. new FieldItem("fileTitle", "附件名称","LinkActionFormatter"),
  33. new FieldItem("", "操作","FileActionFormatter").SetWidth(120),
  34. });
  35. }
  36. @section css{
  37. }
  38. <div class="container-fluid">
  39. <div class="row">
  40. <div class="col-sm-8">
  41. @Html.Partial("Table/_Table", table)
  42. </div>
  43. <div class="col-sm-4">
  44. @Html.Partial("Table/_Table", attachTable)
  45. </div>
  46. </div>
  47. </div>
  48. @section modal{
  49. <!--Main Modal-->
  50. @{
  51. var modal = new ModalViewModel("情景附件配置", new ModalBodyViewModel(new List<Input>()
  52. {
  53. new InputHide("id"),
  54. new InputHide("campNo"),
  55. new InputHide("sceneNo"),
  56. new Input("sceneName", "情景简称"),
  57. new Input("attachNos", "情景附件").SetNotRequired().SetSelectOptions("",true),
  58. }), "modal-scene");
  59. var modalFile = new ModalViewModel("上传附件", new ModalBodyViewModel(new List<Input>()
  60. {
  61. new InputHide("id"),
  62. new InputHide("campNo"),
  63. new InputHide("tableName"),
  64. new InputHide("columnName"),
  65. new InputHide("sourceKey"),
  66. new Input("fileTitle", "附件名称"),
  67. new Input("fileType", "附件类型").SetSelectOptions(fileType),
  68. new InputFile("file", "上传文件").SetFileOption("fileInfo","fileName","fileExt",100),
  69. }),"modal-file");
  70. }
  71. @Html.Partial("Modals/_Modal", modal)
  72. @Html.Partial("Modals/_Modal", modalFile)
  73. }
  74. @section scripts
  75. {
  76. <script type="text/javascript">
  77. var $table = $('#table'), $attachTable = $('#table-attach'), campNo = '@(campNo)';
  78. $(function() {
  79. //$table.closest('.table-box').prepend(
  80. // '<div class="btn-toolbar row tableTool"><div class="btn-group btn-group-sm"></div></div>');
  81. //$attachTable.closest('.table-box').prepend(
  82. // '<div class="btn-toolbar row tableTool"><div class="btn-group btn-group-sm"><button type="button" class="btn btn-default menu-btn" onclick="AddFile()"><i class="far fa-plus-square"></i>添加附件</button></div></div>');
  83. //$attachTable.closest('.table-box').find('.tableTool>div').eq(0).remove();
  84. //$attachTable.closest('.table-box').find('.tableTool>div').eq(0).removeClass('col-sm-4').removeClass('col-lg-3');
  85. $attachTable.closest('.table-box').find('.tableTool>div').eq(0).prepend(
  86. '<div><div class="btn-group btn-group-sm"><button type="button" class="btn btn-default menu-btn" onclick="AddFile()"><i class="far fa-plus-square"></i>添加附件</button></div></div>');
  87. LoadTable({ table: $table });
  88. LoadTable({ table: $attachTable });
  89. });
  90. function SceneMap(attachNos, sceneNo, sceneName) {
  91. $.iwbAjax4({
  92. url: abp.appUrl + 'camp/GetAttachSelectStr?no=' + campNo,
  93. success: function(res) {
  94. $('#modal-scene #attachNos').html(res).select2();
  95. var arr = attachNos ? attachNos.split(',') : [];
  96. OpenModal({
  97. table: $table,
  98. modal: 'modal-scene',
  99. url: abp.appUrl + 'Camp/AttachFile',
  100. data: { campNo: campNo, sceneNo: sceneNo, sceneName: sceneName, attachNos: arr }
  101. });
  102. }
  103. });
  104. }
  105. function AddFile() {
  106. OpenModal({
  107. table: $attachTable,
  108. modal: 'modal-file',
  109. url: abp.appUrl + 'AttachFiles/FileUpload',
  110. data: { campNo: campNo, tableName: 'Train', columnName: 'Camp', sourceKey: campNo+"_"+$.now() }
  111. });
  112. }
  113. function DeleteFile(no) {
  114. MsgConfirm("确认要删除附件吗?","删除附件",
  115. function() {
  116. $.iwbAjax1({
  117. table: $attachTable,
  118. url: abp.appUrl + 'camp/DeleteAttach?no=' + no
  119. });
  120. });
  121. }
  122. </script>
  123. <!--格式化-->
  124. <script id="formatter-script" type="text/javascript">
  125. var icon = '<i class="fa fa-angle-double-right"></i>';
  126. function TypeFormatter(v) {
  127. var name = $('#hid-type option[value="' + v + '"]').text();
  128. switch (v) {
  129. case 0:
  130. return '<span class="label label-danger">' + name + '</span>';
  131. default:
  132. return '<span class="label label-info">' + name + '</span>';
  133. }
  134. }
  135. function ActionFormatter(v, r) {
  136. var str = '',
  137. action = '<span class="table-action" onclick="SceneMap(\'{0}\',\'{1}\',\'{2}\')">{3}配置附件</span>'.format(r.attachNos, r.sceneNo, r.sceneName,icon),
  138. link = '<a class="table-action" href="{1}" target="_blank">{0}</a>';
  139. str += action;
  140. if (r.attachInfos && r.attachInfos.length > 0) {
  141. //str += '<span style="padding-left:10px;color:red;">(</span>';
  142. r.attachInfos.forEach(function(val) {
  143. str += link.format(val.fileTitle, val.filePath);
  144. });
  145. //str += '<span style="color:red;">)</span>';
  146. }
  147. return str;
  148. }
  149. function LinkActionFormatter(v, r) {
  150. var str = '',
  151. link = '<a class="table-action" href="{1}" target="_blank" title="查看附件">{0}</a>';
  152. str += link.format(r.fileTitle+"."+r.fileExt, r.filePath);
  153. return str;
  154. }
  155. function FileActionFormatter(v, r) {
  156. var str = '',
  157. action = '<span class="table-action" onclick="DeleteFile(\'{0}\')">{1}删除附件</span>'.format(r.attachNo,
  158. icon);
  159. str += action;
  160. return str;
  161. }
  162. </script>
  163. }
  164. <section style="display: none">
  165. <select id="hid-type">
  166. <option value=""></option>
  167. </select>
  168. @*@Html.DropDownList("hid-type", type)*@
  169. </section>