<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>采购合同管理-变更合同信息</title>
    <link rel="stylesheet" type="text/css" href="/css/external/fileUploadBase.css">
    <style>
        .btn-info:active,
        .btn-info:focus {
            background-color: #fff;
        }

        li.notcompanyli:hover {
            color: #333 !important;
        }

        .base-extend .newTabAddUpdateBox td.enter .viewDetailWord {
            width: 0.75rem;
            text-align: center;
            top: 0.1rem;
            color: #333 !important;
            cursor: default;
            font-style: normal;
        }

        .base-extend .newTabAddUpdateBox td.enter .prevDetailWord {
            width: 0.85rem;
            text-align: center;
            top: 0.1rem;
            color: #333 !important;
            cursor: default;
            font-style: normal;
        }

        .error option, select.error {
            color: #333 !important;
        }

        input::-webkit-outer-spin-button,
        input::-webkit-inner-spin-button {
            -webkit-appearance: none;
            appearance: none;
            margin: 0;
        }

        #importForm .form-group {
            margin-top: 0.2rem;
            padding: 0 0.2rem;
        }

        .import_chooseFile {
            border: none;
            color: #fff;
            background-color: #52AEDC;
            text-shadow: none;
            width: 90%
        }

        #downloadDiv > div, #uploader_file .col-xs-3 {
            line-height: 0.32rem;
            /* text-align: center; */
            white-space: nowrap
        }

        .import_chooseFile:hover {
            color: #fff;
            background-color: #52AEDC;
            border-color: none;
            -webkit-box-shadow: 0 2px 1px rgba(0, 0, 0, .1);
            box-shadow: 0 2px 1px rgba(0, 0, 0, .1);
        }

        #downloadDiv > a {
            position: relative;
            min-height: 0.32rem;
            margin-bottom: 0.1rem;
            border: 1px solid #ddd;
            text-align: center;
            line-height: 0.32rem;
            color: #ddd;
        }

        .uploaderFile_hidden {
            position: absolute;
            left: 0.1rem;
            top: 0px;
            width: 70%;
            height: 0.3rem;
            opacity: 0
        }

        #uploader_file .filelist > .content {
            margin-top: 0.07rem;
            margin-bottom: 0.07rem;
        }

        #uploader_file .filelist > .content > .file-size {
            float: right;
        }

        #uploader_file .filelist {
            height: auto;
            border: 1px solid #ddd;
            min-height: 0.34rem;
        }

        #sign_loaderFile span {
            display: block
        }

        #sign_loaderFile span label:after {
            content: "*";
            color: red;
            display: inline-block;
            margin-right: 0.1rem;
            margin-left: 0.1rem;
        }

        .chooseGoodsTable td {
            border-left: 1px solid #E8F0F3;
            border-top: 1px solid #E8F0F3;
            padding: 0.1rem;
            text-align: left;
            background-color: #F0F9FC;
            font-size: 0.12rem;
            color: #333;
            min-height: 0.34rem;
            word-break: break-all;
            position: relative;
        }
    </style>
</head>
<body>
<div class="base-extend">
    <div class="modal fade businessDialog" id="myModal-chooseGoods" data-backdrop="static">
        <div class="modal-dialog" style="width:10.5rem;">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal">
                    <span aria-hidden="true" style="font-size:0.18rem">×</span><span class="sr-only">关闭</span>
                </button>
                <span class="modal-title">选择货物</span>
            </div>
            <div class="modal-content" style="max-height:4.7rem;overflow-y:auto;overflow-x:hidden;">
                <div class="listBackBox" style="padding-top:0;">
                    <div class="projectTableBox" id="formForProjectListBox" style="margin:0;">
                        <div class="customerMarketingList formForProjectList col-xs-12 businessTable"
                             style="left:0;padding:0.1rem 0.2rem 0 0.2rem;" tipword="">
                            <p class="detailContentBox-title">可选货物</p>
                            <table id="chooseGoodsList" class="tablebox" style="width: 100%;"></table>
                            <div id="chooseGoodsListPage" class="tablepagebox"></div>

                            <p class="detailContentBox-title" style="margin-top: 20px;display: none">已选货物</p>
                            <table class="chooseGoodsTable" style="width: 100%!important;display: none">
                                <tr>
                                    <td width="5%">
                                        <span style="color: #656565;font-weight: 700">编号</span>
                                    </td>
                                    <td width="14%">
                                        <span style="color: #656565;font-weight: 700">名称</span>
                                    </td>
                                    <td width="14%">
                                        <span style="color: #656565;font-weight: 700">厂家</span>
                                    </td>
                                    <td width="14%">
                                        <span style="color: #656565;font-weight: 700">型号</span>
                                    </td>
                                    <td width="13%">
                                        <span style="color: #656565;font-weight: 700">单位</span>
                                    </td>
                                    <td width="13%">
                                        <span style="color: #656565;font-weight: 700">数量</span>
                                    </td>
                                    <td width="13%">
                                        <span style="color: #656565;font-weight: 700">销售单价</span>
                                    </td>
                                    <td width="10%">
                                        <span style="color: #656565;font-weight: 700">操作</span>
                                    </td>
                                </tr>
                                <tbody class="choosedGoodsList">

                                </tbody>
                            </table>

                        </div>
                    </div>
                </div>
            </div>
            <div class="modal-footer">
                <button class="btn btn-default btn-white btn-info colorbtn chooseSure" style='margin-bottom:0;'>确定
                </button>
                <button class="btn btn-default btn-white btn-info" data-dismiss="modal" style='margin-bottom:0;'>取消
                </button>
            </div>
        </div>
    </div>

    <ol class="breadcrumb">
        <i class="icon-chevron-sign-left newBackBtn"></i>
        <li>采购合同管理</li>
        <li>变更合同信息</li>
    </ol>
    <div class="detailContentBox">
        <p class="detailContentBox-title">变更合同信息</p>
        <form class="form-horizontal" id="contractEntryForm" autocomplete="off">
            <input type="hidden" name="basicId" th:value="${purchContractInfo?.businessKey}">
            <input type="hidden" name="taskId" th:value="${taskId}">
            <div class="newTabAddUpdateBox">
                <div class="row">
                    <table>
                        <tr>
                            <td colspan="4">
                                <span class="detailContentBox-tabletitle">业务信息</span>
                            </td>
                        </tr>
                        <tr>
                            <td width="15%">
                                <span class="required_fileds_star">业务名称</span>：
                            </td>
                            <td width="35%" class="enter">
                                <input type="text" name="businessName" readonly
                                       th:value="${purchContractInfo?.businessBasicInfo?.businessName}"
                                       class="form-control">
                            </td>
                            <td width="15%">
                                <span class="required_fileds_star">核心企业名称</span>：
                            </td>
                            <td width="35%" class="enter">
                                <input type="text" name="enterpriseName" readonly
                                       th:value="${purchContractInfo?.businessBasicInfo?.customer?.enterpriseName}"
                                       class="form-control">
                            </td>
                        </tr>
                        <tr>
                            <td width="15%">
                                <span class="">业务编号</span>：
                            </td>
                            <td width="35%" class="enter">
                                <input type="text" name="businessNo" readonly
                                       th:value="${purchContractInfo?.businessBasicInfo?.businessNumber}"
                                       class="form-control">
                            </td>
                            <td width="15%">
                                <span class="required_fileds_star">创建时间</span>：
                            </td>
                            <td width="35%" class="enter">
                                <input type="text" name="creatTime" readonly
                                       th:value="${#calendars.format(purchContractInfo?.businessBasicInfo?.gmtCreate,'yyyy-MM-dd')}"
                                       class="form-control">
                            </td>
                        </tr>
                    </table>
                </div>

                <div class="row">
                    <table>
                        <tr>
                            <td colspan="4">
                                <span class="detailContentBox-tabletitle">合同信息</span>
                            </td>
                        </tr>
                        <tr>
                            <td width="15%">
                                <span class="required_fileds_star">合同编号</span>：
                            </td>
                            <td width="35%" class="enter">
<!--                                <input type="text" name="contractNumber" class="form-control" readonly-->
<!--                                       th:value="${purchContractInfo?.purchContractBasicInfo?.contractNumber}">-->
                                <input type="text" name="contractNumber" class="form-control" readonly>
                            </td>
                            <td width="15%">
                                <span class="required_fileds_star">合同名称</span>：
                            </td>
                            <td width="35%" class="enter">
                                <input type="text" name="contractName" class="form-control" readonly
                                       th:value="${purchContractInfo?.purchContractBasicInfo?.contractName}">
                            </td>
                        </tr>
                        <tr>
                            <td width="15%">
                                <span class="required_fileds_star">供应商名称</span>：
                            </td>
                            <td width="35%" class="enter">
                                <input type="text" name="platform" readonly
                                       th:value="${purchContractInfo?.customer?.enterpriseName}"
                                       class="form-control">
                            </td>
                            <td width="15%">
                                <span class="required_fileds_star">需方公司名称</span>：
                            </td>
                            <td width="35%" class="enter">
                                <input type="text" name="customer" readonly
                                       th:value="${purchContractInfo?.businessBasicInfo?.platform?.platformName}"
                                       class="form-control">
                            </td>
                        </tr>
                        <tr>
                            <td width="15%">
                                <span class="required_fileds_star">合同期限</span>：
                            </td>
                            <td width="35%" class="enter">
                                <input type="number" onkeyup="value=value.replace(/^(0+)|[^\d]+/g,'')"
                                       name="contractPeriod" min="0" class="form-control" readonly
                                       th:value="${purchContractInfo?.purchContractBasicInfo?.contractPeriod}">
                                <i class="viewDetailWord">天</i>
                            </td>
                            <td width="15%">
                                <span class="required_fileds_star">回购方式</span>：
                            </td>
                            <td width="35%" class="enter">
                                <select name="repurchMethod" class="form-control"
                                        tag:option="purchContractRepurchMethod" disabled
                                        th:value="${purchContractInfo?.purchContractBasicInfo?.repurchMethodDic?.id}"></select>
                            </td>
                        </tr>
                        <tr>
                            <td width="15%">
                                <span class="required_fileds_star">合同约定金额类型</span>：
                            </td>
                            <td width="35%" class="enter">
                                <select name="contractPlanAmountType" class="form-control" disabled
                                        tag:option="salesContractPlanAmountType"
                                        th:value="${purchContractInfo?.purchContractBasicInfo?.contractPlanAmountTypeDic?.id}"></select>
                            </td>
                            <td width="15%">
                                <span class="required_fileds_star">合同约定金额</span>：
                            </td>
                            <td width="35%" class="enter">
                                <input type="text" name="contractPlanAmount" class="form-control amountInput" readonly
                                       th:value="${purchContractInfo?.purchContractBasicInfo?.contractPlanAmount}">
                                <i class="viewDetailWord">元</i>
                            </td>
                        </tr>
                    </table>
                </div>

                <div class="row">
                    <table class="paymentTable">
                        <tr>
                            <td colspan="3">
                                <span class="detailContentBox-tabletitle">付款条件</span>
                            </td>
                        </tr>
                        <tr>
                            <td width="15%">
                                <span>编号</span>
                            </td>
                            <td width="85%">
                                <span>付款条件</span>
                            </td>
                        </tr>
                        <tbody>
                        <tr class="paymentListTbody paymentListTbodyBack"
                            th:each="paymentTerm,paymentTermStat:${purchContractInfo?.purchContractPaymentCondition}">
                            <td width="15%" style="background-color:#fff;">
                                <span th:text="${paymentTermStat.count}"></span>
                            </td>
                            <td width="85%" style="background-color:#fff;" class="enter">
                                <input type="text" name="paymentCondition" maxlength="500" readonly
                                       class="form-control paymentCondition" th:value="${paymentTerm.paymentCondition}">
                                <span class="error" style="display:none;font-size:0.12rem;">请输入付款条件</span>
                            </td>
                            <!--                            <td width="13%" style="background-color:#fff;">-->
                            <!--                                <span class="negativeInformationPlus">+添加</span>-->
                            <!--                                <span class="negativeInformationReduce">-删除</span>-->
                            <!--                            </td>-->
                        </tr>
                        </tbody>
                    </table>
                </div>

                <div class="row">
                    <table>
                        <tr>
                            <td colspan="4">
                                <span class="detailContentBox-tabletitle">结算周期</span>
                            </td>
                        </tr>
                        <tr>
                            <td width="15%">
                                <span class="required_fileds_star">发货时间</span>：
                            </td>
                            <td width="35%" class="enter">
                                <input type="text" name="deliveryDate" class="form-control" readonly
                                       th:value="${purchContractInfo?.purchContractSettleCycle?.deliveryDate}">
                            </td>
                            <td width="15%">
                                <span class="required_fileds_star">签收时间</span>：
                            </td>
                            <td width="35%" class="enter">
                                <input type="text" name="signDate" class="form-control" readonly
                                       th:value="${purchContractInfo?.purchContractSettleCycle?.signDate}">
                            </td>
                        </tr>
                        <tr>
                            <td width="15%">
                                <span class="required_fileds_star">第一次结算时间</span>：
                            </td>
                            <td colspan="3" class="enter">
                                <input type="text" readonly name="firstSettleDate" class="form-control" disabled
                                       th:value="${#calendars.format(purchContractInfo?.purchContractSettleCycle?.firstSettleDate,'yyyy-MM-dd')}">
                            </td>
                        </tr>
                        <tr>
                            <td width="15%">
                                <span class="required_fileds_star">结算周期方式</span>：
                            </td>
                            <td width="35%" class="enter">
                                <select name="settleCycleMethodDict" class="form-control" disabled
                                        tag:option="salesContractSettleCycleMethod"
                                        th:value="${purchContractInfo?.purchContractSettleCycle?.settleCycleMethodDict?.id}"></select>
                            </td>
                            <td width="15%">
                                <span class="required_fileds_star">结算周期</span>：
                            </td>
                            <td width="35%" class="enter">
                                <i class="prevDetailWord">上一次结算后</i>
                                <input type="number" min="0" name="settleCycle" class="form-control" readonly
                                       style="padding-left: 0.85rem;padding-right: 0.75rem"
                                       th:value="${purchContractInfo?.purchContractSettleCycle?.settleCycle}">
                                <i class="viewDetailWord">个自然月</i>
                            </td>
                        </tr>
                        <tr>
                            <td width="15%">
                                <span class="required_fileds_star">约定回款时间</span>：
                            </td>
                            <td colspan="3" class="enter">
                                <i class="prevDetailWord" style="width: 0.6rem">结算后</i>
                                <input type="number" min="0" name="planPaybackDays" class="form-control" readonly
                                       style="padding-left: 0.6rem;padding-right: 0.75rem"
                                       th:value="${purchContractInfo?.purchContractSettleCycle?.planPaybackDays}">
                                <i class="viewDetailWord">天</i>
                            </td>
<!--                            <td width="15%">-->
<!--                                <span class="required_fileds_star">结算最低差额</span>：-->
<!--                            </td>-->
<!--                            <td width="35%" class="enter">-->
<!--                                <input type="text" name="settleMinAmount" class="form-control amountInput" readonly-->
<!--                                       style="padding-right: 0.75rem"-->
<!--                                       th:value="${purchContractInfo?.purchContractSettleCycle?.settleMinAmount}">-->
<!--                                <i class="viewDetailWord">元</i>-->
<!--                            </td>-->
                        </tr>
                    </table>
                </div>

                <div class="row">
                    <table>
                        <tr>
                            <td colspan="4">
                                <span class="detailContentBox-tabletitle">质保金</span>
                            </td>
                        </tr>
                        <tr>
                            <td width="15%">
                                <span class="required_fileds_star">是否有质保金</span>：
                            </td>
                            <td width="35%" class="enter">
                                <select name="retention" class="form-control" disabled>
                                    <option value="">请选择</option>
                                    <option value="1"
                                            th:selected="${purchContractInfo?.purchContractRetentionInfo?.retention==1}">
                                        是
                                    </option>
                                    <option value="0"
                                            th:selected="${purchContractInfo?.purchContractRetentionInfo?.retention==0}">
                                        否
                                    </option>
                                </select>
                            </td>
                            <td width="15%" class="retentionTr">
                                <span class="required_fileds_star">质保金比例</span>：
                            </td>
                            <td width="35%" class="enter retentionTr">
                                <input type="text" name="retentionPercent" class="form-control" readonly
                                       th:value="${purchContractInfo?.purchContractRetentionInfo?.retentionPercent}">
                                <i class="viewDetailWord">%</i>
                            </td>
                        </tr>
                        <tr class="retentionTr">
                            <td width="15%">
                                <span class="required_fileds_star">质保金是否有上限</span>：
                            </td>
                            <td width="35%" class="enter">
                                <select name="limit" class="form-control" disabled>
                                    <option value="">请选择</option>
                                    <option value="1"
                                            th:selected="${purchContractInfo?.purchContractRetentionInfo?.isLimit==1}">是
                                    </option>
                                    <option value="0"
                                            th:selected="${purchContractInfo?.purchContractRetentionInfo?.isLimit==0}">否
                                    </option>
                                </select>
                            </td>
                            <td width="15%" class="retentionLimitTr">
                                <span class="required_fileds_star">质保金上限</span>：
                            </td>
                            <td width="35%" class="enter retentionLimitTr">
                                <input type="text" name="retentionLimit" class="form-control amountInput" readonly
                                       th:value="${purchContractInfo?.purchContractRetentionInfo?.retentionLimit}">
                                <i class="viewDetailWord">元</i>
                            </td>
                        </tr>
                        <tr class="retentionTr">
                            <td width="15%">
                                <span class="required_fileds_star">质保金释放时间</span>：
                            </td>
                            <td colspan="3" class="enter">
                                <select name="releaseMethodDict" class="form-control" disabled
                                        tag:option="salesContractReleaseMethod"
                                        th:value="${purchContractInfo?.purchContractRetentionInfo?.releaseMethodDict?.id}"></select>
                            </td>
                            <td width="15%" class="releaseDate" hidden>
                                <span class="required_fileds_star">释放日期</span>：
                            </td>
                            <td width="35%" class="enter releaseDate" hidden>
                                <input type="text" readonly name="releaseDate" class="form-control"
                                       th:value="${#calendars.format(purchContractInfo?.purchContractRetentionInfo?.releaseDate,'yyyy-MM-dd')}">
                            </td>
                            <td width="15%" class="releaseDays" hidden>
                                <span class="required_fileds_star">释放天数</span>：
                            </td>
                            <td width="35%" class="enter releaseDays" hidden>
                                <input type="text" name="releaseDays" class="form-control" readonly
                                       th:value="${purchContractInfo?.purchContractRetentionInfo?.releaseDays}">
                                <i class="viewDetailWord">天</i>
                            </td>
                        </tr>
                    </table>
                </div>

                <div class="row">
                    <table>
                        <tr>
                            <td colspan="4">
                                <span class="detailContentBox-tabletitle">价格规则</span>
                            </td>
                        </tr>
                        <tr>
                            <td width="15%">
                                <span class="required_fileds_star">利差计算方式</span>：
                            </td>
                            <td colspan="3" class="enter">
                                <select name="accrualMarginCalcMethod" class="form-control" disabled
                                        tag:option="purchAccrualMarginCalcMethod"
                                        th:value="${purchContractInfo?.purchContractPriceRule?.accrualMarginCalcMethodDict?.id}"></select>
                            </td>
                        </tr>
                        <tr class="rateTr" style="display: none">
                            <td width="15%">
                                <span class="required_fileds_star">贸易平台报价</span>：
                            </td>
                            <td width="35%" class="enter">
                                <input type="text" name="tradePlatformOffer" class="form-control" readonly
                                       th:value="${purchContractInfo?.purchContractPriceRule?.tradePlatformOffer}">
                                <i class="viewDetailWord">%</i>
                            </td>
                            <td width="15%">
                                <span class="required_fileds_star">保理报价</span>：
                            </td>
                            <td width="35%" class="enter">
                                <input type="text" name="factoringOffer" class="form-control" readonly
                                       th:value="${purchContractInfo?.purchContractPriceRule?.factoringOffer}">
                                <i class="viewDetailWord">%</i>
                            </td>
                        </tr>
                        <tr class="rateTr" style="display: none">
                            <td width="15%">
                                <span class="required_fileds_star">预估保理融资期限</span>：
                            </td>
                            <td width="35%" class="enter">
                                <input type="number" onkeyup="value=value.replace(/^(0+)|[^\d]+/g,'')" readonly
                                       name="factoringFinanceDeadline" min="0" class="form-control"
                                       th:value="${purchContractInfo?.purchContractPriceRule?.factoringFinanceDeadline}">
                            </td>
                            <td width="15%">
                                <span class="required_fileds_star">月利率</span>：
                            </td>
                            <td width="35%" class="enter">
                                <input type="text" name="monthlyinterestRate" class="form-control" readonly
                                       th:value="${purchContractInfo?.purchContractPriceRule?.monthlyinterestRate}">
                                <i class="viewDetailWord">%</i>
                            </td>
                        </tr>
                        <tr class="chaTr" style="display: none">
                            <td width="15%">
                                <span class="required_fileds_star">差额</span>：
                            </td>
                            <td width="35%" class="enter">
                                <input type="text" name="differAmount" class="form-control amountInput" readonly
                                       th:value="${purchContractInfo?.purchContractPriceRule?.differAmount}">
                                <i class="viewDetailWord">元</i>
                            </td>
                        </tr>
                    </table>
                </div>

                <div class="row">
                    <table>
                        <tr>
                            <td colspan="4">
                                <span class="detailContentBox-tabletitle">应收账款有效期</span>
                            </td>
                        </tr>
                        <tr>
                            <td width="15%">
                                <span class="required_fileds_star">开始日期</span>：
                            </td>
                            <td width="35%" class="enter">
                                <input type="text" name="startDate" class="form-control" readonly
                                       th:value="${purchContractInfo?.purchContractArExp?.startDate}">
                            </td>
                            <td width="15%">
                                <span class="required_fileds_star">结束日期</span>：
                            </td>
                            <td width="35%" class="enter">
                                <i class="prevDetailWord" style="width: 0.6rem">结算后</i>
                                <input type="number" min="0" name="endDate" class="form-control" readonly
                                       style="padding-left: 0.6rem;padding-right: 0.75rem"
                                       th:value="${purchContractInfo?.purchContractArExp?.endDate}">
                                <i class="viewDetailWord">天</i>
                            </td>
                        </tr>
                    </table>
                </div>

                <div class="row">
                    <table class="goodsTable">
                        <tr>
                            <td colspan="10">
                                <span class="detailContentBox-tabletitle">货物信息</span>
                                <span id="chooseButton" class="colorbtn btn" style="float: right;">
                                    选择货物
                                </span>
                            </td>
                        </tr>
                        <tr>
                            <td width="5%">
                                <span>编号</span>
                            </td>
                            <td width="10%">
                                <span>名称</span>
                            </td>
                            <td width="15%">
                                <span>厂家</span>
                            </td>
                            <td width="15%">
                                <span>型号</span>
                            </td>
                            <td width="15%">
                                <span>单位</span>
                            </td>
                            <td width="15%">
                                <span>数量</span>
                            </td>
<!--                            <td width="10%">-->
<!--                                <span>是否明确单价</span>-->
<!--                            </td>-->
<!--                            <td width="10%">-->
<!--                                <span>采购单价</span>-->
<!--                            </td>-->
                            <td width="14%">
                                <span>备注</span>
                            </td>
                            <td width="10%">
                                <span>操作</span>
                            </td>
                        </tr>
                        <tr class="goodsListTbody" style="display: none">
                            <td width="5%" style="background-color:#fff;">
                                <span>1</span>
                            </td>
                            <td width="10%" style="background-color:#fff;" class="enter">
                                <input type="text" readonly class="form-control validInput">
                                <span class="error" style="display:none;">请填写名称</span>
                            </td>
                            <td width="15%" style="background-color:#fff;" class="enter">
                                <input type="text" readonly class="form-control validInput">
                                <span class="error" style="display:none;">请填写厂家</span>
                            </td>
                            <td width="15%" style="background-color:#fff;" class="enter">
                                <input type="text" readonly class="form-control validInput">
                                <span class="error" style="display:none;">请填写型号</span>
                            </td>
                            <td width="15%" style="background-color:#fff;" class="enter">
                                <input type="text" readonly class="form-control validInput">
                                <span class="error" style="display:none;">请填写单位</span>
                            </td>
                            <td width="15%" style="background-color:#fff;" class="enter">
                                <input type="number" min="0" class="form-control validInput">
                                <span class="error" style="display:none;">请填写数量</span>
                            </td>
<!--                            <td width="10%" style="background-color:#fff;" class="enter">-->
<!--                                <select class="form-control">-->
<!--                                    <option value="">请选择</option>-->
<!--                                    <option value="0">否</option>-->
<!--                                    <option value="1">是</option>-->
<!--                                </select>-->
<!--                                <span class="error" style="display:none;">请选择是否明确单价</span>-->
<!--                            </td>-->
<!--                            <td width="10%" style="background-color:#fff;" class="enter">-->
<!--                                <input type="text" class="form-control">-->
<!--                                <span class="error" style="display:none;">请填写单价</span>-->
<!--                            </td>-->
                            <td width="14%" style="background-color:#fff;" class="enter">
                                <input type="text" class="form-control">
                            </td>
                            <td width="10%" style="background-color:#fff;">
                                <!--                                <span class="negativeInformationPlus">+添加</span>-->
                                <span class="negativeInformationReduce">-删除</span>
                            </td>
                        </tr>
                        <tbody class="goodsListTable">
                        <tr class="goodsListTbody goodsListTbodyBack"
                            th:each="goods,goodsStat:${purchContractInfo?.purchContractGoodsInfo}">
                            <td width="5%" style="background-color:#fff;">
                                <span th:text="${goods.goodsCode}"></span>
                            </td>
                            <td width="10%" style="background-color:#fff;" class="enter">
                                <input type="text" class="form-control validInput"
                                       th:goodsId="${goods?.salesContractGoodsInfoId}"
                                       th:value="${goods?.salesContractGoodsInfo?.goodsName}" readonly>
                                <span class="error" style="display:none;">请填写名称</span>
                            </td>
                            <td width="15%" style="background-color:#fff;" class="enter">
                                <input type="text" class="form-control validInput"
                                       th:value="${goods?.salesContractGoodsInfo?.goodsFactory}" readonly>
                                <span class="error" style="display:none;">请填写厂家</span>
                            </td>
                            <td width="15%" style="background-color:#fff;" class="enter">
                                <input type="text" class="form-control validInput"
                                       th:value="${goods?.salesContractGoodsInfo?.modelNumber}" readonly>
                                <span class="error" style="display:none;">请填写型号</span>
                            </td>
                            <td width="15%" style="background-color:#fff;" class="enter">
                                <input type="text" class="form-control validInput"
                                       th:value="${goods?.salesContractGoodsInfo?.units}" readonly>
                                <span class="error" style="display:none;">请填写单位</span>
                            </td>
                            <td width="15%" style="background-color:#fff;" class="enter">
                                <input type="number" min="0" class="form-control validInput"
                                       th:value="${goods?.quantity}" readonly>
                                <span class="error" style="display:none;">请填写数量</span>
                            </td>
<!--                            <td width="10%" style="background-color:#fff;" class="enter">-->
<!--                                <select class="form-control" disabled>-->
<!--                                    <option value="">请选择</option>-->
<!--                                    <option value="0" th:selected="${goods?.clearPrice==0}">否-->
<!--                                    </option>-->
<!--                                    <option value="1" th:selected="${goods?.clearPrice==1}">是-->
<!--                                    </option>-->
<!--                                </select>-->
<!--                                <span class="error" style="display:none;">请选择是否明确单价</span>-->
<!--                            </td>-->
<!--                            <td width="10%" style="background-color:#fff;" class="enter">-->
<!--                                <input type="text" class="form-control "-->
<!--                                       th:value="${goods?.purchPrice}" readonly>-->
<!--                                <span class="error" style="display:none;">请填写单价</span>-->
<!--                            </td>-->
                            <td width="14%" style="background-color:#fff;" class="enter">
                                <input type="text" class="form-control"
                                       th:value="${goods?.remark}" readonly>
                            </td>
                            <td width="10%" style="background-color:#fff;">
                                <!--                                <span class="negativeInformationPlus">+添加</span>-->
                                <!--                                <span class="negativeInformationReduce">-删除</span>-->
                            </td>
                        </tr>
                        </tbody>
                    </table>
                </div>

            </div>
            <div class="yk_addBtns yk_addNewMsg newTabAddUpdateBtnBox">
                <button class="btn btn-white btn-info colorbtn submitBusiness">提交</button>
                <button class="btn btn-white btn-info btn-cancel">关闭</button>
            </div>
        </form>
    </div>
</div>
</body>
<script>
    function chooseGoods(id) {
        var chooseData = $('#chooseGoodsList').jqGrid('getRowData', id);
        var trStr = `<tr class="choosedGoodsTbody">
                        <td width="5%" style="background-color:#fff;border-bottom: 1px solid #E8F0F3;"></td>
                        <td width="14%" style="background-color:#fff;border-bottom: 1px solid #E8F0F3;">` + chooseData.goodsName + `</td>
                        <td width="14%" style="background-color:#fff;border-bottom: 1px solid #E8F0F3;">` + chooseData.goodsFactory + `</td>
                        <td width="14%" style="background-color:#fff;border-bottom: 1px solid #E8F0F3;">` + chooseData.modelNumber + `</td>
                        <td width="13%" style="background-color:#fff;border-bottom: 1px solid #E8F0F3;">` + chooseData.units + `</td>
                        <td width="13%" style="background-color:#fff;border-bottom: 1px solid #E8F0F3;">` + chooseData.quantity + `</td>
                        <td width="13%" style="background-color:#fff;border-bottom: 1px solid #E8F0F3;">` + chooseData.salesPrice + `</td>
                        <td style="display: none">` + chooseData.id + `</td>
                        <td style="display: none" class="remark">` + chooseData.remark + `</td>
                        <td width="10%" style="background-color:#fff;border-bottom: 1px solid #E8F0F3;border-right: 1px solid #E8F0F3;"><span class="relaseGoods" style="color: #5AC4FC;cursor: pointer">释放</span></td>
                    </tr>`
        $(".choosedGoodsList").append(trStr);
        $("#myModal-chooseGoods").resize();
        sortChooseGoodsInfo();
    }

    //paixu
    function sortChooseGoodsInfo() {
        $(".choosedGoodsTbody").each(function (i, ele) {
            $(ele).find('td:first').text(i + 1);
        });
    }

    $(function () {
        //初始化日期
        function setDate(select, startDate, endDate) {
            $(select).datetimepicker(
                {
                    weekStart: 1,
                    autoclose: 1,
                    todayHighlight: 0,
                    startView: 2,
                    minView: 2,
                    forceParse: 0,
                    showMeridian: 1,
                    startDate: startDate,
                    endDate: endDate,
                    format: "yyyy-mm-dd"
                }
            );
            $(select).datetimepicker('setStartDate', startDate);
            $(select).datetimepicker('setEndDate', endDate);
        };
        setDate('[name=firstSettleDate]', '1970-01-01', '2116-12-31');
        setDate('[name=releaseDate]', $("[name=creatTime]").val(), '2116-12-31');

        // 排序-付款条件
        function sortReceiptInfo() {
            $(".paymentListTbody").each(function (i, ele) {
                $(ele).find('td:first span').text(i + 1);
            });
            if ($(".paymentListTbody").length <= 1) {
                $('.paymentTable .negativeInformationReduce').hide();
            } else {
                $('.paymentTable .negativeInformationReduce').show();
            }
            ;
        };
        sortReceiptInfo();

        // 添加行-付款条件
        $("#contractEntryForm").on('click', '.paymentTable .negativeInformationPlus', function () {
            var supplierTrClone = $(".paymentListTbody:first").clone();
            supplierTrClone.find('.negativeInformationReduce').show();
            supplierTrClone.find('.error').hide();
            supplierTrClone.find('input').val('');
            $(this).parents('.paymentListTbody').after(supplierTrClone);
            sortReceiptInfo();
        });

        // 删除行
        $("#contractEntryForm").on('click', '.paymentTable .negativeInformationReduce', function () {
            $(this).parents('.paymentListTbody').remove();
            sortReceiptInfo();
        });

        // 排序-货物
        function sortIGoodsnfo() {
            $(".goodsListTbody").each(function (i, ele) {
                $(ele).find('td:first span').text(i);
            });
            if ($(".goodsListTbody").length <= 1) {
                $('.goodsTable .negativeInformationReduce').hide();
            } else {
                $('.goodsTable .negativeInformationReduce').show();
            }
            ;
        };
        sortIGoodsnfo();


        $("#contractEntryForm").on('click', '.goodsTable #addGoods', function () {
            var supplierTrClone = $(".goodsListTbody:first").clone();
            supplierTrClone.find('.negativeInformationReduce').show();
            supplierTrClone.find('.error').hide();
            supplierTrClone.find('input').val('');
            supplierTrClone.find('select').val('');
            supplierTrClone.show();
            $('.goodsListTable').append(supplierTrClone);
            sortIGoodsnfo();
        });


        // 删除行
        $("#contractEntryForm").on('click', '.goodsTable .negativeInformationReduce', function () {
            $(this).parents('.goodsListTbody').remove();
            sortIGoodsnfo();
        });


        //保存
        function submitFunction(e) {
            var postdata = new FormData();

            postdata.append('taskId', $("[name=taskId]").val());
            postdata.append('businessKey', $("[name=basicId]").val());
            postdata.append('purchContractBasicInfo.businessNumber', $("[name=businessNo]").val());
            postdata.append('purchContractBasicInfo.contractNumber', $("[name=contractNumber]").val());
            postdata.append('purchContractBasicInfo.contractName', $("[name=contractName]").val());
            postdata.append('purchContractBasicInfo.contractPeriod', $("[name=contractPeriod]").val());
            postdata.append('purchContractBasicInfo.repurchMethod', $("[name=repurchMethod]").val());
            postdata.append('purchContractBasicInfo.contractPlanAmountType', $("[name=contractPlanAmountType]").val());
            postdata.append('purchContractBasicInfo.contractPlanAmount', $("[name=contractPlanAmount]").val().split(",").join(''));

            //付款条件
            for (var i = 0; i < $(".paymentListTbody").length; i++) {
                postdata.append('purchContractPaymentCondition[' + i + '].paymentCondition', $(".paymentListTbody").eq(i).find('.paymentCondition').val());
            }
            i = null;

            postdata.append('purchContractSettleCycle.deliveryDate', $("[name=deliveryDate]").val());
            postdata.append('purchContractSettleCycle.signDate', $("[name=signDate]").val());
            postdata.append('purchContractSettleCycle.firstSettleDate', $("[name=firstSettleDate]").val());
            postdata.append('purchContractSettleCycle.settleCycleMethod', $("[name=settleCycleMethodDict]").val());
            postdata.append('purchContractSettleCycle.settleCycle', $("[name=settleCycle]").val());
            postdata.append('purchContractSettleCycle.planPaybackDays', $("[name=planPaybackDays]").val());
            // postdata.append('purchContractSettleCycle.settleMinAmount', $("[name=settleMinAmount]").val().split(",").join(''));

            postdata.append('purchContractRetentionInfo.retention', $("[name=retention]").val());
            postdata.append('purchContractRetentionInfo.retentionPercent', $("[name=retentionPercent]").val());
            postdata.append('purchContractRetentionInfo.isLimit', $("[name=limit]").val());
            postdata.append('purchContractRetentionInfo.retentionLimit', $("[name=retentionLimit]").val().split(",").join(''));
            postdata.append('purchContractRetentionInfo.releaseMethod', $("[name=releaseMethodDict]").val());
            if ($("[name=releaseMethodDict] option:selected").text() == '固定日期') {
                postdata.append('purchContractRetentionInfo.releaseDate', $("[name=releaseDate]").val());
            }
            if ($("[name=releaseMethodDict] option:selected").text() == '回款后固定天数') {
                postdata.append('purchContractRetentionInfo.releaseDays', $("[name=releaseDays]").val());
            }

            postdata.append('purchContractPriceRule.accrualMarginCalcMethod', $("[name=accrualMarginCalcMethod]").val());
            if($("[name=accrualMarginCalcMethod] option:selected").text() == '固定利率') {
                postdata.append('purchContractPriceRule.tradePlatformOffer',$("[name=tradePlatformOffer]").val());
                postdata.append('purchContractPriceRule.factoringOffer',$("[name=factoringOffer]").val());
                postdata.append('purchContractPriceRule.factoringFinanceDeadline',$("[name=factoringFinanceDeadline]").val());
                postdata.append('purchContractPriceRule.monthlyinterestRate',$("[name=monthlyinterestRate]").val());
            }else {
                postdata.append('purchContractPriceRule.differAmount',$("[name=differAmount]").val().split(',').join(''));
            }
            postdata.append('purchContractArExp.startDate', $("[name=startDate]").val());
            postdata.append('purchContractArExp.endDate', $("[name=endDate]").val());

            //货物信息
            for (var i = 1; i < $(".goodsListTbody").length; i++) {
                postdata.append('purchContractGoodsInfo[' + (i - 1) + '].goodsName', $(".goodsListTbody").eq(i).find('td').eq(1).find('input').val());
                postdata.append('purchContractGoodsInfo[' + (i - 1) + '].goodsFactory', $(".goodsListTbody").eq(i).find('td').eq(2).find('input').val());
                postdata.append('purchContractGoodsInfo[' + (i - 1) + '].modelNumber', $(".goodsListTbody").eq(i).find('td').eq(3).find('input').val());
                postdata.append('purchContractGoodsInfo[' + (i - 1) + '].units', $(".goodsListTbody").eq(i).find('td').eq(4).find('input').val());
                postdata.append('purchContractGoodsInfo[' + (i - 1) + '].quantity', $(".goodsListTbody").eq(i).find('td').eq(5).find('input').val());
                //postdata.append('purchContractGoodsInfo[' + (i - 1) + '].clearPrice', $(".goodsListTbody").eq(i).find('td').eq(6).find('select').val());
                //postdata.append('purchContractGoodsInfo[' + (i - 1) + '].purchPrice', $(".goodsListTbody").eq(i).find('td').eq(7).find('input').val());
                postdata.append('purchContractGoodsInfo[' + (i - 1) + '].remark', $(".goodsListTbody").eq(i).find('td').eq(6).find('input').val());

                postdata.append('purchContractGoodsInfo[' + (i - 1) + '].salesContractGoodsInfoId', $(".goodsListTbody").eq(i).find('td').eq(1).find('input').attr('goodsId'));
                postdata.append('purchContractGoodsInfo[' + (i - 1) + '].goodsCode', $(".goodsListTbody").eq(i).find('td').eq(0).find('span').text());
            }
            i = null;

            var url = '/purchContract/doAdd', tip = '变更';

            $.ajax({
                url: url,
                type: 'post',
                data: postdata,
                processData: false,
                contentType: false,
                success: function (data) {
                    if (data.success) {
                        new $.zui.Messager(tip + '合同成功', {
                            type: 'success'
                        }).show();
                        $.get('/purchContract/list', function (data) {
                            $(".yk_rightcontent").empty().append(data);
                        });
                    } else {
                        new $.zui.Messager(tip + '录入失败:' + data.msg, {
                            type: 'danger'
                        }).show();
                    }
                },
                error: function (status) {
                    new $.zui.Messager(tip + '合同时发生错误:' + status, {
                        type: 'danger'
                    }).show();
                }
            });
            return false;
        };

        var formRules = {
            'contractNumber': {
                required: true
            },
            'contractName': {
                required: true
            },
            'contractPeriod': {
                required: true
            },
            'contractPlanAmountType': {
                required: true
            },
            'contractPlanAmount': {
                required: true,
            },
            'repurchMethod': {
                required: true
            },

            'deliveryDate': {
                required: true
            },
            'signDate': {
                required: true
            },
            'firstSettleDate': {
                required: true,
            },
            'settleCycleMethodDict': {
                required: true
            },
            'settleCycle': {
                required: true
            },
            'planPaybackDays': {
                required: true
            },
            // 'settleMinAmount': {
            //     required: true,
            // },

            'retention': {
                required: true
            },
            'retentionPercent': {
                required: true
            },
            'limit': {
                required: true
            },
            'retentionLimit': {
                required: true,
            },
            'releaseMethodDict': {
                required: true
            },
            'releaseDate': {
                required: true
            },
            'releaseDays': {
                required: true
            },

            'accrualMarginCalcMethod': {
                required: true
            },
            'tradePlatformOffer': {
                required: true
            },
            'factoringOffer': {
                required: true,
            },
            'factoringFinanceDeadline': {
                required: true
            },
            'startDate': {
                required: true
            },
            'endDate': {
                required: true
            },
        };

        var formMessages = {
            'contractNumber': {
                required: '请输入合同编号'
            },
            'contractName': {
                required: '请输入合同名称'
            },
            'contractPeriod': {
                required: '请输入合同期限'
            },
            'contractPlanAmountType': {
                required: '请选择合同约定金额类型'
            },
            'contractPlanAmount': {
                required: '请输入合同约定金额',
            },
            'repurchMethod': {
                required: '请选择回购方式'
            },

            'deliveryDate': {
                required: '请输入发货时间'
            },
            'signDate': {
                required: '请输入签收时间'
            },
            'firstSettleDate': {
                required: '请选择第一次结算时间',
            },
            'settleCycleMethodDict': {
                required: '请选择结算周期方式'
            },
            'settleCycle': {
                required: '请输入结算周期'
            },
            'planPaybackDays': {
                required: '请输入约定回款时间'
            },
            // 'settleMinAmount': {
            //     required: '请输入结算最低差额',
            // },
            'retention': {
                required: '请选择是否有质保金'
            },
            'retentionPercent': {
                required: '请输入质保金比例'
            },
            'limit': {
                required: '请选择质保金是否有上限'
            },
            'retentionLimit': {
                required: '请输入质保金上限',
            },
            'releaseMethodDict': {
                required: '请选择质保金释放时间'
            },
            'releaseDate': {
                required: '请选择释放日期'
            },
            'releaseDays': {
                required: '请输入释放天数'
            },

            'accrualMarginCalcMethod': {
                required: '请选择利差计算方式'
            },
            'tradePlatformOffer': {
                required: '请输入贸易平台报价'
            },
            'factoringOffer': {
                required: '请输入保理报价',
            },
            'factoringFinanceDeadline': {
                required: '请输入预估保理融资期限'
            },
            'startDate': {
                required: '请输入开始日期'
            },
            'endDate': {
                required: '请输入结束日期'
            },
        };

        //验证付款条件
        function paymentValid() {
            $('.paymentListTbody').each(function (i, ele) {
                if ($(ele).find('.paymentCondition').val() !== '') {
                    $(ele).find('.error').removeClass('shows').hide()
                } else {
                    $(ele).find('.error').addClass('shows').show()
                }
            })
        }


        //表单验证
        function addNewCustomer(e) {
            paymentValid();

            $("#contractEntryForm").validate({
                promptPosition: "bottomLeft",
                submitHandler: function (form) {
                    //回款时间校验
                    if (Number($("[name=estimatePayBackDays]").val()) < Number($("[name=planPaybackDays]").val())) {
                        new $.zui.Messager('预估回款时间应大于约定回款时间。', {
                            type: 'danger'
                        }).show();
                        return false;
                    }
                    //货物必填验证
                    if ($(".goodsListTable .goodsListTbody").length) {
                        $('.goodsListTable .validInput').change();
                    } else {
                        new $.zui.Messager('请添加货物信息。', {
                            type: 'danger'
                        }).show();
                        return false;
                    }
                    if ($('.error.shows').length > 0) {
                        $('.error.shows:first').prev().focus();
                        return;
                    }
                    ;
                    submitFunction(e);
                },
                rules: formRules,
                messages: formMessages
            });
        };

        $(".amountInput").each(function (i, ele) {
            $(ele).val(commaDelimiter($(this).val()))
        })
        $(".amountInput").keyup(function () {
            $(this).val(commaDelimiter($(this).val()))
        })

        //结算周期方式
        if($("[name=settleCycleMethodDict] option:selected").text() == '自然月') {
            $("[name=settleCycle]").parent().find('.viewDetailWord').text('个自然月')
        }else {
            $("[name=settleCycle]").parent().find('.viewDetailWord').text('天')
        }
        $("[name=settleCycleMethodDict]").change(function () {
            if($("[name=settleCycleMethodDict] option:selected").text() == '自然月') {
                $("[name=settleCycle]").val('')
                $("[name=planPaybackDays]").val('')
                $("[name=settleCycle]").parent().find('.viewDetailWord').text('个自然月')
            }else {
                $("[name=settleCycle]").val('')
                $("[name=planPaybackDays]").val('')
                $("[name=settleCycle]").parent().find('.viewDetailWord').text('天')
            }
        })

        //是否有质保金
        $("[name=retention]").change(function () {
            if ($("[name=retention] option:selected").val() == 0) {
                $(".retentionTr").hide();
                $("[name=retention]").parent().css('width', '0').attr('colspan', 3)
            } else {
                $(".retentionTr").show();
                $("[name=retention]").parent().removeAttr('colspan').css('width', '35%')
            }
        })
        $("[name=retention]").change()

        //质保金上限
        $("[name=limit]").change(function () {
            if ($("[name=limit] option:selected").val() == 0) {
                $(".retentionLimitTr").hide();
                $("[name=limit]").parent().css('width', '0').attr('colspan', 3)
            } else {
                $(".retentionLimitTr").show();
                $("[name=limit]").parent().removeAttr('colspan').css('width', '35%')
            }
        })
        $("[name=limit]").change()

        //质保金释放方式
        $("[name=releaseMethodDict]").change(function () {
            if ($("[name=releaseMethodDict] option:selected").text() == '固定日期') {
                $("[name=releaseMethodDict]").parent().removeAttr('colspan').css('width', '35%')
                $(".releaseDate").show();
                $(".releaseDays").hide();
            } else if ($("[name=releaseMethodDict] option:selected").text() == '回款后固定天数') {
                $("[name=releaseMethodDict]").parent().removeAttr('colspan').css('width', '35%')
                $(".releaseDate").hide();
                $(".releaseDays").show();
            } else {
                $("[name=releaseMethodDict]").parent().css('width', '0').attr('colspan', '3')
                $(".releaseDate").hide();
                $(".releaseDays").hide();
            }
        })
        $("[name=releaseMethodDict]").change()

        //利差计算方式变化
        $('[name=accrualMarginCalcMethod]').change(function () {
            if($('[name=accrualMarginCalcMethod]').val() !== '') {
                if($('[name=accrualMarginCalcMethod] option:selected').text() == '固定利率') {
                    $('.rateTr').show()
                    $('.chaTr').hide();
                }else {
                    $('.rateTr').hide()
                    $('.chaTr').show();
                }
            }else {
                $('.rateTr').hide();
                $('.chaTr').hide()
            }
        })
        $('[name=accrualMarginCalcMethod]').change()


        //货物必填验证
        $(".goodsListTable").on("change", ".validInput", function (e) {
            if ($(this).parent().parent().attr('display') !== 'none') {
                if ($(this).val() == '') {
                    $(this).next().addClass('shows').show();
                } else {
                    $(this).next().removeClass('shows').hide();
                }
            }

        })
        $(".paymentListTbody").on("keyup", "input", function (e) {
            if ($(this).val() == '') {
                $(this).next().addClass('shows').show();
            } else {
                $(this).next().removeClass('shows').hide();
            }
        })

        //提交按钮
        $(".yk_addNewMsg .submitBusiness").click(addNewCustomer);

        //关闭按钮
        $(".yk_addNewMsg .btn-cancel, .newBackBtn").click(function () {
            $.get('/purchContract/list', function (data) {
                $(".yk_rightcontent").empty().append(data);
            });
            return false;
        });


        //释放
        $("#myModal-chooseGoods").on('click', '.chooseGoodsTable .relaseGoods', function () {
            $(this).parents('.choosedGoodsTbody').remove();
            sortChooseGoodsInfo();
            //return false;
        });

        function operate(cellValue, options, rowObject) {
            var btnstr = '';
            btnstr += '<p><span>选择</span><i class="icon-check" onclick="chooseGoods(' + rowObject.id + ')"></i></p>';
            return '<div class="operateIcon noHover">' + btnstr + '</div>';
        };

        function tablefunction(tableid) {
            var tipword = '', pageid = '', pageNo = 1, postData = {};
            url = '', colNamesArray = [], colModelArray = [];
            switch (tableid) {
                case '#chooseGoodsList':
                    tipword = '货物';
                    pageid = '#chooseGoodsListPage';
                    postData = {
                        'businessKey': $("[name=basicId]").val(),
                        'taskId': $("[name=taskId]").val()
                    };
                    url = '/purchContract/selectGoods';
                    colNamesArray = ['ID','销售备注', '编号', '名称', '厂家', '型号', '单位', '数量', '销售单价'];
                    colModelArray = [
                        {name: 'id', label: 'ID', hidedlg: true, hidden: true, sortable: false, title: false},
                        {name: 'remark', label: '销售备注', hidedlg:true, hidden:true,sortable:false,title:false},
                        {name: 'orderNumber', label: '编号', hidedlg: true, width: 50, sortable: false, title: false},
                        {name: 'goodsName', label: '名称', sortable: false, align: 'left', title: false},
                        {name: 'goodsFactory', label: '厂家', sortable: false, align: 'left', title: false},
                        {name: 'modelNumber', label: '型号', sortable: false, align: 'left', title: false},
                        {name: 'units', label: '单位', sortable: false, align: 'left', title: false},
                        {name: 'quantity', label: '数量', sortable: false, align: 'left', title: false},
                        {name: 'salesPrice', label: '销售单价', sortable: false, align: 'left', title: false},
                    ];
                    break;
            }
            ;
            sxUtil.jqGrid(tableid, {
                colNames: colNamesArray,
                colModel: colModelArray,
                height: 'auto',
                mtype: 'GET',
                url: url,
                pager: pageid,
                multiselect: true,
                multiboxonly: true,
                beforeSelectRow: function (rowid, e) {
                    var $myGrid = $(this),
                        i = $.jgrid.getCellIndex($(e.target).closest('td')[0]),
                        cm = $myGrid.jqGrid('getGridParam', 'colModel');
                    return (cm[i].name == 'cb')
                },
                rownumbers: false,
                postData: postData,
                page: pageNo,
                loadError: function () {
                    new $.zui.Messager(tipword + '列表加载失败', {
                        type: 'warning'
                    }).show();
                }
            }, true);
            $(tableid).trigger('reloadGrid');
        };

        tablefunction('#chooseGoodsList');

        $("#chooseButton").click(function () {

            $('#chooseGoodsList').setGridParam({
                mtype: 'GET',
                url: '/purchContract/selectGoods',
                datatype: 'json',
                postData: {
                    'businessKey': $("[name=basicId]").val(),
                    'taskId': $("[name=taskId]").val()
                },
                page: 1
            });
            $('#chooseGoodsList').trigger('reloadGrid');
            $("#myModal-chooseGoods").modal("show");
            $("#myModal-chooseGoods").on('shown.zui.modal', function () {
                $(window).resize();
                $("#chooseGoodsList_cb").css({'width': '45', 'padding': '0 0.12rem'})
                $('#chooseGoodsList .jqgfirstrow td:first').css('width', '45')

                $(".choosedGoodsList").empty();
            })
            return false;

        });

        $(".chooseSure").click(function () {
            var ids = $('#chooseGoodsList').jqGrid('getGridParam', 'selarrrow');
            if (ids.length > 0) {
                for (var i = 0; i < ids.length; i++) {
                    var chooseData = $('#chooseGoodsList').jqGrid('getRowData', ids[i]);
                    var trStr = `<tr class="choosedGoodsTbody">
                        <td width="5%" style="background-color:#fff;border-bottom: 1px solid #E8F0F3;"></td>
                        <td width="14%" style="background-color:#fff;border-bottom: 1px solid #E8F0F3;">` + chooseData.goodsName + `</td>
                        <td width="14%" style="background-color:#fff;border-bottom: 1px solid #E8F0F3;">` + chooseData.goodsFactory + `</td>
                        <td width="14%" style="background-color:#fff;border-bottom: 1px solid #E8F0F3;">` + chooseData.modelNumber + `</td>
                        <td width="13%" style="background-color:#fff;border-bottom: 1px solid #E8F0F3;">` + chooseData.units + `</td>
                        <td width="13%" style="background-color:#fff;border-bottom: 1px solid #E8F0F3;">` + chooseData.quantity + `</td>
                        <td width="13%" style="background-color:#fff;border-bottom: 1px solid #E8F0F3;">` + chooseData.salesPrice + `</td>
                        <td style="display: none">` + chooseData.id + `</td>
                        <td style="display: none" class="remark">` + chooseData.remark + `</td>
                        <td width="10%" style="background-color:#fff;border-bottom: 1px solid #E8F0F3;border-right: 1px solid #E8F0F3;"><span class="relaseGoods" style="color: #5AC4FC;cursor: pointer">释放</span></td>
                    </tr>`
                    $(".choosedGoodsList").append(trStr);
                }
            }

            $(".choosedGoodsTbody").each(function (i, ele) {

                var supplierTrClone2 = $(".goodsListTbody:first").clone();
                supplierTrClone2.find('.negativeInformationReduce').show();
                supplierTrClone2.find('.error').hide();
                supplierTrClone2.find('input').val('');
                supplierTrClone2.find('select').val('');

                supplierTrClone2.find('td').eq(1).find('input').val($(ele).find('td').eq(1).text())
                supplierTrClone2.find('td').eq(2).find('input').val($(ele).find('td').eq(2).text())
                supplierTrClone2.find('td').eq(3).find('input').val($(ele).find('td').eq(3).text())
                supplierTrClone2.find('td').eq(4).find('input').val($(ele).find('td').eq(4).text())
                supplierTrClone2.find('td').eq(5).find('input').val($(ele).find('td').eq(5).text())
                supplierTrClone2.find('td').eq(6).find('input').val($(ele).find('td.remark').text())
                supplierTrClone2.find('td').eq(1).find('input').attr('goodsId', $(ele).find('td').eq(7).text())
                supplierTrClone2.show();
                $('.goodsListTable').append(supplierTrClone2);
                sortIGoodsnfo();

            })
            $("#myModal-chooseGoods").modal("hide");
        })


    })
</script>
</html>
