123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 |
- define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
- var Controller = {
- index: function () {
- // 初始化表格参数
- Table.api.init({
- extend: {
- index_url: 'commission/goods/index' + location.search,
- add_url: '',
- edit_url: 'commission/goods/edit',
- del_url: 'commission/goods/del',
- multi_url: 'commission/goods/multi',
- import_url: 'commission/goods/import',
- table: 'commission_goods',
- }
- });
- var table = $("#table");
- // 初始化表格
- table.bootstrapTable({
- url: $.fn.bootstrapTable.defaults.extend.index_url,
- pk: 'goods_id',
- sortName: 'goods_id',
- columns: [
- [
- {checkbox: true},
- {field: 'goods_id', title: __('商品ID'), width: 80},
- {field: 'title', title: __('商品名称'), operate: 'LIKE'},
- {field: 'image', title: __('商品图片'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
- {field: 'price', title: __('商品价格'), operate: 'BETWEEN'},
- {field: 'commission_goods.status', title: __('分销状态'), searchList: {
- "0": __('不参与分销'),
- "1": __('参与分销')
- }, formatter: function(value, row, index) {
- var statusMap = {
- '0': {text: '不参与分销', color: 'danger'},
- '1': {text: '参与分销', color: 'success'}
- };
- var status = statusMap[value] || {text: '不参与分销', color: 'danger'};
- return '<span class="label label-' + status.color + '">' + status.text + '</span>';
- }},
- {field: 'commission_goods.self_rules', title: __('独立设置'), formatter: function(value, row, index) {
- var selfRulesMap = {
- '0': {text: '否', color: 'info'},
- '1': {text: '是', color: 'success'}
- };
- var selfRules = selfRulesMap[value] || {text: '否', color: 'info'};
- return '<span class="label label-' + selfRules.color + '">' + selfRules.text + '</span>';
- }},
- {field: 'commission_goods.commission_order_status', title: __('是否计入业绩'), formatter: function(value, row, index) {
- var orderStatusMap = {
- '0': {text: '否', color: 'danger'},
- '1': {text: '是', color: 'success'}
- };
- var orderStatus = orderStatusMap[value] || {text: '是', color: 'success'};
- return '<span class="label label-' + orderStatus.color + '">' + orderStatus.text + '</span>';
- }},
- {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate,
- buttons: [
- {
- name: 'detail',
- text: __('详情'),
- title: __('商品详情'),
- classname: 'btn btn-xs btn-primary btn-dialog',
- icon: 'fa fa-list',
- url: 'commission/goods/detail',
- callback: function (data) {
- table.bootstrapTable('refresh');
- }
- },
- {
- name: 'edit',
- text: __('设置佣金'),
- title: __('设置佣金'),
- classname: 'btn btn-xs btn-success btn-editone',
- icon: 'fa fa-edit',
- url: 'commission/goods/edit',
- callback: function (data) {
- table.bootstrapTable('refresh');
- }
- }
- ],
- formatter: Table.api.formatter.operate}
- ]
- ]
- });
- // 为表格绑定事件
- Table.api.bindevent(table);
- },
- detail: function () {
- Controller.api.bindevent();
- },
- edit: function () {
- Controller.api.bindevent();
- },
- api: {
- bindevent: function () {
- Form.api.bindevent($("form[role=form]"));
-
- // 绑定独立设置变化事件
- $(document).on('change', 'input[name="row[self_rules]"]', function() {
- var value = $(this).val();
- var commissionConfigContainer = $('.commission-config-container');
- if (value == '1') {
- commissionConfigContainer.show();
- } else {
- commissionConfigContainer.hide();
- }
- });
- }
- }
- };
- return Controller;
- });
|