|
|
@@ -29,12 +29,9 @@ const emits = defineEmits<{
|
|
|
(e: "saveCallback"): void,
|
|
|
}>()
|
|
|
|
|
|
-declare type VueIntergrationPlatformMenu = {
|
|
|
- cascaders: number[]
|
|
|
-} & IntergrationMenu
|
|
|
|
|
|
const showDialog = ref(false)
|
|
|
-const currentData = ref<VueIntergrationPlatformMenu>({
|
|
|
+const currentData = ref<IntergrationMenu>({
|
|
|
children: [],
|
|
|
component: "",
|
|
|
icon: "",
|
|
|
@@ -55,8 +52,8 @@ const currentData = ref<VueIntergrationPlatformMenu>({
|
|
|
const fromRef = useCompRef(ElForm)
|
|
|
|
|
|
|
|
|
-const rules: FormRules<VueIntergrationPlatformMenu> = reactive({})
|
|
|
-type D = keyof VueIntergrationPlatformMenu
|
|
|
+const rules: FormRules<IntergrationMenu> = reactive({})
|
|
|
+type D = keyof IntergrationMenu
|
|
|
|
|
|
function addRequired(key: D[]) {
|
|
|
key.forEach(item => {
|
|
|
@@ -68,12 +65,12 @@ addRequired(['path', 'component', 'name', 'metaTitle'])
|
|
|
|
|
|
async function save() {
|
|
|
await fromRef.value?.validate()
|
|
|
- if (currentData.value.cascaders.length > 0) {
|
|
|
- currentData.value.parentId = currentData.value.cascaders[currentData.value.cascaders.length - 1]
|
|
|
+ if (currentData.value.cascaders?.length > 0) {
|
|
|
+ currentData.value.parentId = currentData.value!.cascaders?.[currentData.value.cascaders!.length - 1]
|
|
|
}
|
|
|
await updateMenuSettings(currentData.value)
|
|
|
- emits('saveCallback')
|
|
|
showDialog.value = false
|
|
|
+ emits('saveCallback')
|
|
|
}
|
|
|
|
|
|
const icons = ref([])
|
|
|
@@ -106,9 +103,21 @@ function dialogOpen() {
|
|
|
label: tmp,
|
|
|
}
|
|
|
})
|
|
|
-
|
|
|
routerKey.value.push(...layout)
|
|
|
+}
|
|
|
|
|
|
+function handlePath() {
|
|
|
+ const isStartsWith = currentData.value.path.startsWith("/");
|
|
|
+ if (currentData.value.cascaders === null || currentData.value.cascaders!.length === 0) {
|
|
|
+ if (!isStartsWith) {
|
|
|
+ currentData.value.path = "/" + currentData.value.path
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (isStartsWith) {
|
|
|
+ currentData.value.path = currentData.value.path.substring(1)
|
|
|
+ console.log(currentData.value.path.substring(1))
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -117,7 +126,7 @@ function iconClick(icon) {
|
|
|
}
|
|
|
|
|
|
defineExpose({
|
|
|
- openDialog: (row: VueIntergrationPlatformMenu) => {
|
|
|
+ openDialog: (row: IntergrationMenu) => {
|
|
|
currentData.value = XEUtils.clone(row, true)
|
|
|
showDialog.value = true;
|
|
|
}
|
|
|
@@ -138,9 +147,22 @@ defineExpose({
|
|
|
label-width="80px"
|
|
|
size="default">
|
|
|
<el-row :gutter="10">
|
|
|
+
|
|
|
+ <el-col :span="24">
|
|
|
+ <el-form-item label="类型" prop="type">
|
|
|
+ <el-switch v-model="currentData.type"
|
|
|
+ :active-value="1"
|
|
|
+ :inactive-value="2"
|
|
|
+ active-text="目录"
|
|
|
+ inactive-text="页面"
|
|
|
+ />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+
|
|
|
<el-col :span="24">
|
|
|
<el-form-item label="父节点" prop="cascaders">
|
|
|
<el-cascader
|
|
|
+ @change="handlePath"
|
|
|
v-model="currentData.cascaders"
|
|
|
style="width: 100%"
|
|
|
:props="{ checkStrictly: true, value: 'id', label: 'metaTitle' }"
|
|
|
@@ -151,7 +173,14 @@ defineExpose({
|
|
|
|
|
|
<el-col :span="24">
|
|
|
<el-form-item label="路径" prop="path">
|
|
|
- <el-input v-model="currentData.path"/>
|
|
|
+ <template #label>
|
|
|
+ 路径
|
|
|
+ </template>
|
|
|
+ <template #default>
|
|
|
+ <el-input v-model="currentData.path"
|
|
|
+ @blur="handlePath"
|
|
|
+ />
|
|
|
+ </template>
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
|
|
|
@@ -167,30 +196,27 @@ defineExpose({
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
|
|
|
- <el-col :span="24">
|
|
|
- <el-form-item label="路径参数" prop="pathParams">
|
|
|
- <el-input v-model="currentData.pathParams"/>
|
|
|
+ <el-col :span="12">
|
|
|
+ <el-form-item label="路由名称" prop="name">
|
|
|
+ <el-input v-model="currentData.name"
|
|
|
+ clearable maxlength="50"/>
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
|
|
|
<el-col :span="12">
|
|
|
- <el-form-item label="类型" prop="type">
|
|
|
- <el-switch v-model="currentData.type"
|
|
|
- :active-value="1"
|
|
|
- :inactive-value="2"
|
|
|
- active-text="目录"
|
|
|
- inactive-text="页面"
|
|
|
- />
|
|
|
+ <el-form-item label="标题" prop="metaTitle">
|
|
|
+ <el-input v-model="currentData.metaTitle"
|
|
|
+ clearable maxlength="50"/>
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
|
|
|
- <el-col :span="12">
|
|
|
- <el-form-item label="路由名称" prop="name">
|
|
|
- <el-input v-model="currentData.name"
|
|
|
- clearable maxlength="50"/>
|
|
|
+ <el-col :span="24">
|
|
|
+ <el-form-item label="路径参数" prop="pathParams">
|
|
|
+ <el-input v-model="currentData.pathParams"/>
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
|
|
|
+
|
|
|
<el-col :span="12">
|
|
|
<el-form-item label="菜单图标">
|
|
|
<el-popover :width="0" trigger="click">
|
|
|
@@ -217,12 +243,6 @@ defineExpose({
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
|
|
|
- <el-col :span="12">
|
|
|
- <el-form-item label="菜单名称" prop="metaTitle">
|
|
|
- <el-input v-model="currentData.metaTitle"
|
|
|
- clearable maxlength="50"/>
|
|
|
- </el-form-item>
|
|
|
- </el-col>
|
|
|
|
|
|
<el-col :span="12">
|
|
|
<el-form-item label="重定向">
|