<!-- 井基础信息 -->
<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="100px">
      <el-form-item label="区块名称" prop="qk">
        <el-select v-model="queryParams.qk" placeholder="请选择区块名称" clearable filterable>
          <el-option v-for="item in blockOptions" :key="item.qk" :label="item.qk" :value="item.qk" />
        </el-select>
      </el-form-item>
      <el-form-item label="井号" prop="jh">
        <el-input v-model="queryParams.jh" placeholder="请输入井号" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="完井日期">
        <el-date-picker v-model="queryParams.wjrqks" type="date" value-format="yyyy-MM-dd" placeholder="完井开始年份">
        </el-date-picker>
        -
        <el-date-picker v-model="queryParams.wjrqjs" type="date" value-format="yyyy-MM-dd" placeholder="完井结束年份">
        </el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
        <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport"
          v-hasPermi="['system:jsaa:export']">导出</el-button>
      </el-form-item>
    </el-form>

    <!-- <el-row :gutter="10" class="mb8"> -->
    <!-- <el-col :span="1.5">
        <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"
          v-hasPermi="['system:jsaa:add']">新增</el-button>
      </el-col> -->
    <!-- <el-col :span="1.5">
        <el-button type="primary" plain icon="el-icon-view" size="mini" :readonly="single" @click="handleUpdate"
          v-hasPermi="['system:jsaa:edit']">查看</el-button>
      </el-col> -->
    <!-- <el-col :span="1.5">
        <el-button type="danger" plain icon="el-icon-delete" size="mini" :readonly="multiple" @click="handleDelete"
          v-hasPermi="['system:jsaa:remove']">删除</el-button>
      </el-col> -->
    <!-- <el-col :span="1.5">
        <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport"
          v-hasPermi="['system:jsaa:export']">导出</el-button>
      </el-col> -->
    <!-- <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> -->
    <!-- </el-row> -->

    <el-table v-loading="loading" border :data="jsaaList" @selection-change="handleSelectionChange"
      height="calc(100vh - 200px)" class="table-container">
      <!-- <el-table-column type="selection" width="55" align="center" /> -->
      <el-table-column label="井号" align="center" prop="jh" min-width="110" show-overflow-tooltip fixed />
      <!-- <el-table-column label="区块" align="center" prop="qk" width="180" show-overflow-tooltip />
      <el-table-column label="设计井深" align="center" prop="sjjs" width="180" show-overflow-tooltip />
      <el-table-column label="完井井深" align="center" prop="wjjs" width="180" show-overflow-tooltip /> -->
      <!-- <el-table-column label="完钻垂直井深" align="center" prop="wzczjs" show-overflow-tooltip /> -->
      <!-- <el-table-column label="完钻层位" align="center" prop="wzcw" width="180" show-overflow-tooltip /> -->
      <!-- <el-table-column label="搬迁日期" align="center" prop="bqrq" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.bqrq, '{y}-{m}-{d}') }}</span>
        </template>
</el-table-column>
<el-table-column label="搬迁时间" align="center" prop="bqsj" />
<el-table-column label="安装日期" align="center" prop="azrq" width="180">
  <template slot-scope="scope">
          <span>{{ parseTime(scope.row.azrq, '{y}-{m}-{d}') }}</span>
        </template>
</el-table-column>
<el-table-column label="安装时间" align="center" prop="azsj" /> -->
      <el-table-column label="第一次开钻日期" align="center" prop="kzrq1" min-width="125" show-overflow-tooltip>
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.kzrq1, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <!-- <el-table-column label="第一次开钻时间" align="center" prop="kzsj1" /> -->
      <!-- <el-table-column label="第二次开钻日期" align="center" prop="kzrq2" width="180" show-overflow-tooltip>
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.kzrq2, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column> -->
      <!-- <el-table-column label="第二次开钻时间" align="center" prop="kzsj2" />
      <el-table-column label="第三次开钻日期" align="center" prop="kzrq3" width="180" show-overflow-tooltip>
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.kzrq3, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column> -->
      <!-- <el-table-column label="第三次开钻时间" align="center" prop="kzsj3" /> -->
      <!-- <el-table-column label="第四次开钻日期" align="center" prop="kzrq4" width="180" show-overflow-tooltip>
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.kzrq4, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column> -->
      <!-- <el-table-column label="第四次开钻时间" align="center" prop="kzsj4" /> -->
      <!-- <el-table-column label="第五次开钻日期" align="center" prop="kzrq5" width="180" show-overflow-tooltip>
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.kzrq5, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column> -->
      <!-- <el-table-column label="第五次开钻时间" align="center" prop="kzsj5" /> -->
      <el-table-column label="完钻日期" align="center" prop="wzrq" min-width="110" show-overflow-tooltip>
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.wzrq, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="完钻时间" align="center" prop="wzsj" min-width="110" show-overflow-tooltip />
      <el-table-column label="完井日期" align="center" prop="wjrq" min-width="110" show-overflow-tooltip>
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.wjrq, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <!-- <el-table-column label="完井时间" align="center" prop="wjsj" /> -->
      <el-table-column label="钻井周期" align="center" prop="zjzq" min-width="110" show-overflow-tooltip />
      <!-- <el-table-column label="钻井周期h" align="center" prop="zjzq2" width="120" show-overflow-tooltip /> -->
      <!-- <el-table-column label="建井周期d" align="center" prop="jjzq1" />
      <el-table-column label="建井周期h" align="center" prop="jjzq2" />
      <el-table-column label="钻杆测试时间d" align="center" prop="zgcssj1" />
      <el-table-column label="钻杆测试时间h" align="center" prop="zgcssj2" /> -->
      <!-- <el-table-column label="返工进尺" align="center" prop="fgjc" />
      <el-table-column label="取心进尺" align="center" prop="qxjc" />
      <el-table-column label="岩心长度" align="center" prop="yxcd" />
      <el-table-column label="岩心收获率" align="center" prop="yxshl" />
      <el-table-column label="平均单筒进尺" align="center" prop="pjdtjc" /> -->
      <!-- <el-table-column label="完井方法" align="center" prop="wjff" />
      <el-table-column label="钻机月" align="center" prop="zjy" />
      <el-table-column label="钻机月速" align="center" prop="zjys" /> -->
      <el-table-column label="设计井深m" align="center" prop="sjjs" min-width="110" show-overflow-tooltip />
      <el-table-column label="完井井深m" align="center" prop="wjjs" min-width="110" show-overflow-tooltip />
      <el-table-column label="完钻层位" align="center" prop="wzcw" min-width="110" show-overflow-tooltip />
      <el-table-column label="平均机械钻速m/h" align="center" prop="pjjxzs" min-width="110" show-overflow-tooltip />
      <!-- <el-table-column label="井身质量" align="center" prop="jszl" />
      <el-table-column label="固井质量" align="center" prop="gjzl" />
      <el-table-column label="事故次数" align="center" prop="sgcs" />
      <el-table-column label="直接成本" align="center" prop="zjcb" />
      <el-table-column label="综合成本" align="center" prop="zhcb" />
      <el-table-column label="每米直接成本" align="center" prop="mmzjcb" />
      <el-table-column label="每米综合成本" align="center" prop="mmzhcb" />
      <el-table-column label="油公司名称" align="center" prop="ygsmc" /> -->
      <el-table-column label="区块" align="center" prop="qk" min-width="90" show-overflow-tooltip />
      <el-table-column label="特殊工艺井" align="center" prop="tsgyj" min-width="100" show-overflow-tooltip />
      <!-- <el-table-column label="主井号" align="center" prop="zjh" />
      <el-table-column label="分支数" align="center" prop="fzs" />
      <el-table-column label="第几分支" align="center" prop="djfz" /> -->
      <el-table-column label="采油厂" align="center" prop="cyc" min-width="100" show-overflow-tooltip />
      <!-- <el-table-column label="侧钻点深" align="center" prop="czds" /> -->
      <el-table-column label="设计层位" align="center" prop="sjcw" min-width="100" show-overflow-tooltip />
      <el-table-column label="操作" width="140" align="center" class-name="small-padding fixed-width" fixed="right">
        <template slot-scope="scope">
          <el-button size="mini" type="text" icon="el-icon-view" @click="handleUpdate(scope.row)"
            v-hasPermi="['system:jsaa:edit']">查看</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
      :page-sizes="[10, 20, 30, 50, 100]" @pagination="getList" />

    <!-- 添加或修改基础数据对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="90%" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="120px">
        <el-row>
          <el-col :span="6">
            <el-form-item label="井号" prop="jh">
              <el-input v-model="form.jh" placeholder="请输入井号" :readonly="isViewMode" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="搬迁日期" prop="bqrq">
              <el-date-picker clearable v-model="form.bqrq" type="date" value-format="yyyy-MM-dd" placeholder="请选择搬迁日期"
                style="width: 100%;" :readonly="isViewMode">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="搬迁时间" prop="bqsj">
              <el-input v-model="form.bqsj" placeholder="请输入搬迁时间" :readonly="isViewMode" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="安装日期" prop="azrq">
              <el-date-picker clearable v-model="form.azrq" type="date" value-format="yyyy-MM-dd" placeholder="请选择安装日期"
                style="width: 100%;" :readonly="isViewMode">
              </el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="6">
            <el-form-item label="安装时间" prop="azsj">
              <el-input v-model="form.azsj" placeholder="请输入安装时间" :readonly="isViewMode" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="第一次开钻日期" prop="kzrq1">
              <el-date-picker clearable v-model="form.kzrq1" type="date" value-format="yyyy-MM-dd" style="width: 100%;"
                placeholder="请选择第一次开钻日期" :readonly="isViewMode">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="第一次开钻时间" prop="kzsj1">
              <el-input v-model="form.kzsj1" placeholder="请输入第一次开钻时间" :readonly="isViewMode" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="第二次开钻日期" prop="kzrq2">
              <el-date-picker clearable v-model="form.kzrq2" type="date" value-format="yyyy-MM-dd" style="width: 100%;"
                placeholder="请选择第二次开钻日期" :readonly="isViewMode">
              </el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="6">
            <el-form-item label="第二次开钻时间" prop="kzsj2">
              <el-input v-model="form.kzsj2" placeholder="请输入第二次开钻时间" :readonly="isViewMode" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="第三次开钻日期" prop="kzrq3">
              <el-date-picker clearable v-model="form.kzrq3" type="date" value-format="yyyy-MM-dd" style="width: 100%;"
                placeholder="请选择第三次开钻日期" :readonly="isViewMode">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="第三次开钻时间" prop="kzsj3">
              <el-input v-model="form.kzsj3" placeholder="请输入第三次开钻时间" :readonly="isViewMode" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="第四次开钻日期" prop="kzrq4">
              <el-date-picker clearable v-model="form.kzrq4" type="date" value-format="yyyy-MM-dd" style="width: 100%;"
                placeholder="请选择第四次开钻日期" :readonly="isViewMode">
              </el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="6">
            <el-form-item label="第四次开钻时间" prop="kzsj4">
              <el-input v-model="form.kzsj4" placeholder="请输入第四次开钻时间" :readonly="isViewMode" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="第五次开钻日期" prop="kzrq5">
              <el-date-picker clearable v-model="form.kzrq5" type="date" value-format="yyyy-MM-dd" style="width: 100%;"
                placeholder="请选择第五次开钻日期" :readonly="isViewMode">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="第五次开钻时间" prop="kzsj5">
              <el-input v-model="form.kzsj5" placeholder="请输入第五次开钻时间" :readonly="isViewMode" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="完钻日期" prop="wzrq">
              <el-date-picker clearable v-model="form.wzrq" type="date" value-format="yyyy-MM-dd" placeholder="请选择完钻日期"
                style="width: 100%;" :readonly="isViewMode">
              </el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="6">
            <el-form-item label="完钻时间" prop="wzsj">
              <el-input v-model="form.wzsj" placeholder="请输入完钻时间" :readonly="isViewMode" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="完井日期" prop="wjrq">
              <el-date-picker clearable v-model="form.wjrq" type="date" value-format="yyyy-MM-dd" placeholder="请选择完井日期"
                style="width: 100%;" :readonly="isViewMode">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="完井时间" prop="wjsj">
              <el-input v-model="form.wjsj" placeholder="请输入完井时间" :readonly="isViewMode" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="钻井周期" prop="zjzq">
              <el-input v-model="form.zjzq" placeholder="请输入钻井周期(天)" :readonly="isViewMode" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <!-- <el-col :span="6">
            <el-form-item label="钻井周期h" prop="zjzq2">
              <el-input v-model="form.zjzq2" placeholder="请输入钻井周期(小时)" :readonly="isViewMode" />
            </el-form-item>
          </el-col> -->
          <el-col :span="6">
            <el-form-item label="建井周期d" prop="jjzq1">
              <el-input v-model="form.jjzq1" placeholder="请输入建井周期(天)" :readonly="isViewMode" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="建井周期h" prop="jjzq2">
              <el-input v-model="form.jjzq2" placeholder="请输入建井周期(小时)" :readonly="isViewMode" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="钻杆测试时间d" prop="zgcssj1">
              <el-input v-model="form.zgcssj1" placeholder="请输入钻杆测试时间(天)" :readonly="isViewMode" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="钻杆测试时间h" prop="zgcssj2">
              <el-input v-model="form.zgcssj2" placeholder="请输入钻杆测试时间(小时)" :readonly="isViewMode" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>

          <el-col :span="6">
            <el-form-item label="返工进尺" prop="fgjc">
              <el-input v-model="form.fgjc" placeholder="请输入返工进尺" :readonly="isViewMode" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="取心进尺" prop="qxjc">
              <el-input v-model="form.qxjc" placeholder="请输入取心进尺" :readonly="isViewMode" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="岩心长度" prop="yxcd">
              <el-input v-model="form.yxcd" placeholder="请输入岩心长度" :readonly="isViewMode" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="岩心收获率" prop="yxshl">
              <el-input v-model="form.yxshl" placeholder="请输入岩心收获率" :readonly="isViewMode" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>

          <el-col :span="6">
            <el-form-item label="平均单筒进尺" prop="pjdtjc">
              <el-input v-model="form.pjdtjc" placeholder="请输入平均单筒进尺" :readonly="isViewMode" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="设计井深m" prop="sjjs">
              <el-input v-model="form.sjjs" placeholder="请输入设计井深" :readonly="isViewMode" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="完井井深m" prop="wjjs">
              <el-input v-model="form.wjjs" placeholder="请输入完井井深" :readonly="isViewMode" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="完钻垂直井深" prop="wzczjs">
              <el-input v-model="form.wzczjs" placeholder="请输入完钻垂直井深" :readonly="isViewMode" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>

          <el-col :span="6">
            <el-form-item label="完钻层位" prop="wzcw">
              <el-input v-model="form.wzcw" placeholder="请输入完钻层位" :readonly="isViewMode" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="完井方法" prop="wjff">
              <el-input v-model="form.wjff" placeholder="请输入完井方法" :readonly="isViewMode" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="钻机月" prop="zjy">
              <el-input v-model="form.zjy" placeholder="请输入钻机月" :readonly="isViewMode" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="钻机月速" prop="zjys">
              <el-input v-model="form.zjys" placeholder="请输入钻机月速" :readonly="isViewMode" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>

          <el-col :span="6">
            <el-form-item label="平均机械钻速m/h" prop="pjjxzs">
              <el-input v-model="form.pjjxzs" placeholder="请输入平均机械钻速" :readonly="isViewMode" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="井身质量" prop="jszl">
              <el-input v-model="form.jszl" placeholder="请输入井身质量" :readonly="isViewMode" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="固井质量" prop="gjzl">
              <el-input v-model="form.gjzl" placeholder="请输入固井质量" :readonly="isViewMode" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="事故次数" prop="sgcs">
              <el-input v-model="form.sgcs" placeholder="请输入事故次数" :readonly="isViewMode" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>

          <el-col :span="6">
            <el-form-item label="直接成本" prop="zjcb">
              <el-input v-model="form.zjcb" placeholder="请输入直接成本" :readonly="isViewMode" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="综合成本" prop="zhcb">
              <el-input v-model="form.zhcb" placeholder="请输入综合成本" :readonly="isViewMode" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="每米直接成本" prop="mmzjcb">
              <el-input v-model="form.mmzjcb" placeholder="请输入每米直接成本" :readonly="isViewMode" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="每米综合成本" prop="mmzhcb">
              <el-input v-model="form.mmzhcb" placeholder="请输入每米综合成本" :readonly="isViewMode" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>

          <el-col :span="6">
            <el-form-item label="油公司名称" prop="ygsmc">
              <el-input v-model="form.ygsmc" placeholder="请输入油公司名称" :readonly="isViewMode" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="区块" prop="qk">
              <el-input v-model="form.qk" placeholder="请输入区块" :readonly="isViewMode" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="特殊工艺井" prop="tsgyj">
              <el-input v-model="form.tsgyj" placeholder="请输入特殊工艺井" :readonly="isViewMode" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="主井号" prop="zjh">
              <el-input v-model="form.zjh" placeholder="请输入主井号" :readonly="isViewMode" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>

          <el-col :span="6">
            <el-form-item label="分支数" prop="fzs">
              <el-input v-model="form.fzs" placeholder="请输入分支数" :readonly="isViewMode" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="第几分支" prop="djfz">
              <el-input v-model="form.djfz" placeholder="请输入第几分支" :readonly="isViewMode" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="采油厂" prop="cyc">
              <el-input v-model="form.cyc" placeholder="请输入采油厂" :readonly="isViewMode" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="侧钻点深" prop="czds">
              <el-input v-model="form.czds" placeholder="请输入侧钻点深" :readonly="isViewMode" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>

          <el-col :span="6">
            <el-form-item label="设计层位" prop="sjcw">
              <el-input v-model="form.sjcw" placeholder="请输入设计层位" :readonly="isViewMode" />
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="cancel">关 闭</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listJsaa, getJsaa, delJsaa, addJsaa, updateJsaa } from "@/api/system/jsaa";
import { getBlockName, getQkxl } from "@/api/system/jsaa";

export default {
  name: "Jsaa",
  data() {
    return {
      // 区块下拉选项
      blockOptions: [],
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 基础数据表格数据
      jsaaList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 是否为查看模式
      isViewMode: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 20,
        qk: null,
        jh: null,
        wjrqks: null,
        wjrqjs: null
      },
      // 表单参数
      form: {
        jh: null,
        bqrq: null,
        bqsj: null,
        azrq: null,
        azsj: null,
        kzrq1: null,
        kzsj1: null,
        kzrq2: null,
        kzsj2: null,
        kzrq3: null,
        kzsj3: null,
        kzrq4: null,
        kzsj4: null,
        kzrq5: null,
        kzsj5: null,
        wzrq: null,
        wzsj: null,
        wjrq: null,
        wjsj: null,
        zjzq1: null,
        zjzq2: null,
        jjzq1: null,
        jjzq2: null,
        zgcssj1: null,
        zgcssj2: null,
        fgjc: null,
        qxjc: null,
        yxcd: null,
        yxshl: null,
        pjdtjc: null,
        sjjs: null,
        wjjs: null,
        wjczjs: null,
        wzcw: null,
        wjff: null,
        zjy: null,
        zjys: null,
        pjjxzs: null,
        jszl: null,
        gjzl: null,
        sgcs: null,
        zjcb: null,
        zhcb: null,
        mmzjcb: null,
        mmzhcb: null,
        ygsmc: null,
        qk: null,
        tsgyj: null,
        zjh: null,
        fzs: null,
        djfz: null,
        cyc: null,
        czds: null,
        sjcw: null
      },
      // 表单校验
      rules: {
      }
    };
  },
  watch: {
    // 监听路由参数变化
    '$route': {
      handler(newRoute) {
        const qk = newRoute.query.qk;
        // 重置其他查询条件
        this.queryParams = {
          pageNum: 1,
          pageSize: 20,
          qk: qk,
          jh: null,
          wjrqks: null,
          wjrqjs: null
        };
        this.getList();
      },
      immediate: true // 组件创建时立即执行一次
    }
  },
  created() {
    this.getBlockOptions();
  },
  methods: {
    /** 获取区块下拉选项 */
    getBlockOptions() {
      getQkxl().then(response => {
        // 过滤掉无效的选项
        this.blockOptions = response.data.filter(item => item && item.qk);
      });
    },

    /** 查询基础数据列表 */
    getList() {
      this.loading = true;
      listJsaa(this.queryParams).then(response => {
        this.jsaaList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.isViewMode = false; // 重置查看模式
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        jh: null,
        bqrq: null,
        bqsj: null,
        azrq: null,
        azsj: null,
        kzrq1: null,
        kzsj1: null,
        kzrq2: null,
        kzsj2: null,
        kzrq3: null,
        kzsj3: null,
        kzrq4: null,
        kzsj4: null,
        kzrq5: null,
        kzsj5: null,
        wzrq: null,
        wzsj: null,
        wjrq: null,
        wjsj: null,
        zjzq1: null,
        zjzq2: null,
        jjzq1: null,
        jjzq2: null,
        zgcssj1: null,
        zgcssj2: null,
        fgjc: null,
        qxjc: null,
        yxcd: null,
        yxshl: null,
        pjdtjc: null,
        sjjs: null,
        wjjs: null,
        wjczjs: null,
        wzcw: null,
        wjff: null,
        zjy: null,
        zjys: null,
        pjjxzs: null,
        jszl: null,
        gjzl: null,
        sgcs: null,
        zjcb: null,
        zhcb: null,
        mmzjcb: null,
        mmzhcb: null,
        ygsmc: null,
        qk: null,
        tsgyj: null,
        zjh: null,
        fzs: null,
        djfz: null,
        cyc: null,
        czds: null,
        sjcw: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.queryParams.wjrqks = '';
      this.queryParams.wjrqjs = '';
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.jh)
      this.single = selection.length !== 1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加基础数据";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const jh = row.jh || this.ids
      getJsaa(jh).then(response => {
        this.form = response.data;
        this.isViewMode = true; // 设置为查看模式
        this.open = true;
        this.title = "查看基础数据";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.jh != null) {
            updateJsaa(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addJsaa(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const jhs = row.jh || this.ids;
      this.$modal.confirm('是否确认删除基础数据编号为"' + jhs + '"的数据项？').then(function () {
        return delJsaa(jhs);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => { });
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('system/jsaa/export', {
        ...this.queryParams
      }, `井基础信息${new Date().getTime()}.xlsx`)
    }
  }
};
</script>
<style lang="scss" scoped>
.app-container {
  height: 100%;
  padding: 10px;
  box-sizing: border-box;
}

// .table-container {
//   margin-top: 10px;
// }

::v-deep .el-table__cell>.cell {
  font-weight: normal;
}

::v-deep .el-table--medium .el-table__cell {
  padding: 5px 0 !important;
}

::v-deep.pagination-container {
  padding: 5px !important;
  margin: 0;
}

::v-deep .el-form-item {
  margin-bottom: 10px !important;
}
</style>
