Index.js 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441
  1. var refreshGirdData;
  2. var bootstrap = function ($, learun) {
  3. "use strict";
  4. var selectRowsData;
  5. var psuid = "";
  6. var stampType = request('stamptype');
  7. var urls = [{ "url": "/FJManager/BillBomSet/DFM1509", "name": "DFM1509", "width": 744, "height": 690 },
  8. { "url": "/FJManager/BillBomSet/DOF2", "name": "DOF2", "width": 920, "height": 676 },
  9. { "url": "/FJManager/BillBomSet/DOF4", "name": "DOF4", "width": 920, "height": 676 },
  10. { "url": "/FJManager/BillBomSet/DFM6", "name": "DFM6", "width": 920, "height": 676 },
  11. { "url": "/FJManager/BillBomSet/DFM09", "name": "DFM9", "width": 940, "height": 676 },
  12. { "url": "/FJManager/BillBomSet/Exception", "name": "Exception", "width": 920, "height": 676 },
  13. { "url": "/FJManager/BillBomSet/DFMAll", "name": "DFMAll", "width": 920, "height": 676 },];
  14. var page = {
  15. init: function () {
  16. page.bind();
  17. page.initGird();
  18. },
  19. bind: function () {
  20. $('#multiple_condition_query').lrMultipleQuery(function (queryJson) {
  21. // 调用后台查询
  22. // queryJson 查询条件
  23. console.log(queryJson);
  24. queryJson["Code"] = $("#Code").val();
  25. queryJson["Name"] = $("#Name").val();
  26. queryJson["ShortCode"] = $("#ShortCode").val();
  27. queryJson["ProMaterCode"] = $("#ProMaterCode").val();
  28. queryJson["BomCode"] = $("#BomCode").val();
  29. if ($("#IsStop").is(":checked")) {
  30. queryJson["IsStop"] = '1';
  31. } else {
  32. queryJson["IsStop"] = '';
  33. }
  34. queryJson["StampType"] = stampType;
  35. page.search({ queryJson: JSON.stringify(queryJson) });
  36. }, 250);
  37. // 查询
  38. $('#btn_Search').on('click', function () {
  39. var keyword = $('#txt_Keyword').val();
  40. page.search({ queryJson: JSON.stringify({ keyword: $('#txt_Keyword').val(), StampType: stampType }) });
  41. });
  42. // 刷新
  43. $('#lr_refresh').on('click', function () {
  44. location.reload();
  45. });
  46. // 新增
  47. $('#lr_add').on('click', function () {
  48. learun.layerForm({
  49. id: 'form',
  50. title: '新增' + urls[parseInt(stampType) - 1].name,
  51. url: top.$.rootUrl + urls[parseInt(stampType) - 1].url,
  52. width: urls[parseInt(stampType) - 1].width,
  53. height: urls[parseInt(stampType) - 1].height,
  54. callBack: function (id) {
  55. return top[id].acceptClick(refreshGirdData);
  56. }
  57. });
  58. });
  59. // 编辑
  60. $('#lr_edit').on('click', function () {
  61. let editSelRows = $('#gridtable').jfGridGet("rowdata");
  62. if (editSelRows.length == 0) {
  63. learun.alert.error('未选择行!');
  64. return false;
  65. }
  66. if (editSelRows.length > 1) {
  67. learun.alert.error('选择了多行!');
  68. return false;
  69. }
  70. var keyValue = $('#gridtable').jfGridValue('Id');
  71. if (learun.checkrow(keyValue)) {
  72. learun.layerForm({
  73. id: 'form',
  74. title: '编辑' + urls[parseInt(stampType) - 1].name,
  75. url: top.$.rootUrl + urls[parseInt(stampType) - 1].url + '?keyValue=' + keyValue,
  76. width: urls[parseInt(stampType) - 1].width,
  77. height: urls[parseInt(stampType) - 1].height,
  78. callBack: function (id) {
  79. return top[id].acceptClick(refreshGirdData);
  80. }
  81. });
  82. }
  83. });
  84. $("#lr_search").on('click', function () {
  85. let editSelRows = $('#gridtable').jfGridGet("rowdata");
  86. if (editSelRows.length == 0) {
  87. learun.alert.error('未选择行!');
  88. return false;
  89. }
  90. if (editSelRows.length > 1) {
  91. learun.alert.error('选择了多行!');
  92. return false;
  93. }
  94. var keyValue = $('#gridtable').jfGridValue('Id');
  95. if (learun.checkrow(keyValue)) {
  96. learun.layerForm({
  97. id: 'form',
  98. title: '查看' + urls[parseInt(stampType) - 1].name,
  99. btn: ['关闭'],
  100. url: top.$.rootUrl + urls[parseInt(stampType) - 1].url + '?keyValue=' + keyValue,
  101. width: urls[parseInt(stampType) - 1].width,
  102. height: urls[parseInt(stampType) - 1].height,
  103. callBack: function (id) {
  104. return true;
  105. //return top[id].acceptClick(refreshGirdData);
  106. }
  107. });
  108. }
  109. });
  110. // 删除
  111. $('#lr_delete').on('click', function () {
  112. selectRowsData = $('#gridtable').jfGridGet("rowdata");
  113. if (selectRowsData.length == 0) {
  114. learun.alert.error('未选择行!');
  115. return false;
  116. }
  117. var keyValue = selectRowsData.map((item) => item.Id);
  118. //var keyValue = $('#gridtable').jfGridValue('Id');
  119. if (learun.checkrow(keyValue)) {
  120. learun.layerConfirm('是否确认删除该项!', function (res) {
  121. if (res) {
  122. learun.deleteForm(top.$.rootUrl + '/FJManager/BillBomSet/Deletes', { keyValue: keyValue }, function () {
  123. refreshGirdData();
  124. });
  125. }
  126. });
  127. }
  128. });
  129. // 启用
  130. $('#lr_enable').on('click', function () {
  131. var postData = $('#gridtable').jfGridGet("rowdata");
  132. if (postData.length == 0) {
  133. learun.alert.error('未选择行!');
  134. return false;
  135. }
  136. if (postData.length > 1) {
  137. learun.alert.error('启用只能选择一条数据!');
  138. return false;
  139. }
  140. learun.layerConfirm('是否确认启用该跺型!', function (res) {
  141. if (res) {
  142. learun.postForm(top.$.rootUrl + '/FJManager/BillBomSet/Enables', { ids: JSON.stringify(postData.map((item) => item.Id)) }, function () {
  143. refreshGirdData();
  144. });
  145. }
  146. });
  147. });
  148. // 禁用
  149. $('#lr_disable').on('click', function () {
  150. var postData = $('#gridtable').jfGridGet("rowdata");
  151. if (postData.length == 0) {
  152. learun.alert.error('未选择行!');
  153. return false;
  154. }
  155. learun.layerConfirm('是否确认禁用该跺型!', function (res) {
  156. if (res) {
  157. learun.postForm(top.$.rootUrl + '/FJManager/BillBomSet/Disables', { ids: JSON.stringify(postData.map((item) => item.Id)) }, function () {
  158. refreshGirdData();
  159. });
  160. }
  161. });
  162. });
  163. // 打印
  164. $('#lr_print').on('click', function () {
  165. $('#gridtable').jqprintTable();
  166. });
  167. },
  168. // 初始化列表
  169. initGird: function () {
  170. $('#gridtable').jfGrid({
  171. url: top.$.rootUrl + '/FJManager/BillBomSet/GetPageList',
  172. headData: [
  173. { label: '垛型编码', name: 'Code', width: 160, align: 'left' },
  174. { label: '垛型名称', name: 'Name', width: 160, align: 'left' },
  175. { label: '短编号', name: 'ShortCode', width: 50, align: 'left' },
  176. { label: '帘线物料编码', name: 'ProMaterCode', width: 100, align: 'left' },
  177. { label: '投料物料编码', name: 'ProCode', width: 180, align: 'left' },
  178. { label: '实际物料编码', name: 'BomCode', width: 180, align: 'left' },
  179. //{
  180. // label: '投料物料名称', name: 'BomCode', width: 180, align: 'left', formatterAsync: function (callback, value, row) {
  181. // learun.httpAsync('GET', top.$.rootUrl + '/FJManager/BillBomInfo/GetList', { queryJson: JSON.stringify({ Code: value }) }, function (res) {
  182. // if (res.code > 0 && res.data.length > 0) {
  183. // callback(res.data[0].Name);
  184. // }
  185. // });
  186. // },
  187. //},
  188. { label: '工字轮个数', name: 'HWCountQty', width: 70, align: 'left' },
  189. {
  190. label: '托盘类型', name: 'TpTypeCode', width: 60, align: 'left', formatter: function (cellvalue) {
  191. if (cellvalue == '1') {
  192. return '<span class=\"label label-success\" >09</span>';
  193. } else if (cellvalue == '2') {
  194. return '<span class=\"label label-default\" >非09</span>';
  195. } else {
  196. return '<span class=\"label label-default\" >未知</span>';
  197. }
  198. }
  199. },
  200. { label: '层数', name: 'LayerCountQty', width: 40, align: 'left' },
  201. learun.jfFormatter.col_ISSTOP(),
  202. //{
  203. // label: '是否删除', name: 'IsDelete', width: 60, align: "center"
  204. // , formatter: function (cellvalue) {
  205. // if (cellvalue == 0) {
  206. // return '<span class=\"label label-success\" >正常</span>';
  207. // } else if (cellvalue == 1) {
  208. // return '<span class=\"label label-default\" >删除</span>';
  209. // } else {
  210. // return '<span class=\"label label-default\" >未知</span>';
  211. // }
  212. // }
  213. //},
  214. {
  215. label: '子类型', name: 'StampChildType', width: 120, align: 'left', formatter: function (cellvalue, item) {
  216. if (item.StampType == '2') {
  217. if (cellvalue == '1') {
  218. return '<span class=\"label label-default\" >DOF2-01</span>';
  219. } else if (cellvalue == '2') {
  220. return '<span class=\"label label-default\" >DOF2-02</span>';
  221. } else if (cellvalue == '3') {
  222. return '<span class=\"label label-default\" >DOF2-03</span>';
  223. } else if (cellvalue == '4') {
  224. return '<span class=\"label label-default\" >DOF2-04</span>';
  225. } else if (cellvalue == '5') {
  226. return '<span class=\"label label-default\" >DOF2-05</span>';
  227. }
  228. }
  229. if (item.StampType == '3') {
  230. if (cellvalue == '1') {
  231. return '<span class=\"label label-default\" >DOF4-01</span>';
  232. } else if (cellvalue == '2') {
  233. return '<span class=\"label label-default\" >DOF4-02</span>';
  234. } else if (cellvalue == '3') {
  235. return '<span class=\"label label-default\" >DOF4-03</span>';
  236. } else if (cellvalue == '4') {
  237. return '<span class=\"label label-default\" >DOF4-04</span>';
  238. } else if (cellvalue == '5') {
  239. return '<span class=\"label label-default\" >DOF4-05</span>';
  240. } else if (cellvalue == '6') {
  241. return '<span class=\"label label-default\" >DOF4-06</span>';
  242. } else if (cellvalue == '7') {
  243. return '<span class=\"label label-default\" >DOF4-07</span>';
  244. }
  245. }
  246. else if (item.StampType == '4') {
  247. if (cellvalue == '1') {
  248. return '<span class=\"label label-default\" >DFM6-01</span>';
  249. } else if (cellvalue == '2') {
  250. return '<span class=\"label label-default\" >DFM6-02</span>';
  251. } else if (cellvalue == '3') {
  252. return '<span class=\"label label-default\" >DFM6-03</span>';
  253. } else if (cellvalue == '4') {
  254. return '<span class=\"label label-default\" >DFM6-04</span>';
  255. } else if (cellvalue == '5') {
  256. return '<span class=\"label label-default\" >DFM6-05</span>';
  257. } else if (cellvalue == '6') {
  258. return '<span class=\"label label-default\" >DFM6-06</span>';
  259. } else if (cellvalue == '7') {
  260. return '<span class=\"label label-default\" >DFM6-07</span>';
  261. } else if (cellvalue == '8') {
  262. return '<span class=\"label label-default\" >DFM6-08</span>';
  263. } else if (cellvalue == '9') {
  264. return '<span class=\"label label-default\" >DFM6-09</span>';
  265. }
  266. } else if (item.StampType == '5') {
  267. if (cellvalue == '1') {
  268. return '<span class=\"label label-default\" >DFM9-01</span>';
  269. } else if (cellvalue == '2') {
  270. return '<span class=\"label label-default\" >DFM9-02</span>';
  271. } else if (cellvalue == '3') {
  272. return '<span class=\"label label-default\" >DFM9-03</span>';
  273. } else if (cellvalue == '4') {
  274. return '<span class=\"label label-default\" >DFM9-04</span>';
  275. } else if (cellvalue == '5') {
  276. return '<span class=\"label label-default\" >DFM9-05</span>';
  277. } else if (cellvalue == '6') {
  278. return '<span class=\"label label-default\" >DFM9-06</span>';
  279. } else if (cellvalue == '7') {
  280. return '<span class=\"label label-default\" >DFM9-07</span>';
  281. } else if (cellvalue == '8') {
  282. return '<span class=\"label label-default\" >DFM9-08</span>';
  283. } else if (cellvalue == '9') {
  284. return '<span class=\"label label-default\" >DFM9-09</span>';
  285. }
  286. }
  287. else if (item.StampType == '6') {
  288. if (cellvalue == '1') {
  289. return '<span class=\"label label-default\" >WS34芯股--异常</span>';
  290. } else if (cellvalue == '2') {
  291. return '<span class=\"label label-default\" >WS18--异常</span>';
  292. } else if (cellvalue == '3') {
  293. return '<span class=\"label label-default\" >WS50--异常</span>';
  294. } else if (cellvalue == '4') {
  295. return '<span class=\"label label-default\" >WS09--异常</span>';
  296. }
  297. }
  298. else {
  299. return '<span class=\"label label-default\" >无</span>';
  300. }
  301. }
  302. },
  303. {
  304. label: '是否桁架码垛', name: 'IsTruss', width: 80, align: 'left', formatter: function (cellvalue) {
  305. if (cellvalue==1) {
  306. return '<span class=\"label label-success\" >是</span>';
  307. } else if (cellvalue==='') {
  308. return '<span class=\"label label-default\" >未知</span>';
  309. } else if (cellvalue === 0) {
  310. return '<span class=\"label label-info\" >否</span>';
  311. } else {
  312. return '<span class=\"label label-default\" >未知</span>';
  313. }
  314. }
  315. },
  316. learun.jfFormatter.col_AddWho(),
  317. learun.jfFormatter.col_AddTime(),
  318. learun.jfFormatter.col_EditWho(),
  319. learun.jfFormatter.col_EditTime(),
  320. learun.jfFormatter.col_MEMO()
  321. ],
  322. mainId: 'Code',
  323. isPage: true,
  324. isMultiselect: true,
  325. reloadSelected: true,
  326. sidx: 'Code',
  327. isSubGrid: true, // 是否有子表
  328. subGridExpanded: function (subid, rowdata) {
  329. psuid = subid;
  330. $('#' + subid).jfGrid({
  331. url: top.$.rootUrl + '/FJManager/BillBomSet/GetBillBomSetInfoItem',
  332. headData: [
  333. { label: '编号', name: 'XYNo', width: 40, align: 'left' },
  334. { label: '行', name: 'Row', width: 40, align: 'left' },
  335. { label: '物料编码', name: 'MatCode', width: 200, align: 'left' },
  336. { label: '物料Id', name: 'MatId', width: 150, align: 'left' },
  337. {
  338. label: '有/无', name: 'IsEmpty', width: 60, align: 'left', formatter: function (cellvalue) {
  339. if (cellvalue == '0') {
  340. return '<span class=\"label label-success\" >有</span>';
  341. } else if (cellvalue == '1') {
  342. return '<span class=\"label label-default\" >无</span>';
  343. } else {
  344. return '<span class=\"label label-default\" >未知</span>';
  345. }
  346. }
  347. },
  348. {
  349. label: '正/反面', name: 'SideNum', width: 70, align: 'left', formatter: function (cellvalue) {
  350. if (cellvalue == '1') {
  351. return '<span class=\"label label-success\" >正面朝上</span>';
  352. } else if (cellvalue == '2') {
  353. return '<span class=\"label label-default\" >反面朝上</span>';
  354. } else {
  355. return '<span class=\"label label-default\" >未知</span>';
  356. }
  357. }
  358. },
  359. { label: '工字轮型号', name: 'SpoolType', width: 80, align: 'left' },
  360. {
  361. label: '单/双丝', name: 'SilkType', width: 80, align: 'left', formatter: function (cellvalue) {
  362. if (cellvalue == '1') {
  363. return '<span class=\"label label-success\" >单丝</span>';
  364. } else if (cellvalue == '2') {
  365. return '<span class=\"label label-default\" >双丝</span>';
  366. } else if (cellvalue == '3') {
  367. return '<span class=\"label label-default\" >三丝</span>';
  368. }
  369. else {
  370. return '<span class=\"label label-default\" >未知</span>';
  371. }
  372. }
  373. },
  374. { label: '钢丝直径上限', name: 'SilkDiam', width: 100, align: 'left' },
  375. /* { label: '钢丝直径上限', name: 'SilkDiamMaxCount', width: 100, align: 'left' },*/
  376. { label: '数量上限', name: 'QtyMaxCount', width: 100, align: 'left' },
  377. {
  378. label: '是否芯股', name: 'IsCore', width: 100, align: 'left', formatter: function (cellvalue) {
  379. if (cellvalue == '1') {
  380. return '<span class=\"label label-success\" >是</span>';
  381. } else if (cellvalue == '2') {
  382. return '<span class=\"label label-default\" >否</span>';
  383. }
  384. else {
  385. return '<span class=\"label label-default\" >未知</span>';
  386. }
  387. }
  388. },
  389. {
  390. label: '是混合行', name: 'IsMixRow', width: 100, align: 'left', formatter: function (cellvalue) {
  391. if (cellvalue == '1') {
  392. return '<span class=\"label label-success\" >是</span>';
  393. } else if (cellvalue == '0') {
  394. return '<span class=\"label label-default\" >否</span>';
  395. }
  396. else {
  397. return '<span class=\"label label-default\" >未知</span>';
  398. }
  399. }
  400. },
  401. { label: '混合料行编码', name: 'MixRowCode', width: 100, align: 'left' },
  402. learun.jfFormatter.col_ISSTOP(),
  403. ]
  404. });
  405. $('#' + subid).jfGridSet('reloadSon', { bomSetHdrId: rowdata.Id });
  406. },
  407. });
  408. page.search({ queryJson: JSON.stringify({ keyword: $('#txt_Keyword').val(), StampType: stampType }) });
  409. },
  410. search: function (param) {
  411. $('#gridtable').jfGridSet('reload', param);
  412. }
  413. };
  414. refreshGirdData = function () {
  415. $('#gridtable').jfGridSet('reload');
  416. };
  417. page.init();
  418. }