<template>
  <vxe-modal v-model="value" id="updateRmkModal" width="400" v-loading="load" @show="show" @hide="hide" height="260" show-footer title="卖家备注">
    <by-form :propConfig="config" ref="form">
      <template v-slot:isAppend="{value}">
        <el-switch
          v-model="value.isAppend">
        </el-switch>
      </template>
    </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 { updateRemark } from '@/api/omsOrder'
@Component({components:{}})
export default class UpdateRmkModal extends Vue {
  value=false;
  load=false;
  billValue:Array<any>=[];
  config:any={
    attr:{
      rules:{
        remark: [
          { required: true, message: '卖家备注不能为空！', trigger: 'input' }
        ]
      }
    },
    columns:[
      [{
        label:'卖家备注',
        prop:'remark',
        labelWidth:'80px',
        component:'by-input',
        compConfig:{
          attr:{
            type:'textarea'
          }
        }
      }],
      [{
        label:'追加备注',
        prop:'isAppend',
        labelWidth:'80px',
        slot:true
      }]
    ]
  }
  setShow(v:boolean){
    this.value = v;
  }
  setBillValue(data:Array<any>){
    this.billValue = data;
  }
  show(){}
  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
      updateRemark(data).then(()=>{
        this.load = false;
        (this.$message({
          message:'操作成功！',
          type:'success'
        }));
        this.$emit('handleSuccess');
        this.value = false;
      }).catch(()=>{
        this.load = false;
      })
    }).catch(()=>{})
  }
}
</script>

<style lang="scss" scoped>

</style>