<table class="signboard-table">
    <thead>
        <tr>
            <th style="min-width:72px;text-align:left;">
            {{if !select}}
            <span class="cd-ui-checkbox J_check-all {{
            (function(){
                var check = 'checked';
                    if(materialPlanList && materialPlanList.length && materialPlanList[versionIndex] && materialPlanList[versionIndex].materialList.length){
                        for(var i = 0, l = materialPlanList[versionIndex].materialList.length; i < l; i++){
                            if(!materialPlanList[versionIndex].materialList[i].check){
                                check = '';
                                return;
                            }
                        }
                    }else{
                        check = '';
                    }
                return check;
                })()
            }}"></span>
            {{/if}}
            快捷排序</th>
            <th>图片</th>
            <th>链接</th>
            <th><span data-tooltips="" data-direaction="right" data-content="该分类将作为计算BI排序的影响因子，如不填写，将影响BI排序准确性。">BI分类（非必填）</span></th>
            <th style="min-width:115px;">BI排序干预</th>
            {{if !select}}
            <th style="width:200px;">操作</th>
            {{/if}}
        </tr>
    </thead>
    <tbody class="J_product-group">
        {{each materialPlanList item index}}
            {{if index === versionIndex}}
                {{if item.materialList && item.materialList.length > 0}}
                {{each item.materialList subItem subIndex}}
                <tr data-index="{{subIndex}}">
                    <td class="black">
                        {{if !select}}
                            <span class="cd-ui-checkbox J_ui-checkbox {{if subItem.check}}checked{{/if}}"></span>
                            <select name="" value="{{subIndex+1}}">
                                <% for(var i = 0; i < item.materialList.length; i++){ %>
                                    <option {{if subIndex == i}}selected="selected"{{/if}} value="{{i+1}}">{{i+1}}</option>
                                <% } %>
                            </select>
                        {{else}}
                            {{subIndex+1}}
                        {{/if}}
                    </td>
                    <td class="center">
                      <div class="J_image image-item ad-image-item" data-path="materialPlanList[{{index}}].materialList[{{subIndex}}].picUrl">
                        <div style="height:100%;background-image:url({{subItem.picUrl}});background-repeat:no-repeat;background-size:contain;background-position:center;"></div>
                        {{if !select}}
                        <div class="mask">
                          {{if (terminalType === 2 && (imageHeight == 480 || imageHeight == 1350 || imageHeight == 450))}}
                            {{if subItem.bannerId && subItem.templateId}}
                            <span class="J_make-online">在线编辑</span>
                            {{else}}
                            <span class="J_make-online">在线制作</span>
                            {{/if}}
                          {{else}}
                            <span class="J_upload-image">上传图片</span>
                          {{/if}}
                          
                          <hr>
                          <span class="J_select-image">选择图片</span>
                        </div>
                        {{/if}}
                      </div>
                    </td>
                    <td class="center">
                        <div class="link-input {{if !select}}J_link{{/if}}" data-path="materialPlanList[{{index}}].materialList[{{subIndex}}].link">
                            {{if subItem.link.linkType !== undefined}}
                            <span class="l-label">
                                {{[,'自定义链接','商品链接','优惠券','店铺页-首页','店铺页-搜索结果页','店铺页-店铺简介页','店铺页-列表页','店铺页-会员中心','活动页','店铺分类','锚点','店铺页-详情页','店铺-自定义页','拍品链接','','医药商品','小程序插件','小程序'][subItem.link.linkType]}}
                            </span>
                            {{/if}}
                            <span class="cd-href">{{subItem.link.link}}</span>
                            <span class="cd-url"><span class="cd-icons cd-icons-link-icon"></span></span>
                        </div>
                    </td>
                    
                    <td style="width: 215px">
                        <div class="bi-sort-item">
                        {{if !select}}

                            {{if subItem.cid1 && subItem.cid1.length}}
                              {{each subItem.cid1 cid i}}
                                 <div class="cd-sort-group J_add" data-index={{i}}>
                                    <div class="sort-item">
                                        <span class="level one-level"><i>{{
                                        (function(cid){
                                            cid = cid.split('#')[1]
                                            return cid
                                        })(cid)
                                        }}</i></span>
                                        <span class="level two-level"><i>{{
                                        (function(cid){
                                            cid = cid.split('#')[1]
                                            return cid
                                        })(subItem.cid2[i])
                                        }}</i></span>
                                        <span class="level three-level"><i>{{
                                        (function(cid){
                                            cid = cid.split('#')[1]
                                            return cid
                                        })(subItem.cid3[i])
                                        }}</i></span>
                                    </div>
                                    <i class="cd-icons cd-icons-tab-module-del cd-level-close J_levelClose"></i>
                                 </div>
                               {{/each}}

                            {{/if}}

                            {{if !subItem.cid1 || (subItem.cid1 && subItem.cid1.length < 3) }}
                             <div class="cd-add J_add" data-index = {{if subItem.cid1}}{{subItem.cid1.length}}{{else}}0{{/if}}>
                                <span class="cd-add-icon">+</span>
                                <span>添加BI分类</span>
                                <span class="cd-number"> <i>{{if subItem.cid1}}{{subItem.cid1.length}}{{else}}0{{/if}}</i>/3</span>
                             </div>

                            {{/if}}

                          {{/if}}

                          {{if select}}
                              {{if subItem.cid1 && subItem.cid1.length}}
                                 {{each subItem.cid1 cid i}}
                                     <div class="cd-sort-group" data-index={{i}}>
                                        <div class="sort-item">
                                            <span class="level one-level"><i>{{
                                            (function(cid){
                                                cid = cid.split('#')[1]
                                                return cid
                                            })(cid)
                                            }}</i></span>
                                            <span class="level two-level"><i>{{
                                            (function(cid){
                                                cid = cid.split('#')[1]
                                                return cid
                                            })(subItem.cid2[i])
                                            }}</i></span>
                                            <span class="level three-level"><i>{{
                                            (function(cid){
                                                cid = cid.split('#')[1]
                                                return cid
                                            })(subItem.cid3[i])
                                            }}</i></span>
                                        </div>

                                     </div>
                               {{/each}}
                              {{else}}

                               暂未配置bi分类
                              {{/if}}
                          {{/if}}
                        </div>
                    </td>
                    <td><span class="cd-ui-checkbox {{if !select}}J_addBiSort{{/if}} {{if subItem.keepBiOrder}}checked{{/if}}"></span>BI后保持当前排序</td>
                    {{if !select}}
                    <td class="center">
                        <div class="tool black">
                            <span class="transition03 J_top {{if subIndex === 0}}disabled{{/if}}">上移</span>
                            <span class="transition03 J_bottom {{if subIndex+1 === item.materialList.length}}disabled{{/if}}">下移</span>
                            <span class="transition03 J_to-top {{if subIndex === 0}}disabled{{/if}}">置顶</span>
                            <span class="transition03 J_to-bottom {{if subIndex+1 === item.materialList.length}}disabled{{/if}}">置底</span>
                            
                            <span class="transition03 J_delete-item">删除</span>
                        </div>
                    </td>
                    {{/if}}
                </tr>
                {{/each}}
                {{else}}
                <tr>
                    <td style="text-align:center;" colspan="{{select ? 4 : 5}}">暂无数据</td>
                </tr>
                {{/if}}
            {{/if}}
        {{/each}}
    </tbody>
</table>
