<!--
  @description: 招标项目-归档目录管理列表
  @Modifier: 肖文龙
  @routerPath: /bidArchived/bidArchivedTOC-list
  @date: 2019/12/05
-->
<template>
  <table-crud
    ref="tableCrud"
    :search-form="searchForm"
    search-label-width="100px"
    :menu="true"
    @on-load="loadData"
  >
    <template v-slot:header>
      查询归档目录
    </template>
    <template v-slot:search="search">
      <el-form-item label="文件目录名称">
        <el-input
          v-model.trim="searchForm.tenderNo"
          placeholder="文件目录名称"
          @keyup.enter.native="search.onSearch"
        />
      </el-form-item>
      <!--招标方式-->
      <el-form-item
        label="招标方式"
      >
        <el-select v-model="searchForm.tenderMethod" placeholder="请选择">
          <el-option
            v-for="(item,index) in bidTypeList"
            :key="index"
            :label="item.typename"
            :value="item.typecode"
          />
        </el-select>
      </el-form-item>
      <el-form-item
        label="创建时间"
      >
        <!--创建日期-->
        <el-date-picker
          v-model="createTime"
          type="daterange"
          range-separator="至"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
          @change="createTimeChange"
        />
      </el-form-item>
      <el-form-item
        label="文件目录状态"
        prop="qualificationMethod"
      >
        <el-select v-model="searchForm.qualificationMethod" placeholder="请选择" style="width: 220px">
          <el-option
            v-for="(item,index) in fileTOCStautsList"
            :key="index"
            :label="item.typename"
            :value="item.typecode"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="文件来源">
        <el-input
          v-model.trim="searchForm.tenderName"
          placeholder="文件来源"
          @keyup.enter.native="search.onSearch"
        />
      </el-form-item>
    </template>
    <template v-slot:menuLeft>
      <el-button type="primary" plain @click="archivedTOCAdd('')">
        添加文件目录
      </el-button>
    </template>
    <template v-slot:GXTable>
      <el-table
        ref="smallTable"
        v-loading="loading"
        :data="tableData"
      >
        <el-table-column
          type="index"
          label="序号"
          width="60px"
          align="center"
        />
        <el-table-column
          prop="tenderNo"
          header-align="center"
          align="left"
          label="文件目录名称"
          min-width="200"
        />
        <el-table-column
          prop="tenderName"
          align="center"
          label="模版编号"
          width="160"
        />
        <el-table-column
          :formatter="formatTenderMethod"
          header-align="center"
          prop="tenderMethod"
          label="招标方式"
          width="80"
          align="center"
        />
        <el-table-column
          align="center"
          prop="managerName"
          label="保留期限（年）"
          width="140"
        />
        <el-table-column
          header-align="center"
          label="文件来源"
          prop="packName"
          align="left"
          min-width="200"
        />
        <el-table-column
          label="是否必须归档"
          prop="packStatus"
          width="130"
        >
          <template slot-scope="scope">
            {{ filterDictText(isMustArchiveList, scope.row.packStatus) }}
          </template>
        </el-table-column>
        <el-table-column
          label="文件目录状态"
          prop="packStatus"
          width="130"
        >
          <template slot-scope="scope">
            {{ filterDictText(fileTOCStautsList, scope.row.packStatus) }}
          </template>
        </el-table-column>
        <el-table-column
          label="创建时间"
          prop="packStatus"
          width="130"
        />
        <el-table-column
          header-align="center"
          label="操作"
          width="160"
        >
          <template slot-scope="scope">
            <!-- v-if="scope.row.auditStatus==='01'" -->
            <el-link
              type="primary"
              @click.stop="archivedTOCAdd(scope.row)"
            >
              [修改]
            </el-link>
            <!-- v-if="scope.row.useStatus==='00'" -->
            <el-link
              type="primary"
              @click.stop="deleteArchived(scope.row.id)"
            >
              [删除]
            </el-link>
            <!-- v-if="scope.row.useStatus==='00'" -->
            <el-link
              type="primary"
              @click.stop="archivedTOCAdd(scope.row)"
            >
              [变更]
            </el-link>
            <!-- v-if="scope.row.auditStatus==='00'||scope.row.auditStatus==='01'" -->
            <el-link
              type="primary"
              @click.stop="changeRecord(scope.row)"
            >
              [查看变更记录]
            </el-link>
          </template>
        </el-table-column>
      </el-table>
    </template>
  </table-crud>
</template>
<script>
/* 接口*/
// import { listTenderProjectPages, removeProjectPackage } from '@/api/bidding/biddingProject'// 项目列表 项目删除
/* 公用方法*/
import { filterDictText } from '@/assets/js/utils'// 常用方法
/* 混入-字典信息 */
import { bidArchiveddGroup } from './../mixins/bidArchivedGroupMixin'// 字典信息

export default {
  name: 'BidArchivedTOCList',
  data() {
    return {
      loading: true,
      /* 字典信息-start */
      ...bidArchiveddGroup,
      bidTypeList: [], // 招标类型
      /* 字典信息-end */
      createTime: [], // 创建时间 不传给后端只做回显
      // 搜索
      searchForm: {
        auditStatus: '', // 审核状态 00:待审核 01:审核通过 02:审核不通过
        createBeginTime: '', // 创建开始时间
        createEndTime: '', // 创建结束时间
        qualificationMethod: '', // 文件目录状态
        tenderMethod: '', // 招标方式
        tenderName: '', // 文件来源
        tenderNo: '' // 文件目录名称
      },
      tableData: []
    }
  },
  created() {
    // 字典信息
    this.initGroup()
  },
  methods: {
    filterDictText, // 字典值替换文本通用方法
    // 获取字典方法
    initGroup() {
      const data = ['bidType']
      this.$store.dispatch('getGroupType', data).then(res => {
        Object.keys(res.bidTypeData).forEach((key) => {
          this[key] = res.bidTypeData[key]
        })
      })
    },
    // 表格字典值替换文本-招标方式
    formatTenderMethod(row, column, cellValue) {
      return filterDictText(this.bidTypeList, cellValue)
    },
    // 创建时间选择
    createTimeChange(val) {
      this.searchForm.createBeginTime = val[0]// 开始日期
      this.searchForm.createEndTime = val[1]// 结束日期
    },
    // 获取数据
    loadData(params, callback) {
      // listTenderProjectPages(params).then(response => {
      //   this.loading = false
      //   this.tableData = response.data.records
      //   callback(response.data.total)
      // }).catch(() => {
      this.loading = false
      // })
    },
    // 添加文件目录/修改/变更
    archivedTOCAdd(row) {
      this.$router.push({
        name: 'bidArchivedTOC-add',
        params: {
          id: row && row.id // 项目Id
        }
      })
    },
    // 查看变更记录
    changeRecord(row) {
      this.$router.push({
        name: 'archivedTOCChangeRecord-detail',
        params: {
          id: row.id // 项目Id
        }
      })
    },
    // 删除归档目录
    deleteArchived(row) {
      this.$confirm('此操作将永久删除该记录, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        confirmButtonClass: 'confirmBtn',
        cancelButtonClass: 'cancelBtn',
        type: 'warning'
      }).then(() => {
        // const data = {
        //   packId: row.id, // 归档id
        // }
        // removeProjectPackage(data).then(() => {
        //   this.$message({
        //     message: '删除成功',
        //     type: 'success'
        //   })
        //   this.$refs.tableCrud.onSearchChange()
        // })
      }).catch(() => {
      })
    }
  }
}
</script>
<style lang="less" scoped>

</style>
