号码管理
This commit is contained in:
@@ -0,0 +1,206 @@
|
||||
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
|
||||
|
||||
var Controller = {
|
||||
index: function () {
|
||||
Table.api.init({
|
||||
extend: {
|
||||
index_url: 'split.number/index' + location.search,
|
||||
add_url: 'split.number/add',
|
||||
edit_url: 'split.number/edit',
|
||||
del_url: 'split.number/del',
|
||||
multi_url: 'split.number/multi',
|
||||
table: 'split_number',
|
||||
}
|
||||
});
|
||||
|
||||
var table = $("#table");
|
||||
|
||||
table.bootstrapTable({
|
||||
url: $.fn.bootstrapTable.defaults.extend.index_url,
|
||||
pk: 'id',
|
||||
sortName: 'id',
|
||||
sortOrder: 'desc',
|
||||
fixedColumns: true,
|
||||
fixedRightNumber: 1,
|
||||
columns: [
|
||||
[
|
||||
{checkbox: true},
|
||||
{field: 'id', title: __('Id'), sortable: true},
|
||||
{
|
||||
field: 'link_url_text',
|
||||
title: __('Link_url'),
|
||||
operate: false,
|
||||
formatter: Table.api.formatter.content
|
||||
},
|
||||
{field: 'ticket_name', title: __('Ticket_name'), operate: 'LIKE'},
|
||||
{field: 'number', title: __('Number'), operate: 'LIKE'},
|
||||
{
|
||||
field: 'number_type',
|
||||
title: __('Number_type'),
|
||||
searchList: Config.numberTypeList,
|
||||
formatter: Table.api.formatter.normal
|
||||
},
|
||||
{field: 'visit_count', title: __('Visit_count'), operate: false, sortable: true},
|
||||
{field: 'inbound_count', title: __('Inbound_count'), operate: false, sortable: true},
|
||||
{
|
||||
field: 'status',
|
||||
title: __('Status'),
|
||||
searchList: Config.statusList,
|
||||
formatter: Table.api.formatter.toggle,
|
||||
yes: 'normal',
|
||||
no: 'hidden'
|
||||
},
|
||||
{
|
||||
field: 'createtime',
|
||||
title: __('Createtime'),
|
||||
operate: 'RANGE',
|
||||
addclass: 'datetimerange',
|
||||
autocomplete: false,
|
||||
formatter: Table.api.formatter.datetime,
|
||||
sortable: true
|
||||
},
|
||||
{
|
||||
field: 'operate',
|
||||
title: __('Operate'),
|
||||
table: table,
|
||||
events: Table.api.events.operate,
|
||||
formatter: Table.api.formatter.operate
|
||||
}
|
||||
]
|
||||
]
|
||||
});
|
||||
|
||||
table.on('check.bs.table uncheck.bs.table check-all.bs.table uncheck-all.bs.table', function () {
|
||||
var ids = Table.api.selectedids(table);
|
||||
$('.btn-batch-update-status').toggleClass('btn-disabled disabled', ids.length === 0);
|
||||
});
|
||||
|
||||
$('.btn-batch-update-status').on('click', function (e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
if ($(this).hasClass('disabled')) {
|
||||
return false;
|
||||
}
|
||||
var ids = Table.api.selectedids(table);
|
||||
if (!ids.length) {
|
||||
Toastr.warning(__('Please select at least one item'));
|
||||
return false;
|
||||
}
|
||||
Controller.api.openBatchUpdateModal(ids, table);
|
||||
});
|
||||
|
||||
Table.api.bindevent(table);
|
||||
},
|
||||
add: function () {
|
||||
Controller.api.bindevent();
|
||||
},
|
||||
edit: function () {
|
||||
Controller.api.bindevent();
|
||||
},
|
||||
api: {
|
||||
bindevent: function () {
|
||||
Form.api.bindevent($('form[role=form]'));
|
||||
Controller.api.fixSelectPlaceholder();
|
||||
Controller.api.bindNumberTypeToggle();
|
||||
},
|
||||
fixSelectPlaceholder: function () {
|
||||
var text = __('Please select');
|
||||
if (!text || text === 'Please select' || text === 'Please Select') {
|
||||
text = '请选择';
|
||||
}
|
||||
$('#c-split_link_id').each(function () {
|
||||
var $el = $(this);
|
||||
$el.attr({'data-none-selected-text': text, 'title': text});
|
||||
$el.find('option[value=""]').first().text(text);
|
||||
if ($el.data('selectpicker')) {
|
||||
$el.selectpicker('render');
|
||||
}
|
||||
});
|
||||
},
|
||||
bindNumberTypeToggle: function () {
|
||||
var $type = $('#c-number_type');
|
||||
var $wrap = $('.split-number-type-custom');
|
||||
var $custom = $('#c-number_type_custom');
|
||||
if (!$type.length) {
|
||||
return;
|
||||
}
|
||||
var toggle = function () {
|
||||
var val = $type.val();
|
||||
if (val === 'custom') {
|
||||
$wrap.removeClass('hide');
|
||||
$custom.attr('data-rule', 'required');
|
||||
} else {
|
||||
$wrap.addClass('hide');
|
||||
$custom.removeAttr('data-rule');
|
||||
if (!$wrap.closest('form').attr('id') || $('#edit-form').length === 0) {
|
||||
$custom.val('');
|
||||
}
|
||||
}
|
||||
};
|
||||
$type.on('changed.bs.select change', toggle);
|
||||
toggle();
|
||||
},
|
||||
openBatchUpdateModal: function (ids, table) {
|
||||
var statusHtml = '';
|
||||
$.each(Config.statusList || {}, function (key, label) {
|
||||
var checked = key === 'normal' ? ' checked' : '';
|
||||
statusHtml += '<label class="radio-inline"><input type="radio" name="batch_status" value="' + key + '"' + checked + '> ' + label + '</label>';
|
||||
});
|
||||
var manualHtml = '';
|
||||
$.each(Config.manualManageList || {}, function (key, label) {
|
||||
var checked = key === '0' ? ' checked' : '';
|
||||
manualHtml += '<label class="radio-inline"><input type="radio" name="batch_manual_manage" value="' + key + '"' + checked + '> ' + label + '</label>';
|
||||
});
|
||||
var html = [
|
||||
'<div class="split-batch-update-modal" style="padding:18px 22px;">',
|
||||
' <div class="form-group">',
|
||||
' <label class="control-label">' + __('Batch selected count') + '</label>',
|
||||
' <p class="form-control-static" style="font-size:18px;font-weight:600;margin:0;">' + ids.length + ' ' + __('Unit count') + '</p>',
|
||||
' </div>',
|
||||
' <div class="form-group">',
|
||||
' <label class="control-label">' + __('Status') + '</label>',
|
||||
' <div>' + statusHtml + '</div>',
|
||||
' </div>',
|
||||
' <div class="form-group" style="margin-bottom:0;">',
|
||||
' <label class="control-label">' + __('Manual_manage') + '</label>',
|
||||
' <div>' + manualHtml + '</div>',
|
||||
' </div>',
|
||||
'</div>'
|
||||
].join('');
|
||||
|
||||
Layer.open({
|
||||
type: 1,
|
||||
title: __('Batch update title'),
|
||||
area: ['420px', 'auto'],
|
||||
shadeClose: false,
|
||||
content: html,
|
||||
btn: [__('OK'), __('Cancel')],
|
||||
yes: function (index, layero) {
|
||||
var status = layero.find('input[name="batch_status"]:checked').val();
|
||||
var manualManage = layero.find('input[name="batch_manual_manage"]:checked').val();
|
||||
if (typeof status === 'undefined' || typeof manualManage === 'undefined') {
|
||||
Toastr.error(__('Invalid parameters'));
|
||||
return false;
|
||||
}
|
||||
Fast.api.ajax({
|
||||
url: 'split.number/batchupdate',
|
||||
type: 'post',
|
||||
data: {
|
||||
ids: ids.join(','),
|
||||
status: status,
|
||||
manual_manage: manualManage
|
||||
}
|
||||
}, function () {
|
||||
Layer.close(index);
|
||||
table.bootstrapTable('refresh');
|
||||
$('.btn-batch-update-status').addClass('btn-disabled disabled');
|
||||
Toastr.success(__('Batch update success'));
|
||||
});
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
return Controller;
|
||||
});
|
||||
Reference in New Issue
Block a user