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
aeb7dfb4
Commit
aeb7dfb4
authored
Dec 20, 2024
by
wangxl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
4444
parent
170ce7ae
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
27 deletions
+26
-27
cache.js
src/store/modules/cache.js
+19
-19
paraSelect.vue
src/views/components/common/paraSelect.vue
+5
-6
Index.vue
src/views/query/project/Index.vue
+2
-2
No files found.
src/store/modules/cache.js
View file @
aeb7dfb4
import
Vue
from
'vue'
import
Vue
from
'vue'
import
Api
from
'@/api/index.js'
import
api
from
'@/api'
const
state
=
{
const
state
=
{
dict
:
{},
dict
:
{},
queue
:
[]
queue
:
[]
...
@@ -24,10 +25,10 @@ const mutations = {
...
@@ -24,10 +25,10 @@ const mutations = {
}
}
}
}
const
actions
=
{
const
actions
=
{
getDict
:
(
stat
e
)
=>
{
getDict
:
(
{
commit
,
state
},
typ
e
)
=>
{
return
state
.
dict
return
state
.
dict
},
},
getDictByType
:
(
state
)
=>
(
type
)
=>
{
getDictByType
:
(
{
dispatch
,
state
},
type
)
=>
{
/**
/**
* 闭包特性。返回一个函数,该函数接收一个type参数。
* 闭包特性。返回一个函数,该函数接收一个type参数。
* 同时由于闭包还持有state对象,故可以返回需要的值。
* 同时由于闭包还持有state对象,故可以返回需要的值。
...
@@ -43,25 +44,24 @@ const actions = {
...
@@ -43,25 +44,24 @@ const actions = {
// 没有缓存则请求数据
// 没有缓存则请求数据
if
(
!
isExistence
)
{
if
(
!
isExistence
)
{
// 在异步请求之前将该任务标记为已缓存(存入队列)
// 在异步请求之前将该任务标记为已缓存(存入队列)
commit
(
'SET_QUEUE'
,
'dict/'
+
type
)
this
.
commit
(
'cache/SET_QUEUE'
,
'dict/'
+
type
)
return
new
Promise
((
resolve
,
reject
)
=>
{
return
new
Promise
(
async
(
resolve
,
reject
)
=>
{
return
Api
.
getDict
(
type
)
await
api
.
parameter
.
getArrayListByType
({
typeId
:
type
})
.
then
((
res
)
=>
{
.
then
(({
data
=
{}
})
=>
{
const
{
code
,
data
}
=
res
if
(
data
)
{
if
(
code
&&
code
!==
200
)
{
try
{
// 获取失败移除缓存队列
this
.
commit
(
'cache/SET_DICT'
,
{
type
:
type
,
list
:
data
})
commit
(
'DEL_QUEUE'
,
'dict/'
+
type
)
resolve
(
data
)
reject
(
res
)
}
catch
(
error
)
{
reject
(
error
)
}
}
else
{
}
else
{
// 获取到的值存入字典
reject
(
'error'
)
commit
(
'SET_DICT'
,
{
type
:
type
,
list
:
data
})
resolve
(
res
)
}
}
})
}).
catch
(
err
=>
{
.
catch
((
error
)
=>
{
// 获取失败移除缓存队列
// 获取失败移除缓存队列
commit
(
'
DEL_QUEUE'
,
'dict/'
+
type
)
this
.
commit
(
'cache/
DEL_QUEUE'
,
'dict/'
+
type
)
reject
(
err
or
)
reject
(
err
.
response
)
})
})
})
})
}
else
{
}
else
{
...
...
src/views/components/common/paraSelect.vue
View file @
aeb7dfb4
<
template
>
<
template
>
<div
style=
" width:auto; display:inline-block !important; display:inline;"
>
<div
style=
" width:auto; display:inline-block !important; display:inline;"
>
<a-select
:style=
"
{width: width? width+ 'px':'80%'}" v-model="selected" @change="
para
Change($event)" :key="0">
<a-select
:style=
"
{width: width? width+ 'px':'80%'}" v-model="selected" @change="
on
Change($event)" :key="0">
<a-select-option
v-for=
"item in selectArray"
:key=
"item.key"
:value=
"item.key"
select
>
{{
item
.
title
}}
</a-select-option>
<a-select-option
v-for=
"item in selectArray"
:key=
"item.key"
:value=
"item.key"
select
>
{{
item
.
title
}}
</a-select-option>
</a-select>
</a-select>
</div>
</div>
</
template
>
</
template
>
<
script
>
<
script
>
// 用法
<
para
-
select
v
-
model
=
"formData.projClass"
:
typeId
=
"52"
/>
export
default
{
export
default
{
name
:
"paraSelect"
,
name
:
"paraSelect"
,
data
()
{
data
()
{
...
@@ -49,17 +49,16 @@ export default {
...
@@ -49,17 +49,16 @@ export default {
},
},
},
},
created
()
{
created
()
{
this
.
load
Selected
()
this
.
load
()
},
},
methods
:
{
methods
:
{
load
Selected
()
{
load
()
{
let
pars
=
{
typeId
:
this
.
typeId
}
let
pars
=
{
typeId
:
this
.
typeId
}
this
.
$api
.
parameter
.
getParameterList
(
pars
).
then
(({
data
=
{
data
}
})
=>
{
this
.
$api
.
parameter
.
getParameterList
(
pars
).
then
(({
data
=
{
data
}
})
=>
{
if
(
data
)
{
if
(
data
)
{
this
.
selectArray
=
data
.
data
this
.
selectArray
=
data
.
data
this
.
selectArray
.
unshift
(
this
.
defaultValue
)
this
.
selectArray
.
unshift
(
this
.
defaultValue
)
if
(
!!
this
.
value
)
{
if
(
!!
this
.
value
)
{
this
.
loadState
=
true
this
.
selected
=
this
.
value
this
.
selected
=
this
.
value
}
}
else
else
...
@@ -67,7 +66,7 @@ export default {
...
@@ -67,7 +66,7 @@ export default {
}
}
}).
catch
(()
=>
{
})
}).
catch
(()
=>
{
})
},
},
para
Change
(
value
)
{
on
Change
(
value
)
{
this
.
$emit
(
"input"
,
value
);
this
.
$emit
(
"input"
,
value
);
var
newArr
=
this
.
selectArray
.
filter
(
x
=>
x
.
key
==
value
);
var
newArr
=
this
.
selectArray
.
filter
(
x
=>
x
.
key
==
value
);
if
(
!!
newArr
&&
newArr
.
length
>
0
)
{
if
(
!!
newArr
&&
newArr
.
length
>
0
)
{
...
...
src/views/query/project/Index.vue
View file @
aeb7dfb4
...
@@ -15,7 +15,7 @@
...
@@ -15,7 +15,7 @@
</a-form-item>
</a-form-item>
<a-form-item>
<a-form-item>
<a-button
type=
"primary"
icon=
"search"
@
click=
"search"
>
搜索
</a-button>
<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>
<a-button
icon=
"reload"
style=
"margin-left: 10px"
@
click=
"reset"
class=
"bt-normal"
>
重置
</a-button>
</a-form-item>
</a-form-item>
</a-form>
</a-form>
<a-divider
style=
"height: 1px; background-color: #e8e8e8;"
/>
<a-divider
style=
"height: 1px; background-color: #e8e8e8;"
/>
...
@@ -50,7 +50,7 @@ import projectView from '@/views/report/project/components/projectView'
...
@@ -50,7 +50,7 @@ import projectView from '@/views/report/project/components/projectView'
export
default
{
export
default
{
name
:
'queryProject'
,
name
:
'queryProject'
,
components
:
{
components
:
{
projectView
projectView
,
},
},
data
()
{
data
()
{
return
{
return
{
...
...
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