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.

488 lines
22 KiB

  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. <style>
  10. * {
  11. box-sizing: border-box;
  12. }
  13. .form-control {
  14. width:95%
  15. }
  16. </style>
  17. <script>
  18. var SourceID = $.request("SourceID");
  19. var MenuID = $.request("MenuID");
  20. var DataTypeString = new Array();
  21. var NewLine = 0;
  22. var MaxPaiXu = 0;
  23. var FirstShow = 0;
  24. $(function () {
  25. DataTypeString = GetDataTypeString();
  26. gridList();
  27. $(window).resize(function () {
  28. $("#gridList").setGridWidth($(window).width() * 0.99);
  29. $("#gridList").setGridWidth(document.body.clientWidth * 0.99);
  30. $("#gridList").setGridHeight($(window).height() - 96);
  31. $("#gridList").setGridHeight(document.body.clientHeight - 96);
  32. });
  33. });
  34. function gridList() {
  35. document.getElementsByClassName("gridPanel")[0].innerHTML = ' <table id="gridList"></table>';
  36. var $gridList = $("#gridList");
  37. $gridList.dataGrid({
  38. url: "/SystemManage/CommonReport/GetCols?" + Math.random(),
  39. postData: { SourceID: SourceID },
  40. height: $(window).height() - 96,
  41. width:"100%",
  42. colModel: [//IDStr 显示名称 字段名称 数据类型 小数点位数 字段宽度
  43. //合并相同项 合并相同项Key 汇总 从属表头 显示 显示顺序 允许排序 自定义项 自定义公式
  44. //ColCaption ColFiledName DataType DefineFlag FunctionString DeciamlNum
  45. //ColWidth ColMerFlag ColMerKeyFlag ColSumFlag HeaderId COrder VisbleFlag SortFlag
  46. {
  47. label: 'IDStr', name: 'IDStr', width: 80, align: 'left', sortable: false,
  48. },
  49. { label: 'ColCaption', name: 'ColCaption', hidden: true, },
  50. { label: 'ColFiledName', name: 'ColFiledName', hidden: true, },
  51. { label: 'DataType', name: 'DataType', hidden: true, },
  52. { label: 'DefineFlag', name: 'DefineFlag', hidden: true, },
  53. { label: 'FunctionString', name: 'FunctionString', hidden: true, },
  54. { label: 'DeciamlNum', name: 'DeciamlNum', hidden: true, },
  55. { label: 'ColWidth', name: 'ColWidth', hidden: true, },
  56. { label: 'ColMerFlag', name: 'ColMerFlag', hidden: true, },
  57. { label: 'ColMerKeyFlag', name: 'ColMerKeyFlag', hidden: true, },
  58. { label: 'ColSumFlag', name: 'ColSumFlag', hidden: true, },
  59. { label: 'HeaderId', name: 'HeaderId', hidden: true, },
  60. { label: 'COrder', name: 'COrder', hidden: true, },
  61. { label: 'VisbleFlag', name: 'VisbleFlag', hidden: true, },
  62. { label: 'SortFlag', name: 'SortFlag', hidden: true, },
  63. {
  64. label: '显示名称', name: '显示名称', width: 130, align: 'left', sortable: false,
  65. formatter: function (cellvalue, options, rowObject) {
  66. var str_retrun = '<input type="text" class="form-control" id="ColCaption_' + rowObject.IDStr + '" value="' + cellvalue + '" />';
  67. return cellvalue = str_retrun;
  68. },
  69. },
  70. {
  71. label: '字段名称', name: '字段名称', width: 130, align: 'left', sortable: false,
  72. formatter: function (cellvalue, options, rowObject) {
  73. var str_retrun = '<input type="text" class="form-control" id="ColFiledName_' + rowObject.IDStr + '" value="' + cellvalue + '" />';
  74. return cellvalue = str_retrun;
  75. },
  76. },
  77. {
  78. label: '数据类型', name: '数据类型', width: 120, align: 'left', sortable: false,
  79. formatter: function (cellvalue, options, rowObject) {
  80. var str_retrun = '<select class="selectpicker" id="selDataType_' + rowObject.IDStr + '" Title="" data-width="90px" > ';
  81. str_retrun += "<option value=''></option>";
  82. for (var i = 0; i < DataTypeString.length; i++) {
  83. str_retrun += "<option value=\"" + DataTypeString[i].value + "\">" + DataTypeString[i].Str + "</option>";
  84. }
  85. str_retrun += '</select>';
  86. return cellvalue = str_retrun;
  87. }
  88. },
  89. {
  90. label: '小数点位数', name: '小数点位数', width: 80, align: 'left', sortable: false,
  91. formatter: function (cellvalue, options, rowObject) {
  92. var str_retrun = '<input type="text" class="form-control" id="DeciamlNum_' + rowObject.IDStr + '" value="' + cellvalue + '" />';
  93. return cellvalue = str_retrun;
  94. },
  95. },
  96. {
  97. label: '字段宽度', name: '字段宽度', width: 80, align: 'left', sortable: false,
  98. formatter: function (cellvalue, options, rowObject) {
  99. var str_retrun = '<input type="text" class="form-control" id="ColWidth_' + rowObject.IDStr + '" value="' + cellvalue + '" />';
  100. return cellvalue = str_retrun;
  101. },
  102. },
  103. {
  104. label: '合并相同项', name: '合并相同项', width: 80, align: 'left', sortable: false,
  105. formatter: function (cellvalue, options, rowObject) {
  106. var str_retrun = '<input type="checkbox" name="ColMerFlag_' + rowObject.IDStr + '" ';
  107. str_retrun += ' id="ColMerFlag_' + rowObject.IDStr + '" value="' + cellvalue + '" ';
  108. return cellvalue = str_retrun;
  109. }
  110. }, {
  111. label: '合并相同项Key', name: '合并相同项Key', width: 80, align: 'left', sortable: false,
  112. formatter: function (cellvalue, options, rowObject) {
  113. var str_retrun = '<input type="checkbox" name="ColMerKeyFlag_' + rowObject.IDStr + '" ';
  114. str_retrun += ' id="ColMerKeyFlag_' + rowObject.IDStr + '" value="' + cellvalue + '" ';
  115. return cellvalue = str_retrun;
  116. }
  117. },{
  118. label: '汇总', name: '汇总', width: 80, align: 'left', sortable: false,
  119. formatter: function (cellvalue, options, rowObject) {
  120. var str_retrun = '<input type="checkbox" name="ColSumFlag_' + rowObject.IDStr + '" ';
  121. str_retrun += ' id="ColSumFlag_' + rowObject.IDStr + '" value="' + cellvalue + '" ';
  122. return cellvalue = str_retrun;
  123. }
  124. },
  125. {
  126. label: '从属表头', name: '从属表头', width: 90, align: 'left', sortable: false,
  127. formatter: function (cellvalue, options, rowObject) {
  128. var str_retrun = '<input type="text" class="form-control" id="HeaderId_' + rowObject.IDStr + '" value="' + cellvalue + '" />';
  129. return cellvalue = str_retrun;
  130. },
  131. }, {
  132. label: '显示', name: '显示', width: 80, align: 'left', sortable: false,
  133. formatter: function (cellvalue, options, rowObject) {
  134. var str_retrun = '<input type="checkbox" name="VisbleFlag_' + rowObject.IDStr + '" ';
  135. str_retrun += ' id="VisbleFlag_' + rowObject.IDStr + '" value="' + cellvalue + '" ';
  136. return cellvalue = str_retrun;
  137. }
  138. },
  139. {
  140. label: '显示顺序', name: '显示顺序', width: 80, align: 'left', sortable: false,
  141. formatter: function (cellvalue, options, rowObject) {
  142. var str_retrun = '<input type="text" class="form-control" id="COrder_' + rowObject.IDStr + '" value="' + cellvalue + '" />';
  143. return cellvalue = str_retrun;
  144. },
  145. }, {
  146. label: '允许排序', name: '允许排序', width: 80, align: 'left', sortable: false,
  147. formatter: function (cellvalue, options, rowObject) {
  148. var str_retrun = '<input type="checkbox" name="SortFlag_' + rowObject.IDStr + '" ';
  149. str_retrun += ' id="SortFlag_' + rowObject.IDStr + '" value="' + cellvalue + '" ';
  150. return cellvalue = str_retrun;
  151. }
  152. }, {
  153. label: '自定义项', name: '自定义项', width: 60, align: 'left', sortable: false,
  154. formatter: function (cellvalue, options, rowObject) {
  155. var str_retrun = '<input type="checkbox" name="DefineFlag_' + rowObject.IDStr + '" ';
  156. str_retrun+=' id="DefineFlag_' + rowObject.IDStr + '" value="' + cellvalue + '" ';
  157. return cellvalue = str_retrun;
  158. }
  159. }, {
  160. label: '自定义公式', name: '自定义公式', width: 200, align: 'left', sortable: false,
  161. formatter: function (cellvalue, options, rowObject) {
  162. var str_retrun = '<input type="text" class="form-control" id="FunctionString_' + rowObject.IDStr + '" value="' + cellvalue + '" />';
  163. return cellvalue = str_retrun;
  164. },
  165. },
  166. ],
  167. // pager: "#gridPager",
  168. //sortname: '显示顺序',
  169. //// rowNum: -1,
  170. //sortorder: 'asc',
  171. viewrecords: true,
  172. rownumbers: true,
  173. multiselect: true,
  174. rowNum: 500,
  175. // cellEdit: false,
  176. // multiboxonly: true,
  177. // multikey:'shiftKey',
  178. gridComplete: function () {
  179. $("#gridList").setGridParam().hideCol("IDStr");//隐藏ID列
  180. $("#gridList").setGridParam().hideCol("自定义项");//隐藏ID列
  181. $("#gridList").setGridParam().hideCol("自定义公式");//隐藏ID列
  182. var strIds = $("#gridList").jqGrid("getDataIDs");
  183. if (FirstShow == 0) {
  184. for (var i = 0; i < strIds.length; i++) {
  185. var IDStr = $("#gridList").jqGrid("getCell", strIds[i], "IDStr");
  186. //DataType
  187. var selDataType = $("#gridList").jqGrid("getCell", strIds[i], "DataType");
  188. $("#selDataType_" + IDStr).selectpicker('refresh');
  189. $("#selDataType_" + IDStr).selectpicker('val', selDataType);
  190. //DefineFlag
  191. var DefineFlag = $("#gridList").jqGrid("getCell", strIds[i], "DefineFlag");
  192. if (DefineFlag == "false") {
  193. document.getElementById("DefineFlag_" + IDStr).checked = false;
  194. }
  195. else {
  196. document.getElementById("DefineFlag_" + IDStr).checked = true;
  197. }
  198. //ColMerFlag
  199. var ColMerFlag = $("#gridList").jqGrid("getCell", strIds[i], "ColMerFlag");
  200. if (ColMerFlag == "false") {
  201. document.getElementById("ColMerFlag_" + IDStr).checked = false;
  202. }
  203. else
  204. {
  205. document.getElementById("ColMerFlag_" + IDStr).checked = true;
  206. }
  207. //ColMerKeyFlag
  208. var ColMerKeyFlag = $("#gridList").jqGrid("getCell", strIds[i], "ColMerKeyFlag");
  209. if (ColMerKeyFlag == "false") {
  210. document.getElementById("ColMerKeyFlag_" + IDStr).checked = false;
  211. }
  212. else {
  213. document.getElementById("ColMerKeyFlag_" + IDStr).checked = true;
  214. }
  215. //ColSumFlag
  216. var ColSumFlag = $("#gridList").jqGrid("getCell", strIds[i], "ColSumFlag");
  217. if (ColSumFlag == "false") {
  218. document.getElementById("ColSumFlag_" + IDStr).checked = false;
  219. }
  220. else {
  221. document.getElementById("ColSumFlag_" + IDStr).checked = true;
  222. }
  223. //VisbleFlag
  224. var VisbleFlag = $("#gridList").jqGrid("getCell", strIds[i], "VisbleFlag");
  225. if (VisbleFlag == "false") {
  226. document.getElementById("VisbleFlag_" + IDStr).checked = false;
  227. }
  228. else {
  229. document.getElementById("VisbleFlag_" + IDStr).checked = true;
  230. }
  231. //SortFlag
  232. var SortFlag = $("#gridList").jqGrid("getCell", strIds[i], "SortFlag");
  233. if (SortFlag == "false") {
  234. document.getElementById("SortFlag_" + IDStr).checked = false;
  235. }
  236. else {
  237. document.getElementById("SortFlag_" + IDStr).checked = true;
  238. }
  239. }
  240. FirstShow = 1;
  241. }
  242. NewLine = strIds.length;
  243. $("#gridList").jqGrid('hideCol', 'cb');//隐藏勾选框 //勾选框选中的时候 与行选中有异常,所以隐藏
  244. },
  245. });
  246. }
  247. function SHowcols(colname) {
  248. $("#gridList").setGridParam().showCol(colname);
  249. }
  250. function Hiddencols(colname) {
  251. $("#gridList").setGridParam().hideCol(colname);
  252. }
  253. //添加新增列
  254. function btn_ReSet()
  255. {
  256. $.ajax({
  257. url: "/SystemManage/CommonReport/ReSetCols" + "?" + Math.random(),
  258. type: "post",
  259. data: { MenuID: MenuID },
  260. async: false,
  261. success: function (data) {
  262. alert(data);
  263. NewLine = 0;
  264. MaxPaiXu = 0;
  265. FirstShow = 0;
  266. gridList();
  267. },
  268. error: function (aa) {
  269. //alert("异常:" + aa.responseText);
  270. $.modalAlertNew("WMS00015", aa.responseText);
  271. }
  272. });
  273. }
  274. //新增一行
  275. function btn_ADD() {
  276. NewLine = NewLine + 1;
  277. MaxPaiXu = MaxPaiXu + 1;
  278. var ids = jQuery("#gridList").jqGrid('getDataIDs');
  279. if (ids.length == 0) {
  280. ids = [0];
  281. }
  282. //获得当前最大行号(数据编号)
  283. var rowid = Math.max.apply(Math, ids);
  284. //获得新添加行的行号(数据编号)
  285. var newrowid = rowid + 1;
  286. $("#gridList").addRowData(newrowid,
  287. {//IDStr 显示名称 字段名称 数据类型 小数点位数 字段宽度
  288. //合并相同项 合并相同项Key 汇总 从属表头 显示 显示顺序 允许排序 自定义项 自定义公式
  289. //ColCaption ColFiledName DataType DefineFlag FunctionString DeciamlNum
  290. //ColWidth ColMerFlag ColMerKeyFlag ColSumFlag HeaderId COrder VisbleFlag SortFlag
  291. "IDStr": NewLine.toString(),
  292. "ColCaption": "",
  293. "ColFiledName": "",
  294. "DataType": "",
  295. "DeciamlNum": "",
  296. "ColWidth": "",
  297. "ColMerFlag": "",
  298. "ColMerKeyFlag": "",
  299. "ColSumFlag": "",
  300. "HeaderId": "",
  301. "VisbleFlag": "",
  302. "COrder": MaxPaiXu,
  303. "SortFlag": "",
  304. "DefineFlag": "",
  305. "FunctionString": "",
  306. "显示名称": "",
  307. "字段名称": "",
  308. "数据类型": "",
  309. "小数点位数": "",
  310. "字段宽度": "",
  311. "合并相同项": "",
  312. "合并相同项Key": "",
  313. "汇总": "",
  314. "从属表头": "",
  315. "显示": "",
  316. "显示顺序": "",
  317. "允许排序": "",
  318. "自定义项": "",
  319. "自定义公式": "",
  320. },
  321. "last");
  322. var unwritten = document.getElementsByClassName("unwritten")[0];
  323. if (unwritten != null && unwritten != 'undefined') {
  324. unwritten.style.display = "none";
  325. }
  326. // $(".unwritten").attr("display", "none");
  327. //刷新下拉框 select
  328. var strIds = $("#gridList").jqGrid("getDataIDs");
  329. var rr = strIds.length - 1;
  330. var IDStr = $("#gridList").jqGrid("getCell", strIds[rr], "IDStr");
  331. //DataType
  332. var selDataType = $("#gridList").jqGrid("getCell", strIds[rr], "DataType");
  333. $("#selDataType_" + IDStr).selectpicker('refresh');
  334. $("#selDataType_" + IDStr).selectpicker('val', selDataType);
  335. }
  336. //删除选中行
  337. function btn_Del() {
  338. var selectedRowIds = $("#gridList").jqGrid("getGridParam", "selarrrow");
  339. var len = selectedRowIds.length;
  340. for (var i = 0; i < len ; i++) {
  341. $("#gridList").jqGrid("delRowData", selectedRowIds[i]);
  342. }
  343. var selectedRowIds = $("#gridList").jqGrid("getGridParam", "selarrrow");
  344. var len = selectedRowIds.length;
  345. for (var i = 0; i < len ; i++) {
  346. $("#gridList").jqGrid("delRowData", selectedRowIds[i]);
  347. }
  348. }
  349. function submitForm() {
  350. var SubmitLine = new Array();
  351. var strIds = $("#gridList").jqGrid("getDataIDs");
  352. for (var i = 0; i < strIds.length; i++) {
  353. //IDStr 显示名称 字段名称 数据类型 小数点位数 字段宽度
  354. //合并相同项 合并相同项Key 汇总 从属表头 显示 显示顺序 允许排序 自定义项 自定义公式
  355. //ColCaption ColFiledName DataType DefineFlag FunctionString DeciamlNum
  356. //ColWidth ColMerFlag ColMerKeyFlag ColSumFlag HeaderId COrder VisbleFlag SortFlag
  357. var IDStr = $("#gridList").jqGrid("getCell", strIds[i], "IDStr");
  358. var ColCaption = $("#ColCaption_" + IDStr).val();
  359. var ColFiledName = $("#ColFiledName_" + IDStr).val();
  360. var ColCaption = $("#ColCaption_" + IDStr).val();
  361. var DataType = $("#selDataType_" + IDStr).val();
  362. var DefineFlag = checkboxToNumStr(document.getElementById("DefineFlag_" + IDStr));
  363. var FunctionString = $("#FunctionString_" + IDStr).val();
  364. var DeciamlNum = $("#DeciamlNum_" + IDStr).val();
  365. var ColWidth = $("#ColWidth_" + IDStr).val();
  366. var ColMerFlag = checkboxToNumStr(document.getElementById("ColMerFlag_" + IDStr));
  367. var ColMerKeyFlag = checkboxToNumStr(document.getElementById("ColMerKeyFlag_" + IDStr));
  368. var ColSumFlag = checkboxToNumStr(document.getElementById("ColSumFlag_" + IDStr));
  369. var HeaderId = $("#HeaderId_" + IDStr).val();
  370. var COrder = $("#COrder_" + IDStr).val();
  371. var VisbleFlag = checkboxToNumStr(document.getElementById("VisbleFlag_" + IDStr));
  372. var SortFlag = checkboxToNumStr(document.getElementById("SortFlag_" + IDStr));
  373. var obj = {
  374. Id:IDStr,
  375. ColCaption: ColCaption,
  376. ColFiledName: ColFiledName,
  377. DataType: DataType,
  378. DefineFlag: DefineFlag,
  379. FunctionString: FunctionString,
  380. DeciamlNum: DeciamlNum,
  381. ColWidth: ColWidth,
  382. ColMerFlag: ColMerFlag,
  383. ColMerKeyFlag: ColMerKeyFlag,
  384. ColSumFlag: ColSumFlag,
  385. HeaderId: HeaderId,
  386. COrder: COrder,
  387. VisbleFlag: VisbleFlag,
  388. SortFlag: SortFlag,
  389. }
  390. SubmitLine.push(obj);
  391. }
  392. $.ajax({
  393. url: "/SystemManage/CommonReport/SetCols" + "?" + Math.random(),
  394. type: "post",
  395. data: { SourceID: SourceID, List_Cols: JSON.stringify(SubmitLine), },
  396. async: false,
  397. success: function (data) {
  398. alert(data);
  399. $.modalClose();
  400. },
  401. error: function (aa) {
  402. //alert("异常:" + aa.responseText);
  403. $.modalAlertNew("WMS00015", aa.responseText);
  404. }
  405. });
  406. }
  407. </script>
  408. <form id="form1">
  409. <div style="margin-top: 10px; margin-left: 10px; margin-right: 10px;">
  410. <div class="form-group" style="height:40px;margin-bottom:5px">
  411. <div class="btn-group">
  412. <a id="Btn_ReSet" authorize="yes" class="btn btn-primary dropdown-text" onclick="btn_ReSet()"><i class="fa fa-plus"></i>添加新增列</a>
  413. @*<a id="Btn_ADD" authorize="yes" class="btn btn-primary dropdown-text" onclick="btn_ADD()"><i class="fa fa-plus"></i>新增</a>*@
  414. <a id="Btn_Del" authorize="yes" class="btn btn-primary dropdown-text" onclick="btn_Del()"><i class="fa fa-minus"></i>删除</a>
  415. </div>
  416. </div>
  417. <div class="gridPanel">
  418. <table id="gridList"></table>
  419. @*<div id="gridPager"></div>*@
  420. </div>
  421. </div>
  422. </form>