<!--
 * @Author: SunTao 328867980@qq.com
 * @Date: 2025-02-10 11:02:50
 * @LastEditors: SunTao 328867980@qq.com
 * @LastEditTime: 2025-02-10 11:35:21
 * @FilePath: \znxjxt-ui\src\views\xj\document\view-notification\index.vue
 * @Description: 单据-查看通知单页面
-->

<template>
  <div class="content">
    <el-form :model="noticeForm" ref="noticeForm" size="small" :inline="true" label-width="5rem">
      <el-form-item label="道路名称" prop="segmentId">
        <el-select v-model="noticeForm.segmentId" placeholder="请选择路段" clearable filterable>
          <el-option v-for="item in segmentList" :key="item.value" :label="item.label" :value="item.value" />
        </el-select>
      </el-form-item>
      <el-form-item label="采集时间" prop="dateTime">
        <el-date-picker v-model="dateTime" type="daterange" start-placeholder="开始日期" end-placeholder="结束日期"
          format="yyyy-MM-dd" value-format="yyyy-MM-dd" clearable />
      </el-form-item>
      <el-form-item label="病害类型" prop="paramsDefectType">
        <el-cascader v-model="paramsDefectType" :options="tableDefect" :props="{
          checkStrictly: true,
          emitPath: true,
          children: 'subTypes',
        }" clearable></el-cascader>
      </el-form-item>
      <el-form-item label="上下行" prop="inspectDirection">
        <el-select v-model="noticeForm.inspectDirection" placeholder="请选择" clearable>
          <el-option label="上行" value="0" />
          <el-option label="下行" value="1" />
        </el-select>
      </el-form-item>
      <el-form-item label="是否紧急" prop="urgentFlag">
        <el-select v-model="noticeForm.urgentFlag" placeholder="请选择" clearable>
          <el-option label="紧急" value="1" />
          <el-option label="不紧急" value="2" />
        </el-select>
      </el-form-item>
      <el-form-item label="公里桩" prop="stakeRange">
        <el-input v-model="noticeForm.stakeStart" placeholder="起始公里桩" style="width: 10rem" clearable />
        <span style="margin: 0 5px">-</span>
        <el-input v-model="noticeForm.stakeEnd" placeholder="终止公里桩" style="width: 10rem" clearable />
        <el-tooltip class="item" effect="dark" content="格式为K0000+000" placement="top">
          <i class="el-icon-info"></i>
        </el-tooltip>
      </el-form-item>
      <el-form-item label="病害长度" prop="lengthRange">
        <el-input-number v-model="noticeForm.minLen" controls-position="right" placeholder="最小长度"
          :min="0"></el-input-number>
        <span style="margin: 0 5px">-</span>
        <el-input-number v-model="noticeForm.maxLen" controls-position="right" placeholder="最大长度"
          :min="0"></el-input-number>
      </el-form-item>

      <el-form-item label="病害面积" prop="areaRange">
        <el-input-number v-model="noticeForm.minArea" controls-position="right" placeholder="最小面积"
          :min="0"></el-input-number>
        <span style="margin: 0 5px">-</span>
        <el-input-number v-model="noticeForm.maxArea" controls-position="right" placeholder="最大面积"
          :min="0"></el-input-number>
      </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-form-item>
    </el-form>
    <!-- 导航栏 -->
    <el-tabs v-model="activeName" @tab-click="handleClick">
      <el-tab-pane v-for="(item, index) in viewTableTabs" :key="`tabs-${index}`" :label="item.title" :name="item.name">
        <!-- 表格 -->
        <el-table class="notice-table" ref="noticeTable" :data="noticeList" @selection-change="handleSelectionChange"
          v-loading="loading" style="width: 100%">
          <el-table-column type="selection" width="55" align="center" />
          <el-table-column type="index" label="序号"> </el-table-column>
          <el-table-column label="路段名称" align="center" prop="segmentName" />
          <el-table-column label="采集时间" align="center" prop="createdTimeLocal">
          </el-table-column>
          <el-table-column label="病害类型" align="center" prop="defectTypeName">
          </el-table-column>
          <el-table-column label="开始桩号" align="center" prop="stakeStart" />
          <el-table-column label="结束桩号" align="center" prop="stakeEnd" />
          <el-table-column label="病害图片" align="center" prop="media">
            <template slot-scope="scope">
              <img @click="showScreenImg(scope.row)" height="50" :src="scope.row.mediaUrl" />
            </template>
          </el-table-column>
          <el-table-column label="病害长度" align="center" prop="targetLen">
            <template slot-scope="scope">
              {{ scope.row.targetLen * 1 <= 0 ? "" : `${scope.row.targetLen}米` }} </template>
          </el-table-column>
          <el-table-column label="病害面积" align="center" prop="targetArea" />
          <el-table-column label="状态" align="center" prop="noticeStatus" />
          <el-table-column label="是否紧急" align="center" prop="urgentFlag">
            <template slot-scope="scope">
              <el-button v-if="scope.row.urgentFlag === 1" type="danger" plain disabled>紧急</el-button>
              <el-button v-if="scope.row.urgentFlag === 2" type="warning" plain disabled>不紧急</el-button>
            </template>
          </el-table-column>
          <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
            <template slot-scope="scope">
              <el-button size="mini" type="text" icon="el-icon-view" @click="handleView(scope.row)">查看
              </el-button>
              <!-- <el-button
                size="mini"
                type="text"
                icon="el-icon-edit"
                @click="handleUpdate(scope.row)"
                >生成通知单
              </el-button> -->
              <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)">删除
              </el-button>
            </template>
          </el-table-column>
        </el-table>
      </el-tab-pane>
    </el-tabs>
    <!-- 分页组件 -->
    <div class="pagination-part">
      <el-pagination background :current-page.sync="pagination.page" @current-change="handleCurrentChange"
        :page-sizes="[10, 20, 30, 40]" :page-size.sync="pagination.size" @size-change="handleSizeChange"
        layout="total, sizes, prev, pager, next, jumper" :total="tableTotal">
      </el-pagination>
    </div>
  </div>
</template>

<script>
export default {
  name: "MaintenanceNotice",
  components: {},
  data() {
    return {
      // 查询表单绑定
      noticeForm: {},
      // 选择时间绑定
      dateTime: [],
      // 病害类型绑定
      paramsDefectType: [],
      // 路段下拉数据
      segmentList: [],
      // 病害类型下拉数据
      tableDefect: [],

      // 导航栏点击绑定
      activeName: "未完成",
      // 导航栏列表
      viewTableTabs: [{ title: "未完成", name: "未完成" }, { title: "已完成", name: "已完成" }],
      // 列表数据
      noticeList: [],
      // 列表加载状态
      loading: false,
      // 列表勾选绑定
      checkIds: [],
      // 列表分页绑定
      pagination: {
        page: 1,
        size: 10,
      },
      // 列表分页总数
      tableTotal: 0,
    }
  },
  mounted() {

  },
  methods: {
    /**
   * @description: 点击查询事件
   * @param {*}
   * @return {*}
   */
    handleQuery() {

    },

    /**
    * @description: 点击重置事件
    * @param {*}
    * @return {*}
    */
    resetQuery() {

    },

    /**
    * @description: 导航栏点击事件
    * @param {*}
    * @return {*}
    */
    handleClick() {

    },

    /**
    * @description: 列表选择改变事件
    * @param {*} selection
    * @return {*}
    */
    handleSelectionChange(selection) {
      this.checkIds = selection.map((item) => item.id);
    },

    /**
  * @description: 切换分页
  * @param {*} arg
  * @return {*}
  */
    handleCurrentChange(arg) {
      this.pagination.page = arg;
      this.getList();
    },

    /**
     * @description: 切换每页条数
     * @param {*} arg
     * @return {*}
     */
    handleSizeChange(arg) {
      this.pagination.size = arg;
      this.getList();
    },
  },

}
</script>

<style lang="scss" scoped>
.content {
  width: 100%;
  height: calc(100vh - 5.4rem);
  padding: 1rem;
  overflow-y: auto;
}

/* 分页样式 */
.pagination-part {
  width: 100%;
  display: flex;
  padding-top: 1rem;
  justify-content: flex-end;
}
</style>
