profarm.js 2.2 KB
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index1: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'profarm/index1',
                    table: 'project',
                },
                queryParams: function (params) { //自定义搜索条件
                    params.ids = Config.farm_id;//将搜索过滤器和操作方法 都转为JSON字符串
                    return params;
                }

            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id'), operate:false},
                        {field: 'project_name', title: __('项目名称'), operate:false},
                        {field: 'image', title: __('项目图片'),operate:false, events: Table.api.events.image,formatter: Table.api.formatter.image},
                        {field: 'estimate', title: __('预估产量'), operate:false},
                        {field: 'estimate_time', title: __('预估成熟时间'), operate:false},
                        {field: 'status', title: __('项目状态'),formatter: Table.api.formatter.label,searchList:{'0': '培育中', '1': '将收获','2':'已收获'}},
                        {field: 'createtime', title: __('创建时间'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                    ]
                ]
            });

            // 为表格绑定事件
            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;
});