cloudroam
2025-03-28 cef2bb0eeeb91a22860cf5d23c7348af1ba921dc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<template>
  <div class="custom-crud-page">
    <el-bus-crud ref="crud" v-bind="crudConfig"></el-bus-crud>
  </div>
</template>
 
<script>
export default {
  data() {
    return {
      crudConfig: {
        url: 'flower/api/menu/list',
        hasPagination: false,
        saveQuery: false,
        isTree: true,
        hasView: false,
        deleteMessage: () => '此操作将会删除所有子菜单, 是否继续?',
        beforeOpen(row, isNew) {
          if (isNew && row.menuName) {
            row.parentName = row.menuName
          }
          if (!isNew) {
            row.parentName = ''
          }
        },
        extraParentKeys: ['parentName'],
        tableAttrs: {
          rowKey: 'id',
        },
        columns: [
          { label: '菜单名称', prop: 'menuName' },
          {
            label: '前端地址',
            prop: 'menuHref',
          },
          {
            label: '图标',
            formatter: (row) =>
              row.menuIcon ? (
                <i class={row.menuIcon} aria-hidden="true" />
              ) : null,
          },
          { label: '排序', prop: 'seq' },
        ],
        form: [
          {
            label: '父级节点:',
            id: 'parentName',
            type: 'input',
            readonly: true,
            hidden: (row) => !row.parentName,
          },
          {
            label: '标题:',
            id: 'menuName',
            type: 'input',
            el: { placeholder: '请输入标题' },
            rules: { required: true, message: '请输入标题', trigger: 'blur' },
          },
          {
            label: '图标:',
            id: 'menuIcon',
            component: 'base-menu-icon',
          },
          {
            label: '排序:',
            id: 'seq',
            type: 'input-number',
            el: {
              min: 0,
              precision: 0,
              controlsPosition: 'right',
              placeholder: '请输入排序',
            },
          },
          {
            label: '前端地址:',
            id: 'menuHref',
            type: 'input',
            el: { placeholder: '请输入前端地址' },
            rules: {
              required: true,
              message: '请输入前端地址',
              trigger: 'blur',
            },
          },
        ],
      },
    }
  },
  head() {
    return {
      title: '菜单管理',
    }
  },
}
</script>