文件
fenleixinxi/public/assets/js/backend/fc/plan.js
MiAn 111054d984 feat: 新增会员浏览/拨打额度并优化无图展示逻辑
新增会员每日浏览完整信息和拨打电话的额度配置,调整付费查看接口描述为解锁完整信息,优化帖子无图时的兜底展示逻辑,修复图片加载路径问题,删除废弃工具脚本。
2026-10-28 11:06:39 +08:00

113 行
5.7 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/plan/index' + location.search,
add_url: 'fc/plan/add',
edit_url: 'fc/plan/edit',
del_url: 'fc/plan/del',
multi_url: 'fc/plan/multi',
import_url: 'fc/plan/import',
table: 'fc_plan',
}
});
var table = $("#table");
// 初始化表格
table.bootstrapTable({
url: $.fn.bootstrapTable.defaults.extend.index_url,
pk: 'id',
sortName: 'sort',
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: 'plan_code', title: __('Plan_code'), operate: 'LIKE'},
{field: 'name', title: __('Name'), operate: 'LIKE'},
{
field: 'price', title: __('Price'), operate: 'BETWEEN',
formatter: function (value) {
return value === '' || value === null ? '-' : '¥' + parseFloat(value).toFixed(2);
}
},
{
field: 'origin_price', title: __('Origin_price'), operate: 'BETWEEN',
formatter: function (value) {
return value === '' || value === null ? '-' : '¥' + parseFloat(value).toFixed(2);
}
},
{
field: 'days', title: __('Days'),
formatter: function (value) {
return (value || 0) + ' 天';
}
},
{
field: 'post_quota', title: __('Post_quota'), operate: 'BETWEEN',
formatter: function (value) {
var n = parseInt(value || 0, 10);
return n > 0 ? '<span class="text-success">' + n + ' 条</span>' : '<span class="text-muted">不赠送</span>';
}
},
{
field: 'view_quota', title: __('View_quota'), operate: 'BETWEEN',
formatter: function (value) {
var n = parseInt(value !== undefined && value !== null ? value : 20, 10);
return n === 0 ? '<span class="label label-success">不限次浏览</span>' : (n + ' 条/日');
}
},
{
field: 'call_quota', title: __('Call_quota'), operate: 'BETWEEN',
formatter: function (value) {
var n = parseInt(value !== undefined && value !== null ? value : 30, 10);
return n === 0 ? '<span class="label label-success">不限次拨打</span>' : (n + ' 次/日');
}
},
{
field: 'post_discount', title: __('Post_discount'), operate: 'BETWEEN',
formatter: function (value) {
var d = parseFloat(value !== undefined && value !== null ? value : 8.0);
if (isNaN(d) || d >= 10 || d <= 0) {
return '<span class="text-muted">原价</span>';
}
return '<span class="text-warning"><strong>' + parseFloat(d.toFixed(1)) + ' 折</strong></span>';
}
},
{field: 'tag', title: __('Tag'), operate: 'LIKE', formatter: Table.api.formatter.flag},
{
field: 'enabled', title: __('Enabled'),
searchList: {0: '否', 1: '是'},
formatter: Table.api.formatter.toggle
},
{field: 'sort', title: __('Sort')},
{field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
{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}
]
]
});
// 为表格绑定事件
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;
});