文件
fenleixinxi/public/assets/js/backend/fc/merchant.js

152 行
8.1 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',
import_url: 'fc/merchant/import',
table: 'fc_merchant',
}
});
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: 'user_id', title: '用户', addClass: 'selectpage', extend: "data-source='user/user/index' data-field='nickname'", formatter: function (value, row) {
return row.user_name || '-';
}},
{field: 'name', title: __('Name'), operate: 'LIKE'},
{field: 'contact', title: __('Contact'), operate: 'LIKE'},
{field: 'category', title: __('Category'), operate: 'LIKE'},
{
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: __('Shop_status'),
searchList: {normal: __('正常'), pending: __('待审核'), banned: __('已封禁')},
formatter: Format.statusFormatter({normal: __('正常'), pending: __('待审核'), banned: __('已封禁')}, {normal: 'success', pending: 'warning', banned: 'danger'})
},
{field: 'license', title: __('License'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
{field: 'violations', title: __('Violations')},
{field: 'post_count', title: __('Post_count')},
{field: 'audit_reason', title: __('Audit_reason'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
{field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
{field: 'logo', title: __('Logo'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content, 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: 'auditpass',
text: __('AuditPass'),
title: __('AuditPass'),
classname: 'btn btn-xs btn-success btn-click',
visible: function (row) {
return Number(row.audit_status) !== 1;
},
confirm: __('确认审核通过该商家?'),
click: function (options, row) {
Fast.api.ajax({
url: 'fc/merchant/audit',
data: {ids: row.id, auditStatus: 1}
}, function () {
$('#' + options.tableId).bootstrapTable('refresh');
return false;
});
}
},
{
name: 'auditreject',
text: __('AuditReject'),
title: __('AuditReject'),
classname: 'btn btn-xs btn-danger btn-click',
visible: function (row) {
return Number(row.audit_status) !== 2;
},
click: function (options, row) {
Layer.prompt({title: __('请输入驳回原因'), formType: 2}, function (value, index) {
Fast.api.ajax({
url: 'fc/merchant/audit',
data: {ids: row.id, auditStatus: 2, reason: value}
}, function () {
$('#' + options.tableId).bootstrapTable('refresh');
return false;
});
Layer.close(index);
});
}
}
]
}
]
]
});
// 为表格绑定事件
Table.api.bindevent(table);
// 审核通过
$(document).on('click', '.btn-audit-pass', function () {
var ids = Table.api.selectedids(table);
Layer.confirm(__('确认审核通过选中的商家?'), {icon: 3, title: __('提示')}, function (index) {
Fast.api.ajax({
url: 'fc/merchant/audit',
data: {ids: ids.join(','), auditStatus: 1}
}, function (data) {
table.bootstrapTable('refresh');
return false;
});
Layer.close(index);
});
});
// 审核驳回
$(document).on('click', '.btn-audit-reject', function () {
var ids = Table.api.selectedids(table);
Layer.prompt({title: __('请输入驳回原因'), formType: 2}, function (value, index) {
Fast.api.ajax({
url: 'fc/merchant/audit',
data: {ids: ids.join(','), auditStatus: 2, reason: value}
}, function (data) {
table.bootstrapTable('refresh');
return false;
});
Layer.close(index);
});
});
},
add: function () {
Controller.api.bindevent();
},
edit: function () {
Controller.api.bindevent();
},
api: {
bindevent: function () {
Form.api.bindevent($("form[role=form]"));
}
}
};
return Controller;
});