CampAttach.cshtml 7.5 KB

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