goods.js 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. define(["jquery", "easy-admin"], function ($, ea) {
  2. var init = {
  3. table_elem: '#currentTable',
  4. table_render_id: 'currentTableRenderId',
  5. index_url: 'mall.goods/index',
  6. add_url: 'mall.goods/add',
  7. edit_url: 'mall.goods/edit',
  8. copy_url: 'mall.goods/copy',
  9. delete_url: 'mall.goods/delete',
  10. export_url: 'mall.goods/export',
  11. modify_url: 'mall.goods/modify',
  12. stock_url: 'mall.goods/stock',
  13. };
  14. var Controller = {
  15. index: function () {
  16. ea.table.render({
  17. init: init,
  18. toolbar: ['refresh',
  19. [{
  20. text: '添加',
  21. url: init.add_url,
  22. method: 'open',
  23. auth: 'add',
  24. class: 'layui-btn layui-btn-normal layui-btn-sm',
  25. icon: 'fa fa-plus ',
  26. extend: 'data-full="true"',
  27. }],
  28. 'export'],
  29. cols: [[
  30. {type: "checkbox"},
  31. {field: 'goods_sn', width: 140, title: '商品编号'},
  32. {field: 'goods_type', minWidth: 160, title: '商品类型',selectList: {1: '买商品送积分', 2: '积分兑换', 3:'获得任务包兑换券', 4:'提货券', 5:'星钻兑换'},},
  33. {field: 'cate.name', minWidth: 80, title: '商品分类'},
  34. {
  35. field: 'goods_name', minWidth: 250, title: '商品名称', templet: function (d) {
  36. return `<div><div style="width: 20%;float: left;margin-right: 8px;"><img src="${QINIU_DOMIAN}${d.goods_img}" alt="" style="width: 50px;height: 50px"></div>
  37. <div style="width: 80%;text-align: left"><span>${d.goods_name}</span></div></div>`
  38. }
  39. },
  40. {field: 'price', minWidth: 80, title: '销售价'},
  41. {field: 'rebate_score', minWidth: 80, title: '返回积分', search: false},
  42. {field: 'cost_price', minWidth: 80, title: '成本价', search: false},
  43. {field: 'sales_volume', minWidth: 80, title: '虚拟销量', search: false},
  44. {field: 'real_sales_volume', minWidth: 80, title: '真实销量', search: false},
  45. {field: 'supplier.name', minWidth: 80, title: '供应商'},
  46. {field: 'supplier_code', minWidth: 80, title: '供应商编码', search: true},
  47. {field: 'real_sales_volume', minWidth: 80, title: '销量', search: true},
  48. {field: 'real_sales_volume', minWidth: 80, title: '销量', search: true},
  49. {
  50. field: 'on_sale',
  51. title: '是否上架',
  52. width: 100,
  53. selectList: {1: '已上架', 0: '已下架'},
  54. templet: ea.table.switch
  55. },
  56. {
  57. width: 250,
  58. title: '操作',
  59. templet: ea.table.tool,
  60. fixed: 'right',
  61. operat: [
  62. [
  63. {
  64. text: '编辑',
  65. url: init.edit_url,
  66. method: 'open',
  67. auth: 'edit',
  68. class: 'layui-btn layui-btn-xs layui-btn-success',
  69. extend: 'data-full="true"',
  70. },
  71. {
  72. text: '复制',
  73. url: init.copy_url,
  74. method: 'open',
  75. auth: 'copy',
  76. class: 'layui-btn layui-btn-xs layui-btn-warm',
  77. extend: 'data-full="true"',
  78. },
  79. {
  80. text: '入库',
  81. url: init.stock_url,
  82. method: 'open',
  83. auth: 'stock',
  84. class: 'layui-btn layui-btn-xs layui-btn-normal',
  85. }]]
  86. }
  87. ]],
  88. done: function (res, curr, count) {
  89. $(".layui-table-main tr").each(function (index, val) {
  90. $($(".layui-table-fixed .layui-table-body tbody tr")[index]).height($(val).height());
  91. });
  92. $(".layui-table-header").eq(1).find("tr").eq(0).height($(".layui-table-header").eq(0).find("tr").eq(0).height());
  93. }
  94. });
  95. ea.listen();
  96. },
  97. add: function () {
  98. ea.listen();
  99. },
  100. edit: function () {
  101. ea.listen();
  102. },
  103. copy: function () {
  104. ea.listen();
  105. },
  106. stock: function () {
  107. ea.listen();
  108. },
  109. };
  110. return Controller;
  111. });