{{: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">
                    <ul class="data-article-container"
                        data-original-article-type-list="{{:urlencode(base64_encode(json_encode($common_theme_article_type_list)))}}"
                        data-original-brand-list="{{:urlencode(base64_encode(json_encode($brand_list)))}}"
                        data-original-article-category-list="{{:urlencode(base64_encode(json_encode($article_category_list)))}}"
                        data-original-article-order-by-type-list="{{:urlencode(base64_encode(json_encode($common_article_order_by_type_list)))}}"
                        data-original-order-by-rule-list="{{:urlencode(base64_encode(json_encode($common_data_order_by_rule_list)))}}"

                        data-form-item-images-icon="{{:MyLang('common_service.themedata.form_item_images_icon')}}"
                        data-form-item-images-active-icon="{{:MyLang('common_service.themedata.form_item_images_active_icon')}}"
                        data-form-item-images-shape="{{:MyLang('common_service.themedata.form_item_images_shape')}}"
                        data-form-item-images-background="{{:MyLang('common_service.themedata.form_item_images_background')}}"
                        data-form-item-text-title="{{:MyLang('common_service.themedata.form_item_text_title')}}"
                        data-form-item-text-title-message="{{:MyLang('common_service.themedata.form_item_text_title_message')}}"
                        data-form-item-text-vice-title="{{:MyLang('common_service.themedata.form_item_text_vice_title')}}"
                        data-form-item-text-vice-title-message="{{:MyLang('common_service.themedata.form_item_text_vice_title_message')}}"
                        data-form-item-text-more="{{:MyLang('common_service.themedata.form_item_text_more')}}"
                        data-form-item-text-more-message="{{:MyLang('common_service.themedata.form_item_text_more_message')}}"
                        data-form-item-text-btn="{{:MyLang('common_service.themedata.form_item_text_btn')}}"
                        data-form-item-text-btn-message="{{:MyLang('common_service.themedata.form_item_text_btn_message')}}"
                        data-form-item-text-describe="{{:MyLang('common_service.themedata.form_item_text_describe')}}"
                        data-form-item-text-describe-message="{{:MyLang('common_service.themedata.form_item_text_describe_message')}}"

                        data-form-item-article-data-type="{{:MyLang('common_service.themedata.form_item_article_data_type')}}"
                        data-form-item-article-data-type-message="{{:MyLang('common_service.themedata.form_item_article_data_type_message')}}"
                        data-form-item-article-category-ids="{{:MyLang('common_service.themedata.form_item_article_category_ids')}}"
                        data-form-item-article-category-ids-message="{{:MyLang('common_service.themedata.form_item_article_category_ids_message')}}"
                        data-form-item-article-number="{{:MyLang('common_service.themedata.form_item_article_number')}}"
                        data-form-item-article-number-tips="{{:MyLang('common_service.themedata.form_item_article_number_tips')}}"
                        data-form-item-article-number-message="{{:MyLang('common_service.themedata.form_item_article_number_message')}}"
                        data-form-item-article-order-by-type="{{:MyLang('common_service.themedata.form_item_article_order_by_type')}}"
                        data-form-item-article-order-by-type-tips="{{:MyLang('common_service.themedata.form_item_article_order_by_type_tips')}}"
                        data-form-item-article-order-by-type-message="{{:MyLang('common_service.themedata.form_item_article_order_by_type_message')}}"
                        data-form-item-article-order-by-rule="{{:MyLang('common_service.themedata.form_item_article_order_by_rule')}}"
                        data-form-item-article-order-by-rule-tips="{{:MyLang('common_service.themedata.form_item_article_order_by_rule_tips')}}"
                        data-form-item-article-order-by-rule-message="{{:MyLang('common_service.themedata.form_item_article_order_by_rule_message')}}"
                        data-add-article-title="{{:MyLang('common_service.themedata.add_article_title')}}"
                        data-please-select-tips="{{:MyLang('please_select_tips')}}"
                    >
                        {{if !empty($data['data']) and !empty($data['data']['data']) and is_array($data['data']['data'])}}
                            {{foreach $data.data.data as $dk=>$dv}}
                                <li class="data-article-item-container">
                                    <div class="am-panel am-panel-default am-radius">
                                        <div class="am-panel-bd">
                                            <!-- 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'                               => ['data'=>$dv],
                                                    'appoint_form_name_first'            => 'data['.$dk.']',
                                                    'index'                              => $dk,
                                                    'appoint_business_images'            => ['icon', 'active_icon', 'shape', 'background'],
                                                ])}}
                                            </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'                                   => ['data'=>$dv],
                                                    'appoint_form_name_first'                => 'data['.$dk.']',
                                                    'index'                                  => $dk,
                                                    'appoint_business_text'                  => ['title', 'vice_title', 'more', 'btn', 'describe'],
                                                ])}}
                                            </div>

                                            <!-- 数据类型 -->
                                            <div class="am-form-group am-padding-bottom-0">
                                                <label class="am-block">{{:MyLang('common_service.themedata.form_item_article_data_type')}}</label>
                                                <div class="am-radio-group">
                                                    {{foreach $common_theme_article_type_list as $v}}
                                                        <label class="am-radio-inline">
                                                            <input type="radio" name="data[{{$dk}}][article_data_type]" value="{{$v.value}}"  data-validation-message="{{:MyLang('common_service.themedata.form_item_article_data_type_message')}}" {{if (!isset($dv['article_data_type']) and isset($v['checked'])) or (isset($dv['article_data_type']) and $dv['article_data_type'] eq $v['value'])}}checked{{/if}} class="article_data_type" data-am-ucheck> {{$v.name}}
                                                        </label>
                                                    {{/foreach}}
                                                </div>
                                            </div>
                                            <hr data-am-widget="divider" class="am-divider am-divider-dashed" />
                                            <!-- 数据类型选择容器 -->
                                            <div class="data-type-container am-padding-bottom-sm">
                                                <!-- 自动读取 -->
                                                <div class="data-type-auto-container {{if isset($dv['article_data_type']) and $dv['article_data_type'] neq 0}}am-hide{{/if}}">
                                                    <div class="am-form-group">
                                                        <label>{{:MyLang('common_service.themedata.form_item_article_category_ids')}}</label>
                                                        <select name="data[{{$dk}}][article_category_ids]" class="am-radius chosen-select" multiple  data-placeholder="{{:MyLang('please_select_tips')}}" data-validation-message="{{:MyLang('common_service.themedata.form_item_article_category_ids_message')}}">
                                                            {{if !empty($article_category_list)}}
                                                                {{foreach $article_category_list as $v}}
                                                                    <option value="{{$v.id}}" {{if !empty($dv['article_category_ids']) and in_array($v['id'], $dv['article_category_ids'])}}selected{{/if}}>{{$v.name}}</option>
                                                                {{/foreach}}
                                                            {{/if}}
                                                        </select>
                                                    </div>
                                                    <div class="am-form-group">
                                                        <label>{{:MyLang('common_service.themedata.form_item_article_number')}}<span class="am-form-group-label-tips">{{:MyLang('common_service.themedata.form_item_article_number_tips')}}</span></label>
                                                        <input type="text" placeholder="{{:MyLang('common_service.themedata.form_item_article_number')}}" name="data[{{$dk}}][article_number]" maxlength="100" data-validation-message="{{:MyLang('common_service.themedata.form_item_article_number_message')}}" class="am-radius" value="{{if !empty($dv['article_number'])}}{{$dv.article_number}}{{/if}}" />
                                                    </div>
                                                    <div class="am-form-group">
                                                        <label class="am-block">{{:MyLang('common_service.themedata.form_item_article_order_by_type')}}<span class="am-form-group-label-tips">{{:MyLang('common_service.themedata.form_item_article_order_by_type_tips')}}</span></label>
                                                        <div class="am-radio-group">
                                                            {{foreach $common_article_order_by_type_list as $k=>$v}}
                                                                <label class="am-radio-inline">
                                                                    <input type="radio" name="data[{{$dk}}][article_order_by_type]" value="{{$dk}}"  data-validation-message="{{:MyLang('common_service.themedata.form_item_article_order_by_type_message')}}" {{if (!isset($dv['article_order_by_type']) and isset($v['checked'])) or (isset($dv['article_order_by_type']) and $dv['article_order_by_type'] eq $k)}}checked{{/if}} data-am-ucheck> {{$v.name}}
                                                                </label>
                                                            {{/foreach}}
                                                        </div>
                                                    </div>
                                                    <div class="am-form-group am-padding-bottom-0">
                                                        <label class="am-block">{{:MyLang('common_service.themedata.form_item_article_order_by_rule')}}<span class="am-form-group-label-tips">{{:MyLang('common_service.themedata.form_item_article_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="data[{{$dk}}][article_order_by_rule]" value="{{$dk}}"  data-validation-message="{{:MyLang('common_service.themedata.form_item_article_order_by_rule_message')}}" {{if (!isset($dv['article_order_by_rule']) and isset($v['checked'])) or (isset($dv['article_order_by_rule']) and $dv['article_order_by_rule'] eq $k)}}checked{{/if}} data-am-ucheck> {{$v.name}}
                                                                </label>
                                                            {{/foreach}}
                                                        </div>
                                                    </div>
                                                </div>

                                                <!-- 指定文章 -->
                                                <div class="data-type-appoint-container {{if !isset($dv['article_data_type']) or $dv['article_data_type'] neq 1}}am-hide{{/if}}">
                                                    <ul class="manual-mode-data-container manual-mode-data-container-{{$dk}} am-nbfc am-radius" data-form-name="data[{{$dk}}][article_data]" data-index="{{$dk}}">
                                                        {{if isset($dv['article_data_type']) and $dv['article_data_type'] eq 1 and !empty($dv['article_data']) and is_array($dv['article_data'])}}
                                                            {{foreach $dv.article_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="data[{{$dk}}][article_data][{{$v.data_id}}][data_id]" value="{{$v.data_id}}">
                                                                        <ul class="plug-file-upload-view data-custom-cover-view-{{$dk}}-{{$v.data_id}}" data-form-name="data[{{$dk}}][article_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-{{$dk}}-{{$v.data_id}}">
                                                                                {{if empty($v['custom_cover'])}}
                                                                                    <i class="iconfont icon-add"></i>
                                                                                {{else /}}
                                                                                    <input type="text" name="data[{{$dk}}][article_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.url}}" target="_blank" rel="noopener noreferrer" class="am-text-truncate am-flex am-flex-items-center am-gap-1">
                                                                            {{if !empty($v['cover'])}}
                                                                                <img src="{{$v.cover}}" class="am-border-c am-radius" width="35" height="35">
                                                                            {{/if}}
                                                                            <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 article-popup-add" data-tag=".manual-mode-data-container-{{$dk}}">+ {{:MyLang('common_service.themedata.add_article_title')}}</span>
                                                    </div>
                                                </div>
                                            </div>
                                            <!-- 操作 -->
                                            <div class="am-flex am-flex-items-center am-gap-32 am-margin-top content-item-operate">
                                                <a href="javascript:;" class="am-text-xs am-text-danger content-item-remove-submit am-flex am-flex-items-center">
                                                    <i class="iconfont icon-delete"></i>
                                                    <span>{{:MyLang('delete_title')}}</span>
                                                </a>
                                                <a href="javascript:;" class="am-text-xs drag-sort-submit am-flex am-flex-items-center">
                                                    <i class="iconfont icon-sort"></i>
                                                    <span>{{:MyLang('sort_title')}}</span>
                                                </a>
                                            </div>
                                        </div>
                                    </div>
                                </li>
                            {{/foreach}}
                        {{/if}}
                    </ul>
                    <div class="am-nbfc am-padding-bottom-xl">
                        <span class="business-operations-submit articlegroup-content-add-submit am-border-0 am-text-sm">
                            <i class="iconfont icon-add"></i>
                            <span>{{:MyLang('add_data_title')}}</span>
                        </span>
                    </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="6"/>
                <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/article_search_popup')}}

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

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