<template>
  <div class="app-container">
    <div v-show="viewState ==1">
      <button-bar view-title="项目列表" ref="btnbar" :btndisabled="btndisabled" @btnhandle="btnHandle" />
      <div class="main-content">
        <div class="searchcon">
          <el-button size="small" class="searchbtn" @click="clicksearchShow">{{ searchxianshitit }}</el-button>
          <div v-show="isSearchShow" class="search">
            <el-form ref="listQueryform" :inline="true" :model="listQuery" label-width="80px" class="tab-header">
              <el-form-item label="项目名称">
                <el-input v-model="listQuery.params.entryName" maxlength="20" placeholder="请输入项目名称" class="addinputw"
                  clearable />
              </el-form-item>
              <el-form-item label="项目类型">
                <el-select v-model="listQuery.params.projectType" placeholder="请选择">
                  <el-option v-for="(item,i) in ProjectTypeList" :key="i" :label="item.projectType"
                    :value="item.projectType">
                  </el-option>
                </el-select>
              </el-form-item>
              <el-form-item label="贷款行">
                <el-select v-model="listQuery.params.bankSid" placeholder="请选择">
                  <el-option v-for="(item,i) in storehouseList" :key="i" :label="item.name" :value="item.sid">
                  </el-option>
                </el-select>
              </el-form-item>
              <el-form-item label="项目状态">
                <el-select v-model="listQuery.params.stateName" placeholder="请选择" @change="getState">
                  <el-option v-for="(item,i) in stateList" :key="i" :label="item.name" :value="item.sid">
                  </el-option>
                </el-select>
              </el-form-item>
            </el-form>
            <div class="btn" style="text-align: center;">
              <el-button type="primary" icon="el-icon-search" size="small" @click="handleReset">查询</el-button>
              <el-button type="primary" icon="el-icon-refresh" size="small" @click="handleFilter">重置</el-button>
            </div>
          </div>
        </div>
        <div class="listtop">
          <div class="tit">项目列表</div>
          <!-- 翻页分页 -->
          <!-- <pageye v-show="list.length > 0" :total="listQuery.total" :page.sync="listQuery.current" :limit.sync="listQuery.size" class="pagination" @pagination="getList"/> -->
        </div>
        <div class="">
          <el-table v-loading="listLoading" :data="list" border style="width: 100%;" :row-style="{height: '40px'}">
            <!-- <el-table-column type="selection" align="center" width="50"/> -->
            <el-table-column label="序号" type="index" width="80" :index="indexMethod" align="center" />
            <el-table-column label="操作" wid align="center" width="550">
              <template slot-scope="scope">
                <el-button type="primary" size="mini" @click="toPhase(scope.row)">项目阶段</el-button>
                <el-button type="primary" size="mini" @click="toProgress(scope.row)">项目进度</el-button>
                <el-button type="primary" size="mini" @click="toCreditLimit(scope.row)">用还信</el-button>
                <el-button type="primary" size="mini" @click="toLog(scope.row)">监管日志</el-button>
                <el-button type="primary" size="mini" @click="toReport(scope.row)">项目报告</el-button>
                <el-button type="primary" size="mini" @click="toTieUp(scope.row)">关联商享通仓库</el-button>
              </template>
            </el-table-column>
            <el-table-column label="项目名称" prop="entryName" width="250" align="center" />
            <el-table-column label="所属行业" prop="industryName" width="120" align="center" />
            <el-table-column label="项目类型" prop="typeName" width="120" align="center" />
            <el-table-column label="项目状态" prop="stateName" width="120" align="center" />
            <el-table-column label="授信额度" prop="creditLimit" width="120" align="center" />
            <el-table-column label="签约日期" prop="signingDate" width="120" align="center" />
            <el-table-column label="到期日期" prop="endDate" width="120" align="center" />
            <el-table-column label="用信总额" prop="useLimit" width="120" align="center" />
            <el-table-column label="贷款行" prop="bankName" align="center" />
            <el-table-column label="客户经理" prop="bmanagerName" width="120" align="center" />
            <!-- <el-table-column label="企业名称"  prop="enterpriseName"  width="250"  align="center" /> -->
            <!-- <el-table-column label="联系人" prop="econtacts" width="100" align="center" /> -->
            <el-table-column label="监管负责人" prop="regulatoryLeader" width="120" align="center" />
          </el-table>
        </div>
        <div class="pages">
          <pagination v-show="list.length > 0" :total="listQuery.total" :page.sync="listQuery.current"
            :limit.sync="listQuery.size" class="pagination" @pagination="getList" />
        </div>
      </div>
    </div>
    <!-- <projectAdd v-show="viewState ==2 || viewState ==3" ref="divAdd" @doback="resetState"  @reloadlist="getList" /> -->
    <!-- <projectInfo v-show="viewState ==4" ref="divInfo" @doback="resetState"   @reloadlist="getList"/> -->

    <el-dialog title="项目阶段" :close-on-click-modal="false" :visible.sync="dialogShow" width="15%"
      :before-close="dialogClose">

      <el-select v-model="projectState.nodeValue" placeholder="项目阶段" style="margin-top: -30px;"
        @change="seleProjectState">
        <el-option v-for="item in options" :key="item.nodeKey" :label="item.nodeValue" :value="item.nodeKey">
        </el-option>
      </el-select>

      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogClose">取 消</el-button>
        <el-button type="primary" @click="saveProjectState()">保 存</el-button>
      </span>
    </el-dialog>

    <el-dialog title="项目进度" :close-on-click-modal="false" :visible.sync="dialogShow5" width="60%"
      :before-close="dialogClose5">

      <div class="step2Item" style="margin-top: -30px;">

        <el-input v-model="progressParams.params.name" style="width: 200px;" placeholder="阶段名称" clearable />
        <el-button type="primary" style="margin-left: 20px;" @click="getProgressData()">查询</el-button>
        <el-button type="primary" style="margin-left: 20px;" @click="addProgress()">添加</el-button>
        <el-button type="danger" style="margin-left: 20px;" @click="doProgressDel()">删除</el-button>

      </div>
      <el-table :data="progressData" border style="width: 98%;margin-left: 15px;margin-top: 10px;"
        @selection-change="handleSelectionProgressChange">
        <el-table-column fixed width="50" type="selection" align="center" />
        <el-table-column label="序号" type="index" width="60" :index="indexMethod" align="center" />
        <el-table-column label="操作" wid align="center" width="80">
          <template slot-scope="scope">
            <el-button type="primary" size="mini" @click="doProgressEdit(scope.row)">编辑</el-button>
            <!-- <el-button type="danger" size="mini" @click="doProgressDel(scope.$index)">删除</el-button> -->
          </template>
        </el-table-column>
        <el-table-column label="阶段名称" prop="progressDescription" align="center" />
        <el-table-column label="发生日期" prop="orderDate" align="center" />
        <el-table-column label="下一阶段" prop="nextStage" align="center" />
        <el-table-column label="备注" prop="remarks" align="center" />
      </el-table>
      <div class="pages">
        <pagination v-show="progressData.length > 0" :total="progressParams.total" :page.sync="progressParams.current"
          :limit.sync="progressParams.size" class="pagination" @pagination="getProgressData" />
      </div>

      </el-form>
      <span slot="footer" class="dialog-footer">
        <!-- <el-button @click="dialogClose5">取 消</el-button> -->
        <el-button type="primary" @click="dialogClose5">关 闭</el-button>
      </span>
    </el-dialog>

    <el-dialog title="项目进度" :close-on-click-modal="false" :visible.sync="dialogShow6" width="60%"
      :before-close="dialogClose6">

      <el-form ref="form_daily" :model="progressInfo" label-position="right" class="formadd" style="margin-top: -30px;">
        <el-row class="first_row">
          <el-col :span="4" class="tleftb2">
            <span>阶段名称</span>
          </el-col>
          <el-col :span="8" class="trightb">
            <el-form-item>
              <el-input v-model="progressInfo.progressDescription" placeholder="阶段名称" style="width:100%"
                class="addinputw" clearable />
            </el-form-item>
          </el-col>
          <el-col :span="4" class="tleftb2">
            <span>发生日期</span>
          </el-col>
          <el-col :span="8" class="trightb">
            <el-form-item> <el-date-picker v-model="progressInfo.orderDate" type="date" style="width: 100%;"
                placeholder="选择日期" value-format="yyyy-MM-dd" /></el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="4" class="tleftb2">
            <span>下一阶段</span>
          </el-col>
          <el-col :span="8" class="trightb">
            <el-form-item>
              <el-input v-model="progressInfo.nextStage" placeholder="下一阶段" style="width:100%" class="addinputw"
                clearable />
            </el-form-item>
          </el-col>
          <el-col :span="4" class="tleftb2">
            <span>备注</span>
          </el-col>
          <el-col :span="8" class="trightb">
            <el-form-item>
              <el-form-item> <el-input v-model="progressInfo.remarks" placeholder="备注" style="width:100%"
                  class="addinputw" clearable /></el-form-item>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="4" class="tleftb2">
            <span>相关附件</span>
          </el-col>
          <el-col :span="20" class="trightb">
            <el-form-item>
              <upload style="margin-top: 10px;" ref="uploadImg2" v-model="imgList2" :limit="9" @change="backData2"
                bucket="map" :upload-data="{ type: '0001' }"></upload>
            </el-form-item>
          </el-col>
        </el-row>

      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogClose6">取 消</el-button>
        <el-button type="primary" @click="saveProgress()">保 存</el-button>
      </span>
    </el-dialog>

    <el-dialog title="用、还信记录" :close-on-click-modal="false" :visible.sync="dialogShow7" width="60%"
      :before-close="dialogClose7">

      <div class="step2Item" style="margin-top: -30px;">

        <el-input v-model="creditLimitParams.params.money" placeholder="项目名称" style="width:200px" clearable />
        <el-button type="primary" style="margin-left: 20px;" @click="getCreditLimit()">查询</el-button>
        <el-button type="primary" style="margin-left: 20px;" @click="addCreditLimit1()">添加用信</el-button>
        <el-button type="primary" style="margin-left: 20px;" @click="addCreditLimit2()">添加还信</el-button>
        <el-button type="danger" style="margin-left: 20px;" @click="doCreditRecordDel()">删除</el-button>

      </div>

      <el-table :data="creditLimitData" border style="width: 98%;margin-left: 15px;margin-top: 10px;"
        @selection-change="handleSelectionCreditRecordChange">
        <el-table-column type="selection" align="center" width="50" />
        <el-table-column label="序号" type="index" width="60" :index="indexMethod" align="center" />
        <el-table-column label="操作" wid align="center" width="80">
          <template slot-scope="scope">
            <el-button type="primary" size="mini" @click="doCreditRecordEdit(scope.row)">编辑</el-button>
          </template>
        </el-table-column>
        <el-table-column label="项目名称" prop="projectname" align="center" />
        <el-table-column label="填报日期" prop="tbdate" align="center" />
        <el-table-column label="类型" prop="typename" align="center" />
        <el-table-column label="金额" prop="money" align="center" />
        <el-table-column label="性质" prop="creditNature" align="center" />
        <el-table-column label="备注" prop="remarks" align="center" />

      </el-table>
      <div class="pages">
        <pagination v-show="creditLimitData.length > 0" :total="creditLimitParams.total"
          :page.sync="creditLimitParams.current" :limit.sync="creditLimitParams.size" class="pagination"
          @pagination="getCreditLimit" />
      </div>

      </el-form>
      <span slot="footer" class="dialog-footer">
        <!-- <el-button @click="dialogClose7">取 消</el-button> -->
        <el-button type="primary" @click="saveSxtWarehouses()">关 闭</el-button>
      </span>
    </el-dialog>

    <el-dialog title="用、还信" :close-on-click-modal="false" :visible.sync="dialogShow2" width="60%"
      :before-close="dialogClose2">

      <el-form ref="form_daily" :model="creditLimitInfo" label-position="right" class="formadd"
        style="margin-top: -30px;">
        <el-row class="first_row">
          <el-col :span="4" class="tleftb2">
            <span>项目名称</span>
          </el-col>
          <el-col :span="8" class="trightb">
            <el-form-item>
              <span>{{creditLimitInfo.projectname}}</span>
            </el-form-item>
          </el-col>
          <el-col :span="4" class="tleftb2">
            <span>填报日期</span>
          </el-col>
          <el-col :span="8" class="trightb">
            <el-form-item> <el-date-picker v-model="creditLimitInfo.tbdate" type="date" style="width: 100%;"
                placeholder="选择日期" value-format="yyyy-MM-dd" /></el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="4" class="tleftb2">
            <span>类型</span>
          </el-col>
          <el-col :span="8" class="trightb">
            <el-form-item>
              <el-radio-group v-model="creditLimitInfo.type" :disabled="true">
                <el-radio :label="1">用信</el-radio>
                <el-radio :label="2">还信</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
          <el-col :span="4" class="tleftb2">
            <span>金额</span>
          </el-col>
          <el-col :span="8" class="trightb">
            <el-form-item>
              <el-form-item> <el-input v-model="creditLimitInfo.money" placeholder="请输入金额" style="width:100%"
                  class="addinputw"
                  oninput="value=value.replace(/[^\d.]/g, '').replace(/\.{2,}/g, '.').replace('.', '$#$').replace(/\./g, '').replace('$#$', '.').replace(/^(\-)*(\d+)\.(\d\d).*$/, '$1$2.$3').replace(/^\./g, '')"
                  clearable /></el-form-item>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="4" class="tleftb2">
            <span>预计到货日期</span>
          </el-col>
          <el-col :span="8" class="trightb">
            <el-form-item> <el-date-picker v-model="creditLimitInfo.expectedDeliveryDate" type="date"
                style="width: 100%;" placeholder="选择日期" value-format="yyyy-MM-dd" /></el-form-item>
          </el-col>
          <el-col :span="4" class="tleftb2">
            <span>预计完工日期</span>
          </el-col>
          <el-col :span="8" class="trightb">
            <el-form-item>
              <el-form-item> <el-date-picker v-model="creditLimitInfo.expectedCompletionDate" type="date"
                  style="width: 100%;" placeholder="选择日期" value-format="yyyy-MM-dd" /></el-form-item>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="4" class="tleftb2">
            <span>性质</span>
          </el-col>
          <el-col :span="8" class="trightb">
            <el-form-item>
              <el-input v-model="creditLimitInfo.creditNature" placeholder="性质" style="width:100%" class="addinputw"
                clearable />
            </el-form-item>
          </el-col>
          <el-col :span="4" class="tleftb2">
            <span>备注</span>
          </el-col>
          <el-col :span="8" class="trightb">
            <el-form-item> <el-input v-model="creditLimitInfo.remarks" placeholder="请输入备注" style="width:100%"
                class="addinputw" clearable /></el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="4" class="tleftb2">
            <span>附件</span>
          </el-col>
          <el-col :span="20" class="trightb">
            <el-form-item>
              <upload style="margin-top: 10px;" ref="uploadImg2" v-model="imgList" :limit="9" @change="backData"
                bucket="map" :upload-data="{ type: '0001' }"></upload>
            </el-form-item>
          </el-col>
        </el-row>

      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogClose2">取 消</el-button>
        <el-button type="primary" @click="saveFormobj()">保 存</el-button>
      </span>
    </el-dialog>

    <el-dialog title="监管日志记录" :close-on-click-modal="false" :visible.sync="dialogShow8" width="60%"
      :before-close="dialogClose8">

      <div class="step2Item" style="margin-top: -30px;">

        <el-input v-model="logParams.params.name" placeholder="工作名称" style="width:200px" clearable />
        <el-button type="primary" style="margin-left: 20px;" @click="getLogData()">查询</el-button>
        <el-button type="primary" style="margin-left: 20px;" @click="addLog()">添加</el-button>
        <el-button type="danger" style="margin-left: 20px;" @click="doLogDel()">删除</el-button>

      </div>

      <el-table :data="logData" border style="width: 98%;margin-left: 15px;margin-top: 10px;"
        @selection-change="handleSelectionLogChange">
        <el-table-column fixed width="50" type="selection" align="center" />
        <el-table-column label="序号" type="index" width="60" :index="indexMethod" align="center" />
        <el-table-column label="操作" wid align="center" width="80">
          <template slot-scope="scope">
            <el-button type="primary" size="mini" @click="doLogEdit(scope.row)">编辑</el-button>
          </template>
        </el-table-column>
        <el-table-column label="工作名称" prop="regulatoryWork" align="center" />
        <el-table-column label="日期" prop="orderDate" align="center" />
        <el-table-column label="下一步工作安排" prop="workArrangement" align="center" />
        <el-table-column label="备注" prop="remarks" align="center" />
      </el-table>

      <div class="pages">
        <pagination v-show="logData.length > 0" :total="logParams.total" :page.sync="logParams.current"
          :limit.sync="logParams.size" class="pagination" @pagination="getLogData" />
      </div>

      </el-form>
      <span slot="footer" class="dialog-footer">
        <!-- <el-button @click="dialogClose8">取 消</el-button> -->
        <el-button type="primary" @click="dialogClose8()">关 闭</el-button>
      </span>
    </el-dialog>

    <el-dialog title="监管日志" :close-on-click-modal="false" :visible.sync="dialogShow9" width="60%"
      :before-close="dialogClose9">

      <el-form ref="form_daily" :model="logInfo" label-position="right" class="formadd" style="margin-top: -30px;">
        <el-row class="first_row">
          <el-col :span="4" class="tleftb2">
            <span>工作名称</span>
          </el-col>
          <el-col :span="8" class="trightb">
            <el-form-item>
              <el-input v-model="logInfo.regulatoryWork" placeholder="工作名称" style="width:100%" class="addinputw"
                clearable />
            </el-form-item>
          </el-col>
          <el-col :span="4" class="tleftb2">
            <span>日期</span>
          </el-col>
          <el-col :span="8" class="trightb">
            <el-form-item> <el-date-picker v-model="logInfo.orderDate" type="date" style="width: 100%;"
                placeholder="选择日期" value-format="yyyy-MM-dd" /></el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="4" class="tleftb2">
            <span>下一工作安排</span>
          </el-col>
          <el-col :span="8" class="trightb">
            <el-form-item>
              <el-input v-model="logInfo.workArrangement" placeholder="下一工作安排" style="width:100%" class="addinputw"
                clearable />
            </el-form-item>
          </el-col>
          <el-col :span="4" class="tleftb2">
            <span>备注</span>
          </el-col>
          <el-col :span="8" class="trightb">
            <el-form-item>
              <el-form-item> <el-input v-model="logInfo.remarks" placeholder="备注" style="width:100%" class="addinputw"
                  clearable /></el-form-item>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="4" class="tleftb2">
            <span>相关附件</span>
          </el-col>
          <el-col :span="20" class="trightb">
            <el-form-item>
              <upload style="margin-top: 10px;" ref="uploadImg2" v-model="imgList3" :limit="9" @change="backData3"
                bucket="map" :upload-data="{ type: '0001' }"></upload>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogClose9">取 消</el-button>
        <el-button type="primary" @click="saveLog()">保 存</el-button>
      </span>
    </el-dialog>

    <el-dialog title="项目报告" :close-on-click-modal="false" :visible.sync="dialogShow3" width="60%"
      :before-close="dialogClose3">

      <el-form ref="form_daily" label-position="right" class="formadd" style="margin-top: -30px;">
        <el-row class="first_row">

          <el-col :span="4" class="tleftb2" style="padding-bottom: 10px;padding-top: 10px;">
            <span>报告类型</span>
          </el-col>
          <el-col :span="8" class="trightb">
            <el-form-item style="padding-bottom: 10px;padding-top: 10px;">
              <el-select v-model="reportInfo.typeValue" placeholder="报告类型" @change="seleReportType">
                <el-option v-for="item in options" :key="item.nodeKey" :label="item.nodeValue" :value="item.nodeKey">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="4" class="tleftb2" style="padding-bottom: 10px;padding-top: 10px;">
            <span>上传报告</span>
          </el-col>
          <el-col :span="8" class="trightb">
            <el-form-item style="padding-bottom: 10px;padding-top: 10px;">
              <el-upload class="upload-demo" :action="updateAction" :on-success="handleSuccess"
                :on-remove="handleRemove" :file-list="uploadFileList">
                <el-button size="small" type="primary" v-show="reportInfo.typeKey!=''">点击上传报告</el-button>
              </el-upload>
            </el-form-item>
          </el-col>
        </el-row>

        <!-- <el-row>
          <el-col :span="4" class="tleftb2" style="padding-bottom: 10px;padding-top: 10px;">
            <span>竣工报告</span>
          </el-col>
          <el-col :span="8" class="trightb">
            <el-form-item style="padding-bottom: 10px;padding-top: 10px;">
              <el-upload class="upload-demo" :action="updateAction" :on-success="handleSuccess3"
                :on-remove="handleRemove3" :file-list="uploadFileList3">
                <el-button size="small" type="primary">点击上传报告</el-button>
              </el-upload>
            </el-form-item>
          </el-col>
          <el-col :span="4" class="tleftb2">
            <span></span>
          </el-col>
          <el-col :span="8" class="trightb">
            <el-form-item></el-form-item>
          </el-col>
        </el-row> -->

      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogClose3">取 消</el-button>
        <el-button type="primary" @click="saveReport()">保 存</el-button>
      </span>
    </el-dialog>

    <el-dialog title="关联仓库" :close-on-click-modal="false" :visible.sync="dialogShow4" width="60%"
      :before-close="dialogClose4">

      <div class="step2Item" style="margin-top: -30px;">

        <el-select v-model="warehouseName" class="addinputw" placeholder="请选择仓库" style="width:20%" @change="getCangku">
          <el-option v-for="item in seleWarehouseList" :label="item.warehouseName" :value="item.sid" />
        </el-select>

        <el-button type="primary" style="margin-left: 20px;" @click="addCangku()">添加</el-button>

      </div>

      <el-table :data="tieUpWarehouses.warehouse" border style="width: 98%;margin-left: 15px;margin-top: 10px;">
        <!-- <el-table-column type="selection" align="center" width="50"/> -->
        <el-table-column label="操作" wid align="center" width="116">
          <template slot-scope="scope">
            <el-button type="primary" size="mini" @click="doDel(scope.$index)">删除</el-button>
          </template>
        </el-table-column>
        <el-table-column label="仓库名称" prop="name" width="400" align="center" />
        <el-table-column label="仓库地址" prop="address" align="center" />
        <el-table-column label="联系人" prop="linkerName" width="120" align="center" />
        <el-table-column label="联系电话" prop="linkerPhone" width="150" align="center" />

      </el-table>

      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogClose4">取 消</el-button>
        <el-button type="primary" @click="saveSxtWarehouses()">保 存</el-button>
      </span>
    </el-dialog>


  </div>
</template>

<script>
  import req from '@/api/project/project'
  import Pagination from '@/components/pagination'
  import pageye from '@/components/pagination/pageye'
  import ButtonBar from '@/components/ButtonBar'
  // import projectAdd from './projectAdd2.vue'
  // import projectInfo from './projectInfo2.vue'
  import upload from '@/components/uploadFile/upload_yanchejianchaTuBiao.vue'
  export default {
    name: 'CustomerManagement',
    components: {
      Pagination,
      pageye,
      ButtonBar,
      upload
      // projectAdd,
      // projectInfo,

    },
    data() {
      return {
        listLoading: false,
        btndisabled: false,
        btnList: [
          // {
          //   type: 'primary',
          //   size: 'small',
          //   icon: 'plus',
          //   btnKey: 'toAdd',
          //   btnLabel: '新增'
          // },

          {
            type: 'info',
            size: 'small',
            icon: 'cross',
            btnKey: 'doClose',
            btnLabel: '关闭'
          }
        ],
        isSearchShow: false,
        searchxianshitit: '显示查询条件',
        list: [],
        listQuery: {
          current: 1,
          size: 10,
          params: {
            entryName: '',
            projectType: '',
            bankSid: '',
            stateSid: 'b2a9f856-016e-4880-ba1c-261ac4edc8ec',
            stateName: '正式监管',
          },
          total: 0
        },
        viewState: 1,
        storehouseList: [],
        ProjectTypeList: [],
        stateList: [],
        dialogShow: false,
        dialogShow2: false,
        dialogShow3: false,
        dialogShow4: false,
        dialogShow5: false,
        dialogShow6: false,
        dialogShow7: false,
        dialogShow8: false,
        dialogShow9: false,
        options: [],
        projectState: {
          sid: "",
          nodeKey: "",
          nodeValue: ""
        },
        radio: 1,
        imgList: [],
        imgList2: [],
        imgList3: [],
        imgList4: [],
        updateAction: process.env.VUE_APP_BASE_API + '/projectdaily/uploadfile',
        uploadFileList: [],
        reportFileList: [],
        warehouseName: '',
        cangKu: {},
        seleWarehouseList: [],
        tieUpWarehouses: {
          sid: "",
          warehouse: []
        },
        reportInfo: {
          mainsid: "",
          typeKey: '',
          typeValue: '',
          reportList: [],
        },
        progressParams: {
          current: 1,
          size: 10,
          params: {
            name: '',
            projectSid: ""
          },
          total: 0
        },
        progressData: [],
        progressSids: [],
        progressInfo: {
          projectSid: '',
          progressDescription: '',
          nextStage: '',
          orderDate: '',
          remarks: '',
          urls: []
        },

        creditLimitParams: {
          current: 1,
          size: 10,
          params: {
            name: '',
            projectsid: ""
          },
          total: 0
        },
        creditLimitData: [],
        creditRecordSids: [],
        creditRecordList: [],
        creditLimitInfo: {
          usersid: window.sessionStorage.getItem('userSid'),
          projectname: "",
          projectsid: '',
          tbdate: "",
          expectedCompletionDate: "",
          expectedDeliveryDate: "",
          creditNature: "",
          type: 1,
          money: "",
          pzfiles: [],
          remarks: "",
          psid: ""
        },

        logParams: {
          current: 1,
          size: 10,
          params: {
            name: '',
            projectSid: ""
          },
          total: 0
        },
        logData: [],
        logSids: [],
        logInfo: {
          projectSid: '',
          regulatoryWork: '',
          workArrangement: '',
          orderDate: '',
          remarks: '',
          urls: []
        }
      }
    },
    mounted() {
      this.$refs['btnbar'].setButtonList(this.btnList)
    },
    created() {
      this.init()
      // 加载列表
    },
    methods: {
      seleProjectState(val) {
        const choose = this.options.filter((item) => item.nodeKey == val)
        console.log('>>>>>>>>>seleProjectState', choose)
        this.projectState.nodeValue = choose[0].nodeValue
        this.projectState.nodeKey = choose[0].nodeKey
      },
      toPhase(row) {

        this.projectState = {
          sid: row.sid,
          nodeKey: row.nodeKey,
          nodeValue: row.nodeValue
        }

        req.getNodeByProjectSid({
          projectSid: row.sid
        }).then((res) => {
          console.log(">>>>>>>>>getNodeByProjectSid", res.data)
          this.options = res.data
          this.dialogShow = true
        })
      },
      dialogClose() {
        console.log(">>>>>>>>>dialogClose", this.projectState)
        this.projectState = {
          sid: "",
          nodeKey: "",
          nodeValue: ""
        }
        this.dialogShow = false
      },
      saveProjectState() {

        req.updatePhase(this.projectState).then((res) => {
          console.log(">>>>>>>>>updatePhase", res.data)
          this.getList()
          this.dialogShow = false
        })

      },
      toCreditLimit(row) {

        this.creditLimitParams.params.projectsid = row.sid
        this.creditLimitParams.params.projectname = row.entryName
        this.creditLimitInfo.projectsid = row.sid
        this.creditLimitInfo.projectname = row.entryName

        this.dialogShow7 = true
        this.getCreditLimit()
      },
      getCreditLimit() {
        req.getCreditRecord(this.creditLimitParams).then((response) => {
          console.log(">>>>>>>>>getCreditLimit", response.data)
          if (response.success) {
            this.creditLimitData = response.data.records
            this.creditLimitParams.total = response.data.total
          } else {
            this.creditLimitData = []
            this.creditLimitParams.total = 0
          }

        })
      },

      dialogClose7() {
        this.dialogShow7 = false
      },

      addCreditLimit1() {
        this.dialogShow2 = true
        this.creditLimitInfo.type = 1
      },
      addCreditLimit2() {

        if (this.creditRecordSids.length != 1) {
          this.$message({
            showClose: true,
            type: 'warning',
            message: '请选择一条记录进行操作'
          })
          return
        }

        if (this.creditRecordList[0].type != '1') {
          this.$message({
            showClose: true,
            type: 'warning',
            message: '请选择用信记录进行还信操作'
          })
          return
        }

        this.creditLimitInfo.psid = this.creditRecordSids[0]
        this.creditLimitInfo.type = 2
        this.creditLimitInfo.projectsid = this.creditRecordList[0].projectsid
        this.creditLimitInfo.projectname = this.creditRecordList[0].projectname
        this.dialogShow2 = true

      },
      handleSelectionCreditRecordChange(val) {
        console.log("val", val);
        const aa = []
        val.forEach(element => {
          aa.push(element.sid)
        })
        this.creditRecordList = val
        this.creditRecordSids = aa
      },
      doCreditRecordEdit(row) {
        this.creditLimitInfo = row
        this.imgList = []
        for (var i = 0; i < this.creditLimitInfo.pzfiles.length; i++) {
          this.imgList.push({
            url: this.creditLimitInfo.pzfiles[i]
          })
        }

        this.dialogShow2 = true

      },
      doCreditRecordDel() {
        if (this.creditRecordSids.length > 0) {
          const tip = '请确认是否删除所选记录?'
          this.$confirm(tip, '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning'
          }).then(() => {
            req.delCreditRecord(this.creditRecordSids).then((response) => {
              if (response.success) {
                this.$message({
                  showClose: true,
                  type: 'success',
                  message: '删除成功'
                })
                this.getCreditLimit()
              } else {
                this.$message({
                  showClose: true,
                  type: 'error',
                  message: '删除失败'
                })
              }
            })
          })
        } else {
          this.$message({
            showClose: true,
            type: 'warning',
            message: '请至少选择一条记录进行删除操作'
          })
        }
      },
      dialogClose2() {
        console.log("creditLimitInfo", this.creditLimitInfo)
        this.dialogShow2 = false
        this.imgList = []
        this.creditLimitInfo = {
          usersid: window.sessionStorage.getItem('userSid'),
          projectname: this.creditLimitParams.params.projectname,
          projectsid: this.creditLimitParams.params.projectsid,
          tbdate: "",
          expectedCompletionDate: "",
          expectedDeliveryDate: "",
          creditNature: "",
          type: 1,
          money: "",
          pzfiles: [],
          remarks: "",
          psid: ""
        }
      },
      radioChange(val) {
        console.log("radioChange", val)

        this.creditLimitInfo.creditNature = val

      },
      backData(value) {
        console.log(value, 999)
        console.log("imgList", this.imgList)
        const aa = []
        this.creditLimitInfo.pzfiles = []
        if (value.length > 0 && value != null && value != undefined) {
          for (var i = 0; i < value.length; i++) {
            aa.push(value[i].url)
          }
        }
        this.creditLimitInfo.pzfiles = aa

      },
      saveFormobj() {
        console.log("creditLimitInfo", this.creditLimitInfo)

        req.saveCreditRecord(this.creditLimitInfo).then((res) => {
          console.log(">>>>>>>>>saveCreditRecord", res.data)
          this.dialogShow2 = false
          this.imgList = []
          this.getCreditLimit()
          this.creditLimitInfo = {
            usersid: window.sessionStorage.getItem('userSid'),
            projectname: this.creditLimitParams.params.projectname,
            projectsid: this.creditLimitParams.params.projectsid,
            tbdate: "",
            expectedCompletionDate: "",
            expectedDeliveryDate: "",
            creditNature: "",
            type: 1,
            money: "",
            pzfiles: [],
            remarks: "",
            psid: ""
          }
        })

      },

      toReport(row) {
        this.reportInfo.mainsid = row.sid
        req.getNodeByProjectSid({
          projectSid: row.sid
        }).then((res) => {
          console.log(">>>>>>>>>getNodeByProjectSid", res.data)
          this.options = res.data
          this.dialogShow3 = true
        })
      },
      seleReportType(val) {
        console.log(">>>>>>>>>seleReportType1111", val)
        const choose = this.options.filter((item) => item.nodeKey == val)
        console.log('>>>>>>>>>seleReportType', choose)
        this.reportInfo.typeKey = choose[0].nodeKey
        this.reportInfo.typeValue = choose[0].nodeValue

      },

      dialogClose3() {
        this.dialogShow3 = false
      },
      saveReport() {

        var fileTypeName = ''

        if (this.reportInfo.typeValue == '在途') {
          fileTypeName = "到货验收报告"
        }
        if (this.reportInfo.typeValue == '在建') {
          fileTypeName = "在建查验报告"
        }
        if (this.reportInfo.typeValue == '竣工') {
          fileTypeName = "竣工报告"
        }

        for (var i = 0; i < this.reportFileList.length; i++) {
          var item = {
            url: this.reportFileList[i].fullUrl,
            absolutePath: this.reportFileList[i].filePath,
            name: fileTypeName,
            fileSrcName: this.reportFileList[i].fileSrcName,
          }
          this.reportInfo.reportList.push(item)
        }
        console.log('saveReport', this.reportInfo)

        req.saveProjectReport(this.reportInfo).then((res) => {
          this.uploadFileList = []
          this.reportFileList = []
          this.reportInfo.reportList = []
          this.dialogShow3 = false
        })

      },

      handleSuccess(resp, file, fileList) {
        console.log('handleSuccess----', resp)
        const _this = this
        const upfile = {
          fileTypeId: 6, // '文件类型: 1=帐户余额;2=应收账款;3=库存货值;4=在途货值;5=预付款;',
          fileTypeName: '项目报告', // '文件类型名: 1=帐户余额;2=应收账款;3=库存货值;4=在途货值;5=预付款',
          fileSrcName: resp.data.sourceFileName, // '原文件名',
          filePath: resp.data.filePath, // '文件的相对路径',
          fullUrl: resp.data.fullUrl, // '文件完整的访问URL',
          fileuid: file.uid // '文件完整的访问URL',
        }
        _this.reportFileList.push(upfile)
      },
      handleRemove(file, fileList) {
        const _this = this
        let delete_index = 0
        for (let i = 0, len = _this.reportFileList.length; i < len; i++) {
          if (file.uid === _this.reportFileList[i].fileuid) {
            delete_index = i
            break
          }
        }
        _this.reportFileList.splice(delete_index, 1)
      },

      getSxtWarehouses(sid) {
        req.getSxtWarehouses({
          sid: sid
        }).then((res) => {
          console.log(">>>>>>>>>getSxtWarehouses", res.data)
          this.seleWarehouseList = res.data
        })
      },

      toTieUp(row) {
        this.tieUpWarehouses.sid = row.sid

        req.initProjectWarehouses(row.sid).then((res) => {
          console.log(">>>>>>>>>initProjectWarehouses", res.data)
          this.tieUpWarehouses.warehouse = res.data.warehouse
          this.dialogShow4 = true
        })

        this.getSxtWarehouses(row.sid)

      },
      getCangku(value) {

        const choose = this.seleWarehouseList.filter((item) => item.sid === value)

        this.cangKu.name = choose[0].warehouseName
        this.cangKu.shSid = choose[0].sid
        this.cangKu.address = choose[0].address
        this.cangKu.linkerName = choose[0].contacts
        this.cangKu.linkerPhone = choose[0].mob

      },

      addCangku() {

        console.log(">>>>>>>>>addCangku", this.cangKu)
        console.log(">>>>>>>>>addCangku", this.tieUpWarehouses.warehouse)

        var info = {
          shSid: this.cangKu.shSid,
          name: this.cangKu.name,
          address: this.cangKu.address,
          linkerName: this.cangKu.linkerName,
          linkerPhone: this.cangKu.linkerPhone,
        }
        const choose = this.tieUpWarehouses.warehouse.filter((item) => item.shSid === info.shSid)
        console.log(">>>>>>>>>addCangku", choose)
        if (choose.length == 0)
          this.tieUpWarehouses.warehouse.push(info)
        else
          this.$message({
            showClose: true,
            type: 'error',
            message: "请勿重复添加!"
          })
      },
      doDel(index) {
        this.tieUpWarehouses.warehouse.splice(index, 1)
      },
      dialogClose4() {
        this.dialogShow4 = false
      },
      saveSxtWarehouses() {

        req.saveSxtWarehouses(this.tieUpWarehouses).then((res) => {
          console.log(">>>>>>>>>saveSxtWarehouses", res.data)
          this.dialogShow4 = false
          this.warehouseName = ''
        })

      },


      getState(value) {
        console.log(">>>>>>>>>getState", value)
        const choose = this.stateList.filter((item) => item.sid === value)
        console.log(">>>>>>>>>getState", choose)
        this.listQuery.params.stateSid = choose[0].sid

      },
      btnHandle(btnKey) {
        switch (btnKey) {
          // case 'toAdd':
          //   this.toAdd()
          //   break

          case 'doClose':
            this.doClose()
            break
          default:
            break
        }
      },
      // 搜索条件效果
      clicksearchShow() {
        this.isSearchShow = !this.isSearchShow
        if (this.isSearchShow) {
          this.searchxianshitit = '隐藏查询条件'
        } else {
          this.searchxianshitit = '显示查询条件'
        }
      },
      // 初始化
      init() {
        this.getList()
        this.getBankName()
      },
      // 序号
      indexMethod(index) {
        var pagestart = (this.listQuery.current - 1) * this.listQuery.size
        var pageindex = index + 1 + pagestart
        return pageindex
      },
      getBankName() {
        req.getUserListByOrg().then((res) => {
          console.log(">>>>>>>>>getBankName", res.data)
          this.storehouseList = res.data
        })
        req.getProjectType().then((res) => {
          console.log(">>>>>>>>>getProjectType", res.data)
          this.ProjectTypeList = res.data
        })

        req.getProjtypedstated().then((res) => {
          console.log(">>>>>>>>>getProjtypedstated", res.data)
          this.stateList = res.data
          this.stateList.unshift({
            name: '全部',
            sid: '',
          })
        })
      },
      // 查询列表信息
      getList() {
        this.listLoading = true
        req.listPage(this.listQuery).then((response) => {
          this.listLoading = false
          console.log(">>>>>>>>>listPage", response.data)
          if (response.success) {
            this.list = response.data.records
            this.listQuery.total = response.data.total
          } else {
            this.list = []
            this.listQuery.total = 0
          }
        })
      },
      // 查询按钮
      handleReset() {
        this.listQuery.current = 1
        this.getList()
      },
      // 重置
      handleFilter() {
        this.listQuery = {
          current: 1,
          size: 10,
          total: 0,
          params: {
            entryName: '',
            projectType: '',
            bankSid: '',
            stateSid: 'b2a9f856-016e-4880-ba1c-261ac4edc8ec',
            stateName: '正式监管',
          }
        }
        this.getList()
      },
      // 打开添加
      toAdd() {
        this.viewState = 2
        this.$refs['divAdd'].showAdd()
      },
      // 打开修改
      toEdit(row) {
        this.viewState = 3
        this.$refs['divAdd'].showEdit(row)
      },
      // 根据本行ID删除数据
      doDelss(row) {
        const tip = '请确认是否删除所选记录?'
        this.$confirm(tip, '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          req.delBySids(row.sid).then((response) => {
            if (response.success) {
              this.$message({
                showClose: true,
                type: 'success',
                message: '删除成功'
              })
              this.getList()
            } else {
              this.$message({
                showClose: true,
                type: 'error',
                message: '删除失败'
              })
            }
          })
        })
      },
      toDetail(row) {
        this.viewState = 4
        this.$refs['divInfo'].showAdd(row.sid)
      },
      resetState() {
        this.viewState = 1
      },
      jump(sid) {
        console.log("jump", sid)
        this.viewState = 2
        this.$refs['divAdd'].showAdd(sid)
      },
      close(sid) {
        this.viewState = 4
        this.$refs['divInfo'].showAdd(sid)
      },
      doClose() {
        this.$store.dispatch('tagsView/delView', this.$route)
        this.$router.go(-1)
      },
      toProgress(row) {

        this.progressParams.params.projectSid = row.sid
        this.progressInfo.projectSid = row.sid
        this.dialogShow5 = true
        this.getProgressData()
      },

      getProgressData() {

        req.getProgress(this.progressParams).then((response) => {
          console.log(">>>>>>>>>toProgress", response.data)
          if (response.success) {
            this.progressData = response.data.records
            this.progressParams.total = response.data.total
          } else {
            this.progressData = []
            this.progressParams.total = 0
          }

        })
      },

      dialogClose5() {
        this.dialogShow5 = false
      },
      addProgress() {
        this.dialogShow6 = true

      },
      handleSelectionProgressChange(val) {
        console.log("val", val);
        const aa = []
        val.forEach(element => {
          aa.push(element.sid)
        })
        this.progressSids = aa
      },
      doProgressEdit(row) {
        this.progressInfo = row
        for (var i = 0; i < this.progressInfo.urls.length; i++) {
          this.imgList2.push({
            url: this.progressInfo.urls[i]
          })
        }
        console.log("this.imgList2", this.imgList2)
        this.dialogShow6 = true
      },
      doProgressDel(index) {

        if (this.progressSids.length > 0) {
          const tip = '请确认是否删除所选记录?'
          this.$confirm(tip, '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning'
          }).then(() => {
            req.delProgress(this.progressSids).then((response) => {
              if (response.success) {
                this.$message({
                  showClose: true,
                  type: 'success',
                  message: '删除成功'
                })
                this.getProgressData()
              } else {
                this.$message({
                  showClose: true,
                  type: 'error',
                  message: '删除失败'
                })
              }
            })
          })
        } else {
          this.$message({
            showClose: true,
            type: 'warning',
            message: '请至少选择一条记录进行删除操作'
          })
        }
      },
      backData2(value) {
        console.log(value, 999)
        console.log("imgList", this.imgList2)
        const aa = []
        this.progressInfo.urls = []
        if (value.length > 0 && value != null && value != undefined) {
          for (var i = 0; i < value.length; i++) {
            aa.push(value[i].url)
          }
        }
        this.progressInfo.urls = aa

      },
      saveProgress() {
        req.saveProgress(this.progressInfo).then((res) => {
          this.dialogShow6 = false
          this.getProgressData()
          this.progressInfo = {
            projectSid: this.progressParams.params.projectSid,
            progressDescription: '',
            nextStage: '',
            orderDate: '',
            remarks: '',
            urls: []
          }
          this.imgList2 = []
        })
      },
      dialogClose6() {
        this.dialogShow6 = false
        this.progressInfo = {
          projectSid: this.progressParams.params.projectSid,
          progressDescription: '',
          nextStage: '',
          orderDate: '',
          remarks: '',
          urls: []
        }
        this.imgList2 = []
      },

      toLog(row) {
        this.logParams.params.projectSid = row.sid
        this.logInfo.projectSid = row.sid
        this.dialogShow8 = true
        this.getLogData()
      },
      getLogData() {
        req.getLog(this.logParams).then((response) => {
          console.log(">>>>>>>>>toLog", response.data)
          if (response.success) {
            this.logData = response.data.records
            this.logParams.total = response.data.total
          } else {
            this.logData = []
            this.logParams.total = 0
          }

        })

      },

      dialogClose8() {
        this.dialogShow8 = false
      },
      addLog(row) {
        this.dialogShow9 = true
      },
      handleSelectionLogChange(val) {

        console.log("val", val);
        const aa = []
        val.forEach(element => {
          aa.push(element.sid)
        })
        this.logSids = aa
      },
      doLogEdit(row) {
        this.logInfo = row
        for (var i = 0; i < this.logInfo.urls.length; i++) {
          this.imgList3.push({
            url: this.logInfo.urls[i]
          })
        }
        console.log("this.imgList3", this.imgList3)
        this.dialogShow9 = true
      },
      doLogDel() {

        if (this.logSids.length > 0) {
          const tip = '请确认是否删除所选记录?'
          this.$confirm(tip, '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning'
          }).then(() => {
            req.delLog(this.logSids).then((response) => {
              if (response.success) {
                this.$message({
                  showClose: true,
                  type: 'success',
                  message: '删除成功'
                })
                this.getLogData()
              } else {
                this.$message({
                  showClose: true,
                  type: 'error',
                  message: '删除失败'
                })
              }
            })
          })
        } else {
          this.$message({
            showClose: true,
            type: 'warning',
            message: '请至少选择一条记录进行删除操作'
          })
        }
      },

      backData3(value) {
        console.log(value, 999)
        console.log("imgList", this.imgList3)
        const aa = []
        this.logInfo.urls = []
        if (value.length > 0 && value != null && value != undefined) {
          for (var i = 0; i < value.length; i++) {
            aa.push(value[i].url)
          }
        }
        this.logInfo.urls = aa

      },
      saveLog() {
        req.saveLog(this.logInfo).then((res) => {
          this.dialogShow9 = false
          this.getLogData()
          this.logInfo = {
            projectSid: this.logParams.params.projectSid,
            regulatoryWork: '',
            workArrangement: '',
            orderDate: '',
            remarks: '',
            urls: []
          }
          this.imgList3 = []
        })
      },

      dialogClose9() {
        this.dialogShow9 = false
        this.logInfo = {
          projectSid: this.logParams.params.projectSid,
          regulatoryWork: '',
          workArrangement: '',
          orderDate: '',
          remarks: '',
          urls: []
        }
        this.imgList3 = []
      },
    }
  }
</script>
<style scoped>
  .wenjiantit {
    font-size: 16px;
    font-weight: bold;
    margin: 25px 0 10px 0;
  }

  .forminfo {
    margin: 0;
    padding: 0;
  }

  .listcon {
    height: calc(100vh - 250px);
    overflow-y: auto;
    overflow-x: hidden;
  }

  .tleftb2 {
    text-align: center;
    font-size: 14px;
    color: #606266;
    line-height: 40px !important;
    font-weight: 600;
  }

  .tleftb3 {
    display: flex;
    height: 100%;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-size: 14px;
    color: #666666;
  }

  .step2Item {
    display: flex;
    flex-direction: row;
    align-items: center;
    margin-left: 20px;
    padding-top: 15px;
    padding-bottom: 15px;

  }

  .step2ItemBtn {
    margin-left: 20px;
    color: #fff;
    background-color: #0294D7;
    padding: 5px 15px;
    border-radius: 5px;
  }
</style>
