Knowledge.cshtml 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. @using WePlatform.Configuration
  2. @using WePlatform.Authorization
  3. @using WePlatform.Views.Shared.Modals
  4. @using WePlatform.Views.Shared.SearchForm
  5. @using WePlatform.Views.Shared.Table
  6. @{
  7. ViewBag.Title = "知识信息引导库管理";
  8. string activeMenu = PermissionNames.PagesResourceMgGuideMgKnowledgeMg; //The menu item will be active for this page.
  9. ViewBag.ActiveMenu = activeMenu;
  10. string plans = ViewBag.Plan;
  11. var searchForm = new SearchFormViewModel(new List<SearchItem>()
  12. {
  13. new SearchItem("name", "知识名称"),
  14. });
  15. var table = new TableViewModel(IwbConsts.ApiAppUrl + "Knowledge/GetAll", activeMenu, searchForm)
  16. .SetFields(new List<FieldItem>()
  17. {
  18. new FieldItem("id", "编码"),
  19. new FieldItem("name", "知识名称"),
  20. new FieldItem("description", "知识详情"),
  21. });
  22. }
  23. @section css{
  24. <style>
  25. .tree {
  26. color: inherit;
  27. }
  28. </style>
  29. }
  30. @Html.Partial("Table/_Table", table)
  31. @section modal{
  32. <!--Main Modal-->
  33. @{
  34. var input = new ModalBodyViewModel(new List<Input>()
  35. {
  36. new InputHide("id"),
  37. new Input("name", "知识名称").SetNotRequired(),
  38. new InputTextarea("description", "知识详情").SetNotRequired(),
  39. });
  40. }
  41. <section>
  42. <div class="modal fade show" id="modal" tabindex="-1" aria-modal="true">
  43. <div class="modal-dialog modal-lg" style="margin-top: 190.5px;">
  44. <div class="modal-content">
  45. @Html.Partial("Modals/_ModalHeader", new ModalHeaderViewModel("知识信息"))
  46. <div class="modal-body" style="padding: 0">
  47. <form class="form-horizontal " id="form" novalidate="novalidate" style="padding: 0">
  48. <div class="card card-primary card-outline card-outline-tabs" style="margin-bottom: 0; border-top: 0; ">
  49. <div class="card-header p-0 border-bottom-0">
  50. <ul class="nav nav-tabs" id="knowledge-tab" role="tablist">
  51. <li class="nav-item">
  52. <a class="nav-link active" id="tab-base" data-toggle="pill" href="#tab-content-base" role="tab">基础信息</a>
  53. </li>
  54. <li class="nav-item">
  55. <a class="nav-link" id="tab-role" data-toggle="pill" href="#tab-content-plan" role="tab">应急预案</a>
  56. </li>
  57. </ul>
  58. </div>
  59. <div class="card-body">
  60. <div class="tab-content" id="custom-tabs-four-tabContent">
  61. <div class="tab-pane fade show active" id="tab-content-base" role="tabpanel">
  62. @Html.Partial("Modals/_ModalInput", input)
  63. </div>
  64. <div class="tab-pane fade" id="tab-content-plan" role="tabpanel">
  65. <div class="dynamic-box" style="margin: 0 10px;">
  66. <div class="row iwb-dynamic-box">
  67. <div class="dynamic-label col-sm-10">
  68. <label class="iwb-label">应急预案</label>
  69. </div>
  70. <div class="dynamic-control col-sm-2">
  71. <label class="iwb-label">增加/删除</label>
  72. </div>
  73. </div>
  74. <div class="row iwb-dynamic-box">
  75. <div class="col-sm-10">
  76. <div class="input-group input-group-sm">
  77. <select class="form-control tree" id="plan" name="plan" style="width: 100%">
  78. @(Html.Raw(plans))
  79. </select>
  80. </div>
  81. </div>
  82. <div class="col-sm-2">
  83. <button class="btn btn-sm btn-block btn-add" type="button" onclick="AddDynamicBox(this)">增加</button>
  84. </div>
  85. </div>
  86. </div>
  87. </div>
  88. </div>
  89. </div>
  90. </div>
  91. </form>
  92. </div>
  93. @Html.Partial("Modals/_ModalFooter", "0")
  94. </div>
  95. </div>
  96. </div>
  97. </section>
  98. }
  99. @section scripts
  100. {
  101. <script type="text/javascript">
  102. var $table;
  103. $(function () {
  104. // $('#tab-content-plan .iwb-dynamic-box .form-control[name="plan"]').select2tree();
  105. $table = LoadTable();
  106. var funs = window.iwbfuns || { none: function () { console.log("No type"); } };
  107. funs["btnCreate"] = function () {
  108. Reset();
  109. BtnCreate({
  110. data: { id: "" },
  111. dataFun: GetKnowledgeData,
  112. select2tree: 'plan'
  113. });
  114. }
  115. funs["btnUpdate"] = function () {
  116. var row = $table.bootstrapTable("getSelections")[0];
  117. if (row) {
  118. Reset();
  119. BtnUpdate({
  120. disabled: "",
  121. dataFun: GetKnowledgeData,
  122. select2tree: 'plan',
  123. shownAfter: function () {
  124. ParsePlans(row.plans);
  125. }
  126. });
  127. }
  128. };
  129. });
  130. function GetKnowledgeData() {
  131. var data = $.formSerialize($('#modal form'));
  132. var plans = [];
  133. $('#modal #tab-content-plan .iwb-dynamic-box').find('.form-control[name="plan"]').each(
  134. function () {
  135. var v = $(this).val();
  136. if (v && plans.indexOf(v) == -1) {
  137. plans.push(v);
  138. }
  139. });
  140. data.plans = plans;
  141. console.log(data);
  142. return data;
  143. }
  144. function ParsePlans(nos) {
  145. if (!nos) {
  146. return;
  147. }
  148. // var noArr = nos.split(",");
  149. for (var i = 0; i < nos.length; i++) {
  150. var no = nos[i];
  151. var $that = i === 0 ? $('#modal #tab-content-plan .iwb-dynamic-box').eq(1) : AddDynamicBox($('#modal #tab-content-plan .iwb-dynamic-box').eq(1).find('.btn-add'));
  152. $that.find('.form-control[name="plan"]').val(no).select2tree();
  153. }
  154. }
  155. function Reset() {
  156. $('#modal .iwb-dynamic-box-delete').remove();
  157. $('#knowledge-tab li').eq(0).find('a').tab('show');
  158. }
  159. </script>
  160. <!--格式化-->
  161. <script id="formatter-script" type="text/javascript">
  162. function TypeFormatter(v) {
  163. var name = $('#hid-type option[value="' + v + '"]').text();
  164. switch (v) {
  165. case 0:
  166. return '<span class="label label-danger">' + name + '</span>';
  167. default:
  168. return '<span class="label label-info">' + name + '</span>';
  169. }
  170. }
  171. </script>
  172. }
  173. <section style="display: none">
  174. <select id="hid-type">
  175. <option value=""></option>
  176. </select>
  177. @*@Html.DropDownList("hid-type", type)*@
  178. </section>