EvalTarget.cshtml 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. @using WePlatform
  2. @using WePlatform.Configuration
  3. @using WePlatform.Authorization
  4. @using WePlatform.Views.Shared.Modals
  5. @using WePlatform.Views.Shared.SearchForm
  6. @using WePlatform.Views.Shared.Table
  7. @{
  8. ViewBag.Title = "评估指标";
  9. string activeMenu = PermissionNames.PagesEngineModelMgEvalTargetMg; //The menu item will be active for this page.
  10. ViewBag.ActiveMenu = activeMenu;
  11. string targetType = ViewBag.TargetType;
  12. var searchForm = new SearchFormViewModel(new List<SearchItem>()
  13. {
  14. new SearchItem("name","指标名称"),
  15. new SearchItem("version","指标版本"),
  16. new SearchItem("targetType","指标类型",FieldType.I).SetSelectItem(targetType),
  17. }, "search-form", false);
  18. var table = new TableViewModel(IwbConsts.ApiAppUrl + "EvalTarget/GetAll", activeMenu, searchForm)
  19. .SetFields(new List<FieldItem>()
  20. {
  21. new FieldItem("name", "指标名称",align:"left"),
  22. new FieldItem("tag", "指标标签"),
  23. new FieldItem("version", "指标版本"),
  24. //new FieldItem("description", "指标描述"),
  25. new FieldItem("targetType", "指标类型","TargetTypeFormatter"),
  26. new FieldItem("", "操作","ActionsFormatter"),
  27. })
  28. .SetPageArray(1000);
  29. }
  30. @section css{
  31. }
  32. @Html.Partial("Table/_Table", table)
  33. @section modal{
  34. <!--Main Modal-->
  35. @{
  36. var modal = new ModalViewModel("指标", new ModalBodyViewModel(new List<Input>()
  37. {
  38. new InputHide("id"),
  39. new InputHide("typePath"),
  40. new Input("parentNo", "父指标").SetSelectOptions(""),
  41. new Input("name", "指标名称"),
  42. new Input("tag", "指标标签"),
  43. new Input("version", "指标版本"),
  44. new Input("targetType", "指标类型").SetSelectOptions(targetType),
  45. new InputTextarea("description", "指标描述").SetNotRequired(),
  46. }));
  47. }
  48. @Html.Partial("Modals/_Modal", modal)
  49. }
  50. @section scripts
  51. {
  52. <script type="text/javascript">
  53. var $table = $("#table");
  54. var actions = [], funs = [];
  55. $(function () {
  56. funs = LoadTreeTable({
  57. rootNo: null,
  58. table: "table",
  59. idField: 'id',
  60. treeShowField: 'name',
  61. customDataField: ['typePath']
  62. }) || { none: function () { console.log("No type"); } };
  63. var btnCreate = funs['btnCreate'];
  64. funs['btnCreate'] = function (url, id) {
  65. console.log("Add", id);
  66. var row;
  67. if (typeof id === "string" && id !== "") {
  68. row = $table.bootstrapTable("getRowByUniqueId", id);
  69. }
  70. if (row) {
  71. $.iwbAjax4({
  72. url: abp.appUrl + 'EvalTarget/GetSelectStr',
  73. success: function (res) {
  74. $("#parentNo").empty().html(res);
  75. btnCreate(url, id);
  76. }
  77. });
  78. } else {
  79. abp.message.warn(abp.localization.iwbZero('SelectRecordOperation'));
  80. }
  81. }
  82. var btnUpdate = funs['btnUpdate'];
  83. funs['btnUpdate'] = function (url, id) {
  84. console.log("Edit", id);
  85. var row;
  86. if (typeof id === "string" && id !== "") {
  87. row = $table.bootstrapTable("getRowByUniqueId", id);
  88. }
  89. if (row) {
  90. $.iwbAjax4({
  91. url: abp.appUrl + 'EvalTarget/GetSelectStr',
  92. success: function (res) {
  93. $("#parentNo").empty().html(res);
  94. btnUpdate(url, id);
  95. }
  96. });
  97. } else {
  98. abp.message.warn(abp.localization.iwbZero('SelectRecordOperation'));
  99. }
  100. }
  101. });
  102. </script>
  103. <script>
  104. //操作按钮
  105. function ActionsFormatter(v, r) {
  106. r._parent = null;
  107. var str = '<div class="btn-tool">';
  108. for (var i = 0; i < actions.length; i++) {
  109. //str += '<span class="table-action" onclick="funs[' + actions[i]["type"] + '](\'' + actions[i]["url"] + '\',\'' + r.id + '\',this)"><i class="' + actions[i]["icon"] + '"></i>' + actions[i]["name"] + ' </span>';
  110. str += '<span class="table-action" onclick="FunctionCall(\'' + actions[i]["type"] + '\',\'' + actions[i]["url"] + '\',\'' + r.id + '\',this)"><i class="' + actions[i]["icon"] + '"></i>' + actions[i]["name"] + ' </span>';
  111. }
  112. str += '</div>';
  113. return str;
  114. }
  115. function FunctionCall(type, url, id, that) {
  116. funs[type] ? funs[type].call(this, url, id, that) : funs["none"].call(this);
  117. }
  118. </script>
  119. <!--格式化-->
  120. <script id="formatter-script" type="text/javascript">
  121. function TypeFormatter(v) {
  122. var name = $('#hid-type option[value="' + v + '"]').text();
  123. switch (v) {
  124. case 0:
  125. return '<span class="label label-danger">' + name + '</span>';
  126. default:
  127. return '<span class="label label-info">' + name + '</span>';
  128. }
  129. }
  130. function TargetTypeFormatter(v) {
  131. if (!v) {
  132. return "";
  133. }
  134. var name = $('#hid-target-type option[value="' + v + '"]').text();
  135. return name;
  136. }
  137. </script>
  138. }
  139. <section style="display: none">
  140. <select id="hid-type">
  141. <option value=""></option>
  142. </select>
  143. <select id="hid-target-type">
  144. <option value="">
  145. @Html.Raw(targetType)
  146. </option>
  147. </select>
  148. @*@Html.DropDownList("hid-type", type)*@
  149. </section>