FlowLineForm.cshtml 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. @{
  2. ViewBag.Title = "流转条件设置";
  3. Layout = "~/Views/Shared/_Form.cshtml";
  4. }
  5. <!--jqgrid表格组件start-->
  6. <link href="~/Content/scripts/plugins/jqgrid/jqgrid.css" rel="stylesheet" />
  7. <script src="~/Content/scripts/plugins/jqgrid/grid.locale-cn.js"></script>
  8. <script src="~/Content/scripts/plugins/jqgrid/jqgrid.min.js"></script>
  9. <!--表格组件end-->
  10. <script>
  11. var frmtype, lineobject, fromnode, frmCotent, nodePramData;
  12. $(function () {
  13. initLoadPageData();
  14. GetGrid();
  15. InitControl();
  16. });
  17. function initLoadPageData() {
  18. var _FlowDesignObject = top.FlowSchemeBuider.FlowDesignObject;
  19. lineobject = _FlowDesignObject.$lineData[top.FlowSchemeBuider.LineId];
  20. lineobject.id = top.FlowSchemeBuider.LineId;
  21. fromnode = _FlowDesignObject.$nodeData[lineobject.from];
  22. frmtype = top.FlowSchemeBuider.postData["FrmType"];
  23. if (frmtype == 0) {
  24. frmCotent = JSON.parse(top.FlowSchemeBuider.frmData["FrmContent"]);
  25. }
  26. else {
  27. nodePramData = top.FlowSchemeBuider.nodePramData;
  28. }
  29. console.log(frmCotent);
  30. $("#LineName").val(lineobject.name);
  31. }
  32. //获取对象给控件赋值
  33. var SetJsonData;
  34. function InitControl() {
  35. if (lineobject.setInfo) {
  36. $("#gridTable")[0].addJSONData(lineobject.setInfo.ConditionJson);
  37. }
  38. }
  39. //加载表格
  40. function GetGrid() {
  41. //显示表里面字段
  42. var FieldValue = ":";
  43. if (frmtype == 0) {//自定义表单
  44. $.each(frmCotent, function (i, item) {
  45. if (item.control_type != 'image' && item.control_type != 'upload') {
  46. FieldValue += ";" + item.control_field + ":" + item.control_label;
  47. }
  48. });
  49. }
  50. else {//系统表单
  51. $.each(nodePramData, function (i, item) {
  52. FieldValue += ";" + item.column + ":" + item.remark;
  53. });
  54. }
  55. var lastsel = 0;
  56. $("#gridTable").jqGrid({
  57. datatype: "local",
  58. height: 271,
  59. autowidth: true,
  60. colModel: [
  61. { label: '字段ID', name: 'FieldId', index: 'FieldId', hidden: true },
  62. {
  63. label: "字段名称", name: "FieldName", index: "FieldName", width: 240, sortable: false, editable: true, edittype: 'select', editoptions: {
  64. value: FieldValue
  65. }
  66. },
  67. { label: '比较Id', name: 'FilterId', index: 'FilterId', hidden: true },
  68. {
  69. label: "比较", name: "FilterName", index: "FilterName", align: 'center', width: 80, sortable: false, editable: true, edittype: 'select', editoptions: {
  70. value: ":;Equal:等于;NotEqual:不等于;Greater:大于;GreaterThan:大于等于;Less:小于;LessThan:小于等于;Null:为空;NotNull:不为空;Like:包含;NotLike:不包含"//;LeftLike:左包含;RightLike:右包含"
  71. }
  72. },
  73. { label: "比较值", name: "FilterValue", index: "FilterValue", width: 300, sortable: false, editable: true },
  74. {
  75. label: "逻辑", name: "Logic", index: "Logic", width: 60, sortable: false, editable: true, edittype: 'select', editoptions: {
  76. value: ":;并且:并且;或:或"
  77. }
  78. }
  79. ],
  80. pager: "false",
  81. rowNum: 300,
  82. rownumbers: true,
  83. shrinkToFit: false,
  84. altRows: false,
  85. onSelectRow: function (id) {
  86. var RowData = {
  87. FieldId: $("[name='FieldName']").val(),
  88. FieldName: $("[name='FieldName']").find('option:selected').text(),
  89. FilterId: $("[name='FilterName']").val(),
  90. FilterName: $("[name='FilterName']").find('option:selected').text(),
  91. FilterValue: $("[name='FilterValue']").val(),
  92. Logic: $("[name='Logic']").val(),
  93. }
  94. $('#gridTable').jqGrid('restoreRow', lastsel);
  95. $('#gridTable').jqGrid('editRow', id, true);
  96. $('#gridTable').jqGrid('setRowData', lastsel, RowData, '');
  97. lastsel = id;
  98. }
  99. });
  100. $('#gridTable').jqGrid('restoreRow', 1);
  101. $('#gridTable').jqGrid('addRowData', 1, {}, "last");
  102. //表格自适应(高度、宽度)
  103. $(window).resize(function () {
  104. $("#gridTable").jqGrid('setGridWidth', $(window).width() - 4);
  105. });
  106. }
  107. //增加栏位
  108. var rownum = 1;
  109. function btn_add() {
  110. $('#gridTable').jqGrid('restoreRow', rownum+1);
  111. $('#gridTable').jqGrid('addRowData', rownum+1, {}, "last");
  112. rownum++;
  113. }
  114. //删除栏位
  115. function btn_delete()
  116. {
  117. $('#gridTable').jqGrid('restoreRow', rownum);
  118. $('#gridTable').jqGrid('delRowData', rownum);
  119. rownum--;
  120. }
  121. //保存事件
  122. function AcceptClick(callBack) {
  123. var index = $("#gridTable").jqGrid('getGridParam', 'selrow');
  124. var RowData = {
  125. FieldId: $("[name='FieldName']").val(),
  126. FieldName: $("[name='FieldName']").find('option:selected').text(),
  127. FilterId: $("[name='FilterName']").val(),
  128. FilterName: $("[name='FilterName']").find('option:selected').text(),
  129. FilterValue: $("[name='FilterValue']").val(),
  130. Logic: $("[name='Logic']").val(),
  131. }
  132. $('#gridTable').jqGrid('setRowData', index, RowData, '');
  133. var ConditionJson = $("#gridTable").jqGrid("getRowData");
  134. var ConditionValueJson = [];
  135. for (var i = 0; i < ConditionJson.length; i++) {
  136. if (ConditionJson[i].FieldId) {
  137. var Logic = "AND";
  138. if (ConditionJson[i].Logic) {
  139. Logic = ConditionJson[i].Logic == "并且" ? "AND" : "OR";
  140. }
  141. var tdData = {
  142. ParamName: ConditionJson[i].FieldId,
  143. Operation: ConditionJson[i].FilterId,
  144. ParamValue: ConditionJson[i].FilterValue,
  145. Logic: Logic,
  146. }
  147. ConditionValueJson.push(tdData);
  148. }
  149. }
  150. var postData = {
  151. LineName: $("#LineName").val(),
  152. ConditionJson: ConditionJson,
  153. ConditionValueJson: ConditionValueJson
  154. }
  155. top.FlowSchemeBuider.callBackLine(lineobject.id, postData);
  156. dialogClose();
  157. }
  158. </script>
  159. <form id="form1">
  160. <div style="margin: 10px;">
  161. <input id="LineName" type="text" class="form-control" placeholder="请输入箭头标签" style="width: 260px;display:inline-block;" />
  162. <div style="float:right;">
  163. <div class="btn-group">
  164. <a id="btn_add" class="btn btn-default btn-sm" onclick="btn_add()"><i class="fa fa-plus"></i>&nbsp;添加栏位</a>
  165. <a id="btn_delete" class="btn btn-default btn-sm" onclick="btn_delete()"><i class="fa fa-minus"></i>&nbsp;删除栏位</a>
  166. </div>
  167. </div>
  168. </div>
  169. <div>
  170. <div style=" overflow: auto; height: 301px;">
  171. <div id="seniorcondition" class="tabPanel">
  172. <table id="gridTable"></table>
  173. </div>
  174. </div>
  175. </div>
  176. </form>
  177. <style>
  178. .ui-widget-content {
  179. border-left: none;
  180. border-bottom: none;
  181. }
  182. .ui-jqgrid tr.ui-row-ltr td {
  183. padding: 0px;
  184. }
  185. .ui-widget-content .ui-state-hover {
  186. background: #fff;
  187. }
  188. .ui-widget-content .ui-state-highlight {
  189. background: #fff;
  190. color: #000;
  191. }
  192. .unwritten {
  193. display:none;
  194. }
  195. .ui-jqgrid tr.ui-row-ltr td {
  196. border-right: 1px solid #ccc;
  197. }
  198. option {
  199. font-family:微软雅黑,宋体,Arial,Helvetica,Verdana,sans-serif;
  200. font-size:9pt;
  201. }
  202. </style>