<!--
  @description:踏勘通知列表
  @Modifier: haoFx
  @routerPath:/bidding/projectDrive/projectExtend/projectExtendNoticeList
  @date: 2020/3/4-9:35
  isCanOperate: true可以操作 false不可以查看只有查看权限
-->
<template>
  <div>
    <section class="main">
      <el-button
        v-if="tenderBase.isCanOperate"
        type="primary"
        class="mb10"
        @click="addProjectExtendNotice"
      >
        新增踏勘现场通知
      </el-button>
      <div>
        <el-table
          v-loading="loading"
          :data="tableData"

          width="100%"
        >
          <el-table-column
            type="index"
            label="序号"
            width="60px"
            align="center"
          />
          <el-table-column
            header-align="center"
            prop="explorationNum"
            label="踏勘场次"
            width="160px"
          />
          <el-table-column
            header-align="center"
            prop="noticeName"
            label="通知名称"
          />
          <el-table-column
            header-align="center"
            prop="packNames"
            label="关联标段"
          />
          <el-table-column
            prop="gatherTime"
            label="集合时间"
            width="140"
            align="center"
          >
            <template slot-scope="scope">
              {{ scope.row.gatherTime && $Moment(scope.row.gatherTime).format(momentDateTime) }}
            </template>
          </el-table-column>
          <el-table-column
            label="答疑会时间"
            prop="meetTime"
            align="center"
            width="140"
          >
            <template slot-scope="scope">
              {{ scope.row.meetTime && $Moment(scope.row.meetTime).format(momentDateTime) }}
            </template>
          </el-table-column>
          <el-table-column
            label="状态"
            prop="useStatus"
            align="center"
            width="90"
          >
            <template slot-scope="scope">
              <span v-if="scope.row.useStatus==='00'" class="status4">临时</span>
              <span v-if="scope.row.useStatus==='01'" class="status2">正式</span>
              <span v-if="scope.row.useStatus==='02'" class="status3">作废</span>
            </template>
          </el-table-column>
          <el-table-column
            label="踏勘现场截止时间"
            align="center"
            width="140"
            prop="explorationSceneEndTime"
          >
            <template slot-scope="scope">
              {{ scope.row.explorationSceneEndTime && $Moment(scope.row.explorationSceneEndTime).format(momentDateTime) }}
            </template>
          </el-table-column>
          <el-table-column
            header-align="center"
            label="操作"
            width="150"
          >
            <template slot-scope="scope">
              <el-link
                v-if="scope.row.useStatus ==='01'"
                type="primary"
                @click="examine(scope.row)"
              >
                [查看]
              </el-link>
              <template v-if="tenderBase.isCanOperate">
                <el-link
                  v-if="scope.row.useStatus ==='01'"
                  type="primary"
                  @click="viewSurveyRecords(scope.row)"
                >
                  [踏勘记录]
                </el-link>
                <el-link
                  v-if="scope.row.useStatus ==='00'"
                  type="primary"
                  @click="edit(scope.row)"
                >
                  [编辑]
                </el-link>
                <el-link
                  v-if="scope.row.useStatus ==='00'"
                  type="primary"
                  @click="deleteExplorationInfo(scope.row,scope.$index)"
                >
                  [删除]
                </el-link>
              </template>
            </template>
          </el-table-column>
        </el-table>
        <!--分页组件-->
        <pagination :pagination-data="paginationData" @change="getProjectExtendList" />
      </div>
    </section>
  </div>
</template>

<script>
/* api*/
import { listTenderExplorationPages, removeExplorationById } from '@api/bidding/exploration'
/* 混合开发方法-参数字段*/
import { ListMixin } from '@/mixins/ListMixin'// 分页
/* 组件*/
import pagination from '@comp/common/pagination/pagination'
/* 公用方法*/
import { filterObj } from '@/assets/js/utils'// 常用方法

// 分页
export default {
  name: 'Projectextend',
  components: {
    pagination// 分页
  },
  mixins: [ListMixin],
  data() {
    return {
      loading: true,
      tenderBase: this.$store.getters.tenderBase, // 项目信息
      // 踏勘列表
      tableData: [],
      searchForm: {
        tenderId: this.$route.query.id // 项目id
      }
    }
  },
  created() {
    this.getProjectExtendList()
  },
  methods: {
    // 获取踏勘列表
    getProjectExtendList() {
      const params = this.getQueryParams()// 查询条件
      listTenderExplorationPages(params).then(res => {
        this.tableData = res.data.records
        this.paginationData.total = res.data.total
        this.loading = false
      }).catch(() => {
        this.loading = false
      })
    },
    // 查询条件
    getQueryParams() {
      const param = Object.assign({}, this.searchForm)
      param.pageNo = this.paginationData.pageNo
      param.pageSize = this.paginationData.pageSize
      return filterObj(param)
    },
    // 新增踏勘现场通知
    addProjectExtendNotice() {
      const data = {
        ... this.$route.query
      }
      delete data.explorationId
      this.$router.push({
        path: '/bidding/projectDrive/projectExtend/bidProjectExtendAdd',
        query: data
      })
    },
    // 查看
    examine(row) {
      this.$router.push({
        path: '/bidding/projectDrive/projectExtend/bidProjectExtendDetail',
        query: {
          ... this.$route.query,
          explorationId: row.id // 踏勘id
        }
      })
    },
    // 踏勘记录
    viewSurveyRecords(row) {
      this.$router.push({
        path: '/bidding/projectDrive/projectExtend/projectExtendRecord',
        query: {
          ... this.$route.query,
          explorationId: row.id // 踏勘id
        }
      })
    },
    // 编辑
    edit(row) {
      this.$router.push({
        path: '/bidding/projectDrive/projectExtend/bidProjectExtendAdd',
        query: {
          ... this.$route.query,
          explorationId: row.id // 踏勘id
        }
      })
    },
    // 删除
    deleteExplorationInfo(row, index) {
      this.$confirm('此操作将删除该记录, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        confirmButtonClass: 'confirmBtn',
        cancelButtonClass: 'cancelBtn',
        type: 'warning'
      }).then(() => {
        removeExplorationById(row.id).then(res => {
          this.tableData.splice(index, 1)
          this.$message({
            type: 'success',
            message: '删除成功'
          })
        }).catch(() => {

        })
      }).catch(() => {
      })
    }
  }
}
</script>

<style lang="less" scoped>

</style>

