wupengfei
16 小时以前 9e5a47d90455c4770815d32899f660b53fc27110
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
<template>
  <NutForm
    :model-value="form"
    ref="formRef"
    :rules="rules"
    label-position="top"
    class="order-bill-recharge phone chunk-form"
  >
    <NutFormItem class="bole-form-item" prop="refundApplyRemark" required>
      <NutTextarea
        placeholder="请输入退款原因"
        placeholderClass="bole-input-text-placeholder"
        autoSize
        class="bole-input-textarea"
        v-model="form.refundApplyRemark"
        :max-length="200"
        limit-show
      >
      </NutTextarea>
    </NutFormItem>
    <!-- <div class="common-content">
      <nut-button class="recharge-button" type="primary" @click="handleSubmit">
        <div class="recharge-button-inner">
          <div class="recharge-button-text">提交</div>
        </div>
      </nut-button>
    </div> -->
  </NutForm>
</template>
 
<script setup lang="ts">
import {
  Form as NutForm,
  FormItem as NutFormItem,
  Input as NutInput,
  Textarea as NutTextarea,
} from '@nutui/nutui-taro';
import { FormRules } from '@nutui/nutui-taro/dist/types/__VUE/form/types';
import { reactive, ref, computed } from 'vue';
import {
  useLifeRechargeContext,
  LifeRechargeConstants,
  RefundUserLifePayOrderInput,
} from '@life-payment/core-vue';
import { useQueryClient } from '@tanstack/vue-query';
 
defineOptions({
  name: 'OrderApplyRefundView',
});
 
type Props = {
  id: string;
};
 
const props = withDefaults(defineProps<Props>(), {});
 
const emit = defineEmits<{
  (e: 'submitApplyRefund'): void;
}>();
 
const form = reactive({
  refundApplyRemark: '',
});
 
const rules = reactive<FormRules>({
  refundApplyRemark: [{ required: true, message: '请输入退款原因' }],
});
 
const { blLifeRecharge } = useLifeRechargeContext();
 
const formRef = ref<any>(null);
 
function handleSubmit() {
  if (!formRef.value) return;
  formRef.value.validate().then(({ valid, errors }: any) => {
    if (valid) {
      refundUserLifePayOrder();
    }
  });
}
 
const queryClient = useQueryClient();
 
async function refundUserLifePayOrder() {
  try {
    let params: RefundUserLifePayOrderInput = {
      id: props.id,
      userId: blLifeRecharge.accountModel.userId,
      refundApplyRemark: form.refundApplyRemark,
    };
    let res = await blLifeRecharge.services.refundUserLifePayOrder(params);
    emit('submitApplyRefund');
    queryClient.invalidateQueries({
      queryKey: ['blLifeRecharge/getUserLifePayOrderPage'],
    });
  } catch (error) {}
}
 
defineExpose({
  handleSubmit,
});
</script>