| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117 |
- define(["jquery", "easy-admin"], function ($, ea) {
- var init = {
- table_elem: '#currentTable',
- table_render_id: 'currentTableRenderId',
- index_url: 'mall.goods/index',
- add_url: 'mall.goods/add',
- edit_url: 'mall.goods/edit',
- copy_url: 'mall.goods/copy',
- delete_url: 'mall.goods/delete',
- export_url: 'mall.goods/export',
- modify_url: 'mall.goods/modify',
- stock_url: 'mall.goods/stock',
- };
- var Controller = {
- index: function () {
- ea.table.render({
- init: init,
- toolbar: ['refresh',
- [{
- text: '添加',
- url: init.add_url,
- method: 'open',
- auth: 'add',
- class: 'layui-btn layui-btn-normal layui-btn-sm',
- icon: 'fa fa-plus ',
- extend: 'data-full="true"',
- }],
- 'export'],
- cols: [[
- {type: "checkbox"},
- {field: 'goods_sn', width: 140, title: '商品编号'},
- {field: 'goods_type', minWidth: 160, title: '商品类型',selectList: {1: '买商品送积分', 2: '积分兑换', 3:'获得任务包兑换券', 4:'提货券', 5:'星钻兑换'},},
- {field: 'cate.name', minWidth: 80, title: '商品分类'},
- {
- field: 'goods_name', minWidth: 250, title: '商品名称', templet: function (d) {
- 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>
- <div style="width: 80%;text-align: left"><span>${d.goods_name}</span></div></div>`
- }
- },
- {field: 'price', minWidth: 80, title: '销售价'},
- {field: 'rebate_score', minWidth: 80, title: '返回积分', search: false},
- {field: 'cost_price', minWidth: 80, title: '成本价', search: false},
- {field: 'sales_volume', minWidth: 80, title: '虚拟销量', search: false},
- {field: 'real_sales_volume', minWidth: 80, title: '真实销量', search: false},
- {field: 'supplier.name', minWidth: 80, title: '供应商'},
- {field: 'supplier_code', minWidth: 80, title: '供应商编码', search: true},
- {field: 'real_sales_volume', minWidth: 80, title: '销量', search: true},
- {field: 'real_sales_volume', minWidth: 80, title: '销量', search: true},
- {
- field: 'on_sale',
- title: '是否上架',
- width: 100,
- selectList: {1: '已上架', 0: '已下架'},
- templet: ea.table.switch
- },
- {
- width: 250,
- title: '操作',
- templet: ea.table.tool,
- fixed: 'right',
- operat: [
- [
- {
- text: '编辑',
- url: init.edit_url,
- method: 'open',
- auth: 'edit',
- class: 'layui-btn layui-btn-xs layui-btn-success',
- extend: 'data-full="true"',
- },
- {
- text: '复制',
- url: init.copy_url,
- method: 'open',
- auth: 'copy',
- class: 'layui-btn layui-btn-xs layui-btn-warm',
- extend: 'data-full="true"',
- },
- {
- text: '入库',
- url: init.stock_url,
- method: 'open',
- auth: 'stock',
- class: 'layui-btn layui-btn-xs layui-btn-normal',
- }]]
- }
- ]],
- done: function (res, curr, count) {
- $(".layui-table-main tr").each(function (index, val) {
- $($(".layui-table-fixed .layui-table-body tbody tr")[index]).height($(val).height());
- });
- $(".layui-table-header").eq(1).find("tr").eq(0).height($(".layui-table-header").eq(0).find("tr").eq(0).height());
- }
- });
- ea.listen();
- },
- add: function () {
- ea.listen();
- },
- edit: function () {
- ea.listen();
- },
- copy: function () {
- ea.listen();
- },
- stock: function () {
- ea.listen();
- },
- };
- return Controller;
- });
|