PhoneQuestion.cshtml 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  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.PagesBasicMgPhoneQuestionMg; //The menu item will be active for this page.
  10. ViewBag.ActiveMenu = activeMenu;
  11. string answerType = ViewBag.AnswerType;
  12. var searchForm = new SearchFormViewModel(new List<SearchItem>()
  13. {
  14. }, "search-form", false);
  15. var table = new TableViewModel(IwbConsts.ApiAppUrl + "PhoneQuestion/GetAll", activeMenu, searchForm)
  16. .SetFields(new List<FieldItem>()
  17. {
  18. new FieldItem("name", "简称"),
  19. new FieldItem("content", "内容"),
  20. //new FieldItem("type", ""),
  21. //new FieldItem("tag", "标签"),
  22. });
  23. var input = new ModalBodyViewModel(new List<Input>()
  24. {
  25. new InputHide("id"),
  26. new Input("name", "简称").SetNotRequired(),
  27. new InputTextarea("content", "提问内容").SetNotRequired(),
  28. //new InputNumber("type", "").SetNotRequired(),
  29. //new Input("tag", "标签").SetNotRequired(),
  30. });
  31. }
  32. @section css{
  33. }
  34. @Html.Partial("Table/_Table", table)
  35. @section modal{
  36. <!--Main Modal-->
  37. <section>
  38. <div class="modal fade show" id="modal" tabindex="-1" aria-modal="true">
  39. <div class="modal-dialog modal-lg" style="margin-top: 190.5px;">
  40. <div class="modal-content">
  41. @Html.Partial("Modals/_ModalHeader", new ModalHeaderViewModel("问题"))
  42. <div class="modal-body" style="padding: 0">
  43. <form class="form-horizontal " id="form" novalidate="novalidate" style="padding: 0">
  44. <div class="card card-primary card-outline card-outline-tabs" style="margin-bottom: 0; border-top: 0; ">
  45. <div class="card-header p-0 border-bottom-0">
  46. <ul class="nav nav-tabs" role="tablist">
  47. <li class="nav-item">
  48. <a class="nav-link active" id="tab-base" data-toggle="pill" href="#tab-content-base" role="tab">基础信息</a>
  49. </li>
  50. <li class="nav-item">
  51. <a class="nav-link" data-toggle="pill" href="#tab-content-base2" role="tab">配置答案</a>
  52. </li>
  53. </ul>
  54. </div>
  55. <div class="card-body">
  56. <div class="tab-content" id="scene-tabContent">
  57. <div class="tab-pane fade show active" id="tab-content-base" role="tabpanel">
  58. @Html.Partial("Modals/_ModalInput", input)
  59. </div>
  60. <div class="tab-pane fade" id="tab-content-base2" role="tabpanel">
  61. <div class="iwb-dynamic-box" style="padding: 10px 0;margin: 10px 0;border: 1px solid #11998e;border-radius: 8px;">
  62. <input name="a_id" type="hidden" value="">
  63. <div class="form-group row">
  64. <label class=" iwb-label iwb-label-sm iwb-label-required">答案内容</label>
  65. <div class="">
  66. <div class="input-group input-group-sm ">
  67. <textarea rows="2" class="form-control required" name="a_content" placeholder="请输入内容..." value="" style="" aria-required="true"></textarea>
  68. </div>
  69. </div>
  70. </div>
  71. <div class="form-group row">
  72. <label class=" iwb-label iwb-label-sm iwb-label-required">关键字</label>
  73. <div class="">
  74. <div class="input-group input-group-sm ">
  75. <input class="form-control required" name="a_keywords" type="text" placeholder="请输入关键字..." style="" aria-required="true">
  76. </div>
  77. </div>
  78. </div>
  79. <div class="form-group row">
  80. <label class=" iwb-label iwb-label-sm iwb-label-required">答案类型</label>
  81. <div style="width: 65%;">
  82. <div class="input-group input-group-sm ">
  83. <select class="form-control required" name="a_type" placeholder="请选择答案类型..." value="" style="width:100%" tabindex="-1">
  84. @Html.Raw(answerType)
  85. </select>
  86. </div>
  87. </div>
  88. <div style="width: 20%;padding-left: 15px">
  89. <button class="btn btn-sm btn-block btn-add" type="button" onclick="AddDynamicBox(this)">增加</button>
  90. </div>
  91. </div>
  92. </div>
  93. </div>
  94. </div>
  95. </div>
  96. </div>
  97. </form>
  98. </div>
  99. @Html.Partial("Modals/_ModalFooter", "0")
  100. </div>
  101. </div>
  102. </div>
  103. </section>
  104. }
  105. @section scripts
  106. {
  107. <script type="text/javascript">
  108. var $table;
  109. $(function () {
  110. $table = LoadTable();
  111. var funs = window.iwbfuns || { none: function () { console.log("No type"); } };
  112. funs["btnCreate"] = function () {
  113. $('.iwb-dynamic-box-delete').remove();
  114. $('#tab-base').tab('show');
  115. BtnCreate({ data: { id: "" }, dataFun: GetSaveData });
  116. }
  117. funs["btnUpdate"] = function (url) {
  118. $('.iwb-dynamic-box-delete').remove();
  119. $('#tab-base').tab('show');
  120. var row = $table.bootstrapTable("getSelections")[0];
  121. if (row) {
  122. var no = row.id;
  123. BtnUpdate({
  124. url: url,
  125. dataFun: GetSaveData,
  126. disabled: "",
  127. shownAfter: function () {
  128. $.iwbAjax5({
  129. url: abp.appUrl + "query/GetQuestionAnswers?no=" + no,
  130. success: function (res) {
  131. if (res && res.length) {
  132. for (var i = 0; i < res.length; i++) {
  133. var answer = res[i];
  134. var $that = i === 0 ? $('#tab-content-base2 .iwb-dynamic-box').eq(0) : AddDynamicBox($('#tab-content-base2 .iwb-dynamic-box').eq(0).find('.btn-add'));
  135. $that.find('input[name="a_id"]').val(answer.id);
  136. $that.find('.form-control[name="a_content"]').val(answer.content);
  137. $that.find('.form-control[name="a_keywords"]').val(answer.keywords);
  138. $that.find('.form-control[name="a_type"]').val(answer.type).select2();
  139. }
  140. }
  141. }
  142. });
  143. }
  144. }, row);
  145. }
  146. };
  147. });
  148. function GetSaveData() {
  149. var data = {};
  150. data.id = $("#modal #id").val();
  151. data.name = $("#modal #name").val();
  152. data.content = $("#modal #content").val();
  153. data.answers = [];
  154. $('#tab-content-base2 .iwb-dynamic-box').each(function () {
  155. var $this = $(this);
  156. data.answers.push({
  157. id: $this.find('input[name="a_id"]').val(),
  158. content: $this.find('.form-control[name="a_content"]').val(),
  159. keywords: $this.find('.form-control[name="a_keywords"]').val(),
  160. type: $this.find('.form-control[name="a_type"]').val()
  161. });
  162. });
  163. return data;
  164. }
  165. </script>
  166. <!--格式化-->
  167. <script id="formatter-script" type="text/javascript">
  168. function TypeFormatter(v) {
  169. var name = $('#hid-type option[value="' + v + '"]').text();
  170. switch (v) {
  171. case 0:
  172. return '<span class="label label-danger">' + name + '</span>';
  173. default:
  174. return '<span class="label label-info">' + name + '</span>';
  175. }
  176. }
  177. </script>
  178. }
  179. <section style="display: none">
  180. <select id="hid-type">
  181. <option value=""></option>
  182. </select>
  183. @*@Html.DropDownList("hid-type", type)*@
  184. </section>