<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="mini" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="商机名称" prop="boName">
        <el-input
          v-model="queryParams.boName"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="商机阶段" prop="boStage">
        <el-select size="mini" v-model="queryParams.boStage" placeholder="" clearable>
          <el-option
            v-for="item in mk_bo_stage"
            :key="item.code"
            :label="item.name"
            :value="item.code"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="部门" prop="deptName">
        <el-input
          v-model="queryParams.deptName"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="赢单状态" prop="winningState">
        <el-select v-model="queryParams.winningState" placeholder="" clearable>
          <el-option
            v-for="dict in dict.type.mk_bo_winstate"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button>
        <el-button @click="btnExportAll">导出全部</el-button>
      </el-form-item>
    </el-form>
    <el-tabs v-model="activeName" @tab-click="handleClick">
      <el-tab-pane label="SPD商机" name="0">
        <el-table size="mini" :data="boList" v-loading="loading" @cell-dblclick="toBo">
          <el-table-column width="300" show-overflow-tooltip label="商机名称" align="center" prop="boName" />
          <el-table-column label="赢单率状态" align="center" prop="winningState">
            <template slot-scope="scope">
              <dict-tag
                :options="dict.type.mk_bo_winstate"
                :value="scope.row.winningState"
              />
            </template>
          </el-table-column>
          <el-table-column show-overflow-tooltip label="部门" align="center" prop="deptName" />
          <el-table-column label="商机预估值(万元)" align="center" prop="hosDiscreetValue"/>
          <el-table-column width="300" show-overflow-tooltip label="商机内容" align="center" prop="boContent"/>
          <el-table-column width="100" label="创建日期" align="center" prop="createTime" >
            <template slot-scope="scope">
              {{new Date(scope.row.createTime).Format("yyyy-MM-dd")}}
            </template>
          </el-table-column>
          <el-table-column label="商机挖掘" align="center" prop="b0_00">
            <template slot-scope="scope">
              <el-button size="medium" type="text" icon="el-icon-s-flag"/>
              <dev v-if="scope.row.b0_00">
                {{scope.row.b0_00}}
              </dev>
            </template>
          </el-table-column>
          <el-table-column label="商机审核" align="center" prop="b0_01" >
            <template slot-scope="scope">
              <dev v-if="scope.row.b0_01">
                <el-button size="medium" type="text" icon="el-icon-s-flag" />
                {{scope.row.b0_01}}
              </dev>
            </template>
          </el-table-column>
          <el-table-column label="项目立项" align="center" prop="b0_02" >
            <template slot-scope="scope">
              <dev v-if="scope.row.b0_02">
                <el-button size="medium" type="text" icon="el-icon-s-flag" />
                {{scope.row.b0_02}}
              </dev>
            </template>
          </el-table-column>
          <el-table-column label="解决方案" align="center" prop="b0_07" >
            <template slot-scope="scope">
              <dev v-if="scope.row.b0_07">
                <el-button size="medium" type="text" icon="el-icon-s-flag" />
                {{scope.row.b0_07}}
              </dev>
            </template>
          </el-table-column>
          <el-table-column label="投标与签合同" align="center" prop="b0_08" >
            <template slot-scope="scope">
              <dev v-if="scope.row.b0_08">
                <el-button size="medium" type="text" icon="el-icon-s-flag" />
                {{scope.row.b0_08}}
              </dev>
            </template>
          </el-table-column>
          <el-table-column label="完成" align="center" prop="b0_99" >
            <template slot-scope="scope">
              <dev v-if="scope.row.b0_99">
                <el-button size="medium" type="text" icon="el-icon-s-flag" />
                {{scope.row.b0_99}}
              </dev>
            </template>
          </el-table-column>
        </el-table>
      </el-tab-pane>
      <el-tab-pane label="耗材集采商机" name="1">
        <el-table size="mini" :data="boList" v-loading="loading" @cell-dblclick="toBo">
          <el-table-column width="300" show-overflow-tooltip label="商机名称" align="center" prop="boName" />
          <el-table-column label="赢单率状态" align="center" prop="winningState">
            <template slot-scope="scope">
              <dict-tag
                :options="dict.type.mk_bo_winstate"
                :value="scope.row.winningState"
              />
            </template>
          </el-table-column>
          <el-table-column show-overflow-tooltip label="部门" align="center" prop="deptName" />
          <el-table-column label="商机预估值(万元)" align="center" prop="hosDiscreetValue"/>
          <el-table-column width="300" show-overflow-tooltip label="商机内容" align="center" prop="boContent"/>
          <el-table-column width="100" label="创建日期" align="center" prop="createTime" >
            <template slot-scope="scope">
              {{new Date(scope.row.createTime).Format("yyyy-MM-dd")}}
            </template>
          </el-table-column>
          <el-table-column label="商机挖掘" align="center" prop="b1_00">
            <template slot-scope="scope">
              <dev v-if="scope.row.b1_00">
                <el-button size="medium" type="text" icon="el-icon-s-flag" />
                {{scope.row.b1_00}}
              </dev>
            </template>
          </el-table-column>
          <el-table-column label="商机审核" align="center" prop="b1_01" >
            <template slot-scope="scope">
              <dev v-if="scope.row.b1_01">
                <el-button size="medium" type="text" icon="el-icon-s-flag" />
                {{scope.row.b1_01}}
              </dev>
            </template>
          </el-table-column>
          <el-table-column label="项目立项" align="center" prop="b1_02" >
            <template slot-scope="scope">
              <dev v-if="scope.row.b1_02">
                <el-button size="medium" type="text" icon="el-icon-s-flag" />
                {{scope.row.b1_02}}
              </dev>
            </template>
          </el-table-column>
          <el-table-column label="解决方案" align="center" prop="b1_04" >
            <template slot-scope="scope">
              <dev v-if="scope.row.b1_04">
                <el-button size="medium" type="text" icon="el-icon-s-flag" />
                {{scope.row.b1_04}}
              </dev>
            </template>
          </el-table-column>
          <el-table-column label="院内决策" align="center" prop="b1_05" >
            <template slot-scope="scope">
              <dev v-if="scope.row.b1_05">
                <el-button size="medium" type="text" icon="el-icon-s-flag" />
                {{scope.row.b1_05}}
              </dev>
            </template>
          </el-table-column>
          <el-table-column label="投标与签合同" align="center" prop="b1_06" >
            <template slot-scope="scope">
              <dev v-if="scope.row.b1_06">
                <el-button size="medium" type="text" icon="el-icon-s-flag" />
                {{scope.row.b1_06}}
              </dev>
            </template>
          </el-table-column>
          <el-table-column label="完成" align="center" prop="b1_99" >
            <template slot-scope="scope">
              <dev v-if="scope.row.b1_99">
                <el-button size="medium" type="text" icon="el-icon-s-flag" />
                {{scope.row.b1_99}}
              </dev>
            </template>
          </el-table-column>
        </el-table>
      </el-tab-pane>
      <el-tab-pane label="医疗耗材商机" name="2">
        <el-table size="mini" :data="boList" v-loading="loading" @cell-dblclick="toBo">
          <el-table-column width="300" show-overflow-tooltip label="商机名称" align="center" prop="boName" />
          <el-table-column label="赢单率状态" align="center" prop="winningState">
            <template slot-scope="scope">
              <dict-tag
                :options="dict.type.mk_bo_winstate"
                :value="scope.row.winningState"
              />
            </template>
          </el-table-column>
          <el-table-column show-overflow-tooltip label="部门" align="center" prop="deptName" />
          <el-table-column label="商机预估值(万元)" align="center" prop="hosDiscreetValue"/>
          <el-table-column width="200" show-overflow-tooltip label="商机内容" align="center" prop="boContent"/>
          <el-table-column width="100" label="创建日期" align="center" prop="createTime" >
            <template slot-scope="scope">
              {{new Date(scope.row.createTime).Format("yyyy-MM-dd")}}
            </template>
          </el-table-column>
          <el-table-column label="商机挖掘" align="center" prop="b2_00">
            <template slot-scope="scope">
              <dev v-if="scope.row.b2_00">
                <el-button size="medium" type="text" icon="el-icon-s-flag" />
                {{scope.row.b2_00}}
              </dev>
            </template>
          </el-table-column>
          <el-table-column label="需求信息收集" align="center" prop="b2_01">
            <template slot-scope="scope">
              <dev v-if="scope.row.b2_01">
                <el-button size="medium" type="text" icon="el-icon-s-flag" />
                {{scope.row.b2_01}}
              </dev>
            </template>
          </el-table-column>
          <el-table-column label="商机审核" align="center" prop="b2_02" >
            <template slot-scope="scope">
              <dev v-if="scope.row.b2_02">
                <el-button size="medium" type="text" icon="el-icon-s-flag" />
                {{scope.row.b2_02}}
              </dev>
            </template>
          </el-table-column>
          <el-table-column label="项目立项" align="center" prop="b2_03" >
            <template slot-scope="scope">
              <dev v-if="scope.row.b2_03">
                <el-button size="medium" type="text" icon="el-icon-s-flag" />
                {{scope.row.b2_03}}
              </dev>
            </template>
          </el-table-column>
          <el-table-column label="解决方案" align="center" prop="b2_05" >
            <template slot-scope="scope">
              <dev v-if="scope.row.b2_05">
                <el-button size="medium" type="text" icon="el-icon-s-flag" />
                {{scope.row.b2_05}}
              </dev>
            </template>
          </el-table-column>
          <el-table-column label="临床申请" align="center" prop="b2_06" >
            <template slot-scope="scope">
              <dev v-if="scope.row.b2_06">
                <el-button size="medium" type="text" icon="el-icon-s-flag" />
                {{scope.row.b2_06}}
              </dev>
            </template>
          </el-table-column>
          <el-table-column label="院内决策" align="center" prop="b2_07" >
            <template slot-scope="scope">
              <dev v-if="scope.row.b2_07">
                <el-button size="medium" type="text" icon="el-icon-s-flag" />
                {{scope.row.b2_07}}
              </dev>
            </template>
          </el-table-column>
          <el-table-column label="投标与签合同" align="center" prop="b2_08" >
            <template slot-scope="scope">
              <dev v-if="scope.row.b2_08">
                <el-button size="medium" type="text" icon="el-icon-s-flag" />
                {{scope.row.b2_08}}
              </dev>
            </template>
          </el-table-column>
          <el-table-column label="完成" align="center" prop="b2_99" >
            <template slot-scope="scope">
              <dev v-if="scope.row.b2_99">
                <el-button size="medium" type="text" icon="el-icon-s-flag" />
                {{scope.row.b2_99}}
              </dev>
            </template>
          </el-table-column>
        </el-table>
      </el-tab-pane>
      <el-tab-pane label="医疗设备商机" name="3">
        <el-table size="mini" :data="boList" v-loading="loading" @cell-dblclick="toBo">
          <el-table-column width="300" show-overflow-tooltip label="商机名称" align="center" prop="boName" />
          <el-table-column label="赢单率状态" align="center" prop="winningState">
            <template slot-scope="scope">
              <dict-tag
                :options="dict.type.mk_bo_winstate"
                :value="scope.row.winningState"
              />
            </template>
          </el-table-column>
          <el-table-column show-overflow-tooltip label="部门" align="center" prop="deptName" />
          <el-table-column label="商机预估值(万元)" align="center" prop="hosDiscreetValue"/>
          <el-table-column width="300" show-overflow-tooltip label="商机内容" align="center" prop="boContent"/>
          <el-table-column width="100" label="创建日期" align="center" prop="createTime" >
            <template slot-scope="scope">
              {{new Date(scope.row.createTime).Format("yyyy-MM-dd")}}
            </template>
          </el-table-column>
          <el-table-column label="商机挖掘" align="center" prop="b3_00">
            <template slot-scope="scope">
              <dev v-if="scope.row.b3_00">
                <el-button size="medium" type="text" icon="el-icon-s-flag" />
                {{scope.row.b3_00}}
              </dev>
            </template>
          </el-table-column>
          <el-table-column label="需求信息收集" align="center" prop="b3_01">
            <template slot-scope="scope">
              <dev v-if="scope.row.b3_01">
                <el-button size="medium" type="text" icon="el-icon-s-flag" />
                {{scope.row.b3_01}}
              </dev>
            </template>
          </el-table-column>
          <el-table-column label="商机审核" align="center" prop="b3_02" >
            <template slot-scope="scope">
              <dev v-if="scope.row.b3_02">
                <el-button size="medium" type="text" icon="el-icon-s-flag" />
                {{scope.row.b3_02}}
              </dev>
            </template>
          </el-table-column>
          <el-table-column label="项目立项" align="center" prop="b3_03" >
            <template slot-scope="scope">
              <dev v-if="scope.row.b3_03">
                <el-button size="medium" type="text" icon="el-icon-s-flag" />
                {{scope.row.b3_03}}
              </dev>
            </template>
          </el-table-column>
          <el-table-column label="解决方案" align="center" prop="b3_06" >
            <template slot-scope="scope">
              <dev v-if="scope.row.b3_06">
                <el-button size="medium" type="text" icon="el-icon-s-flag" />
                {{scope.row.b3_06}}
              </dev>
            </template>
          </el-table-column>
          <el-table-column label="投标与签合同" align="center" prop="b3_07" >
            <template slot-scope="scope">
              <dev v-if="scope.row.b3_07">
                <el-button size="medium" type="text" icon="el-icon-s-flag" />
                {{scope.row.b3_07}}
              </dev>
            </template>
          </el-table-column>
          <el-table-column label="完成" align="center" prop="b3_99" >
            <template slot-scope="scope">
              <dev v-if="scope.row.b3_99">
                <el-button size="medium" type="text" icon="el-icon-s-flag" />
                {{scope.row.b3_99}}
              </dev>
            </template>
          </el-table-column>
        </el-table>
      </el-tab-pane>
      <el-tab-pane label="军队医疗设备商机" name="4">
        <el-table size="mini" :data="boList" v-loading="loading" @cell-dblclick="toBo">
          <el-table-column width="300" show-overflow-tooltip label="商机名称" align="center" prop="boName" />
          <el-table-column label="赢单率状态" align="center" prop="winningState">
            <template slot-scope="scope">
              <dict-tag
                :options="dict.type.mk_bo_winstate"
                :value="scope.row.winningState"
              />
            </template>
          </el-table-column>
          <el-table-column show-overflow-tooltip label="部门" align="center" prop="deptName" />
          <el-table-column label="商机预估值(万元)" align="center" prop="hosDiscreetValue"/>
          <el-table-column width="300" show-overflow-tooltip label="商机内容" align="center" prop="boContent"/>
          <el-table-column width="100" label="创建日期" align="center" prop="createTime" >
            <template slot-scope="scope">
              {{new Date(scope.row.createTime).Format("yyyy-MM-dd")}}
            </template>
          </el-table-column>
          <el-table-column label="商机挖掘" align="center" prop="b4_00">
            <template slot-scope="scope">
              <dev v-if="scope.row.b4_00">
                <el-button size="medium" type="text" icon="el-icon-s-flag" />
                {{scope.row.b4_00}}
              </dev>
            </template>
          </el-table-column>
          <el-table-column label="需求信息收集" align="center" prop="b4_01">
            <template slot-scope="scope">
              <dev v-if="scope.row.b4_01">
                <el-button size="medium" type="text" icon="el-icon-s-flag" />
                {{scope.row.b4_01}}
              </dev>
            </template>
          </el-table-column>
          <el-table-column label="商机审核" align="center" prop="b4_02" >
            <template slot-scope="scope">
              <dev v-if="scope.row.b4_02">
                <el-button size="medium" type="text" icon="el-icon-s-flag" />
                {{scope.row.b4_02}}
              </dev>
            </template>
          </el-table-column>
          <el-table-column label="项目立项" align="center" prop="b4_03" >
            <template slot-scope="scope">
              <dev v-if="scope.row.b4_03">
                <el-button size="medium" type="text" icon="el-icon-s-flag" />
                {{scope.row.b4_03}}
              </dev>
            </template>
          </el-table-column>
          <el-table-column label="解决方案" align="center" prop="b4_06" >
            <template slot-scope="scope">
              <dev v-if="scope.row.b4_06">
                <el-button size="medium" type="text" icon="el-icon-s-flag" />
                {{scope.row.b4_06}}
              </dev>
            </template>
          </el-table-column>
          <el-table-column label="投标与签合同" align="center" prop="b4_07" >
            <template slot-scope="scope">
              <dev v-if="scope.row.b4_07">
                <el-button size="medium" type="text" icon="el-icon-s-flag" />
                {{scope.row.b4_07}}
              </dev>
            </template>
          </el-table-column>
          <el-table-column label="完成" align="center" prop="b4_99" >
            <template slot-scope="scope">
              <dev v-if="scope.row.b4_99">
                <el-button size="medium" type="text" icon="el-icon-s-flag" />
                {{scope.row.b4_99}}
              </dev>
            </template>
          </el-table-column>
        </el-table>
      </el-tab-pane>
      <el-tab-pane label="工程商机" name="5">
        <el-table size="mini" :data="boList" v-loading="loading" @cell-dblclick="toBo">
          <el-table-column width="300" show-overflow-tooltip label="商机名称" align="center" prop="boName" />
          <el-table-column label="赢单率状态" align="center" prop="winningState">
            <template slot-scope="scope">
              <dict-tag
                :options="dict.type.mk_bo_winstate"
                :value="scope.row.winningState"
              />
            </template>
          </el-table-column>
          <el-table-column show-overflow-tooltip label="部门" align="center" prop="deptName" />
          <el-table-column label="商机预估值(万元)" align="center" prop="hosDiscreetValue"/>
          <el-table-column width="300" show-overflow-tooltip label="商机内容" align="center" prop="boContent"/>
          <el-table-column width="100" label="创建日期" align="center" prop="createTime" >
            <template slot-scope="scope">
              {{new Date(scope.row.createTime).Format("yyyy-MM-dd")}}
            </template>
          </el-table-column>
          <el-table-column label="需求信息收集" align="center" prop="b5_00">
            <template slot-scope="scope">
              <dev v-if="scope.row.b5_00">
                <el-button size="medium" type="text" icon="el-icon-s-flag" />
                {{scope.row.b5_00}}
              </dev>
            </template>
          </el-table-column>
          <el-table-column label="商机审核" align="center" prop="b5_01" >
            <template slot-scope="scope">
              <dev v-if="scope.row.b5_01">
                <el-button size="medium" type="text" icon="el-icon-s-flag" />
                {{scope.row.b5_01}}
              </dev>
            </template>
          </el-table-column>
          <el-table-column label="项目立项" align="center" prop="b5_02" >
            <template slot-scope="scope">
              <dev v-if="scope.row.b5_02">
                <el-button size="medium" type="text" icon="el-icon-s-flag" />
                {{scope.row.b5_02}}
              </dev>
            </template>
          </el-table-column>
          <el-table-column label="考察" align="center" prop="b5_03" >
            <template slot-scope="scope">
              <dev v-if="scope.row.b5_03">
                <el-button size="medium" type="text" icon="el-icon-s-flag" />
                {{scope.row.b5_03}}
              </dev>
            </template>
          </el-table-column>
          <el-table-column label="解决方案" align="center" prop="b5_04" >
            <template slot-scope="scope">
              <dev v-if="scope.row.b5_04">
                <el-button size="medium" type="text" icon="el-icon-s-flag" />
                {{scope.row.b5_04}}
              </dev>
            </template>
          </el-table-column>
          <el-table-column label="投标与签合同" align="center" prop="b5_05" >
            <template slot-scope="scope">
              <dev v-if="scope.row.b5_05">
                <el-button size="medium" type="text" icon="el-icon-s-flag" />
                {{scope.row.b5_05}}
              </dev>
            </template>
          </el-table-column>
          <el-table-column label="完成" align="center" prop="b5_99" >
            <template slot-scope="scope">
              <dev v-if="scope.row.b5_99">
                <el-button size="medium" type="text" icon="el-icon-s-flag" />
                {{scope.row.b5_99}}
              </dev>
            </template>
          </el-table-column>
        </el-table>
      </el-tab-pane>
    </el-tabs>

    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
      class="paginationClass"
    />
  </div>
</template>


<script>
import { listBasic } from "@/api/business/spd/bo/statement";
import { getBoNodeListByType } from "@/api/business/spd/bo/boNode";

export default {
  name: "statement1",
  dicts: [
    "mk_bo_type",
    "mk_bo_source",
    "mk_bo_winstate"
  ],
  data() {
    return {
      // 遮罩层
      loading: true,
      //查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        boType: null,
        boName: null,
        customerName: null,
        principalName: null,
        boSource: null,
      },
      // 显示搜索条件
      showSearch: true,
      //列表数据
      boList:[],
      //当前页签
      activeName: '0',
      //分页参数
      total:0,
      loading: true,
      //阶段列表
      mk_bo_stage: [],
    };
  },
  created() {
    this.queryParams.winningState = '0';
    var e = {
      name: '0',
    }
    this.handleClick(e);
  },
  methods: {
    /** 查询任务列表 */
    getList() {
      var e = {
        name: this.activeName,
      }
      this.handleClick(e);
    },
    handleClick(e) {
      this.loading = true;
      console.log('e',e);
      this.queryParams.boType = e.name;
      this.boTypeChange(e.name);
      listBasic(this.queryParams).then(response => {
        this.boList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    //跳转到商机详情
    toBo(row){
      this.$router.push(`/basic/spd/bo/basic/details/${row.id}`);
    },
    //导出全部
    btnExportAll(){
      this.download(
        "/mk/bo/statement/exportAll",
        { pageNum: 1,
          pageSize: 9999999,
        },
        `商机阶段_${new Date().getTime()}.xlsx`
      );
    },
    //查询参数商机类型改变后
    boTypeChange(boType) {
      if (boType) {
        getBoNodeListByType(boType).then((response) => {
          this.mk_bo_stage = response.rows;
        });
      } else {
        this.mk_bo_stage = [];
      }
    },
  }
};
</script>

<style lang="scss" scoped>
.btn_grooup {
  margin-bottom: 10px;
  display: flex;
  justify-content: flex-end;
}
.paginationClass {
  z-index: 500;
  position: fixed;
  bottom: 10px;
  right: 10px;
  width: 100%;
  line-height: var(--footer-height);
  color: #fff;
}
</style>