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.

537 lines
22 KiB

  1. 
  2. @{
  3. ViewBag.Title = "Index";
  4. Layout = "~/Views/Shared/_Form.cshtml";
  5. }
  6. <link href="~/Content/js/select2/select2.min.css" rel="stylesheet" />
  7. <link href="~/Content/css/bootstrap/bootstrap-select.css" rel="stylesheet" />
  8. <script src="~/Content/js/datepicker/WdatePicker.js"></script>
  9. <script src="~/Content/js/bootstrap/bootstrap-select.js"></script>
  10. <script src="~/Content/js/select2/select2.min.js"></script>
  11. <script src="~/Content/js/layer/layer.js"></script>
  12. <style>
  13. #Additem {
  14. margin-left: 45%;
  15. }
  16. #AddTemitem {
  17. margin-right: 45%;
  18. }
  19. .ui-jqgrid .ui-jqgrid-btable tbody tr.jqgrow td {
  20. overflow: inherit;
  21. word-wrap: break-word;
  22. }
  23. .ui-jqgrid tr.jqgrow td {
  24. white-space: normal !important;
  25. height: auto;
  26. }
  27. </style>
  28. <script>
  29. var _Clos = new Array();
  30. var rfqcode = $.request("rfqcode");
  31. var ID = $.request("ID");
  32. var InCode = $.request("InCode");
  33. $(function(){
  34. SetCols();
  35. var Muser = '@NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode'
  36. var now = new Date();
  37. var date = now.toLocaleDateString();
  38. InitControl();
  39. InitContro2();
  40. InitContro3();
  41. if (!!InCode) {
  42. $.ajax({
  43. url: "/DHAY/ICSCustomerSuppliedIn/GetICSOtherInByInCode?InCode=" + InCode,
  44. //data: { keyValue: keyValue },
  45. dataType: "json",
  46. async: false,
  47. success: function (data) {
  48. debugger;
  49. $("#sel_CodeType").val([data.rows[0].EATTRIBUTE2]).trigger("change");//单据类型
  50. $("#Code").val(data.rows[0].InCode);//单号
  51. $("#sel_Dept").val([data.rows[0].EATTRIBUTE1]).trigger("change");//受益部门
  52. $("#txtSYproject").val([data.rows[0].EATTRIBUTE7]).trigger("change");//受益项目
  53. $("#txtApplyNegCode").val(data.rows[0].EATTRIBUTE3);//在建工程项目
  54. $("#sel_Custmer").val([data.rows[0].EATTRIBUTE4]).trigger("change");//客户
  55. $("#Remarks").val(data.rows[0].EATTRIBUTE5);//备注
  56. $("#txtMUSER").val(Muser);
  57. $("#txtMTIME").val(date);
  58. }
  59. })
  60. }
  61. reloadData();
  62. })
  63. function SetCols() {
  64. $.ajax({
  65. url: "/Print/SelectColumnName?" + Math.random(),
  66. dataType: "json",
  67. async: false,
  68. success: function (data) {
  69. var cols = new Array();
  70. var collast = { label: '主键', name: 'ID', width: 150, align: 'left', hidden: true, key: true };
  71. cols.push(collast);
  72. var collast = { label: 'ID', name: 'ID', width: 150, align: 'left', hidden: true };
  73. cols.push(collast);
  74. var collast = { label: '料品编码', name: 'InvCode', width: 100, align: 'left' };
  75. cols.push(collast);
  76. var collast = { label: '料品名称', name: 'InvName', width: 100, align: 'left' };
  77. cols.push(collast);
  78. var collast = { label: '规格型号', name: 'InvStd', width: 100, align: 'left' };
  79. cols.push(collast);
  80. var collast = { label: '仓库编码', name: 'WHCode', width: 100, align: 'left', hidden: true };
  81. cols.push(collast);
  82. var collast = { label: '仓库名称', name: 'WHCodeName', width: 100, align: 'left', editable: true };
  83. cols.push(collast);
  84. var collast = { label: '批号', name: 'Batch', width: 100, align: 'left', editable: true };
  85. cols.push(collast);
  86. var collast = { label: '数量', name: 'Quantity', width: 100, align: 'left', editable: true, editrules: { number: true } };
  87. cols.push(collast);
  88. var collast = { label: '备注', name: 'EATTRIBUTE6', width: 150, align: 'left', editable: true };
  89. cols.push(collast);
  90. if (data != null && data.length > 0) {
  91. DateList = data;
  92. for (var i = 0; i < data.length; i++) {
  93. var ColName = data[i].ColName;
  94. var ColCode = data[i].ColCode;
  95. var obj = new Array();
  96. obj = {
  97. label: ColName,
  98. name: ColCode,
  99. width: 80,
  100. align: "left"
  101. }
  102. cols.push(obj);
  103. }
  104. }
  105. _Clos = cols;
  106. }
  107. });
  108. }
  109. function reloadData() {
  110. $("#gridList").dataGrid({
  111. url: "/DHAY/ICSCustomerSuppliedIn/GetICSReturnTemporary?rfqno=" + $("#Code").val() + "&" + Math.random(),
  112. height: $(window).height() - 200,
  113. width: $(window).width() - 300,
  114. cellEdit: true,
  115. colModel: _Clos,
  116. cellsubmit: "clientArray",
  117. shrinkToFit: false,//宽度自适应
  118. autoWidth: true,
  119. gridComplete: function () {
  120. debugger;
  121. //设置select
  122. //var RowDatas = $("#gridList").jqGrid('getDataIDs');
  123. //for (var j = 0; j < RowDatas.length; j++) {
  124. // var ID = $("#gridList").jqGrid("getCell", RowDatas[j], "ID");
  125. // var WHCode = $("#gridList").jqGrid("getCell", RowDatas[j], "WHCodeHHH");
  126. // GetSelectPerson(ID, WHCode);
  127. //}
  128. },
  129. pager: "#gridPager",
  130. sortorder: "desc",
  131. sortname: 'DNCode ',
  132. viewrecords: true,
  133. multiselect: true,
  134. subGrid: false, // (1)开启子表格支持
  135. ondblClickRow: function (rowid, cellname, value) {
  136. var colModel = $("#gridList").jqGrid("getGridParam", "colModel");
  137. var cellIndex = $("#gridList").jqGrid("getGridParam", "iCol");
  138. var cellname = colModel[cellIndex].name;
  139. if (cellname == "InvCode") {
  140. $.modalOpen({
  141. id: "InvCodeSelect",
  142. title: "选择物料信息",
  143. url: "/DHAY/ICSCustomerSuppliedReturn/GetInvCode",
  144. width: "50%",
  145. height: "50%",
  146. callBack: function (iframeId) {
  147. debugger;
  148. var obj = top.frames[iframeId].submitForm();
  149. $("#gridList").jqGrid('setCell', rowid, 'InvCode', obj.INVCODE, 'review-' + rowid);
  150. $("#gridList").jqGrid('setCell', rowid, 'INVNAME', obj.INVNAME, 'review-' + rowid);
  151. $("#gridList").jqGrid('setCell', rowid, 'InvStd', obj.InvStd, 'review-' + rowid);
  152. $("#gridList").jqGrid("saveCell", rowid, 1);
  153. $("#gridList").jqGrid("saveCell", rowid, 2);
  154. $("#gridList").jqGrid("saveCell", rowid, 3);
  155. $("#gridList").jqGrid("saveCell", rowid, 4);
  156. $("#gridList").jqGrid("saveCell", rowid, 5);
  157. $("#gridList").jqGrid("saveCell", rowid, 6);
  158. $("#gridList").jqGrid("saveCell", rowid, 7);
  159. $("#gridList").jqGrid("saveCell", rowid, 8);
  160. $("#gridList").jqGrid("saveCell", rowid, 9);
  161. top.frames[iframeId].Close();
  162. }
  163. });
  164. } else if (cellname == "WHCodeName") {
  165. $.modalOpen({
  166. id: "GetWHCode",
  167. title: "选择仓库",
  168. url: "/DHAY/ICSCustomerSuppliedOut/GetWHCode",
  169. width: "50%",
  170. height: "50%",
  171. callBack: function (iframeId) {
  172. debugger;
  173. var obj = top.frames[iframeId].submitForm();
  174. $("#gridList").jqGrid('setCell', rowid, 'WHCode', obj.WarehouseCode, 'review-' + rowid);
  175. $("#gridList").jqGrid('setCell', rowid, 'WHCodeName', obj.WarehouseName, 'review-' + rowid);
  176. $("#gridList").jqGrid("saveCell", rowid, 1);
  177. $("#gridList").jqGrid("saveCell", rowid, 2);
  178. $("#gridList").jqGrid("saveCell", rowid, 3);
  179. $("#gridList").jqGrid("saveCell", rowid, 4);
  180. $("#gridList").jqGrid("saveCell", rowid, 5);
  181. $("#gridList").jqGrid("saveCell", rowid, 6);
  182. $("#gridList").jqGrid("saveCell", rowid, 7);
  183. $("#gridList").jqGrid("saveCell", rowid, 8);
  184. $("#gridList").jqGrid("saveCell", rowid, 9);
  185. top.frames[iframeId].Close();
  186. }
  187. });
  188. } else if (cellname == "Batch") {
  189. $.modalOpen({
  190. id: "InvCodeSelect",
  191. title: "选择批次信息",
  192. url: "/DHAY/ICSCustomerSuppliedReturn/GetBatch",
  193. width: "50%",
  194. height: "50%",
  195. callBack: function (iframeId) {
  196. debugger;
  197. var obj = top.frames[iframeId].submitForm();
  198. $("#gridList").jqGrid('setCell', rowid, 'Batch', obj.BatchCode, 'review-' + rowid);
  199. $("#gridList").jqGrid("saveCell", rowid, 1);
  200. $("#gridList").jqGrid("saveCell", rowid, 2);
  201. $("#gridList").jqGrid("saveCell", rowid, 3);
  202. $("#gridList").jqGrid("saveCell", rowid, 4);
  203. $("#gridList").jqGrid("saveCell", rowid, 5);
  204. $("#gridList").jqGrid("saveCell", rowid, 6);
  205. $("#gridList").jqGrid("saveCell", rowid, 7);
  206. $("#gridList").jqGrid("saveCell", rowid, 8);
  207. $("#gridList").jqGrid("saveCell", rowid, 9);
  208. top.frames[iframeId].Close();
  209. }
  210. });
  211. }
  212. },
  213. /* footerrow: true,//启用底部行(对列汇总时要启用)第一步*/
  214. });
  215. }
  216. function btnLook(cellvalue, options, rowObject) {
  217. return cellvalue = "<a class=\"btn btn-primary dropdown-text\" onclick=\"UpLoadClick('" + rowObject.ID + "')\">查看</a>";
  218. }
  219. function UpLoadClick(ID) {
  220. $.modalOpen({
  221. id: "selectDeatil",
  222. title: "查看修改物料",
  223. url: "/WMS/ProductionIssue/SeachInventory?ID=" + ID + "&" + Math.random(),
  224. width: "1000px",
  225. height: "1000px",
  226. callBack: function (iframeId) {
  227. var obj = top.frames[iframeId].submitForm();
  228. var rowData = $("#gridList").jqGrid('getRowData', ID);
  229. rowData.TLZID=obj.TLZID,
  230. rowData.ZJID= obj.ZJID,
  231. rowData.InvCode= obj.InvCode,
  232. rowData.InvName= obj.InvName,
  233. rowData.InvStd= obj.InvStd,
  234. rowData.InvUnit= obj.InvUnit,
  235. rowData.Quantity= obj.Quantity,
  236. rowData.IssueNegQuantity= obj.IssueQuantity,
  237. rowData.Amount= obj.Amount,
  238. rowData.ExtensionID= obj.ExtensionID,
  239. rowData.ProjectCode= obj.ProjectCode,
  240. rowData.BatchCode= obj.BatchCode,
  241. rowData.Version= obj.Version,
  242. rowData.Brand= obj.Brand,
  243. rowData.cFree1= obj.cFree1,
  244. rowData.cFree2= obj.cFree2,
  245. rowData.cFree3= obj.cFree3,
  246. rowData.cFree4= obj.cFree4,
  247. rowData.cFree5= obj.cFree5,
  248. rowData.cFree6= obj.cFree6,
  249. rowData.cFree7= obj.cFree7,
  250. rowData.cFree8= obj.cFree8,
  251. rowData.cFree9= obj.cFree9,
  252. rowData.cFree10= obj.cFree10
  253. $("#gridList").jqGrid('setRowData', ID, rowData);
  254. $(".unwritten").hide();
  255. top.frames[iframeId].Close();
  256. }
  257. });
  258. }
  259. function guid() {
  260. return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
  261. var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);
  262. return v.toString(16);
  263. });
  264. }
  265. //最后一行新增数据
  266. function AddRowToLast() {
  267. var obj = {
  268. ID: guid(),
  269. WHCode:""
  270. };
  271. $("#gridList").jqGrid('addRowData', obj.ID, obj, 'last');
  272. $(".unwritten").hide();
  273. }
  274. function DeleteRowToLast() {
  275. debugger;
  276. var rowid = $("#gridList").jqGridRowValue().ID
  277. $("#gridList").delRowData(rowid);
  278. }
  279. //获取U9单据类型
  280. function InitControl() {
  281. var $CodeType = $("#sel_CodeType");
  282. $CodeType.select2({
  283. allowClear: true,
  284. escapeMarkup: function (m) {
  285. return m;
  286. }
  287. });
  288. $.ajax({
  289. url: "/DHAY/ICSCustomerSuppliedReturn/GetU9CodeType" + "?" + Math.random(),
  290. dataType: "json",
  291. async: false,
  292. success: function (data) {
  293. $.each(data, function (index, item) {
  294. $CodeType.append("<option value='" + item.Code + "'>&nbsp;" + item.Name + "</option>");
  295. });
  296. }
  297. });
  298. }
  299. //获取U9部门
  300. function InitContro2() {
  301. var $Dept = $("#sel_Dept");
  302. $Dept.select2({
  303. allowClear: true,
  304. escapeMarkup: function (m) {
  305. return m;
  306. }
  307. });
  308. $.ajax({
  309. url: "/DHAY/ICSCustomerSuppliedReturn/GetU9Department" + "?" + Math.random(),
  310. dataType: "json",
  311. async: false,
  312. success: function (data) {
  313. $.each(data, function (index, item) {
  314. $Dept.append("<option value='" + item.Code + "'>&nbsp;" + item.Name + "</option>");
  315. });
  316. }
  317. });
  318. }
  319. //获取U9客户
  320. function InitContro3() {
  321. var $Custmer = $("#sel_Custmer");
  322. $Custmer.select2({
  323. allowClear: true,
  324. escapeMarkup: function (m) {
  325. return m;
  326. }
  327. });
  328. $.ajax({
  329. url: "/DHAY/ICSCustomerSuppliedReturn/GetU9Customer" + "?" + Math.random(),
  330. dataType: "json",
  331. async: false,
  332. success: function (data) {
  333. $.each(data, function (index, item) {
  334. $Custmer.append("<option value='" + item.Code + "'>&nbsp;" + item.Name + "</option>");
  335. });
  336. }
  337. });
  338. }
  339. function submitForm() {
  340. $("#gridList").find($("td[aria-describedby='gridList_rn']")).click();
  341. debugger;
  342. if (!$('#form1').formValid()) {
  343. return false;
  344. }
  345. var CodeType = $("#sel_CodeType").val();//单据类型
  346. var Dept = $("#sel_Dept").val();//部门
  347. var ApplyNegCode = $("#txtApplyNegCode").val();//在建项目
  348. var Custmer = $("#sel_Custmer").val();//客户
  349. var Remarks = $("#Remarks").val();//备注
  350. var Code = $("#Code").val();//单据号
  351. var MTIME = $("#txtMTIME").val();//单据号
  352. var SYproject = $("#txtSYproject").val();//受益项目
  353. var RoleEnCode = '@NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode'
  354. var WorkPoint = '@NFine.Code.OperatorProvider.Provider.GetCurrent().Location'
  355. var IDlist = "";
  356. var Details = [];
  357. SelPerson = "#SelBR_"
  358. var obj_vendor = $("#gridList");
  359. var rowIds_vendor = obj_vendor.getDataIDs();
  360. var arrayData_vendor = new Array();
  361. if (rowIds_vendor.length > 0) {
  362. for (var i = 0; i < rowIds_vendor.length; i++) {
  363. var vendorRowData = obj_vendor.getRowData(rowIds_vendor[i]);
  364. if (vendorRowData.Quantity == "" || vendorRowData.Quantity == 'undefined') {
  365. $.modalAlertNew("WMS00089");
  366. return;
  367. }
  368. /* var WHCode = $("" + SelPerson + "" + vendorRowData.ID + "").val();*/
  369. var obj = {
  370. ID: vendorRowData.ID,
  371. Sequence: i + 1,
  372. InvCode: vendorRowData.InvCode,
  373. Quantity: vendorRowData.Quantity,
  374. WHCode: vendorRowData.WHCode,
  375. DetailReamrk: vendorRowData.EATTRIBUTE6,
  376. Batch: vendorRowData.Batch
  377. };
  378. Details.push(obj);
  379. }
  380. var ICSASNs = {
  381. Dept: Dept,
  382. CodeType: CodeType,
  383. ApplyNegCode: ApplyNegCode,
  384. Custmer: Custmer,
  385. Remarks: Remarks,
  386. Code: Code,
  387. MTIME: MTIME,
  388. SYproject: SYproject,
  389. User: RoleEnCode,
  390. Detail: Details,
  391. }
  392. var ICSASN = [];
  393. ICSASN.push(ICSASNs);
  394. $.submitForm({
  395. url: "/DHAY/ICSCustomerSuppliedIn/UpdateICSOtherIn?" + Math.random(),
  396. param: { ICSASN: JSON.stringify(ICSASN) },
  397. success: function () {
  398. $.currentWindow().$("#gridList").trigger("reloadGrid");
  399. }
  400. })
  401. }
  402. }
  403. function GetSelectPerson( ID, WHCode) {
  404. var str = "";
  405. $.ajax({
  406. url: "/DHAY/ICSCustomerSuppliedIn/Select_ICSWHCode?" + Math.random(),
  407. dataType: "json",
  408. async: false,
  409. async: false,
  410. success: function (data) {
  411. if (data != null && data.length > 0) {
  412. $("#SelBR_" + ID + "").find("option").remove();
  413. for (var i = 0; i < data.length; i++) {
  414. $("#SelBR_" + ID + "").append("<option value='" + data[i].WarehouseCode + "'>" + data[i].WarehouseName + "</option>");
  415. }
  416. }
  417. }
  418. });
  419. $("#SelBR_" + ID + "").selectpicker('refresh');
  420. $("#SelBR_" + ID + "").selectpicker('val', WHCode);
  421. }
  422. </script>
  423. <form id="form1">
  424. <div class="topPanel" style="height:10px">
  425. <div class="btn-group">
  426. @*<a id="AddItemLot" style="margin-left:3px;" class="btn btn-primary" onclick="btnCreate()"><i class="fa fa-pencil-square-o"></i>添加明细</a>
  427. <a id="refresh" class="btn btn-primary" style="margin-left:3px;" onclick="reloadData()"><span class="glyphicon glyphicon-refresh"></span></a>*@
  428. </div>
  429. </div>
  430. <div style="margin-right: 20px;">
  431. <table class="form">
  432. <thead>主表信息</thead>
  433. <tr>
  434. <th class="formTitle">单据类型:</th>
  435. <td class="formValue">
  436. <select id="sel_CodeType" name="sel_CodeType" class="form-control select2 required" style="width: 230px" placeholder="请选择单据类型..."></select>
  437. <input type="hidden" id="hidetext" />
  438. </td>
  439. <th class="formTitle">单号:</th>
  440. <td class="formValue">
  441. <input id="Code" type="text" readonly="readonly" class="form-control required" />
  442. </td>
  443. </tr>
  444. <tr>
  445. <th class="formTitle">受益部门:</th>
  446. <td class="formValue">
  447. <select id="sel_Dept" name="sel_Dept" class="form-control select2 required" style="width: 230px" placeholder="请选择受益部门..."></select>
  448. <input type="hidden" id="hidetext" />
  449. </td>
  450. <th class="formTitle">受益项目:</th>
  451. <td class="formValue">
  452. <input type="text" id="txtSYproject" class="form-control" />
  453. </td>
  454. </tr>
  455. <tr>
  456. <th class="formTitle">在建工程项目:</th>
  457. <td class="formValue">
  458. <input type="text" id="txtApplyNegCode" class="form-control" />
  459. </td>
  460. <th class="formTitle">客户:</th>
  461. <td class="formValue">
  462. <select id="sel_Custmer" name="sel_Custmer" class="form-control select2" style="width: 230px" placeholder="请选择客户..."></select>
  463. <input type="hidden" id="hidetext" />
  464. </td>
  465. </tr>
  466. <tr>
  467. <th class="formTitle">备注:</th>
  468. <td class="formValue">
  469. <input type="text" id="Remarks" class="form-control" />
  470. </td>
  471. </tr>
  472. <tr>
  473. <th class="formTitle">维护人:</th>
  474. <td class="formValue">
  475. <input id="txtMUSER" type="text" readonly="readonly" class="form-control" />
  476. </td>
  477. <th class="formTitle">维护时间:</th>
  478. <td class="formValue">
  479. <input id="txtMTIME" type="text" readonly="readonly" class="form-control" />
  480. </td>
  481. </tr>
  482. </table>
  483. </div>
  484. <div class="gridPanel" style="margin-left:10px">
  485. <span><strong>子表信息</strong></span>
  486. <table id="gridList"></table>
  487. <div style="text-align:center">
  488. <button id="AddRow" class="btn btn-primary" type="button" onclick="AddRowToLast()">添加</button>
  489. <button id="DeleteRow" type="button" class="btn btn-primary" onclick="DeleteRowToLast()">删除</button>
  490. </div>
  491. </div>
  492. </form>