Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
Y
yn-science-front
Project
Project
Details
Activity
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
徐俊
yn-science-front
Commits
96897531
Commit
96897531
authored
Dec 23, 2024
by
wangxl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
333
parent
797b83de
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
139 additions
and
5 deletions
+139
-5
cache.js
src/store/modules/cache.js
+4
-5
select2.vue
src/views/components/common/select2.vue
+134
-0
Index.vue
src/views/query/project/Index.vue
+1
-0
No files found.
src/store/modules/cache.js
View file @
96897531
...
...
@@ -25,15 +25,14 @@ const mutations = {
}
}
const
actions
=
{
getDict
:
({
commit
,
state
},
type
)
=>
{
return
state
.
dict
},
getDictByType
:
({
dispatch
,
state
},
type
)
=>
{
async
getDictByType
({
dispatch
,
state
},
type
)
{
/**
* 闭包特性。返回一个函数,该函数接收一个type参数。
* 同时由于闭包还持有state对象,故可以返回需要的值。
*/
return
state
.
dict
[
type
]
await
dispatch
(
'dict'
,
type
)
var
obj
=
JSON
.
parse
(
JSON
.
stringify
(
state
.
dict
[
type
]))
return
obj
},
// 缓存字典内容
dict
({
commit
,
state
},
type
)
{
...
...
src/views/components/common/select2.vue
0 → 100644
View file @
96897531
<
template
>
<div
style=
" width:auto; display:inline-block !important; display:inline;z-index:100"
>
<a-select
:style=
"
{width: width + 'px'}" v-model="parSelected" @change="parentChange($event)" :key="0">
<a-select-option
v-for=
"item in parArray"
:key=
"item.key"
:value=
"item.key"
select
>
{{
item
.
title
}}
</a-select-option>
</a-select>
<a-select
:style=
"
{width: width + 'px'}" v-model="selected" @change="childChange($event)" :key="1">
<a-select-option
v-for=
"item in chArray"
:key=
"item.key"
:value=
"item.key"
select
>
{{
item
.
title
}}
</a-select-option>
</a-select>
</div>
</
template
>
<
script
>
export
default
{
//用法
<
para
-
multi
-
select
v
-
model
=
"formData.projClass"
:
typeId
=
"52"
/>
name
:
"paraMultiSelect"
,
data
()
{
return
{
parArray
:
[],
chArray
:
[],
parSelected
:
''
,
selected
:
''
,
defaultAll
:
{
title
:
"--请选择"
+
this
.
title
+
"--"
,
key
:
""
,
children
:
[{
title
:
"--请先选择上级-"
,
key
:
""
,
}]
},
loading
:
false
};
},
props
:
{
value
:
{
type
:
String
,
default
()
{
return
null
}
},
typeId
:
{
type
:
Number
,
default
()
{
return
0
}
},
width
:
{
type
:
Number
,
default
()
{
return
180
}
},
title
:
{
type
:
String
,
default
()
{
return
''
}
},
},
created
()
{
this
.
load
(
this
.
value
)
},
methods
:
{
async
load
(
value
)
{
if
(
!!!
this
.
parArray
||
this
.
parArray
.
length
==
0
)
{
this
.
parArray
=
await
this
.
$store
.
dispatch
(
'cache/getDictByType'
,
6
)
this
.
parArray
.
unshift
(
this
.
defaultAll
)
this
.
chArray
=
this
.
parArray
[
0
].
children
this
.
parSelected
=
''
this
.
selected
=
''
}
if
(
!!
value
)
{
var
show
=
this
.
getParIndex
(
this
.
parArray
,
value
)
this
.
chArray
=
this
.
parArray
[
show
].
children
this
.
parSelected
=
this
.
parArray
[
show
].
key
this
.
selected
=
value
}
},
parentChange
(
value
)
{
this
.
childArray
=
[];
this
.
childArray
.
unshift
(
this
.
defaultChild
)
this
.
childValue
=
''
if
(
value
!=
''
)
{
let
pars2
=
{
typeId
:
this
.
typeId
,
parentId
:
value
};
this
.
$api
.
parameter
.
getParameterList
(
pars2
).
then
(({
data
=
{}
})
=>
{
if
(
data
)
{
this
.
childArray
=
data
.
data
this
.
childArray
.
unshift
(
this
.
defaultChild
)
}
}).
catch
(()
=>
{
});
}
else
{
this
.
childArray
=
[
this
.
defaultChild
]
this
.
childValue
=
''
this
.
$emit
(
"input"
,
null
);
this
.
$emit
(
"change"
);
}
this
.
$emit
(
'parentChange'
,
value
)
this
.
$emit
(
"change"
);
},
childChange
(
value
)
{
this
.
$emit
(
"input"
,
value
);
var
newArr
=
this
.
childArray
.
filter
(
x
=>
x
.
key
==
value
);
if
(
!!
newArr
&&
newArr
.
length
>
0
)
{
var
text
=
!!
value
?
newArr
[
0
].
title
:
''
this
.
$emit
(
'changeTitle'
,
text
)
}
this
.
$emit
(
"change"
);
},
getParIndex
(
list
,
value
)
{
var
show
=
0
if
(
!!
list
&&
list
.
length
>
0
)
{
for
(
var
i
=
0
;
i
<
list
.
length
;
i
++
)
{
for
(
var
j
=
0
;
j
<
list
[
i
].
children
.
length
;
j
++
)
{
if
(
list
[
i
].
children
[
j
].
key
==
value
)
{
show
=
i
break
}
}
}
}
return
show
}
},
watch
:
{
value
:
{
handler
(
value
)
{
if
(
!!
value
&&
!
this
.
loading
)
{
this
.
loading
=
true
this
.
load
(
value
)
}
},
},
}
}
</
script
>
src/views/query/project/Index.vue
View file @
96897531
...
...
@@ -13,6 +13,7 @@
<a-form-item>
<base-select
v-model=
"searchForm.projState"
:title=
"'状态'"
:type=
"1"
:isAll=
"true"
:width=
"160"
/>
</a-form-item>
<para-multi-select2
:typeId=
"6"
/>
<a-form-item>
<a-button
type=
"primary"
icon=
"search"
@
click=
"search"
>
搜索
</a-button>
<a-button
icon=
"reload"
style=
"margin-left: 10px"
@
click=
"reset"
class=
"bt-normal"
>
重置
</a-button>
...
...
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