|
|
@@ -22,19 +22,36 @@
|
|
|
@confirm="handleModalConfirm" @cancel="handleModalCancel" :asyncClose="true">
|
|
|
</u-modal>
|
|
|
<u-notify ref="uNotify" message=""></u-notify>
|
|
|
+ <u-popup :show="show" @close="close" @open="open" :closeOnClickOverlay="true" :safeAreaInsetTop="true">
|
|
|
+ <view class="task-finished__area">
|
|
|
+ <u--textarea :focus="true" v-model="report_msg" placeholder="" :maxlength="200" autoHeight border="none"
|
|
|
+ style="margin-bottom: 24rpx;">
|
|
|
+ </u--textarea>
|
|
|
+
|
|
|
+ <u-button text="提交" type="primary" size="small" @click="handleSubmit" :disabled="loading"></u-button>
|
|
|
+ </view>
|
|
|
+
|
|
|
+ </u-popup>
|
|
|
</view>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
+ import HeartBeat from '@/util/HeartBeat.js'
|
|
|
import * as taskService from '@/service/task.js';
|
|
|
import {
|
|
|
- TASK_ACTION_TYPE
|
|
|
+ TASK_ACTION_TYPE,
|
|
|
+ TASK_WALK_TYPE
|
|
|
} from '@/util/constants.js';
|
|
|
import {
|
|
|
assign,
|
|
|
- concat
|
|
|
+ concat,
|
|
|
} from 'lodash-es';
|
|
|
|
|
|
+ import {
|
|
|
+ mapState,
|
|
|
+ mapActions
|
|
|
+ } from 'vuex'
|
|
|
+
|
|
|
export default {
|
|
|
data() {
|
|
|
return {
|
|
|
@@ -64,15 +81,22 @@
|
|
|
taskList: [],
|
|
|
confirmModalVisible: false,
|
|
|
content: '确认接收次任务?',
|
|
|
- currentTaskID: ''
|
|
|
+ currentTaskID: '',
|
|
|
+ _heartBeat: null,
|
|
|
+ isUpdateLocation: false,
|
|
|
+ logs: [],
|
|
|
+ show: false,
|
|
|
+ report_msg: ''
|
|
|
}
|
|
|
},
|
|
|
onShow() {
|
|
|
|
|
|
},
|
|
|
+ onReady() {
|
|
|
+ this._heartBeat = HeartBeat.getInstance(this.recordRatio);
|
|
|
+ },
|
|
|
onLoad() {},
|
|
|
onReachBottom() {
|
|
|
- console.log('each bottom ------- 12')
|
|
|
const hasMore = this.total > 0 && this.toal > this.page * this.pageSize
|
|
|
|
|
|
if (hasMore) {
|
|
|
@@ -99,9 +123,13 @@
|
|
|
|
|
|
},
|
|
|
computed: {
|
|
|
+ ...mapState({
|
|
|
+ recordRatio: state => state.task.ratio
|
|
|
+ }),
|
|
|
offsetLeft() {
|
|
|
return
|
|
|
- }
|
|
|
+ },
|
|
|
+
|
|
|
},
|
|
|
onShow() {
|
|
|
this.page = 1;
|
|
|
@@ -109,6 +137,7 @@
|
|
|
this.getTaskList();
|
|
|
},
|
|
|
methods: {
|
|
|
+ ...mapActions(['addLocationData']),
|
|
|
click(item) {
|
|
|
console.log('item', item);
|
|
|
},
|
|
|
@@ -138,7 +167,7 @@
|
|
|
switch (type) {
|
|
|
case TASK_ACTION_TYPE.START:
|
|
|
case TASK_ACTION_TYPE.PAUSE:
|
|
|
- case TASK_ACTION_TYPE.FINISHED:
|
|
|
+ case TASK_ACTION_TYPE.RESTART:
|
|
|
this.updateWalkStatus(type, taskID);
|
|
|
break;
|
|
|
case TASK_ACTION_TYPE.CLOCK:
|
|
|
@@ -146,6 +175,10 @@
|
|
|
url: '/pages/index/clockDetail?taskID=' + taskID
|
|
|
})
|
|
|
break;
|
|
|
+ case TASK_ACTION_TYPE.FINISHED:
|
|
|
+ this.currentTaskID = taskID;
|
|
|
+ this.show = true;
|
|
|
+ break;
|
|
|
}
|
|
|
},
|
|
|
updateWalkStatus(type, taskID) {
|
|
|
@@ -156,6 +189,9 @@
|
|
|
case TASK_ACTION_TYPE.START:
|
|
|
message = '任务已经开始';
|
|
|
break;
|
|
|
+ case TASK_ACTION_TYPE.RESTART:
|
|
|
+ message = '继续记录';
|
|
|
+ break;
|
|
|
case TASK_ACTION_TYPE.PAUSE:
|
|
|
message = '任务暂停成功';
|
|
|
break;
|
|
|
@@ -164,32 +200,85 @@
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
- this.$refs.uNotify.show({
|
|
|
- top: 10,
|
|
|
- type: 'success',
|
|
|
- message,
|
|
|
- duration: 1000 * 3,
|
|
|
- fontSize: 16,
|
|
|
- safeAreaInsetTop: true
|
|
|
+ const payload = {
|
|
|
+ task_id: taskID,
|
|
|
+ action: type
|
|
|
+ }
|
|
|
+ console.warn('update status', payload)
|
|
|
+ this.loading = true;
|
|
|
+ taskService.updateTaskWalkStatus(payload).then(() => {
|
|
|
+ this.$refs.uNotify.show({
|
|
|
+ top: 10,
|
|
|
+ type: 'success',
|
|
|
+ message,
|
|
|
+ duration: 1000 * 3,
|
|
|
+ fontSize: 16,
|
|
|
+ safeAreaInsetTop: true
|
|
|
+ })
|
|
|
+ this.getTaskList();
|
|
|
+ // 处理轨迹坐标点
|
|
|
+ this.updateRecordLocation(type, taskID);
|
|
|
+
|
|
|
+ }).finally(() => {
|
|
|
+ this.loading = false;
|
|
|
+ })
|
|
|
+ },
|
|
|
+ updateRecordLocation(type, taskID) {
|
|
|
+ switch (type) {
|
|
|
+ case TASK_ACTION_TYPE.START:
|
|
|
+ case TASK_ACTION_TYPE.RESTART:
|
|
|
+ this.isUpdateLocation = true;
|
|
|
+ this._heartBeat.handle({
|
|
|
+ type: 'record_' + taskID,
|
|
|
+ data: {
|
|
|
+ taskID
|
|
|
+ },
|
|
|
+ handler: this.getLocation
|
|
|
+ })
|
|
|
+ break;
|
|
|
+ case TASK_ACTION_TYPE.PAUSE:
|
|
|
+ case TASK_ACTION_TYPE.FINISHED:
|
|
|
+ this.isUpdateLocation = false;
|
|
|
+
|
|
|
+ this._heartBeat.clearByType('record_' + taskID)
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ },
|
|
|
+ getLocation({
|
|
|
+ taskID
|
|
|
+ }) {
|
|
|
+ return new Promise((resolve, reject) => {
|
|
|
+ console.log('getlocation start', this.isUpdateLocation)
|
|
|
+ if (!this.isUpdateLocation) {
|
|
|
+ console.log('getlocation start 1 close')
|
|
|
+ resolve(true)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ console.log('getlocation start 2 exec')
|
|
|
+
|
|
|
+ uni.getLocation({
|
|
|
+ type: 'gcj02',
|
|
|
+ success: (res) => {
|
|
|
+ console.log('当前位置的经度:' + res.longitude);
|
|
|
+ console.log('当前位置的纬度:' + res.latitude);
|
|
|
+ this.logs.push(`记录中:当前位置的经度${res.longitude};当前位置的纬度${res.latitude}`)
|
|
|
+ this.addLocationData({
|
|
|
+ id: Date.now(),
|
|
|
+ taskID,
|
|
|
+ latitude: res.latitude,
|
|
|
+ longitude: res.longitude
|
|
|
+ })
|
|
|
+
|
|
|
+ resolve(false)
|
|
|
+ },
|
|
|
+ fail(err) {
|
|
|
+ console.warn(err, 'get location error')
|
|
|
+ }
|
|
|
+ });
|
|
|
})
|
|
|
- // this.loading = true;
|
|
|
- // taskService.updateTaskWalkStatus({
|
|
|
- // task_id: taskID,
|
|
|
- // action: type
|
|
|
- // }).then(() => {
|
|
|
- // this.$refs.uNotify.show({
|
|
|
- // top: 10,
|
|
|
- // type: 'error',
|
|
|
- // color: '#000',
|
|
|
- // bgColor: '#e8e8e8',
|
|
|
- // message: 'Hi uView',
|
|
|
- // duration: 1000 * 3,
|
|
|
- // fontSize: 20,
|
|
|
- // safeAreaInsetTop: true
|
|
|
- // })
|
|
|
- // }).finally(() => {
|
|
|
- // this.loading = false;
|
|
|
- // })
|
|
|
+
|
|
|
},
|
|
|
resetTaskList() {
|
|
|
this.page = 1;
|
|
|
@@ -205,13 +294,28 @@
|
|
|
start_time: this
|
|
|
.start_time, // 非必填 开始时间
|
|
|
end_time: this.end_time,
|
|
|
- operator_user_name: this.name
|
|
|
+ operator_user_name: this.searchKey
|
|
|
};
|
|
|
|
|
|
taskService.getTaskList(payload).then(res => {
|
|
|
console.log(res, 'get task list')
|
|
|
this.taskList = this.page === 1 ? res.page_list : concat(this.taskList, res.page_list);
|
|
|
this.total = this.total_item;
|
|
|
+
|
|
|
+ res.page_list.forEach(item => {
|
|
|
+ if (item.walk_status === TASK_WALK_TYPE.IS_RECORDING) {
|
|
|
+ this.isUpdateLocation = true;
|
|
|
+ if (!this._heartBeat.hasType('record_' + item.task_id)) {
|
|
|
+ this._heartBeat.handle({
|
|
|
+ type: 'record_' + item.task_id,
|
|
|
+ data: {
|
|
|
+ taskID: item.task_id
|
|
|
+ },
|
|
|
+ handler: this.getLocation
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
console.warn(this.taskList, 'task list 1345555')
|
|
|
}).finally(() => {
|
|
|
this.loading = false;
|
|
|
@@ -240,6 +344,32 @@
|
|
|
this.currentTaskID = '';
|
|
|
this.confirmModalVisible = false;
|
|
|
},
|
|
|
+ open() {
|
|
|
+ console.log('open');
|
|
|
+ },
|
|
|
+ close() {
|
|
|
+ this.show = false
|
|
|
+ console.log('close');
|
|
|
+ },
|
|
|
+ handleSubmit() {
|
|
|
+ if (!this.report_msg) {
|
|
|
+ uni.$u.toast('请输入描述');
|
|
|
+ return
|
|
|
+ }
|
|
|
+ this.loading = true;
|
|
|
+ taskService.taskSubmit({
|
|
|
+ task_id: this.currentTaskID,
|
|
|
+ report_msg: this.report_msg
|
|
|
+ }).then(res=>{
|
|
|
+ uni.$u.toast('提交成功');
|
|
|
+ // this.updateWalkStatus(TASK_ACTION_TYPE.FINISHED,this.currentTaskID);
|
|
|
+ this.getTaskList();
|
|
|
+ this.currentTaskID = '';
|
|
|
+ }).finally(()=>{
|
|
|
+ this.show = false;
|
|
|
+ this.loading = false
|
|
|
+ })
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
</script>
|
|
|
@@ -333,6 +463,12 @@
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ .task-finished {
|
|
|
+ &__area {
|
|
|
+ padding: 24rpx;
|
|
|
+ }
|
|
|
+ }
|
|
|
</style>
|
|
|
<style>
|
|
|
page {
|