Files
hht-weibang-uni/pages/wb/taskmanage.vue
2025-11-07 11:26:05 +08:00

111 lines
2.5 KiB
Vue

<template>
<view class="zd_container">
<!-- 任务管理 -->
<nav-bar :title="title"></nav-bar>
<view class="zd_content">
<view class="zd_wrapper grid-wraper">
<view class="slide_new">
<table>
<thead>
<tr>
<th>任务号</th>
<th>起点</th>
<th>终点</th>
<th>状态</th>
<th>优先级</th>
<th>时间</th>
</tr>
</thead>
<tbody>
<tr v-for="(e, i) in dataList" :key="i" :class="{'checked': e.task_uuid === pkId}" @tap="toCheck(e)">
<td>{{e.task_no}}</td>
<td>{{e.start_devicecode}}</td>
<td>{{e.next_devicecode}}</td>
<td>{{e.task_status_name}}</td>
<td>{{e.priority}}</td>
<td>{{e.create_time}}</td>
</tr>
</tbody>
</table>
</view>
</view>
</view>
<view class="zd-row submit-bar">
<button class="zd-col-11 button-primary" :class="{'button-info': !pkId}" :disabled="disabled" @tap="_taskoperation(1)">重新下发</button>
<button class="zd-col-11 button-primary" :class="{'button-info': !pkId}" :disabled="disabled" @tap="_taskoperation(2)">完成任务</button>
</view>
</view>
</template>
<script>
import NavBar from '@/components/NavBar.vue'
import SearchBox from '@/components/SearchBox.vue'
import {querytasks, taskoperation} from '@/utils/getData3.js'
export default {
components: {
NavBar,
SearchBox
},
data() {
return {
title: '',
pkId: '',
disabled: false,
dataList: []
};
},
onLoad (options) {
this.title = options.title
this._querytasks()
},
methods: {
toCheck (e) {
this.pkId = this.pkId === e.task_uuid ? '' : e.task_uuid
},
async _querytasks () {
try {
let res = await querytasks()
if (res && res.data) {
this.dataList = [...res.data]
} else {
this.dataList = []
uni.showToast({
title: res.message,
icon: 'none'
})
}
} catch (e) {
this.dataList = []
}
},
async _taskOperation (type) {
this.disabled = true
if (!this.pkId) {
this.disabled = false
return
}
try {
let res = await taskOperation(this.pkId, type)
if (res) {
this._queryTask()
uni.showToast({
title: res.message,
icon: 'none'
})
}
this.disabled = false
this.pkId = ''
} catch (err) {
this.disabled = false
this.pkId = ''
}
}
}
}
</script>
<style scoped>
.filter_picker {
text-align: center
}
</style>