123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170 |
- define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
- var Controller = {
- index: function () {
- // 初始化表格参数
- Table.api.init({
- extend: {
- index_url: 'commission/order/index' + location.search,
- add_url: '',
- edit_url: 'commission/order/edit',
- del_url: 'commission/order/del',
- multi_url: 'commission/order/multi',
- import_url: 'commission/order/import',
- table: 'commission_order',
- }
- });
- var table = $("#table");
- // 初始化表格
- table.bootstrapTable({
- url: $.fn.bootstrapTable.defaults.extend.index_url,
- pk: 'id',
- sortName: 'id',
- columns: [
- [
- {checkbox: true},
- {field: 'id', title: __('ID'), width: 60},
- {field: 'order.order_sn', title: __('订单号'), operate: 'LIKE', formatter: function(value, row, index) {
- if (row.order && row.order.order_sn) {
- return '<a href="javascript:;" data-order-id="' + row.order_id + '" class="searchit order-detail">' + row.order.order_sn + '</a>';
- }
- return '-';
- }},
- {field: 'order_item.goods_title', title: __('商品名称'), operate: 'LIKE', formatter: function(value, row, index) {
- if (row.order_item && row.order_item.goods_title) {
- return '<a href="javascript:;" data-goods-id="' + row.order_item.goods_id + '" class="searchit goods-detail">' + row.order_item.goods_title + '</a>';
- }
- return '-';
- }},
- {field: 'buyer.nickname', title: __('下单用户'), operate: 'LIKE'},
- {field: 'buyer.mobile', title: __('手机号'), operate: 'LIKE'},
- {field: 'agent.nickname', title: __('推广分销商'), operate: 'LIKE'},
- {field: 'agent.mobile', title: __('推广手机号'), operate: 'LIKE'},
- {field: 'amount', title: __('结算金额'), operate: 'BETWEEN'},
- {field: 'commission_order_status', title: __('业绩状态'), searchList: {
- "-2": __('已扣除'),
- "-1": __('已取消'),
- "0": __('不计入'),
- "1": __('已计入')
- }, formatter: function(value, row, index) {
- var statusMap = {
- '-2': {text: '已扣除', color: 'danger'},
- '-1': {text: '已取消', color: 'warning'},
- '0': {text: '不计入', color: 'info'},
- '1': {text: '已计入', color: 'success'}
- };
- var status = statusMap[value] || {text: value, color: 'default'};
- return '<span class="label label-' + status.color + '">' + status.text + '</span>';
- }},
- {field: 'commission_reward_status', title: __('佣金状态'), searchList: {
- "-2": __('已退回'),
- "-1": __('已取消'),
- "0": __('未结算'),
- "1": __('已结算')
- }, formatter: function(value, row, index) {
- var statusMap = {
- '-2': {text: '已退回', color: 'danger'},
- '-1': {text: '已取消', color: 'warning'},
- '0': {text: '未结算', color: 'info'},
- '1': {text: '已结算', color: 'success'}
- };
- var status = statusMap[value] || {text: value, color: 'default'};
- return '<span class="label label-' + status.color + '">' + status.text + '</span>';
- }},
- {field: 'commission_time', title: __('结算时间'), operate: 'RANGE', addclass: 'datetimerange', autocomplete: false, formatter: Table.api.formatter.datetime},
- {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate,
- buttons: [
- {
- name: 'confirm',
- text: __('结算'),
- title: __('结算佣金'),
- classname: 'btn btn-xs btn-success',
- icon: 'fa fa-check',
- visible: function (row) {
- return row.commission_reward_status == 0;
- },
- click: function (data) {
- Layer.confirm('确认结算此订单的佣金?', function(index) {
- Fast.api.ajax({
- url: 'commission/order/confirm',
- data: {commission_order_id: data.id}
- }, function(data, ret) {
- table.bootstrapTable('refresh');
- Layer.close(index);
- });
- });
- }
- },
- {
- name: 'cancel',
- text: __('取消'),
- title: __('取消佣金'),
- classname: 'btn btn-xs btn-warning',
- icon: 'fa fa-times',
- visible: function (row) {
- return row.commission_reward_status == 0;
- },
- click: function (data) {
- Layer.confirm('确认取消此订单的佣金?', function(index) {
- Fast.api.ajax({
- url: 'commission/order/cancel',
- data: {commission_order_id: data.id}
- }, function(data, ret) {
- table.bootstrapTable('refresh');
- Layer.close(index);
- });
- });
- }
- },
- {
- name: 'back',
- text: __('退回'),
- title: __('退回佣金'),
- classname: 'btn btn-xs btn-danger',
- icon: 'fa fa-undo',
- visible: function (row) {
- return row.commission_reward_status == 1;
- },
- click: function (data) {
- Layer.confirm('确认退回此订单的佣金?', function(index) {
- Fast.api.ajax({
- url: 'commission/order/back',
- data: {commission_order_id: data.id, deduct_order_money: 1}
- }, function(data, ret) {
- table.bootstrapTable('refresh');
- Layer.close(index);
- });
- });
- }
- }
- ],
- formatter: Table.api.formatter.operate}
- ]
- ]
- });
- // 为表格绑定事件
- Table.api.bindevent(table);
- // 绑定订单详情点击事件
- $(document).on('click', '.order-detail', function() {
- var orderId = $(this).data('order-id');
- Fast.api.open('order/order/detail?id=' + orderId, '订单详情');
- });
- // 绑定商品详情点击事件
- $(document).on('click', '.goods-detail', function() {
- var goodsId = $(this).data('goods-id');
- Fast.api.open('goods/goods/detail?id=' + goodsId, '商品详情');
- });
- },
- api: {
- bindevent: function () {
- Form.api.bindevent($("form[role=form]"));
- }
- }
- };
- return Controller;
- });
|