<%@ page contentType="text/html;charset=UTF-8" %>
	<script>
    /**
     * 项目经理组织交底页面
     * */
    $(document).ready(function () {
        $('#projectTable').bootstrapTable({
            //请求方法
            method: 'post',
            //类型json
            dataType: "json",
            contentType: "application/x-www-form-urlencoded",
            //显示检索按钮
            showSearch: false,
            //显示刷新按钮
            showRefresh: false,
            //显示切换手机试图按钮
            showToggle: false,
            //显示 内容列下拉框
            showColumns: false,
            //显示到处按钮
            showExport: false,
            //显示切换分页按钮
            showPaginationSwitch: false,
            //最低显示2行
            minimumCountColumns: 2,
            //是否显示行间隔色
            striped: true,
            //是否使用缓存，默认为true，所以一般情况下需要设置一下这个属性（*）
            cache: false,
            //是否显示分页（*）
            pagination: true,
            //排序方式
            sortOrder: "asc",
            //初始化加载第一页，默认第一页
            pageNumber: 1,
            //每页的记录行数（*）
            pageSize: 10,
            //可供选择的每页的行数（*）
            pageList: [5, 10, 25, 50, 150],
            //这个接口需要处理bootstrap table传递的固定参数,并返回特定格式的json数据
            url: "${ctx}/sg/managementcenter/project/tearDownData?reserveProjectName=${construction.reserveProjectName}",
            //默认值为 'limit',传给服务端的参数为：limit, offset, search, sort, order Else
            //queryParamsType:'',
            ////查询参数,每次调用是会带上这个参数，可自定义
            queryParams: function (params) {
                var searchParam = $("#searchForm").serializeJSON();
                searchParam.pageNo = params.limit === undefined ? "1" : params.offset / params.limit + 1;
                searchParam.pageSize = params.limit === undefined ? -1 : params.limit;
                searchParam.orderBy = params.sort === undefined ? "" : params.sort + " " + params.order;
                return searchParam;
            },
            //分页方式：client客户端分页，server服务端分页（*）
            sidePagination: "server",
            contextMenuTrigger: "right",//pc端 按右键弹出菜单
            contextMenuTriggerMobile: "press",//手机端 弹出菜单，click：单击， press：长按。
            contextMenu: '#context-menu',
            onContextMenuItem: function (row, $el) {
                if ($el.data("item") == "edit") {
                    edit(row.id);
                } else if ($el.data("item") == "view") {
                    view(row.id);
                } else if ($el.data("item") == "delete") {
                    jp.confirm('确认要删除该表单记录吗？', function () {
                        jp.loading();
                        jp.get("${ctx}/sg/managementcenter/project/delete?id=" + row.id, function (data) {
                            if (data.success) {
                                $('#projectTable').bootstrapTable('refresh');
                                jp.success(data.msg);
                            } else {
                                jp.error(data.msg);
                            }
                        })
                    });
                }
            },

            onClickRow: function (row, $el) {
            },
            onShowSearch: function () {
                $("#search-collapse").slideToggle();
            },
            columns:
                [{
                    field: 'reserveProjectName',
                    width:160,
                    title: '储备项目暂定名称',
                }
                    , {
                    field: 'projectId',
                    width:150,
                    title: '项目定义',
                }
                    , {
                    field: 'projectName',
                    width:150,
                    title: '项目名称',
                }
                    , {
                    field: 'tearDown.reservedName',
                    width:150,
                    title: '基础设备材料名称',
                }
                    , {
                    field: 'tearDown.reserveModel',
                    width:150,
                    title: '基础-型号',
                }
                    , {
                    field: 'tearDown.reserveUnit',
                    width:150,
                    title: '基础-单位',
                }
                    , {
                    field: 'tearDown.reserveNumber',
                    width:150,
                    title: '基础-数量',
                }
                    , {
                    field: 'tearDown.reserveBalance',
                    width:150,
                    title: '基础-差额',
                }
                    , {
                    field: 'tearDown.reserveNotes',
                    width:150,
                    title: '基础-备注',
                }  , {
                    field: 'tearDown.confessionNumber',
                    width:150,
                    title: '交底变更-数量',
                }
                    , {
                    field: 'tearDown.confessionDifference',
                    width:150,
                    title: '交底变更-差额',
                }
                    , {
                    field: 'tearDown.confessionNotes',
                    width:150,
                    title: '交底变更-备注',
                }
                    , {
                    field: 'tearDown.changeNumber',
                    width:150,
                    title: '设计变更-数量',
                }
                    , {
                    field: 'tearDown.changeDifference',
                    width:150,
                    title: '设计变更-差额',
                }
                    , {
                    field: 'tearDown.changeNotes',
                    width:150,
                    title: '设计变更-备注',
                }
                ]
        })

        jp.ajaxForm("#inputForm", function (data) {
            if (data.success) {
                jp.success(data.msg);
                jp.go("${ctx}/managementcenter/divide");
            } else {
                jp.error(data.msg);
                $("#inputForm").find("button:submit").button("reset");
            }
        });

        $('#startTime').datetimepicker({
            format: "YYYY-MM-DD HH:mm:ss"
        });
        $('#endTime').datetimepicker({
            format: "YYYY-MM-DD HH:mm:ss"
        });
        //富文本初始化
        $('#reason').summernote({
            height: 300,
            lang: 'zh-CN',
            readonly: true,
            callbacks: {
                onChange: function (contents, $editable) {
                    $("input[name='reason']").val($('#reason').summernote('code'));//取富文本的值
                }
            }
        });
        $("#btnMaterial").click(function () {
            jp.open({
                type: 2,
                area: [500, 200],
                auto: true,
                title:"导入数据",
                content: "${ctx}/tag/importExcel" ,
                btn: ['确定', '关闭'],
                btn1: function(index, layero){
                    var iframeWin = layero.find('iframe')[0]; //得到iframe页的窗口对象，执行iframe页的方法：iframeWin.method();
                    iframeWin.contentWindow.importExcel('${ctx}/managementcenter/activiti/btnMaterial', function (data) {
                        if(data.success){
                            jp.success(data.msg);
                            jp.close(index);
                        }else{
                            jp.error(data.msg);
                            jp.close(index);
                        }

                    });//调用保存事件
                    return false;
                },
                btn2: function(index){
                    jp.close(index);
                }
            })
        })

        $("#btnInReason").click(function(){
            jp.open({
                type: 2,
                area: [500, 200],
                auto: true,
                title:"导入数据",
                content: "${ctx}/tag/importExcel" ,
                btn: ['确定', '关闭'],
                btn1: function(index, layero){
                    var iframeWin = layero.find('iframe')[0]; //得到iframe页的窗口对象，执行iframe页的方法：iframeWin.method();
                    iframeWin.contentWindow.importExcel('${ctx}/sg/managementcenter/project/importConTear?jumpName=${construction.reserveProjectName}', function (data) {
                        if(data.success){
                            jp.success(data.msg);
                            refresh2();
                        }else{
                            jp.error(data.msg);
                        }
                        jp.close(index);
                    });//调用保存事件
                    return false;
                },
                btn2: function(index){
                    jp.close(index);
                }
            });
        });

        $("#agree").click(function () {
            jp.prompt("审核意见", function (message) {
                jp.post("${ctx}/act/task/importTable",
                    {
                        "taskId":"${construction.act.taskId}",
                        "taskName":"${construction.act.taskName}",
                        "taskDefKey":"${construction.act.taskDefKey}",
                        "procInsId":"${construction.act.procInsId}",
                        "procDefId":"${construction.act.procDefId}",
                        "flag":"yes",
                        "comment":window.encodeURI(message)
                    },
                    function (data) {
                        if(data.success){
                            jp.success(data.msg);
                            jp.go("${ctx}/act/task/todo")
                        }
                    })
            });
        });
    })

    function refresh2() {
        $('#projectTable').bootstrapTable('refresh');
    }

</script>
