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.

449 lines
16 KiB

1 month ago
  1. 
  2. @{
  3. ViewBag.Title = "Index";
  4. Layout = "~/Views/Shared/_Index.cshtml";
  5. }
  6. <link href="~/Content/js/select2/select2.min.css" rel="stylesheet" />
  7. <script src="~/Content/js/select2/select2.min.js"></script>
  8. <script>
  9. var list = "";
  10. var _Clos = new Array();
  11. var STNO = $.request("STNO");
  12. var Vendor = $.request("Vendor");
  13. var WorkPoints = $.request("WorkPoint");
  14. var RoleEnCode = '@NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode'
  15. var UserCode = '@NFine.Code.OperatorProvider.Provider.GetCurrent().VenCode'
  16. var EATTRIBUTE1 = decodeURI($.request("EATTRIBUTE1"));
  17. $(function () {
  18. SetCols();
  19. InitControl();
  20. InitControl1();
  21. gridList();
  22. $("#sel_VenCode").change(function () {
  23. debugger;
  24. var WorkPoint = $("#sel_WorkPoint").children('option:selected').val();
  25. if (WorkPoint == "") {
  26. $.modalAlert("请选择站点!");
  27. $('#sel_VenCode').select2("val", "");
  28. return;
  29. }
  30. else {
  31. GetICSASNCode();
  32. }
  33. })
  34. if (RoleEnCode.includes('Vendor')) {
  35. $("#sel_VenCode").val([UserCode]).trigger("change");
  36. }
  37. var WorkPoint = $("#sel_WorkPoint").children('option:selected').val();
  38. //查询后台条码表单据自定义项(控制前台显示)
  39. $.ajax({
  40. url: "/SRM/ASNAdd/SelectICSColumnEnableForLotEnablebyASN" + "?" + Math.random() + "&WorkPoint=" + WorkPoint,
  41. dataType: "json",
  42. async: false,
  43. success: function (data) {
  44. debugger;
  45. if (data != null && data.length > 0) {
  46. for (var i = 0; i < data.length; i++) {
  47. //debugger;
  48. if (data[i].ColumnCode == 'EATTRIBUTE1')
  49. {
  50. $("#LableEATTRIBUTE1").css('display', 'none');
  51. $("#LableEATTRIBUTE2").css('display', 'none');
  52. }
  53. }
  54. }
  55. else {
  56. $("#LableEATTRIBUTE1").css('display', 'none');
  57. $("#LableEATTRIBUTE2").css('display', 'none');
  58. }
  59. }
  60. });
  61. debugger;
  62. //加载自定义项名字
  63. $.ajax({
  64. url: "/SRM/ASNAdd/GetLoadShowForColumnByASN" + "?" + Math.random() + "&WorkPoint=" + WorkPoint,
  65. dataType: "json",
  66. async: false,
  67. success: function (data) {
  68. if (data.rows.length > 0) {
  69. $("#LableEATTRIBUTE1").text(data.rows[0].Name);
  70. }
  71. }
  72. });
  73. })
  74. function SetCols() {
  75. debugger;
  76. $.ajax({
  77. url: "/SRM/PORelease/SelectColumnName?" + Math.random(),
  78. dataType: "json",
  79. async: false,
  80. success: function (data) {
  81. var cols = new Array();
  82. var collast = { label: "主键", name: "ID", hidden: true, key: true };
  83. cols.push(collast);
  84. var collast = { label: '采购订单号', name: 'Code', width: 120, align: 'left' };
  85. cols.push(collast);
  86. var collast = { label: '行号', name: 'Sequence', width: 120, align: 'left' };
  87. cols.push(collast);
  88. var collast = { label: '物料编码', name: 'InvCode', width: 120, align: 'left' };
  89. cols.push(collast);
  90. var collast = { label: '物料名称', name: 'InvName', width: 120, align: 'left' };
  91. cols.push(collast);
  92. var collast = { label: '规格型号', name: 'InvStd', width: 120, align: 'left' };
  93. cols.push(collast);
  94. var collast = { label: '数量', name: 'Quantity', width: 120, align: 'left',editable: true };
  95. cols.push(collast);
  96. $.ajax({
  97. url: "/SRM/PORelease/SelectTableColumnName?" + Math.random(),
  98. dataType: "json",
  99. async: false,
  100. success: function (data) {
  101. if (data != null && data.length > 0) {
  102. DateList = data;
  103. for (var i = 0; i < data.length; i++) {
  104. var TableCode = data[i].TableCode;
  105. if (TableCode == "ICSPurchaseOrder") {
  106. var Code = data[i].Code;
  107. var Name = data[i].Name;
  108. var obj = new Array();
  109. obj = {
  110. label: Name,
  111. name: Code,
  112. width: 200,
  113. align: "left"
  114. }
  115. cols.push(obj);
  116. }
  117. }
  118. }
  119. _Closs = cols;
  120. //_Clos1 = cols1;
  121. }
  122. });
  123. if (data != null && data.length > 0) {
  124. DateList = data;
  125. for (var i = 0; i < data.length; i++) {
  126. var ColName = data[i].ColName;
  127. var ColCode = data[i].ColCode;
  128. var obj = new Array();
  129. obj = {
  130. label: ColName,
  131. name: ColCode,
  132. width: 80,
  133. align: "left"
  134. }
  135. cols.push(obj);
  136. }
  137. }
  138. _Clos = cols;
  139. }
  140. });
  141. }
  142. function GetICSASNCode() {
  143. debugger;
  144. var WorkPoint = $("#sel_WorkPoint").children('option:selected').val();
  145. var VenCode = $("#sel_VenCode").children('option:selected').val();
  146. if (WorkPoint == "") {
  147. $.modalAlert("请选择站点!");
  148. return;
  149. }
  150. if (VenCode == "") {
  151. $.modalAlert("请选择供应商!");
  152. return;
  153. }
  154. $.ajax({
  155. url: "/SRM/ASNManage/GetICSASNCode?RoleEnCode=" + VenCode + "&WorkPoint=" + WorkPoint,
  156. dataType: "json",
  157. async: false,
  158. success: function (data) {
  159. debugger;
  160. if (data.CartonNo != '') {
  161. $("#STNO").text(data.rows);
  162. $("#EATTRIBUTE1").val(EATTRIBUTE1);
  163. $("#sel_VenCode").attr("disabled", "disabled");
  164. }
  165. else {
  166. $("#sel_VenCode").removeAttr("disabled");
  167. }
  168. }
  169. });
  170. }
  171. function InitControl() {
  172. var $VenCode = $("#sel_VenCode");
  173. $VenCode.select2({
  174. allowClear: true,
  175. escapeMarkup: function (m) {
  176. return m;
  177. }
  178. });
  179. $.ajax({
  180. url: "/PNSRM/ASNManage/GetVendor" + "?" + Math.random(),
  181. dataType: "json",
  182. async: false,
  183. success: function (data) {
  184. $.each(data, function (index, item) {
  185. $VenCode.append("<option value='" + item.F_VenCode + "'>&nbsp;" + item.cVenName + "</option>");
  186. });
  187. }
  188. });
  189. }
  190. function InitControl1() {
  191. var $VenCode = $("#sel_WorkPoint");
  192. $VenCode.select2({
  193. allowClear: true,
  194. escapeMarkup: function (m) {
  195. return m;
  196. }
  197. });
  198. $.ajax({
  199. url: "/PNSRM/ASNManage/GetWorkPoint" + "?" + Math.random(),
  200. dataType: "json",
  201. async: false,
  202. success: function (data) {
  203. $.each(data, function (index, item) {
  204. $VenCode.append("<option value='" + item.WorkPointCode + "'>&nbsp;" + item.WorkPointName + "</option>");
  205. });
  206. $("#sel_WorkPoint").val([data[1].WorkPointCode]).trigger("change");
  207. }
  208. });
  209. }
  210. function gridList() {
  211. var $gridList = $("#gridList");
  212. var WorkPoint = $("#sel_WorkPoint").children('option:selected').val();
  213. var queryJson = {
  214. STNO: STNO,
  215. WorkPoint: WorkPoint,
  216. }
  217. $gridList.dataGrid({
  218. url: "/PNSRM/ASNManage/GetSubGridJson_Add" + "?" + Math.random(),
  219. postData: { queryJson: JSON.stringify(queryJson) ,WorkPoint: JSON.stringify(WorkPoint)},
  220. height: $(window).height() - 200,
  221. width: $(window).width() - 400,
  222. cellEdit: true,
  223. colModel: _Clos,
  224. cellsubmit: "clientArray",
  225. pager: "#gridPager",
  226. sortname: 'ID',
  227. autowidth: true,
  228. rownumbers: true,
  229. viewrecords: true,
  230. });
  231. }
  232. //新增采购订单
  233. function btnCreate() {
  234. var flag = "";
  235. $.ajax({
  236. url: "/PNSRM/ASNManage/IsASNByCarton?" + Math.random(),
  237. dataType: "json",
  238. async: false,
  239. success: function (data) {
  240. debugger;
  241. flag = data.result;
  242. }
  243. });
  244. if (flag == "0") {
  245. debugger;
  246. $.modalAlert("不可添加条码信息,送货单只能添加箱号!", "error");
  247. return;
  248. }
  249. if ($("#sel_VenCode").children('option:selected').val() == "") {
  250. $.modalAlert("请选择供应商!", "error");
  251. return;
  252. }
  253. if ($("#STNO").text() == "") {
  254. $.modalAlert("送货单号不可为空,请先选择供应商!", "error");
  255. return;
  256. }
  257. var WorkPoint = $("#sel_WorkPoint").children('option:selected').val();
  258. var VenCode = $("#sel_VenCode").children('option:selected').val();
  259. $.modalOpen({
  260. id: "SeachLotInfo",
  261. title: "采购订单信息",
  262. url: "/PNSRM/ASNManage/ASNSelect?WorkPoint=" + WorkPoint + "&VenCode=" + VenCode,
  263. width: "1000px",
  264. height: "1000px",
  265. callBack: function (iframeId) {
  266. var objArr = top.frames[iframeId].submitForm();
  267. var arrayData = getJQAllData("#gridList");
  268. for (var j = 0; j < objArr.length; j++) {
  269. for (var i = 0; i < arrayData.length; i++) {
  270. if (objArr[j].Code + objArr[j].Sequence == arrayData[i].Code + arrayData[i].Sequence) {
  271. $.modalAlert("所选采购订单行已添加!请勿重复添加!", "error");
  272. return;
  273. }
  274. }
  275. $("#gridList").jqGrid('addRowData', objArr[j].ID, objArr[j], 'last');
  276. $(".unwritten").hide();
  277. }
  278. top.frames[iframeId].Close();
  279. }
  280. });
  281. }
  282. function getJQAllData(list) {
  283. //拿到grid对象
  284. var obj = $(list);
  285. //获取grid表中所有的rowid值
  286. var rowIds = obj.getDataIDs();
  287. //初始化一个数组arrayData容器,用来存放rowData
  288. var arrayData = new Array();
  289. if (rowIds.length > 0) {
  290. for (var i = 0; i < rowIds.length; i++) {
  291. //rowData=obj.getRowData(rowid);//这里rowid=rowIds[i];
  292. arrayData.push(obj.getRowData(rowIds[i]));
  293. }
  294. }
  295. return arrayData;
  296. }
  297. //刷新
  298. function reloadData() {
  299. STNO = $("#STNO").text();
  300. var WorkPoint = $("#sel_WorkPoint").children('option:selected').val();
  301. var queryJson = {
  302. STNO: STNO,
  303. WorkPoint: WorkPoint,
  304. }
  305. $("#gridList").jqGrid('setGridParam', {
  306. postData: { queryJson: JSON.stringify(queryJson) },
  307. page: 1
  308. }).trigger('reloadGrid');
  309. }
  310. //删除采购订单行
  311. function btn_delete() {
  312. debugger;
  313. var rowid = $("#gridList").jqGridRowValue().ID
  314. $("#gridList").delRowData(rowid);
  315. }
  316. //提交时候删除
  317. function submitForm() {
  318. if ($("#sel_VenCode").children('option:selected').val()=="") {
  319. $.modalAlert("请选择供应商!");
  320. return;
  321. }
  322. if ($("#STNO").text()=="") {
  323. $.modalAlert("送货单号不可为空,请先选择供应商!");
  324. return;
  325. }
  326. debugger;
  327. var WorkPoint = $("#sel_WorkPoint").children('option:selected').val();
  328. var VenCode = $("#sel_VenCode").children('option:selected').val();
  329. var STNO = $("#STNO").text();
  330. var Details = [];
  331. var obj_vendor = $("#gridList");
  332. var rowIds_vendor = obj_vendor.getDataIDs();
  333. var arrayData_vendor = new Array();
  334. var EATTRIBUTE1 = $("#EATTRIBUTE1").val()
  335. if (rowIds_vendor.length > 0) {
  336. for (var i = 0; i < rowIds_vendor.length; i++) {
  337. var vendorRowData = obj_vendor.getRowData(rowIds_vendor[i]);
  338. var obj = {
  339. Sequences: i + 1,
  340. Code: vendorRowData.Code,
  341. Sequence: vendorRowData.Sequence,
  342. InvCode: vendorRowData.InvCode,
  343. Quantity: vendorRowData.Quantity,
  344. Amount: 0,
  345. };
  346. Details.push(obj);
  347. }
  348. var ICSASNs = {
  349. VenCode: VenCode,
  350. ASNCode: STNO,
  351. WorkPoint: WorkPoint,
  352. EATTRIBUTE1: EATTRIBUTE1,
  353. Detail: Details,
  354. }
  355. var ICSASN = [];
  356. ICSASN.push(ICSASNs);
  357. $.submitForm({
  358. url: "/PNSRM/ASNManage/SaveICSASNAndDetail?WorkPoint=" + WorkPoint + "&" + Math.random(),
  359. param: { ICSASN: JSON.stringify(ICSASN) },
  360. success: function () {
  361. $.currentWindow().$("#gridList").trigger("reloadGrid");
  362. }
  363. })
  364. }
  365. }
  366. </script>
  367. <form id="form1">
  368. <div class="topPanel">
  369. <div class="btn-group">
  370. <a id="NF-AddItemLot" style="margin-left:3px;" class="btn btn-primary" onclick="btnCreate()"><i class="fa fa-pencil-square-o"></i>添加采购订单</a>
  371. @*<a id="NF-AddCartonNo" style="margin-left:3px;" class="btn btn-primary" onclick="btnAddCartonNo()"><i class="fa fa-pencil-square-o"></i>添加容器</a>*@
  372. <a id="NF-deleteItemLot" style="margin-left:3px;" class="btn btn-primary" onclick="btn_delete()"><i class="fa fa-pencil-square-o"></i>删除</a>
  373. <a id="refresh" class="btn btn-primary" onclick="reloadData()"><span class="glyphicon glyphicon-refresh"></span></a>
  374. </div>
  375. </div>
  376. <div style="padding-top: 20px; margin-right: 20px;">
  377. <table class="form">
  378. <tr>
  379. <th class="formTitle">站点:</th>
  380. <td class="formValue">
  381. <select id="sel_WorkPoint" name="sel_WorkPoint" class="form-control select2" style="width: 150px" placeholder="请选择站点..."></select>
  382. <input type="hidden" id="hidetext" />
  383. </td>
  384. <th class="formTitle">送货单号:</th>
  385. <td class="formValue">
  386. <label id="STNO" name="STNO" class="form-control" style="height:20px"></label>
  387. </td>
  388. <th class="formTitle "><label id="LableEATTRIBUTE1" ></label></th>
  389. <td class="formValue"id="LableEATTRIBUTE2">
  390. <input id="EATTRIBUTE1" name="EATTRIBUTE1" type="text" class="form-control " />
  391. </td>
  392. <th class="formTitle">供应商:</th>
  393. <td class="formValue">
  394. <select id="sel_VenCode" name="sel_VenCode" class="form-control select2" style="width: 250px" placeholder="请选择供应商编码..."></select>
  395. <input type="hidden" id="hidetext" />
  396. </td>
  397. </tr>
  398. </table>
  399. </div>
  400. <div class="gridPanel">
  401. <table id="gridList"></table>
  402. <div id="gridPager"></div>
  403. </div>
  404. </form>