<!--
  @description: 专家库-创建项目管理列表
  @Modifier: 肖文龙
  @routerPath: /expert/createExtractProject-list
  @date: 2019/10/25-17:52
-->
<template>
  <div>
    <!--标题-->
    <div class="title title_border p0-16">
      <i class="el-icon-s-home" />项目列表
    </div>
    <section class="p0-16">
      <!--查询条件-->
      <div class="crud_menu_title clearfix">
        <span class="icon-line fl">查询条件</span>
      </div>
      <div :class="{'SearchContent_show':toggleSearchStatus}" class="clearfix SearchContent">
        <div class="SearchContent_leftInput fl">
          <el-form
            ref="searchForm"
            :model="searchForm"
            inline
            label-width="100px"
            label-position="left"
          >
            <el-form-item ref="tenderNo" label="招标项目编号" prop="tenderNo">
              <el-input
                v-model.trim="searchForm.tenderNo"
                placeholder="项目编号"
                style="width:220px"
                @keyup.enter.native="onSearch"
              />
            </el-form-item>
            <el-form-item ref="tenderName" label="招标项目名称" prop="tenderName">
              <el-input
                v-model.trim="searchForm.tenderName"
                style="width:220px"
                placeholder="项目名称"
                @keyup.enter.native="onSearch"
              />
            </el-form-item>
            <!--创建日期-->
            <el-form-item
              label="开始日期"
            >
              <el-date-picker
                v-model="searchForm.createBeginTime"
                :format="elValueFormatDate"
                :value-format="elValueFormatDate"
                type="date"
                placeholder="开始日期"
              />
              至
              <el-date-picker
                v-model="searchForm.createEndTime"
                :format="elValueFormatDate"
                :value-format="elValueFormatDate"
                type="date"
                placeholder="结束日期"
              />
            </el-form-item>
          </el-form>
        </div>
        <div class="fr">
          <el-button type="primary" @click="onSearch">
            搜 索
          </el-button>
          <el-button plain type="info" @click="resetForm('searchForm')">
            重 置
          </el-button>
        </div>
      </div>
      <!--查询结果-->
      <div class="crud_menu_title">
        <span class="icon-line">查询结果</span>
      </div>
      <div>
        <el-table
          ref="smallTable"
          v-loading="loading"
          :data="tableData"
          class="tableLimit"
        >
          <el-table-column
            type="index"
            label="序号"
            width="60px"
            align="center"
          />
          <el-table-column
            prop="tenderNo"
            align="center"
            label="项目编号"
            min-width="170"
          />
          <el-table-column
            header-align="center"
            prop="tenderName"
            label="项目名称"
            min-width="300"
          />
          <el-table-column
            align="center"
            prop="createTime"
            label="创建时间"
            min-width="90"
          />
          <el-table-column
            align="center"
            label="状态"
            prop="auditStatus"
            width="110"
          >
            <template slot-scope="scope">
              {{ filterDictText(statusList,scope.row.auditStatus) }}
            </template>
          </el-table-column>
          <el-table-column
            align="center"
            label="操作"
            min-width="130"
          >
            <template slot-scope="scope">
              <!--00 保存  -->
              <template v-if="scope.row.auditStatus==='00'">
                <el-link
                  type="primary"
                  @click.stop="editProject(scope.row)"
                >
                  [编辑]
                </el-link>
                <el-link
                  type="primary"
                  @click.stop="deleteProject(scope.row)"
                >
                  [删除]
                </el-link>
              </template>
              <!-- 01 生效-正式数据 -->
              <el-link
                v-if="scope.row.auditStatus==='01'"
                type="primary"
                @click.stop="preview(scope.row)"
              >
                [查看]
              </el-link>
            </template>
          </el-table-column>
        </el-table>
        <!--分页组件-->
        <pagination :pagination-data="paginationData" @change="loadData" />
      </div>
    </section>
  </div>
</template>
<script>
/* 接口*/
import { queryAllTenderInfoByTenderManager, deleteProjectDetailById } from '@/api/expert/expertscloud.js'// 项目列表 项目删除
/* 公用方法*/
import { filterObj, filterDictText, restoreInitialValue } from '@/assets/js/utils'// 常用方法
/* 混合开发方法-参数字段*/
import { ListMixin } from '@/mixins/ListMixin'// 分页
import { extractProjectMixin } from '../mixins/extractProjectMixins'// 字典信息
/* 组件*/
import pagination from '@comp/common/pagination/pagination'// 分页

export default {
  name: 'TenderProjectList',
  components: {
    pagination// 分页
  },
  mixins: [ListMixin, extractProjectMixin],
  data() {
    return {
      loading: true,
      // 搜索
      searchForm: {
        createBeginTime: '', // 创建开始时间
        createEndTime: '', // 创建结束时间
        tenderName: '', // 项目名称
        tenderNo: '' // 项目编号
      },
      tableData: []
    }
  },
  created() {
    sessionStorage.clear()
    // 获取列表信息
    this.loadData()
  },
  methods: {
    filterDictText, // 字典值替换文本通用方法
    // 获取数据
    loadData() {
      const params = this.getQueryParams()// 查询条件
      queryAllTenderInfoByTenderManager(params).then(response => {
        this.loading = false
        this.tableData = response.data.records
        this.paginationData.total = response.data.total
      }).catch(() => {
        this.loading = false
      })
    },
    // 查询条件
    getQueryParams() {
      const param = Object.assign({}, this.searchForm)
      param.pageNo = this.paginationData.pageNo
      param.pageSize = this.paginationData.pageSize
      return filterObj(param)
    },
    // 编辑
    editProject(row) {
      this.$router.push({
        name: 'createExtractProject-add',
        params: {
          id: row.id
        }
      })
    },
    // 删除项目
    deleteProject(row) {
      this.$confirm('确定删除吗?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        confirmButtonClass: 'confirmBtn',
        cancelButtonClass: 'cancelBtn',
        type: 'warning'
      }).then(() => {
        const data = {
          id: row.id // 项目id
        }
        deleteProjectDetailById(data).then(() => {
          this.$message({
            message: '删除成功',
            type: 'success'
          })
          // 获取列表信息
          this.loadData()
        })
      }).catch(() => {
      })
    },
    // 查看
    preview(row) {
      this.$router.push({
        name: 'createExtractProject-detail',
        params: {
          id: row.id
        }
      })
    },
    // 搜索
    onSearch() {
      this.paginationData.pageNo = 1
      this.paginationData.pageSize = 10
      // 获取列表信息
      this.loadData()
    },
    // 重置
    resetForm(formName) {
      restoreInitialValue(this.searchForm)
      // 获取列表信息
      this.onSearch()
    }
  }
}
</script>
<style lang="less" scoped>

</style>
