Commit fe44789e30f574792576b91c094c6132d9fe7d43
1 parent
62b5353517
Exists in
master
修改路由,新增页面
Showing
15 changed files
with
3698 additions
and
74 deletions
Show diff stats
package.json
src/router/index.js
... | ... | @@ -7,16 +7,22 @@ Vue.use(Router) |
7 | 7 | import Layout from '@/layout' |
8 | 8 | |
9 | 9 | /* Router Modules */ |
10 | -import componentsRouter from './modules/components' | |
10 | +// import componentsRouter from './modules/components' | |
11 | 11 | // import chartsRouter from './modules/charts' |
12 | 12 | // import tableRouter from './modules/table' |
13 | 13 | // import nestedRouter from './modules/nested' |
14 | -import userRouter from './modules/user' | |
15 | -import systemRouter from './modules/system' | |
16 | -import prodRouter from './modules/prod' | |
17 | -import orderRouter from './modules/order' | |
18 | -import metaRouter from './modules/meta' | |
19 | -import sitesRouter from './modules/sites' | |
14 | +import userRouter from './modules/user'// 用户 | |
15 | +import systemRouter from './modules/system'// 系统设置 | |
16 | +import prodRouter from './modules/prod'// 产品 | |
17 | +import orderRouter from './modules/order'// 订单 | |
18 | +import metaRouter from './modules/meta'// 元定义 | |
19 | +// import sitesRouter from './modules/sites' | |
20 | +import applicationRouter from './modules/application'// 应用 | |
21 | +import operationsRouter from './modules/operations'// 运营官 | |
22 | +import logisticsRouter from './modules/logistics'// 物流路由 | |
23 | +import staffRouter from './modules/staff'// 员工 | |
24 | +import recommendRouter from './modules/recommend'// 推荐 | |
25 | +// import manufacturerRouter from './modules/manufacturer' | |
20 | 26 | |
21 | 27 | /** |
22 | 28 | * Note: sub-menu only appear when route children.length >= 1 |
... | ... | @@ -92,7 +98,7 @@ export const constantRoutes = [{ |
92 | 98 | affix: true |
93 | 99 | } |
94 | 100 | }] |
95 | -}, | |
101 | +} | |
96 | 102 | // { |
97 | 103 | // path: '/documentation', |
98 | 104 | // component: Layout, |
... | ... | @@ -105,21 +111,21 @@ export const constantRoutes = [{ |
105 | 111 | // } |
106 | 112 | // ] |
107 | 113 | // }, |
108 | -{ | |
109 | - path: '/guide', | |
110 | - component: Layout, | |
111 | - redirect: '/guide/index', | |
112 | - children: [{ | |
113 | - path: 'index', | |
114 | - component: () => import('@/views/guide/index'), | |
115 | - name: 'Guide', | |
116 | - meta: { | |
117 | - title: 'guide', | |
118 | - icon: 'guide', | |
119 | - noCache: true | |
120 | - } | |
121 | - }] | |
122 | -} | |
114 | +// { | |
115 | +// path: '/guide', | |
116 | +// component: Layout, | |
117 | +// redirect: '/guide/index', | |
118 | +// children: [{ | |
119 | +// path: 'index', | |
120 | +// component: () => import('@/views/guide/index'), | |
121 | +// name: 'Guide', | |
122 | +// meta: { | |
123 | +// title: 'guide', | |
124 | +// icon: 'guide', | |
125 | +// noCache: true | |
126 | +// } | |
127 | +// }] | |
128 | +// } | |
123 | 129 | // { |
124 | 130 | // path: '/profile', |
125 | 131 | // component: Layout, |
... | ... | @@ -184,13 +190,19 @@ export const asyncRoutes = [ |
184 | 190 | // ] |
185 | 191 | // }, |
186 | 192 | // tableRouter, |
187 | - metaRouter, | |
188 | - userRouter, | |
189 | - prodRouter, | |
190 | - orderRouter, | |
191 | - sitesRouter, | |
192 | - systemRouter, | |
193 | - componentsRouter, | |
193 | + applicationRouter, // 应用 | |
194 | + operationsRouter, // 运营官 | |
195 | + // manufacturerRouter, | |
196 | + userRouter, // 用户 | |
197 | + orderRouter, // 订单 | |
198 | + prodRouter, // 产品 | |
199 | + logisticsRouter, // 物流 | |
200 | + staffRouter, // 员工 | |
201 | + recommendRouter, // 推荐 | |
202 | + metaRouter, // 元定义 | |
203 | + // sitesRouter, | |
204 | + systemRouter, // 系统设置 | |
205 | + // componentsRouter, | |
194 | 206 | // chartsRouter, |
195 | 207 | // nestedRouter, |
196 | 208 | // tableRouter, |
... | ... | @@ -210,46 +222,46 @@ export const asyncRoutes = [ |
210 | 222 | }, |
211 | 223 | /** when your routing map is too long, you can split it into small modules **/ |
212 | 224 | |
213 | - { | |
214 | - path: '/example', | |
215 | - component: Layout, | |
216 | - redirect: '/example/list', | |
217 | - name: 'Example', | |
218 | - meta: { | |
219 | - title: 'example', | |
220 | - icon: 'example' | |
221 | - }, | |
222 | - children: [{ | |
223 | - path: 'create', | |
224 | - component: () => import('@/views/example/create'), | |
225 | - name: 'CreateArticle', | |
226 | - meta: { | |
227 | - title: 'createArticle', | |
228 | - icon: 'edit' | |
229 | - } | |
230 | - }, | |
231 | - { | |
232 | - path: 'edit/:id(\\d+)', | |
233 | - component: () => import('@/views/example/edit'), | |
234 | - name: 'EditArticle', | |
235 | - meta: { | |
236 | - title: 'editArticle', | |
237 | - noCache: true, | |
238 | - activeMenu: '/example/list' | |
239 | - }, | |
240 | - hidden: true | |
241 | - }, | |
242 | - { | |
243 | - path: 'list', | |
244 | - component: () => import('@/views/example/list'), | |
245 | - name: 'ArticleList', | |
246 | - meta: { | |
247 | - title: 'articleList', | |
248 | - icon: 'list' | |
249 | - } | |
250 | - } | |
251 | - ] | |
252 | - }, | |
225 | + // { | |
226 | + // path: '/example', | |
227 | + // component: Layout, | |
228 | + // redirect: '/example/list', | |
229 | + // name: 'Example', | |
230 | + // meta: { | |
231 | + // title: 'example', | |
232 | + // icon: 'example' | |
233 | + // }, | |
234 | + // children: [{ | |
235 | + // path: 'create', | |
236 | + // component: () => import('@/views/example/create'), | |
237 | + // name: 'CreateArticle', | |
238 | + // meta: { | |
239 | + // title: 'createArticle', | |
240 | + // icon: 'edit' | |
241 | + // } | |
242 | + // }, | |
243 | + // { | |
244 | + // path: 'edit/:id(\\d+)', | |
245 | + // component: () => import('@/views/example/edit'), | |
246 | + // name: 'EditArticle', | |
247 | + // meta: { | |
248 | + // title: 'editArticle', | |
249 | + // noCache: true, | |
250 | + // activeMenu: '/example/list' | |
251 | + // }, | |
252 | + // hidden: true | |
253 | + // }, | |
254 | + // { | |
255 | + // path: 'list', | |
256 | + // component: () => import('@/views/example/list'), | |
257 | + // name: 'ArticleList', | |
258 | + // meta: { | |
259 | + // title: 'articleList', | |
260 | + // icon: 'list' | |
261 | + // } | |
262 | + // } | |
263 | + // ] | |
264 | + // }, | |
253 | 265 | |
254 | 266 | // { |
255 | 267 | // path: '/tab', | ... | ... |
src/router/modules/application.js
... | ... | @@ -0,0 +1,25 @@ |
1 | +import Layout from '@/layout' | |
2 | + | |
3 | +const applicationRouter = { | |
4 | + path: '/application', | |
5 | + component: Layout, | |
6 | + redirect: '/application/page', | |
7 | + alwaysShow: true, // will always show the root menu | |
8 | + name: 'Application', | |
9 | + meta: { | |
10 | + title: '应用', | |
11 | + icon: 'component', | |
12 | + roles: ['admin', 'assistant'] // you can set roles in root nav | |
13 | + }, | |
14 | + children: [{ | |
15 | + path: 'appManage', | |
16 | + component: () => import('@/views/application/appManage'), | |
17 | + name: 'appManage', | |
18 | + meta: { | |
19 | + title: '应用管理', | |
20 | + icon: 'component', | |
21 | + roles: ['admin', 'assistant'] // or you can only set roles in sub nav | |
22 | + } | |
23 | + }] | |
24 | +} | |
25 | +export default applicationRouter | ... | ... |
src/router/modules/logistics.js
... | ... | @@ -0,0 +1,25 @@ |
1 | +import Layout from '@/layout' | |
2 | + | |
3 | +const logisticsRouter = { | |
4 | + path: '/logistics', | |
5 | + component: Layout, | |
6 | + redirect: '/logistics/page', | |
7 | + alwaysShow: true, // will always show the root menu | |
8 | + name: 'logistics', | |
9 | + meta: { | |
10 | + title: '物流', | |
11 | + icon: 'tree-table', | |
12 | + roles: ['admin', 'assistant'] // you can set roles in root nav | |
13 | + }, | |
14 | + children: [{ | |
15 | + path: 'logisticspage', | |
16 | + component: () => import('@/views/logistics/logistics'), | |
17 | + name: 'logistics', | |
18 | + meta: { | |
19 | + title: '物流管理', | |
20 | + icon: 'tree-table', | |
21 | + roles: ['admin', 'assistant'] // or you can only set roles in sub nav | |
22 | + } | |
23 | + }] | |
24 | +} | |
25 | +export default logisticsRouter | ... | ... |
src/router/modules/manufacturer.js
... | ... | @@ -0,0 +1,25 @@ |
1 | +import Layout from '@/layout' | |
2 | + | |
3 | +const manufacturerRouter = { | |
4 | + path: '/manufacturer', | |
5 | + component: Layout, | |
6 | + redirect: '/manufacturer/page', | |
7 | + alwaysShow: true, // will always show the root menu | |
8 | + name: 'manufacturer', | |
9 | + meta: { | |
10 | + title: '厂商', | |
11 | + icon: 'tree-table', | |
12 | + roles: ['admin', 'assistant'] // you can set roles in root nav | |
13 | + }, | |
14 | + children: [{ | |
15 | + path: 'manufacturerpage', | |
16 | + component: () => import('@/views/manufacturer/manufacturer'), | |
17 | + name: 'manufacturer', | |
18 | + meta: { | |
19 | + title: '厂商管理', | |
20 | + icon: 'tree-table', | |
21 | + roles: ['admin', 'assistant'] // or you can only set roles in sub nav | |
22 | + } | |
23 | + }] | |
24 | +} | |
25 | +export default manufacturerRouter | ... | ... |
src/router/modules/meta.js
... | ... | @@ -7,8 +7,8 @@ const metaRouter = { |
7 | 7 | alwaysShow: true, // will always show the root menu |
8 | 8 | name: 'Meta', |
9 | 9 | meta: { |
10 | - title: 'metas.metas', | |
11 | - icon: 'zip', | |
10 | + title: '元定义', | |
11 | + icon: 'tree', | |
12 | 12 | roles: ['admin', 'assistant'] // you can set roles in root nav |
13 | 13 | }, |
14 | 14 | children: [{ |
... | ... | @@ -17,7 +17,7 @@ const metaRouter = { |
17 | 17 | name: 'MetaList', |
18 | 18 | meta: { |
19 | 19 | title: 'metas.list', |
20 | - icon: 'zip', | |
20 | + icon: 'tree', | |
21 | 21 | roles: ['admin', 'assistant'] // or you can only set roles in sub nav |
22 | 22 | } |
23 | 23 | }] | ... | ... |
src/router/modules/operations.js
... | ... | @@ -0,0 +1,25 @@ |
1 | +import Layout from '@/layout' | |
2 | + | |
3 | +const operationsRouter = { | |
4 | + path: '/operations', | |
5 | + component: Layout, | |
6 | + redirect: '/operations/page', | |
7 | + alwaysShow: true, // will always show the root menu | |
8 | + name: 'operations', | |
9 | + meta: { | |
10 | + title: '运营官', | |
11 | + icon: 'user', | |
12 | + roles: ['admin', 'assistant'] // you can set roles in root nav | |
13 | + }, | |
14 | + children: [{ | |
15 | + path: 'operationsManage', | |
16 | + component: () => import('@/views/operations/operations'), | |
17 | + name: 'operations', | |
18 | + meta: { | |
19 | + title: '运营官管理', | |
20 | + icon: 'user', | |
21 | + roles: ['admin', 'assistant'] // or you can only set roles in sub nav | |
22 | + } | |
23 | + }] | |
24 | +} | |
25 | +export default operationsRouter | ... | ... |
src/router/modules/recommend.js
... | ... | @@ -0,0 +1,25 @@ |
1 | +import Layout from '@/layout' | |
2 | + | |
3 | +const recommendRouter = { | |
4 | + path: '/recommend', | |
5 | + component: Layout, | |
6 | + redirect: '/recommend/page', | |
7 | + alwaysShow: true, // will always show the root menu | |
8 | + name: 'recommend', | |
9 | + meta: { | |
10 | + title: '推荐', | |
11 | + icon: 'table', | |
12 | + roles: ['admin', 'assistant'] // you can set roles in root nav | |
13 | + }, | |
14 | + children: [{ | |
15 | + path: 'recommendpage', | |
16 | + component: () => import('@/views/recommend/recommend'), | |
17 | + name: 'recommend', | |
18 | + meta: { | |
19 | + title: '推荐系统', | |
20 | + icon: 'table', | |
21 | + roles: ['admin', 'assistant'] // or you can only set roles in sub nav | |
22 | + } | |
23 | + }] | |
24 | +} | |
25 | +export default recommendRouter | ... | ... |
src/router/modules/staff.js
... | ... | @@ -0,0 +1,25 @@ |
1 | +import Layout from '@/layout' | |
2 | + | |
3 | +const staffRouter = { | |
4 | + path: '/staff', | |
5 | + component: Layout, | |
6 | + redirect: '/staff/page', | |
7 | + alwaysShow: true, // will always show the root menu | |
8 | + name: 'staff', | |
9 | + meta: { | |
10 | + title: '员工', | |
11 | + icon: 'people', | |
12 | + roles: ['admin', 'assistant'] // you can set roles in root nav | |
13 | + }, | |
14 | + children: [{ | |
15 | + path: 'staffpage', | |
16 | + component: () => import('@/views/staff/staff'), | |
17 | + name: 'staff', | |
18 | + meta: { | |
19 | + title: '员工管理', | |
20 | + icon: 'people', | |
21 | + roles: ['admin', 'assistant'] // or you can only set roles in sub nav | |
22 | + } | |
23 | + }] | |
24 | +} | |
25 | +export default staffRouter | ... | ... |
src/views/application/appManage.vue
... | ... | @@ -0,0 +1,577 @@ |
1 | +<template> | |
2 | + <div class="login-container"> | |
3 | + <el-button | |
4 | + type="primary" | |
5 | + @click="() => addNode()" | |
6 | + >{{ $t('users.add') }}</el-button> | |
7 | + <el-tree | |
8 | + ref="tree" | |
9 | + :data="data" | |
10 | + show-checkbox | |
11 | + node-key="id" | |
12 | + highlight-current | |
13 | + check-strictly | |
14 | + indent="40" | |
15 | + icon-class="el-icon-pc" | |
16 | + :props="defaultProps" | |
17 | + > | |
18 | + <!-- <el-tree | |
19 | + :data="data" | |
20 | + show-checkbox | |
21 | + node-key="id" | |
22 | + default-expand-all | |
23 | + highlight-current | |
24 | + isLeaf | |
25 | + @node-contextmenu="()=>rightKey(node, data)" | |
26 | + check-strictly//在显示复选框的情况下,是否严格的遵循父子不互相关联的做法,默认为 false | |
27 | + :expand-on-click-node="false"//是否在点击节点的时候展开或者收缩节点, 默认值为 true,如果为 false,则只有点箭头图标的时候才会展开或者收缩节点。 | |
28 | + :props="defaultProps" | |
29 | + > --> | |
30 | + <span | |
31 | + slot-scope="{ node, data }" | |
32 | + class="custom-tree-node" | |
33 | + > | |
34 | + <span>{{ node.label }}</span> | |
35 | + <span> | |
36 | + <el-button | |
37 | + type="primary" | |
38 | + icon="el-icon-upload" | |
39 | + size="mini" | |
40 | + @click="() => append(data)" | |
41 | + > | |
42 | + {{ $t('users.add') }} | |
43 | + </el-button> | |
44 | + <el-button | |
45 | + type="primary" | |
46 | + icon="el-icon-edit" | |
47 | + size="mini" | |
48 | + @click="() => update(node, data)" | |
49 | + > | |
50 | + {{ $t('users.update') }} | |
51 | + </el-button> | |
52 | + <el-button | |
53 | + type="primary" | |
54 | + icon="el-icon-delete" | |
55 | + size="mini" | |
56 | + class="danger" | |
57 | + @click="() => remove(node, data)" | |
58 | + > | |
59 | + {{ $t('users.del') }} | |
60 | + </el-button> | |
61 | + </span> | |
62 | + </span> | |
63 | + </el-tree> | |
64 | + | |
65 | + <!-- <div class="buttons"> | |
66 | + <el-button @click="getCheckedNodes">通过 node 获取</el-button> | |
67 | + <el-button @click="getCheckedKeys">通过 key 获取</el-button> | |
68 | + <el-button @click="setCheckedNodes">通过 node 设置</el-button> | |
69 | + <el-button @click="setCheckedKeys">通过 key 设置</el-button> | |
70 | + <el-button @click="resetChecked">清空</el-button> | |
71 | + </div> --> | |
72 | + </div> | |
73 | +</template> | |
74 | +<script> | |
75 | +let id = 1000 | |
76 | +export default { | |
77 | + data() { | |
78 | + return { | |
79 | + data: [ | |
80 | + { | |
81 | + label: '成镜', | |
82 | + id: '1', | |
83 | + children: [ | |
84 | + { | |
85 | + label: '款式', | |
86 | + id: '11', | |
87 | + children: [ | |
88 | + { label: '青春学子风' }, | |
89 | + { label: '休闲' }, | |
90 | + { label: '商务' }, | |
91 | + { label: '复古' }, | |
92 | + { label: '时尚' }, | |
93 | + { label: '质感哥特潮' }, | |
94 | + { label: '轻简北欧风' }, | |
95 | + { label: '理性几何派' }, | |
96 | + { label: '多元新风尚' }, | |
97 | + { label: '立体巴洛克' }, | |
98 | + { label: '有机未来时' }, | |
99 | + { label: '无界人文系' }, | |
100 | + { label: '自然舒视角' }, | |
101 | + { label: '流线洛可可' }, | |
102 | + { label: '奶奶风' }, | |
103 | + { label: '简约-极简文艺范' }, | |
104 | + { label: '运动风' }, | |
105 | + { label: '行政风' }, | |
106 | + { label: '折射率' } | |
107 | + ] | |
108 | + }, | |
109 | + { label: '个性化服务', id: '267', children: [] }, | |
110 | + { | |
111 | + label: '赠品', | |
112 | + id: '259', | |
113 | + children: [{ label: '眼镜布' }, { label: '眼镜盒' }] | |
114 | + }, | |
115 | + { | |
116 | + label: '场景', | |
117 | + id: '258', | |
118 | + children: [ | |
119 | + { label: '学校场景' }, | |
120 | + { label: '出行交际' }, | |
121 | + { label: '夜店迷人' }, | |
122 | + { label: '明星同款' } | |
123 | + ] | |
124 | + }, | |
125 | + { | |
126 | + label: '销售保障', | |
127 | + id: '245', | |
128 | + children: [ | |
129 | + { label: '可退' }, | |
130 | + { label: '可换' }, | |
131 | + { label: '可修' } | |
132 | + ] | |
133 | + }, | |
134 | + { | |
135 | + label: '功能', | |
136 | + id: '140', | |
137 | + children: [ | |
138 | + { label: '防踩压' }, | |
139 | + { label: '防扭曲' }, | |
140 | + { label: '抗过敏' }, | |
141 | + { label: '防腐蚀' }, | |
142 | + { label: '耐磨损' }, | |
143 | + { label: '抗蓝光' } | |
144 | + ] | |
145 | + }, | |
146 | + { | |
147 | + label: '品牌', | |
148 | + id: '71', | |
149 | + children: [ | |
150 | + { label: '购易' }, | |
151 | + { label: '海俪恩' }, | |
152 | + { label: '沙漠风暴' }, | |
153 | + { label: '古诗' }, | |
154 | + { label: '暴龙' }, | |
155 | + { label: '犀牛' }, | |
156 | + { label: 'Ray-Ban雷朋' }, | |
157 | + { label: 'PARIM派丽蒙' }, | |
158 | + { label: '石狼' }, | |
159 | + { label: '木九十' } | |
160 | + ] | |
161 | + }, | |
162 | + { | |
163 | + label: '边形', | |
164 | + id: '49', | |
165 | + children: [ | |
166 | + { label: '半框' }, | |
167 | + { label: '全框' }, | |
168 | + { label: '无框' } | |
169 | + ] | |
170 | + }, | |
171 | + { | |
172 | + label: '性别', | |
173 | + id: '23', | |
174 | + children: [{ label: '男性' }, { label: '女性' }] | |
175 | + }, | |
176 | + { | |
177 | + label: '梁型', | |
178 | + id: '20', | |
179 | + children: [{ label: '双梁' }, { label: '单梁' }] | |
180 | + }, | |
181 | + { | |
182 | + label: '重量', | |
183 | + id: '19', | |
184 | + children: [{ label: '30克以下' }, { label: '80克以上' }] | |
185 | + }, | |
186 | + { | |
187 | + label: '适用脸型', | |
188 | + id: '15', | |
189 | + children: [{ label: '方' }, { label: '圆' }, { label: '瓜子' }] | |
190 | + }, | |
191 | + { | |
192 | + label: '形状', | |
193 | + id: '14', | |
194 | + children: [ | |
195 | + { label: '正圆形' }, | |
196 | + { label: '椭圆形' }, | |
197 | + { label: '方圆' }, | |
198 | + { label: '方形' }, | |
199 | + { label: '多边形' }, | |
200 | + { label: '内三角(蛤蟆)' }, | |
201 | + { label: '外三角(蝶形)' } | |
202 | + ] | |
203 | + }, | |
204 | + { label: '年龄', id: '12', children: [{ label: '通用' }] }, | |
205 | + { | |
206 | + label: '材质', | |
207 | + id: '10', | |
208 | + children: [ | |
209 | + { label: '板材' }, | |
210 | + { label: '纯钛' }, | |
211 | + { label: 'TR90' }, | |
212 | + { label: '木质' }, | |
213 | + { label: '竹质' }, | |
214 | + { label: 'β钛' }, | |
215 | + { label: 'PC' }, | |
216 | + { label: 'ULTEM塑钢' }, | |
217 | + { label: '钨钛塑钢' }, | |
218 | + { label: '镁铝合金' }, | |
219 | + { label: '碳纤维' } | |
220 | + ] | |
221 | + }, | |
222 | + { label: '折射率', id: '286', children: [] }, | |
223 | + { | |
224 | + label: '颜色', | |
225 | + id: '13', | |
226 | + children: [ | |
227 | + { label: '金色' }, | |
228 | + { label: '银色' }, | |
229 | + { label: '黑色' }, | |
230 | + { label: '彩色' }, | |
231 | + { label: '枪色' } | |
232 | + ] | |
233 | + } | |
234 | + ] | |
235 | + }, | |
236 | + { | |
237 | + label: '镜片', | |
238 | + id: '2', | |
239 | + children: [ | |
240 | + { | |
241 | + label: '面型', | |
242 | + id: '85', | |
243 | + children: [{ label: '球面单光' }, { label: '非球面单光' }] | |
244 | + }, | |
245 | + { label: '近视度数', id: '92', children: [] }, | |
246 | + { label: '散光', id: '93', children: [] }, | |
247 | + { | |
248 | + label: '功能', | |
249 | + id: '95', | |
250 | + children: [ | |
251 | + { label: '防起雾' }, | |
252 | + { label: '防蓝光' }, | |
253 | + { label: '防紫外线' }, | |
254 | + { label: '偏光' }, | |
255 | + { label: '染色' }, | |
256 | + { label: '抗疲劳' }, | |
257 | + { label: '青少年渐进' }, | |
258 | + { label: '内渐进' }, | |
259 | + { label: '变色' }, | |
260 | + { label: '双光' }, | |
261 | + { label: '耐磨损' }, | |
262 | + { label: '防尘' }, | |
263 | + { label: '防水' }, | |
264 | + { label: '防摔' }, | |
265 | + { label: '防指纹' }, | |
266 | + { label: '防反光' } | |
267 | + ] | |
268 | + }, | |
269 | + { | |
270 | + label: '颜色', | |
271 | + id: '100', | |
272 | + children: [ | |
273 | + { label: '透明' }, | |
274 | + { label: '染色' }, | |
275 | + { label: '变色' }, | |
276 | + { label: '单色' } | |
277 | + ] | |
278 | + }, | |
279 | + { | |
280 | + label: '折射率', | |
281 | + id: '101', | |
282 | + children: [ | |
283 | + { label: '1.56' }, | |
284 | + { label: '1.60' }, | |
285 | + { label: '1.65' }, | |
286 | + { label: '1.67' }, | |
287 | + { label: '1.71' }, | |
288 | + { label: '1.74' } | |
289 | + ] | |
290 | + }, | |
291 | + { label: '阿贝数(色散)', id: '102', children: [] }, | |
292 | + { label: '重量', id: '103', children: [] }, | |
293 | + { | |
294 | + label: '材质', | |
295 | + id: '104', | |
296 | + children: [ | |
297 | + { label: '树脂' }, | |
298 | + { label: '玻璃' }, | |
299 | + { label: '宇宙PC' }, | |
300 | + { label: 'PC' } | |
301 | + ] | |
302 | + }, | |
303 | + { | |
304 | + label: '品牌', | |
305 | + id: '118', | |
306 | + children: [ | |
307 | + { label: '好视力' }, | |
308 | + { label: 'RAISE锐视' }, | |
309 | + { label: '依视路' }, | |
310 | + { label: '凯米' }, | |
311 | + { label: '蔡司' }, | |
312 | + { label: '舒曼' } | |
313 | + ] | |
314 | + }, | |
315 | + { | |
316 | + label: '销售保障', | |
317 | + id: '249', | |
318 | + children: [ | |
319 | + { label: '可退' }, | |
320 | + { label: '可换' }, | |
321 | + { label: '可修' } | |
322 | + ] | |
323 | + } | |
324 | + ] | |
325 | + }, | |
326 | + { | |
327 | + label: '隐形眼镜', | |
328 | + id: '88', | |
329 | + children: [ | |
330 | + { | |
331 | + label: '颜色', | |
332 | + id: '105', | |
333 | + children: [ | |
334 | + { label: '绿' }, | |
335 | + { label: '灰' }, | |
336 | + { label: '黑' }, | |
337 | + { label: '紫' }, | |
338 | + { label: '蓝' }, | |
339 | + { label: '棕色' }, | |
340 | + { label: '紫色' } | |
341 | + ] | |
342 | + }, | |
343 | + { | |
344 | + label: '颜料', | |
345 | + id: '106', | |
346 | + children: [{ label: '水性' }, { label: '油性' }] | |
347 | + }, | |
348 | + { label: '度数', id: '107', children: [] }, | |
349 | + { | |
350 | + label: '周期', | |
351 | + id: '108', | |
352 | + children: [ | |
353 | + { label: '日抛' }, | |
354 | + { label: '周抛' }, | |
355 | + { label: '双周抛' }, | |
356 | + { label: '月抛' }, | |
357 | + { label: '季抛' }, | |
358 | + { label: '半年抛' }, | |
359 | + { label: '年抛' } | |
360 | + ] | |
361 | + }, | |
362 | + { | |
363 | + label: '品牌', | |
364 | + id: '133', | |
365 | + children: [ | |
366 | + { label: 'HolyNara' }, | |
367 | + { label: '爱尔康' }, | |
368 | + { label: 'MaxLook' }, | |
369 | + { label: 'NEO' }, | |
370 | + { label: 'GEO' }, | |
371 | + { label: '实瞳' }, | |
372 | + { label: '茵洛' }, | |
373 | + { label: 'DAZZSHOP' }, | |
374 | + { label: 'O-LENS' }, | |
375 | + { label: 'envie' }, | |
376 | + { label: '曼秀雷敦' }, | |
377 | + { label: '妃蜜莉' }, | |
378 | + { label: '海俪恩' }, | |
379 | + { label: '凯达' }, | |
380 | + { label: '蔡司' }, | |
381 | + { label: '酷视' }, | |
382 | + { label: 'LILMOON' }, | |
383 | + { label: 'RICHBABY' }, | |
384 | + { label: 'T-Garden' }, | |
385 | + { label: 'lenstown' }, | |
386 | + { label: '新加坡P2' }, | |
387 | + { label: '星欧' }, | |
388 | + { label: '美尼康' }, | |
389 | + { label: '美汐' }, | |
390 | + { label: '欧舒天' }, | |
391 | + { label: '海昌' }, | |
392 | + { label: '菲士康' }, | |
393 | + { label: '卫康' }, | |
394 | + { label: '库博' }, | |
395 | + { label: '安视优' }, | |
396 | + { label: '美若康' }, | |
397 | + { label: '视康' }, | |
398 | + { label: '澜柏' }, | |
399 | + { label: '3N' }, | |
400 | + { label: 'BIJOU' }, | |
401 | + { label: '依视明' }, | |
402 | + { label: '博士伦' }, | |
403 | + { label: '瞳昕' }, | |
404 | + { label: '科莱博' }, | |
405 | + { label: '绮芙莉' }, | |
406 | + { label: '雅培' }, | |
407 | + { label: '爱能视' }, | |
408 | + { label: '女神秘语' }, | |
409 | + { label: '博视顿' }, | |
410 | + { label: '妆美堂' }, | |
411 | + { label: '人鱼姬' }, | |
412 | + { label: 'EverColor' }, | |
413 | + { label: 'Sincere' } | |
414 | + ] | |
415 | + }, | |
416 | + { | |
417 | + label: '工艺', | |
418 | + id: '159', | |
419 | + children: [{ label: '涂层工艺' }, { label: '三层夹色工艺' }] | |
420 | + }, | |
421 | + { | |
422 | + label: '材质', | |
423 | + id: '164', | |
424 | + children: [{ label: '硅水凝胶' }, { label: '水凝胶' }] | |
425 | + }, | |
426 | + { | |
427 | + label: '含水量', | |
428 | + id: '174', | |
429 | + children: [ | |
430 | + { label: '0-40%' }, | |
431 | + { label: '40-44%' }, | |
432 | + { label: '45%以上' } | |
433 | + ] | |
434 | + }, | |
435 | + { | |
436 | + label: '基弧', | |
437 | + id: '178', | |
438 | + children: [{ label: '0.0-8.4' }, { label: '8.4以上' }] | |
439 | + }, | |
440 | + { | |
441 | + label: '直径', | |
442 | + id: '181', | |
443 | + children: [{ label: '13.4-14' }, { label: '14以上' }] | |
444 | + }, | |
445 | + { | |
446 | + label: '中心厚度', | |
447 | + id: '184', | |
448 | + children: [ | |
449 | + { label: '0.0 - 0.03' }, | |
450 | + { label: '0.04 - 0.09' }, | |
451 | + { label: '0.1以上' } | |
452 | + ] | |
453 | + }, | |
454 | + { label: '销售保障', id: '253', children: [] }, | |
455 | + { label: '赠品', id: '260', children: [] } | |
456 | + ] | |
457 | + }, | |
458 | + { | |
459 | + label: '特种镜', | |
460 | + id: '146', | |
461 | + children: [ | |
462 | + { | |
463 | + label: '镜面颜色', | |
464 | + id: '237', | |
465 | + children: [{ label: '透明' }, { label: '亮金色' }] | |
466 | + }, | |
467 | + { | |
468 | + label: '品牌', | |
469 | + id: '238', | |
470 | + children: [{ label: '宁哥牌' }, { label: '秀野牌' }] | |
471 | + }, | |
472 | + { | |
473 | + label: '销售保障', | |
474 | + id: '254', | |
475 | + children: [{ label: '包退' }, { label: '包换' }] | |
476 | + }, | |
477 | + { | |
478 | + label: '功能', | |
479 | + id: '268', | |
480 | + children: [ | |
481 | + { label: '防风镜' }, | |
482 | + { label: '防爆溅工作镜' }, | |
483 | + { label: '泳镜' }, | |
484 | + { label: '智能镜' } | |
485 | + ] | |
486 | + } | |
487 | + ] | |
488 | + } | |
489 | + ], | |
490 | + defaultProps: { | |
491 | + children: 'children', | |
492 | + label: 'label' | |
493 | + } | |
494 | + } | |
495 | + }, | |
496 | + methods: { | |
497 | + getCheckedNodes() { | |
498 | + console.log(this.$refs.tree.getCheckedNodes()) | |
499 | + }, | |
500 | + getCheckedKeys() { | |
501 | + console.log(this.$refs.tree.getCheckedKeys()) | |
502 | + }, | |
503 | + addNode() { | |
504 | + let h | |
505 | + this.$message({ | |
506 | + message: h('p', null, [ | |
507 | + h('span', null, '添加一个新节点 ') | |
508 | + // h("i", { style: "color: teal" }, "VNode") | |
509 | + ]) | |
510 | + }) | |
511 | + }, | |
512 | + append(data) { | |
513 | + const newChild = { id: id++, label: 'testtest', children: [] } | |
514 | + if (!data.children) { | |
515 | + this.$set(data, 'children', []) | |
516 | + } | |
517 | + data.children.push(newChild) | |
518 | + }, | |
519 | + remove(node, data) { | |
520 | + // 删除 | |
521 | + const parent = node.parent | |
522 | + const children = parent.data.children || parent.data | |
523 | + const index = children.findIndex(d => d.id === data.id) | |
524 | + children.splice(index, 1) | |
525 | + }, | |
526 | + rightKey(node, data) { | |
527 | + // 右键 | |
528 | + const h = this.$createElement | |
529 | + // console.log(data, this.$refs.tree); | |
530 | + this.$message({ | |
531 | + message: h('p', null, [ | |
532 | + h('span', null, '右键了啊! ' + node + data), | |
533 | + h('i', { style: 'color: teal' }, 'VNode') | |
534 | + ]) | |
535 | + }) | |
536 | + }, | |
537 | + update(node, data) { | |
538 | + // 更新 | |
539 | + const h = this.$createElement | |
540 | + this.$message({ | |
541 | + message: h('p', null, [ | |
542 | + h('span', null, '内容可以是 '), | |
543 | + h('i', { style: 'color: teal' }, 'VNode') | |
544 | + ]) | |
545 | + }) | |
546 | + }, | |
547 | + setCheckedNodes() { | |
548 | + this.$refs.tree.setCheckedNodes([ | |
549 | + { | |
550 | + id: 5, | |
551 | + label: '二级 2-1' | |
552 | + }, | |
553 | + { | |
554 | + id: 9, | |
555 | + label: '三级 1-1-1' | |
556 | + } | |
557 | + ]) | |
558 | + }, | |
559 | + setCheckedKeys() { | |
560 | + this.$refs.tree.setCheckedKeys([3]) | |
561 | + }, | |
562 | + resetChecked() { | |
563 | + this.$refs.tree.setCheckedKeys([]) | |
564 | + } | |
565 | + } | |
566 | +} | |
567 | +</script> | |
568 | +<style> | |
569 | +.custom-tree-node { | |
570 | + flex: 1; | |
571 | + display: flex; | |
572 | + align-items: center; | |
573 | + justify-content: space-between; | |
574 | + font-size: 14px; | |
575 | + padding-right: 8px; | |
576 | +} | |
577 | +</style> | ... | ... |
src/views/logistics/logistics.vue
... | ... | @@ -0,0 +1,577 @@ |
1 | +<template> | |
2 | + <div class="login-container"> | |
3 | + <el-button | |
4 | + type="primary" | |
5 | + @click="() => addNode()" | |
6 | + >{{ $t('users.add') }}</el-button> | |
7 | + <el-tree | |
8 | + ref="tree" | |
9 | + :data="data" | |
10 | + show-checkbox | |
11 | + node-key="id" | |
12 | + highlight-current | |
13 | + check-strictly | |
14 | + indent="40" | |
15 | + icon-class="el-icon-pc" | |
16 | + :props="defaultProps" | |
17 | + > | |
18 | + <!-- <el-tree | |
19 | + :data="data" | |
20 | + show-checkbox | |
21 | + node-key="id" | |
22 | + default-expand-all | |
23 | + highlight-current | |
24 | + isLeaf | |
25 | + @node-contextmenu="()=>rightKey(node, data)" | |
26 | + check-strictly//在显示复选框的情况下,是否严格的遵循父子不互相关联的做法,默认为 false | |
27 | + :expand-on-click-node="false"//是否在点击节点的时候展开或者收缩节点, 默认值为 true,如果为 false,则只有点箭头图标的时候才会展开或者收缩节点。 | |
28 | + :props="defaultProps" | |
29 | + > --> | |
30 | + <span | |
31 | + slot-scope="{ node, data }" | |
32 | + class="custom-tree-node" | |
33 | + > | |
34 | + <span>{{ node.label }}</span> | |
35 | + <span> | |
36 | + <el-button | |
37 | + type="primary" | |
38 | + icon="el-icon-upload" | |
39 | + size="mini" | |
40 | + @click="() => append(data)" | |
41 | + > | |
42 | + {{ $t('users.add') }} | |
43 | + </el-button> | |
44 | + <el-button | |
45 | + type="primary" | |
46 | + icon="el-icon-edit" | |
47 | + size="mini" | |
48 | + @click="() => update(node, data)" | |
49 | + > | |
50 | + {{ $t('users.update') }} | |
51 | + </el-button> | |
52 | + <el-button | |
53 | + type="primary" | |
54 | + icon="el-icon-delete" | |
55 | + size="mini" | |
56 | + class="danger" | |
57 | + @click="() => remove(node, data)" | |
58 | + > | |
59 | + {{ $t('users.del') }} | |
60 | + </el-button> | |
61 | + </span> | |
62 | + </span> | |
63 | + </el-tree> | |
64 | + | |
65 | + <!-- <div class="buttons"> | |
66 | + <el-button @click="getCheckedNodes">通过 node 获取</el-button> | |
67 | + <el-button @click="getCheckedKeys">通过 key 获取</el-button> | |
68 | + <el-button @click="setCheckedNodes">通过 node 设置</el-button> | |
69 | + <el-button @click="setCheckedKeys">通过 key 设置</el-button> | |
70 | + <el-button @click="resetChecked">清空</el-button> | |
71 | + </div> --> | |
72 | + </div> | |
73 | +</template> | |
74 | +<script> | |
75 | +let id = 1000 | |
76 | +export default { | |
77 | + data() { | |
78 | + return { | |
79 | + data: [ | |
80 | + { | |
81 | + label: '成镜', | |
82 | + id: '1', | |
83 | + children: [ | |
84 | + { | |
85 | + label: '款式', | |
86 | + id: '11', | |
87 | + children: [ | |
88 | + { label: '青春学子风' }, | |
89 | + { label: '休闲' }, | |
90 | + { label: '商务' }, | |
91 | + { label: '复古' }, | |
92 | + { label: '时尚' }, | |
93 | + { label: '质感哥特潮' }, | |
94 | + { label: '轻简北欧风' }, | |
95 | + { label: '理性几何派' }, | |
96 | + { label: '多元新风尚' }, | |
97 | + { label: '立体巴洛克' }, | |
98 | + { label: '有机未来时' }, | |
99 | + { label: '无界人文系' }, | |
100 | + { label: '自然舒视角' }, | |
101 | + { label: '流线洛可可' }, | |
102 | + { label: '奶奶风' }, | |
103 | + { label: '简约-极简文艺范' }, | |
104 | + { label: '运动风' }, | |
105 | + { label: '行政风' }, | |
106 | + { label: '折射率' } | |
107 | + ] | |
108 | + }, | |
109 | + { label: '个性化服务', id: '267', children: [] }, | |
110 | + { | |
111 | + label: '赠品', | |
112 | + id: '259', | |
113 | + children: [{ label: '眼镜布' }, { label: '眼镜盒' }] | |
114 | + }, | |
115 | + { | |
116 | + label: '场景', | |
117 | + id: '258', | |
118 | + children: [ | |
119 | + { label: '学校场景' }, | |
120 | + { label: '出行交际' }, | |
121 | + { label: '夜店迷人' }, | |
122 | + { label: '明星同款' } | |
123 | + ] | |
124 | + }, | |
125 | + { | |
126 | + label: '销售保障', | |
127 | + id: '245', | |
128 | + children: [ | |
129 | + { label: '可退' }, | |
130 | + { label: '可换' }, | |
131 | + { label: '可修' } | |
132 | + ] | |
133 | + }, | |
134 | + { | |
135 | + label: '功能', | |
136 | + id: '140', | |
137 | + children: [ | |
138 | + { label: '防踩压' }, | |
139 | + { label: '防扭曲' }, | |
140 | + { label: '抗过敏' }, | |
141 | + { label: '防腐蚀' }, | |
142 | + { label: '耐磨损' }, | |
143 | + { label: '抗蓝光' } | |
144 | + ] | |
145 | + }, | |
146 | + { | |
147 | + label: '品牌', | |
148 | + id: '71', | |
149 | + children: [ | |
150 | + { label: '购易' }, | |
151 | + { label: '海俪恩' }, | |
152 | + { label: '沙漠风暴' }, | |
153 | + { label: '古诗' }, | |
154 | + { label: '暴龙' }, | |
155 | + { label: '犀牛' }, | |
156 | + { label: 'Ray-Ban雷朋' }, | |
157 | + { label: 'PARIM派丽蒙' }, | |
158 | + { label: '石狼' }, | |
159 | + { label: '木九十' } | |
160 | + ] | |
161 | + }, | |
162 | + { | |
163 | + label: '边形', | |
164 | + id: '49', | |
165 | + children: [ | |
166 | + { label: '半框' }, | |
167 | + { label: '全框' }, | |
168 | + { label: '无框' } | |
169 | + ] | |
170 | + }, | |
171 | + { | |
172 | + label: '性别', | |
173 | + id: '23', | |
174 | + children: [{ label: '男性' }, { label: '女性' }] | |
175 | + }, | |
176 | + { | |
177 | + label: '梁型', | |
178 | + id: '20', | |
179 | + children: [{ label: '双梁' }, { label: '单梁' }] | |
180 | + }, | |
181 | + { | |
182 | + label: '重量', | |
183 | + id: '19', | |
184 | + children: [{ label: '30克以下' }, { label: '80克以上' }] | |
185 | + }, | |
186 | + { | |
187 | + label: '适用脸型', | |
188 | + id: '15', | |
189 | + children: [{ label: '方' }, { label: '圆' }, { label: '瓜子' }] | |
190 | + }, | |
191 | + { | |
192 | + label: '形状', | |
193 | + id: '14', | |
194 | + children: [ | |
195 | + { label: '正圆形' }, | |
196 | + { label: '椭圆形' }, | |
197 | + { label: '方圆' }, | |
198 | + { label: '方形' }, | |
199 | + { label: '多边形' }, | |
200 | + { label: '内三角(蛤蟆)' }, | |
201 | + { label: '外三角(蝶形)' } | |
202 | + ] | |
203 | + }, | |
204 | + { label: '年龄', id: '12', children: [{ label: '通用' }] }, | |
205 | + { | |
206 | + label: '材质', | |
207 | + id: '10', | |
208 | + children: [ | |
209 | + { label: '板材' }, | |
210 | + { label: '纯钛' }, | |
211 | + { label: 'TR90' }, | |
212 | + { label: '木质' }, | |
213 | + { label: '竹质' }, | |
214 | + { label: 'β钛' }, | |
215 | + { label: 'PC' }, | |
216 | + { label: 'ULTEM塑钢' }, | |
217 | + { label: '钨钛塑钢' }, | |
218 | + { label: '镁铝合金' }, | |
219 | + { label: '碳纤维' } | |
220 | + ] | |
221 | + }, | |
222 | + { label: '折射率', id: '286', children: [] }, | |
223 | + { | |
224 | + label: '颜色', | |
225 | + id: '13', | |
226 | + children: [ | |
227 | + { label: '金色' }, | |
228 | + { label: '银色' }, | |
229 | + { label: '黑色' }, | |
230 | + { label: '彩色' }, | |
231 | + { label: '枪色' } | |
232 | + ] | |
233 | + } | |
234 | + ] | |
235 | + }, | |
236 | + { | |
237 | + label: '镜片', | |
238 | + id: '2', | |
239 | + children: [ | |
240 | + { | |
241 | + label: '面型', | |
242 | + id: '85', | |
243 | + children: [{ label: '球面单光' }, { label: '非球面单光' }] | |
244 | + }, | |
245 | + { label: '近视度数', id: '92', children: [] }, | |
246 | + { label: '散光', id: '93', children: [] }, | |
247 | + { | |
248 | + label: '功能', | |
249 | + id: '95', | |
250 | + children: [ | |
251 | + { label: '防起雾' }, | |
252 | + { label: '防蓝光' }, | |
253 | + { label: '防紫外线' }, | |
254 | + { label: '偏光' }, | |
255 | + { label: '染色' }, | |
256 | + { label: '抗疲劳' }, | |
257 | + { label: '青少年渐进' }, | |
258 | + { label: '内渐进' }, | |
259 | + { label: '变色' }, | |
260 | + { label: '双光' }, | |
261 | + { label: '耐磨损' }, | |
262 | + { label: '防尘' }, | |
263 | + { label: '防水' }, | |
264 | + { label: '防摔' }, | |
265 | + { label: '防指纹' }, | |
266 | + { label: '防反光' } | |
267 | + ] | |
268 | + }, | |
269 | + { | |
270 | + label: '颜色', | |
271 | + id: '100', | |
272 | + children: [ | |
273 | + { label: '透明' }, | |
274 | + { label: '染色' }, | |
275 | + { label: '变色' }, | |
276 | + { label: '单色' } | |
277 | + ] | |
278 | + }, | |
279 | + { | |
280 | + label: '折射率', | |
281 | + id: '101', | |
282 | + children: [ | |
283 | + { label: '1.56' }, | |
284 | + { label: '1.60' }, | |
285 | + { label: '1.65' }, | |
286 | + { label: '1.67' }, | |
287 | + { label: '1.71' }, | |
288 | + { label: '1.74' } | |
289 | + ] | |
290 | + }, | |
291 | + { label: '阿贝数(色散)', id: '102', children: [] }, | |
292 | + { label: '重量', id: '103', children: [] }, | |
293 | + { | |
294 | + label: '材质', | |
295 | + id: '104', | |
296 | + children: [ | |
297 | + { label: '树脂' }, | |
298 | + { label: '玻璃' }, | |
299 | + { label: '宇宙PC' }, | |
300 | + { label: 'PC' } | |
301 | + ] | |
302 | + }, | |
303 | + { | |
304 | + label: '品牌', | |
305 | + id: '118', | |
306 | + children: [ | |
307 | + { label: '好视力' }, | |
308 | + { label: 'RAISE锐视' }, | |
309 | + { label: '依视路' }, | |
310 | + { label: '凯米' }, | |
311 | + { label: '蔡司' }, | |
312 | + { label: '舒曼' } | |
313 | + ] | |
314 | + }, | |
315 | + { | |
316 | + label: '销售保障', | |
317 | + id: '249', | |
318 | + children: [ | |
319 | + { label: '可退' }, | |
320 | + { label: '可换' }, | |
321 | + { label: '可修' } | |
322 | + ] | |
323 | + } | |
324 | + ] | |
325 | + }, | |
326 | + { | |
327 | + label: '隐形眼镜', | |
328 | + id: '88', | |
329 | + children: [ | |
330 | + { | |
331 | + label: '颜色', | |
332 | + id: '105', | |
333 | + children: [ | |
334 | + { label: '绿' }, | |
335 | + { label: '灰' }, | |
336 | + { label: '黑' }, | |
337 | + { label: '紫' }, | |
338 | + { label: '蓝' }, | |
339 | + { label: '棕色' }, | |
340 | + { label: '紫色' } | |
341 | + ] | |
342 | + }, | |
343 | + { | |
344 | + label: '颜料', | |
345 | + id: '106', | |
346 | + children: [{ label: '水性' }, { label: '油性' }] | |
347 | + }, | |
348 | + { label: '度数', id: '107', children: [] }, | |
349 | + { | |
350 | + label: '周期', | |
351 | + id: '108', | |
352 | + children: [ | |
353 | + { label: '日抛' }, | |
354 | + { label: '周抛' }, | |
355 | + { label: '双周抛' }, | |
356 | + { label: '月抛' }, | |
357 | + { label: '季抛' }, | |
358 | + { label: '半年抛' }, | |
359 | + { label: '年抛' } | |
360 | + ] | |
361 | + }, | |
362 | + { | |
363 | + label: '品牌', | |
364 | + id: '133', | |
365 | + children: [ | |
366 | + { label: 'HolyNara' }, | |
367 | + { label: '爱尔康' }, | |
368 | + { label: 'MaxLook' }, | |
369 | + { label: 'NEO' }, | |
370 | + { label: 'GEO' }, | |
371 | + { label: '实瞳' }, | |
372 | + { label: '茵洛' }, | |
373 | + { label: 'DAZZSHOP' }, | |
374 | + { label: 'O-LENS' }, | |
375 | + { label: 'envie' }, | |
376 | + { label: '曼秀雷敦' }, | |
377 | + { label: '妃蜜莉' }, | |
378 | + { label: '海俪恩' }, | |
379 | + { label: '凯达' }, | |
380 | + { label: '蔡司' }, | |
381 | + { label: '酷视' }, | |
382 | + { label: 'LILMOON' }, | |
383 | + { label: 'RICHBABY' }, | |
384 | + { label: 'T-Garden' }, | |
385 | + { label: 'lenstown' }, | |
386 | + { label: '新加坡P2' }, | |
387 | + { label: '星欧' }, | |
388 | + { label: '美尼康' }, | |
389 | + { label: '美汐' }, | |
390 | + { label: '欧舒天' }, | |
391 | + { label: '海昌' }, | |
392 | + { label: '菲士康' }, | |
393 | + { label: '卫康' }, | |
394 | + { label: '库博' }, | |
395 | + { label: '安视优' }, | |
396 | + { label: '美若康' }, | |
397 | + { label: '视康' }, | |
398 | + { label: '澜柏' }, | |
399 | + { label: '3N' }, | |
400 | + { label: 'BIJOU' }, | |
401 | + { label: '依视明' }, | |
402 | + { label: '博士伦' }, | |
403 | + { label: '瞳昕' }, | |
404 | + { label: '科莱博' }, | |
405 | + { label: '绮芙莉' }, | |
406 | + { label: '雅培' }, | |
407 | + { label: '爱能视' }, | |
408 | + { label: '女神秘语' }, | |
409 | + { label: '博视顿' }, | |
410 | + { label: '妆美堂' }, | |
411 | + { label: '人鱼姬' }, | |
412 | + { label: 'EverColor' }, | |
413 | + { label: 'Sincere' } | |
414 | + ] | |
415 | + }, | |
416 | + { | |
417 | + label: '工艺', | |
418 | + id: '159', | |
419 | + children: [{ label: '涂层工艺' }, { label: '三层夹色工艺' }] | |
420 | + }, | |
421 | + { | |
422 | + label: '材质', | |
423 | + id: '164', | |
424 | + children: [{ label: '硅水凝胶' }, { label: '水凝胶' }] | |
425 | + }, | |
426 | + { | |
427 | + label: '含水量', | |
428 | + id: '174', | |
429 | + children: [ | |
430 | + { label: '0-40%' }, | |
431 | + { label: '40-44%' }, | |
432 | + { label: '45%以上' } | |
433 | + ] | |
434 | + }, | |
435 | + { | |
436 | + label: '基弧', | |
437 | + id: '178', | |
438 | + children: [{ label: '0.0-8.4' }, { label: '8.4以上' }] | |
439 | + }, | |
440 | + { | |
441 | + label: '直径', | |
442 | + id: '181', | |
443 | + children: [{ label: '13.4-14' }, { label: '14以上' }] | |
444 | + }, | |
445 | + { | |
446 | + label: '中心厚度', | |
447 | + id: '184', | |
448 | + children: [ | |
449 | + { label: '0.0 - 0.03' }, | |
450 | + { label: '0.04 - 0.09' }, | |
451 | + { label: '0.1以上' } | |
452 | + ] | |
453 | + }, | |
454 | + { label: '销售保障', id: '253', children: [] }, | |
455 | + { label: '赠品', id: '260', children: [] } | |
456 | + ] | |
457 | + }, | |
458 | + { | |
459 | + label: '特种镜', | |
460 | + id: '146', | |
461 | + children: [ | |
462 | + { | |
463 | + label: '镜面颜色', | |
464 | + id: '237', | |
465 | + children: [{ label: '透明' }, { label: '亮金色' }] | |
466 | + }, | |
467 | + { | |
468 | + label: '品牌', | |
469 | + id: '238', | |
470 | + children: [{ label: '宁哥牌' }, { label: '秀野牌' }] | |
471 | + }, | |
472 | + { | |
473 | + label: '销售保障', | |
474 | + id: '254', | |
475 | + children: [{ label: '包退' }, { label: '包换' }] | |
476 | + }, | |
477 | + { | |
478 | + label: '功能', | |
479 | + id: '268', | |
480 | + children: [ | |
481 | + { label: '防风镜' }, | |
482 | + { label: '防爆溅工作镜' }, | |
483 | + { label: '泳镜' }, | |
484 | + { label: '智能镜' } | |
485 | + ] | |
486 | + } | |
487 | + ] | |
488 | + } | |
489 | + ], | |
490 | + defaultProps: { | |
491 | + children: 'children', | |
492 | + label: 'label' | |
493 | + } | |
494 | + } | |
495 | + }, | |
496 | + methods: { | |
497 | + getCheckedNodes() { | |
498 | + console.log(this.$refs.tree.getCheckedNodes()) | |
499 | + }, | |
500 | + getCheckedKeys() { | |
501 | + console.log(this.$refs.tree.getCheckedKeys()) | |
502 | + }, | |
503 | + addNode() { | |
504 | + let h | |
505 | + this.$message({ | |
506 | + message: h('p', null, [ | |
507 | + h('span', null, '添加一个新节点 ') | |
508 | + // h("i", { style: "color: teal" }, "VNode") | |
509 | + ]) | |
510 | + }) | |
511 | + }, | |
512 | + append(data) { | |
513 | + const newChild = { id: id++, label: 'testtest', children: [] } | |
514 | + if (!data.children) { | |
515 | + this.$set(data, 'children', []) | |
516 | + } | |
517 | + data.children.push(newChild) | |
518 | + }, | |
519 | + remove(node, data) { | |
520 | + // 删除 | |
521 | + const parent = node.parent | |
522 | + const children = parent.data.children || parent.data | |
523 | + const index = children.findIndex(d => d.id === data.id) | |
524 | + children.splice(index, 1) | |
525 | + }, | |
526 | + rightKey(node, data) { | |
527 | + // 右键 | |
528 | + const h = this.$createElement | |
529 | + // console.log(data, this.$refs.tree); | |
530 | + this.$message({ | |
531 | + message: h('p', null, [ | |
532 | + h('span', null, '右键了啊! ' + node + data), | |
533 | + h('i', { style: 'color: teal' }, 'VNode') | |
534 | + ]) | |
535 | + }) | |
536 | + }, | |
537 | + update(node, data) { | |
538 | + // 更新 | |
539 | + const h = this.$createElement | |
540 | + this.$message({ | |
541 | + message: h('p', null, [ | |
542 | + h('span', null, '内容可以是 '), | |
543 | + h('i', { style: 'color: teal' }, 'VNode') | |
544 | + ]) | |
545 | + }) | |
546 | + }, | |
547 | + setCheckedNodes() { | |
548 | + this.$refs.tree.setCheckedNodes([ | |
549 | + { | |
550 | + id: 5, | |
551 | + label: '二级 2-1' | |
552 | + }, | |
553 | + { | |
554 | + id: 9, | |
555 | + label: '三级 1-1-1' | |
556 | + } | |
557 | + ]) | |
558 | + }, | |
559 | + setCheckedKeys() { | |
560 | + this.$refs.tree.setCheckedKeys([3]) | |
561 | + }, | |
562 | + resetChecked() { | |
563 | + this.$refs.tree.setCheckedKeys([]) | |
564 | + } | |
565 | + } | |
566 | +} | |
567 | +</script> | |
568 | +<style> | |
569 | +.custom-tree-node { | |
570 | + flex: 1; | |
571 | + display: flex; | |
572 | + align-items: center; | |
573 | + justify-content: space-between; | |
574 | + font-size: 14px; | |
575 | + padding-right: 8px; | |
576 | +} | |
577 | +</style> | ... | ... |
src/views/manufacturer/manufacturer.vue
... | ... | @@ -0,0 +1,577 @@ |
1 | +<template> | |
2 | + <div class="login-container"> | |
3 | + <el-button | |
4 | + type="primary" | |
5 | + @click="() => addNode()" | |
6 | + >{{ $t('users.add') }}</el-button> | |
7 | + <el-tree | |
8 | + ref="tree" | |
9 | + :data="data" | |
10 | + show-checkbox | |
11 | + node-key="id" | |
12 | + highlight-current | |
13 | + check-strictly | |
14 | + indent="40" | |
15 | + icon-class="el-icon-pc" | |
16 | + :props="defaultProps" | |
17 | + > | |
18 | + <!-- <el-tree | |
19 | + :data="data" | |
20 | + show-checkbox | |
21 | + node-key="id" | |
22 | + default-expand-all | |
23 | + highlight-current | |
24 | + isLeaf | |
25 | + @node-contextmenu="()=>rightKey(node, data)" | |
26 | + check-strictly//在显示复选框的情况下,是否严格的遵循父子不互相关联的做法,默认为 false | |
27 | + :expand-on-click-node="false"//是否在点击节点的时候展开或者收缩节点, 默认值为 true,如果为 false,则只有点箭头图标的时候才会展开或者收缩节点。 | |
28 | + :props="defaultProps" | |
29 | + > --> | |
30 | + <span | |
31 | + slot-scope="{ node, data }" | |
32 | + class="custom-tree-node" | |
33 | + > | |
34 | + <span>{{ node.label }}</span> | |
35 | + <span> | |
36 | + <el-button | |
37 | + type="primary" | |
38 | + icon="el-icon-upload" | |
39 | + size="mini" | |
40 | + @click="() => append(data)" | |
41 | + > | |
42 | + {{ $t('users.add') }} | |
43 | + </el-button> | |
44 | + <el-button | |
45 | + type="primary" | |
46 | + icon="el-icon-edit" | |
47 | + size="mini" | |
48 | + @click="() => update(node, data)" | |
49 | + > | |
50 | + {{ $t('users.update') }} | |
51 | + </el-button> | |
52 | + <el-button | |
53 | + type="primary" | |
54 | + icon="el-icon-delete" | |
55 | + size="mini" | |
56 | + class="danger" | |
57 | + @click="() => remove(node, data)" | |
58 | + > | |
59 | + {{ $t('users.del') }} | |
60 | + </el-button> | |
61 | + </span> | |
62 | + </span> | |
63 | + </el-tree> | |
64 | + | |
65 | + <!-- <div class="buttons"> | |
66 | + <el-button @click="getCheckedNodes">通过 node 获取</el-button> | |
67 | + <el-button @click="getCheckedKeys">通过 key 获取</el-button> | |
68 | + <el-button @click="setCheckedNodes">通过 node 设置</el-button> | |
69 | + <el-button @click="setCheckedKeys">通过 key 设置</el-button> | |
70 | + <el-button @click="resetChecked">清空</el-button> | |
71 | + </div> --> | |
72 | + </div> | |
73 | +</template> | |
74 | +<script> | |
75 | +let id = 1000 | |
76 | +export default { | |
77 | + data() { | |
78 | + return { | |
79 | + data: [ | |
80 | + { | |
81 | + label: '成镜', | |
82 | + id: '1', | |
83 | + children: [ | |
84 | + { | |
85 | + label: '款式', | |
86 | + id: '11', | |
87 | + children: [ | |
88 | + { label: '青春学子风' }, | |
89 | + { label: '休闲' }, | |
90 | + { label: '商务' }, | |
91 | + { label: '复古' }, | |
92 | + { label: '时尚' }, | |
93 | + { label: '质感哥特潮' }, | |
94 | + { label: '轻简北欧风' }, | |
95 | + { label: '理性几何派' }, | |
96 | + { label: '多元新风尚' }, | |
97 | + { label: '立体巴洛克' }, | |
98 | + { label: '有机未来时' }, | |
99 | + { label: '无界人文系' }, | |
100 | + { label: '自然舒视角' }, | |
101 | + { label: '流线洛可可' }, | |
102 | + { label: '奶奶风' }, | |
103 | + { label: '简约-极简文艺范' }, | |
104 | + { label: '运动风' }, | |
105 | + { label: '行政风' }, | |
106 | + { label: '折射率' } | |
107 | + ] | |
108 | + }, | |
109 | + { label: '个性化服务', id: '267', children: [] }, | |
110 | + { | |
111 | + label: '赠品', | |
112 | + id: '259', | |
113 | + children: [{ label: '眼镜布' }, { label: '眼镜盒' }] | |
114 | + }, | |
115 | + { | |
116 | + label: '场景', | |
117 | + id: '258', | |
118 | + children: [ | |
119 | + { label: '学校场景' }, | |
120 | + { label: '出行交际' }, | |
121 | + { label: '夜店迷人' }, | |
122 | + { label: '明星同款' } | |
123 | + ] | |
124 | + }, | |
125 | + { | |
126 | + label: '销售保障', | |
127 | + id: '245', | |
128 | + children: [ | |
129 | + { label: '可退' }, | |
130 | + { label: '可换' }, | |
131 | + { label: '可修' } | |
132 | + ] | |
133 | + }, | |
134 | + { | |
135 | + label: '功能', | |
136 | + id: '140', | |
137 | + children: [ | |
138 | + { label: '防踩压' }, | |
139 | + { label: '防扭曲' }, | |
140 | + { label: '抗过敏' }, | |
141 | + { label: '防腐蚀' }, | |
142 | + { label: '耐磨损' }, | |
143 | + { label: '抗蓝光' } | |
144 | + ] | |
145 | + }, | |
146 | + { | |
147 | + label: '品牌', | |
148 | + id: '71', | |
149 | + children: [ | |
150 | + { label: '购易' }, | |
151 | + { label: '海俪恩' }, | |
152 | + { label: '沙漠风暴' }, | |
153 | + { label: '古诗' }, | |
154 | + { label: '暴龙' }, | |
155 | + { label: '犀牛' }, | |
156 | + { label: 'Ray-Ban雷朋' }, | |
157 | + { label: 'PARIM派丽蒙' }, | |
158 | + { label: '石狼' }, | |
159 | + { label: '木九十' } | |
160 | + ] | |
161 | + }, | |
162 | + { | |
163 | + label: '边形', | |
164 | + id: '49', | |
165 | + children: [ | |
166 | + { label: '半框' }, | |
167 | + { label: '全框' }, | |
168 | + { label: '无框' } | |
169 | + ] | |
170 | + }, | |
171 | + { | |
172 | + label: '性别', | |
173 | + id: '23', | |
174 | + children: [{ label: '男性' }, { label: '女性' }] | |
175 | + }, | |
176 | + { | |
177 | + label: '梁型', | |
178 | + id: '20', | |
179 | + children: [{ label: '双梁' }, { label: '单梁' }] | |
180 | + }, | |
181 | + { | |
182 | + label: '重量', | |
183 | + id: '19', | |
184 | + children: [{ label: '30克以下' }, { label: '80克以上' }] | |
185 | + }, | |
186 | + { | |
187 | + label: '适用脸型', | |
188 | + id: '15', | |
189 | + children: [{ label: '方' }, { label: '圆' }, { label: '瓜子' }] | |
190 | + }, | |
191 | + { | |
192 | + label: '形状', | |
193 | + id: '14', | |
194 | + children: [ | |
195 | + { label: '正圆形' }, | |
196 | + { label: '椭圆形' }, | |
197 | + { label: '方圆' }, | |
198 | + { label: '方形' }, | |
199 | + { label: '多边形' }, | |
200 | + { label: '内三角(蛤蟆)' }, | |
201 | + { label: '外三角(蝶形)' } | |
202 | + ] | |
203 | + }, | |
204 | + { label: '年龄', id: '12', children: [{ label: '通用' }] }, | |
205 | + { | |
206 | + label: '材质', | |
207 | + id: '10', | |
208 | + children: [ | |
209 | + { label: '板材' }, | |
210 | + { label: '纯钛' }, | |
211 | + { label: 'TR90' }, | |
212 | + { label: '木质' }, | |
213 | + { label: '竹质' }, | |
214 | + { label: 'β钛' }, | |
215 | + { label: 'PC' }, | |
216 | + { label: 'ULTEM塑钢' }, | |
217 | + { label: '钨钛塑钢' }, | |
218 | + { label: '镁铝合金' }, | |
219 | + { label: '碳纤维' } | |
220 | + ] | |
221 | + }, | |
222 | + { label: '折射率', id: '286', children: [] }, | |
223 | + { | |
224 | + label: '颜色', | |
225 | + id: '13', | |
226 | + children: [ | |
227 | + { label: '金色' }, | |
228 | + { label: '银色' }, | |
229 | + { label: '黑色' }, | |
230 | + { label: '彩色' }, | |
231 | + { label: '枪色' } | |
232 | + ] | |
233 | + } | |
234 | + ] | |
235 | + }, | |
236 | + { | |
237 | + label: '镜片', | |
238 | + id: '2', | |
239 | + children: [ | |
240 | + { | |
241 | + label: '面型', | |
242 | + id: '85', | |
243 | + children: [{ label: '球面单光' }, { label: '非球面单光' }] | |
244 | + }, | |
245 | + { label: '近视度数', id: '92', children: [] }, | |
246 | + { label: '散光', id: '93', children: [] }, | |
247 | + { | |
248 | + label: '功能', | |
249 | + id: '95', | |
250 | + children: [ | |
251 | + { label: '防起雾' }, | |
252 | + { label: '防蓝光' }, | |
253 | + { label: '防紫外线' }, | |
254 | + { label: '偏光' }, | |
255 | + { label: '染色' }, | |
256 | + { label: '抗疲劳' }, | |
257 | + { label: '青少年渐进' }, | |
258 | + { label: '内渐进' }, | |
259 | + { label: '变色' }, | |
260 | + { label: '双光' }, | |
261 | + { label: '耐磨损' }, | |
262 | + { label: '防尘' }, | |
263 | + { label: '防水' }, | |
264 | + { label: '防摔' }, | |
265 | + { label: '防指纹' }, | |
266 | + { label: '防反光' } | |
267 | + ] | |
268 | + }, | |
269 | + { | |
270 | + label: '颜色', | |
271 | + id: '100', | |
272 | + children: [ | |
273 | + { label: '透明' }, | |
274 | + { label: '染色' }, | |
275 | + { label: '变色' }, | |
276 | + { label: '单色' } | |
277 | + ] | |
278 | + }, | |
279 | + { | |
280 | + label: '折射率', | |
281 | + id: '101', | |
282 | + children: [ | |
283 | + { label: '1.56' }, | |
284 | + { label: '1.60' }, | |
285 | + { label: '1.65' }, | |
286 | + { label: '1.67' }, | |
287 | + { label: '1.71' }, | |
288 | + { label: '1.74' } | |
289 | + ] | |
290 | + }, | |
291 | + { label: '阿贝数(色散)', id: '102', children: [] }, | |
292 | + { label: '重量', id: '103', children: [] }, | |
293 | + { | |
294 | + label: '材质', | |
295 | + id: '104', | |
296 | + children: [ | |
297 | + { label: '树脂' }, | |
298 | + { label: '玻璃' }, | |
299 | + { label: '宇宙PC' }, | |
300 | + { label: 'PC' } | |
301 | + ] | |
302 | + }, | |
303 | + { | |
304 | + label: '品牌', | |
305 | + id: '118', | |
306 | + children: [ | |
307 | + { label: '好视力' }, | |
308 | + { label: 'RAISE锐视' }, | |
309 | + { label: '依视路' }, | |
310 | + { label: '凯米' }, | |
311 | + { label: '蔡司' }, | |
312 | + { label: '舒曼' } | |
313 | + ] | |
314 | + }, | |
315 | + { | |
316 | + label: '销售保障', | |
317 | + id: '249', | |
318 | + children: [ | |
319 | + { label: '可退' }, | |
320 | + { label: '可换' }, | |
321 | + { label: '可修' } | |
322 | + ] | |
323 | + } | |
324 | + ] | |
325 | + }, | |
326 | + { | |
327 | + label: '隐形眼镜', | |
328 | + id: '88', | |
329 | + children: [ | |
330 | + { | |
331 | + label: '颜色', | |
332 | + id: '105', | |
333 | + children: [ | |
334 | + { label: '绿' }, | |
335 | + { label: '灰' }, | |
336 | + { label: '黑' }, | |
337 | + { label: '紫' }, | |
338 | + { label: '蓝' }, | |
339 | + { label: '棕色' }, | |
340 | + { label: '紫色' } | |
341 | + ] | |
342 | + }, | |
343 | + { | |
344 | + label: '颜料', | |
345 | + id: '106', | |
346 | + children: [{ label: '水性' }, { label: '油性' }] | |
347 | + }, | |
348 | + { label: '度数', id: '107', children: [] }, | |
349 | + { | |
350 | + label: '周期', | |
351 | + id: '108', | |
352 | + children: [ | |
353 | + { label: '日抛' }, | |
354 | + { label: '周抛' }, | |
355 | + { label: '双周抛' }, | |
356 | + { label: '月抛' }, | |
357 | + { label: '季抛' }, | |
358 | + { label: '半年抛' }, | |
359 | + { label: '年抛' } | |
360 | + ] | |
361 | + }, | |
362 | + { | |
363 | + label: '品牌', | |
364 | + id: '133', | |
365 | + children: [ | |
366 | + { label: 'HolyNara' }, | |
367 | + { label: '爱尔康' }, | |
368 | + { label: 'MaxLook' }, | |
369 | + { label: 'NEO' }, | |
370 | + { label: 'GEO' }, | |
371 | + { label: '实瞳' }, | |
372 | + { label: '茵洛' }, | |
373 | + { label: 'DAZZSHOP' }, | |
374 | + { label: 'O-LENS' }, | |
375 | + { label: 'envie' }, | |
376 | + { label: '曼秀雷敦' }, | |
377 | + { label: '妃蜜莉' }, | |
378 | + { label: '海俪恩' }, | |
379 | + { label: '凯达' }, | |
380 | + { label: '蔡司' }, | |
381 | + { label: '酷视' }, | |
382 | + { label: 'LILMOON' }, | |
383 | + { label: 'RICHBABY' }, | |
384 | + { label: 'T-Garden' }, | |
385 | + { label: 'lenstown' }, | |
386 | + { label: '新加坡P2' }, | |
387 | + { label: '星欧' }, | |
388 | + { label: '美尼康' }, | |
389 | + { label: '美汐' }, | |
390 | + { label: '欧舒天' }, | |
391 | + { label: '海昌' }, | |
392 | + { label: '菲士康' }, | |
393 | + { label: '卫康' }, | |
394 | + { label: '库博' }, | |
395 | + { label: '安视优' }, | |
396 | + { label: '美若康' }, | |
397 | + { label: '视康' }, | |
398 | + { label: '澜柏' }, | |
399 | + { label: '3N' }, | |
400 | + { label: 'BIJOU' }, | |
401 | + { label: '依视明' }, | |
402 | + { label: '博士伦' }, | |
403 | + { label: '瞳昕' }, | |
404 | + { label: '科莱博' }, | |
405 | + { label: '绮芙莉' }, | |
406 | + { label: '雅培' }, | |
407 | + { label: '爱能视' }, | |
408 | + { label: '女神秘语' }, | |
409 | + { label: '博视顿' }, | |
410 | + { label: '妆美堂' }, | |
411 | + { label: '人鱼姬' }, | |
412 | + { label: 'EverColor' }, | |
413 | + { label: 'Sincere' } | |
414 | + ] | |
415 | + }, | |
416 | + { | |
417 | + label: '工艺', | |
418 | + id: '159', | |
419 | + children: [{ label: '涂层工艺' }, { label: '三层夹色工艺' }] | |
420 | + }, | |
421 | + { | |
422 | + label: '材质', | |
423 | + id: '164', | |
424 | + children: [{ label: '硅水凝胶' }, { label: '水凝胶' }] | |
425 | + }, | |
426 | + { | |
427 | + label: '含水量', | |
428 | + id: '174', | |
429 | + children: [ | |
430 | + { label: '0-40%' }, | |
431 | + { label: '40-44%' }, | |
432 | + { label: '45%以上' } | |
433 | + ] | |
434 | + }, | |
435 | + { | |
436 | + label: '基弧', | |
437 | + id: '178', | |
438 | + children: [{ label: '0.0-8.4' }, { label: '8.4以上' }] | |
439 | + }, | |
440 | + { | |
441 | + label: '直径', | |
442 | + id: '181', | |
443 | + children: [{ label: '13.4-14' }, { label: '14以上' }] | |
444 | + }, | |
445 | + { | |
446 | + label: '中心厚度', | |
447 | + id: '184', | |
448 | + children: [ | |
449 | + { label: '0.0 - 0.03' }, | |
450 | + { label: '0.04 - 0.09' }, | |
451 | + { label: '0.1以上' } | |
452 | + ] | |
453 | + }, | |
454 | + { label: '销售保障', id: '253', children: [] }, | |
455 | + { label: '赠品', id: '260', children: [] } | |
456 | + ] | |
457 | + }, | |
458 | + { | |
459 | + label: '特种镜', | |
460 | + id: '146', | |
461 | + children: [ | |
462 | + { | |
463 | + label: '镜面颜色', | |
464 | + id: '237', | |
465 | + children: [{ label: '透明' }, { label: '亮金色' }] | |
466 | + }, | |
467 | + { | |
468 | + label: '品牌', | |
469 | + id: '238', | |
470 | + children: [{ label: '宁哥牌' }, { label: '秀野牌' }] | |
471 | + }, | |
472 | + { | |
473 | + label: '销售保障', | |
474 | + id: '254', | |
475 | + children: [{ label: '包退' }, { label: '包换' }] | |
476 | + }, | |
477 | + { | |
478 | + label: '功能', | |
479 | + id: '268', | |
480 | + children: [ | |
481 | + { label: '防风镜' }, | |
482 | + { label: '防爆溅工作镜' }, | |
483 | + { label: '泳镜' }, | |
484 | + { label: '智能镜' } | |
485 | + ] | |
486 | + } | |
487 | + ] | |
488 | + } | |
489 | + ], | |
490 | + defaultProps: { | |
491 | + children: 'children', | |
492 | + label: 'label' | |
493 | + } | |
494 | + } | |
495 | + }, | |
496 | + methods: { | |
497 | + getCheckedNodes() { | |
498 | + console.log(this.$refs.tree.getCheckedNodes()) | |
499 | + }, | |
500 | + getCheckedKeys() { | |
501 | + console.log(this.$refs.tree.getCheckedKeys()) | |
502 | + }, | |
503 | + addNode() { | |
504 | + let h | |
505 | + this.$message({ | |
506 | + message: h('p', null, [ | |
507 | + h('span', null, '添加一个新节点 ') | |
508 | + // h("i", { style: "color: teal" }, "VNode") | |
509 | + ]) | |
510 | + }) | |
511 | + }, | |
512 | + append(data) { | |
513 | + const newChild = { id: id++, label: 'testtest', children: [] } | |
514 | + if (!data.children) { | |
515 | + this.$set(data, 'children', []) | |
516 | + } | |
517 | + data.children.push(newChild) | |
518 | + }, | |
519 | + remove(node, data) { | |
520 | + // 删除 | |
521 | + const parent = node.parent | |
522 | + const children = parent.data.children || parent.data | |
523 | + const index = children.findIndex(d => d.id === data.id) | |
524 | + children.splice(index, 1) | |
525 | + }, | |
526 | + rightKey(node, data) { | |
527 | + // 右键 | |
528 | + const h = this.$createElement | |
529 | + // console.log(data, this.$refs.tree); | |
530 | + this.$message({ | |
531 | + message: h('p', null, [ | |
532 | + h('span', null, '右键了啊! ' + node + data), | |
533 | + h('i', { style: 'color: teal' }, 'VNode') | |
534 | + ]) | |
535 | + }) | |
536 | + }, | |
537 | + update(node, data) { | |
538 | + // 更新 | |
539 | + const h = this.$createElement | |
540 | + this.$message({ | |
541 | + message: h('p', null, [ | |
542 | + h('span', null, '内容可以是 '), | |
543 | + h('i', { style: 'color: teal' }, 'VNode') | |
544 | + ]) | |
545 | + }) | |
546 | + }, | |
547 | + setCheckedNodes() { | |
548 | + this.$refs.tree.setCheckedNodes([ | |
549 | + { | |
550 | + id: 5, | |
551 | + label: '二级 2-1' | |
552 | + }, | |
553 | + { | |
554 | + id: 9, | |
555 | + label: '三级 1-1-1' | |
556 | + } | |
557 | + ]) | |
558 | + }, | |
559 | + setCheckedKeys() { | |
560 | + this.$refs.tree.setCheckedKeys([3]) | |
561 | + }, | |
562 | + resetChecked() { | |
563 | + this.$refs.tree.setCheckedKeys([]) | |
564 | + } | |
565 | + } | |
566 | +} | |
567 | +</script> | |
568 | +<style> | |
569 | +.custom-tree-node { | |
570 | + flex: 1; | |
571 | + display: flex; | |
572 | + align-items: center; | |
573 | + justify-content: space-between; | |
574 | + font-size: 14px; | |
575 | + padding-right: 8px; | |
576 | +} | |
577 | +</style> | ... | ... |
src/views/operations/operations.vue
... | ... | @@ -0,0 +1,577 @@ |
1 | +<template> | |
2 | + <div class="login-container"> | |
3 | + <el-button | |
4 | + type="primary" | |
5 | + @click="() => addNode()" | |
6 | + >{{ $t('users.add') }}</el-button> | |
7 | + <el-tree | |
8 | + ref="tree" | |
9 | + :data="data" | |
10 | + show-checkbox | |
11 | + node-key="id" | |
12 | + highlight-current | |
13 | + check-strictly | |
14 | + indent="40" | |
15 | + icon-class="el-icon-pc" | |
16 | + :props="defaultProps" | |
17 | + > | |
18 | + <!-- <el-tree | |
19 | + :data="data" | |
20 | + show-checkbox | |
21 | + node-key="id" | |
22 | + default-expand-all | |
23 | + highlight-current | |
24 | + isLeaf | |
25 | + @node-contextmenu="()=>rightKey(node, data)" | |
26 | + check-strictly//在显示复选框的情况下,是否严格的遵循父子不互相关联的做法,默认为 false | |
27 | + :expand-on-click-node="false"//是否在点击节点的时候展开或者收缩节点, 默认值为 true,如果为 false,则只有点箭头图标的时候才会展开或者收缩节点。 | |
28 | + :props="defaultProps" | |
29 | + > --> | |
30 | + <span | |
31 | + slot-scope="{ node, data }" | |
32 | + class="custom-tree-node" | |
33 | + > | |
34 | + <span>{{ node.label }}</span> | |
35 | + <span> | |
36 | + <el-button | |
37 | + type="primary" | |
38 | + icon="el-icon-upload" | |
39 | + size="mini" | |
40 | + @click="() => append(data)" | |
41 | + > | |
42 | + {{ $t('users.add') }} | |
43 | + </el-button> | |
44 | + <el-button | |
45 | + type="primary" | |
46 | + icon="el-icon-edit" | |
47 | + size="mini" | |
48 | + @click="() => update(node, data)" | |
49 | + > | |
50 | + {{ $t('users.update') }} | |
51 | + </el-button> | |
52 | + <el-button | |
53 | + type="primary" | |
54 | + icon="el-icon-delete" | |
55 | + size="mini" | |
56 | + class="danger" | |
57 | + @click="() => remove(node, data)" | |
58 | + > | |
59 | + {{ $t('users.del') }} | |
60 | + </el-button> | |
61 | + </span> | |
62 | + </span> | |
63 | + </el-tree> | |
64 | + | |
65 | + <!-- <div class="buttons"> | |
66 | + <el-button @click="getCheckedNodes">通过 node 获取</el-button> | |
67 | + <el-button @click="getCheckedKeys">通过 key 获取</el-button> | |
68 | + <el-button @click="setCheckedNodes">通过 node 设置</el-button> | |
69 | + <el-button @click="setCheckedKeys">通过 key 设置</el-button> | |
70 | + <el-button @click="resetChecked">清空</el-button> | |
71 | + </div> --> | |
72 | + </div> | |
73 | +</template> | |
74 | +<script> | |
75 | +let id = 1000 | |
76 | +export default { | |
77 | + data() { | |
78 | + return { | |
79 | + data: [ | |
80 | + { | |
81 | + label: '成镜', | |
82 | + id: '1', | |
83 | + children: [ | |
84 | + { | |
85 | + label: '款式', | |
86 | + id: '11', | |
87 | + children: [ | |
88 | + { label: '青春学子风' }, | |
89 | + { label: '休闲' }, | |
90 | + { label: '商务' }, | |
91 | + { label: '复古' }, | |
92 | + { label: '时尚' }, | |
93 | + { label: '质感哥特潮' }, | |
94 | + { label: '轻简北欧风' }, | |
95 | + { label: '理性几何派' }, | |
96 | + { label: '多元新风尚' }, | |
97 | + { label: '立体巴洛克' }, | |
98 | + { label: '有机未来时' }, | |
99 | + { label: '无界人文系' }, | |
100 | + { label: '自然舒视角' }, | |
101 | + { label: '流线洛可可' }, | |
102 | + { label: '奶奶风' }, | |
103 | + { label: '简约-极简文艺范' }, | |
104 | + { label: '运动风' }, | |
105 | + { label: '行政风' }, | |
106 | + { label: '折射率' } | |
107 | + ] | |
108 | + }, | |
109 | + { label: '个性化服务', id: '267', children: [] }, | |
110 | + { | |
111 | + label: '赠品', | |
112 | + id: '259', | |
113 | + children: [{ label: '眼镜布' }, { label: '眼镜盒' }] | |
114 | + }, | |
115 | + { | |
116 | + label: '场景', | |
117 | + id: '258', | |
118 | + children: [ | |
119 | + { label: '学校场景' }, | |
120 | + { label: '出行交际' }, | |
121 | + { label: '夜店迷人' }, | |
122 | + { label: '明星同款' } | |
123 | + ] | |
124 | + }, | |
125 | + { | |
126 | + label: '销售保障', | |
127 | + id: '245', | |
128 | + children: [ | |
129 | + { label: '可退' }, | |
130 | + { label: '可换' }, | |
131 | + { label: '可修' } | |
132 | + ] | |
133 | + }, | |
134 | + { | |
135 | + label: '功能', | |
136 | + id: '140', | |
137 | + children: [ | |
138 | + { label: '防踩压' }, | |
139 | + { label: '防扭曲' }, | |
140 | + { label: '抗过敏' }, | |
141 | + { label: '防腐蚀' }, | |
142 | + { label: '耐磨损' }, | |
143 | + { label: '抗蓝光' } | |
144 | + ] | |
145 | + }, | |
146 | + { | |
147 | + label: '品牌', | |
148 | + id: '71', | |
149 | + children: [ | |
150 | + { label: '购易' }, | |
151 | + { label: '海俪恩' }, | |
152 | + { label: '沙漠风暴' }, | |
153 | + { label: '古诗' }, | |
154 | + { label: '暴龙' }, | |
155 | + { label: '犀牛' }, | |
156 | + { label: 'Ray-Ban雷朋' }, | |
157 | + { label: 'PARIM派丽蒙' }, | |
158 | + { label: '石狼' }, | |
159 | + { label: '木九十' } | |
160 | + ] | |
161 | + }, | |
162 | + { | |
163 | + label: '边形', | |
164 | + id: '49', | |
165 | + children: [ | |
166 | + { label: '半框' }, | |
167 | + { label: '全框' }, | |
168 | + { label: '无框' } | |
169 | + ] | |
170 | + }, | |
171 | + { | |
172 | + label: '性别', | |
173 | + id: '23', | |
174 | + children: [{ label: '男性' }, { label: '女性' }] | |
175 | + }, | |
176 | + { | |
177 | + label: '梁型', | |
178 | + id: '20', | |
179 | + children: [{ label: '双梁' }, { label: '单梁' }] | |
180 | + }, | |
181 | + { | |
182 | + label: '重量', | |
183 | + id: '19', | |
184 | + children: [{ label: '30克以下' }, { label: '80克以上' }] | |
185 | + }, | |
186 | + { | |
187 | + label: '适用脸型', | |
188 | + id: '15', | |
189 | + children: [{ label: '方' }, { label: '圆' }, { label: '瓜子' }] | |
190 | + }, | |
191 | + { | |
192 | + label: '形状', | |
193 | + id: '14', | |
194 | + children: [ | |
195 | + { label: '正圆形' }, | |
196 | + { label: '椭圆形' }, | |
197 | + { label: '方圆' }, | |
198 | + { label: '方形' }, | |
199 | + { label: '多边形' }, | |
200 | + { label: '内三角(蛤蟆)' }, | |
201 | + { label: '外三角(蝶形)' } | |
202 | + ] | |
203 | + }, | |
204 | + { label: '年龄', id: '12', children: [{ label: '通用' }] }, | |
205 | + { | |
206 | + label: '材质', | |
207 | + id: '10', | |
208 | + children: [ | |
209 | + { label: '板材' }, | |
210 | + { label: '纯钛' }, | |
211 | + { label: 'TR90' }, | |
212 | + { label: '木质' }, | |
213 | + { label: '竹质' }, | |
214 | + { label: 'β钛' }, | |
215 | + { label: 'PC' }, | |
216 | + { label: 'ULTEM塑钢' }, | |
217 | + { label: '钨钛塑钢' }, | |
218 | + { label: '镁铝合金' }, | |
219 | + { label: '碳纤维' } | |
220 | + ] | |
221 | + }, | |
222 | + { label: '折射率', id: '286', children: [] }, | |
223 | + { | |
224 | + label: '颜色', | |
225 | + id: '13', | |
226 | + children: [ | |
227 | + { label: '金色' }, | |
228 | + { label: '银色' }, | |
229 | + { label: '黑色' }, | |
230 | + { label: '彩色' }, | |
231 | + { label: '枪色' } | |
232 | + ] | |
233 | + } | |
234 | + ] | |
235 | + }, | |
236 | + { | |
237 | + label: '镜片', | |
238 | + id: '2', | |
239 | + children: [ | |
240 | + { | |
241 | + label: '面型', | |
242 | + id: '85', | |
243 | + children: [{ label: '球面单光' }, { label: '非球面单光' }] | |
244 | + }, | |
245 | + { label: '近视度数', id: '92', children: [] }, | |
246 | + { label: '散光', id: '93', children: [] }, | |
247 | + { | |
248 | + label: '功能', | |
249 | + id: '95', | |
250 | + children: [ | |
251 | + { label: '防起雾' }, | |
252 | + { label: '防蓝光' }, | |
253 | + { label: '防紫外线' }, | |
254 | + { label: '偏光' }, | |
255 | + { label: '染色' }, | |
256 | + { label: '抗疲劳' }, | |
257 | + { label: '青少年渐进' }, | |
258 | + { label: '内渐进' }, | |
259 | + { label: '变色' }, | |
260 | + { label: '双光' }, | |
261 | + { label: '耐磨损' }, | |
262 | + { label: '防尘' }, | |
263 | + { label: '防水' }, | |
264 | + { label: '防摔' }, | |
265 | + { label: '防指纹' }, | |
266 | + { label: '防反光' } | |
267 | + ] | |
268 | + }, | |
269 | + { | |
270 | + label: '颜色', | |
271 | + id: '100', | |
272 | + children: [ | |
273 | + { label: '透明' }, | |
274 | + { label: '染色' }, | |
275 | + { label: '变色' }, | |
276 | + { label: '单色' } | |
277 | + ] | |
278 | + }, | |
279 | + { | |
280 | + label: '折射率', | |
281 | + id: '101', | |
282 | + children: [ | |
283 | + { label: '1.56' }, | |
284 | + { label: '1.60' }, | |
285 | + { label: '1.65' }, | |
286 | + { label: '1.67' }, | |
287 | + { label: '1.71' }, | |
288 | + { label: '1.74' } | |
289 | + ] | |
290 | + }, | |
291 | + { label: '阿贝数(色散)', id: '102', children: [] }, | |
292 | + { label: '重量', id: '103', children: [] }, | |
293 | + { | |
294 | + label: '材质', | |
295 | + id: '104', | |
296 | + children: [ | |
297 | + { label: '树脂' }, | |
298 | + { label: '玻璃' }, | |
299 | + { label: '宇宙PC' }, | |
300 | + { label: 'PC' } | |
301 | + ] | |
302 | + }, | |
303 | + { | |
304 | + label: '品牌', | |
305 | + id: '118', | |
306 | + children: [ | |
307 | + { label: '好视力' }, | |
308 | + { label: 'RAISE锐视' }, | |
309 | + { label: '依视路' }, | |
310 | + { label: '凯米' }, | |
311 | + { label: '蔡司' }, | |
312 | + { label: '舒曼' } | |
313 | + ] | |
314 | + }, | |
315 | + { | |
316 | + label: '销售保障', | |
317 | + id: '249', | |
318 | + children: [ | |
319 | + { label: '可退' }, | |
320 | + { label: '可换' }, | |
321 | + { label: '可修' } | |
322 | + ] | |
323 | + } | |
324 | + ] | |
325 | + }, | |
326 | + { | |
327 | + label: '隐形眼镜', | |
328 | + id: '88', | |
329 | + children: [ | |
330 | + { | |
331 | + label: '颜色', | |
332 | + id: '105', | |
333 | + children: [ | |
334 | + { label: '绿' }, | |
335 | + { label: '灰' }, | |
336 | + { label: '黑' }, | |
337 | + { label: '紫' }, | |
338 | + { label: '蓝' }, | |
339 | + { label: '棕色' }, | |
340 | + { label: '紫色' } | |
341 | + ] | |
342 | + }, | |
343 | + { | |
344 | + label: '颜料', | |
345 | + id: '106', | |
346 | + children: [{ label: '水性' }, { label: '油性' }] | |
347 | + }, | |
348 | + { label: '度数', id: '107', children: [] }, | |
349 | + { | |
350 | + label: '周期', | |
351 | + id: '108', | |
352 | + children: [ | |
353 | + { label: '日抛' }, | |
354 | + { label: '周抛' }, | |
355 | + { label: '双周抛' }, | |
356 | + { label: '月抛' }, | |
357 | + { label: '季抛' }, | |
358 | + { label: '半年抛' }, | |
359 | + { label: '年抛' } | |
360 | + ] | |
361 | + }, | |
362 | + { | |
363 | + label: '品牌', | |
364 | + id: '133', | |
365 | + children: [ | |
366 | + { label: 'HolyNara' }, | |
367 | + { label: '爱尔康' }, | |
368 | + { label: 'MaxLook' }, | |
369 | + { label: 'NEO' }, | |
370 | + { label: 'GEO' }, | |
371 | + { label: '实瞳' }, | |
372 | + { label: '茵洛' }, | |
373 | + { label: 'DAZZSHOP' }, | |
374 | + { label: 'O-LENS' }, | |
375 | + { label: 'envie' }, | |
376 | + { label: '曼秀雷敦' }, | |
377 | + { label: '妃蜜莉' }, | |
378 | + { label: '海俪恩' }, | |
379 | + { label: '凯达' }, | |
380 | + { label: '蔡司' }, | |
381 | + { label: '酷视' }, | |
382 | + { label: 'LILMOON' }, | |
383 | + { label: 'RICHBABY' }, | |
384 | + { label: 'T-Garden' }, | |
385 | + { label: 'lenstown' }, | |
386 | + { label: '新加坡P2' }, | |
387 | + { label: '星欧' }, | |
388 | + { label: '美尼康' }, | |
389 | + { label: '美汐' }, | |
390 | + { label: '欧舒天' }, | |
391 | + { label: '海昌' }, | |
392 | + { label: '菲士康' }, | |
393 | + { label: '卫康' }, | |
394 | + { label: '库博' }, | |
395 | + { label: '安视优' }, | |
396 | + { label: '美若康' }, | |
397 | + { label: '视康' }, | |
398 | + { label: '澜柏' }, | |
399 | + { label: '3N' }, | |
400 | + { label: 'BIJOU' }, | |
401 | + { label: '依视明' }, | |
402 | + { label: '博士伦' }, | |
403 | + { label: '瞳昕' }, | |
404 | + { label: '科莱博' }, | |
405 | + { label: '绮芙莉' }, | |
406 | + { label: '雅培' }, | |
407 | + { label: '爱能视' }, | |
408 | + { label: '女神秘语' }, | |
409 | + { label: '博视顿' }, | |
410 | + { label: '妆美堂' }, | |
411 | + { label: '人鱼姬' }, | |
412 | + { label: 'EverColor' }, | |
413 | + { label: 'Sincere' } | |
414 | + ] | |
415 | + }, | |
416 | + { | |
417 | + label: '工艺', | |
418 | + id: '159', | |
419 | + children: [{ label: '涂层工艺' }, { label: '三层夹色工艺' }] | |
420 | + }, | |
421 | + { | |
422 | + label: '材质', | |
423 | + id: '164', | |
424 | + children: [{ label: '硅水凝胶' }, { label: '水凝胶' }] | |
425 | + }, | |
426 | + { | |
427 | + label: '含水量', | |
428 | + id: '174', | |
429 | + children: [ | |
430 | + { label: '0-40%' }, | |
431 | + { label: '40-44%' }, | |
432 | + { label: '45%以上' } | |
433 | + ] | |
434 | + }, | |
435 | + { | |
436 | + label: '基弧', | |
437 | + id: '178', | |
438 | + children: [{ label: '0.0-8.4' }, { label: '8.4以上' }] | |
439 | + }, | |
440 | + { | |
441 | + label: '直径', | |
442 | + id: '181', | |
443 | + children: [{ label: '13.4-14' }, { label: '14以上' }] | |
444 | + }, | |
445 | + { | |
446 | + label: '中心厚度', | |
447 | + id: '184', | |
448 | + children: [ | |
449 | + { label: '0.0 - 0.03' }, | |
450 | + { label: '0.04 - 0.09' }, | |
451 | + { label: '0.1以上' } | |
452 | + ] | |
453 | + }, | |
454 | + { label: '销售保障', id: '253', children: [] }, | |
455 | + { label: '赠品', id: '260', children: [] } | |
456 | + ] | |
457 | + }, | |
458 | + { | |
459 | + label: '特种镜', | |
460 | + id: '146', | |
461 | + children: [ | |
462 | + { | |
463 | + label: '镜面颜色', | |
464 | + id: '237', | |
465 | + children: [{ label: '透明' }, { label: '亮金色' }] | |
466 | + }, | |
467 | + { | |
468 | + label: '品牌', | |
469 | + id: '238', | |
470 | + children: [{ label: '宁哥牌' }, { label: '秀野牌' }] | |
471 | + }, | |
472 | + { | |
473 | + label: '销售保障', | |
474 | + id: '254', | |
475 | + children: [{ label: '包退' }, { label: '包换' }] | |
476 | + }, | |
477 | + { | |
478 | + label: '功能', | |
479 | + id: '268', | |
480 | + children: [ | |
481 | + { label: '防风镜' }, | |
482 | + { label: '防爆溅工作镜' }, | |
483 | + { label: '泳镜' }, | |
484 | + { label: '智能镜' } | |
485 | + ] | |
486 | + } | |
487 | + ] | |
488 | + } | |
489 | + ], | |
490 | + defaultProps: { | |
491 | + children: 'children', | |
492 | + label: 'label' | |
493 | + } | |
494 | + } | |
495 | + }, | |
496 | + methods: { | |
497 | + getCheckedNodes() { | |
498 | + console.log(this.$refs.tree.getCheckedNodes()) | |
499 | + }, | |
500 | + getCheckedKeys() { | |
501 | + console.log(this.$refs.tree.getCheckedKeys()) | |
502 | + }, | |
503 | + addNode() { | |
504 | + let h | |
505 | + this.$message({ | |
506 | + message: h('p', null, [ | |
507 | + h('span', null, '添加一个新节点 ') | |
508 | + // h("i", { style: "color: teal" }, "VNode") | |
509 | + ]) | |
510 | + }) | |
511 | + }, | |
512 | + append(data) { | |
513 | + const newChild = { id: id++, label: 'testtest', children: [] } | |
514 | + if (!data.children) { | |
515 | + this.$set(data, 'children', []) | |
516 | + } | |
517 | + data.children.push(newChild) | |
518 | + }, | |
519 | + remove(node, data) { | |
520 | + // 删除 | |
521 | + const parent = node.parent | |
522 | + const children = parent.data.children || parent.data | |
523 | + const index = children.findIndex(d => d.id === data.id) | |
524 | + children.splice(index, 1) | |
525 | + }, | |
526 | + rightKey(node, data) { | |
527 | + // 右键 | |
528 | + const h = this.$createElement | |
529 | + // console.log(data, this.$refs.tree); | |
530 | + this.$message({ | |
531 | + message: h('p', null, [ | |
532 | + h('span', null, '右键了啊! ' + node + data), | |
533 | + h('i', { style: 'color: teal' }, 'VNode') | |
534 | + ]) | |
535 | + }) | |
536 | + }, | |
537 | + update(node, data) { | |
538 | + // 更新 | |
539 | + const h = this.$createElement | |
540 | + this.$message({ | |
541 | + message: h('p', null, [ | |
542 | + h('span', null, '内容可以是 '), | |
543 | + h('i', { style: 'color: teal' }, 'VNode') | |
544 | + ]) | |
545 | + }) | |
546 | + }, | |
547 | + setCheckedNodes() { | |
548 | + this.$refs.tree.setCheckedNodes([ | |
549 | + { | |
550 | + id: 5, | |
551 | + label: '二级 2-1' | |
552 | + }, | |
553 | + { | |
554 | + id: 9, | |
555 | + label: '三级 1-1-1' | |
556 | + } | |
557 | + ]) | |
558 | + }, | |
559 | + setCheckedKeys() { | |
560 | + this.$refs.tree.setCheckedKeys([3]) | |
561 | + }, | |
562 | + resetChecked() { | |
563 | + this.$refs.tree.setCheckedKeys([]) | |
564 | + } | |
565 | + } | |
566 | +} | |
567 | +</script> | |
568 | +<style> | |
569 | +.custom-tree-node { | |
570 | + flex: 1; | |
571 | + display: flex; | |
572 | + align-items: center; | |
573 | + justify-content: space-between; | |
574 | + font-size: 14px; | |
575 | + padding-right: 8px; | |
576 | +} | |
577 | +</style> | ... | ... |
src/views/recommend/recommend.vue
... | ... | @@ -0,0 +1,577 @@ |
1 | +<template> | |
2 | + <div class="login-container"> | |
3 | + <el-button | |
4 | + type="primary" | |
5 | + @click="() => addNode()" | |
6 | + >{{ $t('users.add') }}</el-button> | |
7 | + <el-tree | |
8 | + ref="tree" | |
9 | + :data="data" | |
10 | + show-checkbox | |
11 | + node-key="id" | |
12 | + highlight-current | |
13 | + check-strictly | |
14 | + indent="40" | |
15 | + icon-class="el-icon-pc" | |
16 | + :props="defaultProps" | |
17 | + > | |
18 | + <!-- <el-tree | |
19 | + :data="data" | |
20 | + show-checkbox | |
21 | + node-key="id" | |
22 | + default-expand-all | |
23 | + highlight-current | |
24 | + isLeaf | |
25 | + @node-contextmenu="()=>rightKey(node, data)" | |
26 | + check-strictly//在显示复选框的情况下,是否严格的遵循父子不互相关联的做法,默认为 false | |
27 | + :expand-on-click-node="false"//是否在点击节点的时候展开或者收缩节点, 默认值为 true,如果为 false,则只有点箭头图标的时候才会展开或者收缩节点。 | |
28 | + :props="defaultProps" | |
29 | + > --> | |
30 | + <span | |
31 | + slot-scope="{ node, data }" | |
32 | + class="custom-tree-node" | |
33 | + > | |
34 | + <span>{{ node.label }}</span> | |
35 | + <span> | |
36 | + <el-button | |
37 | + type="primary" | |
38 | + icon="el-icon-upload" | |
39 | + size="mini" | |
40 | + @click="() => append(data)" | |
41 | + > | |
42 | + {{ $t('users.add') }} | |
43 | + </el-button> | |
44 | + <el-button | |
45 | + type="primary" | |
46 | + icon="el-icon-edit" | |
47 | + size="mini" | |
48 | + @click="() => update(node, data)" | |
49 | + > | |
50 | + {{ $t('users.update') }} | |
51 | + </el-button> | |
52 | + <el-button | |
53 | + type="primary" | |
54 | + icon="el-icon-delete" | |
55 | + size="mini" | |
56 | + class="danger" | |
57 | + @click="() => remove(node, data)" | |
58 | + > | |
59 | + {{ $t('users.del') }} | |
60 | + </el-button> | |
61 | + </span> | |
62 | + </span> | |
63 | + </el-tree> | |
64 | + | |
65 | + <!-- <div class="buttons"> | |
66 | + <el-button @click="getCheckedNodes">通过 node 获取</el-button> | |
67 | + <el-button @click="getCheckedKeys">通过 key 获取</el-button> | |
68 | + <el-button @click="setCheckedNodes">通过 node 设置</el-button> | |
69 | + <el-button @click="setCheckedKeys">通过 key 设置</el-button> | |
70 | + <el-button @click="resetChecked">清空</el-button> | |
71 | + </div> --> | |
72 | + </div> | |
73 | +</template> | |
74 | +<script> | |
75 | +let id = 1000 | |
76 | +export default { | |
77 | + data() { | |
78 | + return { | |
79 | + data: [ | |
80 | + { | |
81 | + label: '成镜', | |
82 | + id: '1', | |
83 | + children: [ | |
84 | + { | |
85 | + label: '款式', | |
86 | + id: '11', | |
87 | + children: [ | |
88 | + { label: '青春学子风' }, | |
89 | + { label: '休闲' }, | |
90 | + { label: '商务' }, | |
91 | + { label: '复古' }, | |
92 | + { label: '时尚' }, | |
93 | + { label: '质感哥特潮' }, | |
94 | + { label: '轻简北欧风' }, | |
95 | + { label: '理性几何派' }, | |
96 | + { label: '多元新风尚' }, | |
97 | + { label: '立体巴洛克' }, | |
98 | + { label: '有机未来时' }, | |
99 | + { label: '无界人文系' }, | |
100 | + { label: '自然舒视角' }, | |
101 | + { label: '流线洛可可' }, | |
102 | + { label: '奶奶风' }, | |
103 | + { label: '简约-极简文艺范' }, | |
104 | + { label: '运动风' }, | |
105 | + { label: '行政风' }, | |
106 | + { label: '折射率' } | |
107 | + ] | |
108 | + }, | |
109 | + { label: '个性化服务', id: '267', children: [] }, | |
110 | + { | |
111 | + label: '赠品', | |
112 | + id: '259', | |
113 | + children: [{ label: '眼镜布' }, { label: '眼镜盒' }] | |
114 | + }, | |
115 | + { | |
116 | + label: '场景', | |
117 | + id: '258', | |
118 | + children: [ | |
119 | + { label: '学校场景' }, | |
120 | + { label: '出行交际' }, | |
121 | + { label: '夜店迷人' }, | |
122 | + { label: '明星同款' } | |
123 | + ] | |
124 | + }, | |
125 | + { | |
126 | + label: '销售保障', | |
127 | + id: '245', | |
128 | + children: [ | |
129 | + { label: '可退' }, | |
130 | + { label: '可换' }, | |
131 | + { label: '可修' } | |
132 | + ] | |
133 | + }, | |
134 | + { | |
135 | + label: '功能', | |
136 | + id: '140', | |
137 | + children: [ | |
138 | + { label: '防踩压' }, | |
139 | + { label: '防扭曲' }, | |
140 | + { label: '抗过敏' }, | |
141 | + { label: '防腐蚀' }, | |
142 | + { label: '耐磨损' }, | |
143 | + { label: '抗蓝光' } | |
144 | + ] | |
145 | + }, | |
146 | + { | |
147 | + label: '品牌', | |
148 | + id: '71', | |
149 | + children: [ | |
150 | + { label: '购易' }, | |
151 | + { label: '海俪恩' }, | |
152 | + { label: '沙漠风暴' }, | |
153 | + { label: '古诗' }, | |
154 | + { label: '暴龙' }, | |
155 | + { label: '犀牛' }, | |
156 | + { label: 'Ray-Ban雷朋' }, | |
157 | + { label: 'PARIM派丽蒙' }, | |
158 | + { label: '石狼' }, | |
159 | + { label: '木九十' } | |
160 | + ] | |
161 | + }, | |
162 | + { | |
163 | + label: '边形', | |
164 | + id: '49', | |
165 | + children: [ | |
166 | + { label: '半框' }, | |
167 | + { label: '全框' }, | |
168 | + { label: '无框' } | |
169 | + ] | |
170 | + }, | |
171 | + { | |
172 | + label: '性别', | |
173 | + id: '23', | |
174 | + children: [{ label: '男性' }, { label: '女性' }] | |
175 | + }, | |
176 | + { | |
177 | + label: '梁型', | |
178 | + id: '20', | |
179 | + children: [{ label: '双梁' }, { label: '单梁' }] | |
180 | + }, | |
181 | + { | |
182 | + label: '重量', | |
183 | + id: '19', | |
184 | + children: [{ label: '30克以下' }, { label: '80克以上' }] | |
185 | + }, | |
186 | + { | |
187 | + label: '适用脸型', | |
188 | + id: '15', | |
189 | + children: [{ label: '方' }, { label: '圆' }, { label: '瓜子' }] | |
190 | + }, | |
191 | + { | |
192 | + label: '形状', | |
193 | + id: '14', | |
194 | + children: [ | |
195 | + { label: '正圆形' }, | |
196 | + { label: '椭圆形' }, | |
197 | + { label: '方圆' }, | |
198 | + { label: '方形' }, | |
199 | + { label: '多边形' }, | |
200 | + { label: '内三角(蛤蟆)' }, | |
201 | + { label: '外三角(蝶形)' } | |
202 | + ] | |
203 | + }, | |
204 | + { label: '年龄', id: '12', children: [{ label: '通用' }] }, | |
205 | + { | |
206 | + label: '材质', | |
207 | + id: '10', | |
208 | + children: [ | |
209 | + { label: '板材' }, | |
210 | + { label: '纯钛' }, | |
211 | + { label: 'TR90' }, | |
212 | + { label: '木质' }, | |
213 | + { label: '竹质' }, | |
214 | + { label: 'β钛' }, | |
215 | + { label: 'PC' }, | |
216 | + { label: 'ULTEM塑钢' }, | |
217 | + { label: '钨钛塑钢' }, | |
218 | + { label: '镁铝合金' }, | |
219 | + { label: '碳纤维' } | |
220 | + ] | |
221 | + }, | |
222 | + { label: '折射率', id: '286', children: [] }, | |
223 | + { | |
224 | + label: '颜色', | |
225 | + id: '13', | |
226 | + children: [ | |
227 | + { label: '金色' }, | |
228 | + { label: '银色' }, | |
229 | + { label: '黑色' }, | |
230 | + { label: '彩色' }, | |
231 | + { label: '枪色' } | |
232 | + ] | |
233 | + } | |
234 | + ] | |
235 | + }, | |
236 | + { | |
237 | + label: '镜片', | |
238 | + id: '2', | |
239 | + children: [ | |
240 | + { | |
241 | + label: '面型', | |
242 | + id: '85', | |
243 | + children: [{ label: '球面单光' }, { label: '非球面单光' }] | |
244 | + }, | |
245 | + { label: '近视度数', id: '92', children: [] }, | |
246 | + { label: '散光', id: '93', children: [] }, | |
247 | + { | |
248 | + label: '功能', | |
249 | + id: '95', | |
250 | + children: [ | |
251 | + { label: '防起雾' }, | |
252 | + { label: '防蓝光' }, | |
253 | + { label: '防紫外线' }, | |
254 | + { label: '偏光' }, | |
255 | + { label: '染色' }, | |
256 | + { label: '抗疲劳' }, | |
257 | + { label: '青少年渐进' }, | |
258 | + { label: '内渐进' }, | |
259 | + { label: '变色' }, | |
260 | + { label: '双光' }, | |
261 | + { label: '耐磨损' }, | |
262 | + { label: '防尘' }, | |
263 | + { label: '防水' }, | |
264 | + { label: '防摔' }, | |
265 | + { label: '防指纹' }, | |
266 | + { label: '防反光' } | |
267 | + ] | |
268 | + }, | |
269 | + { | |
270 | + label: '颜色', | |
271 | + id: '100', | |
272 | + children: [ | |
273 | + { label: '透明' }, | |
274 | + { label: '染色' }, | |
275 | + { label: '变色' }, | |
276 | + { label: '单色' } | |
277 | + ] | |
278 | + }, | |
279 | + { | |
280 | + label: '折射率', | |
281 | + id: '101', | |
282 | + children: [ | |
283 | + { label: '1.56' }, | |
284 | + { label: '1.60' }, | |
285 | + { label: '1.65' }, | |
286 | + { label: '1.67' }, | |
287 | + { label: '1.71' }, | |
288 | + { label: '1.74' } | |
289 | + ] | |
290 | + }, | |
291 | + { label: '阿贝数(色散)', id: '102', children: [] }, | |
292 | + { label: '重量', id: '103', children: [] }, | |
293 | + { | |
294 | + label: '材质', | |
295 | + id: '104', | |
296 | + children: [ | |
297 | + { label: '树脂' }, | |
298 | + { label: '玻璃' }, | |
299 | + { label: '宇宙PC' }, | |
300 | + { label: 'PC' } | |
301 | + ] | |
302 | + }, | |
303 | + { | |
304 | + label: '品牌', | |
305 | + id: '118', | |
306 | + children: [ | |
307 | + { label: '好视力' }, | |
308 | + { label: 'RAISE锐视' }, | |
309 | + { label: '依视路' }, | |
310 | + { label: '凯米' }, | |
311 | + { label: '蔡司' }, | |
312 | + { label: '舒曼' } | |
313 | + ] | |
314 | + }, | |
315 | + { | |
316 | + label: '销售保障', | |
317 | + id: '249', | |
318 | + children: [ | |
319 | + { label: '可退' }, | |
320 | + { label: '可换' }, | |
321 | + { label: '可修' } | |
322 | + ] | |
323 | + } | |
324 | + ] | |
325 | + }, | |
326 | + { | |
327 | + label: '隐形眼镜', | |
328 | + id: '88', | |
329 | + children: [ | |
330 | + { | |
331 | + label: '颜色', | |
332 | + id: '105', | |
333 | + children: [ | |
334 | + { label: '绿' }, | |
335 | + { label: '灰' }, | |
336 | + { label: '黑' }, | |
337 | + { label: '紫' }, | |
338 | + { label: '蓝' }, | |
339 | + { label: '棕色' }, | |
340 | + { label: '紫色' } | |
341 | + ] | |
342 | + }, | |
343 | + { | |
344 | + label: '颜料', | |
345 | + id: '106', | |
346 | + children: [{ label: '水性' }, { label: '油性' }] | |
347 | + }, | |
348 | + { label: '度数', id: '107', children: [] }, | |
349 | + { | |
350 | + label: '周期', | |
351 | + id: '108', | |
352 | + children: [ | |
353 | + { label: '日抛' }, | |
354 | + { label: '周抛' }, | |
355 | + { label: '双周抛' }, | |
356 | + { label: '月抛' }, | |
357 | + { label: '季抛' }, | |
358 | + { label: '半年抛' }, | |
359 | + { label: '年抛' } | |
360 | + ] | |
361 | + }, | |
362 | + { | |
363 | + label: '品牌', | |
364 | + id: '133', | |
365 | + children: [ | |
366 | + { label: 'HolyNara' }, | |
367 | + { label: '爱尔康' }, | |
368 | + { label: 'MaxLook' }, | |
369 | + { label: 'NEO' }, | |
370 | + { label: 'GEO' }, | |
371 | + { label: '实瞳' }, | |
372 | + { label: '茵洛' }, | |
373 | + { label: 'DAZZSHOP' }, | |
374 | + { label: 'O-LENS' }, | |
375 | + { label: 'envie' }, | |
376 | + { label: '曼秀雷敦' }, | |
377 | + { label: '妃蜜莉' }, | |
378 | + { label: '海俪恩' }, | |
379 | + { label: '凯达' }, | |
380 | + { label: '蔡司' }, | |
381 | + { label: '酷视' }, | |
382 | + { label: 'LILMOON' }, | |
383 | + { label: 'RICHBABY' }, | |
384 | + { label: 'T-Garden' }, | |
385 | + { label: 'lenstown' }, | |
386 | + { label: '新加坡P2' }, | |
387 | + { label: '星欧' }, | |
388 | + { label: '美尼康' }, | |
389 | + { label: '美汐' }, | |
390 | + { label: '欧舒天' }, | |
391 | + { label: '海昌' }, | |
392 | + { label: '菲士康' }, | |
393 | + { label: '卫康' }, | |
394 | + { label: '库博' }, | |
395 | + { label: '安视优' }, | |
396 | + { label: '美若康' }, | |
397 | + { label: '视康' }, | |
398 | + { label: '澜柏' }, | |
399 | + { label: '3N' }, | |
400 | + { label: 'BIJOU' }, | |
401 | + { label: '依视明' }, | |
402 | + { label: '博士伦' }, | |
403 | + { label: '瞳昕' }, | |
404 | + { label: '科莱博' }, | |
405 | + { label: '绮芙莉' }, | |
406 | + { label: '雅培' }, | |
407 | + { label: '爱能视' }, | |
408 | + { label: '女神秘语' }, | |
409 | + { label: '博视顿' }, | |
410 | + { label: '妆美堂' }, | |
411 | + { label: '人鱼姬' }, | |
412 | + { label: 'EverColor' }, | |
413 | + { label: 'Sincere' } | |
414 | + ] | |
415 | + }, | |
416 | + { | |
417 | + label: '工艺', | |
418 | + id: '159', | |
419 | + children: [{ label: '涂层工艺' }, { label: '三层夹色工艺' }] | |
420 | + }, | |
421 | + { | |
422 | + label: '材质', | |
423 | + id: '164', | |
424 | + children: [{ label: '硅水凝胶' }, { label: '水凝胶' }] | |
425 | + }, | |
426 | + { | |
427 | + label: '含水量', | |
428 | + id: '174', | |
429 | + children: [ | |
430 | + { label: '0-40%' }, | |
431 | + { label: '40-44%' }, | |
432 | + { label: '45%以上' } | |
433 | + ] | |
434 | + }, | |
435 | + { | |
436 | + label: '基弧', | |
437 | + id: '178', | |
438 | + children: [{ label: '0.0-8.4' }, { label: '8.4以上' }] | |
439 | + }, | |
440 | + { | |
441 | + label: '直径', | |
442 | + id: '181', | |
443 | + children: [{ label: '13.4-14' }, { label: '14以上' }] | |
444 | + }, | |
445 | + { | |
446 | + label: '中心厚度', | |
447 | + id: '184', | |
448 | + children: [ | |
449 | + { label: '0.0 - 0.03' }, | |
450 | + { label: '0.04 - 0.09' }, | |
451 | + { label: '0.1以上' } | |
452 | + ] | |
453 | + }, | |
454 | + { label: '销售保障', id: '253', children: [] }, | |
455 | + { label: '赠品', id: '260', children: [] } | |
456 | + ] | |
457 | + }, | |
458 | + { | |
459 | + label: '特种镜', | |
460 | + id: '146', | |
461 | + children: [ | |
462 | + { | |
463 | + label: '镜面颜色', | |
464 | + id: '237', | |
465 | + children: [{ label: '透明' }, { label: '亮金色' }] | |
466 | + }, | |
467 | + { | |
468 | + label: '品牌', | |
469 | + id: '238', | |
470 | + children: [{ label: '宁哥牌' }, { label: '秀野牌' }] | |
471 | + }, | |
472 | + { | |
473 | + label: '销售保障', | |
474 | + id: '254', | |
475 | + children: [{ label: '包退' }, { label: '包换' }] | |
476 | + }, | |
477 | + { | |
478 | + label: '功能', | |
479 | + id: '268', | |
480 | + children: [ | |
481 | + { label: '防风镜' }, | |
482 | + { label: '防爆溅工作镜' }, | |
483 | + { label: '泳镜' }, | |
484 | + { label: '智能镜' } | |
485 | + ] | |
486 | + } | |
487 | + ] | |
488 | + } | |
489 | + ], | |
490 | + defaultProps: { | |
491 | + children: 'children', | |
492 | + label: 'label' | |
493 | + } | |
494 | + } | |
495 | + }, | |
496 | + methods: { | |
497 | + getCheckedNodes() { | |
498 | + console.log(this.$refs.tree.getCheckedNodes()) | |
499 | + }, | |
500 | + getCheckedKeys() { | |
501 | + console.log(this.$refs.tree.getCheckedKeys()) | |
502 | + }, | |
503 | + addNode() { | |
504 | + let h | |
505 | + this.$message({ | |
506 | + message: h('p', null, [ | |
507 | + h('span', null, '添加一个新节点 ') | |
508 | + // h("i", { style: "color: teal" }, "VNode") | |
509 | + ]) | |
510 | + }) | |
511 | + }, | |
512 | + append(data) { | |
513 | + const newChild = { id: id++, label: 'testtest', children: [] } | |
514 | + if (!data.children) { | |
515 | + this.$set(data, 'children', []) | |
516 | + } | |
517 | + data.children.push(newChild) | |
518 | + }, | |
519 | + remove(node, data) { | |
520 | + // 删除 | |
521 | + const parent = node.parent | |
522 | + const children = parent.data.children || parent.data | |
523 | + const index = children.findIndex(d => d.id === data.id) | |
524 | + children.splice(index, 1) | |
525 | + }, | |
526 | + rightKey(node, data) { | |
527 | + // 右键 | |
528 | + const h = this.$createElement | |
529 | + // console.log(data, this.$refs.tree); | |
530 | + this.$message({ | |
531 | + message: h('p', null, [ | |
532 | + h('span', null, '右键了啊! ' + node + data), | |
533 | + h('i', { style: 'color: teal' }, 'VNode') | |
534 | + ]) | |
535 | + }) | |
536 | + }, | |
537 | + update(node, data) { | |
538 | + // 更新 | |
539 | + const h = this.$createElement | |
540 | + this.$message({ | |
541 | + message: h('p', null, [ | |
542 | + h('span', null, '内容可以是 '), | |
543 | + h('i', { style: 'color: teal' }, 'VNode') | |
544 | + ]) | |
545 | + }) | |
546 | + }, | |
547 | + setCheckedNodes() { | |
548 | + this.$refs.tree.setCheckedNodes([ | |
549 | + { | |
550 | + id: 5, | |
551 | + label: '二级 2-1' | |
552 | + }, | |
553 | + { | |
554 | + id: 9, | |
555 | + label: '三级 1-1-1' | |
556 | + } | |
557 | + ]) | |
558 | + }, | |
559 | + setCheckedKeys() { | |
560 | + this.$refs.tree.setCheckedKeys([3]) | |
561 | + }, | |
562 | + resetChecked() { | |
563 | + this.$refs.tree.setCheckedKeys([]) | |
564 | + } | |
565 | + } | |
566 | +} | |
567 | +</script> | |
568 | +<style> | |
569 | +.custom-tree-node { | |
570 | + flex: 1; | |
571 | + display: flex; | |
572 | + align-items: center; | |
573 | + justify-content: space-between; | |
574 | + font-size: 14px; | |
575 | + padding-right: 8px; | |
576 | +} | |
577 | +</style> | ... | ... |
src/views/staff/staff.vue
... | ... | @@ -0,0 +1,577 @@ |
1 | +<template> | |
2 | + <div class="login-container"> | |
3 | + <el-button | |
4 | + type="primary" | |
5 | + @click="() => addNode()" | |
6 | + >{{ $t('users.add') }}</el-button> | |
7 | + <el-tree | |
8 | + ref="tree" | |
9 | + :data="data" | |
10 | + show-checkbox | |
11 | + node-key="id" | |
12 | + highlight-current | |
13 | + check-strictly | |
14 | + indent="40" | |
15 | + icon-class="el-icon-pc" | |
16 | + :props="defaultProps" | |
17 | + > | |
18 | + <!-- <el-tree | |
19 | + :data="data" | |
20 | + show-checkbox | |
21 | + node-key="id" | |
22 | + default-expand-all | |
23 | + highlight-current | |
24 | + isLeaf | |
25 | + @node-contextmenu="()=>rightKey(node, data)" | |
26 | + check-strictly//在显示复选框的情况下,是否严格的遵循父子不互相关联的做法,默认为 false | |
27 | + :expand-on-click-node="false"//是否在点击节点的时候展开或者收缩节点, 默认值为 true,如果为 false,则只有点箭头图标的时候才会展开或者收缩节点。 | |
28 | + :props="defaultProps" | |
29 | + > --> | |
30 | + <span | |
31 | + slot-scope="{ node, data }" | |
32 | + class="custom-tree-node" | |
33 | + > | |
34 | + <span>{{ node.label }}</span> | |
35 | + <span> | |
36 | + <el-button | |
37 | + type="primary" | |
38 | + icon="el-icon-upload" | |
39 | + size="mini" | |
40 | + @click="() => append(data)" | |
41 | + > | |
42 | + {{ $t('users.add') }} | |
43 | + </el-button> | |
44 | + <el-button | |
45 | + type="primary" | |
46 | + icon="el-icon-edit" | |
47 | + size="mini" | |
48 | + @click="() => update(node, data)" | |
49 | + > | |
50 | + {{ $t('users.update') }} | |
51 | + </el-button> | |
52 | + <el-button | |
53 | + type="primary" | |
54 | + icon="el-icon-delete" | |
55 | + size="mini" | |
56 | + class="danger" | |
57 | + @click="() => remove(node, data)" | |
58 | + > | |
59 | + {{ $t('users.del') }} | |
60 | + </el-button> | |
61 | + </span> | |
62 | + </span> | |
63 | + </el-tree> | |
64 | + | |
65 | + <!-- <div class="buttons"> | |
66 | + <el-button @click="getCheckedNodes">通过 node 获取</el-button> | |
67 | + <el-button @click="getCheckedKeys">通过 key 获取</el-button> | |
68 | + <el-button @click="setCheckedNodes">通过 node 设置</el-button> | |
69 | + <el-button @click="setCheckedKeys">通过 key 设置</el-button> | |
70 | + <el-button @click="resetChecked">清空</el-button> | |
71 | + </div> --> | |
72 | + </div> | |
73 | +</template> | |
74 | +<script> | |
75 | +let id = 1000 | |
76 | +export default { | |
77 | + data() { | |
78 | + return { | |
79 | + data: [ | |
80 | + { | |
81 | + label: '成镜', | |
82 | + id: '1', | |
83 | + children: [ | |
84 | + { | |
85 | + label: '款式', | |
86 | + id: '11', | |
87 | + children: [ | |
88 | + { label: '青春学子风' }, | |
89 | + { label: '休闲' }, | |
90 | + { label: '商务' }, | |
91 | + { label: '复古' }, | |
92 | + { label: '时尚' }, | |
93 | + { label: '质感哥特潮' }, | |
94 | + { label: '轻简北欧风' }, | |
95 | + { label: '理性几何派' }, | |
96 | + { label: '多元新风尚' }, | |
97 | + { label: '立体巴洛克' }, | |
98 | + { label: '有机未来时' }, | |
99 | + { label: '无界人文系' }, | |
100 | + { label: '自然舒视角' }, | |
101 | + { label: '流线洛可可' }, | |
102 | + { label: '奶奶风' }, | |
103 | + { label: '简约-极简文艺范' }, | |
104 | + { label: '运动风' }, | |
105 | + { label: '行政风' }, | |
106 | + { label: '折射率' } | |
107 | + ] | |
108 | + }, | |
109 | + { label: '个性化服务', id: '267', children: [] }, | |
110 | + { | |
111 | + label: '赠品', | |
112 | + id: '259', | |
113 | + children: [{ label: '眼镜布' }, { label: '眼镜盒' }] | |
114 | + }, | |
115 | + { | |
116 | + label: '场景', | |
117 | + id: '258', | |
118 | + children: [ | |
119 | + { label: '学校场景' }, | |
120 | + { label: '出行交际' }, | |
121 | + { label: '夜店迷人' }, | |
122 | + { label: '明星同款' } | |
123 | + ] | |
124 | + }, | |
125 | + { | |
126 | + label: '销售保障', | |
127 | + id: '245', | |
128 | + children: [ | |
129 | + { label: '可退' }, | |
130 | + { label: '可换' }, | |
131 | + { label: '可修' } | |
132 | + ] | |
133 | + }, | |
134 | + { | |
135 | + label: '功能', | |
136 | + id: '140', | |
137 | + children: [ | |
138 | + { label: '防踩压' }, | |
139 | + { label: '防扭曲' }, | |
140 | + { label: '抗过敏' }, | |
141 | + { label: '防腐蚀' }, | |
142 | + { label: '耐磨损' }, | |
143 | + { label: '抗蓝光' } | |
144 | + ] | |
145 | + }, | |
146 | + { | |
147 | + label: '品牌', | |
148 | + id: '71', | |
149 | + children: [ | |
150 | + { label: '购易' }, | |
151 | + { label: '海俪恩' }, | |
152 | + { label: '沙漠风暴' }, | |
153 | + { label: '古诗' }, | |
154 | + { label: '暴龙' }, | |
155 | + { label: '犀牛' }, | |
156 | + { label: 'Ray-Ban雷朋' }, | |
157 | + { label: 'PARIM派丽蒙' }, | |
158 | + { label: '石狼' }, | |
159 | + { label: '木九十' } | |
160 | + ] | |
161 | + }, | |
162 | + { | |
163 | + label: '边形', | |
164 | + id: '49', | |
165 | + children: [ | |
166 | + { label: '半框' }, | |
167 | + { label: '全框' }, | |
168 | + { label: '无框' } | |
169 | + ] | |
170 | + }, | |
171 | + { | |
172 | + label: '性别', | |
173 | + id: '23', | |
174 | + children: [{ label: '男性' }, { label: '女性' }] | |
175 | + }, | |
176 | + { | |
177 | + label: '梁型', | |
178 | + id: '20', | |
179 | + children: [{ label: '双梁' }, { label: '单梁' }] | |
180 | + }, | |
181 | + { | |
182 | + label: '重量', | |
183 | + id: '19', | |
184 | + children: [{ label: '30克以下' }, { label: '80克以上' }] | |
185 | + }, | |
186 | + { | |
187 | + label: '适用脸型', | |
188 | + id: '15', | |
189 | + children: [{ label: '方' }, { label: '圆' }, { label: '瓜子' }] | |
190 | + }, | |
191 | + { | |
192 | + label: '形状', | |
193 | + id: '14', | |
194 | + children: [ | |
195 | + { label: '正圆形' }, | |
196 | + { label: '椭圆形' }, | |
197 | + { label: '方圆' }, | |
198 | + { label: '方形' }, | |
199 | + { label: '多边形' }, | |
200 | + { label: '内三角(蛤蟆)' }, | |
201 | + { label: '外三角(蝶形)' } | |
202 | + ] | |
203 | + }, | |
204 | + { label: '年龄', id: '12', children: [{ label: '通用' }] }, | |
205 | + { | |
206 | + label: '材质', | |
207 | + id: '10', | |
208 | + children: [ | |
209 | + { label: '板材' }, | |
210 | + { label: '纯钛' }, | |
211 | + { label: 'TR90' }, | |
212 | + { label: '木质' }, | |
213 | + { label: '竹质' }, | |
214 | + { label: 'β钛' }, | |
215 | + { label: 'PC' }, | |
216 | + { label: 'ULTEM塑钢' }, | |
217 | + { label: '钨钛塑钢' }, | |
218 | + { label: '镁铝合金' }, | |
219 | + { label: '碳纤维' } | |
220 | + ] | |
221 | + }, | |
222 | + { label: '折射率', id: '286', children: [] }, | |
223 | + { | |
224 | + label: '颜色', | |
225 | + id: '13', | |
226 | + children: [ | |
227 | + { label: '金色' }, | |
228 | + { label: '银色' }, | |
229 | + { label: '黑色' }, | |
230 | + { label: '彩色' }, | |
231 | + { label: '枪色' } | |
232 | + ] | |
233 | + } | |
234 | + ] | |
235 | + }, | |
236 | + { | |
237 | + label: '镜片', | |
238 | + id: '2', | |
239 | + children: [ | |
240 | + { | |
241 | + label: '面型', | |
242 | + id: '85', | |
243 | + children: [{ label: '球面单光' }, { label: '非球面单光' }] | |
244 | + }, | |
245 | + { label: '近视度数', id: '92', children: [] }, | |
246 | + { label: '散光', id: '93', children: [] }, | |
247 | + { | |
248 | + label: '功能', | |
249 | + id: '95', | |
250 | + children: [ | |
251 | + { label: '防起雾' }, | |
252 | + { label: '防蓝光' }, | |
253 | + { label: '防紫外线' }, | |
254 | + { label: '偏光' }, | |
255 | + { label: '染色' }, | |
256 | + { label: '抗疲劳' }, | |
257 | + { label: '青少年渐进' }, | |
258 | + { label: '内渐进' }, | |
259 | + { label: '变色' }, | |
260 | + { label: '双光' }, | |
261 | + { label: '耐磨损' }, | |
262 | + { label: '防尘' }, | |
263 | + { label: '防水' }, | |
264 | + { label: '防摔' }, | |
265 | + { label: '防指纹' }, | |
266 | + { label: '防反光' } | |
267 | + ] | |
268 | + }, | |
269 | + { | |
270 | + label: '颜色', | |
271 | + id: '100', | |
272 | + children: [ | |
273 | + { label: '透明' }, | |
274 | + { label: '染色' }, | |
275 | + { label: '变色' }, | |
276 | + { label: '单色' } | |
277 | + ] | |
278 | + }, | |
279 | + { | |
280 | + label: '折射率', | |
281 | + id: '101', | |
282 | + children: [ | |
283 | + { label: '1.56' }, | |
284 | + { label: '1.60' }, | |
285 | + { label: '1.65' }, | |
286 | + { label: '1.67' }, | |
287 | + { label: '1.71' }, | |
288 | + { label: '1.74' } | |
289 | + ] | |
290 | + }, | |
291 | + { label: '阿贝数(色散)', id: '102', children: [] }, | |
292 | + { label: '重量', id: '103', children: [] }, | |
293 | + { | |
294 | + label: '材质', | |
295 | + id: '104', | |
296 | + children: [ | |
297 | + { label: '树脂' }, | |
298 | + { label: '玻璃' }, | |
299 | + { label: '宇宙PC' }, | |
300 | + { label: 'PC' } | |
301 | + ] | |
302 | + }, | |
303 | + { | |
304 | + label: '品牌', | |
305 | + id: '118', | |
306 | + children: [ | |
307 | + { label: '好视力' }, | |
308 | + { label: 'RAISE锐视' }, | |
309 | + { label: '依视路' }, | |
310 | + { label: '凯米' }, | |
311 | + { label: '蔡司' }, | |
312 | + { label: '舒曼' } | |
313 | + ] | |
314 | + }, | |
315 | + { | |
316 | + label: '销售保障', | |
317 | + id: '249', | |
318 | + children: [ | |
319 | + { label: '可退' }, | |
320 | + { label: '可换' }, | |
321 | + { label: '可修' } | |
322 | + ] | |
323 | + } | |
324 | + ] | |
325 | + }, | |
326 | + { | |
327 | + label: '隐形眼镜', | |
328 | + id: '88', | |
329 | + children: [ | |
330 | + { | |
331 | + label: '颜色', | |
332 | + id: '105', | |
333 | + children: [ | |
334 | + { label: '绿' }, | |
335 | + { label: '灰' }, | |
336 | + { label: '黑' }, | |
337 | + { label: '紫' }, | |
338 | + { label: '蓝' }, | |
339 | + { label: '棕色' }, | |
340 | + { label: '紫色' } | |
341 | + ] | |
342 | + }, | |
343 | + { | |
344 | + label: '颜料', | |
345 | + id: '106', | |
346 | + children: [{ label: '水性' }, { label: '油性' }] | |
347 | + }, | |
348 | + { label: '度数', id: '107', children: [] }, | |
349 | + { | |
350 | + label: '周期', | |
351 | + id: '108', | |
352 | + children: [ | |
353 | + { label: '日抛' }, | |
354 | + { label: '周抛' }, | |
355 | + { label: '双周抛' }, | |
356 | + { label: '月抛' }, | |
357 | + { label: '季抛' }, | |
358 | + { label: '半年抛' }, | |
359 | + { label: '年抛' } | |
360 | + ] | |
361 | + }, | |
362 | + { | |
363 | + label: '品牌', | |
364 | + id: '133', | |
365 | + children: [ | |
366 | + { label: 'HolyNara' }, | |
367 | + { label: '爱尔康' }, | |
368 | + { label: 'MaxLook' }, | |
369 | + { label: 'NEO' }, | |
370 | + { label: 'GEO' }, | |
371 | + { label: '实瞳' }, | |
372 | + { label: '茵洛' }, | |
373 | + { label: 'DAZZSHOP' }, | |
374 | + { label: 'O-LENS' }, | |
375 | + { label: 'envie' }, | |
376 | + { label: '曼秀雷敦' }, | |
377 | + { label: '妃蜜莉' }, | |
378 | + { label: '海俪恩' }, | |
379 | + { label: '凯达' }, | |
380 | + { label: '蔡司' }, | |
381 | + { label: '酷视' }, | |
382 | + { label: 'LILMOON' }, | |
383 | + { label: 'RICHBABY' }, | |
384 | + { label: 'T-Garden' }, | |
385 | + { label: 'lenstown' }, | |
386 | + { label: '新加坡P2' }, | |
387 | + { label: '星欧' }, | |
388 | + { label: '美尼康' }, | |
389 | + { label: '美汐' }, | |
390 | + { label: '欧舒天' }, | |
391 | + { label: '海昌' }, | |
392 | + { label: '菲士康' }, | |
393 | + { label: '卫康' }, | |
394 | + { label: '库博' }, | |
395 | + { label: '安视优' }, | |
396 | + { label: '美若康' }, | |
397 | + { label: '视康' }, | |
398 | + { label: '澜柏' }, | |
399 | + { label: '3N' }, | |
400 | + { label: 'BIJOU' }, | |
401 | + { label: '依视明' }, | |
402 | + { label: '博士伦' }, | |
403 | + { label: '瞳昕' }, | |
404 | + { label: '科莱博' }, | |
405 | + { label: '绮芙莉' }, | |
406 | + { label: '雅培' }, | |
407 | + { label: '爱能视' }, | |
408 | + { label: '女神秘语' }, | |
409 | + { label: '博视顿' }, | |
410 | + { label: '妆美堂' }, | |
411 | + { label: '人鱼姬' }, | |
412 | + { label: 'EverColor' }, | |
413 | + { label: 'Sincere' } | |
414 | + ] | |
415 | + }, | |
416 | + { | |
417 | + label: '工艺', | |
418 | + id: '159', | |
419 | + children: [{ label: '涂层工艺' }, { label: '三层夹色工艺' }] | |
420 | + }, | |
421 | + { | |
422 | + label: '材质', | |
423 | + id: '164', | |
424 | + children: [{ label: '硅水凝胶' }, { label: '水凝胶' }] | |
425 | + }, | |
426 | + { | |
427 | + label: '含水量', | |
428 | + id: '174', | |
429 | + children: [ | |
430 | + { label: '0-40%' }, | |
431 | + { label: '40-44%' }, | |
432 | + { label: '45%以上' } | |
433 | + ] | |
434 | + }, | |
435 | + { | |
436 | + label: '基弧', | |
437 | + id: '178', | |
438 | + children: [{ label: '0.0-8.4' }, { label: '8.4以上' }] | |
439 | + }, | |
440 | + { | |
441 | + label: '直径', | |
442 | + id: '181', | |
443 | + children: [{ label: '13.4-14' }, { label: '14以上' }] | |
444 | + }, | |
445 | + { | |
446 | + label: '中心厚度', | |
447 | + id: '184', | |
448 | + children: [ | |
449 | + { label: '0.0 - 0.03' }, | |
450 | + { label: '0.04 - 0.09' }, | |
451 | + { label: '0.1以上' } | |
452 | + ] | |
453 | + }, | |
454 | + { label: '销售保障', id: '253', children: [] }, | |
455 | + { label: '赠品', id: '260', children: [] } | |
456 | + ] | |
457 | + }, | |
458 | + { | |
459 | + label: '特种镜', | |
460 | + id: '146', | |
461 | + children: [ | |
462 | + { | |
463 | + label: '镜面颜色', | |
464 | + id: '237', | |
465 | + children: [{ label: '透明' }, { label: '亮金色' }] | |
466 | + }, | |
467 | + { | |
468 | + label: '品牌', | |
469 | + id: '238', | |
470 | + children: [{ label: '宁哥牌' }, { label: '秀野牌' }] | |
471 | + }, | |
472 | + { | |
473 | + label: '销售保障', | |
474 | + id: '254', | |
475 | + children: [{ label: '包退' }, { label: '包换' }] | |
476 | + }, | |
477 | + { | |
478 | + label: '功能', | |
479 | + id: '268', | |
480 | + children: [ | |
481 | + { label: '防风镜' }, | |
482 | + { label: '防爆溅工作镜' }, | |
483 | + { label: '泳镜' }, | |
484 | + { label: '智能镜' } | |
485 | + ] | |
486 | + } | |
487 | + ] | |
488 | + } | |
489 | + ], | |
490 | + defaultProps: { | |
491 | + children: 'children', | |
492 | + label: 'label' | |
493 | + } | |
494 | + } | |
495 | + }, | |
496 | + methods: { | |
497 | + getCheckedNodes() { | |
498 | + console.log(this.$refs.tree.getCheckedNodes()) | |
499 | + }, | |
500 | + getCheckedKeys() { | |
501 | + console.log(this.$refs.tree.getCheckedKeys()) | |
502 | + }, | |
503 | + addNode() { | |
504 | + let h | |
505 | + this.$message({ | |
506 | + message: h('p', null, [ | |
507 | + h('span', null, '添加一个新节点 ') | |
508 | + // h("i", { style: "color: teal" }, "VNode") | |
509 | + ]) | |
510 | + }) | |
511 | + }, | |
512 | + append(data) { | |
513 | + const newChild = { id: id++, label: 'testtest', children: [] } | |
514 | + if (!data.children) { | |
515 | + this.$set(data, 'children', []) | |
516 | + } | |
517 | + data.children.push(newChild) | |
518 | + }, | |
519 | + remove(node, data) { | |
520 | + // 删除 | |
521 | + const parent = node.parent | |
522 | + const children = parent.data.children || parent.data | |
523 | + const index = children.findIndex(d => d.id === data.id) | |
524 | + children.splice(index, 1) | |
525 | + }, | |
526 | + rightKey(node, data) { | |
527 | + // 右键 | |
528 | + const h = this.$createElement | |
529 | + // console.log(data, this.$refs.tree); | |
530 | + this.$message({ | |
531 | + message: h('p', null, [ | |
532 | + h('span', null, '右键了啊! ' + node + data), | |
533 | + h('i', { style: 'color: teal' }, 'VNode') | |
534 | + ]) | |
535 | + }) | |
536 | + }, | |
537 | + update(node, data) { | |
538 | + // 更新 | |
539 | + const h = this.$createElement | |
540 | + this.$message({ | |
541 | + message: h('p', null, [ | |
542 | + h('span', null, '内容可以是 '), | |
543 | + h('i', { style: 'color: teal' }, 'VNode') | |
544 | + ]) | |
545 | + }) | |
546 | + }, | |
547 | + setCheckedNodes() { | |
548 | + this.$refs.tree.setCheckedNodes([ | |
549 | + { | |
550 | + id: 5, | |
551 | + label: '二级 2-1' | |
552 | + }, | |
553 | + { | |
554 | + id: 9, | |
555 | + label: '三级 1-1-1' | |
556 | + } | |
557 | + ]) | |
558 | + }, | |
559 | + setCheckedKeys() { | |
560 | + this.$refs.tree.setCheckedKeys([3]) | |
561 | + }, | |
562 | + resetChecked() { | |
563 | + this.$refs.tree.setCheckedKeys([]) | |
564 | + } | |
565 | + } | |
566 | +} | |
567 | +</script> | |
568 | +<style> | |
569 | +.custom-tree-node { | |
570 | + flex: 1; | |
571 | + display: flex; | |
572 | + align-items: center; | |
573 | + justify-content: space-between; | |
574 | + font-size: 14px; | |
575 | + padding-right: 8px; | |
576 | +} | |
577 | +</style> | ... | ... |