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
103
104
105
<template>
<a-form :label-col="{ span: 4 }" :wrapper-col="{ span: 14 }" >
<a-form-item label="支付域名配置" v-bind="validateInfos.alName">
<a-input v-model:value="modelRef.alName" />
</a-form-item>
<a-form-item :wrapper-col="{ span: 14, offset: 4 }">
<a-button type="primary" @click.prevent="onSubmit">提交</a-button>
</a-form-item>
</a-form>
</template>
<script lang="ts" setup>
import { defineExpose, reactive, toRaw,onMounted,ref } from "vue";
import { Form,message} from "ant-design-vue";
import { onCreaterealmName,onSearchSelectrealmName,onUpdaterealmName } from "@/api/index";
const useForm = Form.useForm;
const uid = ref<Number>(0)
const id = ref<any>('0')
const modelRef = reactive({
alName: "",
});
const { resetFields, validate, validateInfos } = useForm(
modelRef,
reactive({
alName: [
{
required: true,
message: "请输入支付宝域名配置",
},
],
})
);
const onSubmit = () => {
validate()
.then(async(res) => {
const params:Object = {
id:id.value,
remarks:'' ,
uid: 1,
url: toRaw(modelRef).alName
}
if(uid){
const data:any = await onUpdaterealmName(JSON.stringify(params))
if(data.state === 1){
message.success('更新成功');
onSreach(1)
}
}else{
const data:any = await onCreaterealmName(JSON.stringify(params))
if(data.state === 1){
message.success('创建成功');
onSreach(1)
}
}
})
.catch((err) => {
console.log("error", err);
});
};
const onSreach = async(uid:any)=>{
const data = await onSearchSelectrealmName(1)
modelRef.alName = data.data[0].url
uid.value = data.data[0].userid
id.value = data.data[0].id
console.log(uid,id,'ididid');
}
onMounted(async()=>{
await onSreach(1)
})
defineExpose({
validateInfos,
modelRef,
onSubmit,
onSreach,
uid,
id
});
</script>
<style>
.dynamic-delete-button {
cursor: pointer;
position: relative;
top: 4px;
font-size: 24px;
color: #999;
transition: all 0.3s;
}
.dynamic-delete-button:hover {
color: #777;
}
.dynamic-delete-button[disabled] {
cursor: not-allowed;
opacity: 0.5;
}
</style>
<style scoped lang="less">
.addform {
}
</style>