<template>
    <view class="mx3" style="padding-bottom: 100rpx">
        <view class="main-color-bg" style="height: 100rpx; margin: 0 -30rpx"></view>
        <view
            class="p3 bg-color-white"
            style="margin-top: -50rpx; border-radius: 20rpx"
        >
            <u-form :model="form" ref="uForm" :label-width="180">
                <u-form-item label="拒单理由" required prop="refuseRemark">
                    <u-input type="textarea" v-model="form.refuseRemark" />
                </u-form-item>
            </u-form>

            <view class="p-fixed d-flex j-around a-center footer">
                <view
                    class="main-color-bg text-color-white common"
                    :loading="confirmLoading"
                    @tap="submit"
                >提交</view
                >
            </view>
        </view>
        <u-toast ref="uToast" />
    </view>
</template>

<script>
export default {
    data() {
        return {
            form: {
                id: '',
                refuseRemark: '',
            },
            rules: {
                refuseRemark: [
                    {
                        required: true,
                        message: '拒单理由不能为空',
                        trigger: 'blur'
                    }
                ]
            },
            confirmLoading: false
        };
    },
    onReady() {
        this.$refs.uForm.setRules(this.rules);
    },
    onLoad(options) {
            this.form = {
                ...this.form,
                ...options
            }
    },
    methods: {
        // 提交
        submit() {
            this.$refs.uForm.validate(valid => {
                if (valid) {
                        this.$Http.rejectRepair(this.form)
                            .then((res) => {
                                this.confirmLoading = false
                                	this.$refs.uToast.show({
					title: '提交成功！',
					type: 'success',
					back : true
				})
                            }).catch(() => {
                                this.confirmLoading = false
                            })
                   
                } else {
                    console.log('验证失败');
                }
            });
        },
    }
};
</script>

<style lang="less">
page {
  background-color: #f4f4f4;
}

.footer {
  bottom: 0;
  left: 0;
  right: 0;
  background-color: #fff;
  z-index: 10000;
  border-top: 1rpx solid #f4f4f4;
  height: 100rpx;

  .common {
    padding: 15rpx 200rpx;
    border-radius: 30rpx;
    background-color: #0082ff;
    color: #fff;
  }
}
</style>
