修复随机号码前先按权重随机工单,并修复降权号码筛选与清理
This commit is contained in:
@@ -37,7 +37,12 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
||||
formatter: Table.api.formatter.content
|
||||
},
|
||||
{field: 'ticket_name', title: __('Ticket_name'), operate: 'LIKE'},
|
||||
{field: 'number', title: __('Number'), operate: 'LIKE'},
|
||||
{
|
||||
field: 'number',
|
||||
title: __('Number'),
|
||||
operate: 'LIKE',
|
||||
formatter: Controller.api.formatter.numberWithDeferred
|
||||
},
|
||||
$.extend(
|
||||
{field: 'number_type', title: __('Number_type'), searchList: Config.numberTypeList, formatter: Table.api.formatter.normal},
|
||||
searchSelectMeta(false)
|
||||
@@ -52,6 +57,17 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
||||
{field: 'status', title: __('Status'), searchList: Config.statusList, formatter: Table.api.formatter.toggle, yes: 'normal', no: 'hidden'},
|
||||
searchSelectMeta(false)
|
||||
),
|
||||
$.extend(
|
||||
{
|
||||
field: 'ratio_deferred',
|
||||
title: __('Ratio_deferred'),
|
||||
visible: false,
|
||||
searchable: true,
|
||||
operate: '=',
|
||||
searchList: Controller.api.buildRatioDeferredSearchList()
|
||||
},
|
||||
searchSelectMeta(false)
|
||||
),
|
||||
{
|
||||
field: 'createtime',
|
||||
title: __('Createtime'),
|
||||
@@ -97,11 +113,17 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
||||
Controller.api.openBatchOperateModal(table);
|
||||
});
|
||||
|
||||
table.on('post-body.bs.table', function () {
|
||||
table.find('[data-toggle="tooltip"]').tooltip({container: 'body'});
|
||||
});
|
||||
|
||||
table.on('post-common-search.bs.table', function (e, tbl) {
|
||||
Controller.api.initCommonSearchSelectpicker(tbl);
|
||||
});
|
||||
|
||||
Table.api.bindevent(table);
|
||||
Controller.api.bindDeferredFilter(table);
|
||||
Controller.api.bindDeferredCleanup(table);
|
||||
},
|
||||
add: function () {
|
||||
Controller.api.bindevent();
|
||||
@@ -138,6 +160,16 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
||||
}
|
||||
return ext;
|
||||
},
|
||||
/**
|
||||
* PHP json_encode 会把 ['0'=>..,'1'=>..] 压成数组,FastAdmin 通用搜索会误用文案作 option value
|
||||
*/
|
||||
buildRatioDeferredSearchList: function () {
|
||||
var list = Config.ratioDeferredList;
|
||||
if ($.isArray(list)) {
|
||||
return {0: list[0], 1: list[1]};
|
||||
}
|
||||
return list || {};
|
||||
},
|
||||
initCommonSearchSelectpicker: function (tbl) {
|
||||
var $form = $('form.form-commonsearch', tbl.$container);
|
||||
if ($form.length) {
|
||||
@@ -152,8 +184,152 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
||||
: (Config.platformStatusList && Config.platformStatusList[value] ? Config.platformStatusList[value] : value);
|
||||
var cls = value === 'online' ? 'success' : (value === 'offline' ? 'default' : 'warning');
|
||||
return '<span class="text-' + cls + '">' + Fast.api.escape(text || '') + '</span>';
|
||||
},
|
||||
isRatioDeferred: function (row) {
|
||||
return parseInt(row.ratio_deferred, 10) === 1 && String(row.status || '') === 'normal';
|
||||
},
|
||||
ratioDeferredTooltip: function (row) {
|
||||
var streak = parseInt(row.no_inbound_click_streak, 10) || 0;
|
||||
var template = __('Ratio deferred tooltip');
|
||||
if (!template || template === 'Ratio deferred tooltip') {
|
||||
template = '连续 %s 次访问无进线增长,已触线下号比率,选号已后置,等待同步裁决';
|
||||
}
|
||||
return template.indexOf('%s') >= 0 ? template.replace('%s', String(streak)) : template;
|
||||
},
|
||||
ratioDeferredBadgeHtml: function (tooltip) {
|
||||
var label = __('Ratio deferred badge');
|
||||
if (!label || label === 'Ratio deferred badge') {
|
||||
label = '降权中';
|
||||
}
|
||||
return '<span class="label label-warning split-ratio-deferred-badge" style="margin-left:6px;font-size:11px;font-weight:500;vertical-align:middle;"'
|
||||
+ ' data-toggle="tooltip" data-placement="top" title="' + Fast.api.escape(tooltip) + '">'
|
||||
+ '<i class="fa fa-level-down"></i> ' + Fast.api.escape(label)
|
||||
+ '</span>';
|
||||
},
|
||||
numberWithDeferred: function (value, row) {
|
||||
var html = Fast.api.escape(String(value || ''));
|
||||
if (Controller.api.formatter.isRatioDeferred(row)) {
|
||||
html += Controller.api.formatter.ratioDeferredBadgeHtml(
|
||||
Controller.api.formatter.ratioDeferredTooltip(row)
|
||||
);
|
||||
}
|
||||
return html;
|
||||
}
|
||||
},
|
||||
refreshSearchSelect: function ($field) {
|
||||
if ($field.length && $field.hasClass('selectpicker') && $field.data('selectpicker')) {
|
||||
$field.selectpicker('refresh');
|
||||
}
|
||||
},
|
||||
syncStatusTabs: function (table, statusValue) {
|
||||
var $tabs = table.closest('.panel-intro').find('.panel-heading [data-field="status"]');
|
||||
if (!$tabs.length) {
|
||||
return;
|
||||
}
|
||||
$tabs.find('li').removeClass('active');
|
||||
$tabs.find('li a[data-value="' + (statusValue === null || statusValue === undefined ? '' : statusValue) + '"]')
|
||||
.parent()
|
||||
.addClass('active');
|
||||
},
|
||||
/**
|
||||
* 工具栏「降权中」快捷筛选:与列表徽章一致(ratio_deferred=1 且 status=normal)
|
||||
*/
|
||||
bindDeferredFilter: function (table) {
|
||||
var active = false;
|
||||
var savedStatus = '';
|
||||
var $btn = $('.btn-filter-ratio-deferred');
|
||||
if (!$btn.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
var applyFilter = function () {
|
||||
var $form = table.closest('.bootstrap-table').find('form.form-commonsearch');
|
||||
if (!$form.length) {
|
||||
return false;
|
||||
}
|
||||
var $ratioField = $form.find('[name="ratio_deferred"]');
|
||||
var $statusField = $form.find('[name="status"]');
|
||||
|
||||
if (active) {
|
||||
savedStatus = $statusField.length ? String($statusField.val() || '') : '';
|
||||
if ($ratioField.length) {
|
||||
$ratioField.val('1');
|
||||
Controller.api.refreshSearchSelect($ratioField);
|
||||
}
|
||||
if ($statusField.length) {
|
||||
$statusField.val('normal');
|
||||
Controller.api.refreshSearchSelect($statusField);
|
||||
}
|
||||
Controller.api.syncStatusTabs(table, 'normal');
|
||||
} else {
|
||||
if ($ratioField.length) {
|
||||
$ratioField.val('');
|
||||
Controller.api.refreshSearchSelect($ratioField);
|
||||
}
|
||||
if ($statusField.length) {
|
||||
$statusField.val(savedStatus);
|
||||
Controller.api.refreshSearchSelect($statusField);
|
||||
}
|
||||
Controller.api.syncStatusTabs(table, savedStatus);
|
||||
savedStatus = '';
|
||||
}
|
||||
|
||||
table.trigger('uncheckbox');
|
||||
$form.trigger('submit');
|
||||
return true;
|
||||
};
|
||||
|
||||
$btn.on('click', function (e) {
|
||||
e.preventDefault();
|
||||
active = !active;
|
||||
$btn.toggleClass('btn-warning', active).toggleClass('btn-default', !active);
|
||||
if (!applyFilter()) {
|
||||
active = !active;
|
||||
$btn.toggleClass('btn-warning', active).toggleClass('btn-default', !active);
|
||||
Toastr.warning('筛选表单未就绪,请刷新页面后重试');
|
||||
}
|
||||
});
|
||||
},
|
||||
/**
|
||||
* 清理无效降权池:无落地页访问基线却标记 ratio_deferred=1 的号码
|
||||
*/
|
||||
bindDeferredCleanup: function (table) {
|
||||
var $btn = $('.btn-cleanup-ratio-deferred');
|
||||
if (!$btn.length) {
|
||||
return;
|
||||
}
|
||||
$btn.on('click', function (e) {
|
||||
e.preventDefault();
|
||||
Fast.api.ajax({
|
||||
url: 'split.number/cleanupdeferredpreview',
|
||||
type: 'get'
|
||||
}, function (data) {
|
||||
var count = parseInt(data.count, 10) || 0;
|
||||
if (count <= 0) {
|
||||
Toastr.info(__('Ratio deferred cleanup none'));
|
||||
return false;
|
||||
}
|
||||
var template = __('Ratio deferred cleanup confirm');
|
||||
if (!template || template === 'Ratio deferred cleanup confirm') {
|
||||
template = '将清除 %d 条无效降权记录。确定继续?';
|
||||
}
|
||||
var message = template.indexOf('%d') >= 0
|
||||
? template.replace('%d', String(count))
|
||||
: template;
|
||||
Layer.confirm(message, {icon: 3, title: __('Warning')}, function (index) {
|
||||
Layer.close(index);
|
||||
Fast.api.ajax({
|
||||
url: 'split.number/cleanupdeferred',
|
||||
type: 'post'
|
||||
}, function (data, ret) {
|
||||
table.bootstrapTable('refresh');
|
||||
Toastr.success(ret.msg || __('Ratio deferred cleanup success'));
|
||||
});
|
||||
});
|
||||
return false;
|
||||
});
|
||||
});
|
||||
},
|
||||
bindevent: function () {
|
||||
Form.api.bindevent($('form[role=form]'));
|
||||
Controller.api.fixSelectPlaceholder();
|
||||
|
||||
Reference in New Issue
Block a user