<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="90px">
      <el-row>
        <el-form-item label="箱号" prop="fNo">
          <el-input style="width: 200px" v-model="queryParams.fNo" placeholder="请输入箱号" clearable size="small">

          </el-input>
        </el-form-item>

        <el-form-item label="箱类型" prop="fTypeid">
          <el-select
            v-model="queryParams.fTypeid"
            style="width: 200px"
            placeholder="请输入名称"
            clearable
            size="small"
            filterable
            :remote-method="boxTypeMethod"
          >
            <el-option
              v-for="item in typeOptions"
              :key="item.fId"
              :label="item.fNo"
              :value="item.fId"
            />
          </el-select>
        </el-form-item>

        <el-form-item label="箱状态" prop="fCntrstatus">
          <el-select
            v-model="queryParams.fCntrstatus"
            style="width: 200px"
            placeholder="请输入或选择"
            clearable
            size="small"
            @keyup.enter.native="handleQuery"
          >
            <el-option
              v-for="dict in cntrstatusOptions"
              :key="dict.dictValue"
              :label="dict.dictLabel"
              :value="dict.dictValue"
            />
          </el-select>
        </el-form-item>

        <el-form-item label="租贷公司" prop="fOwner">
          <el-select
            v-model="queryParams.fOwner"
            style="width: 200px"
            placeholder="请输入或选择"
            clearable
            size="small"
            @keyup.enter.native="handleQuery"
          >
            <el-option
              v-for="dict in ownerOptions"
              :key="dict.dictValue"
              :label="dict.dictLabel"
              :value="dict.dictValue"
            />
          </el-select>
        </el-form-item>
      </el-row>
      <div v-show="queryParamsHidden">
        <el-row>

          <el-form-item label="录入人" prop="createBy">
            <el-input
              v-model="queryParams.createBy"
              style="width: 200px"
              placeholder="请输入电话"
              clearable
              size="small"
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>

          <el-form-item label="备注" prop="remark">
            <el-input
              style="width: 200px"
              type="textarea"
              clearable
              size="small"
              v-model="queryParams.remark"
            />
          </el-form-item>

          <el-form-item label="录入区间" prop="cLoadDate">
            <el-date-picker
              v-model="queryParams.cLoadDate"
              type="daterange"
              value-format="yyyy-MM-dd"
              range-separator="至"
              @change="timeMethods"
              start-placeholder="开始日期"
              end-placeholder="结束日期"
              style="width: 250px"
            >
            </el-date-picker>
          </el-form-item>
        </el-row>
        <el-row>
          <el-col :span="6">
            <el-form-item label="合同协议号" prop="fPactDealHorn">
              <el-input v-model="queryParams.fPactDealHorn" clearable size="small" placeholder="请输入合同协议号"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="启租日期" prop="onHireStartList">
              <el-date-picker
                v-model="queryParams.onHireStartList"
                type="daterange"
                value-format="yyyy-MM-dd"
                range-separator="至"
                unlink-panels
                start-placeholder="开始日期"
                end-placeholder="结束日期"
                style="width: 250px"
              >
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="退租日期" prop="onHireEnfList">
              <el-date-picker
                v-model="queryParams.onHireEnfList"
                type="daterange"
                value-format="yyyy-MM-dd"
                range-separator="至"
                unlink-panels
                start-placeholder="开始日期"
                end-placeholder="结束日期"
                style="width: 250px"
              >
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="状态" prop="fStatus">
              <el-select
                v-model="queryParams.fStatus"
                style="width: 200px"
                placeholder="请选择状态"
                clearable
                size="small"
              >
                <el-option label="启用" value="T"></el-option>
                <el-option label="停用" value="F"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
      </div>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="success"
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['shipping:cntrno:add']"
        >新增
        </el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['shipping:cntrno:updateTCntrno']"
        >修改
        </el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['shipping:cntrno:remove']"
        >删除
        </el-button>
      </el-col>
      <el-col :span="1.5">
        <!--        <el-button-->
        <!--          type="primary"-->
        <!--          icon="el-icon-download"-->
        <!--          size="mini"-->
        <!--          @click="handleExport"-->
        <!--        >导入</el-button>-->
        <el-button
          size="mini"
          icon="el-icon-download"
          type="primary"
          @click="dialogVisible = true"
        >导入
        </el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="primary"
          icon="el-icon-download"
          size="mini"
          @click="downLoad"
        >下载模板
        </el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="primary"
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
        >导出
        </el-button>
      </el-col>
<!--      <el-col :span="1.5">-->
<!--        <el-button-->
<!--          type="info"-->
<!--          icon="el-icon-download"-->
<!--          size="mini"-->
<!--          @click="handleExport"-->
<!--        >取消-->
<!--        </el-button>-->
<!--      </el-col>-->

<!--      <el-col :span="1.5">-->
<!--        <el-upload-->
<!--            :action="uploadUrl"-->
<!--            :auto-upload="true"-->
<!--            accept=".xls,.xlsx"-->
<!--            :on-success="(res, file) => { importBoxDynamics( res, file); }"-->
<!--            :headers="headers"-->
<!--            :show-file-list="false"-->
<!--        >-->
<!--          <el-button size="mini" type="primary" icon="el-icon-plus">导入箱动态</el-button>-->
<!--        </el-upload>-->
<!--      </el-col>-->
<!--      <el-col :span="1.5">-->
<!--        <el-button size="mini" type="primary" icon="el-icon-download" @click="downloadBoxTemplate">下载箱动态模板</el-button>-->
<!--      </el-col>-->
      <el-col :span="1.5">
        <el-button size="mini" type="primary" :disabled="multiple" @click="handleIsEnabel(1)" icon="el-icon-video-pause">启用</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button size="mini" type="primary" :disabled="multiple" @click="handleIsEnabel(0)" icon="el-icon-video-play">退租</el-button>
      </el-col>
      <el-col style="position: absolute;left:70%" :span="5">
        <el-button size="small" @click="queryParamsHidden ? (queryParamsHidden = false) : (queryParamsHidden = true)">
          {{ queryParamsHidden ? '隐藏' : '更多' }}
        </el-button>
        <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-col>
      <div class="tabSetting">
        <right-toolbar
          :showSearch.sync="showSearch"
          @queryTable="getList"
        ></right-toolbar>
        <div style="margin: 0 12px">
          <el-button
            icon="el-icon-setting"
            size="mini"
            circle
            @click="showSetting = !showSetting"
          ></el-button>
        </div>
      </div>
    </el-row>
    <el-dialog title="提示" :visible.sync="showSetting" width="700px" v-dialogDrag>
      <template slot="title">
        <div class="avue-crud__dialog__header">
            <span class="el-dialog__title">
            <span style="display:inline-block;width:3px;height:20px;margin-right:5px; float: left;margin-top:2px"
            ></span>
            </span>
        </div>
      </template>
      <div>配置排序列数据（拖动调整顺序）</div>
      <div style="margin-left: 17px">
        <el-checkbox
          v-model="allCheck"
          label="全选"
          @change="allChecked"
        ></el-checkbox>
      </div>
      <div style="padding: 4px; display: flex; justify-content: center">
        <draggable
          v-model="setRowList"
          group="site"
          animation="300"
          @start="onStart"
          @end="onEnd"
          handle=".indraggable"
        >
          <transition-group>
            <div
              v-for="item in setRowList"
              :key="item.surface"
              class="listStyle"
            >
              <div style="width: 500px" class="indraggable">
                <div class="progress" :style="{ width: item.width + 'px' }">
                  <el-checkbox
                    :label="item.name"
                    v-model="item.checked"
                    :true-label="0"
                    :false-label="1"
                  >{{ item.name }}
                  </el-checkbox>
                </div>
              </div>
              <el-input-number
                v-model.number="item.width"
                controls-position="right"
                :min="1"
                :max="500"
                size="mini"
              ></el-input-number>
            </div>
          </transition-group>
        </draggable>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button @click="showSetting = false">取 消</el-button>
        <el-button @click="delRow" type="danger">重 置</el-button>
        <el-button type="primary" @click="save()">确 定</el-button>
      </span>
    </el-dialog>

    <el-table v-loading="loading" :data="corpsList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" align="center"/>
      <el-table-column type="index" label="行号" align="center" fixed="left"/>
      <el-table-column
        v-for="(item, index) in getRowList"
        :key="index"
        :label="item.name"
        :width="item.width"
        :prop="item.label"
        align="center"
        :fixed="item.fixed"
        :show-overflow-tooltip="true"
        sortable
      >
        <template slot-scope="scope">
          <span v-if="item.label == 'createTime'">{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span>
          <span v-else-if="item.label == 'updateTime'">{{ parseTime(scope.row.updateTime, '{y}-{m}-{d}') }}</span>
          <span v-else>{{scope.row[item.label]}}</span>
        </template>
      </el-table-column>
      <!--      <el-table-column label="箱号" sortable fixed align="center" prop="fNo" fixed width="120px"/>-->
      <!--      <el-table-column label="箱类型" align="center" sortable  prop="typeidName" fixed width="100px"/>-->
      <!--      <el-table-column label="地点" align="center"  sortable  prop="addressName" fixed/>-->
      <!--      <el-table-column :show-overflow-tooltip="true" label="箱主" align="center" prop="ownerName" />-->
      <!--      <el-table-column :show-overflow-tooltip="true" label="箱来源" align="center"  prop="sourceName" />-->
      <!--      <el-table-column label="箱状态" align="center" sortable  prop="cntrstatusName" fixed width="100px"/>-->
      <!--      <el-table-column :show-overflow-tooltip="true" label="租赁方式" align="center" prop="rentName" />-->
      <!--      <el-table-column label="空重" align="center" sortable  prop="updateEFName" fixed/>-->
      <!--      <el-table-column :show-overflow-tooltip="true" label="备注" align="center" prop="remark" />-->
      <!--      <el-table-column label="录入人" align="center" prop="createBy" />-->
      <!--      <el-table-column label="录入时间" align="center" prop="createTime" width="100px">-->
      <!--        <template slot-scope="scope">-->
      <!--          <span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span>-->
      <!--        </template>-->
      <!--      </el-table-column>-->
      <!--      <el-table-column label="最新修改人" align="center" prop="updateBy" width="100px"/>-->
      <!--      <el-table-column label="最新修改时间" align="center" prop="updateTime" width="120px">-->
      <!--        <template slot-scope="scope">-->
      <!--          <span>{{ parseTime(scope.row.updateTime, '{y}-{m}-{d}') }}</span>-->
      <!--        </template>-->
      <!--      </el-table-column>-->
      <el-table-column label="操作" align="center" min-width="120px" fixed="right">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            v-hasPermi="['shipping:cntrno:updateTCntrno']"
            @click="handleUpdate(scope.row)"
          >查看
          </el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            v-hasPermi="['shipping:cntrno:remove']"
            @click="handleDelete(scope.row)"
          >移除
          </el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改客户详情对话框 -->
    <el-dialog
      v-dialogDrag
      :fullscreen="dialogFull"
      :title="title"
      :visible.sync="open"
      width="60%"
      :close-on-click-modal="false"
      append-to-body
    >
      <template slot="title">
        <div class="avue-crud__dialog__header">
            <span class="el-dialog__title">
            <span style="display:inline-block;width:3px;height:20px;margin-right:5px; float: left;margin-top:2px"
            ></span>
            </span>
          <div class="avue-crud__dialog__menu enlarge" @click="full">
            <i
              style="cursor: pointer;display: block;width:12px;height:12px;border:1px solid #909399;border-top:3px solid #909399;margin-top: -3px;"
            ></i>
          </div>
        </div>
      </template>

      <el-form ref="form" :model="form" :rules="rules" label-width="100px">
        <el-row>
          <el-col :span="12">
            <el-form-item label="箱号" prop="fNo">
              <el-input v-model="form.fNo" style="width: 80%" placeholder="请输入箱号" :disabled="doNot"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="箱类型" prop="fTypeid">
              <el-select
                style="width: 80%"
                v-model="form.fTypeid"
                placeholder="请选择箱类型"
                clearable
                :disabled="doNot"
                filterable
                :remote-method="boxTypeMethod"
              >
                <el-option
                  v-for="item in typeOptions"
                  :key="item.fId"
                  :label="item.fNo"
                  :value="item.fId"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="最新地点" prop="fUpdateaddress">
              <el-select
                v-model="form.fUpdateaddress"
                style="width: 80%"
                placeholder="请输入最新地点"
                :disabled="doNot"
                filterable
                :remote-method="addressMethod"
              >
                <el-option
                  v-for="item in this.addressOptions"
                  :key="item.fId"
                  :label="item.fName"
                  :value="item.fId"
                >
                  <span style="float: left; color: #8492a6; font-size: 13px">{{ item.typesName }}</span>
                  <span style="float: right;">{{ item.fName }}</span>
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="租贷公司" prop="fOwner">
              <el-select
                v-model="form.fOwner"
                style="width: 80%"
                :disabled="doNot"
                placeholder="请选择租贷公司"
              >
                <el-option
                  v-for="dict in ownerOptions"
                  :key="dict.dictValue"
                  :label="dict.dictLabel"
                  :value="dict.dictValue"
                />
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>

          <el-col :span="12">
            <el-form-item label="箱来源" prop="fSource">
              <el-select v-model="form.fSource" style="width: 80%" placeholder="请选择箱来源" :disabled="doNot">
                <el-option
                  v-for="dict in sourceOptions"
                  :key="dict.dictValue"
                  :label="dict.dictLabel"
                  :value="dict.dictValue"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="箱状态" prop="fCntrstatus">
              <el-select v-model="form.fCntrstatus" style="width: 80%" placeholder="请选择箱状态" :disabled="doNot">
                <el-option
                  v-for="dict in cntrstatusOptions"
                  :key="dict.dictValue"
                  :label="dict.dictLabel"
                  :value="dict.dictValue"
                />
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="租赁方式" prop="fRent">
              <el-select v-model="form.fRent" style="width: 80%" placeholder="请选择租赁方式" :disabled="doNot">
                <el-option
                  v-for="dict in fRentOptions"
                  :key="dict.dictValue"
                  :label="dict.dictLabel"
                  :value="dict.dictValue"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="空重" prop="fUpdateef">
              <el-select v-model="form.fUpdateef" style="width: 80%" placeholder="请选择空重" :disabled="doNot">
                <el-option
                  v-for="dict in updateEFOptions"
                  :key="dict.dictValue"
                  :label="dict.dictLabel"
                  :value="dict.dictValue"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="造箱时间" prop="fBuildBoxTime">
              <el-date-picker
                  style="width: 80%"
                  v-model="form.fBuildBoxTime"
                  type="date"
                  value-format="yyyy-MM-dd"
                  :disabled="doNot"
                  placeholder="选择日期">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="箱龄(年)" prop="fBoxTurtleYear">
              <el-date-picker
                  style="width: 80%"
                  v-model="form.fBoxTurtleYear"
                  type="year"
                  :disabled="doNot"
                  value-format="yyyy"
                  placeholder="选择年">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="箱龄(月)" prop="fBoxTurtleMonth">
              <span>
                <el-select v-model="form.fBoxTurtleMonth" slot="prepend" style="width: 80%;" placeholder="请选择" :disabled="doNot">
                <el-option
                    v-for="(item,index) in month"
                    :key="index"
                    :label="item.label"
                    :value="item.value"></el-option>
              </el-select>
              </span>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="合同协议号" prop="fPactDealHorn">
              <el-input v-model="form.fPactDealHorn" style="width: 80%" placeholder="请输入合同协议号" :disabled="doNot"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="箱公司" prop="fBoxLord">
              <el-input v-model="form.fBoxLord" style="width: 80%" placeholder="请输入箱公司" :disabled="doNot"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="启租日期" prop="onHireStart">
              <el-date-picker
                style="width: 80%"
                v-model="form.onHireStart"
                type="date"
                :disabled="doNot"
                value-format="yyyy-MM-dd"
                placeholder="选择日期">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="备注" prop="remark">
              <el-input
                v-model="form.remark"
                style="width: 91%"
                placeholder="请输入备注"
                :disabled="doNot"
                type="textarea"
                :autosize="{ minRows: 2}"
              />
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="info" round @click="doNot = false">修 改</el-button>
        <el-button type="success" round @click="submitForm" :disabled="doNot">保 存</el-button>
        <el-button @click="cancel" round>关 闭</el-button>
      </div>
    </el-dialog>
    <el-dialog
      title="提示"
      :visible.sync="dialogVisible"
      width="30%"
    >
      <span>是否已下载模板文件？</span>
      <span slot="footer" class="dialog-footer" style="display: flex;justify-content: flex-end">
        <el-button @click="downloadTemplate" style="margin-right: 10px">否</el-button>
        <el-upload
          class="upload-demo"
          :action="uploadImgUrl"
          :auto-upload="true"
          :on-success="(res, file) => { handleSucces( res, file); }"
          :headers="headers"
          :show-file-list="false"
        >
          <el-button @click="dialogVisible = false" type="primary">是</el-button>
        </el-upload>
      </span>
    </el-dialog>

    <el-dialog
      title="导入箱信息"
      :close-on-press-escape="false"
      :close-on-click-modal="false"
      :visible.sync="boxTable"
      width="75%"
    >
      <el-table
        :data="boxLeadIn"
        style="width: 100%"
      >
        <el-table-column prop="fNo" label="箱号" align="center">
          <template slot-scope="scope">
            <el-input v-model="scope.row.fNo" style="width: 80%" placeholder="请输入箱号"/>
          </template>
        </el-table-column>
        <el-table-column prop="fTypeid" label="箱类型" align="center">
          <template slot-scope="scope">
            <el-select
              style="width: 80%"
              v-model="scope.row.fTypeid"
              placeholder="请选择箱类型"
              clearable
              filterable
              :remote-method="boxTypeMethod"
            >
              <el-option
                v-for="item in typeOptions"
                :key="item.fId"
                :label="item.fNo"
                :value="item.fId"
              />
            </el-select>
          </template>
        </el-table-column>
        <el-table-column prop="fUpdateaddress" label="最新地点" align="center">
          <template slot-scope="scope">
            <el-select
              v-model="scope.row.fUpdateaddress"
              style="width: 80%"
              placeholder="请输入最新地点"
              filterable
              :remote-method="addressMethod"
            >
              <el-option
                v-for="item in addressOptions"
                :key="item.fId"
                :label="item.fName"
                :value="item.fId"
              >
                <span style="float: left; color: #8492a6; font-size: 13px">{{ item.typesName }}</span>
                <span style="float: right;">{{ item.fName }}</span>
              </el-option>
            </el-select>
          </template>
        </el-table-column>
        <el-table-column prop="fOwner" label="租贷公司" align="center">
          <template slot-scope="scope">
            <el-select
              v-model="scope.row.fOwner"
              style="width: 80%"
              placeholder="请选择租贷公司"
            >
              <el-option
                v-for="dict in ownerOptions"
                :key="dict.dictValue"
                :label="dict.dictLabel"
                :value="dict.dictValue"
              />
            </el-select>
          </template>
        </el-table-column>
<!--        <el-table-column prop="fSource" label="箱来源" align="center">-->
<!--          <template slot-scope="scope">-->
<!--            <el-select v-model="scope.row.fSource" style="width: 80%" placeholder="请选择箱来源">-->
<!--              <el-option-->
<!--                v-for="dict in sourceOptions"-->
<!--                :key="dict.dictValue"-->
<!--                :label="dict.dictLabel"-->
<!--                :value="dict.dictValue"-->
<!--              />-->
<!--            </el-select>-->
<!--          </template>-->
<!--        </el-table-column>-->
        <el-table-column prop="fCntrstatus" label="箱状态" align="center">
          <template slot-scope="scope">
            <el-select v-model="scope.row.fCntrstatus" style="width: 80%" placeholder="请选择箱状态">
              <el-option
                v-for="dict in cntrstatusOptions"
                :key="dict.dictValue"
                :label="dict.dictLabel"
                :value="dict.dictValue"
              />
            </el-select>
          </template>
        </el-table-column>
        <el-table-column prop="fUpdateef" label="空重" align="center">
          <template slot-scope="scope">
            <el-select v-model="scope.row.fUpdateef" style="width: 80%" placeholder="请选择空重">
              <el-option
                v-for="dict in updateEFOptions"
                :key="dict.dictValue"
                :label="dict.dictLabel"
                :value="dict.dictValue"
              />
            </el-select>
          </template>
        </el-table-column>
        <el-table-column label="操作" align="center">
          <template slot-scope="scope">
            <el-button
              size="mini"
              type="text"
              icon="el-icon-delete"
              @click="deleteRow(scope.$index, boxLeadIn)"
            >删除</el-button>
          </template>
        </el-table-column>
      </el-table>
      <span slot="footer" class="dialog-footer">
    <el-button @click="boxTable = false">取 消</el-button>
    <el-button type="primary" @click="boxSubmission">提 交</el-button>
  </span>
    </el-dialog>
    <el-dialog
        title="导入箱动态"
        :visible.sync="importDynamicsopen"
        :show-close="false"
        width="80%">
      <el-table
          :data="tableData"
          style="width: 100%">
          <el-table-column
              label="序号"
              type="index"
              width="50"
              fixed
              align="center"
            />
         <el-table-column
            prop="opctnstatusName"
            label="箱动态"
            :show-overflow-tooltip="true"
            align="center">
        </el-table-column>
        <el-table-column
            prop="fNo"
            align="center"
            :show-overflow-tooltip="true"
            label="箱号">
        </el-table-column>
        <el-table-column
          prop="updateEFName"
          align="center"
          :show-overflow-tooltip="true"
          label="空重">
        </el-table-column>
        <el-table-column
            prop="fUpdatetime"
            align="center"
            :show-overflow-tooltip="true"
            label="动态日期">
        </el-table-column>
        <el-table-column
            prop="fVsl"
            align="center"
            :show-overflow-tooltip="true"
            label="船名">
        </el-table-column>
        <el-table-column
            prop="fVoy"
            align="center"
            :show-overflow-tooltip="true"
            label="航次">
        </el-table-column>
        <el-table-column
            prop="fBoxWeight"
            align="center"
            :show-overflow-tooltip="true"
            label="重量">
        </el-table-column>
        <el-table-column
            prop="addressName"
            align="center"
            :show-overflow-tooltip="true"
            label="堆放地点">
        </el-table-column>
        <el-table-column
            prop="fMblno"
            align="center"
            :show-overflow-tooltip="true"
            label="提单号">
        </el-table-column>
        <el-table-column
            prop="fSealno"
            align="center"
            :show-overflow-tooltip="true"
            label="铅封号">
        </el-table-column>
        <el-table-column
            prop="cntrstatusName"
            align="center"
            :show-overflow-tooltip="true"
            label="是否箱损">
        </el-table-column>
        <el-table-column
            prop="remark"
            align="center"
            :show-overflow-tooltip="true"
            label="箱损描述">
        </el-table-column>
        <el-table-column
            prop="portName"
            align="center"
            :show-overflow-tooltip="true"
            label="地点类型">
        </el-table-column>
      </el-table>
      <span slot="footer" class="dialog-footer">
    <el-button @click="importDynamicsopen = false">取 消</el-button>
    <el-button type="primary" @click="confirmLeadingIn">确 定</el-button>
  </span>
    </el-dialog>
<!--    启用或退租弹窗-->
    <el-dialog
      :title="boxStateTitle"
      :visible.sync="boxStateOpen"
      width="60%"
      :close-on-click-modal="false"
      append-to-body
      :show-close="false"
      :close-on-press-escape="false"
    >
      <el-form
        ref="boxStateForm" :model="boxStateForm" :rules="boxStateRules" label-width="100px"
      >
        <el-row>
          <el-col :span="12" v-if="!isEnable">
            <el-form-item label="退租日期" prop="onHireEnd">
              <el-date-picker
                style="width: 80%"
                v-model="boxStateForm.onHireEnd"
                type="date"
                value-format="yyyy-MM-dd"
                placeholder="选择日期">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="12" v-if="isEnable">
            <el-form-item label="启租日期" prop="onHireStart">
              <el-date-picker
                style="width: 80%"
                v-model="boxStateForm.onHireStart"
                type="date"
                value-format="yyyy-MM-dd"
                placeholder="选择日期">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="箱动态" prop="fOpctnstatus">
              <el-select
                disabled
                v-model="boxStateForm.fOpctnstatus"
                style="width: 240px"
                placeholder="请输入状态"
                clearable
                size="small"
              >
                <el-option
                  v-for="item in this.boxActionOptions"
                  :key="item.dictValue"
                  :label="item.dictLabel"
                  :value="item.dictValue"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="地点" prop="fUpdateaddress">
              <el-select
                v-model="boxStateForm.fUpdateaddress"
                style="width: 80%"
                placeholder="请输入地点"
                filterable
                :remote-method="addressMethod"
                size="small"
                clearable
              >
                <el-option
                  v-for="item in this.addressOptions"
                  :key="item.fId"
                  :label="item.fName"
                  :value="item.fId"
                >
                  <span style="float: left; color: #8492a6; font-size: 13px">{{ item.typesName }}</span>
                  <span style="float: right;">{{ item.fName }}</span>
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12" v-if="!isEnable">
            <el-form-item label="提单号" prop="fMblno">
              <el-input v-model="boxStateForm.fMblno" placeholder="请输入提单号"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="备注" prop="remark">
              <el-input v-model="boxStateForm.remark" placeholder="备注"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="success" round @click="submitBoxForm" v-text="isEnable? '启 用': '退 租'"></el-button>
        <el-button @click="boxStateCancel" round>关 闭</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import {
  listCorps,
  getInforma,
  delCorps,
  addboxinformation,
  getType,
  getaddress,
  changeCorpsStatus,
  exportCorps,
  getImport,
  getDown,
  batch,
  downloadBox,
  leadingIn,
  updateHire
} from '@/api/kaihe/containerNews/boxInformation'
import draggable from 'vuedraggable'
import Vue from 'vue'
import Cookies from 'js-cookie'
import { addSet, resetModule, select } from '@/api/system/set'
import { getToken } from '@/utils/auth'

Vue.directive('dialogDrag', {
  bind(el, binding, vnode, oldVnode) {
    const dialogHeaderEl = el.querySelector('.el-dialog__header')
    const dragDom = el.querySelector('.el-dialog')
    const enlarge = el.querySelector('.enlarge')
    dialogHeaderEl.style.cursor = 'move'

    // 获取原有属性 ie dom元素.currentStyle 火狐谷歌 window.getComputedStyle(dom元素, null);
    const sty = dragDom.currentStyle || window.getComputedStyle(dragDom, null)
    if (enlarge) {
      enlarge.onclick = (e) => {
        dragDom.style.top = '0px'
        dragDom.style.left = '0px'
      }
    }
    dialogHeaderEl.onmousedown = (e) => {
      // 鼠标按下，计算当前元素距离可视区的距离
      const disX = e.clientX - dialogHeaderEl.offsetLeft
      const disY = e.clientY - dialogHeaderEl.offsetTop

      // 获取到的值带px 正则匹配替换
      let styL, styT

      // 注意在ie中 第一次获取到的值为组件自带50% 移动之后赋值为px
      if (sty.left.includes('%')) {
        styL = +document.body.clientWidth * (+sty.left.replace(/\%/g, '') / 100)
        styT = +document.body.clientHeight * (+sty.top.replace(/\%/g, '') / 100)
      } else {
        styL = +sty.left.replace(/\px/g, '')
        styT = +sty.top.replace(/\px/g, '')
      }

      document.onmousemove = function(e) {
        // 通过事件委托，计算移动的距离
        const l = e.clientX - disX
        const t = e.clientY - disY

        // 移动当前元素

        if ((t + styT) >= 0) {
          dragDom.style.top = `${t + styT}px`
        }
        dragDom.style.left = `${l + styL}px`
        // 将此时的位置传出去
        // binding.value({x:e.pageX,y:e.pageY})
      }

      document.onmouseup = function(e) {
        document.onmousemove = null
        document.onmouseup = null
      }
    }
  }
})

export default {
  name: 'boxInformation',
  components: {
    draggable
  },
  data() {
    return {
      boxLeadIn: [],
      importDynamicsopen:false,
      month:[
        {label:'一月',value:'1'},
        {label:'二月',value:'2'},
        {label:'三月',value:'3'},
        {label:'四月',value:'4'},
        {label:'五月',value:'5'},
        {label:'六月',value:'6'},
        {label:'七月',value:'7'},
        {label:'八月',value:'8'},
        {label:'九月',value:'9'},
        {label:'十月',value:'10'},
        {label:'十一月',value:'11'},
        {label:'十二月',value:'12'},
      ],
      dialogVisible: false,
      boxTable: false,
      headers: {
        Authorization: 'Bearer ' + getToken()
      },
      uploadImgUrl: process.env.VUE_APP_BASE_API + '/shipping/cntrno/importCreate', // 上传的图片服务器地址
      uploadUrl: process.env.VUE_APP_BASE_API + '/shipping/cntrno/importAirForceStation', // 导入箱动态服务器地址
      setRowList: [],
      getRowList: [],
      tableData: [],
      tableDate: [
        {
          surface: '1',
          label: 'fNo',
          name: '箱号',
          fixed: 'left',
          checked: 0,
          width: 120
        },
        {
          surface: '2',
          label: 'typeidName',
          name: '箱类型',
          fixed: 'left',
          checked: 0,
          width: 120
        },
        {
          surface: '3',
          label: 'addressName',
          name: '地点',
          fixed: 'left',
          checked: 0,
          width: 120
        },
        {
          surface: '4',
          label: 'ownerName',
          name: '租贷公司',
          fixed: 'left',
          checked: 0,
          width: 120
        },
        {
          surface: '5',
          label: 'sourceName',
          name: '箱来源',
          fixed: 'left',
          checked: 0,
          width: 120
        },
        {
          surface: '6',
          label: 'cntrstatusName',
          name: '箱状态',
          fixed: 'left',
          checked: 0,
          width: 120
        },
        {
          surface: '7',
          label: 'rentName',
          name: '租赁方式',
          checked: 0,
          width: 120
        },
        {
          surface: '8',
          label: 'updateEFName',
          name: '空重',
          checked: 0,
          width: 120
        },
        {
          surface: '9',
          label: 'remark',
          name: '备注',
          checked: 0,
          width: 120
        },
        {
          surface: '10',
          label: 'createBy',
          name: '录入人',
          checked: 0,
          width: 120
        },
        {
          surface: '11',
          label: 'createTime',
          name: '录入时间',
          checked: 0,
          width: 120
        },
        {
          surface: '12',
          label: 'updateBy',
          name: '最新修改人',
          checked: 0,
          width: 120
        },
        {
          surface: '13',
          label: 'updateTime',
          name: '最新修改时间',
          checked: 0,
          width: 120
        },{
          surface: '14',
          label: 'fBuildBoxTime',
          name: '造箱时间',
          checked: 0,
          width: 120
        },{
          surface: '15',
          label: 'fBoxTurtleYear',
          name: '箱龄(年)',
          checked: 0,
          width: 120
        },{
          surface: '16',
          label: 'fBoxTurtleMonth',
          name: '箱龄(月)',
          checked: 0,
          width: 120
        },{
          surface: '17',
          label: 'fPactDealHorn',
          name: '合同协议号',
          checked: 0,
          width: 120
        },{
          surface: '18',
          label: 'fBoxLord',
          name: '箱公司',
          checked: 0,
          width: 120
        },{
          surface: '19',
          label: 'onHireStart',
          name: '启租日期',
          checked: 0,
          width: 120
        },{
          surface: '20',
          label: 'onHireEnd',
          name: '退租日期',
          checked: 0,
          width: 120
        },{
          surface: '21',
          label: 'fStatusName',
          name: '状态',
          checked: 0,
          width: 120
        }
      ],
      //自定义列宽
      allCheck: false,
      showSetting: false,
      //默认显示第一行
      queryParamsHidden: false,
      //字典表箱种类
      containerOptions: [],
      //集装箱主字典表
      ownerOptions: [],
      //箱来源字典表
      sourceOptions: [],
      //租赁方式字典表
      fRentOptions: [],
      //空重字典表
      updateEFOptions: [],
      //箱状态字典表
      cntrstatusOptions: [],
      //模糊查询箱类型
      typeOptions: [],
      //查看置灰
      doNot: true,
      //模糊下拉查询地点
      addressOptions: [],
      //全屏放大
      dialogFull: false,
      contactList: [],
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 客户详情表格数据
      corpsList: [],
      // 弹出层标题
      title: '',
      // 状态数据字典
      statusOptions: [],
      // 是否显示弹出层
      open: false,
      // 客户类别字典
      fTypeidOptions: [],
      // 结算表票结、月结字典
      fStltypeidOptions: [],
      // 删除状态字典
      delFlagOptions: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        fNo: null,
        fTypeid: null,
        fCntrstatus: null,
        fOwner: null,
        createBy: null,
        cLoadDate: null,
        remark: null,
        fRentTime: null,
        fReturnTime: null,
        fRentState: null,
      },
      // 表单参数
      form: {
        fTypeid: null,
        fUpdateaddress: null,
        fOwner: null,
        fNo: null,
        fSource: null,
        fRent: null,
        fUpdateef: null,
        fCntrstatus: null,
        remark: null
      },
      // 表单校验
      rules: {
        fTypeid: [
          { required: true, message: '', trigger: 'blur' }
        ],
        fNo: [
          { required: true, message: '箱号不能为空', trigger: 'blur' }
        ],
        fUpdateaddress: [
          { required: true, message: '最新地点不能为空', trigger: 'blur' }
        ],
        fOwner: [
          { required: true, message: '租贷公司不能为空', trigger: 'blur' }
        ],
        fUpdateef: [
          { required: true, message: '空重不能为空', trigger: 'blur' }
        ],
        fBoxLord: [
          { required: true, message: '箱公司不能为空', trigger: 'blur' }
        ],
        fCntrstatus: [
          { required: true, message: '箱状态不能为空', trigger: 'blur' }
        ],
        fRentTime: [
          { required: true, message: '启用日期不能为空', trigger: 'blur' }
        ]
      },
      boxStateTitle: '',
      boxStateOpen: false,
      boxStateForm: {
        onHireEnd: null,
        onHireStart: null,
        fOpctnstatus: null,
        fUpdateaddress: null,
        remark: null,
        fMblno: null,
        fStatus: null,
        cntrnoList: [],
      },
      boxStateRules: {
        onHireEnd: [
          { required: true, message: ' ', trigger: 'blur' }
        ],
        onHireStart: [
          { required: true, message: ' ', trigger: 'blur' }
        ],
        fOpctnstatus: [
          { required: true, message: ' ', trigger: 'blur' }
        ],
        fUpdateaddress: [
          { required: true, message: ' ', trigger: 'blur' }
        ],
        fMblno: [
          { required: true, message: ' ', trigger: 'blur' }
        ],
      },
      // 是否启用 true启用 FALSE停用
      isEnable: true,
      //调箱动作字典表
      boxActionOptions: [],
      selection: []
    }
  },
  created() {
    this.setRowList = this.tableDate
    this.getRowList = this.tableDate
    this.getList()
    this.getDicts('f_type').then(response => {
      this.containerOptions = response.data
    })
    this.getDicts('f_owner').then(response => {
      this.ownerOptions = response.data
    })
    this.getDicts('f_source').then(response => {
      this.sourceOptions = response.data
    })
    this.getDicts('f_rent').then(response => {
      this.fRentOptions = response.data
    })
    this.getDicts('f_updateEF').then(response => {
      this.updateEFOptions = response.data
    })
    this.getDicts('f_cntrstatus').then(response => {
      this.cntrstatusOptions = response.data
    })
    this.getDicts('f_opctnstatus').then(response => {
      this.boxActionOptions = response.data
    })
    this.boxTypeMethod()
    this.addressMethod()
    this.getRow()
  },
  methods: {
    deleteRow(index, rows) {
      rows.splice(index, 1);
    },
    timeMethods() {
      this.queryParams.cLoadDate[0] = this.queryParams.cLoadDate[0] + ' 00:00:00'
      this.queryParams.cLoadDate[1] = this.queryParams.cLoadDate[1] + ' 23:59:59'

    },

    downloadTemplate() {
      this.dialogVisible = false
      this.$message({
        type: 'info',
        message: '请先下载模板文件'
      })
    },
    downLoad() {
      this.$confirm('是否下载模板文件?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
        .then(function() {
          return getDown()
        })
        .then((response) => {
          this.download(response.msg)
          this.$message({
            type: 'success',
            message: '操作成功!'
          })
        })
        .catch(() => {
          this.$message({
            type: 'error',
            message: '操作失败!'
          })
        })
    },
    //确认导入箱动态
    confirmLeadingIn(){
      leadingIn({tCntrno:this.tableData}).then(res=>{
        this.importDynamicsopen = false
        this.$message({
          type: 'success',
          message: '操作成功!'
        })
      })
    },
    importBoxDynamics(file, fileList){
      console.log(file)
      if (file.code === 200){
        this.importDynamicsopen = true
        this.tableData = file.data
      }else if (file.code === 500) {
        this.$message.error(file.msg);
      }
    },
    downloadBoxTemplate(){
      downloadBox().then(res=>{
        this.download(res.msg)
      })
    },
    //附件上传
    handleSucces(file, fileList) {
      console.log(fileList)
      console.log(file)
      if (file.code == 200) {
        this.boxTable = true
        this.boxLeadIn = file.data
        for (let item in this.boxLeadIn){
          if (this.boxLeadIn[item].fUpdateaddress){
            this.boxLeadIn[item].fUpdateaddress = Number(this.boxLeadIn[item].fUpdateaddress)
          }
        }
      } else {
        this.$message.error(file.msg)
      }
    },
    //箱信息提交
    boxSubmission() {
      for (let item in this.boxLeadIn) {
        let i = Number(item)+1
        if (!this.boxLeadIn[item].fNo) {
          return this.$message.error('第' + i + '行箱号不能为空')
        }
        if (!this.boxLeadIn[item].fTypeid) {
          return this.$message.error('第' + i + '行箱类型不能为空')
        }
        if (!this.boxLeadIn[item].fUpdateaddress) {
          return this.$message.error('第' + i + '行最新地点不能为空')
        }
        if (!this.boxLeadIn[item].fOwner) {
          return this.$message.error('第' + i + '行租贷公司不能为空')
        }
        // if (!this.boxLeadIn[item].fSource) {
        //   return this.$message.error('第' + i + '行箱来源不能为空')
        // }
        if (!this.boxLeadIn[item].fCntrstatus) {
          return this.$message.error('第' + i + '行箱状态不能为空')
        }
        if (!this.boxLeadIn[item].fUpdateef) {
          return this.$message.error('第' + i + '行空重不能为空')
        }
        for (let li in this.boxLeadIn){
          if (item != li){
            let i = Number(item)+1
            let e = Number(li)+1
            if (this.boxLeadIn[item].fNo == this.boxLeadIn[li].fNo){
              return this.$message.error('第' + i + '行和第' + e + '行箱号重复')
            }
          }
        }
      }
      this.boxTable = false
      let formDatae = new window.FormData()
      formDatae.append('tCntrno', JSON.stringify(this.boxLeadIn))
      batch(formDatae).then(res =>{
        console.log(res)
        if (res.code === 200){
          if(res.msg == '操作成功'){
            this.$message.success('提交成功');
          }else {
            this.$message.error(res.data);
          }
        }
      })
    },
    //重置列表
    delRow() {
      this.data = {
        tableName: '箱信息',
        userId: Cookies.get('userName')
      }
      resetModule(this.data).then((res) => {
        if (res.code == 200) {
          this.showSetting = false
          this.setRowList = this.tableDate
          console.log(this.setRowList)
          this.getRowList = this.tableDate
        }
      })
    },
    //列设置全选
    allChecked() {
      if (this.allCheck == true) {
        this.setRowList.map((e) => {
          return (e.checked = 0)
        })
      } else {
        this.setRowList.map((e) => {
          return (e.checked = 1)
        })
      }
    },
    //查询列数据
    getRow() {
      let that = this
      this.data = {
        tableName: '箱信息',
        userId: Cookies.get('userName')
      }
      select(this.data).then((res) => {
        if (res.data.length != 0) {
          this.getRowList = res.data.filter((e) => e.checked == 0)
          this.setRowList = res.data
          this.setRowList = this.setRowList.reduce((res, item) => {
            res.push({
              surface: item.surface,
              label: item.label,
              name: item.name,
              checked: item.checked,
              width: item.width,
              fixed: item.fixed
            })
            return res
          }, [])
        }
      })
      console.log(this.getRowList)
    },
    //保存列设置
    save() {
      this.showSetting = false
      this.data = {
        tableName: '箱信息',
        userId: Cookies.get('userName'),
        sysTableSetList: this.setRowList
      }
      addSet(this.data).then((res) => {
        this.getRowList = this.setRowList.filter((e) => e.checked == 0)
      })
    },
    //开始拖拽事件
    onStart() {
      this.drag = true
    },
    //拖拽结束事件
    onEnd() {
      this.drag = false
    },
    //模糊查询地点
    addressMethod() {
      let queryParams = { pageNum: 1 }
      getaddress(queryParams).then(response => {
        this.addressOptions = response.rows
      })
    },
    //模糊查询箱类型
    boxTypeMethod() {
      let queryParams = { pageNum: 1 }
      getType(queryParams).then(response => {
        this.typeOptions = response.rows
      })
    },
    full() {
      this.dialogFull = !this.dialogFull
    },
    /** 查询客户详情列表 */
    getList() {
      this.loading = true
      listCorps(this.queryParams).then(response => {
        this.corpsList = response.rows
        this.total = response.total
        this.loading = false
      })
    },
    // 客户类别字典翻译
    fTypeidFormat(row, column) {
      return this.selectDictLabel(this.fTypeidOptions, row.fTypeid)
    },
    // 结算表票结、月结字典翻译
    fStltypeidFormat(row, column) {
      return this.selectDictLabel(this.fStltypeidOptions, row.fStltypeid)
    },
    // 删除状态字典翻译
    delFlagFormat(row, column) {
      return this.selectDictLabel(this.delFlagOptions, row.delFlag)
    },
    // 取消按钮
    cancel() {
      this.open = false
      this.reset()
    },
    // 表单重置
    reset() {
      this.form = {
        fTypeid: null,
        fUpdateaddress: null,
        fOwner: null,
        fNo: null,
        fSource: null,
        fRent: null,
        fUpdateef: null,
        fCntrstatus: null,
        fRentTime: null,
        remark: null
      }
      this.resetForm('form')
    },
    // 从表重置
    contList() {
      this.contactList = []
    },
    // 状态修改
    handleStatusChange(row) {
      let text = row.fStatus === '0' ? '启用' : '停用'
      this.$confirm('确认要"' + text + '""' + row.fName + '"吗?', '警告', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(function() {
        return changeCorpsStatus(row.fId, row.fStatus)
      }).then(() => {
        this.msgSuccess(text + '成功')
      }).catch(function() {
        row.fStatus = row.fStatus === '0' ? '1' : '0'
      })
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1
      this.getList()
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.queryParams = {
        pageNum: 1,
        pageSize: 10,
      }
      this.resetForm('queryForm')
      this.handleQuery()
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.fId)
      this.single = selection.length !== 1
      this.multiple = !selection.length
      this.selection = selection
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.doNot = false
      this.reset()
      this.open = true
      this.title = '添加客户详情'
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.doNot = true
      this.reset()
      const fId = row.fId || this.ids

      getInforma(fId).then(response => {
        this.form = response.data
        this.form.fUpdateaddress = response.data.addressName
        this.open = true
        this.title = '修改客户详情'
      })
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs['form'].validate(valid => {
        if (valid) {
          if (this.form.fId != null) {
            addboxinformation(this.form).then(response => {
              this.msgSuccess('修改成功')
              this.open = false
              this.getList()
            })
          } else {
            addboxinformation(this.form).then(response => {
              this.msgSuccess('新增成功')
              this.open = false
              this.getList()
            })
          }
        }
      })
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const fIds = row.fId || this.ids
      this.$confirm('是否确认删除客户详情编号为"' + fIds + '"的数据项?', '警告', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(function() {
        return delCorps(fIds)
      }).then(() => {
        this.getList()
        this.msgSuccess('删除成功')
      })
    },
    /** 导出按钮操作 */
    handleExport() {
      const queryParams = this.queryParams
      this.$confirm('是否确认导出所有箱信息数据项?', '警告', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(function() {
        return exportCorps(queryParams)
      }).then(response => {
        this.download(response.msg)
      })
    },
    // 启用 退租按钮
    handleIsEnabel(state) {
      // 清除默认
      this.boxStateForm = {
        onHireEnd: null,
        onHireStart: null,
        fOpctnstatus: null,
        fUpdateaddress: null,
        remark: null,
        fMblno: null,
        fStatus: null,
        cntrnoList: []
      }
      this.selection.map(item => {
        this.boxStateForm.cntrnoList.push(item.fId)
      })
      // state = 0 退 1启
      if (state == 0) {
        for (let i = 0;i < this.selection.length; i++) {
          if (this.selection[i].fStatus == 'F') return this.$message.error('选中的第' + (i + 1) + '条数据箱状态已为停用')
        }
        this.boxStateTitle = '退租';
        this.isEnable = false;
        this.boxStateForm.fOpctnstatus = '0';
        this.boxStateOpen = true;
      } else {
        for (let i = 0;i < this.selection.length; i++) {
          if (this.selection[i].fStatus == 'T') return this.$message.error('选中的第' + (i + 1) + '条数据箱状态已为启用')
        }
        this.$nextTick(() => {
          this.boxStateTitle = '启用';
          this.isEnable = true;
          this.boxStateForm.fOpctnstatus = '4';
          this.boxStateOpen = true;
        })
      }
    },
    boxStateCancel() {
      this.boxStateOpen = false;
      this.$refs['boxStateForm'].resetFields();
    },
    submitBoxForm() {
      this.$refs['boxStateForm'].validate(valid => {
        if (valid) {
          // isEnable TRUE：启 FALSE：禁
          if (this.isEnable) {
            this.boxStateForm.fStatus = 'T'
          } else {
            this.boxStateForm.fStatus = 'F'
          }
          updateHire({...this.boxStateForm}).then(res => {
            console.log(res)
            this.getList()
          })
          this.boxStateOpen = false;
        }
      })
    },
  }
}
</script>
<style lang="scss" scoped>
.avue-crud__dialog__header {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-align: center;
  -ms-flex-align: center;
  align-items: center;
  -webkit-box-pack: justify;
  -ms-flex-pack: justify;
  justify-content: space-between;
}

.el-dialog__title {
  color: rgba(0, 0, 0, .85);
  font-weight: 500;
  word-wrap: break-word;
}

.avue-crud__dialog__menu {
  padding-right: 20px;
  float: left;
}

.avue-crud__dialog__menu i {
  color: #909399;
  font-size: 15px;
}

.el-icon-full-screen {
  cursor: pointer;
}

.el-icon-full-screen:before {
  content: "\e719";
}

.tabSetting {
  display: flex;
  justify-content: flex-end;
}

.listStyle {
  display: flex;
  border-top: 1px solid #dcdfe6;
  border-left: 1px solid #dcdfe6;
  border-right: 1px solid #dcdfe6;
}

.listStyle:last-child {
  border-bottom: 1px solid #dcdfe6;
}

.progress {
  display: flex;
  align-items: center;
  padding: 2px;
  background-color: rgba(0, 0, 0, 0.05);
  height: 100%;
}
</style>
