完整数据字典获取示例:
这里需必须要先获取数据字典,然后再获取用户信息 ,完成前面两部之后才能使用翻译方法进行翻译,所以这里必须要使用同步先进行前面两个步骤; created() {
this.user.userId = this.$route.query.id;
this.getUserDetail();
},
methods: {
async getUserDetail() {
this.loading = true;
let res = await this.getDicts("lh_credential_type");
this.credentialTypeOptions = res.data;
res = await this.getDicts("lh_marriage_state");
this.marrigeStateOptions = res.data;
res = await this.getDicts("sys_yes_no");
this.parentStateOptions = res.data;
res = await this.getDicts("sys_user_sex");
this.sexOptions = res.data;
res = await this.getDicts("lh_nation");
this.nationOptions = res.data;
res = await this.getDicts("lh_life_state");
this.lifeStateOptions = res.data;
res = await getUser(this.user.userId);
this.user = res.data;
this.credentialTypeFormat(this.user.credentialType);
this.marriageStateFormat(this.user.marriageState);
this.parentStateFormat(this.user.parentState);
this.sexFormat(this.user.sex);
this.nationFormat(this.user.nation);
this.lifeStateFormat(this.user.lifeState);
this.mergeHeightWeight();
this.loading = false;
}