Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
patzn-cloud-web-h5app-drs
Overview
Overview
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
zhuxiaomei
patzn-cloud-web-h5app-drs
Commits
8e1e6a81
Commit
8e1e6a81
authored
Mar 11, 2021
by
zhuxiaomei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加与编辑
parent
8a6a8c25
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
190 additions
and
0 deletions
+190
-0
TaskRequirements.vue
src/page/sampling-plan/add/TaskRequirements.vue
+190
-0
No files found.
src/page/sampling-plan/add/TaskRequirements.vue
0 → 100644
View file @
8e1e6a81
<
template
>
<div>
<div
class=
"layout-cont-btn"
>
<van-form>
<van-field
v-model=
"count"
name=
"count"
type=
"digit"
required
center
label=
"人员随机数量"
placeholder=
"请输入人员随机数量"
:rules=
"[
{ required: true, message: '' }]">
<template
#
button
>
<van-button
size=
"small"
type=
"info"
@
click=
"_create"
>
生成
</van-button>
</
template
>
</van-field>
<van-field
label=
"人员"
center
>
<
template
#
input
>
<Tag
v-for=
"(item,index) in userList"
:key=
"item.id"
:name=
"index"
closable
@
on-close=
"_handleClose"
>
{{
item
.
name
}}
</Tag>
<van-button
size=
"small"
type=
"default"
@
click=
"_add"
>
添加
</van-button>
</
template
>
</van-field>
</van-form>
</div>
<div
class=
"layout-cont-btn"
>
<van-form>
<van-field
v-model=
"locCount"
name=
"count"
type=
"digit"
required
center
label=
"随机数量"
placeholder=
"请输入随机数量"
:rules=
"[{ required: true, message: '' }]"
>
<
template
#
button
>
<van-button
size=
"small"
type=
"info"
@
click=
"_locCreate"
>
生成
</van-button>
</
template
>
</van-field>
<van-field
label=
"地点"
center
>
<
template
#
input
>
<Tag
v-for=
"(item,index) in locList"
:key=
"item.id"
:name=
"index"
closable
@
on-close=
"_handleLocClose"
>
{{
item
.
name
}}
</Tag>
<van-button
size=
"small"
type=
"default"
@
click=
"_addLoc"
>
添加
</van-button>
</
template
>
</van-field>
</van-form>
</div>
<van-popup
v-model=
"showAllSelect"
>
<SelectSamplerChecked
@
cancel=
"showAllSelect=false"
@
on-change=
"_selectChange"
ref=
"select"
></SelectSamplerChecked>
</van-popup>
<van-popup
v-model=
"showSelect"
>
<SelectLocChecked
@
cancel=
"showSelect=false"
@
on-change=
"_selectLocChange"
ref=
"selectLoc"
></SelectLocChecked>
</van-popup>
<div
class=
"bottom-btn"
style=
"position: fixed;bottom: 0"
>
<!-- <van-button type="info" block @click="_back">上一步</van-button>-->
<van-button
type=
"info"
block
@
click=
"_save"
>
保存
</van-button>
<van-button
type=
"info"
block
@
click=
"_submit"
>
提交
</van-button>
</div>
</div>
</template>
<
script
>
import
{
samplingPlan
}
from
'../../../api'
import
SelectSamplerChecked
from
'../sampler/SelectSamplerChecked'
import
SelectLocChecked
from
'./loc/SelectLocChecked'
export
default
{
name
:
"CreateSampler"
,
components
:
{
SelectSamplerChecked
,
SelectLocChecked
},
data
()
{
return
{
showAllSelect
:
false
,
planId
:
''
,
count
:
''
,
userList
:
[],
showSelect
:
false
,
locCount
:
''
,
locList
:
[]
}
},
methods
:
{
_open
(
planId
)
{
this
.
planId
=
planId
},
_create
:
async
function
()
{
if
(
this
.
count
)
{
let
result
=
await
samplingPlan
.
generateSampler
({
count
:
this
.
count
,
planId
:
this
.
planId
})
if
(
result
)
{
this
.
$toast
(
'生成成功!'
)
this
.
userList
=
result
}
}
else
{
this
.
$toast
(
"请输入随机数量"
)
}
},
_handleClose
(
event
,
index
)
{
this
.
userList
.
splice
(
index
,
1
);
},
_add
()
{
this
.
showAllSelect
=
true
this
.
$nextTick
(
function
()
{
this
.
$refs
.
select
.
_open
(
this
.
planId
)
})
},
_selectChange
(
res
)
{
this
.
showAllSelect
=
false
this
.
userList
=
[...
res
,
...
this
.
userList
]
},
_save
:
async
function
()
{
if
(
this
.
userList
.
length
===
0
)
{
this
.
$toast
(
'请生成人员!'
)
}
else
if
(
this
.
locList
.
length
===
0
)
{
this
.
$toast
(
'请生成地点!'
)
}
else
{
let
result
=
await
samplingPlan
.
saveSamplerRandom
({
planId
:
this
.
planId
,
samplerIds
:
this
.
userList
.
map
(
item
=>
item
.
id
).
join
(
','
)
})
let
resultLoc
=
await
samplingPlan
.
savePlace
({
planId
:
this
.
planId
,
placeIds
:
this
.
locList
.
map
(
item
=>
item
.
id
).
join
(
','
)
})
if
(
result
&&
resultLoc
)
{
this
.
$toast
(
'保存成功!'
)
this
.
$router
.
go
(
-
1
)
}
}
},
_locCreate
:
async
function
()
{
if
(
this
.
locCount
)
{
let
result
=
await
samplingPlan
.
generatePlace
({
count
:
this
.
locCount
,
planId
:
this
.
planId
})
if
(
result
)
{
this
.
$toast
(
'生成成功!'
)
this
.
locList
=
result
}
}
else
{
this
.
$toast
(
"请输入随机数量"
)
}
},
_handleLocClose
(
event
,
name
)
{
const
index
=
this
.
locList
.
indexOf
(
name
);
this
.
locList
.
splice
(
index
,
1
);
},
_addLoc
()
{
this
.
showSelect
=
true
this
.
$nextTick
(
function
()
{
this
.
$refs
.
selectLoc
.
_open
(
this
.
planId
)
})
},
_selectLocChange
(
res
)
{
this
.
showSelect
=
false
this
.
locList
=
[...
res
,
...
this
.
locList
]
},
_back
()
{
this
.
$emit
(
'back'
)
},
_submit
:
async
function
()
{
if
(
this
.
userList
.
length
===
0
)
{
this
.
$toast
(
'请生成人员!'
)
}
else
if
(
this
.
locList
.
length
===
0
)
{
this
.
$toast
(
'请生成地点!'
)
}
else
{
let
result
=
await
samplingPlan
.
saveSubmitPlan
({
planId
:
this
.
planId
,
samplerIds
:
this
.
userList
.
map
(
item
=>
item
.
id
).
join
(
','
),
placeIds
:
this
.
locList
.
map
(
item
=>
item
.
id
).
join
(
','
)
})
if
(
result
)
{
this
.
$toast
(
'操作成功!'
)
this
.
$router
.
go
(
-
1
)
}
}
}
}
}
</
script
>
<
style
scoped
>
</
style
>
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