PaiKu.js 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  1. var refreshGirdData;
  2. var bootstrap = function ($, learun) {
  3. "use strict";
  4. var selectRowsData;
  5. var psuid = "";
  6. var urls = [{ "url": "/FJManager/BillBomSet/DFM1509", "name": "DFM1509", "width": 744, "height": 690 },
  7. { "url": "/FJManager/BillBomSet/DOF2", "name": "DOF2", "width": 920, "height": 676 },
  8. { "url": "/FJManager/BillBomSet/DOF4", "name": "DOF4", "width": 920, "height": 676 },
  9. { "url": "/FJManager/BillBomSet/DFM6", "name": "DFM6", "width": 920, "height": 676 },
  10. { "url": "/FJManager/BillBomSet/DFM09", "name": "DFM9", "width": 940, "height": 676 },
  11. { "url": "/FJManager/BillBomSet/Exception", "name": "Exception", "width": 920, "height": 676 },
  12. { "url": "/FJManager/BillBomSet/DFMAll", "name": "DFMAll", "width": 920, "height": 676 },];
  13. var page = {
  14. init: function () {
  15. page.bind();
  16. page.initGird();
  17. },
  18. bind: function () {
  19. $('#multiple_condition_query').lrMultipleQuery(function (queryJson) {
  20. // 调用后台查询
  21. // queryJson 查询条件
  22. console.log(queryJson);
  23. queryJson["Code"] = $("#Code").val();
  24. queryJson["Name"] = $("#Name").val();
  25. queryJson["ShortCode"] = $("#ShortCode").val();
  26. queryJson["ProMaterCode"] = $("#ProMaterCode").val();
  27. queryJson["BomCode"] = $("#BomCode").val();
  28. if ($("#IsStop").is(":checked")) {
  29. queryJson["IsStop"] = '1';
  30. } else {
  31. queryJson["IsStop"] = '';
  32. }
  33. queryJson["StampType"] = stampType;
  34. page.search({ queryJson: JSON.stringify(queryJson) });
  35. }, 250);
  36. // 查询
  37. $('#btn_Search').on('click', function () {
  38. var keyword = $('#txt_Keyword').val();
  39. page.search({ queryJson: JSON.stringify({ keyword: $('#txt_Keyword').val(), StampType: stampType }) });
  40. });
  41. // 刷新
  42. $('#lr_refresh').on('click', function () {
  43. location.reload();
  44. });
  45. // 新增
  46. $('#lr_add').on('click', function () {
  47. learun.layerForm({
  48. id: 'form',
  49. title: '新增' + urls[parseInt(stampType) - 1].name,
  50. url: top.$.rootUrl + urls[parseInt(stampType) - 1].url,
  51. width: urls[parseInt(stampType) - 1].width,
  52. height: urls[parseInt(stampType) - 1].height,
  53. callBack: function (id) {
  54. return top[id].acceptClick(refreshGirdData);
  55. }
  56. });
  57. });
  58. // 编辑
  59. $('#lr_edit').on('click', function () {
  60. let editSelRows = $('#gridtable').jfGridGet("rowdata");
  61. if (editSelRows.length == 0) {
  62. learun.alert.error('未选择行!');
  63. return false;
  64. }
  65. if (editSelRows.length > 1) {
  66. learun.alert.error('选择了多行!');
  67. return false;
  68. }
  69. var keyValue = $('#gridtable').jfGridValue('Id');
  70. if (learun.checkrow(keyValue)) {
  71. learun.layerForm({
  72. id: 'form',
  73. title: '编辑' + urls[parseInt(stampType) - 1].name,
  74. url: top.$.rootUrl + urls[parseInt(stampType) - 1].url + '?keyValue=' + keyValue,
  75. width: urls[parseInt(stampType) - 1].width,
  76. height: urls[parseInt(stampType) - 1].height,
  77. callBack: function (id) {
  78. return top[id].acceptClick(refreshGirdData);
  79. }
  80. });
  81. }
  82. });
  83. $("#lr_search").on('click', function () {
  84. let editSelRows = $('#gridtable').jfGridGet("rowdata");
  85. if (editSelRows.length == 0) {
  86. learun.alert.error('未选择行!');
  87. return false;
  88. }
  89. if (editSelRows.length > 1) {
  90. learun.alert.error('选择了多行!');
  91. return false;
  92. }
  93. var keyValue = $('#gridtable').jfGridValue('Id');
  94. if (learun.checkrow(keyValue)) {
  95. learun.layerForm({
  96. id: 'form',
  97. title: '查看' + urls[parseInt(stampType) - 1].name,
  98. btn: ['关闭'],
  99. url: top.$.rootUrl + urls[parseInt(stampType) - 1].url + '?keyValue=' + keyValue,
  100. width: urls[parseInt(stampType) - 1].width,
  101. height: urls[parseInt(stampType) - 1].height,
  102. callBack: function (id) {
  103. return true;
  104. //return top[id].acceptClick(refreshGirdData);
  105. }
  106. });
  107. }
  108. });
  109. // 删除
  110. $('#lr_delete').on('click', function () {
  111. selectRowsData = $('#gridtable').jfGridGet("rowdata");
  112. if (selectRowsData.length == 0) {
  113. learun.alert.error('未选择行!');
  114. return false;
  115. }
  116. var keyValue = selectRowsData.map((item) => item.Id);
  117. //var keyValue = $('#gridtable').jfGridValue('Id');
  118. if (learun.checkrow(keyValue)) {
  119. learun.layerConfirm('是否确认删除该项!', function (res) {
  120. if (res) {
  121. learun.deleteForm(top.$.rootUrl + '/FJManager/BillBomSet/DeletePK', { keyValue: keyValue }, function () {
  122. refreshGirdData();
  123. });
  124. }
  125. });
  126. }
  127. });
  128. // 启用
  129. $('#lr_enable').on('click', function () {
  130. var postData = $('#gridtable').jfGridGet("rowdata");
  131. if (postData.length == 0) {
  132. learun.alert.error('未选择行!');
  133. return false;
  134. }
  135. if (postData.length > 1) {
  136. learun.alert.error('启用只能选择一条数据!');
  137. return false;
  138. }
  139. learun.layerConfirm('是否确认启用该跺型!', function (res) {
  140. if (res) {
  141. learun.postForm(top.$.rootUrl + '/FJManager/BillBomSet/Enables', { ids: JSON.stringify(postData.map((item) => item.Id)) }, function () {
  142. refreshGirdData();
  143. });
  144. }
  145. });
  146. });
  147. // 禁用
  148. $('#lr_disable').on('click', function () {
  149. var postData = $('#gridtable').jfGridGet("rowdata");
  150. if (postData.length == 0) {
  151. learun.alert.error('未选择行!');
  152. return false;
  153. }
  154. learun.layerConfirm('是否确认禁用该跺型!', function (res) {
  155. if (res) {
  156. learun.postForm(top.$.rootUrl + '/FJManager/BillBomSet/Disables', { ids: JSON.stringify(postData.map((item) => item.Id)) }, function () {
  157. refreshGirdData();
  158. });
  159. }
  160. });
  161. });
  162. // 打印
  163. $('#lr_print').on('click', function () {
  164. $('#gridtable').jqprintTable();
  165. });
  166. },
  167. // 初始化列表
  168. initGird: function () {
  169. $('#gridtable').jfGrid({
  170. url: top.$.rootUrl + '/FJManager/BillBomSet/GetPaiKuList',
  171. headData: [
  172. { label: '垛型编码', name: 'BomsetgrpId', width: 160, align: 'left' },
  173. { label: '垛型名称', name: 'BomsetgrpName', width: 160, align: 'left' },
  174. { label: '所属仓库id', name: 'WarehousId', width: 160, align: 'left' },
  175. { label: '所属仓库编码', name: 'WarehouseCode', width: 50, align: 'left' },
  176. { label: '垛型对应仓库占比', name: 'Percent', 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. learun.jfFormatter.col_AddWho(),
  189. learun.jfFormatter.col_AddTime(),
  190. learun.jfFormatter.col_EditWho(),
  191. learun.jfFormatter.col_EditTime(),
  192. learun.jfFormatter.col_MEMO()
  193. ],
  194. mainId: 'Code',
  195. isPage: true,
  196. isMultiselect: true,
  197. reloadSelected: true,
  198. sidx: 'Code',
  199. isSubGrid: true, // 是否有子表
  200. //subGridExpanded: function (subid, rowdata) {
  201. // psuid = subid;
  202. // $('#' + subid).jfGrid({
  203. // url: top.$.rootUrl + '/FJManager/BillBomSet/GetPaiKuList',
  204. // headData: [
  205. // { label: '编号', name: 'XYNo', width: 40, align: 'left' },
  206. // { label: '行', name: 'Row', width: 40, align: 'left' },
  207. // { label: '物料编码', name: 'MatCode', width: 200, align: 'left' },
  208. // { label: '物料Id', name: 'MatId', width: 150, align: 'left' },
  209. // {
  210. // label: '有/无', name: 'IsEmpty', width: 60, align: 'left', formatter: function (cellvalue) {
  211. // if (cellvalue == '0') {
  212. // return '<span class=\"label label-success\" >有</span>';
  213. // } else if (cellvalue == '1') {
  214. // return '<span class=\"label label-default\" >无</span>';
  215. // } else {
  216. // return '<span class=\"label label-default\" >未知</span>';
  217. // }
  218. // }
  219. // },
  220. // {
  221. // label: '正/反面', name: 'SideNum', width: 70, align: 'left', formatter: function (cellvalue) {
  222. // if (cellvalue == '1') {
  223. // return '<span class=\"label label-success\" >正面朝上</span>';
  224. // } else if (cellvalue == '2') {
  225. // return '<span class=\"label label-default\" >反面朝上</span>';
  226. // } else {
  227. // return '<span class=\"label label-default\" >未知</span>';
  228. // }
  229. // }
  230. // },
  231. // { label: '工字轮型号', name: 'SpoolType', width: 80, align: 'left' },
  232. // {
  233. // label: '单/双丝', name: 'SilkType', width: 80, align: 'left', formatter: function (cellvalue) {
  234. // if (cellvalue == '1') {
  235. // return '<span class=\"label label-success\" >单丝</span>';
  236. // } else if (cellvalue == '2') {
  237. // return '<span class=\"label label-default\" >双丝</span>';
  238. // } else if (cellvalue == '3') {
  239. // return '<span class=\"label label-default\" >三丝</span>';
  240. // }
  241. // else {
  242. // return '<span class=\"label label-default\" >未知</span>';
  243. // }
  244. // }
  245. // },
  246. // { label: '钢丝直径上限', name: 'SilkDiam', width: 100, align: 'left' },
  247. // /* { label: '钢丝直径上限', name: 'SilkDiamMaxCount', width: 100, align: 'left' },*/
  248. // { label: '数量上限', name: 'QtyMaxCount', width: 100, align: 'left' },
  249. // {
  250. // label: '是否芯股', name: 'IsCore', width: 100, align: 'left', formatter: function (cellvalue) {
  251. // if (cellvalue == '1') {
  252. // return '<span class=\"label label-success\" >是</span>';
  253. // } else if (cellvalue == '2') {
  254. // return '<span class=\"label label-default\" >否</span>';
  255. // }
  256. // else {
  257. // return '<span class=\"label label-default\" >未知</span>';
  258. // }
  259. // }
  260. // },
  261. // {
  262. // label: '是混合行', name: 'IsMixRow', width: 100, align: 'left', formatter: function (cellvalue) {
  263. // if (cellvalue == '1') {
  264. // return '<span class=\"label label-success\" >是</span>';
  265. // } else if (cellvalue == '0') {
  266. // return '<span class=\"label label-default\" >否</span>';
  267. // }
  268. // else {
  269. // return '<span class=\"label label-default\" >未知</span>';
  270. // }
  271. // }
  272. // },
  273. // { label: '混合料行编码', name: 'MixRowCode', width: 100, align: 'left' },
  274. // learun.jfFormatter.col_ISSTOP(),
  275. // ]
  276. // });
  277. // $('#' + subid).jfGridSet('reloadSon', { bomSetHdrId: rowdata.Id });
  278. //},
  279. });
  280. page.search({ queryJson: JSON.stringify({ keyword: $('#txt_Keyword').val(), StampType: stampType }) });
  281. },
  282. search: function (param) {
  283. $('#gridtable').jfGridSet('reload', param);
  284. }
  285. };
  286. refreshGirdData = function () {
  287. $('#gridtable').jfGridSet('reload');
  288. };
  289. page.init();
  290. }