king
2021-12-22 5223edbcccfed84a33a706e5637ee65a61f377aa
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
/**
 * @description tab表单配置信息
 */
export function getTabForm(tab, setting) {
  let appType = sessionStorage.getItem('appType')
  let roleList = sessionStorage.getItem('sysRoles')
 
  if (roleList) {
    try {
      roleList = JSON.parse(roleList)
    } catch (e) {
      roleList = []
    }
  } else {
    roleList = []
  }
 
  const tabForm = [
    {
      type: 'text',
      field: 'label',
      label: '名称',
      initval: tab.label || '',
      required: true,
      focus: true,
      span: 22
    },
    {
      type: 'mkicon',
      field: 'icon',
      label: '图标',
      initval: tab.icon || '',
      required: false,
      allowClear: true,
      span: 22
    },
    {
      type: 'radio',
      field: 'hasSearch',
      label: '搜索',
      initval: tab.hasSearch || 'false',
      required: false,
      options: [
        {value: 'false', label: '无'},
        {value: 'icon', label: '有'},
      ],
      forbid: appType !== 'mob' || setting.position !== 'top' || setting.display !== 'inline-block',
      span: 22
    },
    {
      type: 'multiselect',
      field: 'blacklist',
      label: '黑名单',
      initval: tab.blacklist || [],
      required: false,
      options: roleList,
      forbid: !!appType,
      span: 22
    },
  ]
 
  return tabForm
}
 
/**
 * @description tabs表单配置信息
 */
export function getTabsSetForm(setting) {
  let appType = sessionStorage.getItem('appType')
  let roleList = sessionStorage.getItem('sysRoles')
 
  if (roleList) {
    try {
      roleList = JSON.parse(roleList)
    } catch (e) {
      roleList = []
    }
  } else {
    roleList = []
  }
 
  const tabForm = [
    {
      type: 'text',
      field: 'name',
      label: '组件名称',
      initval: setting.name || '',
      tooltip: '用于组件间的区分。',
      required: true
    },
    {
      type: 'number',
      field: 'width',
      label: '宽度',
      initval: setting.width || 24,
      tooltip: '栅格布局,每行等分为24列。',
      min: 1,
      max: 24,
      precision: 0,
      required: true
    },
    {
      type: 'select',
      field: 'position',
      label: '标签位置',
      initval: setting.position || 'top',
      required: true,
      options: [
        {value: 'top', label: 'top'},
        {value: 'bottom', label: 'bottom'},
        {value: 'left', label: 'left'},
        {value: 'right', label: 'right'},
      ],
      controlFields: [
        {field: 'display', values: ['top', 'bottom']},
      ]
    },
    {
      type: 'radio',
      field: 'tabStyle',
      label: '页签样式',
      initval: setting.tabStyle || 'line',
      tooltip: '标签位置为top时有效,默认值为line。',
      required: true,
      options: [
        {value: 'line', label: 'line'},
        {value: 'card', label: 'card'},
      ],
    },
    {
      type: 'radio',
      field: 'autoSwitch',
      label: '自动切换',
      initval: setting.autoSwitch || 'false',
      tooltip: '存在两个及以上标签时有效。',
      required: false,
      options: [
        {value: 'true', label: '是'},
        {value: 'false', label: '否'},
      ],
      controlFields: [
        {field: 'interval', values: ['true']},
        {field: 'tabLabel', values: ['true']},
      ]
    },
    {
      type: 'number',
      field: 'interval',
      label: '间隔(s)',
      initval: setting.interval || 5,
      min: 1,
      max: 1000,
      precision: 0,
      required: true
    },
    {
      type: 'radio',
      field: 'tabLabel',
      label: '标签栏',
      initval: setting.tabLabel || 'show',
      required: false,
      options: [
        {value: 'show', label: '显示'},
        {value: 'hide', label: '隐藏'},
      ]
    },
    {
      type: 'multiselect',
      field: 'blacklist',
      label: '黑名单',
      initval: setting.blacklist || [],
      required: false,
      options: roleList,
      forbid: !!appType
    },
  ]
 
  return tabForm