<!--
  @description:招标计划分配-部门级-已分配
  @Modifier: Joel
  @routerPath:
  @date: 2020-6-2
-->
<template>
  <div>
    <section>
      <el-table
        ref="smallTable"
        v-loading="loading"
        :data="tableData"
      >
        <el-table-column
          type="index"
          label="序号"
          align="center"
          width="60"
        />
        <el-table-column
          prop="schemeNo"
          align="center"
          label="招标汇总/计划号"
          width="160"
        />
        <el-table-column

          header-align="center"
          prop="schemeName"
          label="招标汇总/计划名称"
          min-width="300"
        />
        <el-table-column

          header-align="center"
          prop="schemeDeptname"
          label="招标人"
          min-width="230"
        />
        <el-table-column
          header-align="center"
          prop="schemeBudget"
          label="概算金额（元）"
          min-width="140"
          align="right"
        />
        <el-table-column
          header-align="center"
          prop="purchaseClassName"
          label="采购品类"
          min-width="300"
        />
        <el-table-column
          prop="purchasLevel"
          label="采购级别"
          align="center"
          width="100"
        >
          <template slot-scope="scope">
            <span
              v-for="(item,index) in purchaseSchemeLevelList"
              v-if="scope.row.purchasLevel === item.typecode"
              :key="index"
            >{{ item.typename }}</span>
          </template>
        </el-table-column>
        <el-table-column
          prop="bidEvaluationMethod"
          label="评标办法"
          min-width="150px"
          align="center"
        >
          <template slot-scope="scope">
            <span
              v-for="(item,index) in purchasesSchemeProEvalMethodList"
              v-if="scope.row.bidEvaluationMethod === item.typecode"
              :key="index"
            >{{ item.typename }}</span>
          </template>
        </el-table-column>
        <el-table-column
          prop="biddingSchemeType"
          label="采购类别"
          align="center"
          width="100"
        >
          <template slot-scope="scope">
            <span
              v-for="(item,index) in purchaseSchemeProjectTypeList"
              v-if="scope.row.biddingSchemeType === item.typecode"
              :key="index"
            >{{ item.typename }}</span>
          </template>
        </el-table-column>
        <el-table-column
          prop="purchasType"
          label="采购类型"
          align="center"
          width="100"
        >
          <template slot-scope="scope">
            <span
              v-for="(item,index) in purchaseSchemeTypeList"
              v-if="scope.row.purchasType === item.typecode"
              :key="index"
            >{{ item.typename }}</span>
          </template>
        </el-table-column>
        <el-table-column
          label="分配至"
          prop="projectManagerName"
          width="100"
        />
        <el-table-column
          prop="comAssignedTime"
          label="分配时间"
          align="center"
          width="140"
        />
        <el-table-column label="操作" align="center" width="150" fixed="right">
          <template slot-scope="scope">
            <el-link
              type="primary"
              @click="view(scope.row.id)"
            >
              [查看]
            </el-link>
            <el-link
              type="primary"
              @click="recall(scope.row)"
            >
              [撤回]
            </el-link>
          </template>
        </el-table-column>
      </el-table>
      <!--分页组件-->
      <pagination :pagination-data="paginationData" @change="loadData" />
    </section>
  </div>
</template>

<script>
/* api */
import { getPretenderingPurchasesSchemeDepartmentPlanAdminPages, recallPurchasesSchemeByDepartmentPlanAdmin } from '@/api/purchasePlan/pretcloudPurchasescheme'
/* 组件*/
import pagination from '@comp/common/pagination/pagination' // 分页组件
/* 常用公共方法*/
import { filterObj } from '@/assets/js/utils'
/* 混入公共方法*/
import { tenderPlan } from '../../../mixins/tenderPlan'
import { ListMixin } from '@/mixins/ListMixin'
export default {
  name: 'TenderPlanalLocatedComp',
  components: {
    pagination
  },
  mixins: [ListMixin, tenderPlan],
  props: {
    // 搜索参数
    searchForm: {
      type: Object,
      default: function() {
        return {}
      }
    }
  },
  data() {
    return {
      loading: false,
      tableData: [] // 获取获取招标计划已分配列表
    }
  },
  created() {
    // 招标计划-字典信息
    this.initPurchaseSchemeWebTypeGroup()
  },
  methods: {
    // 搜索
    onSearch() {
      this.paginationData.pageNo = 1
      this.paginationData.pageSize = 10
      this.loadData()
    },
    // 公司级计划管理员分页获取获取招标计划列表
    loadData() {
      const params = this.getQueryParams(this.searchForm)// 查询条件
      getPretenderingPurchasesSchemeDepartmentPlanAdminPages(params).then(response => {
        this.loading = false
        this.tableData = response.data.records
        this.paginationData.total = response.data.total
      }).catch(() => {

      })
    },
    // 查询条件
    getQueryParams(searchForm) {
      const param = Object.assign({}, searchForm)
      param.pageNo = this.paginationData.pageNo
      param.pageSize = this.paginationData.pageSize
      param.assignedDepartmentId = this.$store.getters.info.currentDepart.id//  公司级计划管理员分配至部门id(必填，当前登录人组织机构id)
      param.deptAssignedStatus = '01'// 部门级分配状态，00未分配，01已分配(必填)
      delete param.createUserDate
      delete param.createUserDate
      return filterObj(param)
    },
    // 撤回
    recall(row) {
      this.$confirm('确认撤销本条分配记录吗？', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        confirmButtonClass: 'confirmBtn',
        cancelButtonClass: 'cancelBtn',
        type: 'warning'
      }).then(() => {
        recallPurchasesSchemeByDepartmentPlanAdmin({ id: row.id }).then(() => {
          this.$message({
            type: 'success',
            message: '撤回成功'
          })
          this.onSearch()
        })
      }).catch(() => {
      })
    },
    // 查看
    view(id) {
      this.$router.push({
        name: 'TenderPlanSectionClassAllotDetail',
        params: { id }
      })
    }
  }
}
</script>

<style scoped>

</style>
