添加whatshub工单
This commit is contained in:
Regular → Executable
+144
-11
@@ -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,
|
||||
@@ -25,6 +27,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
||||
columns: [
|
||||
[
|
||||
{checkbox: true},
|
||||
searchSelect('split_link_id', __('Split_link_id'), Config.splitLinkFilterList || {}, true),
|
||||
{
|
||||
field: 'ticket_type',
|
||||
title: __('Ticket_type'),
|
||||
@@ -39,6 +42,12 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
||||
operate: false,
|
||||
formatter: Controller.api.formatter.splitLinkCode
|
||||
},
|
||||
{
|
||||
field: 'ticket_url',
|
||||
title: __('Ticket_url'),
|
||||
operate: 'LIKE',
|
||||
formatter: Controller.api.formatter.ticketUrlLink
|
||||
},
|
||||
{
|
||||
field: 'start_time_text',
|
||||
title: __('Start_time'),
|
||||
@@ -89,14 +98,10 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
||||
operate: false,
|
||||
formatter: Controller.api.formatter.syncDisplay
|
||||
},
|
||||
{
|
||||
field: 'status',
|
||||
title: __('Status'),
|
||||
searchList: Config.statusList,
|
||||
formatter: Table.api.formatter.toggle,
|
||||
yes: 'normal',
|
||||
no: 'hidden'
|
||||
},
|
||||
$.extend(
|
||||
{field: 'status', title: __('Status'), searchList: Config.statusList, formatter: Table.api.formatter.toggle, yes: 'normal', no: 'hidden'},
|
||||
searchSelectMeta(false)
|
||||
),
|
||||
{
|
||||
field: 'createtime',
|
||||
title: __('Createtime'),
|
||||
@@ -110,18 +115,27 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
||||
field: 'operate',
|
||||
title: __('Operate'),
|
||||
table: table,
|
||||
events: Table.api.events.operate,
|
||||
formatter: Table.api.formatter.operate
|
||||
events: Controller.api.events.operate,
|
||||
formatter: Controller.api.formatter.operate
|
||||
}
|
||||
]
|
||||
]
|
||||
});
|
||||
|
||||
table.on('post-common-search.bs.table', function (e, tbl) {
|
||||
Controller.api.initCommonSearchSelectpicker(tbl);
|
||||
});
|
||||
|
||||
Table.api.bindevent(table);
|
||||
Controller.api.syncingTicketIds = [];
|
||||
window.__splitTicketPendingPostAddSyncIds = window.__splitTicketPendingPostAddSyncIds || [];
|
||||
|
||||
table.on('load-success.bs.table', function () {
|
||||
table.on('click', '.split-ticket-url-group input, .split-ticket-url-group a', function (e) {
|
||||
e.stopPropagation();
|
||||
});
|
||||
|
||||
table.on('load-success.bs.table', function (e, res) {
|
||||
Controller.api.renderSummaryRow(res);
|
||||
var pendingIds = window.__splitTicketPendingPostAddSyncIds;
|
||||
if (!pendingIds || !pendingIds.length) {
|
||||
return;
|
||||
@@ -185,9 +199,67 @@ 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);
|
||||
}
|
||||
},
|
||||
|
||||
/** @type {number[]} 正在手动同步的工单 ID */
|
||||
syncingTicketIds: [],
|
||||
|
||||
/**
|
||||
* 渲染筛选结果汇总行(全量筛选数据,非当前页)
|
||||
*
|
||||
* @param {object} res 列表接口响应
|
||||
*/
|
||||
renderSummaryRow: function (res) {
|
||||
var $bar = $('#split-ticket-summary');
|
||||
if (!$bar.length) {
|
||||
return;
|
||||
}
|
||||
var total = res && res.total ? parseInt(res.total, 10) : 0;
|
||||
var summary = res && res.summary ? res.summary : null;
|
||||
if (!summary || total <= 0) {
|
||||
$bar.addClass('hide');
|
||||
return;
|
||||
}
|
||||
$bar.removeClass('hide');
|
||||
$bar.find('[data-sum="ticket_total"]').text(summary.ticket_total != null ? summary.ticket_total : 0);
|
||||
$bar.find('[data-sum="complete_count"]').text(summary.complete_count != null ? summary.complete_count : 0);
|
||||
$bar.find('[data-sum="ticket_progress_text"]').text(summary.ticket_progress_text || '0.00%');
|
||||
$bar.find('[data-sum="speed_per_hour"]').text(summary.speed_per_hour != null ? summary.speed_per_hour : '0.00');
|
||||
},
|
||||
|
||||
/**
|
||||
* 后台同步:标记「同步中」并请求 sync 接口
|
||||
*
|
||||
@@ -243,6 +315,30 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
||||
},
|
||||
|
||||
formatter: {
|
||||
/**
|
||||
* 操作列:编辑 → 拷贝 → 删除
|
||||
*/
|
||||
operate: function (value, row, index) {
|
||||
var column = this;
|
||||
var table = this.table;
|
||||
var options = table.bootstrapTable('getOptions');
|
||||
var buttons = [];
|
||||
if (options.extend.edit_url) {
|
||||
buttons.push($.extend({}, Table.button.edit, {url: options.extend.edit_url}));
|
||||
}
|
||||
buttons.push({
|
||||
name: 'copy',
|
||||
icon: 'fa fa-copy',
|
||||
title: __('Copy'),
|
||||
classname: 'btn btn-xs btn-info btn-copyone',
|
||||
url: 'javascript:;',
|
||||
extend: 'data-toggle="tooltip" data-container="body"',
|
||||
});
|
||||
if (options.extend.del_url) {
|
||||
buttons.push($.extend({}, Table.button.del));
|
||||
}
|
||||
return Table.api.buttonlink(column, buttons, value, row, index, 'operate');
|
||||
},
|
||||
/**
|
||||
* 工单类型:纯文本展示,无链接/标签样式
|
||||
*/
|
||||
@@ -267,6 +363,27 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
||||
return '<span class="split-ticket-link-badge" style="display:inline-block;max-width:100%;padding:2px 8px;font-size:12px;line-height:1.5;color:#555;background:#f5f5f5;border:1px solid #ddd;border-radius:3px;word-break:break-all;">'
|
||||
+ safe + '</span>';
|
||||
},
|
||||
/**
|
||||
* 工单链接:只读 input + 外链图标按钮
|
||||
*/
|
||||
ticketUrlLink: function (value) {
|
||||
value = value == null ? '' : String(value).trim();
|
||||
if (value === '') {
|
||||
return '<span class="text-muted">-</span>';
|
||||
}
|
||||
var href = value;
|
||||
if (!/^https?:\/\//i.test(href)) {
|
||||
href = 'https://' + href;
|
||||
}
|
||||
var safeValue = Fast.api.escape(value);
|
||||
var safeHref = Fast.api.escape(href);
|
||||
return '<div class="input-group input-group-sm split-ticket-url-group">'
|
||||
+ '<input type="text" class="form-control input-sm" readonly value="' + safeValue + '" title="' + safeValue + '">'
|
||||
+ '<span class="input-group-btn">'
|
||||
+ '<a href="' + safeHref + '" target="_blank" rel="noopener noreferrer" class="btn btn-default btn-sm" title="' + safeValue + '">'
|
||||
+ '<i class="fa fa-link"></i></a>'
|
||||
+ '</span></div>';
|
||||
},
|
||||
speedPerHour: function (value) {
|
||||
var num = parseFloat(value);
|
||||
if (isNaN(num)) {
|
||||
@@ -308,6 +425,22 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
||||
+ '</span>';
|
||||
}
|
||||
},
|
||||
events: {
|
||||
operate: $.extend({}, Table.api.events.operate, {
|
||||
'click .btn-copyone': function (e, value, row, index) {
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
var table = $(this).closest('table');
|
||||
var options = table.bootstrapTable('getOptions');
|
||||
var id = row[options.pk];
|
||||
Fast.api.open(
|
||||
Fast.api.fixurl('split.ticket/add?copy_id=' + id),
|
||||
__('Copy'),
|
||||
$(this).data() || {}
|
||||
);
|
||||
}
|
||||
})
|
||||
},
|
||||
bindevent: function () {
|
||||
Form.api.bindevent($('form[role=form]'));
|
||||
Controller.api.fixSelectPlaceholder();
|
||||
|
||||
Reference in New Issue
Block a user