纽威
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

316 lines
10 KiB

3 years ago
  1. @{
  2. ViewBag.Title = "Form";
  3. Layout = "~/Views/Shared/_Form.cshtml";
  4. }
  5. <link href="~/Content/css/CommonReport/CommonReport.css" rel="stylesheet" />
  6. <script src="~/Content/js/CommonReport/CommonReport.js"></script>
  7. <link href="~/Content/css/bootstrap/bootstrap-select.css" rel="stylesheet" />
  8. <script src="~/Content/js/bootstrap/bootstrap-select.min.js"></script>
  9. <script>
  10. var _MenuID = $.request("MenuID");
  11. var _IsCommon = $.request("IsCommon");
  12. var _Cols = $.request("Cols");
  13. $(function () {
  14. $('#Select_Roles').selectpicker({ 'deselectAllText': '不选', 'selectAllText': '全选' });
  15. $('#Select_cols').selectpicker({ 'deselectAllText': '不选', 'selectAllText': '全选' });
  16. GetRoles();
  17. if (_IsCommon == "Y") {
  18. //通用报表列取列设置中的列
  19. GetColsFiledName();
  20. }
  21. else {
  22. GetColsByCols();
  23. }
  24. gridList();
  25. $(window).resize(function () {
  26. $("#gridList").setGridWidth($(window).width() * 0.99);
  27. $("#gridList").setGridWidth(document.body.clientWidth * 0.99);
  28. $("#gridList").setGridHeight($(window).height() - 96);
  29. $("#gridList").setGridHeight(document.body.clientHeight - 96);
  30. });
  31. });
  32. function gridList() {
  33. var colsList = $("#Select_cols").val(); var cols = "";
  34. if (colsList != null && colsList.length > 0) {
  35. for (var i = 0; i < colsList.length; i++) {
  36. if (cols == "") {
  37. cols += colsList[i];
  38. }
  39. else {
  40. cols += "," + colsList[i];
  41. }
  42. }
  43. }
  44. var RolesList = $("#Select_Roles").val(); var Roles = "";
  45. if (RolesList != null && RolesList.length > 0) {
  46. for (var i = 0; i < RolesList.length; i++) {
  47. if (Roles == "") {
  48. Roles += RolesList[i];
  49. }
  50. else {
  51. Roles += "," + RolesList[i];
  52. }
  53. }
  54. }
  55. document.getElementsByClassName("gridPanel")[0].innerHTML = ' <table id="gridList"></table>';
  56. var $gridList = $("#gridList");
  57. $gridList.dataGrid({
  58. url: "/SystemManage/CommonReport/GetColsVisible?" + Math.random(),
  59. postData: { MenuID: _MenuID ,Roles:Roles,Cols:cols},
  60. height: $(window).height() - 96,
  61. width: "100%",
  62. colModel: [
  63. // MenuId RoleId FieldName VisibleFlag WorkPoint
  64. { label: 'ID', name: 'ID', width: 80, align: 'left', hidden: true, },
  65. { label: '角色', name: '角色', width: 80, align: 'left', },
  66. { label: '列字段', name: '列字段', width: 80, align: 'left', },
  67. { label: ' ', name: ' ', width: 20, align: 'left', },
  68. ],
  69. sortname: '角色,列字段',
  70. viewrecords: true,
  71. rownumbers: true,
  72. multiselect: true,
  73. rowNum: 1000,
  74. });
  75. }
  76. function GetRoles() {
  77. $.ajax({
  78. url: "/SystemManage/CommonReport/GetRoles?" + "&" + Math.random(),
  79. dataType: "json",
  80. async: false,
  81. success: function (data) {
  82. if (data != false && data != null && data.length > 0) {
  83. $("#Select_Roles").find("option").remove();
  84. for (var i = 0; i < data.length; i++) {
  85. $("#Select_Roles").append("<option value='" + data[i].RolesID + "'>" + data[i].Roles + "</option>");
  86. }
  87. }
  88. $('#Select_Roles').selectpicker('refresh');
  89. $('#Select_Roles').selectpicker('render');
  90. }
  91. });
  92. }
  93. function GetColsFiledName()
  94. {
  95. $.ajax({
  96. url: "/SystemManage/CommonReport/GetColsFiledName?MenuID=" + _MenuID + "&" + Math.random(),
  97. dataType: "json",
  98. async: false,
  99. success: function (data) {
  100. if (data != false && data != null && data.length > 0) {
  101. $("#Select_cols").find("option").remove();
  102. for (var i = 0; i < data.length; i++) {
  103. $("#Select_cols").append("<option value='" + data[i].FiledName + "'>" + data[i].FiledName + "</option>");
  104. }
  105. }
  106. $('#Select_cols').selectpicker('refresh');
  107. $('#Select_cols').selectpicker('render');
  108. }
  109. });
  110. }
  111. function GetColsByCols() {
  112. if (_Cols != '') {
  113. var ColsData = _Cols.split(',');
  114. $("#Select_cols").find("option").remove();
  115. if (ColsData != null && ColsData.length > 0) {
  116. for (var i = 0; i < ColsData.length; i++) {
  117. $("#Select_cols").append("<option value='" + ColsData[i] + "'>" + ColsData[i] + "</option>");
  118. }
  119. }
  120. $('#Select_cols').selectpicker('refresh');
  121. $('#Select_cols').selectpicker('render');
  122. }
  123. }
  124. //所有栏位 所有角色都可见
  125. function btn_All()
  126. {
  127. $.ajax({
  128. url: "/SystemManage/CommonReport/SetColsVisibleALL?" + Math.random(),
  129. type: "post",
  130. data: { Cols: _Cols, IsCommon: _IsCommon, MenuID: _MenuID },
  131. async: false,
  132. success: function (data) {
  133. if (data == "操作成功。") {
  134. alert(data);
  135. }
  136. else { alert(data); }
  137. gridList();
  138. },
  139. error: function (aa) {
  140. alert("异常:" + aa.responseText);
  141. }
  142. });
  143. }
  144. //查询
  145. function btn_Search()
  146. {
  147. gridList();
  148. }
  149. //新增可见
  150. function btn_ADD() {
  151. var colsList = $("#Select_cols").val(); var cols = "";
  152. if (colsList != null && colsList.length > 0) {
  153. for (var i = 0; i < colsList.length; i++) {
  154. if (cols == "") {
  155. cols += colsList[i];
  156. }
  157. else {
  158. cols += "," + colsList[i];
  159. }
  160. }
  161. }
  162. else {
  163. alert("请选择列");
  164. return;
  165. }
  166. var RolesList = $("#Select_Roles").val(); var Roles = "";
  167. if (RolesList != null && RolesList.length > 0) {
  168. for (var i = 0; i < RolesList.length; i++) {
  169. if (Roles == "") {
  170. Roles += RolesList[i];
  171. }
  172. else {
  173. Roles += "," + RolesList[i];
  174. }
  175. }
  176. }
  177. else {
  178. alert("请选择角色");
  179. return;
  180. }
  181. $.ajax({
  182. url: "/SystemManage/CommonReport/SetColsVisibleAdd?" + Math.random(),
  183. type: "post",
  184. data: { Cols: cols, Roles: Roles, MenuID: _MenuID },
  185. async: false,
  186. success: function (data) {
  187. if (data == "操作成功。") {
  188. alert(data);
  189. }
  190. else { alert(data); }
  191. gridList();
  192. },
  193. error: function (aa) {
  194. alert("异常:" + aa.responseText);
  195. }
  196. });
  197. }
  198. //删除
  199. function btn_Del() {
  200. var IDList = "";
  201. var A_RowDatas = $("#gridList").jqGrid('getDataIDs');
  202. var ids = $("#gridList").jqGrid('getGridParam', 'selarrrow'); //获取 多行数据
  203. if (ids.length <= 0) {
  204. $.modalAlert("请选择数据!");
  205. return;
  206. }
  207. for (var i in ids) {
  208. var RowData = $("#gridList").jqGrid('getRowData', ids[i]);
  209. var id = RowData.ID.toString();
  210. IDList = IDList + id + ",";
  211. }
  212. $.ajax({
  213. url: "/SystemManage/CommonReport/SetColsVisibleDel",
  214. type: "post",
  215. data: { MenuID: _MenuID, IDList: IDList },
  216. async: false,
  217. success: function (data) {
  218. if (data == "操作成功。") {
  219. alert(data);
  220. gridList();
  221. }
  222. else { alert(data); }
  223. }
  224. })
  225. }
  226. </script>
  227. <form id="form1">
  228. <div style="margin-top: 10px; margin-left: 10px; margin-right: 10px;">
  229. <div class="form-group" style="height:40px;margin-bottom:5px">
  230. <table class="form" style="width:100%">
  231. <tr>
  232. <th class="formTitle">字段: </th>
  233. <td class="formValue" style="width:160px">
  234. <select id="Select_cols" name="Select_cols" title="" class="selectpicker" data-actions-box="true" data-width="140px" style="margin-right:100px" multiple="multiple"></select>
  235. </td>
  236. <th class="formTitle">角色: </th>
  237. <td class="formValue" style="width:160px">
  238. <select id="Select_Roles" name="Select_Roles" title="" class="selectpicker" data-actions-box="true" data-width="140px" style="margin-right:100px" multiple="multiple"></select>
  239. </td>
  240. <td class="formValue" style="width:290px">
  241. &nbsp;
  242. <a id="Btn_Search" authorize="yes" class="btn btn-primary dropdown-text " onclick="btn_Search()"><i class="fa fa-search"></i>查询</a>
  243. &nbsp;
  244. <a id="Btn_ADD" authorize="yes" class="btn btn-primary dropdown-text " onclick="btn_ADD()"><i class="fa fa-plus"></i>新增</a>
  245. &nbsp;
  246. <a id="Btn_Del" authorize="yes" class="btn btn-primary dropdown-text " onclick="btn_Del()"><i class="fa fa-minus"></i>删除</a>
  247. &nbsp;
  248. <a id="Btn_All" authorize="yes" class="btn btn-primary dropdown-text " onclick="btn_All()"><i class="fa fa-save"></i>全可见</a>
  249. </td>
  250. </tr>
  251. </table>
  252. </div>
  253. <div class="gridPanel">
  254. <table id="gridList"></table>
  255. </div>
  256. </div>
  257. </form>