CampAttach.cshtml 8.9 KB

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