OfficeRkForm.cshtml 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. @{;
  2. ViewBag.Title = "表单页面";
  3. Layout = "~/Views/Shared/_OrderForm.cshtml";
  4. }
  5. <script>
  6. var keyValue = request('keyValue');
  7. $(function () {
  8. InitialPage();
  9. GetOrderEntryGrid();
  10. initControl();
  11. });
  12. //初始化页面
  13. function InitialPage() {;
  14. //resize重设(表格、树形)宽高
  15. $(window).resize(function (e) {
  16. window.setTimeout(function () {
  17. $('#gridTable').setGridWidth(($('.gridPanel').width()));
  18. $('#gridTable').setGridHeight($(window).height() - 240.5);
  19. }, 200);
  20. e.stopPropagation();
  21. });
  22. }
  23. //加载明细表
  24. function GetOrderEntryGrid() {
  25. var $grid = $('#gridTable');
  26. $grid.jqGrid({
  27. unwritten: false,
  28. datatype: 'local',
  29. height: $(window).height() - 240.5,
  30. autowidth: true,
  31. colModel: [
  32. { label: '商品Id', name: 'ProductId', width: 80, align: '', sortable: false, resizable: false },
  33. { label: '商品编号', name: 'ProductCode', width: 80, align: '', sortable: false, resizable: false },
  34. { label: '商品名称', name: 'ProductName', width: 80, align: '', sortable: false, resizable: false },
  35. { label: '单位', name: 'UnitId', width: 80, align: '', sortable: false, resizable: false },
  36. { label: '数量', name: 'Qty', width: 80, align: '', sortable: false, resizable: false },
  37. { label: '单价', name: 'Price', width: 80, align: '', sortable: false, resizable: false },
  38. { label: '金额', name: 'Amount', width: 80, align: '', sortable: false, resizable: false },
  39. { label: '排序码', name: 'SortCode', width: 80, align: '', sortable: false, resizable: false },
  40. { label: '删除标记', name: 'DeleteMark', width: 80, align: '', sortable: false, resizable: false },
  41. { label: '有效标志', name: 'EnabledMark', width: 80, align: '', sortable: false, resizable: false },
  42. { label: '备注', name: 'Description', width: 80, align: '', sortable: false, resizable: false },
  43. ],
  44. pager: false,
  45. rownumbers: true,
  46. shrinkToFit: false,
  47. gridview: true,
  48. footerrow: false,
  49. gridComplete: function () {
  50. }
  51. });
  52. //默认添加13行 空行
  53. for (var i = 1; i < 13; i++) {
  54. var rowdata = {
  55. ProductId: '<input name="ProductId" type="text" class="editable center" />',
  56. ProductCode: '<input name="ProductCode" type="text" class="editable center" />',
  57. ProductName: '<input name="ProductName" type="text" class="editable center" />',
  58. UnitId: '<input name="UnitId" type="text" class="editable center" />',
  59. Qty: '<input name="Qty" type="text" class="editable center" />',
  60. Price: '<input name="Price" type="text" class="editable center" />',
  61. Amount: '<input name="Amount" type="text" class="editable center" />',
  62. SortCode: '<input name="SortCode" type="text" class="editable center" />',
  63. DeleteMark: '<input name="DeleteMark" type="text" class="editable center" />',
  64. EnabledMark: '<input name="EnabledMark" type="text" class="editable center" />',
  65. Description: '<input name="Description" type="text" class="editable center" />'
  66. }
  67. $grid.jqGrid('addRowData', i, rowdata);
  68. };
  69. }
  70. //初始化控件
  71. function initControl() {
  72. //跟进人员
  73. $("#SellerId").ComboBoxTree({
  74. url: "../../BaseManage/User/GetTreeJson",
  75. description: "==请选择==",
  76. height: "200px",
  77. allowSearch: true
  78. });
  79. //客户名称
  80. $("#GysId").ComboBox({
  81. url: "../../SystemManage/DataItemDetail/GetDataItemListJson",
  82. param: { EnCode: "Client_ProductInfo" },
  83. id: "ItemValue",
  84. text: "ItemName",
  85. description: "==请选择==",
  86. height: "200px"
  87. });
  88. //获取表单
  89. if (!!keyValue) {
  90. $.SetForm({
  91. url: "../../DemoManage/OfficeRk/GetFormJson",
  92. param: { keyValue: keyValue },
  93. success: function (data) {
  94. $("#form1").SetWebControls(data.entity);
  95. //明细
  96. var childEntity = data.childEntity;
  97. $('#gridTable').find('[role=row]').each(function (i) {
  98. var row = childEntity[i - 1];
  99. if (row != undefined) {
  100. $(this).find('input[name="ProductId"]').val(row.ProductId);
  101. $(this).find('input[name="ProductCode"]').val(row.ProductCode);
  102. $(this).find('input[name="ProductName"]').val(row.ProductName);
  103. $(this).find('input[name="UnitId"]').val(row.UnitId);
  104. $(this).find('input[name="Qty"]').val(row.Qty);
  105. $(this).find('input[name="Price"]').val(row.Price);
  106. $(this).find('input[name="Amount"]').val(row.Amount);
  107. $(this).find('input[name="SortCode"]').val(row.SortCode);
  108. $(this).find('input[name="DeleteMark"]').val(row.DeleteMark);
  109. $(this).find('input[name="EnabledMark"]').val(row.EnabledMark);
  110. $(this).find('input[name="Description"]').val(row.Description);
  111. }
  112. });
  113. }
  114. })
  115. }
  116. }
  117. //保存表单;
  118. function AcceptClick() {
  119. if (!$('#form1').Validform()) {
  120. return false;
  121. }
  122. var postData = $("#form1").GetWebControls(keyValue);
  123. postData["SellerName"] = $("#SellerId").attr('data-text');
  124. postData["GysName"] = $("#GysId").attr('data-text');
  125. var childEntryJson = [];
  126. $('#gridTable').find('[role=row]').each(function (i) {
  127. if (!!$(this).find('input[name="ProductId"]').val()) {
  128. childEntryJson.push({
  129. ProductId: $(this).find('input[name="ProductId"]').val(),
  130. ProductCode: $(this).find('input[name="ProductCode"]').val(),
  131. ProductName: $(this).find('input[name="ProductName"]').val(),
  132. UnitId: $(this).find('input[name="UnitId"]').val(),
  133. Qty: $(this).find('input[name="Qty"]').val(),
  134. Price: $(this).find('input[name="Price"]').val(),
  135. Amount: $(this).find('input[name="Amount"]').val(),
  136. SortCode: $(this).find('input[name="SortCode"]').val(),
  137. DeleteMark: $(this).find('input[name="DeleteMark"]').val(),
  138. EnabledMark: $(this).find('input[name="EnabledMark"]').val(),
  139. Description: $(this).find('input[name="Description"]').val()
  140. });
  141. }
  142. });
  143. $.SaveForm({
  144. url: "../../DemoManage/OfficeRk/SaveForm?keyValue=" + keyValue,
  145. param: { "strEntity": JSON.stringify(postData), "strChildEntitys": JSON.stringify(childEntryJson) },
  146. loading: "正在保存数据...",
  147. success: function () {
  148. $.currentIframe().$("#gridTable").trigger("reloadGrid");
  149. }
  150. })
  151. }
  152. </script>
  153. <div class="bills">
  154. <div style="height:120px;overflow-y:auto;margin:10px 10px;">
  155. <table class="form" style="width: 100%;">
  156. <tr>
  157. <th class="formTitle" style="width: 60px;">客户名称</th>
  158. <td class="formValue">
  159. <div id="GysId" type="selectTree" class="ui-select" isvalid="yes" checkexpession="NotNull"></div>
  160. </td>
  161. <th class="formTitle" style="width: 60px;">销售人员</th>
  162. <td class="formValue">
  163. <div id="SellerId" type="selectTree" class="ui-select" isvalid="yes" checkexpession="NotNull"></div>
  164. </td>
  165. <th class="formTitle" style="width: 60px;">单据日期</th>
  166. <td class="formValue">
  167. <input id="RkDate" type="text" class="form-control input-wdatepicker" onfocus="WdatePicker()" isvalid="yes" checkexpession="NotNull">
  168. </td>
  169. <th class="formTitle" style="width: 60px;">单据编号</th>
  170. <td class="formValue">
  171. <input id="RkCode" type="text" class="form-control" isvalid="yes" checkexpession="NotNull">
  172. </td>
  173. </tr>
  174. <tr>
  175. <th class="formTitle" style="width: 60px;">应收金额</th>
  176. <td class="formValue">
  177. <input id="Accounts" type="text" class="form-control" isvalid="yes" checkexpession="NotNull">
  178. </td>
  179. <th class="formTitle" style="width: 60px;">摘要信息</th>
  180. <td class="formValue">
  181. <input id="AbstractInfo" type="text" class="form-control" isvalid="yes" checkexpession="NotNull">
  182. </td>
  183. <th class="formTitle" style="width: 60px;">备注</th>
  184. <td class="formValue">
  185. <input id="Description" type="text" class="form-control" isvalid="yes" checkexpession="NotNull">
  186. </td>
  187. </tr>
  188. </table>
  189. </div>
  190. <div class="gridPanel">
  191. <table id="gridTable"></table>
  192. </div>
  193. </div>
  194. <style>
  195. body {
  196. margin: 0px;
  197. }
  198. .bills {
  199. overflow: hidden;
  200. border-radius: 0px;
  201. position: relative;
  202. background: #FFFFFF;
  203. border: 0px solid rgb(204, 204, 204);
  204. box-shadow: none;
  205. padding: 0px;
  206. }
  207. .ui-widget-content {
  208. border-left: 0px;
  209. border-right: 0px;
  210. border-bottom: 0px;
  211. }
  212. </style>