EnterpriseInfo.vue
2.16 KB
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
<template>
<div class="card">
<Card :bordered="false" class="card"> <BasicForm @register="registerForm" /></Card>
<Loading v-bind="compState" />
<a-button
@click="handleUpdateInfo"
size="large"
type="primary"
style="margin-top: 20px; background-color: #2950f7; border-radius: 5px"
>更新基本信息</a-button
>
</div>
</template>
<script lang="ts">
import { defineComponent, onMounted, ref } from 'vue';
import { Card } from 'ant-design-vue';
import { BasicForm, useForm } from '/@/components/Form/index';
import { schemas } from '../config/enterPriseInfo.config';
import { getEnterPriseDetail, updateEnterPriseDetail } from '/@/api/oem/index';
import { Loading } from '/@/components/Loading';
import { useMessage } from '/@/hooks/web/useMessage';
export default defineComponent({
components: {
Card,
BasicForm,
Loading,
},
setup() {
const compState = ref({
absolute: false,
loading: false,
tip: '拼命加载中...',
});
const [registerForm, { getFieldsValue, setFieldsValue }] = useForm({
labelWidth: 80,
schemas,
showResetButton: false,
showSubmitButton: false,
wrapperCol: {
span: 10,
},
});
const { createMessage } = useMessage();
const handleUpdateInfo = async () => {
try {
compState.value.loading = true;
const fieldsValue = getFieldsValue();
await updateEnterPriseDetail({
...fieldsValue,
codeProv: fieldsValue.nameProv,
codeCity: fieldsValue.nameCity,
codeCoun: fieldsValue.nameCoun,
codeTown: fieldsValue.nameTown,
});
compState.value.loading = false;
createMessage.success('更新信息成功');
} catch (e) {
createMessage.error('更新信息失败');
}
};
onMounted(async () => {
const res = await getEnterPriseDetail();
setFieldsValue(res);
});
return {
registerForm,
compState,
handleUpdateInfo,
};
},
});
</script>
<style lang="less" scoped></style>