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.

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