<extend name="Public/base" />
<block name="css">
    <link rel="stylesheet" type="text/css" href="__CSS__/admin_table.css" media="all">
    <link rel="stylesheet" type="text/css" href="__STATIC__/webuploader/webuploader.css" media="all">
    <style>
        #form .txt_area.download_url {width:400px;}
        .tabcon1711 .table_radio2 .table_btn {width:215px;}
        .move200 {margin-left: -1000px;}
        .move150 {margin-left: -150px;}
    </style>
</block>
<block name="body">
    <script type="text/javascript" src="__STATIC__/uploadify/jquery.uploadify.min.js"></script>

    <script src="__STATIC__/md5.js" type="text/javascript" charset="utf-8"></script>
    <script type="text/javascript" src="__STATIC__/webuploader/webuploader.js"></script>
    <script src="__STATIC__/layer/layer.js" type="text/javascript"></script>
    <script type="text/javascript" src="__STATIC__/layer/extend/layer.ext.js"></script>
    <script src="__STATIC__/juicer-min.js" type="text/javascript"></script>

    <!-- 标签页导航 -->
    <div class="tab-wrap">
        <div class="cf main-place top_nav_list navtab_list">
            <ul class="tabnav1711 fr jstabnav">
                <li data-tab="tab1" id="tab_tab1" class="current"><a href="javascript:void(0);">基本信息</a></li>
                <li data-tab="tab2" id="tab_tab2"><a href="javascript:void(0);">结算信息</a></li>
            </ul>
            <h3 class="page_title">{$meta_title}</h3>
        </div>

        <div class="tab-content tabcon1711">
            <!-- 表单 -->
            <form id="form" action="{:U('edit')}" method="post" class="form-horizontal" autocomplete="off">
                <!-- 基础 -->
                <div id="tab1" class="tab-pane in tab1 ">
                    <table  border="0" cellspacing="0" cellpadding="0">
                        <tbody>
                        <tr>
                            <td class="l"><i class="mustmark" style="margin-left:-7px">*</i>合同合作方名称:</td>
                            <td class="r" >
                                <input type="text" class="txt " name="partner" id="partner" value="{$data.partner}" placeholder="请输入合作方名称">
                            </td>
                        </tr>

                        <tr>
                            <td class="l">对应平台(简称):</td>
                            <td class="r" >
                                <input type="text" class="txt " name="matche_platform" value="{$data.matche_platform}" placeholder="请输入对应平台">
                            </td>
                        </tr>

                        <tr>
                            <td class="l">合同期限:</td>
                            <td class="r">
                                <input type="text" class="txt time time1" name="contract_start_time" value="{$data.contract_start_time}" placeholder="请选择开始时间">
                                -<input type="text" class="txt time time2" name="contract_end_time" value="{$data.contract_end_time}" placeholder="请选择结束时间">
                                <span class="notice-text" style="float: none;">结束时间不选默认永久</span>
                            </td>
                        </tr>

                        

                        <tr>
                            <td class="l noticeinfo"><i class="mustmark" style="margin-left:-7px">*</i>是否有预付款:</td>
                            <td class="r table_radio">
                                <span class="form_radio table_btn">
                                    <label>
                                        <input type="radio" class="inp_radio" value="0"  name="has_advance_charge" <if condition="$data['has_advance_charge'] eq 0">checked</if>> 否
                                    </label>
                                    <label>
                                        <input type="radio" class="inp_radio" value="1"  name="has_advance_charge" <if condition="$data['has_advance_charge'] eq 1">checked</if>> 是
                                    </label>
                                </span>
                                <span class="notice-text"></span>
                            </td>
                        </tr>

                        <tr>
                            <td class="l noticeinfo"><i class="mustmark" style="margin-left:-7px">*</i>承担服务费:</td>
                            <td class="r table_radio">
                                <span class="form_radio table_btn" style="width: auto;">
                                    <label>
                                        <input type="radio" class="inp_radio" value="0"  name="has_server_fee" <if condition="$data['has_server_fee'] eq 0">checked</if>> 否
                                       
                                    </label>
                                    <label>
                                        <input type="radio" class="inp_radio" value="1"  name="has_server_fee" <if condition="$data['has_server_fee'] eq 1">checked</if>> 是
                                    </label>
                                </span>
                                <span class="notice-text" id="server_fee_input" style="color: #000;<if condition="$data['has_server_fee'] eq 0">display: none;</if>"><input type="text" class="txt " name="server_fee" value="{$data['server_fee']}" placeholder="请输入服务器费用" style="width: 100px;">&nbsp;&nbsp;元</span>
                            </td>
                        </tr>

                        <tr>
                            <td class="l noticeinfo"><i class="mustmark" style="margin-left:-7px">*</i>合作关系:</td>
                            <td class="r table_radio">
                                <span class="form_radio table_btn">
                                    <label>
                                        <input type="radio" class="inp_radio" value="1"  name="cooperation_status" <if condition="$data['cooperation_status'] eq 1">checked</if>> 合作中
                                    </label>
                                    <label>
                                        <input type="radio" class="inp_radio" value="0"  name="cooperation_status" <if condition="$data['cooperation_status'] eq 0">checked</if>> 停止合作
                                    </label>
                                </span>
                                <span class="notice-text"></span>
                            </td>
                        </tr>

                        <tr>
                            <td class="l noticeinfo"><i class="mustmark" style="margin-left:-7px">*</i>显示状态:</td>
                            <td class="r table_radio">
                                <span class="form_radio table_btn">
                                    <label>
                                        <input type="radio" class="inp_radio" value="1"  name="status" <if condition="$data['status'] eq 1">checked</if>> 开启
                                    </label>
                                    <label>
                                        <input type="radio" class="inp_radio" value="0"  name="status" <if condition="$data['status'] eq 0">checked</if>> 关闭
                                    </label>
                                </span>
                                <span class="notice-text"></span>
                            </td>
                        </tr>

                        <tr>
                            <td class="l noticeinfo">文档管理</td>
                            <td class="r table_radio">
                                <input type="button" class="coin-detail" data-url="{:U('Ajax/addfile')}" value="添加"
                                       style="border-radius:5%;background: #fff;color: #333;font-weight: 400;border: 1px solid #777;width: 100px;height: 35px">
                            </td>
                        </tr>
                        </tbody>
                    </table>
                    <table  border="1" style="width: 600px;text-align: center;margin-left:50px;" cellspacing="0" cellpadding="0" id="docShow">

                    </table>
                </div>
                <div id="tab2" class="tab-pane tab2 ">
                    <table  border="0" cellspacing="0" cellpadding="0">
                        <tbody>
                            <!--<tr>
                                <td class="l"><i class="mustmark" style="margin-left:-7px">*</i>合作方式:</td>
                                <td class="r">
                                  <select name="relation[collaborate_way]" id="collaborate_way" class="select_gallery">
                                    <option  value="1" <?php if($relation['collaborate_way'] == 1):?>selected<?php endif;?>>甲方</option>
                                    <option  value="2" <?php if($relation['collaborate_way'] == 2):?>selected<?php endif;?>>乙方</option>
                                  </select>
                                  <span class="notice-text"></span>
                                </td>
                            </tr>
                            -->
                            <tr>
                                <td class="l"><i class="mustmark" style="margin-left:-7px">*</i>甲方公司类型:</td>
                                <td class="l" style="width: 50px;">
                                    <select name="part_a_type" id="part_a_type" class="select_gallery">
                                        <option  value="2" <?php if($relation['collaborate_way'] == 1):?>selected<?php endif;?>>上游CP公司</option>
                                        <option  value="1" <?php if($relation['collaborate_way'] == 2):?>selected<?php endif;?>>己方公司</option>
                                    </select>
                                    <span class="notice-text"></span>
                                </td>
                                <td class="l" style="width: 100px;"><i class="mustmark" >*</i>乙方公司类型:</td>
                                <td class="r">
                                    <select name="part_b_type" id="part_b_type" class="select_gallery">
                                        <option  value="1" <?php if($relation['collaborate_way'] == 2):?>selected<?php endif;?>>上游CP公司</option>
                                        <option  value="2" <?php if($relation['collaborate_way'] == 1):?>selected<?php endif;?>>己方公司</option>
                                    </select>
                                    <span class="notice-text"></span>
                                </td>
                            </tr>

                            <!--<tr>
                                <td class="l"><i class="mustmark" style="margin-left:-7px">*</i>己方公司:</td>
                                <td class="r">
                                  <select name="relation[self_company_id]" id="self_company" class="select_gallery">
                                      <option value="0">无</option>
                                      <?php foreach($selfCompanies as $selfCompany):?>
                                      <option value="<?=$selfCompany['id']?>" <?php if($relation['self_company_id'] == $selfCompany['id']):?>selected<?php endif;?>><?=$selfCompany['company_name']?></option>
                                      <?php endforeach;?>
                                  </select>
                                  <span class="notice-text"></span>
                                </td>
                            </tr>-->
                            <?php if($relation['collaborate_way'] == 2):?>
                            <tr>
                                <td class="l"><i class="mustmark" style="margin-left:-7px">*</i>甲方公司:</td>
                                <td class="l" style="width: 50px;">
                                    <select name="part_a" id="part_a" class="select_gallery">
                                        <volist name="selfCompanies" id="vo">
                                            <option value="{$vo['id']}" <if condition="$vo['id'] eq $relation['self_company_id']">selected</if>>{$vo['company_name']} </option>
                                        </volist>
                                    </select>

                                    <span class="notice-text"></span>
                                </td>
                                <td class="l" style="width: 90px;"><i class="mustmark" >*</i>乙方公司:</td>
                                <td class="r">
                                    <select name="part_b" id="part_b" class="select_gallery">
                                        <option id="cp_company" value='1'></option>
                                    </select>
                                    <span class="notice-text"></span>
                                </td>
                            </tr>
                            <?php endif;?>
                            <?php if($relation['collaborate_way'] == 1):?>
                            <tr>
                                <td class="l"><i class="mustmark" style="margin-left:-7px">*</i>甲方公司:</td>
                                <td class="l" style="width: 50px;">
                                    <select name="part_a" id="part_a" class="select_gallery">
                                        <option id="cp_company" value='1'></option>
                                    </select>
                                    <span class="notice-text"></span>
                                </td>
                                <td class="l" style="width: 90px;"><i class="mustmark" >*</i>乙方公司:</td>
                                <td class="r">
                                    <select name="part_b" id="part_b" class="select_gallery">
                                        <volist name="selfCompanies" id="vo">
                                            <option value="{$vo['id']}" <if condition="$vo['id'] eq $relation['self_company_id']">selected</if>>{$vo['company_name']} </option>
                                        </volist>
                                    </select>
                                    <span class="notice-text"></span>
                                </td>
                            </tr>
                            <?php endif;?>

                            <tr>
                                <td class="l"><i class="mustmark" style="margin-left:-7px">*</i>结算周期:</td>
                                <td class="r">
                                  <select name="relation[settlement_type]" id="settlement_type" class="select_gallery">
                                    <option  value="0" <?php if($relation['settlement_type'] == 0):?>selected<?php endif;?>>无</option>
                                    <option  value="1" <?php if($relation['settlement_type'] == 1):?>selected<?php endif;?>>周结</option>
                                    <option  value="2" <?php if($relation['settlement_type'] == 2):?>selected<?php endif;?>>月结</option>
                                  </select>
                                  <span class="notice-text"></span>
                                </td>
                            </tr>
                            <tr>
                                <td class="l"><i class="mustmark" style="margin-left:-7px">*</i>开票类型:</td>
                                <td class="r">
                                    <select name="relation[invoice_type]" id="invoice_type" class="select_gallery">
                                        <option  value="0" <?php if($relation['invoice_type'] == 0):?>selected<?php endif;?>>无</option>
                                        <option  value="1" <?php if($relation['invoice_type'] == 1):?>selected<?php endif;?>>专票</option>
                                        <option  value="2" <?php if($relation['invoice_type'] == 2):?>selected<?php endif;?>>普票</option>
                                    </select>
                                    <span class="notice-text"></span>
                                </td>
                            </tr>
                            <tr>
                                <td class="l">开票内容:</td>
                                <td class="r table_radio">
                                  <input type="text" name="relation[invoice_content]" id="invoice_content" class="input" value="<?=$relation['invoice_content']?>"></textarea>
                                </td>
                            </tr>
                            <tr>
                                <td class="l">是否有打款流程:</td>
                                <td class="r table_radio">
                                <span class="form_radio table_btn" style="width: 100px;">
                                    <label>
                                        <input type="radio" value="1" name="relation[is_payment]" <?php if($relation['is_payment'] == 1):?>checked<?php endif;?>> 是
                                    </label>
                                    <label>
                                        <input type="radio" value="2" name="relation[is_payment]" <?php if($relation['is_payment'] == 2):?>checked<?php endif;?>> 否
                                    </label>
                                    </span>
                                    <span class="notice-text">选择否将不能进行线上打款</span>
                                </td>
                            </tr>
                            <tr>
                                <td class="l"><i class="mustmark" style="margin-left:-7px">*</i>收款方:</td>
                                <td class="r">
                                  <select name="relation[collection]" id="collection" class="select_gallery">
                                      <option  value="1" <?php if($relation['collection'] == 1):?>selected<?php endif;?>>甲方</option>
                                      <option  value="2" <?php if($relation['collection'] == 2):?>selected<?php endif;?>>乙方</option>
                                  </select>
                                  <span class="notice-text"></span>
                                </td>
                            </tr>
                            <tr>
                                <td class="l">结算生效期限:</td>
                                <td class="r" style="width: 640px;">
                                    <input type="text" class="txt time time3" name="validity_start_time" value="{$data.validity_start_time}" placeholder="生效开始时间">
                                    -<input type="text" class="txt time time4" name="validity_end_time" value="{$data.validity_end_time}" placeholder="生效结束时间">
                                    <span class="notice-text" style="float: none;">结束时间不选默认永久</span>
                                </td>
                            </tr>
    
                            <tr>
                                <td class="l">渠道费率:</td>
                                <td class="r" >
                                    <input type="text" class="txt " name="channel_rate" value="{$data.channel_rate}" placeholder="渠道费率(最多两位小数)"> <span style="margin-left: 3px;padding-top: 5px">%</span>
                                </td>
                            </tr>
    
                            <tr>
                                <td class="l">开票税点:</td>
                                <td class="r" >
                                    <input type="text" class="txt " name="invoice_rate" value="{$data.invoice_rate}" placeholder="开票税点(最多两位小数)"><span style="margin-left: 3px;padding-top: 5px">%</span>
                                </td>
                            </tr>
                            <tr>
                                <td class="l">税费费率:</td>
                                <td class="r" >
                                    <input type="text" class="txt " name="taxation_rate" value="{$data.taxation_rate}" placeholder="税费费率(最多三位小数)"><span style="margin-left: 3px;padding-top: 5px">%</span>
                                </td>
                            </tr>
    
    
    
                            <tr>
                                <td class="l noticeinfo">是否签署合同:</td>
                                <td class="r">
                                    <select name="is_sign_contract" class="select_gallery">
                                        <!-- <option value="">请选择是否签署合同</option> -->
                                        <option value="1" <if condition="$data['is_sign_contract'] eq '1'">  selected="selected"</if>>是</option>
                                        <option value="0" <if condition="$data['is_sign_contract'] eq '0'">  selected="selected"</if>>否</option>
                                    </select>
                                </td>
                            </tr>
    
                            <!-- <tr>
                                <td class="l noticeinfo">结算方式:</td>
                                <td class="r">
                                    <select name="settlement_type" class="select_gallery">
                                        <option value="0" <if condition="$data['settlement_type'] eq '0'">  selected="selected"</if>>无</option>
                                        <option value="1" <if condition="$data['settlement_type'] eq '1'">  selected="selected"</if>>周结</option>
                                        <option value="2" <if condition="$data['settlement_type'] eq '2'">  selected="selected"</if>>月结</option>
                                    </select>
                                </td>
                            </tr> -->
    
                            <tr>
                                <td class="l noticeinfo">结算性质:</td>
                                <td class="r">
                                    <select name="company_type" class="select_gallery">
                                        <option value="1" <if condition="$data['company_type'] eq '1'">  selected="selected"</if>>公司</option>
                                        <option value="2" <if condition="$data['company_type'] eq '2'">  selected="selected"</if>>个人</option>
                                    </select>
                                </td>
                            </tr>
    
                            <tr>
                                <td class="l noticeinfo">是否有游戏资质:</td>
                                <td class="r">
                                    <select name="has_game_evidence" class="select_gallery">
                                        <!-- <option value="">请选择是否有游戏资质</option> -->
                                        <option value="1" <if condition="$data['has_game_evidence'] eq '1'">  selected="selected"</if>>是</option>
                                        <option value="0" <if condition="$data['has_game_evidence'] eq '0'">  selected="selected"</if>>否</option>
                                    </select>
                                </td>
                            </tr>
    
                            <tr>
                                <td class="l">联系人:</td>
                                <td class="r" >
                                    <input type="text" class="txt " name="link_man" value="{$data.link_man}" placeholder="请输入联系人">
                                </td>
                            </tr>
    
                            <tr>
                                <td class="l">联系电话:</td>
                                <td class="r" >
                                    <input type="text" class="txt " name="link_phone" value="{$data.link_phone}" placeholder="请输入联系电话">
                                </td>
                            </tr>
    
                            <tr>
                                <td class="l">注册地址:</td>
                                <td class="r" >
                                    <input type="text" class="txt " name="reg_address" value="{$data.reg_address}" placeholder="请输入注册地址">
                                </td>
                            </tr>
                            <tr>
                                <td class="l">注册电话:</td>
                                <td class="r" >
                                    <input type="text" class="txt " name="reg_phone" value="{$data.reg_phone}" placeholder="请输入注册电话">
                                </td>
                            </tr>
    
                            <tr>
                                <td class="l">邮寄地址:</td>
                                <td class="r" >
                                    <input type="text" class="txt " name="address" value="{$data.address}" placeholder="请输入邮寄地址">
                                </td>
                            </tr>
    
                            <tr>
                                <td class="l">公司税号:</td>
                                <td class="r" >
                                    <input type="text" class="txt " name="company_tax_no" value="{$data.company_tax_no}" placeholder="请输入公司税号">
                                </td>
                            </tr>
    
                            <tr>
                                <td class="l">账户名:</td>
                                <td class="r" >
                                    <input type="text" class="txt " name="payee_name" value="{$data.payee_name}" placeholder="请输入收款方名称">
                                </td>
                            </tr>
    
                            <tr>
                                <td class="l">银行账号:</td>
                                <td class="r" >
                                    <input type="text" class="txt " name="bank_account" value="{$data.bank_account}" placeholder="请输入银行账号">
                                </td>
                            </tr>
    
    
                            <tr>
                                <td class="l">收款银行:</td>
                                <td class="r" >
                                    <input type="text" class="txt " name="opening_bank" value="{$data.opening_bank}" placeholder="请输入开户行">
                                </td>
                            </tr>
    
                            <tr>
                                <td class="l">支付宝真实姓名:</td>
                                <td class="r" >
                                    <input type="text" class="txt " name="ali_user" value="{$data.ali_user}" placeholder="请输入支付宝真实姓名">
                                </td>
                            </tr>
                            
                            <tr>
                                <td class="l">支付宝登陆账号:</td>
                                <td class="r" >
                                    <input type="text" class="txt " name="ali_account" value="{$data.ali_account}" placeholder="可以是手机及邮箱等">
                                </td>
                            </tr>
    
                            <tr>
                                <td class="l">备注:</td>
                                <td class="r">
                                    <input type="text" name="remark" class="txt" value="{$data.remark}" placeholder="请输入备注">
                                </td>
                            </tr>
                        </tbody>
                    </table>
                </div>
                <div class="form-item cf">
                    <input class="submit_btn" type="button" value="保存" id="submit2"  target-form="form-horizontal" style="margin-left:210px;">
                    <a class="submit_btn " alt="返回上一页" title="返回上一页" href="{:U('Partner/lists')}" >
                        返回
                    </a>
                </div>
                <input type="hidden" name="id" value="{$data.id}">
            </form>
        </div>
    </div>
    <div class="common_settings">
        <span class="plus_icon"><span><img src="__IMG__/zwmimages/icon_jia.png"></span></span>
        <form class="addShortcutIcon">
            <input type="hidden" name="title" value="{$meta_title}">
            <input type="hidden" name="url" value="Partner/add">
        </form>
        <a class="ajax-post add-butn <notempty name='commonset'>addSIsetted</notempty>" href="javascript:;" target-form="addShortcutIcon" url="{:U('Think/addShortcutIcon')}"><img src="__IMG__/zwmimages/icon_jia.png"><span><notempty name='commonset'>已添加<else />添加至常用设置</notempty></span></a>
    </div>

    <script type="text/html" id="doctpl">
        {@each list as it,index}
        {@if index==0}
        <thead>
        <tr>
            <th>文档名称</th>
            <th>上传时间</th>
            <th style="width:150px;">操作</th>
        </tr>
        </thead>
        {@/if}
        <tr>
            <td style="padding:0;">${it.file_name}</td>
            <td>${it.upload_time}</td>
            <td>
                <a class="filedown" data-index="${index}" data-path="${it.file_path}">下载</a>
                <a class="filedel" data-index="${index}" data-path="${it.file_path}">删除</a>
            </td>
        </tr>
        {@/each}
    </script>
</block>

<block name="script">
    <link href="__STATIC__/datetimepicker/css/datetimepicker.css" rel="stylesheet" type="text/css">
    <link href="__STATIC__/datetimepicker/css/dropdown.css" rel="stylesheet" type="text/css">
    <script type="text/javascript" src="__STATIC__/datetimepicker/js/bootstrap-datetimepicker.min.js"></script>
    <script type="text/javascript" src="__STATIC__/datetimepicker/js/locales/bootstrap-datetimepicker.zh-CN.js" charset="UTF-8"></script>
    <script type="text/javascript">
        // 切换select
        function selectRemove(id, typeId) {
            $(id).children().remove();
            indexNum = $(typeId).children('option:selected').index();
            if (indexNum == 0) {
                $(id).append("<option value='1'>" + $("#partner").val() + "</option>");
            }
            if (indexNum == 1) {
                "<?php foreach($selfCompanies as $selfCompany):?>"
                $(id).append(
                    "<option value=\"<?=$selfCompany['id']?>\" <?php if($selfCompany['company_name']=='海南万盟天下科技有限公司'):?>selected<?php endif;?>><?=$selfCompany['company_name']?></option>"
                );
                "<?php endforeach;?>";
            }
        }
        $(function() {
            if (!$("#partner").val()) {
                $("#tab_tab1").click();
            }
            $("#cp_company").text($("#partner").val());

            $("#tab_tab2").click(function() {
                if (!$("#partner").val()) {
                    alert('请填写合作方名称');
                    $("#tab_tab1").click();
                }

                $("#cp_company").text($("#partner").val());
                // $("#part_a").children().remove();
                // $("#part_a").append("<option value='1'>" + $("#partner").val() + "</option>");
                return false;
            });

            $("#part_a_type").change(function() {
                selectRemove("#part_a", "#part_a_type");

                indexBSelect = 0;
                if (indexNum == 0) {
                    indexBSelect = 1;
                }
                if (indexNum == 1) {
                    indexBSelect = 0;
                }

                $("#part_b_type").get(0).selectedIndex = indexBSelect;

                selectRemove("#part_b", "#part_b_type");

            });

            $("#part_b_type").change(function() {
                selectRemove("#part_b", "#part_b_type");

                indexASelect = 0;
                if (indexNum == 0) {
                    indexASelect = 1;
                }
                if (indexNum == 1) {
                    indexASelect = 0;
                }

                $("#part_a_type").get(0).selectedIndex = indexASelect;

                selectRemove("#part_a", "#part_a_type");
            });

        });


        showTab();
        $("input[type=radio][name=has_server_fee]").on('change', function (e) {
        var v = $(this).val();
            if(v == 1){
                $("#server_fee_input").show();
            }else{
                $("#server_fee_input").hide();
            }
      });
        $('.time1').datetimepicker({
            format: 'yyyy-mm-dd',
            language:"zh-CN",
            minView: "month",
            autoclose:true
        }).change(function(){
            var start = new Date($(this).val()).getTime();
            var end = new Date($('.time2').val()).getTime();

            if(isNaN(end)) {return false;}

            if(start>=end) {layer.msg('开始时间必须小于结束时间');return false;}

            return false;
        });

        $('.time2').datetimepicker({
            format: 'yyyy-mm-dd',
            language:"zh-CN",
            minView: "month",
            autoclose:true
        }).change(function(){
            var end = new Date($(this).val()).getTime();
            var start = new Date($('.time1').val()).getTime();

            if(isNaN(start)) {return false;}

            if(start>=end) {layer.msg('开始时间必须小于结束时间');return false;}

            return false;
        });

        $('.time3').datetimepicker({
            format: 'yyyy-mm-dd',
            language:"zh-CN",
            minView: "month",
            autoclose:true
        }).change(function(){
            var start = new Date($(this).val()).getTime();
            var end = new Date($('.time4').val()).getTime();

            if(isNaN(end)) {return false;}

            if(start>=end) {layer.msg('开始时间必须小于结束时间');return false;}

            return false;
        });

        $('.time4').datetimepicker({
            format: 'yyyy-mm-dd',
            language:"zh-CN",
            minView: "month",
            autoclose:true
        }).change(function(){
            var end = new Date($(this).val()).getTime();
            var start = new Date($('.time3').val()).getTime();

            if(isNaN(start)) {return false;}

            if(start>=end) {layer.msg('开始时间必须小于结束时间');return false;}

            return false;
        });

        //导航高亮
        highlight_subnav("{:U('Partner/lists')}");
    </script>

    <script>
        var doc = <?php echo ($data['file_info'] ?: "''") ?>;
        if(!doc){
            doc = [];
        }
        function addFile(info) {
            doc.push(info);
            layer.closeAll();
            PROMOTE.juicerFun();

            // window.parent.addFile(info);
        }
        $(".coin-detail").click(function () {
            var url = $(this).data('url');
            var title =  '文档添加';
            layer.open({
                type: 2,
                title: title,
                shadeClose: true,
                shade: 0.8,
                area: ['40%', '60%'],
                content: url
            });
        });
        $("#submit2").on("click",function(){
            var cres = $('form').serializeArray();
            //验证通过
            if(doc.length > 0){
                cres.push({"name":"file_info", "value":JSON.stringify(doc)});
            }
            //添加
            $.ajax({
                url:"{:U('partner/edit')}",
                type:"post",
                data:cres,
                dataType:"json",
                success:function(data){
                    if(data.status == 1){
                        layer.msg(data.info,function(){
                            window.location.href="{:U('partner/lists')}";
                        });
                    }else{
                        layer.msg(data.info);
                    }
                },
                error:function(e){

                }
            });

        })
        $('#invoice_type').change(function () {
            var val = $(this).val()
            if (val == 0) {
                $('#invoice_content').val('')
            } else {
                $('#invoice_content').val('信息服务费')
            }
        })
        var PROMOTE = {
            juicerFun(){
                var tpl =$("#doctpl").html();
                var html =  juicer(tpl, {list:doc});
                $("#docShow").html(html);
                PROMOTE.juicerEvent();
            },
            juicerEvent(){
                $(".filedown,.filedel").off("click");
                $(".filedown").on("click",function(){
                    var url = window.location.protocol+"//"+window.location.host+$(this).data("path");
                    // window.open(url,"_blank");
                    var link = document.createElement('a');
                    link.setAttribute("download", "");
                    link.href = url;
                    link.click()
                });
                $(".filedel").on("click",function(){
                    var path = $(this).data("path");
                    var index = $(this).data("index");
                    console.log(index);
                    var id = 0;
                    $.ajax({
                        url:"{:U('Ajax/delFile')}",
                        type:"post",
                        data:{
                            "id":0,
                            "file_path":path
                        },
                        dataType:"json",
                        success:function(data){
                            if(data.status == 1){
                                doc.splice(index,1)
                                PROMOTE.juicerFun();
                            }else{
                                layer.alert(data.info);
                            }
                        },
                        error:function(e){

                        }
                    });
                })
            }
        }
        PROMOTE.juicerFun();
    </script>
</block>