Commit 9c66bda5 by zhuxiaomei

地点和货架

parent b2ebe949
...@@ -42,7 +42,8 @@ ...@@ -42,7 +42,8 @@
"parser": "babel-eslint" "parser": "babel-eslint"
}, },
"globals": { "globals": {
"BMap": true "BMap": true,
"AMap": true
}, },
"rules": {} "rules": {}
}, },
......
...@@ -17,5 +17,7 @@ ...@@ -17,5 +17,7 @@
<!--</noscript>--> <!--</noscript>-->
<div id="app"></div> <div id="app"></div>
<!-- built files will be auto injected --> <!-- built files will be auto injected -->
<script src="https://webapi.amap.com/maps?v=1.4.15&key=33d56f06483ab332151b14e85bbb8405"></script>
</body> </body>
</html> </html>
/**
* 抽样计划表相关
*/
import http from '../http'
export default {
page: data => http.post('/drs/v1/sampling_place/page', data).then(res => res),
pageApp: data => http.post('/drs/v1/sampling_place/page_app', data).then(res => res),
edit:data=> http.put('/drs/v1/sampling_place/' + data.id, data.obj).then(res=>res),
}
...@@ -6,6 +6,9 @@ import http from '../http' ...@@ -6,6 +6,9 @@ import http from '../http'
export default { export default {
page: data => http.post('/drs/v1/sampling_plan/page', data).then(res => res), page: data => http.post('/drs/v1/sampling_plan/page', data).then(res => res),
pageApp: data => http.post('/drs/v1/sampling_plan/page_app', data).then(res => res), pageApp: data => http.post('/drs/v1/sampling_plan/page_app', data).then(res => res),
acceptFinish: data => http.post('/drs/v1/sampling_plan/accept_or_finish_task', data).then(res => res),
getById: id => http.get('/drs/v1/sampling_plan/' + id).then(res => res), getById: id => http.get('/drs/v1/sampling_plan/' + id).then(res => res),
savePlace:data=>http.post('/drs/v1/sampling_plan/save_place_random', data).then(res=>res),
} }
/**
* 双随机抽样货架表相关
*/
import http from '../../api/http'
export default {
page: data => http.post('/drs/v1/sampling_shelf/page', data).then(res => res),
add: data => http.post('/drs/v1/sampling_shelf/', data).then(res => res),
edit: data => http.put('/drs/v1/sampling_shelf/' + data.id, data.obj).then(res => res),
deleteByIds: ids => http.delete('/drs/v1/sampling_shelf/?ids=' + ids).then(res => res),
getById: id => http.get('/drs/v1/sampling_shelf/' + id).then(res => res),
}
...@@ -27,3 +27,5 @@ export {default as message} from './message/message' ...@@ -27,3 +27,5 @@ export {default as message} from './message/message'
* drs * drs
*/ */
export {default as samplingPlan} from './drs/sampling-plan' export {default as samplingPlan} from './drs/sampling-plan'
export {default as samplingPlace} from './drs/sampling-place'
export {default as samplingShelf} from './drs/sampling-shelf'
<template> <template>
<div> <div>
<div class="layout-cont-btn"> <div class="layout-cont-btn">
<!--下拉刷新 https://vant-contrib.gitee.io/vant/#/zh-CN/pull-refresh--> <van-pull-refresh v-model="refreshing" @refresh="_refresh">
<van-pull-refresh v-model="refreshing" @refresh="_request"> <van-list
<van-swipe-cell v-for="item in resultList" :key="item.name"> v-model="loading"
<div class="result-item" @click="_goto(item)"> :finished="finished"
<div>货架名称:{{item.placeName}}</div> finished-text="没有更多了"
</div> @load="_load">
<template #right> <van-swipe-cell v-for="item in resultList" :key="item.name">
<van-button square type="danger" text="删除" class="swipe-cell-btn" <div class="result-item" @click="_goto(item)">
@click="_del(item.id)"></van-button> <div>货架名称:{{item.name}}</div>
</template> </div>
</van-swipe-cell> <template #right>
<van-button square type="danger" text="删除" class="swipe-cell-btn"
@click="_del(item.id)"></van-button>
</template>
</van-swipe-cell>
</van-list>
</van-pull-refresh> </van-pull-refresh>
</div> </div>
<div class="bottom-btn"> <div class="bottom-btn">
<van-button type="info" block @click="_add">添加货架</van-button> <van-button type="info" block @click="showAdd=true">添加货架</van-button>
</div> </div>
<van-popup v-model="showAdd" round>
<div style="margin: 20px auto 30px;text-align: center">添加货架</div>
<van-field v-model="name" label="货架" placeholder="请输入货架"></van-field>
<div style="text-align: center;margin: 20px">
<van-button type="info" @click="_add">保存</van-button>
</div>
</van-popup>
</div> </div>
</template> </template>
<script> <script>
import {samplingShelf} from '../../api'
export default { export default {
name: "GoodsShelves", name: "GoodsShelves",
data() { data() {
return { return {
resultList: [{placeItem: 2322}], showAdd: false,
locId: this.$route.locId, resultList: [],
refreshing: false page: 1,
rows: 10,
refreshing: false,//刷新中...
loading: false,//加载中...
finished: false,//没有更多数据
placeId: this.$route.query.placeId,
name: '',//货架名
} }
}, },
mounted() { mounted() {
this._request() this._getData()
}, },
methods: { methods: {
_request: async function () { _refresh() {
// let result = await samplingPlan.getShelves(this.locId) this.page = 1
// if (result) { this._getData()
// this.resultList = result.records
// this.refreshing = false
//
// }
}, },
_del: async function () { _searchParams() {
// let reuslt = await samplingPlan.delShelves(id) let data = {
// if (reuslt) { page: this.page,
// this.$toast('操作成功!') rows: this.rows,
// } placeId: this.placeId
};
return this.$serializeForm(data)
},
_getData: async function () {
let result = await samplingShelf.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()
},
_del: async function (id) {
let result = await samplingShelf.deleteByIds([id])
if (result) {
this.$toast('操作成功!')
this._refresh()
}
},
_add() {
if (this.name === '') {
this.$toast('请输入货架')
} else {
this._addOk()
}
},
_addOk: async function () {
let result = await samplingShelf.add({name: this.name, placeId: this.placeId})
if (result) {
this.$toast('操作成功!')
this.showAdd = false
this.name = ''
this._refresh()
}
}, },
_add(){
}
} }
} }
</script> </script>
......
<template> <template>
<div> <div>
<div class="layout-cont-btn"> <div class="layout-cont-btn">
<van-pull-refresh v-model="refreshing" @refresh="_request"> <van-pull-refresh v-model="refreshing" @refresh="_refresh">
<van-swipe-cell v-for="item in resultList" :key="item.name"> <van-list
<div class="result-item" @click="_goto(item)"> v-model="loading"
<div>地点:{{item.placeName}}</div> :finished="finished"
<div>地址:{{item.address}}</div> finished-text="没有更多了"
<div>打卡时间:{{item.attendanceTime}}</div> @load="_load">
<div>打卡地点:{{item.attendanceAddress}}</div> <van-swipe-cell v-for="item in resultList" :key="item.name">
</div> <div class="result-item" @click="_goto(item)">
<template #right> <div>地点:{{item.name}}</div>
<van-button square type="info" text="打卡" class="swipe-cell-btn" <div>地址:{{item.address}}</div>
@click="_getWebLoc"></van-button> <div>打卡时间:{{item.attendanceTime}}</div>
<van-button square type="danger" text="删除" class="swipe-cell-btn"></van-button> <div>打卡地点:{{item.attendanceAddress}}</div>
</template> </div>
</van-swipe-cell> <template #right>
<van-button square type="info" text="打卡" class="swipe-cell-btn"
@click="_getWebLoc"></van-button>
<van-button square type="danger" text="删除" class="swipe-cell-btn"
@click="_delLoc(id)"></van-button>
</template>
</van-swipe-cell>
</van-list>
</van-pull-refresh> </van-pull-refresh>
<div id='container' v-show="false"></div>
</div> </div>
<div class="bottom-btn"> <div class="bottom-btn">
<van-button type="info" block @click="_add">添加地点</van-button> <van-button type="info" block @click="_add">添加地点</van-button>
</div> </div>
<van-popup v-model="showAllLoc">
<SelectLocation @cancel="showAllLoc=false" @refresh="_refresh" ref="allLoc"></SelectLocation>
</van-popup>
</div> </div>
</template> </template>
<script> <script>
import BaiduMap from "../../lib/map.js"; import BaiduMap from '../../lib/map'
import {samplingPlace} from '../../api'
import SelectLocation from './components/SelectLocation'
export default { export default {
name: "SamplingLocation", name: "SamplingLocation",
components: {
SelectLocation
},
data() { data() {
return { return {
resultList: [{placeName: '21'}], showAllLoc: false,
refreshing: false, resultList: [],
planId: this.$route.planId page: 1,
rows: 10,
refreshing: false,//刷新中...
loading: false,//加载中...
finished: false,//没有更多数据
planId: this.$route.query.planId
} }
}, },
mounted() { mounted() {
this._request() this._getData()
}, },
methods: { methods: {
_request: async function () { _refresh() {
// let result = await samplingPlan.getLoc(this.planId) this.showAllLoc = false
// if(result){ this.page = 1
// this.resultList = result.records this._getData()
// this.refreshing =false },
// } _searchParams() {
let data = {
page: this.page,
rows: this.rows,
planId: this.planId
};
return this.$serializeForm(data)
},
_getData: async function () {
let result = await samplingPlace.pageApp(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()
}, },
_add() { _add() {
this.showAllLoc = true
this.$nextTick(function () {
this.$refs.allLoc._open(this.planId)
})
}, },
//获取位置(web)
_getWebLoc() { _getWebLoc() {
let that = this let that = this
that.$nextTick(() => { that.$nextTick(() => {
BaiduMap.init().then(BMap => { BaiduMap.init().then(BMap => {
let geolocation = new BMap.Geolocation() var geolocation = new BMap.Geolocation()
geolocation.getCurrentPosition(function (r) { geolocation.getCurrentPosition(function (r) {
if (this.getStatus() === 'BMAP_STATUS_SUCCESS') { console.log(r)
that.longitude = that.$changeToDFM(r.point.lng, 'E'); // if (this.getStatus() == BMAP_STATUS_SUCCESS) {
that.latitude = that.$changeToDFM(r.point.lat, 'N'); // that.latitude = that.$changeToDFM(r.point.lat, 'N')
that._action(); // that.longitude = that.$changeToDFM(r.point.lng, 'E')
} else { // console.log(r)
alert('获取不到位置信息') // } else {
} // alert('获取不到位置信息')
// }
}, {enableHighAccuracy: true}) }, {enableHighAccuracy: true})
}) })
}) })
...@@ -74,7 +123,14 @@ ...@@ -74,7 +123,14 @@
// + '&latitude=' + encodeURIComponent(this.latitude); // + '&latitude=' + encodeURIComponent(this.latitude);
}, },
_goto(data) { _goto(data) {
this.$router.push({path: '/sampling_task/goods_shelves', query: {id: data.id}}) this.$router.push({path: '/sampling_task/goods_shelves', query: {placeId: data.id}})
},
_delLoc: async function (id) {
let result = await samplingPlace.edit({id: id, obj: {planId: this.planId, selected: 0}})
if (result) {
this.$toast('操作成功!')
this._refresh()
}
}, },
} }
} }
......
<template> <template>
<div> <div>
<search-bar label="计划名称" <search-bar label="计划名称"
ref="searchBar"
highSearch highSearch
@search="_search" @search="_search"
@high-search="_highSearch" @high-search="_highSearch"
...@@ -26,13 +27,13 @@ ...@@ -26,13 +27,13 @@
<van-swipe-cell v-for="item in resultList" :key="item.name"> <van-swipe-cell v-for="item in resultList" :key="item.name">
<div class="result-item" @click="_goto(item)"> <div class="result-item" @click="_goto(item)">
<div>计划名称:{{item.name}}</div> <div>计划名称:{{item.name}}</div>
<div>抽样进度:{{item.completionRatio}}</div> <div>抽样进度:{{item.summaryCount+'/'+item.samplingQuantity}}</div>
<div>状态:{{item.progress}}</div> <div>状态:{{item.progress}}</div>
</div> </div>
<template #right> <template #right>
<van-button square type="info" text="认领" class="swipe-cell-btn" <van-button square type="info" text="认领" class="swipe-cell-btn"
v-if="item.progress==='审批通过'" @click="_receive(item.id)"></van-button> v-if="item.progress==='审批通过'" @click="_receive(item.id)"></van-button>
<van-button square type="danger" text="结束" class="swipe-cell-btn" @click="_finish(item.id)" <van-button square type="danger" text="结束" class="swipe-cell-btn" @click="_finish(item)"
v-else></van-button> v-else></van-button>
</template> </template>
</van-swipe-cell> </van-swipe-cell>
...@@ -145,22 +146,33 @@ ...@@ -145,22 +146,33 @@
if (item.progress === '审批通过') { if (item.progress === '审批通过') {
this.$router.push({path: '/sampling_task/sampling_task_detail', query: {planId: item.id}}) this.$router.push({path: '/sampling_task/sampling_task_detail', query: {planId: item.id}})
} else { } else {
this.$router.push('/sampling_task/sampling_location') this.$router.push({path:'/sampling_task/sampling_location', query: {planId: item.id}})
} }
}, },
_finish(id) { _finish(item) {
//todo if (item.summaryCount === 0) {
this._finishOk(id) this.$dialog.confirm({
title: '提示',
message: '您还未添加抽样单,是否继续?',
}).then(() => {
this._finishOk(item.id)
}).catch(() => {
// on cancel
});
} else {
this._finishOk(item.id)
}
}, },
_finishOk: async function (id) { _finishOk: async function (id) {
let result = await samplingPlan.finish(id) let result = await samplingPlan.acceptFinish({planId: id, type: 2})
if (result) { if (result) {
this.$toast('操作成功!'); this.$toast('操作成功!');
this._refresh() this._refresh()
} }
}, },
_receive: async function (id) { _receive: async function (id) {
let result = await samplingPlan.receive(id) let result = await samplingPlan.acceptFinish({planId: id, type: 1})
if (result) { if (result) {
this.$toast('操作成功!'); this.$toast('操作成功!');
this._refresh() this._refresh()
......
<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" style="margin-top: 54px">
<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.id" 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 {samplingPlan, samplingPlace} from '../../../api'
export default {
name: "SelectLocation",
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.id) === -1) {
this.checkListValue.push(item.id);
} else {
this.checkListValue.splice(this.checkListValue.indexOf(item.id), 1);
}
},
_add() {
if (this.checkListValue.length === 0) {
this.$toast('请至少选择一条数据!')
} else {
this._addOk()
}
},
_addOk: async function () {
let data = {
planId: this.planId,
placeIds: this.checkListValue.join(',')
}
let result = await samplingPlan.savePlace(data)
if (result) {
this.$toast('操作成功')
this.$emit('refresh')
}
},
_cancel() {
this.$emit('cancel')
}
}
}
</script>
<style scoped>
</style>
...@@ -43,6 +43,7 @@ html, body, #app, .main-content-con { ...@@ -43,6 +43,7 @@ html, body, #app, .main-content-con {
height: 100%; height: 100%;
} }
//主要内容 不包括navbar searchbar
.layout-cont { .layout-cont {
width: 100%; width: 100%;
height: calc(100% - 50px); height: calc(100% - 50px);
......
...@@ -13,7 +13,7 @@ module.exports = { ...@@ -13,7 +13,7 @@ module.exports = {
}, },
configureWebpack: { configureWebpack: {
externals: { externals: {
'BAmp': 'BMap' 'BMap': 'BMap'
} }
}, },
css: { css: {
......
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