grid_edit.js 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  1. define(function () {
  2. return function () {
  3. var $grid, v = 0;
  4. var toolbar = {
  5. xtype: 'toolbar',
  6. items: [
  7. {
  8. text: '多机下拉菜单',
  9. menu: {
  10. xtype: 'menu',
  11. items: [
  12. {
  13. text: '菜单1', iconCls: 'fa fa-save', onClick: function () {
  14. $.yvan.msg('菜单1');
  15. }
  16. },
  17. {
  18. text: '菜单2', iconCls: 'fa fa-times', onClick: function () {
  19. $.yvan.msg('菜单2');
  20. }
  21. }
  22. ]
  23. }
  24. },
  25. {
  26. text: 'IDS', onClick: function () {
  27. var ids = $grid.getDataIDs();
  28. console.log(ids);
  29. }
  30. },
  31. {
  32. text: '上移', onClick: function () {
  33. $grid.moveUp();
  34. }
  35. },
  36. {
  37. text: '下移', onClick: function () {
  38. $grid.moveDown();
  39. }
  40. },
  41. {
  42. text: '删除', iconCls: 'fa fa-minus-square',
  43. onClick: function () {
  44. var result = $grid.deleteRow();
  45. console.log('deleteRow', result);
  46. }
  47. },
  48. {
  49. text: 'addRowForEdit', iconCls: 'fa fa-plus-circle',
  50. onClick: function () {
  51. var result = $grid.addRowForEdit({ orderqty: v++, orderqtyeach: 0, unitprice: 0, totalprice: 0 });
  52. console.log('addRowForEdit', result);
  53. }
  54. },
  55. {
  56. text: 'editRowId', iconCls: 'fa fa-minus-square',
  57. onClick: function () {
  58. var result = $grid.editRowId();
  59. console.log('editRowId', result);
  60. }
  61. },
  62. {
  63. text: 'getEditRow', iconCls: 'fa fa-minus-square',
  64. onClick: function () {
  65. var result = $grid.getEditRow();
  66. console.log('getEditRow', result);
  67. }
  68. },
  69. {
  70. text: 'setEditRow', iconCls: 'fa fa-minus-square',
  71. onClick: function () {
  72. var result = $grid.setEditRow({
  73. skuid: "G1ADKILDID7",
  74. skucode: "W060004236",
  75. polineno: '99',
  76. skuname: "罗弗8002橡皮",
  77. manufacturer: "九州通达",
  78. packcode: "W060004236",
  79. packid: "G1ADKILDID7",
  80. packtype: "3",
  81. allowexcerece: '99',
  82. uom: "3"
  83. });
  84. console.log('setEditRow', result);
  85. }
  86. },
  87. {
  88. text: 'saveEdit', iconCls: 'fa fa-minus-square',
  89. onClick: function () {
  90. var result = $grid.saveEdit();
  91. console.log('saveEdit', result);
  92. }
  93. },
  94. {
  95. text: 'cancelEditRow', iconCls: 'fa fa-minus-square',
  96. onClick: function () {
  97. var result = $grid.cancelEditRow();
  98. console.log('cancelEditRow', result);
  99. }
  100. }
  101. ]
  102. };
  103. return {
  104. center: {
  105. border: false,
  106. items: [
  107. {
  108. onRender: function () {
  109. $grid = $(this);
  110. },
  111. onBeginEditRow: function () {
  112. console.log('beginEditRow', this, arguments);
  113. },
  114. onRestoryEditRow: function () {
  115. console.log('restoryEditRow', this, arguments);
  116. },
  117. onSaveEditRow: function () {
  118. console.log('saveEditRow', this, arguments);
  119. },
  120. onReadysetEditRow: function () {
  121. console.log('readysetEditRow', this, arguments);
  122. },
  123. url: '/mock/docpo.json',
  124. xtype: 'grid',
  125. idField: 'skuid',
  126. toolbar: toolbar,
  127. editable: true,
  128. multiselect: true,
  129. //multiboxonly: true,
  130. editOnSelected: true,
  131. //editOnDblClick: true,
  132. autoSizeColumns: false,
  133. pagination: false,
  134. columns: [[
  135. { field: 'skuid', hidden: true },
  136. { field: 'polineno', hidden: true },
  137. {
  138. field: 'skucode', title: '产品编号', width: 180,
  139. editor: {
  140. xtype: 'searchbox',
  141. required: true,
  142. widget: {
  143. url: '/widget/selectDocSku.js',
  144. bind: {
  145. skuid: 'skuId',
  146. skucode: 'skuCode',
  147. skuname: 'skuName',
  148. manufacturer: 'manufacturer',
  149. packcode: 'packCode',
  150. packid: 'packId',
  151. uom: 'packType',
  152. packtype: 'packType',
  153. packmeasspec: 'packMeasspec',
  154. zpackMeasspec: 'zpackMeasspec'
  155. }
  156. }
  157. }
  158. },
  159. {
  160. field: 'skuname', title: '产品名称', width: 200,
  161. formatter: 'c1'
  162. },
  163. {
  164. field: 'manufacturer', title: '生产厂家', width: 140,
  165. formatter: 'c2'
  166. },
  167. { field: 'packcode', title: '包装编号', width: 100 },
  168. {
  169. field: 'uom', title: '收货单位', width: 100,
  170. editor: {
  171. xtype: 'combobox',
  172. required: true,
  173. data: $.yvan.bizDict('packingType').combo(),
  174. onChange: function () {
  175. $.yvan.msg('收货单位.onChange');
  176. }
  177. }
  178. },
  179. {
  180. field: 'orderqty', title: '订单数量(主单位)', width: 120,
  181. editor: {
  182. xtype: 'numberbox',
  183. precision: 2,
  184. required: true,
  185. validType: 'gtZero',
  186. onChange: function () {
  187. $.yvan.msg('订单数量.onChange');
  188. }
  189. }
  190. },
  191. {
  192. field: 'orderqtyeach', title: '订单数量(收货单位)', width: 120,
  193. editor: {
  194. xtype: 'numberbox',
  195. precision: 2,
  196. required: true,
  197. onChange: function () {
  198. $.yvan.msg('订单数量.onChange');
  199. }
  200. }
  201. },
  202. {
  203. field: 'unitprice', title: '含税单价', width: 100,
  204. editor: {
  205. xtype: 'numberbox',
  206. precision: 2,
  207. onChange: function () {
  208. $.yvan.msg('含税单价.onChange');
  209. }
  210. }
  211. },
  212. {
  213. field: 'totalprice', title: '含税金额', width: 100,
  214. editor: {
  215. xtype: 'numberbox',
  216. precision: 2,
  217. onChange: function () {
  218. $.yvan.msg('含税金额.onChange');
  219. }
  220. }
  221. },
  222. {
  223. field: 'allowexcerece', title: '超量收货', width: 100,
  224. editor: {
  225. xtype: 'checkbox',
  226. on: '99',
  227. off: '10',
  228. onChange: function () {
  229. $.yvan.msg('超量收货.onChange');
  230. }
  231. }
  232. },
  233. {
  234. field: 'excereceperc', title: '超量百分比', width: 100,
  235. editor: {
  236. xtype: 'numberbox',
  237. precision: 2,
  238. onChange: function () {
  239. $.yvan.msg('超量百分比.onChange');
  240. }
  241. }
  242. },
  243. { field: 'packid', hidden: true },
  244. { field: 'packtype', hidden: true },
  245. { field: 'packmeasspec', hidden: true },
  246. { field: 'zpackMeasspec', hidden: true },
  247. { field: 'pono', hidden: true }
  248. ]]
  249. }
  250. ]
  251. }
  252. };
  253. };
  254. });