@model Com._9pm2.ClientWeb.Models.QuotationModel
@{ ViewBag.Title = Model.Id == 0 ? "开报价单" : "修改报价单";}

<script src="../../Scripts/ordercommon.js?vn=20180813"></script>
<script src="../../Scripts/quotationedit.js?vn=20180813"></script>

<div id="divOrder">
    <div class="error-msg"></div>
    <div id="divOrderContent" style="min-height:240px">

        <table id="tableEdit" class="font85 tableEdit" style="width:100%">

            <tr>
                <td class="label">客户</td>
                <td>
                    @Html.DropDownList("CustomerNo", new SelectList(Model.DdlCustomer, "ItemValue", "ItemText"), new { @class = "form-control max-width-180" })
                    <input type="text" placeholder="快速搜索" style="width:100px" class="form-control" id="txtCustomer" />&nbsp;
                    @Html.TextBox("CustomerName", null, new { maxlength = "100", placeholder = "临时客户请填写客户名称", @style = "width:180px", @class = "form-control" })&nbsp;
                    <a href="javascript:void(0)" onclick="newCustomer()">快速创建客户</a>
                </td>

            </tr>
            <tr>
                <td class="label">联系人</td>
                <td>
                    <select id="ContactNo" name="ContactNo" class="form-control"></select>
                    @Html.TextBox("Contact", null, new { maxlength = "100", title = "空格分隔，比如：张三 13888888888", @style = "width:180px", @class = "form-control" })&nbsp;
                    <a href="javascript:void(0)" onclick="newContact()">快速创建联系人</a>
                </td>
            </tr>

            <tr>

                <td class="label">报价日期</td>
                <td>
                    @Html.TextBox("QuotationDate", Model.QuotationDate.ToString("yyyy-MM-dd"), new { maxlength = "10", @class = "text-date" }) <span class="redStar">*</span>
                </td>
            </tr>

            <tr>
                <td class="label">明细</td>
                <td>
                    <button onclick="addDetail()" type="button" class="btn btn-default">添加明细项目</button>
                    <table class="tableDetail small-control" style="width:100%;max-width:1200px;">
                        <thead>
                            <tr class="title">
                                <th>业务类型</th>
                                <th>名称</th>
                                <th>材料</th>
                                <th style="width:60px">单位</th>
                                <th>工艺</th>
                                <th>详细规格</th>
                                <th>备注</th>
                                <th style="width:60px">数量</th>
                                <th style="width:60px">单价</th>
                                <th style="width:80px">金额</th>
                                <th style="width:80px"></th>
                            </tr>
                        </thead>
                        <tbody id="tbodyDetail"></tbody>
                    </table>

                </td>
            </tr>
            <tr>
                <td class="label">其它费用</td>
                <td colspan="5">
                    安装费 @Html.TextBox("FeeInstallation", null, new { maxlength = "10", @class = "text-money amount" })&nbsp;&nbsp;
                    送货费 @Html.TextBox("FeeDelivery", null, new { maxlength = "10", @class = "text-money amount" })&nbsp;&nbsp;
                    设计费 @Html.TextBox("FeeDesign", null, new { maxlength = "10", @class = "text-money amount" })&nbsp;&nbsp;
                    其它费用 @Html.TextBox("FeeOther", null, new { maxlength = "10", @class = "text-money amount" })
                </td>
            </tr>
            <tr>
                <td class="label">开票信息</td>
                <td colspan="5">
                    @Html.DropDownList("TaxType", new SelectList(Model.DdlTaxType, "ItemValue", "ItemText"), new { @class = "form-control" })&nbsp;&nbsp;
                    税率 @Html.TextBox("TaxRatio", null, new { maxlength = "10", @class = "text-money tax-ratio" }) %&nbsp;&nbsp;
                    不含税金额 @Html.TextBox("TaxAmount", null, new { maxlength = "10", @readonly = "readonly", @class = "text-money amount" })&nbsp;&nbsp;
                    税金 @Html.TextBox("FeeTax", null, new { maxlength = "10", @readonly = "readonly", @class = "text-money amount" })
                </td>
            </tr>
            <tr>
                <td class="label">总金额</td>
                <td>
                    @Html.TextBox("MarketAmount", null, new { maxlength = "10", @class = "text-money amount", @readonly = "readonly" })&nbsp;<span class="redStar">*</span>
                </td>
            </tr>
            <tr>
                <td class="label">折扣金额</td>
                <td>
                    @Html.TextBox("Discount", null, new { maxlength = "10", @class = "text-money amount red-text" })
                </td>
            </tr>
            <tr>
                <td class="label">实际金额</td>
                <td>
                    @Html.TextBox("RealAmount", null, new { maxlength = "10", @class = "text-money amount", @readonly = "readonly" })&nbsp;<span class="redStar">*</span>
                </td>
            </tr>

            <tr>
                <td class="label">备注</td>
                <td>
                    @Html.TextArea("Memo", null, new { maxlength = "1000", style = "width:98%;height:80px;", @class = "form-control" })
                </td>
            </tr>
        </table>

    </div>
    <div style="text-align:right;margin:10px 0">
        <span id="errorMessage" class="error-msg"></span>
        <button type="button" class="btn btn-default" id="btnCancel">取消</button>
        <button type="button" class="btn btn-primary" id="btnSave">保存</button>
    </div>
</div>

<div id="divPriceTip" title="价格表" class="tableEdit" style="display:none">
    <div id="divPriceText" style="margin:20px 0;">

    </div>

    <div style="text-align:right;">
        <button type="button" class="btn-close" id="btnPriceTipClose" onclick="$('#divPriceTip').dialog('close');">关闭</button>
    </div>
</div>

<div id="divPriceHistory" title="客户历史价格" style="display:none">
    <div style="margin:0 0 10px 0;">
        <div class="list">
            <table id="tPriceHistory">
                <thead>
                    <tr class="title">
                        <th style="width:120px">客户</th>
                        <th style="width:100px">交易日期</th>
                        <th>详细规格</th>
                        <th style="width:60px">单价</th>
                        <th>备注</th>
                    </tr>
                </thead>
                <tbody id="priceHistoryList"></tbody>
            </table>
        </div>
    </div>

    <div style="text-align:right;">
        <button type="button" class="btn btn-default" id="btnPriceTipClose" onclick="$('#divPriceHistory').dialog('close');">关闭</button>
    </div>

</div>

<div id="popOrderDetail" title="明细" style="display: none">
    <div id="popOrderDetailC" class="list" style="overflow-y: auto;">
        <div class="error-msg"></div>
        <table class="tableEdit">
            <tr>
                <td class="label">
                    订单名称
                    <input type="hidden" id="hiddenSailPrice" />
                </td>
                <td>
                    <input type="text" id="QuotationName" style="width:100%;" />
                </td>
            </tr>

            <tr>
                <td class="label" title="业务类型不存在？请在“系统配置→订单模板配置”页面添加。">
                    业务类型
                </td>
                <td>
                    <select id="Category" class="select2"></select>
                    <input type="hidden" id="ReportCategory" />
                    <input type="hidden" id="Guid" />
                    <input type="hidden" id="Id" />
                </td>
            </tr>
            <tr>
                <td class="label">规格</td>
                <td>
                    <table id="tableDetail" class="tableDetail small-control" style="width:100%"></table>
                </td>
            </tr>
            <tr>
                <td class="label" title="材料不存在？请在“库存管理→材料管理”页面添加。">材料</td>
                <td>
                    @Html.DropDownList("MaterialId", new SelectList(Model.DdlMaterial, "ItemValue", "ItemText"), new { @class = "form-control select2" })
                    @Html.Hidden("StockNumber")
                </td>
            </tr>
            <tr>
                <td class="label">工艺</td>
                <td>
                    <div id="divTechnics" class="divTechnics"></div>
                </td>
            </tr>
            <tr>
                <td class="label">单位</td>
                <td>
                    @Html.DropDownList("PriceUnitId", new SelectList(Model.DdlPriceUnit, "ItemValue", "ItemText"), new { @class = "form-control" })
                </td>
            </tr>
            <tr>
                <td class="label">数量</td>
                <td>
                    @Html.TextBox("Number", null, new { maxlength = "10", @class = "text-money number" })
                </td>
            </tr>
            <tr>
                <td class="label">单价</td>
                <td>
                    @Html.TextBox("Price", null, new { maxlength = "10", @class = "text-money price" })
                    &nbsp;&nbsp;<a href="javascript:void(0);" style="text-decoration:underline; " onclick="OpenPriceTip()">价格表</a>&nbsp;
                    &nbsp;&nbsp;<a href="javascript:void(0);" style="text-decoration:underline;" onclick="OpenPriceHistory()">查看历史价格</a>                    
                </td>
            </tr>
            <tr>
                <td class="label">金额</td>
                <td>
                    @Html.TextBox("Amount", null, new { maxlength = "10", @class = "text-money amount" })&nbsp;<span class="redStar">*</span>&nbsp;
                </td>
            </tr>
            <tr>
                <td class="label">备注</td>
                <td>
                    @Html.TextArea("Memo", null, new { maxlength = "1000", style = "width:100%;height:60px;", @class = "form-control" })
                </td>
            </tr>

        </table>
    </div>
    <div style="text-align: right;">
        <div class="error-msg"></div>
        <button type="button" class="btn btn-default" onclick="$('#popOrderDetail').dialog('close');">关闭</button>
        <button type="button" class="btn btn-primary" id="btnSaveDetail" onclick="saveDetail()">保存</button>
    </div>
</div>

<div id="divCustomer" title="快速创建客户" style="display:none">
    <div id="divCustomerContent">
        @using (Html.BeginForm())
        {
            <table id="tableEdit" class="font85 tableEdit">
                <tr>
                    <td class="label">客户名称</td>
                    <td>
                        @Html.TextBox("CustomerFullName", null, new { maxlength = "100", @style = "width:260px" })&nbsp;<span class="redStar">*</span>
                    </td>
                </tr>

            </table>
        }
    </div>
    <div style="text-align:right;">
        <div class="error-msg"></div>
        <button type="button" class="btn btn-default" id="btnCancelCustomer">关闭</button>
        <button type="button" class="btn btn-primary" id="btnSaveCustomer">保存</button>

    </div>
</div>

<div id="divContact" title="快速创建联系人" style="display:none">
    <div id="divdivContactContent">
        @using (Html.BeginForm())
        {
            <table id="tableEdit" class="font85 tableEdit">
                <tr>
                    <td class="label" style="height:41px">公司名称</td>
                    <td id="tdCustomerName"></td>
                </tr>
                <tr>
                    <td class="label">联系人姓名</td>
                    <td>
                        @Html.TextBox("ContactName", null, new { maxlength = "100", @style = "" })&nbsp;<span class="redStar">*</span>
                    </td>
                </tr>
                <tr>
                    <td class="label">电话号码</td>
                    <td>
                        @Html.TextBox("Phone", null, new { maxlength = "100", @style = "" })
                    </td>
                </tr>

            </table>
        }
    </div>
    <div style="text-align:right;">
        <div class="error-msg"></div>
        <button type="button" class="btn btn-default" onclick="$('#divContact').dialog('close');">关闭</button>
        <button type="button" class="btn btn-primary" onclick="SaveContact()">保存</button>

    </div>
</div>

@Html.Hidden("OrderDetails", Model.OrderDetailString)
@Html.Hidden("OrderTemplateString")
@Html.Hidden("TemplateNo")
@Html.Hidden("Detail")
@Html.Hidden("BackURL")
@Html.Hidden("QuotationId")