Files

57 lines
1.5 KiB
Vue
Raw Normal View History

2023-06-07 10:44:31 +08:00
<template>
<div class="app-container">
<el-card shadow="always" style="width: 55%; margin: 0 auto">
2023-06-13 13:40:54 +08:00
<agent-form ref="agentFormRef" v-model="form" is-add />
2023-06-07 10:44:31 +08:00
<div :style="{ marginLeft: labelWidth + 'px' }">
2023-07-19 09:22:11 +08:00
<el-button @click="$router.go(-1)"
>{{ t("admin.common.cancel") }}
</el-button>
<el-button type="primary" @click="submitForm"
>{{ t("admin.common.submit") }}
</el-button>
2023-06-07 10:44:31 +08:00
</div>
</el-card>
</div>
</template>
<script setup>
2023-06-13 13:40:54 +08:00
import AgentForm from "@/views/components/AgentForm";
import { reactive, ref, toRefs } from "vue";
2023-06-19 17:25:50 +08:00
import { ElMessage } from "element-plus";
import { insertCasBroker } from "@/api/admin/agent/account";
2023-07-19 09:22:11 +08:00
import { useI18n } from "vue-i18n";
import { useRouter } from "vue-router";
2023-06-07 10:44:31 +08:00
2023-07-19 09:22:11 +08:00
const { t } = useI18n();
2023-06-19 17:25:50 +08:00
const router = useRouter();
2023-06-07 10:44:31 +08:00
const props = defineProps({
labelWidth: {
type: Number,
2023-06-13 13:40:54 +08:00
default: 120,
},
});
2023-06-07 10:44:31 +08:00
const data = reactive({
form: {
industrys: [],
2023-06-19 17:25:50 +08:00
idImage: [],
2023-06-13 13:40:54 +08:00
},
});
const { form } = toRefs(data);
const agentFormRef = ref();
2023-06-07 10:44:31 +08:00
const submitForm = async () => {
2023-06-13 13:40:54 +08:00
if (!agentFormRef.value) return;
const valid = await agentFormRef.value.validateForm();
2023-06-07 10:44:31 +08:00
if (valid) {
2023-06-19 17:25:50 +08:00
form.value.idCardPics = form.value.idImage.join(",");
form.value.keyword = form.value.keywords.join(",");
insertCasBroker(form.value).then(() => {
2023-07-27 17:31:39 +08:00
ElMessage.success(t("admin.common.addSuccess"));
2023-06-19 17:25:50 +08:00
router.push({
path: "/identity/index",
});
});
2023-06-07 10:44:31 +08:00
}
2023-06-13 13:40:54 +08:00
};
2023-06-07 10:44:31 +08:00
</script>
2023-06-13 13:40:54 +08:00
<style lang="scss" scoped></style>