纽威
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.

318 lines
10 KiB

3 years ago
3 years ago
3 years ago
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. $.modalAlertNew("WMS00015", aa.responseText);
  142. }
  143. });
  144. }
  145. //查询
  146. function btn_Search()
  147. {
  148. gridList();
  149. }
  150. //新增可见
  151. function btn_ADD() {
  152. var colsList = $("#Select_cols").val(); var cols = "";
  153. if (colsList != null && colsList.length > 0) {
  154. for (var i = 0; i < colsList.length; i++) {
  155. if (cols == "") {
  156. cols += colsList[i];
  157. }
  158. else {
  159. cols += "," + colsList[i];
  160. }
  161. }
  162. }
  163. else {
  164. alert("请选择列");
  165. return;
  166. }
  167. var RolesList = $("#Select_Roles").val(); var Roles = "";
  168. if (RolesList != null && RolesList.length > 0) {
  169. for (var i = 0; i < RolesList.length; i++) {
  170. if (Roles == "") {
  171. Roles += RolesList[i];
  172. }
  173. else {
  174. Roles += "," + RolesList[i];
  175. }
  176. }
  177. }
  178. else {
  179. alert("请选择角色");
  180. return;
  181. }
  182. $.ajax({
  183. url: "/SystemManage/CommonReport/SetColsVisibleAdd?" + Math.random(),
  184. type: "post",
  185. data: { Cols: cols, Roles: Roles, MenuID: _MenuID },
  186. async: false,
  187. success: function (data) {
  188. if (data == "操作成功。") {
  189. alert(data);
  190. }
  191. else { alert(data); }
  192. gridList();
  193. },
  194. error: function (aa) {
  195. //alert("异常:" + aa.responseText);
  196. $.modalAlertNew("WMS00015", aa.responseText);
  197. }
  198. });
  199. }
  200. //删除
  201. function btn_Del() {
  202. var IDList = "";
  203. var A_RowDatas = $("#gridList").jqGrid('getDataIDs');
  204. var ids = $("#gridList").jqGrid('getGridParam', 'selarrrow'); //获取 多行数据
  205. if (ids.length <= 0) {
  206. $.modalAlertNew("WMS00004");
  207. return;
  208. }
  209. for (var i in ids) {
  210. var RowData = $("#gridList").jqGrid('getRowData', ids[i]);
  211. var id = RowData.ID.toString();
  212. IDList = IDList + id + ",";
  213. }
  214. $.ajax({
  215. url: "/SystemManage/CommonReport/SetColsVisibleDel",
  216. type: "post",
  217. data: { MenuID: _MenuID, IDList: IDList },
  218. async: false,
  219. success: function (data) {
  220. if (data == "操作成功。") {
  221. alert(data);
  222. gridList();
  223. }
  224. else { alert(data); }
  225. }
  226. })
  227. }
  228. </script>
  229. <form id="form1">
  230. <div style="margin-top: 10px; margin-left: 10px; margin-right: 10px;">
  231. <div class="form-group" style="height:40px;margin-bottom:5px">
  232. <table class="form" style="width:100%">
  233. <tr>
  234. <th class="formTitle">字段: </th>
  235. <td class="formValue" style="width:160px">
  236. <select id="Select_cols" name="Select_cols" title="" class="selectpicker" data-actions-box="true" data-width="140px" style="margin-right:100px" multiple="multiple"></select>
  237. </td>
  238. <th class="formTitle">角色: </th>
  239. <td class="formValue" style="width:160px">
  240. <select id="Select_Roles" name="Select_Roles" title="" class="selectpicker" data-actions-box="true" data-width="140px" style="margin-right:100px" multiple="multiple"></select>
  241. </td>
  242. <td class="formValue" style="width:290px">
  243. &nbsp;
  244. <a id="Btn_Search" authorize="yes" class="btn btn-primary dropdown-text " onclick="btn_Search()"><i class="fa fa-search"></i>查询</a>
  245. &nbsp;
  246. <a id="Btn_ADD" authorize="yes" class="btn btn-primary dropdown-text " onclick="btn_ADD()"><i class="fa fa-plus"></i>新增</a>
  247. &nbsp;
  248. <a id="Btn_Del" authorize="yes" class="btn btn-primary dropdown-text " onclick="btn_Del()"><i class="fa fa-minus"></i>删除</a>
  249. &nbsp;
  250. <a id="Btn_All" authorize="yes" class="btn btn-primary dropdown-text " onclick="btn_All()"><i class="fa fa-save"></i>全可见</a>
  251. </td>
  252. </tr>
  253. </table>
  254. </div>
  255. <div class="gridPanel">
  256. <table id="gridList"></table>
  257. </div>
  258. </div>
  259. </form>