<template>
    <el-container id="repositoryMain" style="overflow: hidden;">
        <el-header v-if="!havingWritePerm || havingCreatePerm" :height="headerHeight2">
        </el-header>
        <el-header v-if="havingWritePerm || havingCreatePerm" :height="headerHeight1">
            <div style="margin: 12px 0px 10px;text-align: center;">
                <el-popover
                        v-if="havingWritePerm || havingCreatePerm"
                        placement="bottom"
                        width="280"
                        trigger="click"
                        :visible-arrow=false
                        v-model="createDesignerVisible"
                        @show="showCreateEvent">
                    <div v-loading="createMethodLoading" element-loading-text="拼命加载中" class="new-repository-box">
                        <div>
                            <ul>
                                <li style="margin-bottom: 7px;" v-for="row in Math.ceil(fileMethodList.length/4)">
                                    <template v-for="item in fileMethodList.slice((row-1)*4, row*4)">
                                        <div class="new-repository-item"
                                             :style="{opacity: item.opacity, filter: item.filter, cursor: item.cursor}"
                                             @click="item.clickFlag && createDesigner(item.app,item.category,item.method)">
                                            <div style="position: relative;top: 9px;">
                                                <div class="icon-div-repository" :title="item.methodName"
                                                     :style="{'background-color': item.icon.color}">
                                                    <i class="awsui-iconfont icon-dynamic-repository"
                                                       v-html="item.icon.code"></i>
                                                </div>
                                              <el-tooltip effect="dark" :content="item.methodName" placement="bottom">
                                                <div class="item-name text-general-color icon-text">
                                                    <label :style="{cursor: item.cursor}">{{item.methodName}}</label>
                                                </div>
                                              </el-tooltip>
                                            </div>
                                        </div>
                                    </template>
                                </li>
                            </ul>
                        </div>
                        <!--分隔线-->
                        <div style="border-bottom: 1px solid #F2F2F2;"></div>
                        <div style="margin-top: 7px;">
                            <ul>
                                <li>
                                    <template v-for="item in folderMethodList">
                                        <div class="new-repository-item"
                                             :style="{opacity: item.opacity, filter: item.filter, cursor: item.cursor}"
                                             @click="item.clickFlag && createFolder(item.method, item.methodName)">
                                            <div style="position: relative;top: 4px;">
                                                <div class="icon-div-repository">
                                                    <i class="awsui-iconfont icon-fixed-repository" :style="{'color': item.icon.color}" v-html="item.icon.code"></i>
                                                </div>
                                                <div class="item-name text-general-color fixed-icon-text">
                                                    <label :style="{cursor: item.cursor}">{{item.methodName}}</label>
                                                </div>
                                            </div>
                                        </div>
                                    </template>
                                  <!-- <div class="new-repository-item" style="cursor: pointer;" @click="importDesigners">
                                        <div style="position: relative;top: 4px;">
                                            <div class="icon-div-repository">
                                                <i class="iconfont text-linker-color icon-fixed-repository">&#xe671;</i>
                                            </div>
                                            <div class="item-name text-general-color fixed-icon-text">
                                                <label style="cursor: pointer;">导入模型</label>
                                            </div>
                                        </div>
                                    </div>-->
                                </li>
                            </ul>
                        </div>
                    </div>
                    <awsui-button slot="reference" style="width: 100%;height: 36px;margin: 0;font-size: 14px;"
                                  :class="{'button-general-color': !dis}" type="primary"  :disabled="dis" >新建
                    </awsui-button>
                </el-popover>
            </div>
            <!-- 【伊利需求】左侧新增查询条件 -->
            <div class="condition-box" style="margin-bottom: 10px;display: flex;justify-content: space-evenly;">
                <!-- 创建人 -->
                <el-popover
                        placement="bottom"
                        width="310"
                        trigger="click"
                        >
                    <template slot="default">
                        <div class="create-user-box">
                            <el-input size="mini" placeholder="请输入用户名" v-model="searchUserName" class="input-with-select">
                                <el-button slot="append" icon="el-icon-search" @click="searchUserNameText"></el-button>
                            </el-input>
                            <div style="margin: 6px 0;">
                                <el-checkbox v-model="currentUserCheck" @change="handleCheckCurrentUserChange">
                                    <div style="font-weight: 600;">
                                        <span>{{ currentUser.userName }}</span><span style="margin-left: 15px;">(当前用户)</span>
                                    </div>
                                </el-checkbox>
                            </div>
                            <el-divider></el-divider>
                            <div style="margin: 4px 0;">
                                <el-checkbox :indeterminate="userIndeterminate" v-model="userCheckAll" @change="handleCheckAllUserChange"><span style="font-weight: 600">全部</span></el-checkbox>
                            </div>
                            <div style="overflow: auto;height: 88px;">
                                <el-checkbox-group v-model="checkCreateUserIds" @change="handleCheckedUserChange">
                                    <el-checkbox v-for="item in createUserList" :label="item.userId" :key="item.userId">
                                        <div style="display: inline-flex;justify-content: space-between;width: 280px;font-weight: 600;">
                                            <span>{{item.userName}}</span>
                                            <el-tooltip class="item" effect="dark" :content="item.deptName" placement="bottom">
                                                <span style="margin-left: 55px;">{{ item.deptNameView }}</span>
                                            </el-tooltip>
                                        </div>
                                    </el-checkbox>
                                </el-checkbox-group>
                            </div>
                        </div>
                    </template>
                    <div slot="reference" style="cursor: pointer">
                        <span style="font-size: 12px;color: rgb(147,147,153);margin-right: 8px;">创建人</span><span style="color: rgb(147,147,153);"><i class="el-icon-arrow-down"></i></span>
                    </div>
                </el-popover>
                <el-divider direction="vertical"></el-divider>
                <!-- 组织机构 -->
                <el-popover
                        placement="bottom"
                        width="300"
                        trigger="click"
                        >
                    <template slot="default">
                        <div class="org-box">
                            <el-input size="mini" placeholder="请输入组织" v-model="searchOrgName" class="input-with-select">
                                <el-button slot="append" icon="el-icon-search" @click="searchOrgNameFun"></el-button>
                            </el-input>
                            <div style="margin: 6px 0;">
                                <el-checkbox v-model="currentUserDeptCheck" @change="handleCheckCurrentUserDeptChange">
                                    <div style="font-weight: 600;">
                                        <span>{{ currentUser.userName }}</span>
                                        <el-tooltip class="item" effect="dark" :content="currentUser.deptName" placement="bottom">
                                            <span style="margin-left: 110px;">({{ currentUser.deptNameView }})</span>
                                        </el-tooltip>
                                    </div>
                                </el-checkbox>
                            </div>
                            <el-divider></el-divider>
                            <div style="overflow: auto;height: 305px;">
                                <el-tree
                                        ref="orgTree"
                                        :props="treeProps"
                                        :show-checkbox="multiple"
                                        :expand-on-click-node=false
                                        :check-strictly=true
                                        :highlight-current=true
                                        @node-collapse="closeNodeOrg"
                                        :filter-node-method="filterNode"
                                        :default-expanded-keys="expandKeys"
                                        @check-change="orgCheckChange"
                                        node-key="id"
                                        lazy
                                        :load="loadNodeOrg">
                                    <span slot-scope="{node, data}">
                                      <i class="awsui-iconfont tree-content-icon tree-content-icon-padding" :style="{'color': node.data.icon.color}" v-html="node.data.icon.icon"></i>
                                      <span>{{node.label}}</span>
                                    </span>
                                </el-tree>
                            </div>
                        </div>
                    </template>
                    <div slot="reference" style="cursor: pointer">
                        <span style="font-size: 12px;color: rgb(147,147,153);margin-right: 8px;">组织机构</span><span style="color: rgb(147,147,153);"><i class="el-icon-arrow-down"></i></span>
                    </div>
                </el-popover>
                <el-divider direction="vertical"></el-divider>
                <!-- 文件类型 -->
                <el-popover
                        placement="bottom-end"
                        width="200"
                        trigger="click"
                        >
                    <template slot="default">
                        <div class="methodId-box">
                            <el-input size="mini" placeholder="请输入文件类型" v-model="methodIdText" class="input-with-select">
                                <el-button slot="append" icon="el-icon-search" @click="searchMethodIdText"></el-button>
                            </el-input>
                            <div style="margin: 6px 0;">
                                <el-checkbox :indeterminate="isIndeterminate" v-model="checkAll" @change="handleCheckAllChange">全部类型</el-checkbox>
                            </div>
                            <el-divider></el-divider>
                            <el-checkbox-group v-model="checkMethodIds" @change="handleCheckedMethodIdChange">
                                <el-checkbox v-for="item in methodIds" :label="item.methodId" :key="item.methodId">{{item.name}}</el-checkbox>
                            </el-checkbox-group>
                        </div>
                    </template>
                    <div slot="reference" style="cursor: pointer">
                        <span style="font-size: 12px;color: rgb(147,147,153);margin-right: 8px;">文件类型</span><span style="color: rgb(147,147,153);"><i class="el-icon-arrow-down"></i></span>
                    </div>
                </el-popover>
                <el-divider direction="vertical"></el-divider>
                <!-- 筛选条件置空 -->
                <el-tooltip class="item" effect="dark" content="筛选条件清空" placement="bottom">
                    <span style="cursor: pointer;color: rgb(147, 147, 153);font-size: 15px;" @click="clearConditionData"><i class="el-icon-refresh-right"></i></span>
                </el-tooltip>
            </div>
            <div v-if="havingWritePerm || havingCreatePerm" style="width: 100%;border-bottom: 1px solid #F2F2F2;"></div>
        </el-header>
        <el-main class="main-tree" :style="{'overflow': 'auto', 'height': treeHeight}">
            <el-tree
                    ref="tree"
                    :props="treeProps"
                    :expand-on-click-node=false
                    :highlight-current=true
                    @node-click="openNode"
                    @node-expand="expandNode"
                    @node-collapse="closeNode"
                    node-key="id"
                    lazy
                    :load="loadNode">
        <span slot-scope="{node, data}" >
          <i class="awsui-iconfont tree-content-icon tree-content-icon-padding" :style="{'color': node.data.icon.color}"
             v-html="node.data.icon.icon"></i>
             <el-tooltip class="item" effect="dark" :content="node.label" placement="top">  
                <span :style="{'font-weight': data.id.length < 36 ? '600' : ''}">{{node.label}}</span>
            </el-tooltip>
             
        </span>
            </el-tree>
        </el-main>
        <el-dialog
                :title="folderDialog.folderTitle"
                :visible.sync="folderDialog.dialogVisible"
                :modal-append-queryTreeByIdAndPathto-body=false
                :close-on-click-modal=false
                :close-on-press-escape=true
                :before-close="handleCloseFolder"
                width="600px">
            <div style="border: 1px solid #F2F2F2;padding: 0px 10px 10px 10px;">
                <awsui-form :model="folderDialog.folderForm" :rules="folderDialog.rules" ref="folderForm"
                            label-position="top">
                    <awsui-form-item label="名称" prop="name">
                        <awsui-input v-model="folderDialog.folderForm.name"></awsui-input>
                    </awsui-form-item>
                    <awsui-form-item v-if="folderDialog.folderMethod =='default'" label="描述" prop="desc">
                        <awsui-input type="textarea" v-model="folderDialog.folderForm.desc"></awsui-input>
                    </awsui-form-item>
                </awsui-form>
            </div>
            <span slot="footer" class="dialog-footer">
            <awsui-button class="button-general-color" type="primary" @click="createFolderSave('folderForm')">确定</awsui-button>
            <awsui-button @click="clearFolderDlg">取消</awsui-button>
          </span>
        </el-dialog>


        <el-dialog
                :title="ModelsetUpDialog.systemTitle"
                :visible.sync="ModelsetUpDialog.dialogVisible"
                :modal-append-queryTreeByIdAndPathto-body=false
                :close-on-click-modal=false
                :close-on-press-escape=true
                :before-close="handleCloseSystem"
                width="600px">
            <div style="border: 1px solid #F2F2F2;padding: 0px 10px 10px 10px;" >
                <awsui-form :model="ModelsetUpDialog.systemForm" :rules="ModelsetUpDialog.rules" ref="systemForm"
                            label-position="top">
                    <awsui-form-item label="当前选定路径">
                        <awsui-input v-model="ModelsetUpDialog.systemForm.repositoryPathData" disabled></awsui-input>
                    </awsui-form-item>
                    <awsui-form-item label="名称" prop="name">
                        <awsui-input v-model="ModelsetUpDialog.systemForm.name"></awsui-input>
                    </awsui-form-item>
                    <template v-if="ModelsetUpDialog.systemForm.method=='control.policy' ||  ModelsetUpDialog.systemForm.method=='control.oaApprove'">
                        <awsui-form-item label="制度类型" >
                            <awsui-select v-model="ModelsetUpDialog.systemForm.systemType" :options="ModelsetUpDialog.systemForm.SystemTypeOptions" placeholder="请选择制度类型"></awsui-select>
                        </awsui-form-item>
                    </template>

                </awsui-form>
            </div>
            <span slot="footer" class="dialog-footer">
            <awsui-button  class="button-general-color" type="primary" @click="createSystemSave('systemForm')" :loading="isLoading">确定</awsui-button>
            <awsui-button @click="clearSystemDlg">取消</awsui-button>
          </span>
        </el-dialog>


        <awsui-dialog
                title="密级标定"
                :visible.sync="securityVisible"
                :border="false"
                append-to-body
                width="500px">
            <div style="max-height:500px;overflow-y: auto">
                <awsui-form :ref="file.uuid" label-width="200px" :rules="securityRules" v-for="file in securityFileList" :key="file.uuid" :model="file">
                    <awsui-form-item :label="file.name"  prop="securityLevel">
                        <awsui-select v-model="file.securityLevel" :options="securityOptions" style="width:70%"></awsui-select>
                    </awsui-form-item>
                </awsui-form>
            </div>
            <div slot="footer" class="dialog-footer">
                <awsui-button type="primary" @click="uploadServer">确定</awsui-button>
                <awsui-button @click="securityVisible = false">取 消</awsui-button>
            </div>
        </awsui-dialog>
        <RepositoryImport ref="repositoryImport"></RepositoryImport>
    </el-container>
</template>

<script>
    import RepositoryImport from "./RepositoryImport";
    import {openDesigner} from "../../api/commonFun";
    import awsuiAxios from "../../awsuiAxios";
    import bus from '../../eventBus'

    export default {
        name: "RepositoryTree",
        components: {RepositoryImport},
        props: {
          conditionData: {
            type: Object,
            default: null
          }
        },
        data() {
            let securityValidate = (rule, value, callback) => {
                if (value === undefined ) {
                    callback(new Error('请选择文件密级'));
                } else {
                    callback();
                }
            };
            return {
                treeNode: null,
                treeResolve: null,
                expandKeys: [],
                tempNodeArr: [],
                isLoading:false,
                multiple: true,
                // 创建人
                currentUserCheck: false,
                currentUser: '',
                searchUserName: '',
                createUserOptions: [],
                createUserList: [],
                checkCreateUserIds: [],
                userCheckAll: false,
                userIndeterminate: false,
                // 文件类型
                conditionBoxVisible1: false,
                conditionBoxVisible2: true,
                conditionBoxVisible3: false,
                methodIdText: '',
                methodIdOptions: [],
                methodIds: [],
                checkMethodIds: [],
                checkAll: false,
                isIndeterminate: false,
                // 组织机构
                addressType: 'department',
                searchOrgName: '',
                checkOrgIds: [],
                currentUserDeptCheck: false,

                dis: false,
                headerHeight1: '88px',
                headerHeight2: '10px',
                treeHeight: (parseInt(this.$store.getters.getTopMainHeightFn)) - (this.havingWritePerm || this.havingCreatePerm ? parseInt(this.headerHeight1) : parseInt(this.headerHeight2)) + 'px',
                fileMethodList: [],
                folderMethodList: [],
                createDesignerVisible: false,
                folderDialog: {
                    dialogVisible: false,
                    folderMethod: 'default',// 文件夹类型，default默认文件夹，custom自定义文件夹（扩展的文件夹类型的建模方法）
                    folderTitle: '新建文件夹',// 新建文件夹时自定义标题
                    folderForm: {
                        name: '',
                        desc: ''
                    },
                    rules: {
                        name: [
                            {required: true, message: '必填', trigger: 'blur'},
                            {min: 1, max: 120, message: '长度在 1 到 120 个字符', trigger: 'blur'}
                        ],
                        securityLevel: [
                            { required: true, trigger: "change", validator: securityValidate ,type: "number"}
                        ],
                        desc: [
                            {min: 0, max: 2550, message: '长度在 255 个字符以内', trigger: 'blur'}
                        ]
                    }
                },

                //制度弹框
                ModelsetUpDialog: {
                    loading: false,
                    dialogVisible: false,
                    systemMethod: 'default',// 文件夹类型，default默认文件夹，custom自定义文件夹（扩展的文件夹类型的建模方法）
                    systemTitle: '模型新建',// 新建文件夹时自定义标题
                    systemForm: {
                        name: '',
                        uuid:"",
                        parentId:"",
                        repositoryPathData:"",
                        method:"",
                        systemType: '1',
                        category:"",
                        SystemTypeOptions: [
                            {
                                "label" : '制度',
                                "value" : "1"
                            },
                            {
                                "label" : '操作指导',
                                "value" : "2"
                            }
                        ],
                    },
                    rules: {
                        name: [
                            {required: true, message: '必填', trigger: 'blur'},
                            {min: 1, max: 120, message: '长度在 1 到 120 个字符', trigger: 'blur'}
                        ]
                    }
                },
                treeProps: {
                    label: 'name',
                    isLeaf: 'leaf'
                },
                createMethodLoading: false,
                systemMethodLoading:true,
                havingWritePerm: false,
                havingRemovePerm: false,
                havingVersionManagePerm: false,
                validUserPermDataCount: 0,
                isOlderVersion:true,
                havingCreatePerm:false,
                havingBatchPerm:false,
                isHighSecurity: false,
                securityList: {},
                securityVisible: false,
                securityFileList: [],
                securityOptions: [],
                securityRules: {
                    securityLevel: [{ required: true, trigger: "change", validator: securityValidate ,type: "number"}],
                },
                securityType: "",
            }
        },
        inject: ['openRepositoryList','transferTreeNode'],
        provide: function(){
            return{
                getIsHighSecurity: this.getIsHighSecurity,
                setSecurityVisible: this.setSecurityVisible,
                securityFileList: this.securityFileList,
                setSecurityType: this.setSecurityType,
                SystemTypeList:this.SystemTypeList
            }
        },
        created() {
            this.initData();
            this.resolveConditionData();
        },
        mounted() {
            bus.$on("getisDisabled",data =>{
                this.dis=data;
            });
        },
        methods: {
            clearConditionData(){
              this.checkCreateUserIds = [];
              this.currentUserCheck = false;
              this.$store.commit('setCreateUsers',this.checkCreateUserIds);
              this.checkMethodIds = [];
              this.isIndeterminate = false;
              this.userIndeterminate = false;
              this.checkAll = false;
              this.$store.commit('setMethodIds',this.checkMethodIds);
              this.checkOrgIds = [];
              this.currentUserDeptCheck = false;
              this.$refs.orgTree.setCheckedKeys(this.checkOrgIds);
              this.$store.commit('setOrgIds',this.checkOrgIds);
              // 刷新左侧文件树以及右侧最近编辑与收藏
              this.$store.getters.getPageFunction['repositoryMainList_initData']();
              // 刷新左侧树
              this.refreshNode('control');
              this.refreshNode('process');
            },
            filterNode(values, data) {
              if (!values) return true;
              let tempIds = [];
              values.forEach(value => {
                if (value.data.pathIdList.indexOf(data.id) !== -1) {
                  let node = this.$refs.orgTree.getNode(data.id);
                  if (node) {
                    this.tempNodeArr.push(node);
                  }
                }
                value.data.pathIdList.forEach(pathId => {
                  if (tempIds.indexOf(pathId) === -1) {
                    tempIds.push(pathId)
                  }
                });
              });
              return tempIds.indexOf(data.id) !== -1;
            },
            searchOrgNameFun(){
              let that = this;
              if (that.searchOrgName) {
                const data = {
                  url: 'jd',
                  data: {
                    cmd: 'com.actionsoft.apps.coe.pal_search_org_tree_node',
                    orgName: that.searchOrgName,
                  }
                }
                awsuiAxios.post(data).then(ro => {
                  // console.log('--------',ro)
                  let orgIdArr = [...ro.data];
                  if (orgIdArr.length) {
                    // 查询当前部门节所有父级部门
                    that.searchParentOrgIdFun(orgIdArr,that.searchOrgName);
                  }else {
                    that.$message({type:'warning',message:'查询的部门不存在，请检查输入的部门名称'});
                  }
                }).catch(error => {
                  console.log(error);
                })
              }else {
                that.treeNode.childNodes = [];
                that.loadNodeOrg(that.treeNode,that.treeResolve);
                that.expandKeys = [];
                if (that.tempNodeArr?.length){
                  that.tempNodeArr.forEach(node => {
                    that.$refs.orgTree.remove(node);
                  })
                  that.tempNodeArr.length = 0;
                }
              }
            },
            searchParentOrgIdFun(orgId,orgName){
              let that = this;
              const data = {
                url: 'jd',
                data: {
                  cmd: 'com.actionsoft.apps.coe.pal_search_org_tree_parent_node',
                  orgId,
                }
              }
              awsuiAxios.post(data)
                .then(ro => {
                  // console.log('父级部门',ro.data);
                  that.expandKeys = [...ro.data];
                  setTimeout(() => {
                    // that.$refs.orgTree.filter(orgName);
                    let tempNode = [];
                    orgId.forEach(tempOrgId => {
                      let node = that.$refs.orgTree.getNode(tempOrgId);
                      tempNode.push(node);
                      that.tempNodeArr.push(node);
                    })
                    that.$refs.orgTree.filter(tempNode);
                  },500);
                })
                .catch(err => {
                  console.log(err);
                });
            },
            // 当前人的部门是否选中
            handleCheckCurrentUserDeptChange(val){
              let temp = [];
              temp = [...this.checkOrgIds];
              if (val) {
                temp.push(this.currentUser.deptId);
              }else {
                let index = temp.indexOf(this.currentUser.deptId);
                if (index !== -1) {
                  temp.splice(index,1);
                }
              }
              this.$refs.orgTree.setCheckedKeys(temp)
              this.$store.commit('setOrgIds',temp);
              // 刷新左侧文件树以及右侧最近编辑与收藏
              this.$store.getters.getPageFunction['repositoryMainList_initData']();
              // 刷新左侧树
              this.refreshNode('control');
              this.refreshNode('process');
            },
            orgCheckChange(data,checked,isChildCheck){
              let node = this.$refs.orgTree.getNode(data.id)
              if (checked) {
                if (node.expanded) {
                  node.expanded = false
                  node.loaded = false
                }
                // 去重保存勾选节点信息
                if (this.checkOrgIds.indexOf(data.id) === -1) {
                  this.checkOrgIds.push(data.id)
                }
                // 如果与当前人的部门一致 当前人部门选中
                if (this.currentUser.deptId === data.id) {
                  this.currentUserDeptCheck = true;
                }
              }else {
                node.expanded = false
                node.isLeaf = false
                node.loaded = false
                if (this.checkOrgIds.indexOf(data.id) !== -1) {    // 删除取消勾选节点
                  this.checkOrgIds.splice(this.checkOrgIds.indexOf(data.id),1)
                }
                // 如果与当前人的部门一致 当前人部门取消选中
                if (this.currentUser.deptId === data.id) {
                  this.currentUserDeptCheck = false;
                }
              }
              this.$refs.orgTree.setCheckedKeys(this.checkOrgIds)
              this.$store.commit('setOrgIds',this.checkOrgIds);
              // 刷新左侧文件树以及右侧最近编辑与收藏
              this.$store.getters.getPageFunction['repositoryMainList_initData']();
              // 刷新左侧树
              this.refreshNode('control');
              this.refreshNode('process');
            },
            loadNodeOrg(node, resolve) {// `动态`加载
              const that = this;
              that.loading = true;
              const data = {
                url:'jd',
                data:{
                  cmd: 'com.actionsoft.apps.coe.pal_bpm_org_address_component_subjson',
                  addressType: 'department',
                  pid: '',
                  highSecurityFilter: '',
                  parentType: ''
                }
              };
              if (node.level === 0) {
                // 获取根目录
                data.data.pid = '';
                data.data.parentType = '';

                that.treeNode = node;
                that.treeResolve = resolve;
              } else {
                // 获取其他目录
                data.data.pid = node.data.id;
                data.data.parentType = node.data.type;
              }

              if (node.level > 0 && that.checkOrgIds.indexOf(node.data.id) !== -1 && node.checked) {
                resolve([])
                return;
              }
              // 查询数据
              awsuiAxios.post(data).then(function (ro) {
                // 设置是否可选中
                if (that.multiple) {// 多选
                  const isDept = that.addressType.indexOf('department') > -1;
                  const isUser = that.addressType.indexOf('user') > -1;
                  const isRole = that.addressType.indexOf('role') > -1;
                  const isPosition = that.addressType.indexOf('position') > -1;
                  for (let i = 0; i < ro.data.length; i++) {
                    const curr = ro.data[i];
                    if (curr.type == 'company' || curr.type == 'roleRoot' || curr.type == 'roleGroup' || curr.type == 'positionRoot' || curr.type == 'positionGroup') {
                      curr.disabled = true;
                    } else {
                      if (isDept && curr.type == 'department') curr.disabled = false;
                      if (!isDept && curr.type == 'department') curr.disabled = true;
                      if (isUser && curr.type == 'user') curr.disabled = false;
                      if (!isUser && curr.type == 'user') curr.disabled = true;
                      if (isRole && curr.type == 'role') curr.disabled = false;
                      if (!isRole && curr.type == 'role') curr.disabled = true;
                      if (isPosition && curr.type == 'position') curr.disabled = false;
                      if (!isPosition && curr.type == 'position') curr.disabled = true;
                    }
                  }
                };
                resolve(ro.data);
                that.loading = false;
                if (node.level == 0 && ro.data.length > 0) {
                  const tree = that.$refs.orgTree;
                  tree.getNode(ro.data[0].id).expand();
                  setTimeout(function(){
                    const childNode = tree.getNode(ro.data[0].id).childNodes[0];
                    if (childNode != null) {
                      childNode.expand();
                    }
                  }, 500);
                }
              }).catch(error=>{
                console.log(error);
              })
            },
            closeNodeOrg(obj, node, tree) {// 关闭时清空，下次展开重新请求动态加载
              node.childNodes = [];
              node.loaded = false;
            },
            // 当前人状态改变
            handleCheckCurrentUserChange(val){
              let temp = [];
              temp = [...this.checkCreateUserIds];
              if (val) {
                temp.push(this.currentUser.userId);
              }else {
                let index = temp.indexOf(this.currentUser.userId);
                if (index !== -1) {
                  temp.splice(index,1);
                }
              }
              this.$store.commit('setCreateUsers',temp);
              // 刷新左侧文件树以及右侧最近编辑与收藏
              this.$store.getters.getPageFunction['repositoryMainList_initData']();
              // 刷新左侧树
              this.refreshNode('control');
              this.refreshNode('process');
            },
            // 创建人全选
            handleCheckAllUserChange(val){
              let temp = []
              if (val) {
                this.createUserList.forEach(user => temp.push(user.userId));
                this.checkCreateUserIds = temp;
              }else{
                this.checkCreateUserIds = temp;
              }
              // 更新创建人信息 判断是否勾选的当前人
              if (this.currentUserCheck){
                temp.push(this.currentUser.userId)
              }
              this.$store.commit('setCreateUsers',temp);
              this.userIndeterminate = false;
              // 刷新左侧文件树以及右侧最近编辑与收藏
              this.$store.getters.getPageFunction['repositoryMainList_initData']();
              // 刷新左侧树
              this.refreshNode('control');
              this.refreshNode('process');
            },
            handleCheckedUserChange(value){
              let checkedCount = value.length;
              this.userCheckAll = checkedCount === this.createUserList.length;
              this.userIndeterminate = checkedCount > 0 && checkedCount < this.createUserList.length;
              // 保存创建人信息
              let tempArr = [];
              if (this.currentUserCheck) {
                tempArr.push(this.currentUser.userId);
                value.forEach(userId => {
                  tempArr.push(userId);
                })
              }else {
                tempArr = [...value];
              }
              this.$store.commit('setCreateUsers',tempArr);
              // 刷新左侧文件树以及右侧最近编辑与收藏
              this.$store.getters.getPageFunction['repositoryMainList_initData']();
              // 刷新左侧树
              this.refreshNode('control');
              this.refreshNode('process');
            },
            searchUserNameText() {
              this.createUserList = [];
              if (!this.searchUserName) {
                this.createUserList = this.createUserOptions;
                return;
              }
              this.createUserOptions.forEach(item => {
                if (item.userName.indexOf(this.searchUserName) !== -1){
                  this.createUserList.push(item);
                }
              });
            },
            // 文件类型全选
            handleCheckAllChange(val){
              let temp = []
              if (val) {
                this.methodIds.forEach(item => temp.push(item.methodId));
                this.checkMethodIds = temp;
              }else {
                this.checkMethodIds = temp;
              }
              this.$store.commit('setMethodIds',temp);
              this.isIndeterminate = false;
              // 刷新左侧文件树以及右侧最近编辑与收藏
              this.$store.getters.getPageFunction['repositoryMainList_initData']();
              // 刷新左侧树
              this.refreshNode('control');
              this.refreshNode('process');
            },
            handleCheckedMethodIdChange(value){
              let checkedCount = value.length;
              this.checkAll = checkedCount === this.methodIds.length;
              this.isIndeterminate = checkedCount > 0 && checkedCount < this.methodIds.length;

              this.$store.commit('setMethodIds',[...value]);
              // 刷新左侧文件树以及右侧最近编辑与收藏
              this.$store.getters.getPageFunction['repositoryMainList_initData']();
              // 刷新左侧树
              this.refreshNode('control');
              this.refreshNode('process');
            },
            // 文件类型筛选
            searchMethodIdText(){
              this.methodIds = [];
              if (!this.methodIdText) {
                this.methodIds = this.methodIdOptions;
                return;
              }
              this.methodIdOptions.forEach(item => {
                if (item.name.indexOf(this.methodIdText) !== -1){
                  this.methodIds.push(item);
                }
              });
            },
            // 初始化筛选条件数据
            resolveConditionData(){
              const that = this;
              that.methodIdOptions = that.conditionData.methodIds
              that.methodIds = that.methodIdOptions
              that.currentUser = that.conditionData.currentUser
              that.currentUser.deptNameView = that.currentUser.deptName
              if (that.currentUser.deptName.length > 8) {
                that.currentUser.deptNameView = `${that.currentUser.deptName.substring(0,4)}***${that.currentUser.deptName.substring(that.currentUser.deptName.length-4)}`
              }
              that.conditionData.createUsers.forEach(item => {
                item.deptNameView = item.deptName
                if (item.deptName.length > 8) {
                  item.deptNameView = `${item.deptName.substring(0,4)}***${item.deptName.substring(item.deptName.length-4)}`
                }
              })
              that.createUserOptions = that.conditionData.createUsers;
              that.createUserList = that.createUserOptions;

              // 根据历史筛选条件初始化多选框
              if (that.conditionData.historyCondition) {

                let checkMethodIdCount = that.conditionData.historyCondition.methodIds.length
                let checkCreateUsersCount = that.conditionData.historyCondition.createUsers.length
                let index = that.conditionData.historyCondition.createUsers.indexOf(that.currentUser.userId);
                if (index !== -1) {
                  checkCreateUsersCount = checkCreateUsersCount - 1;
                  that.currentUserCheck = true
                }else {
                  that.currentUserCheck = false
                }
                that.checkAll = checkMethodIdCount === that.methodIds.length;
                that.userCheckAll = checkCreateUsersCount === that.createUserList.length;
                that.isIndeterminate = checkMethodIdCount > 0 && checkMethodIdCount < that.methodIds.length;
                that.userIndeterminate = checkCreateUsersCount > 0 && checkCreateUsersCount < that.createUserList.length;

                that.checkCreateUserIds = [];
                that.conditionData.historyCondition.createUsers.forEach(userId => {
                  if (userId !== that.currentUser.userId) {
                    that.checkCreateUserIds.push(userId);
                  }
                })
                that.checkMethodIds = [...that.conditionData.historyCondition.methodIds];
                that.checkOrgIds = [...that.conditionData.historyCondition.orgIds];
                let orgIdIndex = that.conditionData.historyCondition.orgIds.indexOf(that.currentUser.deptId);
                if (orgIdIndex !== -1) {
                  that.currentUserDeptCheck = true;
                }else {
                  that.currentUserDeptCheck = false;
                }
                that.$nextTick(() => {
                  if (that.$refs.orgTree) {
                    that.$refs.orgTree.setCheckedKeys(that.checkOrgIds);
                  }
                })
              }
            },

            initData() {
                const that = this;
                that.loadingText = '加载中';
                that.loading = true;
                if (that.$store.getters.getTeamIdFn && that.$store.getters.getTeamIdFn != '') {
                    const data = {
                        url: 'jd',
                        data: {
                            wsId: that.$store.getters.getWsIdFn,
                            teamId: that.$store.getters.getTeamIdFn,
                            cmd: 'com.actionsoft.apps.coe.pal_user_perm_query'
                        }
                    };
                    // 查询数据
                    awsuiAxios.post(data).then(function (ro) {
                        that.validUserPermDataCount = ro.data.validUserPermDataCount;
                        if (that.validUserPermDataCount > 0) {
                            that.havingWritePerm = ro.data.havingWritePerm;
                            that.havingCreatePerm = ro.data.havingCreatePerm
                        } else {
                            that.havingWritePerm = false;
                            that.havingCreatePerm = false;
                        }
                        that.havingRemovePerm = ro.data.havingRemovePerm;
                        that.havingVersionManagePerm = ro.data.havingVersionManagePerm;
                        that.havingBatchPerm = ro.data.havingBatchPerm;
                        that.isOlderVersion = ro.data.isOlderVersion;
                        that.initTreeHeight();
                    }).catch(error => {
                        console.log(error);
                    })
                } else {
                    that.havingWritePerm = true;
                    that.havingRemovePerm = true;
                    that.havingVersionManagePerm = true;
                }
                this.initTreeHeight();
            },

            queryTreeByIdAndPath(id, versionId, path) {// 定位展开某节点
                const that = this;
                const tree = that.$refs.tree;
                // 分隔字符串
                const pathArr = path.split(',');
                let index = 1;
                for (let i = 0; i < pathArr.length; i++) {// 依次展开
                    if (i > 0) {
                        if (tree.getNode(pathArr[i - 1]) != null) {
                            setTimeout(that._expandNode(tree, pathArr[i - 1]), index * 300);
                            index++;
                        }
                    }
                }
                setTimeout(function () {
                    if (tree.getNode(versionId) != null) {
                        tree.setCurrentKey(versionId);
                    }
                    that.openRepositoryList(id);
                }, index * 300);
            },
            _expandNode(tree, id) {
                return function () {
                    tree.getNode(id).expand();
                }
            },
            openNode(obj, node, tree) {// 打开一只模型文件
                if(obj.folder==false){
                    // window.open(node.data.url, '_blank'); //在新窗口显示目标网页
                    openDesigner(this.$store.getters.getTeamIdFn, node.data.currId, this.$store.state.sessionId);
                }else{
                    this.closeCreatePopover();
                    this.openRepositoryList(node.data.currId);
                    this.transferTreeNode(obj)
                }

            },

            loadNode(node, resolve) {
                const that = this;
                const data = {
                    url: 'jd',
                    data: {}
                };
                data.data.wsId = that.$store.getters.getWsIdFn;
                data.data.teamId = that.$store.getters.getTeamIdFn;
                data.data.createUsers = JSON.stringify(that.$store.getters.getCreateUsers);
                data.data.orgIds = JSON.stringify(that.$store.getters.getOrgIds);
                data.data.methodIds = JSON.stringify(that.$store.getters.getMethodIds);
                data.data.cmd = 'com.actionsoft.apps.coe.pal_processlevel_tree_data';
                if (node.level === 0) {
                    // 获取根目录
                    data.data.pid = '';
                } else {
                    // 获取其他目录
                    data.data.pid = node.data.id;
                }
                // 查询数据
                awsuiAxios.post(data).then(function (ro) {

                    resolve(ro.data);
                    if (node.level == 0 && ro.data.length > 0) {
                        const tree = that.$refs.tree;
                        tree.getNode(ro.data[0].id).expand();
                        setTimeout(function () {
                            const childNode = tree.getNode(ro.data[0].id).childNodes[0];
                            if (childNode != null) {
                                childNode.expand();
                            }
                        }, 500);
                    }
                }).catch(error => {
                    console.log(error);
                    that.tableLoading = false;
                })
            },
            expandNode(obj, node, tree) {// 展开节点

            },
            closeNode(obj, node, tree) {// 关闭时清空，下次展开重新请求动态加载
                node.childNodes = [];
                node.loaded = false;
            },
            refreshNode(id) {// 刷新当前选中节点的子节点，即关闭当前节点后重新打开，会执行loadNode进行自动加载
                if (id == undefined) {// 未指定节点，默认刷新当前选中
                    const nodeData = this.$refs.tree.getCurrentNode();
                    if (nodeData != null) {
                        if (this.$refs.tree.store.nodesMap[nodeData.id] != undefined) {
                            this.$refs.tree.store.nodesMap[nodeData.id].expanded = false;
                        }
                        const node = this.$refs.tree.getNode(nodeData.id);
                        this.closeNode(null, node, null);
                        node.expand();
                    }
                } else {// 指定刷新某节点
                    if (this.$refs.tree.store.nodesMap[id] != undefined) {
                        this.$refs.tree.store.nodesMap[id].expanded = false;
                    }
                    const node = this.$refs.tree.getNode(id);
                    if (node != null) {
                        this.closeNode(null, node, null);
                        node.expand();
                        //刷新后，默认点击当前node
                        this.openNode(node.data,node,null);
                    }
                }
            },
            refreshParentNode(id) {// 刷新当前id节点的父节点，即重新加载id节点
                let nodeData = null;
                if (id == undefined) {
                    nodeData = this.$refs.tree.getCurrentNode();
                } else {
                    nodeData = this.$refs.tree.getNode(id);
                }
                if (nodeData != null) {
                    nodeData = this.$refs.tree.getNode(nodeData.data.pid);
                    this.refreshNode(nodeData.data.id);
                }
            },
            showCreateEvent() {
                const that = this;
                const node = that.$refs.tree.getCurrentNode();
                if (node == null) {
                    that.closeCreatePopover();
                    that.$message({
                        message: '请选择新建文件位置',
                        type: 'warning'
                    });
                    return;
                }
                that.createMethodLoading = true;
                const category = that.$refs.tree.getCurrentNode().plCategory;
                const fileId = that.$refs.tree.getCurrentNode().id;
                const methodId = that.$refs.tree.getCurrentNode().plMethodId;
                // 获取所有类型
                const data = {
                    url: 'jd',
                    data: {
                        cmd: 'com.actionsoft.apps.coe.pal_processlevel_create_method_list',
                        category: category,
                        methodId: methodId,
                        fileId: fileId
                    }
                };
                // 查询数据
                awsuiAxios.post(data).then(function (ro) {

                    if (ro.result == 'ok') {
                        const fileMethodList = ro.data.fileMethodList;// 文件类建模
                        for (let i = 0; i < fileMethodList.length; i++) {
                            let item = fileMethodList[i];
                            if (item.havingCreatePerm) {
                                item.opacity = 1.0;
                                item.filter = 'alpha(opacity=100)';
                                item.clickFlag = true;
                                item.cursor = 'pointer';
                            } else {
                                item.opacity = 0.4;
                                item.filter = 'alpha(opacity=40)';
                                item.clickFlag = false;
                                item.cursor = 'default';
                            }
                        }
                        that.fileMethodList = fileMethodList;

                        const folderMethodList = ro.data.folderMethodList;// 文件夹类型
                        for (let i = 0; i < folderMethodList.length; i++) {
                            let item = folderMethodList[i];
                            if (item.havingCreatePerm) {
                                item.opacity = 1.0;
                                item.filter = 'alpha(opacity=100)';
                                item.clickFlag = true;
                                item.cursor = 'pointer';
                            } else {
                                item.opacity = 0.4;
                                item.filter = 'alpha(opacity=40)';
                                item.clickFlag = false;
                                item.cursor = 'default';
                            }
                            // 对admin单独处理
                          if (uid != 'admin' && item.method != 'default') {// 不是admin且不是文件夹类型，一律只读
                            item.opacity = 0.4;
                            item.filter = 'alpha(opacity=40)';
                            item.clickFlag = false;
                            item.cursor = 'default';
                          }
                        }
                        that.folderMethodList = folderMethodList;
                        // 三员管理配置
                        if(ro.data.isHighSecurity != undefined){
                            that.isHighSecurity = ro.data.isHighSecurity;
                            that.securityList = ro.data.securityList;
                            //设置密级options
                            that.securityOptions = [];
                            Object.keys(that.securityList).map(key =>{
                                let option= {
                                    value: key,
                                    label: that.securityList[key]
                                }
                                that.securityOptions.push(option);
                            })
                        }
                    }
                    that.createMethodLoading = false;
                }).catch(error => {
                    console.log(error);
                })
            },
            createFolder(method, methodName) {// 创建文件夹

                this.folderDialog.folderMethod = method;
                this.folderDialog.folderTitle = '新建' + methodName;
                this.folderDialog.dialogVisible = true;
                this.closeCreatePopover();
            },

            clearFolderDlg(closeDlg) {
                this.$refs['folderForm'].resetFields();
                if (closeDlg) {
                    this.folderDialog.dialogVisible = false;
                }
            },

            clearSystemDlg(closeDlg) {
                this.isLoading = false;
                this.$refs['systemForm'].resetFields();
                if (closeDlg) {
                    this.ModelsetUpDialog.dialogVisible = false;
                }
            },


            handleCloseFolder(done) {
                this.clearFolderDlg(false);
                done();
            },

            handleCloseSystem(done) {
                this.clearSystemDlg(false);
                done();
            },

            //ModelsetUpDialog
            createModelsetUp(method) {// 创建文件夹
                this.ModelsetUpDialog.systemMethod = method;
                this.ModelsetUpDialog.systemForm.method = method;
                this.ModelsetUpDialog.systemTitle = '新建模型';
                this.ModelsetUpDialog.dialogVisible = true;
                this.closeCreatePopover();
            },

            createFolderSave(formName) {// 保存新建的文件夹
                const that = this;
                that.$refs[formName].validate((valid) => {
                    if (valid) {
                        const name = that.folderDialog.folderForm.name;
                        const desc = that.folderDialog.folderForm.desc;
                        if (desc.length > 255) {
                            that.$message({message: '[描述]不允许超过255个字符', type: 'warning'});
                            return;
                        }
                        const nodeData = that.$refs.tree.getCurrentNode();
                        const parentId = nodeData.id;
                        const wsId = that.$store.getters.getWsIdFn;
                        const teamId = that.$store.getters.getTeamIdFn;
                        const method = that.folderDialog.folderMethod;// 默认文件夹或自定义method的文件夹
                        const data = {
                            url: 'jd',
                            data: {
                                cmd: 'com.actionsoft.apps.coe.pal_processlevel_folder_create_save',
                                wsId: wsId,
                                teamId: teamId,
                                method: method,
                                parentId: parentId,
                                name: name,
                                desc: desc,
                                id: ''// 为空代表创建，不为空则更新
                            }
                        };
                        // 查询数据
                        awsuiAxios.post(data).then(function (ro) {
                            if (ro.result == 'ok') {
                                // 刷新节点，重新打开
                                that.refreshNode();
                                that.clearFolderDlg(true);
                                that.openRepositoryList(parentId);
                            }
                        }).catch(error => {
                            console.log(error);
                        })
                    } else {
                        console.log('error submit!!');
                        return false;
                    }
                });
            },

            //新建模型
            createSystemSave(formName) {// 保存新建的文件夹
                const that = this;
                that.$refs[formName].validate((valid) => {
                    if (valid) {
                        const name = that.ModelsetUpDialog.systemForm.name;
                        var judgeFn = new RegExp(/\s+/g);
                        if (judgeFn.test(name)) {
                            that.$message({message: '[名称]不允许包含空格', type: 'warning'});
                            return;
                        }
                        const checkdata = {
                            url:'jd',
                            data:{
                                cmd: 'com.actionsoft.apps.coe.pal_pl_repository_designer_checkname',
                                title: that.ModelsetUpDialog.systemForm.name,
                                method:that.ModelsetUpDialog.systemForm.method
                            }
                        };
                        // 查询数据
                        awsuiAxios.post(checkdata).then(function (ro) {
                            if (ro.data.result == 'ok') {
                                that.isLoading = true;
                                const nodeData = that.$refs.tree.getCurrentNode();
                                const parentId = nodeData.id;
                                const wsId = that.$store.getters.getWsIdFn;
                                const teamId = that.$store.getters.getTeamIdFn;
                                const data = {
                                    url: 'jd',
                                    data: {
                                        cmd: 'com.actionsoft.apps.coe.pal_processlevel_repository_create_save_Designer',
                                        wsId: wsId,
                                        teamId: teamId,
                                        category: that.ModelsetUpDialog.systemForm.category,
                                        method: that.ModelsetUpDialog.systemForm.method,
                                        parentId: parentId,
                                        container: '_blank',// 模板，暂时不做模板
                                        name:that.ModelsetUpDialog.systemForm.name
                                    }
                                };
                                // 查询数据
                                awsuiAxios.post(data).then(function (ro) {
                                    if (ro.result == 'ok') {
                                        that.ModelsetUpDialog.systemForm.uuid=ro.data.id;
                                        that.ModelsetUpDialog.systemForm.parentId=parentId;
                                        if(that.ModelsetUpDialog.systemForm.method == "control.policy" ||  that.ModelsetUpDialog.systemForm.method == "control.oaApprove"){
                                            const data = {
                                                url:'jd',
                                                data:{
                                                    cmd: 'com.actionsoft.apps.coe.pal_pl_repository_designer_CreateSystemModelBySelectType',
                                                    wsId: wsId,
                                                    title: that.ModelsetUpDialog.systemForm.name,
                                                    type: that.ModelsetUpDialog.systemForm.systemType,
                                                    method:that.ModelsetUpDialog.systemForm.method,
                                                    uuid:that.ModelsetUpDialog.systemForm.uuid,
                                                    parentId:that.ModelsetUpDialog.systemForm.parentId
                                                }
                                            };
                                            // 查询数据
                                            awsuiAxios.post(data).then(function (ro) {
                                                if (ro.result == 'ok') {
                                                    that.isLoading = false;
                                                    that.ModelsetUpDialog.dialogVisible = false;
                                                    that.openRepositoryList(that.ModelsetUpDialog.systemForm.parentId);
                                                    // 返回id
                                                    openDesigner(that.$store.getters.getTeamIdFn, that.ModelsetUpDialog.systemForm.uuid, that.$store.state.sessionId);
                                                    //清空数据
                                                    that.$refs['systemForm'].resetFields();
                                                    that.refreshNode('control');
                                                    that.refreshNode('process');
                                                } else {
                                                    that.$message.error(ro.msg);
                                                }
                                            }).catch(error=>{
                                                console.log(error);
                                            })
                                        }else{
                                            that.isLoading = false;
                                            that.refreshNode('control');
                                            that.refreshNode('process');
                                            that.ModelsetUpDialog.dialogVisible = false;
                                            that.openRepositoryList(that.ModelsetUpDialog.systemForm.parentId);
                                            // 返回id
                                            openDesigner(that.$store.getters.getTeamIdFn, that.ModelsetUpDialog.systemForm.uuid, that.$store.state.sessionId);
                                            //清空数据
                                            that.$refs['systemForm'].resetFields();

                                        }


                                    }
                                }).catch(error => {
                                    console.log(error);
                                })
                            } else {
                                that.$message({message: that.ModelsetUpDialog.systemForm.name+'名称重复,请重新输入！！！', type: 'warning'});
                                return;
                            }
                        }).catch(error=>{
                            console.log(error);
                        })


                    }else {
                        console.log('error submit!!');
                        return false;
                    }
                });


            },


            createDesigner(app, category, method) {// 新建文件
                const that = this;
                that.closeCreatePopover();
                if(this.isHighSecurity){
                    //密级标定dialog
                    let file = {
                        uuid: 1,
                        name : "未命名文件",
                        category: category,
                        method: method,
                    };
                    this.securityFileList.push(file);
                    this.securityType = "create";
                    this.securityVisible = true;
                }else {
                    const nodeData = that.$refs.tree.getCurrentNode();
                    const parentId = nodeData.id;
                    const data = {
                        url: 'jd',
                        data: {
                            cmd: 'com.actionsoft.apps.coe.getArchitecturePath',
                            parentId: parentId,

                        }
                    };
                    // 查询数据
                    awsuiAxios.post(data).then(function (ro) {

                        // 返回id
                        that.ModelsetUpDialog.systemForm.category=category;
                        that.ModelsetUpDialog.systemForm.repositoryPathData = ro.data.repositoryPathData;
                        that.ModelsetUpDialog.systemForm.parentId = parentId;
                        that.createModelsetUp(method);

                    }).catch(error => {
                        console.log(error);
                    })

                }
            },
            uploadServer(){
                this.validateFlag = true;
                //规则校验
                for(let i=0;i<this.securityFileList.length;i++){
                    let file = this.securityFileList[i];
                    this.$refs[file.uuid][0].validate(valid =>{
                        if(!valid){
                            this.validateFlag = false;
                            return false;
                        }
                    });
                }
                if(this.validateFlag){
                    if("import" === this.securityType){
                        //导入模型密级标定
                        const data = {
                            url: 'jd',
                            data: {
                                cmd: 'com.actionsoft.apps.coe.pal_pl_file_security_level_batch_update',
                                fileList: JSON.stringify(this.securityFileList),
                            }
                        };
                        // 查询数据
                        awsuiAxios.post(data).then(function (ro) {
                            if (ro.result == 'ok') {
                                // 刷新节点，重新打开
                                that.refreshNode();
                                that.openRepositoryList(parentId);
                                that.$message({
                                    message: '导入成功',
                                    type: 'success'
                                });
                            }
                        }).catch(error => {
                            console.log(error);
                        });
                    }else{
                        //开启设计器
                        const that = this;
                        const nodeData = that.$refs.tree.getCurrentNode();
                        const parentId = nodeData.id;
                        const wsId = that.$store.getters.getWsIdFn;
                        const teamId = that.$store.getters.getTeamIdFn;
                        for(let i=0;i<this.securityFileList.length;i++){
                            let file = this.securityFileList[i];
                            // 新建文件密级标定
                            const data = {
                                url: 'jd',
                                data: {
                                    cmd: 'com.actionsoft.apps.coe.pal_processlevel_repository_create_save',
                                    wsId: wsId,
                                    teamId: teamId,
                                    category: file.category,
                                    method: file.method,
                                    parentId: parentId,
                                    container: '_blank',// 模板，暂时不做模板
                                    securityLevel: file.securityLevel,
                                }
                            };
                            // 查询数据
                            awsuiAxios.post(data).then(function (ro) {
                                if (ro.result == 'ok') {
                                    // 刷新节点，重新打开
                                    that.refreshNode();
                                    that.openRepositoryList(parentId);
                                    // 返回id
                                    const id = ro.data.id;
                                    openDesigner(that.$store.getters.getTeamIdFn, id, that.$store.state.sessionId);
                                }
                            }).catch(error => {
                                console.log(error);
                            })
                        }
                    }
                    this.securityVisible = false;
                }
            },
            importDesigners() {
                this.closeCreatePopover();
                // 导出窗口
                this.$refs.repositoryImport.openImportRepositoryDlg(this, this.$refs.tree.getCurrentNode().plCategory, this.$refs.tree.getCurrentNode().id);
            },
            closeCreatePopover() {
                this.createDesignerVisible = false;
            },
            reload() {

            },
            initTreeHeight() {
                this.treeHeight = (parseInt(this.$store.getters.getTopMainHeightFn)) - (this.havingWritePerm || this.havingCreatePerm ? parseInt(this.headerHeight1) : parseInt(this.headerHeight2)) + 'px';
            },
            getIsHighSecurity(){
                return this.isHighSecurity;
            },
            setSecurityVisible(visible){
                this.securityVisible= visible;
            },
            setSecurityType(val){
                this.securityType = val;
            }
        },
        computed: {
            listenTopMainHeight() {
                return this.$store.getters.getTopMainHeightFn;
            }
        },
        watch: {
            listenTopMainHeight: function (newd, old) {
                this.initTreeHeight();
            },
            //密级选择dialogVisible 变为false，清空securityFileList
            securityVisible(newval, oldval){
                if(!newval){
                    this.securityFileList.splice(0,this.securityFileList.length);
                }
            },
            searchOrgName(newval, oldval){
              if (!newval) {
                this.treeNode.childNodes = [];
                this.loadNodeOrg(this.treeNode,this.treeResolve);
                this.expandKeys = [];
                if (this.tempNodeArr?.length){
                  this.tempNodeArr.forEach(node => {
                    this.$refs.orgTree.remove(node);
                  });
                  this.tempNodeArr.length = 0;
                }
              }
            }
        }
    }
</script>

<style scoped>
    #repositoryMain >>> .el-main {
        display: block;
        -webkit-box-flex: 1;
        -ms-flex: 1;
        flex: 1;
        -ms-flex-preferred-size: auto;
        flex-basis: auto;
        overflow: auto;
        margin: 0 10px 10px;
    }
    #repositoryMain >>> .el-header {
        padding: 0 10px;
    }
    #repositoryMain >>> .el-tree .el-tree-node > .el-tree-node__children {
        overflow: visible;
    }

    #repositoryMain >>> .el-tree--highlight-current .el-tree-node.is-current > .el-tree-node__content {
        background-color: #F5F7FA;
        color: #F79500;
    }

    #repositoryMain >>> .el-tree--highlight-current .el-tree-node.is-current > .el-tree-node__content .awsui-iconfont {
        color: #F79500 !important;
    }

    #repositoryMain >>> .el-dialog__body {
        padding: 10px 20px;
        color: #606266;
        font-size: 14px;
        word-break: break-all;
    }

    #repositoryMain >>> .el-form-item__label {
        line-height: 0;
    }

    #repositoryMain >>> .el-tree {
        min-width: 100%;
        display: inline-block !important;
    }

    .icon-div-repository {
        border-radius: 10%;
        display: inline-block;
        width: 32px;
        height: 32px;
        text-align: center;
        line-height: 32px;
        vertical-align: middle;
    }

    .icon-dynamic-repository {
        color: white;
        font-size: 18px;
    }


    .new-repository-box {
      max-height: 500px; /* 指定的最大高度 */
      overflow-y: auto; /* 纵向滚动条 */
      scrollbar-width: none; /* Firefox */
      -ms-overflow-style: none; /* IE 10+ */
    }

    .new-repository-box::-webkit-scrollbar { /* Chrome, Safari, Opera */
      width: 0;
      height: 0;
    }

    .new-repository-item:hover .item-name {
        color: #4E7FF9;
    }

    .new-repository-item:hover {
        background-color: #F5F7FA;
    }

    .new-repository-item {
        width: 60px;
        height: 70px;
        line-height: 30px;
        text-align: center;
        display: inline-block;
        padding: 5px;
        vertical-align: middle;
    }

    .icon-fixed-repository {
        font-size: 23px;
        height: 20px;
        width: 20px;
    }

    .icon-text {
        font-size: 12px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .fixed-icon-text {
        font-size: 12px;
        line-height: 25px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .main-tree::-webkit-scrollbar {
        display: none;
    }
    .condition-box >>> .el-divider--vertical {
        height: 18px;
    }
    .methodId-box >>> .el-divider--horizontal {
        margin: 8px 0;
    }
    .org-box >>> .el-divider--horizontal {
        margin: 8px 0;
    }
    .create-user-box >>> .el-divider--horizontal {
        margin: 8px 0;
    }
    /deep/ .el-checkbox-group {
        display: flex;
        flex-direction: column;
    }
</style>
