orders.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
  2. var Controller = {
  3. index: function () {
  4. // 初始化表格参数配置
  5. Table.api.init({
  6. extend: {
  7. index_url: 'product/orders/index' + location.search+'&ids='+Config.ids,
  8. table: 'product_order',
  9. }
  10. });
  11. var table = $("#table");
  12. // 初始化表格
  13. table.bootstrapTable({
  14. url: $.fn.bootstrapTable.defaults.extend.index_url,
  15. pk: 'id',
  16. sortName: 'id',
  17. fixedColumns: false,
  18. columns: [
  19. [
  20. {checkbox: true},
  21. {field: 'user_id', title: __('用户Id'), operate: 'LIKE'},
  22. {field: 'users.address', title: __('用户地址'), operate: 'LIKE'},
  23. {field: 'total_num', title: __('持有数量'), operate: false},
  24. ]
  25. ]
  26. });
  27. // 为表格绑定事件
  28. Table.api.bindevent(table);
  29. //total_num
  30. },
  31. api: {
  32. bindevent: function () {
  33. Form.api.bindevent($("form[role=form]"));
  34. }
  35. }
  36. };
  37. setTimeout(getTotalNum, 500);
  38. return Controller;
  39. });
  40. function getTotalNum(){
  41. $.post("product/orders/getTotalNum",{'product_id':Config.ids},
  42. function (data) {
  43. $("#total_num").text(data.totalNum);
  44. })
  45. }