<template>
  <div class="pane-up-wrap right-detail-toolbar">
    <el-toolbar>
      <el-button @click="saveSite" :loading="saveSiteLoading" :priv="`com.zving.cms.Site.Edit.${siteID}`">
        <i class="fa fa-floppy-o"></i>保存</el-button>
      <el-button @click="sortSiteClick" :priv="`com.zving.cms.Site.Edit.${siteID}`" >
        <i class="fa fa-sort"></i>排序</el-button>
      <el-button @click="publishIndexClick" :priv="`com.zving.cms.Site.Publish.${siteID}`">
        <i class="fa fa-paper-plane"></i>发布首页</el-button>
      <el-dropdown menu-align="start" @command="publish">
        <el-button @click="publish('-1')" :priv="`com.zving.cms.Site.Publish.${siteID}`">
          <i class="fa fa-arrow-circle-up"></i>发布全站 &nbsp;
          <i class="fa fa-caret-down"></i>
        </el-button>
        <el-dropdown-menu slot="dropdown">
          <el-dropdown-item command="30">
            <i class="fa fa-home"></i>发布已发布的文档</el-dropdown-item>
          <el-dropdown-item command="20" >
            <i class="fa fa-home"></i>发布待发布的文档</el-dropdown-item>
          <el-dropdown-item command="0" >
            <i class="fa fa-home"></i>发布初稿</el-dropdown-item>
          <el-dropdown-item command="60" >
            <i class="fa fa-home"></i>发布重新编辑的文档</el-dropdown-item>
          <el-dropdown-item command="40" >
            <i class="fa fa-home"></i>发布已下线的文档</el-dropdown-item>
          <el-dropdown-item command="-1" >
            <i class="fa fa-home"></i>发布所有文档</el-dropdown-item>
        </el-dropdown-menu>
        <el-dialog title="发布全站" :append-to-body="true" :visible.sync="isShowModal" class="publish-site-dlg">
          <span :style="{'margin-top':'20px'}">
            提示：<br>
              本次生成的静态页面将覆盖原有页面，确认生成所有静态页面吗？
          </span>
          <div :style="{'margin':'0 auto','margin-top':'10px'}">
            <el-checkbox v-model="isAppointTime">指定时间范围</el-checkbox>
          </div>
          <div v-if="isAppointTime" style="margin:0 auto;margin-top:10px">
              <el-date-picker id="publish-date-picker" class="layout-date-picker" v-model="dateInterval" type="datetimerange" start-placeholder="发布时间" end-placeholder="发布时间" style="width:100%"></el-date-picker>
          </div>
          <div slot="footer">
            <el-button @click="isShowModal= false">取 消</el-button>
            <el-button type="primary" v-loading="submitLoading" @click="confirm">确 定</el-button>
          </div>
        </el-dialog>
      </el-dropdown>
      <el-button @click="previewSite">
        <i class="fa fa-eye"></i>预览</el-button>
      <el-button @click="browseSite">
        <i class="fa fa-search"></i>浏览</el-button>
      <el-button @click="exportSite" :priv="`com.zving.cms.Site.Export.${siteID}`">
        <i class="fa fa-arrow-right"></i>导出站点</el-button>
      <c-import-button  @dialog="dialog" :dimension-id="1" :site-id="siteID" button-type="text"></c-import-button>
      <c-export-structure-button :site-id="siteID" button-type="text"></c-export-structure-button>
      <el-dropdown>
      <el-button>
        <i class="fa fa-ellipsis-h"></i>
      </el-button>
      <el-dropdown-menu slot="dropdown" class="button-dropdown">
        <el-dropdown-item>
          <el-button @click="assignPriv" type="text" :priv="`com.zving.cms.Site.AssignPriv.${siteID}`" style="width:100%;" class="left"><i class="fa fa-key"></i>分配权限</el-button>
        </el-dropdown-item>
        <el-dropdown-item>
          <el-button @click="linkCheckLog" type="text" :priv="`com.zving.cms.Site.Edit.${siteID}`" style="width:100%;" class="left"><i class="fa fa-link"></i>链接及文件检查</el-button>
        </el-dropdown-item>
        <el-dropdown-item :priv="`com.zving.cms.Site.Edit.${siteID}`">
          <el-button @click="copyTemplateFile" type="text" :priv="`com.zving.cms.Site.Edit.${siteID}`" style="width:100%;" class="left"><i class="fa fa-clone"></i>复制模板文件</el-button>
        </el-dropdown-item>
      </el-dropdown-menu>
    </el-dropdown>
    </el-toolbar>
    <div class="pane-wrap">
      <el-form :model="siteInfo" ref="siteInfoForm" :rules="siteInfoRules" label-width="180px" label-suffix="：" >
        <div class="panel-fieldset">
        <h4 class="panel-legend">基本属性</h4>
          <el-form-item prop="ID" label="站点ID">
            {{siteInfo.ID}}
          </el-form-item>
          <div v-if="siteInfo.parentID">
            <el-form-item prop="parentID" label="父站点ID">
              {{siteInfo.parentID}}
              <span style="color:gray;">({{siteInfo.parentName}})</span>
            </el-form-item>
          </div>
          <el-form-item prop="name" label="站点名称">
            <el-input v-model="siteInfo.name" class="form-item"></el-input>
          </el-form-item>
          <el-form-item prop="path" label="站点目录名">
            <el-input v-model="siteInfo.path" class="form-item"></el-input>
          </el-form-item>
          <el-form-item prop="branchInnerCode" label="所属机构">
            <tree-select :value.sync="siteInfo.branchInnerCode" :items="branchTree" :itemsOptions="treeItemsOptions"
              width="300"></tree-select>
          </el-form-item>
          <el-form-item prop="language" label="语言">
            <el-select v-model="siteInfo.language" class="form-item">
              <el-option v-for="item in langs" :key="item.key" :label="item.value" :value="item.key"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item prop="URL" label="站点URL">
            <el-input v-model="siteInfo.URL" class="form-item"></el-input>
            <el-tooltip class="item" effect="dark" content="站点URL需要http://或者https://开头 如：http://www.domain.com" placement="right-start">
              <i class="fa fa-lightbulb-o fa-lg" style="margin-left:5px;color:#FFC125;"></i>
            </el-tooltip>
          </el-form-item>
          <el-form-item prop="info" label="站点备注">
            <el-input type="textarea" v-model="siteInfo.info" :rows="2" class="form-item"></el-input>
          </el-form-item>
        </div>
        <div class="panel-fieldset">
          <h4 class="panel-legend">站点首页模板</h4>
          <div v-if="!siteInfo.indexTemplates">
            <el-form-item prop="indexTemplate" label="PC首页模板">
              <el-input value="template/index.template.html" disabled class="form-item"></el-input>
              <el-button-group>
                <el-button priv="ContentCore.TemplateMenu.Edit" type="primary" icon="edit" title="编辑模板" disabled></el-button>
                <el-button disabled style="width:60px;">浏览...</el-button>
              </el-button-group>
            </el-form-item>
          </div>
          <div v-else v-for="(item,index) in siteInfo.indexTemplates" :key="item.platformName">
            <el-form-item prop="indexTemplate" :label="item.platformName+'首页模板'">
              <el-input v-model="item.indexTemplate" class="form-item"></el-input>
              <el-button-group>
                <el-button type="primary" icon="edit" priv="ContentCore.TemplateMenu.Edit" title="编辑模板" @click="editTemplate(item)" :disabled="!siteID || !item.indexTemplate"></el-button>
                <el-button @click="browseTemplate(item,index)" style="width:60px;">浏览...</el-button>
              </el-button-group>
            </el-form-item>
          </div>
        </div>
        <div class="panel-fieldset">
          <h4 class="panel-legend">其他属性</h4>
          <el-form-item prop="logoSrc" label="Logo图片">
            <logo-path
              :path.sync="siteInfo.logoFile"
              :preview-path.sync="siteInfo.logoSrc"
              edit-position="right"
              :site-id="siteID"
              upload-title="上传站点Logo图片"
              :resource-dialog-props="resourceDialogProps"
              :disabled="!siteID"
            ></logo-path>
          </el-form-item>
          <div v-if="'Y'==config.showSiteSEOConfig">
            <el-form-item prop="SEOKeywords" label="SEO关键字">
              <el-input v-model="siteInfo.SEOKeywords" class="form-item"></el-input>
            </el-form-item>
            <el-form-item prop="SEODescription" label="SEO描述">
              <el-input type="textarea" v-model="siteInfo.SEODescription" :rows="2" class="form-item"></el-input>
            </el-form-item>
            <el-form-item prop="SEOTitle" label="SEO标题">
              <el-input v-model="siteInfo.SEOTitle" class="form-item"></el-input>
            </el-form-item>
          </div>
        </div>
      </el-form>
    </div>
    <!--站点排序 Dialog-->
    <siteSortDialog :show.sync="sortSiteModal" :siteID="siteID" :parentID="siteInfo.parentID" @callback="updateSiteTree"></siteSortDialog>

    <!--导出站点 Dialog-->
    <siteExportTypeDialog :show.sync="exportSiteModal" :siteID="siteID" @callback="exportSiteCallback"></siteExportTypeDialog>

    <!--链接及文件检查 -->
    <linkCheckDialog :show.sync="linkCheckModal" :siteID="siteID"></linkCheckDialog>

    <!--分配权限 Dialog-->
    <privOwnerTabsDialog :show.sync="privOwnerTabsModal" :ID="siteID" privType="Site"></privOwnerTabsDialog>

    <!-- 模板选择弹框 -->
    <templateSelectDialog :show.sync="templateSelectModal" :siteID="siteID" :type="template.type" :value="template.value" :platformID="template.platformID" @callback="templateCallback"></templateSelectDialog>
  </div>
</template>

<script src="./SiteInfo.js"></script>

<style>
.export-site-dialog .el-dialog {
  width: 500px;
}

@media (max-width: 480px) {
  .export-site-dialog .el-dialog {
    width: 90%;
  }
}

.publish-site-dlg .el-dialog{
  width:400px;
}
@media (max-width:480px){
  .publish-site-dlg .el-dialog{
    width:96%;
  }
}
</style>
