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

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'four_baogao/index' + location.search,
                    add_url: 'four_baogao/add',
                    edit_url: 'four_baogao/edit',
                    del_url: 'four_baogao/del',
                    multi_url: 'four_baogao/multi',
                    import_url: 'four_baogao/import',
                    table: 'four_baogao',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id')},
                        // {field: 'card_ids', title: __('Card_ids'), operate: 'LIKE'},
                        // {field: 'activitycard.title', title: __('Activitycard.title'), operate: 'LIKE'},
                        {
                            field: 'type',
                            title: __('Type'),
                            searchList: {
                                "1": __('Type 1'),
                                "2": __('Type 2'),
                                "3": __('Type 3'),
                                "4": __('Type 4'),
                                "5": __('Type 5'),
                                "6": __('Type 6'),
                                "7": __('Type 7'),
                                "8": __('Type 8'),
                                "9": __('Type 9'),
                                "10": __('Type 10')
                            },
                            formatter: Table.api.formatter.normal
                        },
                        // {field: 'sport_image', title: __('Sport_image'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
                        // {field: 'sport_Goods_id', title: __('Sport_goods_id')},
                        // {field: 'eat_image', title: __('Eat_image'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
                        // {field: 'eat_Goods_id', title: __('Eat_goods_id')},
                        // {field: 'body_image', title: __('Body_image'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
                        // {field: 'body_Goods_id', title: __('Body_goods_id')},
                        // {field: 'season_image', title: __('Season_image'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
                        // {field: 'season_Goods_id', title: __('Season_goods_id')},
                        // {field: 'work_image', title: __('Work_image'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
                        // {field: 'work_Goods_id', title: __('Work_goods_id')},
                        {
                            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
                        },
                        // {field: 'goods.title', title: __('Goods.title'), operate: 'LIKE'},
                        {
                            field: 'operate',
                            title: __('Operate'),
                            table: table,
                            events: Table.api.events.operate,
                            formatter: Table.api.formatter.operate
                        }
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            var SportType = document.getElementById("c-sport_type");
            var EatType = document.getElementById("c-eat_type");
            var SeasonType = document.getElementById("c-season_type");
            var BodyType = document.getElementById("c-body_type");
            var WorkType = document.getElementById("c-work_type");
            var FaceType = document.getElementById("c-face_type");
            var web1 = document.getElementById("web1");
            var goods1 = document.getElementById("goods1");
            var web2 = document.getElementById("web2");
            var goods2 = document.getElementById("goods2");
            var web3 = document.getElementById("web3");
            var goods3 = document.getElementById("goods3");
            var web4 = document.getElementById("web4");
            var goods4 = document.getElementById("goods4");
            var web5 = document.getElementById("web5");
            var goods5 = document.getElementById("goods5");
            var web6 = document.getElementById("web6");
            var goods6 = document.getElementById("goods6");
            SportType.onchange = function () {
                if (SportType.value == 1) {
                    web1.style.display = 'none';
                    goods1.style.display = 'block';
                } else {
                    web1.style.display = 'block';
                    goods1.style.display = 'none';
                }
            };
            EatType.onchange = function () {
                if (EatType.value == 1) {
                    web2.style.display = 'none';
                    goods2.style.display = 'block';
                } else {
                    web2.style.display = 'block';
                    goods2.style.display = 'none';
                }
            };
            BodyType.onchange = function () {
                if (BodyType.value == 1) {
                    web3.style.display = 'none';
                    goods3.style.display = 'block';
                } else {
                    web3.style.display = 'block';
                    goods3.style.display = 'none';
                }
            };
            SeasonType.onchange = function () {
                if (SeasonType.value == 1) {
                    web4.style.display = 'none';
                    goods4.style.display = 'block';
                } else {
                    web4.style.display = 'block';
                    goods4.style.display = 'none';
                }
            };
            WorkType.onchange = function () {
                if (WorkType.value == 1) {
                    web5.style.display = 'none';
                    goods5.style.display = 'block';
                } else {
                    web5.style.display = 'block';
                    goods5.style.display = 'none';
                }
            };
            FaceType.onchange = function () {
                if (FaceType.value == 1) {
                    web6.style.display = 'none';
                    goods6.style.display = 'block';
                } else {
                    web6.style.display = 'block';
                    goods6.style.display = 'none';
                }
            };
            Controller.api.bindevent();
        },
        edit: function () {
            // var SportType = Config.SportType;
            // var EatType = Config.EatType;
            // var SeasonType = Config.SeasonType;
            // var BodyType = Config.BodyType;
            // var WorkType = Config.WorkType;
            // var FaceType = Config.FaceType;
            // var web1 = document.getElementById("web1");
            // var goods1 = document.getElementById("goods1");
            // var web2 = document.getElementById("web2");
            // var goods2 = document.getElementById("goods2");
            // var web3 = document.getElementById("web3");
            // var goods3 = document.getElementById("goods3");
            // var web4 = document.getElementById("web4");
            // var goods4 = document.getElementById("goods4");
            // var web5 = document.getElementById("web5");
            // var goods5 = document.getElementById("goods5");
            // var web6 = document.getElementById("web6");
            // var goods6 = document.getElementById("goods6");
            // if (SportType == 1) {
            //     web1.style.display = 'none';
            //     goods1.style.display = 'block';
            // } else {
            //     web1.style.display = 'block';
            //     goods1.style.display = 'none';
            // }
            // if (EatType == 1) {
            //     web2.style.display = 'none';
            //     goods2.style.display = 'block';
            // } else {
            //     web2.style.display = 'block';
            //     goods2.style.display = 'none';
            // }
            // if (BodyType == 1) {
            //     web3.style.display = 'none';
            //     goods3.style.display = 'block';
            // } else {
            //     web3.style.display = 'block';
            //     goods3.style.display = 'none';
            // }
            // if (SeasonType == 1) {
            //     web4.style.display = 'none';
            //     goods4.style.display = 'block';
            // } else {
            //     web4.style.display = 'block';
            //     goods4.style.display = 'none';
            // }
            // if (WorkType == 1) {
            //     web5.style.display = 'none';
            //     goods5.style.display = 'block';
            // } else {
            //     web5.style.display = 'block';
            //     goods5.style.display = 'none';
            // }
            // if (FaceType == 1) {
            //     web6.style.display = 'none';
            //     goods6.style.display = 'block';
            // } else {
            //     web6.style.display = 'block';
            //     goods6.style.display = 'none';
            // }
            // // WorkType.onchange = function () {
            // //     if (WorkType == 1) {
            // //         web5.style.display = 'none';
            // //         goods5.style.display = 'block';
            // //     } else {
            // //         web5.style.display = 'block';
            // //         goods5.style.display = 'none';
            // //     }
            // // };
            // // FaceType.onchange = function () {
            // //     if (FaceType == 1) {
            // //         web6.style.display = 'none';
            // //         goods6.style.display = 'block';
            // //     } else {
            // //         web6.style.display = 'block';
            // //         goods6.style.display = 'none';
            // //     }
            // // };
            // var SportType2 = document.getElementById("c-sport_type");
            // var EatType2 = document.getElementById("c-eat_type");
            // var SeasonType2 = document.getElementById("c-season_type");
            // var BodyType2 = document.getElementById("c-body_type");
            // var WorkType2 = document.getElementById("c-work_type");
            // var FaceType2 = document.getElementById("c-face_type");
            // SportType2.onchange = function () {
            //     if (SportType2.value == 1) {
            //         web1.style.display = 'none';
            //         goods1.style.display = 'block';
            //     } else {
            //         web1.style.display = 'block';
            //         goods1.style.display = 'none';
            //     }
            // };
            // EatType2.onchange = function () {
            //     if (EatType2.value == 1) {
            //         web2.style.display = 'none';
            //         goods2.style.display = 'block';
            //     } else {
            //         web2.style.display = 'block';
            //         goods2.style.display = 'none';
            //     }
            // };
            // BodyType2.onchange = function () {
            //     if (BodyType2.value == 1) {
            //         web3.style.display = 'none';
            //         goods3.style.display = 'block';
            //     } else {
            //         web3.style.display = 'block';
            //         goods3.style.display = 'none';
            //     }
            // };
            // SeasonType2.onchange = function () {
            //     if (SeasonType2.value == 1) {
            //         web4.style.display = 'none';
            //         goods4.style.display = 'block';
            //     } else {
            //         web4.style.display = 'block';
            //         goods4.style.display = 'none';
            //     }
            // };
            // WorkType2.onchange = function () {
            //     if (WorkType2.value == 1) {
            //         web5.style.display = 'none';
            //         goods5.style.display = 'block';
            //     } else {
            //         web5.style.display = 'block';
            //         goods5.style.display = 'none';
            //     }
            // };
            // FaceType2.onchange = function () {
            //     if (FaceType2.value == 1) {
            //         web6.style.display = 'none';
            //         goods6.style.display = 'block';
            //     } else {
            //         web6.style.display = 'block';
            //         goods6.style.display = 'none';
            //     }
            // };
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});