_Question.cshtml 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  1. @using WeOnlineApp.Configuration
  2. @using WeOnlineApp.Helpers
  3. @using WeOnlineApp.Views.Shared.Modals
  4. @using WeOnlineApp.Views.Shared.SearchForm
  5. @using WeOnlineApp.Views.Shared.Table
  6. @{
  7. var table = new TableViewModel(IwbConsts.ApiAppUrl + "Question/GetAll", tableId: "table-q", hasBox: false).SetPageArray(4)
  8. .SetFields(new List<FieldItem>()
  9. {
  10. //new FieldItem("subjectCategory", "课程类型"),
  11. new FieldItem("title", "问题标题",isSort:false),
  12. //new FieldItem("contentInfo", "问题内容"),
  13. new FieldItem("campName", "课程名称","CampFormatter",isSort:false),
  14. new FieldItem("questionState", "问题状态","StateFormatter",isSort:false),
  15. new FieldItem("answerDateTime", "解答时间","AnswerDateTimeFormatter",isSort:false),
  16. new FieldItem("id", "查看详情","ActionFormatter",isSort:false),
  17. });
  18. }
  19. <style>
  20. .table-sm .iwb-checkbox > span {
  21. border-radius: 3px;
  22. top: -1px;
  23. left: 6PX;
  24. height: 15px;
  25. width: 15px;
  26. color: #008080;
  27. }
  28. .table-sm th, .table-sm td {
  29. font-size: 14px;
  30. padding-top: 2px !important;
  31. padding-bottom: 2px !important;
  32. }
  33. .table-sm .fixed-table-container thead th .th-inner, .table-sm .fixed-table-container tbody td .th-inner {
  34. line-height: 1;
  35. font-size: 14px;
  36. }
  37. .bootstrap-table .table thead > tr > th {
  38. padding: 0;
  39. margin: 0;
  40. background: #008080;
  41. color: #fff;
  42. }
  43. .bootstrap-table .fixed-table-container {
  44. border: 1px solid #008080;
  45. border-top: none;
  46. }
  47. .fixed-table-container tbody tr td {
  48. color: #008080;
  49. }
  50. .fixed-table-container tbody tr.selected td {
  51. background: #008080;
  52. color: #fff;
  53. }
  54. .fixed-table-container tbody tr.selected .iwb-checkbox > span {
  55. background: #fff;
  56. }
  57. .fixed-table-pagination .pagination-info {
  58. color: #008080;
  59. line-height: 20px;
  60. font-size: 12px;
  61. }
  62. .fixed-table-pagination div.pagination, .fixed-table-pagination .pagination-detail {
  63. margin-top: 3px;
  64. margin-bottom: 0px;
  65. }
  66. .page-link {
  67. color: #008080;
  68. background-color: #f5f5f5;
  69. }
  70. .page-item.active .page-link {
  71. z-index: 1;
  72. color: #fff;
  73. background-color: #008080;
  74. border-color: #008080;
  75. }
  76. .fixed-table-pagination div.pagination .pagination {
  77. margin-top: 2px;
  78. }
  79. .fixed-table-pagination .pagination a {
  80. padding: 2px 8px;
  81. line-height: 1.25;
  82. font-size: 12px;
  83. }
  84. .table-action {
  85. cursor: pointer;
  86. }
  87. </style>
  88. <div class="table-sm" style="display: none">
  89. @Html.Partial("Table/_Table", table)
  90. </div>
  91. @{
  92. var modal = new ModalViewModel("我要提问", "", new ModalBodyViewModel(new List<Input>()
  93. {
  94. new InputHide("id"),
  95. new InputHide("subjectCategoryNo", "课程类型"),
  96. new InputHide("campNo", "课程名称"),
  97. new Input("campName", "课程名称",placeholder:"未选择课程").SetNotRequired().SetDisabled(),
  98. new Input("title", "问题标题"),
  99. new InputTextarea("contentInfo", "问题内容"),
  100. }, "form-q"), "modal-q");
  101. var modal2 = new ModalViewModel("我要答疑", "", new ModalBodyViewModel(new List<Input>()
  102. {
  103. new InputHide("id"),
  104. new InputHide("questionNo"),
  105. new Input("campName", "课程名称",placeholder:"未选择课程").SetNotRequired().SetDisabled(),
  106. new Input("title", "问题标题").SetDisabled(),
  107. new InputTextarea("contentInfo", "答疑内容"),
  108. }, "form-a"), "modal-a");
  109. }
  110. @using (Html.BeginScripts())
  111. {
  112. @Html.Partial("Modals/_Modal", modal)
  113. @Html.Partial("Modals/_Modal", modal2)
  114. <script type="text/javascript">
  115. var tableQueryType, initFlag=false;
  116. function LoadQuestion(that) {
  117. $(that).closest('.nav-tabs').find('.active').removeClass('active');
  118. $(that).addClass('active');
  119. tableQueryType = $(that).data('type');
  120. if (!initFlag) {
  121. initFlag = true;
  122. LoadTable({
  123. table: 'table-q',
  124. queryParams: QueryParams,
  125. height:183,
  126. });
  127. $('.table-sm').fadeIn(500);
  128. } else {
  129. RefreshTable('table-q',true);
  130. }
  131. }
  132. function QueryParams(params) {
  133. var searchList = [],kf='';
  134. searchList.push({
  135. KeyWords:window.curCampNo,
  136. KeyField: 'campNo',
  137. FieldType: @((int)FieldType.S),
  138. ExpType: @((int)ExpType.Equal)
  139. });
  140. if (tableQueryType == 2) {//我的问题
  141. searchList.push({
  142. KeyWords: '@AbpSession.UserId',
  143. KeyField: 'CreatorUserId',
  144. FieldType: @((int)FieldType.L),
  145. ExpType: @((int)ExpType.Equal)
  146. });
  147. } else if (tableQueryType == 3) {//我的收藏
  148. kf = "1";
  149. }
  150. return {
  151. MaxResultCount: params.limit,
  152. SkipCount: params.offset,
  153. sorting: params.sort ? params.sort + ' ' + params.order : '',
  154. keyField: kf,
  155. fieldType: 0,
  156. expType: 0,
  157. keyWords: window.curSubjectCategoryNo,
  158. SearchList: searchList
  159. };
  160. }
  161. </script>
  162. <script type="text/javascript">
  163. function Question() {
  164. OpenModal({
  165. url: abp.appUrl + "Question/create",
  166. modal: "modal-q",
  167. table: 'table-q',
  168. data: { id: "", subjectCategoryNo: window.curSubjectCategoryNo, campNo: window.curCampNo, campName: window.curCampName }
  169. });
  170. }
  171. function Answer() {
  172. var row = $('#table-q').bootstrapTable("getSelections")[0];
  173. if (row) {
  174. OpenModal({
  175. url: abp.appUrl + "Question/AddAnswer",
  176. modal: "modal-a",
  177. data: {
  178. questionNo: row.id,
  179. title: row.title,
  180. campName: row.campName
  181. }
  182. });
  183. } else {
  184. abp.message.warn("请选择一个问题进行答疑!");
  185. }
  186. }
  187. function Favorite(that) {
  188. var favorite = $(that).data('favorite'), id = $(that).data('id');
  189. $.iwbAjax({
  190. table: 'table-q',
  191. isValidate: false,
  192. data: {
  193. id: id,
  194. isFavorite: !favorite
  195. },
  196. success: function () {
  197. $(that).data('favorite', !favorite);
  198. }
  199. });
  200. }
  201. function QuestionDetail(id) {
  202. window.location.href = "@Url.Action("Detail","Question")/"+id;
  203. //$.iwbAjax4({
  204. // url: abp.appUrl + "Question/GeQuestionDetail?no=" + id,
  205. // success: function(res) {
  206. // }
  207. //});
  208. }
  209. </script>
  210. <!--格式化-->
  211. <script id="formatter-script" type="text/javascript">
  212. function TypeFormatter(v) {
  213. var name = $('#hid-type option[value="' + v + '"]').text();
  214. switch (v) {
  215. case 0:
  216. return '<span class="label label-danger">' + name + '</span>';
  217. default:
  218. return '<span class="label label-info">' + name + '</span>';
  219. }
  220. }
  221. function CampFormatter(v) {
  222. if (v) {
  223. return '<span class="label label-warning">' + v + '</span>';
  224. }
  225. return '';
  226. }
  227. function StateFormatter(v) {
  228. if (v == @(QuestionStateDefinition.New)) {
  229. return '<span class="label label-danger">未解答</span>';
  230. } else if (v == @(QuestionStateDefinition.Answer)) {
  231. return '<span class="label label-success">已解答</span>';
  232. }
  233. return '';
  234. }
  235. function AnswerDateTimeFormatter(v,r,f,d) {
  236. if (r.questionState == @(QuestionStateDefinition.New)) {
  237. return "";
  238. }
  239. return DateTimeFormatter(v, r, f, d);
  240. }
  241. function ActionFormatter(v) {
  242. return '<span class="table-action" onclick="QuestionDetail(\'' + v +'\')"><i class="iconfont icon-eye" style="cursor:pointer;margin-right:5px;"></i>查看</span> ';
  243. }
  244. </script>
  245. }
  246. <section style="display: none">
  247. <select id="hid-type">
  248. <option value=""></option>
  249. </select>
  250. @*@Html.DropDownList("hid-type", type)*@
  251. </section>