Commit 50dac532 by zhuxiaomei

生成人员 地点

parent c6ce3cda
<template>
<div>
<div class="layout-cont-btn">
<van-form @submit="onSubmit">
<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" native-type="submit">生成</van-button>
</template>
</van-field>
<van-field label="地点" center>
<template #input>
<Tag v-for="item in locList" :key="item.id" name="item" 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="bottom-btn">
<van-button block type="info" @click="_ok">保存</van-button>
</div>
<van-popup v-model="showSelect">
<SelectLocChecked @cancel="showSelect=false" @on-change="_selectChange" ref="select"></SelectLocChecked>
</van-popup>
</div>
</template>
<script>
import {samplingPlan} from '../../../api'
import SelectLocChecked from './SelectLocChecked'
export default {
name: "CreateLoc",
data(){
return{
planId:''
components: {
SelectLocChecked
},
data() {
return {
showSelect: false,
planId: '',
count: '',
locList: []
}
},
mounted() {
this.planId = this.$route.query.planId
},
methods:{}
methods: {
onSubmit() {
this._create()
},
_create: async function () {
let result = await samplingPlan.generatePlace({count: this.count, planId: this.planId})
if (result) {
this.$toast('生成成功!')
this.locList = result
}
},
_handleClose(event, name) {
const index = this.locList.indexOf(name);
this.locList.splice(index, 1);
},
_add() {
this.showSelect = true
this.$nextTick(function () {
this.$refs.select._open(this.planId)
})
},
_selectChange(res) {
this.showSelect = false
this.locList = res
},
_ok: async function () {
if (this.userList.length === 0) {
this.$toast('请生成人员!')
} else {
let result = await samplingPlan.savePlace({
planId: this.planId,
placeIds: this.locList.map(item => item.id).join(',')
})
if (result) {
this.$toast('保存成功!')
this.$router.go(-2)
}
}
}
}
}
</script>
......
......@@ -92,7 +92,6 @@
}
},
_add() {
console.log(this.checkListValue, 'this.checkListValue')
if (this.checkListValue.length === 0) {
this.$toast('请至少选择一条数据!')
} else {
......@@ -111,7 +110,6 @@
}),
planId: this.planId
}
console.log(data, ';data')
let result = await samplingPlace.savePlaces(data)
if (result) {
this.$toast('操作成功')
......@@ -247,7 +245,6 @@
}
},
_locSearch(obj) {
debugger
//清除地图上所有覆盖物
for (let i = 0, l = this.polygons.length; i < l; i++) {
this.polygons[i].setMap(null);
......
<template>
<customer-navBar-layout style="width: 100vw;height:100vh">
<template #navBar>
<van-nav-bar
title="选择地点"
left-arrow
@click-left="_cancel"
></van-nav-bar>
</template>
<template #content>
<search-bar label="地点" @search="_search"></search-bar>
<div class="layout-cont-s layout-cont-s-btn" >
<van-pull-refresh v-model="refreshing" @refresh="_refresh">
<van-list
v-model="loading"
:finished="finished"
finished-text="没有更多了"
@load="_load">
<van-checkbox-group v-model="checkListValue" ref="checkboxGroup">
<van-swipe-cell v-for="item in resultList" :key="item.name">
<div class="result-item" @click="_tapItem(item)">
<van-checkbox :name="item" shape="square"></van-checkbox>
<div>地点:{{item.name}}</div>
<div>地址:{{item.address}}</div>
<div>经度:{{item.attendanceTime}}</div>
<div>纬度:{{item.attendanceAddress}}</div>
</div>
</van-swipe-cell>
</van-checkbox-group>
</van-list>
</van-pull-refresh>
</div>
<div class="bottom-btn">
<van-button type="info" block @click="_add">添加</van-button>
</div>
</template>
</customer-navBar-layout>
</template>
<script>
import {samplingPlace} from '../../../api'
export default {
data() {
return {
resultList: [],
page: 1,
rows: 10,
refreshing: false,//刷新中...
loading: false,//加载中...
finished: false,//没有更多数据
checkListValue: [],
planId: ''
}
},
methods: {
_open(planId) {
this.planId = planId
this.checkListValue = []
this._refresh()
},
_search(value) {
this.key = value
this._refresh()
},
_refresh() {
this.page = 1
this._getData()
},
_searchParams() {
let data = {
page: this.page,
rows: this.rows,
name: this.key,
planId: this.planId
};
return this.$serializeForm(data)
},
_getData: async function () {
let result = await samplingPlace.page(this._searchParams())
this.resultList = [...(this.page === 1 ? [] : this.resultList), ...result.records]
this.refreshing = false
this.loading = false
if (this.resultList.length === result.total) {
this.finished = true
}
},
_load() {
this.page = this.page + 1;
this._getData()
},
_tapItem(item) {
if (this.checkListValue.indexOf(item) === -1) {
this.checkListValue.push(item);
} else {
this.checkListValue.splice(this.checkListValue.indexOf(item), 1);
}
},
_add() {
if (this.checkListValue.length === 0) {
this.$toast('请至少选择一条数据!')
} else {
this.$emit('on-change',this.checkListValue)
}
},
_cancel() {
this.$emit('cancel')
}
}
}
</script>
<style scoped>
</style>
<template>
<div>
<div class="layout-cont-btn">
<van-form @submit="onSubmit">
<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" native-type="submit">生成</van-button>
</template>
</van-field>
<van-field label="人员" center>
<template #input>
<Tag v-for="item in userList" :key="item.id" name="item" 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="bottom-btn">
<van-button block type="info" @click="_ok">保存</van-button>
</div>
<van-popup v-model="showAllSelect">
<SelectSamplerChecked @cancel="showAllSelect=false" @on-change="_selectChange"
ref="select"></SelectSamplerChecked>
</van-popup>
</div>
</template>
<script>
import {samplingPlan} from '../../../api'
import SelectSamplerChecked from './SelectSamplerChecked'
export default {
name: "CreateSampler",
components: {
SelectSamplerChecked
},
data() {
return {
planId: ''
showAllSelect: false,
planId: '',
count: '',
userList: []
}
},
mounted() {
this.planId = this.$route.query.planId
},
methods: {}
methods: {
onSubmit() {
this._create()
},
_create: async function () {
let result = await samplingPlan.generateSampler({count: this.count, planId: this.planId})
if (result) {
this.$toast('生成成功!')
this.userList = result
}
},
_handleClose(event, name) {
const index = this.userList.indexOf(name);
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
},
_ok: async function () {
if (this.userList.length === 0) {
this.$toast('请生成人员!')
} else {
let result = await samplingPlan.saveSamplerRandom({
planId: this.planId,
samplerIds: this.userList.map(item => item.id).join(',')
})
if (result) {
this.$toast('保存成功!')
this.$router.go(-2)
}
}
}
}
}
</script>
......
<template>
<customer-navBar-layout style="width: 100vw;height:100vh">
<template #navBar>
<van-nav-bar
title="选择人员"
left-arrow
@click-left="_cancel"
></van-nav-bar>
</template>
<template #content>
<search-bar label="地点" @search="_search"></search-bar>
<div class="layout-cont-s layout-cont-s-btn" >
<van-pull-refresh v-model="refreshing" @refresh="_refresh">
<van-list
v-model="loading"
:finished="finished"
finished-text="没有更多了"
@load="_load">
<van-checkbox-group v-model="checkListValue" ref="checkboxGroup">
<van-swipe-cell v-for="item in resultList" :key="item.name">
<div class="result-item" @click="_tapItem(item)">
<van-checkbox :name="item" shape="square"></van-checkbox>
<div>姓名:{{item.name}}</div>
<div>电话:{{item.tel}}</div>
<div>所属部门:{{item.department}}</div>
</div>
</van-swipe-cell>
</van-checkbox-group>
</van-list>
</van-pull-refresh>
</div>
<div class="bottom-btn">
<van-button type="info" block @click="_add">添加</van-button>
</div>
</template>
</customer-navBar-layout>
</template>
<script>
import {samplingPlan} from '../../../api'
export default {
data() {
return {
resultList: [],
page: 1,
rows: 10,
refreshing: false,//刷新中...
loading: false,//加载中...
finished: false,//没有更多数据
checkListValue: [],
planId: ''
}
},
methods: {
_open(planId) {
this.planId = planId
this.checkListValue = []
this._refresh()
},
_search(value) {
this.key = value
this._refresh()
},
_refresh() {
this.page = 1
this._getData()
},
_searchParams() {
let data = {
page: this.page,
rows: this.rows,
name: this.key,
planId: this.planId
};
return this.$serializeForm(data)
},
_getData: async function () {
let result = await samplingPlan.samplerPage(this._searchParams())
this.resultList = [...(this.page === 1 ? [] : this.resultList), ...result.records]
this.refreshing = false
this.loading = false
if (this.resultList.length === result.total) {
this.finished = true
}
},
_load() {
this.page = this.page + 1;
this._getData()
},
_tapItem(item) {
if (this.checkListValue.indexOf(item) === -1) {
this.checkListValue.push(item);
} else {
this.checkListValue.splice(this.checkListValue.indexOf(item), 1);
}
},
_add() {
if (this.checkListValue.length === 0) {
this.$toast('请至少选择一条数据!')
} else {
this.$emit('on-change',this.checkListValue)
}
},
_cancel() {
this.$emit('cancel')
}
}
}
</script>
<style scoped>
</style>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment