Commit 07f6eb64 authored by 水落(YangLei)'s avatar 水落(YangLei)

feat: 增加菜单管理中的中英文

parent 6e53962f
...@@ -16,6 +16,10 @@ export async function getMenuDataApi(useCache) { ...@@ -16,6 +16,10 @@ export async function getMenuDataApi(useCache) {
}); });
} }
export function getMenuDetailApi(id) {
return getReq(`/api/v1/menus/${id}`);
}
export function addMenuApi(data) { export function addMenuApi(data) {
return postReq('/api/v1/menus', data); return postReq('/api/v1/menus', data);
} }
......
...@@ -10,10 +10,10 @@ ...@@ -10,10 +10,10 @@
</a-radio-group> </a-radio-group>
</a-form-model-item> </a-form-model-item>
<a-form-model-item label="中文名称"> <a-form-model-item label="中文名称">
<a-input v-model="form.menuName" /> <a-input v-model="menuTypeNameZh" />
</a-form-model-item> </a-form-model-item>
<a-form-model-item label="英文名称"> <a-form-model-item label="英文名称">
<a-input /> <a-input v-model="menuTypeNameEn" />
</a-form-model-item> </a-form-model-item>
<a-form-model-item label="模块URL" prop="menuUrl"> <a-form-model-item label="模块URL" prop="menuUrl">
<a-input v-model="form.menuUrl" /> <a-input v-model="form.menuUrl" />
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
</template> </template>
<script> <script>
import { addMenuApi, updateMenuApi } from '@/api'; import { addMenuApi, updateMenuApi, getMenuDetailApi } from '@/api';
import MenuTree from '@/components/menu_tree/select.vue'; import MenuTree from '@/components/menu_tree/select.vue';
export default { export default {
...@@ -42,7 +42,15 @@ export default { ...@@ -42,7 +42,15 @@ export default {
menuType: 'CATALOG', menuType: 'CATALOG',
parentMenuId: null, parentMenuId: null,
menuName: '', menuName: '',
menuNameI18nList: [
{ i18nLocale: 'zh_CN', i18nMessage: '' },
{ i18nLocale: 'en_US', i18nMessage: '' },
],
menuRemark: '',
}, },
menuTypeNameZh: '',
menuTypeNameEn: '',
rules: { rules: {
menuUrl: [{ required: true }], menuUrl: [{ required: true }],
}, },
...@@ -58,12 +66,29 @@ export default { ...@@ -58,12 +66,29 @@ export default {
methods: { methods: {
async submit() { async submit() {
await this.$refs['form'].validate(); await this.$refs['form'].validate();
const reqData = { ...this.form, parentMenuId: this.form.parentMenuId ?? 0 }; console.log('this.form.enuNameI18nList', this.form.enuNameI18nList);
const reqData = {
...this.form,
parentMenuId: this.form.parentMenuId ?? 0,
menuNameI18nList: this.form.menuNameI18nList.map(i18 => {
if (i18.i18nLocale === 'en_US') i18.i18nMessage = this.menuTypeNameEn;
if (i18.i18nLocale === 'zh_CN') i18.i18nMessage = this.menuTypeNameZh;
return i18;
}),
menuName: this.menuTypeNameZh,
};
console.log('this.form.enuNameI18nList', this.form.enuNameI18nList);
return this.isEdit ? updateMenuApi(reqData) : addMenuApi(reqData); return this.isEdit ? updateMenuApi(reqData) : addMenuApi(reqData);
}, },
setEdit(data) { async setEdit(data) {
this.type = 1; this.type = 1;
this.form = data; this.form = await getMenuDetailApi(data.menuId);
this.form.menuNameI18nList?.forEach(i18 => {
if (i18.i18nLocale === 'en_US') this.menuTypeNameEn = i18.i18nMessage;
if (i18.i18nLocale === 'zh_CN') this.menuTypeNameZh = i18.i18nMessage;
});
}, },
}, },
}; };
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment