<template>
  <el-dialog
    :title="title"
    :visible.sync="dialogVisible"
    width="55%"
    height="300px"
  >
    <div class="table">
      <el-form :model="ruleForm" ref="ruleForm" label-width="100px" class="demo-ruleForm" >
        <el-row :gutter="26">
          <el-col :span="6">
            <el-form-item label="业务人员审核" prop="auditUser1" >
              <el-select v-model="ruleForm.auditUser1" filterable placeholder="请选择" style="width: 200px">
                <el-option
                  v-for="item in list"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>

        </el-row>
      </el-form>
      <div style="display:flex;justify-content: center">
        <el-button type="primary" @click="submitForm('ruleForm')" >提交审核</el-button>
      </div>
    </div>
  </el-dialog>
</template>

<script>
import  {commitAudit,getUserList} from '@/api/utils'
// const rules={
//   auditUser1: [
//     { required: true, message: '请输入活动名称', trigger: 'blur' },
//   ],
//     id: [
//     { required: true, message: '请选择活动区域', trigger: 'change' }
//   ],
// }
export default {
  data() {
    return {
      title: "提交审核",
      deptList:[],
      dialogVisible: false,
      loading: false,
      pageNo:1,
      list:[],
      pageSize:10,
      total:0,
      ruleForm: {
        auditUser1: '',
        auditUser2:'',
        auditUser3:'',
        ids: [],
      },
    };
  },
  created() {
   this.getUser()
  },
  methods: {
    async getUser(){
        let res= await getUserList()
        let data=[]
        res.data.forEach(item=>{
          data.push({
            label:item.userName+'_'+item.nickName,
            value:item.userName
          })
        })
      this.list=data
    },
    handle(row){
      this.dialogVisible=true
      this.list=[]
      if(row.length>0){
        row.forEach(item=>{
          this.ruleForm.ids.push(item.id)
        })
      }
      this.ruleForm.auditUser1=''
      this.getUser()
    },
    async submitForm(){
       let res = await  commitAudit(this.ruleForm)
       if (res.code==200){
         this.$message.success('提交成功')
         this.dialogVisible=false
         this.$emit('headel')
       }else {
         this.$message.error('提交失败')
       }
    },
  }
};
</script>

<style lang="scss" scoped>
.demo-ruleForm{
  position: relative;
}

</style>
