| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176 |
- define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
- var Controller = {
- index: function () {
- // 初始化表格参数配置
- Table.api.init({
- extend: {
- index_url: 'channel/index' + location.search,
- add_url: 'channel/add',
- edit_url: 'channel/edit',
- del_url: 'channel/del',
- multi_url: 'channel/multi',
- import_url: 'channel/import',
- table: 'channel',
- }
- });
- var table = $("#table");
- // 初始化表格
- table.bootstrapTable({
- url: $.fn.bootstrapTable.defaults.extend.index_url,
- pk: 'id',
- sortName: 'id',
- fixedColumns: true,
- fixedRightNumber: 1,
- columns: [
- [
- {checkbox: true},
- {field: 'id', title: __('Id')},
- {field: 'promotioner_name', title: "推广团队/人", operate: 'LIKE'},
- {field: 'promotioner_mobile', title: "联系方式", operate: 'LIKE'},
- {
- field: 'starttime',
- title: "开始时间",
- operate: 'RANGE',
- addclass: 'datetimerange',
- autocomplete: false,
- formatter: Table.api.formatter.datetime
- },
- {
- field: 'endtime',
- title: "结束时间",
- operate: 'RANGE',
- addclass: 'datetimerange',
- autocomplete: false,
- formatter: Table.api.formatter.datetime
- },
- {field: 'city_name', title: __('City_name'), operate: 'LIKE'},
- {field: 'description', title: __('Description'), operate: 'LIKE'},
- {field: 'key', title: __('Key'), operate: 'LIKE'},
- {
- field: 'download_qrcode_image',
- title: "下载二维码",
- operate: false,
- events: Table.api.events.image,
- formatter: Table.api.formatter.image
- },
- {
- field: 'register_qrcode_image',
- title: '注册二维码',
- operate: false,
- events: Table.api.events.image,
- formatter: Table.api.formatter.image
- },
- {field: 'download_config', title: __('Download_config'), operate: 'BETWEEN'},
- {field: 'register_config', title: __('Register_config'), operate: 'BETWEEN'},
- {field: 'order_config', title: __('Order_config'), operate: 'BETWEEN'},
- {field: 'download_count', title: __('Download_count')},
- {field: 'register_count', title: __('Register_count')},
- {field: 'order_count', title: __('Order_count')},
- {
- field: 'updatetime',
- title: __('Updatetime'),
- operate: 'RANGE',
- addclass: 'datetimerange',
- autocomplete: false,
- formatter: Table.api.formatter.datetime
- },
- {
- field: 'city_code',
- title: __('区域'),
- searchList: Config.allow_areas,
- visible: false
- },
- {
- field: 'operate',
- title: __('Operate'),
- table: table,
- buttons: [
- {
- name: 'detail',
- text: '结算明细',
- title: '结算明细',
- icon: 'fa fa-list',
- classname: 'btn btn-xs btn-primary btn-dialog',
- url: 'channel/detail?id={id}'
- }
- ],
- events: Table.api.events.operate,
- formatter: Table.api.formatter.operate
- }
- ]
- ]
- });
- // 为表格绑定事件
- Table.api.bindevent(table);
- },
- add: function () {
- Controller.api.bindevent();
- },
- edit: function () {
- $(document).on("click", "#closing_btn", function () {
- var msg = [
- {
- key: "下载",
- config: $("#c-download_config").val() || 0,
- count: $("#c-download_count").val() || 0
- },
- {
- key: "注册",
- config: $("#c-register_config").val() || 0,
- count: $("#c-register_count").val() || 0
- },
- {
- key: "下单",
- config: $("#c-order_config").val() || 0,
- count: $("#c-order_count").val() || 0,
- },
- ];
- var total = msg.reduce(function (p, cur) {
- p += Number(cur.count) * Number(cur.config);
- return p;
- }, 0);
- var fmt = msg.map((item) => {
- return item.key + ":" + item.config + " * " + item.count + " = " + (Number(item.config) * Number(item.count));
- });
- fmt.push("总计: " + total);
- var id = $("#c-id").val();
- if (isNaN(Number(id))) {
- Layer.msg("id 错误");
- return;
- }
- Layer.confirm(fmt.join("<br />"),
- {icon: 3, title: __('Warning'), offset: 0, shadeClose: true},
- function (index) {
- Fast.api.ajax("channel/closing?id=" + id, function (data, ret) {
- $("#closing_btn").css("display: none");
- //成功的回调
- Layer.msg(ret.msg,function () {
- parent.layer.close(parent.layer.getFrameIndex(window.name));
- location.reload();
- });
- return false;
- }, function (data, ret) {
- console.log(ret);
- Layer.msg(ret.msg);
- return false;
- });
- });
- });
- Controller.api.bindevent();
- },
- api: {
- bindevent: function () {
- Form.api.bindevent($("form[role=form]"));
- }
- }
- };
- return Controller;
- });
|