<%@ Page Language="C#" AutoEventWireup="true" CodeFile="printTemplateDesign.aspx.cs" Inherits="eFrameWork.Manage.printTemplateDesign" %><!DOCTYPE html>
<html>
<head>
    <title><asp:Literal ID="LitTitle" runat="server" /></title>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=9;IE=8;IE=7;" />
	<meta http-equiv="X-UA-Compatible" content="edge" /><!--标准模式-->
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">	
	<meta name="renderer" content="webkit"><!--极速模式-->
	<meta name="renderer" content="webkit|ie-comp|ie-stand"> <!--极速模式，兼容模式，IE模式打开-->
	<meta http-equiv="imagetoolbar" content="no" />
    <style>
        html, body {
        width:100%;height:100%;margin:0;padding:0;
        }
    </style>
    <link href="../Plugins/layui226/css/layui.css?ver=<%=Common.Version %>" rel="stylesheet" type="text/css" />     
    <link href="../Plugins/eControls/default/style.css?ver=<%=Common.Version %>" rel="stylesheet" type="text/css" />   
    <link href="../Plugins/Theme/default/style.css?ver=<%=Common.Version %>" rel="stylesheet" type="text/css" />   
	<link href="../Plugins/Theme/manage/style.css?ver=<%=Common.Version %>" rel="stylesheet" type="text/css" />
	<script src="../Scripts/Init.js?ver=<%=Common.Version %>"></script>
</head>
<body>


<link rel="stylesheet" href="../Plugins/luckysheet/pluginsCss.css" />
<link rel="stylesheet" href="../Plugins/luckysheet/plugins.css" />
<link rel="stylesheet" href="../Plugins/luckysheet/luckysheet.css" />
<link rel="stylesheet" href="../Plugins/luckysheet/iconfont.css" />
<script src="../Plugins/luckysheet/plugin.js"></script>
<script src="../Plugins/luckysheet/luckysheet.umd.js"></script>

<div style="margin-top:10px;margin-right:10px;text-align:right;"><a class="button" href="javascript:;" onclick="bindField();"><span><i class="add">绑定数据</i></span></a></div>
<div style="margin:10px;">
<div id="luckysheet" style="margin:0px;padding:0px;height:500px;"></div>
</div>

<script>
    function setFunction(schr,echr)
    {
        var range = luckysheet.getRange();
        if(range)
        {
            var v=luckysheet.getCellValue(range[0].row[0],range[0].column[0]);
            if(v==null || v.length==0)
            {
                layer.msg('请先引用数据!');
                return;
            }
            if(v.indexOf(schr)>-1)
            {
                layer.msg('请勿重复引用!');
                return;
            }
            luckysheet.setCellValue(range[0].row[0],range[0].column[0],schr + v + echr);
        }
    }
    function setValue(v)
    {
        var range = luckysheet.getRange();
        if(range)
        {
            luckysheet.setCellValue(range[0].row[0],range[0].column[0],v);
        }
    }
    function appendValue(v)
    {  
        var range = luckysheet.getRange();
        if(range)
        {
            var ov=luckysheet.getCellValue(range[0].row[0],range[0].column[0])||'';
            luckysheet.setCellValue(range[0].row[0],range[0].column[0],ov+v);
        }
    }
    function bindField()
    {
        var url = "setModelField.aspx?modelid=" + document.location.href.getquerystring("modelid");
        layer.open({
            type: 2,
            title: "绑定数据",
            shade:0,
            shadeClose: true ,//点击遮罩关闭层
            area: ["380px", "100%"],
            offset: 'r',
            content: url,
            success: function (layero, index) {
              arrLayerIndex.push(index);
          },
          cancel: function (index, layero) {
              arrLayerIndex.pop();
          }

        });
    };

    function updata()
    {
        var url = document.location.href;
        url = url.addquerystring("act", "update");
        var designJson = luckysheet.getAllSheets();
        var designData = luckysheet.toJson();
        $.ajax({
            type: 'post',
            url: url,
            data: { designJson: JSON.stringify(designJson),designData: JSON.stringify(designData.data)},
            dataType: "json",
            success: function (data) {
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
            }
        });
    };


    $(function ()
    {
        //timer.start();

    $("#luckysheet").css("height",( $("body").height() - 20) + 'px');
        var options = { // 公共配置项
            container: 'luckysheet', // luckysheet为容器id
            lang: 'zh', // 设定表格语言
            title: '', // 设定表格名称
            forceCalculation: true,
            index: '0',
            status: '1',
            order: '0',
            hide: '0',
            column: 25, // 列数
            row: 30, // 行数
            showtoolbar: true, // 工具栏
            showinfobar: false, // 信息栏
            showsheetbar: false, // 底部sheet页
            sheetFormulaBar: true, // 是否显示公式栏
            showsheetbarConfig: {},// 自定义底部sheet页
            sheetRightClickConfig: {},//自定义底部sheet页右击菜单 
            //showtoolbarConfig:{}, // 自定义配置工具栏
            //showtoolbarConfig: { undoRedo: false, paintFormat: false }, // 隐藏撤销重做和格式刷
            //showtoolbar: false,
            //showtoolbarConfig: { toolbar: ['undo', 'redo', 'bold', 'italic'] }, // 仅保留撤销、重做、加粗、斜体

            hook: {
                updated: function (operate) {
                    updata();
                },

            },
            cellRightClickConfig:{}, // 右键配置

            data:<%=designJson%>,
            data2: [  // 表格sheet的个数和配置项
                {
                    "name": "Sheet1",
                    "defaultRowHeight": 25
                },


            ]
        };


        // 初始化表格
        luckysheet.create(options);
        //luckysheet.bind("cellEdit", callback);
        //luckysheet.bind("cellEdit", function () { document.title = "OKK"; })

    });
</script>
</body>
</html>