<template>
  <div>
    <el-dialog
      :title="title"
      :append-to-body="true"
      :modal-append-to-body="true"
      :close-on-click-modal="false"
      :visible.sync="showDialog"
      :modal="false"
      custom-class="dialog-style list-dialog dialog-checkbox pd_8"
      width="400px"
      v-el-drag-dialog
      v-el-dialog-center
      @close="handleClose"
    >
      <div class="cont" style="height: 550px;">
        <el-form ref="editForm" :model="fileObjAuth" label-width="110px" class="adSearchForm"
                 style="width: 362px;height: auto;">
          <el-form-item label="文件路径">
            <el-breadcrumb separator-class="el-icon-arrow-right">
              <template v-for="(treeNode,index) in treeNodeArr">
                <el-breadcrumb-item v-if="!fileObjAuth._isParent || index<treeNodeArr.length-1" :key="index">{{
                    treeNode.label
                  }}
                </el-breadcrumb-item>
              </template>
            </el-breadcrumb>
          </el-form-item>
          <el-form-item prop="nickName" :label="$t2('机构', 'components.fileLibrary.saleOrg')"
                        :rules="[{ required: false, trigger: 'blur' }]">
            <el-input
              class="search-input"
              v-model="fileObjAuth.saleOrgName"
              clearable
              @clear="
                fileObjAuth.saleOrgId = null;
              "
              v-if="!fileObjAuth._isParent"
              v-el-readonly
            >
              <i slot="suffix" class="el-input__icon el-icon-search" @click="showSaleOrgDialog=true"></i>
            </el-input>
            <span v-else>{{ fileObjAuth.saleOrgName }}</span>
          </el-form-item>
          <el-form-item prop="nickName" :label="$t2('岗位', 'components.fileLibrary.position')"
                        :rules="[{ required: false, trigger: 'blur' }]">
            <el-input
              class="search-input"
              v-model="fileObjAuth.positionName"
              clearable
              @clear="
                fileObjAuth.positionId = null;
              "
              v-if="!fileObjAuth._isParent"
              v-el-readonly
            >
              <i slot="suffix" class="el-input__icon el-icon-search" @click="showPositionDialog=true"></i>
            </el-input>
            <span v-else>{{ fileObjAuth.positionName }}</span>
          </el-form-item>
          <el-form-item prop="nickName" :label="$t2('用户', 'components.fileLibrary.user')"
                        :rules="[{ required: false, trigger: 'blur' }]">
            <el-input
              class="search-input"
              v-model="fileObjAuth.nickName"
              clearable
              @clear="
                fileObjAuth.userId = null;
              "
              v-if="!fileObjAuth._isParent"
              v-el-readonly
            >
              <i slot="suffix" class="el-input__icon el-icon-search" @click="showUserDialog=true"></i>
            </el-input>
            <span v-else>{{ fileObjAuth.nickName }}</span>
          </el-form-item>
          <el-form-item prop="roleName" :label="$t2('角色', 'components.fileLibrary.role')"
                        :rules="[{ required: false, trigger: 'blur' }]">
            <el-input
              class="search-input"
              v-model="fileObjAuth.roleName"
              clearable
              @clear="
                fileObjAuth.roleId = null;
              "
              v-if="!fileObjAuth._isParent"
              v-el-readonly
            >
              <i slot="suffix" class="el-input__icon el-icon-search" @click="showRoleDialog=true"></i>
            </el-input>
            <span v-else>{{ fileObjAuth.roleName }}</span>
          </el-form-item>
          <el-form-item prop="addAuth" :label="$t2('新增', 'components.fileLibrary.add')"
                        :rules="[{ required: false, trigger: 'blur' }]">
            <el-switch v-model="fileObjAuth.addAuth" :active-value="1" :inactive-value="0"
                       :disabled="fileObjAuth._isParent"/>
          </el-form-item>
          <el-form-item prop="editAuth" :label="$t2('编辑', 'components.fileLibrary.edit')"
                        :rules="[{ required: false, trigger: 'blur' }]">
            <el-switch v-model="fileObjAuth.editAuth" :active-value="1" :inactive-value="0"
                       :disabled="fileObjAuth._isParent"/>
          </el-form-item>
          <el-form-item prop="viewAuth" :label="$t2('查看', 'components.fileLibrary.view')"
                        :rules="[{ required: false, trigger: 'blur' }]">
            <el-switch v-model="fileObjAuth.viewAuth" :active-value="1" :inactive-value="0"
                       :disabled="fileObjAuth._isParent"/>
          </el-form-item>
          <el-form-item prop="uploadAuth" :label="$t2('上传', 'components.fileLibrary.upload')"
                        :rules="[{ required: false, trigger: 'blur' }]">
            <el-switch v-model="fileObjAuth.uploadAuth" :active-value="1" :inactive-value="0"
                       :disabled="fileObjAuth._isParent"/>
          </el-form-item>
          <el-form-item prop="downloadAuth" :label="$t2('下载', 'components.fileLibrary.download')"
                        :rules="[{ required: false, trigger: 'blur' }]">
            <el-switch v-model="fileObjAuth.downloadAuth" :active-value="1" :inactive-value="0"
                       :disabled="fileObjAuth._isParent"/>
          </el-form-item>
          <el-form-item prop="moveAuth" :label="$t2('移动', 'components.fileLibrary.move')"
                        :rules="[{ required: false, trigger: 'blur' }]">
            <el-switch v-model="fileObjAuth.moveAuth" :active-value="1" :inactive-value="0"
                       :disabled="fileObjAuth._isParent"/>
          </el-form-item>
          <el-form-item prop="copyAuth" :label="$t2('复制', 'components.fileLibrary.copy')"
                        :rules="[{ required: false, trigger: 'blur' }]">
            <el-switch v-model="fileObjAuth.copyAuth" :active-value="1" :inactive-value="0"
                       :disabled="fileObjAuth._isParent"/>
          </el-form-item>
          <el-form-item prop="replaceAuth" :label="$t2('替换', 'components.fileLibrary.replace')"
                        :rules="[{ required: false, trigger: 'blur' }]">
            <el-switch v-model="fileObjAuth.replaceAuth" :active-value="1" :inactive-value="0"
                       :disabled="fileObjAuth._isParent"/>
          </el-form-item>
          <el-form-item prop="deleteAuth" :label="$t2('删除文件', 'components.fileLibrary.deleteFile')"
                        :rules="[{ required: false, trigger: 'blur' }]">
            <el-switch v-model="fileObjAuth.deleteAuth" :active-value="1" :inactive-value="0"
                       :disabled="fileObjAuth._isParent"/>
          </el-form-item>
          <el-form-item prop="deleteDirAuth" :label="$t2('删除文件夹', 'components.fileLibrary.deleteCategory')"
                        :rules="[{ required: false, trigger: 'blur' }]">
            <el-switch v-model="fileObjAuth.deleteDirAuth" :active-value="1" :inactive-value="0"
                       :disabled="fileObjAuth._isParent"/>
          </el-form-item>
          <el-form-item prop="historyAuth" :label="$t2('查看历史', 'components.fileLibrary.checkHistory')"
                        :rules="[{ required: false, trigger: 'blur' }]">
            <el-switch v-model="fileObjAuth.historyAuth" :active-value="1" :inactive-value="0"
                       :disabled="fileObjAuth._isParent"/>
          </el-form-item>
          <el-form-item prop="shareAuth" :label="$t2('分享', 'components.fileLibrary.share')"
                        :rules="[{ required: false, trigger: 'blur' }]">
            <el-switch v-model="fileObjAuth.shareAuth" :active-value="1" :inactive-value="0"
                       :disabled="fileObjAuth._isParent"/>
          </el-form-item>
          <el-form-item v-if="fileStoreArea.toDownWatermark" prop="downWatermarkAuth" :label="$t1('下载打水印')"
                        :rules="[{ required: false, trigger: 'blur' }]">
            <el-switch v-model="fileObjAuth.downWatermarkAuth" :active-value="1" :inactive-value="0"
                       :disabled="fileObjAuth._isParent"/>
          </el-form-item>

          <el-form-item prop="shareAuth" :label="$t1('设置权限')"
                        :rules="[{ required: false, trigger: 'blur' }]">
            <el-switch v-model="fileObjAuth.authAuth" :active-value="1" :inactive-value="0"
                       :disabled="fileObjAuth._isParent"/>
          </el-form-item>
        </el-form>
      </div>
      <span slot="footer" class="dialog-footer">
      <el-button type="primary" plain class="button-sty" @click="handleClose">
        <i class="el-icon-close el-icon"></i>
        取 消
      </el-button>
      <el-button type="primary" @click="saveData" class="button-sty" v-if="!fileObjAuth._isParent">
        <i class="el-icon-check el-icon"></i>
        确 定
      </el-button>
    </span>
    </el-dialog>
    <userDialog v-if="showUserDialog" :visiable.sync="showUserDialog" @confirm="confirmInsertUser"
                multi="false"/>
    <saleOrgDialog v-if="showSaleOrgDialog" :visiable.sync="showSaleOrgDialog" @confirm="confirmInsertSaleOrg"
                   multi="false"/>
    <positionDialog v-if="showPositionDialog" :visiable.sync="showPositionDialog" @confirm="confirmInsertPosition"
                    multi="false"/>
    <roleDialog v-if="showRoleDialog" :visiable.sync="showRoleDialog" @confirm="confirmInsertRole"
                multi="false"/>
  </div>
</template>

<script>
import mixin from "./mixins/fileObjAuthEditDialogMixin";

export default {
  mixins: [mixin]
};
</script>
