实现了创建企业的前后端联系,在前端创建企业界面上,输入企业名字后,点击创建按钮,即可成功创建企业,此时用户的权限会变为4,即最高权限。
创建成功后页面跳转到企业信息界面。
<script>
import { createCompany } from "@/services/company";
import { mapGetters,mapMutations } from "vuex";
export default {
data() {
return {
labelCol: { span: 4 },
wrapperCol: { span: 14 },
};
},
beforeCreate() {
this.form = this.$form.createForm(this);
},
computed: {
...mapGetters("account", ["username", "userId"]),
},
methods: {
...mapMutations("company", [
"setUserName",
"setUserId",
"setCompanyName",
"setCompanyId",
"setSex",
"setTelephone",
"setRoles",
]),
onSubmit(e) {
e.preventDefault();
this.form.validateFieldsAndScroll((err) => {
if (!err) {
const companyName = this.form.getFieldValue("companyName");
createCompany(this.userId, companyName).then(() => {
let roles= [{id:'founder'}]
this.setRoles(roles)
this.$message.success("创建成功!");
this.$router.push({ path: "/resourceManagement/information" });
});
}
});
},
},
};
</script>