{{:ModuleInclude('public/header')}}

<!-- right content start  -->
<div class="content-right">
    <div class="content">
        <!-- nav start -->
        {{if !isset($is_theme_data_admin) or $is_theme_data_admin eq 0}}
            {{:ModuleInclude('public/admin_nav', [
                'title'     => MyLang('themedata.base_nav_title').(empty($data['id']) ? MyLang('created_title') : MyLang('edit_title')),
                'back_url'  => MyUrl('admin/themedata/index', $params)
            ])}}
        {{/if}}
        <!-- nav end -->

        <!-- form start -->
        <form class="am-form form-validation am-form-full-screen am-form-popup-sticky" action="{{:MyUrl('admin/themedata/save')}}" method="POST" request-type="{{if !isset($is_theme_data_admin) or $is_theme_data_admin eq 0}}ajax-url{{else /}}ajax-reload{{/if}}" request-value="{{if !isset($is_theme_data_admin) or $is_theme_data_admin eq 0}}{{:MyUrl('admin/themedata/index', $params)}}{{else /}}parent{{/if}}">
            {{:ModuleInclude('public/nav_switch_btn', [
                'nav_data' => [
                    [
                        'name' => MyLang('system_title'),
                        'key'  => 'system',
                    ],
                    [
                        'name' => MyLang('base_title'),
                        'key'  => 'base',
                    ],
                    [
                        'name' => MyLang('data_title'),
                        'key'  => 'data',
                    ],
                ]
            ])}}
            <!-- nav end -->
            <div class="nav-content">
                <!-- 系统 -->
                <div class="item am-active" data-key="system">
                    {{:ModuleInclude('themedata/saveinfo/module/base', [
                        'common_theme_view_list'  => empty($common_theme_view_list) ? [] : $common_theme_view_list,
                        'theme_list'              => empty($theme_list) ? [] : $theme_list,
                        'data'                    => empty($data) ? [] : $data,
                    ])}}
                </div>

                <!-- 基础 -->
                <div class="item" data-key="base">
                    <!-- images -->
                    <div class="images-row-container form-custom-group">
                        {{:ModuleInclude('themedata/saveinfo/module/images', [
                            'common_theme_business_images_list'  => empty($common_theme_business_images_list) ? [] : $common_theme_business_images_list,
                            'data'                               => empty($data) ? [] : $data,
                        ])}}
                    </div>

                    <!-- input -->
                    <div class="text-row-container form-custom-group">
                        {{:ModuleInclude('themedata/saveinfo/module/text_input', [
                            'common_theme_business_text_input_list'  => empty($common_theme_business_text_input_list) ? [] : $common_theme_business_text_input_list,
                            'data'                                   => empty($data) ? [] : $data,
                        ])}}
                    </div>
                </div>

                <!-- 数据 -->
                <div class="item" data-key="data">
                    <div class="am-form-group am-padding-bottom-0">
                        <label class="am-block">{{:MyLang('common_service.themedata.form_item_goods_data_type')}}</label>
                        <div class="am-radio-group">
                            {{foreach $common_theme_goods_type_list as $v}}
                                <label class="am-radio-inline">
                                    <input type="radio" name="goods_data_type" value="{{$v.value}}"  data-validation-message="{{:MyLang('common_service.themedata.form_item_goods_data_type_message')}}" {{if (empty($data['data']) and !isset($data['data']['goods_data_type']) and isset($v['checked'])) or (!empty($data['data']) and isset($data['data']['goods_data_type']) and $data['data']['goods_data_type'] eq $v['value'])}}checked{{/if}} data-am-ucheck> {{$v.name}}
                                </label>
                            {{/foreach}}
                        </div>
                    </div>

                    <div class="data-type-container am-margin-top am-padding-bottom-sm">
                        <!-- 自动读取 -->
                        <div class="am-panel am-panel-default am-radius data-type-auto-container {{if !empty($data['data']) and isset($data['data']['goods_data_type']) and $data['data']['goods_data_type'] neq 0}}am-hide{{/if}}">
                            <div class="am-panel-bd am-padding-bottom-0">
                                <div class="am-form-group">
                                    <label class="am-block">{{:MyLang('common_service.themedata.form_item_goods_brand_ids')}}</label>
                                    <select name="goods_brand_ids" class="am-radius chosen-select" multiple data-placeholder="{{:MyLang('please_select_tips')}}" data-validation-message="{{:MyLang('common_service.themedata.form_item_goods_brand_ids_message')}}">
                                        {{if !empty($brand_list)}}
                                            {{foreach $brand_list as $v}}
                                                <option value="{{$v.id}}" {{if !empty($data['data']) and !empty($data['data']['goods_brand_ids']) and is_array($data['data']['goods_brand_ids']) and in_array($v['id'], $data['data']['goods_brand_ids'])}}selected{{/if}}>{{$v.name}}</option>
                                            {{/foreach}}
                                        {{/if}}
                                    </select>
                                </div>
                                <div class="am-form-group">
                                    <label>{{:MyLang('common_service.themedata.form_item_goods_category_ids')}}</label>
                                    <select name="goods_category_ids" class="am-radius chosen-select" multiple  data-placeholder="{{:MyLang('please_select_tips')}}" data-validation-message="{{:MyLang('common_service.themedata.form_item_goods_category_ids_message')}}">
                                        {{if !empty($goods_category_list)}}
                                            {{foreach $goods_category_list as $v}}
                                                <option value="{{$v.id}}" {{if !empty($data['data']) and !empty($data['data']['goods_category_ids']) and in_array($v['id'], $data['data']['goods_category_ids'])}}selected{{/if}}>{{$v.name}}</option>
                                                {{if !empty($v['items'])}}
                                                    {{foreach $v.items as $vs}}
                                                        <option style="padding-left: 20px;" value="{{$vs.id}}" {{if !empty($data['data']) and !empty($data['data']['goods_category_ids']) and in_array($vs['id'], $data['data']['goods_category_ids'])}}selected{{/if}}>{{if empty($vs['items'])}}├{{else /}}└{{/if}}² {{$vs.name}}</option>
                                                        {{if !empty($vs['items'])}}
                                                            {{foreach $vs.items as $kss=>$vss}}
                                                                <option style="padding-left: 40px;" value="{{$vss.id}}" {{if !empty($data['data']) and !empty($data['data']['goods_category_ids']) and in_array($vss['id'], $data['data']['goods_category_ids'])}}selected{{/if}}>{{if $kss eq count($vs['items'])-1}}└{{else /}}├{{/if}}³ {{$vss.name}}</option>
                                                            {{/foreach}}
                                                        {{/if}}
                                                    {{/foreach}}
                                                {{/if}}
                                            {{/foreach}}
                                        {{/if}}
                                    </select>
                                </div>
                                <div class="am-form-group">
                                    <label>{{:MyLang('common_service.themedata.form_item_goods_number')}}<span class="am-form-group-label-tips">{{:MyLang('common_service.themedata.form_item_goods_number_tips')}}</span></label>
                                    <input type="text" placeholder="{{:MyLang('common_service.themedata.form_item_goods_number')}}" name="goods_number" maxlength="100" data-validation-message="{{:MyLang('common_service.themedata.form_item_goods_number_message')}}" class="am-radius" value="{{if !empty($data['data']) and !empty($data['data']['goods_number'])}}{{$data.data.goods_number}}{{/if}}" />
                                </div>
                                <div class="am-form-group">
                                    <label class="am-block">{{:MyLang('common_service.themedata.form_item_goods_order_by_type')}}<span class="am-form-group-label-tips">{{:MyLang('common_service.themedata.form_item_goods_order_by_type_tips')}}</span></label>
                                    <div class="am-radio-group">
                                        {{foreach $common_goods_order_by_type_list as $k=>$v}}
                                            <label class="am-radio-inline">
                                                <input type="radio" name="goods_order_by_type" value="{{$k}}"  data-validation-message="{{:MyLang('common_service.themedata.form_item_goods_order_by_type_message')}}" {{if (empty($data['data']) and !isset($data['data']['goods_order_by_type']) and isset($v['checked'])) or (!empty($data['data']) and isset($data['data']['goods_order_by_type']) and $data['data']['goods_order_by_type'] eq $k)}}checked{{/if}} data-am-ucheck> {{$v.name}}
                                            </label>
                                        {{/foreach}}
                                    </div>
                                </div>
                                <div class="am-form-group">
                                    <label class="am-block">{{:MyLang('common_service.themedata.form_item_goods_order_by_rule')}}<span class="am-form-group-label-tips">{{:MyLang('common_service.themedata.form_item_goods_order_by_rule_tips')}}</span></label>
                                    <div class="am-radio-group">
                                        {{foreach $common_data_order_by_rule_list as $k=>$v}}
                                            <label class="am-radio-inline">
                                                <input type="radio" name="goods_order_by_rule" value="{{$k}}"  data-validation-message="{{:MyLang('common_service.themedata.form_item_goods_order_by_rule_message')}}" {{if (empty($data['data']) and !isset($data['data']['goods_order_by_rule']) and isset($v['checked'])) or (!empty($data['data']) and isset($data['data']['goods_order_by_rule']) and $data['data']['goods_order_by_rule'] eq $k)}}checked{{/if}} data-am-ucheck> {{$v.name}}
                                            </label>
                                        {{/foreach}}
                                    </div>
                                </div>
                            </div>
                        </div>

                        <!-- 指定商品 -->
                        <div class="am-panel am-panel-default am-radius data-type-appoint-container {{if empty($data['data']) or !isset($data['data']['goods_data_type']) or $data['data']['goods_data_type'] neq 1}}am-hide{{/if}}">
                            <div class="am-panel-bd am-padding-bottom-lg">
                                <ul class="manual-mode-data-container am-nbfc am-radius" data-form-name="goods_data">
                                    {{if isset($data['data']['goods_data_type']) and $data['data']['goods_data_type'] eq 1 and !empty($data['data']) and !empty($data['data']['goods_data']) and is_array($data['data']['goods_data'])}}
                                        {{foreach $data.data.goods_data as $v}}
                                            {{if !empty($v['data_id'])}}
                                                <li class="am-padding-left-sm manual-mode-data-item-{{$v.data_id}}">
                                                    <input type="hidden" name="goods_data[{{$v.data_id}}][data_id]" value="{{$v.data_id}}">
                                                    <ul class="plug-file-upload-view data-custom-cover-view-{{$v.data_id}}" data-form-name="goods_data[{{$v.data_id}}][custom_cover]" data-max-number="1" data-dialog-type="images" data-is-eye="1">
                                                        <li class="plug-file-upload-submit" data-view-tag="ul.data-custom-cover-view-{{$v.data_id}}">
                                                            {{if empty($v['custom_cover'])}}
                                                                <i class="iconfont icon-add"></i>
                                                            {{else /}}
                                                                <input type="text" name="goods_data[{{$v.data_id}}][custom_cover]" value="{{$v.custom_cover}}" />
                                                                <img src="{{$v.custom_cover}}" />
                                                                <i class="iconfont icon-close"></i>
                                                                <i class="iconfont icon-eye"></i>
                                                            {{/if}}
                                                        </li>
                                                    </ul>
                                                    <a href="{{$v.goods_url}}" target="_blank" class="am-text-truncate am-flex am-flex-items-center am-gap-1">
                                                        <img src="{{$v.images}}" class="am-border-c am-radius" width="35" height="35">
                                                        <span class="am-flex-1 am-flex-width">{{$v.title}}</span>
                                                    </a>
                                                    <button type="button" class="am-close am-fr">×</button>
                                                </li>
                                            {{/if}}
                                        {{/foreach}}
                                    {{/if}}
                                </ul>
                                <div class="am-margin-top">
                                    <span class="business-operations-submit goods-popup-add">+ {{:MyLang('common_service.themedata.add_goods_title')}}</span>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <div class="am-form-popup-submit">
                <input type="hidden" name="id" {{if !empty($data['id'])}} value="{{$data.id}}"{{/if}} />
                <input type="hidden" name="type" value="3"/>
                <button type="submit" class="am-btn am-btn-primary am-radius am-btn-xs btn-loading-example" data-am-loading="{spinner: 'circle-o-notch', loadingText:'{{:MyLang('save_title')}}'}">
                    <i class="am-icon-save"></i>
                    <span>{{:MyLang('save_title')}}</span>
                </button>
            </div>
        </form>
        <!-- form end -->
    </div>
</div>
<!-- right content end  -->

<!-- 商品添加弹窗 -->
{{:ModuleInclude('themedata/saveinfo/public/goods_search_popup')}}

<!-- url选择弹窗 -->
{{:ModuleInclude('themedata/saveinfo/public/url_choice_popup')}}

<!-- footer start -->
{{:ModuleInclude('public/footer')}}