<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/AppMaster.Master"
    Inherits="System.Web.Mvc.ViewPage<QMAPP.MD.Web.Models.PbomModel>" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	Bom信息列表
</asp:Content> 
     
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <%=Html.QPSeach(100,true) %>
    <table id="condiTable">
        <tr>
         <th align="right">
                <%=Html.QV(p => p.PBOM_CODE)%>
            </th>
            <td>
                <%=Html.QC(p => p.PBOM_CODE)%>
            </td>
            <th align="right">
                <%=Html.QV(p => p.VER_NUM)%>
            </th>
            <td >
                <%=Html.QC(p => p.VER_NUM)%>
            </td>
           
            <th align="right">
                <%=Html.QV(p => p.ITEM_NUM)%>
            </th>
            <td>
                <%=Html.QC(p => p.ITEM_NUM)%>
            </td>
            </tr>
           <tr>
               <th align="right">
                   <%=Html.QV(p => p.FACTORY_CODE)%>
               </th>
               <td>
                   <%=Html.QC(p => p.FACTORY_CODE)%>
               </td>
            <th align="right">
                <%=Html.QV(p => p.MATERIAL_CODE)%>
            </th>
            <td colspan="5">
                <%=Html.QC(p => p.MATERIAL_CODE)%>
                <script type="text/javascript" language="javascript">
                    $(function () {
                        $('#MATERIAL_CODE').combotree({
                            panelHeight: '250',
                            panelWidth: '450',
                            onBeforeSelect: function (node) {
                                if (!$(this).tree('isLeaf', node.target)) {
                                    return false;
                                }
                            }
                        });
                    })  
                </script>
            </td>
        </tr>
    </table>
    <div style="left: 1px; position: relative;"></div>
    <%=Html.QPEnd()%>
    <%=Html.QPList() %>
    <%=Html.QDateGrid<QMAPP.MD.Web.Models.PbomModel>(Model)%>
    <%=Html.QPEnd() %>
    <%=Html.Hidden("selectKey")%>
    <script language="javascript" type="text/javascript">
        $(function () {
            //工厂
            $('#FACTORY_CODE').combobox({
                onSelect: function () {
                    var selectCode = $('#FACTORY_CODE').combobox('getValue');
                    if (selectCode != "") {
                        //获取下拉数据源
                        $('#MATERIAL_CODE').combotree({
                            url: "/Dict/GetFactoryMaterialTree?factoryCode=" + selectCode,
                            editable: 'false',
                        });
                        $('#MATERIAL_CODE').combotree("setValue", "");
                    }
                    else {
                        //清空工序下拉框
                        $('#MATERIAL_CODE').combotree("loadData", "");
                        $('#MATERIAL_CODE').combotree("select", "");
                    }
                }
            });
        });
        //添加
        function Add() {
            openAppWindow1('Bom信息添加', 'PbomEdit', '380', '420');
        }
        //修改
        function Update() {
            var ids = getSelectKey();
            if (ids == "") {
                MSI("提示", "请选择修改记录。");
                return;
            }
            if (ids.indexOf(":") > 0) {
                MSI("提示", "每次只能修改一条记录。");
                return;
            }
            document.getElementById("selectKey").value = ids;
            openAppWindow1('Bom信息修改', 'PbomEdit?PID=' + ids, '580', '420');
        }
        //删除
        function Delete() {
            var ids = getSelectKey();
            var idsPbomCode = getSelectColumnValues("PBOM_CODE");
            if (ids == "") {
                MSI("错误", "至少选择一条记录");
            }
            else {
                document.getElementById("selectKey").value = ids;
                MSQ("提示", "确定要删除选中的记录吗?", function () {
                    submitByButton("PbomDelete");
                })
            }
        }
        //配置Bom信息
        function PbomConfig() {
            var ids = getSelectKey();
            var idsPbomCode = getSelectColumnValues("PBOM_CODE");
            //var factory = getSelectColumnValues("FACTORY_CODE");
            if (ids == "") {
                MSI("提示", "请选择要配置的Bom。");
                return;
            };
            if (ids.indexOf(":") > 0) {
                MSI("提示", "每次只能选择一个Bom进行配置。");
                return;
            }
            var row = $('#QDateGrid').datagrid('getSelected');
//            if (row.MATERIAL_LAYER == 0) {
//                MSI("提示", "该Bom层级为0,不允许添加Bom明细。");
//                return;
            //            }
            //debugger;
            document.getElementById("selectKey").value = ids;
            window.location.href = "/Pbom/PbomItemTree?PBOM_CODE_PAR=" + idsPbomCode + "&ROUTE_CODE=" + row.ROUTE_CODE + "&FACTORY_CODE=" + row.FACTORY_CODE;

        }
        $(function () {

            $('#FACTORY_CODE').combobox({
                panelWidth: '350'

            });

        });

    </script>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ToolContent" runat="server">
    <table cellpadding="0" cellspacing="0">
        <tr>
            <td align="center">
                <%=Html.QTButtonSearch("Pbom", "List", "List(1)", QMAPP.Common.Web.SystemLimit.isLimt)%>
                <%=Html.QTButtonAdd("Pbom", "Add", "Add()", QMAPP.Common.Web.SystemLimit.isLimt)%>  
                <%=Html.QTButtonDelete("Pbom", "Delete", "Delete()", QMAPP.Common.Web.SystemLimit.isLimt)%>
                <%=Html.QTButton("setPbomConfig", "PbomConfig", QMFrameWork.WebUI.IconCls.add, "PbomConfig()", QMAPP.Common.Web.SystemLimit.isLimt)%>
            </td>
        </tr>
    </table>
</asp:Content>