<template>
  <div>
    <el-button type="primary" size="mini" @click="checkBtn">审 核</el-button>
    <el-dialog :visible.sync="drawer" append-to-body width="50%">
      <el-row :gutter="20">
        <el-form :model="form" :rules="rules" ref="form" label-width="90px" label-position="right" size="mini">
          <el-col :span="24">
            <el-form-item label="退款金额" prop="returnamount">
              <el-input v-model="form.returnamount" placeholder="退款金额"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="扣款金额" prop="payamount">
              <el-input v-model="form.payamount" placeholder="退款金额"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="物流单号" prop="logisticno">
              <el-input v-model="form.logisticno" placeholder="请填写物流单号"></el-input>
            </el-form-item>
          </el-col>
        </el-form>
      </el-row>
      <div class="dialog-footer">
        <el-button size="small" @click="drawer = false" class="normal-btn-width">取 消</el-button>
        <el-button size="small" type="warning" @click="onSubmit" class="normal-btn-width btn-warning">确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
export default {
  name: '',
  props:['data'],
  data() {
    return {
      drawer:false,
      form:{
        "sa_aftersalesmagid":'',
        "logisticno":"",
        "returnamount":'',
        "payamount":''
      },
      rules:{
        // logisticno:[
        //   { required: true, message: '请填写物流号', trigger: 'blur'},
        // ],
        // returnamount:[
        //   { required: true, message: '请填写退款金额', trigger: 'blur'}
        // ]
      }
    };
  },
  computed:{
  },
  watch:{
  },
  methods: {
    checkBtn () {
      this.drawer = true
      console.log('触发');
      
    },
    onSubmit (status) {
      this.$refs['form'].validate(async (valid) => {
        if (!valid) return false
        this.form.sa_aftersalesmagid = this.$route.query.id
        let res2 = await this.$api.requested({
          "id": 20230104161103,
          "version":1,
          "content": {
              "sa_aftersalesmagid":this.$route.query.id,
              "ischeck":true
          }
        })
        this.tool.showMessage(res2,async () => {
          const res = await this.$api.requested({
            "id": "20230105100203",
            "content": this.form
          })
          this.tool.showMessage(res,()=>{
            this.$emit('onSuccess')
            this.$refs['form'].resetFields();
            this.drawer = false
          })
        })
      })
    }
  },
};
</script>

<style scoped>

</style>
