<template>
<div>
  <div class="op">
 
<el-button type="primary" @click="showadd" size="mini" style="background:#148A9B;margin-left:10px" icon="el-icon-circle-plus-outline">新增</el-button>
 
</div>
  <el-table
    :data="tableData"
    style="width: 100%"
   >
     <el-table-column
      type="index"
      :index="indexMethod">
      </el-table-column>
    <el-table-column
      prop="flowname"
      label="名称"
      width="180">
    </el-table-column>
    <el-table-column
      prop="createby"
      label="创建人">
    </el-table-column>
     <el-table-column
      prop="createtime"
      label="创建时间">
    </el-table-column>
     
     <el-table-column label="操作">
      <template slot-scope="scope">
         <el-popover
          placement="right"
          width="200"
          trigger="click">
           <div class="step" style="height: 200px;">
            <el-steps direction="vertical" :active="7">
              
              <el-step v-for="index in step" :key="step[index]" :title="index.name"></el-step>
             
            </el-steps>
          </div>
        <el-button
          size="mini"
          slot="reference"
          @click="handle(scope.$index, scope.row)">详情</el-button>
          </el-popover>
       <el-button type="primary" size="mini" style="background:#148A9B" icon="el-icon-edit-outline">修改</el-button>
      </template>
    </el-table-column>
  </el-table>
  <el-pagination
  	class="pone"
      :page-size='10'
      layout="total, prev, pager, next, jumper"
      :total="totals"
      :current-page.sync="Page"
     
>
    </el-pagination>
   
   <el-dialog
  title="新增流程"
  :visible.sync="dialogVisible"
  width="60%"
 
  >
  <el-select v-model="title" clearable placeholder="请选择标题" style="margin-bottom:10px;width:100%">
    <el-option
      v-for="item in titleList"
      :key="item.value"
      :label="item.label"
      :value="item.value"
      >
    </el-option>
  </el-select>
   <el-select
   style="width:100%"
    v-model="value"
    multiple
    filterable
     @visible-change="toshow"
    default-first-option
    placeholder="请编辑流程">
    <el-option
    
      v-for="item in options"
      :key="item.value"
      :label="item.label"
      :value="item.value">
    </el-option>
  </el-select>
  <div class="iii" v-show="showiii"></div>
  <span slot="footer" class="dialog-footer">
    <el-button @click="del">取 消</el-button>
    <el-button type="primary" @click="addflow">确 定</el-button>
  </span>
</el-dialog>
  </div>
</template>

<style>
.op{
  display: flex;
  align-items: center;
 
}
  .idc{
  
    width: 200px
  }
  .el-table .warning-row {
    background: oldlace;
  }

  .el-table .success-row {
    background: #f0f9eb;
  }
  .step{
   margin: 0 auto;
   width:100px
  }
  .iii{
    height: 200px
  }
</style>

<script>
 import CryptoJS from 'crypto-js'
 import {format} from "../../utils/datetime"
 console.log(format)
// import baseUrl from "../../globe/globeUrl"
  export default {
       data() {
      return {
        showiii:false,
        //标题
        title:"",
        titleList:[{
          label:"参保登记审核流程",
          value:"1,参保登记审核流程"
        },{
          label:"信息变更审核流程",
          value:"2,信息变更审核流程"
        },{
          label:"待遇申请审核流程",
          value:"3,待遇申请审核流程"
        }],
        flowname:"",
        dialogVisible: false,
        step:'',
        Page:1,
        totals:0,
        input:"",
        info:'',
        tableData: [],
         options: [],
        value: []
      }
    },
    methods:{
      current_change(s){

      },
      toshow(s){
        this.showiii=s
      },
      del(){
        this.dialogVisible = false
      },
      //获取流程
      showadd(){
        this.options=[]
        this.dialogVisible = true
          this.$api.getlist.selectRoleName().then((res) => {
            if(res.code==200){
         for(var i in res.data){
           this.options.push({
             label:res.data[i].name,
             value:res.data[i].name
           })
         }
         }else{
           alert(JSON.stringify(res))
         }
        
        }).catch((res) => {
          
        });
      },
      //新增流程
       addflow() {
      console.log(this.value)
        for(var d in this.tableData){
          
          
          if(this.tableData[d].type==this.title.split(",")[0]){
            this.$message.error('流程已存在,请选择其它流程!');
            return
          }
          var par={
            type:this.title.split(",")[0],
            flowName:this.title.split(",")[1],
            roleIds:"",
            state:1
          }
          this.$api.getlist.insertFolwCourse(par).then((res) => {
          
        
        }).catch((res) => {
          
        });
        }
        this.dialogVisible = false
       
      },
       indexMethod(index) {
        return index +1;
      },
       handle(s,d){
         var par={
           type:d.type
         }
        this.$api.getlist.selectRoleinfo(par).then((res) => {
          this.step=res.data
         console.log( this.step)
        
        }).catch((res) => {
          
        });
        },
       
    },
    created(){
       
          this.$api.getlist.selectflowlist().then((res) => {
          this.tableData=res.data
        
        }).catch((res) => {
          
        });
    }
  }
    
</script>
