/* * 版 本 PIT-ADMS V7.0.3 敏捷开发框架
 * Copyright (c) 2013-2018 Hexagon PPM
 * 创建人：超级管理员
 * 日  期：2022-03-14 10:58
 * 描  述：业务表
 */
var refreshGirdData;
var bootstrap = function ($, learun) {
    "use strict";
    var page = {
        init: function () {
            page.initGird();
            page.bind();
        },
        bind: function () {
            // 查询
            $('#btn_Search').on('click', function () {
                page.search();
            });
            // 刷新
            $('#lr_refresh').on('click', function () {
                location.reload();
            });
            // 新增
            $('#lr_add').on('click', function () {
                learun.layerForm({
                    id: 'form',
                    title: '新增',
                    url: top.$.rootUrl + '/ZZDT_EC/RefCB/Form',
                    width: 330,
                    height: 330,
                    callBack: function (id) {
                        return top[id].acceptClick(refreshGirdData);
                    }
                });
            });
            // 编辑
            $('#lr_edit').on('click', function () {
                var keyValue = $('#gridtable').jfGridValue('ID');
                if (learun.checkrow(keyValue)) {
                    learun.layerForm({
                        id: 'form',
                        title: '编辑',
                        url: top.$.rootUrl + '/ZZDT_EC/RefCB/Form?keyValue=' + keyValue,
                        width: 330,
                        height: 330,
                        callBack: function (id) {
                            return top[id].acceptClick(refreshGirdData);
                        }
                    });
                }
            });
            // 删除
            $('#lr_delete').on('click', function () {
                var keyValue = $('#gridtable').jfGridValue('ID');
                if (learun.checkrow(keyValue)) {
                    learun.layerConfirm('是否确认删除该开关！', function (res) {
                        if (res) {
                            learun.deleteForm(top.$.rootUrl + '/ZZDT_EC/RefCB/DeleteForm', { keyValue: keyValue }, function () {
                                refreshGirdData();
                            });
                        }
                    });
                }
            });
        },
        initGird: function () {
            $('#gridtable').jfGrid({
                url: top.$.rootUrl + '/ZZDT_EC/RefCB/GetPageList',
                headData: [
                    { label: '型号', name: 'Name', width: 100, align: "left", sort: false },
                    { label: '分类', name: 'breakerType', width: 100, align: "left", sort: false },
                    { label: '供应商', name: 'supplier', width: 100, align: "left", sort: false },
                    //{
                    //    label: "是否复制数据", name: "IsCopyData", width: 120, align: "center", sort: false,
                    //    formatter: function (cellvalue) {
                    //        if (cellvalue == '1') {
                    //            return "是";
                    //        } else {
                    //            return "否";
                    //        }
                    //    }
                    //},
                    { label: '设定值', name: 'Capacity', width: 300, align: "left", sort: false },
                    { label: '框架值', name: 'Capacity_Max', width: 100, align: "left", sort: false },
                    { label: '', name: '', width: 1, sort: false },
                ],
                mainId: 'ID',
                isPage: true
            });
            page.search();
        },
        search: function (param) {
            param = param || {};
            param.Name = $('#Name').val();
            $('#gridtable').jfGridSet('reload', { queryJson: JSON.stringify(param) });
        }
    };
    refreshGirdData = function () {
        $('#gridtable').jfGridSet('reload');
    };
    page.init();
}
