Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
confucius
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
罗超
confucius
Commits
a3e91f89
Commit
a3e91f89
authored
Nov 12, 2020
by
黄奎
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
插件修改
parent
96903729
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
6 additions
and
198 deletions
+6
-198
quasar.conf.js
quasar.conf.js
+3
-1
select-tree.vue
src/components/common/select-tree.vue
+3
-1
select-tree_back.vue
src/components/common/select-tree_back.vue
+0
-196
No files found.
quasar.conf.js
View file @
a3e91f89
...
...
@@ -47,7 +47,9 @@ module.exports = function(ctx) {
build
:
{
vueRouterMode
:
'hash'
,
// available values: 'hash', 'history'
env
:
ctx
.
dev
?
{
API
:
'https://localhost:5001/api'
//http://192.168.1.27:8300/api
//https://localhost:5001/api
API
:
'http://192.168.1.27:8300/api'
}
:
{
API
:
'https://prod.api.com'
},
...
...
src/components/common/select-tree.vue
View file @
a3e91f89
<
template
>
<div
style=
"width:300px"
:id=
"id"
>
<!--多选-->
<template
v-if=
"multiple"
>
<q-select
filled
v-model=
"resultObj"
:options=
"selectList"
clearable
@
clear=
"clearData()"
:label=
"tipText"
:multiple=
"multiple"
emit-value
map-options
>
...
...
@@ -15,6 +16,7 @@
</
template
>
</q-select>
</template>
<!--单选-->
<
template
v-else
>
<q-select
filled
v-model=
"resultObj[0]"
:options=
"selectList"
clearable
@
clear=
"clearData()"
:label=
"tipText"
:multiple=
"multiple"
emit-value
map-options
>
...
...
@@ -30,7 +32,6 @@
</
template
>
</q-select>
</template>
</div>
</template>
<
script
>
...
...
@@ -100,6 +101,7 @@
}
this
.
setTreeCheckNode
()
},
//有默认值
defaultArray
:
{
handler
(
newValue
)
{
if
(
this
.
defaultArray
&&
this
.
defaultArray
.
length
>
0
)
{
...
...
src/components/common/select-tree_back.vue
deleted
100644 → 0
View file @
96903729
<
template
>
<q-card
style=
"width: 360px;"
>
<q-input
ref=
"selectTree"
standout=
"bg-primary text-white"
v-model=
"showMsg"
:label=
"tipText"
@
click
.
native=
"isShowSelect = !isShowSelect"
>
<!--
<template
v-slot:append
>
<q-btn
round
dense
flat
icon=
"search"
/>
</
template
>
-->
</q-input>
<q-card
style=
"width:100%;position:absolute;z-index:100;background:#fff;border:1px solid rgba(0, 0, 0, 0.12);"
>
<q-btn-group
push
v-if=
"isShowSelect"
:spread=
"true"
>
<q-btn
v-if=
"multiple"
push
label=
"全选"
@
click=
"checkAll()"
/>
<q-btn
push
label=
"清空"
@
click=
"clearMsg()"
/>
<q-btn
push
label=
"确认"
@
click=
"getCheckValue()"
/>
<q-btn
push
label=
"关闭"
@
click=
"isShowSelect=false"
/>
</q-btn-group>
<q-tree
style=
"height:250px;overflow-y: scroll;"
v-if=
"isShowSelect"
:nodes=
"treeData"
:node-key=
"nodeKey"
:label-key=
"labelKey"
:children-key=
"childrenKey"
tick-strategy=
"strict"
:default-expand-all=
"defaultExpandAll"
no-connectors
:ticked
.
sync=
"chooseArray"
>
</q-tree>
</q-card>
</q-card>
</template>
<
script
>
export
default
{
props
:
{
//树形结构列表
treeData
:
{
type
:
Array
,
required
:
true
},
//是否默认展开
defaultExpandAll
:
{
type
:
Boolean
,
default
:
false
},
//是否多选
multiple
:
{
type
:
Boolean
,
default
:
false
},
//默认选中值
defaultArray
:
{
type
:
Array
,
required
:
true
,
},
//节点Key
nodeKey
:
{
type
:
String
,
default
:
'id'
},
//节点名称
labelKey
:
{
type
:
String
,
default
:
'name'
},
//子节点名称
childrenKey
:
{
type
:
String
,
default
:
'children'
},
//下拉框提示信息
tipText
:
{
type
:
String
,
default
:
'请选择'
}
},
data
()
{
return
{
//是否显示树状选择器
isShowSelect
:
false
,
selectList
:
[],
defaultProps
:
{
children
:
'children'
,
label
:
'label'
},
showMsg
:
""
,
chooseArray
:
[],
resultObj
:
""
,
}
},
watch
:
{
isShowSelect
(
val
)
{
//隐藏select自带的下拉框
this
.
$refs
.
selectTree
.
blur
();
if
(
val
)
{
// 下拉面板展开-选中节点-展开节点
this
.
setTreeCheckNode
();
}
},
chooseArray
(
val
)
{
if
(
!
this
.
multiple
&&
this
.
chooseArray
&&
this
.
chooseArray
.
length
>
1
)
{
var
lastItem
=
this
.
chooseArray
[
this
.
chooseArray
.
length
-
1
];
this
.
chooseArray
=
[
lastItem
];
}
this
.
setTreeCheckNode
()
},
defaultArray
:
{
handler
(
newValue
)
{
if
(
this
.
defaultArray
&&
this
.
defaultArray
.
length
>
0
)
{
this
.
defaultArray
.
forEach
(
item
=>
{
if
(
item
!=
''
)
{
if
(
this
.
multiple
)
{
this
.
chooseArray
.
push
(
item
)
}
else
{
this
.
chooseArray
=
[
item
];
}
}
})
}
this
.
setTreeCheckNode
();
},
immediate
:
true
}
},
mounted
()
{},
methods
:
{
//全选
checkAll
()
{
var
tempArray
=
[];
var
nodes
=
this
.
findTreeNode
(
this
.
treeData
);
if
(
nodes
&&
nodes
.
length
>
0
)
{
nodes
.
forEach
(
item
=>
{
tempArray
.
push
(
item
.
value
)
});
}
this
.
chooseArray
=
tempArray
;
},
//清空选中
clearMsg
()
{
this
.
chooseArray
=
[];
},
//返回选中的值
getCheckValue
()
{
this
.
isShowSelect
=
false
;
this
.
$emit
(
'getChild'
,
this
.
resultObj
);
},
//设置下拉框选择
setTreeCheckNode
()
{
var
that
=
this
;
this
.
selectList
=
[];
if
(
this
.
multiple
)
{
this
.
resultObj
=
[];
}
else
{
this
.
resultObj
=
""
;
}
this
.
showMsg
=
""
;
var
tempStr
=
""
;
var
nodes
=
this
.
findTreeNode
(
this
.
treeData
);
if
(
this
.
chooseArray
&&
this
.
chooseArray
.
length
>
0
&&
nodes
&&
nodes
.
length
>
0
)
{
this
.
chooseArray
.
forEach
(
id
=>
{
nodes
.
forEach
((
item
,
index
)
=>
{
if
(
item
.
value
==
id
)
{
this
.
selectList
.
push
({
value
:
item
.
value
,
label
:
item
.
label
});
tempStr
+=
","
+
item
.
label
;
if
(
this
.
multiple
)
{
this
.
resultObj
.
push
(
item
.
value
);
}
else
{
this
.
resultObj
=
item
.
value
;
}
}
})
})
if
(
tempStr
&&
tempStr
!=
''
)
{
this
.
showMsg
=
tempStr
.
substring
(
1
,
tempStr
.
length
);
}
}
},
//获取所有节点
findTreeNode
(
tree
)
{
var
temp
=
[];
var
that
=
this
;
//获取子节点
var
getChildNodes
=
function
(
tree
)
{
if
(
tree
&&
tree
.
length
>
0
)
{
for
(
var
i
=
0
;
i
<
tree
.
length
;
i
++
)
{
var
item
=
tree
[
i
];
temp
.
push
({
label
:
tree
[
i
][
that
.
labelKey
],
value
:
tree
[
i
][
that
.
nodeKey
]
});
if
(
tree
[
i
][
that
.
childrenKey
])
{
getChildNodes
(
tree
[
i
][
that
.
childrenKey
]);
}
}
}
};
getChildNodes
(
tree
);
return
temp
;
}
}
}
</
script
>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment