taskDeatils.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. <template>
  2. <view class="main">
  3. <view class="title">
  4. 任务信息
  5. </view>
  6. <view class="main_box">
  7. <view class="text">
  8. <view class="label">
  9. 管线名称
  10. </view>
  11. <view class="value">
  12. {{dataForm.lineName}}
  13. </view>
  14. </view>
  15. <view class="text">
  16. <view class="label">
  17. 管线单元名称
  18. </view>
  19. <view class="value">
  20. {{dataForm.lineUnitName}}
  21. </view>
  22. </view>
  23. <view class="text">
  24. <view class="label">
  25. 单元长度
  26. </view>
  27. <view class="value">
  28. {{dataForm.totalMileage}}km
  29. </view>
  30. </view>
  31. <view class="text">
  32. <view class="label">
  33. 创建时间
  34. </view>
  35. <view class="value">
  36. {{dataForm.createDate}}
  37. </view>
  38. </view>
  39. </view>
  40. <view class="btns">
  41. <u-button v-if="dataForm.isReceived==='0'" type='error' :plain="true" text="拒绝"
  42. @click="refuseTaskArrange"></u-button>
  43. <u-button v-if="dataForm.isReceived==='1'" type='error' :plain="true" text="取消任务"
  44. @click="cancelTaskArrange"></u-button>
  45. <u-button v-if="dataForm.isReceived==='0'&&isApp" type="primary" text="接受"
  46. @click="receiveTaskArrange"></u-button>
  47. <u-button class="custom-style" v-if="dataForm.isReceived==='6'" type="primary" text="完成"
  48. @click="completeTaskArrange"></u-button>
  49. <span style="margin-left: 15rpx;width: 100%;">
  50. <u-button class="custom-style" type="primary" text="导航到起飞点" @click="toFly"></u-button>
  51. </span>
  52. </view>
  53. </view>
  54. </template>
  55. <script>
  56. export default {
  57. data() {
  58. return {
  59. dataForm: {},
  60. isApp: false,
  61. }
  62. },
  63. onLoad(x) {
  64. //#ifdef APP-PLUS
  65. this.isApp = true
  66. // #endif
  67. this.dataForm = JSON.parse(x.data)
  68. },
  69. methods: {
  70. toFly() {
  71. // 定义目的地的坐标和名称
  72. const latitude = this.dataForm.takeoffLatitude; // 纬度
  73. const longitude = this.dataForm.takeoffLongitude; // 经度
  74. const name = '起飞点'; // 地点名称
  75. const address = '起飞点'; // 地址
  76. // 调用uni.openLocation方法
  77. uni.openLocation({
  78. latitude: Number(latitude), // 目标纬度
  79. longitude: Number(longitude), // 目标经度
  80. name: name, // 地点名称
  81. // address: address, // 详细地址
  82. success: function() {
  83. console.log('成功打开地图');
  84. },
  85. fail: function(err) {
  86. console.error('打开地图失败', err);
  87. }
  88. });
  89. },
  90. refuseTaskArrange() {
  91. this.$api.to_http(`/task/zhkjwurenjitaskarrange/refuseTaskArrange/${this.dataForm.id}`).then((res) => {
  92. if (res.data.code != 0) {
  93. return uni.$u.toast(res.data.msg)
  94. }
  95. uni.showToast({
  96. title: '操作成功',
  97. icon: 'success'
  98. })
  99. setTimeout(() => {
  100. uni.navigateBack(-1)
  101. }, 500)
  102. })
  103. },
  104. cancelTaskArrange() {
  105. this.$api.to_http(`/task/zhkjwurenjitaskarrange/completeTaskArrange/${this.dataForm.id}/${0}`).then((
  106. res) => {
  107. if (res.data.code != 0) {
  108. return uni.$u.toast(res.data.msg)
  109. }
  110. uni.showToast({
  111. title: '操作成功',
  112. icon: 'success'
  113. })
  114. setTimeout(() => {
  115. uni.navigateBack(-1)
  116. }, 500)
  117. })
  118. },
  119. completeTaskArrange() {
  120. this.$api.to_http(`/task/zhkjwurenjitaskarrange/completeTaskArrange/${this.dataForm.id}`).then((res) => {
  121. if (res.data.code != 0) {
  122. return uni.$u.toast(res.data.msg)
  123. }
  124. uni.showToast({
  125. title: '操作成功',
  126. icon: 'success'
  127. })
  128. setTimeout(() => {
  129. uni.navigateBack(-1)
  130. }, 500)
  131. })
  132. },
  133. receiveTaskArrange() {
  134. let info = uni.getStorageSync('userInfo')
  135. let that = this
  136. that.dataForm.receivedUserId = info.id
  137. that.dataForm.receivedUserName = info.realName
  138. if (uni.getSystemInfoSync().platform === 'android' || uni.getSystemInfoSync().platform === 'ios') {
  139. const deviceId = plus.device.uuid;
  140. let mechId = deviceId.split(',')[0]
  141. that.dataForm.deviceId = mechId
  142. that.$api.to_http(`/task/zhkjwurenjitaskarrange/receiveTaskArrange`, that.dataForm, 'post').then((
  143. res) => {
  144. if (res.data.code != 0) {
  145. return uni.$u.toast(res.data.msg)
  146. }
  147. uni.showToast({
  148. title: '操作成功',
  149. icon: 'success'
  150. })
  151. setTimeout(() => {
  152. uni.navigateBack(-1)
  153. }, 500)
  154. })
  155. }
  156. }
  157. }
  158. }
  159. </script>
  160. <style lang="less" scoped>
  161. .btns {
  162. padding: 0 20rpx;
  163. box-sizing: border-box;
  164. position: fixed;
  165. width: 100%;
  166. bottom: 1%;
  167. display: flex;
  168. // grid-gap: 20rpx;
  169. // grid-template-columns: 1fr 1fr;
  170. }
  171. .title {
  172. color: #000;
  173. font-weight: bold;
  174. padding: 10rpx 20rpx;
  175. }
  176. .main_box {
  177. background: #fff;
  178. padding: 0rpx 20rpx;
  179. color: #323233;
  180. .text {
  181. display: flex;
  182. padding: 21rpx 0;
  183. margin: 8rpx 0;
  184. border-bottom: 1px solid rgb(235, 237, 240);
  185. font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Helvetica, Segoe UI, Arial, Roboto, "PingFang SC", "miui", "Hiragino Sans GB", "Microsoft Yahei", sans-serif;
  186. .label {
  187. width: 220rpx;
  188. }
  189. }
  190. }
  191. </style>