<template>
        <div :style="'padding:20px 30px;background:#f7f7f7;min-height:'+tableHeight+'px;'">
        <div style="margin: 0 auto;width:1000px;">
            <el-row :gutter="20">
            <el-col :span="17" >
                <div class="box info">
                    <label>{{ $t('basicinformation') }}<el-link v-if="(user.id == project.creatorId || user.id == project.inchargerId) || permissions.projectManagement" @click="showEdit" style="float:right;"><i class="el-icon-edit"  ></i></el-link></label>
                    <el-row :gutter="10" >
                        <el-col :span="5" ><span class="gray_label">{{ $t('headerTop.projectName') }}:</span></el-col><el-col :span="7" ><span >{{project.projectName}}</span></el-col>
                        <el-col :span="5" ><span class="gray_label">{{ $t('projectclassification') }}:</span></el-col><el-col :span="7" ><span >{{project.categoryName}}</span></el-col>
                    </el-row>
                    <el-row :gutter="10" >
                        <el-col :span="5" ><span class="gray_label">{{ $t('other.projectDescription') }}:</span></el-col><el-col :span="7" ></el-col>
                        <el-col :span="18" ><span>{{project.projectDesc}}</span></el-col>
                    </el-row>
                    <el-row :gutter="10" v-if="user.timeType.projectWithDept">
                        <el-col :span="5" ><span class="gray_label">{{ $t('subordinatedepartments') }}:</span></el-col><el-col :span="7" ></el-col>
                        <el-col :span="18" >
                            <span v-if="user.userNameNeedTranslate != 1">{{project.departmentName}}</span>
                            <span v-if="user.userNameNeedTranslate == 1"><ww-open-data type='departmentName' :openid='project.departmentName'></ww-open-data></span>
                        </el-col>
                    </el-row>
                    <el-row :gutter="10">
                        <el-col :span="5" ><span class="gray_label">{{ $t('state.states') }}:</span></el-col><el-col :span="7" ><span >{{project.status==null?'-':statusTxt[project.status]}}</span></el-col>
                        <el-col :span="5" v-if="user.company.packageEngineering==0"><span class="gray_label">{{ $t('completeness') }}: </span></el-col><el-col :span="7" >
                        <span v-if="user.company.packageEngineering==0">
                            <el-progress  :percentage="project.progress == null?0:project.progress"></el-progress>
                        </span></el-col>
                    </el-row>
                    <el-row :gutter="10">
                        <el-col :span="5" ><span class="gray_label">{{ $t('Itemno') }}: </span></el-col><el-col :span="7" ><span >{{project.projectCode}}&nbsp;</span></el-col>
                        <el-col :span="5" v-if="permissions.projectContract"><span class="gray_label">{{ $t('contractamount') }}：</span></el-col>
                        <el-col :span="7" >
                        <span style="float:left;" v-if="permissions.projectContract">{{project.contractAmount == null?'-':project.contractAmount | numberToCurrency}} 元</span>
                        <el-link v-if="user.id == project.creatorId || user.id == project.inchargerId" @click="contractRecord" style="float:left;"><i class="iconfont firerock-iconrecord"></i></el-link>
                        <el-link v-if="user.id == project.creatorId || user.id == project.inchargerId || permissions.projectManagement" @click="contractChange" style="float:right;"><i class="el-icon-edit"  ></i></el-link>
                        </el-col>
                        
                    </el-row>
                    <el-row :gutter="10">
                        <el-col :span="5" ><span class="gray_label">{{ $t('jihuajibie') }}: </span></el-col><el-col :span="7" ><span >{{levelTextShow(project.level)}}</span></el-col>
                        <el-col :span="5" ><span class="gray_label">{{ $t('creationdate') }}:</span></el-col><el-col :span="7" ><span>{{project.createDate}}</span></el-col>
                    </el-row>
                    <el-row :gutter="10">
                        <el-col :span="5" ><span class="gray_label">{{ $t('ommencementDate') }}：</span></el-col>
                        <el-col :span="7" ><span >{{project.planStartDate==null?'-':project.planStartDate}}</span></el-col>
                        <el-col :span="5" ><span class="gray_label">{{ $t('ji-hua-jie-shu-ri-qi') }}：</span></el-col>
                        <el-col :span="7" ><span>{{project.planEndDate == null?'-':project.planEndDate}}</span></el-col>
                    </el-row>
                    <el-row :gutter="10">
                        <el-col :span="5" ><span class="gray_label">{{ $t('shijiawancheng') }}：</span></el-col>
                        <el-col :span="7" ><span>{{project.finishDate==null?'-':project.finishDate}}</span></el-col>
                        <template v-if="user.timeType.outputValueStatus == 1">
                        <el-col :span="5" ><span class="gray_label">{{ $t('projectoutput') }}：</span></el-col>
                        <el-col :span="7" ><span>{{project.outputValue == null?'-':project.outputValue | numberToCurrency}} {{ $t('yuan') }}</span></el-col>
                        </template>
                    </el-row>
                    <el-row :gutter="10" v-if="yonghuUser.customDegreeActive == 1">
                        <el-col :span="5" ><span class="gray_label">{{yonghuUser.customDegreeName}}:</span></el-col>
                        <el-col :span="18" ><span>{{project.associateDegreeNames}}</span></el-col>
                    </el-row>
                    

                    <!-- this.project  -->
                    <div v-if="user.companyId == '936'">
                        <el-row :gutter="10" >
                            <el-col :span="5" ><span class="gray_label">{{ $t('contractno') }}:</span></el-col><el-col :span="7" ></el-col>
                            <el-col :span="18" ><span>{{project.projectSeparate.contractCode}}</span></el-col>
                        </el-row>
                        <el-row :gutter="10">
                            <el-col :span="5" ><span class="gray_label">{{ $t('warrantystartime') }}:</span></el-col><el-col :span="7" >
                                <span >{{project.projectSeparate.warrantyStartDate==null?'-':project.projectSeparate.warrantyStartDate}}</span></el-col>
                            <el-col :span="5" ><span class="gray_label">{{ $t('warrantyexpirationtime') }}:</span></el-col><el-col :span="7" ><span>
                                {{project.projectSeparate.warrantyEndDate == null?'-':project.projectSeparate.warrantyEndDate}}</span></el-col>
                        </el-row>
                        <el-row :gutter="10" >
                            <el-col :span="5" ><span class="gray_label">{{ $t('IndependentProject') }}:</span></el-col><el-col :span="7" ></el-col>
                            <el-col :span="18" ><span>{{project.projectSeparate.projectCategorySub}}</span></el-col>
                        </el-row>
                        <el-row :gutter="10" >
                            <el-col :span="5" ><span class="gray_label">{{ $t('region') }}:</span></el-col><el-col :span="7" ></el-col>
                            <el-col :span="18" ><span>{{project.projectSeparate.region}}</span></el-col>
                        </el-row>
                        <el-row :gutter="10" >
                            <el-col :span="5" ><span class="gray_label">{{ $t('subordinateBU') }}:</span></el-col><el-col :span="7" ></el-col>
                            <el-col :span="18" ><span>{{project.projectSeparate.bu}}</span></el-col>
                        </el-row>
                    </div>
                    <div v-if="user.companyId == '428'">
                        <el-row :gutter="10" >
                            <el-col :span="5" ><span class="gray_label">{{ $t('projectgroup') }}:</span></el-col><el-col :span="7" ></el-col>
                            <el-col :span="18" ><div v-if="project.projectSeparate"><span>{{project.projectSeparate.projectCategorySub}}</span></div></el-col>
                        </el-row>
                    </div>
                </div>
                <div class="box" style="margin-top:10px;">
                    <div><label>{{ $t('xianguan') }}</label>
                    <el-link v-if="user.id == project.creatorId || user.id == project.inchargerId || permissions.projectManagement" @click="showEditPar" style="float:right;"><i class="el-icon-edit"  ></i></el-link>
                    </div>
                    <div style="margin-top:10px;color:#999;">{{ $t('projectmanager') }}</div>
                    <div><el-link style="margin:10px" @click="showUser(project.inchargerId)">
                        <span v-if="user.userNameNeedTranslate != 1">{{project.inchargerName}}</span>
                        <span v-else><ww-open-data type='userName' :openid='project.inchargerName'></ww-open-data></span>
                    </el-link></div>
                    <div style="margin-top:10px;color:#999;">{{ $t('newspaperauditor') }}</div>
                    <div>
                        <span v-if="project.auditorList.length == 0" style="margin:10px;">-</span>
                        <el-link v-for="item in project.auditorList" :key="item.id" style="margin:10px;" @click="showUser(item.auditorId)">
                            <span v-if="user.userNameNeedTranslate != 1">
                                {{item.auditorName}}
                            </span>
                            <span v-if="user.userNameNeedTranslate == 1">
                                <ww-open-data type='userName' :openid='item.auditorName'></ww-open-data>
                            </span>
                        </el-link>
                    </div>
                   
                    <div v-show="project.isPublic == 0" style="color:#999;">{{ $t('participantin') }}</div>
                    <div v-show="project.isPublic == 0" >
                        <el-link v-for="item in project.participationList" :key="item.id" style="margin:10px;" @click="showUser(item.id)">
                            <span v-if="user.userNameNeedTranslate != 1">{{item.name}}</span>
                            <span v-else><ww-open-data type='userName' :openid='item.name'></ww-open-data></span>
                        </el-link>
                        <el-button class="el-icon-plus" @click="addMembVisible=true" size="mini"></el-button>
                    </div>
                </div>

                <div class="box" style="margin-top:10px;" v-if="user.companyId == '936'">
                    <div><label>{{ $t('keynodes') }}</label>
                        <el-link v-if="user.id == project.creatorId || user.id == project.inchargerId || permissions.projectManagement" @click="showEditParKeyNode" style="float:right;"><i class="el-icon-edit"  ></i></el-link>
                    </div>
                    <el-table :data="keyNodesList" style="width: 100%">
                        <el-table-column prop="nodesName" :label="$t('nameofthenode')" width="300"></el-table-column>
                        <el-table-column prop="planCompleteDate" :label="$t('plannedcompletiontime')" width="150"></el-table-column>
                        <el-table-column prop="actualCompleteDate" :label="$t('actualcompletiontime')" width="150"></el-table-column>
                        <el-table-column prop="states" :label="$t('state.states')" width="80">
                            <template slot-scope="scope">
                                <div>
                                    {{scope.row.states == '0' ? $t('zheng-chang') : (scope.row.states == '1' ? $t('yu-qi') : $t('wan-cheng'))}}
                                </div>
                            </template>
                        </el-table-column>
                    </el-table>
                </div>
                <!-- <div class="box info" style="margin-top:10px;" v-if="permissions.projectBaseline">
                    <div><label>成本基线<el-link v-if="permissions.projectCorrection" @click="showEditBase" style="float:right;"><i class="el-icon-edit"  ></i></el-link></label>
                    <el-row :gutter="10">
                        <div v-for="item in projectBaseCostData" :key="item.id">
                        <el-col :span="5" ><span class="gray_label">{{item.baseName}}:</span></el-col>
                        <el-col :span="7" align="right" ><span style="padding-right:20px;">
                            ￥{{item.baseAmount==null?'-':item.baseAmount | numberToCurrency}}</span></el-col>
                        </div>
                    </el-row>
                    </div>
                </div> -->
                <!--项目相关工程专业 -->
                <div class="box info" style="margin-top:10px;" v-if="user.company.packageEngineering == 1">
                    <div><label>{{ $t('xiangguangongcheng') }}<el-link v-if="user.id == project.creatorId || user.id == project.inchargerId || permissions.projectManagement" @click="showEditProfession" style="float:right;"><i class="el-icon-edit"  ></i></el-link></label>
                    <el-row :gutter="10" v-for="item in projectProfessionListOnPage" :key="item.id">
                        <el-col :span="5" ><span >{{item.professionName}}</span></el-col>
                        <el-col :span="2" ><span >{{item.percentage}}%</span></el-col>
                        <el-col :span="14" ><span style="margin: 0 5px;font-size:13px;" v-for="memb in item.membList" :key="memb">{{memb.membName}}({{memb.percentage}}%)</span></el-col>
                        <el-col :span="3" ><span >{{item.inchargerName}}</span></el-col>
                    </el-row>
                    </div>
                </div>

                <!--项目相关领导,弃用 -->
                <!-- <div class="box info" style="margin-top:10px;" >
                    <div><label>相关领导<el-link v-if="user.id == project.creatorId || user.id == project.inchargerId || permissions.projectManagement" @click="showChooseLeaderTree" style="float:right;"><i class="el-icon-edit"  ></i></el-link></label>
                    
                    </div>
                    <el-row :gutter="10">
                        <el-col :span="24" ><span v-for="item in chosenLeaders" :key="item.userId" style="margin-right:10px;">
                            <el-link @click="showUser(item.userId)">{{item.userName}}</el-link>
                        </span>
                        </el-col>
                    </el-row>
                    
                </div> -->

                <div class="box" style="margin-top:10px;">
                    <label>{{ $t('projecttongji') }}</label>
                    <div>
                        <el-row :gutter="10">
                        <el-col :span="4" style="text-align:center;">
                            <p style="color:#666;font-size:12px;">{{ $t('state.completed') }}</p>
                            <p style="font-size:20px;font-weight:bold;color:green;">{{taskSum.finishCount}}</p>
                        </el-col>
                        <el-col :span="4" style="text-align:center;">
                            <p style="color:#666;font-size:12px;">{{ $t('wei-wan-cheng') }}</p>
                            <p style="font-size:20px;color:blue;font-weight:bold;">{{taskSum.unfinishCount}}</p>
                        </el-col>
                        <el-col :span="4" style="text-align:center;">
                            <p style="color:#666;font-size:12px;">{{ $t('yi-yu-qi') }}</p>
                            <p style="font-size:20px;color:red;font-weight:bold;">{{taskSum.timeupCount}}</p>
                        </el-col>
                        <el-col :span="4" style="text-align:center;">
                            <p style="color:#666;font-size:12px;">{{ $t('dai-ren-ling') }}</p>
                            <p style="font-size:20px;color:#orange;font-weight:bold;">{{taskSum.unassignCount}}</p>
                        </el-col>
                        <el-col :span="4" style="text-align:center;">
                            <p style="color:#666;font-size:12px;">{{ $t('duetoday') }}</p>
                            <p style="font-size:20px;font-weight:bold;color:pink;">{{taskSum.todayTimeupCount}}</p>
                        </el-col>
                        <el-col :span="4" style="text-align:center;">
                            <p style="color:#666;font-size:12px;">{{ $t('limittocomplete') }}</p>
                            <p style="font-size:20px;font-weight:bold;color:gray;">{{taskSum.timeupFinishCount}}</p>
                        </el-col>
                        </el-row>
                    </div>
                </div>
            </el-col>
            <el-col :span="7">
                <!--进度显示 -->
                <div v-if="user.company.packageEngineering == 1" style="margin-bottom:10px;background:#fff;border: 1px solid #eeeeee;border-radius:5px;min-height:305px;padding-left:5px;padding-right:5px;">
                    <p><i class="el-icon-odometer"></i><span style="margin-left:5px;">{{ $t('completion') }}</span></p>
                    <el-divider></el-divider>
                    <el-row><el-col :span="12"><span>{{ $t('projectprogress') }}</span></el-col>
                        <el-col :span="12"><el-progress :percentage="progressData.totalProjectProgress" ></el-progress></el-col></el-row>
                    <p style="font-size:12px;color:#666;">{{ $t('progressofeachmajor') }}</p>
                    <el-table :show-header="false" :data="progressData.professionList" row-key="id" size="small"  :tree-props="{children: 'membList', hasChildren: 'hasChildren'}">
                        <el-table-column
                        prop="professionName">
                        </el-table-column>
                        <el-table-column
                        prop="progress"
                        width="100">
                        <template slot-scope="scope">
                            <el-progress :percentage="scope.row.progress" ></el-progress>
                        </template>
                        </el-table-column>
                    </el-table>
                </div>
                
                <div style="background:#fff;border: 1px solid #eeeeee;border-radius:5px;min-height:547px;padding-left:5px;padding-right:5px;">
                    <div>
                    <p><i class="el-icon-trophy"></i><span style="margin-left:5px;">{{ $t('other.milestone') }}</span></p>
                    </div>
                    <el-timeline :reverse="reverse" style="padding-left: 3px;">
                        <el-timeline-item
                        v-for="(task, index) in mileStoneList"
                        :key="index"
                        :color="task.taskStatus==0?'#ddd':'#830BE2'"
                        size="large"
                        :timestamp="task.taskTex">
                        {{task.name}}
                        </el-timeline-item>
                    </el-timeline>
                </div>
            </el-col>
            </el-row>
        </div>
        <!--用户详细信息弹出框-->
        <el-dialog :title="$t('Checkthedetails')" v-if="userDetailVisible" :visible.sync="userDetailVisible" :close-on-click-modal="false" customClass="customWidth" width="500px">
            <div class="line"><span>{{ $t('lable.name') }}</span>
                <span v-if="user.userNameNeedTranslate != 1">{{userDetail.name}}</span>
                <span v-if="user.userNameNeedTranslate == 1"><ww-open-data type='userName' :openid='userDetail.name'></ww-open-data></span>
            </div>
            <div class="line"><span>{{ $t('Worknumber') }}</span><span>{{userDetail.jobNumber}}</span></div>
            <div class="line"><span>{{ $t('lable.phone') }}</span><span>{{userDetail.phone}}</span></div>
            <div class="line"><span>{{ $t('jiao-se') }}</span><span>{{userDetail.roleName}}</span></div>
            <div class="line"><span>{{ $t('lable.department') }}</span>
                <span v-if="user.userNameNeedTranslate != 1">{{userDetail.departmentName}}</span>
                <span v-if="user.userNameNeedTranslate == 1"><ww-open-data type='departmentName' :openid='userDetail.departmentName'></ww-open-data></span>
            </div>
            <div slot="footer" class="dialog-footer">
                <el-button type="primary" @click="userDetailVisible = false" >{{ $t('btn.determine') }}</el-button>
            </div>
        </el-dialog>

        <!-- 修改合同金额 -->
        <el-dialog :title="$t('xiugaihetongjie')" v-if="contractDialog" :visible.sync="contractDialog" :close-on-click-modal="false" customClass="customWidth" width="600px">
            <el-form ref="contractForm" :model="contractData" :rules="contractRules" label-width="120px">
                <el-form-item :label="$t('xiugayuanhetong')"><span>{{contractData.oldContractAmount == null?'-':contractData.oldContractAmount | numberToCurrency}}{{ $t('danwei') }}</span></el-form-item>
                <el-form-item :label="$t('xiu-gai-jin-e')" prop="contractAmount">
                    <el-select v-model="contractData.addordelete" style="width:20%">
                        <el-option :label="$t('addJia')" :value="1"></el-option>
                        <el-option :label="$t('removeSao')" :value="0"></el-option>
                    </el-select>
                    <el-input style="width:79%" v-model="contractData.contractAmount" id="contractChange" placeholder="" clearable @keyup.native="restrictNumber('contractChange')"></el-input>
                </el-form-item>
                <el-form-item :label="$t('modifythereason')">
                    <el-input type="textarea" :rows="2" v-model="contractData.contractAmountDesc" maxlength="200" show-word-limit :placeholder="$t('peaseenterthe')" clearable></el-input>
                </el-form-item>
            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button @click.native="contractDialog = false">{{ $t('btn.cancel') }}</el-button>
                <el-button type="primary" @click="contractChangeSure" :loading="addLoading">{{ $t('btn.submit') }}</el-button>
            </div>
        </el-dialog>

        <!-- 合同金额修改记录 -->
        <el-dialog :title="$t('hetongjinge')" v-if="contractRecordDialog" :visible.sync="contractRecordDialog" :close-on-click-modal="false" customClass="customWidth" width="1000px">
            <el-table :data="contractRecordData" height="500px" :loading="contractRecordLoading" :default-sort="{prop: 'date', order: 'descending'}">
                <el-table-column :label="$t('other.operator')" prop="name" min-width="100">
                    <template slot-scope="scope">
                        <span v-if="user.userNameNeedTranslate == 1"><ww-open-data type='userName' :openid='filterUserContract(scope.row.editUserId)'></ww-open-data></span>
                        <span v-else>{{filterUserContract(scope.row.editUserId)}}</span>
                    </template>
                </el-table-column>
                <el-table-column :label="$t('xiu-gai-shi-jian')" prop="date" min-width="120">
                    <template slot-scope="scope">
                        <!-- <span>{{scope.row.updateDate[0] + '-' + scope.row.updateDate[1] + '-' + scope.row.updateDate[2] + '\u3000' + scope.row.updateDate[3] + ':' + scope.row.updateDate[4] + ':' + scope.row.updateDate[5]}}</span> -->
                        <span>{{tempDateContract(scope.row.updateDate)}}</span>
                    </template>
                </el-table-column>
                <el-table-column :label="$t('yuan-jin-e')" prop="oldContractAmount" min-width="120">
                    <template slot-scope="scope">
                        <span>{{scope.row.oldContractAmount.toFixed(2)}}  {{ $t('yuan') }}</span>
                    </template>
                </el-table-column>
                <el-table-column :label="$t('nderungsverlauf')" prop="record" min-width="120">
                    <template slot-scope="scope">
                        <span>{{scope.row.oldContractAmount - scope.row.newContractAmount > 0 ? $t('addJia') : $t('addJia')}}</span>
                        <span>{{scope.row.oldContractAmount - scope.row.newContractAmount > 0 ? (scope.row.oldContractAmount - scope.row.newContractAmount).toFixed(2) : (scope.row.newContractAmount - scope.row.oldContractAmount).toFixed(2)}} {{ $t('yuan') }}</span>
                    </template>
                </el-table-column>
                <el-table-column :label="$t('modifythereason')" prop="reason" min-width="200"></el-table-column>
            </el-table>
        </el-dialog>

        
        <!--编辑基本信息界面-->
        <el-dialog :title="$t('jiebnxx')" v-if="addFormVisible" :visible.sync="addFormVisible" :close-on-click-modal="false" customClass="customWidth" width="960px">
            <el-form ref="basicInfoForm" :model="addForm" :rules="rules" label-width="120px">
                <el-form-item :label="$t('Itemno')" >
                    <el-input v-model="addForm.code"  :placeholder="$t('peaseenterthe')" clearable></el-input>
                </el-form-item>
                <el-form-item :label="$t('headerTop.projectName')" prop="name">
                    <el-input v-model="addForm.name"  :placeholder="$t('peaseenterthe')" clearable></el-input>
                </el-form-item>
                <el-form-item :label="$t('other.projectDescription')" prop="projectDesc">
                    <el-input type="textarea" :rows="2" v-model="addForm.projectDesc" maxlength="4000" show-word-limit  :placeholder="$t('peaseenterthe')" clearable></el-input>
                </el-form-item>

                <el-form-item :label="$t('subordinatedepartments')" v-if="user.timeType.projectWithDept">
                    <el-cascader v-model="addForm.deptId" :options="departmentList" :placeholder="$t('defaultText.pleaseChoose')"
                        :props="{ checkStrictly: true, expandTrigger: 'hover' }" clearable filterable @change="cascaderChange"
                    ></el-cascader>
                </el-form-item>

                <el-form-item :label="$t('ji-bie')" >
                    <el-select v-model="addForm.level"  placeholder="$t('defaultText.pleaseChoose')" style="width:32%;" v-if="user.timeType.projectLevelState == 1">
                        <el-option v-for="item in levelList" :key="item.id" :label="item.projectLevelName" :value="item.id"></el-option>
                    </el-select>
                    <el-select v-model="addForm.level"  placeholder="$t('defaultText.pleaseChoose')" style="width:32%;" v-else>
                        <el-option v-for="item in importanceList" :key="item.id" :label="item.label" :value="item.id"></el-option>
                    </el-select>
                    <span style="margin-left:50px;margin-right:10px;">{{ $t('contractamount') }}</span>
                    <el-input v-model="addForm.contractAmount" id="contractAmount" :disabled="true" style="width:32%;"
                    placeholder="" clearable @keyup.native="restrictNumber('contractAmount')"></el-input><span style="margin-left:10px;">{{ $t('yuan') }}</span>
                </el-form-item>
                <el-form-item :label="$t('time.startDate')" prop="planStartDate">
                    <el-date-picker v-model="addForm.planStartDate" 
                     :editable="false" 
                     format="yyyy-MM-dd" 
                     value-format="yyyy-MM-dd"
                     :clearable="false" type="date" 
                     style="width:32%"
                     :placeholder="$t('optiondate')"></el-date-picker>
                    <template v-if="user.timeType.outputValueStatus == 1">
                    <span style="margin-left:50px;margin-right:10px;">{{ $t('projectoutput') }}</span>
                    <el-input v-model="addForm.outputValue" id="outputValue" style="width:32%;"
                    placeholder="" clearable @keyup.native="restrictNumber('outputValue')"></el-input><span style="margin-left:10px;">{{ $t('yuan') }}</span>
                    </template>
                </el-form-item>
                <el-form-item :label="$t('expirationdate')" prop="planEndDate">
                    <el-date-picker v-model="addForm.planEndDate" 
                     :editable="false" 
                     format="yyyy-MM-dd" 
                     value-format="yyyy-MM-dd"
                     :clearable="false" type="date" 
                     style="width:32%"
                     :placeholder="$t('optiondate')"></el-date-picker>
                </el-form-item>

                <!-- 研究中心 -->
                <el-form-item :label="yonghuUser.customDegreeName" v-if="user.timeType.customDegreeActive != 0">
                    <el-select v-model="auseList" multiple :placeholder="$t('defaultText.pleaseChoose')" filterable="true" style="width: 100%">
                        <span v-for="(item, index) in ause" :key="index">
                        <el-option :label="item.name" :value="item.id"></el-option>
                        </span> 
                    </el-select>
                </el-form-item>

                <div v-if="user.companyId == '936'">
                    <el-form-item :label="$t('contractno')" >
                        <el-input v-model="addForm.projectSeparate.contractCode" :placeholder="$t('peaseenterthe')" clearable></el-input>
                    </el-form-item>
                    <el-form-item :label="$t('warrantystartime')">
                        <el-date-picker v-model="addForm.projectSeparate.warrantyStartDate" 
                        :editable="false" style="width:32%;" 
                        format="yyyy-MM-dd" 
                        value-format="yyyy-MM-dd"
                        :clearable="false" type="date" 
                        :placeholder="$t('optiondate')"></el-date-picker>

                        <span style="margin-left:63px;margin-right:10px;" >{{ $t('warrantyexpirationtime') }}</span>
                        <el-date-picker v-model="addForm.projectSeparate.warrantyEndDate" style="width:33%;"
                        :editable="false" 
                        format="yyyy-MM-dd" 
                        value-format="yyyy-MM-dd"
                        :clearable="false" type="date" 
                        :placeholder="$t('optiondate')"></el-date-picker>
                    </el-form-item>
                    <el-form-item :label="$t('IndependentProject')" >
                        <el-input v-model="addForm.projectSeparate.projectCategorySub" :placeholder="$t('peaseenterthe')" clearable></el-input>
                    </el-form-item>
                    <el-form-item :label="$t('region')" >
                        <el-input v-model="addForm.projectSeparate.region" :placeholder="$t('peaseenterthe')" clearable></el-input>
                    </el-form-item>
                    <el-form-item :label="$t('subordinateBU')" >
                        <el-input v-model="addForm.projectSeparate.bu" :placeholder="$t('subordinateBU')" clearable></el-input>
                    </el-form-item>
                </div>

                <div v-if="user.companyId == '428'">
                    <el-form-item :label="$t('projectgroup')" >
                        <el-input v-model="addForm.projectSeparate.projectCategorySub" :placeholder="$t('peaseenterthe')" maxlength="50" show-word-limit clearable></el-input>
                    </el-form-item>
                </div>
               
            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button @click.native="addFormVisible = false">{{ $t('btn.cancel') }}</el-button>
                <el-button type="primary" @click="submitInsert" :loading="addLoading">{{ $t('btn.submit') }}</el-button>
            </div>
        </el-dialog>

        <el-dialog :title="$t('jiaoyan')" v-if="addBaseFormVisible" :visible.sync="addBaseFormVisible" :close-on-click-modal="false" customClass="customWidth" width="600px">
            <el-form ref="basicInfoForm" label-width="120px">
                <el-form-item v-for="(item, index) in modBaseCostData" :label="item.baseName" :key="item.id">
                    <el-input :id="'baseCost'+index" v-model="item.baseAmount"  :placeholder="$t('peaseenterthe')" clearable  @keyup.native="restrictNumber('baseCost'+index)"></el-input>
                </el-form-item>
                <el-form-item :label="$t('bei-zhu')" >
                    <el-input v-model="remark"  :placeholder="$t('reasoforcorrection')" ></el-input>
                </el-form-item>
            </el-form>
            
            <div slot="footer" class="dialog-footer">
                <el-button @click.native="addBaseFormVisible = false">{{ $t('btn.cancel') }}</el-button>
                <el-button type="primary" @click="adjustBase" :loading="addLoading">{{ $t('btn.submit') }}</el-button>
            </div>
        </el-dialog>

        <!--编辑参与人界面-->
        <el-dialog :title="$t('editParticipants')" v-if="pVisible" :visible.sync="pVisible" :close-on-click-modal="false" customClass="customWidth" width="600px">
            <el-form ref="participForm" :model="addForm" :rules="rules" label-width="120px">
                <el-form-item :label="$t('Allparticipants')">
                    <el-select v-model="addForm.userId" multiple filterable :placeholder="$t('defaultText.pleaseChoose')" style="width:100%;" @change="changeParticipator">
                        <el-option v-for="item in users" :key="item.id" :label="item.name" :value="item.id"></el-option>
                    </el-select>
                </el-form-item>
                <el-form-item :label="$t('projectmanager')" >
                    <el-select v-if="user.userNameNeedTranslate != 1" v-model="addForm.inchargerId"  filterable :placeholder="$t('defaultText.pleaseChoose')" style="width:100%;" >
                        <el-option v-for="item in project.participationList" :key="item.id" :label="item.name" :value="item.id"></el-option>
                    </el-select>
                    <selectCat v-if="user.userNameNeedTranslate == 1" :size="'mini'" :subject="project.participationList" :subjectId="addForm.inchargerId" :distinction="'1'" @selectCal="selectCal"></selectCat>
                </el-form-item>
            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button @click.native="pVisible = false">{{ $t('btn.cancel') }}</el-button>
                <el-button type="primary" @click="submitParticip" :loading="addLoading">{{ $t('btn.submit') }}</el-button>
            </div>
        </el-dialog>

        <!--添加参与人界面-->
        <el-dialog :title="$t('addingParticipant')" v-if="addMembVisible" :visible.sync="addMembVisible" :close-on-click-modal="false" customClass="customWidth" width="600px">
            <el-form ref="addMembForm" :model="addMembForm"  label-width="120px">
                <el-form-item :label="$t('addAdding')">
                    <el-select v-model="addMembForm.userId" multiple filterable :placeholder="$t('defaultText.pleaseChoose')" style="width:100%;" >
                        <el-option v-for="item in users" :key="item.id" :label="item.name" :value="item.id"></el-option>
                    </el-select>
                </el-form-item>
            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button @click.native="addMembVisible = false">{{ $t('btn.cancel') }}</el-button>
                <el-button type="primary" @click="submitAddMemb" :loading="addLoading">{{ $t('btn.submit') }}</el-button>
            </div>
        </el-dialog>

        <!--修改工程专业界面-->
        <el-dialog :title="$t('engineering')" v-if="editProfessionDialog" :visible.sync="editProfessionDialog" 
        :close-on-click-modal="false" customClass="customWidth" width="1000px">
            <el-table :data="projectProfessionList" size="small" max-height="400" :key="Math.random()">
                <el-table-column prop="professionId" width="200">
                                   <template slot-scope="scope">
                                       <el-select v-model="scope.row.professionId" >
                                           <el-option v-for="item in professionList" :key="item.id" :label="item.name" :value="item.id"/>
                                       </el-select>
                                   </template>
                                   <template slot="header" >
                                       <span style="font-size:14px;font-weight:normal;">{{ $t('nameprofessional') }}</span>
                                   </template>
                               </el-table-column>
                               <el-table-column prop="percentage" width="100" :label="$t('Accountedfor')">
                                   <template slot-scope="scope">
                                       <el-input type="number" v-model="scope.row.percentage"></el-input>
                                   </template>
                               </el-table-column>
                               
                               <el-table-column prop="membNames" :label="$t('personnelproportion')">
                                   <template slot-scope="scope">
                                       <span style="margin:0 5px;" v-for="item in scope.row.membList" :key="item.membId">
                                            <span v-if="user.userNameNeedTranslate != 1">{{item.membName}}({{item.percentage}}%)</span>
                                            <span v-if="user.userNameNeedTranslate == 1">
                                                <ww-open-data type='userName' :openid='item.membName'></ww-open-data>({{item.percentage}}%)
                                            </span>
                                        </span>
                                       <el-link @click="showEditPpMembs(scope.row)">
                                            {{(scope.row.membList == null || scope.row.membList.length == 0)?$t('professionalparticipants'):$t('setup')}}
                                       </el-link>
                                   </template>
                               </el-table-column>
                               <el-table-column prop="inchargerName" width="120" :label="$t('head')">
                                   <template slot-scope="scope">
                                       <el-select v-model="scope.row.inchargerId" >
                                           <el-option v-for="item in participator" :key="item.id" :label="item.name" :value="item.id">
                                           </el-option>
                                       </el-select>
                                   </template>
                               </el-table-column>
                               <el-table-column  width="80">
                                   <template slot-scope="scope">
                                       <el-button icon="el-icon-delete" size="mini" style="margin-left:10px;" @click.stop.native="deleteItem(scope.$index)"></el-button>
                                   </template>
                                   <template slot="header" >
                                       <el-link type="primary" :underline="false" @click="addItem">{{ $t('addTian') }}</el-link>
                                   </template>
                               </el-table-column>
            </el-table>
            <div slot="footer" class="dialog-footer">
                <el-button @click.native="editProfessionDialog = false">{{ $t('btn.cancel') }}</el-button>
                <el-button type="primary" @click="saveProjectProfessions" :loading="addLoading">{{ $t('btn.submit') }}</el-button>
            </div>
        </el-dialog>

        <!-- 项目专业人员的设置 -->
        <el-dialog :title="$t('setupprojectprofessionals')"  v-if="editPpMembDialog" :visible.sync="editPpMembDialog" :close-on-click-modal="false" customClass="customWidth" width="600px">
            <el-table :data="curProfessionRow.membList" height="400">
                <el-table-column prop="name" :label="$t('professionals')">
                    <template slot-scope="scope">
                        <el-select v-model="scope.row.membId"  filterable :placeholder="$t('professionaladdsparticipant')" style="width:100%;" >
                            <el-option v-for="item in participator" :key="item.id" :label="item.name" :value="item.id">
                            </el-option>
                        </el-select>
                    </template>
                </el-table-column>
                <el-table-column prop="percentage" width="120" :label="$t('zhan-bi')">
                    <template slot-scope="scope">
                        <el-input type="number" v-model="scope.row.percentage"></el-input>
                    </template>
                </el-table-column>
                <el-table-column  width="80">
                    <template slot-scope="scope">
                        <el-button icon="el-icon-delete" size="mini" style="margin-left:10px;" @click.stop.native="deleteMembItem(scope.$index)"></el-button>
                    </template>
                    <template slot="header" >
                        <el-link @click="addMembItem">{{ $t('addTian') }}</el-link>
                    </template>
                </el-table-column>
            </el-table>
            <div slot="footer" class="dialog-footer">
                <el-button  @click="editPpMembDialog = false" >{{ $t('btn.cancel') }}</el-button>
                <el-button type="primary" @click="addPpMemb" >{{ $t('btn.determine') }}</el-button>
            </div>
        </el-dialog>
        <!-- 编辑项目关键节点 -->
        <el-dialog :title="$t('editkeyprojectnodes')" :visible.sync="keyNodeIsShow" width="960px" :before-close="handleClose">
            <div>
                <!--新版 -->
                <div class="keyNodes">
                    <div class="keyNodesName">{{ $t('nameofthenode') }}</div>
                    <div class="keyNodesTime">{{ $t('plannedcompletiontime') }}</div>
                    <div class="keyNodesTime">{{ $t('actualcompletiontime') }}</div>
                    <div class="keyNodesTime">{{ $t('state.states') }}</div>
                </div>
                <div class="keyNodes" v-for="item in projectKeyNodesData" :key="item.nodesId">
                    <div class="keyNodesName">{{item.nodesName}}</div>
                    <div class="keyNodesTime">
                        <el-date-picker v-model="item.planCompleteDate" clearable style="width: 80%" size="small" :editable="false" format="yyyy-MM-dd"  value-format="yyyy-MM-dd" type="date"  :placeholder="$t('optiondate')"></el-date-picker>
                    </div>
                    <div class="keyNodesTime">
                        <el-date-picker v-model="item.actualCompleteDate" clearable style="width: 80%" size="small" :editable="false" format="yyyy-MM-dd"  value-format="yyyy-MM-dd" type="date"  :placeholder="$t('optiondate')"></el-date-picker>
                    </div>
                    <div class="keyNodesTime">
                        <el-select v-model="item.states" :placeholder="$t('defaultText.pleaseChoose')" style="width: 80%" size="small">
                            <el-option :label="$t('zheng-chang')" value="0"></el-option>
                            <el-option :label="$t('yu-qi')" value="1"></el-option>
                            <el-option :label="$t('wan-cheng')" value="2"></el-option>
                        </el-select>
                    </div>
                </div>
            </div>
            <span slot="footer" class="dialog-footer">
                <el-button @click="keyNodeIsShow = false">{{ $t('btn.cancel') }}</el-button>
                <el-button type="primary" @click="submitKeyNodeaddForm()">{{ $t('btn.determine') }}</el-button>
            </span>
        </el-dialog>
        
        <!-- 按部门选择相关领导,弃用 -->
        <!-- <el-dialog title="选择相关领导"  v-if="chooseLeaderVisible" :visible.sync="chooseLeaderVisible" :close-on-click-modal="false" customClass="customWidth" width="500px">
            <div class="tree" style="height:400px">
                <el-scrollbar style="height:100%">
                <el-tree :data="deptMembData" show-checkbox :props="defaultProps" node-key="id"
                    ref="chooseLeaderTree" @check-change="onLeaderTreeItemChange" :default-checked-keys="addForm.notifyUserIds"
                    highlight-current ></el-tree>
                </el-scrollbar>
            </div>
            <div>已选中&nbsp;{{chosenMembCount}}&nbsp;人</div>
            <div slot="footer" class="dialog-footer">
                <el-button  @click="chooseLeaderVisible = false" >取消</el-button>
                <el-button type="primary" @click="chooseLeader()" >确定</el-button>
            </div>
        </el-dialog> -->
    </div>
</template>
<style scoped>
.fileTypeIcon {
    color:#20a0ff;font-size:20px;

}
.box {
    background:#fff;border: 1px solid #eeeeee;border-radius:5px;padding:10px;
}
.info span {
    color:#303133;
}
.gray_label {
    color:#999 !important;
}

.el-row {
    margin-top:10px;
}
.line {
    padding:10px;
}
.line span{
    font-size:15px;
}
.line span:nth-child(even){
    float:right;
}
.keyNodes {
    display: flex;
    width: 100%;
    box-sizing: border-box;
    padding: 10px 30px;
}
.keyNodes .keyNodesTime {
    width: 190px;
    display: flex;
    justify-content: center;
}
.keyNodes .keyNodesName {
    width: 260px;
    display: flex;
    align-items: center;
    overflow: hidden;
    text-overflow: ellipsis;
}
</style>
<script>
    // 自定义select组件
    import selectCat from "@/components/select.vue"
    import util from "../../common/js/util";
    export default {
        components: {
            selectCat
        },
        data() {
            return {
                permissions: JSON.parse(sessionStorage.getItem("permissions")),
                remark:null,
                progressData:{},
                deptMembData: [
                    {
                        id: 0,
                        label: this.$t('lable.unassigned'),
                    }
                ],
                chosenMembCount:0,
                chosenLeaders:[],
                chooseLeaderVisible:false,
                projectProfessionItem:null,
                curProfessionRow:null,
                editPpMembDialog:false,
                professionList:[],
                editProfessionDialog: false,
                projectProfessionList:[],
                modBaseCostData:[],
                projectBaseCostData:[],
                roleArray:[this.$t('role.ordinaryEmployees'),this.$t('role.superAdministrator'), this.$t('role.systemAdministrator'), this.$t('role.companyTop'),this.$t('role.financialAdministrator'), this.$t('role.projectManager')],
                addBaseFormVisible:false,
                addMembVisible:false,
                addMembForm:{},
                pVisible:false,
                taskSum:{},
                participator:[],
                users:[],
                addForm:{},
                addFormVisible:false,
                userDetail:{},
                userDetailVisible: false,
                importanceList:[{id:1,label:this.$t('zheng-chang')},{id:2,label:this.$t('jin-ji')},{id:3,label:this.$t('zhong-yao')},{id:4,label:this.$t('zhong-yao-qie-jin-ji')}],
                //1-一般,2-紧急,3-重要,4-重要且紧急
                levelTxt:[this.$t('all'),this.$t('zheng-chang'),this.$t('jin-ji'),this.$t('zhong-yao'),this.$t('zhong-yao-qie-jin-ji')],
                //1-进行中,2-已完成,3-已撤销
                statusTxt: [this.$t('all'),this.$t('ongoing'),this.$t('state.completed'),this.$t('state.undone')],
                mileStoneList:[],
                reverse:false,
                project:{},
                addFolderDialog: false,
                upLoading:false,
                keyword:null,
                user: JSON.parse(sessionStorage.getItem("user")),
                recentFiles: [],
                addLoading: false,
                curProjectId:null,
                title: "",
                rules: {
                    name: [{ required: true, message: this.$t('Pleaseenteraprojectname'), trigger: "blur" }],
                },
                contractRules: {
                    contractAmount: [{ required: true, message: this.$t('enterthecontractamount'), trigger: "blur" }]
                },
                yonghuUser: [],
                ause: [], // 研究中心总数据
                auseList: [], // 选中的研究中心


                contractDialog: false,
                contractData: {},
                contractRecordDialog: false,
                contractRecordLoading: false,
                contractRecordData: [],
                levelList: [],
                departmentList: [],
                keyNodesList: [],
                projectKeyNodesData: [],
                keyNodeIsShow: false,
            };
        },
        filters: {
            numberToCurrency(value) {
                // console.log('info numberToCurrency='+value);
                if (!value || value=='-') return '0.00'
                value = value.toFixed(2)
                const intPart = Math.trunc(value)
                const intPartFormat = intPart.toString().replace(/(\d)(?=(?:\d{3})+$)/g, '$1,')
                let floatPart = '.00'
                const valueArray = value.toString().split('.')
                if (valueArray.length === 2) { // 有小数部分
                floatPart = valueArray[1].toString() // 取得小数部分
                return intPartFormat + '.' + floatPart
                }
                return intPartFormat + floatPart
            }
        },
        methods: {
            levelTextShow(lev){
                if(this.user.timeType.projectLevelState == 1){
                    if(this.levelList.filter(item => item.id == lev).length == 0){
                        return this.levelTxt[lev]
                    }
                    return this.levelList.filter(item => item.id == lev)[0].projectLevelName
                }else{
                    return this.levelTxt[lev]
                }
            },
            // 提交关键节点
            submitKeyNodeaddForm() {
                this.http.post('/project-key-nodes/edit',{
                    projectId: this.project.id,
                    data: JSON.stringify(this.projectKeyNodesData)
                },res => {
                    if(res.code == 'ok'){
                        this.keyNodeIsShow = false
                        this.getKeyNodes()
                        this.$message({
                            message: this.$t('message.modifyTheSuccess'),
                            type: 'success'
                        });
                    }else {
                        this.$message({
                            message: res.msg,
                            type: 'error'
                        })
                    }
                },err => {
                    this.keyNodeIsShow = false
                    this.$message({
                        message: err,
                        type: 'error'
                    })
                })
            },
            filterUserContract(uid){
                let user = this.users.filter(item => item.id == uid)
                if(user.length > 0){
                    return user[0].name
                }else{
                    return '-'
                }
            },
            tempDateContract(date){
                let yyyy = date[0]
                let mm = date[1] < 10 ? '0' + date[1] : date[1]
                let dd = date[2] < 10 ? '0' + date[2] : date[2]
                let dh = date[3] < 10 ? '0' + date[3] : date[3]
                let dm = date[4] < 10 ? '0' + date[4] : date[4]
                let ds = date[5] < 10 ? '0' + date[5] : date[5]
                let datestr = yyyy + '-' + mm + '-' + dd + '\u3000' + dh + ':' + dm + ':' + ds
                return datestr
            },
            // 修改合同金额：参数
            //      oldContractAmount   原合同金额（看你要不要）
            //      contractAmount      修改后金额
            //      contractAmountDesc  修改原因（非必填）
            //      id                  项目id
            // 获取修改记录：操作人、修改时间、修改情况（增加还是减少 多少金额）、本次修改后的合同金额、修改原因
            // 修改合同金额
            contractChange(){
                let data = JSON.parse(JSON.stringify(this.project));
                this.contractData.id = data.id
                this.$set(this.contractData,'oldContractAmount',data.contractAmount)
                this.$set(this.contractData,'contractAmount',0)
                this.$set(this.contractData,'contractAmountDesc','')
                this.$set(this.contractData,'addordelete',1)
                this.contractDialog = true
            },
            contractChangeSure(){
                this.$refs.contractForm.validate(valid => {
                    if (valid) {
                        this.addLoading = true
                        let parameter = {
                            projectId: this.contractData.id,
                            oldContractAmount: this.contractData.oldContractAmount
                        }
                        if(this.contractData.addordelete){
                            parameter.newContractAmount = parseFloat(this.contractData.oldContractAmount) + parseFloat(this.contractData.contractAmount)
                        }else{
                            parameter.newContractAmount = parseFloat(this.contractData.oldContractAmount) - parseFloat(this.contractData.contractAmount)
                        }
                        if(this.contractData.contractAmountDesc.trim()){
                            parameter.reason = this.contractData.contractAmountDesc.trim()
                        }
                        this.http.post('/project/modifyContract',parameter,
                        res => {
                            this.addLoading = false
                            if(res.code == 'ok'){
                                this.contractDialog = false
                                this.$message({
                                    message: this.$t('message.modifyTheSuccess'),
                                    type: 'success'
                                })
                                this.getProjectInfo()
                            }else {
                                this.$message({
                                    message: res.msg,
                                    type: 'error'
                                })
                            }
                        },err => {
                            this.addLoading = false
                            this.$message({
                                message: err,
                                type: 'error'
                            })
                        })
                    }})
            },
            contractRecord(){   //修改记录
                this.contractRecordDialog = true
                this.contractRecordLoading = true
                this.http.post('/contract-modify-record/list',{
                    projectId: this.project.id
                },res => {
                    if(res.code == 'ok'){
                        this.contractRecordData = res.data
                        this.contractRecordLoading = false
                    }else {
                        this.contractRecordLoading = false
                        this.$message({
                            message: res.msg,
                            type: 'error'
                        })
                    }
                },err => {
                    this.contractRecordLoading = false
                    this.$message({
                        message: err,
                        type: 'error'
                    })
                })
            },


            yanjiuzx() {
                this.http.post('/report-extra-degree/getAll ',{},
                res => {
                    if (res.code == "ok") {
                        this.ause = res.data
                    } else {
                        this.$message({
                            message: res.msg,
                            type: "error"
                        });
                    }
                },
                error => {
                    this.$message({
                        message: error,
                        type: "error"
                    });
                    }
                );
            },
            userssHu() {
                this.http.post('/time-type/getCompanyTimeSetting',{ 
                    companyId: this.user.companyId
                },
                res => {
                    if (res.code == "ok") {
                        this.yonghuUser = res.data
                        // console.log(this.yonghuUser)
                    } 
                },
                error => {
                    this.$message({
                        message: error,
                        type: "error"
                    });
                    }
                );
            },
            getProgressData() {
                this.http.post("/project-profession/getProgressData", {projectId: this.curProjectId},
                    res => {
                        if (res.code == "ok") {
                            this.progressData = res.data;
                        } else {
                            this.$message({
                                message: res.msg,
                                type: "error"
                            });
                        }
                    },
                    error => {
                        this.$message({
                            message: error,
                            type: "error"
                        });
                    });
            },
            setUserToDept(list) {
                for (var i in list) {
                    if (list[i].children != null) {
                        this.setUserToDept(list[i].children);
                    }
                    
                    if (list[i].userList != null) {
                        if (list[i].children == null) {
                            list[i].children = [];
                        }
                        list[i].userList.forEach(element => {
                            var obj = {id: element.id, label:element.name, parentId:element.departmentId, isUser:1};
                            list[i].children.push(obj);
                        });
                    }
                }
            },
            getProjectLevel(){
                this.http.post('/project-level/list', {},
                res => {
                    if (res.code == "ok") {
                        this.levelList = res.data
                        // this.$set(this, 'levelList', res.data)
                    } else {
                        this.$message({
                            message: res.msg,
                            type: "error"
                        });
                    }
                },
                error => {
                    this.$message({
                        message: error,
                        type: "error"
                    });
                });
            },
            // 获取部门列表
            getDepartment() {
                this.http.post("/department/listAllMemb", {},
                res => {
                    if (res.code == "ok") {
                        var list = res.data;
                        //设置员工到部门下面
                        this.setUserToDept(list);
                        this.deptMembData = list;
                    } else {
                        this.$message({
                            message: res.msg,
                            type: "error"
                        });
                    }
                },
                error => {
                    this.$message({
                        message: error,
                        type: "error"
                    });
                });
            },

            getProjectNotifyUserList(projectId) {
                this.http.post("/project-notify-user/get", {projectId: projectId},
                    res => {
                        if (res.code == "ok") {
                            var chosenLeaderIds = [];
                            var chosenLeaderNames = '';
                            var leaderList = res.data;
                            this.chosenLeaders = leaderList;
                            for(var j in leaderList) {
                                chosenLeaderIds.push(leaderList[j].userId)
                                chosenLeaderNames += leaderList[j].userName+',';
                            }
                            if (chosenLeaderNames.length > 0) {
                                chosenLeaderNames = chosenLeaderNames.substring(0, chosenLeaderNames.length -1);
                            }
                            this.addForm.notifyUserIds = chosenLeaderIds;
                            this.addForm.notifyUserNames = chosenLeaderNames;
                        } else {
                            this.$message({
                                message: res.msg,
                                type: "error"
                            });
                        }
                    },
                    error => {
                        this.$message({
                            message: error,
                            type: "error"
                        });
                    });
            },
            showChooseLeaderTree() {
                this.chosenMembCount = this.chosenLeaders.length;
                this.chooseLeaderVisible = true;
            },
            onLeaderTreeItemChange() {
                var chosenList = this.$refs.chooseLeaderTree.getCheckedNodes();
                var list = chosenList.filter(item=>item.isUser == 1);
                this.chosenMembCount = list.length;
            },
            //选中相关领导
            chooseLeader() {
                this.chooseLeaderVisible = false;
                var chosenList = this.$refs.chooseLeaderTree.getCheckedNodes();
                var chosenMembList = chosenList.filter(item=>item.isUser == 1);
                this.addForm.notifyUserNames = '';
                this.addForm.notifyUserIds = [];
                this.chosenLeaders = [];
                for (var i=0;i<chosenMembList.length; i++) {
                    this.addForm.notifyUserIds.push(chosenMembList[i].id);
                    this.addForm.notifyUserNames += chosenMembList[i].label+',';
                    var item = {userId:chosenMembList[i].id, userName:chosenMembList[i].label};
                    this.chosenLeaders.push(item);
                }
                if (this.addForm.notifyUserNames.length > 0) {
                    this.addForm.notifyUserNames = this.addForm.notifyUserNames.substring(0, this.addForm.notifyUserNames.length-1);
                }
                //提交数据修改
                this.http.post("/project-notify-user/modify", {projectId: this.curProjectId, chosenLeaders: JSON.stringify(this.chosenLeaders)},
                res => {
                    if (res.code == "ok") {
                        
                    } else {
                        this.$message({
                            message: res.msg,
                            type: "error"
                        });
                    }
                },
                error => {
                    this.$message({
                        message: error,
                        type: "error"
                    });
                });
            },

            restrictNumber(targetId) {
                let inpu = document.getElementById(targetId);
                inpu.value = inpu.value.replace(/[^\d.]/g, "");  //仅保留数字和"."
                inpu.value = inpu.value.replace(/\.{2,}/g, "."); //两个连续的"."仅保留第一个"."
                inpu.value = inpu.value.replace(".", "$#*").replace(/\./g,'').replace('$#*','.');//去除其他"."
                inpu.value = inpu.value.replace(/^(\d+)\.(\d\d).*$/, '$1.$2');;//限制只能输入两个小数
                if (inpu.value.indexOf(".") < 0 && inpu.value != "") { //首位是0的话去掉
                    inpu.value = parseFloat(inpu.value);
                }
                // if (inpu.value.substring(0,1) == '.'){
                //     inpu.value = '0' + inpu.value
                // }
            },
            addPpMemb() {
                //检查合计比例是否到达100%
                let p = 0;
                let hasNoMemb = false;

                this.curProfessionRow.membList.forEach(m=>{
                    p += parseInt(m.percentage);
                    //检查人员是否选择
                    if (m.membId == null) {
                        hasNoMemb = true;
                    }
                });
                if (hasNoMemb) {
                    this.$message({
                            message: this.$t('professionalscannotbeempty'),
                            type: "error"
                        });
                    return;
                }
                //检查人员不能重复
                let hasDuplicate = false;
                this.curProfessionRow.membList.forEach(m=>{
                    if (this.curProfessionRow.membList.filter(innerM=>innerM.membId == m.membId).length>1) {
                        hasDuplicate = true;
                    }
                });
                if (hasDuplicate) {
                    this.$message({
                            message: this.$t('professionalscannotrepeat'),
                            type: "error"
                        });
                    return;
                }
                if (p != 100) {
                    this.$message({
                            message: this.$t('totalproportionmust'),
                            type: "error"
                        });
                    return;
                }
                

                this.editPpMembDialog = false;
                this.curProfessionRow.membList.forEach(m=>{
                    m.membName = this.participator.filter(p=>p.id == m.membId)[0].name;
                });
                this.projectProfessionItem.membList = JSON.parse(JSON.stringify(this.curProfessionRow.membList));
            },
            //删除专业人员
            deleteMembItem(index) {
                this.curProfessionRow.membList.splice(index,1);
            },
            //添加专业人员
            addMembItem() {
                if (this.curProfessionRow.membList == null) {
                    this.curProfessionRow.membList = [{membId:null, percentage:100}];
                } else {
                    let p = 0;
                    this.curProfessionRow.membList.forEach(m=>{
                        p += parseInt(m.percentage);
                    });
                    this.curProfessionRow.membList.push({membId:null, percentage:100-p});
                }
                this.$forceUpdate();
            },
            showEditPpMembs(row) {
                this.projectProfessionItem = row;
                this.curProfessionRow = JSON.parse(JSON.stringify(row));
                if (this.curProfessionRow.membList == null || this.curProfessionRow.membList.length == 0) {
                    this.curProfessionRow.membList = [{membId:null, percentage:100}];
                } 
                this.editPpMembDialog = true;
            },
            checkProjectProfession() {
                //检查合计比例是否到达100%
                let p = 0;
                let hasNoMemb = false;
                let hasNoProfession = false;
                let hasNoMembList = false;
                this.projectProfessionList.forEach(m=>{
                    p += parseInt(m.percentage);
                    //检查人员是否选择
                    if (m.inchargerId == null) {
                        hasNoMemb = true;
                    }
                    if (m.professionId == null) {
                        hasNoProfession = true;
                    }
                    if (m.membList == null) {
                        hasNoMembList = true;
                    }
                });
                
                if (hasNoProfession) {
                    this.$message({
                            message: this.$t('majorcannotbeempty'),
                            type: "error"
                        });
                    return false;
                }
                if (hasNoMembList) {
                    this.$message({
                            message: this.$t('personnelcannotbeleftblank'),
                            type: "error"
                        });
                    return false;
                }
                
                if (hasNoMemb) {
                    this.$message({
                            message: this.$t('leadercannotbeblank'),
                            type: "error"
                        });
                    return false;
                }
                //检查专业不能重复
                let hasDuplicate = false;
                this.projectProfessionList.forEach(m=>{
                    if (this.projectProfessionList.filter(innerM=>innerM.professionId == m.professionId).length>1) {
                        hasDuplicate = true;
                    }
                });
                if (hasDuplicate) {
                    this.$message({
                            message: this.$t('shouldnotberepeated'),
                            type: "error"
                        });
                    return false;
                }
                if (p != 100) {
                    this.$message({
                            message: this.$t('numberomajorsmust'),
                            type: "error"
                        });
                    return false;
                }
                return true;
            },
            showEditProfession() {
                if (this.professionList.length == 0) {
                    this.getProfessionList();
                }
                this.projectProfessionList = JSON.parse(JSON.stringify(this.projectProfessionListOnPage));
                this.editProfessionDialog = true;
            },
            getProjectProfessionList() {
                this.http.post("/project-profession/get", {projectId: this.curProjectId},
                    res => {
                        if (res.code == "ok") {
                            this.projectProfessionListOnPage = res.data;
                        } else {
                            this.$message({
                                message: res.msg,
                                type: "error"
                            });
                        }
                    },
                    error => {
                        this.$message({
                            message: error,
                            type: "error"
                        });
                    });
            },
            //保存项目专业
            saveProjectProfessions() {
                if (!this.checkProjectProfession()) {//检查不通过，直接返回
                    return;
                }
                let projectId = this.curProjectId;
                var list = this.projectProfessionList.filter(p=>p.professionId != null);
                list.forEach(p=>p.inchargerName = this.participator.filter(m=>m.id == p.inchargerId)[0].name);
                list.forEach(p=>p.professionName = this.professionList.filter(m=>m.id == p.professionId)[0].name);
                this.http.post("/project-profession/modify", {projectId: projectId, json: JSON.stringify(list)},
                res => {
                    if (res.code == "ok") {
                        this.editProfessionDialog = false;
                        this.projectProfessionListOnPage = res.data;
                        this.$message({
                            message: this.$t('message.modifyTheSuccess'),
                            type: "success"
                        });
                    } else {
                        this.$message({
                            message: res.msg,
                            type: "error"
                        });
                    }
                },
                error => {
                    this.$message({
                        message: error,
                        type: "error"
                    });
                });
            },
            //删除项目专业
            deleteItem(index) {
                this.projectProfessionList.splice(index,1);
            },
            //添加项目专业
            addItem() {
                let p = 0;
                this.projectProfessionList.forEach(m=>{
                    p += parseInt(m.percentage);
                });
                this.projectProfessionList.push( { professionId:null, inchargerId:null,membIds:[], percentage: 100-p});
            },
            getProfessionList() {
                this.http.post("/profession/getAll", {},
                res => {
                    if (res.code == "ok") {
                        var list = res.data;
                        this.professionList = list;
                    } else {
                        this.$message({
                            message: res.msg,
                            type: "error"
                        });
                    }
                },
                error => {
                    this.$message({
                        message: error,
                        type: "error"
                    });
                });
            },
            getProjectBaseData(projectId) {
                this.http.post('/project-basecost/get',{projectId: projectId},
                        res => {
                            if (res.code == "ok") {
                               this.projectBaseCostData = res.data;
                            } else {
                                this.$message({
                                    message: res.msg,
                                    type: "error"
                                });
                            }
                        },
                        error => {
                            this.$message({
                                message: error,
                                type: "error"
                            });
                            }
                        );
            },
            adjustBase() {
                //如果没有做修改，不提交数据
                var hasChangeData = false;
                for (var i=0;i<this.modBaseCostData.length; i++) {
                    var item = this.modBaseCostData[i];
                    var oldAmount = this.projectBaseCostData.filter(p=>p.id == item.id)[0].baseAmount;
                    if (item.baseAmount != oldAmount) {
                        hasChangeData = true;
                        break;
                    }
                }
                if (!hasChangeData) {
                    this.addBaseFormVisible = false;
                    return;
                }
                this.http.post('/project/adjustBase', {
                    id: this.addForm.id,
                    contractAmount: this.addForm.contractAmount,
                    baseCostData:JSON.stringify(this.modBaseCostData),
                    remark: this.remark
                },
                res => {
                    if (res.code == "ok") {
                        this.getProjectBaseData(this.curProjectId);
                        this.addBaseFormVisible = false;
                        this.$message({
                            message: this.$t('jiaozheng'),
                            type: "success"
                        });
                        this.$emit("basecost-change", null);
                    } else {
                        this.$message({
                        message: res.msg,
                        type: "error"
                        });
                    }
                },
                error => {
                    this.$message({
                        message: error,
                        type: "error"
                    });
                });
            },
            //提交添加参与人的请求
            submitAddMemb() {
                this.addLoading = true;
                let formData = new FormData();
                formData.append("id", this.curProjectId);
                // console.log(this.addMembForm.userId, '要传过去的数据')
                if(this.addMembForm.userId.length != 0) {
                    for(var j in this.addMembForm.userId) {
                        formData.append("userId", this.addMembForm.userId[j]);
                    }
                } else {
                    this.addLoading = false;
                    this.$message({
                        message: this.$t('Pleaseselectparticipants'),
                        type: 'warning'
                    });
                    return
                }
                // return
                this.http.uploadFile('/project/addMemb',formData,
                res => {
                    this.addLoading = false;
                    if (res.code == "ok") {
                        this.$message({
                            message: this.$t('addsuccessful'),
                            type: "success"
                        });
                        this.addMembForm.userId = []
                        this.addMembVisible = false;
                        this.getProjectInfo();
                        this.$parent.$parent.$parent.getDetail(); // 调用父级页面的方法
                    } else {
                        this.$message({
                            message: res.msg,
                            type: "error"
                        });
                    }
                },
                error => {
                    this.addLoading = false;
                    this.$message({
                        message: error,
                        type: "error"
                    });
                });
            },
            getProjectTaskSum() {
                this.http.post('/project/taskSum', {
                    id: this.curProjectId
                },
                res => {
                    if (res.code == "ok") {
                        this.taskSum = res.data;
                    } else {
                        this.$message({
                        message: res.msg,
                        type: "error"
                        });
                    }
                },
                error => {
                    this.$message({
                        message: error,
                        type: "error"
                    });
                });
            },
            number(){　　
        　　　  this.addForm.contractAmount = this.addForm.contractAmount.replace(/[^\.\d]/g,'');
                this.addForm.contractAmount = this.addForm.contractAmount.replace('.','');
        　　},
            //选择参与人
            changeParticipator() {
                //检查是否在参与人中，如果没有需要加入到参与人中
                // console.log(this.addForm.userId);
                var find = false;
                this.project.participationList = [];
                this.addForm.userId.forEach(u=>{
                    var findUser = this.users.filter(au=>au.id == u)[0];
                    // var findUser = this.users.filter(au=>au.id == u);
                    this.project.participationList.push(findUser);
                })
                // console.log(this.project.participationList, '看看')
            },
            getUsers() {
                // this.http.post(this.port.manage.list, {
                //     departmentId: -1,
                //     pageIndex: 1,
                //     pageSize: -1
                //     // pageSize: 99999
                // },
                this.http.post('/user/getSimpleActiveUserList', {},
                res => {
                    if (res.code == "ok") {
                        this.users = res.data;
                    } else {
                        this.$message({
                        message: res.msg,
                        type: "error"
                        });
                    }
                },
                error => {
                    this.$message({
                        message: error,
                        type: "error"
                    });
                });
            },
            submitParticip() {
                this.addLoading = true;
                let formData = new FormData();
                if(this.addForm.id != null) {
                    formData.append("id", this.addForm.id);
                }
                formData.append("name", this.addForm.name);
                if(this.addForm.userId.length != 0) {
                    for(var j in this.addForm.userId) {
                        formData.append("userId", this.addForm.userId[j]);
                    }
                }
                if(this.addForm.inchargerId != null) {
                    formData.append("inchargerId", this.addForm.inchargerId);
                }
                formData.append("onlyChangeParticipate", 'true');
                
                this.http.uploadFile(this.port.project.add,formData,
                res => {
                    this.addLoading = false;
                    if (res.code == "ok") {
                        this.$message({
                            message: this.$t('message.modifyTheSuccess'),
                            type: "success"
                        });
                        this.pVisible = false;
                        this.getProjectInfo();
                        // 子调父方法 getDetail（）
                        this.$parent.$parent.$parent.getDetail()
                    } else {
                        this.$message({
                            message: res.msg,
                            type: "error"
                        });
                    }
                },
                error => {
                    this.addLoading = false;
                    this.$message({
                        message: error,
                        type: "error"
                    });
                });
            },
            submitInsert() {
                this.$refs.basicInfoForm.validate(valid => {
                    if (valid) {
                        this.addLoading = true;
                        let formData = new FormData();
                        formData.append("name", this.addForm.name);
                        if(this.addForm.id != null) {
                            formData.append("id", this.addForm.id);
                        }
                        if(this.addForm.userId.length != 0) {
                            for(var j in this.addForm.userId) {
                                formData.append("userId", this.addForm.userId[j]);
                            }
                        }
                        if(this.addForm.inchargerId != null) {
                            formData.append("inchargerId", this.addForm.inchargerId);
                        }
                        if(this.addForm.code != null) {
                            formData.append("code", this.addForm.code);
                        }
                        if(this.addForm.planStartDate != null) {
                            formData.append("planStartDate", this.addForm.planStartDate);
                        }
                        if(this.addForm.planEndDate != null) {
                            formData.append("planEndDate", this.addForm.planEndDate);
                        }
                        if(this.addForm.level != null) {
                            formData.append("level", this.addForm.level);
                        }
                        if(this.addForm.contractAmount != null) {
                            formData.append("contractAmount", this.addForm.contractAmount);
                        }
                        if(this.addForm.projectDesc != null) {
                            formData.append("projectDesc", this.addForm.projectDesc);
                        }
                        if(this.user.timeType.outputValueStatus == 1){
                            formData.append("outputValue", this.addForm.outputValue ? this.addForm.outputValue : 0)
                        }
                        var listId = []
                        var listName = []
                        if(this.auseList.length > 0) {
                            for(var l in this.auseList) {
                                for(var o in this.ause) {
                                    if(this.auseList[l] == this.ause[o].id) {
                                        listId.push(this.ause[o].id)
                                        listName.push(this.ause[o].name)
                                        break;
                                    }
                                }
                            }
                        }
                        listId.toString()
                        listName.toString()
                        // console.log(listId, listName)
                        formData.append("associateDegrees", listId)
                        formData.append("associateDegreeNames", listName)
                        // 判断公司id是否等于 936
                        if(this.user.companyId == '936') {
                             formData.append("contractCode", this.addForm.projectSeparate.contractCode ? this.addForm.projectSeparate.contractCode : '');
                             formData.append("warrantyStartDate", this.addForm.projectSeparate.warrantyStartDate ? this.addForm.projectSeparate.warrantyStartDate : '');
                             formData.append("warrantyEndDate", this.addForm.projectSeparate.warrantyEndDate ? this.addForm.projectSeparate.warrantyEndDate : '');
                             formData.append("projectCategorySub", this.addForm.projectSeparate.projectCategorySub ? this.addForm.projectSeparate.projectCategorySub : '');
                             formData.append("region", this.addForm.projectSeparate.region ? this.addForm.projectSeparate.region : '');
                             formData.append("bu", this.addForm.projectSeparate.bu ? this.addForm.projectSeparate.bu : '');
                        }
                        if(this.user.companyId == '428') {
                             formData.append("projectCategorySub", this.addForm.projectSeparate.projectCategorySub ? this.addForm.projectSeparate.projectCategorySub : '');
                        }
                        if(this.user.timeType.projectWithDept) {
                            if(this.addForm.deptId != null && this.addForm.deptId != '') {
                                formData.append("deptId", this.addForm.deptId[this.addForm.deptId.length - 1]);
                            }
                        }
                        // return
                        this.http.uploadFile(this.port.project.add,formData,
                        res => {
                            this.addLoading = false;
                            if (res.code == "ok") {
                                this.$message({
                                    message: (this.addForm.id!=null?this.$t('xiu-gai'):this.$t('create'))+this.$t('other.successful'),
                                    type: "success"
                                });
                                this.addFormVisible = false;
                                this.getProjectInfo();
                            } else {
                                this.$message({
                                    message: res.msg,
                                    type: "error"
                                });
                            }
                        },
                        error => {
                            this.addLoading = false;
                            this.$message({
                                message: error,
                                type: "error"
                            });
                        });
                        }
                });
            },
            
            showEdit() {
                this.addForm = JSON.parse(JSON.stringify(this.project));
                // console.log('---'+this.project);
                // console.log(this.addForm.projectCode);
                
                var list = this.project.participationList , arr = [];
                for(var j in list) {
                    arr.push(list[j].id)
                }
                this.$set(this.addForm,'code',this.addForm.projectCode)
                this.$set(this.addForm,'name',this.addForm.projectName)
                this.$set(this.addForm,'outputValue',this.addForm.outputValue ? this.addForm.outputValue : null)
                this.addForm.userId = arr
                this.addFormVisible = true;
                // console.log(this.addForm, 123)
                var arr = []
                // if(this.addForm.associateDegrees != null) {
                    if(this.addForm.associateDegrees.length > 0) {
                        if(this.addForm.associateDegrees.length == 1) {
                            var sl = +this.addForm.associateDegrees + 0
                            arr.push(sl)              
                        } else {
                            var spl =  this.addForm.associateDegrees.split(',')
                            for(var i in spl) {
                                var ss  = +spl[i] + 0
                                arr.push(ss)
                            }
                        }
                    } else {
                        arr = []
                    }
                // }
                this.auseList = arr
                var listList = JSON.parse(JSON.stringify(this.addForm)),
                arrList = [],
                array = [];
                if (listList.deptCascade != "0" && listList.deptCascade != null) {
                if (listList.deptCascade.indexOf(",") > -1) {
                    arrList = listList.deptCascade.split(",");
                } else {
                    arrList = [].concat(listList.deptCascade);
                }
                }
                for (var i in arrList) {
                    array.push(parseInt(arrList[i]));
                }
                this.$set(this.addForm,'deptId', array.reverse())
                // console.log(this.auseList, '看看是个什么值')
                // console.log(this.addForm, '看看是个什么值')
            },
            showEditPar() {
                this.addForm = JSON.parse(JSON.stringify(this.project));
                this.addForm.code = this.addForm.projectCode;
                this.addForm.name = this.addForm.projectName;
                //设置参与人
                var list = this.project.participationList , arr = [];
                for(var j in list) {
                    arr.push(list[j].id)
                }
                this.addForm.userId = arr;
                // console.log(this.addForm.userId );

                this.pVisible = true;
                
            },
            showEditParKeyNode() {
                // console.log('出发了')
                this.keyNodeIsShow = true
                this.projectKeyNodesData = JSON.parse(JSON.stringify(this.keyNodesList))
            },
            //显示用户详情
            showUser(userId) {
                this.userDetailVisible = true;
                this.http.post(this.port.manage.userDetail, {
                    userId: userId
                },
                res => {
                    if (res.code == "ok") {
                        this.userDetail = res.data;
                    } else {
                        this.$message({
                        message: res.msg,
                        type: "error"
                        });
                    }
                },
                error => {
                    this.$message({
                        message: error,
                        type: "error"
                    });
                });
            },
            cursorOver(row, column, cell, event) {
                this.currentDataId = row.id;
            },
            viewOnline(row) {
                this.http.post('/pdf-file/getProjectFile', {fileId: row.id},
                res => {
                    if (res.code == "ok") {
                        // console.log(res.data+'----'+row.documentName);
                        let routeUrl = this.$router.resolve({
                            path: "/viewonline",
                            params: {serverFname:res.data, fileName:row.documentName}
                        });
                        sessionStorage.setItem("serverFname",res.data);
                        sessionStorage.setItem("fileName",row.documentName);
                        // console.log(routeUrl.href);
                        window.open(routeUrl.href, '_blank');
                    } else {
                        this.$message({
                            message: res.msg,
                            type: 'error'
                        });
                    }
                }, error => {
                    this.$message({
                        message: error,
                        type: 'error'
                    });
                })
            },
            

            openWin(url) {
                var el = document.createElement("a");
                document.body.appendChild(el);
                el.href = encodeURI(url); 
                el.target = '_blank'; 
                el.click();
                document.body.removeChild(el);
            },

            //获取里程碑文件
            getMileStoneList() {
                this.http.post('/task/getMileStoneList', {
                    projectId: this.curProjectId,
                },
                res => {
                    if (res.code == "ok") { 
                        // console.log(res.data, '里程碑数据')
                        for(var i in res.data) {
                            // if(res.data[i].taskStatus == 1) {
                            //     res.data[i].taskTex = '完成于 ' + res.data[i].finishDate
                            // } else {
                            //     res.data[i].taskTex = '截止于 ' + res.data[i].endDate
                            // }
                            if(res.data[i].finishDate) {
                                let str = this.$t('wan-cheng-yu') + res.data[i].finishDate
                                res.data[i].taskTex = str
                                if(res.data[i].endDate) {
                                    let strS = this.$t('jie-zhi-yu') + res.data[i].endDate
                                    let assignment = `${strS}   ${str}`
                                    res.data[i].taskTex = assignment
                                }
                                // res.data[i].taskTex = '完成于 ' + res.data[i].finishDate
                            } else if(res.data[i].endDate) {
                                res.data[i].taskTex = this.$t('jie-zhi-yu') + res.data[i].endDate
                            } else {
                                res.data[i].taskTex = ''
                            }

                        }
                        this.mileStoneList = res.data;
                        this.mileStoneList.unshift( {id:-1, name:this.$t('kai-shi'), taskStatus:1});
                        
                        
                    } else {
                        this.$message({
                        message: res.msg,
                        type: "error"
                        });
                    }
                },
                error => {
                    this.$message({
                        message: error,
                        type: "error"
                    });
                });
            },
            getUsers() {
                // this.http.post(this.port.manage.list, {
                //     departmentId: -1,
                //     pageIndex: 1,
                //     // pageSize: 99999
                //     pageSize: -1
                // },
                this.http.post('/user/getSimpleActiveUserList', {},
                res => {
                    if (res.code == "ok") {
                        this.users = res.data;
                    } else {
                        this.$message({
                        message: res.msg,
                        type: "error"
                        });
                    }
                },
                error => {
                    this.$message({
                        message: error,
                        type: "error"
                    });
                });
            },


            //获取列表
            getProjectInfo() {
                this.listLoading = true;
                this.http.post('/project/detail', {
                    id: this.curProjectId
                },
                res => {
                    this.listLoading = false;
                    if (res.code == "ok") {
                        this.project = res.data;
                        if(this.user.companyId == '936' || this.user.companyId == '428') {
                            if(res.data.projectSeparate) {
                                this.project = res.data;
                            } else {
                                if(this.user.companyId == '936') {
                                    var obj = {
                                        contractCode: '',
                                        warrantyStartDate: '',
                                        warrantyEndDate: '',
                                        projectCategorySub: '',
                                        region: '',
                                        bu: '',
                                    }
                                    res.data.projectSeparate = obj
                                    this.project = res.data;
                                } else {
                                    var obj = {
                                        projectCategorySub: '',
                                    }
                                    res.data.projectSeparate = obj
                                    this.project = res.data;
                                }
                            }
                        } else {
                            this.project = res.data;
                        }
                        // console.log('看看值')
                        // console.log('test123',this.project);
                        this.participator = this.project.participationList;
                    } else {
                        this.$message({
                        message: res.msg,
                        type: "error"
                        });
                    }
                },
                error => {
                    this.listLoading = false;
                    this.$message({
                        message: error,
                        type: "error"
                    });
                });
                this.getProjectProfessionList();
            },
            // 获取部门
            getDepartmentList() {
                this.http.post( this.port.manage.depList, {},
                    res => {
                    if (res.code == "ok") {
                        let dptlist = JSON.parse(JSON.stringify(res.data));
                        this.departmentList = this.changeArr(dptlist);
                    } else {
                        this.$message({
                            message: res.msg,
                            type: "error"
                        });
                    }
                    },error => {
                    this.$message({
                        message: error,
                        type: "error"
                    });
                });
            },
            changeArr(arr) {
                for (var i = 0; i < arr.length; i++) {
                    if(arr[i].id != -1 && arr[i].id != 0) {
                        if (arr[i].children != null && arr[i].children.length>0) {
                            arr[i].children = this.changeArr(arr[i].children);
                        }
                        arr[i].id && (arr[i].value = arr[i].id);
                        delete arr[i].id;
                    }
                }
                for(var i in arr) {
                    if(arr[i].id == -1 || arr[i].id == 0) {
                        arr.splice(i,1)
                    }    
                }
                return arr;
            },
            refreshPage() {
                this.curProjectId = parseInt(this.$route.params.id);
                this.getMileStoneList();
                this.getProjectInfo();
                this.getProjectTaskSum();
                this.getProjectBaseData(this.curProjectId);
                this.getProjectNotifyUserList(this.curProjectId);
                this.getProgressData();
            },
            getKeyNodes() {
                this.http.post('/project-key-nodes/get', {
                    projectId: this.curProjectId
                },
                    res => {
                    if (res.code == "ok") {
                        this.keyNodesList = res.data
                    } else {
                        this.$message({
                            message: res.msg,
                            type: "error"
                        });
                    }
                    },error => {
                    this.$message({
                        message: error,
                        type: "error"
                    });
                });
            },
            selectCal(obj) {
                if(obj.distinction == '1' ) {
                    this.addForm.inchargerId = obj.id
                }
            }
        },
        created() {
            // console.log('created===');
            let height = window.innerHeight;
            this.tableHeight = height - 160;
            const that = this;
            window.onresize = function temp() {
                that.tableHeight = window.innerHeight - 160;
            };
        },
        mounted() {
            // console.log('mounted===');
            this.curProjectId = parseInt(this.$route.params.id);
            this.getDepartment();
            this.getUsers();

            this.getMileStoneList();
            this.getProjectInfo();
            this.getProjectTaskSum();
            this.getProjectBaseData(this.curProjectId);
            this.getProjectNotifyUserList(this.curProjectId);
            this.getProgressData();
            this.userssHu()
            this.yanjiuzx()
            this.getProjectLevel()
            // if(this.user.timeType.projectWithDept) {
            //     this.getProjectLevel()
            // }
            if(this.user.companyId == '936') {
                this.getKeyNodes()
            }
        }
    };
</script>