Detail.cshtml 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  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. $(".bills").height($(window).height() - 88);
  15. //resize重设(表格、树形)宽高
  16. $(window).resize(function (e) {
  17. window.setTimeout(function () {
  18. $('#gridTable').setGridWidth(($('.gridPanel').width()));
  19. $(".bills").height($(window).height() - 88);
  20. }, 200);
  21. e.stopPropagation();
  22. });
  23. //客户名称
  24. $("#CustomerId").ComboBox({
  25. url: "../../CustomerManage/Customer/GetListJson",
  26. id: "CustomerId",
  27. text: "FullName",
  28. description: "==请选择==",
  29. height: "360px",
  30. width: "280px",
  31. allowSearch: true
  32. });
  33. //销售人员
  34. $("#SellerId").ComboBoxTree({
  35. url: "../../BaseManage/User/GetTreeJson",
  36. description: "==请选择==",
  37. height: "360px",
  38. width: "280px",
  39. allowSearch: true
  40. });
  41. //收款方式
  42. $("#PaymentMode").ComboBox({
  43. url: "../../SystemManage/DataItemDetail/GetDataItemListJson",
  44. param: { EnCode: "Client_PaymentMode" },
  45. id: "ItemValue",
  46. text: "ItemName",
  47. description: "==请选择==",
  48. height: "200px"
  49. });
  50. }
  51. //初始化控件
  52. function InitControl() {
  53. //获取表单
  54. if (!!keyValue) {
  55. $.SetForm({
  56. url: "../../CustomerManage/Order/GetFormJson",
  57. param: { keyValue: keyValue },
  58. success: function (data) {
  59. //主表
  60. var order = data.order;
  61. $("#form1").SetWebControls(order);
  62. $("#DiscountSum").val(toDecimal(order.DiscountSum));
  63. $("#Accounts").val(toDecimal(order.Accounts));
  64. $("#SaleCost").val(toDecimal(order.SaleCost));
  65. //明细
  66. var orderEntry = data.orderEntry;
  67. $("#gridTable").find('[role=row]').each(function (i) {
  68. var row = orderEntry[i - 1];
  69. if (row != undefined) {
  70. $(this).find('td[aria-describedby="gridTable_OrderEntryId"]').html(row.OrderEntryId);
  71. $(this).find('td[aria-describedby="gridTable_ProductName"]').html(row.ProductName);
  72. $(this).find('td[aria-describedby="gridTable_ProductCode"]').html(row.ProductCode);
  73. $(this).find('td[aria-describedby="gridTable_UnitId"]').html(row.UnitId);
  74. $(this).find('td[aria-describedby="gridTable_Qty"]').html(toDecimal(row.Qty));
  75. $(this).find('td[aria-describedby="gridTable_Price"]').html(toDecimal(row.Price));
  76. $(this).find('td[aria-describedby="gridTable_Amount"]').html(toDecimal(row.Amount));
  77. $(this).find('td[aria-describedby="gridTable_TaxRate"]').html(row.TaxRate);
  78. $(this).find('td[aria-describedby="gridTable_Taxprice"]').html(toDecimal(row.Taxprice));
  79. $(this).find('td[aria-describedby="gridTable_Tax"]').html(toDecimal(row.Tax));
  80. $(this).find('td[aria-describedby="gridTable_TaxAmount"]').html(toDecimal(row.TaxAmount));
  81. $(this).find('td[aria-describedby="gridTable_Description"]').html(row.Description);
  82. }
  83. });
  84. //合计
  85. var TotalQty = 0.00, TotalPrice = 0.00, TotalAmount = 0.00, TotalTaxprice = 0.00, TotalTax = 0.00, TotalTaxAmount = 0.00;
  86. $("#gridTable").find('[role=row]').each(function (i) {
  87. var Qty = $(this).find('td:eq(5)').html();
  88. if (Qty != "" && Qty != undefined && Qty != '&nbsp;') {
  89. TotalQty += Number(Qty);
  90. }
  91. var Price = $(this).find('td:eq(6)').html();
  92. if (Price != "" && Price != undefined && Price != '&nbsp;') {
  93. TotalPrice += Number(Price);
  94. }
  95. var Amount = $(this).find('td:eq(7)').html();
  96. if (Amount != "" && Amount != undefined && Amount != '&nbsp;') {
  97. TotalAmount += Number(Amount);
  98. }
  99. var Taxprice = $(this).find('td:eq(9)').html();
  100. if (Taxprice != "" && Taxprice != undefined && Taxprice != '&nbsp;') {
  101. TotalTaxprice += Number(Taxprice);
  102. }
  103. var Tax = $(this).find('td:eq(10)').html();
  104. if (Tax != "" && Tax != undefined) {
  105. TotalTax += Number(Tax);
  106. }
  107. var TaxAmount = $(this).find('td:eq(11)').html();
  108. if (TaxAmount != "" && TaxAmount != undefined && TaxAmount != '&nbsp;') {
  109. TotalTaxAmount += Number(TaxAmount);
  110. }
  111. });
  112. $("#TotalQty").text(toDecimal(TotalQty));
  113. $("#TotalPrice").text(toDecimal(TotalPrice));
  114. $("#TotalAmount").text(toDecimal(TotalAmount));
  115. $("#TotalTaxprice").text(toDecimal(TotalTaxprice));
  116. $("#TotalTax").text(toDecimal(TotalTax));
  117. $("#TotalTaxAmount").text(toDecimal(TotalTaxAmount));
  118. }
  119. });
  120. }
  121. }
  122. //加载明细
  123. function GetOrderEntryGrid() {
  124. var $grid = $("#gridTable");
  125. $grid.jqGrid({
  126. unwritten: false,
  127. datatype: "local", height: '100%',
  128. autowidth: true,
  129. colModel: [
  130. { label: '主键', name: 'OrderEntryId', hidden: true },
  131. { label: '商品名称', name: "ProductName", width: 260, align: 'left', sortable: false, resizable: false },
  132. { label: '商品编号', name: "ProductCode", width: 100, align: 'center', sortable: false, resizable: false },
  133. { label: '单位', name: "UnitId", width: 100, align: 'center', sortable: false, resizable: false },
  134. { label: '数量', name: 'Qty', width: 80, align: 'center', sortable: false, resizable: false },
  135. { label: '单价', name: 'Price', width: 80, align: 'center', sortable: false, resizable: false },
  136. { label: '金额', name: 'Amount', width: 80, align: 'center', sortable: false, resizable: false },
  137. { label: '税率(%)', name: 'TaxRate', width: 80, align: 'center', sortable: false, resizable: false },
  138. { label: '含税单价', name: 'Taxprice', width: 80, align: 'center', sortable: false, resizable: false },
  139. { label: '税额', name: 'Tax', width: 80, align: 'center', sortable: false, resizable: false },
  140. { label: '含税金额', name: 'TaxAmount', width: 80, align: 'center', sortable: false, resizable: false },
  141. { label: '说明信息', name: 'Description', width: 200, align: 'left', sortable: false, resizable: false } ],
  142. pager: false,
  143. rownumbers: true,
  144. shrinkToFit: false,
  145. gridview: true,
  146. footerrow: true,
  147. gridComplete: function () {
  148. //合计
  149. $(this).footerData("set", {
  150. "UnitId": "合计:",
  151. "Qty": "<span id='TotalQty'>0.00</span>",
  152. "Price": "<span id='TotalPrice'>0.00</span>",
  153. "Amount": "<span id='TotalAmount'>0.00</span>",
  154. "Taxprice": "<span id='TotalTaxprice'>0.00</span>",
  155. "Tax": "<span id='TotalTax'>0.00</span>",
  156. "TaxAmount": "<span id='TotalTaxAmount'>0.00</span>"
  157. });
  158. $('table.ui-jqgrid-ftable td[aria-describedby="gridTable_UnitId"]').prevUntil().css("border-right-color", "#fff");
  159. }
  160. });
  161. //表头合并
  162. $grid.jqGrid('setGroupHeaders', {
  163. useColSpanStyle: true,
  164. groupHeaders: [
  165. { startColumnName: 'ProductName', numberOfColumns: 3, titleText: '商品信息' },
  166. { startColumnName: 'Qty', numberOfColumns: 7, titleText: '价格信息' }
  167. ]
  168. });
  169. //默认添加13行 空行
  170. for (var i = 1; i < 13; i++) {
  171. var rowdata = {
  172. OrderEntryId: '',
  173. ProductName: '',
  174. ProductCode: '',
  175. UnitId: '',
  176. Qty: '',
  177. Price: '',
  178. Amount: '',
  179. TaxRate: '',
  180. Taxprice: '',
  181. Tax: '',
  182. TaxAmount: '',
  183. Description: '',
  184. }
  185. $grid.jqGrid('addRowData', i, rowdata);
  186. };
  187. }
  188. //打印
  189. function btn_print() {
  190. $(".bills").printTable();
  191. }
  192. //导出
  193. function btn_export() {
  194. location.href = "/CustomerManage/Order/ExportOrderEntry?orderId=" + keyValue;
  195. }
  196. //前单
  197. function btn_prev() {
  198. $.ajax({
  199. url: "../../CustomerManage/Order/GetPrevJson?keyValue=" + keyValue,
  200. type: "get",
  201. dataType: "json",
  202. async: false,
  203. success: function (data) {
  204. if (data != null) {
  205. var src = top.contentPath + "/CustomerManage/Order/Detail?keyValue=" + data.OrderId;
  206. window.location = src;
  207. $.currentIframe().att('src', 'src');
  208. }
  209. }
  210. });
  211. }
  212. //后单
  213. function btn_next() {
  214. $.ajax({
  215. url: "../../CustomerManage/Order/GetNextJson?keyValue=" + keyValue,
  216. type: "get",
  217. dataType: "json",
  218. async: false,
  219. success: function (data) {
  220. if (data != null) {
  221. var src = top.contentPath + "/CustomerManage/Order/Detail?keyValue=" + data.OrderId;
  222. window.location = src;
  223. $.currentIframe().att('src', 'src');
  224. }
  225. }
  226. });
  227. }
  228. </script>
  229. <div class="bills">
  230. <div class="printArea">
  231. <table class="form" style="width: 100%; margin-bottom: 10px;">
  232. <tr>
  233. <th class="formTitle" style="width: 60px;">客户名称</th>
  234. <td class="formValue">
  235. <div id="CustomerId" type="select" class="ui-select"></div>
  236. </td>
  237. <th class="formTitle">销售人员</th>
  238. <td class="formValue">
  239. <div id="SellerId" type="selectTree" class="ui-select"></div>
  240. </td>
  241. <th class="formTitle">单据日期</th>
  242. <td class="formValue">
  243. <input id="OrderDate" type="text" class="form-control" />
  244. </td>
  245. <th class="formTitle">单据编号</th>
  246. <td class="formValue">
  247. <input id="OrderCode" type="text" class="form-control" />
  248. </td>
  249. </tr>
  250. </table>
  251. </div>
  252. <div class="gridPanel printArea">
  253. <table id="gridTable"></table>
  254. </div>
  255. <div class="printArea">
  256. <textarea id="Description" placeholder="暂无备注信息" class="form-control" style="width: 100%; height: 50px; margin-top: 10px;"></textarea>
  257. <table class="form" style="width: 100%; margin-top: 5px;">
  258. <tr>
  259. <th class="formTitle" style="width: 60px;">优惠金额</th>
  260. <td class="formValue">
  261. <input id="DiscountSum" type="text" class="form-control" value="0.00" />
  262. </td>
  263. <th class="formTitle">收款金额</th>
  264. <td class="formValue">
  265. <input id="Accounts" type="text" class="form-control" value="0.00" />
  266. </td>
  267. <th class="formTitle">收款日期</th>
  268. <td class="formValue">
  269. <input id="PaymentDate" type="text" class="form-control" />
  270. </td>
  271. <th class="formTitle">收款方式</th>
  272. <td class="formValue">
  273. <div id="PaymentMode" type="select" class="ui-select"></div>
  274. </td>
  275. </tr>
  276. <tr>
  277. <th class="formTitle" style="width: 60px;">销售费用</th>
  278. <td class="formValue">
  279. <input id="SaleCost" type="text" class="form-control" value="0.00" />
  280. </td>
  281. <th class="formTitle">制单人员</th>
  282. <td class="formValue">
  283. <input id="CreateUserName" type="text" class="form-control" /></td>
  284. <th class="formTitle">合同编号</th>
  285. <td class="formValue">
  286. <input id="ContractCode" type="text" class="form-control" />
  287. </td>
  288. <th class="formTitle">合同附件</th>
  289. <td class="formValue">
  290. <input id="ContractFile" type="text" class="form-control" />
  291. </td>
  292. </tr>
  293. <tr>
  294. <th class="formTitle">摘要信息</th>
  295. <td class="formValue" colspan="7">
  296. <input id="AbstractInfo" type="text" class="form-control" />
  297. </td>
  298. </tr>
  299. </table>
  300. </div>
  301. </div>
  302. <div id="bottomField">
  303. <div class="btn-group">
  304. <a id="lr-print" class="btn btn-default" onclick="btn_print()"><i class="fa fa-print"></i>&nbsp;打印</a>
  305. <a id="lr-export" class="btn btn-default" onclick="btn_export()"><i class="fa fa-sign-out"></i>&nbsp;导出</a>
  306. </div>
  307. <div class="btn-group">
  308. <a id="lr-prev" class="btn btn-default" onclick="btn_prev()"><i class="fa fa-backward"></i>&nbsp;前单</a>
  309. <a id="lr-next" class="btn btn-default" onclick="btn_next()"><i class="fa fa-forward"></i>&nbsp;后单</a>
  310. </div>
  311. </div>