- 重构后台所有管理页面工具栏,移除图标改用纯文字按钮 - 新增商户管理的批量审核功能与商家详情/审核页面 - 新增帖子管理的批量审核/上下架功能与帖子详情/审核页面 - 新增多媒体相册字段的前后台处理逻辑 - 新增微信订阅消息兼容导出层 - 更新站点版本号并优化品牌色变量 - 新增商户/帖子控制器的详情与审核方法 - 新增 .sql 文件忽略规则
291 行
14 KiB
JavaScript
291 行
14 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/merchant/index' + location.search,
|
|
add_url: 'fc/merchant/add',
|
|
edit_url: 'fc/merchant/edit',
|
|
del_url: 'fc/merchant/del',
|
|
multi_url: 'fc/merchant/multi',
|
|
table: 'fc_merchant',
|
|
}
|
|
});
|
|
|
|
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: 'logo', title: '门头Logo', operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
|
|
{
|
|
field: 'name', title: __('Name'), operate: 'LIKE',
|
|
events: {
|
|
'click .btn-view-merchant': function (e, value, row, index) {
|
|
e.stopPropagation();
|
|
e.preventDefault();
|
|
Fast.api.open('fc/merchant/detail?ids=' + row.id + '&mode=view', '详情', {area: ['820px', '85%']});
|
|
}
|
|
},
|
|
formatter: function (value, row) {
|
|
return '<a href="javascript:;" class="btn-view-merchant" style="color:#0F172A;font-weight:600;" title="详情">' + value + '</a>';
|
|
}
|
|
},
|
|
{field: 'user_id', title: '入驻用户', addClass: 'selectpage', extend: "data-source='user/user/index' data-field='nickname'"},
|
|
{field: 'category', title: '所属行业', operate: 'LIKE'},
|
|
{field: 'contact', title: __('Contact'), operate: 'LIKE'},
|
|
{field: 'license', title: '营业执照', operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
|
|
{
|
|
field: 'audit_status', title: __('Audit_status'),
|
|
searchList: {0: __('待审核'), 1: __('已通过'), 2: __('已驳回')},
|
|
formatter: Format.statusFormatter({0: __('待审核'), 1: __('已通过'), 2: __('已驳回')}, {0: 'warning', 1: 'success', 2: 'danger'})
|
|
},
|
|
{
|
|
field: 'shop_status', title: '营业状态',
|
|
searchList: {normal: __('正常营业'), closed: __('暂停歇业')},
|
|
formatter: function (value) {
|
|
return value === 'normal' ? '<span class="text-success">正常营业</span>' : '<span class="text-muted">暂停歇业</span>';
|
|
}
|
|
},
|
|
{
|
|
field: 'recommend', title: '推荐位',
|
|
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: 'operate', title: '操作', align: 'center', width: '130px',
|
|
events: {
|
|
'click .btn-audit-one': function (e, value, row, index) {
|
|
e.stopPropagation();
|
|
e.preventDefault();
|
|
Fast.api.open('fc/merchant/detail?ids=' + row.id + '&mode=audit', '审核', {area: ['820px', '85%']});
|
|
},
|
|
'click .btn-detail-one': function (e, value, row, index) {
|
|
e.stopPropagation();
|
|
e.preventDefault();
|
|
Fast.api.open('fc/merchant/detail?ids=' + row.id + '&mode=view', '详情', {area: ['820px', '85%']});
|
|
},
|
|
'click .btn-edit-one': function (e, value, row, index) {
|
|
e.stopPropagation();
|
|
e.preventDefault();
|
|
Fast.api.open('fc/merchant/edit?ids=' + row.id, '编辑', {area: ['820px', '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/merchant/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/merchant/detail?ids=' + row.id + '&mode=' + mode, title, {area: ['820px', '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/merchant/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/merchant/audit',
|
|
data: {ids: ids.join(','), auditStatus: 2, reason: value}
|
|
}, function () {
|
|
table.bootstrapTable('refresh');
|
|
updateBatchBar();
|
|
return false;
|
|
});
|
|
Layer.close(index);
|
|
});
|
|
});
|
|
|
|
// 批量设为推荐
|
|
$(document).on('click', '.btn-merchant-batch-recommend', 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/merchant/recommend',
|
|
data: {ids: ids.join(','), recommend: 1}
|
|
}, function () {
|
|
table.bootstrapTable('refresh');
|
|
updateBatchBar();
|
|
return false;
|
|
});
|
|
Layer.close(index);
|
|
});
|
|
});
|
|
},
|
|
|
|
detail: function () {
|
|
var merchantId = Fast.api.query('ids') || Fast.api.query('id');
|
|
|
|
function submitAudit(status, reason) {
|
|
Fast.api.ajax({
|
|
url: 'fc/merchant/audit',
|
|
type: 'POST',
|
|
data: {
|
|
ids: merchantId,
|
|
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();
|
|
});
|
|
},
|
|
|
|
add: function () {
|
|
Controller.api.bindevent();
|
|
},
|
|
edit: function () {
|
|
Controller.api.bindevent();
|
|
},
|
|
api: {
|
|
bindevent: function () {
|
|
Form.api.bindevent($("form[role=form]"));
|
|
}
|
|
}
|
|
};
|
|
|
|
return Controller;
|
|
});
|