添加whatshub工单
This commit is contained in:
Regular → Executable
+156
-20
@@ -14,6 +14,8 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
||||
});
|
||||
|
||||
var table = $("#table");
|
||||
var searchSelect = Controller.api.searchSelectColumn;
|
||||
var searchSelectMeta = Controller.api.searchSelectMeta;
|
||||
|
||||
table.bootstrapTable({
|
||||
url: $.fn.bootstrapTable.defaults.extend.index_url,
|
||||
@@ -22,9 +24,11 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
||||
sortOrder: 'desc',
|
||||
fixedColumns: true,
|
||||
fixedRightNumber: 1,
|
||||
searchFormVisible: true,
|
||||
columns: [
|
||||
[
|
||||
{checkbox: true},
|
||||
searchSelect('split_link_id', __('Link_url'), Config.splitLinkFilterList || {}, true),
|
||||
{field: 'id', title: __('Id'), sortable: true},
|
||||
{
|
||||
field: 'link_url_text',
|
||||
@@ -34,28 +38,20 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
||||
},
|
||||
{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
|
||||
},
|
||||
$.extend(
|
||||
{field: 'number_type', title: __('Number_type'), searchList: Config.numberTypeList, formatter: Table.api.formatter.normal},
|
||||
searchSelectMeta(false)
|
||||
),
|
||||
{field: 'visit_count', title: __('Visit_count'), operate: false, sortable: true},
|
||||
{field: 'inbound_count', title: __('Inbound_count'), operate: false, sortable: true},
|
||||
{
|
||||
field: 'platform_status',
|
||||
title: __('Platform_status'),
|
||||
searchList: Config.platformStatusList,
|
||||
formatter: Controller.api.formatter.platformStatus
|
||||
},
|
||||
{
|
||||
field: 'status',
|
||||
title: __('Status'),
|
||||
searchList: Config.statusList,
|
||||
formatter: Table.api.formatter.toggle,
|
||||
yes: 'normal',
|
||||
no: 'hidden'
|
||||
},
|
||||
$.extend(
|
||||
{field: 'platform_status', title: __('Platform_status'), searchList: Config.platformStatusList, formatter: Controller.api.formatter.platformStatus},
|
||||
searchSelectMeta(false)
|
||||
),
|
||||
$.extend(
|
||||
{field: 'status', title: __('Status'), searchList: Config.statusList, formatter: Table.api.formatter.toggle, yes: 'normal', no: 'hidden'},
|
||||
searchSelectMeta(false)
|
||||
),
|
||||
{
|
||||
field: 'createtime',
|
||||
title: __('Createtime'),
|
||||
@@ -95,6 +91,16 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
||||
Controller.api.openBatchUpdateModal(ids, table);
|
||||
});
|
||||
|
||||
$('.btn-batch-operate').on('click', function (e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
Controller.api.openBatchOperateModal(table);
|
||||
});
|
||||
|
||||
table.on('post-common-search.bs.table', function (e, tbl) {
|
||||
Controller.api.initCommonSearchSelectpicker(tbl);
|
||||
});
|
||||
|
||||
Table.api.bindevent(table);
|
||||
},
|
||||
add: function () {
|
||||
@@ -104,6 +110,41 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
||||
Controller.api.bindevent();
|
||||
},
|
||||
api: {
|
||||
searchSelectColumn: function (field, title, searchList, liveSearch) {
|
||||
return {
|
||||
field: field,
|
||||
title: title,
|
||||
visible: false,
|
||||
searchList: searchList || {},
|
||||
operate: '=',
|
||||
addclass: 'selectpicker',
|
||||
extend: Controller.api.searchSelectExtend(liveSearch !== false)
|
||||
};
|
||||
},
|
||||
searchSelectMeta: function (liveSearch) {
|
||||
return {
|
||||
addclass: 'selectpicker',
|
||||
extend: Controller.api.searchSelectExtend(liveSearch !== false)
|
||||
};
|
||||
},
|
||||
searchSelectExtend: function (liveSearch) {
|
||||
var text = __('Please select');
|
||||
if (!text || text === 'Please select' || text === 'Please Select') {
|
||||
text = '请选择';
|
||||
}
|
||||
var ext = 'data-none-selected-text="' + text + '" title="' + text + '"';
|
||||
if (liveSearch) {
|
||||
ext += ' data-live-search="true"';
|
||||
}
|
||||
return ext;
|
||||
},
|
||||
initCommonSearchSelectpicker: function (tbl) {
|
||||
var $form = $('form.form-commonsearch', tbl.$container);
|
||||
if ($form.length) {
|
||||
Form.events.selectpicker($form);
|
||||
}
|
||||
},
|
||||
|
||||
formatter: {
|
||||
platformStatus: function (value, row) {
|
||||
var text = row.platform_status_text != null && row.platform_status_text !== ''
|
||||
@@ -214,6 +255,101 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
||||
return false;
|
||||
}
|
||||
});
|
||||
},
|
||||
openBatchOperateModal: function (table) {
|
||||
var pleaseSelect = __('Please select');
|
||||
if (!pleaseSelect || pleaseSelect === 'Please select' || pleaseSelect === 'Please Select') {
|
||||
pleaseSelect = '请选择';
|
||||
}
|
||||
var linkOptions = ['<option value="">' + Fast.api.escape(pleaseSelect) + '</option>'];
|
||||
$.each(Config.splitLinkSelectList || {}, function (id, label) {
|
||||
linkOptions.push('<option value="' + Fast.api.escape(String(id)) + '">' + Fast.api.escape(String(label)) + '</option>');
|
||||
});
|
||||
var html = [
|
||||
'<div class="split-batch-operate-modal" style="padding:18px 22px;">',
|
||||
' <div class="form-group">',
|
||||
' <label class="control-label">' + __('Link_url') + '<span class="text-danger">*</span></label>',
|
||||
' <select id="batch-operate-split-link" class="form-control selectpicker" data-live-search="true" data-none-selected-text="' + pleaseSelect + '" title="' + pleaseSelect + '">',
|
||||
linkOptions.join(''),
|
||||
' </select>',
|
||||
' </div>',
|
||||
' <div class="form-group">',
|
||||
' <label class="control-label">' + __('Number') + '<span class="text-danger">*</span></label>',
|
||||
' <textarea id="batch-operate-numbers" class="form-control" rows="8" placeholder="' + Fast.api.escape(__('Numbers one per line')) + '"></textarea>',
|
||||
' </div>',
|
||||
' <div class="form-group">',
|
||||
' <label class="control-label">' + __('Batch operate action') + '<span class="text-danger">*</span></label>',
|
||||
' <select id="batch-operate-action" class="form-control selectpicker" data-none-selected-text="' + pleaseSelect + '" title="' + pleaseSelect + '">',
|
||||
' <option value="enable">' + Fast.api.escape(__('Batch operate enable')) + '</option>',
|
||||
' <option value="disable">' + Fast.api.escape(__('Batch operate disable')) + '</option>',
|
||||
' <option value="delete">' + Fast.api.escape(__('Batch operate delete')) + '</option>',
|
||||
' </select>',
|
||||
' </div>',
|
||||
' <div class="form-group" style="margin-bottom:0;text-align:right;">',
|
||||
' <button type="button" class="btn btn-primary btn-batch-operate-confirm">' + __('OK') + '</button> ',
|
||||
' <button type="button" class="btn btn-default btn-batch-operate-cancel">' + __('Cancel') + '</button>',
|
||||
' </div>',
|
||||
'</div>'
|
||||
].join('');
|
||||
|
||||
var layerIndex = Layer.open({
|
||||
type: 1,
|
||||
title: __('Batch operate title'),
|
||||
area: ['520px', 'auto'],
|
||||
shadeClose: false,
|
||||
content: html,
|
||||
success: function (layero, index) {
|
||||
Form.events.selectpicker(layero);
|
||||
layero.find('.btn-batch-operate-cancel').on('click', function () {
|
||||
Layer.close(index);
|
||||
});
|
||||
layero.find('.btn-batch-operate-confirm').on('click', function () {
|
||||
var splitLinkId = $.trim(layero.find('#batch-operate-split-link').val());
|
||||
var numbers = $.trim(layero.find('#batch-operate-numbers').val());
|
||||
var action = $.trim(layero.find('#batch-operate-action').val());
|
||||
|
||||
if (!splitLinkId) {
|
||||
Toastr.warning(__('Please select split link'));
|
||||
return false;
|
||||
}
|
||||
if (!numbers) {
|
||||
Toastr.warning(__('Please fill at least one number'));
|
||||
return false;
|
||||
}
|
||||
if (!action) {
|
||||
Toastr.error(__('Invalid batch operate action'));
|
||||
return false;
|
||||
}
|
||||
|
||||
var submit = function () {
|
||||
Fast.api.ajax({
|
||||
url: 'split.number/batchoperate',
|
||||
type: 'post',
|
||||
data: {
|
||||
split_link_id: splitLinkId,
|
||||
numbers: numbers,
|
||||
action: action
|
||||
}
|
||||
}, function (data, ret) {
|
||||
Layer.close(index);
|
||||
table.bootstrapTable('refresh');
|
||||
Toastr.success(ret.msg || __('Batch operate success'));
|
||||
});
|
||||
};
|
||||
|
||||
if (action === 'delete') {
|
||||
Layer.confirm(__('Batch operate delete confirm'), {icon: 3, title: __('Warning')}, function (confirmIndex) {
|
||||
Layer.close(confirmIndex);
|
||||
submit();
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
submit();
|
||||
return false;
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user