123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143 |
- define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
- var Controller = {
- index: function () {
- // 初始化表格参数配置
- Table.api.init({
- extend: {
- index_url: 'body_profile/index' + location.search,
-
- table: 'body_profile',
- }
- });
- 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: __('Id'), sortable: true},
- {
- field: 'profile_name',
- title: __('Profile name'),
- operate: 'LIKE',
- table: table,
- class: 'autocontent',
- formatter: Table.api.formatter.content
- },
- {
- field: 'user.username',
- title: __('User'),
- operate: false,
- formatter: function(value, row, index) {
- return row.user ? row.user.username : '-';
- }
- },
- {
- field: 'gender',
- title: __('Gender'),
- searchList: {"1": __("Male"), "2": __("Female")},
- formatter: Table.api.formatter.normal
- },
- {
- field: 'is_own',
- title: __('Is own'),
- searchList: {"1": __("Yes"), "0": __("No")},
- formatter: Table.api.formatter.normal
- },
- // {
- // field: 'relation',
- // title: __('Relation'),
- // operate: 'LIKE'
- // },
- {
- field: 'age',
- title: __('Age'),
- operate: 'BETWEEN'
- },
- {
- field: 'height',
- title: __('Height'),
- operate: 'BETWEEN',
- formatter: function(value, row, index) {
- return value ? value + 'cm' : '-';
- }
- },
- {
- field: 'weight',
- title: __('Weight'),
- operate: 'BETWEEN',
- formatter: function(value, row, index) {
- return value ? value + 'kg' : '-';
- }
- },
- // {
- // field: 'bmi',
- // title: __('BMI'),
- // operate: false,
- // formatter: function(value, row, index) {
- // if (row.bmi && row.bmi > 0) {
- // var level = row.bmi_level || '';
- // var color = 'success';
- // if (level === '偏瘦') color = 'info';
- // else if (level === '超重') color = 'warning';
- // else if (level === '肥胖') color = 'danger';
- // return '<span class="label label-' + color + '">' + row.bmi + ' (' + level + ')</span>';
- // }
- // return '-';
- // }
- // },
- {
- field: 'createtime',
- title: __('Createtime'),
- operate: 'RANGE',
- addclass: 'datetimerange',
- autocomplete: false,
- formatter: Table.api.formatter.datetime
- },
- {
- field: 'operate',
- title: __('Operate'),
- table: table,
- events: Table.api.events.operate,
- formatter: function(value, row, index) {
- var that = this;
- var buttons = [];
-
- // 详情按钮
- buttons.push('<a href="javascript:;" class="btn btn-xs btn-success btn-detail" data-id="' + row.id + '" title="' + __('Detail') + '"><i class="fa fa-list"></i></a>');
-
- return buttons.join(' ');
- },
- events: $.extend({}, Table.api.events.operate, {
- 'click .btn-detail': function (e, value, row, index) {
- e.stopPropagation();
- e.preventDefault();
- Fast.api.open('body_profile/detail?ids=' + row.id, __('Detail'), {
- area: ['90%', '90%']
- });
- }
- })
- }
- ]
- ]
- });
- // 为表格绑定事件
- Table.api.bindevent(table);
- },
-
- detail: function () {
- // 详情页面初始化
- }
- };
-
- return Controller;
- });
|