<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="100px">
      <el-form-item :label="$t('开票日期')" prop="kprq">
        <el-date-picker
          v-model="chooseDate"
          @change="handleQuery"
          type="daterange"
          style="width: 508px"
          align="right"
          unlink-panels
          :range-separator="$t('至')"
          :start-placeholder="$t('开始日期')"
          :end-placeholder="$t('结束日期')"
          value-format="yyyy-MM-dd"
          :picker-options="pickerOptions">
        </el-date-picker>
      </el-form-item>
      <el-form-item :label="$t('新票/续票')" prop="xpxp">
        <el-select v-model="queryParams.xpxp" :placeholder="$t('请选择') + $t('新票/续票')" clearable size="small"
                   @change="handleQuery">
          <el-option
            v-for="dict in xpxpOptions"
            :key="dict.dictValue"
            :label="dict.dictLabel"
            :value="dict.dictValue"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="票号" prop="allNo">
        <el-input
          v-model="queryParams.allNo"
          placeholder="请输入联系人"
          clearable
          size="small"
          @input="handleQuery"
        />
      </el-form-item>

      <el-form-item :label="$t('火票级别')" prop="hpjb">
        <el-select v-model="queryParams.hpjb" :placeholder="$t('请选择') + $t('火票级别')" clearable size="small"
                   @change="handleQuery">
          <el-option
            v-for="dict in hpjbOptions"
            :key="dict.dictValue"
            :label="dict.dictLabel"
            :value="dict.dictValue"
          />
        </el-select>
      </el-form-item>

      <el-form-item label="高处作业级别" prop="gczyjb">
        <el-select v-model="queryParams.gczyjb" :placeholder="$t('请选择') + $t('高处作业级别')" clearable size="small"
                   @change="handleQuery">
          <el-option
            v-for="dict in gczyjbOptions"
            :key="dict.dictValue"
            :label="dict.dictLabel"
            :value="dict.dictValue"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="工作内容" prop="content">
        <el-input
          v-model="queryParams.content"
          placeholder="请输入工作内容"
          clearable
          size="small" @input="handleQuery"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="BYC负责单位/联系人" label-width="150"  prop="byclxr">
        <el-input
          v-model="queryParams.byclxr"
          placeholder="请输入BYC负责单位/联系人"
          clearable
          size="small" @input="handleQuery"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="施工单位" prop="sgdw">
        <el-input
          v-model="queryParams.sgdw"
          placeholder="请输入施工单位"
          clearable
          size="small" @input="handleQuery"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="销票时间" prop="xpsj">
        <el-date-picker clearable size="small" style="width: 200px"
                        v-model="queryParams.xpsj"
                        type="date"
                        @change="handleQuery"
                        value-format="yyyy-MM-dd"
                        :placeholder="$t('请选择') + $t('销票时间')">
        </el-date-picker>
      </el-form-item>
      <el-form-item :label="$t('作业票状态')" prop="zypzt">
        <el-select v-model="queryParams.zypzt" :placeholder="$t('请选择') + $t('作业票状态')" clearable size="small"
                   @change="handleQuery">
          <el-option
            v-for="dict in zypztOptions"
            :key="dict.dictValue"
            :label="dict.dictLabel"
            :value="dict.dictValue"
          />
        </el-select>
      </el-form-item>

<!--      <el-form-item label="未撤销项编号" prop="wcxxbh">-->
<!--        <el-input-->
<!--          v-model="queryParams.wcxxbh"-->
<!--          placeholder="请输入未撤销项编号"-->
<!--          clearable-->
<!--          size="small" @input="handleQuery"-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
      <el-form-item label="未撤销状态" prop="wcxzt">
        <el-select v-model="queryParams.wcxzt" style="width: 200px" :placeholder="$t('请选择') + $t('未撤销状态')"
                   @change="handleQuery" clearable>
          <el-option
            v-for="dict in wcxztOptions"
            :key="dict.dictValue"
            :label="dict.dictLabel"
            :value="dict.dictValue"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="撤销时间" prop="cxsj">
        <el-date-picker clearable size="small" style="width: 200px"
                        v-model="queryParams.cxsj"
                        type="date"
                        @change="handleQuery"
                        value-format="yyyy-MM-dd"
                        :placeholder="$t('请选择') + $t('撤销时间')">
        </el-date-picker>
      </el-form-item>
      <el-form-item :label="$t('票盒')" prop="tag">
        <el-select v-model="queryParams.tag" clearable filterable @change="handleQuery" placeholder="请选择票盒">
          <el-option-group
            v-for="group in tagOptions"
            :key="group.tag"
            :label="group.tag">
            <el-option
              v-for="item in group.children"
              :key="item.tag"
              :label="item.tag"
              :value="item.tag">
            </el-option>
          </el-option-group>
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">{{ $t('搜索') }}</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">{{ $t('重置') }}</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['ehs:jobticket:add']"
        >{{ $t('新增') }}
        </el-button>
      </el-col>
      <!--      <el-col :span="1.5">
              <el-button
                type="success"
                icon="el-icon-edit"
                size="mini"
                :disabled="single"
                @click="handleUpdate"
                v-hasPermi="['ehs:jobticket:edit']"
              >{{ $t('修改') }}</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="['ehs:jobticket:remove']"
              >{{ $t('删除') }}</el-button>
            </el-col>-->
      <el-col :span="1.5">
        <el-button
          type="warning"
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['ehs:jobticket:export']"
        >{{ $t('导出') }}
        </el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="primary"
          icon="el-icon-s-data"
          size="mini"
          @click="handleData"
        >{{ $t('数据分析') }}
        </el-button>
      </el-col>
      <el-col :span="1.5">
        <el-radio-group v-model="tableType" @input="getList">
          <el-radio-button label="1">树形列表</el-radio-button>
          <el-radio-button label="2">平级列表</el-radio-button>
        </el-radio-group>
      </el-col>

      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <u-table v-if="tableType == 1" v-loading="loading" :data="jobticketList"
              :height="clientHeight" border :cell-style="myclass"
              row-id="id"
             :treeConfig="{
             children: 'children',

             expandAll: true}"
             :data-changes-scroll-top =false
              :tree-props="{children: 'children', hasChildren: 'hasChildren'}"
              :default-expand-all=true
               use-virtual
               showBodyOverflow="title"
              @sort-change="sortList"
    >
      <u-table-column :label="$t('开票日期')" align="center" prop="kprq" :tree-node="true" width="125">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.kprq, '{y}-{m}-{d}') }}</span>
        </template>
      </u-table-column>
      <u-table-column :label="$t('新票/续票')" align="center" prop="xpxp" width="100" :formatter="xpxpFormat"/>
      <u-table-column :label="$t('延期许可证号')" align="center" sortable="custom" prop="yqxkzh" width="120"
                       :show-overflow-tooltip="true"/>
      <u-table-column :label="$t('危害工作许可证号')" align="center" sortable="custom" prop="whgzxkzh" width="120"
                       :show-overflow-tooltip="true"/>
      <u-table-column :label="$t('动火作业许可证号')" align="center" sortable="custom" prop="dhzyxkzh" width="120"
                       :show-overflow-tooltip="true"/>
      <u-table-column :label="$t('火票级别')" align="center" sortable="custom" prop="hpjb" :formatter="hpjbFormat"/>
      <u-table-column :label="$t('限制空间许可证号')" align="center" sortable="custom" prop="xzkjxkzh" width="120"
                       :show-overflow-tooltip="true"/>
      <u-table-column label="盲板作业许可证号" align="center" sortable="custom" prop="mbzyxkzh" width="120" :show-overflow-tooltip="true"/>
      <u-table-column label="高处作业许可证号" align="center" sortable="custom" prop="gczyxkzh" width="120" :show-overflow-tooltip="true"/>
      <u-table-column label="高处作业级别" align="center" sortable="custom" prop="gczyjb" :formatter="gczyjbFormat"/>
      <u-table-column :label="$t('工作内容')" align="center" prop="content" width="300" :show-overflow-tooltip="true"/>
      <u-table-column :label="$t('BYC负责单位/联系人')" align="center" prop="byclxr" width="100"
                       :show-overflow-tooltip="true"/>
      <u-table-column :label="$t('施工单位')" align="center" prop="sgdw" :show-overflow-tooltip="true"/>
      <u-table-column :label="$t('联系人')" align="center" prop="lxr" :show-overflow-tooltip="true"/>
      <u-table-column :label="$t('联系电话')" align="center" prop="lxdh" width="100" :show-overflow-tooltip="true"/>
      <u-table-column :label="$t('销票时间')" align="center" prop="xpsj" width="100">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.xpsj, '{y}-{m}-{d}') }}</span>
        </template>
      </u-table-column>
      <u-table-column :label="$t('作业票状态')" align="center" prop="zypzt" width="200" :formatter="zypztFormat">
        <template slot-scope="scope" v-if="scope.row.zypzt != null">
          <el-dropdown placement="bottom" trigger="click">
            <span class="el-dropdown-link">
              <span style=" font-size: 13px" v-if="scope.row.zypzt==10">作业票未销</span>
               <span style=" font-size: 13px" v-if="scope.row.zypzt==18">作业票收回，作业票关闭</span>
                <span style="font-size: 13px" v-if="scope.row.zypzt==16">作业票延期</span>
                 <span style="font-size: 13px" v-if="scope.row.zypzt==20">作业票作废</span>
              <i class="el-icon-caret-bottom"></i>
            </span>
            <el-dropdown-menu slot="dropdown">
              <el-dropdown-item @click.native="statusChange(10, scope.row)">作业票未销</el-dropdown-item>
              <el-dropdown-item @click.native="statusChange(18, scope.row)">作业票关闭，作业票收回</el-dropdown-item>
              <el-dropdown-item @click.native="statusChange(16, scope.row)">作业票延期</el-dropdown-item>
              <el-dropdown-item @click.native="statusChange(20, scope.row)">作业票作废</el-dropdown-item>
            </el-dropdown-menu>
          </el-dropdown>
        </template>
      </u-table-column>
      <u-table-column :label="$t('未撤销项编号')" align="center" prop="wcxxbh" :show-overflow-tooltip="true"/>
      <u-table-column :label="$t('未撤销状态')" align="center" prop="wcxzt" :formatter="wcxztFormat">
        <template slot-scope="scope" v-if="scope.row.wcxzt != null">
          <el-dropdown placement="bottom" trigger="click">
            <span class="el-dropdown-link">
              <span style=" font-size: 13px" v-if="scope.row.wcxzt==10">有</span>
               <span style=" font-size: 13px" v-if="scope.row.wcxzt==12">无</span>
              <i class="el-icon-caret-bottom"></i>
            </span>
            <el-dropdown-menu slot="dropdown">
              <el-dropdown-item @click.native="wcxztYOU(0, scope.row)">有</el-dropdown-item>
              <el-dropdown-item @click.native="wcxztWU(0, scope.row)">无</el-dropdown-item>
            </el-dropdown-menu>
          </el-dropdown>
        </template>
      </u-table-column>
      <u-table-column :label="$t('撤销时间')" align="center" prop="cxsj" width="100">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.cxsj, '{y}-{m}-{d}') }}</span>
        </template>
      </u-table-column>
      <u-table-column :label="$t('票盒')" align="center" prop="tag" :show-overflow-tooltip="true"/>
      <u-table-column :label="$t('备注')" align="center" prop="remarks" :show-overflow-tooltip="true"/>
      <u-table-column :label="$t('操作')" align="center" fixed="right" width="170"
                       class-name="small-padding">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['ehs:jobticket:edit']"
          >{{ $t('修改') }}
          </el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['ehs:jobticket:remove']"
          >{{ $t('删除') }}
          </el-button>
          <el-button
            v-if="scope.row.xpxp=='10'"
            size="mini"
            type="text"
            icon="el-icon-date"
            @click="handlePostpone(scope.row)"
            v-hasPermi="['ehs:jobticket:add']"
          >{{ $t('延期') }}
          </el-button>
        </template>
      </u-table-column>
    </u-table>
    <u-table v-else v-loading="loading" :data="jobticketList"
              :height="clientHeight" border :cell-style="myclass"
              @sort-change="sortList"
             use-virtual
             showBodyOverflow="title"
             :data-changes-scroll-top =false
    >
      <u-table-column :label="$t('开票日期')" align="center" prop="kprq" width="125">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.kprq, '{y}-{m}-{d}') }}</span>
        </template>
      </u-table-column>
      <u-table-column :label="$t('新票/续票')" align="center" prop="xpxp" width="100" :formatter="xpxpFormat"/>
      <u-table-column :label="$t('延期许可证号')" align="center" sortable="custom" prop="yqxkzh" width="120"
                       :show-overflow-tooltip="true"/>
      <u-table-column :label="$t('危害工作许可证号')" align="center" sortable="custom" prop="whgzxkzh" width="120"
                       :show-overflow-tooltip="true"/>
      <u-table-column :label="$t('动火作业许可证号')" align="center" sortable="custom" prop="dhzyxkzh" width="120"
                       :show-overflow-tooltip="true"/>
      <u-table-column :label="$t('火票级别')" align="center" sortable="custom" prop="hpjb" :formatter="hpjbFormat"/>
      <u-table-column :label="$t('限制空间许可证号')" align="center" sortable="custom" prop="xzkjxkzh" width="120"
                       :show-overflow-tooltip="true"/>
      <u-table-column label="盲板作业许可证号" align="center" sortable="custom" prop="mbzyxkzh" width="120" :show-overflow-tooltip="true"/>
      <u-table-column label="高处作业许可证号" align="center" sortable="custom" prop="gczyxkzh" width="120" :show-overflow-tooltip="true"/>
      <u-table-column label="高处作业级别" align="center" sortable="custom" prop="gczyjb" :formatter="gczyjbFormat"/>
      <u-table-column :label="$t('工作内容')" align="center" prop="content" width="300" :show-overflow-tooltip="true"/>
      <u-table-column :label="$t('BYC负责单位/联系人')" align="center" prop="byclxr" width="100"
                       :show-overflow-tooltip="true"/>
      <u-table-column :label="$t('施工单位')" align="center" prop="sgdw" :show-overflow-tooltip="true"/>
      <u-table-column :label="$t('联系人')" align="center" prop="lxr" :show-overflow-tooltip="true"/>
      <u-table-column :label="$t('联系电话')" align="center" prop="lxdh" width="100" :show-overflow-tooltip="true"/>
      <u-table-column :label="$t('销票时间')" align="center" prop="xpsj" width="100">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.xpsj, '{y}-{m}-{d}') }}</span>
        </template>
      </u-table-column>
      <u-table-column :label="$t('作业票状态')" align="center" prop="zypzt" width="200" :formatter="zypztFormat">
        <template slot-scope="scope" v-if="scope.row.zypzt != null">
          <el-dropdown placement="bottom" trigger="click">
            <span class="el-dropdown-link">
              <span style=" font-size: 13px" v-if="scope.row.zypzt==10">{{ "作业票未销" }}</span>
               <span style=" font-size: 13px" v-if="scope.row.zypzt==18">{{ "作业票收回，作业票关闭" }}</span>
                <span style="font-size: 13px" v-if="scope.row.zypzt==16">{{ "作业票延期" }}</span>
                 <span style="font-size: 13px" v-if="scope.row.zypzt==20">{{ "作业票作废" }}</span>
              <i class="el-icon-caret-bottom"></i>
            </span>
            <el-dropdown-menu slot="dropdown">
              <el-dropdown-item @click.native="statusChange(10, scope.row)">{{ $t('作业票未销') }}</el-dropdown-item>
              <el-dropdown-item @click.native="statusChange(18, scope.row)">{{ $t('作业票关闭，作业票收回') }}</el-dropdown-item>
              <el-dropdown-item @click.native="statusChange(16, scope.row)">{{ $t('作业票延期') }}</el-dropdown-item>
              <el-dropdown-item @click.native="statusChange(20, scope.row)">{{ $t('作业票作废') }}</el-dropdown-item>
            </el-dropdown-menu>
          </el-dropdown>
        </template>
      </u-table-column>
      <u-table-column :label="$t('未撤销项编号')" align="center" prop="wcxxbh" :show-overflow-tooltip="true"/>
      <u-table-column :label="$t('未撤销状态')" align="center" prop="wcxzt" :formatter="wcxztFormat">
        <template slot-scope="scope" v-if="scope.row.wcxzt != null">
          <el-dropdown placement="bottom" trigger="click">
            <span class="el-dropdown-link">
              <span style=" font-size: 13px" v-if="scope.row.wcxzt==10">有</span>
               <span style=" font-size: 13px" v-if="scope.row.wcxzt==12">无</span>
              <i class="el-icon-caret-bottom"></i>
            </span>
            <el-dropdown-menu slot="dropdown">
              <el-dropdown-item @click.native="wcxztYOU(0, scope.row)">有</el-dropdown-item>
              <el-dropdown-item @click.native="wcxztWU(0, scope.row)">无</el-dropdown-item>
            </el-dropdown-menu>
          </el-dropdown>
        </template>
      </u-table-column>
      <u-table-column :label="$t('撤销时间')" align="center" prop="cxsj" width="100">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.cxsj, '{y}-{m}-{d}') }}</span>
        </template>
      </u-table-column>
      <u-table-column :label="$t('票盒')" align="center" prop="tag" :show-overflow-tooltip="true"/>
      <u-table-column :label="$t('备注')" align="center" prop="remarks" :show-overflow-tooltip="true"/>
      <u-table-column :label="$t('操作')" align="center" fixed="right" width="170"
                       class-name="small-padding">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['ehs:jobticket:edit']"
          >{{ $t('修改') }}
          </el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['ehs:jobticket:remove']"
          >{{ $t('删除') }}
          </el-button>
          <el-button
            v-if="scope.row.xpxp=='10'"
            size="mini"
            type="text"
            icon="el-icon-date"
            @click="handlePostpone(scope.row)"
            v-hasPermi="['ehs:jobticket:add']"
          >{{ $t('延期') }}
          </el-button>
        </template>
      </u-table-column>
    </u-table>
    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :page-sizes="[20,100,200,500]"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改工作票对话框 -->
    <el-dialog  :close-on-click-modal="false" v-dialogDrag :title="title" :visible.sync="open" width="700px"
               append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="130px">
        <el-form-item :label="$t('开票日期')" prop="kprq">
          <el-date-picker clearable size="small" style="width: 200px"
                          v-model="form.kprq"
                          type="date"
                          value-format="yyyy-MM-dd"
                          :placeholder="$t('请选择') + $t('开票日期')">
          </el-date-picker>
        </el-form-item>
        <el-form-item :label="$t('签发时间')" prop="qfsj">
          <el-input v-model="form.qfsj" :placeholder="$t('请输入') + $t('签发时间')"/>
        </el-form-item>
        <el-form-item :label="$t('新票/续票')" prop="xpxp" v-if="isxp" >
          <el-select v-model="form.xpxp" :placeholder="$t('请选择') + $t('新票/续票')" :disabled="isxp">
            <el-option
              v-for="dict in xpxpOptions"
              :key="dict.dictValue"
              :label="dict.dictLabel"
              :value="dict.dictValue"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item :label="$t('延期许可证号')" prop="yqxkzh">
          <el-input v-model="form.yqxkzh" :placeholder="$t('请输入') + $t('延期许可证号')"/>
        </el-form-item>
        <el-form-item :label="$t('危害工作许可证号')" prop="whgzxkzh">
          <el-input v-model="form.whgzxkzh" :placeholder="$t('请输入') + $t('危害工作许可证号')"/>
        </el-form-item>
        <el-form-item :label="$t('动火作业许可证号')" prop="dhzyxkzh">
          <el-input v-model="form.dhzyxkzh" :placeholder="$t('请输入') + $t('动火作业许可证号')"/>
        </el-form-item>
        <el-form-item :label="$t('火票级别')" prop="hpjb">
          <el-select v-model="form.hpjb" :placeholder="$t('请选择') + $t('火票级别')" clearable>
            <el-option
              v-for="dict in hpjbOptions"
              :key="dict.dictValue"
              :label="dict.dictLabel"
              :value="dict.dictValue"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item :label="$t('限制空间许可证号')" prop="xzkjxkzh">
          <el-input v-model="form.xzkjxkzh" :placeholder="$t('请输入') + $t('限制空间许可证号')"/>
        </el-form-item>
        <el-form-item :label="$t('盲板作业许可证号')" prop="mbzyxkzh">
          <el-input v-model="form.mbzyxkzh" :placeholder="$t('请输入') + $t('盲板作业许可证号')"/>
        </el-form-item>
        <el-form-item :label="$t('高处作业许可证号')" prop="gczyxkzh">
          <el-input v-model="form.gczyxkzh" :placeholder="$t('请输入') + $t('高处作业许可证号')"/>
        </el-form-item>
        <el-form-item :label="$t('高处作业级别')" prop="hpjb">
          <el-select v-model="form.gczyjb" :placeholder="$t('请选择') + $t('高处作业级别')" clearable>
            <el-option
              v-for="dict in gczyjbOptions"
              :key="dict.dictValue"
              :label="dict.dictLabel"
              :value="dict.dictValue"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item :label="$t('内容')" prop="content">
          <el-input v-model="form.content" :placeholder="$t('请输入') + $t('内容')"/>
        </el-form-item>
        <el-form-item label="用户单位" prop="userUnit">
          <el-select v-model="form.userUnit" placeholder="请选择用户单位"
                     @change="checkCategoryPromotionUpdate(form.userUnit)">
            <el-option
              v-for="dict in userUnitOptions"
              :key="dict.userUnit"
              :label="dict.userUnit"
              :value="dict.userUnit"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="用户主管" prop="userMg">
          <el-select v-model="form.userMg" placeholder="请先选择好用户单位" @change="pick">
            <el-option
              v-for="dict in userMgOptions"
              :key="dict.userId"
              :label="dict.nickName"
              :value="dict.userId"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item :label="$t('施工单位')" prop="sgdw">
          <el-select v-model="form.sgdw" placeholder="请选择施工单位" allow-create filterable @change="selectworkUnit(form.sgdw)">
            <el-option
              v-for="dict in sgdwOptions"
              :key="dict.id"
              :label="dict.label"
              :value="dict.label"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item :label="$t('联系人')" prop="lxr">
          <el-input v-model="form.lxr" :placeholder="$t('请输入') + $t('联系人')"/>
        </el-form-item>
        <el-form-item :label="$t('联系电话')" prop="lxdh">
          <el-input v-model="form.lxdh" :placeholder="$t('请输入') + $t('联系电话')"/>
        </el-form-item>
        <el-form-item :label="$t('销票时间')" prop="xpsj">
          <el-date-picker clearable size="small" style="width: 200px"
                          v-model="form.xpsj"
                          type="date"
                          value-format="yyyy-MM-dd"
                          :placeholder="$t('请选择') + $t('销票时间')">
          </el-date-picker>
        </el-form-item>
        <el-form-item :label="$t('作业票状态')" prop="zypzt">
          <el-select v-model="form.zypzt" :placeholder="$t('请选择') + $t('作业票状态')">
            <el-option
              v-for="dict in zypztOptions"
              :key="dict.dictValue"
              :label="dict.dictLabel"
              :value="dict.dictValue"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item :label="$t('未撤销项编号')" prop="wcxxbh">
          <el-input v-model="form.wcxxbh" :placeholder="$t('请输入') + $t('未撤销项编号')"/>
        </el-form-item>
        <el-form-item :label="$t('未撤销状态')" prop="wcxzt">
          <el-select v-model="form.wcxzt" :placeholder="$t('请选择') + $t('未撤销状态')" clearable>
            <el-option
              v-for="dict in wcxztOptions"
              :key="dict.dictValue"
              :label="dict.dictLabel"
              :value="dict.dictValue"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item :label="$t('撤销时间')" prop="cxsj">
          <el-date-picker clearable size="small" style="width: 200px"
                          v-model="form.cxsj"
                          type="date"
                          value-format="yyyy-MM-dd"
                          :placeholder="$t('请选择') + $t('撤销时间')">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="票盒" prop="tag">
          <el-select v-model="form.tag"  filterable clearable placeholder="请选择票盒">
            <el-option-group
              v-for="group in tagOptions"
              :key="group.tag"
              :label="group.tag">
              <el-option
                v-for="item in group.children"
                :key="item.tag"
                :label="item.tag"
                :value="item.tag">
              </el-option>
            </el-option-group>
          </el-select>
        </el-form-item>
        <el-form-item :label="$t('备注')" prop="remarks">
          <el-input v-model="form.remarks" :placeholder="$t('请输入') + $t('备注')"/>
        </el-form-item>
        <el-form-item :label="$t('归属部门')" prop="deptId">
          <treeselect v-model="form.deptId" :options="deptOptions" :show-count="true"
                      :placeholder="$t('请选择') + $t('归属部门')"/>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">{{ $t('确 定') }}</el-button>
        <el-button @click="cancel">{{ $t('取 消') }}</el-button>
      </div>
    </el-dialog>
    <!-- 用户导入对话框 -->
    <el-dialog  :close-on-click-modal="false" v-dialogDrag :title="upload.title" :visible.sync="upload.open" width="400px"
                append-to-body>
      <el-upload
        ref="upload"
        :limit="1"
        accept=".xlsx, .xls"
        :headers="upload.headers"
        :action="upload.url"
        :disabled="upload.isUploading"
        :on-progress="handleFileUploadProgress"
        :on-success="handleFileSuccess"
        :auto-upload="false"
        drag
      >
        <i class="el-icon-upload"></i>
        <div class="el-upload__text">
          {{ $t('将文件拖到此处，或') }}
          <em>{{ $t('点击上传') }}</em>
        </div>
        <div class="el-upload__tip" slot="tip">
          <!--<el-checkbox v-model="upload.updateSupport" />是否更新已经存在的用户数据-->
          <el-link type="info" style="font-size:12px" @click="importTemplate">{{ $t('下载模板') }}</el-link>
        </div>
        <form ref="downloadFileForm" :action="upload.downloadAction" target="FORMSUBMIT">
          <input name="type" :value="upload.type" hidden/>
        </form>
        <div class="el-upload__tip" style="color:red" slot="tip">{{ $t('提示：仅允许导入“xls”或“xlsx”格式文件！') }}</div>
      </el-upload>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitFileForm">{{ $t('确 定') }}</el-button>
        <el-button @click="upload.open = false">{{ $t('取 消') }}</el-button>
      </div>
    </el-dialog>
    <el-drawer
      :title="$t('数据分析')"
      size="600px"
      :visible.sync="drawer"
      :direction="direction">
      <el-row>
        <el-col>
          <el-card class="box-card" shadow="hover">
            <div slot="header" class="clearfix">
              <span>{{ this.$t('火票级别统计') }}</span>
            </div>
            <div class="text item">
              <fire-data></fire-data>
            </div>
          </el-card>
        </el-col>
      </el-row>
      <el-row>
        <el-col>
          <el-card class="box-card" shadow="hover">
            <div slot="header" class="clearfix">
              <span>{{ this.$t('作业票状态统计') }}</span>
            </div>
            <div class="text item">
              <status-data></status-data>
            </div>
          </el-card>
        </el-col>
      </el-row>
    </el-drawer>
    <el-dialog  :close-on-click-modal="false" title="延期作业许可" :visible.sync="guanlianVisible" width="30%"  center>
      <el-form ref="form" :model="postponeform" :rules="rules1" label-width="80px">
        <el-form-item :label="$t('开票日期')" prop="kprq">
          <el-date-picker clearable size="small" style="width: 200px"
                          v-model="postponeform.kprq"
                          type="date"
                          value-format="yyyy-MM-dd"
                          :placeholder="$t('请选择') + $t('开票日期')">
          </el-date-picker>
        </el-form-item>
        <el-form-item :label="$t('签发时间')" prop="qfsj">
          <el-input v-model="postponeform.qfsj" :placeholder="$t('请输入') + $t('签发时间')"/>
        </el-form-item>
        <el-form-item :label="$t('延期许可证号')" prop="yqxkzh">
          <el-input v-model="postponeform.yqxkzh" :placeholder="$t('请输入') + $t('延期许可证号')"/>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="guanlianVisible=false">取 消</el-button>
        <el-button type="primary" @click="submitPostpone()">确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import {
  listJobticket,
  getJobticket,
  delJobticket,
  addJobticket,
  updateJobticket,
  exportJobticket,
  updateJobticketStatus
} from "@/api/ehs/jobticket";
import {
  listUnit,
  getUnit,
  delUnit,
  addUnit,
  updateUnit,
  exportUnit,
  getUserByUnit,
  getAllUserUnit
} from "@/api/invoice/unit";
import {treeselect, getDept} from "@/api/system/dept";
import {getToken} from "@/utils/auth";
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
import FireData from "./fireData";
import StatusData from "./statusData";
import {listTagAll} from "@/api/invoice/tag";
import base from "@/assets/js/base";
import {listSpecYlrq} from "@/api/sems/specYlrq";

export default {
  name: "Jobticket",
  components: {FireData, Treeselect, StatusData},
  data() {
    return {
      //新票新增
      isxp: false,
      //延期对话框
      guanlianVisible: false,
      yqzyxkzh: "",
      drawer: false,
      direction: 'rtl',
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: false,
      // 总条数
      total: 0,
      // 工作票表格数据
      jobticketList: [],
      // 弹出层标题
      title: "",
      // 部门树选项
      deptOptions: undefined,
      clientHeight: 300,
      // 是否显示弹出层
      open: false,
      // 装置字典
      plantCodeOptions: [],
      // 新票/续票字典
      xpxpOptions: [],
      // 火票级别字典
      hpjbOptions: [],
      // 作业票状态字典
      zypztOptions: [],
      // 高处作业级别字典
      gczyjbOptions: [],
      //作业票未撤销状态字典
      wcxztOptions: [],
      //施工单位字典
      sgdwOptions: [],
      // 用户单位字典
      userUnitOptions: [],
      // 用户主管字典
      userMgOptions: [],
      tagOptions: [],
      // 用户导入参数
      upload: {
        //下载模板请求地址
        downloadAction: process.env.VUE_APP_BASE_API + '/common/template',
        //下载模板类型
        type: "jobticket",
        // 是否显示弹出层（用户导入）
        open: false,
        // 弹出层标题（用户导入）
        title: "",
        // 是否禁用上传
        isUploading: false,
        // 是否更新已经存在的用户数据
        updateSupport: 0,
        // 设置上传的请求头部
        headers: {Authorization: "Bearer " + getToken()},
        // 上传的地址
        url: process.env.VUE_APP_BASE_API + "/ehs/jobticket/importData"
      },
      // 查询参数
      tableType: 1,
      queryParams: {
        tableType: 1,
        pageNum: 1,
        pageSize: 100,
        plantCode: null,
        kprq: null,
        startDate: null,
        endDate: null,
        qfsj: null,
        qfbz: null,
        qfr: null,
        xpxp: null,
        whgzxkzh: null,
        dhzyxkzh: null,
        hpjb: null,
        xzkjxkzh: null,
        content: null,
        byclxr: null,
        sgdw: null,
        lxr: null,
        lxdh: null,
        xpsj: null,
        zypzt: null,
        jccdr: null,
        wcxxbh: null,
        wcxzt: null,
        cxsj: null,
        tag: null,
        orderByColumn: null,
        isAsc: null,
        allNo: null
      },
      //日期快速选择
      pickerOptions: {
        shortcuts: [{
          text: this.$t('最近一周'),
          onClick(picker) {
            const end = new Date();
            const start = new Date();
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
            picker.$emit('pick', [start, end]);
          }
        }, {
          text: this.$t('最近一个月'),
          onClick(picker) {
            const end = new Date();
            const start = new Date();
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
            picker.$emit('pick', [start, end]);
          }
        }, {
          text: this.$t('最近三个月'),
          onClick(picker) {
            const end = new Date();
            const start = new Date();
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
            picker.$emit('pick', [start, end]);
          }
        }]
      },
      //日期选择器
      chooseDate: [],
      // 表单参数
      form: {},
      //延期参数
      postponeParams: {},
      //延期表单
      postponeform: {},
      // 表单校验
      rules: {
        plantCode: [
          {required: true, message: this.$t('装置') + this.$t('不能为空'), trigger: "change"}
        ],
        deptId: [
          {required: true, message: this.$t('部门编号') + this.$t('不能为空'), trigger: "blur"}
        ],
        xpxp: [
          {required: true, message: this.$t('手动新增只能为新票'), trigger: "blur"},
          {validator: this.xpxp, trigger: 'blur'}
        ]
      },
      rules1: {
        yqxkzh: [
          {required: true, message: this.$t('当前续票必填'), trigger: "blur"}
        ],
      }
    };
  },
  watch: {
    // 根据名称筛选部门树
    deptName(val) {
      this.$refs.tree.filter(val);
    }
  },
  created() {
    //设置表格高度对应屏幕高度
    this.$nextTick(() => {
      this.clientHeight = (document.body.clientHeight - 80) * 0.8
    })
    this.getList();
    this.getTreeselect();
    this.getChengbaoshang();
    this.getTagList()
    this.getDicts("PLANT_DIVIDE").then(response => {
      this.plantCodeOptions = response.data;
    });
    this.getDicts("QFBZ").then(response => {
      this.qfbzOptions = response.data;
    });
    this.getDicts("XPXP").then(response => {
      this.xpxpOptions = response.data;
    });
    this.getDicts("HPJB").then(response => {
      this.hpjbOptions = response.data;
    });
    this.getDicts("ZYPZT").then(response => {
      this.zypztOptions = response.data;
    });
    //高处作业级别
    this.getDicts("GCZYJB").then(response => {
      this.gczyjbOptions = response.data;
    });
    this.getDicts("TICKED_WCXZT").then(response => {
      this.wcxztOptions = response.data;
    });
    getAllUserUnit({}).then(response => {
      this.userUnitOptions = response.data;
      console.log(this.userUnitOptions)
    });
  },
  methods: {
    //当前时间
    getNowFormatDate() {
      var date = new Date();
      var seperator1 = "-";
      var year = date.getFullYear();
      var month = date.getMonth() + 1;
      var strDate = date.getDate();
      if (month >= 1 && month <= 9) {
        month = "0" + month;
      }
      if (strDate >= 0 && strDate <= 9) {
        strDate = "0" + strDate;
      }
      var currentdate = year + seperator1 + month + seperator1 + strDate;
      return currentdate;
    },
    //根据用户单位 查询对应选择的用户主管  根据用户单位 字段 查找对应的多个主管 返回 Sysuser的集合(id,name)
    checkCategoryPromotion(oneId) {
      if (!oneId){
        return
      }
      getUserByUnit(oneId).then(response => {
        //     this.form.userMg=null;
        this.userMgOptions = response.data;
        //   let arr=  response.data.userIds.split(',');
      });
    },
    //修改用户单位时，级联的用户主管下拉数据应清空，否则会造成用户修改了用户单位，但未重新选择相应的用户主管
    checkCategoryPromotionUpdate(oneId) {
      this.form.userMg = null;

      getUserByUnit(oneId).then(response => {
        //     this.form.userMg=null;
        this.userMgOptions = response.data;
        //   let arr=  response.data.userIds.split(',');
      });
    },
    //修改延期时的用户单位
    checkCategoryPromotionRenew(oneId) {
      this.postponeform.userMg = null;
      getUserByUnit(oneId).then(response => {
        this.userMgOptions = response.data;
      });
    },
    //主管下拉框变动重新刷新赋值
    pick() {
      this.$forceUpdate()
    },
    //查找施工单位
    selectworkUnit(oneId) {
      //选中的数据和options进行匹配
      var obj = {}
      obj = this.sgdwOptions.find(function (i) {
        return i.label === oneId
      });
      getDept(obj.id).then(response => {
        this.form.lxr = response.data.leader;
        this.form.lxdh = response.data.phone
      });
    },
    //查找承包商列表
    getChengbaoshang() {
      treeselect().then(response => {
        this.sgdwOptions = response.data[1].children;
      });
    },
    //得到票盒下拉框
    getTagList() {
      listTagAll().then(response => {
        this.tagOptions = response
      });
    },
    //延期 即新增一条 改为续票
    handlePostpone(row) {
      this.guanlianVisible = true
      const id = row.id || this.ids
      getJobticket(id).then(response => {
        this.postponeform = response.data;
        this.postponeform.kprq = this.getNowFormatDate()
        //  this.checkCategoryPromotion(response.data.userUnit);
      });
      this.postponeParams = base.deepClone(row)

    },
    //新的 续票 构造票号 最多五次
    submitPostpone() {
      this.guanlianVisible = false
      //保留新票的参数 用来修改新票
      const id = this.postponeParams.id
      const postponeNumber = this.postponeParams.postponeNumber + 1;
      const yqxkzh = this.postponeform.yqxkzh

      //续票的参数
      this.postponeParams.id = null
      this.postponeParams.yqxkzh = this.postponeform.yqxkzh
      this.postponeParams.xpxp = "12"
      this.postponeParams.zypzt = "10"
      this.postponeParams.kprq = this.postponeform.kprq
      this.postponeParams.qfsj = this.postponeform.qfsj
      this.postponeParams.qfbz = this.postponeform.qfbz
      this.postponeParams.qfr = this.postponeform.qfr

      if (postponeNumber > 15) {
        return this.msgError("当前作业票最多可以延期十五次，请重新开票");
      } else {
        if (this.postponeParams.yqxkzh.endsWith('-6')) {
          this.msgError("每张续票最多可以延期五次，请重新命名生成新的续票");
          this.getList();
        } else {
          //若果是第一次延期  延期许可证取输入的 后续的都是原来
          let putData = {}
          putData.id = id
          putData.postponeNumber = postponeNumber
          if (putData.postponeNumber == 1) {
            putData.yqxkzh = yqxkzh.substring(0, yqxkzh.indexOf("-"));
            updateJobticket(putData).then(response => {

            });
          } else {
            putData.yqxkzh = yqxkzh
          }

          addJobticket(this.postponeParams).then(response => {
            this.msgSuccess(this.$t('延期成功，请查看新的续票'));
            this.open = false;
            this.getList();
          });

        }
      }

    },
    //修改单元格样式的方法
    myclass({row, column, rowIndex, columnIndex}) {
      if (row.zypzt == 10) {
        return {'background-color': 'rgba(255, 68,68, 0.5)'}
      }
      if (row.zypzt == 18 || row.zypzt == 14) {
        return {'background-color':'rgba(21,180,51, 0.5)'}
      }
      if (row.zypzt == 16) {
        return {'background-color':'rgba(221,248,9, 0.5)'}
      }
      if (row.zypzt == 20) {
        return  {'background-color':'rgba(163, 150,150, 0.5)'}
      }
    },
    /** 查询工作票列表 */
    getList() {
      this.loading = true;
      this.queryParams.tableType = this.tableType
      listJobticket(this.queryParams).then(response => {
        this.jobticketList = []
        this.jobticketList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    //element表格排序
    sortList(val) {
      var sort = "asc";
      let sortTip = val.order
      this.queryParams.orderByColumn = val.prop;
      if (sortTip === 'descending') {
        this.queryParams.isAsc = 'desc' // 降序
      } else if (sortTip === 'ascending') {
        this.queryParams.isAsc = 'asc' // 升序
      } else if (sortTip === null) {
        this.queryParams.isAsc = null;
        this.queryParams.orderByColumn = null;
      }
      this.getList();
    },
    /** 查询部门下拉树结构 */
    getTreeselect() {
      treeselect().then(response => {
        this.deptOptions = response.data;
      });
    },
    // 装置字典翻译
    plantCodeFormat(row, column) {
      return this.selectDictLabel(this.plantCodeOptions, row.plantCode);
    },
    // 新票/续票字典翻译
    xpxpFormat(row, column) {
      return this.selectDictLabel(this.xpxpOptions, row.xpxp);
    },
    // 火票级别字典翻译
    hpjbFormat(row, column) {
      return this.selectDictLabel(this.hpjbOptions, row.hpjb);
    },
    // 作业票状态字典翻译
    zypztFormat(row, column) {
      return this.selectDictLabel(this.zypztOptions, row.zypzt);
    },
    // 高处作业级别字典翻译
    gczyjbFormat(row, column) {
      return this.selectDictLabel(this.gczyjbOptions, row.gczyjb);
    },
    wcxztFormat(row, column) {
      return this.selectDictLabel(this.wcxztOptions, row.wcxzt);
    },

    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    //变换作业票状态
    statusChange(index, row) {
      this.form = row;
      row.zypzt = index;
      this.form.zypzt = index;
      updateJobticketStatus(this.form).then(response => {
        this.msgSuccess(this.$t('修改成功'));
        this.open = false;
        this.getList();
      });
    },
    wcxztYOU(index, row) {
      this.form = row;
      this.form.wcxzt = 10;
      updateJobticket(this.form).then(response => {
        this.msgSuccess(this.$t('修改成功'));
        this.open = false;
        this.getList();
      });
    },

    wcxztWU(index, row) {
      this.form = row;
      this.form.wcxzt = 12;
      this.form.cxsj = this.getNowFormatDate()
      updateJobticket(this.form).then(response => {
        this.msgSuccess(this.$t('修改成功'));
        this.open = false;
        this.getList();
      });
    },

    // 表单重置
    reset() {
      this.form = {
        id: null,
        plantCode: null,
        kprq: null,
        startDate: null,
        endDate: null,
        qfsj: null,
        qfbz: null,
        qfr: null,
        xpxp: null,
        yqxkzh: null,
        whgzxkzh: null,
        dhzyxkzh: null,
        hpjb: null,
        xzkjxkzh: null,
        content: null,
        byclxr: null,
        sgdw: null,
        lxr: null,
        lxdh: null,
        xpsj: null,
        zypzt: null,
        jccdr: null,
        wcxxbh: null,
        wcxzt: null,
        cxsj: null,
        delFlag: null,
        createrCode: null,
        createdate: null,
        updaterCode: null,
        updatedate: null,
        deptId: null,
        remarks: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      console.log(this.queryParams)
      if (this.chooseDate == null) {
        this.chooseDate = []
      }
      this.queryParams.startDate = this.chooseDate[0]
      this.queryParams.endDate = this.chooseDate[1]
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.chooseDate = "";
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length !== 1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = this.$t('新增') + " " + this.$t('工作票');
      this.form.kprq = this.getNowFormatDate()
      this.form.qfsj = '8:30'
      this.form.zypzt = "10"
      this.form.xpxp = "10"
      this.isxp = false
      this.form.deptId = this.$store.state.user.deptId
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.isxp = true
      this.reset();
      const id = row.id || this.ids
      getJobticket(id).then(response => {
        this.form = response.data;
        this.checkCategoryPromotion(this.form.userUnit);
        this.open = true;
        this.title = this.$t('修改') + this.$t('工作票');
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            updateJobticket(this.form).then(response => {
              this.msgSuccess(this.$t('修改成功'));
              this.open = false;
              this.getList();
            });
          } else {
            addJobticket(this.form).then(response => {
              this.msgSuccess(this.$t('新增成功'));
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      if (row.children != null && row.children.length > 0) {
        this.msgError('存在续票，无法删除主票')
        return
      }
      const ids = row.id || this.ids;
      this.$confirm(this.$t('是否确认删除?'), this.$t('警告'), {
        confirmButtonText: this.$t('确定'),
        cancelButtonText: this.$t('取消'),
        type: "warning"
      }).then(function () {
        return delJobticket(ids);
      }).then(() => {
        this.getList();
        this.msgSuccess(this.$t('删除成功'));
      })
    },
    /** 导出按钮操作 */
    handleExport() {
      const queryParams = this.queryParams;
      this.$confirm(this.$t('是否确认导出所有工作票数据项?'), this.$t('警告'), {
        confirmButtonText: this.$t('确定'),
        cancelButtonText: this.$t('取消'),
        type: "warning"
      }).then(function () {
        return exportJobticket(queryParams);
      }).then(response => {
        this.download(response.msg);
      })
    },
    /** 导入按钮操作 */
    handleImport() {
      this.upload.title = this.$t('用户导入');
      this.upload.open = true;
    },
    /** 下载模板操作 */
    importTemplate() {
      this.$refs['downloadFileForm'].submit()
    },
    // 文件上传中处理
    handleFileUploadProgress(event, file, fileList) {
      this.upload.isUploading = true;
    },
    // 文件上传成功处理
    handleFileSuccess(response, file, fileList) {
      this.upload.open = false;
      this.upload.isUploading = false;
      this.$refs.upload.clearFiles();
      if (response.data[0] != null) {
        this.$alert(this.$t('成功导入') + response.msg + this.$t('条数据') + "，" + this.$t('第') + response.data + this.$t('行数据出现错误导入失败') + "。", this.$t('导入结果'), {dangerouslyUseHTMLString: true});
      } else {
        this.$alert(this.$t('成功导入') + response.msg + this.$t('条数据'), this.$t('导入结果'), {dangerouslyUseHTMLString: true});
      }
      this.getList();
    },
    // 提交上传文件
    submitFileForm() {
      this.$refs.upload.submit();
    },
    //数据分析
    handleData() {
      this.drawer = true
    }
  }
};
</script>
<style>
.text {
  font-size: 14px;
}

.item {
  margin-bottom: 18px;
}

.clearfix {
  color: #1e1e1e;
}

.clearfix:before,
.clearfix:after {
  display: table;
  content: "";
}

.clearfix:after {
  clear: both
}

.box-card {
  width: 100%;
}

.el-drawer__body {
  overflow: auto;
}

.el-drawer__container ::-webkit-scrollbar {
  display: none;
}
</style>
