Commit 1951fb86 by zhuxiaomei

打卡

parent 51b9b2c8
/**
* 双随机抽样计划附件表相关
*/
import http from '../../api/http'
export default {
page: data => http.post('/drs/v1/attendance_record/page', data).then(res => res),
list: data => http.post('/drs/v1/attendance_record/list', data).then(res => res),
add: data => http.post('/drs/v1/attendance_record/', data).then(res => res),
edit: data => http.put('/drs/v1/attendance_record/' + data.id, data.obj).then(res => res),
deleteByIds: data => http.delete('/drs/v1/attendance_record/?ids=' + data.id).then(res => res),
}
...@@ -31,3 +31,4 @@ export {default as samplingPlace} from './drs/sampling-place' ...@@ -31,3 +31,4 @@ export {default as samplingPlace} from './drs/sampling-place'
export {default as samplingShelf} from './drs/sampling-shelf' export {default as samplingShelf} from './drs/sampling-shelf'
export {default as samplingSummary} from './drs/sampling-summary' export {default as samplingSummary} from './drs/sampling-summary'
export {default as samplingPlanAttachment} from './drs/sampling-plan-attachment' export {default as samplingPlanAttachment} from './drs/sampling-plan-attachment'
export {default as attendanceRecord} from './drs/attendance_record'
...@@ -38,6 +38,27 @@ export default { ...@@ -38,6 +38,27 @@ export default {
} }
/** /**
* 将经纬度转化为度分秒的格式
* ****/
Vue.prototype.$changeToDFM = function (du, type) {
let duStr = du.toString()
const arr1 = duStr.split(".");
const d = arr1[0];
let tp = "0." + arr1[1]
tp = String(tp * 60); //这里进行了强制类型转换
const arr2 = tp.split(".");
const f = arr2[0];
tp = "0." + arr2[1];
tp = tp * 60;
let mStr = tp.toString();
const arr3 = mStr.split(".")
const subStr = arr3[1].substring(0, 2)
const m = arr3[0] + "." + subStr;
const dfm = d + "°" + f + "'" + m + "\"" + type;
return dfm;
};
/**
* 全局的配置 * 全局的配置
* @type {{getLogin, logout, baseURL, setToken, setLogin, getToken, version}} * @type {{getLogin, logout, baseURL, setToken, setLogin, getToken, version}}
*/ */
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
</van-list> </van-list>
</van-pull-refresh> </van-pull-refresh>
<div id='container' v-show="false"></div> <div id='map' 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>
...@@ -38,8 +38,7 @@ ...@@ -38,8 +38,7 @@
<script> <script>
import BaiduMap from '../../lib/map' import BaiduMap from '../../lib/map'
import {samplingPlace, attendanceRecord} from '../../api'
import {samplingPlace} from '../../api'
import SelectLocation from './components/SelectLocation' import SelectLocation from './components/SelectLocation'
export default { export default {
...@@ -56,7 +55,9 @@ ...@@ -56,7 +55,9 @@
refreshing: false,//刷新中... refreshing: false,//刷新中...
loading: false,//加载中... loading: false,//加载中...
finished: false,//没有更多数据 finished: false,//没有更多数据
planId: this.$route.query.planId planId: this.$route.query.planId,
latitude: '',
longitude: ''
} }
}, },
mounted() { mounted() {
...@@ -96,31 +97,33 @@ ...@@ -96,31 +97,33 @@
this.$refs.allLoc._open(this.planId) 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 => {
var geolocation = new BMap.Geolocation() var geolocation = new BMap.Geolocation()
geolocation.getCurrentPosition(function (r) { geolocation.getCurrentPosition(function (r) {
console.log(r) if (this.getStatus() == BMAP_STATUS_SUCCESS) {
// if (this.getStatus() == BMAP_STATUS_SUCCESS) { that.latitude = that.$changeToDFM(r.point.lat, 'N')
// that.latitude = that.$changeToDFM(r.point.lat, 'N') that.longitude = that.$changeToDFM(r.point.lng, 'E')
// that.longitude = that.$changeToDFM(r.point.lng, 'E') that._action()
// console.log(r) } else {
// } else { alert('获取不到位置信息')
// alert('获取不到位置信息') }
// }
}, {enableHighAccuracy: true}) }, {enableHighAccuracy: true})
}) })
}) })
}, },
// 打卡 // 打卡
_action() { _action: async function () {
// this.action = Global.baseURL + '/env/v1/point_attachment/upload/?planId=' + this.planId let result = await attendanceRecord.add({
// + '&point=' + encodeURIComponent(this.point) + '&pointCode=' + encodeURIComponent(this.pointCode) planId: this.planId,
// + '&testType=' + encodeURIComponent(this.testType) + '&longitude=' + encodeURIComponent(this.longitude) attendanceAddress: this.latitude + ',' + this.longitude
// + '&latitude=' + encodeURIComponent(this.latitude); })
if (result) {
this.$toast('打卡成功!')
this._refresh()
}
}, },
_goto(data) { _goto(data) {
this.$router.push({path: '/sampling_task/goods_shelves', query: {placeId: data.id}}) this.$router.push({path: '/sampling_task/goods_shelves', query: {placeId: data.id}})
......
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