文件
fenleixinxi/public/assets/js/backend/fc/comment.js
MiAn 134267fcd9 feat: 新增举报详情功能及相关接口、页面
新增举报详情页面路由与配置
新增举报详情接口及路由规则
新增举报列表状态筛选功能
新增错误信息标准化处理方法
优化举报列表页面UI交互
完善微信登录异常提示处理
2026-11-19 09:16:58 +08:00

239 行
12 KiB
JavaScript

此文件含有模棱两可的 Unicode 字符

此文件含有可能会与其他字符混淆的 Unicode 字符。 如果您是想特意这样的,可以安全地忽略该警告。 使用 Escape 按钮显示他们。

define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'backend/format'], function ($, undefined, Backend, Table, Form, Format) {
var Controller = {
index: function () {
// 初始化表格参数配置
Table.api.init({
extend: {
index_url: 'fc/comment/index' + location.search,
add_url: 'fc/comment/add',
edit_url: 'fc/comment/edit',
del_url: 'fc/comment/del',
multi_url: 'fc/comment/multi',
import_url: 'fc/comment/import',
table: 'fc_comment',
}
});
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: __('SerialNo'), operate: false, sortable: false, align: 'center', width: '70px', class: 'fc-serial', table: table, formatter: Format.serial},
{field: 'post_id', title: '信息', addClass: 'selectpage', extend: "data-source='fc/post/index' data-field='title'", formatter: function (value, row) {
return row.post_title || '-';
}},
{field: 'user_id', title: '评价人', addClass: 'selectpage', extend: "data-source='user/user/index' data-field='nickname'", formatter: function (value, row) {
return row.user_name || '-';
}},
{field: 'score', title: __('Score'),
searchList: {1: '1', 2: '2', 3: '3', 4: '4', 5: '5'},
formatter: function (value) {
return (value === null || value === '' || value === undefined) ? '-' : value;
}
},
{field: 'content', title: __('Content'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
{field: 'reply', title: __('Reply'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
{field: 'top', title: __('Top'),
searchList: {0: __('否'), 1: __('是')},
formatter: Format.statusFormatter({0: __('否'), 1: __('已置顶')}, {0: 'default', 1: 'warning'})
},
{field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
{field: 'replytime', title: __('Replytime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
{field: 'status', title: __('Status'),
searchList: {1: __('正常'), 0: __('隐藏')},
formatter: Format.statusFormatter({1: __('正常'), 0: __('隐藏')}, {1: 'success', 0: 'default'})
},
{field: 'images', title: __('Images'), visible: false},
{field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime, visible: false},
{
field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate,
formatter: Table.api.formatter.operate,
buttons: [
{
name: 'reply',
text: __('ReplyComment'),
title: __('ReplyComment'),
classname: 'btn btn-xs btn-success btn-click',
click: function (options, row) {
Layer.prompt({title: __('请输入回复内容'), formType: 2, value: row.reply || ''}, function (value, index) {
Fast.api.ajax({
url: 'fc/comment/reply',
data: {ids: row.id, reply: value}
}, function () {
$('#' + options.tableId).bootstrapTable('refresh');
return false;
});
Layer.close(index);
});
}
},
{
name: 'top',
text: __('TopComment'),
title: __('TopComment'),
classname: 'btn btn-xs btn-info btn-click',
visible: function (row) {
return Number(row.top) !== 1;
},
confirm: __('确认置顶该评价?'),
click: function (options, row) {
Fast.api.ajax({
url: 'fc/comment/top',
data: {ids: row.id, top: 1}
}, function () {
$('#' + options.tableId).bootstrapTable('refresh');
return false;
});
}
},
{
name: 'untop',
text: __('UnTopComment'),
title: __('UnTopComment'),
classname: 'btn btn-xs btn-default btn-click',
visible: function (row) {
return Number(row.top) === 1;
},
confirm: __('确认取消置顶该评价?'),
click: function (options, row) {
Fast.api.ajax({
url: 'fc/comment/top',
data: {ids: row.id, top: 0}
}, function () {
$('#' + options.tableId).bootstrapTable('refresh');
return false;
});
}
},
{
name: 'hide',
text: '隐藏',
title: '隐藏评价',
classname: 'btn btn-xs btn-warning btn-click',
visible: function (row) {
return Number(row.status) === 1;
},
confirm: '确认隐藏该评价?隐藏后前台将不再展示。',
click: function (options, row) {
Fast.api.ajax({
url: 'fc/comment/status',
data: {ids: row.id, status: 0}
}, function () {
$('#' + options.tableId).bootstrapTable('refresh');
return false;
});
}
},
{
name: 'show',
text: '显示',
title: '恢复显示评价',
classname: 'btn btn-xs btn-primary btn-click',
visible: function (row) {
return Number(row.status) !== 1;
},
confirm: '确认恢复显示该评价?恢复后将在前台展示。',
click: function (options, row) {
Fast.api.ajax({
url: 'fc/comment/status',
data: {ids: row.id, status: 1}
}, function () {
$('#' + options.tableId).bootstrapTable('refresh');
return false;
});
}
}
]
}
]
]
});
// 为表格绑定事件
Table.api.bindevent(table);
// 置顶
$(document).on('click', '.btn-top', function () {
var ids = Table.api.selectedids(table);
Layer.confirm(__('确认置顶选中的评价?'), {icon: 3, title: __('提示')}, function (index) {
Fast.api.ajax({
url: 'fc/comment/top',
data: {ids: ids.join(','), top: 1}
}, function (data) {
table.bootstrapTable('refresh');
return false;
});
Layer.close(index);
});
});
// 取消置顶
$(document).on('click', '.btn-untop', function () {
var ids = Table.api.selectedids(table);
Layer.confirm(__('确认取消置顶选中的评价?'), {icon: 3, title: __('提示')}, function (index) {
Fast.api.ajax({
url: 'fc/comment/top',
data: {ids: ids.join(','), top: 0}
}, function (data) {
table.bootstrapTable('refresh');
return false;
});
Layer.close(index);
});
});
/**
* 批量切换选中评价的显示/隐藏状态
* @param {number} status 目标状态(1=显示,0=隐藏)
* @param {string} confirmText 确认弹窗文案
*/
function batchToggleStatus(status, confirmText) {
var ids = Table.api.selectedids(table);
if (!ids.length) return;
Layer.confirm(confirmText, {icon: 3, title: __('提示')}, function (index) {
Fast.api.ajax({
url: 'fc/comment/status',
data: {ids: ids.join(','), status: status}
}, function () {
table.bootstrapTable('refresh');
return false;
});
Layer.close(index);
});
}
// 批量显示
$(document).on('click', '.btn-show', function () {
batchToggleStatus(1, '确认恢复显示选中的评价?');
});
// 批量隐藏
$(document).on('click', '.btn-hide', function () {
batchToggleStatus(0, '确认隐藏选中的评价?隐藏后前台将不再展示。');
});
},
add: function () {
Controller.api.bindevent();
},
edit: function () {
Controller.api.bindevent();
},
api: {
bindevent: function () {
Form.api.bindevent($("form[role=form]"));
}
}
};
return Controller;
});