CampAttach.cshtml 9.7 KB

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