- 重构后台所有管理页面工具栏,移除图标改用纯文字按钮 - 新增商户管理的批量审核功能与商家详情/审核页面 - 新增帖子管理的批量审核/上下架功能与帖子详情/审核页面 - 新增多媒体相册字段的前后台处理逻辑 - 新增微信订阅消息兼容导出层 - 更新站点版本号并优化品牌色变量 - 新增商户/帖子控制器的详情与审核方法 - 新增 .sql 文件忽略规则
400 行
19 KiB
JavaScript
400 行
19 KiB
JavaScript
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/post/index' + location.search,
|
|
add_url: 'fc/post/add',
|
|
edit_url: 'fc/post/edit',
|
|
del_url: 'fc/post/del',
|
|
multi_url: 'fc/post/multi',
|
|
table: 'fc_post',
|
|
}
|
|
});
|
|
|
|
var table = $("#table");
|
|
var batchBar = $("#batch-bar");
|
|
var selectedCount = $("#selected-count");
|
|
|
|
// 初始化表格
|
|
table.bootstrapTable({
|
|
url: $.fn.bootstrapTable.defaults.extend.index_url,
|
|
pk: 'id',
|
|
sortName: 'id',
|
|
sortOrder: 'desc',
|
|
escape: false,
|
|
clickToSelect: false, // 禁用点击行任意位置自动勾选复选框,杜绝点击操作按钮误触发多选
|
|
columns: [
|
|
[
|
|
{checkbox: true},
|
|
{field: 'id', title: '序号', operate: false, formatter: function (value, row, index) {
|
|
return '<span class="fc-serial">' + (index + 1) + '</span>';
|
|
}},
|
|
{
|
|
field: 'cover', title: '封面', operate: false, align: 'center', width: '65px',
|
|
events: Table.api.events.image,
|
|
formatter: function (value, row) {
|
|
var img = value || (row.media && row.media.length > 0 ? (typeof row.media === 'string' && row.media.indexOf('[') === 0 ? JSON.parse(row.media)[0] : row.media.split(',')[0]) : '');
|
|
return img ? Table.api.formatter.image.call(this, img, row) : '<span class="text-muted" style="font-size:11px;">无图</span>';
|
|
}
|
|
},
|
|
{
|
|
field: 'title', title: __('Title'), operate: 'LIKE', align: 'left',
|
|
events: {
|
|
'click .btn-view-detail': function (e, value, row, index) {
|
|
e.stopPropagation();
|
|
e.preventDefault();
|
|
Fast.api.open('fc/post/detail?ids=' + row.id + '&mode=view', '详情', {area: ['850px', '85%']});
|
|
}
|
|
},
|
|
formatter: function (value, row) {
|
|
var topBadge = Number(row.is_top) === 1 ? '<span class="label label-warning" style="margin-right:4px;">置顶</span>' : '';
|
|
return topBadge + '<a href="javascript:;" class="btn-view-detail" style="color:#0F172A;font-weight:600;" title="详情">' + value + '</a>';
|
|
}
|
|
},
|
|
{
|
|
field: 'category_id', title: '分类', addClass: 'selectpage', extend: "data-source='fc/category/index' data-field='name'",
|
|
formatter: function (value, row) {
|
|
return row.category_name ? '<span class="label label-default" style="font-weight:normal;">' + row.category_name + '</span>' : '-';
|
|
}
|
|
},
|
|
{
|
|
field: 'price', title: __('Price'), operate: 'BETWEEN', align: 'right',
|
|
formatter: function (value, row) {
|
|
if (value === null || value === '' || value === undefined || Number(value) === 0) {
|
|
return '<span class="text-muted">面议/免费</span>';
|
|
}
|
|
return '<strong style="color:#EA580C;">¥' + value + '</strong>' + (row.price_unit ? ' <small class="text-muted">' + row.price_unit + '</small>' : '');
|
|
}
|
|
},
|
|
{field: 'area', title: __('Area'), operate: 'LIKE', formatter: function (value) { return value || '-'; }},
|
|
{
|
|
field: 'user_id', title: '发布用户', addClass: 'selectpage', extend: "data-source='user/user/index' data-field='nickname'",
|
|
formatter: function (value, row) {
|
|
return row.user_name ? '<i class="fa fa-user-circle text-muted"></i> ' + row.user_name : '-';
|
|
}
|
|
},
|
|
{
|
|
field: 'audit_status', title: __('Audit_status'),
|
|
searchList: {0: __('待审核'), 1: __('已通过'), 2: __('已驳回')},
|
|
formatter: Format.statusFormatter({0: __('待审核'), 1: __('已通过'), 2: __('已驳回')}, {0: 'warning', 1: 'success', 2: 'danger'})
|
|
},
|
|
{
|
|
field: 'status', title: '上架状态',
|
|
searchList: {1: __('正常'), 0: __('已下架')},
|
|
formatter: Format.statusFormatter({1: __('正常'), 0: __('已下架')}, {1: 'success', 0: 'default'})
|
|
},
|
|
{field: 'views', title: __('Views'), sortable: true, operate: false},
|
|
{field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
|
|
{
|
|
field: 'operate', title: '操作', align: 'center', width: '130px',
|
|
events: {
|
|
'click .btn-audit-one': function (e, value, row, index) {
|
|
e.stopPropagation();
|
|
e.preventDefault();
|
|
Fast.api.open('fc/post/detail?ids=' + row.id + '&mode=audit', '审核', {area: ['850px', '85%']});
|
|
},
|
|
'click .btn-detail-one': function (e, value, row, index) {
|
|
e.stopPropagation();
|
|
e.preventDefault();
|
|
Fast.api.open('fc/post/detail?ids=' + row.id + '&mode=view', '详情', {area: ['850px', '85%']});
|
|
},
|
|
'click .btn-edit-one': function (e, value, row, index) {
|
|
e.stopPropagation();
|
|
e.preventDefault();
|
|
Fast.api.open('fc/post/edit?ids=' + row.id, '编辑', {area: ['850px', '85%']});
|
|
},
|
|
'click .btn-del-one': function (e, value, row, index) {
|
|
e.stopPropagation();
|
|
e.preventDefault();
|
|
Layer.confirm(__('Are you sure you want to delete this item?'), {title: __('Warning'), btn: ['确定', '取消']}, function (confirmIndex) {
|
|
Fast.api.ajax({
|
|
url: 'fc/post/del',
|
|
data: {ids: row.id}
|
|
}, function () {
|
|
table.bootstrapTable('refresh');
|
|
return false;
|
|
});
|
|
Layer.close(confirmIndex);
|
|
});
|
|
}
|
|
},
|
|
formatter: function (value, row) {
|
|
var isPending = Number(row.audit_status) === 0;
|
|
var actionBtn = isPending
|
|
? '<a href="javascript:;" class="btn btn-xs btn-success btn-audit-one" title="审核">审核</a> '
|
|
: '<a href="javascript:;" class="btn btn-xs btn-default btn-detail-one" title="详情">详情</a> ';
|
|
var editBtn = '<a href="javascript:;" class="btn btn-xs btn-default btn-edit-one" title="编辑">编辑</a> ';
|
|
var delBtn = '<a href="javascript:;" class="btn btn-xs btn-danger btn-del-one" title="删除">删除</a>';
|
|
return actionBtn + editBtn + delBtn;
|
|
}
|
|
}
|
|
]
|
|
]
|
|
});
|
|
|
|
// 为表格绑定事件
|
|
Table.api.bindevent(table);
|
|
|
|
/**
|
|
* 联动动态批量操作工具栏(仅勾选多项时显示,杜绝界面臃肿)
|
|
*/
|
|
function updateBatchBar() {
|
|
var selectedIds = Table.api.selectedids(table);
|
|
if (selectedIds.length > 0) {
|
|
selectedCount.text(selectedIds.length);
|
|
batchBar.removeClass('hide').show();
|
|
} else {
|
|
batchBar.addClass('hide').hide();
|
|
}
|
|
}
|
|
|
|
table.on('check.bs.table uncheck.bs.table check-all.bs.table uncheck-all.bs.table load-success.bs.table', function () {
|
|
updateBatchBar();
|
|
});
|
|
|
|
// 双击行打开详情弹窗
|
|
table.on('dbl-click-row.bs.table', function (e, row) {
|
|
var isPending = Number(row.audit_status) === 0;
|
|
var mode = isPending ? 'audit' : 'view';
|
|
var title = isPending ? '审核' : '详情';
|
|
Fast.api.open('fc/post/detail?ids=' + row.id + '&mode=' + mode, title, {area: ['850px', '85%']});
|
|
});
|
|
|
|
// 清除多选选中状态
|
|
$(document).on('click', '.btn-clear-selection', function () {
|
|
table.bootstrapTable('uncheckAll');
|
|
updateBatchBar();
|
|
});
|
|
|
|
// 批量审核通过
|
|
$(document).on('click', '.btn-audit-pass', function () {
|
|
var ids = Table.api.selectedids(table);
|
|
if (ids.length === 0) {
|
|
Toastr.warning('请先勾选需要批量操作的信息');
|
|
return;
|
|
}
|
|
Layer.confirm('确认批量审核通过选中的 ' + ids.length + ' 条信息?', {title: '批量审核确认', btn: ['通过', '取消']}, function (index) {
|
|
Fast.api.ajax({
|
|
url: 'fc/post/audit',
|
|
data: {ids: ids.join(','), auditStatus: 1}
|
|
}, function () {
|
|
table.bootstrapTable('refresh');
|
|
updateBatchBar();
|
|
return false;
|
|
});
|
|
Layer.close(index);
|
|
});
|
|
});
|
|
|
|
// 批量审核驳回
|
|
$(document).on('click', '.btn-audit-reject', function () {
|
|
var ids = Table.api.selectedids(table);
|
|
if (ids.length === 0) {
|
|
Toastr.warning('请先勾选需要批量操作的信息');
|
|
return;
|
|
}
|
|
Layer.prompt({title: '请输入批量驳回的原因(将通知给发布用户)', formType: 2}, function (value, index) {
|
|
if (!$.trim(value)) {
|
|
Toastr.error('驳回原因不可为空');
|
|
return;
|
|
}
|
|
Fast.api.ajax({
|
|
url: 'fc/post/audit',
|
|
data: {ids: ids.join(','), auditStatus: 2, reason: value}
|
|
}, function () {
|
|
table.bootstrapTable('refresh');
|
|
updateBatchBar();
|
|
return false;
|
|
});
|
|
Layer.close(index);
|
|
});
|
|
});
|
|
|
|
// 批量下架
|
|
$(document).on('click', '.btn-offline', function () {
|
|
var ids = Table.api.selectedids(table);
|
|
if (ids.length === 0) {
|
|
Toastr.warning('请先勾选需要下架的信息');
|
|
return;
|
|
}
|
|
Layer.confirm('确认批量下架选中的 ' + ids.length + ' 条信息?', {title: '下架确认', btn: ['下架', '取消']}, function (index) {
|
|
Fast.api.ajax({
|
|
url: 'fc/post/offline',
|
|
data: {ids: ids.join(',')}
|
|
}, function () {
|
|
table.bootstrapTable('refresh');
|
|
updateBatchBar();
|
|
return false;
|
|
});
|
|
Layer.close(index);
|
|
});
|
|
});
|
|
|
|
// 批量置顶
|
|
$(document).on('click', '.btn-top', function () {
|
|
var ids = Table.api.selectedids(table);
|
|
if (ids.length === 0) {
|
|
Toastr.warning('请先勾选需要置顶的信息');
|
|
return;
|
|
}
|
|
Layer.confirm('确认批量置顶选中的 ' + ids.length + ' 条信息?', {title: '置顶确认', btn: ['置顶', '取消']}, function (index) {
|
|
Fast.api.ajax({
|
|
url: 'fc/post/top',
|
|
data: {ids: ids.join(','), isTop: 1}
|
|
}, function () {
|
|
table.bootstrapTable('refresh');
|
|
updateBatchBar();
|
|
return false;
|
|
});
|
|
Layer.close(index);
|
|
});
|
|
});
|
|
},
|
|
|
|
/**
|
|
* 详情与审核窗口逻辑
|
|
*/
|
|
detail: function () {
|
|
var postId = Fast.api.query('ids') || Fast.api.query('id');
|
|
|
|
/**
|
|
* 提交审核结果
|
|
* @param {number} status 1=通过, 2=驳回
|
|
* @param {string} reason 驳回原因
|
|
*/
|
|
function submitAudit(status, reason) {
|
|
Fast.api.ajax({
|
|
url: 'fc/post/audit',
|
|
type: 'POST',
|
|
data: {
|
|
ids: postId,
|
|
auditStatus: status,
|
|
reason: reason || ''
|
|
}
|
|
}, function (data, ret) {
|
|
Toastr.success(ret.msg || '操作成功');
|
|
setTimeout(function () {
|
|
Fast.api.close();
|
|
if (parent.$ && parent.$('#table').length) {
|
|
parent.$('#table').bootstrapTable('refresh');
|
|
}
|
|
}, 400);
|
|
return false;
|
|
}, function (data, ret) {
|
|
Toastr.error(ret.msg || '操作失败');
|
|
return false;
|
|
});
|
|
}
|
|
|
|
// 点击通过:弹窗确认通过
|
|
$('#btn-pass').off('click').on('click', function () {
|
|
Layer.confirm('确认审核通过此信息吗?', {
|
|
title: '通过确认',
|
|
btn: ['通过', '取消']
|
|
}, function (index) {
|
|
Layer.close(index);
|
|
submitAudit(1, '');
|
|
});
|
|
});
|
|
|
|
// 点击驳回:弹窗确认输入驳回原因
|
|
$('#btn-reject').off('click').on('click', function () {
|
|
Layer.prompt({
|
|
title: '请输入驳回原因(将通知给发布用户)',
|
|
formType: 2,
|
|
value: ''
|
|
}, function (value, promptIndex) {
|
|
var reason = $.trim(value);
|
|
if (!reason) {
|
|
Toastr.warning('驳回原因不可为空');
|
|
return;
|
|
}
|
|
Layer.close(promptIndex);
|
|
submitAudit(2, reason);
|
|
});
|
|
});
|
|
|
|
// 点击关闭
|
|
$('#btn-close').off('click').on('click', function () {
|
|
Fast.api.close();
|
|
});
|
|
},
|
|
|
|
recyclebin: function () {
|
|
Table.api.init({
|
|
extend: {
|
|
'dragsort_url': ''
|
|
}
|
|
});
|
|
|
|
var table = $("#table");
|
|
|
|
table.bootstrapTable({
|
|
url: 'fc/post/recyclebin' + location.search,
|
|
pk: 'id',
|
|
sortName: 'id',
|
|
clickToSelect: false,
|
|
columns: [
|
|
[
|
|
{checkbox: true},
|
|
{field: 'id', title: '序号', operate: false, formatter: function (value, row, index) {
|
|
return '<span class="fc-serial">' + (index + 1) + '</span>';
|
|
}},
|
|
{field: 'title', title: __('Title'), align: 'left'},
|
|
{
|
|
field: 'deletetime',
|
|
title: __('Deletetime'),
|
|
operate: 'RANGE',
|
|
addclass: 'datetimerange',
|
|
formatter: Table.api.formatter.datetime
|
|
},
|
|
{
|
|
field: 'operate',
|
|
width: '120px',
|
|
title: '操作',
|
|
table: table,
|
|
events: Table.api.events.operate,
|
|
buttons: [
|
|
{
|
|
name: 'Restore',
|
|
text: '还原',
|
|
classname: 'btn btn-xs btn-info btn-ajax btn-restoreit',
|
|
url: 'fc/post/restore',
|
|
refresh: true
|
|
},
|
|
{
|
|
name: 'Destroy',
|
|
text: '销毁',
|
|
classname: 'btn btn-xs btn-danger btn-ajax btn-destroyit',
|
|
url: 'fc/post/destroy',
|
|
refresh: true
|
|
}
|
|
],
|
|
formatter: Table.api.formatter.operate
|
|
}
|
|
]
|
|
]
|
|
});
|
|
|
|
Table.api.bindevent(table);
|
|
},
|
|
|
|
add: function () {
|
|
Controller.api.bindevent();
|
|
},
|
|
edit: function () {
|
|
Controller.api.bindevent();
|
|
},
|
|
api: {
|
|
bindevent: function () {
|
|
Form.api.bindevent($("form[role=form]"));
|
|
}
|
|
}
|
|
};
|
|
|
|
return Controller;
|
|
});
|