<template>
  <div class="app-container">
    <div v-if="(showSurrender==0)">
      <!-- 筛选条件 -->
      <div>
        <Collapse :screen-form="screenForm">
          <template #right_btn>
            <el-button size="mini" @click="resetFn">清空</el-button>
            <el-button size="mini" type="primary" @click="searchFn">搜索</el-button>
          </template>
          <template #left_btn>
            <el-radio-group @change="changeRadioFn" v-model="examine" size="mini">
              <el-radio-button label="">全部</el-radio-button>
              <el-radio-button label="SAVE">保存</el-radio-button>
              <el-radio-button label="WAIT">待审核</el-radio-button>
              <!--   <el-radio-button label="FAIL">审核驳回</el-radio-button> -->
              <el-radio-button label="OK">审核通过</el-radio-button>
            </el-radio-group>
          </template>
          <template #search>
            <el-form ref="screenForm" :model="screenForm" label-width="140px" size="mini" label-position="left">
              <el-row :gutter="20">
                <el-col :xs="24" :sm="12" :lg="6">
                  <el-form-item label="工程登录编号" prop="refEnginRecordNo">
                    <el-input v-model="screenForm.refEnginRecordNo" placeholder="请输入" />
                  </el-form-item>
                </el-col>
                <el-col :xs="24" :sm="12" :lg="6">
                  <el-form-item label="经销商编码/名称" prop="customerKeyword">
                    <el-input v-model="screenForm.customerKeyword" placeholder="请输入" />
                  </el-form-item>
                </el-col>
                <!-- <el-col :xs="24" :sm="12" :lg="6">
                  <el-form-item label="经销商名称" prop="customerKeyword">
                    <el-input
                      v-model="screenForm.customerKeyword"
                      placeholder="请输入"
                    ></el-input>
                  </el-form-item>
                </el-col> -->
                <el-col :xs="24" :sm="12" :lg="6">
                  <el-form-item label="行业类别" prop="refTradeCategory">
                    <el-input v-model="screenForm.refTradeCategory" placeholder="请输入"></el-input>
                  </el-form-item>
                </el-col>
                <el-col :xs="24" :sm="12" :lg="6">
                  <el-form-item label="使用单位" prop="refUseUnit">
                    <el-input v-model="screenForm.refUseUnit" placeholder="请输入" />
                  </el-form-item>
                </el-col>
                <el-col :xs="24" :sm="12" :lg="6">
                  <el-form-item label="开始申请日期" prop="startSubmitTime">
                    <el-date-picker
                      v-model="screenForm.startSubmitTime"
                      class="dateStyle"
                      type="datetime"
                      placeholder="选择日期"
                      value-format="yyyy-MM-dd HH:mm:ss"
                    />
                  </el-form-item>
                </el-col>
                <el-col :xs="24" :sm="12" :lg="6">
                  <el-form-item label="结束申请日期" prop="endSubmitTime">
                    <el-date-picker
                      v-model="screenForm.endSubmitTime"
                      class="dateStyle"
                      type="datetime"
                      placeholder="选择日期"
                      value-format="yyyy-MM-dd HH:mm:ss"
                    />
                  </el-form-item>
                </el-col>

                <el-col :xs="24" :sm="12" :lg="6">
                  <el-form-item label="是否退押 " prop="isRefundDeposit">
                    <el-select style="width: 100%" v-model="screenForm.isRefundDeposit" placeholder="请选择是否退押 ">
                      <el-option label="默认" :value="null"></el-option>

                      <el-option
                        v-for="item in refundDepositArr"
                        :key="item.value"
                        :label="item.label"
                        :value="item.value"
                      >
                      </el-option>
                    </el-select>
                  </el-form-item>
                </el-col>
                <el-col :xs="24" :sm="12" :lg="6">
                  <el-form-item label="状态 " prop="examineStatus">
                    <el-select style="width: 100%" v-model="screenForm.examineStatus" placeholder="请选择状态 ">
                      <el-option label="默认" :value="null"></el-option>

                      <el-option
                        v-for="item in examineStatusArr"
                        :key="item.value"
                        :label="item.label"
                        :value="item.value"
                      >
                      </el-option>
                    </el-select>
                  </el-form-item>
                </el-col>
                <!-- <el-col :xs="24" :sm="12" :lg="6">
                  <el-form-item label="产品名称" prop="">
                    <el-input placeholder="请输入"></el-input>
                  </el-form-item>
                </el-col>
                <el-col :xs="24" :sm="12" :lg="6">
                  <el-form-item label="规格型号" prop="">
                    <el-input placeholder="请输入"></el-input>
                  </el-form-item>
                </el-col> -->
                <el-col :xs="24" :sm="12" :lg="6">
                  <el-form-item label="开始受理日期" prop="startConfirmTime">
                    <el-date-picker
                      v-model="screenForm.startConfirmTime"
                      class="dateStyle"
                      type="datetime"
                      placeholder="选择日期"
                      value-format="yyyy-MM-dd HH:mm:ss"
                    />
                  </el-form-item>
                </el-col>
                <el-col :xs="24" :sm="12" :lg="6">
                  <el-form-item label="结束受理日期" prop="endConfirmTime">
                    <el-date-picker
                      v-model="screenForm.endConfirmTime"
                      class="dateStyle"
                      type="datetime"
                      placeholder="选择日期"
                      value-format="yyyy-MM-dd HH:mm:ss"
                    />
                  </el-form-item>
                </el-col>
                <template v-if="!isCustomer">
                  <el-col :xs="24" :sm="12" :lg="6">
                    <el-form-item label="审核人" prop="confirmName">
                      <el-input v-model="screenForm.confirmName" placeholder="请输入审核人" />
                    </el-form-item>
                  </el-col>
                  <el-col :xs="24" :sm="12" :lg="6">
                    <el-form-item label="区域" prop="refRegionWork">
                      <el-input v-model="screenForm.refRegionWork" placeholder="请输入区域" />
                    </el-form-item>
                  </el-col>
                  <el-col :xs="24" :sm="12" :lg="6">
                    <el-form-item label="安装日期" style="margin-bottom: 0">
                      <div class="fanwei">
                        <el-form-item prop="startInstallTime">
                          <el-date-picker
                            v-model="screenForm.startInstallTime"
                            class="dateStyle"
                            type="datetime"
                            placeholder="选择日期"
                            value-format="yyyy-MM-dd HH:mm:ss"
                          />
                        </el-form-item>
                        <span>-</span>
                        <el-form-item prop="endInstallTime">
                          <el-date-picker
                            v-model="screenForm.endInstallTime"
                            class="dateStyle"
                            type="datetime"
                            placeholder="选择日期"
                            value-format="yyyy-MM-dd HH:mm:ss"
                          />
                        </el-form-item>
                      </div>
                    </el-form-item>
                  </el-col>
                  <el-col :xs="24" :sm="12" :lg="6">
                    <el-form-item label="规格型号" prop="specification">
                      <el-input v-model="screenForm.specification"></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :xs="24" :sm="12" :lg="6">
                    <el-form-item label="特价编号" prop="specialNo">
                      <el-input v-model="screenForm.specialNo"></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :xs="24" :sm="12" :lg="6">
                    <el-form-item label="跨区厂编号" prop="refFactoryNo">
                      <el-input v-model="screenForm.refFactoryNo"></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :xs="24" :sm="12" :lg="6">
                    <el-form-item label="格力内部备注" prop="geLiInerNote">
                      <el-input v-model="screenForm.geLiInerNote"></el-input>
                    </el-form-item>
                  </el-col>
                  <!-- <el-col :xs="24" :sm="12" :lg="6">
                    <el-form-item label="厂编号" prop="factoryNo">
                      <el-input v-model="screenForm.factoryNo"></el-input>
                    </el-form-item>

                  </el-col> -->
                  <el-col :xs="24" :sm="12" :lg="6">
                    <el-form-item label="厂编号" style="margin-bottom: 0">
                      <div class="fanwei">
                        <el-form-item prop="startFactoryNo">
                          <el-input v-model="screenForm.startFactoryNo" placeholder="厂编号开始"></el-input>
                        </el-form-item>
                        <span>-</span>
                        <el-form-item prop="endFactoryNo">
                          <el-input v-model="screenForm.endFactoryNo" placeholder="厂编号结束"></el-input>
                        </el-form-item>
                      </div>
                    </el-form-item>
                  </el-col>
                  <el-col :xs="24" :sm="12" :lg="6">
                    <el-form-item label="资料审核开始日期" prop="startAcceptTime">
                      <el-date-picker
                        v-model="screenForm.startAcceptTime"
                        class="dateStyle"
                        type="datetime"
                        value-format="yyyy-MM-dd HH:mm:ss"
                        placeholder="选择日期"
                      />
                    </el-form-item>
                  </el-col>
                  <el-col :xs="24" :sm="12" :lg="6">
                    <el-form-item label="资料审核结束日期" prop="endAcceptTime">
                      <el-date-picker
                        v-model="screenForm.endAcceptTime"
                        class="dateStyle"
                        type="datetime"
                        value-format="yyyy-MM-dd HH:mm:ss"
                        placeholder="选择日期"
                      />
                    </el-form-item>
                  </el-col>
                  <!-- <el-col :xs="24" :sm="12" :lg="6">
                    <el-form-item label="寄厂日期" style="margin-bottom: 0">
                      <div class="fanwei">
                        <el-form-item prop="startInstallTime">
                          <el-date-picker
                            v-model="screenForm.startInstallTime"
                            value-format="yyyy-MM-dd HH:mm:ss"
                            class="dateStyle"
                            type="datetime"
                            placeholder="选择日期"
                          />
                        </el-form-item>
                        <span>-</span>
                        <el-form-item prop="endInstallTime">
                          <el-date-picker
                            v-model="screenForm.endInstallTime"
                            value-format="yyyy-MM-dd HH:mm:ss"
                            class="dateStyle"
                            type="datetime"
                            placeholder="选择日期"
                          />
                        </el-form-item>
                      </div>
                    </el-form-item>
                  </el-col>
                  <el-col :xs="24" :sm="12" :lg="6">
                    <el-form-item label="结算日期" style="margin-bottom: 0">
                      <div class="fanwei">
                        <el-form-item prop="startSettlementDate">

                          <el-date-picker
                            v-model="screenForm.startSettlementDate"
                            value-format="yyyy-MM-dd HH:mm:ss"
                            class="dateStyle"
                            type="datetime"
                            placeholder="选择日期"
                          />
                        </el-form-item>
                        <span>-</span>
                        <el-form-item prop="endSettlementDate">

                          <el-date-picker
                            v-model="screenForm.endSettlementDate"
                            value-format="yyyy-MM-dd HH:mm:ss"
                            class="dateStyle"
                            type="datetime"
                            placeholder="选择日期"
                          />
                        </el-form-item>
                      </div>
                    </el-form-item>
                  </el-col> -->
                  <el-col :xs="24" :sm="12" :lg="6">
                    <el-form-item label="结算日期 " prop="settlementStatus">
                      <el-select style="width: 100%" v-model="screenForm.settlementStatus" clearable placeholder="请选择">
                        <el-option label="为空" :value="1"></el-option>
                        <el-option label="不为空" :value="0"></el-option>
                      </el-select>
                    </el-form-item>
                  </el-col>
                  <el-col :xs="24" :sm="12" :lg="6">
                    <el-form-item label="寄厂日期 " prop="mailFactoryStatus">
                      <el-select style="width: 100%" v-model="screenForm.mailFactoryStatus" clearable placeholder="请选择">
                        <el-option label="为空" :value="1"></el-option>
                        <el-option label="不为空" :value="0"></el-option>
                      </el-select>
                    </el-form-item>
                  </el-col>
                  <!-- <el-col :xs="24" :sm="12" :lg="6">
                    <el-form-item label="产品编码" >
                      <div class="fanwei">
                         <el-form-item prop="startMaterialOldNumber">
                            <el-input type="startMaterialOldNumber" ></el-input>
                         </el-form-item>

                      <span>-</span>
                        <el-form-item prop="endMaterialOldNumber">
                        <el-input type="endMaterialOldNumber" ></el-input>
                         </el-form-item>
                      </div>

                    </el-form-item>


                  </el-col> -->
                </template>
              </el-row>
            </el-form>
          </template>
        </Collapse>
      </div>
      <!-- 按钮 -->
      <div class="btn-group clearfix">
        <div class="fl">
          <!-- <el-radio-group @change="changeEnginOrderTypeFn" v-model="enginOrderType" size="mini">
            <el-radio-button label="HOME">家用工程</el-radio-button>
            <el-radio-button label="TRADE">商用工程</el-radio-button>
          </el-radio-group> -->
          <!-- <el-button type="primary" size="mini" @click="syncDateFn">同步资料日期</el-button> -->
        </div>
        <div class="fr">
          <el-button type="primary" size="mini" @click="exportFn">导出</el-button>
          <!--          <el-upload-->
          <!--            class="import-btn"-->
          <!--            action=""-->
          <!--            :http-request="handleImport"-->
          <!--            :file-list="importFileList"-->
          <!--            :show-file-list="false"-->
          <!--          >-->
          <!--            <el-button type="primary" size="mini">导入</el-button>-->
          <!--          </el-upload>-->
        </div>
      </div>
      <!-- 列表 -->
      <div class="mymain-container">
        <div class="table">
          <el-table
            v-loading="listLoading"
            :data="dataList"
            element-loading-text="Loading"
            border
            fit
            highlight-current-row
            stripe
            @selection-change="handleSelectionChange"
            show-summary
            :summary-method="$getSummaries"
          >
            >
            <el-table-column type="selection" align="center" width="55"> </el-table-column>
            <el-table-column align="left" label="状态" prop="" min-width="60" show-overflow-tooltip>
              <template v-slot="{ row }">
                <el-tag size="mini" v-show="row.examineStatus == 'SAVE'">保存</el-tag>
                <el-tag size="mini" v-show="row.examineStatus == 'WAIT'" type="warning">待审核</el-tag>
                <el-tag size="mini" v-show="row.examineStatus == 'OK'" type="success">通过</el-tag>
                <el-tag size="mini" v-show="row.examineStatus == 'FAIL'" type="danger">不通过</el-tag>
              </template>
            </el-table-column>
            <el-table-column align="right" label="数量" prop="hasSendQty" min-width="60" show-overflow-tooltip />
            <el-table-column align="right" label="金额" prop="hasSendQty" min-width="100" show-overflow-tooltip />
            <el-table-column
              align="left"
              label="工程登录编号"
              prop="refEnginRecordNo"
              min-width="160"
              show-overflow-tooltip
            >
              <template slot-scope="scope">
                <CopyButton :copyText="scope.row.refEnginRecordNo" />
                <span>{{ scope.row.refEnginRecordNo }}</span>
              </template>
            </el-table-column>
            <el-table-column align="left" label="申请日期" prop="submitTime" min-width="160" show-overflow-tooltip>
              <template slot-scope="scope">
                <span>{{ scope.row.submitTime }}</span>
              </template>
            </el-table-column>
            <el-table-column align="left" label="受理日期" prop="checkDate" min-width="160" show-overflow-tooltip>
              <template slot-scope="scope">
                <span>{{ scope.row.checkDate }}</span>
              </template>
            </el-table-column>
            <el-table-column
              align="left"
              label="经销商编码"
              prop="customerNumber"
              min-width="100"
              show-overflow-tooltip
            >
              <template slot-scope="scope">
                <CopyButton :copyText="scope.row.customerNumber" />
                <span>{{ scope.row.customerNumber }}</span>
              </template>
            </el-table-column>
            <el-table-column align="left" label="经销商名称" prop="customerName" min-width="260" show-overflow-tooltip>
              <template slot-scope="scope">
                <CopyButton :copyText="scope.row.customerName" />
                <span>{{ scope.row.customerName }}</span>
              </template>
            </el-table-column>
            <el-table-column align="left" label="跨厂区标号" prop="refFactoryNo" min-width="100" show-overflow-tooltip>
              <template slot-scope="scope">
                <CopyButton :copyText="scope.row.refFactoryNo" />
                <span>{{ scope.row.refFactoryNo }}</span>
              </template>
            </el-table-column>
            <el-table-column align="right" label="厂编号" prop="factoryNo" min-width="120" show-overflow-tooltip>
            </el-table-column>
            <el-table-column align="right" label="特价编号" prop="specialNo" min-width="120" show-overflow-tooltip>
            </el-table-column>
            <el-table-column
              align="left"
              label="行业类别"
              prop="refTradeCategory"
              min-width="160"
              show-overflow-tooltip
            >
              <template slot-scope="scope">
                <CopyButton :copyText="scope.row.refTradeCategory" />
                <span>{{ scope.row.refTradeCategory }}</span>
              </template>
            </el-table-column>
            <el-table-column
              align="left"
              label="使用单位
"
              prop="refUseUnit"
              min-width="250"
              show-overflow-tooltip
            >
              <template slot-scope="scope">
                <CopyButton :copyText="scope.row.refUseUnit" />
                <span>{{ scope.row.refUseUnit }}</span>
              </template>
            </el-table-column>

            <el-table-column align="left" label="区域" prop="refRegionWork" min-width="250" show-overflow-tooltip>
              <template slot-scope="scope">
                <CopyButton :copyText="scope.row.refRegionWork" />
                <span>{{ scope.row.refRegionWork }}</span>
              </template>
            </el-table-column>
            <el-table-column
              v-if="!isCustomer"
              align="left"
              label="格力内部备注"
              prop="geLiInerNote"
              min-width="160"
              show-overflow-tooltip
            >
              <template slot-scope="scope">
                <span>{{ scope.row.geLiInerNote }}</span>
              </template>
            </el-table-column>
            <el-table-column align="left" label="物料编码" prop="materialNumber" min-width="120" show-overflow-tooltip>
              <template slot-scope="scope">
                <CopyButton :copyText="scope.row.materialNumber" />
                <span>{{ scope.row.materialNumber }}</span>
              </template>
            </el-table-column>
            <el-table-column
              align="left"
              label="产品编码"
              prop="materialOldNumber"
              min-width="150"
              show-overflow-tooltip
            >
              <template slot-scope="scope">
                <CopyButton :copyText="scope.row.materialOldNumber" />
                <span>{{ scope.row.materialOldNumber }}</span>
              </template>
            </el-table-column>

            <el-table-column align="left" label="产品名称" prop="materialName" min-width="180" show-overflow-tooltip>
              <template slot-scope="scope">
                <CopyButton :copyText="scope.row.materialName" />
                <span>{{ scope.row.materialName }}</span>
              </template>
            </el-table-column>
            <el-table-column align="left" label="规格型号" prop="specification" min-width="350" show-overflow-tooltip>
              <template slot-scope="scope">
                <CopyButton :copyText="scope.row.specification" />
                <span>{{ scope.row.specification }}</span>
              </template>
            </el-table-column>
            <el-table-column
              align="right"
              label="押金金额"
              prop="itemDepositAmount"
              min-width="100"
              show-overflow-tooltip
            >
              <template slot-scope="scope">
                {{ scope.row.itemDepositAmount | numToFixed }}
              </template>
            </el-table-column>
            <!-- <el-table-column align="right" label="规格型号" prop="specification" min-width="160" show-overflow-tooltip>
            </el-table-column> -->
            <el-table-column align="right" label="安装日期" prop="installDate" min-width="160" show-overflow-tooltip>
            </el-table-column>
            <el-table-column align="left" label="审核人" prop="confirmName" min-width="100" show-overflow-tooltip>
              <template slot-scope="scope">
                <CopyButton :copyText="scope.row.confirmName" />
                <span>{{ scope.row.confirmName }}</span>
              </template>
            </el-table-column>
            <el-table-column
              align="left"
              label="资料审核日期"
              prop="refDatumAcceptDate"
              min-width="160"
              show-overflow-tooltip
            />
            <el-table-column align="right" label="金额" prop="totalPrice" min-width="100" show-overflow-tooltip>
              <template slot-scope="scope">
                {{ scope.row.totalPrice | numToFixed }}
              </template>
            </el-table-column>
            <el-table-column align="right" label="订单数量" prop="itemQty" min-width="80" show-overflow-tooltip />
            <!-- <el-table-column align="right" label="合同单价" prop="contractPrice" min-width="160" show-overflow-tooltip >
                <template slot-scope="scope">
                  {{ scope.row.contractPrice | numToFixed}}
                </template>
              </el-table-column> -->

            <el-table-column align="right" label="发货数量" prop="hasSendQty" min-width="80" show-overflow-tooltip />
            <!-- <el-table-column align="right" label="押金金额" prop="depositAmount" min-width="160" show-overflow-tooltip>
              <template slot-scope="scope">
                {{ scope.row.depositAmount | numToFixed}}
              </template>
            </el-table-column> -->
            <!--            <el-table-column align="right" label="上交资料" prop="itemDataQty" min-width="160" show-overflow-tooltip />-->
            <el-table-column fixed="right" align="center" label="操作" min-width="160" show-overflow-tooltip>
              <template slot-scope="scope">
                <el-button
                  type="text"
                  class="textColor"
                  v-if="scope.row.examineStatus == 'WAIT' && $checkBtnRole('examine', $route.meta.roles)"
                  @click="examineFn(scope.row.depositManageId)"
                  >审批</el-button
                >
                <!-- <el-button type="text" class="textColor"
                  v-if="(scope.row.examineStatus == 'OK' ||scope.row.examineStatus == 'AMEND') && $checkBtnRole('examine', $route.meta.roles)"
                  @click="replenishClick(scope.row.depositManageId)">补充资料</el-button>
                  <el-button type="text" class="textColor"
                  v-if="scope.row.examineStatus == 'WAIT_REVIEW' && $checkBtnRole('examine', $route.meta.roles)"
                  @click="reexamineClick(scope.row.depositManageId)">复核</el-button> -->

                <el-button
                  type="text"
                  class="textColor"
                  v-if="
                    scope.row.examineStatus == 'SAVE' ||
                    scope.row.examineStatus == 'OK' ||
                    scope.row.examineStatus == 'FAIL'
                  "
                  @click="infoFn(scope.row.depositManageId)"
                  >详情</el-button
                >
              </template>
            </el-table-column>
          </el-table>
        </div>
        <!-- 分页 -->
        <div class="fr">
          <el-pagination
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :current-page="currentPage"
            :page-sizes="[10, 20, 30, 50]"
            :page-size="pageSize"
            layout="total, sizes, prev, pager, next, jumper"
            :total="listTotal"
          >
          </el-pagination>
        </div>
      </div>
    </div>
    <RefundListDetail v-else-if="(showSurrender==1)" @updateList="updateList" :detailId="detailId"  />
    <!-- <refund-replenish v-else-if="(showSurrender==2)" :detail-id="detailId" @updateList="updateList"/>
    <refund-reexamine v-else-if="(showSurrender==3)" :detail-id="detailId" @updateList="updateList"/> -->
  </div>
</template>

<script>
import { getDepositManageList, getDepositManageDate, getDepositManagExport } from '@/api/engin_deposit/refund_list'
import { downloadFiles, handleImport } from '@/utils/util'
import RefundListDetail from './components/refund_list-detail.vue'
import refund_reexamine from './components/refund_reexamine.vue'
import refund_replenish from './components/refund_replenish.vue'
export default {
  components: {
    RefundListDetail,
    refund_reexamine,
    refund_replenish
  },
  data() {
    return {
      importFileList: [],
      enginOrderType: 'TRADE', //列表类型
      currentPage: 1, // 当前页码
      pageSize: 10, // 每页数量
      listTotal: 0, // 列表总数
      dataList: [], // 列表数据
      screenForm: {
        confirmName: '', // 审核人
        createName: '', // 创建人
        customerKeyword: '', // 客户编码/客户名称
        endDeliverTime: '', // 发货申请日期-结束
        enginOrderNo: '', // 工程订单编号
        enginOrderType: 'TRADE', // 工程订单类型
        examineStatus: '', // 状态
        refEnginRecordNo: '', // 登录单号
        refProjectName: '', // 项目名称
        refUseUnit: '', // 使用单位
        startDeliverTime: '', // 发货申请日期-开始
        startSubmitTime: '',
        startConfirmTime: '',
        isRefundDeposit: null,
        startInstallTime: '',
        endConfirmTime: '',
        endInstallTime: '',
        specification: '',
        refFactoryNo: '',
        factoryNo: '',
        mailFactoryStatus:''  ,
        settlementStatus:'',
        specialNo: '',
        refRegionWork: '',
        endSubmitTime: '',
        refTradeCategory: '',
        startAcceptTime: '',
        endAcceptTime: '',
        geLiInerNote: '',
        startFactoryNo: '',
        endFactoryNo: '',
        startInstallTime:'',endInstallTime:'',startSettlementDate:'',endSettlementDate:'',
        settlementStatus:'',mailFactoryStatus:''

      }, // 搜索表单
      refundDepositArr: [
        {
          label: '是',
          value: true
        },
        {
          label: '否',
          value: false
        }
      ],
      isCollapse: true,
      examineStatusArr: [
        {
          label: '保存',
          value: 'SAVE'
        },
        {
          label: '待审核',
          value: 'WAIT'
        },
        {
          label: '通过',
          value: 'OK'
        },
        {
          label: '不通过',
          value: 'FAIL'
        },
        {
          label: '关闭',
          value: 'CLOSE'
        }
      ],
      listLoading: false, // 列表加载loading
      examine: '',
      showSurrender: 0,
      detailId: '',
      selectData: []
    }
  },
  created() {
    this.getDataList({
      pageSize: this.pageSize,
      pageNum: this.currentPage,
      enginOrderType: this.enginOrderType,
      ...this.screenForm
      // startDeliverTime: "",
    })
  },
  computed: {
    isCustomer() {
      return this.$store.getters.customerId && this.$store.getters.customerNumber
    }
  },
  methods: {
    replenishClick(id){
      this.detailId = id
      this.showSurrender = 2
    },
    reexamineClick(id){
      this.detailId = id
      this.showSurrender = 3
    },
    //同步资料日期
    async syncDateFn() {
      await getDepositManageDate()
      this.$message.success('同步资料日期成功')
    },
    // 导入
    async handleImport(param) {
      const file = param.file

      const formData = new FormData()
      formData.append('file', file)

      let result = await handleImport('deposit-manage/import', formData)

      console.log(result)
      this.importFileList = []
      if (result.code == 200) {
        this.$message.success('导入成功')
        this.getDataList({
          pageSize: this.pageSize,
          pageNum: this.currentPage,
          confirmName: '',
          createName: '',
          customerKeyword: '',
          // endDeliverTime: "",
          enginOrderNo: '',
          enginOrderType: this.enginOrderType,
          examineStatus: '',
          refEnginRecordNo: '',
          refProjectName: '',
          refUseUnit: '',
          ...this.screenForm
          // startDeliverTime: "",
        })
      } else {
        this.$message.error(result.message)
      }
    },
    //审批后更新列表数据
    updateList() {
      this.getDataList({
        pageSize: this.pageSize,
        pageNum: this.currentPage,
        confirmName: '',
        createName: '',
        customerKeyword: '',
        // endDeliverTime: "",
        enginOrderNo: '',
        enginOrderType: this.enginOrderType,
        examineStatus: '',
        refEnginRecordNo: '',
        refProjectName: '',
        refUseUnit: '',
        ...this.screenForm
        // startDeliverTime: "",
      })
    },
    //切换列表
    changeEnginOrderTypeFn(v) {
      // console.log(v);
      this.pageSize = 10
      this.currentPage = 1

      this.getDataList({
        pageSize: this.pageSize,
        pageNum: this.currentPage,
        confirmName: '',
        createName: '',
        customerKeyword: '',
        // endDeliverTime: "",
        enginOrderNo: '',
        enginOrderType: v,
        examineStatus: this.examine,
        refEnginRecordNo: '',
        refProjectName: '',
        refUseUnit: '',
        ...this.screenForm
        // startDeliverTime: "",
      })
    },
    // 更改每页数量
    handleSizeChange(val) {
      this.pageSize = val
      this.currentPage = 1
      this.getDataList({
        pageSize: this.pageSize,
        pageNum: this.currentPage,
        confirmName: '',
        createName: '',
        customerKeyword: '',
        // endDeliverTime: "",
        enginOrderNo: '',
        enginOrderType: this.enginOrderType,
        examineStatus: this.examine,
        refEnginRecordNo: '',
        refProjectName: '',
        refUseUnit: '',
        ...this.screenForm
        // startDeliverTime: "",
      })
    },
    // 更改当前页
    handleCurrentChange(val) {
      this.currentPage = val
      this.getDataList({
        pageSize: this.pageSize,
        pageNum: this.currentPage,
        confirmName: '',
        createName: '',
        customerKeyword: '',
        // endDeliverTime: "",
        enginOrderNo: '',
        enginOrderType: this.enginOrderType,
        examineStatus: this.examine,
        refEnginRecordNo: '',
        refProjectName: '',
        refUseUnit: '',
        ...this.screenForm
        // startDeliverTime: "",
      })
    },
    //切换radio
    changeRadioFn(v) {
      this.examine = v
      this.getDataList({
        pageSize: this.pageSize,
        pageNum: 1,
        enginOrderType: this.enginOrderType,
        ...this.screenForm,
        examineStatus: this.examine
        // startDeliverTime: "",
      })
    },
    //导出
    exportFn() {
      let params = {
        ...this.screenForm,
        orderType: 'HOME',
        examine: this.examine
      }
      downloadFiles('deposit-manage/export', params)
    },
    //多选列表数据
    handleSelectionChange(selectData) {
      this.selectData = selectData
    },
    //重置
    resetFn() {
      this.screenForm.startInstallTime = ''
      this.screenForm.endInstallTime = ''
        this.$refs.screenForm.resetFields()
      // this.screenForm.endSpecification = "";
      // this.screenForm.endSpecialNo = "";
      // this.screenForm.endRefFactoryNo = "";
      this.getDataList({
        pageSize: this.pageSize,
        pageNum: 1,
        confirmName: '',
        createName: '',
        enginOrderNo: '',
        enginOrderType: this.enginOrderType,
        examineStatus: this.examine,
        refUseUnit: '',
        ...this.screenForm
      })
    },
    //搜索
    searchFn() {
      this.getDataList({
        pageSize: this.pageSize,
        pageNum: 1,
        confirmName: '',
        createName: '',
        enginOrderNo: '',
        enginOrderType: this.enginOrderType,
        examineStatus: this.examine,
        refUseUnit: '',
        ...this.screenForm
      })
    },
    //详情
    infoFn(id) {
      this.detailId = id
      this.showSurrender = 1
    },
    async getDataList(data) {
      const res = await getDepositManageList(data)
      res.data.records.forEach(item => {
        item.totalPrice = item.itemPrice * item.itemQty
        item.sums1 = ['hasSendQty', 'itemDataQty', 'itemQty', 'hasSendQty']
        item.sums2 = [
          'itemDepositAmount',
          'diffAmount',
          'price',
          'totalAmount',
          'depositAmount',
          'totalPrice',
          'contractPrice'
        ]
      })
      this.dataList = res.data.records
      this.listTotal = res.data.total
    },
    examineFn(id) {
      this.detailId = id
      this.showSurrender = 1
    }
  }
}
</script>

<style lang="scss" scoped>
.dateStyle {
  width: 100%;
}
.import-btn {
  margin-left: 10px;
  display: inline-block;
}
.fanwei {
  display: flex;
  span {
    margin: 0 20px;
    line-height: 28px;
  }
}
</style>
