<%@ Page Language="C#" %>

<%@ Register TagPrefix="aspxform" Namespace="XFormDesigner.Framework.Web.UI" Assembly="XFormDesigner.Framework" %>
<script runat="server">

    // Insert page code here
    //
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            string s = this.Request.Params["pdata"];
            this.labdata.Text = s;
        }
    }

</script>
<html xmlns:xform="xmlns:xform">
<head runat="server">
    <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
    <script src="../../../../Oimec/Script/jquery-3.2.1.js"></script>
    <script src="../../../../Oimec/Script/jquery-3.2.1.min.js"></script>
    <title>BPM Form</title>
    <style>
        BODY {
            FONT-SIZE: 12px;
            FONT-FAMILY: verdana;
        }

        TABLE {
            border-collapse: collapse;
            FONT-SIZE: 12px;
            FONT-FAMILY: verdana;
        }

        P {
            PADDING-RIGHT: 0px;
            PADDING-LEFT: 0px;
            PADDING-BOTTOM: 0px;
            MARGIN: 0px;
            PADDING-TOP: 0px;
            FONT-SIZE: 12px;
            FONT-FAMILY: verdana;
        }

        TD {
            padding: 1px;
        }

            TD.NoPadding {
                PADDING-RIGHT: 0px;
                PADDING-LEFT: 0px;
                PADDING-BOTTOM: 0px;
                PADDING-TOP: 0px;
            }
        /*INPUT {height: 15px}*/
        INPUT.UL {
            BORDER-RIGHT: medium none;
            BORDER-TOP: medium none;
            BORDER-LEFT: medium none;
            BORDER-BOTTOM: #33ff33 1px solid;
        }

        TEXTAREA {
            FONT-SIZE: 12px;
        }

        input {
            vertical-align: middle; /*margin-right:-3px*/
        }

        /*titlestyle {
        font-size:100px;
        font-weight:bold;
        font-family:黑体；
        }*/
    </style>
    <script type="text/javascript">

        function getXValue(id) {
            return agent.Eles[document.getElementById(id).getAttribute("xform_xele_index")].getValue();
        }

        function setXValue(id, value) {
            agent.Eles[document.getElementById(id).getAttribute("xform_xele_index")].setValue(value);
        }

        Ext.onReady(function () {

            var data = getXValue("labdata");
            MakeHtml(data);

        });

        //制作页面
        function MakeHtml(v) {

            var data = eval('(' + v + ')');

            setXValue("GYS", data.supplierid + " -" + data.suppliername);
            setXValue("WLPZH", data.voucher);
            setXValue("PZTTWB", data.text);

            //产品信息
            var product_list = data.lineItem;
            var pid = "table_product";
            var ptableObj = document.getElementById(pid);
            var rowNum = ptableObj.length;

            //序列号
            var sid = "table_serial";
            var stableObj = document.getElementById(sid);
            var srowNum = stableObj.length;
            var ywy = "";
            for (var i = 0; i < product_list.length; i++) {
                var item = product_list[i];

                ywy = product_list[0].salesman == "" ? "备货" : product_list[0].salesman;

                var tskc = item.so == "" ? "" : "E";
                var trHtml = "<tr align='center' style='height:20px;border-top: black 1px solid; border-right: black 1px solid; border-bottom: black 1px solid; border-left: black 1px solid'>" +
                   "<td style='font-size: 15px;border-right: black 1px solid'>" + item.plant + "</td>" +
                   "<td style='font-size: 15px;border-right: black 1px solid'>" + item.storage + "</td>" +
                   "<td style='font-size: 15px;;border-right: black 1px solid'>" + item.psapid + "-" + item.pname + "|" + item.pmodel + "</td>" +
                   "<td style='font-size: 15px;;border-right: black 1px solid'>" + item.pnumber + "</td>" +
                   "<td style='font-size: 15px;;border-right: black 1px solid'>" + "+" + "</td>" +
                   "<td style='font-size: 15px;;border-right: black 1px solid'>" + item.batch + "</td>" +
                   "<td style='font-size: 15px;;border-right: black 1px solid'>" + tskc + "</td>" +
                   "<td style='font-size: 15px;;border-right: black 1px solid'>" + item.so + "</td>" +
                   "<td style='font-size: 15px;;border-right: black 1px solid'>" + item.soItemNo + "</td>" +
                   "<td style='font-size: 15px;;border-right: black 1px solid'>" + item.po + "</td>" +
                   "<td style='font-size: 15px;;border-right: black 1px solid'>" + item.poItemNo + "</td>";
                addTr(pid, 0, trHtml);

                if (item.serialNo.length > 0) {

                    var trHtml_serial = "<tr align='center' style='height:20px;border-top: black 1px solid; border-right: black 1px solid; border-bottom: black 1px solid; border-left: black 1px solid'>" +
                    "<td style='font-size: 15px;;border-right: black 1px solid'>" + item.psapid + "-" + item.pname + "|" + item.pmodel + "</td>" +
                    "<td style='font-size: 15px;;border-right: black 1px solid'>" + item.serialNo + "</td>";
                    //alert(trHtml);
                    addTr(sid, 0, trHtml_serial);

                }
            }
            var myDate = new Date();
            setXValue("YWY", ywy);
            setXValue("PZRQ", (new Date().Format("yyyy-MM-dd")));
            setXValue("ZH", userToken.Account);
            XFormOnChange(agent.Eles[document.getElementById('ZH').getAttribute("xform_xele_index")]);

        }

        function addTr(id, row, trHtml) {
            //获取table最后一行 $("#tab tr:last")
            //获取table第一行 $("#tab tr").eq(0)
            //获取table倒数第二行 $("#tab tr").eq(-2)
            var $tr = $("#" + id + " tr").eq(row - 1);
            if ($tr.length == 0) {
                alert("指定的table id或行数不存在！");
                return;
            }
            $tr.after(trHtml);
        }

        // 对Date的扩展，将 Date 转化为指定格式的String
        // 月(M)、日(d)、小时(h)、分(m)、秒(s)、季度(q) 可以用 1-2 个占位符，
        // 年(y)可以用 1-4 个占位符，毫秒(S)只能用 1 个占位符(是 1-3 位的数字)
        // 例子：
        // (new Date()).Format("yyyy-MM-dd hh:mm:ss.S") ==> 2006-07-02 08:09:04.423
        // (new Date()).Format("yyyy-M-d h:m:s.S") ==> 2006-7-2 8:9:4.18

        Date.prototype.Format = function (fmt) { // author: meizz
            var o = {
                "M+": this.getMonth() + 1, // 月份
                "d+": this.getDate(), // 日
                "h+": this.getHours(), // 小时
                "m+": this.getMinutes(), // 分
                "s+": this.getSeconds(), // 秒
                "q+": Math.floor((this.getMonth() + 3) / 3), // 季度
                "S": this.getMilliseconds() // 毫秒
            };
            if (/(y+)/.test(fmt))
                fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
            for (var k in o)
                if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
            return fmt;
        }


    </script>
</head>
<body>
    <form runat="server">
        <div id="div_post" style="height: 20px">
            <aspxform:XLabel ID="labdata" runat="server" Width="50px" Text="Label" HiddenExpress="1" name="labdata"></aspxform:XLabel>
        </div>
        <div id="div_content">
        </div>
        <table width="800" align="center" style="border-right: medium none; border-bottom: medium none; border-left: medium none" border="0" cellspacing="0" cellpadding="0">
            <tbody>
                <tr>
                    <td style="border-bottom: medium none" colspan="2">
                        <div align="right">
                            <aspxform:XPrintButton ID="XPrintButton1" runat="server" Orientation="Horizontal" PrintOut="False"></aspxform:XPrintButton>
                        </div>
                    </td>
                </tr>
                <tr>
                    <td width="850" align="center" style="font-weight: bold; border-top: medium none; border-right: medium none; border-bottom: medium none; text-align: center; border-left: medium none">
                        <font face="微软雅黑" size="20"><strong>东方中科出/入库单</strong></font>
                    </td>
                </tr>
            </tbody>
        </table>
        <br />
        <br />
        <table width="850" align="center" border="0" cellspacing="0" cellpadding="0">
            <tbody>
                <tr>
                    <td style="height: 25px; width: 60%" class="titlestyle">
                        <font face="宋体" size="4"><strong>物料凭证号： 
                        <aspxform:XLabel id="WLPZH" runat="server"></strong></font></aspxform:XLabel>
                    </td>
                    <td style="text-align: left; width: 40%">
                        <font face="宋体" size="4"><strong>移动类型： </strong></font>
                        <font face="宋体" size="4"><strong>101 -收货到库存地 </strong></font></td>
                </tr>
                <tr>
                    <td style="height: 25px">
                        <font face="宋体" size="4"><strong>供应商：<aspxform:XLabel id="GYS" runat="server"></aspxform:XLabel>
                        </strong></font></td>
                    <td style="text-align: left">
                        <font face="宋体" size="4"><strong>凭证抬头文本：<aspxform:XLabel id="PZTTWB" runat="server"></aspxform:XLabel>
                        </strong></font></td>

                </tr>
                <%-- <tr>
                    <td style="HEIGHT: 25px">
                        <font face="宋体" size="4"><strong>交货单号：<aspxform:XLabel id="JHDH" runat="server"></aspxform:XLabel>
                        </strong></font></td>
                    <td style="TEXT-ALIGN: right">
                        <font face="宋体" size="4"><strong></strong></font></td>
                    <td style="TEXT-ALIGN: left">
                        <font face="宋体" size="4"><strong></strong></font></td>
                </tr>--%>
            </tbody>
        </table>
        <br />
        <table width="850" align="center" id="table_product" style="border-top: medium none; border-right: medium none; border-left: medium none" border="0" cellspacing="0" cellpadding="0">
            <tbody>
                <tr style="border-top: black 1px solid; border-right: black 1px solid; border-bottom: black 1px solid; text-align: center; border-left: black 1px solid">
                    <td width="50" height="18" style="border-right: black 1px solid; font-weight: bold; font-size: 16px">
                        <asp:Label ID="Label27" runat="server" Text="工厂" Font-Bold="true"></asp:Label></td>
                    <td width="100" style="border-right: black 1px solid; font-weight: bold; font-size: 16px">
                        <asp:Label ID="Label3" runat="server" Text="库存地" Font-Bold="true"></asp:Label></td>
                    <td width="200" style="border-right: black 1px solid; font-weight: bold; font-size: 16px">
                        <asp:Label ID="Label31" runat="server" Text="物料" Font-Bold="true"></asp:Label></td>
                    <td width="70" style="border-right: black 1px solid; font-weight: bold; font-size: 16px">&nbsp;<asp:Label ID="Label33" runat="server" Text="数量" Font-Bold="true"></asp:Label></td>
                    <td width="100" style="border-right: black 1px solid; font-weight: bold; font-size: 16px">
                        <asp:Label ID="Label34" runat="server" Text="记账符号" Font-Bold="true"></asp:Label></td>
                    <td width="80" style="border-right: black 1px solid; font-weight: bold; font-size: 16px">
                        <asp:Label ID="Label5" runat="server" Text="批次" Font-Bold="true"></asp:Label></td>
                    <td width="100" style="border-right: black 1px solid; font-weight: bold; font-size: 16px">
                        <asp:Label ID="Label1" runat="server" Text="特殊库存" Font-Bold="true"></asp:Label></td>
                    <td width="80" style="border-right: black 1px solid; font-weight: bold; font-size: 16px">
                        <asp:Label ID="Label2" runat="server" Text="SO号" Font-Bold="true"></asp:Label></td>
                    <td width="80" style="border-right: black 1px solid; font-weight: bold; font-size: 16px">
                        <asp:Label ID="Label4" runat="server" Text="SO行号" Font-Bold="true"></asp:Label></td>
                    <td width="100" style="border-right: black 1px solid; font-weight: bold; font-size: 16px">
                        <asp:Label ID="Label6" runat="server" Text="PO号" Font-Bold="true"></asp:Label></td>
                    <td width="80" style="border-right: black 1px solid; font-weight: bold; font-size: 16px">
                        <asp:Label ID="Label7" runat="server" Text="PO行号"></asp:Label></td>
                </tr>
            </tbody>
        </table>
        <br />
        <table width="850" align="center" id="table_serial" style="border-top: medium none; border-right: medium none; border-left: medium none" border="0" cellspacing="0" cellpadding="0">
            <tbody>
                <tr style="border-top: black 1px solid; border-right: black 1px solid; border-bottom: black 1px solid; text-align: center; border-left: black 1px solid">
                    <td width="35%" height="18" style="border-right: black 1px solid; font-weight: bold; font-size: 16px">
                        <asp:Label ID="Label8" runat="server" Text="物料"></asp:Label></td>
                    <td width="65%" style="border-right: black 1px solid; font-weight: bold; font-size: 16px">
                        <asp:Label ID="Label9" runat="server" Text="序列号"></asp:Label></td>
                </tr>
            </tbody>
        </table>
        <br />
        <table width="850" align="center">
            <tbody>
                <tr>
                    <td style="font-size: 15px;">账号:<aspxform:XLabel ID="ZH" runat="server" XDataBind="ZH"></aspxform:XLabel>
                        <aspxform:XDropDownList ID="XDropDownList1" HiddenExpress="1" runat="server" XDataSource="TableName:V_DF_HR_BasicInfo;Filter:AttendanceKakaNO->ZH" DataMap="Name->XM"></aspxform:XDropDownList>
                    </td>
                </tr>
                <tr>
                    <td style="font-size: 15px;">姓名:<aspxform:XLabel ID="XM" runat="server" XDataBind="XM"></aspxform:XLabel>
                    </td>
                </tr>
                <tr>
                    <td style="font-size: 15px;">凭证日期:<aspxform:XLabel ID="PZRQ" runat="server"></aspxform:XLabel>
                    </td>
                </tr>
                <tr>
                    <td style="font-size: 80px; font-weight: bold; text-align: center; font-family: 微软雅黑">
                        <aspxform:XLabel ID="YWY" runat="server"></aspxform:XLabel>
                    </td>
                </tr>
                <tr>
                    <td style="font-size: 60px; text-align: center">共___件</td>
                </tr>
            </tbody>
        </table>
    </form>
</body>
</html>
