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

498 lines
22 KiB

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. <style>
  10. * {
  11. box-sizing: border-box;
  12. }
  13. </style>
  14. <script>
  15. var SourceID = $.request("SourceID");
  16. var LogString_Num = new Array();
  17. var LogString_Str = new Array();
  18. var LogString_Date = new Array();
  19. var LogString_Bool = new Array();
  20. var DataTypeString = new Array();
  21. var AllDataBase = new Array();
  22. var NewLine = 0;
  23. var MaxPaiXu = 0;
  24. var FirstShow = 0;
  25. $(function () {
  26. GetAllDataBase();
  27. LogString_Num = GetLogString("数值型");
  28. LogString_Str = GetLogString("字符型");
  29. LogString_Date = GetLogString("日期型");
  30. LogString_Bool = GetLogString("布尔值");
  31. DataTypeString = GetDataTypeString();
  32. gridList();
  33. $(window).resize(function () {
  34. $("#gridList").setGridWidth($(window).width() * 0.99);
  35. $("#gridList").setGridWidth(document.body.clientWidth * 0.99);
  36. $("#gridList").setGridHeight($(window).height() - 96);
  37. $("#gridList").setGridHeight(document.body.clientHeight - 96);
  38. });
  39. });
  40. //加载所有DB选项
  41. function GetAllDataBase() {
  42. $.ajax({
  43. url: "/SystemManage/CommonReport/GetAllDataBase?" + Math.random(),
  44. dataType: "json",
  45. async: false,
  46. success: function (data) {
  47. if (data != false && data != null && data.length > 0) {
  48. AllDataBase = new Array();
  49. for (var i = 0; i < data.length; i++) {
  50. var obj = {
  51. DbId: data[i].DbId,
  52. DBSourceDesc: data[i].DBSourceDesc,
  53. }
  54. AllDataBase.push(obj);
  55. }
  56. }
  57. }
  58. });
  59. }
  60. function gridList() {
  61. var $gridList = $("#gridList");
  62. $gridList.dataGrid({
  63. url: "/SystemManage/CommonReport/GetCondition?" + Math.random(),
  64. postData: { SourceID: SourceID },
  65. height: $(window).height() - 96,
  66. colModel: [//IDStr 排序 必填 条件名称 字段名称 替代符号 数据类型 默认逻辑符号 默认值
  67. //参照选择, 参照语句, 其他数据源, 本系统数据源, 返回字段
  68. {
  69. label: 'IDStr', name: 'IDStr', width: 80, align: 'left', sortable: false,
  70. },
  71. {
  72. label: 'IsNew', name: 'IsNew', width: 80, align: 'left', sortable: false,
  73. },
  74. {
  75. label: '排序', name: '排序', width: 80, align: 'left', sortable: false,
  76. formatter: function (cellvalue, options, rowObject) {
  77. if (parseInt(cellvalue) > MaxPaiXu) {
  78. MaxPaiXu = parseInt(cellvalue);
  79. }
  80. var str_retrun = '<input type="text" class="form-control" id="PaiXu_' + rowObject.IDStr + '" style="width:50px" value="' + cellvalue + '" />';
  81. return cellvalue = str_retrun;
  82. },
  83. },
  84. {
  85. label: '必填', name: '必填', width: 60, align: 'left', sortable: false,
  86. formatter: function (cellvalue, options, rowObject) {
  87. var str_retrun = "";
  88. if (cellvalue == "1") {
  89. str_retrun = '<input type="checkbox" id="Radio_' + rowObject.IDStr + '" checked="checked"/>';
  90. }
  91. else {
  92. str_retrun = '<input type="checkbox" id="Radio_' + rowObject.IDStr + '" />';
  93. }
  94. return cellvalue = str_retrun;
  95. },
  96. },
  97. {
  98. label: '条件名称', name: '条件名称', width: 150, align: 'left', sortable: false,
  99. formatter: function (cellvalue, options, rowObject) {
  100. var str_retrun = '<input type="text" class="form-control" id="Caption_' + rowObject.IDStr + '" value="' + cellvalue + '" />';
  101. return cellvalue = str_retrun;
  102. },
  103. },
  104. {
  105. label: '字段名称', name: '字段名称', width: 150, align: 'left', sortable: false,
  106. formatter: function (cellvalue, options, rowObject) {
  107. var str_retrun = '<input type="text" class="form-control" id="FiledName_' + rowObject.IDStr + '" value="' + cellvalue + '" />';
  108. return cellvalue = str_retrun;
  109. },
  110. },
  111. {
  112. label: '替代符号', name: '替代符号', width: 150, align: 'left', sortable: false,
  113. formatter: function (cellvalue, options, rowObject) {
  114. var str_retrun = '<input type="text" class="form-control" id="Index_' + rowObject.IDStr + '" value="' + cellvalue + '" />';
  115. return cellvalue = str_retrun;
  116. },
  117. },
  118. {
  119. label: '数据类型Data', name: '数据类型Data', width: 150, align: 'left', sortable: false,
  120. },
  121. {
  122. label: '数据类型', name: '数据类型', width: 150, align: 'left', sortable: false,
  123. formatter: function (cellvalue, options, rowObject) {
  124. var str_retrun = '<select class="selectpicker" id="selDataType_' + rowObject.IDStr + '" Title="" onchange="ChangeSel(\'' + rowObject.IDStr + '\')" data-width="100px" > ';
  125. str_retrun += "<option value=''></option>";
  126. for (var i = 0; i < DataTypeString.length; i++) {
  127. str_retrun += "<option value=\"" + DataTypeString[i].value + "\">" + DataTypeString[i].Str + "</option>";
  128. }
  129. str_retrun += '</select>';
  130. return cellvalue = str_retrun;
  131. }
  132. },
  133. {
  134. label: '默认逻辑符号Data', name: '默认逻辑符号Data', width: 150, align: 'left', sortable: false,
  135. },
  136. {
  137. label: '默认逻辑符号', name: '默认逻辑符号', width: 150, align: 'left', sortable: false,
  138. formatter: function (cellvalue, options, rowObject) {
  139. var str_retrun = '<select class="selectpicker" id="selLogString_' + rowObject.IDStr + '" Title="" data-width="100px" > ';
  140. str_retrun += "<option value=''></option>";
  141. for (var i = 0; i < LogString_Str.length; i++) {
  142. str_retrun += "<option value=\"" + LogString_Str[i].value + "\">" + LogString_Str[i].Str + "</option>";
  143. }
  144. str_retrun += '</select>';
  145. return cellvalue = str_retrun;
  146. }
  147. },
  148. {
  149. label: '默认值', name: '默认值', width: 150, align: 'left', sortable: false,
  150. formatter: function (cellvalue, options, rowObject) {
  151. var str_retrun = '<input type="text" class="form-control" id="DefaultValue_' + rowObject.IDStr + '" value="' + cellvalue + '" />';
  152. return cellvalue = str_retrun;
  153. },
  154. },
  155. //参照选择, 参照语句, 其他数据源, 本系统数据源, 返回字段
  156. {
  157. label: '参照选择', name: '参照选择', width: 80, align: 'left', sortable: false,
  158. formatter: function (cellvalue, options, rowObject) {
  159. var str_retrun = "";
  160. if (cellvalue == "1") {
  161. str_retrun = '<input type="checkbox" id="CSelectFlag_' + rowObject.IDStr + '" checked="checked"/>';
  162. }
  163. else {
  164. str_retrun = '<input type="checkbox" id="CSelectFlag_' + rowObject.IDStr + '" />';
  165. }
  166. return cellvalue = str_retrun;
  167. },
  168. },
  169. {
  170. label: '参照语句', name: '参照语句', width: 200, align: 'left', sortable: false,
  171. formatter: function (cellvalue, options, rowObject) {
  172. var str_retrun = '<input type="text" class="form-control" id="CSelectSqlTxt_' + rowObject.IDStr + '" value="' + cellvalue + '" />';
  173. return cellvalue = str_retrun;
  174. },
  175. },
  176. {
  177. label: '本系统数据源', name: '本系统数据源', width: 110, align: 'left', sortable: false,
  178. formatter: function (cellvalue, options, rowObject) {
  179. var str_retrun = "";
  180. if (cellvalue == "1") {
  181. str_retrun = '<input type="checkbox" id="SysDataSourceFlag_' + rowObject.IDStr + '" checked="checked"/>';
  182. }
  183. else {
  184. str_retrun = '<input type="checkbox" id="SysDataSourceFlag_' + rowObject.IDStr + '" />';
  185. }
  186. return cellvalue = str_retrun;
  187. },
  188. },
  189. {
  190. label: '其他数据源Data', name: '其他数据源Data', width: 80, align: 'left', sortable: false,
  191. },
  192. {
  193. label: '其他数据源', name: '其他数据源', width: 150, align: 'left', sortable: false,
  194. formatter: function (cellvalue, options, rowObject) {
  195. var str_retrun = '<select class="selectpicker" id="CSelectSourceId_' + rowObject.IDStr + '" Title="" data-width="100px" > ';
  196. str_retrun += "<option value=''></option>";
  197. for (var i = 0; i < AllDataBase.length; i++) {
  198. str_retrun += "<option value=\"" + AllDataBase[i].DbId + "\">" + AllDataBase[i].DBSourceDesc + "</option>";
  199. }
  200. str_retrun += '</select>';
  201. return cellvalue = str_retrun;
  202. }
  203. },
  204. {
  205. label: '返回字段', name: '返回字段', width: 70, align: 'left', sortable: false,
  206. formatter: function (cellvalue, options, rowObject) {
  207. var str_retrun = '<input type="text" class="form-control" id="ReturnCol_' + rowObject.IDStr + '" value="' + cellvalue + '" />';
  208. return cellvalue = str_retrun;
  209. },
  210. },
  211. ],
  212. viewrecords: true,
  213. rownumbers: true,
  214. multiselect: true,
  215. rowNum: 500,
  216. // cellEdit: false,
  217. // multiboxonly: true,
  218. // multikey:'shiftKey',
  219. gridComplete: function () {
  220. $("#gridList").setGridParam().hideCol("IDStr");//隐藏ID列
  221. $("#gridList").setGridParam().hideCol("IsNew");
  222. $("#gridList").setGridParam().hideCol("数据类型Data");
  223. $("#gridList").setGridParam().hideCol("默认逻辑符号Data");
  224. $("#gridList").setGridParam().hideCol("其他数据源Data");
  225. var strIds = $("#gridList").jqGrid("getDataIDs");
  226. if (FirstShow == 0) {
  227. for (var i = 0; i < strIds.length; i++) {
  228. var IDStr = $("#gridList").jqGrid("getCell", strIds[i], "IDStr");
  229. var selDataType = $("#gridList").jqGrid("getCell", strIds[i], "数据类型Data");
  230. $("#selDataType_" + IDStr).selectpicker('refresh');
  231. $("#selDataType_" + IDStr).selectpicker('val', selDataType);
  232. var selLogString = $("#gridList").jqGrid("getCell", strIds[i], "默认逻辑符号Data");
  233. $("#selLogString_" + IDStr).selectpicker('refresh');
  234. $("#selLogString_" + IDStr).selectpicker('val', selLogString);
  235. var CSelectSourceId = $("#gridList").jqGrid("getCell", strIds[i], "其他数据源Data");
  236. $("#CSelectSourceId_" + IDStr).selectpicker('refresh');
  237. $("#CSelectSourceId_" + IDStr).selectpicker('val', CSelectSourceId);
  238. }
  239. FirstShow = 1;
  240. }
  241. NewLine = strIds.length;
  242. $("#gridList").jqGrid('hideCol', 'cb');//隐藏勾选框 //勾选框选中的时候 与行选中有异常,所以隐藏
  243. },
  244. });
  245. }
  246. function SHowcols(colname) {
  247. $("#gridList").setGridParam().showCol(colname);
  248. }
  249. function Hiddencols(colname) {
  250. $("#gridList").setGridParam().hideCol(colname);
  251. }
  252. //修改字符类型 ->逻辑符号修改
  253. function ChangeSel(ColsName) {
  254. var datatype = $("#selDataType_" + ColsName).find("option:selected").text();
  255. var $LogString = $("#selLogString_" + ColsName);
  256. switch (datatype) {
  257. case "日期型":
  258. $LogString.find("option").remove();
  259. $LogString.append("<option value=''></option>");
  260. for (var i = 0; i < LogString_Date.length; i++) {
  261. $LogString.append("<option value='" + LogString_Date[i].value + "'>" + LogString_Date[i].Str + "</option>");
  262. }
  263. break;
  264. case "字符型":
  265. $LogString.find("option").remove();
  266. $LogString.append("<option value=''></option>");
  267. for (var i = 0; i < LogString_Str.length; i++) {
  268. $LogString.append("<option value='" + LogString_Str[i].value + "'>" + LogString_Str[i].Str + "</option>");
  269. }
  270. break;
  271. case "数值型":
  272. $LogString.find("option").remove();
  273. $LogString.append("<option value=''></option>");
  274. for (var i = 0; i < LogString_Num.length; i++) {
  275. $LogString.append("<option value='" + LogString_Num[i].value + "'>" + LogString_Num[i].Str + "</option>");
  276. }
  277. break;
  278. case "布尔值":
  279. $LogString.find("option").remove();
  280. $LogString.append("<option value=''></option>");
  281. for (var i = 0; i < LogString_Bool.length; i++) {
  282. $LogString.append("<option value='" + LogString_Bool[i].value + "'>" + LogString_Bool[i].Str + "</option>");
  283. }
  284. break;
  285. }
  286. $LogString.selectpicker('refresh');
  287. $LogString.selectpicker('render');
  288. }
  289. //新增一行
  290. function btn_ADD() {
  291. NewLine = NewLine + 1;
  292. MaxPaiXu = MaxPaiXu + 1;
  293. var ids = jQuery("#gridList").jqGrid('getDataIDs');
  294. if (ids.length == 0) {
  295. ids = [0];
  296. }
  297. //获得当前最大行号(数据编号)
  298. var rowid = Math.max.apply(Math, ids);
  299. //获得新添加行的行号(数据编号)
  300. var newrowid = rowid + 1;
  301. $("#gridList").addRowData(newrowid,
  302. {//排序 必填 条件名称 字段名称 替代符号 数据类型 默认逻辑符号 默认值
  303. "IDStr": NewLine.toString(),
  304. "IsNew":"1",
  305. "排序": MaxPaiXu,
  306. "必填": "0",
  307. "条件名称": "",
  308. "字段名称": "",
  309. "替代符号": "1=1",
  310. "数据类型Data": "",
  311. "数据类型": "",
  312. "默认逻辑符号Data": "",
  313. "默认逻辑符号": "",
  314. "默认值": "",
  315. "参照选择": "0",
  316. "参照语句": "",
  317. "其他数据源Data": "",
  318. "其他数据源": "",
  319. "本系统数据源": "0",
  320. "返回字段": "",
  321. },
  322. "last");
  323. var unwritten = document.getElementsByClassName("unwritten")[0];
  324. if (unwritten != null && unwritten != 'undefined') {
  325. unwritten.style.display = "none";
  326. // $(".unwritten").attr("display", "none");
  327. }
  328. var strIds = $("#gridList").jqGrid("getDataIDs");
  329. var rr = strIds.length - 1;
  330. var IDStr = $("#gridList").jqGrid("getCell", strIds[rr], "IDStr");
  331. var selDataType = $("#gridList").jqGrid("getCell", strIds[rr], "数据类型Data");
  332. $("#selDataType_" + IDStr).selectpicker('refresh');
  333. $("#selDataType_" + IDStr).selectpicker('val', selDataType);
  334. var selLogString = $("#gridList").jqGrid("getCell", strIds[rr], "默认逻辑符号Data");
  335. $("#selLogString_" + IDStr).selectpicker('refresh');
  336. $("#selLogString_" + IDStr).selectpicker('val', selLogString);
  337. var CSelectSourceId = $("#gridList").jqGrid("getCell", strIds[rr], "其他数据源Data");
  338. $("#CSelectSourceId_" + IDStr).selectpicker('refresh');
  339. $("#CSelectSourceId_" + IDStr).selectpicker('val', CSelectSourceId);
  340. }
  341. //删除选中行
  342. function btn_Del() {
  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. var selectedRowIds = $("#gridList").jqGrid("getGridParam", "selarrrow");
  349. var len = selectedRowIds.length;
  350. for (var i = 0; i < len ; i++) {
  351. $("#gridList").jqGrid("delRowData", selectedRowIds[i]);
  352. }
  353. }
  354. function submitForm() {
  355. var SubmitLine = new Array();
  356. var strIds = $("#gridList").jqGrid("getDataIDs");
  357. for (var i = 0; i < strIds.length; i++) {
  358. //IDStr 排序 必填 条件名称 字段名称 替代符号 数据类型 默认逻辑符号 默认值
  359. // NotNullFlag CCaption CFiledName CIndex CLogString CDefaultLogStirng CDataType CDefaultValue CSortSeq
  360. var ID = "";
  361. var IDStr = $("#gridList").jqGrid("getCell", strIds[i], "IDStr");
  362. var IsNew = $("#gridList").jqGrid("getCell", strIds[i], "IsNew");//是新增:“1” ,修改:“0”
  363. if(IsNew == "0")
  364. {
  365. ID = IDStr;
  366. }
  367. var CSortSeq = $("#PaiXu_" + IDStr).val();
  368. var NotNullFlagStr = $("#Radio_" + IDStr)[0].checked;
  369. var NotNullFlag = "0";
  370. if (NotNullFlagStr) { NotNullFlag = "1"; }
  371. var CCaption = $("#Caption_" + IDStr).val();
  372. var CFiledName = $("#FiledName_" + IDStr).val();
  373. var CIndex = $("#Index_" + IDStr).val();
  374. var CDataType = $("#selDataType_" + IDStr).val();
  375. var CDefaultLogStirng = $("#selLogString_" + IDStr).val();
  376. var CDefaultValue = $("#DefaultValue_" + IDStr).val();
  377. var CSelectFlagStr = $("#CSelectFlag_" + IDStr)[0].checked;
  378. var CSelectFlag = "0";
  379. if (CSelectFlagStr) { CSelectFlag = "1"; }
  380. var CSelectSqlTxt = $("#CSelectSqlTxt_" + IDStr).val();
  381. var CSelectSourceId = $("#CSelectSourceId_" + IDStr).val();
  382. var SysDataSourceFlagStr = $("#SysDataSourceFlag_" + IDStr)[0].checked;
  383. var SysDataSourceFlag = "0";
  384. if (SysDataSourceFlagStr) { SysDataSourceFlag = "1"; }
  385. var ReturnCol = $("#ReturnCol_" + IDStr).val();
  386. var obj = {
  387. ID: ID,
  388. CSortSeq: CSortSeq,
  389. NotNullFlag: NotNullFlag,
  390. CCaption: CCaption,
  391. CFiledName: CFiledName,
  392. CIndex: CIndex,
  393. CDataType: CDataType,
  394. CDefaultLogStirng: CDefaultLogStirng,
  395. CDefaultValue: CDefaultValue,
  396. CLogString: GetCLogString(CDataType),
  397. CSelectFlag: CSelectFlag,
  398. CSelectSqlTxt: CSelectSqlTxt,
  399. CSelectSourceId: CSelectSourceId,
  400. SysDataSourceFlag: SysDataSourceFlag,
  401. ReturnCol: ReturnCol,
  402. }
  403. SubmitLine.push(obj);
  404. }
  405. $.ajax({
  406. url: "/SystemManage/CommonReport/SetCondition" + "?" + Math.random(),
  407. type: "post",
  408. data: { SourceID: SourceID, List_Condition: JSON.stringify(SubmitLine), },
  409. async: false,
  410. success: function (data) {
  411. alert(data);
  412. $.modalClose();
  413. },
  414. error: function (aa) {
  415. //alert("异常:" + aa.responseText);
  416. $.modalAlertNew("WMS00015", aa.responseText);
  417. }
  418. });
  419. }
  420. </script>
  421. <form id="form1">
  422. <div style="margin-top: 10px; margin-left: 10px; margin-right: 10px;">
  423. <div class="form-group" style="height:40px;margin-bottom:5px">
  424. <div class="btn-group">
  425. <a id="Btn_ADD" authorize="yes" class="btn btn-primary dropdown-text" onclick="btn_ADD()"><i class="fa fa-plus"></i>新增</a>
  426. <a id="Btn_Del" authorize="yes" class="btn btn-primary dropdown-text" onclick="btn_Del()"><i class="fa fa-minus"></i>删除</a>
  427. </div>
  428. </div>
  429. <div class="gridPanel">
  430. <table id="gridList"></table>
  431. @*<div id="gridPager"></div>*@
  432. </div>
  433. </div>
  434. </form>