<template>
  <vxe-modal v-model="value" id="updateSalerModal" width="400" v-loading="load" @hide="hide" height="200" show-footer title="修改业务员">
    <by-form :propConfig="config" ref="form"></by-form>
    <template #footer>
      <div class="btn">
        <el-button plain size="small" @click="value = false">取消</el-button>
        <el-button type="primary" size="small" @click="btn">确定</el-button>
      </div>
    </template>
  </vxe-modal>
</template>

<script lang="ts">
import { Component, Prop, Vue, Watch } from "vue-property-decorator";
import { setCreateUser } from '@/api/omsOrder'
@Component({components:{}})
export default class UpdateSalerModal extends Vue {
  value=false;
  load=false;
  billValue:Array<any>=[];
  config:any={
    attr:{
      rules:{
        createUser: [
          { required: true, message: '业务员不能为空！', trigger: 'input' }
        ]
      }
    },
    columns:[
      [{
        label:'业务员',
        prop:'createUser',
        labelWidth:'80px',
        component:'by-input',
        compConfig:{
          attr:{
            placeholder:'请输入业务员'
          }
        }
      }]
    ]
  }
  setShow(v:boolean){
    this.value = v;
  }
  setBillValue(data:Array<any>){
    this.billValue = data;
  }
  hide(){
    (this.$refs.form as any).clearValidate();
    (this.$refs.form as any).clearValue();
  }
  btn(){
    (this.$refs.form as any).validate().then(()=>{
      let data = (this.$refs.form as any).getValue();
      data.idList = this.billValue;
      this.load = true
      setCreateUser(data).then(()=>{
        this.load = false;
        (this.$message({
          message:'操作成功！',
          type:'success'
        }));
        this.$emit('handleSuccess');
        this.value = false;
      }).catch(()=>{
        this.load = false;
      })
    })
  }
}
</script>

<style lang="scss" scoped>

</style>